[FFmpeg-cvslog] avutil/opt: Fix max/min checking in av_opt_set() for AV_OPT_TYPE_VIDEO_RATE

Michael Niedermayer git at videolan.org
Thu Jun 9 10:40:11 CEST 2016


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Thu Jun  9 05:01:26 2016 +0200| [37bb6004059c15f6a17f38b4ab5c5f5d2f61c087] | committer: Michael Niedermayer

avutil/opt: Fix max/min checking in av_opt_set() for AV_OPT_TYPE_VIDEO_RATE

Fixes Ticket5618

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=37bb6004059c15f6a17f38b4ab5c5f5d2f61c087
---

 libavutil/opt-test.c |    2 +-
 libavutil/opt.c      |    9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavutil/opt-test.c b/libavutil/opt-test.c
index 1f813d6..e41782b 100644
--- a/libavutil/opt-test.c
+++ b/libavutil/opt-test.c
@@ -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 },
diff --git a/libavutil/opt.c b/libavutil/opt.c
index 7e9ad8f..cd16bd1 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -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:



More information about the ffmpeg-cvslog mailing list