edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiBa5441e8Tahinli3 months ago1014 commits
| 1 | //! Ogg (RFC 3533): the container Vorbis, Opus and FLAC-in-Ogg travel in. |
| 2 | //! |
| 3 | //! [`OggDemuxer`] reads pages into packets — continuations reassembled, page |
| 4 | //! checksums verified, damaged pages skipped rather than fatal — and |
| 5 | //! [`OggMuxer`] writes packets back into pages with correct lacing, granule |
| 6 | //! positions and beginning/end-of-stream flags. Both speak the family IR, so an |
| 7 | //! Ogg file is `Demuxer` in and `Muxer` out like every other container here. |
| 8 | //! |
| 9 | //! What a granule position *means* belongs to the mapping, not to Ogg |
| 10 | //! ([`Mapping`]): Vorbis and FLAC count samples at the stream's own rate, Opus |
| 11 | //! counts 48 kHz samples including the pre-skip a decoder discards. Timestamps |
| 12 | //! are therefore exact per packet where the mapping states packet durations |
| 13 | //! (Opus does, in its TOC byte) and per page boundary where it does not (Vorbis |
| 14 | //! hides block sizes behind the setup header's codebooks, which is the Vorbis |
| 15 | //! decoder's parse, not the container's). |
| 16 | //! |
| 17 | //! Because a page states where its *last finishing packet* ends, a remux has to |
| 18 | //! carry that position through: [`OggDemuxer`] attaches it to the packet it |
| 19 | //! belongs to as [`SideData::Custom`] with kind [`GRANULE_KIND`], and |
| 20 | //! [`OggMuxer`] reads it back with [`granule_of`]. A packet without one is |
| 21 | //! still written — it simply cannot be the last packet on a page. |
| 22 | //! |
| 23 | //! Not covered: chained streams (a second beginning-of-stream group after the |
| 24 | //! first ends) are read as far as the first chain and no further, Skeleton |
| 25 | //! indexes are ignored, and Theora/Speex pages are skipped rather than |
| 26 | //! described. Each is a mapping this family does not carry yet, not a silent |
| 27 | //! misread. |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | pub use OggDemuxer; |
| 39 | pub use ; |
| 40 | pub use ; |
| 41 | pub use ; |
| 42 | pub use ; |
| 43 | |
| 44 | use ; |
| 45 | |
| 46 | /// [`SideData::Custom`] kind carrying an Ogg granule position: eight |
| 47 | /// little-endian bytes of `i64`, the position at which the packet ends in its |
| 48 | /// mapping's own units. |
| 49 | /// |
| 50 | /// Ogg states positions per page rather than per packet, and only for the last |
| 51 | /// packet finishing on each page, so this is present on exactly those packets — |
| 52 | /// it is the one piece of Ogg timing that has nowhere else to live in a |
| 53 | /// `Packet`, and without it a remux would have to guess where its pages end. |
| 54 | pub const GRANULE_KIND: u32 = u32from_be_bytes; |
| 55 | |
| 56 | /// Side data stating that a packet ends at `granule`. |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | /// The granule position attached to `packet`, if any. |
| 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 |