Changeset 1460 in SHVCSoftware
- Timestamp:
- 20 Aug 2015, 20:54:17 (9 years ago)
- Location:
- branches/SHM-dev
- Files:
-
- 6 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp
r1442 r1460 113 113 ("TarDecLayerIdSetFile,l", cfg_TargetDecLayerIdSetFile, string(""), "targetDecLayerIdSet file name. The file should include white space separated LayerId values to be decoded. Omitting the option or a value of -1 in the file decodes all layers.") 114 114 ("RespectDefDispWindow,w", m_respectDefDispWindow, 0, "Only output content inside the default display window\n") 115 #if Q0074_COLOUR_REMAPPING_SEI 116 ("SEIColourRemappingInfoFilename", m_colourRemapSEIFileName, string(""), "Colour Remapping YUV output file name. If empty, no remapping is applied (ignore SEI message)\n") 117 #endif 115 118 #if O0043_BEST_EFFORT_DECODING 116 119 ("ForceDecodeBitDepth", m_forceDecodeBitDepth, 0U, "Force the decoder to operate at a particular bit-depth (best effort decoding)") … … 118 121 ("OutputDecodedSEIMessagesFilename", m_outputDecodedSEIMessagesFilename, string(""), "When non empty, output decoded SEI messages to the indicated file. If file is '-', then output to stdout\n") 119 122 ("ClipOutputVideoToRec709Range", m_bClipOutputVideoToRec709Range, false, "If true then clip output video to the Rec. 709 Range on saving") 120 #if Q0074_COLOUR_REMAPPING_SEI121 ("SEIColourRemappingInfo,-cri", m_colourRemapSEIEnabled, false, "Control handling of Colour Remapping Information SEI messages\n"122 "\t1: apply colour remapping on decoded pictures if available in the bitstream\n"123 "\t0: ignore SEI message")124 #endif125 123 ; 126 124 -
branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.h
r1445 r1460 71 71 Bool m_decodedNoDisplaySEIEnabled; ///< Enable(true)/disable(false) writing only pictures that get displayed based on the no display SEI message 72 72 #if Q0074_COLOUR_REMAPPING_SEI 73 Bool m_colourRemapSEIEnabled; ///< Enable the Colour Remapping Information SEI message if available (remapping decoded pictures)73 std::string m_colourRemapSEIFileName; ///< output Colour Remapping file name 74 74 #endif 75 76 75 std::vector<Int> m_targetDecLayerIdSet; ///< set of LayerIds to be included in the sub-bitstream extraction process. 77 76 Int m_respectDefDispWindow; ///< Only output content inside the default display window … … 110 109 , m_decodedNoDisplaySEIEnabled(false) 111 110 #if Q0074_COLOUR_REMAPPING_SEI 112 , m_colourRemapSEI Enabled(false)111 , m_colourRemapSEIFileName() 113 112 #endif 114 113 , m_targetDecLayerIdSet() -
branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp
r1445 r1460 63 63 TAppDecTop::TAppDecTop() 64 64 #if Q0074_COLOUR_REMAPPING_SEI 65 : seiColourRemappingInfoPrevious(NULL) 65 : m_pcSeiColourRemappingInfoPrevious(NULL) 66 , m_pcPicYuvColourRemapped(NULL) 66 67 #endif 67 68 { … … 78 79 : m_iPOCLastDisplay(-MAX_INT) 79 80 #if Q0074_COLOUR_REMAPPING_SEI 80 , seiColourRemappingInfoPrevious(NULL) 81 ,m_pcSeiColourRemappingInfoPrevious(NULL) 82 ,m_pcPicYuvColourRemapped(NULL) 81 83 #endif 82 84 { … … 117 119 #else 118 120 m_reconFileName.clear(); 119 #endif120 #if Q0074_COLOUR_REMAPPING_SEI121 if (seiColourRemappingInfoPrevious != NULL)122 {123 delete seiColourRemappingInfoPrevious;124 }125 121 #endif 126 122 } … … 688 684 } 689 685 #endif 686 #if Q0074_COLOUR_REMAPPING_SEI 687 if (m_pcSeiColourRemappingInfoPrevious != NULL) 688 { 689 delete m_pcSeiColourRemappingInfoPrevious; 690 m_pcSeiColourRemappingInfoPrevious = NULL; 691 } 692 if (m_pcPicYuvColourRemapped != NULL) 693 { 694 m_pcPicYuvColourRemapped->destroy(); 695 delete m_pcPicYuvColourRemapped; 696 m_pcPicYuvColourRemapped = NULL; 697 } 698 #endif 690 699 } 691 700 … … 919 928 920 929 #if Q0074_COLOUR_REMAPPING_SEI 921 if (m_colourRemapSEIEnabled) 922 { 923 SEIMessages colourRemappingInfo = getSeisByType(pcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO ); 924 const SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL; 925 const TComSPS *sps = pcPic->getSlice(0)->getSPS(); 926 927 if (colourRemappingInfo.size() > 1) 928 { 929 printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first."); 930 } 931 if (seiColourRemappingInfo) 932 { 933 xApplyColourRemapping(sps, *pcPic->getPicYuvRec(), seiColourRemappingInfo); 934 } 935 else // using the last CRI SEI received 936 { 937 const SEIColourRemappingInfo *seiColourRemappingInfoCopy; 938 seiColourRemappingInfoCopy = seiColourRemappingInfoPrevious; 939 xApplyColourRemapping(sps, *pcPic->getPicYuvRec(), seiColourRemappingInfoCopy); 940 } 941 942 // save the last CRI SEI received 943 if( seiColourRemappingInfo != NULL){ 944 if (seiColourRemappingInfoPrevious != NULL) 945 { 946 delete seiColourRemappingInfoPrevious; 947 seiColourRemappingInfoPrevious = NULL; 948 } 949 if (seiColourRemappingInfo->m_colourRemapPersistenceFlag) 950 { 951 seiColourRemappingInfoPrevious = new SEIColourRemappingInfo(); 952 seiColourRemappingInfoPrevious->copyFrom(seiColourRemappingInfo); 953 } 954 } 930 if (!m_colourRemapSEIFileName.empty()) 931 { 932 xOutputColourRemapPic(pcPic, activeSPS); 955 933 } 956 934 #endif … … 1122 1100 1123 1101 #if Q0074_COLOUR_REMAPPING_SEI 1124 if (m_colourRemapSEIEnabled) 1125 { 1126 SEIMessages colourRemappingInfo = getSeisByType(pcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO ); 1127 const SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL; 1128 const TComSPS *sps = pcPic->getSlice(0)->getSPS(); 1129 1130 if (colourRemappingInfo.size() > 1) 1131 { 1132 printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first."); 1133 } 1134 if (seiColourRemappingInfo) 1135 { 1136 xApplyColourRemapping( sps, *pcPic->getPicYuvRec(), seiColourRemappingInfo ); 1137 } 1138 else // using the last CRI SEI received 1139 { 1140 const SEIColourRemappingInfo *seiColourRemappingInfoCopy; 1141 seiColourRemappingInfoCopy = seiColourRemappingInfoPrevious; 1142 xApplyColourRemapping( sps, *pcPic->getPicYuvRec(), seiColourRemappingInfoCopy ); 1143 } 1144 1145 // save the last CRI SEI received 1146 if( seiColourRemappingInfo != NULL){ 1147 if (seiColourRemappingInfoPrevious != NULL) 1148 { 1149 delete seiColourRemappingInfoPrevious; 1150 seiColourRemappingInfoPrevious = NULL; 1151 } 1152 if (seiColourRemappingInfo->m_colourRemapPersistenceFlag) 1153 { 1154 seiColourRemappingInfoPrevious = new SEIColourRemappingInfo(); 1155 seiColourRemappingInfoPrevious->copyFrom(seiColourRemappingInfo); 1156 } 1157 } 1102 if (!m_colourRemapSEIFileName.empty()) 1103 { 1104 xOutputColourRemapPic(pcPic, &(pcPic->getPicSym()->getSPS())); 1158 1105 } 1159 1106 #endif … … 1215 1162 return false; 1216 1163 } 1164 1165 #if Q0074_COLOUR_REMAPPING_SEI 1166 1167 Void TAppDecTop::xOutputColourRemapPic(TComPic* pcPic, const TComSPS* activeSPS) 1168 { 1169 SEIMessages colourRemappingInfo = getSeisByType(pcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO ); 1170 SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL; 1171 1172 if (colourRemappingInfo.size() > 1) 1173 { 1174 printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first."); 1175 } 1176 if (seiColourRemappingInfo) 1177 { 1178 applyColourRemapping(*pcPic->getPicYuvRec(), *seiColourRemappingInfo, *activeSPS); 1179 } 1180 else // using the last CRI SEI received 1181 { 1182 if (m_pcSeiColourRemappingInfoPrevious != NULL) 1183 { 1184 if (m_pcSeiColourRemappingInfoPrevious->m_colourRemapPersistenceFlag == false) 1185 { 1186 printf("Warning No SEI-CRI message is present for the current picture, persistence of the CRI is not managed\n"); 1187 } 1188 SEIColourRemappingInfo *seiColourRemappingInfoCopy; 1189 seiColourRemappingInfoCopy = m_pcSeiColourRemappingInfoPrevious; 1190 applyColourRemapping(*pcPic->getPicYuvRec(), *seiColourRemappingInfoCopy, *activeSPS); 1191 } 1192 } 1193 1194 // save the last CRI SEI received 1195 if( seiColourRemappingInfo != NULL) 1196 { 1197 if (m_pcSeiColourRemappingInfoPrevious != NULL) 1198 { 1199 delete m_pcSeiColourRemappingInfoPrevious; 1200 m_pcSeiColourRemappingInfoPrevious = NULL; 1201 } 1202 m_pcSeiColourRemappingInfoPrevious = new SEIColourRemappingInfo(); 1203 m_pcSeiColourRemappingInfoPrevious->copyFrom(*seiColourRemappingInfo); 1204 } 1205 } 1206 1207 // compute lut from SEI 1208 // use at lutPoints points aligned on a power of 2 value 1209 // SEI Lut must be in ascending values of coded Values 1210 static std::vector<Int> 1211 initColourRemappingInfoLut(const Int bitDepth_in, // bit-depth of the input values of the LUT 1212 const Int nbDecimalValues, // Position of the fixed point 1213 const std::vector<SEIColourRemappingInfo::CRIlut> &lut, 1214 const Int maxValue, // maximum output value 1215 const Int lutOffset) 1216 { 1217 const Int lutPoints = (1 << bitDepth_in) + 1 ; 1218 std::vector<Int> retLut(lutPoints); 1219 1220 // missing values: need to define default values before first definition (check codedValue[0] == 0) 1221 Int iTargetPrev = (lut.size() && lut[0].codedValue == 0) ? lut[0].targetValue: 0; 1222 Int startPivot = (lut.size())? ((lut[0].codedValue == 0)? 1: 0): 1; 1223 Int iCodedPrev = 0; 1224 // set max value with the coded bit-depth 1225 // + ((1 << nbDecimalValues) - 1) is for the added bits 1226 const Int maxValueFixedPoint = (maxValue << nbDecimalValues) + ((1 << nbDecimalValues) - 1); 1227 1228 Int iValue = 0; 1229 1230 for ( Int iPivot=startPivot ; iPivot < (Int)lut.size(); iPivot++ ) 1231 { 1232 Int iCodedNext = lut[iPivot].codedValue; 1233 Int iTargetNext = lut[iPivot].targetValue; 1234 1235 // ensure correct bit depth and avoid overflow in lut address 1236 Int iCodedNext_bitDepth = std::min(iCodedNext, (1 << bitDepth_in)); 1237 1238 const Int divValue = (iCodedNext - iCodedPrev > 0)? (iCodedNext - iCodedPrev): 1; 1239 const Int lutValInit = (lutOffset + iTargetPrev) << nbDecimalValues; 1240 const Int roundValue = divValue / 2; 1241 for ( ; iValue<iCodedNext_bitDepth; iValue++ ) 1242 { 1243 Int value = iValue; 1244 Int interpol = ((((value-iCodedPrev) * (iTargetNext - iTargetPrev)) << nbDecimalValues) + roundValue) / divValue; 1245 retLut[iValue] = std::min(lutValInit + interpol , maxValueFixedPoint); 1246 } 1247 iCodedPrev = iCodedNext; 1248 iTargetPrev = iTargetNext; 1249 } 1250 // fill missing values if necessary 1251 if(iCodedPrev < (1 << bitDepth_in)+1) 1252 { 1253 Int iCodedNext = (1 << bitDepth_in); 1254 Int iTargetNext = (1 << bitDepth_in) - 1; 1255 1256 const Int divValue = (iCodedNext - iCodedPrev > 0)? (iCodedNext - iCodedPrev): 1; 1257 const Int lutValInit = (lutOffset + iTargetPrev) << nbDecimalValues; 1258 const Int roundValue = divValue / 2; 1259 1260 for ( ; iValue<=iCodedNext; iValue++ ) 1261 { 1262 Int value = iValue; 1263 Int interpol = ((((value-iCodedPrev) * (iTargetNext - iTargetPrev)) << nbDecimalValues) + roundValue) / divValue; 1264 retLut[iValue] = std::min(lutValInit + interpol , maxValueFixedPoint); 1265 } 1266 } 1267 return retLut; 1268 } 1269 1270 static Void 1271 initColourRemappingInfoLuts(std::vector<Int> (&preLut)[3], 1272 std::vector<Int> (&postLut)[3], 1273 SEIColourRemappingInfo &pCriSEI, 1274 const Int maxBitDepth) 1275 { 1276 Int internalBitDepth = pCriSEI.m_colourRemapBitDepth; 1277 for ( Int c=0 ; c<3 ; c++ ) 1278 { 1279 std::sort(pCriSEI.m_preLut[c].begin(), pCriSEI.m_preLut[c].end()); // ensure preLut is ordered in ascending values of codedValues 1280 preLut[c] = initColourRemappingInfoLut(pCriSEI.m_colourRemapInputBitDepth, maxBitDepth - pCriSEI.m_colourRemapInputBitDepth, pCriSEI.m_preLut[c], ((1 << internalBitDepth) - 1), 0); //Fill preLut 1281 1282 std::sort(pCriSEI.m_postLut[c].begin(), pCriSEI.m_postLut[c].end()); // ensure postLut is ordered in ascending values of codedValues 1283 postLut[c] = initColourRemappingInfoLut(pCriSEI.m_colourRemapBitDepth, maxBitDepth - pCriSEI.m_colourRemapBitDepth, pCriSEI.m_postLut[c], (1 << internalBitDepth) - 1, 0); //Fill postLut 1284 } 1285 } 1286 1287 // apply lut. 1288 // Input lut values are aligned on power of 2 boundaries 1289 static Int 1290 applyColourRemappingInfoLut1D(Int inVal, const std::vector<Int> &lut, const Int inValPrecisionBits) 1291 { 1292 const Int roundValue = (inValPrecisionBits)? 1 << (inValPrecisionBits - 1): 0; 1293 inVal = std::min(std::max(0, inVal), (Int)(((lut.size()-1) << inValPrecisionBits))); 1294 Int index = (Int) std::min((inVal >> inValPrecisionBits), (Int)(lut.size()-2)); 1295 Int outVal = (( inVal - (index<<inValPrecisionBits) ) * (lut[index+1] - lut[index]) + roundValue) >> inValPrecisionBits; 1296 outVal += lut[index] ; 1297 1298 return outVal; 1299 } 1300 1301 static Int 1302 applyColourRemappingInfoMatrix(const Int (&colourRemapCoeffs)[3], const Int postOffsetShift, const Int p0, const Int p1, const Int p2, const Int offset) 1303 { 1304 Int YUVMat = (colourRemapCoeffs[0]* p0 + colourRemapCoeffs[1]* p1 + colourRemapCoeffs[2]* p2 + offset) >> postOffsetShift; 1305 return YUVMat; 1306 } 1307 1308 static Void 1309 setColourRemappingInfoMatrixOffset(Int (&matrixOffset)[3], Int offset0, Int offset1, Int offset2) 1310 { 1311 matrixOffset[0] = offset0; 1312 matrixOffset[1] = offset1; 1313 matrixOffset[2] = offset2; 1314 } 1315 1316 static Void 1317 setColourRemappingInfoMatrixOffsets( Int (&matrixInputOffset)[3], 1318 Int (&matrixOutputOffset)[3], 1319 const Int bitDepth, 1320 const Bool crInputFullRangeFlag, 1321 const Int crInputMatrixCoefficients, 1322 const Bool crFullRangeFlag, 1323 const Int crMatrixCoefficients) 1324 { 1325 // set static matrix offsets 1326 Int crInputOffsetLuma = (crInputFullRangeFlag)? 0:-(16 << (bitDepth-8)); 1327 Int crOffsetLuma = (crFullRangeFlag)? 0:(16 << (bitDepth-8)); 1328 Int crInputOffsetChroma = 0; 1329 Int crOffsetChroma = 0; 1330 1331 switch(crInputMatrixCoefficients) 1332 { 1333 case MATRIX_COEFFICIENTS_RGB: 1334 crInputOffsetChroma = 0; 1335 if(!crInputFullRangeFlag) 1336 { 1337 fprintf(stderr, "WARNING: crInputMatrixCoefficients set to MATRIX_COEFFICIENTS_RGB and crInputFullRangeFlag not set\n"); 1338 crInputOffsetLuma = 0; 1339 } 1340 break; 1341 case MATRIX_COEFFICIENTS_UNSPECIFIED: 1342 case MATRIX_COEFFICIENTS_BT709: 1343 case MATRIX_COEFFICIENTS_BT2020_NON_CONSTANT_LUMINANCE: 1344 crInputOffsetChroma = -(1 << (bitDepth-1)); 1345 break; 1346 default: 1347 fprintf(stderr, "WARNING: crInputMatrixCoefficients set to undefined value: %d\n", crInputMatrixCoefficients); 1348 } 1349 1350 switch(crMatrixCoefficients) 1351 { 1352 case MATRIX_COEFFICIENTS_RGB: 1353 crOffsetChroma = 0; 1354 if(!crFullRangeFlag) 1355 { 1356 fprintf(stderr, "WARNING: crMatrixCoefficients set to MATRIX_COEFFICIENTS_RGB and crInputFullRangeFlag not set\n"); 1357 crOffsetLuma = 0; 1358 } 1359 break; 1360 case MATRIX_COEFFICIENTS_UNSPECIFIED: 1361 case MATRIX_COEFFICIENTS_BT709: 1362 case MATRIX_COEFFICIENTS_BT2020_NON_CONSTANT_LUMINANCE: 1363 crOffsetChroma = (1 << (bitDepth-1)); 1364 break; 1365 default: 1366 fprintf(stderr, "WARNING: crMatrixCoefficients set to undefined value: %d\n", crMatrixCoefficients); 1367 } 1368 1369 setColourRemappingInfoMatrixOffset(matrixInputOffset, crInputOffsetLuma, crInputOffsetChroma, crInputOffsetChroma); 1370 setColourRemappingInfoMatrixOffset(matrixOutputOffset, crOffsetLuma, crOffsetChroma, crOffsetChroma); 1371 } 1372 1373 Void TAppDecTop::applyColourRemapping(const TComPicYuv& pic, SEIColourRemappingInfo& criSEI, const TComSPS &activeSPS) 1374 { 1375 const Int maxBitDepth = 16; 1376 Bool firstPicture = true; 1377 1378 // create colour remapped picture 1379 if ( m_pcPicYuvColourRemapped == NULL ) 1380 { 1381 const ChromaFormat chromaFormatIDC = activeSPS.getChromaFormatIdc(); 1382 const Int iWidth = activeSPS.getPicWidthInLumaSamples(); 1383 const Int iHeight = activeSPS.getPicHeightInLumaSamples(); 1384 const UInt uiMaxCuWidth = activeSPS.getMaxCUWidth(); 1385 const UInt uiMaxCuHeight = activeSPS.getMaxCUHeight(); 1386 const UInt uiMaxDepth = activeSPS.getMaxTotalCUDepth(); 1387 m_pcPicYuvColourRemapped = new TComPicYuv; 1388 m_pcPicYuvColourRemapped->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); 1389 } 1390 else 1391 { 1392 firstPicture = false; 1393 } 1394 1395 if( !criSEI.m_colourRemapCancelFlag ) 1396 { 1397 const Int iHeight = pic.getHeight(COMPONENT_Y); 1398 const Int iWidth = pic.getWidth(COMPONENT_Y); 1399 const Int iStride = pic.getStride(COMPONENT_Y); 1400 const Int iCStride = pic.getStride(COMPONENT_Cb); 1401 const Bool b444 = ( pic.getChromaFormat() == CHROMA_444 ); 1402 const Bool b422 = ( pic.getChromaFormat() == CHROMA_422 ); 1403 const Bool b420 = ( pic.getChromaFormat() == CHROMA_420 ); 1404 1405 std::vector<Int> preLut[3]; 1406 std::vector<Int> postLut[3]; 1407 Int matrixInputOffset[3]; 1408 Int matrixOutputOffset[3]; 1409 const Pel *YUVIn[MAX_NUM_COMPONENT]; 1410 Pel *YUVOut[MAX_NUM_COMPONENT]; 1411 YUVIn[COMPONENT_Y] = pic.getAddr(COMPONENT_Y); 1412 YUVIn[COMPONENT_Cb] = pic.getAddr(COMPONENT_Cb); 1413 YUVIn[COMPONENT_Cr] = pic.getAddr(COMPONENT_Cr); 1414 YUVOut[COMPONENT_Y] = m_pcPicYuvColourRemapped->getAddr(COMPONENT_Y); 1415 YUVOut[COMPONENT_Cb] = m_pcPicYuvColourRemapped->getAddr(COMPONENT_Cb); 1416 YUVOut[COMPONENT_Cr] = m_pcPicYuvColourRemapped->getAddr(COMPONENT_Cr); 1417 1418 Int bitDepthY = activeSPS.getBitDepth(CHANNEL_TYPE_LUMA); 1419 assert(bitDepthY == activeSPS.getBitDepth(CHANNEL_TYPE_CHROMA)); // Different bitdepth is not implemented 1420 1421 const Int postOffsetShift = criSEI.m_log2MatrixDenom; 1422 const Int matrixRound = 1 << (postOffsetShift - 1); 1423 const Int postLutInputPrecision = (maxBitDepth - criSEI.m_colourRemapBitDepth); 1424 1425 if ( ! criSEI.m_colourRemapVideoSignalInfoPresentFlag ) // setting default 1426 { 1427 setColourRemappingInfoMatrixOffsets(matrixInputOffset, matrixOutputOffset, maxBitDepth, 1428 activeSPS.getVuiParameters()->getVideoFullRangeFlag(), activeSPS.getVuiParameters()->getMatrixCoefficients(), 1429 activeSPS.getVuiParameters()->getVideoFullRangeFlag(), activeSPS.getVuiParameters()->getMatrixCoefficients()); 1430 } 1431 else 1432 { 1433 setColourRemappingInfoMatrixOffsets(matrixInputOffset, matrixOutputOffset, maxBitDepth, 1434 activeSPS.getVuiParameters()->getVideoFullRangeFlag(), activeSPS.getVuiParameters()->getMatrixCoefficients(), 1435 criSEI.m_colourRemapFullRangeFlag, criSEI.m_colourRemapMatrixCoefficients); 1436 } 1437 1438 // add matrix rounding to output matrix offsets 1439 matrixOutputOffset[0] = (matrixOutputOffset[0] << postOffsetShift) + matrixRound; 1440 matrixOutputOffset[1] = (matrixOutputOffset[1] << postOffsetShift) + matrixRound; 1441 matrixOutputOffset[2] = (matrixOutputOffset[2] << postOffsetShift) + matrixRound; 1442 1443 // Merge matrixInputOffset and matrixOutputOffset to matrixOutputOffset 1444 matrixOutputOffset[0] += applyColourRemappingInfoMatrix(criSEI.m_colourRemapCoeffs[0], 0, matrixInputOffset[0], matrixInputOffset[1], matrixInputOffset[2], 0); 1445 matrixOutputOffset[1] += applyColourRemappingInfoMatrix(criSEI.m_colourRemapCoeffs[1], 0, matrixInputOffset[0], matrixInputOffset[1], matrixInputOffset[2], 0); 1446 matrixOutputOffset[2] += applyColourRemappingInfoMatrix(criSEI.m_colourRemapCoeffs[2], 0, matrixInputOffset[0], matrixInputOffset[1], matrixInputOffset[2], 0); 1447 1448 // rescaling output: include CRI/output frame difference 1449 const Int scaleShiftOut_neg = abs(bitDepthY - maxBitDepth); 1450 const Int scaleOut_round = 1 << (scaleShiftOut_neg-1); 1451 1452 initColourRemappingInfoLuts(preLut, postLut, criSEI, maxBitDepth); 1453 1454 assert(pic.getChromaFormat() != CHROMA_400); 1455 const Int hs = pic.getComponentScaleX(ComponentID(COMPONENT_Cb)); 1456 1457 for( Int y = 0; y < iHeight; y++ ) 1458 { 1459 for( Int x = 0; x < iWidth; x++ ) 1460 { 1461 const Int xc = (x>>hs); 1462 Bool computeChroma = b444 || ((b422 || !(y&1)) && !(x&1)); 1463 1464 Int YUVPre_0 = applyColourRemappingInfoLut1D(YUVIn[COMPONENT_Y][x], preLut[0], 0); 1465 Int YUVPre_1 = applyColourRemappingInfoLut1D(YUVIn[COMPONENT_Cb][xc], preLut[1], 0); 1466 Int YUVPre_2 = applyColourRemappingInfoLut1D(YUVIn[COMPONENT_Cr][xc], preLut[2], 0); 1467 1468 Int YUVMat_0 = applyColourRemappingInfoMatrix(criSEI.m_colourRemapCoeffs[0], postOffsetShift, YUVPre_0, YUVPre_1, YUVPre_2, matrixOutputOffset[0]); 1469 Int YUVLutB_0 = applyColourRemappingInfoLut1D(YUVMat_0, postLut[0], postLutInputPrecision); 1470 YUVOut[COMPONENT_Y][x] = (YUVLutB_0 + scaleOut_round) >> scaleShiftOut_neg; // scaling output 1471 1472 if( computeChroma ) 1473 { 1474 Int YUVMat_1 = applyColourRemappingInfoMatrix(criSEI.m_colourRemapCoeffs[1], postOffsetShift, YUVPre_0, YUVPre_1, YUVPre_2, matrixOutputOffset[1]); 1475 Int YUVLutB_1 = applyColourRemappingInfoLut1D(YUVMat_1, postLut[1], postLutInputPrecision); 1476 YUVOut[COMPONENT_Cb][xc] = (YUVLutB_1 + scaleOut_round) >> scaleShiftOut_neg; // scaling output 1477 1478 Int YUVMat_2 = applyColourRemappingInfoMatrix(criSEI.m_colourRemapCoeffs[2], postOffsetShift, YUVPre_0, YUVPre_1, YUVPre_2, matrixOutputOffset[2]); 1479 Int YUVLutB_2 = applyColourRemappingInfoLut1D(YUVMat_2, postLut[2], postLutInputPrecision); 1480 YUVOut[COMPONENT_Cr][xc] = (YUVLutB_2 + scaleOut_round) >> scaleShiftOut_neg; // scaling output 1481 } 1482 } 1483 1484 YUVIn[COMPONENT_Y] += iStride; 1485 YUVOut[COMPONENT_Y] += iStride; 1486 if( !(b420 && !(y&1)) ) 1487 { 1488 YUVIn[COMPONENT_Cb] += iCStride; 1489 YUVIn[COMPONENT_Cr] += iCStride; 1490 YUVOut[COMPONENT_Cb] += iCStride; 1491 YUVOut[COMPONENT_Cr] += iCStride; 1492 } 1493 } 1494 //Write remapped picture in display order 1495 m_pcPicYuvColourRemapped->dump( m_colourRemapSEIFileName, activeSPS.getBitDepths(), !firstPicture ); 1496 } 1497 } 1498 #endif 1217 1499 1218 1500 #if ALIGNED_BUMPING … … 1238 1520 1239 1521 #if Q0074_COLOUR_REMAPPING_SEI 1240 if( m_colourRemapSEIEnabled ) 1241 { 1242 const TComSPS *sps = pic->getSlice(0)->getSPS(); 1243 SEIMessages colourRemappingInfo = getSeisByType(pic->getSEIs(), SEI::COLOUR_REMAPPING_INFO ); 1244 const SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL; 1245 1246 if (colourRemappingInfo.size() > 1) 1247 { 1248 printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first."); 1249 } 1250 1251 if (seiColourRemappingInfo) 1252 { 1253 //printf ("\n\nColour Remapping is applied to POC : %d and LayerId : %d ",pic->getPOC(), pic->getLayerId()); 1254 xApplyColourRemapping( sps, *pic->getPicYuvRec(), seiColourRemappingInfo, pic->getLayerId() ); 1255 } 1256 else // using the last CRI SEI received 1257 { 1258 const SEIColourRemappingInfo *seiColourRemappingInfoCopy; 1259 seiColourRemappingInfoCopy = seiColourRemappingInfoPrevious; 1260 xApplyColourRemapping( sps, *pic->getPicYuvRec(), seiColourRemappingInfoCopy, pic->getLayerId() ); 1261 } 1262 1263 // save the last CRI SEI received 1264 if( seiColourRemappingInfo != NULL){ 1265 if (seiColourRemappingInfoPrevious != NULL) 1266 { 1267 delete seiColourRemappingInfoPrevious; 1268 seiColourRemappingInfoPrevious = NULL; 1269 } 1270 if (seiColourRemappingInfo->m_colourRemapPersistenceFlag) 1271 { 1272 seiColourRemappingInfoPrevious = new SEIColourRemappingInfo(); 1273 seiColourRemappingInfoPrevious->copyFrom(seiColourRemappingInfo); 1274 } 1275 } 1276 } 1277 1522 if (!m_colourRemapSEIFileName.empty()) 1523 { 1524 xOutputColourRemapPic(pic, pic->getSlice(0)->getSPS()); 1525 } 1278 1526 #endif 1279 1527 } … … 1795 2043 #endif //ALIGNED_BUMPING 1796 2044 1797 #if Q0074_COLOUR_REMAPPING_SEI1798 Void TAppDecTop::xInitColourRemappingLut( const BitDepths &bitDepths, std::vector<Int>(&preLut)[3], std::vector<Int>(&postLut)[3], const SEIColourRemappingInfo* const pCriSEI )1799 {1800 for ( Int c=0 ; c<3 ; c++ )1801 {1802 Int bitDepth = bitDepths.recon[toChannelType(ComponentID(c))];1803 preLut[c].resize(1 << bitDepth);1804 postLut[c].resize(1 << pCriSEI->m_colourRemapBitDepth);1805 1806 Int bitDepthDiff = pCriSEI->m_colourRemapBitDepth - bitDepth;1807 Int iShift1 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from bitdepth to ColourRemapBitdepth (manage only case colourRemapBitDepth>= bitdepth)1808 if( bitDepthDiff<0 )1809 printf ("Warning: CRI SEI - colourRemapBitDepth (%d) <bitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapBitDepth, bitDepth);1810 bitDepthDiff = pCriSEI->m_colourRemapBitDepth - pCriSEI->m_colourRemapInputBitDepth;1811 Int iShift2 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from ColourRemapInputBitdepth to ColourRemapBitdepth (manage only case colourRemapBitDepth>= colourRemapInputBitDepth)1812 if( bitDepthDiff<0 )1813 printf ("Warning: CRI SEI - colourRemapBitDepth (%d) <colourRemapInputBitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapBitDepth, pCriSEI->m_colourRemapInputBitDepth);1814 1815 //Fill preLut1816 for ( Int k=0 ; k<(1<<bitDepth) ; k++ )1817 {1818 Int iSample = k << iShift1 ;1819 for ( Int iPivot=0 ; iPivot<=pCriSEI->m_preLutNumValMinus1[c] ; iPivot++ )1820 {1821 Int iCodedPrev = pCriSEI->m_preLutCodedValue[c][iPivot] << iShift2; //Coded in CRInputBitdepth1822 Int iCodedNext = pCriSEI->m_preLutCodedValue[c][iPivot+1] << iShift2; //Coded in CRInputBitdepth1823 Int iTargetPrev = pCriSEI->m_preLutTargetValue[c][iPivot]; //Coded in CRBitdepth1824 Int iTargetNext = pCriSEI->m_preLutTargetValue[c][iPivot+1]; //Coded in CRBitdepth1825 if ( iCodedPrev <= iSample && iSample <= iCodedNext )1826 {1827 Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev);1828 preLut[c][k] = (Int)( 0.5f + fInterpol );1829 iPivot = pCriSEI->m_preLutNumValMinus1[c] + 1;1830 }1831 }1832 }1833 1834 //Fill postLut1835 for ( Int k=0 ; k<(1<<pCriSEI->m_colourRemapBitDepth) ; k++ )1836 {1837 Int iSample = k;1838 for ( Int iPivot=0 ; iPivot<=pCriSEI->m_postLutNumValMinus1[c] ; iPivot++ )1839 {1840 Int iCodedPrev = pCriSEI->m_postLutCodedValue[c][iPivot]; //Coded in CRBitdepth1841 Int iCodedNext = pCriSEI->m_postLutCodedValue[c][iPivot+1]; //Coded in CRBitdepth1842 Int iTargetPrev = pCriSEI->m_postLutTargetValue[c][iPivot]; //Coded in CRBitdepth1843 Int iTargetNext = pCriSEI->m_postLutTargetValue[c][iPivot+1]; //Coded in CRBitdepth1844 if ( iCodedPrev <= iSample && iSample <= iCodedNext )1845 {1846 Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev) ;1847 postLut[c][k] = (Int)( 0.5f + fInterpol );1848 iPivot = pCriSEI->m_postLutNumValMinus1[c] + 1;1849 }1850 }1851 }1852 }1853 }1854 1855 Void TAppDecTop::xApplyColourRemapping( const TComSPS *sps, TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId )1856 {1857 const BitDepths& bitDpeths = sps->getBitDepths();1858 1859 if( !storeCriSEI.size() )1860 {1861 #if SVC_EXTENSION1862 storeCriSEI.resize(MAX_LAYERS);1863 #else1864 storeCriSEI.resize(1);1865 #endif1866 }1867 1868 if ( pCriSEI ) //if a CRI SEI has just been retrieved, keep it in memory (persistence management)1869 {1870 storeCriSEI[layerId] = *pCriSEI;1871 }1872 1873 if( !storeCriSEI[layerId].m_colourRemapCancelFlag && pCriSEI)1874 {1875 Int iHeight = pic.getHeight(COMPONENT_Y);1876 Int iWidth = pic.getWidth(COMPONENT_Y);1877 Int iStride = pic.getStride(COMPONENT_Y);1878 Int iCStride = pic.getStride(COMPONENT_Cb);1879 1880 Pel *YUVIn[3], *YUVOut[3];1881 YUVIn[0] = pic.getAddr(COMPONENT_Y);1882 YUVIn[1] = pic.getAddr(COMPONENT_Cb);1883 YUVIn[2] = pic.getAddr(COMPONENT_Cr);1884 1885 TComPicYuv picColourRemapped;1886 1887 #if SVC_EXTENSION1888 #if AUXILIARY_PICTURES1889 picColourRemapped.create( pic.getWidth(COMPONENT_Y), pic.getHeight(COMPONENT_Y), pic.getChromaFormat(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxTotalCUDepth(), true, NULL );1890 #else1891 picColourRemapped.create( pic.getWidth(), pic.getHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxTotalCUDepth(), true, NULL );1892 #endif1893 #else1894 picColourRemapped.create( pic.getWidth(COMPONENT_Y), pic.getHeight(COMPONENT_Y), pic.getChromaFormat(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxTotalCUDepth(), true );1895 #endif1896 YUVOut[0] = picColourRemapped.getAddr(COMPONENT_Y);1897 YUVOut[1] = picColourRemapped.getAddr(COMPONENT_Cb);1898 YUVOut[2] = picColourRemapped.getAddr(COMPONENT_Cr);1899 1900 std::vector<Int> preLut[3];1901 std::vector<Int> postLut[3];1902 xInitColourRemappingLut( bitDpeths, preLut, postLut, &storeCriSEI[layerId] );1903 1904 Int roundingOffset = (storeCriSEI[layerId].m_log2MatrixDenom==0) ? 0 : (1 << (storeCriSEI[layerId].m_log2MatrixDenom - 1));1905 1906 for( Int y = 0; y < iHeight ; y++ )1907 {1908 for( Int x = 0; x < iWidth ; x++ )1909 {1910 Int YUVPre[3], YUVMat[3];1911 YUVPre[0] = preLut[0][ YUVIn[0][x] ];1912 YUVPre[1] = preLut[1][ YUVIn[1][x>>1] ];1913 YUVPre[2] = preLut[2][ YUVIn[2][x>>1] ];1914 1915 YUVMat[0] = ( storeCriSEI[layerId].m_colourRemapCoeffs[0][0]*YUVPre[0]1916 + storeCriSEI[layerId].m_colourRemapCoeffs[0][1]*YUVPre[1]1917 + storeCriSEI[layerId].m_colourRemapCoeffs[0][2]*YUVPre[2]1918 + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom );1919 YUVMat[0] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapBitDepth)-1, YUVMat[0] );1920 YUVOut[0][x] = postLut[0][ YUVMat[0] ];1921 1922 if( (y&1) && (x&1) )1923 {1924 for(Int c=1 ; c<3 ; c++)1925 {1926 YUVMat[c] = ( storeCriSEI[layerId].m_colourRemapCoeffs[c][0]*YUVPre[0]1927 + storeCriSEI[layerId].m_colourRemapCoeffs[c][1]*YUVPre[1]1928 + storeCriSEI[layerId].m_colourRemapCoeffs[c][2]*YUVPre[2]1929 + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom );1930 YUVMat[c] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapBitDepth)-1, YUVMat[c] );1931 YUVOut[c][x>>1] = postLut[c][ YUVMat[c] ];1932 }1933 }1934 }1935 YUVIn[0] += iStride;1936 YUVOut[0] += iStride;1937 if( y&1 )1938 {1939 YUVIn[1] += iCStride;1940 YUVIn[2] += iCStride;1941 YUVOut[1] += iCStride;1942 YUVOut[2] += iCStride;1943 }1944 }1945 1946 //Write remapped picture in decoding order1947 TChar cTemp[255];1948 sprintf(cTemp, "seiColourRemappedPic_L%d_%dx%d_%dbits.yuv", layerId, iWidth, iHeight, storeCriSEI[layerId].m_colourRemapBitDepth );1949 picColourRemapped.dump( cTemp, true, storeCriSEI[layerId].m_colourRemapBitDepth );1950 1951 picColourRemapped.destroy();1952 1953 storeCriSEI[layerId].m_colourRemapCancelFlag = !storeCriSEI[layerId].m_colourRemapPersistenceFlag; //Handling persistence1954 }1955 else1956 {1957 //Write no remapped picture in decoding order1958 if (storeCriSEI[layerId].m_colourRemapBitDepth == 8 || storeCriSEI[layerId].m_colourRemapBitDepth == 10)1959 {1960 TChar cTemp[255];1961 sprintf(cTemp, "seiColourRemappedPic_L%d_%dx%d_%dbits.yuv", layerId, pic.getWidth(COMPONENT_Y), pic.getHeight(COMPONENT_Y), storeCriSEI[layerId].m_colourRemapBitDepth );1962 pic.dump( cTemp, true, storeCriSEI[layerId].m_colourRemapBitDepth );1963 }1964 }1965 }1966 #endif1967 2045 //! \} -
branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.h
r1442 r1460 66 66 TDecTop* m_apcTDecTop[MAX_NUM_LAYER_IDS]; ///< decoder point class 67 67 TVideoIOYuv* m_apcTVideoIOYuvReconFile[MAX_NUM_LAYER_IDS]; ///< reconstruction YUV class 68 #if CONFORMANCE_BITSTREAM_MODE 69 TVideoIOYuv m_confReconFile[63]; ///< decode YUV files 70 #endif 71 // for output control 72 Int m_aiPOCLastDisplay [MAX_LAYERS]; ///< last POC in display order 68 73 #else 69 74 TDecTop m_cTDecTop; ///< decoder class 70 75 TVideoIOYuv m_cTVideoIOYuvReconFile; ///< reconstruction YUV class 76 77 // for output control 78 Int m_iPOCLastDisplay; ///< last POC in display order 71 79 #endif 72 73 // for output control 80 74 81 std::ofstream m_seiMessageFileStream; ///< Used for outputing SEI messages. 75 82 76 #if SVC_EXTENSION77 #if CONFORMANCE_BITSTREAM_MODE78 TVideoIOYuv m_confReconFile[63]; ///< decode YUV files79 #endif80 Int m_aiPOCLastDisplay [MAX_LAYERS]; ///< last POC in display order81 #else82 Int m_iPOCLastDisplay; ///< last POC in display order83 #endif84 83 #if Q0074_COLOUR_REMAPPING_SEI 85 std::vector<SEIColourRemappingInfo> storeCriSEI; //Persistent Colour Remapping Information SEI86 SEIColourRemappingInfo *seiColourRemappingInfoPrevious;84 SEIColourRemappingInfo* m_pcSeiColourRemappingInfoPrevious; 85 TComPicYuv* m_pcPicYuvColourRemapped; ///< Colour Remapped picture 87 86 #endif 88 87 … … 117 116 Void xDestroyDecLib (); ///< destroy internal classes 118 117 Void xInitDecLib (); ///< initialize decoder class 119 120 #if Q0074_COLOUR_REMAPPING_SEI 121 Void xInitColourRemappingLut( const BitDepths &bitDepths, std::vector<Int>(&preLut)[3], std::vector<Int>(&postLut)[3], const SEIColourRemappingInfo* const pCriSEI ); 122 Void xApplyColourRemapping( const TComSPS *sps, TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId = 0 ); 123 #endif 118 124 119 #if SVC_EXTENSION 125 120 Void xWriteOutput ( TComList<TComPic*>* pcListPic, UInt layerId, UInt tId ); ///< write YUV to file … … 130 125 #endif 131 126 Bool isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet 127 128 #if Q0074_COLOUR_REMAPPING_SEI 129 private: 130 Void applyColourRemapping(const TComPicYuv& pic, SEIColourRemappingInfo& pCriSEI, const TComSPS &activeSPS); 131 Void xOutputColourRemapPic(TComPic* pcPic, const TComSPS* activeSPS); 132 #endif 132 133 #if ALIGNED_BUMPING 133 134 Void checkOutputBeforeDecoding(Int layerIdx); -
branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp
r1459 r1460 774 774 Int* cfg_maxTidIlRefPicsPlus1[MAX_LAYERS]; 775 775 #if Q0074_COLOUR_REMAPPING_SEI 776 string* cfg_colourRemapSEIFile Name[MAX_LAYERS];776 string* cfg_colourRemapSEIFileRoot[MAX_LAYERS]; 777 777 #endif 778 778 Bool* cfg_entropyCodingSyncEnabledFlag[MAX_LAYERS]; … … 793 793 cfg_fQP[layer] = &m_apcLayerCfg[layer]->m_fQP; 794 794 #if Q0074_COLOUR_REMAPPING_SEI 795 cfg_colourRemapSEIFile Name[layer] = &m_apcLayerCfg[layer]->m_colourRemapSEIFileName;795 cfg_colourRemapSEIFileRoot[layer] = &m_apcLayerCfg[layer]->m_colourRemapSEIFileRoot; 796 796 #endif 797 797 cfg_repFormatIdx[layer] = &m_apcLayerCfg[layer]->m_repFormatIdx; … … 1073 1073 ("PhaseVerChroma%d", cfg_phaseVerChromaPtr, string(""), m_numLayers, "chroma shift in the vertical direction used in resampling proces") 1074 1074 #if Q0074_COLOUR_REMAPPING_SEI 1075 ("SEIColourRemappingInfoFileRoot%d ", cfg_colourRemapSEIFileName, string(""), m_numLayers, "Colour Remapping Information SEI parameters file name for layer %d")1075 ("SEIColourRemappingInfoFileRoot%d,-cri", cfg_colourRemapSEIFileRoot, string(""), m_numLayers, "Colour Remapping Information SEI parameters root file name (wo num ext)") 1076 1076 #endif 1077 1077 ("InputBitDepth%d", cfg_InputBitDepth[CHANNEL_TYPE_LUMA], 8, m_numLayers, "Bit-depth of input file for layer %d") … … 1141 1141 #if !SVC_EXTENSION 1142 1142 ("FrameRate,-fr", m_iFrameRate, 0, "Frame rate") 1143 #if Q0074_COLOUR_REMAPPING_SEI 1144 ("SEIColourRemappingInfoFileRoot", m_colourRemapSEIFileName, string(""), "Colour Remapping Information SEI parameters file name") 1145 #endif 1146 #endif //SVC_EXTENSION 1143 #endif 1147 1144 ("FrameSkip,-fs", m_FrameSkip, 0u, "Number of frames to skip at start of input YUV") 1148 1145 ("FramesToBeEncoded,f", m_framesToBeEncoded, 0, "Number of frames to be encoded (default=all)") … … 1462 1459 ("Log2MaxMvLengthHorizontal", m_log2MaxMvLengthHorizontal, 15, "Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units") 1463 1460 ("Log2MaxMvLengthVertical", m_log2MaxMvLengthVertical, 15, "Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units") 1461 #if !SVC_EXTENSION 1462 #if Q0074_COLOUR_REMAPPING_SEI 1463 ("SEIColourRemappingInfoFileRoot,-cri", m_colourRemapSEIFileRoot, string(""), "Colour Remapping Information SEI parameters root file name (wo num ext)") 1464 #endif 1465 #endif 1464 1466 ("SEIRecoveryPoint", m_recoveryPointSEIEnabled, false, "Control generation of recovery point SEI messages") 1465 1467 ("SEIBufferingPeriod", m_bufferingPeriodSEIEnabled, false, "Control generation of buffering period SEI messages") … … 1566 1568 ("SEIMasteringDisplayPrimaries", cfg_DisplayPrimariesCode, cfg_DisplayPrimariesCode, "Mastering display primaries for all three colour planes in CIE xy coordinates in increments of 1/50000 (results in the ranges 0 to 50000 inclusive)") 1567 1569 ("SEIMasteringDisplayWhitePoint", cfg_DisplayWhitePointCode, cfg_DisplayWhitePointCode, "Mastering display white point CIE xy coordinates in normalised increments of 1/50000 (e.g. 0.333 = 16667)") 1568 1570 1569 1571 #if LAYERS_NOT_PRESENT_SEI 1570 1572 ("SEILayersNotPresent", m_layersNotPresentSEIEnabled, 0, "Control generation of layers not present SEI message") -
branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h
r1459 r1460 457 457 Int m_log2MaxMvLengthHorizontal; ///< Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units 458 458 Int m_log2MaxMvLengthVertical; ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units 459 #if !SVC_EXTENSION 460 #if Q0074_COLOUR_REMAPPING_SEI 461 std::string m_colourRemapSEIFileRoot; 462 #endif 463 #endif 459 464 460 465 std::string m_summaryOutFilename; ///< filename to use for producing summary output file. … … 486 491 Bool m_elRapSliceBEnabled; 487 492 #endif 488 #if Q0074_COLOUR_REMAPPING_SEI 489 #if !SVC_EXTENSION 490 string m_colourRemapSEIFileName; 491 #endif 492 #endif 493 493 494 // internal member functions 494 495 #if SVC_EXTENSION -
branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp
r1451 r1460 31 31 , m_repFormatIdx(-1) 32 32 { 33 #if Q0074_COLOUR_REMAPPING_SEI34 memset( m_colourRemapSEIPreLutCodedValue, 0, sizeof(m_colourRemapSEIPreLutCodedValue) );35 memset( m_colourRemapSEIPreLutTargetValue, 0, sizeof(m_colourRemapSEIPreLutTargetValue) );36 memset( m_colourRemapSEIPostLutCodedValue, 0, sizeof(m_colourRemapSEIPostLutCodedValue) );37 memset( m_colourRemapSEIPostLutTargetValue, 0, sizeof(m_colourRemapSEIPostLutTargetValue) );38 #endif39 33 m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0; 40 34 m_aiPad[1] = m_aiPad[0] = 0; … … 64 58 delete[] m_aidQP; 65 59 } 66 #if Q0074_COLOUR_REMAPPING_SEI67 for( Int c=0 ; c<3 ; c++)68 {69 if ( m_colourRemapSEIPreLutCodedValue[c] )70 {71 delete[] m_colourRemapSEIPreLutCodedValue[c];72 }73 if ( m_colourRemapSEIPreLutTargetValue[c] )74 {75 delete[] m_colourRemapSEIPreLutTargetValue[c];76 }77 if ( m_colourRemapSEIPostLutCodedValue[c] )78 {79 delete[] m_colourRemapSEIPostLutCodedValue[c];80 }81 if ( m_colourRemapSEIPostLutTargetValue[c] )82 {83 delete[] m_colourRemapSEIPostLutTargetValue[c];84 }85 }86 #endif87 60 } 88 61 -
branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.h
r1459 r1460 135 135 Int m_repFormatIdx; 136 136 #if Q0074_COLOUR_REMAPPING_SEI 137 string m_colourRemapSEIFileName; ///< Colour Remapping Information SEI message parameters file 138 Int m_colourRemapSEIId; 139 Bool m_colourRemapSEICancelFlag; 140 Bool m_colourRemapSEIPersistenceFlag; 141 Bool m_colourRemapSEIVideoSignalInfoPresentFlag; 142 Bool m_colourRemapSEIFullRangeFlag; 143 Int m_colourRemapSEIPrimaries; 144 Int m_colourRemapSEITransferFunction; 145 Int m_colourRemapSEIMatrixCoefficients; 146 Int m_colourRemapSEIInputBitDepth; 147 Int m_colourRemapSEIBitDepth; 148 Int m_colourRemapSEIPreLutNumValMinus1[3]; 149 Int* m_colourRemapSEIPreLutCodedValue[3]; 150 Int* m_colourRemapSEIPreLutTargetValue[3]; 151 Bool m_colourRemapSEIMatrixPresentFlag; 152 Int m_colourRemapSEILog2MatrixDenom; 153 Int m_colourRemapSEICoeffs[3][3]; 154 Int m_colourRemapSEIPostLutNumValMinus1[3]; 155 Int* m_colourRemapSEIPostLutCodedValue[3]; 156 Int* m_colourRemapSEIPostLutTargetValue[3]; 137 string m_colourRemapSEIFileRoot; 157 138 #endif 158 139 -
branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
r1459 r1460 505 505 Bool& m_bUseSAO = m_apcLayerCfg[layer]->m_bUseSAO; 506 506 507 string& m_colourRemapSEIFileName = m_apcLayerCfg[layer]->m_colourRemapSEIFileName;508 509 507 GOPEntry* m_GOPList = m_apcLayerCfg[layer]->m_GOPList; 510 508 Int& m_extraRPSs = m_apcLayerCfg[layer]->m_extraRPSs; 511 509 Int& m_maxTempLayer = m_apcLayerCfg[layer]->m_maxTempLayer; 510 511 #if Q0074_COLOUR_REMAPPING_SEI 512 string& m_colourRemapSEIFileRoot = m_apcLayerCfg[layer]->m_colourRemapSEIFileRoot; 513 #endif 512 514 #endif 513 515 … … 542 544 m_cTEncTop.setGopList ( m_GOPList ); 543 545 m_cTEncTop.setExtraRPSs ( m_extraRPSs ); 544 545 546 for(Int i = 0; i < MAX_TLAYER; i++) 546 547 { … … 765 766 m_cTEncTop.setKneeSEIInputKneePoint ( m_kneeSEIInputKneePoint ); 766 767 m_cTEncTop.setKneeSEIOutputKneePoint ( m_kneeSEIOutputKneePoint ); 768 #if Q0074_COLOUR_REMAPPING_SEI 769 m_cTEncTop.setColourRemapInfoSEIFileRoot ( m_colourRemapSEIFileRoot ); 770 #endif 767 771 m_cTEncTop.setMasteringDisplaySEI ( m_masteringDisplay ); 768 772 … … 842 846 m_cTEncTop.setSummaryVerboseness ( m_summaryVerboseness ); 843 847 844 #if Q0074_COLOUR_REMAPPING_SEI845 m_cTEncTop.xSetCRISEIFileRoot ( m_colourRemapSEIFileName );846 #endif847 848 #if LAYERS_NOT_PRESENT_SEI 848 849 m_cTEncTop.setLayersNotPresentSEIEnabled ( m_layersNotPresentSEIEnabled ); -
branches/SHM-dev/source/Lib/TLibCommon/SEI.cpp
r1442 r1460 150 150 case SEI::CHROMA_RESAMPLING_FILTER_HINT: return "Chroma sampling filter hint"; 151 151 #if Q0074_COLOUR_REMAPPING_SEI 152 case SEI::COLOUR_REMAPPING_INFO: return "Colour Remapping Information";152 case SEI::COLOUR_REMAPPING_INFO: return "Colour remapping info"; 153 153 #endif 154 154 #if SVC_EXTENSION … … 196 196 } 197 197 #endif 198 199 #if Q0074_COLOUR_REMAPPING_SEI200 Void SEIColourRemappingInfo::copyFrom( SEIColourRemappingInfo const * SeiCriInput)201 {202 m_colourRemapId = SeiCriInput->m_colourRemapId;203 m_colourRemapCancelFlag = SeiCriInput->m_colourRemapCancelFlag;204 m_colourRemapPersistenceFlag = SeiCriInput->m_colourRemapPersistenceFlag;205 m_colourRemapVideoSignalInfoPresentFlag = SeiCriInput->m_colourRemapVideoSignalInfoPresentFlag;206 m_colourRemapFullRangeFlag = SeiCriInput->m_colourRemapFullRangeFlag;207 m_colourRemapPrimaries = SeiCriInput->m_colourRemapPrimaries;208 m_colourRemapTransferFunction = SeiCriInput->m_colourRemapTransferFunction;209 m_colourRemapMatrixCoefficients = SeiCriInput->m_colourRemapMatrixCoefficients;210 m_colourRemapInputBitDepth = SeiCriInput->m_colourRemapInputBitDepth;211 m_colourRemapBitDepth = SeiCriInput->m_colourRemapBitDepth;212 213 for( Int c=0 ; c<3 ; c++ )214 {215 m_preLutNumValMinus1[c] = SeiCriInput->m_preLutNumValMinus1[c];216 m_preLutCodedValue[c].resize(m_preLutNumValMinus1[c]+1);217 m_preLutTargetValue[c].resize(m_preLutNumValMinus1[c]+1);218 for ( Int i=0 ; i <= SeiCriInput->m_preLutNumValMinus1[c] ; i++ )219 {220 m_preLutCodedValue[c][i] = SeiCriInput->m_preLutCodedValue[c][i];221 m_preLutTargetValue[c][i] = SeiCriInput->m_preLutTargetValue[c][i];222 }223 }224 225 m_colourRemapMatrixPresentFlag = SeiCriInput->m_colourRemapMatrixPresentFlag;226 m_log2MatrixDenom = SeiCriInput->m_log2MatrixDenom;227 228 for ( Int c=0 ; c<3 ; c++ )229 for ( Int i=0 ; i<3 ; i++ )230 m_colourRemapCoeffs[c][i] = SeiCriInput->m_colourRemapCoeffs[c][i];231 232 for( Int c=0 ; c<3 ; c++ )233 {234 m_postLutNumValMinus1[c] = SeiCriInput->m_postLutNumValMinus1[c];235 m_postLutCodedValue[c].resize(m_postLutNumValMinus1[c]+1);236 m_postLutTargetValue[c].resize(m_postLutNumValMinus1[c]+1);237 for ( Int i=0 ; i <= m_postLutNumValMinus1[c] ; i++ )238 {239 m_postLutCodedValue[c][i] = SeiCriInput->m_postLutCodedValue[c][i];240 m_postLutTargetValue[c][i] = SeiCriInput->m_postLutTargetValue[c][i];241 }242 }243 }244 #endif -
branches/SHM-dev/source/Lib/TLibCommon/SEI.h
r1459 r1460 459 459 }; 460 460 461 #if Q0074_COLOUR_REMAPPING_SEI 462 class SEIColourRemappingInfo : public SEI 463 { 464 public: 465 466 struct CRIlut 467 { 468 Int codedValue; 469 Int targetValue; 470 bool operator < (const CRIlut& a) const 471 { 472 return codedValue < a.codedValue; 473 } 474 }; 475 476 PayloadType payloadType() const { return COLOUR_REMAPPING_INFO; } 477 SEIColourRemappingInfo() {} 478 ~SEIColourRemappingInfo() {} 479 480 Void copyFrom( const SEIColourRemappingInfo &seiCriInput) 481 { 482 (*this) = seiCriInput; 483 } 484 485 UInt m_colourRemapId; 486 Bool m_colourRemapCancelFlag; 487 Bool m_colourRemapPersistenceFlag; 488 Bool m_colourRemapVideoSignalInfoPresentFlag; 489 Bool m_colourRemapFullRangeFlag; 490 Int m_colourRemapPrimaries; 491 Int m_colourRemapTransferFunction; 492 Int m_colourRemapMatrixCoefficients; 493 Int m_colourRemapInputBitDepth; 494 Int m_colourRemapBitDepth; 495 Int m_preLutNumValMinus1[3]; 496 std::vector<CRIlut> m_preLut[3]; 497 Bool m_colourRemapMatrixPresentFlag; 498 Int m_log2MatrixDenom; 499 Int m_colourRemapCoeffs[3][3]; 500 Int m_postLutNumValMinus1[3]; 501 std::vector<CRIlut> m_postLut[3]; 502 }; 503 #endif 504 461 505 class SEIChromaResamplingFilterHint : public SEI 462 506 { … … 673 717 #endif 674 718 675 #if Q0074_COLOUR_REMAPPING_SEI676 struct TComSEIColourRemappingInfo677 {678 std::string m_colourRemapSEIFile;679 Int m_colourRemapSEIId;680 Bool m_colourRemapSEICancelFlag;681 Bool m_colourRemapSEIPersistenceFlag;682 Bool m_colourRemapSEIVideoSignalInfoPresentFlag;683 Bool m_colourRemapSEIFullRangeFlag;684 Int m_colourRemapSEIPrimaries;685 Int m_colourRemapSEITransferFunction;686 Int m_colourRemapSEIMatrixCoefficients;687 Int m_colourRemapSEIInputBitDepth;688 Int m_colourRemapSEIBitDepth;689 Int m_colourRemapSEIPreLutNumValMinus1[3];690 Int* m_colourRemapSEIPreLutCodedValue[3];691 Int* m_colourRemapSEIPreLutTargetValue[3];692 Bool m_colourRemapSEIMatrixPresentFlag;693 Int m_colourRemapSEILog2MatrixDenom;694 Int m_colourRemapSEICoeffs[3][3];695 Int m_colourRemapSEIPostLutNumValMinus1[3];696 Int* m_colourRemapSEIPostLutCodedValue[3];697 Int* m_colourRemapSEIPostLutTargetValue[3];698 };699 700 class SEIColourRemappingInfo : public SEI701 {702 public:703 PayloadType payloadType() const { return COLOUR_REMAPPING_INFO; }704 SEIColourRemappingInfo() {}705 ~SEIColourRemappingInfo() {}706 707 Void copyFrom( SEIColourRemappingInfo const * SeiCriInput);708 709 Int m_colourRemapId;710 Bool m_colourRemapCancelFlag;711 Bool m_colourRemapPersistenceFlag;712 Bool m_colourRemapVideoSignalInfoPresentFlag;713 Bool m_colourRemapFullRangeFlag;714 Int m_colourRemapPrimaries;715 Int m_colourRemapTransferFunction;716 Int m_colourRemapMatrixCoefficients;717 Int m_colourRemapInputBitDepth;718 Int m_colourRemapBitDepth;719 Int m_preLutNumValMinus1[3];720 std::vector<Int> m_preLutCodedValue[3];721 std::vector<Int> m_preLutTargetValue[3];722 Bool m_colourRemapMatrixPresentFlag;723 Int m_log2MatrixDenom;724 Int m_colourRemapCoeffs[3][3];725 Int m_postLutNumValMinus1[3];726 std::vector<Int> m_postLutCodedValue[3];727 std::vector<Int> m_postLutTargetValue[3];728 };729 #endif730 731 719 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 732 720 class SEIInterLayerConstrainedTileSets : public SEI -
branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.cpp
r1442 r1460 296 296 297 297 // NOTE: This function is never called, but may be useful for developers. 298 Void TComPicYuv::dump (const std::string &fileName, const BitDepths &bitDepths, Bool bAdd) const 299 { 300 FILE* pFile = fopen (fileName.c_str(), bAdd?"ab":"wb"); 298 Void TComPicYuv::dump (const std::string &fileName, const BitDepths &bitDepths, const Bool bAppend, const Bool bForceTo8Bit) const 299 { 300 FILE *pFile = fopen (fileName.c_str(), bAppend?"ab":"wb"); 301 302 Bool is16bit=false; 303 for(Int comp = 0; comp < getNumberValidComponents() && !bForceTo8Bit; comp++) 304 { 305 if (bitDepths.recon[toChannelType(ComponentID(comp))]>8) 306 { 307 is16bit=true; 308 } 309 } 301 310 302 311 for(Int comp = 0; comp < getNumberValidComponents(); comp++) 303 312 { 304 313 const ComponentID compId = ComponentID(comp); 305 const Int shift = bitDepths.recon[toChannelType(compId)] - 8;306 const Int offset = (shift>0)?(1<<(shift-1)):0;307 314 const Pel *pi = getAddr(compId); 308 315 const Int stride = getStride(compId); … … 310 317 const Int width = getWidth(compId); 311 318 312 for (Int y = 0; y < height; y++ ) 313 { 314 for (Int x = 0; x < width; x++ ) 315 { 316 UChar uc = (UChar)Clip3<Pel>(0, 255, (pi[x]+offset)>>shift); 317 fwrite( &uc, sizeof(UChar), 1, pFile ); 318 } 319 pi += stride; 320 } 321 } 322 323 fclose(pFile); 324 } 325 326 Void TComPicYuv::dump( const std::string &fileName, const Bool bAdd, const Int bitDepth ) 327 { 328 FILE* pFile = fopen (fileName.c_str(), bAdd?"ab":"wb"); 329 330 if( bitDepth == 8 ) 331 { 332 dump( fileName, bitDepth, bAdd ); 333 return; 334 } 335 336 for(Int chan = 0; chan < getNumberValidComponents(); chan++) 337 { 338 const ComponentID ch = ComponentID(chan); 339 const Pel *pi = getAddr(ch); 340 const Int stride = getStride(ch); 341 const Int height = getHeight(ch); 342 const Int width = getWidth(ch); 343 344 for (Int y = 0; y < height; y++ ) 345 { 346 for (Int x = 0; x < width; x++ ) 347 { 348 Pel pix = pi[x]; 349 350 UChar uc = pix & 0xff; 351 fwrite( &uc, sizeof(UChar), 1, pFile ); 352 uc = (pix >> 8) & 0xff; 353 fwrite( &uc, sizeof(UChar), 1, pFile ); 354 } 355 pi += stride; 356 } 357 } 358 319 if (is16bit) 320 { 321 for (Int y = 0; y < height; y++ ) 322 { 323 for (Int x = 0; x < width; x++ ) 324 { 325 UChar uc = (UChar)((pi[x]>>0) & 0xff); 326 fwrite( &uc, sizeof(UChar), 1, pFile ); 327 uc = (UChar)((pi[x]>>8) & 0xff); 328 fwrite( &uc, sizeof(UChar), 1, pFile ); 329 } 330 pi += stride; 331 } 332 } 333 else 334 { 335 const Int shift = bitDepths.recon[toChannelType(compId)] - 8; 336 const Int offset = (shift>0)?(1<<(shift-1)):0; 337 for (Int y = 0; y < height; y++ ) 338 { 339 for (Int x = 0; x < width; x++ ) 340 { 341 UChar uc = (UChar)Clip3<Pel>(0, 255, (pi[x]+offset)>>shift); 342 fwrite( &uc, sizeof(UChar), 1, pFile ); 343 } 344 pi += stride; 345 } 346 } 347 } 348 359 349 fclose(pFile); 360 350 } -
branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.h
r1442 r1460 180 180 181 181 // Dump picture 182 Void dump (const std::string &fileName, const BitDepths &bitDepths, Bool bAdd =false) const ;182 Void dump (const std::string &fileName, const BitDepths &bitDepths, const Bool bAppend=false, const Bool bForceTo8Bit=false) const ; 183 183 184 184 // Set border extension flag … … 196 196 #endif 197 197 198 Void dump( const std::string &fileName, const Bool bAdd, const Int bitDepth );199 200 198 };// END CLASS DEFINITION TComPicYuv 201 199 -
branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
r1459 r1460 127 127 128 128 #endif // SVC_EXTENSION 129 #define Q0074_COLOUR_REMAPPING_SEI 1 ///< JCTVC-Q0074, JCTVC-R0344: SEI Colour Remapping Information130 129 131 130 //! \ingroup TLibCommon … … 166 165 #define T0196_SELECTIVE_RDOQ 1 ///< selective RDOQ 167 166 #define U0040_MODIFIED_WEIGHTEDPREDICTION_WITH_BIPRED_AND_CLIPPING 1 167 #define Q0074_COLOUR_REMAPPING_SEI 1 ///< JCTVC-Q0074, JCTVC-R0344: SEI Colour Remapping Information 168 168 169 169 // ==================================================================================================================== … … 377 377 NUMBER_INPUT_COLOUR_SPACE_CONVERSIONS = 4 378 378 }; 379 380 #if Q0074_COLOUR_REMAPPING_SEI 381 enum MATRIX_COEFFICIENTS // Table E.5 (Matrix coefficients) 382 { 383 MATRIX_COEFFICIENTS_RGB = 0, 384 MATRIX_COEFFICIENTS_BT709 = 1, 385 MATRIX_COEFFICIENTS_UNSPECIFIED = 2, 386 MATRIX_COEFFICIENTS_RESERVED_BY_ITUISOIEC = 3, 387 MATRIX_COEFFICIENTS_USFCCT47 = 4, 388 MATRIX_COEFFICIENTS_BT601_625 = 5, 389 MATRIX_COEFFICIENTS_BT601_525 = 6, 390 MATRIX_COEFFICIENTS_SMPTE240 = 7, 391 MATRIX_COEFFICIENTS_YCGCO = 8, 392 MATRIX_COEFFICIENTS_BT2020_NON_CONSTANT_LUMINANCE = 9, 393 MATRIX_COEFFICIENTS_BT2020_CONSTANT_LUMINANCE = 10, 394 }; 395 #endif 379 396 380 397 enum DeblockEdgeDir -
branches/SHM-dev/source/Lib/TLibDecoder/SEIread.cpp
r1459 r1460 308 308 xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 309 309 break; 310 case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:311 sei = new SEIMasteringDisplayColourVolume;312 xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream);313 break;314 310 #if Q0074_COLOUR_REMAPPING_SEI 315 311 case SEI::COLOUR_REMAPPING_INFO: … … 318 314 break; 319 315 #endif 316 case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: 317 sei = new SEIMasteringDisplayColourVolume; 318 xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream); 319 break; 320 320 #if SVC_EXTENSION 321 321 #if LAYERS_NOT_PRESENT_SEI … … 1335 1335 } 1336 1336 1337 Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)1338 {1339 UInt code;1340 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);1341 1342 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code;1343 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code;1344 1345 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code;1346 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code;1347 1348 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code;1349 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code;1350 1351 1352 sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code;1353 sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code;1354 1355 sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code;1356 sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code;1357 }1358 1359 1337 #if Q0074_COLOUR_REMAPPING_SEI 1360 Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt /*payloadSize*/, std::ostream *pDecodedMessageOutputStream)1338 Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 1361 1339 { 1362 1340 UInt uiVal; 1363 1341 Int iVal; 1342 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1364 1343 1365 1344 sei_read_uvlc( pDecodedMessageOutputStream, uiVal, "colour_remap_id" ); sei.m_colourRemapId = uiVal; … … 1371 1350 if ( sei.m_colourRemapVideoSignalInfoPresentFlag ) 1372 1351 { 1373 sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_full_range_flag" ); sei.m_colourRemapFullRangeFlag = uiVal;1374 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_primaries" ); sei.m_colourRemapPrimaries = uiVal;1375 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_transfer_function" ); sei.m_colourRemapTransferFunction = uiVal;1376 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_matrix_coefficients" ); sei.m_colourRemapMatrixCoefficients = uiVal;1377 } 1378 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal;1379 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal;1352 sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_full_range_flag" ); sei.m_colourRemapFullRangeFlag = uiVal; 1353 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_primaries" ); sei.m_colourRemapPrimaries = uiVal; 1354 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_transfer_function" ); sei.m_colourRemapTransferFunction = uiVal; 1355 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_matrix_coefficients" ); sei.m_colourRemapMatrixCoefficients = uiVal; 1356 } 1357 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal; 1358 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal; 1380 1359 1381 1360 for( Int c=0 ; c<3 ; c++ ) 1382 1361 { 1383 1362 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; 1384 sei.m_preLutCodedValue[c].resize(sei.m_preLutNumValMinus1[c]+1); 1385 sei.m_preLutTargetValue[c].resize(sei.m_preLutNumValMinus1[c]+1); 1363 sei.m_preLut[c].resize(sei.m_preLutNumValMinus1[c]+1); 1386 1364 if( uiVal> 0 ) 1365 { 1387 1366 for ( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) 1388 1367 { 1389 sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" ); sei.m_preLutCodedValue[c][i] = uiVal; 1390 sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLutTargetValue[c][i] = uiVal; 1391 } 1368 sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" ); sei.m_preLut[c][i].codedValue = uiVal; 1369 sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLut[c][i].targetValue = uiVal; 1370 } 1371 } 1392 1372 else // pre_lut_num_val_minus1[c] == 0 1393 1373 { 1394 sei.m_preLut CodedValue[c][0]= 0;1395 sei.m_preLut TargetValue[c][0]= 0;1396 sei.m_preLut CodedValue[c][1]= (1 << sei.m_colourRemapInputBitDepth) - 1 ;1397 sei.m_preLut TargetValue[c][1]= (1 << sei.m_colourRemapBitDepth) - 1 ;1374 sei.m_preLut[c][0].codedValue = 0; 1375 sei.m_preLut[c][0].targetValue = 0; 1376 sei.m_preLut[c][1].codedValue = (1 << sei.m_colourRemapInputBitDepth) - 1 ; 1377 sei.m_preLut[c][1].targetValue = (1 << sei.m_colourRemapBitDepth) - 1 ; 1398 1378 } 1399 1379 } … … 1404 1384 sei_read_code( pDecodedMessageOutputStream, 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal; 1405 1385 for ( Int c=0 ; c<3 ; c++ ) 1386 { 1406 1387 for ( Int i=0 ; i<3 ; i++ ) 1407 1388 { 1408 1389 sei_read_svlc( pDecodedMessageOutputStream, iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal; 1409 1390 } 1391 } 1410 1392 } 1411 1393 else // setting default matrix (I3) 1412 1394 { 1413 sei.m_log2MatrixDenom = 0;1395 sei.m_log2MatrixDenom = 10; 1414 1396 for ( Int c=0 ; c<3 ; c++ ) 1397 { 1415 1398 for ( Int i=0 ; i<3 ; i++ ) 1416 sei.m_colourRemapCoeffs[c][i] = (c==i) ? 1 : 0; 1399 { 1400 sei.m_colourRemapCoeffs[c][i] = (c==i) << sei.m_log2MatrixDenom; 1401 } 1402 } 1417 1403 } 1418 1404 for( Int c=0 ; c<3 ; c++ ) 1419 1405 { 1420 1406 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; 1421 sei.m_postLutCodedValue[c].resize(sei.m_postLutNumValMinus1[c]+1); 1422 sei.m_postLutTargetValue[c].resize(sei.m_postLutNumValMinus1[c]+1); 1407 sei.m_postLut[c].resize(sei.m_postLutNumValMinus1[c]+1); 1423 1408 if( uiVal > 0 ) 1409 { 1424 1410 for ( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) 1425 1411 { 1426 sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" ); sei.m_postLutCodedValue[c][i] = uiVal; 1427 sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLutTargetValue[c][i] = uiVal; 1428 } 1412 sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" ); sei.m_postLut[c][i].codedValue = uiVal; 1413 sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLut[c][i].targetValue = uiVal; 1414 } 1415 } 1429 1416 else 1430 1417 { 1431 sei.m_postLutCodedValue[c][0] = 0; 1432 sei.m_postLutTargetValue[c][0] = 0; 1433 sei.m_postLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1; 1434 sei.m_postLutCodedValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1; 1435 } 1436 } 1437 } 1438 } 1439 #endif 1440 1418 sei.m_postLut[c][0].codedValue = 0; 1419 sei.m_postLut[c][0].targetValue = 0; 1420 sei.m_postLut[c][1].targetValue = (1 << sei.m_colourRemapBitDepth) - 1; 1421 sei.m_postLut[c][1].codedValue = (1 << sei.m_colourRemapBitDepth) - 1; 1422 } 1423 } 1424 } 1425 } 1426 #endif 1427 1428 Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 1429 { 1430 UInt code; 1431 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1432 1433 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code; 1434 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code; 1435 1436 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code; 1437 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code; 1438 1439 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code; 1440 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code; 1441 1442 1443 sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code; 1444 sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code; 1445 1446 sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code; 1447 sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code; 1448 } 1441 1449 1442 1450 #if SVC_EXTENSION -
branches/SHM-dev/source/Lib/TLibDecoder/SEIread.h
r1442 r1460 108 108 Void xParseSEIKneeFunctionInfo (SEIKneeFunctionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 109 109 Void xParseSEIMasteringDisplayColourVolume (SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 110 #if Q0074_COLOUR_REMAPPING_SEI 111 Void xParseSEIColourRemappingInfo (SEIColourRemappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 112 #endif 110 113 111 114 Void sei_read_code(std::ostream *pOS, UInt uiLength, UInt& ruiCode, const TChar *pSymbolName); … … 114 117 Void sei_read_flag(std::ostream *pOS, UInt& ruiCode, const TChar *pSymbolName); 115 118 116 #if Q0074_COLOUR_REMAPPING_SEI117 Void xParseSEIColourRemappingInfo (SEIColourRemappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream);118 #endif119 119 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 120 120 Void xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); -
branches/SHM-dev/source/Lib/TLibEncoder/SEIEncoder.cpp
r1459 r1460 421 421 } 422 422 423 #if Q0074_COLOUR_REMAPPING_SEI 424 template <typename T> 425 static Void readTokenValue(T &returnedValue, /// value returned 426 Bool &failed, /// used and updated 427 std::istream &is, /// stream to read token from 428 const TChar *pToken) /// token string 429 { 430 returnedValue=T(); 431 if (failed) 432 { 433 return; 434 } 435 436 Int c; 437 // Ignore any whitespace 438 while ((c=is.get())!=EOF && isspace(c)); 439 // test for comment mark 440 while (c=='#') 441 { 442 // Ignore to the end of the line 443 while ((c=is.get())!=EOF && (c!=10 && c!=13)); 444 // Ignore any white space at the start of the next line 445 while ((c=is.get())!=EOF && isspace(c)); 446 } 447 // test first character of token 448 failed=(c!=pToken[0]); 449 // test remaining characters of token 450 Int pos; 451 for(pos=1;!failed && pToken[pos]!=0 && is.get()==pToken[pos]; pos++); 452 failed|=(pToken[pos]!=0); 453 // Ignore any whitespace before the ':' 454 while (!failed && (c=is.get())!=EOF && isspace(c)); 455 failed|=(c!=':'); 456 // Now read the value associated with the token: 457 if (!failed) 458 { 459 is >> returnedValue; 460 failed=!is.good(); 461 if (!failed) 462 { 463 c=is.get(); 464 failed=(c!=EOF && !isspace(c)); 465 } 466 } 467 if (failed) 468 { 469 std::cerr << "Unable to read token '" << pToken << "'\n"; 470 } 471 } 472 473 template <typename T> 474 static Void readTokenValueAndValidate(T &returnedValue, /// value returned 475 Bool &failed, /// used and updated 476 std::istream &is, /// stream to read token from 477 const TChar *pToken, /// token string 478 const T &minInclusive, /// minimum value allowed, inclusive 479 const T &maxInclusive) /// maximum value allowed, inclusive 480 { 481 readTokenValue(returnedValue, failed, is, pToken); 482 if (!failed) 483 { 484 if (returnedValue<minInclusive || returnedValue>maxInclusive) 485 { 486 failed=true; 487 std::cerr << "Value for token " << pToken << " must be in the range " << minInclusive << " to " << maxInclusive << " (inclusive); value read: " << returnedValue << std::endl; 488 } 489 } 490 } 491 492 // Bool version does not have maximum and minimum values. 493 static Void readTokenValueAndValidate(Bool &returnedValue, /// value returned 494 Bool &failed, /// used and updated 495 std::istream &is, /// stream to read token from 496 const TChar *pToken) /// token string 497 { 498 readTokenValue(returnedValue, failed, is, pToken); 499 } 500 501 Bool SEIEncoder::initSEIColourRemappingInfo(SEIColourRemappingInfo* seiColourRemappingInfo, Int currPOC) // returns true on success, false on failure. 502 { 503 assert (m_isInitialized); 504 assert (seiColourRemappingInfo!=NULL); 505 506 // reading external Colour Remapping Information SEI message parameters from file 507 if( !m_pcCfg->getColourRemapInfoSEIFileRoot().empty()) 508 { 509 Bool failed=false; 510 511 // building the CRI file name with poc num in prefix "_poc.txt" 512 std::string colourRemapSEIFileWithPoc(m_pcCfg->getColourRemapInfoSEIFileRoot()); 513 { 514 std::stringstream suffix; 515 suffix << "_" << currPOC << ".txt"; 516 colourRemapSEIFileWithPoc+=suffix.str(); 517 } 518 519 std::ifstream fic(colourRemapSEIFileWithPoc.c_str()); 520 if (!fic.good() || !fic.is_open()) 521 { 522 std::cerr << "No Colour Remapping Information SEI parameters file " << colourRemapSEIFileWithPoc << " for POC " << currPOC << std::endl; 523 return false; 524 } 525 526 // TODO: identify and remove duplication with decoder parsing through abstraction. 527 528 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapId, failed, fic, "colour_remap_id", UInt(0), UInt(0x7fffffff) ); 529 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapCancelFlag, failed, fic, "colour_remap_cancel_flag" ); 530 if( !seiColourRemappingInfo->m_colourRemapCancelFlag ) 531 { 532 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapPersistenceFlag, failed, fic, "colour_remap_persistence_flag" ); 533 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag, failed, fic, "colour_remap_video_signal_info_present_flag"); 534 if( seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag ) 535 { 536 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapFullRangeFlag, failed, fic, "colour_remap_full_range_flag" ); 537 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapPrimaries, failed, fic, "colour_remap_primaries", Int(0), Int(255) ); 538 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapTransferFunction, failed, fic, "colour_remap_transfer_function", Int(0), Int(255) ); 539 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapMatrixCoefficients, failed, fic, "colour_remap_matrix_coefficients", Int(0), Int(255) ); 540 } 541 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapInputBitDepth, failed, fic, "colour_remap_input_bit_depth", Int(8), Int(16) ); 542 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapBitDepth, failed, fic, "colour_remap_bit_depth", Int(8), Int(16) ); 543 544 const Int maximumInputValue = (1<<seiColourRemappingInfo->m_colourRemapInputBitDepth)-1; 545 const Int maximumRemappedValue = (1<<seiColourRemappingInfo->m_colourRemapBitDepth)-1; 546 547 for( Int c=0 ; c<3 ; c++ ) 548 { 549 readTokenValueAndValidate(seiColourRemappingInfo->m_preLutNumValMinus1[c], failed, fic, "pre_lut_num_val_minus1[c]", Int(0), Int(32) ); 550 if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 ) 551 { 552 seiColourRemappingInfo->m_preLut[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1); 553 for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++ ) 554 { 555 readTokenValueAndValidate(seiColourRemappingInfo->m_preLut[c][i].codedValue, failed, fic, "pre_lut_coded_value[c][i]", Int(0), maximumInputValue ); 556 readTokenValueAndValidate(seiColourRemappingInfo->m_preLut[c][i].targetValue, failed, fic, "pre_lut_target_value[c][i]", Int(0), maximumRemappedValue ); 557 } 558 } 559 } 560 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapMatrixPresentFlag, failed, fic, "colour_remap_matrix_present_flag" ); 561 if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag ) 562 { 563 readTokenValueAndValidate(seiColourRemappingInfo->m_log2MatrixDenom, failed, fic, "log2_matrix_denom", Int(0), Int(15) ); 564 for( Int c=0 ; c<3 ; c++ ) 565 { 566 for( Int i=0 ; i<3 ; i++ ) 567 { 568 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapCoeffs[c][i], failed, fic, "colour_remap_coeffs[c][i]", -32768, 32767 ); 569 } 570 } 571 } 572 for( Int c=0 ; c<3 ; c++ ) 573 { 574 readTokenValueAndValidate(seiColourRemappingInfo->m_postLutNumValMinus1[c], failed, fic, "post_lut_num_val_minus1[c]", Int(0), Int(32) ); 575 if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 ) 576 { 577 seiColourRemappingInfo->m_postLut[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1); 578 for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++ ) 579 { 580 readTokenValueAndValidate(seiColourRemappingInfo->m_postLut[c][i].codedValue, failed, fic, "post_lut_coded_value[c][i]", Int(0), maximumRemappedValue ); 581 readTokenValueAndValidate(seiColourRemappingInfo->m_postLut[c][i].targetValue, failed, fic, "post_lut_target_value[c][i]", Int(0), maximumRemappedValue ); 582 } 583 } 584 } 585 } 586 587 if( failed ) 588 { 589 std::cerr << "Error while reading Colour Remapping Information SEI parameters file '" << colourRemapSEIFileWithPoc << "'" << std::endl; 590 exit(EXIT_FAILURE); 591 } 592 } 593 return true; 594 } 595 #endif 596 423 597 Void SEIEncoder::initSEIChromaResamplingFilterHint(SEIChromaResamplingFilterHint *seiChromaResamplingFilterHint, Int iHorFilterIndex, Int iVerFilterIndex) 424 598 { … … 646 820 #endif 647 821 648 #if Q0074_COLOUR_REMAPPING_SEI649 Void SEIEncoder::initSEIColourRemappingInfo(SEIColourRemappingInfo *seiColourRemappingInfo, TComSEIColourRemappingInfo* cfgSeiColourRemappingInfo)650 {651 seiColourRemappingInfo->m_colourRemapId = cfgSeiColourRemappingInfo->m_colourRemapSEIId;652 seiColourRemappingInfo->m_colourRemapCancelFlag = cfgSeiColourRemappingInfo->m_colourRemapSEICancelFlag;653 printf("xCreateSEIColourRemappingInfo - m_colourRemapId = %d m_colourRemapCancelFlag = %d \n",seiColourRemappingInfo->m_colourRemapId, seiColourRemappingInfo->m_colourRemapCancelFlag);654 655 if( !seiColourRemappingInfo->m_colourRemapCancelFlag )656 {657 seiColourRemappingInfo->m_colourRemapPersistenceFlag = cfgSeiColourRemappingInfo->m_colourRemapSEIPersistenceFlag;658 seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag = cfgSeiColourRemappingInfo->m_colourRemapSEIVideoSignalInfoPresentFlag;659 if( seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag )660 {661 seiColourRemappingInfo->m_colourRemapFullRangeFlag = cfgSeiColourRemappingInfo->m_colourRemapSEIFullRangeFlag;662 seiColourRemappingInfo->m_colourRemapPrimaries = cfgSeiColourRemappingInfo->m_colourRemapSEIPrimaries;663 seiColourRemappingInfo->m_colourRemapTransferFunction = cfgSeiColourRemappingInfo->m_colourRemapSEITransferFunction;664 seiColourRemappingInfo->m_colourRemapMatrixCoefficients = cfgSeiColourRemappingInfo->m_colourRemapSEIMatrixCoefficients;665 }666 seiColourRemappingInfo->m_colourRemapInputBitDepth = cfgSeiColourRemappingInfo->m_colourRemapSEIInputBitDepth;667 seiColourRemappingInfo->m_colourRemapBitDepth = cfgSeiColourRemappingInfo->m_colourRemapSEIBitDepth;668 for( Int c=0 ; c<3 ; c++ )669 {670 seiColourRemappingInfo->m_preLutNumValMinus1[c] = cfgSeiColourRemappingInfo->m_colourRemapSEIPreLutNumValMinus1[c];671 if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 )672 {673 seiColourRemappingInfo->m_preLutCodedValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1);674 seiColourRemappingInfo->m_preLutTargetValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1);675 for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++)676 {677 seiColourRemappingInfo->m_preLutCodedValue[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEIPreLutCodedValue[c][i];678 seiColourRemappingInfo->m_preLutTargetValue[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEIPreLutTargetValue[c][i];679 }680 }681 }682 seiColourRemappingInfo->m_colourRemapMatrixPresentFlag = cfgSeiColourRemappingInfo->m_colourRemapSEIMatrixPresentFlag;683 if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag )684 {685 seiColourRemappingInfo->m_log2MatrixDenom = cfgSeiColourRemappingInfo->m_colourRemapSEILog2MatrixDenom;686 for( Int c=0 ; c<3 ; c++ )687 for( Int i=0 ; i<3 ; i++ )688 seiColourRemappingInfo->m_colourRemapCoeffs[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEICoeffs[c][i];689 }690 for( Int c=0 ; c<3 ; c++ )691 {692 seiColourRemappingInfo->m_postLutNumValMinus1[c] = cfgSeiColourRemappingInfo->m_colourRemapSEIPostLutNumValMinus1[c];693 if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 )694 {695 seiColourRemappingInfo->m_postLutCodedValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1);696 seiColourRemappingInfo->m_postLutTargetValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1);697 for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++)698 {699 seiColourRemappingInfo->m_postLutCodedValue[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEIPostLutCodedValue[c][i];700 seiColourRemappingInfo->m_postLutTargetValue[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEIPostLutTargetValue[c][i];701 }702 }703 }704 }705 }706 #endif707 708 709 822 #if O0164_MULTI_LAYER_HRD 710 823 Void SEIEncoder::initBspNestingSEI(SEIScalableNesting *seiScalableNesting, const TComVPS *vps, const TComSPS *sps, Int olsIdx, Int partitioningSchemeIdx, Int bspIdx) -
branches/SHM-dev/source/Lib/TLibEncoder/SEIEncoder.h
r1434 r1460 81 81 Void initSEIChromaResamplingFilterHint(SEIChromaResamplingFilterHint *sei, Int iHorFilterIndex, Int iVerFilterIndex); 82 82 Void initSEITimeCode(SEITimeCode *sei); 83 #if Q0074_COLOUR_REMAPPING_SEI 84 Bool initSEIColourRemappingInfo(SEIColourRemappingInfo *sei, Int currPOC); // returns true on success, false on failure. 85 #endif 83 86 84 87 #if LAYERS_NOT_PRESENT_SEI … … 93 96 #if Q0096_OVERLAY_SEI 94 97 Void initSEIOverlayInfo(SEIOverlayInfo *seiOverlayInfo); 95 #endif96 #if Q0074_COLOUR_REMAPPING_SEI97 Void initSEIColourRemappingInfo(SEIColourRemappingInfo *seiColourRemappingInfo, TComSEIColourRemappingInfo* cfgSeiColourRemappingInfo);98 98 #endif 99 99 #if O0164_MULTI_LAYER_HRD -
branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.cpp
r1459 r1460 152 152 xWriteSEIKneeFunctionInfo(*static_cast<const SEIKneeFunctionInfo*>(&sei)); 153 153 break; 154 case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:155 xWriteSEIMasteringDisplayColourVolume(*static_cast<const SEIMasteringDisplayColourVolume*>(&sei));156 break;157 154 #if Q0074_COLOUR_REMAPPING_SEI 158 155 case SEI::COLOUR_REMAPPING_INFO: … … 160 157 break; 161 158 #endif 159 case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: 160 xWriteSEIMasteringDisplayColourVolume(*static_cast<const SEIMasteringDisplayColourVolume*>(&sei)); 161 break; 162 162 #if SVC_EXTENSION 163 163 #if LAYERS_NOT_PRESENT_SEI … … 987 987 } 988 988 989 #if Q0074_COLOUR_REMAPPING_SEI 990 Void SEIWriter::xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei) 991 { 992 WRITE_UVLC( sei.m_colourRemapId, "colour_remap_id" ); 993 WRITE_FLAG( sei.m_colourRemapCancelFlag, "colour_remap_cancel_flag" ); 994 if( !sei.m_colourRemapCancelFlag ) 995 { 996 WRITE_FLAG( sei.m_colourRemapPersistenceFlag, "colour_remap_persistence_flag" ); 997 WRITE_FLAG( sei.m_colourRemapVideoSignalInfoPresentFlag, "colour_remap_video_signal_info_present_flag" ); 998 if ( sei.m_colourRemapVideoSignalInfoPresentFlag ) 999 { 1000 WRITE_FLAG( sei.m_colourRemapFullRangeFlag, "colour_remap_full_range_flag" ); 1001 WRITE_CODE( sei.m_colourRemapPrimaries, 8, "colour_remap_primaries" ); 1002 WRITE_CODE( sei.m_colourRemapTransferFunction, 8, "colour_remap_transfer_function" ); 1003 WRITE_CODE( sei.m_colourRemapMatrixCoefficients, 8, "colour_remap_matrix_coefficients" ); 1004 } 1005 WRITE_CODE( sei.m_colourRemapInputBitDepth, 8, "colour_remap_input_bit_depth" ); 1006 WRITE_CODE( sei.m_colourRemapBitDepth, 8, "colour_remap_bit_depth" ); 1007 for( Int c=0 ; c<3 ; c++ ) 1008 { 1009 WRITE_CODE( sei.m_preLutNumValMinus1[c], 8, "pre_lut_num_val_minus1[c]" ); 1010 if( sei.m_preLutNumValMinus1[c]>0 ) 1011 { 1012 for( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) 1013 { 1014 WRITE_CODE( sei.m_preLut[c][i].codedValue, (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, "pre_lut_coded_value[c][i]" ); 1015 WRITE_CODE( sei.m_preLut[c][i].targetValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "pre_lut_target_value[c][i]" ); 1016 } 1017 } 1018 } 1019 WRITE_FLAG( sei.m_colourRemapMatrixPresentFlag, "colour_remap_matrix_present_flag" ); 1020 if( sei.m_colourRemapMatrixPresentFlag ) 1021 { 1022 WRITE_CODE( sei.m_log2MatrixDenom, 4, "log2_matrix_denom" ); 1023 for( Int c=0 ; c<3 ; c++ ) 1024 { 1025 for( Int i=0 ; i<3 ; i++ ) 1026 { 1027 WRITE_SVLC( sei.m_colourRemapCoeffs[c][i], "colour_remap_coeffs[c][i]" ); 1028 } 1029 } 1030 } 1031 1032 for( Int c=0 ; c<3 ; c++ ) 1033 { 1034 WRITE_CODE( sei.m_postLutNumValMinus1[c], 8, "m_postLutNumValMinus1[c]" ); 1035 if( sei.m_postLutNumValMinus1[c]>0 ) 1036 { 1037 for( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) 1038 { 1039 WRITE_CODE( sei.m_postLut[c][i].codedValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_coded_value[c][i]" ); 1040 WRITE_CODE( sei.m_postLut[c][i].targetValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_target_value[c][i]" ); 1041 } 1042 } 1043 } 1044 } 1045 } 1046 #endif 989 1047 990 1048 Void SEIWriter::xWriteSEIMasteringDisplayColourVolume(const SEIMasteringDisplayColourVolume& sei) … … 1326 1384 #endif //SVC_EXTENSION 1327 1385 1328 #if Q0074_COLOUR_REMAPPING_SEI1329 Void SEIWriter::xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei)1330 {1331 WRITE_UVLC( sei.m_colourRemapId, "colour_remap_id" );1332 WRITE_FLAG( sei.m_colourRemapCancelFlag, "colour_remap_cancel_flag" );1333 if( !sei.m_colourRemapCancelFlag )1334 {1335 WRITE_FLAG( sei.m_colourRemapPersistenceFlag, "colour_remap_persistence_flag" );1336 WRITE_FLAG( sei.m_colourRemapVideoSignalInfoPresentFlag, "colour_remap_video_signal_info_present_flag" );1337 if ( sei.m_colourRemapVideoSignalInfoPresentFlag )1338 {1339 WRITE_FLAG( sei.m_colourRemapFullRangeFlag, "colour_remap_full_range_flag" );1340 WRITE_CODE( sei.m_colourRemapPrimaries, 8, "colour_remap_primaries" );1341 WRITE_CODE( sei.m_colourRemapTransferFunction, 8, "colour_remap_transfer_function" );1342 WRITE_CODE( sei.m_colourRemapMatrixCoefficients, 8, "colour_remap_matrix_coefficients" );1343 }1344 WRITE_CODE( sei.m_colourRemapInputBitDepth, 8, "colour_remap_input_bit_depth" );1345 WRITE_CODE( sei.m_colourRemapBitDepth, 8, "colour_remap_bit_depth" );1346 for( Int c=0 ; c<3 ; c++ )1347 {1348 WRITE_CODE( sei.m_preLutNumValMinus1[c], 8, "pre_lut_num_val_minus1[c]" );1349 if( sei.m_preLutNumValMinus1[c]>0 )1350 for( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ )1351 {1352 WRITE_CODE( sei.m_preLutCodedValue[c][i], (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, "pre_lut_coded_value[c][i]" );1353 WRITE_CODE( sei.m_preLutTargetValue[c][i], (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "pre_lut_target_value[c][i]" );1354 }1355 }1356 WRITE_FLAG( sei.m_colourRemapMatrixPresentFlag, "colour_remap_matrix_present_flag" );1357 if( sei.m_colourRemapMatrixPresentFlag )1358 {1359 WRITE_CODE( sei.m_log2MatrixDenom, 4, "log2_matrix_denom" );1360 for( Int c=0 ; c<3 ; c++ )1361 for( Int i=0 ; i<3 ; i++ )1362 WRITE_SVLC( sei.m_colourRemapCoeffs[c][i], "colour_remap_coeffs[c][i]" );1363 }1364 1365 for( Int c=0 ; c<3 ; c++ )1366 {1367 WRITE_CODE( sei.m_postLutNumValMinus1[c], 8, "m_postLutNumValMinus1[c]" );1368 if( sei.m_postLutNumValMinus1[c]>0 )1369 for( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ )1370 {1371 WRITE_CODE( sei.m_postLutCodedValue[c][i], (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_coded_value[c][i]" );1372 WRITE_CODE( sei.m_postLutTargetValue[c][i], (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_target_value[c][i]" );1373 }1374 }1375 }1376 }1377 #endif1378 1379 1386 //! \} -
branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.h
r1434 r1460 89 89 Void xWriteSEIChromaResamplingFilterHint(const SEIChromaResamplingFilterHint& sei); 90 90 Void xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei); 91 #if Q0074_COLOUR_REMAPPING_SEI 92 Void xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei); 93 #endif 91 94 Void xWriteSEIMasteringDisplayColourVolume( const SEIMasteringDisplayColourVolume& sei); 92 95 … … 97 100 #endif 98 101 Void xWriteByteAlign(); 99 #if Q0074_COLOUR_REMAPPING_SEI 100 Void xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei); 101 #endif 102 102 103 #if SVC_EXTENSION 103 104 #if LAYERS_NOT_PRESENT_SEI -
branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h
r1459 r1460 321 321 Int* m_kneeSEIInputKneePoint; 322 322 Int* m_kneeSEIOutputKneePoint; 323 #if Q0074_COLOUR_REMAPPING_SEI 324 std::string m_colourRemapSEIFileRoot; ///< SEI Colour Remapping File (initialized from external file) 325 #endif 323 326 TComSEIMasteringDisplay m_masteringDisplay; 324 327 //====== Weighted Prediction ======== … … 907 910 Void setKneeSEIOutputKneePoint(Int *p) { m_kneeSEIOutputKneePoint = p; } 908 911 Int* getKneeSEIOutputKneePoint() { return m_kneeSEIOutputKneePoint; } 912 #if Q0074_COLOUR_REMAPPING_SEI 913 Void setColourRemapInfoSEIFileRoot( const std::string &s ) { m_colourRemapSEIFileRoot = s; } 914 const std::string &getColourRemapInfoSEIFileRoot() const { return m_colourRemapSEIFileRoot; } 915 #endif 909 916 Void setMasteringDisplaySEI(const TComSEIMasteringDisplay &src) { m_masteringDisplay = src; } 910 917 const TComSEIMasteringDisplay &getMasteringDisplaySEI() const { return m_masteringDisplay; } … … 1099 1106 Bool getAlphaClipTypeFlag() { return m_alphaClipTypeFlag; } 1100 1107 #endif 1101 #if Q0074_COLOUR_REMAPPING_SEI1102 Void xSetCRISEIFileRoot( std::string pch ) { m_colourRemapSEIFileName = pch; }1103 std::string& getCRISEIFileRoot() { return m_colourRemapSEIFileName; }1104 #endif1105 1108 #if SVC_EXTENSION 1106 1109 UInt getLayerId() { return m_layerId; } -
branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r1459 r1460 117 117 m_prevPicHasEos = false; 118 118 #endif //SVC_EXTENSION 119 120 #if Q0074_COLOUR_REMAPPING_SEI121 memset( m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue, 0, sizeof(m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue));122 memset( m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue, 0, sizeof(m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue));123 memset( m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue, 0, sizeof(m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue));124 memset( m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue, 0, sizeof(m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue));125 #endif126 119 return; 127 120 } … … 702 695 } 703 696 704 #if Q0074_COLOUR_REMAPPING_SEI705 Void TEncGOP::xFreeColourCRI()706 {707 for( Int c=0 ; c<3 ; c++)708 {709 if ( m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c] != NULL)710 {711 delete[] m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c];712 m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c] = NULL;713 }714 if ( m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c] != NULL)715 {716 delete[] m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c];717 m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c] = NULL;718 }719 if ( m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c] != NULL)720 {721 delete[] m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c];722 m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c] = NULL;723 }724 if ( m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c] != NULL)725 {726 delete[] m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c];727 m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c] = NULL;728 }729 }730 }731 732 Int TEncGOP::xReadingCRIparameters(){733 734 // reading external Colour Remapping Information SEI message parameters from file735 if( m_seiColourRemappingInfo.m_colourRemapSEIFile.c_str() )736 {737 FILE* fic;738 Int retval;739 if((fic = fopen(m_seiColourRemappingInfo.m_colourRemapSEIFile.c_str(),"r")) == (FILE*)NULL)740 {741 //fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", m_colourRemapSEIFile.c_str());742 //exit(EXIT_FAILURE);743 return (-1);744 }745 Int tempCode;746 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIId );747 retval = fscanf( fic, "%d", &tempCode ); m_seiColourRemappingInfo.m_colourRemapSEICancelFlag = tempCode ? 1 : 0;748 if( !m_seiColourRemappingInfo.m_colourRemapSEICancelFlag )749 {750 retval = fscanf( fic, "%d", &tempCode ); m_seiColourRemappingInfo.m_colourRemapSEIPersistenceFlag= tempCode ? 1 : 0;751 retval = fscanf( fic, "%d", &tempCode); m_seiColourRemappingInfo.m_colourRemapSEIVideoSignalInfoPresentFlag = tempCode ? 1 : 0;752 if( m_seiColourRemappingInfo.m_colourRemapSEIVideoSignalInfoPresentFlag )753 {754 retval = fscanf( fic, "%d", &tempCode ); m_seiColourRemappingInfo.m_colourRemapSEIFullRangeFlag = tempCode ? 1 : 0;755 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPrimaries );756 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEITransferFunction );757 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIMatrixCoefficients );758 }759 760 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIInputBitDepth );761 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIBitDepth );762 763 for( Int c=0 ; c<3 ; c++ )764 {765 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c] );766 if( m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c]>0 )767 {768 m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c] = new Int[m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c]+1];769 m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c] = new Int[m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c]+1];770 for( Int i=0 ; i<=m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )771 {772 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c][i] );773 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c][i] );774 }775 }776 }777 778 retval = fscanf( fic, "%d", &tempCode ); m_seiColourRemappingInfo.m_colourRemapSEIMatrixPresentFlag = tempCode ? 1 : 0;779 if( m_seiColourRemappingInfo.m_colourRemapSEIMatrixPresentFlag )780 {781 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEILog2MatrixDenom );782 for( Int c=0 ; c<3 ; c++ )783 {784 for( Int i=0 ; i<3 ; i++ )785 {786 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEICoeffs[c][i] );787 }788 }789 }790 791 for( Int c=0 ; c<3 ; c++ )792 {793 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c] );794 if( m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c]>0 )795 {796 m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c] = new Int[m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c]+1];797 m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c] = new Int[m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c]+1];798 for( Int i=0 ; i<= m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )799 {800 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c][i] );801 retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c][i] );802 }803 }804 }805 }806 807 fclose( fic );808 if( retval != 1 )809 {810 fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n");811 exit(EXIT_FAILURE);812 }813 }814 return 1;815 }816 817 Bool confirmParameter(Bool bflag, const TChar* message);818 // ====================================================================================================================819 // Private member functions820 // ====================================================================================================================821 822 Void TEncGOP::xCheckParameter()823 {824 Bool check_failed = false; /* abort if there is a fatal configuration problem */825 #define xConfirmParameter(a,b) check_failed |= confirmParameter(a,b)826 827 if ( m_seiColourRemappingInfo.m_colourRemapSEIFile.c_str() && !m_seiColourRemappingInfo.m_colourRemapSEICancelFlag )828 {829 xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIInputBitDepth < 8 || m_seiColourRemappingInfo.m_colourRemapSEIInputBitDepth > 16 , "colour_remap_coded_data_bit_depth shall be in the range of 8 to 16, inclusive");830 xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIBitDepth < 8 || (m_seiColourRemappingInfo.m_colourRemapSEIBitDepth > 16 && m_seiColourRemappingInfo.m_colourRemapSEIBitDepth < 255) , "colour_remap_target_bit_depth shall be in the range of 8 to 16, inclusive");831 for( Int c=0 ; c<3 ; c++)832 {833 xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c] < 0 || m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c] > 32, "pre_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");834 if( m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c]>0 )835 for( Int i=0 ; i<= m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c] ; i++)836 {837 xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c][i] < 0 || m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c][i] > ((1<<m_seiColourRemappingInfo.m_colourRemapSEIInputBitDepth)-1), "pre_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_coded_data_bit_depth)-1, inclusive");838 xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c][i] < 0 || m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c][i] > ((1<<m_seiColourRemappingInfo.m_colourRemapSEIBitDepth)-1), "pre_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_target_bit_depth)-1, inclusive");839 }840 xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c] < 0 || m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c] > 32, "post_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");841 if( m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c]>0 )842 for( Int i=0 ; i<= m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c] ; i++)843 {844 xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c][i] < 0 || m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c][i] > ((1<<m_seiColourRemappingInfo.m_colourRemapSEIBitDepth)-1), "post_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_target_bit_depth)-1, inclusive");845 xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c][i] < 0 || m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c][i] > ((1<<m_seiColourRemappingInfo.m_colourRemapSEIBitDepth)-1), "post_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_target_bit_depth)-1, inclusive");846 }847 }848 if ( m_seiColourRemappingInfo.m_colourRemapSEIMatrixPresentFlag )849 {850 xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEILog2MatrixDenom < 0 || m_seiColourRemappingInfo.m_colourRemapSEILog2MatrixDenom > 15, "log2_matrix_denom shall be in the range of 0 to 15, inclusive");851 for( Int c=0 ; c<3 ; c++)852 for( Int i=0 ; i<3 ; i++)853 xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEICoeffs[c][i] < -32768 || m_seiColourRemappingInfo.m_colourRemapSEICoeffs[c][i] > 32767, "colour_remap_coeffs[c][i] shall be in the range of -32768 and 32767, inclusive");854 }855 }856 }857 #endif858 859 697 Void TEncGOP::xCreatePerPictureSEIMessages (Int picInGOP, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, TComSlice *slice) 860 698 { … … 912 750 } 913 751 752 #if Q0074_COLOUR_REMAPPING_SEI 753 // insert one Colour Remapping Info SEI for the picture (if the file exists) 754 if (!m_pcCfg->getColourRemapInfoSEIFileRoot().empty()) 755 { 756 SEIColourRemappingInfo *seiColourRemappingInfo = new SEIColourRemappingInfo(); 757 const Bool success = m_seiEncoder.initSEIColourRemappingInfo(seiColourRemappingInfo, slice->getPOC() ); 758 759 if(success) 760 { 761 seiMessages.push_back(seiColourRemappingInfo); 762 } 763 else 764 { 765 delete seiColourRemappingInfo; 766 } 767 } 768 #endif 769 914 770 #if Q0189_TMVP_CONSTRAINTS 915 771 if( m_pcEncTop->getTMVPConstraintsSEIEnabled() == 1 && (m_pcEncTop->getTMVPModeId() == 1 || m_pcEncTop->getTMVPModeId() == 2) && … … 930 786 seiMessages.push_back(seiFFInfo); 931 787 } 932 #endif933 #if Q0074_COLOUR_REMAPPING_SEI934 // insert one CRI by picture (if the file exist)935 xFreeColourCRI();936 937 // building the CRI file name with poc num in suffix "_poc.txt"938 char suffix[10];939 sprintf(suffix, "_%d.txt", slice->getPOC());940 string colourRemapSEIFileWithPoc(m_pcCfg->getCRISEIFileRoot());941 colourRemapSEIFileWithPoc.append(suffix);942 xSetCRISEIFile( colourRemapSEIFileWithPoc );943 944 Int ret = xReadingCRIparameters();945 946 if(ret != -1 && !m_pcCfg->getCRISEIFileRoot().empty())947 {948 // check validity of input parameters949 xCheckParameter();950 951 SEIColourRemappingInfo *seiColourRemappingInfo = new SEIColourRemappingInfo;952 m_seiEncoder.initSEIColourRemappingInfo(seiColourRemappingInfo, &m_seiColourRemappingInfo);953 seiMessages.push_back(seiColourRemappingInfo);954 }955 788 #endif 956 789 } … … 4590 4423 #endif //SVC_EXTENSION 4591 4424 4592 #if Q0074_COLOUR_REMAPPING_SEI4593 Bool confirmParameter(Bool bflag, const TChar* message)4594 {4595 if (!bflag)4596 return false;4597 4598 printf("Error: %s\n",message);4599 return true;4600 }4601 #endif4602 4603 4425 //! \} -
branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h
r1442 r1460 138 138 SEIEncoder m_seiEncoder; 139 139 140 #if Q0074_COLOUR_REMAPPING_SEI141 TComSEIColourRemappingInfo m_seiColourRemappingInfo;142 #endif143 140 #if SVC_EXTENSION 144 141 Int m_pocCraWithoutReset; … … 274 271 Void applyDeblockingFilterMetric( TComPic* pcPic, UInt uiNumSlices ); 275 272 276 #if Q0074_COLOUR_REMAPPING_SEI277 TComSEIColourRemappingInfo* xGetSEIColourRemappingInfo() { return &m_seiColourRemappingInfo; }278 Void xSetCRISEIFile( std::string pch ) { m_seiColourRemappingInfo.m_colourRemapSEIFile = pch; }279 280 Void xFreeColourCRI();281 Int xReadingCRIparameters();282 Void xCheckParameter();283 #endif284 273 #if SVC_EXTENSION 285 274 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
Note: See TracChangeset for help on using the changeset viewer.