aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/aacenc_tns.c
diff options
context:
space:
mode:
authorClaudio Freire <klaussfreire@gmail.com>2016-01-16 23:02:41 -0300
committerClaudio Freire <klaussfreire@gmail.com>2016-01-17 12:52:54 -0300
commit3d0849cc90a7098e9992317248a53ef5f29ceffc (patch)
tree3a35cdfc75c0ae8c3880c2c8423e7819bdd73041 /libavcodec/aacenc_tns.c
parentdf3fa48288d6e79ac4a193406d514c1dace22397 (diff)
downloadffmpeg-3d0849cc90a7098e9992317248a53ef5f29ceffc.tar.gz
AAC encoder: TNS fixes on short windows
TNS was computing filter coefficients incorrectly for short windows due to a few coefficient addressing bugs. Fixing them fixes lots of instability with transients (short windows).
Diffstat (limited to 'libavcodec/aacenc_tns.c')
-rw-r--r--libavcodec/aacenc_tns.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/libavcodec/aacenc_tns.c b/libavcodec/aacenc_tns.c
index 9ac9ed912e..414a5e91dd 100644
--- a/libavcodec/aacenc_tns.c
+++ b/libavcodec/aacenc_tns.c
@@ -178,23 +178,19 @@ void ff_aac_search_for_tns(AACEncContext *s, SingleChannelElement *sce)
int coef_len = sce->ics.swb_offset[sfb_end] - sce->ics.swb_offset[sfb_start];
const int sfb_len = sfb_end - sfb_start;
- for (g = 0; g < sce->ics.num_swb; g++) {
- if (w*16+g < sfb_start || w*16+g > sfb_end)
- continue;
- for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
- FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
- if ((w+w2)*16+g > sfb_start + (sfb_len/2))
- en[1] += band->energy;
- else
- en[0] += band->energy;
- }
+ for (g = sfb_start; g < sce->ics.num_swb && g <= sfb_end; g++) {
+ FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[w*16+g];
+ if (g > sfb_start + (sfb_len/2))
+ en[1] += band->energy;
+ else
+ en[0] += band->energy;
}
if (coef_len <= 0 || sfb_len <= 0)
continue;
/* LPC */
- gain = ff_lpc_calc_ref_coefs_f(&s->lpc, &sce->coeffs[coef_start],
+ gain = ff_lpc_calc_ref_coefs_f(&s->lpc, &sce->coeffs[w*128 + coef_start],
coef_len, order, coefs);
if (!order || gain < TNS_GAIN_THRESHOLD_LOW || gain > TNS_GAIN_THRESHOLD_HIGH)