Loading...
Searching...
No Matches
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:

## 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.
void | Close () override
| Close the openshot::FrameMapper and internal reader.
| 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.
CacheMemory * | GetCache () override
| Get the cache object used by this reader.
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, which contains the image and audio information for that frame of video.
MappedFrame | GetMappedFrame (int64_t TargetFrameNumber)
| Get a frame based on the target frame rate and the new frame number of a frame.
bool | IsOpen () override
| Determine if reader is open or closed.
std::string | Json () const override
| Generate JSON string of this object.
Json::Value | JsonValue () const override
| Generate Json::Value for this object.
std::string | Name () override
| Return the type name of the class.
void | Open () override
| Open the internal reader.
void | PrintMapping (std::ostream *out=&std::cout)
| Print all of the original frames and which new frames they map to.
ReaderBase * | Reader ()
| Get the current reader.
void | Reader (ReaderBase *new_reader)
| Set the current reader.
void | ResampleMappedAudio (std::shared_ptr< Frame > frame, int64_t original_frame_number)
| Resample audio and map channels (if needed)
void | SetJson (const std::string value) override
| Load JSON string into this object.
void | SetJsonValue (const Json::Value root) override
| Load Json::Value into this object.
virtual | ~FrameMapper ()
| Destructor.
Public Member Functions inherited from openshot::ReaderBase
void | DisplayInfo (std::ostream *out=&std::cout)
| Display file information in the standard output stream (stdout)
openshot::ClipBase * | ParentClip ()
| Parent clip object of this reader (which can be unparented and NULL)
void | ParentClip (openshot::ClipBase *new_clip)
| Set parent clip object of this reader.
| ReaderBase ()
| Constructor for the base reader, where many things are initialized.
virtual | ~ReaderBase ()=default

## Public Attributes

std::vector< Field > | fields
std::vector< MappedFrame > | frames
Public Attributes inherited from openshot::ReaderBase
openshot::ReaderInfo | info
| Information about the current media file.

## Additional Inherited Members

Protected Attributes inherited from openshot::ReaderBase
openshot::ClipBase * | clip
| Pointer to the parent clip instance (if any)
std::recursive_mutex | getFrameMutex
| Mutex for multiple threads.

## 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)
openshot::Fraction
This class represents a fraction.
Definition Fraction.h:30
openshot::FrameMapper
This class creates a mapping between 2 different frame rates, applying a specific pull-down technique...
Definition FrameMapper.h:193
openshot::PULLDOWN_CLASSIC
@ PULLDOWN_CLASSIC
Classic 2:3:2:3 pull-down.
Definition FrameMapper.h:44
openshot::LAYOUT_STEREO
@ LAYOUT_STEREO
Definition ChannelLayouts.h:31
openshot::LAYOUT_MONO
@ LAYOUT_MONO
Definition ChannelLayouts.h:30

Definition at line 193 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 25 of file FrameMapper.cpp.

## ~FrameMapper()

FrameMapper::~FrameMapper | ( |  | ) |

virtual

Destructor.

Definition at line 55 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 787 of file FrameMapper.cpp.

## Close()

void FrameMapper::Close | ( |  | ) |

override virtual

Close the openshot::FrameMapper and internal reader.

Implements openshot::ReaderBase.

Definition at line 697 of file FrameMapper.cpp.

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

## GetCache()

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

inline override virtual

Get the cache object used by this reader.

Implements openshot::ReaderBase.

Definition at line 251 of file FrameMapper.h.

## GetFrame()

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

override 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_frame | The frame number that is requested.

Implements openshot::ReaderBase.

Definition at line 431 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 347 of file FrameMapper.cpp.

Referenced by GetFrame().

## IsOpen()

bool FrameMapper::IsOpen | ( |  | ) |

override virtual

Determine if reader is open or closed.

Implements openshot::ReaderBase.

Definition at line 677 of file FrameMapper.cpp.

## Json()

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

override virtual

Generate JSON string of this object.

Implements openshot::ReaderBase.

Definition at line 729 of file FrameMapper.cpp.

## JsonValue()

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

override virtual

Generate Json::Value for this object.

Implements openshot::ReaderBase.

Definition at line 736 of file FrameMapper.cpp.

Referenced by Json().

## Name()

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

inline override virtual

Return the type name of the class.

Implements openshot::ReaderBase.

Definition at line 265 of file FrameMapper.h.

## Open()

void FrameMapper::Open | ( |  | ) |

override virtual

Open the internal reader.

Implements openshot::ReaderBase.

Definition at line 685 of file FrameMapper.cpp.

Referenced by SetJsonValue().

## PrintMapping()

void FrameMapper::PrintMapping | ( | std::ostream * | out = `&std::cout` | ) |

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

Definition at line 651 of file FrameMapper.cpp.

## Reader() [1/2]

ReaderBase * FrameMapper::Reader | ( |  | ) |

Get the current reader.

Definition at line 64 of file FrameMapper.cpp.

Referenced by openshot::Timeline::Clear(), openshot::Timeline::ClearAllCache(), and openshot::Clip::Reader().

## Reader() [2/2]

void openshot::FrameMapper::Reader | ( | ReaderBase * | new_reader | ) |

inline

Set the current reader.

Definition at line 283 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 832 of file FrameMapper.cpp.

Referenced by GetFrame().

## SetJson()

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

override virtual

Load JSON string into this object.

Implements openshot::ReaderBase.

Definition at line 750 of file FrameMapper.cpp.

## SetJsonValue()

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

override virtual

Load Json::Value into this object.

Implements openshot::ReaderBase.

Definition at line 773 of file FrameMapper.cpp.

Referenced by SetJson().

## Member Data Documentation

## fields

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

Definition at line 232 of file FrameMapper.h.

## frames

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

Definition at line 233 of file FrameMapper.h.

Referenced by GetMappedFrame(), and PrintMapping().

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

- FrameMapper.h
- FrameMapper.cpp