OpenShot Library | libopenshot
0.2.5
|
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... | |
int | GreatestCommonDenominator () |
Calculate the greatest common denominator. More... | |
Fraction | Reciprocal () |
Return the reciprocal as a Fraction. More... | |
void | Reduce () |
Reduce this fraction (i.e. 640/480 = 4/3) More... | |
double | ToDouble () |
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 45 of file Fraction.h.
Fraction::Fraction | ( | ) |
Fraction::Fraction | ( | int | num, |
int | den | ||
) |
Constructor with numerator and denominator.
Definition at line 39 of file Fraction.cpp.
int Fraction::GreatestCommonDenominator | ( | ) |
Calculate the greatest common denominator.
Definition at line 59 of file Fraction.cpp.
Referenced by Reduce().
Fraction Fraction::Reciprocal | ( | ) |
Return the reciprocal as a Fraction.
Definition at line 84 of file Fraction.cpp.
Referenced by openshot::Frame::Display(), openshot::DummyReader::DummyReader(), openshot::Frame::GetSamplesPerFrame(), openshot::Frame::Save(), openshot::Frame::Thumbnail(), openshot::Timeline::Timeline(), and openshot::ImageWriter::WriteFrame().
void Fraction::Reduce | ( | ) |
Reduce this fraction (i.e. 640/480 = 4/3)
Definition at line 74 of file Fraction.cpp.
Referenced by openshot::DummyReader::DummyReader(), openshot::DecklinkWriter::Open(), openshot::QtImageReader::Open(), openshot::ImageReader::Open(), openshot::DecklinkReader::Open(), openshot::QtHtmlReader::Open(), openshot::TextReader::Open(), openshot::QtTextReader::Open(), openshot::ImageWriter::SetVideoOptions(), openshot::FFmpegWriter::SetVideoOptions(), and openshot::Timeline::Timeline().
double Fraction::ToDouble | ( | ) |
Return this fraction as a double (i.e. 1/2 = 0.5)
Definition at line 49 of file Fraction.cpp.
Referenced by openshot::Frame::Display(), openshot::WriterBase::DisplayInfo(), openshot::ReaderBase::DisplayInfo(), openshot::FFmpegReader::FFmpegReader(), openshot::FrameMapper::FrameMapper(), openshot::Timeline::GetFrame(), openshot::Frame::GetSamplesPerFrame(), openshot::DecklinkWriter::Open(), openshot::QtImageReader::Open(), openshot::ImageReader::Open(), openshot::DecklinkReader::Open(), openshot::QtHtmlReader::Open(), openshot::TextReader::Open(), openshot::QtTextReader::Open(), openshot::Frame::Save(), openshot::Frame::Thumbnail(), and openshot::ImageWriter::WriteFrame().
float Fraction::ToFloat | ( | ) |
Return this fraction as a float (i.e. 1/2 = 0.5)
Definition at line 44 of file Fraction.cpp.
Referenced by VideoRenderWidget::centeredViewport(), openshot::DummyReader::DummyReader(), openshot::Clip::End(), openshot::Timeline::GetFrame(), openshot::Timeline::SetJsonValue(), openshot::Timeline::SetMaxSize(), 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 54 of file Fraction.cpp.
Referenced by openshot::FrameMapper::PrintMapping().
int openshot::Fraction::den |
Denominator for the fraction.
Definition at line 48 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::DummyReader::DummyReader(), openshot::FrameMapper::FrameMapper(), openshot::FrameMapper::GetFrame(), GreatestCommonDenominator(), openshot::Profile::JsonValue(), openshot::WriterBase::JsonValue(), openshot::ReaderBase::JsonValue(), openshot::DecklinkWriter::Open(), openshot::QtImageReader::Open(), openshot::ImageReader::Open(), openshot::DecklinkReader::Open(), openshot::QtHtmlReader::Open(), openshot::QtTextReader::Open(), openshot::TextReader::Open(), openshot::Profile::Profile(), Reciprocal(), Reduce(), openshot::Frame::Save(), openshot::Profile::SetJsonValue(), openshot::WriterBase::SetJsonValue(), openshot::ReaderBase::SetJsonValue(), openshot::Timeline::SetMaxSize(), 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 47 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::DummyReader::DummyReader(), openshot::FrameMapper::FrameMapper(), openshot::FrameMapper::GetFrame(), GreatestCommonDenominator(), openshot::Profile::JsonValue(), openshot::WriterBase::JsonValue(), openshot::ReaderBase::JsonValue(), openshot::DecklinkWriter::Open(), openshot::QtImageReader::Open(), openshot::ImageReader::Open(), openshot::DecklinkReader::Open(), openshot::QtHtmlReader::Open(), openshot::QtTextReader::Open(), openshot::TextReader::Open(), openshot::Profile::Profile(), Reciprocal(), Reduce(), openshot::Frame::Save(), openshot::Profile::SetJsonValue(), openshot::WriterBase::SetJsonValue(), openshot::ReaderBase::SetJsonValue(), openshot::Timeline::SetMaxSize(), openshot::Frame::SetPixelRatio(), openshot::ImageWriter::SetVideoOptions(), openshot::FFmpegWriter::SetVideoOptions(), openshot::Frame::Thumbnail(), ToDouble(), ToFloat(), ToInt(), and VideoRenderWidget::VideoRenderWidget().