edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB552edc4Tahinli2 months ago2048 commits
| 1 | //! The Ogg-Opus header packets, RFC 7845. |
| 2 | //! |
| 3 | //! Only the two headers and the channel-mapping table live here; the pages |
| 4 | //! themselves are `ec-ogg`'s job. Keeping the mapping in this crate is what |
| 5 | //! lets an encoder and a muxer agree without either depending on the other. |
| 6 | //! |
| 7 | //! Two numbers a caller must not invent: |
| 8 | //! |
| 9 | //! - **pre-skip** is the encoder's delay in 48 kHz samples |
| 10 | //! ([`crate::Encoder::look_ahead`] scaled to 48 kHz — 120 for this encoder). |
| 11 | //! A player discards that many samples, which is exactly what cancels the |
| 12 | //! delay; getting it wrong shifts the whole stream. |
| 13 | //! - **granule position** counts 48 kHz samples *including* the pre-skip, so |
| 14 | //! the first page's granule is `samples_encoded` and the file's duration is |
| 15 | //! `last_granule - pre_skip`. |
| 16 | |
| 17 | /// Builds an `OpusHead` packet (RFC 7845, Section 5.1). |
| 18 | /// |
| 19 | /// `input_rate` is the rate the samples arrived at, informational only — |
| 20 | /// the granule clock is always 48 kHz. `mapping` is `(family, streams, |
| 21 | /// coupled, table)`; [`None`] writes family 0, which is mono or stereo. |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | /// Builds an `OpusTags` packet with a vendor string and no comments. |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | /// The default channel mapping of RFC 7845 Section 5.1.1.2: `(family, streams, |
| 59 | /// coupled, table)` for 1 to 8 channels. |
| 60 | /// |
| 61 | /// Families 0 and 1 differ in more than the table: family 1 puts the channels |
| 62 | /// in *Vorbis* order (for 5.1: left, centre, right, back left, back right, |
| 63 | /// LFE), so a caller whose buffers are in the usual film order |
| 64 | /// (FL, FR, FC, LFE, BL, BR) permutes by `[0, 2, 1, 4, 5, 3]` on the way in and |
| 65 | /// by the same permutation on the way out. |
| 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 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 |