style: unify identifier naming per updated conventions

Automated with clang-tidy readability-identifier-naming (config added to
.clang-tidy) plus scripted passes, per the updated rules now documented
in CONTRIBUTING.md:

- types (class/struct/enum/alias/template params): PascalCase
- functions, variables, members: snake_case (incl. rational -> Rational)
- private/protected members: trailing underscore; static member
  variables likewise (instance_, available_themes_)
- constants and enum values: snake_case (kLinear -> k_linear,
  F32P -> f32p); ALL_CAPS reserved for macros
- macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG ->
  OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE,
  include guards -> OAK_*)
- file names: all lowercase (Current/Plugin/OliveHost/OliveClip/
  OlivePluginInstance -> current/plugin/olivehost/oliveclip/
  oliveplugininstance)
- getters share the member name sans underscore, setters set_foo()
- Qt and third-party (OpenFX) virtual overrides and framework callbacks
  keep their original names (exempt in .clang-tidy)

Manual follow-ups required where automation could not reach:
- string-based QMetaObject/SIGNAL/SLOT references updated to renamed
  methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...)
- macro bodies referencing renamed methods (OLIVE_CONFIG,
  NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*)
- self-shadowing locals renamed where signals/methods became same-named
  (size_changed, worker_count, selected_items, import param, filters)
- third_party OFX member/namespace usages restored (OFX::Host::*,
  _created, _clipPrefsDirty, createInstance, clearPersistentMessage)
- STL protocol aliases restored (const_iterator) with .clang-tidy
  ignore rules; qHash overloads restored

Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
2026-07-19 16:10:54 +08:00
parent cb1718a103
commit bb40b4923e
1014 changed files with 44257 additions and 44220 deletions
+3 -3
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBOLIVECORE_H
#define LIBOLIVECORE_H
#ifndef OAK_LIBOLIVECORE_H
#define OAK_LIBOLIVECORE_H
#include "render/audioparams.h"
#include "render/pixelformat.h"
@@ -35,4 +35,4 @@
#include "util/timerange.h"
#include "util/value.h"
#endif // LIBOLIVECORE_H
#endif // OAK_LIBOLIVECORE_H
+17 -17
View File
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_AUDIOPARAMS_H
#define LIBOLIVECORE_AUDIOPARAMS_H
#ifndef OAK_LIBOLIVECORE_AUDIOPARAMS_H
#define OAK_LIBOLIVECORE_AUDIOPARAMS_H
#include <cstring>
#include <assert.h>
@@ -50,7 +50,7 @@ public:
: sample_rate_(0)
, channel_layout_mask_(0)
, channel_count_(0)
, format_(SampleFormat::INVALID)
, format_(SampleFormat::invalid)
{
set_default_footage_parameters();
}
@@ -99,19 +99,19 @@ public:
channel_layout_mask_ = mask;
calculate_channel_count();
}
rational time_base() const
Rational time_base() const
{
return timebase_;
}
void set_time_base(const rational &timebase)
void set_time_base(const Rational &timebase)
{
timebase_ = timebase;
}
rational sample_rate_as_time_base() const
Rational sample_rate_as_time_base() const
{
return rational(1, sample_rate());
return Rational(1, sample_rate());
}
SampleFormat format() const
@@ -155,17 +155,17 @@ public:
}
int64_t time_to_bytes(const double &time) const;
int64_t time_to_bytes(const rational &time) const;
int64_t time_to_bytes(const Rational &time) const;
int64_t time_to_bytes_per_channel(const double &time) const;
int64_t time_to_bytes_per_channel(const rational &time) const;
int64_t time_to_bytes_per_channel(const Rational &time) const;
int64_t time_to_samples(const double &time) const;
int64_t time_to_samples(const rational &time) const;
int64_t time_to_samples(const Rational &time) const;
int64_t samples_to_bytes(const int64_t &samples) const;
int64_t samples_to_bytes_per_channel(const int64_t &samples) const;
rational samples_to_time(const int64_t &samples) const;
Rational samples_to_time(const int64_t &samples) const;
int64_t bytes_to_samples(const int64_t &bytes) const;
rational bytes_to_time(const int64_t &bytes) const;
rational bytes_per_channel_to_time(const int64_t &bytes) const;
Rational bytes_to_time(const int64_t &bytes) const;
Rational bytes_per_channel_to_time(const int64_t &bytes) const;
int channel_count() const;
int bytes_per_sample_per_channel() const;
int bits_per_sample() const;
@@ -174,8 +174,8 @@ public:
bool operator==(const AudioParams &other) const;
bool operator!=(const AudioParams &other) const;
static const std::vector<uint64_t> kSupportedChannelLayouts;
static const std::vector<int> kSupportedSampleRates;
static const std::vector<uint64_t> k_supported_channel_layouts;
static const std::vector<int> k_supported_sample_rates;
private:
void set_default_footage_parameters()
@@ -209,9 +209,9 @@ private:
int enabled_; // Using int instead of bool fixes GCC 11 stringop-overflow issue (byte alignment)
int stream_index_; ///< Index in the source file's stream list
int64_t duration_; ///< Stream duration in timebase units
rational timebase_; ///< Timebase for this audio stream
Rational timebase_; ///< Timebase for this audio stream
};
}
#endif // LIBOLIVECORE_AUDIOPARAMS_H
#endif // OAK_LIBOLIVECORE_AUDIOPARAMS_H
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_CHANNELLAYOUT_H
#define LIBOLIVECORE_CHANNELLAYOUT_H
#ifndef OAK_LIBOLIVECORE_CHANNELLAYOUT_H
#define OAK_LIBOLIVECORE_CHANNELLAYOUT_H
#include <stdint.h>
@@ -35,16 +35,16 @@ namespace olive::core
* straight through to the FFmpeg bridge library; the bridge unit tests
* static_assert each value against the real FFmpeg headers.
*/
inline constexpr uint64_t kChannelLayoutMono = 0x4; ///< AV_CH_LAYOUT_MONO
inline constexpr uint64_t kChannelLayoutStereo = 0x3; ///< AV_CH_LAYOUT_STEREO
inline constexpr uint64_t kChannelLayout2_1 = 0x103; ///< AV_CH_LAYOUT_2_1
inline constexpr uint64_t kChannelLayout5Point1 = 0x60F; ///< AV_CH_LAYOUT_5POINT1
inline constexpr uint64_t kChannelLayout7Point1 = 0x63F; ///< AV_CH_LAYOUT_7POINT1
inline constexpr uint64_t k_channel_layout_mono = 0x4; ///< AV_CH_LAYOUT_MONO
inline constexpr uint64_t k_channel_layout_stereo = 0x3; ///< AV_CH_LAYOUT_STEREO
inline constexpr uint64_t k_channel_layout2_1 = 0x103; ///< AV_CH_LAYOUT_2_1
inline constexpr uint64_t k_channel_layout5_point1 = 0x60F; ///< AV_CH_LAYOUT_5POINT1
inline constexpr uint64_t k_channel_layout7_point1 = 0x63F; ///< AV_CH_LAYOUT_7POINT1
/**
* @brief Number of channels in a layout mask (population count)
*/
inline int ChannelLayoutMaskChannelCount(uint64_t mask)
inline int channel_layout_mask_channel_count(uint64_t mask)
{
#if defined(__GNUC__) || defined(__clang__)
return __builtin_popcountll(mask);
@@ -60,4 +60,4 @@ inline int ChannelLayoutMaskChannelCount(uint64_t mask)
}
#endif // LIBOLIVECORE_CHANNELLAYOUT_H
#endif // OAK_LIBOLIVECORE_CHANNELLAYOUT_H
+36 -36
View File
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_PIXELFORMAT_H
#define LIBOLIVECORE_PIXELFORMAT_H
#ifndef OAK_LIBOLIVECORE_PIXELFORMAT_H
#define OAK_LIBOLIVECORE_PIXELFORMAT_H
#include "ofxCore.h"
#include <string>
namespace olive::core
@@ -28,9 +28,9 @@ namespace olive::core
class PixelFormat {
public:
enum Format { INVALID = -1, U8, U10, U16, F16, F32, COUNT };
enum Format { invalid = -1, u8, u10, u16, f16, f32, count };
PixelFormat(Format f = INVALID)
PixelFormat(Format f = invalid)
{
f_ = f;
}
@@ -40,35 +40,35 @@ public:
return f_;
}
static PixelFormat from_ofx(std::string ofxFormat){
if(ofxFormat == kOfxBitDepthByte){
return PixelFormat::U8;
static PixelFormat from_ofx(std::string ofx_format){
if(ofx_format == kOfxBitDepthByte){
return PixelFormat::u8;
}
else if (ofxFormat == kOfxBitDepthShort){
return PixelFormat::U16;
else if (ofx_format == kOfxBitDepthShort){
return PixelFormat::u16;
}
else if(ofxFormat == kOfxBitDepthHalf){
return PixelFormat::F16;
else if(ofx_format == kOfxBitDepthHalf){
return PixelFormat::f16;
}
else if(ofxFormat == kOfxBitDepthFloat){
return PixelFormat::F32;
else if(ofx_format == kOfxBitDepthFloat){
return PixelFormat::f32;
}
return PixelFormat::INVALID;
return PixelFormat::invalid;
}
static int byte_count(Format f)
{
switch (f) {
case INVALID:
case COUNT:
case invalid:
case count:
break;
case U8:
case u8:
return 1;
case U10:
case u10:
return 4; // packed RGBA10A2, treated as 4 bytes per pixel
case U16:
case F16:
case u16:
case f16:
return 2;
case F32:
case f32:
return 4;
}
@@ -78,18 +78,18 @@ public:
const char *to_string() const
{
switch (f_) {
case U8:
case u8:
return "u8";
case U10:
case u10:
return "u10";
case U16:
case u16:
return "u16";
case F16:
case f16:
return "f16";
case F32:
case f32:
return "f32";
case INVALID:
case COUNT:
case invalid:
case count:
break;
}
@@ -104,14 +104,14 @@ public:
static bool is_float(Format f)
{
switch (f) {
case INVALID:
case COUNT:
case U8:
case U10:
case U16:
case invalid:
case count:
case u8:
case u10:
case u16:
break;
case F16:
case F32:
case f16:
case f32:
return true;
}
@@ -129,4 +129,4 @@ private:
}
#endif // LIBOLIVECORE_PIXELFORMAT_H
#endif // OAK_LIBOLIVECORE_PIXELFORMAT_H
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_SAMPLEBUFFER_H
#define LIBOLIVECORE_SAMPLEBUFFER_H
#ifndef OAK_LIBOLIVECORE_SAMPLEBUFFER_H
#define OAK_LIBOLIVECORE_SAMPLEBUFFER_H
#include <memory>
#include <vector>
@@ -42,7 +42,7 @@ namespace olive::core
class SampleBuffer {
public:
SampleBuffer();
SampleBuffer(const AudioParams &audio_params, const rational &length);
SampleBuffer(const AudioParams &audio_params, const Rational &length);
SampleBuffer(const AudioParams &audio_params, size_t samples_per_channel);
SampleBuffer rip_channel(int channel) const;
@@ -56,7 +56,7 @@ public:
return sample_count_per_channel_;
}
void set_sample_count(const size_t &sample_count);
void set_sample_count(const rational &length)
void set_sample_count(const Rational &length)
{
set_sample_count(audio_params_.time_to_samples(length));
}
@@ -134,4 +134,4 @@ private:
}
#endif // LIBOLIVECORE_SAMPLEBUFFER_H
#endif // OAK_LIBOLIVECORE_SAMPLEBUFFER_H
+109 -109
View File
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_SAMPLEFORMAT_H
#define LIBOLIVECORE_SAMPLEFORMAT_H
#ifndef OAK_LIBOLIVECORE_SAMPLEFORMAT_H
#define OAK_LIBOLIVECORE_SAMPLEFORMAT_H
#include <stdexcept>
#include <string>
@@ -31,31 +31,31 @@ namespace olive::core
class SampleFormat {
public:
enum Format {
INVALID = -1,
invalid = -1,
U8P,
S16P,
S32P,
S64P,
F32P,
F64P,
u8_p,
s16_p,
s32_p,
s64_p,
f32_p,
f64_p,
U8,
S16,
S32,
S64,
F32,
F64,
u8,
s16,
s32,
s64,
f32,
f64,
COUNT,
count,
PLANAR_START = U8P,
PACKED_START = U8,
PLANAR_END = PACKED_START,
PACKED_END = COUNT,
planar_start = u8_p,
packed_start = u8,
planar_end = packed_start,
packed_end = count,
};
SampleFormat(Format f = INVALID)
SampleFormat(Format f = invalid)
{
f_ = f;
}
@@ -68,24 +68,24 @@ public:
static int byte_count(Format f)
{
switch (f) {
case U8:
case U8P:
case u8:
case u8_p:
return 1;
case S16:
case S16P:
case s16:
case s16_p:
return 2;
case S32:
case F32:
case S32P:
case F32P:
case s32:
case f32:
case s32_p:
case f32_p:
return 4;
case S64:
case F64:
case S64P:
case F64P:
case s64:
case f64:
case s64_p:
case f64_p:
return 8;
case INVALID:
case COUNT:
case invalid:
case count:
break;
}
@@ -100,32 +100,32 @@ public:
static std::string to_string(Format f)
{
switch (f) {
case INVALID:
case COUNT:
case invalid:
case count:
break;
case U8:
case u8:
return "u8";
case S16:
case s16:
return "s16";
case S32:
case s32:
return "s32";
case S64:
case s64:
return "s64";
case F32:
case f32:
return "f32";
case F64:
case f64:
return "f64";
case U8P:
case u8_p:
return "u8p";
case S16P:
case s16_p:
return "s16p";
case S32P:
case s32_p:
return "s32p";
case S64P:
case s64_p:
return "s64p";
case F32P:
case f32_p:
return "f32p";
case F64P:
case f64_p:
return "f64p";
}
@@ -140,50 +140,50 @@ public:
static SampleFormat from_string(const std::string &s)
{
if (s.empty()) {
return INVALID;
return invalid;
} else if (s == "u8") {
return U8;
return u8;
} else if (s == "s16") {
return S16;
return s16;
} else if (s == "s32") {
return S32;
return s32;
} else if (s == "s64") {
return S64;
return s64;
} else if (s == "f32") {
return F32;
return f32;
} else if (s == "f64") {
return F64;
return f64;
} else if (s == "u8p") {
return U8P;
return u8_p;
} else if (s == "s16p") {
return S16P;
return s16_p;
} else if (s == "s32p") {
return S32P;
return s32_p;
} else if (s == "s64p") {
return S64P;
return s64_p;
} else if (s == "f32p") {
return F32P;
return f32_p;
} else if (s == "f64p") {
return F64P;
return f64_p;
} else {
// Deprecated: sample formats used to be serialized as an integer. Handle that here, but we'll
// probably remove that eventually.
try {
int i = std::stoi(s);
if (i > INVALID && i < COUNT) {
if (i > invalid && i < count) {
return static_cast<Format>(i);
}
} catch (const std::invalid_argument &e) {
}
// Failed to deserialize from string
return INVALID;
return invalid;
}
}
static bool is_packed(Format f)
{
return f >= PACKED_START && f < PACKED_END;
return f >= packed_start && f < packed_end;
}
bool is_packed() const
@@ -193,7 +193,7 @@ public:
static bool is_planar(Format f)
{
return f >= PLANAR_START && f < PLANAR_END;
return f >= planar_start && f < planar_end;
}
bool is_planar() const
@@ -205,34 +205,34 @@ public:
{
switch (fmt) {
// For packed input, just return input
case U8:
case S16:
case S32:
case S64:
case F32:
case F64:
case u8:
case s16:
case s32:
case s64:
case f32:
case f64:
return fmt;
// Convert to packed
case U8P:
return U8;
case S16P:
return S16;
case S32P:
return S32;
case S64P:
return S64;
case F32P:
return F32;
case F64P:
return F64;
case u8_p:
return u8;
case s16_p:
return s16;
case s32_p:
return s32;
case s64_p:
return s64;
case f32_p:
return f32;
case f64_p:
return f64;
case INVALID:
case COUNT:
case invalid:
case count:
break;
}
return INVALID;
return invalid;
}
SampleFormat to_packed_equivalent() const
@@ -244,34 +244,34 @@ public:
{
switch (fmt) {
// Convert to planar
case U8:
return U8P;
case S16:
return S16P;
case S32:
return S32P;
case S64:
return S64P;
case F32:
return F32P;
case F64:
return F64P;
case u8:
return u8_p;
case s16:
return s16_p;
case s32:
return s32_p;
case s64:
return s64_p;
case f32:
return f32_p;
case f64:
return f64_p;
// For planar input, just return input
case U8P:
case S16P:
case S32P:
case S64P:
case F32P:
case F64P:
case u8_p:
case s16_p:
case s32_p:
case s64_p:
case f32_p:
case f64_p:
return fmt;
case INVALID:
case COUNT:
case invalid:
case count:
break;
}
return INVALID;
return invalid;
}
SampleFormat to_planar_equivalent() const
@@ -285,4 +285,4 @@ private:
}
#endif // LIBOLIVECORE_SAMPLEFORMAT_H
#endif // OAK_LIBOLIVECORE_SAMPLEFORMAT_H
+12 -12
View File
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_BEZIER_H
#define LIBOLIVECORE_BEZIER_H
#ifndef OAK_LIBOLIVECORE_BEZIER_H
#define OAK_LIBOLIVECORE_BEZIER_H
#include <Imath/ImathVec.h>
@@ -99,28 +99,28 @@ public:
cp2_y_ = cp2_y;
}
static double QuadraticXtoT(double x, double a, double b, double c);
static double quadratic_xto_t(double x, double a, double b, double c);
static double QuadraticTtoY(double a, double b, double c, double t);
static double quadratic_tto_y(double a, double b, double c, double t);
static double QuadraticXtoY(double x, const Imath::V2d &a,
static double quadratic_xto_y(double x, const Imath::V2d &a,
const Imath::V2d &b, const Imath::V2d &c)
{
return QuadraticTtoY(a.y, b.y, c.y, QuadraticXtoT(x, a.x, b.x, c.x));
return quadratic_tto_y(a.y, b.y, c.y, quadratic_xto_t(x, a.x, b.x, c.x));
}
static double CubicXtoT(double x, double a, double b, double c, double d);
static double cubic_xto_t(double x, double a, double b, double c, double d);
static double CubicTtoY(double a, double b, double c, double d, double t);
static double cubic_tto_y(double a, double b, double c, double d, double t);
static double CubicXtoY(double x, const Imath::V2d &a, const Imath::V2d &b,
static double cubic_xto_y(double x, const Imath::V2d &a, const Imath::V2d &b,
const Imath::V2d &c, const Imath::V2d &d)
{
return CubicTtoY(a.y, b.y, c.y, d.y, CubicXtoT(x, a.x, b.x, c.x, d.x));
return cubic_tto_y(a.y, b.y, c.y, d.y, cubic_xto_t(x, a.x, b.x, c.x, d.x));
}
private:
static double CalculateTFromX(bool cubic, double x, double a, double b,
static double calculate_t_from_x(bool cubic, double x, double a, double b,
double c, double d);
double x_;
@@ -135,4 +135,4 @@ private:
}
#endif // LIBOLIVECORE_BEZIER_H
#endif // OAK_LIBOLIVECORE_BEZIER_H
+12 -12
View File
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_COLOR_H
#define LIBOLIVECORE_COLOR_H
#ifndef OAK_LIBOLIVECORE_COLOR_H
#define OAK_LIBOLIVECORE_COLOR_H
#include "../render/pixelformat.h"
@@ -33,11 +33,11 @@ namespace olive::core
class Color {
public:
using DataType = float;
static constexpr unsigned int RGBA = 4;
static constexpr unsigned int rgba = 4;
Color()
{
for (unsigned int i = 0; i < RGBA; i++) {
for (unsigned int i = 0; i < rgba; i++) {
data_[i] = 0.0;
}
}
@@ -58,7 +58,7 @@ public:
*
* Hue expects a value between 0.0 and 360.0. Saturation and Value expect a value between 0.0 and 1.0.
*/
static Color fromHsv(const DataType &h, const DataType &s,
static Color from_hsv(const DataType &h, const DataType &s,
const DataType &v);
const DataType &red() const
@@ -78,12 +78,12 @@ public:
return data_[3];
}
void toHsv(DataType *hue, DataType *sat, DataType *val) const;
void to_hsv(DataType *hue, DataType *sat, DataType *val) const;
DataType hsv_hue() const;
DataType hsv_saturation() const;
DataType value() const;
void toHsl(DataType *hue, DataType *sat, DataType *lightness) const;
void to_hsl(DataType *hue, DataType *sat, DataType *lightness) const;
DataType hsl_hue() const;
DataType hsl_saturation() const;
DataType lightness() const;
@@ -114,15 +114,15 @@ public:
return data_;
}
void toData(char *out, const PixelFormat &format,
void to_data(char *out, const PixelFormat &format,
unsigned int nb_channels) const;
static Color fromData(const char *in, const PixelFormat &format,
static Color from_data(const char *in, const PixelFormat &format,
unsigned int nb_channels);
// Suuuuper rough luminance value mostly used for UI (determining whether to overlay with black
// or white text)
DataType GetRoughLuminance() const;
DataType get_rough_luminance() const;
// Assignment math operators
Color &operator+=(const Color &rhs);
@@ -176,9 +176,9 @@ public:
}
private:
DataType data_[RGBA];
DataType data_[rgba];
};
}
#endif // LIBOLIVECORE_COLOR_H
#endif // OAK_LIBOLIVECORE_COLOR_H
+3 -3
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBOLIVECORE_CPUOPTIMIZE_H
#define LIBOLIVECORE_CPUOPTIMIZE_H
#ifndef OAK_LIBOLIVECORE_CPUOPTIMIZE_H
#define OAK_LIBOLIVECORE_CPUOPTIMIZE_H
#if defined(__x86_64__) || defined(__i386__)
#define OLIVE_PROCESSOR_X86
@@ -27,4 +27,4 @@
#include "sse2neon.h"
#endif
#endif // LIBOLIVECORE_CPUOPTIMIZE_H
#endif // OAK_LIBOLIVECORE_CPUOPTIMIZE_H
+8 -8
View File
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_FRACTIONUTILS_H
#define LIBOLIVECORE_FRACTIONUTILS_H
#ifndef OAK_LIBOLIVECORE_FRACTIONUTILS_H
#define OAK_LIBOLIVECORE_FRACTIONUTILS_H
#include <stdint.h>
@@ -38,12 +38,12 @@ enum class FractionRounding {
* Round to the nearest value; halfway cases are rounded away from zero.
* Equivalent to FFmpeg's AV_ROUND_NEAR_INF.
*/
kNearInf,
k_near_inf,
/**
* Round toward positive infinity. Equivalent to FFmpeg's AV_ROUND_UP.
*/
kUp
k_up
};
/**
@@ -55,7 +55,7 @@ enum class FractionRounding {
*
* A zero denominator is preserved (with the numerator set to zero).
*/
void ReduceFraction(int64_t &num, int64_t &den, int64_t max);
void reduce_fraction(int64_t &num, int64_t &den, int64_t max);
/**
* @brief Compare two fractions
@@ -64,7 +64,7 @@ void ReduceFraction(int64_t &num, int64_t &den, int64_t max);
* 0 if a == b, 1 if a > b, and INT_MIN when the comparison is meaningless
* (degenerate zero-denominator fractions).
*/
int CompareFractions(int an, int ad, int bn, int bd);
int compare_fractions(int an, int ad, int bn, int bd);
/**
* @brief Rescale `a` by the fraction b/c: returns a * b / c
@@ -73,8 +73,8 @@ int CompareFractions(int an, int ad, int bn, int bd);
* product is computed with 128-bit arithmetic where available so that no
* precision is lost for large timestamps.
*/
int64_t RescaleRnd(int64_t a, int64_t b, int64_t c, FractionRounding rnd);
int64_t rescale_rnd(int64_t a, int64_t b, int64_t c, FractionRounding rnd);
}
#endif // LIBOLIVECORE_FRACTIONUTILS_H
#endif // OAK_LIBOLIVECORE_FRACTIONUTILS_H
+7 -7
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LOG_H
#define LOG_H
#ifndef OAK_LOG_H
#define OAK_LOG_H
#include <iostream>
@@ -42,22 +42,22 @@ public:
return *this;
}
static Log Debug()
static Log debug()
{
return Log("DEBUG");
}
static Log Info()
static Log info()
{
return Log("INFO");
}
static Log Warning()
static Log warning()
{
return Log("WARNING");
}
static Log Error()
static Log error()
{
return Log("ERROR");
}
@@ -65,4 +65,4 @@ public:
}
#endif // LOG_H
#endif // OAK_LOG_H
+3 -3
View File
@@ -19,12 +19,12 @@
***/
#ifndef LIBOLIVECORE_MATH_H
#define LIBOLIVECORE_MATH_H
#ifndef OAK_LIBOLIVECORE_MATH_H
#define OAK_LIBOLIVECORE_MATH_H
namespace olive::core
{
}
#endif // LIBOLIVECORE_MATH_H
#endif // OAK_LIBOLIVECORE_MATH_H
+37 -37
View File
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_RATIONAL_H
#define LIBOLIVECORE_RATIONAL_H
#ifndef OAK_LIBOLIVECORE_RATIONAL_H
#define OAK_LIBOLIVECORE_RATIONAL_H
#include <climits>
#include <iostream>
@@ -32,15 +32,15 @@
namespace olive::core
{
class rational {
class Rational {
public:
rational(const int &numerator = 0)
Rational(const int &numerator = 0)
{
num_ = numerator;
den_ = 1;
}
rational(const int &numerator, const int &denominator)
Rational(const int &numerator, const int &denominator)
{
num_ = numerator;
den_ = denominator;
@@ -49,42 +49,42 @@ public:
reduce();
}
rational(const rational &rhs) = default;
Rational(const Rational &rhs) = default;
static rational fromDouble(const double &flt, bool *ok = nullptr);
static rational fromString(const std::string &str, bool *ok = nullptr);
static Rational from_double(const double &flt, bool *ok = nullptr);
static Rational from_string(const std::string &str, bool *ok = nullptr);
static const rational NaN;
static const Rational na_n;
//Assignment Operators
const rational &operator=(const rational &rhs);
const rational &operator+=(const rational &rhs);
const rational &operator-=(const rational &rhs);
const rational &operator/=(const rational &rhs);
const rational &operator*=(const rational &rhs);
const Rational &operator=(const Rational &rhs);
const Rational &operator+=(const Rational &rhs);
const Rational &operator-=(const Rational &rhs);
const Rational &operator/=(const Rational &rhs);
const Rational &operator*=(const Rational &rhs);
//Binary math operators
rational operator+(const rational &rhs) const;
rational operator-(const rational &rhs) const;
rational operator/(const rational &rhs) const;
rational operator*(const rational &rhs) const;
Rational operator+(const Rational &rhs) const;
Rational operator-(const Rational &rhs) const;
Rational operator/(const Rational &rhs) const;
Rational operator*(const Rational &rhs) const;
//Relational and equality operators
bool operator<(const rational &rhs) const;
bool operator<=(const rational &rhs) const;
bool operator>(const rational &rhs) const;
bool operator>=(const rational &rhs) const;
bool operator==(const rational &rhs) const;
bool operator!=(const rational &rhs) const;
bool operator<(const Rational &rhs) const;
bool operator<=(const Rational &rhs) const;
bool operator>(const Rational &rhs) const;
bool operator>=(const Rational &rhs) const;
bool operator==(const Rational &rhs) const;
bool operator!=(const Rational &rhs) const;
//Unary operators
const rational &operator+() const
const Rational &operator+() const
{
return *this;
}
rational operator-() const
Rational operator-() const
{
return rational(num_, -den_);
return Rational(num_, -den_);
}
bool operator!() const
{
@@ -92,10 +92,10 @@ public:
}
//Function: convert to double
double toDouble() const;
double to_double() const;
#ifdef USE_OTIO
static rational fromRationalTime(const opentime::RationalTime &t)
static Rational fromRationalTime(const opentime::RationalTime &t)
{
// Is this the best way to do this?
return fromDouble(t.to_seconds());
@@ -106,10 +106,10 @@ public:
#endif
// Produce "flipped" version
rational flipped() const;
Rational flipped() const;
void flip();
// Returns whether the rational is valid but equal to zero or not
// Returns whether the Rational is valid but equal to zero or not
//
// A NaN is always a null, but a null is not always a NaN
bool isNull() const
@@ -117,7 +117,7 @@ public:
return num_ == 0;
}
// Returns whether this rational is not a valid number (denominator == 0)
// Returns whether this Rational is not a valid number (denominator == 0)
bool isNaN() const
{
return den_ == 0;
@@ -132,9 +132,9 @@ public:
return den_;
}
std::string toString() const;
std::string to_string() const;
friend std::ostream &operator<<(std::ostream &out, const rational &value)
friend std::ostream &operator<<(std::ostream &out, const Rational &value)
{
out << value.num_ << '/' << value.den_;
@@ -149,9 +149,9 @@ private:
int den_;
};
#define RATIONAL_MIN rational(INT_MIN)
#define RATIONAL_MAX rational(INT_MAX)
#define RATIONAL_MIN Rational(INT_MIN)
#define RATIONAL_MAX Rational(INT_MAX)
}
#endif // LIBOLIVECORE_RATIONAL_H
#endif // OAK_LIBOLIVECORE_RATIONAL_H
+2 -2
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SSE2NEON_H
#define SSE2NEON_H
#ifndef OAK_SSE2NEON_H
#define OAK_SSE2NEON_H
// This header file provides a simple API translation layer
// between SSE intrinsics to their corresponding Arm/Aarch64 NEON versions
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_STRINGUTILS_H
#define LIBOLIVECORE_STRINGUTILS_H
#ifndef OAK_LIBOLIVECORE_STRINGUTILS_H
#define OAK_LIBOLIVECORE_STRINGUTILS_H
#include <algorithm>
#include <regex>
@@ -208,4 +208,4 @@ public:
}
#endif // LIBOLIVECORE_STRINGUTILS_H
#endif // OAK_LIBOLIVECORE_STRINGUTILS_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_TESTS_H
#define LIBOLIVECORE_TESTS_H
#ifndef OAK_LIBOLIVECORE_TESTS_H
#define OAK_LIBOLIVECORE_TESTS_H
#include <list>
@@ -59,4 +59,4 @@ private:
}
#endif // LIBOLIVECORE_TESTS_H
#endif // OAK_LIBOLIVECORE_TESTS_H
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_TIMECODEFUNCTIONS_H
#define LIBOLIVECORE_TIMECODEFUNCTIONS_H
#ifndef OAK_LIBOLIVECORE_TIMECODEFUNCTIONS_H
#define OAK_LIBOLIVECORE_TIMECODEFUNCTIONS_H
#include "rational.h"
@@ -34,7 +34,7 @@ namespace olive::core
*
* Olive uses the following terminology through its code:
*
* `time` - time in seconds presented in a rational form
* `time` - time in seconds presented in a Rational form
* `timebase` - the base time unit of an audio/video stream in seconds
* `timestamp` - an integer representation of a time in timebase units (in many cases is used like a frame number)
* `timecode` a user-friendly string representation of a time according to Timecode::Display
@@ -42,52 +42,52 @@ namespace olive::core
class Timecode {
public:
enum Display {
kTimecodeDropFrame,
kTimecodeNonDropFrame,
kTimecodeSeconds,
kFrames,
kMilliseconds
k_timecode_drop_frame,
k_timecode_non_drop_frame,
k_timecode_seconds,
k_frames,
k_milliseconds
};
enum Rounding { kCeil, kFloor, kRound };
enum Rounding { k_ceil, k_floor, k_round };
/**
* @brief Convert a timestamp (according to a rational timebase) to a user-friendly string representation
* @brief Convert a timestamp (according to a Rational timebase) to a user-friendly string representation
*/
static std::string time_to_timecode(const rational &time,
const rational &timebase,
static std::string time_to_timecode(const Rational &time,
const Rational &timebase,
const Display &display,
bool show_plus_if_positive = false);
static rational timecode_to_time(std::string timecode,
const rational &timebase,
static Rational timecode_to_time(std::string timecode,
const Rational &timebase,
const Display &display,
bool *ok = nullptr);
static std::string time_to_string(int64_t ms);
static rational snap_time_to_timebase(const rational &time,
const rational &timebase,
Rounding floor = kRound);
static Rational snap_time_to_timebase(const Rational &time,
const Rational &timebase,
Rounding floor = k_round);
static int64_t time_to_timestamp(const rational &time,
const rational &timebase,
Rounding floor = kRound);
static int64_t time_to_timestamp(const Rational &time,
const Rational &timebase,
Rounding floor = k_round);
static int64_t time_to_timestamp(const double &time,
const rational &timebase,
Rounding floor = kRound);
const Rational &timebase,
Rounding floor = k_round);
static int64_t rescale_timestamp(const int64_t &ts, const rational &source,
const rational &dest);
static int64_t rescale_timestamp(const int64_t &ts, const Rational &source,
const Rational &dest);
static int64_t rescale_timestamp_ceil(const int64_t &ts,
const rational &source,
const rational &dest);
const Rational &source,
const Rational &dest);
static rational timestamp_to_time(const int64_t &timestamp,
const rational &timebase);
static Rational timestamp_to_time(const int64_t &timestamp,
const Rational &timebase);
static bool timebase_is_drop_frame(const rational &timebase);
static bool timebase_is_drop_frame(const Rational &timebase);
};
}
#endif // LIBOLIVECORE_TIMECODEFUNCTIONS_H
#endif // OAK_LIBOLIVECORE_TIMECODEFUNCTIONS_H
+48 -48
View File
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_TIMERANGE_H
#define LIBOLIVECORE_TIMERANGE_H
#ifndef OAK_LIBOLIVECORE_TIMERANGE_H
#define OAK_LIBOLIVECORE_TIMERANGE_H
#include <list>
#include <vector>
@@ -33,7 +33,7 @@ namespace olive::core
class TimeRange {
public:
TimeRange() = default;
TimeRange(const rational &in, const rational &out);
TimeRange(const Rational &in, const Rational &out);
TimeRange(const TimeRange &r)
: TimeRange(r.in(), r.out())
{
@@ -45,42 +45,42 @@ public:
return *this;
}
const rational &in() const;
const rational &out() const;
const rational &length() const;
const Rational &in() const;
const Rational &out() const;
const Rational &length() const;
void set_in(const rational &in);
void set_out(const rational &out);
void set_range(const rational &in, const rational &out);
void set_in(const Rational &in);
void set_out(const Rational &out);
void set_range(const Rational &in, const Rational &out);
bool operator==(const TimeRange &r) const;
bool operator!=(const TimeRange &r) const;
bool OverlapsWith(const TimeRange &a, bool in_inclusive = true,
bool overlaps_with(const TimeRange &a, bool in_inclusive = true,
bool out_inclusive = true) const;
bool Contains(const TimeRange &a, bool in_inclusive = true,
bool contains(const TimeRange &a, bool in_inclusive = true,
bool out_inclusive = true) const;
bool Contains(const rational &r) const;
bool contains(const Rational &r) const;
TimeRange Combined(const TimeRange &a) const;
static TimeRange Combine(const TimeRange &a, const TimeRange &b);
TimeRange Intersected(const TimeRange &a) const;
static TimeRange Intersect(const TimeRange &a, const TimeRange &b);
TimeRange combined(const TimeRange &a) const;
static TimeRange combine(const TimeRange &a, const TimeRange &b);
TimeRange intersected(const TimeRange &a) const;
static TimeRange intersect(const TimeRange &a, const TimeRange &b);
TimeRange operator+(const rational &rhs) const;
TimeRange operator-(const rational &rhs) const;
TimeRange operator+(const Rational &rhs) const;
TimeRange operator-(const Rational &rhs) const;
const TimeRange &operator+=(const rational &rhs);
const TimeRange &operator-=(const rational &rhs);
const TimeRange &operator+=(const Rational &rhs);
const TimeRange &operator-=(const Rational &rhs);
std::list<TimeRange> Split(const int &chunk_size) const;
std::list<TimeRange> split(const int &chunk_size) const;
private:
void normalize();
rational in_;
rational out_;
rational length_;
Rational in_;
Rational out_;
Rational length_;
};
class TimeRangeList {
@@ -106,11 +106,11 @@ public:
for (auto it = list->begin(); it != list->end();) {
T &compare = *it;
if (remove.Contains(compare)) {
if (remove.contains(compare)) {
// This element is entirely encompassed in this range, remove it
it = list->erase(it);
} else {
if (compare.Contains(remove, false, false)) {
if (compare.contains(remove, false, false)) {
// The remove range is within this element, only choice is to split the element into two
T new_range = compare;
new_range.set_in(remove.out());
@@ -140,10 +140,10 @@ public:
bool contains(const TimeRange &range, bool in_inclusive = true,
bool out_inclusive = true) const;
bool contains(const rational &r) const
bool contains(const Rational &r) const
{
for (const TimeRange &range : array_) {
if (range.Contains(r)) {
if (range.contains(r)) {
return true;
}
}
@@ -151,11 +151,11 @@ public:
return false;
}
bool OverlapsWith(const TimeRange &r, bool in_inclusive = true,
bool overlaps_with(const TimeRange &r, bool in_inclusive = true,
bool out_inclusive = true) const
{
for (const TimeRange &range : array_) {
if (range.OverlapsWith(r, in_inclusive, out_inclusive)) {
if (range.overlaps_with(r, in_inclusive, out_inclusive)) {
return true;
}
}
@@ -178,13 +178,13 @@ public:
return array_.size();
}
void shift(const rational &diff);
void shift(const Rational &diff);
void trim_in(const rational &diff);
void trim_in(const Rational &diff);
void trim_out(const rational &diff);
void trim_out(const Rational &diff);
TimeRangeList Intersects(const TimeRange &range) const;
TimeRangeList intersects(const TimeRange &range) const;
using const_iterator = std::vector<TimeRange>::const_iterator;
@@ -241,20 +241,20 @@ class TimeRangeListFrameIterator {
public:
TimeRangeListFrameIterator();
TimeRangeListFrameIterator(const TimeRangeList &list,
const rational &timebase);
const Rational &timebase);
rational Snap(const rational &r) const;
Rational snap(const Rational &r) const;
bool GetNext(rational *out);
bool get_next(Rational *out);
bool HasNext() const;
bool has_next() const;
std::vector<rational> ToVector() const
std::vector<Rational> to_vector() const
{
TimeRangeListFrameIterator copy(list_, timebase_);
std::vector<rational> times;
rational r;
while (copy.GetNext(&r)) {
std::vector<Rational> times;
Rational r;
while (copy.get_next(&r)) {
times.push_back(r);
}
return times;
@@ -277,12 +277,12 @@ public:
list_.insert(list);
}
bool IsCustomRange() const
bool is_custom_range() const
{
return custom_range_;
}
void SetCustomRange(bool e)
void set_custom_range(bool e)
{
custom_range_ = e;
}
@@ -293,13 +293,13 @@ public:
}
private:
void UpdateIndexIfNecessary();
void update_index_if_necessary();
TimeRangeList list_;
rational timebase_;
Rational timebase_;
rational current_;
Rational current_;
int range_index_;
@@ -312,4 +312,4 @@ private:
}
#endif // LIBOLIVECORE_TIMERANGE_H
#endif // OAK_LIBOLIVECORE_TIMERANGE_H
+8 -8
View File
@@ -19,8 +19,8 @@
***/
#ifndef LIBOLIVECORE_VALUE_H
#define LIBOLIVECORE_VALUE_H
#ifndef OAK_LIBOLIVECORE_VALUE_H
#define OAK_LIBOLIVECORE_VALUE_H
#include <map>
#include <stdint.h>
@@ -38,7 +38,7 @@ class Value {
public:
enum Type {
/// Null/no data
NONE,
none,
/// Signed int64
INT,
@@ -47,12 +47,12 @@ public:
FLOAT,
/// UTF-8 string
STRING
string
};
Value()
{
type_ = NONE;
type_ = none;
}
Value(int64_t v)
@@ -74,14 +74,14 @@ public:
size_t sz = strlen(s);
data_.resize(sz);
memcpy(data_.data(), s, sz);
type_ = STRING;
type_ = string;
}
Value(const std::string &s)
{
data_.resize(s.size());
memcpy(data_.data(), s.data(), data_.size());
type_ = STRING;
type_ = string;
}
private:
@@ -93,4 +93,4 @@ using ValueMap = std::map<std::string, Value>;
}
#endif // LIBOLIVECORE_VALUE_H
#endif // OAK_LIBOLIVECORE_VALUE_H
+15 -15
View File
@@ -26,7 +26,7 @@
namespace olive::core
{
const std::vector<int> AudioParams::kSupportedSampleRates = {
const std::vector<int> AudioParams::k_supported_sample_rates = {
8000, // 8000 Hz
11025, // 11025 Hz
16000, // 16000 Hz
@@ -39,9 +39,9 @@ const std::vector<int> AudioParams::kSupportedSampleRates = {
96000 // 96000 Hz
};
const std::vector<uint64_t> AudioParams::kSupportedChannelLayouts = {
kChannelLayoutMono, kChannelLayoutStereo, kChannelLayout2_1,
kChannelLayout5Point1, kChannelLayout7Point1
const std::vector<uint64_t> AudioParams::k_supported_channel_layouts = {
k_channel_layout_mono, k_channel_layout_stereo, k_channel_layout2_1,
k_channel_layout5_point1, k_channel_layout7_point1
};
bool AudioParams::operator==(const AudioParams &other) const
@@ -61,9 +61,9 @@ int64_t AudioParams::time_to_bytes(const double &time) const
return time_to_bytes_per_channel(time) * channel_count();
}
int64_t AudioParams::time_to_bytes(const rational &time) const
int64_t AudioParams::time_to_bytes(const Rational &time) const
{
return time_to_bytes(time.toDouble());
return time_to_bytes(time.to_double());
}
int64_t AudioParams::time_to_bytes_per_channel(const double &time) const
@@ -73,9 +73,9 @@ int64_t AudioParams::time_to_bytes_per_channel(const double &time) const
return int64_t(time_to_samples(time)) * bytes_per_sample_per_channel();
}
int64_t AudioParams::time_to_bytes_per_channel(const rational &time) const
int64_t AudioParams::time_to_bytes_per_channel(const Rational &time) const
{
return time_to_bytes_per_channel(time.toDouble());
return time_to_bytes_per_channel(time.to_double());
}
int64_t AudioParams::time_to_samples(const double &time) const
@@ -85,9 +85,9 @@ int64_t AudioParams::time_to_samples(const double &time) const
return std::round(double(sample_rate()) * time);
}
int64_t AudioParams::time_to_samples(const rational &time) const
int64_t AudioParams::time_to_samples(const Rational &time) const
{
return time_to_samples(time.toDouble());
return time_to_samples(time.to_double());
}
int64_t AudioParams::samples_to_bytes(const int64_t &samples) const
@@ -104,7 +104,7 @@ int64_t AudioParams::samples_to_bytes_per_channel(const int64_t &samples) const
return samples * bytes_per_sample_per_channel();
}
rational AudioParams::samples_to_time(const int64_t &samples) const
Rational AudioParams::samples_to_time(const int64_t &samples) const
{
return sample_rate_as_time_base() * samples;
}
@@ -116,12 +116,12 @@ int64_t AudioParams::bytes_to_samples(const int64_t &bytes) const
return bytes / (channel_count() * bytes_per_sample_per_channel());
}
rational AudioParams::bytes_to_time(const int64_t &bytes) const
Rational AudioParams::bytes_to_time(const int64_t &bytes) const
{
return samples_to_time(bytes_to_samples(bytes));
}
rational AudioParams::bytes_per_channel_to_time(const int64_t &bytes) const
Rational AudioParams::bytes_per_channel_to_time(const int64_t &bytes) const
{
return samples_to_time(bytes_to_samples(bytes * channel_count()));
}
@@ -144,12 +144,12 @@ int AudioParams::bits_per_sample() const
bool AudioParams::is_valid() const
{
return (!time_base().isNull() && channel_layout_mask_ != 0 &&
format_ > SampleFormat::INVALID && format_ < SampleFormat::COUNT);
format_ > SampleFormat::invalid && format_ < SampleFormat::count);
}
void AudioParams::calculate_channel_count()
{
channel_count_ = ChannelLayoutMaskChannelCount(channel_layout_mask_);
channel_count_ = channel_layout_mask_channel_count(channel_layout_mask_);
}
}
+11 -11
View File
@@ -38,7 +38,7 @@ SampleBuffer::SampleBuffer()
}
SampleBuffer::SampleBuffer(const AudioParams &audio_params,
const rational &length)
const Rational &length)
: audio_params_(audio_params)
{
sample_count_per_channel_ = audio_params_.time_to_samples(length);
@@ -56,7 +56,7 @@ SampleBuffer::SampleBuffer(const AudioParams &audio_params,
SampleBuffer SampleBuffer::rip_channel(int channel) const
{
AudioParams p = this->audio_params_;
p.set_channel_layout(kChannelLayoutMono);
p.set_channel_layout(k_channel_layout_mono);
SampleBuffer b(p, this->sample_count_per_channel_);
b.fast_set(*this, 0, channel);
@@ -76,7 +76,7 @@ const AudioParams &SampleBuffer::audio_params() const
void SampleBuffer::set_audio_params(const AudioParams &params)
{
if (is_allocated()) {
Log::Warning() << "Tried to set parameters on allocated sample buffer";
Log::warning() << "Tried to set parameters on allocated sample buffer";
return;
}
@@ -86,7 +86,7 @@ void SampleBuffer::set_audio_params(const AudioParams &params)
void SampleBuffer::set_sample_count(const size_t &sample_count)
{
if (is_allocated()) {
Log::Warning()
Log::warning()
<< "Tried to set sample count on allocated sample buffer";
return;
}
@@ -97,19 +97,19 @@ void SampleBuffer::set_sample_count(const size_t &sample_count)
void SampleBuffer::allocate()
{
if (!audio_params_.is_valid()) {
Log::Warning()
Log::warning()
<< "Tried to allocate sample buffer with invalid audio parameters";
return;
}
if (!sample_count_per_channel_) {
Log::Warning()
Log::warning()
<< "Tried to allocate sample buffer with zero sample count";
return;
}
if (is_allocated()) {
Log::Warning() << "Tried to allocate already allocated sample buffer";
Log::warning() << "Tried to allocate already allocated sample buffer";
return;
}
@@ -127,7 +127,7 @@ void SampleBuffer::destroy()
void SampleBuffer::reverse()
{
if (!is_allocated()) {
Log::Warning() << "Tried to reverse an unallocated sample buffer";
Log::warning() << "Tried to reverse an unallocated sample buffer";
return;
}
@@ -145,7 +145,7 @@ void SampleBuffer::reverse()
void SampleBuffer::speed(double speed)
{
if (!is_allocated()) {
Log::Warning() << "Tried to speed an unallocated sample buffer";
Log::warning() << "Tried to speed an unallocated sample buffer";
return;
}
@@ -256,7 +256,7 @@ void SampleBuffer::silence(size_t start_sample, size_t end_sample)
void SampleBuffer::silence_bytes(size_t start_byte, size_t end_byte)
{
if (!is_allocated()) {
Log::Warning() << "Tried to fill an unallocated sample buffer";
Log::warning() << "Tried to fill an unallocated sample buffer";
return;
}
@@ -270,7 +270,7 @@ void SampleBuffer::set(int channel, const float *data, size_t sample_offset,
size_t sample_length)
{
if (!is_allocated()) {
Log::Warning() << "Tried to fill an unallocated sample buffer";
Log::warning() << "Tried to fill an unallocated sample buffer";
return;
}
+9 -9
View File
@@ -57,35 +57,35 @@ Bezier::Bezier(double x, double y, double cp1_x, double cp1_y, double cp2_x,
{
}
double Bezier::QuadraticXtoT(double x, double a, double b, double c)
double Bezier::quadratic_xto_t(double x, double a, double b, double c)
{
// Clamp to prevent infinite loop
x = std::clamp(x, a, c);
return CalculateTFromX(false, x, a, b, c, 0);
return calculate_t_from_x(false, x, a, b, c, 0);
}
double Bezier::QuadraticTtoY(double a, double b, double c, double t)
double Bezier::quadratic_tto_y(double a, double b, double c, double t)
{
return std::pow(1.0 - t, 2) * a + 2 * (1.0 - t) * t * b +
std::pow(t, 2) * c;
}
double Bezier::CubicXtoT(double x, double a, double b, double c, double d)
double Bezier::cubic_xto_t(double x, double a, double b, double c, double d)
{
// Clamp to prevent infinite loop
x = std::clamp(x, a, d);
return CalculateTFromX(true, x, a, b, c, d);
return calculate_t_from_x(true, x, a, b, c, d);
}
double Bezier::CubicTtoY(double a, double b, double c, double d, double t)
double Bezier::cubic_tto_y(double a, double b, double c, double d, double t)
{
return std::pow(1.0 - t, 3) * a + 3 * std::pow(1.0 - t, 2) * t * b +
3 * (1.0 - t) * std::pow(t, 2) * c + std::pow(t, 3) * d;
}
double Bezier::CalculateTFromX(bool cubic, double x, double a, double b,
double Bezier::calculate_t_from_x(bool cubic, double x, double a, double b,
double c, double d)
{
double bottom = 0.0;
@@ -97,8 +97,8 @@ double Bezier::CalculateTFromX(bool cubic, double x, double a, double b,
}
double mid = (bottom + top) * 0.5;
double test = cubic ? CubicTtoY(a, b, c, d, mid) :
QuadraticTtoY(a, b, c, mid);
double test = cubic ? cubic_tto_y(a, b, c, d, mid) :
quadratic_tto_y(a, b, c, mid);
if (std::abs(test - x) < 0.000001) {
return mid;
+86 -86
View File
@@ -30,73 +30,73 @@
namespace olive::core
{
Color Color::fromHsv(const DataType &h, const DataType &s, const DataType &v)
Color Color::from_hsv(const DataType &h, const DataType &s, const DataType &v)
{
DataType C = s * v;
DataType X = C * (1.0 - std::abs(std::fmod(h / 60.0, 2.0) - 1.0));
DataType m = v - C;
DataType Rs, Gs, Bs;
DataType c = s * v;
DataType x = c * (1.0 - std::abs(std::fmod(h / 60.0, 2.0) - 1.0));
DataType m = v - c;
DataType rs, gs, bs;
if (h >= 0.0 && h < 60.0) {
Rs = C;
Gs = X;
Bs = 0.0;
rs = c;
gs = x;
bs = 0.0;
} else if (h >= 60.0 && h < 120.0) {
Rs = X;
Gs = C;
Bs = 0.0;
rs = x;
gs = c;
bs = 0.0;
} else if (h >= 120.0 && h < 180.0) {
Rs = 0.0;
Gs = C;
Bs = X;
rs = 0.0;
gs = c;
bs = x;
} else if (h >= 180.0 && h < 240.0) {
Rs = 0.0;
Gs = X;
Bs = C;
rs = 0.0;
gs = x;
bs = c;
} else if (h >= 240.0 && h < 300.0) {
Rs = X;
Gs = 0.0;
Bs = C;
rs = x;
gs = 0.0;
bs = c;
} else {
Rs = C;
Gs = 0.0;
Bs = X;
rs = c;
gs = 0.0;
bs = x;
}
return Color(Rs + m, Gs + m, Bs + m);
return Color(rs + m, gs + m, bs + m);
}
Color::Color(const char *data, const PixelFormat &format, int ch_layout)
{
*this = fromData(data, format, ch_layout);
*this = from_data(data, format, ch_layout);
}
void Color::toHsv(DataType *hue, DataType *sat, DataType *val) const
void Color::to_hsv(DataType *hue, DataType *sat, DataType *val) const
{
DataType fCMax = std::max(std::max(red(), green()), blue());
DataType fCMin = std::min(std::min(red(), green()), blue());
DataType fDelta = fCMax - fCMin;
DataType f_c_max = std::max(std::max(red(), green()), blue());
DataType f_c_min = std::min(std::min(red(), green()), blue());
DataType f_delta = f_c_max - f_c_min;
if (fDelta > 0) {
if (fCMax == red()) {
*hue = 60 * (fmod(((green() - blue()) / fDelta), 6));
} else if (fCMax == green()) {
*hue = 60 * (((blue() - red()) / fDelta) + 2);
} else if (fCMax == blue()) {
*hue = 60 * (((red() - green()) / fDelta) + 4);
if (f_delta > 0) {
if (f_c_max == red()) {
*hue = 60 * (fmod(((green() - blue()) / f_delta), 6));
} else if (f_c_max == green()) {
*hue = 60 * (((blue() - red()) / f_delta) + 2);
} else if (f_c_max == blue()) {
*hue = 60 * (((red() - green()) / f_delta) + 4);
}
if (fCMax > 0) {
*sat = fDelta / fCMax;
if (f_c_max > 0) {
*sat = f_delta / f_c_max;
} else {
*sat = 0;
}
*val = fCMax;
*val = f_c_max;
} else {
*hue = 0;
*sat = 0;
*val = fCMax;
*val = f_c_max;
}
if (*hue < 0) {
@@ -107,50 +107,50 @@ void Color::toHsv(DataType *hue, DataType *sat, DataType *val) const
Color::DataType Color::hsv_hue() const
{
DataType h, s, v;
toHsv(&h, &s, &v);
to_hsv(&h, &s, &v);
return h;
}
Color::DataType Color::hsv_saturation() const
{
DataType h, s, v;
toHsv(&h, &s, &v);
to_hsv(&h, &s, &v);
return s;
}
Color::DataType Color::value() const
{
DataType h, s, v;
toHsv(&h, &s, &v);
to_hsv(&h, &s, &v);
return v;
}
void Color::toHsl(DataType *hue, DataType *sat, DataType *lightness) const
void Color::to_hsl(DataType *hue, DataType *sat, DataType *lightness) const
{
DataType fCMin = std::min(red(), std::min(green(), blue()));
DataType fCMax = std::max(red(), std::max(green(), blue()));
DataType f_c_min = std::min(red(), std::min(green(), blue()));
DataType f_c_max = std::max(red(), std::max(green(), blue()));
*lightness = 0.5 * (fCMin + fCMax);
*lightness = 0.5 * (f_c_min + f_c_max);
if (fCMin == fCMax) {
if (f_c_min == f_c_max) {
*sat = 0;
*hue = 0;
return;
} else if (*lightness < 0.5) {
*sat = (fCMax - fCMin) / (fCMax + fCMin);
*sat = (f_c_max - f_c_min) / (f_c_max + f_c_min);
} else {
*sat = (fCMax - fCMin) / (2.0 - fCMax - fCMin);
*sat = (f_c_max - f_c_min) / (2.0 - f_c_max - f_c_min);
}
if (fCMax == red()) {
*hue = 60 * (green() - blue()) / (fCMax - fCMin);
if (f_c_max == red()) {
*hue = 60 * (green() - blue()) / (f_c_max - f_c_min);
}
if (fCMax == green()) {
*hue = 60 * (blue() - red()) / (fCMax - fCMin) + 120;
if (f_c_max == green()) {
*hue = 60 * (blue() - red()) / (f_c_max - f_c_min) + 120;
}
if (fCMax == blue()) {
*hue = 60 * (red() - green()) / (fCMax - fCMin) + 240;
if (f_c_max == blue()) {
*hue = 60 * (red() - green()) / (f_c_max - f_c_min) + 240;
}
if (*hue < 0) {
*hue = *hue + 360;
@@ -160,30 +160,30 @@ void Color::toHsl(DataType *hue, DataType *sat, DataType *lightness) const
Color::DataType Color::hsl_hue() const
{
DataType h, s, l;
toHsl(&h, &s, &l);
to_hsl(&h, &s, &l);
return h;
}
Color::DataType Color::hsl_saturation() const
{
DataType h, s, l;
toHsl(&h, &s, &l);
to_hsl(&h, &s, &l);
return s;
}
Color::DataType Color::lightness() const
{
DataType h, s, l;
toHsl(&h, &s, &l);
to_hsl(&h, &s, &l);
return l;
}
void Color::toData(char *out, const PixelFormat &format,
void Color::to_data(char *out, const PixelFormat &format,
unsigned int nb_channels) const
{
unsigned int count = std::min(RGBA, nb_channels);
unsigned int count = std::min(rgba, nb_channels);
if (format == PixelFormat::U10 && count == 4) {
if (format == PixelFormat::u10 && count == 4) {
const uint32_t r = static_cast<uint32_t>(std::clamp(data_[0], DataType(0.0), DataType(1.0)) * 1023.0 + 0.5);
const uint32_t g = static_cast<uint32_t>(std::clamp(data_[1], DataType(0.0), DataType(1.0)) * 1023.0 + 0.5);
const uint32_t b = static_cast<uint32_t>(std::clamp(data_[2], DataType(0.0), DataType(1.0)) * 1023.0 + 0.5);
@@ -196,36 +196,36 @@ void Color::toData(char *out, const PixelFormat &format,
DataType f = data_[i];
switch (format) {
case PixelFormat::INVALID:
case PixelFormat::COUNT:
case PixelFormat::invalid:
case PixelFormat::count:
break;
case PixelFormat::U8:
case PixelFormat::u8:
reinterpret_cast<uint8_t *>(out)[i] = f * 255.0;
break;
case PixelFormat::U10:
case PixelFormat::u10:
// handled above
break;
case PixelFormat::U16:
case PixelFormat::u16:
reinterpret_cast<uint16_t *>(out)[i] = f * 65535.0;
break;
case PixelFormat::F16:
case PixelFormat::f16:
reinterpret_cast<Imath::half *>(out)[i] = f;
break;
case PixelFormat::F32:
case PixelFormat::f32:
reinterpret_cast<float *>(out)[i] = f;
break;
}
}
}
Color Color::fromData(const char *in, const PixelFormat &format,
Color Color::from_data(const char *in, const PixelFormat &format,
unsigned int nb_channels)
{
Color c;
unsigned int count = std::min(RGBA, nb_channels);
unsigned int count = std::min(rgba, nb_channels);
if (format == PixelFormat::U10 && count == 4) {
if (format == PixelFormat::u10 && count == 4) {
const uint32_t word = reinterpret_cast<const uint32_t *>(in)[0];
c.data_[0] = DataType((word & 0x3ff) / 1023.0);
c.data_[1] = DataType(((word >> 10) & 0x3ff) / 1023.0);
@@ -238,22 +238,22 @@ Color Color::fromData(const char *in, const PixelFormat &format,
DataType &f = c.data_[i];
switch (format) {
case PixelFormat::INVALID:
case PixelFormat::COUNT:
case PixelFormat::invalid:
case PixelFormat::count:
break;
case PixelFormat::U8:
case PixelFormat::u8:
f = DataType(reinterpret_cast<const uint8_t *>(in)[i]) / 255.0;
break;
case PixelFormat::U10:
case PixelFormat::u10:
// handled above
break;
case PixelFormat::U16:
case PixelFormat::u16:
f = DataType(reinterpret_cast<const uint16_t *>(in)[i]) / 65535.0;
break;
case PixelFormat::F16:
case PixelFormat::f16:
f = DataType(reinterpret_cast<const Imath::half *>(in)[i]);
break;
case PixelFormat::F32:
case PixelFormat::f32:
f = DataType(reinterpret_cast<const float *>(in)[i]);
break;
}
@@ -262,14 +262,14 @@ Color Color::fromData(const char *in, const PixelFormat &format,
return c;
}
Color::DataType Color::GetRoughLuminance() const
Color::DataType Color::get_rough_luminance() const
{
return (2 * red() + blue() + 3 * green()) / 6.0;
}
Color &Color::operator+=(const Color &rhs)
{
for (int i = 0; i < RGBA; i++) {
for (int i = 0; i < rgba; i++) {
data_[i] += rhs.data_[i];
}
@@ -278,7 +278,7 @@ Color &Color::operator+=(const Color &rhs)
Color &Color::operator-=(const Color &rhs)
{
for (int i = 0; i < RGBA; i++) {
for (int i = 0; i < rgba; i++) {
data_[i] -= rhs.data_[i];
}
@@ -287,7 +287,7 @@ Color &Color::operator-=(const Color &rhs)
Color &Color::operator+=(const DataType &rhs)
{
for (int i = 0; i < RGBA; i++) {
for (int i = 0; i < rgba; i++) {
data_[i] += rhs;
}
@@ -296,7 +296,7 @@ Color &Color::operator+=(const DataType &rhs)
Color &Color::operator-=(const DataType &rhs)
{
for (int i = 0; i < RGBA; i++) {
for (int i = 0; i < rgba; i++) {
data_[i] -= rhs;
}
@@ -305,7 +305,7 @@ Color &Color::operator-=(const DataType &rhs)
Color &Color::operator*=(const DataType &rhs)
{
for (int i = 0; i < RGBA; i++) {
for (int i = 0; i < rgba; i++) {
data_[i] *= rhs;
}
@@ -314,7 +314,7 @@ Color &Color::operator*=(const DataType &rhs)
Color &Color::operator/=(const DataType &rhs)
{
for (int i = 0; i < RGBA; i++) {
for (int i = 0; i < rgba; i++) {
data_[i] /= rhs;
}
+4 -4
View File
@@ -53,7 +53,7 @@ int64_t i64_gcd(int64_t a, int64_t b)
} // namespace
void ReduceFraction(int64_t &num, int64_t &den, int64_t max)
void reduce_fraction(int64_t &num, int64_t &den, int64_t max)
{
if (den == 0) {
num = 0;
@@ -110,7 +110,7 @@ void ReduceFraction(int64_t &num, int64_t &den, int64_t max)
den = a1d;
}
int CompareFractions(int an, int ad, int bn, int bd)
int compare_fractions(int an, int ad, int bn, int bd)
{
const int64_t tmp = an * int64_t(bd) - bn * int64_t(ad);
@@ -125,7 +125,7 @@ int CompareFractions(int an, int ad, int bn, int bd)
return INT_MIN;
}
int64_t RescaleRnd(int64_t a, int64_t b, int64_t c, FractionRounding rnd)
int64_t rescale_rnd(int64_t a, int64_t b, int64_t c, FractionRounding rnd)
{
// Normalize so that the divisor is positive; the sign is carried by the
// dividend instead.
@@ -142,7 +142,7 @@ int64_t RescaleRnd(int64_t a, int64_t b, int64_t c, FractionRounding rnd)
unsigned __int128 uc = static_cast<unsigned __int128>(c);
unsigned __int128 q;
if (rnd == FractionRounding::kNearInf) {
if (rnd == FractionRounding::k_near_inf) {
// Round to nearest, ties away from zero
q = (ur + uc / 2) / uc;
} else {
+61 -61
View File
@@ -34,23 +34,23 @@
namespace olive::core
{
const rational rational::NaN = rational(0, 0);
const Rational Rational::na_n = Rational(0, 0);
rational rational::fromDouble(const double &flt, bool *ok)
Rational Rational::from_double(const double &flt, bool *ok)
{
if (isnan(flt)) {
// Return NaN rational
// Return NaN Rational
if (ok)
*ok = false;
return NaN;
return na_n;
}
if (fabs(flt) > double(INT_MAX) + 3.0) {
// Value is out of range for a rational, return NaN
// Value is out of range for a Rational, return NaN
if (ok) {
*ok = false;
}
return NaN;
return na_n;
}
// Continued fraction conversion (ported from FFmpeg's av_d2q)
@@ -61,53 +61,53 @@ rational rational::fromDouble(const double &flt, bool *ok)
int64_t num = int64_t(floor(flt * den + 0.5));
int64_t rnum = num, rden = den;
ReduceFraction(rnum, rden, INT_MAX);
reduce_fraction(rnum, rden, INT_MAX);
if ((!rnum || !rden) && flt) {
// Value was too small to represent above, retry with maximum precision
rnum = int64_t(flt * double(INT64_MAX));
rden = INT64_MAX;
ReduceFraction(rnum, rden, INT_MAX);
reduce_fraction(rnum, rden, INT_MAX);
}
if (rden == 0) {
// If den == 0, we were unable to convert to a rational
// If den == 0, we were unable to convert to a Rational
if (ok) {
*ok = false;
}
return NaN;
return na_n;
}
// Otherwise, assume we received a real rational
// Otherwise, assume we received a real Rational
if (ok) {
*ok = true;
}
return rational(int(rnum), int(rden));
return Rational(int(rnum), int(rden));
}
rational rational::fromString(const std::string &str, bool *ok)
Rational Rational::from_string(const std::string &str, bool *ok)
{
std::vector<std::string> elements = StringUtils::split(str, '/');
switch (elements.size()) {
case 1:
return rational(StringUtils::to_int(elements.front(), ok));
return Rational(StringUtils::to_int(elements.front(), ok));
case 2:
return rational(StringUtils::to_int(elements.at(0), ok),
return Rational(StringUtils::to_int(elements.at(0), ok),
StringUtils::to_int(elements.at(1), ok));
default:
// Returns NaN with ok set to false
if (ok) {
*ok = false;
}
return NaN;
return na_n;
}
}
//Function: convert to double
double rational::toDouble() const
double Rational::to_double() const
{
if (den_ != 0) {
return double(num_) / double(den_);
@@ -117,7 +117,7 @@ double rational::toDouble() const
}
#ifdef USE_OTIO
opentime::RationalTime rational::toRationalTime(double framerate) const
opentime::RationalTime Rational::toRationalTime(double framerate) const
{
// Is this the best way of doing this?
// Olive can store rationals as 0/0 which causes errors in OTIO
@@ -127,14 +127,14 @@ opentime::RationalTime rational::toRationalTime(double framerate) const
}
#endif
rational rational::flipped() const
Rational Rational::flipped() const
{
rational r = *this;
Rational r = *this;
r.flip();
return r;
}
void rational::flip()
void Rational::flip()
{
if (!isNull()) {
std::swap(den_, num_);
@@ -142,12 +142,12 @@ void rational::flip()
}
}
std::string rational::toString() const
std::string Rational::to_string() const
{
return StringUtils::format("%d/%d", num_, den_);
}
void rational::fix_signs()
void Rational::fix_signs()
{
if (den_ < 0) {
// Normalize so that denominator is always positive
@@ -162,35 +162,35 @@ void rational::fix_signs()
}
}
void rational::reduce()
void Rational::reduce()
{
int64_t n = num_, d = den_;
ReduceFraction(n, d, INT_MAX);
reduce_fraction(n, d, INT_MAX);
num_ = int(n);
den_ = int(d);
}
//Assignment Operators
const rational &rational::operator=(const rational &rhs)
const Rational &Rational::operator=(const Rational &rhs)
{
num_ = rhs.num_;
den_ = rhs.den_;
return *this;
}
const rational &rational::operator+=(const rational &rhs)
const Rational &Rational::operator+=(const Rational &rhs)
{
if (*this == RATIONAL_MIN || *this == RATIONAL_MAX || rhs == RATIONAL_MIN ||
rhs == RATIONAL_MAX) {
*this = NaN;
*this = na_n;
} else if (!isNaN()) {
if (rhs.isNaN()) {
*this = NaN;
*this = na_n;
} else {
int64_t n = num_ * int64_t(rhs.den_) + rhs.num_ * int64_t(den_);
int64_t d = den_ * int64_t(rhs.den_);
ReduceFraction(n, d, INT_MAX);
reduce_fraction(n, d, INT_MAX);
num_ = int(n);
den_ = int(d);
fix_signs();
@@ -200,18 +200,18 @@ const rational &rational::operator+=(const rational &rhs)
return *this;
}
const rational &rational::operator-=(const rational &rhs)
const Rational &Rational::operator-=(const Rational &rhs)
{
if (*this == RATIONAL_MIN || *this == RATIONAL_MAX || rhs == RATIONAL_MIN ||
rhs == RATIONAL_MAX) {
*this = NaN;
*this = na_n;
} else if (!isNaN()) {
if (rhs.isNaN()) {
*this = NaN;
*this = na_n;
} else {
int64_t n = num_ * int64_t(rhs.den_) - rhs.num_ * int64_t(den_);
int64_t d = den_ * int64_t(rhs.den_);
ReduceFraction(n, d, INT_MAX);
reduce_fraction(n, d, INT_MAX);
num_ = int(n);
den_ = int(d);
fix_signs();
@@ -221,18 +221,18 @@ const rational &rational::operator-=(const rational &rhs)
return *this;
}
const rational &rational::operator*=(const rational &rhs)
const Rational &Rational::operator*=(const Rational &rhs)
{
if (*this == RATIONAL_MIN || *this == RATIONAL_MAX || rhs == RATIONAL_MIN ||
rhs == RATIONAL_MAX) {
*this = NaN;
*this = na_n;
} else if (!isNaN()) {
if (rhs.isNaN()) {
*this = NaN;
*this = na_n;
} else {
int64_t n = num_ * int64_t(rhs.num_);
int64_t d = den_ * int64_t(rhs.den_);
ReduceFraction(n, d, INT_MAX);
reduce_fraction(n, d, INT_MAX);
num_ = int(n);
den_ = int(d);
fix_signs();
@@ -242,18 +242,18 @@ const rational &rational::operator*=(const rational &rhs)
return *this;
}
const rational &rational::operator/=(const rational &rhs)
const Rational &Rational::operator/=(const Rational &rhs)
{
if (*this == RATIONAL_MIN || *this == RATIONAL_MAX || rhs == RATIONAL_MIN ||
rhs == RATIONAL_MAX) {
*this = NaN;
*this = na_n;
} else if (!isNaN()) {
if (rhs.isNaN()) {
*this = NaN;
*this = na_n;
} else {
int64_t n = num_ * int64_t(rhs.den_);
int64_t d = den_ * int64_t(rhs.num_);
ReduceFraction(n, d, INT_MAX);
reduce_fraction(n, d, INT_MAX);
num_ = int(n);
den_ = int(d);
fix_signs();
@@ -265,64 +265,64 @@ const rational &rational::operator/=(const rational &rhs)
//Binary math operators
rational rational::operator+(const rational &rhs) const
Rational Rational::operator+(const Rational &rhs) const
{
rational answer(*this);
Rational answer(*this);
answer += rhs;
return answer;
}
rational rational::operator-(const rational &rhs) const
Rational Rational::operator-(const Rational &rhs) const
{
rational answer(*this);
Rational answer(*this);
answer -= rhs;
return answer;
}
rational rational::operator/(const rational &rhs) const
Rational Rational::operator/(const Rational &rhs) const
{
rational answer(*this);
Rational answer(*this);
answer /= rhs;
return answer;
}
rational rational::operator*(const rational &rhs) const
Rational Rational::operator*(const Rational &rhs) const
{
rational answer(*this);
Rational answer(*this);
answer *= rhs;
return answer;
}
//Relational and equality operators
bool rational::operator<(const rational &rhs) const
bool Rational::operator<(const Rational &rhs) const
{
return CompareFractions(num_, den_, rhs.num_, rhs.den_) == -1;
return compare_fractions(num_, den_, rhs.num_, rhs.den_) == -1;
}
bool rational::operator<=(const rational &rhs) const
bool Rational::operator<=(const Rational &rhs) const
{
int cmp = CompareFractions(num_, den_, rhs.num_, rhs.den_);
int cmp = compare_fractions(num_, den_, rhs.num_, rhs.den_);
return cmp == 0 || cmp == -1;
}
bool rational::operator>(const rational &rhs) const
bool Rational::operator>(const Rational &rhs) const
{
return CompareFractions(num_, den_, rhs.num_, rhs.den_) == 1;
return compare_fractions(num_, den_, rhs.num_, rhs.den_) == 1;
}
bool rational::operator>=(const rational &rhs) const
bool Rational::operator>=(const Rational &rhs) const
{
int cmp = CompareFractions(num_, den_, rhs.num_, rhs.den_);
int cmp = compare_fractions(num_, den_, rhs.num_, rhs.den_);
return cmp == 0 || cmp == 1;
}
bool rational::operator==(const rational &rhs) const
bool Rational::operator==(const Rational &rhs) const
{
return CompareFractions(num_, den_, rhs.num_, rhs.den_) == 0;
return compare_fractions(num_, den_, rhs.num_, rhs.den_) == 0;
}
bool rational::operator!=(const rational &rhs) const
bool Rational::operator!=(const Rational &rhs) const
{
return !(*this == rhs);
}
+75 -75
View File
@@ -30,21 +30,21 @@
namespace olive::core
{
std::string Timecode::time_to_timecode(const rational &time,
const rational &timebase,
std::string Timecode::time_to_timecode(const Rational &time,
const Rational &timebase,
const Timecode::Display &display,
bool show_plus_if_positive)
{
if (timebase.isNull() || timebase.flipped().toDouble() < 1) {
if (timebase.isNull() || timebase.flipped().to_double() < 1) {
return "INVALID TIMEBASE";
}
double time_dbl = time.toDouble();
double time_dbl = time.to_double();
switch (display) {
case kTimecodeNonDropFrame:
case kTimecodeDropFrame:
case kTimecodeSeconds: {
case k_timecode_non_drop_frame:
case k_timecode_drop_frame:
case k_timecode_seconds: {
const char *prefix = "";
if (time_dbl < 0) {
@@ -53,7 +53,7 @@ std::string Timecode::time_to_timecode(const rational &time,
prefix = "+";
}
if (display == kTimecodeSeconds) {
if (display == k_timecode_seconds) {
time_dbl = std::abs(time_dbl);
int64_t total_seconds = std::floor(time_dbl);
@@ -73,12 +73,12 @@ std::string Timecode::time_to_timecode(const rational &time,
} else {
// Determine what symbol to separate frames (";" is used for drop frame, ":" is non-drop frame)
const char *frame_token;
double frame_rate = timebase.flipped().toDouble();
double frame_rate = timebase.flipped().to_double();
int rounded_frame_rate = std::llround(frame_rate);
int64_t frames, secs, mins, hours;
int64_t f = std::abs(time_to_timestamp(time, timebase));
if (display == kTimecodeDropFrame &&
if (display == k_timecode_drop_frame &&
timebase_is_drop_frame(timebase)) {
frame_token = ";";
@@ -94,19 +94,19 @@ std::string Timecode::time_to_timecode(const rational &time,
f %= (std::llround(frame_rate * 3600) * 24);
// Number of frames per ten minutes
int64_t framesPer10Minutes = std::llround(frame_rate * 600);
int64_t d = f / framesPer10Minutes;
int64_t m = f % framesPer10Minutes;
int64_t frames_per10_minutes = std::llround(frame_rate * 600);
int64_t d = f / frames_per10_minutes;
int64_t m = f % frames_per10_minutes;
// Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate
int64_t dropFrames = std::llround(frame_rate * (2.0 / 30.0));
int64_t drop_frames = std::llround(frame_rate * (2.0 / 30.0));
// Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames
f += dropFrames * 9 * d;
if (m > dropFrames) {
f += dropFrames *
((m - dropFrames) /
(std::llround(frame_rate) * 60 - dropFrames));
f += drop_frames * 9 * d;
if (m > drop_frames) {
f += drop_frames *
((m - drop_frames) /
(std::llround(frame_rate) * 60 - drop_frames));
}
} else {
frame_token = ":";
@@ -126,16 +126,16 @@ std::string Timecode::time_to_timecode(const rational &time,
StringUtils::to_string_leftpad(frames, 2).c_str());
}
}
case kFrames:
case k_frames:
return std::to_string(time_to_timestamp(time, timebase));
case kMilliseconds:
case k_milliseconds:
return std::to_string(std::llround(time_dbl * 1000));
}
return "INVALID TIMECODE MODE";
}
int64_t StrToInt64EmptyTolerant(const std::string &s, bool *ok)
int64_t str_to_int64_empty_tolerant(const std::string &s, bool *ok)
{
if (s.empty()) {
if (ok)
@@ -155,7 +155,7 @@ int64_t StrToInt64EmptyTolerant(const std::string &s, bool *ok)
}
}
double StrToDoubleEmptyTolerant(const std::string &s, bool *ok)
double str_to_double_empty_tolerant(const std::string &s, bool *ok)
{
if (s.empty()) {
if (ok)
@@ -175,8 +175,8 @@ double StrToDoubleEmptyTolerant(const std::string &s, bool *ok)
}
}
rational Timecode::timecode_to_time(std::string timecode,
const rational &timebase,
Rational Timecode::timecode_to_time(std::string timecode,
const Rational &timebase,
const Timecode::Display &display, bool *ok)
{
StringUtils::trim(timecode);
@@ -185,13 +185,13 @@ rational Timecode::timecode_to_time(std::string timecode,
}
switch (display) {
case kTimecodeNonDropFrame:
case kTimecodeDropFrame:
case kTimecodeSeconds: {
case k_timecode_non_drop_frame:
case k_timecode_drop_frame:
case k_timecode_seconds: {
std::vector<std::string> timecode_split =
StringUtils::split_regex(timecode, std::regex("(:)|(;)"));
const int element_count = display == kTimecodeSeconds ? 3 : 4;
const int element_count = display == k_timecode_seconds ? 3 : 4;
// Remove excess tokens (we're only interested in HH:MM:SS.FF)
if (timecode_split.size() > element_count) {
@@ -207,60 +207,60 @@ rational Timecode::timecode_to_time(std::string timecode,
bool negative = (timecode.at(0) == '-');
double frame_rate = timebase.flipped().toDouble();
double frame_rate = timebase.flipped().to_double();
int rounded_frame_rate = std::lround(frame_rate);
bool valid;
rational time;
Rational time;
int64_t hours = StrToInt64EmptyTolerant(timecode_split.at(0), &valid);
int64_t hours = str_to_int64_empty_tolerant(timecode_split.at(0), &valid);
if (!valid)
goto err_fatal;
int64_t mins = StrToInt64EmptyTolerant(timecode_split.at(1), &valid);
int64_t mins = str_to_int64_empty_tolerant(timecode_split.at(1), &valid);
if (!valid)
goto err_fatal;
if (display == kTimecodeSeconds) {
if (display == k_timecode_seconds) {
double secs =
StrToDoubleEmptyTolerant(timecode_split.at(2), &valid);
str_to_double_empty_tolerant(timecode_split.at(2), &valid);
if (!valid)
goto err_fatal;
time = rational::fromDouble(hours * 3600 + mins * 60 + secs);
time = Rational::from_double(hours * 3600 + mins * 60 + secs);
} else {
int64_t secs =
StrToInt64EmptyTolerant(timecode_split.at(2), &valid);
str_to_int64_empty_tolerant(timecode_split.at(2), &valid);
if (!valid)
goto err_fatal;
int64_t frames =
StrToInt64EmptyTolerant(timecode_split.at(3), &valid);
str_to_int64_empty_tolerant(timecode_split.at(3), &valid);
if (!valid)
goto err_fatal;
int64_t sec_count = (hours * 3600 + mins * 60 + secs);
int64_t frame_count = sec_count * rounded_frame_rate + frames;
if (display == kTimecodeDropFrame &&
if (display == k_timecode_drop_frame &&
timebase_is_drop_frame(timebase)) {
// Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate
int64_t dropFrames = std::llround(frame_rate * (2.0 / 30.0));
int64_t drop_frames = std::llround(frame_rate * (2.0 / 30.0));
// d and m need to be calculated from
int64_t real_fr_ts =
std::llround(static_cast<double>(sec_count) * frame_rate) +
frames;
int64_t framesPer10Minutes = std::llround(frame_rate * 600);
int64_t d = real_fr_ts / framesPer10Minutes;
int64_t m = real_fr_ts % framesPer10Minutes;
int64_t frames_per10_minutes = std::llround(frame_rate * 600);
int64_t d = real_fr_ts / frames_per10_minutes;
int64_t m = real_fr_ts % frames_per10_minutes;
if (m > dropFrames) {
if (m > drop_frames) {
frame_count -=
dropFrames *
((m - dropFrames) /
(std::llround(frame_rate) * 60 - dropFrames));
drop_frames *
((m - drop_frames) /
(std::llround(frame_rate) * 60 - drop_frames));
}
frame_count -= dropFrames * 9 * d;
frame_count -= drop_frames * 9 * d;
}
time = timestamp_to_time(frame_count, timebase);
@@ -274,20 +274,20 @@ rational Timecode::timecode_to_time(std::string timecode,
return time;
}
case kMilliseconds: {
case k_milliseconds: {
try {
double timecode_secs = std::stod(timecode);
// Convert milliseconds to seconds
timecode_secs *= 0.001;
// Convert seconds to rational
return rational::fromDouble(timecode_secs, ok);
// Convert seconds to Rational
return Rational::from_double(timecode_secs, ok);
} catch (const std::invalid_argument &e) {
goto err_fatal;
}
}
case kFrames: {
case k_frames: {
try {
int64_t ts = std::stoll(timecode);
if (ok)
@@ -318,8 +318,8 @@ std::string Timecode::time_to_string(int64_t ms)
StringUtils::to_string_leftpad(ss, 2).c_str());
}
rational Timecode::snap_time_to_timebase(const rational &time,
const rational &timebase,
Rational Timecode::snap_time_to_timebase(const Rational &time,
const Rational &timebase,
Rounding floor)
{
// Just convert to a timestamp in timebase units and back
@@ -328,32 +328,32 @@ rational Timecode::snap_time_to_timebase(const rational &time,
return timestamp_to_time(timestamp, timebase);
}
rational Timecode::timestamp_to_time(const int64_t &timestamp,
const rational &timebase)
Rational Timecode::timestamp_to_time(const int64_t &timestamp,
const Rational &timebase)
{
int64_t num = int64_t(timebase.numerator()) * timestamp;
int64_t den = timebase.denominator();
ReduceFraction(num, den, INT_MAX);
reduce_fraction(num, den, INT_MAX);
return rational(int(num), int(den));
return Rational(int(num), int(den));
}
bool Timecode::timebase_is_drop_frame(const rational &timebase)
bool Timecode::timebase_is_drop_frame(const Rational &timebase)
{
return (timebase.numerator() != 1);
}
int64_t Timecode::time_to_timestamp(const rational &time,
const rational &timebase, Rounding floor)
int64_t Timecode::time_to_timestamp(const Rational &time,
const Rational &timebase, Rounding floor)
{
return time_to_timestamp(time.toDouble(), timebase, floor);
return time_to_timestamp(time.to_double(), timebase, floor);
}
int64_t Timecode::time_to_timestamp(const double &time,
const rational &timebase, Rounding floor)
const Rational &timebase, Rounding floor)
{
const double d = time * timebase.flipped().toDouble();
const double d = time * timebase.flipped().to_double();
if (std::isnan(d)) {
return 0;
@@ -362,16 +362,16 @@ int64_t Timecode::time_to_timestamp(const double &time,
const double eps = 0.000000000001;
switch (floor) {
case kRound:
case k_round:
default:
return std::llround(d);
case kFloor:
case k_floor:
if (d > std::ceil(d) - eps) {
return std::ceil(d);
} else {
return std::floor(d);
}
case kCeil:
case k_ceil:
if (d < std::floor(d) + eps) {
return std::floor(d);
} else {
@@ -380,29 +380,29 @@ int64_t Timecode::time_to_timestamp(const double &time,
}
}
int64_t Timecode::rescale_timestamp(const int64_t &ts, const rational &source,
const rational &dest)
int64_t Timecode::rescale_timestamp(const int64_t &ts, const Rational &source,
const Rational &dest)
{
if (source == dest) {
return ts;
}
return RescaleRnd(ts, source.numerator() * int64_t(dest.denominator()),
return rescale_rnd(ts, source.numerator() * int64_t(dest.denominator()),
source.denominator() * int64_t(dest.numerator()),
FractionRounding::kNearInf);
FractionRounding::k_near_inf);
}
int64_t Timecode::rescale_timestamp_ceil(const int64_t &ts,
const rational &source,
const rational &dest)
const Rational &source,
const Rational &dest)
{
if (source == dest) {
return ts;
}
return RescaleRnd(ts, source.numerator() * int64_t(dest.denominator()),
return rescale_rnd(ts, source.numerator() * int64_t(dest.denominator()),
source.denominator() * int64_t(dest.numerator()),
FractionRounding::kUp);
FractionRounding::k_up);
}
}
+47 -47
View File
@@ -30,41 +30,41 @@
namespace olive::core
{
TimeRange::TimeRange(const rational &in, const rational &out)
TimeRange::TimeRange(const Rational &in, const Rational &out)
: in_(in)
, out_(out)
{
normalize();
}
const rational &TimeRange::in() const
const Rational &TimeRange::in() const
{
return in_;
}
const rational &TimeRange::out() const
const Rational &TimeRange::out() const
{
return out_;
}
const rational &TimeRange::length() const
const Rational &TimeRange::length() const
{
return length_;
}
void TimeRange::set_in(const rational &in)
void TimeRange::set_in(const Rational &in)
{
in_ = in;
normalize();
}
void TimeRange::set_out(const rational &out)
void TimeRange::set_out(const Rational &out)
{
out_ = out;
normalize();
}
void TimeRange::set_range(const rational &in, const rational &out)
void TimeRange::set_range(const Rational &in, const Rational &out)
{
in_ = in;
out_ = out;
@@ -81,7 +81,7 @@ bool TimeRange::operator!=(const TimeRange &r) const
return in() != r.in() || out() != r.out();
}
bool TimeRange::OverlapsWith(const TimeRange &a, bool in_inclusive,
bool TimeRange::overlaps_with(const TimeRange &a, bool in_inclusive,
bool out_inclusive) const
{
bool doesnt_overlap_in = (in_inclusive) ? (a.out() < in()) :
@@ -93,12 +93,12 @@ bool TimeRange::OverlapsWith(const TimeRange &a, bool in_inclusive,
return !doesnt_overlap_in && !doesnt_overlap_out;
}
TimeRange TimeRange::Combined(const TimeRange &a) const
TimeRange TimeRange::combined(const TimeRange &a) const
{
return Combine(a, *this);
return combine(a, *this);
}
bool TimeRange::Contains(const TimeRange &compare, bool in_inclusive,
bool TimeRange::contains(const TimeRange &compare, bool in_inclusive,
bool out_inclusive) const
{
bool contains_in = (in_inclusive) ? (compare.in() >= in()) :
@@ -110,69 +110,69 @@ bool TimeRange::Contains(const TimeRange &compare, bool in_inclusive,
return contains_in && contains_out;
}
bool TimeRange::Contains(const rational &r) const
bool TimeRange::contains(const Rational &r) const
{
return r >= in_ && r < out_;
}
TimeRange TimeRange::Combine(const TimeRange &a, const TimeRange &b)
TimeRange TimeRange::combine(const TimeRange &a, const TimeRange &b)
{
return TimeRange(std::min(a.in(), b.in()), std::max(a.out(), b.out()));
}
TimeRange TimeRange::Intersected(const TimeRange &a) const
TimeRange TimeRange::intersected(const TimeRange &a) const
{
return Intersect(a, *this);
return intersect(a, *this);
}
TimeRange TimeRange::Intersect(const TimeRange &a, const TimeRange &b)
TimeRange TimeRange::intersect(const TimeRange &a, const TimeRange &b)
{
return TimeRange(std::max(a.in(), b.in()), std::min(a.out(), b.out()));
}
TimeRange TimeRange::operator+(const rational &rhs) const
TimeRange TimeRange::operator+(const Rational &rhs) const
{
TimeRange answer(*this);
answer += rhs;
return answer;
}
TimeRange TimeRange::operator-(const rational &rhs) const
TimeRange TimeRange::operator-(const Rational &rhs) const
{
TimeRange answer(*this);
answer -= rhs;
return answer;
}
const TimeRange &TimeRange::operator+=(const rational &rhs)
const TimeRange &TimeRange::operator+=(const Rational &rhs)
{
set_range(in_ + rhs, out_ + rhs);
return *this;
}
const TimeRange &TimeRange::operator-=(const rational &rhs)
const TimeRange &TimeRange::operator-=(const Rational &rhs)
{
set_range(in_ - rhs, out_ - rhs);
return *this;
}
std::list<TimeRange> TimeRange::Split(const int &chunk_size) const
std::list<TimeRange> TimeRange::split(const int &chunk_size) const
{
std::list<TimeRange> split_ranges;
int start_time =
std::floor(this->in().toDouble() / static_cast<double>(chunk_size)) *
std::floor(this->in().to_double() / static_cast<double>(chunk_size)) *
chunk_size;
int end_time =
std::ceil(this->out().toDouble() / static_cast<double>(chunk_size)) *
std::ceil(this->out().to_double() / static_cast<double>(chunk_size)) *
chunk_size;
for (int i = start_time; i < end_time; i += chunk_size) {
split_ranges.push_back(
TimeRange(std::max(this->in(), rational(i)),
std::min(this->out(), rational(i + chunk_size))));
TimeRange(std::max(this->in(), Rational(i)),
std::min(this->out(), Rational(i + chunk_size))));
}
return split_ranges;
@@ -188,7 +188,7 @@ void TimeRange::normalize()
// Calculate length
if (out_ == RATIONAL_MIN || out_ == RATIONAL_MAX || in_ == RATIONAL_MIN ||
in_ == RATIONAL_MAX) {
length_ = rational::NaN;
length_ = Rational::na_n;
} else {
length_ = out_ - in_;
}
@@ -212,8 +212,8 @@ void TimeRangeList::insert(TimeRange range_to_add)
for (auto it = array_.begin(); it != array_.end();) {
const TimeRange &compare = *it;
if (compare.OverlapsWith(range_to_add)) {
range_to_add = TimeRange::Combine(range_to_add, compare);
if (compare.overlaps_with(range_to_add)) {
range_to_add = TimeRange::combine(range_to_add, compare);
it = array_.erase(it);
} else {
it++;
@@ -239,7 +239,7 @@ bool TimeRangeList::contains(const TimeRange &range, bool in_inclusive,
bool out_inclusive) const
{
for (int i = 0; i < size(); i++) {
if (array_.at(i).Contains(range, in_inclusive, out_inclusive)) {
if (array_.at(i).contains(range, in_inclusive, out_inclusive)) {
return true;
}
}
@@ -247,14 +247,14 @@ bool TimeRangeList::contains(const TimeRange &range, bool in_inclusive,
return false;
}
void TimeRangeList::shift(const rational &diff)
void TimeRangeList::shift(const Rational &diff)
{
for (int i = 0; i < array_.size(); i++) {
array_[i] += diff;
}
}
void TimeRangeList::trim_in(const rational &diff)
void TimeRangeList::trim_in(const Rational &diff)
{
// Re-do list since we want to handle overlaps
TimeRangeList temp = *this;
@@ -268,7 +268,7 @@ void TimeRangeList::trim_in(const rational &diff)
}
}
void TimeRangeList::trim_out(const rational &diff)
void TimeRangeList::trim_out(const Rational &diff)
{
// Re-do list since we want to handle overlaps
TimeRangeList temp = *this;
@@ -282,7 +282,7 @@ void TimeRangeList::trim_out(const rational &diff)
}
}
TimeRangeList TimeRangeList::Intersects(const TimeRange &range) const
TimeRangeList TimeRangeList::intersects(const TimeRange &range) const
{
TimeRangeList intersect_list;
@@ -305,12 +305,12 @@ TimeRangeList TimeRangeList::Intersects(const TimeRange &range) const
}
TimeRangeListFrameIterator::TimeRangeListFrameIterator()
: TimeRangeListFrameIterator(TimeRangeList(), rational::NaN)
: TimeRangeListFrameIterator(TimeRangeList(), Rational::na_n)
{
}
TimeRangeListFrameIterator::TimeRangeListFrameIterator(
const TimeRangeList &list, const rational &timebase)
const TimeRangeList &list, const Rational &timebase)
: list_(list)
, timebase_(timebase)
, range_index_(-1)
@@ -324,17 +324,17 @@ TimeRangeListFrameIterator::TimeRangeListFrameIterator(
<< std::endl;
}
UpdateIndexIfNecessary();
update_index_if_necessary();
}
rational TimeRangeListFrameIterator::Snap(const rational &r) const
Rational TimeRangeListFrameIterator::snap(const Rational &r) const
{
return Timecode::snap_time_to_timebase(r, timebase_, Timecode::kFloor);
return Timecode::snap_time_to_timebase(r, timebase_, Timecode::k_floor);
}
bool TimeRangeListFrameIterator::GetNext(rational *out)
bool TimeRangeListFrameIterator::get_next(Rational *out)
{
if (!HasNext()) {
if (!has_next()) {
return false;
}
@@ -345,7 +345,7 @@ bool TimeRangeListFrameIterator::GetNext(rational *out)
current_ += timebase_;
// If this time is outside the current range, jump to the next one
UpdateIndexIfNecessary();
update_index_if_necessary();
// Increment frame index
frame_index_++;
@@ -353,7 +353,7 @@ bool TimeRangeListFrameIterator::GetNext(rational *out)
return true;
}
bool TimeRangeListFrameIterator::HasNext() const
bool TimeRangeListFrameIterator::has_next() const
{
return range_index_ < list_.size();
}
@@ -365,9 +365,9 @@ int TimeRangeListFrameIterator::size()
size_ = 0;
for (const TimeRange &range : list_) {
rational start = Snap(range.in());
rational end = Timecode::snap_time_to_timebase(
range.out(), timebase_, Timecode::kFloor);
Rational start = snap(range.in());
Rational end = Timecode::snap_time_to_timebase(
range.out(), timebase_, Timecode::k_floor);
if (end == range.out()) {
end -= timebase_;
@@ -383,14 +383,14 @@ int TimeRangeListFrameIterator::size()
return size_;
}
void TimeRangeListFrameIterator::UpdateIndexIfNecessary()
void TimeRangeListFrameIterator::update_index_if_necessary()
{
while (range_index_ < list_.size() &&
(range_index_ == -1 || current_ >= list_.at(range_index_).out())) {
range_index_++;
if (range_index_ < list_.size()) {
current_ = Snap(list_.at(range_index_).in());
current_ = snap(list_.at(range_index_).in());
}
}
}
+14 -14
View File
@@ -28,22 +28,22 @@ using namespace olive::core;
bool rational_to_from_string_test()
{
rational r(1, 30);
Rational r(1, 30);
std::string s = r.toString();
rational r2 = rational::fromString(s);
Rational r2 = Rational::fromString(s);
return r == r2;
}
bool rational_to_from_string_test2()
{
rational r(69, 420);
Rational r(69, 420);
std::string s = r.toString();
rational r2 = rational::fromString(s);
Rational r2 = Rational::fromString(s);
return r == r2;
}
@@ -51,7 +51,7 @@ bool rational_to_from_string_test2()
bool rational_defaults()
{
// By default, rationals are valid 0/1
rational basic_constructor;
Rational basic_constructor;
if (!basic_constructor.isNull()) {
return false;
@@ -67,21 +67,21 @@ bool rational_defaults()
bool rational_nan()
{
// Create a NaN with a 0 denominator
rational nan = rational(0, 0);
Rational nan = Rational(0, 0);
if (!nan.isNaN())
return false;
if (!nan.isNull())
return false;
// Create a non-NaN with a zero numerator
rational zero_nonnan(0, 999);
Rational zero_nonnan(0, 999);
if (!zero_nonnan.isNull())
return false;
if (zero_nonnan.isNaN())
return false;
// Create a non-NaN with a non-zero numerator
rational nonzer_nonnan(1, 30);
Rational nonzer_nonnan(1, 30);
if (nonzer_nonnan.isNull())
return false;
if (nonzer_nonnan.isNaN())
@@ -92,18 +92,18 @@ bool rational_nan()
bool rational_nan_constant()
{
return rational::NaN.isNaN();
return Rational::NaN.isNaN();
}
int main()
{
Tester t;
t.add("rational::defaults", rational_defaults);
t.add("rational::NaN", rational_nan);
t.add("rational::NaN_constant", rational_nan_constant);
t.add("rational::toString/fromString", rational_to_from_string_test);
t.add("rational::toString/fromString2", rational_to_from_string_test2);
t.add("Rational::defaults", rational_defaults);
t.add("Rational::NaN", rational_nan);
t.add("Rational::NaN_constant", rational_nan_constant);
t.add("Rational::toString/fromString", rational_to_from_string_test);
t.add("Rational::toString/fromString2", rational_to_from_string_test2);
return t.exec();
}
+4 -4
View File
@@ -28,10 +28,10 @@ using namespace olive::core;
bool timecodefunctions_time_to_timecode_test()
{
rational drop_frame_30(1001, 30000);
Rational drop_frame_30(1001, 30000);
std::string timecode = Timecode::time_to_timecode(
rational(1), drop_frame_30, Timecode::kTimecodeDropFrame);
Rational(1), drop_frame_30, Timecode::kTimecodeDropFrame);
if (strcmp(timecode.c_str(), "00:00:01;00") != 0) {
return false;
}
@@ -41,10 +41,10 @@ bool timecodefunctions_time_to_timecode_test()
bool timecodefunctions_time_to_timecode_test2()
{
rational bizarre_timebase(156632219);
Rational bizarre_timebase(156632219);
std::string timecode = Timecode::time_to_timecode(
rational(0), bizarre_timebase, Timecode::kTimecodeDropFrame);
Rational(0), bizarre_timebase, Timecode::kTimecodeDropFrame);
if (strcmp(timecode.c_str(), "INVALID TIMEBASE") != 0) {
return false;
}