edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBfbc29d1Tahinli2 months ago972 commits
| 1 | //! Export: the edit list rendered back out as one mp4 (H.264, AV1 or HEVC) or |
| 2 | //! one Matroska file (AV1 or HEVC) — or, picture left behind, as one WAV, FLAC, |
| 3 | //! MP3 or Ogg Vorbis of the timeline's audio alone. |
| 4 | //! |
| 5 | //! The HEVC pair is **intra-only**, and says so wherever it is offered: every |
| 6 | //! frame is a self-contained IDR from `ec-h265`, the project's own pure-Rust |
| 7 | //! HEVC encoder -- intra-only by construction, the same file the row promises. |
| 8 | //! That makes it an intraframe master in the family of ProRes and DNxHD — large |
| 9 | //! files, every frame a cut point — and not a delivery codec. |
| 10 | //! |
| 11 | //! Picture and sound are both **copied wherever a copy says exactly what the |
| 12 | //! timeline says** — a copy is exact, free and never a generation of loss. For |
| 13 | //! the sound that is packet for packet ([`copy_audio`]); for the picture it is |
| 14 | //! block for block out of a Matroska source into a Matroska file ([`CopyPlan`]), |
| 15 | //! which is what makes a cut in a two-hour film cost the reading of it rather |
| 16 | //! than the re-encoding of it. The picture's copy is all-or-nothing per export, |
| 17 | //! because a copied span and an encoded one cannot share one track: what it |
| 18 | //! needs of a cut is that it lands on a sync point, and everything else — a |
| 19 | //! grade, a speed, a gap, a source of another size or codec, an mp4 — goes |
| 20 | //! through the encoder exactly as it always did. Where the *sound* cannot be |
| 21 | //! copied — a second audio lane to mix in, a speeded clip, an |
| 22 | //! equalized one, a source that is not AAC inside an mp4's own sample table — |
| 23 | //! the sound is decoded, mixed and encoded again with `ec-aac` |
| 24 | //! ([`encode_audio`]). The audio-only formats have no such split: `hound` writes |
| 25 | //! PCM, `flacenc` encodes FLAC, `ec-mp3` encodes MP3 and `ec-vorbis` |
| 26 | //! encodes Vorbis, so those are always *decoded* out of the timeline. The worker owns everything: the caller gets an |
| 27 | //! [`ExportHandle`] and polls it from its render loop. |
| 28 | //! |
| 29 | //! **Every video format here carries the timeline's sound**, in whichever |
| 30 | //! container: the mp4 muxer writes an AAC track and so does the Matroska one. |
| 31 | //! Nothing is written picture-only and nothing is left silent without saying so |
| 32 | //! — the only sound that does not come out is sound this engine cannot decode at |
| 33 | //! all (Opus and AC-3 inside a Matroska file), and that is an error by name. |
| 34 | //! |
| 35 | //! A **speeded** clip splits along the same line, and for the same reason. The |
| 36 | //! picture is re-encoded, so the frame walk honours a rate: it takes the source |
| 37 | //! frame each timeline frame shows ([`crate::project::Speed::source_at`], the |
| 38 | //! very frame preview holds there) and encodes a held one again rather than |
| 39 | //! decoding it twice. A clip whose *file* was shot at another rate than the |
| 40 | //! timeline goes through the same walk with one more conversion on the end |
| 41 | //! ([`crate::project::Rate`]), so it is encoded at the speed it was shot at. |
| 42 | //! The sound is *copied* unless something forces a decode, and a packet carries |
| 43 | //! no rate — so a speeded lane is one of the things that forces one |
| 44 | //! ([`copy_audio`]) rather than being written out at 1.00x under a re-timed |
| 45 | //! picture. The audio-only formats are decoded and resampled, so they honour a |
| 46 | //! rate like the picture does. |
| 47 | //! |
| 48 | //! Nothing partial survives a failure: the worker writes to `<out>.part` and |
| 49 | //! renames it onto `out` only once the file is closed and complete, so the |
| 50 | //! output either does not exist or is finished — there is no window where a |
| 51 | //! half-written `.export.mp4` is sitting there looking playable. Cancel and |
| 52 | //! every error path delete the `.part`. A killed *process* leaves the `.part` |
| 53 | //! behind (only in-process cleanup is promised), which is an orphan a user can |
| 54 | //! delete rather than a file that plays for two seconds and stops. |
| 55 | |
| 56 | use File; |
| 57 | use ; |
| 58 | use ; |
| 59 | use ; |
| 60 | use ; |
| 61 | use ; |
| 62 | use thread; |
| 63 | |
| 64 | use VideoFrame; |
| 65 | use ; |
| 66 | use Decoder as _; |
| 67 | use ; |
| 68 | use ; |
| 69 | use ; |
| 70 | use |
| 71 | |
| 72 | ; |
| 73 | |
| 74 | use BitRepr; |
| 75 | use Verify; |
| 76 | // The trait the Ogg muxer's `write_header` / `write_packet` / `write_trailer` |
| 77 | // live on -- `oxideav_ogg::mux::open_concrete` hands back the concrete muxer |
| 78 | // (the only way to reach `set_page_target_bytes`), so the trait has to be here. |
| 79 | use Muxer as _; |
| 80 | |
| 81 | use crate; |
| 82 | use crate; |
| 83 | use crate; |
| 84 | use crate; |
| 85 | use crate |
| 86 | |
| 87 | ; |
| 88 | use crate; |
| 89 | use crate; |
| 90 | use crate; |
| 91 | use crate; |
| 92 | use crateTransformParams; |
| 93 | |
| 94 | /// Progress is reported in permille: an atomic integer the render loop can read |
| 95 | /// without a lock, fine enough for any progress bar. |
| 96 | pub const PROGRESS_SCALE: u32 = 1_000; |
| 97 | |
| 98 | /// The head of the bar the *sound* owns, before a picture is written at all. |
| 99 | /// The mix is decoded, encoded and measured before the muxer exists ([`run`] |
| 100 | /// says why), and on a feature film that is a minute or two in which a bar |
| 101 | /// pinned at zero is the only thing on screen -- which reads as an export that |
| 102 | /// has hung. Small, because the picture is still nearly all of the work. |
| 103 | pub const AUDIO_BAND: u32 = PROGRESS_SCALE / 20; |
| 104 | |
| 105 | /// Where the bar stands with `done` of `total` pictures written: the sound's |
| 106 | /// band is already behind it ([`AUDIO_BAND`]), so the picture fills what is |
| 107 | /// left rather than starting again from zero. |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | /// D2 rate control: bits per pixel per second, then a sane range. 720p30 lands |
| 121 | /// at 2.76 Mbps, which S1 measured the software encoder hitting within 1%. |
| 122 | const BITS_PER_PIXEL: f64 = 0.1; |
| 123 | /// The floor under a rate somebody *asked* for, and under the derived one: 100 |
| 124 | /// kbps, so a sub-Mbps budget -- a lo-fi delivery, a tiny picture, a |
| 125 | /// phone-rate master -- is a rate this export is written at. A megabit was the |
| 126 | /// old floor, and it silently rewrote every such ask. Nothing below this is |
| 127 | /// worth a container: the sound's own row starts at 128 kbps. |
| 128 | const MIN_BITRATE: u64 = 100_000; |
| 129 | const MAX_BITRATE: u64 = 20_000_000; |
| 130 | |
| 131 | /// The ceiling on a bitrate somebody *asked* for, which is a different question |
| 132 | /// from where the derived one stops: [`MAX_BITRATE`] is the top of the automatic |
| 133 | /// figure's sane range, and a rate a person typed is not that program's guess to |
| 134 | /// bound. Nothing in either encoder objects to it -- the VA-API seat takes a |
| 135 | /// `u64` and the software ones a `u32`/`i32`, all of which hold this with room |
| 136 | /// -- so the old shared ceiling was only ever the auto range wearing two hats. |
| 137 | const MAX_EXPLICIT_BITRATE: u64 = 50_000_000; |
| 138 | |
| 139 | /// The rates the sound may be coded at, smallest first -- what a front-end |
| 140 | /// offers and what [`ExportSettings::audio_kbps`] is clamped into. Every one of |
| 141 | /// them is a legal MPEG-1 Layer III value, so the MP3 path writes the figure it |
| 142 | /// was given rather than the nearest one `ec-mp3` snaps to. |
| 143 | pub const AUDIO_KBPS: = ; |
| 144 | |
| 145 | /// What the sound is coded at when nobody picked: the rate this project wrote |
| 146 | /// before the choice existed. 256 and not the encoders' own 128, because an |
| 147 | /// export is a master a person edits from again and this is a second lossy |
| 148 | /// generation over sources that may already have been one -- measured on the |
| 149 | /// suite's fixtures, an untouched clip re-encoded moves 0.15 dB here against |
| 150 | /// 0.46 dB at 128, and 32 KB/s beside a 2.76 Mbps picture is not a size anyone |
| 151 | /// is counting. |
| 152 | pub const DEFAULT_AUDIO_KBPS: u32 = 256; |
| 153 | |
| 154 | /// `rav1e`'s fastest preset. Anything slower is minutes per second of timeline |
| 155 | /// on a build with no assembly, which is what this one is. |
| 156 | const AV1_SPEED: u8 = 10; |
| 157 | |
| 158 | /// How many lane encoders the intra HEVC seat spreads frames across. Twelve |
| 159 | /// is where the 2026-08-11 bench stopped scaling on this box; more lanes |
| 160 | /// only holds more decoded frames in memory. The cores the lanes leave over |
| 161 | /// go to the wavefront inside each lane's encoder. |
| 162 | const HEVC_LANES: usize = 12; |
| 163 | /// Bits per pixel an intra HEVC encoder spends at QP 27: 0.607 at 720p and |
| 164 | /// 0.586 at 1080p on the old seat's bench, and `ec-h265` lands on the same |
| 165 | /// 0.6 anchor. What [`hevc_qp`] maps a bitrate row through. |
| 166 | const HEVC_BPP_AT_27: f64 = 0.6; |
| 167 | /// The band [`hevc_qp`] is clamped into, for the reason stated there. |
| 168 | const HEVC_QP_MIN: i32 = 22; |
| 169 | const HEVC_QP_MAX: i32 = 40; |
| 170 | |
| 171 | /// What an export writes. H.264-in-mp4, AV1 and HEVC -- each of the last two in |
| 172 | /// Matroska or in mp4, the user's pick of container -- are the *video* pairs |
| 173 | /// with both an encoder and a decoder under this project's no-install rule, and |
| 174 | /// pure-Rust encoder: `hound`, `flacenc`, `ec-mp3` and `ec-vorbis`. Opus |
| 175 | /// still has none as a *file* -- the Matroska seat is `ec-opus`, but a standalone |
| 176 | /// `.opus` row this project does not offer. |
| 177 | /// (AAC has one too -- `ec-aac`, which is what a re-encoded video track's |
| 178 | /// sound leaves through -- but AAC is a container's own audio, never a file of |
| 179 | /// its own here.) VP9 and VP8 are the |
| 180 | /// codecs that come in through the plugin and stop there, HEVC having |
| 181 | /// gained an encoder (an intra-only one, which the rows say). A front-end says |
| 182 | /// so rather than hiding the row. |
| 183 | /// |
| 184 | /// **Every video format carries sound.** Which way it carries it is the only |
| 185 | /// difference: copied packet for packet where a copy can say what the timeline |
| 186 | /// says, decoded and encoded again ([`encode_audio`]) where it cannot. |
| 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 | |
| 215 | |
| 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 | |
| 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 | |
| 285 | |
| 286 | /// Which encoder writes the picture, as a person picks it on a card. Three |
| 287 | /// discrete choices and not a switch, because "whatever is best" and "the GPU, |
| 288 | /// and say so if there is none" are different answers: a driver that encodes |
| 289 | /// badly wants [`Software`](Self::Software), and a person who *needs* the GPU |
| 290 | /// (a long delivery, a machine whose CPU is doing something else) wants to be |
| 291 | /// told when it is not there rather than to wait out a silent fallback. |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 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 | /// What the caller gets to decide about the output. The codec is not among it: |
| 329 | /// [`Format`] names a container *and* what goes in it, because every pair we |
| 330 | /// can write is a pair we can also read back. |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 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 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | /// The lowest H.264 level (Table A-1) whose frame size and macroblock rate |
| 410 | /// hold `width`x`height` at `fps_num/fps_den`, as the `level_idc` byte; 62 |
| 411 | /// past the table. One table for both seats: the software encoder writes it |
| 412 | /// into its SPS (its default is 3.0, which is out of spec above 720p30) and |
| 413 | /// the plugin hands it to the driver. |
| 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 | /// A running export. Poll [`is_finished`](ExportHandle::is_finished) once per |
| 478 | /// rendered frame and take the [`result`](ExportHandle::result) when it flips; |
| 479 | /// dropping the handle does *not* stop the worker, [`cancel`](ExportHandle::cancel) |
| 480 | /// does. |
| 481 | |
| 482 | |
| 483 | |
| 484 | |
| 485 | |
| 486 | |
| 487 | |
| 488 | |
| 489 | |
| 490 | |
| 491 | |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 501 | |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | |
| 507 | |
| 508 | |
| 509 | |
| 510 | |
| 511 | |
| 512 | |
| 513 | |
| 514 | |
| 515 | |
| 516 | |
| 517 | |
| 518 | |
| 519 | |
| 520 | |
| 521 | |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | /// Starts the worker. Failures are reported through the handle rather than |
| 527 | /// returned, so a caller has exactly one place to look. The files to read are |
| 528 | /// the project's own [`sources`](Project::sources) -- every clip names one -- |
| 529 | /// so nothing but the edit list decides what is decoded. |
| 530 | |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | |
| 552 | |
| 553 | |
| 554 | |
| 555 | |
| 556 | |
| 557 | |
| 558 | |
| 559 | |
| 560 | |
| 561 | |
| 562 | |
| 563 | |
| 564 | |
| 565 | |
| 566 | |
| 567 | |
| 568 | |
| 569 | |
| 570 | |
| 571 | |
| 572 | |
| 573 | |
| 574 | |
| 575 | |
| 576 | |
| 577 | |
| 578 | |
| 579 | |
| 580 | |
| 581 | |
| 582 | |
| 583 | |
| 584 | |
| 585 | |
| 586 | |
| 587 | |
| 588 | |
| 589 | |
| 590 | |
| 591 | |
| 592 | |
| 593 | |
| 594 | |
| 595 | |
| 596 | |
| 597 | |
| 598 | |
| 599 | |
| 600 | |
| 601 | |
| 602 | |
| 603 | |
| 604 | |
| 605 | |
| 606 | |
| 607 | |
| 608 | |
| 609 | |
| 610 | |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | |
| 616 | |
| 617 | |
| 618 | |
| 619 | |
| 620 | |
| 621 | |
| 622 | |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | |
| 637 | |
| 638 | |
| 639 | |
| 640 | |
| 641 | |
| 642 | |
| 643 | |
| 644 | |
| 645 | |
| 646 | |
| 647 | |
| 648 | |
| 649 | |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| 654 | |
| 655 | |
| 656 | |
| 657 | |
| 658 | |
| 659 | |
| 660 | |
| 661 | |
| 662 | |
| 663 | |
| 664 | |
| 665 | |
| 666 | |
| 667 | /// Whether any video lane holds anything at all -- what tells an audio-only |
| 668 | /// timeline from one that merely opens on a gap. Asked of the *lanes* rather |
| 669 | /// than of the sources, because a project may name a video file no clip plays |
| 670 | /// from any more. |
| 671 | |
| 672 | |
| 673 | |
| 674 | |
| 675 | |
| 676 | |
| 677 | |
| 678 | /// Whether any audio lane holds anything, [`has_picture`]'s pair: what tells a |
| 679 | /// timeline whose export will carry sound from one whose file has none. |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | |
| 687 | /// Whether any equalizer on the sound is doing something -- the one edit a |
| 688 | /// packet copy cannot carry, so an mp4 whose lane has one is decoded and |
| 689 | /// re-encoded ([`encode_audio`]) instead of copied. Asked of every audio lane: |
| 690 | /// the copy path has exactly one by the time it asks, and [`planned_audio`] is |
| 691 | /// asked before that is settled. |
| 692 | |
| 693 | |
| 694 | |
| 695 | |
| 696 | |
| 697 | |
| 698 | |
| 699 | /// Whether the *mix* is doing something -- a lane turned off unity, or a |
| 700 | /// limiter in circuit. [`equalized`]'s pair, and a copy cannot carry either of |
| 701 | /// them: both live where the lanes are summed |
| 702 | /// ([`AudioSession::open_mixed_streams_master`]), and a copied packet was never |
| 703 | /// summed at all. An mp4 whose timeline is mixed is decoded and re-encoded. |
| 704 | |
| 705 | |
| 706 | |
| 707 | |
| 708 | /// Whether any audio clip has a fade -- [`equalized`]'s pair again: a fade is |
| 709 | /// gain math on decoded samples ([`crate::project::Fade::apply`]), and a |
| 710 | /// packet copy carries neither an equalizer nor a fade. An mp4 whose timeline |
| 711 | /// has one is decoded and re-encoded so the fade actually reaches the file. |
| 712 | |
| 713 | |
| 714 | |
| 715 | |
| 716 | |
| 717 | |
| 718 | |
| 719 | /// The bitrate an export codes at: the caller's number clamped into what an |
| 720 | /// asked-for rate may be ([`MIN_BITRATE`]..[`MAX_EXPLICIT_BITRATE`]), the |
| 721 | /// derived one where there was none. Clamped rather than refused, for the |
| 722 | /// reason [`Enc::open`] states. |
| 723 | |
| 724 | |
| 725 | |
| 726 | |
| 727 | |
| 728 | |
| 729 | |
| 730 | /// The rate the sound codes at: the caller's pick clamped into the offered |
| 731 | /// range, [`DEFAULT_AUDIO_KBPS`] where there was none. Clamped and not refused, |
| 732 | /// for [`bitrate_of`]'s reason -- a number out of range is a caller's slip and |
| 733 | /// not a file worth failing. |
| 734 | |
| 735 | |
| 736 | |
| 737 | |
| 738 | |
| 739 | |
| 740 | /// The hardware seat for these settings, opened exactly as the export opens it |
| 741 | /// -- the same pins, the same dimensions a driver may refuse -- or `None` where |
| 742 | /// the software encoder takes the file. The single place that choice is made, |
| 743 | /// which is what lets [`planned_video`] *measure* it instead of promising it. |
| 744 | /// |
| 745 | /// `Err` is the one answer the software encoder does **not** take over from: |
| 746 | /// [`EncoderSeat::Hardware`] asked for the GPU by name and this machine has no |
| 747 | /// seat for the codec, so the export refuses in words rather than falling back |
| 748 | /// to an encoder nobody picked. Every caller is before a file exists |
| 749 | /// ([`Enc::open`] runs ahead of the muxer), which is what makes the refusal |
| 750 | /// free. |
| 751 | |
| 752 | |
| 753 | |
| 754 | |
| 755 | |
| 756 | |
| 757 | |
| 758 | |
| 759 | |
| 760 | |
| 761 | |
| 762 | |
| 763 | |
| 764 | |
| 765 | |
| 766 | |
| 767 | /// The plugin half of [`hw_seat`]: what the driver gives for this codec and |
| 768 | /// this picture, with no policy in it but the AV1 one. |
| 769 | |
| 770 | |
| 771 | |
| 772 | |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | |
| 778 | |
| 779 | |
| 780 | |
| 781 | |
| 782 | |
| 783 | |
| 784 | |
| 785 | |
| 786 | |
| 787 | |
| 788 | |
| 789 | |
| 790 | |
| 791 | |
| 792 | |
| 793 | |
| 794 | |
| 795 | |
| 796 | |
| 797 | |
| 798 | |
| 799 | |
| 800 | |
| 801 | |
| 802 | |
| 803 | |
| 804 | |
| 805 | |
| 806 | |
| 807 | |
| 808 | |
| 809 | |
| 810 | |
| 811 | |
| 812 | |
| 813 | |
| 814 | |
| 815 | |
| 816 | |
| 817 | |
| 818 | |
| 819 | |
| 820 | /// What a hardware encode is called wherever one is named -- the card's line |
| 821 | /// before the export and the progress line during it. |
| 822 | const HW_LABEL: &str = "HW encode (VA-API)"; |
| 823 | |
| 824 | /// ...and what a card says instead where [`EncoderSeat::Hardware`] was picked |
| 825 | /// and there is no seat: the export's own refusal in the width of a card row, |
| 826 | /// shown *before* the button is pressed rather than a minute into a file. |
| 827 | pub const NO_HW_SEAT: &str = "no HW seat here — pick Auto or Software"; |
| 828 | |
| 829 | /// How a front-end names a video seat: which of the two encoders has the file, |
| 830 | /// and which library that is. Not the codec -- a caller shows this beside the |
| 831 | /// format it picked, and `rav1e` names AV1 as `ec-h264` names H.264. One |
| 832 | /// place, so what a card says before an export and what its progress line says |
| 833 | /// during one cannot drift apart. |
| 834 | |
| 835 | |
| 836 | |
| 837 | |
| 838 | |
| 839 | |
| 840 | |
| 841 | |
| 842 | |
| 843 | /// Whether the *edit* has touched the samples a copy would carry out: the one |
| 844 | /// predicate both copy-or-encode decisions ask, with `lanes` the sound's own |
| 845 | /// list as the caller has it -- every audio lane for the question a card asks |
| 846 | /// before the button ([`forces_encode`]), and the single lane the segments have |
| 847 | /// already narrowed a copy to ([`copy_audio`]). |
| 848 | /// |
| 849 | /// One function and not two lists of the same conditions, which is what they |
| 850 | /// were: `faded` reached [`forces_encode`] and not [`copy_audio`]'s gate, so an |
| 851 | /// mp4 whose lane carried a fade wrote the source's own packets with the fade |
| 852 | /// nowhere, while the card had promised a re-encode -- and the WAV, FLAC and |
| 853 | /// MP3 exports of the same project applied it. Two gates that cannot be given |
| 854 | /// two answers is the fix; the drift was the defect. |
| 855 | |
| 856 | |
| 857 | |
| 858 | |
| 859 | |
| 860 | |
| 861 | |
| 862 | |
| 863 | |
| 864 | |
| 865 | |
| 866 | |
| 867 | |
| 868 | /// The cheap half of "does this timeline's sound have to be re-encoded": what |
| 869 | /// the *edit* says, with no file opened ([`sample_altered`], asked of every |
| 870 | /// audio lane). The other half -- whether the sources can be copied out of at |
| 871 | /// all -- costs a file open each and belongs to [`copy_audio`], which may |
| 872 | /// re-encode where this says copy. |
| 873 | |
| 874 | |
| 875 | |
| 876 | |
| 877 | |
| 878 | |
| 879 | |
| 880 | /// What the sound is written by. Every audio encoder here is software -- there |
| 881 | /// is no hardware AAC, PCM, FLAC or MP3 seat -- so this names *which* one, and |
| 882 | /// whether a container escapes encoding altogether by copying the packets it was |
| 883 | /// given. Both AV1 formats are in it like the mp4: an AV1 export carries the |
| 884 | /// timeline's sound too, so leaving it unnamed would be the old lie. |
| 885 | /// |
| 886 | /// A prediction, and it says so: `copied` is what [`copy_audio`] *did*, which a |
| 887 | /// card asking before the export has no way to know (a source that cannot be |
| 888 | /// copied out of is only found by opening it). `None` predicts from the edit |
| 889 | /// alone. |
| 890 | |
| 891 | |
| 892 | |
| 893 | |
| 894 | |
| 895 | |
| 896 | |
| 897 | |
| 898 | |
| 899 | |
| 900 | |
| 901 | |
| 902 | |
| 903 | |
| 904 | |
| 905 | |
| 906 | |
| 907 | |
| 908 | |
| 909 | |
| 910 | |
| 911 | |
| 912 | |
| 913 | |
| 914 | |
| 915 | |
| 916 | |
| 917 | |
| 918 | |
| 919 | |
| 920 | |
| 921 | |
| 922 | |
| 923 | |
| 924 | |
| 925 | |
| 926 | /// What the export *did* to the sound, for the line it publishes while it runs: |
| 927 | /// [`audio_label`]'s words with the one thing no prediction can know filled in |
| 928 | /// -- whether the Opus seat took the track or handed it back |
| 929 | /// ([`encode_opus`]'s gate). |
| 930 | /// |
| 931 | /// `sound` is `Some(copied)` for a track and `None` for a file with no sound. |
| 932 | /// Naming Opus for *every* Matroska encode is what made that fallback |
| 933 | /// invisible: a track the gate refused was written as AAC and the line still |
| 934 | /// said Opus, on the one path where the difference is audible. |
| 935 | |
| 936 | |
| 937 | |
| 938 | |
| 939 | |
| 940 | |
| 941 | |
| 942 | |
| 943 | |
| 944 | |
| 945 | |
| 946 | |
| 947 | |
| 948 | |
| 949 | |
| 950 | |
| 951 | |
| 952 | |
| 953 | /// What [`start`] would write this timeline's sound with, before one is |
| 954 | /// started. Pure: no probe and no file opened, so a card may ask it per |
| 955 | /// repaint. `ranged` is whether the export a card is describing is bounded to |
| 956 | /// a marked range -- a copy needs the source's own packets to *be* the file, |
| 957 | /// which a range's exact offset and length rule out ([`copy_audio`]). |
| 958 | |
| 959 | |
| 960 | |
| 961 | |
| 962 | /// Why the sound's rate is nothing this timeline can be asked about in this |
| 963 | /// format, or `None` where it is a real choice: there is no sound to write, the |
| 964 | /// format codes the samples themselves, or the packets are the source's own and |
| 965 | /// carry the rate *it* was coded at. Pure, like [`planned_audio`], and a |
| 966 | /// prediction in the same way -- a copy that turns out impossible (a source no |
| 967 | /// mp4 sample table holds) falls through to [`encode_audio`], which codes at |
| 968 | /// [`ExportSettings::audio_kbps`] like every other encode. So the value travels |
| 969 | /// even where this refuses; what it cannot do is silently write a rate nobody |
| 970 | /// picked. |
| 971 | |
| 972 | |
| 973 | |
| 974 | |
| 975 | |
| 976 | |
| 977 | |
| 978 | |
| 979 | |
| 980 | |
| 981 | |
| 982 | |
| 983 | |
| 984 | |
| 985 | |
| 986 | |
| 987 | |
| 988 | /// The tracks an export carries, in the order they were picked, and empty where |
| 989 | /// it carries none: no pick, a pick nothing answers, a track that could not be |
| 990 | /// read, one with no cue left on the exported timeline -- and every format that |
| 991 | /// is the sound alone, which has nowhere to put them. Filtered *per track*, so |
| 992 | /// one unusable pick costs its own row and not the others. |
| 993 | /// |
| 994 | /// Both containers, since the mp4 muxer gained its `tx3g` track: what the two |
| 995 | /// do with the very same [`SubParams`] is theirs to say |
| 996 | /// ([`crate::mux::Mp4Muxer::write_subtitles`], [`MkvMuxer`]), and nothing here |
| 997 | /// asks which one is being written. |
| 998 | |
| 999 | |
| 1000 | |
| 1001 | |
| 1002 | |
| 1003 | |
| 1004 | |
| 1005 | |
| 1006 | |
| 1007 | |
| 1008 | |
| 1009 | |
| 1010 | |
| 1011 | |
| 1012 | |
| 1013 | |
| 1014 | |
| 1015 | |
| 1016 | |
| 1017 | |
| 1018 | |
| 1019 | |
| 1020 | |
| 1021 | |
| 1022 | |
| 1023 | |
| 1024 | |
| 1025 | |
| 1026 | |
| 1027 | |
| 1028 | |
| 1029 | |
| 1030 | |
| 1031 | |
| 1032 | |
| 1033 | |
| 1034 | |
| 1035 | |
| 1036 | |
| 1037 | |
| 1038 | |
| 1039 | |
| 1040 | |
| 1041 | |
| 1042 | |
| 1043 | |
| 1044 | |
| 1045 | |
| 1046 | |
| 1047 | /// The project's subtitle lanes in display order, and empty where **nothing is |
| 1048 | /// placed on any of them** -- an empty list is what the export and the card both |
| 1049 | /// read as "this project does not use lanes yet", so a project holding a bare |
| 1050 | /// `S1` nobody dropped a caption on still exports by the pick list. |
| 1051 | |
| 1052 | |
| 1053 | |
| 1054 | |
| 1055 | |
| 1056 | |
| 1057 | |
| 1058 | |
| 1059 | /// One track per subtitle *lane*, in lane order -- so the file declares them |
| 1060 | /// top-down as the timeline shows them and a player's subtitle menu lists them |
| 1061 | /// in that order. |
| 1062 | /// |
| 1063 | /// The cues are [`Project::sub_lane_cues`]: each placement's window of its |
| 1064 | /// palette track, on the timeline's own clock. Clipped again here to what the |
| 1065 | /// export *writes*, which ends with the last picture or sound |
| 1066 | /// ([`Project::media_frames`]) -- a caption hanging past both holds the |
| 1067 | /// timeline open ([`Project::timeline_frames`]) but there is no picture under |
| 1068 | /// it to write, so a cue out there is dropped and one straddling the end keeps |
| 1069 | /// the half that is inside. [`planned_subtitles`] says so before the button is |
| 1070 | /// pressed. |
| 1071 | /// |
| 1072 | /// A lane is dropped whole -- no track at all in the file -- where any |
| 1073 | /// placement on it is a picture ([`SubtitleTrack::is_bitmap`]), a track that |
| 1074 | /// could not be read, or a palette row that has since gone: the muxers write |
| 1075 | /// words, and half a lane's cues under the other half's name would be worse |
| 1076 | /// than none. Its language and title are the lane's *first* placement's track, |
| 1077 | /// which is the one thing the whole lane is named by. |
| 1078 | |
| 1079 | |
| 1080 | |
| 1081 | |
| 1082 | |
| 1083 | |
| 1084 | |
| 1085 | |
| 1086 | |
| 1087 | |
| 1088 | |
| 1089 | |
| 1090 | |
| 1091 | |
| 1092 | |
| 1093 | |
| 1094 | |
| 1095 | |
| 1096 | |
| 1097 | |
| 1098 | |
| 1099 | |
| 1100 | |
| 1101 | |
| 1102 | |
| 1103 | |
| 1104 | |
| 1105 | |
| 1106 | |
| 1107 | |
| 1108 | |
| 1109 | |
| 1110 | |
| 1111 | |
| 1112 | |
| 1113 | |
| 1114 | |
| 1115 | |
| 1116 | |
| 1117 | /// The composite spans an export *writes*: [`Project::composite_spans_from`] |
| 1118 | /// cut to where the media runs out ([`Project::media_frames`]), and, with |
| 1119 | /// `range` set, to that window too. |
| 1120 | /// |
| 1121 | /// The walk itself is the timeline's ([`Project::timeline_frames`]), because a |
| 1122 | /// caption placed past the last picture holds the timeline open under it and |
| 1123 | /// playback parks on that tail -- but there is nothing to *write* out there, so |
| 1124 | /// an unbounded walk encoded and muxed black frames past the end of the media |
| 1125 | /// and padded the sound to match. This is the one place that end is decided: |
| 1126 | /// the frame count [`run`] publishes, the cues [`lane_subtitles`] clips and the |
| 1127 | /// blocks [`CopyPlan`] copies are then the same number by construction, which |
| 1128 | /// is what makes [`planned_lanes`]' "cut off there" true of the file. |
| 1129 | /// |
| 1130 | /// `span.start` stays the *project's* own timeline coordinate throughout -- |
| 1131 | /// what [`Project::composite_color_at`] and its fit sibling are keyed on -- so |
| 1132 | /// a caller writing a range-relative output shifts it at the one place that |
| 1133 | /// actually emits a position (`CopyPlan`'s own region, since the encode loop |
| 1134 | /// counts pictures rather than reading `span.start` for its output clock). |
| 1135 | /// Trimming the left edge mid-span moves `from`'s source frame by |
| 1136 | /// [`Speed::source_at`], the same mapping a legal cut is placed by. |
| 1137 | |
| 1138 | |
| 1139 | |
| 1140 | |
| 1141 | |
| 1142 | |
| 1143 | |
| 1144 | |
| 1145 | |
| 1146 | |
| 1147 | |
| 1148 | |
| 1149 | |
| 1150 | |
| 1151 | |
| 1152 | |
| 1153 | |
| 1154 | |
| 1155 | |
| 1156 | |
| 1157 | |
| 1158 | |
| 1159 | |
| 1160 | |
| 1161 | |
| 1162 | |
| 1163 | /// The cross-dissolve this span's tail owes its successor, or `None` for a |
| 1164 | /// hard cut. `(b_source, b_in_frame, window, b_start)`: which source and |
| 1165 | /// source frame the dissolve's B side starts reading, how many *output* |
| 1166 | /// frames the blend ramps across, and where B sits on the timeline (which is |
| 1167 | /// what its own grade and fit are keyed on, [`Project::composite_color_at`] |
| 1168 | /// and [`Project::composite_fit_at`]). |
| 1169 | /// |
| 1170 | /// [`Clip::transition_out`] is trusted only after adjacency is checked again |
| 1171 | /// here: a trim or a split since it was set leaves the stored number in |
| 1172 | /// place but not its meaning, so a stale one plays as the hard cut it now |
| 1173 | /// is rather than as a dissolve into a clip that no longer follows. |
| 1174 | pub |
| 1175 | |
| 1176 | |
| 1177 | |
| 1178 | |
| 1179 | |
| 1180 | |
| 1181 | |
| 1182 | |
| 1183 | |
| 1184 | |
| 1185 | |
| 1186 | |
| 1187 | |
| 1188 | |
| 1189 | |
| 1190 | |
| 1191 | |
| 1192 | |
| 1193 | |
| 1194 | |
| 1195 | |
| 1196 | |
| 1197 | |
| 1198 | |
| 1199 | |
| 1200 | |
| 1201 | |
| 1202 | |
| 1203 | /// `B`'s weight in [`blend_i420`] at output frame `idx_in_window` of `window` |
| 1204 | /// (`idx_in_window < window`): a ramp from just above 0 to just below 1 that |
| 1205 | /// never actually reaches either end, so the first blended frame still shows |
| 1206 | /// a trace of A and the last still a trace of B -- the cut a hard transition |
| 1207 | /// would have made lands one frame *after* the window, at full B, rather than |
| 1208 | /// inside it. |
| 1209 | pub |
| 1210 | |
| 1211 | |
| 1212 | |
| 1213 | /// A dissolve's B side, open beside A's own decoder for this span's tail: |
| 1214 | /// its own decoder, and everything [`place_picture`] needs to put its frames |
| 1215 | /// on the same canvas, in the same space, graded the way B is graded rather |
| 1216 | /// than the way A is -- [`Project::composite_color_at`]/`composite_fit_at` |
| 1217 | /// asked at B's own start, not at the timeline position the blend writes to, |
| 1218 | /// which is still inside A's span. |
| 1219 | |
| 1220 | |
| 1221 | |
| 1222 | |
| 1223 | |
| 1224 | |
| 1225 | |
| 1226 | |
| 1227 | |
| 1228 | |
| 1229 | |
| 1230 | |
| 1231 | |
| 1232 | |
| 1233 | |
| 1234 | |
| 1235 | |
| 1236 | |
| 1237 | |
| 1238 | |
| 1239 | |
| 1240 | |
| 1241 | |
| 1242 | |
| 1243 | |
| 1244 | |
| 1245 | |
| 1246 | /// The track's cues where the *exported* timeline puts them, which is the only |
| 1247 | /// clock the file has: the export writes timeline frame 0 onwards and nothing |
| 1248 | /// else, exactly as the sound is mixed from frame 0 and resized to the |
| 1249 | /// timeline's own length ([`encode_audio`]). |
| 1250 | /// |
| 1251 | /// Which clock the cues arrive in is what the track itself says: |
| 1252 | /// |
| 1253 | /// * a track out of a *file* (`SubtitleTrack::track`) is timed against that |
| 1254 | /// file, so each cue is carried through the spans that play it -- a cue over |
| 1255 | /// a stretch that was cut out is gone, one straddling a cut keeps the half |
| 1256 | /// that is still there, and one after a rippled delete moves back with the |
| 1257 | /// picture it belongs to. The *edges* a cut clips to are frames -- that is |
| 1258 | /// what a cut is -- but a cue nothing clipped keeps its own microseconds, so |
| 1259 | /// an untouched timeline exports the times the source states. |
| 1260 | /// * a *standalone* file (`subs.srt`) is timed against nothing else -- there is |
| 1261 | /// no clip to hang it on and no offset in the project to shift it by -- so it |
| 1262 | /// is the timeline's own clock, which is where it was drawn while editing |
| 1263 | /// (`Player::subtitle_overlay`). Clipped to the exported length and no more. |
| 1264 | /// |
| 1265 | /// This is also what the *preview* draws: the plate over the picture and the |
| 1266 | /// timeline strip both ask it through |
| 1267 | /// [`PlaybackSession::timeline_cues`](crate::PlaybackSession::timeline_cues), so |
| 1268 | /// what a rippled timeline shows and what its export writes are one answer by |
| 1269 | /// construction rather than two maps kept in step by hand. |
| 1270 | /// |
| 1271 | /// Pure and cheap enough to ask per repaint (a walk of the spans and of the |
| 1272 | /// cues, no file opened), which is how a front-end asks it. |
| 1273 | |
| 1274 | |
| 1275 | |
| 1276 | |
| 1277 | |
| 1278 | |
| 1279 | |
| 1280 | |
| 1281 | |
| 1282 | |
| 1283 | |
| 1284 | |
| 1285 | |
| 1286 | |
| 1287 | |
| 1288 | |
| 1289 | |
| 1290 | |
| 1291 | |
| 1292 | |
| 1293 | |
| 1294 | |
| 1295 | |
| 1296 | |
| 1297 | |
| 1298 | |
| 1299 | |
| 1300 | |
| 1301 | |
| 1302 | |
| 1303 | |
| 1304 | |
| 1305 | |
| 1306 | |
| 1307 | |
| 1308 | |
| 1309 | |
| 1310 | |
| 1311 | |
| 1312 | |
| 1313 | |
| 1314 | |
| 1315 | |
| 1316 | |
| 1317 | |
| 1318 | |
| 1319 | |
| 1320 | |
| 1321 | |
| 1322 | |
| 1323 | |
| 1324 | |
| 1325 | |
| 1326 | |
| 1327 | |
| 1328 | |
| 1329 | |
| 1330 | |
| 1331 | |
| 1332 | |
| 1333 | |
| 1334 | |
| 1335 | |
| 1336 | |
| 1337 | /// What [`start`] would do about the subtitles, in the words a card shows: what |
| 1338 | /// travels, and the reason beside every pick that does not. Pure, like |
| 1339 | /// [`planned_audio`]: no file is opened, so it may be asked per repaint. |
| 1340 | /// |
| 1341 | /// `picks` is any run of indices into [`Project::subtitles`] -- an |
| 1342 | /// [`ExportSettings::subtitles`] list (`picks.iter().copied()`) as much as a |
| 1343 | /// single `Some(row)`, which is what a front-end holding one row still hands it. |
| 1344 | |
| 1345 | |
| 1346 | |
| 1347 | |
| 1348 | |
| 1349 | |
| 1350 | |
| 1351 | |
| 1352 | |
| 1353 | |
| 1354 | |
| 1355 | |
| 1356 | |
| 1357 | |
| 1358 | |
| 1359 | |
| 1360 | |
| 1361 | |
| 1362 | |
| 1363 | |
| 1364 | |
| 1365 | |
| 1366 | |
| 1367 | |
| 1368 | |
| 1369 | |
| 1370 | |
| 1371 | |
| 1372 | |
| 1373 | |
| 1374 | |
| 1375 | |
| 1376 | |
| 1377 | |
| 1378 | |
| 1379 | |
| 1380 | |
| 1381 | |
| 1382 | |
| 1383 | |
| 1384 | |
| 1385 | |
| 1386 | |
| 1387 | |
| 1388 | |
| 1389 | |
| 1390 | |
| 1391 | |
| 1392 | |
| 1393 | |
| 1394 | |
| 1395 | |
| 1396 | |
| 1397 | |
| 1398 | |
| 1399 | |
| 1400 | |
| 1401 | |
| 1402 | |
| 1403 | |
| 1404 | |
| 1405 | |
| 1406 | |
| 1407 | /// [`planned_subtitles`] for a timeline that *places* its words: one clause per |
| 1408 | /// subtitle lane, named by the lane and by the palette row it shows, in the |
| 1409 | /// order the file will declare them ([`lane_subtitles`]). |
| 1410 | /// |
| 1411 | /// Every reason a lane does not travel is said here rather than found in the |
| 1412 | /// file: a picture track placed on it, a track that could not be read, a palette |
| 1413 | /// row that has since gone, a lane sitting entirely past the last picture, and |
| 1414 | /// -- before a byte is written -- more lanes than a Matroska block can number |
| 1415 | /// ([`crate::mux::MAX_SUB_TRACKS`], which the muxer refuses again). |
| 1416 | |
| 1417 | |
| 1418 | |
| 1419 | |
| 1420 | |
| 1421 | |
| 1422 | |
| 1423 | |
| 1424 | |
| 1425 | |
| 1426 | |
| 1427 | |
| 1428 | |
| 1429 | |
| 1430 | |
| 1431 | |
| 1432 | |
| 1433 | |
| 1434 | |
| 1435 | |
| 1436 | |
| 1437 | |
| 1438 | |
| 1439 | |
| 1440 | |
| 1441 | |
| 1442 | |
| 1443 | |
| 1444 | |
| 1445 | |
| 1446 | |
| 1447 | |
| 1448 | |
| 1449 | |
| 1450 | |
| 1451 | |
| 1452 | |
| 1453 | |
| 1454 | |
| 1455 | |
| 1456 | |
| 1457 | |
| 1458 | |
| 1459 | |
| 1460 | |
| 1461 | |
| 1462 | |
| 1463 | |
| 1464 | |
| 1465 | |
| 1466 | |
| 1467 | |
| 1468 | |
| 1469 | |
| 1470 | |
| 1471 | |
| 1472 | |
| 1473 | |
| 1474 | |
| 1475 | |
| 1476 | /// What [`start`] would encode the picture with, probed the way the export |
| 1477 | /// probes it -- the very encoder is opened and closed again -- so this is a |
| 1478 | /// measurement and not a promise. `None` for a format that carries no picture. |
| 1479 | /// |
| 1480 | /// Costs that open (~100 ms here): ask it off a render thread and keep the |
| 1481 | /// answer until the format, the resolution or the bitrate changes. |
| 1482 | |
| 1483 | |
| 1484 | |
| 1485 | |
| 1486 | |
| 1487 | |
| 1488 | |
| 1489 | |
| 1490 | |
| 1491 | /// What [`start`] would open for *this* timeline: the picture's seat -- or the |
| 1492 | /// copy that means there is no encoder at all -- and the sound's, asked of the |
| 1493 | /// very gates the export asks ([`CopyPlan::of`] and [`copy_audio`]'s) rather |
| 1494 | /// than of the format alone. |
| 1495 | /// |
| 1496 | /// This exists because the card and the running export used to disagree in both |
| 1497 | /// directions on the same file: the card named a software HEVC encode for a cut |
| 1498 | /// the engine copied, and named an AAC copy for a Matroska source whose sound |
| 1499 | /// no sample table holds and which therefore always re-encodes. A prediction |
| 1500 | /// that is not the decision is worse than no prediction, because a person plans |
| 1501 | /// their evening around it. |
| 1502 | /// |
| 1503 | /// Costs what [`planned_video`] costs (an encoder opened and closed) plus a |
| 1504 | /// header read per source and, once per file, its cluster walk: ask it off a |
| 1505 | /// render thread and keep the answer until the timeline or the settings change. |
| 1506 | |
| 1507 | |
| 1508 | |
| 1509 | |
| 1510 | |
| 1511 | |
| 1512 | |
| 1513 | |
| 1514 | |
| 1515 | |
| 1516 | |
| 1517 | |
| 1518 | |
| 1519 | |
| 1520 | |
| 1521 | |
| 1522 | |
| 1523 | |
| 1524 | |
| 1525 | |
| 1526 | |
| 1527 | |
| 1528 | |
| 1529 | |
| 1530 | |
| 1531 | |
| 1532 | |
| 1533 | |
| 1534 | |
| 1535 | |
| 1536 | |
| 1537 | |
| 1538 | |
| 1539 | |
| 1540 | |
| 1541 | |
| 1542 | |
| 1543 | |
| 1544 | |
| 1545 | /// The audio track an export writes, and how it was made -- a copy is the |
| 1546 | /// source's own packets, bit for bit, and anything else is this project's |
| 1547 | /// encoder over the decoded mix. [`run`] publishes which of the two really |
| 1548 | /// happened, so the encoder line a user reads is measured and not promised. |
| 1549 | pub |
| 1550 | |
| 1551 | |
| 1552 | |
| 1553 | |
| 1554 | |
| 1555 | |
| 1556 | |
| 1557 | |
| 1558 | |
| 1559 | |
| 1560 | |
| 1561 | /// The timeline's audio track for a file that carries picture: copied packet for |
| 1562 | /// packet where a copy says exactly what the timeline says, and decoded, mixed |
| 1563 | /// and encoded again ([`encode_audio`]) where it cannot -- a second audio lane, |
| 1564 | /// a speeded clip, an equalizer, a source that is not AAC inside an mp4 sample |
| 1565 | /// table. Nothing is refused for being uncopyable any more; the only refusals |
| 1566 | /// left below the copy are about sound this engine cannot *decode* either, and |
| 1567 | /// those come out of the decode path by name. |
| 1568 | /// |
| 1569 | /// The copy is still the default and still bit-exact: a timeline nobody has |
| 1570 | /// touched leaves as the very packets its source holds. |
| 1571 | /// |
| 1572 | /// corner-cut: this holds the whole exported AAC track in memory (~3 kB per |
| 1573 | /// 23 ms packet, so ~500 MB for an hour). Upgrade path is a streaming |
| 1574 | /// `copy_segments` that yields packets instead of collecting them. |
| 1575 | |
| 1576 | |
| 1577 | |
| 1578 | |
| 1579 | |
| 1580 | |
| 1581 | |
| 1582 | |
| 1583 | |
| 1584 | |
| 1585 | |
| 1586 | |
| 1587 | |
| 1588 | |
| 1589 | |
| 1590 | |
| 1591 | |
| 1592 | |
| 1593 | |
| 1594 | |
| 1595 | |
| 1596 | |
| 1597 | |
| 1598 | |
| 1599 | |
| 1600 | |
| 1601 | |
| 1602 | |
| 1603 | |
| 1604 | |
| 1605 | |
| 1606 | |
| 1607 | |
| 1608 | |
| 1609 | |
| 1610 | |
| 1611 | |
| 1612 | |
| 1613 | |
| 1614 | |
| 1615 | |
| 1616 | |
| 1617 | |
| 1618 | |
| 1619 | |
| 1620 | |
| 1621 | |
| 1622 | |
| 1623 | |
| 1624 | |
| 1625 | |
| 1626 | |
| 1627 | |
| 1628 | |
| 1629 | |
| 1630 | |
| 1631 | |
| 1632 | |
| 1633 | |
| 1634 | |
| 1635 | |
| 1636 | |
| 1637 | |
| 1638 | |
| 1639 | |
| 1640 | |
| 1641 | |
| 1642 | |
| 1643 | |
| 1644 | |
| 1645 | |
| 1646 | |
| 1647 | |
| 1648 | |
| 1649 | |
| 1650 | |
| 1651 | |
| 1652 | |
| 1653 | |
| 1654 | |
| 1655 | |
| 1656 | |
| 1657 | |
| 1658 | |
| 1659 | |
| 1660 | |
| 1661 | |
| 1662 | |
| 1663 | |
| 1664 | |
| 1665 | |
| 1666 | |
| 1667 | |
| 1668 | |
| 1669 | |
| 1670 | |
| 1671 | |
| 1672 | |
| 1673 | |
| 1674 | |
| 1675 | |
| 1676 | |
| 1677 | |
| 1678 | |
| 1679 | |
| 1680 | |
| 1681 | |
| 1682 | |
| 1683 | |
| 1684 | |
| 1685 | |
| 1686 | |
| 1687 | |
| 1688 | |
| 1689 | |
| 1690 | |
| 1691 | |
| 1692 | |
| 1693 | |
| 1694 | |
| 1695 | |
| 1696 | |
| 1697 | |
| 1698 | |
| 1699 | /// The picture's half of [`copy_audio`]: a Matroska export whose every span is |
| 1700 | /// its source's own coded blocks, written back out without a decoder or an |
| 1701 | /// encoder anywhere in the path. |
| 1702 | /// |
| 1703 | /// **When.** A copy is entered only where it says *exactly* what the timeline |
| 1704 | /// says, which is the audio gate's rule and not a looser one: the file this |
| 1705 | /// export writes is Matroska, the source's codec is the one that file would |
| 1706 | /// carry ([`Format::Hevc`] over HEVC, [`Format::Av1`] over AV1), and nothing on |
| 1707 | /// the way has touched a sample -- no grade, no speed, no rate conversion, no |
| 1708 | /// gap to fill with black, no source of another size to place on the canvas, |
| 1709 | /// no `ContentEncodings` packing to undo. Anything else re-encodes exactly as |
| 1710 | /// it always did; there is no half-copied file. |
| 1711 | /// |
| 1712 | /// **All or nothing, per export.** A copied span and an encoded one cannot |
| 1713 | /// share one track: this project's encoders write 8-bit SDR streams whose |
| 1714 | /// parameter sets are their own, so splicing them into (say) a Main 10 HDR |
| 1715 | /// source would change bit depth and colour mid-track, and a container states |
| 1716 | /// its configuration record once. So the head and tail fragments of a cut that |
| 1717 | /// lands mid-GOP are *not* re-encoded into the copy -- they are what makes the |
| 1718 | /// whole export fall back to the encoder. What a copy needs instead is that |
| 1719 | /// every span begins on a sync point and ends where the next one begins, which |
| 1720 | /// is what a cut placed on a keyframe gives it. |
| 1721 | /// |
| 1722 | /// **What a cut costs.** An open-GOP source (x265's default) writes leading |
| 1723 | /// pictures after a sync point that are shown *before* it and reference the |
| 1724 | /// group before it. At the start of a copied region those references are not in |
| 1725 | /// the file, so they are dropped -- the picture before the cut is held for those |
| 1726 | /// few frames (four at this film's B-depth, a sixth of a second) rather than |
| 1727 | /// being written as pictures that cannot decode. The region still starts at the |
| 1728 | /// timeline frame it owns, so the sound never drifts. |
| 1729 | /// |
| 1730 | /// corner-cut: mp4 is not copied (its `hvc1` sample entry forbids in-band |
| 1731 | /// parameter sets, and the mp4 muxer here writes its sample table from a frame |
| 1732 | /// counter), and neither is H.264, which this project only writes into mp4. The |
| 1733 | /// upgrade path for both is a sample-table writer that takes explicit |
| 1734 | /// timestamps, which is what [`MkvMuxer::write_block`] already is for Matroska. |
| 1735 | |
| 1736 | |
| 1737 | |
| 1738 | |
| 1739 | |
| 1740 | |
| 1741 | |
| 1742 | |
| 1743 | |
| 1744 | |
| 1745 | |
| 1746 | |
| 1747 | |
| 1748 | |
| 1749 | |
| 1750 | |
| 1751 | |
| 1752 | |
| 1753 | |
| 1754 | |
| 1755 | |
| 1756 | |
| 1757 | /// A run of source blocks copied in one piece: what a cut leaves behind, and |
| 1758 | /// what two spans that continue each other in the same file merge back into. |
| 1759 | |
| 1760 | |
| 1761 | |
| 1762 | |
| 1763 | |
| 1764 | |
| 1765 | |
| 1766 | |
| 1767 | |
| 1768 | |
| 1769 | /// Why [`ExportSettings::exact`] cannot be honoured for this project right |
| 1770 | /// now, or `None` where [`CopyPlan`] already carries the whole file. A state |
| 1771 | /// report, not an instruction: it says what the file *is* rather than what to |
| 1772 | /// pick instead. |
| 1773 | /// |
| 1774 | /// Two shapes of reason, told apart because only one of them is permanent. |
| 1775 | /// **The container cannot carry the source's own codec at all** -- Exact was |
| 1776 | /// asked of an mp4, or of a Matroska file whose codec is not the source's own |
| 1777 | /// -- which is [`CopyPlan`]'s own corner-cut (mp4 copies nothing yet) and |
| 1778 | /// [`CopyPlan::of`]'s codec check, so it is checked here the same way rather |
| 1779 | /// than duplicated with different words. **The edit is what stops it** -- a |
| 1780 | /// cut off a sync point, a grade, a speed, a dissolve, a moved or scaled |
| 1781 | /// clip -- which the same format would carry exactly if the edit let it, so |
| 1782 | /// those six [`CopyPlan::of`] gates are named together rather than picked |
| 1783 | /// apart into six different sentences. |
| 1784 | |
| 1785 | |
| 1786 | |
| 1787 | |
| 1788 | |
| 1789 | |
| 1790 | |
| 1791 | |
| 1792 | |
| 1793 | |
| 1794 | |
| 1795 | |
| 1796 | |
| 1797 | |
| 1798 | |
| 1799 | |
| 1800 | |
| 1801 | |
| 1802 | |
| 1803 | |
| 1804 | |
| 1805 | |
| 1806 | |
| 1807 | |
| 1808 | |
| 1809 | |
| 1810 | |
| 1811 | |
| 1812 | |
| 1813 | |
| 1814 | |
| 1815 | |
| 1816 | |
| 1817 | |
| 1818 | |
| 1819 | |
| 1820 | |
| 1821 | |
| 1822 | |
| 1823 | |
| 1824 | |
| 1825 | |
| 1826 | |
| 1827 | |
| 1828 | |
| 1829 | |
| 1830 | |
| 1831 | |
| 1832 | |
| 1833 | |
| 1834 | |
| 1835 | |
| 1836 | |
| 1837 | |
| 1838 | |
| 1839 | |
| 1840 | |
| 1841 | |
| 1842 | |
| 1843 | |
| 1844 | |
| 1845 | |
| 1846 | |
| 1847 | |
| 1848 | |
| 1849 | |
| 1850 | |
| 1851 | |
| 1852 | |
| 1853 | |
| 1854 | |
| 1855 | |
| 1856 | |
| 1857 | |
| 1858 | |
| 1859 | |
| 1860 | |
| 1861 | |
| 1862 | |
| 1863 | |
| 1864 | |
| 1865 | |
| 1866 | |
| 1867 | |
| 1868 | |
| 1869 | |
| 1870 | |
| 1871 | |
| 1872 | |
| 1873 | |
| 1874 | |
| 1875 | |
| 1876 | |
| 1877 | |
| 1878 | |
| 1879 | |
| 1880 | |
| 1881 | |
| 1882 | |
| 1883 | |
| 1884 | |
| 1885 | |
| 1886 | |
| 1887 | |
| 1888 | |
| 1889 | |
| 1890 | |
| 1891 | |
| 1892 | |
| 1893 | |
| 1894 | |
| 1895 | |
| 1896 | |
| 1897 | |
| 1898 | |
| 1899 | |
| 1900 | |
| 1901 | |
| 1902 | |
| 1903 | |
| 1904 | |
| 1905 | |
| 1906 | |
| 1907 | |
| 1908 | |
| 1909 | |
| 1910 | |
| 1911 | |
| 1912 | |
| 1913 | |
| 1914 | |
| 1915 | |
| 1916 | |
| 1917 | |
| 1918 | |
| 1919 | |
| 1920 | |
| 1921 | |
| 1922 | |
| 1923 | |
| 1924 | |
| 1925 | |
| 1926 | |
| 1927 | |
| 1928 | |
| 1929 | |
| 1930 | |
| 1931 | |
| 1932 | |
| 1933 | |
| 1934 | |
| 1935 | |
| 1936 | |
| 1937 | |
| 1938 | |
| 1939 | |
| 1940 | |
| 1941 | |
| 1942 | |
| 1943 | |
| 1944 | |
| 1945 | |
| 1946 | |
| 1947 | |
| 1948 | |
| 1949 | |
| 1950 | |
| 1951 | |
| 1952 | |
| 1953 | |
| 1954 | |
| 1955 | |
| 1956 | |
| 1957 | |
| 1958 | |
| 1959 | |
| 1960 | |
| 1961 | |
| 1962 | |
| 1963 | |
| 1964 | |
| 1965 | |
| 1966 | |
| 1967 | |
| 1968 | |
| 1969 | |
| 1970 | |
| 1971 | |
| 1972 | |
| 1973 | |
| 1974 | |
| 1975 | |
| 1976 | |
| 1977 | |
| 1978 | |
| 1979 | |
| 1980 | |
| 1981 | |
| 1982 | |
| 1983 | |
| 1984 | |
| 1985 | |
| 1986 | |
| 1987 | |
| 1988 | |
| 1989 | |
| 1990 | |
| 1991 | |
| 1992 | |
| 1993 | |
| 1994 | |
| 1995 | |
| 1996 | |
| 1997 | |
| 1998 | |
| 1999 | |
| 2000 | |
| 2001 | |
| 2002 | |
| 2003 | |
| 2004 | |
| 2005 | |
| 2006 | |
| 2007 | |
| 2008 | |
| 2009 | |
| 2010 | |
| 2011 | |
| 2012 | |
| 2013 | |
| 2014 | |
| 2015 | |
| 2016 | |
| 2017 | |
| 2018 | |
| 2019 | |
| 2020 | |
| 2021 | |
| 2022 | |
| 2023 | |
| 2024 | |
| 2025 | |
| 2026 | |
| 2027 | |
| 2028 | |
| 2029 | |
| 2030 | |
| 2031 | |
| 2032 | |
| 2033 | |
| 2034 | |
| 2035 | |
| 2036 | |
| 2037 | |
| 2038 | |
| 2039 | |
| 2040 | |
| 2041 | |
| 2042 | |
| 2043 | |
| 2044 | |
| 2045 | |
| 2046 | |
| 2047 | |
| 2048 | |
| 2049 | |
| 2050 | |
| 2051 | |
| 2052 | |
| 2053 | |
| 2054 | |
| 2055 | |
| 2056 | |
| 2057 | |
| 2058 | |
| 2059 | |
| 2060 | |
| 2061 | |
| 2062 | |
| 2063 | |
| 2064 | |
| 2065 | |
| 2066 | |
| 2067 | |
| 2068 | |
| 2069 | |
| 2070 | |
| 2071 | |
| 2072 | |
| 2073 | |
| 2074 | |
| 2075 | |
| 2076 | |
| 2077 | |
| 2078 | |
| 2079 | |
| 2080 | |
| 2081 | |
| 2082 | |
| 2083 | |
| 2084 | |
| 2085 | |
| 2086 | |
| 2087 | |
| 2088 | |
| 2089 | |
| 2090 | |
| 2091 | |
| 2092 | |
| 2093 | |
| 2094 | |
| 2095 | |
| 2096 | |
| 2097 | |
| 2098 | |
| 2099 | |
| 2100 | |
| 2101 | |
| 2102 | |
| 2103 | |
| 2104 | |
| 2105 | |
| 2106 | |
| 2107 | |
| 2108 | |
| 2109 | |
| 2110 | |
| 2111 | |
| 2112 | |
| 2113 | |
| 2114 | |
| 2115 | |
| 2116 | |
| 2117 | |
| 2118 | |
| 2119 | |
| 2120 | |
| 2121 | |
| 2122 | |
| 2123 | |
| 2124 | |
| 2125 | |
| 2126 | |
| 2127 | |
| 2128 | |
| 2129 | /// Whether `policy` places the picture `source` is DRAWN at onto this `canvas` |
| 2130 | /// without touching a sample: the whole picture, at the whole canvas, 1:1. |
| 2131 | /// |
| 2132 | /// The 1:1 is the half the rects cannot state: a source scaled onto a canvas |
| 2133 | /// of another aspect is placed whole and cropped nowhere, which is a resize |
| 2134 | /// and not an identity -- so the pairs themselves are compared first. |
| 2135 | /// |
| 2136 | /// The pair asked about is the **drawn** one ([`VideoMeta::width`]/`height`]), |
| 2137 | /// never the coded one: what the fit is composed against is what a decoder |
| 2138 | /// hands the canvas after the file's turn and its pixel aspect have been |
| 2139 | /// applied, so a 1440x1080 file with a 4:3 sample aspect is a 1920x1080 |
| 2140 | /// picture, and a project at 1920x1080 is copying it exactly. The coded pair |
| 2141 | /// has its own question -- what a copied track *declares* -- and the coded-to- |
| 2142 | /// coded check in [`CopyPlan::of`] already asks that one; asking it twice, in |
| 2143 | /// the geometry's stead, refuses a copy main performs byte for byte. |
| 2144 | /// |
| 2145 | /// Asked from [`scale::fit_rect`] -- the one function that *is* a fit policy's |
| 2146 | /// meaning -- rather than from the policy itself, which is what makes this |
| 2147 | /// canvas-aware twice over: `Fill` on a canvas the size of the source's own |
| 2148 | /// samples is the identity (nothing is cropped, because there is nothing to |
| 2149 | /// crop), while `Fit` on a canvas of another aspect is not (it bars or crops). |
| 2150 | /// A policy added to [`FitPolicy`] later is judged by what it places, not by |
| 2151 | /// being absent from a list here. |
| 2152 | |
| 2153 | |
| 2154 | |
| 2155 | |
| 2156 | |
| 2157 | |
| 2158 | |
| 2159 | |
| 2160 | |
| 2161 | |
| 2162 | |
| 2163 | |
| 2164 | |
| 2165 | |
| 2166 | |
| 2167 | |
| 2168 | |
| 2169 | |
| 2170 | |
| 2171 | |
| 2172 | |
| 2173 | |
| 2174 | |
| 2175 | |
| 2176 | |
| 2177 | |
| 2178 | |
| 2179 | |
| 2180 | |
| 2181 | |
| 2182 | /// The same lane, *decoded*: what a packet copy cannot carry comes out here as |
| 2183 | /// AAC written by this project's own encoder. |
| 2184 | /// |
| 2185 | /// The samples are the very ones [`run_audio`] would put in a WAV -- the same |
| 2186 | /// opener with the same equalizers, the same rates and the same resize onto the |
| 2187 | /// timeline's own length -- so an mp4 and a WAV of one timeline are one mix, |
| 2188 | /// not two that could disagree. |
| 2189 | /// |
| 2190 | /// AAC-LC's encoder delay is one 1024-frame block, which is exactly the priming |
| 2191 | /// a reader drops when the file carries no edit list (`audio::DEFAULT_PRIMING`, |
| 2192 | /// and [`crate::mux::Mp4Muxer`] writes none): the first packet is that delay, so |
| 2193 | /// the sound starts at timeline frame 0 as a copied track's does. |
| 2194 | /// |
| 2195 | /// corner-cut: the mix sits in memory as f32 before it is encoded (~46 MB a |
| 2196 | /// minute of 48 kHz stereo), for [`run_audio`]'s reason -- sizing the track |
| 2197 | /// against the timeline, publishing the mix third of the bar as it goes and |
| 2198 | /// answering a cancel before the encode are whole-mix concerns here. The |
| 2199 | /// upgrade path is a chunked push: `ec_aac`'s encoder itself streams. |
| 2200 | |
| 2201 | |
| 2202 | |
| 2203 | |
| 2204 | |
| 2205 | |
| 2206 | |
| 2207 | |
| 2208 | |
| 2209 | |
| 2210 | |
| 2211 | |
| 2212 | |
| 2213 | |
| 2214 | |
| 2215 | |
| 2216 | |
| 2217 | |
| 2218 | |
| 2219 | |
| 2220 | |
| 2221 | |
| 2222 | |
| 2223 | |
| 2224 | |
| 2225 | |
| 2226 | |
| 2227 | |
| 2228 | |
| 2229 | |
| 2230 | |
| 2231 | |
| 2232 | |
| 2233 | |
| 2234 | |
| 2235 | |
| 2236 | |
| 2237 | |
| 2238 | |
| 2239 | |
| 2240 | |
| 2241 | |
| 2242 | |
| 2243 | |
| 2244 | |
| 2245 | |
| 2246 | |
| 2247 | |
| 2248 | |
| 2249 | |
| 2250 | |
| 2251 | |
| 2252 | |
| 2253 | |
| 2254 | |
| 2255 | |
| 2256 | |
| 2257 | |
| 2258 | |
| 2259 | |
| 2260 | |
| 2261 | |
| 2262 | |
| 2263 | |
| 2264 | |
| 2265 | |
| 2266 | |
| 2267 | |
| 2268 | |
| 2269 | |
| 2270 | |
| 2271 | |
| 2272 | |
| 2273 | |
| 2274 | |
| 2275 | |
| 2276 | |
| 2277 | |
| 2278 | |
| 2279 | |
| 2280 | |
| 2281 | |
| 2282 | |
| 2283 | |
| 2284 | |
| 2285 | |
| 2286 | |
| 2287 | |
| 2288 | |
| 2289 | |
| 2290 | |
| 2291 | |
| 2292 | |
| 2293 | |
| 2294 | |
| 2295 | |
| 2296 | |
| 2297 | |
| 2298 | |
| 2299 | |
| 2300 | |
| 2301 | |
| 2302 | |
| 2303 | |
| 2304 | |
| 2305 | |
| 2306 | |
| 2307 | |
| 2308 | |
| 2309 | |
| 2310 | |
| 2311 | |
| 2312 | |
| 2313 | |
| 2314 | |
| 2315 | |
| 2316 | |
| 2317 | |
| 2318 | |
| 2319 | |
| 2320 | |
| 2321 | |
| 2322 | |
| 2323 | |
| 2324 | |
| 2325 | |
| 2326 | |
| 2327 | |
| 2328 | |
| 2329 | |
| 2330 | |
| 2331 | |
| 2332 | |
| 2333 | |
| 2334 | |
| 2335 | |
| 2336 | |
| 2337 | |
| 2338 | |
| 2339 | |
| 2340 | |
| 2341 | |
| 2342 | |
| 2343 | |
| 2344 | |
| 2345 | |
| 2346 | /// The one rate Opus codes at. The container may state another one in its |
| 2347 | /// `OpusHead` and every decoder still runs at 48 kHz (RFC 7845 §5.1), so a |
| 2348 | /// timeline at any other rate is not "encoded at its own rate" here -- it is |
| 2349 | /// resampled or it is not Opus, and [`encode_audio`] picks the second. |
| 2350 | pub const OPUS_RATE: u32 = 48_000; |
| 2351 | |
| 2352 | /// 20 ms at [`OPUS_RATE`], the frame every Opus muxer in the wild writes: |
| 2353 | /// long enough that the per-packet overhead is nothing, short enough that a |
| 2354 | /// Matroska block timestamp in whole milliseconds is exact. |
| 2355 | const OPUS_FRAME: usize = 960; |
| 2356 | |
| 2357 | /// The most this project asks of the Opus encoder, in kbps, and why it is a cap |
| 2358 | /// rather than the four rates the Sound row offers. |
| 2359 | /// |
| 2360 | /// History, because the number moved once already and the reason it could is |
| 2361 | /// part of the record. Under `opus-rs 0.1.26` the ceiling was 128: that encoder |
| 2362 | /// fell off a cliff at a rate that depended on the *content*, and above it a |
| 2363 | /// conformant decoder got noise back. Measured on three one-second spans of a |
| 2364 | /// real 5.1 Opus film, encoded there and decoded with `ruopus` -- which was not |
| 2365 | /// the suspect, since it decoded ffmpeg's own libopus at 256 kbps to |
| 2366 | /// correlation 1.00000 on the same material: |
| 2367 | /// |
| 2368 | /// ```text |
| 2369 | /// kbps 120 128 136 144 152 160 |
| 2370 | /// span A 0.945 0.937 0.452 0.206 0.223 0.163 |
| 2371 | /// span B 0.986 0.989 0.697 0.153 0.114 0.149 |
| 2372 | /// span C 0.999 0.994 0.951 0.335 0.266 0.326 |
| 2373 | /// libopus 0.997 0.998 -- -- -- 0.996 (same spans, control) |
| 2374 | /// ``` |
| 2375 | /// |
| 2376 | /// So: usable to 128, ruined by 136 on real film sound -- and mono worse, at |
| 2377 | /// every rate, which is why a mono mix kept the AAC path entirely. `ec-opus` |
| 2378 | /// has no such cliff: its own suite holds every rate of the format's table to |
| 2379 | /// the reference decoders, mono, stereo and 5.1 alike, and this project |
| 2380 | /// re-measures the high band and the mono path where the old encoder failed |
| 2381 | /// (`the_opus_encoder_is_pinned_to_the_band_it_was_measured_in`). |
| 2382 | /// |
| 2383 | /// It is still not *trusted*: every track is decoded again and measured before |
| 2384 | /// it is written ([`opus_fidelity`]), because a rate nobody measured on *your* |
| 2385 | /// sound is not something a constant can be safe against on its own. |
| 2386 | /// The ceiling is the Sound row's ([`AUDIO_KBPS`]), not the format's 510 kbps: |
| 2387 | /// a rate nothing in the product can ask for is a rate nothing here measures. |
| 2388 | /// 320 covers the row honestly, including the 256 default |
| 2389 | /// ([`DEFAULT_AUDIO_KBPS`]) the old cap silently halved on a Matroska export. |
| 2390 | pub const OPUS_MAX_KBPS: u32 = 320; |
| 2391 | |
| 2392 | /// How well a track has to survive its own round trip to be written as Opus: |
| 2393 | /// the correlation between the mix and the decode of what was encoded from it. |
| 2394 | /// A good encoder scores 0.98-0.999 on this material (libopus, measured above); |
| 2395 | /// the failure mode is not subtle at all, scoring 0.1-0.7. 0.95 sits in the gap |
| 2396 | /// with room on both sides, and what fails it is written as AAC -- the export's |
| 2397 | /// own encoder line then says AAC, so the fallback is visible rather than |
| 2398 | /// silent. |
| 2399 | const OPUS_MIN_FIDELITY: f64 = 0.95; |
| 2400 | |
| 2401 | /// The encoder's lookahead at [`OPUS_RATE`] in the mode this envelope always |
| 2402 | /// selects (CELT-only: 2.5 ms). The pre-skip a file states is this *plus* the |
| 2403 | /// warm-up frame [`encode_opus`] throws away. Measured by |
| 2404 | /// cross-correlating the decode against the source, not taken from the crate -- |
| 2405 | /// it exposes no lookahead getter -- and asserted at both ends of the rate band |
| 2406 | /// in `tests/opus_export.rs`, which is what catches a version that changes it. |
| 2407 | const OPUS_PRE_SKIP: u16 = 120; |
| 2408 | |
| 2409 | /// The mix as Opus packets, one per [`OPUS_FRAME`], plus the pre-skip that has |
| 2410 | /// to be declared in front of them. Mono or stereo, at [`OPUS_RATE`] -- the |
| 2411 | /// caller checks all of it, because outside that envelope this encoder is not |
| 2412 | /// one this project is willing to write files with ([`OPUS_MAX_KBPS`]). |
| 2413 | /// |
| 2414 | /// The tail frame is padded with silence rather than dropped: Opus codes whole |
| 2415 | /// frames and a track a few milliseconds short under a picture that is not is |
| 2416 | /// the drift every other path here is written to avoid. The pre-skip trims the |
| 2417 | /// front; the container's duration trims the back. |
| 2418 | |
| 2419 | |
| 2420 | |
| 2421 | |
| 2422 | |
| 2423 | |
| 2424 | |
| 2425 | |
| 2426 | |
| 2427 | |
| 2428 | |
| 2429 | |
| 2430 | |
| 2431 | |
| 2432 | |
| 2433 | |
| 2434 | |
| 2435 | |
| 2436 | |
| 2437 | |
| 2438 | |
| 2439 | |
| 2440 | |
| 2441 | |
| 2442 | |
| 2443 | |
| 2444 | |
| 2445 | |
| 2446 | |
| 2447 | |
| 2448 | |
| 2449 | |
| 2450 | |
| 2451 | |
| 2452 | |
| 2453 | |
| 2454 | |
| 2455 | |
| 2456 | |
| 2457 | |
| 2458 | |
| 2459 | |
| 2460 | |
| 2461 | |
| 2462 | |
| 2463 | |
| 2464 | |
| 2465 | |
| 2466 | |
| 2467 | |
| 2468 | |
| 2469 | |
| 2470 | |
| 2471 | |
| 2472 | |
| 2473 | |
| 2474 | |
| 2475 | |
| 2476 | |
| 2477 | |
| 2478 | |
| 2479 | |
| 2480 | |
| 2481 | |
| 2482 | |
| 2483 | |
| 2484 | |
| 2485 | |
| 2486 | |
| 2487 | /// Packets one sampled window listens to: 5 s at [`OPUS_FRAME`]. |
| 2488 | const FIDELITY_WINDOW: usize = 250; |
| 2489 | |
| 2490 | /// How many of them a long track is judged on -- a minute of sound, wherever |
| 2491 | /// the track's length puts them, and a constant cost rather than one that grows |
| 2492 | /// with the film ([`opus_fidelity`]). |
| 2493 | const FIDELITY_WINDOWS: usize = 12; |
| 2494 | |
| 2495 | /// Packets decoded into a window and thrown away before it is measured. CELT |
| 2496 | /// predicts across frames, so a decoder started cold mid-stream is behind its |
| 2497 | /// own history for a few frames; 100 ms is far more than it needs and is not |
| 2498 | /// worth counting. |
| 2499 | const FIDELITY_WARMUP: usize = 5; |
| 2500 | |
| 2501 | /// How much sound a window must carry before its correlation means anything: |
| 2502 | /// mean square per sample. A window of digital silence -- the head of a film, |
| 2503 | /// the gap between a feature and its credits -- correlates with nothing, and |
| 2504 | /// failing a track for it would send perfectly good sound to AAC. |
| 2505 | const FIDELITY_FLOOR: f64 = 1e-9; |
| 2506 | |
| 2507 | /// The correlation between `samples` and the decode of `packets` with the first |
| 2508 | /// `pre_skip` frames dropped: 1.0 is the same waveform, and this codec's failure |
| 2509 | /// mode lands near 0.1. Streamed packet by packet -- the decode is never held, |
| 2510 | /// only three running sums -- because the mix behind it is already the biggest |
| 2511 | /// thing in an export ([`encode_audio`]'s corner-cut). |
| 2512 | /// |
| 2513 | /// A packet the decoder refuses is 0.0 and no argument: a track this project |
| 2514 | /// cannot read is exactly what this is here to catch. |
| 2515 | /// |
| 2516 | /// **Sampled above a minute of sound, and the median window is the answer.** |
| 2517 | /// This decode was the whole cost of exporting a feature film under the |
| 2518 | /// previous decoder: `ruopus` ran its inverse MDCT at 0.2x real time (measured, |
| 2519 | /// 24.2 s for 121.5 s of stereo; `ec-opus`, the decoder here now, is far |
| 2520 | /// quicker, and the sampling survives it because it costs almost nothing to |
| 2521 | /// keep), |
| 2522 | /// so judging every packet of a two-and-a-half-hour film costs half an hour |
| 2523 | /// before a byte of picture is written -- which is what it did, and what made a |
| 2524 | /// copy export that has no encoding to do at all sit at zero for twenty minutes. |
| 2525 | /// [`FIDELITY_WINDOWS`] windows spread evenly across the track cost the same |
| 2526 | /// minute of decode whatever the film's length, and what they are looking for |
| 2527 | /// survives sampling: [`OPUS_MAX_KBPS`]'s cliff is a *rate* the encoder falls |
| 2528 | /// off everywhere that rate is used, not a defect of one bar of music. |
| 2529 | /// |
| 2530 | /// The **median** and not the worst, and that is measured rather than cautious. |
| 2531 | /// Forty five-second windows of a real 5.1 film's mix, encoded here at 128 kbps |
| 2532 | /// and decoded back, in order: |
| 2533 | /// |
| 2534 | /// ```text |
| 2535 | /// 0.803 0.835 0.938 0.940 0.960 0.987 0.994 ... median 0.998 ... 0.999 |
| 2536 | /// ``` |
| 2537 | /// |
| 2538 | /// Five of the thirty-nine that carried sound sit under [`OPUS_MIN_FIDELITY`] on |
| 2539 | /// a track that is *good* -- which is the same thing the table in |
| 2540 | /// [`OPUS_MAX_KBPS`] shows, where a span scoring 0.937 at 128 kbps is inside the |
| 2541 | /// usable band. A worst-window rule at 0.95 therefore refuses films this encoder |
| 2542 | /// handles perfectly well, while the failure it exists for is the opposite |
| 2543 | /// shape: at 136 kbps the same three measured spans read 0.452, 0.697, 0.951, |
| 2544 | /// and at 256 kbps the whole track correlates 0.06. Half a track cannot be |
| 2545 | /// ruined without the middle of the list moving, so the median separates the two |
| 2546 | /// by a margin no single window can (0.998 against under 0.7) -- and a track |
| 2547 | /// under a minute is one window, where median and whole-track correlation are |
| 2548 | /// the same number the gate always used. |
| 2549 | |
| 2550 | |
| 2551 | |
| 2552 | |
| 2553 | |
| 2554 | |
| 2555 | |
| 2556 | |
| 2557 | |
| 2558 | |
| 2559 | |
| 2560 | |
| 2561 | |
| 2562 | |
| 2563 | |
| 2564 | |
| 2565 | |
| 2566 | |
| 2567 | |
| 2568 | |
| 2569 | |
| 2570 | |
| 2571 | |
| 2572 | |
| 2573 | |
| 2574 | |
| 2575 | |
| 2576 | |
| 2577 | |
| 2578 | |
| 2579 | |
| 2580 | |
| 2581 | |
| 2582 | |
| 2583 | |
| 2584 | |
| 2585 | /// [`opus_fidelity`] over `packets[measure..to]`, with `packets[from..measure]` |
| 2586 | /// -- the warm-up -- decoded for its state and thrown away. `None` where the |
| 2587 | /// source window carries no sound worth correlating ([`FIDELITY_FLOOR`]). |
| 2588 | |
| 2589 | |
| 2590 | |
| 2591 | |
| 2592 | |
| 2593 | |
| 2594 | |
| 2595 | |
| 2596 | |
| 2597 | |
| 2598 | |
| 2599 | |
| 2600 | |
| 2601 | |
| 2602 | |
| 2603 | |
| 2604 | |
| 2605 | |
| 2606 | |
| 2607 | |
| 2608 | |
| 2609 | |
| 2610 | |
| 2611 | |
| 2612 | |
| 2613 | |
| 2614 | |
| 2615 | |
| 2616 | |
| 2617 | |
| 2618 | |
| 2619 | |
| 2620 | |
| 2621 | |
| 2622 | |
| 2623 | |
| 2624 | |
| 2625 | |
| 2626 | |
| 2627 | |
| 2628 | |
| 2629 | |
| 2630 | |
| 2631 | |
| 2632 | |
| 2633 | |
| 2634 | /// The audio pass, running beside the picture: what [`run`] holds while it |
| 2635 | /// encodes and joins where the file it is writing needs the track. |
| 2636 | type AudioJob = JoinHandle; |
| 2637 | |
| 2638 | /// The pass while [`run`] holds it, joined however that function leaves -- |
| 2639 | /// including through a `?`. |
| 2640 | /// |
| 2641 | /// A [`JoinHandle`](thread::JoinHandle) that is merely dropped *detaches* its |
| 2642 | /// thread, and the one error that matters here is the hardware encoder's |
| 2643 | /// process dying ([`crate::hwproc`]): the whole export is then written again by |
| 2644 | /// [`start`], which starts an audio pass of its own. The abandoned one would go |
| 2645 | /// on mixing and encoding the same sound beside it -- two passes of a feature |
| 2646 | /// film's audio at once, on the machine that has just lost its GPU. Joined |
| 2647 | /// instead, so an export has one audio pass at a time and none outlives it. |
| 2648 | ; |
| 2649 | |
| 2650 | |
| 2651 | |
| 2652 | |
| 2653 | |
| 2654 | |
| 2655 | |
| 2656 | |
| 2657 | |
| 2658 | |
| 2659 | |
| 2660 | |
| 2661 | |
| 2662 | |
| 2663 | |
| 2664 | |
| 2665 | |
| 2666 | |
| 2667 | |
| 2668 | |
| 2669 | |
| 2670 | |
| 2671 | |
| 2672 | |
| 2673 | |
| 2674 | |
| 2675 | |
| 2676 | |
| 2677 | /// The pass's answer, or the failure that is the export's failure. A panicked |
| 2678 | /// audio thread reads as an error rather than as silence: an export that wrote |
| 2679 | /// its picture and quietly no sound is the one outcome this must not have. |
| 2680 | |
| 2681 | |
| 2682 | |
| 2683 | |
| 2684 | |
| 2685 | /// The encoder line a running export shows: the seat the picture is really |
| 2686 | /// being written by, and what the sound is -- or that the sound is still being |
| 2687 | /// worked out, which an overlapped audio pass is until it is collected. |
| 2688 | |
| 2689 | |
| 2690 | |
| 2691 | |
| 2692 | |
| 2693 | |
| 2694 | |
| 2695 | |
| 2696 | |
| 2697 | |
| 2698 | |
| 2699 | |
| 2700 | |
| 2701 | |
| 2702 | |
| 2703 | |
| 2704 | |
| 2705 | |
| 2706 | |
| 2707 | /// Hands a mix that finished mixing early to the mp4 it belongs in, the |
| 2708 | /// moment both exist: `late` may land before the first coded picture has |
| 2709 | /// opened `muxer` at all, so this is tried both right where the mix lands |
| 2710 | /// and after every picture written afterwards, and does nothing once |
| 2711 | /// `*fed` says an earlier try already succeeded. Declaring the track and |
| 2712 | /// queuing its packets here is what lets [`crate::mux::Mp4Muxer`]'s own |
| 2713 | /// hold interleave them under the pictures still to come, rather than the |
| 2714 | /// track landing all at once after the picture is done. |
| 2715 | |
| 2716 | |
| 2717 | |
| 2718 | |
| 2719 | |
| 2720 | |
| 2721 | |
| 2722 | |
| 2723 | |
| 2724 | |
| 2725 | |
| 2726 | |
| 2727 | |
| 2728 | |
| 2729 | |
| 2730 | |
| 2731 | |
| 2732 | |
| 2733 | |
| 2734 | |
| 2735 | |
| 2736 | |
| 2737 | |
| 2738 | |
| 2739 | |
| 2740 | |
| 2741 | |
| 2742 | |
| 2743 | |
| 2744 | |
| 2745 | |
| 2746 | |
| 2747 | |
| 2748 | |
| 2749 | |
| 2750 | |
| 2751 | |
| 2752 | |
| 2753 | |
| 2754 | |
| 2755 | |
| 2756 | |
| 2757 | |
| 2758 | |
| 2759 | |
| 2760 | |
| 2761 | |
| 2762 | |
| 2763 | |
| 2764 | |
| 2765 | |
| 2766 | |
| 2767 | |
| 2768 | |
| 2769 | |
| 2770 | |
| 2771 | |
| 2772 | |
| 2773 | |
| 2774 | |
| 2775 | |
| 2776 | |
| 2777 | |
| 2778 | |
| 2779 | |
| 2780 | |
| 2781 | |
| 2782 | |
| 2783 | |
| 2784 | |
| 2785 | |
| 2786 | |
| 2787 | |
| 2788 | |
| 2789 | |
| 2790 | |
| 2791 | |
| 2792 | |
| 2793 | |
| 2794 | |
| 2795 | |
| 2796 | |
| 2797 | |
| 2798 | |
| 2799 | |
| 2800 | |
| 2801 | |
| 2802 | |
| 2803 | |
| 2804 | |
| 2805 | |
| 2806 | |
| 2807 | |
| 2808 | |
| 2809 | |
| 2810 | |
| 2811 | |
| 2812 | |
| 2813 | |
| 2814 | |
| 2815 | |
| 2816 | |
| 2817 | |
| 2818 | |
| 2819 | |
| 2820 | |
| 2821 | |
| 2822 | |
| 2823 | |
| 2824 | |
| 2825 | |
| 2826 | |
| 2827 | |
| 2828 | |
| 2829 | |
| 2830 | |
| 2831 | |
| 2832 | |
| 2833 | |
| 2834 | |
| 2835 | |
| 2836 | |
| 2837 | |
| 2838 | |
| 2839 | |
| 2840 | |
| 2841 | |
| 2842 | |
| 2843 | |
| 2844 | |
| 2845 | |
| 2846 | |
| 2847 | |
| 2848 | |
| 2849 | |
| 2850 | |
| 2851 | |
| 2852 | |
| 2853 | |
| 2854 | |
| 2855 | |
| 2856 | |
| 2857 | |
| 2858 | |
| 2859 | |
| 2860 | |
| 2861 | |
| 2862 | |
| 2863 | |
| 2864 | |
| 2865 | |
| 2866 | |
| 2867 | |
| 2868 | |
| 2869 | |
| 2870 | |
| 2871 | |
| 2872 | |
| 2873 | |
| 2874 | |
| 2875 | |
| 2876 | |
| 2877 | |
| 2878 | |
| 2879 | |
| 2880 | |
| 2881 | |
| 2882 | |
| 2883 | |
| 2884 | |
| 2885 | |
| 2886 | |
| 2887 | |
| 2888 | |
| 2889 | |
| 2890 | |
| 2891 | |
| 2892 | |
| 2893 | |
| 2894 | |
| 2895 | |
| 2896 | |
| 2897 | |
| 2898 | |
| 2899 | |
| 2900 | |
| 2901 | |
| 2902 | |
| 2903 | |
| 2904 | |
| 2905 | |
| 2906 | |
| 2907 | |
| 2908 | |
| 2909 | |
| 2910 | |
| 2911 | |
| 2912 | |
| 2913 | |
| 2914 | |
| 2915 | |
| 2916 | |
| 2917 | |
| 2918 | |
| 2919 | |
| 2920 | |
| 2921 | |
| 2922 | |
| 2923 | |
| 2924 | |
| 2925 | |
| 2926 | |
| 2927 | |
| 2928 | |
| 2929 | |
| 2930 | |
| 2931 | |
| 2932 | |
| 2933 | |
| 2934 | |
| 2935 | |
| 2936 | |
| 2937 | |
| 2938 | |
| 2939 | |
| 2940 | |
| 2941 | |
| 2942 | |
| 2943 | |
| 2944 | |
| 2945 | |
| 2946 | |
| 2947 | |
| 2948 | |
| 2949 | |
| 2950 | |
| 2951 | |
| 2952 | |
| 2953 | |
| 2954 | |
| 2955 | |
| 2956 | |
| 2957 | |
| 2958 | |
| 2959 | |
| 2960 | |
| 2961 | |
| 2962 | |
| 2963 | |
| 2964 | |
| 2965 | |
| 2966 | |
| 2967 | |
| 2968 | |
| 2969 | |
| 2970 | |
| 2971 | |
| 2972 | |
| 2973 | |
| 2974 | |
| 2975 | |
| 2976 | |
| 2977 | |
| 2978 | |
| 2979 | |
| 2980 | |
| 2981 | |
| 2982 | |
| 2983 | |
| 2984 | |
| 2985 | |
| 2986 | |
| 2987 | |
| 2988 | |
| 2989 | |
| 2990 | |
| 2991 | |
| 2992 | |
| 2993 | |
| 2994 | |
| 2995 | |
| 2996 | |
| 2997 | |
| 2998 | |
| 2999 | |
| 3000 | |
| 3001 | |
| 3002 | |
| 3003 | |
| 3004 | |
| 3005 | |
| 3006 | |
| 3007 | |
| 3008 | |
| 3009 | |
| 3010 | |
| 3011 | |
| 3012 | |
| 3013 | |
| 3014 | |
| 3015 | |
| 3016 | |
| 3017 | |
| 3018 | |
| 3019 | |
| 3020 | |
| 3021 | |
| 3022 | |
| 3023 | |
| 3024 | |
| 3025 | |
| 3026 | |
| 3027 | |
| 3028 | |
| 3029 | |
| 3030 | |
| 3031 | |
| 3032 | |
| 3033 | |
| 3034 | |
| 3035 | |
| 3036 | |
| 3037 | |
| 3038 | |
| 3039 | |
| 3040 | |
| 3041 | |
| 3042 | |
| 3043 | |
| 3044 | |
| 3045 | |
| 3046 | |
| 3047 | |
| 3048 | |
| 3049 | |
| 3050 | |
| 3051 | |
| 3052 | |
| 3053 | |
| 3054 | |
| 3055 | |
| 3056 | |
| 3057 | |
| 3058 | |
| 3059 | |
| 3060 | |
| 3061 | |
| 3062 | |
| 3063 | |
| 3064 | |
| 3065 | |
| 3066 | |
| 3067 | |
| 3068 | |
| 3069 | |
| 3070 | |
| 3071 | |
| 3072 | |
| 3073 | |
| 3074 | |
| 3075 | |
| 3076 | |
| 3077 | |
| 3078 | |
| 3079 | |
| 3080 | |
| 3081 | |
| 3082 | |
| 3083 | |
| 3084 | |
| 3085 | |
| 3086 | |
| 3087 | |
| 3088 | |
| 3089 | |
| 3090 | |
| 3091 | |
| 3092 | |
| 3093 | |
| 3094 | |
| 3095 | |
| 3096 | |
| 3097 | |
| 3098 | |
| 3099 | |
| 3100 | |
| 3101 | |
| 3102 | |
| 3103 | |
| 3104 | |
| 3105 | |
| 3106 | |
| 3107 | |
| 3108 | |
| 3109 | |
| 3110 | |
| 3111 | |
| 3112 | |
| 3113 | |
| 3114 | |
| 3115 | |
| 3116 | |
| 3117 | |
| 3118 | |
| 3119 | |
| 3120 | |
| 3121 | |
| 3122 | |
| 3123 | |
| 3124 | |
| 3125 | |
| 3126 | |
| 3127 | |
| 3128 | |
| 3129 | |
| 3130 | |
| 3131 | |
| 3132 | |
| 3133 | |
| 3134 | |
| 3135 | |
| 3136 | |
| 3137 | |
| 3138 | |
| 3139 | |
| 3140 | |
| 3141 | |
| 3142 | |
| 3143 | |
| 3144 | |
| 3145 | |
| 3146 | |
| 3147 | |
| 3148 | |
| 3149 | |
| 3150 | |
| 3151 | |
| 3152 | |
| 3153 | |
| 3154 | |
| 3155 | |
| 3156 | |
| 3157 | |
| 3158 | |
| 3159 | |
| 3160 | |
| 3161 | |
| 3162 | |
| 3163 | |
| 3164 | |
| 3165 | |
| 3166 | |
| 3167 | |
| 3168 | |
| 3169 | |
| 3170 | |
| 3171 | |
| 3172 | |
| 3173 | |
| 3174 | |
| 3175 | |
| 3176 | |
| 3177 | |
| 3178 | |
| 3179 | |
| 3180 | |
| 3181 | |
| 3182 | |
| 3183 | |
| 3184 | |
| 3185 | |
| 3186 | |
| 3187 | |
| 3188 | |
| 3189 | |
| 3190 | |
| 3191 | |
| 3192 | |
| 3193 | |
| 3194 | |
| 3195 | |
| 3196 | |
| 3197 | |
| 3198 | |
| 3199 | |
| 3200 | |
| 3201 | |
| 3202 | |
| 3203 | |
| 3204 | |
| 3205 | |
| 3206 | |
| 3207 | |
| 3208 | |
| 3209 | |
| 3210 | |
| 3211 | |
| 3212 | |
| 3213 | |
| 3214 | |
| 3215 | |
| 3216 | |
| 3217 | |
| 3218 | |
| 3219 | |
| 3220 | |
| 3221 | |
| 3222 | |
| 3223 | |
| 3224 | |
| 3225 | |
| 3226 | |
| 3227 | |
| 3228 | |
| 3229 | |
| 3230 | |
| 3231 | |
| 3232 | |
| 3233 | |
| 3234 | |
| 3235 | |
| 3236 | |
| 3237 | |
| 3238 | |
| 3239 | |
| 3240 | |
| 3241 | |
| 3242 | |
| 3243 | |
| 3244 | |
| 3245 | |
| 3246 | |
| 3247 | |
| 3248 | |
| 3249 | |
| 3250 | |
| 3251 | |
| 3252 | |
| 3253 | |
| 3254 | |
| 3255 | |
| 3256 | |
| 3257 | |
| 3258 | |
| 3259 | |
| 3260 | |
| 3261 | |
| 3262 | |
| 3263 | |
| 3264 | |
| 3265 | |
| 3266 | |
| 3267 | |
| 3268 | |
| 3269 | |
| 3270 | |
| 3271 | |
| 3272 | |
| 3273 | |
| 3274 | |
| 3275 | |
| 3276 | |
| 3277 | |
| 3278 | |
| 3279 | |
| 3280 | |
| 3281 | |
| 3282 | |
| 3283 | |
| 3284 | |
| 3285 | |
| 3286 | |
| 3287 | |
| 3288 | |
| 3289 | |
| 3290 | |
| 3291 | |
| 3292 | |
| 3293 | |
| 3294 | |
| 3295 | |
| 3296 | |
| 3297 | |
| 3298 | |
| 3299 | |
| 3300 | |
| 3301 | |
| 3302 | |
| 3303 | |
| 3304 | |
| 3305 | |
| 3306 | |
| 3307 | |
| 3308 | |
| 3309 | |
| 3310 | |
| 3311 | |
| 3312 | |
| 3313 | |
| 3314 | |
| 3315 | |
| 3316 | |
| 3317 | |
| 3318 | |
| 3319 | |
| 3320 | |
| 3321 | |
| 3322 | |
| 3323 | |
| 3324 | |
| 3325 | |
| 3326 | |
| 3327 | |
| 3328 | |
| 3329 | |
| 3330 | |
| 3331 | |
| 3332 | |
| 3333 | |
| 3334 | |
| 3335 | |
| 3336 | |
| 3337 | |
| 3338 | |
| 3339 | |
| 3340 | |
| 3341 | |
| 3342 | |
| 3343 | |
| 3344 | |
| 3345 | |
| 3346 | |
| 3347 | |
| 3348 | |
| 3349 | |
| 3350 | |
| 3351 | |
| 3352 | |
| 3353 | |
| 3354 | |
| 3355 | |
| 3356 | |
| 3357 | |
| 3358 | |
| 3359 | |
| 3360 | |
| 3361 | |
| 3362 | |
| 3363 | |
| 3364 | |
| 3365 | |
| 3366 | |
| 3367 | |
| 3368 | |
| 3369 | |
| 3370 | |
| 3371 | |
| 3372 | |
| 3373 | |
| 3374 | |
| 3375 | |
| 3376 | |
| 3377 | |
| 3378 | |
| 3379 | |
| 3380 | |
| 3381 | |
| 3382 | |
| 3383 | |
| 3384 | |
| 3385 | |
| 3386 | |
| 3387 | |
| 3388 | |
| 3389 | |
| 3390 | |
| 3391 | |
| 3392 | |
| 3393 | |
| 3394 | |
| 3395 | |
| 3396 | |
| 3397 | |
| 3398 | |
| 3399 | |
| 3400 | |
| 3401 | |
| 3402 | |
| 3403 | |
| 3404 | |
| 3405 | |
| 3406 | |
| 3407 | |
| 3408 | |
| 3409 | |
| 3410 | |
| 3411 | |
| 3412 | |
| 3413 | |
| 3414 | |
| 3415 | |
| 3416 | |
| 3417 | |
| 3418 | |
| 3419 | |
| 3420 | |
| 3421 | |
| 3422 | |
| 3423 | |
| 3424 | |
| 3425 | |
| 3426 | |
| 3427 | |
| 3428 | |
| 3429 | |
| 3430 | /// One decoded picture turned, graded, tone-mapped, remapped and placed on the |
| 3431 | /// canvas -- everything between a source's own samples and the ones an encoder |
| 3432 | /// is fed, which is exactly the work a zero-copy span has none of. |
| 3433 | /// |
| 3434 | /// `rotation` first, before the grade: it is the file's own display matrix, the |
| 3435 | /// turn a player would make before showing the picture at all, and everything |
| 3436 | /// after this -- the grade, the letterbox, the encoder -- is about the picture |
| 3437 | /// as it is *meant* to be seen. `turned`, `graded` and `canvas` are the span's |
| 3438 | /// scratch: the planes come back borrowed from one of them, or from the picture |
| 3439 | /// itself where not a byte was touched. |
| 3440 | |
| 3441 | |
| 3442 | |
| 3443 | |
| 3444 | |
| 3445 | |
| 3446 | |
| 3447 | |
| 3448 | |
| 3449 | |
| 3450 | |
| 3451 | |
| 3452 | |
| 3453 | |
| 3454 | |
| 3455 | |
| 3456 | |
| 3457 | |
| 3458 | |
| 3459 | |
| 3460 | |
| 3461 | |
| 3462 | |
| 3463 | |
| 3464 | |
| 3465 | |
| 3466 | |
| 3467 | |
| 3468 | |
| 3469 | |
| 3470 | |
| 3471 | |
| 3472 | |
| 3473 | |
| 3474 | |
| 3475 | |
| 3476 | |
| 3477 | |
| 3478 | |
| 3479 | |
| 3480 | |
| 3481 | |
| 3482 | |
| 3483 | |
| 3484 | |
| 3485 | |
| 3486 | |
| 3487 | |
| 3488 | |
| 3489 | |
| 3490 | |
| 3491 | |
| 3492 | |
| 3493 | |
| 3494 | |
| 3495 | |
| 3496 | |
| 3497 | |
| 3498 | |
| 3499 | |
| 3500 | |
| 3501 | |
| 3502 | |
| 3503 | |
| 3504 | |
| 3505 | |
| 3506 | |
| 3507 | |
| 3508 | |
| 3509 | |
| 3510 | |
| 3511 | |
| 3512 | |
| 3513 | |
| 3514 | |
| 3515 | |
| 3516 | |
| 3517 | |
| 3518 | |
| 3519 | |
| 3520 | |
| 3521 | |
| 3522 | |
| 3523 | |
| 3524 | |
| 3525 | |
| 3526 | |
| 3527 | |
| 3528 | |
| 3529 | |
| 3530 | |
| 3531 | |
| 3532 | |
| 3533 | |
| 3534 | |
| 3535 | |
| 3536 | |
| 3537 | |
| 3538 | |
| 3539 | |
| 3540 | |
| 3541 | |
| 3542 | |
| 3543 | |
| 3544 | |
| 3545 | |
| 3546 | |
| 3547 | |
| 3548 | |
| 3549 | |
| 3550 | |
| 3551 | |
| 3552 | |
| 3553 | |
| 3554 | |
| 3555 | |
| 3556 | /// Which matrix pair a span's samples are rewritten by on the way into a file |
| 3557 | /// whose own matrix is `out` -- `None` when they are already coded against it, |
| 3558 | /// and for a gap, whose 16/128/128 black is black in every matrix here. |
| 3559 | /// |
| 3560 | /// `toned` says the tone map ran on this span: it hands back BT.709 SDR whatever |
| 3561 | /// the source was coded as, so an HDR clip is never *also* given the matrix |
| 3562 | /// treatment its BT.2020 tag would ask for -- one conversion or the other, never |
| 3563 | /// both on one frame -- while a tone-mapped clip on a canvas below 720 lines |
| 3564 | /// still takes its 709 -> 601 step. |
| 3565 | |
| 3566 | |
| 3567 | |
| 3568 | |
| 3569 | |
| 3570 | |
| 3571 | |
| 3572 | |
| 3573 | |
| 3574 | |
| 3575 | |
| 3576 | |
| 3577 | /// What rate `path` was shot at against a timeline at `timeline_fps` |
| 3578 | /// ([`Rate`]). [`Rate::REAL_TIME`] for the files that have no rate of their own |
| 3579 | /// -- a still, a song -- and for one that will not open here: the decoder is |
| 3580 | /// opened a few lines later and fails the export by name, which is a better |
| 3581 | /// error than this one could raise. |
| 3582 | |
| 3583 | |
| 3584 | |
| 3585 | |
| 3586 | |
| 3587 | |
| 3588 | |
| 3589 | |
| 3590 | |
| 3591 | |
| 3592 | |
| 3593 | |
| 3594 | |
| 3595 | |
| 3596 | |
| 3597 | |
| 3598 | |
| 3599 | |
| 3600 | |
| 3601 | |
| 3602 | |
| 3603 | |
| 3604 | |
| 3605 | |
| 3606 | |
| 3607 | |
| 3608 | |
| 3609 | |
| 3610 | |
| 3611 | |
| 3612 | |
| 3613 | |
| 3614 | |
| 3615 | |
| 3616 | |
| 3617 | |
| 3618 | |
| 3619 | |
| 3620 | |
| 3621 | |
| 3622 | |
| 3623 | |
| 3624 | |
| 3625 | |
| 3626 | |
| 3627 | |
| 3628 | |
| 3629 | |
| 3630 | |
| 3631 | |
| 3632 | |
| 3633 | |
| 3634 | |
| 3635 | |
| 3636 | |
| 3637 | /// The audio lanes alone, summed, as a WAV or a FLAC. |
| 3638 | /// |
| 3639 | /// Nothing here re-derives the edit: the play lists are |
| 3640 | /// [`Project::audio_segments_from`] and they are handed to the very |
| 3641 | /// [`AudioSession::open_mixed_streams`] playback feeds from, so what is written |
| 3642 | /// is what was heard -- every lane, mixed the same way, gaps included, which |
| 3643 | /// arrive as real silence from that choke point rather than as a hole this would |
| 3644 | /// have to invent. |
| 3645 | /// |
| 3646 | /// The length is the *timeline's*: each segment resolves its window to whole |
| 3647 | /// samples on its own, so the sum can miss the timeline by a sample or two, and |
| 3648 | /// a source that runs out early would leave the file short. Both are settled by |
| 3649 | /// one `resize` at the end -- padding with silence, trimming what overshot -- |
| 3650 | /// so an exported file is exactly as long as what was edited. |
| 3651 | |
| 3652 | |
| 3653 | |
| 3654 | |
| 3655 | |
| 3656 | |
| 3657 | |
| 3658 | |
| 3659 | |
| 3660 | |
| 3661 | |
| 3662 | |
| 3663 | |
| 3664 | |
| 3665 | |
| 3666 | |
| 3667 | |
| 3668 | |
| 3669 | |
| 3670 | |
| 3671 | |
| 3672 | |
| 3673 | |
| 3674 | |
| 3675 | |
| 3676 | |
| 3677 | |
| 3678 | |
| 3679 | |
| 3680 | |
| 3681 | |
| 3682 | |
| 3683 | |
| 3684 | |
| 3685 | |
| 3686 | |
| 3687 | |
| 3688 | |
| 3689 | |
| 3690 | |
| 3691 | |
| 3692 | |
| 3693 | |
| 3694 | |
| 3695 | |
| 3696 | |
| 3697 | |
| 3698 | |
| 3699 | |
| 3700 | |
| 3701 | |
| 3702 | |
| 3703 | |
| 3704 | |
| 3705 | |
| 3706 | |
| 3707 | |
| 3708 | |
| 3709 | |
| 3710 | |
| 3711 | |
| 3712 | |
| 3713 | |
| 3714 | |
| 3715 | |
| 3716 | |
| 3717 | |
| 3718 | |
| 3719 | |
| 3720 | |
| 3721 | |
| 3722 | |
| 3723 | |
| 3724 | |
| 3725 | |
| 3726 | |
| 3727 | |
| 3728 | |
| 3729 | |
| 3730 | |
| 3731 | |
| 3732 | |
| 3733 | |
| 3734 | |
| 3735 | |
| 3736 | |
| 3737 | |
| 3738 | |
| 3739 | |
| 3740 | |
| 3741 | /// 16-bit PCM at the timeline's own rate and layout: no resampling anywhere in |
| 3742 | /// this engine, so what the decoder handed over is what the header says. |
| 3743 | |
| 3744 | |
| 3745 | |
| 3746 | |
| 3747 | |
| 3748 | |
| 3749 | |
| 3750 | |
| 3751 | |
| 3752 | |
| 3753 | |
| 3754 | |
| 3755 | |
| 3756 | |
| 3757 | |
| 3758 | |
| 3759 | |
| 3760 | |
| 3761 | |
| 3762 | /// The same samples as MPEG-1 Layer III, `ec-mp3` doing the encoding -- the |
| 3763 | /// family's own, taking the seat at the same contract (CBR in, frames out, |
| 3764 | /// `Mp3EncoderConfig`'s fields are the old seat's names), so the swap cost the |
| 3765 | /// call sites nothing. |
| 3766 | /// |
| 3767 | /// CBR at the caller's rate, [`DEFAULT_AUDIO_KBPS`] where there was none. Every |
| 3768 | /// offered rate is already a legal Layer III value, so the encoder's snap is a |
| 3769 | /// backstop and not a silent substitution; a sample rate MPEG has no frame for |
| 3770 | /// (anything but the nine MPEG rates 8-48 kHz) is refused there by name rather |
| 3771 | /// than written as something else. |
| 3772 | /// |
| 3773 | /// corner-cut: CBR only -- the card offers rates and not a quality index. Upgrade |
| 3774 | /// path is `Mp3EncoderConfig::vbr_quality` behind a setting of its own. |
| 3775 | |
| 3776 | |
| 3777 | |
| 3778 | |
| 3779 | |
| 3780 | |
| 3781 | |
| 3782 | |
| 3783 | |
| 3784 | |
| 3785 | |
| 3786 | |
| 3787 | |
| 3788 | |
| 3789 | |
| 3790 | |
| 3791 | |
| 3792 | |
| 3793 | |
| 3794 | |
| 3795 | |
| 3796 | |
| 3797 | |
| 3798 | /// Where the Vorbis rate loop starts, on `ec-vorbis`'s normalised `[0, 1]` |
| 3799 | /// scale, beside [`VORBIS_TARGET_BPS`] -- the two numbers every `.ogg` this |
| 3800 | /// program writes is coded at. |
| 3801 | /// |
| 3802 | /// A measured operating point, not a taste (2026-09-13 bench, every output |
| 3803 | /// decoded back with **symphonia** -- an independent decoder, and the very one |
| 3804 | /// [`crate::audio`] reopens an export with). The incumbent seat's own 0.85 -- |
| 3805 | /// its top quality that still decoded every fixture to exactly its own length |
| 3806 | /// -- measured 124-176 kbps across this suite's fixtures with correlation |
| 3807 | /// 0.9947-0.9957 against the source. The quality knob alone on the new seat |
| 3808 | /// saturates well under that band (0.98 lands ~87 kbps on a 30-second music |
| 3809 | /// clip), so the seat is driven the way its own rate gates are measured: the |
| 3810 | /// loop starts at 0.85 and is held to a 128 kbps target, which landed |
| 3811 | /// 124-134 kbps actual on the same inputs and beat the incumbent at its own |
| 3812 | /// operating point on every one of them -- correlation 0.9968 against 0.9947 |
| 3813 | /// on the music clip, +3.1 dB PSNR -- at the same size of file. Against |
| 3814 | /// ffmpeg's own libvorbis at `-q 5` (125.8 kbps actual on the same clip) it |
| 3815 | /// reads 0.9968 against 0.9973: par at the same rate. |
| 3816 | const VORBIS_QUALITY: f32 = 0.85; |
| 3817 | |
| 3818 | /// The rate [`VORBIS_QUALITY`]'s loop is held to, in bits per second. Measured |
| 3819 | /// landing within +1..+5% of target across the bench's inputs; the Sound row |
| 3820 | /// stays refused for this format because this target is the encoder's measured |
| 3821 | /// operating point, not a number a card may offer. |
| 3822 | const VORBIS_TARGET_BPS: i32 = 128_000; |
| 3823 | |
| 3824 | /// The same samples as Vorbis I in an Ogg container: `ec-vorbis` encodes, |
| 3825 | /// `oxideav-ogg` pages. Pure Rust on both halves, like every other encoder here. |
| 3826 | /// |
| 3827 | /// The old seat's two corrections are gone with it, and the going is measured |
| 3828 | /// rather than assumed (2026-09-13, every output decoded back with symphonia). |
| 3829 | /// This encoder numbers its packets the spec's way -- the first audio packet |
| 3830 | /// at granule 0, every packet after at the absolute sample position its block |
| 3831 | /// ends on -- and clamps its final granule to the sample count it was fed, so |
| 3832 | /// a decoder trims the block grid's tail on its own. Written straight through, |
| 3833 | /// every file decodes to exactly the timeline's frame count with the |
| 3834 | /// correlation peak at lag zero, which is what the one-hop pre-roll and the |
| 3835 | /// two granule corrections this function used to carry around the old encoder |
| 3836 | /// were for. |
| 3837 | /// |
| 3838 | /// **Stereo, always.** The format row promises stereo, so a mono mix is |
| 3839 | /// written as dual mono, both channels bit-identical (measured: `max|L-R|` is |
| 3840 | /// exactly 0; the encoder's own channel coupling codes the empty side channel |
| 3841 | /// for almost nothing). The encoder would serve a mono stream, but the row |
| 3842 | /// says stereo and folding the file back down must give exactly what was |
| 3843 | /// mixed. Wider than stereo cannot reach here -- [`crate::audio`] folds 5.1 |
| 3844 | /// to stereo when the source is opened -- but it is refused by name rather |
| 3845 | /// than left to the library's own message. |
| 3846 | /// |
| 3847 | /// corner-cut: one operating point, [`VORBIS_QUALITY`] + |
| 3848 | /// [`VORBIS_TARGET_BPS`], with no user control -- the Sound row is refused for |
| 3849 | /// this format. Upgrade path is a quality picker of its own, worth building |
| 3850 | /// the day the card has a control that speaks in quality rather than kbps. |
| 3851 | |
| 3852 | |
| 3853 | |
| 3854 | |
| 3855 | |
| 3856 | |
| 3857 | |
| 3858 | |
| 3859 | |
| 3860 | |
| 3861 | |
| 3862 | |
| 3863 | |
| 3864 | |
| 3865 | |
| 3866 | |
| 3867 | |
| 3868 | |
| 3869 | |
| 3870 | |
| 3871 | |
| 3872 | |
| 3873 | |
| 3874 | |
| 3875 | |
| 3876 | |
| 3877 | |
| 3878 | |
| 3879 | |
| 3880 | |
| 3881 | |
| 3882 | |
| 3883 | |
| 3884 | |
| 3885 | |
| 3886 | |
| 3887 | |
| 3888 | |
| 3889 | |
| 3890 | |
| 3891 | |
| 3892 | |
| 3893 | |
| 3894 | |
| 3895 | |
| 3896 | |
| 3897 | |
| 3898 | |
| 3899 | |
| 3900 | |
| 3901 | |
| 3902 | |
| 3903 | |
| 3904 | |
| 3905 | |
| 3906 | |
| 3907 | |
| 3908 | |
| 3909 | |
| 3910 | |
| 3911 | |
| 3912 | |
| 3913 | |
| 3914 | |
| 3915 | |
| 3916 | |
| 3917 | |
| 3918 | |
| 3919 | |
| 3920 | |
| 3921 | |
| 3922 | |
| 3923 | |
| 3924 | |
| 3925 | |
| 3926 | |
| 3927 | |
| 3928 | |
| 3929 | |
| 3930 | |
| 3931 | |
| 3932 | |
| 3933 | |
| 3934 | |
| 3935 | |
| 3936 | |
| 3937 | |
| 3938 | |
| 3939 | |
| 3940 | |
| 3941 | |
| 3942 | /// The page size [`write_ogg`] asks the Ogg muxer to aim at, in bytes. RFC 3533 |
| 3943 | /// describes pages as "usually 4-8 kB", which is also the muxer's own suggested |
| 3944 | /// general-purpose value. |
| 3945 | const OGG_PAGE_BYTES: usize = 4096; |
| 3946 | |
| 3947 | /// The same samples, losslessly compressed. `flacenc`'s errors are flattened to |
| 3948 | /// text: they are not `Send + Sync`, and every one of them fails the export the |
| 3949 | /// same way. |
| 3950 | |
| 3951 | |
| 3952 | |
| 3953 | |
| 3954 | |
| 3955 | |
| 3956 | |
| 3957 | |
| 3958 | |
| 3959 | |
| 3960 | |
| 3961 | |
| 3962 | |
| 3963 | |
| 3964 | |
| 3965 | |
| 3966 | |
| 3967 | |
| 3968 | |
| 3969 | |
| 3970 | |
| 3971 | |
| 3972 | |
| 3973 | |
| 3974 | |
| 3975 | |
| 3976 | |
| 3977 | |
| 3978 | |
| 3979 | |
| 3980 | |
| 3981 | |
| 3982 | |
| 3983 | /// The I420 planes of one black picture, allocated once for a whole export: a |
| 3984 | /// gap in the video lane is encoded, not skipped, or every frame after it would |
| 3985 | /// arrive early. Limited-range black is `Y=16, U=V=128`, the same convention |
| 3986 | /// [`crate::convert`] decodes with. |
| 3987 | |
| 3988 | |
| 3989 | |
| 3990 | |
| 3991 | |
| 3992 | |
| 3993 | |
| 3994 | |
| 3995 | |
| 3996 | |
| 3997 | |
| 3998 | |
| 3999 | |
| 4000 | |
| 4001 | |
| 4002 | |
| 4003 | |
| 4004 | |
| 4005 | |
| 4006 | |
| 4007 | |
| 4008 | |
| 4009 | |
| 4010 | /// `Err` once a cancel has been asked for. Called at every point where the work |
| 4011 | /// left is more than an instant, so an `esc` at 99.9% still stops the export |
| 4012 | /// instead of quietly completing it. |
| 4013 | |
| 4014 | |
| 4015 | |
| 4016 | |
| 4017 | |
| 4018 | |
| 4019 | |
| 4020 | /// The two containers an export writes, so the picture loop above is one loop: |
| 4021 | /// H.264 goes into mp4, AV1 into Matroska, and nothing else is offered. |
| 4022 | |
| 4023 | |
| 4024 | |
| 4025 | |
| 4026 | |
| 4027 | |
| 4028 | |
| 4029 | |
| 4030 | |
| 4031 | |
| 4032 | |
| 4033 | |
| 4034 | |
| 4035 | |
| 4036 | /// Test-only panic point, so the worker's own `catch_unwind` branch in |
| 4037 | /// [`start`] is reachable without a codec parser that actually panics: the |
| 4038 | /// variable names the one `.part` whose export dies, and no export but that |
| 4039 | /// one ever matches it, so a concurrent export in the same process is safe. |
| 4040 | |
| 4041 | |
| 4042 | |
| 4043 | |
| 4044 | |
| 4045 | |
| 4046 | /// Writes one access unit, creating the file on the first one -- the parameter |
| 4047 | /// sets for `avcC` (and the sequence header for `CodecPrivate`) only exist once |
| 4048 | /// the encoder has coded something. Units with no coded slice are skipped: a |
| 4049 | /// software encoder may hand back an empty buffer while it buffers, and the |
| 4050 | /// muxer rejects a sample that would carry no picture. |
| 4051 | |
| 4052 | |
| 4053 | |
| 4054 | |
| 4055 | |
| 4056 | |
| 4057 | |
| 4058 | |
| 4059 | |
| 4060 | |
| 4061 | |
| 4062 | |
| 4063 | |
| 4064 | |
| 4065 | |
| 4066 | |
| 4067 | |
| 4068 | |
| 4069 | |
| 4070 | |
| 4071 | |
| 4072 | |
| 4073 | |
| 4074 | |
| 4075 | |
| 4076 | |
| 4077 | |
| 4078 | |
| 4079 | |
| 4080 | |
| 4081 | |
| 4082 | |
| 4083 | |
| 4084 | |
| 4085 | |
| 4086 | |
| 4087 | |
| 4088 | |
| 4089 | |
| 4090 | |
| 4091 | |
| 4092 | |
| 4093 | |
| 4094 | |
| 4095 | |
| 4096 | |
| 4097 | |
| 4098 | |
| 4099 | |
| 4100 | |
| 4101 | |
| 4102 | |
| 4103 | |
| 4104 | |
| 4105 | |
| 4106 | |
| 4107 | |
| 4108 | |
| 4109 | |
| 4110 | |
| 4111 | |
| 4112 | |
| 4113 | |
| 4114 | |
| 4115 | |
| 4116 | |
| 4117 | |
| 4118 | |
| 4119 | |
| 4120 | |
| 4121 | |
| 4122 | |
| 4123 | |
| 4124 | |
| 4125 | |
| 4126 | |
| 4127 | |
| 4128 | |
| 4129 | |
| 4130 | |
| 4131 | |
| 4132 | |
| 4133 | |
| 4134 | |
| 4135 | |
| 4136 | |
| 4137 | |
| 4138 | |
| 4139 | |
| 4140 | |
| 4141 | |
| 4142 | |
| 4143 | |
| 4144 | |
| 4145 | |
| 4146 | |
| 4147 | |
| 4148 | |
| 4149 | |
| 4150 | |
| 4151 | |
| 4152 | |
| 4153 | |
| 4154 | |
| 4155 | |
| 4156 | |
| 4157 | |
| 4158 | |
| 4159 | |
| 4160 | |
| 4161 | |
| 4162 | |
| 4163 | |
| 4164 | |
| 4165 | |
| 4166 | |
| 4167 | |
| 4168 | |
| 4169 | |
| 4170 | |
| 4171 | |
| 4172 | |
| 4173 | |
| 4174 | |
| 4175 | |
| 4176 | |
| 4177 | |
| 4178 | |
| 4179 | |
| 4180 | |
| 4181 | |
| 4182 | |
| 4183 | |
| 4184 | |
| 4185 | |
| 4186 | |
| 4187 | |
| 4188 | |
| 4189 | |
| 4190 | |
| 4191 | |
| 4192 | |
| 4193 | |
| 4194 | |
| 4195 | |
| 4196 | |
| 4197 | |
| 4198 | |
| 4199 | |
| 4200 | |
| 4201 | |
| 4202 | /// The `hvcC` record of the first coded unit, or the refusal by name. Split out |
| 4203 | /// because both HEVC containers ask it in the same words. |
| 4204 | |
| 4205 | |
| 4206 | |
| 4207 | |
| 4208 | |
| 4209 | |
| 4210 | |
| 4211 | |
| 4212 | |
| 4213 | |
| 4214 | |
| 4215 | |
| 4216 | |
| 4217 | |
| 4218 | /// Hardware where it is available, software everywhere else -- chosen once for |
| 4219 | /// the whole export, so the stream never changes encoder mid-file. Both codecs |
| 4220 | /// have both seats: an AV1 export runs on the plugin's VA-API encoder where the |
| 4221 | /// GPU has one and on `rav1e` where it has not, which is the same pair H.264 has |
| 4222 | /// had and the same silent fallback. |
| 4223 | |
| 4224 | |
| 4225 | |
| 4226 | |
| 4227 | |
| 4228 | |
| 4229 | |
| 4230 | |
| 4231 | |
| 4232 | |
| 4233 | |
| 4234 | |
| 4235 | |
| 4236 | |
| 4237 | |
| 4238 | |
| 4239 | |
| 4240 | |
| 4241 | |
| 4242 | |
| 4243 | |
| 4244 | |
| 4245 | |
| 4246 | |
| 4247 | |
| 4248 | |
| 4249 | |
| 4250 | |
| 4251 | |
| 4252 | |
| 4253 | |
| 4254 | |
| 4255 | |
| 4256 | |
| 4257 | /// The intra HEVC seat. Frames arrive one at a time (the export walk is one |
| 4258 | /// picture per timeline frame) and are held until there is a lane for each, |
| 4259 | /// then coded in parallel and queued in **display order**. `ec-h265`'s |
| 4260 | /// wavefront spreads one picture across the workers it is given and the lanes |
| 4261 | /// spread the frames across the machine, so decode and render keep filling |
| 4262 | /// the next batch while this one codes -- a seat that coded one picture at a |
| 4263 | /// time would serialize the whole walk behind its encoder (measured: 7.4 fps |
| 4264 | /// against 11.8 at 1080p on the same box, which is the regression this |
| 4265 | /// batching exists to prevent). |
| 4266 | /// |
| 4267 | /// corner-cut: a batch of display-size planes sits in memory (~3 MB a frame |
| 4268 | /// at 1080p, so ~37 MB at 12 lanes) and the tail of a timeline is coded on |
| 4269 | /// fewer lanes than the middle. Upgrade path is a pipeline that keeps every |
| 4270 | /// lane fed from a decoder running ahead of the encoder rather than a batch |
| 4271 | /// barrier. |
| 4272 | |
| 4273 | |
| 4274 | |
| 4275 | |
| 4276 | |
| 4277 | |
| 4278 | |
| 4279 | |
| 4280 | |
| 4281 | |
| 4282 | |
| 4283 | |
| 4284 | |
| 4285 | |
| 4286 | |
| 4287 | |
| 4288 | |
| 4289 | |
| 4290 | |
| 4291 | |
| 4292 | |
| 4293 | |
| 4294 | |
| 4295 | |
| 4296 | |
| 4297 | |
| 4298 | |
| 4299 | |
| 4300 | |
| 4301 | |
| 4302 | |
| 4303 | |
| 4304 | |
| 4305 | |
| 4306 | |
| 4307 | |
| 4308 | |
| 4309 | |
| 4310 | |
| 4311 | |
| 4312 | |
| 4313 | |
| 4314 | |
| 4315 | |
| 4316 | |
| 4317 | |
| 4318 | |
| 4319 | |
| 4320 | |
| 4321 | |
| 4322 | |
| 4323 | |
| 4324 | |
| 4325 | |
| 4326 | |
| 4327 | |
| 4328 | |
| 4329 | |
| 4330 | |
| 4331 | |
| 4332 | |
| 4333 | |
| 4334 | |
| 4335 | |
| 4336 | |
| 4337 | |
| 4338 | |
| 4339 | |
| 4340 | |
| 4341 | |
| 4342 | |
| 4343 | |
| 4344 | |
| 4345 | |
| 4346 | |
| 4347 | |
| 4348 | |
| 4349 | |
| 4350 | |
| 4351 | |
| 4352 | |
| 4353 | |
| 4354 | |
| 4355 | |
| 4356 | |
| 4357 | |
| 4358 | |
| 4359 | |
| 4360 | |
| 4361 | |
| 4362 | |
| 4363 | |
| 4364 | |
| 4365 | |
| 4366 | |
| 4367 | |
| 4368 | |
| 4369 | |
| 4370 | |
| 4371 | |
| 4372 | |
| 4373 | |
| 4374 | |
| 4375 | |
| 4376 | |
| 4377 | |
| 4378 | |
| 4379 | |
| 4380 | |
| 4381 | |
| 4382 | |
| 4383 | |
| 4384 | |
| 4385 | |
| 4386 | |
| 4387 | |
| 4388 | |
| 4389 | |
| 4390 | |
| 4391 | |
| 4392 | |
| 4393 | |
| 4394 | |
| 4395 | |
| 4396 | |
| 4397 | |
| 4398 | |
| 4399 | |
| 4400 | |
| 4401 | |
| 4402 | |
| 4403 | |
| 4404 | |
| 4405 | |
| 4406 | |
| 4407 | |
| 4408 | |
| 4409 | |
| 4410 | |
| 4411 | |
| 4412 | |
| 4413 | |
| 4414 | |
| 4415 | |
| 4416 | |
| 4417 | |
| 4418 | |
| 4419 | |
| 4420 | |
| 4421 | |
| 4422 | |
| 4423 | |
| 4424 | |
| 4425 | |
| 4426 | |
| 4427 | |
| 4428 | |
| 4429 | |
| 4430 | |
| 4431 | |
| 4432 | |
| 4433 | |
| 4434 | |
| 4435 | |
| 4436 | |
| 4437 | |
| 4438 | |
| 4439 | |
| 4440 | |
| 4441 | |
| 4442 | |
| 4443 | |
| 4444 | |
| 4445 | |
| 4446 | |
| 4447 | |
| 4448 | |
| 4449 | |
| 4450 | |
| 4451 | |
| 4452 | |
| 4453 | |
| 4454 | |
| 4455 | |
| 4456 | |
| 4457 | |
| 4458 | |
| 4459 | |
| 4460 | |
| 4461 | |
| 4462 | |
| 4463 | |
| 4464 | |
| 4465 | |
| 4466 | |
| 4467 | |
| 4468 | |
| 4469 | |
| 4470 | |
| 4471 | |
| 4472 | |
| 4473 | |
| 4474 | |
| 4475 | |
| 4476 | |
| 4477 | |
| 4478 | |
| 4479 | |
| 4480 | |
| 4481 | |
| 4482 | |
| 4483 | |
| 4484 | |
| 4485 | |
| 4486 | |
| 4487 | |
| 4488 | |
| 4489 | |
| 4490 | |
| 4491 | |
| 4492 | |
| 4493 | |
| 4494 | |
| 4495 | |
| 4496 | |
| 4497 | |
| 4498 | |
| 4499 | |
| 4500 | |
| 4501 | |
| 4502 | |
| 4503 | |
| 4504 | |
| 4505 | |
| 4506 | |
| 4507 | |
| 4508 | |
| 4509 | |
| 4510 | |
| 4511 | |
| 4512 | |
| 4513 | |
| 4514 | |
| 4515 | |
| 4516 | |
| 4517 | |
| 4518 | |
| 4519 | |
| 4520 | |
| 4521 | |
| 4522 | |
| 4523 | |
| 4524 | |
| 4525 | |
| 4526 | |
| 4527 | |
| 4528 | |
| 4529 | |
| 4530 | |
| 4531 | |
| 4532 | |
| 4533 | |
| 4534 | |
| 4535 | |
| 4536 | |
| 4537 | |
| 4538 | |
| 4539 | |
| 4540 | |
| 4541 | |
| 4542 | |
| 4543 | |
| 4544 | |
| 4545 | |
| 4546 | |
| 4547 | |
| 4548 | |
| 4549 | |
| 4550 | |
| 4551 | |
| 4552 | |
| 4553 | |
| 4554 | |
| 4555 | |
| 4556 | |
| 4557 | |
| 4558 | |
| 4559 | |
| 4560 | |
| 4561 | |
| 4562 | |
| 4563 | |
| 4564 | |
| 4565 | |
| 4566 | |
| 4567 | |
| 4568 | |
| 4569 | |
| 4570 | |
| 4571 | |
| 4572 | |
| 4573 | |
| 4574 | |
| 4575 | |
| 4576 | |
| 4577 | |
| 4578 | |
| 4579 | |
| 4580 | |
| 4581 | |
| 4582 | |
| 4583 | |
| 4584 | |
| 4585 | |
| 4586 | |
| 4587 | |
| 4588 | |
| 4589 | |
| 4590 | |
| 4591 | |
| 4592 | |
| 4593 | |
| 4594 | |
| 4595 | |
| 4596 | |
| 4597 | |
| 4598 | |
| 4599 | |
| 4600 | |
| 4601 | |
| 4602 | |
| 4603 | |
| 4604 | |
| 4605 | |
| 4606 | |
| 4607 | |
| 4608 | |
| 4609 | |
| 4610 | |
| 4611 | |
| 4612 | |
| 4613 | |
| 4614 | |
| 4615 | |
| 4616 | |
| 4617 | |
| 4618 | |
| 4619 | |
| 4620 | |
| 4621 | |
| 4622 | |
| 4623 | |
| 4624 | |
| 4625 | |
| 4626 | |
| 4627 | |
| 4628 | |
| 4629 | |
| 4630 | |
| 4631 | |
| 4632 | |
| 4633 | |
| 4634 | |
| 4635 | |
| 4636 | |
| 4637 | |
| 4638 | |
| 4639 | |
| 4640 | |
| 4641 | |
| 4642 | |
| 4643 | |
| 4644 | |
| 4645 | |
| 4646 | |
| 4647 | |
| 4648 | |
| 4649 | |
| 4650 | |
| 4651 | |
| 4652 | |
| 4653 | |
| 4654 | |
| 4655 | |
| 4656 | |
| 4657 | |
| 4658 | |
| 4659 | |
| 4660 | |
| 4661 | |
| 4662 | |
| 4663 | |
| 4664 | |
| 4665 | |
| 4666 | |
| 4667 | |
| 4668 | |
| 4669 | |
| 4670 | |
| 4671 | |
| 4672 | |
| 4673 | |
| 4674 | |
| 4675 | |
| 4676 | |
| 4677 | |
| 4678 | |
| 4679 | |
| 4680 | |
| 4681 | |
| 4682 | |
| 4683 | |
| 4684 | |
| 4685 | |
| 4686 | |
| 4687 | |
| 4688 | |
| 4689 | |
| 4690 | |
| 4691 | |
| 4692 | |
| 4693 | |
| 4694 | |
| 4695 | |
| 4696 | |
| 4697 | |
| 4698 | |
| 4699 | |
| 4700 | |
| 4701 | |
| 4702 | |
| 4703 | |
| 4704 | |
| 4705 | |
| 4706 | |
| 4707 | |
| 4708 | |
| 4709 | |
| 4710 | |
| 4711 | |
| 4712 | |
| 4713 | |
| 4714 | |
| 4715 | |
| 4716 | |
| 4717 | |
| 4718 | |
| 4719 | |
| 4720 | |
| 4721 | |
| 4722 | |
| 4723 | |
| 4724 | |
| 4725 | |
| 4726 | |
| 4727 | |
| 4728 | |
| 4729 | |
| 4730 | |
| 4731 | /// The oldest coded intra AU, lent out under the same "valid until the next |
| 4732 | /// call" contract [`pop_av1`] has. Every one of them is an IDR, so the key |
| 4733 | /// flag is not a guess. |
| 4734 | |
| 4735 | |
| 4736 | |
| 4737 | |
| 4738 | /// The quantiser an intra HEVC export codes at, mapped from the *bitrate* row a |
| 4739 | /// user picked -- the card has no QP control and this codec has no rate control, |
| 4740 | /// so the two are joined by measurement rather than promised to each other. |
| 4741 | /// |
| 4742 | /// The encoder codes ~0.6 bits per pixel at QP 27 ([`HEVC_BPP_AT_27`], measured |
| 4743 | /// on the 720p and 1080p benches to within 4% of each other), and a step of 6 QP |
| 4744 | /// is a factor of two in rate, which is the classic HEVC relation. So the QP |
| 4745 | /// that would land on a target is `27 + 6 * log2(0.6 / target)` -- and it is |
| 4746 | /// clamped, because this is a *quality* dial and not a rate controller: below QP |
| 4747 | /// 22 the file grows without a picture to show for it, and past QP 40 an |
| 4748 | /// intra-only frame goes blocky in a way no bitrate row asked for. A 1080p30 |
| 4749 | /// timeline at the automatic 6.2 Mbps therefore codes at QP 40 and comes out |
| 4750 | /// bigger than that, which is what "intra-only, large files" on the format row |
| 4751 | /// means: the row buys quality, not a size. |
| 4752 | |
| 4753 | |
| 4754 | |
| 4755 | |
| 4756 | |
| 4757 | |
| 4758 | |
| 4759 | /// What the *bitstream* says the samples mean, in the words a sequence header |
| 4760 | /// spells them -- the same H.273 code points [`crate::mux`] writes into the |
| 4761 | /// container, from the same [`ColorDescription::output`] rule, so the two halves |
| 4762 | /// of a file cannot drift apart. |
| 4763 | /// |
| 4764 | /// This exists because a container tag is not enough: libavcodec takes the |
| 4765 | /// bitstream's answer first, and a stream that says nothing is "unspecified", |
| 4766 | /// which renders BT.601 -- a visible shift on a 709 export that a player reads |
| 4767 | /// from the wrong matrix. Every export is limited range, which is what |
| 4768 | /// `video_full_range_flag = false` says here. |
| 4769 | |
| 4770 | |
| 4771 | |
| 4772 | |
| 4773 | |
| 4774 | |
| 4775 | |
| 4776 | |
| 4777 | |
| 4778 | |
| 4779 | |
| 4780 | |
| 4781 | |
| 4782 | |
| 4783 | |
| 4784 | /// Every temporal unit `rav1e` has finished, moved into the queue in display |
| 4785 | /// order. `NeedMoreData` (send another picture) and `LimitReached` (the flush is |
| 4786 | /// through) are the two ways it says there is nothing more; `Encoded` means a |
| 4787 | /// picture was coded but not yet packetised, which is a *keep asking* -- taking |
| 4788 | /// it for an end leaves the tail of the export inside the encoder. |
| 4789 | |
| 4790 | |
| 4791 | |
| 4792 | |
| 4793 | |
| 4794 | |
| 4795 | |
| 4796 | |
| 4797 | |
| 4798 | |
| 4799 | |
| 4800 | |
| 4801 | |
| 4802 | |
| 4803 | |
| 4804 | /// The oldest finished unit, moved into the buffer that is lent out -- the same |
| 4805 | /// "valid until the next call" contract the plugin's slice has. |
| 4806 | |
| 4807 | |
| 4808 | |
| 4809 | |
| 4810 | |
| 4811 | |
| 4812 | |
| 4813 | |
| 4814 | |
| 4815 | /// I420 straight out of the decoder: the export never converts to BGRA and back, |
| 4816 | /// which would cost two conversions and a generation of colour precision. |
| 4817 | /// |
| 4818 | /// This mirrors `decode`'s two worker loops rather than reusing `DecodeSession`, |
| 4819 | /// which only speaks BGRA. A hardware decode that fails *before* the first |
| 4820 | /// picture falls back to software, exactly as playback's does -- nothing has |
| 4821 | /// been encoded yet, so the span can be taken over cleanly. One that fails |
| 4822 | /// after the first picture fails the export, which then deletes the |
| 4823 | /// half-written file: a restart there would re-encode what the muxer holds. |
| 4824 | |
| 4825 | |
| 4826 | |
| 4827 | |
| 4828 | |
| 4829 | |
| 4830 | |
| 4831 | |
| 4832 | |
| 4833 | |
| 4834 | |
| 4835 | |
| 4836 | |
| 4837 | |
| 4838 | |
| 4839 | |
| 4840 | |
| 4841 | |
| 4842 | |
| 4843 | |
| 4844 | |
| 4845 | |
| 4846 | |
| 4847 | |
| 4848 | |
| 4849 | |
| 4850 | |
| 4851 | |
| 4852 | |
| 4853 | |
| 4854 | |
| 4855 | |
| 4856 | |
| 4857 | |
| 4858 | |
| 4859 | |
| 4860 | /// The receiving half of a decode thread, plus the picture it last handed out |
| 4861 | /// -- which is what lets `next` keep lending planes rather than moving them. |
| 4862 | /// |
| 4863 | /// The first two fields are in this order on purpose, and it is the order |
| 4864 | /// [`crate::decode::FrameStream`] states for the same pair: Rust drops fields as |
| 4865 | /// they are declared, so the receiver disconnects *first* -- the only thing that |
| 4866 | /// wakes a decoder parked in a full `send` -- and the join inside |
| 4867 | /// [`DecodeThread::drop`] runs second. The other way round is a hang and not a |
| 4868 | /// slow path. |
| 4869 | |
| 4870 | |
| 4871 | |
| 4872 | |
| 4873 | |
| 4874 | |
| 4875 | |
| 4876 | |
| 4877 | |
| 4878 | |
| 4879 | |
| 4880 | |
| 4881 | |
| 4882 | /// A decode thread, joined when its span's decoder is dropped -- the rule |
| 4883 | /// [`crate::decode::Worker`] is written for: a thread abandoned mid |
| 4884 | /// `vaInitialize` outlives the process, and Mesa's `atexit` handlers then free |
| 4885 | /// the state it is still reading, which is a SIGSEGV at exit long after the |
| 4886 | /// export succeeded. |
| 4887 | >>); |
| 4888 | |
| 4889 | |
| 4890 | |
| 4891 | |
| 4892 | |
| 4893 | |
| 4894 | |
| 4895 | |
| 4896 | |
| 4897 | |
| 4898 | |
| 4899 | |
| 4900 | /// One picture on its way from a decode thread to the encoder: its bytes, or |
| 4901 | /// the GPU buffer they are still in. |
| 4902 | |
| 4903 | |
| 4904 | |
| 4905 | |
| 4906 | |
| 4907 | |
| 4908 | |
| 4909 | |
| 4910 | |
| 4911 | |
| 4912 | |
| 4913 | |
| 4914 | |
| 4915 | |
| 4916 | |
| 4917 | |
| 4918 | |
| 4919 | |
| 4920 | |
| 4921 | |
| 4922 | |
| 4923 | |
| 4924 | |
| 4925 | |
| 4926 | |
| 4927 | |
| 4928 | |
| 4929 | |
| 4930 | |
| 4931 | /// One picture as the export loop sees it: planes to grade and place, or a |
| 4932 | /// buffer that goes straight into the encoder. |
| 4933 | |
| 4934 | |
| 4935 | |
| 4936 | |
| 4937 | |
| 4938 | |
| 4939 | |
| 4940 | |
| 4941 | |
| 4942 | |
| 4943 | |
| 4944 | |
| 4945 | |
| 4946 | |
| 4947 | |
| 4948 | |
| 4949 | |
| 4950 | |
| 4951 | |
| 4952 | |
| 4953 | |
| 4954 | |
| 4955 | |
| 4956 | |
| 4957 | |
| 4958 | |
| 4959 | |
| 4960 | |
| 4961 | |
| 4962 | |
| 4963 | |
| 4964 | |
| 4965 | |
| 4966 | |
| 4967 | |
| 4968 | |
| 4969 | |
| 4970 | |
| 4971 | |
| 4972 | |
| 4973 | |
| 4974 | |
| 4975 | |
| 4976 | |
| 4977 | |
| 4978 | |
| 4979 | |
| 4980 | |
| 4981 | |
| 4982 | |
| 4983 | |
| 4984 | |
| 4985 | |
| 4986 | |
| 4987 | |
| 4988 | |
| 4989 | |
| 4990 | |
| 4991 | |
| 4992 | |
| 4993 | |
| 4994 | |
| 4995 | |
| 4996 | |
| 4997 | |
| 4998 | |
| 4999 | |
| 5000 | |
| 5001 | |
| 5002 | |
| 5003 | |
| 5004 | |
| 5005 | |
| 5006 | |
| 5007 | |
| 5008 | |
| 5009 | |
| 5010 | |
| 5011 | |
| 5012 | |
| 5013 | |
| 5014 | |
| 5015 | |
| 5016 | |
| 5017 | |
| 5018 | |
| 5019 | |
| 5020 | |
| 5021 | |
| 5022 | |
| 5023 | |
| 5024 | |
| 5025 | |
| 5026 | |
| 5027 | |
| 5028 | |
| 5029 | |
| 5030 | |
| 5031 | |
| 5032 | |
| 5033 | |
| 5034 | |
| 5035 | |
| 5036 | |
| 5037 | |
| 5038 | |
| 5039 | |
| 5040 | |
| 5041 | |
| 5042 | |
| 5043 | |
| 5044 | |
| 5045 | |
| 5046 | |
| 5047 | |
| 5048 | /// One span's decode, on its own thread: open the file (hardware if the plugin |
| 5049 | /// will have it, software otherwise) and send every picture until the encoder |
| 5050 | /// stops taking them. |
| 5051 | /// |
| 5052 | /// Hardware that fails before the first picture falls back to the software seat |
| 5053 | /// (see the loop's `decoded == 0` arm); one that fails after it fails the |
| 5054 | /// export, which then deletes the half-written file. |
| 5055 | /// |
| 5056 | /// Every way this returns says which way it was, down the channel: a picture, an |
| 5057 | /// error, or the `Ok(None)` that *is* end of stream. Closing the channel is not |
| 5058 | /// one of them -- a silent close is a panicked thread, and the receiver treats |
| 5059 | /// it as the failure it is rather than as a source that ran out. |
| 5060 | |
| 5061 | |
| 5062 | |
| 5063 | |
| 5064 | |
| 5065 | |
| 5066 | |
| 5067 | |
| 5068 | |
| 5069 | |
| 5070 | |
| 5071 | |
| 5072 | |
| 5073 | |
| 5074 | |
| 5075 | |
| 5076 | |
| 5077 | |
| 5078 | |
| 5079 | |
| 5080 | |
| 5081 | |
| 5082 | |
| 5083 | |
| 5084 | |
| 5085 | |
| 5086 | |
| 5087 | |
| 5088 | |
| 5089 | |
| 5090 | |
| 5091 | |
| 5092 | |
| 5093 | |
| 5094 | |
| 5095 | |
| 5096 | |
| 5097 | |
| 5098 | |
| 5099 | |
| 5100 | |
| 5101 | |
| 5102 | |
| 5103 | |
| 5104 | |
| 5105 | |
| 5106 | |
| 5107 | |
| 5108 | |
| 5109 | |
| 5110 | |
| 5111 | |
| 5112 | |
| 5113 | |
| 5114 | |
| 5115 | |
| 5116 | |
| 5117 | |
| 5118 | |
| 5119 | |
| 5120 | |
| 5121 | |
| 5122 | /// The two stream decoders, on the thread that opened them. |
| 5123 | |
| 5124 | |
| 5125 | |
| 5126 | |
| 5127 | |
| 5128 | |
| 5129 | |
| 5130 | |
| 5131 | |
| 5132 | |
| 5133 | |
| 5134 | |
| 5135 | |
| 5136 | |
| 5137 | |
| 5138 | |
| 5139 | |
| 5140 | |
| 5141 | |
| 5142 | |
| 5143 | |
| 5144 | |
| 5145 | |
| 5146 | |
| 5147 | |
| 5148 | |
| 5149 | |
| 5150 | |
| 5151 | |
| 5152 | |
| 5153 | |
| 5154 | |
| 5155 | |
| 5156 | |
| 5157 | |
| 5158 | |
| 5159 | |
| 5160 | |
| 5161 | |
| 5162 | |
| 5163 | |
| 5164 | |
| 5165 | |
| 5166 | |
| 5167 | |
| 5168 | |
| 5169 | |
| 5170 | |
| 5171 | |
| 5172 | |
| 5173 | |
| 5174 | |
| 5175 | |
| 5176 | |
| 5177 | |
| 5178 | |
| 5179 | |
| 5180 | |
| 5181 | |
| 5182 | |
| 5183 | |
| 5184 | |
| 5185 | |
| 5186 | |
| 5187 | |
| 5188 | |
| 5189 | |
| 5190 | |
| 5191 | |
| 5192 | |
| 5193 | |
| 5194 | |
| 5195 | |
| 5196 | |
| 5197 | |
| 5198 | |
| 5199 | |
| 5200 | |
| 5201 | |
| 5202 | |
| 5203 | |
| 5204 | |
| 5205 | |
| 5206 | |
| 5207 | |
| 5208 | |
| 5209 | |
| 5210 | |
| 5211 | |
| 5212 | |
| 5213 | |
| 5214 | |
| 5215 | |
| 5216 | |
| 5217 | |
| 5218 | |
| 5219 | |
| 5220 | |
| 5221 | |
| 5222 | |
| 5223 | |
| 5224 | |
| 5225 | |
| 5226 | |
| 5227 | |
| 5228 | |
| 5229 | |
| 5230 | |
| 5231 | |
| 5232 | |
| 5233 | |
| 5234 | |
| 5235 | |
| 5236 | |
| 5237 | |
| 5238 | |
| 5239 | |
| 5240 | |
| 5241 | |
| 5242 | |
| 5243 | |
| 5244 | |
| 5245 | |
| 5246 | |
| 5247 | |
| 5248 | |
| 5249 | |
| 5250 | |
| 5251 | |
| 5252 | |
| 5253 | |
| 5254 | |
| 5255 | |
| 5256 | |
| 5257 | |
| 5258 | |
| 5259 | |
| 5260 | |
| 5261 | |
| 5262 | |
| 5263 | |
| 5264 | |
| 5265 | |
| 5266 | |
| 5267 | |
| 5268 | |
| 5269 | |
| 5270 | |
| 5271 | |
| 5272 | |
| 5273 | |
| 5274 | |
| 5275 | |
| 5276 | |
| 5277 | |
| 5278 | |
| 5279 | |
| 5280 | |
| 5281 | |
| 5282 | |
| 5283 | |
| 5284 | |
| 5285 | |
| 5286 | |
| 5287 | |
| 5288 | |
| 5289 | |
| 5290 | |
| 5291 | |
| 5292 | |
| 5293 | |
| 5294 | |
| 5295 | |
| 5296 | |
| 5297 | |
| 5298 | |
| 5299 | |
| 5300 | |
| 5301 | |
| 5302 | |
| 5303 | |
| 5304 | |
| 5305 | |
| 5306 | |
| 5307 | |
| 5308 | |
| 5309 | |
| 5310 | |
| 5311 | |
| 5312 | |
| 5313 | |
| 5314 | |
| 5315 | |
| 5316 | |
| 5317 | |
| 5318 | |
| 5319 | |
| 5320 | |
| 5321 | |
| 5322 | |
| 5323 | |
| 5324 | |
| 5325 | |
| 5326 | |
| 5327 | |
| 5328 | |
| 5329 | |
| 5330 | |
| 5331 | |
| 5332 | |
| 5333 | |
| 5334 | |
| 5335 | |
| 5336 | |
| 5337 | |
| 5338 | |
| 5339 | |
| 5340 | |
| 5341 | |
| 5342 | |
| 5343 | |
| 5344 | |
| 5345 | |
| 5346 | |
| 5347 | |
| 5348 | |
| 5349 | |
| 5350 | |
| 5351 | |
| 5352 | |
| 5353 | |
| 5354 | |
| 5355 | |
| 5356 | |
| 5357 | |
| 5358 | |
| 5359 | |
| 5360 | |
| 5361 | |
| 5362 | |
| 5363 | |
| 5364 | |
| 5365 | |
| 5366 | |
| 5367 | |
| 5368 | |
| 5369 | |
| 5370 | |
| 5371 | |
| 5372 | |
| 5373 | |
| 5374 | |
| 5375 | |
| 5376 | |
| 5377 | |
| 5378 | |
| 5379 | |
| 5380 | |
| 5381 | |
| 5382 | |
| 5383 | |
| 5384 | |
| 5385 | |
| 5386 | |
| 5387 | |
| 5388 | |
| 5389 | |
| 5390 | |
| 5391 | |
| 5392 | |
| 5393 | |
| 5394 | |
| 5395 | |
| 5396 | |
| 5397 | |
| 5398 | |
| 5399 | |
| 5400 | |
| 5401 | |
| 5402 | |
| 5403 | |
| 5404 | |
| 5405 | |
| 5406 | |
| 5407 | |
| 5408 | |
| 5409 | |
| 5410 | |
| 5411 | |
| 5412 | |
| 5413 | |
| 5414 | |
| 5415 | |
| 5416 | |
| 5417 | |
| 5418 | |
| 5419 | |
| 5420 | |
| 5421 | |
| 5422 | |
| 5423 | |
| 5424 | |
| 5425 | |
| 5426 | |
| 5427 | |
| 5428 | |
| 5429 | |
| 5430 | |
| 5431 | |
| 5432 | |
| 5433 | |
| 5434 | |
| 5435 | |
| 5436 | |
| 5437 | |
| 5438 | |
| 5439 | |
| 5440 | |
| 5441 | |
| 5442 | |
| 5443 | |
| 5444 | |
| 5445 | |
| 5446 | |
| 5447 | |
| 5448 | |
| 5449 | |
| 5450 | |
| 5451 | |
| 5452 | |
| 5453 | |
| 5454 | |
| 5455 | |
| 5456 | |
| 5457 | |
| 5458 | |
| 5459 | |
| 5460 | |
| 5461 | |
| 5462 | |
| 5463 | |
| 5464 | |
| 5465 | |
| 5466 | |
| 5467 | |
| 5468 | |
| 5469 | |
| 5470 | |
| 5471 | |
| 5472 | |
| 5473 | |
| 5474 | |
| 5475 | |
| 5476 | |
| 5477 | |
| 5478 | |
| 5479 | |
| 5480 | |
| 5481 | |
| 5482 | |
| 5483 | |
| 5484 | |
| 5485 | |
| 5486 | |
| 5487 | |
| 5488 | |
| 5489 | |
| 5490 | |
| 5491 | |
| 5492 | |
| 5493 | |
| 5494 | |
| 5495 | |
| 5496 | |
| 5497 | |
| 5498 | |
| 5499 | |
| 5500 | |
| 5501 | |
| 5502 | |
| 5503 | |
| 5504 | |
| 5505 | |
| 5506 | |
| 5507 | |
| 5508 | |
| 5509 | |
| 5510 | |
| 5511 | |
| 5512 | |
| 5513 | |
| 5514 | |
| 5515 | |
| 5516 | |
| 5517 | |
| 5518 | |
| 5519 | |
| 5520 | |
| 5521 | |
| 5522 | |
| 5523 | |
| 5524 | |
| 5525 | |
| 5526 | |
| 5527 | |
| 5528 | |
| 5529 | |
| 5530 | |
| 5531 | |
| 5532 | |
| 5533 | |
| 5534 | |
| 5535 | |
| 5536 | |
| 5537 | |
| 5538 | |
| 5539 | |
| 5540 | |
| 5541 | |
| 5542 | |
| 5543 | |
| 5544 | |
| 5545 | |
| 5546 | |
| 5547 | |
| 5548 | |
| 5549 | |
| 5550 | |
| 5551 | |
| 5552 | |
| 5553 | |
| 5554 | |
| 5555 | |
| 5556 | |
| 5557 | |
| 5558 | |
| 5559 | |
| 5560 | |
| 5561 | |
| 5562 | |
| 5563 | |
| 5564 | |
| 5565 | |
| 5566 | |
| 5567 | |
| 5568 | |
| 5569 | |
| 5570 | |
| 5571 | |
| 5572 | |
| 5573 | |
| 5574 | |
| 5575 | |
| 5576 | |
| 5577 | |
| 5578 | |
| 5579 | |
| 5580 | |
| 5581 | |
| 5582 | |
| 5583 | |
| 5584 | |
| 5585 | |
| 5586 | |
| 5587 | |
| 5588 | |
| 5589 | |
| 5590 | |
| 5591 | |
| 5592 | |
| 5593 | |
| 5594 | |
| 5595 | |
| 5596 | |
| 5597 | |
| 5598 | |
| 5599 | |
| 5600 | |
| 5601 | |
| 5602 | |
| 5603 | |
| 5604 | |
| 5605 | |
| 5606 | |
| 5607 | |
| 5608 | |
| 5609 | |
| 5610 | |
| 5611 | |
| 5612 | |
| 5613 | |
| 5614 | |
| 5615 | |
| 5616 | |
| 5617 | |
| 5618 | |
| 5619 | |
| 5620 | |
| 5621 | |
| 5622 | |
| 5623 | |
| 5624 | |
| 5625 | |
| 5626 | |
| 5627 | |
| 5628 | |
| 5629 | |
| 5630 | |
| 5631 | |
| 5632 | |
| 5633 | |
| 5634 | |
| 5635 | |
| 5636 | |
| 5637 | |
| 5638 | |
| 5639 | |
| 5640 | |
| 5641 | |
| 5642 | |
| 5643 | |
| 5644 | |
| 5645 | |
| 5646 | |
| 5647 | |
| 5648 | |
| 5649 | |
| 5650 | |
| 5651 | |
| 5652 | |
| 5653 | |
| 5654 | |
| 5655 | |
| 5656 | |
| 5657 | |
| 5658 | |
| 5659 | |
| 5660 | |
| 5661 | |
| 5662 | |
| 5663 | |
| 5664 | |
| 5665 | |
| 5666 | |
| 5667 | |
| 5668 | |
| 5669 | |
| 5670 | |
| 5671 | |
| 5672 | |
| 5673 | |
| 5674 | |
| 5675 | |
| 5676 | |
| 5677 | |
| 5678 | |
| 5679 | |
| 5680 | |
| 5681 | |
| 5682 | |
| 5683 | |
| 5684 | |
| 5685 | |
| 5686 | |
| 5687 | |
| 5688 | |
| 5689 | |
| 5690 | |
| 5691 | |
| 5692 | |
| 5693 | |
| 5694 | |
| 5695 | |
| 5696 | |
| 5697 | |
| 5698 | |
| 5699 | |
| 5700 | |
| 5701 | |
| 5702 | |
| 5703 | |
| 5704 | |
| 5705 | |
| 5706 | |
| 5707 | |
| 5708 | |
| 5709 | |
| 5710 | |
| 5711 | |
| 5712 | |
| 5713 | |
| 5714 | |
| 5715 | |
| 5716 | |
| 5717 | |
| 5718 | |
| 5719 | |
| 5720 | |
| 5721 | |
| 5722 | |
| 5723 | |
| 5724 | |
| 5725 | |
| 5726 | |
| 5727 | |
| 5728 | |
| 5729 | |
| 5730 | |
| 5731 | |
| 5732 | |
| 5733 | |
| 5734 | |
| 5735 | |
| 5736 | |
| 5737 | |
| 5738 | |
| 5739 | |
| 5740 | |
| 5741 | |
| 5742 | |
| 5743 | |
| 5744 | |
| 5745 | |
| 5746 | |
| 5747 | |
| 5748 | |
| 5749 | |
| 5750 | |
| 5751 | |
| 5752 | |
| 5753 | |
| 5754 | |
| 5755 | |
| 5756 | |
| 5757 | |
| 5758 | |
| 5759 | |
| 5760 | |
| 5761 | |
| 5762 | |
| 5763 | |
| 5764 | |
| 5765 | |
| 5766 | |
| 5767 | |
| 5768 | |
| 5769 | |
| 5770 | |
| 5771 | |
| 5772 | |
| 5773 | |
| 5774 | |
| 5775 | |
| 5776 | |
| 5777 | |
| 5778 | |
| 5779 | |
| 5780 | |
| 5781 | |
| 5782 | |
| 5783 | |
| 5784 | |
| 5785 | |
| 5786 | |
| 5787 | |
| 5788 | |
| 5789 | |
| 5790 | |
| 5791 | |
| 5792 | |
| 5793 | |
| 5794 | |
| 5795 | |
| 5796 | |
| 5797 | |
| 5798 | |
| 5799 | |
| 5800 | |
| 5801 | |
| 5802 | |
| 5803 | |
| 5804 | |
| 5805 | |
| 5806 | |
| 5807 | |
| 5808 | |
| 5809 | |
| 5810 | |
| 5811 | |
| 5812 | |
| 5813 | |
| 5814 | |
| 5815 | |
| 5816 | |
| 5817 | |
| 5818 | |
| 5819 | |
| 5820 | |
| 5821 | |
| 5822 | |
| 5823 | |
| 5824 | |
| 5825 | |
| 5826 | |
| 5827 | |
| 5828 | |
| 5829 | |
| 5830 | |
| 5831 | |
| 5832 | |
| 5833 | |
| 5834 | |
| 5835 | |
| 5836 | |
| 5837 | |
| 5838 | |
| 5839 | |
| 5840 | |
| 5841 | |
| 5842 | |
| 5843 | |
| 5844 | |
| 5845 | |
| 5846 | |
| 5847 | |
| 5848 | |
| 5849 | |
| 5850 | |
| 5851 | |
| 5852 | |
| 5853 | |
| 5854 | |
| 5855 | |
| 5856 | |
| 5857 | |
| 5858 | |
| 5859 | |
| 5860 | |
| 5861 | |
| 5862 | |
| 5863 | |
| 5864 | |
| 5865 | |
| 5866 | |
| 5867 | |
| 5868 | |
| 5869 | |
| 5870 | |
| 5871 | |
| 5872 | |
| 5873 | |
| 5874 | |
| 5875 | |
| 5876 | |
| 5877 | |
| 5878 | |
| 5879 | |
| 5880 | |
| 5881 | |
| 5882 | |
| 5883 | |
| 5884 | |
| 5885 | |
| 5886 | |
| 5887 | |
| 5888 | |
| 5889 | |
| 5890 | |
| 5891 | |
| 5892 | |
| 5893 | |
| 5894 | |
| 5895 | |
| 5896 | |
| 5897 | |
| 5898 | |
| 5899 | |
| 5900 | |
| 5901 | |
| 5902 | |
| 5903 | |
| 5904 | |
| 5905 | |
| 5906 | |
| 5907 | |
| 5908 | |
| 5909 | |
| 5910 | |
| 5911 | |
| 5912 | |
| 5913 | |
| 5914 | |
| 5915 | |
| 5916 | |
| 5917 | |
| 5918 | |
| 5919 | |
| 5920 | |
| 5921 | |
| 5922 | |
| 5923 | |
| 5924 | |
| 5925 | |
| 5926 | |
| 5927 | |
| 5928 | |
| 5929 | |
| 5930 | |
| 5931 | |
| 5932 | |
| 5933 | |
| 5934 | |
| 5935 | |
| 5936 | |
| 5937 | |
| 5938 | |
| 5939 | |
| 5940 | |
| 5941 | |
| 5942 | |
| 5943 | |
| 5944 | |
| 5945 | |
| 5946 | |
| 5947 | |
| 5948 | |
| 5949 | |
| 5950 | |
| 5951 | |
| 5952 | |
| 5953 | |
| 5954 | |
| 5955 |