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
+36 -1
View File
@@ -144,4 +144,39 @@ readability-static-accessed-through-instance,
readability-static-definition-in-anonymous-namespace, readability-static-definition-in-anonymous-namespace,
readability-string-compare, readability-string-compare,
readability-uniqueptr-delete-release, readability-uniqueptr-delete-release,
readability-use-anyofallof' readability-use-anyofallof,
readability-identifier-naming'
CheckOptions:
readability-identifier-naming.ClassCase: CamelCase
readability-identifier-naming.StructCase: CamelCase
readability-identifier-naming.EnumCase: CamelCase
readability-identifier-naming.UnionCase: CamelCase
readability-identifier-naming.TypeAliasCase: CamelCase
readability-identifier-naming.TypeAliasIgnoredRegexp: '^(const_)?(reverse_)?iterator$|^const_(reference|pointer)$|^(value|size|difference|reference|pointer)_type$'
readability-identifier-naming.UsingCase: CamelCase
readability-identifier-naming.UsingIgnoredRegexp: '^(const_)?(reverse_)?iterator$|^const_(reference|pointer)$|^(value|size|difference|reference|pointer)_type$'
readability-identifier-naming.StaticVariableCase: lower_case
readability-identifier-naming.StaticVariableSuffix: _
readability-identifier-naming.TemplateParameterCase: CamelCase
readability-identifier-naming.EnumConstantCase: lower_case
readability-identifier-naming.ConstantCase: lower_case
readability-identifier-naming.ConstexprVariableCase: lower_case
readability-identifier-naming.ClassConstantCase: lower_case
readability-identifier-naming.StaticConstantCase: lower_case
readability-identifier-naming.GlobalConstantCase: lower_case
readability-identifier-naming.LocalConstantCase: lower_case
readability-identifier-naming.VariableCase: lower_case
readability-identifier-naming.ParameterCase: lower_case
readability-identifier-naming.LocalVariableCase: lower_case
readability-identifier-naming.MemberCase: lower_case
readability-identifier-naming.PrivateMemberSuffix: _
readability-identifier-naming.ProtectedMemberSuffix: _
readability-identifier-naming.FunctionCase: lower_case
readability-identifier-naming.ClassMethodCase: lower_case
readability-identifier-naming.GlobalFunctionCase: lower_case
readability-identifier-naming.NamespaceCase: lower_case
readability-identifier-naming.MacroDefinitionIgnoredRegexp: '.*'
# Qt and third-party (OFX) virtual overrides / framework callbacks keep
# their original names — renaming them would break the override.
readability-identifier-naming.FunctionIgnoredRegexp: '^(.*Event|eventFilter|sizeHint|minimumSizeHint|heightForWidth|hasHeightForWidth|initializeGL|resizeGL|paintGL|readData|writeData|readLineData|itemChange|boundingRect|sceneEvent|drawForeground|drawBackground|createEditor|setEditorData|setModelData|updateEditorGeometry|editorEvent|canFetchMore|fetchMore|mimeData|mimeTypes|dropMimeData|canDropMimeData|supportedDropActions|supportedDragActions|roleNames|connectNotify|disconnectNotify|initStyleOption|isSequential|showPopup|hidePopup|inputMethodQuery|viewportEvent|scrollContentsBy|updateGeometries|keyboardSearch|startDrag|viewOptions|setSelection|currentChanged|selectionChanged|createWidget|deleteWidget|createMimeDataFromSelection|canInsertFromMimeData|insertFromMimeData|dropIndicatorPosition|qHash|get[A-Z].*|set[A-Z].*|can[A-Z].*|calc[A-Z].*|is[A-Z].*|.*Action|new.*|addParam|multiThread.*|mutex.*|timeLine.*|editBegin|editEnd|freeMem|copyFrom|deleteKey|deleteAllKeys|makeDescriptor|initDescriptor|initParamDescriptor|loadFromPlugin|examineOutArgs|paramChangedByPlugin|saveXML|verifyMagic|pluginSupported|loadingStatus|confirmPlugin|callEntry|mainEntry|deriveV|integrateV|getV|setV|swapBuffers|loadTexture|flushOpenGLResources|clearPersistentMessage|progressStart|progressEnd|progressUpdate|beginXmlParsing|endXmlParsing|xmlCharacterHandler|xmlElementBegin|xmlElementEnd)$'
readability-identifier-naming.ClassMethodIgnoredRegexp: '^(.*Event|eventFilter|sizeHint|minimumSizeHint|heightForWidth|hasHeightForWidth|initializeGL|resizeGL|paintGL|readData|writeData|readLineData|itemChange|boundingRect|sceneEvent|drawForeground|drawBackground|createEditor|setEditorData|setModelData|updateEditorGeometry|editorEvent|canFetchMore|fetchMore|mimeData|mimeTypes|dropMimeData|canDropMimeData|supportedDropActions|supportedDragActions|roleNames|connectNotify|disconnectNotify|initStyleOption|isSequential|showPopup|hidePopup|inputMethodQuery|viewportEvent|scrollContentsBy|updateGeometries|keyboardSearch|startDrag|viewOptions|setSelection|currentChanged|selectionChanged|createWidget|deleteWidget|createMimeDataFromSelection|canInsertFromMimeData|insertFromMimeData|dropIndicatorPosition|get[A-Z].*|set[A-Z].*|can[A-Z].*|calc[A-Z].*|is[A-Z].*|.*Action|new.*|addParam|multiThread.*|mutex.*|timeLine.*|editBegin|editEnd|freeMem|copyFrom|deleteKey|deleteAllKeys|makeDescriptor|initDescriptor|initParamDescriptor|loadFromPlugin|examineOutArgs|paramChangedByPlugin|saveXML|verifyMagic|pluginSupported|loadingStatus|confirmPlugin|callEntry|mainEntry|deriveV|integrateV|getV|setV|swapBuffers|loadTexture|flushOpenGLResources|clearPersistentMessage|progressStart|progressEnd|progressUpdate|beginXmlParsing|endXmlParsing|xmlCharacterHandler|xmlElementBegin|xmlElementEnd)$'
+10 -7
View File
@@ -20,12 +20,15 @@ submitted should abide by the following standards:
with the following project-specific exceptions and notes: with the following project-specific exceptions and notes:
* Indentation uses **tabs**, not spaces. * Indentation uses **tabs**, not spaces.
* Documentation comments should use **Javadoc-style** (`/** ... */`) where appropriate. * Documentation comments should use **Javadoc-style** (`/** ... */`) where appropriate.
* The naming rules below are retained from the original Olive codebase: * Naming rules (enforced by `readability-identifier-naming` in `.clang-tidy`):
* `lowercase_underscored_variable_names` * Types (`class`, `struct`, `enum`, type aliases, template parameters): `PascalCase`
* `lowercase_underscored_functions()` or `SentenceCaseFunctions()` * Functions, variables, member variables: `snake_case`
* `class SentenceCaseClassesAndStructs {}` * Private/protected members: trailing underscore, `class_member_variables_`
* `kSentenceCaseConstants` prepended with a lowercase `k` * Constants and enum values: `snake_case` (e.g. `k_dry_run_interval`, `k_linear`); `ALL_CAPS` is reserved for macros — save the fear for things that are actually dangerous
* `UPPERCASE_UNDERSCORED_MACROS` for variables or same style as functions for macro functions * Macros: `OAK_ALL_CAPS` (project prefix), and avoid them when a constant or function will do
* `class_member_variables_` end with a `_` * File names: all lowercase, `mystring.h` / `mystring.cpp`
* Namespaces: short `snake_case`
* Getters: same name as the private member without the trailing underscore (`foo_``foo()`); setters: `set_foo()`
* Exception: Qt and third-party (e.g. OpenFX) virtual overrides and framework callbacks keep their original names (`paintEvent`, `getParams`, ...) — renaming them would break the override
* 100 column limit (where it doesn't impair readability) * 100 column limit (where it doesn't impair readability)
* Unix line endings (only LF no CRLF) * Unix line endings (only LF no CRLF)
+9 -9
View File
@@ -29,7 +29,7 @@ namespace olive
{ {
AudioLevelMeter::Stats AudioLevelMeter::Stats
AudioLevelMeter::AnalyzeSampleBuffer(const core::SampleBuffer &samples) AudioLevelMeter::analyze_sample_buffer(const core::SampleBuffer &samples)
{ {
Stats stats; Stats stats;
@@ -63,9 +63,9 @@ AudioLevelMeter::AnalyzeSampleBuffer(const core::SampleBuffer &samples)
ChannelStats channel_stats; ChannelStats channel_stats;
channel_stats.peak_linear = peak; channel_stats.peak_linear = peak;
channel_stats.peak_db = LinearToDb(peak); channel_stats.peak_db = linear_to_db(peak);
channel_stats.rms_linear = rms; channel_stats.rms_linear = rms;
channel_stats.rms_db = LinearToDb(rms); channel_stats.rms_db = linear_to_db(rms);
channel_stats.vu_db = channel_stats.rms_db; channel_stats.vu_db = channel_stats.rms_db;
stats.channels[channel] = channel_stats; stats.channels[channel] = channel_stats;
@@ -76,24 +76,24 @@ AudioLevelMeter::AnalyzeSampleBuffer(const core::SampleBuffer &samples)
stats.silence = qFuzzyIsNull(stats.max_peak_linear); stats.silence = qFuzzyIsNull(stats.max_peak_linear);
stats.integrated_lufs = stats.integrated_lufs =
PowerToLufs(total_square / static_cast<double>(total_samples)); power_to_lufs(total_square / static_cast<double>(total_samples));
return stats; return stats;
} }
double AudioLevelMeter::LinearToDb(double linear) double AudioLevelMeter::linear_to_db(double linear)
{ {
if (linear <= 0.0) { if (linear <= 0.0) {
return Decibel::MINIMUM; return Decibel::minimum;
} }
return Decibel::fromLinear(linear); return Decibel::from_linear(linear);
} }
double AudioLevelMeter::PowerToLufs(double mean_square) double AudioLevelMeter::power_to_lufs(double mean_square)
{ {
if (mean_square <= 0.0) { if (mean_square <= 0.0) {
return Decibel::MINIMUM; return Decibel::minimum;
} }
// BS.1770 loudness uses K-weighted mean square. This first pass stores the // BS.1770 loudness uses K-weighted mean square. This first pass stores the
+6 -6
View File
@@ -18,8 +18,8 @@
***/ ***/
#ifndef AUDIOLEVELMETER_H #ifndef OAK_AUDIOLEVELMETER_H
#define AUDIOLEVELMETER_H #define OAK_AUDIOLEVELMETER_H
#include <QVector> #include <QVector>
@@ -45,13 +45,13 @@ public:
bool silence = true; bool silence = true;
}; };
static Stats AnalyzeSampleBuffer(const core::SampleBuffer &samples); static Stats analyze_sample_buffer(const core::SampleBuffer &samples);
private: private:
static double LinearToDb(double linear); static double linear_to_db(double linear);
static double PowerToLufs(double mean_square); static double power_to_lufs(double mean_square);
}; };
} }
#endif // AUDIOLEVELMETER_H #endif // OAK_AUDIOLEVELMETER_H
+68 -68
View File
@@ -34,14 +34,14 @@ namespace olive
AudioManager *AudioManager::instance_ = nullptr; AudioManager *AudioManager::instance_ = nullptr;
void AudioManager::CreateInstance() void AudioManager::create_instance()
{ {
if (instance_ == nullptr) { if (instance_ == nullptr) {
instance_ = new AudioManager(); instance_ = new AudioManager();
} }
} }
void AudioManager::DestroyInstance() void AudioManager::destroy_instance()
{ {
delete instance_; delete instance_;
instance_ = nullptr; instance_ = nullptr;
@@ -52,18 +52,18 @@ AudioManager *AudioManager::instance()
return instance_; return instance_;
} }
void AudioManager::SetOutputNotifyInterval(int n) void AudioManager::set_output_notify_interval(int n)
{ {
output_buffer_->set_notify_interval(n); output_buffer_->set_notify_interval(n);
} }
int OutputCallback(const void *input, void *output, unsigned long frameCount, int output_callback(const void *input, void *output, unsigned long frame_count,
const PaStreamCallbackTimeInfo *timeInfo, const PaStreamCallbackTimeInfo *time_info,
PaStreamCallbackFlags statusFlags, void *userData) PaStreamCallbackFlags status_flags, void *user_data)
{ {
PreviewAudioDevice *device = static_cast<PreviewAudioDevice *>(userData); PreviewAudioDevice *device = static_cast<PreviewAudioDevice *>(user_data);
qint64 max_read = frameCount * device->bytes_per_frame(); qint64 max_read = frame_count * device->bytes_per_frame();
qint64 read_count = qint64 read_count =
device->read(reinterpret_cast<char *>(output), max_read); device->read(reinterpret_cast<char *>(output), max_read);
if (read_count < max_read) { if (read_count < max_read) {
@@ -74,23 +74,23 @@ int OutputCallback(const void *input, void *output, unsigned long frameCount,
return paContinue; return paContinue;
} }
int InputCallback(const void *input, void *output, unsigned long frameCount, int input_callback(const void *input, void *output, unsigned long frame_count,
const PaStreamCallbackTimeInfo *timeInfo, const PaStreamCallbackTimeInfo *time_info,
PaStreamCallbackFlags statusFlags, void *userData) PaStreamCallbackFlags status_flags, void *user_data)
{ {
FFmpegEncoder *f = static_cast<FFmpegEncoder *>(userData); FFmpegEncoder *f = static_cast<FFmpegEncoder *>(user_data);
AudioParams our_params = f->params().audio_params(); AudioParams our_params = f->params().audio_params();
our_params.set_format( our_params.set_format(
f->params().audio_params().format().to_packed_equivalent()); f->params().audio_params().format().to_packed_equivalent());
f->WriteAudioData(our_params, reinterpret_cast<const uint8_t **>(&input), f->write_audio_data(our_params, reinterpret_cast<const uint8_t **>(&input),
frameCount); frame_count);
return paContinue; return paContinue;
} }
bool AudioManager::PushToOutput(const AudioParams &params, bool AudioManager::push_to_output(const AudioParams &params,
const QByteArray &samples, QString *error) const QByteArray &samples, QString *error)
{ {
if (output_device_ == paNoDevice) { if (output_device_ == paNoDevice) {
@@ -102,14 +102,14 @@ bool AudioManager::PushToOutput(const AudioParams &params,
if (output_params_ != params || output_stream_ == nullptr) { if (output_params_ != params || output_stream_ == nullptr) {
output_params_ = params; output_params_ = params;
CloseOutputStream(); close_output_stream();
PaStreamParameters p = GetPortAudioParams(params, output_device_); PaStreamParameters p = get_port_audio_params(params, output_device_);
PaError r = Pa_OpenStream(&output_stream_, nullptr, &p, PaError r = Pa_OpenStream(&output_stream_, nullptr, &p,
output_params_.sample_rate(), output_params_.sample_rate(),
paFramesPerBufferUnspecified, paNoFlag, paFramesPerBufferUnspecified, paNoFlag,
OutputCallback, output_buffer_); output_callback, output_buffer_);
if (r != paNoError) { if (r != paNoError) {
// Unhandled error // Unhandled error
//qCritical() << "Failed to open output stream:" << Pa_GetErrorText(r); //qCritical() << "Failed to open output stream:" << Pa_GetErrorText(r);
@@ -136,59 +136,59 @@ bool AudioManager::PushToOutput(const AudioParams &params,
return true; return true;
} }
void AudioManager::ClearBufferedOutput() void AudioManager::clear_buffered_output()
{ {
output_buffer_->clear(); output_buffer_->clear();
} }
PaSampleFormat AudioManager::GetPortAudioSampleFormat(SampleFormat fmt) PaSampleFormat AudioManager::get_port_audio_sample_format(SampleFormat fmt)
{ {
switch (fmt) { switch (fmt) {
case SampleFormat::U8: case SampleFormat::u8:
case SampleFormat::U8P: case SampleFormat::u8_p:
return paUInt8; return paUInt8;
case SampleFormat::S16: case SampleFormat::s16:
case SampleFormat::S16P: case SampleFormat::s16_p:
return paInt16; return paInt16;
case SampleFormat::S32: case SampleFormat::s32:
case SampleFormat::S32P: case SampleFormat::s32_p:
return paInt32; return paInt32;
case SampleFormat::F32: case SampleFormat::f32:
case SampleFormat::F32P: case SampleFormat::f32_p:
return paFloat32; return paFloat32;
case SampleFormat::S64: case SampleFormat::s64:
case SampleFormat::S64P: case SampleFormat::s64_p:
case SampleFormat::F64: case SampleFormat::f64:
case SampleFormat::F64P: case SampleFormat::f64_p:
case SampleFormat::INVALID: case SampleFormat::invalid:
case SampleFormat::COUNT: case SampleFormat::count:
break; break;
} }
return 0; return 0;
} }
void AudioManager::CloseOutputStream() void AudioManager::close_output_stream()
{ {
if (output_stream_) { if (output_stream_) {
if (Pa_IsStreamActive(output_stream_)) { if (Pa_IsStreamActive(output_stream_)) {
StopOutput(); stop_output();
} }
Pa_CloseStream(output_stream_); Pa_CloseStream(output_stream_);
output_stream_ = nullptr; output_stream_ = nullptr;
} }
} }
void AudioManager::StopOutput() void AudioManager::stop_output()
{ {
// Abort the stream so playback stops immediately // Abort the stream so playback stops immediately
if (output_stream_) { if (output_stream_) {
Pa_AbortStream(output_stream_); Pa_AbortStream(output_stream_);
ClearBufferedOutput(); clear_buffered_output();
} }
} }
void AudioManager::SetOutputDevice(PaDeviceIndex device) void AudioManager::set_output_device(PaDeviceIndex device)
{ {
if (device == paNoDevice) { if (device == paNoDevice) {
qInfo() << "No output device found"; qInfo() << "No output device found";
@@ -201,12 +201,12 @@ void AudioManager::SetOutputDevice(PaDeviceIndex device)
output_device_ = device; output_device_ = device;
CloseOutputStream(); close_output_stream();
emit OutputParamsChanged(); emit output_params_changed();
} }
void AudioManager::SetInputDevice(PaDeviceIndex device) void AudioManager::set_input_device(PaDeviceIndex device)
{ {
if (device == paNoDevice) { if (device == paNoDevice) {
qInfo() << "No input device found"; qInfo() << "No input device found";
@@ -220,14 +220,14 @@ void AudioManager::SetInputDevice(PaDeviceIndex device)
input_device_ = device; input_device_ = device;
} }
void AudioManager::HardReset() void AudioManager::hard_reset()
{ {
CloseOutputStream(); close_output_stream();
Pa_Terminate(); Pa_Terminate();
Pa_Initialize(); Pa_Initialize();
} }
bool AudioManager::StartRecording(const EncodingParams &params, bool AudioManager::start_recording(const EncodingParams &params,
QString *error_str) QString *error_str)
{ {
if (input_device_ == paNoDevice) { if (input_device_ == paNoDevice) {
@@ -235,18 +235,18 @@ bool AudioManager::StartRecording(const EncodingParams &params,
} }
input_encoder_ = new FFmpegEncoder(params); input_encoder_ = new FFmpegEncoder(params);
if (!input_encoder_->Open()) { if (!input_encoder_->open()) {
qCritical() << "Failed to open encoder for recording"; qCritical() << "Failed to open encoder for recording";
return false; return false;
} }
PaStreamParameters p = PaStreamParameters p =
GetPortAudioParams(params.audio_params(), input_device_); get_port_audio_params(params.audio_params(), input_device_);
PaError r = Pa_OpenStream(&input_stream_, &p, nullptr, PaError r = Pa_OpenStream(&input_stream_, &p, nullptr,
params.audio_params().sample_rate(), params.audio_params().sample_rate(),
paFramesPerBufferUnspecified, paNoFlag, paFramesPerBufferUnspecified, paNoFlag,
InputCallback, input_encoder_); input_callback, input_encoder_);
if (r == paNoError) { if (r == paNoError) {
//const PaStreamInfo* info = Pa_GetStreamInfo(input_stream_); //const PaStreamInfo* info = Pa_GetStreamInfo(input_stream_);
r = Pa_StartStream(input_stream_); r = Pa_StartStream(input_stream_);
@@ -259,11 +259,11 @@ bool AudioManager::StartRecording(const EncodingParams &params,
*error_str = Pa_GetErrorText(r); *error_str = Pa_GetErrorText(r);
} }
StopRecording(); stop_recording();
return false; return false;
} }
void AudioManager::StopRecording() void AudioManager::stop_recording()
{ {
if (input_stream_) { if (input_stream_) {
if (Pa_IsStreamActive(input_stream_)) { if (Pa_IsStreamActive(input_stream_)) {
@@ -275,14 +275,14 @@ void AudioManager::StopRecording()
} }
if (input_encoder_) { if (input_encoder_) {
input_encoder_->Close(); input_encoder_->close();
delete input_encoder_; delete input_encoder_;
input_encoder_ = nullptr; input_encoder_ = nullptr;
} }
} }
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
static bool IsPreferredLinuxAudioHostApi(const PaHostApiInfo *info) static bool is_preferred_linux_audio_host_api(const PaHostApiInfo *info)
{ {
if (!info) { if (!info) {
return false; return false;
@@ -294,7 +294,7 @@ static bool IsPreferredLinuxAudioHostApi(const PaHostApiInfo *info)
name.contains(QStringLiteral("PulseAudio"), Qt::CaseInsensitive); name.contains(QStringLiteral("PulseAudio"), Qt::CaseInsensitive);
} }
static PaDeviceIndex GetPreferredLinuxAudioDevice(bool is_output_device) static PaDeviceIndex get_preferred_linux_audio_device(bool is_output_device)
{ {
// Prefer sound servers that provide mixing and desktop integration // Prefer sound servers that provide mixing and desktop integration
// (PipeWire, JACK, PulseAudio) over plain ALSA defaults, which often // (PipeWire, JACK, PulseAudio) over plain ALSA defaults, which often
@@ -328,16 +328,16 @@ static PaDeviceIndex GetPreferredLinuxAudioDevice(bool is_output_device)
} }
#endif #endif
PaDeviceIndex AudioManager::FindConfigDeviceByName(bool is_output_device) PaDeviceIndex AudioManager::find_config_device_by_name(bool is_output_device)
{ {
QString entry = is_output_device ? QStringLiteral("AudioOutput") : QString entry = is_output_device ? QStringLiteral("AudioOutput") :
QStringLiteral("AudioInput"); QStringLiteral("AudioInput");
return FindDeviceByName(OLIVE_CONFIG_STR(entry).toString(), return find_device_by_name(OAK_CONFIG_STR(entry).toString(),
is_output_device); is_output_device);
} }
PaDeviceIndex AudioManager::FindDeviceByName(const QString &s, PaDeviceIndex AudioManager::find_device_by_name(const QString &s,
bool is_output_device) bool is_output_device)
{ {
PaDeviceIndex exact_match = paNoDevice; PaDeviceIndex exact_match = paNoDevice;
@@ -367,7 +367,7 @@ PaDeviceIndex AudioManager::FindDeviceByName(const QString &s,
if (matched_info) { if (matched_info) {
const PaHostApiInfo *host_api = const PaHostApiInfo *host_api =
Pa_GetHostApiInfo(matched_info->hostApi); Pa_GetHostApiInfo(matched_info->hostApi);
if (IsPreferredLinuxAudioHostApi(host_api)) { if (is_preferred_linux_audio_host_api(host_api)) {
// Keep an explicit choice that already uses a preferred API. // Keep an explicit choice that already uses a preferred API.
return exact_match; return exact_match;
} }
@@ -375,7 +375,7 @@ PaDeviceIndex AudioManager::FindDeviceByName(const QString &s,
// Upgrade a non-preferred (e.g. ALSA) match to a preferred backend // Upgrade a non-preferred (e.g. ALSA) match to a preferred backend
// when one is available. // when one is available.
PaDeviceIndex preferred = PaDeviceIndex preferred =
GetPreferredLinuxAudioDevice(is_output_device); get_preferred_linux_audio_device(is_output_device);
if (preferred != paNoDevice) { if (preferred != paNoDevice) {
qInfo() << "Overriding saved audio device" << s qInfo() << "Overriding saved audio device" << s
<< "with preferred Linux audio device" << "with preferred Linux audio device"
@@ -388,7 +388,7 @@ PaDeviceIndex AudioManager::FindDeviceByName(const QString &s,
} }
} }
return GetPreferredLinuxAudioDevice(is_output_device); return get_preferred_linux_audio_device(is_output_device);
#else #else
if (exact_match != paNoDevice) { if (exact_match != paNoDevice) {
return exact_match; return exact_match;
@@ -399,7 +399,7 @@ PaDeviceIndex AudioManager::FindDeviceByName(const QString &s,
#endif #endif
} }
PaStreamParameters AudioManager::GetPortAudioParams(const AudioParams &params, PaStreamParameters AudioManager::get_port_audio_params(const AudioParams &params,
PaDeviceIndex device) PaDeviceIndex device)
{ {
PaStreamParameters p; PaStreamParameters p;
@@ -407,7 +407,7 @@ PaStreamParameters AudioManager::GetPortAudioParams(const AudioParams &params,
p.channelCount = params.channel_count(); p.channelCount = params.channel_count();
p.device = device; p.device = device;
p.hostApiSpecificStreamInfo = nullptr; p.hostApiSpecificStreamInfo = nullptr;
p.sampleFormat = GetPortAudioSampleFormat(params.format()); p.sampleFormat = get_port_audio_sample_format(params.format());
if (device >= 0 && device < Pa_GetDeviceCount()) { if (device >= 0 && device < Pa_GetDeviceCount()) {
p.suggestedLatency = Pa_GetDeviceInfo(device)->defaultLowOutputLatency; p.suggestedLatency = Pa_GetDeviceInfo(device)->defaultLowOutputLatency;
@@ -432,24 +432,24 @@ AudioManager::AudioManager()
Pa_Initialize(); Pa_Initialize();
// Get device from config // Get device from config
PaDeviceIndex output_device = FindConfigDeviceByName(true); PaDeviceIndex output_device = find_config_device_by_name(true);
PaDeviceIndex input_device = FindConfigDeviceByName(false); PaDeviceIndex input_device = find_config_device_by_name(false);
qDebug() << "AudioManager: selected output device index=" << output_device qDebug() << "AudioManager: selected output device index=" << output_device
<< "input device index=" << input_device; << "input device index=" << input_device;
SetOutputDevice(output_device); set_output_device(output_device);
SetInputDevice(input_device); set_input_device(input_device);
output_buffer_ = new PreviewAudioDevice(this); output_buffer_ = new PreviewAudioDevice(this);
output_buffer_->open(PreviewAudioDevice::ReadWrite); output_buffer_->open(PreviewAudioDevice::ReadWrite);
connect(output_buffer_, &PreviewAudioDevice::Notify, this, connect(output_buffer_, &PreviewAudioDevice::notify, this,
&AudioManager::OutputNotify); &AudioManager::output_notify);
} }
AudioManager::~AudioManager() AudioManager::~AudioManager()
{ {
CloseOutputStream(); close_output_stream();
Pa_Terminate(); Pa_Terminate();
} }
+23 -23
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef AUDIOMANAGER_H #ifndef OAK_AUDIOMANAGER_H
#define AUDIOMANAGER_H #define OAK_AUDIOMANAGER_H
#include <memory> #include <memory>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
@@ -46,61 +46,61 @@ namespace olive
class AudioManager : public QObject { class AudioManager : public QObject {
Q_OBJECT Q_OBJECT
public: public:
static void CreateInstance(); static void create_instance();
static void DestroyInstance(); static void destroy_instance();
static AudioManager *instance(); static AudioManager *instance();
void SetOutputNotifyInterval(int n); void set_output_notify_interval(int n);
bool PushToOutput(const AudioParams &params, const QByteArray &samples, bool push_to_output(const AudioParams &params, const QByteArray &samples,
QString *error = nullptr); QString *error = nullptr);
void ClearBufferedOutput(); void clear_buffered_output();
void StopOutput(); void stop_output();
PaDeviceIndex GetOutputDevice() const PaDeviceIndex get_output_device() const
{ {
return output_device_; return output_device_;
} }
PaDeviceIndex GetInputDevice() const PaDeviceIndex get_input_device() const
{ {
return input_device_; return input_device_;
} }
void SetOutputDevice(PaDeviceIndex device); void set_output_device(PaDeviceIndex device);
void SetInputDevice(PaDeviceIndex device); void set_input_device(PaDeviceIndex device);
void HardReset(); void hard_reset();
bool StartRecording(const EncodingParams &params, bool start_recording(const EncodingParams &params,
QString *error_str = nullptr); QString *error_str = nullptr);
void StopRecording(); void stop_recording();
static PaDeviceIndex FindConfigDeviceByName(bool is_output_device); static PaDeviceIndex find_config_device_by_name(bool is_output_device);
static PaDeviceIndex FindDeviceByName(const QString &s, static PaDeviceIndex find_device_by_name(const QString &s,
bool is_output_device); bool is_output_device);
static PaStreamParameters GetPortAudioParams(const AudioParams &p, static PaStreamParameters get_port_audio_params(const AudioParams &p,
PaDeviceIndex device); PaDeviceIndex device);
signals: signals:
void OutputNotify(); void output_notify();
void OutputParamsChanged(); void output_params_changed();
private: private:
AudioManager(); AudioManager();
virtual ~AudioManager() override; virtual ~AudioManager() override;
static PaSampleFormat GetPortAudioSampleFormat(SampleFormat fmt); static PaSampleFormat get_port_audio_sample_format(SampleFormat fmt);
void CloseOutputStream(); void close_output_stream();
static AudioManager *instance_; static AudioManager *instance_;
@@ -117,4 +117,4 @@ private:
} }
#endif // AUDIOMANAGER_H #endif // OAK_AUDIOMANAGER_H
+12 -12
View File
@@ -38,7 +38,7 @@ namespace olive
* If the mask is zero, fall back to a default layout derived from the * If the mask is zero, fall back to a default layout derived from the
* channel count (stereo when unknown). * channel count (stereo when unknown).
*/ */
static AudioParams FixChannelLayout(const AudioParams &params) static AudioParams fix_channel_layout(const AudioParams &params)
{ {
AudioParams result = params; AudioParams result = params;
@@ -66,10 +66,10 @@ AudioProcessor::AudioProcessor()
AudioProcessor::~AudioProcessor() AudioProcessor::~AudioProcessor()
{ {
Close(); close();
} }
bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to, bool AudioProcessor::open(const AudioParams &from, const AudioParams &to,
double tempo) double tempo)
{ {
if (graph_) { if (graph_) {
@@ -77,8 +77,8 @@ bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to,
return false; return false;
} }
AudioParams from_fixed = FixChannelLayout(from); AudioParams from_fixed = fix_channel_layout(from);
AudioParams to_fixed = FixChannelLayout(to); AudioParams to_fixed = fix_channel_layout(to);
qDebug() << "AudioProcessor::Open: from sample_rate=" qDebug() << "AudioProcessor::Open: from sample_rate="
<< from_fixed.sample_rate() << "channels=" << from_fixed.sample_rate() << "channels="
@@ -92,13 +92,13 @@ bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to,
config.in_sample_rate = from_fixed.sample_rate(); config.in_sample_rate = from_fixed.sample_rate();
config.in_channel_layout_mask = from_fixed.channel_layout(); config.in_channel_layout_mask = from_fixed.channel_layout();
config.in_sample_format = config.in_sample_format =
FFmpegUtils::GetFFmpegSampleFormat(from_fixed.format()); FFmpegUtils::get_f_fmpeg_sample_format(from_fixed.format());
config.in_channels = from_fixed.channel_count(); config.in_channels = from_fixed.channel_count();
config.out_sample_rate = to_fixed.sample_rate(); config.out_sample_rate = to_fixed.sample_rate();
config.out_channel_layout_mask = to_fixed.channel_layout(); config.out_channel_layout_mask = to_fixed.channel_layout();
config.out_sample_format = config.out_sample_format =
FFmpegUtils::GetFFmpegSampleFormat(to_fixed.format()); FFmpegUtils::get_f_fmpeg_sample_format(to_fixed.format());
config.out_channels = to_fixed.channel_count(); config.out_channels = to_fixed.channel_count();
config.out_is_planar = to_fixed.format().is_planar() ? 1 : 0; config.out_is_planar = to_fixed.format().is_planar() ? 1 : 0;
@@ -113,7 +113,7 @@ bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to,
out_frame_ = fb_frame_alloc(); out_frame_ = fb_frame_alloc();
if (!out_frame_) { if (!out_frame_) {
qCritical() << "Failed to allocate output frame"; qCritical() << "Failed to allocate output frame";
Close(); close();
return false; return false;
} }
@@ -123,7 +123,7 @@ bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to,
return true; return true;
} }
void AudioProcessor::Close() void AudioProcessor::close()
{ {
if (graph_) { if (graph_) {
fb_audio_graph_free(&graph_); fb_audio_graph_free(&graph_);
@@ -134,10 +134,10 @@ void AudioProcessor::Close()
} }
} }
int AudioProcessor::Convert(float **in, int nb_in_samples, int AudioProcessor::convert(float **in, int nb_in_samples,
AudioProcessor::Buffer *output) AudioProcessor::Buffer *output)
{ {
if (!IsOpen()) { if (!is_open()) {
qCritical() << "Tried to convert on closed processor"; qCritical() << "Tried to convert on closed processor";
return -1; return -1;
} }
@@ -197,7 +197,7 @@ int AudioProcessor::Convert(float **in, int nb_in_samples,
return r; return r;
} }
void AudioProcessor::Flush() void AudioProcessor::flush()
{ {
int r = fb_audio_graph_push(graph_, nullptr, 0); int r = fb_audio_graph_push(graph_, nullptr, 0);
if (r < 0) { if (r < 0) {
+8 -8
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef AUDIOPROCESSOR_H #ifndef OAK_AUDIOPROCESSOR_H
#define AUDIOPROCESSOR_H #define OAK_AUDIOPROCESSOR_H
#include <inttypes.h> #include <inttypes.h>
#include <olive/core/core.h> #include <olive/core/core.h>
@@ -43,20 +43,20 @@ public:
DISABLE_COPY_MOVE(AudioProcessor) DISABLE_COPY_MOVE(AudioProcessor)
bool Open(const AudioParams &from, const AudioParams &to, bool open(const AudioParams &from, const AudioParams &to,
double tempo = 1.0); double tempo = 1.0);
void Close(); void close();
bool IsOpen() const bool is_open() const
{ {
return graph_; return graph_;
} }
using Buffer = QVector<QByteArray>; using Buffer = QVector<QByteArray>;
int Convert(float **in, int nb_in_samples, AudioProcessor::Buffer *output); int convert(float **in, int nb_in_samples, AudioProcessor::Buffer *output);
void Flush(); void flush();
const AudioParams &from() const const AudioParams &from() const
{ {
@@ -79,4 +79,4 @@ private:
} }
#endif // AUDIOPROCESSOR_H #endif // OAK_AUDIOPROCESSOR_H
+7 -7
View File
@@ -23,9 +23,9 @@
namespace olive namespace olive
{ {
AudioSynchronizer::Placement AudioSynchronizer::PlaceBySourceTime( AudioSynchronizer::Placement AudioSynchronizer::place_by_source_time(
const SourceClip &reference, const SourceClip &candidate, const SourceClip &reference, const SourceClip &candidate,
const core::rational &reference_timeline_in) const core::Rational &reference_timeline_in)
{ {
Placement placement; Placement placement;
if (!reference.has_source_start_time || !candidate.has_source_start_time || if (!reference.has_source_start_time || !candidate.has_source_start_time ||
@@ -34,9 +34,9 @@ AudioSynchronizer::Placement AudioSynchronizer::PlaceBySourceTime(
return placement; return placement;
} }
const core::rational reference_head_source = const core::Rational reference_head_source =
reference.source_start_time + reference.media_in; reference.source_start_time + reference.media_in;
const core::rational candidate_head_source = const core::Rational candidate_head_source =
candidate.source_start_time + candidate.media_in; candidate.source_start_time + candidate.media_in;
placement.timeline_in = placement.timeline_in =
@@ -45,8 +45,8 @@ AudioSynchronizer::Placement AudioSynchronizer::PlaceBySourceTime(
return placement; return placement;
} }
AudioSynchronizer::Placement AudioSynchronizer::PlaceByWaveformOffset( AudioSynchronizer::Placement AudioSynchronizer::place_by_waveform_offset(
const core::rational &reference_timeline_in, const core::Rational &reference_timeline_in,
int64_t candidate_offset_samples, int sample_rate) int64_t candidate_offset_samples, int sample_rate)
{ {
Placement placement; Placement placement;
@@ -55,7 +55,7 @@ AudioSynchronizer::Placement AudioSynchronizer::PlaceByWaveformOffset(
} }
placement.timeline_in = reference_timeline_in + placement.timeline_in = reference_timeline_in +
core::rational::fromDouble( core::Rational::from_double(
static_cast<double>(candidate_offset_samples) / static_cast<double>(candidate_offset_samples) /
static_cast<double>(sample_rate)); static_cast<double>(sample_rate));
placement.valid = !placement.timeline_in.isNaN(); placement.valid = !placement.timeline_in.isNaN();
+9 -9
View File
@@ -18,8 +18,8 @@
***/ ***/
#ifndef AUDIOSYNCHRONIZER_H #ifndef OAK_AUDIOSYNCHRONIZER_H
#define AUDIOSYNCHRONIZER_H #define OAK_AUDIOSYNCHRONIZER_H
#include <cstdint> #include <cstdint>
@@ -31,25 +31,25 @@ namespace olive
class AudioSynchronizer { class AudioSynchronizer {
public: public:
struct SourceClip { struct SourceClip {
core::rational source_start_time; core::Rational source_start_time;
core::rational media_in; core::Rational media_in;
bool has_source_start_time = false; bool has_source_start_time = false;
}; };
struct Placement { struct Placement {
core::rational timeline_in; core::Rational timeline_in;
bool valid = false; bool valid = false;
}; };
static Placement static Placement
PlaceBySourceTime(const SourceClip &reference, const SourceClip &candidate, place_by_source_time(const SourceClip &reference, const SourceClip &candidate,
const core::rational &reference_timeline_in); const core::Rational &reference_timeline_in);
static Placement static Placement
PlaceByWaveformOffset(const core::rational &reference_timeline_in, place_by_waveform_offset(const core::Rational &reference_timeline_in,
int64_t candidate_offset_samples, int sample_rate); int64_t candidate_offset_samples, int sample_rate);
}; };
} }
#endif // AUDIOSYNCHRONIZER_H #endif // OAK_AUDIOSYNCHRONIZER_H
+71 -71
View File
@@ -29,19 +29,19 @@
namespace olive namespace olive
{ {
const rational AudioVisualWaveform::kMinimumSampleRate = rational(1, 8); const Rational AudioVisualWaveform::k_minimum_sample_rate = Rational(1, 8);
const rational AudioVisualWaveform::kMaximumSampleRate = 1024; const Rational AudioVisualWaveform::k_maximum_sample_rate = 1024;
AudioVisualWaveform::AudioVisualWaveform() AudioVisualWaveform::AudioVisualWaveform()
: channels_(0) : channels_(0)
{ {
for (rational i = kMinimumSampleRate; i <= kMaximumSampleRate; i *= 2) { for (Rational i = k_minimum_sample_rate; i <= k_maximum_sample_rate; i *= 2) {
mipmapped_data_.insert({ i, Sample() }); mipmapped_data_.insert({ i, Sample() });
} }
} }
void AudioVisualWaveform::OverwriteSamplesFromBuffer( void AudioVisualWaveform::overwrite_samples_from_buffer(
const SampleBuffer &samples, int sample_rate, const rational &start, const SampleBuffer &samples, int sample_rate, const Rational &start,
double target_rate, Sample &data, size_t &start_index, double target_rate, Sample &data, size_t &start_index,
size_t &samples_length) size_t &samples_length)
{ {
@@ -64,16 +64,16 @@ void AudioVisualWaveform::OverwriteSamplesFromBuffer(
size_t(qRound64((double(i + channels_) * chunk_size))) / channels_, size_t(qRound64((double(i + channels_) * chunk_size))) / channels_,
samples.sample_count()); samples.sample_count());
Sample summary = SumSamples(samples, src_start, src_end - src_start); Sample summary = sum_samples(samples, src_start, src_end - src_start);
memcpy(&data.data()[i + start_index], summary.data(), memcpy(&data.data()[i + start_index], summary.data(),
summary.size() * sizeof(SamplePerChannel)); summary.size() * sizeof(SamplePerChannel));
} }
} }
void AudioVisualWaveform::OverwriteSamplesFromMipmap( void AudioVisualWaveform::overwrite_samples_from_mipmap(
const AudioVisualWaveform::Sample &input, double input_sample_rate, const AudioVisualWaveform::Sample &input, double input_sample_rate,
size_t &input_start, size_t &input_length, const rational &start, size_t &input_start, size_t &input_length, const Rational &start,
double output_rate, AudioVisualWaveform::Sample &output_data) double output_rate, AudioVisualWaveform::Sample &output_data)
{ {
size_t start_index = time_to_samples(start, output_rate); size_t start_index = time_to_samples(start, output_rate);
@@ -91,7 +91,7 @@ void AudioVisualWaveform::OverwriteSamplesFromMipmap(
for (size_t i = 0; i < samples_length; i += channels_) { for (size_t i = 0; i < samples_length; i += channels_) {
Sample summary = Sample summary =
ReSumSamples(&input.data()[input_start + (i * chunk_size)], re_sum_samples(&input.data()[input_start + (i * chunk_size)],
chunk_size * channels_, channels_); chunk_size * channels_, channels_);
memcpy(&output_data.data()[i + start_index], summary.data(), memcpy(&output_data.data()[i + start_index], summary.data(),
@@ -102,31 +102,31 @@ void AudioVisualWaveform::OverwriteSamplesFromMipmap(
input_length = samples_length; input_length = samples_length;
} }
void AudioVisualWaveform::ValidateVirtualStart(const rational &new_start) void AudioVisualWaveform::validate_virtual_start(const Rational &new_start)
{ {
if (length_ == 0) { if (length_ == 0) {
virtual_start_ = new_start; virtual_start_ = new_start;
} else if (virtual_start_ > new_start) { } else if (virtual_start_ > new_start) {
TrimIn(new_start - virtual_start_); trim_in(new_start - virtual_start_);
} }
} }
void AudioVisualWaveform::OverwriteSamples(const SampleBuffer &samples, void AudioVisualWaveform::overwrite_samples(const SampleBuffer &samples,
int sample_rate, int sample_rate,
const rational &start) const Rational &start)
{ {
if (!channels_) { if (!channels_) {
qWarning() << "Failed to write samples - channel count is zero"; qWarning() << "Failed to write samples - channel count is zero";
return; return;
} }
ValidateVirtualStart(start); validate_virtual_start(start);
// Process the largest mipmap directly for the samples // Process the largest mipmap directly for the samples
auto current_mipmap = mipmapped_data_.rbegin(); auto current_mipmap = mipmapped_data_.rbegin();
size_t input_start, input_length; size_t input_start, input_length;
OverwriteSamplesFromBuffer(samples, sample_rate, start - virtual_start_, overwrite_samples_from_buffer(samples, sample_rate, start - virtual_start_,
current_mipmap->first.toDouble(), current_mipmap->first.to_double(),
current_mipmap->second, input_start, current_mipmap->second, input_start,
input_length); input_length);
@@ -139,37 +139,37 @@ void AudioVisualWaveform::OverwriteSamples(const SampleBuffer &samples,
break; break;
} }
OverwriteSamplesFromMipmap( overwrite_samples_from_mipmap(
previous_mipmap->second, previous_mipmap->first.toDouble(), previous_mipmap->second, previous_mipmap->first.to_double(),
input_start, input_length, start - virtual_start_, input_start, input_length, start - virtual_start_,
current_mipmap->first.toDouble(), current_mipmap->second); current_mipmap->first.to_double(), current_mipmap->second);
} }
rational sample_length(samples.sample_count(), sample_rate); Rational sample_length(samples.sample_count(), sample_rate);
length_ = qMax(length_, start + sample_length); length_ = qMax(length_, start + sample_length);
} }
void AudioVisualWaveform::OverwriteSums(const AudioVisualWaveform &sums, void AudioVisualWaveform::overwrite_sums(const AudioVisualWaveform &sums,
const rational &dest, const Rational &dest,
const rational &offset, const Rational &offset,
const rational &length) const Rational &length)
{ {
ValidateVirtualStart(dest); validate_virtual_start(dest);
for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) { for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) {
rational rate = it->first; Rational rate = it->first;
Sample &our_arr = it->second; Sample &our_arr = it->second;
const Sample &their_arr = sums.mipmapped_data_.at(rate); const Sample &their_arr = sums.mipmapped_data_.at(rate);
double rate_dbl = rate.toDouble(); double rate_dbl = rate.to_double();
// Get our destination sample // Get our destination sample
size_t our_start_index = size_t our_start_index =
time_to_samples(dest - virtual_start_, rate_dbl); time_to_samples(dest - virtual_start_, rate_dbl);
// Get our source sample, indexing with the SOURCE's channel count // Get our source sample, indexing with the SOURCE's channel count
size_t their_start_index = std::floor(offset.toDouble() * rate_dbl) * size_t their_start_index = std::floor(offset.to_double() * rate_dbl) *
sums.channel_count(); sums.channel_count();
if (their_start_index >= their_arr.size()) { if (their_start_index >= their_arr.size()) {
continue; continue;
@@ -201,17 +201,17 @@ void AudioVisualWaveform::OverwriteSums(const AudioVisualWaveform &sums,
length)); length));
} }
void AudioVisualWaveform::OverwriteSilence(const rational &start, void AudioVisualWaveform::overwrite_silence(const Rational &start,
const rational &length) const Rational &length)
{ {
ValidateVirtualStart(start); validate_virtual_start(start);
for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) { for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) {
rational rate = it->first; Rational rate = it->first;
Sample &our_arr = it->second; Sample &our_arr = it->second;
double rate_dbl = rate.toDouble(); double rate_dbl = rate.to_double();
// Get our destination sample // Get our destination sample
size_t our_start_index = size_t our_start_index =
@@ -231,7 +231,7 @@ void AudioVisualWaveform::OverwriteSilence(const rational &start,
length_ = qMax(length_, start + length); length_ = qMax(length_, start + length);
} }
void AudioVisualWaveform::TrimIn(rational length) void AudioVisualWaveform::trim_in(Rational length)
{ {
if (length == 0) { if (length == 0) {
return; return;
@@ -245,8 +245,8 @@ void AudioVisualWaveform::TrimIn(rational length)
} }
for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) { for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) {
rational rate = it->first; Rational rate = it->first;
double rate_dbl = rate.toDouble(); double rate_dbl = rate.to_double();
Sample &data = it->second; Sample &data = it->second;
size_t chop_length = time_to_samples(length, rate_dbl); size_t chop_length = time_to_samples(length, rate_dbl);
@@ -262,40 +262,40 @@ void AudioVisualWaveform::TrimIn(rational length)
} }
if (!negative) { if (!negative) {
length_ = qMax(rational(0), length_ - length); length_ = qMax(Rational(0), length_ - length);
} }
// Prepending grows the data before the existing start, so the absolute // Prepending grows the data before the existing start, so the absolute
// end (which length_ tracks) is unchanged // end (which length_ tracks) is unchanged
} }
AudioVisualWaveform AudioVisualWaveform::Mid(const rational &offset) const AudioVisualWaveform AudioVisualWaveform::mid(const Rational &offset) const
{ {
AudioVisualWaveform mid = *this; AudioVisualWaveform mid = *this;
mid.TrimIn(offset - virtual_start_); mid.trim_in(offset - virtual_start_);
return mid; return mid;
} }
AudioVisualWaveform AudioVisualWaveform::Mid(const rational &offset, AudioVisualWaveform AudioVisualWaveform::mid(const Rational &offset,
const rational &length) const const Rational &length) const
{ {
AudioVisualWaveform mid = *this; AudioVisualWaveform mid = *this;
mid.TrimRange(offset - virtual_start_, length); mid.trim_range(offset - virtual_start_, length);
return mid; return mid;
} }
void AudioVisualWaveform::Resize(const rational &length) void AudioVisualWaveform::resize(const Rational &length)
{ {
if (length_ == length) { if (length_ == length) {
return; return;
} }
for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) { for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) {
rational rate = it->first; Rational rate = it->first;
double rate_dbl = rate.toDouble(); double rate_dbl = rate.to_double();
Sample &data = it->second; Sample &data = it->second;
size_t chop_length = time_to_samples(length, rate_dbl); size_t chop_length = time_to_samples(length, rate_dbl);
@@ -306,20 +306,20 @@ void AudioVisualWaveform::Resize(const rational &length)
length_ = length; length_ = length;
} }
void AudioVisualWaveform::TrimRange(const rational &in, const rational &length) void AudioVisualWaveform::trim_range(const Rational &in, const Rational &length)
{ {
TrimIn(in); trim_in(in);
Resize(length); resize(length);
} }
AudioVisualWaveform::Sample AudioVisualWaveform::Sample
AudioVisualWaveform::GetSummaryFromTime(const rational &start, AudioVisualWaveform::get_summary_from_time(const Rational &start,
const rational &length) const const Rational &length) const
{ {
// Find mipmap that requires // Find mipmap that requires
auto using_mipmap = GetMipmapForScale(length.flipped().toDouble()); auto using_mipmap = get_mipmap_for_scale(length.flipped().to_double());
double rate_dbl = using_mipmap->first.toDouble(); double rate_dbl = using_mipmap->first.to_double();
size_t start_sample = time_to_samples(start - virtual_start_, rate_dbl); size_t start_sample = time_to_samples(start - virtual_start_, rate_dbl);
size_t sample_length = time_to_samples(length, rate_dbl); size_t sample_length = time_to_samples(length, rate_dbl);
@@ -333,7 +333,7 @@ AudioVisualWaveform::GetSummaryFromTime(const rational &start,
sample_length = qMin(sample_length, size_t(available)); sample_length = qMin(sample_length, size_t(available));
if (sample_length > 0) { if (sample_length > 0) {
return ReSumSamples(&mipmap_data.data()[start_sample], return re_sum_samples(&mipmap_data.data()[start_sample],
sample_length, channels_); sample_length, channels_);
} }
} }
@@ -342,7 +342,7 @@ AudioVisualWaveform::GetSummaryFromTime(const rational &start,
return AudioVisualWaveform::Sample(channel_count(), { 0, 0 }); return AudioVisualWaveform::Sample(channel_count(), { 0, 0 });
} }
void ExpandMinMaxChannel(const float *a, size_t length, float &min_val, void expand_min_max_channel(const float *a, size_t length, float &min_val,
float &max_val) float &max_val)
{ {
#if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM) #if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM)
@@ -387,7 +387,7 @@ void ExpandMinMaxChannel(const float *a, size_t length, float &min_val,
} }
AudioVisualWaveform::Sample AudioVisualWaveform::Sample
AudioVisualWaveform::SumSamples(const SampleBuffer &samples, size_t start_index, AudioVisualWaveform::sum_samples(const SampleBuffer &samples, size_t start_index,
size_t length) size_t length)
{ {
int channels = samples.audio_params().channel_count(); int channels = samples.audio_params().channel_count();
@@ -395,7 +395,7 @@ AudioVisualWaveform::SumSamples(const SampleBuffer &samples, size_t start_index,
for (int channel = 0; channel < samples.audio_params().channel_count(); for (int channel = 0; channel < samples.audio_params().channel_count();
channel++) { channel++) {
ExpandMinMaxChannel(samples.data(channel) + start_index, length, expand_min_max_channel(samples.data(channel) + start_index, length,
summed_samples[channel].min, summed_samples[channel].min,
summed_samples[channel].max); summed_samples[channel].max);
} }
@@ -409,7 +409,7 @@ AudioVisualWaveform::SumSamples(const SampleBuffer &samples, size_t start_index,
} }
AudioVisualWaveform::Sample AudioVisualWaveform::Sample
AudioVisualWaveform::ReSumSamples(const SamplePerChannel *samples, AudioVisualWaveform::re_sum_samples(const SamplePerChannel *samples,
size_t nb_samples, int nb_channels) size_t nb_samples, int nb_channels)
{ {
AudioVisualWaveform::Sample summed_samples(nb_channels); AudioVisualWaveform::Sample summed_samples(nb_channels);
@@ -437,7 +437,7 @@ template <typename T> inline int round_away_from_zero(T t)
return (t < 0) ? std::floor(t) : std::ceil(t); return (t < 0) ? std::floor(t) : std::ceil(t);
} }
void AudioVisualWaveform::DrawSample(QPainter *painter, const Sample &sample, void AudioVisualWaveform::draw_sample(QPainter *painter, const Sample &sample,
int x, int y, int height, bool rectified) int x, int y, int height, bool rectified)
{ {
if (sample.empty()) { if (sample.empty()) {
@@ -475,19 +475,19 @@ void AudioVisualWaveform::DrawSample(QPainter *painter, const Sample &sample,
} }
} }
void AudioVisualWaveform::DrawWaveform(QPainter *painter, const QRect &rect, void AudioVisualWaveform::draw_waveform(QPainter *painter, const QRect &rect,
const double &scale, const double &scale,
const AudioVisualWaveform &samples, const AudioVisualWaveform &samples,
const rational &start_time) const Rational &start_time)
{ {
if (samples.mipmapped_data_.empty()) { if (samples.mipmapped_data_.empty()) {
return; return;
} }
auto using_mipmap = samples.GetMipmapForScale(scale); auto using_mipmap = samples.get_mipmap_for_scale(scale);
rational rate = using_mipmap->first; Rational rate = using_mipmap->first;
double rate_dbl = rate.toDouble(); double rate_dbl = rate.to_double();
const Sample &arr = using_mipmap->second; const Sample &arr = using_mipmap->second;
size_t start_sample_index = size_t start_sample_index =
@@ -509,7 +509,7 @@ void AudioVisualWaveform::DrawWaveform(QPainter *painter, const QRect &rect,
size_t start = qMax(rect.x(), -top_left.x()); size_t start = qMax(rect.x(), -top_left.x());
size_t end = qMin(rect.right(), -top_left.x() + viewport.width()); size_t end = qMin(rect.right(), -top_left.x() + viewport.width());
bool rectified = OLIVE_CONFIG("RectifiedWaveforms").toBool(); bool rectified = OAK_CONFIG("RectifiedWaveforms").toBool();
for (size_t i = start; i < end; i++) { for (size_t i = start; i < end; i++) {
sample_index = next_sample_index; sample_index = next_sample_index;
@@ -526,7 +526,7 @@ void AudioVisualWaveform::DrawWaveform(QPainter *painter, const QRect &rect,
samples.channel_count())); samples.channel_count()));
if (summary_index != sample_index) { if (summary_index != sample_index) {
summary = AudioVisualWaveform::ReSumSamples( summary = AudioVisualWaveform::re_sum_samples(
&arr.at(sample_index), &arr.at(sample_index),
qMax(size_t(samples.channel_count()), qMax(size_t(samples.channel_count()),
next_sample_index - sample_index), next_sample_index - sample_index),
@@ -534,14 +534,14 @@ void AudioVisualWaveform::DrawWaveform(QPainter *painter, const QRect &rect,
summary_index = sample_index; summary_index = sample_index;
} }
DrawSample(painter, summary, i, rect.y(), rect.height(), rectified); draw_sample(painter, summary, i, rect.y(), rect.height(), rectified);
} }
} }
size_t AudioVisualWaveform::time_to_samples(const rational &time, size_t AudioVisualWaveform::time_to_samples(const Rational &time,
double sample_rate) const double sample_rate) const
{ {
return time_to_samples(time.toDouble(), sample_rate); return time_to_samples(time.to_double(), sample_rate);
} }
size_t AudioVisualWaveform::time_to_samples(const double &time, size_t AudioVisualWaveform::time_to_samples(const double &time,
@@ -550,13 +550,13 @@ size_t AudioVisualWaveform::time_to_samples(const double &time,
return std::floor(time * sample_rate) * channels_; return std::floor(time * sample_rate) * channels_;
} }
std::map<rational, AudioVisualWaveform::Sample>::const_iterator std::map<Rational, AudioVisualWaveform::Sample>::const_iterator
AudioVisualWaveform::GetMipmapForScale(double scale) const AudioVisualWaveform::get_mipmap_for_scale(double scale) const
{ {
// Find largest mipmap for this scale (or the largest if we don't find one sufficient) // Find largest mipmap for this scale (or the largest if we don't find one sufficient)
for (auto it = mipmapped_data_.cbegin(); it != mipmapped_data_.cend(); for (auto it = mipmapped_data_.cbegin(); it != mipmapped_data_.cend();
it++) { it++) {
if (it->first.toDouble() >= scale) { if (it->first.to_double() >= scale) {
return it; return it;
} }
} }
+35 -35
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef SUMSAMPLES_H #ifndef OAK_SUMSAMPLES_H
#define SUMSAMPLES_H #define OAK_SUMSAMPLES_H
#include <olive/core/core.h> #include <olive/core/core.h>
#include <QPainter> #include <QPainter>
@@ -58,7 +58,7 @@ public:
channels_ = channels; channels_ = channels;
} }
const rational &length() const const Rational &length() const
{ {
return length_; return length_;
} }
@@ -68,8 +68,8 @@ public:
* *
* Starting at `start`, writes samples over anything in the buffer, expanding it if necessary. * Starting at `start`, writes samples over anything in the buffer, expanding it if necessary.
*/ */
void OverwriteSamples(const SampleBuffer &samples, int sample_rate, void overwrite_samples(const SampleBuffer &samples, int sample_rate,
const rational &start = 0); const Rational &start = 0);
/** /**
* @brief Replaces sums at a certain range in this visual waveform * @brief Replaces sums at a certain range in this visual waveform
@@ -90,74 +90,74 @@ public:
* *
* Maximum length of `sums` to overwrite with. * Maximum length of `sums` to overwrite with.
*/ */
void OverwriteSums(const AudioVisualWaveform &sums, const rational &dest, void overwrite_sums(const AudioVisualWaveform &sums, const Rational &dest,
const rational &offset = 0, const rational &length = 0); const Rational &offset = 0, const Rational &length = 0);
void OverwriteSilence(const rational &start, const rational &length); void overwrite_silence(const Rational &start, const Rational &length);
void TrimIn(rational length); void trim_in(Rational length);
AudioVisualWaveform Mid(const rational &offset) const; AudioVisualWaveform mid(const Rational &offset) const;
AudioVisualWaveform Mid(const rational &offset, AudioVisualWaveform mid(const Rational &offset,
const rational &length) const; const Rational &length) const;
void Resize(const rational &length); void resize(const Rational &length);
void TrimRange(const rational &in, const rational &length); void trim_range(const Rational &in, const Rational &length);
Sample GetSummaryFromTime(const rational &start, Sample get_summary_from_time(const Rational &start,
const rational &length) const; const Rational &length) const;
static Sample SumSamples(const SampleBuffer &samples, size_t start_index, static Sample sum_samples(const SampleBuffer &samples, size_t start_index,
size_t length); size_t length);
static Sample ReSumSamples(const SamplePerChannel *samples, static Sample re_sum_samples(const SamplePerChannel *samples,
size_t nb_samples, int nb_channels); size_t nb_samples, int nb_channels);
static void DrawSample(QPainter *painter, const Sample &sample, int x, static void draw_sample(QPainter *painter, const Sample &sample, int x,
int y, int height, bool rectified); int y, int height, bool rectified);
static void DrawWaveform(QPainter *painter, const QRect &rect, static void draw_waveform(QPainter *painter, const QRect &rect,
const double &scale, const double &scale,
const AudioVisualWaveform &samples, const AudioVisualWaveform &samples,
const rational &start_time); const Rational &start_time);
// Must be a power of 2 // Must be a power of 2
static const rational kMinimumSampleRate; static const Rational k_minimum_sample_rate;
static const rational kMaximumSampleRate; static const Rational k_maximum_sample_rate;
private: private:
void OverwriteSamplesFromBuffer(const SampleBuffer &samples, void overwrite_samples_from_buffer(const SampleBuffer &samples,
int sample_rate, const rational &start, int sample_rate, const Rational &start,
double target_rate, Sample &data, double target_rate, Sample &data,
size_t &start_index, size_t &start_index,
size_t &samples_length); size_t &samples_length);
void OverwriteSamplesFromMipmap(const Sample &input, void overwrite_samples_from_mipmap(const Sample &input,
double input_sample_rate, double input_sample_rate,
size_t &input_start, size_t &input_length, size_t &input_start, size_t &input_length,
const rational &start, double output_rate, const Rational &start, double output_rate,
Sample &output_data); Sample &output_data);
size_t time_to_samples(const rational &time, double sample_rate) const; size_t time_to_samples(const Rational &time, double sample_rate) const;
size_t time_to_samples(const double &time, double sample_rate) const; size_t time_to_samples(const double &time, double sample_rate) const;
std::map<rational, Sample>::const_iterator std::map<Rational, Sample>::const_iterator
GetMipmapForScale(double scale) const; get_mipmap_for_scale(double scale) const;
void ValidateVirtualStart(const rational &new_start); void validate_virtual_start(const Rational &new_start);
rational virtual_start_; Rational virtual_start_;
int channels_; int channels_;
std::map<rational, Sample> mipmapped_data_; std::map<Rational, Sample> mipmapped_data_;
rational length_; Rational length_;
}; };
} }
Q_DECLARE_METATYPE(olive::AudioVisualWaveform) Q_DECLARE_METATYPE(olive::AudioVisualWaveform)
#endif // SUMSAMPLES_H #endif // OAK_SUMSAMPLES_H
+10 -10
View File
@@ -27,7 +27,7 @@ namespace olive
{ {
QVector<double> QVector<double>
AudioWaveformSync::ExtractRmsEnvelope(const core::SampleBuffer &samples, AudioWaveformSync::extract_rms_envelope(const core::SampleBuffer &samples,
size_t window_samples) size_t window_samples)
{ {
QVector<double> envelope; QVector<double> envelope;
@@ -64,7 +64,7 @@ AudioWaveformSync::ExtractRmsEnvelope(const core::SampleBuffer &samples,
return envelope; return envelope;
} }
AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateOffset( AudioWaveformSync::OffsetResult AudioWaveformSync::estimate_offset(
const core::SampleBuffer &reference, const core::SampleBuffer &candidate, const core::SampleBuffer &reference, const core::SampleBuffer &candidate,
size_t window_samples, int64_t max_offset_samples) size_t window_samples, int64_t max_offset_samples)
{ {
@@ -73,26 +73,26 @@ AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateOffset(
} }
const QVector<double> reference_envelope = const QVector<double> reference_envelope =
ExtractRmsEnvelope(reference, window_samples); extract_rms_envelope(reference, window_samples);
const QVector<double> candidate_envelope = const QVector<double> candidate_envelope =
ExtractRmsEnvelope(candidate, window_samples); extract_rms_envelope(candidate, window_samples);
const int64_t max_offset_windows = const int64_t max_offset_windows =
max_offset_samples / static_cast<int64_t>(window_samples); max_offset_samples / static_cast<int64_t>(window_samples);
return EstimateEnvelopeOffset(reference_envelope, candidate_envelope, return estimate_envelope_offset(reference_envelope, candidate_envelope,
window_samples, max_offset_windows); window_samples, max_offset_windows);
} }
AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateEnvelopeOffset( AudioWaveformSync::OffsetResult AudioWaveformSync::estimate_envelope_offset(
const QVector<double> &reference, const QVector<double> &candidate, const QVector<double> &reference, const QVector<double> &candidate,
size_t window_samples, int64_t max_offset_windows) size_t window_samples, int64_t max_offset_windows)
{ {
return EstimateEnvelopeOffset(reference, candidate, QVector<bool>(), return estimate_envelope_offset(reference, candidate, QVector<bool>(),
QVector<bool>(), window_samples, QVector<bool>(), window_samples,
max_offset_windows); max_offset_windows);
} }
AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateEnvelopeOffset( AudioWaveformSync::OffsetResult AudioWaveformSync::estimate_envelope_offset(
const QVector<double> &reference, const QVector<double> &candidate, const QVector<double> &reference, const QVector<double> &candidate,
const QVector<bool> &reference_valid, const QVector<bool> &candidate_valid, const QVector<bool> &reference_valid, const QVector<bool> &candidate_valid,
size_t window_samples, int64_t max_offset_windows) size_t window_samples, int64_t max_offset_windows)
@@ -185,7 +185,7 @@ AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateEnvelopeOffset(
return result; return result;
} }
AudioWaveformSync::StretchOffsetResult AudioWaveformSync::EstimateStretchAndOffset( AudioWaveformSync::StretchOffsetResult AudioWaveformSync::estimate_stretch_and_offset(
const QVector<double> &reference, const QVector<double> &candidate, const QVector<double> &reference, const QVector<double> &candidate,
const QVector<bool> &reference_valid, const QVector<bool> &candidate_valid, const QVector<bool> &reference_valid, const QVector<bool> &candidate_valid,
size_t window_samples, int64_t max_offset_windows, double min_rate, size_t window_samples, int64_t max_offset_windows, double min_rate,
@@ -226,7 +226,7 @@ AudioWaveformSync::StretchOffsetResult AudioWaveformSync::EstimateStretchAndOffs
(candidate_valid.at(lower) && candidate_valid.at(upper))); (candidate_valid.at(lower) && candidate_valid.at(upper)));
} }
const OffsetResult offset = EstimateEnvelopeOffset( const OffsetResult offset = estimate_envelope_offset(
reference, resampled, reference_valid, resampled_valid, reference, resampled, reference_valid, resampled_valid,
window_samples, max_offset_windows); window_samples, max_offset_windows);
+8 -8
View File
@@ -18,8 +18,8 @@
***/ ***/
#ifndef AUDIOWAVEFORMSYNC_H #ifndef OAK_AUDIOWAVEFORMSYNC_H
#define AUDIOWAVEFORMSYNC_H #define OAK_AUDIOWAVEFORMSYNC_H
#include <cstdint> #include <cstdint>
@@ -48,15 +48,15 @@ public:
bool valid = false; bool valid = false;
}; };
static QVector<double> ExtractRmsEnvelope(const core::SampleBuffer &samples, static QVector<double> extract_rms_envelope(const core::SampleBuffer &samples,
size_t window_samples); size_t window_samples);
static OffsetResult EstimateOffset(const core::SampleBuffer &reference, static OffsetResult estimate_offset(const core::SampleBuffer &reference,
const core::SampleBuffer &candidate, const core::SampleBuffer &candidate,
size_t window_samples, size_t window_samples,
int64_t max_offset_samples); int64_t max_offset_samples);
static OffsetResult EstimateEnvelopeOffset(const QVector<double> &reference, static OffsetResult estimate_envelope_offset(const QVector<double> &reference,
const QVector<double> &candidate, const QVector<double> &candidate,
size_t window_samples, size_t window_samples,
int64_t max_offset_windows); int64_t max_offset_windows);
@@ -71,7 +71,7 @@ public:
* waveform cache have not been generated yet. Empty masks are treated as * waveform cache have not been generated yet. Empty masks are treated as
* "all windows valid". * "all windows valid".
*/ */
static OffsetResult EstimateEnvelopeOffset(const QVector<double> &reference, static OffsetResult estimate_envelope_offset(const QVector<double> &reference,
const QVector<double> &candidate, const QVector<double> &candidate,
const QVector<bool> &reference_valid, const QVector<bool> &reference_valid,
const QVector<bool> &candidate_valid, const QVector<bool> &candidate_valid,
@@ -89,7 +89,7 @@ public:
* callers should bound max_offset_windows to a sensible range. * callers should bound max_offset_windows to a sensible range.
*/ */
static StretchOffsetResult static StretchOffsetResult
EstimateStretchAndOffset(const QVector<double> &reference, estimate_stretch_and_offset(const QVector<double> &reference,
const QVector<double> &candidate, const QVector<double> &candidate,
const QVector<bool> &reference_valid, const QVector<bool> &reference_valid,
const QVector<bool> &candidate_valid, size_t window_samples, const QVector<bool> &candidate_valid, size_t window_samples,
@@ -99,4 +99,4 @@ public:
} }
#endif // AUDIOWAVEFORMSYNC_H #endif // OAK_AUDIOWAVEFORMSYNC_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef CLIEXPORTMANAGER_H #ifndef OAK_CLIEXPORTMANAGER_H
#define CLIEXPORTMANAGER_H #define OAK_CLIEXPORTMANAGER_H
#include "task/export/export.h" #include "task/export/export.h"
@@ -34,4 +34,4 @@ public:
} }
#endif // CLIEXPORTMANAGER_H #endif // OAK_CLIEXPORTMANAGER_H
+4 -4
View File
@@ -32,10 +32,10 @@ CLIProgressDialog::CLIProgressDialog(const QString &title, QObject *parent)
, progress_(-1) , progress_(-1)
, drawn_(false) , drawn_(false)
{ {
SetProgress(0); set_progress(0);
} }
void CLIProgressDialog::Update() void CLIProgressDialog::update()
{ {
if (drawn_) { if (drawn_) {
// We've been here before, do a carriage return back to the start of the terminal line // We've been here before, do a carriage return back to the start of the terminal line
@@ -102,12 +102,12 @@ void CLIProgressDialog::Update()
std::cout << percent << "% " << std::endl << std::flush; std::cout << percent << "% " << std::endl << std::flush;
} }
void CLIProgressDialog::SetProgress(double p) void CLIProgressDialog::set_progress(double p)
{ {
if (progress_ != p) { if (progress_ != p) {
progress_ = p; progress_ = p;
Update(); update();
} }
} }
+5 -5
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef CLIPROGRESSDIALOG_H #ifndef OAK_CLIPROGRESSDIALOG_H
#define CLIPROGRESSDIALOG_H #define OAK_CLIPROGRESSDIALOG_H
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
@@ -35,10 +35,10 @@ public:
CLIProgressDialog(const QString &title, QObject *parent = nullptr); CLIProgressDialog(const QString &title, QObject *parent = nullptr);
public slots: public slots:
void SetProgress(double p); void set_progress(double p);
private: private:
void Update(); void update();
QString title_; QString title_;
@@ -49,4 +49,4 @@ private:
} }
#endif // CLIPROGRESSDIALOG_H #endif // OAK_CLIPROGRESSDIALOG_H
+4 -4
View File
@@ -25,15 +25,15 @@ namespace olive
{ {
CLITaskDialog::CLITaskDialog(Task *task, QObject *parent) CLITaskDialog::CLITaskDialog(Task *task, QObject *parent)
: CLIProgressDialog(task->GetTitle(), parent) : CLIProgressDialog(task->get_title(), parent)
, task_(task) , task_(task)
{ {
connect(task_, &Task::ProgressChanged, this, &CLITaskDialog::SetProgress); connect(task_, &Task::progress_changed, this, &CLITaskDialog::set_progress);
} }
bool CLITaskDialog::Run() bool CLITaskDialog::run()
{ {
return task_->Start(); return task_->start();
} }
} }
+4 -4
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef CLITASKDIALOG_H #ifndef OAK_CLITASKDIALOG_H
#define CLITASKDIALOG_H #define OAK_CLITASKDIALOG_H
#include "cli/cliprogress/cliprogressdialog.h" #include "cli/cliprogress/cliprogressdialog.h"
#include "task/task.h" #include "task/task.h"
@@ -33,7 +33,7 @@ class CLITaskDialog : public CLIProgressDialog {
public: public:
CLITaskDialog(Task *task, QObject *parent = nullptr); CLITaskDialog(Task *task, QObject *parent = nullptr);
bool Run(); bool run();
private: private:
Task *task_; Task *task_;
@@ -41,4 +41,4 @@ private:
} }
#endif // CLITASKDIALOG_H #endif // OAK_CLITASKDIALOG_H
+15 -15
View File
@@ -27,7 +27,7 @@ namespace olive
ConformManager *ConformManager::instance_ = nullptr; ConformManager *ConformManager::instance_ = nullptr;
ConformManager::Conform ConformManager::GetConformState( ConformManager::Conform ConformManager::get_conform_state(
const QString &decoder_id, const QString &cache_path, const QString &decoder_id, const QString &cache_path,
const Decoder::CodecStream &stream, const AudioParams &params, bool wait) const Decoder::CodecStream &stream, const AudioParams &params, bool wait)
{ {
@@ -36,9 +36,9 @@ ConformManager::Conform ConformManager::GetConformState(
// Return existing conform if exists // Return existing conform if exists
QVector<QString> filenames = QVector<QString> filenames =
GetConformedFilename(cache_path, stream, params); get_conformed_filename(cache_path, stream, params);
if (AllConformsExist(filenames)) { if (all_conforms_exist(filenames)) {
return { kConformExists, filenames, nullptr }; return { k_conform_exists, filenames, nullptr };
} }
ConformTask *conforming_task = nullptr; ConformTask *conforming_task = nullptr;
@@ -63,10 +63,10 @@ ConformManager::Conform ConformManager::GetConformState(
conforming_task = conforming_task =
new ConformTask(decoder_id, stream, params, working_filenames); new ConformTask(decoder_id, stream, params, working_filenames);
connect(conforming_task, &ConformTask::Finished, this, connect(conforming_task, &ConformTask::finished, this,
&ConformManager::ConformTaskFinished); &ConformManager::conform_task_finished);
conforming_task->moveToThread(TaskManager::instance()->thread()); conforming_task->moveToThread(TaskManager::instance()->thread());
QMetaObject::invokeMethod(TaskManager::instance(), "AddTask", QMetaObject::invokeMethod(TaskManager::instance(), "add_task",
Qt::QueuedConnection, Qt::QueuedConnection,
Q_ARG(Task *, conforming_task)); Q_ARG(Task *, conforming_task));
@@ -77,15 +77,15 @@ ConformManager::Conform ConformManager::GetConformState(
if (wait) { if (wait) {
do { do {
conform_done_condition_.wait(&mutex_); conform_done_condition_.wait(&mutex_);
} while (!AllConformsExist(filenames)); } while (!all_conforms_exist(filenames));
return { kConformExists, filenames, nullptr }; return { k_conform_exists, filenames, nullptr };
} }
return { kConformGenerating, QVector<QString>(), conforming_task }; return { k_conform_generating, QVector<QString>(), conforming_task };
} }
QVector<QString> QVector<QString>
ConformManager::GetConformedFilename(const QString &cache_path, ConformManager::get_conformed_filename(const QString &cache_path,
const Decoder::CodecStream &stream, const Decoder::CodecStream &stream,
const AudioParams &params) const AudioParams &params)
{ {
@@ -94,7 +94,7 @@ ConformManager::GetConformedFilename(const QString &cache_path,
for (int i = 0; i < filenames.size(); i++) { for (int i = 0; i < filenames.size(); i++) {
QString index_fn = QString index_fn =
QStringLiteral("%1-%2.%3.%4.%5.%6.pcm") QStringLiteral("%1-%2.%3.%4.%5.%6.pcm")
.arg(FileFunctions::GetUniqueFileIdentifier(stream.filename()), .arg(FileFunctions::get_unique_file_identifier(stream.filename()),
QString::number(stream.stream()), QString::number(stream.stream()),
QString::number(params.sample_rate()), QString::number(params.sample_rate()),
QString::number(params.format()), QString::number(params.format()),
@@ -107,7 +107,7 @@ ConformManager::GetConformedFilename(const QString &cache_path,
return filenames; return filenames;
} }
bool ConformManager::AllConformsExist(const QVector<QString> &filenames) bool ConformManager::all_conforms_exist(const QVector<QString> &filenames)
{ {
foreach (const QString &fn, filenames) { foreach (const QString &fn, filenames) {
if (!QFileInfo::exists(fn)) { if (!QFileInfo::exists(fn)) {
@@ -118,7 +118,7 @@ bool ConformManager::AllConformsExist(const QVector<QString> &filenames)
return true; return true;
} }
void ConformManager::ConformTaskFinished(Task *task, bool succeeded) void ConformManager::conform_task_finished(Task *task, bool succeeded)
{ {
QMutexLocker locker(&mutex_); QMutexLocker locker(&mutex_);
@@ -146,7 +146,7 @@ void ConformManager::ConformTaskFinished(Task *task, bool succeeded)
conform_done_condition_.wakeAll(); conform_done_condition_.wakeAll();
locker.unlock(); locker.unlock();
emit ConformReady(); emit conform_ready();
} else { } else {
// Failed, just delete the working filename if exists // Failed, just delete the working filename if exists
for (int i = 0; i < data.working_filename.size(); i++) { for (int i = 0; i < data.working_filename.size(); i++) {
+11 -11
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CONFORMMANAGER_H #ifndef OAK_CONFORMMANAGER_H
#define CONFORMMANAGER_H #define OAK_CONFORMMANAGER_H
#include <QMutex> #include <QMutex>
#include <QObject> #include <QObject>
@@ -31,14 +31,14 @@ namespace olive
class ConformManager : public QObject { class ConformManager : public QObject {
Q_OBJECT Q_OBJECT
public: public:
static void CreateInstance() static void create_instance()
{ {
if (!instance_) { if (!instance_) {
instance_ = new ConformManager(); instance_ = new ConformManager();
} }
} }
static void DestroyInstance() static void destroy_instance()
{ {
delete instance_; delete instance_;
instance_ = nullptr; instance_ = nullptr;
@@ -49,7 +49,7 @@ public:
return instance_; return instance_;
} }
enum ConformState { kConformExists, kConformGenerating }; enum ConformState { k_conform_exists, k_conform_generating };
struct Conform { struct Conform {
ConformState state; ConformState state;
@@ -62,13 +62,13 @@ public:
* *
* Thread-safe. * Thread-safe.
*/ */
Conform GetConformState(const QString &decoder_id, Conform get_conform_state(const QString &decoder_id,
const QString &cache_path, const QString &cache_path,
const Decoder::CodecStream &stream, const Decoder::CodecStream &stream,
const AudioParams &params, bool wait); const AudioParams &params, bool wait);
signals: signals:
void ConformReady(); void conform_ready();
private: private:
ConformManager() = default; ConformManager() = default;
@@ -93,16 +93,16 @@ private:
* @brief Get the destination filename of an audio stream conformed to a set of parameters * @brief Get the destination filename of an audio stream conformed to a set of parameters
*/ */
static QVector<QString> static QVector<QString>
GetConformedFilename(const QString &cache_path, get_conformed_filename(const QString &cache_path,
const Decoder::CodecStream &stream, const Decoder::CodecStream &stream,
const AudioParams &params); const AudioParams &params);
static bool AllConformsExist(const QVector<QString> &filenames); static bool all_conforms_exist(const QVector<QString> &filenames);
private slots: private slots:
void ConformTaskFinished(Task *task, bool succeeded); void conform_task_finished(Task *task, bool succeeded);
}; };
} // namespace olive } // namespace olive
#endif // CONFORMMANAGER_H #endif // OAK_CONFORMMANAGER_H
+62 -62
View File
@@ -33,26 +33,26 @@
namespace olive namespace olive
{ {
const rational Decoder::kAnyTimecode = RATIONAL_MIN; const Rational Decoder::k_any_timecode = RATIONAL_MIN;
Decoder::Decoder() Decoder::Decoder()
: cached_texture_(nullptr) : cached_texture_(nullptr)
{ {
UpdateLastAccessed(); update_last_accessed();
} }
void Decoder::IncrementAccessTime(qint64 t) void Decoder::increment_access_time(qint64 t)
{ {
last_accessed_ += t; last_accessed_ += t;
} }
bool Decoder::Open(const CodecStream &stream) bool Decoder::open(const CodecStream &stream)
{ {
QMutexLocker locker(&mutex_); QMutexLocker locker(&mutex_);
UpdateLastAccessed(); update_last_accessed();
if (stream_.IsValid()) { if (stream_.is_valid()) {
// Decoder is already open. Return TRUE if the stream is the stream we have, or FALSE if not. // Decoder is already open. Return TRUE if the stream is the stream we have, or FALSE if not.
if (stream_ == stream) { if (stream_ == stream) {
return true; return true;
@@ -63,13 +63,13 @@ bool Decoder::Open(const CodecStream &stream)
} }
} else { } else {
// Stream was not open, try opening it now // Stream was not open, try opening it now
if (!stream.IsValid()) { if (!stream.is_valid()) {
// Cannot open null stream // Cannot open null stream
qCritical() << "Decoder attempted to open null stream"; qCritical() << "Decoder attempted to open null stream";
return false; return false;
} }
if (!stream.Exists()) { if (!stream.exists()) {
// Cannot open file that doesn't exist // Cannot open file that doesn't exist
qCritical() << "Decoder attempted to open file that doesn't exist"; qCritical() << "Decoder attempted to open file that doesn't exist";
return false; return false;
@@ -79,36 +79,36 @@ bool Decoder::Open(const CodecStream &stream)
stream_ = stream; stream_ = stream;
// Try open internal // Try open internal
if (OpenInternal()) { if (open_internal()) {
return true; return true;
} else { } else {
// Unset stream // Unset stream
qCritical() << "Failed to open" << stream_.filename() << "stream" qCritical() << "Failed to open" << stream_.filename() << "stream"
<< stream_.stream(); << stream_.stream();
CloseInternal(); close_internal();
stream_.Reset(); stream_.reset();
return false; return false;
} }
} }
} }
TexturePtr Decoder::RetrieveVideo(const RetrieveVideoParams &p) TexturePtr Decoder::retrieve_video(const RetrieveVideoParams &p)
{ {
QMutexLocker locker(&mutex_); QMutexLocker locker(&mutex_);
UpdateLastAccessed(); update_last_accessed();
if (!stream_.IsValid()) { if (!stream_.is_valid()) {
qCritical() << "Can't retrieve video on a closed decoder"; qCritical() << "Can't retrieve video on a closed decoder";
return nullptr; return nullptr;
} }
if (!SupportsVideo()) { if (!supports_video()) {
qCritical() << "Decoder doesn't support video"; qCritical() << "Decoder doesn't support video";
return nullptr; return nullptr;
} }
if (p.cancelled && p.cancelled->IsCancelled()) { if (p.cancelled && p.cancelled->is_cancelled()) {
return nullptr; return nullptr;
} }
@@ -117,110 +117,110 @@ TexturePtr Decoder::RetrieveVideo(const RetrieveVideoParams &p)
return cached_texture_; return cached_texture_;
} }
cached_texture_ = RetrieveVideoInternal(p); cached_texture_ = retrieve_video_internal(p);
cached_time_ = p.time; cached_time_ = p.time;
cached_divider_ = p.divider; cached_divider_ = p.divider;
return cached_texture_; return cached_texture_;
} }
FramePtr Decoder::RetrieveVideoFrame(const RetrieveVideoParams &p) FramePtr Decoder::retrieve_video_frame(const RetrieveVideoParams &p)
{ {
QMutexLocker locker(&mutex_); QMutexLocker locker(&mutex_);
UpdateLastAccessed(); update_last_accessed();
if (!stream_.IsValid()) { if (!stream_.is_valid()) {
qCritical() << "Can't retrieve video frame on a closed decoder"; qCritical() << "Can't retrieve video frame on a closed decoder";
return nullptr; return nullptr;
} }
if (!SupportsVideo()) { if (!supports_video()) {
qCritical() << "Decoder doesn't support video"; qCritical() << "Decoder doesn't support video";
return nullptr; return nullptr;
} }
if (p.cancelled && p.cancelled->IsCancelled()) { if (p.cancelled && p.cancelled->is_cancelled()) {
return nullptr; return nullptr;
} }
return RetrieveVideoFrameInternal(p); return retrieve_video_frame_internal(p);
} }
Decoder::RetrieveAudioStatus Decoder::RetrieveAudioStatus
Decoder::RetrieveAudio(SampleBuffer &dest, const TimeRange &range, Decoder::retrieve_audio(SampleBuffer &dest, const TimeRange &range,
const AudioParams &params, const QString &cache_path, const AudioParams &params, const QString &cache_path,
LoopMode loop_mode, RenderMode::Mode mode) LoopMode loop_mode, RenderMode::Mode mode)
{ {
QMutexLocker locker(&mutex_); QMutexLocker locker(&mutex_);
UpdateLastAccessed(); update_last_accessed();
if (!stream_.IsValid()) { if (!stream_.is_valid()) {
qCritical() << "Can't retrieve audio on a closed decoder"; qCritical() << "Can't retrieve audio on a closed decoder";
return kInvalid; return k_invalid;
} }
if (!SupportsAudio()) { if (!supports_audio()) {
qCritical() << "Decoder doesn't support audio"; qCritical() << "Decoder doesn't support audio";
return kInvalid; return k_invalid;
} }
if (params.sample_rate() <= 0 || params.channel_count() <= 0) { if (params.sample_rate() <= 0 || params.channel_count() <= 0) {
qWarning() << "Invalid audio parameters, skipping audio retrieve"; qWarning() << "Invalid audio parameters, skipping audio retrieve";
return kInvalid; return k_invalid;
} }
// Get conform state from ConformManager // Get conform state from ConformManager
ConformManager::Conform conform = ConformManager::Conform conform =
ConformManager::instance()->GetConformState( ConformManager::instance()->get_conform_state(
id(), cache_path, stream_, params, (mode == RenderMode::kOnline)); id(), cache_path, stream_, params, (mode == RenderMode::k_online));
if (conform.state == ConformManager::kConformGenerating) { if (conform.state == ConformManager::k_conform_generating) {
// If we need the task, it's available in `conform.task` // If we need the task, it's available in `conform.task`
return kWaitingForConform; return k_waiting_for_conform;
} }
// See if we got the conform // See if we got the conform
if (RetrieveAudioFromConform(dest, conform.filenames, range, loop_mode, if (retrieve_audio_from_conform(dest, conform.filenames, range, loop_mode,
params)) { params)) {
return kOK; return k_ok;
} else { } else {
return kUnknownError; return k_unknown_error;
} }
} }
qint64 Decoder::GetLastAccessedTime() qint64 Decoder::get_last_accessed_time()
{ {
return last_accessed_; return last_accessed_;
} }
void Decoder::Close() void Decoder::close()
{ {
QMutexLocker locker(&mutex_); QMutexLocker locker(&mutex_);
UpdateLastAccessed(); update_last_accessed();
cached_texture_ = nullptr; cached_texture_ = nullptr;
if (stream_.IsValid()) { if (stream_.is_valid()) {
CloseInternal(); close_internal();
stream_.Reset(); stream_.reset();
} else { } else {
qWarning() << "Tried to close a decoder that wasn't open"; qWarning() << "Tried to close a decoder that wasn't open";
} }
} }
bool Decoder::ConformAudio(const QVector<QString> &output_filenames, bool Decoder::conform_audio(const QVector<QString> &output_filenames,
const AudioParams &params, CancelAtom *cancelled) const AudioParams &params, CancelAtom *cancelled)
{ {
return ConformAudioInternal(output_filenames, params, cancelled); return conform_audio_internal(output_filenames, params, cancelled);
} }
/* /*
* DECODER STATIC PUBLIC MEMBERS * DECODER STATIC PUBLIC MEMBERS
*/ */
QVector<DecoderPtr> Decoder::ReceiveListOfAllDecoders() QVector<DecoderPtr> Decoder::receive_list_of_all_decoders()
{ {
QVector<DecoderPtr> decoders; QVector<DecoderPtr> decoders;
@@ -232,14 +232,14 @@ QVector<DecoderPtr> Decoder::ReceiveListOfAllDecoders()
return decoders; return decoders;
} }
DecoderPtr Decoder::CreateFromID(const QString &id) DecoderPtr Decoder::create_from_id(const QString &id)
{ {
if (id.isEmpty()) { if (id.isEmpty()) {
return nullptr; return nullptr;
} }
// Create list to iterate through // Create list to iterate through
QVector<DecoderPtr> decoder_list = ReceiveListOfAllDecoders(); QVector<DecoderPtr> decoder_list = receive_list_of_all_decoders();
foreach (DecoderPtr d, decoder_list) { foreach (DecoderPtr d, decoder_list) {
if (d->id() == id) { if (d->id() == id) {
@@ -250,18 +250,18 @@ DecoderPtr Decoder::CreateFromID(const QString &id)
return nullptr; return nullptr;
} }
void Decoder::SignalProcessingProgress(int64_t ts, int64_t duration) void Decoder::signal_processing_progress(int64_t ts, int64_t duration)
{ {
if (duration != FB_NOPTS_VALUE && duration != 0) { if (duration != FB_NOPTS_VALUE && duration != 0) {
emit IndexProgress(static_cast<double>(ts) / emit index_progress(static_cast<double>(ts) /
static_cast<double>(duration)); static_cast<double>(duration));
} }
} }
QString Decoder::TransformImageSequenceFileName(const QString &filename, QString Decoder::transform_image_sequence_file_name(const QString &filename,
const int64_t &number) const int64_t &number)
{ {
int digit_count = GetImageSequenceDigitCount(filename); int digit_count = get_image_sequence_digit_count(filename);
QFileInfo file_info(filename); QFileInfo file_info(filename);
@@ -276,7 +276,7 @@ QString Decoder::TransformImageSequenceFileName(const QString &filename,
file_info.fileName().replace(original_basename, new_basename)); file_info.fileName().replace(original_basename, new_basename));
} }
int Decoder::GetImageSequenceDigitCount(const QString &filename) int Decoder::get_image_sequence_digit_count(const QString &filename)
{ {
QString basename = QFileInfo(filename).completeBaseName(); QString basename = QFileInfo(filename).completeBaseName();
@@ -294,9 +294,9 @@ int Decoder::GetImageSequenceDigitCount(const QString &filename)
return digit_count; return digit_count;
} }
int64_t Decoder::GetImageSequenceIndex(const QString &filename) int64_t Decoder::get_image_sequence_index(const QString &filename)
{ {
int digit_count = GetImageSequenceDigitCount(filename); int digit_count = get_image_sequence_digit_count(filename);
QFileInfo file_info(filename); QFileInfo file_info(filename);
@@ -308,19 +308,19 @@ int64_t Decoder::GetImageSequenceIndex(const QString &filename)
return number_only.toLongLong(); return number_only.toLongLong();
} }
TexturePtr Decoder::RetrieveVideoInternal(const RetrieveVideoParams &p) TexturePtr Decoder::retrieve_video_internal(const RetrieveVideoParams &p)
{ {
Q_UNUSED(p) Q_UNUSED(p)
return nullptr; return nullptr;
} }
FramePtr Decoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p) FramePtr Decoder::retrieve_video_frame_internal(const RetrieveVideoParams &p)
{ {
Q_UNUSED(p) Q_UNUSED(p)
return nullptr; return nullptr;
} }
bool Decoder::ConformAudioInternal(const QVector<QString> &filenames, bool Decoder::conform_audio_internal(const QVector<QString> &filenames,
const AudioParams &params, const AudioParams &params,
CancelAtom *cancelled) CancelAtom *cancelled)
{ {
@@ -330,14 +330,14 @@ bool Decoder::ConformAudioInternal(const QVector<QString> &filenames,
return false; return false;
} }
bool Decoder::RetrieveAudioFromConform( bool Decoder::retrieve_audio_from_conform(
SampleBuffer &sample_buffer, const QVector<QString> &conform_filenames, SampleBuffer &sample_buffer, const QVector<QString> &conform_filenames,
TimeRange range, LoopMode loop_mode, const AudioParams &input_params) TimeRange range, LoopMode loop_mode, const AudioParams &input_params)
{ {
PlanarFileDevice input; PlanarFileDevice input;
if (input.open(conform_filenames, QFile::ReadOnly)) { if (input.open(conform_filenames, QFile::ReadOnly)) {
// Offset range by audio start offset // Offset range by audio start offset
range -= GetAudioStartOffset(); range -= get_audio_start_offset();
qint64 read_index = input_params.time_to_bytes(range.in()) / qint64 read_index = input_params.time_to_bytes(range.in()) /
input_params.channel_count(); input_params.channel_count();
@@ -348,7 +348,7 @@ bool Decoder::RetrieveAudioFromConform(
input_params.bytes_per_sample_per_channel(); input_params.bytes_per_sample_per_channel();
while (write_index < buffer_length_in_bytes) { while (write_index < buffer_length_in_bytes) {
if (loop_mode == LoopMode::kLoopModeLoop) { if (loop_mode == LoopMode::k_loop_mode_loop) {
while (read_index >= input.size()) { while (read_index >= input.size()) {
read_index -= input.size(); read_index -= input.size();
} }
@@ -391,7 +391,7 @@ bool Decoder::RetrieveAudioFromConform(
return false; return false;
} }
void Decoder::UpdateLastAccessed() void Decoder::update_last_accessed()
{ {
last_accessed_ = QDateTime::currentMSecsSinceEpoch(); last_accessed_ = QDateTime::currentMSecsSinceEpoch();
} }
+45 -45
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef DECODER_H #ifndef OAK_DECODER_H
#define DECODER_H #define OAK_DECODER_H
#include <QFileInfo> #include <QFileInfo>
#include <QMutex> #include <QMutex>
@@ -43,7 +43,7 @@ using DecoderPtr = std::shared_ptr<Decoder>;
#define DECODER_DEFAULT_DESTRUCTOR(x) \ #define DECODER_DEFAULT_DESTRUCTOR(x) \
virtual ~x() override \ virtual ~x() override \
{ \ { \
CloseInternal(); \ close_internal(); \
} }
/** /**
@@ -65,7 +65,7 @@ using DecoderPtr = std::shared_ptr<Decoder>;
class Decoder : public QObject { class Decoder : public QObject {
Q_OBJECT Q_OBJECT
public: public:
enum RetrieveState { kReady, kFailedToOpen, kIndexUnavailable }; enum RetrieveState { k_ready, k_failed_to_open, k_index_unavailable };
Decoder(); Decoder();
@@ -74,16 +74,16 @@ public:
*/ */
virtual QString id() const = 0; virtual QString id() const = 0;
virtual bool SupportsVideo() virtual bool supports_video()
{ {
return false; return false;
} }
virtual bool SupportsAudio() virtual bool supports_audio()
{ {
return false; return false;
} }
void IncrementAccessTime(qint64 t); void increment_access_time(qint64 t);
class CodecStream { class CodecStream {
public: public:
@@ -100,17 +100,17 @@ public:
{ {
} }
bool IsValid() const bool is_valid() const
{ {
return !filename_.isEmpty() && stream_ >= 0; return !filename_.isEmpty() && stream_ >= 0;
} }
bool Exists() const bool exists() const
{ {
return QFileInfo::exists(filename_); return QFileInfo::exists(filename_);
} }
void Reset() void reset()
{ {
*this = CodecStream(); *this = CodecStream();
} }
@@ -152,18 +152,18 @@ public:
* already open and the stream == the stream provided. Returns FALSE if the stream couldn't * already open and the stream == the stream provided. Returns FALSE if the stream couldn't
* be opened OR if already open and the stream is NOT the same. * be opened OR if already open and the stream is NOT the same.
*/ */
bool Open(const CodecStream &stream); bool open(const CodecStream &stream);
static const rational kAnyTimecode; static const Rational k_any_timecode;
struct RetrieveVideoParams { struct RetrieveVideoParams {
Renderer *renderer = nullptr; Renderer *renderer = nullptr;
rational time; Rational time;
int divider = 1; int divider = 1;
PixelFormat maximum_format = PixelFormat::INVALID; PixelFormat maximum_format = PixelFormat::invalid;
CancelAtom *cancelled = nullptr; CancelAtom *cancelled = nullptr;
VideoParams::ColorRange force_range = VideoParams::kColorRangeDefault; VideoParams::ColorRange force_range = VideoParams::k_color_range_default;
VideoParams::Interlacing src_interlacing = VideoParams::kInterlaceNone; VideoParams::Interlacing src_interlacing = VideoParams::k_interlace_none;
}; };
/** /**
@@ -176,7 +176,7 @@ public:
* *
* This function is thread safe and can only run while the decoder is open. \see Open() * This function is thread safe and can only run while the decoder is open. \see Open()
*/ */
TexturePtr RetrieveVideo(const RetrieveVideoParams &p); TexturePtr retrieve_video(const RetrieveVideoParams &p);
/** /**
* @brief Retrieves a decoded video frame in CPU memory. * @brief Retrieves a decoded video frame in CPU memory.
@@ -184,13 +184,13 @@ public:
* Used by render-process isolation to decode media in the main process and pass packed pixel * Used by render-process isolation to decode media in the main process and pass packed pixel
* data to workers through shared memory. * data to workers through shared memory.
*/ */
FramePtr RetrieveVideoFrame(const RetrieveVideoParams &p); FramePtr retrieve_video_frame(const RetrieveVideoParams &p);
enum RetrieveAudioStatus { enum RetrieveAudioStatus {
kInvalid = -1, k_invalid = -1,
kOK, k_ok,
kWaitingForConform, k_waiting_for_conform,
kUnknownError k_unknown_error
}; };
/** /**
@@ -202,14 +202,14 @@ public:
* This function is thread safe and can only run while the decoder is open. \see Open() * This function is thread safe and can only run while the decoder is open. \see Open()
*/ */
RetrieveAudioStatus RetrieveAudioStatus
RetrieveAudio(SampleBuffer &dest, const TimeRange &range, retrieve_audio(SampleBuffer &dest, const TimeRange &range,
const AudioParams &params, const QString &cache_path, const AudioParams &params, const QString &cache_path,
LoopMode loop_mode, RenderMode::Mode mode); LoopMode loop_mode, RenderMode::Mode mode);
/** /**
* @brief Determine the last time this decoder instance was used in any way * @brief Determine the last time this decoder instance was used in any way
*/ */
qint64 GetLastAccessedTime(); qint64 get_last_accessed_time();
/** /**
* @brief Generate a Footage object from a file * @brief Generate a Footage object from a file
@@ -222,7 +222,7 @@ public:
* *
* This function is re-entrant. * This function is re-entrant.
*/ */
virtual FootageDescription Probe(const QString &filename, virtual FootageDescription probe(const QString &filename,
CancelAtom *cancelled) const = 0; CancelAtom *cancelled) const = 0;
/** /**
@@ -230,12 +230,12 @@ public:
* *
* This function is thread safe and can only run while the decoder is open. \see Open() * This function is thread safe and can only run while the decoder is open. \see Open()
*/ */
void Close(); void close();
/** /**
* @brief Conform audio stream * @brief Conform audio stream
*/ */
bool ConformAudio(const QVector<QString> &output_filenames, bool conform_audio(const QVector<QString> &output_filenames,
const AudioParams &params, const AudioParams &params,
CancelAtom *cancelled = nullptr); CancelAtom *cancelled = nullptr);
@@ -246,16 +246,16 @@ public:
* *
* A Decoder instance or nullptr if a Decoder with this ID does not exist * A Decoder instance or nullptr if a Decoder with this ID does not exist
*/ */
static DecoderPtr CreateFromID(const QString &id); static DecoderPtr create_from_id(const QString &id);
static QString TransformImageSequenceFileName(const QString &filename, static QString transform_image_sequence_file_name(const QString &filename,
const int64_t &number); const int64_t &number);
static int GetImageSequenceDigitCount(const QString &filename); static int get_image_sequence_digit_count(const QString &filename);
static int64_t GetImageSequenceIndex(const QString &filename); static int64_t get_image_sequence_index(const QString &filename);
static QVector<DecoderPtr> ReceiveListOfAllDecoders(); static QVector<DecoderPtr> receive_list_of_all_decoders();
protected: protected:
/** /**
@@ -267,10 +267,10 @@ protected:
* decoder is not open yet and that the footage stream was from that sub-classes probe function. * decoder is not open yet and that the footage stream was from that sub-classes probe function.
* *
* Return TRUE if everything opened successfully and the decoder is ready to work. Otherwise, * Return TRUE if everything opened successfully and the decoder is ready to work. Otherwise,
* return FALSE. If this function returns false, Decoder will call CloseInternal to clean any * return FALSE. If this function returns false, Decoder will call close_internal to clean any
* memory allocated during OpenInternal. * memory allocated during OpenInternal.
*/ */
virtual bool OpenInternal() = 0; virtual bool open_internal() = 0;
/** /**
* @brief Internal close function * @brief Internal close function
@@ -278,7 +278,7 @@ protected:
* Sub-classes must override this function. Function should be able to safely clear all allocated * Sub-classes must override this function. Function should be able to safely clear all allocated
* memory. It may be called even if Open() didn't complete or RetrieveVideo() was never called. * memory. It may be called even if Open() didn't complete or RetrieveVideo() was never called.
*/ */
virtual void CloseInternal() = 0; virtual void close_internal() = 0;
/** /**
* @brief Internal frame retrieval function * @brief Internal frame retrieval function
@@ -286,15 +286,15 @@ protected:
* Sub-classes must override this function IF they support video. Function is already mutexed * Sub-classes must override this function IF they support video. Function is already mutexed
* so sub-classes don't need to worry about thread safety. * so sub-classes don't need to worry about thread safety.
*/ */
virtual TexturePtr RetrieveVideoInternal(const RetrieveVideoParams &p); virtual TexturePtr retrieve_video_internal(const RetrieveVideoParams &p);
virtual FramePtr RetrieveVideoFrameInternal(const RetrieveVideoParams &p); virtual FramePtr retrieve_video_frame_internal(const RetrieveVideoParams &p);
virtual bool ConformAudioInternal(const QVector<QString> &filenames, virtual bool conform_audio_internal(const QVector<QString> &filenames,
const AudioParams &params, const AudioParams &params,
CancelAtom *cancelled); CancelAtom *cancelled);
void SignalProcessingProgress(int64_t ts, int64_t duration); void signal_processing_progress(int64_t ts, int64_t duration);
/** /**
* @brief Return currently open stream * @brief Return currently open stream
@@ -306,7 +306,7 @@ protected:
return stream_; return stream_;
} }
virtual rational GetAudioStartOffset() const virtual Rational get_audio_start_offset() const
{ {
return 0; return 0;
} }
@@ -316,12 +316,12 @@ signals:
* @brief While indexing, this signal will provide progress as a percentage (0-100 inclusive) if * @brief While indexing, this signal will provide progress as a percentage (0-100 inclusive) if
* available * available
*/ */
void IndexProgress(double); void index_progress(double);
private: private:
void UpdateLastAccessed(); void update_last_accessed();
bool RetrieveAudioFromConform(SampleBuffer &sample_buffer, bool retrieve_audio_from_conform(SampleBuffer &sample_buffer,
const QVector<QString> &conform_filenames, const QVector<QString> &conform_filenames,
TimeRange range, LoopMode loop_mode, TimeRange range, LoopMode loop_mode,
const AudioParams &params); const AudioParams &params);
@@ -333,7 +333,7 @@ private:
std::atomic_int64_t last_accessed_; std::atomic_int64_t last_accessed_;
TexturePtr cached_texture_; TexturePtr cached_texture_;
rational cached_time_; Rational cached_time_;
int cached_divider_; int cached_divider_;
}; };
@@ -343,4 +343,4 @@ uint qHash(Decoder::CodecStream stream, uint seed = 0);
Q_DECLARE_METATYPE(olive::Decoder::RetrieveState) Q_DECLARE_METATYPE(olive::Decoder::RetrieveState)
#endif // DECODER_H #endif // OAK_DECODER_H
+82 -82
View File
@@ -30,9 +30,9 @@
namespace olive namespace olive
{ {
const QRegularExpression Encoder::kImageSequenceContainsDigits = const QRegularExpression Encoder::k_image_sequence_contains_digits =
QRegularExpression(QStringLiteral("\\[[#]+\\]")); QRegularExpression(QStringLiteral("\\[[#]+\\]"));
const QRegularExpression Encoder::kImageSequenceRemoveDigits = const QRegularExpression Encoder::k_image_sequence_remove_digits =
QRegularExpression(QStringLiteral("[\\-\\.\\ \\_]?\\[[#]+\\]")); QRegularExpression(QStringLiteral("[\\-\\.\\ \\_]?\\[[#]+\\]"));
Encoder::Encoder(const EncodingParams &params) Encoder::Encoder(const EncodingParams &params)
@@ -45,18 +45,18 @@ const EncodingParams &Encoder::params() const
return params_; return params_;
} }
QString Encoder::GetFilenameForFrame(const rational &frame) QString Encoder::get_filename_for_frame(const Rational &frame)
{ {
if (params().video_is_image_sequence()) { if (params().video_is_image_sequence()) {
// Transform! // Transform!
int64_t frame_index = Timecode::time_to_timestamp( int64_t frame_index = Timecode::time_to_timestamp(
frame, params().video_params().frame_rate_as_time_base()); frame, params().video_params().frame_rate_as_time_base());
int digits = GetImageSequencePlaceholderDigitCount(params().filename()); int digits = get_image_sequence_placeholder_digit_count(params().filename());
QString frame_index_str = QString frame_index_str =
QStringLiteral("%1").arg(frame_index, digits, 10, QChar('0')); QStringLiteral("%1").arg(frame_index, digits, 10, QChar('0'));
QString f = params_.filename(); QString f = params_.filename();
f.replace(kImageSequenceContainsDigits, frame_index_str); f.replace(k_image_sequence_contains_digits, frame_index_str);
return f; return f;
} else { } else {
// Keep filename // Keep filename
@@ -64,9 +64,9 @@ QString Encoder::GetFilenameForFrame(const rational &frame)
} }
} }
int Encoder::GetImageSequencePlaceholderDigitCount(const QString &filename) int Encoder::get_image_sequence_placeholder_digit_count(const QString &filename)
{ {
int start = filename.indexOf(kImageSequenceContainsDigits); int start = filename.indexOf(k_image_sequence_contains_digits);
int digit_count = 0; int digit_count = 0;
for (int i = start + 1; i < filename.size(); i++) { for (int i = start + 1; i < filename.size(); i++) {
if (filename.at(i) == '#') { if (filename.at(i) == '#') {
@@ -78,14 +78,14 @@ int Encoder::GetImageSequencePlaceholderDigitCount(const QString &filename)
return digit_count; return digit_count;
} }
bool Encoder::FilenameContainsDigitPlaceholder(const QString &filename) bool Encoder::filename_contains_digit_placeholder(const QString &filename)
{ {
return filename.contains(kImageSequenceContainsDigits); return filename.contains(k_image_sequence_contains_digits);
} }
QString Encoder::FilenameRemoveDigitPlaceholder(QString filename) QString Encoder::filename_remove_digit_placeholder(QString filename)
{ {
return filename.remove(kImageSequenceRemoveDigits); return filename.remove(k_image_sequence_remove_digits);
} }
EncodingParams::EncodingParams() EncodingParams::EncodingParams()
@@ -100,24 +100,24 @@ EncodingParams::EncodingParams()
, audio_bit_rate_(0) , audio_bit_rate_(0)
, subtitles_enabled_(false) , subtitles_enabled_(false)
, subtitles_are_sidecar_(false) , subtitles_are_sidecar_(false)
, video_scaling_method_(kStretch) , video_scaling_method_(k_stretch)
, has_custom_range_(false) , has_custom_range_(false)
{ {
} }
QDir EncodingParams::GetPresetPath() QDir EncodingParams::get_preset_path()
{ {
return QDir(FileFunctions::GetConfigurationLocation()) return QDir(FileFunctions::get_configuration_location())
.filePath(QStringLiteral("exportpresets")); .filePath(QStringLiteral("exportpresets"));
} }
QStringList EncodingParams::GetListOfPresets() QStringList EncodingParams::get_list_of_presets()
{ {
QDir d = EncodingParams::GetPresetPath(); QDir d = EncodingParams::get_preset_path();
return d.entryList(QDir::Files); return d.entryList(QDir::Files);
} }
void EncodingParams::EnableVideo(const VideoParams &video_params, void EncodingParams::enable_video(const VideoParams &video_params,
const ExportCodec::Codec &vcodec) const ExportCodec::Codec &vcodec)
{ {
video_enabled_ = true; video_enabled_ = true;
@@ -125,7 +125,7 @@ void EncodingParams::EnableVideo(const VideoParams &video_params,
video_codec_ = vcodec; video_codec_ = vcodec;
} }
void EncodingParams::EnableAudio(const AudioParams &audio_params, void EncodingParams::enable_audio(const AudioParams &audio_params,
const ExportCodec::Codec &acodec) const ExportCodec::Codec &acodec)
{ {
audio_enabled_ = true; audio_enabled_ = true;
@@ -133,13 +133,13 @@ void EncodingParams::EnableAudio(const AudioParams &audio_params,
audio_codec_ = acodec; audio_codec_ = acodec;
} }
void EncodingParams::EnableSubtitles(const ExportCodec::Codec &scodec) void EncodingParams::enable_subtitles(const ExportCodec::Codec &scodec)
{ {
subtitles_enabled_ = true; subtitles_enabled_ = true;
subtitles_codec_ = scodec; subtitles_codec_ = scodec;
} }
void EncodingParams::EnableSidecarSubtitles(const ExportFormat::Format &sfmt, void EncodingParams::enable_sidecar_subtitles(const ExportFormat::Format &sfmt,
const ExportCodec::Codec &scodec) const ExportCodec::Codec &scodec)
{ {
subtitles_enabled_ = true; subtitles_enabled_ = true;
@@ -148,24 +148,24 @@ void EncodingParams::EnableSidecarSubtitles(const ExportFormat::Format &sfmt,
subtitles_codec_ = scodec; subtitles_codec_ = scodec;
} }
void EncodingParams::DisableVideo() void EncodingParams::disable_video()
{ {
video_enabled_ = false; video_enabled_ = false;
} }
void EncodingParams::DisableAudio() void EncodingParams::disable_audio()
{ {
audio_enabled_ = false; audio_enabled_ = false;
} }
void EncodingParams::DisableSubtitles() void EncodingParams::disable_subtitles()
{ {
subtitles_enabled_ = false; subtitles_enabled_ = false;
} }
bool EncodingParams::Load(QXmlStreamReader *reader) bool EncodingParams::load(QXmlStreamReader *reader)
{ {
while (XMLReadNextStartElement(reader)) { while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("export")) { if (reader->name() == QStringLiteral("export")) {
int version = 0; int version = 0;
@@ -178,7 +178,7 @@ bool EncodingParams::Load(QXmlStreamReader *reader)
switch (version) { switch (version) {
case 1: case 1:
return LoadV1(reader); return load_v1(reader);
} }
} else { } else {
reader->skipCurrentElement(); reader->skipCurrentElement();
@@ -188,26 +188,26 @@ bool EncodingParams::Load(QXmlStreamReader *reader)
return false; return false;
} }
bool EncodingParams::Load(QIODevice *device) bool EncodingParams::load(QIODevice *device)
{ {
QXmlStreamReader reader(device); QXmlStreamReader reader(device);
return Load(&reader); return load(&reader);
} }
void EncodingParams::Save(QIODevice *device) const void EncodingParams::save(QIODevice *device) const
{ {
QXmlStreamWriter writer(device); QXmlStreamWriter writer(device);
Save(&writer); save(&writer);
} }
void EncodingParams::Save(QXmlStreamWriter *writer) const void EncodingParams::save(QXmlStreamWriter *writer) const
{ {
writer->writeStartDocument(); writer->writeStartDocument();
writer->writeStartElement(QStringLiteral("export")); writer->writeStartElement(QStringLiteral("export"));
writer->writeAttribute(QStringLiteral("version"), writer->writeAttribute(QStringLiteral("version"),
QString::number(kEncoderParamsVersion)); QString::number(k_encoder_params_version));
writer->writeTextElement(QStringLiteral("filename"), filename_); writer->writeTextElement(QStringLiteral("filename"), filename_);
writer->writeTextElement(QStringLiteral("format"), writer->writeTextElement(QStringLiteral("format"),
@@ -217,10 +217,10 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
QString::number(has_custom_range_)); QString::number(has_custom_range_));
writer->writeTextElement( writer->writeTextElement(
QStringLiteral("customrangein"), QStringLiteral("customrangein"),
QString::fromStdString(custom_range_.in().toString())); QString::fromStdString(custom_range_.in().to_string()));
writer->writeTextElement( writer->writeTextElement(
QStringLiteral("customrangeout"), QStringLiteral("customrangeout"),
QString::fromStdString(custom_range_.out().toString())); QString::fromStdString(custom_range_.out().to_string()));
writer->writeStartElement(QStringLiteral("video")); writer->writeStartElement(QStringLiteral("video"));
@@ -239,10 +239,10 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
writer->writeTextElement( writer->writeTextElement(
QStringLiteral("pixelaspect"), QStringLiteral("pixelaspect"),
QString::fromStdString( QString::fromStdString(
video_params_.pixel_aspect_ratio().toString())); video_params_.pixel_aspect_ratio().to_string()));
writer->writeTextElement( writer->writeTextElement(
QStringLiteral("timebase"), QStringLiteral("timebase"),
QString::fromStdString(video_params_.time_base().toString())); QString::fromStdString(video_params_.time_base().to_string()));
writer->writeTextElement(QStringLiteral("divider"), writer->writeTextElement(QStringLiteral("divider"),
QString::number(video_params_.divider())); QString::number(video_params_.divider()));
writer->writeTextElement(QStringLiteral("bitrate"), writer->writeTextElement(QStringLiteral("bitrate"),
@@ -332,77 +332,77 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
writer->writeEndDocument(); writer->writeEndDocument();
} }
Encoder *Encoder::CreateFromID(Type id, const EncodingParams &params) Encoder *Encoder::create_from_id(Type id, const EncodingParams &params)
{ {
switch (id) { switch (id) {
case kEncoderTypeNone: case k_encoder_type_none:
break; break;
case kEncoderTypeFFmpeg: case k_encoder_type_f_fmpeg:
return new FFmpegEncoder(params); return new FFmpegEncoder(params);
case kEncoderTypeOIIO: case k_encoder_type_oiio:
return new OIIOEncoder(params); return new OIIOEncoder(params);
} }
return nullptr; return nullptr;
} }
Encoder::Type Encoder::GetTypeFromFormat(ExportFormat::Format f) Encoder::Type Encoder::get_type_from_format(ExportFormat::Format f)
{ {
switch (f) { switch (f) {
case ExportFormat::kFormatDNxHD: case ExportFormat::k_format_d_nx_hd:
case ExportFormat::kFormatMatroska: case ExportFormat::k_format_matroska:
case ExportFormat::kFormatQuickTime: case ExportFormat::k_format_quick_time:
case ExportFormat::kFormatMPEG4Video: case ExportFormat::k_format_mpe_g4_video:
case ExportFormat::kFormatMPEG4Audio: case ExportFormat::k_format_mpe_g4_audio:
case ExportFormat::kFormatWAV: case ExportFormat::k_format_wav:
case ExportFormat::kFormatAIFF: case ExportFormat::k_format_aiff:
case ExportFormat::kFormatMP3: case ExportFormat::k_format_m_p3:
case ExportFormat::kFormatFLAC: case ExportFormat::k_format_flac:
case ExportFormat::kFormatOgg: case ExportFormat::k_format_ogg:
case ExportFormat::kFormatWebM: case ExportFormat::k_format_web_m:
case ExportFormat::kFormatSRT: case ExportFormat::k_format_srt:
return kEncoderTypeFFmpeg; return k_encoder_type_f_fmpeg;
case ExportFormat::kFormatOpenEXR: case ExportFormat::k_format_open_exr:
case ExportFormat::kFormatPNG: case ExportFormat::k_format_png:
case ExportFormat::kFormatTIFF: case ExportFormat::k_format_tiff:
return kEncoderTypeOIIO; return k_encoder_type_oiio;
case ExportFormat::kFormatCount: case ExportFormat::k_format_count:
break; break;
} }
return kEncoderTypeNone; return k_encoder_type_none;
} }
Encoder *Encoder::CreateFromFormat(ExportFormat::Format f, Encoder *Encoder::create_from_format(ExportFormat::Format f,
const EncodingParams &params) const EncodingParams &params)
{ {
return CreateFromID(GetTypeFromFormat(f), params); return create_from_id(get_type_from_format(f), params);
} }
Encoder *Encoder::CreateFromParams(const EncodingParams &params) Encoder *Encoder::create_from_params(const EncodingParams &params)
{ {
return CreateFromFormat(params.format(), params); return create_from_format(params.format(), params);
} }
QStringList Encoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const QStringList Encoder::get_pixel_formats_for_codec(ExportCodec::Codec c) const
{ {
return QStringList(); return QStringList();
} }
std::vector<SampleFormat> std::vector<SampleFormat>
Encoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const Encoder::get_sample_formats_for_codec(ExportCodec::Codec c) const
{ {
return std::vector<SampleFormat>(); return std::vector<SampleFormat>();
} }
QMatrix4x4 QMatrix4x4
EncodingParams::GenerateMatrix(EncodingParams::VideoScalingMethod method, EncodingParams::generate_matrix(EncodingParams::VideoScalingMethod method,
int source_width, int source_height, int source_width, int source_height,
int dest_width, int dest_height) int dest_width, int dest_height)
{ {
QMatrix4x4 preview_matrix; QMatrix4x4 preview_matrix;
if (method == EncodingParams::kStretch) { if (method == EncodingParams::k_stretch) {
return preview_matrix; return preview_matrix;
} }
@@ -415,7 +415,7 @@ EncodingParams::GenerateMatrix(EncodingParams::VideoScalingMethod method,
return preview_matrix; return preview_matrix;
} }
if ((export_ar > source_ar) == (method == EncodingParams::kFit)) { if ((export_ar > source_ar) == (method == EncodingParams::k_fit)) {
preview_matrix.scale(source_ar / export_ar, 1.0F); preview_matrix.scale(source_ar / export_ar, 1.0F);
} else { } else {
preview_matrix.scale(1.0F, export_ar / source_ar); preview_matrix.scale(1.0F, export_ar / source_ar);
@@ -424,11 +424,11 @@ EncodingParams::GenerateMatrix(EncodingParams::VideoScalingMethod method,
return preview_matrix; return preview_matrix;
} }
bool EncodingParams::LoadV1(QXmlStreamReader *reader) bool EncodingParams::load_v1(QXmlStreamReader *reader)
{ {
rational custom_range_in, custom_range_out; Rational custom_range_in, custom_range_out;
while (XMLReadNextStartElement(reader)) { while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("filename")) { if (reader->name() == QStringLiteral("filename")) {
filename_ = reader->readElementText(); filename_ = reader->readElementText();
} else if (reader->name() == QStringLiteral("format")) { } else if (reader->name() == QStringLiteral("format")) {
@@ -438,10 +438,10 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
has_custom_range_ = reader->readElementText().toInt(); has_custom_range_ = reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("customrangein")) { } else if (reader->name() == QStringLiteral("customrangein")) {
custom_range_in = custom_range_in =
rational::fromString(reader->readElementText().toStdString()); Rational::from_string(reader->readElementText().toStdString());
} else if (reader->name() == QStringLiteral("customrangeout")) { } else if (reader->name() == QStringLiteral("customrangeout")) {
custom_range_out = custom_range_out =
rational::fromString(reader->readElementText().toStdString()); Rational::from_string(reader->readElementText().toStdString());
} else if (reader->name() == QStringLiteral("video")) { } else if (reader->name() == QStringLiteral("video")) {
XMLAttributeLoop(reader, attr) XMLAttributeLoop(reader, attr)
{ {
@@ -450,7 +450,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
} }
} }
while (XMLReadNextStartElement(reader)) { while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("codec")) { if (reader->name() == QStringLiteral("codec")) {
video_codec_ = static_cast<ExportCodec::Codec>( video_codec_ = static_cast<ExportCodec::Codec>(
reader->readElementText().toInt()); reader->readElementText().toInt());
@@ -462,10 +462,10 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
video_params_.set_format(static_cast<PixelFormat::Format>( video_params_.set_format(static_cast<PixelFormat::Format>(
reader->readElementText().toInt())); reader->readElementText().toInt()));
} else if (reader->name() == QStringLiteral("pixelaspect")) { } else if (reader->name() == QStringLiteral("pixelaspect")) {
video_params_.set_pixel_aspect_ratio(rational::fromString( video_params_.set_pixel_aspect_ratio(Rational::from_string(
reader->readElementText().toStdString())); reader->readElementText().toStdString()));
} else if (reader->name() == QStringLiteral("timebase")) { } else if (reader->name() == QStringLiteral("timebase")) {
video_params_.set_time_base(rational::fromString( video_params_.set_time_base(Rational::from_string(
reader->readElementText().toStdString())); reader->readElementText().toStdString()));
} else if (reader->name() == QStringLiteral("divider")) { } else if (reader->name() == QStringLiteral("divider")) {
video_params_.set_divider( video_params_.set_divider(
@@ -488,7 +488,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
video_is_image_sequence_ = video_is_image_sequence_ =
reader->readElementText().toInt(); reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("color")) { } else if (reader->name() == QStringLiteral("color")) {
while (XMLReadNextStartElement(reader)) { while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("output")) { if (reader->name() == QStringLiteral("output")) {
color_transform_ = reader->readElementText(); color_transform_ = reader->readElementText();
} else { } else {
@@ -499,10 +499,10 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
video_scaling_method_ = static_cast<VideoScalingMethod>( video_scaling_method_ = static_cast<VideoScalingMethod>(
reader->readElementText().toInt()); reader->readElementText().toInt());
} else if (reader->name() == QStringLiteral("opts")) { } else if (reader->name() == QStringLiteral("opts")) {
while (XMLReadNextStartElement(reader)) { while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("entry")) { if (reader->name() == QStringLiteral("entry")) {
QString key, value; QString key, value;
while (XMLReadNextStartElement(reader)) { while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("key")) { if (reader->name() == QStringLiteral("key")) {
key = reader->readElementText(); key = reader->readElementText();
} else if (reader->name() == } else if (reader->name() ==
@@ -534,7 +534,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
} }
} }
while (XMLReadNextStartElement(reader)) { while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("codec")) { if (reader->name() == QStringLiteral("codec")) {
audio_codec_ = static_cast<ExportCodec::Codec>( audio_codec_ = static_cast<ExportCodec::Codec>(
reader->readElementText().toInt()); reader->readElementText().toInt());
@@ -566,7 +566,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
} }
} }
while (XMLReadNextStartElement(reader)) { while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("sidecar")) { if (reader->name() == QStringLiteral("sidecar")) {
subtitles_are_sidecar_ = reader->readElementText().toInt(); subtitles_are_sidecar_ = reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("sidecarformat")) { } else if (reader->name() == QStringLiteral("sidecarformat")) {
+53 -53
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef ENCODER_H #ifndef OAK_ENCODER_H
#define ENCODER_H #define OAK_ENCODER_H
#include <memory> #include <memory>
#include <QRegularExpression> #include <QRegularExpression>
@@ -43,34 +43,34 @@ using EncoderPtr = std::shared_ptr<Encoder>;
class EncodingParams { class EncodingParams {
public: public:
enum VideoScalingMethod { kFit, kStretch, kCrop }; enum VideoScalingMethod { k_fit, k_stretch, k_crop };
EncodingParams(); EncodingParams();
static QDir GetPresetPath(); static QDir get_preset_path();
static QStringList GetListOfPresets(); static QStringList get_list_of_presets();
bool IsValid() const bool is_valid() const
{ {
return video_enabled_ || audio_enabled_ || subtitles_enabled_; return video_enabled_ || audio_enabled_ || subtitles_enabled_;
} }
void SetFilename(const QString &filename) void set_filename(const QString &filename)
{ {
filename_ = filename; filename_ = filename;
} }
void EnableVideo(const VideoParams &video_params, void enable_video(const VideoParams &video_params,
const ExportCodec::Codec &vcodec); const ExportCodec::Codec &vcodec);
void EnableAudio(const AudioParams &audio_params, void enable_audio(const AudioParams &audio_params,
const ExportCodec::Codec &acodec); const ExportCodec::Codec &acodec);
void EnableSubtitles(const ExportCodec::Codec &scodec); void enable_subtitles(const ExportCodec::Codec &scodec);
void EnableSidecarSubtitles(const ExportFormat::Format &sfmt, void enable_sidecar_subtitles(const ExportFormat::Format &sfmt,
const ExportCodec::Codec &scodec); const ExportCodec::Codec &scodec);
void DisableVideo(); void disable_video();
void DisableAudio(); void disable_audio();
void DisableSubtitles(); void disable_subtitles();
const ExportFormat::Format &format() const const ExportFormat::Format &format() const
{ {
@@ -219,20 +219,20 @@ public:
return subtitles_codec_; return subtitles_codec_;
} }
const rational &GetExportLength() const const Rational &get_export_length() const
{ {
return export_length_; return export_length_;
} }
void SetExportLength(const rational &export_length) void set_export_length(const Rational &export_length)
{ {
export_length_ = export_length; export_length_ = export_length;
} }
bool Load(QIODevice *device); bool load(QIODevice *device);
bool Load(QXmlStreamReader *reader); bool load(QXmlStreamReader *reader);
void Save(QIODevice *device) const; void save(QIODevice *device) const;
void Save(QXmlStreamWriter *writer) const; void save(QXmlStreamWriter *writer) const;
bool has_custom_range() const bool has_custom_range() const
{ {
@@ -258,20 +258,20 @@ public:
video_scaling_method_ = video_scaling_method; video_scaling_method_ = video_scaling_method;
} }
static QMatrix4x4 GenerateMatrix(VideoScalingMethod method, static QMatrix4x4 generate_matrix(VideoScalingMethod method,
int source_width, int source_height, int source_width, int source_height,
int dest_width, int dest_height); int dest_width, int dest_height);
private: private:
static const int kEncoderParamsVersion = 1; static const int k_encoder_params_version = 1;
bool LoadV1(QXmlStreamReader *reader); bool load_v1(QXmlStreamReader *reader);
QString filename_; QString filename_;
ExportFormat::Format format_ = ExportFormat::kFormatCount; ExportFormat::Format format_ = ExportFormat::k_format_count;
bool video_enabled_; bool video_enabled_;
ExportCodec::Codec video_codec_ = ExportCodec::kCodecCount; ExportCodec::Codec video_codec_ = ExportCodec::k_codec_count;
VideoParams video_params_; VideoParams video_params_;
QHash<QString, QString> video_opts_; QHash<QString, QString> video_opts_;
int64_t video_bit_rate_; int64_t video_bit_rate_;
@@ -284,16 +284,16 @@ private:
ColorTransform color_transform_; ColorTransform color_transform_;
bool audio_enabled_; bool audio_enabled_;
ExportCodec::Codec audio_codec_ = ExportCodec::kCodecCount; ExportCodec::Codec audio_codec_ = ExportCodec::k_codec_count;
AudioParams audio_params_; AudioParams audio_params_;
int64_t audio_bit_rate_; int64_t audio_bit_rate_;
bool subtitles_enabled_; bool subtitles_enabled_;
bool subtitles_are_sidecar_; bool subtitles_are_sidecar_;
ExportFormat::Format subtitle_sidecar_fmt_ = ExportFormat::kFormatCount; ExportFormat::Format subtitle_sidecar_fmt_ = ExportFormat::k_format_count;
ExportCodec::Codec subtitles_codec_ = ExportCodec::kCodecCount; ExportCodec::Codec subtitles_codec_ = ExportCodec::k_codec_count;
rational export_length_; Rational export_length_;
VideoScalingMethod video_scaling_method_; VideoScalingMethod video_scaling_method_;
bool has_custom_range_; bool has_custom_range_;
@@ -305,7 +305,7 @@ class Encoder : public QObject {
public: public:
Encoder(const EncodingParams &params); Encoder(const EncodingParams &params);
enum Type { kEncoderTypeNone = -1, kEncoderTypeFFmpeg, kEncoderTypeOIIO }; enum Type { k_encoder_type_none = -1, k_encoder_type_f_fmpeg, k_encoder_type_oiio };
/** /**
* @brief Create a Encoder instance using a Encoder ID * @brief Create a Encoder instance using a Encoder ID
@@ -314,53 +314,53 @@ public:
* *
* A Encoder instance or nullptr if a Decoder with this ID does not exist * A Encoder instance or nullptr if a Decoder with this ID does not exist
*/ */
static Encoder *CreateFromID(Type id, const EncodingParams &params); static Encoder *create_from_id(Type id, const EncodingParams &params);
static Type GetTypeFromFormat(ExportFormat::Format f); static Type get_type_from_format(ExportFormat::Format f);
static Encoder *CreateFromFormat(ExportFormat::Format f, static Encoder *create_from_format(ExportFormat::Format f,
const EncodingParams &params); const EncodingParams &params);
static Encoder *CreateFromParams(const EncodingParams &params); static Encoder *create_from_params(const EncodingParams &params);
virtual QStringList GetPixelFormatsForCodec(ExportCodec::Codec c) const; virtual QStringList get_pixel_formats_for_codec(ExportCodec::Codec c) const;
virtual std::vector<SampleFormat> virtual std::vector<SampleFormat>
GetSampleFormatsForCodec(ExportCodec::Codec c) const; get_sample_formats_for_codec(ExportCodec::Codec c) const;
const EncodingParams &params() const; const EncodingParams &params() const;
virtual PixelFormat GetDesiredPixelFormat() const virtual PixelFormat get_desired_pixel_format() const
{ {
return PixelFormat::INVALID; return PixelFormat::invalid;
} }
const QString &GetError() const const QString &get_error() const
{ {
return error_; return error_;
} }
QString GetFilenameForFrame(const rational &frame); QString get_filename_for_frame(const Rational &frame);
static int GetImageSequencePlaceholderDigitCount(const QString &filename); static int get_image_sequence_placeholder_digit_count(const QString &filename);
static bool FilenameContainsDigitPlaceholder(const QString &filename); static bool filename_contains_digit_placeholder(const QString &filename);
static QString FilenameRemoveDigitPlaceholder(QString filename); static QString filename_remove_digit_placeholder(QString filename);
static const QRegularExpression kImageSequenceContainsDigits; static const QRegularExpression k_image_sequence_contains_digits;
static const QRegularExpression kImageSequenceRemoveDigits; static const QRegularExpression k_image_sequence_remove_digits;
public slots: public slots:
virtual bool Open() = 0; virtual bool open() = 0;
virtual bool WriteFrame(olive::FramePtr frame, virtual bool write_frame(olive::FramePtr frame,
olive::core::rational time) = 0; olive::core::Rational time) = 0;
virtual bool WriteAudio(const olive::SampleBuffer &audio) = 0; virtual bool write_audio(const olive::SampleBuffer &audio) = 0;
virtual bool WriteSubtitle(const SubtitleBlock *sub_block) = 0; virtual bool write_subtitle(const SubtitleBlock *sub_block) = 0;
virtual void Close() = 0; virtual void close() = 0;
protected: protected:
void SetError(const QString &err) void set_error(const QString &err)
{ {
error_ = err; error_ = err;
} }
@@ -373,4 +373,4 @@ private:
} }
#endif // ENCODER_H #endif // OAK_ENCODER_H
+63 -63
View File
@@ -27,109 +27,109 @@ extern "C" {
namespace olive namespace olive
{ {
QString ExportCodec::GetCodecName(ExportCodec::Codec c) QString ExportCodec::get_codec_name(ExportCodec::Codec c)
{ {
switch (c) { switch (c) {
case kCodecDNxHD: case k_codec_d_nx_hd:
return tr("DNxHD"); return tr("DNxHD");
case kCodecH264: case k_codec_h264:
return tr("H.264"); return tr("H.264");
case kCodecH264rgb: case k_codec_h264rgb:
return tr("H.264 RGB"); return tr("H.264 RGB");
case kCodecH265: case k_codec_h265:
return tr("H.265"); return tr("H.265");
case kCodecOpenEXR: case k_codec_open_exr:
return tr("OpenEXR"); return tr("OpenEXR");
case kCodecPNG: case k_codec_png:
return tr("PNG"); return tr("PNG");
case kCodecProRes: case k_codec_pro_res:
return tr("ProRes"); return tr("ProRes");
case kCodecCineform: case k_codec_cineform:
return tr("Cineform"); return tr("Cineform");
case kCodecTIFF: case k_codec_tiff:
return tr("TIFF"); return tr("TIFF");
case kCodecMP2: case k_codec_m_p2:
return tr("MP2"); return tr("MP2");
case kCodecMP3: case k_codec_m_p3:
return tr("MP3"); return tr("MP3");
case kCodecAAC: case k_codec_aac:
return tr("AAC"); return tr("AAC");
case kCodecPCM: case k_codec_pcm:
return tr("PCM (Uncompressed)"); return tr("PCM (Uncompressed)");
case kCodecFLAC: case k_codec_flac:
return tr("FLAC"); return tr("FLAC");
case kCodecOpus: case k_codec_opus:
return tr("Opus"); return tr("Opus");
case kCodecVorbis: case k_codec_vorbis:
return tr("Vorbis"); return tr("Vorbis");
case kCodecVP9: case k_codec_v_p9:
return tr("VP9"); return tr("VP9");
case kCodecAV1: case k_codec_a_v1:
return tr("AV1"); return tr("AV1");
case kCodecSRT: case k_codec_srt:
return tr("SubRip SRT"); return tr("SubRip SRT");
case kCodecCount: case k_codec_count:
break; break;
} }
return tr("Unknown"); return tr("Unknown");
} }
bool ExportCodec::IsCodecAStillImage(ExportCodec::Codec c) bool ExportCodec::is_codec_a_still_image(ExportCodec::Codec c)
{ {
switch (c) { switch (c) {
case kCodecDNxHD: case k_codec_d_nx_hd:
case kCodecH264: case k_codec_h264:
case kCodecH264rgb: case k_codec_h264rgb:
case kCodecH265: case k_codec_h265:
case kCodecProRes: case k_codec_pro_res:
case kCodecCineform: case k_codec_cineform:
case kCodecMP2: case k_codec_m_p2:
case kCodecMP3: case k_codec_m_p3:
case kCodecAAC: case k_codec_aac:
case kCodecPCM: case k_codec_pcm:
case kCodecVorbis: case k_codec_vorbis:
case kCodecOpus: case k_codec_opus:
case kCodecFLAC: case k_codec_flac:
case kCodecVP9: case k_codec_v_p9:
case kCodecAV1: case k_codec_a_v1:
case kCodecSRT: case k_codec_srt:
return false; return false;
case kCodecOpenEXR: case k_codec_open_exr:
case kCodecPNG: case k_codec_png:
case kCodecTIFF: case k_codec_tiff:
return true; return true;
case kCodecCount: case k_codec_count:
break; break;
} }
return false; return false;
} }
bool ExportCodec::IsCodecLossless(Codec c) bool ExportCodec::is_codec_lossless(Codec c)
{ {
switch (c) { switch (c) {
case kCodecPCM: case k_codec_pcm:
case kCodecFLAC: case k_codec_flac:
return true; return true;
case kCodecDNxHD: case k_codec_d_nx_hd:
case kCodecH264: case k_codec_h264:
case kCodecH264rgb: case k_codec_h264rgb:
case kCodecH265: case k_codec_h265:
case kCodecProRes: case k_codec_pro_res:
case kCodecCineform: case k_codec_cineform:
case kCodecMP2: case k_codec_m_p2:
case kCodecMP3: case k_codec_m_p3:
case kCodecAAC: case k_codec_aac:
case kCodecVorbis: case k_codec_vorbis:
case kCodecOpus: case k_codec_opus:
case kCodecVP9: case k_codec_v_p9:
case kCodecAV1: case k_codec_a_v1:
case kCodecSRT: case k_codec_srt:
case kCodecOpenEXR: case k_codec_open_exr:
case kCodecPNG: case k_codec_png:
case kCodecTIFF: case k_codec_tiff:
case kCodecCount: case k_codec_count:
break; break;
} }
+26 -26
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef EXPORTCODEC_H #ifndef OAK_EXPORTCODEC_H
#define EXPORTCODEC_H #define OAK_EXPORTCODEC_H
#include <QObject> #include <QObject>
#include <QString> #include <QString>
@@ -36,36 +36,36 @@ class ExportCodec : public QObject {
public: public:
// Only append to this list (never insert) because indexes are used in serialized files // Only append to this list (never insert) because indexes are used in serialized files
enum Codec { enum Codec {
kCodecDNxHD, k_codec_d_nx_hd,
kCodecH264, k_codec_h264,
kCodecH264rgb, k_codec_h264rgb,
kCodecH265, k_codec_h265,
kCodecOpenEXR, k_codec_open_exr,
kCodecPNG, k_codec_png,
kCodecProRes, k_codec_pro_res,
kCodecCineform, k_codec_cineform,
kCodecTIFF, k_codec_tiff,
kCodecVP9, k_codec_v_p9,
kCodecMP2, k_codec_m_p2,
kCodecMP3, k_codec_m_p3,
kCodecAAC, k_codec_aac,
kCodecPCM, k_codec_pcm,
kCodecOpus, k_codec_opus,
kCodecVorbis, k_codec_vorbis,
kCodecFLAC, k_codec_flac,
kCodecSRT, k_codec_srt,
kCodecAV1, k_codec_a_v1,
kCodecCount k_codec_count
}; };
static QString GetCodecName(Codec c); static QString get_codec_name(Codec c);
static bool IsCodecAStillImage(Codec c); static bool is_codec_a_still_image(Codec c);
static bool IsCodecLossless(Codec c); static bool is_codec_lossless(Codec c);
}; };
} }
#endif // EXPORTCODEC_H #endif // OAK_EXPORTCODEC_H
+122 -122
View File
@@ -26,206 +26,206 @@
namespace olive namespace olive
{ {
QString ExportFormat::GetName(olive::ExportFormat::Format f) QString ExportFormat::get_name(olive::ExportFormat::Format f)
{ {
switch (f) { switch (f) {
case kFormatDNxHD: case k_format_d_nx_hd:
return tr("DNxHD"); return tr("DNxHD");
case kFormatMatroska: case k_format_matroska:
return tr("Matroska Video"); return tr("Matroska Video");
case kFormatMPEG4Video: case k_format_mpe_g4_video:
return tr("MPEG-4 Video"); return tr("MPEG-4 Video");
case kFormatMPEG4Audio: case k_format_mpe_g4_audio:
return tr("MPEG-4 Audio"); return tr("MPEG-4 Audio");
case kFormatOpenEXR: case k_format_open_exr:
return tr("OpenEXR"); return tr("OpenEXR");
case kFormatPNG: case k_format_png:
return tr("PNG"); return tr("PNG");
case kFormatTIFF: case k_format_tiff:
return tr("TIFF"); return tr("TIFF");
case kFormatQuickTime: case k_format_quick_time:
return tr("QuickTime"); return tr("QuickTime");
case kFormatWAV: case k_format_wav:
return tr("Wave Audio"); return tr("Wave Audio");
case kFormatAIFF: case k_format_aiff:
return tr("AIFF"); return tr("AIFF");
case kFormatMP3: case k_format_m_p3:
return tr("MP3"); return tr("MP3");
case kFormatFLAC: case k_format_flac:
return tr("FLAC"); return tr("FLAC");
case kFormatOgg: case k_format_ogg:
return tr("Ogg"); return tr("Ogg");
case kFormatWebM: case k_format_web_m:
return tr("WebM"); return tr("WebM");
case kFormatSRT: case k_format_srt:
return tr("SubRip SRT"); return tr("SubRip SRT");
case kFormatCount: case k_format_count:
break; break;
} }
return tr("Unknown"); return tr("Unknown");
} }
QString ExportFormat::GetExtension(ExportFormat::Format f) QString ExportFormat::get_extension(ExportFormat::Format f)
{ {
switch (f) { switch (f) {
case kFormatDNxHD: case k_format_d_nx_hd:
return QStringLiteral("mxf"); return QStringLiteral("mxf");
case kFormatMatroska: case k_format_matroska:
return QStringLiteral("mkv"); return QStringLiteral("mkv");
case kFormatMPEG4Video: case k_format_mpe_g4_video:
return QStringLiteral("mp4"); return QStringLiteral("mp4");
case kFormatMPEG4Audio: case k_format_mpe_g4_audio:
return QStringLiteral("m4a"); return QStringLiteral("m4a");
case kFormatOpenEXR: case k_format_open_exr:
return QStringLiteral("exr"); return QStringLiteral("exr");
case kFormatPNG: case k_format_png:
return QStringLiteral("png"); return QStringLiteral("png");
case kFormatTIFF: case k_format_tiff:
return QStringLiteral("tiff"); return QStringLiteral("tiff");
case kFormatQuickTime: case k_format_quick_time:
return QStringLiteral("mov"); return QStringLiteral("mov");
case kFormatWAV: case k_format_wav:
return QStringLiteral("wav"); return QStringLiteral("wav");
case kFormatAIFF: case k_format_aiff:
return QStringLiteral("aiff"); return QStringLiteral("aiff");
case kFormatMP3: case k_format_m_p3:
return QStringLiteral("mp3"); return QStringLiteral("mp3");
case kFormatFLAC: case k_format_flac:
return QStringLiteral("flac"); return QStringLiteral("flac");
case kFormatOgg: case k_format_ogg:
return QStringLiteral("ogg"); return QStringLiteral("ogg");
case kFormatWebM: case k_format_web_m:
return QStringLiteral("webm"); return QStringLiteral("webm");
case kFormatSRT: case k_format_srt:
return QStringLiteral("srt"); return QStringLiteral("srt");
case kFormatCount: case k_format_count:
break; break;
} }
return QString(); return QString();
} }
QList<ExportCodec::Codec> ExportFormat::GetVideoCodecs(ExportFormat::Format f) QList<ExportCodec::Codec> ExportFormat::get_video_codecs(ExportFormat::Format f)
{ {
switch (f) { switch (f) {
case kFormatDNxHD: case k_format_d_nx_hd:
return { ExportCodec::kCodecDNxHD }; return { ExportCodec::k_codec_d_nx_hd };
case kFormatMatroska: case k_format_matroska:
return { ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb, return { ExportCodec::k_codec_h264, ExportCodec::k_codec_h264rgb,
ExportCodec::kCodecH265, ExportCodec::kCodecVP9 }; ExportCodec::k_codec_h265, ExportCodec::k_codec_v_p9 };
case kFormatMPEG4Video: case k_format_mpe_g4_video:
return { ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb, return { ExportCodec::k_codec_h264, ExportCodec::k_codec_h264rgb,
ExportCodec::kCodecH265 }; ExportCodec::k_codec_h265 };
case kFormatOpenEXR: case k_format_open_exr:
return { ExportCodec::kCodecOpenEXR }; return { ExportCodec::k_codec_open_exr };
case kFormatPNG: case k_format_png:
return { ExportCodec::kCodecPNG }; return { ExportCodec::k_codec_png };
case kFormatTIFF: case k_format_tiff:
return { ExportCodec::kCodecTIFF }; return { ExportCodec::k_codec_tiff };
case kFormatQuickTime: case k_format_quick_time:
return { ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb, return { ExportCodec::k_codec_h264, ExportCodec::k_codec_h264rgb,
ExportCodec::kCodecH265, ExportCodec::kCodecProRes, ExportCodec::k_codec_h265, ExportCodec::k_codec_pro_res,
ExportCodec::kCodecCineform }; ExportCodec::k_codec_cineform };
case kFormatWebM: case k_format_web_m:
return { ExportCodec::kCodecAV1, ExportCodec::kCodecVP9 }; return { ExportCodec::k_codec_a_v1, ExportCodec::k_codec_v_p9 };
case kFormatOgg: case k_format_ogg:
case kFormatWAV: case k_format_wav:
case kFormatMPEG4Audio: case k_format_mpe_g4_audio:
case kFormatAIFF: case k_format_aiff:
case kFormatMP3: case k_format_m_p3:
case kFormatFLAC: case k_format_flac:
case kFormatSRT: case k_format_srt:
case kFormatCount: case k_format_count:
break; break;
} }
return {}; return {};
} }
QList<ExportCodec::Codec> ExportFormat::GetAudioCodecs(ExportFormat::Format f) QList<ExportCodec::Codec> ExportFormat::get_audio_codecs(ExportFormat::Format f)
{ {
switch (f) { switch (f) {
// Video/audio formats // Video/audio formats
case kFormatDNxHD: case k_format_d_nx_hd:
return { ExportCodec::kCodecPCM }; return { ExportCodec::k_codec_pcm };
case kFormatMatroska: case k_format_matroska:
return { ExportCodec::kCodecAAC, ExportCodec::kCodecMP2, return { ExportCodec::k_codec_aac, ExportCodec::k_codec_m_p2,
ExportCodec::kCodecMP3, ExportCodec::kCodecPCM, ExportCodec::k_codec_m_p3, ExportCodec::k_codec_pcm,
ExportCodec::kCodecVorbis, ExportCodec::kCodecOpus, ExportCodec::k_codec_vorbis, ExportCodec::k_codec_opus,
ExportCodec::kCodecFLAC }; ExportCodec::k_codec_flac };
case kFormatMPEG4Video: case k_format_mpe_g4_video:
case kFormatMPEG4Audio: case k_format_mpe_g4_audio:
return { ExportCodec::kCodecAAC, ExportCodec::kCodecMP2, return { ExportCodec::k_codec_aac, ExportCodec::k_codec_m_p2,
ExportCodec::kCodecMP3 }; ExportCodec::k_codec_m_p3 };
case kFormatQuickTime: case k_format_quick_time:
return { ExportCodec::kCodecAAC, ExportCodec::kCodecMP2, return { ExportCodec::k_codec_aac, ExportCodec::k_codec_m_p2,
ExportCodec::kCodecMP3, ExportCodec::kCodecPCM }; ExportCodec::k_codec_m_p3, ExportCodec::k_codec_pcm };
case kFormatWebM: case k_format_web_m:
return { ExportCodec::kCodecOpus, ExportCodec::kCodecAAC, return { ExportCodec::k_codec_opus, ExportCodec::k_codec_aac,
ExportCodec::kCodecMP2, ExportCodec::kCodecMP3, ExportCodec::k_codec_m_p2, ExportCodec::k_codec_m_p3,
ExportCodec::kCodecPCM, ExportCodec::kCodecVorbis }; ExportCodec::k_codec_pcm, ExportCodec::k_codec_vorbis };
// Audio only formats // Audio only formats
case kFormatWAV: case k_format_wav:
return { ExportCodec::kCodecPCM }; return { ExportCodec::k_codec_pcm };
case kFormatAIFF: case k_format_aiff:
return { ExportCodec::kCodecPCM }; return { ExportCodec::k_codec_pcm };
case kFormatMP3: case k_format_m_p3:
return { ExportCodec::kCodecMP3 }; return { ExportCodec::k_codec_m_p3 };
case kFormatFLAC: case k_format_flac:
return { ExportCodec::kCodecFLAC }; return { ExportCodec::k_codec_flac };
case kFormatOgg: case k_format_ogg:
return { ExportCodec::kCodecOpus, ExportCodec::kCodecVorbis, return { ExportCodec::k_codec_opus, ExportCodec::k_codec_vorbis,
ExportCodec::kCodecPCM }; ExportCodec::k_codec_pcm };
// Video only formats // Video only formats
case kFormatOpenEXR: case k_format_open_exr:
case kFormatPNG: case k_format_png:
case kFormatTIFF: case k_format_tiff:
case kFormatSRT: case k_format_srt:
case kFormatCount: case k_format_count:
break; break;
} }
return {}; return {};
} }
QList<ExportCodec::Codec> ExportFormat::GetSubtitleCodecs(Format f) QList<ExportCodec::Codec> ExportFormat::get_subtitle_codecs(Format f)
{ {
switch (f) { switch (f) {
case kFormatDNxHD: case k_format_d_nx_hd:
case kFormatMPEG4Video: case k_format_mpe_g4_video:
case kFormatMPEG4Audio: case k_format_mpe_g4_audio:
case kFormatOpenEXR: case k_format_open_exr:
case kFormatQuickTime: case k_format_quick_time:
case kFormatPNG: case k_format_png:
case kFormatTIFF: case k_format_tiff:
case kFormatWAV: case k_format_wav:
case kFormatAIFF: case k_format_aiff:
case kFormatMP3: case k_format_m_p3:
case kFormatFLAC: case k_format_flac:
case kFormatOgg: case k_format_ogg:
case kFormatWebM: case k_format_web_m:
case kFormatCount: case k_format_count:
break; break;
case kFormatMatroska: case k_format_matroska:
case kFormatSRT: case k_format_srt:
return { ExportCodec::kCodecSRT }; return { ExportCodec::k_codec_srt };
} }
return {}; return {};
} }
QStringList ExportFormat::GetPixelFormatsForCodec(ExportFormat::Format f, QStringList ExportFormat::get_pixel_formats_for_codec(ExportFormat::Format f,
ExportCodec::Codec c) ExportCodec::Codec c)
{ {
Encoder *e = Encoder::CreateFromFormat(f, EncodingParams()); Encoder *e = Encoder::create_from_format(f, EncodingParams());
QStringList list; QStringList list;
if (e) { if (e) {
list = e->GetPixelFormatsForCodec(c); list = e->get_pixel_formats_for_codec(c);
delete e; delete e;
} }
@@ -233,13 +233,13 @@ QStringList ExportFormat::GetPixelFormatsForCodec(ExportFormat::Format f,
} }
std::vector<SampleFormat> std::vector<SampleFormat>
ExportFormat::GetSampleFormatsForCodec(Format format, ExportCodec::Codec c) ExportFormat::get_sample_formats_for_codec(Format format, ExportCodec::Codec c)
{ {
std::vector<SampleFormat> f; std::vector<SampleFormat> f;
Encoder *e = Encoder::CreateFromFormat(format, EncodingParams()); Encoder *e = Encoder::create_from_format(format, EncodingParams());
if (e) { if (e) {
f = e->GetSampleFormatsForCodec(c); f = e->get_sample_formats_for_codec(c);
delete e; delete e;
} }
+26 -26
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef EXPORTFORMAT_H #ifndef OAK_EXPORTFORMAT_H
#define EXPORTFORMAT_H #define OAK_EXPORTFORMAT_H
#include <QList> #include <QList>
#include <QString> #include <QString>
@@ -36,36 +36,36 @@ class ExportFormat : public QObject {
public: public:
// Only append to this list (never insert) because indexes are used in serialized files // Only append to this list (never insert) because indexes are used in serialized files
enum Format { enum Format {
kFormatDNxHD, k_format_d_nx_hd,
kFormatMatroska, k_format_matroska,
kFormatMPEG4Video, k_format_mpe_g4_video,
kFormatOpenEXR, k_format_open_exr,
kFormatQuickTime, k_format_quick_time,
kFormatPNG, k_format_png,
kFormatTIFF, k_format_tiff,
kFormatWAV, k_format_wav,
kFormatAIFF, k_format_aiff,
kFormatMP3, k_format_m_p3,
kFormatFLAC, k_format_flac,
kFormatOgg, k_format_ogg,
kFormatWebM, k_format_web_m,
kFormatSRT, k_format_srt,
kFormatMPEG4Audio, k_format_mpe_g4_audio,
kFormatCount k_format_count
}; };
static QString GetName(Format f); static QString get_name(Format f);
static QString GetExtension(Format f); static QString get_extension(Format f);
static QList<ExportCodec::Codec> GetVideoCodecs(ExportFormat::Format f); static QList<ExportCodec::Codec> get_video_codecs(ExportFormat::Format f);
static QList<ExportCodec::Codec> GetAudioCodecs(ExportFormat::Format f); static QList<ExportCodec::Codec> get_audio_codecs(ExportFormat::Format f);
static QList<ExportCodec::Codec> GetSubtitleCodecs(ExportFormat::Format f); static QList<ExportCodec::Codec> get_subtitle_codecs(ExportFormat::Format f);
static QStringList GetPixelFormatsForCodec(Format f, ExportCodec::Codec c); static QStringList get_pixel_formats_for_codec(Format f, ExportCodec::Codec c);
static std::vector<SampleFormat> static std::vector<SampleFormat>
GetSampleFormatsForCodec(Format f, ExportCodec::Codec c); get_sample_formats_for_codec(Format f, ExportCodec::Codec c);
}; };
} }
#endif // EXPORTFORMAT_H #endif // OAK_EXPORTFORMAT_H
File diff suppressed because it is too large Load Diff
+26 -26
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef FFMPEGDECODER_H #ifndef OAK_FFMPEGDECODER_H
#define FFMPEGDECODER_H #define OAK_FFMPEGDECODER_H
#include <inttypes.h> #include <inttypes.h>
@@ -53,30 +53,30 @@ public:
virtual QString id() const override; virtual QString id() const override;
virtual bool SupportsVideo() override virtual bool supports_video() override
{ {
return true; return true;
} }
virtual bool SupportsAudio() override virtual bool supports_audio() override
{ {
return true; return true;
} }
virtual FootageDescription Probe(const QString &filename, virtual FootageDescription probe(const QString &filename,
CancelAtom *cancelled) const override; CancelAtom *cancelled) const override;
protected: protected:
virtual bool OpenInternal() override; virtual bool open_internal() override;
virtual TexturePtr virtual TexturePtr
RetrieveVideoInternal(const RetrieveVideoParams &p) override; retrieve_video_internal(const RetrieveVideoParams &p) override;
virtual FramePtr virtual FramePtr
RetrieveVideoFrameInternal(const RetrieveVideoParams &p) override; retrieve_video_frame_internal(const RetrieveVideoParams &p) override;
virtual bool ConformAudioInternal(const QVector<QString> &filenames, virtual bool conform_audio_internal(const QVector<QString> &filenames,
const AudioParams &params, const AudioParams &params,
CancelAtom *cancelled) override; CancelAtom *cancelled) override;
virtual void CloseInternal() override; virtual void close_internal() override;
virtual rational GetAudioStartOffset() const override; virtual Rational get_audio_start_offset() const override;
private: private:
/** /**
@@ -87,32 +87,32 @@ private:
* *
* @param error_code * @param error_code
*/ */
static QString FFmpegError(int error_code); static QString f_fmpeg_error(int error_code);
void FreeScaler(); void free_scaler();
AVFramePtr TransferHardwareFrame(AVFramePtr f); AVFramePtr transfer_hardware_frame(AVFramePtr f);
static PixelFormat GetNativePixelFormat(int pix_fmt); static PixelFormat get_native_pixel_format(int pix_fmt);
static int GetNativeChannelCount(int pix_fmt); static int get_native_channel_count(int pix_fmt);
static bool IsPixelFormatGLSLCompatible(int f); static bool is_pixel_format_glsl_compatible(int f);
AVFramePtr GetFrameFromCache(const int64_t &t) const; AVFramePtr get_frame_from_cache(const int64_t &t) const;
void ClearFrameCache(); void clear_frame_cache();
AVFramePtr PreProcessFrame(AVFramePtr f, const RetrieveVideoParams &p); AVFramePtr pre_process_frame(AVFramePtr f, const RetrieveVideoParams &p);
TexturePtr ProcessFrameIntoTexture(AVFramePtr f, TexturePtr process_frame_into_texture(AVFramePtr f,
const RetrieveVideoParams &p, const RetrieveVideoParams &p,
const AVFramePtr original); const AVFramePtr original);
AVFramePtr RetrieveFrame(const rational &time, CancelAtom *cancelled); AVFramePtr retrieve_frame(const Rational &time, CancelAtom *cancelled);
void RemoveFirstFrame(); void remove_first_frame();
static int MaximumQueueSize(); static int maximum_queue_size();
FBScaler *scaler_; FBScaler *scaler_;
int scaler_src_width_; int scaler_src_width_;
@@ -137,7 +137,7 @@ private:
// Stream parameters cached on open (the stream object itself lives // Stream parameters cached on open (the stream object itself lives
// inside the bridge library) // inside the bridge library)
rational stream_time_base_; Rational stream_time_base_;
int64_t stream_start_time_; int64_t stream_start_time_;
int64_t stream_duration_; int64_t stream_duration_;
int64_t format_start_time_; int64_t format_start_time_;
@@ -148,4 +148,4 @@ private:
} }
#endif // FFMPEGDECODER_H #endif // OAK_FFMPEGDECODER_H
+94 -94
View File
@@ -38,12 +38,12 @@ FFmpegEncoder::FFmpegEncoder(const EncodingParams &params)
{ {
} }
QStringList FFmpegEncoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const QStringList FFmpegEncoder::get_pixel_formats_for_codec(ExportCodec::Codec c) const
{ {
QStringList pix_fmts; QStringList pix_fmts;
int bridge_codec = ExportCodecToBridge(c); int bridge_codec = export_codec_to_bridge(c);
if (bridge_codec != FB_CODEC_NONE) { if (bridge_codec != fb_codec_none) {
int count = int count =
fb_encoder_codec_get_pixel_formats(bridge_codec, nullptr, 0); fb_encoder_codec_get_pixel_formats(bridge_codec, nullptr, 0);
if (count > 0) { if (count > 0) {
@@ -60,19 +60,19 @@ QStringList FFmpegEncoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const
} }
std::vector<SampleFormat> std::vector<SampleFormat>
FFmpegEncoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const FFmpegEncoder::get_sample_formats_for_codec(ExportCodec::Codec c) const
{ {
std::vector<SampleFormat> f; std::vector<SampleFormat> f;
if (c == ExportCodec::kCodecPCM) { if (c == ExportCodec::k_codec_pcm) {
// FFmpeg lists these as separate codecs so we need custom functionality here // FFmpeg lists these as separate codecs so we need custom functionality here
// We list signed 16 first because ExportDialog will always use the first element by default // We list signed 16 first because ExportDialog will always use the first element by default
// (because first element is the "default" in FFmpeg) // (because first element is the "default" in FFmpeg)
f = { SampleFormat::S16, SampleFormat::U8, SampleFormat::S32, f = { SampleFormat::s16, SampleFormat::u8, SampleFormat::s32,
SampleFormat::S64, SampleFormat::F32, SampleFormat::F64 }; SampleFormat::s64, SampleFormat::f32, SampleFormat::f64 };
} else { } else {
int bridge_codec = ExportCodecToBridge(c); int bridge_codec = export_codec_to_bridge(c);
if (bridge_codec != FB_CODEC_NONE) { if (bridge_codec != fb_codec_none) {
int count = int count =
fb_encoder_codec_get_sample_formats(bridge_codec, nullptr, 0); fb_encoder_codec_get_sample_formats(bridge_codec, nullptr, 0);
if (count > 0) { if (count > 0) {
@@ -81,8 +81,8 @@ FFmpegEncoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const
count); count);
for (int fmt : fmts) { for (int fmt : fmts) {
SampleFormat native = SampleFormat native =
FFmpegUtils::GetNativeSampleFormat(fmt); FFmpegUtils::get_native_sample_format(fmt);
if (native != SampleFormat::INVALID) { if (native != SampleFormat::invalid) {
f.push_back(native); f.push_back(native);
} }
} }
@@ -93,7 +93,7 @@ FFmpegEncoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const
return f; return f;
} }
bool FFmpegEncoder::Open() bool FFmpegEncoder::open()
{ {
if (open_) { if (open_) {
return true; return true;
@@ -117,7 +117,7 @@ bool FFmpegEncoder::Open()
// Set up video if it's enabled // Set up video if it's enabled
if (params().video_enabled()) { if (params().video_enabled()) {
config.video_enabled = 1; config.video_enabled = 1;
config.video_codec = ExportCodecToBridge(params().video_codec()); config.video_codec = export_codec_to_bridge(params().video_codec());
config.video_width = params().video_params().width(); config.video_width = params().video_params().width();
config.video_height = params().video_params().height(); config.video_height = params().video_params().height();
config.video_pixel_aspect_num = config.video_pixel_aspect_num =
@@ -141,17 +141,17 @@ bool FFmpegEncoder::Open()
// This is the format we will need to convert the frame to for the bridge to understand it // This is the format we will need to convert the frame to for the bridge to understand it
video_conversion_fmt_ = video_conversion_fmt_ =
FFmpegUtils::GetCompatiblePixelFormat(native_pixel_fmt); FFmpegUtils::get_compatible_pixel_format(native_pixel_fmt);
// These are the equivalent pixel formats as bridge pixel formats // These are the equivalent pixel formats as bridge pixel formats
int src_alpha_pix_fmt = FFmpegUtils::GetFFmpegPixelFormat( int src_alpha_pix_fmt = FFmpegUtils::get_f_fmpeg_pixel_format(
video_conversion_fmt_, VideoParams::kRGBAChannelCount); video_conversion_fmt_, VideoParams::k_rgba_channel_count);
int src_noalpha_pix_fmt = FFmpegUtils::GetFFmpegPixelFormat( int src_noalpha_pix_fmt = FFmpegUtils::get_f_fmpeg_pixel_format(
video_conversion_fmt_, VideoParams::kRGBChannelCount); video_conversion_fmt_, VideoParams::k_rgb_channel_count);
if (src_alpha_pix_fmt == FB_PIX_FMT_NONE || if (src_alpha_pix_fmt == fb_pix_fmt_none ||
src_noalpha_pix_fmt == FB_PIX_FMT_NONE) { src_noalpha_pix_fmt == fb_pix_fmt_none) {
SetError( set_error(
tr("Failed to find suitable pixel format for this buffer")); tr("Failed to find suitable pixel format for this buffer"));
return false; return false;
} }
@@ -160,19 +160,19 @@ bool FFmpegEncoder::Open()
config.video_color_range = config.video_color_range =
params().video_params().color_range() == params().video_params().color_range() ==
VideoParams::kColorRangeFull ? VideoParams::k_color_range_full ?
FB_COLOR_RANGE_JPEG : fb_color_range_jpeg :
FB_COLOR_RANGE_MPEG; fb_color_range_mpeg;
switch (params().video_params().interlacing()) { switch (params().video_params().interlacing()) {
case VideoParams::kInterlacedTopFirst: case VideoParams::k_interlaced_top_first:
config.video_field_order = FB_FIELD_ORDER_TT; config.video_field_order = fb_field_order_tt;
break; break;
case VideoParams::kInterlacedBottomFirst: case VideoParams::k_interlaced_bottom_first:
config.video_field_order = FB_FIELD_ORDER_BB; config.video_field_order = fb_field_order_bb;
break; break;
default: default:
config.video_field_order = FB_FIELD_ORDER_PROGRESSIVE; config.video_field_order = fb_field_order_progressive;
break; break;
} }
@@ -207,11 +207,11 @@ bool FFmpegEncoder::Open()
// Set up audio if it's enabled // Set up audio if it's enabled
if (params().audio_enabled()) { if (params().audio_enabled()) {
config.audio_enabled = 1; config.audio_enabled = 1;
config.audio_codec = ExportCodecToBridge(params().audio_codec()); config.audio_codec = export_codec_to_bridge(params().audio_codec());
config.audio_sample_rate = params().audio_params().sample_rate(); config.audio_sample_rate = params().audio_params().sample_rate();
config.audio_channel_layout_mask = config.audio_channel_layout_mask =
params().audio_params().channel_layout(); params().audio_params().channel_layout();
config.audio_sample_format = FFmpegUtils::GetFFmpegSampleFormat( config.audio_sample_format = FFmpegUtils::get_f_fmpeg_sample_format(
params().audio_params().format()); params().audio_params().format());
config.audio_bit_rate = params().audio_bit_rate(); config.audio_bit_rate = params().audio_bit_rate();
} }
@@ -219,8 +219,8 @@ bool FFmpegEncoder::Open()
// Set up subtitles if they're enabled // Set up subtitles if they're enabled
if (params().subtitles_enabled()) { if (params().subtitles_enabled()) {
config.subtitles_enabled = 1; config.subtitles_enabled = 1;
config.subtitle_codec = ExportCodecToBridge(params().subtitles_codec()); config.subtitle_codec = export_codec_to_bridge(params().subtitles_codec());
subtitle_header = SubtitleParams::GenerateASSHeader().toUtf8(); subtitle_header = SubtitleParams::generate_ass_header().toUtf8();
config.subtitle_header = config.subtitle_header =
reinterpret_cast<const uint8_t *>(subtitle_header.constData()); reinterpret_cast<const uint8_t *>(subtitle_header.constData());
config.subtitle_header_size = subtitle_header.size(); config.subtitle_header_size = subtitle_header.size();
@@ -228,12 +228,12 @@ bool FFmpegEncoder::Open()
encoder_ = fb_encoder_create(&config); encoder_ = fb_encoder_create(&config);
if (!encoder_) { if (!encoder_) {
SetError(tr("Failed to create encoder")); set_error(tr("Failed to create encoder"));
return false; return false;
} }
if (fb_encoder_open(encoder_) != 0) { if (fb_encoder_open(encoder_) != 0) {
SetErrorFromBridge(); set_error_from_bridge();
fb_encoder_free(&encoder_); fb_encoder_free(&encoder_);
return false; return false;
} }
@@ -242,29 +242,29 @@ bool FFmpegEncoder::Open()
return true; return true;
} }
bool FFmpegEncoder::WriteFrame(FramePtr frame, rational time) bool FFmpegEncoder::write_frame(FramePtr frame, Rational time)
{ {
// We may need to convert this frame to a frame that the bridge will understand // We may need to convert this frame to a frame that the bridge will understand
if (frame->format() != video_conversion_fmt_) { if (frame->format() != video_conversion_fmt_) {
frame = frame->convert(video_conversion_fmt_); frame = frame->convert(video_conversion_fmt_);
} }
int src_pix_fmt = FFmpegUtils::GetFFmpegPixelFormat(frame->format(), int src_pix_fmt = FFmpegUtils::get_f_fmpeg_pixel_format(frame->format(),
frame->channel_count()); frame->channel_count());
int r = fb_encoder_write_video_frame( int r = fb_encoder_write_video_frame(
encoder_, frame->width(), frame->height(), src_pix_fmt, encoder_, frame->width(), frame->height(), src_pix_fmt,
reinterpret_cast<const uint8_t *>(frame->data()), reinterpret_cast<const uint8_t *>(frame->data()),
frame->linesize_bytes(), time.toDouble()); frame->linesize_bytes(), time.to_double());
if (r != 0) { if (r != 0) {
SetErrorFromBridge(); set_error_from_bridge();
return false; return false;
} }
return true; return true;
} }
bool FFmpegEncoder::WriteAudio(const SampleBuffer &audio) bool FFmpegEncoder::write_audio(const SampleBuffer &audio)
{ {
if (!audio.is_allocated()) { if (!audio.is_allocated()) {
return true; return true;
@@ -284,50 +284,50 @@ bool FFmpegEncoder::WriteAudio(const SampleBuffer &audio)
int r = fb_encoder_write_audio( int r = fb_encoder_write_audio(
encoder_, channel_data.data(), encoder_, channel_data.data(),
audio.audio_params().channel_count(), audio.audio_params().channel_count(),
FFmpegUtils::GetFFmpegSampleFormat(audio.audio_params().format()), FFmpegUtils::get_f_fmpeg_sample_format(audio.audio_params().format()),
audio_params.sample_rate(), audio_params.channel_layout(), audio_params.sample_rate(), audio_params.channel_layout(),
int64_t(audio.sample_count())); int64_t(audio.sample_count()));
if (r != 0) { if (r != 0) {
SetErrorFromBridge(); set_error_from_bridge();
return false; return false;
} }
return true; return true;
} }
bool FFmpegEncoder::WriteAudioData(const AudioParams &audio_params, bool FFmpegEncoder::write_audio_data(const AudioParams &audio_params,
const uint8_t **data, const uint8_t **data,
int input_sample_count) int input_sample_count)
{ {
int r = fb_encoder_write_audio( int r = fb_encoder_write_audio(
encoder_, data, audio_params.channel_count(), encoder_, data, audio_params.channel_count(),
FFmpegUtils::GetFFmpegSampleFormat(audio_params.format()), FFmpegUtils::get_f_fmpeg_sample_format(audio_params.format()),
audio_params.sample_rate(), audio_params.channel_layout(), audio_params.sample_rate(), audio_params.channel_layout(),
input_sample_count); input_sample_count);
if (r != 0) { if (r != 0) {
SetErrorFromBridge(); set_error_from_bridge();
return false; return false;
} }
return true; return true;
} }
bool FFmpegEncoder::WriteSubtitle(const SubtitleBlock *sub_block) bool FFmpegEncoder::write_subtitle(const SubtitleBlock *sub_block)
{ {
QByteArray utf8_sub = sub_block->GetText().toUtf8(); QByteArray utf8_sub = sub_block->get_text().toUtf8();
int r = fb_encoder_write_subtitle(encoder_, utf8_sub.constData(), int r = fb_encoder_write_subtitle(encoder_, utf8_sub.constData(),
sub_block->in().toDouble(), sub_block->in().to_double(),
sub_block->length().toDouble()); sub_block->length().to_double());
if (r != 0) { if (r != 0) {
SetErrorFromBridge(); set_error_from_bridge();
return false; return false;
} }
return true; return true;
} }
void FFmpegEncoder::Close() void FFmpegEncoder::close()
{ {
if (encoder_) { if (encoder_) {
// Flushes encoders, writes the trailer, and frees everything // Flushes encoders, writes the trailer, and frees everything
@@ -337,57 +337,57 @@ void FFmpegEncoder::Close()
open_ = false; open_ = false;
} }
void FFmpegEncoder::SetErrorFromBridge() void FFmpegEncoder::set_error_from_bridge()
{ {
SetError(QString::fromUtf8(fb_encoder_get_error(encoder_))); set_error(QString::fromUtf8(fb_encoder_get_error(encoder_)));
} }
int FFmpegEncoder::ExportCodecToBridge(ExportCodec::Codec c) int FFmpegEncoder::export_codec_to_bridge(ExportCodec::Codec c)
{ {
switch (c) { switch (c) {
case ExportCodec::kCodecH264: case ExportCodec::k_codec_h264:
return FB_CODEC_H264; return fb_codec_h264;
case ExportCodec::kCodecH264rgb: case ExportCodec::k_codec_h264rgb:
return FB_CODEC_H264RGB; return fb_codec_h264_rgb;
case ExportCodec::kCodecDNxHD: case ExportCodec::k_codec_d_nx_hd:
return FB_CODEC_DNXHD; return fb_codec_dnxhd;
case ExportCodec::kCodecProRes: case ExportCodec::k_codec_pro_res:
return FB_CODEC_PRORES; return fb_codec_prores;
case ExportCodec::kCodecCineform: case ExportCodec::k_codec_cineform:
return FB_CODEC_CINEFORM; return fb_codec_cineform;
case ExportCodec::kCodecH265: case ExportCodec::k_codec_h265:
return FB_CODEC_H265; return fb_codec_h265;
case ExportCodec::kCodecVP9: case ExportCodec::k_codec_v_p9:
return FB_CODEC_VP9; return fb_codec_v_p9;
case ExportCodec::kCodecAV1: case ExportCodec::k_codec_a_v1:
return FB_CODEC_AV1; return fb_codec_a_v1;
case ExportCodec::kCodecOpenEXR: case ExportCodec::k_codec_open_exr:
return FB_CODEC_OPENEXR; return fb_codec_openexr;
case ExportCodec::kCodecPNG: case ExportCodec::k_codec_png:
return FB_CODEC_PNG; return fb_codec_png;
case ExportCodec::kCodecTIFF: case ExportCodec::k_codec_tiff:
return FB_CODEC_TIFF; return fb_codec_tiff;
case ExportCodec::kCodecMP2: case ExportCodec::k_codec_m_p2:
return FB_CODEC_MP2; return fb_codec_m_p2;
case ExportCodec::kCodecMP3: case ExportCodec::k_codec_m_p3:
return FB_CODEC_MP3; return fb_codec_m_p3;
case ExportCodec::kCodecAAC: case ExportCodec::k_codec_aac:
return FB_CODEC_AAC; return fb_codec_aac;
case ExportCodec::kCodecPCM: case ExportCodec::k_codec_pcm:
return FB_CODEC_PCM; return fb_codec_pcm;
case ExportCodec::kCodecFLAC: case ExportCodec::k_codec_flac:
return FB_CODEC_FLAC; return fb_codec_flac;
case ExportCodec::kCodecOpus: case ExportCodec::k_codec_opus:
return FB_CODEC_OPUS; return fb_codec_opus;
case ExportCodec::kCodecVorbis: case ExportCodec::k_codec_vorbis:
return FB_CODEC_VORBIS; return fb_codec_vorbis;
case ExportCodec::kCodecSRT: case ExportCodec::k_codec_srt:
return FB_CODEC_SRT; return fb_codec_srt;
case ExportCodec::kCodecCount: case ExportCodec::k_codec_count:
break; break;
} }
return FB_CODEC_NONE; return fb_codec_none;
} }
} }
+15 -15
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef FFMPEGENCODER_H #ifndef OAK_FFMPEGENCODER_H
#define FFMPEGENCODER_H #define OAK_FFMPEGENCODER_H
#include <ffmpeg_bridge/ffmpeg_bridge.h> #include <ffmpeg_bridge/ffmpeg_bridge.h>
@@ -42,26 +42,26 @@ public:
FFmpegEncoder(const EncodingParams &params); FFmpegEncoder(const EncodingParams &params);
virtual QStringList virtual QStringList
GetPixelFormatsForCodec(ExportCodec::Codec c) const override; get_pixel_formats_for_codec(ExportCodec::Codec c) const override;
virtual std::vector<SampleFormat> virtual std::vector<SampleFormat>
GetSampleFormatsForCodec(ExportCodec::Codec c) const override; get_sample_formats_for_codec(ExportCodec::Codec c) const override;
virtual bool Open() override; virtual bool open() override;
virtual bool WriteFrame(olive::FramePtr frame, virtual bool write_frame(olive::FramePtr frame,
olive::core::rational time) override; olive::core::Rational time) override;
virtual bool WriteAudio(const olive::SampleBuffer &audio) override; virtual bool write_audio(const olive::SampleBuffer &audio) override;
bool WriteAudioData(const AudioParams &audio_params, const uint8_t **data, bool write_audio_data(const AudioParams &audio_params, const uint8_t **data,
int input_sample_count); int input_sample_count);
virtual bool WriteSubtitle(const SubtitleBlock *sub_block) override; virtual bool write_subtitle(const SubtitleBlock *sub_block) override;
virtual void Close() override; virtual void close() override;
virtual PixelFormat GetDesiredPixelFormat() const override virtual PixelFormat get_desired_pixel_format() const override
{ {
return video_conversion_fmt_; return video_conversion_fmt_;
} }
@@ -70,9 +70,9 @@ private:
/** /**
* @brief Copy the last error message from the bridge into the encoder error state * @brief Copy the last error message from the bridge into the encoder error state
*/ */
void SetErrorFromBridge(); void set_error_from_bridge();
static int ExportCodecToBridge(ExportCodec::Codec c); static int export_codec_to_bridge(ExportCodec::Codec c);
FBEncoder *encoder_; FBEncoder *encoder_;
@@ -83,4 +83,4 @@ private:
} }
#endif // FFMPEGENCODER_H #endif // OAK_FFMPEGENCODER_H
+15 -15
View File
@@ -44,7 +44,7 @@ Frame::~Frame()
destroy(); destroy();
} }
FramePtr Frame::Create() FramePtr Frame::create()
{ {
return std::make_shared<Frame>(); return std::make_shared<Frame>();
} }
@@ -60,10 +60,10 @@ void Frame::set_video_params(const VideoParams &params)
linesize_ = generate_linesize_bytes(width(), params_.format(), linesize_ = generate_linesize_bytes(width(), params_.format(),
params_.channel_count()); params_.channel_count());
linesize_pixels_ = linesize_ / params_.GetBytesPerPixel(); linesize_pixels_ = linesize_ / params_.get_bytes_per_pixel();
} }
FramePtr Frame::Interlace(FramePtr top, FramePtr bottom) FramePtr Frame::interlace(FramePtr top, FramePtr bottom)
{ {
if (top->video_params() != bottom->video_params()) { if (top->video_params() != bottom->video_params()) {
qCritical() qCritical()
@@ -71,7 +71,7 @@ FramePtr Frame::Interlace(FramePtr top, FramePtr bottom)
return nullptr; return nullptr;
} }
FramePtr interlaced = Frame::Create(); FramePtr interlaced = Frame::create();
interlaced->set_video_params(top->video_params()); interlaced->set_video_params(top->video_params());
interlaced->allocate(); interlaced->allocate();
@@ -91,7 +91,7 @@ int Frame::generate_linesize_bytes(int width, PixelFormat format,
int channel_count) int channel_count)
{ {
// Align to 32 bytes (not sure if this is necessary?) // Align to 32 bytes (not sure if this is necessary?)
return VideoParams::GetBytesPerPixel(format, channel_count) * return VideoParams::get_bytes_per_pixel(format, channel_count) *
((width + 31) & ~31); ((width + 31) & ~31);
} }
@@ -102,7 +102,7 @@ Color Frame::get_pixel(int x, int y) const
} }
int byte_offset = int byte_offset =
y * linesize_bytes() + x * video_params().GetBytesPerPixel(); y * linesize_bytes() + x * video_params().get_bytes_per_pixel();
return Color(reinterpret_cast<const char *>(data_ + byte_offset), return Color(reinterpret_cast<const char *>(data_ + byte_offset),
video_params().format(), video_params().channel_count()); video_params().format(), video_params().channel_count());
@@ -120,9 +120,9 @@ void Frame::set_pixel(int x, int y, const Color &c)
} }
int byte_offset = int byte_offset =
y * linesize_bytes() + x * video_params().GetBytesPerPixel(); y * linesize_bytes() + x * video_params().get_bytes_per_pixel();
c.toData(reinterpret_cast<char *>(data_ + byte_offset), c.to_data(reinterpret_cast<char *>(data_ + byte_offset),
video_params().format(), video_params().channel_count()); video_params().format(), video_params().channel_count());
} }
@@ -140,7 +140,7 @@ bool Frame::allocate()
} }
data_size_ = linesize_ * height(); data_size_ = linesize_ * height();
data_ = FrameManager::Allocate(data_size_); data_ = FrameManager::allocate(data_size_);
return true; return true;
} }
@@ -148,7 +148,7 @@ bool Frame::allocate()
void Frame::destroy() void Frame::destroy()
{ {
if (is_allocated()) { if (is_allocated()) {
FrameManager::Deallocate(data_size_, data_); FrameManager::deallocate(data_size_, data_);
data_size_ = 0; data_size_ = 0;
data_ = nullptr; data_ = nullptr;
@@ -162,7 +162,7 @@ FramePtr Frame::convert(PixelFormat format) const
params.set_format(format); params.set_format(format);
// Create new frame // Create new frame
FramePtr converted = Frame::Create(); FramePtr converted = Frame::create();
converted->set_video_params(params); converted->set_video_params(params);
converted->set_timestamp(timestamp_); converted->set_timestamp(timestamp_);
converted->allocate(); converted->allocate();
@@ -170,16 +170,16 @@ FramePtr Frame::convert(PixelFormat format) const
// Do the conversion through OIIO for convenience // Do the conversion through OIIO for convenience
OIIO::ImageBuf src( OIIO::ImageBuf src(
OIIO::ImageSpec(width(), height(), channel_count(), OIIO::ImageSpec(width(), height(), channel_count(),
OIIOUtils::GetOIIOBaseTypeFromFormat(this->format()))); OIIOUtils::get_oiio_base_type_from_format(this->format())));
OIIOUtils::FrameToBuffer(this, &src); OIIOUtils::frame_to_buffer(this, &src);
OIIO::ImageBuf dst(OIIO::ImageSpec( OIIO::ImageBuf dst(OIIO::ImageSpec(
converted->width(), converted->height(), channel_count(), converted->width(), converted->height(), channel_count(),
OIIOUtils::GetOIIOBaseTypeFromFormat(format))); OIIOUtils::get_oiio_base_type_from_format(format)));
if (dst.copy_pixels(src)) { if (dst.copy_pixels(src)) {
OIIOUtils::BufferToFrame(&dst, converted.get()); OIIOUtils::buffer_to_frame(&dst, converted.get());
return converted; return converted;
} else { } else {
return nullptr; return nullptr;
+9 -9
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef FRAME_H #ifndef OAK_FRAME_H
#define FRAME_H #define OAK_FRAME_H
#include <memory> #include <memory>
#include <olive/core/core.h> #include <olive/core/core.h>
@@ -46,12 +46,12 @@ public:
DISABLE_COPY_MOVE(Frame) DISABLE_COPY_MOVE(Frame)
static FramePtr Create(); static FramePtr create();
const VideoParams &video_params() const; const VideoParams &video_params() const;
void set_video_params(const VideoParams &params); void set_video_params(const VideoParams &params);
static FramePtr Interlace(FramePtr top, FramePtr bottom); static FramePtr interlace(FramePtr top, FramePtr bottom);
static int generate_linesize_bytes(int width, PixelFormat format, static int generate_linesize_bytes(int width, PixelFormat format,
int channel_count); int channel_count);
@@ -93,14 +93,14 @@ public:
/** /**
* @brief Get frame's timestamp. * @brief Get frame's timestamp.
* *
* This timestamp is always a rational that will equate to the time in seconds. * This timestamp is always a Rational that will equate to the time in seconds.
*/ */
const rational &timestamp() const const Rational &timestamp() const
{ {
return timestamp_; return timestamp_;
} }
void set_timestamp(const rational &timestamp) void set_timestamp(const Rational &timestamp)
{ {
timestamp_ = timestamp; timestamp_ = timestamp;
} }
@@ -161,7 +161,7 @@ private:
char *data_; char *data_;
int data_size_; int data_size_;
rational timestamp_; Rational timestamp_;
int linesize_; int linesize_;
@@ -172,4 +172,4 @@ private:
Q_DECLARE_METATYPE(olive::FramePtr) Q_DECLARE_METATYPE(olive::FramePtr)
#endif // FRAME_H #endif // OAK_FRAME_H
+32 -32
View File
@@ -32,7 +32,7 @@
namespace olive namespace olive
{ {
QStringList OIIODecoder::supported_formats_; QStringList OIIODecoder::supported_formats;
OIIODecoder::OIIODecoder() OIIODecoder::OIIODecoder()
: image_(nullptr) : image_(nullptr)
@@ -44,7 +44,7 @@ QString OIIODecoder::id() const
return QStringLiteral("oiio"); return QStringLiteral("oiio");
} }
FootageDescription OIIODecoder::Probe(const QString &filename, FootageDescription OIIODecoder::probe(const QString &filename,
CancelAtom *cancelled) const CancelAtom *cancelled) const
{ {
Q_UNUSED(cancelled) Q_UNUSED(cancelled)
@@ -53,7 +53,7 @@ FootageDescription OIIODecoder::Probe(const QString &filename,
// Filter out any file extensions that aren't expected to work - sometimes OIIO will crash trying // Filter out any file extensions that aren't expected to work - sometimes OIIO will crash trying
// to open a file that it can't if it's given one // to open a file that it can't if it's given one
if (!FileTypeIsSupported(filename)) { if (!file_type_is_supported(filename)) {
return desc; return desc;
} }
@@ -77,7 +77,7 @@ FootageDescription OIIODecoder::Probe(const QString &filename,
for (i = 0; in->seek_subimage(i, 0); i++) { for (i = 0; in->seek_subimage(i, 0); i++) {
OIIO::ImageSpec spec = in->spec(); OIIO::ImageSpec spec = in->spec();
VideoParams video_params = GetVideoParamsFromImageSpec(spec); VideoParams video_params = get_video_params_from_image_spec(spec);
video_params.set_stream_index(i); video_params.set_stream_index(i);
@@ -104,10 +104,10 @@ FootageDescription OIIODecoder::Probe(const QString &filename,
// likely reduces the fidelity? // likely reduces the fidelity?
video_params.set_premultiplied_alpha(true); video_params.set_premultiplied_alpha(true);
desc.AddVideoStream(video_params); desc.add_video_stream(video_params);
} }
desc.SetStreamCount(i); desc.set_stream_count(i);
// If we're here, we have a successful image open // If we're here, we have a successful image open
in->close(); in->close();
@@ -115,26 +115,26 @@ FootageDescription OIIODecoder::Probe(const QString &filename,
return desc; return desc;
} }
bool OIIODecoder::OpenInternal() bool OIIODecoder::open_internal()
{ {
// If we can open the filename provided, assume everything is working // If we can open the filename provided, assume everything is working
return OpenImageHandler(stream().filename(), stream().stream()); return open_image_handler(stream().filename(), stream().stream());
} }
TexturePtr OIIODecoder::RetrieveVideoInternal(const RetrieveVideoParams &p) TexturePtr OIIODecoder::retrieve_video_internal(const RetrieveVideoParams &p)
{ {
FramePtr frame = RetrieveVideoFrameInternal(p); FramePtr frame = retrieve_video_frame_internal(p);
if (!frame) { if (!frame) {
return nullptr; return nullptr;
} }
return p.renderer->CreateTexture(frame->video_params(), frame->data(), return p.renderer->create_texture(frame->video_params(), frame->data(),
frame->linesize_pixels()); frame->linesize_pixels());
} }
FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p) FramePtr OIIODecoder::retrieve_video_frame_internal(const RetrieveVideoParams &p)
{ {
VideoParams vp = GetVideoParamsFromImageSpec(image_->spec()); VideoParams vp = get_video_params_from_image_spec(image_->spec());
vp.set_divider(p.divider); vp.set_divider(p.divider);
if (!buffer_.is_allocated() || last_params_.divider != p.divider) { if (!buffer_.is_allocated() || last_params_.divider != p.divider) {
@@ -154,7 +154,7 @@ FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p)
buf.scanline_stride(), buf.z_stride()); buf.scanline_stride(), buf.z_stride());
// Roughly downsample image for divider (for some reason OIIO::ImageBufAlgo::resample failed here) // Roughly downsample image for divider (for some reason OIIO::ImageBufAlgo::resample failed here)
int px_sz = vp.GetBytesPerPixel(); int px_sz = vp.get_bytes_per_pixel();
for (int dst_y = 0; dst_y < buffer_.height(); dst_y++) { for (int dst_y = 0; dst_y < buffer_.height(); dst_y++) {
int src_y = dst_y * buf.spec().height / buffer_.height(); int src_y = dst_y * buf.spec().height / buffer_.height();
@@ -171,15 +171,15 @@ FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p)
} }
// Force F32 output for all still images // Force F32 output for all still images
if (vp.format() != PixelFormat::F32) { if (vp.format() != PixelFormat::f32) {
FramePtr f32_frame = buffer_.convert(PixelFormat::F32); FramePtr f32_frame = buffer_.convert(PixelFormat::f32);
if (f32_frame) { if (f32_frame) {
f32_frame->set_timestamp(p.time); f32_frame->set_timestamp(p.time);
return f32_frame; return f32_frame;
} }
} }
FramePtr frame = Frame::Create(); FramePtr frame = Frame::create();
frame->set_video_params(buffer_.video_params()); frame->set_video_params(buffer_.video_params());
frame->set_timestamp(p.time); frame->set_timestamp(p.time);
if (!frame->allocate()) { if (!frame->allocate()) {
@@ -190,19 +190,19 @@ FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p)
return frame; return frame;
} }
void OIIODecoder::CloseInternal() void OIIODecoder::close_internal()
{ {
CloseImageHandle(); close_image_handle();
} }
bool OIIODecoder::FileTypeIsSupported(const QString &fn) bool OIIODecoder::file_type_is_supported(const QString &fn)
{ {
// We prioritize OIIO over FFmpeg to pick up still images more effectively, but some OIIO decoders (notably OpenJPEG) // We prioritize OIIO over FFmpeg to pick up still images more effectively, but some OIIO decoders (notably OpenJPEG)
// will segfault entirely if given unexpected data (an MPEG-4 for instance). To workaround this issue, we use OIIO's // will segfault entirely if given unexpected data (an MPEG-4 for instance). To workaround this issue, we use OIIO's
// "extension_list" attribute and match it with the extension of the file. // "extension_list" attribute and match it with the extension of the file.
// Check if we've created the supported formats list, create it if not // Check if we've created the supported formats list, create it if not
if (supported_formats_.isEmpty()) { if (supported_formats.isEmpty()) {
QStringList extension_list = QStringList extension_list =
QString::fromStdString(OIIO::get_string_attribute("extension_list")) QString::fromStdString(OIIO::get_string_attribute("extension_list"))
.split(';'); .split(';');
@@ -211,11 +211,11 @@ bool OIIODecoder::FileTypeIsSupported(const QString &fn)
foreach (const QString &ext, extension_list) { foreach (const QString &ext, extension_list) {
QStringList format_and_ext = ext.split(':'); QStringList format_and_ext = ext.split(':');
supported_formats_.append(format_and_ext.at(1).split(',')); supported_formats.append(format_and_ext.at(1).split(','));
} }
} }
if (!supported_formats_.contains(QFileInfo(fn).suffix(), if (!supported_formats.contains(QFileInfo(fn).suffix(),
Qt::CaseInsensitive)) { Qt::CaseInsensitive)) {
return false; return false;
} }
@@ -223,7 +223,7 @@ bool OIIODecoder::FileTypeIsSupported(const QString &fn)
return true; return true;
} }
bool OIIODecoder::OpenImageHandler(const QString &fn, int subimage) bool OIIODecoder::open_image_handler(const QString &fn, int subimage)
{ {
image_ = OIIO::ImageInput::open(fn.toStdString()); image_ = OIIO::ImageInput::open(fn.toStdString());
@@ -239,16 +239,16 @@ bool OIIODecoder::OpenImageHandler(const QString &fn, int subimage)
const OIIO::ImageSpec &spec = image_->spec(); const OIIO::ImageSpec &spec = image_->spec();
// We use RGBA frames because that tends to be the native format of GPUs // We use RGBA frames because that tends to be the native format of GPUs
pix_fmt_ = OIIOUtils::GetFormatFromOIIOBasetype( pix_fmt_ = OIIOUtils::get_format_from_oiio_basetype(
static_cast<OIIO::TypeDesc::BASETYPE>(spec.format.basetype)); static_cast<OIIO::TypeDesc::BASETYPE>(spec.format.basetype));
if (pix_fmt_ == PixelFormat::INVALID) { if (pix_fmt_ == PixelFormat::invalid) {
qWarning() qWarning()
<< "Failed to convert OIIO::ImageDesc to native pixel format"; << "Failed to convert OIIO::ImageDesc to native pixel format";
return false; return false;
} }
oiio_pix_fmt_ = OIIOUtils::GetOIIOBaseTypeFromFormat(pix_fmt_); oiio_pix_fmt_ = OIIOUtils::get_oiio_base_type_from_format(pix_fmt_);
if (oiio_pix_fmt_ == OIIO::TypeDesc::UNKNOWN) { if (oiio_pix_fmt_ == OIIO::TypeDesc::UNKNOWN) {
qCritical() qCritical()
@@ -259,7 +259,7 @@ bool OIIODecoder::OpenImageHandler(const QString &fn, int subimage)
return true; return true;
} }
void OIIODecoder::CloseImageHandle() void OIIODecoder::close_image_handle()
{ {
if (image_) { if (image_) {
image_->close(); image_->close();
@@ -270,18 +270,18 @@ void OIIODecoder::CloseImageHandle()
} }
VideoParams VideoParams
OIIODecoder::GetVideoParamsFromImageSpec(const OIIO::ImageSpec &spec) OIIODecoder::get_video_params_from_image_spec(const OIIO::ImageSpec &spec)
{ {
VideoParams video_params; VideoParams video_params;
video_params.set_width(spec.width); video_params.set_width(spec.width);
video_params.set_height(spec.height); video_params.set_height(spec.height);
video_params.set_format(OIIOUtils::GetFormatFromOIIOBasetype( video_params.set_format(OIIOUtils::get_format_from_oiio_basetype(
static_cast<OIIO::TypeDesc::BASETYPE>(spec.format.basetype))); static_cast<OIIO::TypeDesc::BASETYPE>(spec.format.basetype)));
video_params.set_channel_count(spec.nchannels); video_params.set_channel_count(spec.nchannels);
video_params.set_pixel_aspect_ratio( video_params.set_pixel_aspect_ratio(
OIIOUtils::GetPixelAspectRatioFromOIIO(spec)); OIIOUtils::get_pixel_aspect_ratio_from_oiio(spec));
video_params.set_video_type(VideoParams::kVideoTypeStill); video_params.set_video_type(VideoParams::k_video_type_still);
return video_params; return video_params;
} }
+14 -14
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef OIIODECODER_H #ifndef OAK_OIIODECODER_H
#define OIIODECODER_H #define OAK_OIIODECODER_H
#include <OpenImageIO/imageio.h> #include <OpenImageIO/imageio.h>
#include <OpenImageIO/imagebuf.h> #include <OpenImageIO/imagebuf.h>
@@ -39,32 +39,32 @@ public:
virtual QString id() const override; virtual QString id() const override;
virtual bool SupportsVideo() override virtual bool supports_video() override
{ {
return true; return true;
} }
virtual FootageDescription Probe(const QString &filename, virtual FootageDescription probe(const QString &filename,
CancelAtom *cancelled) const override; CancelAtom *cancelled) const override;
protected: protected:
virtual bool OpenInternal() override; virtual bool open_internal() override;
virtual TexturePtr virtual TexturePtr
RetrieveVideoInternal(const RetrieveVideoParams &p) override; retrieve_video_internal(const RetrieveVideoParams &p) override;
virtual FramePtr virtual FramePtr
RetrieveVideoFrameInternal(const RetrieveVideoParams &p) override; retrieve_video_frame_internal(const RetrieveVideoParams &p) override;
virtual void CloseInternal() override; virtual void close_internal() override;
private: private:
std::unique_ptr<OIIO::ImageInput> image_; std::unique_ptr<OIIO::ImageInput> image_;
static bool FileTypeIsSupported(const QString &fn); static bool file_type_is_supported(const QString &fn);
bool OpenImageHandler(const QString &fn, int subimage); bool open_image_handler(const QString &fn, int subimage);
void CloseImageHandle(); void close_image_handle();
static VideoParams GetVideoParamsFromImageSpec(const OIIO::ImageSpec &spec); static VideoParams get_video_params_from_image_spec(const OIIO::ImageSpec &spec);
PixelFormat pix_fmt_; PixelFormat pix_fmt_;
OIIO::TypeDesc::BASETYPE oiio_pix_fmt_; OIIO::TypeDesc::BASETYPE oiio_pix_fmt_;
@@ -72,9 +72,9 @@ private:
Frame buffer_; Frame buffer_;
RetrieveVideoParams last_params_; RetrieveVideoParams last_params_;
static QStringList supported_formats_; static QStringList supported_formats;
}; };
} }
#endif // OIIODECODER_H #endif // OAK_OIIODECODER_H
+7 -7
View File
@@ -31,21 +31,21 @@ OIIOEncoder::OIIOEncoder(const EncodingParams &params)
{ {
} }
bool OIIOEncoder::Open() bool OIIOEncoder::open()
{ {
return true; return true;
} }
bool OIIOEncoder::WriteFrame(FramePtr frame, rational time) bool OIIOEncoder::write_frame(FramePtr frame, Rational time)
{ {
std::string filename = GetFilenameForFrame(time).toStdString(); std::string filename = get_filename_for_frame(time).toStdString();
auto output = OIIO::ImageOutput::create(filename); auto output = OIIO::ImageOutput::create(filename);
if (!output) { if (!output) {
return false; return false;
} }
OIIO::TypeDesc type = OIIOUtils::GetOIIOBaseTypeFromFormat(frame->format()); OIIO::TypeDesc type = OIIOUtils::get_oiio_base_type_from_format(frame->format());
OIIO::ImageSpec spec(frame->width(), frame->height(), OIIO::ImageSpec spec(frame->width(), frame->height(),
frame->channel_count(), type); frame->channel_count(), type);
@@ -65,18 +65,18 @@ bool OIIOEncoder::WriteFrame(FramePtr frame, rational time)
return true; return true;
} }
bool OIIOEncoder::WriteAudio(const SampleBuffer &audio) bool OIIOEncoder::write_audio(const SampleBuffer &audio)
{ {
// Do nothing // Do nothing
return false; return false;
} }
bool OIIOEncoder::WriteSubtitle(const SubtitleBlock *sub_block) bool OIIOEncoder::write_subtitle(const SubtitleBlock *sub_block)
{ {
return false; return false;
} }
void OIIOEncoder::Close() void OIIOEncoder::close()
{ {
// Do nothing // Do nothing
} }
+9 -9
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef OIIOENCODER_H #ifndef OAK_OIIOENCODER_H
#define OIIOENCODER_H #define OAK_OIIOENCODER_H
#include "codec/encoder.h" #include "codec/encoder.h"
@@ -33,16 +33,16 @@ public:
OIIOEncoder(const EncodingParams &params); OIIOEncoder(const EncodingParams &params);
public slots: public slots:
virtual bool Open() override; virtual bool open() override;
virtual bool WriteFrame(olive::FramePtr frame, virtual bool write_frame(olive::FramePtr frame,
olive::core::rational time) override; olive::core::Rational time) override;
virtual bool WriteAudio(const SampleBuffer &audio) override; virtual bool write_audio(const SampleBuffer &audio) override;
virtual bool WriteSubtitle(const SubtitleBlock *sub_block) override; virtual bool write_subtitle(const SubtitleBlock *sub_block) override;
virtual void Close() override; virtual void close() override;
}; };
} }
#endif // OIIOENCODER_H #endif // OAK_OIIOENCODER_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef PLANARFILEDEVICE_H #ifndef OAK_PLANARFILEDEVICE_H
#define PLANARFILEDEVICE_H #define OAK_PLANARFILEDEVICE_H
#include <olive/core/core.h> #include <olive/core/core.h>
#include <QFile> #include <QFile>
@@ -62,4 +62,4 @@ private:
} }
#endif // PLANARFILEDEVICE_H #endif // OAK_PLANARFILEDEVICE_H
+48 -48
View File
@@ -34,7 +34,7 @@ namespace olive
ProxyManager *ProxyManager::instance_ = nullptr; ProxyManager *ProxyManager::instance_ = nullptr;
bool ProxyParamsEqual(const ProxyManager::ProxyParams &a, bool proxy_params_equal(const ProxyManager::ProxyParams &a,
const ProxyManager::ProxyParams &b) const ProxyManager::ProxyParams &b)
{ {
return a.width == b.width && a.height == b.height && return a.width == b.width && a.height == b.height &&
@@ -43,22 +43,22 @@ bool ProxyParamsEqual(const ProxyManager::ProxyParams &a,
a.include_audio == b.include_audio; a.include_audio == b.include_audio;
} }
QString ProxyManager::GetProxyDirectory(const QString &cache_path) QString ProxyManager::get_proxy_directory(const QString &cache_path)
{ {
return QDir(cache_path).filePath(QStringLiteral("proxy")); return QDir(cache_path).filePath(QStringLiteral("proxy"));
} }
QString ProxyManager::GetProxyFilename(const QString &cache_path, QString ProxyManager::get_proxy_filename(const QString &cache_path,
const QString &source_filename, const QString &source_filename,
int stream_index, int stream_index,
const ProxyParams &params) const ProxyParams &params)
{ {
const QString proxy_dir = GetProxyDirectory(cache_path); const QString proxy_dir = get_proxy_directory(cache_path);
const QString extension = const QString extension =
params.extension.isEmpty() ? QStringLiteral("mp4") : params.extension; params.extension.isEmpty() ? QStringLiteral("mp4") : params.extension;
const QString filename = const QString filename =
QStringLiteral("%1-%2.%3x%4.v%5.a%6.%7") QStringLiteral("%1-%2.%3x%4.v%5.a%6.%7")
.arg(FileFunctions::GetUniqueFileIdentifier(source_filename), .arg(FileFunctions::get_unique_file_identifier(source_filename),
QString::number(stream_index), QString::number(params.width), QString::number(stream_index), QString::number(params.width),
QString::number(params.height), QString::number(params.version), QString::number(params.height), QString::number(params.version),
params.include_audio ? QStringLiteral("1") : QStringLiteral("0"), params.include_audio ? QStringLiteral("1") : QStringLiteral("0"),
@@ -67,7 +67,7 @@ QString ProxyManager::GetProxyFilename(const QString &cache_path,
return QDir(proxy_dir).filePath(filename); return QDir(proxy_dir).filePath(filename);
} }
QString ProxyManager::GetWorkingProxyFilename(const QString &proxy_filename) QString ProxyManager::get_working_proxy_filename(const QString &proxy_filename)
{ {
// Append a recognizable suffix while keeping a standard container extension // Append a recognizable suffix while keeping a standard container extension
// so ffmpeg can infer the output format. // so ffmpeg can infer the output format.
@@ -75,29 +75,29 @@ QString ProxyManager::GetWorkingProxyFilename(const QString &proxy_filename)
} }
ProxyManager::ProxyState ProxyManager::ProxyState
ProxyManager::GetProxyState(const QString &proxy_filename) ProxyManager::get_proxy_state(const QString &proxy_filename)
{ {
if (QFileInfo::exists(proxy_filename)) { if (QFileInfo::exists(proxy_filename)) {
return kProxyReady; return k_proxy_ready;
} }
if (QFileInfo::exists(GetWorkingProxyFilename(proxy_filename))) { if (QFileInfo::exists(get_working_proxy_filename(proxy_filename))) {
return kProxyGenerating; return k_proxy_generating;
} }
return kProxyMissing; return k_proxy_missing;
} }
QString ProxyManager::ProxyStateToString(ProxyState state) QString ProxyManager::proxy_state_to_string(ProxyState state)
{ {
switch (state) { switch (state) {
case kProxyMissing: case k_proxy_missing:
return QStringLiteral("missing"); return QStringLiteral("missing");
case kProxyGenerating: case k_proxy_generating:
return QStringLiteral("generating"); return QStringLiteral("generating");
case kProxyReady: case k_proxy_ready:
return QStringLiteral("ready"); return QStringLiteral("ready");
case kProxyFailed: case k_proxy_failed:
return QStringLiteral("failed"); return QStringLiteral("failed");
} }
@@ -105,41 +105,41 @@ QString ProxyManager::ProxyStateToString(ProxyState state)
} }
ProxyManager::ProxyState ProxyManager::ProxyState
ProxyManager::ProxyStateFromString(const QString &state) ProxyManager::proxy_state_from_string(const QString &state)
{ {
if (state == QStringLiteral("generating")) { if (state == QStringLiteral("generating")) {
return kProxyGenerating; return k_proxy_generating;
} }
if (state == QStringLiteral("ready")) { if (state == QStringLiteral("ready")) {
return kProxyReady; return k_proxy_ready;
} }
if (state == QStringLiteral("failed")) { if (state == QStringLiteral("failed")) {
return kProxyFailed; return k_proxy_failed;
} }
return kProxyMissing; return k_proxy_missing;
} }
bool ProxyManager::ProxyFilenameHasAudio(const QString &proxy_filename) bool ProxyManager::proxy_filename_has_audio(const QString &proxy_filename)
{ {
return QFileInfo(proxy_filename).fileName().contains( return QFileInfo(proxy_filename).fileName().contains(
QStringLiteral(".a1.")); QStringLiteral(".a1."));
} }
ProxyManager::ProxyParams ProxyManager::ProxyParamsFromConfig() ProxyManager::ProxyParams ProxyManager::proxy_params_from_config()
{ {
ProxyParams params; ProxyParams params;
params.width = OLIVE_CONFIG("ProxyWidth").value<int>(); params.width = OAK_CONFIG("ProxyWidth").value<int>();
params.height = OLIVE_CONFIG("ProxyHeight").value<int>(); params.height = OAK_CONFIG("ProxyHeight").value<int>();
params.crf = OLIVE_CONFIG("ProxyCRF").value<int>(); params.crf = OAK_CONFIG("ProxyCRF").value<int>();
params.preset = OLIVE_CONFIG("ProxyPreset").toString(); params.preset = OAK_CONFIG("ProxyPreset").toString();
params.include_audio = OLIVE_CONFIG("ProxyIncludeAudio").toBool(); params.include_audio = OAK_CONFIG("ProxyIncludeAudio").toBool();
return params; return params;
} }
QString ProxyManager::FindFFmpegExecutable(const QString &configured_path) QString ProxyManager::find_f_fmpeg_executable(const QString &configured_path)
{ {
// An explicitly configured path takes precedence if it is usable // An explicitly configured path takes precedence if it is usable
if (!configured_path.isEmpty()) { if (!configured_path.isEmpty()) {
@@ -187,46 +187,46 @@ QString ProxyManager::FindFFmpegExecutable(const QString &configured_path)
} }
ProxyManager::Proxy ProxyManager::Proxy
ProxyManager::GetOrStartProxy(const QString &cache_path, ProxyManager::get_or_start_proxy(const QString &cache_path,
const QString &source_filename, int stream_index, const QString &source_filename, int stream_index,
const ProxyParams &params) const ProxyParams &params)
{ {
QMutexLocker locker(&mutex_); QMutexLocker locker(&mutex_);
const QString filename = const QString filename =
GetProxyFilename(cache_path, source_filename, stream_index, params); get_proxy_filename(cache_path, source_filename, stream_index, params);
const ProxyState file_state = GetProxyState(filename); const ProxyState file_state = get_proxy_state(filename);
if (file_state == kProxyReady) { if (file_state == k_proxy_ready) {
return { kProxyReady, filename, nullptr }; return { k_proxy_ready, filename, nullptr };
} }
for (const ProxyData &data : proxying_) { for (const ProxyData &data : proxying_) {
if (data.source_filename == source_filename && if (data.source_filename == source_filename &&
data.stream_index == stream_index && data.stream_index == stream_index &&
ProxyParamsEqual(data.params, params)) { proxy_params_equal(data.params, params)) {
return { kProxyGenerating, filename, data.task }; return { k_proxy_generating, filename, data.task };
} }
} }
if (file_state == kProxyGenerating) { if (file_state == k_proxy_generating) {
QFile::remove(GetWorkingProxyFilename(filename)); QFile::remove(get_working_proxy_filename(filename));
} }
const QString working_filename = GetWorkingProxyFilename(filename); const QString working_filename = get_working_proxy_filename(filename);
ProxyTask *task = ProxyTask *task =
new ProxyTask(source_filename, stream_index, params, working_filename); new ProxyTask(source_filename, stream_index, params, working_filename);
connect(task, &Task::Finished, this, &ProxyManager::ProxyTaskFinished); connect(task, &Task::finished, this, &ProxyManager::proxy_task_finished);
task->moveToThread(TaskManager::instance()->thread()); task->moveToThread(TaskManager::instance()->thread());
QMetaObject::invokeMethod(TaskManager::instance(), "AddTask", QMetaObject::invokeMethod(TaskManager::instance(), "add_task",
Qt::QueuedConnection, Q_ARG(Task *, task)); Qt::QueuedConnection, Q_ARG(Task *, task));
proxying_.append({ source_filename, stream_index, params, task, proxying_.append({ source_filename, stream_index, params, task,
working_filename, filename }); working_filename, filename });
return { kProxyGenerating, filename, task }; return { k_proxy_generating, filename, task };
} }
void ProxyManager::ProxyTaskFinished(Task *task, bool succeeded) void ProxyManager::proxy_task_finished(Task *task, bool succeeded)
{ {
QMutexLocker locker(&mutex_); QMutexLocker locker(&mutex_);
@@ -250,18 +250,18 @@ void ProxyManager::ProxyTaskFinished(Task *task, bool succeeded)
QFile::remove(data.finished_filename); QFile::remove(data.finished_filename);
if (QFile::rename(data.working_filename, data.finished_filename)) { if (QFile::rename(data.working_filename, data.finished_filename)) {
locker.unlock(); locker.unlock();
emit ProxyReady(data.source_filename, data.stream_index, emit proxy_ready(data.source_filename, data.stream_index,
data.finished_filename); data.finished_filename);
emit ProxyFinished(data.source_filename, data.stream_index, emit proxy_finished(data.source_filename, data.stream_index,
data.finished_filename, kProxyReady); data.finished_filename, k_proxy_ready);
return; return;
} }
} }
QFile::remove(data.working_filename); QFile::remove(data.working_filename);
locker.unlock(); locker.unlock();
emit ProxyFinished(data.source_filename, data.stream_index, emit proxy_finished(data.source_filename, data.stream_index,
data.finished_filename, kProxyFailed); data.finished_filename, k_proxy_failed);
} }
} }
+23 -23
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PROXYMANAGER_H #ifndef OAK_PROXYMANAGER_H
#define PROXYMANAGER_H #define OAK_PROXYMANAGER_H
#include <QMutex> #include <QMutex>
#include <QObject> #include <QObject>
@@ -34,14 +34,14 @@ class ProxyTask;
class ProxyManager : public QObject { class ProxyManager : public QObject {
Q_OBJECT Q_OBJECT
public: public:
static void CreateInstance() static void create_instance()
{ {
if (!instance_) { if (!instance_) {
instance_ = new ProxyManager(); instance_ = new ProxyManager();
} }
} }
static void DestroyInstance() static void destroy_instance()
{ {
delete instance_; delete instance_;
instance_ = nullptr; instance_ = nullptr;
@@ -53,10 +53,10 @@ public:
} }
enum ProxyState { enum ProxyState {
kProxyMissing, k_proxy_missing,
kProxyGenerating, k_proxy_generating,
kProxyReady, k_proxy_ready,
kProxyFailed k_proxy_failed
}; };
struct ProxyParams { struct ProxyParams {
@@ -70,36 +70,36 @@ public:
}; };
struct Proxy { struct Proxy {
ProxyState state = kProxyMissing; ProxyState state = k_proxy_missing;
QString filename; QString filename;
ProxyTask *task = nullptr; ProxyTask *task = nullptr;
}; };
static QString GetProxyDirectory(const QString &cache_path); static QString get_proxy_directory(const QString &cache_path);
static QString GetProxyFilename(const QString &cache_path, static QString get_proxy_filename(const QString &cache_path,
const QString &source_filename, const QString &source_filename,
int stream_index, int stream_index,
const ProxyParams &params); const ProxyParams &params);
static QString GetWorkingProxyFilename(const QString &proxy_filename); static QString get_working_proxy_filename(const QString &proxy_filename);
static ProxyState GetProxyState(const QString &proxy_filename); static ProxyState get_proxy_state(const QString &proxy_filename);
static QString ProxyStateToString(ProxyState state); static QString proxy_state_to_string(ProxyState state);
static ProxyState ProxyStateFromString(const QString &state); static ProxyState proxy_state_from_string(const QString &state);
/** /**
* @brief Returns true if a proxy filename generated by GetProxyFilename() * @brief Returns true if a proxy filename generated by GetProxyFilename()
* indicates the proxy contains audio streams * indicates the proxy contains audio streams
*/ */
static bool ProxyFilenameHasAudio(const QString &proxy_filename); static bool proxy_filename_has_audio(const QString &proxy_filename);
/** /**
* @brief Builds proxy parameters from the global application config * @brief Builds proxy parameters from the global application config
*/ */
static ProxyParams ProxyParamsFromConfig(); static ProxyParams proxy_params_from_config();
/** /**
* @brief Locates an ffmpeg executable for proxy generation * @brief Locates an ffmpeg executable for proxy generation
@@ -109,16 +109,16 @@ public:
* platform-specific install locations. Returns an empty string if no * platform-specific install locations. Returns an empty string if no
* executable could be found. * executable could be found.
*/ */
static QString FindFFmpegExecutable(const QString &configured_path); static QString find_f_fmpeg_executable(const QString &configured_path);
Proxy GetOrStartProxy(const QString &cache_path, Proxy get_or_start_proxy(const QString &cache_path,
const QString &source_filename, int stream_index, const QString &source_filename, int stream_index,
const ProxyParams &params); const ProxyParams &params);
signals: signals:
void ProxyReady(const QString &source_filename, int stream_index, void proxy_ready(const QString &source_filename, int stream_index,
const QString &proxy_filename); const QString &proxy_filename);
void ProxyFinished(const QString &source_filename, int stream_index, void proxy_finished(const QString &source_filename, int stream_index,
const QString &proxy_filename, ProxyState state); const QString &proxy_filename, ProxyState state);
private: private:
@@ -139,9 +139,9 @@ private:
QVector<ProxyData> proxying_; QVector<ProxyData> proxying_;
private slots: private slots:
void ProxyTaskFinished(Task *task, bool succeeded); void proxy_task_finished(Task *task, bool succeeded);
}; };
} }
#endif // PROXYMANAGER_H #endif // OAK_PROXYMANAGER_H
+7 -7
View File
@@ -29,8 +29,8 @@ namespace olive
{ {
TimecodeMetadata::SourceTime TimecodeMetadata::SourceTime
TimecodeMetadata::FromTimecodeString(const QString &timecode, TimecodeMetadata::from_timecode_string(const QString &timecode,
const core::rational &timebase) const core::Rational &timebase)
{ {
SourceTime result; SourceTime result;
const QString trimmed = timecode.trimmed(); const QString trimmed = timecode.trimmed();
@@ -40,8 +40,8 @@ TimecodeMetadata::FromTimecodeString(const QString &timecode,
bool ok = false; bool ok = false;
const core::Timecode::Display display = const core::Timecode::Display display =
trimmed.contains(';') ? core::Timecode::kTimecodeDropFrame : trimmed.contains(';') ? core::Timecode::k_timecode_drop_frame :
core::Timecode::kTimecodeNonDropFrame; core::Timecode::k_timecode_non_drop_frame;
result.time = core::Timecode::timecode_to_time(trimmed.toStdString(), result.time = core::Timecode::timecode_to_time(trimmed.toStdString(),
timebase, display, &ok); timebase, display, &ok);
result.valid = ok; result.valid = ok;
@@ -52,7 +52,7 @@ TimecodeMetadata::FromTimecodeString(const QString &timecode,
} }
TimecodeMetadata::SourceTime TimecodeMetadata::SourceTime
TimecodeMetadata::FromBwfTimeReference(const QString &time_reference, TimecodeMetadata::from_bwf_time_reference(const QString &time_reference,
int sample_rate) int sample_rate)
{ {
SourceTime result; SourceTime result;
@@ -75,10 +75,10 @@ TimecodeMetadata::FromBwfTimeReference(const QString &time_reference,
const qulonglong rational_limit = const qulonglong rational_limit =
static_cast<qulonglong>(std::numeric_limits<int>::max()); static_cast<qulonglong>(std::numeric_limits<int>::max());
if (numerator <= rational_limit && denominator <= rational_limit) { if (numerator <= rational_limit && denominator <= rational_limit) {
result.time = core::rational(static_cast<int>(numerator), result.time = core::Rational(static_cast<int>(numerator),
static_cast<int>(denominator)); static_cast<int>(denominator));
} else { } else {
result.time = core::rational::fromDouble( result.time = core::Rational::from_double(
static_cast<double>(samples) / static_cast<double>(sample_rate)); static_cast<double>(samples) / static_cast<double>(sample_rate));
} }
result.source = QStringLiteral("bwf_time_reference"); result.source = QStringLiteral("bwf_time_reference");
+7 -7
View File
@@ -18,8 +18,8 @@
***/ ***/
#ifndef TIMECODEMETADATA_H #ifndef OAK_TIMECODEMETADATA_H
#define TIMECODEMETADATA_H #define OAK_TIMECODEMETADATA_H
#include <QString> #include <QString>
@@ -31,18 +31,18 @@ namespace olive
class TimecodeMetadata { class TimecodeMetadata {
public: public:
struct SourceTime { struct SourceTime {
core::rational time; core::Rational time;
QString source; QString source;
bool valid = false; bool valid = false;
}; };
static SourceTime FromTimecodeString(const QString &timecode, static SourceTime from_timecode_string(const QString &timecode,
const core::rational &timebase); const core::Rational &timebase);
static SourceTime FromBwfTimeReference(const QString &time_reference, static SourceTime from_bwf_time_reference(const QString &time_reference,
int sample_rate); int sample_rate);
}; };
} }
#endif // TIMECODEMETADATA_H #endif // OAK_TIMECODEMETADATA_H
+2 -2
View File
@@ -22,8 +22,8 @@ target_sources(libolive-editor PRIVATE
crashpadinterface.cpp crashpadinterface.cpp
crashpadinterface.h crashpadinterface.h
crashpadutils.h crashpadutils.h
Current.cpp current.cpp
Current.h current.h
debug.cpp debug.cpp
debug.h debug.h
decibel.h decibel.h
+4 -4
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef AUTOSCROLL_H #ifndef OAK_AUTOSCROLL_H
#define AUTOSCROLL_H #define OAK_AUTOSCROLL_H
#include "common/define.h" #include "common/define.h"
@@ -29,9 +29,9 @@ namespace olive
class AutoScroll { class AutoScroll {
public: 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 #ifndef OAK_AVFRAMEPTR_H
#define AVFRAMEPTR_H #define OAK_AVFRAMEPTR_H
#include <stdint.h> #include <stdint.h>
@@ -124,16 +124,16 @@ private:
using AVFramePtr = std::shared_ptr<AVFrame>; 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); return std::make_shared<AVFrame>(f);
} }
inline AVFramePtr CreateAVFramePtr() inline AVFramePtr create_av_frame_ptr()
{ {
return std::make_shared<AVFrame>(); return std::make_shared<AVFrame>();
} }
} }
#endif // AVFRAMEPTR_H #endif // OAK_AVFRAMEPTR_H
+8 -8
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef CANCELABLEOBJECT_H #ifndef OAK_CANCELABLEOBJECT_H
#define CANCELABLEOBJECT_H #define OAK_CANCELABLEOBJECT_H
#include "common/define.h" #include "common/define.h"
#include "render/cancelatom.h" #include "render/cancelatom.h"
@@ -34,20 +34,20 @@ public:
{ {
} }
void Cancel() void cancel()
{ {
cancel_.Cancel(); cancel_.cancel();
CancelEvent(); CancelEvent();
} }
CancelAtom *GetCancelAtom() CancelAtom *get_cancel_atom()
{ {
return &cancel_; return &cancel_;
} }
bool IsCancelled() bool is_cancelled()
{ {
return cancel_.IsCancelled(); return cancel_.is_cancelled();
} }
protected: 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 * const CommandLineParser::Option *
CommandLineParser::AddOption(const QStringList &strings, CommandLineParser::add_option(const QStringList &strings,
const QString &description, bool takes_arg, const QString &description, bool takes_arg,
const QString &arg_placeholder, bool hidden) const QString &arg_placeholder, bool hidden)
{ {
@@ -49,7 +49,7 @@ CommandLineParser::AddOption(const QStringList &strings,
} }
const CommandLineParser::PositionalArgument * const CommandLineParser::PositionalArgument *
CommandLineParser::AddPositionalArgument(const QString &name, CommandLineParser::add_positional_argument(const QString &name,
const QString &description, const QString &description,
bool required) bool required)
{ {
@@ -60,7 +60,7 @@ CommandLineParser::AddPositionalArgument(const QString &name,
return a; return a;
} }
void CommandLineParser::Process(const QVector<QString> &argv) void CommandLineParser::process(const QVector<QString> &argv)
{ {
int positional_index = 0; int positional_index = 0;
@@ -79,10 +79,10 @@ void CommandLineParser::Process(const QVector<QString> &argv)
foreach (const QString &s, o.args) { foreach (const QString &s, o.args) {
if (!s.compare(arg_basename, Qt::CaseInsensitive)) { if (!s.compare(arg_basename, Qt::CaseInsensitive)) {
// Flag discovered! // Flag discovered!
o.option->Set(); o.option->set();
if (o.takes_arg && i + 1 < argv.size()) { if (o.takes_arg && i + 1 < argv.size()) {
o.option->SetSetting(argv[i + 1]); o.option->set_setting(argv[i + 1]);
i++; i++;
} }
@@ -100,7 +100,7 @@ found_flag:
} else { } else {
// Must be a positional flag // Must be a positional flag
if (positional_index < positional_args_.size()) { 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++; positional_index++;
} else { } else {
qWarning() << "Unknown parameter:" << argv[i]; 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(), printf("%s %s\n", QCoreApplication::applicationName().toUtf8().constData(),
QCoreApplication::applicationVersion().toUtf8().constData()); QCoreApplication::applicationVersion().toUtf8().constData());
+11 -11
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef COMMANDLINEPARSER_H #ifndef OAK_COMMANDLINEPARSER_H
#define COMMANDLINEPARSER_H #define OAK_COMMANDLINEPARSER_H
#include <QStringList> #include <QStringList>
#include <QVector> #include <QVector>
@@ -47,12 +47,12 @@ public:
public: public:
PositionalArgument() = default; PositionalArgument() = default;
const QString &GetSetting() const const QString &get_setting() const
{ {
return setting_; return setting_;
} }
void SetSetting(const QString &s) void set_setting(const QString &s)
{ {
setting_ = s; setting_ = s;
} }
@@ -68,12 +68,12 @@ public:
is_set_ = false; is_set_ = false;
} }
bool IsSet() const bool is_set() const
{ {
return is_set_; return is_set_;
} }
void Set() void set()
{ {
is_set_ = true; is_set_ = true;
} }
@@ -84,18 +84,18 @@ public:
CommandLineParser() = default; CommandLineParser() = default;
const Option *AddOption(const QStringList &strings, const Option *add_option(const QStringList &strings,
const QString &description, bool takes_arg = false, const QString &description, bool takes_arg = false,
const QString &arg_placeholder = QString(), const QString &arg_placeholder = QString(),
bool hidden = false); bool hidden = false);
const PositionalArgument *AddPositionalArgument(const QString &name, const PositionalArgument *add_positional_argument(const QString &name,
const QString &description, const QString &description,
bool required = false); 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: private:
struct KnownOption { struct KnownOption {
@@ -119,4 +119,4 @@ private:
QVector<KnownPositionalArgument> positional_args_; QVector<KnownPositionalArgument> positional_args_;
}; };
#endif // COMMANDLINEPARSER_H #endif // OAK_COMMANDLINEPARSER_H
+3 -3
View File
@@ -18,8 +18,8 @@
***/ ***/
#ifndef CRASHPAD_INTERFACE_H #ifndef OAK_CRASHPAD_INTERFACE_H
#define CRASHPAD_INTERFACE_H #define OAK_CRASHPAD_INTERFACE_H
#ifdef USE_CRASHPAD #ifdef USE_CRASHPAD
@@ -30,4 +30,4 @@ bool InitializeCrashpad();
#endif // USE_CRASHPAD #endif // USE_CRASHPAD
#endif // CRASHPAD_INTERFACE_H #endif // OAK_CRASHPAD_INTERFACE_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef CRASHPADUTILS_H #ifndef OAK_CRASHPADUTILS_H
#define CRASHPADUTILS_H #define OAK_CRASHPADUTILS_H
#include <client/crashpad_client.h> #include <client/crashpad_client.h>
@@ -38,4 +38,4 @@
#define BASE_STRING_TO_QSTRING(x) QString::fromStdWString(x) #define BASE_STRING_TO_QSTRING(x) QString::fromStdWString(x)
#endif // BUILDFLAG(IS_WIN) #endif // BUILDFLAG(IS_WIN)
#endif // CRASHPADUTILS_H #endif // OAK_CRASHPADUTILS_H
@@ -17,6 +17,6 @@
* *
*/ */
#include "Current.h" #include "current.h"
Current Current::current; Current Current::current;
+11 -11
View File
@@ -17,9 +17,9 @@
* *
*/ */
#ifndef CURRENT_H #ifndef OAK_CURRENT_H
#define CURRENT_H #define OAK_CURRENT_H
#include "pluginSupport/OliveHost.h" #include "pluginSupport/olivehost.h"
#include "render/videoparams.h" #include "render/videoparams.h"
#include "render/job/pluginjob.h" #include "render/job/pluginjob.h"
@@ -29,11 +29,11 @@ public:
{ {
return current; return current;
} }
olive::VideoParams &currentVideoParams() olive::VideoParams &current_video_params()
{ {
return currentVideoParams_; return currentVideoParams_;
} }
olive::AudioParams &currentAudioParams() olive::AudioParams &current_audio_params()
{ {
return currentAudioParams_; return currentAudioParams_;
} }
@@ -58,17 +58,17 @@ public:
return true; 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) 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_; return plugin_cache_;
} }
@@ -83,8 +83,8 @@ private:
static Current current; static Current current;
olive::VideoParams currentVideoParams_; olive::VideoParams currentVideoParams_;
olive::AudioParams currentAudioParams_; 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_; 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 namespace olive
{ {
void DebugHandler(QtMsgType type, const QMessageLogContext &context, void debug_handler(QtMsgType type, const QMessageLogContext &context,
const QString &msg) const QString &msg)
{ {
QByteArray localMsg = msg.toLocal8Bit(); QByteArray local_msg = msg.toLocal8Bit();
const char *msg_type = "UNKNOWN"; const char *msg_type = "UNKNOWN";
switch (type) { 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 (%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 #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 // 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 #ifndef OAK_DEBUG_H
#define DEBUG_H #define OAK_DEBUG_H
#include <QDebug> #include <QDebug>
@@ -29,9 +29,9 @@
namespace olive namespace olive
{ {
void DebugHandler(QtMsgType type, const QMessageLogContext &context, void debug_handler(QtMsgType type, const QMessageLogContext &context,
const QString &msg); const QString &msg);
} }
#endif // DEBUG_H #endif // OAK_DEBUG_H
+17 -17
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef DECIBEL_H #ifndef OAK_DECIBEL_H
#define DECIBEL_H #define OAK_DECIBEL_H
#include <QtGlobal> #include <QtGlobal>
#include <cmath> #include <cmath>
@@ -33,20 +33,20 @@ namespace olive
class Decibel { class Decibel {
public: public:
// In basically all circumstances, this should calculate to 0.0 linear // 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); double v = double(20.0) * std::log10(linear);
#ifndef ALLOW_RETURNING_INFINITY #ifndef ALLOW_RETURNING_INFINITY
if (std::isinf(v)) { if (std::isinf(v)) {
return MINIMUM; return minimum;
} }
#endif #endif
return v; 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)); 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) if (logarithmic < 0.001)
#ifdef ALLOW_RETURNING_INFINITY #ifdef ALLOW_RETURNING_INFINITY
return std::numeric_limits<double>::infinity(); return std::numeric_limits<double>::infinity();
#else #else
return MINIMUM; return minimum;
#endif #endif
else if (logarithmic > 0.99) else if (logarithmic > 0.99)
return 0; return 0;
else 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)) { if (qFuzzyIsNull(decibel)) {
return 1; return 1;
} else { } 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) { if (logarithmic > 0.99) {
return 1; return 1;
} else { } else {
return -std::log(1 - logarithmic) / LOG100; return -std::log(1 - logarithmic) / lo_g100;
} }
} }
private: 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 #ifndef OAK_OLIVECOMMONDEFINE_H
#define OLIVECOMMONDEFINE_H #define OAK_OLIVECOMMONDEFINE_H
namespace olive namespace olive
{ {
/// The minimum size an icon in ProjectExplorer can be /// 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 /// 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 /// 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_COPY(Class) \
DISABLE_MOVE(Class) DISABLE_MOVE(Class)
#endif // OLIVECOMMONDEFINE_H #endif // OAK_OLIVECOMMONDEFINE_H
+4 -4
View File
@@ -19,15 +19,15 @@
***/ ***/
#ifndef DIGIT_H #ifndef OAK_DIGIT_H
#define DIGIT_H #define OAK_DIGIT_H
#include <stdint.h> #include <stdint.h>
namespace olive namespace olive
{ {
inline int64_t GetDigitCount(int64_t input) inline int64_t get_digit_count(int64_t input)
{ {
input = std::abs(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 namespace olive
{ {
int FFmpegUtils::GetCompatibleBridgePixelFormat(int pix_fmt, int FFmpegUtils::get_compatible_bridge_pixel_format(int pix_fmt,
PixelFormat maximum) PixelFormat maximum)
{ {
int possible_pix_fmts[4]; 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) { if (maximum == PixelFormat::u8) {
possible_pix_fmts[1] = FB_PIX_FMT_NONE; possible_pix_fmts[1] = fb_pix_fmt_none;
} else { } else {
possible_pix_fmts[1] = FB_PIX_FMT_RGBA64LE; possible_pix_fmts[1] = fb_pix_fmt_rgb_a64_le;
if (maximum == PixelFormat::F32) { if (maximum == PixelFormat::f32) {
possible_pix_fmts[2] = FB_PIX_FMT_RGBAF32LE; possible_pix_fmts[2] = fb_pix_fmt_rgba_f32_le;
possible_pix_fmts[3] = FB_PIX_FMT_NONE; possible_pix_fmts[3] = fb_pix_fmt_none;
} else { } 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); 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) { switch (smp_fmt) {
case FB_SAMPLE_FMT_U8: case fb_sample_fmt_u8:
return SampleFormat::U8; return SampleFormat::u8;
case FB_SAMPLE_FMT_S16: case fb_sample_fmt_s16:
return SampleFormat::S16; return SampleFormat::s16;
case FB_SAMPLE_FMT_S32: case fb_sample_fmt_s32:
return SampleFormat::S32; return SampleFormat::s32;
case FB_SAMPLE_FMT_S64: case fb_sample_fmt_s64:
return SampleFormat::S64; return SampleFormat::s64;
case FB_SAMPLE_FMT_FLT: case fb_sample_fmt_flt:
return SampleFormat::F32; return SampleFormat::f32;
case FB_SAMPLE_FMT_DBL: case fb_sample_fmt_dbl:
return SampleFormat::F64; return SampleFormat::f64;
case FB_SAMPLE_FMT_U8P: case fb_sample_fmt_u8_p:
return SampleFormat::U8P; return SampleFormat::u8_p;
case FB_SAMPLE_FMT_S16P: case fb_sample_fmt_s16_p:
return SampleFormat::S16P; return SampleFormat::s16_p;
case FB_SAMPLE_FMT_S32P: case fb_sample_fmt_s32_p:
return SampleFormat::S32P; return SampleFormat::s32_p;
case FB_SAMPLE_FMT_S64P: case fb_sample_fmt_s64_p:
return SampleFormat::S64P; return SampleFormat::s64_p;
case FB_SAMPLE_FMT_FLTP: case fb_sample_fmt_fltp:
return SampleFormat::F32P; return SampleFormat::f32_p;
case FB_SAMPLE_FMT_DBLP: case fb_sample_fmt_dblp:
return SampleFormat::F64P; return SampleFormat::f64_p;
default: default:
break; 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) { switch (smp_fmt) {
case SampleFormat::U8: case SampleFormat::u8:
return FB_SAMPLE_FMT_U8; return fb_sample_fmt_u8;
case SampleFormat::S16: case SampleFormat::s16:
return FB_SAMPLE_FMT_S16; return fb_sample_fmt_s16;
case SampleFormat::S32: case SampleFormat::s32:
return FB_SAMPLE_FMT_S32; return fb_sample_fmt_s32;
case SampleFormat::S64: case SampleFormat::s64:
return FB_SAMPLE_FMT_S64; return fb_sample_fmt_s64;
case SampleFormat::F32: case SampleFormat::f32:
return FB_SAMPLE_FMT_FLT; return fb_sample_fmt_flt;
case SampleFormat::F64: case SampleFormat::f64:
return FB_SAMPLE_FMT_DBL; return fb_sample_fmt_dbl;
case SampleFormat::U8P: case SampleFormat::u8_p:
return FB_SAMPLE_FMT_U8P; return fb_sample_fmt_u8_p;
case SampleFormat::S16P: case SampleFormat::s16_p:
return FB_SAMPLE_FMT_S16P; return fb_sample_fmt_s16_p;
case SampleFormat::S32P: case SampleFormat::s32_p:
return FB_SAMPLE_FMT_S32P; return fb_sample_fmt_s32_p;
case SampleFormat::S64P: case SampleFormat::s64_p:
return FB_SAMPLE_FMT_S64P; return fb_sample_fmt_s64_p;
case SampleFormat::F32P: case SampleFormat::f32_p:
return FB_SAMPLE_FMT_FLTP; return fb_sample_fmt_fltp;
case SampleFormat::F64P: case SampleFormat::f64_p:
return FB_SAMPLE_FMT_DBLP; return fb_sample_fmt_dblp;
case SampleFormat::INVALID: case SampleFormat::invalid:
case SampleFormat::COUNT: case SampleFormat::count:
break; 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) { switch (f) {
case FB_PIX_FMT_YUVJ420P: case fb_pix_fmt_yuv_j420_p:
return FB_PIX_FMT_YUV420P; return fb_pix_fmt_yu_v420_p;
case FB_PIX_FMT_YUVJ422P: case fb_pix_fmt_yuv_j422_p:
return FB_PIX_FMT_YUV422P; return fb_pix_fmt_yu_v422_p;
case FB_PIX_FMT_YUVJ444P: case fb_pix_fmt_yuv_j444_p:
return FB_PIX_FMT_YUV444P; return fb_pix_fmt_yu_v444_p;
case FB_PIX_FMT_YUVJ440P: case fb_pix_fmt_yuv_j440_p:
return FB_PIX_FMT_YUV440P; return fb_pix_fmt_yu_v440_p;
case FB_PIX_FMT_YUVJ411P: case fb_pix_fmt_yuv_j411_p:
return FB_PIX_FMT_YUV411P; return fb_pix_fmt_yu_v411_p;
default: default:
break; break;
} }
@@ -135,63 +135,63 @@ int FFmpegUtils::ConvertJPEGSpaceToRegularSpace(int f)
return f; return f;
} }
int FFmpegUtils::GetFFmpegPixelFormat(const PixelFormat &pix_fmt, int FFmpegUtils::get_f_fmpeg_pixel_format(const PixelFormat &pix_fmt,
int channel_layout) int channel_layout)
{ {
if (channel_layout == VideoParams::kRGBChannelCount) { if (channel_layout == VideoParams::k_rgb_channel_count) {
switch (pix_fmt) { switch (pix_fmt) {
case PixelFormat::U8: case PixelFormat::u8:
return FB_PIX_FMT_RGB24; return fb_pix_fmt_rg_b24;
case PixelFormat::U10: case PixelFormat::u10:
return FB_PIX_FMT_NONE; return fb_pix_fmt_none;
case PixelFormat::U16: case PixelFormat::u16:
return FB_PIX_FMT_RGB48LE; return fb_pix_fmt_rg_b48_le;
case PixelFormat::F16: case PixelFormat::f16:
return FB_PIX_FMT_RGBF16LE; return fb_pix_fmt_rgb_f16_le;
case PixelFormat::F32: case PixelFormat::f32:
return FB_PIX_FMT_RGBF32LE; return fb_pix_fmt_rgb_f32_le;
case PixelFormat::INVALID: case PixelFormat::invalid:
case PixelFormat::COUNT: case PixelFormat::count:
break; break;
} }
} else if (channel_layout == VideoParams::kRGBAChannelCount) { } else if (channel_layout == VideoParams::k_rgba_channel_count) {
switch (pix_fmt) { switch (pix_fmt) {
case PixelFormat::U8: case PixelFormat::u8:
return FB_PIX_FMT_RGBA; return fb_pix_fmt_rgba;
case PixelFormat::U10: case PixelFormat::u10:
return FB_PIX_FMT_NONE; return fb_pix_fmt_none;
case PixelFormat::U16: case PixelFormat::u16:
return FB_PIX_FMT_RGBA64LE; return fb_pix_fmt_rgb_a64_le;
case PixelFormat::F16: case PixelFormat::f16:
return FB_PIX_FMT_RGBAF16LE; return fb_pix_fmt_rgba_f16_le;
case PixelFormat::F32: case PixelFormat::f32:
return FB_PIX_FMT_RGBAF32LE; return fb_pix_fmt_rgba_f32_le;
case PixelFormat::INVALID: case PixelFormat::invalid:
case PixelFormat::COUNT: case PixelFormat::count:
break; 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) { switch (pix_fmt) {
case PixelFormat::U8: case PixelFormat::u8:
return PixelFormat::U8; return PixelFormat::u8;
case PixelFormat::U10: case PixelFormat::u10:
return PixelFormat::U8; return PixelFormat::u8;
case PixelFormat::U16: case PixelFormat::u16:
case PixelFormat::F16: case PixelFormat::f16:
case PixelFormat::F32: case PixelFormat::f32:
return PixelFormat::U16; return PixelFormat::u16;
case PixelFormat::INVALID: case PixelFormat::invalid:
case PixelFormat::COUNT: case PixelFormat::count:
break; break;
} }
return PixelFormat::INVALID; return PixelFormat::invalid;
} }
} }
+10 -10
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef FFMPEGABSTRACTION_H #ifndef OAK_FFMPEGABSTRACTION_H
#define FFMPEGABSTRACTION_H #define OAK_FFMPEGABSTRACTION_H
#include <ffmpeg_bridge/ffmpeg_bridge.h> #include <ffmpeg_bridge/ffmpeg_bridge.h>
@@ -50,29 +50,29 @@ public:
* taking a single argument, an unscoped enum argument would silently * taking a single argument, an unscoped enum argument would silently
* prefer an int overload over the PixelFormat one. * prefer an int overload over the PixelFormat one.
*/ */
static int GetCompatibleBridgePixelFormat( static int get_compatible_bridge_pixel_format(
int pix_fmt, PixelFormat maximum = PixelFormat::INVALID); 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 * @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 * @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); int channel_layout);
/** /**
* @brief Returns a native sample format type for a given bridge sample format * @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 * @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 * @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 * time being, FFmpeg still uses these JPEG spaces, so for simplicity (since we *are* color_range
* aware), we use this function. * 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 namespace olive
{ {
QString FileFunctions::GetUniqueFileIdentifier(const QString &filename) QString FileFunctions::get_unique_file_identifier(const QString &filename)
{ {
QFileInfo info(filename); QFileInfo info(filename);
@@ -53,10 +53,10 @@ QString FileFunctions::GetUniqueFileIdentifier(const QString &filename)
return QString(result.toHex()); return QString(result.toHex());
} }
QString FileFunctions::GetConfigurationLocation() QString FileFunctions::get_configuration_location()
{ {
if (IsPortable()) { if (is_portable()) {
return GetApplicationPath(); return get_application_path();
} else { } else {
QString s = QString s =
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); 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(); return QCoreApplication::applicationDirPath();
} }
QString FileFunctions::GetTempFilePath() QString FileFunctions::get_temp_file_path()
{ {
QString temp_path = QString temp_path =
QDir( QDir(
@@ -89,7 +89,7 @@ QString FileFunctions::GetTempFilePath()
return temp_path; return temp_path;
} }
bool FileFunctions::CanCopyDirectoryWithoutOverwriting(const QString &source, bool FileFunctions::can_copy_directory_without_overwriting(const QString &source,
const QString &dest) const QString &dest)
{ {
QFileInfoList info_list = QDir(source).entryInfoList(); QFileInfoList info_list = QDir(source).entryInfoList();
@@ -104,7 +104,7 @@ bool FileFunctions::CanCopyDirectoryWithoutOverwriting(const QString &source,
QString dest_equivalent = QDir(dest).filePath(info.fileName()); QString dest_equivalent = QDir(dest).filePath(info.fileName());
if (info.isDir()) { if (info.isDir()) {
if (!CanCopyDirectoryWithoutOverwriting(info.absoluteFilePath(), if (!can_copy_directory_without_overwriting(info.absoluteFilePath(),
dest_equivalent)) { dest_equivalent)) {
return false; return false;
} }
@@ -116,7 +116,7 @@ bool FileFunctions::CanCopyDirectoryWithoutOverwriting(const QString &source,
return true; return true;
} }
void FileFunctions::CopyDirectory(const QString &source, const QString &dest, void FileFunctions::copy_directory(const QString &source, const QString &dest,
bool overwrite) bool overwrite)
{ {
QDir d(source); QDir d(source);
@@ -147,7 +147,7 @@ void FileFunctions::CopyDirectory(const QString &source, const QString &dest,
if (info.isDir()) { if (info.isDir()) {
// Copy dir // Copy dir
CopyDirectory(info.absoluteFilePath(), dest_file_path, overwrite); copy_directory(info.absoluteFilePath(), dest_file_path, overwrite);
} else { } else {
// Copy file // Copy file
if (overwrite && QFile::exists(dest_file_path)) { 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) bool try_to_create_if_not_exists)
{ {
// Return whether the directory exists, or whether it could be created if it doesn't // 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("."))); (try_to_create_if_not_exists && d.mkpath(QStringLiteral(".")));
} }
QString FileFunctions::EnsureFilenameExtension(QString fn, QString FileFunctions::ensure_filename_extension(QString fn,
const QString &extension) const QString &extension)
{ {
// No-op if either input is empty // No-op if either input is empty
@@ -190,7 +190,7 @@ QString FileFunctions::EnsureFilenameExtension(QString fn,
return fn; return fn;
} }
QString FileFunctions::ReadFileAsString(const QString &filename) QString FileFunctions::read_file_as_string(const QString &filename)
{ {
QFile f(filename); QFile f(filename);
QString file_data; QString file_data;
@@ -202,7 +202,7 @@ QString FileFunctions::ReadFileAsString(const QString &filename)
return file_data; return file_data;
} }
QString FileFunctions::GetSafeTemporaryFilename(const QString &original) QString FileFunctions::get_safe_temporary_filename(const QString &original)
{ {
int counter = 0; int counter = 0;
@@ -226,7 +226,7 @@ QString FileFunctions::GetSafeTemporaryFilename(const QString &original)
return temp_abs_path; return temp_abs_path;
} }
bool FileFunctions::RenameFileAllowOverwrite(const QString &from, bool FileFunctions::rename_file_allow_overwrite(const QString &from,
const QString &to) const QString &to)
{ {
if (QFileInfo::exists(to) && !QFile::remove(to)) { if (QFileInfo::exists(to) && !QFile::remove(to)) {
@@ -243,7 +243,7 @@ bool FileFunctions::RenameFileAllowOverwrite(const QString &from,
return true; return true;
} }
QString FileFunctions::GetAutoRecoveryRoot() QString FileFunctions::get_auto_recovery_root()
{ {
return QDir(QStandardPaths::writableLocation( return QDir(QStandardPaths::writableLocation(
QStandardPaths::AppLocalDataLocation)) QStandardPaths::AppLocalDataLocation))
+17 -17
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef FILEFUNCTIONS_H #ifndef OAK_FILEFUNCTIONS_H
#define FILEFUNCTIONS_H #define OAK_FILEFUNCTIONS_H
#include <QDir> #include <QDir>
#include <QString> #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 * 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. * 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); 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); 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); 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. * @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); 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 * @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 * This function returns a slight variant of the filename provided that's guaranteed to not exist
* and therefore won't overwrite anything important. * 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 * @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); const QString &to);
inline static QString GetFormattedExecutableForPlatform(QString unformatted) inline static QString get_formatted_executable_for_platform(QString unformatted)
{ {
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
unformatted.append(QStringLiteral(".exe")); unformatted.append(QStringLiteral(".exe"));
@@ -101,9 +101,9 @@ public:
return unformatted; 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 namespace olive
{ {
const QVector<QString> Html::kBlockTags = { QStringLiteral("p"), const QVector<QString> Html::k_block_tags = { QStringLiteral("p"),
QStringLiteral("div") }; 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); return !a.compare(b, Qt::CaseInsensitive);
} }
QString Html::DocToHtml(const QTextDocument *doc) QString Html::doc_to_html(const QTextDocument *doc)
{ {
QString html; QString html;
QXmlStreamWriter writer(&html); QXmlStreamWriter writer(&html);
@@ -42,7 +42,7 @@ QString Html::DocToHtml(const QTextDocument *doc)
//writer.setAutoFormatting(true); //writer.setAutoFormatting(true);
for (auto it = doc->begin(); it != doc->end(); it = it.next()) { for (auto it = doc->begin(); it != doc->end(); it = it.next()) {
WriteBlock(&writer, it); write_block(&writer, it);
} }
return html; return html;
@@ -53,7 +53,7 @@ struct HtmlNode {
QTextCharFormat format; QTextCharFormat format;
}; };
QTextCharFormat MergeHtmlFormats(const QVector<HtmlNode> &stack) QTextCharFormat merge_html_formats(const QVector<HtmlNode> &stack)
{ {
QTextCharFormat f; QTextCharFormat f;
@@ -64,7 +64,7 @@ QTextCharFormat MergeHtmlFormats(const QVector<HtmlNode> &stack)
return f; return f;
} }
void Html::HtmlToDoc(QTextDocument *doc, const QString &html) void Html::html_to_doc(QTextDocument *doc, const QString &html)
{ {
// Empty doc // Empty doc
doc->clear(); doc->clear();
@@ -90,12 +90,12 @@ void Html::HtmlToDoc(QTextDocument *doc, const QString &html)
if (reader.tokenType() == QXmlStreamReader::StartElement) { if (reader.tokenType() == QXmlStreamReader::StartElement) {
QString tag = reader.name().toString().toLower(); QString tag = reader.name().toString().toLower();
fmt_stack.append({ tag, ReadCharFormat(reader.attributes()) }); fmt_stack.append({ tag, read_char_format(reader.attributes()) });
current_fmt = MergeHtmlFormats(fmt_stack); current_fmt = merge_html_formats(fmt_stack);
if (kBlockTags.contains(tag)) { if (k_block_tags.contains(tag)) {
QTextBlockFormat block_fmt = QTextBlockFormat block_fmt =
ReadBlockFormat(reader.attributes()); read_block_format(reader.attributes());
if (inside_block) { if (inside_block) {
c.setBlockFormat(block_fmt); c.setBlockFormat(block_fmt);
c.setBlockCharFormat(current_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--) { for (int i = fmt_stack.size() - 1; i >= 0; i--) {
if (fmt_stack.at(i).tag == tag) { if (fmt_stack.at(i).tag == tag) {
fmt_stack.removeAt(i); 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; inside_block = false;
} }
break; 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")); writer->writeStartElement(QStringLiteral("p"));
@@ -160,11 +160,11 @@ void Html::WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block)
QString style; QString style;
if (fmt.lineHeightType() != QTextBlockFormat::SingleHeight) { if (fmt.lineHeightType() != QTextBlockFormat::SingleHeight) {
WriteCSSProperty(&style, QStringLiteral("line-height"), write_css_property(&style, QStringLiteral("line-height"),
QStringLiteral("%1%").arg(fmt.lineHeight())); QStringLiteral("%1%").arg(fmt.lineHeight()));
} }
WriteCharFormat(&style, block.charFormat()); write_char_format(&style, block.charFormat());
if (!style.isEmpty()) { if (!style.isEmpty()) {
writer->writeAttribute(QStringLiteral("style"), style); writer->writeAttribute(QStringLiteral("style"), style);
@@ -174,14 +174,14 @@ void Html::WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block)
if (it != block.end()) { if (it != block.end()) {
for (; it != block.end(); it++) { for (; it != block.end(); it++) {
WriteFragment(writer, it.fragment()); write_fragment(writer, it.fragment());
} }
} }
writer->writeEndElement(); // p writer->writeEndElement(); // p
} }
void Html::WriteFragment(QXmlStreamWriter *writer, void Html::write_fragment(QXmlStreamWriter *writer,
const QTextFragment &fragment) const QTextFragment &fragment)
{ {
const QTextCharFormat &fmt = fragment.charFormat(); const QTextCharFormat &fmt = fragment.charFormat();
@@ -191,7 +191,7 @@ void Html::WriteFragment(QXmlStreamWriter *writer,
// Write CSS attributes // Write CSS attributes
QString style; QString style;
WriteCharFormat(&style, fmt); write_char_format(&style, fmt);
if (!style.isEmpty()) { if (!style.isEmpty()) {
writer->writeAttribute(QStringLiteral("style"), style); writer->writeAttribute(QStringLiteral("style"), style);
@@ -211,7 +211,7 @@ void Html::WriteFragment(QXmlStreamWriter *writer,
writer->writeEndElement(); // span writer->writeEndElement(); // span
} }
void Html::WriteCSSProperty(QString *style, const QString &key, void Html::write_css_property(QString *style, const QString &key,
const QStringList &values) const QStringList &values)
{ {
QString value; QString value;
@@ -220,39 +220,39 @@ void Html::WriteCSSProperty(QString *style, const QString &key,
v = QStringLiteral("'%1'").arg(v); 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(); QStringList families = fmt.fontFamilies().toStringList();
if (!families.isEmpty()) { if (!families.isEmpty()) {
WriteCSSProperty(style, QStringLiteral("font-family"), write_css_property(style, QStringLiteral("font-family"),
families.first()); families.first());
} }
if (fmt.hasProperty(QTextFormat::FontPointSize)) { if (fmt.hasProperty(QTextFormat::FontPointSize)) {
WriteCSSProperty( write_css_property(
style, QStringLiteral("font-size"), style, QStringLiteral("font-size"),
QStringLiteral("%1pt").arg(QString::number(fmt.fontPointSize()))); QStringLiteral("%1pt").arg(QString::number(fmt.fontPointSize())));
} }
if (fmt.hasProperty(QTextFormat::FontWeight)) { if (fmt.hasProperty(QTextFormat::FontWeight)) {
WriteCSSProperty(style, QStringLiteral("font-weight"), write_css_property(style, QStringLiteral("font-weight"),
QString::number(fmt.fontWeight() * 8)); QString::number(fmt.fontWeight() * 8));
} }
if (fmt.hasProperty(QTextFormat::FontItalic)) { if (fmt.hasProperty(QTextFormat::FontItalic)) {
WriteCSSProperty(style, QStringLiteral("font-style"), write_css_property(style, QStringLiteral("font-style"),
fmt.fontItalic() ? QStringLiteral("italic") : fmt.fontItalic() ? QStringLiteral("italic") :
QStringLiteral("normal")); QStringLiteral("normal"));
} }
if (fmt.hasProperty(QTextFormat::FontStyleName)) { if (fmt.hasProperty(QTextFormat::FontStyleName)) {
WriteCSSProperty(style, QStringLiteral("-ove-font-style"), write_css_property(style, QStringLiteral("-ove-font-style"),
fmt.fontStyleName().toString()); fmt.fontStyleName().toString());
} }
@@ -271,7 +271,7 @@ void Html::WriteCharFormat(QString *style, const QTextCharFormat &fmt)
} }
if (!deco.isEmpty()) { if (!deco.isEmpty()) {
WriteCSSProperty(style, QStringLiteral("text-decoration"), deco); write_css_property(style, QStringLiteral("text-decoration"), deco);
} }
if (fmt.foreground().style() != Qt::NoBrush) { if (fmt.foreground().style() != Qt::NoBrush) {
@@ -288,37 +288,37 @@ void Html::WriteCharFormat(QString *style, const QTextCharFormat &fmt)
QString::number(color.alphaF())); 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::MixedCase) {
if (fmt.fontCapitalization() == QFont::SmallCaps) { if (fmt.fontCapitalization() == QFont::SmallCaps) {
WriteCSSProperty(style, QStringLiteral("font-variant"), write_css_property(style, QStringLiteral("font-variant"),
QStringLiteral("small-caps")); QStringLiteral("small-caps"));
// TODO: Add others // TODO: Add others
} }
} }
if (fmt.fontLetterSpacing() != 0.0) { if (fmt.fontLetterSpacing() != 0.0) {
WriteCSSProperty(style, QStringLiteral("letter-spacing"), write_css_property(style, QStringLiteral("letter-spacing"),
QStringLiteral("%1%").arg( QStringLiteral("%1%").arg(
QString::number(fmt.fontLetterSpacing()))); QString::number(fmt.fontLetterSpacing())));
} }
if (fmt.fontStretch() != 0) { if (fmt.fontStretch() != 0) {
WriteCSSProperty( write_css_property(
style, QStringLiteral("font-stretch"), style, QStringLiteral("font-stretch"),
QStringLiteral("%1%").arg(QString::number(fmt.fontStretch()))); QStringLiteral("%1%").arg(QString::number(fmt.fontStretch())));
} }
} }
QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes) QTextCharFormat Html::read_char_format(const QXmlStreamAttributes &attributes)
{ {
QTextCharFormat fmt; QTextCharFormat fmt;
foreach (const QXmlStreamAttribute &attr, attributes) { foreach (const QXmlStreamAttribute &attr, attributes) {
if (StrEquals(attr.name(), QStringLiteral("style"))) { if (str_equals(attr.name(), QStringLiteral("style"))) {
auto css = GetCSSFromStyle(attr.value().toString()); auto css = get_css_from_style(attr.value().toString());
for (auto it = css.begin(); it != css.end(); it++) { for (auto it = css.begin(); it != css.end(); it++) {
const QString &first_val = it.value().first(); const QString &first_val = it.value().first();
@@ -334,15 +334,15 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes)
fmt.setFontWeight(first_val.toInt() / 8); fmt.setFontWeight(first_val.toInt() / 8);
} else if (it.key() == QStringLiteral("font-style")) { } else if (it.key() == QStringLiteral("font-style")) {
fmt.setFontItalic( fmt.setFontItalic(
StrEquals(first_val, QStringLiteral("italic"))); str_equals(first_val, QStringLiteral("italic")));
} else if (it.key() == QStringLiteral("text-decoration")) { } else if (it.key() == QStringLiteral("text-decoration")) {
foreach (const QString &v, it.value()) { foreach (const QString &v, it.value()) {
if (StrEquals(v, QStringLiteral("underline"))) { if (str_equals(v, QStringLiteral("underline"))) {
fmt.setFontUnderline(true); fmt.setFontUnderline(true);
} else if (StrEquals(v, } else if (str_equals(v,
QStringLiteral("line-through"))) { QStringLiteral("line-through"))) {
fmt.setFontStrikeOut(true); fmt.setFontStrikeOut(true);
} else if (StrEquals(v, QStringLiteral("overline"))) { } else if (str_equals(v, QStringLiteral("overline"))) {
fmt.setFontOverline(true); fmt.setFontOverline(true);
} }
} }
@@ -366,7 +366,7 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes)
fmt.setForeground(QColor(first_val)); fmt.setForeground(QColor(first_val));
} }
} else if (it.key() == QStringLiteral("font-variant")) { } 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); fmt.setFontCapitalization(QFont::SmallCaps);
} }
} else if (it.key() == QStringLiteral("letter-spacing")) { } else if (it.key() == QStringLiteral("letter-spacing")) {
@@ -387,25 +387,25 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes)
return fmt; return fmt;
} }
QTextBlockFormat Html::ReadBlockFormat(const QXmlStreamAttributes &attributes) QTextBlockFormat Html::read_block_format(const QXmlStreamAttributes &attributes)
{ {
QTextBlockFormat block_fmt; QTextBlockFormat block_fmt;
foreach (const QXmlStreamAttribute &attr, attributes) { foreach (const QXmlStreamAttribute &attr, attributes) {
if (StrEquals(attr.name(), QStringLiteral("align"))) { if (str_equals(attr.name(), QStringLiteral("align"))) {
if (StrEquals(attr.value(), QStringLiteral("right"))) { if (str_equals(attr.value(), QStringLiteral("right"))) {
block_fmt.setAlignment(Qt::AlignRight); 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); 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); block_fmt.setAlignment(Qt::AlignJustify);
} }
} else if (StrEquals(attr.name(), QStringLiteral("dir"))) { } else if (str_equals(attr.name(), QStringLiteral("dir"))) {
if (StrEquals(attr.value(), QStringLiteral("rtl"))) { if (str_equals(attr.value(), QStringLiteral("rtl"))) {
block_fmt.setLayoutDirection(Qt::RightToLeft); block_fmt.setLayoutDirection(Qt::RightToLeft);
} }
} else if (StrEquals(attr.name(), QStringLiteral("style"))) { } else if (str_equals(attr.name(), QStringLiteral("style"))) {
auto css = GetCSSFromStyle(attr.value().toString()); auto css = get_css_from_style(attr.value().toString());
for (auto it = css.begin(); it != css.end(); it++) { for (auto it = css.begin(); it != css.end(); it++) {
if (it.key() == QStringLiteral("line-height")) { if (it.key() == QStringLiteral("line-height")) {
@@ -423,7 +423,7 @@ QTextBlockFormat Html::ReadBlockFormat(const QXmlStreamAttributes &attributes)
return block_fmt; 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()) { if (!s->isEmpty()) {
s->append(QChar(' ')); s->append(QChar(' '));
@@ -432,7 +432,7 @@ void Html::AppendStringAutoSpace(QString *s, const QString &append)
s->append(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; QMap<QString, QStringList> map;
+16 -16
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef HTML_H #ifndef OAK_HTML_H
#define HTML_H #define OAK_HTML_H
#include <QTextDocument> #include <QTextDocument>
#include <QTextFragment> #include <QTextFragment>
@@ -45,39 +45,39 @@ namespace olive
*/ */
class Html { class Html {
public: 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: 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); const QTextFragment &fragment);
static void WriteCSSProperty(QString *style, const QString &key, static void write_css_property(QString *style, const QString &key,
const QStringList &value); const QStringList &value);
static void WriteCSSProperty(QString *style, const QString &key, static void write_css_property(QString *style, const QString &key,
const QString &value) 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 static QTextCharFormat
ReadCharFormat(const QXmlStreamAttributes &attributes); read_char_format(const QXmlStreamAttributes &attributes);
static QTextBlockFormat 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() JobTime::JobTime()
{ {
Acquire(); acquire();
} }
void JobTime::Acquire() void JobTime::acquire()
{ {
job_time_mutex.lock(); job_time_mutex.lock();
+4 -4
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef JOBTIME_H #ifndef OAK_JOBTIME_H
#define JOBTIME_H #define OAK_JOBTIME_H
#include <QDebug> #include <QDebug>
#include <stdint.h> #include <stdint.h>
@@ -29,7 +29,7 @@ class JobTime {
public: public:
JobTime(); JobTime();
void Acquire(); void acquire();
uint64_t value() const uint64_t value() const
{ {
@@ -76,4 +76,4 @@ QDebug operator<<(QDebug debug, const olive::JobTime &r);
Q_DECLARE_METATYPE(olive::JobTime) Q_DECLARE_METATYPE(olive::JobTime)
#endif // JOBTIME_H #endif // OAK_JOBTIME_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef LERP_H #ifndef OAK_LERP_H
#define LERP_H #define OAK_LERP_H
template <typename T> 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); 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 #ifndef OAK_MEMORYPOOL_H
#define MEMORYPOOL_H #define OAK_MEMORYPOOL_H
#include <memory> #include <memory>
#include <QApplication> #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 namespace olive
{ {
OCIO::BitDepth OCIOUtils::GetOCIOBitDepthFromPixelFormat(PixelFormat format) ocio::BitDepth OCIOUtils::get_ocio_bit_depth_from_pixel_format(PixelFormat format)
{ {
switch (format) { switch (format) {
case PixelFormat::U8: case PixelFormat::u8:
return OCIO::BIT_DEPTH_UINT8; return ocio::BIT_DEPTH_UINT8;
case PixelFormat::U10: case PixelFormat::u10:
return OCIO::BIT_DEPTH_UINT10; return ocio::BIT_DEPTH_UINT10;
case PixelFormat::U16: case PixelFormat::u16:
return OCIO::BIT_DEPTH_UINT16; return ocio::BIT_DEPTH_UINT16;
break; break;
case PixelFormat::F16: case PixelFormat::f16:
return OCIO::BIT_DEPTH_F16; return ocio::BIT_DEPTH_F16;
break; break;
case PixelFormat::F32: case PixelFormat::f32:
return OCIO::BIT_DEPTH_F32; return ocio::BIT_DEPTH_F32;
break; break;
case PixelFormat::INVALID: case PixelFormat::invalid:
case PixelFormat::COUNT: case PixelFormat::count:
break; break;
} }
return OCIO::BIT_DEPTH_UNKNOWN; return ocio::BIT_DEPTH_UNKNOWN;
} }
} }
+5 -5
View File
@@ -19,11 +19,11 @@
***/ ***/
#ifndef OCIOUTILS_H #ifndef OAK_OCIOUTILS_H
#define OCIOUTILS_H #define OAK_OCIOUTILS_H
#include <OpenColorIO/OpenColorIO.h> #include <OpenColorIO/OpenColorIO.h>
namespace OCIO = OCIO_NAMESPACE; namespace ocio = OCIO_NAMESPACE;
#include "render/videoparams.h" #include "render/videoparams.h"
@@ -32,9 +32,9 @@ namespace olive
class OCIOUtils { class OCIOUtils {
public: 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 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(), buf->set_pixels(OIIO::ROI(), buf->spec().format, frame->const_data(),
OIIO::AutoStride, frame->linesize_bytes()); 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(), buf->get_pixels(OIIO::ROI(), buf->spec().format, frame->data(),
OIIO::AutoStride, frame->linesize_bytes()); 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)); 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) { switch (type) {
case OIIO::TypeDesc::UNKNOWN: case OIIO::TypeDesc::UNKNOWN:
@@ -65,16 +65,16 @@ PixelFormat OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::BASETYPE type)
break; break;
case OIIO::TypeDesc::UINT8: case OIIO::TypeDesc::UINT8:
return PixelFormat::U8; return PixelFormat::u8;
case OIIO::TypeDesc::UINT16: case OIIO::TypeDesc::UINT16:
return PixelFormat::U16; return PixelFormat::u16;
case OIIO::TypeDesc::HALF: case OIIO::TypeDesc::HALF:
return PixelFormat::F16; return PixelFormat::f16;
case OIIO::TypeDesc::FLOAT: 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 #ifndef OAK_OIIOUTILS_H
#define OIIOUTILS_H #define OAK_OIIOUTILS_H
#include <OpenImageIO/imagebuf.h> #include <OpenImageIO/imagebuf.h>
#include <OpenImageIO/typedesc.h> #include <OpenImageIO/typedesc.h>
@@ -34,36 +34,36 @@ namespace olive
class OIIOUtils { class OIIOUtils {
public: public:
static OIIO::TypeDesc::BASETYPE static OIIO::TypeDesc::BASETYPE
GetOIIOBaseTypeFromFormat(PixelFormat format) get_oiio_base_type_from_format(PixelFormat format)
{ {
switch (format) { switch (format) {
case PixelFormat::U8: case PixelFormat::u8:
return OIIO::TypeDesc::UINT8; return OIIO::TypeDesc::UINT8;
case PixelFormat::U10: case PixelFormat::u10:
return OIIO::TypeDesc::UNKNOWN; return OIIO::TypeDesc::UNKNOWN;
case PixelFormat::U16: case PixelFormat::u16:
return OIIO::TypeDesc::UINT16; return OIIO::TypeDesc::UINT16;
case PixelFormat::F16: case PixelFormat::f16:
return OIIO::TypeDesc::HALF; return OIIO::TypeDesc::HALF;
case PixelFormat::F32: case PixelFormat::f32:
return OIIO::TypeDesc::FLOAT; return OIIO::TypeDesc::FLOAT;
case PixelFormat::INVALID: case PixelFormat::invalid:
case PixelFormat::COUNT: case PixelFormat::count:
break; break;
} }
return OIIO::TypeDesc::UNKNOWN; 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 #ifndef OAK_OTIOUTILS_H
#define OTIOUTILS_H #define OAK_OTIOUTILS_H
#ifdef USE_OTIO #ifdef USE_OTIO
#include <opentimelineio/version.h> #include <opentimelineio/version.h>
+3 -3
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef POWER_H #ifndef OAK_POWER_H
#define POWER_H #define OAK_POWER_H
#include <stdint.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 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) #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
return fm.width(s); return fm.width(s);
@@ -35,7 +35,7 @@ int QtUtils::QFontMetricsWidth(QFontMetrics fm, const QString &s)
#endif #endif
} }
QFrame *QtUtils::CreateHorizontalLine() QFrame *QtUtils::create_horizontal_line()
{ {
QFrame *horizontal_line = new QFrame(); QFrame *horizontal_line = new QFrame();
horizontal_line->setFrameShape(QFrame::HLine); horizontal_line->setFrameShape(QFrame::HLine);
@@ -43,14 +43,14 @@ QFrame *QtUtils::CreateHorizontalLine()
return horizontal_line; return horizontal_line;
} }
QFrame *QtUtils::CreateVerticalLine() QFrame *QtUtils::create_vertical_line()
{ {
QFrame *l = CreateHorizontalLine(); QFrame *l = create_horizontal_line();
l->setFrameShape(QFrame::VLine); l->setFrameShape(QFrame::VLine);
return l; 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, const QString &title, const QString &message,
QMessageBox::StandardButtons buttons) QMessageBox::StandardButtons buttons)
{ {
@@ -72,7 +72,7 @@ int QtUtils::MsgBox(QWidget *parent, QMessageBox::Icon icon,
return b.exec(); 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) #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
return info.created(); return info.created();
@@ -85,12 +85,12 @@ QDateTime QtUtils::GetCreationDate(const QFileInfo &info)
#endif #endif
} }
QString QtUtils::GetFormattedDateTime(const QDateTime &dt) QString QtUtils::get_formatted_date_time(const QDateTime &dt)
{ {
return dt.toString(Qt::TextDate); 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) int bounding_width)
{ {
QStringList list; QStringList list;
@@ -102,7 +102,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
QString this_line = lines.at(i); QString this_line = lines.at(i);
while (this_line.size() > 1 && 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 old_size = this_line.size();
int hard_break = -1; 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); const QChar &char_test = this_line.at(j);
if (char_test.isSpace() || char_test == '-') { 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) { bounding_width) {
if (!char_test.isSpace()) { if (!char_test.isSpace()) {
j++; j++;
@@ -128,7 +128,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
break; break;
} }
} else if (hard_break == -1 && } else if (hard_break == -1 &&
QFontMetricsWidth(fm, this_line.left(j)) < q_font_metrics_width(fm, this_line.left(j)) <
bounding_width) { bounding_width) {
// In case we can't find a better place to split, split at the earliest time the line // In case we can't find a better place to split, split at the earliest time the line
// goes under the width limit // goes under the width limit
@@ -157,7 +157,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
} }
Qt::KeyboardModifiers Qt::KeyboardModifiers
QtUtils::FlipControlAndShiftModifiers(Qt::KeyboardModifiers e) QtUtils::flip_control_and_shift_modifiers(Qt::KeyboardModifiers e)
{ {
if (e & Qt::ControlModifier & Qt::ShiftModifier) { if (e & Qt::ControlModifier & Qt::ShiftModifier) {
return e; return e;
@@ -174,7 +174,7 @@ QtUtils::FlipControlAndShiftModifiers(Qt::KeyboardModifiers e)
return 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++) { for (int i = 0; i < cb->count(); i++) {
if (cb->itemData(i).toInt() == data) { 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++) { for (int i = 0; i < cb->count(); i++) {
if (cb->itemData(i).toString() == data) { 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; QColor c;
@@ -210,9 +210,9 @@ QColor QtUtils::toQColor(const core::Color &i)
namespace core 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) uint qHash(const core::TimeRange &r, uint seed)
+19 -19
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef QTVERSIONABSTRACTION_H #ifndef OAK_QTVERSIONABSTRACTION_H
#define QTVERSIONABSTRACTION_H #define OAK_QTVERSIONABSTRACTION_H
#include <olive/core/core.h> #include <olive/core/core.h>
#include <QComboBox> #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 * latter was only introduced in 5.11+. This function wraps the latter for 5.11+ and the former for
* earlier. * 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, const QString &title, const QString &message,
QMessageBox::StandardButtons buttons = QMessageBox::Ok); 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); int bounding_width);
static Qt::KeyboardModifiers static Qt::KeyboardModifiers
FlipControlAndShiftModifiers(Qt::KeyboardModifiers e); flip_control_and_shift_modifiers(Qt::KeyboardModifiers e);
static void SetComboBoxData(QComboBox *cb, int data); static void set_combo_box_data(QComboBox *cb, int data);
static void SetComboBoxData(QComboBox *cb, const QString &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(); QObject *t = child->parent();
@@ -79,12 +79,12 @@ public:
return nullptr; 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 * @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); return reinterpret_cast<quintptr>(ptr);
} }
@@ -92,7 +92,7 @@ public:
/** /**
* @brief Convert a NodeParam value to a pointer of any kind * @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>()); return reinterpret_cast<T *>(ptr.value<quintptr>());
} }
@@ -101,18 +101,18 @@ public:
namespace core 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); 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::Color)
Q_DECLARE_METATYPE(olive::core::TimeRange) Q_DECLARE_METATYPE(olive::core::TimeRange)
Q_DECLARE_METATYPE(olive::core::Bezier) Q_DECLARE_METATYPE(olive::core::Bezier)
Q_DECLARE_METATYPE(olive::core::AudioParams) Q_DECLARE_METATYPE(olive::core::AudioParams)
Q_DECLARE_METATYPE(olive::core::SampleBuffer) Q_DECLARE_METATYPE(olive::core::SampleBuffer)
#endif // QTVERSIONABSTRACTION_H #endif // OAK_QTVERSIONABSTRACTION_H
+4 -4
View File
@@ -19,12 +19,12 @@
***/ ***/
#ifndef RANGE_H #ifndef OAK_RANGE_H
#define 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); return (a >= b - range && a <= b + range);
} }
#endif // RANGE_H #endif // OAK_RANGE_H
+2 -2
View File
@@ -28,7 +28,7 @@
namespace olive 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; QString s;
@@ -86,7 +86,7 @@ double GetFloatRatioFromUser(QWidget *parent, const QString &title, bool *ok_in)
QCoreApplication::translate( QCoreApplication::translate(
"RatioDialog", "RatioDialog",
"Failed to parse \"%1\" into an aspect ratio. Please format a " "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), .arg(s),
QMessageBox::Ok); QMessageBox::Ok);
} }
+4 -4
View File
@@ -19,17 +19,17 @@
***/ ***/
#ifndef RATIODIALOG_H #ifndef OAK_RATIODIALOG_H
#define RATIODIALOG_H #define OAK_RATIODIALOG_H
#include <QInputDialog> #include <QInputDialog>
namespace olive namespace olive
{ {
double GetFloatRatioFromUser(QWidget *parent, const QString &title, double get_float_ratio_from_user(QWidget *parent, const QString &title,
bool *ok_in); 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef THREADSAFEMAP_H #ifndef OAK_THREADSAFEMAP_H
#define THREADSAFEMAP_H #define OAK_THREADSAFEMAP_H
#include <QMap> #include <QMap>
#include <QMutex> #include <QMutex>
@@ -39,4 +39,4 @@ private:
QMap<K, V> map_; 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TOHEX_H #ifndef OAK_TOHEX_H
#define TOHEX_H #define OAK_TOHEX_H
#include <QString> #include <QString>
#include <QtGlobal> #include <QtGlobal>
@@ -27,11 +27,11 @@
namespace olive namespace olive
{ {
inline QString ToHex(quint64 t) inline QString to_hex(quint64 t)
{ {
return QStringLiteral("%1").arg(t, 0, 16); 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 #ifndef OAK_UTIL_H
#define UTIL_H #define OAK_UTIL_H
template <typename T> inline T mid(T a, T b) template <typename T> inline T mid(T a, T b)
{ {
return (a + b) * 0.5; return (a + b) * 0.5;
} }
#endif // UTIL_H #endif // OAK_UTIL_H
+2 -2
View File
@@ -27,13 +27,13 @@
namespace olive namespace olive
{ {
bool XMLReadNextStartElement(QXmlStreamReader *reader, CancelAtom *cancel_atom) bool xml_read_next_start_element(QXmlStreamReader *reader, CancelAtom *cancel_atom)
{ {
QXmlStreamReader::TokenType token; QXmlStreamReader::TokenType token;
while ((token = reader->readNext()) != QXmlStreamReader::Invalid && while ((token = reader->readNext()) != QXmlStreamReader::Invalid &&
token != QXmlStreamReader::EndDocument && token != QXmlStreamReader::EndDocument &&
(!cancel_atom || !cancel_atom->IsCancelled())) { (!cancel_atom || !cancel_atom->is_cancelled())) {
if (reader->isEndElement()) { if (reader->isEndElement()) {
return false; return false;
} else if (reader->isStartElement()) { } else if (reader->isStartElement()) {
+4 -4
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef XMLREADLOOP_H #ifndef OAK_XMLREADLOOP_H
#define XMLREADLOOP_H #define OAK_XMLREADLOOP_H
#include <QXmlStreamReader> #include <QXmlStreamReader>
@@ -48,9 +48,9 @@ class NodeGroup;
* *
* See also: https://stackoverflow.com/questions/46346450/qt-qxmlstreamreader-always-returns-premature-end-of-document-error * 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); CancelAtom *cancel_atom = nullptr);
} }
#endif // XMLREADLOOP_H #endif // OAK_XMLREADLOOP_H
+182 -182
View File
@@ -42,239 +42,239 @@
namespace olive namespace olive
{ {
Config Config::current_config_; Config Config::current_config;
Config::Config() Config::Config()
{ {
SetDefaults(); set_defaults();
} }
void Config::SetEntryInternal(const QString &key, NodeValue::Type type, void Config::set_entry_internal(const QString &key, NodeValue::Type type,
const QVariant &data) const QVariant &data)
{ {
config_map_[key] = { type, data }; config_map_[key] = { type, data };
} }
QString Config::GetConfigFilePath() QString Config::get_config_file_path()
{ {
return QDir(FileFunctions::GetConfigurationLocation()) return QDir(FileFunctions::get_configuration_location())
.filePath(QStringLiteral("config.xml")); .filePath(QStringLiteral("config.xml"));
} }
Config &Config::Current() Config &Config::current()
{ {
return current_config_; return current_config;
} }
void Config::SetDefaults() void Config::set_defaults()
{ {
config_map_.clear(); config_map_.clear();
SetEntryInternal(QStringLiteral("Style"), NodeValue::kText, set_entry_internal(QStringLiteral("Style"), NodeValue::k_text,
StyleManager::kDefaultStyle); StyleManager::k_default_style);
SetEntryInternal(QStringLiteral("TimecodeDisplay"), NodeValue::kInt, set_entry_internal(QStringLiteral("TimecodeDisplay"), NodeValue::k_int,
Timecode::kTimecodeDropFrame); Timecode::k_timecode_drop_frame);
SetEntryInternal(QStringLiteral("DefaultStillLength"), NodeValue::kRational, set_entry_internal(QStringLiteral("DefaultStillLength"), NodeValue::k_rational,
QVariant::fromValue(rational(2))); QVariant::fromValue(Rational(2)));
SetEntryInternal(QStringLiteral("HoverFocus"), NodeValue::kBoolean, false); set_entry_internal(QStringLiteral("HoverFocus"), NodeValue::k_boolean, false);
SetEntryInternal(QStringLiteral("AudioScrubbing"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("AudioScrubbing"), NodeValue::k_boolean,
true); true);
SetEntryInternal(QStringLiteral("AutorecoveryEnabled"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("AutorecoveryEnabled"), NodeValue::k_boolean,
true); true);
SetEntryInternal(QStringLiteral("AutorecoveryInterval"), NodeValue::kInt, set_entry_internal(QStringLiteral("AutorecoveryInterval"), NodeValue::k_int,
1); 1);
SetEntryInternal(QStringLiteral("AutorecoveryMaximum"), NodeValue::kInt, set_entry_internal(QStringLiteral("AutorecoveryMaximum"), NodeValue::k_int,
20); 20);
SetEntryInternal(QStringLiteral("DiskCacheSaveInterval"), NodeValue::kInt, set_entry_internal(QStringLiteral("DiskCacheSaveInterval"), NodeValue::k_int,
10000); 10000);
SetEntryInternal(QStringLiteral("Language"), NodeValue::kText, QString()); set_entry_internal(QStringLiteral("Language"), NodeValue::k_text, QString());
SetEntryInternal(QStringLiteral("ScrollZooms"), NodeValue::kBoolean, false); set_entry_internal(QStringLiteral("ScrollZooms"), NodeValue::k_boolean, false);
SetEntryInternal(QStringLiteral("EnableSeekToImport"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("EnableSeekToImport"), NodeValue::k_boolean,
false); false);
SetEntryInternal(QStringLiteral("EditToolAlsoSeeks"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("EditToolAlsoSeeks"), NodeValue::k_boolean,
false); false);
SetEntryInternal(QStringLiteral("EditToolSelectsLinks"), set_entry_internal(QStringLiteral("EditToolSelectsLinks"),
NodeValue::kBoolean, false); NodeValue::k_boolean, false);
SetEntryInternal(QStringLiteral("EnableDragFilesToTimeline"), set_entry_internal(QStringLiteral("EnableDragFilesToTimeline"),
NodeValue::kBoolean, true); NodeValue::k_boolean, true);
SetEntryInternal(QStringLiteral("InvertTimelineScrollAxes"), set_entry_internal(QStringLiteral("InvertTimelineScrollAxes"),
NodeValue::kBoolean, true); NodeValue::k_boolean, true);
SetEntryInternal(QStringLiteral("SelectAlsoSeeks"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("SelectAlsoSeeks"), NodeValue::k_boolean,
false); false);
SetEntryInternal(QStringLiteral("PasteSeeks"), NodeValue::kBoolean, true); set_entry_internal(QStringLiteral("PasteSeeks"), NodeValue::k_boolean, true);
SetEntryInternal(QStringLiteral("SeekAlsoSelects"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("SeekAlsoSelects"), NodeValue::k_boolean,
false); false);
SetEntryInternal(QStringLiteral("SetNameWithMarker"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("SetNameWithMarker"), NodeValue::k_boolean,
false); false);
SetEntryInternal(QStringLiteral("AutoSeekToBeginning"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("AutoSeekToBeginning"), NodeValue::k_boolean,
true); true);
SetEntryInternal(QStringLiteral("DropFileOnMediaToReplace"), set_entry_internal(QStringLiteral("DropFileOnMediaToReplace"),
NodeValue::kBoolean, false); NodeValue::k_boolean, false);
SetEntryInternal(QStringLiteral("AddDefaultEffectsToClips"), set_entry_internal(QStringLiteral("AddDefaultEffectsToClips"),
NodeValue::kBoolean, true); NodeValue::k_boolean, true);
SetEntryInternal(QStringLiteral("AutoscaleByDefault"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("AutoscaleByDefault"), NodeValue::k_boolean,
false); false);
SetEntryInternal(QStringLiteral("Autoscroll"), NodeValue::kInt, set_entry_internal(QStringLiteral("Autoscroll"), NodeValue::k_int,
AutoScroll::kPage); AutoScroll::k_page);
SetEntryInternal(QStringLiteral("AutoSelectDivider"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("AutoSelectDivider"), NodeValue::k_boolean,
true); true);
SetEntryInternal(QStringLiteral("SetNameWithMarker"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("SetNameWithMarker"), NodeValue::k_boolean,
false); false);
SetEntryInternal(QStringLiteral("RectifiedWaveforms"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("RectifiedWaveforms"), NodeValue::k_boolean,
true); true);
SetEntryInternal(QStringLiteral("DropWithoutSequenceBehavior"), set_entry_internal(QStringLiteral("DropWithoutSequenceBehavior"),
NodeValue::kInt, ImportTool::kDWSAsk); NodeValue::k_int, ImportTool::k_dws_ask);
SetEntryInternal(QStringLiteral("Loop"), NodeValue::kBoolean, false); set_entry_internal(QStringLiteral("Loop"), NodeValue::k_boolean, false);
SetEntryInternal(QStringLiteral("SplitClipsCopyNodes"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("SplitClipsCopyNodes"), NodeValue::k_boolean,
true); true);
SetEntryInternal(QStringLiteral("UseGradients"), NodeValue::kBoolean, true); set_entry_internal(QStringLiteral("UseGradients"), NodeValue::k_boolean, true);
SetEntryInternal(QStringLiteral("AutoMergeTracks"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("AutoMergeTracks"), NodeValue::k_boolean,
true); true);
SetEntryInternal(QStringLiteral("UseSliderLadders"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("UseSliderLadders"), NodeValue::k_boolean,
true); true);
SetEntryInternal(QStringLiteral("ShowWelcomeDialog"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("ShowWelcomeDialog"), NodeValue::k_boolean,
true); true);
SetEntryInternal(QStringLiteral("ShowClipWhileDragging"), set_entry_internal(QStringLiteral("ShowClipWhileDragging"),
NodeValue::kBoolean, true); NodeValue::k_boolean, true);
SetEntryInternal(QStringLiteral("StopPlaybackOnLastFrame"), set_entry_internal(QStringLiteral("StopPlaybackOnLastFrame"),
NodeValue::kBoolean, false); NodeValue::k_boolean, false);
SetEntryInternal(QStringLiteral("UseLegacyColorInInputTab"), set_entry_internal(QStringLiteral("UseLegacyColorInInputTab"),
NodeValue::kBoolean, false); NodeValue::k_boolean, false);
SetEntryInternal(QStringLiteral("ReassocLinToNonLin"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("ReassocLinToNonLin"), NodeValue::k_boolean,
false); false);
SetEntryInternal(QStringLiteral("PreviewNonFloatDontAskAgain"), set_entry_internal(QStringLiteral("PreviewNonFloatDontAskAgain"),
NodeValue::kBoolean, false); NodeValue::k_boolean, false);
SetEntryInternal(QStringLiteral("UseGLFinish"), NodeValue::kBoolean, false); set_entry_internal(QStringLiteral("UseGLFinish"), NodeValue::k_boolean, false);
SetEntryInternal(QStringLiteral("GraphicsBackend"), NodeValue::kText, set_entry_internal(QStringLiteral("GraphicsBackend"), NodeValue::k_text,
QStringLiteral("opengl")); QStringLiteral("opengl"));
SetEntryInternal(QStringLiteral("TimelineThumbnailMode"), NodeValue::kInt, set_entry_internal(QStringLiteral("TimelineThumbnailMode"), NodeValue::k_int,
Timeline::kThumbnailInOut); Timeline::k_thumbnail_in_out);
SetEntryInternal(QStringLiteral("TimelineWaveformMode"), NodeValue::kInt, set_entry_internal(QStringLiteral("TimelineWaveformMode"), NodeValue::k_int,
Timeline::kWaveformsEnabled); Timeline::k_waveforms_enabled);
SetEntryInternal( set_entry_internal(
QStringLiteral("DefaultVideoTransition"), NodeValue::kText, QStringLiteral("DefaultVideoTransition"), NodeValue::k_text,
QStringLiteral("org.olivevideoeditor.Olive.crossdissolve")); QStringLiteral("org.olivevideoeditor.Olive.crossdissolve"));
SetEntryInternal( set_entry_internal(
QStringLiteral("DefaultAudioTransition"), NodeValue::kText, QStringLiteral("DefaultAudioTransition"), NodeValue::k_text,
QStringLiteral("org.olivevideoeditor.Olive.crossdissolve")); QStringLiteral("org.olivevideoeditor.Olive.crossdissolve"));
SetEntryInternal(QStringLiteral("DefaultTransitionLength"), set_entry_internal(QStringLiteral("DefaultTransitionLength"),
NodeValue::kRational, QVariant::fromValue(rational(1))); NodeValue::k_rational, QVariant::fromValue(Rational(1)));
SetEntryInternal(QStringLiteral("DefaultSubtitleSize"), NodeValue::kInt, set_entry_internal(QStringLiteral("DefaultSubtitleSize"), NodeValue::k_int,
48); 48);
SetEntryInternal(QStringLiteral("DefaultSubtitleFamily"), NodeValue::kText, set_entry_internal(QStringLiteral("DefaultSubtitleFamily"), NodeValue::k_text,
QString()); QString());
SetEntryInternal(QStringLiteral("DefaultSubtitleWeight"), NodeValue::kInt, set_entry_internal(QStringLiteral("DefaultSubtitleWeight"), NodeValue::k_int,
QFont::Bold); QFont::Bold);
SetEntryInternal(QStringLiteral("AntialiasSubtitles"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("AntialiasSubtitles"), NodeValue::k_boolean,
true); true);
SetEntryInternal(QStringLiteral("AutoCacheDelay"), NodeValue::kInt, 1000); set_entry_internal(QStringLiteral("AutoCacheDelay"), NodeValue::k_int, 1000);
SetEntryInternal(QStringLiteral("CatColor0"), NodeValue::kInt, set_entry_internal(QStringLiteral("CatColor0"), NodeValue::k_int,
ColorCoding::kRed); ColorCoding::k_red);
SetEntryInternal(QStringLiteral("CatColor1"), NodeValue::kInt, set_entry_internal(QStringLiteral("CatColor1"), NodeValue::k_int,
ColorCoding::kMaroon); ColorCoding::k_maroon);
SetEntryInternal(QStringLiteral("CatColor2"), NodeValue::kInt, set_entry_internal(QStringLiteral("CatColor2"), NodeValue::k_int,
ColorCoding::kOrange); ColorCoding::k_orange);
SetEntryInternal(QStringLiteral("CatColor3"), NodeValue::kInt, set_entry_internal(QStringLiteral("CatColor3"), NodeValue::k_int,
ColorCoding::kBrown); ColorCoding::k_brown);
SetEntryInternal(QStringLiteral("CatColor4"), NodeValue::kInt, set_entry_internal(QStringLiteral("CatColor4"), NodeValue::k_int,
ColorCoding::kYellow); ColorCoding::k_yellow);
SetEntryInternal(QStringLiteral("CatColor5"), NodeValue::kInt, set_entry_internal(QStringLiteral("CatColor5"), NodeValue::k_int,
ColorCoding::kOlive); ColorCoding::k_olive);
SetEntryInternal(QStringLiteral("CatColor6"), NodeValue::kInt, set_entry_internal(QStringLiteral("CatColor6"), NodeValue::k_int,
ColorCoding::kLime); ColorCoding::k_lime);
SetEntryInternal(QStringLiteral("CatColor7"), NodeValue::kInt, set_entry_internal(QStringLiteral("CatColor7"), NodeValue::k_int,
ColorCoding::kGreen); ColorCoding::k_green);
SetEntryInternal(QStringLiteral("CatColor8"), NodeValue::kInt, set_entry_internal(QStringLiteral("CatColor8"), NodeValue::k_int,
ColorCoding::kCyan); ColorCoding::k_cyan);
SetEntryInternal(QStringLiteral("CatColor9"), NodeValue::kInt, set_entry_internal(QStringLiteral("CatColor9"), NodeValue::k_int,
ColorCoding::kTeal); ColorCoding::k_teal);
SetEntryInternal(QStringLiteral("CatColor10"), NodeValue::kInt, set_entry_internal(QStringLiteral("CatColor10"), NodeValue::k_int,
ColorCoding::kBlue); ColorCoding::k_blue);
SetEntryInternal(QStringLiteral("CatColor11"), NodeValue::kInt, set_entry_internal(QStringLiteral("CatColor11"), NodeValue::k_int,
ColorCoding::kNavy); ColorCoding::k_navy);
SetEntryInternal(QStringLiteral("AudioOutput"), NodeValue::kText, set_entry_internal(QStringLiteral("AudioOutput"), NodeValue::k_text,
QString()); QString());
SetEntryInternal(QStringLiteral("AudioInput"), NodeValue::kText, QString()); set_entry_internal(QStringLiteral("AudioInput"), NodeValue::k_text, QString());
SetEntryInternal(QStringLiteral("AudioOutputSampleRate"), NodeValue::kInt, set_entry_internal(QStringLiteral("AudioOutputSampleRate"), NodeValue::k_int,
48000); 48000);
SetEntryInternal(QStringLiteral("AudioOutputChannelLayout"), set_entry_internal(QStringLiteral("AudioOutputChannelLayout"),
NodeValue::kInt, NodeValue::k_int,
QVariant::fromValue(static_cast<int64_t>(kChannelLayoutStereo))); QVariant::fromValue(static_cast<int64_t>(k_channel_layout_stereo)));
SetEntryInternal( set_entry_internal(
QStringLiteral("AudioOutputSampleFormat"), NodeValue::kText, QStringLiteral("AudioOutputSampleFormat"), NodeValue::k_text,
QString::fromStdString(SampleFormat(SampleFormat::S16).to_string())); QString::fromStdString(SampleFormat(SampleFormat::s16).to_string()));
SetEntryInternal(QStringLiteral("AudioRecordingFormat"), NodeValue::kInt, set_entry_internal(QStringLiteral("AudioRecordingFormat"), NodeValue::k_int,
ExportFormat::kFormatWAV); ExportFormat::k_format_wav);
SetEntryInternal(QStringLiteral("AudioRecordingCodec"), NodeValue::kInt, set_entry_internal(QStringLiteral("AudioRecordingCodec"), NodeValue::k_int,
ExportCodec::kCodecPCM); ExportCodec::k_codec_pcm);
SetEntryInternal(QStringLiteral("AudioRecordingSampleRate"), set_entry_internal(QStringLiteral("AudioRecordingSampleRate"),
NodeValue::kInt, 48000); NodeValue::k_int, 48000);
SetEntryInternal(QStringLiteral("AudioRecordingChannelLayout"), set_entry_internal(QStringLiteral("AudioRecordingChannelLayout"),
NodeValue::kInt, NodeValue::k_int,
QVariant::fromValue(static_cast<int64_t>(kChannelLayoutStereo))); QVariant::fromValue(static_cast<int64_t>(k_channel_layout_stereo)));
SetEntryInternal( set_entry_internal(
QStringLiteral("AudioRecordingSampleFormat"), NodeValue::kText, QStringLiteral("AudioRecordingSampleFormat"), NodeValue::k_text,
QString::fromStdString(SampleFormat(SampleFormat::S16).to_string())); QString::fromStdString(SampleFormat(SampleFormat::s16).to_string()));
SetEntryInternal(QStringLiteral("AudioRecordingBitRate"), NodeValue::kInt, set_entry_internal(QStringLiteral("AudioRecordingBitRate"), NodeValue::k_int,
320); 320);
SetEntryInternal(QStringLiteral("DiskCacheBehind"), NodeValue::kRational, set_entry_internal(QStringLiteral("DiskCacheBehind"), NodeValue::k_rational,
QVariant::fromValue(rational(0))); QVariant::fromValue(Rational(0)));
SetEntryInternal(QStringLiteral("DiskCacheAhead"), NodeValue::kRational, set_entry_internal(QStringLiteral("DiskCacheAhead"), NodeValue::k_rational,
QVariant::fromValue(rational(60))); QVariant::fromValue(Rational(60)));
SetEntryInternal(QStringLiteral("ProxyWidth"), NodeValue::kInt, 1280); set_entry_internal(QStringLiteral("ProxyWidth"), NodeValue::k_int, 1280);
SetEntryInternal(QStringLiteral("ProxyHeight"), NodeValue::kInt, 720); set_entry_internal(QStringLiteral("ProxyHeight"), NodeValue::k_int, 720);
SetEntryInternal(QStringLiteral("ProxyCRF"), NodeValue::kInt, 23); set_entry_internal(QStringLiteral("ProxyCRF"), NodeValue::k_int, 23);
SetEntryInternal(QStringLiteral("ProxyPreset"), NodeValue::kText, set_entry_internal(QStringLiteral("ProxyPreset"), NodeValue::k_text,
QStringLiteral("veryfast")); QStringLiteral("veryfast"));
SetEntryInternal(QStringLiteral("ProxyIncludeAudio"), NodeValue::kBoolean, set_entry_internal(QStringLiteral("ProxyIncludeAudio"), NodeValue::k_boolean,
true); true);
SetEntryInternal(QStringLiteral("FFmpegPath"), NodeValue::kText, set_entry_internal(QStringLiteral("FFmpegPath"), NodeValue::k_text,
QString()); QString());
SetEntryInternal(QStringLiteral("LUTLibraryPaths"), NodeValue::kText, set_entry_internal(QStringLiteral("LUTLibraryPaths"), NodeValue::k_text,
QString()); QString());
SetEntryInternal(QStringLiteral("DefaultSequenceWidth"), NodeValue::kInt, set_entry_internal(QStringLiteral("DefaultSequenceWidth"), NodeValue::k_int,
1920); 1920);
SetEntryInternal(QStringLiteral("DefaultSequenceHeight"), NodeValue::kInt, set_entry_internal(QStringLiteral("DefaultSequenceHeight"), NodeValue::k_int,
1080); 1080);
SetEntryInternal(QStringLiteral("DefaultSequencePixelAspect"), set_entry_internal(QStringLiteral("DefaultSequencePixelAspect"),
NodeValue::kRational, QVariant::fromValue(rational(1))); NodeValue::k_rational, QVariant::fromValue(Rational(1)));
SetEntryInternal(QStringLiteral("DefaultSequenceFrameRate"), set_entry_internal(QStringLiteral("DefaultSequenceFrameRate"),
NodeValue::kRational, NodeValue::k_rational,
QVariant::fromValue(rational(1001, 30000))); QVariant::fromValue(Rational(1001, 30000)));
SetEntryInternal(QStringLiteral("DefaultSequenceInterlacing"), set_entry_internal(QStringLiteral("DefaultSequenceInterlacing"),
NodeValue::kInt, VideoParams::kInterlaceNone); NodeValue::k_int, VideoParams::k_interlace_none);
SetEntryInternal(QStringLiteral("DefaultSequenceAutoCache2"), set_entry_internal(QStringLiteral("DefaultSequenceAutoCache2"),
NodeValue::kBoolean, true); NodeValue::k_boolean, true);
SetEntryInternal(QStringLiteral("DefaultSequenceAudioFrequency"), set_entry_internal(QStringLiteral("DefaultSequenceAudioFrequency"),
NodeValue::kInt, 48000); NodeValue::k_int, 48000);
SetEntryInternal( set_entry_internal(
QStringLiteral("DefaultSequenceAudioLayout"), NodeValue::kInt, QStringLiteral("DefaultSequenceAudioLayout"), NodeValue::k_int,
QVariant::fromValue(static_cast<int64_t>(kChannelLayoutStereo))); QVariant::fromValue(static_cast<int64_t>(k_channel_layout_stereo)));
// Online/offline settings // Online/offline settings
SetEntryInternal(QStringLiteral("OnlinePixelFormat"), NodeValue::kInt, set_entry_internal(QStringLiteral("OnlinePixelFormat"), NodeValue::k_int,
PixelFormat::F32); PixelFormat::f32);
SetEntryInternal(QStringLiteral("OfflinePixelFormat"), NodeValue::kInt, set_entry_internal(QStringLiteral("OfflinePixelFormat"), NodeValue::k_int,
PixelFormat::F32); PixelFormat::f32);
SetEntryInternal(QStringLiteral("MarkerColor"), NodeValue::kInt, set_entry_internal(QStringLiteral("MarkerColor"), NodeValue::k_int,
ColorCoding::kLime); ColorCoding::k_lime);
} }
void Config::Load() void Config::load()
{ {
QFile config_file(GetConfigFilePath()); QFile config_file(get_config_file_path());
if (!config_file.exists()) { if (!config_file.exists()) {
return; return;
@@ -287,15 +287,15 @@ void Config::Load()
} }
// Reset to defaults // Reset to defaults
current_config_.SetDefaults(); current_config.set_defaults();
QXmlStreamReader reader(&config_file); QXmlStreamReader reader(&config_file);
QString config_version; QString config_version;
while (XMLReadNextStartElement(&reader)) { while (xml_read_next_start_element(&reader)) {
if (reader.name() == QStringLiteral("Configuration")) { if (reader.name() == QStringLiteral("Configuration")) {
while (XMLReadNextStartElement(&reader)) { while (xml_read_next_start_element(&reader)) {
QString key = reader.name().toString(); QString key = reader.name().toString();
QString value = reader.readElementText(); QString value = reader.readElementText();
@@ -309,20 +309,20 @@ void Config::Load()
} else if (key == QStringLiteral("DefaultSequenceFrameRate") && } else if (key == QStringLiteral("DefaultSequenceFrameRate") &&
!config_version.contains('.')) { !config_version.contains('.')) {
// 0.1.x stored this value as a float while we now use rationals, we'll use a heuristic to find the closest // 0.1.x stored this value as a float while we now use rationals, we'll use a heuristic to find the closest
// supported rational // supported Rational
qDebug() << " CONFIG: Finding closest match to" << value; qDebug() << " CONFIG: Finding closest match to" << value;
double config_fr = value.toDouble(); double config_fr = value.toDouble();
const QVector<rational> &supported_frame_rates = const QVector<Rational> &supported_frame_rates =
VideoParams::kSupportedFrameRates; VideoParams::k_supported_frame_rates;
rational match = supported_frame_rates.first(); Rational match = supported_frame_rates.first();
double match_diff = qAbs(match.toDouble() - config_fr); double match_diff = qAbs(match.to_double() - config_fr);
for (int i = 1; i < supported_frame_rates.size(); i++) { for (int i = 1; i < supported_frame_rates.size(); i++) {
double diff = qAbs( double diff = qAbs(
supported_frame_rates.at(i).toDouble() - config_fr); supported_frame_rates.at(i).to_double() - config_fr);
if (diff < match_diff) { if (diff < match_diff) {
match = supported_frame_rates.at(i); match = supported_frame_rates.at(i);
@@ -331,12 +331,12 @@ void Config::Load()
} }
qDebug() qDebug()
<< " CONFIG: Closest match was" << match.toDouble(); << " CONFIG: Closest match was" << match.to_double();
current_config_[key] = QVariant::fromValue(match.flipped()); current_config[key] = QVariant::fromValue(match.flipped());
} else { } else {
current_config_[key] = NodeValue::StringToValue( current_config[key] = NodeValue::string_to_value(
current_config_.GetConfigEntryType(key), value, false); current_config.get_config_entry_type(key), value, false);
} }
} }
@@ -361,17 +361,17 @@ void Config::Load()
"use defaults.\n\n%1") "use defaults.\n\n%1")
.arg(reader.errorString()), .arg(reader.errorString()),
QMessageBox::Ok); QMessageBox::Ok);
current_config_.SetDefaults(); current_config.set_defaults();
} }
config_file.close(); config_file.close();
} }
void Config::Save() void Config::save()
{ {
QString real_filename = GetConfigFilePath(); QString real_filename = get_config_file_path();
QString temp_filename = QString temp_filename =
FileFunctions::GetSafeTemporaryFilename(real_filename); FileFunctions::get_safe_temporary_filename(real_filename);
QFile config_file(temp_filename); QFile config_file(temp_filename);
@@ -398,14 +398,14 @@ void Config::Save()
writer.writeTextElement( writer.writeTextElement(
"Version", QCoreApplication::applicationVersion().split('-').first()); "Version", QCoreApplication::applicationVersion().split('-').first());
QMapIterator<QString, ConfigEntry> iterator(current_config_.config_map_); QMapIterator<QString, ConfigEntry> iterator(current_config.config_map_);
while (iterator.hasNext()) { while (iterator.hasNext()) {
iterator.next(); iterator.next();
QString value = NodeValue::ValueToString(iterator.value().type, QString value = NodeValue::value_to_string(iterator.value().type,
iterator.value().data, false); iterator.value().data, false);
if (iterator.value().type == NodeValue::kNone) { if (iterator.value().type == NodeValue::k_none) {
qWarning() << "Config key" << iterator.key() qWarning() << "Config key" << iterator.key()
<< "had null type and was discarded"; << "had null type and was discarded";
} else { } else {
@@ -419,7 +419,7 @@ void Config::Save()
config_file.close(); config_file.close();
if (!FileFunctions::RenameFileAllowOverwrite(temp_filename, if (!FileFunctions::rename_file_allow_overwrite(temp_filename,
real_filename)) { real_filename)) {
qWarning() qWarning()
<< QStringLiteral( << QStringLiteral(
@@ -438,7 +438,7 @@ QVariant &Config::operator[](const QString &key)
return config_map_[key].data; return config_map_[key].data;
} }
NodeValue::Type Config::GetConfigEntryType(const QString &key) const NodeValue::Type Config::get_config_entry_type(const QString &key) const
{ {
return config_map_[key].type; return config_map_[key].type;
} }
+13 -13
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef CONFIG_H #ifndef OAK_CONFIG_H
#define CONFIG_H #define OAK_CONFIG_H
#include <QMap> #include <QMap>
#include <QString> #include <QString>
@@ -31,24 +31,24 @@
namespace olive namespace olive
{ {
#define OLIVE_CONFIG(x) Config::Current()[QStringLiteral(x)] #define OAK_CONFIG(x) Config::current()[QStringLiteral(x)]
#define OLIVE_CONFIG_STR(x) Config::Current()[x] #define OAK_CONFIG_STR(x) Config::current()[x]
class Config { class Config {
public: public:
static Config &Current(); static Config &current();
void SetDefaults(); void set_defaults();
static void Load(); static void load();
static void Save(); static void save();
QVariant operator[](const QString &) const; QVariant operator[](const QString &) const;
QVariant &operator[](const QString &); QVariant &operator[](const QString &);
NodeValue::Type GetConfigEntryType(const QString &key) const; NodeValue::Type get_config_entry_type(const QString &key) const;
private: private:
Config(); Config();
@@ -58,16 +58,16 @@ private:
QVariant data; QVariant data;
}; };
void SetEntryInternal(const QString &key, NodeValue::Type type, void set_entry_internal(const QString &key, NodeValue::Type type,
const QVariant &data); const QVariant &data);
QMap<QString, ConfigEntry> config_map_; QMap<QString, ConfigEntry> config_map_;
static Config current_config_; static Config current_config;
static QString GetConfigFilePath(); static QString get_config_file_path();
}; };
} }
#endif // CONFIG_H #endif // OAK_CONFIG_H
+294 -294
View File
File diff suppressed because it is too large Load Diff
+97 -97
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef CORE_H #ifndef OAK_CORE_H
#define CORE_H #define OAK_CORE_H
#include <olive/core/core.h> #include <olive/core/core.h>
#include <QFileInfoList> #include <QFileInfoList>
@@ -42,7 +42,7 @@ namespace olive
class MainWindow; class MainWindow;
/** /**
* @brief The main central Olive application instance * @brief The main central Olive application instance_
* *
* This runs both in GUI and CLI modes (and handles what to init based on that). * This runs both in GUI and CLI modes (and handles what to init based on that).
* It also contains various global functions/variables for use throughout Olive. * It also contains various global functions/variables for use throughout Olive.
@@ -57,7 +57,7 @@ public:
public: public:
CoreParams(); CoreParams();
enum RunMode { kRunNormal, kHeadlessExport, kHeadlessPreCache }; enum RunMode { k_run_normal, k_headless_export, k_headless_pre_cache };
bool fullscreen() const bool fullscreen() const
{ {
@@ -135,9 +135,9 @@ public:
*/ */
static Core *instance(); static Core *instance();
static QString FootageFileDialogFilter(); static QString footage_file_dialog_filter();
static QStringList AllowedFootageExtensions(); static QStringList allowed_footage_extensions();
static bool IsFootageExtensionAllowed(const QString &path); static bool is_footage_extension_allowed(const QString &path);
const CoreParams &core_params() const const CoreParams &core_params() const
{ {
@@ -149,17 +149,17 @@ public:
* *
* Main application launcher. Parses command line arguments and constructs main window (if entering a GUI mode). * Main application launcher. Parses command line arguments and constructs main window (if entering a GUI mode).
*/ */
void Start(); void start();
/** /**
* @brief Stop Olive Core * @brief Stop Olive Core
* *
* Ends all threads and frees all memory ready for the application to exit. * Ends all threads and frees all memory ready for the application to exit.
*/ */
void Stop(); void stop();
/** /**
* @brief Retrieve main window instance * @brief Retrieve main window instance_
* *
* @return * @return
* *
@@ -180,7 +180,7 @@ public:
* *
* @param urls * @param urls
*/ */
void ImportFiles(const QStringList &urls, Folder *parent); void import_files(const QStringList &urls, Folder *parent);
/** /**
* @brief Get the currently active tool * @brief Get the currently active tool
@@ -190,12 +190,12 @@ public:
/** /**
* @brief Get the currently selected object that the add tool should make (if the add tool is active) * @brief Get the currently selected object that the add tool should make (if the add tool is active)
*/ */
const Tool::AddableObject &GetSelectedAddableObject() const; const Tool::AddableObject &get_selected_addable_object() const;
/** /**
* @brief Get the currently selected node that the transition tool should make (if the transition tool is active) * @brief Get the currently selected node that the transition tool should make (if the transition tool is active)
*/ */
const QString &GetSelectedTransition() const; const QString &get_selected_transition() const;
/** /**
* @brief Get current snapping value * @brief Get current snapping value
@@ -205,7 +205,7 @@ public:
/** /**
* @brief Returns a list of the most recently opened/saved projects * @brief Returns a list of the most recently opened/saved projects
*/ */
const QStringList &GetRecentProjects() const; const QStringList &get_recent_projects() const;
/** /**
* @brief Get the currently active project * @brief Get the currently active project
@@ -217,92 +217,92 @@ public:
* *
* The active Project file, or nullptr if the heuristic couldn't find one. * The active Project file, or nullptr if the heuristic couldn't find one.
*/ */
Project *GetActiveProject() const; Project *get_active_project() const;
Folder *GetSelectedFolderInActiveProject() const; Folder *get_selected_folder_in_active_project() const;
/** /**
* @brief Gets current timecode display mode * @brief Gets current timecode display mode
*/ */
Timecode::Display GetTimecodeDisplay() const; Timecode::Display get_timecode_display() const;
/** /**
* @brief Sets current timecode display mode * @brief Sets current timecode display mode
*/ */
void SetTimecodeDisplay(Timecode::Display d); void set_timecode_display(Timecode::Display d);
/** /**
* @brief Set how frequently an autorecovery should be saved (if the project has changed, see SetProjectModified()) * @brief Set how frequently an autorecovery should be saved (if the project has changed, see SetProjectModified())
*/ */
void SetAutorecoveryInterval(int minutes); void set_autorecovery_interval(int minutes);
static void CopyStringToClipboard(const QString &s); static void copy_string_to_clipboard(const QString &s);
static QString PasteStringFromClipboard(); static QString paste_string_from_clipboard();
/** /**
* @brief Recursively count files in a file/directory list * @brief Recursively count files in a file/directory list
*/ */
static int CountFilesInFileList(const QFileInfoList &filenames); static int count_files_in_file_list(const QFileInfoList &filenames);
/** /**
* @brief Show a dialog to the user to rename a set of nodes * @brief Show a dialog to the user to rename a set of nodes
*/ */
bool LabelNodes(const QVector<Node *> &nodes, bool label_nodes(const QVector<Node *> &nodes,
MultiUndoCommand *parent = nullptr); MultiUndoCommand *parent = nullptr);
/** /**
* @brief Create a new sequence named appropriately for the active project * @brief Create a new sequence named appropriately for the active project
*/ */
static Sequence *CreateNewSequenceForProject(const QString &format, static Sequence *create_new_sequence_for_project(const QString &format,
Project *project); Project *project);
static Sequence *CreateNewSequenceForProject(Project *project) static Sequence *create_new_sequence_for_project(Project *project)
{ {
return CreateNewSequenceForProject(tr("Sequence %1"), project); return create_new_sequence_for_project(tr("Sequence %1"), project);
} }
/** /**
* @brief Opens a project from the recently opened list * @brief Opens a project from the recently opened list
*/ */
void OpenProjectFromRecentList(int index); void open_project_from_recent_list(int index);
/** /**
* @brief Closes a project * @brief Closes a project
*/ */
bool CloseProject(bool auto_open_new, bool ignore_modified = false); bool close_project(bool auto_open_new, bool ignore_modified = false);
/** /**
* @brief Runs a modal cache task on the currently active sequence * @brief Runs a modal cache task on the currently active sequence
*/ */
void CacheActiveSequence(bool in_out_only); void cache_active_sequence(bool in_out_only);
/** /**
* @brief Check each footage object for whether it still exists or has changed * @brief Check each footage object for whether it still exists or has changed
*/ */
bool ValidateFootageInLoadedProject(Project *project, bool validate_footage_in_loaded_project(Project *project,
const QString &project_saved_url); const QString &project_saved_url);
/** /**
* @brief Changes the current language * @brief Changes the current language
*/ */
bool SetLanguage(const QString &locale); bool set_language(const QString &locale);
/** /**
* @brief Show message in main window's status bar * @brief Show message in main window's status bar
* *
* Shorthand for Core::instance()->main_window()->statusBar()->showMessage(); * Shorthand for Core::instance()->main_window()->statusBar()->showMessage();
*/ */
void ShowStatusBarMessage(const QString &s, int timeout = 0); void show_status_bar_message(const QString &s, int timeout = 0);
void ClearStatusBarMessage(); void clear_status_bar_message();
void OpenRecoveryProject(const QString &filename); void open_recovery_project(const QString &filename);
void OpenNodeInViewer(ViewerOutput *viewer); void open_node_in_viewer(ViewerOutput *viewer);
void OpenExportDialogForViewer(ViewerOutput *viewer, void open_export_dialog_for_viewer(ViewerOutput *viewer,
bool start_still_image); bool start_still_image);
bool IsMagicEnabled() const bool is_magic_enabled() const
{ {
return magic_; return magic_;
} }
@@ -311,56 +311,56 @@ public slots:
/** /**
* @brief Starts an open file dialog to load a project from file * @brief Starts an open file dialog to load a project from file
*/ */
void OpenProject(); void open_project();
/** /**
* @brief Saves the current project * @brief Saves the current project
*/ */
bool SaveProject(); bool save_project();
/** /**
* @brief Performs a "save as" on the current project * @brief Performs a "save as" on the current project
*/ */
bool SaveProjectAs(); bool save_project_as();
void RevertProject(); void revert_project();
/** /**
* @brief Set the current application-wide tool * @brief Set the current application-wide tool
* *
* @param tool * @param tool
*/ */
void SetTool(const Tool::Item &tool); void set_tool(const Tool::Item &tool);
/** /**
* @brief Set the current snapping setting * @brief Set the current snapping setting
*/ */
void SetSnapping(const bool &b); void set_snapping(const bool &b);
/** /**
* @brief Show an About dialog * @brief Show an About dialog
*/ */
void DialogAboutShow(); void dialog_about_show();
/** /**
* @brief Open the import footage dialog and import the files selected (runs ImportFiles()) * @brief Open the import footage dialog and import the files selected (runs ImportFiles())
*/ */
void DialogImportShow(); void dialog_import_show();
/** /**
* @brief Show Preferences dialog * @brief Show Preferences dialog
*/ */
void DialogPreferencesShow(int start_tab = 0); void dialog_preferences_show(int start_tab = 0);
/** /**
* @brief Show Project Properties dialog * @brief Show Project Properties dialog
*/ */
void DialogProjectPropertiesShow(); void dialog_project_properties_show();
/** /**
* @brief Show Export dialog * @brief Show Export dialog
*/ */
void DialogExportShow(); void dialog_export_show();
/** /**
* @brief Show OTIO import dialog * @brief Show OTIO import dialog
@@ -372,42 +372,42 @@ public slots:
/** /**
* @brief Create a new folder in the currently active project * @brief Create a new folder in the currently active project
*/ */
void CreateNewFolder(); void create_new_folder();
/** /**
* @brief Create a new sequence in the currently active project * @brief Create a new sequence in the currently active project
*/ */
void CreateNewSequence(); void create_new_sequence();
/** /**
* @brief Set the currently selected object that the add tool should make * @brief Set the currently selected object that the add tool should make
*/ */
void SetSelectedAddableObject(const Tool::AddableObject &obj); void set_selected_addable_object(const Tool::AddableObject &obj);
/** /**
* @brief Set the currently selected object that the add tool should make * @brief Set the currently selected object that the add tool should make
*/ */
void SetSelectedTransitionObject(const QString &obj); void set_selected_transition_object(const QString &obj);
/** /**
* @brief Clears the list of recently opened/saved projects * @brief Clears the list of recently opened/saved projects
*/ */
void ClearOpenRecentList(); void clear_open_recent_list();
/** /**
* @brief Creates a new empty project and opens it * @brief Creates a new empty project and opens it
*/ */
void CreateNewProject(); void create_new_project();
void CheckForAutoRecoveries(); void check_for_auto_recoveries();
void BrowseAutoRecoveries(); void browse_auto_recoveries();
void RequestPixelSamplingInViewers(bool e); void request_pixel_sampling_in_viewers(bool e);
void WarnCacheFull(); void warn_cache_full();
void SetMagic(bool e) void set_magic(bool e)
{ {
magic_ = e; magic_ = e;
} }
@@ -416,60 +416,60 @@ signals:
/** /**
* @brief Signal emitted when the tool is changed from somewhere * @brief Signal emitted when the tool is changed from somewhere
*/ */
void ToolChanged(const Tool::Item &tool); void tool_changed(const Tool::Item &tool);
/** /**
* @brief Signal emitted when addable object changes through SetSelectedAddableObject * @brief Signal emitted when addable object changes through SetSelectedAddableObject
*/ */
void AddableObjectChanged(Tool::AddableObject o); void addable_object_changed(Tool::AddableObject o);
/** /**
* @brief Signal emitted when the snapping setting is changed * @brief Signal emitted when the snapping setting is changed
*/ */
void SnappingChanged(const bool &b); void snapping_changed(const bool &b);
/** /**
* @brief Signal emitted when the default timecode display mode changed * @brief Signal emitted when the default timecode display mode changed
*/ */
void TimecodeDisplayChanged(Timecode::Display d); void timecode_display_changed(Timecode::Display d);
/** /**
* @brief Signal emitted when a change is made to the open recent list * @brief Signal emitted when a change is made to the open recent list
*/ */
void OpenRecentListChanged(); void open_recent_list_changed();
/** /**
* @brief Enable mouse color sampling functionality on all viewers * @brief Enable mouse color sampling functionality on all viewers
* *
* This can be slow, so we only turn it on when we need it. * This can be slow, so we only turn it on when we need it.
*/ */
void ColorPickerEnabled(bool e); void color_picker_enabled(bool e);
/** /**
* @brief A viewer with color picked enabled has emitted a color * @brief A viewer with color picked enabled has emitted a color
*/ */
void ColorPickerColorEmitted(const Color &reference, const Color &display); void color_picker_color_emitted(const Color &reference, const Color &display);
private: private:
/** /**
* @brief Get the file filter than can be used with QFileDialog to open and save compatible projects * @brief Get the file filter than can be used with QFileDialog to open and save compatible projects
*/ */
static QString GetProjectFilter(bool include_any_filter); static QString get_project_filter(bool include_any_filter);
/** /**
* @brief Returns the filename where the recently opened/saved projects should be stored * @brief Returns the filename where the recently opened/saved projects should be stored
*/ */
static QString GetRecentProjectsFilePath(); static QString get_recent_projects_file_path();
/** /**
* @brief Called only on startup to set the locale * @brief Called only on startup to set the locale
*/ */
void SetStartupLocale(); void set_startup_locale();
/** /**
* @brief Adds a filename to the top of the recently opened projects list (or moves it if it already exists) * @brief Adds a filename to the top of the recently opened projects list (or moves it if it already exists)
*/ */
void PushRecentlyOpenedProject(const QString &s); void push_recently_opened_project(const QString &s);
/** /**
* @brief Declare custom types/classes for Qt's signal/slot system * @brief Declare custom types/classes for Qt's signal/slot system
@@ -477,42 +477,42 @@ private:
* Qt's signal/slot system requires types to be declared. In the interest of doing this only at startup, we contain * Qt's signal/slot system requires types to be declared. In the interest of doing this only at startup, we contain
* them all in a function here. * them all in a function here.
*/ */
void DeclareTypesForQt(); void declare_types_for_qt();
/** /**
* @brief Start GUI portion of Olive * @brief Start GUI portion of Olive
* *
* Starts services and objects required for the GUI of Olive. It's guaranteed that running without this function will * Starts services and objects required for the GUI of Olive. It's guaranteed that running without this function will
* create an application instance that is completely valid minus the UI (e.g. for CLI modes). * create an application instance_ that is completely valid minus the UI (e.g. for CLI modes).
*/ */
void StartGUI(bool full_screen); void start_gui(bool full_screen);
/** /**
* @brief Internal function for saving a project to a file * @brief Internal function for saving a project to a file
*/ */
void SaveProjectInternal(const QString &override_filename = QString()); void save_project_internal(const QString &override_filename = QString());
/** /**
* @brief Retrieves the currently most active sequence for exporting * @brief Retrieves the currently most active sequence for exporting
*/ */
ViewerOutput *GetSequenceToExport(); ViewerOutput *get_sequence_to_export();
static QString GetAutoRecoveryIndexFilename(); static QString get_auto_recovery_index_filename();
void SaveUnrecoveredList(); void save_unrecovered_list();
bool RevertProjectInternal(bool by_opening_existing); bool revert_project_internal(bool by_opening_existing);
void SaveRecentProjectsList(); void save_recent_projects_list();
/** /**
* @brief Adds a project to the "open projects" list * @brief Adds a project to the "open projects" list
*/ */
void AddOpenProject(olive::Project *p, bool add_to_recents = false); void add_open_project(olive::Project *p, bool add_to_recents = false);
bool AddOpenProjectFromTask(Task *task, bool add_to_recents); bool add_open_project_from_task(Task *task, bool add_to_recents);
void SetActiveProject(Project *p); void set_active_project(Project *p);
/** /**
* @brief Internal main window object * @brief Internal main window object
@@ -550,7 +550,7 @@ private:
QTimer autorecovery_timer_; QTimer autorecovery_timer_;
/** /**
* @brief Application-wide undo stack instance * @brief Application-wide undo stack instance_
*/ */
UndoStack undo_stack_; UndoStack undo_stack_;
@@ -565,7 +565,7 @@ private:
CoreParams core_params_; CoreParams core_params_;
/** /**
* @brief Static singleton core instance * @brief Static singleton core instance_
*/ */
static Core *instance_; static Core *instance_;
@@ -592,36 +592,36 @@ private:
bool shown_cache_full_warning_; bool shown_cache_full_warning_;
private slots: private slots:
void SaveAutorecovery(); void save_autorecovery();
void ProjectSaveSucceeded(Task *task); void project_save_succeeded(Task *task);
bool AddOpenProjectFromTaskAndAddToRecents(Task *task) bool add_open_project_from_task_and_add_to_recents(Task *task)
{ {
return AddOpenProjectFromTask(task, true); return add_open_project_from_task(task, true);
} }
void ImportTaskComplete(Task *task); void import_task_complete(Task *task);
bool ConfirmImageSequence(const QString &filename); bool confirm_image_sequence(const QString &filename);
void ProjectWasModified(bool e); void project_was_modified(bool e);
bool StartHeadlessExport(); bool start_headless_export();
void OpenStartupProject(); void open_startup_project();
void AddRecoveryProjectFromTask(Task *task); void add_recovery_project_from_task(Task *task);
/** /**
* @brief Internal project open * @brief Internal project open
*/ */
void OpenProjectInternal(const QString &filename, void open_project_internal(const QString &filename,
bool recovery_project = false); bool recovery_project = false);
void ImportSingleFile(const QString &f); void import_single_file(const QString &f);
}; };
} }
#endif // CORE_H #endif // OAK_CORE_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef CRASHHANDLERDIALOG_H #ifndef OAK_CRASHHANDLERDIALOG_H
#define CRASHHANDLERDIALOG_H #define OAK_CRASHHANDLERDIALOG_H
#include <client/crash_report_database.h> #include <client/crash_report_database.h>
#include <QDialog> #include <QDialog>
@@ -79,4 +79,4 @@ private slots:
} }
#endif // CRASHHANDLERDIALOG_H #endif // OAK_CRASHHANDLERDIALOG_H
+2 -2
View File
@@ -115,7 +115,7 @@ AboutDialog::AboutDialog(bool welcome_dialog, QWidget *parent)
if (!patrons.isEmpty()) { if (!patrons.isEmpty()) {
ScrollingLabel *scroll = new ScrollingLabel(patrons); ScrollingLabel *scroll = new ScrollingLabel(patrons);
scroll->StartAnimating(); scroll->start_animating();
layout->addWidget(scroll); layout->addWidget(scroll);
} }
@@ -150,7 +150,7 @@ AboutDialog::AboutDialog(bool welcome_dialog, QWidget *parent)
void AboutDialog::accept() void AboutDialog::accept()
{ {
if (dont_show_again_checkbox_ && dont_show_again_checkbox_->isChecked()) { if (dont_show_again_checkbox_ && dont_show_again_checkbox_->isChecked()) {
OLIVE_CONFIG("ShowWelcomeDialog") = false; OAK_CONFIG("ShowWelcomeDialog") = false;
} }
QDialog::accept(); QDialog::accept();
+3 -3
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef ABOUTDIALOG_H #ifndef OAK_ABOUTDIALOG_H
#define ABOUTDIALOG_H #define OAK_ABOUTDIALOG_H
#include <QCheckBox> #include <QCheckBox>
#include <QDialog> #include <QDialog>
@@ -59,4 +59,4 @@ private:
} }
#endif // ABOUTDIALOG_H #endif // OAK_ABOUTDIALOG_H
+3 -3
View File
@@ -16,11 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PATREON_H #ifndef OAK_PATREON_H
#define PATREON_H #define OAK_PATREON_H
#include <QStringList> #include <QStringList>
QStringList patrons; QStringList patrons;
#endif // PATREON_H #endif // OAK_PATREON_H
+11 -11
View File
@@ -28,23 +28,23 @@
namespace olive namespace olive
{ {
const int ScrollingLabel::kMinLineHeight = 10; const int ScrollingLabel::k_min_line_height = 10;
ScrollingLabel::ScrollingLabel(QWidget *parent) ScrollingLabel::ScrollingLabel(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, animate_(0) , animate_(0)
{ {
timer_.setInterval(50); timer_.setInterval(50);
connect(&timer_, &QTimer::timeout, this, &ScrollingLabel::AnimationUpdate); connect(&timer_, &QTimer::timeout, this, &ScrollingLabel::animation_update);
} }
ScrollingLabel::ScrollingLabel(const QStringList &text, QWidget *parent) ScrollingLabel::ScrollingLabel(const QStringList &text, QWidget *parent)
: ScrollingLabel(parent) : ScrollingLabel(parent)
{ {
SetText(text); set_text(text);
} }
void ScrollingLabel::SetText(const QStringList &text) void ScrollingLabel::set_text(const QStringList &text)
{ {
text_ = text; text_ = text;
@@ -53,10 +53,10 @@ void ScrollingLabel::SetText(const QStringList &text)
int width = 0; int width = 0;
foreach (const QString &s, text_) { foreach (const QString &s, text_) {
width = qMax(width, QtUtils::QFontMetricsWidth(fm, s)); width = qMax(width, QtUtils::q_font_metrics_width(fm, s));
} }
setMinimumSize(width, text_height_ * kMinLineHeight); setMinimumSize(width, text_height_ * k_min_line_height);
} }
void ScrollingLabel::paintEvent(QPaintEvent *e) void ScrollingLabel::paintEvent(QPaintEvent *e)
@@ -82,15 +82,15 @@ void ScrollingLabel::paintEvent(QPaintEvent *e)
const QString &s = text_.at(i); const QString &s = text_.at(i);
int width = QtUtils::QFontMetricsWidth(fm, s); int width = QtUtils::q_font_metrics_width(fm, s);
p.drawText(half_width / 2 - width / 2, text_y, s); p.drawText(half_width / 2 - width / 2, text_y, s);
} }
for (int y = 0; y < text_height_; y++) { for (int y = 0; y < text_height_; y++) {
double mul = double(y) / double(text_height_); double mul = double(y) / double(text_height_);
SetOpacityOfScanLine(map.scanLine(y), map.width(), 4, mul); set_opacity_of_scan_line(map.scanLine(y), map.width(), 4, mul);
SetOpacityOfScanLine(map.scanLine(map.height() - 1 - y), set_opacity_of_scan_line(map.scanLine(map.height() - 1 - y),
map.width(), 4, mul); map.width(), 4, mul);
} }
} }
@@ -99,7 +99,7 @@ void ScrollingLabel::paintEvent(QPaintEvent *e)
wp.drawImage(0, 0, map); wp.drawImage(0, 0, map);
} }
void ScrollingLabel::SetOpacityOfScanLine(uchar *scan_line, int width, void ScrollingLabel::set_opacity_of_scan_line(uchar *scan_line, int width,
int channels, double mul) int channels, double mul)
{ {
for (int x = 0; x < width; x++) { for (int x = 0; x < width; x++) {
@@ -111,7 +111,7 @@ void ScrollingLabel::SetOpacityOfScanLine(uchar *scan_line, int width,
} }
} }
void ScrollingLabel::AnimationUpdate() void ScrollingLabel::animation_update()
{ {
animate_++; animate_++;
+9 -9
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef SCROLLINGLABEL_H #ifndef OAK_SCROLLINGLABEL_H
#define SCROLLINGLABEL_H #define OAK_SCROLLINGLABEL_H
#include <QTimer> #include <QTimer>
#include <QWidget> #include <QWidget>
@@ -34,14 +34,14 @@ public:
ScrollingLabel(QWidget *parent = nullptr); ScrollingLabel(QWidget *parent = nullptr);
ScrollingLabel(const QStringList &text, QWidget *parent = nullptr); ScrollingLabel(const QStringList &text, QWidget *parent = nullptr);
void SetText(const QStringList &text); void set_text(const QStringList &text);
void StartAnimating() void start_animating()
{ {
timer_.start(); timer_.start();
} }
void StopAnimating() void stop_animating()
{ {
timer_.stop(); timer_.stop();
} }
@@ -50,10 +50,10 @@ protected:
virtual void paintEvent(QPaintEvent *e) override; virtual void paintEvent(QPaintEvent *e) override;
private: private:
static void SetOpacityOfScanLine(uchar *scan_line, int width, int channels, static void set_opacity_of_scan_line(uchar *scan_line, int width, int channels,
double mul); double mul);
static const int kMinLineHeight; static const int k_min_line_height;
QStringList text_; QStringList text_;
@@ -64,9 +64,9 @@ private:
int animate_; int animate_;
private slots: private slots:
void AnimationUpdate(); void animation_update();
}; };
} }
#endif // SCROLLINGLABEL_H #endif // OAK_SCROLLINGLABEL_H
+25 -25
View File
@@ -66,30 +66,30 @@ ActionSearch::ActionSearch(QWidget *parent)
// moveSelectionUp() and moveSelectionDown() are emitted when the user pressed up or down on the text field. // moveSelectionUp() and moveSelectionDown() are emitted when the user pressed up or down on the text field.
// We override it here to select the upper or lower item in the list. // We override it here to select the upper or lower item in the list.
connect(entry_field, SIGNAL(moveSelectionUp()), this, connect(entry_field, SIGNAL(move_selection_up()), this,
SLOT(move_selection_up())); SLOT(move_selection_up()));
connect(entry_field, SIGNAL(moveSelectionDown()), this, connect(entry_field, SIGNAL(move_selection_down()), this,
SLOT(move_selection_down())); SLOT(move_selection_down()));
layout->addWidget(entry_field); layout->addWidget(entry_field);
// Construct list of actions // Construct list of actions
list_widget = new ActionSearchList(this); list_widget_ = new ActionSearchList(this);
// Set list's font to 1.2x its standard font size // Set list's font to 1.2x its standard font size
QFont list_widget_font = list_widget->font(); QFont list_widget_font = list_widget_->font();
list_widget_font.setPointSize(qRound(list_widget_font.pointSize() * 1.2)); list_widget_font.setPointSize(qRound(list_widget_font.pointSize() * 1.2));
list_widget->setFont(list_widget_font); list_widget_->setFont(list_widget_font);
layout->addWidget(list_widget); layout->addWidget(list_widget_);
connect(list_widget, SIGNAL(dbl_click()), this, SLOT(perform_action())); connect(list_widget_, SIGNAL(dbl_click()), this, SLOT(perform_action()));
// Instantly focus on the entry field to allow for fully keyboard operation (if this popup was initiated by keyboard // Instantly focus on the entry field to allow for fully keyboard operation (if this popup was initiated by keyboard
// shortcut for example). // shortcut for example).
entry_field->setFocus(); entry_field->setFocus();
} }
void ActionSearch::SetMenuBar(QMenuBar *menu_bar) void ActionSearch::set_menu_bar(QMenuBar *menu_bar)
{ {
menu_bar_ = menu_bar; menu_bar_ = menu_bar;
} }
@@ -112,7 +112,7 @@ void ActionSearch::search_update(const QString &s, const QString &p,
// (and their submenus). // (and their submenus).
// We'll clear all the current items in the list since if we're here, we're just starting. // We'll clear all the current items in the list since if we're here, we're just starting.
list_widget->clear(); list_widget_->clear();
QList<QAction *> menus = menu_bar_->actions(); QList<QAction *> menus = menu_bar_->actions();
@@ -125,8 +125,8 @@ void ActionSearch::search_update(const QString &s, const QString &p,
// Once we're here, all the recursion/item retrieval is complete. We auto-select the first item for better // Once we're here, all the recursion/item retrieval is complete. We auto-select the first item for better
// keyboard-exclusive functionality. // keyboard-exclusive functionality.
if (list_widget->count() > 0) { if (list_widget_->count() > 0) {
list_widget->item(0)->setSelected(true); list_widget_->item(0)->setSelected(true);
} }
} else { } else {
@@ -162,13 +162,13 @@ void ActionSearch::search_update(const QString &s, const QString &p,
// If so, we add it to the list widget. // If so, we add it to the list widget.
QListWidgetItem *item = new QListWidgetItem( QListWidgetItem *item = new QListWidgetItem(
QStringLiteral("%1\n(%2)").arg(comp, menu_text), QStringLiteral("%1\n(%2)").arg(comp, menu_text),
list_widget); list_widget_);
// Add a pointer to the original QAction in the item's data // Add a pointer to the original QAction in the item's data
item->setData(Qt::UserRole + 1, item->setData(Qt::UserRole + 1,
reinterpret_cast<quintptr>(a)); reinterpret_cast<quintptr>(a));
list_widget->addItem(item); list_widget_->addItem(item);
} }
} }
} }
@@ -179,8 +179,8 @@ void ActionSearch::search_update(const QString &s, const QString &p,
void ActionSearch::perform_action() void ActionSearch::perform_action()
{ {
// Loop over all the items in the list and if we find one that's selected, we trigger it. // Loop over all the items in the list and if we find one that's selected, we trigger it.
QList<QListWidgetItem *> selected_items = list_widget->selectedItems(); QList<QListWidgetItem *> selected_items = list_widget_->selectedItems();
if (list_widget->count() > 0 && selected_items.size() > 0) { if (list_widget_->count() > 0 && selected_items.size() > 0) {
QListWidgetItem *item = selected_items.at(0); QListWidgetItem *item = selected_items.at(0);
// Get QAction pointer from item's data // Get QAction pointer from item's data
@@ -200,11 +200,11 @@ void ActionSearch::move_selection_up()
// iterating at 1 (instead of 0) to efficiently ignore the first item (since the selection can't go below the very // iterating at 1 (instead of 0) to efficiently ignore the first item (since the selection can't go below the very
// bottom item). // bottom item).
int lim = list_widget->count(); int lim = list_widget_->count();
for (int i = 1; i < lim; i++) { for (int i = 1; i < lim; i++) {
if (list_widget->item(i)->isSelected()) { if (list_widget_->item(i)->isSelected()) {
list_widget->item(i - 1)->setSelected(true); list_widget_->item(i - 1)->setSelected(true);
list_widget->scrollToItem(list_widget->item(i - 1)); list_widget_->scrollToItem(list_widget_->item(i - 1));
break; break;
} }
} }
@@ -216,11 +216,11 @@ void ActionSearch::move_selection_down()
// one entry before count() to efficiently ignore the item at the end (since the selection can't go below the very // one entry before count() to efficiently ignore the item at the end (since the selection can't go below the very
// bottom item). // bottom item).
int lim = list_widget->count() - 1; int lim = list_widget_->count() - 1;
for (int i = 0; i < lim; i++) { for (int i = 0; i < lim; i++) {
if (list_widget->item(i)->isSelected()) { if (list_widget_->item(i)->isSelected()) {
list_widget->item(i + 1)->setSelected(true); list_widget_->item(i + 1)->setSelected(true);
list_widget->scrollToItem(list_widget->item(i + 1)); list_widget_->scrollToItem(list_widget_->item(i + 1));
break; break;
} }
} }
@@ -247,11 +247,11 @@ bool ActionSearchEntry::event(QEvent *e)
switch (static_cast<QKeyEvent *>(e)->key()) { switch (static_cast<QKeyEvent *>(e)->key()) {
case Qt::Key_Up: case Qt::Key_Up:
e->accept(); e->accept();
emit moveSelectionUp(); emit move_selection_up();
return true; return true;
case Qt::Key_Down: case Qt::Key_Down:
e->accept(); e->accept();
emit moveSelectionDown(); emit move_selection_down();
return true; return true;
} }
break; break;
+7 -7
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef ACTIONSEARCH_H #ifndef OAK_ACTIONSEARCH_H
#define ACTIONSEARCH_H #define OAK_ACTIONSEARCH_H
#include <QDialog> #include <QDialog>
#include <QLineEdit> #include <QLineEdit>
@@ -58,7 +58,7 @@ public:
/** /**
* @brief Set the menu bar to use in this action search * @brief Set the menu bar to use in this action search
*/ */
void SetMenuBar(QMenuBar *menu_bar); void set_menu_bar(QMenuBar *menu_bar);
private slots: private slots:
/** /**
* @brief Update the list of actions according to a search query * @brief Update the list of actions according to a search query
@@ -115,7 +115,7 @@ private:
/** /**
* @brief Main widget that shows the list of commands * @brief Main widget that shows the list of commands
*/ */
ActionSearchList *list_widget; ActionSearchList *list_widget_;
/** /**
* @brief Attached menu bar object * @brief Attached menu bar object
@@ -180,14 +180,14 @@ signals:
/** /**
* @brief Emitted when the user presses the up arrow key. * @brief Emitted when the user presses the up arrow key.
*/ */
void moveSelectionUp(); void move_selection_up();
/** /**
* @brief Emitted when the user presses the down arrow key. * @brief Emitted when the user presses the down arrow key.
*/ */
void moveSelectionDown(); void move_selection_down();
}; };
} }
#endif // ACTIONSEARCH_H #endif // OAK_ACTIONSEARCH_H
@@ -40,24 +40,24 @@ AutoRecoveryDialog::AutoRecoveryDialog(const QString &message,
bool autocheck_latest, QWidget *parent) bool autocheck_latest, QWidget *parent)
: QDialog(parent) : QDialog(parent)
{ {
Init(message); init(message);
PopulateTree(recoveries, autocheck_latest); populate_tree(recoveries, autocheck_latest);
} }
void AutoRecoveryDialog::accept() void AutoRecoveryDialog::accept()
{ {
foreach (QTreeWidgetItem *checkable, checkable_items_) { foreach (QTreeWidgetItem *checkable, checkable_items_) {
if (checkable->checkState(0) == Qt::Checked) { if (checkable->checkState(0) == Qt::Checked) {
QString filename = checkable->data(0, kFilenameRole).toString(); QString filename = checkable->data(0, k_filename_role).toString();
Core::instance()->OpenRecoveryProject(filename); Core::instance()->open_recovery_project(filename);
} }
} }
super::accept(); super::accept();
} }
void AutoRecoveryDialog::Init(const QString &header_text) void AutoRecoveryDialog::init(const QString &header_text)
{ {
QVBoxLayout *layout = new QVBoxLayout(this); QVBoxLayout *layout = new QVBoxLayout(this);
@@ -79,11 +79,11 @@ void AutoRecoveryDialog::Init(const QString &header_text)
layout->addWidget(buttons); layout->addWidget(buttons);
} }
void AutoRecoveryDialog::PopulateTree(const QStringList &recoveries, void AutoRecoveryDialog::populate_tree(const QStringList &recoveries,
bool autocheck_latest) bool autocheck_latest)
{ {
// Each entry in `recoveries` is a directory with 1+ recovery projects in it // Each entry in `recoveries` is a directory with 1+ recovery projects in it
QDir autorecovery_root(FileFunctions::GetAutoRecoveryRoot()); QDir autorecovery_root(FileFunctions::get_auto_recovery_root());
foreach (const QString &recovery_folder, recoveries) { foreach (const QString &recovery_folder, recoveries) {
QDir recovery_dir(autorecovery_root.filePath(recovery_folder)); QDir recovery_dir(autorecovery_root.filePath(recovery_folder));
@@ -137,7 +137,7 @@ void AutoRecoveryDialog::PopulateTree(const QStringList &recoveries,
} }
entry_item->setText(0, entry_name); entry_item->setText(0, entry_name);
entry_item->setData(0, kFilenameRole, entry_item->setData(0, k_filename_role,
recovery_dir.filePath(entry)); recovery_dir.filePath(entry));
// Allow to be checked, auto-checking the first entry // Allow to be checked, auto-checking the first entry
+6 -6
View File
@@ -19,8 +19,8 @@
***/ ***/
#ifndef AUTORECOVERYDIALOG_H #ifndef OAK_AUTORECOVERYDIALOG_H
#define AUTORECOVERYDIALOG_H #define OAK_AUTORECOVERYDIALOG_H
#include <QDialog> #include <QDialog>
#include <QTreeWidget> #include <QTreeWidget>
@@ -40,17 +40,17 @@ public slots:
virtual void accept() override; virtual void accept() override;
private: private:
void Init(const QString &header_text); void init(const QString &header_text);
void PopulateTree(const QStringList &recoveries, bool autocheck); void populate_tree(const QStringList &recoveries, bool autocheck);
QTreeWidget *tree_widget_; QTreeWidget *tree_widget_;
QVector<QTreeWidgetItem *> checkable_items_; QVector<QTreeWidgetItem *> checkable_items_;
enum DataRole { kFilenameRole = Qt::UserRole }; enum DataRole { k_filename_role = Qt::UserRole };
}; };
} }
#endif // AUTORECOVERYDIALOG_H #endif // OAK_AUTORECOVERYDIALOG_H
+60 -60
View File
@@ -56,7 +56,7 @@ ColorDialog::ColorDialog(ColorManager *color_manager, const ManagedColor &start,
hsv_value_gradient_ = new ColorGradientWidget(Qt::Vertical); hsv_value_gradient_ = new ColorGradientWidget(Qt::Vertical);
hsv_value_gradient_->setFixedWidth( hsv_value_gradient_->setFixedWidth(
QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral("HHH"))); QtUtils::q_font_metrics_width(fontMetrics(), QStringLiteral("HHH")));
wheel_layout->addWidget(hsv_value_gradient_); wheel_layout->addWidget(hsv_value_gradient_);
QHBoxLayout *swatch_layout = new QHBoxLayout(); QHBoxLayout *swatch_layout = new QHBoxLayout();
@@ -76,7 +76,7 @@ ColorDialog::ColorDialog(ColorManager *color_manager, const ManagedColor &start,
splitter->addWidget(value_area); splitter->addWidget(value_area);
color_values_widget_ = new ColorValuesWidget(color_manager_); color_values_widget_ = new ColorValuesWidget(color_manager_);
color_values_widget_->IgnorePickFrom(this); color_values_widget_->ignore_pick_from(this);
value_layout->addWidget(color_values_widget_); value_layout->addWidget(color_values_widget_);
chooser_ = new ColorSpaceChooser(color_manager_); chooser_ = new ColorSpaceChooser(color_manager_);
@@ -86,32 +86,32 @@ ColorDialog::ColorDialog(ColorManager *color_manager, const ManagedColor &start,
// Split window 50/50 // Split window 50/50
splitter->setSizes({ INT_MAX, INT_MAX }); splitter->setSizes({ INT_MAX, INT_MAX });
connect(color_wheel_, &ColorWheelWidget::SelectedColorChanged, connect(color_wheel_, &ColorWheelWidget::selected_color_changed,
color_values_widget_, &ColorValuesWidget::SetColor); color_values_widget_, &ColorValuesWidget::set_color);
connect(color_wheel_, &ColorWheelWidget::SelectedColorChanged, connect(color_wheel_, &ColorWheelWidget::selected_color_changed,
hsv_value_gradient_, &ColorGradientWidget::SetSelectedColor); hsv_value_gradient_, &ColorGradientWidget::set_selected_color);
connect(color_wheel_, &ColorWheelWidget::SelectedColorChanged, swatch_, connect(color_wheel_, &ColorWheelWidget::selected_color_changed, swatch_,
&ColorSwatchChooser::SetCurrentColor); &ColorSwatchChooser::set_current_color);
connect(hsv_value_gradient_, &ColorGradientWidget::SelectedColorChanged, connect(hsv_value_gradient_, &ColorGradientWidget::selected_color_changed,
color_values_widget_, &ColorValuesWidget::SetColor); color_values_widget_, &ColorValuesWidget::set_color);
connect(hsv_value_gradient_, &ColorGradientWidget::SelectedColorChanged, connect(hsv_value_gradient_, &ColorGradientWidget::selected_color_changed,
color_wheel_, &ColorWheelWidget::SetSelectedColor); color_wheel_, &ColorWheelWidget::set_selected_color);
connect(hsv_value_gradient_, &ColorGradientWidget::SelectedColorChanged, connect(hsv_value_gradient_, &ColorGradientWidget::selected_color_changed,
swatch_, &ColorSwatchChooser::SetCurrentColor); swatch_, &ColorSwatchChooser::set_current_color);
connect(color_values_widget_, &ColorValuesWidget::ColorChanged, connect(color_values_widget_, &ColorValuesWidget::color_changed,
hsv_value_gradient_, &ColorGradientWidget::SetSelectedColor); hsv_value_gradient_, &ColorGradientWidget::set_selected_color);
connect(color_values_widget_, &ColorValuesWidget::ColorChanged, connect(color_values_widget_, &ColorValuesWidget::color_changed,
color_wheel_, &ColorWheelWidget::SetSelectedColor); color_wheel_, &ColorWheelWidget::set_selected_color);
connect(color_values_widget_, &ColorValuesWidget::ColorChanged, swatch_, connect(color_values_widget_, &ColorValuesWidget::color_changed, swatch_,
&ColorSwatchChooser::SetCurrentColor); &ColorSwatchChooser::set_current_color);
connect(swatch_, &ColorSwatchChooser::ColorClicked, hsv_value_gradient_, connect(swatch_, &ColorSwatchChooser::color_clicked, hsv_value_gradient_,
&ColorGradientWidget::SetSelectedColor); &ColorGradientWidget::set_selected_color);
connect(swatch_, &ColorSwatchChooser::ColorClicked, color_wheel_, connect(swatch_, &ColorSwatchChooser::color_clicked, color_wheel_,
&ColorWheelWidget::SetSelectedColor); &ColorWheelWidget::set_selected_color);
connect(swatch_, &ColorSwatchChooser::ColorClicked, color_values_widget_, connect(swatch_, &ColorSwatchChooser::color_clicked, color_values_widget_,
&ColorValuesWidget::SetColor); &ColorValuesWidget::set_color);
connect(color_wheel_, &ColorWheelWidget::DiameterChanged, connect(color_wheel_, &ColorWheelWidget::diameter_changed,
hsv_value_gradient_, &ColorGradientWidget::setFixedHeight); hsv_value_gradient_, &ColorGradientWidget::setFixedHeight);
QDialogButtonBox *buttons = QDialogButtonBox *buttons =
@@ -120,17 +120,17 @@ ColorDialog::ColorDialog(ColorManager *color_manager, const ManagedColor &start,
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
layout->addWidget(buttons); layout->addWidget(buttons);
SetColor(start); set_color(start);
connect(chooser_, &ColorSpaceChooser::ColorSpaceChanged, this, connect(chooser_, &ColorSpaceChooser::color_space_changed, this,
&ColorDialog::ColorSpaceChanged); &ColorDialog::color_space_changed);
ColorSpaceChanged(chooser_->input(), chooser_->output()); color_space_changed(chooser_->input(), chooser_->output());
// Set default size ratio to 2:1 // Set default size ratio to 2:1
resize(sizeHint().height() * 2, sizeHint().height()); resize(sizeHint().height() * 2, sizeHint().height());
} }
void ColorDialog::SetColor(const ManagedColor &start) void ColorDialog::set_color(const ManagedColor &start)
{ {
chooser_->set_input(start.color_input()); chooser_->set_input(start.color_input());
chooser_->set_output(start.color_output()); chooser_->set_output(start.color_output());
@@ -142,70 +142,70 @@ void ColorDialog::SetColor(const ManagedColor &start)
} else { } else {
// Convert reference color to the input space // Convert reference color to the input space
ColorProcessorPtr linear_to_input = ColorProcessor::Create( ColorProcessorPtr linear_to_input = ColorProcessor::create(
color_manager_, color_manager_->GetReferenceColorSpace(), color_manager_, color_manager_->get_reference_color_space(),
start.color_input()); start.color_input());
managed_start = linear_to_input->ConvertColor(start); managed_start = linear_to_input->convert_color(start);
} }
color_wheel_->SetSelectedColor(managed_start); color_wheel_->set_selected_color(managed_start);
hsv_value_gradient_->SetSelectedColor(managed_start); hsv_value_gradient_->set_selected_color(managed_start);
color_values_widget_->SetColor(managed_start); color_values_widget_->set_color(managed_start);
swatch_->SetCurrentColor(managed_start); swatch_->set_current_color(managed_start);
} }
ManagedColor ColorDialog::GetSelectedColor() const ManagedColor ColorDialog::get_selected_color() const
{ {
ManagedColor selected = color_wheel_->GetSelectedColor(); ManagedColor selected = color_wheel_->get_selected_color();
// Convert to linear and return a linear color // Convert to linear and return a linear color
if (input_to_ref_processor_) { if (input_to_ref_processor_) {
selected = input_to_ref_processor_->ConvertColor(selected); selected = input_to_ref_processor_->convert_color(selected);
} }
selected.set_color_input(GetColorSpaceInput()); selected.set_color_input(get_color_space_input());
selected.set_color_output(GetColorSpaceOutput()); selected.set_color_output(get_color_space_output());
return selected; return selected;
} }
QString ColorDialog::GetColorSpaceInput() const QString ColorDialog::get_color_space_input() const
{ {
return chooser_->input(); return chooser_->input();
} }
ColorTransform ColorDialog::GetColorSpaceOutput() const ColorTransform ColorDialog::get_color_space_output() const
{ {
return chooser_->output(); return chooser_->output();
} }
void ColorDialog::ColorSpaceChanged(const QString &input, void ColorDialog::color_space_changed(const QString &input,
const ColorTransform &output) const ColorTransform &output)
{ {
input_to_ref_processor_ = ColorProcessor::Create( input_to_ref_processor_ = ColorProcessor::create(
color_manager_, input, color_manager_->GetReferenceColorSpace()); color_manager_, input, color_manager_->get_reference_color_space());
ColorProcessorPtr ref_to_display = ColorProcessor::Create( ColorProcessorPtr ref_to_display = ColorProcessor::create(
color_manager_, color_manager_->GetReferenceColorSpace(), output); color_manager_, color_manager_->get_reference_color_space(), output);
ColorProcessorPtr ref_to_input = ColorProcessor::Create( ColorProcessorPtr ref_to_input = ColorProcessor::create(
color_manager_, color_manager_->GetReferenceColorSpace(), input); color_manager_, color_manager_->get_reference_color_space(), input);
// Display -> reference is the inverse of the display transform. Older OCIO // Display -> reference is the inverse of the display transform. Older OCIO
// versions crashed on TRANSFORM_DIR_INVERSE; guard by requiring a valid // versions crashed on TRANSFORM_DIR_INVERSE; guard by requiring a valid
// processor and fall back to disabling the display tab if creation fails. // processor and fall back to disabling the display tab if creation fails.
ColorProcessorPtr display_to_ref = ColorProcessor::Create( ColorProcessorPtr display_to_ref = ColorProcessor::create(
color_manager_, color_manager_->GetReferenceColorSpace(), output, color_manager_, color_manager_->get_reference_color_space(), output,
ColorProcessor::kInverse); ColorProcessor::k_inverse);
if (display_to_ref && !display_to_ref->GetProcessor()) { if (display_to_ref && !display_to_ref->get_processor()) {
display_to_ref = nullptr; display_to_ref = nullptr;
} }
color_wheel_->SetColorProcessor(input_to_ref_processor_, ref_to_display); color_wheel_->set_color_processor(input_to_ref_processor_, ref_to_display);
hsv_value_gradient_->SetColorProcessor(input_to_ref_processor_, hsv_value_gradient_->set_color_processor(input_to_ref_processor_,
ref_to_display); ref_to_display);
color_values_widget_->SetColorProcessor( color_values_widget_->set_color_processor(
input_to_ref_processor_, ref_to_display, display_to_ref, ref_to_input); input_to_ref_processor_, ref_to_display, display_to_ref, ref_to_input);
} }

Some files were not shown because too many files have changed in this diff Show More