edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB552edc4Tahinli2 months ago2048 commits
| 1 | //! `oxideav-ac3` as edith consumes it, over [`ec_ac3`]. |
| 2 | //! |
| 3 | //! A shim, not a port: it carries the incumbent's package name and version so |
| 4 | //! the swap is a `[patch.crates-io]` line, and it exposes exactly the items the |
| 5 | //! replica names — the header surface it reads a track's rate and layout out of |
| 6 | //! ([`syncinfo::parse`], [`bsi::parse`], [`eac3::bsi::parse`], `audio.rs:1954`, |
| 7 | //! `2063`) and [`register_codecs`], which is how it gets a decoder at all |
| 8 | //! (`audio.rs:2132`). The header modules are `ec_ac3`'s own: their signatures, |
| 9 | //! their entry offsets (`bsi` after the five `syncinfo()` bytes, `eac3::bsi` |
| 10 | //! after the 16-bit sync word) and their fields already match what the replica |
| 11 | //! writes, so a re-export is the whole adapter. |
| 12 | //! |
| 13 | //! Two differences are owned here rather than at the call site: |
| 14 | //! |
| 15 | //! * **Sample format.** The incumbent hands out S16 little-endian and the |
| 16 | //! replica reads it as such (`audio.rs:2160`, `chunks_exact(2)` over |
| 17 | //! `/32768.0`); `ec_ac3` decodes to `f32`. The conversion is |
| 18 | //! [`Ac3Decoder::receive_frame`], once, for every caller — which is why this |
| 19 | //! shim writes its own [`oxideav_core::Decoder`] instead of wrapping |
| 20 | //! `oxideav_core::EcDecoder`, whose job is the frames that need no |
| 21 | //! conversion. |
| 22 | //! * **Downmix request.** The incumbent takes the wanted channel count on |
| 23 | //! [`CodecParameters::channels`] and `ec_ac3` takes a [`Downmix`] mode; the |
| 24 | //! factory translates. `Some(2)` is the A/52 §7.8 stereo fold the replica |
| 25 | //! asks for on anything wider than mono, `None` the stream's own layout. |
| 26 | //! |
| 27 | //! Encoding is not on the incumbent's own surface, so [`Ac3Encoder`] is |
| 28 | //! shaped after this family's other software encoder shim instead — |
| 29 | //! `rusty_aac::AacEncoder`'s `new`/`push_pcm_f32`/`next_packet`/ |
| 30 | //! `encoder_delay` — so an export path already wired to one SW audio |
| 31 | //! encoder here can add this one the same way. |
| 32 | |
| 33 | |
| 34 | |
| 35 | pub use ; |
| 36 | |
| 37 | use ; |
| 38 | use |
| 39 | |
| 40 | ; |
| 41 | |
| 42 | /// Register this crate's codecs — `ac3` and `eac3` — into `registry`. |
| 43 | /// |
| 44 | /// Both ids reach the same decoder: it dispatches per packet on `bsid`, so the |
| 45 | /// id picks the capability set and not the syntax. |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | /// A decoder for `params`, folded down to `params.channels`. |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | /// The family's AC-3 decoder: one syncframe in, one S16 little-endian frame |
| 69 | /// out. |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | /// Interleaved `f32` bytes as S16 little-endian, which is what the incumbent |
| 97 | /// speaks. Full scale is 32768 in both directions, saturating: the replica's |
| 98 | /// inverse is `/32768.0`, and a sample at or past `+1.0` has to land on |
| 99 | /// `i16::MAX` rather than wrap to silence. |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | /// How [`Ac3Encoder::new`] is configured. |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | /// An AC-3 encoder: PCM in, syncframes out. |
| 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 | |
| 248 |