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
@@ -2,5 +2,6 @@
* 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:
@@ -32,6 +33,12 @@
#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;
@@ -52,6 +59,6 @@ const int32_t Inverse_Table_6_9[8][4] = {
-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;
@@ -60,5 +67,5 @@ static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) {
*chunk = pMem;
- while ((int) pMem % alignment)
+ while ((uintptr_t) pMem % alignment)
pMem++;
@@ -67,4 +74,41 @@ static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) {
+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,
@@ -86,4 +130,6 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
this->dest_height = dest_height;
this->rgb_stride = rgb_stride;
+ this->slice_height = source_height;
+ this->slice_offset = 0;
if (this->y_chunk) {
@@ -100,8 +146,21 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
}
+#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);
@@ -139,9 +198,21 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
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) {
@@ -1205,14 +1276,27 @@ static scale_line_func_t find_scale_line_func(int step) {
};
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;
}
@@ -1273,5 +1357,5 @@ static void scale_line_4 (uint8_t *source, uint8_t *dest,
-#define RGB(i) \
+#define X_RGB(i) \
U = pu[i]; \
V = pv[i]; \
@@ -1349,5 +1433,5 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (height = 0;; ) {
@@ -1360,14 +1444,14 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1413,5 +1497,5 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
}
} else {
- height = this->source_height >> 1;
+ height = this->next_slice (this, &_dst) >> 1;
do {
dst_1 = (uint32_t*)_dst;
@@ -1424,17 +1508,17 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1480,5 +1564,5 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (height = 0;; ) {
@@ -1491,14 +1575,14 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1544,5 +1628,5 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
}
} else {
- height = this->source_height >> 1;
+ height = this->next_slice (this, &_dst) >> 1;
do {
dst_1 = _dst;
@@ -1555,17 +1639,17 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1611,5 +1695,5 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (height = 0;; ) {
@@ -1622,14 +1706,14 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1676,5 +1760,5 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
} else {
- height = this->source_height >> 1;
+ height = this->next_slice (this, &_dst) >> 1;
do {
dst_1 = _dst;
@@ -1686,17 +1770,17 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1742,5 +1826,5 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (height = 0;; ) {
@@ -1753,14 +1837,14 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1806,5 +1890,5 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
}
} else {
- height = this->source_height >> 1;
+ height = this->next_slice (this, &_dst) >> 1;
do {
dst_1 = (uint16_t*)_dst;
@@ -1816,17 +1900,17 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1872,5 +1956,5 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (height = 0;; ) {
@@ -1883,14 +1967,14 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1936,5 +2020,5 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
}
} else {
- height = this->source_height >> 1;
+ height = this->next_slice (this, &_dst) >> 1;
do {
dst_1 = (uint8_t*)_dst;
@@ -1947,17 +2031,17 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1991,5 +2075,5 @@ static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst,
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (;;) {
@@ -2017,5 +2101,5 @@ static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst,
}
} 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;
@@ -2047,5 +2131,5 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
dy = 0;
- dst_height = this->dest_height;
+ dst_height = this->next_slice (this, &_dst);
for (height = 0;; ) {
@@ -2058,14 +2142,14 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -2111,5 +2195,5 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
}
} else {
- height = this->source_height >> 1;
+ height = this->next_slice (this, &_dst) >> 1;
do {
dst_1 = _dst;
@@ -2121,17 +2205,17 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -2162,5 +2246,6 @@ static int div_round (int dividend, int 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;
@@ -2178,8 +2263,11 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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;
@@ -2189,5 +2277,8 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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);
@@ -2218,5 +2309,8 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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);
@@ -2231,5 +2325,8 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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);
@@ -2271,5 +2368,8 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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);
@@ -2295,5 +2395,8 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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);
@@ -2319,6 +2422,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
default:
- fprintf (stderr, "mode %d not supported by yuv2rgb\n", mode);
- abort();
+ lprintf ("mode %d not supported by yuv2rgb\n", mode);
+ _x_abort();
}
@@ -2332,6 +2435,8 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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
}
@@ -2449,6 +2554,6 @@ static void yuv2rgb_c_init (yuv2rgb_factory_t *this)
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();
}
@@ -2492,6 +2597,6 @@ static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) {
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();
}
}
@@ -2521,5 +2626,5 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
@@ -2533,14 +2638,14 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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);
@@ -2565,5 +2670,5 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
/*
@@ -2600,5 +2705,5 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
@@ -2611,14 +2716,14 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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);
@@ -2643,5 +2748,5 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
/*
@@ -2678,5 +2783,5 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
@@ -2689,14 +2794,14 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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);
@@ -2721,5 +2826,5 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
@@ -2752,5 +2857,5 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
@@ -2763,14 +2868,14 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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);
@@ -2795,5 +2900,5 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
@@ -2826,5 +2931,5 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
@@ -2837,14 +2942,14 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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);
@@ -2869,5 +2974,5 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
@@ -2890,5 +2995,5 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
if (this->do_scale) {
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
@@ -2909,9 +3014,9 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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;
@@ -2921,5 +3026,5 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
}
_dst += this->rgb_stride;
- _p += this->y_stride*2;
+ _p += this->y_stride;
}
}
@@ -2943,5 +3048,5 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
for (;;) {
@@ -2954,14 +3059,14 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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);
@@ -2986,5 +3091,5 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
break;
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
@@ -3034,12 +3139,13 @@ static void yuy22rgb_c_init (yuv2rgb_factory_t *this)
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;
@@ -3048,8 +3154,15 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
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;
@@ -3058,4 +3171,6 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
this->configure = yuv2rgb_configure;
+ this->next_slice = yuv2rgb_next_slice;
+ this->dispose = yuv2rgb_dispose;
return this;
}
@@ -3064,22 +3179,10 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
* 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);
}
@@ -3088,8 +3191,5 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
yuv2rgb_factory_t *this;
-
-#ifdef ARCH_X86
uint32_t mm = xine_mm_accel();
-#endif
this = malloc (sizeof (yuv2rgb_factory_t));
@@ -3099,10 +3199,13 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int 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);
/*
@@ -3111,11 +3214,13 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
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
}
@@ -3124,27 +3229,33 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
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);
}
@@ -3165,3 +3276,2 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
return this;
}
-