[FFmpeg-devel] [PATCH 10/10] Implement av_parse_fraction(), and use it in av_parse_video_rate().

Stefano Sabatini stefano.sabatini-lala
Fri Oct 1 09:19:22 CEST 2010


On date Friday 2010-10-01 00:29:55 +0200, Michael Niedermayer encoded:
> On Thu, Sep 30, 2010 at 11:50:57PM +0200, Stefano Sabatini wrote:
> > The new function is useful for parsing framerates, timebases or
> > generic fractions (not necessarily video frame rates).
> 
> see eval.c

#include <libavutil/eval.h>
#include <libavutil/rational.h>

...

double res;
if ((ret = av_parse_and_eval_expr(&res, str, NULL, NULL, NULL, NULL, NULL, 0, NULL)) < 0)
   return ret;
AVRational q = av_d2q(res, INT_MAX);

That's slightly overkill compared to:

if ((ret = av_parse_fraction(&q, str))
   return ret;

...
-- 
FFmpeg = Flucking and Fundamentalist MultiPurpose Encoding/decoding Gem



More information about the ffmpeg-devel mailing list