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