Changeset 1386 in 3DVCSoftware for trunk/source/App/TAppDecoder/TAppDecTop.cpp
- Timestamp:
- 13 Nov 2015, 16:29:39 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/App/TAppDecoder/TAppDecTop.cpp
r1321 r1386 62 62 : m_numDecoders( 0 ) 63 63 #endif 64 ,m_pcSeiColourRemappingInfoPrevious(NULL) 64 65 { 65 66 #if NH_MV … … 118 119 xDestroyDecLib(); 119 120 #endif 120 121 if (m_pchBitstreamFile) 122 { 123 free (m_pchBitstreamFile); 124 m_pchBitstreamFile = NULL; 125 } 121 m_bitstreamFileName.clear(); 126 122 #if NH_MV 127 123 for (Int decIdx = 0; decIdx < m_numDecoders; decIdx++) … … 134 130 } 135 131 #endif 136 if (m_pchReconFile) 137 { 138 free (m_pchReconFile); 139 m_pchReconFile = NULL; 140 } 132 m_reconFileName.clear(); 141 133 #if NH_3D 142 134 if (m_pchScaleOffsetFile) … … 160 152 . 161 153 */ 162 163 154 #if NH_MV 164 Void TAppDecTop::decode() 165 { 155 Void TAppDecTop::decode( Int num ) 156 { 157 m_targetOptLayerSetIdx = m_targetOptLayerSetInd[ num ]; 166 158 // create & initialize internal classes 167 159 xInitFileIO (); … … 221 213 222 214 #if !NH_MV 223 Void TAppDecTop::decode( )215 Void TAppDecTop::decode( ) 224 216 { 225 217 Int poc; 226 218 TComList<TComPic*>* pcListPic = NULL; 227 219 228 ifstream bitstreamFile(m_ pchBitstreamFile, ifstream::in | ifstream::binary);220 ifstream bitstreamFile(m_bitstreamFileName.c_str(), ifstream::in | ifstream::binary); 229 221 if (!bitstreamFile) 230 222 { 231 fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_ pchBitstreamFile);223 fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_bitstreamFileName.c_str()); 232 224 exit(EXIT_FAILURE); 233 225 } … … 250 242 251 243 m_iPOCLastDisplay += m_iSkipFrame; // set the last displayed POC correctly for skip forward. 244 245 // clear contents of colour-remap-information-SEI output file 246 if (!m_colourRemapSEIFileName.empty()) 247 { 248 std::ofstream ofile(m_colourRemapSEIFileName.c_str()); 249 if (!ofile.good() || !ofile.is_open()) 250 { 251 fprintf(stderr, "\nUnable to open file '%s' for writing colour-remap-information-SEI video\n", m_colourRemapSEIFileName.c_str()); 252 exit(EXIT_FAILURE); 253 } 254 } 252 255 253 256 // main decoder loop … … 336 339 if( pcListPic ) 337 340 { 338 if ( m_pchReconFile && !openedReconFile)341 if ( (!m_reconFileName.empty()) && (!openedReconFile) ) 339 342 { 340 343 const BitDepths &bitDepths=pcListPic->front()->getPicSym()->getSPS().getBitDepths(); // use bit depths of first reconstructed picture. … … 346 349 } 347 350 } 348 m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode 351 352 m_cTVideoIOYuvReconFile.open( m_reconFileName, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode 349 353 openedReconFile = true; 350 354 } … … 436 440 } 437 441 #else 438 if ( m_pchReconFile)442 if ( !m_reconFileName.empty() ) 439 443 { 440 444 m_cTVideoIOYuvReconFile. close(); … … 444 448 m_cTDecTop.destroy(); 445 449 #endif 450 if (m_pcSeiColourRemappingInfoPrevious != NULL) 451 { 452 delete m_pcSeiColourRemappingInfoPrevious; 453 m_pcSeiColourRemappingInfoPrevious = NULL; 454 } 446 455 #if NH_3D 447 456 m_cCamParsCollector.uninit(); … … 474 483 } 475 484 #endif 485 if (m_pcSeiColourRemappingInfoPrevious != NULL) 486 { 487 delete m_pcSeiColourRemappingInfoPrevious; 488 m_pcSeiColourRemappingInfoPrevious = NULL; 489 } 476 490 } 477 491 … … 549 563 // write to file 550 564 numPicsNotYetDisplayed = numPicsNotYetDisplayed-2; 551 if ( m_pchReconFile)565 if ( !m_reconFileName.empty() ) 552 566 { 553 567 const Window &conf = pcPicTop->getConformanceWindow(); … … 617 631 dpbFullness--; 618 632 } 619 if ( m_pchReconFile)633 if ( !m_reconFileName.empty() ) 620 634 { 621 635 const Window &conf = pcPic->getConformanceWindow(); … … 631 645 } 632 646 647 if (!m_colourRemapSEIFileName.empty()) 648 { 649 xOutputColourRemapPic(pcPic); 650 } 651 633 652 // update POC of display order 634 653 m_iPOCLastDisplay = pcPic->getPOC(); … … 678 697 // write to file 679 698 680 if ( m_pchReconFile)699 if ( !m_reconFileName.empty() ) 681 700 { 682 701 const Window &conf = pcPicTop->getConformanceWindow(); … … 736 755 { 737 756 // write to file 738 if ( m_pchReconFile)757 if ( !m_reconFileName.empty() ) 739 758 { 740 759 const Window &conf = pcPic->getConformanceWindow(); … … 749 768 } 750 769 770 if (!m_colourRemapSEIFileName.empty()) 771 { 772 xOutputColourRemapPic(pcPic); 773 } 774 751 775 // update POC of display order 752 776 m_iPOCLastDisplay = pcPic->getPOC(); … … 1068 1092 m_newVpsActivatedbyCurAu = true; //TBD 1069 1093 m_newVpsActivatedbyCurPic = true; 1070 #if NH_3D 1094 #if NH_3D_VSO 1071 1095 m_dpb.setVPS( m_vps ); 1072 1096 #endif … … 1232 1256 } 1233 1257 1234 if ( m_printVpsInfo && ( m_decProcCvsg == ANNEX_F ) )1258 if ( m_printVpsInfo && ( m_decProcCvsg == ANNEX_F ) && ( m_targetOptLayerSetIdx == m_targetOptLayerSetInd[ 0 ] ) ) 1235 1259 { 1236 1260 m_vps->printScalabilityId(); … … 1979 2003 // - After all slices of the current picture have been decoded, the decoding process for ending the decoding of a 1980 2004 // coded picture with nuh_layer_id greater than 0 specified in clause F.8.1.6 is invoked. 1981 xF816decProcEndDecOfCodPicLIdGrtZero( ); 2005 xF816decProcEndDecOfCodPicLIdGrtZero( ); 1982 2006 } 1983 2007 … … 2671 2695 2672 2696 // create recon file related stuff 2673 Char* pchTempFilename = NULL;2674 if ( m_pchReconFile)2675 { 2676 Char buffer[4];2697 TChar* pchTempFilename = NULL; 2698 if ( !m_reconFileName.empty() ) 2699 { 2700 TChar buffer[4]; 2677 2701 sprintf(buffer,"_%i", layerId ); 2678 assert ( m_pchReconFile);2679 xAppendToFileNameEnd( m_ pchReconFile, buffer, pchTempFilename );2702 assert ( !m_reconFileName.empty() ); 2703 xAppendToFileNameEnd( m_reconFileName.c_str() , buffer, pchTempFilename ); 2680 2704 assert( m_pchReconFiles.size() == m_numDecoders ); 2681 2705 } … … 2870 2894 Void TAppDecTop::xInitFileIO() 2871 2895 { 2872 m_bitstreamFile.open(m_ pchBitstreamFile, ifstream::in | ifstream::binary);2896 m_bitstreamFile.open(m_bitstreamFileName.c_str(), ifstream::in | ifstream::binary); 2873 2897 2874 2898 if ( !m_bitstreamFile) 2875 2899 { 2876 fprintf(stderr, "\nUnable to open bitstream file `%s' for reading\n", m_ pchBitstreamFile);2900 fprintf(stderr, "\nUnable to open bitstream file `%s' for reading\n", m_bitstreamFileName.c_str()); 2877 2901 exit(EXIT_FAILURE); 2878 2902 } … … 2905 2929 Int decIdx = xGetDecoderIdx( curPic->getLayerId() ); 2906 2930 2907 if ( m_pchReconFile&& !m_reconOpen[decIdx] )2931 if ( !m_reconFileName.empty() && !m_reconOpen[decIdx] ) 2908 2932 { 2909 2933 const BitDepths &bitDepths= curPic->getPicSym()->getSPS().getBitDepths(); // use bit depths of first reconstructed picture. … … 3007 3031 3008 3032 #endif 3033 3034 Void TAppDecTop::xOutputColourRemapPic(TComPic* pcPic) 3035 { 3036 const TComSPS &sps=pcPic->getPicSym()->getSPS(); 3037 SEIMessages colourRemappingInfo = getSeisByType(pcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO ); 3038 SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL; 3039 3040 if (colourRemappingInfo.size() > 1) 3041 { 3042 printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first."); 3043 } 3044 if (seiColourRemappingInfo) 3045 { 3046 applyColourRemapping(*pcPic->getPicYuvRec(), *seiColourRemappingInfo, sps); 3047 3048 // save the last CRI SEI received 3049 if (m_pcSeiColourRemappingInfoPrevious == NULL) 3050 { 3051 m_pcSeiColourRemappingInfoPrevious = new SEIColourRemappingInfo(); 3052 } 3053 m_pcSeiColourRemappingInfoPrevious->copyFrom(*seiColourRemappingInfo); 3054 } 3055 else // using the last CRI SEI received 3056 { 3057 // TODO: prevent persistence of CRI SEI across C(L)VS. 3058 if (m_pcSeiColourRemappingInfoPrevious != NULL) 3059 { 3060 if (m_pcSeiColourRemappingInfoPrevious->m_colourRemapPersistenceFlag == false) 3061 { 3062 printf("Warning No SEI-CRI message is present for the current picture, persistence of the CRI is not managed\n"); 3063 } 3064 applyColourRemapping(*pcPic->getPicYuvRec(), *m_pcSeiColourRemappingInfoPrevious, sps); 3065 } 3066 } 3067 } 3068 3069 // compute lut from SEI 3070 // use at lutPoints points aligned on a power of 2 value 3071 // SEI Lut must be in ascending values of coded Values 3072 static std::vector<Int> 3073 initColourRemappingInfoLut(const Int bitDepth_in, // bit-depth of the input values of the LUT 3074 const Int nbDecimalValues, // Position of the fixed point 3075 const std::vector<SEIColourRemappingInfo::CRIlut> &lut, 3076 const Int maxValue, // maximum output value 3077 const Int lutOffset) 3078 { 3079 const Int lutPoints = (1 << bitDepth_in) + 1 ; 3080 std::vector<Int> retLut(lutPoints); 3081 3082 // missing values: need to define default values before first definition (check codedValue[0] == 0) 3083 Int iTargetPrev = (lut.size() && lut[0].codedValue == 0) ? lut[0].targetValue: 0; 3084 Int startPivot = (lut.size())? ((lut[0].codedValue == 0)? 1: 0): 1; 3085 Int iCodedPrev = 0; 3086 // set max value with the coded bit-depth 3087 // + ((1 << nbDecimalValues) - 1) is for the added bits 3088 const Int maxValueFixedPoint = (maxValue << nbDecimalValues) + ((1 << nbDecimalValues) - 1); 3089 3090 Int iValue = 0; 3091 3092 for ( Int iPivot=startPivot ; iPivot < (Int)lut.size(); iPivot++ ) 3093 { 3094 Int iCodedNext = lut[iPivot].codedValue; 3095 Int iTargetNext = lut[iPivot].targetValue; 3096 3097 // ensure correct bit depth and avoid overflow in lut address 3098 Int iCodedNext_bitDepth = std::min(iCodedNext, (1 << bitDepth_in)); 3099 3100 const Int divValue = (iCodedNext - iCodedPrev > 0)? (iCodedNext - iCodedPrev): 1; 3101 const Int lutValInit = (lutOffset + iTargetPrev) << nbDecimalValues; 3102 const Int roundValue = divValue / 2; 3103 for ( ; iValue<iCodedNext_bitDepth; iValue++ ) 3104 { 3105 Int value = iValue; 3106 Int interpol = ((((value-iCodedPrev) * (iTargetNext - iTargetPrev)) << nbDecimalValues) + roundValue) / divValue; 3107 retLut[iValue] = std::min(lutValInit + interpol , maxValueFixedPoint); 3108 } 3109 iCodedPrev = iCodedNext; 3110 iTargetPrev = iTargetNext; 3111 } 3112 // fill missing values if necessary 3113 if(iCodedPrev < (1 << bitDepth_in)+1) 3114 { 3115 Int iCodedNext = (1 << bitDepth_in); 3116 Int iTargetNext = (1 << bitDepth_in) - 1; 3117 3118 const Int divValue = (iCodedNext - iCodedPrev > 0)? (iCodedNext - iCodedPrev): 1; 3119 const Int lutValInit = (lutOffset + iTargetPrev) << nbDecimalValues; 3120 const Int roundValue = divValue / 2; 3121 3122 for ( ; iValue<=iCodedNext; iValue++ ) 3123 { 3124 Int value = iValue; 3125 Int interpol = ((((value-iCodedPrev) * (iTargetNext - iTargetPrev)) << nbDecimalValues) + roundValue) / divValue; 3126 retLut[iValue] = std::min(lutValInit + interpol , maxValueFixedPoint); 3127 } 3128 } 3129 return retLut; 3130 } 3131 3132 static Void 3133 initColourRemappingInfoLuts(std::vector<Int> (&preLut)[3], 3134 std::vector<Int> (&postLut)[3], 3135 SEIColourRemappingInfo &pCriSEI, 3136 const Int maxBitDepth) 3137 { 3138 Int internalBitDepth = pCriSEI.m_colourRemapBitDepth; 3139 for ( Int c=0 ; c<3 ; c++ ) 3140 { 3141 std::sort(pCriSEI.m_preLut[c].begin(), pCriSEI.m_preLut[c].end()); // ensure preLut is ordered in ascending values of codedValues 3142 preLut[c] = initColourRemappingInfoLut(pCriSEI.m_colourRemapInputBitDepth, maxBitDepth - pCriSEI.m_colourRemapInputBitDepth, pCriSEI.m_preLut[c], ((1 << internalBitDepth) - 1), 0); //Fill preLut 3143 3144 std::sort(pCriSEI.m_postLut[c].begin(), pCriSEI.m_postLut[c].end()); // ensure postLut is ordered in ascending values of codedValues 3145 postLut[c] = initColourRemappingInfoLut(pCriSEI.m_colourRemapBitDepth, maxBitDepth - pCriSEI.m_colourRemapBitDepth, pCriSEI.m_postLut[c], (1 << internalBitDepth) - 1, 0); //Fill postLut 3146 } 3147 } 3148 3149 // apply lut. 3150 // Input lut values are aligned on power of 2 boundaries 3151 static Int 3152 applyColourRemappingInfoLut1D(Int inVal, const std::vector<Int> &lut, const Int inValPrecisionBits) 3153 { 3154 const Int roundValue = (inValPrecisionBits)? 1 << (inValPrecisionBits - 1): 0; 3155 inVal = std::min(std::max(0, inVal), (Int)(((lut.size()-1) << inValPrecisionBits))); 3156 Int index = (Int) std::min((inVal >> inValPrecisionBits), (Int)(lut.size()-2)); 3157 Int outVal = (( inVal - (index<<inValPrecisionBits) ) * (lut[index+1] - lut[index]) + roundValue) >> inValPrecisionBits; 3158 outVal += lut[index] ; 3159 3160 return outVal; 3161 } 3162 3163 static Int 3164 applyColourRemappingInfoMatrix(const Int (&colourRemapCoeffs)[3], const Int postOffsetShift, const Int p0, const Int p1, const Int p2, const Int offset) 3165 { 3166 Int YUVMat = (colourRemapCoeffs[0]* p0 + colourRemapCoeffs[1]* p1 + colourRemapCoeffs[2]* p2 + offset) >> postOffsetShift; 3167 return YUVMat; 3168 } 3169 3170 static Void 3171 setColourRemappingInfoMatrixOffset(Int (&matrixOffset)[3], Int offset0, Int offset1, Int offset2) 3172 { 3173 matrixOffset[0] = offset0; 3174 matrixOffset[1] = offset1; 3175 matrixOffset[2] = offset2; 3176 } 3177 3178 static Void 3179 setColourRemappingInfoMatrixOffsets( Int (&matrixInputOffset)[3], 3180 Int (&matrixOutputOffset)[3], 3181 const Int bitDepth, 3182 const Bool crInputFullRangeFlag, 3183 const Int crInputMatrixCoefficients, 3184 const Bool crFullRangeFlag, 3185 const Int crMatrixCoefficients) 3186 { 3187 // set static matrix offsets 3188 Int crInputOffsetLuma = (crInputFullRangeFlag)? 0:-(16 << (bitDepth-8)); 3189 Int crOffsetLuma = (crFullRangeFlag)? 0:(16 << (bitDepth-8)); 3190 Int crInputOffsetChroma = 0; 3191 Int crOffsetChroma = 0; 3192 3193 switch(crInputMatrixCoefficients) 3194 { 3195 case MATRIX_COEFFICIENTS_RGB: 3196 crInputOffsetChroma = 0; 3197 if(!crInputFullRangeFlag) 3198 { 3199 fprintf(stderr, "WARNING: crInputMatrixCoefficients set to MATRIX_COEFFICIENTS_RGB and crInputFullRangeFlag not set\n"); 3200 crInputOffsetLuma = 0; 3201 } 3202 break; 3203 case MATRIX_COEFFICIENTS_UNSPECIFIED: 3204 case MATRIX_COEFFICIENTS_BT709: 3205 case MATRIX_COEFFICIENTS_BT2020_NON_CONSTANT_LUMINANCE: 3206 crInputOffsetChroma = -(1 << (bitDepth-1)); 3207 break; 3208 default: 3209 fprintf(stderr, "WARNING: crInputMatrixCoefficients set to undefined value: %d\n", crInputMatrixCoefficients); 3210 } 3211 3212 switch(crMatrixCoefficients) 3213 { 3214 case MATRIX_COEFFICIENTS_RGB: 3215 crOffsetChroma = 0; 3216 if(!crFullRangeFlag) 3217 { 3218 fprintf(stderr, "WARNING: crMatrixCoefficients set to MATRIX_COEFFICIENTS_RGB and crInputFullRangeFlag not set\n"); 3219 crOffsetLuma = 0; 3220 } 3221 break; 3222 case MATRIX_COEFFICIENTS_UNSPECIFIED: 3223 case MATRIX_COEFFICIENTS_BT709: 3224 case MATRIX_COEFFICIENTS_BT2020_NON_CONSTANT_LUMINANCE: 3225 crOffsetChroma = (1 << (bitDepth-1)); 3226 break; 3227 default: 3228 fprintf(stderr, "WARNING: crMatrixCoefficients set to undefined value: %d\n", crMatrixCoefficients); 3229 } 3230 3231 setColourRemappingInfoMatrixOffset(matrixInputOffset, crInputOffsetLuma, crInputOffsetChroma, crInputOffsetChroma); 3232 setColourRemappingInfoMatrixOffset(matrixOutputOffset, crOffsetLuma, crOffsetChroma, crOffsetChroma); 3233 } 3234 3235 Void TAppDecTop::applyColourRemapping(const TComPicYuv& pic, SEIColourRemappingInfo& criSEI, const TComSPS &activeSPS) 3236 { 3237 const Int maxBitDepth = 16; 3238 3239 // create colour remapped picture 3240 if( !criSEI.m_colourRemapCancelFlag && pic.getChromaFormat()!=CHROMA_400) // 4:0:0 not supported. 3241 { 3242 const Int iHeight = pic.getHeight(COMPONENT_Y); 3243 const Int iWidth = pic.getWidth(COMPONENT_Y); 3244 const ChromaFormat chromaFormatIDC = pic.getChromaFormat(); 3245 3246 TComPicYuv picYuvColourRemapped; 3247 picYuvColourRemapped.createWithoutCUInfo( iWidth, iHeight, chromaFormatIDC ); 3248 3249 const Int iStrideIn = pic.getStride(COMPONENT_Y); 3250 const Int iCStrideIn = pic.getStride(COMPONENT_Cb); 3251 const Int iStrideOut = picYuvColourRemapped.getStride(COMPONENT_Y); 3252 const Int iCStrideOut = picYuvColourRemapped.getStride(COMPONENT_Cb); 3253 const Bool b444 = ( pic.getChromaFormat() == CHROMA_444 ); 3254 const Bool b422 = ( pic.getChromaFormat() == CHROMA_422 ); 3255 const Bool b420 = ( pic.getChromaFormat() == CHROMA_420 ); 3256 3257 std::vector<Int> preLut[3]; 3258 std::vector<Int> postLut[3]; 3259 Int matrixInputOffset[3]; 3260 Int matrixOutputOffset[3]; 3261 const Pel *YUVIn[MAX_NUM_COMPONENT]; 3262 Pel *YUVOut[MAX_NUM_COMPONENT]; 3263 YUVIn[COMPONENT_Y] = pic.getAddr(COMPONENT_Y); 3264 YUVIn[COMPONENT_Cb] = pic.getAddr(COMPONENT_Cb); 3265 YUVIn[COMPONENT_Cr] = pic.getAddr(COMPONENT_Cr); 3266 YUVOut[COMPONENT_Y] = picYuvColourRemapped.getAddr(COMPONENT_Y); 3267 YUVOut[COMPONENT_Cb] = picYuvColourRemapped.getAddr(COMPONENT_Cb); 3268 YUVOut[COMPONENT_Cr] = picYuvColourRemapped.getAddr(COMPONENT_Cr); 3269 3270 const Int bitDepth = criSEI.m_colourRemapBitDepth; 3271 BitDepths bitDepthsCriFile; 3272 bitDepthsCriFile.recon[CHANNEL_TYPE_LUMA] = bitDepth; 3273 bitDepthsCriFile.recon[CHANNEL_TYPE_CHROMA] = bitDepth; // Different bitdepth is not implemented 3274 3275 const Int postOffsetShift = criSEI.m_log2MatrixDenom; 3276 const Int matrixRound = 1 << (postOffsetShift - 1); 3277 const Int postLutInputPrecision = (maxBitDepth - criSEI.m_colourRemapBitDepth); 3278 3279 if ( ! criSEI.m_colourRemapVideoSignalInfoPresentFlag ) // setting default 3280 { 3281 setColourRemappingInfoMatrixOffsets(matrixInputOffset, matrixOutputOffset, maxBitDepth, 3282 activeSPS.getVuiParameters()->getVideoFullRangeFlag(), activeSPS.getVuiParameters()->getMatrixCoefficients(), 3283 activeSPS.getVuiParameters()->getVideoFullRangeFlag(), activeSPS.getVuiParameters()->getMatrixCoefficients()); 3284 } 3285 else 3286 { 3287 setColourRemappingInfoMatrixOffsets(matrixInputOffset, matrixOutputOffset, maxBitDepth, 3288 activeSPS.getVuiParameters()->getVideoFullRangeFlag(), activeSPS.getVuiParameters()->getMatrixCoefficients(), 3289 criSEI.m_colourRemapFullRangeFlag, criSEI.m_colourRemapMatrixCoefficients); 3290 } 3291 3292 // add matrix rounding to output matrix offsets 3293 matrixOutputOffset[0] = (matrixOutputOffset[0] << postOffsetShift) + matrixRound; 3294 matrixOutputOffset[1] = (matrixOutputOffset[1] << postOffsetShift) + matrixRound; 3295 matrixOutputOffset[2] = (matrixOutputOffset[2] << postOffsetShift) + matrixRound; 3296 3297 // Merge matrixInputOffset and matrixOutputOffset to matrixOutputOffset 3298 matrixOutputOffset[0] += applyColourRemappingInfoMatrix(criSEI.m_colourRemapCoeffs[0], 0, matrixInputOffset[0], matrixInputOffset[1], matrixInputOffset[2], 0); 3299 matrixOutputOffset[1] += applyColourRemappingInfoMatrix(criSEI.m_colourRemapCoeffs[1], 0, matrixInputOffset[0], matrixInputOffset[1], matrixInputOffset[2], 0); 3300 matrixOutputOffset[2] += applyColourRemappingInfoMatrix(criSEI.m_colourRemapCoeffs[2], 0, matrixInputOffset[0], matrixInputOffset[1], matrixInputOffset[2], 0); 3301 3302 // rescaling output: include CRI/output frame difference 3303 const Int scaleShiftOut_neg = abs(bitDepth - maxBitDepth); 3304 const Int scaleOut_round = 1 << (scaleShiftOut_neg-1); 3305 3306 initColourRemappingInfoLuts(preLut, postLut, criSEI, maxBitDepth); 3307 3308 assert(pic.getChromaFormat() != CHROMA_400); 3309 const Int hs = pic.getComponentScaleX(ComponentID(COMPONENT_Cb)); 3310 const Int maxOutputValue = (1 << bitDepth) - 1; 3311 3312 for( Int y = 0; y < iHeight; y++ ) 3313 { 3314 for( Int x = 0; x < iWidth; x++ ) 3315 { 3316 const Int xc = (x>>hs); 3317 Bool computeChroma = b444 || ((b422 || !(y&1)) && !(x&1)); 3318 3319 Int YUVPre_0 = applyColourRemappingInfoLut1D(YUVIn[COMPONENT_Y][x], preLut[0], 0); 3320 Int YUVPre_1 = applyColourRemappingInfoLut1D(YUVIn[COMPONENT_Cb][xc], preLut[1], 0); 3321 Int YUVPre_2 = applyColourRemappingInfoLut1D(YUVIn[COMPONENT_Cr][xc], preLut[2], 0); 3322 3323 Int YUVMat_0 = applyColourRemappingInfoMatrix(criSEI.m_colourRemapCoeffs[0], postOffsetShift, YUVPre_0, YUVPre_1, YUVPre_2, matrixOutputOffset[0]); 3324 Int YUVLutB_0 = applyColourRemappingInfoLut1D(YUVMat_0, postLut[0], postLutInputPrecision); 3325 YUVOut[COMPONENT_Y][x] = std::min(maxOutputValue, (YUVLutB_0 + scaleOut_round) >> scaleShiftOut_neg); 3326 3327 if( computeChroma ) 3328 { 3329 Int YUVMat_1 = applyColourRemappingInfoMatrix(criSEI.m_colourRemapCoeffs[1], postOffsetShift, YUVPre_0, YUVPre_1, YUVPre_2, matrixOutputOffset[1]); 3330 Int YUVLutB_1 = applyColourRemappingInfoLut1D(YUVMat_1, postLut[1], postLutInputPrecision); 3331 YUVOut[COMPONENT_Cb][xc] = std::min(maxOutputValue, (YUVLutB_1 + scaleOut_round) >> scaleShiftOut_neg); 3332 3333 Int YUVMat_2 = applyColourRemappingInfoMatrix(criSEI.m_colourRemapCoeffs[2], postOffsetShift, YUVPre_0, YUVPre_1, YUVPre_2, matrixOutputOffset[2]); 3334 Int YUVLutB_2 = applyColourRemappingInfoLut1D(YUVMat_2, postLut[2], postLutInputPrecision); 3335 YUVOut[COMPONENT_Cr][xc] = std::min(maxOutputValue, (YUVLutB_2 + scaleOut_round) >> scaleShiftOut_neg); 3336 } 3337 } 3338 3339 YUVIn[COMPONENT_Y] += iStrideIn; 3340 YUVOut[COMPONENT_Y] += iStrideOut; 3341 if( !(b420 && !(y&1)) ) 3342 { 3343 YUVIn[COMPONENT_Cb] += iCStrideIn; 3344 YUVIn[COMPONENT_Cr] += iCStrideIn; 3345 YUVOut[COMPONENT_Cb] += iCStrideOut; 3346 YUVOut[COMPONENT_Cr] += iCStrideOut; 3347 } 3348 } 3349 //Write remapped picture in display order 3350 picYuvColourRemapped.dump( m_colourRemapSEIFileName, bitDepthsCriFile, true ); 3351 picYuvColourRemapped.destroy(); 3352 } 3353 } 3009 3354 //! \}
Note: See TracChangeset for help on using the changeset viewer.