edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiBcd32144Tahinli2 months ago2288 commits
| 1 | //! AAC-LC: decoder (mono through 7.1) and encoder, in safe Rust. |
| 2 | //! |
| 3 | //! # Where the tables come from |
| 4 | //! |
| 5 | //! The Huffman codebooks, the scalefactor codebook and the scalefactor-band |
| 6 | //! offsets in [`tables`] were **derived**, not transcribed: `scripts/derive-aac-tables.py` |
| 7 | //! synthesises access units whose spectral payload is a chosen bit string, has a |
| 8 | //! reference decoder decode them, and reads the quantised spectrum back through |
| 9 | //! the inverse MDCT. Walking the binary tree of probes enumerates each codebook |
| 10 | //! in about `2M` frames for `M` codewords. Every table came out with a Kraft |
| 11 | //! sum of exactly 1 and the entry count ISO/IEC 14496-3 prescribes, which is |
| 12 | //! what makes the derivation self-checking rather than a transcription to be |
| 13 | //! trusted. |
| 14 | //! |
| 15 | //! # What is here and what is not |
| 16 | //! |
| 17 | //! AAC-LC (audio object type 2) is complete: all four window sequences, both |
| 18 | //! window shapes, TNS, pulse data, M/S and intensity stereo, PNS, and SCE, CPE, |
| 19 | //! LFE, DSE, PCE and FIL elements. HE-AAC v1 (SBR) is reconstructed: the core |
| 20 | //! decodes, its low bands feed the SBR QMF/HF/envelope chain, and the output |
| 21 | //! is at the extension rate. Parametric Stereo is **not** implemented; a |
| 22 | //! stream that signals it decodes to its AAC-LC core, at the core sample |
| 23 | //! rate, and says so through [`AacDecoder::sbr_support`] and |
| 24 | //! [`AacDecoder::output_sample_rate`] rather than silently claiming the |
| 25 | //! extension rate. See `sbr_is_reported_not_silently_upsampled` in the tests. |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | pub use |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | ; |
| 49 | pub use ; |
| 50 | pub use ; |
| 51 | pub use ; |
| 52 | /// Diagnostic only (round-20): per-(access-unit, channel) side-info rows |
| 53 | /// logged during decode when `EC_AAC_SBR_SIDEINFO_DEBUG` is set. |
| 54 | pub use ; |
| 55 | /// Diagnostic only (round-17 Task 1 conviction check): reads back the |
| 56 | /// per-absolute-QMF-band transmitted signal/noise energy sums |
| 57 | /// `EC_AAC_SBR_NOISE_FRACTION_DEBUG` accumulates during decode. |
| 58 | pub use noise_fraction_table; |
| 59 | pub use SAMPLE_RATES; |
| 60 | |
| 61 | use BlockDecoder; |
| 62 | use BitReader; |
| 63 | |
| 64 | /// What this decoder does with a High Efficiency stream. |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | /// One decoded frame: interleaved `f32` in film channel order. |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | /// Bitstream element order to the film order `FL, FR, FC, LFE, BL, BR, SL, SR` |
| 100 | /// that every downmix in this family folds (ISO/IEC 14496-3 tbl 1.19: the |
| 101 | /// elements arrive centre first, LFE last). |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | /// An AAC-LC decoder. |
| 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 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | /// Appends a block's planes to the packet's, growing the plane count if a later |
| 248 | /// `raw_data_block` carries more channels than an earlier one. |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 |