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

Michael Niedermayer michael at niedermayer.cc
Wed Nov 10 16:39:30 EET 2021


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


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Old school: Use the lowest level language in which you can solve the problem
            conveniently.
New school: Use the highest level language in which the latest supercomputer
            can solve the problem without the user falling asleep waiting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20211110/18582ee8/attachment.sig>


More information about the ffmpeg-devel mailing list