summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/yuv2rgb.c
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opieplayer2/yuv2rgb.c') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/yuv2rgb.c436
1 files changed, 273 insertions, 163 deletions
diff --git a/noncore/multimedia/opieplayer2/yuv2rgb.c b/noncore/multimedia/opieplayer2/yuv2rgb.c
index 8e34052..487ed20 100644
--- a/noncore/multimedia/opieplayer2/yuv2rgb.c
+++ b/noncore/multimedia/opieplayer2/yuv2rgb.c
@@ -1,16 +1,17 @@
/*
* yuv2rgb.c
*
- * This file is part of xine, a unix video player.
+ * Copyright (C) 2003-2004 the xine project
+ * This file is part of xine, a free video player.
*
* based on work from mpeg2dec:
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
@@ -22,96 +23,154 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "yuv2rgb.h"
-#include <xine/xineutils.h>
+#define LOG_MODULE "yuv2rgb"
+#define LOG_VERBOSE
+/*
+#define LOG
+*/
+
+#include <xine/xineutils.h>
static int prof_scale_line = -1;
static scale_line_func_t find_scale_line_func(int step);
const int32_t Inverse_Table_6_9[8][4] = {
{117504, 138453, 13954, 34903}, /* no sequence_display_extension */
{117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
{104597, 132201, 25675, 53279}, /* unspecified */
{104597, 132201, 25675, 53279}, /* reserved */
{104448, 132798, 24759, 53109}, /* FCC */
{104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */
{104597, 132201, 25675, 53279}, /* SMPTE 170M */
{117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */
};
-static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) {
-
+static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk)
+{
char *pMem;
pMem = xine_xmalloc (size+alignment);
*chunk = pMem;
- while ((int) pMem % alignment)
+ while ((uintptr_t) pMem % alignment)
pMem++;
return pMem;
}
+static int yuv2rgb_next_slice (yuv2rgb_t *this, uint8_t **dest)
+{
+ int y0, y1;
+
+ if (dest == NULL) {
+ this->slice_offset = 0;
+ this->slice_height = 16;
+ return 0;
+ }
+ if (this->slice_height == this->source_height) {
+ return this->dest_height;
+ }
+
+ y0 = (this->slice_offset * this->dest_height) / this->source_height;
+ y1 = ((this->slice_offset + this->slice_height) * this->dest_height) / this->source_height;
+ *dest += (this->rgb_stride * y0);
+
+ if ((this->slice_offset + this->slice_height) >= this->source_height) {
+ this->slice_offset = 0;
+ return (this->dest_height - y0);
+ } else {
+ this->slice_offset += this->slice_height;
+ return (y1 - y0);
+ }
+}
+
+static void yuv2rgb_dispose (yuv2rgb_t *this)
+{
+ free (this->y_chunk);
+ free (this->u_chunk);
+ free (this->v_chunk);
+#ifdef HAVE_MLIB
+ free (this->mlib_chunk);
+#endif
+ free (this);
+}
+
static int yuv2rgb_configure (yuv2rgb_t *this,
int source_width, int source_height,
int y_stride, int uv_stride,
int dest_width, int dest_height,
int rgb_stride) {
/*
printf ("yuv2rgb setup (%d x %d => %d x %d)\n", source_width, source_height,
dest_width, dest_height);
*/
if (prof_scale_line == -1)
prof_scale_line = xine_profiler_allocate_slot("xshm scale line");
this->source_width = source_width;
this->source_height = source_height;
this->y_stride = y_stride;
this->uv_stride = uv_stride;
this->dest_width = dest_width;
this->dest_height = dest_height;
this->rgb_stride = rgb_stride;
+ this->slice_height = source_height;
+ this->slice_offset = 0;
if (this->y_chunk) {
free (this->y_chunk);
this->y_buffer = this->y_chunk = NULL;
}
if (this->u_chunk) {
free (this->u_chunk);
this->u_buffer = this->u_chunk = NULL;
}
if (this->v_chunk) {
free (this->v_chunk);
this->v_buffer = this->v_chunk = NULL;
}
+#ifdef HAVE_MLIB
+ if (this->mlib_chunk) {
+ free (this->mlib_chunk);
+ this->mlib_buffer = this->mlib_chunk = NULL;
+ }
+ if (this->mlib_resize_chunk) {
+ free (this->mlib_resize_chunk);
+ this->mlib_resize_buffer = this->mlib_resize_chunk = NULL;
+ }
+#endif
this->step_dx = source_width * 32768 / dest_width;
this->step_dy = source_height * 32768 / dest_height;
-
+/*
+ printf("yuv2rgb config: src_ht=%i, dst_ht=%i\n",source_height, dest_height);
+ printf("yuv2rgb config: step_dy=%i %f\n",this->step_dy, (float)this->step_dy / 32768.0);
+*/
this->scale_line = find_scale_line_func(this->step_dx);
if ((source_width == dest_width) && (source_height == dest_height)) {
this->do_scale = 0;
/*
* space for two y-lines (for yuv2rgb_mlib)
* u,v subsampled 2:1
*/
this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk);
if (!this->y_buffer)
return 0;
@@ -129,29 +188,41 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
* space for two y-lines (for yuv2rgb_mlib)
* u,v subsampled 2:1
*/
this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk);
if (!this->y_buffer)
return 0;
this->u_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->u_chunk);
if (!this->u_buffer)
return 0;
this->v_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->v_chunk);
if (!this->v_buffer)
return 0;
+
+#if HAVE_MLIB
+ /* Only need these if we are resizing and in mlib code */
+ this->mlib_buffer = my_malloc_aligned (16, source_width*source_height*4, &this->mlib_chunk);
+ if (!this->mlib_buffer)
+ return 0;
+ /* Only need this one if we are 24 bit */
+ if((rgb_stride / dest_width) == 3) {
+ this->mlib_resize_buffer = my_malloc_aligned (16, dest_width*dest_height*4, &this->mlib_resize_chunk);
+ if (!this->mlib_resize_buffer)
+ return 0;
+ }
+#endif
}
return 1;
}
-
static void scale_line_gen (uint8_t *source, uint8_t *dest,
int width, int step) {
/*
* scales a yuv source row to a dest row, with interpolation
* (good quality, but slow)
*/
int p1;
int p2;
int dx;
xine_profiler_start_count(prof_scale_line);
@@ -1195,34 +1266,47 @@ static scale_line_func_t find_scale_line_func(int step) {
{ 15, 16, scale_line_15_16, "dvd 4:3(pal)" },
{ 45, 64, scale_line_45_64, "dvd 16:9(pal), fullscreen(1024x768)" },
{ 9, 16, scale_line_9_16, "dvd fullscreen(1280x1024)" },
{ 45, 53, scale_line_45_53, "dvd 16:9(ntsc)" },
{ 11, 12, scale_line_11_12, "vcd 4:3(pal)" },
{ 11, 24, scale_line_11_24, "vcd 4:3(pal) 2*zoom" },
{ 5, 8, scale_line_5_8, "svcd 4:3(pal)" },
{ 3, 4, scale_line_3_4, "svcd 4:3(ntsc)" },
{ 1, 2, scale_line_1_2, "2*zoom" },
{ 1, 1, scale_line_1_1, "non-scaled" },
};
int i;
+#ifdef LOG
+ /* to filter out multiple messages about the scale_line variant we're using */
+ static int reported_for_step;
+#endif
for (i = 0; i < sizeof(scale_line)/sizeof(scale_line[0]); i++) {
if (step == scale_line[i].src_step*32768/scale_line[i].dest_step) {
- //printf("yuv2rgb: using %s optimized scale_line\n", scale_line[i].desc);
+#ifdef LOG
+ if (step != reported_for_step)
+ printf("yuv2rgb: using %s optimized scale_line\n", scale_line[i].desc);
+ reported_for_step = step;
+#endif
return scale_line[i].func;
}
}
- //printf("yuv2rgb: using generic scale_line with interpolation\n");
- return scale_line_gen;
+#ifdef LOG
+ if (step != reported_for_step)
+ printf("yuv2rgb: using generic scale_line with interpolation\n");
+ reported_for_step = step;
+#endif
+
+ return scale_line_gen;
}
static void scale_line_2 (uint8_t *source, uint8_t *dest,
int width, int step) {
int p1;
int p2;
int dx;
p1 = *source; source+=2;
p2 = *source; source+=2;
dx = 0;
@@ -1263,25 +1347,25 @@ static void scale_line_4 (uint8_t *source, uint8_t *dest,
dx -= 32768;
p1 = p2;
p2 = *source;
source+=4;
}
dest ++;
width --;
}
}
-#define RGB(i) \
+#define X_RGB(i) \
U = pu[i]; \
V = pv[i]; \
r = this->table_rV[V]; \
g = (void *) (((uint8_t *)this->table_gU[U]) + this->table_gV[V]); \
b = this->table_bU[U];
#define DST1(i) \
Y = py_1[2*i]; \
dst_1[2*i] = r[Y] + g[Y] + b[Y]; \
Y = py_1[2*i+1]; \
dst_1[2*i+1] = r[Y] + g[Y] + b[Y];
@@ -1339,45 +1423,45 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (height = 0;; ) {
dst_1 = (uint32_t*)_dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1(0);
- RGB(1);
+ X_RGB(1);
DST1(1);
- RGB(2);
+ X_RGB(2);
DST1(2);
- RGB(3);
+ X_RGB(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
@@ -1403,48 +1487,48 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
_pv += this->uv_stride;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
}
height++;
} while( dy>=32768);
}
} else {
- height = this->source_height >> 1;
+ height = this->next_slice (this, &_dst) >> 1;
do {
dst_1 = (uint32_t*)_dst;
dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
py_1 = _py;
py_2 = _py + this->y_stride;
pu = _pu;
pv = _pv;
width = this->source_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1(0);
DST2(0);
- RGB(1);
+ X_RGB(1);
DST2(1);
DST1(1);
- RGB(2);
+ X_RGB(2);
DST1(2);
DST2(2);
- RGB(3);
+ X_RGB(3);
DST2(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 8;
dst_2 += 8;
} while (--width);
_dst += 2 * this->rgb_stride;
@@ -1470,45 +1554,45 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (height = 0;; ) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1RGB(0);
- RGB(1);
+ X_RGB(1);
DST1RGB(1);
- RGB(2);
+ X_RGB(2);
DST1RGB(2);
- RGB(3);
+ X_RGB(3);
DST1RGB(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 24;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
@@ -1534,48 +1618,48 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
_pv += this->uv_stride;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
}
height++;
} while (dy>=32768);
}
} else {
- height = this->source_height >> 1;
+ height = this->next_slice (this, &_dst) >> 1;
do {
dst_1 = _dst;
dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
py_1 = _py;
py_2 = _py + this->y_stride;
pu = _pu;
pv = _pv;
width = this->source_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1RGB(0);
DST2RGB(0);
- RGB(1);
+ X_RGB(1);
DST2RGB(1);
DST1RGB(1);
- RGB(2);
+ X_RGB(2);
DST1RGB(2);
DST2RGB(2);
- RGB(3);
+ X_RGB(3);
DST2RGB(3);
DST1RGB(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 24;
dst_2 += 24;
} while (--width);
_dst += 2 * this->rgb_stride;
@@ -1601,45 +1685,45 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (height = 0;; ) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1BGR(0);
- RGB(1);
+ X_RGB(1);
DST1BGR(1);
- RGB(2);
+ X_RGB(2);
DST1BGR(2);
- RGB(3);
+ X_RGB(3);
DST1BGR(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 24;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
@@ -1666,47 +1750,47 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
}
height++;
} while( dy>=32768 );
}
} else {
- height = this->source_height >> 1;
+ height = this->next_slice (this, &_dst) >> 1;
do {
dst_1 = _dst;
dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
py_1 = _py;
py_2 = _py + this->y_stride;
pu = _pu;
pv = _pv;
width = this->source_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1BGR(0);
DST2BGR(0);
- RGB(1);
+ X_RGB(1);
DST2BGR(1);
DST1BGR(1);
- RGB(2);
+ X_RGB(2);
DST1BGR(2);
DST2BGR(2);
- RGB(3);
+ X_RGB(3);
DST2BGR(3);
DST1BGR(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 24;
dst_2 += 24;
} while (--width);
_dst += 2 * this->rgb_stride;
@@ -1732,45 +1816,45 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (height = 0;; ) {
dst_1 = (uint16_t*)_dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1(0);
- RGB(1);
+ X_RGB(1);
DST1(1);
- RGB(2);
+ X_RGB(2);
DST1(2);
- RGB(3);
+ X_RGB(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
@@ -1796,47 +1880,47 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
_pv += this->uv_stride;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
}
height++;
} while( dy>=32768);
}
} else {
- height = this->source_height >> 1;
+ height = this->next_slice (this, &_dst) >> 1;
do {
dst_1 = (uint16_t*)_dst;
dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
py_1 = _py;
py_2 = _py + this->y_stride;
pu = _pu;
pv = _pv;
width = this->source_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1(0);
DST2(0);
- RGB(1);
+ X_RGB(1);
DST2(1);
DST1(1);
- RGB(2);
+ X_RGB(2);
DST1(2);
DST2(2);
- RGB(3);
+ X_RGB(3);
DST2(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 8;
dst_2 += 8;
} while (--width);
_dst += 2 * this->rgb_stride;
@@ -1862,45 +1946,45 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (height = 0;; ) {
dst_1 = (uint8_t*)_dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1(0);
- RGB(1);
+ X_RGB(1);
DST1(1);
- RGB(2);
+ X_RGB(2);
DST1(2);
- RGB(3);
+ X_RGB(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
@@ -1926,48 +2010,48 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
_pv += this->uv_stride;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
}
height++;
} while( dy>=32768 );
}
} else {
- height = this->source_height >> 1;
+ height = this->next_slice (this, &_dst) >> 1;
do {
dst_1 = (uint8_t*)_dst;
dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
py_1 = _py;
py_2 = _py + this->y_stride;
pu = _pu;
pv = _pv;
width = this->source_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1(0);
DST2(0);
- RGB(1);
+ X_RGB(1);
DST2(1);
DST1(1);
- RGB(2);
+ X_RGB(2);
DST1(2);
DST2(2);
- RGB(3);
+ X_RGB(3);
DST2(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 8;
dst_2 += 8;
} while (--width);
_dst += 2 * this->rgb_stride;
@@ -1981,25 +2065,25 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
/* now for something different: 256 grayscale mode */
static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst,
uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
{
int height, dst_height;
int dy;
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (;;) {
scale_line (_py, _dst, this->dest_width, this->step_dx);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
dy += this->step_dy;
@@ -2007,25 +2091,25 @@ static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst,
}
if (dst_height <= 0)
break;
_py += this->y_stride*(dy>>15);
dy &= 32767;
/* dy -= 32768;
_py += this->y_stride;
*/
}
} else {
- for (height = this->source_height; --height >= 0; ) {
+ for (height = this->next_slice (this, &_dst); --height >= 0; ) {
xine_fast_memcpy(_dst, _py, this->dest_width);
_dst += this->rgb_stride;
_py += this->y_stride;
}
}
}
/* now for something different: 256 color mode */
static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
{
int U, V, Y;
@@ -2037,45 +2121,45 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (height = 0;; ) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1CMAP(0);
- RGB(1);
+ X_RGB(1);
DST1CMAP(1);
- RGB(2);
+ X_RGB(2);
DST1CMAP(2);
- RGB(3);
+ X_RGB(3);
DST1CMAP(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
@@ -2101,47 +2185,47 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
_pv += this->uv_stride;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
}
height++;
} while( dy>=32768 );
}
} else {
- height = this->source_height >> 1;
+ height = this->next_slice (this, &_dst) >> 1;
do {
dst_1 = _dst;
dst_2 = _dst + this->rgb_stride;
py_1 = _py;
py_2 = _py + this->y_stride;
pu = _pu;
pv = _pv;
width = this->source_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1CMAP(0);
DST2CMAP(0);
- RGB(1);
+ X_RGB(1);
DST2CMAP(1);
DST1CMAP(1);
- RGB(2);
+ X_RGB(2);
DST1CMAP(2);
DST2CMAP(2);
- RGB(3);
+ X_RGB(3);
DST2CMAP(3);
DST1CMAP(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 8;
dst_2 += 8;
} while (--width);
_dst += 2 * this->rgb_stride;
@@ -2152,52 +2236,59 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
} while (--height);
}
}
static int div_round (int dividend, int divisor)
{
if (dividend > 0)
return (dividend + (divisor>>1)) / divisor;
else
return -((-dividend + (divisor>>1)) / divisor);
}
-static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped)
+static void yuv2rgb_set_csc_levels (yuv2rgb_factory_t *this,
+ int brightness, int contrast, int saturation)
{
int i;
uint8_t table_Y[1024];
uint32_t * table_32 = 0;
uint16_t * table_16 = 0;
uint8_t * table_8 = 0;
int entry_size = 0;
void *table_r = 0, *table_g = 0, *table_b = 0;
int shift_r = 0, shift_g = 0, shift_b = 0;
int crv = Inverse_Table_6_9[this->matrix_coefficients][0];
int cbu = Inverse_Table_6_9[this->matrix_coefficients][1];
int cgu = -Inverse_Table_6_9[this->matrix_coefficients][2];
int cgv = -Inverse_Table_6_9[this->matrix_coefficients][3];
+ int mode = this->mode;
+ int swapped = this->swapped;
+
for (i = 0; i < 1024; i++) {
int j;
- j = (76309 * (i - 384 - 16) + 32768) >> 16;
+ j = (76309 * (i - 384 - 16 + brightness) + 32768) >> 16;
j = (j < 0) ? 0 : ((j > 255) ? 255 : j);
table_Y[i] = j;
}
switch (mode) {
case MODE_32_RGB:
case MODE_32_BGR:
- table_32 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t));
+ if (this->table_base == NULL) {
+ this->table_base = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t));
+ }
+ table_32 = this->table_base;
entry_size = sizeof (uint32_t);
table_r = table_32 + 197;
table_b = table_32 + 197 + 685;
table_g = table_32 + 197 + 2*682;
if (swapped) {
switch (mode) {
case MODE_32_RGB: shift_r = 8; shift_g = 16; shift_b = 24; break;
case MODE_32_BGR: shift_r = 24; shift_g = 16; shift_b = 8; break;
}
} else {
@@ -2208,38 +2299,44 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
}
for (i = -197; i < 256+197; i++)
((uint32_t *) table_r)[i] = table_Y[i+384] << shift_r;
for (i = -132; i < 256+132; i++)
((uint32_t *) table_g)[i] = table_Y[i+384] << shift_g;
for (i = -232; i < 256+232; i++)
((uint32_t *) table_b)[i] = table_Y[i+384] << shift_b;
break;
case MODE_24_RGB:
case MODE_24_BGR:
- table_8 = malloc ((256 + 2*232) * sizeof (uint8_t));
+ if (this->table_base == NULL) {
+ this->table_base = malloc ((256 + 2*232) * sizeof (uint8_t));
+ }
+ table_8 = this->table_base;
entry_size = sizeof (uint8_t);
table_r = table_g = table_b = table_8 + 232;
for (i = -232; i < 256+232; i++)
((uint8_t * )table_b)[i] = table_Y[i+384];
break;
case MODE_15_BGR:
case MODE_16_BGR:
case MODE_15_RGB:
case MODE_16_RGB:
- table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
+ if (this->table_base == NULL) {
+ this->table_base = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
+ }
+ table_16 = this->table_base;
entry_size = sizeof (uint16_t);
table_r = table_16 + 197;
table_b = table_16 + 197 + 685;
table_g = table_16 + 197 + 2*682;
if (swapped) {
switch (mode) {
case MODE_15_BGR: shift_r = 8; shift_g = 5; shift_b = 2; break;
case MODE_16_BGR: shift_r = 8; shift_g = 5; shift_b = 3; break;
case MODE_15_RGB: shift_r = 2; shift_g = 5; shift_b = 8; break;
case MODE_16_RGB: shift_r = 3; shift_g = 5; shift_b = 8; break;
@@ -2261,87 +2358,95 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
if (swapped)
((uint16_t *)table_g)[i] = (j&7) << 13 | (j>>3);
else
((uint16_t *)table_g)[i] = j << 5;
}
for (i = -232; i < 256+232; i++)
((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << shift_b;
break;
case MODE_8_RGB:
case MODE_8_BGR:
- table_8 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
+ if (this->table_base == NULL) {
+ this->table_base = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
+ }
+ table_8 = this->table_base;
entry_size = sizeof (uint8_t);
table_r = table_8 + 197;
table_b = table_8 + 197 + 685;
table_g = table_8 + 197 + 2*682;
switch (mode) {
case MODE_8_RGB: shift_r = 5; shift_g = 2; shift_b = 0; break;
case MODE_8_BGR: shift_r = 0; shift_g = 3; shift_b = 6; break;
}
for (i = -197; i < 256+197; i++)
((uint8_t *) table_r)[i] = (table_Y[i+384] >> 5) << shift_r;
for (i = -132; i < 256+132; i++)
((uint8_t *) table_g)[i] = (table_Y[i+384] >> 5) << shift_g;
for (i = -232; i < 256+232; i++)
((uint8_t *) table_b)[i] = (table_Y[i+384] >> 6) << shift_b;
break;
case MODE_8_GRAY:
return;
case MODE_PALETTE:
- table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
+ if (this->table_base == NULL) {
+ this->table_base = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
+ }
+ table_16 = this->table_base;
entry_size = sizeof (uint16_t);
table_r = table_16 + 197;
table_b = table_16 + 197 + 685;
table_g = table_16 + 197 + 2*682;
shift_r = 10;
shift_g = 5;
shift_b = 0;
for (i = -197; i < 256+197; i++)
((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << 10;
for (i = -132; i < 256+132; i++)
((uint16_t *)table_g)[i] = (table_Y[i+384] >> 3) << 5;
for (i = -232; i < 256+232; i++)
((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << 0;
break;
default:
- fprintf (stderr, "mode %d not supported by yuv2rgb\n", mode);
- abort();
+ lprintf ("mode %d not supported by yuv2rgb\n", mode);
+ _x_abort();
}
for (i = 0; i < 256; i++) {
this->table_rV[i] = (((uint8_t *) table_r) +
entry_size * div_round (crv * (i-128), 76309));
this->table_gU[i] = (((uint8_t *) table_g) +
entry_size * div_round (cgu * (i-128), 76309));
this->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309);
this->table_bU[i] = (((uint8_t *)table_b) +
entry_size * div_round (cbu * (i-128), 76309));
}
- this->gamma = 0;
- this->entry_size = entry_size;
+
+#if defined(ARCH_X86) || defined(ARCH_X86_64)
+ mmx_yuv2rgb_set_csc_levels (this, brightness, contrast, saturation);
+#endif
}
static uint32_t yuv2rgb_single_pixel_32 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
{
uint32_t * r, * g, * b;
r = this->table_rV[v];
g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
b = this->table_bU[u];
return r[y] + g[y] + b[y];
}
@@ -2439,26 +2544,26 @@ static void yuv2rgb_c_init (yuv2rgb_factory_t *this)
this->yuv2rgb_fun = yuv2rgb_c_8;
break;
case MODE_8_GRAY:
this->yuv2rgb_fun = yuv2rgb_c_gray;
break;
case MODE_PALETTE:
this->yuv2rgb_fun = yuv2rgb_c_palette;
break;
default:
- printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode);
- abort();
+ lprintf ("mode %d not supported by yuv2rgb\n", this->mode);
+ _x_abort();
}
}
static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) {
switch (this->mode) {
case MODE_32_RGB:
case MODE_32_BGR:
this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_32;
break;
@@ -2482,26 +2587,26 @@ static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) {
this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_8;
break;
case MODE_8_GRAY:
this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_gray;
break;
case MODE_PALETTE:
this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_palette;
break;
default:
- printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode);
- abort();
+ lprintf ("mode %d not supported by yuv2rgb\n", this->mode);
+ _x_abort();
}
}
/*
* yuy2 stuff
*/
static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
{
int U, V, Y;
uint8_t * py_1, * pu, * pv;
@@ -2511,69 +2616,69 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
int dy;
/* FIXME: implement unscaled version */
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
dst_1 = (uint32_t*)_dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1(0);
- RGB(1);
+ X_RGB(1);
DST1(1);
- RGB(2);
+ X_RGB(2);
DST1(2);
- RGB(3);
+ X_RGB(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
/*
dy -= 32768;
_p += this->y_stride*2;
*/
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
@@ -2590,68 +2695,68 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
int dy;
/* FIXME: implement unscaled version */
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1RGB(0);
- RGB(1);
+ X_RGB(1);
DST1RGB(1);
- RGB(2);
+ X_RGB(2);
DST1RGB(2);
- RGB(3);
+ X_RGB(3);
DST1RGB(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 24;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
/*
dy -= 32768;
_p += this->y_stride*2;
*/
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
@@ -2668,68 +2773,68 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
int dy;
/* FIXME: implement unscaled version */
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1BGR(0);
- RGB(1);
+ X_RGB(1);
DST1BGR(1);
- RGB(2);
+ X_RGB(2);
DST1BGR(2);
- RGB(3);
+ X_RGB(3);
DST1BGR(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 24;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
}
}
static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
@@ -2742,68 +2847,68 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
int dy;
/* FIXME: implement unscaled version */
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
dst_1 = (uint16_t*)_dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1(0);
- RGB(1);
+ X_RGB(1);
DST1(1);
- RGB(2);
+ X_RGB(2);
DST1(2);
- RGB(3);
+ X_RGB(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
}
}
static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
@@ -2816,185 +2921,185 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
int dy;
/* FIXME: implement unscaled version */
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1(0);
- RGB(1);
+ X_RGB(1);
DST1(1);
- RGB(2);
+ X_RGB(2);
DST1(2);
- RGB(3);
+ X_RGB(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
}
}
static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
{
int width, height;
int dy;
uint8_t * dst;
uint8_t * y;
if (this->do_scale) {
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
scale_line_2 (_p, _dst, this->dest_width, this->step_dx);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
}
} else {
- for (height = this->source_height; --height >= 0; ) {
+ for (height = this->next_slice (this, &_dst); --height >= 0; ) {
dst = _dst;
y = _p;
for (width = this->source_width; --width >= 0; ) {
*dst++ = *y;
y += 2;
}
_dst += this->rgb_stride;
- _p += this->y_stride*2;
+ _p += this->y_stride;
}
}
}
static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
{
int U, V, Y;
uint8_t * py_1, * pu, * pv;
uint16_t * r, * g, * b;
uint8_t * dst_1;
int width, height;
int dy;
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
- RGB(0);
+ X_RGB(0);
DST1CMAP(0);
- RGB(1);
+ X_RGB(1);
DST1CMAP(1);
- RGB(2);
+ X_RGB(2);
DST1CMAP(2);
- RGB(3);
+ X_RGB(3);
DST1CMAP(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
}
}
static void yuy22rgb_c_init (yuv2rgb_factory_t *this)
@@ -3024,144 +3129,149 @@ static void yuy22rgb_c_init (yuv2rgb_factory_t *this)
this->yuy22rgb_fun = yuy22rgb_c_8;
break;
case MODE_8_GRAY:
this->yuy22rgb_fun = yuy22rgb_c_gray;
break;
case MODE_PALETTE:
this->yuy22rgb_fun = yuy22rgb_c_palette;
break;
default:
- printf ("yuv2rgb: mode %d not supported for yuy2\n", this->mode);
+ lprintf ("mode %d not supported for yuy2\n", this->mode);
}
}
-yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
+static yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
yuv2rgb_t *this = xine_xmalloc (sizeof (yuv2rgb_t));
+ this->swapped = factory->swapped;
this->cmap = factory->cmap;
this->y_chunk = this->y_buffer = NULL;
this->u_chunk = this->u_buffer = NULL;
this->v_chunk = this->v_buffer = NULL;
+#ifdef HAVE_MLIB
+ this->mlib_chunk = this->mlib_buffer = NULL;
+ this->mlib_resize_chunk = this->mlib_resize_buffer = NULL;
+ this->mlib_filter_type = MLIB_BILINEAR;
+#endif
+
this->table_rV = factory->table_rV;
this->table_gU = factory->table_gU;
this->table_gV = factory->table_gV;
this->table_bU = factory->table_bU;
+ this->table_mmx = factory->table_mmx;
this->yuv2rgb_fun = factory->yuv2rgb_fun;
this->yuy22rgb_fun = factory->yuy22rgb_fun;
this->yuv2rgb_single_pixel_fun = factory->yuv2rgb_single_pixel_fun;
this->configure = yuv2rgb_configure;
+ this->next_slice = yuv2rgb_next_slice;
+ this->dispose = yuv2rgb_dispose;
return this;
}
/*
* factory functions
*/
-void yuv2rgb_set_gamma (yuv2rgb_factory_t *this, int gamma) {
-
- int i;
-
- for (i = 0; i < 256; i++) {
- (uint8_t *)this->table_rV[i] += this->entry_size*(gamma - this->gamma);
- (uint8_t *)this->table_gU[i] += this->entry_size*(gamma - this->gamma);
- (uint8_t *)this->table_bU[i] += this->entry_size*(gamma - this->gamma);
- }
-#ifdef ARCH_X86
- mmx_yuv2rgb_set_gamma(gamma);
-#endif
- this->gamma = gamma;
-}
-int yuv2rgb_get_gamma (yuv2rgb_factory_t *this) {
+static void yuv2rgb_factory_dispose (yuv2rgb_factory_t *this) {
- return this->gamma;
+ free (this->table_base);
+ free (this->table_mmx_base);
+ free (this);
}
yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
uint8_t *cmap) {
yuv2rgb_factory_t *this;
-
-#ifdef ARCH_X86
uint32_t mm = xine_mm_accel();
-#endif
this = malloc (sizeof (yuv2rgb_factory_t));
this->mode = mode;
this->swapped = swapped;
this->cmap = cmap;
this->create_converter = yuv2rgb_create_converter;
- this->set_gamma = yuv2rgb_set_gamma;
- this->get_gamma = yuv2rgb_get_gamma;
+ this->set_csc_levels = yuv2rgb_set_csc_levels;
+ this->dispose = yuv2rgb_factory_dispose;
this->matrix_coefficients = 6;
+ this->table_base = NULL;
+ this->table_mmx = NULL;
+ this->table_mmx_base = NULL;
- yuv2rgb_setup_tables (this, mode, swapped);
+ yuv2rgb_set_csc_levels (this, 0, 128, 128);
/*
* auto-probe for the best yuv2rgb function
*/
this->yuv2rgb_fun = NULL;
-#ifdef ARCH_X86
+#if defined(ARCH_X86) || defined(ARCH_X86_64)
if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMXEXT)) {
yuv2rgb_init_mmxext (this);
+#ifdef LOG
if (this->yuv2rgb_fun != NULL)
printf ("yuv2rgb: using MMXEXT for colorspace transform\n");
+#endif
}
if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMX)) {
yuv2rgb_init_mmx (this);
+#ifdef LOG
if (this->yuv2rgb_fun != NULL)
printf ("yuv2rgb: using MMX for colorspace transform\n");
+#endif
}
+#ifdef __arm__
+ if (this->yuv2rgb_fun == NULL) {
+ yuv2rgb_init_arm ( this );
+
+ if(this->yuv2rgb_fun != NULL)
+ printf("yuv2rgb: using arm4l assembler for colorspace transform\n" );
+ }
+#endif
+
#endif
#if HAVE_MLIB
- if (this->yuv2rgb_fun == NULL) {
+ if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_MLIB)) {
yuv2rgb_init_mlib (this);
+#ifdef LOG
if (this->yuv2rgb_fun != NULL)
printf ("yuv2rgb: using medialib for colorspace transform\n");
- }
#endif
-#ifdef __arm__
- if (this->yuv2rgb_fun == NULL) {
- yuv2rgb_init_arm ( this );
-
- if(this->yuv2rgb_fun != NULL)
- printf("yuv2rgb: using arm4l assembler for colorspace transform\n" );
}
#endif
if (this->yuv2rgb_fun == NULL) {
- printf ("yuv2rgb: no accelerated colorspace conversion found\n");
+ lprintf ("no accelerated colorspace conversion found\n");
+
yuv2rgb_c_init (this);
}
/*
* auto-probe for the best yuy22rgb function
*/
/* FIXME: implement mmx/mlib functions */
yuy22rgb_c_init (this);
/*
* set up single pixel function
*/
yuv2rgb_single_pixel_init (this);
return this;
}
-