You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
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.
This commit is contained in:
@@ -455,9 +455,9 @@ void Frame::SetFrameNumber(int64_t new_number)
|
||||
// Calculate the # of samples per video frame (for a specific frame number and frame rate)
|
||||
int Frame::GetSamplesPerFrame(int64_t number, Fraction fps, int sample_rate, int channels)
|
||||
{
|
||||
// Directly return 0 if there are no channels
|
||||
// Directly return 0 for invalid audio/frame-rate parameters
|
||||
// so that we do not need to deal with NaNs later
|
||||
if (channels == 0) return 0;
|
||||
if (channels <= 0 || sample_rate <= 0 || fps.num <= 0 || fps.den <= 0) return 0;
|
||||
|
||||
// Get the total # of samples for the previous frame, and the current frame (rounded)
|
||||
double fps_rate = fps.Reciprocal().ToDouble();
|
||||
|
||||
Reference in New Issue
Block a user