edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiB978e685Tahinli3 months ago627 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, in the order the giants list them: the |
| 6 | /// pictures, the sound, and the words. A file is in exactly one of them, so a |
| 7 | /// tab is a question with an answer rather than a filter with a guess. |
| 8 | |
| 9 | pub |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | pub const LIBRARY_TABS: = ; |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | /// What is known about a source's audio. Three states and not two, because a |
| 50 | /// file whose peaks have not come back yet must not be drawn as one that has no |
| 51 | /// audio at all: the first shows a bed, the second shows nothing. |
| 52 | |
| 53 | pub |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | /// The bench's own version of [`Wave`] for the picture instead of the sound: one |
| 66 | /// representative decoded frame per file, kept and reused across every clip cut |
| 67 | /// from it (DESIGN.md §5's "real thumbnails across video clips", §12 step 5 -- |
| 68 | /// this is the frame, not the ink; the ink comes from [`crate::source_tint`] |
| 69 | /// until real extraction lands). Audio-only files never enter this map (see |
| 70 | /// `cache_media`'s filter), so `Silent` has no counterpart here. |
| 71 | |
| 72 | pub |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | /// What a source's stand-in is up to ([`engine::proxy`]). Kept per file and |
| 81 | /// filled like every other library fact -- presence means "asked", so a repaint |
| 82 | /// mid-encode cannot start a second one. |
| 83 | pub |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 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 | /// The import a worker is reading, as the line above the panel shows it. No |
| 133 | /// fraction anywhere: neither read reports how far into the file it has come, |
| 134 | /// so what is honest is the file's name, the stage, and two clocks -- one that |
| 135 | /// proves the window is answering, one that says the stage has not moved. |
| 136 | pub |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | /// What a scan is *of*: the source, which of its audio streams, and the clip's |
| 181 | /// own `[in, out)` source frames. The range is part of the name because it is |
| 182 | /// part of the read -- a clip cut in half is a different, shorter decode than |
| 183 | /// the whole take was, and levels read for one are not the other's. |
| 184 | pub type ScanKey = ; |
| 185 | |
| 186 | /// The silence scan a worker is running, as the card shows it. Same two clocks |
| 187 | /// as an [`Import`] and for the same reason -- one proves the window answers, |
| 188 | /// one says the read has stopped moving -- over a progress that *can* move: |
| 189 | /// a decode knows how far into the sound it has come, so the card says so. |
| 190 | pub |
| 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 | /// How long a stage may sit without moving before the import line stops |
| 221 | /// reading like a progress line and says outright that the wait is the file's, |
| 222 | /// not the window's. Five seconds: a 25 GB remux spends eleven in its header |
| 223 | /// alone, and a person watching a still line for that long has already decided |
| 224 | /// the editor hung. |
| 225 | pub const IMPORT_STALL: f32 = 5.; |
| 226 | |
| 227 | /// Which of an import's two reads the worker is inside. Travels as one atomic, |
| 228 | /// the way an export's progress does ([`engine::ExportHandle`]) -- there is no |
| 229 | /// fraction to send, because neither read reports where in the file it is. |
| 230 | |
| 231 | pub |
| 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 | /// argv sorted into the file that becomes the timeline and the queue every |
| 261 | /// named file is read through, in the order they were named. The whole of what |
| 262 | /// a launch does before the window is on screen -- and it touches no disk, |
| 263 | /// which is the point: the header walk happens on a worker with the window |
| 264 | /// already up ([`Player::take_import`]). |
| 265 | pub |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | /// What a queued file turns into. Every file goes through one queue -- argv's |
| 273 | /// first file, argv's extras, a drop, the Import button -- and this is the fork |
| 274 | /// its worker is started on. |
| 275 | |
| 276 | pub |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | /// Which of the three a queued file is (`landing` above is the drag's). |
| 287 | /// `opening` is the one path argv named and is cleared as it lands, so a second |
| 288 | /// arrival of the same *media* path -- a drop of the film that is already open |
| 289 | /// -- is an import, which is what a drop has always been. |
| 290 | /// |
| 291 | /// A `.edith` is never an import, whichever door it came through: it is a whole |
| 292 | /// timeline and there is nothing to add it to. Argv's, a dropped one and the |
| 293 | /// Import button's are one landing, so the seconds its open costs are the |
| 294 | /// worker's for all three ([`open_ahead`]) and the line above the panel names it |
| 295 | /// while it runs. |
| 296 | pub |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | /// The whole of what an import shows while it runs: which file, which stage, |
| 305 | /// the clock that proves the window is still answering, and what is behind it |
| 306 | /// in the queue. |
| 307 | /// |
| 308 | /// `since` is how long the *stage* has stood still, which is the only movement |
| 309 | /// an unmeasurable read has: past [`IMPORT_STALL`] the line says so in words, |
| 310 | /// because a bar that cannot move and a bar that has stopped look identical. |
| 311 | /// |
| 312 | /// `opening` is the file argv named, which is read through the same queue and |
| 313 | /// says so in the same words -- except that it is being *opened*, and a line |
| 314 | /// that called it an import would be describing the wrong thing to the one |
| 315 | /// person who typed the name. |
| 316 | pub |
| 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 | /// What opening the silence card on a source costs. |
| 344 | |
| 345 | pub |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | /// Which of the three [`ScanPlan`]s opening the card on `key` means. The whole |
| 357 | /// of the cache policy, and the reason a second film does not cost the first |
| 358 | /// one its levels: what is cached is asked per source, never "the last one". |
| 359 | pub |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | /// The half-open source seconds a [`ScanKey`]'s frames name, at the project's |
| 368 | /// rate -- what [`engine::silence::levels`] is asked to read, and the same |
| 369 | /// arithmetic playback puts a clip's `in_frame` through. A rate that is not a |
| 370 | /// rate reads the whole file rather than an empty window: a scan of nothing is |
| 371 | /// worse than a scan of too much. |
| 372 | pub |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | /// The [`ScanKey`] a background scan lands its whole-file levels under: every |
| 380 | /// frame the source has, so one entry answers for every clip cut from it. A |
| 381 | /// sentinel `out_frame` rather than a fourth map, because [`ScanKey`] is |
| 382 | /// already what [`Player::silence_levels`] is keyed by -- a clip can never |
| 383 | /// itself claim `u32::MAX` as its own `out_frame`, so the two never collide. |
| 384 | pub |
| 385 | |
| 386 | |
| 387 | |
| 388 | /// The clip's own stretch of a whole-source scan, in the same dBFS windows |
| 389 | /// [`engine::silence::levels`] would have decoded for it directly: window `k` |
| 390 | /// of both is the same [`engine::silence::WINDOWS_PER_SEC`]th of a second from |
| 391 | /// the start of the file, so slicing costs no decode and reads the same |
| 392 | /// numbers the on-demand scan would have. Empty past the end of what the |
| 393 | /// background read has landed so far -- a scan still running answers with |
| 394 | /// what it has, same as [`SilenceScan`]'s own cancel does. |
| 395 | pub |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | /// Whether the card may draw `key`'s marks as arithmetic rather than start a |
| 409 | /// worker for it: its own exact read, or -- new since the scan moved to |
| 410 | /// import -- the whole-source background scan its file is cut from |
| 411 | /// ([`Player::cache_media`]). One function so `Player::open_silence`'s plan |
| 412 | /// and `Player::scan_silences`' lookup share the one contract for what |
| 413 | /// "cached" means, instead of two copies that could drift. |
| 414 | pub |
| 415 | |
| 416 | |
| 417 | |
| 418 | /// What the silence card says while its worker reads. Unlike an import this |
| 419 | /// one *has* a fraction -- a decode knows how far into the sound it has come -- |
| 420 | /// so the line is where it is up to, out of what the header claims the track is |
| 421 | /// (`total` of 0 for a header that does not say, drawn as nothing rather than |
| 422 | /// as a guess). Both in seconds. |
| 423 | /// |
| 424 | /// The stall clock is [`IMPORT_STALL`]'s, for its reason: past five seconds |
| 425 | /// without the mark moving, a line that cannot move and a line that has stopped |
| 426 | /// look identical, and only one of them is worth words. |
| 427 | pub |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | /// How often a progress mark is worth keeping, how far back the rate is |
| 443 | /// measured, and the least span that may answer at all. An export crosses |
| 444 | /// hardware and software segments that run at different speeds, so the |
| 445 | /// estimate is a window's average and never the instant's. |
| 446 | pub const ETA_SAMPLE: f32 = 0.5; |
| 447 | pub const ETA_WINDOW: f32 = 8.; |
| 448 | pub const ETA_SPAN: f32 = 1.5; |
| 449 | |
| 450 | /// Records where the export has got to and forgets what has fallen out of the |
| 451 | /// window. One mark per `ETA_SAMPLE`, a window's worth kept: a bounded list |
| 452 | /// whichever way the encode goes. |
| 453 | pub |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | /// Seconds left at the window's rate, or `None` while nothing measurable has |
| 463 | /// happened yet -- which the line says as "estimating…" rather than as a |
| 464 | /// number it would have to take back. |
| 465 | pub |
| 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 |