avutil/opt: Fix max/min checking in av_opt_set() for AV_OPT_TYPE_VIDEO_RATE
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 9 Jun 2016 03:01:26 +0000 (05:01 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 9 Jun 2016 08:35:13 +0000 (10:35 +0200)
Fixes Ticket5618

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavutil/opt-test.c
libavutil/opt.c

index 1f813d6..e41782b 100644 (file)
@@ -76,7 +76,7 @@ static const AVOption test_options[]= {
     {"size",       "set size",           OFFSET(w),              AV_OPT_TYPE_IMAGE_SIZE,     { .str="200x300" },                0,         0, 1 },
     {"pix_fmt",    "set pixfmt",         OFFSET(pix_fmt),        AV_OPT_TYPE_PIXEL_FMT,      { .i64 = AV_PIX_FMT_0BGR },       -1,   INT_MAX, 1 },
     {"sample_fmt", "set samplefmt",      OFFSET(sample_fmt),     AV_OPT_TYPE_SAMPLE_FMT,     { .i64 = AV_SAMPLE_FMT_S16 },     -1,   INT_MAX, 1 },
-    {"video_rate", "set videorate",      OFFSET(video_rate),     AV_OPT_TYPE_VIDEO_RATE,     { .str = "25" },                   0,         0, 1 },
+    {"video_rate", "set videorate",      OFFSET(video_rate),     AV_OPT_TYPE_VIDEO_RATE,     { .str = "25" },                   0,         INT_MAX, 1 },
     {"duration",   "set duration",       OFFSET(duration),       AV_OPT_TYPE_DURATION,       { .i64 = 1000 },                   0, INT64_MAX, 1 },
     {"color",      "set color",          OFFSET(color),          AV_OPT_TYPE_COLOR,          { .str = "pink" },                 0,         0, 1 },
     {"cl",         "set channel layout", OFFSET(channel_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, { .i64 = AV_CH_LAYOUT_HEXAGONAL }, 0, INT64_MAX, 1 },
index 7e9ad8f..cd16bd1 100644 (file)
@@ -462,8 +462,13 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
         return set_string_number(obj, target_obj, o, val, dst);
     case AV_OPT_TYPE_IMAGE_SIZE:
         return set_string_image_size(obj, o, val, dst);
-    case AV_OPT_TYPE_VIDEO_RATE:
-        return set_string_video_rate(obj, o, val, dst);
+    case AV_OPT_TYPE_VIDEO_RATE: {
+        AVRational tmp;
+        ret = set_string_video_rate(obj, o, val, &tmp);
+        if (ret < 0)
+            return ret;
+        return write_number(obj, o, dst, 1, tmp.den, tmp.num);
+    }
     case AV_OPT_TYPE_PIXEL_FMT:
         return set_string_pixel_fmt(obj, o, val, dst);
     case AV_OPT_TYPE_SAMPLE_FMT: