Skip to content

Commit 9911248

Browse files
committed
Add processing modes
Remove the previous GPU Effects option and replace it with multiple processing modes that enable higher bit depth and linear color processing.
1 parent 7b35b08 commit 9911248

File tree

11 files changed

+277
-90
lines changed

11 files changed

+277
-90
lines changed

src/docks/encodedock.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,15 @@ QPoint EncodeDock::addConsumerElement(
12171217
consumerNode.setAttribute("strict", "experimental");
12181218
if (!ui->disableSubtitlesCheckbox->isChecked())
12191219
setSubtitleProperties(consumerNode, service);
1220-
1220+
ShotcutSettings::ProcessingMode processingMode = Settings.processingMode();
1221+
if (processingMode == ShotcutSettings::Native10Cpu
1222+
|| processingMode == ShotcutSettings::Linear10Cpu) {
1223+
consumerNode.setAttribute("mlt_image_format", "rgba64");
1224+
}
1225+
if (processingMode == ShotcutSettings::Linear8Cpu
1226+
|| processingMode == ShotcutSettings::Linear10Cpu) {
1227+
consumerNode.setAttribute("mlt_color_trc", "linear");
1228+
}
12211229
return QPoint(consumerNode.hasAttribute("frame_rate_num")
12221230
? consumerNode.attribute("frame_rate_num").toInt()
12231231
: MLT.profile().frame_rate_num(),

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class Application : public QApplication
237237
ShotcutSettings::setAppDataForSession(appDirArg);
238238
}
239239
if (parser.isSet(gpuOption))
240-
Settings.setPlayerGPU(true);
240+
Settings.setProcessingMode(ShotcutSettings::Native10GpuCpu);
241241
if (!parser.positionalArguments().isEmpty())
242242
resourceArg = parser.positionalArguments();
243243

src/mainwindow.cpp

Lines changed: 117 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,74 @@ MainWindow::~MainWindow()
10411041
void MainWindow::setupSettingsMenu()
10421042
{
10431043
LOG_DEBUG() << "begin";
1044+
10441045
QActionGroup *group = new QActionGroup(this);
1046+
ui->actionNative8bitCpu->setData(ShotcutSettings::Native8Cpu);
1047+
ui->actionLinear8bitCpu->setData(ShotcutSettings::Linear8Cpu);
1048+
ui->actionNative10bitCpu->setData(ShotcutSettings::Native10Cpu);
1049+
ui->actionLinear10bitCpu->setData(ShotcutSettings::Linear10Cpu);
1050+
ui->actionNative10bitGpuCpu->setData(ShotcutSettings::Native10GpuCpu);
1051+
group->addAction(ui->actionNative8bitCpu);
1052+
group->addAction(ui->actionLinear8bitCpu);
1053+
group->addAction(ui->actionNative10bitCpu);
1054+
group->addAction(ui->actionLinear10bitCpu);
1055+
group->addAction(ui->actionNative10bitGpuCpu);
1056+
for (auto a : group->actions()) {
1057+
ShotcutSettings::ProcessingMode mode = (ShotcutSettings::ProcessingMode) a->data().toInt();
1058+
if (Settings.processingMode() == mode) {
1059+
a->setChecked(true);
1060+
setProcessingMode(mode);
1061+
break;
1062+
}
1063+
}
1064+
connect(group, &QActionGroup::triggered, this, [&](QAction *action) {
1065+
ShotcutSettings::ProcessingMode oldMode = Settings.processingMode();
1066+
ShotcutSettings::ProcessingMode newMode
1067+
= (ShotcutSettings::ProcessingMode) action->data().toInt();
1068+
if (oldMode == newMode)
1069+
return;
1070+
LOG_INFO() << "Processing Mode" << oldMode << "->" << newMode;
1071+
if (newMode == ShotcutSettings::Native10GpuCpu) {
1072+
QMessageBox dialog(QMessageBox::Warning,
1073+
qApp->applicationName(),
1074+
tr("GPU is experimental and does not work on all computers. "
1075+
"Plan to do some testing after turning this on.\n"
1076+
"At this time, a project created with GPU processing cannot be "
1077+
"converted to a CPU-only project later.\n"
1078+
"Do you want to enable GPU processing and restart Shotcut?"),
1079+
QMessageBox::No | QMessageBox::Yes,
1080+
this);
1081+
dialog.setDefaultButton(QMessageBox::Yes);
1082+
dialog.setEscapeButton(QMessageBox::No);
1083+
dialog.setWindowModality(QmlApplication::dialogModality());
1084+
dialog.adjustSize();
1085+
if (dialog.exec() == QMessageBox::Yes) {
1086+
Settings.setProcessingMode(newMode);
1087+
m_exitCode = EXIT_RESTART;
1088+
QApplication::closeAllWindows();
1089+
}
1090+
} else if (oldMode == ShotcutSettings::Native10GpuCpu) {
1091+
QMessageBox dialog(QMessageBox::Information,
1092+
qApp->applicationName(),
1093+
tr("Shotcut must restart to disable GPU processing mode.\n"
1094+
"Disable GPU processing and restart?"),
1095+
QMessageBox::No | QMessageBox::Yes,
1096+
this);
1097+
dialog.setDefaultButton(QMessageBox::Yes);
1098+
dialog.setEscapeButton(QMessageBox::No);
1099+
dialog.setWindowModality(QmlApplication::dialogModality());
1100+
dialog.adjustSize();
1101+
if (dialog.exec() == QMessageBox::Yes) {
1102+
Settings.setProcessingMode(newMode);
1103+
m_exitCode = EXIT_RESTART;
1104+
QApplication::closeAllWindows();
1105+
}
1106+
} else {
1107+
setProcessingMode((ShotcutSettings::ProcessingMode) action->data().toInt());
1108+
}
1109+
});
1110+
1111+
group = new QActionGroup(this);
10451112
group->addAction(ui->actionChannels1);
10461113
group->addAction(ui->actionChannels2);
10471114
group->addAction(ui->actionChannels4);
@@ -1617,12 +1684,12 @@ bool MainWindow::isCompatibleWithGpuMode(MltXmlChecker &checker)
16171684
{
16181685
if (checker.needsGPU() && !Settings.playerGPU()) {
16191686
LOG_INFO() << "file uses GPU but GPU not enabled";
1620-
QMessageBox
1621-
dialog(QMessageBox::Warning,
1622-
qApp->applicationName(),
1623-
tr("The file you opened uses GPU effects, but GPU effects are not enabled."),
1624-
QMessageBox::Ok,
1625-
this);
1687+
QMessageBox dialog(
1688+
QMessageBox::Warning,
1689+
qApp->applicationName(),
1690+
tr("The file you opened uses GPU processing, but GPU processing mode is not enabled."),
1691+
QMessageBox::Ok,
1692+
this);
16261693
dialog.setWindowModality(QmlApplication::dialogModality());
16271694
dialog.setDefaultButton(QMessageBox::Ok);
16281695
dialog.setEscapeButton(QMessageBox::Ok);
@@ -1633,16 +1700,16 @@ bool MainWindow::isCompatibleWithGpuMode(MltXmlChecker &checker)
16331700
QMessageBox dialog(QMessageBox::Question,
16341701
qApp->applicationName(),
16351702
tr("The file you opened uses CPU effects that are incompatible with GPU "
1636-
"effects, but GPU effects are enabled.\n"
1637-
"Do you want to disable GPU effects and restart?"),
1703+
"effects, but GPU mode is enabled.\n"
1704+
"Do you want to disable GPU processing mode and restart?"),
16381705
QMessageBox::No | QMessageBox::Yes,
16391706
this);
16401707
dialog.setWindowModality(QmlApplication::dialogModality());
16411708
dialog.setDefaultButton(QMessageBox::Yes);
16421709
dialog.setEscapeButton(QMessageBox::No);
16431710
int r = dialog.exec();
16441711
if (r == QMessageBox::Yes) {
1645-
ui->actionGPU->setChecked(false);
1712+
Settings.setProcessingMode(ShotcutSettings::Native8Cpu);
16461713
m_exitCode = EXIT_RESTART;
16471714
QApplication::closeAllWindows();
16481715
}
@@ -1847,6 +1914,33 @@ void MainWindow::setAudioChannels(int channels)
18471914
emit audioChannelsChanged();
18481915
}
18491916

1917+
void MainWindow::setProcessingMode(ShotcutSettings::ProcessingMode mode)
1918+
{
1919+
LOG_DEBUG() << mode;
1920+
if (mode != Settings.processingMode()) {
1921+
Settings.setProcessingMode(mode);
1922+
}
1923+
switch (mode) {
1924+
case ShotcutSettings::Native8Cpu:
1925+
ui->actionNative8bitCpu->setChecked(true);
1926+
break;
1927+
case ShotcutSettings::Linear8Cpu:
1928+
ui->actionLinear8bitCpu->setChecked(true);
1929+
break;
1930+
case ShotcutSettings::Native10Cpu:
1931+
ui->actionNative10bitCpu->setChecked(true);
1932+
break;
1933+
case ShotcutSettings::Linear10Cpu:
1934+
ui->actionLinear10bitCpu->setChecked(true);
1935+
break;
1936+
case ShotcutSettings::Native10GpuCpu:
1937+
ui->actionNative10bitGpuCpu->setChecked(true);
1938+
break;
1939+
}
1940+
MLT.videoWidget()->setProperty("processing_mode", mode);
1941+
MLT.setProcessingMode(mode);
1942+
}
1943+
18501944
void MainWindow::showSaveError()
18511945
{
18521946
QMessageBox dialog(QMessageBox::Critical,
@@ -2093,6 +2187,7 @@ bool MainWindow::open(QString url, const Mlt::Properties *properties, bool play,
20932187
m_player->setPauseAfterOpen(!play || !MLT.isClip());
20942188

20952189
setAudioChannels(MLT.audioChannels());
2190+
setProcessingMode(MLT.processingMode());
20962191
if (url.endsWith(".mlt") || url.endsWith(".xml")) {
20972192
if (MLT.producer()->get_int(kShotcutProjectFolder)) {
20982193
MLT.setProjectFolder(info.absolutePath());
@@ -2297,8 +2392,6 @@ void MainWindow::readPlayerSettings()
22972392
ui->actionScrubAudio->setChecked(Settings.playerScrubAudio());
22982393
if (ui->actionJack)
22992394
ui->actionJack->setChecked(Settings.playerJACK());
2300-
if (ui->actionGPU)
2301-
ui->actionGPU->setChecked(Settings.playerGPU());
23022395

23032396
QString external = Settings.playerExternal();
23042397
bool ok = false;
@@ -2571,7 +2664,6 @@ void MainWindow::writeSettings()
25712664
if (isFullScreen())
25722665
showNormal();
25732666
#endif
2574-
Settings.setPlayerGPU(ui->actionGPU->isChecked());
25752667
Settings.setWindowGeometry(saveGeometry());
25762668
Settings.setWindowState(saveState());
25772669
Settings.sync();
@@ -4009,11 +4101,11 @@ void MainWindow::on_actionEnterFullScreen_triggered()
40094101

40104102
void MainWindow::onGpuNotSupported()
40114103
{
4012-
Settings.setPlayerGPU(false);
4013-
if (ui->actionGPU) {
4014-
ui->actionGPU->setChecked(false);
4015-
ui->actionGPU->setDisabled(true);
4104+
if (Settings.processingMode() == ShotcutSettings::Native10GpuCpu) {
4105+
Settings.setProcessingMode(ShotcutSettings::Native8Cpu);
40164106
}
4107+
ui->actionNative10bitGpuCpu->setChecked(false);
4108+
ui->actionNative10bitGpuCpu->setDisabled(true);
40174109
LOG_WARNING() << "";
40184110
QMessageBox::critical(this, qApp->applicationName(), tr("GPU effects are not supported"));
40194111
}
@@ -4256,48 +4348,6 @@ void MainWindow::on_actionJack_triggered(bool checked)
42564348
}
42574349
}
42584350

4259-
void MainWindow::on_actionGPU_triggered(bool checked)
4260-
{
4261-
if (checked) {
4262-
QMessageBox dialog(QMessageBox::Warning,
4263-
qApp->applicationName(),
4264-
tr("GPU effects are experimental and do not work good on all computers. "
4265-
"Plan to do some testing after turning this on.\n"
4266-
"At this time, a project created with GPU effects cannot be "
4267-
"converted to a CPU-only project later."
4268-
"\n\n"
4269-
"Do you want to enable GPU effects and restart Shotcut?"),
4270-
QMessageBox::No | QMessageBox::Yes,
4271-
this);
4272-
dialog.setDefaultButton(QMessageBox::Yes);
4273-
dialog.setEscapeButton(QMessageBox::No);
4274-
dialog.setWindowModality(QmlApplication::dialogModality());
4275-
if (dialog.exec() == QMessageBox::Yes) {
4276-
m_exitCode = EXIT_RESTART;
4277-
QApplication::closeAllWindows();
4278-
} else {
4279-
ui->actionGPU->setChecked(false);
4280-
}
4281-
} else {
4282-
QMessageBox dialog(QMessageBox::Information,
4283-
qApp->applicationName(),
4284-
tr("Shotcut must restart to disable GPU effects."
4285-
"\n\n"
4286-
"Disable GPU effects and restart?"),
4287-
QMessageBox::No | QMessageBox::Yes,
4288-
this);
4289-
dialog.setDefaultButton(QMessageBox::Yes);
4290-
dialog.setEscapeButton(QMessageBox::No);
4291-
dialog.setWindowModality(QmlApplication::dialogModality());
4292-
if (dialog.exec() == QMessageBox::Yes) {
4293-
m_exitCode = EXIT_RESTART;
4294-
QApplication::closeAllWindows();
4295-
} else {
4296-
ui->actionGPU->setChecked(true);
4297-
}
4298-
}
4299-
}
4300-
43014351
void MainWindow::onExternalTriggered(QAction *action)
43024352
{
43034353
LOG_DEBUG() << action->data().toString();
@@ -5577,25 +5627,22 @@ void MainWindow::on_actionClearRecentOnExit_toggled(bool arg1)
55775627
void MainWindow::onSceneGraphInitialized()
55785628
{
55795629
if (Settings.playerGPU() && Settings.playerWarnGPU()) {
5580-
QMessageBox dialog(QMessageBox::Warning,
5581-
qApp->applicationName(),
5582-
tr("GPU effects are EXPERIMENTAL, UNSTABLE and UNSUPPORTED! Unsupported "
5583-
"means do not report bugs about it.\n\n"
5584-
"Do you want to disable GPU effects and restart Shotcut?"),
5585-
QMessageBox::No | QMessageBox::Yes,
5586-
this);
5630+
QMessageBox
5631+
dialog(QMessageBox::Warning,
5632+
qApp->applicationName(),
5633+
tr("GPU processing is EXPERIMENTAL, UNSTABLE and UNSUPPORTED! Unsupported "
5634+
"means do not report bugs about it.\n\n"
5635+
"Do you want to disable GPU processing and restart Shotcut?"),
5636+
QMessageBox::No | QMessageBox::Yes,
5637+
this);
55875638
dialog.setDefaultButton(QMessageBox::Yes);
55885639
dialog.setEscapeButton(QMessageBox::No);
55895640
dialog.setWindowModality(QmlApplication::dialogModality());
55905641
if (dialog.exec() == QMessageBox::Yes) {
5591-
ui->actionGPU->setChecked(false);
5642+
Settings.setProcessingMode(ShotcutSettings::Native8Cpu);
55925643
m_exitCode = EXIT_RESTART;
55935644
QApplication::closeAllWindows();
5594-
} else {
5595-
ui->actionGPU->setVisible(true);
55965645
}
5597-
} else {
5598-
ui->actionGPU->setVisible(true);
55995646
}
56005647
auto videoWidget = (Mlt::VideoWidget *) &(MLT);
56015648
videoWidget->setBlankScene();

src/mainwindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class MainWindow : public QMainWindow
160160
bool checkAutoSave(QString &url);
161161
bool saveRepairedXmlFile(MltXmlChecker &checker, QString &fileName);
162162
void setAudioChannels(int channels);
163+
void setProcessingMode(ShotcutSettings::ProcessingMode mode);
163164
void showSaveError();
164165
void setPreviewScale(int scale);
165166
void setVideoModeMenu();
@@ -302,7 +303,6 @@ private slots:
302303
void on_actionBicubic_triggered(bool checked);
303304
void on_actionHyper_triggered(bool checked);
304305
void on_actionJack_triggered(bool checked);
305-
void on_actionGPU_triggered(bool checked);
306306
void onExternalTriggered(QAction *);
307307
void onDecklinkGammaTriggered(QAction *);
308308
void onKeyerTriggered(QAction *);

src/mainwindow.ui

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@
155155
</property>
156156
<addaction name="actionProfileAutomatic"/>
157157
</widget>
158+
<widget class="QMenu" name="menuProcessingMode">
159+
<property name="title">
160+
<string>Processing Mode</string>
161+
</property>
162+
<addaction name="actionNative8bitCpu"/>
163+
<addaction name="actionLinear8bitCpu"/>
164+
<addaction name="actionNative10bitCpu"/>
165+
<addaction name="actionLinear10bitCpu"/>
166+
<addaction name="actionNative10bitGpuCpu"/>
167+
</widget>
158168
<widget class="QMenu" name="menuLanguage">
159169
<property name="title">
160170
<string>Language</string>
@@ -287,8 +297,8 @@
287297
<addaction name="actionBackupWeekly"/>
288298
</widget>
289299
<addaction name="actionProject"/>
290-
<addaction name="actionGPU"/>
291300
<addaction name="menuProfile"/>
301+
<addaction name="menuProcessingMode"/>
292302
<addaction name="menuAudioChannels"/>
293303
<addaction name="menuBackup"/>
294304
<addaction name="actionUser_Interface"/>
@@ -580,18 +590,44 @@
580590
<string>Progressive</string>
581591
</property>
582592
</action>
583-
<action name="actionGPU">
593+
<action name="actionNative8bitCpu">
584594
<property name="checkable">
585595
<bool>true</bool>
586596
</property>
587597
<property name="text">
588-
<string>GPU Effects (unstable)</string>
598+
<string>Native 8-bit CPU</string>
589599
</property>
590-
<property name="toolTip">
591-
<string>Use GPU filters</string>
600+
</action>
601+
<action name="actionLinear8bitCpu">
602+
<property name="checkable">
603+
<bool>true</bool>
592604
</property>
593-
<property name="visible">
594-
<bool>false</bool>
605+
<property name="text">
606+
<string>Linear 8-bit CPU</string>
607+
</property>
608+
</action>
609+
<action name="actionNative10bitCpu">
610+
<property name="checkable">
611+
<bool>true</bool>
612+
</property>
613+
<property name="text">
614+
<string>Native 10-bit CPU</string>
615+
</property>
616+
</action>
617+
<action name="actionLinear10bitCpu">
618+
<property name="checkable">
619+
<bool>true</bool>
620+
</property>
621+
<property name="text">
622+
<string>Linear 10-bit CPU</string>
623+
</property>
624+
</action>
625+
<action name="actionNative10bitGpuCpu">
626+
<property name="checkable">
627+
<bool>true</bool>
628+
</property>
629+
<property name="text">
630+
<string>Native 10-bit GPU/CPU (Experimental)</string>
595631
</property>
596632
</action>
597633
<action name="actionChannels1">

0 commit comments

Comments
 (0)