From: Kostya Shishkov Date: Sat, 21 Jun 2025 12:27:21 +0000 (+0200) Subject: aac/sbr: fix noise band selection X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=2b0ee5290506b95fac2b7d818bbf32767d1200d5;p=nihav.git aac/sbr: fix noise band selection --- diff --git a/nihav-mpeg/src/codecs/aac/sbr/synth.rs b/nihav-mpeg/src/codecs/aac/sbr/synth.rs index 42a5ba0..cc7cd5c 100644 --- a/nihav-mpeg/src/codecs/aac/sbr/synth.rs +++ b/nihav-mpeg/src/codecs/aac/sbr/synth.rs @@ -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);