summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/yuv2rgb.c
Unidiff
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 @@
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 *
@@ -33,4 +34,10 @@
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
@@ -53,4 +60,4 @@ const int32_t Inverse_Table_6_9[8][4] = {
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;
@@ -61,3 +68,3 @@ static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) {
61 68
62 while ((int) pMem % alignment) 69 while ((uintptr_t) pMem % alignment)
63 pMem++; 70 pMem++;
@@ -68,2 +75,39 @@ static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) {
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,
@@ -87,2 +131,4 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
87 this->rgb_stride = rgb_stride; 131 this->rgb_stride = rgb_stride;
132 this->slice_height = source_height;
133 this->slice_offset = 0;
88 134
@@ -101,2 +147,12 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
101 147
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
102 158
@@ -104,3 +160,6 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
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);
@@ -140,2 +199,15 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
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 }
@@ -144,3 +216,2 @@ static int yuv2rgb_configure (yuv2rgb_t *this,
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,
@@ -1206,2 +1277,6 @@ static scale_line_func_t find_scale_line_func(int step) {
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
@@ -1209,3 +1284,7 @@ static scale_line_func_t find_scale_line_func(int step) {
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;
@@ -1213,5 +1292,10 @@ static scale_line_func_t find_scale_line_func(int step) {
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}
@@ -1274,3 +1358,3 @@ static void scale_line_4 (uint8_t *source, uint8_t *dest,
1274 1358
1275 #define RGB(i) \ 1359 #define X_RGB(i) \
1276 U = pu[i]; \ 1360 U = pu[i]; \
@@ -1350,3 +1434,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
1350 dy = 0; 1434 dy = 0;
1351 dst_height = this->dest_height; 1435 dst_height = this->next_slice (this, &_dst);
1352 1436
@@ -1361,12 +1445,12 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1414,3 +1498,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
1414 } else { 1498 } else {
1415 height = this->source_height >> 1; 1499 height = this->next_slice (this, &_dst) >> 1;
1416 do { 1500 do {
@@ -1425,3 +1509,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
1425 do { 1509 do {
1426 RGB(0); 1510 X_RGB(0);
1427 DST1(0); 1511 DST1(0);
@@ -1429,3 +1513,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
1429 1513
1430 RGB(1); 1514 X_RGB(1);
1431 DST2(1); 1515 DST2(1);
@@ -1433,3 +1517,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
1433 1517
1434 RGB(2); 1518 X_RGB(2);
1435 DST1(2); 1519 DST1(2);
@@ -1437,3 +1521,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
1437 1521
1438 RGB(3); 1522 X_RGB(3);
1439 DST2(3); 1523 DST2(3);
@@ -1481,3 +1565,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
1481 dy = 0; 1565 dy = 0;
1482 dst_height = this->dest_height; 1566 dst_height = this->next_slice (this, &_dst);
1483 1567
@@ -1492,12 +1576,12 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1545,3 +1629,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
1545 } else { 1629 } else {
1546 height = this->source_height >> 1; 1630 height = this->next_slice (this, &_dst) >> 1;
1547 do { 1631 do {
@@ -1556,3 +1640,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
1556 do { 1640 do {
1557 RGB(0); 1641 X_RGB(0);
1558 DST1RGB(0); 1642 DST1RGB(0);
@@ -1560,3 +1644,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
1560 1644
1561 RGB(1); 1645 X_RGB(1);
1562 DST2RGB(1); 1646 DST2RGB(1);
@@ -1564,3 +1648,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
1564 1648
1565 RGB(2); 1649 X_RGB(2);
1566 DST1RGB(2); 1650 DST1RGB(2);
@@ -1568,3 +1652,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
1568 1652
1569 RGB(3); 1653 X_RGB(3);
1570 DST2RGB(3); 1654 DST2RGB(3);
@@ -1612,3 +1696,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
1612 dy = 0; 1696 dy = 0;
1613 dst_height = this->dest_height; 1697 dst_height = this->next_slice (this, &_dst);
1614 1698
@@ -1623,12 +1707,12 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1677,3 +1761,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
1677 } else { 1761 } else {
1678 height = this->source_height >> 1; 1762 height = this->next_slice (this, &_dst) >> 1;
1679 do { 1763 do {
@@ -1687,3 +1771,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
1687 do { 1771 do {
1688 RGB(0); 1772 X_RGB(0);
1689 DST1BGR(0); 1773 DST1BGR(0);
@@ -1691,3 +1775,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
1691 1775
1692 RGB(1); 1776 X_RGB(1);
1693 DST2BGR(1); 1777 DST2BGR(1);
@@ -1695,3 +1779,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
1695 1779
1696 RGB(2); 1780 X_RGB(2);
1697 DST1BGR(2); 1781 DST1BGR(2);
@@ -1699,3 +1783,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
1699 1783
1700 RGB(3); 1784 X_RGB(3);
1701 DST2BGR(3); 1785 DST2BGR(3);
@@ -1743,3 +1827,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
1743 dy = 0; 1827 dy = 0;
1744 dst_height = this->dest_height; 1828 dst_height = this->next_slice (this, &_dst);
1745 1829
@@ -1754,12 +1838,12 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1807,3 +1891,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
1807 } else { 1891 } else {
1808 height = this->source_height >> 1; 1892 height = this->next_slice (this, &_dst) >> 1;
1809 do { 1893 do {
@@ -1817,3 +1901,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
1817 do { 1901 do {
1818 RGB(0); 1902 X_RGB(0);
1819 DST1(0); 1903 DST1(0);
@@ -1821,3 +1905,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
1821 1905
1822 RGB(1); 1906 X_RGB(1);
1823 DST2(1); 1907 DST2(1);
@@ -1825,3 +1909,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
1825 1909
1826 RGB(2); 1910 X_RGB(2);
1827 DST1(2); 1911 DST1(2);
@@ -1829,3 +1913,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
1829 1913
1830 RGB(3); 1914 X_RGB(3);
1831 DST2(3); 1915 DST2(3);
@@ -1873,3 +1957,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
1873 dy = 0; 1957 dy = 0;
1874 dst_height = this->dest_height; 1958 dst_height = this->next_slice (this, &_dst);
1875 1959
@@ -1884,12 +1968,12 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -1937,3 +2021,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
1937 } else { 2021 } else {
1938 height = this->source_height >> 1; 2022 height = this->next_slice (this, &_dst) >> 1;
1939 do { 2023 do {
@@ -1948,3 +2032,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
1948 do { 2032 do {
1949 RGB(0); 2033 X_RGB(0);
1950 DST1(0); 2034 DST1(0);
@@ -1952,3 +2036,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
1952 2036
1953 RGB(1); 2037 X_RGB(1);
1954 DST2(1); 2038 DST2(1);
@@ -1956,3 +2040,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
1956 2040
1957 RGB(2); 2041 X_RGB(2);
1958 DST1(2); 2042 DST1(2);
@@ -1960,3 +2044,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
1960 2044
1961 RGB(3); 2045 X_RGB(3);
1962 DST2(3); 2046 DST2(3);
@@ -1992,3 +2076,3 @@ static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst,
1992 dy = 0; 2076 dy = 0;
1993 dst_height = this->dest_height; 2077 dst_height = this->next_slice (this, &_dst);
1994 2078
@@ -2018,3 +2102,3 @@ static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -2048,3 +2132,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
2048 dy = 0; 2132 dy = 0;
2049 dst_height = this->dest_height; 2133 dst_height = this->next_slice (this, &_dst);
2050 2134
@@ -2059,12 +2143,12 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
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);
@@ -2112,3 +2196,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
2112 } else { 2196 } else {
2113 height = this->source_height >> 1; 2197 height = this->next_slice (this, &_dst) >> 1;
2114 do { 2198 do {
@@ -2122,3 +2206,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
2122 do { 2206 do {
2123 RGB(0); 2207 X_RGB(0);
2124 DST1CMAP(0); 2208 DST1CMAP(0);
@@ -2126,3 +2210,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
2126 2210
2127 RGB(1); 2211 X_RGB(1);
2128 DST2CMAP(1); 2212 DST2CMAP(1);
@@ -2130,3 +2214,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
2130 2214
2131 RGB(2); 2215 X_RGB(2);
2132 DST1CMAP(2); 2216 DST1CMAP(2);
@@ -2134,3 +2218,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
2134 2218
2135 RGB(3); 2219 X_RGB(3);
2136 DST2CMAP(3); 2220 DST2CMAP(3);
@@ -2163,3 +2247,4 @@ static int div_round (int dividend, int divisor)
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{
@@ -2179,2 +2264,5 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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++) {
@@ -2182,3 +2270,3 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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);
@@ -2190,3 +2278,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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
@@ -2219,3 +2310,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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
@@ -2232,3 +2326,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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
@@ -2272,3 +2369,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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
@@ -2296,3 +2396,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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
@@ -2320,4 +2423,4 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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 }
@@ -2333,4 +2436,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped
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}
@@ -2450,4 +2555,4 @@ static void yuv2rgb_c_init (yuv2rgb_factory_t *this)
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 }
@@ -2493,4 +2598,4 @@ static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) {
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 }
@@ -2522,3 +2627,3 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2522 dy = 0; 2627 dy = 0;
2523 height = this->dest_height; 2628 height = this->next_slice (this, &_dst);
2524 2629
@@ -2534,12 +2639,12 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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);
@@ -2566,3 +2671,3 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2566 2671
2567 _p += this->y_stride*2*(dy>>15); 2672 _p += this->y_stride*(dy>>15);
2568 dy &= 32767; 2673 dy &= 32767;
@@ -2601,3 +2706,3 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2601 dy = 0; 2706 dy = 0;
2602 height = this->dest_height; 2707 height = this->next_slice (this, &_dst);
2603 2708
@@ -2612,12 +2717,12 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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);
@@ -2644,3 +2749,3 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2644 2749
2645 _p += this->y_stride*2*(dy>>15); 2750 _p += this->y_stride*(dy>>15);
2646 dy &= 32767; 2751 dy &= 32767;
@@ -2679,3 +2784,3 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2679 dy = 0; 2784 dy = 0;
2680 height = this->dest_height; 2785 height = this->next_slice (this, &_dst);
2681 2786
@@ -2690,12 +2795,12 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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);
@@ -2722,3 +2827,3 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2722 2827
2723 _p += this->y_stride*2*(dy>>15); 2828 _p += this->y_stride*(dy>>15);
2724 dy &= 32767; 2829 dy &= 32767;
@@ -2753,3 +2858,3 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2753 dy = 0; 2858 dy = 0;
2754 height = this->dest_height; 2859 height = this->next_slice (this, &_dst);
2755 2860
@@ -2764,12 +2869,12 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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);
@@ -2796,3 +2901,3 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2796 2901
2797 _p += this->y_stride*2*(dy>>15); 2902 _p += this->y_stride*(dy>>15);
2798 dy &= 32767; 2903 dy &= 32767;
@@ -2827,3 +2932,3 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2827 dy = 0; 2932 dy = 0;
2828 height = this->dest_height; 2933 height = this->next_slice (this, &_dst);
2829 2934
@@ -2838,12 +2943,12 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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);
@@ -2870,3 +2975,3 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2870 2975
2871 _p += this->y_stride*2*(dy>>15); 2976 _p += this->y_stride*(dy>>15);
2872 dy &= 32767; 2977 dy &= 32767;
@@ -2891,3 +2996,3 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2891 dy = 0; 2996 dy = 0;
2892 height = this->dest_height; 2997 height = this->next_slice (this, &_dst);
2893 2998
@@ -2910,3 +3015,3 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2910 3015
2911 _p += this->y_stride*2*(dy>>15); 3016 _p += this->y_stride*(dy>>15);
2912 dy &= 32767; 3017 dy &= 32767;
@@ -2914,3 +3019,3 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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;
@@ -2922,3 +3027,3 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2922 _dst += this->rgb_stride; 3027 _dst += this->rgb_stride;
2923 _p += this->y_stride*2; 3028 _p += this->y_stride;
2924 } 3029 }
@@ -2944,3 +3049,3 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2944 dy = 0; 3049 dy = 0;
2945 height = this->dest_height; 3050 height = this->next_slice (this, &_dst);
2946 3051
@@ -2955,12 +3060,12 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
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);
@@ -2987,3 +3092,3 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2987 3092
2988 _p += this->y_stride*2*(dy>>15); 3093 _p += this->y_stride*(dy>>15);
2989 dy &= 32767; 3094 dy &= 32767;
@@ -3035,3 +3140,3 @@ static void yuy22rgb_c_init (yuv2rgb_factory_t *this)
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 }
@@ -3039,3 +3144,3 @@ static void yuy22rgb_c_init (yuv2rgb_factory_t *this)
3039 3144
3040yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { 3145static yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
3041 3146
@@ -3043,2 +3148,3 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
3043 3148
3149 this->swapped = factory->swapped;
3044 this->cmap = factory->cmap; 3150 this->cmap = factory->cmap;
@@ -3049,2 +3155,8 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
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;
@@ -3053,2 +3165,3 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
3053 this->table_bU = factory->table_bU; 3165 this->table_bU = factory->table_bU;
3166 this->table_mmx = factory->table_mmx;
3054 3167
@@ -3059,2 +3172,4 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
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;
@@ -3065,20 +3180,8 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
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}
@@ -3089,6 +3192,3 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
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
@@ -3100,8 +3200,11 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
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
@@ -3112,3 +3215,3 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
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)) {
@@ -3117,4 +3220,6 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
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 }
@@ -3125,8 +3230,19 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
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
3128 } 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" );
3242 }
3243#endif
3244
3129#endif 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
@@ -3134,12 +3250,6 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
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 }
@@ -3147,3 +3257,4 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
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);
@@ -3166,2 +3277 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
3166} 3277}
3167