diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-08-27 10:41:14 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-08-27 10:41:14 +0200 |
commit | b103b7b26e1ceb2a5529960b4f407e55dd51c910 (patch) | |
tree | 71c026e13f874fb30d8ee4981c700ea1d9f905fd | |
parent | 2451e9532d1796640598e106ae2ecbcce38e2793 (diff) | |
download | nihav-b103b7b26e1ceb2a5529960b4f407e55dd51c910.tar.gz |
aac: fix TNS filtering
The specification says it should use initial zero filter state instead of
relying on neighbour coefficients.
Reported by Philip Deljanov
-rw-r--r-- | nihav-commonfmt/src/codecs/aac.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/nihav-commonfmt/src/codecs/aac.rs b/nihav-commonfmt/src/codecs/aac.rs index d3f991b..5058a44 100644 --- a/nihav-commonfmt/src/codecs/aac.rs +++ b/nihav-commonfmt/src/codecs/aac.rs @@ -782,17 +782,23 @@ impl ICS { let start = w * 128 + self.get_band_start(tns_max_bands.min(bottom)); let end = w * 128 + self.get_band_start(tns_max_bands.min(top)); let lpc = &tns_data.coeffs[w][f].coef; + let mut state = [0.0f32; 64]; + let mut sidx = 32; if !tns_data.coeffs[w][f].direction { for m in start..end { - for i in 0..order.min(m) { - self.coeffs[m] -= self.coeffs[m - i - 1] * lpc[i]; + for i in 0..order { + self.coeffs[m] -= state[(sidx + i) & 63] * lpc[i]; } + sidx = (sidx + 63) & 63; + state[sidx] = self.coeffs[m]; } } else { for m in (start..end).rev() { - for i in 0..order.min(m) { - self.coeffs[m] -= self.coeffs[m + i - 1] * lpc[i]; + for i in 0..order { + self.coeffs[m] -= state[(sidx + i) & 63] * lpc[i]; } + sidx = (sidx + 63) & 63; + state[sidx] = self.coeffs[m]; } } } |