Commit Graph

55 Commits

Author SHA1 Message Date
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
Jonathan Thomas
64815d6bae Removing adaptive caching support, and make things generally less aggressive. Do not cache when paused (to allow for transform tool and timeline scrubbing to only render the current frame needed, for speed). This results in very smooth transform tool editing, very smooth timeline scrubbing, and I'm still seeing very smooth video playback when not paused. Needs more testing though. 2022-02-24 15:56:39 -06:00
Jonathan Thomas
d24e39407e Prevent crashes:
- Tweaking GetSmallestFrame to not use an additional mutex.
- Replace 2 mutex on Timeline::GetFrame with 1 mutex.
- Remove mutex from Timeline::ClearAllCache.
- Slow down loop on video cache thread.
- Protect audioThread::Seek() if missing a source.
- Rearrange StopPlayback to always stop the videoCache thread first.
2022-02-12 13:31:21 -06:00
Jonathan Thomas
35d4629df6 Large refactor to caching and playback timing:
- Support different speeds (-1X, 2X, 4X, etc...)
 - Clamp getFrame between 1 and timeline length
 - Support rewind using new timing code
 - Caching in both directions (based on previous speed)
 - Removing mutex from Timeline::GetFrame (cached path)
 - Caching supports actual speed now
 - Bust cache and trigger pre-roll if we encounter too many uncached frames. This will re-sync the video + audio threads.
 - Sleep less in cache loop / Adjusting min frames to 24 (trial and error). Too few and backwards playback suffers. Too many and all playback waits.
2022-02-09 17:29:04 -06:00
Jonathan Thomas
5fe398bda5 Reducing pre-roll to 12 frames 2022-02-01 15:46:35 -06:00
Jonathan Thomas
f70ca4b877 Break out of cache loop if playback speed changes during caching. Move getFrame() below pause code, to prevent accidental incrementing video_position. 2022-02-01 15:33:32 -06:00
Jonathan Thomas
176f2fff9c Big refactor of AudioReaderSource, to be simpler, and only fill the audio samples requested (removed double/internal buffer complexity). Also, we now initialize the audio device manager at a specific sampleRate and # of channels correctly. Removed 'latency' adjustment in PrivatePlayer (no longer needed with no read-ahead buffer). Increased the min_frames_required on the video cache to 24. 2022-01-31 15:18:07 -06:00
Jonathan Thomas
133bae40c3 Adding pre-roll to VideoCacheThread, and making video & audio threads wait for the isReady() method before playing. Also fixed an audio bug where our internal buffer was not being cleared on seek. Removed some unused caching from Clip, and did some minor refactor on FrameMapper/Clip cache clearing. 2022-01-26 17:56:33 -06:00