edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! Subtitles: what is parsed, what is listed and what is drawn. |
| 2 | |
| 3 | use crate::*; |
| 4 | |
| 5 | /// One press of the size stepper, and how far it may be pushed: below |
| 6 | /// [`SUB_SIZE_RANGE`].0 a plate is unreadable, above its top it eats the |
| 7 | /// smallest picture the layout floor promises ([`the_subtitle_plate_and_lanes_fit_the_smallest_window`]). |
| 8 | pub const SUB_SIZE_STEP: f32 = 1.; |
| 9 | pub const SUB_SIZE_RANGE: = ; |
| 10 | |
| 11 | /// The cue's line height at `size`, on the ratio the defaults draw at |
| 12 | /// ([`SUB_LINE_H`] over [`SUB_TEXT`]): a bigger cue wants a taller line, not |
| 13 | /// just bigger letters on the old one. |
| 14 | pub |
| 15 | |
| 16 | |
| 17 | |
| 18 | /// Where the subtitle style survives: beside the keybindings and the theme, |
| 19 | /// same corner-cut persistence -- a torn write costs the style and nothing |
| 20 | /// else, and [`load_subtitle_style`] falls back to the defaults on one. |
| 21 | pub |
| 22 | |
| 23 | |
| 24 | |
| 25 | /// The outline a cue's text is drawn with. gpui has no text stroke, so an |
| 26 | /// outline is copies of the text behind it, each one offset by a step of |
| 27 | /// [`Self::offsets`]. |
| 28 | |
| 29 | pub |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | /// Where the cue plate sits: over the bottom of the picture, the default, or |
| 80 | /// over its top -- for a picture whose bottom is someone else's lower third. |
| 81 | |
| 82 | pub |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | /// Everything the cue plate is drawn with, the app-wide look the subtitle |
| 104 | /// style card edits. The defaults are the look the plate always had. |
| 105 | |
| 106 | pub |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | /// The card's rows in the order the arrow keys walk them. Row 0 is the size |
| 129 | /// slider, the three chip rows follow it, then the platform default, then one |
| 130 | /// row per family in `Player::subtitle_fonts`, from [`SUB_ROW_FIRST_FAMILY`]. |
| 131 | pub const SUB_ROW_SIZE: usize = 0; |
| 132 | pub const SUB_ROW_OUTLINE: usize = 1; |
| 133 | pub const SUB_ROW_BOX: usize = 2; |
| 134 | pub const SUB_ROW_PLACE: usize = 3; |
| 135 | /// The caption animation rows edit the project's caption style (what a burn draws), not the |
| 136 | /// app-wide plate: the animation, the highlight colour, the highlight box, capitals and the |
| 137 | /// words on screen at once. |
| 138 | pub const SUB_ROW_ANIM: usize = 4; |
| 139 | pub const SUB_ROW_HIGHLIGHT: usize = 5; |
| 140 | pub const SUB_ROW_HL_BOX: usize = 6; |
| 141 | pub const SUB_ROW_UPPERCASE: usize = 7; |
| 142 | pub const SUB_ROW_WORDS: usize = 8; |
| 143 | pub const SUB_ROW_DEFAULT: usize = 9; |
| 144 | pub const SUB_ROW_FIRST_FAMILY: usize = 10; |
| 145 | |
| 146 | /// The highlight colours the card offers, by name. |
| 147 | pub const HIGHLIGHT_SWATCHES: = |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | ; |
| 155 | |
| 156 | /// The size a slider position names: the range's own span, whole pixels, so |
| 157 | /// a drag lands on the sizes the stepper and the file both use. |
| 158 | pub |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | /// Lines: the family (empty for the system default), the size, then the |
| 164 | /// outline, the box (`on` or `off`) and the place. A file older than the |
| 165 | /// outline, box and place has only the first two, and a line this build does |
| 166 | /// not know keeps its default -- so an old style still loads, and a new one |
| 167 | /// loads in an old build as the size it always was. |
| 168 | /// Anything unreadable, missing or out of range leaves the defaults in |
| 169 | /// force -- a subtitle style file is not the user's work, so a bad one is |
| 170 | /// worth no message at startup, exactly as [`ui::theme::load`]. |
| 171 | pub |
| 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 | /// Writes the style whole, the way [`ui::theme::save`] writes the palette. |
| 206 | pub |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | /// Whether a dropped or named path is a subtitle file rather than media: the |
| 225 | /// formats `engine::subtitle` parses, lowercased, for [`engine::is_audio`]'s |
| 226 | /// reason -- the import door has to know which of the engine's two doors a file |
| 227 | /// goes through before anything is opened. |
| 228 | /// |
| 229 | /// `.mks` is one of them, and it is the only Matroska extension that is: it is |
| 230 | /// the *subtitles alone*, so there is no source in it to import and a drop of |
| 231 | /// one used to be refused for having no video track -- while `+ S` on the same |
| 232 | /// bytes took it ([`PlaybackSession::parse_subtitles`] reads it as Matroska). |
| 233 | /// The other two are media and stay media: `.mka` is the sound alone, which |
| 234 | /// [`engine::is_audio`] already imports as a song, and `.mk3d` is a film. Both |
| 235 | /// may *carry* subtitles, which is [`carries_subtitles`] and not this. |
| 236 | pub |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | /// Whether a media path is a container that can carry subtitle tracks *inside* |
| 246 | /// it -- every Matroska extension and the three ISO-BMFF ones, which is the list |
| 247 | /// [`PlaybackSession::parse_subtitles`] walks (Matroska blocks and mp4 `tx3g` |
| 248 | /// alike). Named for what it gates and not for one of the two families, because |
| 249 | /// an mp4 answers `true` here now. |
| 250 | /// |
| 251 | /// Matroska's set is the standard's own and closed by it |
| 252 | /// (`engine::demux::is_matroska`), so it is copied whole rather than trimmed to |
| 253 | /// the two that carry a film: a `.mk3d` opened as media has its tracks walked |
| 254 | /// like the `.mkv` it is, and a `.mka` song can hold a lyric track. A suffix |
| 255 | /// wider than the engine's would be a file taken here and refused deeper down. |
| 256 | pub |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | /// What a worker hands back, which is the fork [`arrival`] made when it was |
| 266 | /// started. An import is *read* and thrown away; the file argv named is opened |
| 267 | /// outright, because nothing else is going to open it afterwards. |
| 268 | pub |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | /// What the container walk found, for [`Player::take_import`] to register, or |
| 287 | /// the engine's refusal in the words it would have used on the UI thread. |
| 288 | /// |
| 289 | /// `None` for the doors that never reach a demuxer: a song, a still and a |
| 290 | /// subtitle file, whose own small reads stay where they were |
| 291 | /// ([`engine::PlaybackSession::import`]). |
| 292 | pub type Probe = ; |
| 293 | |
| 294 | /// A media file opened as a session, with the subtitle tracks it carries inside |
| 295 | /// it taken in the same breath -- the two reads a file costs, in the one place |
| 296 | /// both doors ([`Player::open_media`] and the worker below) go through. |
| 297 | /// |
| 298 | /// `place` is which door: a file *opened* is the timeline, one *imported* into |
| 299 | /// an empty window fills the library and leaves the lanes empty for a drag. |
| 300 | pub |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | /// The whole of what a queued file costs, off the UI thread. An import only |
| 315 | /// needs its pages warmed ([`read_ahead`]); the file argv named is *opened* |
| 316 | /// here instead, and that is the difference between a warm launch paying for |
| 317 | /// one header walk and paying for two -- the window is up either way. |
| 318 | pub |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | /// A whole timeline, opened here and handed over: the file argv named (`place`, |
| 335 | /// which *is* the timeline) and a file arriving at a window with no timeline to |
| 336 | /// import into, which fills the library instead. One function because they are |
| 337 | /// one read -- the engine's two doors differ by which lanes come up empty |
| 338 | /// ([`engine::PlaybackSession::open_library`]), not by what they walk. |
| 339 | pub |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | /// Reads, off the UI thread, everything the import that follows would have read |
| 362 | /// -- and hands all of it over. Nothing here is a warm-up any more: the |
| 363 | /// container is *probed* ([`engine::PlaybackSession::probe_import`]) and the |
| 364 | /// subtitle tracks are *walked*, and [`Player::take_import`] registers what came |
| 365 | /// back. Measured on the 24 GB 4K HEVC remux: 21.4 s of header cold, 429 ms |
| 366 | /// warm, plus 1-4 s of probing the timeline's own first source, plus the cue |
| 367 | /// walk -- all of it here, and the window keeps painting through it. |
| 368 | /// |
| 369 | /// `gate` is the timeline the file is checked against |
| 370 | /// ([`engine::PlaybackSession::import_gate`]), taken before the worker started |
| 371 | /// because a worker cannot reach the session. `None` is a window with no |
| 372 | /// timeline to import into: then there is nothing to check against and nothing |
| 373 | /// to register, so the file is *opened* here instead, whole |
| 374 | /// ([`open_whole`]) -- which is the same twenty seconds, on the same thread, |
| 375 | /// rather than on the one that draws. |
| 376 | /// |
| 377 | /// The header error is carried back now rather than dropped: it is the engine's |
| 378 | /// own refusal, from the only walk anybody makes, so it is worded once and shown |
| 379 | /// at the landing. The subtitle refusal travels beside it for the same reason. |
| 380 | /// |
| 381 | /// `stage` is what the line above the panel is naming while this runs. |
| 382 | pub |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | /// The toast's own words for a standalone audio import -- rate, channel |
| 415 | /// count and rounded length -- appended after every other tail, so an |
| 416 | /// audio-only file's IMPORTED line reads the numbers a properties card would |
| 417 | /// otherwise take a click to open. `has_video` is the caller's probed answer |
| 418 | /// ([`Player::has_video`], or the import's own `NoVideoTrack` refusal): a |
| 419 | /// film's toast is unchanged, an audio-only container gets the numbers the |
| 420 | /// same as a song, and a song whose own small header read comes back empty |
| 421 | /// stays plain. |
| 422 | pub |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | /// Every subtitle track a file carries, cues and all -- the walk that costs, in |
| 442 | /// the one place every door that pays it goes through. `Ok` and empty for a file |
| 443 | /// with none to read, which is what a file that is neither a container we can |
| 444 | /// walk ([`carries_subtitles`]) nor a subtitle file is: the same answer |
| 445 | /// `add_subtitle_tracks` gives it, and nothing is opened to find that out. |
| 446 | /// |
| 447 | /// Nothing in here is a session, on purpose ([`PlaybackSession::parse_subtitles`] |
| 448 | /// is an associated fn): no borrow crosses the await, so this runs whole on a |
| 449 | /// worker while the window keeps painting. |
| 450 | pub |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | /// The subtitle tracks a media file carries, taken into the session as it is |
| 458 | /// opened, and the tail the notice grows for them: an mkv or an mp4 with |
| 459 | /// subtitles in it arrives with its subtitles, because a track nobody imported |
| 460 | /// is a track nobody knows is there. Every other container answers `None` |
| 461 | /// without being read. |
| 462 | /// |
| 463 | /// A refusal is a tail too, never a failure of the open: the picture and the |
| 464 | /// sound of a film whose subtitle tracks cannot be walked are still the film. |
| 465 | /// |
| 466 | /// Both halves at once, which only a *worker* may do: the walk reads the whole |
| 467 | /// file for its cues (`engine::subtitle::of_matroska`) -- ~200 ms on a two-hour |
| 468 | /// 4K remux, 9.7 s on a cold 25 GB one. The one caller is the open beside which |
| 469 | /// this runs on the worker ([`open_ahead`]), never the render thread; an |
| 470 | /// import splits the two halves across the hop instead ([`read_ahead`] walks, |
| 471 | /// [`subtitle_tail`] pushes). |
| 472 | pub |
| 473 | |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | |
| 479 | /// What a subtitle walk ([`walk_subtitles`]) gave, on its way from whichever |
| 480 | /// thread paid for it to the timeline. `Send` all the way down (`sendable()`, |
| 481 | /// `engine/tests/subtitles.rs`), which is what lets the walk be a worker's. |
| 482 | pub type Subs = Result; |
| 483 | |
| 484 | /// The tail a file's own subtitle tracks earn on the notice that names it, and |
| 485 | /// the push that puts them on the timeline -- the second half of the walk, the |
| 486 | /// cheap one ([`PlaybackSession::add_subtitle_tracks`]: no open, no seek, no |
| 487 | /// decode). Every door that arrives with a *file* words it here, once: the file |
| 488 | /// argv named, an import, and an import into an empty window cannot say the same |
| 489 | /// thing differently, whichever thread read the cues. |
| 490 | /// |
| 491 | /// A count and nothing else (DESIGN §8: the room never explains itself in |
| 492 | /// prose). The tracks land in a *list* beside the media, not over the picture |
| 493 | /// ([`Player::subtitle_overlay`] shows one once it is on a subtitle lane) -- |
| 494 | /// where they went is the list's own geography to say, not this line's. |
| 495 | /// |
| 496 | /// `None` for a file that gave none and for one whose tracks are on the timeline |
| 497 | /// already -- an import that adds nothing says nothing about subtitles. A |
| 498 | /// refusal is a tail too, never a failure of the import: the picture and the |
| 499 | /// sound of a film whose subtitle tracks cannot be walked are still the film. |
| 500 | pub |
| 501 | |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | |
| 507 | |
| 508 | |
| 509 | |
| 510 | /// What the subtitles toggle says it just did ([`Player::toggle_subtitles`]), |
| 511 | /// worded off the lanes: `placed` is every caption on every subtitle lane |
| 512 | /// ([`Player::placed_captions`]), because that -- and never the palette row the |
| 513 | /// list marks -- is what the toggle covers and uncovers. |
| 514 | /// |
| 515 | /// Nothing placed is its own sentence: "Subtitles shown — 0 caption(s)" over an |
| 516 | /// unchanged picture reads as a broken toggle, so it says the move that would |
| 517 | /// put words there instead. |
| 518 | pub |
| 519 | |
| 520 | |
| 521 | |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | /// The push both deliberate add-subtitles doors end on -- `+ S` and its key |
| 527 | /// ([`Player::add_subtitles`]) and a dropped or argv'd subtitle file |
| 528 | /// ([`Player::take_subtitles`]) -- so the two cannot come to word the same file |
| 529 | /// differently. |
| 530 | /// |
| 531 | /// The walk having found *nothing* is a refusal and not a count: a container |
| 532 | /// with no subtitle track in it and a file whose tracks are all on the timeline |
| 533 | /// already both push zero rows, and they are opposite answers -- one says look |
| 534 | /// somewhere else, the other says you already have them. The engine's own door |
| 535 | /// draws the same line in the same words |
| 536 | /// ([`PlaybackSession::no_subtitles_in`], asked here because this route splits |
| 537 | /// the walk from the push to keep the walk off the render thread). |
| 538 | /// |
| 539 | /// The file itself joins nothing either way: no library row, no lane, no clip. |
| 540 | /// Subtitles are a list the timeline carries, and this is the only thing that |
| 541 | /// touches it. |
| 542 | pub |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | |
| 552 | |
| 553 | /// What a subtitle row says under its name: how many cues it holds and whether |
| 554 | /// they are pictures ([`engine::subtitle::SubtitleTrack::is_bitmap`]) -- which |
| 555 | /// is the difference between a track an export writes into the file and one it |
| 556 | /// can only draw -- or, for a track that could not be read, the engine's own |
| 557 | /// reason verbatim. A refusal is still what a row can be *for*: a VobSub track |
| 558 | /// dropped from the list would say the film has no subtitles at all. |
| 559 | pub |
| 560 | |
| 561 | |
| 562 | |
| 563 | |
| 564 | |
| 565 | |
| 566 | |
| 567 | /// What the export card's Subtitles row says: the engine's own words for the |
| 568 | /// tracks an export carries (`plan`, [`engine::export::planned_subtitles`] asked |
| 569 | /// about `picks`) and, beside them, the rows it is carrying nothing of. |
| 570 | /// |
| 571 | /// `picks` is [`Player::export_subs`] -- every track with a cue left in the |
| 572 | /// exported range -- so a track sitting in the list with eighty-three cues |
| 573 | /// nowhere near a trimmed timeline never reaches the engine at all, and the card |
| 574 | /// said nothing about it while the list went on showing it. Which tracks have |
| 575 | /// cues *here* is this side's answer and nobody else's, so this side words it. |
| 576 | /// |
| 577 | /// Past [`SUB_PLAN_CHARS`] the line counts rather than names: every name is more |
| 578 | /// words in a value box `MENU_W` wide, and at 35 tracks the row wrapped to ten |
| 579 | /// lines and pushed the Destination row under the fold of the card. The names |
| 580 | /// are still one row each in the Subtitles list, with the cue count and the |
| 581 | /// reason under them ([`subtitle_detail`]) -- more than this line ever said. |
| 582 | /// |
| 583 | /// The counted split follows the engine's own order of reasons (`refused`, then |
| 584 | /// pictures, then no cues), with the last asked of the timeline instead of the |
| 585 | /// track. |
| 586 | /// |
| 587 | /// corner-cut: that split reads the same public fields the list rows read |
| 588 | /// (`refused`, [`engine::subtitle::SubtitleTrack::is_bitmap`]) rather than the |
| 589 | /// engine's decision, so a *new* reason to drop a track would be counted here as |
| 590 | /// embedded until this follows it -- the named line, which is the engine's |
| 591 | /// string verbatim, would say it correctly meanwhile. Upgrade path: reasons out |
| 592 | /// of `planned_subtitles` as data rather than as one sentence, which is an |
| 593 | /// engine change. |
| 594 | // read by `Player::subtitle_line`, which Settings shows |
| 595 | pub |
| 596 | |
| 597 | |
| 598 | |
| 599 | |
| 600 | |
| 601 | |
| 602 | |
| 603 | |
| 604 | |
| 605 | |
| 606 | |
| 607 | |
| 608 | |
| 609 | |
| 610 | |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | |
| 616 | |
| 617 | |
| 618 | |
| 619 | |
| 620 | |
| 621 | |
| 622 | |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | |
| 637 | |
| 638 | |
| 639 | |
| 640 | |
| 641 | |
| 642 | |
| 643 | |
| 644 | |
| 645 | |
| 646 | |
| 647 | |
| 648 | |
| 649 | |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| 654 | /// Whether the engine's sentence already speaks for this row: with words placed |
| 655 | /// on lanes, every clause of it names the palette row its lane shows |
| 656 | /// ([`engine::export::planned_subtitles`]) -- and a line that embeds a track and |
| 657 | /// then says the same track is on no track is a line contradicting itself. |
| 658 | /// |
| 659 | /// corner-cut: the match is the label found in the sentence, because the engine |
| 660 | /// hands back one string and not the rows it spoke for. Ceiling: two rows whose |
| 661 | /// labels are one a prefix of the other ("eng", "eng 2") -- with the longer one |
| 662 | /// placed, the shorter loses its clause; it never gains a wrong one. Upgrade |
| 663 | /// path: `planned_subtitles` handing its clauses back as data, the same upgrade |
| 664 | /// [`subtitle_plan`]'s own note names. |
| 665 | |
| 666 | |
| 667 | |
| 668 | |
| 669 | /// Every subtitle track one file gave, kept together. Plain data, planned |
| 670 | /// before anything is drawn -- the grouping is the branchy part and it is the |
| 671 | /// same answer whatever a styling puts around it. |
| 672 | /// |
| 673 | /// [`Player::subtitle_section`] draws one block per group of these, and |
| 674 | /// [`sub_pick_name`] names the pick out of the same answer -- so what a heading |
| 675 | /// says and what a row a person clicked says cannot disagree. |
| 676 | |
| 677 | pub |
| 678 | |
| 679 | |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | |
| 687 | |
| 688 | /// One subtitle track, as a row shows it. |
| 689 | |
| 690 | pub |
| 691 | |
| 692 | |
| 693 | |
| 694 | |
| 695 | |
| 696 | |
| 697 | |
| 698 | |
| 699 | |
| 700 | |
| 701 | |
| 702 | |
| 703 | |
| 704 | |
| 705 | |
| 706 | |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 | /// What a subtitle row is called, off the two fields the container really |
| 713 | /// stated rather than out of the flattened |
| 714 | /// [`label`](engine::subtitle::SubtitleTrack::label). The pair is what an export |
| 715 | /// writes (`TRACK_LANGUAGE` and `TRACK_NAME` are two fields), and reading the |
| 716 | /// display string back apart is the very heuristic that sent every French track |
| 717 | /// out as English: `lang_human` on a whole "und — Signs" matches nothing and |
| 718 | /// names a language nobody speaks. |
| 719 | /// |
| 720 | /// The three shapes a track arrives in, all three of them real: a standalone |
| 721 | /// file states no language and is its own name, an embedded one states a |
| 722 | /// language and sometimes a title beside it, and a refused one states neither |
| 723 | /// and keeps the label it was refused under (`SubtitleTrack::refused`). |
| 724 | pub |
| 725 | |
| 726 | |
| 727 | |
| 728 | |
| 729 | |
| 730 | |
| 731 | |
| 732 | |
| 733 | |
| 734 | |
| 735 | |
| 736 | |
| 737 | |
| 738 | /// The subtitle list as rows under the file each came out of: one group per |
| 739 | /// distinct path, in the order the files first appear, and each file's tracks |
| 740 | /// in the order they were added. Two remuxes' tracks arriving interleaved -- |
| 741 | /// which is what importing a second film does -- still read as two films. |
| 742 | pub |
| 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 | /// How the picked track is named wherever the pick is echoed -- the strip |
| 772 | /// header, the section heading, the toggle's own notice. What the track is |
| 773 | /// *and* which file it came out of: two remuxes each carrying an "eng" track |
| 774 | /// give the same word twice, and the file is the only thing that tells them |
| 775 | /// apart. A file that gave several of them numbers them within itself, the way |
| 776 | /// [`row_name`] numbers audio streams, since "eng" twice off one remux is the |
| 777 | /// same problem one file down. |
| 778 | /// |
| 779 | /// Goes through [`subtitle_rows`], so the name a header says and the row a |
| 780 | /// person clicked cannot disagree -- and the label is humanised there, so an |
| 781 | /// "und" track is named in words here without being passed through |
| 782 | /// [`lang_human`] twice. |
| 783 | /// |
| 784 | /// `None` for an index no track answers to, which is the silence |
| 785 | /// [`Player::subtitle_track`] gives at the same moment. |
| 786 | /// Where the picked subtitle row lands once `removed` has been taken off a list |
| 787 | /// that is `left` long afterwards. The pick follows the list: the same *track* |
| 788 | /// while it is still there -- every index past the one that went moves down |
| 789 | /// ([`engine::Project::remove_subtitles`]) -- the row that slid into the empty |
| 790 | /// place when the picked one is what went, and the last row when that was the |
| 791 | /// last. Zero on an emptied list, which is the index the section is not drawn at |
| 792 | /// all. |
| 793 | /// |
| 794 | /// Its own function because the pick is read as "which row" everywhere it is |
| 795 | /// echoed -- the dock highlights the picked row by comparing it |
| 796 | /// (`dock_stance`'s `track == player.sub_track`), and the section heading and |
| 797 | /// its notices name it -- so left where it was it would highlight one track and |
| 798 | /// name another the moment a row above it went. The plate over the picture is |
| 799 | /// not on that list: it is drawn from the *placements* on the shown lane |
| 800 | /// ([`Player::active_sub_lane`], and the session's own `sub_lane_cues`). What an export |
| 801 | /// writes is not this pick either -- it is worked out from the cues on the |
| 802 | /// timeline each time ([`Player::export_subs`]). |
| 803 | pub |
| 804 | |
| 805 | |
| 806 | |
| 807 | |
| 808 | |
| 809 | |
| 810 | |
| 811 | /// What a palette row *is*, apart from where it sits: the file it came out of, |
| 812 | /// which track of it, and the two words a row shows. Cloned out of the palette |
| 813 | /// once per history step -- a path and three short strings, against a palette |
| 814 | /// whose cues are the whole film's subtitles. Not [`SubRow`], which is a row as |
| 815 | /// the column *draws* it. |
| 816 | |
| 817 | pub |
| 818 | |
| 819 | |
| 820 | |
| 821 | |
| 822 | |
| 823 | |
| 824 | |
| 825 | |
| 826 | |
| 827 | |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 | |
| 833 | |
| 834 | |
| 835 | |
| 836 | |
| 837 | |
| 838 | |
| 839 | |
| 840 | |
| 841 | |
| 842 | |
| 843 | |
| 844 | |
| 845 | |
| 846 | |
| 847 | /// Where the pick lands once a *restored* palette is back in place: the row |
| 848 | /// that was picked, found by what it is rather than by where it sat. |
| 849 | /// |
| 850 | /// A history step moves rows without saying which one moved -- an undo of a |
| 851 | /// removal puts a column back above the pick as often as below it -- so an |
| 852 | /// index left where it was names a different track, which is the desync |
| 853 | /// [`sub_pick_after_removal`] prevents at the door where the row that moved is |
| 854 | /// known. That door's arithmetic is this map's one-row-moved case. |
| 855 | /// |
| 856 | /// A row the restored palette does not have (it went again, or the pick named |
| 857 | /// nothing) falls back to the old index clamped into the new list -- that same |
| 858 | /// door's own fallback, and the zero the section is not drawn at all for an |
| 859 | /// emptied palette. |
| 860 | pub |
| 861 | |
| 862 | |
| 863 | |
| 864 | |
| 865 | |
| 866 | |
| 867 | |
| 868 | |
| 869 | |
| 870 | pub |
| 871 | |
| 872 | |
| 873 | |
| 874 | |
| 875 | |
| 876 | |
| 877 | |
| 878 | |
| 879 | |
| 880 | |
| 881 | |
| 882 | |
| 883 | |
| 884 | |
| 885 | |
| 886 | |
| 887 | |
| 888 | |
| 889 | |
| 890 | /// Where a cue is drawn on the bed: left edge and width in pixels, through the |
| 891 | /// same [`Scale`] every clip box goes through -- so a cue and the take it is |
| 892 | /// spoken over line up at every zoom, which is the only reason the strip is |
| 893 | /// worth drawing. Microseconds are the cue's unit and seconds are the scale's, |
| 894 | /// and this is the one place they meet. |
| 895 | /// |
| 896 | /// Never narrower than [`SUB_CUE_MIN_W`]: zoomed out, a one-second cue is a |
| 897 | /// fraction of a pixel, and a mark that rounds away reads as a track with |
| 898 | /// nothing in it. |
| 899 | |
| 900 | pub |
| 901 | |
| 902 | |
| 903 | |
| 904 | /// [`cue_box`] for a stretch of the timeline's own clock, in microseconds: how a cue block of a |
| 905 | /// lane is placed ([`engine::project::CueSpan`]). |
| 906 | pub |
| 907 | |
| 908 | |
| 909 | |
| 910 | |
| 911 | |
| 912 | |
| 913 | |
| 914 | /// Which subtitle lane draws over the picture, out of the pick somebody made |
| 915 | /// and the lanes there are *now* ([`Player::active_sub_lane`]): the picked one |
| 916 | /// while it is still on the timeline, and the first lane otherwise -- which is |
| 917 | /// the whole of "one lane needs no picking", "the first lane added draws" and |
| 918 | /// "a removed lane's pick promotes its neighbour rather than showing nothing". |
| 919 | /// |
| 920 | /// `None` only with no subtitle lane at all, which is a timeline with nowhere |
| 921 | /// for words to be. |
| 922 | /// |
| 923 | /// A pick against the live list rather than a pointer kept in step with it: a |
| 924 | /// [`Lane`] is a position among its kind, so an add, a removal, a reorder and |
| 925 | /// every undo of those move what a stored handle names -- and each of them is |
| 926 | /// answered here, at the read, by a list that is never stale. |
| 927 | pub |
| 928 | |
| 929 | |
| 930 | |
| 931 | |
| 932 | |
| 933 | /// Which cues of a track are on screen at `at` seconds. Half-open, as the cue |
| 934 | /// itself is: one that ends exactly where the next begins hands over rather than |
| 935 | /// overlapping it for a frame, and several that genuinely overlap all come back |
| 936 | /// -- a sign and a line of dialogue are two cues at one moment. |
| 937 | pub |
| 938 | |
| 939 | |
| 940 | |
| 941 | |
| 942 | |
| 943 | |
| 944 | /// How long a failed waveform decode is left alone before the next repaint asks |
| 945 | /// again: long enough that sixty repaints a second do not become sixty decodes, |
| 946 | /// short enough that a file which arrived mid-copy has its envelope a moment |
| 947 | /// after it lands. The engine memoizes no failure for the same reason |
| 948 | /// ([`engine::waveform`]): the reason one failed may have gone away. |
| 949 | pub const WAVE_RETRY: Duration = from_secs; |
| 950 | |
| 951 | /// The sources a repaint has not asked about yet, as of `now`. A key that is |
| 952 | /// already there means "asked", whatever state it is in -- which is what stops |
| 953 | /// a decode already running from being started again by the next of sixty |
| 954 | /// repaints a second -- with one exception: a [`Wave::Failed`] older than |
| 955 | /// [`WAVE_RETRY`] is asked again, because a decode that failed once is not an |
| 956 | /// answer about the file, only about the moment it was tried. A file with no |
| 957 | /// audio (`Wave::Silent`) is an answer like any other and is never re-asked. |
| 958 | pub |
| 959 | |
| 960 | |
| 961 | |
| 962 | |
| 963 | |
| 964 | |
| 965 | |
| 966 | |
| 967 | |
| 968 | |
| 969 | |
| 970 | |
| 971 | |
| 972 | |
| 973 | |
| 974 | |
| 975 | /// The same, for the per-file caches: one entry per *file*, however many of its |
| 976 | /// streams the timeline plays. Generic in the value, because the stream probe |
| 977 | /// and the still's own size are both asked once per file and answered by |
| 978 | /// presence in a map. |
| 979 | pub |
| 980 | |
| 981 | |
| 982 | |
| 983 | |
| 984 | |
| 985 | |
| 986 | |
| 987 | |
| 988 | |
| 989 | /// The films a repaint may start a stand-in for ([`engine::proxy`]): the unseen |
| 990 | /// ones while this project makes them by itself, and **none at all** while it |
| 991 | /// does not -- until the Proxies switch is thrown, which is the ask, since |
| 992 | /// nothing else offers to make one. |
| 993 | /// |
| 994 | /// A film left out here stays out of the map it was checked against, which is |
| 995 | /// what brings it back the moment either switch says yes: an import made while |
| 996 | /// both were off is not a film that missed its turn. |
| 997 | pub |
| 998 | |
| 999 | |
| 1000 | |
| 1001 | |
| 1002 | |
| 1003 | |
| 1004 | |
| 1005 | |
| 1006 | |
| 1007 | |
| 1008 | |
| 1009 | /// Which timeline frame the playhead is on, by the rule the engine's own edits |
| 1010 | /// use (playback.rs `secs_to_frame`): the frame that has started, with the |
| 1011 | /// epsilon that keeps a clock sitting exactly on a boundary from reading as the |
| 1012 | /// frame before it. Only ever a hint here -- what an edit does is still the |
| 1013 | /// engine's answer, taken from the same seconds. |
| 1014 | pub |
| 1015 | |
| 1016 | |
| 1017 | |
| 1018 | /// The tallest the engine-drawn caption bitmap is: the text scales with the |
| 1019 | /// frame's height, so a 540-line canvas draws the same picture as a 4K one at a |
| 1020 | /// fraction of the shaping and upload cost, and the plate scales it to fit. |
| 1021 | const CAPTION_CANVAS_H: u32 = 540; |
| 1022 | |
| 1023 | /// The animated caption at timeline frame `frame`, drawn by the engine's own |
| 1024 | /// burn function ([`engine::captionanim::plan`] into |
| 1025 | /// [`engine::text::overlay_blocks`], what an export paints too) as a straight |
| 1026 | /// alpha BGRA bitmap the size of the (scaled) project canvas. |
| 1027 | /// |
| 1028 | /// `cues` are the ones on screen, on the timeline's clock. Returns the key of |
| 1029 | /// what was drawn -- its words and every word's pose, so two frames that look |
| 1030 | /// alike share a key and a held cue is drawn once -- and the bitmap; `None` |
| 1031 | /// where nothing is on screen. The key is computed *before* any text is shaped, |
| 1032 | /// so a caller that already holds that key never pays for the drawing. |
| 1033 | pub |
| 1034 | |
| 1035 | |
| 1036 | |
| 1037 | |
| 1038 | |
| 1039 | |
| 1040 | |
| 1041 | |
| 1042 | |
| 1043 | |
| 1044 | |
| 1045 | |
| 1046 | |
| 1047 | |
| 1048 | |
| 1049 | |
| 1050 | |
| 1051 | |
| 1052 | /// The bitmap for `blocks` ([`animated_caption_key`]) on a canvas of the |
| 1053 | /// project's shape, and its size. Straight alpha, BGRA: the text is composed |
| 1054 | /// over black and over white, and the difference of the two is the coverage. |
| 1055 | pub |
| 1056 | |
| 1057 | |
| 1058 | |
| 1059 | |
| 1060 | |
| 1061 | |
| 1062 | |
| 1063 | |
| 1064 | |
| 1065 | |
| 1066 | |
| 1067 | |
| 1068 | |
| 1069 | |
| 1070 | |
| 1071 | |
| 1072 | |
| 1073 | |
| 1074 | |
| 1075 | |
| 1076 | |
| 1077 | |
| 1078 | |
| 1079 | |
| 1080 | |
| 1081 | |
| 1082 | |
| 1083 | |
| 1084 | |
| 1085 | |
| 1086 | |
| 1087 | |
| 1088 | |
| 1089 | |
| 1090 | |
| 1091 | |
| 1092 | |
| 1093 |