edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! VP9 import: the first source codec that is not H.264. |
| 2 | //! |
| 3 | //! The container and refusal checks need nothing installed. The software seat |
| 4 | //! (`ec-vp9`, `VE_SW` pinned) runs unignored; its fixtures are encoded by |
| 5 | //! ffmpeg's `libvpx-vp9` at test time, and its reference is ffmpeg's libvpx |
| 6 | //! decode, so those tests skip where ffmpeg has no libvpx. The hardware decode |
| 7 | //! and export twins need a built `libengine_hw.so` and a VA-API driver with a |
| 8 | //! VP9 decode entrypoint (`vainfo | grep VP9`), so they are `#[ignore]`d: |
| 9 | //! |
| 10 | //! ```text |
| 11 | //! cargo build -p engine -p engine-hw --release |
| 12 | //! LD_LIBRARY_PATH=target/release \ |
| 13 | //! cargo test -p engine --release --test vp9 -- --include-ignored --nocapture --test-threads=1 |
| 14 | //! ``` |
| 15 | //! |
| 16 | //! `VE_SW` is process-wide: every test that pins a seat takes it through |
| 17 | //! `support/seat.rs`, so the software and hardware tests here never see each |
| 18 | //! other's pin, with or without `--test-threads=1`. |
| 19 | |
| 20 | use crateseat; |
| 21 | |
| 22 | use ; |
| 23 | use Command; |
| 24 | use ; |
| 25 | |
| 26 | use ; |
| 27 | use Chroma; |
| 28 | use ; |
| 29 | use ExportSettings; |
| 30 | use Scratch; |
| 31 | use ; |
| 32 | |
| 33 | /// 1280x720@30, 2 s -- see `scripts/gen_fixtures.sh`. |
| 34 | const FRAMES: u32 = 60; |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | /// `VE_SW` is process-wide, so every test here that sets it or reads a decode |
| 43 | /// that depends on it takes this pin: parallel tests then see each other's |
| 44 | /// `VE_SW` only when they hold it, and a poisoned lock still serialises. |
| 45 | static ENV_PIN: Mutex = new; |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | /// The container half: a vp09 track is found, described and named as VP9, and |
| 52 | /// its AAC track is read exactly as any other file's -- the audio path knows |
| 53 | /// nothing about the video codec and this is what says so. |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | /// The software seat takes VP9 now: with the plugin forced off, the stream |
| 78 | /// opens on `ec-vp9` in this process. H.264 is untouched by the same pin. |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | /// A 4:4:4 HEVC clip, which no seat takes, encoded by ffmpeg's libx265 into the |
| 89 | /// temp dir: 3 frames of 64x64. `assets/` is gitignored, so the clip is made here. |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | /// A timeline is *not* refused a source coded differently -- every clip opens |
| 110 | /// its own decoder. With the plugin forced off, VP9 joins the timeline on |
| 111 | /// `ec-vp9` and HEVC on `ec-h265`; 4:4:4 HEVC is no seat's, so it is refused at |
| 112 | /// the door by the decoder's own name. |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | /// The refusal *at a span*, which is where it happens now: playback opens its |
| 135 | /// files on the worker (`DecodeSession::open_worker_deferred`), so a clip no |
| 136 | /// decoder here can take is refused there rather than on the caller's thread. |
| 137 | /// What must survive that move is the behaviour a refused span always had -- |
| 138 | /// no pictures from that clip, and the session walks on to the end instead of |
| 139 | /// stalling on it. |
| 140 | /// |
| 141 | /// The clip is imported as H.264, because the *door* still refuses what it |
| 142 | /// cannot open; the bytes under it become 4:4:4 HEVC afterwards, which is the only |
| 143 | /// way to put a span the worker must refuse on a timeline. (4:4:4 HEVC, not |
| 144 | /// HEVC: `ec-h265` has a software seat now and would decode 4:2:0 HEVC, and 4:2:2.) |
| 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 | /// The end-to-end user path: opening the file yields pictures, all of them, |
| 184 | /// through the plugin. |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | /// Export re-encodes to H.264 whatever the source was coded with: the packet |
| 215 | /// copy path is audio-only, so no VP9 byte can reach an `avc1` track. |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | // --- the software seat ----------------------------------------------------- |
| 241 | // |
| 242 | // `ec-vp9` against ffmpeg's `libvpx-vp9` decode, sample for sample. The clips |
| 243 | // are encoded by the same libvpx at test time: 24 frames of 352x288, a keyframe |
| 244 | // every 8, so seeks have several sync points to land on. |
| 245 | |
| 246 | const SW_FRAMES: u32 = 24; |
| 247 | const SW_KEYFRAME: u32 = 8; |
| 248 | |
| 249 | /// A WebM encoded by ffmpeg's libvpx at test time. `None` where ffmpeg with |
| 250 | /// `libvpx-vp9` is not installed -- the skip the other ffmpeg witnesses take. |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | /// Every picture ffmpeg's libvpx decoder releases, as raw planes of 16-bit |
| 267 | /// samples (8-bit output is widened, so one comparison serves both depths). |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | /// Every shown picture `ec-vp9` produces for the file's own access units, |
| 302 | /// planes as 16-bit samples, the same widening as [`ffmpeg_libvpx_planes`]. |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | /// The decoder, sample for sample against libvpx: profile 0 (8-bit) and profile |
| 317 | /// 2 (10-bit), every picture, not a sample of them. |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | /// Opens a clip and drains it, returning the pictures with their display |
| 340 | /// indices. The caller holds the software seat: the pin is read when the span |
| 341 | /// opens on its worker, so it must stay in place through the drain. |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | /// The edith seat, end to end: every frame of profile 0 and profile 2 comes out |
| 349 | /// through the span, in display order, at the clip's size, with pictures in |
| 350 | /// them -- and a seek lands on the very bytes a linear decode delivered, at the |
| 351 | /// sync points and between them. |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | /// Profile 1 is 4:4:4 (or 4:2:2 / 4:4:0), which the GPU does not take. Such a file |
| 398 | /// is not refused: the demuxer reads it, and it opens and decodes on the ec-vp9 |
| 399 | /// software seat, which takes all four profiles. Its pictures come out at the |
| 400 | /// clip's size, in display order, with a picture in them. |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 |