summaryrefslogtreecommitdiff
path: root/libavutil/opt.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-11-20 12:57:42 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-11-20 22:39:52 +0100
commit748ce9d702860708746993c1fecbbfa7cb533db8 (patch)
tree7a0e0c0ad2a681552f24569abf08658432c16066 /libavutil/opt.c
parent322568c079d6253e46e6730244162fd6aad455c6 (diff)
avutil/opt: Fix setting int64 to its maximum
Found-by: Andreas Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r--libavutil/opt.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c
index cd16bd1d3f..cd46a56dc4 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -126,9 +126,13 @@ static int write_number(void *obj, const AVOption *o, void *dst, double num, int
break;
case AV_OPT_TYPE_DURATION:
case AV_OPT_TYPE_CHANNEL_LAYOUT:
- case AV_OPT_TYPE_INT64:
- *(int64_t *)dst = llrint(num / den) * intnum;
- break;
+ case AV_OPT_TYPE_INT64:{
+ double d = num / den;
+ if (intnum == 1 && d == (double)INT64_MAX) {
+ *(int64_t *)dst = INT64_MAX;
+ } else
+ *(int64_t *)dst = llrint(d) * intnum;
+ break;}
case AV_OPT_TYPE_FLOAT:
*(float *)dst = num * intnum / den;
break;