Fix sop/sat parameters

Fix reset effect param to default value broken
parent 5274d608
Pipeline #9826 passed with stage
in 13 minutes and 44 seconds
......@@ -59,51 +59,51 @@
<name>SOP/Sat</name>
<description>Changes Slope, Offset, and Power of the color components, and the overall Saturation, according to the ASC CDL (Color Decision List).</description>
<author>Simon A. Eugster (Granjow)</author>
<parameter type="animated" name="rSlope" default="0.05" min="0" max="1000" factor="2000">
<parameter type="animated" name="rSlope" default="0.05" min="0" max="1000" factor="1000">
<name>Slope Red</name>
<comment><![CDATA[Changing the slope means multiplying the pixel value with a constant value. Black pixels will remain black, whileas brighter ones will be changed.<br/>
All effects can be observed well when applied on a greyscale gradient and looking at the RGB Parade monitor.]]></comment>
</parameter>
<parameter type="animated" name="gSlope" default="0.05" min="0" max="1000" factor="2000">
<parameter type="animated" name="gSlope" default="0.05" min="0" max="1000" factor="1000">
<name>Slope Green</name>
</parameter>
<parameter type="animated" name="bSlope" default="0.05" min="0" max="1000" factor="2000">
<parameter type="animated" name="bSlope" default="0.05" min="0" max="1000" factor="1000">
<name>Slope Blue</name>
</parameter>
<parameter type="animated" name="aSlope" default="0.05" min="0" max="1000" factor="2000">
<parameter type="animated" name="aSlope" default="0.05" min="0" max="1000" factor="1000">
<name>Slope Alpha</name>
</parameter>
<parameter type="animated" name="rOffset" default="0" min="-1024" max="1024" factor="2048" offset="-1024">
<parameter type="animated" name="rOffset" default="0.5" min="0" max="2048" factor="2048">
<name>Offset Red</name>
<comment>Changing the offset lifts (or lowers) the brightness of each pixel by the given value.</comment>
</parameter>
<parameter type="animated" name="gOffset" default="0" min="-1024" max="1024" factor="2048" offset="-1024">
<parameter type="animated" name="gOffset" default="0.5" min="0" max="2048" factor="2048">
<name>Offset Green</name>
</parameter>
<parameter type="animated" name="bOffset" default="0" min="-1024" max="1024" factor="2048" offset="-1024">
<parameter type="animated" name="bOffset" default="0.5" min="0" max="2048" factor="2048">
<name>Offset Blue</name>
</parameter>
<parameter type="animated" name="aOffset" default="0" min="-1024" max="1024" factor="2048" offset="-1024">
<parameter type="animated" name="aOffset" default="0.5" min="0" max="2048" factor="2048">
<name>Offset Alpha</name>
</parameter>
<parameter type="animated" name="rPower" default="0.05" min="1" max="1000" factor="2000">
<parameter type="animated" name="rPower" default="0.05" min="0" max="1000" factor="1000">
<name>Power Red</name>
<comment><![CDATA[Changes the Gamma value for the selected channel. Black and white pixel values will not be affected, but everything between.<br/>
Mathematically, what happens is an exponentiation of the pixel brightness on <code>[0,1]</code> by the gamma value.]]></comment>
</parameter>
<parameter type="animated" name="gPower" default="0.05" min="1" max="1000" factor="2000">
<parameter type="animated" name="gPower" default="0.05" min="0" max="1000" factor="1000">
<name>Power Green</name>
</parameter>
<parameter type="animated" name="bPower" default="0.05" min="1" max="1000" factor="2000">
<parameter type="animated" name="bPower" default="0.05" min="0" max="1000" factor="1000">
<name>Power Blue</name>
</parameter>
<parameter type="animated" name="aPower" default="0.05" min="1" max="1000" factor="2000">
<parameter type="animated" name="aPower" default="0.05" min="0" max="1000" factor="1000">
<name>Power Alpha</name>
</parameter>
<parameter type="animated" name="saturation" default="0.1" min="0" max="500" factor="1000">
<parameter type="animated" name="saturation" default="0.1" min="0" max="1000" factor="1000">
<name>Overall Saturation</name>
<comment>The overall saturation will be changed in the last step of this filter.</comment>
</parameter>
......
......@@ -94,26 +94,10 @@ bool KeyframeModel::addKeyframe(GenTime pos, KeyframeType type, QVariant value,
bool KeyframeModel::addKeyframe(int frame, double normalizedValue)
{
if (auto ptr = m_model.lock()) {
Q_ASSERT(m_index.isValid());
double min = ptr->data(m_index, AssetParameterModel::MinRole).toDouble();
double max = ptr->data(m_index, AssetParameterModel::MaxRole).toDouble();
double factor = ptr->data(m_index, AssetParameterModel::FactorRole).toDouble();
double norm = ptr->data(m_index, AssetParameterModel::DefaultRole).toDouble();
int logRole = ptr->data(m_index, AssetParameterModel::ScaleRole).toInt();
double realValue;
if (logRole == -1) {
// Logarythmic scale for lower than norm values
if (normalizedValue >= 0.5) {
realValue = norm + (2 * (normalizedValue - 0.5) * (max / factor - norm));
} else {
realValue = norm - pow(2 * (0.5 - normalizedValue), 10.0 / 6) * (norm - min / factor);
}
} else {
realValue = (normalizedValue * (max - min) + min) / factor;
}
QVariant result = getNormalizedValue(normalizedValue);
if (result.isValid()) {
// TODO: Use default configurable kf type
return addKeyframe(GenTime(frame, pCore->getCurrentFps()), KeyframeType::Linear, realValue);
return addKeyframe(GenTime(frame, pCore->getCurrentFps()), KeyframeType::Linear, result);
}
return false;
}
......@@ -188,24 +172,8 @@ bool KeyframeModel::moveKeyframe(GenTime oldPos, GenTime pos, QVariant newVal, F
}
double realValue = newVal.toDouble();
// Calculate real value from normalized
if (auto ptr = m_model.lock()) {
double min = ptr->data(m_index, AssetParameterModel::MinRole).toDouble();
double max = ptr->data(m_index, AssetParameterModel::MaxRole).toDouble();
double factor = ptr->data(m_index, AssetParameterModel::FactorRole).toDouble();
double norm = ptr->data(m_index, AssetParameterModel::DefaultRole).toDouble();
int logRole = ptr->data(m_index, AssetParameterModel::ScaleRole).toInt();
if (logRole == -1) {
// Logarythmic scale for lower than norm values
if (realValue >= 0.5) {
realValue = norm + (2 * (realValue - 0.5) * (max / factor - norm));
} else {
realValue = norm - pow(2 * (0.5 - realValue), 10.0 / 6) * (norm - min / factor);
}
} else {
realValue = (realValue * (max - min) + min) / factor;
}
}
return updateKeyframe(pos, realValue);
QVariant result = getNormalizedValue(newVal.toDouble());
return updateKeyframe(pos, result);
}
if (oldPos != pos && hasKeyframe(pos)) {
return false;
......@@ -226,24 +194,9 @@ bool KeyframeModel::moveKeyframe(GenTime oldPos, GenTime pos, QVariant newVal, F
}
res = addKeyframe(pos, oldType, newVal, true, local_undo, local_redo);
} else if (newVal.isValid()) {
if (auto ptr = m_model.lock()) {
double min = ptr->data(m_index, AssetParameterModel::MinRole).toDouble();
double max = ptr->data(m_index, AssetParameterModel::MaxRole).toDouble();
double factor = ptr->data(m_index, AssetParameterModel::FactorRole).toDouble();
double norm = ptr->data(m_index, AssetParameterModel::DefaultRole).toDouble();
int logRole = ptr->data(m_index, AssetParameterModel::ScaleRole).toInt();
double realValue = newVal.toDouble();
if (logRole == -1) {
// Logarythmic scale for lower than norm values
if (newVal >= 0.5) {
realValue = norm + (2 * (realValue - 0.5) * (max / factor - norm));
} else {
realValue = norm - pow(2 * (0.5 - realValue), 10.0 / 6) * (norm - min / factor);
}
} else {
realValue = (realValue * (max - min) + min) / factor;
}
res = addKeyframe(pos, oldType, realValue, true, local_undo, local_redo);
QVariant result = getNormalizedValue(newVal.toDouble());
if (result.isValid()) {
res = addKeyframe(pos, oldType, result, true, local_undo, local_redo);
}
} else {
res = addKeyframe(pos, oldType, oldValue, true, local_undo, local_redo);
......
......@@ -32,7 +32,7 @@ DoubleWidget::DoubleWidget(const QString &name, double value, double min, double
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
m_dragVal = new DragValue(name, defaultValue, decimals, min, max, id, suffix, true, this);
m_dragVal = new DragValue(name, defaultValue * m_factor, decimals, min, max, id, suffix, true, this);
layout->addWidget(m_dragVal);
setMinimumHeight(m_dragVal->height());
......
Markdown is supported
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