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
@@ -33,28 +33,28 @@ ConformTask::ConformTask(const QString &decoder_id,
, params_(params)
, output_filenames_(output_filenames)
{
SetTitle(tr("Conforming Audio %1:%2")
set_title(tr("Conforming Audio %1:%2")
.arg(stream.filename(), QString::number(stream.stream())));
}
bool ConformTask::Run()
bool ConformTask::run()
{
DecoderPtr decoder = Decoder::CreateFromID(decoder_id_);
DecoderPtr decoder = Decoder::create_from_id(decoder_id_);
if (!decoder->Open(stream_)) {
SetError(tr("Failed to open decoder for audio conform"));
if (!decoder->open(stream_)) {
set_error(tr("Failed to open decoder for audio conform"));
return false;
}
connect(decoder.get(), &Decoder::IndexProgress, this,
&ConformTask::ProgressChanged);
connect(decoder.get(), &Decoder::index_progress, this,
&ConformTask::progress_changed);
qDebug() << "Starting conform of" << stream_.filename() << stream_.stream();
bool ret =
decoder->ConformAudio(output_filenames_, params_, GetCancelAtom());
decoder->conform_audio(output_filenames_, params_, get_cancel_atom());
decoder->Close();
decoder->close();
return ret;
}
+4 -4
View File
@@ -19,8 +19,8 @@
***/
#ifndef CONFORMTASK_H
#define CONFORMTASK_H
#ifndef OAK_CONFORMTASK_H
#define OAK_CONFORMTASK_H
#include "codec/decoder.h"
#include "node/project/footage/footage.h"
@@ -37,7 +37,7 @@ public:
const QVector<QString> &output_filenames);
protected:
virtual bool Run() override;
virtual bool run() override;
private:
QString decoder_id_;
@@ -51,4 +51,4 @@ private:
}
#endif // CONFORMTASK_H
#endif // OAK_CONFORMTASK_H
+5 -5
View File
@@ -27,10 +27,10 @@ namespace olive
CustomCacheTask::CustomCacheTask(const QString &sequence_name)
: cancelled_through_finish_(false)
{
SetTitle(tr("Caching custom range for \"%1\"").arg(sequence_name));
set_title(tr("Caching custom range for \"%1\"").arg(sequence_name));
}
void CustomCacheTask::Finish()
void CustomCacheTask::finish()
{
mutex_.lock();
@@ -40,11 +40,11 @@ void CustomCacheTask::Finish()
mutex_.unlock();
}
bool CustomCacheTask::Run()
bool CustomCacheTask::run()
{
mutex_.lock();
while (!IsCancelled()) {
while (!is_cancelled()) {
wait_cond_.wait(&mutex_);
}
@@ -56,7 +56,7 @@ bool CustomCacheTask::Run()
void CustomCacheTask::CancelEvent()
{
if (!cancelled_through_finish_) {
emit Cancelled();
emit cancelled();
}
wait_cond_.wakeOne();
}
+6 -6
View File
@@ -19,8 +19,8 @@
***/
#ifndef CUSTOMCACHETASK_H
#define CUSTOMCACHETASK_H
#ifndef OAK_CUSTOMCACHETASK_H
#define OAK_CUSTOMCACHETASK_H
#include <QMutex>
#include <QWaitCondition>
@@ -35,13 +35,13 @@ class CustomCacheTask : public Task {
public:
CustomCacheTask(const QString &sequence_name);
void Finish();
void finish();
signals:
void Cancelled();
void cancelled();
protected:
virtual bool Run() override;
virtual bool run() override;
virtual void CancelEvent() override;
@@ -55,4 +55,4 @@ private:
}
#endif // CUSTOMCACHETASK_H
#endif // OAK_CUSTOMCACHETASK_H
+57 -57
View File
@@ -32,79 +32,79 @@ ExportTask::ExportTask(ViewerOutput *viewer_node, ColorManager *color_manager,
{
// Create a copy of the project
copier_ = new ProjectCopier(this);
copier_->SetProject(viewer_node->project());
copier_->set_project(viewer_node->project());
set_viewer(copier_->GetCopy(viewer_node));
color_manager_ = copier_->GetCopiedProject()->color_manager();
set_viewer(copier_->get_copy(viewer_node));
color_manager_ = copier_->get_copied_project()->color_manager();
// Adjust video params to have no divider
VideoParams vp = viewer_node->GetVideoParams();
VideoParams vp = viewer_node->get_video_params();
vp.set_divider(1);
vp.set_time_base(params.video_params().time_base());
vp.set_frame_rate(params.video_params().frame_rate());
set_video_params(vp);
set_audio_params(viewer_node->GetAudioParams());
set_audio_params(viewer_node->get_audio_params());
SetTitle(tr("Exporting \"%1\"").arg(viewer_node->GetLabel()));
SetNativeProgressSignallingEnabled(false);
set_title(tr("Exporting \"%1\"").arg(viewer_node->get_label()));
set_native_progress_signalling_enabled(false);
}
bool ExportTask::Run()
bool ExportTask::run()
{
// For safety, if we're overwriting, we save to a temporary filename and then only overwrite it
// at the end
QString real_filename = params_.filename();
if (QFileInfo::exists(params_.filename())) {
// Generate a filename that definitely doesn't exist
params_.SetFilename(
FileFunctions::GetSafeTemporaryFilename(real_filename));
params_.set_filename(
FileFunctions::get_safe_temporary_filename(real_filename));
}
// If we're exporting to a sidecar subtitle file, disable the subtitles in the main encoder
bool subtitles_enabled = params_.subtitles_enabled();
EncodingParams sidecar_params = params_;
if (subtitles_enabled && params_.subtitles_are_sidecar()) {
params_.DisableSubtitles();
params_.disable_subtitles();
}
encoder_ = std::shared_ptr<Encoder>(Encoder::CreateFromParams(params_));
encoder_ = std::shared_ptr<Encoder>(Encoder::create_from_params(params_));
if (!encoder_) {
SetError(tr("Failed to create encoder"));
set_error(tr("Failed to create encoder"));
return false;
}
if (!encoder_->Open()) {
SetError(tr("Failed to open file: %1").arg(encoder_->GetError()));
if (!encoder_->open()) {
set_error(tr("Failed to open file: %1").arg(encoder_->get_error()));
return false;
}
if (subtitles_enabled && params_.subtitles_are_sidecar()) {
// Construct sidecar params
sidecar_params.DisableVideo();
sidecar_params.DisableAudio();
sidecar_params.disable_video();
sidecar_params.disable_audio();
QString sidecar_filename;
{
QFileInfo fi(real_filename);
sidecar_filename = fi.completeBaseName();
sidecar_filename.append('.');
sidecar_filename.append(ExportFormat::GetExtension(
sidecar_filename.append(ExportFormat::get_extension(
sidecar_params.subtitle_sidecar_fmt()));
sidecar_filename = fi.dir().filePath(sidecar_filename);
}
sidecar_params.SetFilename(sidecar_filename);
sidecar_params.set_filename(sidecar_filename);
subtitle_encoder_ = std::shared_ptr<Encoder>(Encoder::CreateFromFormat(
subtitle_encoder_ = std::shared_ptr<Encoder>(Encoder::create_from_format(
sidecar_params.subtitle_sidecar_fmt(), sidecar_params));
if (!subtitle_encoder_) {
SetError(tr("Failed to create subtitle encoder"));
set_error(tr("Failed to create subtitle encoder"));
return false;
}
if (!subtitle_encoder_->Open()) {
SetError(tr("Failed to open subtitle sidecar file: %1")
if (!subtitle_encoder_->open()) {
set_error(tr("Failed to open subtitle sidecar file: %1")
.arg(sidecar_filename));
return false;
}
@@ -117,7 +117,7 @@ bool ExportTask::Run()
export_range_ = params_.custom_range();
} else {
// Render entire sequence
export_range_ = TimeRange(0, viewer()->GetLength());
export_range_ = TimeRange(0, viewer()->get_length());
}
frame_time_ = 0;
@@ -132,8 +132,8 @@ bool ExportTask::Run()
video_force_size = QSize(params_.video_params().width(),
params_.video_params().height());
if (params_.video_scaling_method() != EncodingParams::kStretch) {
video_force_matrix = EncodingParams::GenerateMatrix(
if (params_.video_scaling_method() != EncodingParams::k_stretch) {
video_force_matrix = EncodingParams::generate_matrix(
params_.video_scaling_method(), video_params().width(),
video_params().height(), params_.video_params().width(),
params_.video_params().height());
@@ -144,8 +144,8 @@ bool ExportTask::Run()
}
// Create color processor
color_processor_ = ColorProcessor::Create(
color_manager_, color_manager_->GetReferenceColorSpace(),
color_processor_ = ColorProcessor::create(
color_manager_, color_manager_->get_reference_color_space(),
params_.color_transform());
}
@@ -170,36 +170,36 @@ bool ExportTask::Run()
subtitle_range = export_range_;
}
Render(color_manager_, video_range, audio_range, subtitle_range,
RenderMode::kOnline, nullptr, video_force_size, video_force_matrix,
encoder_->GetDesiredPixelFormat(), VideoParams::kRGBAChannelCount,
render(color_manager_, video_range, audio_range, subtitle_range,
RenderMode::k_online, nullptr, video_force_size, video_force_matrix,
encoder_->get_desired_pixel_format(), VideoParams::k_rgba_channel_count,
color_processor_, params_.color_transform());
bool success = true;
encoder_->Close();
if (!encoder_->GetError().isEmpty()) {
SetError(encoder_->GetError());
encoder_->close();
if (!encoder_->get_error().isEmpty()) {
set_error(encoder_->get_error());
success = false;
}
if (subtitle_encoder_ != encoder_) {
subtitle_encoder_->Close();
if (!subtitle_encoder_->GetError().isEmpty()) {
SetError(subtitle_encoder_->GetError());
subtitle_encoder_->close();
if (!subtitle_encoder_->get_error().isEmpty()) {
set_error(subtitle_encoder_->get_error());
success = false;
}
}
// If cancelled, delete the file we made, which is always a file we created since we write to a
// temp file during the actual encoding process
if (IsCancelled()) {
if (is_cancelled()) {
QFile::remove(params_.filename());
} else if (params_.filename() != real_filename) {
// If we were writing to a temp file, overwrite now
if (!FileFunctions::RenameFileAllowOverwrite(params_.filename(),
if (!FileFunctions::rename_file_allow_overwrite(params_.filename(),
real_filename)) {
SetError(
set_error(
tr("Failed to overwrite \"%1\". Export has been saved as \"%2\" instead.")
.arg(real_filename, params_.filename()));
success = false;
@@ -209,14 +209,14 @@ bool ExportTask::Run()
return success;
}
bool ExportTask::FrameDownloaded(FramePtr f, const rational &time)
bool ExportTask::frame_downloaded(FramePtr f, const Rational &time)
{
rational actual_time = time - export_range_.in();
Rational actual_time = time - export_range_.in();
time_map_.insert(actual_time, f);
while (!IsCancelled()) {
rational real_time = Timecode::timestamp_to_time(
while (!is_cancelled()) {
Rational real_time = Timecode::timestamp_to_time(
frame_time_, video_params().frame_rate_as_time_base());
if (!time_map_.contains(real_time)) {
@@ -225,26 +225,26 @@ bool ExportTask::FrameDownloaded(FramePtr f, const rational &time)
// Unfortunately this can't be done in another thread since the frames need to be sent
// one after the other chronologically.
if (!encoder_->WriteFrame(time_map_.take(real_time), real_time)) {
SetError(encoder_->GetError());
if (!encoder_->write_frame(time_map_.take(real_time), real_time)) {
set_error(encoder_->get_error());
return false;
}
frame_time_++;
emit ProgressChanged(double(frame_time_) /
double(GetTotalNumberOfFrames()));
emit progress_changed(double(frame_time_) /
double(get_total_number_of_frames()));
}
return true;
}
bool ExportTask::AudioDownloaded(const TimeRange &range,
bool ExportTask::audio_downloaded(const TimeRange &range,
const SampleBuffer &samples)
{
TimeRange adjusted_range = range - export_range_.in();
if (adjusted_range.in() == audio_time_) {
if (!WriteAudioLoop(adjusted_range, samples)) {
if (!write_audio_loop(adjusted_range, samples)) {
return false;
}
} else {
@@ -254,21 +254,21 @@ bool ExportTask::AudioDownloaded(const TimeRange &range,
return true;
}
bool ExportTask::EncodeSubtitle(const SubtitleBlock *sub)
bool ExportTask::encode_subtitle(const SubtitleBlock *sub)
{
if (!subtitle_encoder_->WriteSubtitle(sub)) {
SetError(subtitle_encoder_->GetError());
if (!subtitle_encoder_->write_subtitle(sub)) {
set_error(subtitle_encoder_->get_error());
return false;
} else {
return true;
}
}
bool ExportTask::WriteAudioLoop(const TimeRange &time,
bool ExportTask::write_audio_loop(const TimeRange &time,
const SampleBuffer &samples)
{
if (!encoder_->WriteAudio(samples)) {
SetError(encoder_->GetError());
if (!encoder_->write_audio(samples)) {
set_error(encoder_->get_error());
return false;
}
@@ -283,7 +283,7 @@ bool ExportTask::WriteAudioLoop(const TimeRange &time,
audio_map_.erase(it);
// Call recursively to write the next sample buffer
if (!WriteAudioLoop(t, s)) {
if (!write_audio_loop(t, s)) {
return false;
}
+11 -11
View File
@@ -19,8 +19,8 @@
***/
#ifndef EXPORTTASK_H
#define EXPORTTASK_H
#ifndef OAK_EXPORTTASK_H
#define OAK_EXPORTTASK_H
#include "codec/encoder.h"
#include "node/output/viewer/viewer.h"
@@ -39,26 +39,26 @@ public:
const EncodingParams &params);
protected:
virtual bool Run() override;
virtual bool run() override;
virtual bool FrameDownloaded(FramePtr frame, const rational &time) override;
virtual bool frame_downloaded(FramePtr frame, const Rational &time) override;
virtual bool AudioDownloaded(const TimeRange &range,
virtual bool audio_downloaded(const TimeRange &range,
const SampleBuffer &samples) override;
virtual bool EncodeSubtitle(const SubtitleBlock *sub) override;
virtual bool encode_subtitle(const SubtitleBlock *sub) override;
virtual bool TwoStepFrameRendering() const override
virtual bool two_step_frame_rendering() const override
{
return false;
}
private:
bool WriteAudioLoop(const TimeRange &time, const SampleBuffer &samples);
bool write_audio_loop(const TimeRange &time, const SampleBuffer &samples);
ProjectCopier *copier_;
QHash<rational, FramePtr> time_map_;
QHash<Rational, FramePtr> time_map_;
QHash<TimeRange, SampleBuffer> audio_map_;
@@ -74,11 +74,11 @@ private:
int64_t frame_time_;
rational audio_time_;
Rational audio_time_;
TimeRange export_range_;
};
}
#endif // EXPORTTASK_H
#endif // OAK_EXPORTTASK_H
+22 -22
View File
@@ -29,8 +29,8 @@ namespace olive
PreCacheTask::PreCacheTask(Footage *footage, int index, Sequence *sequence)
{
// Set video and audio params
set_video_params(sequence->GetVideoParams());
set_audio_params(sequence->GetAudioParams());
set_video_params(sequence->get_video_params());
set_audio_params(sequence->get_audio_params());
// Create new project
project_ = new Project();
@@ -38,25 +38,25 @@ PreCacheTask::PreCacheTask(Footage *footage, int index, Sequence *sequence)
// Create viewer with same parameters as the sequence
set_viewer(new ViewerOutput());
viewer()->setParent(project_);
viewer()->SetVideoParams(sequence->GetVideoParams());
viewer()->SetAudioParams(sequence->GetAudioParams());
viewer()->set_video_params(sequence->get_video_params());
viewer()->set_audio_params(sequence->get_audio_params());
// Copy project config nodes
Project::CopySettings(footage->project(), project_);
Project::copy_settings(footage->project(), project_);
// Copy footage node so it can precache without any modifications from the user screwing it up
footage_ = static_cast<Footage *>(footage->copy());
footage_->setParent(project_);
Node::CopyInputs(footage, footage_, false);
Node::copy_inputs(footage, footage_, false);
Node::ConnectEdge(footage_,
NodeInput(viewer(), ViewerOutput::kTextureInput));
viewer()->SetValueHintForInput(
ViewerOutput::kTextureInput,
Node::ValueHint({ NodeValue::kTexture },
Track::Reference(Track::kVideo, index).ToString()));
Node::connect_edge(footage_,
NodeInput(viewer(), ViewerOutput::k_texture_input));
viewer()->set_value_hint_for_input(
ViewerOutput::k_texture_input,
Node::ValueHint({ NodeValue::k_texture },
Track::Reference(Track::k_video, index).to_string()));
SetTitle(tr("Pre-caching %1:%2")
set_title(tr("Pre-caching %1:%2")
.arg(footage_->filename(), QString::number(index)));
}
@@ -66,29 +66,29 @@ PreCacheTask::~PreCacheTask()
delete project_;
}
bool PreCacheTask::Run()
bool PreCacheTask::run()
{
// Get list of invalidated ranges
TimeRange intersection;
if (footage_->GetWorkArea()->enabled()) {
if (footage_->get_work_area()->enabled()) {
// If we're caching only in-out, limit the range to that
intersection = footage_->GetWorkArea()->range();
intersection = footage_->get_work_area()->range();
} else {
// Otherwise use full length
intersection = TimeRange(0, footage_->GetVideoLength());
intersection = TimeRange(0, footage_->get_video_length());
}
TimeRangeList video_range =
viewer()->video_frame_cache()->GetInvalidatedRanges(intersection);
viewer()->video_frame_cache()->get_invalidated_ranges(intersection);
Render(project_->color_manager(), video_range, TimeRangeList(), TimeRange(),
RenderMode::kOnline, viewer()->video_frame_cache());
render(project_->color_manager(), video_range, TimeRangeList(), TimeRange(),
RenderMode::k_online, viewer()->video_frame_cache());
return true;
}
bool PreCacheTask::FrameDownloaded(FramePtr frame, const rational &time)
bool PreCacheTask::frame_downloaded(FramePtr frame, const Rational &time)
{
// Do nothing. Pre-cache essentially just creates more frames in the cache, it doesn't need to do
// anything else.
@@ -99,7 +99,7 @@ bool PreCacheTask::FrameDownloaded(FramePtr frame, const rational &time)
return true;
}
bool PreCacheTask::AudioDownloaded(const TimeRange &range,
bool PreCacheTask::audio_downloaded(const TimeRange &range,
const SampleBuffer &samples)
{
// Pre-cache doesn't cache any audio
+7 -7
View File
@@ -19,8 +19,8 @@
***/
#ifndef PRECACHETASK_H
#define PRECACHETASK_H
#ifndef OAK_PRECACHETASK_H
#define OAK_PRECACHETASK_H
#include "node/project/footage/footage.h"
#include "node/project/sequence/sequence.h"
@@ -37,12 +37,12 @@ public:
virtual ~PreCacheTask() override;
protected:
virtual bool Run() override;
virtual bool run() override;
virtual bool FrameDownloaded(FramePtr frame,
const rational &times) override;
virtual bool frame_downloaded(FramePtr frame,
const Rational &times) override;
virtual bool AudioDownloaded(const TimeRange &range,
virtual bool audio_downloaded(const TimeRange &range,
const SampleBuffer &samples) override;
private:
@@ -53,4 +53,4 @@ private:
}
#endif // PRECACHETASK_H
#endif // OAK_PRECACHETASK_H
+50 -50
View File
@@ -41,25 +41,25 @@ ProjectImportTask::ProjectImportTask(Folder *folder,
filenames_.append(QFileInfo(f));
}
file_count_ = Core::CountFilesInFileList(filenames_);
file_count_ = Core::count_files_in_file_list(filenames_);
SetTitle(tr("Importing %n file(s)", nullptr, file_count_));
set_title(tr("Importing %n file(s)", nullptr, file_count_));
}
const int &ProjectImportTask::GetFileCount() const
const int &ProjectImportTask::get_file_count() const
{
return file_count_;
}
bool ProjectImportTask::Run()
bool ProjectImportTask::run()
{
command_ = new MultiUndoCommand();
int imported = 0;
Import(folder_, filenames_, imported, command_);
import(folder_, filenames_, imported, command_);
if (IsCancelled()) {
if (is_cancelled()) {
delete command_;
command_ = nullptr;
return false;
@@ -68,15 +68,15 @@ bool ProjectImportTask::Run()
}
}
void ProjectImportTask::Import(Folder *folder, QFileInfoList import,
void ProjectImportTask::import(Folder *folder, QFileInfoList entries,
int &counter, MultiUndoCommand *parent_command)
{
for (int i = 0; i < import.size(); i++) {
if (IsCancelled()) {
for (int i = 0; i < entries.size(); i++) {
if (is_cancelled()) {
break;
}
const QFileInfo &file_info = import.at(i);
const QFileInfo &file_info = entries.at(i);
// Check if this file is a directory
if (file_info.isDir()) {
@@ -99,31 +99,31 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import,
// Create a folder corresponding to the directory
Folder *f = new Folder();
f->SetLabel(file_info.fileName());
f->set_label(file_info.fileName());
// Create undoable command that adds the items to the model
AddItemToFolder(folder, f, parent_command);
add_item_to_folder(folder, f, parent_command);
// Recursively follow this path
Import(f, entry_list, counter, parent_command);
import(f, entry_list, counter, parent_command);
}
} else {
Footage *footage = new Footage();
footage->SetCancelPointer(this->GetCancelAtom());
footage->set_cancel_pointer(this->get_cancel_atom());
footage->set_filename(file_info.absoluteFilePath());
footage->SetLabel(file_info.fileName());
footage->set_label(file_info.fileName());
footage->SetCancelPointer(nullptr);
footage->set_cancel_pointer(nullptr);
if (footage->IsValid()) {
if (footage->is_valid()) {
// See if this footage is an image sequence
ValidateImageSequence(footage, import, i);
validate_image_sequence(footage, entries, i);
// Create undoable command that adds the items to the model
AddItemToFolder(folder, footage, parent_command);
add_item_to_folder(folder, footage, parent_command);
// Add to vector
imported_footage_.push_back(footage);
@@ -136,13 +136,13 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import,
counter++;
emit ProgressChanged(static_cast<double>(counter) /
emit progress_changed(static_cast<double>(counter) /
static_cast<double>(file_count_));
}
}
}
void ProjectImportTask::ValidateImageSequence(Footage *footage,
void ProjectImportTask::validate_image_sequence(Footage *footage,
QFileInfoList &info_list,
int index)
{
@@ -150,51 +150,51 @@ void ProjectImportTask::ValidateImageSequence(Footage *footage,
//
// By this point we've established that video contains a single still image stream. Now we'll
// see if it ends with numbers.
if (Decoder::GetImageSequenceDigitCount(footage->filename()) > 0 &&
if (Decoder::get_image_sequence_digit_count(footage->filename()) > 0 &&
!image_sequence_ignore_files_.contains(footage->filename()) &&
footage->InputArraySize(Footage::kVideoParamsInput)) {
VideoParams video_stream = footage->GetVideoParams(0);
footage->input_array_size(Footage::k_video_params_input)) {
VideoParams video_stream = footage->get_video_params(0);
QSize dim(video_stream.width(), video_stream.height());
int64_t ind = Decoder::GetImageSequenceIndex(footage->filename());
int64_t ind = Decoder::get_image_sequence_index(footage->filename());
// Check if files around exist around it with that follow a sequence
QString previous_img_fn = Decoder::TransformImageSequenceFileName(
QString previous_img_fn = Decoder::transform_image_sequence_file_name(
footage->filename(), ind - 1);
QString next_img_fn = Decoder::TransformImageSequenceFileName(
QString next_img_fn = Decoder::transform_image_sequence_file_name(
footage->filename(), ind + 1);
Footage *previous_file = new Footage(previous_img_fn);
Footage *next_file = new Footage(next_img_fn);
// Finally see if these files have the same dimensions
if ((previous_file->IsValid() &&
CompareStillImageSize(previous_file, dim)) ||
(next_file->IsValid() && CompareStillImageSize(next_file, dim))) {
if ((previous_file->is_valid() &&
compare_still_image_size(previous_file, dim)) ||
(next_file->is_valid() && compare_still_image_size(next_file, dim))) {
// By this point, we've established this file is a still image with a number at the end of
// the filename surrounded by adjacent numbers. It could be a still image! But let's ask the
// user just in case...
bool is_sequence;
QMetaObject::invokeMethod(Core::instance(), "ConfirmImageSequence",
QMetaObject::invokeMethod(Core::instance(), "confirm_image_sequence",
Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, is_sequence),
Q_ARG(QString, footage->filename()));
int64_t seq_index =
Decoder::GetImageSequenceIndex(footage->filename());
Decoder::get_image_sequence_index(footage->filename());
// Heuristic to find the first and last images (users can always override this later in
// FootagePropertiesDialog)
int64_t start_index =
GetImageSequenceLimit(footage->filename(), seq_index, false);
get_image_sequence_limit(footage->filename(), seq_index, false);
int64_t end_index =
GetImageSequenceLimit(footage->filename(), seq_index, true);
get_image_sequence_limit(footage->filename(), seq_index, true);
// Depending on the user's choice, either remove them from the list or don't ask for the
// remainders
for (int64_t j = start_index; j <= end_index; j++) {
QString entry_fn = Decoder::TransformImageSequenceFileName(
QString entry_fn = Decoder::transform_image_sequence_file_name(
footage->filename(), j);
if (is_sequence) {
@@ -215,17 +215,17 @@ void ProjectImportTask::ValidateImageSequence(Footage *footage,
if (is_sequence) {
// User has confirmed it is a still image, let's set it accordingly.
video_stream.set_video_type(
VideoParams::kVideoTypeImageSequence);
VideoParams::k_video_type_image_sequence);
rational default_timebase =
OLIVE_CONFIG("DefaultSequenceFrameRate").value<rational>();
Rational default_timebase =
OAK_CONFIG("DefaultSequenceFrameRate").value<Rational>();
video_stream.set_time_base(default_timebase);
video_stream.set_frame_rate(default_timebase.flipped());
video_stream.set_start_time(start_index);
video_stream.set_duration(end_index - start_index + 1);
footage->SetVideoParams(video_stream, 0);
footage->set_video_params(video_stream, 0);
}
}
@@ -234,44 +234,44 @@ void ProjectImportTask::ValidateImageSequence(Footage *footage,
}
}
void ProjectImportTask::AddItemToFolder(Folder *folder, Node *item,
void ProjectImportTask::add_item_to_folder(Folder *folder, Node *item,
MultiUndoCommand *command)
{
// Create undoable command that adds the items to the model
Project *project = folder_->project();
NodeAddCommand *nac = new NodeAddCommand(project, item);
nac->PushToThread(project->thread());
nac->push_to_thread(project->thread());
command->add_child(nac);
command->add_child(new FolderAddChild(folder, item));
}
bool ProjectImportTask::ItemIsStillImageFootageOnly(Footage *footage)
bool ProjectImportTask::item_is_still_image_footage_only(Footage *footage)
{
if (footage->GetTotalStreamCount() != 1) {
if (footage->get_total_stream_count() != 1) {
// Footage with more than one stream (usually video+audio) most likely isn't an image sequence
return false;
}
VideoParams vp = footage->GetVideoParams(0);
VideoParams vp = footage->get_video_params(0);
// Footage must be valid and video stream must be a still image to be an image sequence
return vp.is_valid() && vp.video_type() == VideoParams::kVideoTypeStill;
return vp.is_valid() && vp.video_type() == VideoParams::k_video_type_still;
}
bool ProjectImportTask::CompareStillImageSize(Footage *footage, const QSize &sz)
bool ProjectImportTask::compare_still_image_size(Footage *footage, const QSize &sz)
{
if (!ItemIsStillImageFootageOnly(footage)) {
if (!item_is_still_image_footage_only(footage)) {
return false;
}
VideoParams stream = footage->GetVideoParams(0);
VideoParams stream = footage->get_video_params(0);
return stream.width() == sz.width() && stream.height() == sz.height();
}
int64_t ProjectImportTask::GetImageSequenceLimit(const QString &start_fn,
int64_t ProjectImportTask::get_image_sequence_limit(const QString &start_fn,
int64_t start, bool up)
{
QString test_filename;
@@ -286,7 +286,7 @@ int64_t ProjectImportTask::GetImageSequenceLimit(const QString &start_fn,
}
test_filename =
Decoder::TransformImageSequenceFileName(start_fn, test_index);
Decoder::transform_image_sequence_file_name(start_fn, test_index);
if (!QFileInfo::exists(test_filename)) {
// Reached end of index
+15 -15
View File
@@ -19,8 +19,8 @@
***/
#ifndef PROJECTIMPORTMANAGER_H
#define PROJECTIMPORTMANAGER_H
#ifndef OAK_PROJECTIMPORTMANAGER_H
#define OAK_PROJECTIMPORTMANAGER_H
#include <QFileInfoList>
#include <QUndoCommand>
@@ -37,45 +37,45 @@ class ProjectImportTask : public Task {
public:
ProjectImportTask(Folder *folder, const QStringList &filenames);
const int &GetFileCount() const;
const int &get_file_count() const;
MultiUndoCommand *GetCommand() const
MultiUndoCommand *get_command() const
{
return command_;
}
const QStringList &GetInvalidFiles() const
const QStringList &get_invalid_files() const
{
return invalid_files_;
}
bool HasInvalidFiles() const
bool has_invalid_files() const
{
return !invalid_files_.isEmpty();
}
const QVector<Footage *> &GetImportedFootage() const
const QVector<Footage *> &get_imported_footage() const
{
return imported_footage_;
}
protected:
virtual bool Run() override;
virtual bool run() override;
private:
void Import(Folder *folder, QFileInfoList import, int &counter,
void import(Folder *folder, QFileInfoList entries, int &counter,
MultiUndoCommand *parent_command);
void ValidateImageSequence(Footage *footage, QFileInfoList &info_list,
void validate_image_sequence(Footage *footage, QFileInfoList &info_list,
int index);
void AddItemToFolder(Folder *folder, Node *item, MultiUndoCommand *command);
void add_item_to_folder(Folder *folder, Node *item, MultiUndoCommand *command);
static bool ItemIsStillImageFootageOnly(Footage *footage);
static bool item_is_still_image_footage_only(Footage *footage);
static bool CompareStillImageSize(Footage *footage, const QSize &sz);
static bool compare_still_image_size(Footage *footage, const QSize &sz);
static int64_t GetImageSequenceLimit(const QString &start_fn, int64_t start,
static int64_t get_image_sequence_limit(const QString &start_fn, int64_t start,
bool up);
MultiUndoCommand *command_;
@@ -95,4 +95,4 @@ private:
}
#endif // PROJECTIMPORTMANAGER_H
#endif // OAK_PROJECTIMPORTMANAGER_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef PROJECTIMPORTERRORDIALOG_H
#define PROJECTIMPORTERRORDIALOG_H
#ifndef OAK_PROJECTIMPORTERRORDIALOG_H
#define OAK_PROJECTIMPORTERRORDIALOG_H
#include <QDialog>
@@ -38,4 +38,4 @@ public:
}
#endif // PROJECTIMPORTERRORDIALOG_H
#endif // OAK_PROJECTIMPORTERRORDIALOG_H
+23 -23
View File
@@ -33,51 +33,51 @@ ProjectLoadTask::ProjectLoadTask(const QString &filename)
{
}
bool ProjectLoadTask::Run()
bool ProjectLoadTask::run()
{
project_ = new Project();
project_->set_filename(GetFilename());
project_->set_filename(get_filename());
ProjectSerializer::Result result = ProjectSerializer::Load(
project_, GetFilename(), ProjectSerializer::kProject);
ProjectSerializer::Result result = ProjectSerializer::load(
project_, get_filename(), ProjectSerializer::k_project);
layout_ = result.GetLoadData().layout;
layout_ = result.get_load_data().layout;
switch (result.code()) {
case ProjectSerializer::kSuccess:
case ProjectSerializer::k_success:
break;
case ProjectSerializer::kProjectTooOld:
SetError(tr(
case ProjectSerializer::k_project_too_old:
set_error(tr(
"This project is from a version of Oak Video Editor that is no longer supported in this version."));
break;
case ProjectSerializer::kProjectTooNew:
SetError(tr(
case ProjectSerializer::k_project_too_new:
set_error(tr(
"This project is from a newer version of Oak Video Editor and cannot be opened in this version."));
break;
case ProjectSerializer::kUnknownVersion:
SetError(tr("Failed to determine project version."));
case ProjectSerializer::k_unknown_version:
set_error(tr("Failed to determine project version."));
break;
case ProjectSerializer::kFileError:
SetError(
tr("Failed to read file \"%1\" for reading.").arg(GetFilename()));
case ProjectSerializer::k_file_error:
set_error(
tr("Failed to read file \"%1\" for reading.").arg(get_filename()));
break;
case ProjectSerializer::kXmlError:
SetError(
case ProjectSerializer::k_xml_error:
set_error(
tr("Failed to read XML document. File may be corrupt. Error was: %1")
.arg(result.GetDetails()));
.arg(result.get_details()));
break;
case ProjectSerializer::kNoData:
SetError(tr("Failed to find any data to parse."));
case ProjectSerializer::k_no_data:
set_error(tr("Failed to find any data to parse."));
break;
// Errors that should never be thrown by a load
case ProjectSerializer::kOverwriteError:
SetError(tr("Unknown error."));
case ProjectSerializer::k_overwrite_error:
set_error(tr("Unknown error."));
break;
}
if (result == ProjectSerializer::kSuccess) {
if (result == ProjectSerializer::k_success) {
project_->moveToThread(qApp->thread());
return true;
} else {
+4 -4
View File
@@ -19,8 +19,8 @@
***/
#ifndef PROJECTLOADMANAGER_H
#define PROJECTLOADMANAGER_H
#ifndef OAK_PROJECTLOADMANAGER_H
#define OAK_PROJECTLOADMANAGER_H
#include "loadbasetask.h"
#include "window/mainwindow/mainwindowlayoutinfo.h"
@@ -34,9 +34,9 @@ public:
ProjectLoadTask(const QString &filename);
protected:
virtual bool Run() override;
virtual bool run() override;
};
}
#endif // PROJECTLOADMANAGER_H
#endif // OAK_PROJECTLOADMANAGER_H
+1 -1
View File
@@ -28,7 +28,7 @@ ProjectLoadBaseTask::ProjectLoadBaseTask(const QString &filename)
: project_(nullptr)
, filename_(filename)
{
SetTitle(tr("Loading '%1'").arg(filename));
set_title(tr("Loading '%1'").arg(filename));
}
}
+5 -5
View File
@@ -19,8 +19,8 @@
***/
#ifndef PROJECTLOADBASETASK_H
#define PROJECTLOADBASETASK_H
#ifndef OAK_PROJECTLOADBASETASK_H
#define OAK_PROJECTLOADBASETASK_H
#include "node/project.h"
#include "task/task.h"
@@ -33,17 +33,17 @@ class ProjectLoadBaseTask : public Task {
public:
ProjectLoadBaseTask(const QString &filename);
Project *GetLoadedProject() const
Project *get_loaded_project() const
{
return project_;
}
const QString &GetFilename() const
const QString &get_filename() const
{
return filename_;
}
const MainWindowLayoutInfo &GetLoadedLayout() const
const MainWindowLayoutInfo &get_loaded_layout() const
{
return layout_;
}
+6 -6
View File
@@ -221,17 +221,17 @@ bool LoadOTIOTask::Run()
track->AppendBlock(block);
rational start_time;
rational duration;
Rational start_time;
Rational duration;
if (otio_block->schema_name() == "Clip" ||
otio_block->schema_name() == "Gap") {
start_time = rational::fromDouble(
start_time = Rational::fromDouble(
static_cast<OTIO::Item *>(otio_block)
->source_range()
->start_time()
.to_seconds());
duration = rational::fromDouble(
duration = Rational::fromDouble(
static_cast<OTIO::Item *>(otio_block)
->source_range()
->duration()
@@ -262,9 +262,9 @@ bool LoadOTIOTask::Run()
// Set how far the transition eats into the previous clip
transition_block->set_offsets_and_length(
rational::fromRationalTime(
Rational::fromRationalTime(
otio_block_transition->in_offset()),
rational::fromRationalTime(
Rational::fromRationalTime(
otio_block_transition->out_offset()));
if (previous_block) {
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef OTIODECODER_H
#define OTIODECODER_H
#ifndef OAK_OTIODECODER_H
#define OAK_OTIODECODER_H
#ifdef USE_OTIO
@@ -44,4 +44,4 @@ protected:
#endif
#endif // OTIODECODER_H
#endif // OAK_OTIODECODER_H
+21 -21
View File
@@ -36,50 +36,50 @@ ProjectSaveTask::ProjectSaveTask(Project *project, bool use_compression)
: project_(project)
, use_compression_(use_compression)
{
SetTitle(tr("Saving '%1'").arg(project->filename()));
set_title(tr("Saving '%1'").arg(project->filename()));
}
bool ProjectSaveTask::Run()
bool ProjectSaveTask::run()
{
QString using_filename = override_filename_.isEmpty() ?
project_->filename() :
override_filename_;
ProjectSerializer::SaveData data(ProjectSerializer::kProject);
ProjectSerializer::SaveData data(ProjectSerializer::k_project);
data.SetFilename(using_filename);
data.SetProject(project_);
data.SetLayout(layout_);
data.set_filename(using_filename);
data.set_project(project_);
data.set_layout(layout_);
ProjectSerializer::Result result =
ProjectSerializer::Save(data, use_compression_);
ProjectSerializer::save(data, use_compression_);
bool success = false;
switch (result.code()) {
case ProjectSerializer::kSuccess:
case ProjectSerializer::k_success:
success = true;
break;
case ProjectSerializer::kXmlError:
SetError(tr("Failed to write XML data."));
case ProjectSerializer::k_xml_error:
set_error(tr("Failed to write XML data."));
break;
case ProjectSerializer::kFileError:
SetError(tr("Failed to open file \"%1\" for writing.")
.arg(result.GetDetails()));
case ProjectSerializer::k_file_error:
set_error(tr("Failed to open file \"%1\" for writing.")
.arg(result.get_details()));
break;
case ProjectSerializer::kOverwriteError:
SetError(
case ProjectSerializer::k_overwrite_error:
set_error(
tr("Failed to overwrite \"%1\". Project has been saved as \"%2\" instead.")
.arg(using_filename, result.GetDetails()));
.arg(using_filename, result.get_details()));
success = true;
break;
// Errors that should never be thrown by a save
case ProjectSerializer::kProjectTooNew:
case ProjectSerializer::kProjectTooOld:
case ProjectSerializer::kUnknownVersion:
case ProjectSerializer::kNoData:
SetError(tr("Unknown error."));
case ProjectSerializer::k_project_too_new:
case ProjectSerializer::k_project_too_old:
case ProjectSerializer::k_unknown_version:
case ProjectSerializer::k_no_data:
set_error(tr("Unknown error."));
break;
}
+7 -7
View File
@@ -19,8 +19,8 @@
***/
#ifndef PROJECTSAVEMANAGER_H
#define PROJECTSAVEMANAGER_H
#ifndef OAK_PROJECTSAVEMANAGER_H
#define OAK_PROJECTSAVEMANAGER_H
#include "node/project.h"
#include "task/task.h"
@@ -33,23 +33,23 @@ class ProjectSaveTask : public Task {
public:
ProjectSaveTask(Project *project, bool use_compression);
Project *GetProject() const
Project *get_project() const
{
return project_;
}
void SetOverrideFilename(const QString &filename)
void set_override_filename(const QString &filename)
{
override_filename_ = filename;
}
void SetLayout(const MainWindowLayoutInfo &layout)
void set_layout(const MainWindowLayoutInfo &layout)
{
layout_ = layout;
}
protected:
virtual bool Run() override;
virtual bool run() override;
private:
Project *project_;
@@ -63,4 +63,4 @@ private:
}
#endif // PROJECTSAVEMANAGER_H
#endif // OAK_PROJECTSAVEMANAGER_H
+2 -2
View File
@@ -125,7 +125,7 @@ OTIO::Timeline *SaveOTIOTask::SerializeTimeline(Sequence *sequence)
}
OTIO::Track *SaveOTIOTask::SerializeTrack(Track *track, double sequence_rate,
rational max_track_length)
Rational max_track_length)
{
auto otio_track = new OTIO::Track();
@@ -246,7 +246,7 @@ bool SaveOTIOTask::SerializeTrackList(TrackList *list,
{
OTIO::ErrorStatus es;
rational max_track_length = RATIONAL_MIN;
Rational max_track_length = RATIONAL_MIN;
foreach (Track *track, list->GetTracks()) {
if (track->track_length() > max_track_length) {
+4 -4
View File
@@ -19,8 +19,8 @@
***/
#ifndef PROJECTSAVEASOTIOTASK_H
#define PROJECTSAVEASOTIOTASK_H
#ifndef OAK_PROJECTSAVEASOTIOTASK_H
#define OAK_PROJECTSAVEASOTIOTASK_H
#ifdef USE_OTIO
@@ -46,7 +46,7 @@ private:
OTIO::Timeline *SerializeTimeline(Sequence *sequence);
OTIO::Track *SerializeTrack(Track *track, double sequence_rate,
rational max_track_length);
Rational max_track_length);
bool SerializeTrackList(TrackList *list, OTIO::Timeline *otio_timeline,
double sequence_rate);
@@ -58,4 +58,4 @@ private:
#endif
#endif // PROJECTSAVEASOTIOTASK_H
#endif // OAK_PROJECTSAVEASOTIOTASK_H
+14 -14
View File
@@ -39,11 +39,11 @@ ProxyTask::ProxyTask(const QString &source_filename, int stream_index,
, params_(params)
, output_filename_(output_filename)
{
SetTitle(tr("Generating Proxy %1:%2")
set_title(tr("Generating Proxy %1:%2")
.arg(source_filename_, QString::number(stream_index_)));
}
QStringList ProxyTask::BuildArguments(const QString &source_filename,
QStringList ProxyTask::build_arguments(const QString &source_filename,
int stream_index,
const ProxyManager::ProxyParams &params,
const QString &output_filename)
@@ -82,12 +82,12 @@ QStringList ProxyTask::BuildArguments(const QString &source_filename,
return args;
}
bool ProxyTask::Run()
bool ProxyTask::run()
{
const QString ffmpeg = ProxyManager::FindFFmpegExecutable(
OLIVE_CONFIG("FFmpegPath").toString());
const QString ffmpeg = ProxyManager::find_f_fmpeg_executable(
OAK_CONFIG("FFmpegPath").toString());
if (ffmpeg.isEmpty()) {
SetError(
set_error(
tr("Failed to generate proxy: ffmpeg executable was not found. Set "
"the ffmpeg path in Preferences > Disk > Proxy Settings."));
qWarning() << "ProxyTask: ffmpeg executable not found";
@@ -96,7 +96,7 @@ bool ProxyTask::Run()
QDir output_dir = QFileInfo(output_filename_).dir();
if (!output_dir.exists() && !output_dir.mkpath(QStringLiteral("."))) {
SetError(tr("Failed to create proxy output directory"));
set_error(tr("Failed to create proxy output directory"));
qWarning() << "ProxyTask: failed to create output directory"
<< output_dir.absolutePath();
return false;
@@ -108,7 +108,7 @@ bool ProxyTask::Run()
QFile::remove(output_filename_);
const QStringList args = BuildArguments(source_filename_, stream_index_,
const QStringList args = build_arguments(source_filename_, stream_index_,
params_, output_filename_);
QProcess process;
@@ -118,18 +118,18 @@ bool ProxyTask::Run()
process.start();
if (!process.waitForStarted()) {
SetError(tr("Failed to start ffmpeg for proxy generation"));
set_error(tr("Failed to start ffmpeg for proxy generation"));
qWarning()
<< "ProxyTask: failed to start ffmpeg" << process.errorString();
return false;
}
while (!process.waitForFinished(100)) {
if (IsCancelled()) {
if (is_cancelled()) {
process.kill();
process.waitForFinished();
QFile::remove(output_filename_);
SetError(tr("Proxy generation was cancelled"));
set_error(tr("Proxy generation was cancelled"));
return false;
}
}
@@ -138,21 +138,21 @@ bool ProxyTask::Run()
process.exitCode() != 0) {
const QString output = QString::fromUtf8(process.readAll()).trimmed();
QFile::remove(output_filename_);
SetError(tr("ffmpeg failed to generate proxy: %1").arg(output));
set_error(tr("ffmpeg failed to generate proxy: %1").arg(output));
qWarning() << "ProxyTask: ffmpeg failed with exit code"
<< process.exitCode() << "output:" << output;
return false;
}
if (!QFileInfo::exists(output_filename_)) {
SetError(tr("ffmpeg finished but proxy file was not created"));
set_error(tr("ffmpeg finished but proxy file was not created"));
qWarning() << "ProxyTask: ffmpeg finished but output file missing"
<< output_filename_;
return false;
}
qDebug() << "ProxyTask: proxy generation succeeded:" << output_filename_;
emit ProgressChanged(1.0);
emit progress_changed(1.0);
return true;
}
+5 -5
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROXYTASK_H
#define PROXYTASK_H
#ifndef OAK_PROXYTASK_H
#define OAK_PROXYTASK_H
#include "codec/proxymanager.h"
#include "task/task.h"
@@ -39,13 +39,13 @@ public:
* that it is stream 0 in the proxy file; audio streams (when enabled)
* follow in source order.
*/
static QStringList BuildArguments(const QString &source_filename,
static QStringList build_arguments(const QString &source_filename,
int stream_index,
const ProxyManager::ProxyParams &params,
const QString &output_filename);
protected:
virtual bool Run() override;
virtual bool run() override;
private:
QString source_filename_;
@@ -56,4 +56,4 @@ private:
}
#endif // PROXYTASK_H
#endif // OAK_PROXYTASK_H
+61 -61
View File
@@ -37,7 +37,7 @@ RenderTask::~RenderTask()
{
}
bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range,
bool RenderTask::render(ColorManager *manager, const TimeRangeList &video_range,
const TimeRangeList &audio_range,
const TimeRange &subtitle_range, RenderMode::Mode mode,
FrameHashCache *cache, const QSize &force_size,
@@ -65,14 +65,14 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range,
//total_length += r.length().toDouble();
RenderManager::RenderAudioParams rap(
viewer_->GetConnectedSampleOutput(), range, audio_params_,
RenderMode::kOnline);
viewer_->get_connected_sample_output(), range, audio_params_,
RenderMode::k_online);
RenderTicketWatcher *watcher = new RenderTicketWatcher();
watcher->setProperty("range", QVariant::fromValue(range));
PrepareWatcher(watcher, &watcher_thread);
IncrementRunningTickets();
watcher->SetTicket(RenderManager::instance()->RenderAudio(rap));
prepare_watcher(watcher, &watcher_thread);
increment_running_tickets();
watcher->set_ticket(RenderManager::instance()->render_audio(rap));
}
// Look up hashes
@@ -87,10 +87,10 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range,
// each of the system's threads are utilized as memory allows.
const int maximum_rendered_frames = QThread::idealThreadCount();
rational next_frame;
Rational next_frame;
for (int i = 0;
i < maximum_rendered_frames && iterator.GetNext(&next_frame); i++) {
StartTicket(&watcher_thread, manager, next_frame, mode, cache,
i < maximum_rendered_frames && iterator.get_next(&next_frame); i++) {
start_ticket(&watcher_thread, manager, next_frame, mode, cache,
force_size, force_matrix, force_format, force_channel_count,
force_color_output, force_color_transform);
}
@@ -100,37 +100,37 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range,
// Subtitle loop, loops over all blocks in sequence on all tracks
if (!subtitle_range.length().isNull()) {
if (Sequence *sequence = dynamic_cast<Sequence *>(viewer_)) {
TrackList *list = sequence->track_list(Track::kSubtitle);
QVector<int> block_indexes(list->GetTrackCount(), 0);
TrackList *list = sequence->track_list(Track::k_subtitle);
QVector<int> block_indexes(list->get_track_count(), 0);
QVector<int> tracks_to_push;
do {
tracks_to_push.clear();
for (int i = 0; i < block_indexes.size(); i++) {
Track *this_track = list->GetTrackAt(i);
if (this_track->IsMuted()) {
Track *this_track = list->get_track_at(i);
if (this_track->is_muted()) {
continue;
}
int &this_block_index = block_indexes[i];
if (this_block_index >= this_track->Blocks().size()) {
if (this_block_index >= this_track->blocks().size()) {
continue;
}
Block *this_block =
this_track->Blocks().at(this_block_index);
this_track->blocks().at(this_block_index);
Track *compare_track =
tracks_to_push.isEmpty() ?
nullptr :
list->GetTrackAt(tracks_to_push.first());
list->get_track_at(tracks_to_push.first());
const int &compare_block_index =
tracks_to_push.isEmpty() ?
-1 :
block_indexes.at(tracks_to_push.first());
Block *compare_block =
compare_track ?
compare_track->Blocks().at(compare_block_index) :
compare_track->blocks().at(compare_block_index) :
nullptr;
if (!compare_track ||
compare_block->in() >= this_block->in()) {
@@ -143,14 +143,14 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range,
}
for (int i = 0; i < tracks_to_push.size(); i++) {
Track *this_track = list->GetTrackAt(tracks_to_push.at(i));
Block *this_block = this_track->Blocks().at(
Track *this_track = list->get_track_at(tracks_to_push.at(i));
Block *this_block = this_track->blocks().at(
block_indexes.at(tracks_to_push.at(i)));
if (const SubtitleBlock *sub =
dynamic_cast<const SubtitleBlock *>(this_block)) {
if (sub->is_enabled()) {
if (!EncodeSubtitle(sub)) {
if (!encode_subtitle(sub)) {
result = false;
break;
}
@@ -165,8 +165,8 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range,
finished_watcher_mutex_.lock();
while (result && !IsCancelled()) {
while (!finished_watchers_.empty() && !IsCancelled() && result) {
while (result && !is_cancelled()) {
while (!finished_watchers_.empty() && !is_cancelled() && result) {
RenderTicketWatcher *watcher = finished_watchers_.front();
finished_watchers_.pop_front();
@@ -174,15 +174,15 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range,
// Analyze watcher here
RenderManager::TicketType ticket_type =
watcher->GetTicket()
watcher->get_ticket()
->property("type")
.value<RenderManager::TicketType>();
if (ticket_type == RenderManager::kTypeAudio) {
if (ticket_type == RenderManager::k_type_audio) {
TimeRange range = watcher->property("range").value<TimeRange>();
if (!AudioDownloaded(range,
watcher->Get().value<SampleBuffer>())) {
if (!audio_downloaded(range,
watcher->get().value<SampleBuffer>())) {
result = false;
}
@@ -191,39 +191,39 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range,
//progress_counter += range.length().toDouble();
//emit ProgressChanged(progress_counter / total_length);
} else if (ticket_type == RenderManager::kTypeVideo &&
TwoStepFrameRendering()) {
if (!DownloadFrame(
&watcher_thread, watcher->Get().value<FramePtr>(),
watcher->property("time").value<rational>())) {
} else if (ticket_type == RenderManager::k_type_video &&
two_step_frame_rendering()) {
if (!download_frame(
&watcher_thread, watcher->get().value<FramePtr>(),
watcher->property("time").value<Rational>())) {
result = false;
}
if (native_progress_signalling_) {
progress_counter += 0.5;
emit ProgressChanged(progress_counter / total_length);
emit progress_changed(progress_counter / total_length);
}
} else {
// Assume single-step video or video download ticket
if (!FrameDownloaded(
watcher->Get().value<FramePtr>(),
watcher->property("time").value<rational>())) {
if (!frame_downloaded(
watcher->get().value<FramePtr>(),
watcher->property("time").value<Rational>())) {
result = false;
}
if (native_progress_signalling_) {
double progress_to_add = 1.0;
if (TwoStepFrameRendering()) {
if (two_step_frame_rendering()) {
progress_to_add *= 0.5;
}
progress_counter += progress_to_add;
emit ProgressChanged(progress_counter / total_length);
emit progress_changed(progress_counter / total_length);
}
if (iterator.GetNext(&next_frame)) {
StartTicket(&watcher_thread, manager, next_frame, mode,
if (iterator.get_next(&next_frame)) {
start_ticket(&watcher_thread, manager, next_frame, mode,
cache, force_size, force_matrix, force_format,
force_channel_count, force_color_output,
force_color_transform);
@@ -236,7 +236,7 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range,
finished_watcher_mutex_.lock();
}
if (IsCancelled() || !result) {
if (is_cancelled() || !result) {
break;
}
@@ -251,17 +251,17 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range,
finished_watcher_mutex_.unlock();
if (IsCancelled() || !result) {
if (is_cancelled() || !result) {
// Cancel every watcher we created
foreach (RenderTicketWatcher *watcher, running_watchers_) {
watcher->Cancel();
disconnect(watcher, &RenderTicketWatcher::Finished, this,
&RenderTask::TicketDone);
RenderManager::instance()->RemoveTicket(watcher->GetTicket());
watcher->cancel();
disconnect(watcher, &RenderTicketWatcher::finished, this,
&RenderTask::ticket_done);
RenderManager::instance()->remove_ticket(watcher->get_ticket());
}
foreach (RenderTicketWatcher *watcher, running_watchers_) {
watcher->WaitForFinished();
watcher->wait_for_finished();
}
}
@@ -275,8 +275,8 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range,
return result;
}
bool RenderTask::DownloadFrame(QThread *thread, FramePtr frame,
const rational &time)
bool RenderTask::download_frame(QThread *thread, FramePtr frame,
const Rational &time)
{
//RenderTicketWatcher* watcher = new RenderTicketWatcher();
//PrepareWatcher(watcher, thread);
@@ -289,36 +289,36 @@ bool RenderTask::DownloadFrame(QThread *thread, FramePtr frame,
return true;
}
bool RenderTask::EncodeSubtitle(const SubtitleBlock *subtitle)
bool RenderTask::encode_subtitle(const SubtitleBlock *subtitle)
{
Q_UNUSED(subtitle)
return true;
}
void RenderTask::PrepareWatcher(RenderTicketWatcher *watcher, QThread *thread)
void RenderTask::prepare_watcher(RenderTicketWatcher *watcher, QThread *thread)
{
watcher->moveToThread(thread);
connect(watcher, &RenderTicketWatcher::Finished, this,
&RenderTask::TicketDone, Qt::DirectConnection);
connect(watcher, &RenderTicketWatcher::finished, this,
&RenderTask::ticket_done, Qt::DirectConnection);
running_watchers_.append(watcher);
}
void RenderTask::IncrementRunningTickets()
void RenderTask::increment_running_tickets()
{
finished_watcher_mutex_.lock();
running_tickets_++;
finished_watcher_mutex_.unlock();
}
void RenderTask::StartTicket(QThread *watcher_thread, ColorManager *manager,
const rational &time, RenderMode::Mode mode,
void RenderTask::start_ticket(QThread *watcher_thread, ColorManager *manager,
const Rational &time, RenderMode::Mode mode,
FrameHashCache *cache, const QSize &force_size,
const QMatrix4x4 &force_matrix,
PixelFormat force_format, int force_channel_count,
ColorProcessorPtr force_color_output,
const ColorTransform &force_color_transform)
{
RenderManager::RenderVideoParams rvp(viewer_->GetConnectedTextureOutput(),
RenderManager::RenderVideoParams rvp(viewer_->get_connected_texture_output(),
video_params_, audio_params_, time,
manager, mode);
@@ -330,17 +330,17 @@ void RenderTask::StartTicket(QThread *watcher_thread, ColorManager *manager,
rvp.force_channel_count = force_channel_count;
if (cache) {
rvp.AddCache(cache);
rvp.add_cache(cache);
}
RenderTicketWatcher *watcher = new RenderTicketWatcher();
watcher->setProperty("time", QVariant::fromValue(time));
PrepareWatcher(watcher, watcher_thread);
IncrementRunningTickets();
watcher->SetTicket(RenderManager::instance()->RenderFrame(rvp));
prepare_watcher(watcher, watcher_thread);
increment_running_tickets();
watcher->set_ticket(RenderManager::instance()->render_frame(rvp));
}
void RenderTask::TicketDone(RenderTicketWatcher *watcher)
void RenderTask::ticket_done(RenderTicketWatcher *watcher)
{
finished_watcher_mutex_.lock();
finished_watchers_.push_back(watcher);
+18 -18
View File
@@ -19,8 +19,8 @@
***/
#ifndef RENDERTASK_H
#define RENDERTASK_H
#ifndef OAK_RENDERTASK_H
#define OAK_RENDERTASK_H
#include <QtConcurrent/QtConcurrent>
@@ -41,25 +41,25 @@ public:
virtual ~RenderTask() override;
protected:
bool Render(ColorManager *manager, const TimeRangeList &video_range,
bool render(ColorManager *manager, const TimeRangeList &video_range,
const TimeRangeList &audio_range,
const TimeRange &subtitle_range, RenderMode::Mode mode,
FrameHashCache *cache, const QSize &force_size = QSize(0, 0),
const QMatrix4x4 &force_matrix = QMatrix4x4(),
PixelFormat force_format = PixelFormat::INVALID,
PixelFormat force_format = PixelFormat::invalid,
int force_channel_count = 0,
ColorProcessorPtr force_color_output = nullptr,
const ColorTransform &force_color_transform = ColorTransform());
virtual bool DownloadFrame(QThread *thread, FramePtr frame,
const rational &time);
virtual bool download_frame(QThread *thread, FramePtr frame,
const Rational &time);
virtual bool FrameDownloaded(FramePtr frame, const rational &time) = 0;
virtual bool frame_downloaded(FramePtr frame, const Rational &time) = 0;
virtual bool AudioDownloaded(const TimeRange &range,
virtual bool audio_downloaded(const TimeRange &range,
const SampleBuffer &samples) = 0;
virtual bool EncodeSubtitle(const SubtitleBlock *subtitle);
virtual bool encode_subtitle(const SubtitleBlock *subtitle);
ViewerOutput *viewer() const
{
@@ -98,12 +98,12 @@ protected:
finished_watcher_mutex_.unlock();
}
virtual bool TwoStepFrameRendering() const
virtual bool two_step_frame_rendering() const
{
return true;
}
void SetNativeProgressSignallingEnabled(bool e)
void set_native_progress_signalling_enabled(bool e)
{
native_progress_signalling_ = e;
}
@@ -111,18 +111,18 @@ protected:
/**
* @brief Only valid after Render() is called
*/
int64_t GetTotalNumberOfFrames() const
int64_t get_total_number_of_frames() const
{
return total_number_of_frames_;
}
private:
void PrepareWatcher(RenderTicketWatcher *watcher, QThread *thread);
void prepare_watcher(RenderTicketWatcher *watcher, QThread *thread);
void IncrementRunningTickets();
void increment_running_tickets();
void StartTicket(QThread *watcher_thread, ColorManager *manager,
const rational &time, RenderMode::Mode mode,
void start_ticket(QThread *watcher_thread, ColorManager *manager,
const Rational &time, RenderMode::Mode mode,
FrameHashCache *cache, const QSize &force_size,
const QMatrix4x4 &force_matrix, PixelFormat force_format,
int force_channel_count,
@@ -146,9 +146,9 @@ private:
int64_t total_number_of_frames_;
private slots:
void TicketDone(RenderTicketWatcher *watcher);
void ticket_done(RenderTicketWatcher *watcher);
};
}
#endif // RENDERTASK_H
#endif // OAK_RENDERTASK_H
+18 -18
View File
@@ -19,8 +19,8 @@
***/
#ifndef TASK_H
#define TASK_H
#ifndef OAK_TASK_H
#define OAK_TASK_H
#include <memory>
#include <QDateTime>
@@ -65,7 +65,7 @@ public:
/**
* @brief Retrieve the current title of this Task
*/
const QString &GetTitle() const
const QString &get_title() const
{
return title_;
}
@@ -73,12 +73,12 @@ public:
/**
* @brief Returns the error that occurred if Run() returns false
*/
const QString &GetError() const
const QString &get_error() const
{
return error_;
}
const qint64 &GetStartTime() const
const qint64 &get_start_time() const
{
return start_time_;
}
@@ -91,18 +91,18 @@ public slots:
*
* \see GetError() if this returns false.
*/
bool Start()
bool start()
{
start_time_ = QDateTime::currentMSecsSinceEpoch();
emit Started(start_time_);
emit started(start_time_);
bool ret = Run();
bool ret = run();
// Print how long this task took for debugging purposes
qDebug() << this << "took"
<< (QDateTime::currentMSecsSinceEpoch() - start_time_);
emit Finished(this, ret);
emit finished(this, ret);
return ret;
}
@@ -113,7 +113,7 @@ public slots:
* Override this if your class holds any persistent state that should be cleared/modified before
* it's safe for Run() to run again.
*/
virtual void Reset()
virtual void reset()
{
}
@@ -125,11 +125,11 @@ public slots:
*/
void Cancel()
{
CancelableObject::Cancel();
CancelableObject::cancel();
}
protected:
virtual bool Run() = 0;
virtual bool run() = 0;
/**
* @brief Set the error message
@@ -137,7 +137,7 @@ protected:
* It is recommended to use this if your Action() function ever returns FALSE to tell the user why the failure
* occurred.
*/
void SetError(const QString &s)
void set_error(const QString &s)
{
error_ = s;
}
@@ -149,13 +149,13 @@ protected:
* and shouldn't need to change during the life of the Task. To show an error message, it's recommended to use
* set_error() instead.
*/
void SetTitle(const QString &s)
void set_title(const QString &s)
{
title_ = s;
}
signals:
void Started(qint64 start_time);
void started(qint64 start_time);
/**
* @brief Signal emitted whenever progress is made
@@ -166,14 +166,14 @@ signals:
*
* A progress value between 0.0 and 1.0.
*/
void ProgressChanged(double d);
void progress_changed(double d);
/**
* @brief Emitted when task is finished
*
* Do NOT delete immediately after this signal, call deleteLater() instead.
*/
void Finished(Task *task, bool succeeded);
void finished(Task *task, bool succeeded);
private:
QString title_;
@@ -185,4 +185,4 @@ private:
}
#endif // TASK_H
#endif // OAK_TASK_H
+16 -16
View File
@@ -49,12 +49,12 @@ TaskManager::~TaskManager()
}
}
void TaskManager::CreateInstance()
void TaskManager::create_instance()
{
instance_ = new TaskManager();
}
void TaskManager::DestroyInstance()
void TaskManager::destroy_instance()
{
delete instance_;
instance_ = nullptr;
@@ -65,17 +65,17 @@ TaskManager *TaskManager::instance()
return instance_;
}
int TaskManager::GetTaskCount() const
int TaskManager::get_task_count() const
{
return tasks_.size();
}
Task *TaskManager::GetFirstTask() const
Task *TaskManager::get_first_task() const
{
return tasks_.begin().value();
}
void TaskManager::CancelTaskAndWait(Task *t)
void TaskManager::cancel_task_and_wait(Task *t)
{
t->Cancel();
@@ -86,12 +86,12 @@ void TaskManager::CancelTaskAndWait(Task *t)
}
}
void TaskManager::AddTask(Task *t)
void TaskManager::add_task(Task *t)
{
// Create a watcher for signalling
QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>();
connect(watcher, &QFutureWatcher<bool>::finished, this,
&TaskManager::TaskFinished);
&TaskManager::task_finished);
// Add the Task to the queue
tasks_.insert(watcher, t);
@@ -99,30 +99,30 @@ void TaskManager::AddTask(Task *t)
// Run task concurrently
watcher->setFuture(
#if QT_VERSION_MAJOR >= 6
QtConcurrent::run(&thread_pool_, &Task::Start, t)
QtConcurrent::run(&thread_pool_, &Task::start, t)
#else
QtConcurrent::run(&thread_pool_, t, &Task::Start)
#endif
);
// Emit signal that a Task was added
emit TaskAdded(t);
emit TaskListChanged();
emit task_added(t);
emit task_list_changed();
}
void TaskManager::CancelTask(Task *t)
void TaskManager::cancel_task(Task *t)
{
if (std::find(failed_tasks_.begin(), failed_tasks_.end(), t) !=
failed_tasks_.end()) {
failed_tasks_.remove(t);
emit TaskRemoved(t);
emit task_removed(t);
t->deleteLater();
} else {
t->Cancel();
}
}
void TaskManager::TaskFinished()
void TaskManager::task_finished()
{
QFutureWatcher<bool> *watcher =
static_cast<QFutureWatcher<bool> *>(sender());
@@ -132,17 +132,17 @@ void TaskManager::TaskFinished()
if (watcher->result()) {
// Task completed successfully
emit TaskRemoved(t);
emit task_removed(t);
t->deleteLater();
} else {
// Task failed, keep it so the user can see the error message
emit TaskFailed(t);
emit task_failed(t);
failed_tasks_.push_back(t);
}
watcher->deleteLater();
emit TaskListChanged();
emit task_list_changed();
}
}
+16 -16
View File
@@ -19,8 +19,8 @@
***/
#ifndef TASKMANAGER_H
#define TASKMANAGER_H
#ifndef OAK_TASKMANAGER_H
#define OAK_TASKMANAGER_H
#include <QtConcurrent/QtConcurrent>
#include <QVector>
@@ -54,17 +54,17 @@ public:
*/
virtual ~TaskManager();
static void CreateInstance();
static void create_instance();
static void DestroyInstance();
static void destroy_instance();
static TaskManager *instance();
int GetTaskCount() const;
int get_task_count() const;
Task *GetFirstTask() const;
Task *get_first_task() const;
void CancelTaskAndWait(Task *t);
void cancel_task_and_wait(Task *t);
public slots:
/**
@@ -82,9 +82,9 @@ public slots:
*
* The task to add and run. TaskManager takes ownership of this Task and will be responsible for freeing it.
*/
void AddTask(Task *t);
void add_task(Task *t);
void CancelTask(Task *t);
void cancel_task(Task *t);
signals:
/**
@@ -94,22 +94,22 @@ signals:
*
* Task that was added
*/
void TaskAdded(Task *t);
void task_added(Task *t);
/**
* @brief Signal emitted when any change to the running task list has been made
*/
void TaskListChanged();
void task_list_changed();
/**
* @brief Signal emitted when a task is deleted
*/
void TaskRemoved(Task *t);
void task_removed(Task *t);
/**
* @brief Signal emitted when a task fails
*/
void TaskFailed(Task *t);
void task_failed(Task *t);
private:
/**
@@ -128,14 +128,14 @@ private:
QThreadPool thread_pool_;
/**
* @brief TaskManager singleton instance
* @brief TaskManager singleton instance_
*/
static TaskManager *instance_;
private slots:
void TaskFinished();
void task_finished();
};
}
#endif // TASKMANAGER_H
#endif // OAK_TASKMANAGER_H