1 /*****************************************************************************
2 * blend.c: alpha blend 2 pictures together
3 *****************************************************************************
4 * Copyright (C) 2003-2008 the VideoLAN team
7 * Authors: Gildas Bazin <gbazin@videolan.org>
8 * Antoine Cellerier <dionoea @t videolan dot org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
33 #include <vlc_common.h>
34 #include <vlc_plugin.h>
36 #include "vlc_filter.h"
38 /*****************************************************************************
40 *****************************************************************************/
41 static int OpenFilter ( vlc_object_t * );
42 static void CloseFilter( vlc_object_t * );
45 set_description( N_("Video pictures blending") );
46 set_capability( "video blending", 100 );
47 set_callbacks( OpenFilter, CloseFilter );
51 /*****************************************************************************
52 * filter_sys_t : filter descriptor
53 *****************************************************************************/
59 #define FCC_YUVA VLC_FOURCC('Y','U','V','A')
60 #define FCC_YUVP VLC_FOURCC('Y','U','V','P')
61 #define FCC_RGBA VLC_FOURCC('R','G','B','A')
63 #define FCC_I420 VLC_FOURCC('I','4','2','0')
64 #define FCC_YV12 VLC_FOURCC('Y','V','1','2')
65 #define FCC_YUY2 VLC_FOURCC('Y','U','Y','2')
66 #define FCC_UYVY VLC_FOURCC('U','Y','V','Y')
67 #define FCC_YVYU VLC_FOURCC('Y','V','Y','U')
68 #define FCC_RV15 VLC_FOURCC('R','V','1','5')
69 #define FCC_RV16 VLC_FOURCC('R','V','1','6')
70 #define FCC_RV24 VLC_FOURCC('R','V','2','4')
71 #define FCC_RV32 VLC_FOURCC('R','V','3','2')
73 /****************************************************************************
75 ****************************************************************************/
76 static void Blend( filter_t *, picture_t *, picture_t *, picture_t *,
80 static void BlendI420( filter_t *, picture_t *, picture_t *, picture_t *,
81 int, int, int, int, int );
82 static void BlendR16( filter_t *, picture_t *, picture_t *, picture_t *,
83 int, int, int, int, int );
84 static void BlendR24( filter_t *, picture_t *, picture_t *, picture_t *,
85 int, int, int, int, int );
86 static void BlendYUVPacked( filter_t *, picture_t *, picture_t *, picture_t *,
87 int, int, int, int, int );
90 static void BlendI420I420( filter_t *, picture_t *, picture_t *, picture_t *,
91 int, int, int, int, int );
92 static void BlendI420I420_no_alpha(
93 filter_t *, picture_t *, picture_t *, picture_t *,
95 static void BlendI420R16( filter_t *, picture_t *, picture_t *, picture_t *,
96 int, int, int, int, int );
97 static void BlendI420R24( filter_t *, picture_t *, picture_t *, picture_t *,
98 int, int, int, int, int );
99 static void BlendI420YUVPacked( filter_t *, picture_t *, picture_t *,
100 picture_t *, int, int, int, int, int );
103 static void BlendPalI420( filter_t *, picture_t *, picture_t *, picture_t *,
104 int, int, int, int, int );
105 static void BlendPalYUVPacked( filter_t *, picture_t *, picture_t *, picture_t *,
106 int, int, int, int, int );
107 static void BlendPalRV( filter_t *, picture_t *, picture_t *, picture_t *,
108 int, int, int, int, int );
111 static void BlendRGBAI420( filter_t *, picture_t *, picture_t *, picture_t *,
112 int, int, int, int, int );
113 static void BlendRGBAYUVPacked( filter_t *, picture_t *, picture_t *,
114 picture_t *, int, int, int, int, int );
115 static void BlendRGBAR16( filter_t *, picture_t *, picture_t *, picture_t *,
116 int, int, int, int, int );
117 static void BlendRGBAR24( filter_t *, picture_t *, picture_t *, picture_t *,
118 int, int, int, int, int );
120 static void video_format_FixRgb( video_format_t *p_fmt );
122 /*****************************************************************************
123 * OpenFilter: probe the filter and return score
124 *****************************************************************************/
125 static int OpenFilter( vlc_object_t *p_this )
127 filter_t *p_filter = (filter_t*)p_this;
130 /* Check if we can handle that format.
131 * We could try to use a chroma filter if we can't. */
132 int in_chroma = p_filter->fmt_in.video.i_chroma;
133 int out_chroma = p_filter->fmt_out.video.i_chroma;
134 if( ( in_chroma != FCC_YUVA && in_chroma != FCC_I420 &&
135 in_chroma != FCC_YV12 && in_chroma != FCC_YUVP &&
136 in_chroma != FCC_RGBA ) ||
137 ( out_chroma != FCC_I420 && out_chroma != FCC_YUY2 &&
138 out_chroma != FCC_YV12 && out_chroma != FCC_UYVY &&
139 out_chroma != FCC_YVYU && out_chroma != FCC_RV15 &&
140 out_chroma != FCC_YVYU && out_chroma != FCC_RV16 &&
141 out_chroma != FCC_RV24 && out_chroma != FCC_RV32 ) )
146 /* Allocate the memory needed to store the decoder's structure */
147 p_filter->p_sys = p_sys = malloc(sizeof(filter_sys_t));
152 p_filter->pf_video_blend = Blend;
154 msg_Dbg( p_filter, "chroma: %4.4s -> %4.4s",
155 (char *)&p_filter->fmt_in.video.i_chroma,
156 (char *)&p_filter->fmt_out.video.i_chroma );
161 /*****************************************************************************
162 * CloseFilter: clean up the filter
163 *****************************************************************************/
164 static void CloseFilter( vlc_object_t *p_this )
166 filter_t *p_filter = (filter_t*)p_this;
167 filter_sys_t *p_sys = p_filter->p_sys;
172 /****************************************************************************
173 * Blend: the whole thing
174 ****************************************************************************
175 * This function is called just after the thread is launched.
176 ****************************************************************************/
177 typedef void (*BlendFunction)( filter_t *, picture_t *,
178 picture_t *, picture_t *,
179 int , int , int , int , int );
181 #define FCC_PLANAR_420 { FCC_I420, FCC_YV12, 0 }
182 #define FCC_PACKED_422 { FCC_YUY2, FCC_UYVY, FCC_YVYU, 0 }
183 #define FCC_RGB_16 { FCC_RV15, FCC_RV16, 0 }
184 #define FCC_RGB_24 { FCC_RV24, FCC_RV32, 0 }
186 #define BLEND_CFG( fccSrc, fctPlanar, fctPacked, fctRgb16, fctRgb24 ) \
187 { .src = fccSrc, .p_dst = FCC_PLANAR_420, .pf_blend = fctPlanar }, \
188 { .src = fccSrc, .p_dst = FCC_PACKED_422, .pf_blend = fctPacked }, \
189 { .src = fccSrc, .p_dst = FCC_RGB_16, .pf_blend = fctRgb16 }, \
190 { .src = fccSrc, .p_dst = FCC_RGB_24, .pf_blend = fctRgb24 }
195 vlc_fourcc_t p_dst[16];
196 BlendFunction pf_blend;
199 BLEND_CFG( FCC_YUVA, BlendI420, BlendYUVPacked, BlendR16, BlendR24 ),
201 BLEND_CFG( FCC_YUVP, BlendPalI420, BlendPalYUVPacked, BlendPalRV, BlendPalRV ),
203 BLEND_CFG( FCC_RGBA, BlendRGBAI420, BlendRGBAYUVPacked, BlendRGBAR16, BlendRGBAR24 ),
205 BLEND_CFG( FCC_I420, BlendI420I420, BlendI420YUVPacked, BlendI420R16, BlendI420R24 ),
207 BLEND_CFG( FCC_YV12, BlendI420I420, BlendI420YUVPacked, BlendI420R16, BlendI420R24 ),
212 static void Blend( filter_t *p_filter, picture_t *p_dst,
213 picture_t *p_dst_orig, picture_t *p_src,
214 int i_x_offset, int i_y_offset, int i_alpha )
216 int i_width, i_height;
221 i_width = __MIN((int)p_filter->fmt_out.video.i_visible_width - i_x_offset,
222 (int)p_filter->fmt_in.video.i_visible_width);
224 i_height = __MIN((int)p_filter->fmt_out.video.i_visible_height -i_y_offset,
225 (int)p_filter->fmt_in.video.i_visible_height);
227 if( i_width <= 0 || i_height <= 0 )
230 video_format_FixRgb( &p_filter->fmt_out.video );
231 video_format_FixRgb( &p_filter->fmt_in.video );
234 msg_Dbg( p_filter, "chroma: %4.4s -> %4.4s\n",
235 (char *)&p_filter->fmt_in.video.i_chroma,
236 (char *)&p_filter->fmt_out.video.i_chroma );
239 for( int i = 0; p_blend_cfg[i].src != 0; i++ )
241 if( p_blend_cfg[i].src != p_filter->fmt_in.video.i_chroma )
243 for( int j = 0; p_blend_cfg[i].p_dst[j] != 0; j++ )
245 if( p_blend_cfg[i].p_dst[j] != p_filter->fmt_out.video.i_chroma )
248 p_blend_cfg[i].pf_blend( p_filter, p_dst, p_dst_orig, p_src,
249 i_x_offset, i_y_offset, i_width, i_height, i_alpha );
254 msg_Dbg( p_filter, "no matching alpha blending routine "
255 "(chroma: %4.4s -> %4.4s)",
256 (char *)&p_filter->fmt_in.video.i_chroma,
257 (char *)&p_filter->fmt_out.video.i_chroma );
260 /***********************************************************************
262 ***********************************************************************/
263 static inline uint8_t vlc_uint8( int v )
272 #define MAX_TRANS 255
275 static inline int vlc_blend( int v1, int v2, int a )
277 /* TODO bench if the tests really increase speed */
280 else if( a == MAX_TRANS )
282 return ( v1 * a + v2 * (MAX_TRANS - a ) ) >> TRANS_BITS;
285 static inline int vlc_alpha( int t, int a )
289 return (t * a) / 255;
292 static inline void yuv_to_rgb( int *r, int *g, int *b,
293 uint8_t y1, uint8_t u1, uint8_t v1 )
295 /* macros used for YUV pixel conversions */
296 # define SCALEBITS 10
297 # define ONE_HALF (1 << (SCALEBITS - 1))
298 # define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
300 int y, cb, cr, r_add, g_add, b_add;
304 r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;
305 g_add = - FIX(0.34414*255.0/224.0) * cb
306 - FIX(0.71414*255.0/224.0) * cr + ONE_HALF;
307 b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;
308 y = (y1 - 16) * FIX(255.0/219.0);
309 *r = vlc_uint8( (y + r_add) >> SCALEBITS );
310 *g = vlc_uint8( (y + g_add) >> SCALEBITS );
311 *b = vlc_uint8( (y + b_add) >> SCALEBITS );
317 static inline void rgb_to_yuv( uint8_t *y, uint8_t *u, uint8_t *v,
318 int r, int g, int b )
320 *y = ( ( ( 66 * r + 129 * g + 25 * b + 128 ) >> 8 ) + 16 );
321 *u = ( ( -38 * r - 74 * g + 112 * b + 128 ) >> 8 ) + 128 ;
322 *v = ( ( 112 * r - 94 * g - 18 * b + 128 ) >> 8 ) + 128 ;
325 static uint8_t *vlc_plane_start( int *pi_pitch,
326 picture_t *p_picture,
328 int i_x_offset, int i_y_offset,
329 const video_format_t *p_fmt,
332 const int i_pitch = p_picture->p[i_plane].i_pitch;
333 uint8_t *p_pixels = p_picture->p[i_plane].p_pixels;
335 const int i_dx = ( i_x_offset + p_fmt->i_x_offset ) / r;
336 const int i_dy = ( i_y_offset + p_fmt->i_y_offset ) / r;
340 return &p_pixels[ i_dy * i_pitch + i_dx ];
343 static void vlc_yuv_packed_index( int *pi_y, int *pi_u, int *pi_v, vlc_fourcc_t i_chroma )
345 static const struct {
349 { FCC_YUY2, 0, 1, 3 },
350 { FCC_UYVY, 1, 0, 2 },
351 { FCC_YVYU, 0, 3, 1 },
356 for( i = 0; p_index[i].chroma != 0; i++ )
358 if( p_index[i].chroma == i_chroma )
361 *pi_y = p_index[i].y;
362 *pi_u = p_index[i].u;
363 *pi_v = p_index[i].v;
366 static void vlc_blend_packed( uint8_t *p_dst, const uint8_t *p_src,
367 int i_offset0, int i_offset1, int i_offset2,
368 int c0, int c1, int c2, int i_alpha,
371 p_dst[i_offset0] = vlc_blend( c0, p_src[i_offset0], i_alpha );
374 p_dst[i_offset1] = vlc_blend( c1, p_src[i_offset1], i_alpha );
375 p_dst[i_offset2] = vlc_blend( c2, p_src[i_offset2], i_alpha );
379 static void vlc_blend_rgb16( uint16_t *p_dst, const uint16_t *p_src,
380 int R, int G, int B, int i_alpha,
381 const video_format_t *p_fmt )
383 const int i_pix = *p_src;
384 const int r = ( i_pix & p_fmt->i_rmask ) >> p_fmt->i_lrshift;
385 const int g = ( i_pix & p_fmt->i_gmask ) >> p_fmt->i_lgshift;
386 const int b = ( i_pix & p_fmt->i_bmask ) >> p_fmt->i_lbshift;
388 *p_dst = ( vlc_blend( R >> p_fmt->i_rrshift, r, i_alpha ) << p_fmt->i_lrshift ) |
389 ( vlc_blend( G >> p_fmt->i_rgshift, g, i_alpha ) << p_fmt->i_lgshift ) |
390 ( vlc_blend( B >> p_fmt->i_rbshift, b, i_alpha ) << p_fmt->i_lbshift );
393 /*****************************************************************************
394 * BinaryLog: computes the base 2 log of a binary value
395 *****************************************************************************
396 * This functions is used by MaskToShift, to get a bit index from a binary
398 *****************************************************************************/
399 static int BinaryLog( uint32_t i )
403 if( i == 0 ) return -31337;
405 if( i & 0xffff0000 ) i_log += 16;
406 if( i & 0xff00ff00 ) i_log += 8;
407 if( i & 0xf0f0f0f0 ) i_log += 4;
408 if( i & 0xcccccccc ) i_log += 2;
409 if( i & 0xaaaaaaaa ) i_log += 1;
415 * It transforms a color mask into right and left shifts
416 * FIXME copied from video_output.c
419 static void vlc_rgb_index( int *pi_rindex, int *pi_gindex, int *pi_bindex,
420 const video_format_t *p_fmt )
422 if( p_fmt->i_chroma != FCC_RV24 && p_fmt->i_chroma != FCC_RV32 )
425 /* XXX it will works only if mask are 8 bits aligned */
426 #ifdef WORDS_BIGENDIAN
427 const int i_mask_bits = p_fmt->i_chroma == FCC_RV24 ? 24 : 32;
428 *pi_rindex = ( i_mask_bits - p_fmt->i_lrshift ) / 8;
429 *pi_gindex = ( i_mask_bits - p_fmt->i_lgshift ) / 8;
430 *pi_bindex = ( i_mask_bits - p_fmt->i_lbshift ) / 8;
432 *pi_rindex = p_fmt->i_lrshift / 8;
433 *pi_gindex = p_fmt->i_lgshift / 8;
434 *pi_bindex = p_fmt->i_lbshift / 8;
441 * FIXME copied from video_output.c
443 static void MaskToShift( int *pi_left, int *pi_right, uint32_t i_mask )
445 uint32_t i_low, i_high; /* lower hand higher bits of the mask */
449 *pi_left = *pi_right = 0;
454 i_low = i_high = i_mask;
456 i_low &= - (int32_t)i_low; /* lower bit of the mask */
457 i_high += i_low; /* higher bit of the mask */
459 /* Transform bits into an index. Also deal with i_high overflow, which
460 * is faster than changing the BinaryLog code to handle 64 bit integers. */
461 i_low = BinaryLog (i_low);
462 i_high = i_high ? BinaryLog (i_high) : 32;
464 /* Update pointers and return */
466 *pi_right = (8 - i_high + i_low);
469 /* FIXME should be moved to src/ */
470 static void video_format_FixRgb( video_format_t *p_fmt )
472 if( p_fmt->i_chroma != FCC_RV15 &&
473 p_fmt->i_chroma != FCC_RV16 &&
474 p_fmt->i_chroma != FCC_RV24 &&
475 p_fmt->i_chroma != FCC_RV32 )
478 /* FIXME find right default mask */
479 if( !p_fmt->i_rmask || !p_fmt->i_gmask || !p_fmt->i_bmask )
481 switch( p_fmt->i_chroma )
484 p_fmt->i_rmask = 0x7c00;
485 p_fmt->i_gmask = 0x03e0;
486 p_fmt->i_bmask = 0x001f;
490 p_fmt->i_rmask = 0xf800;
491 p_fmt->i_gmask = 0x07e0;
492 p_fmt->i_bmask = 0x001f;
496 p_fmt->i_rmask = 0xff0000;
497 p_fmt->i_gmask = 0x00ff00;
498 p_fmt->i_bmask = 0x0000ff;
501 p_fmt->i_rmask = 0x00ff0000;
502 p_fmt->i_gmask = 0x0000ff00;
503 p_fmt->i_bmask = 0x000000ff;
512 MaskToShift( &p_fmt->i_lrshift, &p_fmt->i_rrshift,
514 MaskToShift( &p_fmt->i_lgshift, &p_fmt->i_rgshift,
516 MaskToShift( &p_fmt->i_lbshift, &p_fmt->i_rbshift,
520 /***********************************************************************
522 ***********************************************************************/
523 static void BlendI420( filter_t *p_filter, picture_t *p_dst,
524 picture_t *p_dst_orig, picture_t *p_src,
525 int i_x_offset, int i_y_offset,
526 int i_width, int i_height, int i_alpha )
528 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
529 uint8_t *p_src1_y, *p_src2_y, *p_dst_y;
530 uint8_t *p_src1_u, *p_src2_u, *p_dst_u;
531 uint8_t *p_src1_v, *p_src2_v, *p_dst_v;
533 int i_x, i_y, i_trans = 0;
534 bool b_even_scanline = i_y_offset % 2;
536 p_dst_y = vlc_plane_start( &i_dst_pitch, p_dst, Y_PLANE,
537 i_x_offset, i_y_offset, &p_filter->fmt_out.video, 1 );
538 p_dst_u = vlc_plane_start( NULL, p_dst, U_PLANE,
539 i_x_offset, i_y_offset, &p_filter->fmt_out.video, 2 );
540 p_dst_v = vlc_plane_start( NULL, p_dst, V_PLANE,
541 i_x_offset, i_y_offset, &p_filter->fmt_out.video, 2 );
543 p_src1_y = vlc_plane_start( &i_src1_pitch, p_dst_orig, Y_PLANE,
544 i_x_offset, i_y_offset, &p_filter->fmt_out.video, 1 );
545 p_src1_u = vlc_plane_start( NULL, p_dst_orig, U_PLANE,
546 i_x_offset, i_y_offset, &p_filter->fmt_out.video, 2 );
547 p_src1_v = vlc_plane_start( NULL, p_dst_orig, V_PLANE,
548 i_x_offset, i_y_offset, &p_filter->fmt_out.video, 2 );
550 p_src2_y = vlc_plane_start( &i_src2_pitch, p_src, Y_PLANE,
551 0, 0, &p_filter->fmt_in.video, 1 );
552 p_src2_u = vlc_plane_start( NULL, p_src, U_PLANE,
553 0, 0, &p_filter->fmt_in.video, 2 );
554 p_src2_v = vlc_plane_start( NULL, p_src, V_PLANE,
555 0, 0, &p_filter->fmt_in.video, 2 );
556 p_trans = vlc_plane_start( NULL, p_src, A_PLANE,
557 0, 0, &p_filter->fmt_in.video, 1 );
559 /* Draw until we reach the bottom of the subtitle */
560 for( i_y = 0; i_y < i_height; i_y++, p_trans += i_src2_pitch,
561 p_dst_y += i_dst_pitch, p_src1_y += i_src1_pitch,
562 p_src2_y += i_src2_pitch,
563 p_dst_u += b_even_scanline ? i_dst_pitch/2 : 0,
564 p_src1_u += b_even_scanline ? i_src1_pitch/2 : 0,
565 p_src2_u += i_src2_pitch,
566 p_dst_v += b_even_scanline ? i_dst_pitch/2 : 0,
567 p_src1_v += b_even_scanline ? i_src1_pitch/2 : 0,
568 p_src2_v += i_src2_pitch )
570 b_even_scanline = !b_even_scanline;
572 /* Draw until we reach the end of the line */
573 for( i_x = 0; i_x < i_width; i_x++ )
576 i_trans = vlc_alpha( p_trans[i_x], i_alpha );
582 p_dst_y[i_x] = vlc_blend( p_src2_y[i_x], p_src1_y[i_x], i_trans );
583 if( b_even_scanline && i_x % 2 == 0 )
585 p_dst_u[i_x/2] = vlc_blend( p_src2_u[i_x], p_src1_u[i_x/2], i_trans );
586 p_dst_v[i_x/2] = vlc_blend( p_src2_v[i_x], p_src1_v[i_x/2], i_trans );
592 static void BlendR16( filter_t *p_filter, picture_t *p_dst_pic,
593 picture_t *p_dst_orig, picture_t *p_src,
594 int i_x_offset, int i_y_offset,
595 int i_width, int i_height, int i_alpha )
597 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
598 uint8_t *p_dst, *p_src1, *p_src2_y;
599 uint8_t *p_src2_u, *p_src2_v;
601 int i_x, i_y, i_pix_pitch, i_trans = 0;
604 i_pix_pitch = p_dst_pic->p->i_pixel_pitch;
605 i_dst_pitch = p_dst_pic->p->i_pitch;
606 p_dst = p_dst_pic->p->p_pixels + i_x_offset * i_pix_pitch +
607 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
608 p_dst_pic->p->i_pitch *
609 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
611 i_src1_pitch = p_dst_orig->p[Y_PLANE].i_pitch;
612 p_src1 = p_dst_orig->p->p_pixels + i_x_offset * i_pix_pitch +
613 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
614 p_dst_orig->p->i_pitch *
615 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
617 p_src2_y = vlc_plane_start( &i_src2_pitch, p_src, Y_PLANE,
618 0, 0, &p_filter->fmt_in.video, 1 );
619 p_src2_u = vlc_plane_start( NULL, p_src, U_PLANE,
620 0, 0, &p_filter->fmt_in.video, 2 );
621 p_src2_v = vlc_plane_start( NULL, p_src, V_PLANE,
622 0, 0, &p_filter->fmt_in.video, 2 );
623 p_trans = vlc_plane_start( NULL, p_src, A_PLANE,
624 0, 0, &p_filter->fmt_in.video, 1 );
626 /* Draw until we reach the bottom of the subtitle */
627 for( i_y = 0; i_y < i_height; i_y++, p_trans += i_src2_pitch,
628 p_dst += i_dst_pitch, p_src1 += i_src1_pitch,
629 p_src2_y += i_src2_pitch, p_src2_u += i_src2_pitch,
630 p_src2_v += i_src2_pitch )
632 /* Draw until we reach the end of the line */
633 for( i_x = 0; i_x < i_width; i_x++ )
636 i_trans = vlc_alpha( p_trans[i_x], i_alpha );
641 yuv_to_rgb( &r, &g, &b,
642 p_src2_y[i_x], p_src2_u[i_x], p_src2_v[i_x] );
644 vlc_blend_rgb16( (uint16_t*)&p_dst[i_x * i_pix_pitch],
645 (const uint16_t*)&p_src1[i_x * i_pix_pitch],
646 r, g, b, i_trans, &p_filter->fmt_out.video );
651 static void BlendR24( filter_t *p_filter, picture_t *p_dst_pic,
652 picture_t *p_dst_orig, picture_t *p_src,
653 int i_x_offset, int i_y_offset,
654 int i_width, int i_height, int i_alpha )
656 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
657 uint8_t *p_dst, *p_src1, *p_src2_y;
658 uint8_t *p_src2_u, *p_src2_v;
660 int i_x, i_y, i_pix_pitch, i_trans = 0;
663 i_pix_pitch = p_dst_pic->p->i_pixel_pitch;
664 i_dst_pitch = p_dst_pic->p->i_pitch;
665 p_dst = p_dst_pic->p->p_pixels + i_x_offset * i_pix_pitch +
666 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
667 p_dst_pic->p->i_pitch *
668 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
670 i_src1_pitch = p_dst_orig->p->i_pitch;
671 p_src1 = p_dst_orig->p->p_pixels + i_x_offset * i_pix_pitch +
672 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
673 p_dst_orig->p->i_pitch *
674 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
676 p_src2_y = vlc_plane_start( &i_src2_pitch, p_src, Y_PLANE,
677 0, 0, &p_filter->fmt_in.video, 1 );
678 p_src2_u = vlc_plane_start( NULL, p_src, U_PLANE,
679 0, 0, &p_filter->fmt_in.video, 2 );
680 p_src2_v = vlc_plane_start( NULL, p_src, V_PLANE,
681 0, 0, &p_filter->fmt_in.video, 2 );
682 p_trans = vlc_plane_start( NULL, p_src, A_PLANE,
683 0, 0, &p_filter->fmt_in.video, 1 );
685 if( (i_pix_pitch == 4)
686 && (((((intptr_t)p_dst)|((intptr_t)p_src1)|i_dst_pitch|i_src1_pitch)
690 ** if picture pixels are 32 bits long and lines addresses are 32 bit
691 ** aligned, optimize rendering
693 uint32_t *p32_dst = (uint32_t *)p_dst;
694 uint32_t i32_dst_pitch = (uint32_t)(i_dst_pitch>>2);
695 uint32_t *p32_src1 = (uint32_t *)p_src1;
696 uint32_t i32_src1_pitch = (uint32_t)(i_src1_pitch>>2);
698 int i_rshift, i_gshift, i_bshift;
699 uint32_t i_rmask, i_gmask, i_bmask;
701 i_rmask = p_filter->fmt_out.video.i_rmask;
702 i_gmask = p_filter->fmt_out.video.i_gmask;
703 i_bmask = p_filter->fmt_out.video.i_bmask;
704 i_rshift = p_filter->fmt_out.video.i_lrshift;
705 i_gshift = p_filter->fmt_out.video.i_lgshift;
706 i_bshift = p_filter->fmt_out.video.i_lbshift;
708 /* Draw until we reach the bottom of the subtitle */
709 for( i_y = 0; i_y < i_height; i_y++, p_trans += i_src2_pitch,
710 p32_dst += i32_dst_pitch, p32_src1 += i32_src1_pitch,
711 p_src2_y += i_src2_pitch, p_src2_u += i_src2_pitch,
712 p_src2_v += i_src2_pitch )
714 /* Draw until we reach the end of the line */
715 for( i_x = 0; i_x < i_width; i_x++ )
718 i_trans = vlc_alpha( p_trans[i_x], i_alpha );
722 if( i_trans == MAX_TRANS )
724 /* Completely opaque. Completely overwrite underlying pixel */
725 yuv_to_rgb( &r, &g, &b,
726 p_src2_y[i_x], p_src2_u[i_x], p_src2_v[i_x] );
728 p32_dst[i_x] = (r<<i_rshift) |
735 uint32_t i_pix_src1 = p32_src1[i_x];
736 yuv_to_rgb( &r, &g, &b,
737 p_src2_y[i_x], p_src2_u[i_x], p_src2_v[i_x] );
739 p32_dst[i_x] = ( vlc_blend( r, (i_pix_src1 & i_rmask)>>i_rshift, i_trans ) << i_rshift ) |
740 ( vlc_blend( g, (i_pix_src1 & i_gmask)>>i_gshift, i_trans ) << i_gshift ) |
741 ( vlc_blend( b, (i_pix_src1 & i_bmask)>>i_bshift, i_trans ) << i_bshift );
748 int i_rindex, i_gindex, i_bindex;
749 uint32_t i_rmask, i_gmask, i_bmask;
751 i_rmask = p_filter->fmt_out.video.i_rmask;
752 i_gmask = p_filter->fmt_out.video.i_gmask;
753 i_bmask = p_filter->fmt_out.video.i_bmask;
755 vlc_rgb_index( &i_rindex, &i_gindex, &i_bindex, &p_filter->fmt_out.video );
757 /* Draw until we reach the bottom of the subtitle */
758 for( i_y = 0; i_y < i_height; i_y++, p_trans += i_src2_pitch,
759 p_dst += i_dst_pitch, p_src1 += i_src1_pitch,
760 p_src2_y += i_src2_pitch, p_src2_u += i_src2_pitch,
761 p_src2_v += i_src2_pitch )
763 /* Draw until we reach the end of the line */
764 for( i_x = 0; i_x < i_width; i_x++ )
767 i_trans = vlc_alpha( p_trans[i_x], i_alpha );
772 yuv_to_rgb( &r, &g, &b,
773 p_src2_y[i_x], p_src2_u[i_x], p_src2_v[i_x] );
775 vlc_blend_packed( &p_dst[ i_x * i_pix_pitch],
776 &p_src1[i_x * i_pix_pitch],
777 i_rindex, i_gindex, i_bindex,
778 r, g, b, i_alpha, true );
784 static void BlendYUVPacked( filter_t *p_filter, picture_t *p_dst_pic,
785 picture_t *p_dst_orig, picture_t *p_src,
786 int i_x_offset, int i_y_offset,
787 int i_width, int i_height, int i_alpha )
789 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
790 uint8_t *p_dst, *p_src1, *p_src2_y;
791 uint8_t *p_src2_u, *p_src2_v;
793 int i_x, i_y, i_pix_pitch, i_trans = 0;
794 bool b_even = !((i_x_offset + p_filter->fmt_out.video.i_x_offset)%2);
795 int i_l_offset, i_u_offset, i_v_offset;
797 vlc_yuv_packed_index( &i_l_offset, &i_u_offset, &i_v_offset,
798 p_filter->fmt_out.video.i_chroma );
801 i_dst_pitch = p_dst_pic->p->i_pitch;
802 p_dst = p_dst_pic->p->p_pixels + i_x_offset * i_pix_pitch +
803 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
804 p_dst_pic->p->i_pitch *
805 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
807 i_src1_pitch = p_dst_orig->p[Y_PLANE].i_pitch;
808 p_src1 = p_dst_orig->p->p_pixels + i_x_offset * i_pix_pitch +
809 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
810 p_dst_orig->p->i_pitch *
811 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
813 p_src2_y = vlc_plane_start( &i_src2_pitch, p_src, Y_PLANE,
814 0, 0, &p_filter->fmt_in.video, 1 );
815 p_src2_u = vlc_plane_start( NULL, p_src, U_PLANE,
816 0, 0, &p_filter->fmt_in.video, 2 );
817 p_src2_v = vlc_plane_start( NULL, p_src, V_PLANE,
818 0, 0, &p_filter->fmt_in.video, 2 );
819 p_trans = vlc_plane_start( NULL, p_src, A_PLANE,
820 0, 0, &p_filter->fmt_in.video, 1 );
822 i_width &= ~1; /* Needs to be a multiple of 2 */
824 /* Draw until we reach the bottom of the subtitle */
825 for( i_y = 0; i_y < i_height; i_y++, p_trans += i_src2_pitch,
826 p_dst += i_dst_pitch, p_src1 += i_src1_pitch,
827 p_src2_y += i_src2_pitch, p_src2_u += i_src2_pitch,
828 p_src2_v += i_src2_pitch )
830 /* Draw until we reach the end of the line */
831 for( i_x = 0; i_x < i_width; i_x++, b_even = !b_even )
833 i_trans = vlc_alpha( p_trans[i_x], i_alpha );
842 /* FIXME what's with 0xaa ? */
843 if( p_trans[i_x+1] > 0xaa )
845 i_u = (p_src2_u[i_x]+p_src2_u[i_x+1])>>1;
846 i_v = (p_src2_v[i_x]+p_src2_v[i_x+1])>>1;
854 vlc_blend_packed( &p_dst[i_x * 2], &p_src1[i_x * 2],
855 i_l_offset, i_u_offset, i_v_offset,
856 p_src2_y[i_x], i_u, i_v, i_trans, true );
860 p_dst[i_x * 2 + i_l_offset] = vlc_blend( p_src2_y[i_x], p_src1[i_x * 2 + i_l_offset], i_trans );
865 /***********************************************************************
867 ***********************************************************************/
868 static void BlendI420I420( filter_t *p_filter, picture_t *p_dst,
869 picture_t *p_dst_orig, picture_t *p_src,
870 int i_x_offset, int i_y_offset,
871 int i_width, int i_height, int i_alpha )
873 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
874 uint8_t *p_src1_y, *p_src2_y, *p_dst_y;
875 uint8_t *p_src1_u, *p_src2_u, *p_dst_u;
876 uint8_t *p_src1_v, *p_src2_v, *p_dst_v;
878 bool b_even_scanline = i_y_offset % 2;
880 if( i_alpha == 0xff )
882 BlendI420I420_no_alpha( p_filter, p_dst, p_dst_orig, p_src,
883 i_x_offset, i_y_offset, i_width, i_height );
888 i_dst_pitch = p_dst->p[Y_PLANE].i_pitch;
889 p_dst_y = p_dst->p[Y_PLANE].p_pixels + i_x_offset +
890 p_filter->fmt_out.video.i_x_offset +
891 p_dst->p[Y_PLANE].i_pitch *
892 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
893 p_dst_u = p_dst->p[U_PLANE].p_pixels + i_x_offset/2 +
894 p_filter->fmt_out.video.i_x_offset/2 +
895 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
896 p_dst->p[U_PLANE].i_pitch;
897 p_dst_v = p_dst->p[V_PLANE].p_pixels + i_x_offset/2 +
898 p_filter->fmt_out.video.i_x_offset/2 +
899 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
900 p_dst->p[V_PLANE].i_pitch;
902 i_src1_pitch = p_dst_orig->p[Y_PLANE].i_pitch;
903 p_src1_y = p_dst_orig->p[Y_PLANE].p_pixels + i_x_offset +
904 p_filter->fmt_out.video.i_x_offset +
905 p_dst_orig->p[Y_PLANE].i_pitch *
906 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
907 p_src1_u = p_dst_orig->p[U_PLANE].p_pixels + i_x_offset/2 +
908 p_filter->fmt_out.video.i_x_offset/2 +
909 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
910 p_dst_orig->p[U_PLANE].i_pitch;
911 p_src1_v = p_dst_orig->p[V_PLANE].p_pixels + i_x_offset/2 +
912 p_filter->fmt_out.video.i_x_offset/2 +
913 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
914 p_dst_orig->p[V_PLANE].i_pitch;
916 p_src2_y = vlc_plane_start( &i_src2_pitch, p_src, Y_PLANE,
917 0, 0, &p_filter->fmt_in.video, 1 );
918 p_src2_u = vlc_plane_start( NULL, p_src, U_PLANE,
919 0, 0, &p_filter->fmt_in.video, 2 );
920 p_src2_v = vlc_plane_start( NULL, p_src, V_PLANE,
921 0, 0, &p_filter->fmt_in.video, 2 );
924 /* Draw until we reach the bottom of the subtitle */
925 for( i_y = 0; i_y < i_height; i_y++,
926 p_dst_y += i_dst_pitch, p_src1_y += i_src1_pitch,
927 p_src2_y += i_src2_pitch )
929 if( b_even_scanline )
931 p_dst_u += i_dst_pitch/2;
932 p_dst_v += i_dst_pitch/2;
933 p_src1_u += i_src1_pitch/2;
934 p_src1_v += i_src1_pitch/2;
936 b_even_scanline = !b_even_scanline;
938 /* Draw until we reach the end of the line */
939 for( i_x = 0; i_x < i_width; i_x++ )
945 p_dst_y[i_x] = vlc_blend( p_src2_y[i_x], p_src1_y[i_x], i_alpha );
946 if( b_even_scanline && i_x % 2 == 0 )
948 p_dst_u[i_x/2] = vlc_blend( p_src2_u[i_x/2], p_src1_u[i_x/2], i_alpha );
949 p_dst_v[i_x/2] = vlc_blend( p_src2_v[i_x/2], p_src1_v[i_x/2], i_alpha );
954 p_src2_u += i_src2_pitch/2;
955 p_src2_v += i_src2_pitch/2;
959 static void BlendI420I420_no_alpha( filter_t *p_filter, picture_t *p_dst,
960 picture_t *p_dst_orig, picture_t *p_src,
961 int i_x_offset, int i_y_offset,
962 int i_width, int i_height )
964 int i_src2_pitch, i_dst_pitch;
965 uint8_t *p_src2_y, *p_dst_y;
966 uint8_t *p_src2_u, *p_dst_u;
967 uint8_t *p_src2_v, *p_dst_v;
969 bool b_even_scanline = i_y_offset % 2;
971 i_dst_pitch = p_dst->p[Y_PLANE].i_pitch;
972 p_dst_y = p_dst->p[Y_PLANE].p_pixels + i_x_offset +
973 p_filter->fmt_out.video.i_x_offset +
974 p_dst->p[Y_PLANE].i_pitch *
975 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
976 p_dst_u = p_dst->p[U_PLANE].p_pixels + i_x_offset/2 +
977 p_filter->fmt_out.video.i_x_offset/2 +
978 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
979 p_dst->p[U_PLANE].i_pitch;
980 p_dst_v = p_dst->p[V_PLANE].p_pixels + i_x_offset/2 +
981 p_filter->fmt_out.video.i_x_offset/2 +
982 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
983 p_dst->p[V_PLANE].i_pitch;
985 p_src2_y = vlc_plane_start( &i_src2_pitch, p_src, Y_PLANE,
986 0, 0, &p_filter->fmt_in.video, 1 );
987 p_src2_u = vlc_plane_start( NULL, p_src, U_PLANE,
988 0, 0, &p_filter->fmt_in.video, 2 );
989 p_src2_v = vlc_plane_start( NULL, p_src, V_PLANE,
990 0, 0, &p_filter->fmt_in.video, 2 );
994 /* Draw until we reach the bottom of the subtitle */
995 for( i_y = 0; i_y < i_height;
996 i_y++, p_dst_y += i_dst_pitch, p_src2_y += i_src2_pitch )
998 /* Completely opaque. Completely overwrite underlying pixel */
999 vlc_memcpy( p_dst_y, p_src2_y, i_width );
1000 if( b_even_scanline )
1002 p_dst_u += i_dst_pitch/2;
1003 p_dst_v += i_dst_pitch/2;
1007 vlc_memcpy( p_dst_u, p_src2_u, i_width/2 );
1008 vlc_memcpy( p_dst_v, p_src2_v, i_width/2 );
1010 b_even_scanline = !b_even_scanline;
1013 p_src2_u += i_src2_pitch/2;
1014 p_src2_v += i_src2_pitch/2;
1019 static void BlendI420R16( filter_t *p_filter, picture_t *p_dst_pic,
1020 picture_t *p_dst_orig, picture_t *p_src,
1021 int i_x_offset, int i_y_offset,
1022 int i_width, int i_height, int i_alpha )
1024 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
1025 uint8_t *p_dst, *p_src1, *p_src2_y;
1026 uint8_t *p_src2_u, *p_src2_v;
1027 int i_x, i_y, i_pix_pitch;
1030 i_pix_pitch = p_dst_pic->p->i_pixel_pitch;
1031 i_dst_pitch = p_dst_pic->p->i_pitch;
1032 p_dst = p_dst_pic->p->p_pixels + i_x_offset * i_pix_pitch +
1033 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
1034 p_dst_pic->p->i_pitch *
1035 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1037 i_src1_pitch = p_dst_orig->p[Y_PLANE].i_pitch;
1038 p_src1 = p_dst_orig->p->p_pixels + i_x_offset * i_pix_pitch +
1039 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
1040 p_dst_orig->p->i_pitch *
1041 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1043 p_src2_y = vlc_plane_start( &i_src2_pitch, p_src, Y_PLANE,
1044 0, 0, &p_filter->fmt_in.video, 1 );
1045 p_src2_u = vlc_plane_start( NULL, p_src, U_PLANE,
1046 0, 0, &p_filter->fmt_in.video, 2 );
1047 p_src2_v = vlc_plane_start( NULL, p_src, V_PLANE,
1048 0, 0, &p_filter->fmt_in.video, 2 );
1050 /* Draw until we reach the bottom of the subtitle */
1051 for( i_y = 0; i_y < i_height; i_y++,
1052 p_dst += i_dst_pitch, p_src1 += i_src1_pitch,
1053 p_src2_y += i_src2_pitch )
1055 /* Draw until we reach the end of the line */
1056 for( i_x = 0; i_x < i_width; i_x++ )
1059 yuv_to_rgb( &r, &g, &b,
1060 p_src2_y[i_x], p_src2_u[i_x/2], p_src2_v[i_x/2] );
1062 vlc_blend_rgb16( (uint16_t*)&p_dst[i_x * i_pix_pitch],
1063 (const uint16_t*)&p_src1[i_x * i_pix_pitch],
1064 r, g, b, 0xff, &p_filter->fmt_out.video );
1068 p_src2_u += i_src2_pitch/2;
1069 p_src2_v += i_src2_pitch/2;
1074 static void BlendI420R24( filter_t *p_filter, picture_t *p_dst_pic,
1075 picture_t *p_dst_orig, picture_t *p_src,
1076 int i_x_offset, int i_y_offset,
1077 int i_width, int i_height, int i_alpha )
1079 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
1080 uint8_t *p_dst, *p_src1, *p_src2_y;
1081 uint8_t *p_src2_u, *p_src2_v;
1082 int i_x, i_y, i_pix_pitch;
1083 int i_rindex, i_gindex, i_bindex;
1086 i_pix_pitch = p_dst_pic->p->i_pixel_pitch;
1087 i_dst_pitch = p_dst_pic->p->i_pitch;
1088 p_dst = p_dst_pic->p->p_pixels + i_x_offset * i_pix_pitch +
1089 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
1090 p_dst_pic->p->i_pitch *
1091 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1093 i_src1_pitch = p_dst_orig->p[Y_PLANE].i_pitch;
1094 p_src1 = p_dst_orig->p->p_pixels + i_x_offset * i_pix_pitch +
1095 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
1096 p_dst_orig->p->i_pitch *
1097 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1099 p_src2_y = vlc_plane_start( &i_src2_pitch, p_src, Y_PLANE,
1100 0, 0, &p_filter->fmt_in.video, 1 );
1101 p_src2_u = vlc_plane_start( NULL, p_src, U_PLANE,
1102 0, 0, &p_filter->fmt_in.video, 2 );
1103 p_src2_v = vlc_plane_start( NULL, p_src, V_PLANE,
1104 0, 0, &p_filter->fmt_in.video, 2 );
1106 vlc_rgb_index( &i_rindex, &i_gindex, &i_bindex, &p_filter->fmt_out.video );
1108 /* Draw until we reach the bottom of the subtitle */
1109 for( i_y = 0; i_y < i_height; i_y++,
1110 p_dst += i_dst_pitch, p_src1 += i_src1_pitch,
1111 p_src2_y += i_src2_pitch, p_src2_u += i_src2_pitch,
1112 p_src2_v += i_src2_pitch )
1114 /* Draw until we reach the end of the line */
1115 for( i_x = 0; i_x < i_width; i_x++ )
1121 yuv_to_rgb( &r, &g, &b,
1122 p_src2_y[i_x], p_src2_u[i_x/2], p_src2_v[i_x/2] );
1124 vlc_blend_packed( &p_dst[i_x * i_pix_pitch], &p_src1[i_x * i_pix_pitch],
1125 i_rindex, i_gindex, i_bindex, r, g, b, i_alpha, true );
1129 p_src2_u += i_src2_pitch/2;
1130 p_src2_v += i_src2_pitch/2;
1135 static void BlendI420YUVPacked( filter_t *p_filter, picture_t *p_dst_pic,
1136 picture_t *p_dst_orig, picture_t *p_src,
1137 int i_x_offset, int i_y_offset,
1138 int i_width, int i_height, int i_alpha )
1140 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
1141 uint8_t *p_dst, *p_src1, *p_src2_y;
1142 uint8_t *p_src2_u, *p_src2_v;
1143 int i_x, i_y, i_pix_pitch;
1144 bool b_even = !((i_x_offset + p_filter->fmt_out.video.i_x_offset)%2);
1145 int i_l_offset, i_u_offset, i_v_offset;
1147 vlc_yuv_packed_index( &i_l_offset, &i_u_offset, &i_v_offset,
1148 p_filter->fmt_out.video.i_chroma );
1151 i_dst_pitch = p_dst_pic->p->i_pitch;
1152 p_dst = p_dst_pic->p->p_pixels + i_x_offset * i_pix_pitch +
1153 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
1154 p_dst_pic->p->i_pitch *
1155 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1157 i_src1_pitch = p_dst_orig->p[Y_PLANE].i_pitch;
1158 p_src1 = p_dst_orig->p->p_pixels + i_x_offset * i_pix_pitch +
1159 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
1160 p_dst_orig->p->i_pitch *
1161 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1163 p_src2_y = vlc_plane_start( &i_src2_pitch, p_src, Y_PLANE,
1164 0, 0, &p_filter->fmt_in.video, 1 );
1165 p_src2_u = vlc_plane_start( NULL, p_src, U_PLANE,
1166 0, 0, &p_filter->fmt_in.video, 2 );
1167 p_src2_v = vlc_plane_start( NULL, p_src, V_PLANE,
1168 0, 0, &p_filter->fmt_in.video, 2 );
1170 i_width &= ~1; /* Needs to be a multiple of 2 */
1172 /* Draw until we reach the bottom of the subtitle */
1173 for( i_y = 0; i_y < i_height; i_y++,
1174 p_dst += i_dst_pitch, p_src1 += i_src1_pitch,
1175 p_src2_y += i_src2_pitch, p_src2_u += i_src2_pitch,
1176 p_src2_v += i_src2_pitch )
1178 /* Draw until we reach the end of the line */
1179 for( i_x = 0; i_x < i_width; i_x++, b_even = !b_even )
1185 vlc_blend_packed( &p_dst[i_x * 2], &p_src1[i_x * 2],
1186 i_l_offset, i_u_offset, i_v_offset,
1187 p_src2_y[i_x], p_src2_u[i_x/2], p_src2_v[i_x/2], i_alpha, b_even );
1191 p_src2_u += i_src2_pitch/2;
1192 p_src2_v += i_src2_pitch/2;
1197 /***********************************************************************
1199 ***********************************************************************/
1200 static void BlendPalI420( filter_t *p_filter, picture_t *p_dst,
1201 picture_t *p_dst_orig, picture_t *p_src,
1202 int i_x_offset, int i_y_offset,
1203 int i_width, int i_height, int i_alpha )
1205 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
1206 uint8_t *p_src1_y, *p_src2, *p_dst_y;
1207 uint8_t *p_src1_u, *p_dst_u;
1208 uint8_t *p_src1_v, *p_dst_v;
1209 int i_x, i_y, i_trans;
1210 bool b_even_scanline = i_y_offset % 2;
1212 i_dst_pitch = p_dst->p[Y_PLANE].i_pitch;
1213 p_dst_y = p_dst->p[Y_PLANE].p_pixels + i_x_offset +
1214 p_filter->fmt_out.video.i_x_offset +
1215 p_dst->p[Y_PLANE].i_pitch *
1216 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1217 p_dst_u = p_dst->p[U_PLANE].p_pixels + i_x_offset/2 +
1218 p_filter->fmt_out.video.i_x_offset/2 +
1219 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
1220 p_dst->p[U_PLANE].i_pitch;
1221 p_dst_v = p_dst->p[V_PLANE].p_pixels + i_x_offset/2 +
1222 p_filter->fmt_out.video.i_x_offset/2 +
1223 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
1224 p_dst->p[V_PLANE].i_pitch;
1226 i_src1_pitch = p_dst_orig->p[Y_PLANE].i_pitch;
1227 p_src1_y = p_dst_orig->p[Y_PLANE].p_pixels + i_x_offset +
1228 p_filter->fmt_out.video.i_x_offset +
1229 p_dst_orig->p[Y_PLANE].i_pitch *
1230 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1231 p_src1_u = p_dst_orig->p[U_PLANE].p_pixels + i_x_offset/2 +
1232 p_filter->fmt_out.video.i_x_offset/2 +
1233 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
1234 p_dst_orig->p[U_PLANE].i_pitch;
1235 p_src1_v = p_dst_orig->p[V_PLANE].p_pixels + i_x_offset/2 +
1236 p_filter->fmt_out.video.i_x_offset/2 +
1237 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
1238 p_dst_orig->p[V_PLANE].i_pitch;
1240 i_src2_pitch = p_src->p->i_pitch;
1241 p_src2 = p_src->p->p_pixels + p_filter->fmt_in.video.i_x_offset +
1242 i_src2_pitch * p_filter->fmt_in.video.i_y_offset;
1244 const uint8_t *p_trans = p_src2;
1245 #define p_pal p_filter->fmt_in.video.p_palette->palette
1247 /* Draw until we reach the bottom of the subtitle */
1248 for( i_y = 0; i_y < i_height; i_y++,
1249 p_dst_y += i_dst_pitch, p_src1_y += i_src1_pitch,
1250 p_src2 += i_src2_pitch,
1251 p_dst_u += b_even_scanline ? i_dst_pitch/2 : 0,
1252 p_src1_u += b_even_scanline ? i_src1_pitch/2 : 0,
1253 p_dst_v += b_even_scanline ? i_dst_pitch/2 : 0,
1254 p_src1_v += b_even_scanline ? i_src1_pitch/2 : 0 )
1256 b_even_scanline = !b_even_scanline;
1258 /* Draw until we reach the end of the line */
1259 for( i_x = 0; i_x < i_width; i_x++ )
1261 i_trans = vlc_alpha( p_pal[p_trans[i_x]][3], i_alpha );
1266 p_dst_y[i_x] = vlc_blend( p_pal[p_src2[i_x]][0], p_src1_y[i_x], i_trans );
1267 if( b_even_scanline && ((i_x % 2) == 0) )
1269 p_dst_u[i_x/2] = vlc_blend( p_pal[p_src2[i_x]][1], p_src1_u[i_x/2], i_trans );
1270 p_dst_v[i_x/2] = vlc_blend( p_pal[p_src2[i_x]][2], p_src1_v[i_x/2], i_trans );
1277 static void BlendPalYUVPacked( filter_t *p_filter, picture_t *p_dst_pic,
1278 picture_t *p_dst_orig, picture_t *p_src,
1279 int i_x_offset, int i_y_offset,
1280 int i_width, int i_height, int i_alpha )
1282 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
1283 uint8_t *p_src1, *p_src2, *p_dst;
1284 int i_x, i_y, i_pix_pitch, i_trans;
1285 bool b_even = !((i_x_offset + p_filter->fmt_out.video.i_x_offset)%2);
1286 int i_l_offset, i_u_offset, i_v_offset;
1288 vlc_yuv_packed_index( &i_l_offset, &i_u_offset, &i_v_offset,
1289 p_filter->fmt_out.video.i_chroma );
1292 i_dst_pitch = p_dst_pic->p->i_pitch;
1293 p_dst = p_dst_pic->p->p_pixels + i_pix_pitch * (i_x_offset +
1294 p_filter->fmt_out.video.i_x_offset) + p_dst_pic->p->i_pitch *
1295 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1297 i_src1_pitch = p_dst_orig->p->i_pitch;
1298 p_src1 = p_dst_orig->p->p_pixels + i_pix_pitch * (i_x_offset +
1299 p_filter->fmt_out.video.i_x_offset) + p_dst_orig->p->i_pitch *
1300 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1302 i_src2_pitch = p_src->p->i_pitch;
1303 p_src2 = p_src->p->p_pixels + p_filter->fmt_in.video.i_x_offset +
1304 i_src2_pitch * p_filter->fmt_in.video.i_y_offset;
1306 i_width &= ~1; /* Needs to be a multiple of 2 */
1308 const uint8_t *p_trans = p_src2;
1309 #define p_pal p_filter->fmt_in.video.p_palette->palette
1311 /* Draw until we reach the bottom of the subtitle */
1312 for( i_y = 0; i_y < i_height; i_y++,
1313 p_dst += i_dst_pitch, p_src1 += i_src1_pitch, p_src2 += i_src2_pitch )
1315 /* Draw until we reach the end of the line */
1316 for( i_x = 0; i_x < i_width; i_x++, b_even = !b_even )
1318 i_trans = vlc_alpha( p_pal[p_trans[i_x]][3], i_alpha );
1327 if( p_trans[i_x+1] > 0xaa )
1329 i_u = (p_pal[p_src2[i_x]][1] + p_pal[p_src2[i_x+1]][1]) >> 1;
1330 i_v = (p_pal[p_src2[i_x]][2] + p_pal[p_src2[i_x+1]][2]) >> 1;
1334 i_u = p_pal[p_src2[i_x]][1];
1335 i_v = p_pal[p_src2[i_x]][2];
1338 vlc_blend_packed( &p_dst[i_x * 2], &p_src1[i_x * 2],
1339 i_l_offset, i_u_offset, i_v_offset,
1340 p_pal[p_src2[i_x]][0], i_u, i_v, i_trans, true );
1344 p_dst[i_x * 2 + i_l_offset] = vlc_blend( p_pal[p_src2[i_x]][0], p_src1[i_x * 2 + i_l_offset], i_trans );
1351 static void BlendPalRV( filter_t *p_filter, picture_t *p_dst_pic,
1352 picture_t *p_dst_orig, picture_t *p_src,
1353 int i_x_offset, int i_y_offset,
1354 int i_width, int i_height, int i_alpha )
1356 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
1357 uint8_t *p_src1, *p_src2, *p_dst;
1358 int i_x, i_y, i_pix_pitch, i_trans;
1360 video_palette_t rgbpalette;
1361 int i_rindex, i_gindex, i_bindex;
1363 i_pix_pitch = p_dst_pic->p->i_pixel_pitch;
1364 i_dst_pitch = p_dst_pic->p->i_pitch;
1365 p_dst = p_dst_pic->p->p_pixels + i_pix_pitch * (i_x_offset +
1366 p_filter->fmt_out.video.i_x_offset) + p_dst_pic->p->i_pitch *
1367 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1369 i_src1_pitch = p_dst_orig->p->i_pitch;
1370 p_src1 = p_dst_orig->p->p_pixels + i_pix_pitch * (i_x_offset +
1371 p_filter->fmt_out.video.i_x_offset) + p_dst_orig->p->i_pitch *
1372 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1374 i_src2_pitch = p_src->p->i_pitch;
1375 p_src2 = p_src->p->p_pixels + p_filter->fmt_in.video.i_x_offset +
1376 i_src2_pitch * p_filter->fmt_in.video.i_y_offset;
1378 const uint8_t *p_trans = p_src2;
1379 #define p_pal p_filter->fmt_in.video.p_palette->palette
1380 #define rgbpal rgbpalette.palette
1382 /* Convert palette first */
1383 for( i_y = 0; i_y < p_filter->fmt_in.video.p_palette->i_entries && i_y < 256; i_y++ )
1385 yuv_to_rgb( &r, &g, &b, p_pal[i_y][0], p_pal[i_y][1], p_pal[i_y][2] );
1386 rgbpal[i_y][0] = r; rgbpal[i_y][1] = g; rgbpal[i_y][2] = b;
1390 vlc_rgb_index( &i_rindex, &i_gindex, &i_bindex, &p_filter->fmt_out.video );
1392 /* Draw until we reach the bottom of the subtitle */
1393 for( i_y = 0; i_y < i_height; i_y++,
1394 p_dst += i_dst_pitch, p_src1 += i_src1_pitch, p_src2 += i_src2_pitch )
1396 /* Draw until we reach the end of the line */
1397 for( i_x = 0; i_x < i_width; i_x++ )
1399 i_trans = vlc_alpha( p_pal[p_trans[i_x]][3], i_alpha );
1404 if( p_filter->fmt_out.video.i_chroma == FCC_RV15 || p_filter->fmt_out.video.i_chroma == FCC_RV16 )
1405 vlc_blend_rgb16( (uint16_t*)&p_dst[i_x * i_pix_pitch],
1406 (const uint16_t*)&p_src1[i_x * i_pix_pitch],
1407 rgbpal[p_src2[i_x]][0], rgbpal[p_src2[i_x]][1], rgbpal[p_src2[i_x]][3],
1409 &p_filter->fmt_out.video );
1411 vlc_blend_packed( &p_dst[i_x * i_pix_pitch], &p_src1[i_x * i_pix_pitch],
1412 i_rindex, i_gindex, i_bindex,
1413 rgbpal[p_src2[i_x]][0], rgbpal[p_src2[i_x]][1], rgbpal[p_src2[i_x]][3],
1422 /***********************************************************************
1424 ***********************************************************************/
1425 static void BlendRGBAI420( filter_t *p_filter, picture_t *p_dst,
1426 picture_t *p_dst_orig, picture_t *p_src,
1427 int i_x_offset, int i_y_offset,
1428 int i_width, int i_height, int i_alpha )
1430 int i_src1_pitch, i_src2_pitch, i_dst_pitch, i_src_pix_pitch;
1431 uint8_t *p_src1_y, *p_dst_y;
1432 uint8_t *p_src1_u, *p_dst_u;
1433 uint8_t *p_src1_v, *p_dst_v;
1435 int i_x, i_y, i_trans;
1438 bool b_even_scanline = i_y_offset % 2;
1440 i_dst_pitch = p_dst->p[Y_PLANE].i_pitch;
1441 p_dst_y = p_dst->p[Y_PLANE].p_pixels + i_x_offset +
1442 p_filter->fmt_out.video.i_x_offset +
1443 p_dst->p[Y_PLANE].i_pitch *
1444 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1445 p_dst_u = p_dst->p[U_PLANE].p_pixels + i_x_offset/2 +
1446 p_filter->fmt_out.video.i_x_offset/2 +
1447 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
1448 p_dst->p[U_PLANE].i_pitch;
1449 p_dst_v = p_dst->p[V_PLANE].p_pixels + i_x_offset/2 +
1450 p_filter->fmt_out.video.i_x_offset/2 +
1451 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
1452 p_dst->p[V_PLANE].i_pitch;
1454 i_src1_pitch = p_dst_orig->p[Y_PLANE].i_pitch;
1455 p_src1_y = p_dst_orig->p[Y_PLANE].p_pixels + i_x_offset +
1456 p_filter->fmt_out.video.i_x_offset +
1457 p_dst_orig->p[Y_PLANE].i_pitch *
1458 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1459 p_src1_u = p_dst_orig->p[U_PLANE].p_pixels + i_x_offset/2 +
1460 p_filter->fmt_out.video.i_x_offset/2 +
1461 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
1462 p_dst_orig->p[U_PLANE].i_pitch;
1463 p_src1_v = p_dst_orig->p[V_PLANE].p_pixels + i_x_offset/2 +
1464 p_filter->fmt_out.video.i_x_offset/2 +
1465 ( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
1466 p_dst_orig->p[V_PLANE].i_pitch;
1468 i_src_pix_pitch = p_src->p->i_pixel_pitch;
1469 i_src2_pitch = p_src->p->i_pitch;
1470 p_src2 = p_src->p->p_pixels +
1471 p_filter->fmt_in.video.i_x_offset * i_src2_pitch +
1472 p_src->p->i_pitch * p_filter->fmt_in.video.i_y_offset;
1475 /* Draw until we reach the bottom of the subtitle */
1476 for( i_y = 0; i_y < i_height; i_y++,
1477 p_dst_y += i_dst_pitch, p_src1_y += i_src1_pitch,
1478 p_dst_u += b_even_scanline ? i_dst_pitch/2 : 0,
1479 p_src1_u += b_even_scanline ? i_src1_pitch/2 : 0,
1480 p_dst_v += b_even_scanline ? i_dst_pitch/2 : 0,
1481 p_src1_v += b_even_scanline ? i_src1_pitch/2 : 0,
1482 p_src2 += i_src2_pitch )
1484 b_even_scanline = !b_even_scanline;
1486 /* Draw until we reach the end of the line */
1487 for( i_x = 0; i_x < i_width; i_x++ )
1489 const int R = p_src2[i_x * i_src_pix_pitch + 0];
1490 const int G = p_src2[i_x * i_src_pix_pitch + 1];
1491 const int B = p_src2[i_x * i_src_pix_pitch + 2];
1493 i_trans = vlc_alpha( p_src2[i_x * i_src_pix_pitch + 3], i_alpha );
1498 rgb_to_yuv( &y, &u, &v, R, G, B );
1500 p_dst_y[i_x] = vlc_blend( y, p_src1_y[i_x], i_trans );
1501 if( b_even_scanline && i_x % 2 == 0 )
1503 p_dst_u[i_x/2] = vlc_blend( u, p_src1_u[i_x/2], i_trans );
1504 p_dst_v[i_x/2] = vlc_blend( v, p_src1_v[i_x/2], i_trans );
1510 static void BlendRGBAR24( filter_t *p_filter, picture_t *p_dst_pic,
1511 picture_t *p_dst_orig, picture_t *p_src,
1512 int i_x_offset, int i_y_offset,
1513 int i_width, int i_height, int i_alpha )
1515 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
1516 uint8_t *p_dst, *p_src1, *p_src2;
1517 int i_x, i_y, i_pix_pitch, i_trans, i_src_pix_pitch;
1518 int i_rindex, i_gindex, i_bindex;
1520 i_pix_pitch = p_dst_pic->p->i_pixel_pitch;
1521 i_dst_pitch = p_dst_pic->p->i_pitch;
1522 p_dst = p_dst_pic->p->p_pixels + i_x_offset * i_pix_pitch +
1523 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
1524 p_dst_pic->p->i_pitch *
1525 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1527 i_src1_pitch = p_dst_orig->p->i_pitch;
1528 p_src1 = p_dst_orig->p->p_pixels + i_x_offset * i_pix_pitch +
1529 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
1530 p_dst_orig->p->i_pitch *
1531 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1533 i_src_pix_pitch = p_src->p->i_pixel_pitch;
1534 i_src2_pitch = p_src->p->i_pitch;
1535 p_src2 = p_src->p->p_pixels +
1536 p_filter->fmt_in.video.i_x_offset * i_pix_pitch +
1537 p_src->p->i_pitch * p_filter->fmt_in.video.i_y_offset;
1539 vlc_rgb_index( &i_rindex, &i_gindex, &i_bindex, &p_filter->fmt_out.video );
1541 /* Draw until we reach the bottom of the subtitle */
1542 for( i_y = 0; i_y < i_height; i_y++,
1543 p_dst += i_dst_pitch, p_src1 += i_src1_pitch, p_src2 += i_src2_pitch )
1545 /* Draw until we reach the end of the line */
1546 for( i_x = 0; i_x < i_width; i_x++ )
1548 const int R = p_src2[i_x * i_src_pix_pitch + 0];
1549 const int G = p_src2[i_x * i_src_pix_pitch + 1];
1550 const int B = p_src2[i_x * i_src_pix_pitch + 2];
1552 i_trans = vlc_alpha( p_src2[i_x * i_src_pix_pitch + 3], i_alpha );
1557 vlc_blend_packed( &p_dst[i_x * i_pix_pitch], &p_src1[i_x * i_pix_pitch],
1558 i_rindex, i_gindex, i_bindex,
1559 R, G, B, i_trans, true );
1564 static void BlendRGBAR16( filter_t *p_filter, picture_t *p_dst_pic,
1565 picture_t *p_dst_orig, picture_t *p_src,
1566 int i_x_offset, int i_y_offset,
1567 int i_width, int i_height, int i_alpha )
1569 int i_src1_pitch, i_src2_pitch, i_dst_pitch;
1570 uint8_t *p_dst, *p_src1, *p_src2;
1571 int i_x, i_y, i_pix_pitch, i_trans, i_src_pix_pitch;
1573 i_pix_pitch = p_dst_pic->p->i_pixel_pitch;
1574 i_dst_pitch = p_dst_pic->p->i_pitch;
1575 p_dst = p_dst_pic->p->p_pixels + i_x_offset * i_pix_pitch +
1576 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
1577 p_dst_pic->p->i_pitch *
1578 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1580 i_src1_pitch = p_dst_orig->p->i_pitch;
1581 p_src1 = p_dst_orig->p->p_pixels + i_x_offset * i_pix_pitch +
1582 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
1583 p_dst_orig->p->i_pitch *
1584 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1586 i_src_pix_pitch = p_src->p->i_pixel_pitch;
1587 i_src2_pitch = p_src->p->i_pitch;
1588 p_src2 = p_src->p->p_pixels +
1589 p_filter->fmt_in.video.i_x_offset * i_pix_pitch +
1590 p_src->p->i_pitch * p_filter->fmt_in.video.i_y_offset;
1592 /* Draw until we reach the bottom of the subtitle */
1593 for( i_y = 0; i_y < i_height; i_y++,
1594 p_dst += i_dst_pitch, p_src1 += i_src1_pitch, p_src2 += i_src2_pitch )
1596 /* Draw until we reach the end of the line */
1597 for( i_x = 0; i_x < i_width; i_x++ )
1599 const int R = p_src2[i_x * i_src_pix_pitch + 0];
1600 const int G = p_src2[i_x * i_src_pix_pitch + 1];
1601 const int B = p_src2[i_x * i_src_pix_pitch + 2];
1603 i_trans = vlc_alpha( p_src2[i_x * i_src_pix_pitch + 3], i_alpha );
1608 vlc_blend_rgb16( (uint16_t*)&p_dst[i_x * i_pix_pitch],
1609 (const uint16_t*)&p_src1[i_x * i_pix_pitch],
1610 R, G, B, i_trans, &p_filter->fmt_out.video );
1615 static void BlendRGBAYUVPacked( filter_t *p_filter, picture_t *p_dst_pic,
1616 picture_t *p_dst_orig, picture_t *p_src,
1617 int i_x_offset, int i_y_offset,
1618 int i_width, int i_height, int i_alpha )
1620 int i_src1_pitch, i_src2_pitch, i_dst_pitch, i_src_pix_pitch;
1621 uint8_t *p_dst, *p_src1, *p_src2;
1623 int i_x, i_y, i_pix_pitch, i_trans;
1624 bool b_even = !((i_x_offset + p_filter->fmt_out.video.i_x_offset)%2);
1625 int i_l_offset, i_u_offset, i_v_offset;
1628 vlc_yuv_packed_index( &i_l_offset, &i_u_offset, &i_v_offset,
1629 p_filter->fmt_out.video.i_chroma );
1632 i_dst_pitch = p_dst_pic->p->i_pitch;
1633 p_dst = p_dst_pic->p->p_pixels + i_x_offset * i_pix_pitch +
1634 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
1635 p_dst_pic->p->i_pitch *
1636 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1638 i_src1_pitch = p_dst_orig->p[Y_PLANE].i_pitch;
1639 p_src1 = p_dst_orig->p->p_pixels + i_x_offset * i_pix_pitch +
1640 p_filter->fmt_out.video.i_x_offset * i_pix_pitch +
1641 p_dst_orig->p->i_pitch *
1642 ( i_y_offset + p_filter->fmt_out.video.i_y_offset );
1644 i_src_pix_pitch = p_src->p->i_pixel_pitch;
1645 i_src2_pitch = p_src->p->i_pitch;
1646 p_src2 = p_src->p->p_pixels +
1647 p_filter->fmt_in.video.i_x_offset * i_src2_pitch +
1648 p_src->p->i_pitch * p_filter->fmt_in.video.i_y_offset;
1650 i_width &= ~1; /* Needs to be a multiple of 2 */
1652 /* Draw until we reach the bottom of the subtitle */
1653 for( i_y = 0; i_y < i_height; i_y++, p_trans += i_src2_pitch,
1654 p_dst += i_dst_pitch, p_src1 += i_src1_pitch,
1655 p_src2 += i_src2_pitch )
1657 /* Draw until we reach the end of the line */
1658 for( i_x = 0; i_x < i_width; i_x++, b_even = !b_even )
1660 const int R = p_src2[i_x * i_src_pix_pitch + 0];
1661 const int G = p_src2[i_x * i_src_pix_pitch + 1];
1662 const int B = p_src2[i_x * i_src_pix_pitch + 2];
1664 i_trans = vlc_alpha( p_src2[i_x * i_src_pix_pitch + 3], i_alpha );
1669 rgb_to_yuv( &y, &u, &v, R, G, B );
1671 vlc_blend_packed( &p_dst[i_x * 2], &p_src1[i_x * 2],
1672 i_l_offset, i_u_offset, i_v_offset,
1673 y, u, v, i_trans, b_even );