added thread count selection in export settings
This commit is contained in:
@@ -28,63 +28,80 @@
|
||||
#include <QDebug>
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavutil/pixdesc.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavutil/pixdesc.h>
|
||||
}
|
||||
|
||||
AdvancedVideoDialog::AdvancedVideoDialog(QWidget *parent,
|
||||
int encoding_codec,
|
||||
VideoCodecParams &iparams) :
|
||||
QDialog(parent),
|
||||
params(iparams)
|
||||
QDialog(parent),
|
||||
params_(iparams)
|
||||
{
|
||||
setWindowTitle(tr("Advanced Video Settings"));
|
||||
setWindowTitle(tr("Advanced Video Settings"));
|
||||
|
||||
// use variable for row to assist adding new fields to this dialog
|
||||
int row = 0;
|
||||
// use variable for row to assist adding new fields to the grid layout
|
||||
int row = 0;
|
||||
|
||||
// get encoder information for this codec
|
||||
AVCodec* codec_info = avcodec_find_encoder(static_cast<AVCodecID>(encoding_codec));
|
||||
// get encoder information for this codec from FFmpeg
|
||||
AVCodec* codec_info = avcodec_find_encoder(static_cast<AVCodecID>(encoding_codec));
|
||||
|
||||
// set up grid layout for dialog
|
||||
QGridLayout* layout = new QGridLayout(this);
|
||||
// set up grid layout for dialog
|
||||
QGridLayout* layout = new QGridLayout(this);
|
||||
|
||||
// codec pixel formats
|
||||
layout->addWidget(new QLabel(tr("Pixel Format:")), row, 0);
|
||||
// create row for codec pixel formats
|
||||
layout->addWidget(new QLabel(tr("Pixel Format:")), row, 0);
|
||||
pix_fmt_combo_ = new QComboBox();
|
||||
|
||||
pix_fmt_combo = new QComboBox();
|
||||
// loop through available pixel formats for this codec
|
||||
int pix_fmt_index = 0;
|
||||
while (codec_info->pix_fmts[pix_fmt_index] != -1) { // AVCodec->pix_fmts is terminated by "-1"
|
||||
|
||||
// load possible pixel formats for this codec into the combobox
|
||||
int pix_fmt_index = 0;
|
||||
// get the name of the pixel format and add it to the combobox (with the pixel format constant)
|
||||
pix_fmt_combo_->addItem(av_get_pix_fmt_name(codec_info->pix_fmts[pix_fmt_index]),
|
||||
codec_info->pix_fmts[pix_fmt_index]);
|
||||
|
||||
// AVCodec->pix_fmts is terminated by "-1"
|
||||
while (codec_info->pix_fmts[pix_fmt_index] != -1) {
|
||||
pix_fmt_combo->addItem(av_get_pix_fmt_name(codec_info->pix_fmts[pix_fmt_index]),
|
||||
codec_info->pix_fmts[pix_fmt_index]);
|
||||
|
||||
if (codec_info->pix_fmts[pix_fmt_index] == params.pix_fmt) {
|
||||
pix_fmt_combo->setCurrentIndex(pix_fmt_combo->count()-1);
|
||||
}
|
||||
|
||||
pix_fmt_index++;
|
||||
// if the user has already selected a pixel format, set the combobox to it as well
|
||||
if (codec_info->pix_fmts[pix_fmt_index] == params_.pix_fmt) {
|
||||
pix_fmt_combo_->setCurrentIndex(pix_fmt_combo_->count()-1);
|
||||
}
|
||||
|
||||
layout->addWidget(pix_fmt_combo, row, 1);
|
||||
pix_fmt_index++;
|
||||
}
|
||||
|
||||
row++;
|
||||
layout->addWidget(pix_fmt_combo_, row, 1);
|
||||
|
||||
// buttons
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
buttons->setCenterButtons(true);
|
||||
connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
layout->addWidget(buttons, row, 0, 1, 2);
|
||||
row++;
|
||||
|
||||
// create row for multithreading thread count
|
||||
layout->addWidget(new QLabel(tr("Threads:")), row, 0);
|
||||
|
||||
thread_spinbox_ = new QSpinBox();
|
||||
|
||||
// with the thread count, "0" is considered automatics
|
||||
thread_spinbox_->setMinimum(0);
|
||||
thread_spinbox_->setSpecialValueText("Auto");
|
||||
|
||||
// load current thread value
|
||||
thread_spinbox_->setValue(params_.threads);
|
||||
|
||||
layout->addWidget(thread_spinbox_);
|
||||
|
||||
row++;
|
||||
|
||||
// buttons
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
buttons->setCenterButtons(true);
|
||||
connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
layout->addWidget(buttons, row, 0, 1, 2);
|
||||
}
|
||||
|
||||
void AdvancedVideoDialog::accept() {
|
||||
// store settings back into struct
|
||||
// store settings back into struct
|
||||
|
||||
params.pix_fmt = pix_fmt_combo->currentData().toInt();
|
||||
params_.pix_fmt = pix_fmt_combo_->currentData().toInt();
|
||||
params_.threads = thread_spinbox_->value();
|
||||
|
||||
QDialog::accept();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
@@ -23,22 +23,40 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QComboBox>
|
||||
#include <QSpinBox>
|
||||
|
||||
#include "io/exportthread.h"
|
||||
|
||||
/**
|
||||
* @brief The AdvancedVideoDialog class
|
||||
*
|
||||
* A dialog for interfacing with VideoCodecParams, a struct for more advanced video settings sometimes specific to
|
||||
* one codec.
|
||||
*/
|
||||
class AdvancedVideoDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
AdvancedVideoDialog(QWidget* parent,
|
||||
int encoding_codec,
|
||||
VideoCodecParams& iparams);
|
||||
AdvancedVideoDialog(QWidget* parent,
|
||||
int encoding_codec,
|
||||
VideoCodecParams& iparams);
|
||||
|
||||
public slots:
|
||||
virtual void accept() override;
|
||||
virtual void accept() override;
|
||||
private:
|
||||
VideoCodecParams& params;
|
||||
/**
|
||||
* @brief Internal reference to VideoCodecParams struct provided by ExportDialog.
|
||||
*/
|
||||
VideoCodecParams& params_;
|
||||
|
||||
QComboBox* pix_fmt_combo;
|
||||
/**
|
||||
* @brief ComboBox to show available pixel formats for this codec
|
||||
*/
|
||||
QComboBox* pix_fmt_combo_;
|
||||
|
||||
/**
|
||||
* @brief SpinBox for multithreading settings
|
||||
*/
|
||||
QSpinBox* thread_spinbox_;
|
||||
};
|
||||
|
||||
#endif // ADVANCEDVIDEODIALOG_H
|
||||
|
||||
@@ -107,10 +107,14 @@ ExportDialog::ExportDialog(QWidget *parent) :
|
||||
}
|
||||
formatCombobox->setCurrentIndex(FORMAT_MPEG4);
|
||||
|
||||
// default to sequence's native dimensions
|
||||
widthSpinbox->setValue(olive::ActiveSequence->width);
|
||||
heightSpinbox->setValue(olive::ActiveSequence->height);
|
||||
samplingRateSpinbox->setValue(olive::ActiveSequence->audio_frequency);
|
||||
framerateSpinbox->setValue(olive::ActiveSequence->frame_rate);
|
||||
|
||||
// set some advanced defaults
|
||||
vcodec_params.threads = 0;
|
||||
}
|
||||
|
||||
ExportDialog::~ExportDialog()
|
||||
|
||||
+37
-37
@@ -35,52 +35,52 @@
|
||||
|
||||
class ExportDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ExportDialog(QWidget *parent = 0);
|
||||
~ExportDialog();
|
||||
QString export_error;
|
||||
explicit ExportDialog(QWidget *parent = nullptr);
|
||||
~ExportDialog();
|
||||
QString export_error;
|
||||
|
||||
private slots:
|
||||
void format_changed(int index);
|
||||
void export_action();
|
||||
void update_progress_bar(int value, qint64 remaining_ms);
|
||||
void cancel_render();
|
||||
void render_thread_finished();
|
||||
void vcodec_changed(int index);
|
||||
void comp_type_changed(int index);
|
||||
void open_advanced_video_dialog();
|
||||
void format_changed(int index);
|
||||
void export_action();
|
||||
void update_progress_bar(int value, qint64 remaining_ms);
|
||||
void cancel_render();
|
||||
void render_thread_finished();
|
||||
void vcodec_changed(int index);
|
||||
void comp_type_changed(int index);
|
||||
void open_advanced_video_dialog();
|
||||
|
||||
private:
|
||||
QVector<QString> format_strings;
|
||||
void setup_ui();
|
||||
QVector<QString> format_strings;
|
||||
void setup_ui();
|
||||
|
||||
ExportThread* et;
|
||||
void prep_ui_for_render(bool r);
|
||||
bool cancelled;
|
||||
ExportThread* et;
|
||||
void prep_ui_for_render(bool r);
|
||||
bool cancelled;
|
||||
|
||||
void add_codec_to_combobox(QComboBox* box, enum AVCodecID codec);
|
||||
void add_codec_to_combobox(QComboBox* box, enum AVCodecID codec);
|
||||
|
||||
VideoCodecParams vcodec_params;
|
||||
VideoCodecParams vcodec_params;
|
||||
|
||||
QComboBox* rangeCombobox;
|
||||
QSpinBox* widthSpinbox;
|
||||
QDoubleSpinBox* videobitrateSpinbox;
|
||||
QLabel* videoBitrateLabel;
|
||||
QDoubleSpinBox* framerateSpinbox;
|
||||
QComboBox* vcodecCombobox;
|
||||
QComboBox* acodecCombobox;
|
||||
QSpinBox* samplingRateSpinbox;
|
||||
QSpinBox* audiobitrateSpinbox;
|
||||
QProgressBar* progressBar;
|
||||
QComboBox* formatCombobox;
|
||||
QSpinBox* heightSpinbox;
|
||||
QPushButton* export_button;
|
||||
QPushButton* cancel_button;
|
||||
QPushButton* renderCancel;
|
||||
QGroupBox* videoGroupbox;
|
||||
QGroupBox* audioGroupbox;
|
||||
QComboBox* compressionTypeCombobox;
|
||||
QComboBox* rangeCombobox;
|
||||
QSpinBox* widthSpinbox;
|
||||
QDoubleSpinBox* videobitrateSpinbox;
|
||||
QLabel* videoBitrateLabel;
|
||||
QDoubleSpinBox* framerateSpinbox;
|
||||
QComboBox* vcodecCombobox;
|
||||
QComboBox* acodecCombobox;
|
||||
QSpinBox* samplingRateSpinbox;
|
||||
QSpinBox* audiobitrateSpinbox;
|
||||
QProgressBar* progressBar;
|
||||
QComboBox* formatCombobox;
|
||||
QSpinBox* heightSpinbox;
|
||||
QPushButton* export_button;
|
||||
QPushButton* cancel_button;
|
||||
QPushButton* renderCancel;
|
||||
QGroupBox* videoGroupbox;
|
||||
QGroupBox* audioGroupbox;
|
||||
QComboBox* compressionTypeCombobox;
|
||||
};
|
||||
|
||||
#endif // EXPORTDIALOG_H
|
||||
|
||||
Reference in New Issue
Block a user