X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Faacenc_utils.h;h=bb1dcb4361626a2090dcc1f03e984fbfaa5abb51;hb=b098e1a4697573d5c501aceb863d89ebf1fcd5fd;hp=cb5bc8da12962cbd9206a2fac389a5ede81ab728;hpb=4401f07f4daac9167dfffc9080c3a978dd36534b;p=ffmpeg diff --git a/libavcodec/aacenc_utils.h b/libavcodec/aacenc_utils.h index cb5bc8da129..bb1dcb43616 100644 --- a/libavcodec/aacenc_utils.h +++ b/libavcodec/aacenc_utils.h @@ -28,6 +28,7 @@ #ifndef AVCODEC_AACENC_UTILS_H #define AVCODEC_AACENC_UTILS_H +#include "libavutil/ffmath.h" #include "aac.h" #include "aacenctab.h" #include "aactab.h" @@ -66,13 +67,13 @@ 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; + int tmp = (int)FFMIN(qc + rounding, (float)maxval); if (is_signed && in[i] < 0.0f) { - out[i] = -out[i]; + tmp = -tmp; } + out[i] = tmp; } } @@ -90,8 +91,7 @@ static inline float find_max_val(int group_len, int swb_size, const float *scale static inline int find_min_book(float maxval, int sf) { - float Q = ff_aac_pow2sf_tab[POW_SF2_ZERO - sf + SCALE_ONE_POS - SCALE_DIV_512]; - float Q34 = sqrtf(Q * sqrtf(Q)); + float Q34 = ff_aac_pow34sf_tab[POW_SF2_ZERO - sf + SCALE_ONE_POS - SCALE_DIV_512]; int qmaxval, cb; qmaxval = maxval * Q34 + C_QUANT; if (qmaxval >= (FF_ARRAY_ELEMS(aac_maxval_cb))) @@ -123,7 +123,10 @@ static inline float find_form_factor(int group_len, int swb_size, float thresh, if (s >= ethresh) { nzl += 1.0f; } else { - nzl += powf(s / ethresh, nzslope); + if (nzslope == 2.f) + nzl += (s / ethresh) * (s / ethresh); + else + nzl += ff_fast_powf(s / ethresh, nzslope); } } if (e2 > thresh) {