edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! VP8 import: the container half, and the decode half. The software seat is |
| 2 | //! `ec-vp8` in this process (`decode::vp8`), and it runs unignored: its clips |
| 3 | //! are encoded by ffmpeg's `libvpx` at test time, and its reference is ffmpeg's |
| 4 | //! libvpx decode, so those tests skip where ffmpeg has no libvpx. The plugin's |
| 5 | //! own VP8 arm (`engine-hw`'s `vpx.rs`, the same `ec-vp8`) is the hardware-first |
| 6 | //! twin and needs a built `libengine_hw.so`, but **no VA-API VP8 profile**: no |
| 7 | //! such profile exists on this GPU, and none is asked for. |
| 8 | //! |
| 9 | //! ```text |
| 10 | //! cargo build -p engine -p engine-hw --release |
| 11 | //! LD_LIBRARY_PATH=target/release \ |
| 12 | //! cargo test -p engine --release --test vp8 -- --include-ignored --nocapture --test-threads=1 |
| 13 | //! ``` |
| 14 | //! |
| 15 | //! `VE_SW` is process-wide: every test that pins a seat takes it through |
| 16 | //! `support/seat.rs`, so the software and hardware tests here never see each |
| 17 | //! other's pin, with or without `--test-threads=1`. |
| 18 | use crateseat; |
| 19 | |
| 20 | use ; |
| 21 | use Command; |
| 22 | use ; |
| 23 | |
| 24 | use ; |
| 25 | use ; |
| 26 | use ExportSettings; |
| 27 | use Scratch; |
| 28 | use ; |
| 29 | |
| 30 | /// 1280x720@30, 2 s -- see `scripts/gen_fixtures.sh`. |
| 31 | const FRAMES: u32 = 60; |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | /// The container half: a vp08 track is found and named as VP8 out of the mp4, |
| 40 | /// its `V_VP8` twin out of the `.webm`, and the AAC track is read exactly as |
| 41 | /// any other file's -- the audio path knows nothing about the video codec. |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | /// The software seat takes VP8 now: with the plugin forced off, the stream |
| 64 | /// opens on `ec-vp8` in this process, the same way H.264 and VP9 do. |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | /// The end-to-end user path: opening the file yields pictures, all of them, |
| 73 | /// through the plugin's VP8 arm. The `.webm` is the file this decodes, |
| 74 | /// the container half being the Matroska demuxer's `V_VP8` row. |
| 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 | /// Export re-encodes to H.264 whatever the source was coded with: the packet |
| 116 | /// copy path is audio-only, so no VP8 byte can reach an `avc1` track. |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | // --- the software seat ----------------------------------------------------- |
| 149 | // |
| 150 | // `ec-vp8` against ffmpeg's `libvpx` decode, picture for picture. The clips are |
| 151 | // encoded by the same libvpx at test time. Three shapes: a plain stream with a |
| 152 | // key frame every 8, a stream with hidden alt-ref frames (lag-in-frames and |
| 153 | // auto-alt-ref, so the decoder's reference handling beyond the key frame is |
| 154 | // exercised), and an odd-sized 99x67 stream (chroma planes of 50x34). |
| 155 | |
| 156 | const SW_FRAMES: u32 = 24; |
| 157 | const SW_KEYFRAME: u32 = 8; |
| 158 | |
| 159 | /// One clip shape: name, width, height, and whether it carries alt-ref frames. |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | const CLIPS: = |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | ; |
| 187 | |
| 188 | /// A WebM encoded by ffmpeg's libvpx at test time. `None` where ffmpeg with |
| 189 | /// `libvpx` is not installed -- the skip the other ffmpeg witnesses take. |
| 190 | /// |
| 191 | /// The alt-ref clip is two-pass: libvpx's one-pass encoder through ffmpeg never |
| 192 | /// emits a hidden alt-ref frame, and the stream would not test what its name says. |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | /// An odd-sized clip. ffmpeg's libvpx encoder only takes even sizes (asked for |
| 229 | /// 99x67 it writes 98x66), so the 98x66 stream is re-labelled at the bitstream |
| 230 | /// level: 98 and 66 round up to the same 7x5 macroblock grid as 99 and 67, so |
| 231 | /// every key frame's dimension field is rewritten and the macroblock data is |
| 232 | /// untouched. The result is a real 99x67 stream, which libvpx then decodes as |
| 233 | /// its own. The IVF header is rewritten too, so the WebM ffmpeg muxes from it |
| 234 | /// carries 99x67. |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | /// The display indices of a file's shown frames, and how many access units it |
| 285 | /// has. A hidden frame is one whose `show_frame` bit (bit 4 of the first byte, |
| 286 | /// RFC 6386 9.1) is clear: it takes a container slot and shows nothing. |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | /// Every picture ffmpeg's libvpx decoder releases, as 8-bit I420 planes widened |
| 301 | /// to 16 bits, so one comparison serves every shape. Chroma is `div_ceil(2)`, |
| 302 | /// which is what makes the odd-sized clip's planes come out right. |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | /// Every shown picture `ec-vp8` produces for the file's own access units, plus |
| 334 | /// how many access units it took to get them: the difference is the hidden |
| 335 | /// frames, which the altref clip must have. |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | /// The decoder, picture for picture against libvpx: every shown frame of every |
| 352 | /// clip shape, plane by plane. The altref clip must also carry hidden frames, |
| 353 | /// or it would not be testing what it is named for. |
| 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 | /// Opens a clip and drains it, returning the pictures with their display |
| 397 | /// indices. The caller holds the software seat: the pin is read when the span |
| 398 | /// opens on its worker, so it must stay in place through the drain. |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | /// The edith seat, end to end: every frame of every clip shape comes out |
| 406 | /// through the span, in display order, at the clip's size, with pictures in |
| 407 | /// them -- and a seek lands on the very bytes a linear decode delivered, at the |
| 408 | /// key frames, between them, and past the hidden frames. |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | |
| 479 | |
| 480 | |
| 481 | |
| 482 | |
| 483 | |
| 484 | |
| 485 | |
| 486 | |
| 487 | |
| 488 | |
| 489 | |
| 490 | |
| 491 | |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 |