Tone_core's pulse/tns/gain flags sat after spectral data, not before
Browse files at this commit23f057e2d13593f68f2f4078ea11ce1a022f6113Parent: e3a8adf- fix
- tone_core's pulse/tns/gain flags sat after spectral data, not before
3 changed files +13 -8
- crates/ec-aac/examples/adts_to_pcm.rs +3 -1
- crates/ec-aac/src/sbr_hf.rs +6 -6
- scripts/aac-tables/sbrchirp.py +4 -1
crates/ec-aac/examples/adts_to_pcm.rsmodified+3 -1
| @@ -5,7 +5,9 @@ | |||
| 5 | use std::io::Write; | 5 | use std::io::Write; |
| 6 | 6 | ||
| 7 | fn main() { | 7 | fn main() { |
| 8 | - let path = std::env::args().nth(1).expect("usage: adts_to_pcm <file.aac>"); | 8 | + let path = std::env::args() |
| 9 | + .nth(1) | ||
| 10 | + .expect("usage: adts_to_pcm <file.aac>"); | ||
| 9 | let data = std::fs::read(&path).expect("file readable"); | 11 | let data = std::fs::read(&path).expect("file readable"); |
| 10 | // Plain `AacDecoder::new()` never enables SBR (it only turns on from an | 12 | // Plain `AacDecoder::new()` never enables SBR (it only turns on from an |
| 11 | // explicit AudioSpecificConfig's `sbr_present`, per `with_config`) -- | 13 | // explicit AudioSpecificConfig's `sbr_present`, per `with_config`) -- |
crates/ec-aac/src/sbr_hf.rsmodified+6 -6
| @@ -354,12 +354,12 @@ mod tests { | |||
| 354 | use crate::sbr_bands::freq_tables; | 354 | use crate::sbr_bands::freq_tables; |
| 355 | 355 | ||
| 356 | fn real_file_tables() -> BandTables { | 356 | fn real_file_tables() -> BandTables { |
| 357 | - // The rig's own header params for ~/Music/reeln.mp4's SBR | 357 | + // The real file's actual SBR header, read straight off the |
| 358 | - // element (44100 Hz extension rate, core-Nyquist crossover ~5 kHz): | 358 | + // bitstream (round-27/28: start_freq=5 stop_freq=8 xover_band=0 |
| 359 | - // freq_scale=2, alter_scale=1, noise_bands=2, start/stop/xover taken | 359 | + // freq_scale=2 alter_scale=1 noise_bands=2 -> kx=14 k2=43 n_q=3; |
| 360 | - // from the mid-range defaults `EXTRA1_DEFAULTS` documents when a | 360 | + // the previous stop_freq=3/xover_band=2 guess gave a smaller, |
| 361 | - // stream omits bs_header_extra_1/2. | 361 | + // wrong kx=16 k2=29 header). |
| 362 | - freq_tables(44100, 5, 3, 2, 1, 2, 2).expect("valid header for the real file's rate") | 362 | + freq_tables(44100, 5, 8, 2, 1, 0, 2).expect("valid header for the real file's rate") |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | #[test] | 365 | #[test] |
scripts/aac-tables/sbrchirp.pymodified+4 -1
| @@ -87,6 +87,10 @@ def tone_core(w, sfb_idx, group_active, gain=200): | |||
| 87 | w.w(3, 4) | 87 | w.w(3, 4) |
| 88 | w.w(1, 5) | 88 | w.w(1, 5) |
| 89 | w.w(P.HCB_SF[60][1], P.HCB_SF[60][0]) # scalefactor delta 0 | 89 | w.w(P.HCB_SF[60][1], P.HCB_SF[60][0]) # scalefactor delta 0 |
| 90 | + w.w(0, 3) # pulse/tns/gain-control absent -- MUST precede spectral_data() | ||
| 91 | + # (round-28 fix: this write sat AFTER the spectral loop below, shifting | ||
| 92 | + # every bit that followed and desyncing the reference decoder on every | ||
| 93 | + # probed band -- byte-accounted against sce_core's proven field order.) | ||
| 90 | ngroups = (swb[sfb_idx + 1] - swb[sfb_idx]) // 4 | 94 | ngroups = (swb[sfb_idx + 1] - swb[sfb_idx]) // 4 |
| 91 | for i in range(ngroups): | 95 | for i in range(ngroups): |
| 92 | quad = (2, 0, 0, 0) if i == group_active else (0, 0, 0, 0) | 96 | quad = (2, 0, 0, 0) if i == group_active else (0, 0, 0, 0) |
| @@ -95,7 +99,6 @@ def tone_core(w, sfb_idx, group_active, gain=200): | |||
| 95 | w.w(code, length) | 99 | w.w(code, length) |
| 96 | for _ in signs: | 100 | for _ in signs: |
| 97 | w.w(0, 1) | 101 | w.w(0, 1) |
| 98 | - w.w(0, 3) # pulse/tns/gain-control absent | ||
| 99 | return w | 102 | return w |
| 100 | 103 | ||
| 101 | 104 | ||