[FFmpeg-soc] [soc]: r2589 - in aac: aac.c aactab.h
superdump
subversion at mplayerhq.hu
Sun Jun 29 17:21:29 CEST 2008
Author: superdump
Date: Sun Jun 29 17:21:29 2008
New Revision: 2589
Log:
Use overall mean noise energy rather than calculate the noise per band.
Note: This differs from the 3GPP reference implementation which calculates
the energy per band and scales using that energy.
Modified:
aac/aac.c
aac/aactab.h
Modified: aac/aac.c
==============================================================================
--- aac/aac.c (original)
+++ aac/aac.c Sun Jun 29 17:21:29 2008
@@ -1188,12 +1188,7 @@ static int decode_spectral_data(AACConte
const int cur_cb = cb[g][i];
const int dim = cur_cb >= FIRST_PAIR_HCB ? 2 : 4;
int group;
- if (cur_cb == NOISE_HCB) {
- for (group = 0; group < ics->group_len[g]; group++) {
- for (k = offsets[i]; k < offsets[i+1]; k++)
- icoef[group*128+k] = av_random(&ac->random_state) & 0x0000FFFF;
- }
- }else if (cur_cb == ZERO_HCB) {
+ if (cur_cb == ZERO_HCB) {
for (group = 0; group < ics->group_len[g]; group++) {
memset(icoef + group * 128 + offsets[i], 0, (offsets[i+1] - offsets[i])*sizeof(int));
}
@@ -1261,13 +1256,9 @@ static void quant_to_spec_tool(AACContex
for (i = 0; i < ics->max_sfb; i++) {
if (cb[g][i] == NOISE_HCB) {
for (group = 0; group < ics->group_len[g]; group++) {
- float energy = 0;
- float scale = 1.;// / (float)(offsets[i+1] - offsets[i]);
- for (k = offsets[i]; k < offsets[i+1]; k++)
- energy += (float)icoef[group*128+k] * icoef[group*128+k];
- scale *= sf[g][i] / sqrt(energy);
+ float scale = sf[g][i] / ((offsets[i+1] - offsets[i]) * PNS_MEAN_ENERGY);
for (k = offsets[i]; k < offsets[i+1]; k++)
- coef[group*128+k] = icoef[group*128+k] * scale;
+ coef[group*128+k] = (int32_t)av_random(&ac->random_state) * scale;
}
} else if (cb[g][i] != INTENSITY_HCB && cb[g][i] != INTENSITY_HCB2) {
for (group = 0; group < ics->group_len[g]; group++) {
Modified: aac/aactab.h
==============================================================================
--- aac/aactab.h (original)
+++ aac/aactab.h Sun Jun 29 17:21:29 2008
@@ -31,6 +31,7 @@
#define FFMPEG_AACTAB_H
#define TNS_MAX_ORDER 20
+#define PNS_MEAN_ENERGY 3719550720.0f // sqrt(3.0) * 1<<31
static const uint16_t swb_offset_1024_96[] = {
0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56,
More information about the FFmpeg-soc
mailing list