mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-03 14:32:16 +02:00
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).
This commit is contained in:
parent
df3fa48288
commit
3d0849cc90
@ -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];
|
int coef_len = sce->ics.swb_offset[sfb_end] - sce->ics.swb_offset[sfb_start];
|
||||||
const int sfb_len = sfb_end - sfb_start;
|
const int sfb_len = sfb_end - sfb_start;
|
||||||
|
|
||||||
for (g = 0; g < sce->ics.num_swb; g++) {
|
for (g = sfb_start; g < sce->ics.num_swb && g <= sfb_end; g++) {
|
||||||
if (w*16+g < sfb_start || w*16+g > sfb_end)
|
FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[w*16+g];
|
||||||
continue;
|
if (g > sfb_start + (sfb_len/2))
|
||||||
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
|
en[1] += band->energy;
|
||||||
FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
|
else
|
||||||
if ((w+w2)*16+g > sfb_start + (sfb_len/2))
|
en[0] += band->energy;
|
||||||
en[1] += band->energy;
|
|
||||||
else
|
|
||||||
en[0] += band->energy;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (coef_len <= 0 || sfb_len <= 0)
|
if (coef_len <= 0 || sfb_len <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* LPC */
|
/* 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);
|
coef_len, order, coefs);
|
||||||
|
|
||||||
if (!order || gain < TNS_GAIN_THRESHOLD_LOW || gain > TNS_GAIN_THRESHOLD_HIGH)
|
if (!order || gain < TNS_GAIN_THRESHOLD_LOW || gain > TNS_GAIN_THRESHOLD_HIGH)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user