[MPlayer-dev-eng] [PATCH] further dvr-ms playback improvements

John Donaghy johnfdonaghy at gmail.com
Thu Sep 28 04:27:36 CEST 2006


> + asf->avg_vid_frame_time = (float)((double)time*0.001f/(double)asf->vid_frame_ct);
>
> Since avg_vid_frame_time is a double, what is the point of the float cast?

Oops, it was originally a float - so no point anymore.

> Also, floating point constants are type double by default.  Just use this:
> asf->avg_vid_frame_time = time*0.001/asf->vid_frame_ct;

Yes, my C is a bit rusty (too many stored procs for too long!). Thanks.

> Try printing out avg_vid_frame_time and vid_frame_ct for each frame and
> then graphing them.  That should give you a good idea of how long it takes
> to converge on the correct value.
I did that and it stabilizes after 1-2 secs but the pts values in the
file can sometimes be out enough to make the average value change from
say 0.033 to 0.334 for over a minute of playback.

>
> If there is a seek before this occurs, reset the averager to the current
> frame and start over (you could try to keep the data already collected, but
> it doesn't seem worth the trouble).
>
> It would look something like this:
>
> if (asf->vid_frame_ct == -1) {
>     // Seek has reset averaging data, this frame is new start point
>     asf->start_time = time;
>     asf->vid_frame_ct = 0;
> } else if (asf->vid_frame_ct >= 0) {
>     // Estimate average frame time by dividing the total time between our
>     // averaging start frame and this frame by the number of frames.
>     // If each frame time has an maximum error of e, then the max error
>     // of the estimate is 2 * e / vid_frame_ct.
>     asf->vid_frame_ct++;
>     asf->avg_vid_frame_time = (time - asf->start_time)*0.001/asf->vid_frame_ct;
> }
> // else, avg_vid_frame_time is already estimated, do nothing
>
> And in the seek function:
>
> if (asf->vid_frame_ct < XXXX) {
>     // Not enough frame to have an accurate estimate of average frame time
>     asf->vid_frame_ct = -1;  // -1 == start over
> } else {
>     // Estimate is good enough, don't bother calculating a new one
>     asf->vid_frame_ct = -2;  // -2 == finished estimating
> }
>
Actually I did something quite like this at first (except for the
stopping when it stablizes bit) but I didnt submit it because, for
some reason that I couldnt figure out, the audio and video were badly
out of sync after the seek. I hope to investigate this later but I
though I'd get straight playback working first. I guess it is better
to get it all fixed in one patch though.

For what it's worth, all I do know about the seek av sync issue now is
that, since the video-pts you pick up from the file is wrong, it is
probably a mistake to skip audio frames till the audio and video pts
values match. I not sure how this should be handled.

> For extra credit, keep using the old average after a seek until the new
> average is based on more samples than the old one.
That's a good idea. Thanks for your suggestions...

John



More information about the MPlayer-dev-eng mailing list