summaryrefslogtreecommitdiff
path: root/libavutil/opt.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2020-04-18 21:37:45 +0200
committerMarton Balint <cus@passwd.hu>2020-05-01 17:22:58 +0200
commit6847affcb775e89d9256b33c7dc8a7502d2bb428 (patch)
treead5cfcb92c307136d92b9e2ced5e23cc60b7fea9 /libavutil/opt.c
parente7626e4e7975ff887478ecd53a39f06b3d629751 (diff)
downloadffmpeg-6847affcb775e89d9256b33c7dc8a7502d2bb428.tar.gz
avutil/opt: only skip evaluation for rational options
Fixes problems when non-rational options were set using rational expressions, causing rounding errors and the option range limits not to be enforced properly. ffmpeg -f lavfi -i "sine=r=96000/2" This caused an assertion failure with assert level 2. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r--libavutil/opt.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c
index bf2562737b..b792dec01c 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -229,13 +229,15 @@ static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **d
static int set_string_number(void *obj, void *target_obj, const AVOption *o, const char *val, void *dst)
{
int ret = 0;
- int num, den;
- char c;
- if (sscanf(val, "%d%*1[:/]%d%c", &num, &den, &c) == 2) {
- if ((ret = write_number(obj, o, dst, 1, den, num)) >= 0)
- return ret;
- ret = 0;
+ if (o->type == AV_OPT_TYPE_RATIONAL || o->type == AV_OPT_TYPE_VIDEO_RATE) {
+ int num, den;
+ char c;
+ if (sscanf(val, "%d%*1[:/]%d%c", &num, &den, &c) == 2) {
+ if ((ret = write_number(obj, o, dst, 1, den, num)) >= 0)
+ return ret;
+ ret = 0;
+ }
}
for (;;) {