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
+2 -2
View File
@@ -22,8 +22,8 @@ target_sources(libolive-editor PRIVATE
crashpadinterface.cpp
crashpadinterface.h
crashpadutils.h
Current.cpp
Current.h
current.cpp
current.h
debug.cpp
debug.h
decibel.h
+4 -4
View File
@@ -19,8 +19,8 @@
***/
#ifndef AUTOSCROLL_H
#define AUTOSCROLL_H
#ifndef OAK_AUTOSCROLL_H
#define OAK_AUTOSCROLL_H
#include "common/define.h"
@@ -29,9 +29,9 @@ namespace olive
class AutoScroll {
public:
enum Method { kNone, kPage, kSmooth };
enum Method { k_none, k_page, k_smooth };
};
}
#endif // AUTOSCROLL_H
#endif // OAK_AUTOSCROLL_H
+5 -5
View File
@@ -19,8 +19,8 @@
***/
#ifndef AVFRAMEPTR_H
#define AVFRAMEPTR_H
#ifndef OAK_AVFRAMEPTR_H
#define OAK_AVFRAMEPTR_H
#include <stdint.h>
@@ -124,16 +124,16 @@ private:
using AVFramePtr = std::shared_ptr<AVFrame>;
inline AVFramePtr CreateAVFramePtr(FBFrame *f)
inline AVFramePtr create_av_frame_ptr(FBFrame *f)
{
return std::make_shared<AVFrame>(f);
}
inline AVFramePtr CreateAVFramePtr()
inline AVFramePtr create_av_frame_ptr()
{
return std::make_shared<AVFrame>();
}
}
#endif // AVFRAMEPTR_H
#endif // OAK_AVFRAMEPTR_H
+8 -8
View File
@@ -19,8 +19,8 @@
***/
#ifndef CANCELABLEOBJECT_H
#define CANCELABLEOBJECT_H
#ifndef OAK_CANCELABLEOBJECT_H
#define OAK_CANCELABLEOBJECT_H
#include "common/define.h"
#include "render/cancelatom.h"
@@ -34,20 +34,20 @@ public:
{
}
void Cancel()
void cancel()
{
cancel_.Cancel();
cancel_.cancel();
CancelEvent();
}
CancelAtom *GetCancelAtom()
CancelAtom *get_cancel_atom()
{
return &cancel_;
}
bool IsCancelled()
bool is_cancelled()
{
return cancel_.IsCancelled();
return cancel_.is_cancelled();
}
protected:
@@ -61,4 +61,4 @@ private:
}
#endif // CANCELABLEOBJECT_H
#endif // OAK_CANCELABLEOBJECT_H
+7 -7
View File
@@ -36,7 +36,7 @@ CommandLineParser::~CommandLineParser()
}
const CommandLineParser::Option *
CommandLineParser::AddOption(const QStringList &strings,
CommandLineParser::add_option(const QStringList &strings,
const QString &description, bool takes_arg,
const QString &arg_placeholder, bool hidden)
{
@@ -49,7 +49,7 @@ CommandLineParser::AddOption(const QStringList &strings,
}
const CommandLineParser::PositionalArgument *
CommandLineParser::AddPositionalArgument(const QString &name,
CommandLineParser::add_positional_argument(const QString &name,
const QString &description,
bool required)
{
@@ -60,7 +60,7 @@ CommandLineParser::AddPositionalArgument(const QString &name,
return a;
}
void CommandLineParser::Process(const QVector<QString> &argv)
void CommandLineParser::process(const QVector<QString> &argv)
{
int positional_index = 0;
@@ -79,10 +79,10 @@ void CommandLineParser::Process(const QVector<QString> &argv)
foreach (const QString &s, o.args) {
if (!s.compare(arg_basename, Qt::CaseInsensitive)) {
// Flag discovered!
o.option->Set();
o.option->set();
if (o.takes_arg && i + 1 < argv.size()) {
o.option->SetSetting(argv[i + 1]);
o.option->set_setting(argv[i + 1]);
i++;
}
@@ -100,7 +100,7 @@ found_flag:
} else {
// Must be a positional flag
if (positional_index < positional_args_.size()) {
positional_args_[positional_index].option->SetSetting(argv[i]);
positional_args_[positional_index].option->set_setting(argv[i]);
positional_index++;
} else {
qWarning() << "Unknown parameter:" << argv[i];
@@ -109,7 +109,7 @@ found_flag:
}
}
void CommandLineParser::PrintHelp(const char *filename)
void CommandLineParser::print_help(const char *filename)
{
printf("%s %s\n", QCoreApplication::applicationName().toUtf8().constData(),
QCoreApplication::applicationVersion().toUtf8().constData());
+11 -11
View File
@@ -19,8 +19,8 @@
***/
#ifndef COMMANDLINEPARSER_H
#define COMMANDLINEPARSER_H
#ifndef OAK_COMMANDLINEPARSER_H
#define OAK_COMMANDLINEPARSER_H
#include <QStringList>
#include <QVector>
@@ -47,12 +47,12 @@ public:
public:
PositionalArgument() = default;
const QString &GetSetting() const
const QString &get_setting() const
{
return setting_;
}
void SetSetting(const QString &s)
void set_setting(const QString &s)
{
setting_ = s;
}
@@ -68,12 +68,12 @@ public:
is_set_ = false;
}
bool IsSet() const
bool is_set() const
{
return is_set_;
}
void Set()
void set()
{
is_set_ = true;
}
@@ -84,18 +84,18 @@ public:
CommandLineParser() = default;
const Option *AddOption(const QStringList &strings,
const Option *add_option(const QStringList &strings,
const QString &description, bool takes_arg = false,
const QString &arg_placeholder = QString(),
bool hidden = false);
const PositionalArgument *AddPositionalArgument(const QString &name,
const PositionalArgument *add_positional_argument(const QString &name,
const QString &description,
bool required = false);
void Process(const QVector<QString> &argv);
void process(const QVector<QString> &argv);
void PrintHelp(const char *filename);
void print_help(const char *filename);
private:
struct KnownOption {
@@ -119,4 +119,4 @@ private:
QVector<KnownPositionalArgument> positional_args_;
};
#endif // COMMANDLINEPARSER_H
#endif // OAK_COMMANDLINEPARSER_H
+3 -3
View File
@@ -18,8 +18,8 @@
***/
#ifndef CRASHPAD_INTERFACE_H
#define CRASHPAD_INTERFACE_H
#ifndef OAK_CRASHPAD_INTERFACE_H
#define OAK_CRASHPAD_INTERFACE_H
#ifdef USE_CRASHPAD
@@ -30,4 +30,4 @@ bool InitializeCrashpad();
#endif // USE_CRASHPAD
#endif // CRASHPAD_INTERFACE_H
#endif // OAK_CRASHPAD_INTERFACE_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef CRASHPADUTILS_H
#define CRASHPADUTILS_H
#ifndef OAK_CRASHPADUTILS_H
#define OAK_CRASHPADUTILS_H
#include <client/crashpad_client.h>
@@ -38,4 +38,4 @@
#define BASE_STRING_TO_QSTRING(x) QString::fromStdWString(x)
#endif // BUILDFLAG(IS_WIN)
#endif // CRASHPADUTILS_H
#endif // OAK_CRASHPADUTILS_H
@@ -17,6 +17,6 @@
*
*/
#include "Current.h"
#include "current.h"
Current Current::current;
+11 -11
View File
@@ -17,9 +17,9 @@
*
*/
#ifndef CURRENT_H
#define CURRENT_H
#include "pluginSupport/OliveHost.h"
#ifndef OAK_CURRENT_H
#define OAK_CURRENT_H
#include "pluginSupport/olivehost.h"
#include "render/videoparams.h"
#include "render/job/pluginjob.h"
@@ -29,11 +29,11 @@ public:
{
return current;
}
olive::VideoParams &currentVideoParams()
olive::VideoParams &current_video_params()
{
return currentVideoParams_;
}
olive::AudioParams &currentAudioParams()
olive::AudioParams &current_audio_params()
{
return currentAudioParams_;
}
@@ -58,17 +58,17 @@ public:
return true;
}
std::shared_ptr<olive::plugin::OliveHost> pluginHost()
std::shared_ptr<olive::plugin::OliveHost> plugin_host()
{
return myHost;
return myHost_;
}
void setPluginHost(std::shared_ptr<olive::plugin::OliveHost> host)
{
myHost = host;
myHost_ = host;
}
std::shared_ptr<OFX::Host::ImageEffect::PluginCache> pluginCache()
std::shared_ptr<OFX::Host::ImageEffect::PluginCache> plugin_cache()
{
return plugin_cache_;
}
@@ -83,8 +83,8 @@ private:
static Current current;
olive::VideoParams currentVideoParams_;
olive::AudioParams currentAudioParams_;
std::shared_ptr<olive::plugin::OliveHost> myHost;
std::shared_ptr<olive::plugin::OliveHost> myHost_;
std::shared_ptr<OFX::Host::ImageEffect::PluginCache> plugin_cache_;
};
#endif //CURRENT_H
#endif //OAK_CURRENT_H
+3 -3
View File
@@ -24,10 +24,10 @@
namespace olive
{
void DebugHandler(QtMsgType type, const QMessageLogContext &context,
void debug_handler(QtMsgType type, const QMessageLogContext &context,
const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
QByteArray local_msg = msg.toLocal8Bit();
const char *msg_type = "UNKNOWN";
switch (type) {
@@ -49,7 +49,7 @@ void DebugHandler(QtMsgType type, const QMessageLogContext &context,
}
//fprintf(stderr, "[%s] %s (%s:%u)\n", msg_type, localMsg.constData(), context.function, context.line);
fprintf(stderr, "[%s] %s\n", msg_type, localMsg.constData());
fprintf(stderr, "[%s] %s\n", msg_type, local_msg.constData());
#ifdef Q_OS_WINDOWS
// Windows still seems to buffer stderr and we want to see debug messages immediately, so here we make sure each line
+4 -4
View File
@@ -19,8 +19,8 @@
***/
#ifndef DEBUG_H
#define DEBUG_H
#ifndef OAK_DEBUG_H
#define OAK_DEBUG_H
#include <QDebug>
@@ -29,9 +29,9 @@
namespace olive
{
void DebugHandler(QtMsgType type, const QMessageLogContext &context,
void debug_handler(QtMsgType type, const QMessageLogContext &context,
const QString &msg);
}
#endif // DEBUG_H
#endif // OAK_DEBUG_H
+17 -17
View File
@@ -19,8 +19,8 @@
***/
#ifndef DECIBEL_H
#define DECIBEL_H
#ifndef OAK_DECIBEL_H
#define OAK_DECIBEL_H
#include <QtGlobal>
#include <cmath>
@@ -33,20 +33,20 @@ namespace olive
class Decibel {
public:
// In basically all circumstances, this should calculate to 0.0 linear
static constexpr double MINIMUM = -200.0;
static constexpr double minimum = -200.0;
static double fromLinear(double linear)
static double from_linear(double linear)
{
double v = double(20.0) * std::log10(linear);
#ifndef ALLOW_RETURNING_INFINITY
if (std::isinf(v)) {
return MINIMUM;
return minimum;
}
#endif
return v;
}
static double toLinear(double decibel)
static double to_linear(double decibel)
{
double to_linear = std::pow(double(10.0), decibel / double(20.0));
@@ -58,47 +58,47 @@ public:
}
}
static double fromLogarithmic(double logarithmic)
static double from_logarithmic(double logarithmic)
{
if (logarithmic < 0.001)
#ifdef ALLOW_RETURNING_INFINITY
return std::numeric_limits<double>::infinity();
#else
return MINIMUM;
return minimum;
#endif
else if (logarithmic > 0.99)
return 0;
else
return 20.0 * std::log10(-std::log(1 - logarithmic) / LOG100);
return 20.0 * std::log10(-std::log(1 - logarithmic) / lo_g100);
}
static double toLogarithmic(double decibel)
static double to_logarithmic(double decibel)
{
if (qFuzzyIsNull(decibel)) {
return 1;
} else {
return 1 - std::exp(-std::pow(10.0, decibel / 20.0) * LOG100);
return 1 - std::exp(-std::pow(10.0, decibel / 20.0) * lo_g100);
}
}
static double LinearToLogarithmic(double linear)
static double linear_to_logarithmic(double linear)
{
return 1 - std::exp(-linear * LOG100);
return 1 - std::exp(-linear * lo_g100);
}
static double LogarithmicToLinear(double logarithmic)
static double logarithmic_to_linear(double logarithmic)
{
if (logarithmic > 0.99) {
return 1;
} else {
return -std::log(1 - logarithmic) / LOG100;
return -std::log(1 - logarithmic) / lo_g100;
}
}
private:
static constexpr double LOG100 = 4.60517018599;
static constexpr double lo_g100 = 4.60517018599;
};
}
#endif // DECIBEL_H
#endif // OAK_DECIBEL_H
+7 -7
View File
@@ -19,22 +19,22 @@
***/
#ifndef OLIVECOMMONDEFINE_H
#define OLIVECOMMONDEFINE_H
#ifndef OAK_OLIVECOMMONDEFINE_H
#define OAK_OLIVECOMMONDEFINE_H
namespace olive
{
/// The minimum size an icon in ProjectExplorer can be
const int kProjectIconSizeMinimum = 16;
const int k_project_icon_size_minimum = 16;
/// The maximum size an icon in ProjectExplorer can be
const int kProjectIconSizeMaximum = 256;
const int k_project_icon_size_maximum = 256;
/// The default size an icon in ProjectExplorer can be
const int kProjectIconSizeDefault = 64;
const int k_project_icon_size_default = 64;
const int kBytesInGigabyte = 1073741824;
const int k_bytes_in_gigabyte = 1073741824;
}
@@ -65,4 +65,4 @@ const int kBytesInGigabyte = 1073741824;
DISABLE_COPY(Class) \
DISABLE_MOVE(Class)
#endif // OLIVECOMMONDEFINE_H
#endif // OAK_OLIVECOMMONDEFINE_H
+4 -4
View File
@@ -19,15 +19,15 @@
***/
#ifndef DIGIT_H
#define DIGIT_H
#ifndef OAK_DIGIT_H
#define OAK_DIGIT_H
#include <stdint.h>
namespace olive
{
inline int64_t GetDigitCount(int64_t input)
inline int64_t get_digit_count(int64_t input)
{
input = std::abs(input);
@@ -44,4 +44,4 @@ inline int64_t GetDigitCount(int64_t input)
}
#endif // DIGIT_H
#endif // OAK_DIGIT_H
+114 -114
View File
@@ -24,110 +24,110 @@
namespace olive
{
int FFmpegUtils::GetCompatibleBridgePixelFormat(int pix_fmt,
int FFmpegUtils::get_compatible_bridge_pixel_format(int pix_fmt,
PixelFormat maximum)
{
int possible_pix_fmts[4];
possible_pix_fmts[0] = FB_PIX_FMT_RGBA;
possible_pix_fmts[0] = fb_pix_fmt_rgba;
if (maximum == PixelFormat::U8) {
possible_pix_fmts[1] = FB_PIX_FMT_NONE;
if (maximum == PixelFormat::u8) {
possible_pix_fmts[1] = fb_pix_fmt_none;
} else {
possible_pix_fmts[1] = FB_PIX_FMT_RGBA64LE;
if (maximum == PixelFormat::F32) {
possible_pix_fmts[2] = FB_PIX_FMT_RGBAF32LE;
possible_pix_fmts[3] = FB_PIX_FMT_NONE;
possible_pix_fmts[1] = fb_pix_fmt_rgb_a64_le;
if (maximum == PixelFormat::f32) {
possible_pix_fmts[2] = fb_pix_fmt_rgba_f32_le;
possible_pix_fmts[3] = fb_pix_fmt_none;
} else {
possible_pix_fmts[2] = FB_PIX_FMT_NONE;
possible_pix_fmts[2] = fb_pix_fmt_none;
}
}
return fb_find_best_pix_fmt_of_list(possible_pix_fmts, pix_fmt);
}
SampleFormat FFmpegUtils::GetNativeSampleFormat(int smp_fmt)
SampleFormat FFmpegUtils::get_native_sample_format(int smp_fmt)
{
switch (smp_fmt) {
case FB_SAMPLE_FMT_U8:
return SampleFormat::U8;
case FB_SAMPLE_FMT_S16:
return SampleFormat::S16;
case FB_SAMPLE_FMT_S32:
return SampleFormat::S32;
case FB_SAMPLE_FMT_S64:
return SampleFormat::S64;
case FB_SAMPLE_FMT_FLT:
return SampleFormat::F32;
case FB_SAMPLE_FMT_DBL:
return SampleFormat::F64;
case FB_SAMPLE_FMT_U8P:
return SampleFormat::U8P;
case FB_SAMPLE_FMT_S16P:
return SampleFormat::S16P;
case FB_SAMPLE_FMT_S32P:
return SampleFormat::S32P;
case FB_SAMPLE_FMT_S64P:
return SampleFormat::S64P;
case FB_SAMPLE_FMT_FLTP:
return SampleFormat::F32P;
case FB_SAMPLE_FMT_DBLP:
return SampleFormat::F64P;
case fb_sample_fmt_u8:
return SampleFormat::u8;
case fb_sample_fmt_s16:
return SampleFormat::s16;
case fb_sample_fmt_s32:
return SampleFormat::s32;
case fb_sample_fmt_s64:
return SampleFormat::s64;
case fb_sample_fmt_flt:
return SampleFormat::f32;
case fb_sample_fmt_dbl:
return SampleFormat::f64;
case fb_sample_fmt_u8_p:
return SampleFormat::u8_p;
case fb_sample_fmt_s16_p:
return SampleFormat::s16_p;
case fb_sample_fmt_s32_p:
return SampleFormat::s32_p;
case fb_sample_fmt_s64_p:
return SampleFormat::s64_p;
case fb_sample_fmt_fltp:
return SampleFormat::f32_p;
case fb_sample_fmt_dblp:
return SampleFormat::f64_p;
default:
break;
}
return SampleFormat::INVALID;
return SampleFormat::invalid;
}
int FFmpegUtils::GetFFmpegSampleFormat(const SampleFormat &smp_fmt)
int FFmpegUtils::get_f_fmpeg_sample_format(const SampleFormat &smp_fmt)
{
switch (smp_fmt) {
case SampleFormat::U8:
return FB_SAMPLE_FMT_U8;
case SampleFormat::S16:
return FB_SAMPLE_FMT_S16;
case SampleFormat::S32:
return FB_SAMPLE_FMT_S32;
case SampleFormat::S64:
return FB_SAMPLE_FMT_S64;
case SampleFormat::F32:
return FB_SAMPLE_FMT_FLT;
case SampleFormat::F64:
return FB_SAMPLE_FMT_DBL;
case SampleFormat::U8P:
return FB_SAMPLE_FMT_U8P;
case SampleFormat::S16P:
return FB_SAMPLE_FMT_S16P;
case SampleFormat::S32P:
return FB_SAMPLE_FMT_S32P;
case SampleFormat::S64P:
return FB_SAMPLE_FMT_S64P;
case SampleFormat::F32P:
return FB_SAMPLE_FMT_FLTP;
case SampleFormat::F64P:
return FB_SAMPLE_FMT_DBLP;
case SampleFormat::INVALID:
case SampleFormat::COUNT:
case SampleFormat::u8:
return fb_sample_fmt_u8;
case SampleFormat::s16:
return fb_sample_fmt_s16;
case SampleFormat::s32:
return fb_sample_fmt_s32;
case SampleFormat::s64:
return fb_sample_fmt_s64;
case SampleFormat::f32:
return fb_sample_fmt_flt;
case SampleFormat::f64:
return fb_sample_fmt_dbl;
case SampleFormat::u8_p:
return fb_sample_fmt_u8_p;
case SampleFormat::s16_p:
return fb_sample_fmt_s16_p;
case SampleFormat::s32_p:
return fb_sample_fmt_s32_p;
case SampleFormat::s64_p:
return fb_sample_fmt_s64_p;
case SampleFormat::f32_p:
return fb_sample_fmt_fltp;
case SampleFormat::f64_p:
return fb_sample_fmt_dblp;
case SampleFormat::invalid:
case SampleFormat::count:
break;
}
return FB_SAMPLE_FMT_NONE;
return fb_sample_fmt_none;
}
int FFmpegUtils::ConvertJPEGSpaceToRegularSpace(int f)
int FFmpegUtils::convert_jpeg_space_to_regular_space(int f)
{
switch (f) {
case FB_PIX_FMT_YUVJ420P:
return FB_PIX_FMT_YUV420P;
case FB_PIX_FMT_YUVJ422P:
return FB_PIX_FMT_YUV422P;
case FB_PIX_FMT_YUVJ444P:
return FB_PIX_FMT_YUV444P;
case FB_PIX_FMT_YUVJ440P:
return FB_PIX_FMT_YUV440P;
case FB_PIX_FMT_YUVJ411P:
return FB_PIX_FMT_YUV411P;
case fb_pix_fmt_yuv_j420_p:
return fb_pix_fmt_yu_v420_p;
case fb_pix_fmt_yuv_j422_p:
return fb_pix_fmt_yu_v422_p;
case fb_pix_fmt_yuv_j444_p:
return fb_pix_fmt_yu_v444_p;
case fb_pix_fmt_yuv_j440_p:
return fb_pix_fmt_yu_v440_p;
case fb_pix_fmt_yuv_j411_p:
return fb_pix_fmt_yu_v411_p;
default:
break;
}
@@ -135,63 +135,63 @@ int FFmpegUtils::ConvertJPEGSpaceToRegularSpace(int f)
return f;
}
int FFmpegUtils::GetFFmpegPixelFormat(const PixelFormat &pix_fmt,
int FFmpegUtils::get_f_fmpeg_pixel_format(const PixelFormat &pix_fmt,
int channel_layout)
{
if (channel_layout == VideoParams::kRGBChannelCount) {
if (channel_layout == VideoParams::k_rgb_channel_count) {
switch (pix_fmt) {
case PixelFormat::U8:
return FB_PIX_FMT_RGB24;
case PixelFormat::U10:
return FB_PIX_FMT_NONE;
case PixelFormat::U16:
return FB_PIX_FMT_RGB48LE;
case PixelFormat::F16:
return FB_PIX_FMT_RGBF16LE;
case PixelFormat::F32:
return FB_PIX_FMT_RGBF32LE;
case PixelFormat::INVALID:
case PixelFormat::COUNT:
case PixelFormat::u8:
return fb_pix_fmt_rg_b24;
case PixelFormat::u10:
return fb_pix_fmt_none;
case PixelFormat::u16:
return fb_pix_fmt_rg_b48_le;
case PixelFormat::f16:
return fb_pix_fmt_rgb_f16_le;
case PixelFormat::f32:
return fb_pix_fmt_rgb_f32_le;
case PixelFormat::invalid:
case PixelFormat::count:
break;
}
} else if (channel_layout == VideoParams::kRGBAChannelCount) {
} else if (channel_layout == VideoParams::k_rgba_channel_count) {
switch (pix_fmt) {
case PixelFormat::U8:
return FB_PIX_FMT_RGBA;
case PixelFormat::U10:
return FB_PIX_FMT_NONE;
case PixelFormat::U16:
return FB_PIX_FMT_RGBA64LE;
case PixelFormat::F16:
return FB_PIX_FMT_RGBAF16LE;
case PixelFormat::F32:
return FB_PIX_FMT_RGBAF32LE;
case PixelFormat::INVALID:
case PixelFormat::COUNT:
case PixelFormat::u8:
return fb_pix_fmt_rgba;
case PixelFormat::u10:
return fb_pix_fmt_none;
case PixelFormat::u16:
return fb_pix_fmt_rgb_a64_le;
case PixelFormat::f16:
return fb_pix_fmt_rgba_f16_le;
case PixelFormat::f32:
return fb_pix_fmt_rgba_f32_le;
case PixelFormat::invalid:
case PixelFormat::count:
break;
}
}
return FB_PIX_FMT_NONE;
return fb_pix_fmt_none;
}
PixelFormat FFmpegUtils::GetCompatiblePixelFormat(const PixelFormat &pix_fmt)
PixelFormat FFmpegUtils::get_compatible_pixel_format(const PixelFormat &pix_fmt)
{
switch (pix_fmt) {
case PixelFormat::U8:
return PixelFormat::U8;
case PixelFormat::U10:
return PixelFormat::U8;
case PixelFormat::U16:
case PixelFormat::F16:
case PixelFormat::F32:
return PixelFormat::U16;
case PixelFormat::INVALID:
case PixelFormat::COUNT:
case PixelFormat::u8:
return PixelFormat::u8;
case PixelFormat::u10:
return PixelFormat::u8;
case PixelFormat::u16:
case PixelFormat::f16:
case PixelFormat::f32:
return PixelFormat::u16;
case PixelFormat::invalid:
case PixelFormat::count:
break;
}
return PixelFormat::INVALID;
return PixelFormat::invalid;
}
}
+10 -10
View File
@@ -19,8 +19,8 @@
***/
#ifndef FFMPEGABSTRACTION_H
#define FFMPEGABSTRACTION_H
#ifndef OAK_FFMPEGABSTRACTION_H
#define OAK_FFMPEGABSTRACTION_H
#include <ffmpeg_bridge/ffmpeg_bridge.h>
@@ -50,29 +50,29 @@ public:
* taking a single argument, an unscoped enum argument would silently
* prefer an int overload over the PixelFormat one.
*/
static int GetCompatibleBridgePixelFormat(
int pix_fmt, PixelFormat maximum = PixelFormat::INVALID);
static int get_compatible_bridge_pixel_format(
int pix_fmt, PixelFormat maximum = PixelFormat::invalid);
/**
* @brief Returns a native pixel format that can be used to convert from a native frame to a bridge frame with minimal data loss
*/
static PixelFormat GetCompatiblePixelFormat(const PixelFormat &pix_fmt);
static PixelFormat get_compatible_pixel_format(const PixelFormat &pix_fmt);
/**
* @brief Returns a bridge pixel format for a given native pixel format
*/
static int GetFFmpegPixelFormat(const PixelFormat &pix_fmt,
static int get_f_fmpeg_pixel_format(const PixelFormat &pix_fmt,
int channel_layout);
/**
* @brief Returns a native sample format type for a given bridge sample format
*/
static SampleFormat GetNativeSampleFormat(int smp_fmt);
static SampleFormat get_native_sample_format(int smp_fmt);
/**
* @brief Returns a bridge sample format type for a given native type
*/
static int GetFFmpegSampleFormat(const SampleFormat &smp_fmt);
static int get_f_fmpeg_sample_format(const SampleFormat &smp_fmt);
/**
* @brief Convert "JPEG"/full-range colorspace to its regular counterpart
@@ -81,9 +81,9 @@ public:
* time being, FFmpeg still uses these JPEG spaces, so for simplicity (since we *are* color_range
* aware), we use this function.
*/
static int ConvertJPEGSpaceToRegularSpace(int f);
static int convert_jpeg_space_to_regular_space(int f);
};
}
#endif // FFMPEGABSTRACTION_H
#endif // OAK_FFMPEGABSTRACTION_H
+18 -18
View File
@@ -33,7 +33,7 @@
namespace olive
{
QString FileFunctions::GetUniqueFileIdentifier(const QString &filename)
QString FileFunctions::get_unique_file_identifier(const QString &filename)
{
QFileInfo info(filename);
@@ -53,10 +53,10 @@ QString FileFunctions::GetUniqueFileIdentifier(const QString &filename)
return QString(result.toHex());
}
QString FileFunctions::GetConfigurationLocation()
QString FileFunctions::get_configuration_location()
{
if (IsPortable()) {
return GetApplicationPath();
if (is_portable()) {
return get_application_path();
} else {
QString s =
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
@@ -65,17 +65,17 @@ QString FileFunctions::GetConfigurationLocation()
}
}
bool FileFunctions::IsPortable()
bool FileFunctions::is_portable()
{
return QFileInfo::exists(QDir(GetApplicationPath()).filePath("portable"));
return QFileInfo::exists(QDir(get_application_path()).filePath("portable"));
}
QString FileFunctions::GetApplicationPath()
QString FileFunctions::get_application_path()
{
return QCoreApplication::applicationDirPath();
}
QString FileFunctions::GetTempFilePath()
QString FileFunctions::get_temp_file_path()
{
QString temp_path =
QDir(
@@ -89,7 +89,7 @@ QString FileFunctions::GetTempFilePath()
return temp_path;
}
bool FileFunctions::CanCopyDirectoryWithoutOverwriting(const QString &source,
bool FileFunctions::can_copy_directory_without_overwriting(const QString &source,
const QString &dest)
{
QFileInfoList info_list = QDir(source).entryInfoList();
@@ -104,7 +104,7 @@ bool FileFunctions::CanCopyDirectoryWithoutOverwriting(const QString &source,
QString dest_equivalent = QDir(dest).filePath(info.fileName());
if (info.isDir()) {
if (!CanCopyDirectoryWithoutOverwriting(info.absoluteFilePath(),
if (!can_copy_directory_without_overwriting(info.absoluteFilePath(),
dest_equivalent)) {
return false;
}
@@ -116,7 +116,7 @@ bool FileFunctions::CanCopyDirectoryWithoutOverwriting(const QString &source,
return true;
}
void FileFunctions::CopyDirectory(const QString &source, const QString &dest,
void FileFunctions::copy_directory(const QString &source, const QString &dest,
bool overwrite)
{
QDir d(source);
@@ -147,7 +147,7 @@ void FileFunctions::CopyDirectory(const QString &source, const QString &dest,
if (info.isDir()) {
// Copy dir
CopyDirectory(info.absoluteFilePath(), dest_file_path, overwrite);
copy_directory(info.absoluteFilePath(), dest_file_path, overwrite);
} else {
// Copy file
if (overwrite && QFile::exists(dest_file_path)) {
@@ -164,7 +164,7 @@ void FileFunctions::CopyDirectory(const QString &source, const QString &dest,
}
}
bool FileFunctions::DirectoryIsValid(const QDir &d,
bool FileFunctions::directory_is_valid(const QDir &d,
bool try_to_create_if_not_exists)
{
// Return whether the directory exists, or whether it could be created if it doesn't
@@ -172,7 +172,7 @@ bool FileFunctions::DirectoryIsValid(const QDir &d,
(try_to_create_if_not_exists && d.mkpath(QStringLiteral(".")));
}
QString FileFunctions::EnsureFilenameExtension(QString fn,
QString FileFunctions::ensure_filename_extension(QString fn,
const QString &extension)
{
// No-op if either input is empty
@@ -190,7 +190,7 @@ QString FileFunctions::EnsureFilenameExtension(QString fn,
return fn;
}
QString FileFunctions::ReadFileAsString(const QString &filename)
QString FileFunctions::read_file_as_string(const QString &filename)
{
QFile f(filename);
QString file_data;
@@ -202,7 +202,7 @@ QString FileFunctions::ReadFileAsString(const QString &filename)
return file_data;
}
QString FileFunctions::GetSafeTemporaryFilename(const QString &original)
QString FileFunctions::get_safe_temporary_filename(const QString &original)
{
int counter = 0;
@@ -226,7 +226,7 @@ QString FileFunctions::GetSafeTemporaryFilename(const QString &original)
return temp_abs_path;
}
bool FileFunctions::RenameFileAllowOverwrite(const QString &from,
bool FileFunctions::rename_file_allow_overwrite(const QString &from,
const QString &to)
{
if (QFileInfo::exists(to) && !QFile::remove(to)) {
@@ -243,7 +243,7 @@ bool FileFunctions::RenameFileAllowOverwrite(const QString &from,
return true;
}
QString FileFunctions::GetAutoRecoveryRoot()
QString FileFunctions::get_auto_recovery_root()
{
return QDir(QStandardPaths::writableLocation(
QStandardPaths::AppLocalDataLocation))
+17 -17
View File
@@ -19,8 +19,8 @@
***/
#ifndef FILEFUNCTIONS_H
#define FILEFUNCTIONS_H
#ifndef OAK_FILEFUNCTIONS_H
#define OAK_FILEFUNCTIONS_H
#include <QDir>
#include <QString>
@@ -41,23 +41,23 @@ public:
* In portable mode, any persistent configuration files should be made in a path relative to the application rather
* than in the user's home folder.
*/
static bool IsPortable();
static bool is_portable();
static QString GetUniqueFileIdentifier(const QString &filename);
static QString get_unique_file_identifier(const QString &filename);
static QString GetConfigurationLocation();
static QString get_configuration_location();
static QString GetApplicationPath();
static QString get_application_path();
static QString GetTempFilePath();
static QString get_temp_file_path();
static bool CanCopyDirectoryWithoutOverwriting(const QString &source,
static bool can_copy_directory_without_overwriting(const QString &source,
const QString &dest);
static void CopyDirectory(const QString &source, const QString &dest,
static void copy_directory(const QString &source, const QString &dest,
bool overwrite = false);
static bool DirectoryIsValid(const QDir &dir,
static bool directory_is_valid(const QDir &dir,
bool try_to_create_if_not_exists = true);
/**
@@ -69,10 +69,10 @@ public:
* @return The filename provided either untouched or with the extension appended to it.
*/
static QString EnsureFilenameExtension(QString fn,
static QString ensure_filename_extension(QString fn,
const QString &extension);
static QString ReadFileAsString(const QString &filename);
static QString read_file_as_string(const QString &filename);
/**
* @brief Returns a temporary filename that can be used while writing rather than the original
@@ -84,15 +84,15 @@ public:
* This function returns a slight variant of the filename provided that's guaranteed to not exist
* and therefore won't overwrite anything important.
*/
static QString GetSafeTemporaryFilename(const QString &original);
static QString get_safe_temporary_filename(const QString &original);
/**
* @brief Renames a file from `from` to `to`, deleting `to` if such a file already exists first
*/
static bool RenameFileAllowOverwrite(const QString &from,
static bool rename_file_allow_overwrite(const QString &from,
const QString &to);
inline static QString GetFormattedExecutableForPlatform(QString unformatted)
inline static QString get_formatted_executable_for_platform(QString unformatted)
{
#ifdef Q_OS_WINDOWS
unformatted.append(QStringLiteral(".exe"));
@@ -101,9 +101,9 @@ public:
return unformatted;
}
static QString GetAutoRecoveryRoot();
static QString get_auto_recovery_root();
};
}
#endif // FILEFUNCTIONS_H
#endif // OAK_FILEFUNCTIONS_H
+51 -51
View File
@@ -26,15 +26,15 @@
namespace olive
{
const QVector<QString> Html::kBlockTags = { QStringLiteral("p"),
const QVector<QString> Html::k_block_tags = { QStringLiteral("p"),
QStringLiteral("div") };
inline bool StrEquals(const QStringView &a, const QStringView &b)
inline bool str_equals(const QStringView &a, const QStringView &b)
{
return !a.compare(b, Qt::CaseInsensitive);
}
QString Html::DocToHtml(const QTextDocument *doc)
QString Html::doc_to_html(const QTextDocument *doc)
{
QString html;
QXmlStreamWriter writer(&html);
@@ -42,7 +42,7 @@ QString Html::DocToHtml(const QTextDocument *doc)
//writer.setAutoFormatting(true);
for (auto it = doc->begin(); it != doc->end(); it = it.next()) {
WriteBlock(&writer, it);
write_block(&writer, it);
}
return html;
@@ -53,7 +53,7 @@ struct HtmlNode {
QTextCharFormat format;
};
QTextCharFormat MergeHtmlFormats(const QVector<HtmlNode> &stack)
QTextCharFormat merge_html_formats(const QVector<HtmlNode> &stack)
{
QTextCharFormat f;
@@ -64,7 +64,7 @@ QTextCharFormat MergeHtmlFormats(const QVector<HtmlNode> &stack)
return f;
}
void Html::HtmlToDoc(QTextDocument *doc, const QString &html)
void Html::html_to_doc(QTextDocument *doc, const QString &html)
{
// Empty doc
doc->clear();
@@ -90,12 +90,12 @@ void Html::HtmlToDoc(QTextDocument *doc, const QString &html)
if (reader.tokenType() == QXmlStreamReader::StartElement) {
QString tag = reader.name().toString().toLower();
fmt_stack.append({ tag, ReadCharFormat(reader.attributes()) });
current_fmt = MergeHtmlFormats(fmt_stack);
fmt_stack.append({ tag, read_char_format(reader.attributes()) });
current_fmt = merge_html_formats(fmt_stack);
if (kBlockTags.contains(tag)) {
if (k_block_tags.contains(tag)) {
QTextBlockFormat block_fmt =
ReadBlockFormat(reader.attributes());
read_block_format(reader.attributes());
if (inside_block) {
c.setBlockFormat(block_fmt);
c.setBlockCharFormat(current_fmt);
@@ -115,9 +115,9 @@ void Html::HtmlToDoc(QTextDocument *doc, const QString &html)
for (int i = fmt_stack.size() - 1; i >= 0; i--) {
if (fmt_stack.at(i).tag == tag) {
fmt_stack.removeAt(i);
current_fmt = MergeHtmlFormats(fmt_stack);
current_fmt = merge_html_formats(fmt_stack);
if (kBlockTags.contains(tag)) {
if (k_block_tags.contains(tag)) {
inside_block = false;
}
break;
@@ -131,7 +131,7 @@ void Html::HtmlToDoc(QTextDocument *doc, const QString &html)
}
}
void Html::WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block)
void Html::write_block(QXmlStreamWriter *writer, const QTextBlock &block)
{
writer->writeStartElement(QStringLiteral("p"));
@@ -160,11 +160,11 @@ void Html::WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block)
QString style;
if (fmt.lineHeightType() != QTextBlockFormat::SingleHeight) {
WriteCSSProperty(&style, QStringLiteral("line-height"),
write_css_property(&style, QStringLiteral("line-height"),
QStringLiteral("%1%").arg(fmt.lineHeight()));
}
WriteCharFormat(&style, block.charFormat());
write_char_format(&style, block.charFormat());
if (!style.isEmpty()) {
writer->writeAttribute(QStringLiteral("style"), style);
@@ -174,14 +174,14 @@ void Html::WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block)
if (it != block.end()) {
for (; it != block.end(); it++) {
WriteFragment(writer, it.fragment());
write_fragment(writer, it.fragment());
}
}
writer->writeEndElement(); // p
}
void Html::WriteFragment(QXmlStreamWriter *writer,
void Html::write_fragment(QXmlStreamWriter *writer,
const QTextFragment &fragment)
{
const QTextCharFormat &fmt = fragment.charFormat();
@@ -191,7 +191,7 @@ void Html::WriteFragment(QXmlStreamWriter *writer,
// Write CSS attributes
QString style;
WriteCharFormat(&style, fmt);
write_char_format(&style, fmt);
if (!style.isEmpty()) {
writer->writeAttribute(QStringLiteral("style"), style);
@@ -211,7 +211,7 @@ void Html::WriteFragment(QXmlStreamWriter *writer,
writer->writeEndElement(); // span
}
void Html::WriteCSSProperty(QString *style, const QString &key,
void Html::write_css_property(QString *style, const QString &key,
const QStringList &values)
{
QString value;
@@ -220,39 +220,39 @@ void Html::WriteCSSProperty(QString *style, const QString &key,
v = QStringLiteral("'%1'").arg(v);
}
AppendStringAutoSpace(&value, v);
append_string_auto_space(&value, v);
}
AppendStringAutoSpace(style, QStringLiteral("%1: %2;").arg(key, value));
append_string_auto_space(style, QStringLiteral("%1: %2;").arg(key, value));
}
void Html::WriteCharFormat(QString *style, const QTextCharFormat &fmt)
void Html::write_char_format(QString *style, const QTextCharFormat &fmt)
{
QStringList families = fmt.fontFamilies().toStringList();
if (!families.isEmpty()) {
WriteCSSProperty(style, QStringLiteral("font-family"),
write_css_property(style, QStringLiteral("font-family"),
families.first());
}
if (fmt.hasProperty(QTextFormat::FontPointSize)) {
WriteCSSProperty(
write_css_property(
style, QStringLiteral("font-size"),
QStringLiteral("%1pt").arg(QString::number(fmt.fontPointSize())));
}
if (fmt.hasProperty(QTextFormat::FontWeight)) {
WriteCSSProperty(style, QStringLiteral("font-weight"),
write_css_property(style, QStringLiteral("font-weight"),
QString::number(fmt.fontWeight() * 8));
}
if (fmt.hasProperty(QTextFormat::FontItalic)) {
WriteCSSProperty(style, QStringLiteral("font-style"),
write_css_property(style, QStringLiteral("font-style"),
fmt.fontItalic() ? QStringLiteral("italic") :
QStringLiteral("normal"));
}
if (fmt.hasProperty(QTextFormat::FontStyleName)) {
WriteCSSProperty(style, QStringLiteral("-ove-font-style"),
write_css_property(style, QStringLiteral("-ove-font-style"),
fmt.fontStyleName().toString());
}
@@ -271,7 +271,7 @@ void Html::WriteCharFormat(QString *style, const QTextCharFormat &fmt)
}
if (!deco.isEmpty()) {
WriteCSSProperty(style, QStringLiteral("text-decoration"), deco);
write_css_property(style, QStringLiteral("text-decoration"), deco);
}
if (fmt.foreground().style() != Qt::NoBrush) {
@@ -288,37 +288,37 @@ void Html::WriteCharFormat(QString *style, const QTextCharFormat &fmt)
QString::number(color.alphaF()));
}
WriteCSSProperty(style, QStringLiteral("color"), cs);
write_css_property(style, QStringLiteral("color"), cs);
}
if (fmt.fontCapitalization() != QFont::MixedCase) {
if (fmt.fontCapitalization() == QFont::SmallCaps) {
WriteCSSProperty(style, QStringLiteral("font-variant"),
write_css_property(style, QStringLiteral("font-variant"),
QStringLiteral("small-caps"));
// TODO: Add others
}
}
if (fmt.fontLetterSpacing() != 0.0) {
WriteCSSProperty(style, QStringLiteral("letter-spacing"),
write_css_property(style, QStringLiteral("letter-spacing"),
QStringLiteral("%1%").arg(
QString::number(fmt.fontLetterSpacing())));
}
if (fmt.fontStretch() != 0) {
WriteCSSProperty(
write_css_property(
style, QStringLiteral("font-stretch"),
QStringLiteral("%1%").arg(QString::number(fmt.fontStretch())));
}
}
QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes)
QTextCharFormat Html::read_char_format(const QXmlStreamAttributes &attributes)
{
QTextCharFormat fmt;
foreach (const QXmlStreamAttribute &attr, attributes) {
if (StrEquals(attr.name(), QStringLiteral("style"))) {
auto css = GetCSSFromStyle(attr.value().toString());
if (str_equals(attr.name(), QStringLiteral("style"))) {
auto css = get_css_from_style(attr.value().toString());
for (auto it = css.begin(); it != css.end(); it++) {
const QString &first_val = it.value().first();
@@ -334,15 +334,15 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes)
fmt.setFontWeight(first_val.toInt() / 8);
} else if (it.key() == QStringLiteral("font-style")) {
fmt.setFontItalic(
StrEquals(first_val, QStringLiteral("italic")));
str_equals(first_val, QStringLiteral("italic")));
} else if (it.key() == QStringLiteral("text-decoration")) {
foreach (const QString &v, it.value()) {
if (StrEquals(v, QStringLiteral("underline"))) {
if (str_equals(v, QStringLiteral("underline"))) {
fmt.setFontUnderline(true);
} else if (StrEquals(v,
} else if (str_equals(v,
QStringLiteral("line-through"))) {
fmt.setFontStrikeOut(true);
} else if (StrEquals(v, QStringLiteral("overline"))) {
} else if (str_equals(v, QStringLiteral("overline"))) {
fmt.setFontOverline(true);
}
}
@@ -366,7 +366,7 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes)
fmt.setForeground(QColor(first_val));
}
} else if (it.key() == QStringLiteral("font-variant")) {
if (StrEquals(first_val, QStringLiteral("small-caps"))) {
if (str_equals(first_val, QStringLiteral("small-caps"))) {
fmt.setFontCapitalization(QFont::SmallCaps);
}
} else if (it.key() == QStringLiteral("letter-spacing")) {
@@ -387,25 +387,25 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes)
return fmt;
}
QTextBlockFormat Html::ReadBlockFormat(const QXmlStreamAttributes &attributes)
QTextBlockFormat Html::read_block_format(const QXmlStreamAttributes &attributes)
{
QTextBlockFormat block_fmt;
foreach (const QXmlStreamAttribute &attr, attributes) {
if (StrEquals(attr.name(), QStringLiteral("align"))) {
if (StrEquals(attr.value(), QStringLiteral("right"))) {
if (str_equals(attr.name(), QStringLiteral("align"))) {
if (str_equals(attr.value(), QStringLiteral("right"))) {
block_fmt.setAlignment(Qt::AlignRight);
} else if (StrEquals(attr.value(), QStringLiteral("center"))) {
} else if (str_equals(attr.value(), QStringLiteral("center"))) {
block_fmt.setAlignment(Qt::AlignHCenter);
} else if (StrEquals(attr.value(), QStringLiteral("justify"))) {
} else if (str_equals(attr.value(), QStringLiteral("justify"))) {
block_fmt.setAlignment(Qt::AlignJustify);
}
} else if (StrEquals(attr.name(), QStringLiteral("dir"))) {
if (StrEquals(attr.value(), QStringLiteral("rtl"))) {
} else if (str_equals(attr.name(), QStringLiteral("dir"))) {
if (str_equals(attr.value(), QStringLiteral("rtl"))) {
block_fmt.setLayoutDirection(Qt::RightToLeft);
}
} else if (StrEquals(attr.name(), QStringLiteral("style"))) {
auto css = GetCSSFromStyle(attr.value().toString());
} else if (str_equals(attr.name(), QStringLiteral("style"))) {
auto css = get_css_from_style(attr.value().toString());
for (auto it = css.begin(); it != css.end(); it++) {
if (it.key() == QStringLiteral("line-height")) {
@@ -423,7 +423,7 @@ QTextBlockFormat Html::ReadBlockFormat(const QXmlStreamAttributes &attributes)
return block_fmt;
}
void Html::AppendStringAutoSpace(QString *s, const QString &append)
void Html::append_string_auto_space(QString *s, const QString &append)
{
if (!s->isEmpty()) {
s->append(QChar(' '));
@@ -432,7 +432,7 @@ void Html::AppendStringAutoSpace(QString *s, const QString &append)
s->append(append);
}
QMap<QString, QStringList> Html::GetCSSFromStyle(const QString &s)
QMap<QString, QStringList> Html::get_css_from_style(const QString &s)
{
QMap<QString, QStringList> map;
+16 -16
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HTML_H
#define HTML_H
#ifndef OAK_HTML_H
#define OAK_HTML_H
#include <QTextDocument>
#include <QTextFragment>
@@ -45,39 +45,39 @@ namespace olive
*/
class Html {
public:
static QString DocToHtml(const QTextDocument *doc);
static QString doc_to_html(const QTextDocument *doc);
static void HtmlToDoc(QTextDocument *doc, const QString &html);
static void html_to_doc(QTextDocument *doc, const QString &html);
private:
static void WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block);
static void write_block(QXmlStreamWriter *writer, const QTextBlock &block);
static void WriteFragment(QXmlStreamWriter *writer,
static void write_fragment(QXmlStreamWriter *writer,
const QTextFragment &fragment);
static void WriteCSSProperty(QString *style, const QString &key,
static void write_css_property(QString *style, const QString &key,
const QStringList &value);
static void WriteCSSProperty(QString *style, const QString &key,
static void write_css_property(QString *style, const QString &key,
const QString &value)
{
WriteCSSProperty(style, key, QStringList({ value }));
write_css_property(style, key, QStringList({ value }));
}
static void WriteCharFormat(QString *style, const QTextCharFormat &fmt);
static void write_char_format(QString *style, const QTextCharFormat &fmt);
static QTextCharFormat
ReadCharFormat(const QXmlStreamAttributes &attributes);
read_char_format(const QXmlStreamAttributes &attributes);
static QTextBlockFormat
ReadBlockFormat(const QXmlStreamAttributes &attributes);
read_block_format(const QXmlStreamAttributes &attributes);
static void AppendStringAutoSpace(QString *s, const QString &append);
static void append_string_auto_space(QString *s, const QString &append);
static QMap<QString, QStringList> GetCSSFromStyle(const QString &s);
static QMap<QString, QStringList> get_css_from_style(const QString &s);
static const QVector<QString> kBlockTags;
static const QVector<QString> k_block_tags;
};
}
#endif // HTML_H
#endif // OAK_HTML_H
+2 -2
View File
@@ -28,10 +28,10 @@ QMutex job_time_mutex;
JobTime::JobTime()
{
Acquire();
acquire();
}
void JobTime::Acquire()
void JobTime::acquire()
{
job_time_mutex.lock();
+4 -4
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef JOBTIME_H
#define JOBTIME_H
#ifndef OAK_JOBTIME_H
#define OAK_JOBTIME_H
#include <QDebug>
#include <stdint.h>
@@ -29,7 +29,7 @@ class JobTime {
public:
JobTime();
void Acquire();
void acquire();
uint64_t value() const
{
@@ -76,4 +76,4 @@ QDebug operator<<(QDebug debug, const olive::JobTime &r);
Q_DECLARE_METATYPE(olive::JobTime)
#endif // JOBTIME_H
#endif // OAK_JOBTIME_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef LERP_H
#define LERP_H
#ifndef OAK_LERP_H
#define OAK_LERP_H
template <typename T>
/**
@@ -39,4 +39,4 @@ template <typename T> T lerp(T a, T b, float t)
return (a * (1.0f - t)) + (b * t);
}
#endif // LERP_H
#endif // OAK_LERP_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef MEMORYPOOL_H
#define MEMORYPOOL_H
#ifndef OAK_MEMORYPOOL_H
#define OAK_MEMORYPOOL_H
#include <memory>
#include <QApplication>
@@ -435,4 +435,4 @@ private slots:
}
#endif // MEMORYPOOL_H
#endif // OAK_MEMORYPOOL_H
+14 -14
View File
@@ -24,28 +24,28 @@
namespace olive
{
OCIO::BitDepth OCIOUtils::GetOCIOBitDepthFromPixelFormat(PixelFormat format)
ocio::BitDepth OCIOUtils::get_ocio_bit_depth_from_pixel_format(PixelFormat format)
{
switch (format) {
case PixelFormat::U8:
return OCIO::BIT_DEPTH_UINT8;
case PixelFormat::U10:
return OCIO::BIT_DEPTH_UINT10;
case PixelFormat::U16:
return OCIO::BIT_DEPTH_UINT16;
case PixelFormat::u8:
return ocio::BIT_DEPTH_UINT8;
case PixelFormat::u10:
return ocio::BIT_DEPTH_UINT10;
case PixelFormat::u16:
return ocio::BIT_DEPTH_UINT16;
break;
case PixelFormat::F16:
return OCIO::BIT_DEPTH_F16;
case PixelFormat::f16:
return ocio::BIT_DEPTH_F16;
break;
case PixelFormat::F32:
return OCIO::BIT_DEPTH_F32;
case PixelFormat::f32:
return ocio::BIT_DEPTH_F32;
break;
case PixelFormat::INVALID:
case PixelFormat::COUNT:
case PixelFormat::invalid:
case PixelFormat::count:
break;
}
return OCIO::BIT_DEPTH_UNKNOWN;
return ocio::BIT_DEPTH_UNKNOWN;
}
}
+5 -5
View File
@@ -19,11 +19,11 @@
***/
#ifndef OCIOUTILS_H
#define OCIOUTILS_H
#ifndef OAK_OCIOUTILS_H
#define OAK_OCIOUTILS_H
#include <OpenColorIO/OpenColorIO.h>
namespace OCIO = OCIO_NAMESPACE;
namespace ocio = OCIO_NAMESPACE;
#include "render/videoparams.h"
@@ -32,9 +32,9 @@ namespace olive
class OCIOUtils {
public:
static OCIO::BitDepth GetOCIOBitDepthFromPixelFormat(PixelFormat format);
static ocio::BitDepth get_ocio_bit_depth_from_pixel_format(PixelFormat format);
};
}
#endif // OCIOUTILS_H
#endif // OAK_OCIOUTILS_H
+10 -10
View File
@@ -26,25 +26,25 @@
namespace olive
{
void OIIOUtils::FrameToBuffer(const Frame *frame, OIIO::ImageBuf *buf)
void OIIOUtils::frame_to_buffer(const Frame *frame, OIIO::ImageBuf *buf)
{
buf->set_pixels(OIIO::ROI(), buf->spec().format, frame->const_data(),
OIIO::AutoStride, frame->linesize_bytes());
}
void OIIOUtils::BufferToFrame(OIIO::ImageBuf *buf, Frame *frame)
void OIIOUtils::buffer_to_frame(OIIO::ImageBuf *buf, Frame *frame)
{
buf->get_pixels(OIIO::ROI(), buf->spec().format, frame->data(),
OIIO::AutoStride, frame->linesize_bytes());
}
rational OIIOUtils::GetPixelAspectRatioFromOIIO(const OIIO::ImageSpec &spec)
Rational OIIOUtils::get_pixel_aspect_ratio_from_oiio(const OIIO::ImageSpec &spec)
{
return rational::fromDouble(
return Rational::from_double(
spec.get_float_attribute("PixelAspectRatio", 1));
}
PixelFormat OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::BASETYPE type)
PixelFormat OIIOUtils::get_format_from_oiio_basetype(OIIO::TypeDesc::BASETYPE type)
{
switch (type) {
case OIIO::TypeDesc::UNKNOWN:
@@ -65,16 +65,16 @@ PixelFormat OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::BASETYPE type)
break;
case OIIO::TypeDesc::UINT8:
return PixelFormat::U8;
return PixelFormat::u8;
case OIIO::TypeDesc::UINT16:
return PixelFormat::U16;
return PixelFormat::u16;
case OIIO::TypeDesc::HALF:
return PixelFormat::F16;
return PixelFormat::f16;
case OIIO::TypeDesc::FLOAT:
return PixelFormat::F32;
return PixelFormat::f32;
}
return PixelFormat::INVALID;
return PixelFormat::invalid;
}
}
+15 -15
View File
@@ -19,8 +19,8 @@
***/
#ifndef OIIOUTILS_H
#define OIIOUTILS_H
#ifndef OAK_OIIOUTILS_H
#define OAK_OIIOUTILS_H
#include <OpenImageIO/imagebuf.h>
#include <OpenImageIO/typedesc.h>
@@ -34,36 +34,36 @@ namespace olive
class OIIOUtils {
public:
static OIIO::TypeDesc::BASETYPE
GetOIIOBaseTypeFromFormat(PixelFormat format)
get_oiio_base_type_from_format(PixelFormat format)
{
switch (format) {
case PixelFormat::U8:
case PixelFormat::u8:
return OIIO::TypeDesc::UINT8;
case PixelFormat::U10:
case PixelFormat::u10:
return OIIO::TypeDesc::UNKNOWN;
case PixelFormat::U16:
case PixelFormat::u16:
return OIIO::TypeDesc::UINT16;
case PixelFormat::F16:
case PixelFormat::f16:
return OIIO::TypeDesc::HALF;
case PixelFormat::F32:
case PixelFormat::f32:
return OIIO::TypeDesc::FLOAT;
case PixelFormat::INVALID:
case PixelFormat::COUNT:
case PixelFormat::invalid:
case PixelFormat::count:
break;
}
return OIIO::TypeDesc::UNKNOWN;
}
static void FrameToBuffer(const Frame *frame, OIIO::ImageBuf *buf);
static void frame_to_buffer(const Frame *frame, OIIO::ImageBuf *buf);
static void BufferToFrame(OIIO::ImageBuf *buf, Frame *frame);
static void buffer_to_frame(OIIO::ImageBuf *buf, Frame *frame);
static PixelFormat GetFormatFromOIIOBasetype(OIIO::TypeDesc::BASETYPE type);
static PixelFormat get_format_from_oiio_basetype(OIIO::TypeDesc::BASETYPE type);
static rational GetPixelAspectRatioFromOIIO(const OIIO::ImageSpec &spec);
static Rational get_pixel_aspect_ratio_from_oiio(const OIIO::ImageSpec &spec);
};
}
#endif // OIIOUTILS_H
#endif // OAK_OIIOUTILS_H
+2 -2
View File
@@ -18,8 +18,8 @@
***/
#ifndef OTIOUTILS_H
#define OTIOUTILS_H
#ifndef OAK_OTIOUTILS_H
#define OAK_OTIOUTILS_H
#ifdef USE_OTIO
#include <opentimelineio/version.h>
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef POWER_H
#define POWER_H
#ifndef OAK_POWER_H
#define OAK_POWER_H
#include <stdint.h>
@@ -55,4 +55,4 @@ uint32_t floor_to_power_of_2(uint32_t x)
}
#endif // POWER_H
#endif // OAK_POWER_H
+17 -17
View File
@@ -26,7 +26,7 @@
namespace olive
{
int QtUtils::QFontMetricsWidth(QFontMetrics fm, const QString &s)
int QtUtils::q_font_metrics_width(QFontMetrics fm, const QString &s)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
return fm.width(s);
@@ -35,7 +35,7 @@ int QtUtils::QFontMetricsWidth(QFontMetrics fm, const QString &s)
#endif
}
QFrame *QtUtils::CreateHorizontalLine()
QFrame *QtUtils::create_horizontal_line()
{
QFrame *horizontal_line = new QFrame();
horizontal_line->setFrameShape(QFrame::HLine);
@@ -43,14 +43,14 @@ QFrame *QtUtils::CreateHorizontalLine()
return horizontal_line;
}
QFrame *QtUtils::CreateVerticalLine()
QFrame *QtUtils::create_vertical_line()
{
QFrame *l = CreateHorizontalLine();
QFrame *l = create_horizontal_line();
l->setFrameShape(QFrame::VLine);
return l;
}
int QtUtils::MsgBox(QWidget *parent, QMessageBox::Icon icon,
int QtUtils::msg_box(QWidget *parent, QMessageBox::Icon icon,
const QString &title, const QString &message,
QMessageBox::StandardButtons buttons)
{
@@ -72,7 +72,7 @@ int QtUtils::MsgBox(QWidget *parent, QMessageBox::Icon icon,
return b.exec();
}
QDateTime QtUtils::GetCreationDate(const QFileInfo &info)
QDateTime QtUtils::get_creation_date(const QFileInfo &info)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
return info.created();
@@ -85,12 +85,12 @@ QDateTime QtUtils::GetCreationDate(const QFileInfo &info)
#endif
}
QString QtUtils::GetFormattedDateTime(const QDateTime &dt)
QString QtUtils::get_formatted_date_time(const QDateTime &dt)
{
return dt.toString(Qt::TextDate);
}
QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
QStringList QtUtils::word_wrap_string(const QString &s, const QFontMetrics &fm,
int bounding_width)
{
QStringList list;
@@ -102,7 +102,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
QString this_line = lines.at(i);
while (this_line.size() > 1 &&
QFontMetricsWidth(fm, this_line) >= bounding_width) {
q_font_metrics_width(fm, this_line) >= bounding_width) {
int old_size = this_line.size();
int hard_break = -1;
@@ -110,7 +110,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
const QChar &char_test = this_line.at(j);
if (char_test.isSpace() || char_test == '-') {
if (QFontMetricsWidth(fm, this_line.left(j)) <
if (q_font_metrics_width(fm, this_line.left(j)) <
bounding_width) {
if (!char_test.isSpace()) {
j++;
@@ -128,7 +128,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
break;
}
} else if (hard_break == -1 &&
QFontMetricsWidth(fm, this_line.left(j)) <
q_font_metrics_width(fm, this_line.left(j)) <
bounding_width) {
// In case we can't find a better place to split, split at the earliest time the line
// goes under the width limit
@@ -157,7 +157,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
}
Qt::KeyboardModifiers
QtUtils::FlipControlAndShiftModifiers(Qt::KeyboardModifiers e)
QtUtils::flip_control_and_shift_modifiers(Qt::KeyboardModifiers e)
{
if (e & Qt::ControlModifier & Qt::ShiftModifier) {
return e;
@@ -174,7 +174,7 @@ QtUtils::FlipControlAndShiftModifiers(Qt::KeyboardModifiers e)
return e;
}
void QtUtils::SetComboBoxData(QComboBox *cb, int data)
void QtUtils::set_combo_box_data(QComboBox *cb, int data)
{
for (int i = 0; i < cb->count(); i++) {
if (cb->itemData(i).toInt() == data) {
@@ -184,7 +184,7 @@ void QtUtils::SetComboBoxData(QComboBox *cb, int data)
}
}
void QtUtils::SetComboBoxData(QComboBox *cb, const QString &data)
void QtUtils::set_combo_box_data(QComboBox *cb, const QString &data)
{
for (int i = 0; i < cb->count(); i++) {
if (cb->itemData(i).toString() == data) {
@@ -194,7 +194,7 @@ void QtUtils::SetComboBoxData(QComboBox *cb, const QString &data)
}
}
QColor QtUtils::toQColor(const core::Color &i)
QColor QtUtils::to_q_color(const core::Color &i)
{
QColor c;
@@ -210,9 +210,9 @@ QColor QtUtils::toQColor(const core::Color &i)
namespace core
{
uint qHash(const core::rational &r, uint seed)
uint qHash(const core::Rational &r, uint seed)
{
return ::qHash(r.toDouble(), seed);
return ::qHash(r.to_double(), seed);
}
uint qHash(const core::TimeRange &r, uint seed)
+19 -19
View File
@@ -19,8 +19,8 @@
***/
#ifndef QTVERSIONABSTRACTION_H
#define QTVERSIONABSTRACTION_H
#ifndef OAK_QTVERSIONABSTRACTION_H
#define OAK_QTVERSIONABSTRACTION_H
#include <olive/core/core.h>
#include <QComboBox>
@@ -42,30 +42,30 @@ public:
* latter was only introduced in 5.11+. This function wraps the latter for 5.11+ and the former for
* earlier.
*/
static int QFontMetricsWidth(QFontMetrics fm, const QString &s);
static int q_font_metrics_width(QFontMetrics fm, const QString &s);
static QFrame *CreateHorizontalLine();
static QFrame *create_horizontal_line();
static QFrame *CreateVerticalLine();
static QFrame *create_vertical_line();
static int MsgBox(QWidget *parent, QMessageBox::Icon icon,
static int msg_box(QWidget *parent, QMessageBox::Icon icon,
const QString &title, const QString &message,
QMessageBox::StandardButtons buttons = QMessageBox::Ok);
static QDateTime GetCreationDate(const QFileInfo &info);
static QDateTime get_creation_date(const QFileInfo &info);
static QString GetFormattedDateTime(const QDateTime &dt);
static QString get_formatted_date_time(const QDateTime &dt);
static QStringList WordWrapString(const QString &s, const QFontMetrics &fm,
static QStringList word_wrap_string(const QString &s, const QFontMetrics &fm,
int bounding_width);
static Qt::KeyboardModifiers
FlipControlAndShiftModifiers(Qt::KeyboardModifiers e);
flip_control_and_shift_modifiers(Qt::KeyboardModifiers e);
static void SetComboBoxData(QComboBox *cb, int data);
static void SetComboBoxData(QComboBox *cb, const QString &data);
static void set_combo_box_data(QComboBox *cb, int data);
static void set_combo_box_data(QComboBox *cb, const QString &data);
template <typename T> static T *GetParentOfType(const QObject *child)
template <typename T> static T *get_parent_of_type(const QObject *child)
{
QObject *t = child->parent();
@@ -79,12 +79,12 @@ public:
return nullptr;
}
static QColor toQColor(const core::Color &c);
static QColor to_q_color(const core::Color &c);
/**
* @brief Convert a pointer to a value that can be sent between NodeParams
*/
static QVariant PtrToValue(void *ptr)
static QVariant ptr_to_value(void *ptr)
{
return reinterpret_cast<quintptr>(ptr);
}
@@ -92,7 +92,7 @@ public:
/**
* @brief Convert a NodeParam value to a pointer of any kind
*/
template <class T> static T *ValueToPtr(const QVariant &ptr)
template <class T> static T *value_to_ptr(const QVariant &ptr)
{
return reinterpret_cast<T *>(ptr.value<quintptr>());
}
@@ -101,18 +101,18 @@ public:
namespace core
{
uint qHash(const core::rational &r, uint seed = 0);
uint qHash(const core::Rational &r, uint seed = 0);
uint qHash(const core::TimeRange &r, uint seed = 0);
}
}
Q_DECLARE_METATYPE(olive::core::rational)
Q_DECLARE_METATYPE(olive::core::Rational)
Q_DECLARE_METATYPE(olive::core::Color)
Q_DECLARE_METATYPE(olive::core::TimeRange)
Q_DECLARE_METATYPE(olive::core::Bezier)
Q_DECLARE_METATYPE(olive::core::AudioParams)
Q_DECLARE_METATYPE(olive::core::SampleBuffer)
#endif // QTVERSIONABSTRACTION_H
#endif // OAK_QTVERSIONABSTRACTION_H
+4 -4
View File
@@ -19,12 +19,12 @@
***/
#ifndef RANGE_H
#define RANGE_H
#ifndef OAK_RANGE_H
#define OAK_RANGE_H
template <typename T> bool InRange(T a, T b, T range)
template <typename T> bool in_range(T a, T b, T range)
{
return (a >= b - range && a <= b + range);
}
#endif // RANGE_H
#endif // OAK_RANGE_H
+2 -2
View File
@@ -28,7 +28,7 @@
namespace olive
{
double GetFloatRatioFromUser(QWidget *parent, const QString &title, bool *ok_in)
double get_float_ratio_from_user(QWidget *parent, const QString &title, bool *ok_in)
{
QString s;
@@ -86,7 +86,7 @@ double GetFloatRatioFromUser(QWidget *parent, const QString &title, bool *ok_in)
QCoreApplication::translate(
"RatioDialog",
"Failed to parse \"%1\" into an aspect ratio. Please format a "
"rational fraction with a ':' or a '/' separator.")
"Rational fraction with a ':' or a '/' separator.")
.arg(s),
QMessageBox::Ok);
}
+4 -4
View File
@@ -19,17 +19,17 @@
***/
#ifndef RATIODIALOG_H
#define RATIODIALOG_H
#ifndef OAK_RATIODIALOG_H
#define OAK_RATIODIALOG_H
#include <QInputDialog>
namespace olive
{
double GetFloatRatioFromUser(QWidget *parent, const QString &title,
double get_float_ratio_from_user(QWidget *parent, const QString &title,
bool *ok_in);
}
#endif // RATIODIALOG_H
#endif // OAK_RATIODIALOG_H
+3 -3
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef THREADSAFEMAP_H
#define THREADSAFEMAP_H
#ifndef OAK_THREADSAFEMAP_H
#define OAK_THREADSAFEMAP_H
#include <QMap>
#include <QMutex>
@@ -39,4 +39,4 @@ private:
QMap<K, V> map_;
};
#endif // THREADSAFEMAP_H
#endif // OAK_THREADSAFEMAP_H
+4 -4
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOHEX_H
#define TOHEX_H
#ifndef OAK_TOHEX_H
#define OAK_TOHEX_H
#include <QString>
#include <QtGlobal>
@@ -27,11 +27,11 @@
namespace olive
{
inline QString ToHex(quint64 t)
inline QString to_hex(quint64 t)
{
return QStringLiteral("%1").arg(t, 0, 16);
}
}
#endif // TOHEX_H
#endif // OAK_TOHEX_H
+3 -3
View File
@@ -19,12 +19,12 @@
***/
#ifndef UTIL_H
#define UTIL_H
#ifndef OAK_UTIL_H
#define OAK_UTIL_H
template <typename T> inline T mid(T a, T b)
{
return (a + b) * 0.5;
}
#endif // UTIL_H
#endif // OAK_UTIL_H
+2 -2
View File
@@ -27,13 +27,13 @@
namespace olive
{
bool XMLReadNextStartElement(QXmlStreamReader *reader, CancelAtom *cancel_atom)
bool xml_read_next_start_element(QXmlStreamReader *reader, CancelAtom *cancel_atom)
{
QXmlStreamReader::TokenType token;
while ((token = reader->readNext()) != QXmlStreamReader::Invalid &&
token != QXmlStreamReader::EndDocument &&
(!cancel_atom || !cancel_atom->IsCancelled())) {
(!cancel_atom || !cancel_atom->is_cancelled())) {
if (reader->isEndElement()) {
return false;
} else if (reader->isStartElement()) {
+4 -4
View File
@@ -19,8 +19,8 @@
***/
#ifndef XMLREADLOOP_H
#define XMLREADLOOP_H
#ifndef OAK_XMLREADLOOP_H
#define OAK_XMLREADLOOP_H
#include <QXmlStreamReader>
@@ -48,9 +48,9 @@ class NodeGroup;
*
* See also: https://stackoverflow.com/questions/46346450/qt-qxmlstreamreader-always-returns-premature-end-of-document-error
*/
bool XMLReadNextStartElement(QXmlStreamReader *reader,
bool xml_read_next_start_element(QXmlStreamReader *reader,
CancelAtom *cancel_atom = nullptr);
}
#endif // XMLREADLOOP_H
#endif // OAK_XMLREADLOOP_H