Changeset 1089 in SHVCSoftware for branches/SHM-dev/source/Lib
- Timestamp:
- 25 Jun 2015, 16:19:05 (10 years ago)
- Location:
- branches/SHM-dev/source/Lib
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibCommon/SEI.cpp
r1037 r1089 169 169 } 170 170 } 171 172 #if Q0074_COLOUR_REMAPPING_SEI 173 Void SEIColourRemappingInfo::copyFrom( SEIColourRemappingInfo const * SeiCriInput) 174 { 175 m_colourRemapId = SeiCriInput->m_colourRemapId; 176 m_colourRemapCancelFlag = SeiCriInput->m_colourRemapCancelFlag; 177 m_colourRemapPersistenceFlag = SeiCriInput->m_colourRemapPersistenceFlag; 178 m_colourRemapVideoSignalInfoPresentFlag = SeiCriInput->m_colourRemapVideoSignalInfoPresentFlag; 179 m_colourRemapFullRangeFlag = SeiCriInput->m_colourRemapFullRangeFlag; 180 m_colourRemapPrimaries = SeiCriInput->m_colourRemapPrimaries; 181 m_colourRemapTransferFunction = SeiCriInput->m_colourRemapTransferFunction; 182 m_colourRemapMatrixCoefficients = SeiCriInput->m_colourRemapMatrixCoefficients; 183 m_colourRemapInputBitDepth = SeiCriInput->m_colourRemapInputBitDepth; 184 m_colourRemapBitDepth = SeiCriInput->m_colourRemapBitDepth; 185 186 for( Int c=0 ; c<3 ; c++ ) 187 { 188 m_preLutNumValMinus1[c] = SeiCriInput->m_preLutNumValMinus1[c]; 189 m_preLutCodedValue[c].resize(m_preLutNumValMinus1[c]+1); 190 m_preLutTargetValue[c].resize(m_preLutNumValMinus1[c]+1); 191 for ( Int i=0 ; i <= SeiCriInput->m_preLutNumValMinus1[c] ; i++ ) 192 { 193 m_preLutCodedValue[c][i] = SeiCriInput->m_preLutCodedValue[c][i]; 194 m_preLutTargetValue[c][i] = SeiCriInput->m_preLutTargetValue[c][i]; 195 } 196 } 197 198 m_colourRemapMatrixPresentFlag = SeiCriInput->m_colourRemapMatrixPresentFlag; 199 m_log2MatrixDenom = SeiCriInput->m_log2MatrixDenom; 200 201 for ( Int c=0 ; c<3 ; c++ ) 202 for ( Int i=0 ; i<3 ; i++ ) 203 m_colourRemapCoeffs[c][i] = SeiCriInput->m_colourRemapCoeffs[c][i]; 204 205 for( Int c=0 ; c<3 ; c++ ) 206 { 207 m_postLutNumValMinus1[c] = SeiCriInput->m_postLutNumValMinus1[c]; 208 m_postLutCodedValue[c].resize(m_postLutNumValMinus1[c]+1); 209 m_postLutTargetValue[c].resize(m_postLutNumValMinus1[c]+1); 210 for ( Int i=0 ; i <= m_postLutNumValMinus1[c] ; i++ ) 211 { 212 m_postLutCodedValue[c][i] = SeiCriInput->m_postLutCodedValue[c][i]; 213 m_postLutTargetValue[c][i] = SeiCriInput->m_postLutTargetValue[c][i]; 214 } 215 } 216 } 217 #endif -
branches/SHM-dev/source/Lib/TLibCommon/SEI.h
r1070 r1089 766 766 SEIColourRemappingInfo() {} 767 767 ~SEIColourRemappingInfo() {} 768 769 Void copyFrom( SEIColourRemappingInfo const * SeiCriInput); 768 770 769 771 Int m_colourRemapId; -
branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.cpp
r1031 r1089 313 313 for (Int x = 0; x < width; x++ ) 314 314 { 315 Pel pix = Clip3<Pel>(0, (1 << bitDepth)-1, (pi[x]+offset)>>shift);315 Pel pix = pi[x]; 316 316 317 317 UChar uc = pix & 0xff; -
branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp
r1049 r1089 64 64 //! \{ 65 65 static Void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI); 66 #if Q0074_COLOUR_REMAPPING_SEI67 static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* colourRemappingInfoSEI, UInt layerId=0 );68 static std::vector<SEIColourRemappingInfo> storeCriSEI; //Persistent Colour Remapping Information SEI69 #endif70 66 // ==================================================================================================================== 71 67 // Constructor / destructor / initialization / destroy … … 258 254 thisLayerBuffer->push_back(*pcPic); 259 255 std::sort( thisLayerBuffer->begin(), thisLayerBuffer->end(), pocCompareFunction ); 260 }261 #endif262 #if Q0074_COLOUR_REMAPPING_SEI263 if (m_colourRemapSEIEnabled)264 {265 SEIMessages colourRemappingInfo = getSeisByType(pcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO );266 const SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL;267 if (colourRemappingInfo.size() > 1)268 {269 printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first.");270 }271 applyColourRemapping(*pcPic->getPicYuvRec(), seiColourRemappingInfo272 #if SVC_EXTENSION273 , pcPic->getLayerId()274 #endif275 );276 256 } 277 257 #endif … … 354 334 } 355 335 356 #if Q0074_COLOUR_REMAPPING_SEI357 Void xInitColourRemappingLut( const Int bitDepthY, const Int bitDepthC, std::vector<Int>(&preLut)[3], std::vector<Int>(&postLut)[3], const SEIColourRemappingInfo* const pCriSEI )358 {359 for ( Int c=0 ; c<3 ; c++ )360 {361 Int bitDepth = c ? bitDepthC : bitDepthY ;362 preLut[c].resize(1 << bitDepth);363 postLut[c].resize(1 << pCriSEI->m_colourRemapBitDepth);364 365 Int bitDepthDiff = pCriSEI->m_colourRemapBitDepth - bitDepth;366 Int iShift1 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from bitdepth to ColourRemapBitdepth (manage only case colourRemapBitDepth>= bitdepth)367 if( bitDepthDiff<0 )368 printf ("Warning: CRI SEI - colourRemapBitDepth (%d) <bitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapBitDepth, bitDepth);369 bitDepthDiff = pCriSEI->m_colourRemapBitDepth - pCriSEI->m_colourRemapInputBitDepth;370 Int iShift2 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from ColourRemapInputBitdepth to ColourRemapBitdepth (manage only case colourRemapBitDepth>= colourRemapInputBitDepth)371 if( bitDepthDiff<0 )372 printf ("Warning: CRI SEI - colourRemapBitDepth (%d) <colourRemapInputBitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapBitDepth, pCriSEI->m_colourRemapInputBitDepth);373 374 //Fill preLut375 for ( Int k=0 ; k<(1<<bitDepth) ; k++ )376 {377 Int iSample = k << iShift1 ;378 for ( Int iPivot=0 ; iPivot<=pCriSEI->m_preLutNumValMinus1[c] ; iPivot++ )379 {380 Int iCodedPrev = pCriSEI->m_preLutCodedValue[c][iPivot] << iShift2; //Coded in CRInputBitdepth381 Int iCodedNext = pCriSEI->m_preLutCodedValue[c][iPivot+1] << iShift2; //Coded in CRInputBitdepth382 Int iTargetPrev = pCriSEI->m_preLutTargetValue[c][iPivot]; //Coded in CRBitdepth383 Int iTargetNext = pCriSEI->m_preLutTargetValue[c][iPivot+1]; //Coded in CRBitdepth384 if ( iCodedPrev <= iSample && iSample <= iCodedNext )385 {386 Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev);387 preLut[c][k] = (Int)( 0.5f + fInterpol );388 iPivot = pCriSEI->m_preLutNumValMinus1[c] + 1;389 }390 }391 }392 393 //Fill postLut394 for ( Int k=0 ; k<(1<<pCriSEI->m_colourRemapBitDepth) ; k++ )395 {396 Int iSample = k;397 for ( Int iPivot=0 ; iPivot<=pCriSEI->m_postLutNumValMinus1[c] ; iPivot++ )398 {399 Int iCodedPrev = pCriSEI->m_postLutCodedValue[c][iPivot]; //Coded in CRBitdepth400 Int iCodedNext = pCriSEI->m_postLutCodedValue[c][iPivot+1]; //Coded in CRBitdepth401 Int iTargetPrev = pCriSEI->m_postLutTargetValue[c][iPivot]; //Coded in CRBitdepth402 Int iTargetNext = pCriSEI->m_postLutTargetValue[c][iPivot+1]; //Coded in CRBitdepth403 if ( iCodedPrev <= iSample && iSample <= iCodedNext )404 {405 Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev) ;406 postLut[c][k] = (Int)( 0.5f + fInterpol );407 iPivot = pCriSEI->m_postLutNumValMinus1[c] + 1;408 }409 }410 }411 }412 }413 414 static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId )415 {416 if( !storeCriSEI.size() )417 #if SVC_EXTENSION418 storeCriSEI.resize(MAX_LAYERS);419 #else420 storeCriSEI.resize(1);421 #endif422 423 if ( pCriSEI ) //if a CRI SEI has just been retrieved, keep it in memory (persistence management)424 storeCriSEI[layerId] = *pCriSEI;425 426 if( !storeCriSEI[layerId].m_colourRemapCancelFlag )427 {428 Int iHeight = pic.getHeight(COMPONENT_Y);429 Int iWidth = pic.getWidth(COMPONENT_Y);430 Int iStride = pic.getStride(COMPONENT_Y);431 Int iCStride = pic.getStride(COMPONENT_Cb);432 433 Pel *YUVIn[3], *YUVOut[3];434 YUVIn[0] = pic.getAddr(COMPONENT_Y);435 YUVIn[1] = pic.getAddr(COMPONENT_Cb);436 YUVIn[2] = pic.getAddr(COMPONENT_Cr);437 438 TComPicYuv picColourRemapped;439 #if SVC_EXTENSION440 picColourRemapped.create( pic.getWidth(COMPONENT_Y), pic.getHeight(COMPONENT_Y), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );441 #else442 picColourRemapped.create( pic.getWidth(COMPONENT_Y), pic.getHeight(COMPONENT_Y), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );443 #endif444 YUVOut[0] = picColourRemapped.getAddr(COMPONENT_Y);445 YUVOut[1] = picColourRemapped.getAddr(COMPONENT_Cb);446 YUVOut[2] = picColourRemapped.getAddr(COMPONENT_Cr);447 448 #if SVC_EXTENSION449 Int bitDepthY = g_bitDepthLayer[CHANNEL_TYPE_LUMA][layerId];450 Int bitDepthC = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][layerId];451 452 assert( g_bitDepth[CHANNEL_TYPE_LUMA] == bitDepthY );453 assert( g_bitDepth[CHANNEL_TYPE_CHROMA] == bitDepthC );454 #else455 Int bitDepthY = g_bitDepth[CHANNEL_TYPE_LUMA];456 Int bitDepthC = g_bitDepth[CHANNEL_TYPE_CHROMA];457 #endif458 459 std::vector<Int> preLut[3];460 std::vector<Int> postLut[3];461 xInitColourRemappingLut( bitDepthY, bitDepthC, preLut, postLut, &storeCriSEI[layerId] );462 463 Int roundingOffset = (storeCriSEI[layerId].m_log2MatrixDenom==0) ? 0 : (1 << (storeCriSEI[layerId].m_log2MatrixDenom - 1));464 465 for( Int y = 0; y < iHeight ; y++ )466 {467 for( Int x = 0; x < iWidth ; x++ )468 {469 Int YUVPre[3], YUVMat[3];470 YUVPre[0] = preLut[0][ YUVIn[0][x] ];471 YUVPre[1] = preLut[1][ YUVIn[1][x>>1] ];472 YUVPre[2] = preLut[2][ YUVIn[2][x>>1] ];473 474 YUVMat[0] = ( storeCriSEI[layerId].m_colourRemapCoeffs[0][0]*YUVPre[0]475 + storeCriSEI[layerId].m_colourRemapCoeffs[0][1]*YUVPre[1]476 + storeCriSEI[layerId].m_colourRemapCoeffs[0][2]*YUVPre[2]477 + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom );478 YUVMat[0] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapBitDepth)-1, YUVMat[0] );479 YUVOut[0][x] = postLut[0][ YUVMat[0] ];480 481 if( (y&1) && (x&1) )482 {483 for(Int c=1 ; c<3 ; c++)484 {485 YUVMat[c] = ( storeCriSEI[layerId].m_colourRemapCoeffs[c][0]*YUVPre[0]486 + storeCriSEI[layerId].m_colourRemapCoeffs[c][1]*YUVPre[1]487 + storeCriSEI[layerId].m_colourRemapCoeffs[c][2]*YUVPre[2]488 + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom );489 YUVMat[c] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapBitDepth)-1, YUVMat[c] );490 YUVOut[c][x>>1] = postLut[c][ YUVMat[c] ];491 }492 }493 }494 YUVIn[0] += iStride;495 YUVOut[0] += iStride;496 if( y&1 )497 {498 YUVIn[1] += iCStride;499 YUVIn[2] += iCStride;500 YUVOut[1] += iCStride;501 YUVOut[2] += iCStride;502 }503 }504 505 //Write remapped picture in decoding order506 Char cTemp[255];507 sprintf(cTemp, "seiColourRemappedPic_L%d_%dx%d_%dbits.yuv", layerId, iWidth, iHeight, storeCriSEI[layerId].m_colourRemapBitDepth );508 picColourRemapped.dump( cTemp, true, storeCriSEI[layerId].m_colourRemapBitDepth );509 510 picColourRemapped.destroy();511 512 storeCriSEI[layerId].m_colourRemapCancelFlag = !storeCriSEI[layerId].m_colourRemapPersistenceFlag; //Handling persistence513 }514 }515 #endif516 336 //! \} -
branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.h
r1049 r1089 80 80 Double m_dDecTime; 81 81 Int m_decodedPictureHashSEIEnabled; ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message 82 #if Q0074_COLOUR_REMAPPING_SEI 83 Bool m_colourRemapSEIEnabled; ///< Enable/disable Colour Remapping Information SEI message acting on decoded pictures 84 #endif 82 85 83 #if SVC_EXTENSION 86 84 UInt m_layerId; … … 114 112 115 113 Void setDecodedPictureHashSEIEnabled(Int enabled) { m_decodedPictureHashSEIEnabled = enabled; } 116 #if Q0074_COLOUR_REMAPPING_SEI117 Void setColourRemappingInfoSEIEnabled(Int enabled) { m_colourRemapSEIEnabled = enabled; }118 #endif119 114 #if SVC_EXTENSION 120 115 TDecTop* getLayerDec(UInt layerId) { return m_ppcTDecTop[layerId]; } -
branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h
r1084 r1089 203 203 204 204 Void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } 205 #if Q0074_COLOUR_REMAPPING_SEI206 void setColourRemappingInfoSEIEnabled(Bool enabled) { m_cGopDecoder.setColourRemappingInfoSEIEnabled(enabled); }207 #endif208 205 209 206 Void init(); -
branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h
r1057 r1089 465 465 #endif //SVC_EXTENSION 466 466 #if Q0074_COLOUR_REMAPPING_SEI 467 Char* m_colourRemapSEIFile; ///< SEI Colour Remapping File (initialized from external file) 468 Int m_colourRemapSEIId; 469 Bool m_colourRemapSEICancelFlag; 470 Bool m_colourRemapSEIPersistenceFlag; 471 Bool m_colourRemapSEIVideoSignalInfoPresentFlag; 472 Bool m_colourRemapSEIFullRangeFlag; 473 Int m_colourRemapSEIPrimaries; 474 Int m_colourRemapSEITransferFunction; 475 Int m_colourRemapSEIMatrixCoefficients; 476 Int m_colourRemapSEIInputBitDepth; 477 Int m_colourRemapSEIBitDepth; 478 Int m_colourRemapSEIPreLutNumValMinus1[3]; 479 Int* m_colourRemapSEIPreLutCodedValue[3]; 480 Int* m_colourRemapSEIPreLutTargetValue[3]; 481 Bool m_colourRemapSEIMatrixPresentFlag; 482 Int m_colourRemapSEILog2MatrixDenom; 483 Int m_colourRemapSEICoeffs[3][3]; 484 Int m_colourRemapSEIPostLutNumValMinus1[3]; 485 Int* m_colourRemapSEIPostLutCodedValue[3]; 486 Int* m_colourRemapSEIPostLutTargetValue[3]; 467 Char* m_colourRemapSEIFileRoot; ///< SEI Colour Remapping File (initialized from external file) 487 468 #endif 488 469 … … 492 473 , m_tileRowHeight() 493 474 #if Q0074_COLOUR_REMAPPING_SEI 494 , m_colourRemapSEIFile (NULL)475 , m_colourRemapSEIFileRoot(NULL) 495 476 #endif 496 477 {} … … 1030 1011 #endif 1031 1012 #if Q0074_COLOUR_REMAPPING_SEI 1032 Void setCRISEIFile( Char* pch ) { m_colourRemapSEIFile = pch; } 1033 Char* getCRISEIFile() { return m_colourRemapSEIFile; } 1034 Void setCRISEIId(Int i) { m_colourRemapSEIId = i; } 1035 Int getCRISEIId() { return m_colourRemapSEIId; } 1036 Void setCRISEICancelFlag(Bool b) { m_colourRemapSEICancelFlag = b; } 1037 Bool getCRISEICancelFlag() { return m_colourRemapSEICancelFlag; } 1038 Void setCRISEIPersistenceFlag(Bool b) { m_colourRemapSEIPersistenceFlag = b; } 1039 Bool getCRISEIPersistenceFlag() { return m_colourRemapSEIPersistenceFlag; } 1040 Void setCRISEIVideoSignalInfoPresentFlag(Bool b) { m_colourRemapSEIVideoSignalInfoPresentFlag = b; } 1041 Bool getCRISEIVideoSignalInfoPresentFlag() { return m_colourRemapSEIVideoSignalInfoPresentFlag; } 1042 Void setCRISEIFullRangeFlag(Bool b) { m_colourRemapSEIFullRangeFlag = b; } 1043 Bool getCRISEIFullRangeFlag() { return m_colourRemapSEIFullRangeFlag; } 1044 Void setCRISEIPrimaries(Int i) { m_colourRemapSEIPrimaries = i; } 1045 Int getCRISEIPrimaries() { return m_colourRemapSEIPrimaries; } 1046 Void setCRISEITransferFunction(Int i) { m_colourRemapSEITransferFunction = i; } 1047 Int getCRISEITransferFunction() { return m_colourRemapSEITransferFunction; } 1048 Void setCRISEIMatrixCoefficients(Int i) { m_colourRemapSEIMatrixCoefficients = i; } 1049 Int getCRISEIMatrixCoefficients() { return m_colourRemapSEIMatrixCoefficients; } 1050 Void setCRISEIInputBitDepth(Int i) { m_colourRemapSEIInputBitDepth = i; } 1051 Int getCRISEIInputBitDepth() { return m_colourRemapSEIInputBitDepth; } 1052 Void setCRISEIBitDepth(Int i) { m_colourRemapSEIBitDepth = i; } 1053 Int getCRISEIBitDepth() { return m_colourRemapSEIBitDepth; } 1054 Void setCRISEIPreLutNumValMinus1(Int *i) { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPreLutNumValMinus1[c] = i[c]; } 1055 Int getCRISEIPreLutNumValMinus1(Int i) { return m_colourRemapSEIPreLutNumValMinus1[i]; } 1056 Void setCRISEIPreLutCodedValue(Int **i) { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPreLutCodedValue[c] = i[c]; } 1057 Int* getCRISEIPreLutCodedValue(Int i) { return m_colourRemapSEIPreLutCodedValue[i]; } 1058 Void setCRISEIPreLutTargetValue(Int **i) { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPreLutTargetValue[c] = i[c]; } 1059 Int* getCRISEIPreLutTargetValue(Int i) { return m_colourRemapSEIPreLutTargetValue[i]; } 1060 Void setCRISEIMatrixPresentFlag(Bool b) { m_colourRemapSEIMatrixPresentFlag = b; } 1061 Bool getCRISEIMatrixPresentFlag() { return m_colourRemapSEIMatrixPresentFlag; } 1062 Void setCRISEILog2MatrixDenom(Int i) { m_colourRemapSEILog2MatrixDenom = i; } 1063 Int getCRISEILog2MatrixDenom() { return m_colourRemapSEILog2MatrixDenom; } 1064 Void setCRISEICoeffs(Int i[3][3]) { for(Int c=0 ; c<3 ; c++) for(Int j=0 ; j<3 ; j++) m_colourRemapSEICoeffs[c][j] = i[c][j]; } 1065 Int* getCRISEICoeffs(Int i) { return m_colourRemapSEICoeffs[i]; } 1066 Void setCRISEIPostLutNumValMinus1(Int *i) { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPostLutNumValMinus1[c] = i[c]; } 1067 Int getCRISEIPostLutNumValMinus1(Int i) { return m_colourRemapSEIPostLutNumValMinus1[i]; } 1068 Void setCRISEIPostLutCodedValue(Int **i) { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPostLutCodedValue[c] = i[c]; } 1069 Int* getCRISEIPostLutCodedValue(Int i) { return m_colourRemapSEIPostLutCodedValue[i]; } 1070 Void setCRISEIPostLutTargetValue(Int **i) { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPostLutTargetValue[c] = i[c]; } 1071 Int* getCRISEIPostLutTargetValue(Int i) { return m_colourRemapSEIPostLutTargetValue[i]; } 1013 Void setCRISEIFileRoot( Char* pch ) { m_colourRemapSEIFileRoot = pch; } 1014 Char* getCRISEIFileRoot() { return m_colourRemapSEIFileRoot; } 1072 1015 #endif 1073 1016 #if SVC_EXTENSION -
branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r1085 r1089 127 127 #endif 128 128 #endif //SVC_EXTENSION 129 130 #if Q0074_COLOUR_REMAPPING_SEI 131 for( Int c=0 ; c<3 ; c++) 132 { 133 m_colourRemapSEIPreLutCodedValue[c] = NULL; 134 m_colourRemapSEIPreLutTargetValue[c] = NULL; 135 m_colourRemapSEIPostLutCodedValue[c] = NULL; 136 m_colourRemapSEIPostLutTargetValue[c] = NULL; 137 } 138 #endif 129 139 return; 130 140 } … … 642 652 } 643 653 644 #if Q0074_COLOUR_REMAPPING_SEI645 if(m_pcCfg->getCRISEIFile() && strlen(m_pcCfg->getCRISEIFile()))646 {647 SEIColourRemappingInfo *sei = xCreateSEIColourRemappingInfo ();648 649 #if SVC_EXTENSION650 nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, sps->getLayerId()); // SEI-CRI is applied per layer651 #else652 nalu = NALUnit(NAL_UNIT_PREFIX_SEI);653 #endif654 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);655 #if O0164_MULTI_LAYER_HRD656 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);657 #else658 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);659 #endif660 writeRBSPTrailingBits(nalu.m_Bitstream);661 accessUnit.push_back(new NALUnitEBSP(nalu));662 delete sei;663 }664 #endif665 666 654 #if SVC_EXTENSION 667 655 #if LAYERS_NOT_PRESENT_SEI … … 732 720 #endif //SVC_EXTENSION 733 721 } 722 723 #if Q0074_COLOUR_REMAPPING_SEI 724 Void TEncGOP::freeColourCRI() 725 { 726 for( Int c=0 ; c<3 ; c++) 727 { 728 if ( m_colourRemapSEIPreLutCodedValue[c] != NULL) 729 { 730 delete[] m_colourRemapSEIPreLutCodedValue[c]; 731 m_colourRemapSEIPreLutCodedValue[c] = NULL; 732 } 733 if ( m_colourRemapSEIPreLutTargetValue[c] != NULL) 734 { 735 delete[] m_colourRemapSEIPreLutTargetValue[c]; 736 m_colourRemapSEIPreLutTargetValue[c] = NULL; 737 } 738 if ( m_colourRemapSEIPostLutCodedValue[c] != NULL) 739 { 740 delete[] m_colourRemapSEIPostLutCodedValue[c]; 741 m_colourRemapSEIPostLutCodedValue[c] = NULL; 742 } 743 if ( m_colourRemapSEIPostLutTargetValue[c] != NULL) 744 { 745 delete[] m_colourRemapSEIPostLutTargetValue[c]; 746 m_colourRemapSEIPostLutTargetValue[c] = NULL; 747 } 748 } 749 } 750 751 Int TEncGOP::readingCRIparameters(){ 752 753 // reading external Colour Remapping Information SEI message parameters from file 754 if( m_colourRemapSEIFile.c_str() ) 755 { 756 FILE* fic; 757 Int retval; 758 if((fic = fopen(m_colourRemapSEIFile.c_str(),"r")) == (FILE*)NULL) 759 { 760 //fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", m_colourRemapSEIFile.c_str()); 761 //exit(EXIT_FAILURE); 762 return (-1); 763 } 764 Int tempCode; 765 retval = fscanf( fic, "%d", &m_colourRemapSEIId ); 766 retval = fscanf( fic, "%d", &tempCode );m_colourRemapSEICancelFlag = tempCode ? 1 : 0; 767 if( !m_colourRemapSEICancelFlag ) 768 { 769 retval = fscanf( fic, "%d", &tempCode ); m_colourRemapSEIPersistenceFlag= tempCode ? 1 : 0; 770 retval = fscanf( fic, "%d", &tempCode); m_colourRemapSEIVideoSignalInfoPresentFlag = tempCode ? 1 : 0; 771 if( m_colourRemapSEIVideoSignalInfoPresentFlag ) 772 { 773 retval = fscanf( fic, "%d", &tempCode ); m_colourRemapSEIFullRangeFlag = tempCode ? 1 : 0; 774 retval = fscanf( fic, "%d", &m_colourRemapSEIPrimaries ); 775 retval = fscanf( fic, "%d", &m_colourRemapSEITransferFunction ); 776 retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixCoefficients ); 777 } 778 779 retval = fscanf( fic, "%d", &m_colourRemapSEIInputBitDepth ); 780 retval = fscanf( fic, "%d", &m_colourRemapSEIBitDepth ); 781 782 for( Int c=0 ; c<3 ; c++ ) 783 { 784 retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutNumValMinus1[c] ); 785 if( m_colourRemapSEIPreLutNumValMinus1[c]>0 ) 786 { 787 m_colourRemapSEIPreLutCodedValue[c] = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1]; 788 m_colourRemapSEIPreLutTargetValue[c] = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1]; 789 for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++ ) 790 { 791 retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutCodedValue[c][i] ); 792 retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutTargetValue[c][i] ); 793 } 794 } 795 } 796 797 retval = fscanf( fic, "%d", &tempCode ); m_colourRemapSEIMatrixPresentFlag = tempCode ? 1 : 0; 798 if( m_colourRemapSEIMatrixPresentFlag ) 799 { 800 retval = fscanf( fic, "%d", &m_colourRemapSEILog2MatrixDenom ); 801 for( Int c=0 ; c<3 ; c++ ) 802 for( Int i=0 ; i<3 ; i++ ) 803 retval = fscanf( fic, "%d", &m_colourRemapSEICoeffs[c][i] ); 804 } 805 806 for( Int c=0 ; c<3 ; c++ ) 807 { 808 retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutNumValMinus1[c] ); 809 if( m_colourRemapSEIPostLutNumValMinus1[c]>0 ) 810 { 811 m_colourRemapSEIPostLutCodedValue[c] = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1]; 812 m_colourRemapSEIPostLutTargetValue[c] = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1]; 813 for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++ ) 814 { 815 retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutCodedValue[c][i] ); 816 retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutTargetValue[c][i] ); 817 } 818 } 819 } 820 } 821 822 fclose( fic ); 823 if( retval != 1 ) 824 { 825 fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n"); 826 exit(EXIT_FAILURE); 827 } 828 } 829 return 1; 830 } 831 Bool confirmParameter(Bool bflag, const Char* message); 832 // ==================================================================================================================== 833 // Private member functions 834 // ==================================================================================================================== 835 836 Void TEncGOP::xCheckParameter() 837 { 838 Bool check_failed = false; /* abort if there is a fatal configuration problem */ 839 #define xConfirmParameter(a,b) check_failed |= confirmParameter(a,b) 840 841 if ( m_colourRemapSEIFile.c_str() && !m_colourRemapSEICancelFlag ) 842 { 843 xConfirmParameter( m_colourRemapSEIInputBitDepth < 8 || m_colourRemapSEIInputBitDepth > 16 , "colour_remap_coded_data_bit_depth shall be in the range of 8 to 16, inclusive"); 844 xConfirmParameter( m_colourRemapSEIBitDepth < 8 || (m_colourRemapSEIBitDepth > 16 && m_colourRemapSEIBitDepth < 255) , "colour_remap_target_bit_depth shall be in the range of 8 to 16, inclusive"); 845 for( Int c=0 ; c<3 ; c++) 846 { 847 xConfirmParameter( m_colourRemapSEIPreLutNumValMinus1[c] < 0 || m_colourRemapSEIPreLutNumValMinus1[c] > 32, "pre_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive"); 848 if( m_colourRemapSEIPreLutNumValMinus1[c]>0 ) 849 for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++) 850 { 851 xConfirmParameter( m_colourRemapSEIPreLutCodedValue[c][i] < 0 || m_colourRemapSEIPreLutCodedValue[c][i] > ((1<<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"); 852 xConfirmParameter( m_colourRemapSEIPreLutTargetValue[c][i] < 0 || m_colourRemapSEIPreLutTargetValue[c][i] > ((1<<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"); 853 } 854 xConfirmParameter( m_colourRemapSEIPostLutNumValMinus1[c] < 0 || m_colourRemapSEIPostLutNumValMinus1[c] > 32, "post_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive"); 855 if( m_colourRemapSEIPostLutNumValMinus1[c]>0 ) 856 for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++) 857 { 858 xConfirmParameter( m_colourRemapSEIPostLutCodedValue[c][i] < 0 || m_colourRemapSEIPostLutCodedValue[c][i] > ((1<<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"); 859 xConfirmParameter( m_colourRemapSEIPostLutTargetValue[c][i] < 0 || m_colourRemapSEIPostLutTargetValue[c][i] > ((1<<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"); 860 } 861 } 862 if ( m_colourRemapSEIMatrixPresentFlag ) 863 { 864 xConfirmParameter( m_colourRemapSEILog2MatrixDenom < 0 || m_colourRemapSEILog2MatrixDenom > 15, "log2_matrix_denom shall be in the range of 0 to 15, inclusive"); 865 for( Int c=0 ; c<3 ; c++) 866 for( Int i=0 ; i<3 ; i++) 867 xConfirmParameter( m_colourRemapSEICoeffs[c][i] < -32768 || m_colourRemapSEICoeffs[c][i] > 32767, "colour_remap_coeffs[c][i] shall be in the range of -32768 and 32767, inclusive"); 868 } 869 } 870 } 871 #endif 734 872 735 873 // ==================================================================================================================== … … 2834 2972 } 2835 2973 2974 // insert one CRI by picture (if the file exist) 2975 #if Q0074_COLOUR_REMAPPING_SEI 2976 2977 freeColourCRI(); 2978 2979 // building the CRI file name with poc num in suffix "_poc.txt" 2980 char suffix[10]; 2981 sprintf(suffix, "_%d.txt", pcSlice->getPOC()); 2982 string colourRemapSEIFileWithPoc(m_pcCfg->getCRISEIFileRoot()); 2983 colourRemapSEIFileWithPoc.append(suffix); 2984 setCRISEIFile( const_cast<Char*>(colourRemapSEIFileWithPoc.c_str()) ); 2985 2986 Int ret = readingCRIparameters(); 2987 2988 if(ret != -1 && m_pcCfg->getCRISEIFileRoot()) 2989 { 2990 // check validity of input parameters 2991 xCheckParameter(); 2992 2993 SEIColourRemappingInfo *sei = xCreateSEIColourRemappingInfo (); 2994 #if SVC_EXTENSION 2995 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, 0, pcSlice->getSPS()->getLayerId()); // SEI-CRI is applied per layer 2996 #else 2997 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI); 2998 #endif 2999 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 3000 #if SVC_EXTENSION 3001 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), pcSlice->getSPS() ); 3002 #else 3003 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, pcSlice->getSPS() ); 3004 #endif 3005 writeRBSPTrailingBits(nalu.m_Bitstream); 3006 accessUnit.push_back(new NALUnitEBSP(nalu)); 3007 delete sei; 3008 } 3009 #endif 3010 2836 3011 /* use the main bitstream buffer for storing the marshalled picture */ 2837 3012 m_pcEntropyCoder->setBitstream(NULL); … … 4486 4661 { 4487 4662 SEIColourRemappingInfo *seiColourRemappingInfo = new SEIColourRemappingInfo(); 4488 seiColourRemappingInfo->m_colourRemapId = m_pcCfg->getCRISEIId(); 4489 seiColourRemappingInfo->m_colourRemapCancelFlag = m_pcCfg->getCRISEICancelFlag(); 4663 seiColourRemappingInfo->m_colourRemapId = m_colourRemapSEIId; 4664 seiColourRemappingInfo->m_colourRemapCancelFlag = m_colourRemapSEICancelFlag; 4665 printf("xCreateSEIColourRemappingInfo - m_colourRemapId = %d m_colourRemapCancelFlag = %d \n",seiColourRemappingInfo->m_colourRemapId, seiColourRemappingInfo->m_colourRemapCancelFlag); 4666 4490 4667 if( !seiColourRemappingInfo->m_colourRemapCancelFlag ) 4491 4668 { 4492 seiColourRemappingInfo->m_colourRemapPersistenceFlag = m_ pcCfg->getCRISEIPersistenceFlag();4493 seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag = m_ pcCfg->getCRISEIVideoSignalInfoPresentFlag();4669 seiColourRemappingInfo->m_colourRemapPersistenceFlag = m_colourRemapSEIPersistenceFlag; 4670 seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag = m_colourRemapSEIVideoSignalInfoPresentFlag; 4494 4671 if( seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag ) 4495 4672 { 4496 seiColourRemappingInfo->m_colourRemapFullRangeFlag = m_ pcCfg->getCRISEIFullRangeFlag();4497 seiColourRemappingInfo->m_colourRemapPrimaries = m_ pcCfg->getCRISEIPrimaries();4498 seiColourRemappingInfo->m_colourRemapTransferFunction = m_ pcCfg->getCRISEITransferFunction();4499 seiColourRemappingInfo->m_colourRemapMatrixCoefficients = m_ pcCfg->getCRISEIMatrixCoefficients();4500 } 4501 seiColourRemappingInfo->m_colourRemapInputBitDepth = m_ pcCfg->getCRISEIInputBitDepth();4502 seiColourRemappingInfo->m_colourRemapBitDepth = m_ pcCfg->getCRISEIBitDepth();4673 seiColourRemappingInfo->m_colourRemapFullRangeFlag = m_colourRemapSEIFullRangeFlag; 4674 seiColourRemappingInfo->m_colourRemapPrimaries = m_colourRemapSEIPrimaries; 4675 seiColourRemappingInfo->m_colourRemapTransferFunction = m_colourRemapSEITransferFunction; 4676 seiColourRemappingInfo->m_colourRemapMatrixCoefficients = m_colourRemapSEIMatrixCoefficients; 4677 } 4678 seiColourRemappingInfo->m_colourRemapInputBitDepth = m_colourRemapSEIInputBitDepth; 4679 seiColourRemappingInfo->m_colourRemapBitDepth = m_colourRemapSEIBitDepth; 4503 4680 for( Int c=0 ; c<3 ; c++ ) 4504 4681 { 4505 seiColourRemappingInfo->m_preLutNumValMinus1[c] = m_ pcCfg->getCRISEIPreLutNumValMinus1(c);4682 seiColourRemappingInfo->m_preLutNumValMinus1[c] = m_colourRemapSEIPreLutNumValMinus1[c]; 4506 4683 if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 ) 4507 4684 { … … 4510 4687 for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++) 4511 4688 { 4512 seiColourRemappingInfo->m_preLutCodedValue[c][i] = (m_pcCfg->getCRISEIPreLutCodedValue(c))[i];4513 seiColourRemappingInfo->m_preLutTargetValue[c][i] = (m_pcCfg->getCRISEIPreLutTargetValue(c))[i];4514 } 4515 } 4516 } 4517 seiColourRemappingInfo->m_colourRemapMatrixPresentFlag = m_ pcCfg->getCRISEIMatrixPresentFlag();4689 seiColourRemappingInfo->m_preLutCodedValue[c][i] = m_colourRemapSEIPreLutCodedValue[c][i]; 4690 seiColourRemappingInfo->m_preLutTargetValue[c][i] = m_colourRemapSEIPreLutTargetValue[c][i]; 4691 } 4692 } 4693 } 4694 seiColourRemappingInfo->m_colourRemapMatrixPresentFlag = m_colourRemapSEIMatrixPresentFlag; 4518 4695 if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag ) 4519 4696 { 4520 seiColourRemappingInfo->m_log2MatrixDenom = m_ pcCfg->getCRISEILog2MatrixDenom();4697 seiColourRemappingInfo->m_log2MatrixDenom = m_colourRemapSEILog2MatrixDenom; 4521 4698 for( Int c=0 ; c<3 ; c++ ) 4522 4699 for( Int i=0 ; i<3 ; i++ ) 4523 seiColourRemappingInfo->m_colourRemapCoeffs[c][i] = (m_pcCfg->getCRISEICoeffs(c))[i];4700 seiColourRemappingInfo->m_colourRemapCoeffs[c][i] = m_colourRemapSEICoeffs[c][i]; 4524 4701 } 4525 4702 for( Int c=0 ; c<3 ; c++ ) 4526 4703 { 4527 seiColourRemappingInfo->m_postLutNumValMinus1[c] = m_ pcCfg->getCRISEIPostLutNumValMinus1(c);4704 seiColourRemappingInfo->m_postLutNumValMinus1[c] = m_colourRemapSEIPostLutNumValMinus1[c]; 4528 4705 if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 ) 4529 4706 { … … 4532 4709 for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++) 4533 4710 { 4534 seiColourRemappingInfo->m_postLutCodedValue[c][i] = (m_pcCfg->getCRISEIPostLutCodedValue(c))[i];4535 seiColourRemappingInfo->m_postLutTargetValue[c][i] = (m_pcCfg->getCRISEIPostLutTargetValue(c))[i];4711 seiColourRemappingInfo->m_postLutCodedValue[c][i] = m_colourRemapSEIPostLutCodedValue[c][i]; 4712 seiColourRemappingInfo->m_postLutTargetValue[c][i] = m_colourRemapSEIPostLutTargetValue[c][i]; 4536 4713 } 4537 4714 } … … 5433 5610 #endif //SVC_EXTENSION 5434 5611 5612 #if Q0074_COLOUR_REMAPPING_SEI 5613 Bool confirmParameter(Bool bflag, const Char* message) 5614 { 5615 if (!bflag) 5616 return false; 5617 5618 printf("Error: %s\n",message); 5619 return true; 5620 } 5621 #endif 5622 5435 5623 //! \} -
branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h
r1037 r1089 88 88 #endif 89 89 90 #if Q0074_COLOUR_REMAPPING_SEI 91 string m_colourRemapSEIFile; 92 Int m_colourRemapSEIId; 93 Bool m_colourRemapSEICancelFlag; 94 Bool m_colourRemapSEIPersistenceFlag; 95 Bool m_colourRemapSEIVideoSignalInfoPresentFlag; 96 Bool m_colourRemapSEIFullRangeFlag; 97 Int m_colourRemapSEIPrimaries; 98 Int m_colourRemapSEITransferFunction; 99 Int m_colourRemapSEIMatrixCoefficients; 100 Int m_colourRemapSEIInputBitDepth; 101 Int m_colourRemapSEIBitDepth; 102 Int m_colourRemapSEIPreLutNumValMinus1[3]; 103 Int* m_colourRemapSEIPreLutCodedValue[3]; 104 Int* m_colourRemapSEIPreLutTargetValue[3]; 105 Bool m_colourRemapSEIMatrixPresentFlag; 106 Int m_colourRemapSEILog2MatrixDenom; 107 Int m_colourRemapSEICoeffs[3][3]; 108 Int m_colourRemapSEIPostLutNumValMinus1[3]; 109 Int* m_colourRemapSEIPostLutCodedValue[3]; 110 Int* m_colourRemapSEIPostLutTargetValue[3]; 111 #endif 90 112 // Access channel 91 113 TEncTop* m_pcEncTop; … … 245 267 246 268 #if Q0074_COLOUR_REMAPPING_SEI 269 Void setCRISEIFile( Char* pch ) { m_colourRemapSEIFile = pch; } 270 271 Void freeColourCRI(); 272 Int readingCRIparameters(); 273 Void xCheckParameter(); 274 247 275 SEIColourRemappingInfo* xCreateSEIColourRemappingInfo(); 248 276 #endif
Note: See TracChangeset for help on using the changeset viewer.