[FFmpeg-devel] GoC 2008 and H264 SVC decoder

Michael Niedermayer michaelni
Sat Mar 29 21:21:16 CET 2008

On Sat, Mar 29, 2008 at 09:15:26PM +0200, Robert Marston wrote:
> Hi
> Struggling with understanding this pts and dts problem with h264, could
> some1 help me with the following questions, Michael perhaps?
> >> Michael Niedermayer wrote:
> >
> > If you look at av_parser_parse() you will see it does some timestamp
> > reordering so the existing timestamps get associated with the correct
> > frames (which are output from av_parser_parse().
> The pts and dts values set here, are they actual pts and dts values from
> the h.264 sequences or do they just to associate a pts and a dts value
> with the packet?

The parser receives PTS/DTS values from the MPEG packets, each of these
packets can contain a random chunk of one or more H.264 access units,
the existing reordering code
will associate these PTS/DTS values with the correct H264 access units.
after that you have a few H.264 access units with PTS/DTS and many with
nothing. That "nothing" is the problem it has to be filled in by parsing
the various headers/SEI/..- of H.264 and by using the surrounding known
DTS/PTS. And this must be done exact, no guessing or approximation. Also
the code cannot look into the future as this would add a delay.

> > compute_pkt_fields() then tries to calculate missing timestamps exactly
> > This goes wrong in various ways for h.264 due to the h264 parser not
> > setting things like has has_b_frames correctly.
> > Also compute_pkt_fields() plain does not have enough information to
> > calculate exact h264 timestamps.
> Aside from the has_b_frames, what else is not set correctly and what
> information is the function missing that it can't set the h.264
> timestamps? ie. Is it possible to add to the h264 parser that will enable
> the compute_pkt_fields() to correctly set the timestamps?

compute_pkt_fields() is designed for MPEG1/2/4 IPB timestamps and reordering
of PTS into DTS for arbitrary codecs with known "has_b_frames". It can also
handle a few other special cases. 
So to awnser your question, no, it cannot calculate H.264 timestamps.
You could of course implement part of the timestamp calculation in the parser
and part in compute_pkt_fields() thats perfectly fine if its cleaner that

> > One way to solve this is to implement what is written in H.222 about H264
> > timestamps in the h264 parser, so that av_parser_parse() returns only
> > frames/fields with timestamps.
> I have looked through H.222 but I am not sure where exactly you are
> referring to with how to handle H264 timestamps?

2.7.5 Conditional coding of timestamps

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080329/5586bba1/attachment.pgp>

More information about the ffmpeg-devel mailing list