edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBc327308Tahinli25 days ago1014 commits
| 1 | #!/usr/bin/env bash |
| 2 | # Regenerates the gitignored test fixtures under assets/. |
| 3 | # Needs the ffmpeg CLI (dev tool only — the app itself never uses ffmpeg). |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | # A/V fixture: video + stereo AAC. Left channel 440 Hz, right 880 Hz, so |
| 12 | # channel mapping mistakes are audible; 1 Hz volume pulse makes drift visible. |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | # Second A/V fixture for multi-file import: same properties as test_av.mp4 |
| 20 | # (1280x720@30 baseline, AAC-LC 44.1k stereo) but plainly different content — |
| 21 | # testsrc pattern, 4 s, an octave up (660/1320 Hz) with the same 1 Hz pulse. |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | # Multi-audio fixture: one video and three audio streams, so stream selection |
| 29 | # has something to select. Stream 0 is AAC 44.1k stereo (440 Hz left, 880 Hz |
| 30 | # right), stream 1 is AAC 22.05k mono 220 Hz tagged French — different rate, |
| 31 | # layout and content, so a test can tell which stream it was handed — and |
| 32 | # stream 2 is AC-3, the codec we cannot decode and must still list. |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | # Unsupported-audio fixture: an AC-3 track, which we cannot decode at all. The |
| 46 | # file plays as picture with silence, and the point is that it says so. |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | # The shape a BluRay remux has: 48 kHz 5.1 AC-3, which the decoder downmixes to |
| 52 | # stereo for the timeline. The mono fixture above is the other end of the same |
| 53 | # path — no downmix at all — and both have to work. |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | # Multi-language fixture: the shape real media has — one video and two AAC |
| 59 | # streams that *agree* on rate and layout (44.1k stereo) and differ only in |
| 60 | # language and content, 440/880 Hz undefined and 220/330 Hz French. One |
| 61 | # timeline means one set of audio parameters, so this is the file where the |
| 62 | # second stream can actually be put on the timeline; test_multiaudio.mp4 is the |
| 63 | # file where it cannot, and both cases have to be shown. |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | # VP9 fixture: the same A/V shape as test_av.mp4 (1280x720@30, AAC-LC 44.1k |
| 76 | # stereo) with a VP9 picture, so what the tests measure is the codec and |
| 77 | # nothing else. 2 s, because VP9 only ever decodes on the hardware path. |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | # The same VP9 stream in Matroska, which is where a yt-dlp download and every |
| 85 | # other VP9 file in the wild actually arrives: `V_VP9` used to fall through the |
| 86 | # mkv track dispatch and be refused by name while the mp4 twin above decoded. |
| 87 | # Opus audio because that is what a .webm carries -- the sound decodes here now |
| 88 | # (`ec-opus`), and this is the webm cell of the Opus row in `capability_matrix`. |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | # ...and profile 2, 10-bit, which no container states: an mkv `TrackEntry` |
| 94 | # carries no configuration record for VP9 at all and the `vpcC` in an mp4 is |
| 95 | # optional, so the depth is read off the keyframe's uncompressed header |
| 96 | # (`demux::vp9_bit_depth`) -- the difference between a P010 surface pool and a |
| 97 | # picture of garbage. |
| 98 | |
| 99 | |
| 100 | |
| 101 | # VP8 fixture pair, the twins of the VP9 ones. ffmpeg's mov muxer carries no |
| 102 | # VP8 tag for mp4 at all (and its VP9 path re-parses the frames it is handed, |
| 103 | # dropping them), so the mp4 half is assembled by hand: the picture is encoded |
| 104 | # to an IVF, the AAC sound to an mp4 of its own, and the video track is |
| 105 | # spliced in with the `vp08` sample entry written out byte for byte -- the |
| 106 | # very entry `demux::sample_entry` reads by hand, which is what this fixture |
| 107 | # exists to exercise. `-enc_time_base 1/30` keeps the IVF timestamps exact, |
| 108 | # which is what the mp4 stts and the 30 fps the tests assert come from. |
| 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 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 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 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | # ...and the Matroska twin, the recipe of test_vp9.webm with libvpx rather |
| 212 | # than libvpx-vp9 for the picture and the same Opus sound a `.webm` carries. |
| 213 | # The engine reads `V_VP8` since the demux dispatch learned it; the decode |
| 214 | # half is the plugin's (there is no software VP8 decoder here), so both files |
| 215 | # are container and refusal fixtures. |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | # One Matroska file per audio codec the refusal string in `audio.rs` claims is |
| 221 | # decodable, as five tracks of one file: FLAC, MP3, Vorbis, ALAC and PCM. The |
| 222 | # string said "AAC and AC-3 only" long after every one of these decoded, which is |
| 223 | # the shape of refusal this suite exists to stop (`tests/capability_matrix.rs`). |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | # ...and the codec that really is refused, so the other half of the refusal is |
| 231 | # testable too: DTS, which no decoder in this tree has (symphonia has none at any |
| 232 | # version and there is no pure-Rust one to reach for, unlike AC-3 and Opus). The |
| 233 | # notice must name *this* track and go on naming what would have worked. |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | # Two video tracks in one mp4, at different sizes so a test can tell which one |
| 239 | # the demuxer picked. `Mp4Reader::tracks()` is a HashMap and iterating it made |
| 240 | # "the video track" a different one from one run to the next; the pick comes out |
| 241 | # of `moov.traks` (file order) and this is what holds it there. |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | # HEVC fixture: the same A/V shape again, so the tests measure the codec and |
| 247 | # nothing else. 8-bit Main profile, because the plugin's NV12 read-back cannot |
| 248 | # carry Main 10. |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | # The same HEVC stream tagged hvc1, which is what Apple and ffmpeg's mov muxer |
| 256 | # write in practice: mp4 0.14 recognises only a hev1 sample entry, so this one |
| 257 | # is found by demux.rs reading the stsd fourcc itself (`tests/hevc_hvc1.rs`). |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | # AV1 fixture, and the only Matroska one: `mp4 0.14` has no `av01` sample entry |
| 265 | # at all, so AV1 is read out of an mkv (`demux::MkvDemuxer`). Same A/V shape as |
| 266 | # the others so the tests measure the codec and nothing else -- but `-g 30` is |
| 267 | # not a preference: it puts a second keyframe at frame 30, which is what the |
| 268 | # sync index and the seek test are checked against. 8-bit Main profile here; the |
| 269 | # 10-bit twin is below. Its AAC track is deliberate too: it is the AAC a Matroska |
| 270 | # file's sound is read out of through symphonia, beside the AC-3 fixtures further |
| 271 | # down that no symphonia version decodes. |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | # ...and an AV1 file that asks for film grain, which no other fixture here does. |
| 279 | # A frame with `apply_grain` set is *displayed* from a second surface the driver |
| 280 | # synthesizes the grain into, and a decoder that hands it none is refused the |
| 281 | # picture outright (radeonsi: VA_STATUS_ERROR_INVALID_SURFACE out of |
| 282 | # `vaEndPicture`) -- which is how AV1 decode died at frame 49 of a real film |
| 283 | # while every fixture above sailed through. Three seconds rather than two so the |
| 284 | # surface pool wraps several times, `noise` on the source because SVT-AV1 reads |
| 285 | # the grain parameters it signals *off the source* (a clean testsrc2 yields grain |
| 286 | # with no amplitude at all, measured), and `film-grain-denoise=1` so the coded |
| 287 | # picture is the smooth one and the grain is really the decoder's own work. |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | # ...and the same file 10-bit, which is what an `av1C` with `high_bitdepth` set |
| 296 | # reads as and what the P010 surface pool is picked by -- the AV1 seat of the |
| 297 | # pair test_hevc.mkv/test_hevc10.mkv already make for HEVC. libaom rather than |
| 298 | # SVT-AV1 because it is the encoder that writes a 10-bit `av1C` here. |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | # The AV1 chroma and depth matrix, 64x64 and 3 frames each, in both containers. |
| 306 | # 4:4:4, 4:2:2 and 12-bit are refused at open by name; the two 4:2:0 files (8 and |
| 307 | # 10-bit) are the ones that open and decode. `test_av1_gray` is monochrome. |
| 308 | for; do |
| 309 | pix=; tag= |
| 310 | for; do |
| 311 | |
| 312 | |
| 313 | |
| 314 | done |
| 315 | done |
| 316 | # H.264 in Matroska: the same stream the mp4 fixtures carry, in the container |
| 317 | # that used to refuse it. Baseline profile so `rusty_h264` reads it with nothing |
| 318 | # installed, `-g 30` for the second keyframe the sync index is checked against, |
| 319 | # and the AAC track for the sound an mkv's audio path reads back. |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | # Subtitles in Matroska: the two text codecs a film carries, muxed out of the |
| 327 | # hand-written files the tests also parse standalone |
| 328 | # (`crates/engine/tests/data/`), so the embedded cues and the external ones can |
| 329 | # be compared to each other and both to the source. Track 2 is S_TEXT/UTF8 and |
| 330 | # track 3 is S_TEXT/ASS -- the same three cues, one of them with markup, which |
| 331 | # is what makes "the markup is resolved, not carried" measurable. |
| 332 | # |
| 333 | # No bitmap track here: ffmpeg cannot encode text subtitles into pictures, so |
| 334 | # the PGS refusal is checked against a Matroska file the test writes itself |
| 335 | # (`crates/engine/tests/subtitles.rs`). |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | # The same two tracks with no picture and no sound at all: `.mks`, the Matroska |
| 345 | # extension that is the subtitles alone (what a subtitle release ships beside |
| 346 | # the film). Refused by name until the container gate learned every Matroska |
| 347 | # extension rather than the two that carry a film -- the very reader that walks |
| 348 | # a `.mkv` walks this. |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | # ...and the same file stating its languages the way a modern muxer does: in |
| 355 | # `LanguageBCP47` (0x22B59D) and *not* in the legacy `Language` (0x22B59C), |
| 356 | # which is the shape of every English track of two real Blu-ray-sourced films. |
| 357 | # ffmpeg writes only the legacy element (8.1.2 does not read |
| 358 | # the BCP-47 one either), so the element is swapped in place afterwards: the |
| 359 | # 4-byte id, then the length as a two-byte VINT (`40 02`, a legal non-minimal |
| 360 | # encoding) so the tag is two bytes and the element stays the eight bytes it |
| 361 | # was -- every enclosing size in the file survives untouched. |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | # HEVC in Matroska: the shape a film off a disc arrives in. Same A/V shape as |
| 372 | # test_hevc.mp4 so the tests measure the container and nothing else, `-g 30` for |
| 373 | # the same reason test_av1.mkv has it (a second keyframe to seek to), and the |
| 374 | # AAC track is read out of the mkv now rather than named as unsupported. |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | # ...and the same file in the shape the ask came from: HEVC **Main 10** with a |
| 382 | # 5.1 AAC track, which is a 4K BluRay remux in miniature. The picture decodes |
| 383 | # through a P010 surface pool and the sound is folded to stereo, so both halves |
| 384 | # of that file have a fixture. One tone per channel -- 440 FL, 880 FR, 220 FC, |
| 385 | # 60 LFE, 1320 BL, 1760 BR as written, whatever the encoder's own element order |
| 386 | # does with them -- so a test can say which channel reached which output. |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | # Matroska sound: the two Dolby codecs that arrive in one and are read straight |
| 398 | # out of its blocks (`demux::MkvAudio`). Stereo AC-3 for the plain syntax and |
| 399 | # **5.1 E-AC-3** for Annex E -- the shape a remux has, and the one that must |
| 400 | # come down to stereo through the same A/52 7.8 downmix the mp4 path uses. |
| 401 | # 48 kHz both, which is the only rate E-AC-3 is written at in practice. Small |
| 402 | # H.264 picture on purpose: these two are about the sound, and the software |
| 403 | # decoder reads that one, so an audio test needs no VA-API plugin to open a |
| 404 | # session on them. |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | # Dual audio in Matroska: the shape an anime remux has -- one picture and two |
| 416 | # AAC tracks that differ in language and content and *agree* on rate and layout |
| 417 | # (44.1k stereo), so either one can go on the same timeline. Stream 0 is |
| 418 | # 440/880 Hz English, stream 1 is 220/330 Hz French; the tones are what a test |
| 419 | # tells the two apart by, and getting the mapping wrong plays the other |
| 420 | # language. test_multilang.mp4 is this file's mp4 twin. |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | # Colour-tag fixtures. The picture is irrelevant here -- what is measured is |
| 434 | # what the file *says* its numbers mean (`engine::colorspace`), so these are |
| 435 | # one-second clips with nothing in them. |
| 436 | # |
| 437 | # First pair: SMPTE 170M (BT.601) tagged in the container, at 720 lines, where |
| 438 | # the resolution heuristic would have said BT.709. That is the point: it is the |
| 439 | # fixture that shows the container tags being read and outranking the guess. |
| 440 | # Both containers, because the `colr` box and the Matroska `Colour` element are |
| 441 | # parsed by different code. |
| 442 | for; do |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | done |
| 448 | # ...and the tier below it: BT.709 written into the *bitstream* by the encoder |
| 449 | # and nowhere else. Passing the codes through `-x264-params`/`-x265-params`/ |
| 450 | # `-svtav1-params` rather than through ffmpeg's stream tags leaves the muxer |
| 451 | # with nothing to write, so these files have no `colr` box at all -- checked by |
| 452 | # the test. 480 lines, so the heuristic would say BT.601 and a pass means the |
| 453 | # VUI (or AV1 `color_config`) was really read. The HEVC one asks for |
| 454 | # `scaling-lists=default` on purpose: a set of scaling lists sits between the |
| 455 | # SPS header and its VUI, and a walk that counts them wrongly reads the colour |
| 456 | # out of the middle of a coefficient. (x264 writes its quant matrices into the |
| 457 | # PPS instead, so the H.264 side of that is a synthetic SPS in the unit tests.) |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | # The HDR fixture, and the one place in this set where the *picture* is the |
| 471 | # point: four flat patches written straight into the planes by `geq`, so a test |
| 472 | # can name the code it feeds the tone map (`engine::tonemap`) and the code it |
| 473 | # expects back. Top left is BT.2408 diffuse white -- 203 cd/m^2 is PQ signal |
| 474 | # 0.584, limited-range code 144 -- top right the 1000 cd/m^2 the grade is |
| 475 | # mastered against (code 181), and the bottom half a saturated BT.2020 red, |
| 476 | # which is what a grey-washed render loses. H.264 rather than HEVC so the |
| 477 | # software decoder can read it on a machine with no VA-API plugin: the tone map |
| 478 | # is fed by the tags, not by the codec. `-qp 1` on flat patches is exact to the |
| 479 | # code, so the numbers a test names are the numbers that arrive; the tags go on |
| 480 | # through `setparams` rather than through the encoder's own `-colorspace`, |
| 481 | # because that one makes ffmpeg *convert* into BT.2020 and the patches would no |
| 482 | # longer be the codes written above. |
| 483 | |
| 484 | |
| 485 | |
| 486 | # The HDR *metadata* fixtures: the same grade written three ways, so the three |
| 487 | # places a film's real peak brightness can live each have a file with known |
| 488 | # numbers in it. MaxCLL 1000, MaxFALL 400, mastering display 1000 nits down to |
| 489 | # 0.005 (which is what x265's `L(10000000,50)` means: ten-thousandths of a nit). |
| 490 | # |
| 491 | # Two passes, and the second one is not optional: `-x265-params master-display` |
| 492 | # only writes the SEI messages *inside the bitstream*, and ffmpeg's muxers write |
| 493 | # a container's own MaxCLL/`mdcv` off stream side data, which exists only once a |
| 494 | # decode has extracted those SEIs. Remuxing with `-c copy` does not do it -- |
| 495 | # verified, the `Colour` element comes back out with the code points and nothing |
| 496 | # else. So: encode HEVC with the SEIs, then transcode into each container, which |
| 497 | # is also what leaves test_hdr_sei.mkv carrying the SEI tier *alone* (H.264 |
| 498 | # writes no such SEI, so the transcoded pair carry the container tier alone). |
| 499 | |
| 500 | |
| 501 | |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | |
| 507 | # ...and one whose declared peak is a number nothing assumes: the three above |
| 508 | # say 1000, which is exactly what a file that declared *nothing* is assumed at, |
| 509 | # so no picture made from them can show that the metadata was read. This one is |
| 510 | # mastered at 4000 (`L(40000000,50)`, MaxCLL 4000) over the same four patches |
| 511 | # `test_pq.mp4` carries -- ten-bit codes here, four times the eight-bit ones -- |
| 512 | # so a tone map told 4000 lands them visibly elsewhere than one told 1000. |
| 513 | # |
| 514 | # Same two passes for the same reason, and the H.264 second one is what makes it |
| 515 | # software-decodable: the render tests that read it must not need a VA-API |
| 516 | # plugin. `-qp 1` on flat patches so the codes arrive as written (measured: 144, |
| 517 | # 181 and 100 come back exactly). |
| 518 | bright_sei="" |
| 519 | |
| 520 | |
| 521 | |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | # Sync fixture: one flash and one beep, at the same instant. Black picture with |
| 527 | # a white frame from t=1.0 to t=1.1, silence with a 1 kHz tone over exactly that |
| 528 | # stretch — so a test can find each of them and say how far apart they came out. |
| 529 | # What it is for is *speed*: a re-timed clip that drifts puts the beep somewhere |
| 530 | # the flash is not, and nothing else in the fixture set has a mark to measure |
| 531 | # that against. Same 30 fps / 44.1k stereo shape as test_av.mp4, so it can share |
| 532 | # a timeline with the rest. |
| 533 | # The beep is silence-then-tone-then-silence rather than a gated tone: lavfi's |
| 534 | # `sine` comes out at an eighth of full scale, and a mark a test looks for has |
| 535 | # to be plainly louder than anything around it. |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | # Mismatch fixture: different resolution and no audio track at all, so import |
| 544 | # has something concrete to refuse. |
| 545 | |
| 546 | |
| 547 | # Frame-rate fixture: test_av.mp4 in every respect a timeline is held to -- same |
| 548 | # codec, same profile, same 44.1k stereo AAC -- except that it runs at 25 fps, |
| 549 | # so a timeline of 30 fps clips has one at another rate to read through `Rate`. |
| 550 | |
| 551 | |
| 552 | |
| 553 | |
| 554 | |
| 555 | |
| 556 | # ...and the same again at 23.976 fps (24000/1001), the rate whose ratio to a |
| 557 | # 30 fps timeline does not terminate: what the frame mapping's rounding is |
| 558 | # actually tested against. |
| 559 | |
| 560 | |
| 561 | |
| 562 | |
| 563 | |
| 564 | |
| 565 | # Standalone audio fixtures: the same 440/880 Hz tone with the 1 Hz pulse the |
| 566 | # A/V fixture carries, at test_av.mp4's own 44.1k stereo -- so an imported song |
| 567 | # can share a timeline with the video clips and the peaks tests can reuse the |
| 568 | # dip pattern. One per container we claim to read. |
| 569 | tone="[0:a][1:a]join=inputs=2:channel_layout=stereo,volume='0.5+0.5*sin(2*PI*t)':eval=frame[a]" |
| 570 | for; do |
| 571 | case in |
| 572 | mp3) codec=(-c:a libmp3lame -b:a 128k) ;; |
| 573 | wav) codec=(-c:a pcm_s16le) ;; |
| 574 | flac) codec=(-c:a flac) ;; |
| 575 | ogg) codec=(-c:a libvorbis) ;; |
| 576 | # ALAC in mp4, and raw AAC in ADTS -- the two the mp4/AAC packet-copy |
| 577 | # path cannot claim: one is not AAC, the other is not in an mp4. |
| 578 | m4a) codec=(-c:a alac) ;; |
| 579 | aac) codec=(-c:a aac -b:a 128k -f adts) ;; |
| 580 | esac |
| 581 | |
| 582 | |
| 583 | |
| 584 | |
| 585 | done |
| 586 | # ...and the same tone in the MPEG audio spellings an encoder names after the |
| 587 | # standard rather than the codec (`.mpeg`/`.mpg`), carrying a JPEG cover in its |
| 588 | # ID3v2 tag -- the shape a voice note or a tagged download has. `-f mp3` is what |
| 589 | # makes it an MPEG *audio* stream: left to the extension, ffmpeg would write an |
| 590 | # MPEG program stream instead, which is a different file that this engine has no |
| 591 | # demuxer for. `test_tone_cover.jpg` is the cover it muxes in; a reader that |
| 592 | # walked the file as an mp4 saw only `InvalidData("file contains a box with a |
| 593 | # larger size than it")` before `is_audio` admitted the spelling. |
| 594 | |
| 595 | |
| 596 | |
| 597 | |
| 598 | |
| 599 | |
| 600 | |
| 601 | |
| 602 | |
| 603 | |
| 604 | |
| 605 | |
| 606 | # The two Opus fixtures, which cannot join the loop above: Opus decodes at 48 kHz |
| 607 | # and nothing else, so these are the 48k twins of the tone rather than 44.1k ones. |
| 608 | # First the standalone `.opus`, an Ogg file `crate::is_audio` now admits. |
| 609 | |
| 610 | |
| 611 | |
| 612 | |
| 613 | # ...and 5.1 Opus in an `.mka`, which is the shape a film soundtrack has: four |
| 614 | # Opus streams with the Vorbis channel mapping, folded to stereo on the way to |
| 615 | # the timeline. The tone sits in **FL and BR only**, both silent in between, so |
| 616 | # the fold's channel order is checkable without an FFT: done right, 440 Hz comes |
| 617 | # out left and 880 Hz right; read in the decoder's own Vorbis order (FL, FC, FR, |
| 618 | # BL, BR, LFE) instead of the film order the fold wants (FL, FR, FC, LFE, BL, BR), |
| 619 | # BR lands on the left with FL and the right channel comes out silent. |
| 620 | # `join` needs every output channel mapped and assigns them by *name*, not by |
| 621 | # input order: without the explicit `map=` the two tones land in FC and BR |
| 622 | # instead, and the fixture stops testing what its comment says. |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | # ...and **7.1 Opus**, which is a large film's soundtrack in miniature: five |
| 629 | # Opus streams, three coupled, and the widest layout the fold has a table for. |
| 630 | # One frequency per channel, four of the eight carrying anything, so the whole |
| 631 | # downmix is checkable by picking those four out of the folded pair |
| 632 | # (`tests/audio_multi.rs`): 440 in FL is left only, 880 in FC is both sides at |
| 633 | # -3 dB, 1320 in the LFE must be *gone*, and 1760 in SR is right only. Get the |
| 634 | # Vorbis-to-film permutation wrong at this width and every one of those moves. |
| 635 | |
| 636 | |
| 637 | |
| 638 | |
| 639 | |
| 640 | |
| 641 | |
| 642 | # ...and standalone AC-3 in an `.mka`: the same syntax `test_ac3.mkv` carries, |
| 643 | # with no picture at all, which is DEBT #64's shape -- an AC-3 soundtrack |
| 644 | # ripped to its own Matroska file rather than left beside a video track. Read |
| 645 | # through the same [`MkvAc3Track`] door `.mkv` uses (`crate::demux::is_matroska` |
| 646 | # admits `.mka`), not symphonia, which has no AC-3 decoder. |
| 647 | |
| 648 | |
| 649 | # Still-image fixture: the source with a picture and no timeline in it. Two |
| 650 | # bands rather than one colour, so a test can tell top from bottom (a flipped |
| 651 | # decode) and red from blue (a swapped channel order); 640x360, which is 16:9 |
| 652 | # like the video fixtures, so a Fit onto 1280x720 covers the canvas with no |
| 653 | # bars and every pixel of the exported frame is the image. |
| 654 | |
| 655 | |
| 656 | |
| 657 | |
| 658 | # The refusal fixture: same tone at 48k, which one output device cannot mix |
| 659 | # with a 44.1k timeline. |
| 660 | |
| 661 | |
| 662 | |
| 663 | |
| 664 | # A file long enough to have a *cue table*, whose audio says where in it you |
| 665 | # are: a 30 s chirp from 200 Hz rising 160 Hz a second, so the frequency of any |
| 666 | # quarter second of it names the second it came from. That is what makes a seek |
| 667 | # landing measurable without a reference decode (`tests/audio_seek.rs`), and the |
| 668 | # length is the point -- symphonia's Matroska seek goes through the cues, and on |
| 669 | # a two-second fixture there are none to go wrong. Opus in an mkv because that |
| 670 | # is the film the desync was measured on, keyframes every five seconds because |
| 671 | # that is what writes a cue point per cluster. |
| 672 | |
| 673 | |
| 674 | |
| 675 | |
| 676 | # The lopsided container: 2 s of picture under 60 s of sound, which is what a |
| 677 | # still with a song over it or a botched remux looks like from the outside. The |
| 678 | # point is the *denominator* -- a file 60 s long whose video track is 2 s long |
| 679 | # reports thirty times its real byte rate if the bitrate row divides by the |
| 680 | # picture rather than by the file (`crates/engine/tests/bitrate.rs`). Nothing |
| 681 | # else here has this shape, which is exactly why it is here. |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | # A song wearing a film's extension: AAC audio, no video track, muxed into an |
| 687 | # `.mp4` -- the shape a phone's voice memo or a stripped remux takes, and the |
| 688 | # one `crate::is_audio` cannot see (`tests/audio_files.rs`). |
| 689 | |
| 690 | |
| 691 | |
| 692 | # A QuickTime-brand `.mov` (what Resolve, Final Cut and `ffmpeg -f mov` write): |
| 693 | # its AAC sample entry is a version-1 SoundDescription -- 16 bytes of |
| 694 | # compression fields after the sample rate, then the `esds` inside a `wave` |
| 695 | # wrapper -- rather than the bare ISO `mp4a`+`esds` an `.mp4` carries. Stock |
| 696 | # mp4 0.14 walked past both and called the track esds-less, so a `.mov` opened |
| 697 | # with no sound at all (`tests/audio_decode.rs`). 440 Hz left / 880 Hz right |
| 698 | # at 44.1k, 2 s, so the same channel-identity check applies. |
| 699 | |
| 700 | |
| 701 | |
| 702 | |
| 703 | |
| 704 | |
| 705 | |
| 706 | # The display matrix: `test_rotation*.mp4` are one 320x180 source -- four |
| 707 | # coloured quadrants, so a quarter turn is readable from a single sampled pixel |
| 708 | # per corner and a wrong direction cannot pass -- written back out with a |
| 709 | # rotation asked for. This is how a phone records a portrait video: the pixels |
| 710 | # stay landscape and the container says which way to turn them. |
| 711 | # |
| 712 | # The trap this recipe exists to avoid: `-metadata:s:v rotate=90`, the form |
| 713 | # every search result gives, writes **no display matrix at all** with this |
| 714 | # machine's ffmpeg (`ffprobe -show_streams` comes back with an empty side-data |
| 715 | # block, so a "rotated" fixture is really an unrotated one and the test passes |
| 716 | # against nothing). `-display_rotation` is a *muxer* option here and, being an |
| 717 | # input option, goes **before** the `-i` it applies to. |
| 718 | # |
| 719 | # The four quadrants are red, green, blue and yellow: |
| 720 | # |
| 721 | # coded -display_rotation 90 -display_rotation 180 |
| 722 | # red green green yellow yellow blue |
| 723 | # blue yellow red blue green red |
| 724 | # |
| 725 | # which is exactly ffmpeg's own autorotation of each file -- measured |
| 726 | # (`ffmpeg -i f.mp4 -f rawvideo -pix_fmt rgb24 -`) rather than derived, because |
| 727 | # which way a display matrix turns a picture is the one thing a reader has to be |
| 728 | # told rather than guess. `tests/rotation.rs` asserts those layouts. |
| 729 | # |
| 730 | # `-display_rotation 45` is the other half: a matrix that is a rotation and not |
| 731 | # a *quarter* turn, which this engine refuses by name (`demux::UnsupportedRotation`) |
| 732 | # instead of showing it sideways. |
| 733 | |
| 734 | |
| 735 | |
| 736 | |
| 737 | |
| 738 | |
| 739 | |
| 740 | for; do |
| 741 | |
| 742 | |
| 743 | done |
| 744 | # ...and the very same turn asked for inside a Matroska, from the very same |
| 745 | # source: one set of expected layouts then covers both containers |
| 746 | # (`tests/rotation.rs`), which is the point -- a roll read the wrong way round is |
| 747 | # a file that plays on its side in exactly one of the two. |
| 748 | # |
| 749 | # What the muxer actually writes, byte-verified by walking the header rather than |
| 750 | # taken off a table: a `Projection` master (`0x7670`) holding one |
| 751 | # `ProjectionPoseRoll` (`0x7675`), an 8-byte big-endian float -- `+90.0`, `+180.0` |
| 752 | # and *`-90.0`* for `-display_rotation 90/180/270` -- and no `ProjectionType` |
| 753 | # element at all, which is the spec's default of 0 (rectangular). `ffprobe` |
| 754 | # reports the same display matrix as the mp4 twin, which is what makes the |
| 755 | # layouts above ffmpeg's own autorotation of either file. The roll counts |
| 756 | # counter-clockwise where the matrix counts clockwise turns, which is why the |
| 757 | # engine negates it. |
| 758 | for; do |
| 759 | |
| 760 | |
| 761 | done |
| 762 | |
| 763 | |
| 764 | # The one fixture where the coded and the displayed height disagree about what the |
| 765 | # material is: `test_rotation90tall` is 1280x640 as stored and 640x1280 as shown, |
| 766 | # and neither container tags its colour (the mkv's `Colour` element carries only |
| 767 | # chroma siting, the mp4 has no `colr` box), so the 720-line rule an untagged |
| 768 | # stream's matrix is guessed from reads a different side of itself depending on |
| 769 | # which height a door feeds it. |
| 770 | |
| 771 | |
| 772 | |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | for; do |
| 778 | |
| 779 | |
| 780 | done |
| 781 | |
| 782 | |
| 783 | # The sample aspect ratio: `test_anamorphic.*` are one 1440x1080 source whose |
| 784 | # pixels are drawn 4/3 wide -- the classic anamorphic 16:9 frame stored on a |
| 785 | # 4:3 raster (`-vf setsar=4/3`), so the displayed picture is 1920x1080 and the |
| 786 | # stored one never is. This is how a DVD rip and a Blu-ray remux say "widen |
| 787 | # me": the pixels stay where the encoder put them and the container carries |
| 788 | # the ratio. |
| 789 | # |
| 790 | # What each muxer actually writes, byte-verified by walking the output rather |
| 791 | # than taken off a table: the Matroska muxer writes `DisplayWidth` 16, |
| 792 | # `DisplayHeight` 9 and `DisplayUnit` 3 -- a *display aspect ratio* pair, not |
| 793 | # a sample aspect ratio, and 4:3 SAR over 1440x1080 is exactly 16:9 DAR -- and |
| 794 | # a square-pixel file gets no `Display*` element at all. The mp4 muxer writes |
| 795 | # a `pasp` box (hSpacing 4, vSpacing 3) inside the `avc1` sample entry, and |
| 796 | # 1/1 for a square one. `tests/anamorphic.rs` reads both spellings through the |
| 797 | # engine and asserts the same displayed shape off either. |
| 798 | |
| 799 | |
| 800 | |
| 801 | |
| 802 | |
| 803 | |
| 804 | |
| 805 | # ...and the anamorphic HEVC Matroska twin, for the copy path: `tests/`'s |
| 806 | # copy door only copies HEVC or AV1 Matroska (`tests/video_copy.rs`), so an |
| 807 | # anamorphic *copy* needs an anamorphic source in a codec that door takes. |
| 808 | # Same source as above through libx265; the SAR rides the stream. |
| 809 | |
| 810 | |
| 811 | |
| 812 | |
| 813 | |
| 814 | # HEVC on the software seat (`ec-h265`, `tests/hevc_sw.rs`, `decode/hevc.rs`): |
| 815 | # libx265 at 8-bit and Main 10, in mp4 and Matroska, at 352x288 for one second, |
| 816 | # B-frames and an IDR every 15 frames. The odd size is 350x286 (a conformance |
| 817 | # window that crops the coded 352x288). The CRA file is open-GOP, so its GOPs |
| 818 | # start on CRAs with RASL pictures. The 4:2:2 file is refused by name at open. |
| 819 | |
| 820 | |
| 821 | |
| 822 | |
| 823 | |
| 824 | |
| 825 | |
| 826 | |
| 827 | |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 | |
| 833 | |
| 834 | |
| 835 | |
| 836 | |
| 837 | |
| 838 | |
| 839 | |
| 840 | # The 10-bit RExt 4:2:2 HEVC the probe refuses by name at open (`hvcC` chroma 2, depth 10). |
| 841 | |
| 842 | |
| 843 | |
| 844 | # The 1080p 8-bit clip the software seat's per-frame timing is read off. |
| 845 | |
| 846 | |
| 847 | |
| 848 | |
| 849 | |
| 850 |