13 #ifndef OPENSHOT_FRAMEMAPPER_H 14 #define OPENSHOT_FRAMEMAPPER_H 60 Field() : Frame(0), isOdd(true) { };
62 Field(int64_t frame,
bool isodd)
85 int remaining_samples = samples;
86 while (remaining_samples > 0) {
90 if (remaining_samples + sample_end < samples_per_frame) {
91 sample_end += remaining_samples;
92 remaining_samples = 0;
95 remaining_samples -= (samples_per_frame - sample_end);
100 if (sample_start - remaining_samples >= 0) {
101 sample_start -= remaining_samples;
102 remaining_samples = 0;
105 remaining_samples -= (sample_start + 1);
117 int remaining_samples = samples;
118 while (remaining_samples > 0) {
121 if (sample_end - remaining_samples >= 0) {
122 sample_end -= remaining_samples;
123 remaining_samples = 0;
127 remaining_samples -= (sample_end + 1);
128 sample_end = samples_per_frame - 1;
133 if (sample_start + remaining_samples < samples_per_frame) {
134 sample_start += remaining_samples;
135 remaining_samples = 0;
138 remaining_samples -= (samples_per_frame - sample_start);
154 Extend(samples, fps, sample_rate, channels,
true);
155 Shrink(samples, fps, sample_rate, channels,
false);
158 Extend(samples, fps, sample_rate, channels,
false);
159 Shrink(samples, fps, sample_rate, channels,
true);
210 float parent_position;
212 int64_t previous_frame;
219 void AddField(int64_t frame);
220 void AddField(
Field field);
226 std::shared_ptr<Frame> GetOrCreateFrame(int64_t number);
229 int64_t AdjustFrameNumber(int64_t clip_frame_number);
252 void Close()
override;
255 MappedFrame GetMappedFrame(int64_t TargetFrameNumber);
266 std::shared_ptr<Frame> GetFrame(int64_t requested_frame)
override;
269 bool IsOpen()
override;
272 std::string
Name()
override {
return "FrameMapper"; };
275 std::string Json()
const override;
276 void SetJson(
const std::string value)
override;
277 Json::Value JsonValue()
const override;
278 void SetJsonValue(
const Json::Value root)
override;
281 void Open()
override;
284 void PrintMapping(std::ostream* out=&std::cout);
293 void ResampleMappedAudio(std::shared_ptr<Frame> frame, int64_t original_frame_number);
Classic 2:3:2:3 pull-down.
Header file for Fraction class.
Header file for ReaderBase class.
Header file for OpenMPUtilities (set some common macros)
void Shrink(int64_t samples, openshot::Fraction fps, int sample_rate, int channels, bool right_side)
Shrink SampleRange on either side.
std::vector< MappedFrame > frames
std::vector< Field > fields
This abstract class is the base class, used by all readers in libopenshot.
Header file for the Keyframe class.
This struct holds a single field (half a frame).
Header file for CacheMemory class.
This struct holds a the range of samples needed by this frame.
int GetSamplesPerFrame(openshot::Fraction fps, int sample_rate, int channels)
Calculate the # of samples per video frame (for the current frame number)
Header file for Frame class.
Header file for AudioResampler class.
Field(int64_t frame, bool isodd)
This class represents a fraction.
void Extend(int64_t samples, openshot::Fraction fps, int sample_rate, int channels, bool right_side)
Extend SampleRange on either side.
ChannelLayout
This enumeration determines the audio channel layout (such as stereo, mono, 5 point surround...
void Reader(ReaderBase *new_reader)
Set the current reader.
CacheMemory * GetCache() override
Get the cache object used by this reader.
This struct holds two fields which together make up a complete video frame.
std::string Name() override
Return the type name of the class.
void Shift(int64_t samples, openshot::Fraction fps, int sample_rate, int channels, bool right_side)
This class creates a mapping between 2 different frame rates, applying a specific pull-down technique...
This namespace is the default namespace for all code in the openshot library.
Do not apply pull-down techniques, just repeat or skip entire frames.
PulldownType
This enumeration determines how frame rates are increased or decreased.
Header file for FFmpegUtilities.
This class is a memory-based cache manager for Frame objects.
Advanced 2:3:3:2 pull-down (minimal dirty frames)
This class is used to resample audio data for many sequential frames.