mirror of https://git.ffmpeg.org/ffmpeg.git
LGPL version of ac3_decode_transform_coeffs_ch, ~12.4% faster.
Originally committed as revision 18875 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
bae3abb02c
commit
d869a460db
|
@ -439,12 +439,12 @@ static void calc_transform_coeffs_cpl(AC3DecodeContext *s)
|
||||||
* Grouped mantissas for 3-level 5-level and 11-level quantization
|
* Grouped mantissas for 3-level 5-level and 11-level quantization
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int b1_mant[3];
|
int b1_mant[2];
|
||||||
int b2_mant[3];
|
int b2_mant[2];
|
||||||
int b4_mant[2];
|
int b4_mant;
|
||||||
int b1ptr;
|
int b1;
|
||||||
int b2ptr;
|
int b2;
|
||||||
int b4ptr;
|
int b4;
|
||||||
} mant_groups;
|
} mant_groups;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -453,73 +453,72 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, mant_groups *m)
|
static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, mant_groups *m)
|
||||||
{
|
{
|
||||||
|
int start_freq = s->start_freq[ch_index];
|
||||||
|
int end_freq = s->end_freq[ch_index];
|
||||||
|
uint8_t *baps = s->bap[ch_index];
|
||||||
|
int8_t *exps = s->dexps[ch_index];
|
||||||
|
int *coeffs = s->fixed_coeffs[ch_index];
|
||||||
GetBitContext *gbc = &s->gbc;
|
GetBitContext *gbc = &s->gbc;
|
||||||
int i, gcode, tbap, start, end;
|
int freq;
|
||||||
uint8_t *exps;
|
|
||||||
uint8_t *bap;
|
|
||||||
int *coeffs;
|
|
||||||
|
|
||||||
exps = s->dexps[ch_index];
|
for(freq = start_freq; freq < end_freq; freq++){
|
||||||
bap = s->bap[ch_index];
|
int bap = baps[freq];
|
||||||
coeffs = s->fixed_coeffs[ch_index];
|
int mantissa;
|
||||||
start = s->start_freq[ch_index];
|
switch(bap){
|
||||||
end = s->end_freq[ch_index];
|
|
||||||
|
|
||||||
for (i = start; i < end; i++) {
|
|
||||||
tbap = bap[i];
|
|
||||||
switch (tbap) {
|
|
||||||
case 0:
|
case 0:
|
||||||
coeffs[i] = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000;
|
mantissa = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if(m->b1ptr > 2) {
|
if(m->b1){
|
||||||
gcode = get_bits(gbc, 5);
|
m->b1--;
|
||||||
m->b1_mant[0] = b1_mantissas[gcode][0];
|
mantissa = m->b1_mant[m->b1];
|
||||||
m->b1_mant[1] = b1_mantissas[gcode][1];
|
}
|
||||||
m->b1_mant[2] = b1_mantissas[gcode][2];
|
else{
|
||||||
m->b1ptr = 0;
|
int bits = get_bits(gbc, 5);
|
||||||
|
mantissa = b1_mantissas[bits][0];
|
||||||
|
m->b1_mant[1] = b1_mantissas[bits][1];
|
||||||
|
m->b1_mant[0] = b1_mantissas[bits][2];
|
||||||
|
m->b1 = 2;
|
||||||
}
|
}
|
||||||
coeffs[i] = m->b1_mant[m->b1ptr++];
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if(m->b2ptr > 2) {
|
if(m->b2){
|
||||||
gcode = get_bits(gbc, 7);
|
m->b2--;
|
||||||
m->b2_mant[0] = b2_mantissas[gcode][0];
|
mantissa = m->b2_mant[m->b2];
|
||||||
m->b2_mant[1] = b2_mantissas[gcode][1];
|
}
|
||||||
m->b2_mant[2] = b2_mantissas[gcode][2];
|
else{
|
||||||
m->b2ptr = 0;
|
int bits = get_bits(gbc, 7);
|
||||||
|
mantissa = b2_mantissas[bits][0];
|
||||||
|
m->b2_mant[1] = b2_mantissas[bits][1];
|
||||||
|
m->b2_mant[0] = b2_mantissas[bits][2];
|
||||||
|
m->b2 = 2;
|
||||||
}
|
}
|
||||||
coeffs[i] = m->b2_mant[m->b2ptr++];
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
coeffs[i] = b3_mantissas[get_bits(gbc, 3)];
|
mantissa = b3_mantissas[get_bits(gbc, 3)];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
if(m->b4ptr > 1) {
|
if(m->b4){
|
||||||
gcode = get_bits(gbc, 7);
|
m->b4 = 0;
|
||||||
m->b4_mant[0] = b4_mantissas[gcode][0];
|
mantissa = m->b4_mant;
|
||||||
m->b4_mant[1] = b4_mantissas[gcode][1];
|
}
|
||||||
m->b4ptr = 0;
|
else{
|
||||||
|
int bits = get_bits(gbc, 7);
|
||||||
|
mantissa = b4_mantissas[bits][0];
|
||||||
|
m->b4_mant = b4_mantissas[bits][1];
|
||||||
|
m->b4 = 1;
|
||||||
}
|
}
|
||||||
coeffs[i] = m->b4_mant[m->b4ptr++];
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
coeffs[i] = b5_mantissas[get_bits(gbc, 4)];
|
mantissa = b5_mantissas[get_bits(gbc, 4)];
|
||||||
break;
|
break;
|
||||||
|
default: /* 6 to 15 */
|
||||||
default: {
|
mantissa = get_bits(gbc, quantization_tab[bap]);
|
||||||
/* asymmetric dequantization */
|
/* Shift mantissa and sign-extend it. */
|
||||||
int qlevel = quantization_tab[tbap];
|
mantissa = (mantissa << (32-quantization_tab[bap]))>>8;
|
||||||
coeffs[i] = get_sbits(gbc, qlevel) << (24 - qlevel);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
coeffs[i] >>= exps[i];
|
coeffs[freq] = mantissa >> exps[freq];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,7 +581,7 @@ static void decode_transform_coeffs(AC3DecodeContext *s, int blk)
|
||||||
int got_cplchan = 0;
|
int got_cplchan = 0;
|
||||||
mant_groups m;
|
mant_groups m;
|
||||||
|
|
||||||
m.b1ptr = m.b2ptr = m.b4ptr = 3;
|
m.b1 = m.b2 = m.b4 = 0;
|
||||||
|
|
||||||
for (ch = 1; ch <= s->channels; ch++) {
|
for (ch = 1; ch <= s->channels; ch++) {
|
||||||
/* transform coefficients for full-bandwidth channel */
|
/* transform coefficients for full-bandwidth channel */
|
||||||
|
|
Loading…
Reference in New Issue