Commit Graph

62 Commits

Author SHA1 Message Date
Jonathan Thomas
90d0710d78 Fixing some regressions in performance of Mask effect, and flickering cached frames during updates (i.e. property slider updates) 2026-03-01 16:56:42 -06:00
Jonathan Thomas
4387f8b394 - Timeline composition no longer mutates cached clip frames (fixes trails/ghosting).
- Clip updates via ApplyJsonDiff now also clear clip cache (not just timeline/reader ranges).
- Added regressions for cache invalidation + no cached-frame mutation; kept paused preroll/cache-bar behavior intact.
2026-03-01 14:19:27 -06:00
Jonathan Thomas
ff22d416da - Playback updates no longer act like seeks.
- Scrubbing inside cached area keeps cache.
- Scrubbing outside cached area clears cache immediately.
- Preroll now starts on seek commit (release), not during drag.
- Temporary debug logs were removed.
- Tests were added for these behaviors.
2026-02-26 13:22:06 -06:00
Jonathan Thomas
429826be36 Fixing a few nitpicks in caching function to use local variables when available (instead of the atomic ones) 2026-02-13 11:48:33 -06:00
Jonathan Thomas
c43092eaa5 Merge branch 'develop' into caching-protections
# Conflicts:
#	src/Qt/VideoCacheThread.cpp
2026-02-13 11:29:32 -06:00
Jonathan Thomas
fb41a3c479 • - Fix VideoCacheThread::isReady() so preroll readiness is clamped by frames actually available to the timeline boundary (end/start), preventing playback from stalling in PLAY near the end.
- Add regression coverage in tests/VideoCacheThread.cpp (isReady: clamps preroll requirement at timeline boundaries) for forward-near-end and backward-near-start cases.
2026-02-12 23:41:51 -06:00
Jonathan Thomas
d70e80eac4 Harden playback/cache path for malformed media and concurrent timeline updates
- Invalidate timeline cache on ApplyJsonDiff() clip insert (remove affected frame range).
  - Add lock in Timeline::ClearAllCache() for safe concurrent access.
  - Make VideoCacheThread cross-thread state safe (atomics + seek-state mutex).
  - Lock CacheMemory::Contains() to avoid races.
  - Handle malformed audio streams in FFmpegReader by disabling invalid audio and continuing video-only.
  - Add FPS/timebase safety fallbacks in FFmpeg frame/PTS math.
  - Guard Frame::GetSamplesPerFrame() against invalid inputs.
  - Add/adjust regression tests for cache invalidation and invalid rate handling.
2026-02-11 20:11:47 -06:00
Jonathan Thomas
43f9ed89ae VideoCacheThread: add directional preroll
- start cache rebuilds with a preroll offset (settings-based)
- tighten isReady to require frames ahead/behind playhead add unit tests for preroll clamping and readiness
2026-02-05 12:39:06 -06:00
Jonathan Thomas
01a4d9f6ef Fixing regression/bug in video cache thread - to correctly reset cached_frame_count, and make isReady() return correctly. The result of this bug was audio starting playback sooner than video - and some general jank around video caching. 2025-09-15 18:20:05 -05:00
Jonathan Thomas
0d492ec77f Removing Play/Stop implementation from VideoCacheThread. Adding back in a ClearAllCache in Seek(), to handle updates via the UI correctly. 2025-06-07 16:05:19 -05:00
Jonathan Thomas
a6ca7d9a2f Adding back Setting::VIDEO_CACHE_MAX_FRAMES, to limit the video cache thread to a hard #. Also, minor refactor to reduce duplication of capacity. 2025-06-06 15:25:46 -05:00
Jonathan Thomas
6c39b0f8e5 Another large refactor of our primary cache thread, to split out many functions which we can test in our unit tests. 2025-06-03 19:36:05 -05:00
Jonathan Thomas
fd91892fea More tweaks to keep the cache window centered on the playhead, so different speeds (- and +) still result in moving cache window. 2025-06-03 17:49:56 -05:00
Jonathan Thomas
ec81c1d1cd Simplification and another small refactor of Run code (to make it more maintainable) 2025-06-03 16:46:04 -05:00
Jonathan Thomas
6d5e55175b Huge refactor of VideoCacheThread, to provide better caching, fixing many edge cases that cause our cache to become unsynced with playback. This is still a work-in-progress though.. 2025-06-03 16:23:17 -05:00
Jonathan Thomas
6a234fe4ce Always cache starting 1 frame previous to the playhead - to prevent the Seek method from clearing all cache 2022-10-24 13:08:37 -05:00
Jonathan Thomas
28e6e0ba21 Break out of cache loop when caching is temporarily disabled (i.e. when transforming, editing keyframes, rotating, moving, resizing, etc...) 2022-10-15 00:08:49 -05:00
Jonathan Thomas
87052b5a35 Fixing whitespace issues 2022-10-13 10:02:56 -05:00
Jonathan Thomas
8ac1589b2d Optimizing caching thread to exclude frames where no clips exist, and simplify some of the caching loop logic 2022-10-04 18:35:16 -05:00
Jonathan Thomas
969a2015bf Increasing max video cache frames, moving percentage-ahead caching to a setting, fixing a calculation error on bytes per frame 2022-09-20 16:55:07 -05:00
Jonathan Thomas
95100f2ac4 Fixing white space issue 2022-09-16 10:32:38 -05:00
Jonathan Thomas
6ecc8b8998 Fixing white space issue 2022-09-16 10:21:54 -05:00
Jonathan Thomas
8c7b463e38 Improvements to the ClearAllCache() function, allowing both shallow and deep clearing. Lots of bug fixes in VideoCacheThread, to correctly pre-roll and cache the correct frames, and a new method of disabling/enabling the cache thread. 2022-09-15 18:33:06 -05:00
Jonathan Thomas
8864bea8e9 Renaming variable for clarity 2022-03-01 13:00:53 -06:00
Jonathan Thomas
c71a1af6ea Allow cache on initial pause, to use the Timeline cache size to initially cache a bunch more frames... and then fully pause. This allows for a balance between not-caching during pause (for Transform and Scrubbing performance), but still caching frames on pause so the user can wait for a smoother playback experience. 2022-02-28 15:45:46 -06:00