Revision bc12b3b1

View differences:

libavcore/avcore.h
28 28

  
29 29
#define LIBAVCORE_VERSION_MAJOR  0
30 30
#define LIBAVCORE_VERSION_MINOR  9
31
#define LIBAVCORE_VERSION_MICRO  0
31
#define LIBAVCORE_VERSION_MICRO  1
32 32

  
33 33
#define LIBAVCORE_VERSION_INT   AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \
34 34
                                               LIBAVCORE_VERSION_MINOR, \
libavcore/parseutils.c
23 23

  
24 24
#include "parseutils.h"
25 25
#include "libavutil/avutil.h"
26
#include "libavutil/eval.h"
26 27

  
27 28
typedef struct {
28 29
    const char *abbr;
......
115 116

  
116 117
int av_parse_video_rate(AVRational *rate, const char *arg)
117 118
{
118
    int i;
119
    int i, ret;
119 120
    int n = FF_ARRAY_ELEMS(video_rate_abbrs);
120
    char *cp;
121
    double res;
121 122

  
122 123
    /* First, we check our abbreviation table */
123 124
    for (i = 0; i < n; ++i)
......
127 128
        }
128 129

  
129 130
    /* Then, we try to parse it as fraction */
130
    cp = strchr(arg, '/');
131
    if (!cp)
132
        cp = strchr(arg, ':');
133
    if (cp) {
134
        char *cpp;
135
        rate->num = strtol(arg, &cpp, 10);
136
        if (cpp != arg || cpp == cp)
137
            rate->den = strtol(cp+1, &cpp, 10);
138
        else
139
            rate->num = 0;
140
    } else {
141
        /* Finally we give up and parse it as double */
142
        *rate = av_d2q(strtod(arg, 0), 1001000);
143
    }
131
    if ((ret = av_parse_and_eval_expr(&res, arg, NULL, NULL, NULL, NULL, NULL, NULL,
132
                                      NULL, 0, NULL)) < 0)
133
        return ret;
134
    *rate = av_d2q(res, 1001000);
144 135
    if (rate->num <= 0 || rate->den <= 0)
145 136
        return AVERROR(EINVAL);
146 137
    return 0;

Also available in: Unified diff