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:
@@ -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_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 ¶ms)
|
||||
{
|
||||
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 ¶ms)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 ×tamp,
|
||||
const rational &timebase)
|
||||
Rational Timecode::timestamp_to_time(const int64_t ×tamp,
|
||||
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
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user