[MPlayer-dev-eng] [PATCH] buffered pts when -correct-pts

Pásztor Szilárd don at tricon.hu
Tue Aug 17 10:44:44 CEST 2010


Sorry for this mail being long, but for the sake of detailed explanation...

Carl Eugen Hoyos:
> Are you sure you tested -demuxer lavf? It works for me for most (see below)
> samples, including the one you provided.

Hm. Demuxer lavf differs in the sense that it has correct-pts turned on by
default. (BTW, shouldn't it be independent of demuxer type? I'm not sure.)
That's why only blit frames get counted in the end when playback gets on into
the main loop in mplayer.c. But the values in the PTS buffer get corrupted
nevertheless - that's not a question of the demuxer. I can supply an endless
number of samples if you wish, the problem you see will be the same with all.
All in all mplayer keeps A-V sync without the patch but frames are not
distributed evenly in time. Jerky. You can even see it in the rapid changes
to +-200 ms in A-V sync while playback. If you do a dump where you precisely
print frame times, you'll see.

Here's my debug snippet of how the buffer looks without the fix. Additions and
deletions are marked, and so is the bogus cut:

 ADD 22575.81, buf: 22575.81 22575.67 22575.65
 ADD 22575.83, buf: 22575.83 22575.81 22575.67 22575.65
 DEL 22575.65, buf: 22575.83 22575.81 22575.67
Cut to 2 elements, buf: 22575.83 22575.81
Frame displayed, PTS: 22575.65
 ADD 22575.73, buf: 22575.83 22575.81 22575.73
 ADD 22575.75, buf: 22575.83 22575.81 22575.75 22575.73
 DEL 22575.73, buf: 22575.83 22575.81 22575.75
Cut to 2 elements, buf: 22575.83 22575.81
Frame displayed, PTS: 22575.73
 ADD 22575.69, buf: 22575.83 22575.81 22575.69
 ADD 22575.71, buf: 22575.83 22575.81 22575.71 22575.69
 DEL 22575.69, buf: 22575.83 22575.81 22575.71
Cut to 2 elements, buf: 22575.83 22575.81
Frame displayed, PTS: 22575.77
 ADD 22575.77, buf: 22575.83 22575.81 22575.77
 ADD 22575.79, buf: 22575.83 22575.81 22575.79 22575.77
 DEL 22575.77, buf: 22575.83 22575.81 22575.79
Cut to 2 elements, buf: 22575.83 22575.81
Frame displayed, PTS: 22575.77

If you follow the fate of PTS values, it is clear what goes wrong here. Stamps
simply get dropped from the buffer before use and the corrupted values get
overwritten afterwards - but never really fixed. This severely jerks playback.

Same dump after the fix:

 ADD 22575.61, buf: 22575.67 22575.65 22575.61 22575.59 22575.57
 ADD 22575.63, buf: 22575.67 22575.65 22575.63 22575.61 22575.59 22575.57
 DEL 22575.57, buf: 22575.67 22575.65 22575.63 22575.61 22575.59
Cut to 4 elements, buf: 22575.67 22575.65 22575.63 22575.61
Frame displayed, PTS: 22575.57
 ADD 22575.81, buf: 22575.81 22575.67 22575.65 22575.63 22575.61
 ADD 22575.83, buf: 22575.83 22575.81 22575.67 22575.65 22575.63 22575.61
 DEL 22575.61, buf: 22575.83 22575.81 22575.67 22575.65 22575.63
Cut to 4 elements, buf: 22575.83 22575.81 22575.67 22575.65
Frame displayed, PTS: 22575.61
 ADD 22575.73, buf: 22575.83 22575.81 22575.73 22575.67 22575.65
 ADD 22575.75, buf: 22575.83 22575.81 22575.75 22575.73 22575.67 22575.65
 DEL 22575.65, buf: 22575.83 22575.81 22575.75 22575.73 22575.67
Cut to 4 elements, buf: 22575.83 22575.81 22575.75 22575.73
Frame displayed, PTS: 22575.65
 ADD 22575.69, buf: 22575.83 22575.81 22575.75 22575.73 22575.69
 ADD 22575.71, buf: 22575.83 22575.81 22575.75 22575.73 22575.71 22575.69
 DEL 22575.69, buf: 22575.83 22575.81 22575.75 22575.73 22575.71
Cut to 4 elements, buf: 22575.83 22575.81 22575.75 22575.73
Frame displayed, PTS: 22575.69

And this is how it should be, if we're already splitted down into fields...

> > and they were from many Blu-rays, and practically
> > all HDTV streams. And same as with others - I recently saw in the users
> > list archives that a Danish user complained about jerky playback and even
> > sent a sample.
> 
> Which is not fixed by your patch...

It is indeed "fixed". This is the same problem. But let me emphasize that it
is independent of the demuxer; it is only a matter of correct-pts being
enabled or not which is an issue AFTER we've been demuxed. It's only that
different demuxers set this correct-pts differently by default.

s.

     ---------------------------------------------------------------------
     |  When you earnest believe you can compensate for a lack of skill  |
     |  by doubling your efforts, there's no end to what you can't do.   |
     ---------------------------------------------------------------------


More information about the MPlayer-dev-eng mailing list