[FFmpeg-devel] [PATCH] aacenc: avoid double in quantize_bands.

Rostislav Pehlivanov atomnuker at gmail.com
Wed Mar 2 20:33:31 CET 2016


On 1 March 2016 at 21:55, Reimar Döffinger <Reimar.Doeffinger at gmx.de> wrote:

> I cannot see any point whatsoever to use
> double here instead of float.
> Using float allows for use of SIMD.
> ---
>  libavcodec/aacenc_utils.h | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/aacenc_utils.h b/libavcodec/aacenc_utils.h
> index cb5bc8d..571b1e6 100644
> --- a/libavcodec/aacenc_utils.h
> +++ b/libavcodec/aacenc_utils.h
> @@ -66,10 +66,9 @@ static inline void quantize_bands(int *out, const float
> *in, const float *scaled
>                                    const float rounding)
>  {
>      int i;
> -    double qc;
>      for (i = 0; i < size; i++) {
> -        qc = scaled[i] * Q34;
> -        out[i] = (int)FFMIN(qc + rounding, (double)maxval);
> +        float qc = scaled[i] * Q34;
> +        out[i] = (int)FFMIN(qc + rounding, (float)maxval);
>          if (is_signed && in[i] < 0.0f) {
>              out[i] = -out[i];
>          }
> --
>

You could just avoid the whole need for qc and just do "FFMIN((scaled[i] *
Q34) + rounding, (float)maxval));". We have plenty of space and I think it
would look neater.
But up to you to decide, either way it looks good to me, doesn't change
anything. Feel free to push if you can.

Thanks


More information about the ffmpeg-devel mailing list