edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! Bringing a file in: the library's tabs, the import and scan state, the stages. |
| 2 | |
| 3 | use crate::*; |
| 4 | |
| 5 | // The library's three categories -- `LibraryTab::Media/Audio/Text`, their |
| 6 | // `holds` filter and their three empty nouns -- went with cleanse round 2 |
| 7 | // (2026-09-10): the dock shows one list of everything and a row says its own |
| 8 | // kind on its metadata line, so there is no tab to answer and no third empty |
| 9 | // word to keep in step. `is_subtitle` (subs.rs) is still the kind check the |
| 10 | // import fork reads. |
| 11 | |
| 12 | /// What is known about a source's audio. Three states and not two, because a |
| 13 | /// file whose peaks have not come back yet must not be drawn as one that has no |
| 14 | /// audio at all: the first shows a bed, the second shows nothing. |
| 15 | |
| 16 | pub |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | /// The bench's own version of [`Wave`] for the picture instead of the sound: one |
| 34 | /// representative decoded frame per file, kept and reused across every clip cut |
| 35 | /// from it (DESIGN.md §5's "real thumbnails across video clips", §12 step 5 -- |
| 36 | /// this is the frame, not the ink; the ink comes from [`crate::source_tint`] |
| 37 | /// until real extraction lands). Audio-only files never enter this map (see |
| 38 | /// `cache_media`'s filter), so `Silent` has no counterpart here. |
| 39 | |
| 40 | pub |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | /// What a source's stand-in is up to ([`engine::proxy`]). Kept per file and |
| 49 | /// filled like every other library fact -- presence means "asked", so a repaint |
| 50 | /// mid-encode cannot start a second one. |
| 51 | pub |
| 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 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | /// The import a worker is reading, as the line above the panel shows it. No |
| 86 | /// fraction anywhere: neither read reports how far into the file it has come, |
| 87 | /// so what is honest is the file's name, the stage, and two clocks -- one that |
| 88 | /// proves the window is answering, one that says the stage has not moved. |
| 89 | pub |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | /// What a scan is *of*: the source, which of its audio streams, and the clip's |
| 134 | /// own `[in, out)` source frames. The range is part of the name because it is |
| 135 | /// part of the read -- a clip cut in half is a different, shorter decode than |
| 136 | /// the whole take was, and levels read for one are not the other's. |
| 137 | pub type ScanKey = ; |
| 138 | |
| 139 | /// The silence scan a worker is running, as the card shows it. Same two clocks |
| 140 | /// as an [`Import`] and for the same reason -- one proves the window answers, |
| 141 | /// one says the read has stopped moving -- over a progress that *can* move: |
| 142 | /// a decode knows how far into the sound it has come, so the card says so. |
| 143 | pub |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | /// How long a stage may sit without moving before the import line stops |
| 177 | /// reading like a progress line and says outright that the wait is the file's, |
| 178 | /// not the window's. Five seconds: a 25 GB remux spends eleven in its header |
| 179 | /// alone, and a person watching a still line for that long has already decided |
| 180 | /// the editor hung. |
| 181 | pub const IMPORT_STALL: f32 = 5.; |
| 182 | |
| 183 | /// Which of an import's two reads the worker is inside. Travels as one atomic, |
| 184 | /// the way an export's progress does ([`engine::ExportHandle`]) -- there is no |
| 185 | /// fraction to send, because neither read reports where in the file it is. |
| 186 | |
| 187 | pub |
| 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 | /// argv sorted into the file that becomes the timeline and the queue every |
| 217 | /// named file is read through, in the order they were named. The whole of what |
| 218 | /// a launch does before the window is on screen -- and it touches no disk, |
| 219 | /// which is the point: the header walk happens on a worker with the window |
| 220 | /// already up ([`Player::take_import`]). |
| 221 | pub |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | /// What a queued file turns into. Every file goes through one queue -- argv's |
| 229 | /// first file, argv's extras, a drop, the Import button -- and this is the fork |
| 230 | /// its worker is started on. |
| 231 | |
| 232 | pub |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | /// Whether `path` is an OpenTimelineIO file: a timeline to make a sequence of, never media. |
| 243 | pub |
| 244 | |
| 245 | |
| 246 | |
| 247 | /// Which of the three a queued file is (`landing` above is the drag's). |
| 248 | /// `opening` is the one path argv named and is cleared as it lands, so a second |
| 249 | /// arrival of the same *media* path -- a drop of the film that is already open |
| 250 | /// -- is an import, which is what a drop has always been. |
| 251 | /// |
| 252 | /// A `.edith` is never an import, whichever door it came through: it is a whole |
| 253 | /// timeline and there is nothing to add it to. Argv's, a dropped one and the |
| 254 | /// Import button's are one landing, so the seconds its open costs are the |
| 255 | /// worker's for all three ([`open_ahead`]) and the line above the panel names it |
| 256 | /// while it runs. |
| 257 | pub |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | /// The whole of what an import shows while it runs: which file, which stage, |
| 266 | /// the clock that proves the window is still answering, and what is behind it |
| 267 | /// in the queue. |
| 268 | /// |
| 269 | /// `since` is how long the *stage* has stood still, which is the only movement |
| 270 | /// an unmeasurable read has: past [`IMPORT_STALL`] the line says so in words, |
| 271 | /// because a bar that cannot move and a bar that has stopped look identical. |
| 272 | /// |
| 273 | /// `opening` is the file argv named, which is read through the same queue and |
| 274 | /// says so in the same words -- except that it is being *opened*, and a line |
| 275 | /// that called it an import would be describing the wrong thing to the one |
| 276 | /// person who typed the name. |
| 277 | pub |
| 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 | /// What opening the silence card on a source costs. |
| 305 | |
| 306 | pub |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | /// Which of the three [`ScanPlan`]s opening the card on `key` means. The whole |
| 318 | /// of the cache policy, and the reason a second film does not cost the first |
| 319 | /// one its levels: what is cached is asked per source, never "the last one". |
| 320 | pub |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | /// The half-open source seconds a [`ScanKey`]'s frames name, at the project's |
| 329 | /// rate -- what [`engine::silence::levels`] is asked to read, and the same |
| 330 | /// arithmetic playback puts a clip's `in_frame` through. A rate that is not a |
| 331 | /// rate reads the whole file rather than an empty window: a scan of nothing is |
| 332 | /// worse than a scan of too much. |
| 333 | pub |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | /// The [`ScanKey`] a background scan lands its whole-file levels under: every |
| 341 | /// frame the source has, so one entry answers for every clip cut from it. A |
| 342 | /// sentinel `out_frame` rather than a fourth map, because [`ScanKey`] is |
| 343 | /// already what [`Player::silence_levels`] is keyed by -- a clip can never |
| 344 | /// itself claim `u32::MAX` as its own `out_frame`, so the two never collide. |
| 345 | pub |
| 346 | |
| 347 | |
| 348 | |
| 349 | /// The clip's own stretch of a whole-source scan, in the same dBFS windows |
| 350 | /// [`engine::silence::levels`] would have decoded for it directly: window `k` |
| 351 | /// of both is the same [`engine::silence::WINDOWS_PER_SEC`]th of a second from |
| 352 | /// the start of the file, so slicing costs no decode and reads the same |
| 353 | /// numbers the on-demand scan would have. Empty past the end of what the |
| 354 | /// background read has landed so far -- a scan still running answers with |
| 355 | /// what it has, same as [`SilenceScan`]'s own cancel does. |
| 356 | pub |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | /// Whether the card may draw `key`'s marks as arithmetic rather than start a |
| 375 | /// worker for it: its own exact read, or -- new since the scan moved to |
| 376 | /// import -- the whole-source background scan its file is cut from |
| 377 | /// ([`Player::cache_media`]). One function so `Player::open_silence`'s plan |
| 378 | /// and `Player::scan_silences`' lookup share the one contract for what |
| 379 | /// "cached" means, instead of two copies that could drift. |
| 380 | pub |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | /// What the silence card says while its worker reads. Unlike an import this |
| 388 | /// one *has* a fraction -- a decode knows how far into the sound it has come -- |
| 389 | /// so the line is where it is up to, out of what the header claims the track is |
| 390 | /// (`total` of 0 for a header that does not say, drawn as nothing rather than |
| 391 | /// as a guess). Both in seconds. |
| 392 | /// |
| 393 | /// The stall clock is [`IMPORT_STALL`]'s, for its reason: past five seconds |
| 394 | /// without the mark moving, a line that cannot move and a line that has stopped |
| 395 | /// look identical, and only one of them is worth words. |
| 396 | pub |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | /// How often a progress mark is worth keeping, how far back the rate is |
| 412 | /// measured, and the least span that may answer at all. An export crosses |
| 413 | /// hardware and software segments that run at different speeds, so the |
| 414 | /// estimate is a window's average and never the instant's. |
| 415 | pub const ETA_SAMPLE: f32 = 0.5; |
| 416 | pub const ETA_WINDOW: f32 = 8.; |
| 417 | pub const ETA_SPAN: f32 = 1.5; |
| 418 | |
| 419 | /// Records where the export has got to and forgets what has fallen out of the |
| 420 | /// window. One mark per `ETA_SAMPLE`, a window's worth kept: a bounded list |
| 421 | /// whichever way the encode goes. |
| 422 | pub |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | /// Seconds left at the window's rate, or `None` while nothing measurable has |
| 432 | /// happened yet -- which the line says as "estimating…" rather than as a |
| 433 | /// number it would have to take back. |
| 434 | pub |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 |