edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! HEVC in Matroska, 8- and 10-bit, sound included: the shape a film off a disc |
| 2 | //! arrives in, and the one the AV1 walk was written for one codec too early. |
| 3 | //! |
| 4 | //! Three things meet here and each is checked on its own: the demuxer reads an |
| 5 | //! `hvcC` out of a `CodecPrivate` and reframes Matroska blocks to Annex-B, the |
| 6 | //! plugin decodes Main 10 through a P010 surface pool, and the sound -- 5.1 AAC |
| 7 | //! at 48 kHz -- is read by symphonia's mkv reader, decoded by `ec-aac` and |
| 8 | //! folded to the stereo one output device carries. |
| 9 | //! |
| 10 | //! The container and audio checks need nothing installed. The decode twins need |
| 11 | //! a built `libengine_hw.so` and a VA-API driver with an HEVC decode entrypoint |
| 12 | //! (`vainfo | grep HEVC`), so they are `#[ignore]`d: |
| 13 | //! |
| 14 | //! ```text |
| 15 | //! cargo build -p engine -p engine-hw --release |
| 16 | //! LD_LIBRARY_PATH=target/release \ |
| 17 | //! cargo test -p engine --release --test hevc_mkv -- --include-ignored --nocapture |
| 18 | //! ``` |
| 19 | |
| 20 | use cratehwchild; |
| 21 | |
| 22 | use PathBuf; |
| 23 | |
| 24 | use ; |
| 25 | use HwSession; |
| 26 | use ; |
| 27 | |
| 28 | /// 1280x720@30, 2 s, keyed twice -- see `scripts/gen_fixtures.sh`. |
| 29 | const FRAMES: u32 = 60; |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | /// The container half: an HEVC track in an mkv is found, named, measured, and |
| 38 | /// its blocks come back as Annex-B access units with the parameter sets in |
| 39 | /// front of every keyframe. Matroska indexes nothing, so all four numbers come |
| 40 | /// out of the walk. |
| 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 | /// A Matroska file's sound is read now, and a 5.1 track joins the timeline as |
| 102 | /// the stereo source the fold makes of it. |
| 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 | /// The fold, measured on the tones the fixture puts one per channel: every |
| 136 | /// channel but the LFE reaches the stereo pair, the surrounds and the centre at |
| 137 | /// -3 dB of the fronts, and nothing crosses sides. |
| 138 | /// |
| 139 | /// Which tone is which *position* is the encoder's business (ffmpeg's AAC |
| 140 | /// encoder does not keep the order they were written in), so the check is on |
| 141 | /// the shape: two full-weight tones, one per side; one tone in both at -3 dB; |
| 142 | /// two more at -3 dB, one per side; and the 60 Hz LFE nowhere. |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | /// Amplitude of one frequency in `x` (Goertzel), which is what "this channel |
| 199 | /// reached that output" is measured with. |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | /// The picture, on the hardware that decodes it: every frame of both files, at |
| 214 | /// the size the container declared. Main 10 goes through the P010 pool and is |
| 215 | /// read back to the same 8-bit I420 the 8-bit path hands out, so the only thing |
| 216 | /// this can tell them apart by is that neither errors. |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | /// ...and the same file through the session a clip actually plays from, which |
| 241 | /// is where a codec that only the plugin can decode is refused if it cannot. |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 |