edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiB6dae2b4Tahinli3 months ago555 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 the vendored `oxideav-h265`, which is the |
| 7 | //! only shape of a pure-Rust HEVC encode fast enough to wait for (its inter |
| 8 | //! modes code 1080p at 0.81 fps across 12 cores against the intra path's 4.30). |
| 9 | //! That makes it an intraframe master in the family of ProRes and DNxHD — large |
| 10 | //! files, every frame a cut point — and not a delivery codec. |
| 11 | //! |
| 12 | //! Picture and sound are both **copied wherever a copy says exactly what the |
| 13 | //! timeline says** — a copy is exact, free and never a generation of loss. For |
| 14 | //! the sound that is packet for packet ([`copy_audio`]); for the picture it is |
| 15 | //! block for block out of a Matroska source into a Matroska file ([`CopyPlan`]), |
| 16 | //! which is what makes a cut in a two-hour film cost the reading of it rather |
| 17 | //! than the re-encoding of it. The picture's copy is all-or-nothing per export, |
| 18 | //! because a copied span and an encoded one cannot share one track: what it |
| 19 | //! needs of a cut is that it lands on a sync point, and everything else — a |
| 20 | //! grade, a speed, a gap, a source of another size or codec, an mp4 — goes |
| 21 | //! through the encoder exactly as it always did. Where the *sound* cannot be |
| 22 | //! copied — a second audio lane to mix in, a speeded clip, an |
| 23 | //! equalized one, a source that is not AAC inside an mp4's own sample table — |
| 24 | //! the sound is decoded, mixed and encoded again with `rusty_aac` |
| 25 | //! ([`encode_audio`]). The audio-only formats have no such split: `hound` writes |
| 26 | //! PCM, `flacenc` encodes FLAC, `rusty_mp3` encodes MP3 and `rusty_vorbis` |
| 27 | //! encodes Vorbis, so those are always *decoded* out of the timeline. The worker owns everything: the caller gets an |
| 28 | //! [`ExportHandle`] and polls it from its render loop. |
| 29 | //! |
| 30 | //! **Every video format here carries the timeline's sound**, in whichever |
| 31 | //! container: the mp4 muxer writes an AAC track and so does the Matroska one. |
| 32 | //! Nothing is written picture-only and nothing is left silent without saying so |
| 33 | //! — the only sound that does not come out is sound this engine cannot decode at |
| 34 | //! all (Opus and AC-3 inside a Matroska file), and that is an error by name. |
| 35 | //! |
| 36 | //! A **speeded** clip splits along the same line, and for the same reason. The |
| 37 | //! picture is re-encoded, so the frame walk honours a rate: it takes the source |
| 38 | //! frame each timeline frame shows ([`crate::project::Speed::source_at`], the |
| 39 | //! very frame preview holds there) and encodes a held one again rather than |
| 40 | //! decoding it twice. A clip whose *file* was shot at another rate than the |
| 41 | //! timeline goes through the same walk with one more conversion on the end |
| 42 | //! ([`crate::project::Rate`]), so it is encoded at the speed it was shot at. |
| 43 | //! The sound is *copied* unless something forces a decode, and a packet carries |
| 44 | //! no rate — so a speeded lane is one of the things that forces one |
| 45 | //! ([`copy_audio`]) rather than being written out at 1.00x under a re-timed |
| 46 | //! picture. The audio-only formats are decoded and resampled, so they honour a |
| 47 | //! rate like the picture does. |
| 48 | //! |
| 49 | //! Nothing partial survives a failure: the worker writes to `<out>.part` and |
| 50 | //! renames it onto `out` only once the file is closed and complete, so the |
| 51 | //! output either does not exist or is finished — there is no window where a |
| 52 | //! half-written `.export.mp4` is sitting there looking playable. Cancel and |
| 53 | //! every error path delete the `.part`. A killed *process* leaves the `.part` |
| 54 | //! behind (only in-process cleanup is promised), which is an orphan a user can |
| 55 | //! delete rather than a file that plays for two seconds and stops. |
| 56 | |
| 57 | use File; |
| 58 | use ; |
| 59 | use ; |
| 60 | use ; |
| 61 | use ; |
| 62 | use ; |
| 63 | use thread; |
| 64 | |
| 65 | use ; |
| 66 | |
| 67 | use BitRepr; |
| 68 | use Verify; |
| 69 | // The trait the Ogg muxer's `write_header` / `write_packet` / `write_trailer` |
| 70 | // live on -- `oxideav_ogg::mux::open_concrete` hands back the concrete muxer |
| 71 | // (the only way to reach `set_page_target_bytes`), so the trait has to be here. |
| 72 | use Muxer as _; |
| 73 | |
| 74 | use crate; |
| 75 | use crate; |
| 76 | use crate; |
| 77 | use crate; |
| 78 | use crate |
| 79 | |
| 80 | ; |
| 81 | use crate; |
| 82 | use crateComposer; |
| 83 | use crate; |
| 84 | use crate; |
| 85 | |
| 86 | /// Progress is reported in permille: an atomic integer the render loop can read |
| 87 | /// without a lock, fine enough for any progress bar. |
| 88 | pub const PROGRESS_SCALE: u32 = 1_000; |
| 89 | |
| 90 | /// The head of the bar the *sound* owns, before a picture is written at all. |
| 91 | /// The mix is decoded, encoded and measured before the muxer exists ([`run`] |
| 92 | /// says why), and on a feature film that is a minute or two in which a bar |
| 93 | /// pinned at zero is the only thing on screen -- which reads as an export that |
| 94 | /// has hung. Small, because the picture is still nearly all of the work. |
| 95 | pub const AUDIO_BAND: u32 = PROGRESS_SCALE / 20; |
| 96 | |
| 97 | /// Where the bar stands with `done` of `total` pictures written: the sound's |
| 98 | /// band is already behind it ([`AUDIO_BAND`]), so the picture fills what is |
| 99 | /// left rather than starting again from zero. |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | /// D2 rate control: bits per pixel per second, then a sane range. 720p30 lands |
| 105 | /// at 2.76 Mbps, which S1 measured the software encoder hitting within 1%. |
| 106 | const BITS_PER_PIXEL: f64 = 0.1; |
| 107 | const MIN_BITRATE: u64 = 1_000_000; |
| 108 | const MAX_BITRATE: u64 = 20_000_000; |
| 109 | |
| 110 | /// The ceiling on a bitrate somebody *asked* for, which is a different question |
| 111 | /// from where the derived one stops: [`MAX_BITRATE`] is the top of the automatic |
| 112 | /// figure's sane range, and a rate a person typed is not that program's guess to |
| 113 | /// bound. Nothing in either encoder objects to it -- the VA-API seat takes a |
| 114 | /// `u64` and the software ones a `u32`/`i32`, all of which hold this with room |
| 115 | /// -- so the old shared ceiling was only ever the auto range wearing two hats. |
| 116 | const MAX_EXPLICIT_BITRATE: u64 = 50_000_000; |
| 117 | |
| 118 | /// The rates the sound may be coded at, smallest first -- what a front-end |
| 119 | /// offers and what [`ExportSettings::audio_kbps`] is clamped into. Every one of |
| 120 | /// them is a legal MPEG-1 Layer III value, so the MP3 path writes the figure it |
| 121 | /// was given rather than the nearest one `rusty_mp3` snaps to. |
| 122 | pub const AUDIO_KBPS: = ; |
| 123 | |
| 124 | /// What the sound is coded at when nobody picked: the rate this project wrote |
| 125 | /// before the choice existed. 256 and not the encoders' own 128, because an |
| 126 | /// export is a master a person edits from again and this is a second lossy |
| 127 | /// generation over sources that may already have been one -- measured on the |
| 128 | /// suite's fixtures, an untouched clip re-encoded moves 0.15 dB here against |
| 129 | /// 0.46 dB at 128, and 32 KB/s beside a 2.76 Mbps picture is not a size anyone |
| 130 | /// is counting. |
| 131 | pub const DEFAULT_AUDIO_KBPS: u32 = 256; |
| 132 | |
| 133 | /// `rav1e`'s fastest preset. Anything slower is minutes per second of timeline |
| 134 | /// on a build with no assembly, which is what this one is. |
| 135 | const AV1_SPEED: u8 = 10; |
| 136 | |
| 137 | /// The HEVC coding tree block this encoder is fixed at: the coded picture is a |
| 138 | /// whole number of them, which is what the conformance window crops back. |
| 139 | const CTB: usize = 16; |
| 140 | /// How many frames the intra HEVC encoder codes at once. Twelve is where the |
| 141 | /// 2026-08-11 bench stopped scaling on this box (4.30 fps at 1080p); more lanes |
| 142 | /// only holds more decoded frames in memory. |
| 143 | const HEVC_LANES: usize = 12; |
| 144 | /// Bits per pixel the intra encoder spends at QP 27, measured on the same bench: |
| 145 | /// 0.607 at 720p and 0.586 at 1080p. What [`hevc_qp`] maps a bitrate row through. |
| 146 | const HEVC_BPP_AT_27: f64 = 0.6; |
| 147 | /// The band [`hevc_qp`] is clamped into, for the reason stated there. |
| 148 | const HEVC_QP_MIN: i32 = 22; |
| 149 | const HEVC_QP_MAX: i32 = 40; |
| 150 | |
| 151 | /// What an export writes. H.264-in-mp4, AV1 and HEVC -- each of the last two in |
| 152 | /// Matroska or in mp4, the user's pick of container -- are the *video* pairs |
| 153 | /// with both an encoder and a decoder under this project's no-install rule, and |
| 154 | /// WAV, FLAC, MP3 and Ogg Vorbis are the standalone audio formats with a |
| 155 | /// pure-Rust encoder: `hound`, `flacenc`, `rusty_mp3` and `rusty_vorbis`. Opus |
| 156 | /// still has none -- `oxideav-opus` encodes CELT alone, which is half a codec. |
| 157 | /// (AAC has one too -- `rusty_aac`, which is what a re-encoded video track's |
| 158 | /// sound leaves through -- but AAC is a container's own audio, never a file of |
| 159 | /// its own here.) VP9 is the |
| 160 | /// one codec left that comes in through the plugin and stops there, HEVC having |
| 161 | /// gained an encoder (an intra-only one, which the rows say). A front-end says |
| 162 | /// so rather than hiding the row. |
| 163 | /// |
| 164 | /// **Every video format carries sound.** Which way it carries it is the only |
| 165 | /// difference: copied packet for packet where a copy can say what the timeline |
| 166 | /// says, decoded and encoded again ([`encode_audio`]) where it cannot. |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 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 | /// Which encoder writes the picture, as a person picks it on a card. Three |
| 267 | /// discrete choices and not a switch, because "whatever is best" and "the GPU, |
| 268 | /// and say so if there is none" are different answers: a driver that encodes |
| 269 | /// badly wants [`Software`](Self::Software), and a person who *needs* the GPU |
| 270 | /// (a long delivery, a machine whose CPU is doing something else) wants to be |
| 271 | /// told when it is not there rather than to wait out a silent fallback. |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | /// What the caller gets to decide about the output. The codec is not among it: |
| 309 | /// [`Format`] names a container *and* what goes in it, because every pair we |
| 310 | /// can write is a pair we can also read back. |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 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 | /// A running export. Poll [`is_finished`](ExportHandle::is_finished) once per |
| 398 | /// rendered frame and take the [`result`](ExportHandle::result) when it flips; |
| 399 | /// dropping the handle does *not* stop the worker, [`cancel`](ExportHandle::cancel) |
| 400 | /// does. |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | /// Starts the worker. Failures are reported through the handle rather than |
| 438 | /// returned, so a caller has exactly one place to look. The files to read are |
| 439 | /// the project's own [`sources`](Project::sources) -- every clip names one -- |
| 440 | /// so nothing but the edit list decides what is decoded. |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | |
| 479 | |
| 480 | |
| 481 | |
| 482 | |
| 483 | |
| 484 | |
| 485 | |
| 486 | |
| 487 | |
| 488 | |
| 489 | |
| 490 | |
| 491 | |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | |
| 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 | |
| 527 | |
| 528 | |
| 529 | |
| 530 | |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | /// Whether any video lane holds anything at all -- what tells an audio-only |
| 550 | /// timeline from one that merely opens on a gap. Asked of the *lanes* rather |
| 551 | /// than of the sources, because a project may name a video file no clip plays |
| 552 | /// from any more. |
| 553 | |
| 554 | |
| 555 | |
| 556 | |
| 557 | |
| 558 | |
| 559 | |
| 560 | /// Whether any audio lane holds anything, [`has_picture`]'s pair: what tells a |
| 561 | /// timeline whose export will carry sound from one whose file has none. |
| 562 | |
| 563 | |
| 564 | |
| 565 | |
| 566 | |
| 567 | |
| 568 | |
| 569 | /// Whether any equalizer on the sound is doing something -- the one edit a |
| 570 | /// packet copy cannot carry, so an mp4 whose lane has one is decoded and |
| 571 | /// re-encoded ([`encode_audio`]) instead of copied. Asked of every audio lane: |
| 572 | /// the copy path has exactly one by the time it asks, and [`planned_audio`] is |
| 573 | /// asked before that is settled. |
| 574 | |
| 575 | |
| 576 | |
| 577 | |
| 578 | |
| 579 | |
| 580 | |
| 581 | /// Whether the *mix* is doing something -- a lane turned off unity, or a |
| 582 | /// limiter in circuit. [`equalized`]'s pair, and a copy cannot carry either of |
| 583 | /// them: both live where the lanes are summed |
| 584 | /// ([`AudioSession::open_mixed_streams_master`]), and a copied packet was never |
| 585 | /// summed at all. An mp4 whose timeline is mixed is decoded and re-encoded. |
| 586 | |
| 587 | |
| 588 | |
| 589 | |
| 590 | /// The bitrate an export codes at: the caller's number clamped into what an |
| 591 | /// asked-for rate may be ([`MAX_EXPLICIT_BITRATE`]), the derived one where there |
| 592 | /// was none. Clamped rather than refused, for the reason [`Enc::open`] states. |
| 593 | |
| 594 | |
| 595 | |
| 596 | |
| 597 | |
| 598 | |
| 599 | |
| 600 | /// The rate the sound codes at: the caller's pick clamped into the offered |
| 601 | /// range, [`DEFAULT_AUDIO_KBPS`] where there was none. Clamped and not refused, |
| 602 | /// for [`bitrate_of`]'s reason -- a number out of range is a caller's slip and |
| 603 | /// not a file worth failing. |
| 604 | |
| 605 | |
| 606 | |
| 607 | |
| 608 | |
| 609 | |
| 610 | /// The hardware seat for these settings, opened exactly as the export opens it |
| 611 | /// -- the same pins, the same dimensions a driver may refuse -- or `None` where |
| 612 | /// the software encoder takes the file. The single place that choice is made, |
| 613 | /// which is what lets [`planned_video`] *measure* it instead of promising it. |
| 614 | /// |
| 615 | /// `Err` is the one answer the software encoder does **not** take over from: |
| 616 | /// [`EncoderSeat::Hardware`] asked for the GPU by name and this machine has no |
| 617 | /// seat for the codec, so the export refuses in words rather than falling back |
| 618 | /// to an encoder nobody picked. Every caller is before a file exists |
| 619 | /// ([`Enc::open`] runs ahead of the muxer), which is what makes the refusal |
| 620 | /// free. |
| 621 | |
| 622 | |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | |
| 637 | /// The plugin half of [`hw_seat`]: what the driver gives for this codec and |
| 638 | /// this picture, with no policy in it but the AV1 one. |
| 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 | |
| 668 | |
| 669 | |
| 670 | |
| 671 | |
| 672 | |
| 673 | |
| 674 | |
| 675 | |
| 676 | |
| 677 | |
| 678 | |
| 679 | |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | |
| 687 | |
| 688 | |
| 689 | |
| 690 | /// What a hardware encode is called wherever one is named -- the card's line |
| 691 | /// before the export and the progress line during it. |
| 692 | const HW_LABEL: &str = "HW encode (VA-API)"; |
| 693 | |
| 694 | /// ...and what a card says instead where [`EncoderSeat::Hardware`] was picked |
| 695 | /// and there is no seat: the export's own refusal in the width of a card row, |
| 696 | /// shown *before* the button is pressed rather than a minute into a file. |
| 697 | pub const NO_HW_SEAT: &str = "no HW seat here — pick Auto or Software"; |
| 698 | |
| 699 | /// How a front-end names a video seat: which of the two encoders has the file, |
| 700 | /// and which library that is. Not the codec -- a caller shows this beside the |
| 701 | /// format it picked, and `rav1e` names AV1 as `rusty_h264` names H.264. One |
| 702 | /// place, so what a card says before an export and what its progress line says |
| 703 | /// during one cannot drift apart. |
| 704 | |
| 705 | |
| 706 | |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 | |
| 713 | /// The cheap half of "does this timeline's sound have to be re-encoded": what |
| 714 | /// the *edit* says, with no file opened. Two lanes are a mix and a mix is not a |
| 715 | /// copy; a speeded lane is resampled; an equalizer is sample math. The other |
| 716 | /// half -- whether the sources can be copied out of at all -- costs a file open |
| 717 | /// each and belongs to [`copy_audio`], which may re-encode where this says copy. |
| 718 | |
| 719 | |
| 720 | |
| 721 | |
| 722 | |
| 723 | |
| 724 | |
| 725 | |
| 726 | |
| 727 | |
| 728 | |
| 729 | |
| 730 | |
| 731 | |
| 732 | /// What the sound is written by. Every audio encoder here is software -- there |
| 733 | /// is no hardware AAC, PCM, FLAC or MP3 seat -- so this names *which* one, and |
| 734 | /// whether a container escapes encoding altogether by copying the packets it was |
| 735 | /// given. Both AV1 formats are in it like the mp4: an AV1 export carries the |
| 736 | /// timeline's sound too, so leaving it unnamed would be the old lie. |
| 737 | /// |
| 738 | /// A prediction, and it says so: `copied` is what [`copy_audio`] *did*, which a |
| 739 | /// card asking before the export has no way to know (a source that cannot be |
| 740 | /// copied out of is only found by opening it). `None` predicts from the edit |
| 741 | /// alone. |
| 742 | |
| 743 | |
| 744 | |
| 745 | |
| 746 | |
| 747 | |
| 748 | |
| 749 | |
| 750 | |
| 751 | |
| 752 | |
| 753 | |
| 754 | |
| 755 | |
| 756 | |
| 757 | |
| 758 | |
| 759 | |
| 760 | |
| 761 | |
| 762 | |
| 763 | |
| 764 | |
| 765 | |
| 766 | |
| 767 | |
| 768 | |
| 769 | |
| 770 | |
| 771 | |
| 772 | |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | /// What the export *did* to the sound, for the line it publishes while it runs: |
| 778 | /// [`audio_label`]'s words with the one thing no prediction can know filled in |
| 779 | /// -- whether the Opus seat took the track or handed it back |
| 780 | /// ([`encode_opus`]'s gate). |
| 781 | /// |
| 782 | /// `sound` is `Some(copied)` for a track and `None` for a file with no sound. |
| 783 | /// Naming Opus for *every* Matroska encode is what made that fallback |
| 784 | /// invisible: a track the gate refused was written as AAC and the line still |
| 785 | /// said Opus, on the one path where the difference is audible. |
| 786 | |
| 787 | |
| 788 | |
| 789 | |
| 790 | |
| 791 | |
| 792 | |
| 793 | |
| 794 | |
| 795 | |
| 796 | |
| 797 | |
| 798 | |
| 799 | |
| 800 | |
| 801 | |
| 802 | /// What [`start`] would write this timeline's sound with, before one is |
| 803 | /// started. Pure: no probe and no file opened, so a card may ask it per repaint. |
| 804 | |
| 805 | |
| 806 | |
| 807 | |
| 808 | /// Why the sound's rate is nothing this timeline can be asked about in this |
| 809 | /// format, or `None` where it is a real choice: there is no sound to write, the |
| 810 | /// format codes the samples themselves, or the packets are the source's own and |
| 811 | /// carry the rate *it* was coded at. Pure, like [`planned_audio`], and a |
| 812 | /// prediction in the same way -- a copy that turns out impossible (a source no |
| 813 | /// mp4 sample table holds) falls through to [`encode_audio`], which codes at |
| 814 | /// [`ExportSettings::audio_kbps`] like every other encode. So the value travels |
| 815 | /// even where this refuses; what it cannot do is silently write a rate nobody |
| 816 | /// picked. |
| 817 | |
| 818 | |
| 819 | |
| 820 | |
| 821 | |
| 822 | |
| 823 | |
| 824 | |
| 825 | |
| 826 | |
| 827 | |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 | |
| 833 | |
| 834 | /// The tracks an export carries, in the order they were picked, and empty where |
| 835 | /// it carries none: no pick, a pick nothing answers, a track that could not be |
| 836 | /// read, one with no cue left on the exported timeline -- and every format that |
| 837 | /// is the sound alone, which has nowhere to put them. Filtered *per track*, so |
| 838 | /// one unusable pick costs its own row and not the others. |
| 839 | /// |
| 840 | /// Both containers, since the mp4 muxer gained its `tx3g` track: what the two |
| 841 | /// do with the very same [`SubParams`] is theirs to say |
| 842 | /// ([`crate::mux::Mp4Muxer::write_subtitles`], [`MkvMuxer`]), and nothing here |
| 843 | /// asks which one is being written. |
| 844 | |
| 845 | |
| 846 | |
| 847 | |
| 848 | |
| 849 | |
| 850 | |
| 851 | |
| 852 | |
| 853 | |
| 854 | |
| 855 | |
| 856 | |
| 857 | |
| 858 | |
| 859 | |
| 860 | |
| 861 | |
| 862 | |
| 863 | |
| 864 | |
| 865 | |
| 866 | |
| 867 | |
| 868 | |
| 869 | |
| 870 | |
| 871 | |
| 872 | |
| 873 | |
| 874 | |
| 875 | |
| 876 | |
| 877 | |
| 878 | |
| 879 | |
| 880 | |
| 881 | |
| 882 | |
| 883 | |
| 884 | |
| 885 | |
| 886 | |
| 887 | |
| 888 | |
| 889 | |
| 890 | |
| 891 | |
| 892 | |
| 893 | /// The project's subtitle lanes in display order, and empty where **nothing is |
| 894 | /// placed on any of them** -- an empty list is what the export and the card both |
| 895 | /// read as "this project does not use lanes yet", so a project holding a bare |
| 896 | /// `S1` nobody dropped a caption on still exports by the pick list. |
| 897 | |
| 898 | |
| 899 | |
| 900 | |
| 901 | |
| 902 | |
| 903 | |
| 904 | |
| 905 | /// One track per subtitle *lane*, in lane order -- so the file declares them |
| 906 | /// top-down as the timeline shows them and a player's subtitle menu lists them |
| 907 | /// in that order. |
| 908 | /// |
| 909 | /// The cues are [`Project::sub_lane_cues`]: each placement's window of its |
| 910 | /// palette track, on the timeline's own clock. Clipped again here to what the |
| 911 | /// export *writes*, which ends with the last picture or sound |
| 912 | /// ([`Project::media_frames`]) -- a caption hanging past both holds the |
| 913 | /// timeline open ([`Project::timeline_frames`]) but there is no picture under |
| 914 | /// it to write, so a cue out there is dropped and one straddling the end keeps |
| 915 | /// the half that is inside. [`planned_subtitles`] says so before the button is |
| 916 | /// pressed. |
| 917 | /// |
| 918 | /// A lane is dropped whole -- no track at all in the file -- where any |
| 919 | /// placement on it is a picture ([`SubtitleTrack::is_bitmap`]), a track that |
| 920 | /// could not be read, or a palette row that has since gone: the muxers write |
| 921 | /// words, and half a lane's cues under the other half's name would be worse |
| 922 | /// than none. Its language and title are the lane's *first* placement's track, |
| 923 | /// which is the one thing the whole lane is named by. |
| 924 | |
| 925 | |
| 926 | |
| 927 | |
| 928 | |
| 929 | |
| 930 | |
| 931 | |
| 932 | |
| 933 | |
| 934 | |
| 935 | |
| 936 | |
| 937 | |
| 938 | |
| 939 | |
| 940 | |
| 941 | |
| 942 | |
| 943 | |
| 944 | |
| 945 | |
| 946 | |
| 947 | |
| 948 | |
| 949 | |
| 950 | |
| 951 | |
| 952 | |
| 953 | |
| 954 | |
| 955 | |
| 956 | |
| 957 | |
| 958 | |
| 959 | |
| 960 | |
| 961 | |
| 962 | |
| 963 | /// The composite spans an export *writes*: [`Project::composite_spans_from`] |
| 964 | /// cut to where the media runs out ([`Project::media_frames`]). |
| 965 | /// |
| 966 | /// The walk itself is the timeline's ([`Project::timeline_frames`]), because a |
| 967 | /// caption placed past the last picture holds the timeline open under it and |
| 968 | /// playback parks on that tail -- but there is nothing to *write* out there, so |
| 969 | /// an unbounded walk encoded and muxed black frames past the end of the media |
| 970 | /// and padded the sound to match. This is the one place that end is decided: |
| 971 | /// the frame count [`run`] publishes, the cues [`lane_subtitles`] clips and the |
| 972 | /// blocks [`CopyPlan`] copies are then the same number by construction, which |
| 973 | /// is what makes [`planned_lanes`]' "cut off there" true of the file. |
| 974 | |
| 975 | |
| 976 | |
| 977 | |
| 978 | |
| 979 | |
| 980 | |
| 981 | |
| 982 | |
| 983 | |
| 984 | /// The track's cues where the *exported* timeline puts them, which is the only |
| 985 | /// clock the file has: the export writes timeline frame 0 onwards and nothing |
| 986 | /// else, exactly as the sound is mixed from frame 0 and resized to the |
| 987 | /// timeline's own length ([`encode_audio`]). |
| 988 | /// |
| 989 | /// Which clock the cues arrive in is what the track itself says: |
| 990 | /// |
| 991 | /// * a track out of a *file* (`SubtitleTrack::track`) is timed against that |
| 992 | /// file, so each cue is carried through the spans that play it -- a cue over |
| 993 | /// a stretch that was cut out is gone, one straddling a cut keeps the half |
| 994 | /// that is still there, and one after a rippled delete moves back with the |
| 995 | /// picture it belongs to. The *edges* a cut clips to are frames -- that is |
| 996 | /// what a cut is -- but a cue nothing clipped keeps its own microseconds, so |
| 997 | /// an untouched timeline exports the times the source states. |
| 998 | /// * a *standalone* file (`subs.srt`) is timed against nothing else -- there is |
| 999 | /// no clip to hang it on and no offset in the project to shift it by -- so it |
| 1000 | /// is the timeline's own clock, which is where it was drawn while editing |
| 1001 | /// (`Player::subtitle_overlay`). Clipped to the exported length and no more. |
| 1002 | /// |
| 1003 | /// This is also what the *preview* draws: the plate over the picture and the |
| 1004 | /// timeline strip both ask it through |
| 1005 | /// [`PlaybackSession::timeline_cues`](crate::PlaybackSession::timeline_cues), so |
| 1006 | /// what a rippled timeline shows and what its export writes are one answer by |
| 1007 | /// construction rather than two maps kept in step by hand. |
| 1008 | /// |
| 1009 | /// Pure and cheap enough to ask per repaint (a walk of the spans and of the |
| 1010 | /// cues, no file opened), which is how a front-end asks it. |
| 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 | |
| 1048 | |
| 1049 | |
| 1050 | |
| 1051 | |
| 1052 | |
| 1053 | |
| 1054 | |
| 1055 | |
| 1056 | |
| 1057 | |
| 1058 | |
| 1059 | |
| 1060 | |
| 1061 | |
| 1062 | |
| 1063 | |
| 1064 | |
| 1065 | |
| 1066 | |
| 1067 | |
| 1068 | |
| 1069 | |
| 1070 | |
| 1071 | |
| 1072 | |
| 1073 | |
| 1074 | |
| 1075 | /// What [`start`] would do about the subtitles, in the words a card shows: what |
| 1076 | /// travels, and the reason beside every pick that does not. Pure, like |
| 1077 | /// [`planned_audio`]: no file is opened, so it may be asked per repaint. |
| 1078 | /// |
| 1079 | /// `picks` is any run of indices into [`Project::subtitles`] -- an |
| 1080 | /// [`ExportSettings::subtitles`] list (`picks.iter().copied()`) as much as a |
| 1081 | /// single `Some(row)`, which is what a front-end holding one row still hands it. |
| 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 | |
| 1118 | |
| 1119 | |
| 1120 | |
| 1121 | |
| 1122 | |
| 1123 | |
| 1124 | |
| 1125 | |
| 1126 | |
| 1127 | |
| 1128 | |
| 1129 | |
| 1130 | |
| 1131 | |
| 1132 | |
| 1133 | |
| 1134 | |
| 1135 | |
| 1136 | |
| 1137 | |
| 1138 | |
| 1139 | |
| 1140 | |
| 1141 | |
| 1142 | |
| 1143 | |
| 1144 | |
| 1145 | /// [`planned_subtitles`] for a timeline that *places* its words: one clause per |
| 1146 | /// subtitle lane, named by the lane and by the palette row it shows, in the |
| 1147 | /// order the file will declare them ([`lane_subtitles`]). |
| 1148 | /// |
| 1149 | /// Every reason a lane does not travel is said here rather than found in the |
| 1150 | /// file: a picture track placed on it, a track that could not be read, a palette |
| 1151 | /// row that has since gone, a lane sitting entirely past the last picture, and |
| 1152 | /// -- before a byte is written -- more lanes than a Matroska block can number |
| 1153 | /// ([`crate::mux::MAX_SUB_TRACKS`], which the muxer refuses again). |
| 1154 | |
| 1155 | |
| 1156 | |
| 1157 | |
| 1158 | |
| 1159 | |
| 1160 | |
| 1161 | |
| 1162 | |
| 1163 | |
| 1164 | |
| 1165 | |
| 1166 | |
| 1167 | |
| 1168 | |
| 1169 | |
| 1170 | |
| 1171 | |
| 1172 | |
| 1173 | |
| 1174 | |
| 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 | |
| 1204 | |
| 1205 | |
| 1206 | |
| 1207 | |
| 1208 | |
| 1209 | |
| 1210 | |
| 1211 | |
| 1212 | |
| 1213 | |
| 1214 | /// What [`start`] would encode the picture with, probed the way the export |
| 1215 | /// probes it -- the very encoder is opened and closed again -- so this is a |
| 1216 | /// measurement and not a promise. `None` for a format that carries no picture. |
| 1217 | /// |
| 1218 | /// Costs that open (~100 ms here): ask it off a render thread and keep the |
| 1219 | /// answer until the format, the resolution or the bitrate changes. |
| 1220 | |
| 1221 | |
| 1222 | |
| 1223 | |
| 1224 | |
| 1225 | |
| 1226 | |
| 1227 | |
| 1228 | |
| 1229 | /// What [`start`] would open for *this* timeline: the picture's seat -- or the |
| 1230 | /// copy that means there is no encoder at all -- and the sound's, asked of the |
| 1231 | /// very gates the export asks ([`CopyPlan::of`] and [`copy_audio`]'s) rather |
| 1232 | /// than of the format alone. |
| 1233 | /// |
| 1234 | /// This exists because the card and the running export used to disagree in both |
| 1235 | /// directions on the same file: the card named a software HEVC encode for a cut |
| 1236 | /// the engine copied, and named an AAC copy for a Matroska source whose sound |
| 1237 | /// no sample table holds and which therefore always re-encodes. A prediction |
| 1238 | /// that is not the decision is worse than no prediction, because a person plans |
| 1239 | /// their evening around it. |
| 1240 | /// |
| 1241 | /// Costs what [`planned_video`] costs (an encoder opened and closed) plus a |
| 1242 | /// header read per source and, once per file, its cluster walk: ask it off a |
| 1243 | /// render thread and keep the answer until the timeline or the settings change. |
| 1244 | |
| 1245 | |
| 1246 | |
| 1247 | |
| 1248 | |
| 1249 | |
| 1250 | |
| 1251 | |
| 1252 | |
| 1253 | |
| 1254 | |
| 1255 | |
| 1256 | |
| 1257 | |
| 1258 | |
| 1259 | |
| 1260 | |
| 1261 | |
| 1262 | |
| 1263 | |
| 1264 | |
| 1265 | |
| 1266 | |
| 1267 | |
| 1268 | |
| 1269 | |
| 1270 | |
| 1271 | |
| 1272 | |
| 1273 | |
| 1274 | |
| 1275 | |
| 1276 | |
| 1277 | /// The audio track an export writes, and how it was made -- a copy is the |
| 1278 | /// source's own packets, bit for bit, and anything else is this project's |
| 1279 | /// encoder over the decoded mix. [`run`] publishes which of the two really |
| 1280 | /// happened, so the encoder line a user reads is measured and not promised. |
| 1281 | pub |
| 1282 | |
| 1283 | |
| 1284 | |
| 1285 | |
| 1286 | |
| 1287 | |
| 1288 | |
| 1289 | |
| 1290 | |
| 1291 | |
| 1292 | |
| 1293 | /// The timeline's audio track for a file that carries picture: copied packet for |
| 1294 | /// packet where a copy says exactly what the timeline says, and decoded, mixed |
| 1295 | /// and encoded again ([`encode_audio`]) where it cannot -- a second audio lane, |
| 1296 | /// a speeded clip, an equalizer, a source that is not AAC inside an mp4 sample |
| 1297 | /// table. Nothing is refused for being uncopyable any more; the only refusals |
| 1298 | /// left below the copy are about sound this engine cannot *decode* either, and |
| 1299 | /// those come out of the decode path by name. |
| 1300 | /// |
| 1301 | /// The copy is still the default and still bit-exact: a timeline nobody has |
| 1302 | /// touched leaves as the very packets its source holds. |
| 1303 | /// |
| 1304 | /// corner-cut: this holds the whole exported AAC track in memory (~3 kB per |
| 1305 | /// 23 ms packet, so ~500 MB for an hour). Upgrade path is a streaming |
| 1306 | /// `copy_segments` that yields packets instead of collecting them. |
| 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 | |
| 1338 | |
| 1339 | |
| 1340 | |
| 1341 | |
| 1342 | |
| 1343 | |
| 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 | |
| 1408 | |
| 1409 | |
| 1410 | |
| 1411 | |
| 1412 | |
| 1413 | |
| 1414 | |
| 1415 | |
| 1416 | |
| 1417 | /// The picture's half of [`copy_audio`]: a Matroska export whose every span is |
| 1418 | /// its source's own coded blocks, written back out without a decoder or an |
| 1419 | /// encoder anywhere in the path. |
| 1420 | /// |
| 1421 | /// **When.** A copy is entered only where it says *exactly* what the timeline |
| 1422 | /// says, which is the audio gate's rule and not a looser one: the file this |
| 1423 | /// export writes is Matroska, the source's codec is the one that file would |
| 1424 | /// carry ([`Format::Hevc`] over HEVC, [`Format::Av1`] over AV1), and nothing on |
| 1425 | /// the way has touched a sample -- no grade, no speed, no rate conversion, no |
| 1426 | /// gap to fill with black, no source of another size to place on the canvas, |
| 1427 | /// no `ContentEncodings` packing to undo. Anything else re-encodes exactly as |
| 1428 | /// it always did; there is no half-copied file. |
| 1429 | /// |
| 1430 | /// **All or nothing, per export.** A copied span and an encoded one cannot |
| 1431 | /// share one track: this project's encoders write 8-bit SDR streams whose |
| 1432 | /// parameter sets are their own, so splicing them into (say) a Main 10 HDR |
| 1433 | /// source would change bit depth and colour mid-track, and a container states |
| 1434 | /// its configuration record once. So the head and tail fragments of a cut that |
| 1435 | /// lands mid-GOP are *not* re-encoded into the copy -- they are what makes the |
| 1436 | /// whole export fall back to the encoder. What a copy needs instead is that |
| 1437 | /// every span begins on a sync point and ends where the next one begins, which |
| 1438 | /// is what a cut placed on a keyframe gives it. |
| 1439 | /// |
| 1440 | /// **What a cut costs.** An open-GOP source (x265's default) writes leading |
| 1441 | /// pictures after a sync point that are shown *before* it and reference the |
| 1442 | /// group before it. At the start of a copied region those references are not in |
| 1443 | /// the file, so they are dropped -- the picture before the cut is held for those |
| 1444 | /// few frames (four at this film's B-depth, a sixth of a second) rather than |
| 1445 | /// being written as pictures that cannot decode. The region still starts at the |
| 1446 | /// timeline frame it owns, so the sound never drifts. |
| 1447 | /// |
| 1448 | /// corner-cut: mp4 is not copied (its `hvc1` sample entry forbids in-band |
| 1449 | /// parameter sets, and the mp4 muxer here writes its sample table from a frame |
| 1450 | /// counter), and neither is H.264, which this project only writes into mp4. The |
| 1451 | /// upgrade path for both is a sample-table writer that takes explicit |
| 1452 | /// timestamps, which is what [`MkvMuxer::write_block`] already is for Matroska. |
| 1453 | |
| 1454 | |
| 1455 | |
| 1456 | |
| 1457 | |
| 1458 | |
| 1459 | |
| 1460 | |
| 1461 | |
| 1462 | |
| 1463 | |
| 1464 | |
| 1465 | |
| 1466 | |
| 1467 | |
| 1468 | /// A run of source blocks copied in one piece: what a cut leaves behind, and |
| 1469 | /// what two spans that continue each other in the same file merge back into. |
| 1470 | |
| 1471 | |
| 1472 | |
| 1473 | |
| 1474 | |
| 1475 | |
| 1476 | |
| 1477 | |
| 1478 | |
| 1479 | |
| 1480 | |
| 1481 | |
| 1482 | |
| 1483 | |
| 1484 | |
| 1485 | |
| 1486 | |
| 1487 | |
| 1488 | |
| 1489 | |
| 1490 | |
| 1491 | |
| 1492 | |
| 1493 | |
| 1494 | |
| 1495 | |
| 1496 | |
| 1497 | |
| 1498 | |
| 1499 | |
| 1500 | |
| 1501 | |
| 1502 | |
| 1503 | |
| 1504 | |
| 1505 | |
| 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 | |
| 1546 | |
| 1547 | |
| 1548 | |
| 1549 | |
| 1550 | |
| 1551 | |
| 1552 | |
| 1553 | |
| 1554 | |
| 1555 | |
| 1556 | |
| 1557 | |
| 1558 | |
| 1559 | |
| 1560 | |
| 1561 | |
| 1562 | |
| 1563 | |
| 1564 | |
| 1565 | |
| 1566 | |
| 1567 | |
| 1568 | |
| 1569 | |
| 1570 | |
| 1571 | |
| 1572 | |
| 1573 | |
| 1574 | |
| 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 | /// The same lane, *decoded*: what a packet copy cannot carry comes out here as |
| 1646 | /// AAC written by this project's own encoder. |
| 1647 | /// |
| 1648 | /// The samples are the very ones [`run_audio`] would put in a WAV -- the same |
| 1649 | /// opener with the same equalizers, the same rates and the same resize onto the |
| 1650 | /// timeline's own length -- so an mp4 and a WAV of one timeline are one mix, |
| 1651 | /// not two that could disagree. |
| 1652 | /// |
| 1653 | /// AAC-LC's encoder delay is one 1024-frame block, which is exactly the priming |
| 1654 | /// a reader drops when the file carries no edit list (`audio::DEFAULT_PRIMING`, |
| 1655 | /// and [`crate::mux::Mp4Muxer`] writes none): the first packet is that delay, so |
| 1656 | /// the sound starts at timeline frame 0 as a copied track's does. |
| 1657 | /// |
| 1658 | /// corner-cut: the mix sits in memory as f32 before it is encoded (~46 MB a |
| 1659 | /// minute of 48 kHz stereo), for [`run_audio`]'s reason -- `rusty_aac` buffers |
| 1660 | /// the whole stream anyway, since it encodes its frames in parallel. Upgrade |
| 1661 | /// path is a chunked push once that encoder streams. |
| 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 | |
| 1700 | |
| 1701 | |
| 1702 | |
| 1703 | |
| 1704 | |
| 1705 | |
| 1706 | |
| 1707 | |
| 1708 | |
| 1709 | |
| 1710 | |
| 1711 | |
| 1712 | |
| 1713 | |
| 1714 | |
| 1715 | |
| 1716 | |
| 1717 | |
| 1718 | |
| 1719 | |
| 1720 | |
| 1721 | |
| 1722 | |
| 1723 | |
| 1724 | |
| 1725 | |
| 1726 | |
| 1727 | |
| 1728 | |
| 1729 | |
| 1730 | |
| 1731 | |
| 1732 | |
| 1733 | |
| 1734 | |
| 1735 | |
| 1736 | |
| 1737 | |
| 1738 | |
| 1739 | |
| 1740 | |
| 1741 | |
| 1742 | |
| 1743 | |
| 1744 | |
| 1745 | |
| 1746 | |
| 1747 | |
| 1748 | |
| 1749 | |
| 1750 | |
| 1751 | |
| 1752 | |
| 1753 | |
| 1754 | |
| 1755 | |
| 1756 | |
| 1757 | |
| 1758 | |
| 1759 | |
| 1760 | |
| 1761 | |
| 1762 | |
| 1763 | |
| 1764 | |
| 1765 | |
| 1766 | |
| 1767 | |
| 1768 | |
| 1769 | |
| 1770 | |
| 1771 | |
| 1772 | |
| 1773 | |
| 1774 | |
| 1775 | |
| 1776 | |
| 1777 | |
| 1778 | |
| 1779 | |
| 1780 | |
| 1781 | |
| 1782 | |
| 1783 | |
| 1784 | |
| 1785 | |
| 1786 | |
| 1787 | |
| 1788 | |
| 1789 | |
| 1790 | |
| 1791 | |
| 1792 | |
| 1793 | |
| 1794 | |
| 1795 | |
| 1796 | |
| 1797 | |
| 1798 | |
| 1799 | |
| 1800 | /// The one rate Opus codes at. The container may state another one in its |
| 1801 | /// `OpusHead` and every decoder still runs at 48 kHz (RFC 7845 §5.1), so a |
| 1802 | /// timeline at any other rate is not "encoded at its own rate" here -- it is |
| 1803 | /// resampled or it is not Opus, and [`encode_audio`] picks the second. |
| 1804 | pub const OPUS_RATE: u32 = 48_000; |
| 1805 | |
| 1806 | /// 20 ms at [`OPUS_RATE`], the frame every Opus muxer in the wild writes: |
| 1807 | /// long enough that the per-packet overhead is nothing, short enough that a |
| 1808 | /// Matroska block timestamp in whole milliseconds is exact. |
| 1809 | const OPUS_FRAME: usize = 960; |
| 1810 | |
| 1811 | /// The most this project asks of `opus-rs`, in kbps, and why it is a cap rather |
| 1812 | /// than the four rates the Sound row offers: this encoder falls off a cliff at a |
| 1813 | /// rate that depends on the *content*, and above it a conformant decoder gets |
| 1814 | /// noise back. Measured on three one-second spans of a real 5.1 Opus film, |
| 1815 | /// encoded here and decoded with `ruopus` -- which is not the suspect, since it |
| 1816 | /// decodes ffmpeg's own libopus at 256 kbps to correlation 1.00000 on the same |
| 1817 | /// material: |
| 1818 | /// |
| 1819 | /// ```text |
| 1820 | /// kbps 120 128 136 144 152 160 |
| 1821 | /// span A 0.945 0.937 0.452 0.206 0.223 0.163 |
| 1822 | /// span B 0.986 0.989 0.697 0.153 0.114 0.149 |
| 1823 | /// span C 0.999 0.994 0.951 0.335 0.266 0.326 |
| 1824 | /// libopus 0.997 0.998 -- -- -- 0.996 (same spans, control) |
| 1825 | /// ``` |
| 1826 | /// |
| 1827 | /// So: usable to 128, ruined by 136 on real film sound, and the pure-tone |
| 1828 | /// fixtures that first suggested a 165 kbps ceiling were simply easy material. |
| 1829 | /// 128 kbps stereo Opus is around transparency anyway (libopus scores 0.998 |
| 1830 | /// there on the worst of those spans), so the cap costs nothing a listener has. |
| 1831 | /// It is still not *trusted*: every track is decoded again and measured before |
| 1832 | /// it is written ([`opus_fidelity`]), because a cliff whose edge moves with the |
| 1833 | /// material is not something a constant can be safe against on its own. |
| 1834 | /// |
| 1835 | /// corner-cut: the ceiling is this encoder's, not the format's. Upgrade path is a |
| 1836 | /// released `opus-rs` that survives its own high rates -- the unit test pins the |
| 1837 | /// failure, so it fails the day the bug is fixed and this can be raised. |
| 1838 | pub const OPUS_MAX_KBPS: u32 = 128; |
| 1839 | |
| 1840 | /// How well a track has to survive its own round trip to be written as Opus: |
| 1841 | /// the correlation between the mix and the decode of what was encoded from it. |
| 1842 | /// A good encoder scores 0.98-0.999 on this material (libopus, measured above); |
| 1843 | /// the failure mode is not subtle at all, scoring 0.1-0.7. 0.95 sits in the gap |
| 1844 | /// with room on both sides, and what fails it is written as AAC -- the export's |
| 1845 | /// own encoder line then says AAC, so the fallback is visible rather than |
| 1846 | /// silent. |
| 1847 | const OPUS_MIN_FIDELITY: f64 = 0.95; |
| 1848 | |
| 1849 | /// The encoder's lookahead at [`OPUS_RATE`] in the mode this envelope always |
| 1850 | /// selects (CELT-only: 2.5 ms). The pre-skip a file states is this *plus* the |
| 1851 | /// warm-up frame [`encode_opus`] throws away. Measured by |
| 1852 | /// cross-correlating the decode against the source, not taken from the crate -- |
| 1853 | /// it exposes no lookahead getter -- and asserted at both ends of the rate band |
| 1854 | /// in `tests/opus_export.rs`, which is what catches a version that changes it. |
| 1855 | const OPUS_PRE_SKIP: u16 = 120; |
| 1856 | |
| 1857 | /// The mix as Opus packets, one per [`OPUS_FRAME`], plus the pre-skip that has |
| 1858 | /// to be declared in front of them. Stereo and [`OPUS_RATE`] only -- the caller |
| 1859 | /// checks both, because outside that pair this encoder is not one this project |
| 1860 | /// is willing to write files with ([`OPUS_MAX_KBPS`]). |
| 1861 | /// |
| 1862 | /// The tail frame is padded with silence rather than dropped: Opus codes whole |
| 1863 | /// frames and a track a few milliseconds short under a picture that is not is |
| 1864 | /// the drift every other path here is written to avoid. The pre-skip trims the |
| 1865 | /// front; the container's duration trims the back. |
| 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 | /// Packets one sampled window listens to: 5 s at [`OPUS_FRAME`]. |
| 1927 | const FIDELITY_WINDOW: usize = 250; |
| 1928 | |
| 1929 | /// How many of them a long track is judged on -- a minute of sound, wherever |
| 1930 | /// the track's length puts them, and a constant cost rather than one that grows |
| 1931 | /// with the film ([`opus_fidelity`]). |
| 1932 | const FIDELITY_WINDOWS: usize = 12; |
| 1933 | |
| 1934 | /// Packets decoded into a window and thrown away before it is measured. CELT |
| 1935 | /// predicts across frames, so a decoder started cold mid-stream is behind its |
| 1936 | /// own history for a few frames; 100 ms is far more than it needs and is not |
| 1937 | /// worth counting. |
| 1938 | const FIDELITY_WARMUP: usize = 5; |
| 1939 | |
| 1940 | /// How much sound a window must carry before its correlation means anything: |
| 1941 | /// mean square per sample. A window of digital silence -- the head of a film, |
| 1942 | /// the gap between a feature and its credits -- correlates with nothing, and |
| 1943 | /// failing a track for it would send perfectly good sound to AAC. |
| 1944 | const FIDELITY_FLOOR: f64 = 1e-9; |
| 1945 | |
| 1946 | /// The correlation between `samples` and the decode of `packets` with the first |
| 1947 | /// `pre_skip` frames dropped: 1.0 is the same waveform, and this codec's failure |
| 1948 | /// mode lands near 0.1. Streamed packet by packet -- the decode is never held, |
| 1949 | /// only three running sums -- because the mix behind it is already the biggest |
| 1950 | /// thing in an export ([`encode_audio`]'s corner-cut). |
| 1951 | /// |
| 1952 | /// A packet the decoder refuses is 0.0 and no argument: a track this project |
| 1953 | /// cannot read is exactly what this is here to catch. |
| 1954 | /// |
| 1955 | /// **Sampled above a minute of sound, and the median window is the answer.** |
| 1956 | /// This decode is the whole cost of exporting a feature film: `ruopus` runs its |
| 1957 | /// inverse MDCT at 0.2x real time here (measured, 24.2 s for 121.5 s of stereo), |
| 1958 | /// so judging every packet of a two-and-a-half-hour film costs half an hour |
| 1959 | /// before a byte of picture is written -- which is what it did, and what made a |
| 1960 | /// copy export that has no encoding to do at all sit at zero for twenty minutes. |
| 1961 | /// [`FIDELITY_WINDOWS`] windows spread evenly across the track cost the same |
| 1962 | /// minute of decode whatever the film's length, and what they are looking for |
| 1963 | /// survives sampling: [`OPUS_MAX_KBPS`]'s cliff is a *rate* the encoder falls |
| 1964 | /// off everywhere that rate is used, not a defect of one bar of music. |
| 1965 | /// |
| 1966 | /// The **median** and not the worst, and that is measured rather than cautious. |
| 1967 | /// Forty five-second windows of a real 5.1 film's mix, encoded here at 128 kbps |
| 1968 | /// and decoded back, in order: |
| 1969 | /// |
| 1970 | /// ```text |
| 1971 | /// 0.803 0.835 0.938 0.940 0.960 0.987 0.994 ... median 0.998 ... 0.999 |
| 1972 | /// ``` |
| 1973 | /// |
| 1974 | /// Five of the thirty-nine that carried sound sit under [`OPUS_MIN_FIDELITY`] on |
| 1975 | /// a track that is *good* -- which is the same thing the table in |
| 1976 | /// [`OPUS_MAX_KBPS`] shows, where a span scoring 0.937 at 128 kbps is inside the |
| 1977 | /// usable band. A worst-window rule at 0.95 therefore refuses films this encoder |
| 1978 | /// handles perfectly well, while the failure it exists for is the opposite |
| 1979 | /// shape: at 136 kbps the same three measured spans read 0.452, 0.697, 0.951, |
| 1980 | /// and at 256 kbps the whole track correlates 0.06. Half a track cannot be |
| 1981 | /// ruined without the middle of the list moving, so the median separates the two |
| 1982 | /// by a margin no single window can (0.998 against under 0.7) -- and a track |
| 1983 | /// under a minute is one window, where median and whole-track correlation are |
| 1984 | /// the same number the gate always used. |
| 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 | /// [`opus_fidelity`] over `packets[measure..to]`, with `packets[from..measure]` |
| 2016 | /// -- the warm-up -- decoded for its state and thrown away. `None` where the |
| 2017 | /// source window carries no sound worth correlating ([`FIDELITY_FLOOR`]). |
| 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 | /// The audio pass, running beside the picture: what [`run`] holds while it |
| 2058 | /// encodes and joins where the file it is writing needs the track. |
| 2059 | type AudioJob = JoinHandle; |
| 2060 | |
| 2061 | /// The pass while [`run`] holds it, joined however that function leaves -- |
| 2062 | /// including through a `?`. |
| 2063 | /// |
| 2064 | /// A [`JoinHandle`](thread::JoinHandle) that is merely dropped *detaches* its |
| 2065 | /// thread, and the one error that matters here is the hardware encoder's |
| 2066 | /// process dying ([`crate::hwproc`]): the whole export is then written again by |
| 2067 | /// [`start`], which starts an audio pass of its own. The abandoned one would go |
| 2068 | /// on mixing and encoding the same sound beside it -- two passes of a feature |
| 2069 | /// film's audio at once, on the machine that has just lost its GPU. Joined |
| 2070 | /// instead, so an export has one audio pass at a time and none outlives it. |
| 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 | /// The pass's answer, or the failure that is the export's failure. A panicked |
| 2101 | /// audio thread reads as an error rather than as silence: an export that wrote |
| 2102 | /// its picture and quietly no sound is the one outcome this must not have. |
| 2103 | |
| 2104 | |
| 2105 | |
| 2106 | |
| 2107 | |
| 2108 | /// The encoder line a running export shows: the seat the picture is really |
| 2109 | /// being written by, and what the sound is -- or that the sound is still being |
| 2110 | /// worked out, which an overlapped audio pass is until it is collected. |
| 2111 | |
| 2112 | |
| 2113 | |
| 2114 | |
| 2115 | |
| 2116 | |
| 2117 | |
| 2118 | |
| 2119 | |
| 2120 | |
| 2121 | |
| 2122 | |
| 2123 | |
| 2124 | |
| 2125 | |
| 2126 | |
| 2127 | |
| 2128 | |
| 2129 | |
| 2130 | |
| 2131 | |
| 2132 | |
| 2133 | |
| 2134 | |
| 2135 | |
| 2136 | |
| 2137 | |
| 2138 | |
| 2139 | |
| 2140 | |
| 2141 | |
| 2142 | |
| 2143 | |
| 2144 | |
| 2145 | |
| 2146 | |
| 2147 | |
| 2148 | |
| 2149 | |
| 2150 | |
| 2151 | |
| 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 | |
| 2183 | |
| 2184 | |
| 2185 | |
| 2186 | |
| 2187 | |
| 2188 | |
| 2189 | |
| 2190 | |
| 2191 | |
| 2192 | |
| 2193 | |
| 2194 | |
| 2195 | |
| 2196 | |
| 2197 | |
| 2198 | |
| 2199 | |
| 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 | |
| 2347 | |
| 2348 | |
| 2349 | |
| 2350 | |
| 2351 | |
| 2352 | |
| 2353 | |
| 2354 | |
| 2355 | |
| 2356 | |
| 2357 | |
| 2358 | |
| 2359 | |
| 2360 | |
| 2361 | |
| 2362 | |
| 2363 | |
| 2364 | |
| 2365 | |
| 2366 | |
| 2367 | |
| 2368 | |
| 2369 | |
| 2370 | |
| 2371 | |
| 2372 | |
| 2373 | |
| 2374 | |
| 2375 | |
| 2376 | |
| 2377 | |
| 2378 | |
| 2379 | |
| 2380 | |
| 2381 | |
| 2382 | |
| 2383 | |
| 2384 | |
| 2385 | |
| 2386 | |
| 2387 | |
| 2388 | |
| 2389 | |
| 2390 | |
| 2391 | |
| 2392 | |
| 2393 | |
| 2394 | |
| 2395 | |
| 2396 | |
| 2397 | |
| 2398 | |
| 2399 | |
| 2400 | |
| 2401 | |
| 2402 | |
| 2403 | |
| 2404 | |
| 2405 | |
| 2406 | |
| 2407 | |
| 2408 | |
| 2409 | |
| 2410 | |
| 2411 | |
| 2412 | |
| 2413 | |
| 2414 | |
| 2415 | |
| 2416 | |
| 2417 | |
| 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 | |
| 2488 | |
| 2489 | |
| 2490 | |
| 2491 | |
| 2492 | |
| 2493 | |
| 2494 | |
| 2495 | |
| 2496 | |
| 2497 | |
| 2498 | |
| 2499 | |
| 2500 | |
| 2501 | |
| 2502 | |
| 2503 | |
| 2504 | |
| 2505 | |
| 2506 | |
| 2507 | |
| 2508 | |
| 2509 | |
| 2510 | |
| 2511 | |
| 2512 | |
| 2513 | |
| 2514 | |
| 2515 | |
| 2516 | |
| 2517 | |
| 2518 | |
| 2519 | |
| 2520 | |
| 2521 | |
| 2522 | |
| 2523 | |
| 2524 | |
| 2525 | |
| 2526 | |
| 2527 | |
| 2528 | |
| 2529 | |
| 2530 | |
| 2531 | |
| 2532 | |
| 2533 | |
| 2534 | |
| 2535 | |
| 2536 | |
| 2537 | |
| 2538 | |
| 2539 | |
| 2540 | |
| 2541 | |
| 2542 | |
| 2543 | |
| 2544 | |
| 2545 | |
| 2546 | |
| 2547 | |
| 2548 | |
| 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 | |
| 2586 | |
| 2587 | |
| 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 | /// One decoded picture graded, tone-mapped, remapped and placed on the canvas |
| 2627 | /// -- everything between a source's own samples and the ones an encoder is fed, |
| 2628 | /// which is exactly the work a zero-copy span has none of. |
| 2629 | /// |
| 2630 | /// `graded` and `canvas` are the span's scratch: the planes come back borrowed |
| 2631 | /// from one of them, or from the picture itself where not a byte was touched. |
| 2632 | |
| 2633 | |
| 2634 | |
| 2635 | |
| 2636 | |
| 2637 | |
| 2638 | |
| 2639 | |
| 2640 | |
| 2641 | |
| 2642 | |
| 2643 | |
| 2644 | |
| 2645 | |
| 2646 | |
| 2647 | |
| 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 | |
| 2678 | |
| 2679 | |
| 2680 | /// Which matrix pair a span's samples are rewritten by on the way into a file |
| 2681 | /// whose own matrix is `out` -- `None` when they are already coded against it, |
| 2682 | /// and for a gap, whose 16/128/128 black is black in every matrix here. |
| 2683 | /// |
| 2684 | /// `toned` says the tone map ran on this span: it hands back BT.709 SDR whatever |
| 2685 | /// the source was coded as, so an HDR clip is never *also* given the matrix |
| 2686 | /// treatment its BT.2020 tag would ask for -- one conversion or the other, never |
| 2687 | /// both on one frame -- while a tone-mapped clip on a canvas below 720 lines |
| 2688 | /// still takes its 709 -> 601 step. |
| 2689 | |
| 2690 | |
| 2691 | |
| 2692 | |
| 2693 | |
| 2694 | |
| 2695 | |
| 2696 | |
| 2697 | |
| 2698 | |
| 2699 | |
| 2700 | |
| 2701 | /// What rate `path` was shot at against a timeline at `timeline_fps` |
| 2702 | /// ([`Rate`]). [`Rate::REAL_TIME`] for the files that have no rate of their own |
| 2703 | /// -- a still, a song -- and for one that will not open here: the decoder is |
| 2704 | /// opened a few lines later and fails the export by name, which is a better |
| 2705 | /// error than this one could raise. |
| 2706 | |
| 2707 | |
| 2708 | |
| 2709 | |
| 2710 | |
| 2711 | |
| 2712 | |
| 2713 | |
| 2714 | |
| 2715 | |
| 2716 | |
| 2717 | |
| 2718 | |
| 2719 | |
| 2720 | |
| 2721 | |
| 2722 | |
| 2723 | |
| 2724 | |
| 2725 | |
| 2726 | |
| 2727 | |
| 2728 | |
| 2729 | |
| 2730 | |
| 2731 | |
| 2732 | /// The audio lanes alone, summed, as a WAV or a FLAC. |
| 2733 | /// |
| 2734 | /// Nothing here re-derives the edit: the play lists are |
| 2735 | /// [`Project::audio_segments_from`] and they are handed to the very |
| 2736 | /// [`AudioSession::open_mixed_streams`] playback feeds from, so what is written |
| 2737 | /// is what was heard -- every lane, mixed the same way, gaps included, which |
| 2738 | /// arrive as real silence from that choke point rather than as a hole this would |
| 2739 | /// have to invent. |
| 2740 | /// |
| 2741 | /// The length is the *timeline's*: each segment resolves its window to whole |
| 2742 | /// samples on its own, so the sum can miss the timeline by a sample or two, and |
| 2743 | /// a source that runs out early would leave the file short. Both are settled by |
| 2744 | /// one `resize` at the end -- padding with silence, trimming what overshot -- |
| 2745 | /// so an exported file is exactly as long as what was edited. |
| 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 | /// 16-bit PCM at the timeline's own rate and layout: no resampling anywhere in |
| 2827 | /// this engine, so what the decoder handed over is what the header says. |
| 2828 | |
| 2829 | |
| 2830 | |
| 2831 | |
| 2832 | |
| 2833 | |
| 2834 | |
| 2835 | |
| 2836 | |
| 2837 | |
| 2838 | |
| 2839 | |
| 2840 | |
| 2841 | |
| 2842 | |
| 2843 | |
| 2844 | |
| 2845 | |
| 2846 | |
| 2847 | /// The same samples as MPEG-1 Layer III, `rusty_mp3` doing the encoding -- pure |
| 2848 | /// Rust like every other encoder here, and the reason this format is a row at |
| 2849 | /// all: the LGPL `shine-rs` was the only one when it was not. |
| 2850 | /// |
| 2851 | /// CBR at the caller's rate, [`DEFAULT_AUDIO_KBPS`] where there was none. Every |
| 2852 | /// offered rate is already a legal Layer III value, so the encoder's snap is a |
| 2853 | /// backstop and not a silent substitution; a sample rate MPEG has no frame for |
| 2854 | /// (anything but 8-48 kHz) is refused there by name rather than written as |
| 2855 | /// something else. |
| 2856 | /// |
| 2857 | /// corner-cut: CBR only -- the card offers rates and not a quality index. Upgrade |
| 2858 | /// path is `Mp3EncoderConfig::vbr_quality` behind a setting of its own. |
| 2859 | |
| 2860 | |
| 2861 | |
| 2862 | |
| 2863 | |
| 2864 | |
| 2865 | |
| 2866 | |
| 2867 | |
| 2868 | |
| 2869 | |
| 2870 | |
| 2871 | |
| 2872 | |
| 2873 | |
| 2874 | |
| 2875 | |
| 2876 | |
| 2877 | |
| 2878 | |
| 2879 | |
| 2880 | |
| 2881 | |
| 2882 | /// The Vorbis quality every `.ogg` this program writes is coded at, on |
| 2883 | /// `rusty_vorbis`'s normalised `[0, 1]` scale -- about `-q 8.35` on the scale |
| 2884 | /// Vorbis itself is spoken in (`quality01_from_vorbis_q`). |
| 2885 | /// |
| 2886 | /// A measured number, not a taste. The 2026-08-11 bench encoded three of this |
| 2887 | /// suite's fixtures (`test_tone_48k.wav`, `test_av.mp4`, `test_tone.mp3`) at |
| 2888 | /// every quality from 0.40 to 0.95 and decoded each back with **symphonia** -- |
| 2889 | /// an independent decoder, and the very one [`crate::audio`] reopens an export |
| 2890 | /// with. Two things came out of it: |
| 2891 | /// |
| 2892 | /// * **Below 0.50 the encoder is quiet, not just coarse.** The decoded RMS |
| 2893 | /// against the source's runs 0.83-0.94 at quality 0.40 (a 1 to 1.6 dB level |
| 2894 | /// error), and at 0.10 and below the file decodes to near-silence -- the same |
| 2895 | /// class of failure the AC-3 mono downmix has in `crate::audio`. From 0.55 up |
| 2896 | /// the level sits at 1.000-1.009, which is what a lossy codec should do. |
| 2897 | /// * **The band tops out well under the rates the Sound row offers.** Quality |
| 2898 | /// 0.85 measured 176, 144 and 148 kbps on the three fixtures; 0.95 only |
| 2899 | /// reaches ~200. That is why [`audio_rate_refusal`] takes the row away rather |
| 2900 | /// than mapping 128/192/256/320 onto quality steps: the top two are numbers |
| 2901 | /// this encoder cannot produce, and a card that printed them would be lying. |
| 2902 | /// |
| 2903 | /// 0.85 is the top of the band where every fixture still decoded to *exactly* |
| 2904 | /// its own length (0.95 overshot one by 820 samples), which is the property |
| 2905 | /// [`write_ogg`] is built around. |
| 2906 | const VORBIS_QUALITY: f32 = 0.85; |
| 2907 | |
| 2908 | /// The Vorbis block hop, and the size of the pre-roll [`write_ogg`] feeds the |
| 2909 | /// encoder. `rusty_vorbis` emits long blocks only (`N = 2048`, hop `N/2`). |
| 2910 | const VORBIS_HOP: usize = 1024; |
| 2911 | |
| 2912 | /// The same samples as Vorbis I in an Ogg container: `rusty_vorbis` encodes, |
| 2913 | /// `oxideav-ogg` pages. Pure Rust on both halves, like every other encoder here. |
| 2914 | /// |
| 2915 | /// Two corrections stand between that library pair and a file this project would |
| 2916 | /// ship, and both are measured rather than guessed (2026-08-11, decoded back |
| 2917 | /// with symphonia every time): |
| 2918 | /// |
| 2919 | /// 1. **One hop of pre-roll.** `rusty_vorbis` advances the granule by a full hop |
| 2920 | /// on its *first* audio packet, which its own doc comment says decodes to |
| 2921 | /// zero samples. Written straight through, every sample lands ~1024 early: |
| 2922 | /// a marker signal whose only energy was its first and last 1024 samples came |
| 2923 | /// back with the head at 36% of its amplitude and a full-scale burst 1500 |
| 2924 | /// samples *before* the real one, in what should have been silence. Feeding |
| 2925 | /// [`VORBIS_HOP`] samples of silence ahead of the mix and subtracting the same |
| 2926 | /// from every granule puts it back: head 0.86 against an input peak of 0.80, |
| 2927 | /// the phantom burst down to 0.04, the real burst at its own place. The |
| 2928 | /// decoder drops the pre-roll itself -- a first page whose granule is under |
| 2929 | /// what its packets decode to is exactly how Ogg says "skip this much". |
| 2930 | /// 2. **The tail is declared, not encoded.** The block grid overshoots the last |
| 2931 | /// sample, so the stream is padded out and the *last* page's granule is set |
| 2932 | /// to the timeline's own frame count. A decoder trims to it, which is what |
| 2933 | /// makes an `.ogg` here exactly as long as the WAV of the same timeline -- |
| 2934 | /// the promise [`run_audio`] makes for every other audio format. |
| 2935 | /// |
| 2936 | /// **Stereo, always.** The embedded setup header `rusty_vorbis` ships is a |
| 2937 | /// stereo profile: a mono push is refused outright ("bad coupling channels"), |
| 2938 | /// and so is anything wider. A mono mix is therefore written as dual mono, both |
| 2939 | /// channels bit-identical (measured: `max|L-R|` is exactly 0, and Vorbis's own |
| 2940 | /// channel coupling codes the empty side channel for almost nothing). Wider than |
| 2941 | /// stereo cannot reach here -- [`crate::audio`] folds 5.1 to stereo when the |
| 2942 | /// source is opened -- but it is refused by name rather than left to the |
| 2943 | /// library's own message. |
| 2944 | /// |
| 2945 | /// corner-cut: one quality, [`VORBIS_QUALITY`], with no user control -- the Sound |
| 2946 | /// row is refused for this format because the rates it offers are not rates |
| 2947 | /// Vorbis reaches. Upgrade path is a quality picker of its own, worth building |
| 2948 | /// the day the card has a control that speaks in quality rather than kbps. |
| 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 | /// The page size [`write_ogg`] asks the Ogg muxer to aim at, in bytes. RFC 3533 |
| 3043 | /// describes pages as "usually 4-8 kB", which is also the muxer's own suggested |
| 3044 | /// general-purpose value. |
| 3045 | const OGG_PAGE_BYTES: usize = 4096; |
| 3046 | |
| 3047 | /// The same samples, losslessly compressed. `flacenc`'s errors are flattened to |
| 3048 | /// text: they are not `Send + Sync`, and every one of them fails the export the |
| 3049 | /// same way. |
| 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 | /// The I420 planes of one black picture, allocated once for a whole export: a |
| 3084 | /// gap in the video lane is encoded, not skipped, or every frame after it would |
| 3085 | /// arrive early. Limited-range black is `Y=16, U=V=128`, the same convention |
| 3086 | /// [`crate::convert`] decodes with. |
| 3087 | |
| 3088 | |
| 3089 | |
| 3090 | |
| 3091 | |
| 3092 | |
| 3093 | |
| 3094 | |
| 3095 | |
| 3096 | |
| 3097 | |
| 3098 | |
| 3099 | |
| 3100 | |
| 3101 | |
| 3102 | |
| 3103 | |
| 3104 | |
| 3105 | |
| 3106 | |
| 3107 | |
| 3108 | |
| 3109 | |
| 3110 | /// `Err` once a cancel has been asked for. Called at every point where the work |
| 3111 | /// left is more than an instant, so an `esc` at 99.9% still stops the export |
| 3112 | /// instead of quietly completing it. |
| 3113 | |
| 3114 | |
| 3115 | |
| 3116 | |
| 3117 | |
| 3118 | |
| 3119 | |
| 3120 | /// The two containers an export writes, so the picture loop above is one loop: |
| 3121 | /// H.264 goes into mp4, AV1 into Matroska, and nothing else is offered. |
| 3122 | |
| 3123 | |
| 3124 | |
| 3125 | |
| 3126 | |
| 3127 | |
| 3128 | |
| 3129 | |
| 3130 | |
| 3131 | |
| 3132 | |
| 3133 | |
| 3134 | |
| 3135 | |
| 3136 | /// Writes one access unit, creating the file on the first one -- the parameter |
| 3137 | /// sets for `avcC` (and the sequence header for `CodecPrivate`) only exist once |
| 3138 | /// the encoder has coded something. Units with no coded slice are skipped: a |
| 3139 | /// software encoder may hand back an empty buffer while it buffers, and the |
| 3140 | /// muxer rejects a sample that would carry no picture. |
| 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 | /// The `hvcC` record of the first coded unit, or the refusal by name. Split out |
| 3293 | /// because both HEVC containers ask it in the same words. |
| 3294 | |
| 3295 | |
| 3296 | |
| 3297 | |
| 3298 | |
| 3299 | |
| 3300 | |
| 3301 | |
| 3302 | |
| 3303 | |
| 3304 | |
| 3305 | |
| 3306 | |
| 3307 | |
| 3308 | /// Hardware where it is available, software everywhere else -- chosen once for |
| 3309 | /// the whole export, so the stream never changes encoder mid-file. Both codecs |
| 3310 | /// have both seats: an AV1 export runs on the plugin's VA-API encoder where the |
| 3311 | /// GPU has one and on `rav1e` where it has not, which is the same pair H.264 has |
| 3312 | /// had and the same silent fallback. |
| 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 | /// The intra HEVC seat. Frames arrive one at a time (the export walk is one |
| 3345 | /// picture per timeline frame) and are held until there are [`lanes`] of them, |
| 3346 | /// then coded in parallel and queued in **display order** -- fanning out is the |
| 3347 | /// only thing that makes a pure-Rust HEVC export bearable (4.30 fps at 1080p on |
| 3348 | /// 12 lanes against 0.55 fps on one, measured 2026-08-11), and an export whose |
| 3349 | /// frames came back shuffled would be no export at all. |
| 3350 | /// |
| 3351 | /// corner-cut: a batch of padded planes sits in memory (~3 MB a frame at 1080p, |
| 3352 | /// so ~37 MB at 12 lanes) and the tail of a timeline is coded on fewer lanes |
| 3353 | /// than the middle. Upgrade path is a pipeline that keeps every lane fed from a |
| 3354 | /// decoder running ahead of the encoder rather than a batch barrier. |
| 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 | |
| 3431 | |
| 3432 | |
| 3433 | |
| 3434 | |
| 3435 | |
| 3436 | |
| 3437 | |
| 3438 | |
| 3439 | |
| 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 | |
| 3557 | |
| 3558 | |
| 3559 | |
| 3560 | |
| 3561 | |
| 3562 | |
| 3563 | |
| 3564 | |
| 3565 | |
| 3566 | |
| 3567 | |
| 3568 | |
| 3569 | |
| 3570 | |
| 3571 | |
| 3572 | |
| 3573 | |
| 3574 | |
| 3575 | |
| 3576 | |
| 3577 | |
| 3578 | |
| 3579 | |
| 3580 | |
| 3581 | |
| 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 | |
| 3638 | |
| 3639 | |
| 3640 | |
| 3641 | |
| 3642 | |
| 3643 | |
| 3644 | |
| 3645 | |
| 3646 | |
| 3647 | |
| 3648 | |
| 3649 | |
| 3650 | |
| 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 | |
| 3742 | |
| 3743 | |
| 3744 | |
| 3745 | |
| 3746 | |
| 3747 | |
| 3748 | |
| 3749 | |
| 3750 | |
| 3751 | |
| 3752 | |
| 3753 | |
| 3754 | |
| 3755 | |
| 3756 | |
| 3757 | |
| 3758 | |
| 3759 | |
| 3760 | |
| 3761 | |
| 3762 | |
| 3763 | |
| 3764 | |
| 3765 | |
| 3766 | |
| 3767 | |
| 3768 | |
| 3769 | |
| 3770 | |
| 3771 | |
| 3772 | |
| 3773 | |
| 3774 | |
| 3775 | |
| 3776 | |
| 3777 | |
| 3778 | |
| 3779 | |
| 3780 | |
| 3781 | |
| 3782 | |
| 3783 | |
| 3784 | |
| 3785 | |
| 3786 | |
| 3787 | |
| 3788 | |
| 3789 | |
| 3790 | |
| 3791 | |
| 3792 | |
| 3793 | |
| 3794 | |
| 3795 | |
| 3796 | /// The oldest coded intra AU, lent out under the same "valid until the next |
| 3797 | /// call" contract [`pop_av1`] has. Every one of them is an IDR, so the key flag |
| 3798 | /// is not a guess. |
| 3799 | |
| 3800 | |
| 3801 | |
| 3802 | |
| 3803 | |
| 3804 | /// One I420 picture copied onto the padded plane sizes the CTB grid needs, the |
| 3805 | /// added rows and columns filled by **replicating the edge** rather than with |
| 3806 | /// black: the padding is coded and then cropped away, and a black border would |
| 3807 | /// bleed into the last real column through the intra prediction and the |
| 3808 | /// transform that straddles it. |
| 3809 | |
| 3810 | |
| 3811 | |
| 3812 | |
| 3813 | |
| 3814 | |
| 3815 | |
| 3816 | |
| 3817 | |
| 3818 | |
| 3819 | |
| 3820 | |
| 3821 | |
| 3822 | |
| 3823 | |
| 3824 | |
| 3825 | |
| 3826 | |
| 3827 | |
| 3828 | |
| 3829 | |
| 3830 | |
| 3831 | |
| 3832 | |
| 3833 | |
| 3834 | |
| 3835 | /// The quantiser an intra HEVC export codes at, mapped from the *bitrate* row a |
| 3836 | /// user picked -- the card has no QP control and this codec has no rate control, |
| 3837 | /// so the two are joined by measurement rather than promised to each other. |
| 3838 | /// |
| 3839 | /// The encoder codes ~0.6 bits per pixel at QP 27 ([`HEVC_BPP_AT_27`], measured |
| 3840 | /// on the 720p and 1080p benches to within 4% of each other), and a step of 6 QP |
| 3841 | /// is a factor of two in rate, which is the classic HEVC relation. So the QP |
| 3842 | /// that would land on a target is `27 + 6 * log2(0.6 / target)` -- and it is |
| 3843 | /// clamped, because this is a *quality* dial and not a rate controller: below QP |
| 3844 | /// 22 the file grows without a picture to show for it, and past QP 40 an |
| 3845 | /// intra-only frame goes blocky in a way no bitrate row asked for. A 1080p30 |
| 3846 | /// timeline at the automatic 6.2 Mbps therefore codes at QP 40 and comes out |
| 3847 | /// bigger than that, which is what "intra-only, large files" on the format row |
| 3848 | /// means: the row buys quality, not a size. |
| 3849 | |
| 3850 | |
| 3851 | |
| 3852 | |
| 3853 | |
| 3854 | |
| 3855 | |
| 3856 | /// What the *bitstream* says the samples mean, in the words a sequence header |
| 3857 | /// spells them -- the same H.273 code points [`crate::mux`] writes into the |
| 3858 | /// container, from the same [`ColorDescription::output`] rule, so the two halves |
| 3859 | /// of a file cannot drift apart. |
| 3860 | /// |
| 3861 | /// This exists because a container tag is not enough: libavcodec takes the |
| 3862 | /// bitstream's answer first, and a stream that says nothing is "unspecified", |
| 3863 | /// which renders BT.601 -- a visible shift on a 709 export that a player reads |
| 3864 | /// from the wrong matrix. Every export is limited range, which is what |
| 3865 | /// `video_full_range_flag = false` says here. |
| 3866 | |
| 3867 | |
| 3868 | |
| 3869 | |
| 3870 | |
| 3871 | |
| 3872 | |
| 3873 | |
| 3874 | |
| 3875 | |
| 3876 | |
| 3877 | |
| 3878 | |
| 3879 | |
| 3880 | |
| 3881 | /// Every temporal unit `rav1e` has finished, moved into the queue in display |
| 3882 | /// order. `NeedMoreData` (send another picture) and `LimitReached` (the flush is |
| 3883 | /// through) are the two ways it says there is nothing more; `Encoded` means a |
| 3884 | /// picture was coded but not yet packetised, which is a *keep asking* -- taking |
| 3885 | /// it for an end leaves the tail of the export inside the encoder. |
| 3886 | |
| 3887 | |
| 3888 | |
| 3889 | |
| 3890 | |
| 3891 | |
| 3892 | |
| 3893 | |
| 3894 | |
| 3895 | |
| 3896 | |
| 3897 | |
| 3898 | |
| 3899 | |
| 3900 | |
| 3901 | /// The oldest finished unit, moved into the buffer that is lent out -- the same |
| 3902 | /// "valid until the next call" contract the plugin's slice has. |
| 3903 | |
| 3904 | |
| 3905 | |
| 3906 | |
| 3907 | |
| 3908 | |
| 3909 | |
| 3910 | |
| 3911 | |
| 3912 | /// I420 straight out of the decoder: the export never converts to BGRA and back, |
| 3913 | /// which would cost two conversions and a generation of colour precision. |
| 3914 | /// |
| 3915 | /// This mirrors `decode`'s two worker loops rather than reusing `DecodeSession`, |
| 3916 | /// which only speaks BGRA. Unlike playback there is no mid-clip fallback to |
| 3917 | /// software: a hardware decode that fails after the first picture fails the |
| 3918 | /// export, which then deletes the half-written file. |
| 3919 | |
| 3920 | |
| 3921 | |
| 3922 | |
| 3923 | |
| 3924 | |
| 3925 | |
| 3926 | |
| 3927 | |
| 3928 | |
| 3929 | |
| 3930 | |
| 3931 | |
| 3932 | |
| 3933 | |
| 3934 | |
| 3935 | |
| 3936 | |
| 3937 | |
| 3938 | /// The receiving half of a decode thread, plus the picture it last handed out |
| 3939 | /// -- which is what lets `next` keep lending planes rather than moving them. |
| 3940 | /// |
| 3941 | /// The first two fields are in this order on purpose, and it is the order |
| 3942 | /// [`crate::decode::FrameStream`] states for the same pair: Rust drops fields as |
| 3943 | /// they are declared, so the receiver disconnects *first* -- the only thing that |
| 3944 | /// wakes a decoder parked in a full `send` -- and the join inside |
| 3945 | /// [`DecodeThread::drop`] runs second. The other way round is a hang and not a |
| 3946 | /// slow path. |
| 3947 | |
| 3948 | |
| 3949 | |
| 3950 | |
| 3951 | |
| 3952 | |
| 3953 | |
| 3954 | |
| 3955 | |
| 3956 | |
| 3957 | |
| 3958 | |
| 3959 | |
| 3960 | /// A decode thread, joined when its span's decoder is dropped -- the rule |
| 3961 | /// [`crate::decode::Worker`] is written for: a thread abandoned mid |
| 3962 | /// `vaInitialize` outlives the process, and Mesa's `atexit` handlers then free |
| 3963 | /// the state it is still reading, which is a SIGSEGV at exit long after the |
| 3964 | /// export succeeded. |
| 3965 | >>); |
| 3966 | |
| 3967 | |
| 3968 | |
| 3969 | |
| 3970 | |
| 3971 | |
| 3972 | |
| 3973 | |
| 3974 | |
| 3975 | |
| 3976 | |
| 3977 | |
| 3978 | /// One picture on its way from a decode thread to the encoder: its bytes, or |
| 3979 | /// the GPU buffer they are still in. |
| 3980 | |
| 3981 | |
| 3982 | |
| 3983 | |
| 3984 | |
| 3985 | |
| 3986 | |
| 3987 | |
| 3988 | |
| 3989 | |
| 3990 | |
| 3991 | |
| 3992 | |
| 3993 | |
| 3994 | |
| 3995 | |
| 3996 | |
| 3997 | |
| 3998 | |
| 3999 | |
| 4000 | |
| 4001 | |
| 4002 | |
| 4003 | |
| 4004 | |
| 4005 | |
| 4006 | |
| 4007 | |
| 4008 | |
| 4009 | /// One picture as the export loop sees it: planes to grade and place, or a |
| 4010 | /// buffer that goes straight into the encoder. |
| 4011 | |
| 4012 | |
| 4013 | |
| 4014 | |
| 4015 | |
| 4016 | |
| 4017 | |
| 4018 | |
| 4019 | |
| 4020 | |
| 4021 | |
| 4022 | |
| 4023 | |
| 4024 | |
| 4025 | |
| 4026 | |
| 4027 | |
| 4028 | |
| 4029 | |
| 4030 | |
| 4031 | |
| 4032 | |
| 4033 | |
| 4034 | |
| 4035 | |
| 4036 | |
| 4037 | |
| 4038 | |
| 4039 | |
| 4040 | |
| 4041 | |
| 4042 | |
| 4043 | |
| 4044 | |
| 4045 | |
| 4046 | |
| 4047 | |
| 4048 | |
| 4049 | |
| 4050 | |
| 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 | /// One span's decode, on its own thread: open the file (hardware if the plugin |
| 4078 | /// will have it, software otherwise) and send every picture until the encoder |
| 4079 | /// stops taking them. |
| 4080 | /// |
| 4081 | /// Unlike playback there is no mid-clip fallback to software: a hardware decode |
| 4082 | /// that fails after the first picture fails the export, which then deletes the |
| 4083 | /// half-written file. |
| 4084 | /// |
| 4085 | /// Every way this returns says which way it was, down the channel: a picture, an |
| 4086 | /// error, or the `Ok(None)` that *is* end of stream. Closing the channel is not |
| 4087 | /// one of them -- a silent close is a panicked thread, and the receiver treats |
| 4088 | /// it as the failure it is rather than as a source that ran out. |
| 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 | /// The two stream decoders, on the thread that opened them. |
| 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 | |
| 4203 | |
| 4204 | |
| 4205 | |
| 4206 | |
| 4207 | |
| 4208 | |
| 4209 | |
| 4210 | |
| 4211 | |
| 4212 | |
| 4213 | |
| 4214 | |
| 4215 | |
| 4216 | |
| 4217 | |
| 4218 | |
| 4219 | |
| 4220 | |
| 4221 | |
| 4222 | |
| 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 | |
| 4258 | |
| 4259 | |
| 4260 | |
| 4261 | |
| 4262 | |
| 4263 | |
| 4264 | |
| 4265 | |
| 4266 | |
| 4267 | |
| 4268 | |
| 4269 | |
| 4270 | |
| 4271 | |
| 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 | |
| 4732 | |
| 4733 | |
| 4734 | |
| 4735 | |
| 4736 | |
| 4737 | |
| 4738 | |
| 4739 | |
| 4740 | |
| 4741 | |
| 4742 | |
| 4743 | |
| 4744 | |
| 4745 | |
| 4746 | |
| 4747 | |
| 4748 | |
| 4749 | |
| 4750 | |
| 4751 |