13#ifndef OPENSHOT_FRAMEMAPPER_H
14#define OPENSHOT_FRAMEMAPPER_H
77 int remaining_samples = samples;
78 while (remaining_samples > 0) {
82 if (remaining_samples +
sample_end < samples_per_frame) {
84 remaining_samples = 0;
87 remaining_samples -= (samples_per_frame -
sample_end);
94 remaining_samples = 0;
109 int remaining_samples = samples;
110 while (remaining_samples > 0) {
115 remaining_samples = 0;
125 if (
sample_start + remaining_samples < samples_per_frame) {
127 remaining_samples = 0;
130 remaining_samples -= (samples_per_frame -
sample_start);
146 Extend(samples, fps, sample_rate, channels,
true);
147 Shrink(samples, fps, sample_rate, channels,
false);
150 Extend(samples, fps, sample_rate, channels,
false);
151 Shrink(samples, fps, sample_rate, channels,
true);
202 float parent_position;
204 int64_t previous_frame;
211 void AddField(int64_t frame);
212 void AddField(int64_t frame,
bool isOdd);
213 void AddField(
Field field);
219 std::shared_ptr<Frame> GetOrCreateFrame(int64_t number);
222 int64_t AdjustFrameNumber(int64_t clip_frame_number);
245 void Close()
override;
259 std::shared_ptr<Frame>
GetFrame(int64_t requested_frame)
override;
265 std::string
Name()
override {
return "FrameMapper"; };
268 std::string
Json()
const override;
269 void SetJson(
const std::string value)
override;
274 void Open()
override;
Header file for AudioResampler class.
Header file for CacheMemory class.
Header file for FFmpegUtilities.
Header file for Fraction class.
Header file for Frame class.
Header file for the Keyframe class.
Header file for OpenMPUtilities (set some common macros)
Header file for ReaderBase class.
This class is used to resample audio data for many sequential frames.
This class is a memory-based cache manager for Frame objects.
This class represents a fraction.
This class creates a mapping between 2 different frame rates, applying a specific pull-down technique...
std::shared_ptr< Frame > GetFrame(int64_t requested_frame) override
This method is required for all derived classes of ReaderBase, and return the openshot::Frame object,...
void ChangeMapping(Fraction target_fps, PulldownType pulldown, int target_sample_rate, int target_channels, ChannelLayout target_channel_layout)
Change frame rate or audio mapping details.
void Reader(ReaderBase *new_reader)
Set the current reader.
MappedFrame GetMappedFrame(int64_t TargetFrameNumber)
Get a frame based on the target frame rate and the new frame number of a frame.
std::string Name() override
Return the type name of the class.
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
bool IsOpen() override
Determine if reader is open or closed.
std::vector< Field > fields
ReaderBase * Reader()
Get the current reader.
std::vector< MappedFrame > frames
void ResampleMappedAudio(std::shared_ptr< Frame > frame, int64_t original_frame_number)
Resample audio and map channels (if needed)
void Open() override
Open the internal reader.
CacheMemory * GetCache() override
Get the cache object used by this reader.
void Close() override
Close the openshot::FrameMapper and internal reader.
std::string Json() const override
Generate JSON string of this object.
void PrintMapping(std::ostream *out=&std::cout)
Print all of the original frames and which new frames they map to.
void SetJson(const std::string value) override
Load JSON string into this object.
Json::Value JsonValue() const override
Generate Json::Value for this object.
virtual ~FrameMapper()
Destructor.
int GetSamplesPerFrame(openshot::Fraction fps, int sample_rate, int channels)
Calculate the # of samples per video frame (for the current frame number)
This abstract class is the base class, used by all readers in libopenshot.
This namespace is the default namespace for all code in the openshot library.
PulldownType
This enumeration determines how frame rates are increased or decreased.
@ PULLDOWN_CLASSIC
Classic 2:3:2:3 pull-down.
@ PULLDOWN_ADVANCED
Advanced 2:3:3:2 pull-down (minimal dirty frames)
@ PULLDOWN_NONE
Do not apply pull-down techniques, just repeat or skip entire frames.
ChannelLayout
This enumeration determines the audio channel layout (such as stereo, mono, 5 point surround,...
This struct holds a single field (half a frame).
This struct holds two fields which together make up a complete video frame.
This struct holds a the range of samples needed by this frame.
void Shrink(int64_t samples, openshot::Fraction fps, int sample_rate, int channels, bool right_side)
Shrink SampleRange on either side.
void Extend(int64_t samples, openshot::Fraction fps, int sample_rate, int channels, bool right_side)
Extend SampleRange on either side.
void Shift(int64_t samples, openshot::Fraction fps, int sample_rate, int channels, bool right_side)