[vlc-devel] [PATCH 1/2] mp4 demux: ensure the PTS is set (to the DTS)
Laurent Aimar
fenrir at elivagar.org
Sun Nov 13 18:41:35 CET 2011
On Sun, Nov 13, 2011 at 12:17:45PM -0500, Rafaël Carré wrote:
> Le Sun, 13 Nov 2011 10:58:16 +0100,
> Laurent Aimar <fenrir at elivagar.org> a écrit :
>
> > On Sun, Nov 13, 2011 at 12:27:07AM -0500, Rafaël Carré wrote:
> > > Also for videos (in case we didn't find the ctts box)
> > > ---
> > > modules/demux/mp4/mp4.c | 4 +---
> > > 1 files changed, 1 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
> > > index 9561d0f..a9914e7 100644
> > > --- a/modules/demux/mp4/mp4.c
> > > +++ b/modules/demux/mp4/mp4.c
> > > @@ -738,10 +738,8 @@ static int Demux( demux_t *p_demux )
> > > i_delta = MP4_TrackGetPTSDelta( tk );
> > > if( i_delta != -1 )
> > > p_block->i_pts = p_block->i_dts + i_delta;
> > > - else if( tk->fmt.i_cat != VIDEO_ES )
> > > - p_block->i_pts = p_block->i_dts;
> > > else
> > > - p_block->i_pts = VLC_TS_INVALID;
> > > + p_block->i_pts = p_block->i_dts;
> >
> > Sadly, this is not right. MP4 files can miss the ctts but still have B frames
> > (or out of ourder I/P).
>
> Is there some section of the spec which tells about out of order I/P ?
> Or can the encoder just choose which ever DTS it wants?
For H264, the display order and the frame type have no relations. Further
more, the reordering can be higher than 1.
> > With this patch, such file will now have a jerky playback.
> >
> > IMHO, The only proper way to fix this issue, is to improve the H264 packetizer
> > but it will be a lot of work.
>
> How are we supposed to infer display order?
In H264 ? By simulating the decoded pictures buffer as described in the spec.
When using VLC for decoding, avcodec does it, which make the file plays nicely.
--
fenrir
More information about the vlc-devel
mailing list