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
@@ -3,3 +3,4 @@
*
- * 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.
*
@@ -33,4 +34,10 @@
#include "yuv2rgb.h"
-#include <xine/xineutils.h>
+#define LOG_MODULE "yuv2rgb"
+#define LOG_VERBOSE
+/*
+#define LOG
+*/
+
+#include <xine/xineutils.h>
@@ -53,4 +60,4 @@ 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;
@@ -61,3 +68,3 @@ static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) {
- while ((int) pMem % alignment)
+ while ((uintptr_t) pMem % alignment)
pMem++;
@@ -68,2 +75,39 @@ 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,
@@ -87,2 +131,4 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
this->rgb_stride = rgb_stride;
+ this->slice_height = source_height;
+ this->slice_offset = 0;
@@ -101,2 +147,12 @@ 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
@@ -104,3 +160,6 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
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);
@@ -140,2 +199,15 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
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
}
@@ -144,3 +216,2 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
-
static void scale_line_gen (uint8_t *source, uint8_t *dest,
@@ -1206,2 +1277,6 @@ 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
@@ -1209,3 +1284,7 @@ static scale_line_func_t find_scale_line_func(int step) {
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;
@@ -1213,5 +1292,10 @@ static scale_line_func_t find_scale_line_func(int step) {
}
- //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;
}
@@ -1274,3 +1358,3 @@ static void scale_line_4 (uint8_t *source, uint8_t *dest,
-#define RGB(i) \
+#define X_RGB(i) \
U = pu[i]; \
@@ -1350,3 +1434,3 @@ 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);
@@ -1361,12 +1445,12 @@ 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);
@@ -1414,3 +1498,3 @@ 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 {
@@ -1425,3 +1509,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
do {
- RGB(0);
+ X_RGB(0);
DST1(0);
@@ -1429,3 +1513,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
- RGB(1);
+ X_RGB(1);
DST2(1);
@@ -1433,3 +1517,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
- RGB(2);
+ X_RGB(2);
DST1(2);
@@ -1437,3 +1521,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
- RGB(3);
+ X_RGB(3);
DST2(3);
@@ -1481,3 +1565,3 @@ 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);
@@ -1492,12 +1576,12 @@ 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);
@@ -1545,3 +1629,3 @@ 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 {
@@ -1556,3 +1640,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
do {
- RGB(0);
+ X_RGB(0);
DST1RGB(0);
@@ -1560,3 +1644,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
- RGB(1);
+ X_RGB(1);
DST2RGB(1);
@@ -1564,3 +1648,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
- RGB(2);
+ X_RGB(2);
DST1RGB(2);
@@ -1568,3 +1652,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
- RGB(3);
+ X_RGB(3);
DST2RGB(3);
@@ -1612,3 +1696,3 @@ 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);
@@ -1623,12 +1707,12 @@ 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);
@@ -1677,3 +1761,3 @@ 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 {
@@ -1687,3 +1771,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
do {
- RGB(0);
+ X_RGB(0);
DST1BGR(0);
@@ -1691,3 +1775,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
- RGB(1);
+ X_RGB(1);
DST2BGR(1);
@@ -1695,3 +1779,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
- RGB(2);
+ X_RGB(2);
DST1BGR(2);
@@ -1699,3 +1783,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
- RGB(3);
+ X_RGB(3);
DST2BGR(3);
@@ -1743,3 +1827,3 @@ 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);
@@ -1754,12 +1838,12 @@ 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);
@@ -1807,3 +1891,3 @@ 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 {
@@ -1817,3 +1901,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
do {
- RGB(0);
+ X_RGB(0);
DST1(0);
@@ -1821,3 +1905,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
- RGB(1);
+ X_RGB(1);
DST2(1);
@@ -1825,3 +1909,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
- RGB(2);
+ X_RGB(2);
DST1(2);
@@ -1829,3 +1913,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
- RGB(3);
+ X_RGB(3);
DST2(3);
@@ -1873,3 +1957,3 @@ 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);
@@ -1884,12 +1968,12 @@ 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);
@@ -1937,3 +2021,3 @@ 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 {
@@ -1948,3 +2032,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
do {
- RGB(0);
+ X_RGB(0);
DST1(0);
@@ -1952,3 +2036,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
- RGB(1);
+ X_RGB(1);
DST2(1);
@@ -1956,3 +2040,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
- RGB(2);
+ X_RGB(2);
DST1(2);
@@ -1960,3 +2044,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
- RGB(3);
+ X_RGB(3);
DST2(3);
@@ -1992,3 +2076,3 @@ 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);
@@ -2018,3 +2102,3 @@ 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);
@@ -2048,3 +2132,3 @@ 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);
@@ -2059,12 +2143,12 @@ 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);
@@ -2112,3 +2196,3 @@ 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 {
@@ -2122,3 +2206,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
do {
- RGB(0);
+ X_RGB(0);
DST1CMAP(0);
@@ -2126,3 +2210,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
- RGB(1);
+ X_RGB(1);
DST2CMAP(1);
@@ -2130,3 +2214,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
- RGB(2);
+ X_RGB(2);
DST1CMAP(2);
@@ -2134,3 +2218,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
- RGB(3);
+ X_RGB(3);
DST2CMAP(3);
@@ -2163,3 +2247,4 @@ 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)
{
@@ -2179,2 +2264,5 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
+ int mode = this->mode;
+ int swapped = this->swapped;
+
for (i = 0; i < 1024; i++) {
@@ -2182,3 +2270,3 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
- j = (76309 * (i - 384 - 16) + 32768) >> 16;
+ j = (76309 * (i - 384 - 16 + brightness) + 32768) >> 16;
j = (j < 0) ? 0 : ((j > 255) ? 255 : j);
@@ -2190,3 +2278,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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;
@@ -2219,3 +2310,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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;
@@ -2232,3 +2326,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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;
@@ -2272,3 +2369,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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;
@@ -2296,3 +2396,6 @@ 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;
@@ -2320,4 +2423,4 @@ 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();
}
@@ -2333,4 +2436,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
}
- 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
}
@@ -2450,4 +2555,4 @@ 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();
}
@@ -2493,4 +2598,4 @@ 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();
}
@@ -2522,3 +2627,3 @@ 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);
@@ -2534,12 +2639,12 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
- 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);
@@ -2566,3 +2671,3 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
@@ -2601,3 +2706,3 @@ 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);
@@ -2612,12 +2717,12 @@ 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);
@@ -2644,3 +2749,3 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
@@ -2679,3 +2784,3 @@ 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);
@@ -2690,12 +2795,12 @@ 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);
@@ -2722,3 +2827,3 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
@@ -2753,3 +2858,3 @@ 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);
@@ -2764,12 +2869,12 @@ 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);
@@ -2796,3 +2901,3 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
@@ -2827,3 +2932,3 @@ 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);
@@ -2838,12 +2943,12 @@ 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);
@@ -2870,3 +2975,3 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
@@ -2891,3 +2996,3 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
dy = 0;
- height = this->dest_height;
+ height = this->next_slice (this, &_dst);
@@ -2910,3 +3015,3 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
@@ -2914,3 +3019,3 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
} else {
- for (height = this->source_height; --height >= 0; ) {
+ for (height = this->next_slice (this, &_dst); --height >= 0; ) {
dst = _dst;
@@ -2922,3 +3027,3 @@ 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;
}
@@ -2944,3 +3049,3 @@ 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);
@@ -2955,12 +3060,12 @@ 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);
@@ -2987,3 +3092,3 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
- _p += this->y_stride*2*(dy>>15);
+ _p += this->y_stride*(dy>>15);
dy &= 32767;
@@ -3035,3 +3140,3 @@ 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);
}
@@ -3039,3 +3144,3 @@ static void yuy22rgb_c_init (yuv2rgb_factory_t *this)
-yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
+static yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
@@ -3043,2 +3148,3 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
+ this->swapped = factory->swapped;
this->cmap = factory->cmap;
@@ -3049,2 +3155,8 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
+#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;
@@ -3053,2 +3165,3 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
this->table_bU = factory->table_bU;
+ this->table_mmx = factory->table_mmx;
@@ -3059,2 +3172,4 @@ 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;
@@ -3065,20 +3180,8 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
*/
-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);
}
@@ -3089,6 +3192,3 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
yuv2rgb_factory_t *this;
-
-#ifdef ARCH_X86
uint32_t mm = xine_mm_accel();
-#endif
@@ -3100,8 +3200,11 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
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);
@@ -3112,3 +3215,3 @@ 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)) {
@@ -3117,4 +3220,6 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
+#ifdef LOG
if (this->yuv2rgb_fun != NULL)
printf ("yuv2rgb: using MMXEXT for colorspace transform\n");
+#endif
}
@@ -3125,8 +3230,19 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
+#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)) {
@@ -3134,12 +3250,6 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
+#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" );
}
@@ -3147,3 +3257,4 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
if (this->yuv2rgb_fun == NULL) {
- printf ("yuv2rgb: no accelerated colorspace conversion found\n");
+ lprintf ("no accelerated colorspace conversion found\n");
+
yuv2rgb_c_init (this);
@@ -3166,2 +3277 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
}
-