Skip to content

Conversation

@jonoomph
Copy link
Member

@jonoomph jonoomph commented Feb 28, 2023

Large refactor of Clip::GetFrame() and time-remapping of audio samples. This also addresses a common crash, often reported while speeding up or slowing down a clip using the time keyframe. This PR also includes quite a few optimizations and performance improvements, especially between FrameMapper::GetFrame() and Clip::GetFrame().

  • 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)
  • New Frame::ReverseAudio() function which safely reverses audio for a frame - only 1 time
  • Refactor how FrameMapper handles reversed videos (using time keyframes) - to correctly reverse samples before resampling, preventing many pops, clicks, and invalid audio waveforms
  • Refactor how FrameMapper extends and shifts SampleRange objects - when applying EXTRA_INPUT_SAMPLES to the resampler (to prevent becoming input limited)
  • New SampleRange unit tests for Extend(), Shrink(), and Shift() methods

- 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)
@jonoomph
Copy link
Member Author

…used lots of clicks / seams between frames... Also, added a new overload to GetInterleavedAudioSamples, to reverse the samples before returning the float* array. Essentially, the FrameMapper is now aware of it's parent clip, and especially the 'time' keyframe, if the audio is in the forward or reverse direction. Also fixed a memory leak in time remapping.
… 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
@codecov
Copy link

codecov bot commented Mar 10, 2023

Codecov Report

Merging #905 (8238328) into develop (8f92bac) will increase coverage by 1.34%.
The diff coverage is 88.51%.

@@             Coverage Diff             @@
##           develop     #905      +/-   ##
===========================================
+ Coverage    52.70%   54.04%   +1.34%     
===========================================
  Files          190      191       +1     
  Lines        16771    16842      +71     
===========================================
+ Hits          8839     9103     +264     
+ Misses        7932     7739     -193     
Impacted Files Coverage Δ
src/FFmpegReader.h 100.00% <ø> (ø)
src/Frame.h 100.00% <ø> (ø)
src/KeyFrame.h 100.00% <ø> (ø)
src/effects/ObjectDetection.cpp 0.00% <0.00%> (ø)
src/effects/Tracker.cpp 12.10% <0.00%> (ø)
src/EffectBase.cpp 29.41% <50.00%> (ø)
src/Frame.cpp 47.07% <50.00%> (+2.96%) ⬆️
src/Clip.cpp 69.82% <79.45%> (+10.89%) ⬆️
src/Timeline.cpp 55.97% <87.01%> (+0.19%) ⬆️
src/FrameMapper.cpp 90.80% <89.28%> (-1.77%) ⬇️
... and 11 more

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

…), and removing version logic around swresample/avresample logic - since GitHub versions are completely different than expected (for example: avformat version: 3.100 vs avformat version: 58.45.100)
…the EXTRA_INPUT_SAMPLES, to prevent the resampler from becoming input limited.

- Fixed some unit tests
- Added new convenience methods for SampleRange, to extend either side, or shift it left or right
- Added new SampleRange unit tests
- No more audio pops at the beginning of clips which are being resampled!!!
- Time remapping now works perfectly smoothly, no more pops or crashes!!!
@jonoomph
Copy link
Member Author

@jonoomph jonoomph changed the title Time Remapping Improvements Time Remapping & Audio Resampling Improvements Mar 11, 2023
…ce to the time-mapping resampler, to prevent some strange waveform issues at the beginning of a time-mapped clip
@jonoomph jonoomph merged commit ec0c0b1 into develop Mar 18, 2023
@jonoomph jonoomph deleted the improved-timemapping-feb-27-2023 branch March 18, 2023 22:01
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.

2 participants