Skip to content

Commit 5933cc8

Browse files
Ronan Boitardy-guyon
authored andcommitted
[ST2094-50] Fix at decode scaling of component mix when not equal to 1.0
Quantization can result in sum of quantized value not equal to 50000 (1.0). Scaling by the sum of all custom coefficient. Also fixed wrong common flag set at encode.
1 parent 02b1d36 commit 5933cc8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

IsoLib/t35_tool/sources/SMPTE_ST2094_50.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,10 @@ void SMPTE_ST2094_50::convertMetadataItemsToSyntaxElements(){
648648
}
649649
sumCoefficients = sumCoefficients + elm.component_mixing_coefficient[iAlt][iCmf];
650650
}
651-
if (sumCoefficients != 60000) { logMsg(LOGLEVEL_ERROR, "sum component mixing coefficient for alternate %d is not equal to 1.0", iAlt); }
651+
if (sumCoefficients != Q_COMPONENT_MIXING_COEFFICIENT) { logMsg(LOGLEVEL_WARNING, "Sum component mixing coefficient for alternate %d is not equal to 1.0, they will be scaled to 1.0 at decoding", iAlt); }
652652
}
653653
if (elm.component_mixing_type[0] != elm.component_mixing_type[iAlt]) {
654-
elm.has_common_curve_params_flag = false;
654+
elm.component_mixing_type = false;
655655
}
656656

657657
// Create syntax elements for the gain curve function
@@ -1034,10 +1034,18 @@ void SMPTE_ST2094_50::convertSyntaxElementsToMetadataItems(){
10341034
cgf.cm.componentMixGreen = 1.0f / 6.0f;
10351035
cgf.cm.componentMixBlue = 1.0f / 6.0f;}
10361036
else if (elm.component_mixing_type[iAlt] == 3) {
1037+
// Compute sum of component
1038+
float sumComponent = 0.0f;
1039+
for (int k = 0; k < MAX_NB_COMPONENT_MIXING_COEFFICIENT; k++) {
1040+
sumComponent = float(elm.component_mixing_coefficient[iAlt][k]);
1041+
}
1042+
if (sumComponent != Q_COMPONENT_MIXING_COEFFICIENT){
1043+
logMsg(LOGLEVEL_WARNING, "Sum component mixing coefficient for alternate %d is not equal to 1.0, they will be scaled to 1.0.", iAlt); }
1044+
}
10371045
for (int k = 0; k < MAX_NB_COMPONENT_MIXING_COEFFICIENT; k++) {
10381046
float value = 0.0f;
10391047
if (elm.has_component_mixing_coefficient_flag[iAlt][k]) {
1040-
value = float(elm.component_mixing_coefficient[iAlt][k]) / Q_COMPONENT_MIXING_COEFFICIENT;
1048+
value = float(elm.component_mixing_coefficient[iAlt][k]) / sumComponent;
10411049
}
10421050
switch (k) {
10431051
case 0: cgf.cm.componentMixRed = value; break;

0 commit comments

Comments
 (0)