edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | //! Whole-stream decoding: an IVF file in, decoded pictures out. |
| 2 | //! |
| 3 | //! VP9 frames are not self-delimiting — a frame's total size only the |
| 4 | //! container knows (and one IVF chunk may hold a superframe with hidden |
| 5 | //! ALTREF frames) — so the whole-stream API takes the stream in the |
| 6 | //! container VP9 actually ships in: IVF (`DKIF`/`VP90`). Single frames |
| 7 | //! or chunks from any other demuxer feed |
| 8 | //! [`crate::decode::Decoder::decode`] directly, which splits superframes |
| 9 | //! itself. |
| 10 | //! |
| 11 | //! The shape mirrors `ec-vp8`'s: [`decode_stream`] collects every shown |
| 12 | //! picture into a `Vec`, and [`decode_stream_with`] hands each picture |
| 13 | //! to a sink the moment it exists. |
| 14 | |
| 15 | use crate; |
| 16 | use crateensure; |
| 17 | use crate::; |
| 18 | |
| 19 | /// The IVF file magic, `DKIF`. |
| 20 | const DKIF: & = b"DKIF"; |
| 21 | /// The fourcc for VP9 video (`VP90`). |
| 22 | const VP90: & = b"VP90"; |
| 23 | |
| 24 | /// One demuxed IVF frame: presentation timestamp plus the compressed |
| 25 | /// VP9 payload (possibly a superframe chunk). |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | /// Split an IVF byte stream into its frames, validating the container |
| 32 | /// envelope as [`Error`]s rather than panics. |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 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 | /// Decode every shown frame in an IVF VP9 stream, in presentation order. |
| 65 | /// |
| 66 | /// The stream must start with a key frame; hidden frames |
| 67 | /// (`show_frame == 0`) update the reference buffers but are not part of |
| 68 | /// the output. |
| 69 | /// |
| 70 | /// # Errors |
| 71 | /// As [`demux`] reports for the container, [`Decoder::decode`] for the |
| 72 | /// frames, plus `vp9 inter` refusals once a lane-ineligible frame shows |
| 73 | /// up. |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | /// Streaming form of [`decode_stream`]: hand every shown picture to |
| 84 | /// `sink` the moment it exists. `sink` receives the picture, the |
| 85 | /// decode-order index of the IVF chunk it came from, and the IVF |
| 86 | /// presentation timestamp. An `Err` from `sink` aborts the decode. |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 |