edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | //! Granule trimming: where an Ogg Vorbis stream starts and ends, in samples. |
| 2 | //! |
| 3 | //! A Vorbis block always decodes a whole window of samples, so the last packet |
| 4 | //! of a stream routinely reaches past the end the container states. Ogg says |
| 5 | //! where that end is: the granule position of the last page, which |
| 6 | //! `ec-ogg` attaches to the packet that finishes on it. Vorbis I (Annex A.2) |
| 7 | //! makes that granule the stream's exact length. |
| 8 | //! |
| 9 | //! The decoder counts its own samples from zero. A granule is an absolute |
| 10 | //! position, so the two are tied by an *offset* (`granule - decoded`), taken |
| 11 | //! from the first granule that arrives before any sample has been produced. |
| 12 | //! A stream that begins at position zero has offset zero and no front trim; |
| 13 | //! one that begins later, or whose first granule is ahead of its decoded |
| 14 | //! count, gets its head dropped. Later granules only move the end. |
| 15 | //! |
| 16 | //! Samples past the latest granule are not released: a later page may still |
| 17 | //! extend the stream, and the flush at end of stream cuts the rest. |
| 18 | |
| 19 | use ; |
| 20 | |
| 21 | /// The [`SideData::Custom`] kind `ec-ogg` attaches a page granule under. It is |
| 22 | /// `ec_ogg::GRANULE_KIND`; this crate does not depend on `ec-ogg`, so the |
| 23 | /// constant is restated here. |
| 24 | const GRANULE_KIND: u32 = u32from_be_bytes; |
| 25 | |
| 26 | /// The granule position `ec-ogg` attached to `packet`, if it did. |
| 27 | pub |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | /// Holds decoded samples until the granules say which of them are the stream's. |
| 37 | |
| 38 | pub |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 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 | |
| 91 | |
| 92 | |
| 93 | |
| 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 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 |