edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB03dc6e9Tahinli3 months ago178 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 | |
| 28 | |
| 29 | pub use ; |
| 30 | |
| 31 | use ; |
| 32 | use |
| 33 | |
| 34 | ; |
| 35 | |
| 36 | /// Register this crate's codecs — `ac3` and `eac3` — into `registry`. |
| 37 | /// |
| 38 | /// Both ids reach the same decoder: it dispatches per packet on `bsid`, so the |
| 39 | /// id picks the capability set and not the syntax. |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | /// A decoder for `params`, folded down to `params.channels`. |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | /// The family's AC-3 decoder: one syncframe in, one S16 little-endian frame |
| 63 | /// out. |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | /// Interleaved `f32` bytes as S16 little-endian, which is what the incumbent |
| 91 | /// speaks. Full scale is 32768 in both directions, saturating: the replica's |
| 92 | /// inverse is `/32768.0`, and a sample at or past `+1.0` has to land on |
| 93 | /// `i16::MAX` rather than wrap to silence. |
| 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 |