Commit Graph

275 Commits

Author SHA1 Message Date
Jonathan Thomas
0570ad084b Large timeline clean-up, speed-up, and fix concurrency bugs:
- make Add/Remove Effect methods thread safe
- Fix RemoveClip memory leak
- Improve performance of sorting clips by position and layer, cache some common accessors, and speed up "clip intersection" logic
- Don't resize audio container in loop - do it once
- Large refactor of looping through clips and finding top clip
- Protect ClearAllCache from empty Readers, prevent crash
- Expanded unit tests to include RemoveEffect, and test many of the changes in the commit.
2025-09-11 23:27:41 -05:00
Jonathan Thomas
f68d18419a Improve GetMinFrame / GetMaxFrame functions for a timeline, to be inclusive on min, and exclusive on max (trying to prevent rounding errors on last frame) 2025-09-08 15:59:29 -05:00
Jonathan Thomas
6cea273b77 Fix timeline cache when updating Clips with ApplyJsonDiff (old and new position) 2025-07-08 15:19:17 -05:00
Jonathan Thomas
805af0dffc Fix Timeline::ApplyJsonDiff to make changes to our data first, and then clear cache afterwards (potential race condition) 2025-06-07 16:03:55 -05:00
Jonathan Thomas
5977483142 Fixing GetMinFrame() function to correctly + 1, since our starting frames in OpenShot always begin with 1 (not 0) 2024-12-09 23:30:46 -06:00
Jonathan Thomas
bc6174fc9a Ensure SetJson() method recalculates project duration (min/max times) 2024-10-01 14:54:24 -05:00
Jonathan Thomas
959947a3f8 Adding GetMinTime/GetMinFrame functions to timeline, to find the "start" position of a timeline, if it's not 0.0. 2024-09-30 16:23:30 -05:00
Jonathan Thomas
118810f160 Do not add +1 to GetMaxFrame() calculation. This is incorrect math for calculating the max frame of a timeline, and not correct. For example, 1 second long timeline at 30 FPS, should have exactly 30 frames (not 31). 2024-09-24 12:40:37 -05:00
Jonathan Thomas
4af80925b2 Ignore NULL nodes in JSON arrays (clips, effects). This can happen sometimes (for an unknown reason), and it currently crashes OpenShot when attempting to Export a video. 2023-10-07 15:19:36 -05:00
Jonathan Thomas
26c18fd76c Refactor of effect handling, to allow effects to be applied BEFORE or AFTER a clip's keyframes are applied. For example, this allows for a mask to apply after an animation/movement is applied to the clip image, like an animated scrolling credits to be masked/faded in a static location. 2023-05-24 17:12:15 -05:00
Jonathan Thomas
7100dc7a94 Adding lock around SetCache method, which causes some crashes. Detected in Sentry: OPENSHOT-1Q 2023-04-19 17:01:02 -05:00
Jonathan Thomas
89714b67b3 Small refactor to ensure that audio files have no image data - and allow videos below them to show through... 2023-04-16 01:50:11 -05:00
Jonathan Thomas
09ce05bbf2 Many improvements for smooth audio playback when 'time' keyframes are used for time remapping.
- Added new Frame::ReverseAudio() helper method - for time keyframe support playing backwards audio
- Fixed math rounding error on time keyframe Resampler, to use the rounded source samples value
- Removed some unused args and Frame audio methods
- Reset FrameMapper resample context when non-adjacent frames are requested
- Correctly reverse Frame audio if a time keyframe is present, and reversing audio
- Rewrite Keyframe::IsIncreasing() function, to give accurate direction of time keyframes at any index (special logic to support first and last indexes)
- Fixed Keyframe unit tests - since logic has changed a bit
- Improved time mapping unit tests
- Replace many c-style casts with static_cast
- Added new sine.wav test file
2023-03-10 01:15:14 -06:00
Jonathan Thomas
59d46e59be Large refactor of Clip::GetFrame and time-remapping of audio samples.
- Refactor AudioLocation into own header
- AudioResampler now supports variable channels
- Adding cache back to Clips - to prevent the cost of multiple calls for the same GetFrame() frame, used in time-remapping
- Large refactor of Clip::GetFrame, to prevent multiple code paths, and much improved time-remapping
- Clip's time keyframe now supports Bezier and sub-frame precision - to you can curve audio speed using any curve shape
- Fixing # of audio samples on Clip frame's, based on timeline position (to predictably divide samples per frame)
- New Clip unit tests for time remapping and resampling audio, and reversing audio
- New Frame::GetAudioSamples arg, to allow for reversing the direction of audio samples
- Fix bug in Frame::AddAudioSilence() to correctly cache the # of audio samples
- FrameMapper clean up resample context (when changing frame rate)
- FrameMapper refactor to optimize # of calls to Reader()::GetFrame(), since calls to Clip::GetFrame are quite expensive
- Removing RepeatingFraction functionality from Keyframe object (since it was a bad implementation detail from our previous time remapping)
- Making Keyframe GetDelta method a float, and no longer an int - to allow for more precision on time remapping
- Large amount of white space fixing (to make things consistent)
2023-02-27 22:11:13 -06:00
Jonathan Thomas
7a733c0a7b Fixing whitespace 2022-10-28 19:03:17 -05:00
Jonathan Thomas
9f3fa0af52 Fixing whitespace 2022-10-28 19:01:27 -05:00
Jonathan Thomas
1547fb1d52 New unit tests around GetMaxFrame / GetMaxTime. Improvemetns to apply_json_to_timeline() to not clear all cache when setting the timeline's "duration" - an optimization for performance 2022-10-28 15:25:30 -05:00
Jonathan Thomas
c12e3fe96e - 2 new unit tests, to verify Reader() ownership and clean-up is correct
- Bug fix for clip, to delete a new Reader, regardless of how it was set (correctly track allocated readers, and ignore FrameMappers pointed to existing allocated reader)
- Bug fix for timeline to correctly wrap Reader with FrameMapper
2022-10-28 11:00:47 -05:00
Jonathan Thomas
52de46078a Adding mutex to Timeline::Close 2022-10-26 23:15:50 -05:00
Jonathan Thomas
389bf33adb - Protect AddClip(), RemoveClip(), update_open_clips(), sort_clips(), sort_effects() methods with mutex, making them thread safe
- Refactor sorting of clips & effects, and only sort these arrays when the arrays change (instead of each call to GetFrame)
- Cache max timeline duration, and make Timeline::GetMaxTime() thread safe
- New multi-threaded unit tests, which are designed to verify no seg faults on multi-threaded calls to Timeline::GetFrame(), Timeline::AddClip(), and Timeline::RemoveClip()
- New public Timeline::SortTimeline() method which is called by child Clips automatically, when certain properties are changed
2022-10-22 22:55:40 -05:00
Jonathan Thomas
788a3c77a6 Fixing whitespace 2022-10-21 18:15:41 -05:00
Jonathan Thomas
d8f8cba27f Do not sort_clips on every call to GetFrame, as this invalidates the internal clips list, and causes crashes in ClearAllCache() and Clear() methods. 2022-10-21 18:11:32 -05:00
Jonathan Thomas
ca33d951e6 Removing cache clearing from Timeline::Clear method - unneeded 2022-10-15 21:48:55 -05:00
Jonathan Thomas
4ad94c7727 Fixing more whitespace 2022-10-13 10:25:04 -05:00
Jonathan Thomas
9284113867 Fixing more whitespace 2022-10-13 10:21:40 -05:00