MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / is_near

Method is_near

src/FFmpegReader.cpp:144–159  ·  view source on GitHub ↗

This struct holds the associated video frame and starting sample # for an audio packet.

Source from the content-addressed store, hash-verified

142
143// This struct holds the associated video frame and starting sample # for an audio packet.
144bool AudioLocation::is_near(AudioLocation location, int samples_per_frame, int64_t amount) {
145 // Is frame even close to this one?
146 if (abs(location.frame - frame) >= 2)
147 // This is too far away to be considered
148 return false;
149
150 // Note that samples_per_frame can vary slightly frame to frame when the
151 // audio sampling rate is not an integer multiple of the video fps.
152 int64_t diff = samples_per_frame * (location.frame - frame) + location.sample_start - sample_start;
153 if (abs(diff) <= amount)
154 // close
155 return true;
156
157 // not close
158 return false;
159}
160
161#if USE_HW_ACCEL
162

Callers 1

GetAudioPTSLocationMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected