Synchronise code with AAC decoder in SoC

Originally committed as revision 14695 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Robert Swain 16 years ago
parent 9cc04edff9
commit 9edae4ad81
  1. 20
      libavcodec/aac.c

@ -436,7 +436,6 @@ static int decode_band_types(AACContext * ac, enum BandType band_type[120],
/** /**
* Decode scalefactors; reference: table 4.47. * Decode scalefactors; reference: table 4.47.
* *
* @param mix_gain channel gain (Not used by AAC bitstream.)
* @param global_gain first scalefactor value as scalefactors are differentially coded * @param global_gain first scalefactor value as scalefactors are differentially coded
* @param band_type array of the used band type * @param band_type array of the used band type
* @param band_type_run_end array of the last scalefactor band of a band type run * @param band_type_run_end array of the last scalefactor band of a band type run
@ -445,7 +444,7 @@ static int decode_band_types(AACContext * ac, enum BandType band_type[120],
* @return Returns error status. 0 - OK, !0 - error * @return Returns error status. 0 - OK, !0 - error
*/ */
static int decode_scalefactors(AACContext * ac, float sf[120], GetBitContext * gb, static int decode_scalefactors(AACContext * ac, float sf[120], GetBitContext * gb,
float mix_gain, unsigned int global_gain, IndividualChannelStream * ics, unsigned int global_gain, IndividualChannelStream * ics,
enum BandType band_type[120], int band_type_run_end[120]) { enum BandType band_type[120], int band_type_run_end[120]) {
const int sf_offset = ac->sf_offset + (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE ? 12 : 0); const int sf_offset = ac->sf_offset + (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE ? 12 : 0);
int g, i, idx = 0; int g, i, idx = 0;
@ -469,7 +468,6 @@ static int decode_scalefactors(AACContext * ac, float sf[120], GetBitContext * g
return -1; return -1;
} }
sf[idx] = ff_aac_pow2sf_tab[-offset[2] + 300]; sf[idx] = ff_aac_pow2sf_tab[-offset[2] + 300];
sf[idx] *= mix_gain;
} }
}else if(band_type[idx] == NOISE_BT) { }else if(band_type[idx] == NOISE_BT) {
for(; i < run_end; i++, idx++) { for(; i < run_end; i++, idx++) {
@ -483,7 +481,6 @@ static int decode_scalefactors(AACContext * ac, float sf[120], GetBitContext * g
return -1; return -1;
} }
sf[idx] = -ff_aac_pow2sf_tab[ offset[1] + sf_offset]; sf[idx] = -ff_aac_pow2sf_tab[ offset[1] + sf_offset];
sf[idx] *= mix_gain;
} }
}else { }else {
for(; i < run_end; i++, idx++) { for(; i < run_end; i++, idx++) {
@ -494,7 +491,6 @@ static int decode_scalefactors(AACContext * ac, float sf[120], GetBitContext * g
return -1; return -1;
} }
sf[idx] = -ff_aac_pow2sf_tab[ offset[0] + sf_offset]; sf[idx] = -ff_aac_pow2sf_tab[ offset[0] + sf_offset];
sf[idx] *= mix_gain;
} }
} }
} }
@ -649,7 +645,7 @@ static int decode_cpe(AACContext * ac, GetBitContext * gb, int elem_id) {
*/ */
static int decode_sbr_extension(AACContext * ac, GetBitContext * gb, int crc, int cnt) { static int decode_sbr_extension(AACContext * ac, GetBitContext * gb, int crc, int cnt) {
// TODO : sbr_extension implementation // TODO : sbr_extension implementation
av_log(ac->avccontext, AV_LOG_DEBUG, "aac: SBR not yet supported.\n"); av_log_missing_feature(ac->avccontext, "SBR", 0);
skip_bits_long(gb, 8*cnt - 4); // -4 due to reading extension type skip_bits_long(gb, 8*cnt - 4); // -4 due to reading extension type
return cnt; return cnt;
} }
@ -769,11 +765,10 @@ static void apply_dependent_coupling(AACContext * ac, SingleChannelElement * sce
for (g = 0; g < ics->num_window_groups; g++) { for (g = 0; g < ics->num_window_groups; g++) {
for (i = 0; i < ics->max_sfb; i++, idx++) { for (i = 0; i < ics->max_sfb; i++, idx++) {
if (cc->ch[0].band_type[idx] != ZERO_BT) { if (cc->ch[0].band_type[idx] != ZERO_BT) {
float gain = cc->coup.gain[index][idx] * sce->mixing_gain;
for (group = 0; group < ics->group_len[g]; group++) { for (group = 0; group < ics->group_len[g]; group++) {
for (k = offsets[i]; k < offsets[i+1]; k++) { for (k = offsets[i]; k < offsets[i+1]; k++) {
// XXX dsputil-ize // XXX dsputil-ize
dest[group*128+k] += gain * src[group*128+k]; dest[group*128+k] += cc->coup.gain[index][idx] * src[group*128+k];
} }
} }
} }
@ -790,9 +785,8 @@ static void apply_dependent_coupling(AACContext * ac, SingleChannelElement * sce
*/ */
static void apply_independent_coupling(AACContext * ac, SingleChannelElement * sce, ChannelElement * cc, int index) { static void apply_independent_coupling(AACContext * ac, SingleChannelElement * sce, ChannelElement * cc, int index) {
int i; int i;
float gain = cc->coup.gain[index][0] * sce->mixing_gain;
for (i = 0; i < 1024; i++) for (i = 0; i < 1024; i++)
sce->ret[i] += gain * (cc->ch[0].ret[i] - ac->add_bias); sce->ret[i] += cc->coup.gain[index][0] * (cc->ch[0].ret[i] - ac->add_bias);
} }
if (!ac->is_saved) { if (!ac->is_saved) {
@ -817,11 +811,11 @@ static void apply_independent_coupling(AACContext * ac, SingleChannelElement * s
static av_cold int aac_decode_close(AVCodecContext * avccontext) { static av_cold int aac_decode_close(AVCodecContext * avccontext) {
AACContext * ac = avccontext->priv_data; AACContext * ac = avccontext->priv_data;
int i, j; int i, type;
for (i = 0; i < MAX_ELEM_ID; i++) { for (i = 0; i < MAX_ELEM_ID; i++) {
for(j = 0; j < 4; j++) for(type = 0; type < 4; type++)
av_freep(&ac->che[j][i]); av_freep(&ac->che[type][i]);
} }
ff_mdct_end(&ac->mdct); ff_mdct_end(&ac->mdct);

Loading…
Cancel
Save