edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! H.264 in Matroska: the codec this project has always decoded, in the |
| 2 | //! container that used to refuse it by name. Nothing new decodes here -- the |
| 3 | //! demuxer reframes the `avcC`-prefixed blocks to Annex-B and hands them to the |
| 4 | //! same dispatch an mp4's samples go to -- so the whole file runs with nothing |
| 5 | //! installed, on the software seat (`ec-h264`) if the plugin is absent. |
| 6 | //! |
| 7 | //! ```text |
| 8 | //! cargo test -p engine --test h264_mkv |
| 9 | //! ``` |
| 10 | |
| 11 | use PathBuf; |
| 12 | use ; |
| 13 | |
| 14 | use ; |
| 15 | use ; |
| 16 | |
| 17 | /// 1280x720@30, 2 s, keyframes 30 apart -- see `scripts/gen_fixtures.sh`. |
| 18 | const FRAMES: u32 = 60; |
| 19 | const KEYFRAME: u32 = 30; |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | /// The Annex-B NAL types of an access unit, in order: `nal_unit_type` is the low |
| 28 | /// 5 bits of the byte after each start code. |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | /// The container half, and the refusal this slice exists to delete: the file |
| 38 | /// opens, and it says H.264 rather than "not supported". |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | /// Matroska stores H.264 in `avcC` framing -- length prefixes, and the SPS/PPS |
| 61 | /// out of band in `CodecPrivate` -- so an access unit is only decodable if both |
| 62 | /// were handled: reframed to Annex-B, parameter sets ahead of every keyframe. |
| 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 | /// The user-facing end of it, through the very call the window's open door makes |
| 105 | /// (`app/src/main.rs:2242`): the file becomes a timeline and that timeline shows |
| 106 | /// a picture. No plugin is required -- H.264 is the one codec with a software |
| 107 | /// decoder here -- so this is what says the reframed access units are really |
| 108 | /// decodable and not just well-shaped. |
| 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 | /// The sound comes with it: a Matroska file's audio is read whatever its picture |
| 135 | /// is coded with, so nothing is left for the "cannot be decoded" notice to name. |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 |