Changeset 856 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibDecoder
- Timestamp:
- 11 Aug 2014, 19:11:02 (10 years ago)
- Location:
- branches/SHM-dev/source/Lib/TLibDecoder
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibDecoder/SEIread.cpp
r847 r856 98 98 break; 99 99 #endif 100 #if Q0074_ SEI_COLOR_MAPPING101 case SEI::COLO R_MAPPING_INFO:102 fprintf( g_hTrace, "===========Colo r Mapping InfoSEI message ===========\n");100 #if Q0074_COLOUR_REMAPPING_SEI 101 case SEI::COLOUR_REMAPPING_INFO: 102 fprintf( g_hTrace, "===========Colour Remapping Information SEI message ===========\n"); 103 103 break; 104 104 #endif … … 132 132 fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n"); 133 133 break; 134 #if !REMOVE_BSP_HRD_SEI 134 135 case SEI::BSP_HRD: 135 136 fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n"); 136 137 break; 138 #endif 137 139 #endif 138 140 #if Q0078_ADD_LAYER_SETS … … 304 306 break; 305 307 #endif 306 #if Q0074_ SEI_COLOR_MAPPING307 case SEI::COLO R_MAPPING_INFO:308 sei = new SEIColo rMappingInfo;309 xParseSEIColo rMappingInfo((SEIColorMappingInfo&) *sei, payloadSize);308 #if Q0074_COLOUR_REMAPPING_SEI 309 case SEI::COLOUR_REMAPPING_INFO: 310 sei = new SEIColourRemappingInfo; 311 xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize); 310 312 break; 311 313 #endif … … 923 925 #endif 924 926 925 #if Q0074_ SEI_COLOR_MAPPING926 Void SEIReader::xParseSEIColo rMappingInfo(SEIColorMappingInfo& sei, UInt /*payloadSize*/)927 #if Q0074_COLOUR_REMAPPING_SEI 928 Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt /*payloadSize*/) 927 929 { 928 930 UInt uiVal; 929 931 Int iVal; 930 932 931 READ_UVLC( uiVal, "colour_map_id" ); sei.m_colorMapId = uiVal; 932 READ_FLAG( uiVal, "colour_map_cancel_flag" ); sei.m_colorMapCancelFlag = uiVal; 933 if( !sei.m_colorMapCancelFlag ) 934 { 935 READ_FLAG( uiVal, "colour_map_persistence_flag" ); sei.m_colorMapPersistenceFlag = uiVal; 936 READ_FLAG( uiVal, "colour_map_video_signal_type_present_flag" ); sei.m_colorMap_video_signal_type_present_flag = uiVal; 937 if ( sei.m_colorMap_video_signal_type_present_flag ) { 938 READ_FLAG( uiVal, "colour_map_video_full_range_flag" ); sei.m_colorMap_video_full_range_flag = uiVal; 939 READ_CODE( 8, uiVal, "colour_map_primaries" ); sei.m_colorMap_primaries = uiVal; 940 READ_CODE( 8, uiVal, "colour_map_transfer_characteristics" ); sei.m_colorMap_transfer_characteristics = uiVal; 941 READ_CODE( 8, uiVal, "colour_map_matrix_coeffs" ); sei.m_colorMap_matrix_coeffs = uiVal; 942 } 943 } 944 945 READ_CODE( 5, uiVal, "colour_map_coded_data_bit_depth" ); sei.m_colour_map_coded_data_bit_depth = uiVal; 946 READ_CODE( 5, uiVal, "colour_map_target_bit_depth" ); sei.m_colour_map_target_bit_depth = uiVal; 947 READ_UVLC( uiVal, "colour_map_model_id" ); sei.m_colorMapModelId = uiVal; 948 949 assert( sei.m_colorMapModelId == 0 ); 933 READ_UVLC( uiVal, "colour_remap_id" ); sei.m_colourRemapId = uiVal; 934 READ_FLAG( uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal; 935 if( !sei.m_colourRemapCancelFlag ) 936 { 937 READ_FLAG( uiVal, "colour_remap_persistence_flag" ); sei.m_colourRemapPersistenceFlag = uiVal; 938 READ_FLAG( uiVal, "colour_remap_video_signal_type_present_flag" ); sei.m_colourRemapVideoSignalTypePresentFlag = uiVal; 939 if ( sei.m_colourRemapVideoSignalTypePresentFlag ) 940 { 941 READ_FLAG( uiVal, "colour_remap_video_full_range_flag" ); sei.m_colourRemapVideoFullRangeFlag = uiVal; 942 READ_CODE( 8, uiVal, "colour_remap_primaries" ); sei.m_colourRemapPrimaries = uiVal; 943 READ_CODE( 8, uiVal, "colour_remap_transfer_characteristics" ); sei.m_colourRemapTransferCharacteristics = uiVal; 944 READ_CODE( 8, uiVal, "colour_remap_matrix_coeffs" ); sei.m_colourRemapMatrixCoeffs = uiVal; 945 } 946 READ_CODE( 8, uiVal, "colour_remap_coded_data_bit_depth" ); sei.m_colourRemapCodedDataBitDepth = uiVal; 947 READ_CODE( 8, uiVal, "colour_remap_target_bit_depth" ); sei.m_colourRemapTargetBitDepth = uiVal; 950 948 951 for( Int i=0 ; i<3 ; i++ ) 952 { 953 READ_CODE( 8, uiVal, "num_input_pivots_minus1[i]" ); sei.m_num_input_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ; 954 sei.m_coded_input_pivot_value[i] = new Int[ sei.m_num_input_pivots[i] ]; 955 sei.m_target_input_pivot_value[i] = new Int[ sei.m_num_input_pivots[i] ]; 956 if( uiVal > 0 ) 957 { 958 for ( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ ) 959 { 960 READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "coded_input_pivot_value[i][j]" ); sei.m_coded_input_pivot_value[i][j] = uiVal; 961 READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "target_input_pivot_value[i][j]" ); sei.m_target_input_pivot_value[i][j] = uiVal; 962 } 963 } 964 else 965 { 966 sei.m_coded_input_pivot_value[i][0] = 0; 967 sei.m_target_input_pivot_value[i][0] = 0; 968 sei.m_coded_input_pivot_value[i][1] = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ; 969 sei.m_target_input_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ; 970 } 971 } 972 973 READ_FLAG( uiVal, "matrix_flag" ); sei.m_matrix_flag = uiVal; 974 if( sei.m_matrix_flag ) 975 { 976 READ_CODE( 4, uiVal, "log2_matrix_denom" ); sei.m_log2_matrix_denom = uiVal; 977 for ( Int i=0 ; i<3 ; i++ ) 978 { 979 for ( Int j=0 ; j<3 ; j++ ) 980 { 981 READ_SVLC( iVal, "matrix_coef[i][j]" ); sei.m_matrix_coef[i][j] = iVal; 982 } 983 } 984 } 985 986 for ( Int i=0 ; i<3 ; i++ ) 987 { 988 READ_CODE( 8, uiVal, "num_output_pivots_minus1[i]" ); sei.m_num_output_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ; 989 sei.m_coded_output_pivot_value[i] = new Int[ sei.m_num_output_pivots[i] ]; 990 sei.m_target_output_pivot_value[i] = new Int[ sei.m_num_output_pivots[i] ]; 991 if( uiVal > 0 ) 992 { 993 for ( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ ) 994 { 995 READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "coded_output_pivot_value[i][j]" ); sei.m_coded_output_pivot_value[i][j] = uiVal; 996 READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "target_output_pivot_value[i][j]" ); sei.m_target_output_pivot_value[i][j] = uiVal; 997 } 998 } 999 else 1000 { 1001 sei.m_coded_output_pivot_value[i][0] = 0; 1002 sei.m_target_output_pivot_value[i][0] = 0; 1003 sei.m_coded_output_pivot_value[i][1] = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ; 1004 sei.m_target_output_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ; 949 for( Int c=0 ; c<3 ; c++ ) 950 { 951 READ_CODE( 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; 952 sei.m_preLutCodedValue[c].resize(sei.m_preLutNumValMinus1[c]+1); 953 sei.m_preLutTargetValue[c].resize(sei.m_preLutNumValMinus1[c]+1); 954 if( uiVal> 0 ) 955 for ( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) 956 { 957 READ_CODE( (( sei.m_colourRemapCodedDataBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" ); sei.m_preLutCodedValue[c][i] = uiVal; 958 READ_CODE( (( sei.m_colourRemapTargetBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLutTargetValue[c][i] = uiVal; 959 } 960 else // pre_lut_num_val_minus1[c] == 0 961 { 962 sei.m_preLutCodedValue[c][0] = 0; 963 sei.m_preLutTargetValue[c][0] = 0; 964 sei.m_preLutCodedValue[c][1] = (1 << sei.m_colourRemapCodedDataBitDepth) - 1 ; 965 sei.m_preLutTargetValue[c][1] = (1 << sei.m_colourRemapTargetBitDepth) - 1 ; 966 } 967 } 968 969 READ_FLAG( uiVal, "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresentFlag = uiVal; 970 if( sei.m_colourRemapMatrixPresentFlag ) 971 { 972 READ_CODE( 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal; 973 for ( Int c=0 ; c<3 ; c++ ) 974 for ( Int i=0 ; i<3 ; i++ ) 975 { 976 READ_SVLC( iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal; 977 } 978 } 979 else // setting default matrix (I3) 980 { 981 sei.m_log2MatrixDenom = 0; 982 for ( Int c=0 ; c<3 ; c++ ) 983 for ( Int i=0 ; i<3 ; i++ ) 984 sei.m_colourRemapCoeffs[c][i] = (c==i) ? 1 : 0; 985 } 986 for( Int c=0 ; c<3 ; c++ ) 987 { 988 READ_CODE( 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; 989 sei.m_postLutCodedValue[c].resize(sei.m_postLutNumValMinus1[c]+1); 990 sei.m_postLutTargetValue[c].resize(sei.m_postLutNumValMinus1[c]+1); 991 if( uiVal > 0 ) 992 for ( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) 993 { 994 READ_CODE( (( sei.m_colourRemapTargetBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" ); sei.m_postLutCodedValue[c][i] = uiVal; 995 READ_CODE( (( sei.m_colourRemapTargetBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLutTargetValue[c][i] = uiVal; 996 } 997 else 998 { 999 sei.m_postLutCodedValue[c][0] = 0; 1000 sei.m_postLutTargetValue[c][0] = 0; 1001 sei.m_postLutTargetValue[c][1] = (1 << sei.m_colourRemapTargetBitDepth) - 1; 1002 sei.m_postLutCodedValue[c][1] = (1 << sei.m_colourRemapTargetBitDepth) - 1; 1003 } 1005 1004 } 1006 1005 } -
branches/SHM-dev/source/Lib/TLibDecoder/SEIread.h
r846 r856 93 93 Void xParseSEIKneeFunctionInfo (SEIKneeFunctionInfo& sei, UInt payloadSize); 94 94 #endif 95 #if Q0074_ SEI_COLOR_MAPPING96 Void xParseSEIColo rMappingInfo (SEIColorMappingInfo& sei, UInt payloadSize);95 #if Q0074_COLOUR_REMAPPING_SEI 96 Void xParseSEIColourRemappingInfo (SEIColourRemappingInfo& sei, UInt payloadSize); 97 97 #endif 98 98 Void xParseSEISOPDescription (SEISOPDescription &sei, UInt payloadSize); -
branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp
r841 r856 54 54 //! \{ 55 55 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI); 56 #if Q0074_COLOUR_REMAPPING_SEI 57 static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* colourRemappingInfoSEI, UInt layerId=0 ); 58 static std::vector<SEIColourRemappingInfo> storeCriSEI; //Persistent Colour Remapping Information SEI 59 #endif 56 60 // ==================================================================================================================== 57 61 // Constructor / destructor / initialization / destroy … … 252 256 calcAndPrintHashStatus(*rpcPic->getPicYuvRec(), hash); 253 257 } 258 #if Q0074_COLOUR_REMAPPING_SEI 259 if (m_colourRemapSEIEnabled) 260 { 261 SEIMessages colourRemappingInfo = getSeisByType(rpcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO ); 262 const SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL; 263 if (colourRemappingInfo.size() > 1) 264 { 265 printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first."); 266 } 267 applyColourRemapping(*rpcPic->getPicYuvRec(), seiColourRemappingInfo 268 #if SVC_EXTENSION 269 , rpcPic->getLayerId() 270 #endif 271 ); 272 } 273 #endif 254 274 255 275 #if SETTING_PIC_OUTPUT_MARK … … 339 359 } 340 360 } 361 362 #if Q0074_COLOUR_REMAPPING_SEI 363 Void xInitColourRemappingLut( const Int bitDepthY, const Int bitDepthC, std::vector<Int>(&preLut)[3], std::vector<Int>(&postLut)[3], const SEIColourRemappingInfo* const pCriSEI ) 364 { 365 for ( Int c=0 ; c<3 ; c++ ) 366 { 367 Int bitDepth = c ? bitDepthC : bitDepthY ; 368 preLut[c].resize(1 << bitDepth); 369 postLut[c].resize(1 << pCriSEI->m_colourRemapTargetBitDepth); 370 371 Int bitDepthDiff = pCriSEI->m_colourRemapTargetBitDepth - bitDepth; 372 Int iShift1 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from bitdepth to TargetBitdepth (manage only case colourRemapTargetBitDepth>= bitdepth) 373 if( bitDepthDiff<0 ) 374 printf ("Warning: CRI SEI - colourRemapTargetBitDepth (%d) <bitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapTargetBitDepth, bitDepth); 375 bitDepthDiff = pCriSEI->m_colourRemapTargetBitDepth - pCriSEI->m_colourRemapCodedDataBitDepth; 376 Int iShift2 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from codedDataBitdepth to TargetBitdepth (manage only case colourRemapTargetBitDepth>= colourRemapCodedDataBitDepth) 377 if( bitDepthDiff<0 ) 378 printf ("Warning: CRI SEI - colourRemapTargetBitDepth (%d) <colourRemapCodedDataBitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapTargetBitDepth, pCriSEI->m_colourRemapCodedDataBitDepth); 379 380 //Fill preLut 381 for ( Int k=0 ; k<(1<<bitDepth) ; k++ ) 382 { 383 Int iSample = k << iShift1 ; 384 for ( Int iPivot=0 ; iPivot<=pCriSEI->m_preLutNumValMinus1[c] ; iPivot++ ) 385 { 386 Int iCodedPrev = pCriSEI->m_preLutCodedValue[c][iPivot] << iShift2; //Coded in CodedDataBitdepth 387 Int iCodedNext = pCriSEI->m_preLutCodedValue[c][iPivot+1] << iShift2; //Coded in CodedDataBitdepth 388 Int iTargetPrev = pCriSEI->m_preLutTargetValue[c][iPivot]; //Coded in TargetBitdepth 389 Int iTargetNext = pCriSEI->m_preLutTargetValue[c][iPivot+1]; //Coded in TargetBitdepth 390 if ( iCodedPrev <= iSample && iSample <= iCodedNext ) 391 { 392 Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev); 393 preLut[c][k] = (Int)( 0.5f + fInterpol ); 394 iPivot = pCriSEI->m_preLutNumValMinus1[c] + 1; 395 } 396 } 397 } 398 399 //Fill postLut 400 for ( Int k=0 ; k<(1<<pCriSEI->m_colourRemapTargetBitDepth) ; k++ ) 401 { 402 Int iSample = k; 403 for ( Int iPivot=0 ; iPivot<=pCriSEI->m_postLutNumValMinus1[c] ; iPivot++ ) 404 { 405 Int iCodedPrev = pCriSEI->m_postLutCodedValue[c][iPivot]; //Coded in TargetBitdepth 406 Int iCodedNext = pCriSEI->m_postLutCodedValue[c][iPivot+1]; //Coded in TargetBitdepth 407 Int iTargetPrev = pCriSEI->m_postLutTargetValue[c][iPivot]; //Coded in TargetBitdepth 408 Int iTargetNext = pCriSEI->m_postLutTargetValue[c][iPivot+1]; //Coded in TargetBitdepth 409 if ( iCodedPrev <= iSample && iSample <= iCodedNext ) 410 { 411 Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev) ; 412 postLut[c][k] = (Int)( 0.5f + fInterpol ); 413 iPivot = pCriSEI->m_postLutNumValMinus1[c] + 1; 414 } 415 } 416 } 417 } 418 } 419 420 static void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId ) 421 { 422 if( !storeCriSEI.size() ) 423 #if SVC_EXTENSION 424 storeCriSEI.resize(MAX_LAYERS); 425 #else 426 storeCriSEI.resize(1); 427 #endif 428 429 if ( pCriSEI ) //if a CRI SEI has just been retrieved, keep it in memory (persistence management) 430 storeCriSEI[layerId] = *pCriSEI; 431 432 if( !storeCriSEI[layerId].m_colourRemapCancelFlag ) 433 { 434 Int iHeight = pic.getHeight(); 435 Int iWidth = pic.getWidth(); 436 Int iStride = pic.getStride(); 437 Int iCStride = pic.getCStride(); 438 439 Pel *YUVIn[3], *YUVOut[3]; 440 YUVIn[0] = pic.getLumaAddr(); 441 YUVIn[1] = pic.getCbAddr(); 442 YUVIn[2] = pic.getCrAddr(); 443 444 TComPicYuv picColourRemapped; 445 #if SVC_EXTENSION 446 #if AUXILIARY_PICTURES 447 picColourRemapped.create( pic.getWidth(), pic.getHeight(), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); 448 #else 449 picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); 450 #endif 451 #else 452 picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 453 #endif 454 YUVOut[0] = picColourRemapped.getLumaAddr(); 455 YUVOut[1] = picColourRemapped.getCbAddr(); 456 YUVOut[2] = picColourRemapped.getCrAddr(); 457 458 #if SVC_EXTENSION 459 Int bitDepthY = g_bitDepthYLayer[layerId]; 460 Int bitDepthC = g_bitDepthCLayer[layerId]; 461 462 assert( g_bitDepthY == bitDepthY ); 463 assert( g_bitDepthC == bitDepthC ); 464 #else 465 Int bitDepthY = g_bitDepthY; 466 Int bitDepthC = g_bitDepthC; 467 #endif 468 469 std::vector<Int> preLut[3]; 470 std::vector<Int> postLut[3]; 471 xInitColourRemappingLut( bitDepthY, bitDepthC, preLut, postLut, &storeCriSEI[layerId] ); 472 473 Int roundingOffset = (storeCriSEI[layerId].m_log2MatrixDenom==0) ? 0 : (1 << (storeCriSEI[layerId].m_log2MatrixDenom - 1)); 474 475 for( Int y = 0; y < iHeight ; y++ ) 476 { 477 for( Int x = 0; x < iWidth ; x++ ) 478 { 479 Int YUVPre[3], YUVMat[3]; 480 YUVPre[0] = preLut[0][ YUVIn[0][x] ]; 481 YUVPre[1] = preLut[1][ YUVIn[1][x>>1] ]; 482 YUVPre[2] = preLut[2][ YUVIn[2][x>>1] ]; 483 484 YUVMat[0] = ( storeCriSEI[layerId].m_colourRemapCoeffs[0][0]*YUVPre[0] 485 + storeCriSEI[layerId].m_colourRemapCoeffs[0][1]*YUVPre[1] 486 + storeCriSEI[layerId].m_colourRemapCoeffs[0][2]*YUVPre[2] 487 + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom ); 488 YUVMat[0] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapTargetBitDepth)-1, YUVMat[0] ); 489 YUVOut[0][x] = postLut[0][ YUVMat[0] ]; 490 491 if( (y&1) && (x&1) ) 492 { 493 for(Int c=1 ; c<3 ; c++) 494 { 495 YUVMat[c] = ( storeCriSEI[layerId].m_colourRemapCoeffs[c][0]*YUVPre[0] 496 + storeCriSEI[layerId].m_colourRemapCoeffs[c][1]*YUVPre[1] 497 + storeCriSEI[layerId].m_colourRemapCoeffs[c][2]*YUVPre[2] 498 + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom ); 499 YUVMat[c] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapTargetBitDepth)-1, YUVMat[c] ); 500 YUVOut[c][x>>1] = postLut[c][ YUVMat[c] ]; 501 } 502 } 503 } 504 YUVIn[0] += iStride; 505 YUVOut[0] += iStride; 506 if( y&1 ) 507 { 508 YUVIn[1] += iCStride; 509 YUVIn[2] += iCStride; 510 YUVOut[1] += iCStride; 511 YUVOut[2] += iCStride; 512 } 513 } 514 515 //Write remapped picture in decoding order 516 Char cTemp[255]; 517 sprintf(cTemp, "seiColourRemappedPic_L%d_%dx%d_%dbits.yuv", layerId, iWidth, iHeight, storeCriSEI[layerId].m_colourRemapTargetBitDepth ); 518 picColourRemapped.dump( cTemp, true, storeCriSEI[layerId].m_colourRemapTargetBitDepth ); 519 520 picColourRemapped.destroy(); 521 522 storeCriSEI[layerId].m_colourRemapCancelFlag = !storeCriSEI[layerId].m_colourRemapPersistenceFlag; //Handling persistence 523 } 524 } 525 #endif 341 526 //! \} -
branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.h
r595 r856 82 82 Double m_dDecTime; 83 83 Int m_decodedPictureHashSEIEnabled; ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message 84 84 #if Q0074_COLOUR_REMAPPING_SEI 85 Bool m_colourRemapSEIEnabled; ///< Enable/disable Colour Remapping Information SEI message acting on decoded pictures 86 #endif 85 87 #if SVC_EXTENSION 86 88 UInt m_layerId; … … 114 116 115 117 void setDecodedPictureHashSEIEnabled(Int enabled) { m_decodedPictureHashSEIEnabled = enabled; } 118 #if Q0074_COLOUR_REMAPPING_SEI 119 void setColourRemappingInfoSEIEnabled(Int enabled) { m_colourRemapSEIEnabled = enabled; } 120 #endif 116 121 #if SVC_EXTENSION 117 122 TDecTop* getLayerDec(UInt LayerId) { return m_ppcTDecTop[LayerId]; } -
branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
r854 r856 117 117 #endif 118 118 119 #if Q0074_SEI_COLOR_MAPPING120 m_ColorMapping = new TDecColorMapping();121 #endif122 123 119 #if POC_RESET_RESTRICTIONS 124 120 resetPocRestrictionCheckParameters(); … … 137 133 delete m_pColorMappedPic; 138 134 m_pColorMappedPic = NULL; 139 }140 #endif141 #if Q0074_SEI_COLOR_MAPPING142 if ( m_ColorMapping )143 {144 delete m_ColorMapping;145 m_ColorMapping = NULL;146 135 } 147 136 #endif … … 891 880 g_uiMaxCUDepth = sps->getMaxCUDepth(); 892 881 g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() ); 893 894 #if Q0074_SEI_COLOR_MAPPING895 for(Int compID=0; compID<3; compID++)896 {897 m_ColorMapping->setColorMapping( compID ? g_bitDepthC : g_bitDepthY, compID );898 }899 #endif900 882 901 883 for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) … … 2324 2306 } 2325 2307 } 2326 #if Q0074_SEI_COLOR_MAPPING2327 m_ColorMapping->setColorMapping( m_SEIs );2328 #endif2329 2308 } 2330 2309 #else … … 2857 2836 #endif //SVC_EXTENSION 2858 2837 2859 #if Q0074_SEI_COLOR_MAPPING2860 TDecColorMapping::TDecColorMapping()2861 {2862 m_pcColorMappingPic[0] = NULL;2863 m_pcColorMappingPic[1] = NULL;2864 2865 m_colorMapCancelFlag = true;2866 2867 for( Int i=0 ; i<3 ; i++ )2868 {2869 m_lut1d_computed[i] = false;2870 m_lut1d_input[i] = NULL;2871 m_coded_input_pivot_value[i] = NULL;2872 m_target_input_pivot_value[i] = NULL;2873 }2874 for( Int i=0 ; i<3 ; i++ )2875 {2876 m_lut1d_output[i] = NULL;2877 m_coded_output_pivot_value[i] = NULL;2878 m_target_output_pivot_value[i] = NULL;2879 }2880 }2881 2882 TDecColorMapping::~TDecColorMapping()2883 {2884 if ( m_pcColorMappingPic[0] ) delete m_pcColorMappingPic[0];2885 if ( m_pcColorMappingPic[1] ) delete m_pcColorMappingPic[1];2886 2887 for( Int i=0 ; i<3 ; i++ )2888 {2889 if ( m_lut1d_input[i] ) delete m_lut1d_input[i];2890 if ( m_coded_input_pivot_value[i] ) delete m_coded_input_pivot_value[i];2891 if ( m_target_input_pivot_value[i] ) delete m_target_input_pivot_value[i];2892 }2893 for( Int i=0 ; i<3 ; i++ )2894 {2895 if ( m_lut1d_output[i] ) delete m_lut1d_output[i];2896 if ( m_coded_output_pivot_value[i] ) delete m_coded_output_pivot_value[i];2897 if ( m_target_output_pivot_value[i] ) delete m_target_output_pivot_value[i];2898 }2899 }2900 2901 Void TDecColorMapping::setColorMapping( SEIMessages m_SEIs )2902 {2903 SEIMessages colorMappingInfo = getSeisByType(m_SEIs, SEI::COLOR_MAPPING_INFO) ;2904 SEIColorMappingInfo *seiColorMappingInfo = NULL;2905 if (colorMappingInfo.size() !=0)2906 {2907 seiColorMappingInfo = (SEIColorMappingInfo*)(*colorMappingInfo.begin());2908 2909 m_colorMapId = seiColorMappingInfo->m_colorMapId;2910 m_colorMapCancelFlag = seiColorMappingInfo->m_colorMapCancelFlag;2911 if( !m_colorMapCancelFlag )2912 {2913 m_colorMapPersistenceFlag = seiColorMappingInfo->m_colorMapPersistenceFlag;2914 m_colorMap_video_signal_type_present_flag = seiColorMappingInfo->m_colorMap_video_signal_type_present_flag;2915 m_colorMap_video_full_range_flag = seiColorMappingInfo->m_colorMap_video_full_range_flag;2916 m_colorMap_primaries = seiColorMappingInfo->m_colorMap_primaries;2917 m_colorMap_transfer_characteristics = seiColorMappingInfo->m_colorMap_transfer_characteristics;2918 m_colorMap_matrix_coeffs = seiColorMappingInfo->m_colorMap_matrix_coeffs;2919 m_colorMapModelId = seiColorMappingInfo->m_colorMapModelId;2920 2921 m_colour_map_coded_data_bit_depth = seiColorMappingInfo->m_colour_map_coded_data_bit_depth;2922 m_colour_map_target_bit_depth = seiColorMappingInfo->m_colour_map_target_bit_depth;2923 2924 for( Int i=0 ; i<3 ; i++ )2925 {2926 m_num_input_pivots[i] = seiColorMappingInfo->m_num_input_pivots[i];2927 if ( m_coded_input_pivot_value[i] ) delete m_coded_input_pivot_value[i];2928 if ( m_target_input_pivot_value[i] ) delete m_target_input_pivot_value[i];2929 m_coded_input_pivot_value[i] = new Int[ m_num_input_pivots[i] ];2930 m_target_input_pivot_value[i] = new Int[ m_num_input_pivots[i] ];2931 for( Int j=0 ; j<m_num_input_pivots[i] ; j++ )2932 {2933 m_coded_input_pivot_value[i][j] = seiColorMappingInfo->m_coded_input_pivot_value[i][j];2934 m_target_input_pivot_value[i][j] = seiColorMappingInfo->m_target_input_pivot_value[i][j];2935 }2936 }2937 2938 m_matrix_flag = seiColorMappingInfo->m_matrix_flag;2939 m_log2_matrix_denom = m_matrix_flag ? (seiColorMappingInfo->m_log2_matrix_denom) : (0) ;2940 for( Int i=0 ; i<3 ; i++ )2941 {2942 for( Int j=0 ; j<3 ; j++ )2943 {2944 m_matrix_coef[i][j] = seiColorMappingInfo->m_matrix_coef[i][j];2945 }2946 }2947 2948 for( Int i=0 ; i<3 ; i++ )2949 {2950 m_num_output_pivots[i] = seiColorMappingInfo->m_num_output_pivots[i];2951 if ( m_coded_output_pivot_value[i] ) delete m_coded_output_pivot_value[i];2952 if ( m_target_output_pivot_value[i] ) delete m_target_output_pivot_value[i];2953 m_coded_output_pivot_value[i] = new Int[ m_num_output_pivots[i] ];2954 m_target_output_pivot_value[i] = new Int[ m_num_output_pivots[i] ];2955 for( Int j=0 ; j<m_num_output_pivots[i] ; j++ )2956 {2957 m_coded_output_pivot_value[i][j] = seiColorMappingInfo->m_coded_output_pivot_value[i][j];2958 m_target_output_pivot_value[i][j] = seiColorMappingInfo->m_target_output_pivot_value[i][j];2959 }2960 }2961 2962 memset( m_lut1d_computed, 0, sizeof( m_lut1d_computed ) );2963 }2964 }2965 2966 }2967 2968 Void TDecColorMapping::setColorMapping( Int bitDepth, Int iComp )2969 {2970 if( !m_colorMapCancelFlag && !m_lut1d_computed[iComp] )2971 {2972 2973 if ( m_lut1d_input[iComp] ) delete m_lut1d_input[iComp];2974 if ( m_lut1d_output[iComp] ) delete m_lut1d_output[iComp];2975 2976 m_lut1d_input[iComp] = new Int[ 1 << bitDepth ];2977 m_lut1d_output[iComp] = new Int[ 1 << bitDepth ];2978 2979 Int iShift = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0);2980 Int iShiftPivot = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_coded_data_bit_depth);2981 2982 for( Int k=0 ; k<(1<<bitDepth) ; k++ )2983 {2984 Int iSample = k << iShift ;2985 if( m_num_input_pivots[iComp] > 1 )2986 {2987 for( Int iPivot=0 ; iPivot<m_num_input_pivots[iComp] ; iPivot++ )2988 {2989 Int iCodedPrev = m_coded_input_pivot_value[iComp][iPivot] << iShiftPivot;2990 Int iCodedNext = m_coded_input_pivot_value[iComp][iPivot+1] << iShiftPivot;2991 Int iTargetPrev = m_target_input_pivot_value[iComp][iPivot] << iShiftPivot;2992 Int iTargetNext = m_target_input_pivot_value[iComp][iPivot+1] << iShiftPivot;2993 if ( iCodedPrev <= iSample && iSample < iCodedNext )2994 {2995 Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ;2996 m_lut1d_input[iComp][k] = (Int)( 0.5 + fInterpol );2997 iPivot = m_num_input_pivots[iComp]; // stop2998 }2999 }3000 }3001 else3002 {3003 m_lut1d_input[iComp][k] = k;3004 }3005 }3006 3007 iShift = ( (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0) );3008 Int iOffset = iShift ? (1 << (iShift - 1)) : (0) ;3009 iShiftPivot = (m_colour_map_target_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_target_bit_depth) ;3010 for( Int k=0 ; k<(1<<bitDepth) ; k++ )3011 {3012 Int iSample = k << iShift;3013 if ( m_num_output_pivots[iComp]>1 )3014 {3015 for( Int iPivot=0 ; iPivot<m_num_output_pivots[iComp] ; iPivot++ )3016 {3017 Int iCodedPrev = m_coded_output_pivot_value[iComp][iPivot] << iShiftPivot;3018 Int iCodedNext = m_coded_output_pivot_value[iComp][iPivot+1] << iShiftPivot;3019 Int iTargetPrev = m_target_output_pivot_value[iComp][iPivot] << iShiftPivot;3020 Int iTargetNext = m_target_output_pivot_value[iComp][iPivot+1] << iShiftPivot;3021 if ( iCodedPrev <= iSample && iSample < iCodedNext )3022 {3023 Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ;3024 m_lut1d_output[iComp][k] = ( (Int)(0.5 + fInterpol) + iOffset ) >> iShift ;3025 iPivot = m_num_output_pivots[iComp]; // stop3026 }3027 }3028 }3029 else3030 {3031 m_lut1d_output[iComp][k] = k;3032 }3033 }3034 3035 m_lut1d_computed[iComp] = true;3036 }3037 3038 }3039 3040 TComPicYuv* TDecColorMapping::getColorMapping( TComPicYuv* pPicYuvRec, Int iTop, Int curlayerId )3041 {3042 if( !m_colorMapCancelFlag )3043 {3044 if( !m_pcColorMappingPic[iTop] )3045 {3046 m_pcColorMappingPic[iTop] = new TComPicYuv;3047 #if SVC_EXTENSION3048 m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), pPicYuvRec->getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );3049 #else3050 m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );3051 #endif3052 }3053 3054 Int iHeight = pPicYuvRec->getHeight();3055 Int iWidth = pPicYuvRec->getWidth();3056 Int iStride = pPicYuvRec->getStride();3057 Int iCStride = pPicYuvRec->getCStride();3058 3059 Pel* Lum0 = pPicYuvRec->getLumaAddr();3060 Pel* Cb0 = pPicYuvRec->getCbAddr();3061 Pel* Cr0 = pPicYuvRec->getCrAddr();3062 Pel* Lum1 = m_pcColorMappingPic[iTop]->getLumaAddr();3063 Pel* Cb1 = m_pcColorMappingPic[iTop]->getCbAddr();3064 Pel* Cr1 = m_pcColorMappingPic[iTop]->getCrAddr();3065 3066 #if SVC_EXTENSION3067 Int bitDepthY = g_bitDepthYLayer[curlayerId];3068 Int bitDepthC = g_bitDepthCLayer[curlayerId];3069 3070 assert( g_bitDepthY == bitDepthY );3071 assert( g_bitDepthC == bitDepthC );3072 #else3073 Int bitDepthY = g_bitDepthY;3074 Int bitDepthC = g_bitDepthC;3075 #endif3076 3077 Int iYShift = (m_colour_map_target_bit_depth >= bitDepthY) ? (m_colour_map_target_bit_depth - bitDepthY) : (0) ;3078 Int iCShift = (m_colour_map_target_bit_depth >= bitDepthC) ? (m_colour_map_target_bit_depth - bitDepthC) : (0) ;3079 Int offsetY = (1 << (m_log2_matrix_denom+iYShift - 1));3080 Int offsetC = (1 << (m_log2_matrix_denom+iCShift - 1));3081 3082 Int cShift = 1 ;3083 3084 //Pel* LumPrev0 = Lum0;3085 for( Int y = 0; y < iHeight ; y++ )3086 {3087 Bool bDoChroma = (y % 2);3088 for( Int x = 0; x < iWidth ; x++ )3089 {3090 Int s1Y = m_lut1d_input[0][ Lum0[x] ];3091 Int s1U = m_lut1d_input[1][ Cb0[x>>1] ];3092 Int s1V = m_lut1d_input[2][ Cr0[x>>1] ];3093 3094 Int s2Y, s2U, s2V;3095 if( m_matrix_flag )3096 {3097 s2Y = ( m_matrix_coef[0][0]*s1Y + m_matrix_coef[0][1]*s1U + m_matrix_coef[0][2]*s1V + offsetY ) >> ( m_log2_matrix_denom + iYShift );3098 //s2Y = ClipBD( s2Y , bitDepthY );3099 s2Y = ClipY( s2Y );3100 Lum1[x] = m_lut1d_output[0][ s2Y ];3101 }3102 else3103 {3104 s1Y = ( s1Y + offsetY ) >> iYShift ;3105 //s1Y = ClipBD( s1Y , bitDepthY );3106 s1Y = ClipY( s1Y );3107 Lum1[x] = m_lut1d_output[0][ s1Y ];3108 }3109 3110 if( bDoChroma && (x%2) )3111 {3112 if( m_matrix_flag )3113 {3114 //s1Y = ( m_lut1d_input[0][ Lum0[x] ] + m_lut1d_input[0][ Lum0[x+1] ] + m_lut1d_input[0][ LumPrev0[x] ] + m_lut1d_input[0][ LumPrev0[x+1] ] + 2 ) >> 2 ;3115 //s1Y = m_lut1d_input[0][ (Lum0[x] + Lum0[x+1] + LumPrev0[x] + LumPrev0[x+1] + 2)>>2 ] ;3116 s1Y = m_lut1d_input[0][ Lum0[x] ];3117 3118 s2U = ( m_matrix_coef[1][0]*s1Y + m_matrix_coef[1][1]*s1U + m_matrix_coef[1][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ;3119 s2V = ( m_matrix_coef[2][0]*s1Y + m_matrix_coef[2][1]*s1U + m_matrix_coef[2][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ;3120 //s2U = ClipBD( s2U , bitDepthC );3121 //s2V = ClipBD( s2V , bitDepthC );3122 s2U = ClipC( s2U );3123 s2V = ClipC( s2V );3124 Cb1[x>>cShift] = m_lut1d_output[1][ s2U ];3125 Cr1[x>>cShift] = m_lut1d_output[2][ s2V ];3126 }3127 else3128 {3129 s1U = ( s1U + offsetC ) >> iCShift ;3130 s1V = ( s1V + offsetC ) >> iCShift ;3131 //s1U = ClipBD( s1U , bitDepthC );3132 //s1V = ClipBD( s1V , bitDepthC );3133 s1U = ClipC( s1U );3134 s1V = ClipC( s1V );3135 Cb1[x>>cShift] = m_lut1d_output[1][ s1U ];3136 Cr1[x>>cShift] = m_lut1d_output[2][ s1V ];3137 }3138 }3139 3140 }3141 3142 //LumPrev0 = Lum0;3143 Lum0 += iStride;3144 Lum1 += iStride;3145 if( bDoChroma )3146 {3147 Cb0 += iCStride;3148 Cr0 += iCStride;3149 Cb1 += iCStride;3150 Cr1 += iCStride;3151 }3152 }3153 3154 return m_pcColorMappingPic[iTop];3155 }3156 3157 return pPicYuvRec;3158 }3159 #endif3160 2838 3161 2839 //! \} -
branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h
r854 r856 64 64 // ==================================================================================================================== 65 65 66 #if Q0074_SEI_COLOR_MAPPING67 class TDecColorMapping68 {69 Int m_colorMapId;70 Bool m_colorMapCancelFlag;71 Bool m_colorMapPersistenceFlag;72 Bool m_colorMap_video_signal_type_present_flag;73 Bool m_colorMap_video_full_range_flag;74 Int m_colorMap_primaries;75 Int m_colorMap_transfer_characteristics;76 Int m_colorMap_matrix_coeffs;77 Int m_colorMapModelId;78 79 Int m_colour_map_coded_data_bit_depth;80 Int m_colour_map_target_bit_depth;81 82 Int m_num_input_pivots[3];83 Int* m_coded_input_pivot_value[3];84 Int* m_target_input_pivot_value[3];85 86 Bool m_matrix_flag;87 Int m_log2_matrix_denom;88 Int m_matrix_coef[3][3];89 90 Int m_num_output_pivots[3];91 Int* m_coded_output_pivot_value[3];92 Int* m_target_output_pivot_value[3];93 94 Bool m_lut1d_computed[3];95 Int* m_lut1d_input[3];96 Int* m_lut1d_output[3];97 TComPicYuv* m_pcColorMappingPic[2];98 99 public:100 TDecColorMapping();101 ~TDecColorMapping();102 103 Bool getColorMappingFlag() { return(!m_colorMapCancelFlag);};104 105 Void setColorMapping( SEIMessages m_SEIs );106 Void setColorMapping( Int bitDepthY, Int bitDepthC );107 TComPicYuv* getColorMapping( TComPicYuv* pPicYuvRec, Int iTop=0, Int curlayerId=0 );108 };// END CLASS DEFINITION TDecColorMapping109 #endif110 111 66 /// decoder class 112 67 class TDecTop … … 209 164 #endif 210 165 public: 211 #if Q0074_SEI_COLOR_MAPPING212 TDecColorMapping* m_ColorMapping;213 #endif214 215 166 #if POC_RESET_RESTRICTIONS 216 167 static Bool m_checkPocRestrictionsForCurrAu; … … 236 187 237 188 void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } 189 #if Q0074_COLOUR_REMAPPING_SEI 190 void setColourRemappingInfoSEIEnabled(Bool enabled) { m_cGopDecoder.setColourRemappingInfoSEIEnabled(enabled); } 191 #endif 238 192 239 193 Void init();
Note: See TracChangeset for help on using the changeset viewer.