OpenShot Library | libopenshot
0.3.3
|
This class represents a fraction. More...
#include <Fraction.h>
Public Member Functions | |
Fraction () | |
Default Constructor. More... | |
Fraction (int num, int den) | |
Constructor with numerator and denominator. More... | |
Fraction (std::map< std::string, int > mapping) | |
Constructor that takes a key-value mapping (keys: 'num'. 'den') More... | |
Fraction (std::pair< int, int > pair) | |
Constructor that accepts a (num, den) pair. More... | |
Fraction (std::vector< int > vector) | |
Constructor that takes a vector of length 2 (containing {num, den}) More... | |
int | GreatestCommonDenominator () |
Calculate the greatest common denominator. More... | |
template<class numT > | |
numT | operator* (const numT &other) const |
Multiplication in the form (openshot_Fraction * numeric_value) More... | |
openshot::Fraction | operator* (openshot::Fraction other) |
Multiply two Fraction objects together. More... | |
template<class numT > | |
numT | operator/ (const numT &other) const |
Division in the form (openshot_Fraction / numeric_value) More... | |
openshot::Fraction | operator/ (openshot::Fraction other) |
Divide a Fraction by another Fraction. More... | |
Fraction | Reciprocal () const |
Return the reciprocal as a Fraction. More... | |
void | Reduce () |
Reduce this fraction (i.e. 640/480 = 4/3) More... | |
double | ToDouble () const |
Return this fraction as a double (i.e. 1/2 = 0.5) More... | |
float | ToFloat () |
Return this fraction as a float (i.e. 1/2 = 0.5) More... | |
int | ToInt () |
Return a rounded integer of the fraction (for example 30000/1001 returns 30) More... | |
Public Attributes | |
int | den |
Denominator for the fraction. More... | |
int | num |
Numerator for the fraction. More... | |
This class represents a fraction.
Fractions are often used in video editing to represent ratios and rates, for example: pixel ratios, frames per second, timebase, and other common ratios. Fractions are preferred over decimals due to their increased precision.
Definition at line 30 of file Fraction.h.
Fraction::Fraction | ( | ) |
Fraction::Fraction | ( | int | num, |
int | den | ||
) |
Constructor with numerator and denominator.
Definition at line 31 of file Fraction.cpp.
Fraction::Fraction | ( | std::pair< int, int > | pair | ) |
Constructor that accepts a (num, den) pair.
Definition at line 21 of file Fraction.cpp.
Fraction::Fraction | ( | std::vector< int > | vector | ) |
Constructor that takes a vector of length 2 (containing {num, den})
Definition at line 27 of file Fraction.cpp.
Fraction::Fraction | ( | std::map< std::string, int > | mapping | ) |
Constructor that takes a key-value mapping (keys: 'num'. 'den')
Definition at line 24 of file Fraction.cpp.
int Fraction::GreatestCommonDenominator | ( | ) |
Calculate the greatest common denominator.
Definition at line 50 of file Fraction.cpp.
Referenced by Reduce().
|
inline |
Multiplication in the form (openshot_Fraction * numeric_value)
Definition at line 82 of file Fraction.h.
|
inline |
Multiply two Fraction objects together.
Definition at line 71 of file Fraction.h.
|
inline |
Division in the form (openshot_Fraction / numeric_value)
Definition at line 88 of file Fraction.h.
|
inline |
Divide a Fraction by another Fraction.
Definition at line 76 of file Fraction.h.
Fraction Fraction::Reciprocal | ( | ) | const |
Return the reciprocal as a Fraction.
Definition at line 78 of file Fraction.cpp.
Referenced by openshot::Frame::Display(), openshot::TrackedObjectBBox::FrameNToTime(), openshot::Frame::GetSamplesPerFrame(), openshot::ImageReader::Open(), operator/(), openshot::Frame::Save(), openshot::ImageWriter::SetVideoOptions(), openshot::Frame::Thumbnail(), and openshot::Timeline::Timeline().
void Fraction::Reduce | ( | ) |
Reduce this fraction (i.e. 640/480 = 4/3)
Definition at line 65 of file Fraction.cpp.
Referenced by openshot::ImageReader::Open(), openshot::QtHtmlReader::Open(), openshot::TextReader::Open(), openshot::QtTextReader::Open(), openshot::QtImageReader::Open(), openshot::Profile::SetJsonValue(), openshot::ImageWriter::SetVideoOptions(), openshot::FFmpegWriter::SetVideoOptions(), and openshot::Timeline::Timeline().
double Fraction::ToDouble | ( | ) | const |
Return this fraction as a double (i.e. 1/2 = 0.5)
Definition at line 40 of file Fraction.cpp.
Referenced by openshot::Timeline::apply_effects(), openshot::FrameMapper::ChangeMapping(), openshot::Frame::Display(), openshot::WriterBase::DisplayInfo(), openshot::ReaderBase::DisplayInfo(), openshot::FrameMapper::FrameMapper(), openshot::TrackedObjectBBox::FrameNToTime(), openshot::Caption::GetFrame(), openshot::Timeline::GetFrame(), openshot::Timeline::GetMaxFrame(), openshot::Timeline::GetMinFrame(), openshot::Frame::GetSamplesPerFrame(), openshot::ImageReader::Open(), openshot::QtHtmlReader::Open(), openshot::TextReader::Open(), openshot::QtTextReader::Open(), openshot::QtImageReader::Open(), operator*(), openshot::operator*(), operator/(), openshot::operator/(), openshot::Clip::PropertiesJSON(), openshot::VideoCacheThread::run(), openshot::Frame::Save(), and openshot::Frame::Thumbnail().
float Fraction::ToFloat | ( | ) |
Return this fraction as a float (i.e. 1/2 = 0.5)
Definition at line 35 of file Fraction.cpp.
Referenced by VideoRenderWidget::centeredViewport(), openshot::Clip::End(), openshot::Caption::GetFrame(), openshot::Timeline::GetFrame(), openshot::VideoCacheThread::run(), openshot::Timeline::SetJsonValue(), openshot::Timeline::Timeline(), and openshot::ImageWriter::WriteFrame().
int Fraction::ToInt | ( | ) |
Return a rounded integer of the fraction (for example 30000/1001 returns 30)
Definition at line 45 of file Fraction.cpp.
int openshot::Fraction::den |
Denominator for the fraction.
Definition at line 33 of file Fraction.h.
Referenced by openshot::FrameMapper::ChangeMapping(), openshot::WriterBase::CopyReaderInfo(), openshot::Frame::DeepCopy(), openshot::Frame::Display(), openshot::WriterBase::DisplayInfo(), openshot::ReaderBase::DisplayInfo(), openshot::FrameMapper::FrameMapper(), openshot::FrameMapper::GetFrame(), GreatestCommonDenominator(), openshot::WriterBase::JsonValue(), openshot::ReaderBase::JsonValue(), openshot::Profile::JsonValue(), openshot::TrackedObjectBBox::JsonValue(), openshot::Profile::Key(), openshot::Profile::LongName(), openshot::Profile::LongNameWithDesc(), openshot::ImageReader::Open(), openshot::QtHtmlReader::Open(), openshot::TextReader::Open(), openshot::QtTextReader::Open(), openshot::QtImageReader::Open(), operator*(), openshot::operator<<(), openshot::Profile::Profile(), Reciprocal(), Reduce(), openshot::Profile::Save(), openshot::Frame::Save(), openshot::WriterBase::SetJsonValue(), openshot::ReaderBase::SetJsonValue(), openshot::Profile::SetJsonValue(), openshot::TrackedObjectBBox::SetJsonValue(), openshot::Frame::SetPixelRatio(), openshot::ImageWriter::SetVideoOptions(), openshot::FFmpegWriter::SetVideoOptions(), openshot::Frame::Thumbnail(), ToDouble(), ToFloat(), ToInt(), and VideoRenderWidget::VideoRenderWidget().
int openshot::Fraction::num |
Numerator for the fraction.
Definition at line 32 of file Fraction.h.
Referenced by openshot::FrameMapper::ChangeMapping(), openshot::WriterBase::CopyReaderInfo(), openshot::Frame::DeepCopy(), openshot::Frame::Display(), openshot::WriterBase::DisplayInfo(), openshot::ReaderBase::DisplayInfo(), openshot::FrameMapper::FrameMapper(), openshot::FrameMapper::GetFrame(), GreatestCommonDenominator(), openshot::WriterBase::JsonValue(), openshot::ReaderBase::JsonValue(), openshot::Profile::JsonValue(), openshot::TrackedObjectBBox::JsonValue(), openshot::Profile::Key(), openshot::Profile::LongName(), openshot::Profile::LongNameWithDesc(), openshot::ImageReader::Open(), openshot::QtHtmlReader::Open(), openshot::TextReader::Open(), openshot::QtTextReader::Open(), openshot::QtImageReader::Open(), operator*(), openshot::operator<<(), openshot::Profile::Profile(), Reciprocal(), Reduce(), openshot::Profile::Save(), openshot::Frame::Save(), openshot::WriterBase::SetJsonValue(), openshot::ReaderBase::SetJsonValue(), openshot::Profile::SetJsonValue(), openshot::TrackedObjectBBox::SetJsonValue(), openshot::Frame::SetPixelRatio(), openshot::ImageWriter::SetVideoOptions(), openshot::FFmpegWriter::SetVideoOptions(), openshot::Frame::Thumbnail(), ToDouble(), ToFloat(), ToInt(), and VideoRenderWidget::VideoRenderWidget().