Commit 881b68a0 authored by Gildas Bazin's avatar Gildas Bazin

* modules/codec/libmpeg2.c: use the DTS in the synchro algorithm.

parent eb6c4509
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id$ * $Id$
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@videolan.org>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -54,9 +54,10 @@ struct decoder_sys_t ...@@ -54,9 +54,10 @@ struct decoder_sys_t
/* /*
* Input properties * Input properties
*/ */
mtime_t i_pts;
mtime_t i_previous_pts; mtime_t i_previous_pts;
mtime_t i_current_pts; mtime_t i_current_pts;
mtime_t i_previous_dts;
mtime_t i_current_dts;
int i_current_rate; int i_current_rate;
picture_t * p_picture_to_destroy; picture_t * p_picture_to_destroy;
vlc_bool_t b_garbage_pic; vlc_bool_t b_garbage_pic;
...@@ -126,9 +127,10 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -126,9 +127,10 @@ static int OpenDecoder( vlc_object_t *p_this )
p_sys->p_mpeg2dec = NULL; p_sys->p_mpeg2dec = NULL;
p_sys->p_synchro = NULL; p_sys->p_synchro = NULL;
p_sys->p_info = NULL; p_sys->p_info = NULL;
p_sys->i_pts = mdate() + DEFAULT_PTS_DELAY;
p_sys->i_current_pts = 0; p_sys->i_current_pts = 0;
p_sys->i_previous_pts = 0; p_sys->i_previous_pts = 0;
p_sys->i_current_dts = 0;
p_sys->i_previous_dts = 0;
p_sys->p_picture_to_destroy = NULL; p_sys->p_picture_to_destroy = NULL;
p_sys->b_garbage_pic = 0; p_sys->b_garbage_pic = 0;
p_sys->b_slice_i = 0; p_sys->b_slice_i = 0;
...@@ -240,17 +242,22 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -240,17 +242,22 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
} }
} }
#ifdef PIC_FLAG_PTS
if( p_block->i_pts ) if( p_block->i_pts )
{ {
#ifdef PIC_FLAG_PTS
mpeg2_pts( p_sys->p_mpeg2dec, (uint32_t)p_block->i_pts ); mpeg2_pts( p_sys->p_mpeg2dec, (uint32_t)p_block->i_pts );
#else /* New interface */ #else /* New interface */
if( p_block->i_pts || p_block->i_dts )
{
mpeg2_tag_picture( p_sys->p_mpeg2dec, mpeg2_tag_picture( p_sys->p_mpeg2dec,
(uint32_t)p_block->i_pts, 0/*dts*/ ); (uint32_t)p_block->i_pts,
(uint32_t)p_block->i_dts );
#endif #endif
p_sys->i_previous_pts = p_sys->i_current_pts; p_sys->i_previous_pts = p_sys->i_current_pts;
p_sys->i_current_pts = p_block->i_pts; p_sys->i_current_pts = p_block->i_pts;
p_sys->i_previous_dts = p_sys->i_current_dts;
p_sys->i_current_dts = p_block->i_dts;
} }
p_sys->i_current_rate = p_block->i_rate; p_sys->i_current_rate = p_block->i_rate;
...@@ -369,7 +376,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -369,7 +376,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
case STATE_PICTURE: case STATE_PICTURE:
{ {
uint8_t *buf[3]; uint8_t *buf[3];
mtime_t i_pts; mtime_t i_pts, i_dts;
buf[0] = buf[1] = buf[2] = NULL; buf[0] = buf[1] = buf[2] = NULL;
if ( p_sys->b_after_sequence_header && if ( p_sys->b_after_sequence_header &&
...@@ -391,14 +398,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -391,14 +398,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
( ( p_sys->p_info->current_picture->pts == ( ( p_sys->p_info->current_picture->pts ==
(uint32_t)p_sys->i_current_pts ) ? (uint32_t)p_sys->i_current_pts ) ?
p_sys->i_current_pts : p_sys->i_previous_pts ) : 0; p_sys->i_current_pts : p_sys->i_previous_pts ) : 0;
i_dts = 0;
#else /* New interface */
i_pts = p_sys->p_info->current_picture->flags & PIC_FLAG_TAGS ?
( ( p_sys->p_info->current_picture->tag ==
(uint32_t)p_sys->i_current_pts ) ?
p_sys->i_current_pts : p_sys->i_previous_pts ) : 0;
#endif
/* Hack to handle demuxers which only have DTS timestamps */ /* Hack to handle demuxers which only have DTS timestamps */
if( !i_pts && !p_block->i_pts && p_block->i_dts > 0 ) if( !i_pts && !p_block->i_pts && p_block->i_dts > 0 )
...@@ -413,10 +413,22 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -413,10 +413,22 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
p_block->i_pts = p_block->i_dts = 0; p_block->i_pts = p_block->i_dts = 0;
/* End hack */ /* End hack */
#else /* New interface */
i_pts = p_sys->p_info->current_picture->flags & PIC_FLAG_TAGS ?
( ( p_sys->p_info->current_picture->tag ==
(uint32_t)p_sys->i_current_pts ) ?
p_sys->i_current_pts : p_sys->i_previous_pts ) : 0;
i_dts = p_sys->p_info->current_picture->flags & PIC_FLAG_TAGS ?
( ( p_sys->p_info->current_picture->tag2 ==
(uint32_t)p_sys->i_current_dts ) ?
p_sys->i_current_dts : p_sys->i_previous_dts ) : 0;
#endif
vout_SynchroNewPicture( p_sys->p_synchro, vout_SynchroNewPicture( p_sys->p_synchro,
p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE, p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE,
p_sys->p_info->current_picture->nb_fields, i_pts, p_sys->p_info->current_picture->nb_fields, i_pts, i_dts,
0, p_sys->i_current_rate ); p_sys->i_current_rate );
if ( !(p_sys->b_slice_i if ( !(p_sys->b_slice_i
&& ((p_sys->p_info->current_picture->flags && ((p_sys->p_info->current_picture->flags
......
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