[FFmpeg-devel] [PATCH] avformat/aiffdec: avoid double and ldexp()

Mark Harris mark.hsj at gmail.com
Mon Jun 8 06:29:20 CEST 2015


> -    sample_rate = ldexp(val, exp - 16383 - 63);
> +    if (exp >= 0)
> +        sample_rate = val << exp;
> +    else
> +        sample_rate = (val + (1<<(-exp/2))) >> -exp;

To round the value it should probably be something like:
    sample_rate = (val + ((uint64_t)1<<(-exp-1))) >> -exp;

To avoid possible undefined behavior it would also need to check that
exp is within range.


More information about the ffmpeg-devel mailing list