On Tue, Feb 18, 2014 at 02:14:17PM -0500, Mashiat Sarker Shakkhar wrote:
> It is not clear why this has to be `1 << 24` and can't be INT_MAX.

It might be because of float type precision but you're absolutely right, it's
not clear at all.

> ---
>  libavutil/opt.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavutil/opt.c b/libavutil/opt.c
> index ede4a49..d50e631 100644
> --- a/libavutil/opt.c
> +++ b/libavutil/opt.c
> @@ -76,7 +76,7 @@ static int write_number(void *obj, const AVOption *o, void 
> *dst, double num, int
>      case AV_OPT_TYPE_DOUBLE:*(double    *)dst= num*intnum/den;         break;
>      case AV_OPT_TYPE_RATIONAL:
>          if ((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, 
> den};
> -        else                 *(AVRational*)dst= av_d2q(num*intnum/den, 
> 1<<24);
> +        else                 *(AVRational*)dst= av_d2q(num*intnum/den, 
> INT_MAX);
>          break;
>      default:
>          return AVERROR(EINVAL);
> -- 

Probably it's better to use power of two here for precision sake, not 2^N - 1.
INT_MAX - (INT_MAX >> 1) might do the trick ;)
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to