1 /*****************************************************************************
2 * extract.c : Extract RGB components
3 *****************************************************************************
4 * Copyright (C) 2000-2006 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea .t videolan d@t org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
31 #include "vlc_filter.h"
32 #include "filter_picture.h"
36 /*****************************************************************************
38 *****************************************************************************/
39 static int Create ( vlc_object_t * );
40 static void Destroy ( vlc_object_t * );
42 static picture_t *Filter( filter_t *, picture_t * );
43 static int ExtractCallback( vlc_object_t *, char const *,
44 vlc_value_t, vlc_value_t, void * );
46 static void get_red_from_yuv420( picture_t *, picture_t *, int, int, int );
47 static void get_green_from_yuv420( picture_t *, picture_t *, int, int, int );
48 static void get_blue_from_yuv420( picture_t *, picture_t *, int, int, int );
49 static void get_red_from_yuv422( picture_t *, picture_t *, int, int, int );
50 static void get_green_from_yuv422( picture_t *, picture_t *, int, int, int );
51 static void get_blue_from_yuv422( picture_t *, picture_t *, int, int, int );
52 static void make_projection_matrix( filter_t *, int color, int *matrix );
53 static void get_custom_from_yuv420( picture_t *, picture_t *, int, int, int, int * );
54 static void get_custom_from_yuv422( picture_t *, picture_t *, int, int, int, int * );
55 static void get_custom_from_packedyuv422( picture_t *, picture_t *, int * );
58 #define COMPONENT_TEXT N_("RGB component to extract")
59 #define COMPONENT_LONGTEXT N_("RGB component to extract. 0 for Red, 1 for Green and 2 for Blue.")
60 #define FILTER_PREFIX "extract-"
62 static int pi_component_values[] = { 0xFF0000, 0x00FF00, 0x0000FF };
63 static const char *ppsz_component_descriptions[] = { "Red", "Green", "Blue" };
65 /*****************************************************************************
67 *****************************************************************************/
69 set_description( _("Extract RGB component video filter") );
70 set_shortname( _("Extract" ));
71 set_category( CAT_VIDEO );
72 set_subcategory( SUBCAT_VIDEO_VFILTER );
73 set_capability( "video filter2", 0 );
74 add_shortcut( "extract" );
76 add_integer_with_range( FILTER_PREFIX "component", 0xFF0000, 1, 0xFFFFFF,
77 NULL, COMPONENT_TEXT, COMPONENT_LONGTEXT, VLC_FALSE );
79 change_integer_list( pi_component_values, ppsz_component_descriptions, 0 );
81 set_callbacks( Create, Destroy );
84 static const char *ppsz_filter_options[] = {
88 enum { RED=0xFF0000, GREEN=0x00FF00, BLUE=0x0000FF };
92 int *projection_matrix;
95 /*****************************************************************************
97 *****************************************************************************/
98 static int Create( vlc_object_t *p_this )
100 filter_t *p_filter = (filter_t *)p_this;
102 switch( p_filter->fmt_in.video.i_chroma )
104 case VLC_FOURCC('I','4','2','0'):
105 case VLC_FOURCC('I','Y','U','V'):
106 case VLC_FOURCC('J','4','2','0'):
107 case VLC_FOURCC('Y','V','1','2'):
109 case VLC_FOURCC('I','4','2','2'):
110 case VLC_FOURCC('J','4','2','2'):
116 /* We only want planar YUV 4:2:0 or 4:2:2 */
117 msg_Err( p_filter, "Unsupported input chroma (%4s)",
118 (char*)&(p_filter->fmt_in.video.i_chroma) );
122 /* Allocate structure */
123 p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
124 if( p_filter->p_sys == NULL )
126 msg_Err( p_filter, "out of memory" );
129 p_filter->p_sys->projection_matrix = malloc( 9 * sizeof( int ) );
130 if( !p_filter->p_sys->projection_matrix )
132 free( p_filter->p_sys );
133 msg_Err( p_filter, "out of memory" );
137 config_ChainParse( p_filter, FILTER_PREFIX, ppsz_filter_options,
140 p_filter->p_sys->i_color = var_CreateGetIntegerCommand( p_filter,
141 FILTER_PREFIX "component" );
142 var_AddCallback( p_filter, FILTER_PREFIX "component",
143 ExtractCallback, p_filter->p_sys );
145 /* Matrix won't be used for RED, GREEN or BLUE in planar formats */
146 make_projection_matrix( p_filter, p_filter->p_sys->i_color,
147 p_filter->p_sys->projection_matrix );
149 p_filter->pf_video_filter = Filter;
154 /*****************************************************************************
156 *****************************************************************************/
157 static void Destroy( vlc_object_t *p_this )
159 filter_t *p_filter = (filter_t *)p_this;
161 free( p_filter->p_sys->projection_matrix );
162 free( p_filter->p_sys );
165 /*****************************************************************************
167 *****************************************************************************/
168 static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
172 if( !p_pic ) return NULL;
174 p_outpic = p_filter->pf_vout_buffer_new( p_filter );
177 msg_Warn( p_filter, "can't get output picture" );
178 if( p_pic->pf_release )
179 p_pic->pf_release( p_pic );
183 switch( p_pic->format.i_chroma )
185 case VLC_FOURCC('I','4','2','0'):
186 case VLC_FOURCC('I','Y','U','V'):
187 case VLC_FOURCC('J','4','2','0'):
188 case VLC_FOURCC('Y','V','1','2'):
189 switch( p_filter->p_sys->i_color )
192 get_red_from_yuv420( p_pic, p_outpic,
193 Y_PLANE, U_PLANE, V_PLANE );
196 get_green_from_yuv420( p_pic, p_outpic,
197 Y_PLANE, U_PLANE, V_PLANE );
200 get_blue_from_yuv420( p_pic, p_outpic,
201 Y_PLANE, U_PLANE, V_PLANE );
204 get_custom_from_yuv420( p_pic, p_outpic,
205 Y_PLANE, U_PLANE, V_PLANE,
206 p_filter->p_sys->projection_matrix);
211 case VLC_FOURCC('I','4','2','2'):
212 case VLC_FOURCC('J','4','2','2'):
213 switch( p_filter->p_sys->i_color )
216 get_red_from_yuv422( p_pic, p_outpic,
217 Y_PLANE, U_PLANE, V_PLANE );
220 get_green_from_yuv422( p_pic, p_outpic,
221 Y_PLANE, U_PLANE, V_PLANE );
224 get_blue_from_yuv422( p_pic, p_outpic,
225 Y_PLANE, U_PLANE, V_PLANE );
228 get_custom_from_yuv422( p_pic, p_outpic,
229 Y_PLANE, U_PLANE, V_PLANE,
230 p_filter->p_sys->projection_matrix);
236 get_custom_from_packedyuv422( p_pic, p_outpic,
237 p_filter->p_sys->projection_matrix );
241 msg_Warn( p_filter, "Unsupported input chroma (%4s)",
242 (char*)&(p_pic->format.i_chroma) );
243 if( p_pic->pf_release )
244 p_pic->pf_release( p_pic );
248 p_outpic->date = p_pic->date;
249 p_outpic->b_force = p_pic->b_force;
250 p_outpic->i_nb_fields = p_pic->i_nb_fields;
251 p_outpic->b_progressive = p_pic->b_progressive;
252 p_outpic->b_top_field_first = p_pic->b_top_field_first;
254 if( p_pic->pf_release )
255 p_pic->pf_release( p_pic );
260 static inline uint8_t crop( int a )
262 if( a < 0 ) return 0;
263 if( a > 255 ) return 255;
264 else return (uint8_t)a;
270 static void mmult( double *res, double *a, double *b )
273 for( i = 0; i < 3; i++ )
275 for( j = 0; j < 3; j++ )
278 for( k = 0; k < 3; k++ )
280 res[ i*3 + j ] += a[ i*3 + k ] * b[ k*3 + j ];
285 static void make_projection_matrix( filter_t *p_filter, int color, int *matrix )
287 double left_matrix[9] =
288 { 76.24500, 149.68500, 29.07000,
289 -43.02765, -84.47235, 127.50000,
290 127.50000, -106.76534, -20.73466 };
291 double right_matrix[9] =
292 { 257.00392, 0.00000, 360.31950,
293 257.00392, -88.44438, -183.53583,
294 257.00392, 455.41095, 0.00000 };
295 double red = ((double)(( 0xFF0000 & color )>>16))/255.;
296 double green = ((double)(( 0x00FF00 & color )>>8))/255.;
297 double blue = ((double)( 0x0000FF & color ))/255.;
298 double norm = sqrt( red*red + green*green + blue*blue );
302 /* XXX: We might still need to norm the rgb_matrix */
303 double rgb_matrix[9] =
304 { red*red, red*green, red*blue,
305 red*green, green*green, green*blue,
306 red*blue, green*blue, blue*blue };
310 msg_Dbg( p_filter, "red: %f", red );
311 msg_Dbg( p_filter, "green: %f", green );
312 msg_Dbg( p_filter, "blue: %f", blue );
313 mmult( result1, rgb_matrix, right_matrix );
314 mmult( result, left_matrix, result1 );
315 for( i = 0; i < 9; i++ )
317 matrix[i] = (int)result[i];
319 msg_Dbg( p_filter, "Projection matrix:" );
320 msg_Dbg( p_filter, "%6d %6d %6d", matrix[0], matrix[1], matrix[2] );
321 msg_Dbg( p_filter, "%6d %6d %6d", matrix[3], matrix[4], matrix[5] );
322 msg_Dbg( p_filter, "%6d %6d %6d", matrix[6], matrix[7], matrix[8] );
325 static void get_custom_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
326 int yp, int up, int vp, int *m )
328 uint8_t *y1in = p_inpic->p[yp].p_pixels;
330 uint8_t *uin = p_inpic->p[up].p_pixels;
331 uint8_t *vin = p_inpic->p[vp].p_pixels;
333 uint8_t *y1out = p_outpic->p[yp].p_pixels;
335 uint8_t *uout = p_outpic->p[up].p_pixels;
336 uint8_t *vout = p_outpic->p[vp].p_pixels;
338 const int i_pitch = p_inpic->p[yp].i_pitch;
339 const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
340 const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
342 const int i_uv_pitch = p_inpic->p[up].i_pitch;
343 const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
345 const uint8_t *yend = y1in + i_visible_lines * i_pitch;
348 const uint8_t *y1end = y1in + i_visible_pitch;
349 y2in = y1in + i_pitch;
350 y2out = y1out + i_pitch;
351 while( y1in < y1end )
353 *uout++ = crop( (*y1in * m[3] + (*uin-U) * m[4] + (*vin-V) * m[5])
355 *vout++ = crop( (*y1in * m[6] + (*uin-U) * m[7] + (*vin-V) * m[8])
357 *y1out++ = crop( (*y1in++ * m[0] + (*uin-U) * m[1] + (*vin-V) * m[2])
359 *y1out++ = crop( (*y1in++ * m[0] + (*uin-U) * m[1] + (*vin-V) * m[2])
361 *y2out++ = crop( (*y2in++ * m[0] + (*uin-U) * m[1] + (*vin-V) * m[2])
363 *y2out++ = crop( (*y2in++ * m[0] + (*uin++ - U) * m[1] + (*vin++ -V) * m[2])
366 y1in += 2*i_pitch - i_visible_pitch;
367 y1out += 2*i_pitch - i_visible_pitch;
368 uin += i_uv_pitch - i_uv_visible_pitch;
369 uout += i_uv_pitch - i_uv_visible_pitch;
370 vin += i_uv_pitch - i_uv_visible_pitch;
371 vout += i_uv_pitch - i_uv_visible_pitch;
374 static void get_custom_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
375 int yp, int up, int vp, int *m )
377 uint8_t *y1in = p_inpic->p[yp].p_pixels;
378 uint8_t *uin = p_inpic->p[up].p_pixels;
379 uint8_t *vin = p_inpic->p[vp].p_pixels;
381 uint8_t *y1out = p_outpic->p[yp].p_pixels;
382 uint8_t *uout = p_outpic->p[up].p_pixels;
383 uint8_t *vout = p_outpic->p[vp].p_pixels;
385 const int i_pitch = p_inpic->p[yp].i_pitch;
386 const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
387 const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
389 const int i_uv_pitch = p_inpic->p[up].i_pitch;
390 const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
392 const uint8_t *yend = y1in + i_visible_lines * i_pitch;
395 const uint8_t *y1end = y1in + i_visible_pitch;
396 while( y1in < y1end )
398 *uout++ = crop( (*y1in * m[3] + (*uin-U) * m[4] + (*vin-V) * m[5])
400 *vout++ = crop( (*y1in * m[6] + (*uin-U) * m[7] + (*vin-V) * m[8])
402 *y1out++ = crop( (*y1in++ * m[0] + (*uin-U) * m[1] + (*vin-V) * m[2])
404 *y1out++ = crop( (*y1in++ * m[0] + (*uin++ -U) * m[1] + (*vin++ -V) * m[2])
407 y1in += i_pitch - i_visible_pitch;
408 y1out += i_pitch - i_visible_pitch;
409 uin += i_uv_pitch - i_uv_visible_pitch;
410 uout += i_uv_pitch - i_uv_visible_pitch;
411 vin += i_uv_pitch - i_uv_visible_pitch;
412 vout += i_uv_pitch - i_uv_visible_pitch;
416 static void get_custom_from_packedyuv422( picture_t *p_inpic,
420 int i_y_offset, i_u_offset, i_v_offset;
421 if( GetPackedYuvOffsets( p_inpic->format.i_chroma, &i_y_offset,
422 &i_u_offset, &i_v_offset ) != VLC_SUCCESS )
425 uint8_t *yin = p_inpic->p->p_pixels + i_y_offset;
426 uint8_t *uin = p_inpic->p->p_pixels + i_u_offset;
427 uint8_t *vin = p_inpic->p->p_pixels + i_v_offset;
429 uint8_t *yout = p_outpic->p->p_pixels + i_y_offset;
430 uint8_t *uout = p_outpic->p->p_pixels + i_u_offset;
431 uint8_t *vout = p_outpic->p->p_pixels + i_v_offset;
433 const int i_pitch = p_inpic->p->i_pitch;
434 const int i_visible_pitch = p_inpic->p->i_visible_pitch;
435 const int i_visible_lines = p_inpic->p->i_visible_lines;
437 const uint8_t *yend = yin + i_visible_lines * i_pitch;
440 const uint8_t *ylend = yin + i_visible_pitch;
443 *uout = crop( (*yin * m[3] + (*uin-U) * m[4] + (*vin-V) * m[5])
446 *vout = crop( (*yin * m[6] + (*uin-U) * m[7] + (*vin-V) * m[8])
449 *yout = crop( (*yin * m[0] + (*uin-U) * m[1] + (*vin-V) * m[2])
453 *yout = crop( (*yin * m[0] + (*uin-U) * m[1] + (*vin-V) * m[2])
460 yin += i_pitch - i_visible_pitch;
461 yout += i_pitch - i_visible_pitch;
462 uin += i_pitch - i_visible_pitch;
463 uout += i_pitch - i_visible_pitch;
464 vin += i_pitch - i_visible_pitch;
465 vout += i_pitch - i_visible_pitch;
469 static void get_red_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
470 int yp, int up, int vp )
472 uint8_t *y1in = p_inpic->p[yp].p_pixels;
474 uint8_t *vin = p_inpic->p[vp].p_pixels;
476 uint8_t *y1out = p_outpic->p[yp].p_pixels;
478 uint8_t *uout = p_outpic->p[up].p_pixels;
479 uint8_t *vout = p_outpic->p[vp].p_pixels;
481 const int i_pitch = p_inpic->p[yp].i_pitch;
482 const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
483 const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
485 const int i_uv_pitch = p_inpic->p[up].i_pitch;
486 const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
488 const uint8_t *yend = y1in + i_visible_lines * i_pitch;
491 const uint8_t *y1end = y1in + i_visible_pitch;
492 y2in = y1in + i_pitch;
493 y2out = y1out + i_pitch;
494 while( y1in < y1end )
501 *uout++ = crop( (*y1in * -11058 + (*vin - V) * -15504)
503 *vout++ = crop( (*y1in * 32768 + (*vin - V) * 45941)
505 *y1out++ = crop( (*y1in++ * 19595 + (*vin - V) * 27473)
507 *y1out++ = crop( (*y1in++ * 19595 + (*vin - V) * 27473)
509 *y2out++ = crop( (*y2in++ * 19594 + (*vin - V) * 27473)
511 *y2out++ = crop( (*y2in++ * 19594 + (*vin++ - V) * 27473)
514 y1in += 2*i_pitch - i_visible_pitch;
515 y1out += 2*i_pitch - i_visible_pitch;
516 uout += i_uv_pitch - i_uv_visible_pitch;
517 vin += i_uv_pitch - i_uv_visible_pitch;
518 vout += i_uv_pitch - i_uv_visible_pitch;
522 static void get_green_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
523 int yp, int up, int vp )
525 uint8_t *y1in = p_inpic->p[yp].p_pixels;
527 uint8_t *uin = p_inpic->p[up].p_pixels;
528 uint8_t *vin = p_inpic->p[vp].p_pixels;
530 uint8_t *y1out = p_outpic->p[yp].p_pixels;
532 uint8_t *uout = p_outpic->p[up].p_pixels;
533 uint8_t *vout = p_outpic->p[vp].p_pixels;
535 const int i_pitch = p_inpic->p[yp].i_pitch;
536 const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
537 const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
539 const int i_uv_pitch = p_inpic->p[up].i_pitch;
540 const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
542 const uint8_t *yend = y1in + i_visible_lines * i_pitch;
545 const uint8_t *y1end = y1in + i_visible_pitch;
546 y2in = y1in + i_pitch;
547 y2out = y1out + i_pitch;
548 while( y1in < y1end )
555 *uout++ = crop( (*y1in * -21710 + (*uin-U) * 7471 + (*vin-V) * 15504)
557 *vout++ = crop( (*y1in * -27439 + (*uin-U) * 9443 + (*vin-V) * 19595)
559 *y1out++ = crop( (*y1in++ * 38470 + (*uin-U) * -13239 + (*vin-V) * -27473)
561 *y1out++ = crop( (*y1in++ * 38470 + (*uin-U) * -13239 + (*vin-V) * -27473)
563 *y2out++ = crop( (*y2in++ * 38470 + (*uin-U) * -13239 + (*vin-V) * -27473)
565 *y2out++ = crop( (*y2in++ * 38470 + (*uin++ - U) * -13239 + (*vin++ -V) * -27473)
568 y1in += 2*i_pitch - i_visible_pitch;
569 y1out += 2*i_pitch - i_visible_pitch;
570 uin += i_uv_pitch - i_uv_visible_pitch;
571 uout += i_uv_pitch - i_uv_visible_pitch;
572 vin += i_uv_pitch - i_uv_visible_pitch;
573 vout += i_uv_pitch - i_uv_visible_pitch;
577 static void get_blue_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
578 int yp, int up, int vp )
580 uint8_t *y1in = p_inpic->p[yp].p_pixels;
582 uint8_t *uin = p_inpic->p[up].p_pixels;
584 uint8_t *y1out = p_outpic->p[yp].p_pixels;
586 uint8_t *uout = p_outpic->p[up].p_pixels;
587 uint8_t *vout = p_outpic->p[vp].p_pixels;
589 const int i_pitch = p_inpic->p[yp].i_pitch;
590 const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
591 const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
593 const int i_uv_pitch = p_inpic->p[up].i_pitch;
594 const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
596 const uint8_t *yend = y1in + i_visible_lines * i_pitch;
599 const uint8_t *y1end = y1in + i_visible_pitch;
600 y2in = y1in + i_pitch;
601 y2out = y1out + i_pitch;
602 while( y1in < y1end )
609 *uout++ = crop( (*y1in* 32768 + (*uin - U) * 58065 )
611 *vout++ = crop( (*y1in * -5329 + (*uin - U) * -9443 )
613 *y1out++ = crop( (*y1in++ * 7471 + (*uin - U) * 13239 )
615 *y1out++ = crop( (*y1in++ * 7471 + (*uin - U) * 13239 )
617 *y2out++ = crop( (*y2in++ * 7471 + (*uin - U) * 13239 )
619 *y2out++ = crop( (*y2in++ * 7471 + (*uin++ - U) * 13239 )
622 y1in += 2*i_pitch - i_visible_pitch;
623 y1out += 2*i_pitch - i_visible_pitch;
624 uin += i_uv_pitch - i_uv_visible_pitch;
625 uout += i_uv_pitch - i_uv_visible_pitch;
626 vout += i_uv_pitch - i_uv_visible_pitch;
630 static void get_red_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
631 int yp, int up, int vp )
633 uint8_t *y1in = p_inpic->p[yp].p_pixels;
634 uint8_t *vin = p_inpic->p[vp].p_pixels;
636 uint8_t *y1out = p_outpic->p[yp].p_pixels;
637 uint8_t *uout = p_outpic->p[up].p_pixels;
638 uint8_t *vout = p_outpic->p[vp].p_pixels;
640 const int i_pitch = p_inpic->p[yp].i_pitch;
641 const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
642 const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
644 const int i_uv_pitch = p_inpic->p[up].i_pitch;
645 const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
647 const uint8_t *yend = y1in + i_visible_lines * i_pitch;
650 const uint8_t *y1end = y1in + i_visible_pitch;
651 while( y1in < y1end )
658 *uout++ = crop( (*y1in * -11058 + (*vin - V) * -15504)
660 *vout++ = crop( (*y1in * 32768 + (*vin - V) * 45941)
662 *y1out++ = crop( (*y1in++ * 19595 + (*vin - V) * 27473)
664 *y1out++ = crop( (*y1in++ * 19595 + (*vin++ - V) * 27473)
667 y1in += i_pitch - i_visible_pitch;
668 y1out += i_pitch - i_visible_pitch;
669 uout += i_uv_pitch - i_uv_visible_pitch;
670 vin += i_uv_pitch - i_uv_visible_pitch;
671 vout += i_uv_pitch - i_uv_visible_pitch;
675 static void get_green_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
676 int yp, int up, int vp )
678 uint8_t *y1in = p_inpic->p[yp].p_pixels;
679 uint8_t *uin = p_inpic->p[up].p_pixels;
680 uint8_t *vin = p_inpic->p[vp].p_pixels;
682 uint8_t *y1out = p_outpic->p[yp].p_pixels;
683 uint8_t *uout = p_outpic->p[up].p_pixels;
684 uint8_t *vout = p_outpic->p[vp].p_pixels;
686 const int i_pitch = p_inpic->p[yp].i_pitch;
687 const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
688 const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
690 const int i_uv_pitch = p_inpic->p[up].i_pitch;
691 const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
693 const uint8_t *yend = y1in + i_visible_lines * i_pitch;
696 const uint8_t *y1end = y1in + i_visible_pitch;
697 while( y1in < y1end )
704 *uout++ = crop( (*y1in * -21710 + (*uin-U) * 7471 + (*vin-V) * 15504)
706 *vout++ = crop( (*y1in * -27439 + (*uin-U) * 9443 + (*vin-V) * 19595)
708 *y1out++ = crop( (*y1in++ * 38470 + (*uin-U) * -13239 + (*vin-V) * -27473)
710 *y1out++ = crop( (*y1in++ * 38470 + (*uin++-U) * -13239 + (*vin++-V) * -27473)
713 y1in += i_pitch - i_visible_pitch;
714 y1out += i_pitch - i_visible_pitch;
715 uin += i_uv_pitch - i_uv_visible_pitch;
716 uout += i_uv_pitch - i_uv_visible_pitch;
717 vin += i_uv_pitch - i_uv_visible_pitch;
718 vout += i_uv_pitch - i_uv_visible_pitch;
722 static void get_blue_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
723 int yp, int up, int vp )
725 uint8_t *y1in = p_inpic->p[yp].p_pixels;
726 uint8_t *uin = p_inpic->p[up].p_pixels;
728 uint8_t *y1out = p_outpic->p[yp].p_pixels;
729 uint8_t *uout = p_outpic->p[up].p_pixels;
730 uint8_t *vout = p_outpic->p[vp].p_pixels;
732 const int i_pitch = p_inpic->p[yp].i_pitch;
733 const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
734 const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
736 const int i_uv_pitch = p_inpic->p[up].i_pitch;
737 const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
739 const uint8_t *yend = y1in + i_visible_lines * i_pitch;
742 const uint8_t *y1end = y1in + i_visible_pitch;
743 while( y1in < y1end )
750 *uout++ = crop( (*y1in* 32768 + (*uin - U) * 58065 )
752 *vout++ = crop( (*y1in * -5329 + (*uin - U) * -9443 )
754 *y1out++ = crop( (*y1in++ * 7471 + (*uin - U) * 13239 )
756 *y1out++ = crop( (*y1in++ * 7471 + (*uin++ - U) * 13239 )
759 y1in += i_pitch - i_visible_pitch;
760 y1out += i_pitch - i_visible_pitch;
761 uin += i_uv_pitch - i_uv_visible_pitch;
762 uout += i_uv_pitch - i_uv_visible_pitch;
763 vout += i_uv_pitch - i_uv_visible_pitch;
767 static int ExtractCallback( vlc_object_t *p_this, char const *psz_var,
768 vlc_value_t oldval, vlc_value_t newval,
771 filter_sys_t *p_sys = (filter_sys_t *)p_data;
773 if( !strcmp( psz_var, FILTER_PREFIX "component" ) )
775 p_sys->i_color = newval.i_int;
776 /* Matrix won't be used for RED, GREEN or BLUE in planar formats */
777 make_projection_matrix( (filter_t *)p_this, p_sys->i_color,
778 p_sys->projection_matrix );
782 msg_Warn( p_this, "Unknown callback command." );