Commit 8a714260 authored by Julius Künzel's avatar Julius Künzel
Browse files

[Render Presets] GOP and B-Frames params: enable only if it makes sense

parent da75c7b0
Pipeline #153652 passed with stage
in 6 minutes and 50 seconds
......@@ -77,6 +77,10 @@ RenderPresetDialog::RenderPresetDialog(QWidget *parent, RenderPresetModel *prese
QStringLiteral("channels")
});
// TODO: implement colorspace
colorspaceCombo->hide();
colorspaceLabel->hide();
formatCombo->addItems(RenderPresetRepository::supportedFormats());
vCodecCombo->addItems(RenderPresetRepository::vcodecs());
aCodecCombo->addItems(RenderPresetRepository::acodecs());
......@@ -104,48 +108,69 @@ RenderPresetDialog::RenderPresetDialog(QWidget *parent, RenderPresetModel *prese
setPixelAspectRatio(64, 45);
setPixelAspectRatio(11, 9);
setPixelAspectRatio(118, 81);
/*parCombo->addItem(QStringLiteral("1.0000 (1:1)"), QStringLiteral("1:1"));
parCombo->addItem(QStringLiteral("0.9090 (10:11)"), QStringLiteral("10:11"));
parCombo->addItem(QStringLiteral("1.0909 (12:11)"), QStringLiteral("12:11"));
parCombo->addItem(QStringLiteral("1.0925 (59:54)"), QStringLiteral("59:54"));
parCombo->addItem(QStringLiteral("1.3333 (4:3)"), QStringLiteral("4:3"));
parCombo->addItem(QStringLiteral("1.4222 (64:45)"), QStringLiteral("64:45"));
parCombo->addItem(QStringLiteral("1.4545 (11:9)"), QStringLiteral("11:9"));
parCombo->addItem(QStringLiteral("1.456790123 (118:81)"), QStringLiteral("118:81"));*/
vRateControlCombo->addItem(i18n("Average Bitrate"));
vRateControlCombo->addItem(i18n("CBR – Constant Bitrate"));
vRateControlCombo->addItem(i18n("VBR – Variable Bitrate"));
vRateControlCombo->addItem(i18n("Contrained VBR"));
connect(vRateControlCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this](int index) {
switch (index) {
case RenderPresetModel::RateControl::Average:
default_vbitrate->setEnabled(true);
default_vbitrate_label->setEnabled(true);
default_vquality->setEnabled(false);
vquality_label->setEnabled(false);
vBuffer->setEnabled(false);
vBuffer_label->setEnabled(false);
break;
case RenderPresetModel::RateControl::Constant:
default_vbitrate->setEnabled(true);
default_vbitrate_label->setEnabled(true);
default_vquality->setEnabled(false);
vquality_label->setEnabled(false);
vBuffer->setEnabled(true);
vBuffer_label->setEnabled(true);
break;
case RenderPresetModel::RateControl::Constrained:
default_vbitrate->setEnabled(true);
default_vbitrate_label->setEnabled(true);
default_vquality->setEnabled(true);
vquality_label->setEnabled(true);
vBuffer->setEnabled(true);
vBuffer_label->setEnabled(true);
break;
case RenderPresetModel::RateControl::Quality:
default_vbitrate->setEnabled(false);
default_vbitrate_label->setEnabled(false);
default_vquality->setEnabled(true);
vquality_label->setEnabled(true);
vBuffer->setEnabled(false);
vBuffer_label->setEnabled(false);
break;
};
slotUpdateParams();
});
vRateControlCombo->addItem(i18n("Average Bitrate"));
vRateControlCombo->addItem(i18n("CBR – Constant Bitrate"));
vRateControlCombo->addItem(i18n("VBR – Variable Bitrate"));
vRateControlCombo->addItem(i18n("Contrained VBR"));
connect(scanningCombo, &QComboBox::currentTextChanged, this, [&](){
fieldOrderCombo->setEnabled(scanningCombo->currentIndex() != 1);
fieldOrderLabel->setEnabled(scanningCombo->currentIndex() != 1);
slotUpdateParams();
});
connect(gopSpinner, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [&] (int value) {
fixedGop->setEnabled(value > 1);
bFramesSpinner->setEnabled(value > 1);
bFramesLabel->setEnabled(value > 1);
if (value <= 1) {
fixedGop->blockSignals(true);
fixedGop->setChecked(false);
fixedGop->blockSignals(false);
bFramesSpinner->blockSignals(true);
bFramesSpinner->setValue(-1);
bFramesSpinner->blockSignals(false);
} else {
bFramesSpinner->setMaximum(value - 1);
}
slotUpdateParams();
});
......@@ -407,7 +432,6 @@ RenderPresetDialog::RenderPresetDialog(QWidget *parent, RenderPresetModel *prese
slotUpdateParams();
});
connect(fixedGop, &QCheckBox::stateChanged, this, &RenderPresetDialog::slotUpdateParams);
connect(gopSpinner, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RenderPresetDialog::slotUpdateParams);
connect(bFramesSpinner, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &RenderPresetDialog::slotUpdateParams);
connect(additionalParams, &QPlainTextEdit::textChanged, this, &RenderPresetDialog::slotUpdateParams);
......@@ -502,7 +526,7 @@ void RenderPresetDialog::slotUpdateParams() {
break;
}
}
if (fixedGop->isChecked()) {
if (fixedGop->isEnabled() && fixedGop->isChecked()) {
params.append(QStringLiteral("sc_threshold=0"));
}
} else if (vcodec.contains("nvenc")) {
......@@ -535,7 +559,7 @@ void RenderPresetDialog::slotUpdateParams() {
/*if (ui->dualPassCheckbox->isChecked())
setIfNotSet(p, "v2pass", 1);
*/
if (fixedGop->isChecked()) {
if (fixedGop->isEnabled() && fixedGop->isChecked()) {
params.append(QStringLiteral("sc_threshold=0 strict_gop=1"));
}
} else if (vcodec.endsWith("_amf")) {
......@@ -571,7 +595,7 @@ void RenderPresetDialog::slotUpdateParams() {
/*if (ui->dualPassCheckbox->isChecked())
setIfNotSet(p, "v2pass", 1);
*/
if (fixedGop->isChecked()) {
if (fixedGop->isEnabled() && fixedGop->isChecked()) {
params.append(QStringLiteral("sc_threshold=0 strict_gop=1"));
}
} else {
......@@ -618,7 +642,7 @@ void RenderPresetDialog::slotUpdateParams() {
break;
}
}
if (fixedGop->isChecked()) {
if (fixedGop->isEnabled() && fixedGop->isChecked()) {
if (vcodec.startsWith("libvpx") || vcodec.startsWith("libaom-")) {
params.append(QStringLiteral("keyint_min=%1").arg(gopSpinner->value()));
} else {
......@@ -633,8 +657,12 @@ void RenderPresetDialog::slotUpdateParams() {
setIfNotSet(p, "connection_type", "x11");
}*/
}
params.append(QStringLiteral("g=%1").arg(gopSpinner->value()));
params.append(QStringLiteral("bf=%1").arg(bFramesSpinner->value()));
if (gopSpinner->value() > 0) {
params.append(QStringLiteral("g=%1").arg(gopSpinner->value()));
if (bFramesSpinner->value() >= 0) {
params.append(QStringLiteral("bf=%1").arg(bFramesSpinner->value()));
}
}
// audio tab
QString acodec = aCodecCombo->currentText();
......
......@@ -485,6 +485,7 @@ QString RenderPresetModel::warning() const
int RenderPresetModel::estimateFileSize(int length)
{
Q_UNUSED(length)
// TODO
/*RateControl vrc = videoRateControl();
if (vrc == Average || vrc == Constant) {
......
......@@ -326,7 +326,7 @@
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_25">
<widget class="QLabel" name="fieldOrderLabel">
<property name="text">
<string>Field Order:</string>
</property>
......@@ -350,7 +350,7 @@
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="colorspaceLabel">
<property name="enabled">
<bool>false</bool>
</property>
......@@ -360,17 +360,31 @@
</widget>
</item>
<item row="7" column="1">
<widget class="QComboBox" name="comboBox_3">
<widget class="QComboBox" name="colorspaceCombo">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QComboBox" name="vCodecCombo"/>
<widget class="QComboBox" name="vCodecCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QComboBox" name="vRateControlCombo"/>
<widget class="QComboBox" name="vRateControlCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_24">
......@@ -421,7 +435,7 @@
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_21">
<widget class="QLabel" name="vquality_label">
<property name="text">
<string>Quality:</string>
</property>
......@@ -445,7 +459,26 @@
</widget>
</item>
<item row="13" column="1">
<widget class="QSpinBox" name="gopSpinner">
<property name="specialValueText">
<string>Auto</string>
</property>
<property name="suffix">
<string> frame(s)</string>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QCheckBox" name="fixedGop">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>A fixed GOP means that keyframes will not be inserted at detected scene changes.</string>
</property>
......@@ -454,30 +487,35 @@
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QSpinBox" name="gopSpinner">
<item row="15" column="1">
<widget class="QSpinBox" name="bFramesSpinner">
<property name="enabled">
<bool>false</bool>
</property>
<property name="specialValueText">
<string>Auto</string>
</property>
<property name="suffix">
<string> frame(s)</string>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>999</number>
<number>8</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_27">
<widget class="QLabel" name="bFramesLabel">
<property name="text">
<string>B Frames:</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QSpinBox" name="bFramesSpinner">
<property name="maximum">
<number>8</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
......@@ -691,6 +729,12 @@
</item>
<item row="0" column="1">
<widget class="QComboBox" name="groupName">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment