- i_chroma == VLC_CODEC_I422;
-}
-
-/*****************************************************************************
- * Init: initialize Deinterlace video thread output method
- *****************************************************************************/
-static int Init( vout_thread_t *p_vout )
-{
- I_OUTPUTPICTURES = 0;
-
- if( !IsChromaSupported( p_vout->render.i_chroma ) )
- return VLC_EGENERIC; /* unknown chroma */
-
- /* Initialize the output structure, full of directbuffers since we want
- * the decoder to output directly to our structures. */
- p_vout->output.i_chroma = p_vout->render.i_chroma;
- p_vout->output.i_width = p_vout->render.i_width;
- p_vout->output.i_height = p_vout->render.i_height;
- p_vout->output.i_aspect = p_vout->render.i_aspect;
- p_vout->fmt_out = p_vout->fmt_in;
-
- /* Try to open the real video output */
- p_vout->p_sys->p_vout = SpawnRealVout( p_vout );
-
- if( p_vout->p_sys->p_vout == NULL )
- {
- /* Everything failed */
- msg_Err( p_vout, "cannot open vout, aborting" );
-
- return VLC_EGENERIC;
- }
-
- vout_filter_AllocateDirectBuffers( p_vout, VOUT_MAX_PICTURES );
-
- vout_filter_AddChild( p_vout, p_vout->p_sys->p_vout, MouseEvent );
-
- var_AddCallback( p_vout, "deinterlace-mode", FilterCallback, NULL );
-
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * SpawnRealVout: spawn the real video output.
- *****************************************************************************/
-static vout_thread_t *SpawnRealVout( vout_thread_t *p_vout )
-{
- msg_Dbg( p_vout, "spawning the real video output" );
-
- video_format_t fmt;
- GetOutputFormat( p_vout, &fmt, &p_vout->fmt_out );
-
- return vout_Create( p_vout, &fmt );
-}
-
-/*****************************************************************************
- * End: terminate Deinterlace video thread output method
- *****************************************************************************/
-static void End( vout_thread_t *p_vout )
-{
- vout_sys_t *p_sys = p_vout->p_sys;
-
- var_DelCallback( p_vout, "deinterlace-mode", FilterCallback, NULL );
-
- if( p_sys->p_vout )
- {
- vout_filter_DelChild( p_vout, p_sys->p_vout, MouseEvent );
- vout_CloseAndRelease( p_sys->p_vout );
- }
-
- vout_filter_ReleaseDirectBuffers( p_vout );
-}
-
-/*****************************************************************************
- * Destroy: destroy Deinterlace video thread output method
- *****************************************************************************
- * Terminate an output method created by DeinterlaceCreateOutputMethod
- *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
-{
- vout_thread_t *p_vout = (vout_thread_t *)p_this;
- vlc_mutex_destroy( &p_vout->p_sys->filter_lock );
- free( p_vout->p_sys );
-}
-
-/**
- * Forward mouse event with proper conversion.
- */
-static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
- vlc_value_t oldval, vlc_value_t newval, void *p_data )
-{
- vout_thread_t *p_vout = p_data;
- VLC_UNUSED(p_this); VLC_UNUSED(oldval);
-
- if( !strcmp( psz_var, "mouse-y" ) && p_vout->p_sys->b_half_height )
- newval.i_int *= 2;
-
- return var_Set( p_vout, psz_var, newval );
-}
-
-/*****************************************************************************
- * Render: displays previously rendered output
- *****************************************************************************
- * This function send the currently rendered image to Deinterlace image,
- * waits until it is displayed and switch the two rendering buffers, preparing
- * next frame.
- *****************************************************************************/
-static void Render ( vout_thread_t *p_vout, picture_t *p_pic )
-{
- vout_sys_t *p_sys = p_vout->p_sys;
- picture_t *pp_outpic[2];
-
- /* FIXME are they needed ? */
- p_vout->fmt_out.i_x_offset = p_vout->fmt_in.i_x_offset;
- p_vout->fmt_out.i_y_offset = p_vout->fmt_in.i_y_offset;
- p_vout->fmt_out.i_visible_width = p_vout->fmt_in.i_visible_width;
- p_vout->fmt_out.i_visible_height = p_vout->fmt_in.i_visible_height;
-
- /* FIXME p_sys->p_vout->* should NOT be changed FIXME */
- p_sys->p_vout->fmt_in.i_x_offset = p_vout->fmt_out.i_x_offset;
- p_sys->p_vout->fmt_in.i_y_offset = p_vout->fmt_out.i_y_offset;
- p_sys->p_vout->fmt_in.i_visible_width = p_vout->fmt_out.i_visible_width;
- p_sys->p_vout->fmt_in.i_visible_height = p_vout->fmt_in.i_visible_height;
- if( p_vout->p_sys->b_half_height )
- {
- p_sys->p_vout->fmt_in.i_y_offset /= 2;
- p_sys->p_vout->fmt_in.i_visible_height /= 2;
- }
-
- if( p_vout->i_changes & VOUT_ASPECT_CHANGE )
- {
- p_vout->i_changes &= ~VOUT_ASPECT_CHANGE;
-
- p_vout->fmt_out.i_aspect = p_vout->fmt_in.i_aspect;
- p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num;
- p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den;
-
- video_format_t fmt = p_vout->fmt_out;
- if( p_vout->p_sys->b_half_height )
- {
- fmt.i_height /= 2; fmt.i_visible_height /= 2; fmt.i_y_offset /= 2;
- fmt.i_sar_den *= 2;
- }
-
- p_sys->p_vout = vout_Request( p_vout, p_sys->p_vout, &fmt );
- }
- if( !p_sys->p_vout )
- return;
-
- pp_outpic[0] = pp_outpic[1] = NULL;
-
- vlc_mutex_lock( &p_vout->p_sys->filter_lock );
-
- /* Get a new picture */
- while( ( pp_outpic[0] = vout_CreatePicture( p_vout->p_sys->p_vout,
- 0, 0, 0 ) )
- == NULL )
- {
- if( !vlc_object_alive( p_vout ) || p_vout->b_error )
- {
- vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
- return;
- }
- msleep( VOUT_OUTMEM_SLEEP );
- }
-
- pp_outpic[0]->date = p_pic->date;
-
- /* If we are using double rate, get an additional new picture */
- if( p_vout->p_sys->b_double_rate )
- {
- while( ( pp_outpic[1] = vout_CreatePicture( p_vout->p_sys->p_vout,
- 0, 0, 0 ) )
- == NULL )
- {
- if( !vlc_object_alive( p_vout ) || p_vout->b_error )
- {
- vout_DestroyPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
- vlc_mutex_unlock( &p_vout->p_sys->filter_lock );
- return;
- }
- msleep( VOUT_OUTMEM_SLEEP );
- }
-
- /* 20ms is a bit arbitrary, but it's only for the first image we get */
- if( !p_vout->p_sys->last_date )
- pp_outpic[1]->date = p_pic->date + 20000;
- else
- pp_outpic[1]->date = (3 * p_pic->date - p_vout->p_sys->last_date) / 2;
- p_vout->p_sys->last_date = p_pic->date;
- }
-
- switch( p_vout->p_sys->i_mode )
- {
- case DEINTERLACE_DISCARD:
- RenderDiscard( p_vout, pp_outpic[0], p_pic, 0 );
- vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
- break;
-
- case DEINTERLACE_BOB:
- RenderBob( p_vout, pp_outpic[0], p_pic, p_pic->b_top_field_first ? 0 : 1 );
- vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
- RenderBob( p_vout, pp_outpic[1], p_pic, p_pic->b_top_field_first ? 1 : 0 );
- vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[1] );
- break;
-
- case DEINTERLACE_LINEAR:
- RenderLinear( p_vout, pp_outpic[0], p_pic, p_pic->b_top_field_first ? 0 : 1 );
- vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
- RenderLinear( p_vout, pp_outpic[1], p_pic, p_pic->b_top_field_first ? 1 : 0 );
- vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[1] );
- break;
-
- case DEINTERLACE_MEAN:
- RenderMean( p_vout, pp_outpic[0], p_pic );
- vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
- break;
-
- case DEINTERLACE_BLEND:
- RenderBlend( p_vout, pp_outpic[0], p_pic );
- vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
- break;
-
- case DEINTERLACE_X:
- RenderX( pp_outpic[0], p_pic );
- vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] );
- break;
- }
- vlc_mutex_unlock( &p_vout->p_sys->filter_lock );