avcpp
2.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
|
Go to the documentation of this file.
11 #ifdef AVCPP_USE_SPACESHIP_OPERATOR
18 #define AV_TIME_BASE_Q_CPP AVRational{1, AV_TIME_BASE}
29 Rational(
int numerator,
int denominator = 1) noexcept;
30 Rational(
const AVRational &value) noexcept;
33 AVRational&
getValue() noexcept {
return m_value; }
34 const AVRational&
getValue() const noexcept {
return m_value; }
35 void setValue(
const AVRational &newValue) noexcept { m_value = newValue; }
37 void setNumerator(
int numerator) noexcept { m_value.num = numerator; }
42 double getDouble() const noexcept {
return (
double)m_value.num / (double)m_value.den; }
46 int64_t
rescale(int64_t srcValue,
const Rational &dstBase)
const noexcept;
48 void dump() const noexcept;
50 Rational& operator= (const AVRational &value) noexcept;
51 Rational& operator= (
double value) noexcept;
53 bool operator== (const
Rational &other) const noexcept;
54 #ifdef AVCPP_USE_SPACESHIP_OPERATOR
55 std::strong_ordering operator<=>(
const Rational &other)
const noexcept
57 switch (threewaycmp(other)) {
59 return std::strong_ordering::less;
61 return std::strong_ordering::equal;
63 return std::strong_ordering::greater;
65 return std::strong_ordering::equal;
69 return threewaycmp(other) != 0;
72 return threewaycmp(other) < 0;
75 return threewaycmp(other) > 0;
78 return (*
this < other) || (*
this == other);
81 return (*
this > other) || (*
this == other);
92 operator const AVRational&() const noexcept
98 int threewaycmp(
const Rational &other)
const noexcept;
107 std::enable_if_t<std::is_floating_point_v<T> || std::is_integral_v<T>,
Rational>
114 std::enable_if_t<std::is_floating_point_v<T> || std::is_integral_v<T>,
Rational>
133 stream >> temp.num >> ch >> temp.den;
140 catch (
const std::exception &e)
150 #ifdef __cpp_lib_format
153 template <
typename CharT>
154 struct std::formatter<
av::Rational, CharT>
156 template<
typename ParseContext>
157 constexpr
auto parse(ParseContext& ctx)
161 template<
typename ParseContext>
162 auto format(
const av::Rational& value, ParseContext& ctx)
const
Definition: rational.h:25
AVRational & getValue() noexcept
Definition: rational.h:33
bool operator<=(const Rational &other) const noexcept
Definition: rational.h:77
@ RationalMaxPrecision
Definition: rational.h:22
int getNumerator() const noexcept
Definition: rational.h:40
int64_t rescale(int64_t srcValue, const Rational &dstBase) const noexcept
Definition: rational.cpp:36
Rational operator/(const Rational &value) const noexcept
Definition: rational.cpp:76
bool operator>(const Rational &other) const noexcept
Definition: rational.h:74
Rational() noexcept
Definition: rational.cpp:10
int getDenominator() const noexcept
Definition: rational.h:41
Rational operator-(const Rational &value) const noexcept
Definition: rational.cpp:64
Rational operator+(const Rational &value) const noexcept
Definition: rational.cpp:58
std::ostream & operator<<(std::ostream &stream, const Rational &value)
Definition: rational.h:119
bool operator>=(const Rational &other) const noexcept
Definition: rational.h:80
static Rational fromDouble(double value, int maxPrecision=RationalMaxPrecision) noexcept
Definition: rational.cpp:30
auto operator/(T num, Rational value) -> std::enable_if_t< std::is_floating_point_v< T >||std::is_integral_v< T >, Rational >
Definition: rational.h:106
void dump() const noexcept
Definition: rational.cpp:41
void setNumerator(int numerator) noexcept
Definition: rational.h:37
double operator()() const noexcept
Definition: rational.cpp:82
const AVRational & getValue() const noexcept
Definition: rational.h:34
Definition: audioresampler.cpp:8
bool operator<(const Rational &other) const noexcept
Definition: rational.h:71
double getDouble() const noexcept
Definition: rational.h:42
void setValue(const AVRational &newValue) noexcept
Definition: rational.h:35
bool operator!=(const Rational &other) const noexcept
Definition: rational.h:68
void setDenominator(int denominator) noexcept
Definition: rational.h:38
std::istream & operator>>(std::istream &stream, Rational &value)
Definition: rational.h:126
Rational operator*(const Rational &value) const noexcept
Definition: rational.cpp:70