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
+9 -9
View File
@@ -29,7 +29,7 @@ namespace olive
{
AudioLevelMeter::Stats
AudioLevelMeter::AnalyzeSampleBuffer(const core::SampleBuffer &samples)
AudioLevelMeter::analyze_sample_buffer(const core::SampleBuffer &samples)
{
Stats stats;
@@ -63,9 +63,9 @@ AudioLevelMeter::AnalyzeSampleBuffer(const core::SampleBuffer &samples)
ChannelStats channel_stats;
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_db = LinearToDb(rms);
channel_stats.rms_db = linear_to_db(rms);
channel_stats.vu_db = channel_stats.rms_db;
stats.channels[channel] = channel_stats;
@@ -76,24 +76,24 @@ AudioLevelMeter::AnalyzeSampleBuffer(const core::SampleBuffer &samples)
stats.silence = qFuzzyIsNull(stats.max_peak_linear);
stats.integrated_lufs =
PowerToLufs(total_square / static_cast<double>(total_samples));
power_to_lufs(total_square / static_cast<double>(total_samples));
return stats;
}
double AudioLevelMeter::LinearToDb(double linear)
double AudioLevelMeter::linear_to_db(double linear)
{
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) {
return Decibel::MINIMUM;
return Decibel::minimum;
}
// BS.1770 loudness uses K-weighted mean square. This first pass stores the
+6 -6
View File
@@ -18,8 +18,8 @@
***/
#ifndef AUDIOLEVELMETER_H
#define AUDIOLEVELMETER_H
#ifndef OAK_AUDIOLEVELMETER_H
#define OAK_AUDIOLEVELMETER_H
#include <QVector>
@@ -45,13 +45,13 @@ public:
bool silence = true;
};
static Stats AnalyzeSampleBuffer(const core::SampleBuffer &samples);
static Stats analyze_sample_buffer(const core::SampleBuffer &samples);
private:
static double LinearToDb(double linear);
static double PowerToLufs(double mean_square);
static double linear_to_db(double linear);
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;
void AudioManager::CreateInstance()
void AudioManager::create_instance()
{
if (instance_ == nullptr) {
instance_ = new AudioManager();
}
}
void AudioManager::DestroyInstance()
void AudioManager::destroy_instance()
{
delete instance_;
instance_ = nullptr;
@@ -52,18 +52,18 @@ AudioManager *AudioManager::instance()
return instance_;
}
void AudioManager::SetOutputNotifyInterval(int n)
void AudioManager::set_output_notify_interval(int n)
{
output_buffer_->set_notify_interval(n);
}
int OutputCallback(const void *input, void *output, unsigned long frameCount,
const PaStreamCallbackTimeInfo *timeInfo,
PaStreamCallbackFlags statusFlags, void *userData)
int output_callback(const void *input, void *output, unsigned long frame_count,
const PaStreamCallbackTimeInfo *time_info,
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 =
device->read(reinterpret_cast<char *>(output), max_read);
if (read_count < max_read) {
@@ -74,23 +74,23 @@ int OutputCallback(const void *input, void *output, unsigned long frameCount,
return paContinue;
}
int InputCallback(const void *input, void *output, unsigned long frameCount,
const PaStreamCallbackTimeInfo *timeInfo,
PaStreamCallbackFlags statusFlags, void *userData)
int input_callback(const void *input, void *output, unsigned long frame_count,
const PaStreamCallbackTimeInfo *time_info,
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();
our_params.set_format(
f->params().audio_params().format().to_packed_equivalent());
f->WriteAudioData(our_params, reinterpret_cast<const uint8_t **>(&input),
frameCount);
f->write_audio_data(our_params, reinterpret_cast<const uint8_t **>(&input),
frame_count);
return paContinue;
}
bool AudioManager::PushToOutput(const AudioParams &params,
bool AudioManager::push_to_output(const AudioParams &params,
const QByteArray &samples, QString *error)
{
if (output_device_ == paNoDevice) {
@@ -102,14 +102,14 @@ bool AudioManager::PushToOutput(const AudioParams &params,
if (output_params_ != params || output_stream_ == nullptr) {
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,
output_params_.sample_rate(),
paFramesPerBufferUnspecified, paNoFlag,
OutputCallback, output_buffer_);
output_callback, output_buffer_);
if (r != paNoError) {
// Unhandled error
//qCritical() << "Failed to open output stream:" << Pa_GetErrorText(r);
@@ -136,59 +136,59 @@ bool AudioManager::PushToOutput(const AudioParams &params,
return true;
}
void AudioManager::ClearBufferedOutput()
void AudioManager::clear_buffered_output()
{
output_buffer_->clear();
}
PaSampleFormat AudioManager::GetPortAudioSampleFormat(SampleFormat fmt)
PaSampleFormat AudioManager::get_port_audio_sample_format(SampleFormat fmt)
{
switch (fmt) {
case SampleFormat::U8:
case SampleFormat::U8P:
case SampleFormat::u8:
case SampleFormat::u8_p:
return paUInt8;
case SampleFormat::S16:
case SampleFormat::S16P:
case SampleFormat::s16:
case SampleFormat::s16_p:
return paInt16;
case SampleFormat::S32:
case SampleFormat::S32P:
case SampleFormat::s32:
case SampleFormat::s32_p:
return paInt32;
case SampleFormat::F32:
case SampleFormat::F32P:
case SampleFormat::f32:
case SampleFormat::f32_p:
return paFloat32;
case SampleFormat::S64:
case SampleFormat::S64P:
case SampleFormat::F64:
case SampleFormat::F64P:
case SampleFormat::INVALID:
case SampleFormat::COUNT:
case SampleFormat::s64:
case SampleFormat::s64_p:
case SampleFormat::f64:
case SampleFormat::f64_p:
case SampleFormat::invalid:
case SampleFormat::count:
break;
}
return 0;
}
void AudioManager::CloseOutputStream()
void AudioManager::close_output_stream()
{
if (output_stream_) {
if (Pa_IsStreamActive(output_stream_)) {
StopOutput();
stop_output();
}
Pa_CloseStream(output_stream_);
output_stream_ = nullptr;
}
}
void AudioManager::StopOutput()
void AudioManager::stop_output()
{
// Abort the stream so playback stops immediately
if (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) {
qInfo() << "No output device found";
@@ -201,12 +201,12 @@ void AudioManager::SetOutputDevice(PaDeviceIndex 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) {
qInfo() << "No input device found";
@@ -220,14 +220,14 @@ void AudioManager::SetInputDevice(PaDeviceIndex device)
input_device_ = device;
}
void AudioManager::HardReset()
void AudioManager::hard_reset()
{
CloseOutputStream();
close_output_stream();
Pa_Terminate();
Pa_Initialize();
}
bool AudioManager::StartRecording(const EncodingParams &params,
bool AudioManager::start_recording(const EncodingParams &params,
QString *error_str)
{
if (input_device_ == paNoDevice) {
@@ -235,18 +235,18 @@ bool AudioManager::StartRecording(const EncodingParams &params,
}
input_encoder_ = new FFmpegEncoder(params);
if (!input_encoder_->Open()) {
if (!input_encoder_->open()) {
qCritical() << "Failed to open encoder for recording";
return false;
}
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,
params.audio_params().sample_rate(),
paFramesPerBufferUnspecified, paNoFlag,
InputCallback, input_encoder_);
input_callback, input_encoder_);
if (r == paNoError) {
//const PaStreamInfo* info = Pa_GetStreamInfo(input_stream_);
r = Pa_StartStream(input_stream_);
@@ -259,11 +259,11 @@ bool AudioManager::StartRecording(const EncodingParams &params,
*error_str = Pa_GetErrorText(r);
}
StopRecording();
stop_recording();
return false;
}
void AudioManager::StopRecording()
void AudioManager::stop_recording()
{
if (input_stream_) {
if (Pa_IsStreamActive(input_stream_)) {
@@ -275,14 +275,14 @@ void AudioManager::StopRecording()
}
if (input_encoder_) {
input_encoder_->Close();
input_encoder_->close();
delete input_encoder_;
input_encoder_ = nullptr;
}
}
#ifdef Q_OS_LINUX
static bool IsPreferredLinuxAudioHostApi(const PaHostApiInfo *info)
static bool is_preferred_linux_audio_host_api(const PaHostApiInfo *info)
{
if (!info) {
return false;
@@ -294,7 +294,7 @@ static bool IsPreferredLinuxAudioHostApi(const PaHostApiInfo *info)
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
// (PipeWire, JACK, PulseAudio) over plain ALSA defaults, which often
@@ -328,16 +328,16 @@ static PaDeviceIndex GetPreferredLinuxAudioDevice(bool is_output_device)
}
#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") :
QStringLiteral("AudioInput");
return FindDeviceByName(OLIVE_CONFIG_STR(entry).toString(),
return find_device_by_name(OAK_CONFIG_STR(entry).toString(),
is_output_device);
}
PaDeviceIndex AudioManager::FindDeviceByName(const QString &s,
PaDeviceIndex AudioManager::find_device_by_name(const QString &s,
bool is_output_device)
{
PaDeviceIndex exact_match = paNoDevice;
@@ -367,7 +367,7 @@ PaDeviceIndex AudioManager::FindDeviceByName(const QString &s,
if (matched_info) {
const PaHostApiInfo *host_api =
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.
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
// when one is available.
PaDeviceIndex preferred =
GetPreferredLinuxAudioDevice(is_output_device);
get_preferred_linux_audio_device(is_output_device);
if (preferred != paNoDevice) {
qInfo() << "Overriding saved audio device" << s
<< "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
if (exact_match != paNoDevice) {
return exact_match;
@@ -399,7 +399,7 @@ PaDeviceIndex AudioManager::FindDeviceByName(const QString &s,
#endif
}
PaStreamParameters AudioManager::GetPortAudioParams(const AudioParams &params,
PaStreamParameters AudioManager::get_port_audio_params(const AudioParams &params,
PaDeviceIndex device)
{
PaStreamParameters p;
@@ -407,7 +407,7 @@ PaStreamParameters AudioManager::GetPortAudioParams(const AudioParams &params,
p.channelCount = params.channel_count();
p.device = device;
p.hostApiSpecificStreamInfo = nullptr;
p.sampleFormat = GetPortAudioSampleFormat(params.format());
p.sampleFormat = get_port_audio_sample_format(params.format());
if (device >= 0 && device < Pa_GetDeviceCount()) {
p.suggestedLatency = Pa_GetDeviceInfo(device)->defaultLowOutputLatency;
@@ -432,24 +432,24 @@ AudioManager::AudioManager()
Pa_Initialize();
// Get device from config
PaDeviceIndex output_device = FindConfigDeviceByName(true);
PaDeviceIndex input_device = FindConfigDeviceByName(false);
PaDeviceIndex output_device = find_config_device_by_name(true);
PaDeviceIndex input_device = find_config_device_by_name(false);
qDebug() << "AudioManager: selected output device index=" << output_device
<< "input device index=" << input_device;
SetOutputDevice(output_device);
SetInputDevice(input_device);
set_output_device(output_device);
set_input_device(input_device);
output_buffer_ = new PreviewAudioDevice(this);
output_buffer_->open(PreviewAudioDevice::ReadWrite);
connect(output_buffer_, &PreviewAudioDevice::Notify, this,
&AudioManager::OutputNotify);
connect(output_buffer_, &PreviewAudioDevice::notify, this,
&AudioManager::output_notify);
}
AudioManager::~AudioManager()
{
CloseOutputStream();
close_output_stream();
Pa_Terminate();
}
+23 -23
View File
@@ -19,8 +19,8 @@
***/
#ifndef AUDIOMANAGER_H
#define AUDIOMANAGER_H
#ifndef OAK_AUDIOMANAGER_H
#define OAK_AUDIOMANAGER_H
#include <memory>
#include <QtConcurrent/QtConcurrent>
@@ -46,61 +46,61 @@ namespace olive
class AudioManager : public QObject {
Q_OBJECT
public:
static void CreateInstance();
static void DestroyInstance();
static void create_instance();
static void destroy_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);
void ClearBufferedOutput();
void clear_buffered_output();
void StopOutput();
void stop_output();
PaDeviceIndex GetOutputDevice() const
PaDeviceIndex get_output_device() const
{
return output_device_;
}
PaDeviceIndex GetInputDevice() const
PaDeviceIndex get_input_device() const
{
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);
void StopRecording();
void stop_recording();
static PaDeviceIndex FindConfigDeviceByName(bool is_output_device);
static PaDeviceIndex FindDeviceByName(const QString &s,
static PaDeviceIndex find_config_device_by_name(bool is_output_device);
static PaDeviceIndex find_device_by_name(const QString &s,
bool is_output_device);
static PaStreamParameters GetPortAudioParams(const AudioParams &p,
static PaStreamParameters get_port_audio_params(const AudioParams &p,
PaDeviceIndex device);
signals:
void OutputNotify();
void output_notify();
void OutputParamsChanged();
void output_params_changed();
private:
AudioManager();
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_;
@@ -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
* channel count (stereo when unknown).
*/
static AudioParams FixChannelLayout(const AudioParams &params)
static AudioParams fix_channel_layout(const AudioParams &params)
{
AudioParams result = params;
@@ -66,10 +66,10 @@ 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)
{
if (graph_) {
@@ -77,8 +77,8 @@ bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to,
return false;
}
AudioParams from_fixed = FixChannelLayout(from);
AudioParams to_fixed = FixChannelLayout(to);
AudioParams from_fixed = fix_channel_layout(from);
AudioParams to_fixed = fix_channel_layout(to);
qDebug() << "AudioProcessor::Open: from sample_rate="
<< 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_channel_layout_mask = from_fixed.channel_layout();
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.out_sample_rate = to_fixed.sample_rate();
config.out_channel_layout_mask = to_fixed.channel_layout();
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_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();
if (!out_frame_) {
qCritical() << "Failed to allocate output frame";
Close();
close();
return false;
}
@@ -123,7 +123,7 @@ bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to,
return true;
}
void AudioProcessor::Close()
void AudioProcessor::close()
{
if (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)
{
if (!IsOpen()) {
if (!is_open()) {
qCritical() << "Tried to convert on closed processor";
return -1;
}
@@ -197,7 +197,7 @@ int AudioProcessor::Convert(float **in, int nb_in_samples,
return r;
}
void AudioProcessor::Flush()
void AudioProcessor::flush()
{
int r = fb_audio_graph_push(graph_, nullptr, 0);
if (r < 0) {
+8 -8
View File
@@ -19,8 +19,8 @@
***/
#ifndef AUDIOPROCESSOR_H
#define AUDIOPROCESSOR_H
#ifndef OAK_AUDIOPROCESSOR_H
#define OAK_AUDIOPROCESSOR_H
#include <inttypes.h>
#include <olive/core/core.h>
@@ -43,20 +43,20 @@ public:
DISABLE_COPY_MOVE(AudioProcessor)
bool Open(const AudioParams &from, const AudioParams &to,
bool open(const AudioParams &from, const AudioParams &to,
double tempo = 1.0);
void Close();
void close();
bool IsOpen() const
bool is_open() const
{
return graph_;
}
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
{
@@ -79,4 +79,4 @@ private:
}
#endif // AUDIOPROCESSOR_H
#endif // OAK_AUDIOPROCESSOR_H
+7 -7
View File
@@ -23,9 +23,9 @@
namespace olive
{
AudioSynchronizer::Placement AudioSynchronizer::PlaceBySourceTime(
AudioSynchronizer::Placement AudioSynchronizer::place_by_source_time(
const SourceClip &reference, const SourceClip &candidate,
const core::rational &reference_timeline_in)
const core::Rational &reference_timeline_in)
{
Placement placement;
if (!reference.has_source_start_time || !candidate.has_source_start_time ||
@@ -34,9 +34,9 @@ AudioSynchronizer::Placement AudioSynchronizer::PlaceBySourceTime(
return placement;
}
const core::rational reference_head_source =
const core::Rational reference_head_source =
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;
placement.timeline_in =
@@ -45,8 +45,8 @@ AudioSynchronizer::Placement AudioSynchronizer::PlaceBySourceTime(
return placement;
}
AudioSynchronizer::Placement AudioSynchronizer::PlaceByWaveformOffset(
const core::rational &reference_timeline_in,
AudioSynchronizer::Placement AudioSynchronizer::place_by_waveform_offset(
const core::Rational &reference_timeline_in,
int64_t candidate_offset_samples, int sample_rate)
{
Placement placement;
@@ -55,7 +55,7 @@ AudioSynchronizer::Placement AudioSynchronizer::PlaceByWaveformOffset(
}
placement.timeline_in = reference_timeline_in +
core::rational::fromDouble(
core::Rational::from_double(
static_cast<double>(candidate_offset_samples) /
static_cast<double>(sample_rate));
placement.valid = !placement.timeline_in.isNaN();
+9 -9
View File
@@ -18,8 +18,8 @@
***/
#ifndef AUDIOSYNCHRONIZER_H
#define AUDIOSYNCHRONIZER_H
#ifndef OAK_AUDIOSYNCHRONIZER_H
#define OAK_AUDIOSYNCHRONIZER_H
#include <cstdint>
@@ -31,25 +31,25 @@ namespace olive
class AudioSynchronizer {
public:
struct SourceClip {
core::rational source_start_time;
core::rational media_in;
core::Rational source_start_time;
core::Rational media_in;
bool has_source_start_time = false;
};
struct Placement {
core::rational timeline_in;
core::Rational timeline_in;
bool valid = false;
};
static Placement
PlaceBySourceTime(const SourceClip &reference, const SourceClip &candidate,
const core::rational &reference_timeline_in);
place_by_source_time(const SourceClip &reference, const SourceClip &candidate,
const core::Rational &reference_timeline_in);
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);
};
}
#endif // AUDIOSYNCHRONIZER_H
#endif // OAK_AUDIOSYNCHRONIZER_H
+71 -71
View File
@@ -29,19 +29,19 @@
namespace olive
{
const rational AudioVisualWaveform::kMinimumSampleRate = rational(1, 8);
const rational AudioVisualWaveform::kMaximumSampleRate = 1024;
const Rational AudioVisualWaveform::k_minimum_sample_rate = Rational(1, 8);
const Rational AudioVisualWaveform::k_maximum_sample_rate = 1024;
AudioVisualWaveform::AudioVisualWaveform()
: 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() });
}
}
void AudioVisualWaveform::OverwriteSamplesFromBuffer(
const SampleBuffer &samples, int sample_rate, const rational &start,
void AudioVisualWaveform::overwrite_samples_from_buffer(
const SampleBuffer &samples, int sample_rate, const Rational &start,
double target_rate, Sample &data, size_t &start_index,
size_t &samples_length)
{
@@ -64,16 +64,16 @@ void AudioVisualWaveform::OverwriteSamplesFromBuffer(
size_t(qRound64((double(i + channels_) * chunk_size))) / channels_,
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(),
summary.size() * sizeof(SamplePerChannel));
}
}
void AudioVisualWaveform::OverwriteSamplesFromMipmap(
void AudioVisualWaveform::overwrite_samples_from_mipmap(
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)
{
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_) {
Sample summary =
ReSumSamples(&input.data()[input_start + (i * chunk_size)],
re_sum_samples(&input.data()[input_start + (i * chunk_size)],
chunk_size * channels_, channels_);
memcpy(&output_data.data()[i + start_index], summary.data(),
@@ -102,31 +102,31 @@ void AudioVisualWaveform::OverwriteSamplesFromMipmap(
input_length = samples_length;
}
void AudioVisualWaveform::ValidateVirtualStart(const rational &new_start)
void AudioVisualWaveform::validate_virtual_start(const Rational &new_start)
{
if (length_ == 0) {
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,
const rational &start)
const Rational &start)
{
if (!channels_) {
qWarning() << "Failed to write samples - channel count is zero";
return;
}
ValidateVirtualStart(start);
validate_virtual_start(start);
// Process the largest mipmap directly for the samples
auto current_mipmap = mipmapped_data_.rbegin();
size_t input_start, input_length;
OverwriteSamplesFromBuffer(samples, sample_rate, start - virtual_start_,
current_mipmap->first.toDouble(),
overwrite_samples_from_buffer(samples, sample_rate, start - virtual_start_,
current_mipmap->first.to_double(),
current_mipmap->second, input_start,
input_length);
@@ -139,37 +139,37 @@ void AudioVisualWaveform::OverwriteSamples(const SampleBuffer &samples,
break;
}
OverwriteSamplesFromMipmap(
previous_mipmap->second, previous_mipmap->first.toDouble(),
overwrite_samples_from_mipmap(
previous_mipmap->second, previous_mipmap->first.to_double(),
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);
}
void AudioVisualWaveform::OverwriteSums(const AudioVisualWaveform &sums,
const rational &dest,
const rational &offset,
const rational &length)
void AudioVisualWaveform::overwrite_sums(const AudioVisualWaveform &sums,
const Rational &dest,
const Rational &offset,
const Rational &length)
{
ValidateVirtualStart(dest);
validate_virtual_start(dest);
for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) {
rational rate = it->first;
Rational rate = it->first;
Sample &our_arr = it->second;
const Sample &their_arr = sums.mipmapped_data_.at(rate);
double rate_dbl = rate.toDouble();
double rate_dbl = rate.to_double();
// Get our destination sample
size_t our_start_index =
time_to_samples(dest - virtual_start_, rate_dbl);
// 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();
if (their_start_index >= their_arr.size()) {
continue;
@@ -201,17 +201,17 @@ void AudioVisualWaveform::OverwriteSums(const AudioVisualWaveform &sums,
length));
}
void AudioVisualWaveform::OverwriteSilence(const rational &start,
const rational &length)
void AudioVisualWaveform::overwrite_silence(const Rational &start,
const Rational &length)
{
ValidateVirtualStart(start);
validate_virtual_start(start);
for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) {
rational rate = it->first;
Rational rate = it->first;
Sample &our_arr = it->second;
double rate_dbl = rate.toDouble();
double rate_dbl = rate.to_double();
// Get our destination sample
size_t our_start_index =
@@ -231,7 +231,7 @@ void AudioVisualWaveform::OverwriteSilence(const rational &start,
length_ = qMax(length_, start + length);
}
void AudioVisualWaveform::TrimIn(rational length)
void AudioVisualWaveform::trim_in(Rational length)
{
if (length == 0) {
return;
@@ -245,8 +245,8 @@ void AudioVisualWaveform::TrimIn(rational length)
}
for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) {
rational rate = it->first;
double rate_dbl = rate.toDouble();
Rational rate = it->first;
double rate_dbl = rate.to_double();
Sample &data = it->second;
size_t chop_length = time_to_samples(length, rate_dbl);
@@ -262,40 +262,40 @@ void AudioVisualWaveform::TrimIn(rational length)
}
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
// end (which length_ tracks) is unchanged
}
AudioVisualWaveform AudioVisualWaveform::Mid(const rational &offset) const
AudioVisualWaveform AudioVisualWaveform::mid(const Rational &offset) const
{
AudioVisualWaveform mid = *this;
mid.TrimIn(offset - virtual_start_);
mid.trim_in(offset - virtual_start_);
return mid;
}
AudioVisualWaveform AudioVisualWaveform::Mid(const rational &offset,
const rational &length) const
AudioVisualWaveform AudioVisualWaveform::mid(const Rational &offset,
const Rational &length) const
{
AudioVisualWaveform mid = *this;
mid.TrimRange(offset - virtual_start_, length);
mid.trim_range(offset - virtual_start_, length);
return mid;
}
void AudioVisualWaveform::Resize(const rational &length)
void AudioVisualWaveform::resize(const Rational &length)
{
if (length_ == length) {
return;
}
for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) {
rational rate = it->first;
double rate_dbl = rate.toDouble();
Rational rate = it->first;
double rate_dbl = rate.to_double();
Sample &data = it->second;
size_t chop_length = time_to_samples(length, rate_dbl);
@@ -306,20 +306,20 @@ void AudioVisualWaveform::Resize(const rational &length)
length_ = length;
}
void AudioVisualWaveform::TrimRange(const rational &in, const rational &length)
void AudioVisualWaveform::trim_range(const Rational &in, const Rational &length)
{
TrimIn(in);
Resize(length);
trim_in(in);
resize(length);
}
AudioVisualWaveform::Sample
AudioVisualWaveform::GetSummaryFromTime(const rational &start,
const rational &length) const
AudioVisualWaveform::get_summary_from_time(const Rational &start,
const Rational &length) const
{
// 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 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));
if (sample_length > 0) {
return ReSumSamples(&mipmap_data.data()[start_sample],
return re_sum_samples(&mipmap_data.data()[start_sample],
sample_length, channels_);
}
}
@@ -342,7 +342,7 @@ AudioVisualWaveform::GetSummaryFromTime(const rational &start,
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)
{
#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::SumSamples(const SampleBuffer &samples, size_t start_index,
AudioVisualWaveform::sum_samples(const SampleBuffer &samples, size_t start_index,
size_t length)
{
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();
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].max);
}
@@ -409,7 +409,7 @@ AudioVisualWaveform::SumSamples(const SampleBuffer &samples, size_t start_index,
}
AudioVisualWaveform::Sample
AudioVisualWaveform::ReSumSamples(const SamplePerChannel *samples,
AudioVisualWaveform::re_sum_samples(const SamplePerChannel *samples,
size_t nb_samples, int 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);
}
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)
{
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 AudioVisualWaveform &samples,
const rational &start_time)
const Rational &start_time)
{
if (samples.mipmapped_data_.empty()) {
return;
}
auto using_mipmap = samples.GetMipmapForScale(scale);
auto using_mipmap = samples.get_mipmap_for_scale(scale);
rational rate = using_mipmap->first;
double rate_dbl = rate.toDouble();
Rational rate = using_mipmap->first;
double rate_dbl = rate.to_double();
const Sample &arr = using_mipmap->second;
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 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++) {
sample_index = next_sample_index;
@@ -526,7 +526,7 @@ void AudioVisualWaveform::DrawWaveform(QPainter *painter, const QRect &rect,
samples.channel_count()));
if (summary_index != sample_index) {
summary = AudioVisualWaveform::ReSumSamples(
summary = AudioVisualWaveform::re_sum_samples(
&arr.at(sample_index),
qMax(size_t(samples.channel_count()),
next_sample_index - sample_index),
@@ -534,14 +534,14 @@ void AudioVisualWaveform::DrawWaveform(QPainter *painter, const QRect &rect,
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
{
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,
@@ -550,13 +550,13 @@ size_t AudioVisualWaveform::time_to_samples(const double &time,
return std::floor(time * sample_rate) * channels_;
}
std::map<rational, AudioVisualWaveform::Sample>::const_iterator
AudioVisualWaveform::GetMipmapForScale(double scale) const
std::map<Rational, AudioVisualWaveform::Sample>::const_iterator
AudioVisualWaveform::get_mipmap_for_scale(double scale) const
{
// 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();
it++) {
if (it->first.toDouble() >= scale) {
if (it->first.to_double() >= scale) {
return it;
}
}
+35 -35
View File
@@ -19,8 +19,8 @@
***/
#ifndef SUMSAMPLES_H
#define SUMSAMPLES_H
#ifndef OAK_SUMSAMPLES_H
#define OAK_SUMSAMPLES_H
#include <olive/core/core.h>
#include <QPainter>
@@ -58,7 +58,7 @@ public:
channels_ = channels;
}
const rational &length() const
const Rational &length() const
{
return length_;
}
@@ -68,8 +68,8 @@ public:
*
* Starting at `start`, writes samples over anything in the buffer, expanding it if necessary.
*/
void OverwriteSamples(const SampleBuffer &samples, int sample_rate,
const rational &start = 0);
void overwrite_samples(const SampleBuffer &samples, int sample_rate,
const Rational &start = 0);
/**
* @brief Replaces sums at a certain range in this visual waveform
@@ -90,74 +90,74 @@ public:
*
* Maximum length of `sums` to overwrite with.
*/
void OverwriteSums(const AudioVisualWaveform &sums, const rational &dest,
const rational &offset = 0, const rational &length = 0);
void overwrite_sums(const AudioVisualWaveform &sums, const Rational &dest,
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 rational &length) const;
AudioVisualWaveform mid(const Rational &offset) const;
AudioVisualWaveform mid(const Rational &offset,
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,
const rational &length) const;
Sample get_summary_from_time(const Rational &start,
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);
static Sample ReSumSamples(const SamplePerChannel *samples,
static Sample re_sum_samples(const SamplePerChannel *samples,
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);
static void DrawWaveform(QPainter *painter, const QRect &rect,
static void draw_waveform(QPainter *painter, const QRect &rect,
const double &scale,
const AudioVisualWaveform &samples,
const rational &start_time);
const Rational &start_time);
// Must be a power of 2
static const rational kMinimumSampleRate;
static const rational kMaximumSampleRate;
static const Rational k_minimum_sample_rate;
static const Rational k_maximum_sample_rate;
private:
void OverwriteSamplesFromBuffer(const SampleBuffer &samples,
int sample_rate, const rational &start,
void overwrite_samples_from_buffer(const SampleBuffer &samples,
int sample_rate, const Rational &start,
double target_rate, Sample &data,
size_t &start_index,
size_t &samples_length);
void OverwriteSamplesFromMipmap(const Sample &input,
void overwrite_samples_from_mipmap(const Sample &input,
double input_sample_rate,
size_t &input_start, size_t &input_length,
const rational &start, double output_rate,
const Rational &start, double output_rate,
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;
std::map<rational, Sample>::const_iterator
GetMipmapForScale(double scale) const;
std::map<Rational, Sample>::const_iterator
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_;
std::map<rational, Sample> mipmapped_data_;
std::map<Rational, Sample> mipmapped_data_;
rational length_;
Rational length_;
};
}
Q_DECLARE_METATYPE(olive::AudioVisualWaveform)
#endif // SUMSAMPLES_H
#endif // OAK_SUMSAMPLES_H
+10 -10
View File
@@ -27,7 +27,7 @@ namespace olive
{
QVector<double>
AudioWaveformSync::ExtractRmsEnvelope(const core::SampleBuffer &samples,
AudioWaveformSync::extract_rms_envelope(const core::SampleBuffer &samples,
size_t window_samples)
{
QVector<double> envelope;
@@ -64,7 +64,7 @@ AudioWaveformSync::ExtractRmsEnvelope(const core::SampleBuffer &samples,
return envelope;
}
AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateOffset(
AudioWaveformSync::OffsetResult AudioWaveformSync::estimate_offset(
const core::SampleBuffer &reference, const core::SampleBuffer &candidate,
size_t window_samples, int64_t max_offset_samples)
{
@@ -73,26 +73,26 @@ AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateOffset(
}
const QVector<double> reference_envelope =
ExtractRmsEnvelope(reference, window_samples);
extract_rms_envelope(reference, window_samples);
const QVector<double> candidate_envelope =
ExtractRmsEnvelope(candidate, window_samples);
extract_rms_envelope(candidate, window_samples);
const int64_t max_offset_windows =
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);
}
AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateEnvelopeOffset(
AudioWaveformSync::OffsetResult AudioWaveformSync::estimate_envelope_offset(
const QVector<double> &reference, const QVector<double> &candidate,
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,
max_offset_windows);
}
AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateEnvelopeOffset(
AudioWaveformSync::OffsetResult AudioWaveformSync::estimate_envelope_offset(
const QVector<double> &reference, const QVector<double> &candidate,
const QVector<bool> &reference_valid, const QVector<bool> &candidate_valid,
size_t window_samples, int64_t max_offset_windows)
@@ -185,7 +185,7 @@ AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateEnvelopeOffset(
return result;
}
AudioWaveformSync::StretchOffsetResult AudioWaveformSync::EstimateStretchAndOffset(
AudioWaveformSync::StretchOffsetResult AudioWaveformSync::estimate_stretch_and_offset(
const QVector<double> &reference, const QVector<double> &candidate,
const QVector<bool> &reference_valid, const QVector<bool> &candidate_valid,
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)));
}
const OffsetResult offset = EstimateEnvelopeOffset(
const OffsetResult offset = estimate_envelope_offset(
reference, resampled, reference_valid, resampled_valid,
window_samples, max_offset_windows);
+8 -8
View File
@@ -18,8 +18,8 @@
***/
#ifndef AUDIOWAVEFORMSYNC_H
#define AUDIOWAVEFORMSYNC_H
#ifndef OAK_AUDIOWAVEFORMSYNC_H
#define OAK_AUDIOWAVEFORMSYNC_H
#include <cstdint>
@@ -48,15 +48,15 @@ public:
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);
static OffsetResult EstimateOffset(const core::SampleBuffer &reference,
static OffsetResult estimate_offset(const core::SampleBuffer &reference,
const core::SampleBuffer &candidate,
size_t window_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,
size_t window_samples,
int64_t max_offset_windows);
@@ -71,7 +71,7 @@ public:
* waveform cache have not been generated yet. Empty masks are treated as
* "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<bool> &reference_valid,
const QVector<bool> &candidate_valid,
@@ -89,7 +89,7 @@ public:
* callers should bound max_offset_windows to a sensible range.
*/
static StretchOffsetResult
EstimateStretchAndOffset(const QVector<double> &reference,
estimate_stretch_and_offset(const QVector<double> &reference,
const QVector<double> &candidate,
const QVector<bool> &reference_valid,
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
#define CLIEXPORTMANAGER_H
#ifndef OAK_CLIEXPORTMANAGER_H
#define OAK_CLIEXPORTMANAGER_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)
, drawn_(false)
{
SetProgress(0);
set_progress(0);
}
void CLIProgressDialog::Update()
void CLIProgressDialog::update()
{
if (drawn_) {
// 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;
}
void CLIProgressDialog::SetProgress(double p)
void CLIProgressDialog::set_progress(double p)
{
if (progress_ != p) {
progress_ = p;
Update();
update();
}
}
+5 -5
View File
@@ -19,8 +19,8 @@
***/
#ifndef CLIPROGRESSDIALOG_H
#define CLIPROGRESSDIALOG_H
#ifndef OAK_CLIPROGRESSDIALOG_H
#define OAK_CLIPROGRESSDIALOG_H
#include <QObject>
#include <QTimer>
@@ -35,10 +35,10 @@ public:
CLIProgressDialog(const QString &title, QObject *parent = nullptr);
public slots:
void SetProgress(double p);
void set_progress(double p);
private:
void Update();
void update();
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)
: CLIProgressDialog(task->GetTitle(), parent)
: CLIProgressDialog(task->get_title(), parent)
, 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
#define CLITASKDIALOG_H
#ifndef OAK_CLITASKDIALOG_H
#define OAK_CLITASKDIALOG_H
#include "cli/cliprogress/cliprogressdialog.h"
#include "task/task.h"
@@ -33,7 +33,7 @@ class CLITaskDialog : public CLIProgressDialog {
public:
CLITaskDialog(Task *task, QObject *parent = nullptr);
bool Run();
bool run();
private:
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::Conform ConformManager::GetConformState(
ConformManager::Conform ConformManager::get_conform_state(
const QString &decoder_id, const QString &cache_path,
const Decoder::CodecStream &stream, const AudioParams &params, bool wait)
{
@@ -36,9 +36,9 @@ ConformManager::Conform ConformManager::GetConformState(
// Return existing conform if exists
QVector<QString> filenames =
GetConformedFilename(cache_path, stream, params);
if (AllConformsExist(filenames)) {
return { kConformExists, filenames, nullptr };
get_conformed_filename(cache_path, stream, params);
if (all_conforms_exist(filenames)) {
return { k_conform_exists, filenames, nullptr };
}
ConformTask *conforming_task = nullptr;
@@ -63,10 +63,10 @@ ConformManager::Conform ConformManager::GetConformState(
conforming_task =
new ConformTask(decoder_id, stream, params, working_filenames);
connect(conforming_task, &ConformTask::Finished, this,
&ConformManager::ConformTaskFinished);
connect(conforming_task, &ConformTask::finished, this,
&ConformManager::conform_task_finished);
conforming_task->moveToThread(TaskManager::instance()->thread());
QMetaObject::invokeMethod(TaskManager::instance(), "AddTask",
QMetaObject::invokeMethod(TaskManager::instance(), "add_task",
Qt::QueuedConnection,
Q_ARG(Task *, conforming_task));
@@ -77,15 +77,15 @@ ConformManager::Conform ConformManager::GetConformState(
if (wait) {
do {
conform_done_condition_.wait(&mutex_);
} while (!AllConformsExist(filenames));
return { kConformExists, filenames, nullptr };
} while (!all_conforms_exist(filenames));
return { k_conform_exists, filenames, nullptr };
}
return { kConformGenerating, QVector<QString>(), conforming_task };
return { k_conform_generating, QVector<QString>(), conforming_task };
}
QVector<QString>
ConformManager::GetConformedFilename(const QString &cache_path,
ConformManager::get_conformed_filename(const QString &cache_path,
const Decoder::CodecStream &stream,
const AudioParams &params)
{
@@ -94,7 +94,7 @@ ConformManager::GetConformedFilename(const QString &cache_path,
for (int i = 0; i < filenames.size(); i++) {
QString index_fn =
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(params.sample_rate()),
QString::number(params.format()),
@@ -107,7 +107,7 @@ ConformManager::GetConformedFilename(const QString &cache_path,
return filenames;
}
bool ConformManager::AllConformsExist(const QVector<QString> &filenames)
bool ConformManager::all_conforms_exist(const QVector<QString> &filenames)
{
foreach (const QString &fn, filenames) {
if (!QFileInfo::exists(fn)) {
@@ -118,7 +118,7 @@ bool ConformManager::AllConformsExist(const QVector<QString> &filenames)
return true;
}
void ConformManager::ConformTaskFinished(Task *task, bool succeeded)
void ConformManager::conform_task_finished(Task *task, bool succeeded)
{
QMutexLocker locker(&mutex_);
@@ -146,7 +146,7 @@ void ConformManager::ConformTaskFinished(Task *task, bool succeeded)
conform_done_condition_.wakeAll();
locker.unlock();
emit ConformReady();
emit conform_ready();
} else {
// Failed, just delete the working filename if exists
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/>.
*/
#ifndef CONFORMMANAGER_H
#define CONFORMMANAGER_H
#ifndef OAK_CONFORMMANAGER_H
#define OAK_CONFORMMANAGER_H
#include <QMutex>
#include <QObject>
@@ -31,14 +31,14 @@ namespace olive
class ConformManager : public QObject {
Q_OBJECT
public:
static void CreateInstance()
static void create_instance()
{
if (!instance_) {
instance_ = new ConformManager();
}
}
static void DestroyInstance()
static void destroy_instance()
{
delete instance_;
instance_ = nullptr;
@@ -49,7 +49,7 @@ public:
return instance_;
}
enum ConformState { kConformExists, kConformGenerating };
enum ConformState { k_conform_exists, k_conform_generating };
struct Conform {
ConformState state;
@@ -62,13 +62,13 @@ public:
*
* Thread-safe.
*/
Conform GetConformState(const QString &decoder_id,
Conform get_conform_state(const QString &decoder_id,
const QString &cache_path,
const Decoder::CodecStream &stream,
const AudioParams &params, bool wait);
signals:
void ConformReady();
void conform_ready();
private:
ConformManager() = default;
@@ -93,16 +93,16 @@ private:
* @brief Get the destination filename of an audio stream conformed to a set of parameters
*/
static QVector<QString>
GetConformedFilename(const QString &cache_path,
get_conformed_filename(const QString &cache_path,
const Decoder::CodecStream &stream,
const AudioParams &params);
static bool AllConformsExist(const QVector<QString> &filenames);
static bool all_conforms_exist(const QVector<QString> &filenames);
private slots:
void ConformTaskFinished(Task *task, bool succeeded);
void conform_task_finished(Task *task, bool succeeded);
};
} // namespace olive
#endif // CONFORMMANAGER_H
#endif // OAK_CONFORMMANAGER_H
+62 -62
View File
@@ -33,26 +33,26 @@
namespace olive
{
const rational Decoder::kAnyTimecode = RATIONAL_MIN;
const Rational Decoder::k_any_timecode = RATIONAL_MIN;
Decoder::Decoder()
: cached_texture_(nullptr)
{
UpdateLastAccessed();
update_last_accessed();
}
void Decoder::IncrementAccessTime(qint64 t)
void Decoder::increment_access_time(qint64 t)
{
last_accessed_ += t;
}
bool Decoder::Open(const CodecStream &stream)
bool Decoder::open(const CodecStream &stream)
{
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.
if (stream_ == stream) {
return true;
@@ -63,13 +63,13 @@ bool Decoder::Open(const CodecStream &stream)
}
} else {
// Stream was not open, try opening it now
if (!stream.IsValid()) {
if (!stream.is_valid()) {
// Cannot open null stream
qCritical() << "Decoder attempted to open null stream";
return false;
}
if (!stream.Exists()) {
if (!stream.exists()) {
// Cannot open file that doesn't exist
qCritical() << "Decoder attempted to open file that doesn't exist";
return false;
@@ -79,36 +79,36 @@ bool Decoder::Open(const CodecStream &stream)
stream_ = stream;
// Try open internal
if (OpenInternal()) {
if (open_internal()) {
return true;
} else {
// Unset stream
qCritical() << "Failed to open" << stream_.filename() << "stream"
<< stream_.stream();
CloseInternal();
stream_.Reset();
close_internal();
stream_.reset();
return false;
}
}
}
TexturePtr Decoder::RetrieveVideo(const RetrieveVideoParams &p)
TexturePtr Decoder::retrieve_video(const RetrieveVideoParams &p)
{
QMutexLocker locker(&mutex_);
UpdateLastAccessed();
update_last_accessed();
if (!stream_.IsValid()) {
if (!stream_.is_valid()) {
qCritical() << "Can't retrieve video on a closed decoder";
return nullptr;
}
if (!SupportsVideo()) {
if (!supports_video()) {
qCritical() << "Decoder doesn't support video";
return nullptr;
}
if (p.cancelled && p.cancelled->IsCancelled()) {
if (p.cancelled && p.cancelled->is_cancelled()) {
return nullptr;
}
@@ -117,110 +117,110 @@ TexturePtr Decoder::RetrieveVideo(const RetrieveVideoParams &p)
return cached_texture_;
}
cached_texture_ = RetrieveVideoInternal(p);
cached_texture_ = retrieve_video_internal(p);
cached_time_ = p.time;
cached_divider_ = p.divider;
return cached_texture_;
}
FramePtr Decoder::RetrieveVideoFrame(const RetrieveVideoParams &p)
FramePtr Decoder::retrieve_video_frame(const RetrieveVideoParams &p)
{
QMutexLocker locker(&mutex_);
UpdateLastAccessed();
update_last_accessed();
if (!stream_.IsValid()) {
if (!stream_.is_valid()) {
qCritical() << "Can't retrieve video frame on a closed decoder";
return nullptr;
}
if (!SupportsVideo()) {
if (!supports_video()) {
qCritical() << "Decoder doesn't support video";
return nullptr;
}
if (p.cancelled && p.cancelled->IsCancelled()) {
if (p.cancelled && p.cancelled->is_cancelled()) {
return nullptr;
}
return RetrieveVideoFrameInternal(p);
return retrieve_video_frame_internal(p);
}
Decoder::RetrieveAudioStatus
Decoder::RetrieveAudio(SampleBuffer &dest, const TimeRange &range,
Decoder::retrieve_audio(SampleBuffer &dest, const TimeRange &range,
const AudioParams &params, const QString &cache_path,
LoopMode loop_mode, RenderMode::Mode mode)
{
QMutexLocker locker(&mutex_);
UpdateLastAccessed();
update_last_accessed();
if (!stream_.IsValid()) {
if (!stream_.is_valid()) {
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";
return kInvalid;
return k_invalid;
}
if (params.sample_rate() <= 0 || params.channel_count() <= 0) {
qWarning() << "Invalid audio parameters, skipping audio retrieve";
return kInvalid;
return k_invalid;
}
// Get conform state from ConformManager
ConformManager::Conform conform =
ConformManager::instance()->GetConformState(
id(), cache_path, stream_, params, (mode == RenderMode::kOnline));
if (conform.state == ConformManager::kConformGenerating) {
ConformManager::instance()->get_conform_state(
id(), cache_path, stream_, params, (mode == RenderMode::k_online));
if (conform.state == ConformManager::k_conform_generating) {
// If we need the task, it's available in `conform.task`
return kWaitingForConform;
return k_waiting_for_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)) {
return kOK;
return k_ok;
} else {
return kUnknownError;
return k_unknown_error;
}
}
qint64 Decoder::GetLastAccessedTime()
qint64 Decoder::get_last_accessed_time()
{
return last_accessed_;
}
void Decoder::Close()
void Decoder::close()
{
QMutexLocker locker(&mutex_);
UpdateLastAccessed();
update_last_accessed();
cached_texture_ = nullptr;
if (stream_.IsValid()) {
CloseInternal();
stream_.Reset();
if (stream_.is_valid()) {
close_internal();
stream_.reset();
} else {
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)
{
return ConformAudioInternal(output_filenames, params, cancelled);
return conform_audio_internal(output_filenames, params, cancelled);
}
/*
* DECODER STATIC PUBLIC MEMBERS
*/
QVector<DecoderPtr> Decoder::ReceiveListOfAllDecoders()
QVector<DecoderPtr> Decoder::receive_list_of_all_decoders()
{
QVector<DecoderPtr> decoders;
@@ -232,14 +232,14 @@ QVector<DecoderPtr> Decoder::ReceiveListOfAllDecoders()
return decoders;
}
DecoderPtr Decoder::CreateFromID(const QString &id)
DecoderPtr Decoder::create_from_id(const QString &id)
{
if (id.isEmpty()) {
return nullptr;
}
// Create list to iterate through
QVector<DecoderPtr> decoder_list = ReceiveListOfAllDecoders();
QVector<DecoderPtr> decoder_list = receive_list_of_all_decoders();
foreach (DecoderPtr d, decoder_list) {
if (d->id() == id) {
@@ -250,18 +250,18 @@ DecoderPtr Decoder::CreateFromID(const QString &id)
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) {
emit IndexProgress(static_cast<double>(ts) /
emit index_progress(static_cast<double>(ts) /
static_cast<double>(duration));
}
}
QString Decoder::TransformImageSequenceFileName(const QString &filename,
QString Decoder::transform_image_sequence_file_name(const QString &filename,
const int64_t &number)
{
int digit_count = GetImageSequenceDigitCount(filename);
int digit_count = get_image_sequence_digit_count(filename);
QFileInfo file_info(filename);
@@ -276,7 +276,7 @@ QString Decoder::TransformImageSequenceFileName(const QString &filename,
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();
@@ -294,9 +294,9 @@ int Decoder::GetImageSequenceDigitCount(const QString &filename)
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);
@@ -308,19 +308,19 @@ int64_t Decoder::GetImageSequenceIndex(const QString &filename)
return number_only.toLongLong();
}
TexturePtr Decoder::RetrieveVideoInternal(const RetrieveVideoParams &p)
TexturePtr Decoder::retrieve_video_internal(const RetrieveVideoParams &p)
{
Q_UNUSED(p)
return nullptr;
}
FramePtr Decoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p)
FramePtr Decoder::retrieve_video_frame_internal(const RetrieveVideoParams &p)
{
Q_UNUSED(p)
return nullptr;
}
bool Decoder::ConformAudioInternal(const QVector<QString> &filenames,
bool Decoder::conform_audio_internal(const QVector<QString> &filenames,
const AudioParams &params,
CancelAtom *cancelled)
{
@@ -330,14 +330,14 @@ bool Decoder::ConformAudioInternal(const QVector<QString> &filenames,
return false;
}
bool Decoder::RetrieveAudioFromConform(
bool Decoder::retrieve_audio_from_conform(
SampleBuffer &sample_buffer, const QVector<QString> &conform_filenames,
TimeRange range, LoopMode loop_mode, const AudioParams &input_params)
{
PlanarFileDevice input;
if (input.open(conform_filenames, QFile::ReadOnly)) {
// Offset range by audio start offset
range -= GetAudioStartOffset();
range -= get_audio_start_offset();
qint64 read_index = input_params.time_to_bytes(range.in()) /
input_params.channel_count();
@@ -348,7 +348,7 @@ bool Decoder::RetrieveAudioFromConform(
input_params.bytes_per_sample_per_channel();
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()) {
read_index -= input.size();
}
@@ -391,7 +391,7 @@ bool Decoder::RetrieveAudioFromConform(
return false;
}
void Decoder::UpdateLastAccessed()
void Decoder::update_last_accessed()
{
last_accessed_ = QDateTime::currentMSecsSinceEpoch();
}
+45 -45
View File
@@ -19,8 +19,8 @@
***/
#ifndef DECODER_H
#define DECODER_H
#ifndef OAK_DECODER_H
#define OAK_DECODER_H
#include <QFileInfo>
#include <QMutex>
@@ -43,7 +43,7 @@ using DecoderPtr = std::shared_ptr<Decoder>;
#define DECODER_DEFAULT_DESTRUCTOR(x) \
virtual ~x() override \
{ \
CloseInternal(); \
close_internal(); \
}
/**
@@ -65,7 +65,7 @@ using DecoderPtr = std::shared_ptr<Decoder>;
class Decoder : public QObject {
Q_OBJECT
public:
enum RetrieveState { kReady, kFailedToOpen, kIndexUnavailable };
enum RetrieveState { k_ready, k_failed_to_open, k_index_unavailable };
Decoder();
@@ -74,16 +74,16 @@ public:
*/
virtual QString id() const = 0;
virtual bool SupportsVideo()
virtual bool supports_video()
{
return false;
}
virtual bool SupportsAudio()
virtual bool supports_audio()
{
return false;
}
void IncrementAccessTime(qint64 t);
void increment_access_time(qint64 t);
class CodecStream {
public:
@@ -100,17 +100,17 @@ public:
{
}
bool IsValid() const
bool is_valid() const
{
return !filename_.isEmpty() && stream_ >= 0;
}
bool Exists() const
bool exists() const
{
return QFileInfo::exists(filename_);
}
void Reset()
void reset()
{
*this = CodecStream();
}
@@ -152,18 +152,18 @@ public:
* 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.
*/
bool Open(const CodecStream &stream);
bool open(const CodecStream &stream);
static const rational kAnyTimecode;
static const Rational k_any_timecode;
struct RetrieveVideoParams {
Renderer *renderer = nullptr;
rational time;
Rational time;
int divider = 1;
PixelFormat maximum_format = PixelFormat::INVALID;
PixelFormat maximum_format = PixelFormat::invalid;
CancelAtom *cancelled = nullptr;
VideoParams::ColorRange force_range = VideoParams::kColorRangeDefault;
VideoParams::Interlacing src_interlacing = VideoParams::kInterlaceNone;
VideoParams::ColorRange force_range = VideoParams::k_color_range_default;
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()
*/
TexturePtr RetrieveVideo(const RetrieveVideoParams &p);
TexturePtr retrieve_video(const RetrieveVideoParams &p);
/**
* @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
* data to workers through shared memory.
*/
FramePtr RetrieveVideoFrame(const RetrieveVideoParams &p);
FramePtr retrieve_video_frame(const RetrieveVideoParams &p);
enum RetrieveAudioStatus {
kInvalid = -1,
kOK,
kWaitingForConform,
kUnknownError
k_invalid = -1,
k_ok,
k_waiting_for_conform,
k_unknown_error
};
/**
@@ -202,14 +202,14 @@ public:
* This function is thread safe and can only run while the decoder is open. \see Open()
*/
RetrieveAudioStatus
RetrieveAudio(SampleBuffer &dest, const TimeRange &range,
retrieve_audio(SampleBuffer &dest, const TimeRange &range,
const AudioParams &params, const QString &cache_path,
LoopMode loop_mode, RenderMode::Mode mode);
/**
* @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
@@ -222,7 +222,7 @@ public:
*
* This function is re-entrant.
*/
virtual FootageDescription Probe(const QString &filename,
virtual FootageDescription probe(const QString &filename,
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()
*/
void Close();
void close();
/**
* @brief Conform audio stream
*/
bool ConformAudio(const QVector<QString> &output_filenames,
bool conform_audio(const QVector<QString> &output_filenames,
const AudioParams &params,
CancelAtom *cancelled = nullptr);
@@ -246,16 +246,16 @@ public:
*
* 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);
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:
/**
@@ -267,10 +267,10 @@ protected:
* 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 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.
*/
virtual bool OpenInternal() = 0;
virtual bool open_internal() = 0;
/**
* @brief Internal close function
@@ -278,7 +278,7 @@ protected:
* 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.
*/
virtual void CloseInternal() = 0;
virtual void close_internal() = 0;
/**
* @brief Internal frame retrieval function
@@ -286,15 +286,15 @@ protected:
* 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.
*/
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,
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
@@ -306,7 +306,7 @@ protected:
return stream_;
}
virtual rational GetAudioStartOffset() const
virtual Rational get_audio_start_offset() const
{
return 0;
}
@@ -316,12 +316,12 @@ signals:
* @brief While indexing, this signal will provide progress as a percentage (0-100 inclusive) if
* available
*/
void IndexProgress(double);
void index_progress(double);
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,
TimeRange range, LoopMode loop_mode,
const AudioParams &params);
@@ -333,7 +333,7 @@ private:
std::atomic_int64_t last_accessed_;
TexturePtr cached_texture_;
rational cached_time_;
Rational cached_time_;
int cached_divider_;
};
@@ -343,4 +343,4 @@ uint qHash(Decoder::CodecStream stream, uint seed = 0);
Q_DECLARE_METATYPE(olive::Decoder::RetrieveState)
#endif // DECODER_H
#endif // OAK_DECODER_H
+82 -82
View File
@@ -30,9 +30,9 @@
namespace olive
{
const QRegularExpression Encoder::kImageSequenceContainsDigits =
const QRegularExpression Encoder::k_image_sequence_contains_digits =
QRegularExpression(QStringLiteral("\\[[#]+\\]"));
const QRegularExpression Encoder::kImageSequenceRemoveDigits =
const QRegularExpression Encoder::k_image_sequence_remove_digits =
QRegularExpression(QStringLiteral("[\\-\\.\\ \\_]?\\[[#]+\\]"));
Encoder::Encoder(const EncodingParams &params)
@@ -45,18 +45,18 @@ const EncodingParams &Encoder::params() const
return params_;
}
QString Encoder::GetFilenameForFrame(const rational &frame)
QString Encoder::get_filename_for_frame(const Rational &frame)
{
if (params().video_is_image_sequence()) {
// Transform!
int64_t frame_index = Timecode::time_to_timestamp(
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 =
QStringLiteral("%1").arg(frame_index, digits, 10, QChar('0'));
QString f = params_.filename();
f.replace(kImageSequenceContainsDigits, frame_index_str);
f.replace(k_image_sequence_contains_digits, frame_index_str);
return f;
} else {
// 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;
for (int i = start + 1; i < filename.size(); i++) {
if (filename.at(i) == '#') {
@@ -78,14 +78,14 @@ int Encoder::GetImageSequencePlaceholderDigitCount(const QString &filename)
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()
@@ -100,24 +100,24 @@ EncodingParams::EncodingParams()
, audio_bit_rate_(0)
, subtitles_enabled_(false)
, subtitles_are_sidecar_(false)
, video_scaling_method_(kStretch)
, video_scaling_method_(k_stretch)
, 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"));
}
QStringList EncodingParams::GetListOfPresets()
QStringList EncodingParams::get_list_of_presets()
{
QDir d = EncodingParams::GetPresetPath();
QDir d = EncodingParams::get_preset_path();
return d.entryList(QDir::Files);
}
void EncodingParams::EnableVideo(const VideoParams &video_params,
void EncodingParams::enable_video(const VideoParams &video_params,
const ExportCodec::Codec &vcodec)
{
video_enabled_ = true;
@@ -125,7 +125,7 @@ void EncodingParams::EnableVideo(const VideoParams &video_params,
video_codec_ = vcodec;
}
void EncodingParams::EnableAudio(const AudioParams &audio_params,
void EncodingParams::enable_audio(const AudioParams &audio_params,
const ExportCodec::Codec &acodec)
{
audio_enabled_ = true;
@@ -133,13 +133,13 @@ void EncodingParams::EnableAudio(const AudioParams &audio_params,
audio_codec_ = acodec;
}
void EncodingParams::EnableSubtitles(const ExportCodec::Codec &scodec)
void EncodingParams::enable_subtitles(const ExportCodec::Codec &scodec)
{
subtitles_enabled_ = true;
subtitles_codec_ = scodec;
}
void EncodingParams::EnableSidecarSubtitles(const ExportFormat::Format &sfmt,
void EncodingParams::enable_sidecar_subtitles(const ExportFormat::Format &sfmt,
const ExportCodec::Codec &scodec)
{
subtitles_enabled_ = true;
@@ -148,24 +148,24 @@ void EncodingParams::EnableSidecarSubtitles(const ExportFormat::Format &sfmt,
subtitles_codec_ = scodec;
}
void EncodingParams::DisableVideo()
void EncodingParams::disable_video()
{
video_enabled_ = false;
}
void EncodingParams::DisableAudio()
void EncodingParams::disable_audio()
{
audio_enabled_ = false;
}
void EncodingParams::DisableSubtitles()
void EncodingParams::disable_subtitles()
{
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")) {
int version = 0;
@@ -178,7 +178,7 @@ bool EncodingParams::Load(QXmlStreamReader *reader)
switch (version) {
case 1:
return LoadV1(reader);
return load_v1(reader);
}
} else {
reader->skipCurrentElement();
@@ -188,26 +188,26 @@ bool EncodingParams::Load(QXmlStreamReader *reader)
return false;
}
bool EncodingParams::Load(QIODevice *device)
bool EncodingParams::load(QIODevice *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);
Save(&writer);
save(&writer);
}
void EncodingParams::Save(QXmlStreamWriter *writer) const
void EncodingParams::save(QXmlStreamWriter *writer) const
{
writer->writeStartDocument();
writer->writeStartElement(QStringLiteral("export"));
writer->writeAttribute(QStringLiteral("version"),
QString::number(kEncoderParamsVersion));
QString::number(k_encoder_params_version));
writer->writeTextElement(QStringLiteral("filename"), filename_);
writer->writeTextElement(QStringLiteral("format"),
@@ -217,10 +217,10 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
QString::number(has_custom_range_));
writer->writeTextElement(
QStringLiteral("customrangein"),
QString::fromStdString(custom_range_.in().toString()));
QString::fromStdString(custom_range_.in().to_string()));
writer->writeTextElement(
QStringLiteral("customrangeout"),
QString::fromStdString(custom_range_.out().toString()));
QString::fromStdString(custom_range_.out().to_string()));
writer->writeStartElement(QStringLiteral("video"));
@@ -239,10 +239,10 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
writer->writeTextElement(
QStringLiteral("pixelaspect"),
QString::fromStdString(
video_params_.pixel_aspect_ratio().toString()));
video_params_.pixel_aspect_ratio().to_string()));
writer->writeTextElement(
QStringLiteral("timebase"),
QString::fromStdString(video_params_.time_base().toString()));
QString::fromStdString(video_params_.time_base().to_string()));
writer->writeTextElement(QStringLiteral("divider"),
QString::number(video_params_.divider()));
writer->writeTextElement(QStringLiteral("bitrate"),
@@ -332,77 +332,77 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
writer->writeEndDocument();
}
Encoder *Encoder::CreateFromID(Type id, const EncodingParams &params)
Encoder *Encoder::create_from_id(Type id, const EncodingParams &params)
{
switch (id) {
case kEncoderTypeNone:
case k_encoder_type_none:
break;
case kEncoderTypeFFmpeg:
case k_encoder_type_f_fmpeg:
return new FFmpegEncoder(params);
case kEncoderTypeOIIO:
case k_encoder_type_oiio:
return new OIIOEncoder(params);
}
return nullptr;
}
Encoder::Type Encoder::GetTypeFromFormat(ExportFormat::Format f)
Encoder::Type Encoder::get_type_from_format(ExportFormat::Format f)
{
switch (f) {
case ExportFormat::kFormatDNxHD:
case ExportFormat::kFormatMatroska:
case ExportFormat::kFormatQuickTime:
case ExportFormat::kFormatMPEG4Video:
case ExportFormat::kFormatMPEG4Audio:
case ExportFormat::kFormatWAV:
case ExportFormat::kFormatAIFF:
case ExportFormat::kFormatMP3:
case ExportFormat::kFormatFLAC:
case ExportFormat::kFormatOgg:
case ExportFormat::kFormatWebM:
case ExportFormat::kFormatSRT:
return kEncoderTypeFFmpeg;
case ExportFormat::kFormatOpenEXR:
case ExportFormat::kFormatPNG:
case ExportFormat::kFormatTIFF:
return kEncoderTypeOIIO;
case ExportFormat::kFormatCount:
case ExportFormat::k_format_d_nx_hd:
case ExportFormat::k_format_matroska:
case ExportFormat::k_format_quick_time:
case ExportFormat::k_format_mpe_g4_video:
case ExportFormat::k_format_mpe_g4_audio:
case ExportFormat::k_format_wav:
case ExportFormat::k_format_aiff:
case ExportFormat::k_format_m_p3:
case ExportFormat::k_format_flac:
case ExportFormat::k_format_ogg:
case ExportFormat::k_format_web_m:
case ExportFormat::k_format_srt:
return k_encoder_type_f_fmpeg;
case ExportFormat::k_format_open_exr:
case ExportFormat::k_format_png:
case ExportFormat::k_format_tiff:
return k_encoder_type_oiio;
case ExportFormat::k_format_count:
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)
{
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();
}
std::vector<SampleFormat>
Encoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const
Encoder::get_sample_formats_for_codec(ExportCodec::Codec c) const
{
return std::vector<SampleFormat>();
}
QMatrix4x4
EncodingParams::GenerateMatrix(EncodingParams::VideoScalingMethod method,
EncodingParams::generate_matrix(EncodingParams::VideoScalingMethod method,
int source_width, int source_height,
int dest_width, int dest_height)
{
QMatrix4x4 preview_matrix;
if (method == EncodingParams::kStretch) {
if (method == EncodingParams::k_stretch) {
return preview_matrix;
}
@@ -415,7 +415,7 @@ EncodingParams::GenerateMatrix(EncodingParams::VideoScalingMethod method,
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);
} else {
preview_matrix.scale(1.0F, export_ar / source_ar);
@@ -424,11 +424,11 @@ EncodingParams::GenerateMatrix(EncodingParams::VideoScalingMethod method,
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")) {
filename_ = reader->readElementText();
} else if (reader->name() == QStringLiteral("format")) {
@@ -438,10 +438,10 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
has_custom_range_ = reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("customrangein")) {
custom_range_in =
rational::fromString(reader->readElementText().toStdString());
Rational::from_string(reader->readElementText().toStdString());
} else if (reader->name() == QStringLiteral("customrangeout")) {
custom_range_out =
rational::fromString(reader->readElementText().toStdString());
Rational::from_string(reader->readElementText().toStdString());
} else if (reader->name() == QStringLiteral("video")) {
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")) {
video_codec_ = static_cast<ExportCodec::Codec>(
reader->readElementText().toInt());
@@ -462,10 +462,10 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
video_params_.set_format(static_cast<PixelFormat::Format>(
reader->readElementText().toInt()));
} 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()));
} else if (reader->name() == QStringLiteral("timebase")) {
video_params_.set_time_base(rational::fromString(
video_params_.set_time_base(Rational::from_string(
reader->readElementText().toStdString()));
} else if (reader->name() == QStringLiteral("divider")) {
video_params_.set_divider(
@@ -488,7 +488,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
video_is_image_sequence_ =
reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("color")) {
while (XMLReadNextStartElement(reader)) {
while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("output")) {
color_transform_ = reader->readElementText();
} else {
@@ -499,10 +499,10 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
video_scaling_method_ = static_cast<VideoScalingMethod>(
reader->readElementText().toInt());
} else if (reader->name() == QStringLiteral("opts")) {
while (XMLReadNextStartElement(reader)) {
while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("entry")) {
QString key, value;
while (XMLReadNextStartElement(reader)) {
while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("key")) {
key = reader->readElementText();
} 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")) {
audio_codec_ = static_cast<ExportCodec::Codec>(
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")) {
subtitles_are_sidecar_ = reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("sidecarformat")) {
+53 -53
View File
@@ -19,8 +19,8 @@
***/
#ifndef ENCODER_H
#define ENCODER_H
#ifndef OAK_ENCODER_H
#define OAK_ENCODER_H
#include <memory>
#include <QRegularExpression>
@@ -43,34 +43,34 @@ using EncoderPtr = std::shared_ptr<Encoder>;
class EncodingParams {
public:
enum VideoScalingMethod { kFit, kStretch, kCrop };
enum VideoScalingMethod { k_fit, k_stretch, k_crop };
EncodingParams();
static QDir GetPresetPath();
static QStringList GetListOfPresets();
static QDir get_preset_path();
static QStringList get_list_of_presets();
bool IsValid() const
bool is_valid() const
{
return video_enabled_ || audio_enabled_ || subtitles_enabled_;
}
void SetFilename(const QString &filename)
void set_filename(const QString &filename)
{
filename_ = filename;
}
void EnableVideo(const VideoParams &video_params,
void enable_video(const VideoParams &video_params,
const ExportCodec::Codec &vcodec);
void EnableAudio(const AudioParams &audio_params,
void enable_audio(const AudioParams &audio_params,
const ExportCodec::Codec &acodec);
void EnableSubtitles(const ExportCodec::Codec &scodec);
void EnableSidecarSubtitles(const ExportFormat::Format &sfmt,
void enable_subtitles(const ExportCodec::Codec &scodec);
void enable_sidecar_subtitles(const ExportFormat::Format &sfmt,
const ExportCodec::Codec &scodec);
void DisableVideo();
void DisableAudio();
void DisableSubtitles();
void disable_video();
void disable_audio();
void disable_subtitles();
const ExportFormat::Format &format() const
{
@@ -219,20 +219,20 @@ public:
return subtitles_codec_;
}
const rational &GetExportLength() const
const Rational &get_export_length() const
{
return export_length_;
}
void SetExportLength(const rational &export_length)
void set_export_length(const Rational &export_length)
{
export_length_ = export_length;
}
bool Load(QIODevice *device);
bool Load(QXmlStreamReader *reader);
bool load(QIODevice *device);
bool load(QXmlStreamReader *reader);
void Save(QIODevice *device) const;
void Save(QXmlStreamWriter *writer) const;
void save(QIODevice *device) const;
void save(QXmlStreamWriter *writer) const;
bool has_custom_range() const
{
@@ -258,20 +258,20 @@ public:
video_scaling_method_ = video_scaling_method;
}
static QMatrix4x4 GenerateMatrix(VideoScalingMethod method,
static QMatrix4x4 generate_matrix(VideoScalingMethod method,
int source_width, int source_height,
int dest_width, int dest_height);
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_;
ExportFormat::Format format_ = ExportFormat::kFormatCount;
ExportFormat::Format format_ = ExportFormat::k_format_count;
bool video_enabled_;
ExportCodec::Codec video_codec_ = ExportCodec::kCodecCount;
ExportCodec::Codec video_codec_ = ExportCodec::k_codec_count;
VideoParams video_params_;
QHash<QString, QString> video_opts_;
int64_t video_bit_rate_;
@@ -284,16 +284,16 @@ private:
ColorTransform color_transform_;
bool audio_enabled_;
ExportCodec::Codec audio_codec_ = ExportCodec::kCodecCount;
ExportCodec::Codec audio_codec_ = ExportCodec::k_codec_count;
AudioParams audio_params_;
int64_t audio_bit_rate_;
bool subtitles_enabled_;
bool subtitles_are_sidecar_;
ExportFormat::Format subtitle_sidecar_fmt_ = ExportFormat::kFormatCount;
ExportCodec::Codec subtitles_codec_ = ExportCodec::kCodecCount;
ExportFormat::Format subtitle_sidecar_fmt_ = ExportFormat::k_format_count;
ExportCodec::Codec subtitles_codec_ = ExportCodec::k_codec_count;
rational export_length_;
Rational export_length_;
VideoScalingMethod video_scaling_method_;
bool has_custom_range_;
@@ -305,7 +305,7 @@ class Encoder : public QObject {
public:
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
@@ -314,53 +314,53 @@ public:
*
* 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);
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>
GetSampleFormatsForCodec(ExportCodec::Codec c) const;
get_sample_formats_for_codec(ExportCodec::Codec c) 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_;
}
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 QString FilenameRemoveDigitPlaceholder(QString filename);
static bool filename_contains_digit_placeholder(const QString &filename);
static QString filename_remove_digit_placeholder(QString filename);
static const QRegularExpression kImageSequenceContainsDigits;
static const QRegularExpression kImageSequenceRemoveDigits;
static const QRegularExpression k_image_sequence_contains_digits;
static const QRegularExpression k_image_sequence_remove_digits;
public slots:
virtual bool Open() = 0;
virtual bool open() = 0;
virtual bool WriteFrame(olive::FramePtr frame,
olive::core::rational time) = 0;
virtual bool WriteAudio(const olive::SampleBuffer &audio) = 0;
virtual bool WriteSubtitle(const SubtitleBlock *sub_block) = 0;
virtual bool write_frame(olive::FramePtr frame,
olive::core::Rational time) = 0;
virtual bool write_audio(const olive::SampleBuffer &audio) = 0;
virtual bool write_subtitle(const SubtitleBlock *sub_block) = 0;
virtual void Close() = 0;
virtual void close() = 0;
protected:
void SetError(const QString &err)
void set_error(const QString &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
{
QString ExportCodec::GetCodecName(ExportCodec::Codec c)
QString ExportCodec::get_codec_name(ExportCodec::Codec c)
{
switch (c) {
case kCodecDNxHD:
case k_codec_d_nx_hd:
return tr("DNxHD");
case kCodecH264:
case k_codec_h264:
return tr("H.264");
case kCodecH264rgb:
case k_codec_h264rgb:
return tr("H.264 RGB");
case kCodecH265:
case k_codec_h265:
return tr("H.265");
case kCodecOpenEXR:
case k_codec_open_exr:
return tr("OpenEXR");
case kCodecPNG:
case k_codec_png:
return tr("PNG");
case kCodecProRes:
case k_codec_pro_res:
return tr("ProRes");
case kCodecCineform:
case k_codec_cineform:
return tr("Cineform");
case kCodecTIFF:
case k_codec_tiff:
return tr("TIFF");
case kCodecMP2:
case k_codec_m_p2:
return tr("MP2");
case kCodecMP3:
case k_codec_m_p3:
return tr("MP3");
case kCodecAAC:
case k_codec_aac:
return tr("AAC");
case kCodecPCM:
case k_codec_pcm:
return tr("PCM (Uncompressed)");
case kCodecFLAC:
case k_codec_flac:
return tr("FLAC");
case kCodecOpus:
case k_codec_opus:
return tr("Opus");
case kCodecVorbis:
case k_codec_vorbis:
return tr("Vorbis");
case kCodecVP9:
case k_codec_v_p9:
return tr("VP9");
case kCodecAV1:
case k_codec_a_v1:
return tr("AV1");
case kCodecSRT:
case k_codec_srt:
return tr("SubRip SRT");
case kCodecCount:
case k_codec_count:
break;
}
return tr("Unknown");
}
bool ExportCodec::IsCodecAStillImage(ExportCodec::Codec c)
bool ExportCodec::is_codec_a_still_image(ExportCodec::Codec c)
{
switch (c) {
case kCodecDNxHD:
case kCodecH264:
case kCodecH264rgb:
case kCodecH265:
case kCodecProRes:
case kCodecCineform:
case kCodecMP2:
case kCodecMP3:
case kCodecAAC:
case kCodecPCM:
case kCodecVorbis:
case kCodecOpus:
case kCodecFLAC:
case kCodecVP9:
case kCodecAV1:
case kCodecSRT:
case k_codec_d_nx_hd:
case k_codec_h264:
case k_codec_h264rgb:
case k_codec_h265:
case k_codec_pro_res:
case k_codec_cineform:
case k_codec_m_p2:
case k_codec_m_p3:
case k_codec_aac:
case k_codec_pcm:
case k_codec_vorbis:
case k_codec_opus:
case k_codec_flac:
case k_codec_v_p9:
case k_codec_a_v1:
case k_codec_srt:
return false;
case kCodecOpenEXR:
case kCodecPNG:
case kCodecTIFF:
case k_codec_open_exr:
case k_codec_png:
case k_codec_tiff:
return true;
case kCodecCount:
case k_codec_count:
break;
}
return false;
}
bool ExportCodec::IsCodecLossless(Codec c)
bool ExportCodec::is_codec_lossless(Codec c)
{
switch (c) {
case kCodecPCM:
case kCodecFLAC:
case k_codec_pcm:
case k_codec_flac:
return true;
case kCodecDNxHD:
case kCodecH264:
case kCodecH264rgb:
case kCodecH265:
case kCodecProRes:
case kCodecCineform:
case kCodecMP2:
case kCodecMP3:
case kCodecAAC:
case kCodecVorbis:
case kCodecOpus:
case kCodecVP9:
case kCodecAV1:
case kCodecSRT:
case kCodecOpenEXR:
case kCodecPNG:
case kCodecTIFF:
case kCodecCount:
case k_codec_d_nx_hd:
case k_codec_h264:
case k_codec_h264rgb:
case k_codec_h265:
case k_codec_pro_res:
case k_codec_cineform:
case k_codec_m_p2:
case k_codec_m_p3:
case k_codec_aac:
case k_codec_vorbis:
case k_codec_opus:
case k_codec_v_p9:
case k_codec_a_v1:
case k_codec_srt:
case k_codec_open_exr:
case k_codec_png:
case k_codec_tiff:
case k_codec_count:
break;
}
+26 -26
View File
@@ -19,8 +19,8 @@
***/
#ifndef EXPORTCODEC_H
#define EXPORTCODEC_H
#ifndef OAK_EXPORTCODEC_H
#define OAK_EXPORTCODEC_H
#include <QObject>
#include <QString>
@@ -36,36 +36,36 @@ class ExportCodec : public QObject {
public:
// Only append to this list (never insert) because indexes are used in serialized files
enum Codec {
kCodecDNxHD,
kCodecH264,
kCodecH264rgb,
kCodecH265,
kCodecOpenEXR,
kCodecPNG,
kCodecProRes,
kCodecCineform,
kCodecTIFF,
kCodecVP9,
kCodecMP2,
kCodecMP3,
kCodecAAC,
kCodecPCM,
kCodecOpus,
kCodecVorbis,
kCodecFLAC,
kCodecSRT,
kCodecAV1,
k_codec_d_nx_hd,
k_codec_h264,
k_codec_h264rgb,
k_codec_h265,
k_codec_open_exr,
k_codec_png,
k_codec_pro_res,
k_codec_cineform,
k_codec_tiff,
k_codec_v_p9,
k_codec_m_p2,
k_codec_m_p3,
k_codec_aac,
k_codec_pcm,
k_codec_opus,
k_codec_vorbis,
k_codec_flac,
k_codec_srt,
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
{
QString ExportFormat::GetName(olive::ExportFormat::Format f)
QString ExportFormat::get_name(olive::ExportFormat::Format f)
{
switch (f) {
case kFormatDNxHD:
case k_format_d_nx_hd:
return tr("DNxHD");
case kFormatMatroska:
case k_format_matroska:
return tr("Matroska Video");
case kFormatMPEG4Video:
case k_format_mpe_g4_video:
return tr("MPEG-4 Video");
case kFormatMPEG4Audio:
case k_format_mpe_g4_audio:
return tr("MPEG-4 Audio");
case kFormatOpenEXR:
case k_format_open_exr:
return tr("OpenEXR");
case kFormatPNG:
case k_format_png:
return tr("PNG");
case kFormatTIFF:
case k_format_tiff:
return tr("TIFF");
case kFormatQuickTime:
case k_format_quick_time:
return tr("QuickTime");
case kFormatWAV:
case k_format_wav:
return tr("Wave Audio");
case kFormatAIFF:
case k_format_aiff:
return tr("AIFF");
case kFormatMP3:
case k_format_m_p3:
return tr("MP3");
case kFormatFLAC:
case k_format_flac:
return tr("FLAC");
case kFormatOgg:
case k_format_ogg:
return tr("Ogg");
case kFormatWebM:
case k_format_web_m:
return tr("WebM");
case kFormatSRT:
case k_format_srt:
return tr("SubRip SRT");
case kFormatCount:
case k_format_count:
break;
}
return tr("Unknown");
}
QString ExportFormat::GetExtension(ExportFormat::Format f)
QString ExportFormat::get_extension(ExportFormat::Format f)
{
switch (f) {
case kFormatDNxHD:
case k_format_d_nx_hd:
return QStringLiteral("mxf");
case kFormatMatroska:
case k_format_matroska:
return QStringLiteral("mkv");
case kFormatMPEG4Video:
case k_format_mpe_g4_video:
return QStringLiteral("mp4");
case kFormatMPEG4Audio:
case k_format_mpe_g4_audio:
return QStringLiteral("m4a");
case kFormatOpenEXR:
case k_format_open_exr:
return QStringLiteral("exr");
case kFormatPNG:
case k_format_png:
return QStringLiteral("png");
case kFormatTIFF:
case k_format_tiff:
return QStringLiteral("tiff");
case kFormatQuickTime:
case k_format_quick_time:
return QStringLiteral("mov");
case kFormatWAV:
case k_format_wav:
return QStringLiteral("wav");
case kFormatAIFF:
case k_format_aiff:
return QStringLiteral("aiff");
case kFormatMP3:
case k_format_m_p3:
return QStringLiteral("mp3");
case kFormatFLAC:
case k_format_flac:
return QStringLiteral("flac");
case kFormatOgg:
case k_format_ogg:
return QStringLiteral("ogg");
case kFormatWebM:
case k_format_web_m:
return QStringLiteral("webm");
case kFormatSRT:
case k_format_srt:
return QStringLiteral("srt");
case kFormatCount:
case k_format_count:
break;
}
return QString();
}
QList<ExportCodec::Codec> ExportFormat::GetVideoCodecs(ExportFormat::Format f)
QList<ExportCodec::Codec> ExportFormat::get_video_codecs(ExportFormat::Format f)
{
switch (f) {
case kFormatDNxHD:
return { ExportCodec::kCodecDNxHD };
case kFormatMatroska:
return { ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb,
ExportCodec::kCodecH265, ExportCodec::kCodecVP9 };
case kFormatMPEG4Video:
return { ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb,
ExportCodec::kCodecH265 };
case kFormatOpenEXR:
return { ExportCodec::kCodecOpenEXR };
case kFormatPNG:
return { ExportCodec::kCodecPNG };
case kFormatTIFF:
return { ExportCodec::kCodecTIFF };
case kFormatQuickTime:
return { ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb,
ExportCodec::kCodecH265, ExportCodec::kCodecProRes,
ExportCodec::kCodecCineform };
case kFormatWebM:
return { ExportCodec::kCodecAV1, ExportCodec::kCodecVP9 };
case kFormatOgg:
case kFormatWAV:
case kFormatMPEG4Audio:
case kFormatAIFF:
case kFormatMP3:
case kFormatFLAC:
case kFormatSRT:
case kFormatCount:
case k_format_d_nx_hd:
return { ExportCodec::k_codec_d_nx_hd };
case k_format_matroska:
return { ExportCodec::k_codec_h264, ExportCodec::k_codec_h264rgb,
ExportCodec::k_codec_h265, ExportCodec::k_codec_v_p9 };
case k_format_mpe_g4_video:
return { ExportCodec::k_codec_h264, ExportCodec::k_codec_h264rgb,
ExportCodec::k_codec_h265 };
case k_format_open_exr:
return { ExportCodec::k_codec_open_exr };
case k_format_png:
return { ExportCodec::k_codec_png };
case k_format_tiff:
return { ExportCodec::k_codec_tiff };
case k_format_quick_time:
return { ExportCodec::k_codec_h264, ExportCodec::k_codec_h264rgb,
ExportCodec::k_codec_h265, ExportCodec::k_codec_pro_res,
ExportCodec::k_codec_cineform };
case k_format_web_m:
return { ExportCodec::k_codec_a_v1, ExportCodec::k_codec_v_p9 };
case k_format_ogg:
case k_format_wav:
case k_format_mpe_g4_audio:
case k_format_aiff:
case k_format_m_p3:
case k_format_flac:
case k_format_srt:
case k_format_count:
break;
}
return {};
}
QList<ExportCodec::Codec> ExportFormat::GetAudioCodecs(ExportFormat::Format f)
QList<ExportCodec::Codec> ExportFormat::get_audio_codecs(ExportFormat::Format f)
{
switch (f) {
// Video/audio formats
case kFormatDNxHD:
return { ExportCodec::kCodecPCM };
case kFormatMatroska:
return { ExportCodec::kCodecAAC, ExportCodec::kCodecMP2,
ExportCodec::kCodecMP3, ExportCodec::kCodecPCM,
ExportCodec::kCodecVorbis, ExportCodec::kCodecOpus,
ExportCodec::kCodecFLAC };
case kFormatMPEG4Video:
case kFormatMPEG4Audio:
return { ExportCodec::kCodecAAC, ExportCodec::kCodecMP2,
ExportCodec::kCodecMP3 };
case kFormatQuickTime:
return { ExportCodec::kCodecAAC, ExportCodec::kCodecMP2,
ExportCodec::kCodecMP3, ExportCodec::kCodecPCM };
case kFormatWebM:
return { ExportCodec::kCodecOpus, ExportCodec::kCodecAAC,
ExportCodec::kCodecMP2, ExportCodec::kCodecMP3,
ExportCodec::kCodecPCM, ExportCodec::kCodecVorbis };
case k_format_d_nx_hd:
return { ExportCodec::k_codec_pcm };
case k_format_matroska:
return { ExportCodec::k_codec_aac, ExportCodec::k_codec_m_p2,
ExportCodec::k_codec_m_p3, ExportCodec::k_codec_pcm,
ExportCodec::k_codec_vorbis, ExportCodec::k_codec_opus,
ExportCodec::k_codec_flac };
case k_format_mpe_g4_video:
case k_format_mpe_g4_audio:
return { ExportCodec::k_codec_aac, ExportCodec::k_codec_m_p2,
ExportCodec::k_codec_m_p3 };
case k_format_quick_time:
return { ExportCodec::k_codec_aac, ExportCodec::k_codec_m_p2,
ExportCodec::k_codec_m_p3, ExportCodec::k_codec_pcm };
case k_format_web_m:
return { ExportCodec::k_codec_opus, ExportCodec::k_codec_aac,
ExportCodec::k_codec_m_p2, ExportCodec::k_codec_m_p3,
ExportCodec::k_codec_pcm, ExportCodec::k_codec_vorbis };
// Audio only formats
case kFormatWAV:
return { ExportCodec::kCodecPCM };
case kFormatAIFF:
return { ExportCodec::kCodecPCM };
case kFormatMP3:
return { ExportCodec::kCodecMP3 };
case kFormatFLAC:
return { ExportCodec::kCodecFLAC };
case kFormatOgg:
return { ExportCodec::kCodecOpus, ExportCodec::kCodecVorbis,
ExportCodec::kCodecPCM };
case k_format_wav:
return { ExportCodec::k_codec_pcm };
case k_format_aiff:
return { ExportCodec::k_codec_pcm };
case k_format_m_p3:
return { ExportCodec::k_codec_m_p3 };
case k_format_flac:
return { ExportCodec::k_codec_flac };
case k_format_ogg:
return { ExportCodec::k_codec_opus, ExportCodec::k_codec_vorbis,
ExportCodec::k_codec_pcm };
// Video only formats
case kFormatOpenEXR:
case kFormatPNG:
case kFormatTIFF:
case kFormatSRT:
case kFormatCount:
case k_format_open_exr:
case k_format_png:
case k_format_tiff:
case k_format_srt:
case k_format_count:
break;
}
return {};
}
QList<ExportCodec::Codec> ExportFormat::GetSubtitleCodecs(Format f)
QList<ExportCodec::Codec> ExportFormat::get_subtitle_codecs(Format f)
{
switch (f) {
case kFormatDNxHD:
case kFormatMPEG4Video:
case kFormatMPEG4Audio:
case kFormatOpenEXR:
case kFormatQuickTime:
case kFormatPNG:
case kFormatTIFF:
case kFormatWAV:
case kFormatAIFF:
case kFormatMP3:
case kFormatFLAC:
case kFormatOgg:
case kFormatWebM:
case kFormatCount:
case k_format_d_nx_hd:
case k_format_mpe_g4_video:
case k_format_mpe_g4_audio:
case k_format_open_exr:
case k_format_quick_time:
case k_format_png:
case k_format_tiff:
case k_format_wav:
case k_format_aiff:
case k_format_m_p3:
case k_format_flac:
case k_format_ogg:
case k_format_web_m:
case k_format_count:
break;
case kFormatMatroska:
case kFormatSRT:
return { ExportCodec::kCodecSRT };
case k_format_matroska:
case k_format_srt:
return { ExportCodec::k_codec_srt };
}
return {};
}
QStringList ExportFormat::GetPixelFormatsForCodec(ExportFormat::Format f,
QStringList ExportFormat::get_pixel_formats_for_codec(ExportFormat::Format f,
ExportCodec::Codec c)
{
Encoder *e = Encoder::CreateFromFormat(f, EncodingParams());
Encoder *e = Encoder::create_from_format(f, EncodingParams());
QStringList list;
if (e) {
list = e->GetPixelFormatsForCodec(c);
list = e->get_pixel_formats_for_codec(c);
delete e;
}
@@ -233,13 +233,13 @@ QStringList ExportFormat::GetPixelFormatsForCodec(ExportFormat::Format f,
}
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;
Encoder *e = Encoder::CreateFromFormat(format, EncodingParams());
Encoder *e = Encoder::create_from_format(format, EncodingParams());
if (e) {
f = e->GetSampleFormatsForCodec(c);
f = e->get_sample_formats_for_codec(c);
delete e;
}
+26 -26
View File
@@ -19,8 +19,8 @@
***/
#ifndef EXPORTFORMAT_H
#define EXPORTFORMAT_H
#ifndef OAK_EXPORTFORMAT_H
#define OAK_EXPORTFORMAT_H
#include <QList>
#include <QString>
@@ -36,36 +36,36 @@ class ExportFormat : public QObject {
public:
// Only append to this list (never insert) because indexes are used in serialized files
enum Format {
kFormatDNxHD,
kFormatMatroska,
kFormatMPEG4Video,
kFormatOpenEXR,
kFormatQuickTime,
kFormatPNG,
kFormatTIFF,
kFormatWAV,
kFormatAIFF,
kFormatMP3,
kFormatFLAC,
kFormatOgg,
kFormatWebM,
kFormatSRT,
kFormatMPEG4Audio,
k_format_d_nx_hd,
k_format_matroska,
k_format_mpe_g4_video,
k_format_open_exr,
k_format_quick_time,
k_format_png,
k_format_tiff,
k_format_wav,
k_format_aiff,
k_format_m_p3,
k_format_flac,
k_format_ogg,
k_format_web_m,
k_format_srt,
k_format_mpe_g4_audio,
kFormatCount
k_format_count
};
static QString GetName(Format f);
static QString GetExtension(Format f);
static QList<ExportCodec::Codec> GetVideoCodecs(ExportFormat::Format f);
static QList<ExportCodec::Codec> GetAudioCodecs(ExportFormat::Format f);
static QList<ExportCodec::Codec> GetSubtitleCodecs(ExportFormat::Format f);
static QString get_name(Format f);
static QString get_extension(Format f);
static QList<ExportCodec::Codec> get_video_codecs(ExportFormat::Format f);
static QList<ExportCodec::Codec> get_audio_codecs(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>
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
#define FFMPEGDECODER_H
#ifndef OAK_FFMPEGDECODER_H
#define OAK_FFMPEGDECODER_H
#include <inttypes.h>
@@ -53,30 +53,30 @@ public:
virtual QString id() const override;
virtual bool SupportsVideo() override
virtual bool supports_video() override
{
return true;
}
virtual bool SupportsAudio() override
virtual bool supports_audio() override
{
return true;
}
virtual FootageDescription Probe(const QString &filename,
virtual FootageDescription probe(const QString &filename,
CancelAtom *cancelled) const override;
protected:
virtual bool OpenInternal() override;
virtual bool open_internal() override;
virtual TexturePtr
RetrieveVideoInternal(const RetrieveVideoParams &p) override;
retrieve_video_internal(const RetrieveVideoParams &p) override;
virtual FramePtr
RetrieveVideoFrameInternal(const RetrieveVideoParams &p) override;
virtual bool ConformAudioInternal(const QVector<QString> &filenames,
retrieve_video_frame_internal(const RetrieveVideoParams &p) override;
virtual bool conform_audio_internal(const QVector<QString> &filenames,
const AudioParams &params,
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:
/**
@@ -87,32 +87,32 @@ private:
*
* @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 int GetNativeChannelCount(int pix_fmt);
static PixelFormat get_native_pixel_format(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 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_;
int scaler_src_width_;
@@ -137,7 +137,7 @@ private:
// Stream parameters cached on open (the stream object itself lives
// inside the bridge library)
rational stream_time_base_;
Rational stream_time_base_;
int64_t stream_start_time_;
int64_t stream_duration_;
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;
int bridge_codec = ExportCodecToBridge(c);
if (bridge_codec != FB_CODEC_NONE) {
int bridge_codec = export_codec_to_bridge(c);
if (bridge_codec != fb_codec_none) {
int count =
fb_encoder_codec_get_pixel_formats(bridge_codec, nullptr, 0);
if (count > 0) {
@@ -60,19 +60,19 @@ QStringList FFmpegEncoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const
}
std::vector<SampleFormat>
FFmpegEncoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const
FFmpegEncoder::get_sample_formats_for_codec(ExportCodec::Codec c) const
{
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
// We list signed 16 first because ExportDialog will always use the first element by default
// (because first element is the "default" in FFmpeg)
f = { SampleFormat::S16, SampleFormat::U8, SampleFormat::S32,
SampleFormat::S64, SampleFormat::F32, SampleFormat::F64 };
f = { SampleFormat::s16, SampleFormat::u8, SampleFormat::s32,
SampleFormat::s64, SampleFormat::f32, SampleFormat::f64 };
} else {
int bridge_codec = ExportCodecToBridge(c);
if (bridge_codec != FB_CODEC_NONE) {
int bridge_codec = export_codec_to_bridge(c);
if (bridge_codec != fb_codec_none) {
int count =
fb_encoder_codec_get_sample_formats(bridge_codec, nullptr, 0);
if (count > 0) {
@@ -81,8 +81,8 @@ FFmpegEncoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const
count);
for (int fmt : fmts) {
SampleFormat native =
FFmpegUtils::GetNativeSampleFormat(fmt);
if (native != SampleFormat::INVALID) {
FFmpegUtils::get_native_sample_format(fmt);
if (native != SampleFormat::invalid) {
f.push_back(native);
}
}
@@ -93,7 +93,7 @@ FFmpegEncoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const
return f;
}
bool FFmpegEncoder::Open()
bool FFmpegEncoder::open()
{
if (open_) {
return true;
@@ -117,7 +117,7 @@ bool FFmpegEncoder::Open()
// Set up video if it's enabled
if (params().video_enabled()) {
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_height = params().video_params().height();
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
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
int src_alpha_pix_fmt = FFmpegUtils::GetFFmpegPixelFormat(
video_conversion_fmt_, VideoParams::kRGBAChannelCount);
int src_noalpha_pix_fmt = FFmpegUtils::GetFFmpegPixelFormat(
video_conversion_fmt_, VideoParams::kRGBChannelCount);
int src_alpha_pix_fmt = FFmpegUtils::get_f_fmpeg_pixel_format(
video_conversion_fmt_, VideoParams::k_rgba_channel_count);
int src_noalpha_pix_fmt = FFmpegUtils::get_f_fmpeg_pixel_format(
video_conversion_fmt_, VideoParams::k_rgb_channel_count);
if (src_alpha_pix_fmt == FB_PIX_FMT_NONE ||
src_noalpha_pix_fmt == FB_PIX_FMT_NONE) {
SetError(
if (src_alpha_pix_fmt == fb_pix_fmt_none ||
src_noalpha_pix_fmt == fb_pix_fmt_none) {
set_error(
tr("Failed to find suitable pixel format for this buffer"));
return false;
}
@@ -160,19 +160,19 @@ bool FFmpegEncoder::Open()
config.video_color_range =
params().video_params().color_range() ==
VideoParams::kColorRangeFull ?
FB_COLOR_RANGE_JPEG :
FB_COLOR_RANGE_MPEG;
VideoParams::k_color_range_full ?
fb_color_range_jpeg :
fb_color_range_mpeg;
switch (params().video_params().interlacing()) {
case VideoParams::kInterlacedTopFirst:
config.video_field_order = FB_FIELD_ORDER_TT;
case VideoParams::k_interlaced_top_first:
config.video_field_order = fb_field_order_tt;
break;
case VideoParams::kInterlacedBottomFirst:
config.video_field_order = FB_FIELD_ORDER_BB;
case VideoParams::k_interlaced_bottom_first:
config.video_field_order = fb_field_order_bb;
break;
default:
config.video_field_order = FB_FIELD_ORDER_PROGRESSIVE;
config.video_field_order = fb_field_order_progressive;
break;
}
@@ -207,11 +207,11 @@ bool FFmpegEncoder::Open()
// Set up audio if it's enabled
if (params().audio_enabled()) {
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_channel_layout_mask =
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());
config.audio_bit_rate = params().audio_bit_rate();
}
@@ -219,8 +219,8 @@ bool FFmpegEncoder::Open()
// Set up subtitles if they're enabled
if (params().subtitles_enabled()) {
config.subtitles_enabled = 1;
config.subtitle_codec = ExportCodecToBridge(params().subtitles_codec());
subtitle_header = SubtitleParams::GenerateASSHeader().toUtf8();
config.subtitle_codec = export_codec_to_bridge(params().subtitles_codec());
subtitle_header = SubtitleParams::generate_ass_header().toUtf8();
config.subtitle_header =
reinterpret_cast<const uint8_t *>(subtitle_header.constData());
config.subtitle_header_size = subtitle_header.size();
@@ -228,12 +228,12 @@ bool FFmpegEncoder::Open()
encoder_ = fb_encoder_create(&config);
if (!encoder_) {
SetError(tr("Failed to create encoder"));
set_error(tr("Failed to create encoder"));
return false;
}
if (fb_encoder_open(encoder_) != 0) {
SetErrorFromBridge();
set_error_from_bridge();
fb_encoder_free(&encoder_);
return false;
}
@@ -242,29 +242,29 @@ bool FFmpegEncoder::Open()
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
if (frame->format() != 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());
int r = fb_encoder_write_video_frame(
encoder_, frame->width(), frame->height(), src_pix_fmt,
reinterpret_cast<const uint8_t *>(frame->data()),
frame->linesize_bytes(), time.toDouble());
frame->linesize_bytes(), time.to_double());
if (r != 0) {
SetErrorFromBridge();
set_error_from_bridge();
return false;
}
return true;
}
bool FFmpegEncoder::WriteAudio(const SampleBuffer &audio)
bool FFmpegEncoder::write_audio(const SampleBuffer &audio)
{
if (!audio.is_allocated()) {
return true;
@@ -284,50 +284,50 @@ bool FFmpegEncoder::WriteAudio(const SampleBuffer &audio)
int r = fb_encoder_write_audio(
encoder_, channel_data.data(),
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(),
int64_t(audio.sample_count()));
if (r != 0) {
SetErrorFromBridge();
set_error_from_bridge();
return false;
}
return true;
}
bool FFmpegEncoder::WriteAudioData(const AudioParams &audio_params,
bool FFmpegEncoder::write_audio_data(const AudioParams &audio_params,
const uint8_t **data,
int input_sample_count)
{
int r = fb_encoder_write_audio(
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(),
input_sample_count);
if (r != 0) {
SetErrorFromBridge();
set_error_from_bridge();
return false;
}
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(),
sub_block->in().toDouble(),
sub_block->length().toDouble());
sub_block->in().to_double(),
sub_block->length().to_double());
if (r != 0) {
SetErrorFromBridge();
set_error_from_bridge();
return false;
}
return true;
}
void FFmpegEncoder::Close()
void FFmpegEncoder::close()
{
if (encoder_) {
// Flushes encoders, writes the trailer, and frees everything
@@ -337,57 +337,57 @@ void FFmpegEncoder::Close()
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) {
case ExportCodec::kCodecH264:
return FB_CODEC_H264;
case ExportCodec::kCodecH264rgb:
return FB_CODEC_H264RGB;
case ExportCodec::kCodecDNxHD:
return FB_CODEC_DNXHD;
case ExportCodec::kCodecProRes:
return FB_CODEC_PRORES;
case ExportCodec::kCodecCineform:
return FB_CODEC_CINEFORM;
case ExportCodec::kCodecH265:
return FB_CODEC_H265;
case ExportCodec::kCodecVP9:
return FB_CODEC_VP9;
case ExportCodec::kCodecAV1:
return FB_CODEC_AV1;
case ExportCodec::kCodecOpenEXR:
return FB_CODEC_OPENEXR;
case ExportCodec::kCodecPNG:
return FB_CODEC_PNG;
case ExportCodec::kCodecTIFF:
return FB_CODEC_TIFF;
case ExportCodec::kCodecMP2:
return FB_CODEC_MP2;
case ExportCodec::kCodecMP3:
return FB_CODEC_MP3;
case ExportCodec::kCodecAAC:
return FB_CODEC_AAC;
case ExportCodec::kCodecPCM:
return FB_CODEC_PCM;
case ExportCodec::kCodecFLAC:
return FB_CODEC_FLAC;
case ExportCodec::kCodecOpus:
return FB_CODEC_OPUS;
case ExportCodec::kCodecVorbis:
return FB_CODEC_VORBIS;
case ExportCodec::kCodecSRT:
return FB_CODEC_SRT;
case ExportCodec::kCodecCount:
case ExportCodec::k_codec_h264:
return fb_codec_h264;
case ExportCodec::k_codec_h264rgb:
return fb_codec_h264_rgb;
case ExportCodec::k_codec_d_nx_hd:
return fb_codec_dnxhd;
case ExportCodec::k_codec_pro_res:
return fb_codec_prores;
case ExportCodec::k_codec_cineform:
return fb_codec_cineform;
case ExportCodec::k_codec_h265:
return fb_codec_h265;
case ExportCodec::k_codec_v_p9:
return fb_codec_v_p9;
case ExportCodec::k_codec_a_v1:
return fb_codec_a_v1;
case ExportCodec::k_codec_open_exr:
return fb_codec_openexr;
case ExportCodec::k_codec_png:
return fb_codec_png;
case ExportCodec::k_codec_tiff:
return fb_codec_tiff;
case ExportCodec::k_codec_m_p2:
return fb_codec_m_p2;
case ExportCodec::k_codec_m_p3:
return fb_codec_m_p3;
case ExportCodec::k_codec_aac:
return fb_codec_aac;
case ExportCodec::k_codec_pcm:
return fb_codec_pcm;
case ExportCodec::k_codec_flac:
return fb_codec_flac;
case ExportCodec::k_codec_opus:
return fb_codec_opus;
case ExportCodec::k_codec_vorbis:
return fb_codec_vorbis;
case ExportCodec::k_codec_srt:
return fb_codec_srt;
case ExportCodec::k_codec_count:
break;
}
return FB_CODEC_NONE;
return fb_codec_none;
}
}
+15 -15
View File
@@ -19,8 +19,8 @@
***/
#ifndef FFMPEGENCODER_H
#define FFMPEGENCODER_H
#ifndef OAK_FFMPEGENCODER_H
#define OAK_FFMPEGENCODER_H
#include <ffmpeg_bridge/ffmpeg_bridge.h>
@@ -42,26 +42,26 @@ public:
FFmpegEncoder(const EncodingParams &params);
virtual QStringList
GetPixelFormatsForCodec(ExportCodec::Codec c) const override;
get_pixel_formats_for_codec(ExportCodec::Codec c) const override;
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,
olive::core::rational time) override;
virtual bool write_frame(olive::FramePtr frame,
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);
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_;
}
@@ -70,9 +70,9 @@ private:
/**
* @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_;
@@ -83,4 +83,4 @@ private:
}
#endif // FFMPEGENCODER_H
#endif // OAK_FFMPEGENCODER_H
+15 -15
View File
@@ -44,7 +44,7 @@ Frame::~Frame()
destroy();
}
FramePtr Frame::Create()
FramePtr Frame::create()
{
return std::make_shared<Frame>();
}
@@ -60,10 +60,10 @@ void Frame::set_video_params(const VideoParams &params)
linesize_ = generate_linesize_bytes(width(), params_.format(),
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()) {
qCritical()
@@ -71,7 +71,7 @@ FramePtr Frame::Interlace(FramePtr top, FramePtr bottom)
return nullptr;
}
FramePtr interlaced = Frame::Create();
FramePtr interlaced = Frame::create();
interlaced->set_video_params(top->video_params());
interlaced->allocate();
@@ -91,7 +91,7 @@ int Frame::generate_linesize_bytes(int width, PixelFormat format,
int channel_count)
{
// 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);
}
@@ -102,7 +102,7 @@ Color Frame::get_pixel(int x, int y) const
}
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),
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 =
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());
}
@@ -140,7 +140,7 @@ bool Frame::allocate()
}
data_size_ = linesize_ * height();
data_ = FrameManager::Allocate(data_size_);
data_ = FrameManager::allocate(data_size_);
return true;
}
@@ -148,7 +148,7 @@ bool Frame::allocate()
void Frame::destroy()
{
if (is_allocated()) {
FrameManager::Deallocate(data_size_, data_);
FrameManager::deallocate(data_size_, data_);
data_size_ = 0;
data_ = nullptr;
@@ -162,7 +162,7 @@ FramePtr Frame::convert(PixelFormat format) const
params.set_format(format);
// Create new frame
FramePtr converted = Frame::Create();
FramePtr converted = Frame::create();
converted->set_video_params(params);
converted->set_timestamp(timestamp_);
converted->allocate();
@@ -170,16 +170,16 @@ FramePtr Frame::convert(PixelFormat format) const
// Do the conversion through OIIO for convenience
OIIO::ImageBuf src(
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(
converted->width(), converted->height(), channel_count(),
OIIOUtils::GetOIIOBaseTypeFromFormat(format)));
OIIOUtils::get_oiio_base_type_from_format(format)));
if (dst.copy_pixels(src)) {
OIIOUtils::BufferToFrame(&dst, converted.get());
OIIOUtils::buffer_to_frame(&dst, converted.get());
return converted;
} else {
return nullptr;
+9 -9
View File
@@ -19,8 +19,8 @@
***/
#ifndef FRAME_H
#define FRAME_H
#ifndef OAK_FRAME_H
#define OAK_FRAME_H
#include <memory>
#include <olive/core/core.h>
@@ -46,12 +46,12 @@ public:
DISABLE_COPY_MOVE(Frame)
static FramePtr Create();
static FramePtr create();
const VideoParams &video_params() const;
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,
int channel_count);
@@ -93,14 +93,14 @@ public:
/**
* @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_;
}
void set_timestamp(const rational &timestamp)
void set_timestamp(const Rational &timestamp)
{
timestamp_ = timestamp;
}
@@ -161,7 +161,7 @@ private:
char *data_;
int data_size_;
rational timestamp_;
Rational timestamp_;
int linesize_;
@@ -172,4 +172,4 @@ private:
Q_DECLARE_METATYPE(olive::FramePtr)
#endif // FRAME_H
#endif // OAK_FRAME_H
+32 -32
View File
@@ -32,7 +32,7 @@
namespace olive
{
QStringList OIIODecoder::supported_formats_;
QStringList OIIODecoder::supported_formats;
OIIODecoder::OIIODecoder()
: image_(nullptr)
@@ -44,7 +44,7 @@ QString OIIODecoder::id() const
return QStringLiteral("oiio");
}
FootageDescription OIIODecoder::Probe(const QString &filename,
FootageDescription OIIODecoder::probe(const QString &filename,
CancelAtom *cancelled) const
{
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
// to open a file that it can't if it's given one
if (!FileTypeIsSupported(filename)) {
if (!file_type_is_supported(filename)) {
return desc;
}
@@ -77,7 +77,7 @@ FootageDescription OIIODecoder::Probe(const QString &filename,
for (i = 0; in->seek_subimage(i, 0); i++) {
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);
@@ -104,10 +104,10 @@ FootageDescription OIIODecoder::Probe(const QString &filename,
// likely reduces the fidelity?
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
in->close();
@@ -115,26 +115,26 @@ FootageDescription OIIODecoder::Probe(const QString &filename,
return desc;
}
bool OIIODecoder::OpenInternal()
bool OIIODecoder::open_internal()
{
// 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) {
return nullptr;
}
return p.renderer->CreateTexture(frame->video_params(), frame->data(),
return p.renderer->create_texture(frame->video_params(), frame->data(),
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);
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());
// 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++) {
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
if (vp.format() != PixelFormat::F32) {
FramePtr f32_frame = buffer_.convert(PixelFormat::F32);
if (vp.format() != PixelFormat::f32) {
FramePtr f32_frame = buffer_.convert(PixelFormat::f32);
if (f32_frame) {
f32_frame->set_timestamp(p.time);
return f32_frame;
}
}
FramePtr frame = Frame::Create();
FramePtr frame = Frame::create();
frame->set_video_params(buffer_.video_params());
frame->set_timestamp(p.time);
if (!frame->allocate()) {
@@ -190,19 +190,19 @@ FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p)
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)
// 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.
// Check if we've created the supported formats list, create it if not
if (supported_formats_.isEmpty()) {
if (supported_formats.isEmpty()) {
QStringList extension_list =
QString::fromStdString(OIIO::get_string_attribute("extension_list"))
.split(';');
@@ -211,11 +211,11 @@ bool OIIODecoder::FileTypeIsSupported(const QString &fn)
foreach (const QString &ext, extension_list) {
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)) {
return false;
}
@@ -223,7 +223,7 @@ bool OIIODecoder::FileTypeIsSupported(const QString &fn)
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());
@@ -239,16 +239,16 @@ bool OIIODecoder::OpenImageHandler(const QString &fn, int subimage)
const OIIO::ImageSpec &spec = image_->spec();
// 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));
if (pix_fmt_ == PixelFormat::INVALID) {
if (pix_fmt_ == PixelFormat::invalid) {
qWarning()
<< "Failed to convert OIIO::ImageDesc to native pixel format";
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) {
qCritical()
@@ -259,7 +259,7 @@ bool OIIODecoder::OpenImageHandler(const QString &fn, int subimage)
return true;
}
void OIIODecoder::CloseImageHandle()
void OIIODecoder::close_image_handle()
{
if (image_) {
image_->close();
@@ -270,18 +270,18 @@ void OIIODecoder::CloseImageHandle()
}
VideoParams
OIIODecoder::GetVideoParamsFromImageSpec(const OIIO::ImageSpec &spec)
OIIODecoder::get_video_params_from_image_spec(const OIIO::ImageSpec &spec)
{
VideoParams video_params;
video_params.set_width(spec.width);
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)));
video_params.set_channel_count(spec.nchannels);
video_params.set_pixel_aspect_ratio(
OIIOUtils::GetPixelAspectRatioFromOIIO(spec));
video_params.set_video_type(VideoParams::kVideoTypeStill);
OIIOUtils::get_pixel_aspect_ratio_from_oiio(spec));
video_params.set_video_type(VideoParams::k_video_type_still);
return video_params;
}
+14 -14
View File
@@ -19,8 +19,8 @@
***/
#ifndef OIIODECODER_H
#define OIIODECODER_H
#ifndef OAK_OIIODECODER_H
#define OAK_OIIODECODER_H
#include <OpenImageIO/imageio.h>
#include <OpenImageIO/imagebuf.h>
@@ -39,32 +39,32 @@ public:
virtual QString id() const override;
virtual bool SupportsVideo() override
virtual bool supports_video() override
{
return true;
}
virtual FootageDescription Probe(const QString &filename,
virtual FootageDescription probe(const QString &filename,
CancelAtom *cancelled) const override;
protected:
virtual bool OpenInternal() override;
virtual bool open_internal() override;
virtual TexturePtr
RetrieveVideoInternal(const RetrieveVideoParams &p) override;
retrieve_video_internal(const RetrieveVideoParams &p) override;
virtual FramePtr
RetrieveVideoFrameInternal(const RetrieveVideoParams &p) override;
virtual void CloseInternal() override;
retrieve_video_frame_internal(const RetrieveVideoParams &p) override;
virtual void close_internal() override;
private:
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_;
OIIO::TypeDesc::BASETYPE oiio_pix_fmt_;
@@ -72,9 +72,9 @@ private:
Frame buffer_;
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;
}
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);
if (!output) {
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(),
frame->channel_count(), type);
@@ -65,18 +65,18 @@ bool OIIOEncoder::WriteFrame(FramePtr frame, rational time)
return true;
}
bool OIIOEncoder::WriteAudio(const SampleBuffer &audio)
bool OIIOEncoder::write_audio(const SampleBuffer &audio)
{
// Do nothing
return false;
}
bool OIIOEncoder::WriteSubtitle(const SubtitleBlock *sub_block)
bool OIIOEncoder::write_subtitle(const SubtitleBlock *sub_block)
{
return false;
}
void OIIOEncoder::Close()
void OIIOEncoder::close()
{
// Do nothing
}
+9 -9
View File
@@ -19,8 +19,8 @@
***/
#ifndef OIIOENCODER_H
#define OIIOENCODER_H
#ifndef OAK_OIIOENCODER_H
#define OAK_OIIOENCODER_H
#include "codec/encoder.h"
@@ -33,16 +33,16 @@ public:
OIIOEncoder(const EncodingParams &params);
public slots:
virtual bool Open() override;
virtual bool open() override;
virtual bool WriteFrame(olive::FramePtr frame,
olive::core::rational time) override;
virtual bool WriteAudio(const SampleBuffer &audio) override;
virtual bool WriteSubtitle(const SubtitleBlock *sub_block) override;
virtual bool write_frame(olive::FramePtr frame,
olive::core::Rational time) override;
virtual bool write_audio(const SampleBuffer &audio) 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
#define PLANARFILEDEVICE_H
#ifndef OAK_PLANARFILEDEVICE_H
#define OAK_PLANARFILEDEVICE_H
#include <olive/core/core.h>
#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;
bool ProxyParamsEqual(const ProxyManager::ProxyParams &a,
bool proxy_params_equal(const ProxyManager::ProxyParams &a,
const ProxyManager::ProxyParams &b)
{
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;
}
QString ProxyManager::GetProxyDirectory(const QString &cache_path)
QString ProxyManager::get_proxy_directory(const QString &cache_path)
{
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,
int stream_index,
const ProxyParams &params)
{
const QString proxy_dir = GetProxyDirectory(cache_path);
const QString proxy_dir = get_proxy_directory(cache_path);
const QString extension =
params.extension.isEmpty() ? QStringLiteral("mp4") : params.extension;
const QString filename =
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(params.height), QString::number(params.version),
params.include_audio ? QStringLiteral("1") : QStringLiteral("0"),
@@ -67,7 +67,7 @@ QString ProxyManager::GetProxyFilename(const QString &cache_path,
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
// so ffmpeg can infer the output format.
@@ -75,29 +75,29 @@ QString ProxyManager::GetWorkingProxyFilename(const QString &proxy_filename)
}
ProxyManager::ProxyState
ProxyManager::GetProxyState(const QString &proxy_filename)
ProxyManager::get_proxy_state(const QString &proxy_filename)
{
if (QFileInfo::exists(proxy_filename)) {
return kProxyReady;
return k_proxy_ready;
}
if (QFileInfo::exists(GetWorkingProxyFilename(proxy_filename))) {
return kProxyGenerating;
if (QFileInfo::exists(get_working_proxy_filename(proxy_filename))) {
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) {
case kProxyMissing:
case k_proxy_missing:
return QStringLiteral("missing");
case kProxyGenerating:
case k_proxy_generating:
return QStringLiteral("generating");
case kProxyReady:
case k_proxy_ready:
return QStringLiteral("ready");
case kProxyFailed:
case k_proxy_failed:
return QStringLiteral("failed");
}
@@ -105,41 +105,41 @@ QString ProxyManager::ProxyStateToString(ProxyState state)
}
ProxyManager::ProxyState
ProxyManager::ProxyStateFromString(const QString &state)
ProxyManager::proxy_state_from_string(const QString &state)
{
if (state == QStringLiteral("generating")) {
return kProxyGenerating;
return k_proxy_generating;
}
if (state == QStringLiteral("ready")) {
return kProxyReady;
return k_proxy_ready;
}
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(
QStringLiteral(".a1."));
}
ProxyManager::ProxyParams ProxyManager::ProxyParamsFromConfig()
ProxyManager::ProxyParams ProxyManager::proxy_params_from_config()
{
ProxyParams params;
params.width = OLIVE_CONFIG("ProxyWidth").value<int>();
params.height = OLIVE_CONFIG("ProxyHeight").value<int>();
params.crf = OLIVE_CONFIG("ProxyCRF").value<int>();
params.preset = OLIVE_CONFIG("ProxyPreset").toString();
params.include_audio = OLIVE_CONFIG("ProxyIncludeAudio").toBool();
params.width = OAK_CONFIG("ProxyWidth").value<int>();
params.height = OAK_CONFIG("ProxyHeight").value<int>();
params.crf = OAK_CONFIG("ProxyCRF").value<int>();
params.preset = OAK_CONFIG("ProxyPreset").toString();
params.include_audio = OAK_CONFIG("ProxyIncludeAudio").toBool();
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
if (!configured_path.isEmpty()) {
@@ -187,46 +187,46 @@ QString ProxyManager::FindFFmpegExecutable(const QString &configured_path)
}
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 ProxyParams &params)
{
QMutexLocker locker(&mutex_);
const QString filename =
GetProxyFilename(cache_path, source_filename, stream_index, params);
const ProxyState file_state = GetProxyState(filename);
if (file_state == kProxyReady) {
return { kProxyReady, filename, nullptr };
get_proxy_filename(cache_path, source_filename, stream_index, params);
const ProxyState file_state = get_proxy_state(filename);
if (file_state == k_proxy_ready) {
return { k_proxy_ready, filename, nullptr };
}
for (const ProxyData &data : proxying_) {
if (data.source_filename == source_filename &&
data.stream_index == stream_index &&
ProxyParamsEqual(data.params, params)) {
return { kProxyGenerating, filename, data.task };
proxy_params_equal(data.params, params)) {
return { k_proxy_generating, filename, data.task };
}
}
if (file_state == kProxyGenerating) {
QFile::remove(GetWorkingProxyFilename(filename));
if (file_state == k_proxy_generating) {
QFile::remove(get_working_proxy_filename(filename));
}
const QString working_filename = GetWorkingProxyFilename(filename);
const QString working_filename = get_working_proxy_filename(filename);
ProxyTask *task =
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());
QMetaObject::invokeMethod(TaskManager::instance(), "AddTask",
QMetaObject::invokeMethod(TaskManager::instance(), "add_task",
Qt::QueuedConnection, Q_ARG(Task *, task));
proxying_.append({ source_filename, stream_index, params, task,
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_);
@@ -250,18 +250,18 @@ void ProxyManager::ProxyTaskFinished(Task *task, bool succeeded)
QFile::remove(data.finished_filename);
if (QFile::rename(data.working_filename, data.finished_filename)) {
locker.unlock();
emit ProxyReady(data.source_filename, data.stream_index,
emit proxy_ready(data.source_filename, data.stream_index,
data.finished_filename);
emit ProxyFinished(data.source_filename, data.stream_index,
data.finished_filename, kProxyReady);
emit proxy_finished(data.source_filename, data.stream_index,
data.finished_filename, k_proxy_ready);
return;
}
}
QFile::remove(data.working_filename);
locker.unlock();
emit ProxyFinished(data.source_filename, data.stream_index,
data.finished_filename, kProxyFailed);
emit proxy_finished(data.source_filename, data.stream_index,
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/>.
*/
#ifndef PROXYMANAGER_H
#define PROXYMANAGER_H
#ifndef OAK_PROXYMANAGER_H
#define OAK_PROXYMANAGER_H
#include <QMutex>
#include <QObject>
@@ -34,14 +34,14 @@ class ProxyTask;
class ProxyManager : public QObject {
Q_OBJECT
public:
static void CreateInstance()
static void create_instance()
{
if (!instance_) {
instance_ = new ProxyManager();
}
}
static void DestroyInstance()
static void destroy_instance()
{
delete instance_;
instance_ = nullptr;
@@ -53,10 +53,10 @@ public:
}
enum ProxyState {
kProxyMissing,
kProxyGenerating,
kProxyReady,
kProxyFailed
k_proxy_missing,
k_proxy_generating,
k_proxy_ready,
k_proxy_failed
};
struct ProxyParams {
@@ -70,36 +70,36 @@ public:
};
struct Proxy {
ProxyState state = kProxyMissing;
ProxyState state = k_proxy_missing;
QString filename;
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,
int stream_index,
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()
* 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
*/
static ProxyParams ProxyParamsFromConfig();
static ProxyParams proxy_params_from_config();
/**
* @brief Locates an ffmpeg executable for proxy generation
@@ -109,16 +109,16 @@ public:
* platform-specific install locations. Returns an empty string if no
* 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 ProxyParams &params);
signals:
void ProxyReady(const QString &source_filename, int stream_index,
void proxy_ready(const QString &source_filename, int stream_index,
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);
private:
@@ -139,9 +139,9 @@ private:
QVector<ProxyData> proxying_;
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::FromTimecodeString(const QString &timecode,
const core::rational &timebase)
TimecodeMetadata::from_timecode_string(const QString &timecode,
const core::Rational &timebase)
{
SourceTime result;
const QString trimmed = timecode.trimmed();
@@ -40,8 +40,8 @@ TimecodeMetadata::FromTimecodeString(const QString &timecode,
bool ok = false;
const core::Timecode::Display display =
trimmed.contains(';') ? core::Timecode::kTimecodeDropFrame :
core::Timecode::kTimecodeNonDropFrame;
trimmed.contains(';') ? core::Timecode::k_timecode_drop_frame :
core::Timecode::k_timecode_non_drop_frame;
result.time = core::Timecode::timecode_to_time(trimmed.toStdString(),
timebase, display, &ok);
result.valid = ok;
@@ -52,7 +52,7 @@ TimecodeMetadata::FromTimecodeString(const QString &timecode,
}
TimecodeMetadata::SourceTime
TimecodeMetadata::FromBwfTimeReference(const QString &time_reference,
TimecodeMetadata::from_bwf_time_reference(const QString &time_reference,
int sample_rate)
{
SourceTime result;
@@ -75,10 +75,10 @@ TimecodeMetadata::FromBwfTimeReference(const QString &time_reference,
const qulonglong rational_limit =
static_cast<qulonglong>(std::numeric_limits<int>::max());
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));
} else {
result.time = core::rational::fromDouble(
result.time = core::Rational::from_double(
static_cast<double>(samples) / static_cast<double>(sample_rate));
}
result.source = QStringLiteral("bwf_time_reference");
+7 -7
View File
@@ -18,8 +18,8 @@
***/
#ifndef TIMECODEMETADATA_H
#define TIMECODEMETADATA_H
#ifndef OAK_TIMECODEMETADATA_H
#define OAK_TIMECODEMETADATA_H
#include <QString>
@@ -31,18 +31,18 @@ namespace olive
class TimecodeMetadata {
public:
struct SourceTime {
core::rational time;
core::Rational time;
QString source;
bool valid = false;
};
static SourceTime FromTimecodeString(const QString &timecode,
const core::rational &timebase);
static SourceTime from_timecode_string(const QString &timecode,
const core::Rational &timebase);
static SourceTime FromBwfTimeReference(const QString &time_reference,
static SourceTime from_bwf_time_reference(const QString &time_reference,
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.h
crashpadutils.h
Current.cpp
Current.h
current.cpp
current.h
debug.cpp
debug.h
decibel.h
+4 -4
View File
@@ -19,8 +19,8 @@
***/
#ifndef AUTOSCROLL_H
#define AUTOSCROLL_H
#ifndef OAK_AUTOSCROLL_H
#define OAK_AUTOSCROLL_H
#include "common/define.h"
@@ -29,9 +29,9 @@ namespace olive
class AutoScroll {
public:
enum Method { kNone, kPage, kSmooth };
enum Method { k_none, k_page, k_smooth };
};
}
#endif // AUTOSCROLL_H
#endif // OAK_AUTOSCROLL_H
+5 -5
View File
@@ -19,8 +19,8 @@
***/
#ifndef AVFRAMEPTR_H
#define AVFRAMEPTR_H
#ifndef OAK_AVFRAMEPTR_H
#define OAK_AVFRAMEPTR_H
#include <stdint.h>
@@ -124,16 +124,16 @@ private:
using AVFramePtr = std::shared_ptr<AVFrame>;
inline AVFramePtr CreateAVFramePtr(FBFrame *f)
inline AVFramePtr create_av_frame_ptr(FBFrame *f)
{
return std::make_shared<AVFrame>(f);
}
inline AVFramePtr CreateAVFramePtr()
inline AVFramePtr create_av_frame_ptr()
{
return std::make_shared<AVFrame>();
}
}
#endif // AVFRAMEPTR_H
#endif // OAK_AVFRAMEPTR_H
+8 -8
View File
@@ -19,8 +19,8 @@
***/
#ifndef CANCELABLEOBJECT_H
#define CANCELABLEOBJECT_H
#ifndef OAK_CANCELABLEOBJECT_H
#define OAK_CANCELABLEOBJECT_H
#include "common/define.h"
#include "render/cancelatom.h"
@@ -34,20 +34,20 @@ public:
{
}
void Cancel()
void cancel()
{
cancel_.Cancel();
cancel_.cancel();
CancelEvent();
}
CancelAtom *GetCancelAtom()
CancelAtom *get_cancel_atom()
{
return &cancel_;
}
bool IsCancelled()
bool is_cancelled()
{
return cancel_.IsCancelled();
return cancel_.is_cancelled();
}
protected:
@@ -61,4 +61,4 @@ private:
}
#endif // CANCELABLEOBJECT_H
#endif // OAK_CANCELABLEOBJECT_H
+7 -7
View File
@@ -36,7 +36,7 @@ CommandLineParser::~CommandLineParser()
}
const CommandLineParser::Option *
CommandLineParser::AddOption(const QStringList &strings,
CommandLineParser::add_option(const QStringList &strings,
const QString &description, bool takes_arg,
const QString &arg_placeholder, bool hidden)
{
@@ -49,7 +49,7 @@ CommandLineParser::AddOption(const QStringList &strings,
}
const CommandLineParser::PositionalArgument *
CommandLineParser::AddPositionalArgument(const QString &name,
CommandLineParser::add_positional_argument(const QString &name,
const QString &description,
bool required)
{
@@ -60,7 +60,7 @@ CommandLineParser::AddPositionalArgument(const QString &name,
return a;
}
void CommandLineParser::Process(const QVector<QString> &argv)
void CommandLineParser::process(const QVector<QString> &argv)
{
int positional_index = 0;
@@ -79,10 +79,10 @@ void CommandLineParser::Process(const QVector<QString> &argv)
foreach (const QString &s, o.args) {
if (!s.compare(arg_basename, Qt::CaseInsensitive)) {
// Flag discovered!
o.option->Set();
o.option->set();
if (o.takes_arg && i + 1 < argv.size()) {
o.option->SetSetting(argv[i + 1]);
o.option->set_setting(argv[i + 1]);
i++;
}
@@ -100,7 +100,7 @@ found_flag:
} else {
// Must be a positional flag
if (positional_index < positional_args_.size()) {
positional_args_[positional_index].option->SetSetting(argv[i]);
positional_args_[positional_index].option->set_setting(argv[i]);
positional_index++;
} else {
qWarning() << "Unknown parameter:" << argv[i];
@@ -109,7 +109,7 @@ found_flag:
}
}
void CommandLineParser::PrintHelp(const char *filename)
void CommandLineParser::print_help(const char *filename)
{
printf("%s %s\n", QCoreApplication::applicationName().toUtf8().constData(),
QCoreApplication::applicationVersion().toUtf8().constData());
+11 -11
View File
@@ -19,8 +19,8 @@
***/
#ifndef COMMANDLINEPARSER_H
#define COMMANDLINEPARSER_H
#ifndef OAK_COMMANDLINEPARSER_H
#define OAK_COMMANDLINEPARSER_H
#include <QStringList>
#include <QVector>
@@ -47,12 +47,12 @@ public:
public:
PositionalArgument() = default;
const QString &GetSetting() const
const QString &get_setting() const
{
return setting_;
}
void SetSetting(const QString &s)
void set_setting(const QString &s)
{
setting_ = s;
}
@@ -68,12 +68,12 @@ public:
is_set_ = false;
}
bool IsSet() const
bool is_set() const
{
return is_set_;
}
void Set()
void set()
{
is_set_ = true;
}
@@ -84,18 +84,18 @@ public:
CommandLineParser() = default;
const Option *AddOption(const QStringList &strings,
const Option *add_option(const QStringList &strings,
const QString &description, bool takes_arg = false,
const QString &arg_placeholder = QString(),
bool hidden = false);
const PositionalArgument *AddPositionalArgument(const QString &name,
const PositionalArgument *add_positional_argument(const QString &name,
const QString &description,
bool required = false);
void Process(const QVector<QString> &argv);
void process(const QVector<QString> &argv);
void PrintHelp(const char *filename);
void print_help(const char *filename);
private:
struct KnownOption {
@@ -119,4 +119,4 @@ private:
QVector<KnownPositionalArgument> positional_args_;
};
#endif // COMMANDLINEPARSER_H
#endif // OAK_COMMANDLINEPARSER_H
+3 -3
View File
@@ -18,8 +18,8 @@
***/
#ifndef CRASHPAD_INTERFACE_H
#define CRASHPAD_INTERFACE_H
#ifndef OAK_CRASHPAD_INTERFACE_H
#define OAK_CRASHPAD_INTERFACE_H
#ifdef USE_CRASHPAD
@@ -30,4 +30,4 @@ bool InitializeCrashpad();
#endif // USE_CRASHPAD
#endif // CRASHPAD_INTERFACE_H
#endif // OAK_CRASHPAD_INTERFACE_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef CRASHPADUTILS_H
#define CRASHPADUTILS_H
#ifndef OAK_CRASHPADUTILS_H
#define OAK_CRASHPADUTILS_H
#include <client/crashpad_client.h>
@@ -38,4 +38,4 @@
#define BASE_STRING_TO_QSTRING(x) QString::fromStdWString(x)
#endif // BUILDFLAG(IS_WIN)
#endif // CRASHPADUTILS_H
#endif // OAK_CRASHPADUTILS_H
@@ -17,6 +17,6 @@
*
*/
#include "Current.h"
#include "current.h"
Current Current::current;
+11 -11
View File
@@ -17,9 +17,9 @@
*
*/
#ifndef CURRENT_H
#define CURRENT_H
#include "pluginSupport/OliveHost.h"
#ifndef OAK_CURRENT_H
#define OAK_CURRENT_H
#include "pluginSupport/olivehost.h"
#include "render/videoparams.h"
#include "render/job/pluginjob.h"
@@ -29,11 +29,11 @@ public:
{
return current;
}
olive::VideoParams &currentVideoParams()
olive::VideoParams &current_video_params()
{
return currentVideoParams_;
}
olive::AudioParams &currentAudioParams()
olive::AudioParams &current_audio_params()
{
return currentAudioParams_;
}
@@ -58,17 +58,17 @@ public:
return true;
}
std::shared_ptr<olive::plugin::OliveHost> pluginHost()
std::shared_ptr<olive::plugin::OliveHost> plugin_host()
{
return myHost;
return myHost_;
}
void setPluginHost(std::shared_ptr<olive::plugin::OliveHost> host)
{
myHost = host;
myHost_ = host;
}
std::shared_ptr<OFX::Host::ImageEffect::PluginCache> pluginCache()
std::shared_ptr<OFX::Host::ImageEffect::PluginCache> plugin_cache()
{
return plugin_cache_;
}
@@ -83,8 +83,8 @@ private:
static Current current;
olive::VideoParams currentVideoParams_;
olive::AudioParams currentAudioParams_;
std::shared_ptr<olive::plugin::OliveHost> myHost;
std::shared_ptr<olive::plugin::OliveHost> myHost_;
std::shared_ptr<OFX::Host::ImageEffect::PluginCache> plugin_cache_;
};
#endif //CURRENT_H
#endif //OAK_CURRENT_H
+3 -3
View File
@@ -24,10 +24,10 @@
namespace olive
{
void DebugHandler(QtMsgType type, const QMessageLogContext &context,
void debug_handler(QtMsgType type, const QMessageLogContext &context,
const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
QByteArray local_msg = msg.toLocal8Bit();
const char *msg_type = "UNKNOWN";
switch (type) {
@@ -49,7 +49,7 @@ void DebugHandler(QtMsgType type, const QMessageLogContext &context,
}
//fprintf(stderr, "[%s] %s (%s:%u)\n", msg_type, localMsg.constData(), context.function, context.line);
fprintf(stderr, "[%s] %s\n", msg_type, localMsg.constData());
fprintf(stderr, "[%s] %s\n", msg_type, local_msg.constData());
#ifdef Q_OS_WINDOWS
// Windows still seems to buffer stderr and we want to see debug messages immediately, so here we make sure each line
+4 -4
View File
@@ -19,8 +19,8 @@
***/
#ifndef DEBUG_H
#define DEBUG_H
#ifndef OAK_DEBUG_H
#define OAK_DEBUG_H
#include <QDebug>
@@ -29,9 +29,9 @@
namespace olive
{
void DebugHandler(QtMsgType type, const QMessageLogContext &context,
void debug_handler(QtMsgType type, const QMessageLogContext &context,
const QString &msg);
}
#endif // DEBUG_H
#endif // OAK_DEBUG_H
+17 -17
View File
@@ -19,8 +19,8 @@
***/
#ifndef DECIBEL_H
#define DECIBEL_H
#ifndef OAK_DECIBEL_H
#define OAK_DECIBEL_H
#include <QtGlobal>
#include <cmath>
@@ -33,20 +33,20 @@ namespace olive
class Decibel {
public:
// In basically all circumstances, this should calculate to 0.0 linear
static constexpr double MINIMUM = -200.0;
static constexpr double minimum = -200.0;
static double fromLinear(double linear)
static double from_linear(double linear)
{
double v = double(20.0) * std::log10(linear);
#ifndef ALLOW_RETURNING_INFINITY
if (std::isinf(v)) {
return MINIMUM;
return minimum;
}
#endif
return v;
}
static double toLinear(double decibel)
static double to_linear(double decibel)
{
double to_linear = std::pow(double(10.0), decibel / double(20.0));
@@ -58,47 +58,47 @@ public:
}
}
static double fromLogarithmic(double logarithmic)
static double from_logarithmic(double logarithmic)
{
if (logarithmic < 0.001)
#ifdef ALLOW_RETURNING_INFINITY
return std::numeric_limits<double>::infinity();
#else
return MINIMUM;
return minimum;
#endif
else if (logarithmic > 0.99)
return 0;
else
return 20.0 * std::log10(-std::log(1 - logarithmic) / LOG100);
return 20.0 * std::log10(-std::log(1 - logarithmic) / lo_g100);
}
static double toLogarithmic(double decibel)
static double to_logarithmic(double decibel)
{
if (qFuzzyIsNull(decibel)) {
return 1;
} else {
return 1 - std::exp(-std::pow(10.0, decibel / 20.0) * LOG100);
return 1 - std::exp(-std::pow(10.0, decibel / 20.0) * lo_g100);
}
}
static double LinearToLogarithmic(double linear)
static double linear_to_logarithmic(double linear)
{
return 1 - std::exp(-linear * LOG100);
return 1 - std::exp(-linear * lo_g100);
}
static double LogarithmicToLinear(double logarithmic)
static double logarithmic_to_linear(double logarithmic)
{
if (logarithmic > 0.99) {
return 1;
} else {
return -std::log(1 - logarithmic) / LOG100;
return -std::log(1 - logarithmic) / lo_g100;
}
}
private:
static constexpr double LOG100 = 4.60517018599;
static constexpr double lo_g100 = 4.60517018599;
};
}
#endif // DECIBEL_H
#endif // OAK_DECIBEL_H
+7 -7
View File
@@ -19,22 +19,22 @@
***/
#ifndef OLIVECOMMONDEFINE_H
#define OLIVECOMMONDEFINE_H
#ifndef OAK_OLIVECOMMONDEFINE_H
#define OAK_OLIVECOMMONDEFINE_H
namespace olive
{
/// The minimum size an icon in ProjectExplorer can be
const int kProjectIconSizeMinimum = 16;
const int k_project_icon_size_minimum = 16;
/// The maximum size an icon in ProjectExplorer can be
const int kProjectIconSizeMaximum = 256;
const int k_project_icon_size_maximum = 256;
/// The default size an icon in ProjectExplorer can be
const int kProjectIconSizeDefault = 64;
const int k_project_icon_size_default = 64;
const int kBytesInGigabyte = 1073741824;
const int k_bytes_in_gigabyte = 1073741824;
}
@@ -65,4 +65,4 @@ const int kBytesInGigabyte = 1073741824;
DISABLE_COPY(Class) \
DISABLE_MOVE(Class)
#endif // OLIVECOMMONDEFINE_H
#endif // OAK_OLIVECOMMONDEFINE_H
+4 -4
View File
@@ -19,15 +19,15 @@
***/
#ifndef DIGIT_H
#define DIGIT_H
#ifndef OAK_DIGIT_H
#define OAK_DIGIT_H
#include <stdint.h>
namespace olive
{
inline int64_t GetDigitCount(int64_t input)
inline int64_t get_digit_count(int64_t input)
{
input = std::abs(input);
@@ -44,4 +44,4 @@ inline int64_t GetDigitCount(int64_t input)
}
#endif // DIGIT_H
#endif // OAK_DIGIT_H
+114 -114
View File
@@ -24,110 +24,110 @@
namespace olive
{
int FFmpegUtils::GetCompatibleBridgePixelFormat(int pix_fmt,
int FFmpegUtils::get_compatible_bridge_pixel_format(int pix_fmt,
PixelFormat maximum)
{
int possible_pix_fmts[4];
possible_pix_fmts[0] = FB_PIX_FMT_RGBA;
possible_pix_fmts[0] = fb_pix_fmt_rgba;
if (maximum == PixelFormat::U8) {
possible_pix_fmts[1] = FB_PIX_FMT_NONE;
if (maximum == PixelFormat::u8) {
possible_pix_fmts[1] = fb_pix_fmt_none;
} else {
possible_pix_fmts[1] = FB_PIX_FMT_RGBA64LE;
if (maximum == PixelFormat::F32) {
possible_pix_fmts[2] = FB_PIX_FMT_RGBAF32LE;
possible_pix_fmts[3] = FB_PIX_FMT_NONE;
possible_pix_fmts[1] = fb_pix_fmt_rgb_a64_le;
if (maximum == PixelFormat::f32) {
possible_pix_fmts[2] = fb_pix_fmt_rgba_f32_le;
possible_pix_fmts[3] = fb_pix_fmt_none;
} else {
possible_pix_fmts[2] = FB_PIX_FMT_NONE;
possible_pix_fmts[2] = fb_pix_fmt_none;
}
}
return fb_find_best_pix_fmt_of_list(possible_pix_fmts, pix_fmt);
}
SampleFormat FFmpegUtils::GetNativeSampleFormat(int smp_fmt)
SampleFormat FFmpegUtils::get_native_sample_format(int smp_fmt)
{
switch (smp_fmt) {
case FB_SAMPLE_FMT_U8:
return SampleFormat::U8;
case FB_SAMPLE_FMT_S16:
return SampleFormat::S16;
case FB_SAMPLE_FMT_S32:
return SampleFormat::S32;
case FB_SAMPLE_FMT_S64:
return SampleFormat::S64;
case FB_SAMPLE_FMT_FLT:
return SampleFormat::F32;
case FB_SAMPLE_FMT_DBL:
return SampleFormat::F64;
case FB_SAMPLE_FMT_U8P:
return SampleFormat::U8P;
case FB_SAMPLE_FMT_S16P:
return SampleFormat::S16P;
case FB_SAMPLE_FMT_S32P:
return SampleFormat::S32P;
case FB_SAMPLE_FMT_S64P:
return SampleFormat::S64P;
case FB_SAMPLE_FMT_FLTP:
return SampleFormat::F32P;
case FB_SAMPLE_FMT_DBLP:
return SampleFormat::F64P;
case fb_sample_fmt_u8:
return SampleFormat::u8;
case fb_sample_fmt_s16:
return SampleFormat::s16;
case fb_sample_fmt_s32:
return SampleFormat::s32;
case fb_sample_fmt_s64:
return SampleFormat::s64;
case fb_sample_fmt_flt:
return SampleFormat::f32;
case fb_sample_fmt_dbl:
return SampleFormat::f64;
case fb_sample_fmt_u8_p:
return SampleFormat::u8_p;
case fb_sample_fmt_s16_p:
return SampleFormat::s16_p;
case fb_sample_fmt_s32_p:
return SampleFormat::s32_p;
case fb_sample_fmt_s64_p:
return SampleFormat::s64_p;
case fb_sample_fmt_fltp:
return SampleFormat::f32_p;
case fb_sample_fmt_dblp:
return SampleFormat::f64_p;
default:
break;
}
return SampleFormat::INVALID;
return SampleFormat::invalid;
}
int FFmpegUtils::GetFFmpegSampleFormat(const SampleFormat &smp_fmt)
int FFmpegUtils::get_f_fmpeg_sample_format(const SampleFormat &smp_fmt)
{
switch (smp_fmt) {
case SampleFormat::U8:
return FB_SAMPLE_FMT_U8;
case SampleFormat::S16:
return FB_SAMPLE_FMT_S16;
case SampleFormat::S32:
return FB_SAMPLE_FMT_S32;
case SampleFormat::S64:
return FB_SAMPLE_FMT_S64;
case SampleFormat::F32:
return FB_SAMPLE_FMT_FLT;
case SampleFormat::F64:
return FB_SAMPLE_FMT_DBL;
case SampleFormat::U8P:
return FB_SAMPLE_FMT_U8P;
case SampleFormat::S16P:
return FB_SAMPLE_FMT_S16P;
case SampleFormat::S32P:
return FB_SAMPLE_FMT_S32P;
case SampleFormat::S64P:
return FB_SAMPLE_FMT_S64P;
case SampleFormat::F32P:
return FB_SAMPLE_FMT_FLTP;
case SampleFormat::F64P:
return FB_SAMPLE_FMT_DBLP;
case SampleFormat::INVALID:
case SampleFormat::COUNT:
case SampleFormat::u8:
return fb_sample_fmt_u8;
case SampleFormat::s16:
return fb_sample_fmt_s16;
case SampleFormat::s32:
return fb_sample_fmt_s32;
case SampleFormat::s64:
return fb_sample_fmt_s64;
case SampleFormat::f32:
return fb_sample_fmt_flt;
case SampleFormat::f64:
return fb_sample_fmt_dbl;
case SampleFormat::u8_p:
return fb_sample_fmt_u8_p;
case SampleFormat::s16_p:
return fb_sample_fmt_s16_p;
case SampleFormat::s32_p:
return fb_sample_fmt_s32_p;
case SampleFormat::s64_p:
return fb_sample_fmt_s64_p;
case SampleFormat::f32_p:
return fb_sample_fmt_fltp;
case SampleFormat::f64_p:
return fb_sample_fmt_dblp;
case SampleFormat::invalid:
case SampleFormat::count:
break;
}
return FB_SAMPLE_FMT_NONE;
return fb_sample_fmt_none;
}
int FFmpegUtils::ConvertJPEGSpaceToRegularSpace(int f)
int FFmpegUtils::convert_jpeg_space_to_regular_space(int f)
{
switch (f) {
case FB_PIX_FMT_YUVJ420P:
return FB_PIX_FMT_YUV420P;
case FB_PIX_FMT_YUVJ422P:
return FB_PIX_FMT_YUV422P;
case FB_PIX_FMT_YUVJ444P:
return FB_PIX_FMT_YUV444P;
case FB_PIX_FMT_YUVJ440P:
return FB_PIX_FMT_YUV440P;
case FB_PIX_FMT_YUVJ411P:
return FB_PIX_FMT_YUV411P;
case fb_pix_fmt_yuv_j420_p:
return fb_pix_fmt_yu_v420_p;
case fb_pix_fmt_yuv_j422_p:
return fb_pix_fmt_yu_v422_p;
case fb_pix_fmt_yuv_j444_p:
return fb_pix_fmt_yu_v444_p;
case fb_pix_fmt_yuv_j440_p:
return fb_pix_fmt_yu_v440_p;
case fb_pix_fmt_yuv_j411_p:
return fb_pix_fmt_yu_v411_p;
default:
break;
}
@@ -135,63 +135,63 @@ int FFmpegUtils::ConvertJPEGSpaceToRegularSpace(int f)
return f;
}
int FFmpegUtils::GetFFmpegPixelFormat(const PixelFormat &pix_fmt,
int FFmpegUtils::get_f_fmpeg_pixel_format(const PixelFormat &pix_fmt,
int channel_layout)
{
if (channel_layout == VideoParams::kRGBChannelCount) {
if (channel_layout == VideoParams::k_rgb_channel_count) {
switch (pix_fmt) {
case PixelFormat::U8:
return FB_PIX_FMT_RGB24;
case PixelFormat::U10:
return FB_PIX_FMT_NONE;
case PixelFormat::U16:
return FB_PIX_FMT_RGB48LE;
case PixelFormat::F16:
return FB_PIX_FMT_RGBF16LE;
case PixelFormat::F32:
return FB_PIX_FMT_RGBF32LE;
case PixelFormat::INVALID:
case PixelFormat::COUNT:
case PixelFormat::u8:
return fb_pix_fmt_rg_b24;
case PixelFormat::u10:
return fb_pix_fmt_none;
case PixelFormat::u16:
return fb_pix_fmt_rg_b48_le;
case PixelFormat::f16:
return fb_pix_fmt_rgb_f16_le;
case PixelFormat::f32:
return fb_pix_fmt_rgb_f32_le;
case PixelFormat::invalid:
case PixelFormat::count:
break;
}
} else if (channel_layout == VideoParams::kRGBAChannelCount) {
} else if (channel_layout == VideoParams::k_rgba_channel_count) {
switch (pix_fmt) {
case PixelFormat::U8:
return FB_PIX_FMT_RGBA;
case PixelFormat::U10:
return FB_PIX_FMT_NONE;
case PixelFormat::U16:
return FB_PIX_FMT_RGBA64LE;
case PixelFormat::F16:
return FB_PIX_FMT_RGBAF16LE;
case PixelFormat::F32:
return FB_PIX_FMT_RGBAF32LE;
case PixelFormat::INVALID:
case PixelFormat::COUNT:
case PixelFormat::u8:
return fb_pix_fmt_rgba;
case PixelFormat::u10:
return fb_pix_fmt_none;
case PixelFormat::u16:
return fb_pix_fmt_rgb_a64_le;
case PixelFormat::f16:
return fb_pix_fmt_rgba_f16_le;
case PixelFormat::f32:
return fb_pix_fmt_rgba_f32_le;
case PixelFormat::invalid:
case PixelFormat::count:
break;
}
}
return FB_PIX_FMT_NONE;
return fb_pix_fmt_none;
}
PixelFormat FFmpegUtils::GetCompatiblePixelFormat(const PixelFormat &pix_fmt)
PixelFormat FFmpegUtils::get_compatible_pixel_format(const PixelFormat &pix_fmt)
{
switch (pix_fmt) {
case PixelFormat::U8:
return PixelFormat::U8;
case PixelFormat::U10:
return PixelFormat::U8;
case PixelFormat::U16:
case PixelFormat::F16:
case PixelFormat::F32:
return PixelFormat::U16;
case PixelFormat::INVALID:
case PixelFormat::COUNT:
case PixelFormat::u8:
return PixelFormat::u8;
case PixelFormat::u10:
return PixelFormat::u8;
case PixelFormat::u16:
case PixelFormat::f16:
case PixelFormat::f32:
return PixelFormat::u16;
case PixelFormat::invalid:
case PixelFormat::count:
break;
}
return PixelFormat::INVALID;
return PixelFormat::invalid;
}
}
+10 -10
View File
@@ -19,8 +19,8 @@
***/
#ifndef FFMPEGABSTRACTION_H
#define FFMPEGABSTRACTION_H
#ifndef OAK_FFMPEGABSTRACTION_H
#define OAK_FFMPEGABSTRACTION_H
#include <ffmpeg_bridge/ffmpeg_bridge.h>
@@ -50,29 +50,29 @@ public:
* taking a single argument, an unscoped enum argument would silently
* prefer an int overload over the PixelFormat one.
*/
static int GetCompatibleBridgePixelFormat(
int pix_fmt, PixelFormat maximum = PixelFormat::INVALID);
static int get_compatible_bridge_pixel_format(
int pix_fmt, PixelFormat maximum = PixelFormat::invalid);
/**
* @brief Returns a native pixel format that can be used to convert from a native frame to a bridge frame with minimal data loss
*/
static PixelFormat GetCompatiblePixelFormat(const PixelFormat &pix_fmt);
static PixelFormat get_compatible_pixel_format(const PixelFormat &pix_fmt);
/**
* @brief Returns a bridge pixel format for a given native pixel format
*/
static int GetFFmpegPixelFormat(const PixelFormat &pix_fmt,
static int get_f_fmpeg_pixel_format(const PixelFormat &pix_fmt,
int channel_layout);
/**
* @brief Returns a native sample format type for a given bridge sample format
*/
static SampleFormat GetNativeSampleFormat(int smp_fmt);
static SampleFormat get_native_sample_format(int smp_fmt);
/**
* @brief Returns a bridge sample format type for a given native type
*/
static int GetFFmpegSampleFormat(const SampleFormat &smp_fmt);
static int get_f_fmpeg_sample_format(const SampleFormat &smp_fmt);
/**
* @brief Convert "JPEG"/full-range colorspace to its regular counterpart
@@ -81,9 +81,9 @@ public:
* time being, FFmpeg still uses these JPEG spaces, so for simplicity (since we *are* color_range
* aware), we use this function.
*/
static int ConvertJPEGSpaceToRegularSpace(int f);
static int convert_jpeg_space_to_regular_space(int f);
};
}
#endif // FFMPEGABSTRACTION_H
#endif // OAK_FFMPEGABSTRACTION_H
+18 -18
View File
@@ -33,7 +33,7 @@
namespace olive
{
QString FileFunctions::GetUniqueFileIdentifier(const QString &filename)
QString FileFunctions::get_unique_file_identifier(const QString &filename)
{
QFileInfo info(filename);
@@ -53,10 +53,10 @@ QString FileFunctions::GetUniqueFileIdentifier(const QString &filename)
return QString(result.toHex());
}
QString FileFunctions::GetConfigurationLocation()
QString FileFunctions::get_configuration_location()
{
if (IsPortable()) {
return GetApplicationPath();
if (is_portable()) {
return get_application_path();
} else {
QString s =
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
@@ -65,17 +65,17 @@ QString FileFunctions::GetConfigurationLocation()
}
}
bool FileFunctions::IsPortable()
bool FileFunctions::is_portable()
{
return QFileInfo::exists(QDir(GetApplicationPath()).filePath("portable"));
return QFileInfo::exists(QDir(get_application_path()).filePath("portable"));
}
QString FileFunctions::GetApplicationPath()
QString FileFunctions::get_application_path()
{
return QCoreApplication::applicationDirPath();
}
QString FileFunctions::GetTempFilePath()
QString FileFunctions::get_temp_file_path()
{
QString temp_path =
QDir(
@@ -89,7 +89,7 @@ QString FileFunctions::GetTempFilePath()
return temp_path;
}
bool FileFunctions::CanCopyDirectoryWithoutOverwriting(const QString &source,
bool FileFunctions::can_copy_directory_without_overwriting(const QString &source,
const QString &dest)
{
QFileInfoList info_list = QDir(source).entryInfoList();
@@ -104,7 +104,7 @@ bool FileFunctions::CanCopyDirectoryWithoutOverwriting(const QString &source,
QString dest_equivalent = QDir(dest).filePath(info.fileName());
if (info.isDir()) {
if (!CanCopyDirectoryWithoutOverwriting(info.absoluteFilePath(),
if (!can_copy_directory_without_overwriting(info.absoluteFilePath(),
dest_equivalent)) {
return false;
}
@@ -116,7 +116,7 @@ bool FileFunctions::CanCopyDirectoryWithoutOverwriting(const QString &source,
return true;
}
void FileFunctions::CopyDirectory(const QString &source, const QString &dest,
void FileFunctions::copy_directory(const QString &source, const QString &dest,
bool overwrite)
{
QDir d(source);
@@ -147,7 +147,7 @@ void FileFunctions::CopyDirectory(const QString &source, const QString &dest,
if (info.isDir()) {
// Copy dir
CopyDirectory(info.absoluteFilePath(), dest_file_path, overwrite);
copy_directory(info.absoluteFilePath(), dest_file_path, overwrite);
} else {
// Copy file
if (overwrite && QFile::exists(dest_file_path)) {
@@ -164,7 +164,7 @@ void FileFunctions::CopyDirectory(const QString &source, const QString &dest,
}
}
bool FileFunctions::DirectoryIsValid(const QDir &d,
bool FileFunctions::directory_is_valid(const QDir &d,
bool try_to_create_if_not_exists)
{
// Return whether the directory exists, or whether it could be created if it doesn't
@@ -172,7 +172,7 @@ bool FileFunctions::DirectoryIsValid(const QDir &d,
(try_to_create_if_not_exists && d.mkpath(QStringLiteral(".")));
}
QString FileFunctions::EnsureFilenameExtension(QString fn,
QString FileFunctions::ensure_filename_extension(QString fn,
const QString &extension)
{
// No-op if either input is empty
@@ -190,7 +190,7 @@ QString FileFunctions::EnsureFilenameExtension(QString fn,
return fn;
}
QString FileFunctions::ReadFileAsString(const QString &filename)
QString FileFunctions::read_file_as_string(const QString &filename)
{
QFile f(filename);
QString file_data;
@@ -202,7 +202,7 @@ QString FileFunctions::ReadFileAsString(const QString &filename)
return file_data;
}
QString FileFunctions::GetSafeTemporaryFilename(const QString &original)
QString FileFunctions::get_safe_temporary_filename(const QString &original)
{
int counter = 0;
@@ -226,7 +226,7 @@ QString FileFunctions::GetSafeTemporaryFilename(const QString &original)
return temp_abs_path;
}
bool FileFunctions::RenameFileAllowOverwrite(const QString &from,
bool FileFunctions::rename_file_allow_overwrite(const QString &from,
const QString &to)
{
if (QFileInfo::exists(to) && !QFile::remove(to)) {
@@ -243,7 +243,7 @@ bool FileFunctions::RenameFileAllowOverwrite(const QString &from,
return true;
}
QString FileFunctions::GetAutoRecoveryRoot()
QString FileFunctions::get_auto_recovery_root()
{
return QDir(QStandardPaths::writableLocation(
QStandardPaths::AppLocalDataLocation))
+17 -17
View File
@@ -19,8 +19,8 @@
***/
#ifndef FILEFUNCTIONS_H
#define FILEFUNCTIONS_H
#ifndef OAK_FILEFUNCTIONS_H
#define OAK_FILEFUNCTIONS_H
#include <QDir>
#include <QString>
@@ -41,23 +41,23 @@ public:
* In portable mode, any persistent configuration files should be made in a path relative to the application rather
* than in the user's home folder.
*/
static bool IsPortable();
static bool is_portable();
static QString GetUniqueFileIdentifier(const QString &filename);
static QString get_unique_file_identifier(const QString &filename);
static QString GetConfigurationLocation();
static QString get_configuration_location();
static QString GetApplicationPath();
static QString get_application_path();
static QString GetTempFilePath();
static QString get_temp_file_path();
static bool CanCopyDirectoryWithoutOverwriting(const QString &source,
static bool can_copy_directory_without_overwriting(const QString &source,
const QString &dest);
static void CopyDirectory(const QString &source, const QString &dest,
static void copy_directory(const QString &source, const QString &dest,
bool overwrite = false);
static bool DirectoryIsValid(const QDir &dir,
static bool directory_is_valid(const QDir &dir,
bool try_to_create_if_not_exists = true);
/**
@@ -69,10 +69,10 @@ public:
* @return The filename provided either untouched or with the extension appended to it.
*/
static QString EnsureFilenameExtension(QString fn,
static QString ensure_filename_extension(QString fn,
const QString &extension);
static QString ReadFileAsString(const QString &filename);
static QString read_file_as_string(const QString &filename);
/**
* @brief Returns a temporary filename that can be used while writing rather than the original
@@ -84,15 +84,15 @@ public:
* This function returns a slight variant of the filename provided that's guaranteed to not exist
* and therefore won't overwrite anything important.
*/
static QString GetSafeTemporaryFilename(const QString &original);
static QString get_safe_temporary_filename(const QString &original);
/**
* @brief Renames a file from `from` to `to`, deleting `to` if such a file already exists first
*/
static bool RenameFileAllowOverwrite(const QString &from,
static bool rename_file_allow_overwrite(const QString &from,
const QString &to);
inline static QString GetFormattedExecutableForPlatform(QString unformatted)
inline static QString get_formatted_executable_for_platform(QString unformatted)
{
#ifdef Q_OS_WINDOWS
unformatted.append(QStringLiteral(".exe"));
@@ -101,9 +101,9 @@ public:
return unformatted;
}
static QString GetAutoRecoveryRoot();
static QString get_auto_recovery_root();
};
}
#endif // FILEFUNCTIONS_H
#endif // OAK_FILEFUNCTIONS_H
+51 -51
View File
@@ -26,15 +26,15 @@
namespace olive
{
const QVector<QString> Html::kBlockTags = { QStringLiteral("p"),
const QVector<QString> Html::k_block_tags = { QStringLiteral("p"),
QStringLiteral("div") };
inline bool StrEquals(const QStringView &a, const QStringView &b)
inline bool str_equals(const QStringView &a, const QStringView &b)
{
return !a.compare(b, Qt::CaseInsensitive);
}
QString Html::DocToHtml(const QTextDocument *doc)
QString Html::doc_to_html(const QTextDocument *doc)
{
QString html;
QXmlStreamWriter writer(&html);
@@ -42,7 +42,7 @@ QString Html::DocToHtml(const QTextDocument *doc)
//writer.setAutoFormatting(true);
for (auto it = doc->begin(); it != doc->end(); it = it.next()) {
WriteBlock(&writer, it);
write_block(&writer, it);
}
return html;
@@ -53,7 +53,7 @@ struct HtmlNode {
QTextCharFormat format;
};
QTextCharFormat MergeHtmlFormats(const QVector<HtmlNode> &stack)
QTextCharFormat merge_html_formats(const QVector<HtmlNode> &stack)
{
QTextCharFormat f;
@@ -64,7 +64,7 @@ QTextCharFormat MergeHtmlFormats(const QVector<HtmlNode> &stack)
return f;
}
void Html::HtmlToDoc(QTextDocument *doc, const QString &html)
void Html::html_to_doc(QTextDocument *doc, const QString &html)
{
// Empty doc
doc->clear();
@@ -90,12 +90,12 @@ void Html::HtmlToDoc(QTextDocument *doc, const QString &html)
if (reader.tokenType() == QXmlStreamReader::StartElement) {
QString tag = reader.name().toString().toLower();
fmt_stack.append({ tag, ReadCharFormat(reader.attributes()) });
current_fmt = MergeHtmlFormats(fmt_stack);
fmt_stack.append({ tag, read_char_format(reader.attributes()) });
current_fmt = merge_html_formats(fmt_stack);
if (kBlockTags.contains(tag)) {
if (k_block_tags.contains(tag)) {
QTextBlockFormat block_fmt =
ReadBlockFormat(reader.attributes());
read_block_format(reader.attributes());
if (inside_block) {
c.setBlockFormat(block_fmt);
c.setBlockCharFormat(current_fmt);
@@ -115,9 +115,9 @@ void Html::HtmlToDoc(QTextDocument *doc, const QString &html)
for (int i = fmt_stack.size() - 1; i >= 0; i--) {
if (fmt_stack.at(i).tag == tag) {
fmt_stack.removeAt(i);
current_fmt = MergeHtmlFormats(fmt_stack);
current_fmt = merge_html_formats(fmt_stack);
if (kBlockTags.contains(tag)) {
if (k_block_tags.contains(tag)) {
inside_block = false;
}
break;
@@ -131,7 +131,7 @@ void Html::HtmlToDoc(QTextDocument *doc, const QString &html)
}
}
void Html::WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block)
void Html::write_block(QXmlStreamWriter *writer, const QTextBlock &block)
{
writer->writeStartElement(QStringLiteral("p"));
@@ -160,11 +160,11 @@ void Html::WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block)
QString style;
if (fmt.lineHeightType() != QTextBlockFormat::SingleHeight) {
WriteCSSProperty(&style, QStringLiteral("line-height"),
write_css_property(&style, QStringLiteral("line-height"),
QStringLiteral("%1%").arg(fmt.lineHeight()));
}
WriteCharFormat(&style, block.charFormat());
write_char_format(&style, block.charFormat());
if (!style.isEmpty()) {
writer->writeAttribute(QStringLiteral("style"), style);
@@ -174,14 +174,14 @@ void Html::WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block)
if (it != block.end()) {
for (; it != block.end(); it++) {
WriteFragment(writer, it.fragment());
write_fragment(writer, it.fragment());
}
}
writer->writeEndElement(); // p
}
void Html::WriteFragment(QXmlStreamWriter *writer,
void Html::write_fragment(QXmlStreamWriter *writer,
const QTextFragment &fragment)
{
const QTextCharFormat &fmt = fragment.charFormat();
@@ -191,7 +191,7 @@ void Html::WriteFragment(QXmlStreamWriter *writer,
// Write CSS attributes
QString style;
WriteCharFormat(&style, fmt);
write_char_format(&style, fmt);
if (!style.isEmpty()) {
writer->writeAttribute(QStringLiteral("style"), style);
@@ -211,7 +211,7 @@ void Html::WriteFragment(QXmlStreamWriter *writer,
writer->writeEndElement(); // span
}
void Html::WriteCSSProperty(QString *style, const QString &key,
void Html::write_css_property(QString *style, const QString &key,
const QStringList &values)
{
QString value;
@@ -220,39 +220,39 @@ void Html::WriteCSSProperty(QString *style, const QString &key,
v = QStringLiteral("'%1'").arg(v);
}
AppendStringAutoSpace(&value, v);
append_string_auto_space(&value, v);
}
AppendStringAutoSpace(style, QStringLiteral("%1: %2;").arg(key, value));
append_string_auto_space(style, QStringLiteral("%1: %2;").arg(key, value));
}
void Html::WriteCharFormat(QString *style, const QTextCharFormat &fmt)
void Html::write_char_format(QString *style, const QTextCharFormat &fmt)
{
QStringList families = fmt.fontFamilies().toStringList();
if (!families.isEmpty()) {
WriteCSSProperty(style, QStringLiteral("font-family"),
write_css_property(style, QStringLiteral("font-family"),
families.first());
}
if (fmt.hasProperty(QTextFormat::FontPointSize)) {
WriteCSSProperty(
write_css_property(
style, QStringLiteral("font-size"),
QStringLiteral("%1pt").arg(QString::number(fmt.fontPointSize())));
}
if (fmt.hasProperty(QTextFormat::FontWeight)) {
WriteCSSProperty(style, QStringLiteral("font-weight"),
write_css_property(style, QStringLiteral("font-weight"),
QString::number(fmt.fontWeight() * 8));
}
if (fmt.hasProperty(QTextFormat::FontItalic)) {
WriteCSSProperty(style, QStringLiteral("font-style"),
write_css_property(style, QStringLiteral("font-style"),
fmt.fontItalic() ? QStringLiteral("italic") :
QStringLiteral("normal"));
}
if (fmt.hasProperty(QTextFormat::FontStyleName)) {
WriteCSSProperty(style, QStringLiteral("-ove-font-style"),
write_css_property(style, QStringLiteral("-ove-font-style"),
fmt.fontStyleName().toString());
}
@@ -271,7 +271,7 @@ void Html::WriteCharFormat(QString *style, const QTextCharFormat &fmt)
}
if (!deco.isEmpty()) {
WriteCSSProperty(style, QStringLiteral("text-decoration"), deco);
write_css_property(style, QStringLiteral("text-decoration"), deco);
}
if (fmt.foreground().style() != Qt::NoBrush) {
@@ -288,37 +288,37 @@ void Html::WriteCharFormat(QString *style, const QTextCharFormat &fmt)
QString::number(color.alphaF()));
}
WriteCSSProperty(style, QStringLiteral("color"), cs);
write_css_property(style, QStringLiteral("color"), cs);
}
if (fmt.fontCapitalization() != QFont::MixedCase) {
if (fmt.fontCapitalization() == QFont::SmallCaps) {
WriteCSSProperty(style, QStringLiteral("font-variant"),
write_css_property(style, QStringLiteral("font-variant"),
QStringLiteral("small-caps"));
// TODO: Add others
}
}
if (fmt.fontLetterSpacing() != 0.0) {
WriteCSSProperty(style, QStringLiteral("letter-spacing"),
write_css_property(style, QStringLiteral("letter-spacing"),
QStringLiteral("%1%").arg(
QString::number(fmt.fontLetterSpacing())));
}
if (fmt.fontStretch() != 0) {
WriteCSSProperty(
write_css_property(
style, QStringLiteral("font-stretch"),
QStringLiteral("%1%").arg(QString::number(fmt.fontStretch())));
}
}
QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes)
QTextCharFormat Html::read_char_format(const QXmlStreamAttributes &attributes)
{
QTextCharFormat fmt;
foreach (const QXmlStreamAttribute &attr, attributes) {
if (StrEquals(attr.name(), QStringLiteral("style"))) {
auto css = GetCSSFromStyle(attr.value().toString());
if (str_equals(attr.name(), QStringLiteral("style"))) {
auto css = get_css_from_style(attr.value().toString());
for (auto it = css.begin(); it != css.end(); it++) {
const QString &first_val = it.value().first();
@@ -334,15 +334,15 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes)
fmt.setFontWeight(first_val.toInt() / 8);
} else if (it.key() == QStringLiteral("font-style")) {
fmt.setFontItalic(
StrEquals(first_val, QStringLiteral("italic")));
str_equals(first_val, QStringLiteral("italic")));
} else if (it.key() == QStringLiteral("text-decoration")) {
foreach (const QString &v, it.value()) {
if (StrEquals(v, QStringLiteral("underline"))) {
if (str_equals(v, QStringLiteral("underline"))) {
fmt.setFontUnderline(true);
} else if (StrEquals(v,
} else if (str_equals(v,
QStringLiteral("line-through"))) {
fmt.setFontStrikeOut(true);
} else if (StrEquals(v, QStringLiteral("overline"))) {
} else if (str_equals(v, QStringLiteral("overline"))) {
fmt.setFontOverline(true);
}
}
@@ -366,7 +366,7 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes)
fmt.setForeground(QColor(first_val));
}
} else if (it.key() == QStringLiteral("font-variant")) {
if (StrEquals(first_val, QStringLiteral("small-caps"))) {
if (str_equals(first_val, QStringLiteral("small-caps"))) {
fmt.setFontCapitalization(QFont::SmallCaps);
}
} else if (it.key() == QStringLiteral("letter-spacing")) {
@@ -387,25 +387,25 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes)
return fmt;
}
QTextBlockFormat Html::ReadBlockFormat(const QXmlStreamAttributes &attributes)
QTextBlockFormat Html::read_block_format(const QXmlStreamAttributes &attributes)
{
QTextBlockFormat block_fmt;
foreach (const QXmlStreamAttribute &attr, attributes) {
if (StrEquals(attr.name(), QStringLiteral("align"))) {
if (StrEquals(attr.value(), QStringLiteral("right"))) {
if (str_equals(attr.name(), QStringLiteral("align"))) {
if (str_equals(attr.value(), QStringLiteral("right"))) {
block_fmt.setAlignment(Qt::AlignRight);
} else if (StrEquals(attr.value(), QStringLiteral("center"))) {
} else if (str_equals(attr.value(), QStringLiteral("center"))) {
block_fmt.setAlignment(Qt::AlignHCenter);
} else if (StrEquals(attr.value(), QStringLiteral("justify"))) {
} else if (str_equals(attr.value(), QStringLiteral("justify"))) {
block_fmt.setAlignment(Qt::AlignJustify);
}
} else if (StrEquals(attr.name(), QStringLiteral("dir"))) {
if (StrEquals(attr.value(), QStringLiteral("rtl"))) {
} else if (str_equals(attr.name(), QStringLiteral("dir"))) {
if (str_equals(attr.value(), QStringLiteral("rtl"))) {
block_fmt.setLayoutDirection(Qt::RightToLeft);
}
} else if (StrEquals(attr.name(), QStringLiteral("style"))) {
auto css = GetCSSFromStyle(attr.value().toString());
} else if (str_equals(attr.name(), QStringLiteral("style"))) {
auto css = get_css_from_style(attr.value().toString());
for (auto it = css.begin(); it != css.end(); it++) {
if (it.key() == QStringLiteral("line-height")) {
@@ -423,7 +423,7 @@ QTextBlockFormat Html::ReadBlockFormat(const QXmlStreamAttributes &attributes)
return block_fmt;
}
void Html::AppendStringAutoSpace(QString *s, const QString &append)
void Html::append_string_auto_space(QString *s, const QString &append)
{
if (!s->isEmpty()) {
s->append(QChar(' '));
@@ -432,7 +432,7 @@ void Html::AppendStringAutoSpace(QString *s, const QString &append)
s->append(append);
}
QMap<QString, QStringList> Html::GetCSSFromStyle(const QString &s)
QMap<QString, QStringList> Html::get_css_from_style(const QString &s)
{
QMap<QString, QStringList> map;
+16 -16
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HTML_H
#define HTML_H
#ifndef OAK_HTML_H
#define OAK_HTML_H
#include <QTextDocument>
#include <QTextFragment>
@@ -45,39 +45,39 @@ namespace olive
*/
class Html {
public:
static QString DocToHtml(const QTextDocument *doc);
static QString doc_to_html(const QTextDocument *doc);
static void HtmlToDoc(QTextDocument *doc, const QString &html);
static void html_to_doc(QTextDocument *doc, const QString &html);
private:
static void WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block);
static void write_block(QXmlStreamWriter *writer, const QTextBlock &block);
static void WriteFragment(QXmlStreamWriter *writer,
static void write_fragment(QXmlStreamWriter *writer,
const QTextFragment &fragment);
static void WriteCSSProperty(QString *style, const QString &key,
static void write_css_property(QString *style, const QString &key,
const QStringList &value);
static void WriteCSSProperty(QString *style, const QString &key,
static void write_css_property(QString *style, const QString &key,
const QString &value)
{
WriteCSSProperty(style, key, QStringList({ value }));
write_css_property(style, key, QStringList({ value }));
}
static void WriteCharFormat(QString *style, const QTextCharFormat &fmt);
static void write_char_format(QString *style, const QTextCharFormat &fmt);
static QTextCharFormat
ReadCharFormat(const QXmlStreamAttributes &attributes);
read_char_format(const QXmlStreamAttributes &attributes);
static QTextBlockFormat
ReadBlockFormat(const QXmlStreamAttributes &attributes);
read_block_format(const QXmlStreamAttributes &attributes);
static void AppendStringAutoSpace(QString *s, const QString &append);
static void append_string_auto_space(QString *s, const QString &append);
static QMap<QString, QStringList> GetCSSFromStyle(const QString &s);
static QMap<QString, QStringList> get_css_from_style(const QString &s);
static const QVector<QString> kBlockTags;
static const QVector<QString> k_block_tags;
};
}
#endif // HTML_H
#endif // OAK_HTML_H
+2 -2
View File
@@ -28,10 +28,10 @@ QMutex job_time_mutex;
JobTime::JobTime()
{
Acquire();
acquire();
}
void JobTime::Acquire()
void JobTime::acquire()
{
job_time_mutex.lock();
+4 -4
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef JOBTIME_H
#define JOBTIME_H
#ifndef OAK_JOBTIME_H
#define OAK_JOBTIME_H
#include <QDebug>
#include <stdint.h>
@@ -29,7 +29,7 @@ class JobTime {
public:
JobTime();
void Acquire();
void acquire();
uint64_t value() const
{
@@ -76,4 +76,4 @@ QDebug operator<<(QDebug debug, const olive::JobTime &r);
Q_DECLARE_METATYPE(olive::JobTime)
#endif // JOBTIME_H
#endif // OAK_JOBTIME_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef LERP_H
#define LERP_H
#ifndef OAK_LERP_H
#define OAK_LERP_H
template <typename T>
/**
@@ -39,4 +39,4 @@ template <typename T> T lerp(T a, T b, float t)
return (a * (1.0f - t)) + (b * t);
}
#endif // LERP_H
#endif // OAK_LERP_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef MEMORYPOOL_H
#define MEMORYPOOL_H
#ifndef OAK_MEMORYPOOL_H
#define OAK_MEMORYPOOL_H
#include <memory>
#include <QApplication>
@@ -435,4 +435,4 @@ private slots:
}
#endif // MEMORYPOOL_H
#endif // OAK_MEMORYPOOL_H
+14 -14
View File
@@ -24,28 +24,28 @@
namespace olive
{
OCIO::BitDepth OCIOUtils::GetOCIOBitDepthFromPixelFormat(PixelFormat format)
ocio::BitDepth OCIOUtils::get_ocio_bit_depth_from_pixel_format(PixelFormat format)
{
switch (format) {
case PixelFormat::U8:
return OCIO::BIT_DEPTH_UINT8;
case PixelFormat::U10:
return OCIO::BIT_DEPTH_UINT10;
case PixelFormat::U16:
return OCIO::BIT_DEPTH_UINT16;
case PixelFormat::u8:
return ocio::BIT_DEPTH_UINT8;
case PixelFormat::u10:
return ocio::BIT_DEPTH_UINT10;
case PixelFormat::u16:
return ocio::BIT_DEPTH_UINT16;
break;
case PixelFormat::F16:
return OCIO::BIT_DEPTH_F16;
case PixelFormat::f16:
return ocio::BIT_DEPTH_F16;
break;
case PixelFormat::F32:
return OCIO::BIT_DEPTH_F32;
case PixelFormat::f32:
return ocio::BIT_DEPTH_F32;
break;
case PixelFormat::INVALID:
case PixelFormat::COUNT:
case PixelFormat::invalid:
case PixelFormat::count:
break;
}
return OCIO::BIT_DEPTH_UNKNOWN;
return ocio::BIT_DEPTH_UNKNOWN;
}
}
+5 -5
View File
@@ -19,11 +19,11 @@
***/
#ifndef OCIOUTILS_H
#define OCIOUTILS_H
#ifndef OAK_OCIOUTILS_H
#define OAK_OCIOUTILS_H
#include <OpenColorIO/OpenColorIO.h>
namespace OCIO = OCIO_NAMESPACE;
namespace ocio = OCIO_NAMESPACE;
#include "render/videoparams.h"
@@ -32,9 +32,9 @@ namespace olive
class OCIOUtils {
public:
static OCIO::BitDepth GetOCIOBitDepthFromPixelFormat(PixelFormat format);
static ocio::BitDepth get_ocio_bit_depth_from_pixel_format(PixelFormat format);
};
}
#endif // OCIOUTILS_H
#endif // OAK_OCIOUTILS_H
+10 -10
View File
@@ -26,25 +26,25 @@
namespace olive
{
void OIIOUtils::FrameToBuffer(const Frame *frame, OIIO::ImageBuf *buf)
void OIIOUtils::frame_to_buffer(const Frame *frame, OIIO::ImageBuf *buf)
{
buf->set_pixels(OIIO::ROI(), buf->spec().format, frame->const_data(),
OIIO::AutoStride, frame->linesize_bytes());
}
void OIIOUtils::BufferToFrame(OIIO::ImageBuf *buf, Frame *frame)
void OIIOUtils::buffer_to_frame(OIIO::ImageBuf *buf, Frame *frame)
{
buf->get_pixels(OIIO::ROI(), buf->spec().format, frame->data(),
OIIO::AutoStride, frame->linesize_bytes());
}
rational OIIOUtils::GetPixelAspectRatioFromOIIO(const OIIO::ImageSpec &spec)
Rational OIIOUtils::get_pixel_aspect_ratio_from_oiio(const OIIO::ImageSpec &spec)
{
return rational::fromDouble(
return Rational::from_double(
spec.get_float_attribute("PixelAspectRatio", 1));
}
PixelFormat OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::BASETYPE type)
PixelFormat OIIOUtils::get_format_from_oiio_basetype(OIIO::TypeDesc::BASETYPE type)
{
switch (type) {
case OIIO::TypeDesc::UNKNOWN:
@@ -65,16 +65,16 @@ PixelFormat OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::BASETYPE type)
break;
case OIIO::TypeDesc::UINT8:
return PixelFormat::U8;
return PixelFormat::u8;
case OIIO::TypeDesc::UINT16:
return PixelFormat::U16;
return PixelFormat::u16;
case OIIO::TypeDesc::HALF:
return PixelFormat::F16;
return PixelFormat::f16;
case OIIO::TypeDesc::FLOAT:
return PixelFormat::F32;
return PixelFormat::f32;
}
return PixelFormat::INVALID;
return PixelFormat::invalid;
}
}
+15 -15
View File
@@ -19,8 +19,8 @@
***/
#ifndef OIIOUTILS_H
#define OIIOUTILS_H
#ifndef OAK_OIIOUTILS_H
#define OAK_OIIOUTILS_H
#include <OpenImageIO/imagebuf.h>
#include <OpenImageIO/typedesc.h>
@@ -34,36 +34,36 @@ namespace olive
class OIIOUtils {
public:
static OIIO::TypeDesc::BASETYPE
GetOIIOBaseTypeFromFormat(PixelFormat format)
get_oiio_base_type_from_format(PixelFormat format)
{
switch (format) {
case PixelFormat::U8:
case PixelFormat::u8:
return OIIO::TypeDesc::UINT8;
case PixelFormat::U10:
case PixelFormat::u10:
return OIIO::TypeDesc::UNKNOWN;
case PixelFormat::U16:
case PixelFormat::u16:
return OIIO::TypeDesc::UINT16;
case PixelFormat::F16:
case PixelFormat::f16:
return OIIO::TypeDesc::HALF;
case PixelFormat::F32:
case PixelFormat::f32:
return OIIO::TypeDesc::FLOAT;
case PixelFormat::INVALID:
case PixelFormat::COUNT:
case PixelFormat::invalid:
case PixelFormat::count:
break;
}
return OIIO::TypeDesc::UNKNOWN;
}
static void FrameToBuffer(const Frame *frame, OIIO::ImageBuf *buf);
static void frame_to_buffer(const Frame *frame, OIIO::ImageBuf *buf);
static void BufferToFrame(OIIO::ImageBuf *buf, Frame *frame);
static void buffer_to_frame(OIIO::ImageBuf *buf, Frame *frame);
static PixelFormat GetFormatFromOIIOBasetype(OIIO::TypeDesc::BASETYPE type);
static PixelFormat get_format_from_oiio_basetype(OIIO::TypeDesc::BASETYPE type);
static rational GetPixelAspectRatioFromOIIO(const OIIO::ImageSpec &spec);
static Rational get_pixel_aspect_ratio_from_oiio(const OIIO::ImageSpec &spec);
};
}
#endif // OIIOUTILS_H
#endif // OAK_OIIOUTILS_H
+2 -2
View File
@@ -18,8 +18,8 @@
***/
#ifndef OTIOUTILS_H
#define OTIOUTILS_H
#ifndef OAK_OTIOUTILS_H
#define OAK_OTIOUTILS_H
#ifdef USE_OTIO
#include <opentimelineio/version.h>
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef POWER_H
#define POWER_H
#ifndef OAK_POWER_H
#define OAK_POWER_H
#include <stdint.h>
@@ -55,4 +55,4 @@ uint32_t floor_to_power_of_2(uint32_t x)
}
#endif // POWER_H
#endif // OAK_POWER_H
+17 -17
View File
@@ -26,7 +26,7 @@
namespace olive
{
int QtUtils::QFontMetricsWidth(QFontMetrics fm, const QString &s)
int QtUtils::q_font_metrics_width(QFontMetrics fm, const QString &s)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
return fm.width(s);
@@ -35,7 +35,7 @@ int QtUtils::QFontMetricsWidth(QFontMetrics fm, const QString &s)
#endif
}
QFrame *QtUtils::CreateHorizontalLine()
QFrame *QtUtils::create_horizontal_line()
{
QFrame *horizontal_line = new QFrame();
horizontal_line->setFrameShape(QFrame::HLine);
@@ -43,14 +43,14 @@ QFrame *QtUtils::CreateHorizontalLine()
return horizontal_line;
}
QFrame *QtUtils::CreateVerticalLine()
QFrame *QtUtils::create_vertical_line()
{
QFrame *l = CreateHorizontalLine();
QFrame *l = create_horizontal_line();
l->setFrameShape(QFrame::VLine);
return l;
}
int QtUtils::MsgBox(QWidget *parent, QMessageBox::Icon icon,
int QtUtils::msg_box(QWidget *parent, QMessageBox::Icon icon,
const QString &title, const QString &message,
QMessageBox::StandardButtons buttons)
{
@@ -72,7 +72,7 @@ int QtUtils::MsgBox(QWidget *parent, QMessageBox::Icon icon,
return b.exec();
}
QDateTime QtUtils::GetCreationDate(const QFileInfo &info)
QDateTime QtUtils::get_creation_date(const QFileInfo &info)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
return info.created();
@@ -85,12 +85,12 @@ QDateTime QtUtils::GetCreationDate(const QFileInfo &info)
#endif
}
QString QtUtils::GetFormattedDateTime(const QDateTime &dt)
QString QtUtils::get_formatted_date_time(const QDateTime &dt)
{
return dt.toString(Qt::TextDate);
}
QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
QStringList QtUtils::word_wrap_string(const QString &s, const QFontMetrics &fm,
int bounding_width)
{
QStringList list;
@@ -102,7 +102,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
QString this_line = lines.at(i);
while (this_line.size() > 1 &&
QFontMetricsWidth(fm, this_line) >= bounding_width) {
q_font_metrics_width(fm, this_line) >= bounding_width) {
int old_size = this_line.size();
int hard_break = -1;
@@ -110,7 +110,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
const QChar &char_test = this_line.at(j);
if (char_test.isSpace() || char_test == '-') {
if (QFontMetricsWidth(fm, this_line.left(j)) <
if (q_font_metrics_width(fm, this_line.left(j)) <
bounding_width) {
if (!char_test.isSpace()) {
j++;
@@ -128,7 +128,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
break;
}
} else if (hard_break == -1 &&
QFontMetricsWidth(fm, this_line.left(j)) <
q_font_metrics_width(fm, this_line.left(j)) <
bounding_width) {
// In case we can't find a better place to split, split at the earliest time the line
// goes under the width limit
@@ -157,7 +157,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm,
}
Qt::KeyboardModifiers
QtUtils::FlipControlAndShiftModifiers(Qt::KeyboardModifiers e)
QtUtils::flip_control_and_shift_modifiers(Qt::KeyboardModifiers e)
{
if (e & Qt::ControlModifier & Qt::ShiftModifier) {
return e;
@@ -174,7 +174,7 @@ QtUtils::FlipControlAndShiftModifiers(Qt::KeyboardModifiers e)
return e;
}
void QtUtils::SetComboBoxData(QComboBox *cb, int data)
void QtUtils::set_combo_box_data(QComboBox *cb, int data)
{
for (int i = 0; i < cb->count(); i++) {
if (cb->itemData(i).toInt() == data) {
@@ -184,7 +184,7 @@ void QtUtils::SetComboBoxData(QComboBox *cb, int data)
}
}
void QtUtils::SetComboBoxData(QComboBox *cb, const QString &data)
void QtUtils::set_combo_box_data(QComboBox *cb, const QString &data)
{
for (int i = 0; i < cb->count(); i++) {
if (cb->itemData(i).toString() == data) {
@@ -194,7 +194,7 @@ void QtUtils::SetComboBoxData(QComboBox *cb, const QString &data)
}
}
QColor QtUtils::toQColor(const core::Color &i)
QColor QtUtils::to_q_color(const core::Color &i)
{
QColor c;
@@ -210,9 +210,9 @@ QColor QtUtils::toQColor(const core::Color &i)
namespace core
{
uint qHash(const core::rational &r, uint seed)
uint qHash(const core::Rational &r, uint seed)
{
return ::qHash(r.toDouble(), seed);
return ::qHash(r.to_double(), seed);
}
uint qHash(const core::TimeRange &r, uint seed)
+19 -19
View File
@@ -19,8 +19,8 @@
***/
#ifndef QTVERSIONABSTRACTION_H
#define QTVERSIONABSTRACTION_H
#ifndef OAK_QTVERSIONABSTRACTION_H
#define OAK_QTVERSIONABSTRACTION_H
#include <olive/core/core.h>
#include <QComboBox>
@@ -42,30 +42,30 @@ public:
* latter was only introduced in 5.11+. This function wraps the latter for 5.11+ and the former for
* earlier.
*/
static int QFontMetricsWidth(QFontMetrics fm, const QString &s);
static int q_font_metrics_width(QFontMetrics fm, const QString &s);
static QFrame *CreateHorizontalLine();
static QFrame *create_horizontal_line();
static QFrame *CreateVerticalLine();
static QFrame *create_vertical_line();
static int MsgBox(QWidget *parent, QMessageBox::Icon icon,
static int msg_box(QWidget *parent, QMessageBox::Icon icon,
const QString &title, const QString &message,
QMessageBox::StandardButtons buttons = QMessageBox::Ok);
static QDateTime GetCreationDate(const QFileInfo &info);
static QDateTime get_creation_date(const QFileInfo &info);
static QString GetFormattedDateTime(const QDateTime &dt);
static QString get_formatted_date_time(const QDateTime &dt);
static QStringList WordWrapString(const QString &s, const QFontMetrics &fm,
static QStringList word_wrap_string(const QString &s, const QFontMetrics &fm,
int bounding_width);
static Qt::KeyboardModifiers
FlipControlAndShiftModifiers(Qt::KeyboardModifiers e);
flip_control_and_shift_modifiers(Qt::KeyboardModifiers e);
static void SetComboBoxData(QComboBox *cb, int data);
static void SetComboBoxData(QComboBox *cb, const QString &data);
static void set_combo_box_data(QComboBox *cb, int data);
static void set_combo_box_data(QComboBox *cb, const QString &data);
template <typename T> static T *GetParentOfType(const QObject *child)
template <typename T> static T *get_parent_of_type(const QObject *child)
{
QObject *t = child->parent();
@@ -79,12 +79,12 @@ public:
return nullptr;
}
static QColor toQColor(const core::Color &c);
static QColor to_q_color(const core::Color &c);
/**
* @brief Convert a pointer to a value that can be sent between NodeParams
*/
static QVariant PtrToValue(void *ptr)
static QVariant ptr_to_value(void *ptr)
{
return reinterpret_cast<quintptr>(ptr);
}
@@ -92,7 +92,7 @@ public:
/**
* @brief Convert a NodeParam value to a pointer of any kind
*/
template <class T> static T *ValueToPtr(const QVariant &ptr)
template <class T> static T *value_to_ptr(const QVariant &ptr)
{
return reinterpret_cast<T *>(ptr.value<quintptr>());
}
@@ -101,18 +101,18 @@ public:
namespace core
{
uint qHash(const core::rational &r, uint seed = 0);
uint qHash(const core::Rational &r, uint seed = 0);
uint qHash(const core::TimeRange &r, uint seed = 0);
}
}
Q_DECLARE_METATYPE(olive::core::rational)
Q_DECLARE_METATYPE(olive::core::Rational)
Q_DECLARE_METATYPE(olive::core::Color)
Q_DECLARE_METATYPE(olive::core::TimeRange)
Q_DECLARE_METATYPE(olive::core::Bezier)
Q_DECLARE_METATYPE(olive::core::AudioParams)
Q_DECLARE_METATYPE(olive::core::SampleBuffer)
#endif // QTVERSIONABSTRACTION_H
#endif // OAK_QTVERSIONABSTRACTION_H
+4 -4
View File
@@ -19,12 +19,12 @@
***/
#ifndef RANGE_H
#define RANGE_H
#ifndef OAK_RANGE_H
#define OAK_RANGE_H
template <typename T> bool InRange(T a, T b, T range)
template <typename T> bool in_range(T a, T b, T range)
{
return (a >= b - range && a <= b + range);
}
#endif // RANGE_H
#endif // OAK_RANGE_H
+2 -2
View File
@@ -28,7 +28,7 @@
namespace olive
{
double GetFloatRatioFromUser(QWidget *parent, const QString &title, bool *ok_in)
double get_float_ratio_from_user(QWidget *parent, const QString &title, bool *ok_in)
{
QString s;
@@ -86,7 +86,7 @@ double GetFloatRatioFromUser(QWidget *parent, const QString &title, bool *ok_in)
QCoreApplication::translate(
"RatioDialog",
"Failed to parse \"%1\" into an aspect ratio. Please format a "
"rational fraction with a ':' or a '/' separator.")
"Rational fraction with a ':' or a '/' separator.")
.arg(s),
QMessageBox::Ok);
}
+4 -4
View File
@@ -19,17 +19,17 @@
***/
#ifndef RATIODIALOG_H
#define RATIODIALOG_H
#ifndef OAK_RATIODIALOG_H
#define OAK_RATIODIALOG_H
#include <QInputDialog>
namespace olive
{
double GetFloatRatioFromUser(QWidget *parent, const QString &title,
double get_float_ratio_from_user(QWidget *parent, const QString &title,
bool *ok_in);
}
#endif // RATIODIALOG_H
#endif // OAK_RATIODIALOG_H
+3 -3
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef THREADSAFEMAP_H
#define THREADSAFEMAP_H
#ifndef OAK_THREADSAFEMAP_H
#define OAK_THREADSAFEMAP_H
#include <QMap>
#include <QMutex>
@@ -39,4 +39,4 @@ private:
QMap<K, V> map_;
};
#endif // THREADSAFEMAP_H
#endif // OAK_THREADSAFEMAP_H
+4 -4
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOHEX_H
#define TOHEX_H
#ifndef OAK_TOHEX_H
#define OAK_TOHEX_H
#include <QString>
#include <QtGlobal>
@@ -27,11 +27,11 @@
namespace olive
{
inline QString ToHex(quint64 t)
inline QString to_hex(quint64 t)
{
return QStringLiteral("%1").arg(t, 0, 16);
}
}
#endif // TOHEX_H
#endif // OAK_TOHEX_H
+3 -3
View File
@@ -19,12 +19,12 @@
***/
#ifndef UTIL_H
#define UTIL_H
#ifndef OAK_UTIL_H
#define OAK_UTIL_H
template <typename T> inline T mid(T a, T b)
{
return (a + b) * 0.5;
}
#endif // UTIL_H
#endif // OAK_UTIL_H
+2 -2
View File
@@ -27,13 +27,13 @@
namespace olive
{
bool XMLReadNextStartElement(QXmlStreamReader *reader, CancelAtom *cancel_atom)
bool xml_read_next_start_element(QXmlStreamReader *reader, CancelAtom *cancel_atom)
{
QXmlStreamReader::TokenType token;
while ((token = reader->readNext()) != QXmlStreamReader::Invalid &&
token != QXmlStreamReader::EndDocument &&
(!cancel_atom || !cancel_atom->IsCancelled())) {
(!cancel_atom || !cancel_atom->is_cancelled())) {
if (reader->isEndElement()) {
return false;
} else if (reader->isStartElement()) {
+4 -4
View File
@@ -19,8 +19,8 @@
***/
#ifndef XMLREADLOOP_H
#define XMLREADLOOP_H
#ifndef OAK_XMLREADLOOP_H
#define OAK_XMLREADLOOP_H
#include <QXmlStreamReader>
@@ -48,9 +48,9 @@ class NodeGroup;
*
* See also: https://stackoverflow.com/questions/46346450/qt-qxmlstreamreader-always-returns-premature-end-of-document-error
*/
bool XMLReadNextStartElement(QXmlStreamReader *reader,
bool xml_read_next_start_element(QXmlStreamReader *reader,
CancelAtom *cancel_atom = nullptr);
}
#endif // XMLREADLOOP_H
#endif // OAK_XMLREADLOOP_H
+182 -182
View File
@@ -42,239 +42,239 @@
namespace olive
{
Config Config::current_config_;
Config Config::current_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)
{
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"));
}
Config &Config::Current()
Config &Config::current()
{
return current_config_;
return current_config;
}
void Config::SetDefaults()
void Config::set_defaults()
{
config_map_.clear();
SetEntryInternal(QStringLiteral("Style"), NodeValue::kText,
StyleManager::kDefaultStyle);
SetEntryInternal(QStringLiteral("TimecodeDisplay"), NodeValue::kInt,
Timecode::kTimecodeDropFrame);
SetEntryInternal(QStringLiteral("DefaultStillLength"), NodeValue::kRational,
QVariant::fromValue(rational(2)));
SetEntryInternal(QStringLiteral("HoverFocus"), NodeValue::kBoolean, false);
SetEntryInternal(QStringLiteral("AudioScrubbing"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("Style"), NodeValue::k_text,
StyleManager::k_default_style);
set_entry_internal(QStringLiteral("TimecodeDisplay"), NodeValue::k_int,
Timecode::k_timecode_drop_frame);
set_entry_internal(QStringLiteral("DefaultStillLength"), NodeValue::k_rational,
QVariant::fromValue(Rational(2)));
set_entry_internal(QStringLiteral("HoverFocus"), NodeValue::k_boolean, false);
set_entry_internal(QStringLiteral("AudioScrubbing"), NodeValue::k_boolean,
true);
SetEntryInternal(QStringLiteral("AutorecoveryEnabled"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("AutorecoveryEnabled"), NodeValue::k_boolean,
true);
SetEntryInternal(QStringLiteral("AutorecoveryInterval"), NodeValue::kInt,
set_entry_internal(QStringLiteral("AutorecoveryInterval"), NodeValue::k_int,
1);
SetEntryInternal(QStringLiteral("AutorecoveryMaximum"), NodeValue::kInt,
set_entry_internal(QStringLiteral("AutorecoveryMaximum"), NodeValue::k_int,
20);
SetEntryInternal(QStringLiteral("DiskCacheSaveInterval"), NodeValue::kInt,
set_entry_internal(QStringLiteral("DiskCacheSaveInterval"), NodeValue::k_int,
10000);
SetEntryInternal(QStringLiteral("Language"), NodeValue::kText, QString());
SetEntryInternal(QStringLiteral("ScrollZooms"), NodeValue::kBoolean, false);
SetEntryInternal(QStringLiteral("EnableSeekToImport"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("Language"), NodeValue::k_text, QString());
set_entry_internal(QStringLiteral("ScrollZooms"), NodeValue::k_boolean, false);
set_entry_internal(QStringLiteral("EnableSeekToImport"), NodeValue::k_boolean,
false);
SetEntryInternal(QStringLiteral("EditToolAlsoSeeks"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("EditToolAlsoSeeks"), NodeValue::k_boolean,
false);
SetEntryInternal(QStringLiteral("EditToolSelectsLinks"),
NodeValue::kBoolean, false);
SetEntryInternal(QStringLiteral("EnableDragFilesToTimeline"),
NodeValue::kBoolean, true);
SetEntryInternal(QStringLiteral("InvertTimelineScrollAxes"),
NodeValue::kBoolean, true);
SetEntryInternal(QStringLiteral("SelectAlsoSeeks"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("EditToolSelectsLinks"),
NodeValue::k_boolean, false);
set_entry_internal(QStringLiteral("EnableDragFilesToTimeline"),
NodeValue::k_boolean, true);
set_entry_internal(QStringLiteral("InvertTimelineScrollAxes"),
NodeValue::k_boolean, true);
set_entry_internal(QStringLiteral("SelectAlsoSeeks"), NodeValue::k_boolean,
false);
SetEntryInternal(QStringLiteral("PasteSeeks"), NodeValue::kBoolean, true);
SetEntryInternal(QStringLiteral("SeekAlsoSelects"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("PasteSeeks"), NodeValue::k_boolean, true);
set_entry_internal(QStringLiteral("SeekAlsoSelects"), NodeValue::k_boolean,
false);
SetEntryInternal(QStringLiteral("SetNameWithMarker"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("SetNameWithMarker"), NodeValue::k_boolean,
false);
SetEntryInternal(QStringLiteral("AutoSeekToBeginning"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("AutoSeekToBeginning"), NodeValue::k_boolean,
true);
SetEntryInternal(QStringLiteral("DropFileOnMediaToReplace"),
NodeValue::kBoolean, false);
SetEntryInternal(QStringLiteral("AddDefaultEffectsToClips"),
NodeValue::kBoolean, true);
SetEntryInternal(QStringLiteral("AutoscaleByDefault"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("DropFileOnMediaToReplace"),
NodeValue::k_boolean, false);
set_entry_internal(QStringLiteral("AddDefaultEffectsToClips"),
NodeValue::k_boolean, true);
set_entry_internal(QStringLiteral("AutoscaleByDefault"), NodeValue::k_boolean,
false);
SetEntryInternal(QStringLiteral("Autoscroll"), NodeValue::kInt,
AutoScroll::kPage);
SetEntryInternal(QStringLiteral("AutoSelectDivider"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("Autoscroll"), NodeValue::k_int,
AutoScroll::k_page);
set_entry_internal(QStringLiteral("AutoSelectDivider"), NodeValue::k_boolean,
true);
SetEntryInternal(QStringLiteral("SetNameWithMarker"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("SetNameWithMarker"), NodeValue::k_boolean,
false);
SetEntryInternal(QStringLiteral("RectifiedWaveforms"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("RectifiedWaveforms"), NodeValue::k_boolean,
true);
SetEntryInternal(QStringLiteral("DropWithoutSequenceBehavior"),
NodeValue::kInt, ImportTool::kDWSAsk);
SetEntryInternal(QStringLiteral("Loop"), NodeValue::kBoolean, false);
SetEntryInternal(QStringLiteral("SplitClipsCopyNodes"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("DropWithoutSequenceBehavior"),
NodeValue::k_int, ImportTool::k_dws_ask);
set_entry_internal(QStringLiteral("Loop"), NodeValue::k_boolean, false);
set_entry_internal(QStringLiteral("SplitClipsCopyNodes"), NodeValue::k_boolean,
true);
SetEntryInternal(QStringLiteral("UseGradients"), NodeValue::kBoolean, true);
SetEntryInternal(QStringLiteral("AutoMergeTracks"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("UseGradients"), NodeValue::k_boolean, true);
set_entry_internal(QStringLiteral("AutoMergeTracks"), NodeValue::k_boolean,
true);
SetEntryInternal(QStringLiteral("UseSliderLadders"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("UseSliderLadders"), NodeValue::k_boolean,
true);
SetEntryInternal(QStringLiteral("ShowWelcomeDialog"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("ShowWelcomeDialog"), NodeValue::k_boolean,
true);
SetEntryInternal(QStringLiteral("ShowClipWhileDragging"),
NodeValue::kBoolean, true);
SetEntryInternal(QStringLiteral("StopPlaybackOnLastFrame"),
NodeValue::kBoolean, false);
SetEntryInternal(QStringLiteral("UseLegacyColorInInputTab"),
NodeValue::kBoolean, false);
SetEntryInternal(QStringLiteral("ReassocLinToNonLin"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("ShowClipWhileDragging"),
NodeValue::k_boolean, true);
set_entry_internal(QStringLiteral("StopPlaybackOnLastFrame"),
NodeValue::k_boolean, false);
set_entry_internal(QStringLiteral("UseLegacyColorInInputTab"),
NodeValue::k_boolean, false);
set_entry_internal(QStringLiteral("ReassocLinToNonLin"), NodeValue::k_boolean,
false);
SetEntryInternal(QStringLiteral("PreviewNonFloatDontAskAgain"),
NodeValue::kBoolean, false);
SetEntryInternal(QStringLiteral("UseGLFinish"), NodeValue::kBoolean, false);
SetEntryInternal(QStringLiteral("GraphicsBackend"), NodeValue::kText,
set_entry_internal(QStringLiteral("PreviewNonFloatDontAskAgain"),
NodeValue::k_boolean, false);
set_entry_internal(QStringLiteral("UseGLFinish"), NodeValue::k_boolean, false);
set_entry_internal(QStringLiteral("GraphicsBackend"), NodeValue::k_text,
QStringLiteral("opengl"));
SetEntryInternal(QStringLiteral("TimelineThumbnailMode"), NodeValue::kInt,
Timeline::kThumbnailInOut);
SetEntryInternal(QStringLiteral("TimelineWaveformMode"), NodeValue::kInt,
Timeline::kWaveformsEnabled);
set_entry_internal(QStringLiteral("TimelineThumbnailMode"), NodeValue::k_int,
Timeline::k_thumbnail_in_out);
set_entry_internal(QStringLiteral("TimelineWaveformMode"), NodeValue::k_int,
Timeline::k_waveforms_enabled);
SetEntryInternal(
QStringLiteral("DefaultVideoTransition"), NodeValue::kText,
set_entry_internal(
QStringLiteral("DefaultVideoTransition"), NodeValue::k_text,
QStringLiteral("org.olivevideoeditor.Olive.crossdissolve"));
SetEntryInternal(
QStringLiteral("DefaultAudioTransition"), NodeValue::kText,
set_entry_internal(
QStringLiteral("DefaultAudioTransition"), NodeValue::k_text,
QStringLiteral("org.olivevideoeditor.Olive.crossdissolve"));
SetEntryInternal(QStringLiteral("DefaultTransitionLength"),
NodeValue::kRational, QVariant::fromValue(rational(1)));
set_entry_internal(QStringLiteral("DefaultTransitionLength"),
NodeValue::k_rational, QVariant::fromValue(Rational(1)));
SetEntryInternal(QStringLiteral("DefaultSubtitleSize"), NodeValue::kInt,
set_entry_internal(QStringLiteral("DefaultSubtitleSize"), NodeValue::k_int,
48);
SetEntryInternal(QStringLiteral("DefaultSubtitleFamily"), NodeValue::kText,
set_entry_internal(QStringLiteral("DefaultSubtitleFamily"), NodeValue::k_text,
QString());
SetEntryInternal(QStringLiteral("DefaultSubtitleWeight"), NodeValue::kInt,
set_entry_internal(QStringLiteral("DefaultSubtitleWeight"), NodeValue::k_int,
QFont::Bold);
SetEntryInternal(QStringLiteral("AntialiasSubtitles"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("AntialiasSubtitles"), NodeValue::k_boolean,
true);
SetEntryInternal(QStringLiteral("AutoCacheDelay"), NodeValue::kInt, 1000);
set_entry_internal(QStringLiteral("AutoCacheDelay"), NodeValue::k_int, 1000);
SetEntryInternal(QStringLiteral("CatColor0"), NodeValue::kInt,
ColorCoding::kRed);
SetEntryInternal(QStringLiteral("CatColor1"), NodeValue::kInt,
ColorCoding::kMaroon);
SetEntryInternal(QStringLiteral("CatColor2"), NodeValue::kInt,
ColorCoding::kOrange);
SetEntryInternal(QStringLiteral("CatColor3"), NodeValue::kInt,
ColorCoding::kBrown);
SetEntryInternal(QStringLiteral("CatColor4"), NodeValue::kInt,
ColorCoding::kYellow);
SetEntryInternal(QStringLiteral("CatColor5"), NodeValue::kInt,
ColorCoding::kOlive);
SetEntryInternal(QStringLiteral("CatColor6"), NodeValue::kInt,
ColorCoding::kLime);
SetEntryInternal(QStringLiteral("CatColor7"), NodeValue::kInt,
ColorCoding::kGreen);
SetEntryInternal(QStringLiteral("CatColor8"), NodeValue::kInt,
ColorCoding::kCyan);
SetEntryInternal(QStringLiteral("CatColor9"), NodeValue::kInt,
ColorCoding::kTeal);
SetEntryInternal(QStringLiteral("CatColor10"), NodeValue::kInt,
ColorCoding::kBlue);
SetEntryInternal(QStringLiteral("CatColor11"), NodeValue::kInt,
ColorCoding::kNavy);
set_entry_internal(QStringLiteral("CatColor0"), NodeValue::k_int,
ColorCoding::k_red);
set_entry_internal(QStringLiteral("CatColor1"), NodeValue::k_int,
ColorCoding::k_maroon);
set_entry_internal(QStringLiteral("CatColor2"), NodeValue::k_int,
ColorCoding::k_orange);
set_entry_internal(QStringLiteral("CatColor3"), NodeValue::k_int,
ColorCoding::k_brown);
set_entry_internal(QStringLiteral("CatColor4"), NodeValue::k_int,
ColorCoding::k_yellow);
set_entry_internal(QStringLiteral("CatColor5"), NodeValue::k_int,
ColorCoding::k_olive);
set_entry_internal(QStringLiteral("CatColor6"), NodeValue::k_int,
ColorCoding::k_lime);
set_entry_internal(QStringLiteral("CatColor7"), NodeValue::k_int,
ColorCoding::k_green);
set_entry_internal(QStringLiteral("CatColor8"), NodeValue::k_int,
ColorCoding::k_cyan);
set_entry_internal(QStringLiteral("CatColor9"), NodeValue::k_int,
ColorCoding::k_teal);
set_entry_internal(QStringLiteral("CatColor10"), NodeValue::k_int,
ColorCoding::k_blue);
set_entry_internal(QStringLiteral("CatColor11"), NodeValue::k_int,
ColorCoding::k_navy);
SetEntryInternal(QStringLiteral("AudioOutput"), NodeValue::kText,
set_entry_internal(QStringLiteral("AudioOutput"), NodeValue::k_text,
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);
SetEntryInternal(QStringLiteral("AudioOutputChannelLayout"),
NodeValue::kInt,
QVariant::fromValue(static_cast<int64_t>(kChannelLayoutStereo)));
SetEntryInternal(
QStringLiteral("AudioOutputSampleFormat"), NodeValue::kText,
QString::fromStdString(SampleFormat(SampleFormat::S16).to_string()));
set_entry_internal(QStringLiteral("AudioOutputChannelLayout"),
NodeValue::k_int,
QVariant::fromValue(static_cast<int64_t>(k_channel_layout_stereo)));
set_entry_internal(
QStringLiteral("AudioOutputSampleFormat"), NodeValue::k_text,
QString::fromStdString(SampleFormat(SampleFormat::s16).to_string()));
SetEntryInternal(QStringLiteral("AudioRecordingFormat"), NodeValue::kInt,
ExportFormat::kFormatWAV);
SetEntryInternal(QStringLiteral("AudioRecordingCodec"), NodeValue::kInt,
ExportCodec::kCodecPCM);
SetEntryInternal(QStringLiteral("AudioRecordingSampleRate"),
NodeValue::kInt, 48000);
SetEntryInternal(QStringLiteral("AudioRecordingChannelLayout"),
NodeValue::kInt,
QVariant::fromValue(static_cast<int64_t>(kChannelLayoutStereo)));
SetEntryInternal(
QStringLiteral("AudioRecordingSampleFormat"), NodeValue::kText,
QString::fromStdString(SampleFormat(SampleFormat::S16).to_string()));
SetEntryInternal(QStringLiteral("AudioRecordingBitRate"), NodeValue::kInt,
set_entry_internal(QStringLiteral("AudioRecordingFormat"), NodeValue::k_int,
ExportFormat::k_format_wav);
set_entry_internal(QStringLiteral("AudioRecordingCodec"), NodeValue::k_int,
ExportCodec::k_codec_pcm);
set_entry_internal(QStringLiteral("AudioRecordingSampleRate"),
NodeValue::k_int, 48000);
set_entry_internal(QStringLiteral("AudioRecordingChannelLayout"),
NodeValue::k_int,
QVariant::fromValue(static_cast<int64_t>(k_channel_layout_stereo)));
set_entry_internal(
QStringLiteral("AudioRecordingSampleFormat"), NodeValue::k_text,
QString::fromStdString(SampleFormat(SampleFormat::s16).to_string()));
set_entry_internal(QStringLiteral("AudioRecordingBitRate"), NodeValue::k_int,
320);
SetEntryInternal(QStringLiteral("DiskCacheBehind"), NodeValue::kRational,
QVariant::fromValue(rational(0)));
SetEntryInternal(QStringLiteral("DiskCacheAhead"), NodeValue::kRational,
QVariant::fromValue(rational(60)));
set_entry_internal(QStringLiteral("DiskCacheBehind"), NodeValue::k_rational,
QVariant::fromValue(Rational(0)));
set_entry_internal(QStringLiteral("DiskCacheAhead"), NodeValue::k_rational,
QVariant::fromValue(Rational(60)));
SetEntryInternal(QStringLiteral("ProxyWidth"), NodeValue::kInt, 1280);
SetEntryInternal(QStringLiteral("ProxyHeight"), NodeValue::kInt, 720);
SetEntryInternal(QStringLiteral("ProxyCRF"), NodeValue::kInt, 23);
SetEntryInternal(QStringLiteral("ProxyPreset"), NodeValue::kText,
set_entry_internal(QStringLiteral("ProxyWidth"), NodeValue::k_int, 1280);
set_entry_internal(QStringLiteral("ProxyHeight"), NodeValue::k_int, 720);
set_entry_internal(QStringLiteral("ProxyCRF"), NodeValue::k_int, 23);
set_entry_internal(QStringLiteral("ProxyPreset"), NodeValue::k_text,
QStringLiteral("veryfast"));
SetEntryInternal(QStringLiteral("ProxyIncludeAudio"), NodeValue::kBoolean,
set_entry_internal(QStringLiteral("ProxyIncludeAudio"), NodeValue::k_boolean,
true);
SetEntryInternal(QStringLiteral("FFmpegPath"), NodeValue::kText,
set_entry_internal(QStringLiteral("FFmpegPath"), NodeValue::k_text,
QString());
SetEntryInternal(QStringLiteral("LUTLibraryPaths"), NodeValue::kText,
set_entry_internal(QStringLiteral("LUTLibraryPaths"), NodeValue::k_text,
QString());
SetEntryInternal(QStringLiteral("DefaultSequenceWidth"), NodeValue::kInt,
set_entry_internal(QStringLiteral("DefaultSequenceWidth"), NodeValue::k_int,
1920);
SetEntryInternal(QStringLiteral("DefaultSequenceHeight"), NodeValue::kInt,
set_entry_internal(QStringLiteral("DefaultSequenceHeight"), NodeValue::k_int,
1080);
SetEntryInternal(QStringLiteral("DefaultSequencePixelAspect"),
NodeValue::kRational, QVariant::fromValue(rational(1)));
SetEntryInternal(QStringLiteral("DefaultSequenceFrameRate"),
NodeValue::kRational,
QVariant::fromValue(rational(1001, 30000)));
SetEntryInternal(QStringLiteral("DefaultSequenceInterlacing"),
NodeValue::kInt, VideoParams::kInterlaceNone);
SetEntryInternal(QStringLiteral("DefaultSequenceAutoCache2"),
NodeValue::kBoolean, true);
SetEntryInternal(QStringLiteral("DefaultSequenceAudioFrequency"),
NodeValue::kInt, 48000);
SetEntryInternal(
QStringLiteral("DefaultSequenceAudioLayout"), NodeValue::kInt,
QVariant::fromValue(static_cast<int64_t>(kChannelLayoutStereo)));
set_entry_internal(QStringLiteral("DefaultSequencePixelAspect"),
NodeValue::k_rational, QVariant::fromValue(Rational(1)));
set_entry_internal(QStringLiteral("DefaultSequenceFrameRate"),
NodeValue::k_rational,
QVariant::fromValue(Rational(1001, 30000)));
set_entry_internal(QStringLiteral("DefaultSequenceInterlacing"),
NodeValue::k_int, VideoParams::k_interlace_none);
set_entry_internal(QStringLiteral("DefaultSequenceAutoCache2"),
NodeValue::k_boolean, true);
set_entry_internal(QStringLiteral("DefaultSequenceAudioFrequency"),
NodeValue::k_int, 48000);
set_entry_internal(
QStringLiteral("DefaultSequenceAudioLayout"), NodeValue::k_int,
QVariant::fromValue(static_cast<int64_t>(k_channel_layout_stereo)));
// Online/offline settings
SetEntryInternal(QStringLiteral("OnlinePixelFormat"), NodeValue::kInt,
PixelFormat::F32);
SetEntryInternal(QStringLiteral("OfflinePixelFormat"), NodeValue::kInt,
PixelFormat::F32);
set_entry_internal(QStringLiteral("OnlinePixelFormat"), NodeValue::k_int,
PixelFormat::f32);
set_entry_internal(QStringLiteral("OfflinePixelFormat"), NodeValue::k_int,
PixelFormat::f32);
SetEntryInternal(QStringLiteral("MarkerColor"), NodeValue::kInt,
ColorCoding::kLime);
set_entry_internal(QStringLiteral("MarkerColor"), NodeValue::k_int,
ColorCoding::k_lime);
}
void Config::Load()
void Config::load()
{
QFile config_file(GetConfigFilePath());
QFile config_file(get_config_file_path());
if (!config_file.exists()) {
return;
@@ -287,15 +287,15 @@ void Config::Load()
}
// Reset to defaults
current_config_.SetDefaults();
current_config.set_defaults();
QXmlStreamReader reader(&config_file);
QString config_version;
while (XMLReadNextStartElement(&reader)) {
while (xml_read_next_start_element(&reader)) {
if (reader.name() == QStringLiteral("Configuration")) {
while (XMLReadNextStartElement(&reader)) {
while (xml_read_next_start_element(&reader)) {
QString key = reader.name().toString();
QString value = reader.readElementText();
@@ -309,20 +309,20 @@ void Config::Load()
} else if (key == QStringLiteral("DefaultSequenceFrameRate") &&
!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
// supported rational
// supported Rational
qDebug() << " CONFIG: Finding closest match to" << value;
double config_fr = value.toDouble();
const QVector<rational> &supported_frame_rates =
VideoParams::kSupportedFrameRates;
const QVector<Rational> &supported_frame_rates =
VideoParams::k_supported_frame_rates;
rational match = supported_frame_rates.first();
double match_diff = qAbs(match.toDouble() - config_fr);
Rational match = supported_frame_rates.first();
double match_diff = qAbs(match.to_double() - config_fr);
for (int i = 1; i < supported_frame_rates.size(); i++) {
double diff = qAbs(
supported_frame_rates.at(i).toDouble() - config_fr);
supported_frame_rates.at(i).to_double() - config_fr);
if (diff < match_diff) {
match = supported_frame_rates.at(i);
@@ -331,12 +331,12 @@ void Config::Load()
}
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 {
current_config_[key] = NodeValue::StringToValue(
current_config_.GetConfigEntryType(key), value, false);
current_config[key] = NodeValue::string_to_value(
current_config.get_config_entry_type(key), value, false);
}
}
@@ -361,17 +361,17 @@ void Config::Load()
"use defaults.\n\n%1")
.arg(reader.errorString()),
QMessageBox::Ok);
current_config_.SetDefaults();
current_config.set_defaults();
}
config_file.close();
}
void Config::Save()
void Config::save()
{
QString real_filename = GetConfigFilePath();
QString real_filename = get_config_file_path();
QString temp_filename =
FileFunctions::GetSafeTemporaryFilename(real_filename);
FileFunctions::get_safe_temporary_filename(real_filename);
QFile config_file(temp_filename);
@@ -398,14 +398,14 @@ void Config::Save()
writer.writeTextElement(
"Version", QCoreApplication::applicationVersion().split('-').first());
QMapIterator<QString, ConfigEntry> iterator(current_config_.config_map_);
QMapIterator<QString, ConfigEntry> iterator(current_config.config_map_);
while (iterator.hasNext()) {
iterator.next();
QString value = NodeValue::ValueToString(iterator.value().type,
QString value = NodeValue::value_to_string(iterator.value().type,
iterator.value().data, false);
if (iterator.value().type == NodeValue::kNone) {
if (iterator.value().type == NodeValue::k_none) {
qWarning() << "Config key" << iterator.key()
<< "had null type and was discarded";
} else {
@@ -419,7 +419,7 @@ void Config::Save()
config_file.close();
if (!FileFunctions::RenameFileAllowOverwrite(temp_filename,
if (!FileFunctions::rename_file_allow_overwrite(temp_filename,
real_filename)) {
qWarning()
<< QStringLiteral(
@@ -438,7 +438,7 @@ QVariant &Config::operator[](const QString &key)
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;
}
+13 -13
View File
@@ -19,8 +19,8 @@
***/
#ifndef CONFIG_H
#define CONFIG_H
#ifndef OAK_CONFIG_H
#define OAK_CONFIG_H
#include <QMap>
#include <QString>
@@ -31,24 +31,24 @@
namespace olive
{
#define OLIVE_CONFIG(x) Config::Current()[QStringLiteral(x)]
#define OLIVE_CONFIG_STR(x) Config::Current()[x]
#define OAK_CONFIG(x) Config::current()[QStringLiteral(x)]
#define OAK_CONFIG_STR(x) Config::current()[x]
class Config {
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 &);
NodeValue::Type GetConfigEntryType(const QString &key) const;
NodeValue::Type get_config_entry_type(const QString &key) const;
private:
Config();
@@ -58,16 +58,16 @@ private:
QVariant data;
};
void SetEntryInternal(const QString &key, NodeValue::Type type,
void set_entry_internal(const QString &key, NodeValue::Type type,
const QVariant &data);
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
#define CORE_H
#ifndef OAK_CORE_H
#define OAK_CORE_H
#include <olive/core/core.h>
#include <QFileInfoList>
@@ -42,7 +42,7 @@ namespace olive
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).
* It also contains various global functions/variables for use throughout Olive.
@@ -57,7 +57,7 @@ public:
public:
CoreParams();
enum RunMode { kRunNormal, kHeadlessExport, kHeadlessPreCache };
enum RunMode { k_run_normal, k_headless_export, k_headless_pre_cache };
bool fullscreen() const
{
@@ -135,9 +135,9 @@ public:
*/
static Core *instance();
static QString FootageFileDialogFilter();
static QStringList AllowedFootageExtensions();
static bool IsFootageExtensionAllowed(const QString &path);
static QString footage_file_dialog_filter();
static QStringList allowed_footage_extensions();
static bool is_footage_extension_allowed(const QString &path);
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).
*/
void Start();
void start();
/**
* @brief Stop Olive Core
*
* 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
*
@@ -180,7 +180,7 @@ public:
*
* @param urls
*/
void ImportFiles(const QStringList &urls, Folder *parent);
void import_files(const QStringList &urls, Folder *parent);
/**
* @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)
*/
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)
*/
const QString &GetSelectedTransition() const;
const QString &get_selected_transition() const;
/**
* @brief Get current snapping value
@@ -205,7 +205,7 @@ public:
/**
* @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
@@ -217,92 +217,92 @@ public:
*
* The active Project file, or nullptr if the heuristic couldn't find one.
*/
Project *GetActiveProject() const;
Folder *GetSelectedFolderInActiveProject() const;
Project *get_active_project() const;
Folder *get_selected_folder_in_active_project() const;
/**
* @brief Gets current timecode display mode
*/
Timecode::Display GetTimecodeDisplay() const;
Timecode::Display get_timecode_display() const;
/**
* @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())
*/
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
*/
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
*/
bool LabelNodes(const QVector<Node *> &nodes,
bool label_nodes(const QVector<Node *> &nodes,
MultiUndoCommand *parent = nullptr);
/**
* @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);
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
*/
void OpenProjectFromRecentList(int index);
void open_project_from_recent_list(int index);
/**
* @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
*/
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
*/
bool ValidateFootageInLoadedProject(Project *project,
bool validate_footage_in_loaded_project(Project *project,
const QString &project_saved_url);
/**
* @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
*
* 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 IsMagicEnabled() const
bool is_magic_enabled() const
{
return magic_;
}
@@ -311,56 +311,56 @@ public slots:
/**
* @brief Starts an open file dialog to load a project from file
*/
void OpenProject();
void open_project();
/**
* @brief Saves the current project
*/
bool SaveProject();
bool save_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
*
* @param tool
*/
void SetTool(const Tool::Item &tool);
void set_tool(const Tool::Item &tool);
/**
* @brief Set the current snapping setting
*/
void SetSnapping(const bool &b);
void set_snapping(const bool &b);
/**
* @brief Show an About dialog
*/
void DialogAboutShow();
void dialog_about_show();
/**
* @brief Open the import footage dialog and import the files selected (runs ImportFiles())
*/
void DialogImportShow();
void dialog_import_show();
/**
* @brief Show Preferences dialog
*/
void DialogPreferencesShow(int start_tab = 0);
void dialog_preferences_show(int start_tab = 0);
/**
* @brief Show Project Properties dialog
*/
void DialogProjectPropertiesShow();
void dialog_project_properties_show();
/**
* @brief Show Export dialog
*/
void DialogExportShow();
void dialog_export_show();
/**
* @brief Show OTIO import dialog
@@ -372,42 +372,42 @@ public slots:
/**
* @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
*/
void CreateNewSequence();
void create_new_sequence();
/**
* @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
*/
void SetSelectedTransitionObject(const QString &obj);
void set_selected_transition_object(const QString &obj);
/**
* @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
*/
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;
}
@@ -416,60 +416,60 @@ signals:
/**
* @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
*/
void AddableObjectChanged(Tool::AddableObject o);
void addable_object_changed(Tool::AddableObject o);
/**
* @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
*/
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
*/
void OpenRecentListChanged();
void open_recent_list_changed();
/**
* @brief Enable mouse color sampling functionality on all viewers
*
* 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
*/
void ColorPickerColorEmitted(const Color &reference, const Color &display);
void color_picker_color_emitted(const Color &reference, const Color &display);
private:
/**
* @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
*/
static QString GetRecentProjectsFilePath();
static QString get_recent_projects_file_path();
/**
* @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)
*/
void PushRecentlyOpenedProject(const QString &s);
void push_recently_opened_project(const QString &s);
/**
* @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
* them all in a function here.
*/
void DeclareTypesForQt();
void declare_types_for_qt();
/**
* @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
* 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
*/
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
*/
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
*/
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
@@ -550,7 +550,7 @@ private:
QTimer autorecovery_timer_;
/**
* @brief Application-wide undo stack instance
* @brief Application-wide undo stack instance_
*/
UndoStack undo_stack_;
@@ -565,7 +565,7 @@ private:
CoreParams core_params_;
/**
* @brief Static singleton core instance
* @brief Static singleton core instance_
*/
static Core *instance_;
@@ -592,36 +592,36 @@ private:
bool shown_cache_full_warning_;
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
*/
void OpenProjectInternal(const QString &filename,
void open_project_internal(const QString &filename,
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
#define CRASHHANDLERDIALOG_H
#ifndef OAK_CRASHHANDLERDIALOG_H
#define OAK_CRASHHANDLERDIALOG_H
#include <client/crash_report_database.h>
#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()) {
ScrollingLabel *scroll = new ScrollingLabel(patrons);
scroll->StartAnimating();
scroll->start_animating();
layout->addWidget(scroll);
}
@@ -150,7 +150,7 @@ AboutDialog::AboutDialog(bool welcome_dialog, QWidget *parent)
void AboutDialog::accept()
{
if (dont_show_again_checkbox_ && dont_show_again_checkbox_->isChecked()) {
OLIVE_CONFIG("ShowWelcomeDialog") = false;
OAK_CONFIG("ShowWelcomeDialog") = false;
}
QDialog::accept();
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef ABOUTDIALOG_H
#define ABOUTDIALOG_H
#ifndef OAK_ABOUTDIALOG_H
#define OAK_ABOUTDIALOG_H
#include <QCheckBox>
#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/>.
*/
#ifndef PATREON_H
#define PATREON_H
#ifndef OAK_PATREON_H
#define OAK_PATREON_H
#include <QStringList>
QStringList patrons;
#endif // PATREON_H
#endif // OAK_PATREON_H
+11 -11
View File
@@ -28,23 +28,23 @@
namespace olive
{
const int ScrollingLabel::kMinLineHeight = 10;
const int ScrollingLabel::k_min_line_height = 10;
ScrollingLabel::ScrollingLabel(QWidget *parent)
: QWidget(parent)
, animate_(0)
{
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(parent)
{
SetText(text);
set_text(text);
}
void ScrollingLabel::SetText(const QStringList &text)
void ScrollingLabel::set_text(const QStringList &text)
{
text_ = text;
@@ -53,10 +53,10 @@ void ScrollingLabel::SetText(const QStringList &text)
int width = 0;
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)
@@ -82,15 +82,15 @@ void ScrollingLabel::paintEvent(QPaintEvent *e)
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);
}
for (int y = 0; y < text_height_; y++) {
double mul = double(y) / double(text_height_);
SetOpacityOfScanLine(map.scanLine(y), map.width(), 4, mul);
SetOpacityOfScanLine(map.scanLine(map.height() - 1 - y),
set_opacity_of_scan_line(map.scanLine(y), map.width(), 4, mul);
set_opacity_of_scan_line(map.scanLine(map.height() - 1 - y),
map.width(), 4, mul);
}
}
@@ -99,7 +99,7 @@ void ScrollingLabel::paintEvent(QPaintEvent *e)
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)
{
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_++;
+9 -9
View File
@@ -19,8 +19,8 @@
***/
#ifndef SCROLLINGLABEL_H
#define SCROLLINGLABEL_H
#ifndef OAK_SCROLLINGLABEL_H
#define OAK_SCROLLINGLABEL_H
#include <QTimer>
#include <QWidget>
@@ -34,14 +34,14 @@ public:
ScrollingLabel(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();
}
void StopAnimating()
void stop_animating()
{
timer_.stop();
}
@@ -50,10 +50,10 @@ protected:
virtual void paintEvent(QPaintEvent *e) override;
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);
static const int kMinLineHeight;
static const int k_min_line_height;
QStringList text_;
@@ -64,9 +64,9 @@ private:
int animate_;
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.
// 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()));
connect(entry_field, SIGNAL(moveSelectionDown()), this,
connect(entry_field, SIGNAL(move_selection_down()), this,
SLOT(move_selection_down()));
layout->addWidget(entry_field);
// 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
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->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
// shortcut for example).
entry_field->setFocus();
}
void ActionSearch::SetMenuBar(QMenuBar *menu_bar)
void ActionSearch::set_menu_bar(QMenuBar *menu_bar)
{
menu_bar_ = menu_bar;
}
@@ -112,7 +112,7 @@ void ActionSearch::search_update(const QString &s, const QString &p,
// (and their submenus).
// 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();
@@ -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
// keyboard-exclusive functionality.
if (list_widget->count() > 0) {
list_widget->item(0)->setSelected(true);
if (list_widget_->count() > 0) {
list_widget_->item(0)->setSelected(true);
}
} else {
@@ -162,13 +162,13 @@ void ActionSearch::search_update(const QString &s, const QString &p,
// If so, we add it to the list widget.
QListWidgetItem *item = new QListWidgetItem(
QStringLiteral("%1\n(%2)").arg(comp, menu_text),
list_widget);
list_widget_);
// Add a pointer to the original QAction in the item's data
item->setData(Qt::UserRole + 1,
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()
{
// 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();
if (list_widget->count() > 0 && selected_items.size() > 0) {
QList<QListWidgetItem *> selected_items = list_widget_->selectedItems();
if (list_widget_->count() > 0 && selected_items.size() > 0) {
QListWidgetItem *item = selected_items.at(0);
// 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
// bottom item).
int lim = list_widget->count();
int lim = list_widget_->count();
for (int i = 1; i < lim; i++) {
if (list_widget->item(i)->isSelected()) {
list_widget->item(i - 1)->setSelected(true);
list_widget->scrollToItem(list_widget->item(i - 1));
if (list_widget_->item(i)->isSelected()) {
list_widget_->item(i - 1)->setSelected(true);
list_widget_->scrollToItem(list_widget_->item(i - 1));
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
// bottom item).
int lim = list_widget->count() - 1;
int lim = list_widget_->count() - 1;
for (int i = 0; i < lim; i++) {
if (list_widget->item(i)->isSelected()) {
list_widget->item(i + 1)->setSelected(true);
list_widget->scrollToItem(list_widget->item(i + 1));
if (list_widget_->item(i)->isSelected()) {
list_widget_->item(i + 1)->setSelected(true);
list_widget_->scrollToItem(list_widget_->item(i + 1));
break;
}
}
@@ -247,11 +247,11 @@ bool ActionSearchEntry::event(QEvent *e)
switch (static_cast<QKeyEvent *>(e)->key()) {
case Qt::Key_Up:
e->accept();
emit moveSelectionUp();
emit move_selection_up();
return true;
case Qt::Key_Down:
e->accept();
emit moveSelectionDown();
emit move_selection_down();
return true;
}
break;
+7 -7
View File
@@ -19,8 +19,8 @@
***/
#ifndef ACTIONSEARCH_H
#define ACTIONSEARCH_H
#ifndef OAK_ACTIONSEARCH_H
#define OAK_ACTIONSEARCH_H
#include <QDialog>
#include <QLineEdit>
@@ -58,7 +58,7 @@ public:
/**
* @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:
/**
* @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
*/
ActionSearchList *list_widget;
ActionSearchList *list_widget_;
/**
* @brief Attached menu bar object
@@ -180,14 +180,14 @@ signals:
/**
* @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.
*/
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)
: QDialog(parent)
{
Init(message);
init(message);
PopulateTree(recoveries, autocheck_latest);
populate_tree(recoveries, autocheck_latest);
}
void AutoRecoveryDialog::accept()
{
foreach (QTreeWidgetItem *checkable, checkable_items_) {
if (checkable->checkState(0) == Qt::Checked) {
QString filename = checkable->data(0, kFilenameRole).toString();
Core::instance()->OpenRecoveryProject(filename);
QString filename = checkable->data(0, k_filename_role).toString();
Core::instance()->open_recovery_project(filename);
}
}
super::accept();
}
void AutoRecoveryDialog::Init(const QString &header_text)
void AutoRecoveryDialog::init(const QString &header_text)
{
QVBoxLayout *layout = new QVBoxLayout(this);
@@ -79,11 +79,11 @@ void AutoRecoveryDialog::Init(const QString &header_text)
layout->addWidget(buttons);
}
void AutoRecoveryDialog::PopulateTree(const QStringList &recoveries,
void AutoRecoveryDialog::populate_tree(const QStringList &recoveries,
bool autocheck_latest)
{
// 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) {
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->setData(0, kFilenameRole,
entry_item->setData(0, k_filename_role,
recovery_dir.filePath(entry));
// Allow to be checked, auto-checking the first entry
+6 -6
View File
@@ -19,8 +19,8 @@
***/
#ifndef AUTORECOVERYDIALOG_H
#define AUTORECOVERYDIALOG_H
#ifndef OAK_AUTORECOVERYDIALOG_H
#define OAK_AUTORECOVERYDIALOG_H
#include <QDialog>
#include <QTreeWidget>
@@ -40,17 +40,17 @@ public slots:
virtual void accept() override;
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_;
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_->setFixedWidth(
QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral("HHH")));
QtUtils::q_font_metrics_width(fontMetrics(), QStringLiteral("HHH")));
wheel_layout->addWidget(hsv_value_gradient_);
QHBoxLayout *swatch_layout = new QHBoxLayout();
@@ -76,7 +76,7 @@ ColorDialog::ColorDialog(ColorManager *color_manager, const ManagedColor &start,
splitter->addWidget(value_area);
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_);
chooser_ = new ColorSpaceChooser(color_manager_);
@@ -86,32 +86,32 @@ ColorDialog::ColorDialog(ColorManager *color_manager, const ManagedColor &start,
// Split window 50/50
splitter->setSizes({ INT_MAX, INT_MAX });
connect(color_wheel_, &ColorWheelWidget::SelectedColorChanged,
color_values_widget_, &ColorValuesWidget::SetColor);
connect(color_wheel_, &ColorWheelWidget::SelectedColorChanged,
hsv_value_gradient_, &ColorGradientWidget::SetSelectedColor);
connect(color_wheel_, &ColorWheelWidget::SelectedColorChanged, swatch_,
&ColorSwatchChooser::SetCurrentColor);
connect(hsv_value_gradient_, &ColorGradientWidget::SelectedColorChanged,
color_values_widget_, &ColorValuesWidget::SetColor);
connect(hsv_value_gradient_, &ColorGradientWidget::SelectedColorChanged,
color_wheel_, &ColorWheelWidget::SetSelectedColor);
connect(hsv_value_gradient_, &ColorGradientWidget::SelectedColorChanged,
swatch_, &ColorSwatchChooser::SetCurrentColor);
connect(color_values_widget_, &ColorValuesWidget::ColorChanged,
hsv_value_gradient_, &ColorGradientWidget::SetSelectedColor);
connect(color_values_widget_, &ColorValuesWidget::ColorChanged,
color_wheel_, &ColorWheelWidget::SetSelectedColor);
connect(color_values_widget_, &ColorValuesWidget::ColorChanged, swatch_,
&ColorSwatchChooser::SetCurrentColor);
connect(swatch_, &ColorSwatchChooser::ColorClicked, hsv_value_gradient_,
&ColorGradientWidget::SetSelectedColor);
connect(swatch_, &ColorSwatchChooser::ColorClicked, color_wheel_,
&ColorWheelWidget::SetSelectedColor);
connect(swatch_, &ColorSwatchChooser::ColorClicked, color_values_widget_,
&ColorValuesWidget::SetColor);
connect(color_wheel_, &ColorWheelWidget::selected_color_changed,
color_values_widget_, &ColorValuesWidget::set_color);
connect(color_wheel_, &ColorWheelWidget::selected_color_changed,
hsv_value_gradient_, &ColorGradientWidget::set_selected_color);
connect(color_wheel_, &ColorWheelWidget::selected_color_changed, swatch_,
&ColorSwatchChooser::set_current_color);
connect(hsv_value_gradient_, &ColorGradientWidget::selected_color_changed,
color_values_widget_, &ColorValuesWidget::set_color);
connect(hsv_value_gradient_, &ColorGradientWidget::selected_color_changed,
color_wheel_, &ColorWheelWidget::set_selected_color);
connect(hsv_value_gradient_, &ColorGradientWidget::selected_color_changed,
swatch_, &ColorSwatchChooser::set_current_color);
connect(color_values_widget_, &ColorValuesWidget::color_changed,
hsv_value_gradient_, &ColorGradientWidget::set_selected_color);
connect(color_values_widget_, &ColorValuesWidget::color_changed,
color_wheel_, &ColorWheelWidget::set_selected_color);
connect(color_values_widget_, &ColorValuesWidget::color_changed, swatch_,
&ColorSwatchChooser::set_current_color);
connect(swatch_, &ColorSwatchChooser::color_clicked, hsv_value_gradient_,
&ColorGradientWidget::set_selected_color);
connect(swatch_, &ColorSwatchChooser::color_clicked, color_wheel_,
&ColorWheelWidget::set_selected_color);
connect(swatch_, &ColorSwatchChooser::color_clicked, color_values_widget_,
&ColorValuesWidget::set_color);
connect(color_wheel_, &ColorWheelWidget::DiameterChanged,
connect(color_wheel_, &ColorWheelWidget::diameter_changed,
hsv_value_gradient_, &ColorGradientWidget::setFixedHeight);
QDialogButtonBox *buttons =
@@ -120,17 +120,17 @@ ColorDialog::ColorDialog(ColorManager *color_manager, const ManagedColor &start,
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
layout->addWidget(buttons);
SetColor(start);
set_color(start);
connect(chooser_, &ColorSpaceChooser::ColorSpaceChanged, this,
&ColorDialog::ColorSpaceChanged);
ColorSpaceChanged(chooser_->input(), chooser_->output());
connect(chooser_, &ColorSpaceChooser::color_space_changed, this,
&ColorDialog::color_space_changed);
color_space_changed(chooser_->input(), chooser_->output());
// Set default size ratio to 2:1
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_output(start.color_output());
@@ -142,70 +142,70 @@ void ColorDialog::SetColor(const ManagedColor &start)
} else {
// Convert reference color to the input space
ColorProcessorPtr linear_to_input = ColorProcessor::Create(
color_manager_, color_manager_->GetReferenceColorSpace(),
ColorProcessorPtr linear_to_input = ColorProcessor::create(
color_manager_, color_manager_->get_reference_color_space(),
start.color_input());
managed_start = linear_to_input->ConvertColor(start);
managed_start = linear_to_input->convert_color(start);
}
color_wheel_->SetSelectedColor(managed_start);
hsv_value_gradient_->SetSelectedColor(managed_start);
color_values_widget_->SetColor(managed_start);
swatch_->SetCurrentColor(managed_start);
color_wheel_->set_selected_color(managed_start);
hsv_value_gradient_->set_selected_color(managed_start);
color_values_widget_->set_color(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
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_output(GetColorSpaceOutput());
selected.set_color_input(get_color_space_input());
selected.set_color_output(get_color_space_output());
return selected;
}
QString ColorDialog::GetColorSpaceInput() const
QString ColorDialog::get_color_space_input() const
{
return chooser_->input();
}
ColorTransform ColorDialog::GetColorSpaceOutput() const
ColorTransform ColorDialog::get_color_space_output() const
{
return chooser_->output();
}
void ColorDialog::ColorSpaceChanged(const QString &input,
void ColorDialog::color_space_changed(const QString &input,
const ColorTransform &output)
{
input_to_ref_processor_ = ColorProcessor::Create(
color_manager_, input, color_manager_->GetReferenceColorSpace());
input_to_ref_processor_ = ColorProcessor::create(
color_manager_, input, color_manager_->get_reference_color_space());
ColorProcessorPtr ref_to_display = ColorProcessor::Create(
color_manager_, color_manager_->GetReferenceColorSpace(), output);
ColorProcessorPtr ref_to_display = ColorProcessor::create(
color_manager_, color_manager_->get_reference_color_space(), output);
ColorProcessorPtr ref_to_input = ColorProcessor::Create(
color_manager_, color_manager_->GetReferenceColorSpace(), input);
ColorProcessorPtr ref_to_input = ColorProcessor::create(
color_manager_, color_manager_->get_reference_color_space(), input);
// Display -> reference is the inverse of the display transform. Older OCIO
// versions crashed on TRANSFORM_DIR_INVERSE; guard by requiring a valid
// processor and fall back to disabling the display tab if creation fails.
ColorProcessorPtr display_to_ref = ColorProcessor::Create(
color_manager_, color_manager_->GetReferenceColorSpace(), output,
ColorProcessor::kInverse);
if (display_to_ref && !display_to_ref->GetProcessor()) {
ColorProcessorPtr display_to_ref = ColorProcessor::create(
color_manager_, color_manager_->get_reference_color_space(), output,
ColorProcessor::k_inverse);
if (display_to_ref && !display_to_ref->get_processor()) {
display_to_ref = nullptr;
}
color_wheel_->SetColorProcessor(input_to_ref_processor_, ref_to_display);
hsv_value_gradient_->SetColorProcessor(input_to_ref_processor_,
color_wheel_->set_color_processor(input_to_ref_processor_, ref_to_display);
hsv_value_gradient_->set_color_processor(input_to_ref_processor_,
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);
}
+8 -8
View File
@@ -19,8 +19,8 @@
***/
#ifndef COLORDIALOG_H
#define COLORDIALOG_H
#ifndef OAK_COLORDIALOG_H
#define OAK_COLORDIALOG_H
#include <QDialog>
@@ -66,14 +66,14 @@ public:
*
* The color is always returned in the ColorManager's reference space (usually scene linear).
*/
ManagedColor GetSelectedColor() const;
ManagedColor get_selected_color() const;
QString GetColorSpaceInput() const;
QString get_color_space_input() const;
ColorTransform GetColorSpaceOutput() const;
ColorTransform get_color_space_output() const;
public slots:
void SetColor(const ManagedColor &c);
void set_color(const ManagedColor &c);
private:
ColorManager *color_manager_;
@@ -91,9 +91,9 @@ private:
ColorSwatchChooser *swatch_;
private slots:
void ColorSpaceChanged(const QString &input, const ColorTransform &output);
void color_space_changed(const QString &input, const ColorTransform &output);
};
}
#endif // COLORDIALOG_H
#endif // OAK_COLORDIALOG_H
+4 -4
View File
@@ -65,7 +65,7 @@ ConfigDialogBase::ConfigDialogBase(QWidget *parent)
void ConfigDialogBase::accept()
{
foreach (ConfigDialogBaseTab *tab, tabs_) {
if (!tab->Validate()) {
if (!tab->validate()) {
return;
}
}
@@ -73,7 +73,7 @@ void ConfigDialogBase::accept()
MultiUndoCommand *command = new MultiUndoCommand();
foreach (ConfigDialogBaseTab *tab, tabs_) {
tab->Accept(command);
tab->accept(command);
}
Core::instance()->undo_stack()->push(command, tr("Set Configuration"));
@@ -83,7 +83,7 @@ void ConfigDialogBase::accept()
QDialog::accept();
}
void ConfigDialogBase::AddTab(ConfigDialogBaseTab *tab, const QString &title)
void ConfigDialogBase::add_tab(ConfigDialogBaseTab *tab, const QString &title)
{
list_widget_->addItem(title);
preference_pane_stack_->addWidget(tab);
@@ -91,7 +91,7 @@ void ConfigDialogBase::AddTab(ConfigDialogBaseTab *tab, const QString &title)
tabs_.append(tab);
}
void ConfigDialogBase::SetCurrentTab(int index)
void ConfigDialogBase::set_current_tab(int index)
{
if (index >= 0 && index < list_widget_->count()) {
list_widget_->setCurrentRow(index);

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