OpenShot Library | libopenshot  0.2.5
Public Member Functions | Public Attributes | List of all members
openshot::FrameMapper Class Reference

This class creates a mapping between 2 different frame rates, applying a specific pull-down technique. More...

#include <FrameMapper.h>

Inheritance diagram for openshot::FrameMapper:
openshot::ReaderBase

Public Member Functions

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. More...
 
void Close ()
 Close the openshot::FrameMapper and internal reader. More...
 
 FrameMapper (ReaderBase *reader, Fraction target_fps, PulldownType target_pulldown, int target_sample_rate, int target_channels, ChannelLayout target_channel_layout)
 Default constructor for openshot::FrameMapper class. More...
 
CacheMemoryGetCache ()
 Get the cache object used by this reader. More...
 
std::shared_ptr< FrameGetFrame (int64_t requested_frame)
 This method is required for all derived classes of ReaderBase, and return the openshot::Frame object, which contains the image and audio information for that frame of video. More...
 
MappedFrame GetMappedFrame (int64_t TargetFrameNumber)
 Get a frame based on the target frame rate and the new frame number of a frame. More...
 
bool IsOpen ()
 Determine if reader is open or closed. More...
 
std::string Json () const override
 Get and Set JSON methods. More...
 
Json::Value JsonValue () const override
 Generate Json::Value for this object. More...
 
std::string Name ()
 Return the type name of the class. More...
 
void Open ()
 Open the internal reader. More...
 
void PrintMapping ()
 Print all of the original frames and which new frames they map to. More...
 
ReaderBaseReader ()
 Get the current reader. More...
 
void Reader (ReaderBase *new_reader)
 Set the current reader. More...
 
void ResampleMappedAudio (std::shared_ptr< Frame > frame, int64_t original_frame_number)
 Resample audio and map channels (if needed) More...
 
void SetJson (const std::string value)
 Load JSON string into this object. More...
 
void SetJsonValue (const Json::Value root)
 Load Json::Value into this object. More...
 
virtual ~FrameMapper ()
 Destructor. More...
 
- Public Member Functions inherited from openshot::ReaderBase
void DisplayInfo ()
 Display file information in the standard output stream (stdout) More...
 
openshot::ClipBaseGetClip ()
 Parent clip object of this reader (which can be unparented and NULL) More...
 
 ReaderBase ()
 Constructor for the base reader, where many things are initialized. More...
 
void SetClip (openshot::ClipBase *clip)
 Set parent clip object of this reader. More...
 
virtual ~ReaderBase ()=default
 

Public Attributes

std::vector< Fieldfields
 
std::vector< MappedFrameframes
 
- Public Attributes inherited from openshot::ReaderBase
openshot::ReaderInfo info
 Information about the current media file. More...
 

Additional Inherited Members

- Protected Attributes inherited from openshot::ReaderBase
juce::CriticalSection getFrameCriticalSection
 Section lock for multiple threads. More...
 
openshot::ClipBaseparent
 
juce::CriticalSection processingCriticalSection
 

Detailed Description

This class creates a mapping between 2 different frame rates, applying a specific pull-down technique.

This class creates a mapping between 2 different video files, and supports many pull-down techniques, such as 2:3:2:3 or 2:3:3:2, and also supports inverse telecine. Pull-down techniques are only needed to remove artificial fields added when converting between 24 fps (film) and television fps (29.97 fps NTSC or 25 fps PAL).

The following graphic displays a how frame rates are mapped, and how time remapping affects the order of frames returned from the FrameMapper.

Please see the following Example Code:

// Create a frame mapper for a reader, and convert the frame rate (from 24 fps to 29.97 fps)
FrameMapper mapping(reader, Fraction(30000, 1001), PULLDOWN_CLASSIC, 44100, 2, LAYOUT_STEREO);
std::shared_ptr<Frame> frame2 = mapping.GetFrame(2);
// If you need to change the mapping...
mapping.ChangeMapping(Fraction(24, 1), PULLDOWN_CLASSIC, 48000, 2, LAYOUT_MONO)
FrameMapper(ReaderBase *reader, Fraction target_fps, PulldownType target_pulldown, int target_sample_rate, int target_channels, ChannelLayout target_channel_layout)
Default constructor for openshot::FrameMapper class.
Definition: FrameMapper.cpp:36
@ PULLDOWN_CLASSIC
Classic 2:3:2:3 pull-down.
Definition: FrameMapper.h:62

Definition at line 139 of file FrameMapper.h.

Constructor & Destructor Documentation

◆ FrameMapper()

FrameMapper::FrameMapper ( ReaderBase reader,
Fraction  target_fps,
PulldownType  target_pulldown,
int  target_sample_rate,
int  target_channels,
ChannelLayout  target_channel_layout 
)

Default constructor for openshot::FrameMapper class.

Definition at line 36 of file FrameMapper.cpp.

◆ ~FrameMapper()

FrameMapper::~FrameMapper ( )
virtual

Destructor.

Definition at line 63 of file FrameMapper.cpp.

Member Function Documentation

◆ ChangeMapping()

void FrameMapper::ChangeMapping ( Fraction  target_fps,
PulldownType  pulldown,
int  target_sample_rate,
int  target_channels,
ChannelLayout  target_channel_layout 
)

Change frame rate or audio mapping details.

Definition at line 727 of file FrameMapper.cpp.

◆ Close()

void FrameMapper::Close ( )
virtual

Close the openshot::FrameMapper and internal reader.

Implements openshot::ReaderBase.

Definition at line 645 of file FrameMapper.cpp.

Referenced by SetJsonValue(), ~FrameMapper(), and openshot::Timeline::~Timeline().

◆ GetCache()

CacheMemory* openshot::FrameMapper::GetCache ( )
inlinevirtual

Get the cache object used by this reader.

Implements openshot::ReaderBase.

Definition at line 185 of file FrameMapper.h.

◆ GetFrame()

std::shared_ptr< Frame > FrameMapper::GetFrame ( int64_t  requested_frame)
virtual

This method is required for all derived classes of ReaderBase, and return the openshot::Frame object, which contains the image and audio information for that frame of video.

Returns
The requested frame of video
Parameters
requested_frameThe frame number that is requested.

Implements openshot::ReaderBase.

Definition at line 389 of file FrameMapper.cpp.

◆ GetMappedFrame()

MappedFrame FrameMapper::GetMappedFrame ( int64_t  TargetFrameNumber)

Get a frame based on the target frame rate and the new frame number of a frame.

Definition at line 314 of file FrameMapper.cpp.

Referenced by GetFrame().

◆ IsOpen()

bool FrameMapper::IsOpen ( )
virtual

Determine if reader is open or closed.

Implements openshot::ReaderBase.

Definition at line 624 of file FrameMapper.cpp.

◆ Json()

std::string FrameMapper::Json ( ) const
overridevirtual

Get and Set JSON methods.

Generate JSON string of this object

Implements openshot::ReaderBase.

Definition at line 678 of file FrameMapper.cpp.

◆ JsonValue()

Json::Value FrameMapper::JsonValue ( ) const
overridevirtual

Generate Json::Value for this object.

Implements openshot::ReaderBase.

Definition at line 685 of file FrameMapper.cpp.

Referenced by Json().

◆ Name()

std::string openshot::FrameMapper::Name ( )
inlinevirtual

Return the type name of the class.

Implements openshot::ReaderBase.

Definition at line 199 of file FrameMapper.h.

◆ Open()

void FrameMapper::Open ( )
virtual

Open the internal reader.

Implements openshot::ReaderBase.

Definition at line 633 of file FrameMapper.cpp.

Referenced by SetJsonValue().

◆ PrintMapping()

void FrameMapper::PrintMapping ( )

Print all of the original frames and which new frames they map to.

Definition at line 590 of file FrameMapper.cpp.

◆ Reader() [1/2]

ReaderBase * FrameMapper::Reader ( )

Get the current reader.

Definition at line 72 of file FrameMapper.cpp.

Referenced by openshot::Timeline::ClearAllCache(), and openshot::Timeline::~Timeline().

◆ Reader() [2/2]

void openshot::FrameMapper::Reader ( ReaderBase new_reader)
inline

Set the current reader.

Definition at line 217 of file FrameMapper.h.

◆ ResampleMappedAudio()

void FrameMapper::ResampleMappedAudio ( std::shared_ptr< Frame frame,
int64_t  original_frame_number 
)

Resample audio and map channels (if needed)

Definition at line 761 of file FrameMapper.cpp.

Referenced by GetFrame().

◆ SetJson()

void FrameMapper::SetJson ( const std::string  value)
virtual

Load JSON string into this object.

Implements openshot::ReaderBase.

Definition at line 696 of file FrameMapper.cpp.

◆ SetJsonValue()

void FrameMapper::SetJsonValue ( const Json::Value  root)
virtual

Load Json::Value into this object.

Implements openshot::ReaderBase.

Definition at line 713 of file FrameMapper.cpp.

Referenced by SetJson().

Member Data Documentation

◆ fields

std::vector<Field> openshot::FrameMapper::fields

Definition at line 166 of file FrameMapper.h.

Referenced by Close().

◆ frames

std::vector<MappedFrame> openshot::FrameMapper::frames

Definition at line 167 of file FrameMapper.h.

Referenced by Close(), GetMappedFrame(), and PrintMapping().


The documentation for this class was generated from the following files: