Module thumbs

Source
Expand description

Thumbnail cache for timeline filmstrips and library previews. Non-blocking: get/texture return immediately; misses are queued to ONE worker thread (newest request first, so scrubbing/zooming stays responsive) that owns a DecoderPool (backend from settings) and decodes h-pixel-tall RGBA thumbnails (aspect kept; images ignore t; Sequence clips are not handled here — the timeline draws a label). Results are kept in an LRU bounded by both entry count (≤512) and decoded bytes (≤48 MB) and uploaded lazily as egui textures (texture) so panels can paint them directly. ctx.request_repaint() when a thumbnail lands. Key = (path, t rounded to 0.5 s buckets, h rounded up to 16 px); clear() forgets everything (e.g. after save-over-original).

Structs§

Entry 🔒
Shared 🔒
ThumbCache

Enums§

Job 🔒

Constants§

BUDGET 🔒
Max decoded bytes kept — a 1080p source 300 px tall is 640 KB per entry, so CAP alone is not a bound.
CAP 🔒
Max decoded thumbnails kept (failed lookups are memoised separately and never evicted).

Functions§

bucket_time 🔒
The half-second bucket time actually decoded for a request at t (0 for images).
decode_thumb 🔒
Decode path at t scaled to h px tall, aspect kept. None on any failure.
evict 🔒
Drop least-recently-used decoded thumbnails beyond CAP entries or BUDGET bytes (failed memos are exempt: they cost nothing). ponytail: O(n) min-scan per insert over ≤512 entries on the worker thread — a real LRU list if CAP grows.
key_of 🔒
ponytail: 64-bit hash as the map key so per-frame lookups allocate nothing — collisions are astronomically unlikely.
qh 🔒
ponytail: 16 px steps so a track-height drag reuses cached thumbs instead of queueing a decode per pixel of height; rounding up means the texture is never upscaled on draw.
worker 🔒