Mercurial > libavcodec.hg
diff aac.c @ 8109:7baa25290231 libavcodec
Fix perceptual noise shaping scaling including an oversight of the offset for
the EIGHT_SHORT window type. Fixes issue 664.
Patch by Alex Converse (alex converse gmail com)
author | superdump |
---|---|
date | Wed, 05 Nov 2008 13:59:42 +0000 |
parents | e70975d5ff80 |
children | 8a8d40fe77d9 |
line wrap: on
line diff
--- a/aac.c Wed Nov 05 13:32:06 2008 +0000 +++ b/aac.c Wed Nov 05 13:59:42 2008 +0000 @@ -399,7 +399,7 @@ } #ifndef CONFIG_HARDCODED_TABLES - for (i = 0; i < 316; i++) + for (i = 0; i < 428; i++) ff_aac_pow2sf_tab[i] = pow(2, (i - 200)/4.); #endif /* CONFIG_HARDCODED_TABLES */ @@ -573,7 +573,7 @@ "%s (%d) out of range.\n", sf_str[1], offset[1]); return -1; } - sf[idx] = -ff_aac_pow2sf_tab[ offset[1] + sf_offset]; + sf[idx] = -ff_aac_pow2sf_tab[ offset[1] + sf_offset + 100]; } }else { for(; i < run_end; i++, idx++) { @@ -704,11 +704,17 @@ memset(coef + group * 128 + offsets[i], 0, (offsets[i+1] - offsets[i])*sizeof(float)); } }else if (cur_band_type == NOISE_BT) { - const float scale = sf[idx] / ((offsets[i+1] - offsets[i]) * PNS_MEAN_ENERGY); for (group = 0; group < ics->group_len[g]; group++) { + float scale; + float band_energy = 0; for (k = offsets[i]; k < offsets[i+1]; k++) { ac->random_state = lcg_random(ac->random_state); - coef[group*128+k] = ac->random_state * scale; + coef[group*128+k] = ac->random_state; + band_energy += coef[group*128+k]*coef[group*128+k]; + } + scale = sf[idx] / sqrtf(band_energy); + for (k = offsets[i]; k < offsets[i+1]; k++) { + coef[group*128+k] *= scale; } } }else if (cur_band_type != INTENSITY_BT2 && cur_band_type != INTENSITY_BT) {