Message ID | tencent_0A6E4B892638D08526C4E7C56AACD30B9C06@qq.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel] avutil/opt: handle whole range of int64_t in av_opt_get_int | expand |
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 |
On Wed, Nov 10, 2021 at 08:46:26PM +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(-) > > diff --git a/libavutil/opt.c b/libavutil/opt.c > index c7001dbcd3..b2be63828d 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 == 1.0) this can be simplified to num == den [...]
diff --git a/libavutil/opt.c b/libavutil/opt.c index c7001dbcd3..b2be63828d 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 == 1.0) + *out_val = intnum; + else + *out_val = num * intnum / den; return 0; }