added thread count selection in export settings

This commit is contained in:
itsmattkc
2019-02-26 10:02:36 -08:00
parent 39d62fe394
commit 19618fb8e9
9 changed files with 365 additions and 306 deletions
+54 -37
View File
@@ -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();
}