author | zecke <zecke> | 2005-04-17 13:56:34 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-04-17 13:56:34 (UTC) |
commit | 3d5e5c098ccb686588380bc1f220beafbc5a6d76 (patch) (unidiff) | |
tree | 92fad8a98ea341ec290dc7f9fca7759470b795f6 | |
parent | 49335d66d8e96b1fc86ecfe95cd343c8960126bc (diff) | |
download | opie-3d5e5c098ccb686588380bc1f220beafbc5a6d76.zip opie-3d5e5c098ccb686588380bc1f220beafbc5a6d76.tar.gz opie-3d5e5c098ccb686588380bc1f220beafbc5a6d76.tar.bz2 |
Opie Player2 XINE update:
-update xine code alphablend, yuv2rgb to be up to date
-XINELib:
-use the XINE infrastructure to change the gui width/height
-use the XINE infrastructure to change the brightness
-Update the NULL Video Driver:
-make use of frame_dest_cb and and dest_size_cb (callback)
to update the size of the gui
-use alphablend
-merge the video_out_fb xine driver
To Alwin: your testvideo now lockups op2. with valgrind I see
it has to do with the yuv2rgb conversion methods
-rw-r--r-- | noncore/multimedia/opieplayer2/alphablend.c | 1469 | ||||
-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 | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mainTest.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/nullvideo.c | 220 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb.c | 436 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb.h | 50 |
8 files changed, 1782 insertions, 578 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,5 +1 @@ | |||
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 | /* | /* | |
@@ -9,2 +5,3 @@ | |||
9 | * Copyright (C) 2000 Thomas Mirlacher | 5 | * Copyright (C) 2000 Thomas Mirlacher |
6 | * 2002-2004 the xine project | ||
10 | * | 7 | * |
@@ -32,2 +29,3 @@ | |||
32 | #define LOG_BLEND_YUV | 29 | #define LOG_BLEND_YUV |
30 | #define LOG_BLEND_RGB16 | ||
33 | */ | 31 | */ |
@@ -37,5 +35,3 @@ | |||
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> |
@@ -43,2 +39,3 @@ | |||
43 | #include "alphablend.h" | 39 | #include "alphablend.h" |
40 | #include "bswap.h" | ||
44 | 41 | ||
@@ -73,15 +70,2 @@ static void mem_blend24(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b, | |||
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) { |
@@ -100,3 +84,2 @@ static void mem_blend32(uint8_t *mem, uint8_t *src, uint8_t o, int len) { | |||
100 | 84 | ||
101 | |||
102 | /* | 85 | /* |
@@ -129,9 +112,9 @@ rle_img_advance_line(rle_elem_t *rle, rle_elem_t *rle_limit, int w) | |||
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 | ||
@@ -140,2 +123,3 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, | |||
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; |
@@ -145,11 +129,55 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, | |||
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 | ||
@@ -159,3 +187,3 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, | |||
159 | else | 187 | else |
160 | clip_right = dst_width - 1 - img_overl->x; | 188 | clip_right = dst_width - img_overl->x; |
161 | 189 | ||
@@ -163,50 +191,294 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, | |||
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; | ||
174 | 204 | ||
175 | clr = rle->color; | 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 | ||
214 | |||
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; |
247 | rle_remainder = 0; | ||
248 | rlelen -= rle_this_bite; | ||
249 | /*printf("(x,y) = (%03i,%03i), clr=%03x, len=%03i, zone=%i\n", x, y, clr, rle_this_bite, zone_state); */ | ||
250 | if (o) { | ||
251 | x1_scaled = SCALED_TO_INT( x * x_scale ); | ||
252 | x2_scaled = SCALED_TO_INT( (x + rle_this_bite) * x_scale); | ||
253 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); | ||
254 | } | ||
255 | x += rle_this_bite; | ||
256 | if (x >= src_width ) { | ||
257 | x -= src_width; | ||
258 | img_pix += img_width; | ||
178 | 259 | ||
179 | if (o && mask) { | 260 | dy += dy_step; |
180 | /* threat cases where clipping border is inside rle->len pixels */ | 261 | if (dy >= INT_TO_SCALED(1)) { |
181 | if ( img_overl->clip_left > x ) { | 262 | dy -= INT_TO_SCALED(1); |
182 | if( img_overl->clip_left < x + rlelen ) { | 263 | ++y; |
183 | x1_scaled = SCALED_TO_INT( img_overl->clip_left * x_scale ); | 264 | while (dy >= INT_TO_SCALED(1)) { |
184 | rlelen -= img_overl->clip_left - x; | 265 | rle = rle_img_advance_line(rle, rle_limit, src_width); |
185 | x += img_overl->clip_left - x; | 266 | dy -= INT_TO_SCALED(1); |
267 | ++y; | ||
268 | } | ||
269 | rle_start = rle; | ||
186 | } else { | 270 | } else { |
187 | o = 0; | 271 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ |
188 | } | 272 | } |
189 | } else if( clip_right < x + rlelen ) { | 273 | } |
190 | if( clip_right > x ) { | 274 | rle_remainder = rlelen = rle->len; |
191 | x2_scaled = SCALED_TO_INT( clip_right * x_scale); | 275 | clr_next = rle->color; |
192 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, | 276 | rle++; |
193 | x2_scaled-x1_scaled); | 277 | if (rle >= rle_limit) { |
194 | o = 0; | 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; | ||
290 | } | ||
291 | } | ||
292 | } | ||
293 | break; | ||
294 | case 2: /* Left of button */ | ||
295 | clut = (clut_t*) img_overl->color; | ||
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; | ||
307 | } | ||
308 | if (o) { | ||
309 | x1_scaled = SCALED_TO_INT( x * x_scale ); | ||
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; | ||
195 | } else { | 327 | } else { |
196 | o = 0; | 328 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ |
197 | } | 329 | } |
330 | if (y >= img_overl->clip_bottom) { | ||
331 | zone_state = 5; | ||
332 | break; | ||
198 | } | 333 | } |
199 | } | 334 | } |
200 | 335 | if (rle >= rle_limit) { | |
201 | x2_scaled = SCALED_TO_INT((x + rlelen) * x_scale); | 336 | zone_state = 6; |
202 | if (o && mask) { | 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); | ||
203 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); | 356 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); |
204 | } | 357 | } |
205 | 358 | x += rle_this_bite; | |
206 | x1_scaled = x2_scaled; | 359 | if (x >= src_width ) { |
207 | x += rlelen; | 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; | ||
208 | rle++; | 392 | rle++; |
209 | if (rle >= rle_limit) break; | 393 | } else { |
394 | rle_this_bite = src_width - x; | ||
395 | rle_remainder -= rle_this_bite; | ||
396 | zone_state = 2; | ||
210 | } | 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; | ||
461 | rle++; | ||
462 | if (rle >= rle_limit) { | ||
463 | zone_state = 6; | ||
464 | } | ||
465 | break; | ||
466 | case 6: /* Finished */ | ||
467 | _x_abort(); | ||
211 | 468 | ||
469 | case 7: /* No button */ | ||
470 | clut = (clut_t*) img_overl->color; | ||
471 | trans = img_overl->trans; | ||
472 | o = trans[clr]; | ||
473 | rle_this_bite = rle_remainder; | ||
474 | rle_remainder = 0; | ||
475 | rlelen -= rle_this_bite; | ||
476 | if (o) { | ||
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); | ||
480 | } | ||
481 | x += rle_this_bite; | ||
482 | if (x >= src_width ) { | ||
483 | x -= src_width; | ||
212 | img_pix += img_width; | 484 | img_pix += img_width; |
@@ -221,2 +493,3 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, | |||
221 | } | 493 | } |
494 | rle_start = rle; | ||
222 | } else { | 495 | } else { |
@@ -225,2 +498,17 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, | |||
225 | } | 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 | ; | ||
508 | } | ||
509 | } | ||
510 | #ifdef LOG_BLEND_RGB16 | ||
511 | printf("blend_rgb16 ended\n"); | ||
512 | #endif | ||
513 | |||
226 | } | 514 | } |
@@ -229,6 +517,5 @@ 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; |
@@ -248,47 +535,87 @@ void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, | |||
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) { |
561 | if (rle >= rle_limit) | ||
562 | break; | ||
563 | |||
272 | rlelen = rle->len; | 564 | rlelen = rle->len; |
565 | clr = rle->color; | ||
566 | rle++; | ||
567 | } | ||
273 | 568 | ||
274 | if (o && mask) { | 569 | if (!mask) { |
275 | /* threat cases where clipping border is inside rle->len pixels */ | 570 | /* above or below clipping area */ |
276 | if ( img_overl->clip_left > x ) { | 571 | |
277 | if( img_overl->clip_left < x + rlelen ) { | 572 | rle_bite = rlelen; |
278 | x1_scaled = SCALED_TO_INT( img_overl->clip_left * x_scale ); | 573 | /* choose palette for surrounding area */ |
279 | rlelen -= img_overl->clip_left - x; | 574 | colors = (clut_t*)img_overl->color; |
280 | x += img_overl->clip_left - x; | 575 | trans = img_overl->trans; |
281 | } else { | 576 | } else { |
282 | o = 0; | 577 | /* treat cases where clipping border is inside rle->len pixels */ |
283 | } | 578 | if ( x < img_overl->clip_left ) { |
284 | } else if( clip_right < x + rlelen ) { | 579 | /* starts left */ |
285 | if( clip_right > x ) { | 580 | if( x + rlelen > img_overl->clip_left ) { |
286 | x2_scaled = SCALED_TO_INT( clip_right * x_scale); | 581 | /* ends not left */ |
287 | mem_blend24(img_pix + x1_scaled*3, clut[clr].cb, | 582 | |
288 | clut[clr].cr, clut[clr].y, | 583 | /* choose the largest "bite" up to palette change */ |
289 | o, x2_scaled-x1_scaled); | 584 | rle_bite = img_overl->clip_left - x; |
290 | o = 0; | 585 | /* choose palette for surrounding area */ |
586 | colors = (clut_t*)img_overl->color; | ||
587 | trans = img_overl->trans; | ||
588 | } else { | ||
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; | ||
595 | } | ||
596 | } else if( x + rlelen > clip_right ) { | ||
597 | /* ends right */ | ||
598 | if( x < clip_right ) { | ||
599 | /* starts not right */ | ||
600 | |||
601 | /* choose the largest "bite" up to palette change */ | ||
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 | } |
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; | ||
294 | } | 621 | } |
@@ -296,6 +623,8 @@ void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, | |||
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); |
@@ -304,5 +633,4 @@ void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, | |||
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 | } |
@@ -327,6 +655,5 @@ 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; |
@@ -346,47 +673,87 @@ void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, | |||
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; | ||
367 | 696 | ||
368 | clr = rle->color; | 697 | /* take next element from rle list everytime an element is finished */ |
369 | o = trans[clr]; | 698 | if (rlelen <= 0) { |
699 | if (rle >= rle_limit) | ||
700 | break; | ||
701 | |||
370 | rlelen = rle->len; | 702 | rlelen = rle->len; |
703 | clr = rle->color; | ||
704 | rle++; | ||
705 | } | ||
371 | 706 | ||
372 | if (o && mask) { | 707 | if (!mask) { |
373 | /* threat cases where clipping border is inside rle->len pixels */ | 708 | /* above or below clipping area */ |
374 | if ( img_overl->clip_left > x ) { | 709 | |
375 | if( img_overl->clip_left < x + rlelen ) { | 710 | rle_bite = rlelen; |
376 | x1_scaled = SCALED_TO_INT( img_overl->clip_left * x_scale ); | 711 | /* choose palette for surrounding area */ |
377 | rlelen -= img_overl->clip_left - x; | 712 | colors = (clut_t*)img_overl->color; |
378 | x += img_overl->clip_left - x; | 713 | trans = img_overl->trans; |
379 | } else { | ||
380 | o = 0; | ||
381 | } | ||
382 | } else if( clip_right < x + rlelen ) { | ||
383 | if( clip_right > x ) { | ||
384 | x2_scaled = SCALED_TO_INT( clip_right * x_scale); | ||
385 | mem_blend24_32(img_pix + x1_scaled*4, clut[clr].cb, | ||
386 | clut[clr].cr, clut[clr].y, | ||
387 | o, x2_scaled-x1_scaled); | ||
388 | o = 0; | ||
389 | } else { | 714 | } else { |
390 | o = 0; | 715 | /* treat cases where clipping border is inside rle->len pixels */ |
716 | if ( x < img_overl->clip_left ) { | ||
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; | ||
726 | } else { | ||
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; | ||
733 | } | ||
734 | } else if( x + rlelen > clip_right ) { | ||
735 | /* ends right */ | ||
736 | if( x < clip_right ) { | ||
737 | /* starts not right */ | ||
738 | |||
739 | /* choose the largest "bite" up to palette change */ | ||
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; | ||
744 | } else { | ||
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 | } |
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; | ||
392 | } | 759 | } |
@@ -394,7 +761,7 @@ void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, | |||
394 | 761 | ||
395 | x2_scaled = SCALED_TO_INT((x + rlelen) * x_scale); | 762 | x2_scaled = SCALED_TO_INT((x + rle_bite) * x_scale); |
396 | if (o && mask) { | 763 | |
397 | mem_blend24_32(img_pix + x1_scaled*4, clut[clr].cb, | 764 | o = trans[clr]; |
398 | clut[clr].cr, clut[clr].y, | 765 | if (o) { |
399 | o, x2_scaled-x1_scaled); | 766 | mem_blend32(img_pix + x1_scaled*4, (uint8_t *)&colors[clr], o, x2_scaled-x1_scaled); |
400 | } | 767 | } |
@@ -402,5 +769,4 @@ void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, | |||
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 | } |
@@ -432,5 +798,105 @@ static void mem_blend8(uint8_t *mem, uint8_t val, uint8_t o, size_t sz) | |||
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; |
@@ -444,2 +910,4 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
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; |
@@ -452,7 +920,10 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
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 |
@@ -464,10 +935,26 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
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; |
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 | } | ||
473 | 960 | ||
@@ -475,3 +962,10 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
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; |
@@ -483,2 +977,10 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
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 |
@@ -488,3 +990,5 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
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 | } |
@@ -501,3 +1005,2 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
501 | rle_remainder = src_width - x; | 1005 | rle_remainder = src_width - x; |
502 | ; | ||
503 | } | 1006 | } |
@@ -508,5 +1011,5 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
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 |
@@ -515,3 +1018,3 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
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; |
@@ -559,3 +1062,3 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
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 ) { |
@@ -599,2 +1102,19 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
599 | #endif | 1102 | #endif |
1103 | |||
1104 | if (x < (dst_width - x_off)) { | ||
1105 | /* clip against right edge of destination area */ | ||
1106 | if ((x + rle_this_bite) > (dst_width - x_off)) { | ||
1107 | int toClip = (x + rle_this_bite) - (dst_width - x_off); | ||
1108 | |||
1109 | rle_this_bite -= toClip; | ||
1110 | rle_remainder += toClip; | ||
1111 | rlelen += toClip; | ||
1112 | } | ||
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 | |||
600 | if (o) { | 1120 | if (o) { |
@@ -602,5 +1122,7 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
602 | memset(dst_y + x, my_clut[clr].y, rle_this_bite); | 1122 | memset(dst_y + x, my_clut[clr].y, rle_this_bite); |
603 | if (y & 1) { | 1123 | if (!enable_exact_blending) { |
604 | memset(dst_cr + (x >> 1), my_clut[clr].cr, (rle_this_bite+1) >> 1); | 1124 | if ((y + y_odd) & 1) { |
605 | memset(dst_cb + (x >> 1), my_clut[clr].cb, (rle_this_bite+1) >> 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 | } | ||
606 | } | 1128 | } |
@@ -608,6 +1130,8 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
608 | mem_blend8(dst_y + x, my_clut[clr].y, o, rle_this_bite); | 1130 | mem_blend8(dst_y + x, my_clut[clr].y, o, rle_this_bite); |
609 | if (y & 1) { | 1131 | if (!enable_exact_blending) { |
1132 | if ((y + y_odd) & 1) { | ||
610 | /* Blending cr and cb should use a different function, with pre -128 to each sample */ | 1133 | /* 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); | 1134 | mem_blend8(dst_cr + ((x + x_odd) >> 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); | 1135 | mem_blend8(dst_cb + ((x + x_odd) >> 1), my_clut[clr].cb, o, (rle_this_bite+1) >> 1); |
1136 | } | ||
613 | } | 1137 | } |
@@ -615,2 +1139,8 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
615 | 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 | } |
@@ -620,23 +1150,38 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
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 | } | 1151 | } |
1152 | |||
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; | ||
627 | } | 1165 | } |
628 | if (rle >= rle_limit) { | ||
629 | #ifdef LOG_BLEND_YUV | ||
630 | printf("x-rle_limit\n"); | ||
631 | #endif | ||
632 | break; | ||
633 | } | 1166 | } |
634 | 1167 | ||
635 | dst_y += dst_width; | 1168 | dst_cr += dst_pitches[2]; |
1169 | dst_cb += dst_pitches[1]; | ||
1170 | } | ||
636 | 1171 | ||
637 | if (y & 1) { | 1172 | dst_y += dst_pitches[0]; |
638 | dst_cr += (dst_width + 1) / 2; | ||
639 | dst_cb += (dst_width + 1) / 2; | ||
640 | } | 1173 | } |
1174 | |||
1175 | if (enable_exact_blending) { | ||
1176 | /* blend buffered lines */ | ||
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); | ||
641 | } | 1181 | } |
1182 | |||
1183 | blend_yuv_exact(dst_cr, dst_cb, exact_blend_width, x_odd, blend_yuv_data); | ||
1184 | } | ||
1185 | } | ||
1186 | |||
642 | #ifdef LOG_BLEND_YUV | 1187 | #ifdef LOG_BLEND_YUV |
@@ -646,5 +1191,94 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | |||
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; |
@@ -658,9 +1292,25 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, | |||
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; | ||
664 | 1301 | ||
665 | uint8_t *dst_y = dst_img + 2 * (dst_width * y_off + x_off); | 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; | ||
1314 | |||
1315 | uint8_t *dst_y = dst_img + dst_pitch * y_off + 2 * x_off; | ||
666 | uint8_t *dst; | 1316 | uint8_t *dst; |
@@ -671,13 +1321,32 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, | |||
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; | ||
680 | 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 | } | ||
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 | ||
@@ -685,49 +1354,165 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, | |||
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 | ||
1357 | if (rle >= rle_limit) | ||
1358 | break; | ||
1359 | |||
1360 | if ((rlelen < 0) || (rle_remainder < 0)) { | ||
1361 | #ifdef LOG_BLEND_YUV | ||
1362 | printf("alphablend: major bug in blend_yuv < 0\n"); | ||
1363 | #endif | ||
1364 | } | ||
1365 | if (rlelen == 0) { | ||
1366 | rle_remainder = rlelen = rle->len; | ||
690 | clr = rle->color; | 1367 | clr = rle->color; |
691 | o = my_trans[clr]; | 1368 | rle++; |
692 | rlelen = rle->len; | 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 | ||
693 | 1380 | ||
694 | if (o && mask) { | 1381 | if (ymask == 0) { |
695 | /* threat cases where clipping border is inside rle->len pixels */ | 1382 | if (x < img_overl->clip_left) { |
696 | if ( img_overl->clip_left > x ) { | 1383 | /* Starts outside clip area */ |
697 | if( img_overl->clip_left < x + rlelen ) { | 1384 | if ((x + rle_remainder) > img_overl->clip_left ) { |
698 | rlelen -= img_overl->clip_left - x; | 1385 | #ifdef LOG_BLEND_YUV |
699 | x += img_overl->clip_left - x; | 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; | ||
1394 | } else { | ||
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; | ||
1404 | } | ||
1405 | } else if (x < clip_right) { | ||
1406 | /* Starts inside clip area */ | ||
1407 | if ((x + rle_remainder) > clip_right ) { | ||
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; | ||
700 | } else { | 1417 | } else { |
701 | 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; | ||
702 | } | 1427 | } |
703 | } else if( clip_right < x + rlelen ) { | 1428 | } else if (x >= clip_right) { |
704 | if( clip_right > x ) { | 1429 | /* Starts outside clip area, ends outsite clip area */ |
705 | /* fixme: case not implemented */ | 1430 | if ((x + rle_remainder ) > src_width ) { |
706 | o = 0; | 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; | ||
707 | } else { | 1441 | } else { |
708 | o = 0; | 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 | } | ||
709 | } | 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; | ||
710 | } | 1461 | } |
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; | ||
711 | } | 1472 | } |
712 | 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 | } | ||
713 | 1479 | ||
714 | if (o && mask) { | 1480 | if (o) { |
715 | l = rlelen>>1; | 1481 | if (!enable_exact_blending) { |
716 | if( !(x & 1) ) { | 1482 | l = rle_this_bite>>1; |
717 | yuy2 = my_clut[clr].y + (my_clut[clr].cb << 8) + | 1483 | if( !((x_odd+x) & 1) ) { |
718 | (my_clut[clr].y << 16) + (my_clut[clr].cr << 24); | 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; | ||
719 | } else { | 1488 | } else { |
720 | yuy2 = my_clut[clr].y + (my_clut[clr].cr << 8) + | 1489 | yuy2.b[0] = my_clut[clr].y; |
721 | (my_clut[clr].y << 16) + (my_clut[clr].cb << 24); | 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 | } | ||
722 | } | 1494 | } |
723 | |||
724 | if (o >= 15) { | 1495 | if (o >= 15) { |
1496 | if (!enable_exact_blending) { | ||
725 | while(l--) { | 1497 | while(l--) { |
726 | *((uint32_t *)dst)++ = yuy2; | 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; | ||
727 | } | 1506 | } |
728 | if(rlelen & 1) | ||
729 | *((uint16_t *)dst)++ = yuy2 & 0xffff; | ||
730 | } else { | 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) { | ||
731 | if( l ) { | 1516 | if( l ) { |
732 | mem_blend32(dst, (uint8_t *)&yuy2, o, l); | 1517 | mem_blend32(dst, &yuy2.b[0], o, l); |
733 | dst += 4*l; | 1518 | dst += 4*l; |
@@ -735,14 +1520,224 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, | |||
735 | 1520 | ||
736 | if(rlelen & 1) { | 1521 | if(rle_this_bite & 1) { |
737 | *dst = BLEND_BYTE(*dst, *((uint8_t *)&yuy2), o); | 1522 | *dst = BLEND_BYTE(*dst, yuy2.b[0], o); |
738 | dst++; | 1523 | dst++; |
739 | *dst = BLEND_BYTE(*dst, *((uint8_t *)&yuy2+1), o); | 1524 | *dst = BLEND_BYTE(*dst, yuy2.b[1], o); |
740 | dst++; | 1525 | dst++; |
741 | } | 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 | } | ||
1535 | |||
1536 | if (enable_exact_blending) { | ||
1537 | /* remember chroma of current line */ | ||
1538 | memset(&(*blend_yuy2_data)[ 1 ][ x + x_odd ], my_clut[ clr ].cr, rle_this_bite); | ||
1539 | memset(&(*blend_yuy2_data)[ 2 ][ x + x_odd ], my_clut[ clr ].cb, rle_this_bite); | ||
742 | } | 1540 | } |
743 | } else { | 1541 | } else { |
744 | dst += rlelen*2; | 1542 | dst += rle_this_bite*2; |
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); | ||
1553 | |||
1554 | any_line_buffered = 0; | ||
1555 | } | ||
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; | ||
745 | } | 1580 | } |
746 | 1581 | ||
747 | x += rlelen; | 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; | ||
1736 | } | ||
1737 | } else { | ||
1738 | memblend_xx44(dst,norm_pixel,len, alphamask); | ||
1739 | dst += len; | ||
1740 | } | ||
1741 | } | ||
1742 | x += rle->len; | ||
748 | rle++; | 1743 | rle++; |
@@ -751,5 +1746,39 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, | |||
751 | if (rle >= rle_limit) break; | 1746 | if (rle >= rle_limit) break; |
1747 | dst_y += dst_pitch; | ||
1748 | } | ||
1749 | } | ||
752 | 1750 | ||
753 | dst_y += dst_width*2; | 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; | ||
754 | } | 1756 | } |
1757 | |||
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); | ||
755 | } | 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; | ||
1780 | } | ||
1781 | |||
1782 | extra_data->buffer_size = 0; | ||
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 | |||
@@ -29,2 +29,31 @@ | |||
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 */ |
@@ -34,3 +63,19 @@ typedef struct { /* CLUT == Color LookUp Table */ | |||
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 | ||
@@ -38,3 +83,4 @@ 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 | ||
@@ -42,3 +88,4 @@ 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 | ||
@@ -46,11 +93,41 @@ 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 | ||
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 | |||
@@ -51,18 +51,13 @@ 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 | } |
@@ -129,3 +124,6 @@ void Lib::initialize() | |||
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 | ||
@@ -141,4 +139,2 @@ void Lib::initialize() | |||
141 | 139 | ||
142 | ::null_preload_decoders( m_stream ); | ||
143 | |||
144 | m_duringInitialization = false; | 140 | m_duringInitialization = false; |
@@ -167,6 +163,4 @@ void Lib::resize ( const QSize &s ) { | |||
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 | } |
@@ -424,3 +418,3 @@ void Lib::showVideoFullScreen( bool fullScreen ) { | |||
424 | 418 | ||
425 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 419 | #warning use xine |
426 | } | 420 | } |
@@ -430,3 +424,4 @@ bool Lib::isVideoFullScreen() const { | |||
430 | 424 | ||
431 | return ::null_is_fullscreen( m_videoOutput ); | 425 | #warning use xine |
426 | return false; | ||
432 | } | 427 | } |
@@ -436,3 +431,4 @@ void Lib::setScaling( bool scale ) { | |||
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 | } |
@@ -441,4 +437,3 @@ 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 | } |
@@ -448,3 +443,4 @@ bool Lib::isScaling() const { | |||
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 | } |
@@ -460,10 +456,34 @@ void Lib::xine_display_frame( void* user_data, uint8_t *frame, | |||
460 | 456 | ||
461 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 457 | void Lib::xine_vo_scale_cb( void *user_data, int video_with, int video_height, |
462 | assert( m_initialized ); | 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; | ||
463 | 465 | ||
464 | if ( !m_video ) { | 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() ) | ||
465 | return; | 478 | return; |
479 | |||
480 | *dest_width = size.width(); | ||
481 | *dest_height = size.height(); | ||
466 | } | 482 | } |
467 | 483 | ||
468 | // assert( m_wid ); | 484 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
485 | assert( m_initialized ); | ||
486 | |||
487 | if ( !m_video ) | ||
488 | return; | ||
469 | 489 | ||
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 | |||
@@ -196,2 +196,3 @@ namespace XINE { | |||
196 | XineVideoWidget *m_wid; | 196 | XineVideoWidget *m_wid; |
197 | QSize m_videoSize; | ||
197 | xine_t *m_xine; | 198 | xine_t *m_xine; |
@@ -210,2 +211,5 @@ namespace XINE { | |||
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 | }; |
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 | |||
@@ -4,3 +4,2 @@ | |||
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> |
@@ -42,3 +41,2 @@ | |||
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> |
@@ -53,3 +51,3 @@ | |||
53 | /* | 51 | /* |
54 | #define LOG | 52 | * #define LOG |
55 | */ | 53 | */ |
@@ -59,2 +57,6 @@ 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 | ||
@@ -65,6 +67,4 @@ struct null_driver_s { | |||
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 | ||
@@ -73,3 +73,3 @@ struct null_driver_s { | |||
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; |
@@ -80,9 +80,10 @@ struct null_driver_s { | |||
80 | 80 | ||
81 | int gui_width; | 81 | /* |
82 | int gui_height; | 82 | * DISPLAY to widget... |
83 | int gui_changed; | 83 | */ |
84 | |||
85 | double display_ratio; | ||
86 | void* caller; | ||
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 | }; |
@@ -112,4 +113,4 @@ struct opie_frame_s { | |||
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 | } |
@@ -121,4 +122,14 @@ static void null_frame_proc_slice (vo_frame_t *vo_img, uint8_t **src) { | |||
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; |
@@ -144,3 +155,3 @@ static void null_frame_field (vo_frame_t *vo_img, int 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; |
@@ -148,3 +159,3 @@ static void null_frame_field (vo_frame_t *vo_img, int which_field) { | |||
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; |
@@ -152,3 +163,3 @@ static void null_frame_field (vo_frame_t *vo_img, int which_field) { | |||
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; |
@@ -179,2 +190,4 @@ static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ | |||
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 | ||
@@ -189,2 +202,3 @@ static vo_frame_t* null_alloc_frame( vo_driver_t* 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; |
@@ -231,3 +245,2 @@ static void null_frame_reallocate( null_driver_t *this, opie_frame_t *frame, | |||
231 | */ | 245 | */ |
232 | if( frame->data ) { | ||
233 | if( frame->chunk[0] ){ | 246 | if( frame->chunk[0] ){ |
@@ -244,4 +257,4 @@ static void null_frame_reallocate( null_driver_t *this, opie_frame_t *frame, | |||
244 | } | 257 | } |
258 | if(frame->data) | ||
245 | free ( frame->data ); | 259 | free ( frame->data ); |
246 | } | ||
247 | 260 | ||
@@ -312,6 +325,13 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, | |||
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) |
@@ -322,5 +342,4 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, | |||
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; |
@@ -331,5 +350,4 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, | |||
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 | ||
@@ -365,3 +383,3 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, | |||
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; |
@@ -369,3 +387,3 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, | |||
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; |
@@ -373,3 +391,3 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, | |||
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; |
@@ -389,3 +407,3 @@ static void null_display_frame( vo_driver_t* self, vo_frame_t *frame_gen ){ | |||
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, |
@@ -444,3 +462,3 @@ static void null_overlay_blend ( vo_driver_t *this_gen, vo_frame_t *frame_gen, | |||
444 | case 16: | 462 | case 16: |
445 | blend_rgb16((uint8_t *)frame->data, | 463 | blend_rgb16(frame->data, |
446 | overlay, | 464 | overlay, |
@@ -449,6 +467,7 @@ static void null_overlay_blend ( vo_driver_t *this_gen, vo_frame_t *frame_gen, | |||
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, |
@@ -457,6 +476,7 @@ static void null_overlay_blend ( vo_driver_t *this_gen, vo_frame_t *frame_gen, | |||
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, |
@@ -465,3 +485,4 @@ static void null_overlay_blend ( vo_driver_t *this_gen, vo_frame_t *frame_gen, | |||
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; |
@@ -476,3 +497,2 @@ static void null_overlay_blend ( vo_driver_t *this_gen, vo_frame_t *frame_gen, | |||
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; |
@@ -492,6 +512,2 @@ static int null_get_property( vo_driver_t* self, int property ){ | |||
492 | } | 512 | } |
493 | #else | ||
494 | property = property; | ||
495 | self = self; | ||
496 | #endif | ||
497 | 513 | ||
@@ -501,3 +517,2 @@ 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; |
@@ -519,6 +534,2 @@ static int null_set_property( vo_driver_t* self, int property, | |||
519 | } | 534 | } |
520 | #else | ||
521 | self = self; | ||
522 | property = property; | ||
523 | #endif | ||
524 | 535 | ||
@@ -529,7 +540,9 @@ static void null_get_property_min_max( vo_driver_t* self, | |||
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 | } |
@@ -538,6 +551,2 @@ static int null_gui_data_exchange( vo_driver_t* self, | |||
538 | void *data ){ | 551 | void *data ){ |
539 | self = self; | ||
540 | data_type = data_type; | ||
541 | data = data; | ||
542 | |||
543 | return 0; | 552 | return 0; |
@@ -547,2 +556,3 @@ 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 ); |
@@ -550,5 +560,4 @@ static void null_dispose ( vo_driver_t* self ){ | |||
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 | } |
@@ -559,23 +568,19 @@ xine_video_port_t* init_video_out_plugin( xine_t *xine, | |||
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 | ||
@@ -586,3 +591,5 @@ xine_video_port_t* init_video_out_plugin( xine_t *xine, | |||
586 | vo->vo_driver.display_frame = null_display_frame; | 591 | vo->vo_driver.display_frame = null_display_frame; |
592 | vo->vo_driver.overlay_begin = 0; | ||
587 | vo->vo_driver.overlay_blend = null_overlay_blend; | 593 | vo->vo_driver.overlay_blend = null_overlay_blend; |
594 | vo->vo_driver.overlay_end = 0; | ||
588 | vo->vo_driver.get_property = null_get_property; | 595 | vo->vo_driver.get_property = null_get_property; |
@@ -594,9 +601,13 @@ xine_video_port_t* init_video_out_plugin( xine_t *xine, | |||
594 | 601 | ||
595 | |||
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; |
@@ -623,27 +634,2 @@ void null_set_show_video( xine_vo_driver_t* self, int show ) { | |||
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 | ||
@@ -699,5 +685,2 @@ void null_set_mode( xine_vo_driver_t* self, int depth, int rgb ) { | |||
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 | }; |
@@ -707,3 +690,3 @@ void null_display_handler( xine_vo_driver_t* self, display_xine_frame_t t, | |||
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; |
@@ -711,25 +694,2 @@ void null_display_handler( xine_vo_driver_t* self, display_xine_frame_t t, | |||
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 | |||
@@ -3,3 +3,4 @@ | |||
3 | * | 3 | * |
4 | * This file is part of xine, a unix video player. | 4 | * Copyright (C) 2003-2004 the xine project |
5 | * This file is part of xine, a free video player. | ||
5 | * | 6 | * |
@@ -33,4 +34,10 @@ | |||
33 | #include "yuv2rgb.h" | 34 | #include "yuv2rgb.h" |
34 | #include <xine/xineutils.h> | ||
35 | 35 | ||
36 | #define LOG_MODULE "yuv2rgb" | ||
37 | #define LOG_VERBOSE | ||
38 | /* | ||
39 | #define LOG | ||
40 | */ | ||
41 | |||
42 | #include <xine/xineutils.h> | ||
36 | 43 | ||
@@ -53,4 +60,4 @@ const int32_t Inverse_Table_6_9[8][4] = { | |||
53 | 60 | ||
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; |
@@ -61,3 +68,3 @@ static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) { | |||
61 | 68 | ||
62 | while ((int) pMem % alignment) | 69 | while ((uintptr_t) pMem % alignment) |
63 | pMem++; | 70 | pMem++; |
@@ -68,2 +75,39 @@ static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) { | |||
68 | 75 | ||
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, |
@@ -87,2 +131,4 @@ static int yuv2rgb_configure (yuv2rgb_t *this, | |||
87 | this->rgb_stride = rgb_stride; | 131 | this->rgb_stride = rgb_stride; |
132 | this->slice_height = source_height; | ||
133 | this->slice_offset = 0; | ||
88 | 134 | ||
@@ -101,2 +147,12 @@ static int yuv2rgb_configure (yuv2rgb_t *this, | |||
101 | 147 | ||
148 | #ifdef HAVE_MLIB | ||
149 | if (this->mlib_chunk) { | ||
150 | free (this->mlib_chunk); | ||
151 | this->mlib_buffer = this->mlib_chunk = NULL; | ||
152 | } | ||
153 | if (this->mlib_resize_chunk) { | ||
154 | free (this->mlib_resize_chunk); | ||
155 | this->mlib_resize_buffer = this->mlib_resize_chunk = NULL; | ||
156 | } | ||
157 | #endif | ||
102 | 158 | ||
@@ -104,3 +160,6 @@ static int yuv2rgb_configure (yuv2rgb_t *this, | |||
104 | this->step_dy = source_height * 32768 / dest_height; | 160 | this->step_dy = source_height * 32768 / dest_height; |
105 | 161 | /* | |
162 | printf("yuv2rgb config: src_ht=%i, dst_ht=%i\n",source_height, dest_height); | ||
163 | printf("yuv2rgb config: step_dy=%i %f\n",this->step_dy, (float)this->step_dy / 32768.0); | ||
164 | */ | ||
106 | this->scale_line = find_scale_line_func(this->step_dx); | 165 | this->scale_line = find_scale_line_func(this->step_dx); |
@@ -140,2 +199,15 @@ static int yuv2rgb_configure (yuv2rgb_t *this, | |||
140 | return 0; | 199 | return 0; |
200 | |||
201 | #if HAVE_MLIB | ||
202 | /* Only need these if we are resizing and in mlib code */ | ||
203 | this->mlib_buffer = my_malloc_aligned (16, source_width*source_height*4, &this->mlib_chunk); | ||
204 | if (!this->mlib_buffer) | ||
205 | return 0; | ||
206 | /* Only need this one if we are 24 bit */ | ||
207 | if((rgb_stride / dest_width) == 3) { | ||
208 | this->mlib_resize_buffer = my_malloc_aligned (16, dest_width*dest_height*4, &this->mlib_resize_chunk); | ||
209 | if (!this->mlib_resize_buffer) | ||
210 | return 0; | ||
211 | } | ||
212 | #endif | ||
141 | } | 213 | } |
@@ -144,3 +216,2 @@ static int yuv2rgb_configure (yuv2rgb_t *this, | |||
144 | 216 | ||
145 | |||
146 | static void scale_line_gen (uint8_t *source, uint8_t *dest, | 217 | static void scale_line_gen (uint8_t *source, uint8_t *dest, |
@@ -1206,2 +1277,6 @@ static scale_line_func_t find_scale_line_func(int step) { | |||
1206 | int i; | 1277 | int i; |
1278 | #ifdefLOG | ||
1279 | /* to filter out multiple messages about the scale_line variant we're using */ | ||
1280 | static int reported_for_step; | ||
1281 | #endif | ||
1207 | 1282 | ||
@@ -1209,3 +1284,7 @@ static scale_line_func_t find_scale_line_func(int step) { | |||
1209 | if (step == scale_line[i].src_step*32768/scale_line[i].dest_step) { | 1284 | if (step == scale_line[i].src_step*32768/scale_line[i].dest_step) { |
1210 | //printf("yuv2rgb: using %s optimized scale_line\n", scale_line[i].desc); | 1285 | #ifdefLOG |
1286 | if (step != reported_for_step) | ||
1287 | printf("yuv2rgb: using %s optimized scale_line\n", scale_line[i].desc); | ||
1288 | reported_for_step = step; | ||
1289 | #endif | ||
1211 | return scale_line[i].func; | 1290 | return scale_line[i].func; |
@@ -1213,5 +1292,10 @@ static scale_line_func_t find_scale_line_func(int step) { | |||
1213 | } | 1292 | } |
1214 | //printf("yuv2rgb: using generic scale_line with interpolation\n"); | ||
1215 | return scale_line_gen; | ||
1216 | 1293 | ||
1294 | #ifdefLOG | ||
1295 | if (step != reported_for_step) | ||
1296 | printf("yuv2rgb: using generic scale_line with interpolation\n"); | ||
1297 | reported_for_step = step; | ||
1298 | #endif | ||
1299 | |||
1300 | return scale_line_gen; | ||
1217 | } | 1301 | } |
@@ -1274,3 +1358,3 @@ static void scale_line_4 (uint8_t *source, uint8_t *dest, | |||
1274 | 1358 | ||
1275 | #define RGB(i) \ | 1359 | #define X_RGB(i) \ |
1276 | U = pu[i]; \ | 1360 | U = pu[i]; \ |
@@ -1350,3 +1434,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
1350 | dy = 0; | 1434 | dy = 0; |
1351 | dst_height = this->dest_height; | 1435 | dst_height = this->next_slice (this, &_dst); |
1352 | 1436 | ||
@@ -1361,12 +1445,12 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
1361 | do { | 1445 | do { |
1362 | RGB(0); | 1446 | X_RGB(0); |
1363 | DST1(0); | 1447 | DST1(0); |
1364 | 1448 | ||
1365 | RGB(1); | 1449 | X_RGB(1); |
1366 | DST1(1); | 1450 | DST1(1); |
1367 | 1451 | ||
1368 | RGB(2); | 1452 | X_RGB(2); |
1369 | DST1(2); | 1453 | DST1(2); |
1370 | 1454 | ||
1371 | RGB(3); | 1455 | X_RGB(3); |
1372 | DST1(3); | 1456 | DST1(3); |
@@ -1414,3 +1498,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
1414 | } else { | 1498 | } else { |
1415 | height = this->source_height >> 1; | 1499 | height = this->next_slice (this, &_dst) >> 1; |
1416 | do { | 1500 | do { |
@@ -1425,3 +1509,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
1425 | do { | 1509 | do { |
1426 | RGB(0); | 1510 | X_RGB(0); |
1427 | DST1(0); | 1511 | DST1(0); |
@@ -1429,3 +1513,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
1429 | 1513 | ||
1430 | RGB(1); | 1514 | X_RGB(1); |
1431 | DST2(1); | 1515 | DST2(1); |
@@ -1433,3 +1517,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
1433 | 1517 | ||
1434 | RGB(2); | 1518 | X_RGB(2); |
1435 | DST1(2); | 1519 | DST1(2); |
@@ -1437,3 +1521,3 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | |||
1437 | 1521 | ||
1438 | RGB(3); | 1522 | X_RGB(3); |
1439 | DST2(3); | 1523 | DST2(3); |
@@ -1481,3 +1565,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
1481 | dy = 0; | 1565 | dy = 0; |
1482 | dst_height = this->dest_height; | 1566 | dst_height = this->next_slice (this, &_dst); |
1483 | 1567 | ||
@@ -1492,12 +1576,12 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
1492 | do { | 1576 | do { |
1493 | RGB(0); | 1577 | X_RGB(0); |
1494 | DST1RGB(0); | 1578 | DST1RGB(0); |
1495 | 1579 | ||
1496 | RGB(1); | 1580 | X_RGB(1); |
1497 | DST1RGB(1); | 1581 | DST1RGB(1); |
1498 | 1582 | ||
1499 | RGB(2); | 1583 | X_RGB(2); |
1500 | DST1RGB(2); | 1584 | DST1RGB(2); |
1501 | 1585 | ||
1502 | RGB(3); | 1586 | X_RGB(3); |
1503 | DST1RGB(3); | 1587 | DST1RGB(3); |
@@ -1545,3 +1629,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
1545 | } else { | 1629 | } else { |
1546 | height = this->source_height >> 1; | 1630 | height = this->next_slice (this, &_dst) >> 1; |
1547 | do { | 1631 | do { |
@@ -1556,3 +1640,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
1556 | do { | 1640 | do { |
1557 | RGB(0); | 1641 | X_RGB(0); |
1558 | DST1RGB(0); | 1642 | DST1RGB(0); |
@@ -1560,3 +1644,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
1560 | 1644 | ||
1561 | RGB(1); | 1645 | X_RGB(1); |
1562 | DST2RGB(1); | 1646 | DST2RGB(1); |
@@ -1564,3 +1648,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
1564 | 1648 | ||
1565 | RGB(2); | 1649 | X_RGB(2); |
1566 | DST1RGB(2); | 1650 | DST1RGB(2); |
@@ -1568,3 +1652,3 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
1568 | 1652 | ||
1569 | RGB(3); | 1653 | X_RGB(3); |
1570 | DST2RGB(3); | 1654 | DST2RGB(3); |
@@ -1612,3 +1696,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
1612 | dy = 0; | 1696 | dy = 0; |
1613 | dst_height = this->dest_height; | 1697 | dst_height = this->next_slice (this, &_dst); |
1614 | 1698 | ||
@@ -1623,12 +1707,12 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
1623 | do { | 1707 | do { |
1624 | RGB(0); | 1708 | X_RGB(0); |
1625 | DST1BGR(0); | 1709 | DST1BGR(0); |
1626 | 1710 | ||
1627 | RGB(1); | 1711 | X_RGB(1); |
1628 | DST1BGR(1); | 1712 | DST1BGR(1); |
1629 | 1713 | ||
1630 | RGB(2); | 1714 | X_RGB(2); |
1631 | DST1BGR(2); | 1715 | DST1BGR(2); |
1632 | 1716 | ||
1633 | RGB(3); | 1717 | X_RGB(3); |
1634 | DST1BGR(3); | 1718 | DST1BGR(3); |
@@ -1677,3 +1761,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
1677 | } else { | 1761 | } else { |
1678 | height = this->source_height >> 1; | 1762 | height = this->next_slice (this, &_dst) >> 1; |
1679 | do { | 1763 | do { |
@@ -1687,3 +1771,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
1687 | do { | 1771 | do { |
1688 | RGB(0); | 1772 | X_RGB(0); |
1689 | DST1BGR(0); | 1773 | DST1BGR(0); |
@@ -1691,3 +1775,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
1691 | 1775 | ||
1692 | RGB(1); | 1776 | X_RGB(1); |
1693 | DST2BGR(1); | 1777 | DST2BGR(1); |
@@ -1695,3 +1779,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
1695 | 1779 | ||
1696 | RGB(2); | 1780 | X_RGB(2); |
1697 | DST1BGR(2); | 1781 | DST1BGR(2); |
@@ -1699,3 +1783,3 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | |||
1699 | 1783 | ||
1700 | RGB(3); | 1784 | X_RGB(3); |
1701 | DST2BGR(3); | 1785 | DST2BGR(3); |
@@ -1743,3 +1827,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
1743 | dy = 0; | 1827 | dy = 0; |
1744 | dst_height = this->dest_height; | 1828 | dst_height = this->next_slice (this, &_dst); |
1745 | 1829 | ||
@@ -1754,12 +1838,12 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
1754 | do { | 1838 | do { |
1755 | RGB(0); | 1839 | X_RGB(0); |
1756 | DST1(0); | 1840 | DST1(0); |
1757 | 1841 | ||
1758 | RGB(1); | 1842 | X_RGB(1); |
1759 | DST1(1); | 1843 | DST1(1); |
1760 | 1844 | ||
1761 | RGB(2); | 1845 | X_RGB(2); |
1762 | DST1(2); | 1846 | DST1(2); |
1763 | 1847 | ||
1764 | RGB(3); | 1848 | X_RGB(3); |
1765 | DST1(3); | 1849 | DST1(3); |
@@ -1807,3 +1891,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
1807 | } else { | 1891 | } else { |
1808 | height = this->source_height >> 1; | 1892 | height = this->next_slice (this, &_dst) >> 1; |
1809 | do { | 1893 | do { |
@@ -1817,3 +1901,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
1817 | do { | 1901 | do { |
1818 | RGB(0); | 1902 | X_RGB(0); |
1819 | DST1(0); | 1903 | DST1(0); |
@@ -1821,3 +1905,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
1821 | 1905 | ||
1822 | RGB(1); | 1906 | X_RGB(1); |
1823 | DST2(1); | 1907 | DST2(1); |
@@ -1825,3 +1909,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
1825 | 1909 | ||
1826 | RGB(2); | 1910 | X_RGB(2); |
1827 | DST1(2); | 1911 | DST1(2); |
@@ -1829,3 +1913,3 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | |||
1829 | 1913 | ||
1830 | RGB(3); | 1914 | X_RGB(3); |
1831 | DST2(3); | 1915 | DST2(3); |
@@ -1873,3 +1957,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
1873 | dy = 0; | 1957 | dy = 0; |
1874 | dst_height = this->dest_height; | 1958 | dst_height = this->next_slice (this, &_dst); |
1875 | 1959 | ||
@@ -1884,12 +1968,12 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
1884 | do { | 1968 | do { |
1885 | RGB(0); | 1969 | X_RGB(0); |
1886 | DST1(0); | 1970 | DST1(0); |
1887 | 1971 | ||
1888 | RGB(1); | 1972 | X_RGB(1); |
1889 | DST1(1); | 1973 | DST1(1); |
1890 | 1974 | ||
1891 | RGB(2); | 1975 | X_RGB(2); |
1892 | DST1(2); | 1976 | DST1(2); |
1893 | 1977 | ||
1894 | RGB(3); | 1978 | X_RGB(3); |
1895 | DST1(3); | 1979 | DST1(3); |
@@ -1937,3 +2021,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
1937 | } else { | 2021 | } else { |
1938 | height = this->source_height >> 1; | 2022 | height = this->next_slice (this, &_dst) >> 1; |
1939 | do { | 2023 | do { |
@@ -1948,3 +2032,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
1948 | do { | 2032 | do { |
1949 | RGB(0); | 2033 | X_RGB(0); |
1950 | DST1(0); | 2034 | DST1(0); |
@@ -1952,3 +2036,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
1952 | 2036 | ||
1953 | RGB(1); | 2037 | X_RGB(1); |
1954 | DST2(1); | 2038 | DST2(1); |
@@ -1956,3 +2040,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
1956 | 2040 | ||
1957 | RGB(2); | 2041 | X_RGB(2); |
1958 | DST1(2); | 2042 | DST1(2); |
@@ -1960,3 +2044,3 @@ static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | |||
1960 | 2044 | ||
1961 | RGB(3); | 2045 | X_RGB(3); |
1962 | DST2(3); | 2046 | DST2(3); |
@@ -1992,3 +2076,3 @@ static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, | |||
1992 | dy = 0; | 2076 | dy = 0; |
1993 | dst_height = this->dest_height; | 2077 | dst_height = this->next_slice (this, &_dst); |
1994 | 2078 | ||
@@ -2018,3 +2102,3 @@ static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, | |||
2018 | } else { | 2102 | } else { |
2019 | for (height = this->source_height; --height >= 0; ) { | 2103 | for (height = this->next_slice (this, &_dst); --height >= 0; ) { |
2020 | xine_fast_memcpy(_dst, _py, this->dest_width); | 2104 | xine_fast_memcpy(_dst, _py, this->dest_width); |
@@ -2048,3 +2132,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
2048 | dy = 0; | 2132 | dy = 0; |
2049 | dst_height = this->dest_height; | 2133 | dst_height = this->next_slice (this, &_dst); |
2050 | 2134 | ||
@@ -2059,12 +2143,12 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
2059 | do { | 2143 | do { |
2060 | RGB(0); | 2144 | X_RGB(0); |
2061 | DST1CMAP(0); | 2145 | DST1CMAP(0); |
2062 | 2146 | ||
2063 | RGB(1); | 2147 | X_RGB(1); |
2064 | DST1CMAP(1); | 2148 | DST1CMAP(1); |
2065 | 2149 | ||
2066 | RGB(2); | 2150 | X_RGB(2); |
2067 | DST1CMAP(2); | 2151 | DST1CMAP(2); |
2068 | 2152 | ||
2069 | RGB(3); | 2153 | X_RGB(3); |
2070 | DST1CMAP(3); | 2154 | DST1CMAP(3); |
@@ -2112,3 +2196,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
2112 | } else { | 2196 | } else { |
2113 | height = this->source_height >> 1; | 2197 | height = this->next_slice (this, &_dst) >> 1; |
2114 | do { | 2198 | do { |
@@ -2122,3 +2206,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
2122 | do { | 2206 | do { |
2123 | RGB(0); | 2207 | X_RGB(0); |
2124 | DST1CMAP(0); | 2208 | DST1CMAP(0); |
@@ -2126,3 +2210,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
2126 | 2210 | ||
2127 | RGB(1); | 2211 | X_RGB(1); |
2128 | DST2CMAP(1); | 2212 | DST2CMAP(1); |
@@ -2130,3 +2214,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
2130 | 2214 | ||
2131 | RGB(2); | 2215 | X_RGB(2); |
2132 | DST1CMAP(2); | 2216 | DST1CMAP(2); |
@@ -2134,3 +2218,3 @@ static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | |||
2134 | 2218 | ||
2135 | RGB(3); | 2219 | X_RGB(3); |
2136 | DST2CMAP(3); | 2220 | DST2CMAP(3); |
@@ -2163,3 +2247,4 @@ static int div_round (int dividend, int divisor) | |||
2163 | 2247 | ||
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 | { |
@@ -2179,2 +2264,5 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
2179 | 2264 | ||
2265 | int mode = this->mode; | ||
2266 | int swapped = this->swapped; | ||
2267 | |||
2180 | for (i = 0; i < 1024; i++) { | 2268 | for (i = 0; i < 1024; i++) { |
@@ -2182,3 +2270,3 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
2182 | 2270 | ||
2183 | j = (76309 * (i - 384 - 16) + 32768) >> 16; | 2271 | j = (76309 * (i - 384 - 16 + brightness) + 32768) >> 16; |
2184 | j = (j < 0) ? 0 : ((j > 255) ? 255 : j); | 2272 | j = (j < 0) ? 0 : ((j > 255) ? 255 : j); |
@@ -2190,3 +2278,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
2190 | case MODE_32_BGR: | 2278 | case MODE_32_BGR: |
2191 | table_32 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t)); | 2279 | if (this->table_base == NULL) { |
2280 | this->table_base = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t)); | ||
2281 | } | ||
2282 | table_32 = this->table_base; | ||
2192 | 2283 | ||
@@ -2219,3 +2310,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
2219 | case MODE_24_BGR: | 2310 | case MODE_24_BGR: |
2220 | table_8 = malloc ((256 + 2*232) * sizeof (uint8_t)); | 2311 | if (this->table_base == NULL) { |
2312 | this->table_base = malloc ((256 + 2*232) * sizeof (uint8_t)); | ||
2313 | } | ||
2314 | table_8 = this->table_base; | ||
2221 | 2315 | ||
@@ -2232,3 +2326,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
2232 | case MODE_16_RGB: | 2326 | case MODE_16_RGB: |
2233 | table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); | 2327 | if (this->table_base == NULL) { |
2328 | this->table_base = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); | ||
2329 | } | ||
2330 | table_16 = this->table_base; | ||
2234 | 2331 | ||
@@ -2272,3 +2369,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
2272 | case MODE_8_BGR: | 2369 | case MODE_8_BGR: |
2273 | table_8 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); | 2370 | if (this->table_base == NULL) { |
2371 | this->table_base = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); | ||
2372 | } | ||
2373 | table_8 = this->table_base; | ||
2274 | 2374 | ||
@@ -2296,3 +2396,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
2296 | case MODE_PALETTE: | 2396 | case MODE_PALETTE: |
2297 | table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); | 2397 | if (this->table_base == NULL) { |
2398 | this->table_base = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); | ||
2399 | } | ||
2400 | table_16 = this->table_base; | ||
2298 | 2401 | ||
@@ -2320,4 +2423,4 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
2320 | default: | 2423 | default: |
2321 | fprintf (stderr, "mode %d not supported by yuv2rgb\n", mode); | 2424 | lprintf ("mode %d not supported by yuv2rgb\n", mode); |
2322 | abort(); | 2425 | _x_abort(); |
2323 | } | 2426 | } |
@@ -2333,4 +2436,6 @@ static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped | |||
2333 | } | 2436 | } |
2334 | this->gamma = 0; | 2437 | |
2335 | this->entry_size = entry_size; | 2438 | #if defined(ARCH_X86) || defined(ARCH_X86_64) |
2439 | mmx_yuv2rgb_set_csc_levels (this, brightness, contrast, saturation); | ||
2440 | #endif | ||
2336 | } | 2441 | } |
@@ -2450,4 +2555,4 @@ static void yuv2rgb_c_init (yuv2rgb_factory_t *this) | |||
2450 | default: | 2555 | default: |
2451 | printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode); | 2556 | lprintf ("mode %d not supported by yuv2rgb\n", this->mode); |
2452 | abort(); | 2557 | _x_abort(); |
2453 | } | 2558 | } |
@@ -2493,4 +2598,4 @@ static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) { | |||
2493 | default: | 2598 | default: |
2494 | printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode); | 2599 | lprintf ("mode %d not supported by yuv2rgb\n", this->mode); |
2495 | abort(); | 2600 | _x_abort(); |
2496 | } | 2601 | } |
@@ -2522,3 +2627,3 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2522 | dy = 0; | 2627 | dy = 0; |
2523 | height = this->dest_height; | 2628 | height = this->next_slice (this, &_dst); |
2524 | 2629 | ||
@@ -2534,12 +2639,12 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2534 | 2639 | ||
2535 | RGB(0); | 2640 | X_RGB(0); |
2536 | DST1(0); | 2641 | DST1(0); |
2537 | 2642 | ||
2538 | RGB(1); | 2643 | X_RGB(1); |
2539 | DST1(1); | 2644 | DST1(1); |
2540 | 2645 | ||
2541 | RGB(2); | 2646 | X_RGB(2); |
2542 | DST1(2); | 2647 | DST1(2); |
2543 | 2648 | ||
2544 | RGB(3); | 2649 | X_RGB(3); |
2545 | DST1(3); | 2650 | DST1(3); |
@@ -2566,3 +2671,3 @@ static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2566 | 2671 | ||
2567 | _p += this->y_stride*2*(dy>>15); | 2672 | _p += this->y_stride*(dy>>15); |
2568 | dy &= 32767; | 2673 | dy &= 32767; |
@@ -2601,3 +2706,3 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2601 | dy = 0; | 2706 | dy = 0; |
2602 | height = this->dest_height; | 2707 | height = this->next_slice (this, &_dst); |
2603 | 2708 | ||
@@ -2612,12 +2717,12 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2612 | do { | 2717 | do { |
2613 | RGB(0); | 2718 | X_RGB(0); |
2614 | DST1RGB(0); | 2719 | DST1RGB(0); |
2615 | 2720 | ||
2616 | RGB(1); | 2721 | X_RGB(1); |
2617 | DST1RGB(1); | 2722 | DST1RGB(1); |
2618 | 2723 | ||
2619 | RGB(2); | 2724 | X_RGB(2); |
2620 | DST1RGB(2); | 2725 | DST1RGB(2); |
2621 | 2726 | ||
2622 | RGB(3); | 2727 | X_RGB(3); |
2623 | DST1RGB(3); | 2728 | DST1RGB(3); |
@@ -2644,3 +2749,3 @@ static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2644 | 2749 | ||
2645 | _p += this->y_stride*2*(dy>>15); | 2750 | _p += this->y_stride*(dy>>15); |
2646 | dy &= 32767; | 2751 | dy &= 32767; |
@@ -2679,3 +2784,3 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2679 | dy = 0; | 2784 | dy = 0; |
2680 | height = this->dest_height; | 2785 | height = this->next_slice (this, &_dst); |
2681 | 2786 | ||
@@ -2690,12 +2795,12 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2690 | do { | 2795 | do { |
2691 | RGB(0); | 2796 | X_RGB(0); |
2692 | DST1BGR(0); | 2797 | DST1BGR(0); |
2693 | 2798 | ||
2694 | RGB(1); | 2799 | X_RGB(1); |
2695 | DST1BGR(1); | 2800 | DST1BGR(1); |
2696 | 2801 | ||
2697 | RGB(2); | 2802 | X_RGB(2); |
2698 | DST1BGR(2); | 2803 | DST1BGR(2); |
2699 | 2804 | ||
2700 | RGB(3); | 2805 | X_RGB(3); |
2701 | DST1BGR(3); | 2806 | DST1BGR(3); |
@@ -2722,3 +2827,3 @@ static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2722 | 2827 | ||
2723 | _p += this->y_stride*2*(dy>>15); | 2828 | _p += this->y_stride*(dy>>15); |
2724 | dy &= 32767; | 2829 | dy &= 32767; |
@@ -2753,3 +2858,3 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2753 | dy = 0; | 2858 | dy = 0; |
2754 | height = this->dest_height; | 2859 | height = this->next_slice (this, &_dst); |
2755 | 2860 | ||
@@ -2764,12 +2869,12 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2764 | do { | 2869 | do { |
2765 | RGB(0); | 2870 | X_RGB(0); |
2766 | DST1(0); | 2871 | DST1(0); |
2767 | 2872 | ||
2768 | RGB(1); | 2873 | X_RGB(1); |
2769 | DST1(1); | 2874 | DST1(1); |
2770 | 2875 | ||
2771 | RGB(2); | 2876 | X_RGB(2); |
2772 | DST1(2); | 2877 | DST1(2); |
2773 | 2878 | ||
2774 | RGB(3); | 2879 | X_RGB(3); |
2775 | DST1(3); | 2880 | DST1(3); |
@@ -2796,3 +2901,3 @@ static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2796 | 2901 | ||
2797 | _p += this->y_stride*2*(dy>>15); | 2902 | _p += this->y_stride*(dy>>15); |
2798 | dy &= 32767; | 2903 | dy &= 32767; |
@@ -2827,3 +2932,3 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2827 | dy = 0; | 2932 | dy = 0; |
2828 | height = this->dest_height; | 2933 | height = this->next_slice (this, &_dst); |
2829 | 2934 | ||
@@ -2838,12 +2943,12 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2838 | do { | 2943 | do { |
2839 | RGB(0); | 2944 | X_RGB(0); |
2840 | DST1(0); | 2945 | DST1(0); |
2841 | 2946 | ||
2842 | RGB(1); | 2947 | X_RGB(1); |
2843 | DST1(1); | 2948 | DST1(1); |
2844 | 2949 | ||
2845 | RGB(2); | 2950 | X_RGB(2); |
2846 | DST1(2); | 2951 | DST1(2); |
2847 | 2952 | ||
2848 | RGB(3); | 2953 | X_RGB(3); |
2849 | DST1(3); | 2954 | DST1(3); |
@@ -2870,3 +2975,3 @@ static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2870 | 2975 | ||
2871 | _p += this->y_stride*2*(dy>>15); | 2976 | _p += this->y_stride*(dy>>15); |
2872 | dy &= 32767; | 2977 | dy &= 32767; |
@@ -2891,3 +2996,3 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2891 | dy = 0; | 2996 | dy = 0; |
2892 | height = this->dest_height; | 2997 | height = this->next_slice (this, &_dst); |
2893 | 2998 | ||
@@ -2910,3 +3015,3 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2910 | 3015 | ||
2911 | _p += this->y_stride*2*(dy>>15); | 3016 | _p += this->y_stride*(dy>>15); |
2912 | dy &= 32767; | 3017 | dy &= 32767; |
@@ -2914,3 +3019,3 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2914 | } else { | 3019 | } else { |
2915 | for (height = this->source_height; --height >= 0; ) { | 3020 | for (height = this->next_slice (this, &_dst); --height >= 0; ) { |
2916 | dst = _dst; | 3021 | dst = _dst; |
@@ -2922,3 +3027,3 @@ static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2922 | _dst += this->rgb_stride; | 3027 | _dst += this->rgb_stride; |
2923 | _p += this->y_stride*2; | 3028 | _p += this->y_stride; |
2924 | } | 3029 | } |
@@ -2944,3 +3049,3 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2944 | dy = 0; | 3049 | dy = 0; |
2945 | height = this->dest_height; | 3050 | height = this->next_slice (this, &_dst); |
2946 | 3051 | ||
@@ -2955,12 +3060,12 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2955 | do { | 3060 | do { |
2956 | RGB(0); | 3061 | X_RGB(0); |
2957 | DST1CMAP(0); | 3062 | DST1CMAP(0); |
2958 | 3063 | ||
2959 | RGB(1); | 3064 | X_RGB(1); |
2960 | DST1CMAP(1); | 3065 | DST1CMAP(1); |
2961 | 3066 | ||
2962 | RGB(2); | 3067 | X_RGB(2); |
2963 | DST1CMAP(2); | 3068 | DST1CMAP(2); |
2964 | 3069 | ||
2965 | RGB(3); | 3070 | X_RGB(3); |
2966 | DST1CMAP(3); | 3071 | DST1CMAP(3); |
@@ -2987,3 +3092,3 @@ static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | |||
2987 | 3092 | ||
2988 | _p += this->y_stride*2*(dy>>15); | 3093 | _p += this->y_stride*(dy>>15); |
2989 | dy &= 32767; | 3094 | dy &= 32767; |
@@ -3035,3 +3140,3 @@ static void yuy22rgb_c_init (yuv2rgb_factory_t *this) | |||
3035 | default: | 3140 | default: |
3036 | printf ("yuv2rgb: mode %d not supported for yuy2\n", this->mode); | 3141 | lprintf ("mode %d not supported for yuy2\n", this->mode); |
3037 | } | 3142 | } |
@@ -3039,3 +3144,3 @@ static void yuy22rgb_c_init (yuv2rgb_factory_t *this) | |||
3039 | 3144 | ||
3040 | yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { | 3145 | static yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { |
3041 | 3146 | ||
@@ -3043,2 +3148,3 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { | |||
3043 | 3148 | ||
3149 | this->swapped = factory->swapped; | ||
3044 | this->cmap = factory->cmap; | 3150 | this->cmap = factory->cmap; |
@@ -3049,2 +3155,8 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { | |||
3049 | 3155 | ||
3156 | #ifdef HAVE_MLIB | ||
3157 | this->mlib_chunk = this->mlib_buffer = NULL; | ||
3158 | this->mlib_resize_chunk = this->mlib_resize_buffer = NULL; | ||
3159 | this->mlib_filter_type = MLIB_BILINEAR; | ||
3160 | #endif | ||
3161 | |||
3050 | this->table_rV = factory->table_rV; | 3162 | this->table_rV = factory->table_rV; |
@@ -3053,2 +3165,3 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { | |||
3053 | this->table_bU = factory->table_bU; | 3165 | this->table_bU = factory->table_bU; |
3166 | this->table_mmx = factory->table_mmx; | ||
3054 | 3167 | ||
@@ -3059,2 +3172,4 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { | |||
3059 | this->configure = yuv2rgb_configure; | 3172 | this->configure = yuv2rgb_configure; |
3173 | this->next_slice = yuv2rgb_next_slice; | ||
3174 | this->dispose = yuv2rgb_dispose; | ||
3060 | return this; | 3175 | return this; |
@@ -3065,20 +3180,8 @@ yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { | |||
3065 | */ | 3180 | */ |
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 | } |
@@ -3089,6 +3192,3 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, | |||
3089 | yuv2rgb_factory_t *this; | 3192 | yuv2rgb_factory_t *this; |
3090 | |||
3091 | #ifdef ARCH_X86 | ||
3092 | uint32_t mm = xine_mm_accel(); | 3193 | uint32_t mm = xine_mm_accel(); |
3093 | #endif | ||
3094 | 3194 | ||
@@ -3100,8 +3200,11 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, | |||
3100 | this->create_converter = yuv2rgb_create_converter; | 3200 | this->create_converter = yuv2rgb_create_converter; |
3101 | this->set_gamma = yuv2rgb_set_gamma; | 3201 | this->set_csc_levels = yuv2rgb_set_csc_levels; |
3102 | this->get_gamma = yuv2rgb_get_gamma; | 3202 | this->dispose = yuv2rgb_factory_dispose; |
3103 | this->matrix_coefficients = 6; | 3203 | this->matrix_coefficients = 6; |
3204 | this->table_base = NULL; | ||
3205 | this->table_mmx = NULL; | ||
3206 | this->table_mmx_base = NULL; | ||
3104 | 3207 | ||
3105 | 3208 | ||
3106 | yuv2rgb_setup_tables (this, mode, swapped); | 3209 | yuv2rgb_set_csc_levels (this, 0, 128, 128); |
3107 | 3210 | ||
@@ -3112,3 +3215,3 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, | |||
3112 | this->yuv2rgb_fun = NULL; | 3215 | this->yuv2rgb_fun = NULL; |
3113 | #ifdef ARCH_X86 | 3216 | #if defined(ARCH_X86) || defined(ARCH_X86_64) |
3114 | if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMXEXT)) { | 3217 | if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMXEXT)) { |
@@ -3117,4 +3220,6 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, | |||
3117 | 3220 | ||
3221 | #ifdef LOG | ||
3118 | if (this->yuv2rgb_fun != NULL) | 3222 | if (this->yuv2rgb_fun != NULL) |
3119 | printf ("yuv2rgb: using MMXEXT for colorspace transform\n"); | 3223 | printf ("yuv2rgb: using MMXEXT for colorspace transform\n"); |
3224 | #endif | ||
3120 | } | 3225 | } |
@@ -3125,8 +3230,19 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, | |||
3125 | 3230 | ||
3231 | #ifdef LOG | ||
3126 | if (this->yuv2rgb_fun != NULL) | 3232 | if (this->yuv2rgb_fun != NULL) |
3127 | printf ("yuv2rgb: using MMX for colorspace transform\n"); | 3233 | printf ("yuv2rgb: using MMX for colorspace transform\n"); |
3234 | #endif | ||
3128 | } | 3235 | } |
3236 | #ifdef __arm__ | ||
3237 | if (this->yuv2rgb_fun == NULL) { | ||
3238 | yuv2rgb_init_arm ( this ); | ||
3239 | |||
3240 | if(this->yuv2rgb_fun != NULL) | ||
3241 | printf("yuv2rgb: using arm4l assembler for colorspace transform\n" ); | ||
3242 | } | ||
3243 | #endif | ||
3244 | |||
3129 | #endif | 3245 | #endif |
3130 | #if HAVE_MLIB | 3246 | #if HAVE_MLIB |
3131 | if (this->yuv2rgb_fun == NULL) { | 3247 | if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_MLIB)) { |
3132 | 3248 | ||
@@ -3134,12 +3250,6 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, | |||
3134 | 3250 | ||
3251 | #ifdef LOG | ||
3135 | if (this->yuv2rgb_fun != NULL) | 3252 | if (this->yuv2rgb_fun != NULL) |
3136 | printf ("yuv2rgb: using medialib for colorspace transform\n"); | 3253 | printf ("yuv2rgb: using medialib for colorspace transform\n"); |
3137 | } | ||
3138 | #endif | 3254 | #endif |
3139 | #ifdef __arm__ | ||
3140 | if (this->yuv2rgb_fun == NULL) { | ||
3141 | yuv2rgb_init_arm ( this ); | ||
3142 | |||
3143 | if(this->yuv2rgb_fun != NULL) | ||
3144 | printf("yuv2rgb: using arm4l assembler for colorspace transform\n" ); | ||
3145 | } | 3255 | } |
@@ -3147,3 +3257,4 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, | |||
3147 | if (this->yuv2rgb_fun == NULL) { | 3257 | if (this->yuv2rgb_fun == NULL) { |
3148 | printf ("yuv2rgb: no accelerated colorspace conversion found\n"); | 3258 | lprintf ("no accelerated colorspace conversion found\n"); |
3259 | |||
3149 | yuv2rgb_c_init (this); | 3260 | yuv2rgb_c_init (this); |
@@ -3166,2 +3277 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, | |||
3166 | } | 3277 | } |
3167 | |||
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 | |||
@@ -4,2 +4,6 @@ | |||
4 | 4 | ||
5 | #ifdef HAVE_MLIB | ||
6 | #include <mlib_video.h> | ||
7 | #endif | ||
8 | |||
5 | #include <inttypes.h> | 9 | #include <inttypes.h> |
@@ -24,3 +28,2 @@ typedef uint32_t (*yuv2rgb_single_pixel_fun_t) (yuv2rgb_t *this, uint8_t y, uint | |||
24 | 28 | ||
25 | |||
26 | /* | 29 | /* |
@@ -43,3 +46,2 @@ typedef uint32_t (*yuv2rgb_single_pixel_fun_t) (yuv2rgb_t *this, uint8_t y, uint | |||
43 | struct yuv2rgb_s { | 46 | struct yuv2rgb_s { |
44 | |||
45 | /* | 47 | /* |
@@ -54,2 +56,12 @@ struct yuv2rgb_s { | |||
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 |
@@ -76,4 +88,5 @@ struct yuv2rgb_s { | |||
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 | ||
@@ -86,2 +99,10 @@ struct yuv2rgb_s { | |||
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; |
@@ -90,2 +111,3 @@ struct yuv2rgb_s { | |||
90 | void **table_bU; | 111 | void **table_bU; |
112 | void *table_mmx; | ||
91 | 113 | ||
@@ -93,3 +115,2 @@ struct yuv2rgb_s { | |||
93 | scale_line_func_t scale_line; | 115 | scale_line_func_t scale_line; |
94 | |||
95 | } ; | 116 | } ; |
@@ -101,3 +122,2 @@ struct yuv2rgb_s { | |||
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); |
@@ -105,11 +125,12 @@ struct yuv2rgb_factory_s { | |||
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 | ||
@@ -121,7 +142,5 @@ struct yuv2rgb_factory_s { | |||
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]; |
@@ -130,2 +149,4 @@ struct yuv2rgb_factory_s { | |||
130 | void *table_bU[256]; | 149 | void *table_bU[256]; |
150 | void *table_mmx_base; | ||
151 | void *table_mmx; | ||
131 | 152 | ||
@@ -135,3 +156,2 @@ struct yuv2rgb_factory_s { | |||
135 | yuv2rgb_single_pixel_fun_t yuv2rgb_single_pixel_fun; | 156 | yuv2rgb_single_pixel_fun_t yuv2rgb_single_pixel_fun; |
136 | |||
137 | }; | 157 | }; |
@@ -145,3 +165,4 @@ yuv2rgb_factory_t *yuv2rgb_factory_init (int mode, int swapped, uint8_t *colorma | |||
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); |
@@ -149,3 +170,2 @@ 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 | ||