|
|
| Rational () noexcept |
| | Create zero, in the sense of 0/1.
|
| | Rational (int numerator, int denominator=1) noexcept |
| | Create a rational number.
|
| | Rational (const AVRational &value) noexcept |
| | Wrap an FFmpeg rational.
|
| | Rational (double value, int maxPrecision=RationalMaxPrecision) noexcept |
| | Approximate a floating point value as a rational.
|
| AVRational & | getValue () noexcept |
| | Mutable access to the underlying FFmpeg value.
|
| const AVRational & | getValue () const noexcept |
| | The underlying FFmpeg value.
|
| void | setValue (const AVRational &newValue) noexcept |
| | Replace the value.
|
| void | setNumerator (int numerator) noexcept |
| | Set the numerator.
|
| void | setDenominator (int denominator) noexcept |
| | Set the denominator.
|
| int | getNumerator () const noexcept |
| | The numerator.
|
| int | getDenominator () const noexcept |
| | The denominator.
|
| double | getDouble () const noexcept |
| | The value as a floating point number.
|
| int64_t | rescale (int64_t srcValue, const Rational &dstBase) const noexcept |
| | Rescale a value from this base to another.
|
|
void | dump () const noexcept |
| | Print the value through the FFmpeg log system.
|
| Rational & | operator= (const AVRational &value) noexcept |
| | Assign an FFmpeg rational.
|
| Rational & | operator= (double value) noexcept |
| | Assign an approximation of a floating point value.
|
| bool | operator== (const Rational &other) const noexcept |
| | Compare two rationals by value, not by representation.
|
| std::strong_ordering | operator<=> (const Rational &other) const noexcept |
| | Order two rationals by value.
|
| Rational | operator+ (const Rational &value) const noexcept |
| | Add another rational.
|
| Rational | operator- (const Rational &value) const noexcept |
| | Subtract another rational.
|
| Rational | operator* (const Rational &value) const noexcept |
| | Multiply by another rational.
|
| Rational | operator/ (const Rational &value) const noexcept |
| | Divide by another rational.
|
| double | operator() () const noexcept |
| | The value as a floating point number.
|
| | operator const AVRational & () const noexcept |
| | Implicit conversion to the FFmpeg type.
|
Widths, heights and frame rates in FFmpeg are rationals, and so are the time bases that give meaning to timestamps. The class keeps the FFmpeg representation and adds comparison and arithmetic that account for different denominators, so 1/25 and 2/50 compare equal.
A denominator of zero is preserved rather than corrected: it is what FFmpeg uses for "unknown", and isValid() reports it.
- Examples
- api2-decode-encode-audio.cpp, api2-decode-encode-video.cpp, api2-decode-filter-encode.cpp, api2-decode-overlay-encode.cpp, api2-generate-subtitles.cpp, api2-hw-encode.cpp, api2-hw-scale.cpp, api2-hw-transcode.cpp, and api2-scale-video.cpp.