Commit b01f3dda authored by Claudio Freire's avatar Claudio Freire

AAC encoder: simplify and speed up find_min_book

Trivial change to simplify the small but hot
find_min_book function. The new form is easier to
understand and faster.
parent 91b668ac
......@@ -89,13 +89,10 @@ static inline int find_min_book(float maxval, int sf)
float Q34 = sqrtf(Q * sqrtf(Q));
int qmaxval, cb;
qmaxval = maxval * Q34 + C_QUANT;
if (qmaxval == 0) cb = 0;
else if (qmaxval == 1) cb = 1;
else if (qmaxval == 2) cb = 3;
else if (qmaxval <= 4) cb = 5;
else if (qmaxval <= 7) cb = 7;
else if (qmaxval <= 12) cb = 9;
else cb = 11;
if (qmaxval >= (FF_ARRAY_ELEMS(aac_maxval_cb)))
cb = 11;
else
cb = aac_maxval_cb[qmaxval];
return cb;
}
......
......@@ -110,4 +110,8 @@ static const uint8_t aac_cb_in_map[CB_TOT_ALL+1] = {0,1,2,3,4,5,6,7,8,9,10,11,0,
static const uint8_t aac_cb_range [12] = {0, 3, 3, 3, 3, 9, 9, 8, 8, 13, 13, 17};
static const uint8_t aac_cb_maxval[12] = {0, 1, 1, 2, 2, 4, 4, 7, 7, 12, 12, 16};
static unsigned char aac_maxval_cb[] = {
0, 1, 3, 5, 5, 7, 7, 7, 9, 9, 9, 9, 9, 11
};
#endif /* AVCODEC_AACENCTAB_H */
......@@ -178,14 +178,10 @@ static 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));
int qmaxval, cb;
qmaxval = maxval * Q34 + 0.4054f;
if (qmaxval == 0) cb = 0;
else if (qmaxval == 1) cb = 1;
else if (qmaxval == 2) cb = 3;
else if (qmaxval <= 4) cb = 5;
else if (qmaxval <= 7) cb = 7;
else if (qmaxval <= 12) cb = 9;
else cb = 11;
if (qmaxval >= (FF_ARRAY_ELEMS(aac_maxval_cb)))
cb = 11;
else
cb = aac_maxval_cb[qmaxval];
return cb;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment