Browse code

lavfi/cellauto: make use of AV_OPT_TYPE_VIDEO_RATE

Signed-off-by: Paul B Mahol <onemda@gmail.com>

Paul B Mahol authored on 2013/03/26 21:19:16
Showing 1 changed files
... ...
@@ -47,8 +47,7 @@ typedef struct {
47 47
     int buf_prev_row_idx, buf_row_idx;
48 48
     uint8_t rule;
49 49
     uint64_t pts;
50
-    AVRational time_base;
51
-    char *rate;                 ///< video frame rate
50
+    AVRational frame_rate;
52 51
     double   random_fill_ratio;
53 52
     uint32_t random_seed;
54 53
     int stitch, scroll, start_full;
... ...
@@ -65,8 +64,8 @@ static const AVOption cellauto_options[] = {
65 65
     { "f",        "read initial pattern from file", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
66 66
     { "pattern",  "set initial pattern", OFFSET(pattern), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
67 67
     { "p",        "set initial pattern", OFFSET(pattern), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
68
-    { "rate",     "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, FLAGS },
69
-    { "r",        "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, FLAGS },
68
+    { "rate",     "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
69
+    { "r",        "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
70 70
     { "size",     "set video size", OFFSET(w),    AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, FLAGS },
71 71
     { "s",        "set video size", OFFSET(w),    AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, FLAGS },
72 72
     { "rule",     "set rule",       OFFSET(rule), AV_OPT_TYPE_INT,    {.i64 = 110},  0, 255, FLAGS },
... ...
@@ -163,7 +162,6 @@ static int init_pattern_from_file(AVFilterContext *ctx)
163 163
 static int init(AVFilterContext *ctx, const char *args)
164 164
 {
165 165
     CellAutoContext *cellauto = ctx->priv;
166
-    AVRational frame_rate;
167 166
     int ret;
168 167
 
169 168
     cellauto->class = &cellauto_class;
... ...
@@ -172,17 +170,9 @@ static int init(AVFilterContext *ctx, const char *args)
172 172
     if ((ret = av_set_options_string(cellauto, args, "=", ":")) < 0)
173 173
         return ret;
174 174
 
175
-    if ((ret = av_parse_video_rate(&frame_rate, cellauto->rate)) < 0) {
176
-        av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: %s\n", cellauto->rate);
177
-        return AVERROR(EINVAL);
178
-    }
179
-
180 175
     if (!cellauto->w && !cellauto->filename && !cellauto->pattern)
181 176
         av_opt_set(cellauto, "size", "320x518", 0);
182 177
 
183
-    cellauto->time_base.num = frame_rate.den;
184
-    cellauto->time_base.den = frame_rate.num;
185
-
186 178
     if (cellauto->filename && cellauto->pattern) {
187 179
         av_log(ctx, AV_LOG_ERROR, "Only one of the filename or pattern options can be used\n");
188 180
         return AVERROR(EINVAL);
... ...
@@ -215,7 +205,7 @@ static int init(AVFilterContext *ctx, const char *args)
215 215
 
216 216
     av_log(ctx, AV_LOG_VERBOSE,
217 217
            "s:%dx%d r:%d/%d rule:%d stitch:%d scroll:%d full:%d seed:%u\n",
218
-           cellauto->w, cellauto->h, frame_rate.num, frame_rate.den,
218
+           cellauto->w, cellauto->h, cellauto->frame_rate.num, cellauto->frame_rate.den,
219 219
            cellauto->rule, cellauto->stitch, cellauto->scroll, cellauto->start_full,
220 220
            cellauto->random_seed);
221 221
     return 0;
... ...
@@ -236,7 +226,7 @@ static int config_props(AVFilterLink *outlink)
236 236
 
237 237
     outlink->w = cellauto->w;
238 238
     outlink->h = cellauto->h;
239
-    outlink->time_base = cellauto->time_base;
239
+    outlink->time_base = av_inv_q(cellauto->frame_rate);
240 240
 
241 241
     return 0;
242 242
 }