]> git.nihav.org Git - nihav.git/commitdiff
aac/sbr: fix noise band selection
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 21 Jun 2025 12:27:21 +0000 (14:27 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 21 Jun 2025 12:27:21 +0000 (14:27 +0200)
nihav-mpeg/src/codecs/aac/sbr/synth.rs

index 42a5ba04f4d671eca6d0aeb48a00d5155d31988e..cc7cd5c650470ec96ee73b0cb6c970eff8800efa 100644 (file)
@@ -223,8 +223,9 @@ impl SBRChannel {
                     let cur_x = self.x[l][p];
                     let prev_x = self.x[l - 1][p];
                     let pprev_x = self.x[l - 2][p];
-                    let g_k = match state.f_noise[..state.num_noise_bands].binary_search(&k) {
-                            Ok(idx) | Err(idx) => idx.min(state.num_noise_bands - 1),
+                    let g_k = match state.f_noise[..state.num_noise_bands].binary_search(&(dst_k + k)) {
+                            Ok(idx) => idx,
+                            Err(idx) => (idx - 1).min(state.num_noise_bands - 1),
                         };
                     let bw_val = self.bw_array[g_k];
                     *dst = cur_x + a0[p] * prev_x.scale(bw_val) + a1[p] * pprev_x.scale(bw_val * bw_val);