[MPlayer-dev-eng] Reverted patch of time-based PTS locking

Pásztor Szilárd don at tricon.hu
Tue Aug 14 10:23:30 CEST 2012

Reimar Döffinger:
> Did you try with -mc 100? Actually the sample I tried
> (http://samples.mplayerhq.hu/V-codecs/h264/PAFF/Sat1PAFF.ts) seems
> to work fine even without most of the time (though I admit it is a
> bit hard to tell).

It is indifferent from the -mc parameter. This is not an issue of speed of
catching A-V sync. Also, with -demuxer lavf this code is not in effect by
default at H.264 streams as the PTS reordering code (-correct-pts) is enabled
then. Without -demuxer-lavf, however, it is.

Here is what the code does:
1. wait for two subsequent frames at a PTS difference of "frametime" value,
that is, a sequence of 2 frames in correct order
2. then start replacing video PTS by increments of "frametime"
3. constantly check for drifts: if the recalculated PTS is closer to the
incoming PTS than frametime/10, use original PTS. This eliminates rounding
errors. If recalculated PTS is farther away from incoming PTS than
frametime*20, give up and stop replacing PTS until step 1 happens again

As this shows, this code should not have any effect on A-V sync, it merely
corrects disordered video PTS with being on the safe side as much as possible.

> Where as far as I could tell by the code "correctly" means it doesn't
> even try to get closer than 400 ms. While it might be better than
> nothing, some would consider that unwatchable.

None by me and I'm fairly sure this problem is not up to this code. I'll
upload a sample in the evening where you can check everything.

Meanwhile, an error has been introduced that kind of wrecks lavc signing a
first field correctly in libmpcodecs/vd_ffmpeg.c:

    if(!got_picture) {
        if (avctx->codec->id == CODEC_ID_H264 &&
            skip_frame > AVDISCARD_DEFAULT)
            return &mpi_no_picture; // H.264 first field only
            return NULL;    // skipped image

I think this "skip_frame > AVDISCARD_DEFAULT" should be <= because that's
when the frame is not to be skipped. But I'm not sure at all that this check
is in the right place here, this seems suspicious, maybe it'd be better to
discard the full frame later and not intervene in field detection.


      |  Flying rabbits are amazing. They carry eagles on their backs.  |

More information about the MPlayer-dev-eng mailing list