[FFmpeg-devel] [PATCH] Move av_parse_frame_size() and av_parse_frame_rate() from libavcodec to libavcore

Michael Niedermayer michaelni
Mon Jul 26 23:21:59 CEST 2010


oOn Mon, Jul 26, 2010 at 11:38:17AM +0200, Stefano Sabatini wrote:
[...]
> +int av_parse_video_rate(AVRational *frame_rate, const char *arg)
> +{
> +    int i;
> +    int n = FF_ARRAY_ELEMS(video_frame_rate_abbrs);
> +    char *cp;
> +
> +    /* First, we check our abbreviation table */
> +    for (i = 0; i < n; ++i)
> +         if (!strcmp(video_frame_rate_abbrs[i].abbr, arg)) {

> +             frame_rate->num = video_frame_rate_abbrs[i].rate_num;
> +             frame_rate->den = video_frame_rate_abbrs[i].rate_den;

> +             return 0;
> +         }
> +
> +    /* Then, we try to parse it as fraction */
> +    cp = strchr(arg, '/');
> +    if (!cp)
> +        cp = strchr(arg, ':');
> +    if (cp) {
> +        char *cpp;
> +        frame_rate->num = strtol(arg, &cpp, 10);
> +        if (cpp != arg || cpp == cp)
> +            frame_rate->den = strtol(cp+1, &cpp, 10);
> +        else
> +            frame_rate->num = 0;
> +    } else {
> +        /* Finally we give up and parse it as double */
> +        AVRational time_base = av_d2q(strtod(arg, 0), 1001000);
> +        frame_rate->den = time_base.den;
> +        frame_rate->num = time_base.num;
> +    }
> +    if (!frame_rate->num || !frame_rate->den)
> +        return -1;
> +    else

{}
and it needs a <0 check

looks ok otherwise as far as i maintain the files

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100726/117d92b2/attachment.pgp>



More information about the ffmpeg-devel mailing list