1 /*****************************************************************************
2 * deinterlace.c : deinterlacer plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN
5 * $Id: deinterlace.c,v 1.14 2003/05/25 11:31:54 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, &val, NULL );
142 if( val.psz_string == NULL )
144 msg_Err( p_vout, "configuration variable deinterlace-mode empty" );
145 msg_Err( p_vout, "no deinterlace mode provided, using \"discard\"" );
147 val.psz_string = strdup( "discard" );
150 msg_Dbg( p_vout, "using %s deinterlace mode", val.psz_string );
152 SetFilterMethod( p_vout, val.psz_string );
154 free( val.psz_string );
156 var_AddCallback( p_vout, "deinterlace-mode", FilterCallback, NULL );
161 /*****************************************************************************
162 * SetFilterMethod: setup the deinterlace method to use.
163 *****************************************************************************/
164 static void SetFilterMethod( vout_thread_t *p_vout, char *psz_method )
166 if( !strcmp( psz_method, "discard" ) )
168 p_vout->p_sys->i_mode = DEINTERLACE_DISCARD;
169 p_vout->p_sys->b_double_rate = 0;
171 else if( !strcmp( psz_method, "mean" ) )
173 p_vout->p_sys->i_mode = DEINTERLACE_MEAN;
174 p_vout->p_sys->b_double_rate = 0;
176 else if( !strcmp( psz_method, "blend" )
177 || !strcmp( psz_method, "average" )
178 || !strcmp( psz_method, "combine-fields" ) )
180 p_vout->p_sys->i_mode = DEINTERLACE_BLEND;
181 p_vout->p_sys->b_double_rate = 0;
183 else if( !strcmp( psz_method, "bob" )
184 || !strcmp( psz_method, "progressive-scan" ) )
186 p_vout->p_sys->i_mode = DEINTERLACE_BOB;
187 p_vout->p_sys->b_double_rate = 1;
189 else if( !strcmp( psz_method, "linear" ) )
191 p_vout->p_sys->i_mode = DEINTERLACE_LINEAR;
192 p_vout->p_sys->b_double_rate = 1;
196 msg_Err( p_vout, "no valid deinterlace mode provided, "
197 "using \"discard\"" );
200 msg_Dbg( p_vout, "using %s deinterlace method", psz_method );
203 /*****************************************************************************
204 * Init: initialize Deinterlace video thread output method
205 *****************************************************************************/
206 static int Init( vout_thread_t *p_vout )
211 I_OUTPUTPICTURES = 0;
213 /* Initialize the output structure, full of directbuffers since we want
214 * the decoder to output directly to our structures. */
215 switch( p_vout->render.i_chroma )
217 case VLC_FOURCC('I','4','2','0'):
218 case VLC_FOURCC('I','Y','U','V'):
219 case VLC_FOURCC('Y','V','1','2'):
220 case VLC_FOURCC('I','4','2','2'):
221 p_vout->output.i_chroma = p_vout->render.i_chroma;
222 p_vout->output.i_width = p_vout->render.i_width;
223 p_vout->output.i_height = p_vout->render.i_height;
224 p_vout->output.i_aspect = p_vout->render.i_aspect;
228 return VLC_EGENERIC; /* unknown chroma */
232 /* Try to open the real video output */
233 p_vout->p_sys->p_vout = SpawnRealVout( p_vout );
235 if( p_vout->p_sys->p_vout == NULL )
237 /* Everything failed */
238 msg_Err( p_vout, "cannot open vout, aborting" );
243 ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
245 ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
250 /*****************************************************************************
251 * SpawnRealVout: spawn the real video output.
252 *****************************************************************************/
253 static vout_thread_t *SpawnRealVout( vout_thread_t *p_vout )
255 vout_thread_t *p_real_vout = NULL;
257 msg_Dbg( p_vout, "spawning the real video output" );
259 switch( p_vout->render.i_chroma )
261 case VLC_FOURCC('I','4','2','0'):
262 case VLC_FOURCC('I','Y','U','V'):
263 case VLC_FOURCC('Y','V','1','2'):
264 switch( p_vout->p_sys->i_mode )
266 case DEINTERLACE_MEAN:
267 case DEINTERLACE_DISCARD:
270 p_vout->output.i_width, p_vout->output.i_height / 2,
271 p_vout->output.i_chroma, p_vout->output.i_aspect );
274 case DEINTERLACE_BOB:
275 case DEINTERLACE_BLEND:
276 case DEINTERLACE_LINEAR:
279 p_vout->output.i_width, p_vout->output.i_height,
280 p_vout->output.i_chroma, p_vout->output.i_aspect );
285 case VLC_FOURCC('I','4','2','2'):
288 p_vout->output.i_width, p_vout->output.i_height,
289 VLC_FOURCC('I','4','2','0'), p_vout->output.i_aspect );
299 /*****************************************************************************
300 * End: terminate Deinterlace video thread output method
301 *****************************************************************************/
302 static void End( vout_thread_t *p_vout )
306 /* Free the fake output buffers we allocated */
307 for( i_index = I_OUTPUTPICTURES ; i_index ; )
310 free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
314 /*****************************************************************************
315 * Destroy: destroy Deinterlace video thread output method
316 *****************************************************************************
317 * Terminate an output method created by DeinterlaceCreateOutputMethod
318 *****************************************************************************/
319 static void Destroy( vlc_object_t *p_this )
321 vout_thread_t *p_vout = (vout_thread_t *)p_this;
323 DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
325 vlc_object_detach( p_vout->p_sys->p_vout );
326 vout_Destroy( p_vout->p_sys->p_vout );
328 free( p_vout->p_sys );
331 /*****************************************************************************
332 * Render: displays previously rendered output
333 *****************************************************************************
334 * This function send the currently rendered image to Deinterlace image,
335 * waits until it is displayed and switch the two rendering buffers, preparing
337 *****************************************************************************/
338 static void Render ( vout_thread_t *p_vout, picture_t *p_pic )
340 picture_t *pp_outpic[2];
342 vlc_mutex_lock( &p_vout->p_sys->filter_lock );
344 /* Get a new picture */
345 while( ( pp_outpic[0] = vout_CreatePicture( p_vout->p_sys->p_vout,
349 if( p_vout->b_die || p_vout->b_error )
351 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
354 msleep( VOUT_OUTMEM_SLEEP );
357 vout_DatePicture( p_vout->p_sys->p_vout, pp_outpic[0], p_pic->date );
359 /* If we are using double rate, get an additional new picture */
360 if( p_vout->p_sys->b_double_rate )
362 while( ( pp_outpic[1] = vout_CreatePicture( p_vout->p_sys->p_vout,
366 if( p_vout->b_die || p_vout->b_error )
368 vout_DestroyPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
369 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
372 msleep( VOUT_OUTMEM_SLEEP );
375 /* 20ms is a bit arbitrary, but it's only for the first image we get */
376 if( !p_vout->p_sys->last_date )
378 vout_DatePicture( p_vout->p_sys->p_vout, pp_outpic[1],
379 p_pic->date + 20000 );
383 vout_DatePicture( p_vout->p_sys->p_vout, pp_outpic[1],
384 (3 * p_pic->date - p_vout->p_sys->last_date) / 2 );
386 p_vout->p_sys->last_date = p_pic->date;
389 switch( p_vout->p_sys->i_mode )
391 case DEINTERLACE_DISCARD:
392 RenderDiscard( p_vout, pp_outpic[0], p_pic, 0 );
393 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
396 case DEINTERLACE_BOB:
397 RenderBob( p_vout, pp_outpic[0], p_pic, 0 );
398 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
399 RenderBob( p_vout, pp_outpic[1], p_pic, 1 );
400 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[1] );
403 case DEINTERLACE_LINEAR:
404 RenderLinear( p_vout, pp_outpic[0], p_pic, 0 );
405 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
406 RenderLinear( p_vout, pp_outpic[1], p_pic, 1 );
407 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[1] );
410 case DEINTERLACE_MEAN:
411 RenderMean( p_vout, pp_outpic[0], p_pic );
412 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
415 case DEINTERLACE_BLEND:
416 RenderBlend( p_vout, pp_outpic[0], p_pic );
417 vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
421 vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
424 /*****************************************************************************
425 * RenderDiscard: only keep TOP or BOTTOM field, discard the other.
426 *****************************************************************************/
427 static void RenderDiscard( vout_thread_t *p_vout,
428 picture_t *p_outpic, picture_t *p_pic, int i_field )
432 /* Copy image and skip lines */
433 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
435 uint8_t *p_in, *p_out_end, *p_out;
438 p_in = p_pic->p[i_plane].p_pixels
439 + i_field * p_pic->p[i_plane].i_pitch;
441 p_out = p_outpic->p[i_plane].p_pixels;
442 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
443 * p_outpic->p[i_plane].i_lines;
445 switch( p_vout->render.i_chroma )
447 case VLC_FOURCC('I','4','2','0'):
448 case VLC_FOURCC('I','Y','U','V'):
449 case VLC_FOURCC('Y','V','1','2'):
451 for( ; p_out < p_out_end ; )
453 p_vout->p_vlc->pf_memcpy( p_out, p_in,
454 p_pic->p[i_plane].i_pitch );
456 p_out += p_pic->p[i_plane].i_pitch;
457 p_in += 2 * p_pic->p[i_plane].i_pitch;
461 case VLC_FOURCC('I','4','2','2'):
463 i_increment = 2 * p_pic->p[i_plane].i_pitch;
465 if( i_plane == Y_PLANE )
467 for( ; p_out < p_out_end ; )
469 p_vout->p_vlc->pf_memcpy( p_out, p_in,
470 p_pic->p[i_plane].i_pitch );
471 p_out += p_pic->p[i_plane].i_pitch;
472 p_vout->p_vlc->pf_memcpy( p_out, p_in,
473 p_pic->p[i_plane].i_pitch );
474 p_out += p_pic->p[i_plane].i_pitch;
480 for( ; p_out < p_out_end ; )
482 p_vout->p_vlc->pf_memcpy( p_out, p_in,
483 p_pic->p[i_plane].i_pitch );
484 p_out += p_pic->p[i_plane].i_pitch;
496 /*****************************************************************************
497 * RenderBob: renders a BOB picture - simple copy
498 *****************************************************************************/
499 static void RenderBob( vout_thread_t *p_vout,
500 picture_t *p_outpic, picture_t *p_pic, int i_field )
504 /* Copy image and skip lines */
505 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
507 uint8_t *p_in, *p_out_end, *p_out;
509 p_in = p_pic->p[i_plane].p_pixels;
510 p_out = p_outpic->p[i_plane].p_pixels;
511 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
512 * p_outpic->p[i_plane].i_lines;
514 /* For BOTTOM field we need to add the first line */
517 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
518 p_in += p_pic->p[i_plane].i_pitch;
519 p_out += p_pic->p[i_plane].i_pitch;
522 p_out_end -= 2 * p_outpic->p[i_plane].i_pitch;
524 for( ; p_out < p_out_end ; )
526 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
528 p_out += p_pic->p[i_plane].i_pitch;
530 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
532 p_in += 2 * p_pic->p[i_plane].i_pitch;
533 p_out += p_pic->p[i_plane].i_pitch;
536 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
538 /* For TOP field we need to add the last line */
541 p_in += p_pic->p[i_plane].i_pitch;
542 p_out += p_pic->p[i_plane].i_pitch;
543 p_vout->p_vlc->pf_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch );
548 /*****************************************************************************
549 * RenderLinear: BOB with linear interpolation
550 *****************************************************************************/
551 static void RenderLinear( vout_thread_t *p_vout,
552 picture_t *p_outpic, picture_t *p_pic, int i_field )
556 /* Copy image and skip lines */
557 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
559 uint8_t *p_in, *p_out_end, *p_out;
561 p_in = p_pic->p[i_plane].p_pixels;
562 p_out = p_outpic->p[i_plane].p_pixels;
563 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
564 * p_outpic->p[i_plane].i_lines;
566 /* For BOTTOM field we need to add the first line */
569 p_vout->p_vlc->pf_memcpy( p_out, p_in,
570 p_pic->p[i_plane].i_pitch );
571 p_in += p_pic->p[i_plane].i_pitch;
572 p_out += p_pic->p[i_plane].i_pitch;
575 p_out_end -= 2 * p_outpic->p[i_plane].i_pitch;
577 for( ; p_out < p_out_end ; )
579 p_vout->p_vlc->pf_memcpy( p_out, p_in,
580 p_pic->p[i_plane].i_pitch );
582 p_out += p_pic->p[i_plane].i_pitch;
584 Merge( p_out, p_in, p_in + 2 * p_pic->p[i_plane].i_pitch,
585 p_pic->p[i_plane].i_pitch );
587 p_in += 2 * p_pic->p[i_plane].i_pitch;
588 p_out += p_pic->p[i_plane].i_pitch;
591 p_vout->p_vlc->pf_memcpy( p_out, p_in,
592 p_pic->p[i_plane].i_pitch );
594 /* For TOP field we need to add the last line */
597 p_in += p_pic->p[i_plane].i_pitch;
598 p_out += p_pic->p[i_plane].i_pitch;
599 p_vout->p_vlc->pf_memcpy( p_out, p_in,
600 p_pic->p[i_plane].i_pitch );
605 static void RenderMean( vout_thread_t *p_vout,
606 picture_t *p_outpic, picture_t *p_pic )
610 /* Copy image and skip lines */
611 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
613 uint8_t *p_in, *p_out_end, *p_out;
615 p_in = p_pic->p[i_plane].p_pixels;
617 p_out = p_outpic->p[i_plane].p_pixels;
618 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
619 * p_outpic->p[i_plane].i_lines;
621 /* All lines: mean value */
622 for( ; p_out < p_out_end ; )
624 Merge( p_out, p_in, p_in + p_pic->p[i_plane].i_pitch,
625 p_pic->p[i_plane].i_pitch );
627 p_out += p_pic->p[i_plane].i_pitch;
628 p_in += 2 * p_pic->p[i_plane].i_pitch;
633 static void RenderBlend( vout_thread_t *p_vout,
634 picture_t *p_outpic, picture_t *p_pic )
638 /* Copy image and skip lines */
639 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
641 uint8_t *p_in, *p_out_end, *p_out;
643 p_in = p_pic->p[i_plane].p_pixels;
645 p_out = p_outpic->p[i_plane].p_pixels;
646 p_out_end = p_out + p_outpic->p[i_plane].i_pitch
647 * p_outpic->p[i_plane].i_lines;
649 /* First line: simple copy */
650 p_vout->p_vlc->pf_memcpy( p_out, p_in,
651 p_pic->p[i_plane].i_pitch );
652 p_out += p_pic->p[i_plane].i_pitch;
654 /* Remaining lines: mean value */
655 for( ; p_out < p_out_end ; )
657 Merge( p_out, p_in, p_in + p_pic->p[i_plane].i_pitch,
658 p_pic->p[i_plane].i_pitch );
660 p_out += p_pic->p[i_plane].i_pitch;
661 p_in += p_pic->p[i_plane].i_pitch;
666 static void Merge( void *_p_dest, const void *_p_s1,
667 const void *_p_s2, size_t i_bytes )
669 uint8_t* p_dest = (uint8_t*)_p_dest;
670 const uint8_t *p_s1 = (const uint8_t *)_p_s1;
671 const uint8_t *p_s2 = (const uint8_t *)_p_s2;
672 uint8_t* p_end = p_dest + i_bytes - 8;
674 while( p_dest < p_end )
676 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
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;
688 while( p_dest < p_end )
690 *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
694 /*****************************************************************************
695 * SendEvents: forward mouse and keyboard events to the parent p_vout
696 *****************************************************************************/
697 static int SendEvents( vlc_object_t *p_this, char const *psz_var,
698 vlc_value_t oldval, vlc_value_t newval, void *_p_vout )
700 vout_thread_t *p_vout = (vout_thread_t *)_p_vout;
701 vlc_value_t sentval = newval;
703 if( !strcmp( psz_var, "mouse-y" ) )
705 switch( p_vout->p_sys->i_mode )
707 case DEINTERLACE_MEAN:
708 case DEINTERLACE_DISCARD:
714 var_Set( p_vout, psz_var, sentval );
719 /*****************************************************************************
720 * FilterCallback: called when changing the deinterlace method on the fly.
721 *****************************************************************************/
722 static int FilterCallback( vlc_object_t *p_this, char const *psz_cmd,
723 vlc_value_t oldval, vlc_value_t newval,
726 vout_thread_t * p_vout = (vout_thread_t *)p_this;
727 int i_old_mode = p_vout->p_sys->i_mode;
729 msg_Dbg( p_vout, "using %s deinterlace mode", newval.psz_string );
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 );