Diffstat (limited to 'noncore/multimedia/opieplayer2/yuv2rgb.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb.c | 446 |
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,16 +1,17 @@ | |||
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 | * |
11 | * mpeg2dec is free software; you can redistribute it and/or modify | 12 | * mpeg2dec is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by | 13 | * it under the terms of the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2 of the License, or | 14 | * the Free Software Foundation; either version 2 of the License, or |
14 | * (at your option) any later version. | 15 | * (at your option) any later version. |
15 | * | 16 | * |
16 | * mpeg2dec is distributed in the hope that it will be useful, | 17 | * mpeg2dec is distributed in the hope that it will be useful, |
@@ -22,96 +23,154 @@ | |||
22 | * along with this program; if not, write to the Free Software | 23 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 | * | 25 | * |
25 | * $Id$ | 26 | * $Id$ |
26 | */ | 27 | */ |
27 | 28 | ||
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 | ||
37 | static int prof_scale_line = -1; | 44 | static int prof_scale_line = -1; |
38 | 45 | ||
39 | static scale_line_func_t find_scale_line_func(int step); | 46 | static scale_line_func_t find_scale_line_func(int step); |
40 | 47 | ||
41 | 48 | ||
42 | const int32_t Inverse_Table_6_9[8][4] = { | 49 | const int32_t Inverse_Table_6_9[8][4] = { |
43 | {117504, 138453, 13954, 34903}, /* no sequence_display_extension */ | 50 | {117504, 138453, 13954, 34903}, /* no sequence_display_extension */ |
44 | {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */ | 51 | {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */ |
45 | {104597, 132201, 25675, 53279}, /* unspecified */ | 52 | {104597, 132201, 25675, 53279}, /* unspecified */ |
46 | {104597, 132201, 25675, 53279}, /* reserved */ | 53 | {104597, 132201, 25675, 53279}, /* reserved */ |
47 | {104448, 132798, 24759, 53109}, /* FCC */ | 54 | {104448, 132798, 24759, 53109}, /* FCC */ |
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 | ||
54 | static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) { | 61 | static 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 | ||
76 | static 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 | |||
102 | static 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 | |||
69 | static int yuv2rgb_configure (yuv2rgb_t *this, | 113 | static 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); |
95 | this->u_buffer = this->u_chunk = NULL; | 141 | this->u_buffer = this->u_chunk = NULL; |
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 | /* |
112 | * space for two y-lines (for yuv2rgb_mlib) | 171 | * space for two y-lines (for yuv2rgb_mlib) |
113 | * u,v subsampled 2:1 | 172 | * u,v subsampled 2:1 |
114 | */ | 173 | */ |
115 | this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk); | 174 | this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk); |
116 | if (!this->y_buffer) | 175 | if (!this->y_buffer) |
117 | return 0; | 176 | return 0; |
@@ -129,29 +188,41 @@ static int yuv2rgb_configure (yuv2rgb_t *this, | |||
129 | * space for two y-lines (for yuv2rgb_mlib) | 188 | * space for two y-lines (for yuv2rgb_mlib) |
130 | * u,v subsampled 2:1 | 189 | * u,v subsampled 2:1 |
131 | */ | 190 | */ |
132 | this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk); | 191 | this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk); |
133 | if (!this->y_buffer) | 192 | if (!this->y_buffer) |
134 | return 0; | 193 | return 0; |
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 | |||
146 | static void scale_line_gen (uint8_t *source, uint8_t *dest, | 217 | static 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) |
152 | */ | 223 | */ |
153 | int p1; | 224 | int p1; |
154 | int p2; | 225 | int p2; |
155 | int dx; | 226 | int dx; |
156 | 227 | ||
157 | xine_profiler_start_count(prof_scale_line); | 228 | xine_profiler_start_count(prof_scale_line); |
@@ -1195,34 +1266,47 @@ static scale_line_func_t find_scale_line_func(int step) { | |||
1195 | { 15, 16, scale_line_15_16, "dvd 4:3(pal)" }, | 1266 | { 15, 16, scale_line_15_16, "dvd 4:3(pal)" }, |
1196 | { 45, 64, scale_line_45_64, "dvd 16:9(pal), fullscreen(1024x768)" }, | 1267 | { 45, 64, scale_line_45_64, "dvd 16:9(pal), fullscreen(1024x768)" }, |
1197 | { 9, 16, scale_line_9_16, "dvd fullscreen(1280x1024)" }, | 1268 | { 9, 16, scale_line_9_16, "dvd fullscreen(1280x1024)" }, |
1198 | { 45, 53, scale_line_45_53, "dvd 16:9(ntsc)" }, | 1269 | { 45, 53, scale_line_45_53, "dvd 16:9(ntsc)" }, |
1199 | { 11, 12, scale_line_11_12, "vcd 4:3(pal)" }, | 1270 | { 11, 12, scale_line_11_12, "vcd 4:3(pal)" }, |
1200 | { 11, 24, scale_line_11_24, "vcd 4:3(pal) 2*zoom" }, | 1271 | { 11, 24, scale_line_11_24, "vcd 4:3(pal) 2*zoom" }, |
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 | ||
1220 | static void scale_line_2 (uint8_t *source, uint8_t *dest, | 1304 | static 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; |
1223 | int p2; | 1307 | int p2; |
1224 | int dx; | 1308 | int dx; |
1225 | 1309 | ||
1226 | p1 = *source; source+=2; | 1310 | p1 = *source; source+=2; |
1227 | p2 = *source; source+=2; | 1311 | p2 = *source; source+=2; |
1228 | dx = 0; | 1312 | dx = 0; |
@@ -1263,25 +1347,25 @@ static void scale_line_4 (uint8_t *source, uint8_t *dest, | |||
1263 | dx -= 32768; | 1347 | dx -= 32768; |
1264 | p1 = p2; | 1348 | p1 = p2; |
1265 | p2 = *source; | 1349 | p2 = *source; |
1266 | source+=4; | 1350 | source+=4; |
1267 | } | 1351 | } |
1268 | 1352 | ||
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 | ||
1282 | #define DST1(i) \ | 1366 | #define DST1(i) \ |
1283 | Y = py_1[2*i]; \ | 1367 | Y = py_1[2*i]; \ |
1284 | dst_1[2*i] = r[Y] + g[Y] + b[Y];\ | 1368 | dst_1[2*i] = r[Y] + g[Y] + b[Y];\ |
1285 | Y = py_1[2*i+1]; \ | 1369 | Y = py_1[2*i+1]; \ |
1286 | dst_1[2*i+1] = r[Y] + g[Y] + b[Y]; | 1370 | dst_1[2*i+1] = r[Y] + g[Y] + b[Y]; |
1287 | 1371 | ||
@@ -1339,45 +1423,45 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
1339 | 1423 | ||
1340 | if (this->do_scale) { | 1424 | if (this->do_scale) { |
1341 | scale_line_func_t scale_line = this->scale_line; | 1425 | scale_line_func_t scale_line = this->scale_line; |
1342 | 1426 | ||
1343 | scale_line (_pu, this->u_buffer, | 1427 | scale_line (_pu, this->u_buffer, |
1344 | this->dest_width >> 1, this->step_dx); | 1428 | this->dest_width >> 1, this->step_dx); |
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; |
1378 | } while (--width); | 1462 | } while (--width); |
1379 | 1463 | ||
1380 | dy += this->step_dy; | 1464 | dy += this->step_dy; |
1381 | _dst += this->rgb_stride; | 1465 | _dst += this->rgb_stride; |
1382 | 1466 | ||
1383 | while (--dst_height > 0 && dy < 32768) { | 1467 | while (--dst_height > 0 && dy < 32768) { |
@@ -1403,48 +1487,48 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
1403 | _pv += this->uv_stride; | 1487 | _pv += this->uv_stride; |
1404 | 1488 | ||
1405 | scale_line (_pu, this->u_buffer, | 1489 | scale_line (_pu, this->u_buffer, |
1406 | this->dest_width >> 1, this->step_dx); | 1490 | this->dest_width >> 1, this->step_dx); |
1407 | scale_line (_pv, this->v_buffer, | 1491 | scale_line (_pv, this->v_buffer, |
1408 | this->dest_width >> 1, this->step_dx); | 1492 | this->dest_width >> 1, this->step_dx); |
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; |
1445 | py_2 += 8; | 1529 | py_2 += 8; |
1446 | dst_1 += 8; | 1530 | dst_1 += 8; |
1447 | dst_2 += 8; | 1531 | dst_2 += 8; |
1448 | } while (--width); | 1532 | } while (--width); |
1449 | 1533 | ||
1450 | _dst += 2 * this->rgb_stride; | 1534 | _dst += 2 * this->rgb_stride; |
@@ -1470,45 +1554,45 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
1470 | if (this->do_scale) { | 1554 | if (this->do_scale) { |
1471 | 1555 | ||
1472 | scale_line_func_t scale_line = this->scale_line; | 1556 | scale_line_func_t scale_line = this->scale_line; |
1473 | 1557 | ||
1474 | scale_line (_pu, this->u_buffer, | 1558 | scale_line (_pu, this->u_buffer, |
1475 | this->dest_width >> 1, this->step_dx); | 1559 | this->dest_width >> 1, this->step_dx); |
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; |
1509 | } while (--width); | 1593 | } while (--width); |
1510 | 1594 | ||
1511 | dy += this->step_dy; | 1595 | dy += this->step_dy; |
1512 | _dst += this->rgb_stride; | 1596 | _dst += this->rgb_stride; |
1513 | 1597 | ||
1514 | while (--dst_height > 0 && dy < 32768) { | 1598 | while (--dst_height > 0 && dy < 32768) { |
@@ -1534,48 +1618,48 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
1534 | _pv += this->uv_stride; | 1618 | _pv += this->uv_stride; |
1535 | 1619 | ||
1536 | scale_line (_pu, this->u_buffer, | 1620 | scale_line (_pu, this->u_buffer, |
1537 | this->dest_width >> 1, this->step_dx); | 1621 | this->dest_width >> 1, this->step_dx); |
1538 | scale_line (_pv, this->v_buffer, | 1622 | scale_line (_pv, this->v_buffer, |
1539 | this->dest_width >> 1, this->step_dx); | 1623 | this->dest_width >> 1, this->step_dx); |
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; |
1576 | py_2 += 8; | 1660 | py_2 += 8; |
1577 | dst_1 += 24; | 1661 | dst_1 += 24; |
1578 | dst_2 += 24; | 1662 | dst_2 += 24; |
1579 | } while (--width); | 1663 | } while (--width); |
1580 | 1664 | ||
1581 | _dst += 2 * this->rgb_stride; | 1665 | _dst += 2 * this->rgb_stride; |
@@ -1601,45 +1685,45 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
1601 | if (this->do_scale) { | 1685 | if (this->do_scale) { |
1602 | 1686 | ||
1603 | scale_line_func_t scale_line = this->scale_line; | 1687 | scale_line_func_t scale_line = this->scale_line; |
1604 | 1688 | ||
1605 | scale_line (_pu, this->u_buffer, | 1689 | scale_line (_pu, this->u_buffer, |
1606 | this->dest_width >> 1, this->step_dx); | 1690 | this->dest_width >> 1, this->step_dx); |
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; |
1640 | } while (--width); | 1724 | } while (--width); |
1641 | 1725 | ||
1642 | dy += this->step_dy; | 1726 | dy += this->step_dy; |
1643 | _dst += this->rgb_stride; | 1727 | _dst += this->rgb_stride; |
1644 | 1728 | ||
1645 | while (--dst_height > 0 && dy < 32768) { | 1729 | while (--dst_height > 0 && dy < 32768) { |
@@ -1666,47 +1750,47 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
1666 | 1750 | ||
1667 | scale_line (_pu, this->u_buffer, | 1751 | scale_line (_pu, this->u_buffer, |
1668 | this->dest_width >> 1, this->step_dx); | 1752 | this->dest_width >> 1, this->step_dx); |
1669 | scale_line (_pv, this->v_buffer, | 1753 | scale_line (_pv, this->v_buffer, |
1670 | this->dest_width >> 1, this->step_dx); | 1754 | this->dest_width >> 1, this->step_dx); |
1671 | 1755 | ||
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; |
1707 | py_2 += 8; | 1791 | py_2 += 8; |
1708 | dst_1 += 24; | 1792 | dst_1 += 24; |
1709 | dst_2 += 24; | 1793 | dst_2 += 24; |
1710 | } while (--width); | 1794 | } while (--width); |
1711 | 1795 | ||
1712 | _dst += 2 * this->rgb_stride; | 1796 | _dst += 2 * this->rgb_stride; |
@@ -1732,45 +1816,45 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
1732 | 1816 | ||
1733 | if (this->do_scale) { | 1817 | if (this->do_scale) { |
1734 | scale_line_func_t scale_line = this->scale_line; | 1818 | scale_line_func_t scale_line = this->scale_line; |
1735 | 1819 | ||
1736 | scale_line (_pu, this->u_buffer, | 1820 | scale_line (_pu, this->u_buffer, |
1737 | this->dest_width >> 1, this->step_dx); | 1821 | this->dest_width >> 1, this->step_dx); |
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; |
1771 | } while (--width); | 1855 | } while (--width); |
1772 | 1856 | ||
1773 | dy += this->step_dy; | 1857 | dy += this->step_dy; |
1774 | _dst += this->rgb_stride; | 1858 | _dst += this->rgb_stride; |
1775 | 1859 | ||
1776 | while (--dst_height > 0 && dy < 32768) { | 1860 | while (--dst_height > 0 && dy < 32768) { |
@@ -1796,47 +1880,47 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
1796 | _pv += this->uv_stride; | 1880 | _pv += this->uv_stride; |
1797 | 1881 | ||
1798 | scale_line (_pu, this->u_buffer, | 1882 | scale_line (_pu, this->u_buffer, |
1799 | this->dest_width >> 1, this->step_dx); | 1883 | this->dest_width >> 1, this->step_dx); |
1800 | scale_line (_pv, this->v_buffer, | 1884 | scale_line (_pv, this->v_buffer, |
1801 | this->dest_width >> 1, this->step_dx); | 1885 | this->dest_width >> 1, this->step_dx); |
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; |
1837 | py_2 += 8; | 1921 | py_2 += 8; |
1838 | dst_1 += 8; | 1922 | dst_1 += 8; |
1839 | dst_2 += 8; | 1923 | dst_2 += 8; |
1840 | } while (--width); | 1924 | } while (--width); |
1841 | 1925 | ||
1842 | _dst += 2 * this->rgb_stride; | 1926 | _dst += 2 * this->rgb_stride; |
@@ -1862,45 +1946,45 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
1862 | 1946 | ||
1863 | if (this->do_scale) { | 1947 | if (this->do_scale) { |
1864 | scale_line_func_t scale_line = this->scale_line; | 1948 | scale_line_func_t scale_line = this->scale_line; |
1865 | 1949 | ||
1866 | scale_line (_pu, this->u_buffer, | 1950 | scale_line (_pu, this->u_buffer, |
1867 | this->dest_width >> 1, this->step_dx); | 1951 | this->dest_width >> 1, this->step_dx); |
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; |
1901 | } while (--width); | 1985 | } while (--width); |
1902 | 1986 | ||
1903 | dy += this->step_dy; | 1987 | dy += this->step_dy; |
1904 | _dst += this->rgb_stride; | 1988 | _dst += this->rgb_stride; |
1905 | 1989 | ||
1906 | while (--dst_height > 0 && dy < 32768) { | 1990 | while (--dst_height > 0 && dy < 32768) { |
@@ -1926,48 +2010,48 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
1926 | _pv += this->uv_stride; | 2010 | _pv += this->uv_stride; |
1927 | 2011 | ||
1928 | scale_line (_pu, this->u_buffer, | 2012 | scale_line (_pu, this->u_buffer, |
1929 | this->dest_width >> 1, this->step_dx); | 2013 | this->dest_width >> 1, this->step_dx); |
1930 | scale_line (_pv, this->v_buffer, | 2014 | scale_line (_pv, this->v_buffer, |
1931 | this->dest_width >> 1, this->step_dx); | 2015 | this->dest_width >> 1, this->step_dx); |
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; |
1968 | py_2 += 8; | 2052 | py_2 += 8; |
1969 | dst_1 += 8; | 2053 | dst_1 += 8; |
1970 | dst_2 += 8; | 2054 | dst_2 += 8; |
1971 | } while (--width); | 2055 | } while (--width); |
1972 | 2056 | ||
1973 | _dst += 2 * this->rgb_stride; | 2057 | _dst += 2 * this->rgb_stride; |
@@ -1981,25 +2065,25 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
1981 | 2065 | ||
1982 | /* now for something different: 256 grayscale mode */ | 2066 | /* now for something different: 256 grayscale mode */ |
1983 | static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, | 2067 | static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, |
1984 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) | 2068 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) |
1985 | { | 2069 | { |
1986 | int height, dst_height; | 2070 | int height, dst_height; |
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; |
2000 | 2084 | ||
2001 | while (--dst_height > 0 && dy < 32768) { | 2085 | while (--dst_height > 0 && dy < 32768) { |
2002 | 2086 | ||
2003 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 2087 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
2004 | 2088 | ||
2005 | dy += this->step_dy; | 2089 | dy += this->step_dy; |
@@ -2007,25 +2091,25 @@ static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, | |||
2007 | } | 2091 | } |
2008 | 2092 | ||
2009 | if (dst_height <= 0) | 2093 | if (dst_height <= 0) |
2010 | break; | 2094 | break; |
2011 | 2095 | ||
2012 | _py += this->y_stride*(dy>>15); | 2096 | _py += this->y_stride*(dy>>15); |
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 | } |
2026 | 2110 | ||
2027 | /* now for something different: 256 color mode */ | 2111 | /* now for something different: 256 color mode */ |
2028 | static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | 2112 | static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, |
2029 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) | 2113 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) |
2030 | { | 2114 | { |
2031 | int U, V, Y; | 2115 | int U, V, Y; |
@@ -2037,45 +2121,45 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
2037 | 2121 | ||
2038 | if (this->do_scale) { | 2122 | if (this->do_scale) { |
2039 | scale_line_func_t scale_line = this->scale_line; | 2123 | scale_line_func_t scale_line = this->scale_line; |
2040 | 2124 | ||
2041 | scale_line (_pu, this->u_buffer, | 2125 | scale_line (_pu, this->u_buffer, |
2042 | this->dest_width >> 1, this->step_dx); | 2126 | this->dest_width >> 1, this->step_dx); |
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; |
2076 | } while (--width); | 2160 | } while (--width); |
2077 | 2161 | ||
2078 | dy += this->step_dy; | 2162 | dy += this->step_dy; |
2079 | _dst += this->rgb_stride; | 2163 | _dst += this->rgb_stride; |
2080 | 2164 | ||
2081 | while (--dst_height > 0 && dy < 32768) { | 2165 | while (--dst_height > 0 && dy < 32768) { |
@@ -2101,47 +2185,47 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
2101 | _pv += this->uv_stride; | 2185 | _pv += this->uv_stride; |
2102 | 2186 | ||
2103 | scale_line (_pu, this->u_buffer, | 2187 | scale_line (_pu, this->u_buffer, |
2104 | this->dest_width >> 1, this->step_dx); | 2188 | this->dest_width >> 1, this->step_dx); |
2105 | scale_line (_pv, this->v_buffer, | 2189 | scale_line (_pv, this->v_buffer, |
2106 | this->dest_width >> 1, this->step_dx); | 2190 | this->dest_width >> 1, this->step_dx); |
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; |
2142 | py_2 += 8; | 2226 | py_2 += 8; |
2143 | dst_1 += 8; | 2227 | dst_1 += 8; |
2144 | dst_2 += 8; | 2228 | dst_2 += 8; |
2145 | } while (--width); | 2229 | } while (--width); |
2146 | 2230 | ||
2147 | _dst += 2 * this->rgb_stride; | 2231 | _dst += 2 * this->rgb_stride; |
@@ -2152,52 +2236,59 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
2152 | } while (--height); | 2236 | } while (--height); |
2153 | } | 2237 | } |
2154 | } | 2238 | } |
2155 | 2239 | ||
2156 | static int div_round (int dividend, int divisor) | 2240 | static int div_round (int dividend, int divisor) |
2157 | { | 2241 | { |
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 | ||
2164 | static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped) | 2248 | static 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; |
2171 | int entry_size = 0; | 2256 | int entry_size = 0; |
2172 | void *table_r = 0, *table_g = 0, *table_b = 0; | 2257 | void *table_r = 0, *table_g = 0, *table_b = 0; |
2173 | int shift_r = 0, shift_g = 0, shift_b = 0; | 2258 | int shift_r = 0, shift_g = 0, shift_b = 0; |
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 | ||
2198 | if (swapped) { | 2289 | if (swapped) { |
2199 | switch (mode) { | 2290 | switch (mode) { |
2200 | case MODE_32_RGB: shift_r = 8; shift_g = 16; shift_b = 24; break; | 2291 | case MODE_32_RGB: shift_r = 8; shift_g = 16; shift_b = 24; break; |
2201 | case MODE_32_BGR:shift_r = 24; shift_g = 16; shift_b = 8; break; | 2292 | case MODE_32_BGR:shift_r = 24; shift_g = 16; shift_b = 8; break; |
2202 | } | 2293 | } |
2203 | } else { | 2294 | } else { |
@@ -2208,38 +2299,44 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
2208 | } | 2299 | } |
2209 | 2300 | ||
2210 | for (i = -197; i < 256+197; i++) | 2301 | for (i = -197; i < 256+197; i++) |
2211 | ((uint32_t *) table_r)[i] = table_Y[i+384] << shift_r; | 2302 | ((uint32_t *) table_r)[i] = table_Y[i+384] << shift_r; |
2212 | for (i = -132; i < 256+132; i++) | 2303 | for (i = -132; i < 256+132; i++) |
2213 | ((uint32_t *) table_g)[i] = table_Y[i+384] << shift_g; | 2304 | ((uint32_t *) table_g)[i] = table_Y[i+384] << shift_g; |
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 | ||
2240 | if (swapped) { | 2337 | if (swapped) { |
2241 | switch (mode) { | 2338 | switch (mode) { |
2242 | case MODE_15_BGR: shift_r = 8; shift_g = 5; shift_b = 2; break; | 2339 | case MODE_15_BGR: shift_r = 8; shift_g = 5; shift_b = 2; break; |
2243 | case MODE_16_BGR:shift_r = 8; shift_g = 5; shift_b = 3; break; | 2340 | case MODE_16_BGR:shift_r = 8; shift_g = 5; shift_b = 3; break; |
2244 | case MODE_15_RGB:shift_r = 2; shift_g = 5; shift_b = 8; break; | 2341 | case MODE_15_RGB:shift_r = 2; shift_g = 5; shift_b = 8; break; |
2245 | case MODE_16_RGB:shift_r = 3; shift_g = 5; shift_b = 8; break; | 2342 | case MODE_16_RGB:shift_r = 3; shift_g = 5; shift_b = 8; break; |
@@ -2261,87 +2358,95 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
2261 | if (swapped) | 2358 | if (swapped) |
2262 | ((uint16_t *)table_g)[i] = (j&7) << 13 | (j>>3); | 2359 | ((uint16_t *)table_g)[i] = (j&7) << 13 | (j>>3); |
2263 | else | 2360 | else |
2264 | ((uint16_t *)table_g)[i] = j << 5; | 2361 | ((uint16_t *)table_g)[i] = j << 5; |
2265 | } | 2362 | } |
2266 | for (i = -232; i < 256+232; i++) | 2363 | for (i = -232; i < 256+232; i++) |
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 | ||
2280 | switch (mode) { | 2380 | switch (mode) { |
2281 | case MODE_8_RGB: shift_r = 5; shift_g = 2; shift_b = 0; break; | 2381 | case MODE_8_RGB: shift_r = 5; shift_g = 2; shift_b = 0; break; |
2282 | case MODE_8_BGR: shift_r = 0; shift_g = 3; shift_b = 6; break; | 2382 | case MODE_8_BGR: shift_r = 0; shift_g = 3; shift_b = 6; break; |
2283 | } | 2383 | } |
2284 | 2384 | ||
2285 | for (i = -197; i < 256+197; i++) | 2385 | for (i = -197; i < 256+197; i++) |
2286 | ((uint8_t *) table_r)[i] = (table_Y[i+384] >> 5) << shift_r; | 2386 | ((uint8_t *) table_r)[i] = (table_Y[i+384] >> 5) << shift_r; |
2287 | for (i = -132; i < 256+132; i++) | 2387 | for (i = -132; i < 256+132; i++) |
2288 | ((uint8_t *) table_g)[i] = (table_Y[i+384] >> 5) << shift_g; | 2388 | ((uint8_t *) table_g)[i] = (table_Y[i+384] >> 5) << shift_g; |
2289 | for (i = -232; i < 256+232; i++) | 2389 | for (i = -232; i < 256+232; i++) |
2290 | ((uint8_t *) table_b)[i] = (table_Y[i+384] >> 6) << shift_b; | 2390 | ((uint8_t *) table_b)[i] = (table_Y[i+384] >> 6) << shift_b; |
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 | ||
2304 | shift_r = 10; | 2407 | shift_r = 10; |
2305 | shift_g = 5; | 2408 | shift_g = 5; |
2306 | shift_b = 0; | 2409 | shift_b = 0; |
2307 | 2410 | ||
2308 | for (i = -197; i < 256+197; i++) | 2411 | for (i = -197; i < 256+197; i++) |
2309 | ((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << 10; | 2412 | ((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << 10; |
2310 | 2413 | ||
2311 | for (i = -132; i < 256+132; i++) | 2414 | for (i = -132; i < 256+132; i++) |
2312 | ((uint16_t *)table_g)[i] = (table_Y[i+384] >> 3) << 5; | 2415 | ((uint16_t *)table_g)[i] = (table_Y[i+384] >> 3) << 5; |
2313 | 2416 | ||
2314 | for (i = -232; i < 256+232; i++) | 2417 | for (i = -232; i < 256+232; i++) |
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 | ||
2338 | static uint32_t yuv2rgb_single_pixel_32 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2443 | static 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 | ||
2342 | r = this->table_rV[v]; | 2447 | r = this->table_rV[v]; |
2343 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); | 2448 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); |
2344 | b = this->table_bU[u]; | 2449 | b = this->table_bU[u]; |
2345 | 2450 | ||
2346 | return r[y] + g[y] + b[y]; | 2451 | return r[y] + g[y] + b[y]; |
2347 | } | 2452 | } |
@@ -2439,26 +2544,26 @@ static void yuv2rgb_c_init (yuv2rgb_factory_t *this) | |||
2439 | this->yuv2rgb_fun = yuv2rgb_c_8; | 2544 | this->yuv2rgb_fun = yuv2rgb_c_8; |
2440 | break; | 2545 | break; |
2441 | 2546 | ||
2442 | case MODE_8_GRAY: | 2547 | case MODE_8_GRAY: |
2443 | this->yuv2rgb_fun = yuv2rgb_c_gray; | 2548 | this->yuv2rgb_fun = yuv2rgb_c_gray; |
2444 | break; | 2549 | break; |
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 | ||
2457 | static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) { | 2562 | static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) { |
2458 | 2563 | ||
2459 | switch (this->mode) { | 2564 | switch (this->mode) { |
2460 | case MODE_32_RGB: | 2565 | case MODE_32_RGB: |
2461 | case MODE_32_BGR: | 2566 | case MODE_32_BGR: |
2462 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_32; | 2567 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_32; |
2463 | break; | 2568 | break; |
2464 | 2569 | ||
@@ -2482,26 +2587,26 @@ static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) { | |||
2482 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_8; | 2587 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_8; |
2483 | break; | 2588 | break; |
2484 | 2589 | ||
2485 | case MODE_8_GRAY: | 2590 | case MODE_8_GRAY: |
2486 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_gray; | 2591 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_gray; |
2487 | break; | 2592 | break; |
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 |
2502 | */ | 2607 | */ |
2503 | 2608 | ||
2504 | static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2609 | static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2505 | { | 2610 | { |
2506 | int U, V, Y; | 2611 | int U, V, Y; |
2507 | uint8_t * py_1, * pu, * pv; | 2612 | uint8_t * py_1, * pu, * pv; |
@@ -2511,69 +2616,69 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2511 | int dy; | 2616 | int dy; |
2512 | 2617 | ||
2513 | /* FIXME: implement unscaled version */ | 2618 | /* FIXME: implement unscaled version */ |
2514 | 2619 | ||
2515 | scale_line_4 (_p+1, this->u_buffer, | 2620 | scale_line_4 (_p+1, this->u_buffer, |
2516 | this->dest_width >> 1, this->step_dx); | 2621 | this->dest_width >> 1, this->step_dx); |
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; |
2551 | } while (--width); | 2656 | } while (--width); |
2552 | 2657 | ||
2553 | dy += this->step_dy; | 2658 | dy += this->step_dy; |
2554 | _dst += this->rgb_stride; | 2659 | _dst += this->rgb_stride; |
2555 | 2660 | ||
2556 | while (--height > 0 && dy < 32768) { | 2661 | while (--height > 0 && dy < 32768) { |
2557 | 2662 | ||
2558 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4); | 2663 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4); |
2559 | 2664 | ||
2560 | dy += this->step_dy; | 2665 | dy += this->step_dy; |
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 | ||
2574 | scale_line_4 (_p+1, this->u_buffer, | 2679 | scale_line_4 (_p+1, this->u_buffer, |
2575 | this->dest_width >> 1, this->step_dx); | 2680 | this->dest_width >> 1, this->step_dx); |
2576 | scale_line_4 (_p+3, this->v_buffer, | 2681 | scale_line_4 (_p+3, this->v_buffer, |
2577 | this->dest_width >> 1, this->step_dx); | 2682 | this->dest_width >> 1, this->step_dx); |
2578 | scale_line_2 (_p, this->y_buffer, | 2683 | scale_line_2 (_p, this->y_buffer, |
2579 | this->dest_width, this->step_dx); | 2684 | this->dest_width, this->step_dx); |
@@ -2590,68 +2695,68 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2590 | int dy; | 2695 | int dy; |
2591 | 2696 | ||
2592 | /* FIXME: implement unscaled version */ | 2697 | /* FIXME: implement unscaled version */ |
2593 | 2698 | ||
2594 | scale_line_4 (_p+1, this->u_buffer, | 2699 | scale_line_4 (_p+1, this->u_buffer, |
2595 | this->dest_width >> 1, this->step_dx); | 2700 | this->dest_width >> 1, this->step_dx); |
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; |
2629 | } while (--width); | 2734 | } while (--width); |
2630 | 2735 | ||
2631 | dy += this->step_dy; | 2736 | dy += this->step_dy; |
2632 | _dst += this->rgb_stride; | 2737 | _dst += this->rgb_stride; |
2633 | 2738 | ||
2634 | while (--height > 0 && dy < 32768) { | 2739 | while (--height > 0 && dy < 32768) { |
2635 | 2740 | ||
2636 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3); | 2741 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3); |
2637 | 2742 | ||
2638 | dy += this->step_dy; | 2743 | dy += this->step_dy; |
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 | ||
2652 | scale_line_4 (_p+1, this->u_buffer, | 2757 | scale_line_4 (_p+1, this->u_buffer, |
2653 | this->dest_width >> 1, this->step_dx); | 2758 | this->dest_width >> 1, this->step_dx); |
2654 | scale_line_4 (_p+3, this->v_buffer, | 2759 | scale_line_4 (_p+3, this->v_buffer, |
2655 | this->dest_width >> 1, this->step_dx); | 2760 | this->dest_width >> 1, this->step_dx); |
2656 | scale_line_2 (_p, this->y_buffer, | 2761 | scale_line_2 (_p, this->y_buffer, |
2657 | this->dest_width, this->step_dx); | 2762 | this->dest_width, this->step_dx); |
@@ -2668,68 +2773,68 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2668 | int dy; | 2773 | int dy; |
2669 | 2774 | ||
2670 | /* FIXME: implement unscaled version */ | 2775 | /* FIXME: implement unscaled version */ |
2671 | 2776 | ||
2672 | scale_line_4 (_p+1, this->u_buffer, | 2777 | scale_line_4 (_p+1, this->u_buffer, |
2673 | this->dest_width >> 1, this->step_dx); | 2778 | this->dest_width >> 1, this->step_dx); |
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; |
2707 | } while (--width); | 2812 | } while (--width); |
2708 | 2813 | ||
2709 | dy += this->step_dy; | 2814 | dy += this->step_dy; |
2710 | _dst += this->rgb_stride; | 2815 | _dst += this->rgb_stride; |
2711 | 2816 | ||
2712 | while (--height > 0 && dy < 32768) { | 2817 | while (--height > 0 && dy < 32768) { |
2713 | 2818 | ||
2714 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3); | 2819 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3); |
2715 | 2820 | ||
2716 | dy += this->step_dy; | 2821 | dy += this->step_dy; |
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); |
2730 | scale_line_2 (_p, this->y_buffer, | 2835 | scale_line_2 (_p, this->y_buffer, |
2731 | this->dest_width, this->step_dx); | 2836 | this->dest_width, this->step_dx); |
2732 | } | 2837 | } |
2733 | } | 2838 | } |
2734 | 2839 | ||
2735 | static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2840 | static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
@@ -2742,68 +2847,68 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2742 | int dy; | 2847 | int dy; |
2743 | 2848 | ||
2744 | /* FIXME: implement unscaled version */ | 2849 | /* FIXME: implement unscaled version */ |
2745 | 2850 | ||
2746 | scale_line_4 (_p+1, this->u_buffer, | 2851 | scale_line_4 (_p+1, this->u_buffer, |
2747 | this->dest_width >> 1, this->step_dx); | 2852 | this->dest_width >> 1, this->step_dx); |
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; |
2781 | } while (--width); | 2886 | } while (--width); |
2782 | 2887 | ||
2783 | dy += this->step_dy; | 2888 | dy += this->step_dy; |
2784 | _dst += this->rgb_stride; | 2889 | _dst += this->rgb_stride; |
2785 | 2890 | ||
2786 | while (--height > 0 && dy < 32768) { | 2891 | while (--height > 0 && dy < 32768) { |
2787 | 2892 | ||
2788 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); | 2893 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); |
2789 | 2894 | ||
2790 | dy += this->step_dy; | 2895 | dy += this->step_dy; |
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); |
2804 | scale_line_2 (_p, this->y_buffer, | 2909 | scale_line_2 (_p, this->y_buffer, |
2805 | this->dest_width, this->step_dx); | 2910 | this->dest_width, this->step_dx); |
2806 | } | 2911 | } |
2807 | } | 2912 | } |
2808 | 2913 | ||
2809 | static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2914 | static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
@@ -2816,185 +2921,185 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2816 | int dy; | 2921 | int dy; |
2817 | 2922 | ||
2818 | /* FIXME: implement unscaled version */ | 2923 | /* FIXME: implement unscaled version */ |
2819 | 2924 | ||
2820 | scale_line_4 (_p+1, this->u_buffer, | 2925 | scale_line_4 (_p+1, this->u_buffer, |
2821 | this->dest_width >> 1, this->step_dx); | 2926 | this->dest_width >> 1, this->step_dx); |
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; |
2855 | } while (--width); | 2960 | } while (--width); |
2856 | 2961 | ||
2857 | dy += this->step_dy; | 2962 | dy += this->step_dy; |
2858 | _dst += this->rgb_stride; | 2963 | _dst += this->rgb_stride; |
2859 | 2964 | ||
2860 | while (--height > 0 && dy < 32768) { | 2965 | while (--height > 0 && dy < 32768) { |
2861 | 2966 | ||
2862 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 2967 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
2863 | 2968 | ||
2864 | dy += this->step_dy; | 2969 | dy += this->step_dy; |
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); |
2878 | scale_line_2 (_p, this->y_buffer, | 2983 | scale_line_2 (_p, this->y_buffer, |
2879 | this->dest_width, this->step_dx); | 2984 | this->dest_width, this->step_dx); |
2880 | } | 2985 | } |
2881 | } | 2986 | } |
2882 | 2987 | ||
2883 | static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2988 | static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2884 | { | 2989 | { |
2885 | int width, height; | 2990 | int width, height; |
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; |
2899 | 3004 | ||
2900 | while (--height > 0 && dy < 32768) { | 3005 | while (--height > 0 && dy < 32768) { |
2901 | 3006 | ||
2902 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 3007 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
2903 | 3008 | ||
2904 | dy += this->step_dy; | 3009 | dy += this->step_dy; |
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 | ||
2928 | static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 3033 | static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2929 | { | 3034 | { |
2930 | int U, V, Y; | 3035 | int U, V, Y; |
2931 | uint8_t * py_1, * pu, * pv; | 3036 | uint8_t * py_1, * pu, * pv; |
2932 | uint16_t * r, * g, * b; | 3037 | uint16_t * r, * g, * b; |
2933 | uint8_t * dst_1; | 3038 | uint8_t * dst_1; |
2934 | int width, height; | 3039 | int width, height; |
2935 | int dy; | 3040 | int dy; |
2936 | 3041 | ||
2937 | scale_line_4 (_p+1, this->u_buffer, | 3042 | scale_line_4 (_p+1, this->u_buffer, |
2938 | this->dest_width >> 1, this->step_dx); | 3043 | this->dest_width >> 1, this->step_dx); |
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; |
2972 | } while (--width); | 3077 | } while (--width); |
2973 | 3078 | ||
2974 | dy += this->step_dy; | 3079 | dy += this->step_dy; |
2975 | _dst += this->rgb_stride; | 3080 | _dst += this->rgb_stride; |
2976 | 3081 | ||
2977 | while (--height > 0 && dy < 32768) { | 3082 | while (--height > 0 && dy < 32768) { |
2978 | 3083 | ||
2979 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 3084 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
2980 | 3085 | ||
2981 | dy += this->step_dy; | 3086 | dy += this->step_dy; |
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); |
2995 | scale_line_2 (_p, this->y_buffer, | 3100 | scale_line_2 (_p, this->y_buffer, |
2996 | this->dest_width, this->step_dx); | 3101 | this->dest_width, this->step_dx); |
2997 | } | 3102 | } |
2998 | } | 3103 | } |
2999 | 3104 | ||
3000 | static void yuy22rgb_c_init (yuv2rgb_factory_t *this) | 3105 | static void yuy22rgb_c_init (yuv2rgb_factory_t *this) |
@@ -3024,144 +3129,149 @@ static void yuy22rgb_c_init (yuv2rgb_factory_t *this) | |||
3024 | this->yuy22rgb_fun = yuy22rgb_c_8; | 3129 | this->yuy22rgb_fun = yuy22rgb_c_8; |
3025 | break; | 3130 | break; |
3026 | 3131 | ||
3027 | case MODE_8_GRAY: | 3132 | case MODE_8_GRAY: |
3028 | this->yuy22rgb_fun = yuy22rgb_c_gray; | 3133 | this->yuy22rgb_fun = yuy22rgb_c_gray; |
3029 | break; | 3134 | break; |
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 | ||
3040 | yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { | 3145 | static 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 | */ |
3066 | void 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 | ||
3081 | int yuv2rgb_get_gamma (yuv2rgb_factory_t *this) { | 3182 | static 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 | ||
3086 | yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, | 3189 | yuv2rgb_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 | */ |
3155 | 3266 | ||
3156 | /* FIXME: implement mmx/mlib functions */ | 3267 | /* FIXME: implement mmx/mlib functions */ |
3157 | yuy22rgb_c_init (this); | 3268 | yuy22rgb_c_init (this); |
3158 | 3269 | ||
3159 | /* | 3270 | /* |
3160 | * set up single pixel function | 3271 | * set up single pixel function |
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 | |||