diff mbox series

[FFmpeg-devel,v2] avutil/opt: handle whole range of int64_t in av_opt_get_int

Message ID tencent_A5AAB0533ADC438BBEE6095096E6DF67F106@qq.com
State Accepted
Commit 9fd2b39428165c2319106e82a3c1ca1bba11aa54
Headers show
Series [FFmpeg-devel,v2] avutil/opt: handle whole range of int64_t in av_opt_get_int | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Zhao Zhili Nov. 10, 2021, 3:36 p.m. UTC
Make get_int/set_int symetric. The int64_t to double to int64_t
conversion is unprecise for large value.
---
 libavutil/opt.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Nov. 11, 2021, 12:13 p.m. UTC | #1
On Wed, Nov 10, 2021 at 11:36:15PM +0800, Zhao Zhili wrote:
> Make get_int/set_int symetric. The int64_t to double to int64_t
> conversion is unprecise for large value.
> ---
>  libavutil/opt.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavutil/opt.c b/libavutil/opt.c
index c7001dbcd3..cfda31ea2f 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -920,7 +920,10 @@  int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_v
 
     if ((ret = get_number(obj, name, NULL, &num, &den, &intnum, search_flags)) < 0)
         return ret;
-    *out_val = num * intnum / den;
+    if (num == den)
+        *out_val = intnum;
+    else
+        *out_val = num * intnum / den;
     return 0;
 }