mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Use lookup table to avoid division in mp2 decoder
Originally committed as revision 23840 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
a64fadf62b
commit
186d02150e
@ -97,6 +97,14 @@ static int32_t csa_table[8][4];
|
|||||||
static float csa_table_float[8][4];
|
static float csa_table_float[8][4];
|
||||||
static INTFLOAT mdct_win[8][36];
|
static INTFLOAT mdct_win[8][36];
|
||||||
|
|
||||||
|
static int16_t division_tab3[1<<6 ];
|
||||||
|
static int16_t division_tab5[1<<8 ];
|
||||||
|
static int16_t division_tab9[1<<11];
|
||||||
|
|
||||||
|
static int16_t * const division_tabs[4] = {
|
||||||
|
division_tab3, division_tab5, NULL, division_tab9
|
||||||
|
};
|
||||||
|
|
||||||
/* lower 2 bits: modulo 3, higher bits: shift */
|
/* lower 2 bits: modulo 3, higher bits: shift */
|
||||||
static uint16_t scale_factor_modshift[64];
|
static uint16_t scale_factor_modshift[64];
|
||||||
/* [i][j]: 2^(-j/3) * FRAC_ONE * 2^(i+2) / (2^(i+2) - 1) */
|
/* [i][j]: 2^(-j/3) * FRAC_ONE * 2^(i+2) / (2^(i+2) - 1) */
|
||||||
@ -399,6 +407,20 @@ static av_cold int decode_init(AVCodecContext * avctx)
|
|||||||
int_pow_init();
|
int_pow_init();
|
||||||
mpegaudio_tableinit();
|
mpegaudio_tableinit();
|
||||||
|
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
if (ff_mpa_quant_bits[i] < 0)
|
||||||
|
for (j = 0; j < (1<<(-ff_mpa_quant_bits[i]+1)); j++) {
|
||||||
|
int val1, val2, val3, steps;
|
||||||
|
int val = j;
|
||||||
|
steps = ff_mpa_quant_steps[i];
|
||||||
|
val1 = val % steps;
|
||||||
|
val /= steps;
|
||||||
|
val2 = val % steps;
|
||||||
|
val3 = val / steps;
|
||||||
|
division_tabs[i][j] = val1 + (val2 << 4) + (val3 << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for(i=0;i<7;i++) {
|
for(i=0;i<7;i++) {
|
||||||
float f;
|
float f;
|
||||||
INTFLOAT v;
|
INTFLOAT v;
|
||||||
@ -1268,17 +1290,18 @@ static int mp_decode_layer2(MPADecodeContext *s)
|
|||||||
qindex = alloc_table[j+b];
|
qindex = alloc_table[j+b];
|
||||||
bits = ff_mpa_quant_bits[qindex];
|
bits = ff_mpa_quant_bits[qindex];
|
||||||
if (bits < 0) {
|
if (bits < 0) {
|
||||||
|
int v2;
|
||||||
/* 3 values at the same time */
|
/* 3 values at the same time */
|
||||||
v = get_bits(&s->gb, -bits);
|
v = get_bits(&s->gb, -bits);
|
||||||
steps = ff_mpa_quant_steps[qindex];
|
v2 = division_tabs[qindex][v];
|
||||||
|
steps = ff_mpa_quant_steps[qindex];
|
||||||
|
|
||||||
s->sb_samples[ch][k * 12 + l + 0][i] =
|
s->sb_samples[ch][k * 12 + l + 0][i] =
|
||||||
l2_unscale_group(steps, v % steps, scale);
|
l2_unscale_group(steps, v2 & 15, scale);
|
||||||
v = v / steps;
|
|
||||||
s->sb_samples[ch][k * 12 + l + 1][i] =
|
s->sb_samples[ch][k * 12 + l + 1][i] =
|
||||||
l2_unscale_group(steps, v % steps, scale);
|
l2_unscale_group(steps, (v2 >> 4) & 15, scale);
|
||||||
v = v / steps;
|
|
||||||
s->sb_samples[ch][k * 12 + l + 2][i] =
|
s->sb_samples[ch][k * 12 + l + 2][i] =
|
||||||
l2_unscale_group(steps, v, scale);
|
l2_unscale_group(steps, v2 >> 8 , scale);
|
||||||
} else {
|
} else {
|
||||||
for(m=0;m<3;m++) {
|
for(m=0;m<3;m++) {
|
||||||
v = get_bits(&s->gb, bits);
|
v = get_bits(&s->gb, bits);
|
||||||
|
Loading…
Reference in New Issue
Block a user