* deinterlace.c : deinterlacer plugin for vlc
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
- * $Id: deinterlace.c,v 1.1 2001/12/30 07:09:55 sam Exp $
+ * $Id: deinterlace.c,v 1.6 2002/02/24 20:51:09 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
{
int i_mode;
struct vout_thread_s *p_vout;
+ mtime_t last_date;
} vout_sys_t;
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int vout_Probe ( probedata_t *p_data );
static int vout_Create ( struct vout_thread_s * );
static int vout_Init ( struct vout_thread_s * );
static void vout_End ( struct vout_thread_s * );
static void vout_Destroy ( struct vout_thread_s * );
static int vout_Manage ( struct vout_thread_s * );
+static void vout_Render ( struct vout_thread_s *, struct picture_s * );
static void vout_Display ( struct vout_thread_s *, struct picture_s * );
/*****************************************************************************
*****************************************************************************/
static void vout_getfunctions( function_list_t * p_function_list )
{
- p_function_list->pf_probe = vout_Probe;
p_function_list->functions.vout.pf_create = vout_Create;
p_function_list->functions.vout.pf_init = vout_Init;
p_function_list->functions.vout.pf_end = vout_End;
p_function_list->functions.vout.pf_destroy = vout_Destroy;
p_function_list->functions.vout.pf_manage = vout_Manage;
+ p_function_list->functions.vout.pf_render = vout_Render;
p_function_list->functions.vout.pf_display = vout_Display;
- p_function_list->functions.vout.pf_setpalette = NULL;
-}
-
-/*****************************************************************************
- * intf_Probe: return a score
- *****************************************************************************/
-static int vout_Probe( probedata_t *p_data )
-{
- return( 0 );
}
/*****************************************************************************
*****************************************************************************/
static int vout_Create( vout_thread_t *p_vout )
{
- char *psz_method;
+ char *psz_method, *psz_method_tmp;
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
}
/* Look what method was requested */
- psz_method = main_GetPszVariable( VOUT_FILTER_VAR, "" );
+ if( !(psz_method = psz_method_tmp
+ = config_GetPszVariable( VOUT_FILTER_VAR )) )
+ {
+ intf_ErrMsg( "vout error: configuration variable %s empty",
+ VOUT_FILTER_VAR );
+ return( 1 );
+ }
while( *psz_method && *psz_method != ':' )
{
p_vout->p_sys->i_mode = DEINTERLACE_MODE_BOB;
}
+ free( psz_method_tmp );
+
return( 0 );
}
* the decoder to output directly to our structures. */
switch( p_vout->render.i_chroma )
{
- case YUV_420_PICTURE:
- case YUV_422_PICTURE:
+ case FOURCC_I420:
+ case FOURCC_IYUV:
+ case FOURCC_YV12:
+ case FOURCC_I422:
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;
}
/* Try to open the real video output, with half the height our images */
- psz_filter = main_GetPszVariable( VOUT_FILTER_VAR, "" );
- main_PutPszVariable( VOUT_FILTER_VAR, "" );
+ psz_filter = config_GetPszVariable( VOUT_FILTER_VAR );
+ config_PutPszVariable( VOUT_FILTER_VAR, NULL );
intf_WarnMsg( 1, "filter: spawning the real video output" );
switch( p_vout->render.i_chroma )
{
- case YUV_420_PICTURE:
+ case FOURCC_I420:
+ case FOURCC_IYUV:
+ case FOURCC_YV12:
switch( p_vout->p_sys->i_mode )
{
case DEINTERLACE_MODE_BOB:
}
break;
- case YUV_422_PICTURE:
+ case FOURCC_I422:
p_vout->p_sys->p_vout =
vout_CreateThread( NULL,
p_vout->output.i_width, p_vout->output.i_height,
- YUV_420_PICTURE, p_vout->output.i_aspect );
+ FOURCC_I420, p_vout->output.i_aspect );
break;
default:
break;
}
+ config_PutPszVariable( VOUT_FILTER_VAR, psz_filter );
+ if( psz_filter ) free( psz_filter );
+
/* Everything failed */
if( p_vout->p_sys->p_vout == NULL )
{
return( 0 );
}
- main_PutPszVariable( VOUT_FILTER_VAR, psz_filter );
+ p_vout->p_sys->last_date = 0;
ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
for( i_index = I_OUTPUTPICTURES ; i_index ; )
{
i_index--;
- free( PP_OUTPUTPICTURE[ i_index ]->planes[ 0 ].p_data );
+ free( PP_OUTPUTPICTURE[ i_index ]->p_data );
}
}
}
/*****************************************************************************
- * vout_Display: displays previously rendered output
+ * vout_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 vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
+static void vout_Render ( vout_thread_t *p_vout, picture_t *p_pic )
{
picture_t *p_outpic;
- int i_index, i_field;
+ int i_plane, i_field;
+ /* 20ms is a bit arbitrary, but it's only for the first image we get */
+ mtime_t new_date = p_vout->p_sys->last_date
+ ? ( 3 * p_pic->date - p_vout->p_sys->last_date ) / 2
+ : p_pic->date + 20000;
+
+ p_vout->p_sys->last_date = p_pic->date;
for( i_field = 0 ; i_field < 2 ; i_field++ )
{
msleep( VOUT_OUTMEM_SLEEP );
}
- /* XXX: completely arbitrary values ! */
vout_DatePicture( p_vout->p_sys->p_vout, p_outpic,
- mdate() + (mtime_t)(50000 + i_field * 20000) );
+ p_pic->date + i_field ? new_date : p_pic->date );
/* Copy image and skip lines */
- for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
+ for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
{
- pixel_data_t *p_in, *p_out_end, *p_out;
+ u8 *p_in, *p_out_end, *p_out;
int i_increment;
- p_in = p_pic->planes[ i_index ].p_data
- + i_field * p_pic->planes[ i_index ].i_line_bytes;
+ p_in = p_pic->p[i_plane].p_pixels
+ + i_field * p_pic->p[i_plane].i_pitch;
- p_out = p_outpic->planes[ i_index ].p_data;
- p_out_end = p_out + p_outpic->planes[ i_index ].i_bytes;
+ p_out = p_outpic->p[i_plane].p_pixels;
+ p_out_end = p_out + p_outpic->p[i_plane].i_pitch
+ * p_outpic->p[i_plane].i_lines;
switch( p_vout->render.i_chroma )
{
- case YUV_420_PICTURE:
+ case FOURCC_I420:
+ case FOURCC_IYUV:
+ case FOURCC_YV12:
switch( p_vout->p_sys->i_mode )
{
case DEINTERLACE_MODE_BOB:
for( ; p_out < p_out_end ; )
{
- FAST_MEMCPY( p_out, p_in,
- p_pic->planes[ i_index ].i_line_bytes );
+ FAST_MEMCPY( p_out, p_in, p_pic->p[i_plane].i_pitch );
- p_out += p_pic->planes[ i_index ].i_line_bytes;
- p_in += 2 * p_pic->planes[ i_index ].i_line_bytes;
+ p_out += p_pic->p[i_plane].i_pitch;
+ p_in += 2 * p_pic->p[i_plane].i_pitch;
}
break;
case DEINTERLACE_MODE_BLEND:
- if( i_index != Y_PLANE )
+ if( i_plane != Y_PLANE )
{
for( ; p_out < p_out_end ; )
{
FAST_MEMCPY( p_out, p_in,
- p_pic->planes[ i_index ].i_line_bytes );
+ p_pic->p[i_plane].i_pitch );
- p_out += p_pic->planes[ i_index ].i_line_bytes;
+ p_out += p_pic->p[i_plane].i_pitch;
FAST_MEMCPY( p_out, p_in,
- p_pic->planes[ i_index ].i_line_bytes );
+ p_pic->p[i_plane].i_pitch );
- p_out += p_pic->planes[ i_index ].i_line_bytes;
- p_in += 2 * p_pic->planes[ i_index ].i_line_bytes;
+ p_out += p_pic->p[i_plane].i_pitch;
+ p_in += 2 * p_pic->p[i_plane].i_pitch;
}
break;
}
if( i_field == 0 )
{
- FAST_MEMCPY( p_out, p_in,
- p_pic->planes[ i_index ].i_line_bytes );
- p_in += 2 * p_pic->planes[ i_index ].i_line_bytes;
- p_out += p_pic->planes[ i_index ].i_line_bytes;
+ FAST_MEMCPY( p_out, p_in, p_pic->p[i_plane].i_pitch );
+ p_in += 2 * p_pic->p[i_plane].i_pitch;
+ p_out += p_pic->p[i_plane].i_pitch;
}
for( ; p_out < p_out_end ; )
{
- FAST_MEMCPY( p_out, p_in,
- p_pic->planes[ i_index ].i_line_bytes );
+ FAST_MEMCPY( p_out, p_in, p_pic->p[i_plane].i_pitch );
- p_out += p_pic->planes[ i_index ].i_line_bytes;
+ p_out += p_pic->p[i_plane].i_pitch;
- memblend( p_out, p_in, p_in + 2 * p_pic->planes[ i_index ].i_line_bytes, p_pic->planes[ i_index ].i_line_bytes );
+ memblend( p_out, p_in,
+ p_in + 2 * p_pic->p[i_plane].i_pitch,
+ p_pic->p[i_plane].i_pitch );
- p_in += 2 * p_pic->planes[ i_index ].i_line_bytes;
- p_out += p_pic->planes[ i_index ].i_line_bytes;
+ p_in += 2 * p_pic->p[i_plane].i_pitch;
+ p_out += p_pic->p[i_plane].i_pitch;
}
break;
}
break;
- case YUV_422_PICTURE:
+ case FOURCC_I422:
- i_increment = 2 * p_pic->planes[ i_index ].i_line_bytes;
+ i_increment = 2 * p_pic->p[i_plane].i_pitch;
- if( i_index == Y_PLANE )
+ if( i_plane == Y_PLANE )
{
for( ; p_out < p_out_end ; )
{
- FAST_MEMCPY( p_out, p_in,
- p_pic->planes[ i_index ].i_line_bytes );
- p_out += p_pic->planes[ i_index ].i_line_bytes;
- FAST_MEMCPY( p_out, p_in,
- p_pic->planes[ i_index ].i_line_bytes );
- p_out += p_pic->planes[ i_index ].i_line_bytes;
+ FAST_MEMCPY( p_out, p_in, p_pic->p[i_plane].i_pitch );
+ p_out += p_pic->p[i_plane].i_pitch;
+ FAST_MEMCPY( p_out, p_in, p_pic->p[i_plane].i_pitch );
+ p_out += p_pic->p[i_plane].i_pitch;
p_in += i_increment;
}
}
{
for( ; p_out < p_out_end ; )
{
- FAST_MEMCPY( p_out, p_in,
- p_pic->planes[ i_index ].i_line_bytes );
- p_out += p_pic->planes[ i_index ].i_line_bytes;
+ FAST_MEMCPY( p_out, p_in, p_pic->p[i_plane].i_pitch );
+ p_out += p_pic->p[i_plane].i_pitch;
p_in += i_increment;
}
}
}
}
+/*****************************************************************************
+ * vout_Display: displays previously rendered output
+ *****************************************************************************
+ * This function send the currently rendered image to Invert image, waits
+ * until it is displayed and switch the two rendering buffers, preparing next
+ * frame.
+ *****************************************************************************/
+static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
+{
+ ;
+}
+
static void *memblend( void *p_dest, const void *p_s1,
const void *p_s2, size_t i_bytes )
{