-rw-r--r-- | noncore/multimedia/opieplayer2/alphablend.c | 1567 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/alphablend.h | 91 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 74 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 40 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mainTest.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/nullvideo.c | 292 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb.c | 446 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb.h | 56 |
8 files changed, 1893 insertions, 689 deletions
diff --git a/noncore/multimedia/opieplayer2/alphablend.c b/noncore/multimedia/opieplayer2/alphablend.c index cdd7b28..ab80531 100644 --- a/noncore/multimedia/opieplayer2/alphablend.c +++ b/noncore/multimedia/opieplayer2/alphablend.c | |||
@@ -1,13 +1,10 @@ | |||
1 | //TOAST_SPU will define ALL spu entries - no matter the tranparency | ||
2 | //#define TOAST_SPU | ||
3 | /* #define PRIV_CLUT */ | ||
4 | /* Currently only blend_yuv(..) works */ | ||
5 | /* | 1 | /* |
6 | * | 2 | * |
7 | * Copyright (C) James Courtier-Dutton James@superbug.demon.co.uk - July 2001 | 3 | * Copyright (C) James Courtier-Dutton James@superbug.demon.co.uk - July 2001 |
8 | * | 4 | * |
9 | * Copyright (C) 2000 Thomas Mirlacher | 5 | * Copyright (C) 2000 Thomas Mirlacher |
6 | * 2002-2004 the xine project | ||
10 | * | 7 | * |
11 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by | 9 | * 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 | 10 | * the Free Software Foundation; either version 2 of the License, or |
@@ -29,19 +26,19 @@ | |||
29 | */ | 26 | */ |
30 | 27 | ||
31 | /* | 28 | /* |
32 | #define LOG_BLEND_YUV | 29 | #define LOG_BLEND_YUV |
30 | #define LOG_BLEND_RGB16 | ||
33 | */ | 31 | */ |
34 | 32 | ||
35 | #include <string.h> | 33 | #include <string.h> |
36 | #include <stdlib.h> | 34 | #include <stdlib.h> |
37 | #include <stdio.h> | 35 | #include <stdio.h> |
38 | #include <inttypes.h> | ||
39 | 36 | ||
40 | #include <xine.h> | ||
41 | #include <xine/xine_internal.h> | 37 | #include <xine/xine_internal.h> |
42 | #include <xine/video_out.h> | 38 | #include <xine/video_out.h> |
43 | #include "alphablend.h" | 39 | #include "alphablend.h" |
40 | #include "bswap.h" | ||
44 | 41 | ||
45 | 42 | ||
46 | #define BLEND_COLOR(dst, src, mask, o) ((((src&mask)*o + ((dst&mask)*(0x0f-o)))/0xf) & mask) | 43 | #define BLEND_COLOR(dst, src, mask, o) ((((src&mask)*o + ((dst&mask)*(0x0f-o)))/0xf) & mask) |
47 | 44 | ||
@@ -58,9 +55,9 @@ static void mem_blend16(uint16_t *mem, uint16_t clr, uint8_t o, int len) { | |||
58 | } | 55 | } |
59 | } | 56 | } |
60 | 57 | ||
61 | static void mem_blend24(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b, | 58 | static void mem_blend24(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b, |
62 | uint8_t o, int len) { | 59 | uint8_t o, int len) { |
63 | uint8_t *limit = mem + len*3; | 60 | uint8_t *limit = mem + len*3; |
64 | while (mem < limit) { | 61 | while (mem < limit) { |
65 | *mem = BLEND_BYTE(*mem, r, o); | 62 | *mem = BLEND_BYTE(*mem, r, o); |
66 | mem++; | 63 | mem++; |
@@ -70,21 +67,8 @@ static void mem_blend24(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b, | |||
70 | mem++; | 67 | mem++; |
71 | } | 68 | } |
72 | } | 69 | } |
73 | 70 | ||
74 | static void mem_blend24_32(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b, | ||
75 | uint8_t o, int len) { | ||
76 | uint8_t *limit = mem + len*4; | ||
77 | while (mem < limit) { | ||
78 | *mem = BLEND_BYTE(*mem, r, o); | ||
79 | mem++; | ||
80 | *mem = BLEND_BYTE(*mem, g, o); | ||
81 | mem++; | ||
82 | *mem = BLEND_BYTE(*mem, b, o); | ||
83 | mem += 2; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | static void mem_blend32(uint8_t *mem, uint8_t *src, uint8_t o, int len) { | 71 | static void mem_blend32(uint8_t *mem, uint8_t *src, uint8_t o, int len) { |
88 | uint8_t *limit = mem + len*4; | 72 | uint8_t *limit = mem + len*4; |
89 | while (mem < limit) { | 73 | while (mem < limit) { |
90 | *mem = BLEND_BYTE(*mem, src[0], o); | 74 | *mem = BLEND_BYTE(*mem, src[0], o); |
@@ -97,9 +81,8 @@ static void mem_blend32(uint8_t *mem, uint8_t *src, uint8_t o, int len) { | |||
97 | mem++; | 81 | mem++; |
98 | } | 82 | } |
99 | } | 83 | } |
100 | 84 | ||
101 | |||
102 | /* | 85 | /* |
103 | * Some macros for fixed point arithmetic. | 86 | * Some macros for fixed point arithmetic. |
104 | * | 87 | * |
105 | * The blend_rgb* routines perform rle image scaling using | 88 | * The blend_rgb* routines perform rle image scaling using |
@@ -126,112 +109,416 @@ rle_img_advance_line(rle_elem_t *rle, rle_elem_t *rle_limit, int w) | |||
126 | } | 109 | } |
127 | return rle; | 110 | return rle; |
128 | } | 111 | } |
129 | 112 | ||
130 | |||
131 | void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, | 113 | void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, |
132 | int img_width, int img_height, | 114 | int img_width, int img_height, |
133 | int dst_width, int dst_height) | 115 | int dst_width, int dst_height, |
116 | alphablend_t *extra_data) | ||
134 | { | 117 | { |
135 | uint8_t *trans; | 118 | uint8_t *trans; |
136 | clut_t* clut = (clut_t*) img_overl->clip_color; | 119 | clut_t *clut; |
137 | 120 | ||
138 | int src_width = img_overl->width; | 121 | int src_width = img_overl->width; |
139 | int src_height = img_overl->height; | 122 | int src_height = img_overl->height; |
140 | rle_elem_t *rle = img_overl->rle; | 123 | rle_elem_t *rle = img_overl->rle; |
124 | rle_elem_t *rle_start = img_overl->rle; | ||
141 | rle_elem_t *rle_limit = rle + img_overl->num_rle; | 125 | rle_elem_t *rle_limit = rle + img_overl->num_rle; |
142 | int x, y, x1_scaled, x2_scaled; | 126 | int x, y, x1_scaled, x2_scaled; |
143 | int dy, dy_step, x_scale;/* scaled 2**SCALE_SHIFT */ | 127 | int dy, dy_step, x_scale; /* scaled 2**SCALE_SHIFT */ |
144 | int clip_right; | 128 | int clip_right; |
145 | uint16_t *img_pix; | 129 | uint16_t *img_pix; |
130 | int rlelen; | ||
131 | int rle_this_bite; | ||
132 | int rle_remainder; | ||
133 | int zone_state=0; | ||
134 | uint8_t clr_next,clr; | ||
135 | uint16_t o; | ||
136 | double img_offset; | ||
137 | int stripe_height; | ||
138 | /* | ||
139 | * Let zone_state keep state. | ||
140 | * 0 = Starting. | ||
141 | * 1 = Above button. | ||
142 | * 2 = Left of button. | ||
143 | * 3 = Inside of button. | ||
144 | * 4 = Right of button. | ||
145 | * 5 = Below button. | ||
146 | * 6 = Finished. | ||
147 | * | ||
148 | * Each time round the loop, update the state. | ||
149 | * We can do this easily and cheaply(fewer IF statements per cycle) as we are testing rle end position anyway. | ||
150 | * Possible optimization is to ensure that rle never overlaps from outside to inside a button. | ||
151 | * Possible optimization is to pre-scale the RLE overlay, so that no scaling is needed here. | ||
152 | */ | ||
146 | 153 | ||
147 | dy_step = INT_TO_SCALED(dst_height) / img_height; | 154 | #ifdef LOG_BLEND_RGB16 |
148 | x_scale = INT_TO_SCALED(img_width) / dst_width; | 155 | printf("blend_rgb16: img_height=%i, dst_height=%i\n", img_height, dst_height); |
156 | printf("blend_rgb16: img_width=%i, dst_width=%i\n", img_width, dst_width); | ||
157 | if (img_width & 1) { printf("blend_rgb16s: odd\n");} | ||
158 | else { printf("blend_rgb16s: even\n");} | ||
149 | 159 | ||
150 | img_pix = (uint16_t *) img | 160 | #endif |
161 | /* stripe_height is used in yuv2rgb scaling, so use the same scale factor here for overlays. */ | ||
162 | stripe_height = 16 * img_height / dst_height; | ||
163 | /* dy_step = INT_TO_SCALED(dst_height) / img_height; */ | ||
164 | dy_step = INT_TO_SCALED(16) / stripe_height; | ||
165 | x_scale = INT_TO_SCALED(img_width) / dst_width; | ||
166 | #ifdef LOG_BLEND_RGB16 | ||
167 | printf("blend_rgb16: dy_step=%i, x_scale=%i\n", dy_step, x_scale); | ||
168 | #endif | ||
169 | if (img_width & 1) img_width++; | ||
170 | img_offset = ( ( (img_overl->y * img_height) / dst_height) * img_width) | ||
171 | + ( (img_overl->x * img_width) / dst_width); | ||
172 | #ifdef LOG_BLEND_RGB16 | ||
173 | printf("blend_rgb16: x=%i, y=%i, w=%i, h=%i, img_offset=%lf\n", img_overl->x, img_overl->y, | ||
174 | img_overl->width, | ||
175 | img_overl->height, | ||
176 | img_offset); | ||
177 | #endif | ||
178 | img_pix = (uint16_t *) img + (int)img_offset; | ||
179 | /* | ||
151 | + (img_overl->y * img_height / dst_height) * img_width | 180 | + (img_overl->y * img_height / dst_height) * img_width |
152 | + (img_overl->x * img_width / dst_width); | 181 | + (img_overl->x * img_width / dst_width); |
153 | 182 | */ | |
154 | trans = img_overl->clip_trans; | ||
155 | 183 | ||
156 | /* avoid wraping overlay if drawing to small image */ | 184 | /* avoid wraping overlay if drawing to small image */ |
157 | if( (img_overl->x + img_overl->clip_right) < dst_width ) | 185 | if( (img_overl->x + img_overl->clip_right) < dst_width ) |
158 | clip_right = img_overl->clip_right; | 186 | clip_right = img_overl->clip_right; |
159 | else | 187 | else |
160 | clip_right = dst_width - 1 - img_overl->x; | 188 | clip_right = dst_width - img_overl->x; |
161 | 189 | ||
162 | /* avoid buffer overflow */ | 190 | /* avoid buffer overflow */ |
163 | if( (src_height + img_overl->y) >= dst_height ) | 191 | if( (src_height + img_overl->y) >= dst_height ) |
164 | src_height = dst_height - 1 - img_overl->y; | 192 | src_height = dst_height - img_overl->y; |
165 | 193 | ||
166 | for (y = dy = 0; y < src_height && rle < rle_limit;) { | 194 | rlelen = rle_remainder = rle_this_bite = 0; |
167 | int mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y); | 195 | rle_remainder = rlelen = rle->len; |
168 | rle_elem_t *rle_start = rle; | 196 | clr_next = rle->color; |
197 | rle++; | ||
198 | y = dy = 0; | ||
199 | x = x1_scaled = x2_scaled = 0; | ||
169 | 200 | ||
170 | for (x = x1_scaled = 0; x < src_width;) { | 201 | #ifdef LOG_BLEND_RGB16 |
171 | uint8_t clr; | 202 | printf("blend_rgb16 started\n"); |
172 | uint16_t o; | 203 | #endif |
173 | int rlelen; | 204 | |
205 | while (zone_state != 6) { | ||
206 | clr = clr_next; | ||
207 | switch (zone_state) { | ||
208 | case 0: /* Starting */ | ||
209 | /* FIXME: Get libspudec to set clip_top to -1 if no button */ | ||
210 | if (img_overl->clip_top < 0) { | ||
211 | #ifdef LOG_BLEND_RGB16 | ||
212 | printf("blend_rgb16: No button clip area\n"); | ||
213 | #endif | ||
174 | 214 | ||
175 | clr = rle->color; | 215 | zone_state = 7; |
216 | break; | ||
217 | } | ||
218 | #ifdef LOG_BLEND_RGB16 | ||
219 | printf("blend_rgb16: Button clip area found. (%d,%d) .. (%d,%d)\n", | ||
220 | img_overl->clip_left, | ||
221 | img_overl->clip_top, | ||
222 | img_overl->clip_right, | ||
223 | img_overl->clip_bottom); | ||
224 | #endif | ||
225 | if (y < img_overl->clip_top) { | ||
226 | zone_state = 1; | ||
227 | break; | ||
228 | } else if (y >= img_overl->clip_bottom) { | ||
229 | zone_state = 5; | ||
230 | break; | ||
231 | } else if (x < img_overl->clip_left) { | ||
232 | zone_state = 2; | ||
233 | break; | ||
234 | } else if (x >= img_overl->clip_right) { | ||
235 | zone_state = 4; | ||
236 | break; | ||
237 | } else { | ||
238 | zone_state = 3; | ||
239 | break; | ||
240 | } | ||
241 | break; | ||
242 | case 1: /* Above clip area */ | ||
243 | clut = (clut_t*) img_overl->color; | ||
244 | trans = img_overl->trans; | ||
176 | o = trans[clr]; | 245 | o = trans[clr]; |
177 | rlelen = rle->len; | 246 | rle_this_bite = rle_remainder; |
178 | 247 | rle_remainder = 0; | |
179 | if (o && mask) { | 248 | rlelen -= rle_this_bite; |
180 | /* threat cases where clipping border is inside rle->len pixels */ | 249 | /*printf("(x,y) = (%03i,%03i), clr=%03x, len=%03i, zone=%i\n", x, y, clr, rle_this_bite, zone_state); */ |
181 | if ( img_overl->clip_left > x ) { | 250 | if (o) { |
182 | if( img_overl->clip_left < x + rlelen ) { | 251 | x1_scaled = SCALED_TO_INT( x * x_scale ); |
183 | x1_scaled = SCALED_TO_INT( img_overl->clip_left * x_scale ); | 252 | x2_scaled = SCALED_TO_INT( (x + rle_this_bite) * x_scale); |
184 | rlelen -= img_overl->clip_left - x; | 253 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); |
185 | x += img_overl->clip_left - x; | 254 | } |
186 | } else { | 255 | x += rle_this_bite; |
187 | o = 0; | 256 | if (x >= src_width ) { |
257 | x -= src_width; | ||
258 | img_pix += img_width; | ||
259 | |||
260 | dy += dy_step; | ||
261 | if (dy >= INT_TO_SCALED(1)) { | ||
262 | dy -= INT_TO_SCALED(1); | ||
263 | ++y; | ||
264 | while (dy >= INT_TO_SCALED(1)) { | ||
265 | rle = rle_img_advance_line(rle, rle_limit, src_width); | ||
266 | dy -= INT_TO_SCALED(1); | ||
267 | ++y; | ||
188 | } | 268 | } |
189 | } else if( clip_right < x + rlelen ) { | 269 | rle_start = rle; |
190 | if( clip_right > x ) { | 270 | } else { |
191 | x2_scaled = SCALED_TO_INT( clip_right * x_scale); | 271 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ |
192 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, | 272 | } |
193 | x2_scaled-x1_scaled); | 273 | } |
194 | o = 0; | 274 | rle_remainder = rlelen = rle->len; |
195 | } else { | 275 | clr_next = rle->color; |
196 | o = 0; | 276 | rle++; |
277 | if (rle >= rle_limit) { | ||
278 | zone_state = 6; | ||
279 | } | ||
280 | if (y >= img_overl->clip_top) { | ||
281 | zone_state = 2; | ||
282 | #ifdef LOG_BLEND_RGB16 | ||
283 | printf("blend_rgb16: Button clip top reached. y=%i, top=%i\n", | ||
284 | y, img_overl->clip_top); | ||
285 | #endif | ||
286 | if (x >= img_overl->clip_left) { | ||
287 | zone_state = 3; | ||
288 | if (x >= img_overl->clip_right) { | ||
289 | zone_state = 4; | ||
197 | } | 290 | } |
198 | } | 291 | } |
199 | } | 292 | } |
200 | 293 | break; | |
201 | x2_scaled = SCALED_TO_INT((x + rlelen) * x_scale); | 294 | case 2: /* Left of button */ |
202 | if (o && mask) { | 295 | clut = (clut_t*) img_overl->color; |
203 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); | 296 | trans = img_overl->trans; |
297 | o = trans[clr]; | ||
298 | if (x + rle_remainder <= img_overl->clip_left) { | ||
299 | rle_this_bite = rle_remainder; | ||
300 | rle_remainder = rlelen = rle->len; | ||
301 | clr_next = rle->color; | ||
302 | rle++; | ||
303 | } else { | ||
304 | rle_this_bite = img_overl->clip_left - x; | ||
305 | rle_remainder -= rle_this_bite; | ||
306 | zone_state = 3; | ||
204 | } | 307 | } |
205 | 308 | if (o) { | |
206 | x1_scaled = x2_scaled; | 309 | x1_scaled = SCALED_TO_INT( x * x_scale ); |
207 | x += rlelen; | 310 | x2_scaled = SCALED_TO_INT( (x + rle_this_bite) * x_scale); |
311 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); | ||
312 | } | ||
313 | x += rle_this_bite; | ||
314 | if (x >= src_width ) { | ||
315 | x -= src_width; | ||
316 | img_pix += img_width; | ||
317 | dy += dy_step; | ||
318 | if (dy >= INT_TO_SCALED(1)) { | ||
319 | dy -= INT_TO_SCALED(1); | ||
320 | ++y; | ||
321 | while (dy >= INT_TO_SCALED(1)) { | ||
322 | rle = rle_img_advance_line(rle, rle_limit, src_width); | ||
323 | dy -= INT_TO_SCALED(1); | ||
324 | ++y; | ||
325 | } | ||
326 | rle_start = rle; | ||
327 | } else { | ||
328 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ | ||
329 | } | ||
330 | if (y >= img_overl->clip_bottom) { | ||
331 | zone_state = 5; | ||
332 | break; | ||
333 | } | ||
334 | } | ||
335 | if (rle >= rle_limit) { | ||
336 | zone_state = 6; | ||
337 | } | ||
338 | break; | ||
339 | case 3: /* In button */ | ||
340 | clut = (clut_t*) img_overl->clip_color; | ||
341 | trans = img_overl->clip_trans; | ||
342 | o = trans[clr]; | ||
343 | if (x + rle_remainder <= img_overl->clip_right) { | ||
344 | rle_this_bite = rle_remainder; | ||
345 | rle_remainder = rlelen = rle->len; | ||
346 | clr_next = rle->color; | ||
347 | rle++; | ||
348 | } else { | ||
349 | rle_this_bite = img_overl->clip_right - x; | ||
350 | rle_remainder -= rle_this_bite; | ||
351 | zone_state = 4; | ||
352 | } | ||
353 | if (o) { | ||
354 | x1_scaled = SCALED_TO_INT( x * x_scale ); | ||
355 | x2_scaled = SCALED_TO_INT( (x + rle_this_bite) * x_scale); | ||
356 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); | ||
357 | } | ||
358 | x += rle_this_bite; | ||
359 | if (x >= src_width ) { | ||
360 | x -= src_width; | ||
361 | img_pix += img_width; | ||
362 | dy += dy_step; | ||
363 | if (dy >= INT_TO_SCALED(1)) { | ||
364 | dy -= INT_TO_SCALED(1); | ||
365 | ++y; | ||
366 | while (dy >= INT_TO_SCALED(1)) { | ||
367 | rle = rle_img_advance_line(rle, rle_limit, src_width); | ||
368 | dy -= INT_TO_SCALED(1); | ||
369 | ++y; | ||
370 | } | ||
371 | rle_start = rle; | ||
372 | } else { | ||
373 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ | ||
374 | } | ||
375 | if (y >= img_overl->clip_bottom) { | ||
376 | zone_state = 5; | ||
377 | break; | ||
378 | } | ||
379 | } | ||
380 | if (rle >= rle_limit) { | ||
381 | zone_state = 6; | ||
382 | } | ||
383 | break; | ||
384 | case 4: /* Right of button */ | ||
385 | clut = (clut_t*) img_overl->color; | ||
386 | trans = img_overl->trans; | ||
387 | o = trans[clr]; | ||
388 | if (x + rle_remainder <= src_width) { | ||
389 | rle_this_bite = rle_remainder; | ||
390 | rle_remainder = rlelen = rle->len; | ||
391 | clr_next = rle->color; | ||
392 | rle++; | ||
393 | } else { | ||
394 | rle_this_bite = src_width - x; | ||
395 | rle_remainder -= rle_this_bite; | ||
396 | zone_state = 2; | ||
397 | } | ||
398 | if (o) { | ||
399 | x1_scaled = SCALED_TO_INT( x * x_scale ); | ||
400 | x2_scaled = SCALED_TO_INT( (x + rle_this_bite) * x_scale); | ||
401 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); | ||
402 | } | ||
403 | x += rle_this_bite; | ||
404 | if (x >= src_width ) { | ||
405 | x -= src_width; | ||
406 | img_pix += img_width; | ||
407 | dy += dy_step; | ||
408 | if (dy >= INT_TO_SCALED(1)) { | ||
409 | dy -= INT_TO_SCALED(1); | ||
410 | ++y; | ||
411 | while (dy >= INT_TO_SCALED(1)) { | ||
412 | rle = rle_img_advance_line(rle, rle_limit, src_width); | ||
413 | dy -= INT_TO_SCALED(1); | ||
414 | ++y; | ||
415 | } | ||
416 | rle_start = rle; | ||
417 | } else { | ||
418 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ | ||
419 | } | ||
420 | if (y >= img_overl->clip_bottom) { | ||
421 | zone_state = 5; | ||
422 | break; | ||
423 | } | ||
424 | } | ||
425 | if (rle >= rle_limit) { | ||
426 | zone_state = 6; | ||
427 | } | ||
428 | break; | ||
429 | case 5: /* Below button */ | ||
430 | clut = (clut_t*) img_overl->color; | ||
431 | trans = img_overl->trans; | ||
432 | o = trans[clr]; | ||
433 | rle_this_bite = rle_remainder; | ||
434 | rle_remainder = 0; | ||
435 | rlelen -= rle_this_bite; | ||
436 | if (o) { | ||
437 | x1_scaled = SCALED_TO_INT( x * x_scale ); | ||
438 | x2_scaled = SCALED_TO_INT( (x + rle_this_bite) * x_scale); | ||
439 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); | ||
440 | } | ||
441 | x += rle_this_bite; | ||
442 | if (x >= src_width ) { | ||
443 | x -= src_width; | ||
444 | img_pix += img_width; | ||
445 | dy += dy_step; | ||
446 | if (dy >= INT_TO_SCALED(1)) { | ||
447 | dy -= INT_TO_SCALED(1); | ||
448 | ++y; | ||
449 | while (dy >= INT_TO_SCALED(1)) { | ||
450 | rle = rle_img_advance_line(rle, rle_limit, src_width); | ||
451 | dy -= INT_TO_SCALED(1); | ||
452 | ++y; | ||
453 | } | ||
454 | rle_start = rle; | ||
455 | } else { | ||
456 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ | ||
457 | } | ||
458 | } | ||
459 | rle_remainder = rlelen = rle->len; | ||
460 | clr_next = rle->color; | ||
208 | rle++; | 461 | rle++; |
209 | if (rle >= rle_limit) break; | 462 | if (rle >= rle_limit) { |
210 | } | 463 | zone_state = 6; |
464 | } | ||
465 | break; | ||
466 | case 6: /* Finished */ | ||
467 | _x_abort(); | ||
211 | 468 | ||
212 | img_pix += img_width; | 469 | case 7: /* No button */ |
213 | dy += dy_step; | 470 | clut = (clut_t*) img_overl->color; |
214 | if (dy >= INT_TO_SCALED(1)) { | 471 | trans = img_overl->trans; |
215 | dy -= INT_TO_SCALED(1); | 472 | o = trans[clr]; |
216 | ++y; | 473 | rle_this_bite = rle_remainder; |
217 | while (dy >= INT_TO_SCALED(1)) { | 474 | rle_remainder = 0; |
218 | rle = rle_img_advance_line(rle, rle_limit, src_width); | 475 | rlelen -= rle_this_bite; |
219 | dy -= INT_TO_SCALED(1); | 476 | if (o) { |
220 | ++y; | 477 | x1_scaled = SCALED_TO_INT( x * x_scale ); |
478 | x2_scaled = SCALED_TO_INT( (x + rle_this_bite) * x_scale); | ||
479 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); | ||
221 | } | 480 | } |
222 | } else { | 481 | x += rle_this_bite; |
223 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ | 482 | if (x >= src_width ) { |
483 | x -= src_width; | ||
484 | img_pix += img_width; | ||
485 | dy += dy_step; | ||
486 | if (dy >= INT_TO_SCALED(1)) { | ||
487 | dy -= INT_TO_SCALED(1); | ||
488 | ++y; | ||
489 | while (dy >= INT_TO_SCALED(1)) { | ||
490 | rle = rle_img_advance_line(rle, rle_limit, src_width); | ||
491 | dy -= INT_TO_SCALED(1); | ||
492 | ++y; | ||
493 | } | ||
494 | rle_start = rle; | ||
495 | } else { | ||
496 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ | ||
497 | } | ||
498 | } | ||
499 | rle_remainder = rlelen = rle->len; | ||
500 | clr_next = rle->color; | ||
501 | rle++; | ||
502 | if (rle >= rle_limit) { | ||
503 | zone_state = 6; | ||
504 | } | ||
505 | break; | ||
506 | default: | ||
507 | ; | ||
224 | } | 508 | } |
225 | } | 509 | } |
510 | #ifdef LOG_BLEND_RGB16 | ||
511 | printf("blend_rgb16 ended\n"); | ||
512 | #endif | ||
513 | |||
226 | } | 514 | } |
227 | 515 | ||
228 | void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, | 516 | void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, |
229 | int img_width, int img_height, | 517 | int img_width, int img_height, |
230 | int dst_width, int dst_height) | 518 | int dst_width, int dst_height, |
519 | alphablend_t *extra_data) | ||
231 | { | 520 | { |
232 | clut_t* clut = (clut_t*) img_overl->clip_color; | ||
233 | uint8_t *trans; | ||
234 | int src_width = img_overl->width; | 521 | int src_width = img_overl->width; |
235 | int src_height = img_overl->height; | 522 | int src_height = img_overl->height; |
236 | rle_elem_t *rle = img_overl->rle; | 523 | rle_elem_t *rle = img_overl->rle; |
237 | rle_elem_t *rle_limit = rle + img_overl->num_rle; | 524 | rle_elem_t *rle_limit = rle + img_overl->num_rle; |
@@ -245,67 +532,108 @@ void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, | |||
245 | 532 | ||
246 | img_pix = img + 3 * ( (img_overl->y * img_height / dst_height) * img_width | 533 | img_pix = img + 3 * ( (img_overl->y * img_height / dst_height) * img_width |
247 | + (img_overl->x * img_width / dst_width)); | 534 | + (img_overl->x * img_width / dst_width)); |
248 | 535 | ||
249 | trans = img_overl->clip_trans; | ||
250 | |||
251 | /* avoid wraping overlay if drawing to small image */ | 536 | /* avoid wraping overlay if drawing to small image */ |
252 | if( (img_overl->x + img_overl->clip_right) < dst_width ) | 537 | if( (img_overl->x + img_overl->clip_right) <= dst_width ) |
253 | clip_right = img_overl->clip_right; | 538 | clip_right = img_overl->clip_right; |
254 | else | 539 | else |
255 | clip_right = dst_width - 1 - img_overl->x; | 540 | clip_right = dst_width - img_overl->x; |
256 | 541 | ||
257 | /* avoid buffer overflow */ | 542 | /* avoid buffer overflow */ |
258 | if( (src_height + img_overl->y) >= dst_height ) | 543 | if( (src_height + img_overl->y) > dst_height ) |
259 | src_height = dst_height - 1 - img_overl->y; | 544 | src_height = dst_height - img_overl->y; |
260 | 545 | ||
261 | for (dy = y = 0; y < src_height && rle < rle_limit; ) { | 546 | for (dy = y = 0; y < src_height && rle < rle_limit; ) { |
262 | int mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y); | 547 | int mask = !(y < img_overl->clip_top || y >= img_overl->clip_bottom); |
263 | rle_elem_t *rle_start = rle; | 548 | rle_elem_t *rle_start = rle; |
264 | 549 | ||
550 | int rlelen = 0; | ||
551 | uint8_t clr = 0; | ||
552 | |||
265 | for (x = x1_scaled = 0; x < src_width;) { | 553 | for (x = x1_scaled = 0; x < src_width;) { |
266 | uint8_t clr; | 554 | int rle_bite; |
555 | clut_t *colors; | ||
556 | uint8_t *trans; | ||
267 | uint16_t o; | 557 | uint16_t o; |
268 | int rlelen; | ||
269 | 558 | ||
270 | clr = rle->color; | 559 | /* take next element from rle list everytime an element is finished */ |
271 | o = trans[clr]; | 560 | if (rlelen <= 0) { |
272 | rlelen = rle->len; | 561 | if (rle >= rle_limit) |
273 | 562 | break; | |
274 | if (o && mask) { | 563 | |
275 | /* threat cases where clipping border is inside rle->len pixels */ | 564 | rlelen = rle->len; |
276 | if ( img_overl->clip_left > x ) { | 565 | clr = rle->color; |
277 | if( img_overl->clip_left < x + rlelen ) { | 566 | rle++; |
278 | x1_scaled = SCALED_TO_INT( img_overl->clip_left * x_scale ); | 567 | } |
279 | rlelen -= img_overl->clip_left - x; | 568 | |
280 | x += img_overl->clip_left - x; | 569 | if (!mask) { |
570 | /* above or below clipping area */ | ||
571 | |||
572 | rle_bite = rlelen; | ||
573 | /* choose palette for surrounding area */ | ||
574 | colors = (clut_t*)img_overl->color; | ||
575 | trans = img_overl->trans; | ||
576 | } else { | ||
577 | /* treat cases where clipping border is inside rle->len pixels */ | ||
578 | if ( x < img_overl->clip_left ) { | ||
579 | /* starts left */ | ||
580 | if( x + rlelen > img_overl->clip_left ) { | ||
581 | /* ends not left */ | ||
582 | |||
583 | /* choose the largest "bite" up to palette change */ | ||
584 | rle_bite = img_overl->clip_left - x; | ||
585 | /* choose palette for surrounding area */ | ||
586 | colors = (clut_t*)img_overl->color; | ||
587 | trans = img_overl->trans; | ||
281 | } else { | 588 | } else { |
282 | o = 0; | 589 | /* ends left */ |
590 | |||
591 | rle_bite = rlelen; | ||
592 | /* choose palette for surrounding area */ | ||
593 | colors = (clut_t*)img_overl->color; | ||
594 | trans = img_overl->trans; | ||
283 | } | 595 | } |
284 | } else if( clip_right < x + rlelen ) { | 596 | } else if( x + rlelen > clip_right ) { |
285 | if( clip_right > x ) { | 597 | /* ends right */ |
286 | x2_scaled = SCALED_TO_INT( clip_right * x_scale); | 598 | if( x < clip_right ) { |
287 | mem_blend24(img_pix + x1_scaled*3, clut[clr].cb, | 599 | /* starts not right */ |
288 | clut[clr].cr, clut[clr].y, | 600 | |
289 | o, x2_scaled-x1_scaled); | 601 | /* choose the largest "bite" up to palette change */ |
290 | o = 0; | 602 | rle_bite = clip_right - x; |
603 | /* we're in the center area so choose clip palette */ | ||
604 | colors = (clut_t*)img_overl->clip_color; | ||
605 | trans = img_overl->clip_trans; | ||
291 | } else { | 606 | } else { |
292 | o = 0; | 607 | /* starts right */ |
608 | |||
609 | rle_bite = rlelen; | ||
610 | /* choose palette for surrounding area */ | ||
611 | colors = (clut_t*)img_overl->color; | ||
612 | trans = img_overl->trans; | ||
293 | } | 613 | } |
294 | } | 614 | } else { |
615 | /* starts not left and ends not right */ | ||
616 | |||
617 | rle_bite = rlelen; | ||
618 | /* we're in the center area so choose clip palette */ | ||
619 | colors = (clut_t*)img_overl->clip_color; | ||
620 | trans = img_overl->clip_trans; | ||
621 | } | ||
295 | } | 622 | } |
296 | 623 | ||
297 | x2_scaled = SCALED_TO_INT((x + rlelen) * x_scale); | 624 | x2_scaled = SCALED_TO_INT((x + rle_bite) * x_scale); |
298 | if (o && mask) { | 625 | |
299 | mem_blend24(img_pix + x1_scaled*3, clut[clr].cb, | 626 | o = trans[clr]; |
300 | clut[clr].cr, clut[clr].y, | 627 | if (o) { |
628 | mem_blend24(img_pix + x1_scaled*3, | ||
629 | colors[clr].cb, colors[clr].cr, colors[clr].y, | ||
301 | o, x2_scaled-x1_scaled); | 630 | o, x2_scaled-x1_scaled); |
302 | } | 631 | } |
303 | 632 | ||
304 | x1_scaled = x2_scaled; | 633 | x1_scaled = x2_scaled; |
305 | x += rlelen; | 634 | x += rle_bite; |
306 | rle++; | 635 | rlelen -= rle_bite; |
307 | if (rle >= rle_limit) break; | ||
308 | } | 636 | } |
309 | 637 | ||
310 | img_pix += img_width * 3; | 638 | img_pix += img_width * 3; |
311 | dy += dy_step; | 639 | dy += dy_step; |
@@ -324,12 +652,11 @@ void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, | |||
324 | } | 652 | } |
325 | 653 | ||
326 | void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, | 654 | void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, |
327 | int img_width, int img_height, | 655 | int img_width, int img_height, |
328 | int dst_width, int dst_height) | 656 | int dst_width, int dst_height, |
657 | alphablend_t *extra_data) | ||
329 | { | 658 | { |
330 | clut_t* clut = (clut_t*) img_overl->clip_color; | ||
331 | uint8_t *trans; | ||
332 | int src_width = img_overl->width; | 659 | int src_width = img_overl->width; |
333 | int src_height = img_overl->height; | 660 | int src_height = img_overl->height; |
334 | rle_elem_t *rle = img_overl->rle; | 661 | rle_elem_t *rle = img_overl->rle; |
335 | rle_elem_t *rle_limit = rle + img_overl->num_rle; | 662 | rle_elem_t *rle_limit = rle + img_overl->num_rle; |
@@ -343,67 +670,106 @@ void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, | |||
343 | 670 | ||
344 | img_pix = img + 4 * ( (img_overl->y * img_height / dst_height) * img_width | 671 | img_pix = img + 4 * ( (img_overl->y * img_height / dst_height) * img_width |
345 | + (img_overl->x * img_width / dst_width)); | 672 | + (img_overl->x * img_width / dst_width)); |
346 | 673 | ||
347 | trans = img_overl->clip_trans; | ||
348 | |||
349 | /* avoid wraping overlay if drawing to small image */ | 674 | /* avoid wraping overlay if drawing to small image */ |
350 | if( (img_overl->x + img_overl->clip_right) < dst_width ) | 675 | if( (img_overl->x + img_overl->clip_right) <= dst_width ) |
351 | clip_right = img_overl->clip_right; | 676 | clip_right = img_overl->clip_right; |
352 | else | 677 | else |
353 | clip_right = dst_width - 1 - img_overl->x; | 678 | clip_right = dst_width - img_overl->x; |
354 | 679 | ||
355 | /* avoid buffer overflow */ | 680 | /* avoid buffer overflow */ |
356 | if( (src_height + img_overl->y) >= dst_height ) | 681 | if( (src_height + img_overl->y) > dst_height ) |
357 | src_height = dst_height - 1 - img_overl->y; | 682 | src_height = dst_height - img_overl->y; |
358 | 683 | ||
359 | for (y = dy = 0; y < src_height && rle < rle_limit; ) { | 684 | for (y = dy = 0; y < src_height && rle < rle_limit; ) { |
360 | int mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y); | 685 | int mask = !(y < img_overl->clip_top || y >= img_overl->clip_bottom); |
361 | rle_elem_t *rle_start = rle; | 686 | rle_elem_t *rle_start = rle; |
362 | 687 | ||
688 | int rlelen = 0; | ||
689 | uint8_t clr = 0; | ||
690 | |||
363 | for (x = x1_scaled = 0; x < src_width;) { | 691 | for (x = x1_scaled = 0; x < src_width;) { |
364 | uint8_t clr; | 692 | int rle_bite; |
693 | clut_t *colors; | ||
694 | uint8_t *trans; | ||
365 | uint16_t o; | 695 | uint16_t o; |
366 | int rlelen; | 696 | |
697 | /* take next element from rle list everytime an element is finished */ | ||
698 | if (rlelen <= 0) { | ||
699 | if (rle >= rle_limit) | ||
700 | break; | ||
701 | |||
702 | rlelen = rle->len; | ||
703 | clr = rle->color; | ||
704 | rle++; | ||
705 | } | ||
367 | 706 | ||
368 | clr = rle->color; | 707 | if (!mask) { |
369 | o = trans[clr]; | 708 | /* above or below clipping area */ |
370 | rlelen = rle->len; | 709 | |
371 | 710 | rle_bite = rlelen; | |
372 | if (o && mask) { | 711 | /* choose palette for surrounding area */ |
373 | /* threat cases where clipping border is inside rle->len pixels */ | 712 | colors = (clut_t*)img_overl->color; |
374 | if ( img_overl->clip_left > x ) { | 713 | trans = img_overl->trans; |
375 | if( img_overl->clip_left < x + rlelen ) { | 714 | } else { |
376 | x1_scaled = SCALED_TO_INT( img_overl->clip_left * x_scale ); | 715 | /* treat cases where clipping border is inside rle->len pixels */ |
377 | rlelen -= img_overl->clip_left - x; | 716 | if ( x < img_overl->clip_left ) { |
378 | x += img_overl->clip_left - x; | 717 | /* starts left */ |
718 | if( x + rlelen > img_overl->clip_left ) { | ||
719 | /* ends not left */ | ||
720 | |||
721 | /* choose the largest "bite" up to palette change */ | ||
722 | rle_bite = img_overl->clip_left - x; | ||
723 | /* choose palette for surrounding area */ | ||
724 | colors = (clut_t*)img_overl->color; | ||
725 | trans = img_overl->trans; | ||
379 | } else { | 726 | } else { |
380 | o = 0; | 727 | /* ends left */ |
728 | |||
729 | rle_bite = rlelen; | ||
730 | /* choose palette for surrounding area */ | ||
731 | colors = (clut_t*)img_overl->color; | ||
732 | trans = img_overl->trans; | ||
381 | } | 733 | } |
382 | } else if( clip_right < x + rlelen ) { | 734 | } else if( x + rlelen > clip_right ) { |
383 | if( clip_right > x ) { | 735 | /* ends right */ |
384 | x2_scaled = SCALED_TO_INT( clip_right * x_scale); | 736 | if( x < clip_right ) { |
385 | mem_blend24_32(img_pix + x1_scaled*4, clut[clr].cb, | 737 | /* starts not right */ |
386 | clut[clr].cr, clut[clr].y, | 738 | |
387 | o, x2_scaled-x1_scaled); | 739 | /* choose the largest "bite" up to palette change */ |
388 | o = 0; | 740 | rle_bite = clip_right - x; |
741 | /* we're in the center area so choose clip palette */ | ||
742 | colors = (clut_t*)img_overl->clip_color; | ||
743 | trans = img_overl->clip_trans; | ||
389 | } else { | 744 | } else { |
390 | o = 0; | 745 | /* starts right */ |
746 | |||
747 | rle_bite = rlelen; | ||
748 | /* choose palette for surrounding area */ | ||
749 | colors = (clut_t*)img_overl->color; | ||
750 | trans = img_overl->trans; | ||
391 | } | 751 | } |
392 | } | 752 | } else { |
753 | /* starts not left and ends not right */ | ||
754 | |||
755 | rle_bite = rlelen; | ||
756 | /* we're in the center area so choose clip palette */ | ||
757 | colors = (clut_t*)img_overl->clip_color; | ||
758 | trans = img_overl->clip_trans; | ||
759 | } | ||
393 | } | 760 | } |
761 | |||
762 | x2_scaled = SCALED_TO_INT((x + rle_bite) * x_scale); | ||
394 | 763 | ||
395 | x2_scaled = SCALED_TO_INT((x + rlelen) * x_scale); | 764 | o = trans[clr]; |
396 | if (o && mask) { | 765 | if (o) { |
397 | mem_blend24_32(img_pix + x1_scaled*4, clut[clr].cb, | 766 | mem_blend32(img_pix + x1_scaled*4, (uint8_t *)&colors[clr], o, x2_scaled-x1_scaled); |
398 | clut[clr].cr, clut[clr].y, | ||
399 | o, x2_scaled-x1_scaled); | ||
400 | } | 767 | } |
401 | 768 | ||
402 | x1_scaled = x2_scaled; | 769 | x1_scaled = x2_scaled; |
403 | x += rlelen; | 770 | x += rle_bite; |
404 | rle++; | 771 | rlelen -= rle_bite; |
405 | if (rle >= rle_limit) break; | ||
406 | } | 772 | } |
407 | 773 | ||
408 | img_pix += img_width * 4; | 774 | img_pix += img_width * 4; |
409 | dy += dy_step; | 775 | dy += dy_step; |
@@ -429,11 +795,111 @@ static void mem_blend8(uint8_t *mem, uint8_t val, uint8_t o, size_t sz) | |||
429 | mem++; | 795 | mem++; |
430 | } | 796 | } |
431 | } | 797 | } |
432 | 798 | ||
799 | static void blend_yuv_exact(uint8_t *dst_cr, uint8_t *dst_cb, | ||
800 | int src_width, int x_odd, | ||
801 | uint8_t *(*blend_yuv_data)[ 3 ][ 2 ]) | ||
802 | { | ||
803 | int x; | ||
804 | |||
805 | for (x = 0; x < src_width; x += 2) { | ||
806 | /* get opacity of the 4 pixels that share chroma */ | ||
807 | int o00 = (*blend_yuv_data)[ 0 ][ 0 ][ x + 0 ]; | ||
808 | int o01 = (*blend_yuv_data)[ 0 ][ 0 ][ x + 1 ]; | ||
809 | int o10 = (*blend_yuv_data)[ 0 ][ 1 ][ x + 0 ]; | ||
810 | int o11 = (*blend_yuv_data)[ 0 ][ 1 ][ x + 1 ]; | ||
811 | |||
812 | /* are there any pixels a little bit opaque? */ | ||
813 | if (o00 || o01 || o10 || o11) { | ||
814 | /* get the chroma components of the 4 pixels */ | ||
815 | int cr00 = -128 + (*blend_yuv_data)[ 1 ][ 0 ][ x + 0 ]; | ||
816 | int cr01 = -128 + (*blend_yuv_data)[ 1 ][ 0 ][ x + 1 ]; | ||
817 | int cr10 = -128 + (*blend_yuv_data)[ 1 ][ 1 ][ x + 0 ]; | ||
818 | int cr11 = -128 + (*blend_yuv_data)[ 1 ][ 1 ][ x + 1 ]; | ||
819 | |||
820 | int cb00 = -128 + (*blend_yuv_data)[ 2 ][ 0 ][ x + 0 ]; | ||
821 | int cb01 = -128 + (*blend_yuv_data)[ 2 ][ 0 ][ x + 1 ]; | ||
822 | int cb10 = -128 + (*blend_yuv_data)[ 2 ][ 1 ][ x + 0 ]; | ||
823 | int cb11 = -128 + (*blend_yuv_data)[ 2 ][ 1 ][ x + 1 ]; | ||
824 | |||
825 | /* are all pixels completely opaque? */ | ||
826 | if (o00 >= 0xf && o01 >= 0xf && o10 >= 0xf && o11 >= 0xf) { | ||
827 | /* set the output chroma to the average of the four pixels */ | ||
828 | *dst_cr = 128 + (cr00 + cr01 + cr10 + cr11) / 4; | ||
829 | *dst_cb = 128 + (cb00 + cb01 + cb10 + cb11) / 4; | ||
830 | } else { | ||
831 | int t4, cr, cb; | ||
832 | |||
833 | /* blending required, so clamp opacity values to allowed range */ | ||
834 | if (o00 > 0xf) o00 = 0xf; | ||
835 | if (o01 > 0xf) o01 = 0xf; | ||
836 | if (o10 > 0xf) o10 = 0xf; | ||
837 | if (o11 > 0xf) o11 = 0xf; | ||
838 | |||
839 | /* calculate transparency of background over the four pixels */ | ||
840 | t4 = (0xf - o00) + (0xf - o01) + (0xf - o10) + (0xf - o11); | ||
841 | |||
842 | /* get background chroma */ | ||
843 | cr = -128 + *dst_cr; | ||
844 | cb = -128 + *dst_cb; | ||
845 | |||
846 | /* blend the output chroma to the average of the four pixels */ | ||
847 | *dst_cr = 128 + (cr * t4 + cr00 * o00 + cr01 * o01 + cr10 * o10 + cr11 * o11) / (4 * 0xf); | ||
848 | *dst_cb = 128 + (cb * t4 + cb00 * o00 + cb01 * o01 + cb10 * o10 + cb11 * o11) / (4 * 0xf); | ||
849 | } | ||
850 | } | ||
851 | |||
852 | /* next chroma sample */ | ||
853 | dst_cr++; | ||
854 | dst_cb++; | ||
855 | } | ||
856 | } | ||
857 | |||
858 | static uint8_t *(*blend_yuv_grow_extra_data(alphablend_t *extra_data, int osd_width))[ 3 ][ 2 ] | ||
859 | { | ||
860 | struct __attribute__((packed)) header_s { | ||
861 | int id; | ||
862 | int max_width; | ||
863 | uint8_t *data[ 3 ][ 2 ]; | ||
864 | } **header = (struct header_s **)&extra_data->buffer; | ||
865 | |||
866 | int needed_buffer_size = sizeof (**header) + sizeof (uint8_t[ 3 ][ 2 ][ osd_width ]); | ||
867 | |||
868 | if (extra_data->buffer_size < needed_buffer_size) { | ||
869 | |||
870 | free(extra_data->buffer); | ||
871 | extra_data->buffer = xine_xmalloc(needed_buffer_size); | ||
872 | |||
873 | if (!extra_data->buffer) { | ||
874 | extra_data->buffer_size = 0; | ||
875 | return 0; | ||
876 | } | ||
877 | |||
878 | extra_data->buffer_size = needed_buffer_size; | ||
879 | (*header)->max_width = 0; | ||
880 | } | ||
881 | |||
882 | if ((*header)->id != ME_FOURCC('y', 'u', 'v', 0) || (*header)->max_width < osd_width) { | ||
883 | (*header)->id = ME_FOURCC('y', 'u', 'v', 0); | ||
884 | (*header)->max_width = osd_width; | ||
885 | |||
886 | (*header)->data[ 0 ][ 0 ] = ((uint8_t *)extra_data->buffer) + sizeof (**header); | ||
887 | (*header)->data[ 0 ][ 1 ] = (*header)->data[ 0 ][ 0 ] + osd_width; | ||
888 | (*header)->data[ 1 ][ 0 ] = (*header)->data[ 0 ][ 1 ] + osd_width; | ||
889 | (*header)->data[ 1 ][ 1 ] = (*header)->data[ 1 ][ 0 ] + osd_width; | ||
890 | (*header)->data[ 2 ][ 0 ] = (*header)->data[ 1 ][ 1 ] + osd_width; | ||
891 | (*header)->data[ 2 ][ 1 ] = (*header)->data[ 2 ][ 0 ] + osd_width; | ||
892 | } | ||
893 | |||
894 | return &(*header)->data; | ||
895 | } | ||
896 | |||
433 | void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | 897 | void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, |
434 | int dst_width, int dst_height) | 898 | int dst_width, int dst_height, int dst_pitches[3], |
899 | alphablend_t *extra_data) | ||
435 | { | 900 | { |
901 | int enable_exact_blending = !extra_data->disable_exact_blending; | ||
436 | clut_t *my_clut; | 902 | clut_t *my_clut; |
437 | uint8_t *my_trans; | 903 | uint8_t *my_trans; |
438 | 904 | ||
439 | int src_width = img_overl->width; | 905 | int src_width = img_overl->width; |
@@ -441,53 +907,91 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
441 | rle_elem_t *rle = img_overl->rle; | 907 | rle_elem_t *rle = img_overl->rle; |
442 | rle_elem_t *rle_limit = rle + img_overl->num_rle; | 908 | rle_elem_t *rle_limit = rle + img_overl->num_rle; |
443 | int x_off = img_overl->x; | 909 | int x_off = img_overl->x; |
444 | int y_off = img_overl->y; | 910 | int y_off = img_overl->y; |
911 | int x_odd = x_off & 1; | ||
912 | int y_odd = y_off & 1; | ||
445 | int ymask,xmask; | 913 | int ymask,xmask; |
446 | int rle_this_bite; | 914 | int rle_this_bite; |
447 | int rle_remainder; | 915 | int rle_remainder; |
448 | int rlelen; | 916 | int rlelen; |
449 | int x, y; | 917 | int x, y; |
450 | int clip_right; | 918 | int clip_right; |
451 | uint8_t clr=0; | 919 | uint8_t clr=0; |
452 | 920 | ||
453 | uint8_t *dst_y = dst_base[0] + dst_width * y_off + x_off; | 921 | int any_line_buffered = 0; |
454 | uint8_t *dst_cr = dst_base[2] + | 922 | int exact_blend_width = ((src_width <= (dst_width - x_off)) ? src_width : (dst_width - x_off)); |
455 | (y_off / 2) * (dst_width / 2) + (x_off / 2) + 1; | 923 | int exact_blend_width_m2 = (x_odd + exact_blend_width + 1) & ~1; /* make it a (larger) multiple of 2 */ |
456 | uint8_t *dst_cb = dst_base[1] + | 924 | uint8_t *(*blend_yuv_data)[ 3 ][ 2 ] = 0; |
457 | (y_off / 2) * (dst_width / 2) + (x_off / 2) + 1; | 925 | |
926 | uint8_t *dst_y = dst_base[0] + dst_pitches[0] * y_off + x_off; | ||
927 | uint8_t *dst_cr = dst_base[2] + (y_off / 2) * dst_pitches[1] + (x_off / 2); | ||
928 | uint8_t *dst_cb = dst_base[1] + (y_off / 2) * dst_pitches[2] + (x_off / 2); | ||
458 | #ifdef LOG_BLEND_YUV | 929 | #ifdef LOG_BLEND_YUV |
459 | printf("overlay_blend started x=%d, y=%d, w=%d h=%d\n",img_overl->x,img_overl->y,img_overl->width,img_overl->height); | 930 | printf("overlay_blend started x=%d, y=%d, w=%d h=%d\n",img_overl->x,img_overl->y,img_overl->width,img_overl->height); |
460 | #endif | 931 | #endif |
461 | my_clut = (clut_t*) img_overl->clip_color; | 932 | my_clut = (clut_t*) img_overl->clip_color; |
462 | my_trans = img_overl->clip_trans; | 933 | my_trans = img_overl->clip_trans; |
463 | 934 | ||
464 | /* avoid wraping overlay if drawing to small image */ | 935 | /* avoid wraping overlay if drawing to small image */ |
465 | if( (x_off + img_overl->clip_right) < dst_width ) | 936 | if( (x_off + img_overl->clip_right) <= dst_width ) |
466 | clip_right = img_overl->clip_right; | 937 | clip_right = img_overl->clip_right; |
467 | else | 938 | else |
468 | clip_right = dst_width - 1 - x_off; | 939 | clip_right = dst_width - x_off; |
469 | 940 | ||
470 | /* avoid buffer overflow */ | 941 | /* avoid buffer overflow */ |
471 | if( (src_height + y_off) >= dst_height ) | 942 | if( (src_height + y_off) > dst_height ) |
472 | src_height = dst_height - 1 - y_off; | 943 | src_height = dst_height - y_off; |
473 | 944 | ||
945 | if (src_height <= 0) | ||
946 | return; | ||
947 | |||
948 | if (enable_exact_blending) { | ||
949 | if (exact_blend_width <= 0) | ||
950 | return; | ||
951 | |||
952 | blend_yuv_data = blend_yuv_grow_extra_data(extra_data, exact_blend_width_m2); | ||
953 | if (!blend_yuv_data) | ||
954 | return; | ||
955 | |||
956 | /* make linebuffer transparent */ | ||
957 | memset(&(*blend_yuv_data)[ 0 ][ 0 ][ 0 ], 0, exact_blend_width_m2); | ||
958 | memset(&(*blend_yuv_data)[ 0 ][ 1 ][ 0 ], 0, exact_blend_width_m2); | ||
959 | } | ||
960 | |||
474 | rlelen=rle_remainder=0; | 961 | rlelen=rle_remainder=0; |
475 | for (y = 0; y < src_height; y++) { | 962 | for (y = 0; y < src_height; y++) { |
476 | ymask = ((img_overl->clip_top > y) || (img_overl->clip_bottom < y)); | 963 | if (rle >= rle_limit) { |
964 | #ifdef LOG_BLEND_YUV | ||
965 | printf("y-rle_limit\n"); | ||
966 | #endif | ||
967 | break; | ||
968 | } | ||
969 | |||
970 | ymask = ((y < img_overl->clip_top) || (y >= img_overl->clip_bottom)); | ||
477 | xmask = 0; | 971 | xmask = 0; |
478 | #ifdef LOG_BLEND_YUV | 972 | #ifdef LOG_BLEND_YUV |
479 | printf("X started ymask=%d y=%d src_height=%d\n",ymask, y, src_height); | 973 | printf("X started ymask=%d y=%d src_height=%d\n",ymask, y, src_height); |
480 | #endif | 974 | #endif |
481 | 975 | ||
482 | for (x = 0; x < src_width;) { | 976 | for (x = 0; x < src_width;) { |
483 | uint16_t o; | 977 | uint16_t o; |
978 | |||
979 | if (rle >= rle_limit) { | ||
980 | #ifdef LOG_BLEND_YUV | ||
981 | printf("x-rle_limit\n"); | ||
982 | #endif | ||
983 | break; | ||
984 | } | ||
985 | |||
484 | #ifdef LOG_BLEND_YUV | 986 | #ifdef LOG_BLEND_YUV |
485 | printf("1:rle_len=%d, remainder=%d, x=%d\n",rlelen, rle_remainder, x); | 987 | printf("1:rle_len=%d, remainder=%d, x=%d\n",rlelen, rle_remainder, x); |
486 | #endif | 988 | #endif |
487 | 989 | ||
488 | if ((rlelen < 0) || (rle_remainder < 0)) { | 990 | if ((rlelen < 0) || (rle_remainder < 0)) { |
991 | #ifdef LOG_BLEND_YUV | ||
489 | printf("alphablend: major bug in blend_yuv < 0\n"); | 992 | printf("alphablend: major bug in blend_yuv < 0\n"); |
993 | #endif | ||
490 | } | 994 | } |
491 | if (rlelen == 0) { | 995 | if (rlelen == 0) { |
492 | rle_remainder = rlelen = rle->len; | 996 | rle_remainder = rlelen = rle->len; |
493 | clr = rle->color; | 997 | clr = rle->color; |
@@ -497,24 +1001,23 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
497 | rle_remainder = rlelen; | 1001 | rle_remainder = rlelen; |
498 | } | 1002 | } |
499 | if ((rle_remainder + x) > src_width) { | 1003 | if ((rle_remainder + x) > src_width) { |
500 | /* Do something for long rlelengths */ | 1004 | /* Do something for long rlelengths */ |
501 | rle_remainder = src_width - x; | 1005 | rle_remainder = src_width - x; |
502 | ; | ||
503 | } | 1006 | } |
504 | #ifdef LOG_BLEND_YUV | 1007 | #ifdef LOG_BLEND_YUV |
505 | printf("2:rle_len=%d, remainder=%d, x=%d\n",rlelen, rle_remainder, x); | 1008 | printf("2:rle_len=%d, remainder=%d, x=%d\n",rlelen, rle_remainder, x); |
506 | #endif | 1009 | #endif |
507 | 1010 | ||
508 | if (ymask == 0) { | 1011 | if (ymask == 0) { |
509 | if (x <= img_overl->clip_left) { | 1012 | if (x < img_overl->clip_left) { |
510 | /* Starts outside clip area */ | 1013 | /* Starts outside clip area */ |
511 | if ((x + rle_remainder - 1) > img_overl->clip_left ) { | 1014 | if ((x + rle_remainder) > img_overl->clip_left ) { |
512 | #ifdef LOG_BLEND_YUV | 1015 | #ifdef LOG_BLEND_YUV |
513 | printf("Outside clip left %d, ending inside\n", img_overl->clip_left); | 1016 | printf("Outside clip left %d, ending inside\n", img_overl->clip_left); |
514 | #endif | 1017 | #endif |
515 | /* Cutting needed, starts outside, ends inside */ | 1018 | /* Cutting needed, starts outside, ends inside */ |
516 | rle_this_bite = (img_overl->clip_left - x + 1); | 1019 | rle_this_bite = (img_overl->clip_left - x); |
517 | rle_remainder -= rle_this_bite; | 1020 | rle_remainder -= rle_this_bite; |
518 | rlelen -= rle_this_bite; | 1021 | rlelen -= rle_this_bite; |
519 | my_clut = (clut_t*) img_overl->color; | 1022 | my_clut = (clut_t*) img_overl->color; |
520 | my_trans = img_overl->trans; | 1023 | my_trans = img_overl->trans; |
@@ -556,9 +1059,9 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
556 | my_trans = img_overl->clip_trans; | 1059 | my_trans = img_overl->clip_trans; |
557 | xmask++; | 1060 | xmask++; |
558 | } | 1061 | } |
559 | } else if (x >= clip_right) { | 1062 | } else if (x >= clip_right) { |
560 | /* Starts outside clip area, ends outsite clip area */ | 1063 | /* Starts outside clip area, ends outside clip area */ |
561 | if ((x + rle_remainder ) > src_width ) { | 1064 | if ((x + rle_remainder ) > src_width ) { |
562 | #ifdef LOG_BLEND_YUV | 1065 | #ifdef LOG_BLEND_YUV |
563 | printf("Outside clip right %d, ending eol\n", clip_right); | 1066 | printf("Outside clip right %d, ending eol\n", clip_right); |
564 | #endif | 1067 | #endif |
@@ -596,58 +1099,189 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
596 | o = my_trans[clr]; | 1099 | o = my_trans[clr]; |
597 | #ifdef LOG_BLEND_YUV | 1100 | #ifdef LOG_BLEND_YUV |
598 | printf("Trans=%d clr=%d xmask=%d my_clut[clr]=%d\n",o, clr, xmask, my_clut[clr].y); | 1101 | printf("Trans=%d clr=%d xmask=%d my_clut[clr]=%d\n",o, clr, xmask, my_clut[clr].y); |
599 | #endif | 1102 | #endif |
600 | if (o) { | 1103 | |
601 | if(o >= 15) { | 1104 | if (x < (dst_width - x_off)) { |
602 | memset(dst_y + x, my_clut[clr].y, rle_this_bite); | 1105 | /* clip against right edge of destination area */ |
603 | if (y & 1) { | 1106 | if ((x + rle_this_bite) > (dst_width - x_off)) { |
604 | memset(dst_cr + (x >> 1), my_clut[clr].cr, (rle_this_bite+1) >> 1); | 1107 | int toClip = (x + rle_this_bite) - (dst_width - x_off); |
605 | memset(dst_cb + (x >> 1), my_clut[clr].cb, (rle_this_bite+1) >> 1); | 1108 | |
606 | } | 1109 | rle_this_bite -= toClip; |
607 | } else { | 1110 | rle_remainder += toClip; |
608 | mem_blend8(dst_y + x, my_clut[clr].y, o, rle_this_bite); | 1111 | rlelen += toClip; |
609 | if (y & 1) { | ||
610 | /* Blending cr and cb should use a different function, with pre -128 to each sample */ | ||
611 | mem_blend8(dst_cr + (x >> 1), my_clut[clr].cr, o, (rle_this_bite+1) >> 1); | ||
612 | mem_blend8(dst_cb + (x >> 1), my_clut[clr].cb, o, (rle_this_bite+1) >> 1); | ||
613 | } | ||
614 | } | 1112 | } |
615 | 1113 | ||
1114 | if (enable_exact_blending) { | ||
1115 | /* remember opacity of current line */ | ||
1116 | memset(&(*blend_yuv_data)[ 0 ][ (y + y_odd) & 1 ][ x + x_odd ], o, rle_this_bite); | ||
1117 | any_line_buffered |= ((y + y_odd) & 1) ? 2 : 1; | ||
1118 | } | ||
1119 | |||
1120 | if (o) { | ||
1121 | if(o >= 15) { | ||
1122 | memset(dst_y + x, my_clut[clr].y, rle_this_bite); | ||
1123 | if (!enable_exact_blending) { | ||
1124 | if ((y + y_odd) & 1) { | ||
1125 | memset(dst_cr + ((x + x_odd) >> 1), my_clut[clr].cr, (rle_this_bite+1) >> 1); | ||
1126 | memset(dst_cb + ((x + x_odd) >> 1), my_clut[clr].cb, (rle_this_bite+1) >> 1); | ||
1127 | } | ||
1128 | } | ||
1129 | } else { | ||
1130 | mem_blend8(dst_y + x, my_clut[clr].y, o, rle_this_bite); | ||
1131 | if (!enable_exact_blending) { | ||
1132 | if ((y + y_odd) & 1) { | ||
1133 | /* Blending cr and cb should use a different function, with pre -128 to each sample */ | ||
1134 | mem_blend8(dst_cr + ((x + x_odd) >> 1), my_clut[clr].cr, o, (rle_this_bite+1) >> 1); | ||
1135 | mem_blend8(dst_cb + ((x + x_odd) >> 1), my_clut[clr].cb, o, (rle_this_bite+1) >> 1); | ||
1136 | } | ||
1137 | } | ||
1138 | } | ||
1139 | |||
1140 | if (enable_exact_blending) { | ||
1141 | /* remember chroma of current line */ | ||
1142 | memset(&(*blend_yuv_data)[ 1 ][ (y + y_odd) & 1 ][ x + x_odd ], my_clut[ clr ].cr, rle_this_bite); | ||
1143 | memset(&(*blend_yuv_data)[ 2 ][ (y + y_odd) & 1 ][ x + x_odd ], my_clut[ clr ].cb, rle_this_bite); | ||
1144 | } | ||
1145 | } | ||
616 | } | 1146 | } |
617 | #ifdef LOG_BLEND_YUV | 1147 | #ifdef LOG_BLEND_YUV |
618 | printf("rle_this_bite=%d, remainder=%d, x=%d\n",rle_this_bite, rle_remainder, x); | 1148 | printf("rle_this_bite=%d, remainder=%d, x=%d\n",rle_this_bite, rle_remainder, x); |
619 | #endif | 1149 | #endif |
620 | x += rle_this_bite; | 1150 | x += rle_this_bite; |
621 | if (rle >= rle_limit) { | ||
622 | #ifdef LOG_BLEND_YUV | ||
623 | printf("x-rle_limit\n"); | ||
624 | #endif | ||
625 | break; | ||
626 | } | ||
627 | } | ||
628 | if (rle >= rle_limit) { | ||
629 | #ifdef LOG_BLEND_YUV | ||
630 | printf("x-rle_limit\n"); | ||
631 | #endif | ||
632 | break; | ||
633 | } | 1151 | } |
634 | 1152 | ||
635 | dst_y += dst_width; | 1153 | if ((y + y_odd) & 1) { |
1154 | if (enable_exact_blending) { | ||
1155 | /* blend buffered lines */ | ||
1156 | if (any_line_buffered) { | ||
1157 | if (!(any_line_buffered & 2)) { | ||
1158 | /* make second line transparent */ | ||
1159 | memset(&(*blend_yuv_data)[ 0 ][ 1 ][ 0 ], 0, exact_blend_width_m2); | ||
1160 | } | ||
1161 | |||
1162 | blend_yuv_exact(dst_cr, dst_cb, exact_blend_width, x_odd, blend_yuv_data); | ||
1163 | |||
1164 | any_line_buffered = 0; | ||
1165 | } | ||
1166 | } | ||
1167 | |||
1168 | dst_cr += dst_pitches[2]; | ||
1169 | dst_cb += dst_pitches[1]; | ||
1170 | } | ||
1171 | |||
1172 | dst_y += dst_pitches[0]; | ||
1173 | } | ||
636 | 1174 | ||
637 | if (y & 1) { | 1175 | if (enable_exact_blending) { |
638 | dst_cr += (dst_width + 1) / 2; | 1176 | /* blend buffered lines */ |
639 | dst_cb += (dst_width + 1) / 2; | 1177 | if (any_line_buffered) { |
1178 | if (!(any_line_buffered & 2)) { | ||
1179 | /* make second line transparent */ | ||
1180 | memset(&(*blend_yuv_data)[ 0 ][ 1 ][ 0 ], 0, exact_blend_width_m2); | ||
1181 | } | ||
1182 | |||
1183 | blend_yuv_exact(dst_cr, dst_cb, exact_blend_width, x_odd, blend_yuv_data); | ||
640 | } | 1184 | } |
641 | } | 1185 | } |
1186 | |||
642 | #ifdef LOG_BLEND_YUV | 1187 | #ifdef LOG_BLEND_YUV |
643 | printf("overlay_blend ended\n"); | 1188 | printf("overlay_blend ended\n"); |
644 | #endif | 1189 | #endif |
645 | } | 1190 | } |
646 | 1191 | ||
1192 | static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, | ||
1193 | int src_width, int x_odd, | ||
1194 | uint8_t *(*blend_yuy2_data)[ 3 ]) | ||
1195 | { | ||
1196 | int x; | ||
1197 | |||
1198 | for (x = 0; x < src_width; x += 2) { | ||
1199 | /* get opacity of the 2 pixels that share chroma */ | ||
1200 | int o0 = (*blend_yuy2_data)[ 0 ][ x + 0 ]; | ||
1201 | int o1 = (*blend_yuy2_data)[ 0 ][ x + 1 ]; | ||
1202 | |||
1203 | /* are there any pixels a little bit opaque? */ | ||
1204 | if (o0 || o1) { | ||
1205 | /* get the chroma components of the 2 pixels */ | ||
1206 | int cr0 = -128 + (*blend_yuy2_data)[ 1 ][ x + 0 ]; | ||
1207 | int cr1 = -128 + (*blend_yuy2_data)[ 1 ][ x + 1 ]; | ||
1208 | |||
1209 | int cb0 = -128 + (*blend_yuy2_data)[ 2 ][ x + 0 ]; | ||
1210 | int cb1 = -128 + (*blend_yuy2_data)[ 2 ][ x + 1 ]; | ||
1211 | |||
1212 | /* are all pixels completely opaque? */ | ||
1213 | if (o0 >= 0xf && o1 >= 0xf) { | ||
1214 | /* set the output chroma to the average of the two pixels */ | ||
1215 | *dst_cr = 128 + (cr0 + cr1) / 2; | ||
1216 | *dst_cb = 128 + (cb0 + cb1) / 2; | ||
1217 | } else { | ||
1218 | int t2, cr, cb; | ||
1219 | |||
1220 | /* blending required, so clamp opacity values to allowed range */ | ||
1221 | if (o0 > 0xf) o0 = 0xf; | ||
1222 | if (o1 > 0xf) o1 = 0xf; | ||
1223 | |||
1224 | /* calculate transparency of background over the two pixels */ | ||
1225 | t2 = (0xf - o0) + (0xf - o1); | ||
1226 | |||
1227 | /* get background chroma */ | ||
1228 | cr = -128 + *dst_cr; | ||
1229 | cb = -128 + *dst_cb; | ||
1230 | |||
1231 | /* blend the output chroma to the average of the two pixels */ | ||
1232 | *dst_cr = 128 + (cr * t2 + cr0 * o0 + cr1 * o1) / (2 * 0xf); | ||
1233 | *dst_cb = 128 + (cb * t2 + cb0 * o0 + cb1 * o1) / (2 * 0xf); | ||
1234 | } | ||
1235 | } | ||
1236 | |||
1237 | /* next chroma sample */ | ||
1238 | dst_cr += 4; | ||
1239 | dst_cb += 4; | ||
1240 | } | ||
1241 | } | ||
1242 | |||
1243 | static uint8_t *(*blend_yuy2_grow_extra_data(alphablend_t *extra_data, int osd_width))[ 3 ] | ||
1244 | { | ||
1245 | struct __attribute__((packed)) header_s { | ||
1246 | int id; | ||
1247 | int max_width; | ||
1248 | uint8_t *data[ 3 ]; | ||
1249 | } **header = (struct header_s **)&extra_data->buffer; | ||
1250 | |||
1251 | int needed_buffer_size = sizeof (**header) + sizeof (uint8_t[ 3 ][ osd_width ]); | ||
1252 | |||
1253 | if (extra_data->buffer_size < needed_buffer_size) { | ||
1254 | |||
1255 | free(extra_data->buffer); | ||
1256 | extra_data->buffer = xine_xmalloc(needed_buffer_size); | ||
1257 | |||
1258 | if (!extra_data->buffer) { | ||
1259 | extra_data->buffer_size = 0; | ||
1260 | return 0; | ||
1261 | } | ||
1262 | |||
1263 | extra_data->buffer_size = needed_buffer_size; | ||
1264 | (*header)->max_width = 0; | ||
1265 | } | ||
1266 | |||
1267 | if ((*header)->id != ME_FOURCC('y', 'u', 'y', '2') || (*header)->max_width < osd_width) { | ||
1268 | (*header)->id = ME_FOURCC('y', 'u', 'y', '2'); | ||
1269 | (*header)->max_width = osd_width; | ||
1270 | |||
1271 | (*header)->data[ 0 ] = ((uint8_t *)extra_data->buffer) + sizeof (**header); | ||
1272 | (*header)->data[ 1 ] = (*header)->data[ 0 ] + osd_width; | ||
1273 | (*header)->data[ 2 ] = (*header)->data[ 1 ] + osd_width; | ||
1274 | } | ||
1275 | |||
1276 | return &(*header)->data; | ||
1277 | } | ||
1278 | |||
647 | void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, | 1279 | void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, |
648 | int dst_width, int dst_height) | 1280 | int dst_width, int dst_height, int dst_pitch, |
1281 | alphablend_t *extra_data) | ||
649 | { | 1282 | { |
1283 | int enable_exact_blending = !extra_data->disable_exact_blending; | ||
650 | clut_t *my_clut; | 1284 | clut_t *my_clut; |
651 | uint8_t *my_trans; | 1285 | uint8_t *my_trans; |
652 | 1286 | ||
653 | int src_width = img_overl->width; | 1287 | int src_width = img_overl->width; |
@@ -655,101 +1289,496 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, | |||
655 | rle_elem_t *rle = img_overl->rle; | 1289 | rle_elem_t *rle = img_overl->rle; |
656 | rle_elem_t *rle_limit = rle + img_overl->num_rle; | 1290 | rle_elem_t *rle_limit = rle + img_overl->num_rle; |
657 | int x_off = img_overl->x; | 1291 | int x_off = img_overl->x; |
658 | int y_off = img_overl->y; | 1292 | int y_off = img_overl->y; |
659 | int mask; | 1293 | int x_odd = x_off & 1; |
1294 | int ymask; | ||
1295 | int rle_this_bite; | ||
1296 | int rle_remainder; | ||
1297 | int rlelen; | ||
660 | int x, y; | 1298 | int x, y; |
661 | int l; | 1299 | int l = 0; |
662 | int clip_right; | 1300 | int clip_right; |
663 | uint32_t yuy2; | 1301 | |
1302 | union { | ||
1303 | uint32_t value; | ||
1304 | uint8_t b[4]; | ||
1305 | uint16_t h[2]; | ||
1306 | } yuy2; | ||
1307 | |||
1308 | uint8_t clr = 0; | ||
1309 | |||
1310 | int any_line_buffered = 0; | ||
1311 | int exact_blend_width = ((src_width <= (dst_width - x_off)) ? src_width : (dst_width - x_off)); | ||
1312 | int exact_blend_width_m2 = (x_odd + exact_blend_width + 1) & ~1; /* make it a (larger) multiple of 2 */ | ||
1313 | uint8_t *(*blend_yuy2_data)[ 3 ] = 0; | ||
664 | 1314 | ||
665 | uint8_t *dst_y = dst_img + 2 * (dst_width * y_off + x_off); | 1315 | uint8_t *dst_y = dst_img + dst_pitch * y_off + 2 * x_off; |
666 | uint8_t *dst; | 1316 | uint8_t *dst; |
667 | 1317 | ||
668 | my_clut = (clut_t*) img_overl->clip_color; | 1318 | my_clut = (clut_t*) img_overl->clip_color; |
669 | my_trans = img_overl->clip_trans; | 1319 | my_trans = img_overl->clip_trans; |
670 | 1320 | ||
671 | /* avoid wraping overlay if drawing to small image */ | 1321 | /* avoid wraping overlay if drawing to small image */ |
672 | if( (x_off + img_overl->clip_right) < dst_width ) | 1322 | if( (x_off + img_overl->clip_right) <= dst_width ) |
673 | clip_right = img_overl->clip_right; | 1323 | clip_right = img_overl->clip_right; |
674 | else | 1324 | else |
675 | clip_right = dst_width - 1 - x_off; | 1325 | clip_right = dst_width - x_off; |
676 | 1326 | ||
677 | /* avoid buffer overflow */ | 1327 | /* avoid buffer overflow */ |
678 | if( (src_height + y_off) >= dst_height ) | 1328 | if( (src_height + y_off) > dst_height ) |
679 | src_height = dst_height - 1 - y_off; | 1329 | src_height = dst_height - y_off; |
1330 | |||
1331 | if (src_height <= 0) | ||
1332 | return; | ||
1333 | |||
1334 | if (enable_exact_blending) { | ||
1335 | if (exact_blend_width <= 0) | ||
1336 | return; | ||
1337 | |||
1338 | blend_yuy2_data = blend_yuy2_grow_extra_data(extra_data, exact_blend_width_m2); | ||
1339 | if (!blend_yuy2_data) | ||
1340 | return; | ||
1341 | |||
1342 | /* make linebuffer transparent */ | ||
1343 | memset(&(*blend_yuy2_data)[ 0 ][ 0 ], 0, exact_blend_width_m2); | ||
1344 | } | ||
680 | 1345 | ||
1346 | rlelen=rle_remainder=0; | ||
681 | for (y = 0; y < src_height; y++) { | 1347 | for (y = 0; y < src_height; y++) { |
682 | mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y); | 1348 | if (rle >= rle_limit) |
1349 | break; | ||
1350 | |||
1351 | ymask = ((y < img_overl->clip_top) || (y >= img_overl->clip_bottom)); | ||
683 | 1352 | ||
684 | dst = dst_y; | 1353 | dst = dst_y; |
685 | for (x = 0; x < src_width;) { | 1354 | for (x = 0; x < src_width;) { |
686 | uint8_t clr; | ||
687 | uint16_t o; | 1355 | uint16_t o; |
688 | int rlelen; | ||
689 | 1356 | ||
690 | clr = rle->color; | 1357 | if (rle >= rle_limit) |
691 | o = my_trans[clr]; | 1358 | break; |
692 | rlelen = rle->len; | 1359 | |
693 | 1360 | if ((rlelen < 0) || (rle_remainder < 0)) { | |
694 | if (o && mask) { | 1361 | #ifdef LOG_BLEND_YUV |
695 | /* threat cases where clipping border is inside rle->len pixels */ | 1362 | printf("alphablend: major bug in blend_yuv < 0\n"); |
696 | if ( img_overl->clip_left > x ) { | 1363 | #endif |
697 | if( img_overl->clip_left < x + rlelen ) { | 1364 | } |
698 | rlelen -= img_overl->clip_left - x; | 1365 | if (rlelen == 0) { |
699 | x += img_overl->clip_left - x; | 1366 | rle_remainder = rlelen = rle->len; |
1367 | clr = rle->color; | ||
1368 | rle++; | ||
1369 | } | ||
1370 | if (rle_remainder == 0) { | ||
1371 | rle_remainder = rlelen; | ||
1372 | } | ||
1373 | if ((rle_remainder + x) > src_width) { | ||
1374 | /* Do something for long rlelengths */ | ||
1375 | rle_remainder = src_width - x; | ||
1376 | } | ||
1377 | #ifdef LOG_BLEND_YUV | ||
1378 | printf("2:rle_len=%d, remainder=%d, x=%d\n",rlelen, rle_remainder, x); | ||
1379 | #endif | ||
1380 | |||
1381 | if (ymask == 0) { | ||
1382 | if (x < img_overl->clip_left) { | ||
1383 | /* Starts outside clip area */ | ||
1384 | if ((x + rle_remainder) > img_overl->clip_left ) { | ||
1385 | #ifdef LOG_BLEND_YUV | ||
1386 | printf("Outside clip left %d, ending inside\n", img_overl->clip_left); | ||
1387 | #endif | ||
1388 | /* Cutting needed, starts outside, ends inside */ | ||
1389 | rle_this_bite = (img_overl->clip_left - x); | ||
1390 | rle_remainder -= rle_this_bite; | ||
1391 | rlelen -= rle_this_bite; | ||
1392 | my_clut = (clut_t*) img_overl->color; | ||
1393 | my_trans = img_overl->trans; | ||
700 | } else { | 1394 | } else { |
701 | o = 0; | 1395 | #ifdef LOG_BLEND_YUV |
1396 | printf("Outside clip left %d, ending outside\n", img_overl->clip_left); | ||
1397 | #endif | ||
1398 | /* no cutting needed, starts outside, ends outside */ | ||
1399 | rle_this_bite = rle_remainder; | ||
1400 | rle_remainder = 0; | ||
1401 | rlelen -= rle_this_bite; | ||
1402 | my_clut = (clut_t*) img_overl->color; | ||
1403 | my_trans = img_overl->trans; | ||
702 | } | 1404 | } |
703 | } else if( clip_right < x + rlelen ) { | 1405 | } else if (x < clip_right) { |
704 | if( clip_right > x ) { | 1406 | /* Starts inside clip area */ |
705 | /* fixme: case not implemented */ | 1407 | if ((x + rle_remainder) > clip_right ) { |
706 | o = 0; | 1408 | #ifdef LOG_BLEND_YUV |
1409 | printf("Inside clip right %d, ending outside\n", clip_right); | ||
1410 | #endif | ||
1411 | /* Cutting needed, starts inside, ends outside */ | ||
1412 | rle_this_bite = (clip_right - x); | ||
1413 | rle_remainder -= rle_this_bite; | ||
1414 | rlelen -= rle_this_bite; | ||
1415 | my_clut = (clut_t*) img_overl->clip_color; | ||
1416 | my_trans = img_overl->clip_trans; | ||
707 | } else { | 1417 | } else { |
708 | o = 0; | 1418 | #ifdef LOG_BLEND_YUV |
1419 | printf("Inside clip right %d, ending inside\n", clip_right); | ||
1420 | #endif | ||
1421 | /* no cutting needed, starts inside, ends inside */ | ||
1422 | rle_this_bite = rle_remainder; | ||
1423 | rle_remainder = 0; | ||
1424 | rlelen -= rle_this_bite; | ||
1425 | my_clut = (clut_t*) img_overl->clip_color; | ||
1426 | my_trans = img_overl->clip_trans; | ||
709 | } | 1427 | } |
710 | } | 1428 | } else if (x >= clip_right) { |
1429 | /* Starts outside clip area, ends outsite clip area */ | ||
1430 | if ((x + rle_remainder ) > src_width ) { | ||
1431 | #ifdef LOG_BLEND_YUV | ||
1432 | printf("Outside clip right %d, ending eol\n", clip_right); | ||
1433 | #endif | ||
1434 | /* Cutting needed, starts outside, ends at right edge */ | ||
1435 | /* It should never reach here due to the earlier test of src_width */ | ||
1436 | rle_this_bite = (src_width - x ); | ||
1437 | rle_remainder -= rle_this_bite; | ||
1438 | rlelen -= rle_this_bite; | ||
1439 | my_clut = (clut_t*) img_overl->color; | ||
1440 | my_trans = img_overl->trans; | ||
1441 | } else { | ||
1442 | /* no cutting needed, starts outside, ends outside */ | ||
1443 | #ifdef LOG_BLEND_YUV | ||
1444 | printf("Outside clip right %d, ending outside\n", clip_right); | ||
1445 | #endif | ||
1446 | rle_this_bite = rle_remainder; | ||
1447 | rle_remainder = 0; | ||
1448 | rlelen -= rle_this_bite; | ||
1449 | my_clut = (clut_t*) img_overl->color; | ||
1450 | my_trans = img_overl->trans; | ||
1451 | } | ||
1452 | } | ||
1453 | } else { | ||
1454 | /* Outside clip are due to y */ | ||
1455 | /* no cutting needed, starts outside, ends outside */ | ||
1456 | rle_this_bite = rle_remainder; | ||
1457 | rle_remainder = 0; | ||
1458 | rlelen -= rle_this_bite; | ||
1459 | my_clut = (clut_t*) img_overl->color; | ||
1460 | my_trans = img_overl->trans; | ||
711 | } | 1461 | } |
712 | 1462 | o = my_trans[clr]; | |
1463 | |||
1464 | if (x < (dst_width - x_off)) { | ||
1465 | /* clip against right edge of destination area */ | ||
1466 | if ((x + rle_this_bite) > (dst_width - x_off)) { | ||
1467 | int toClip = (x + rle_this_bite) - (dst_width - x_off); | ||
1468 | |||
1469 | rle_this_bite -= toClip; | ||
1470 | rle_remainder += toClip; | ||
1471 | rlelen += toClip; | ||
1472 | } | ||
1473 | |||
1474 | if (enable_exact_blending) { | ||
1475 | /* remember opacity of current line */ | ||
1476 | memset(&(*blend_yuy2_data)[ 0 ][ x + x_odd ], o, rle_this_bite); | ||
1477 | any_line_buffered = 1; | ||
1478 | } | ||
1479 | |||
1480 | if (o) { | ||
1481 | if (!enable_exact_blending) { | ||
1482 | l = rle_this_bite>>1; | ||
1483 | if( !((x_odd+x) & 1) ) { | ||
1484 | yuy2.b[0] = my_clut[clr].y; | ||
1485 | yuy2.b[1] = my_clut[clr].cb; | ||
1486 | yuy2.b[2] = my_clut[clr].y; | ||
1487 | yuy2.b[3] = my_clut[clr].cr; | ||
1488 | } else { | ||
1489 | yuy2.b[0] = my_clut[clr].y; | ||
1490 | yuy2.b[1] = my_clut[clr].cr; | ||
1491 | yuy2.b[2] = my_clut[clr].y; | ||
1492 | yuy2.b[3] = my_clut[clr].cb; | ||
1493 | } | ||
1494 | } | ||
1495 | if (o >= 15) { | ||
1496 | if (!enable_exact_blending) { | ||
1497 | while(l--) { | ||
1498 | *(uint16_t *)dst = yuy2.h[0]; | ||
1499 | dst += 2; | ||
1500 | *(uint16_t *)dst = yuy2.h[1]; | ||
1501 | dst += 2; | ||
1502 | } | ||
1503 | if(rle_this_bite & 1) { | ||
1504 | *(uint16_t *)dst = yuy2.h[0]; | ||
1505 | dst += 2; | ||
1506 | } | ||
1507 | } else { | ||
1508 | l = rle_this_bite; | ||
1509 | while (l--) { | ||
1510 | *dst = my_clut[clr].y; | ||
1511 | dst += 2; | ||
1512 | } | ||
1513 | } | ||
1514 | } else { | ||
1515 | if (!enable_exact_blending) { | ||
1516 | if( l ) { | ||
1517 | mem_blend32(dst, &yuy2.b[0], o, l); | ||
1518 | dst += 4*l; | ||
1519 | } | ||
1520 | |||
1521 | if(rle_this_bite & 1) { | ||
1522 | *dst = BLEND_BYTE(*dst, yuy2.b[0], o); | ||
1523 | dst++; | ||
1524 | *dst = BLEND_BYTE(*dst, yuy2.b[1], o); | ||
1525 | dst++; | ||
1526 | } | ||
1527 | } else { | ||
1528 | l = rle_this_bite; | ||
1529 | while (l--) { | ||
1530 | *dst = BLEND_BYTE(*dst, my_clut[clr].y, o); | ||
1531 | dst += 2; | ||
1532 | } | ||
1533 | } | ||
1534 | } | ||
713 | 1535 | ||
714 | if (o && mask) { | 1536 | if (enable_exact_blending) { |
715 | l = rlelen>>1; | 1537 | /* remember chroma of current line */ |
716 | if( !(x & 1) ) { | 1538 | memset(&(*blend_yuy2_data)[ 1 ][ x + x_odd ], my_clut[ clr ].cr, rle_this_bite); |
717 | yuy2 = my_clut[clr].y + (my_clut[clr].cb << 8) + | 1539 | memset(&(*blend_yuy2_data)[ 2 ][ x + x_odd ], my_clut[ clr ].cb, rle_this_bite); |
718 | (my_clut[clr].y << 16) + (my_clut[clr].cr << 24); | 1540 | } |
719 | } else { | 1541 | } else { |
720 | yuy2 = my_clut[clr].y + (my_clut[clr].cr << 8) + | 1542 | dst += rle_this_bite*2; |
721 | (my_clut[clr].y << 16) + (my_clut[clr].cb << 24); | ||
722 | } | 1543 | } |
1544 | } | ||
1545 | |||
1546 | x += rle_this_bite; | ||
1547 | } | ||
1548 | |||
1549 | if (enable_exact_blending) { | ||
1550 | /* blend buffered line */ | ||
1551 | if (any_line_buffered) { | ||
1552 | blend_yuy2_exact(dst_y - x_odd * 2 + 3, dst_y - x_odd * 2 + 1, exact_blend_width, x_odd, blend_yuy2_data); | ||
723 | 1553 | ||
724 | if (o >= 15) { | 1554 | any_line_buffered = 0; |
725 | while(l--) { | 1555 | } |
726 | *((uint32_t *)dst)++ = yuy2; | 1556 | } |
1557 | |||
1558 | dst_y += dst_pitch; | ||
1559 | } | ||
1560 | } | ||
1561 | |||
1562 | void clear_xx44_palette(xx44_palette_t *p) | ||
1563 | { | ||
1564 | register int i; | ||
1565 | register uint32_t *cluts = p->cluts; | ||
1566 | register int *ids = p->lookup_cache; | ||
1567 | |||
1568 | i= p->size; | ||
1569 | while(i--) | ||
1570 | *cluts++ = 0; | ||
1571 | i = 2*OVL_PALETTE_SIZE; | ||
1572 | while(i--) | ||
1573 | *ids++ = -1; | ||
1574 | p->max_used=1; | ||
1575 | } | ||
1576 | |||
1577 | void init_xx44_palette(xx44_palette_t *p, unsigned num_entries) | ||
1578 | { | ||
1579 | p->size = (num_entries > XX44_PALETTE_SIZE) ? XX44_PALETTE_SIZE : num_entries; | ||
1580 | } | ||
1581 | |||
1582 | void dispose_xx44_palette(xx44_palette_t *p) | ||
1583 | { | ||
1584 | } | ||
1585 | |||
1586 | static void colorToPalette(const uint32_t *icolor, unsigned char *palette_p, | ||
1587 | unsigned num_xvmc_components, char *xvmc_components) | ||
1588 | { | ||
1589 | const clut_t *color = (const clut_t *) icolor; | ||
1590 | int i; | ||
1591 | for (i=0; i<num_xvmc_components; ++i) { | ||
1592 | switch(xvmc_components[i]) { | ||
1593 | case 'V': *palette_p = color->cr; break; | ||
1594 | case 'U': *palette_p = color->cb; break; | ||
1595 | case 'Y': | ||
1596 | default: *palette_p = color->y; break; | ||
1597 | } | ||
1598 | *palette_p++; | ||
1599 | } | ||
1600 | } | ||
1601 | |||
1602 | |||
1603 | void xx44_to_xvmc_palette(const xx44_palette_t *p,unsigned char *xvmc_palette, | ||
1604 | unsigned first_xx44_entry, unsigned num_xx44_entries, | ||
1605 | unsigned num_xvmc_components, char *xvmc_components) | ||
1606 | { | ||
1607 | register int i; | ||
1608 | register const uint32_t *cluts = p->cluts + first_xx44_entry; | ||
1609 | |||
1610 | for (i=0; i<num_xx44_entries; ++i) { | ||
1611 | if ((cluts - p->cluts) < p->size) { | ||
1612 | colorToPalette(cluts++, xvmc_palette, num_xvmc_components, xvmc_components); | ||
1613 | xvmc_palette += num_xvmc_components; | ||
1614 | } | ||
1615 | } | ||
1616 | } | ||
1617 | |||
1618 | static int xx44_paletteIndex(xx44_palette_t *p, int color, uint32_t clut) | ||
1619 | { | ||
1620 | |||
1621 | register int i; | ||
1622 | register uint32_t *cluts = p->cluts; | ||
1623 | register int tmp; | ||
1624 | |||
1625 | if ((tmp = p->lookup_cache[color]) >= 0) | ||
1626 | if (cluts[tmp] == clut) return tmp; | ||
1627 | |||
1628 | for (i=0; i<p->max_used; ++i) { | ||
1629 | if (*cluts++ == clut) return p->lookup_cache[color] = i; | ||
1630 | } | ||
1631 | |||
1632 | if (p->max_used == p->size -1) { | ||
1633 | printf("video_out: Warning! Out of xx44 palette colors!\n"); | ||
1634 | return 1; | ||
1635 | } | ||
1636 | p->cluts[p->max_used] = clut; | ||
1637 | return p->lookup_cache[color] = p->max_used++; | ||
1638 | } | ||
1639 | |||
1640 | static void memblend_xx44(uint8_t *mem,uint8_t val, register size_t size, uint8_t mask) | ||
1641 | { | ||
1642 | register uint8_t masked_val = val & mask; | ||
1643 | |||
1644 | while(size--) { | ||
1645 | if ((*mem & mask) <= masked_val ) *mem = val; | ||
1646 | mem++; | ||
1647 | } | ||
1648 | } | ||
1649 | |||
1650 | void blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl, | ||
1651 | int dst_width, int dst_height, int dst_pitch, | ||
1652 | alphablend_t *extra_data, | ||
1653 | xx44_palette_t *palette,int ia44) | ||
1654 | { | ||
1655 | int src_width = img_overl->width; | ||
1656 | int src_height = img_overl->height; | ||
1657 | rle_elem_t *rle = img_overl->rle; | ||
1658 | rle_elem_t *rle_limit = rle + img_overl->num_rle; | ||
1659 | int mask; | ||
1660 | int x_off = img_overl->x; | ||
1661 | int y_off = img_overl->y; | ||
1662 | int x, y; | ||
1663 | uint8_t norm_pixel,clip_pixel; | ||
1664 | uint8_t *dst_y; | ||
1665 | uint8_t *dst; | ||
1666 | uint8_t alphamask = (ia44) ? 0x0F : 0xF0; | ||
1667 | int clip_right; | ||
1668 | |||
1669 | if (!img_overl) | ||
1670 | return; | ||
1671 | |||
1672 | dst_y = dst_img + dst_pitch*y_off + x_off; | ||
1673 | |||
1674 | if( (x_off + img_overl->width) <= dst_width ) | ||
1675 | clip_right = img_overl->width; | ||
1676 | else | ||
1677 | clip_right = dst_width - x_off; | ||
1678 | |||
1679 | if ((src_height + y_off) > dst_height) | ||
1680 | src_height = dst_height - y_off; | ||
1681 | |||
1682 | for (y = 0; y < src_height; y++) { | ||
1683 | |||
1684 | mask = !(y < img_overl->clip_top || y >= img_overl->clip_bottom); | ||
1685 | dst = dst_y; | ||
1686 | |||
1687 | for (x = 0; x < src_width;) { | ||
1688 | int len = (x + rle->len > clip_right) ? clip_right - x : rle->len; | ||
1689 | |||
1690 | if (len > 0) { | ||
1691 | norm_pixel = (uint8_t)((xx44_paletteIndex(palette,rle->color, | ||
1692 | img_overl->color[rle->color]) << 4) | | ||
1693 | (img_overl->trans[rle->color] & 0x0F)); | ||
1694 | clip_pixel = (uint8_t)((xx44_paletteIndex(palette,rle->color+OVL_PALETTE_SIZE, | ||
1695 | img_overl->clip_color[rle->color]) << 4) | | ||
1696 | (img_overl->clip_trans[rle->color] & 0x0F)); | ||
1697 | if (!ia44) { | ||
1698 | norm_pixel = ((norm_pixel & 0x0F) << 4) | ((norm_pixel & 0xF0) >> 4); | ||
1699 | clip_pixel = ((clip_pixel & 0x0F) << 4) | ((clip_pixel & 0xF0) >> 4); | ||
1700 | } | ||
1701 | if (mask) { | ||
1702 | if (x < img_overl->clip_left) { | ||
1703 | if (x + len <= img_overl->clip_left) { | ||
1704 | memblend_xx44(dst,norm_pixel,len, alphamask); | ||
1705 | dst += len; | ||
1706 | } else { | ||
1707 | memblend_xx44(dst,norm_pixel,img_overl->clip_left -x, alphamask); | ||
1708 | dst += img_overl->clip_left - x; | ||
1709 | len -= img_overl->clip_left - x; | ||
1710 | if (len <= img_overl->clip_right - img_overl->clip_left) { | ||
1711 | memblend_xx44(dst,clip_pixel,len, alphamask); | ||
1712 | dst += len; | ||
1713 | } else { | ||
1714 | memblend_xx44(dst,clip_pixel,img_overl->clip_right - img_overl->clip_left, | ||
1715 | alphamask); | ||
1716 | dst += img_overl->clip_right - img_overl->clip_left; | ||
1717 | len -= img_overl->clip_right - img_overl->clip_left; | ||
1718 | memblend_xx44(dst,norm_pixel,len, alphamask); | ||
1719 | dst += len; | ||
1720 | } | ||
1721 | } | ||
1722 | } else if (x < img_overl->clip_right) { | ||
1723 | if (len <= img_overl->clip_right - x) { | ||
1724 | memblend_xx44(dst,clip_pixel,len, alphamask); | ||
1725 | dst += len; | ||
1726 | } else { | ||
1727 | memblend_xx44(dst,clip_pixel,img_overl->clip_right - x,alphamask); | ||
1728 | dst += img_overl->clip_right - x; | ||
1729 | len -= img_overl->clip_right - x; | ||
1730 | memblend_xx44(dst,norm_pixel,len, alphamask); | ||
1731 | dst += len; | ||
1732 | } | ||
1733 | } else { | ||
1734 | memblend_xx44(dst,norm_pixel,len, alphamask); | ||
1735 | dst += len; | ||
727 | } | 1736 | } |
728 | if(rlelen & 1) | ||
729 | *((uint16_t *)dst)++ = yuy2 & 0xffff; | ||
730 | } else { | 1737 | } else { |
731 | if( l ) { | 1738 | memblend_xx44(dst,norm_pixel,len, alphamask); |
732 | mem_blend32(dst, (uint8_t *)&yuy2, o, l); | 1739 | dst += len; |
733 | dst += 4*l; | ||
734 | } | ||
735 | |||
736 | if(rlelen & 1) { | ||
737 | *dst = BLEND_BYTE(*dst, *((uint8_t *)&yuy2), o); | ||
738 | dst++; | ||
739 | *dst = BLEND_BYTE(*dst, *((uint8_t *)&yuy2+1), o); | ||
740 | dst++; | ||
741 | } | ||
742 | } | 1740 | } |
743 | } else { | ||
744 | dst += rlelen*2; | ||
745 | } | 1741 | } |
746 | 1742 | x += rle->len; | |
747 | x += rlelen; | ||
748 | rle++; | 1743 | rle++; |
749 | if (rle >= rle_limit) break; | 1744 | if (rle >= rle_limit) break; |
750 | } | 1745 | } |
751 | if (rle >= rle_limit) break; | 1746 | if (rle >= rle_limit) break; |
1747 | dst_y += dst_pitch; | ||
1748 | } | ||
1749 | } | ||
1750 | |||
1751 | static void alphablend_disable_exact_osd_alpha_blending_changed(void *user_data, xine_cfg_entry_t *entry) | ||
1752 | { | ||
1753 | alphablend_t *extra_data = (alphablend_t *)user_data; | ||
1754 | |||
1755 | extra_data->disable_exact_blending = entry->num_value; | ||
1756 | } | ||
752 | 1757 | ||
753 | dst_y += dst_width*2; | 1758 | void _x_alphablend_init(alphablend_t *extra_data, xine_t *xine) |
1759 | { | ||
1760 | config_values_t *config = xine->config; | ||
1761 | |||
1762 | extra_data->buffer = 0; | ||
1763 | extra_data->buffer_size = 0; | ||
1764 | |||
1765 | extra_data->disable_exact_blending = | ||
1766 | config->register_bool(config, "video.output.disable_exact_alphablend", 0, | ||
1767 | _("disable exact alpha blending of overlays"), | ||
1768 | _("If you experience a performance impact when an On Screen Display or other " | ||
1769 | "overlays like DVD subtitles are active, then you might want to enable this option.\n" | ||
1770 | "The result is that alpha blending of overlays is less accurate than before, " | ||
1771 | "but the CPU usage will be decreased as well."), | ||
1772 | 10, alphablend_disable_exact_osd_alpha_blending_changed, extra_data); | ||
1773 | } | ||
1774 | |||
1775 | void _x_alphablend_free(alphablend_t *extra_data) | ||
1776 | { | ||
1777 | if (extra_data->buffer) { | ||
1778 | free(extra_data->buffer); | ||
1779 | extra_data->buffer = NULL; | ||
754 | } | 1780 | } |
1781 | |||
1782 | extra_data->buffer_size = 0; | ||
755 | } | 1783 | } |
1784 | |||
diff --git a/noncore/multimedia/opieplayer2/alphablend.h b/noncore/multimedia/opieplayer2/alphablend.h index 7230f41..1edb5ba 100644 --- a/noncore/multimedia/opieplayer2/alphablend.h +++ b/noncore/multimedia/opieplayer2/alphablend.h | |||
@@ -26,32 +26,109 @@ | |||
26 | #define __ALPHABLEND_H__ | 26 | #define __ALPHABLEND_H__ |
27 | 27 | ||
28 | #include <xine/video_out.h> | 28 | #include <xine/video_out.h> |
29 | 29 | ||
30 | typedef struct { | ||
31 | void *buffer; | ||
32 | int buffer_size; | ||
33 | |||
34 | int disable_exact_blending; | ||
35 | } alphablend_t; | ||
36 | |||
37 | void _x_alphablend_init(alphablend_t *extra_data, xine_t *xine); | ||
38 | void _x_alphablend_free(alphablend_t *extra_data); | ||
39 | |||
40 | /* _MSC_VER port changes */ | ||
41 | #undef ATTRIBUTE_PACKED | ||
42 | #undef PRAGMA_PACK_BEGIN | ||
43 | #undef PRAGMA_PACK_END | ||
44 | |||
45 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined(__ICC) | ||
46 | #define ATTRIBUTE_PACKED __attribute__ ((packed)) | ||
47 | #define PRAGMA_PACK 0 | ||
48 | #endif | ||
49 | |||
50 | #if !defined(ATTRIBUTE_PACKED) | ||
51 | #define ATTRIBUTE_PACKED | ||
52 | #define PRAGMA_PACK 1 | ||
53 | #endif | ||
54 | |||
55 | #if PRAGMA_PACK | ||
56 | #pragma pack(8) | ||
57 | #endif | ||
58 | |||
30 | typedef struct { /* CLUT == Color LookUp Table */ | 59 | typedef struct { /* CLUT == Color LookUp Table */ |
31 | uint8_t cb : 8; | 60 | uint8_t cb : 8; |
32 | uint8_t cr : 8; | 61 | uint8_t cr : 8; |
33 | uint8_t y : 8; | 62 | uint8_t y : 8; |
34 | uint8_t foo : 8; | 63 | uint8_t foo : 8; |
35 | } __attribute__ ((packed)) clut_t; | 64 | } ATTRIBUTE_PACKED clut_t; |
65 | |||
66 | |||
67 | #if PRAGMA_PACK | ||
68 | #pragma pack() | ||
69 | #endif | ||
70 | |||
71 | #define XX44_PALETTE_SIZE 32 | ||
72 | |||
73 | typedef struct { | ||
74 | unsigned size; | ||
75 | unsigned max_used; | ||
76 | uint32_t cluts[XX44_PALETTE_SIZE]; | ||
77 | /* cache palette entries for both colors and clip_colors */ | ||
78 | int lookup_cache[OVL_PALETTE_SIZE*2]; | ||
79 | } xx44_palette_t; | ||
80 | |||
36 | 81 | ||
37 | void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, | 82 | void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, |
38 | int img_width, int img_height, | 83 | int img_width, int img_height, |
39 | int dst_width, int dst_height); | 84 | int dst_width, int dst_height, |
85 | alphablend_t *extra_data); | ||
40 | 86 | ||
41 | void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, | 87 | void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, |
42 | int img_width, int img_height, | 88 | int img_width, int img_height, |
43 | int dst_width, int dst_height); | 89 | int dst_width, int dst_height, |
90 | alphablend_t *extra_data); | ||
44 | 91 | ||
45 | void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, | 92 | void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, |
46 | int img_width, int img_height, | 93 | int img_width, int img_height, |
47 | int dst_width, int dst_height); | 94 | int dst_width, int dst_height, |
95 | alphablend_t *extra_data); | ||
48 | 96 | ||
49 | void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | 97 | void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, |
50 | int dst_width, int dst_height); | 98 | int dst_width, int dst_height, int dst_pitches[3], |
99 | alphablend_t *extra_data); | ||
51 | 100 | ||
52 | void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, | 101 | void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, |
53 | int dst_width, int dst_height); | 102 | int dst_width, int dst_height, int dst_pitch, |
103 | alphablend_t *extra_data); | ||
104 | |||
105 | /* | ||
106 | * This function isn't too smart about blending. We want to avoid creating new | ||
107 | * colors in the palette as a result from two non-zero colors needed to be | ||
108 | * blended. Instead we choose the color with the highest alpha value to be | ||
109 | * visible. Some parts of the code taken from the "VeXP" project. | ||
110 | */ | ||
111 | |||
112 | void blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl, | ||
113 | int dst_width, int dst_height, int dst_pitch, | ||
114 | alphablend_t *extra_data, | ||
115 | xx44_palette_t *palette,int ia44); | ||
116 | |||
117 | /* | ||
118 | * Functions to handle the xine-specific palette. | ||
119 | */ | ||
120 | |||
121 | void clear_xx44_palette(xx44_palette_t *p); | ||
122 | void init_xx44_palette(xx44_palette_t *p, unsigned num_entries); | ||
123 | void dispose_xx44_palette(xx44_palette_t *p); | ||
124 | |||
125 | /* | ||
126 | * Convert the xine-specific palette to something useful. | ||
127 | */ | ||
128 | |||
129 | void xx44_to_xvmc_palette(const xx44_palette_t *p,unsigned char *xvmc_palette, | ||
130 | unsigned first_xx44_entry, unsigned num_xx44_entries, | ||
131 | unsigned num_xvmc_components, char *xvmc_components); | ||
54 | 132 | ||
55 | void crop_overlay (vo_overlay_t * overlay); | ||
56 | 133 | ||
57 | #endif | 134 | #endif |
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 4ae8490..84d28ce 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -48,24 +48,19 @@ _;:, .> :=|. This program is free software; you can | |||
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 50 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
51 | int width, int height,int bytes ); | 51 | int width, int height,int bytes ); |
52 | typedef void (*vo_scale_cb) (void*, int, int, double, | ||
53 | int*, int*, int*, int*, double*, int*, int* ); | ||
54 | typedef void (*dest_size_cb) (void*, int, int, double, int*, int*, double*); | ||
55 | |||
52 | 56 | ||
53 | extern "C" { | 57 | extern "C" { |
54 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); | 58 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void *, vo_scale_cb, dest_size_cb ); |
55 | int null_is_showing_video( const xine_vo_driver_t* self ); | 59 | int null_is_showing_video( const xine_vo_driver_t* self ); |
56 | void null_set_show_video( const xine_vo_driver_t* self, int show ); | 60 | void null_set_show_video( const xine_vo_driver_t* self, int show ); |
57 | int null_is_fullscreen( const xine_vo_driver_t* self ); | ||
58 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); | ||
59 | int null_is_scaling( const xine_vo_driver_t* self ); | ||
60 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); | ||
61 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); | ||
62 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); | ||
63 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); | 61 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); |
64 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); | ||
65 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); | 62 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
66 | |||
67 | void null_preload_decoders( xine_stream_t *stream ); | ||
68 | } | 63 | } |
69 | 64 | ||
70 | using namespace XINE; | 65 | using namespace XINE; |
71 | 66 | ||
@@ -126,9 +121,12 @@ void Lib::initialize() | |||
126 | 121 | ||
127 | // allocate oss for sound | 122 | // allocate oss for sound |
128 | // and fb for framebuffer | 123 | // and fb for framebuffer |
129 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); | 124 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); |
130 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); | 125 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, |
126 | xine_display_frame, this, | ||
127 | xine_vo_scale_cb, | ||
128 | xine_dest_cb ); | ||
131 | 129 | ||
132 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 130 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
133 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); | 131 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); |
134 | 132 | ||
@@ -138,10 +136,8 @@ void Lib::initialize() | |||
138 | 136 | ||
139 | m_queue = xine_event_new_queue (m_stream); | 137 | m_queue = xine_event_new_queue (m_stream); |
140 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 138 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
141 | 139 | ||
142 | ::null_preload_decoders( m_stream ); | ||
143 | |||
144 | m_duringInitialization = false; | 140 | m_duringInitialization = false; |
145 | } | 141 | } |
146 | 142 | ||
147 | Lib::~Lib() { | 143 | Lib::~Lib() { |
@@ -164,12 +160,10 @@ Lib::~Lib() { | |||
164 | 160 | ||
165 | void Lib::resize ( const QSize &s ) { | 161 | void Lib::resize ( const QSize &s ) { |
166 | assert( m_initialized || m_duringInitialization ); | 162 | assert( m_initialized || m_duringInitialization ); |
167 | 163 | ||
168 | if ( s. width ( ) && s. height ( ) ) { | 164 | if ( s. width ( ) && s. height ( ) ) |
169 | ::null_set_gui_width( m_videoOutput, s. width() ); | 165 | m_videoSize = s; |
170 | ::null_set_gui_height( m_videoOutput, s. height() ); | ||
171 | } | ||
172 | } | 166 | } |
173 | 167 | ||
174 | int Lib::majorVersion() { | 168 | int Lib::majorVersion() { |
175 | int major, minor, sub; | 169 | int major, minor, sub; |
@@ -421,33 +415,35 @@ bool Lib::isShowingVideo() const { | |||
421 | 415 | ||
422 | void Lib::showVideoFullScreen( bool fullScreen ) { | 416 | void Lib::showVideoFullScreen( bool fullScreen ) { |
423 | assert( m_initialized ); | 417 | assert( m_initialized ); |
424 | 418 | ||
425 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 419 | #warning use xine |
426 | } | 420 | } |
427 | 421 | ||
428 | bool Lib::isVideoFullScreen() const { | 422 | bool Lib::isVideoFullScreen() const { |
429 | assert( m_initialized ); | 423 | assert( m_initialized ); |
430 | 424 | ||
431 | return ::null_is_fullscreen( m_videoOutput ); | 425 | #warning use xine |
426 | return false; | ||
432 | } | 427 | } |
433 | 428 | ||
434 | void Lib::setScaling( bool scale ) { | 429 | void Lib::setScaling( bool scale ) { |
435 | assert( m_initialized ); | 430 | assert( m_initialized ); |
436 | 431 | ||
437 | ::null_set_scaling( m_videoOutput, scale ); | 432 | xine_set_param( m_stream, XINE_PARAM_VO_ASPECT_RATIO, |
433 | scale ? XINE_VO_ASPECT_AUTO : XINE_VO_ASPECT_SQUARE ); | ||
438 | } | 434 | } |
439 | 435 | ||
440 | void Lib::setGamma( int value ) { | 436 | void Lib::setGamma( int value ) { |
441 | assert( m_initialized ); | 437 | assert( m_initialized ); |
442 | 438 | xine_set_param( m_stream, XINE_PARAM_VO_BRIGHTNESS, value ); | |
443 | ::null_set_videoGamma( m_videoOutput, value ); | ||
444 | } | 439 | } |
445 | 440 | ||
446 | bool Lib::isScaling() const { | 441 | bool Lib::isScaling() const { |
447 | assert( m_initialized ); | 442 | assert( m_initialized ); |
448 | 443 | ||
449 | return ::null_is_scaling( m_videoOutput ); | 444 | int aratio = xine_get_param( m_stream, XINE_PARAM_VO_ASPECT_RATIO ); |
445 | return aratio == XINE_VO_ASPECT_AUTO; | ||
450 | } | 446 | } |
451 | 447 | ||
452 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { | 448 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { |
453 | ( (Lib*)user_data)->handleXineEvent( t ); | 449 | ( (Lib*)user_data)->handleXineEvent( t ); |
@@ -457,15 +453,39 @@ void Lib::xine_display_frame( void* user_data, uint8_t *frame, | |||
457 | int width, int height, int bytes ) { | 453 | int width, int height, int bytes ) { |
458 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 454 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
459 | } | 455 | } |
460 | 456 | ||
457 | void Lib::xine_vo_scale_cb( void *user_data, int video_with, int video_height, | ||
458 | double video_pixel_aspect, | ||
459 | int *dest_x, int *dest_y, int *dest_width, | ||
460 | int *dest_height, double *dest_pixel_aspect, | ||
461 | int *win_x, int *win_y ) { | ||
462 | QSize size = ((Lib*)user_data)->m_videoSize; | ||
463 | if (!size.isValid()) | ||
464 | return; | ||
465 | |||
466 | *dest_x = 0; | ||
467 | *dest_y = 0; | ||
468 | *dest_width = size.width(); | ||
469 | *dest_height = size.height(); | ||
470 | *win_x = 0; | ||
471 | *win_y = 0; | ||
472 | } | ||
473 | |||
474 | void Lib::xine_dest_cb( void* user_data, int, int, double, | ||
475 | int *dest_width, int* dest_height, double* ) { | ||
476 | QSize size = ((Lib*)user_data)->m_videoSize; | ||
477 | if ( !size.isValid() ) | ||
478 | return; | ||
479 | |||
480 | *dest_width = size.width(); | ||
481 | *dest_height = size.height(); | ||
482 | } | ||
483 | |||
461 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 484 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
462 | assert( m_initialized ); | 485 | assert( m_initialized ); |
463 | 486 | ||
464 | if ( !m_video ) { | 487 | if ( !m_video ) |
465 | return; | 488 | return; |
466 | } | ||
467 | |||
468 | // assert( m_wid ); | ||
469 | 489 | ||
470 | if (m_wid) m_wid-> setVideoFrame ( frame, width, height, bytes ); | 490 | if (m_wid) m_wid-> setVideoFrame ( frame, width, height, bytes ); |
471 | } | 491 | } |
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index 2607193..a6ac033 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h | |||
@@ -186,29 +186,33 @@ namespace XINE { | |||
186 | 186 | ||
187 | virtual void run(); | 187 | virtual void run(); |
188 | 188 | ||
189 | private: | 189 | private: |
190 | void initialize(); | 190 | void initialize(); |
191 | 191 | ||
192 | int m_bytes_per_pixel; | 192 | int m_bytes_per_pixel; |
193 | bool m_initialized:1; | 193 | bool m_initialized:1; |
194 | bool m_duringInitialization:1; | 194 | bool m_duringInitialization:1; |
195 | bool m_video:1; | 195 | bool m_video:1; |
196 | XineVideoWidget *m_wid; | 196 | XineVideoWidget *m_wid; |
197 | xine_t *m_xine; | 197 | QSize m_videoSize; |
198 | xine_stream_t *m_stream; | 198 | xine_t *m_xine; |
199 | xine_cfg_entry_t *m_config; | 199 | xine_stream_t *m_stream; |
200 | xine_vo_driver_t *m_videoOutput; | 200 | xine_cfg_entry_t *m_config; |
201 | xine_ao_driver_t* m_audioOutput; | 201 | xine_vo_driver_t *m_videoOutput; |
202 | xine_event_queue_t *m_queue; | 202 | xine_ao_driver_t* m_audioOutput; |
203 | 203 | xine_event_queue_t *m_queue; | |
204 | void handleXineEvent( const xine_event_t* t ); | 204 | |
205 | void handleXineEvent( int type, int data, const char* name ); | 205 | void handleXineEvent( const xine_event_t* t ); |
206 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); | 206 | void handleXineEvent( int type, int data, const char* name ); |
207 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); | ||
207 | // C -> C++ bridge for the event system | 208 | // C -> C++ bridge for the event system |
208 | static void xine_event_handler( void* user_data, const xine_event_t* t); | 209 | static void xine_event_handler( void* user_data, const xine_event_t* t); |
209 | static void xine_display_frame( void* user_data, uint8_t* frame , | 210 | static void xine_display_frame( void* user_data, uint8_t* frame , |
210 | int width, int height, int bytes ); | 211 | int width, int height, int bytes ); |
212 | static void xine_vo_scale_cb(void *, int, int, double, | ||
213 | int*,int*,int*,int*,double*,int*,int*); | ||
214 | static void xine_dest_cb(void*,int,int,double,int*,int*,double*); | ||
211 | }; | 215 | }; |
212 | }; | 216 | }; |
213 | 217 | ||
214 | 218 | ||
diff --git a/noncore/multimedia/opieplayer2/mainTest.cpp b/noncore/multimedia/opieplayer2/mainTest.cpp deleted file mode 100644 index e374c89..0000000 --- a/noncore/multimedia/opieplayer2/mainTest.cpp +++ b/dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | |||
2 | #include <stdlib.h> | ||
3 | #include <stdio.h> | ||
4 | #include <unistd.h> | ||
5 | |||
6 | #include "lib.h" | ||
7 | |||
8 | int main( int argc, char *argv[] ) { | ||
9 | printf("FixME\n"); | ||
10 | //return 0; | ||
11 | XINE::Lib lib; | ||
12 | QString str = QString::fromLatin1( argv[1] ); | ||
13 | lib.play( str ); | ||
14 | for (;;) sleep( 60 ); | ||
15 | return 0; | ||
16 | } | ||
diff --git a/noncore/multimedia/opieplayer2/nullvideo.c b/noncore/multimedia/opieplayer2/nullvideo.c index 6769a37..99fa329 100644 --- a/noncore/multimedia/opieplayer2/nullvideo.c +++ b/noncore/multimedia/opieplayer2/nullvideo.c | |||
@@ -1,9 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 LJP <> | ||
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 5 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | Copyright (c) 2002-2003 Miguel Freitas of xine | 6 | Copyright (c) 2002-2003 Miguel Freitas of xine |
8 | =. | 7 | =. |
9 | .=l. | 8 | .=l. |
@@ -39,9 +38,8 @@ | |||
39 | 38 | ||
40 | #include <xine.h> | 39 | #include <xine.h> |
41 | #include <xine/video_out.h> | 40 | #include <xine/video_out.h> |
42 | #include <xine/xine_internal.h> | 41 | #include <xine/xine_internal.h> |
43 | //#include <xine/xineutils.h> | ||
44 | #include <xine/vo_scale.h> | 42 | #include <xine/vo_scale.h> |
45 | #include <xine/buffer.h> | 43 | #include <xine/buffer.h> |
46 | 44 | ||
47 | #include <pthread.h> | 45 | #include <pthread.h> |
@@ -50,42 +48,45 @@ | |||
50 | 48 | ||
51 | #define printf(x,...) | 49 | #define printf(x,...) |
52 | 50 | ||
53 | /* | 51 | /* |
54 | #define LOG | 52 | * #define LOG |
55 | */ | 53 | */ |
56 | 54 | ||
57 | /* the caller for our event draw handler */ | 55 | /* the caller for our event draw handler */ |
58 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 56 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
59 | int width, int height,int bytes ); | 57 | int width, int height,int bytes ); |
58 | typedef void (*vo_scale_cb) (void*, int, int, double, | ||
59 | int*, int*, int*, double*, int*, int* ); | ||
60 | typedef void (*dest_size_cb) (void*, int, int, double, int*, int*, double*); | ||
61 | |||
60 | 62 | ||
61 | typedef struct null_driver_s null_driver_t; | 63 | typedef struct null_driver_s null_driver_t; |
62 | 64 | ||
63 | struct null_driver_s { | 65 | struct null_driver_s { |
64 | vo_driver_t vo_driver; | 66 | vo_driver_t vo_driver; |
65 | 67 | ||
66 | uint32_t m_capabilities; | ||
67 | int m_show_video; | 68 | int m_show_video; |
68 | int m_video_fullscreen; | 69 | int m_video_fullscreen; |
69 | int m_is_scaling; | ||
70 | 70 | ||
71 | int depth, bpp, bytes_per_pixel; | 71 | int depth, bpp, bytes_per_pixel; |
72 | int yuv2rgb_mode; | 72 | int yuv2rgb_mode; |
73 | int yuv2rgb_swap; | 73 | int yuv2rgb_swap; |
74 | int yuv2rgb_gamma; | 74 | int yuv2rgb_brightness; |
75 | uint8_t *yuv2rgb_cmap; | 75 | uint8_t *yuv2rgb_cmap; |
76 | yuv2rgb_factory_t *yuv2rgb_factory; | 76 | yuv2rgb_factory_t *yuv2rgb_factory; |
77 | 77 | ||
78 | vo_overlay_t *overlay; | 78 | vo_overlay_t *overlay; |
79 | vo_scale_t sc; | 79 | vo_scale_t sc; |
80 | |||
81 | int gui_width; | ||
82 | int gui_height; | ||
83 | int gui_changed; | ||
84 | 80 | ||
85 | double display_ratio; | 81 | /* |
86 | void* caller; | 82 | * DISPLAY to widget... |
83 | */ | ||
87 | display_xine_frame_t frameDis; | 84 | display_xine_frame_t frameDis; |
85 | void *userData; | ||
86 | |||
87 | xine_t *xine; | ||
88 | alphablend_t alphablend_extra_data; | ||
88 | }; | 89 | }; |
89 | 90 | ||
90 | typedef struct opie_frame_s opie_frame_t; | 91 | typedef struct opie_frame_s opie_frame_t; |
91 | struct opie_frame_s { | 92 | struct opie_frame_s { |
@@ -104,24 +105,34 @@ struct opie_frame_s { | |||
104 | yuv2rgb_t *yuv2rgb; | 105 | yuv2rgb_t *yuv2rgb; |
105 | uint8_t *rgb_dst; | 106 | uint8_t *rgb_dst; |
106 | int yuv_stride; | 107 | int yuv_stride; |
107 | int stripe_height, stripe_inc; | 108 | int stripe_height, stripe_inc; |
108 | 109 | ||
109 | null_driver_t *output; | 110 | null_driver_t *output; |
110 | }; | 111 | }; |
111 | 112 | ||
112 | static uint32_t null_get_capabilities( vo_driver_t *self ){ | 113 | static uint32_t null_get_capabilities( vo_driver_t *self ){ |
113 | null_driver_t* this = (null_driver_t*)self; | 114 | self = self; |
114 | return this->m_capabilities; | 115 | return VO_CAP_YUY2 | VO_CAP_YV12; |
115 | } | 116 | } |
116 | 117 | ||
117 | static void null_frame_proc_slice (vo_frame_t *vo_img, uint8_t **src) { | 118 | static void null_frame_proc_slice (vo_frame_t *vo_img, uint8_t **src) { |
118 | opie_frame_t *frame = (opie_frame_t *) vo_img ; | 119 | opie_frame_t *frame = (opie_frame_t *) vo_img ; |
119 | 120 | ||
120 | vo_img->proc_called = 1; | 121 | vo_img->proc_called = 1; |
121 | 122 | ||
122 | if (!frame->output->m_show_video) { | 123 | /* |
123 | /* printf("nullvideo: no video\n"); */ | 124 | * drop hard if we don't show the video |
125 | */ | ||
126 | if (!frame->output->m_show_video) | ||
127 | return; | ||
128 | |||
129 | if( frame->frame.crop_left || frame->frame.crop_top || | ||
130 | frame->frame.crop_right || frame->frame.crop_bottom ) | ||
131 | { | ||
132 | /* we don't support crop, so don't even waste cpu cycles. | ||
133 | * cropping will be performed by video_out.c | ||
134 | */ | ||
124 | return; | 135 | return; |
125 | } | 136 | } |
126 | 137 | ||
127 | if (frame->format == XINE_IMGFMT_YV12) { | 138 | if (frame->format == XINE_IMGFMT_YV12) { |
@@ -141,17 +152,17 @@ static void null_frame_field (vo_frame_t *vo_img, int which_field) { | |||
141 | opie_frame_t *frame = (opie_frame_t *) vo_img ; | 152 | opie_frame_t *frame = (opie_frame_t *) vo_img ; |
142 | 153 | ||
143 | switch (which_field) { | 154 | switch (which_field) { |
144 | case VO_TOP_FIELD: | 155 | case VO_TOP_FIELD: |
145 | frame->rgb_dst = (uint8_t *)frame->data; | 156 | frame->rgb_dst = frame->data; |
146 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; | 157 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; |
147 | break; | 158 | break; |
148 | case VO_BOTTOM_FIELD: | 159 | case VO_BOTTOM_FIELD: |
149 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | 160 | frame->rgb_dst = frame->data + frame->bytes_per_line ; |
150 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; | 161 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; |
151 | break; | 162 | break; |
152 | case VO_BOTH_FIELDS: | 163 | case VO_BOTH_FIELDS: |
153 | frame->rgb_dst = (uint8_t *)frame->data; | 164 | frame->rgb_dst = frame->data; |
154 | break; | 165 | break; |
155 | } | 166 | } |
156 | } | 167 | } |
157 | 168 | ||
@@ -176,8 +187,10 @@ static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ | |||
176 | fprintf (stderr, "nullvideo: alloc_frame\n"); | 187 | fprintf (stderr, "nullvideo: alloc_frame\n"); |
177 | #endif | 188 | #endif |
178 | 189 | ||
179 | frame = (opie_frame_t*)xine_xmalloc ( sizeof(opie_frame_t) ); | 190 | frame = (opie_frame_t*)xine_xmalloc ( sizeof(opie_frame_t) ); |
191 | if(!frame) | ||
192 | return NULL; | ||
180 | 193 | ||
181 | memcpy (&frame->sc, &this->sc, sizeof(vo_scale_t)); | 194 | memcpy (&frame->sc, &this->sc, sizeof(vo_scale_t)); |
182 | 195 | ||
183 | pthread_mutex_init (&frame->frame.mutex, NULL); | 196 | pthread_mutex_init (&frame->frame.mutex, NULL); |
@@ -186,8 +199,9 @@ static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ | |||
186 | 199 | ||
187 | /* initialize the frame*/ | 200 | /* initialize the frame*/ |
188 | frame->frame.driver = self; | 201 | frame->frame.driver = self; |
189 | frame->frame.proc_slice = null_frame_proc_slice; | 202 | frame->frame.proc_slice = null_frame_proc_slice; |
203 | frame->frame.proc_frame = NULL; | ||
190 | frame->frame.field = null_frame_field; | 204 | frame->frame.field = null_frame_field; |
191 | frame->frame.dispose = null_frame_dispose; | 205 | frame->frame.dispose = null_frame_dispose; |
192 | 206 | ||
193 | /* | 207 | /* |
@@ -198,9 +212,9 @@ static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ | |||
198 | return (vo_frame_t*) frame; | 212 | return (vo_frame_t*) frame; |
199 | } | 213 | } |
200 | 214 | ||
201 | 215 | ||
202 | static void null_frame_compute_ideal_size( null_driver_t *this, | 216 | static void null_frame_compute_ideal_size( null_driver_t *this, |
203 | opie_frame_t *frame ) { | 217 | opie_frame_t *frame ) { |
204 | this = this; | 218 | this = this; |
205 | 219 | ||
206 | _x_vo_scale_compute_ideal_size(&frame->sc); | 220 | _x_vo_scale_compute_ideal_size(&frame->sc); |
@@ -228,25 +242,24 @@ static void null_frame_reallocate( null_driver_t *this, opie_frame_t *frame, | |||
228 | uint32_t width, uint32_t height, int format){ | 242 | uint32_t width, uint32_t height, int format){ |
229 | /* | 243 | /* |
230 | * (re-) allocate | 244 | * (re-) allocate |
231 | */ | 245 | */ |
232 | if( frame->data ) { | 246 | if( frame->chunk[0] ){ |
233 | if( frame->chunk[0] ){ | 247 | free( frame->chunk[0] ); |
234 | free( frame->chunk[0] ); | 248 | frame->chunk[0] = NULL; |
235 | frame->chunk[0] = NULL; | 249 | } |
236 | } | 250 | if( frame->chunk[1] ){ |
237 | if( frame->chunk[1] ){ | 251 | free ( frame->chunk[1] ); |
238 | free ( frame->chunk[1] ); | 252 | frame->chunk[1] = NULL; |
239 | frame->chunk[1] = NULL; | ||
240 | } | ||
241 | if( frame->chunk[2] ){ | ||
242 | free ( frame->chunk[2] ); | ||
243 | frame->chunk[2] = NULL; | ||
244 | } | ||
245 | free ( frame->data ); | ||
246 | } | 253 | } |
254 | if( frame->chunk[2] ){ | ||
255 | free ( frame->chunk[2] ); | ||
256 | frame->chunk[2] = NULL; | ||
257 | } | ||
258 | if(frame->data) | ||
259 | free ( frame->data ); | ||
247 | 260 | ||
248 | frame->data = xine_xmalloc (frame->sc.output_width | 261 | frame->data = xine_xmalloc (frame->sc.output_width |
249 | * frame->sc.output_height | 262 | * frame->sc.output_height |
250 | * this->bytes_per_pixel ); | 263 | * this->bytes_per_pixel ); |
251 | 264 | ||
252 | if( format == XINE_IMGFMT_YV12 ) { | 265 | if( format == XINE_IMGFMT_YV12 ) { |
@@ -300,39 +313,44 @@ static void null_setup_colorspace_converter(opie_frame_t *frame, int flags ) { | |||
300 | } | 313 | } |
301 | 314 | ||
302 | static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, | 315 | static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, |
303 | uint32_t width, uint32_t height, | 316 | uint32_t width, uint32_t height, |
304 | double ratio_code, int format, | 317 | double ratio_code, int format, |
305 | int flags ){ | 318 | int flags ){ |
306 | null_driver_t* this = (null_driver_t*) self; | 319 | null_driver_t* this = (null_driver_t*) self; |
307 | opie_frame_t* frame = (opie_frame_t*)img; | 320 | opie_frame_t* frame = (opie_frame_t*)img; |
308 | 321 | ||
309 | #ifdef LOG | 322 | #ifdef LOG |
310 | fprintf (stderr, "nullvideo: update_frame_format\n"); | 323 | fprintf (stderr, "nullvideo: update_frame_format\n"); |
311 | #endif | 324 | #endif |
312 | 325 | ||
326 | int gui_width = 0; | ||
327 | int gui_height = 0; | ||
328 | double gui_pixel_aspect = 0.0; | ||
329 | |||
313 | flags &= VO_BOTH_FIELDS; | 330 | flags &= VO_BOTH_FIELDS; |
314 | 331 | ||
315 | /* find out if we need to adapt this frame */ | 332 | frame->sc.dest_size_cb(frame->sc.user_data, width, height, |
333 | frame->sc.video_pixel_aspect, | ||
334 | &gui_width, &gui_height, &gui_pixel_aspect); | ||
316 | 335 | ||
336 | /* find out if we need to adapt this frame */ | ||
317 | if ((width != frame->sc.delivered_width) | 337 | if ((width != frame->sc.delivered_width) |
318 | || (height != frame->sc.delivered_height) | 338 | || (height != frame->sc.delivered_height) |
319 | || (ratio_code != frame->sc.delivered_ratio) | 339 | || (ratio_code != frame->sc.delivered_ratio) |
320 | || (flags != frame->flags) | 340 | || (flags != frame->flags) |
321 | || (format != frame->format) | 341 | || (format != frame->format) |
322 | || (this->sc.user_ratio != frame->sc.user_ratio) | 342 | || (this->sc.user_ratio != frame->sc.user_ratio) |
323 | || (this->gui_width != frame->sc.gui_width) | 343 | || (gui_width != frame->sc.gui_width) |
324 | || (this->gui_height != frame->sc.gui_height)) { | 344 | || (gui_height != frame->sc.gui_height)) { |
325 | |||
326 | frame->sc.delivered_width = width; | 345 | frame->sc.delivered_width = width; |
327 | frame->sc.delivered_height = height; | 346 | frame->sc.delivered_height = height; |
328 | frame->sc.delivered_ratio = ratio_code; | 347 | frame->sc.delivered_ratio = ratio_code; |
329 | frame->flags = flags; | 348 | frame->flags = flags; |
330 | frame->format = format; | 349 | frame->format = format; |
331 | frame->sc.user_ratio = this->sc.user_ratio; | 350 | frame->sc.user_ratio = this->sc.user_ratio; |
332 | frame->sc.gui_width = this->gui_width; | 351 | frame->sc.gui_width = gui_width; |
333 | frame->sc.gui_height = this->gui_height; | 352 | frame->sc.gui_height = gui_height; |
334 | frame->sc.gui_pixel_aspect = 1.0; | ||
335 | 353 | ||
336 | 354 | ||
337 | null_frame_compute_ideal_size(this, frame); | 355 | null_frame_compute_ideal_size(this, frame); |
338 | null_frame_compute_rgb_size(this, frame); | 356 | null_frame_compute_rgb_size(this, frame); |
@@ -362,17 +380,17 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, | |||
362 | 380 | ||
363 | if (frame->data) { | 381 | if (frame->data) { |
364 | switch (flags) { | 382 | switch (flags) { |
365 | case VO_TOP_FIELD: | 383 | case VO_TOP_FIELD: |
366 | frame->rgb_dst = (uint8_t *)frame->data; | 384 | frame->rgb_dst = frame->data; |
367 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | 385 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; |
368 | break; | 386 | break; |
369 | case VO_BOTTOM_FIELD: | 387 | case VO_BOTTOM_FIELD: |
370 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | 388 | frame->rgb_dst = frame->data + frame->bytes_per_line ; |
371 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | 389 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; |
372 | break; | 390 | break; |
373 | case VO_BOTH_FIELDS: | 391 | case VO_BOTH_FIELDS: |
374 | frame->rgb_dst = (uint8_t *)frame->data; | 392 | frame->rgb_dst = frame->data; |
375 | frame->stripe_inc = frame->stripe_height * frame->bytes_per_line; | 393 | frame->stripe_inc = frame->stripe_height * frame->bytes_per_line; |
376 | break; | 394 | break; |
377 | } | 395 | } |
378 | } | 396 | } |
@@ -386,9 +404,9 @@ static void null_display_frame( vo_driver_t* self, vo_frame_t *frame_gen ){ | |||
386 | if (!this->m_show_video) | 404 | if (!this->m_show_video) |
387 | return; | 405 | return; |
388 | 406 | ||
389 | if( display != NULL ) { | 407 | if( display != NULL ) { |
390 | (*display)(this->caller, frame->data, | 408 | (*display)(this->userData, frame->data, |
391 | frame->sc.output_width, frame->sc.output_height, | 409 | frame->sc.output_width, frame->sc.output_height, |
392 | frame->bytes_per_line ); | 410 | frame->bytes_per_line ); |
393 | } | 411 | } |
394 | 412 | ||
@@ -441,30 +459,33 @@ static void null_overlay_blend ( vo_driver_t *this_gen, vo_frame_t *frame_gen, | |||
441 | null_overlay_clut_yuv2rgb(this,overlay,frame); | 459 | null_overlay_clut_yuv2rgb(this,overlay,frame); |
442 | 460 | ||
443 | switch(this->bpp) { | 461 | switch(this->bpp) { |
444 | case 16: | 462 | case 16: |
445 | blend_rgb16((uint8_t *)frame->data, | 463 | blend_rgb16(frame->data, |
446 | overlay, | 464 | overlay, |
447 | frame->sc.output_width, | 465 | frame->sc.output_width, |
448 | frame->sc.output_height, | 466 | frame->sc.output_height, |
449 | frame->sc.delivered_width, | 467 | frame->sc.delivered_width, |
450 | frame->sc.delivered_height); | 468 | frame->sc.delivered_height, |
469 | &this->alphablend_extra_data); | ||
451 | break; | 470 | break; |
452 | case 24: | 471 | case 24: |
453 | blend_rgb24((uint8_t *)frame->data, | 472 | blend_rgb24(frame->data, |
454 | overlay, | 473 | overlay, |
455 | frame->sc.output_width, | 474 | frame->sc.output_width, |
456 | frame->sc.output_height, | 475 | frame->sc.output_height, |
457 | frame->sc.delivered_width, | 476 | frame->sc.delivered_width, |
458 | frame->sc.delivered_height); | 477 | frame->sc.delivered_height, |
478 | &this->alphablend_extra_data); | ||
459 | break; | 479 | break; |
460 | case 32: | 480 | case 32: |
461 | blend_rgb32((uint8_t *)frame->data, | 481 | blend_rgb32(frame->data, |
462 | overlay, | 482 | overlay, |
463 | frame->sc.output_width, | 483 | frame->sc.output_width, |
464 | frame->sc.output_height, | 484 | frame->sc.output_height, |
465 | frame->sc.delivered_width, | 485 | frame->sc.delivered_width, |
466 | frame->sc.delivered_height); | 486 | frame->sc.delivered_height, |
487 | &this->alphablend_extra_data); | ||
467 | break; | 488 | break; |
468 | default: | 489 | default: |
469 | /* It should never get here */ | 490 | /* It should never get here */ |
470 | break; | 491 | break; |
@@ -473,9 +494,8 @@ static void null_overlay_blend ( vo_driver_t *this_gen, vo_frame_t *frame_gen, | |||
473 | } | 494 | } |
474 | 495 | ||
475 | 496 | ||
476 | static int null_get_property( vo_driver_t* self, int property ){ | 497 | static int null_get_property( vo_driver_t* self, int property ){ |
477 | #if 0 | ||
478 | null_driver_t *this = (null_driver_t *)self; | 498 | null_driver_t *this = (null_driver_t *)self; |
479 | 499 | ||
480 | switch(property) | 500 | switch(property) |
481 | { | 501 | { |
@@ -489,18 +509,13 @@ static int null_get_property( vo_driver_t* self, int property ){ | |||
489 | return this->sc.gui_height; | 509 | return this->sc.gui_height; |
490 | default: | 510 | default: |
491 | break; | 511 | break; |
492 | } | 512 | } |
493 | #else | ||
494 | property = property; | ||
495 | self = self; | ||
496 | #endif | ||
497 | 513 | ||
498 | return 0; | 514 | return 0; |
499 | } | 515 | } |
500 | static int null_set_property( vo_driver_t* self, int property, | 516 | static int null_set_property( vo_driver_t* self, int property, |
501 | int value ){ | 517 | int value ){ |
502 | #if 0 | ||
503 | null_driver_t *this = (null_driver_t *)self; | 518 | null_driver_t *this = (null_driver_t *)self; |
504 | 519 | ||
505 | switch(property) | 520 | switch(property) |
506 | { | 521 | { |
@@ -516,90 +531,86 @@ static int null_set_property( vo_driver_t* self, int property, | |||
516 | break; | 531 | break; |
517 | default: | 532 | default: |
518 | break; | 533 | break; |
519 | } | 534 | } |
520 | #else | ||
521 | self = self; | ||
522 | property = property; | ||
523 | #endif | ||
524 | 535 | ||
525 | return value; | 536 | return value; |
526 | } | 537 | } |
527 | static void null_get_property_min_max( vo_driver_t* self, | 538 | static void null_get_property_min_max( vo_driver_t* self, |
528 | int property, int *min, | 539 | int property, int *min, |
529 | int *max ){ | 540 | int *max ){ |
530 | self = self; | 541 | if(property == VO_PROP_BRIGHTNESS) { |
531 | property = property; | 542 | *min = -100; |
532 | 543 | *max = +100; | |
533 | *max = 0; | 544 | }else { |
534 | *min = 0; | 545 | *min = 0; |
546 | *max = 0; | ||
547 | } | ||
535 | } | 548 | } |
536 | static int null_gui_data_exchange( vo_driver_t* self, | 549 | static int null_gui_data_exchange( vo_driver_t* self, |
537 | int data_type, | 550 | int data_type, |
538 | void *data ){ | 551 | void *data ){ |
539 | self = self; | ||
540 | data_type = data_type; | ||
541 | data = data; | ||
542 | |||
543 | return 0; | 552 | return 0; |
544 | } | 553 | } |
545 | 554 | ||
546 | static void null_dispose ( vo_driver_t* self ){ | 555 | static void null_dispose ( vo_driver_t* self ){ |
547 | null_driver_t* this = (null_driver_t*)self; | 556 | null_driver_t* this = (null_driver_t*)self; |
557 | _x_alphablend_free(&this->alphablend_extra_data); | ||
548 | free ( this ); | 558 | free ( this ); |
549 | } | 559 | } |
550 | static int null_redraw_needed( vo_driver_t* self ){ | 560 | static int null_redraw_needed( vo_driver_t* self ){ |
551 | self = self; | 561 | null_driver_t *this = (null_driver_t*)self; |
552 | 562 | return _x_vo_scale_redraw_needed(&this->sc); | |
553 | return 0; | ||
554 | } | 563 | } |
555 | 564 | ||
556 | 565 | ||
557 | xine_video_port_t* init_video_out_plugin( xine_t *xine, | 566 | xine_video_port_t* init_video_out_plugin( xine_t *xine, |
558 | void* video, | 567 | void* video, |
559 | display_xine_frame_t frameDisplayFunc, | 568 | display_xine_frame_t frameDisplayFunc, |
560 | void *userData ){ | 569 | void *userData, vo_scale_cb frame_cb, |
561 | video = video; | 570 | dest_size_cb dest_cb) { |
562 | |||
563 | |||
564 | null_driver_t *vo; | 571 | null_driver_t *vo; |
565 | vo = (null_driver_t*)malloc( sizeof(null_driver_t ) ); | 572 | vo = (null_driver_t*)xine_xmalloc(sizeof(null_driver_t )); |
566 | 573 | vo->xine = xine; | |
567 | /* memset? */ | ||
568 | memset(vo,0, sizeof(null_driver_t ) ); | ||
569 | 574 | ||
575 | _x_alphablend_init(&vo->alphablend_extra_data, xine); | ||
570 | _x_vo_scale_init (&vo->sc, 0, 0, xine->config); | 576 | _x_vo_scale_init (&vo->sc, 0, 0, xine->config); |
577 | vo->sc.gui_width = 18; | ||
578 | vo->sc.gui_height = 6; | ||
579 | vo->sc.user_ratio = XINE_VO_ASPECT_AUTO; | ||
580 | vo->sc.user_data = userData; | ||
581 | vo->sc.frame_output_cb = frame_cb; | ||
582 | vo->sc.dest_size_cb = dest_cb; | ||
571 | 583 | ||
572 | vo->sc.gui_pixel_aspect = 1.0; | ||
573 | 584 | ||
574 | vo->m_show_video = 0; // false | 585 | vo->m_show_video = 0; // false |
575 | vo->m_video_fullscreen = 0; | ||
576 | vo->m_is_scaling = 0; | ||
577 | vo->display_ratio = 1.0; | ||
578 | vo->gui_width = 16; | ||
579 | vo->gui_height = 8; | ||
580 | vo->frameDis = NULL; | ||
581 | 586 | ||
582 | /* install callback handlers*/ | 587 | /* install callback handlers*/ |
583 | vo->vo_driver.get_capabilities = null_get_capabilities; | 588 | vo->vo_driver.get_capabilities = null_get_capabilities; |
584 | vo->vo_driver.alloc_frame = null_alloc_frame; | 589 | vo->vo_driver.alloc_frame = null_alloc_frame; |
585 | vo->vo_driver.update_frame_format = null_update_frame_format; | 590 | vo->vo_driver.update_frame_format = null_update_frame_format; |
586 | vo->vo_driver.display_frame = null_display_frame; | 591 | vo->vo_driver.display_frame = null_display_frame; |
587 | vo->vo_driver.overlay_blend = null_overlay_blend; | 592 | vo->vo_driver.overlay_begin = 0; |
588 | vo->vo_driver.get_property = null_get_property; | 593 | vo->vo_driver.overlay_blend = null_overlay_blend; |
589 | vo->vo_driver.set_property = null_set_property; | 594 | vo->vo_driver.overlay_end = 0; |
590 | vo->vo_driver.get_property_min_max = null_get_property_min_max; | 595 | vo->vo_driver.get_property = null_get_property; |
591 | vo->vo_driver.gui_data_exchange = null_gui_data_exchange; | 596 | vo->vo_driver.set_property = null_set_property; |
592 | vo->vo_driver.dispose = null_dispose; | 597 | vo->vo_driver.get_property_min_max= null_get_property_min_max; |
593 | vo->vo_driver.redraw_needed = null_redraw_needed; | 598 | vo->vo_driver.gui_data_exchange = null_gui_data_exchange; |
594 | 599 | vo->vo_driver.dispose = null_dispose; | |
600 | vo->vo_driver.redraw_needed = null_redraw_needed; | ||
595 | 601 | ||
596 | /* capabilities */ | 602 | /* capabilities */ |
597 | vo->m_capabilities = VO_CAP_YUY2 | VO_CAP_YV12; | 603 | vo->yuv2rgb_mode = MODE_16_RGB; |
598 | vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap, | 604 | vo->yuv2rgb_brightness = 0; |
605 | vo->yuv2rgb_factory = yuv2rgb_factory_init (vo->yuv2rgb_mode, | ||
606 | vo->yuv2rgb_swap, | ||
599 | vo->yuv2rgb_cmap); | 607 | vo->yuv2rgb_cmap); |
608 | vo->yuv2rgb_factory->set_csc_levels(vo->yuv2rgb_factory, | ||
609 | vo->yuv2rgb_brightness, | ||
610 | 128,128); | ||
600 | 611 | ||
601 | vo->caller = userData; | 612 | vo->userData = userData; |
602 | vo->frameDis = frameDisplayFunc; | 613 | vo->frameDis = frameDisplayFunc; |
603 | 614 | ||
604 | return _x_vo_new_port(xine, &vo->vo_driver, 0); | 615 | return _x_vo_new_port(xine, &vo->vo_driver, 0); |
605 | } | 616 | } |
@@ -620,42 +631,17 @@ int null_is_showing_video( xine_vo_driver_t* self ){ | |||
620 | void null_set_show_video( xine_vo_driver_t* self, int show ) { | 631 | void null_set_show_video( xine_vo_driver_t* self, int show ) { |
621 | ((null_driver_t*)self->driver)->m_show_video = show; | 632 | ((null_driver_t*)self->driver)->m_show_video = show; |
622 | } | 633 | } |
623 | 634 | ||
624 | int null_is_fullscreen( xine_vo_driver_t* self ){ | ||
625 | return ((null_driver_t*)self->driver)->m_video_fullscreen; | ||
626 | } | ||
627 | void null_set_fullscreen( xine_vo_driver_t* self, int screen ){ | ||
628 | ((null_driver_t*)self->driver)->m_video_fullscreen = screen; | ||
629 | } | ||
630 | int null_is_scaling( xine_vo_driver_t* self ){ | ||
631 | return ((null_driver_t*)self->driver)->m_is_scaling; | ||
632 | } | ||
633 | |||
634 | void null_set_videoGamma( xine_vo_driver_t* self , int value ) { | ||
635 | ((null_driver_t*) self->driver) ->yuv2rgb_gamma = value; | ||
636 | ((null_driver_t*) self->driver) ->yuv2rgb_factory->set_gamma( ((null_driver_t*) self->driver) ->yuv2rgb_factory, value ); | ||
637 | } | ||
638 | |||
639 | void null_set_scaling( xine_vo_driver_t* self, int scale ) { | ||
640 | ((null_driver_t*)self->driver)->m_is_scaling = scale; | ||
641 | } | ||
642 | |||
643 | void null_set_gui_width( xine_vo_driver_t* self, int width ) { | ||
644 | ((null_driver_t*)self->driver)->gui_width = width; | ||
645 | } | ||
646 | void null_set_gui_height( xine_vo_driver_t* self, int height ) { | ||
647 | ((null_driver_t*)self->driver)->gui_height = height; | ||
648 | } | ||
649 | 635 | ||
650 | 636 | ||
651 | void null_set_mode( xine_vo_driver_t* self, int depth, int rgb ) { | 637 | void null_set_mode( xine_vo_driver_t* self, int depth, int rgb ) { |
652 | null_driver_t* this = (null_driver_t*)self->driver; | 638 | null_driver_t* this = (null_driver_t*)self->driver; |
653 | 639 | ||
654 | this->bytes_per_pixel = (depth + 7 ) / 8; | 640 | this->bytes_per_pixel = (depth + 7 ) / 8; |
655 | this->bpp = this->bytes_per_pixel * 8; | 641 | this->bpp = this->bytes_per_pixel * 8; |
656 | this->depth = depth; | 642 | this->depth = depth; |
657 | 643 | ||
658 | switch ( this->depth ) { | 644 | switch ( this->depth ) { |
659 | case 32: | 645 | case 32: |
660 | if( rgb == 0 ) | 646 | if( rgb == 0 ) |
661 | this->yuv2rgb_mode = MODE_32_RGB; | 647 | this->yuv2rgb_mode = MODE_32_RGB; |
@@ -696,40 +682,14 @@ void null_set_mode( xine_vo_driver_t* self, int depth, int rgb ) { | |||
696 | this->yuv2rgb_mode = MODE_8_BGR; | 682 | this->yuv2rgb_mode = MODE_8_BGR; |
697 | } | 683 | } |
698 | break; | 684 | break; |
699 | }; | 685 | }; |
700 | //free(this->yuv2rgb_factory ); | ||
701 | // this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap, | ||
702 | // this->yuv2rgb_cmap); | ||
703 | }; | 686 | }; |
704 | 687 | ||
705 | void null_display_handler( xine_vo_driver_t* self, display_xine_frame_t t, | 688 | void null_display_handler( xine_vo_driver_t* self, display_xine_frame_t t, |
706 | void* user_data ) { | 689 | void* user_data ) { |
707 | null_driver_t* this = (null_driver_t*) self->driver; | 690 | null_driver_t* this = (null_driver_t*) self->driver; |
708 | this->caller = user_data; | 691 | this->userData = user_data; |
709 | this->frameDis = t; | 692 | this->frameDis = t; |
710 | } | 693 | } |
711 | 694 | ||
712 | void null_preload_decoders( xine_stream_t *stream ) | ||
713 | { | ||
714 | static const uint32_t preloadedAudioDecoders[] = { BUF_AUDIO_MPEG, BUF_AUDIO_VORBIS }; | ||
715 | static const uint8_t preloadedAudioDecoderCount = sizeof( preloadedAudioDecoders ) / sizeof( preloadedAudioDecoders[ 0 ] ); | ||
716 | static const uint32_t preloadedVideoDecoders[] = { BUF_VIDEO_MPEG, BUF_VIDEO_MPEG4, BUF_VIDEO_DIVX5 }; | ||
717 | static const uint8_t preloadedVideoDecoderCount = sizeof( preloadedVideoDecoders ) / sizeof( preloadedVideoDecoders[ 0 ] ); | ||
718 | |||
719 | uint8_t i; | ||
720 | #if 0 | ||
721 | |||
722 | for ( i = 0; i < preloadedAudioDecoderCount; ++i ) { | ||
723 | audio_decoder_t *decoder = get_audio_decoder( stream, ( preloadedAudioDecoders[ i ] >> 16 ) & 0xff ); | ||
724 | decoder = decoder; | ||
725 | /* free_audio_decoder( stream, decoder ); */ | ||
726 | } | ||
727 | |||
728 | for ( i = 0; i < preloadedVideoDecoderCount; ++i ) { | ||
729 | video_decoder_t *decoder = get_video_decoder( stream, ( preloadedVideoDecoders[ i ] >> 16 ) & 0xff ); | ||
730 | decoder = decoder; | ||
731 | /* free_video_decoder( stream, decoder ); */ | ||
732 | } | ||
733 | #endif | ||
734 | } | ||
735 | 695 | ||
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,8 +1,9 @@ | |||
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 | * |
@@ -30,10 +31,16 @@ | |||
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); |
@@ -50,32 +57,69 @@ const int32_t Inverse_Table_6_9[8][4] = { | |||
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; |
@@ -84,9 +128,11 @@ static int yuv2rgb_configure (yuv2rgb_t *this, | |||
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 | } |
@@ -98,12 +144,25 @@ static int yuv2rgb_configure (yuv2rgb_t *this, | |||
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; |
@@ -137,13 +196,25 @@ static int yuv2rgb_configure (yuv2rgb_t *this, | |||
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 | /* |
@@ -1203,18 +1274,31 @@ static scale_line_func_t find_scale_line_func(int step) { | |||
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, |
@@ -1271,9 +1355,9 @@ static void scale_line_4 (uint8_t *source, uint8_t *dest, | |||
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]);\ |
@@ -1347,9 +1431,9 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1358,18 +1442,18 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1411,9 +1495,9 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1422,21 +1506,21 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1478,9 +1562,9 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1489,18 +1573,18 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1542,9 +1626,9 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1553,21 +1637,21 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1609,9 +1693,9 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1620,18 +1704,18 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1674,9 +1758,9 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1684,21 +1768,21 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1740,9 +1824,9 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1751,18 +1835,18 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1804,9 +1888,9 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1814,21 +1898,21 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1870,9 +1954,9 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1881,18 +1965,18 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1934,9 +2018,9 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1945,21 +2029,21 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -1989,9 +2073,9 @@ static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, | |||
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 | ||
@@ -2015,9 +2099,9 @@ static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, | |||
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 | } |
@@ -2045,9 +2129,9 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -2056,18 +2140,18 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -2109,9 +2193,9 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -2119,21 +2203,21 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
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; |
@@ -2160,9 +2244,10 @@ static int div_round (int dividend, int 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; |
@@ -2176,20 +2261,26 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
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; |
@@ -2216,9 +2307,12 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
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 | ||
@@ -2229,9 +2323,12 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
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; |
@@ -2269,9 +2366,12 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
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; |
@@ -2293,9 +2393,12 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
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; |
@@ -2317,10 +2420,10 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
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) + |
@@ -2330,10 +2433,12 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
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 | { |
@@ -2447,10 +2552,10 @@ static void yuv2rgb_c_init (yuv2rgb_factory_t *this) | |||
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 | ||
@@ -2490,10 +2595,10 @@ static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) { | |||
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 | ||
@@ -2519,9 +2624,9 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2531,18 +2636,18 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2563,9 +2668,9 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2598,9 +2703,9 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2609,18 +2714,18 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2641,9 +2746,9 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2676,9 +2781,9 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2687,18 +2792,18 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2719,9 +2824,9 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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); |
@@ -2750,9 +2855,9 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2761,18 +2866,18 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2793,9 +2898,9 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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); |
@@ -2824,9 +2929,9 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2835,18 +2940,18 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2867,9 +2972,9 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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); |
@@ -2888,9 +2993,9 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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 | ||
@@ -2907,21 +3012,21 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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 | ||
@@ -2941,9 +3046,9 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2952,18 +3057,18 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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; |
@@ -2984,9 +3089,9 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
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); |
@@ -3032,121 +3137,127 @@ static void yuy22rgb_c_init (yuv2rgb_factory_t *this) | |||
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 | /* |
@@ -3163,5 +3274,4 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, | |||
3163 | yuv2rgb_single_pixel_init (this); | 3274 | yuv2rgb_single_pixel_init (this); |
3164 | 3275 | ||
3165 | return this; | 3276 | return this; |
3166 | } | 3277 | } |
3167 | |||
diff --git a/noncore/multimedia/opieplayer2/yuv2rgb.h b/noncore/multimedia/opieplayer2/yuv2rgb.h index e453243..1833889 100644 --- a/noncore/multimedia/opieplayer2/yuv2rgb.h +++ b/noncore/multimedia/opieplayer2/yuv2rgb.h | |||
@@ -1,8 +1,12 @@ | |||
1 | 1 | ||
2 | #ifndef HAVE_YUV2RGB_H | 2 | #ifndef HAVE_YUV2RGB_H |
3 | #define HAVE_YUV2RGB_h | 3 | #define HAVE_YUV2RGB_h |
4 | 4 | ||
5 | #ifdef HAVE_MLIB | ||
6 | #include <mlib_video.h> | ||
7 | #endif | ||
8 | |||
5 | #include <inttypes.h> | 9 | #include <inttypes.h> |
6 | 10 | ||
7 | typedef struct yuv2rgb_s yuv2rgb_t; | 11 | typedef struct yuv2rgb_s yuv2rgb_t; |
8 | 12 | ||
@@ -21,9 +25,8 @@ typedef void (*yuv2rgb_fun_t) (yuv2rgb_t *this, uint8_t * image, uint8_t * py, u | |||
21 | typedef void (*yuy22rgb_fun_t) (yuv2rgb_t *this, uint8_t * image, uint8_t * p); | 25 | typedef void (*yuy22rgb_fun_t) (yuv2rgb_t *this, uint8_t * image, uint8_t * p); |
22 | 26 | ||
23 | typedef uint32_t (*yuv2rgb_single_pixel_fun_t) (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v); | 27 | typedef uint32_t (*yuv2rgb_single_pixel_fun_t) (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v); |
24 | 28 | ||
25 | |||
26 | /* | 29 | /* |
27 | * modes supported - feel free to implement yours | 30 | * modes supported - feel free to implement yours |
28 | */ | 31 | */ |
29 | 32 | ||
@@ -40,9 +43,8 @@ typedef uint32_t (*yuv2rgb_single_pixel_fun_t) (yuv2rgb_t *this, uint8_t y, uint | |||
40 | #defineMODE_8_GRAY 11 | 43 | #defineMODE_8_GRAY 11 |
41 | #define MODE_PALETTE 12 | 44 | #define MODE_PALETTE 12 |
42 | 45 | ||
43 | struct yuv2rgb_s { | 46 | struct yuv2rgb_s { |
44 | |||
45 | /* | 47 | /* |
46 | * configure converter for scaling factors | 48 | * configure converter for scaling factors |
47 | */ | 49 | */ |
48 | int (*configure) (yuv2rgb_t *this, | 50 | int (*configure) (yuv2rgb_t *this, |
@@ -51,8 +53,18 @@ struct yuv2rgb_s { | |||
51 | int dest_width, int dest_height, | 53 | int dest_width, int dest_height, |
52 | int rgb_stride); | 54 | int rgb_stride); |
53 | 55 | ||
54 | /* | 56 | /* |
57 | * start a new field or frame if dest is NULL | ||
58 | */ | ||
59 | int (*next_slice) (yuv2rgb_t *this, uint8_t **dest); | ||
60 | |||
61 | /* | ||
62 | * free resources | ||
63 | */ | ||
64 | void (*dispose) (yuv2rgb_t *this); | ||
65 | |||
66 | /* | ||
55 | * this is the function to call for the yuv2rgb and scaling process | 67 | * this is the function to call for the yuv2rgb and scaling process |
56 | */ | 68 | */ |
57 | yuv2rgb_fun_t yuv2rgb_fun; | 69 | yuv2rgb_fun_t yuv2rgb_fun; |
58 | 70 | ||
@@ -73,80 +85,88 @@ struct yuv2rgb_s { | |||
73 | int source_width, source_height; | 85 | int source_width, source_height; |
74 | int y_stride, uv_stride; | 86 | int y_stride, uv_stride; |
75 | int dest_width, dest_height; | 87 | int dest_width, dest_height; |
76 | int rgb_stride; | 88 | int rgb_stride; |
89 | int slice_height, slice_offset; | ||
77 | int step_dx, step_dy; | 90 | int step_dx, step_dy; |
78 | int do_scale; | 91 | int do_scale, swapped; |
79 | 92 | ||
80 | uint8_t *y_buffer; | 93 | uint8_t *y_buffer; |
81 | uint8_t *u_buffer; | 94 | uint8_t *u_buffer; |
82 | uint8_t *v_buffer; | 95 | uint8_t *v_buffer; |
83 | void *y_chunk; | 96 | void *y_chunk; |
84 | void *u_chunk; | 97 | void *u_chunk; |
85 | void *v_chunk; | 98 | void *v_chunk; |
86 | 99 | ||
100 | #ifdef HAVE_MLIB | ||
101 | uint8_t *mlib_buffer; | ||
102 | uint8_t *mlib_resize_buffer; | ||
103 | void *mlib_chunk; | ||
104 | void *mlib_resize_chunk; | ||
105 | mlib_filter mlib_filter_type; | ||
106 | #endif | ||
107 | |||
87 | void **table_rV; | 108 | void **table_rV; |
88 | void **table_gU; | 109 | void **table_gU; |
89 | int *table_gV; | 110 | int *table_gV; |
90 | void **table_bU; | 111 | void **table_bU; |
112 | void *table_mmx; | ||
91 | 113 | ||
92 | uint8_t *cmap; | 114 | uint8_t *cmap; |
93 | scale_line_func_t scale_line; | 115 | scale_line_func_t scale_line; |
94 | |||
95 | } ; | 116 | } ; |
96 | 117 | ||
97 | /* | 118 | /* |
98 | * convenience class to easily create a lot of converters | 119 | * convenience class to easily create a lot of converters |
99 | */ | 120 | */ |
100 | 121 | ||
101 | struct yuv2rgb_factory_s { | 122 | struct yuv2rgb_factory_s { |
102 | |||
103 | yuv2rgb_t* (*create_converter) (yuv2rgb_factory_t *this); | 123 | yuv2rgb_t* (*create_converter) (yuv2rgb_factory_t *this); |
104 | 124 | ||
105 | /* | 125 | /* |
106 | * adjust gamma (-100 to 100 looks fine) | 126 | * set color space conversion levels |
107 | * for all converters produced by this factory | 127 | * for all converters produced by this factory |
108 | */ | 128 | */ |
109 | void (*set_gamma) (yuv2rgb_factory_t *this, int gamma); | 129 | void (*set_csc_levels) (yuv2rgb_factory_t *this, |
130 | int brightness, int contrast, int saturation); | ||
110 | 131 | ||
111 | /* | 132 | /* |
112 | * get gamma value | 133 | * free resources |
113 | */ | 134 | */ |
114 | int (*get_gamma) (yuv2rgb_factory_t *this); | 135 | void (*dispose) (yuv2rgb_factory_t *this); |
115 | 136 | ||
116 | /* private data */ | 137 | /* private data */ |
117 | 138 | ||
118 | int mode; | 139 | int mode; |
119 | int swapped; | 140 | int swapped; |
120 | uint8_t *cmap; | 141 | uint8_t *cmap; |
121 | 142 | ||
122 | int gamma; | ||
123 | int entry_size; | ||
124 | |||
125 | uint32_t matrix_coefficients; | 143 | uint32_t matrix_coefficients; |
126 | 144 | ||
145 | void *table_base; | ||
127 | void *table_rV[256]; | 146 | void *table_rV[256]; |
128 | void *table_gU[256]; | 147 | void *table_gU[256]; |
129 | int table_gV[256]; | 148 | int table_gV[256]; |
130 | void *table_bU[256]; | 149 | void *table_bU[256]; |
150 | void *table_mmx_base; | ||
151 | void *table_mmx; | ||
131 | 152 | ||
132 | /* preselected functions for mode/swap/hardware */ | 153 | /* preselected functions for mode/swap/hardware */ |
133 | yuv2rgb_fun_t yuv2rgb_fun; | 154 | yuv2rgb_fun_t yuv2rgb_fun; |
134 | yuy22rgb_fun_t yuy22rgb_fun; | 155 | yuy22rgb_fun_t yuy22rgb_fun; |
135 | yuv2rgb_single_pixel_fun_t yuv2rgb_single_pixel_fun; | 156 | yuv2rgb_single_pixel_fun_t yuv2rgb_single_pixel_fun; |
136 | |||
137 | }; | 157 | }; |
138 | 158 | ||
139 | yuv2rgb_factory_t *yuv2rgb_factory_init (int mode, int swapped, uint8_t *colormap); | 159 | yuv2rgb_factory_t *yuv2rgb_factory_init (int mode, int swapped, uint8_t *colormap); |
140 | 160 | ||
141 | 161 | ||
142 | /* | 162 | /* |
143 | * internal stuff below this line | 163 | * internal stuff below this line |
144 | */ | 164 | */ |
145 | 165 | ||
146 | void mmx_yuv2rgb_set_gamma(int gamma); | 166 | void mmx_yuv2rgb_set_csc_levels(yuv2rgb_factory_t *this, |
167 | int brightness, int contrast, int saturation); | ||
147 | void yuv2rgb_init_mmxext (yuv2rgb_factory_t *this); | 168 | void yuv2rgb_init_mmxext (yuv2rgb_factory_t *this); |
148 | void yuv2rgb_init_mmx (yuv2rgb_factory_t *this); | 169 | void yuv2rgb_init_mmx (yuv2rgb_factory_t *this); |
149 | void yuv2rgb_init_mlib (yuv2rgb_factory_t *this); | 170 | void yuv2rgb_init_mlib (yuv2rgb_factory_t *this); |
150 | void yuv2rgb_init_arm (yuv2rgb_factory_t *this); | ||
151 | 171 | ||
152 | #endif | 172 | #endif |