Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions IsoLib/t35_tool/sources/SMPTE_ST2094_50.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "SMPTE_ST2094_50.hpp"
#include <cstdarg>
#include <cstdio>
#include <bitset>
#include <numeric>

/* *********************************** LOCAL LOGGING FUNCTIONS *******************************************************************************************/

Expand Down Expand Up @@ -380,7 +382,7 @@ return error_raised;
void SMPTE_ST2094_50::convertMetadataItemsToSyntaxElements(){
elm.has_custom_hdr_reference_white_flag = false;
elm.has_adaptive_tone_map_flag = false;
if (abs(cvt.hdrReferenceWhite - 203.0) > Q_HDR_REFERENCE_WHITE / 2) {
if (std::abs(cvt.hdrReferenceWhite - 203.0) > Q_HDR_REFERENCE_WHITE / 2) {
elm.has_custom_hdr_reference_white_flag = true;
elm.hdr_reference_white = uint16_t(cvt.hdrReferenceWhite * Q_HDR_REFERENCE_WHITE);
}
Expand Down Expand Up @@ -447,12 +449,12 @@ void SMPTE_ST2094_50::convertMetadataItemsToSyntaxElements(){
elm.has_common_component_mix_params_flag = true; // Init at true, any mismatch makes it false
for (uint16_t iAlt = 1; iAlt < cvt.hatm.numAlternateImages; iAlt++) {
// Check if any coefficient is different across alterante images
if (abs(cvt.hatm.cgf[0].cm.componentMixRed - cvt.hatm.cgf[iAlt].cm.componentMixRed) > Q_COMPONENT_MIXING_COEFFICIENT ||
abs(cvt.hatm.cgf[0].cm.componentMixGreen - cvt.hatm.cgf[iAlt].cm.componentMixGreen) > Q_COMPONENT_MIXING_COEFFICIENT ||
abs(cvt.hatm.cgf[0].cm.componentMixBlue - cvt.hatm.cgf[iAlt].cm.componentMixBlue) > Q_COMPONENT_MIXING_COEFFICIENT ||
abs(cvt.hatm.cgf[0].cm.componentMixMax - cvt.hatm.cgf[iAlt].cm.componentMixMax) > Q_COMPONENT_MIXING_COEFFICIENT ||
abs(cvt.hatm.cgf[0].cm.componentMixMin - cvt.hatm.cgf[iAlt].cm.componentMixMin) > Q_COMPONENT_MIXING_COEFFICIENT ||
abs(cvt.hatm.cgf[0].cm.componentMixComponent - cvt.hatm.cgf[iAlt].cm.componentMixComponent) > Q_COMPONENT_MIXING_COEFFICIENT) {
if (std::abs(cvt.hatm.cgf[0].cm.componentMixRed - cvt.hatm.cgf[iAlt].cm.componentMixRed) > Q_COMPONENT_MIXING_COEFFICIENT ||
std::abs(cvt.hatm.cgf[0].cm.componentMixGreen - cvt.hatm.cgf[iAlt].cm.componentMixGreen) > Q_COMPONENT_MIXING_COEFFICIENT ||
std::abs(cvt.hatm.cgf[0].cm.componentMixBlue - cvt.hatm.cgf[iAlt].cm.componentMixBlue) > Q_COMPONENT_MIXING_COEFFICIENT ||
std::abs(cvt.hatm.cgf[0].cm.componentMixMax - cvt.hatm.cgf[iAlt].cm.componentMixMax) > Q_COMPONENT_MIXING_COEFFICIENT ||
std::abs(cvt.hatm.cgf[0].cm.componentMixMin - cvt.hatm.cgf[iAlt].cm.componentMixMin) > Q_COMPONENT_MIXING_COEFFICIENT ||
std::abs(cvt.hatm.cgf[0].cm.componentMixComponent - cvt.hatm.cgf[iAlt].cm.componentMixComponent) > Q_COMPONENT_MIXING_COEFFICIENT) {
elm.has_common_component_mix_params_flag = false;
break;
}
Expand Down Expand Up @@ -488,28 +490,28 @@ void SMPTE_ST2094_50::convertMetadataItemsToSyntaxElements(){
}
// Component mixing
if (
abs(cvt.hatm.cgf[iAlt].cm.componentMixRed ) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixGreen ) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixBlue ) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixMax- 1.0 ) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixMin ) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixComponent) < P_COMPONENT_MIXING_COEFFICIENT){
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixRed ) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixGreen ) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixBlue ) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixMax- 1.0 ) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixMin ) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixComponent) < P_COMPONENT_MIXING_COEFFICIENT){
elm.component_mixing_type[iAlt] = 0;
} else if (
abs(cvt.hatm.cgf[iAlt].cm.componentMixRed ) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixGreen ) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixBlue ) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixMax ) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixMin ) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixComponent - 1.0 ) < P_COMPONENT_MIXING_COEFFICIENT){
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixRed ) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixGreen ) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixBlue ) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixMax ) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixMin ) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixComponent - 1.0 ) < P_COMPONENT_MIXING_COEFFICIENT){
elm.component_mixing_type[iAlt] = 1;
} else if (
abs(cvt.hatm.cgf[iAlt].cm.componentMixRed - (1.0 / 6.0)) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixGreen - (1.0 / 6.0)) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixBlue - (1.0 / 6.0)) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixMax - (1.0 / 2.0)) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixMin ) < P_COMPONENT_MIXING_COEFFICIENT &&
abs(cvt.hatm.cgf[iAlt].cm.componentMixComponent) < P_COMPONENT_MIXING_COEFFICIENT){
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixRed - (1.0 / 6.0)) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixGreen - (1.0 / 6.0)) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixBlue - (1.0 / 6.0)) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixMax - (1.0 / 2.0)) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixMin ) < P_COMPONENT_MIXING_COEFFICIENT &&
std::abs(cvt.hatm.cgf[iAlt].cm.componentMixComponent) < P_COMPONENT_MIXING_COEFFICIENT){
elm.component_mixing_type[iAlt] = 2;
} else { // Send flag to true for each non-zero coefficient
elm.component_mixing_type[iAlt] = 3;
Expand Down Expand Up @@ -539,7 +541,7 @@ void SMPTE_ST2094_50::convertMetadataItemsToSyntaxElements(){
elm.gain_curve_num_control_points_minus_1[iAlt] = cvt.hatm.cgf[iAlt].gc.gainCurveNumControlPoints - 1;
for (uint16_t iCps = 0; iCps < cvt.hatm.cgf[iAlt].gc.gainCurveNumControlPoints; iCps++){
elm.gain_curve_control_points_x[iAlt][iCps] = uint16_t(cvt.hatm.cgf[iAlt].gc.gainCurveControlPointX[iCps] * Q_GAIN_CURVE_CONTROL_POINT_X );
elm.gain_curve_control_points_y[iAlt][iCps] = uint16_t( abs( cvt.hatm.cgf[iAlt].gc.gainCurveControlPointY[iCps] ) * Q_GAIN_CURVE_CONTROL_POINT_Y );
elm.gain_curve_control_points_y[iAlt][iCps] = uint16_t( std::abs( cvt.hatm.cgf[iAlt].gc.gainCurveControlPointY[iCps] ) * Q_GAIN_CURVE_CONTROL_POINT_Y );
}
elm.gain_curve_use_pchip_slope_flag[iAlt] = !hasSlopeParameter[iAlt];
if (!elm.gain_curve_use_pchip_slope_flag[iAlt]) {
Expand Down Expand Up @@ -989,6 +991,7 @@ return j;
/* *********************************** DEBUGGING SECTION *******************************************************************************************/
// Print the metadata item
void SMPTE_ST2094_50::dbgPrintMetadataItems(bool decode) {
(void)decode;
// Only print at DEBUG level or higher
if (verboseLevel < LOGLEVEL_DEBUG) {
return;
Expand Down
Loading