1 /*****************************************************************************
2 * deinterlace.c : deinterlacer plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN
5 * $Id: deinterlace.c,v 1.13 2003/05/24 23:40:11 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_("You can choose the default deinterlace mode")
78 static char *mode_list[] = { "discard", "blend", "mean", "bob", "linear", NULL };
81 add_category_hint( N_("Deinterlace"), NULL, VLC_FALSE );
82 add_string_from_list( "deinterlace-mode", "discard", mode_list, NULL,
83 MODE_TEXT, MODE_LONGTEXT, VLC_FALSE );
84 set_description( _("video deinterlacing filter") );
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 var_Create( p_vout, "deinterlace-mode", VLC_VAR_STRING );
140 var_Change( p_vout, "deinterlace-mode", VLC_VAR_INHERITVALUE, NULL, NULL );
141 var_Get( p_vout, "deinterlace-mode", &val );
143 if( val.psz_string == NULL )
145 msg_Err( p_vout, "configuration variable deinterlace-mode empty" );
146 msg_Err( p_vout, "no deinterlace mode provided, using \"discard\"" );
148 val.psz_string = strdup( "discard" );
151 msg_Dbg( p_vout, "using %s deinterlace mode", val.psz_string );
153 SetFilterMethod( p_vout, val.psz_string );
155 free( val.psz_string );
157 var_AddCallback( p_vout, "deinterlace-mode", FilterCallback, NULL );
162 /*****************************************************************************
163 * SetFilterMethod: setup the deinterlace method to use.
164 *****************************************************************************/
165 static void SetFilterMethod( vout_thread_t *p_vout, char *psz_method )
167 if( !strcmp( psz_method, "discard" ) )
169 p_vout->p_sys->i_mode = DEINTERLACE_DISCARD;
170 p_vout->p_sys->b_double_rate = 0;
172 else if( !strcmp( psz_method, "mean" ) )
174 p_vout->p_sys->i_mode = DEINTERLACE_MEAN;
175 p_vout->p_sys->b_double_rate = 0;
177 else if( !strcmp( psz_method, "blend" )
178 || !strcmp( psz_method, "average" )
179 || !strcmp( psz_method, "combine-fields" ) )
181 p_vout->p_sys->i_mode = DEINTERLACE_BLEND;
182 p_vout->p_sys->b_double_rate = 0;
184 else if( !strcmp( psz_method, "bob" )
185 || !strcmp( psz_method, "progressive-scan" ) )
187 p_vout->p_sys->i_mode = DEINTERLACE_BOB;
188 p_vout->p_sys->b_double_rate = 1;
190 else if( !strcmp( psz_method, "linear" ) )
192 p_vout->p_sys->i_mode = DEINTERLACE_LINEAR;
193 p_vout->p_sys->b_double_rate = 1;
197 msg_Err( p_vout, "no valid deinterlace mode provided, "
198 "using \"discard\"" );
201 msg_Dbg( p_vout, "using %s deinterlace method", psz_method );
204 /*****************************************************************************
205 * Init: initialize Deinterlace video thread output method
206 *****************************************************************************/
207 static int Init( vout_thread_t *p_vout )
212 I_OUTPUTPICTURES = 0;
214 /* Initialize the output structure, full of directbuffers since we want
215 * the decoder to output directly to our structures. */
216 switch( p_vout->render.i_chroma )
218 case VLC_FOURCC('I','4','2','0'):
219 case VLC_FOURCC('I','Y','U','V'):
220 case VLC_FOURCC('Y','V','1','2'):
221 case VLC_FOURCC('I','4','2','2'):
222 p_vout->output.i_chroma = p_vout->render.i_chroma;
223 p_vout->output.i_width = p_vout->render.i_width;
224 p_vout->output.i_height = p_vout->render.i_height;
225 p_vout->output.i_aspect = p_vout->render.i_aspect;
229 return VLC_EGENERIC; /* unknown chroma */
233 /* Try to open the real video output */
234 p_vout->p_sys->p_vout = SpawnRealVout( p_vout );
236 if( p_vout->p_sys->p_vout == NULL )
238 /* Everything failed */
239 msg_Err( p_vout, "cannot open vout, aborting" );
244 ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
246 ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
251 /*****************************************************************************
252 * SpawnRealVout: spawn the real video output.
253 *****************************************************************************/
254 static vout_thread_t *SpawnRealVout( vout_thread_t *p_vout )
256 vout_thread_t *p_real_vout = NULL;
258 msg_Dbg( p_vout, "spawning the real video output" );
260 switch( p_vout->render.i_chroma )
262 case VLC_FOURCC('I','4','2','0'):
263 case VLC_FOURCC('I','Y','U','V'):
264 case VLC_FOURCC('Y','V','1','2'):
265 switch( p_vout->p_sys->i_mode )
267 case DEINTERLACE_MEAN:
268 case DEINTERLACE_DISCARD:
271 p_vout->output.i_width, p_vout->output.i_height / 2,
272 p_vout->output.i_chroma, p_vout->output.i_aspect );
275 case DEINTERLACE_BOB:
276 case DEINTERLACE_BLEND:
277 case DEINTERLACE_LINEAR:
280 p_vout->output.i_width, p_vout->output.i_height,
281 p_vout->output.i_chroma, p_vout->output.i_aspect );
286 case VLC_FOURCC('I','4','2','2'):
289 p_vout->output.i_width, p_vout->output.i_height,
290 VLC_FOURCC('I','4','2','0'), p_vout->output.i_aspect );
300 /*****************************************************************************
301 * End: terminate Deinterlace video thread output method
302 *****************************************************************************/
303 static void End( vout_thread_t *p_vout )
307 /* Free the fake output buffers we allocated */
308 for( i_index = I_OUTPUTPICTURES ; i_index ; )
311 free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
315 /*****************************************************************************
316 * Destroy: destroy Deinterlace video thread output method
317 *****************************************************************************
318 * Terminate an output method created by DeinterlaceCreateOutputMethod
319 *****************************************************************************/
320 static void Destroy( vlc_object_t *p_this )
322 vout_thread_t *p_vout = (vout_thread_t *)p_this;
324 DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
326 vlc_object_detach( p_vout->p_sys->p_vout );
327 vout_Destroy( p_vout->p_sys->p_vout );
329 free( p_vout->p_sys );
332 /*****************************************************************************
333 * Render: displays previously rendered output
334 *****************************************************************************
335 * This function send the currently rendered image to Deinterlace image,
336 * waits until it is displayed and switch the two rendering buffers, preparing
338 *****************************************************************************/
339 static void Render ( vout_thread_t *p_vout, picture_t *p_pic )
341 picture_t *pp_outpic[2];
343 vlc_mutex_lock( &p_vout->p_sys->filter_lock );
345 /* Get a new picture */
346 while( ( pp_outpic[0] = vout_CreatePicture( p_vout->p_sys->p_vout,
350 if( p_vout->b_die || p_vout->b_error )
352 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
355 msleep( VOUT_OUTMEM_SLEEP );
358 vout_DatePicture( p_vout->p_sys->p_vout, pp_outpic[0], p_pic->date );
360 /* If we are using double rate, get an additional new picture */
361 if( p_vout->p_sys->b_double_rate )
363 while( ( pp_outpic[1] = vout_CreatePicture( p_vout->p_sys->p_vout,
367 if( p_vout->b_die || p_vout->b_error )
369 vout_DestroyPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
370 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
373 msleep( VOUT_OUTMEM_SLEEP );
376 /* 20ms is a bit arbitrary, but it's only for the first image we get */
377 if( !p_vout->p_sys->last_date )
379 vout_DatePicture( p_vout->p_sys->p_vout, pp_outpic[1],
380 p_pic->date + 20000 );
384 vout_DatePicture( p_vout->p_sys->p_vout, pp_outpic[1],
385 (3 * p_pic->date - p_vout->p_sys->last_date) / 2 );
387 p_vout->p_sys->last_date = p_pic->date;
390 switch( p_vout->p_sys->i_mode )
392 case DEINTERLACE_DISCARD:
393 RenderDiscard( p_vout, pp_outpic[0], p_pic, 0 );
394 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
397 case DEINTERLACE_BOB:
398 RenderBob( p_vout, pp_outpic[0], p_pic, 0 );
399 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
400 RenderBob( p_vout, pp_outpic[1], p_pic, 1 );
401 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[1] );
404 case DEINTERLACE_LINEAR:
405 RenderLinear( p_vout, pp_outpic[0], p_pic, 0 );
406 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
407 RenderLinear( p_vout, pp_outpic[1], p_pic, 1 );
408 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[1] );
411 case DEINTERLACE_MEAN:
412 RenderMean( p_vout, pp_outpic[0], p_pic );
413 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
416 case DEINTERLACE_BLEND:
417 RenderBlend( p_vout, pp_outpic[0], p_pic );
418 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
422 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
425 /*****************************************************************************
426 * RenderDiscard: only keep TOP or BOTTOM field, discard the other.
427 *****************************************************************************/
428 static void RenderDiscard( vout_thread_t *p_vout,
429 picture_t *p_outpic, picture_t *p_pic, int i_field )
433 /* Copy image and skip lines */
434 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
436 uint8_t *p_in, *p_out_end, *p_out;
439 p_in = p_pic->p[i_plane].p_pixels
440 + i_field * p_pic->p[i_plane].i_pitch;
442 p_out = p_outpic->p[i_plane].p_pixels;
443 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
444 * p_outpic->p[i_plane].i_lines;
446 switch( p_vout->render.i_chroma )
448 case VLC_FOURCC('I','4','2','0'):
449 case VLC_FOURCC('I','Y','U','V'):
450 case VLC_FOURCC('Y','V','1','2'):
452 for( ; p_out < p_out_end ; )
454 p_vout->p_vlc->pf_memcpy( p_out, p_in,
455 p_pic->p[i_plane].i_pitch );
457 p_out += p_pic->p[i_plane].i_pitch;
458 p_in += 2 * p_pic->p[i_plane].i_pitch;
462 case VLC_FOURCC('I','4','2','2'):
464 i_increment = 2 * p_pic->p[i_plane].i_pitch;
466 if( i_plane == Y_PLANE )
468 for( ; p_out < p_out_end ; )
470 p_vout->p_vlc->pf_memcpy( p_out, p_in,
471 p_pic->p[i_plane].i_pitch );
472 p_out += p_pic->p[i_plane].i_pitch;
473 p_vout->p_vlc->pf_memcpy( p_out, p_in,
474 p_pic->p[i_plane].i_pitch );
475 p_out += p_pic->p[i_plane].i_pitch;
481 for( ; p_out < p_out_end ; )
483 p_vout->p_vlc->pf_memcpy( p_out, p_in,
484 p_pic->p[i_plane].i_pitch );
485 p_out += p_pic->p[i_plane].i_pitch;
497 /*****************************************************************************
498 * RenderBob: renders a BOB picture - simple copy
499 *****************************************************************************/
500 static void RenderBob( vout_thread_t *p_vout,
501 picture_t *p_outpic, picture_t *p_pic, int i_field )
505 /* Copy image and skip lines */
506 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
508 uint8_t *p_in, *p_out_end, *p_out;
510 p_in = p_pic->p[i_plane].p_pixels;
511 p_out = p_outpic->p[i_plane].p_pixels;
512 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
513 * p_outpic->p[i_plane].i_lines;
515 /* For BOTTOM field we need to add the first line */
518 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
519 p_in += p_pic->p[i_plane].i_pitch;
520 p_out += p_pic->p[i_plane].i_pitch;
523 p_out_end -= 2 * p_outpic->p[i_plane].i_pitch;
525 for( ; p_out < p_out_end ; )
527 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
529 p_out += p_pic->p[i_plane].i_pitch;
531 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
533 p_in += 2 * p_pic->p[i_plane].i_pitch;
534 p_out += p_pic->p[i_plane].i_pitch;
537 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
539 /* For TOP field we need to add the last line */
542 p_in += p_pic->p[i_plane].i_pitch;
543 p_out += p_pic->p[i_plane].i_pitch;
544 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
549 /*****************************************************************************
550 * RenderLinear: BOB with linear interpolation
551 *****************************************************************************/
552 static void RenderLinear( vout_thread_t *p_vout,
553 picture_t *p_outpic, picture_t *p_pic, int i_field )
557 /* Copy image and skip lines */
558 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
560 uint8_t *p_in, *p_out_end, *p_out;
562 p_in = p_pic->p[i_plane].p_pixels;
563 p_out = p_outpic->p[i_plane].p_pixels;
564 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
565 * p_outpic->p[i_plane].i_lines;
567 /* For BOTTOM field we need to add the first line */
570 p_vout->p_vlc->pf_memcpy( p_out, p_in,
571 p_pic->p[i_plane].i_pitch );
572 p_in += p_pic->p[i_plane].i_pitch;
573 p_out += p_pic->p[i_plane].i_pitch;
576 p_out_end -= 2 * p_outpic->p[i_plane].i_pitch;
578 for( ; p_out < p_out_end ; )
580 p_vout->p_vlc->pf_memcpy( p_out, p_in,
581 p_pic->p[i_plane].i_pitch );
583 p_out += p_pic->p[i_plane].i_pitch;
585 Merge( p_out, p_in, p_in + 2 * p_pic->p[i_plane].i_pitch,
586 p_pic->p[i_plane].i_pitch );
588 p_in += 2 * p_pic->p[i_plane].i_pitch;
589 p_out += p_pic->p[i_plane].i_pitch;
592 p_vout->p_vlc->pf_memcpy( p_out, p_in,
593 p_pic->p[i_plane].i_pitch );
595 /* For TOP field we need to add the last line */
598 p_in += p_pic->p[i_plane].i_pitch;
599 p_out += p_pic->p[i_plane].i_pitch;
600 p_vout->p_vlc->pf_memcpy( p_out, p_in,
601 p_pic->p[i_plane].i_pitch );
606 static void RenderMean( vout_thread_t *p_vout,
607 picture_t *p_outpic, picture_t *p_pic )
611 /* Copy image and skip lines */
612 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
614 uint8_t *p_in, *p_out_end, *p_out;
616 p_in = p_pic->p[i_plane].p_pixels;
618 p_out = p_outpic->p[i_plane].p_pixels;
619 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
620 * p_outpic->p[i_plane].i_lines;
622 /* All lines: mean value */
623 for( ; p_out < p_out_end ; )
625 Merge( p_out, p_in, p_in + p_pic->p[i_plane].i_pitch,
626 p_pic->p[i_plane].i_pitch );
628 p_out += p_pic->p[i_plane].i_pitch;
629 p_in += 2 * p_pic->p[i_plane].i_pitch;
634 static void RenderBlend( vout_thread_t *p_vout,
635 picture_t *p_outpic, picture_t *p_pic )
639 /* Copy image and skip lines */
640 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
642 uint8_t *p_in, *p_out_end, *p_out;
644 p_in = p_pic->p[i_plane].p_pixels;
646 p_out = p_outpic->p[i_plane].p_pixels;
647 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
648 * p_outpic->p[i_plane].i_lines;
650 /* First line: simple copy */
651 p_vout->p_vlc->pf_memcpy( p_out, p_in,
652 p_pic->p[i_plane].i_pitch );
653 p_out += p_pic->p[i_plane].i_pitch;
655 /* Remaining lines: mean value */
656 for( ; p_out < p_out_end ; )
658 Merge( p_out, p_in, p_in + p_pic->p[i_plane].i_pitch,
659 p_pic->p[i_plane].i_pitch );
661 p_out += p_pic->p[i_plane].i_pitch;
662 p_in += p_pic->p[i_plane].i_pitch;
667 static void Merge( void *_p_dest, const void *_p_s1,
668 const void *_p_s2, size_t i_bytes )
670 uint8_t* p_dest = (uint8_t*)_p_dest;
671 const uint8_t *p_s1 = (const uint8_t *)_p_s1;
672 const uint8_t *p_s2 = (const uint8_t *)_p_s2;
673 uint8_t* p_end = p_dest + i_bytes - 8;
675 while( p_dest < p_end )
677 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
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;
689 while( p_dest < p_end )
691 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
695 /*****************************************************************************
696 * SendEvents: forward mouse and keyboard events to the parent p_vout
697 *****************************************************************************/
698 static int SendEvents( vlc_object_t *p_this, char const *psz_var,
699 vlc_value_t oldval, vlc_value_t newval, void *_p_vout )
701 vout_thread_t *p_vout = (vout_thread_t *)_p_vout;
702 vlc_value_t sentval = newval;
704 if( !strcmp( psz_var, "mouse-y" ) )
706 switch( p_vout->p_sys->i_mode )
708 case DEINTERLACE_MEAN:
709 case DEINTERLACE_DISCARD:
715 var_Set( p_vout, psz_var, sentval );
720 /*****************************************************************************
721 * FilterCallback: called when changing the deinterlace method on the fly.
722 *****************************************************************************/
723 static int FilterCallback( vlc_object_t *p_this, char const *psz_cmd,
724 vlc_value_t oldval, vlc_value_t newval,
727 vout_thread_t * p_vout = (vout_thread_t *)p_this;
728 int i_old_mode = p_vout->p_sys->i_mode;
730 msg_Dbg( p_vout, "using %s deinterlace mode", newval.psz_string );
732 vlc_mutex_lock( &p_vout->p_sys->filter_lock );
734 SetFilterMethod( p_vout, newval.psz_string );
736 switch( p_vout->render.i_chroma )
738 case VLC_FOURCC('I','4','2','2'):
739 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
743 case VLC_FOURCC('I','4','2','0'):
744 case VLC_FOURCC('I','Y','U','V'):
745 case VLC_FOURCC('Y','V','1','2'):
746 switch( p_vout->p_sys->i_mode )
748 case DEINTERLACE_MEAN:
749 case DEINTERLACE_DISCARD:
750 if( ( i_old_mode == DEINTERLACE_MEAN )
751 || ( i_old_mode == DEINTERLACE_DISCARD ) )
753 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
758 case DEINTERLACE_BOB:
759 case DEINTERLACE_BLEND:
760 case DEINTERLACE_LINEAR:
761 if( ( i_old_mode == DEINTERLACE_BOB )
762 || ( i_old_mode == DEINTERLACE_BLEND )
763 || ( i_old_mode == DEINTERLACE_LINEAR ) )
765 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
776 /* We need to kill the old vout */
778 DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
780 vlc_object_detach( p_vout->p_sys->p_vout );
781 vout_Destroy( p_vout->p_sys->p_vout );
783 /* Try to open a new video output */
784 p_vout->p_sys->p_vout = SpawnRealVout( p_vout );
786 if( p_vout->p_sys->p_vout == NULL )
788 /* Everything failed */
789 msg_Err( p_vout, "cannot open vout, aborting" );
791 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
795 ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
797 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );