export: allow users to override the thread count

This commit is contained in:
itsmattkc
2020-04-30 17:19:43 +10:00
parent aecfa842c3
commit ce42388d68
10 changed files with 141 additions and 15 deletions
+2
View File
@@ -20,6 +20,8 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
dialog/export/export.h
dialog/export/export.cpp
dialog/export/exportadvancedvideodialog.h
dialog/export/exportadvancedvideodialog.cpp
dialog/export/exportaudiotab.h
dialog/export/exportaudiotab.cpp
dialog/export/exportcodec.h
+5 -5
View File
@@ -78,7 +78,7 @@ void H264Section::AddOpts(EncodingParams *params)
if (method == kConstantRateFactor) {
// Simply set CRF value
params->SetVideoOption(QStringLiteral("crf"), QString::number(crf_section_->GetValue()));
params->set_video_option(QStringLiteral("crf"), QString::number(crf_section_->GetValue()));
} else {
@@ -95,11 +95,11 @@ void H264Section::AddOpts(EncodingParams *params)
}
// Disable CRF encoding
params->SetVideoOption(QStringLiteral("crf"), QStringLiteral("-1"));
params->set_video_option(QStringLiteral("crf"), QStringLiteral("-1"));
params->SetVideoBitRate(target_rate);
params->SetVideoMaxBitRate(max_rate);
params->SetVideoBufferSize(2000000);
params->set_video_bit_rate(target_rate);
params->set_video_max_bit_rate(max_rate);
params->set_video_buffer_size(2000000);
}
}
+2
View File
@@ -531,6 +531,8 @@ ExportParams ExportDialog::GenerateParams() const
params.EnableVideo(video_render_params,
video_codec.id());
params.set_video_threads(video_tab_->threads());
video_tab_->GetCodecSection()->AddOpts(&params);
params.set_color_transform(video_tab_->CurrentOCIOColorSpace());
@@ -0,0 +1,42 @@
#include "exportadvancedvideodialog.h"
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QLabel>
OLIVE_NAMESPACE_ENTER
ExportAdvancedVideoDialog::ExportAdvancedVideoDialog(QWidget *parent) :
QDialog(parent)
{
setWindowTitle(tr("Advanced"));
QGridLayout* layout = new QGridLayout(this);
int row = 0;
layout->addWidget(new QLabel(tr("Threads:")), row, 0);
thread_slider_ = new IntegerSlider();
thread_slider_->SetMinimum(0);
layout->addWidget(thread_slider_, row, 1);
row++;
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttons, &QDialogButtonBox::accepted, this, &ExportAdvancedVideoDialog::accept);
connect(buttons, &QDialogButtonBox::rejected, this, &ExportAdvancedVideoDialog::reject);
layout->addWidget(buttons, row, 0, 1, 2);
}
int ExportAdvancedVideoDialog::threads() const
{
return static_cast<int>(thread_slider_->GetValue());
}
void ExportAdvancedVideoDialog::set_threads(int t)
{
thread_slider_->SetValue(t);
}
OLIVE_NAMESPACE_EXIT
@@ -0,0 +1,27 @@
#ifndef EXPORTADVANCEDVIDEODIALOG_H
#define EXPORTADVANCEDVIDEODIALOG_H
#include <QDialog>
#include "render/backend/exportparams.h"
#include "widget/slider/integerslider.h"
OLIVE_NAMESPACE_ENTER
class ExportAdvancedVideoDialog : public QDialog
{
Q_OBJECT
public:
ExportAdvancedVideoDialog(QWidget* parent = nullptr);
int threads() const;
void set_threads(int t);
private:
IntegerSlider* thread_slider_;
};
OLIVE_NAMESPACE_EXIT
#endif // EXPORTADVANCEDVIDEODIALOG_H
+26 -1
View File
@@ -24,8 +24,10 @@
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QPushButton>
#include "core.h"
#include "exportadvancedvideodialog.h"
#include "render/backend/exportparams.h"
#include "render/colormanager.h"
@@ -33,7 +35,8 @@ OLIVE_NAMESPACE_ENTER
ExportVideoTab::ExportVideoTab(ColorManager* color_manager, QWidget *parent) :
QWidget(parent),
color_manager_(color_manager)
color_manager_(color_manager),
threads_(0)
{
QVBoxLayout* outer_layout = new QVBoxLayout(this);
@@ -106,6 +109,11 @@ H264Section *ExportVideoTab::h264_section() const
return h264_section_;
}
const int &ExportVideoTab::threads() const
{
return threads_;
}
QWidget* ExportVideoTab::SetupResolutionSection()
{
int row = 0;
@@ -196,6 +204,12 @@ QWidget *ExportVideoTab::SetupCodecSection()
h264_section_ = new H264Section();
codec_stack_->addWidget(h264_section_);
row++;
QPushButton* advanced_btn = new QPushButton(tr("Advanced"));
connect(advanced_btn, &QPushButton::clicked, this, &ExportVideoTab::OpenAdvancedDialog);
codec_layout->addWidget(advanced_btn, row, 1);
return codec_group;
}
@@ -204,4 +218,15 @@ void ExportVideoTab::MaintainAspectRatioChanged(bool val)
scaling_method_combobox_->setEnabled(!val);
}
void ExportVideoTab::OpenAdvancedDialog()
{
ExportAdvancedVideoDialog d(this);
d.set_threads(threads_);
if (d.exec() == QDialog::Accepted) {
threads_ = d.threads();
}
}
OLIVE_NAMESPACE_EXIT
+6
View File
@@ -57,6 +57,8 @@ public:
ImageSection* image_section() const;
H264Section* h264_section() const;
const int& threads() const;
signals:
void ColorSpaceChanged(const QString& colorspace);
@@ -83,9 +85,13 @@ private:
ColorManager* color_manager_;
int threads_;
private slots:
void MaintainAspectRatioChanged(bool val);
void OpenAdvancedDialog();
};
OLIVE_NAMESPACE_EXIT