edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli4 days ago4021 commits
| 1 | //! Parametric Stereo (HE-AACv2) against FFmpeg's native AAC decoder. |
| 2 | //! |
| 3 | //! Each fixture is a 2-second HE-AACv2 stereo ADTS stream (generated by |
| 4 | //! `scripts/aac-tables/make-ps-fixtures.sh`). The reference is FFmpeg's own |
| 5 | //! decode of the same file. The acceptance bar is a per-channel correlation of |
| 6 | //! at least 0.999 after a bounded lag search, which absorbs decoder priming |
| 7 | //! delay, as `sbr_real_library.rs` does for HE-AAC v1. |
| 8 | |
| 9 | use cratehave_ffmpeg; |
| 10 | use cratefixture; |
| 11 | use cratedeinterleave; |
| 12 | use cratecorrelation; |
| 13 | use AacDecoder; |
| 14 | use Path; |
| 15 | use Command; |
| 16 | |
| 17 | /// Per-channel correlation the reconstruction must reach against FFmpeg. |
| 18 | const MIN_CORR: f64 = 0.999; |
| 19 | /// Fixtures whose PS reconstruction is known to differ from FFmpeg, with the |
| 20 | /// correlation floor the current code is held to. Empty: every PS fixture |
| 21 | /// matches FFmpeg at `MIN_CORR` or better. An entry here needs a one-line reason |
| 22 | /// and a measured floor; remove it once the fixture passes at `MIN_CORR`. |
| 23 | const KNOWN_INEXACT: & = &; |
| 24 | const KNOWN_INEXACT_FLOOR: f64 = 0.69; |
| 25 | /// Lag search bound, in samples. A winning lag at this bound is not a measurement. |
| 26 | const LAG_MAX: i64 = 4096; |
| 27 | /// Window (in samples) the coarse lag search correlates over. |
| 28 | const WINDOW: usize = 16_384; |
| 29 | /// Where the coarse window starts, past the decoder's start-up transient. |
| 30 | const WINDOW_START: usize = 32_768; |
| 31 | |
| 32 | /// (fixture, sample rate it decodes to) |
| 33 | const FIXTURES: & = & |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | ; |
| 39 | |
| 40 | /// FFmpeg's decode of `path` as planar stereo `f32`. |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | /// The overlap of `ours` and `theirs` at `lag`: `ours[i]` pairs with `theirs[i + lag]`. |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | /// The lag that best aligns `ours` with `theirs`, and the full-overlap |
| 75 | /// correlation at that lag. A winning lag on the search bound is refused: the |
| 76 | /// true alignment may lie outside the search, so the number would be noise. |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 |