Skip to content

feat(ui): cache recently decoded frames - #75

Merged
blocksmith314 merged 1 commit into
mainfrom
feature/frame-cache
Nov 21, 2026
Merged

blocksmith314 merged 1 commit into
mainfrom
feature/frame-cache

Conversation

@blocksmith314

Copy link
Copy Markdown
Owner

Summary

Fixes #69: recently decoded frames are cached and re-displayed instantly.

  • New FrameCache (LRU, 256 MB default, byte-based eviction) storing full-resolution QImage frames.
  • ShowFrame() inserts the displayed frame; ShowFrameAt() checks the cache first when not playing, displaying a hit without seeking or decoding.
  • Resync: a cache hit leaves the decoder behind, so the next non-cached decode forces SeekToFrame(target) to realign. This prevents the "right frame number, wrong image" failure mode.
  • Playing bypasses the cache lookup but keeps filling it; opening a file clears it.
  • Performance log records cache hits (cache file frame=N).

Verification

  • FrameCacheTest.EvictsLeastRecentlyUsed
  • MainWindowTest.CacheServesRevisitedFrames (load -> step right -> step left, log contains cache)
  • ctest: 75/75 pass
  • tidy.sh on the changed files: 0 issues

Limitations

  • Memory only; no persistence.
  • 256 MB is a compile-time default (about 30 frames at 1080p, ~7 at 4K); could become a setting later.
  • Backward steps that miss the cache still pay a seek + GOP decode.

Fixes #69

Add a bounded LRU FrameCache (256 MB default) keyed by frame index. ShowFrame
stores the full-resolution image; ShowFrameAt checks the cache first when not
playing and displays the cached frame without touching the decoder.

Because a cache hit leaves the decoder at an older position, a resync flag
forces SeekToFrame() before the next decode so the displayed frame and the
decoder cannot diverge. Opening a file clears the cache, and the performance
log records cache hits.

Adds FrameCache eviction/LRU tests and a GUI test that revisits a cached frame.
@blocksmith314
blocksmith314 merged commit 520cb60 into main Nov 21, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache recently decoded frames for instant re-display

1 participant