Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
9905e26c
Commit
9905e26c
authored
Mar 22, 2022
by
Julius Künzel
Browse files
[Render Presets] Combo Box for PAR to prevent render errors
parent
0d38cbf2
Pipeline
#153552
passed with stage
in 5 minutes and 27 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/dialogs/renderpresetdialog.cpp
View file @
9905e26c
...
...
@@ -15,10 +15,23 @@
#include <KMessageBox>
#include <QPushButton>
// TODO replace this by std::gcd ones why require C++17 or greater
static
int
gcd
(
int
a
,
int
b
)
{
for
(;;)
{
if
(
a
==
0
)
return
b
;
b
%=
a
;
if
(
b
==
0
)
return
a
;
a
%=
b
;
}
}
RenderPresetDialog
::
RenderPresetDialog
(
QWidget
*
parent
,
RenderPresetModel
*
preset
,
Mode
mode
)
:
QDialog
(
parent
)
,
m_saveName
()
,
m_monitor
(
nullptr
)
,
m_fixedResRatio
(
1.
)
{
setupUi
(
this
);
...
...
@@ -80,6 +93,26 @@ RenderPresetDialog::RenderPresetDialog(QWidget *parent, RenderPresetModel *prese
QValidator
*
validator
=
new
QIntValidator
(
this
);
audioSampleRate
->
setValidator
(
validator
);
// Add some common pixel aspect ratios:
// The following code works, because setting a yet
// unknown ratio will add it to the combo box.
setPixelAspectRatio
(
1
,
1
);
setPixelAspectRatio
(
10
,
11
);
setPixelAspectRatio
(
12
,
11
);
setPixelAspectRatio
(
59
,
54
);
setPixelAspectRatio
(
4
,
3
);
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"
));
...
...
@@ -119,6 +152,8 @@ RenderPresetDialog::RenderPresetDialog(QWidget *parent, RenderPresetModel *prese
groupName
->
addItems
(
RenderPresetRepository
::
get
()
->
groupNames
());
std
::
unique_ptr
<
ProfileModel
>
&
projectProfile
=
pCore
->
getCurrentProfile
();
int
parNum
=
projectProfile
->
sample_aspect_num
();
int
parDen
=
projectProfile
->
sample_aspect_den
();
if
(
preset
)
{
groupName
->
setCurrentText
(
preset
->
groupName
());
if
(
mode
!=
Mode
::
New
)
{
...
...
@@ -179,17 +214,14 @@ RenderPresetDialog::RenderPresetDialog(QWidget *parent, RenderPresetModel *prese
QString
sampAsp
=
preset
->
getParam
(
QStringLiteral
(
"aspect"
));
if
(
!
(
sampAspNum
.
isEmpty
()
&&
sampAspDen
.
isEmpty
()))
{
p
ixelAspectNum
->
setValue
(
sampAspNum
.
toInt
()
)
;
p
ixelAspectDen
->
setValue
(
sampAspDen
.
toInt
()
)
;
p
arNum
=
sampAspNum
.
toInt
();
p
arDen
=
sampAspDen
.
toInt
();
}
else
if
(
!
sampAsp
.
isEmpty
())
{
QStringList
list
=
sampAsp
.
split
(
QStringLiteral
(
"/"
));
if
(
list
.
count
()
==
2
)
{
p
ixelAspectNum
->
setValue
(
list
.
at
(
0
).
toInt
()
)
;
p
ixelAspectDen
->
setValue
(
list
.
at
(
1
).
toInt
()
)
;
p
arNum
=
list
.
at
(
0
).
toInt
();
p
arDen
=
list
.
at
(
1
).
toInt
();
}
}
else
{
pixelAspectNum
->
setValue
(
projectProfile
->
sample_aspect_num
());
pixelAspectDen
->
setValue
(
projectProfile
->
sample_aspect_den
());
}
if
(
preset
->
hasParam
(
QStringLiteral
(
"display_aspect_num"
))
...
...
@@ -272,13 +304,15 @@ RenderPresetDialog::RenderPresetDialog(QWidget *parent, RenderPresetModel *prese
resWidth
->
setValue
(
projectProfile
->
width
());
framerateNum
->
setValue
(
projectProfile
->
frame_rate_num
());
framerateDen
->
setValue
(
projectProfile
->
frame_rate_den
());
p
ixelAspectNum
->
setValue
(
projectProfile
->
sample_aspect_num
()
)
;
p
ixelAspectDen
->
setValue
(
projectProfile
->
sample_aspect_den
()
)
;
p
arNum
=
projectProfile
->
sample_aspect_num
();
p
arDen
=
projectProfile
->
sample_aspect_den
();
displayAspectNum
->
setValue
(
projectProfile
->
display_aspect_num
());
displayAspectDen
->
setValue
(
projectProfile
->
display_aspect_den
());
scanningCombo
->
setCurrentIndex
(
projectProfile
->
progressive
()
?
1
:
0
);
}
setPixelAspectRatio
(
parNum
,
parDen
);
if
(
groupName
->
currentText
().
isEmpty
())
{
groupName
->
setCurrentText
(
i18nc
(
"Group Name"
,
"Custom"
));
}
...
...
@@ -328,26 +362,34 @@ RenderPresetDialog::RenderPresetDialog(QWidget *parent, RenderPresetModel *prese
connect
(
fieldOrderCombo
,
&
QComboBox
::
currentTextChanged
,
this
,
&
RenderPresetDialog
::
slotUpdateParams
);
connect
(
aCodecCombo
,
&
QComboBox
::
currentTextChanged
,
this
,
&
RenderPresetDialog
::
slotUpdateParams
);
connect
(
resWidth
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
&
RenderPresetDialog
::
slotUpdateParams
);
connect
(
resHeight
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
&
RenderPresetDialog
::
slotUpdateParams
);
connect
(
pixelAspectNum
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
[
&
](
int
value
){
if
(
value
==
0
)
{
pixelAspectDen
->
blockSignals
(
true
);
pixelAspectDen
->
setValue
(
0
);
pixelAspectDen
->
blockSignals
(
false
);
connect
(
linkResoultion
,
&
QToolButton
::
clicked
,
this
,
[
&
](){
m_fixedResRatio
=
double
(
resWidth
->
value
())
/
double
(
resHeight
->
value
());
});
connect
(
resWidth
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
[
&
](
int
value
){
if
(
linkResoultion
->
isChecked
())
{
resHeight
->
blockSignals
(
true
);
resHeight
->
setValue
(
qRound
(
value
/
m_fixedResRatio
));
resHeight
->
blockSignals
(
false
);
}
slotUpdateParams
();
updateDisplayAspectRatio
();
});
connect
(
pixelAspectDen
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
[
&
](
int
value
){
if
(
value
==
0
)
{
pixelAspectNum
->
blockSignals
(
true
);
pixelAspectNum
->
setValue
(
0
);
pixelAspectNum
->
blockSignals
(
false
);
connect
(
resHeight
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
[
&
](
int
value
){
if
(
linkResoultion
->
isChecked
()
)
{
resWidth
->
blockSignals
(
true
);
resWidth
->
setValue
(
qRound
(
value
*
m_fixedResRatio
)
);
resWidth
->
blockSignals
(
false
);
}
slotUpdateParams
();
updateDisplayAspectRatio
();
});
connect
(
displayAspectNum
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
&
RenderPresetDialog
::
slotUpdateParams
);
connect
(
displayAspectDen
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
&
RenderPresetDialog
::
slotUpdateParams
);
connect
(
parCombo
,
static_cast
<
void
(
QComboBox
::*
)(
int
)
>
(
&
QComboBox
::
currentIndexChanged
),
this
,
&
RenderPresetDialog
::
updateDisplayAspectRatio
);
auto
update_par
=
[
&
]()
{
int
parNum
=
displayAspectNum
->
value
()
*
resHeight
->
value
();
int
parDen
=
displayAspectDen
->
value
()
*
resWidth
->
value
();
setPixelAspectRatio
(
parNum
,
parDen
);
slotUpdateParams
();
};
connect
(
displayAspectNum
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
update_par
);
connect
(
displayAspectDen
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
update_par
);
connect
(
framerateNum
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
[
&
](
int
value
){
if
(
value
==
0
)
{
framerateDen
->
blockSignals
(
true
);
...
...
@@ -375,6 +417,7 @@ RenderPresetDialog::RenderPresetDialog(QWidget *parent, RenderPresetModel *prese
connect
(
audioChannels
,
&
QComboBox
::
currentTextChanged
,
this
,
&
RenderPresetDialog
::
slotUpdateParams
);
connect
(
audioSampleRate
,
&
QComboBox
::
currentTextChanged
,
this
,
&
RenderPresetDialog
::
slotUpdateParams
);
linkResoultion
->
setChecked
(
true
);
slotUpdateParams
();
// TODO
if
(
false
&&
m_monitor
==
nullptr
)
{
...
...
@@ -411,10 +454,11 @@ void RenderPresetDialog::slotUpdateParams() {
if
(
resHeight
->
value
()
>
0
)
{
params
.
append
(
QStringLiteral
(
"height=%1"
).
arg
(
resHeight
->
value
()));
}
if
(
pixelAspectNum
->
value
()
>
0
&&
pixelAspectDen
->
value
()
>
0
)
{
QStringList
par
=
parCombo
->
currentData
().
toString
().
split
(
QStringLiteral
(
":"
));
if
(
par
.
length
()
>=
2
&&
par
.
at
(
0
).
toInt
()
>
0
&&
par
.
at
(
1
).
toInt
()
>
0
)
{
params
.
append
(
QStringLiteral
(
"sample_aspect_num=%1 sample_aspect_den=%2"
)
.
arg
(
p
ixelAspectNum
->
value
())
.
arg
(
p
ixelAspectDen
->
value
()));
.
arg
(
p
ar
.
at
(
0
).
toInt
())
.
arg
(
p
ar
.
at
(
1
).
toInt
()));
}
if
(
displayAspectNum
->
value
()
>
0
&&
displayAspectDen
->
value
()
>
0
)
{
params
.
append
(
QStringLiteral
(
"display_aspect_num=%1 display_aspect_den=%2"
)
...
...
@@ -643,7 +687,7 @@ void RenderPresetDialog::slotUpdateParams() {
QString
addionalParams
=
additionalParams
->
toPlainText
().
simplified
();
QStringList
removed
;
for
(
auto
p
:
m_uiParams
)
{
for
(
const
auto
&
p
:
qAsConst
(
m_uiParams
)
)
{
QString
store
=
addionalParams
;
if
(
store
!=
addionalParams
.
remove
(
QRegularExpression
(
QStringLiteral
(
"((^|
\\
s)%1=
\\
S*)"
).
arg
(
p
))))
{
removed
.
append
(
p
);
...
...
@@ -660,6 +704,42 @@ void RenderPresetDialog::slotUpdateParams() {
parameters
->
setText
(
addionalParams
.
simplified
());
}
void
RenderPresetDialog
::
setPixelAspectRatio
(
int
num
,
int
den
)
{
parCombo
->
blockSignals
(
true
);
if
(
num
<
1
)
num
=
1
;
if
(
den
<
1
)
den
=
1
;
int
gcdV
=
gcd
(
num
,
den
);
QString
data
=
QStringLiteral
(
"%1:%2"
).
arg
(
num
/
gcdV
).
arg
(
den
/
gcdV
);
int
ix
=
parCombo
->
findData
(
data
);
if
(
ix
<
0
)
{
parCombo
->
addItem
(
QStringLiteral
(
"%L1 (%2:%3)"
)
.
arg
(
double
(
num
)
/
double
(
den
),
0
,
'g'
,
8
)
.
arg
(
num
/
gcdV
).
arg
(
den
/
gcdV
),
data
);
ix
=
parCombo
->
count
()
-
1
;
}
parCombo
->
setCurrentIndex
(
ix
);
parCombo
->
blockSignals
(
false
);
}
void
RenderPresetDialog
::
updateDisplayAspectRatio
()
{
displayAspectNum
->
blockSignals
(
true
);
displayAspectDen
->
blockSignals
(
true
);
QStringList
par
=
parCombo
->
currentData
().
toString
().
split
(
QStringLiteral
(
":"
));
int
parNum
=
resWidth
->
value
();
int
parDen
=
resHeight
->
value
();
if
(
par
.
length
()
>=
2
&&
par
.
at
(
0
).
toInt
()
>
0
&&
par
.
at
(
1
).
toInt
()
>
0
)
{
parNum
*=
par
.
at
(
0
).
toInt
();
parDen
*=
par
.
at
(
1
).
toInt
();
}
int
gcdV
=
gcd
(
parNum
,
parDen
);
displayAspectNum
->
setValue
(
parNum
/
gcdV
);
displayAspectDen
->
setValue
(
parDen
/
gcdV
);
displayAspectNum
->
blockSignals
(
false
);
displayAspectDen
->
blockSignals
(
false
);
slotUpdateParams
();
};
QString
RenderPresetDialog
::
saveName
()
{
return
m_saveName
;
...
...
src/dialogs/renderpresetdialog.h
View file @
9905e26c
...
...
@@ -30,6 +30,10 @@ private:
QString
m_saveName
;
QStringList
m_uiParams
;
Monitor
*
m_monitor
;
double
m_fixedResRatio
;
void
setPixelAspectRatio
(
int
num
,
int
den
);
void
updateDisplayAspectRatio
();
private
slots
:
void
slotUpdateParams
();
...
...
src/ui/editrenderpreset_ui.ui
View file @
9905e26c
...
...
@@ -6,7 +6,7 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
46
1
</width>
<width>
46
3
</width>
<height>
630
</height>
</rect>
</property>
...
...
@@ -155,10 +155,7 @@
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"toolButton"
>
<property
name=
"enabled"
>
<bool>
false
</bool>
</property>
<widget
class=
"QToolButton"
name=
"linkResoultion"
>
<property
name=
"text"
>
<string>
...
</string>
</property>
...
...
@@ -169,6 +166,9 @@
<property
name=
"checkable"
>
<bool>
true
</bool>
</property>
<property
name=
"autoRaise"
>
<bool>
true
</bool>
</property>
</widget>
</item>
</layout>
...
...
@@ -181,44 +181,11 @@
</widget>
</item>
<item
row=
"1"
column=
"1"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<item>
<widget
class=
"QSpinBox"
name=
"pixelAspectNum"
>
<property
name=
"minimum"
>
<number>
1
</number>
</property>
<property
name=
"maximum"
>
<number>
8192
</number>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"label_10"
>
<property
name=
"minimumSize"
>
<size>
<width>
10
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"text"
>
<string
notr=
"true"
>
:
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignCenter
</set>
</property>
</widget>
</item>
<item>
<widget
class=
"QSpinBox"
name=
"pixelAspectDen"
>
<property
name=
"minimum"
>
<number>
1
</number>
</property>
<property
name=
"maximum"
>
<number>
8192
</number>
</property>
</widget>
</item>
</layout>
<widget
class=
"QComboBox"
name=
"parCombo"
>
<property
name=
"sizeAdjustPolicy"
>
<enum>
QComboBox::AdjustToContents
</enum>
</property>
</widget>
</item>
<item
row=
"2"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_16"
>
...
...
@@ -267,13 +234,6 @@
</item>
</layout>
</item>
<item
row=
"3"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
Frame Rate:
</string>
</property>
</widget>
</item>
<item
row=
"3"
column=
"1"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
...
...
@@ -320,6 +280,30 @@
</item>
</layout>
</item>
<item
row=
"3"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
Frame Rate:
</string>
</property>
</widget>
</item>
<item
row=
"4"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_22"
>
<property
name=
"text"
>
<string>
Fields per Second:
</string>
</property>
</widget>
</item>
<item
row=
"4"
column=
"1"
>
<widget
class=
"QLabel"
name=
"frameRateDisplay"
>
<property
name=
"enabled"
>
<bool>
true
</bool>
</property>
<property
name=
"text"
>
<string>
Placeholder
</string>
</property>
</widget>
</item>
<item
row=
"5"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_7"
>
<property
name=
"text"
>
...
...
@@ -382,6 +366,12 @@
</property>
</widget>
</item>
<item
row=
"8"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"vCodecCombo"
/>
</item>
<item
row=
"9"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"vRateControlCombo"
/>
</item>
<item
row=
"8"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_24"
>
<property
name=
"text"
>
...
...
@@ -389,9 +379,6 @@
</property>
</widget>
</item>
<item
row=
"8"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"vCodecCombo"
/>
</item>
<item
row=
"9"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_12"
>
<property
name=
"text"
>
...
...
@@ -399,9 +386,6 @@
</property>
</widget>
</item>
<item
row=
"9"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"vRateControlCombo"
/>
</item>
<item
row=
"10"
column=
"0"
>
<widget
class=
"QLabel"
name=
"default_vbitrate_label"
>
<property
name=
"text"
>
...
...
@@ -450,23 +434,23 @@
</property>
</widget>
</item>
<item
row=
"13"
column=
"
1
"
>
<widget
class=
"Q
CheckBox"
name=
"fixedGop
"
>
<item
row=
"13"
column=
"
0
"
>
<widget
class=
"Q
Label"
name=
"label_26
"
>
<property
name=
"toolTip"
>
<string>
A fixed GOP means that keyframes will not be inserted at detected scene chang
es
.
</string>
<string>
GOP = Group of Pictur
es
</string>
</property>
<property
name=
"text"
>
<string>
Fixed
</string>
<string>
GOP:
</string>
</property>
</widget>
</item>
<item
row=
"13"
column=
"
0
"
>
<widget
class=
"Q
Label"
name=
"label_26
"
>
<item
row=
"13"
column=
"
1
"
>
<widget
class=
"Q
CheckBox"
name=
"fixedGop
"
>
<property
name=
"toolTip"
>
<string>
GOP = Group of Pictures
</string>
<string>
A fixed GOP means that keyframes will not be inserted at detected scene changes.
</string>
</property>
<property
name=
"text"
>
<string>
GOP:
</string>
<string>
Fixed
</string>
</property>
</widget>
</item>
...
...
@@ -494,23 +478,6 @@
</property>
</widget>
</item>
<item
row=
"4"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_22"
>
<property
name=
"text"
>
<string>
Fields per Second:
</string>
</property>
</widget>
</item>
<item
row=
"4"
column=
"1"
>
<widget
class=
"QLabel"
name=
"frameRateDisplay"
>
<property
name=
"enabled"
>
<bool>
true
</bool>
</property>
<property
name=
"text"
>
<string>
Placeholder
</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
...
...
@@ -681,15 +648,12 @@
</item>
<item>
<widget
class=
"KMessageWidget"
name=
"overrideParamsWarning"
>
<property
name=
"wordWrap"
>
<property
name=
"wordWrap"
stdset=
"0"
>
<bool>
true
</bool>
</property>
<property
name=
"closeButtonVisible"
>
<property
name=
"closeButtonVisible"
stdset=
"0"
>
<bool>
false
</bool>
</property>
<property
name=
"messageType"
>
<enum>
KMessageWidget::Warning
</enum>
</property>
</widget>
</item>
<item>
...
...
@@ -756,6 +720,7 @@
<class>
KMessageWidget
</class>
<extends>
QFrame
</extends>
<header>
kmessagewidget.h
</header>
<container>
1
</container>
</customwidget>
</customwidgets>
<resources/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment