summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/yuv2rgb.c
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/yuv2rgb.c') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/yuv2rgb.c446
1 files changed, 278 insertions, 168 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,10 +1,11 @@
1/* 1/*
2 * yuv2rgb.c 2 * yuv2rgb.c
3 * 3 *
4 * This file is part of xine, a unix video player. 4 * Copyright (C) 2003-2004 the xine project
5 * This file is part of xine, a free video player.
5 * 6 *
6 * based on work from mpeg2dec: 7 * based on work from mpeg2dec:
7 * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> 8 * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
8 * 9 *
9 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 10 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
10 * 11 *
@@ -28,14 +29,20 @@
28#include <stdio.h> 29#include <stdio.h>
29#include <stdlib.h> 30#include <stdlib.h>
30#include <string.h> 31#include <string.h>
31#include <inttypes.h> 32#include <inttypes.h>
32 33
33#include "yuv2rgb.h" 34#include "yuv2rgb.h"
34#include <xine/xineutils.h>
35 35
36#define LOG_MODULE "yuv2rgb"
37#define LOG_VERBOSE
38/*
39#define LOG
40*/
41
42#include <xine/xineutils.h>
36 43
37static int prof_scale_line = -1; 44static int prof_scale_line = -1;
38 45
39static scale_line_func_t find_scale_line_func(int step); 46static scale_line_func_t find_scale_line_func(int step);
40 47
41 48
@@ -48,47 +55,86 @@ const int32_t Inverse_Table_6_9[8][4] = {
48 {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */ 55 {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */
49 {104597, 132201, 25675, 53279}, /* SMPTE 170M */ 56 {104597, 132201, 25675, 53279}, /* SMPTE 170M */
50 {117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */ 57 {117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */
51}; 58};
52 59
53 60
54static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) { 61static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk)
55 62{
56 char *pMem; 63 char *pMem;
57 64
58 pMem = xine_xmalloc (size+alignment); 65 pMem = xine_xmalloc (size+alignment);
59 66
60 *chunk = pMem; 67 *chunk = pMem;
61 68
62 while ((int) pMem % alignment) 69 while ((uintptr_t) pMem % alignment)
63 pMem++; 70 pMem++;
64 71
65 return pMem; 72 return pMem;
66} 73}
67 74
68 75
76static int yuv2rgb_next_slice (yuv2rgb_t *this, uint8_t **dest)
77{
78 int y0, y1;
79
80 if (dest == NULL) {
81 this->slice_offset = 0;
82 this->slice_height = 16;
83 return 0;
84 }
85 if (this->slice_height == this->source_height) {
86 return this->dest_height;
87 }
88
89 y0 = (this->slice_offset * this->dest_height) / this->source_height;
90 y1 = ((this->slice_offset + this->slice_height) * this->dest_height) / this->source_height;
91 *dest += (this->rgb_stride * y0);
92
93 if ((this->slice_offset + this->slice_height) >= this->source_height) {
94 this->slice_offset = 0;
95 return (this->dest_height - y0);
96 } else {
97 this->slice_offset += this->slice_height;
98 return (y1 - y0);
99 }
100}
101
102static void yuv2rgb_dispose (yuv2rgb_t *this)
103{
104 free (this->y_chunk);
105 free (this->u_chunk);
106 free (this->v_chunk);
107#ifdef HAVE_MLIB
108 free (this->mlib_chunk);
109#endif
110 free (this);
111}
112
69static int yuv2rgb_configure (yuv2rgb_t *this, 113static int yuv2rgb_configure (yuv2rgb_t *this,
70 int source_width, int source_height, 114 int source_width, int source_height,
71 int y_stride, int uv_stride, 115 int y_stride, int uv_stride,
72 int dest_width, int dest_height, 116 int dest_width, int dest_height,
73 int rgb_stride) { 117 int rgb_stride) {
74 /* 118/*
75 printf ("yuv2rgb setup (%d x %d => %d x %d)\n", source_width, source_height, 119 printf ("yuv2rgb setup (%d x %d => %d x %d)\n", source_width, source_height,
76 dest_width, dest_height); 120 dest_width, dest_height);
77 */ 121 */
78 if (prof_scale_line == -1) 122 if (prof_scale_line == -1)
79 prof_scale_line = xine_profiler_allocate_slot("xshm scale line"); 123 prof_scale_line = xine_profiler_allocate_slot("xshm scale line");
80 124
81 this->source_width = source_width; 125 this->source_width = source_width;
82 this->source_height = source_height; 126 this->source_height = source_height;
83 this->y_stride = y_stride; 127 this->y_stride = y_stride;
84 this->uv_stride = uv_stride; 128 this->uv_stride = uv_stride;
85 this->dest_width = dest_width; 129 this->dest_width = dest_width;
86 this->dest_height = dest_height; 130 this->dest_height = dest_height;
87 this->rgb_stride = rgb_stride; 131 this->rgb_stride = rgb_stride;
88 132 this->slice_height = source_height;
133 this->slice_offset = 0;
134
89 if (this->y_chunk) { 135 if (this->y_chunk) {
90 free (this->y_chunk); 136 free (this->y_chunk);
91 this->y_buffer = this->y_chunk = NULL; 137 this->y_buffer = this->y_chunk = NULL;
92 } 138 }
93 if (this->u_chunk) { 139 if (this->u_chunk) {
94 free (this->u_chunk); 140 free (this->u_chunk);
@@ -96,16 +142,29 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
96 } 142 }
97 if (this->v_chunk) { 143 if (this->v_chunk) {
98 free (this->v_chunk); 144 free (this->v_chunk);
99 this->v_buffer = this->v_chunk = NULL; 145 this->v_buffer = this->v_chunk = NULL;
100 } 146 }
101 147
102 148#ifdef HAVE_MLIB
149 if (this->mlib_chunk) {
150 free (this->mlib_chunk);
151 this->mlib_buffer = this->mlib_chunk = NULL;
152 }
153 if (this->mlib_resize_chunk) {
154 free (this->mlib_resize_chunk);
155 this->mlib_resize_buffer = this->mlib_resize_chunk = NULL;
156 }
157#endif
158
103 this->step_dx = source_width * 32768 / dest_width; 159 this->step_dx = source_width * 32768 / dest_width;
104 this->step_dy = source_height * 32768 / dest_height; 160 this->step_dy = source_height * 32768 / dest_height;
105 161/*
162 printf("yuv2rgb config: src_ht=%i, dst_ht=%i\n",source_height, dest_height);
163 printf("yuv2rgb config: step_dy=%i %f\n",this->step_dy, (float)this->step_dy / 32768.0);
164*/
106 this->scale_line = find_scale_line_func(this->step_dx); 165 this->scale_line = find_scale_line_func(this->step_dx);
107 166
108 if ((source_width == dest_width) && (source_height == dest_height)) { 167 if ((source_width == dest_width) && (source_height == dest_height)) {
109 this->do_scale = 0; 168 this->do_scale = 0;
110 169
111 /* 170 /*
@@ -135,17 +194,29 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
135 this->u_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->u_chunk); 194 this->u_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->u_chunk);
136 if (!this->u_buffer) 195 if (!this->u_buffer)
137 return 0; 196 return 0;
138 this->v_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->v_chunk); 197 this->v_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->v_chunk);
139 if (!this->v_buffer) 198 if (!this->v_buffer)
140 return 0; 199 return 0;
200
201#if HAVE_MLIB
202 /* Only need these if we are resizing and in mlib code */
203 this->mlib_buffer = my_malloc_aligned (16, source_width*source_height*4, &this->mlib_chunk);
204 if (!this->mlib_buffer)
205 return 0;
206 /* Only need this one if we are 24 bit */
207 if((rgb_stride / dest_width) == 3) {
208 this->mlib_resize_buffer = my_malloc_aligned (16, dest_width*dest_height*4, &this->mlib_resize_chunk);
209 if (!this->mlib_resize_buffer)
210 return 0;
211 }
212 #endif
141 } 213 }
142 return 1; 214 return 1;
143} 215}
144 216
145
146static void scale_line_gen (uint8_t *source, uint8_t *dest, 217static void scale_line_gen (uint8_t *source, uint8_t *dest,
147 int width, int step) { 218 int width, int step) {
148 219
149 /* 220 /*
150 * scales a yuv source row to a dest row, with interpolation 221 * scales a yuv source row to a dest row, with interpolation
151 * (good quality, but slow) 222 * (good quality, but slow)
@@ -1201,22 +1272,35 @@ static scale_line_func_t find_scale_line_func(int step) {
1201 { 5, 8, scale_line_5_8, "svcd 4:3(pal)" }, 1272 { 5, 8, scale_line_5_8, "svcd 4:3(pal)" },
1202 { 3, 4, scale_line_3_4, "svcd 4:3(ntsc)" }, 1273 { 3, 4, scale_line_3_4, "svcd 4:3(ntsc)" },
1203 { 1, 2, scale_line_1_2, "2*zoom" }, 1274 { 1, 2, scale_line_1_2, "2*zoom" },
1204 { 1, 1, scale_line_1_1, "non-scaled" }, 1275 { 1, 1, scale_line_1_1, "non-scaled" },
1205 }; 1276 };
1206 int i; 1277 int i;
1278 #ifdefLOG
1279 /* to filter out multiple messages about the scale_line variant we're using */
1280 static int reported_for_step;
1281#endif
1207 1282
1208 for (i = 0; i < sizeof(scale_line)/sizeof(scale_line[0]); i++) { 1283 for (i = 0; i < sizeof(scale_line)/sizeof(scale_line[0]); i++) {
1209 if (step == scale_line[i].src_step*32768/scale_line[i].dest_step) { 1284 if (step == scale_line[i].src_step*32768/scale_line[i].dest_step) {
1210 //printf("yuv2rgb: using %s optimized scale_line\n", scale_line[i].desc); 1285 #ifdefLOG
1286 if (step != reported_for_step)
1287 printf("yuv2rgb: using %s optimized scale_line\n", scale_line[i].desc);
1288 reported_for_step = step;
1289#endif
1211 return scale_line[i].func; 1290 return scale_line[i].func;
1212 } 1291 }
1213 } 1292 }
1214 //printf("yuv2rgb: using generic scale_line with interpolation\n");
1215 return scale_line_gen;
1216 1293
1294 #ifdefLOG
1295 if (step != reported_for_step)
1296 printf("yuv2rgb: using generic scale_line with interpolation\n");
1297 reported_for_step = step;
1298#endif
1299
1300 return scale_line_gen;
1217} 1301}
1218 1302
1219 1303
1220static void scale_line_2 (uint8_t *source, uint8_t *dest, 1304static void scale_line_2 (uint8_t *source, uint8_t *dest,
1221 int width, int step) { 1305 int width, int step) {
1222 int p1; 1306 int p1;
@@ -1269,13 +1353,13 @@ static void scale_line_4 (uint8_t *source, uint8_t *dest,
1269 dest ++; 1353 dest ++;
1270 width --; 1354 width --;
1271 } 1355 }
1272} 1356}
1273 1357
1274 1358
1275 #define RGB(i) \ 1359 #define X_RGB(i) \
1276 U = pu[i]; \ 1360 U = pu[i]; \
1277 V = pv[i]; \ 1361 V = pv[i]; \
1278 r = this->table_rV[V]; \ 1362 r = this->table_rV[V]; \
1279 g = (void *) (((uint8_t *)this->table_gU[U]) + this->table_gV[V]);\ 1363 g = (void *) (((uint8_t *)this->table_gU[U]) + this->table_gV[V]);\
1280 b = this->table_bU[U]; 1364 b = this->table_bU[U];
1281 1365
@@ -1345,33 +1429,33 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
1345 scale_line (_pv, this->v_buffer, 1429 scale_line (_pv, this->v_buffer,
1346 this->dest_width >> 1, this->step_dx); 1430 this->dest_width >> 1, this->step_dx);
1347 scale_line (_py, this->y_buffer, 1431 scale_line (_py, this->y_buffer,
1348 this->dest_width, this->step_dx); 1432 this->dest_width, this->step_dx);
1349 1433
1350 dy = 0; 1434 dy = 0;
1351 dst_height = this->dest_height; 1435 dst_height = this->next_slice (this, &_dst);
1352 1436
1353 for (height = 0;; ) { 1437 for (height = 0;; ) {
1354 dst_1 = (uint32_t*)_dst; 1438 dst_1 = (uint32_t*)_dst;
1355 py_1 = this->y_buffer; 1439 py_1 = this->y_buffer;
1356 pu = this->u_buffer; 1440 pu = this->u_buffer;
1357 pv = this->v_buffer; 1441 pv = this->v_buffer;
1358 1442
1359 width = this->dest_width >> 3; 1443 width = this->dest_width >> 3;
1360 1444
1361 do { 1445 do {
1362 RGB(0); 1446 X_RGB(0);
1363 DST1(0); 1447 DST1(0);
1364 1448
1365 RGB(1); 1449 X_RGB(1);
1366 DST1(1); 1450 DST1(1);
1367 1451
1368 RGB(2); 1452 X_RGB(2);
1369 DST1(2); 1453 DST1(2);
1370 1454
1371 RGB(3); 1455 X_RGB(3);
1372 DST1(3); 1456 DST1(3);
1373 1457
1374 pu += 4; 1458 pu += 4;
1375 pv += 4; 1459 pv += 4;
1376 py_1 += 8; 1460 py_1 += 8;
1377 dst_1 += 8; 1461 dst_1 += 8;
@@ -1409,36 +1493,36 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
1409 1493
1410 } 1494 }
1411 height++; 1495 height++;
1412 } while( dy>=32768); 1496 } while( dy>=32768);
1413 } 1497 }
1414 } else { 1498 } else {
1415 height = this->source_height >> 1; 1499 height = this->next_slice (this, &_dst) >> 1;
1416 do { 1500 do {
1417 dst_1 = (uint32_t*)_dst; 1501 dst_1 = (uint32_t*)_dst;
1418 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); 1502 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
1419 py_1 = _py; 1503 py_1 = _py;
1420 py_2 = _py + this->y_stride; 1504 py_2 = _py + this->y_stride;
1421 pu = _pu; 1505 pu = _pu;
1422 pv = _pv; 1506 pv = _pv;
1423 1507
1424 width = this->source_width >> 3; 1508 width = this->source_width >> 3;
1425 do { 1509 do {
1426 RGB(0); 1510 X_RGB(0);
1427 DST1(0); 1511 DST1(0);
1428 DST2(0); 1512 DST2(0);
1429 1513
1430 RGB(1); 1514 X_RGB(1);
1431 DST2(1); 1515 DST2(1);
1432 DST1(1); 1516 DST1(1);
1433 1517
1434 RGB(2); 1518 X_RGB(2);
1435 DST1(2); 1519 DST1(2);
1436 DST2(2); 1520 DST2(2);
1437 1521
1438 RGB(3); 1522 X_RGB(3);
1439 DST2(3); 1523 DST2(3);
1440 DST1(3); 1524 DST1(3);
1441 1525
1442 pu += 4; 1526 pu += 4;
1443 pv += 4; 1527 pv += 4;
1444 py_1 += 8; 1528 py_1 += 8;
@@ -1476,33 +1560,33 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
1476 scale_line (_pv, this->v_buffer, 1560 scale_line (_pv, this->v_buffer,
1477 this->dest_width >> 1, this->step_dx); 1561 this->dest_width >> 1, this->step_dx);
1478 scale_line (_py, this->y_buffer, 1562 scale_line (_py, this->y_buffer,
1479 this->dest_width, this->step_dx); 1563 this->dest_width, this->step_dx);
1480 1564
1481 dy = 0; 1565 dy = 0;
1482 dst_height = this->dest_height; 1566 dst_height = this->next_slice (this, &_dst);
1483 1567
1484 for (height = 0;; ) { 1568 for (height = 0;; ) {
1485 dst_1 = _dst; 1569 dst_1 = _dst;
1486 py_1 = this->y_buffer; 1570 py_1 = this->y_buffer;
1487 pu = this->u_buffer; 1571 pu = this->u_buffer;
1488 pv = this->v_buffer; 1572 pv = this->v_buffer;
1489 1573
1490 width = this->dest_width >> 3; 1574 width = this->dest_width >> 3;
1491 1575
1492 do { 1576 do {
1493 RGB(0); 1577 X_RGB(0);
1494 DST1RGB(0); 1578 DST1RGB(0);
1495 1579
1496 RGB(1); 1580 X_RGB(1);
1497 DST1RGB(1); 1581 DST1RGB(1);
1498 1582
1499 RGB(2); 1583 X_RGB(2);
1500 DST1RGB(2); 1584 DST1RGB(2);
1501 1585
1502 RGB(3); 1586 X_RGB(3);
1503 DST1RGB(3); 1587 DST1RGB(3);
1504 1588
1505 pu += 4; 1589 pu += 4;
1506 pv += 4; 1590 pv += 4;
1507 py_1 += 8; 1591 py_1 += 8;
1508 dst_1 += 24; 1592 dst_1 += 24;
@@ -1540,36 +1624,36 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
1540 1624
1541 } 1625 }
1542 height++; 1626 height++;
1543 } while (dy>=32768); 1627 } while (dy>=32768);
1544 } 1628 }
1545 } else { 1629 } else {
1546 height = this->source_height >> 1; 1630 height = this->next_slice (this, &_dst) >> 1;
1547 do { 1631 do {
1548 dst_1 = _dst; 1632 dst_1 = _dst;
1549 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); 1633 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
1550 py_1 = _py; 1634 py_1 = _py;
1551 py_2 = _py + this->y_stride; 1635 py_2 = _py + this->y_stride;
1552 pu = _pu; 1636 pu = _pu;
1553 pv = _pv; 1637 pv = _pv;
1554 1638
1555 width = this->source_width >> 3; 1639 width = this->source_width >> 3;
1556 do { 1640 do {
1557 RGB(0); 1641 X_RGB(0);
1558 DST1RGB(0); 1642 DST1RGB(0);
1559 DST2RGB(0); 1643 DST2RGB(0);
1560 1644
1561 RGB(1); 1645 X_RGB(1);
1562 DST2RGB(1); 1646 DST2RGB(1);
1563 DST1RGB(1); 1647 DST1RGB(1);
1564 1648
1565 RGB(2); 1649 X_RGB(2);
1566 DST1RGB(2); 1650 DST1RGB(2);
1567 DST2RGB(2); 1651 DST2RGB(2);
1568 1652
1569 RGB(3); 1653 X_RGB(3);
1570 DST2RGB(3); 1654 DST2RGB(3);
1571 DST1RGB(3); 1655 DST1RGB(3);
1572 1656
1573 pu += 4; 1657 pu += 4;
1574 pv += 4; 1658 pv += 4;
1575 py_1 += 8; 1659 py_1 += 8;
@@ -1607,33 +1691,33 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
1607 scale_line (_pv, this->v_buffer, 1691 scale_line (_pv, this->v_buffer,
1608 this->dest_width >> 1, this->step_dx); 1692 this->dest_width >> 1, this->step_dx);
1609 scale_line (_py, this->y_buffer, 1693 scale_line (_py, this->y_buffer,
1610 this->dest_width, this->step_dx); 1694 this->dest_width, this->step_dx);
1611 1695
1612 dy = 0; 1696 dy = 0;
1613 dst_height = this->dest_height; 1697 dst_height = this->next_slice (this, &_dst);
1614 1698
1615 for (height = 0;; ) { 1699 for (height = 0;; ) {
1616 dst_1 = _dst; 1700 dst_1 = _dst;
1617 py_1 = this->y_buffer; 1701 py_1 = this->y_buffer;
1618 pu = this->u_buffer; 1702 pu = this->u_buffer;
1619 pv = this->v_buffer; 1703 pv = this->v_buffer;
1620 1704
1621 width = this->dest_width >> 3; 1705 width = this->dest_width >> 3;
1622 1706
1623 do { 1707 do {
1624 RGB(0); 1708 X_RGB(0);
1625 DST1BGR(0); 1709 DST1BGR(0);
1626 1710
1627 RGB(1); 1711 X_RGB(1);
1628 DST1BGR(1); 1712 DST1BGR(1);
1629 1713
1630 RGB(2); 1714 X_RGB(2);
1631 DST1BGR(2); 1715 DST1BGR(2);
1632 1716
1633 RGB(3); 1717 X_RGB(3);
1634 DST1BGR(3); 1718 DST1BGR(3);
1635 1719
1636 pu += 4; 1720 pu += 4;
1637 pv += 4; 1721 pv += 4;
1638 py_1 += 8; 1722 py_1 += 8;
1639 dst_1 += 24; 1723 dst_1 += 24;
@@ -1672,35 +1756,35 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
1672 } 1756 }
1673 height++; 1757 height++;
1674 } while( dy>=32768 ); 1758 } while( dy>=32768 );
1675 } 1759 }
1676 1760
1677 } else { 1761 } else {
1678 height = this->source_height >> 1; 1762 height = this->next_slice (this, &_dst) >> 1;
1679 do { 1763 do {
1680 dst_1 = _dst; 1764 dst_1 = _dst;
1681 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); 1765 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
1682 py_1 = _py; 1766 py_1 = _py;
1683 py_2 = _py + this->y_stride; 1767 py_2 = _py + this->y_stride;
1684 pu = _pu; 1768 pu = _pu;
1685 pv = _pv; 1769 pv = _pv;
1686 width = this->source_width >> 3; 1770 width = this->source_width >> 3;
1687 do { 1771 do {
1688 RGB(0); 1772 X_RGB(0);
1689 DST1BGR(0); 1773 DST1BGR(0);
1690 DST2BGR(0); 1774 DST2BGR(0);
1691 1775
1692 RGB(1); 1776 X_RGB(1);
1693 DST2BGR(1); 1777 DST2BGR(1);
1694 DST1BGR(1); 1778 DST1BGR(1);
1695 1779
1696 RGB(2); 1780 X_RGB(2);
1697 DST1BGR(2); 1781 DST1BGR(2);
1698 DST2BGR(2); 1782 DST2BGR(2);
1699 1783
1700 RGB(3); 1784 X_RGB(3);
1701 DST2BGR(3); 1785 DST2BGR(3);
1702 DST1BGR(3); 1786 DST1BGR(3);
1703 1787
1704 pu += 4; 1788 pu += 4;
1705 pv += 4; 1789 pv += 4;
1706 py_1 += 8; 1790 py_1 += 8;
@@ -1738,33 +1822,33 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
1738 scale_line (_pv, this->v_buffer, 1822 scale_line (_pv, this->v_buffer,
1739 this->dest_width >> 1, this->step_dx); 1823 this->dest_width >> 1, this->step_dx);
1740 scale_line (_py, this->y_buffer, 1824 scale_line (_py, this->y_buffer,
1741 this->dest_width, this->step_dx); 1825 this->dest_width, this->step_dx);
1742 1826
1743 dy = 0; 1827 dy = 0;
1744 dst_height = this->dest_height; 1828 dst_height = this->next_slice (this, &_dst);
1745 1829
1746 for (height = 0;; ) { 1830 for (height = 0;; ) {
1747 dst_1 = (uint16_t*)_dst; 1831 dst_1 = (uint16_t*)_dst;
1748 py_1 = this->y_buffer; 1832 py_1 = this->y_buffer;
1749 pu = this->u_buffer; 1833 pu = this->u_buffer;
1750 pv = this->v_buffer; 1834 pv = this->v_buffer;
1751 1835
1752 width = this->dest_width >> 3; 1836 width = this->dest_width >> 3;
1753 1837
1754 do { 1838 do {
1755 RGB(0); 1839 X_RGB(0);
1756 DST1(0); 1840 DST1(0);
1757 1841
1758 RGB(1); 1842 X_RGB(1);
1759 DST1(1); 1843 DST1(1);
1760 1844
1761 RGB(2); 1845 X_RGB(2);
1762 DST1(2); 1846 DST1(2);
1763 1847
1764 RGB(3); 1848 X_RGB(3);
1765 DST1(3); 1849 DST1(3);
1766 1850
1767 pu += 4; 1851 pu += 4;
1768 pv += 4; 1852 pv += 4;
1769 py_1 += 8; 1853 py_1 += 8;
1770 dst_1 += 8; 1854 dst_1 += 8;
@@ -1802,35 +1886,35 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
1802 1886
1803 } 1887 }
1804 height++; 1888 height++;
1805 } while( dy>=32768); 1889 } while( dy>=32768);
1806 } 1890 }
1807 } else { 1891 } else {
1808 height = this->source_height >> 1; 1892 height = this->next_slice (this, &_dst) >> 1;
1809 do { 1893 do {
1810 dst_1 = (uint16_t*)_dst; 1894 dst_1 = (uint16_t*)_dst;
1811 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); 1895 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
1812 py_1 = _py; 1896 py_1 = _py;
1813 py_2 = _py + this->y_stride; 1897 py_2 = _py + this->y_stride;
1814 pu = _pu; 1898 pu = _pu;
1815 pv = _pv; 1899 pv = _pv;
1816 width = this->source_width >> 3; 1900 width = this->source_width >> 3;
1817 do { 1901 do {
1818 RGB(0); 1902 X_RGB(0);
1819 DST1(0); 1903 DST1(0);
1820 DST2(0); 1904 DST2(0);
1821 1905
1822 RGB(1); 1906 X_RGB(1);
1823 DST2(1); 1907 DST2(1);
1824 DST1(1); 1908 DST1(1);
1825 1909
1826 RGB(2); 1910 X_RGB(2);
1827 DST1(2); 1911 DST1(2);
1828 DST2(2); 1912 DST2(2);
1829 1913
1830 RGB(3); 1914 X_RGB(3);
1831 DST2(3); 1915 DST2(3);
1832 DST1(3); 1916 DST1(3);
1833 1917
1834 pu += 4; 1918 pu += 4;
1835 pv += 4; 1919 pv += 4;
1836 py_1 += 8; 1920 py_1 += 8;
@@ -1868,33 +1952,33 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
1868 scale_line (_pv, this->v_buffer, 1952 scale_line (_pv, this->v_buffer,
1869 this->dest_width >> 1, this->step_dx); 1953 this->dest_width >> 1, this->step_dx);
1870 scale_line (_py, this->y_buffer, 1954 scale_line (_py, this->y_buffer,
1871 this->dest_width, this->step_dx); 1955 this->dest_width, this->step_dx);
1872 1956
1873 dy = 0; 1957 dy = 0;
1874 dst_height = this->dest_height; 1958 dst_height = this->next_slice (this, &_dst);
1875 1959
1876 for (height = 0;; ) { 1960 for (height = 0;; ) {
1877 dst_1 = (uint8_t*)_dst; 1961 dst_1 = (uint8_t*)_dst;
1878 py_1 = this->y_buffer; 1962 py_1 = this->y_buffer;
1879 pu = this->u_buffer; 1963 pu = this->u_buffer;
1880 pv = this->v_buffer; 1964 pv = this->v_buffer;
1881 1965
1882 width = this->dest_width >> 3; 1966 width = this->dest_width >> 3;
1883 1967
1884 do { 1968 do {
1885 RGB(0); 1969 X_RGB(0);
1886 DST1(0); 1970 DST1(0);
1887 1971
1888 RGB(1); 1972 X_RGB(1);
1889 DST1(1); 1973 DST1(1);
1890 1974
1891 RGB(2); 1975 X_RGB(2);
1892 DST1(2); 1976 DST1(2);
1893 1977
1894 RGB(3); 1978 X_RGB(3);
1895 DST1(3); 1979 DST1(3);
1896 1980
1897 pu += 4; 1981 pu += 4;
1898 pv += 4; 1982 pv += 4;
1899 py_1 += 8; 1983 py_1 += 8;
1900 dst_1 += 8; 1984 dst_1 += 8;
@@ -1932,36 +2016,36 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
1932 2016
1933 } 2017 }
1934 height++; 2018 height++;
1935 } while( dy>=32768 ); 2019 } while( dy>=32768 );
1936 } 2020 }
1937 } else { 2021 } else {
1938 height = this->source_height >> 1; 2022 height = this->next_slice (this, &_dst) >> 1;
1939 do { 2023 do {
1940 dst_1 = (uint8_t*)_dst; 2024 dst_1 = (uint8_t*)_dst;
1941 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); 2025 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
1942 py_1 = _py; 2026 py_1 = _py;
1943 py_2 = _py + this->y_stride; 2027 py_2 = _py + this->y_stride;
1944 pu = _pu; 2028 pu = _pu;
1945 pv = _pv; 2029 pv = _pv;
1946 2030
1947 width = this->source_width >> 3; 2031 width = this->source_width >> 3;
1948 do { 2032 do {
1949 RGB(0); 2033 X_RGB(0);
1950 DST1(0); 2034 DST1(0);
1951 DST2(0); 2035 DST2(0);
1952 2036
1953 RGB(1); 2037 X_RGB(1);
1954 DST2(1); 2038 DST2(1);
1955 DST1(1); 2039 DST1(1);
1956 2040
1957 RGB(2); 2041 X_RGB(2);
1958 DST1(2); 2042 DST1(2);
1959 DST2(2); 2043 DST2(2);
1960 2044
1961 RGB(3); 2045 X_RGB(3);
1962 DST2(3); 2046 DST2(3);
1963 DST1(3); 2047 DST1(3);
1964 2048
1965 pu += 4; 2049 pu += 4;
1966 pv += 4; 2050 pv += 4;
1967 py_1 += 8; 2051 py_1 += 8;
@@ -1987,13 +2071,13 @@ static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst,
1987 int dy; 2071 int dy;
1988 2072
1989 if (this->do_scale) { 2073 if (this->do_scale) {
1990 scale_line_func_t scale_line = this->scale_line; 2074 scale_line_func_t scale_line = this->scale_line;
1991 2075
1992 dy = 0; 2076 dy = 0;
1993 dst_height = this->dest_height; 2077 dst_height = this->next_slice (this, &_dst);
1994 2078
1995 for (;;) { 2079 for (;;) {
1996 scale_line (_py, _dst, this->dest_width, this->step_dx); 2080 scale_line (_py, _dst, this->dest_width, this->step_dx);
1997 2081
1998 dy += this->step_dy; 2082 dy += this->step_dy;
1999 _dst += this->rgb_stride; 2083 _dst += this->rgb_stride;
@@ -2013,13 +2097,13 @@ static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst,
2013 dy &= 32767; 2097 dy &= 32767;
2014 /* dy -= 32768; 2098 /* dy -= 32768;
2015 _py += this->y_stride; 2099 _py += this->y_stride;
2016 */ 2100 */
2017 } 2101 }
2018 } else { 2102 } else {
2019 for (height = this->source_height; --height >= 0; ) { 2103 for (height = this->next_slice (this, &_dst); --height >= 0; ) {
2020 xine_fast_memcpy(_dst, _py, this->dest_width); 2104 xine_fast_memcpy(_dst, _py, this->dest_width);
2021 _dst += this->rgb_stride; 2105 _dst += this->rgb_stride;
2022 _py += this->y_stride; 2106 _py += this->y_stride;
2023 } 2107 }
2024 } 2108 }
2025} 2109}
@@ -2043,33 +2127,33 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
2043 scale_line (_pv, this->v_buffer, 2127 scale_line (_pv, this->v_buffer,
2044 this->dest_width >> 1, this->step_dx); 2128 this->dest_width >> 1, this->step_dx);
2045 scale_line (_py, this->y_buffer, 2129 scale_line (_py, this->y_buffer,
2046 this->dest_width, this->step_dx); 2130 this->dest_width, this->step_dx);
2047 2131
2048 dy = 0; 2132 dy = 0;
2049 dst_height = this->dest_height; 2133 dst_height = this->next_slice (this, &_dst);
2050 2134
2051 for (height = 0;; ) { 2135 for (height = 0;; ) {
2052 dst_1 = _dst; 2136 dst_1 = _dst;
2053 py_1 = this->y_buffer; 2137 py_1 = this->y_buffer;
2054 pu = this->u_buffer; 2138 pu = this->u_buffer;
2055 pv = this->v_buffer; 2139 pv = this->v_buffer;
2056 2140
2057 width = this->dest_width >> 3; 2141 width = this->dest_width >> 3;
2058 2142
2059 do { 2143 do {
2060 RGB(0); 2144 X_RGB(0);
2061 DST1CMAP(0); 2145 DST1CMAP(0);
2062 2146
2063 RGB(1); 2147 X_RGB(1);
2064 DST1CMAP(1); 2148 DST1CMAP(1);
2065 2149
2066 RGB(2); 2150 X_RGB(2);
2067 DST1CMAP(2); 2151 DST1CMAP(2);
2068 2152
2069 RGB(3); 2153 X_RGB(3);
2070 DST1CMAP(3); 2154 DST1CMAP(3);
2071 2155
2072 pu += 4; 2156 pu += 4;
2073 pv += 4; 2157 pv += 4;
2074 py_1 += 8; 2158 py_1 += 8;
2075 dst_1 += 8; 2159 dst_1 += 8;
@@ -2107,35 +2191,35 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
2107 2191
2108 } 2192 }
2109 height++; 2193 height++;
2110 } while( dy>=32768 ); 2194 } while( dy>=32768 );
2111 } 2195 }
2112 } else { 2196 } else {
2113 height = this->source_height >> 1; 2197 height = this->next_slice (this, &_dst) >> 1;
2114 do { 2198 do {
2115 dst_1 = _dst; 2199 dst_1 = _dst;
2116 dst_2 = _dst + this->rgb_stride; 2200 dst_2 = _dst + this->rgb_stride;
2117 py_1 = _py; 2201 py_1 = _py;
2118 py_2 = _py + this->y_stride; 2202 py_2 = _py + this->y_stride;
2119 pu = _pu; 2203 pu = _pu;
2120 pv = _pv; 2204 pv = _pv;
2121 width = this->source_width >> 3; 2205 width = this->source_width >> 3;
2122 do { 2206 do {
2123 RGB(0); 2207 X_RGB(0);
2124 DST1CMAP(0); 2208 DST1CMAP(0);
2125 DST2CMAP(0); 2209 DST2CMAP(0);
2126 2210
2127 RGB(1); 2211 X_RGB(1);
2128 DST2CMAP(1); 2212 DST2CMAP(1);
2129 DST1CMAP(1); 2213 DST1CMAP(1);
2130 2214
2131 RGB(2); 2215 X_RGB(2);
2132 DST1CMAP(2); 2216 DST1CMAP(2);
2133 DST2CMAP(2); 2217 DST2CMAP(2);
2134 2218
2135 RGB(3); 2219 X_RGB(3);
2136 DST2CMAP(3); 2220 DST2CMAP(3);
2137 DST1CMAP(3); 2221 DST1CMAP(3);
2138 2222
2139 pu += 4; 2223 pu += 4;
2140 pv += 4; 2224 pv += 4;
2141 py_1 += 8; 2225 py_1 += 8;
@@ -2158,13 +2242,14 @@ static int div_round (int dividend, int divisor)
2158 if (dividend > 0) 2242 if (dividend > 0)
2159 return (dividend + (divisor>>1)) / divisor; 2243 return (dividend + (divisor>>1)) / divisor;
2160 else 2244 else
2161 return -((-dividend + (divisor>>1)) / divisor); 2245 return -((-dividend + (divisor>>1)) / divisor);
2162} 2246}
2163 2247
2164static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped) 2248static void yuv2rgb_set_csc_levels (yuv2rgb_factory_t *this,
2249 int brightness, int contrast, int saturation)
2165{ 2250{
2166 int i; 2251 int i;
2167 uint8_t table_Y[1024]; 2252 uint8_t table_Y[1024];
2168 uint32_t * table_32 = 0; 2253 uint32_t * table_32 = 0;
2169 uint16_t * table_16 = 0; 2254 uint16_t * table_16 = 0;
2170 uint8_t * table_8 = 0; 2255 uint8_t * table_8 = 0;
@@ -2174,24 +2259,30 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
2174 2259
2175 int crv = Inverse_Table_6_9[this->matrix_coefficients][0]; 2260 int crv = Inverse_Table_6_9[this->matrix_coefficients][0];
2176 int cbu = Inverse_Table_6_9[this->matrix_coefficients][1]; 2261 int cbu = Inverse_Table_6_9[this->matrix_coefficients][1];
2177 int cgu = -Inverse_Table_6_9[this->matrix_coefficients][2]; 2262 int cgu = -Inverse_Table_6_9[this->matrix_coefficients][2];
2178 int cgv = -Inverse_Table_6_9[this->matrix_coefficients][3]; 2263 int cgv = -Inverse_Table_6_9[this->matrix_coefficients][3];
2179 2264
2265 int mode = this->mode;
2266 int swapped = this->swapped;
2267
2180 for (i = 0; i < 1024; i++) { 2268 for (i = 0; i < 1024; i++) {
2181 int j; 2269 int j;
2182 2270
2183 j = (76309 * (i - 384 - 16) + 32768) >> 16; 2271 j = (76309 * (i - 384 - 16 + brightness) + 32768) >> 16;
2184 j = (j < 0) ? 0 : ((j > 255) ? 255 : j); 2272 j = (j < 0) ? 0 : ((j > 255) ? 255 : j);
2185 table_Y[i] = j; 2273 table_Y[i] = j;
2186 } 2274 }
2187 2275
2188 switch (mode) { 2276 switch (mode) {
2189 case MODE_32_RGB: 2277 case MODE_32_RGB:
2190 case MODE_32_BGR: 2278 case MODE_32_BGR:
2191 table_32 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t)); 2279 if (this->table_base == NULL) {
2280 this->table_base = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t));
2281 }
2282 table_32 = this->table_base;
2192 2283
2193 entry_size = sizeof (uint32_t); 2284 entry_size = sizeof (uint32_t);
2194 table_r = table_32 + 197; 2285 table_r = table_32 + 197;
2195 table_b = table_32 + 197 + 685; 2286 table_b = table_32 + 197 + 685;
2196 table_g = table_32 + 197 + 2*682; 2287 table_g = table_32 + 197 + 2*682;
2197 2288
@@ -2214,26 +2305,32 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
2214 for (i = -232; i < 256+232; i++) 2305 for (i = -232; i < 256+232; i++)
2215 ((uint32_t *) table_b)[i] = table_Y[i+384] << shift_b; 2306 ((uint32_t *) table_b)[i] = table_Y[i+384] << shift_b;
2216 break; 2307 break;
2217 2308
2218 case MODE_24_RGB: 2309 case MODE_24_RGB:
2219 case MODE_24_BGR: 2310 case MODE_24_BGR:
2220 table_8 = malloc ((256 + 2*232) * sizeof (uint8_t)); 2311 if (this->table_base == NULL) {
2312 this->table_base = malloc ((256 + 2*232) * sizeof (uint8_t));
2313 }
2314 table_8 = this->table_base;
2221 2315
2222 entry_size = sizeof (uint8_t); 2316 entry_size = sizeof (uint8_t);
2223 table_r = table_g = table_b = table_8 + 232; 2317 table_r = table_g = table_b = table_8 + 232;
2224 2318
2225 for (i = -232; i < 256+232; i++) 2319 for (i = -232; i < 256+232; i++)
2226 ((uint8_t * )table_b)[i] = table_Y[i+384]; 2320 ((uint8_t * )table_b)[i] = table_Y[i+384];
2227 break; 2321 break;
2228 2322
2229 case MODE_15_BGR: 2323 case MODE_15_BGR:
2230 case MODE_16_BGR: 2324 case MODE_16_BGR:
2231 case MODE_15_RGB: 2325 case MODE_15_RGB:
2232 case MODE_16_RGB: 2326 case MODE_16_RGB:
2233 table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); 2327 if (this->table_base == NULL) {
2328 this->table_base = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
2329 }
2330 table_16 = this->table_base;
2234 2331
2235 entry_size = sizeof (uint16_t); 2332 entry_size = sizeof (uint16_t);
2236 table_r = table_16 + 197; 2333 table_r = table_16 + 197;
2237 table_b = table_16 + 197 + 685; 2334 table_b = table_16 + 197 + 685;
2238 table_g = table_16 + 197 + 2*682; 2335 table_g = table_16 + 197 + 2*682;
2239 2336
@@ -2267,13 +2364,16 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
2267 ((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << shift_b; 2364 ((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << shift_b;
2268 2365
2269 break; 2366 break;
2270 2367
2271 case MODE_8_RGB: 2368 case MODE_8_RGB:
2272 case MODE_8_BGR: 2369 case MODE_8_BGR:
2273 table_8 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); 2370 if (this->table_base == NULL) {
2371 this->table_base = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
2372 }
2373 table_8 = this->table_base;
2274 2374
2275 entry_size = sizeof (uint8_t); 2375 entry_size = sizeof (uint8_t);
2276 table_r = table_8 + 197; 2376 table_r = table_8 + 197;
2277 table_b = table_8 + 197 + 685; 2377 table_b = table_8 + 197 + 685;
2278 table_g = table_8 + 197 + 2*682; 2378 table_g = table_8 + 197 + 2*682;
2279 2379
@@ -2291,13 +2391,16 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
2291 break; 2391 break;
2292 2392
2293 case MODE_8_GRAY: 2393 case MODE_8_GRAY:
2294 return; 2394 return;
2295 2395
2296 case MODE_PALETTE: 2396 case MODE_PALETTE:
2297 table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); 2397 if (this->table_base == NULL) {
2398 this->table_base = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
2399 }
2400 table_16 = this->table_base;
2298 2401
2299 entry_size = sizeof (uint16_t); 2402 entry_size = sizeof (uint16_t);
2300 table_r = table_16 + 197; 2403 table_r = table_16 + 197;
2301 table_b = table_16 + 197 + 685; 2404 table_b = table_16 + 197 + 685;
2302 table_g = table_16 + 197 + 2*682; 2405 table_g = table_16 + 197 + 2*682;
2303 2406
@@ -2315,27 +2418,29 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
2315 ((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << 0; 2418 ((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << 0;
2316 2419
2317 break; 2420 break;
2318 2421
2319 2422
2320 default: 2423 default:
2321 fprintf (stderr, "mode %d not supported by yuv2rgb\n", mode); 2424 lprintf ("mode %d not supported by yuv2rgb\n", mode);
2322 abort(); 2425 _x_abort();
2323 } 2426 }
2324 2427
2325 for (i = 0; i < 256; i++) { 2428 for (i = 0; i < 256; i++) {
2326 this->table_rV[i] = (((uint8_t *) table_r) + 2429 this->table_rV[i] = (((uint8_t *) table_r) +
2327 entry_size * div_round (crv * (i-128), 76309)); 2430 entry_size * div_round (crv * (i-128), 76309));
2328 this->table_gU[i] = (((uint8_t *) table_g) + 2431 this->table_gU[i] = (((uint8_t *) table_g) +
2329 entry_size * div_round (cgu * (i-128), 76309)); 2432 entry_size * div_round (cgu * (i-128), 76309));
2330 this->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309); 2433 this->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309);
2331 this->table_bU[i] = (((uint8_t *)table_b) + 2434 this->table_bU[i] = (((uint8_t *)table_b) +
2332 entry_size * div_round (cbu * (i-128), 76309)); 2435 entry_size * div_round (cbu * (i-128), 76309));
2333 } 2436 }
2334 this->gamma = 0; 2437
2335 this->entry_size = entry_size; 2438#if defined(ARCH_X86) || defined(ARCH_X86_64)
2439 mmx_yuv2rgb_set_csc_levels (this, brightness, contrast, saturation);
2440#endif
2336} 2441}
2337 2442
2338static uint32_t yuv2rgb_single_pixel_32 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) 2443static uint32_t yuv2rgb_single_pixel_32 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
2339{ 2444{
2340 uint32_t * r, * g, * b; 2445 uint32_t * r, * g, * b;
2341 2446
@@ -2445,14 +2550,14 @@ static void yuv2rgb_c_init (yuv2rgb_factory_t *this)
2445 2550
2446 case MODE_PALETTE: 2551 case MODE_PALETTE:
2447 this->yuv2rgb_fun = yuv2rgb_c_palette; 2552 this->yuv2rgb_fun = yuv2rgb_c_palette;
2448 break; 2553 break;
2449 2554
2450 default: 2555 default:
2451 printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode); 2556 lprintf ("mode %d not supported by yuv2rgb\n", this->mode);
2452 abort(); 2557 _x_abort();
2453 } 2558 }
2454 2559
2455} 2560}
2456 2561
2457static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) { 2562static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) {
2458 2563
@@ -2488,14 +2593,14 @@ static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) {
2488 2593
2489 case MODE_PALETTE: 2594 case MODE_PALETTE:
2490 this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_palette; 2595 this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_palette;
2491 break; 2596 break;
2492 2597
2493 default: 2598 default:
2494 printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode); 2599 lprintf ("mode %d not supported by yuv2rgb\n", this->mode);
2495 abort(); 2600 _x_abort();
2496 } 2601 }
2497} 2602}
2498 2603
2499 2604
2500/* 2605/*
2501 * yuy2 stuff 2606 * yuy2 stuff
@@ -2517,34 +2622,34 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2517 scale_line_4 (_p+3, this->v_buffer, 2622 scale_line_4 (_p+3, this->v_buffer,
2518 this->dest_width >> 1, this->step_dx); 2623 this->dest_width >> 1, this->step_dx);
2519 scale_line_2 (_p, this->y_buffer, 2624 scale_line_2 (_p, this->y_buffer,
2520 this->dest_width, this->step_dx); 2625 this->dest_width, this->step_dx);
2521 2626
2522 dy = 0; 2627 dy = 0;
2523 height = this->dest_height; 2628 height = this->next_slice (this, &_dst);
2524 2629
2525 for (;;) { 2630 for (;;) {
2526 dst_1 = (uint32_t*)_dst; 2631 dst_1 = (uint32_t*)_dst;
2527 py_1 = this->y_buffer; 2632 py_1 = this->y_buffer;
2528 pu = this->u_buffer; 2633 pu = this->u_buffer;
2529 pv = this->v_buffer; 2634 pv = this->v_buffer;
2530 2635
2531 width = this->dest_width >> 3; 2636 width = this->dest_width >> 3;
2532 2637
2533 do { 2638 do {
2534 2639
2535 RGB(0); 2640 X_RGB(0);
2536 DST1(0); 2641 DST1(0);
2537 2642
2538 RGB(1); 2643 X_RGB(1);
2539 DST1(1); 2644 DST1(1);
2540 2645
2541 RGB(2); 2646 X_RGB(2);
2542 DST1(2); 2647 DST1(2);
2543 2648
2544 RGB(3); 2649 X_RGB(3);
2545 DST1(3); 2650 DST1(3);
2546 2651
2547 pu += 4; 2652 pu += 4;
2548 pv += 4; 2653 pv += 4;
2549 py_1 += 8; 2654 py_1 += 8;
2550 dst_1 += 8; 2655 dst_1 += 8;
@@ -2561,13 +2666,13 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2561 _dst += this->rgb_stride; 2666 _dst += this->rgb_stride;
2562 } 2667 }
2563 2668
2564 if (height <= 0) 2669 if (height <= 0)
2565 break; 2670 break;
2566 2671
2567 _p += this->y_stride*2*(dy>>15); 2672 _p += this->y_stride*(dy>>15);
2568 dy &= 32767; 2673 dy &= 32767;
2569 /* 2674 /*
2570 dy -= 32768; 2675 dy -= 32768;
2571 _p += this->y_stride*2; 2676 _p += this->y_stride*2;
2572 */ 2677 */
2573 2678
@@ -2596,33 +2701,33 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2596 scale_line_4 (_p+3, this->v_buffer, 2701 scale_line_4 (_p+3, this->v_buffer,
2597 this->dest_width >> 1, this->step_dx); 2702 this->dest_width >> 1, this->step_dx);
2598 scale_line_2 (_p, this->y_buffer, 2703 scale_line_2 (_p, this->y_buffer,
2599 this->dest_width, this->step_dx); 2704 this->dest_width, this->step_dx);
2600 2705
2601 dy = 0; 2706 dy = 0;
2602 height = this->dest_height; 2707 height = this->next_slice (this, &_dst);
2603 2708
2604 for (;;) { 2709 for (;;) {
2605 dst_1 = _dst; 2710 dst_1 = _dst;
2606 py_1 = this->y_buffer; 2711 py_1 = this->y_buffer;
2607 pu = this->u_buffer; 2712 pu = this->u_buffer;
2608 pv = this->v_buffer; 2713 pv = this->v_buffer;
2609 2714
2610 width = this->dest_width >> 3; 2715 width = this->dest_width >> 3;
2611 2716
2612 do { 2717 do {
2613 RGB(0); 2718 X_RGB(0);
2614 DST1RGB(0); 2719 DST1RGB(0);
2615 2720
2616 RGB(1); 2721 X_RGB(1);
2617 DST1RGB(1); 2722 DST1RGB(1);
2618 2723
2619 RGB(2); 2724 X_RGB(2);
2620 DST1RGB(2); 2725 DST1RGB(2);
2621 2726
2622 RGB(3); 2727 X_RGB(3);
2623 DST1RGB(3); 2728 DST1RGB(3);
2624 2729
2625 pu += 4; 2730 pu += 4;
2626 pv += 4; 2731 pv += 4;
2627 py_1 += 8; 2732 py_1 += 8;
2628 dst_1 += 24; 2733 dst_1 += 24;
@@ -2639,13 +2744,13 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2639 _dst += this->rgb_stride; 2744 _dst += this->rgb_stride;
2640 } 2745 }
2641 2746
2642 if (height <= 0) 2747 if (height <= 0)
2643 break; 2748 break;
2644 2749
2645 _p += this->y_stride*2*(dy>>15); 2750 _p += this->y_stride*(dy>>15);
2646 dy &= 32767; 2751 dy &= 32767;
2647 /* 2752 /*
2648 dy -= 32768; 2753 dy -= 32768;
2649 _p += this->y_stride*2; 2754 _p += this->y_stride*2;
2650 */ 2755 */
2651 2756
@@ -2674,33 +2779,33 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2674 scale_line_4 (_p+3, this->v_buffer, 2779 scale_line_4 (_p+3, this->v_buffer,
2675 this->dest_width >> 1, this->step_dx); 2780 this->dest_width >> 1, this->step_dx);
2676 scale_line_2 (_p, this->y_buffer, 2781 scale_line_2 (_p, this->y_buffer,
2677 this->dest_width, this->step_dx); 2782 this->dest_width, this->step_dx);
2678 2783
2679 dy = 0; 2784 dy = 0;
2680 height = this->dest_height; 2785 height = this->next_slice (this, &_dst);
2681 2786
2682 for (;;) { 2787 for (;;) {
2683 dst_1 = _dst; 2788 dst_1 = _dst;
2684 py_1 = this->y_buffer; 2789 py_1 = this->y_buffer;
2685 pu = this->u_buffer; 2790 pu = this->u_buffer;
2686 pv = this->v_buffer; 2791 pv = this->v_buffer;
2687 2792
2688 width = this->dest_width >> 3; 2793 width = this->dest_width >> 3;
2689 2794
2690 do { 2795 do {
2691 RGB(0); 2796 X_RGB(0);
2692 DST1BGR(0); 2797 DST1BGR(0);
2693 2798
2694 RGB(1); 2799 X_RGB(1);
2695 DST1BGR(1); 2800 DST1BGR(1);
2696 2801
2697 RGB(2); 2802 X_RGB(2);
2698 DST1BGR(2); 2803 DST1BGR(2);
2699 2804
2700 RGB(3); 2805 X_RGB(3);
2701 DST1BGR(3); 2806 DST1BGR(3);
2702 2807
2703 pu += 4; 2808 pu += 4;
2704 pv += 4; 2809 pv += 4;
2705 py_1 += 8; 2810 py_1 += 8;
2706 dst_1 += 24; 2811 dst_1 += 24;
@@ -2717,13 +2822,13 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2717 _dst += this->rgb_stride; 2822 _dst += this->rgb_stride;
2718 } 2823 }
2719 2824
2720 if (height <= 0) 2825 if (height <= 0)
2721 break; 2826 break;
2722 2827
2723 _p += this->y_stride*2*(dy>>15); 2828 _p += this->y_stride*(dy>>15);
2724 dy &= 32767; 2829 dy &= 32767;
2725 2830
2726 scale_line_4 (_p+1, this->u_buffer, 2831 scale_line_4 (_p+1, this->u_buffer,
2727 this->dest_width >> 1, this->step_dx); 2832 this->dest_width >> 1, this->step_dx);
2728 scale_line_4 (_p+3, this->v_buffer, 2833 scale_line_4 (_p+3, this->v_buffer,
2729 this->dest_width >> 1, this->step_dx); 2834 this->dest_width >> 1, this->step_dx);
@@ -2748,33 +2853,33 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2748 scale_line_4 (_p+3, this->v_buffer, 2853 scale_line_4 (_p+3, this->v_buffer,
2749 this->dest_width >> 1, this->step_dx); 2854 this->dest_width >> 1, this->step_dx);
2750 scale_line_2 (_p, this->y_buffer, 2855 scale_line_2 (_p, this->y_buffer,
2751 this->dest_width, this->step_dx); 2856 this->dest_width, this->step_dx);
2752 2857
2753 dy = 0; 2858 dy = 0;
2754 height = this->dest_height; 2859 height = this->next_slice (this, &_dst);
2755 2860
2756 for (;;) { 2861 for (;;) {
2757 dst_1 = (uint16_t*)_dst; 2862 dst_1 = (uint16_t*)_dst;
2758 py_1 = this->y_buffer; 2863 py_1 = this->y_buffer;
2759 pu = this->u_buffer; 2864 pu = this->u_buffer;
2760 pv = this->v_buffer; 2865 pv = this->v_buffer;
2761 2866
2762 width = this->dest_width >> 3; 2867 width = this->dest_width >> 3;
2763 2868
2764 do { 2869 do {
2765 RGB(0); 2870 X_RGB(0);
2766 DST1(0); 2871 DST1(0);
2767 2872
2768 RGB(1); 2873 X_RGB(1);
2769 DST1(1); 2874 DST1(1);
2770 2875
2771 RGB(2); 2876 X_RGB(2);
2772 DST1(2); 2877 DST1(2);
2773 2878
2774 RGB(3); 2879 X_RGB(3);
2775 DST1(3); 2880 DST1(3);
2776 2881
2777 pu += 4; 2882 pu += 4;
2778 pv += 4; 2883 pv += 4;
2779 py_1 += 8; 2884 py_1 += 8;
2780 dst_1 += 8; 2885 dst_1 += 8;
@@ -2791,13 +2896,13 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2791 _dst += this->rgb_stride; 2896 _dst += this->rgb_stride;
2792 } 2897 }
2793 2898
2794 if (height <= 0) 2899 if (height <= 0)
2795 break; 2900 break;
2796 2901
2797 _p += this->y_stride*2*(dy>>15); 2902 _p += this->y_stride*(dy>>15);
2798 dy &= 32767; 2903 dy &= 32767;
2799 2904
2800 scale_line_4 (_p+1, this->u_buffer, 2905 scale_line_4 (_p+1, this->u_buffer,
2801 this->dest_width >> 1, this->step_dx); 2906 this->dest_width >> 1, this->step_dx);
2802 scale_line_4 (_p+3, this->v_buffer, 2907 scale_line_4 (_p+3, this->v_buffer,
2803 this->dest_width >> 1, this->step_dx); 2908 this->dest_width >> 1, this->step_dx);
@@ -2822,33 +2927,33 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2822 scale_line_4 (_p+3, this->v_buffer, 2927 scale_line_4 (_p+3, this->v_buffer,
2823 this->dest_width >> 1, this->step_dx); 2928 this->dest_width >> 1, this->step_dx);
2824 scale_line_2 (_p, this->y_buffer, 2929 scale_line_2 (_p, this->y_buffer,
2825 this->dest_width, this->step_dx); 2930 this->dest_width, this->step_dx);
2826 2931
2827 dy = 0; 2932 dy = 0;
2828 height = this->dest_height; 2933 height = this->next_slice (this, &_dst);
2829 2934
2830 for (;;) { 2935 for (;;) {
2831 dst_1 = _dst; 2936 dst_1 = _dst;
2832 py_1 = this->y_buffer; 2937 py_1 = this->y_buffer;
2833 pu = this->u_buffer; 2938 pu = this->u_buffer;
2834 pv = this->v_buffer; 2939 pv = this->v_buffer;
2835 2940
2836 width = this->dest_width >> 3; 2941 width = this->dest_width >> 3;
2837 2942
2838 do { 2943 do {
2839 RGB(0); 2944 X_RGB(0);
2840 DST1(0); 2945 DST1(0);
2841 2946
2842 RGB(1); 2947 X_RGB(1);
2843 DST1(1); 2948 DST1(1);
2844 2949
2845 RGB(2); 2950 X_RGB(2);
2846 DST1(2); 2951 DST1(2);
2847 2952
2848 RGB(3); 2953 X_RGB(3);
2849 DST1(3); 2954 DST1(3);
2850 2955
2851 pu += 4; 2956 pu += 4;
2852 pv += 4; 2957 pv += 4;
2853 py_1 += 8; 2958 py_1 += 8;
2854 dst_1 += 8; 2959 dst_1 += 8;
@@ -2865,13 +2970,13 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2865 _dst += this->rgb_stride; 2970 _dst += this->rgb_stride;
2866 } 2971 }
2867 2972
2868 if (height <= 0) 2973 if (height <= 0)
2869 break; 2974 break;
2870 2975
2871 _p += this->y_stride*2*(dy>>15); 2976 _p += this->y_stride*(dy>>15);
2872 dy &= 32767; 2977 dy &= 32767;
2873 2978
2874 scale_line_4 (_p+1, this->u_buffer, 2979 scale_line_4 (_p+1, this->u_buffer,
2875 this->dest_width >> 1, this->step_dx); 2980 this->dest_width >> 1, this->step_dx);
2876 scale_line_4 (_p+3, this->v_buffer, 2981 scale_line_4 (_p+3, this->v_buffer,
2877 this->dest_width >> 1, this->step_dx); 2982 this->dest_width >> 1, this->step_dx);
@@ -2886,13 +2991,13 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2886 int dy; 2991 int dy;
2887 uint8_t * dst; 2992 uint8_t * dst;
2888 uint8_t * y; 2993 uint8_t * y;
2889 2994
2890 if (this->do_scale) { 2995 if (this->do_scale) {
2891 dy = 0; 2996 dy = 0;
2892 height = this->dest_height; 2997 height = this->next_slice (this, &_dst);
2893 2998
2894 for (;;) { 2999 for (;;) {
2895 scale_line_2 (_p, _dst, this->dest_width, this->step_dx); 3000 scale_line_2 (_p, _dst, this->dest_width, this->step_dx);
2896 3001
2897 dy += this->step_dy; 3002 dy += this->step_dy;
2898 _dst += this->rgb_stride; 3003 _dst += this->rgb_stride;
@@ -2905,25 +3010,25 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2905 _dst += this->rgb_stride; 3010 _dst += this->rgb_stride;
2906 } 3011 }
2907 3012
2908 if (height <= 0) 3013 if (height <= 0)
2909 break; 3014 break;
2910 3015
2911 _p += this->y_stride*2*(dy>>15); 3016 _p += this->y_stride*(dy>>15);
2912 dy &= 32767; 3017 dy &= 32767;
2913 } 3018 }
2914 } else { 3019 } else {
2915 for (height = this->source_height; --height >= 0; ) { 3020 for (height = this->next_slice (this, &_dst); --height >= 0; ) {
2916 dst = _dst; 3021 dst = _dst;
2917 y = _p; 3022 y = _p;
2918 for (width = this->source_width; --width >= 0; ) { 3023 for (width = this->source_width; --width >= 0; ) {
2919 *dst++ = *y; 3024 *dst++ = *y;
2920 y += 2; 3025 y += 2;
2921 } 3026 }
2922 _dst += this->rgb_stride; 3027 _dst += this->rgb_stride;
2923 _p += this->y_stride*2; 3028 _p += this->y_stride;
2924 } 3029 }
2925 } 3030 }
2926} 3031}
2927 3032
2928static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) 3033static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2929{ 3034{
@@ -2939,33 +3044,33 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2939 scale_line_4 (_p+3, this->v_buffer, 3044 scale_line_4 (_p+3, this->v_buffer,
2940 this->dest_width >> 1, this->step_dx); 3045 this->dest_width >> 1, this->step_dx);
2941 scale_line_2 (_p, this->y_buffer, 3046 scale_line_2 (_p, this->y_buffer,
2942 this->dest_width, this->step_dx); 3047 this->dest_width, this->step_dx);
2943 3048
2944 dy = 0; 3049 dy = 0;
2945 height = this->dest_height; 3050 height = this->next_slice (this, &_dst);
2946 3051
2947 for (;;) { 3052 for (;;) {
2948 dst_1 = _dst; 3053 dst_1 = _dst;
2949 py_1 = this->y_buffer; 3054 py_1 = this->y_buffer;
2950 pu = this->u_buffer; 3055 pu = this->u_buffer;
2951 pv = this->v_buffer; 3056 pv = this->v_buffer;
2952 3057
2953 width = this->dest_width >> 3; 3058 width = this->dest_width >> 3;
2954 3059
2955 do { 3060 do {
2956 RGB(0); 3061 X_RGB(0);
2957 DST1CMAP(0); 3062 DST1CMAP(0);
2958 3063
2959 RGB(1); 3064 X_RGB(1);
2960 DST1CMAP(1); 3065 DST1CMAP(1);
2961 3066
2962 RGB(2); 3067 X_RGB(2);
2963 DST1CMAP(2); 3068 DST1CMAP(2);
2964 3069
2965 RGB(3); 3070 X_RGB(3);
2966 DST1CMAP(3); 3071 DST1CMAP(3);
2967 3072
2968 pu += 4; 3073 pu += 4;
2969 pv += 4; 3074 pv += 4;
2970 py_1 += 8; 3075 py_1 += 8;
2971 dst_1 += 8; 3076 dst_1 += 8;
@@ -2982,13 +3087,13 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2982 _dst += this->rgb_stride; 3087 _dst += this->rgb_stride;
2983 } 3088 }
2984 3089
2985 if (height <= 0) 3090 if (height <= 0)
2986 break; 3091 break;
2987 3092
2988 _p += this->y_stride*2*(dy>>15); 3093 _p += this->y_stride*(dy>>15);
2989 dy &= 32767; 3094 dy &= 32767;
2990 3095
2991 scale_line_4 (_p+1, this->u_buffer, 3096 scale_line_4 (_p+1, this->u_buffer,
2992 this->dest_width >> 1, this->step_dx); 3097 this->dest_width >> 1, this->step_dx);
2993 scale_line_4 (_p+3, this->v_buffer, 3098 scale_line_4 (_p+3, this->v_buffer,
2994 this->dest_width >> 1, this->step_dx); 3099 this->dest_width >> 1, this->step_dx);
@@ -3030,125 +3135,131 @@ static void yuy22rgb_c_init (yuv2rgb_factory_t *this)
3030 3135
3031 case MODE_PALETTE: 3136 case MODE_PALETTE:
3032 this->yuy22rgb_fun = yuy22rgb_c_palette; 3137 this->yuy22rgb_fun = yuy22rgb_c_palette;
3033 break; 3138 break;
3034 3139
3035 default: 3140 default:
3036 printf ("yuv2rgb: mode %d not supported for yuy2\n", this->mode); 3141 lprintf ("mode %d not supported for yuy2\n", this->mode);
3037 } 3142 }
3038} 3143}
3039 3144
3040yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { 3145static yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
3041 3146
3042 yuv2rgb_t *this = xine_xmalloc (sizeof (yuv2rgb_t)); 3147 yuv2rgb_t *this = xine_xmalloc (sizeof (yuv2rgb_t));
3043 3148
3149 this->swapped = factory->swapped;
3044 this->cmap = factory->cmap; 3150 this->cmap = factory->cmap;
3045 3151
3046 this->y_chunk = this->y_buffer = NULL; 3152 this->y_chunk = this->y_buffer = NULL;
3047 this->u_chunk = this->u_buffer = NULL; 3153 this->u_chunk = this->u_buffer = NULL;
3048 this->v_chunk = this->v_buffer = NULL; 3154 this->v_chunk = this->v_buffer = NULL;
3049 3155
3156#ifdef HAVE_MLIB
3157 this->mlib_chunk = this->mlib_buffer = NULL;
3158 this->mlib_resize_chunk = this->mlib_resize_buffer = NULL;
3159 this->mlib_filter_type = MLIB_BILINEAR;
3160#endif
3161
3050 this->table_rV = factory->table_rV; 3162 this->table_rV = factory->table_rV;
3051 this->table_gU = factory->table_gU; 3163 this->table_gU = factory->table_gU;
3052 this->table_gV = factory->table_gV; 3164 this->table_gV = factory->table_gV;
3053 this->table_bU = factory->table_bU; 3165 this->table_bU = factory->table_bU;
3166 this->table_mmx = factory->table_mmx;
3054 3167
3055 this->yuv2rgb_fun = factory->yuv2rgb_fun; 3168 this->yuv2rgb_fun = factory->yuv2rgb_fun;
3056 this->yuy22rgb_fun = factory->yuy22rgb_fun; 3169 this->yuy22rgb_fun = factory->yuy22rgb_fun;
3057 this->yuv2rgb_single_pixel_fun = factory->yuv2rgb_single_pixel_fun; 3170 this->yuv2rgb_single_pixel_fun = factory->yuv2rgb_single_pixel_fun;
3058 3171
3059 this->configure = yuv2rgb_configure; 3172 this->configure = yuv2rgb_configure;
3173 this->next_slice = yuv2rgb_next_slice;
3174 this->dispose = yuv2rgb_dispose;
3060 return this; 3175 return this;
3061} 3176}
3062 3177
3063/* 3178/*
3064 * factory functions 3179 * factory functions
3065 */ 3180 */
3066void yuv2rgb_set_gamma (yuv2rgb_factory_t *this, int gamma) {
3067
3068 int i;
3069
3070 for (i = 0; i < 256; i++) {
3071 (uint8_t *)this->table_rV[i] += this->entry_size*(gamma - this->gamma);
3072 (uint8_t *)this->table_gU[i] += this->entry_size*(gamma - this->gamma);
3073 (uint8_t *)this->table_bU[i] += this->entry_size*(gamma - this->gamma);
3074 }
3075#ifdef ARCH_X86
3076 mmx_yuv2rgb_set_gamma(gamma);
3077#endif
3078 this->gamma = gamma;
3079}
3080 3181
3081int yuv2rgb_get_gamma (yuv2rgb_factory_t *this) { 3182static void yuv2rgb_factory_dispose (yuv2rgb_factory_t *this) {
3082 3183
3083 return this->gamma; 3184 free (this->table_base);
3185 free (this->table_mmx_base);
3186 free (this);
3084} 3187}
3085 3188
3086yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, 3189yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
3087 uint8_t *cmap) { 3190 uint8_t *cmap) {
3088 3191
3089 yuv2rgb_factory_t *this; 3192 yuv2rgb_factory_t *this;
3090
3091#ifdef ARCH_X86
3092 uint32_t mm = xine_mm_accel(); 3193 uint32_t mm = xine_mm_accel();
3093#endif
3094 3194
3095 this = malloc (sizeof (yuv2rgb_factory_t)); 3195 this = malloc (sizeof (yuv2rgb_factory_t));
3096 3196
3097 this->mode = mode; 3197 this->mode = mode;
3098 this->swapped = swapped; 3198 this->swapped = swapped;
3099 this->cmap = cmap; 3199 this->cmap = cmap;
3100 this->create_converter = yuv2rgb_create_converter; 3200 this->create_converter = yuv2rgb_create_converter;
3101 this->set_gamma = yuv2rgb_set_gamma; 3201 this->set_csc_levels = yuv2rgb_set_csc_levels;
3102 this->get_gamma = yuv2rgb_get_gamma; 3202 this->dispose = yuv2rgb_factory_dispose;
3103 this->matrix_coefficients = 6; 3203 this->matrix_coefficients = 6;
3204 this->table_base = NULL;
3205 this->table_mmx = NULL;
3206 this->table_mmx_base = NULL;
3104 3207
3105 3208
3106 yuv2rgb_setup_tables (this, mode, swapped); 3209 yuv2rgb_set_csc_levels (this, 0, 128, 128);
3107 3210
3108 /* 3211 /*
3109 * auto-probe for the best yuv2rgb function 3212 * auto-probe for the best yuv2rgb function
3110 */ 3213 */
3111 3214
3112 this->yuv2rgb_fun = NULL; 3215 this->yuv2rgb_fun = NULL;
3113#ifdef ARCH_X86 3216#if defined(ARCH_X86) || defined(ARCH_X86_64)
3114 if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMXEXT)) { 3217 if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMXEXT)) {
3115 3218
3116 yuv2rgb_init_mmxext (this); 3219 yuv2rgb_init_mmxext (this);
3117 3220
3221#ifdef LOG
3118 if (this->yuv2rgb_fun != NULL) 3222 if (this->yuv2rgb_fun != NULL)
3119 printf ("yuv2rgb: using MMXEXT for colorspace transform\n"); 3223 printf ("yuv2rgb: using MMXEXT for colorspace transform\n");
3224#endif
3120 } 3225 }
3121 3226
3122 if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMX)) { 3227 if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMX)) {
3123 3228
3124 yuv2rgb_init_mmx (this); 3229 yuv2rgb_init_mmx (this);
3125 3230
3231#ifdef LOG
3126 if (this->yuv2rgb_fun != NULL) 3232 if (this->yuv2rgb_fun != NULL)
3127 printf ("yuv2rgb: using MMX for colorspace transform\n"); 3233 printf ("yuv2rgb: using MMX for colorspace transform\n");
3234#endif
3235 }
3236#ifdef __arm__
3237 if (this->yuv2rgb_fun == NULL) {
3238 yuv2rgb_init_arm ( this );
3239
3240 if(this->yuv2rgb_fun != NULL)
3241 printf("yuv2rgb: using arm4l assembler for colorspace transform\n" );
3128 } 3242 }
3129#endif 3243#endif
3244
3245#endif
3130#if HAVE_MLIB 3246#if HAVE_MLIB
3131 if (this->yuv2rgb_fun == NULL) { 3247 if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_MLIB)) {
3132 3248
3133 yuv2rgb_init_mlib (this); 3249 yuv2rgb_init_mlib (this);
3134 3250
3251#ifdef LOG
3135 if (this->yuv2rgb_fun != NULL) 3252 if (this->yuv2rgb_fun != NULL)
3136 printf ("yuv2rgb: using medialib for colorspace transform\n"); 3253 printf ("yuv2rgb: using medialib for colorspace transform\n");
3137 }
3138#endif 3254#endif
3139#ifdef __arm__
3140 if (this->yuv2rgb_fun == NULL) {
3141 yuv2rgb_init_arm ( this );
3142
3143 if(this->yuv2rgb_fun != NULL)
3144 printf("yuv2rgb: using arm4l assembler for colorspace transform\n" );
3145 } 3255 }
3146#endif 3256#endif
3147 if (this->yuv2rgb_fun == NULL) { 3257 if (this->yuv2rgb_fun == NULL) {
3148 printf ("yuv2rgb: no accelerated colorspace conversion found\n"); 3258 lprintf ("no accelerated colorspace conversion found\n");
3259
3149 yuv2rgb_c_init (this); 3260 yuv2rgb_c_init (this);
3150 } 3261 }
3151 3262
3152 /* 3263 /*
3153 * auto-probe for the best yuy22rgb function 3264 * auto-probe for the best yuy22rgb function
3154 */ 3265 */
@@ -3161,7 +3272,6 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
3161 */ 3272 */
3162 3273
3163 yuv2rgb_single_pixel_init (this); 3274 yuv2rgb_single_pixel_init (this);
3164 3275
3165 return this; 3276 return this;
3166} 3277}
3167