Commit 5d3d5ee7 authored by Christophe Massiot's avatar Christophe Massiot

* modules/codec/libmpeg2.c, modules/packetizer/mpegvideo.c: Fixed wrong PTS

   and DTS for field pictures.
parent b1b72b63
......@@ -64,6 +64,7 @@ struct decoder_sys_t
vlc_bool_t b_after_sequence_header; /* is it the next frame after
* the sequence header ? */
vlc_bool_t b_slice_i; /* intra-slice refresh stream */
vlc_bool_t b_second_field;
vlc_bool_t b_preroll;
......@@ -143,6 +144,7 @@ static int OpenDecoder( vlc_object_t *p_this )
p_sys->p_picture_to_destroy = NULL;
p_sys->b_garbage_pic = 0;
p_sys->b_slice_i = 0;
p_sys->b_second_field = 0;
p_sys->b_skip = 0;
p_sys->b_preroll = VLC_FALSE;
......@@ -339,20 +341,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
break;
case STATE_PICTURE_2ND:
vout_SynchroNewPicture( p_sys->p_synchro,
p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE,
p_sys->p_info->current_picture->nb_fields,
0, 0, p_sys->i_current_rate,
p_sys->p_info->sequence->flags & SEQ_FLAG_LOW_DELAY );
if( p_sys->b_skip )
{
vout_SynchroTrash( p_sys->p_synchro );
}
else
{
vout_SynchroDecode( p_sys->p_synchro );
}
p_sys->b_second_field = 1;
break;
case STATE_PICTURE:
......@@ -408,8 +397,15 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
p_sys->i_current_dts : p_sys->i_previous_dts ) : 0;
#endif
/* If nb_fields == 1, it is a field picture, and it will be
* followed by another field picture for which we won't call
* vout_SynchroNewPicture() because this would have other
* problems, so we take it into account here.
* This kind of sucks, but I didn't think better. --Meuuh
*/
vout_SynchroNewPicture( p_sys->p_synchro,
p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE,
p_sys->p_info->current_picture->nb_fields == 1 ? 2 :
p_sys->p_info->current_picture->nb_fields, i_pts, i_dts,
p_sys->i_current_rate,
p_sys->p_info->sequence->flags & SEQ_FLAG_LOW_DELAY );
......
......@@ -118,6 +118,7 @@ struct decoder_sys_t
mtime_t i_interpolated_dts;
mtime_t i_old_duration;
mtime_t i_last_ref_pts;
vlc_bool_t b_second_field;
/* Number of pictures since last sequence header */
int i_seq_old;
......@@ -185,6 +186,7 @@ static int Open( vlc_object_t *p_this )
p_sys->i_interpolated_dts = 0;
p_sys->i_old_duration = 0;
p_sys->i_last_ref_pts = 0;
p_sys->b_second_field = 0;
p_sys->b_discontinuity = VLC_FALSE;
p_sys->b_sync_on_intra_frame = var_CreateGetBool( p_dec, "packetizer-mpegvideo-sync-iframe" );
......@@ -433,14 +435,16 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
else
{
/* Correct interpolated dts when we receive a new pts/dts */
if( p_sys->i_last_ref_pts > 0 )
if( p_sys->i_last_ref_pts > 0 && !p_sys->b_second_field )
p_sys->i_interpolated_dts = p_sys->i_last_ref_pts;
if( p_sys->i_dts > 0 ) p_sys->i_interpolated_dts = p_sys->i_dts;
if( !p_sys->b_second_field )
p_sys->i_last_ref_pts = p_sys->i_pts;
}
p_pic->i_dts = p_sys->i_interpolated_dts;
p_sys->i_interpolated_dts += i_duration;
/* Set PTS only if we have a B frame or if it comes from the stream */
if( p_sys->i_pts > 0 )
......@@ -456,17 +460,6 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
p_pic->i_pts = 0;
}
if( p_sys->b_low_delay || p_sys->i_picture_type == 0x03 )
{
/* Trivial case (DTS == PTS) */
p_sys->i_interpolated_dts += i_duration;
}
else
{
p_sys->i_interpolated_dts += p_sys->i_old_duration;
p_sys->i_old_duration = i_duration;
}
switch ( p_sys->i_picture_type )
{
case 0x01:
......@@ -491,6 +484,15 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
p_sys->p_frame = NULL;
p_sys->pp_last = &p_sys->p_frame;
p_sys->b_frame_slice = VLC_FALSE;
if( p_sys->i_picture_structure != 0x03 )
{
p_sys->b_second_field = !p_sys->b_second_field;
}
else
{
p_sys->b_second_field = 0;
}
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment