[MPlayer-dev-eng] enhancement for yuv4mpeg output driver

Trent Piepho xyzzy at speakeasy.org
Thu Jan 20 16:03:51 CET 2005

On Thu, 20 Jan 2005, D Richard Felker III wrote:
> > Into the email message, yes.  Mplayer only prints the fps value to three
> > places when you play a file, so I only copied it down to three places.  I
> > didn't think anyone would feel 10 decimal places were necessary for an example
> > in an email message.....
> But the whole precision is there in MPlayer's fps variable, and will
> get passed to av_reduce if you use it right.

What do you mean by "whole precision"?  If you mean enough precision to turn
any fraction that was converted to a floating point number back into a
fraction, that is theoretically impossible.

> > Secondly, even if I specify -fps 30000/1001, av_reduce() reduces it to
> > 10999/367!  My float->fraction code gets it right.
> But only for special cases... BTW if this is true and av_reduce is
> that broken, it needs to be fixed.

It is not possible take a fraction, turn it into a 32-bit floating point
number, and then turn it back into a fraction equal to the original in all
cases.  For any floating point value you pick, there are an infinite number of
fractions from which it could have come.  There is no way to figure out which
of these it came from.  Therefor, any routine you may come up with will only
work for special cases.

I came up with a simple routine for converting floats to fractions that works
correctly for any frame rate you are ever likely to see.  The routine in lavc
does not even work for all 18 of the ATSC standard formats, much less typical
avi files, while being more complex.  Why do you want me to cut and paste the
code from lavc into vo_yuv4mpeg?

If you want to replace what's in lavc with my code, that's really a different
issue than getting the yuv4mpeg output driver to create a working header.

More information about the MPlayer-dev-eng mailing list