From f9581022075b7e6a6e815132b18fc8fba37d3246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 10:08:53 +0300 Subject: [PATCH] ec-aac SBR: FIXVAR/VARVAR trailing relative borders applied in reverse order sbr_payload.rs parse_grid read the trailing rel borders in wire order but subtracted the last-read one from the trailing edge. FFmpeg n8.0 aacsbr_template.c read_sbr_grid assigns the first-read rel to t_env[n-1] (FIXVAR: t_env[bs_num_env-1-i] = t_env[bs_num_env-i] - 2*bits-2, same in VARVAR). Only differs when there are 2+ trailing rels (num_env >= 3), so a uniform list hid it. Fix: rel index num_env-1-i in both trailing loops. --- crates/ec-aac/src/sbr_payload.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ec-aac/src/sbr_payload.rs b/crates/ec-aac/src/sbr_payload.rs index 7aadfd5f..fa58f27f 100644 --- a/crates/ec-aac/src/sbr_payload.rs +++ b/crates/ec-aac/src/sbr_payload.rs @@ -350,7 +350,7 @@ impl SbrParser { t[num_env] = trail; let mut acc = trail; for i in (1..num_env).rev() { - acc -= rel[i - 1]; + acc -= rel[num_env - 1 - i]; t[i] = acc; } } else { @@ -394,7 +394,7 @@ impl SbrParser { t[num_env] = trail; let mut acc = trail; for i in (num_rel0 + 1..num_env).rev() { - acc -= rel1[i - num_rel0 - 1]; + acc -= rel1[num_env - 1 - i]; t[i] = acc; } if t.windows(2).any(|w| w[0] >= w[1]) {