mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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.
This commit is contained in:
parent
91b668acd6
commit
b01f3ddad3
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user