1 /*****************************************************************************
2 * deinterlace.c : deinterlacer plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN
5 * $Id: deinterlace.c,v 1.8 2003/01/28 13:03:13 gbazin Exp $
7 * Authors: Samuel Hocevar <sam@zoy.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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
34 #include "../filter_common.h"
36 #define DEINTERLACE_DISCARD 1
37 #define DEINTERLACE_MEAN 2
38 #define DEINTERLACE_BLEND 3
39 #define DEINTERLACE_BOB 4
40 #define DEINTERLACE_LINEAR 5
42 /*****************************************************************************
44 *****************************************************************************/
45 static int Create ( vlc_object_t * );
46 static void Destroy ( vlc_object_t * );
48 static int Init ( vout_thread_t * );
49 static void End ( vout_thread_t * );
50 static void Render ( vout_thread_t *, picture_t * );
52 static void RenderDiscard( vout_thread_t *, picture_t *, picture_t *, int );
53 static void RenderBob ( vout_thread_t *, picture_t *, picture_t *, int );
54 static void RenderMean ( vout_thread_t *, picture_t *, picture_t * );
55 static void RenderBlend ( vout_thread_t *, picture_t *, picture_t * );
56 static void RenderLinear ( vout_thread_t *, picture_t *, picture_t *, int );
58 static void Merge ( void *, const void *, const void *, size_t );
60 static int SendEvents ( vlc_object_t *, char const *,
61 vlc_value_t, vlc_value_t, void * );
63 static void SetFilterMethod( vout_thread_t *p_vout, char *psz_method );
64 static vout_thread_t *SpawnRealVout( vout_thread_t *p_vout );
66 /*****************************************************************************
68 *****************************************************************************/
69 static int FilterCallback ( vlc_object_t *, char const *,
70 vlc_value_t, vlc_value_t, void * );
72 /*****************************************************************************
74 *****************************************************************************/
75 #define MODE_TEXT N_("deinterlace mode")
76 #define MODE_LONGTEXT N_("One of \"discard\", \"blend\", \"mean\", \"bob\" or \"linear\"")
78 static char *mode_list[] = { "discard", "blend", "mean", "bob", "linear", NULL };
81 add_category_hint( N_("Miscellaneous"), NULL );
82 add_string_from_list( "deinterlace-mode", "discard", mode_list, NULL,
83 MODE_TEXT, MODE_LONGTEXT );
84 set_description( _("deinterlacing module") );
85 set_capability( "video filter", 0 );
86 add_shortcut( "deinterlace" );
87 set_callbacks( Create, Destroy );
90 /*****************************************************************************
91 * vout_sys_t: Deinterlace video output method descriptor
92 *****************************************************************************
93 * This structure is part of the video output thread descriptor.
94 * It describes the Deinterlace specific properties of an output thread.
95 *****************************************************************************/
98 int i_mode; /* Deinterlace mode */
99 vlc_bool_t b_double_rate; /* Shall we double the framerate? */
104 vout_thread_t *p_vout;
106 vlc_mutex_t filter_lock;
109 /*****************************************************************************
110 * Create: allocates Deinterlace video thread output method
111 *****************************************************************************
112 * This function allocates and initializes a Deinterlace vout method.
113 *****************************************************************************/
114 static int Create( vlc_object_t *p_this )
116 vout_thread_t *p_vout = (vout_thread_t *)p_this;
119 /* Allocate structure */
120 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
121 if( p_vout->p_sys == NULL )
123 msg_Err( p_vout, "out of memory" );
127 p_vout->pf_init = Init;
128 p_vout->pf_end = End;
129 p_vout->pf_manage = NULL;
130 p_vout->pf_render = Render;
131 p_vout->pf_display = NULL;
133 p_vout->p_sys->i_mode = DEINTERLACE_DISCARD;
134 p_vout->p_sys->b_double_rate = 0;
135 p_vout->p_sys->last_date = 0;
136 vlc_mutex_init( p_vout, &p_vout->p_sys->filter_lock );
138 /* Look what method was requested */
139 val.psz_string = config_GetPsz( p_vout, "deinterlace-mode" );
141 var_Create( p_vout, "deinterlace-mode", VLC_VAR_STRING );
143 if( val.psz_string == NULL )
145 msg_Err( p_vout, "configuration variable %s empty",
146 "deinterlace-mode" );
147 msg_Err( p_vout, "no deinterlace mode provided, using \"discard\"" );
149 val.psz_string = strdup( "discard" );
152 var_Set( p_vout, "deinterlace-mode", val );
154 SetFilterMethod( p_vout, val.psz_string );
156 free( val.psz_string );
158 var_AddCallback( p_vout, "deinterlace-mode", FilterCallback, NULL );
163 /*****************************************************************************
164 * SetFilterMethod: setup the deinterlace method to use.
165 *****************************************************************************/
166 static void SetFilterMethod( vout_thread_t *p_vout, char *psz_method )
168 if( !strcmp( psz_method, "discard" ) )
170 p_vout->p_sys->i_mode = DEINTERLACE_DISCARD;
171 p_vout->p_sys->b_double_rate = 0;
173 else if( !strcmp( psz_method, "mean" ) )
175 p_vout->p_sys->i_mode = DEINTERLACE_MEAN;
176 p_vout->p_sys->b_double_rate = 0;
178 else if( !strcmp( psz_method, "blend" )
179 || !strcmp( psz_method, "average" )
180 || !strcmp( psz_method, "combine-fields" ) )
182 p_vout->p_sys->i_mode = DEINTERLACE_BLEND;
183 p_vout->p_sys->b_double_rate = 0;
185 else if( !strcmp( psz_method, "bob" )
186 || !strcmp( psz_method, "progressive-scan" ) )
188 p_vout->p_sys->i_mode = DEINTERLACE_BOB;
189 p_vout->p_sys->b_double_rate = 1;
191 else if( !strcmp( psz_method, "linear" ) )
193 p_vout->p_sys->i_mode = DEINTERLACE_LINEAR;
194 p_vout->p_sys->b_double_rate = 1;
198 msg_Err( p_vout, "no valid deinterlace mode provided, "
199 "using \"discard\"" );
202 msg_Dbg( p_vout, "using %s deinterlace method", psz_method );
205 /*****************************************************************************
206 * Init: initialize Deinterlace video thread output method
207 *****************************************************************************/
208 static int Init( vout_thread_t *p_vout )
213 I_OUTPUTPICTURES = 0;
215 /* Initialize the output structure, full of directbuffers since we want
216 * the decoder to output directly to our structures. */
217 switch( p_vout->render.i_chroma )
219 case VLC_FOURCC('I','4','2','0'):
220 case VLC_FOURCC('I','Y','U','V'):
221 case VLC_FOURCC('Y','V','1','2'):
222 case VLC_FOURCC('I','4','2','2'):
223 p_vout->output.i_chroma = p_vout->render.i_chroma;
224 p_vout->output.i_width = p_vout->render.i_width;
225 p_vout->output.i_height = p_vout->render.i_height;
226 p_vout->output.i_aspect = p_vout->render.i_aspect;
230 return VLC_EGENERIC; /* unknown chroma */
234 /* Try to open the real video output */
235 p_vout->p_sys->p_vout = SpawnRealVout( p_vout );
237 if( p_vout->p_sys->p_vout == NULL )
239 /* Everything failed */
240 msg_Err( p_vout, "cannot open vout, aborting" );
245 ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
247 ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
252 /*****************************************************************************
253 * SpawnRealVout: spawn the real video output.
254 *****************************************************************************/
255 static vout_thread_t *SpawnRealVout( vout_thread_t *p_vout )
257 vout_thread_t *p_real_vout = NULL;
259 msg_Dbg( p_vout, "spawning the real video output" );
261 switch( p_vout->render.i_chroma )
263 case VLC_FOURCC('I','4','2','0'):
264 case VLC_FOURCC('I','Y','U','V'):
265 case VLC_FOURCC('Y','V','1','2'):
266 switch( p_vout->p_sys->i_mode )
268 case DEINTERLACE_MEAN:
269 case DEINTERLACE_DISCARD:
272 p_vout->output.i_width, p_vout->output.i_height / 2,
273 p_vout->output.i_chroma, p_vout->output.i_aspect );
276 case DEINTERLACE_BOB:
277 case DEINTERLACE_BLEND:
278 case DEINTERLACE_LINEAR:
281 p_vout->output.i_width, p_vout->output.i_height,
282 p_vout->output.i_chroma, p_vout->output.i_aspect );
287 case VLC_FOURCC('I','4','2','2'):
290 p_vout->output.i_width, p_vout->output.i_height,
291 VLC_FOURCC('I','4','2','0'), p_vout->output.i_aspect );
301 /*****************************************************************************
302 * End: terminate Deinterlace video thread output method
303 *****************************************************************************/
304 static void End( vout_thread_t *p_vout )
308 /* Free the fake output buffers we allocated */
309 for( i_index = I_OUTPUTPICTURES ; i_index ; )
312 free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
316 /*****************************************************************************
317 * Destroy: destroy Deinterlace video thread output method
318 *****************************************************************************
319 * Terminate an output method created by DeinterlaceCreateOutputMethod
320 *****************************************************************************/
321 static void Destroy( vlc_object_t *p_this )
323 vout_thread_t *p_vout = (vout_thread_t *)p_this;
325 DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
327 vlc_object_detach( p_vout->p_sys->p_vout );
328 vout_Destroy( p_vout->p_sys->p_vout );
330 free( p_vout->p_sys );
333 /*****************************************************************************
334 * Render: displays previously rendered output
335 *****************************************************************************
336 * This function send the currently rendered image to Deinterlace image,
337 * waits until it is displayed and switch the two rendering buffers, preparing
339 *****************************************************************************/
340 static void Render ( vout_thread_t *p_vout, picture_t *p_pic )
342 picture_t *pp_outpic[2];
344 vlc_mutex_lock( &p_vout->p_sys->filter_lock );
346 /* Get a new picture */
347 while( ( pp_outpic[0] = vout_CreatePicture( p_vout->p_sys->p_vout,
351 if( p_vout->b_die || p_vout->b_error )
353 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
356 msleep( VOUT_OUTMEM_SLEEP );
359 vout_DatePicture( p_vout->p_sys->p_vout, pp_outpic[0], p_pic->date );
361 /* If we are using double rate, get an additional new picture */
362 if( p_vout->p_sys->b_double_rate )
364 while( ( pp_outpic[1] = vout_CreatePicture( p_vout->p_sys->p_vout,
368 if( p_vout->b_die || p_vout->b_error )
370 vout_DestroyPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
371 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
374 msleep( VOUT_OUTMEM_SLEEP );
377 /* 20ms is a bit arbitrary, but it's only for the first image we get */
378 if( !p_vout->p_sys->last_date )
380 vout_DatePicture( p_vout->p_sys->p_vout, pp_outpic[1],
381 p_pic->date + 20000 );
385 vout_DatePicture( p_vout->p_sys->p_vout, pp_outpic[1],
386 (3 * p_pic->date - p_vout->p_sys->last_date) / 2 );
388 p_vout->p_sys->last_date = p_pic->date;
391 switch( p_vout->p_sys->i_mode )
393 case DEINTERLACE_DISCARD:
394 RenderDiscard( p_vout, pp_outpic[0], p_pic, 0 );
395 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
398 case DEINTERLACE_BOB:
399 RenderBob( p_vout, pp_outpic[0], p_pic, 0 );
400 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
401 RenderBob( p_vout, pp_outpic[1], p_pic, 1 );
402 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[1] );
405 case DEINTERLACE_LINEAR:
406 RenderLinear( p_vout, pp_outpic[0], p_pic, 0 );
407 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
408 RenderLinear( p_vout, pp_outpic[1], p_pic, 1 );
409 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[1] );
412 case DEINTERLACE_MEAN:
413 RenderMean( p_vout, pp_outpic[0], p_pic );
414 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
417 case DEINTERLACE_BLEND:
418 RenderBlend( p_vout, pp_outpic[0], p_pic );
419 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
423 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
426 /*****************************************************************************
427 * RenderDiscard: only keep TOP or BOTTOM field, discard the other.
428 *****************************************************************************/
429 static void RenderDiscard( vout_thread_t *p_vout,
430 picture_t *p_outpic, picture_t *p_pic, int i_field )
434 /* Copy image and skip lines */
435 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
437 uint8_t *p_in, *p_out_end, *p_out;
440 p_in = p_pic->p[i_plane].p_pixels
441 + i_field * p_pic->p[i_plane].i_pitch;
443 p_out = p_outpic->p[i_plane].p_pixels;
444 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
445 * p_outpic->p[i_plane].i_lines;
447 switch( p_vout->render.i_chroma )
449 case VLC_FOURCC('I','4','2','0'):
450 case VLC_FOURCC('I','Y','U','V'):
451 case VLC_FOURCC('Y','V','1','2'):
453 for( ; p_out < p_out_end ; )
455 p_vout->p_vlc->pf_memcpy( p_out, p_in,
456 p_pic->p[i_plane].i_pitch );
458 p_out += p_pic->p[i_plane].i_pitch;
459 p_in += 2 * p_pic->p[i_plane].i_pitch;
463 case VLC_FOURCC('I','4','2','2'):
465 i_increment = 2 * p_pic->p[i_plane].i_pitch;
467 if( i_plane == Y_PLANE )
469 for( ; p_out < p_out_end ; )
471 p_vout->p_vlc->pf_memcpy( p_out, p_in,
472 p_pic->p[i_plane].i_pitch );
473 p_out += p_pic->p[i_plane].i_pitch;
474 p_vout->p_vlc->pf_memcpy( p_out, p_in,
475 p_pic->p[i_plane].i_pitch );
476 p_out += p_pic->p[i_plane].i_pitch;
482 for( ; p_out < p_out_end ; )
484 p_vout->p_vlc->pf_memcpy( p_out, p_in,
485 p_pic->p[i_plane].i_pitch );
486 p_out += p_pic->p[i_plane].i_pitch;
498 /*****************************************************************************
499 * RenderBob: renders a BOB picture - simple copy
500 *****************************************************************************/
501 static void RenderBob( vout_thread_t *p_vout,
502 picture_t *p_outpic, picture_t *p_pic, int i_field )
506 /* Copy image and skip lines */
507 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
509 uint8_t *p_in, *p_out_end, *p_out;
511 p_in = p_pic->p[i_plane].p_pixels;
512 p_out = p_outpic->p[i_plane].p_pixels;
513 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
514 * p_outpic->p[i_plane].i_lines;
516 /* For BOTTOM field we need to add the first line */
519 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
520 p_in += p_pic->p[i_plane].i_pitch;
521 p_out += p_pic->p[i_plane].i_pitch;
524 p_out_end -= 2 * p_outpic->p[i_plane].i_pitch;
526 for( ; p_out < p_out_end ; )
528 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
530 p_out += p_pic->p[i_plane].i_pitch;
532 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
534 p_in += 2 * p_pic->p[i_plane].i_pitch;
535 p_out += p_pic->p[i_plane].i_pitch;
538 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
540 /* For TOP field we need to add the last line */
543 p_in += p_pic->p[i_plane].i_pitch;
544 p_out += p_pic->p[i_plane].i_pitch;
545 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
550 /*****************************************************************************
551 * RenderLinear: BOB with linear interpolation
552 *****************************************************************************/
553 static void RenderLinear( vout_thread_t *p_vout,
554 picture_t *p_outpic, picture_t *p_pic, int i_field )
558 /* Copy image and skip lines */
559 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
561 uint8_t *p_in, *p_out_end, *p_out;
563 p_in = p_pic->p[i_plane].p_pixels;
564 p_out = p_outpic->p[i_plane].p_pixels;
565 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
566 * p_outpic->p[i_plane].i_lines;
568 /* For BOTTOM field we need to add the first line */
571 p_vout->p_vlc->pf_memcpy( p_out, p_in,
572 p_pic->p[i_plane].i_pitch );
573 p_in += p_pic->p[i_plane].i_pitch;
574 p_out += p_pic->p[i_plane].i_pitch;
577 p_out_end -= 2 * p_outpic->p[i_plane].i_pitch;
579 for( ; p_out < p_out_end ; )
581 p_vout->p_vlc->pf_memcpy( p_out, p_in,
582 p_pic->p[i_plane].i_pitch );
584 p_out += p_pic->p[i_plane].i_pitch;
586 Merge( p_out, p_in, p_in + 2 * p_pic->p[i_plane].i_pitch,
587 p_pic->p[i_plane].i_pitch );
589 p_in += 2 * p_pic->p[i_plane].i_pitch;
590 p_out += p_pic->p[i_plane].i_pitch;
593 p_vout->p_vlc->pf_memcpy( p_out, p_in,
594 p_pic->p[i_plane].i_pitch );
596 /* For TOP field we need to add the last line */
599 p_in += p_pic->p[i_plane].i_pitch;
600 p_out += p_pic->p[i_plane].i_pitch;
601 p_vout->p_vlc->pf_memcpy( p_out, p_in,
602 p_pic->p[i_plane].i_pitch );
607 static void RenderMean( vout_thread_t *p_vout,
608 picture_t *p_outpic, picture_t *p_pic )
612 /* Copy image and skip lines */
613 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
615 uint8_t *p_in, *p_out_end, *p_out;
617 p_in = p_pic->p[i_plane].p_pixels;
619 p_out = p_outpic->p[i_plane].p_pixels;
620 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
621 * p_outpic->p[i_plane].i_lines;
623 /* All lines: mean value */
624 for( ; p_out < p_out_end ; )
626 Merge( p_out, p_in, p_in + p_pic->p[i_plane].i_pitch,
627 p_pic->p[i_plane].i_pitch );
629 p_out += p_pic->p[i_plane].i_pitch;
630 p_in += 2 * p_pic->p[i_plane].i_pitch;
635 static void RenderBlend( vout_thread_t *p_vout,
636 picture_t *p_outpic, picture_t *p_pic )
640 /* Copy image and skip lines */
641 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
643 uint8_t *p_in, *p_out_end, *p_out;
645 p_in = p_pic->p[i_plane].p_pixels;
647 p_out = p_outpic->p[i_plane].p_pixels;
648 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
649 * p_outpic->p[i_plane].i_lines;
651 /* First line: simple copy */
652 p_vout->p_vlc->pf_memcpy( p_out, p_in,
653 p_pic->p[i_plane].i_pitch );
654 p_out += p_pic->p[i_plane].i_pitch;
656 /* Remaining lines: mean value */
657 for( ; p_out < p_out_end ; )
659 Merge( p_out, p_in, p_in + p_pic->p[i_plane].i_pitch,
660 p_pic->p[i_plane].i_pitch );
662 p_out += p_pic->p[i_plane].i_pitch;
663 p_in += p_pic->p[i_plane].i_pitch;
668 static void Merge( void *_p_dest, const void *_p_s1,
669 const void *_p_s2, size_t i_bytes )
671 uint8_t* p_dest = (uint8_t*)_p_dest;
672 const uint8_t *p_s1 = (const uint8_t *)_p_s1;
673 const uint8_t *p_s2 = (const uint8_t *)_p_s2;
674 uint8_t* p_end = p_dest + i_bytes - 8;
676 while( p_dest < p_end )
678 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
679 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
680 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
681 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
682 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
683 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
684 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
685 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
690 while( p_dest < p_end )
692 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
696 /*****************************************************************************
697 * SendEvents: forward mouse and keyboard events to the parent p_vout
698 *****************************************************************************/
699 static int SendEvents( vlc_object_t *p_this, char const *psz_var,
700 vlc_value_t oldval, vlc_value_t newval, void *_p_vout )
702 vout_thread_t *p_vout = (vout_thread_t *)_p_vout;
703 vlc_value_t sentval = newval;
705 if( !strcmp( psz_var, "mouse-y" ) )
707 switch( p_vout->p_sys->i_mode )
709 case DEINTERLACE_MEAN:
710 case DEINTERLACE_DISCARD:
716 var_Set( p_vout, psz_var, sentval );
721 /*****************************************************************************
722 * FilterCallback: called when changing the deinterlace method on the fly.
723 *****************************************************************************/
724 static int FilterCallback( vlc_object_t *p_this, char const *psz_cmd,
725 vlc_value_t oldval, vlc_value_t newval,
728 vout_thread_t * p_vout = (vout_thread_t *)p_this;
729 int i_old_mode = p_vout->p_sys->i_mode;
731 vlc_mutex_lock( &p_vout->p_sys->filter_lock );
733 SetFilterMethod( p_vout, newval.psz_string );
735 switch( p_vout->render.i_chroma )
737 case VLC_FOURCC('I','4','2','2'):
738 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
742 case VLC_FOURCC('I','4','2','0'):
743 case VLC_FOURCC('I','Y','U','V'):
744 case VLC_FOURCC('Y','V','1','2'):
745 switch( p_vout->p_sys->i_mode )
747 case DEINTERLACE_MEAN:
748 case DEINTERLACE_DISCARD:
749 if( ( i_old_mode == DEINTERLACE_MEAN )
750 || ( i_old_mode == DEINTERLACE_DISCARD ) )
752 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
757 case DEINTERLACE_BOB:
758 case DEINTERLACE_BLEND:
759 case DEINTERLACE_LINEAR:
760 if( ( i_old_mode == DEINTERLACE_BOB )
761 || ( i_old_mode == DEINTERLACE_BLEND )
762 || ( i_old_mode == DEINTERLACE_LINEAR ) )
764 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
775 /* We need to kill the old vout */
777 DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
779 vlc_object_detach( p_vout->p_sys->p_vout );
780 vout_Destroy( p_vout->p_sys->p_vout );
782 /* Try to open a new video output */
783 p_vout->p_sys->p_vout = SpawnRealVout( p_vout );
785 if( p_vout->p_sys->p_vout == NULL )
787 /* Everything failed */
788 msg_Err( p_vout, "cannot open vout, aborting" );
790 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
794 ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
796 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );