Changeset 296 in 3DVCSoftware for trunk/source/Lib/TLibEncoder
- Timestamp:
- 20 Feb 2013, 22:07:43 (12 years ago)
- Location:
- trunk/source/Lib/TLibEncoder
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibEncoder/NALwrite.cpp
r210 r296 56 56 57 57 bsNALUHeader.write(0,1); // forbidden_zero_flag 58 #if NAL_REF_FLAG59 58 bsNALUHeader.write(nalu.m_nalRefFlag? 1 : 0, 1); // nal_ref_flag 60 59 bsNALUHeader.write(nalu.m_nalUnitType, 6); // nal_unit_type 61 #else62 bsNALUHeader.write(nalu.m_nalRefIDC, 2); // nal_ref_idc63 bsNALUHeader.write(nalu.m_nalUnitType, 5); // nal_unit_type64 #endif65 60 66 61 #if QC_MVHEVC_B0046 … … 72 67 bsNALUHeader.write(nalu.m_layerId + 1, 5); // layer_id_plus1 73 68 #else 74 #if H038875 69 bsNALUHeader.write(nalu.m_temporalId, 3); // temporal_id 76 70 // bsNALUHeader.write(1, 5); // reserved_one_5bits 77 71 bsNALUHeader.write(nalu.m_viewId+1,4); 78 72 bsNALUHeader.write(nalu.m_isDepth,1); 79 #else80 switch (nalu.m_nalUnitType)81 {82 case NAL_UNIT_CODED_SLICE:83 case NAL_UNIT_CODED_SLICE_IDR:84 #if H0566_TLA85 #if !QC_REM_IDV_B004686 case NAL_UNIT_CODED_SLICE_IDV:87 #endif88 case NAL_UNIT_CODED_SLICE_CRA:89 case NAL_UNIT_CODED_SLICE_TLA:90 #else91 case NAL_UNIT_CODED_SLICE_CDR:92 #endif93 bsNALUHeader.write(nalu.m_temporalId, 3); // temporal_id94 bsNALUHeader.write(nalu.m_OutputFlag, 1); // output_flag95 // bsNALUHeader.write(1, 4); // reserved_one_4bits96 bsNALUHeader.write(nalu.m_viewId+1,3);97 bsNALUHeader.write(nalu.m_isDepth,1);98 break;99 default: break;100 }101 #endif102 73 #endif 103 74 #endif … … 209 180 { 210 181 naluDest.m_nalUnitType = naluSrc.m_nalUnitType; 211 #if NAL_REF_FLAG212 182 naluDest.m_nalRefFlag = naluSrc.m_nalRefFlag; 213 #else214 naluDest.m_nalRefIDC = naluSrc.m_nalRefIDC;215 #endif216 183 #if !VIDYO_VPS_INTEGRATION 217 184 naluDest.m_viewId = naluSrc.m_viewId; … … 223 190 #else 224 191 225 #if !H0388226 naluDest.m_OutputFlag = naluSrc.m_OutputFlag;227 #endif228 192 #endif 229 193 naluDest.m_Bitstream = naluSrc.m_Bitstream; -
trunk/source/Lib/TLibEncoder/NALwrite.h
r210 r296 54 54 * written to the bitstream. 55 55 */ 56 #if H038857 56 OutputNALUnit( 58 57 NalUnitType nalUnitType, 59 #if NAL_REF_FLAG60 58 Bool nalRefFlag, 61 #else62 NalRefIdc nalRefIDC,63 #endif64 59 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 65 60 unsigned layerId, … … 69 64 #endif 70 65 unsigned temporalID = 0) 71 #if NAL_REF_FLAG72 66 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 73 67 : NALUnit(nalUnitType, nalRefFlag, layerId, temporalID) … … 75 69 : NALUnit(nalUnitType, nalRefFlag, viewId, isDepth, temporalID) 76 70 #endif 77 #else78 #if VIDYO_VPS_INTEGRATION79 : NALUnit(nalUnitType, nalRefIDC, layerId, temporalID)80 #else81 : NALUnit(nalUnitType, nalRefIDC, viewId, isDepth, temporalID)82 #endif83 #endif84 71 , m_Bitstream() 85 72 {} 86 #else87 OutputNALUnit(88 NalUnitType nalUnitType,89 NalRefIdc nalRefIDC,90 Int viewId,91 Bool isDepth,92 unsigned temporalID = 0,93 bool outputFlag = true)94 : NALUnit(nalUnitType, nalRefIDC, viewId, isDepth, temporalID, outputFlag)95 , m_Bitstream()96 {}97 #endif98 73 99 74 OutputNALUnit(const NALUnit& src) -
trunk/source/Lib/TLibEncoder/TEncAdaptiveLoopFilter.cpp
r56 r296 47 47 // Constants 48 48 // ==================================================================================================================== 49 #if LCU_SYNTAX_ALF50 49 #define ALF_NUM_OF_REDESIGN 1 51 #else52 #define ALF_NUM_OF_REDESIGN 353 #endif54 50 // ==================================================================================================================== 55 51 // Tables 56 52 // ==================================================================================================================== 57 #if LCU_SYNTAX_ALF58 53 const Int TEncAdaptiveLoopFilter::m_alfNumPartsInRowTab[5] = 59 54 { … … 82 77 341, //level 4 83 78 }; 84 #endif85 79 // ==================================================================================================================== 86 80 // Constructor / destructor 87 81 // ==================================================================================================================== 88 82 89 #if LCU_SYNTAX_ALF90 83 ///AlfCorrData 91 84 AlfCorrData::AlfCorrData() … … 376 369 return *this; 377 370 } 378 #endif379 371 380 372 381 373 TEncAdaptiveLoopFilter::TEncAdaptiveLoopFilter() 382 374 { 383 #if !LCU_SYNTAX_ALF384 m_ppdAlfCorr = NULL;385 m_ppdAlfCorrCb = NULL;386 m_ppdAlfCorrCr = NULL;387 m_pdDoubleAlfCoeff = NULL;388 #endif389 375 m_pcEntropyCoder = NULL; 390 #if !LCU_SYNTAX_ALF391 m_pcBestAlfParam = NULL;392 m_pcTempAlfParam = NULL;393 #endif394 376 m_pcPicYuvBest = NULL; 395 377 m_pcPicYuvTmp = NULL; 396 #if !LCU_SYNTAX_ALF397 pcAlfParamShape0 = NULL;398 pcAlfParamShape1 = NULL;399 pcPicYuvRecShape0 = NULL;400 pcPicYuvRecShape1 = NULL;401 m_pcSliceYuvTmp = NULL;402 #endif403 378 404 379 m_iALFMaxNumberFilters = NO_FILTERS; … … 411 386 // ==================================================================================================================== 412 387 413 #if LCU_SYNTAX_ALF414 388 /** convert Level Row Col to Idx 415 389 * \param level, row, col … … 799 773 } 800 774 801 #else802 803 /** create ALF global buffers804 * \param iALFEncodePassReduction 0: 16-pass encoding, 1: 1-pass encoding, 2: 2-pass encoding805 * This function is used to create the filter buffers to perform time-delay filtering.806 */807 Void TEncAdaptiveLoopFilter::createAlfGlobalBuffers(Int iALFEncodePassReduction)808 {809 if(iALFEncodePassReduction)810 {811 Int iNumOfBuffer = m_iGOPSize +1;812 813 for(Int i=0; i< NUM_ALF_CLASS_METHOD; i++)814 {815 m_mergeTableSavedMethods[i] = new Int*[iNumOfBuffer];816 m_aiFilterCoeffSavedMethods[i] = new Int**[iNumOfBuffer];817 for(Int j=0; j< iNumOfBuffer; j++)818 {819 m_mergeTableSavedMethods[i][j] = new Int[NO_VAR_BINS];820 m_aiFilterCoeffSavedMethods[i][j] = new Int*[NO_VAR_BINS];821 for(Int k=0; k< NO_VAR_BINS; k++)822 {823 m_aiFilterCoeffSavedMethods[i][j][k] = new Int[ALF_MAX_NUM_COEF];824 }825 }826 m_iPreviousFilterShapeMethods[i] = new Int[iNumOfBuffer];827 }828 829 }830 }831 /** destroy ALF global buffers832 * This function is used to destroy the filter buffers.833 */834 835 Void TEncAdaptiveLoopFilter::destroyAlfGlobalBuffers()836 {837 if(m_iALFEncodePassReduction)838 {839 for(Int i=0; i< NUM_ALF_CLASS_METHOD; i++)840 {841 for(Int j=0; j< m_iGOPSize+1; j++)842 {843 for(Int k=0; k< NO_VAR_BINS; k++)844 {845 delete[] m_aiFilterCoeffSavedMethods[i][j][k];846 }847 delete[] m_aiFilterCoeffSavedMethods[i][j];848 delete[] m_mergeTableSavedMethods[i][j];849 }850 delete[] m_aiFilterCoeffSavedMethods[i];851 delete[] m_iPreviousFilterShapeMethods[i];852 delete[] m_mergeTableSavedMethods[i];853 854 }855 856 }857 858 }859 #endif860 775 /** 861 776 \param pcPic picture (TComPic) pointer … … 865 780 { 866 781 m_pcEntropyCoder = pcEntropyCoder; 867 #if !LCU_SYNTAX_ALF868 xInitParam();869 #endif870 782 xCreateTmpAlfCtrlFlags(); 871 783 … … 876 788 m_pcPicYuvTmp->createLuma(iWidth, iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth); 877 789 m_pcPicYuvBest = pcPic->getPicYuvPred(); 878 #if !LCU_SYNTAX_ALF879 m_pcBestAlfParam = new ALFParam;880 m_pcTempAlfParam = new ALFParam;881 allocALFParam(m_pcBestAlfParam);882 allocALFParam(m_pcTempAlfParam);883 pcPicYuvRecShape0 = new TComPicYuv();884 pcPicYuvRecShape0->createLuma(iWidth, iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);885 886 pcPicYuvRecShape1 = new TComPicYuv();887 pcPicYuvRecShape1->createLuma(iWidth, iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);888 889 pcAlfParamShape0 = new ALFParam;890 pcAlfParamShape1 = new ALFParam;891 892 allocALFParam(pcAlfParamShape0);893 allocALFParam(pcAlfParamShape1);894 895 // init qc_filter896 initMatrix4D_double(&m_EGlobalSym, NUM_ALF_FILTER_SHAPE+1, NO_VAR_BINS, MAX_SQR_FILT_LENGTH, MAX_SQR_FILT_LENGTH);897 initMatrix3D_double(&m_yGlobalSym, NUM_ALF_FILTER_SHAPE+1, NO_VAR_BINS, MAX_SQR_FILT_LENGTH);898 #endif899 790 initMatrix_int(&m_filterCoeffSymQuant, NO_VAR_BINS, ALF_MAX_NUM_COEF); 900 #if !LCU_SYNTAX_ALF901 m_pixAcc = (double *) calloc(NO_VAR_BINS, sizeof(double));902 #endif903 791 initMatrix_Pel(&m_maskImg, m_img_height, m_img_width); 904 792 initMatrix_double(&m_E_temp, MAX_SQR_FILT_LENGTH, MAX_SQR_FILT_LENGTH);// … … 913 801 initMatrix_int(&m_FilterCoeffQuantTemp, NO_VAR_BINS, ALF_MAX_NUM_COEF);// 914 802 915 #if LCU_SYNTAX_ALF916 803 m_tempALFp = new ALFParam(ALF_Y); 917 #else918 m_tempALFp = new ALFParam;919 allocALFParam(m_tempALFp);920 if( m_bUseNonCrossALF )921 {922 m_pcSliceYuvTmp = new TComPicYuv();923 m_pcSliceYuvTmp->create(iWidth, iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);924 }925 #endif926 804 } 927 805 928 806 Void TEncAdaptiveLoopFilter::endALFEnc() 929 807 { 930 #if !LCU_SYNTAX_ALF931 xUninitParam();932 #endif933 808 xDestroyTmpAlfCtrlFlags(); 934 809 … … 938 813 m_pcPic = NULL; 939 814 m_pcEntropyCoder = NULL; 940 #if !LCU_SYNTAX_ALF941 freeALFParam(m_pcBestAlfParam);942 freeALFParam(m_pcTempAlfParam);943 delete m_pcBestAlfParam;944 delete m_pcTempAlfParam;945 946 pcPicYuvRecShape0->destroyLuma();947 delete pcPicYuvRecShape0;948 pcPicYuvRecShape0 = NULL;949 950 pcPicYuvRecShape1->destroyLuma();951 delete pcPicYuvRecShape1;952 pcPicYuvRecShape1 = NULL;953 954 freeALFParam(pcAlfParamShape0);955 freeALFParam(pcAlfParamShape1);956 957 delete pcAlfParamShape0;958 delete pcAlfParamShape1;959 960 // delete qc filters961 destroyMatrix4D_double(m_EGlobalSym, NUM_ALF_FILTER_SHAPE+1, NO_VAR_BINS);962 destroyMatrix3D_double(m_yGlobalSym, NUM_ALF_FILTER_SHAPE+1);963 #endif964 815 destroyMatrix_int(m_filterCoeffSymQuant); 965 #if !LCU_SYNTAX_ALF966 free(m_pixAcc);967 #endif968 816 destroyMatrix_Pel(m_maskImg); 969 817 destroyMatrix3D_double(m_E_merged, NO_VAR_BINS); … … 980 828 destroyMatrix_int(m_FilterCoeffQuantTemp); 981 829 982 #if LCU_SYNTAX_ALF983 830 delete m_tempALFp; 984 #else 985 freeALFParam(m_tempALFp); 986 delete m_tempALFp; 987 988 if(m_bUseNonCrossALF) 989 { 990 m_pcSliceYuvTmp->destroy(); 991 delete m_pcSliceYuvTmp; 992 m_pcSliceYuvTmp = NULL; 993 } 994 #endif 995 } 996 997 #if LCU_SYNTAX_ALF 831 } 832 998 833 999 834 /** Assign output ALF parameters … … 2762 2597 #endif 2763 2598 2764 #if ALF_SINGLE_FILTER_SHAPE2765 2599 calcCorrOneCompRegionChma(pPicOrg, pPicSrc, stride, ypos, xpos, height, width, alfCorr->ECorr[0], alfCorr->yCorr[0], isLastBlock); 2766 #endif2767 2600 } 2768 2601 } … … 2822 2655 #endif 2823 2656 2824 #if ALF_SINGLE_FILTER_SHAPE2825 2657 calcCorrOneCompRegionLuma(pPicOrg, pPicSrc, stride, ypos, xpos, height, width, alfCorr->ECorr, alfCorr->yCorr, alfCorr->pixAcc, forceCollection, isLastBlock); 2826 #endif2827 2658 } 2828 2659 } … … 2838 2669 2839 2670 2840 #if ALF_SINGLE_FILTER_SHAPE2841 2671 /** Gather correlations for one region for chroma component 2842 2672 * \param [in] imgOrg picture buffer for original picture … … 3086 2916 3087 2917 } 3088 #endif 3089 3090 #else 3091 3092 3093 #if ALF_CHROMA_LAMBDA 3094 /** 3095 \param pcAlfParam ALF parameter 3096 \param [out] pvAlfCtrlParam ALF CU control parameters container for slices 3097 \param dLambdaLuma luma lambda value for RD cost computation 3098 \param dLambdaChroma chroma lambda value for RD cost computation 3099 \retval ruiDist distortion 3100 \retval ruiBits required bits 3101 \retval ruiMaxAlfCtrlDepth optimal partition depth 3102 */ 3103 #if HHI_INTERVIEW_SKIP 3104 Void TEncAdaptiveLoopFilter::ALFProcess( ALFParam* pcAlfParam, std::vector<AlfCUCtrlInfo>* pvAlfCtrlParam, Double dLambdaLuma, Double dLambdaChroma, UInt64& ruiDist, UInt64& ruiBits, Bool bInterviewSkip) 3105 #else 3106 Void TEncAdaptiveLoopFilter::ALFProcess( ALFParam* pcAlfParam, std::vector<AlfCUCtrlInfo>* pvAlfCtrlParam, Double dLambdaLuma, Double dLambdaChroma, UInt64& ruiDist, UInt64& ruiBits) 3107 3108 #endif 3109 #else 3110 /** 3111 \param pcAlfParam ALF parameter 3112 \param dLambda lambda value for RD cost computation 3113 \retval ruiDist distortion 3114 \retval ruiBits required bits 3115 \retval ruiMaxAlfCtrlDepth optimal partition depth 3116 */ 3117 #if HHI_INTERVIEW_SKIP 3118 Void TEncAdaptiveLoopFilter::ALFProcess( ALFParam* pcAlfParam, std::vector<AlfCUCtrlInfo>* pvAlfCtrlParam, Double dLambda, UInt64& ruiDist, UInt64& ruiBits, Bool bInterviewSkip) 3119 #else 3120 Void TEncAdaptiveLoopFilter::ALFProcess( ALFParam* pcAlfParam, std::vector<AlfCUCtrlInfo>* pvAlfCtrlParam, Double dLambda, UInt64& ruiDist, UInt64& ruiBits) 3121 3122 #endif 3123 #endif 3124 { 3125 3126 // set lambda 3127 #if ALF_CHROMA_LAMBDA 3128 m_dLambdaLuma = dLambdaLuma; 3129 m_dLambdaChroma = dLambdaChroma; 3130 #else 3131 m_dLambdaLuma = dLambda; 3132 m_dLambdaChroma = dLambda; 3133 #endif 3134 3135 m_lcuHeight = m_pcPic->getSlice(0)->getSPS()->getMaxCUHeight(); 3136 3137 #if ALF_SINGLE_FILTER_SHAPE 3138 m_lineIdxPadBot = m_lcuHeight - 4 - 3; // DFRegion, Vertical Taps 3139 #else 3140 m_lineIdxPadBot = m_lcuHeight - 4 - 4; // DFRegion, Vertical Taps 3141 #endif 3142 m_lineIdxPadTop = m_lcuHeight - 4; // DFRegion 3143 3144 m_lcuHeightChroma = m_lcuHeight>>1; 3145 #if ALF_SINGLE_FILTER_SHAPE 3146 m_lineIdxPadBotChroma = m_lcuHeightChroma - 2 - 3; // DFRegion, Vertical Taps 3147 #else 3148 m_lineIdxPadBotChroma = m_lcuHeightChroma - 2 - 4; // DFRegion, Vertical Taps 3149 #endif 3150 m_lineIdxPadTopChroma = m_lcuHeightChroma - 2 ; // DFRegion 3151 3152 TComPicYuv* pcPicOrg = m_pcPic->getPicYuvOrg(); 3153 3154 // extend image for filtering 3155 TComPicYuv* pcPicYuvRec = m_pcPic->getPicYuvRec(); 3156 TComPicYuv* pcPicYuvExtRec = m_pcTempPicYuv; 3157 #if HHI_INTERVIEW_SKIP 3158 TComPicYuv* pcUsedPelMap = m_pcPic->getUsedPelsMap() ; 3159 if(bInterviewSkip) 3160 assert( pcUsedPelMap ) ; 3161 #endif 3162 3163 pcPicYuvRec->copyToPic(pcPicYuvExtRec); 3164 if(!m_bUseNonCrossALF) 3165 { 3166 pcPicYuvExtRec->setBorderExtension( false ); 3167 pcPicYuvExtRec->extendPicBorder (); 3168 } 3169 3170 // set min cost 3171 UInt64 uiMinRate = MAX_INT; 3172 UInt64 uiMinDist = MAX_INT; 3173 Double dMinCost = MAX_DOUBLE; 3174 3175 UInt64 uiOrigRate; 3176 UInt64 uiOrigDist; 3177 Double dOrigCost; 3178 3179 // calc original cost 3180 #if HHI_INTERVIEW_SKIP 3181 xCalcRDCost( pcPicOrg, pcPicYuvRec, pcUsedPelMap, NULL, uiOrigRate, uiOrigDist, dOrigCost ); 3182 #else 3183 xCalcRDCost( pcPicOrg, pcPicYuvRec, NULL, uiOrigRate, uiOrigDist, dOrigCost ); 3184 #endif 3185 m_pcBestAlfParam->alf_flag = 0; 3186 // initialize temp_alfps 3187 m_pcTempAlfParam->alf_flag = 1; 3188 m_pcTempAlfParam->chroma_idc = 0; 3189 3190 m_bAlfCUCtrlEnabled = (pvAlfCtrlParam != NULL)?true:false; 3191 if(m_bAlfCUCtrlEnabled) 3192 { 3193 m_vBestAlfCUCtrlParam.resize(m_uiNumSlicesInPic); 3194 for(Int s=0; s< m_uiNumSlicesInPic; s++) 3195 { 3196 m_vBestAlfCUCtrlParam[s].cu_control_flag = 0; 3197 } 3198 } 3199 else 3200 { 3201 m_vBestAlfCUCtrlParam.clear(); 3202 } 3203 3204 setALFEncodingParam(m_pcPic); 3205 3206 // adaptive in-loop wiener filtering 3207 #if HHI_INTERVIEW_SKIP 3208 xEncALFLuma( pcPicOrg, pcPicYuvExtRec, pcPicYuvRec, uiMinRate, uiMinDist, dMinCost, bInterviewSkip ); 3209 #else 3210 xEncALFLuma( pcPicOrg, pcPicYuvExtRec, pcPicYuvRec, uiMinRate, uiMinDist, dMinCost ); 3211 #endif 3212 3213 // cu-based filter on/off control 3214 #if HHI_INTERVIEW_SKIP 3215 xCUAdaptiveControl_qc( pcPicOrg, pcPicYuvExtRec, pcPicYuvRec, pcUsedPelMap, uiMinRate, uiMinDist, dMinCost ); 3216 #else 3217 xCUAdaptiveControl_qc( pcPicOrg, pcPicYuvExtRec, pcPicYuvRec, uiMinRate, uiMinDist, dMinCost ); 3218 #endif 3219 3220 // compare RD cost to non-ALF case 3221 if( dMinCost < dOrigCost ) 3222 { 3223 m_pcBestAlfParam->alf_flag = 1; 3224 3225 ruiBits = uiMinRate; 3226 ruiDist = uiMinDist; 3227 } 3228 else 3229 { 3230 m_pcBestAlfParam->alf_flag = 0; 3231 3232 uiMinRate = uiOrigRate; 3233 uiMinDist = uiOrigDist; 3234 3235 m_pcEntropyCoder->setAlfCtrl(false); 3236 if(m_bAlfCUCtrlEnabled) 3237 { 3238 for(Int s=0; s< m_uiNumSlicesInPic; s++) 3239 { 3240 m_vBestAlfCUCtrlParam[s].cu_control_flag = 0; 3241 } 3242 } 3243 pcPicYuvExtRec->copyToPicLuma(pcPicYuvRec); 3244 3245 ruiBits = uiOrigRate; 3246 ruiDist = uiOrigDist; 3247 } 3248 // if ALF works 3249 if( m_pcBestAlfParam->alf_flag ) 3250 { 3251 // do additional ALF process for chroma 3252 xFilterTapDecisionChroma( uiMinRate, pcPicOrg, pcPicYuvExtRec, pcPicYuvRec, ruiDist, ruiBits ); 3253 } 3254 3255 // copy to best storage 3256 copyALFParam(pcAlfParam, m_pcBestAlfParam); 3257 3258 if(m_bAlfCUCtrlEnabled) 3259 { 3260 for(Int s=0; s< m_uiNumSlicesInPic; s++) 3261 { 3262 (*pvAlfCtrlParam)[s]= m_vBestAlfCUCtrlParam[s]; 3263 } 3264 } 3265 } 3266 #endif 2918 3267 2919 3268 2920 /** PCM LF disable process. … … 3284 2936 // Private member functions 3285 2937 // ==================================================================================================================== 3286 #if !LCU_SYNTAX_ALF3287 Void TEncAdaptiveLoopFilter::xInitParam()3288 {3289 Int i, j;3290 3291 if (m_ppdAlfCorr != NULL)3292 {3293 for (i = 0; i < ALF_MAX_NUM_COEF; i++)3294 {3295 for (j = 0; j < ALF_MAX_NUM_COEF+1; j++)3296 {3297 m_ppdAlfCorr[i][j] = 0;3298 }3299 }3300 }3301 else3302 {3303 m_ppdAlfCorr = new Double*[ALF_MAX_NUM_COEF];3304 for (i = 0; i < ALF_MAX_NUM_COEF; i++)3305 {3306 m_ppdAlfCorr[i] = new Double[ALF_MAX_NUM_COEF+1];3307 for (j = 0; j < ALF_MAX_NUM_COEF+1; j++)3308 {3309 m_ppdAlfCorr[i][j] = 0;3310 }3311 }3312 }3313 3314 if (m_pdDoubleAlfCoeff != NULL)3315 {3316 for (i = 0; i < ALF_MAX_NUM_COEF; i++)3317 {3318 m_pdDoubleAlfCoeff[i] = 0;3319 }3320 }3321 else3322 {3323 m_pdDoubleAlfCoeff = new Double[ALF_MAX_NUM_COEF];3324 for (i = 0; i < ALF_MAX_NUM_COEF; i++)3325 {3326 m_pdDoubleAlfCoeff[i] = 0;3327 }3328 }3329 if (m_ppdAlfCorrCb != NULL)3330 {3331 for (i = 0; i < ALF_MAX_NUM_COEF; i++)3332 {3333 for (j = 0; j < ALF_MAX_NUM_COEF+1; j++)3334 {3335 m_ppdAlfCorrCb[i][j] = 0;3336 }3337 }3338 }3339 else3340 {3341 m_ppdAlfCorrCb = new Double*[ALF_MAX_NUM_COEF];3342 for (i = 0; i < ALF_MAX_NUM_COEF; i++)3343 {3344 m_ppdAlfCorrCb[i] = new Double[ALF_MAX_NUM_COEF+1];3345 for (j = 0; j < ALF_MAX_NUM_COEF+1; j++)3346 {3347 m_ppdAlfCorrCb[i][j] = 0;3348 }3349 }3350 }3351 3352 if (m_ppdAlfCorrCr != NULL)3353 {3354 for (i = 0; i < ALF_MAX_NUM_COEF; i++)3355 {3356 for (j = 0; j < ALF_MAX_NUM_COEF+1; j++)3357 {3358 m_ppdAlfCorrCr[i][j] = 0;3359 }3360 }3361 }3362 else3363 {3364 m_ppdAlfCorrCr = new Double*[ALF_MAX_NUM_COEF];3365 for (i = 0; i < ALF_MAX_NUM_COEF; i++)3366 {3367 m_ppdAlfCorrCr[i] = new Double[ALF_MAX_NUM_COEF+1];3368 for (j = 0; j < ALF_MAX_NUM_COEF+1; j++)3369 {3370 m_ppdAlfCorrCr[i][j] = 0;3371 }3372 }3373 }3374 }3375 3376 Void TEncAdaptiveLoopFilter::xUninitParam()3377 {3378 Int i;3379 3380 if (m_ppdAlfCorr != NULL)3381 {3382 for (i = 0; i < ALF_MAX_NUM_COEF; i++)3383 {3384 delete[] m_ppdAlfCorr[i];3385 m_ppdAlfCorr[i] = NULL;3386 }3387 delete[] m_ppdAlfCorr;3388 m_ppdAlfCorr = NULL;3389 }3390 3391 if (m_pdDoubleAlfCoeff != NULL)3392 {3393 delete[] m_pdDoubleAlfCoeff;3394 m_pdDoubleAlfCoeff = NULL;3395 }3396 if (m_ppdAlfCorrCb != NULL)3397 {3398 for (i = 0; i < ALF_MAX_NUM_COEF; i++)3399 {3400 delete[] m_ppdAlfCorrCb[i];3401 m_ppdAlfCorrCb[i] = NULL;3402 }3403 delete[] m_ppdAlfCorrCb;3404 m_ppdAlfCorrCb = NULL;3405 }3406 3407 if (m_ppdAlfCorrCr != NULL)3408 {3409 for (i = 0; i < ALF_MAX_NUM_COEF; i++)3410 {3411 delete[] m_ppdAlfCorrCr[i];3412 m_ppdAlfCorrCr[i] = NULL;3413 }3414 delete[] m_ppdAlfCorrCr;3415 m_ppdAlfCorrCr = NULL;3416 }3417 }3418 #endif3419 2938 Void TEncAdaptiveLoopFilter::xCreateTmpAlfCtrlFlags() 3420 2939 { … … 3512 3031 } 3513 3032 3514 #if !LCU_SYNTAX_ALF3515 3516 Void TEncAdaptiveLoopFilter::xCalcCorrelationFunc(Int ypos, Int xpos, Pel* pImgOrg, Pel* pImgPad, Int filtNo, Int iWidth, Int iHeight, Int iOrgStride, Int iCmpStride, Bool bSymmCopyBlockMatrix)3517 {3518 Int yposEnd = ypos + iHeight -1;3519 Int xposEnd = xpos + iWidth -1;3520 Int N = m_sqrFiltLengthTab[filtNo];3521 3522 Int imgHeightChroma = m_img_height>>1;3523 Int yLineInLCU;3524 Int paddingline ;3525 3526 Int ELocal[ALF_MAX_NUM_COEF];3527 Pel *pImgPad1, *pImgPad2, *pImgPad3, *pImgPad4;3528 Int i, j, k, l;3529 Int yLocal;3530 3531 pImgPad += (ypos*iCmpStride);3532 pImgOrg += (ypos*iOrgStride);3533 3534 switch(filtNo)3535 {3536 #if !ALF_SINGLE_FILTER_SHAPE3537 case ALF_STAR5x5:3538 {3539 for (i= ypos; i<= yposEnd; i++)3540 {3541 yLineInLCU = i % m_lcuHeightChroma;3542 3543 if (yLineInLCU < m_lineIdxPadBotChroma || i-yLineInLCU+m_lcuHeightChroma >= imgHeightChroma )3544 {3545 pImgPad1 = pImgPad + iCmpStride;3546 pImgPad2 = pImgPad - iCmpStride;3547 pImgPad3 = pImgPad + 2*iCmpStride;3548 pImgPad4 = pImgPad - 2*iCmpStride;3549 }3550 else if (yLineInLCU < m_lineIdxPadTopChroma)3551 {3552 paddingline = - yLineInLCU + m_lineIdxPadTopChroma - 1;3553 pImgPad1 = pImgPad + min(paddingline, 1)*iCmpStride;3554 pImgPad2 = pImgPad - iCmpStride;3555 pImgPad3 = pImgPad + min(paddingline, 2)*iCmpStride;3556 pImgPad4 = pImgPad - 2*iCmpStride;3557 }3558 else3559 {3560 paddingline = yLineInLCU - m_lineIdxPadTopChroma ;3561 pImgPad1 = pImgPad + iCmpStride;3562 pImgPad2 = pImgPad - min(paddingline, 1)*iCmpStride;3563 pImgPad3 = pImgPad + 2*iCmpStride;3564 pImgPad4 = pImgPad - min(paddingline, 2)*iCmpStride;3565 }3566 3567 if ( (yLineInLCU == m_lineIdxPadTopChroma || yLineInLCU == m_lineIdxPadTopChroma-1) && i-yLineInLCU+m_lcuHeightChroma < imgHeightChroma )3568 {3569 pImgPad+= iCmpStride;3570 pImgOrg+= iOrgStride;3571 continue;3572 }3573 else3574 {3575 for (j= xpos; j<= xposEnd; j++)3576 {3577 memset(ELocal, 0, N*sizeof(Int));3578 3579 ELocal[0] = (pImgPad3[j+2] + pImgPad4[j-2]);3580 ELocal[1] = (pImgPad3[j ] + pImgPad4[j ]);3581 ELocal[2] = (pImgPad3[j-2] + pImgPad4[j+2]);3582 3583 ELocal[3] = (pImgPad1[j+1] + pImgPad2[j-1]);3584 ELocal[4] = (pImgPad1[j ] + pImgPad2[j ]);3585 ELocal[5] = (pImgPad1[j-1] + pImgPad2[j+1]);3586 3587 ELocal[6] = (pImgPad[j+2] + pImgPad[j-2]);3588 ELocal[7] = (pImgPad[j+1] + pImgPad[j-1]);3589 ELocal[8] = (pImgPad[j ]);3590 3591 yLocal= (Int)pImgOrg[j];3592 3593 for(k=0; k<N; k++)3594 {3595 m_ppdAlfCorr[k][k] += ELocal[k]*ELocal[k];3596 for(l=k+1; l<N; l++)3597 {3598 m_ppdAlfCorr[k][l] += ELocal[k]*ELocal[l];3599 }3600 3601 m_ppdAlfCorr[k][N] += yLocal*ELocal[k];3602 }3603 }3604 pImgPad+= iCmpStride;3605 pImgOrg+= iOrgStride;3606 }3607 3608 }3609 }3610 break;3611 case ALF_CROSS9x9:3612 {3613 Pel *pImgPad5, *pImgPad6, *pImgPad7, *pImgPad8;3614 #else3615 case ALF_CROSS9x7_SQUARE3x3:3616 {3617 Pel *pImgPad5, *pImgPad6;3618 #endif3619 for (i= ypos; i<= yposEnd; i++)3620 {3621 yLineInLCU = i % m_lcuHeightChroma;3622 3623 if (yLineInLCU<2 && i> 2)3624 {3625 paddingline = yLineInLCU + 2 ;3626 pImgPad1 = pImgPad + iCmpStride;3627 pImgPad2 = pImgPad - iCmpStride;3628 pImgPad3 = pImgPad + 2*iCmpStride;3629 pImgPad4 = pImgPad - 2*iCmpStride;3630 pImgPad5 = (paddingline < 3) ? pImgPad : pImgPad + 3*iCmpStride;3631 pImgPad6 = (paddingline < 3) ? pImgPad : pImgPad - min(paddingline, 3)*iCmpStride;;3632 #if !ALF_SINGLE_FILTER_SHAPE3633 pImgPad7 = (paddingline < 4) ? pImgPad : pImgPad + 4*iCmpStride;3634 pImgPad8 = (paddingline < 4) ? pImgPad : pImgPad - min(paddingline, 4)*iCmpStride;;3635 #endif3636 }3637 else if (yLineInLCU < m_lineIdxPadBotChroma || i-yLineInLCU+m_lcuHeightChroma >= imgHeightChroma )3638 {3639 pImgPad1 = pImgPad + iCmpStride;3640 pImgPad2 = pImgPad - iCmpStride;3641 pImgPad3 = pImgPad + 2*iCmpStride;3642 pImgPad4 = pImgPad - 2*iCmpStride;3643 pImgPad5 = pImgPad + 3*iCmpStride;3644 pImgPad6 = pImgPad - 3*iCmpStride;3645 #if !ALF_SINGLE_FILTER_SHAPE3646 pImgPad7 = pImgPad + 4*iCmpStride;3647 pImgPad8 = pImgPad - 4*iCmpStride;3648 #endif3649 }3650 else if (yLineInLCU < m_lineIdxPadTopChroma)3651 {3652 paddingline = - yLineInLCU + m_lineIdxPadTopChroma - 1;3653 pImgPad1 = (paddingline < 1) ? pImgPad : pImgPad + min(paddingline, 1)*iCmpStride;3654 pImgPad2 = (paddingline < 1) ? pImgPad : pImgPad - iCmpStride;3655 pImgPad3 = (paddingline < 2) ? pImgPad : pImgPad + min(paddingline, 2)*iCmpStride;3656 pImgPad4 = (paddingline < 2) ? pImgPad : pImgPad - 2*iCmpStride;3657 pImgPad5 = (paddingline < 3) ? pImgPad : pImgPad + min(paddingline, 3)*iCmpStride;3658 pImgPad6 = (paddingline < 3) ? pImgPad : pImgPad - 3*iCmpStride;3659 #if !ALF_SINGLE_FILTER_SHAPE3660 pImgPad7 = (paddingline < 4) ? pImgPad : pImgPad + min(paddingline, 4)*iCmpStride;3661 pImgPad8 = (paddingline < 4) ? pImgPad : pImgPad - 4*iCmpStride;3662 #endif3663 }3664 else3665 {3666 paddingline = yLineInLCU - m_lineIdxPadTopChroma ;3667 pImgPad1 = (paddingline < 1) ? pImgPad : pImgPad + iCmpStride;3668 pImgPad2 = (paddingline < 1) ? pImgPad : pImgPad - min(paddingline, 1)*iCmpStride;3669 pImgPad3 = (paddingline < 2) ? pImgPad : pImgPad + 2*iCmpStride;3670 pImgPad4 = (paddingline < 2) ? pImgPad : pImgPad - min(paddingline, 2)*iCmpStride;3671 pImgPad5 = (paddingline < 3) ? pImgPad : pImgPad + 3*iCmpStride;3672 pImgPad6 = (paddingline < 3) ? pImgPad : pImgPad - min(paddingline, 3)*iCmpStride;3673 #if !ALF_SINGLE_FILTER_SHAPE3674 pImgPad7 = (paddingline < 4) ? pImgPad : pImgPad + 4*iCmpStride;3675 pImgPad8 = (paddingline < 4) ? pImgPad : pImgPad - min(paddingline, 4)*iCmpStride;3676 #endif3677 }3678 3679 for (j= xpos; j<= xposEnd; j++)3680 {3681 memset(ELocal, 0, N*sizeof(Int));3682 #if ALF_SINGLE_FILTER_SHAPE3683 ELocal[0] = (pImgPad5[j]+pImgPad6[j]);3684 ELocal[1] = (pImgPad3[j]+pImgPad4[j]);3685 ELocal[2] = (pImgPad1[j-1]+pImgPad2[j+1]);3686 ELocal[3] = (pImgPad1[j]+pImgPad2[j]);3687 ELocal[4] = (pImgPad1[j+1]+pImgPad2[j-1]);3688 ELocal[5] = (pImgPad[j+4]+pImgPad[j-4]);3689 ELocal[6] = (pImgPad[j+3]+pImgPad[j-3]);3690 ELocal[7] = (pImgPad[j+2]+pImgPad[j-2]);3691 ELocal[8] = (pImgPad[j+1]+pImgPad[j-1]);3692 ELocal[9] = (pImgPad[j ]);3693 #else3694 ELocal[0] = (pImgPad7[j] + pImgPad8[j]);3695 3696 ELocal[1] = (pImgPad5[j] + pImgPad6[j]);3697 3698 ELocal[2] = (pImgPad3[j] + pImgPad4[j]);3699 3700 ELocal[3] = (pImgPad1[j] + pImgPad2[j]);3701 3702 ELocal[4] = (pImgPad[j+4] + pImgPad[j-4]);3703 ELocal[5] = (pImgPad[j+3] + pImgPad[j-3]);3704 ELocal[6] = (pImgPad[j+2] + pImgPad[j-2]);3705 ELocal[7] = (pImgPad[j+1] + pImgPad[j-1]);3706 ELocal[8] = (pImgPad[j ] );3707 #endif3708 yLocal= (Int)pImgOrg[j];3709 3710 for(k=0; k<N; k++)3711 {3712 m_ppdAlfCorr[k][k] += ELocal[k]*ELocal[k];3713 for(l=k+1; l<N; l++)3714 {3715 m_ppdAlfCorr[k][l] += ELocal[k]*ELocal[l];3716 }3717 3718 m_ppdAlfCorr[k][N] += yLocal*ELocal[k];3719 }3720 }3721 pImgPad+= iCmpStride;3722 pImgOrg+= iOrgStride;3723 }3724 3725 }3726 break;3727 default:3728 {3729 printf("Not a supported filter shape\n");3730 assert(0);3731 exit(1);3732 }3733 }3734 3735 if(bSymmCopyBlockMatrix)3736 {3737 for(j=0; j<N-1; j++)3738 {3739 for(i=j+1; i<N; i++)3740 {3741 m_ppdAlfCorr[i][j] = m_ppdAlfCorr[j][i];3742 }3743 }3744 }3745 }3746 3747 #endif3748 3033 #if IBDI_DISTORTION 3749 3034 #if HHI_INTERVIEW_SKIP … … 3946 3231 Int *nc; 3947 3232 const Int *pFiltMag; 3948 #if LCU _SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS3233 #if LCUALF_QP_DEPENDENT_BITS 3949 3234 Int alfPrecisionBit = getAlfPrecisionBit( m_alfQP ); 3950 3235 #endif 3951 3236 3952 3237 N = m_sqrFiltLengthTab[tap]; 3953 #if ALF_SINGLE_FILTER_SHAPE3954 3238 pFiltMag = weightsShape1Sym; 3955 #else3956 // star shape3957 if(tap == 0)3958 {3959 pFiltMag = weightsShape0Sym;3960 }3961 // cross shape3962 else3963 {3964 pFiltMag = weightsShape1Sym;3965 }3966 #endif3967 3239 3968 3240 dh = new Double[N]; 3969 3241 nc = new Int[N]; 3970 3242 3971 #if LCU _SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS3243 #if LCUALF_QP_DEPENDENT_BITS 3972 3244 max_value = (1<<(1+alfPrecisionBit))-1; 3973 3245 min_value = 0-(1<<(1+alfPrecisionBit)); … … 3983 3255 if(h[i]>=0.0) 3984 3256 { 3985 #if LCU _SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS3257 #if LCUALF_QP_DEPENDENT_BITS 3986 3258 qh[i] = (Int)( h[i]*(1<<alfPrecisionBit)+0.5); 3987 3259 #else … … 3991 3263 else 3992 3264 { 3993 #if LCU _SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS3265 #if LCUALF_QP_DEPENDENT_BITS 3994 3266 qh[i] = -(Int)(-h[i]*(1<<alfPrecisionBit)+0.5); 3995 3267 #else … … 3998 3270 } 3999 3271 4000 #if LCU _SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS3272 #if LCUALF_QP_DEPENDENT_BITS 4001 3273 dh[i] = (Double)qh[i]/(Double)(1<<alfPrecisionBit) - h[i]; 4002 3274 #else … … 4010 3282 4011 3283 // modification of quantized filter coefficients 4012 #if LCU _SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS3284 #if LCUALF_QP_DEPENDENT_BITS 4013 3285 total_gain = (Int)(dbl_total_gain*(1<<alfPrecisionBit)+0.5); 4014 3286 #else … … 4082 3354 nc = NULL; 4083 3355 } 4084 #if !LCU_SYNTAX_ALF4085 Void TEncAdaptiveLoopFilter::xClearFilterCoefInt(Int* qh, Int N)4086 {4087 // clear4088 memset( qh, 0, sizeof( Int ) * N );4089 4090 // center pos4091 qh[N-1] = 1<<ALF_NUM_BIT_SHIFT;4092 }4093 /** Calculate RD cost4094 * \param [in] pAlfParam ALF parameters4095 * \param [out] ruiRate coding bits4096 * \param [in] uiDist distortion4097 * \param [out] rdCost rate-distortion cost4098 * \param [in] pvAlfCUCtrlParam ALF CU control parameters4099 */4100 Void TEncAdaptiveLoopFilter::xCalcRDCost(ALFParam* pAlfParam, UInt64& ruiRate, UInt64 uiDist, Double& rdCost, std::vector<AlfCUCtrlInfo>* pvAlfCUCtrlParam)4101 {4102 if(pAlfParam != NULL)4103 {4104 m_pcEntropyCoder->resetEntropy();4105 m_pcEntropyCoder->resetBits();4106 m_pcEntropyCoder->encodeAlfParam(pAlfParam);4107 4108 ruiRate = m_pcEntropyCoder->getNumberOfWrittenBits();4109 4110 if(pvAlfCUCtrlParam != NULL)4111 {4112 for(UInt s=0; s< m_uiNumSlicesInPic; s++)4113 {4114 if(!m_pcPic->getValidSlice(s))4115 {4116 continue;4117 }4118 m_pcEntropyCoder->resetEntropy();4119 m_pcEntropyCoder->resetBits();4120 m_pcEntropyCoder->encodeAlfCtrlParam( (*pvAlfCUCtrlParam)[s], m_uiNumCUsInFrame);4121 ruiRate += m_pcEntropyCoder->getNumberOfWrittenBits();4122 }4123 }4124 else4125 {4126 ruiRate += m_uiNumSlicesInPic;4127 }4128 }4129 else4130 {4131 ruiRate = 1;4132 }4133 4134 rdCost = (Double)(ruiRate) * m_dLambdaLuma + (Double)(uiDist);4135 }4136 4137 /** Calculate RD cost4138 * \param [in] pcPicOrg original picture buffer4139 * \param [in] pcPicCmp compared picture buffer4140 * \param [in] pAlfParam ALF parameters4141 * \param [out] ruiRate coding bits4142 * \param [out] ruiDist distortion4143 * \param [out] rdCost rate-distortion cost4144 * \param [in] pvAlfCUCtrlParam ALF CU control parameters4145 */4146 #if HHI_INTERVIEW_SKIP4147 Void TEncAdaptiveLoopFilter::xCalcRDCost(TComPicYuv* pcPicOrg, TComPicYuv* pcPicCmp, TComPicYuv* pcUsedPelMap, ALFParam* pAlfParam, UInt64& ruiRate, UInt64& ruiDist, Double& rdCost, std::vector<AlfCUCtrlInfo>* pvAlfCUCtrlParam)4148 #else4149 Void TEncAdaptiveLoopFilter::xCalcRDCost(TComPicYuv* pcPicOrg, TComPicYuv* pcPicCmp, ALFParam* pAlfParam, UInt64& ruiRate, UInt64& ruiDist, Double& rdCost, std::vector<AlfCUCtrlInfo>* pvAlfCUCtrlParam)4150 #endif4151 {4152 if(pAlfParam != NULL)4153 {4154 m_pcEntropyCoder->resetEntropy();4155 m_pcEntropyCoder->resetBits();4156 m_pcEntropyCoder->encodeAlfParam(pAlfParam);4157 4158 ruiRate = m_pcEntropyCoder->getNumberOfWrittenBits();4159 4160 if(pvAlfCUCtrlParam != NULL)4161 {4162 for(UInt s=0; s< m_uiNumSlicesInPic; s++)4163 {4164 if(! m_pcPic->getValidSlice(s))4165 {4166 continue;4167 }4168 m_pcEntropyCoder->resetEntropy();4169 m_pcEntropyCoder->resetBits();4170 m_pcEntropyCoder->encodeAlfCtrlParam( (*pvAlfCUCtrlParam)[s], m_uiNumCUsInFrame);4171 ruiRate += m_pcEntropyCoder->getNumberOfWrittenBits();4172 }4173 4174 }4175 else4176 {4177 ruiRate += m_uiNumSlicesInPic;4178 }4179 }4180 else4181 {4182 ruiRate = 1;4183 }4184 4185 ruiDist = xCalcSSD(pcPicOrg->getLumaAddr(), pcPicCmp->getLumaAddr(), pcPicOrg->getWidth(), pcPicOrg->getHeight(), pcPicOrg->getStride());4186 rdCost = (Double)(ruiRate) * m_dLambdaLuma + (Double)(ruiDist);4187 }4188 /** Calculate RD cost for chroma ALF4189 * \param pcPicOrg original picture buffer4190 * \param pcPicCmp compared picture buffer4191 * \param pAlfParam ALF parameters4192 * \returns ruiRate bitrate4193 * \returns uiDist distortion4194 * \returns rdCost RD cost4195 */4196 Void TEncAdaptiveLoopFilter::xCalcRDCostChroma(TComPicYuv* pcPicOrg, TComPicYuv* pcPicCmp, ALFParam* pAlfParam, UInt64& ruiRate, UInt64& ruiDist, Double& rdCost)4197 {4198 if(pAlfParam->chroma_idc)4199 {4200 ruiRate = xCalcRateChroma(pAlfParam);4201 }4202 ruiDist = 0;4203 ruiDist += xCalcSSD(pcPicOrg->getCbAddr(), pcPicCmp->getCbAddr(), (pcPicOrg->getWidth()>>1), (pcPicOrg->getHeight()>>1), pcPicOrg->getCStride());4204 ruiDist += xCalcSSD(pcPicOrg->getCrAddr(), pcPicCmp->getCrAddr(), (pcPicOrg->getWidth()>>1), (pcPicOrg->getHeight()>>1), pcPicOrg->getCStride());4205 rdCost = (Double)(ruiRate) * m_dLambdaChroma + (Double)(ruiDist);4206 }4207 4208 Void TEncAdaptiveLoopFilter::xFilteringFrameChroma(ALFParam* pcAlfParam, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest)4209 {4210 Int filtNo = pcAlfParam->filter_shape_chroma;4211 Int *coeff = pcAlfParam->coeff_chroma;4212 Int iChromaFormatShift = 1; //4:2:04213 4214 if ((pcAlfParam->chroma_idc>>1)&0x01)4215 {4216 if(!m_bUseNonCrossALF)4217 {4218 Int iStride = pcPicRest->getCStride();4219 Pel* pDec = pcPicDec->getCbAddr();4220 Pel* pRest = pcPicRest->getCbAddr();4221 4222 filterChroma(pRest, pDec, iStride, 0, (Int)(m_img_height>>1) -1, 0, (Int)(m_img_width>>1)-1, filtNo, coeff);4223 }4224 else4225 {4226 xFilterChromaSlices(ALF_Cb, pcPicDec, pcPicRest, coeff, filtNo, iChromaFormatShift);4227 }4228 }4229 if ((pcAlfParam->chroma_idc)&0x01)4230 {4231 if(!m_bUseNonCrossALF)4232 {4233 Int iStride = pcPicRest->getCStride();4234 Pel* pDec = pcPicDec->getCrAddr();4235 Pel* pRest = pcPicRest->getCrAddr();4236 4237 filterChroma(pRest, pDec, iStride, 0, (Int)(m_img_height>>1) -1, 0, (Int)(m_img_width>>1)-1, filtNo, coeff);4238 }4239 else4240 {4241 xFilterChromaSlices(ALF_Cr, pcPicDec, pcPicRest, coeff, filtNo, iChromaFormatShift);4242 }4243 }4244 4245 if(pcAlfParam->chroma_idc<3)4246 {4247 if(pcAlfParam->chroma_idc==1)4248 {4249 pcPicDec->copyToPicCb(pcPicRest);4250 }4251 if(pcAlfParam->chroma_idc==2)4252 {4253 pcPicDec->copyToPicCr(pcPicRest);4254 }4255 }4256 4257 }4258 #endif4259 #if LCU_SYNTAX_ALF4260 3356 /** Restore the not-filtered pixels 4261 3357 * \param [in] imgDec picture buffer before filtering … … 4264 3360 */ 4265 3361 Void TEncAdaptiveLoopFilter::xCopyDecToRestCUs(Pel* imgDec, Pel* imgRest, Int stride) 4266 #else4267 /** Restore the not-filtered pixels4268 * \param pcPicDec picture buffer before filtering4269 * \param pcPicRest picture buffer after filtering4270 */4271 Void TEncAdaptiveLoopFilter::xCopyDecToRestCUs(TComPicYuv* pcPicDec, TComPicYuv* pcPicRest)4272 #endif4273 3362 { 4274 3363 4275 3364 if(m_uiNumSlicesInPic > 1) 4276 3365 { 4277 #if LCU_SYNTAX_ALF4278 3366 Pel* pPicDecLuma = imgDec; 4279 3367 Pel* pPicRestLuma = imgRest; 4280 #else4281 Pel* pPicDecLuma = pcPicDec->getLumaAddr();4282 Pel* pPicRestLuma = pcPicRest->getLumaAddr();4283 Int stride = pcPicDec->getStride();4284 #endif4285 3368 UInt SUWidth = m_pcPic->getMinCUWidth(); 4286 3369 UInt SUHeight = m_pcPic->getMinCUHeight(); … … 4335 3418 { 4336 3419 TComDataCU* pcCU = m_pcPic->getCU( uiCUAddr ); 4337 #if LCU_SYNTAX_ALF4338 3420 xCopyDecToRestCU(pcCU, 0, 0, imgDec, imgRest, stride); 4339 #else 4340 xCopyDecToRestCU(pcCU, 0, 0, pcPicDec, pcPicRest); 4341 #endif 4342 } 4343 } 4344 4345 #if LCU_SYNTAX_ALF 3421 } 3422 } 3423 4346 3424 Void TEncAdaptiveLoopFilter::xCopyDecToRestCU(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Pel* imgDec, Pel* imgRest, Int stride) 4347 #else4348 Void TEncAdaptiveLoopFilter::xCopyDecToRestCU(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest)4349 #endif4350 3425 { 4351 3426 Bool bBoundary = false; … … 4369 3444 4370 3445 if( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) 4371 #if LCU_SYNTAX_ALF4372 3446 xCopyDecToRestCU(pcCU, uiAbsPartIdx, uiDepth+1, imgDec, imgRest, stride); 4373 #else4374 xCopyDecToRestCU(pcCU, uiAbsPartIdx, uiDepth+1, pcPicDec, pcPicRest);4375 #endif4376 3447 } 4377 3448 return; … … 4380 3451 if (!pcCU->getAlfCtrlFlag(uiAbsPartIdx)) 4381 3452 { 4382 #if !LCU_SYNTAX_ALF4383 UInt uiCUAddr = pcCU->getAddr();4384 #endif4385 3453 Int iWidth = pcCU->getWidth(uiAbsPartIdx); 4386 3454 Int iHeight = pcCU->getHeight(uiAbsPartIdx); 4387 #if LCU_SYNTAX_ALF4388 3455 copyPixelsInOneRegion(imgRest, imgDec, stride, (Int)uiTPelY, iHeight, (Int)uiLPelX, iWidth); 4389 #else4390 Pel* pRec = pcPicDec->getLumaAddr(uiCUAddr, uiAbsPartIdx);4391 Pel* pFilt = pcPicRest->getLumaAddr(uiCUAddr, uiAbsPartIdx);4392 4393 Int iRecStride = pcPicDec->getStride();4394 Int iFiltStride = pcPicRest->getStride();4395 4396 for (Int y = 0; y < iHeight; y++)4397 {4398 for (Int x = 0; x < iWidth; x++)4399 {4400 pFilt[x] = pRec[x];4401 }4402 pRec += iRecStride;4403 pFilt += iFiltStride;4404 }4405 #endif4406 3456 } 4407 3457 } … … 4426 3476 Void TEncAdaptiveLoopFilter::predictALFCoeffLumaEnc(ALFParam* pcAlfParam, Int **pfilterCoeffSym, Int filter_shape) 4427 3477 { 4428 #if LCU _SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS3478 #if LCUALF_QP_DEPENDENT_BITS 4429 3479 Int alfPrecisionBit = getAlfPrecisionBit( m_alfQP ); 4430 3480 #endif … … 4442 3492 if((pcAlfParam->predMethod==0)|(ind==0)) 4443 3493 { 4444 #if LCU _SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS3494 #if LCUALF_QP_DEPENDENT_BITS 4445 3495 coeffPred = ((1<<alfPrecisionBit)-sum) >> 2; 4446 3496 #else … … 4465 3515 if((pcAlfParam->predMethod==0)|(ind==0)) 4466 3516 { 4467 #if LCU _SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS3517 #if LCUALF_QP_DEPENDENT_BITS 4468 3518 coeffPred = (1<<alfPrecisionBit)-sum; 4469 3519 #else … … 4600 3650 *pDepthInt=NULL, kMinTab[MAX_SCAN_VAL], bitsCoeffScan[MAX_SCAN_VAL][MAX_EXP_GOLOMB], 4601 3651 minKStart, minBitsKStart, bitsKStart; 4602 #if ALF_SINGLE_FILTER_SHAPE4603 3652 Int minScanVal = MIN_SCAN_POS_CROSS; 4604 #else4605 int minScanVal = (fl==ALF_STAR5x5) ? 0 : MIN_SCAN_POS_CROSS;4606 #endif4607 3653 pDepthInt = pDepthIntTabShapes[fl]; 4608 3654 … … 4672 3718 // Coding parameters 4673 3719 // len += lengthFilterCodingParams(minKStart, maxScanVal, kMinTab, createBitstream); 4674 #if LCU_SYNTAX_ALF4675 3720 if (filters_per_group == 1) 4676 3721 { … … 4680 3725 else 4681 3726 { 4682 #endif4683 3727 len += (3 + maxScanVal); 4684 3728 … … 4686 3730 len += lengthFilterCoeffs(sqrFiltLength, filters_per_group, pDepthInt, pDiffQFilterCoeffIntPP, 4687 3731 kMinTab, createBitstream); 4688 #if LCU_SYNTAX_ALF 4689 } 4690 #endif 3732 } 4691 3733 4692 3734 return len; … … 4735 3777 { 4736 3778 scanPos = pDepthInt[i] - 1; 4737 #if LCU_SYNTAX_ALF4738 3779 Int k = (filters_per_group == 1) ? kMinTab[i] : kMinTab[scanPos]; 4739 3780 bit_cnt += lengthGolomb(abs(FilterCoeff[ind][i]), k); 4740 #else4741 bit_cnt += lengthGolomb(abs(FilterCoeff[ind][i]), kMinTab[scanPos]);4742 #endif4743 3781 } 4744 3782 } … … 4746 3784 } 4747 3785 4748 #if !LCU_SYNTAX_ALF 4749 4750 Void TEncAdaptiveLoopFilter::xEncALFLuma ( TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiMinRate, UInt64& ruiMinDist, Double& rdMinCost ) 4751 { 4752 //pcPicDec: extended decoded 4753 //pcPicRest: original decoded: filtered signal will be stored 4754 4755 UInt64 uiRate; 4756 UInt64 uiDist; 4757 Double dCost; 4758 Int LumaStride = pcPicOrg->getStride(); 4759 Pel* pOrg = pcPicOrg->getLumaAddr(); 4760 Pel* pRest = pcPicRest->getLumaAddr(); 4761 Pel* pDec = pcPicDec->getLumaAddr(); 4762 4763 Double dMinMethodCost = MAX_DOUBLE; 4764 UInt64 uiMinMethodDist = MAX_UINT; 4765 UInt64 uiMinMethodRate = MAX_UINT; 4766 Int iBestClassMethod = ALF_RA; 4767 Double adExtraCostReduction[NUM_ALF_CLASS_METHOD]; 4768 ALFParam cFrmAlfParam [NUM_ALF_CLASS_METHOD]; 4769 ALFParam* pcAlfParam = NULL; 4770 4771 for(Int i=0; i< NUM_ALF_CLASS_METHOD; i++) 4772 { 4773 pcAlfParam = &(cFrmAlfParam[i]); 4774 allocALFParam(pcAlfParam); 4775 4776 pcAlfParam->alf_flag = 1; 4777 pcAlfParam->chroma_idc = 0; 4778 4779 switch(i) 4780 { 4781 case ALF_RA: 4782 { 4783 adExtraCostReduction[i] = (double)(m_img_height * m_img_width) * m_dLambdaLuma * 2.0 / 4096.0; 4784 } 4785 break; 4786 case ALF_BA: 4787 { 4788 adExtraCostReduction[i] = 0.0; 4789 } 4790 break; 4791 default: 4792 { 4793 printf("Not a support adaptation method\n"); 4794 assert(0); 4795 exit(-1); 4796 } 4797 } 4798 } 4799 4800 4801 for(Int i=0; i< NUM_ALF_CLASS_METHOD; i++) 4802 { 4803 m_uiVarGenMethod = i; 4804 4805 pcAlfParam = &(cFrmAlfParam[m_uiVarGenMethod]); 4806 m_varImg = m_varImgMethods[m_uiVarGenMethod]; 4807 4808 pcAlfParam->alf_pcr_region_flag = m_uiVarGenMethod; 4809 4810 setInitialMask(pcPicOrg, pcPicDec); 4811 4812 if(m_iALFEncodePassReduction == 0) 4813 { 4814 static Int best_filter_shape = 0; 4815 if (m_uiVarGenMethod == 0) 4816 { 4817 UInt64 MinRate_Shape0 = MAX_INT; 4818 UInt64 MinDist_Shape0 = MAX_INT; 4819 Double MinCost_Shape0 = MAX_DOUBLE; 4820 4821 UInt64 MinRate_Shape1 = MAX_INT; 4822 UInt64 MinDist_Shape1 = MAX_INT; 4823 Double MinCost_Shape1 = MAX_DOUBLE; 4824 4825 #if ALF_SINGLE_FILTER_SHAPE 4826 Int filter_shape = 0; 4827 #else 4828 for (Int filter_shape = 0; filter_shape < 2 ;filter_shape ++) 4829 #endif 4830 { 4831 pcAlfParam->filter_shape = filter_shape; 4832 pcAlfParam->num_coeff = m_pcTempAlfParam->num_coeff = m_sqrFiltLengthTab[filter_shape]; 4833 xFirstFilteringFrameLuma(pOrg, pDec, m_pcPicYuvTmp->getLumaAddr(), pcAlfParam, pcAlfParam->filter_shape, LumaStride); 4834 xCalcRDCost(pcPicOrg, m_pcPicYuvTmp, pcAlfParam, uiRate, uiDist, dCost); 4835 if (filter_shape == 0) 4836 { 4837 // copy Shape0 4838 MinRate_Shape0 = uiRate; 4839 MinDist_Shape0 = uiDist; 4840 MinCost_Shape0 = dCost; 4841 m_pcPicYuvTmp->copyToPicLuma(pcPicYuvRecShape0); 4842 copyALFParam(pcAlfParamShape0, pcAlfParam); 4843 } 4844 else //if (filter_shape == 1) 4845 { 4846 // copy Shape1 4847 MinRate_Shape1 = uiRate; 4848 MinDist_Shape1 = uiDist; 4849 MinCost_Shape1 = dCost; 4850 m_pcPicYuvTmp->copyToPicLuma(pcPicYuvRecShape1); 4851 copyALFParam(pcAlfParamShape1, pcAlfParam); 4852 } 4853 } 4854 4855 if (MinCost_Shape0 <= MinCost_Shape1) 4856 { 4857 pcPicYuvRecShape0->copyToPicLuma(m_pcPicYuvTmp); 4858 copyALFParam(pcAlfParam, pcAlfParamShape0); 4859 uiRate = MinRate_Shape0; 4860 uiDist = MinDist_Shape0; 4861 dCost = MinCost_Shape0; 4862 best_filter_shape = 0; 4863 } 4864 else //if (MinCost_Shape1 < MinCost_Shape0) 4865 { 4866 pcPicYuvRecShape1->copyToPicLuma(m_pcPicYuvTmp); 4867 copyALFParam(pcAlfParam, pcAlfParamShape1); 4868 uiRate = MinRate_Shape1; 4869 uiDist = MinDist_Shape1; 4870 dCost = MinCost_Shape1; 4871 best_filter_shape = 1; 4872 } 4873 } 4874 else 4875 { 4876 pcAlfParam->filter_shape = best_filter_shape; 4877 pcAlfParam->num_coeff = m_pcTempAlfParam->num_coeff = m_sqrFiltLengthTab[best_filter_shape]; 4878 xFirstFilteringFrameLuma(pOrg, pDec, m_pcPicYuvTmp->getLumaAddr(), pcAlfParam, best_filter_shape, LumaStride); 4879 xCalcRDCost(pcPicOrg, m_pcPicYuvTmp, pcAlfParam, uiRate, uiDist, dCost); 4880 } 4881 } 4882 else 4883 { 4884 decideFilterShapeLuma(pOrg, pDec, LumaStride, pcAlfParam, uiRate, uiDist, dCost); 4885 } 4886 4887 dCost -= adExtraCostReduction[m_uiVarGenMethod]; 4888 4889 if(dCost < dMinMethodCost) 4890 { 4891 iBestClassMethod = m_uiVarGenMethod; 4892 dMinMethodCost = dCost; 4893 uiMinMethodRate= uiRate; 4894 uiMinMethodDist = uiDist; 4895 4896 if(m_iALFEncodePassReduction == 0) 4897 { 4898 m_pcPicYuvTmp->copyToPicLuma(pcPicRest); 4899 } 4900 } 4901 } 4902 4903 m_uiVarGenMethod = iBestClassMethod; 4904 dMinMethodCost += adExtraCostReduction[m_uiVarGenMethod]; 4905 m_varImg= m_varImgMethods[m_uiVarGenMethod]; 4906 4907 pcAlfParam = &(cFrmAlfParam[m_uiVarGenMethod]); 4908 4909 ALFParam cAlfParamWithBestMethod; 4910 allocALFParam(&cAlfParamWithBestMethod); 4911 4912 4913 if(m_iALFEncodePassReduction ==0) 4914 { 4915 copyALFParam(&cAlfParamWithBestMethod, pcAlfParam); 4916 } 4917 else 4918 { 4919 cAlfParamWithBestMethod.alf_flag = 1; 4920 cAlfParamWithBestMethod.chroma_idc = 0; 4921 cAlfParamWithBestMethod.alf_pcr_region_flag = m_uiVarGenMethod; 4922 cAlfParamWithBestMethod.filter_shape= pcAlfParam->filter_shape; 4923 cAlfParamWithBestMethod.num_coeff = m_sqrFiltLengthTab[cAlfParamWithBestMethod.filter_shape]; 4924 decodeFilterSet(pcAlfParam, m_varIndTab, m_filterCoeffSym); 4925 if(!m_bUseNonCrossALF) 4926 { 4927 filterLuma(pRest, pDec, LumaStride, 0, m_img_height-1, 0, m_img_width-1, pcAlfParam->filter_shape, m_filterCoeffSym, m_varIndTab, m_varImg); 4928 } 4929 else 4930 { 4931 xfilterSlicesEncoder(pDec, pRest, LumaStride, pcAlfParam->filter_shape, m_filterCoeffSym, m_varIndTab, m_varImg); 4932 } 4933 xcodeFiltCoeff(m_filterCoeffSym, pcAlfParam->filter_shape, m_varIndTab, pcAlfParam->filters_per_group,&cAlfParamWithBestMethod); 4934 4935 xCalcRDCost(pcPicOrg, pcPicRest, &cAlfParamWithBestMethod, uiMinMethodRate, uiMinMethodDist, dMinMethodCost); 4936 4937 } 4938 4939 if(dMinMethodCost < rdMinCost ) 4940 { 4941 ruiMinRate = uiMinMethodRate; 4942 ruiMinDist = uiMinMethodDist; 4943 rdMinCost = dMinMethodCost; 4944 copyALFParam(m_pcBestAlfParam, &cAlfParamWithBestMethod); 4945 } 4946 4947 freeALFParam(&cAlfParamWithBestMethod); 4948 for(Int i=0; i< NUM_ALF_CLASS_METHOD; i++) 4949 { 4950 freeALFParam(&cFrmAlfParam[i]); 4951 } 4952 } 4953 4954 4955 4956 Void TEncAdaptiveLoopFilter::xFirstFilteringFrameLuma(Pel* imgOrg, Pel* imgDec, Pel* imgRest, ALFParam* ALFp, Int filtNo, Int stride) 4957 { 4958 if(!m_bUseNonCrossALF) 4959 { 4960 xstoreInBlockMatrix(0, 0, m_img_height, m_img_width, true, true, imgOrg, imgDec, filtNo, stride); 4961 } 4962 else 4963 { 4964 xstoreInBlockMatrixforSlices(imgOrg, imgDec, filtNo, stride); 4965 } 4966 4967 4968 xFilteringFrameLuma(imgOrg, imgDec, imgRest, ALFp, filtNo, stride); 4969 } 4970 4971 Void TEncAdaptiveLoopFilter::xstoreInBlockMatrix(Int ypos, Int xpos, Int iheight, Int iwidth, Bool bResetBlockMatrix, Bool bSymmCopyBlockMatrix, Pel* pImgOrg, Pel* pImgPad, Int filtNo, Int stride) 4972 { 4973 4974 Pel regionOfInterested = (m_iDesignCurrentFilter ==1)?(1):(0); 4975 Int sqrFiltLength = (filtNo == 2)?((Int)(MAX_SQR_FILT_LENGTH)):(m_sqrFiltLengthTab[filtNo]); 4976 Int yposEnd = ypos + iheight -1; 4977 Int xposEnd = xpos + iwidth -1; 4978 Double ***EShape = m_EGlobalSym[filtNo]; 4979 Double **yShape = m_yGlobalSym[filtNo]; 4980 4981 Int ELocal[MAX_SQR_FILT_LENGTH]; 4982 Pel *pImgPad1, *pImgPad2, *pImgPad3, *pImgPad4; 4983 Int i,j,k,l,varInd, yLocal; 4984 double **E,*yy; 4985 4986 static Int numValidPels; 4987 if(bResetBlockMatrix) 4988 { 4989 numValidPels = 0; 4990 memset( m_pixAcc, 0,sizeof(double)*NO_VAR_BINS); 4991 for (varInd=0; varInd<NO_VAR_BINS; varInd++) 4992 { 4993 memset(yShape[varInd],0,sizeof(double)*MAX_SQR_FILT_LENGTH); 4994 for (k=0; k<sqrFiltLength; k++) 4995 { 4996 memset(EShape[varInd][k],0,sizeof(double)*MAX_SQR_FILT_LENGTH); 4997 } 4998 } 4999 for (i = 0; i < m_img_height; i++) 5000 { 5001 for (j = 0; j < m_img_width; j++) 5002 { 5003 if (m_maskImg[i][j] == regionOfInterested) 5004 { 5005 numValidPels++; 5006 } 5007 } 5008 } 5009 } 5010 5011 Int yLineInLCU; 5012 Int paddingLine ; 5013 5014 pImgPad += (ypos* stride); 5015 pImgOrg += (ypos* stride); 5016 5017 switch(filtNo) 5018 { 5019 #if !ALF_SINGLE_FILTER_SHAPE 5020 case ALF_STAR5x5: 5021 { 5022 for (i= ypos; i<= yposEnd; i++) 5023 { 5024 yLineInLCU = i % m_lcuHeight; 5025 5026 if (yLineInLCU < m_lineIdxPadBot || i-yLineInLCU+m_lcuHeight >= m_img_height ) 5027 { 5028 pImgPad1 = pImgPad + stride; 5029 pImgPad2 = pImgPad - stride; 5030 pImgPad3 = pImgPad + 2*stride; 5031 pImgPad4 = pImgPad - 2*stride; 5032 } 5033 else if (yLineInLCU < m_lineIdxPadTop) 5034 { 5035 paddingLine = - yLineInLCU + m_lineIdxPadTop - 1; 5036 pImgPad1 = pImgPad + min(paddingLine, 1)*stride; 5037 pImgPad2 = pImgPad - stride; 5038 pImgPad3 = pImgPad + min(paddingLine, 2)*stride; 5039 pImgPad4 = pImgPad - 2*stride; 5040 } 5041 else 5042 { 5043 paddingLine = yLineInLCU - m_lineIdxPadTop; 5044 pImgPad1 = pImgPad + stride; 5045 pImgPad2 = pImgPad - min(paddingLine, 1)*stride; 5046 pImgPad3 = pImgPad + 2*stride; 5047 pImgPad4 = pImgPad - min(paddingLine, 2)*stride; 5048 } 5049 5050 if ( (yLineInLCU == m_lineIdxPadTop || yLineInLCU == m_lineIdxPadTop-1) && i-yLineInLCU+m_lcuHeight < m_img_height ) 5051 { 5052 pImgPad+= stride; 5053 pImgOrg+= stride; 5054 continue; 5055 } 5056 else 5057 { 5058 for (j= xpos; j<= xposEnd; j++) 5059 { 5060 if ( (m_maskImg[i][j] == regionOfInterested) || (numValidPels == 0) ) 5061 { 5062 varInd = m_varImg[i/VAR_SIZE_H][j/VAR_SIZE_W]; 5063 memset(ELocal, 0, 10*sizeof(Int)); 5064 5065 ELocal[0] = (pImgPad3[j+2] + pImgPad4[j-2]); 5066 ELocal[1] = (pImgPad3[j ] + pImgPad4[j ]); 5067 ELocal[2] = (pImgPad3[j-2] + pImgPad4[j+2]); 5068 5069 ELocal[3] = (pImgPad1[j+1] + pImgPad2[j-1]); 5070 ELocal[4] = (pImgPad1[j ] + pImgPad2[j ]); 5071 ELocal[5] = (pImgPad1[j-1] + pImgPad2[j+1]); 5072 5073 ELocal[6] = (pImgPad[j+2] + pImgPad[j-2]); 5074 ELocal[7] = (pImgPad[j+1] + pImgPad[j-1]); 5075 ELocal[8] = (pImgPad[j ]); 5076 5077 yLocal= pImgOrg[j]; 5078 m_pixAcc[varInd]+=(yLocal*yLocal); 5079 E= EShape[varInd]; 5080 yy= yShape[varInd]; 5081 5082 for (k=0; k<10; k++) 5083 { 5084 for (l=k; l<10; l++) 5085 { 5086 E[k][l]+=(double)(ELocal[k]*ELocal[l]); 5087 } 5088 yy[k]+=(double)(ELocal[k]*yLocal); 5089 } 5090 5091 } 5092 } 5093 pImgPad+= stride; 5094 pImgOrg+= stride; 5095 } 5096 } 5097 } 5098 break; 5099 case ALF_CROSS9x9: 5100 { 5101 Pel *pImgPad5, *pImgPad6, *pImgPad7, *pImgPad8; 5102 #else 5103 case ALF_CROSS9x7_SQUARE3x3: 5104 { 5105 Pel *pImgPad5, *pImgPad6; 5106 #endif 5107 for (i= ypos; i<= yposEnd; i++) 5108 { 5109 yLineInLCU = i % m_lcuHeight; 5110 5111 if (yLineInLCU<m_lineIdxPadBot || i-yLineInLCU+m_lcuHeight >= m_img_height) 5112 { 5113 pImgPad1 = pImgPad + stride; 5114 pImgPad2 = pImgPad - stride; 5115 pImgPad3 = pImgPad + 2*stride; 5116 pImgPad4 = pImgPad - 2*stride; 5117 pImgPad5 = pImgPad + 3*stride; 5118 pImgPad6 = pImgPad - 3*stride; 5119 #if !ALF_SINGLE_FILTER_SHAPE 5120 pImgPad7 = pImgPad + 4*stride; 5121 pImgPad8 = pImgPad - 4*stride; 5122 #endif 5123 } 5124 else if (yLineInLCU<m_lineIdxPadTop) 5125 { 5126 paddingLine = - yLineInLCU + m_lineIdxPadTop - 1; 5127 pImgPad1 = (paddingLine < 1) ? pImgPad : pImgPad + min(paddingLine, 1)*stride; 5128 pImgPad2 = (paddingLine < 1) ? pImgPad : pImgPad - stride; 5129 pImgPad3 = (paddingLine < 2) ? pImgPad : pImgPad + min(paddingLine, 2)*stride; 5130 pImgPad4 = (paddingLine < 2) ? pImgPad : pImgPad - 2*stride; 5131 pImgPad5 = (paddingLine < 3) ? pImgPad : pImgPad + min(paddingLine, 3)*stride; 5132 pImgPad6 = (paddingLine < 3) ? pImgPad : pImgPad - 3*stride; 5133 #if !ALF_SINGLE_FILTER_SHAPE 5134 pImgPad7 = (paddingLine < 4) ? pImgPad : pImgPad + min(paddingLine, 4)*stride; 5135 pImgPad8 = (paddingLine < 4) ? pImgPad : pImgPad - 4*stride; 5136 #endif 5137 } 5138 else 5139 { 5140 paddingLine = yLineInLCU - m_lineIdxPadTop; 5141 pImgPad1 = (paddingLine < 1) ? pImgPad : pImgPad + stride; 5142 pImgPad2 = (paddingLine < 1) ? pImgPad : pImgPad - min(paddingLine, 1)*stride; 5143 pImgPad3 = (paddingLine < 2) ? pImgPad : pImgPad + 2*stride; 5144 pImgPad4 = (paddingLine < 2) ? pImgPad : pImgPad - min(paddingLine, 2)*stride; 5145 pImgPad5 = (paddingLine < 3) ? pImgPad : pImgPad + 3*stride; 5146 pImgPad6 = (paddingLine < 3) ? pImgPad : pImgPad - min(paddingLine, 3)*stride; 5147 #if !ALF_SINGLE_FILTER_SHAPE 5148 pImgPad7 = (paddingLine < 4) ? pImgPad : pImgPad + 4*stride; 5149 pImgPad8 = (paddingLine < 4) ? pImgPad : pImgPad - min(paddingLine, 4)*stride; 5150 #endif 5151 } 5152 5153 for (j= xpos; j<= xposEnd; j++) 5154 { 5155 if ( (m_maskImg[i][j] == regionOfInterested) || (numValidPels == 0) ) 5156 { 5157 varInd = m_varImg[i/VAR_SIZE_H][j/VAR_SIZE_W]; 5158 5159 #if ALF_SINGLE_FILTER_SHAPE 5160 memset(ELocal, 0, (sqrFiltLength+1)*sizeof(Int)); 5161 5162 ELocal[0] = (pImgPad5[j]+pImgPad6[j]); 5163 ELocal[1] = (pImgPad3[j]+pImgPad4[j]); 5164 ELocal[2] = (pImgPad1[j-1]+pImgPad2[j+1]); 5165 ELocal[3] = (pImgPad1[j]+pImgPad2[j]); 5166 ELocal[4] = (pImgPad1[j+1]+pImgPad2[j-1]); 5167 ELocal[5] = (pImgPad[j+4]+pImgPad[j-4]); 5168 ELocal[6] = (pImgPad[j+3]+pImgPad[j-3]); 5169 ELocal[7] = (pImgPad[j+2]+pImgPad[j-2]); 5170 ELocal[8] = (pImgPad[j+1]+pImgPad[j-1]); 5171 ELocal[9] = (pImgPad[j ]); 5172 #else 5173 memset(ELocal, 0, 10*sizeof(Int)); 5174 5175 ELocal[0] = (pImgPad7[j] + pImgPad8[j]); 5176 5177 ELocal[1] = (pImgPad5[j] + pImgPad6[j]); 5178 5179 ELocal[2] = (pImgPad3[j] + pImgPad4[j]); 5180 5181 ELocal[3] = (pImgPad1[j] + pImgPad2[j]); 5182 5183 ELocal[4] = (pImgPad[j+4] + pImgPad[j-4]); 5184 ELocal[5] = (pImgPad[j+3] + pImgPad[j-3]); 5185 ELocal[6] = (pImgPad[j+2] + pImgPad[j-2]); 5186 ELocal[7] = (pImgPad[j+1] + pImgPad[j-1]); 5187 ELocal[8] = (pImgPad[j ] ); 5188 #endif 5189 yLocal= pImgOrg[j]; 5190 m_pixAcc[varInd]+=(yLocal*yLocal); 5191 E= EShape[varInd]; 5192 yy= yShape[varInd]; 5193 5194 #if ALF_SINGLE_FILTER_SHAPE 5195 for (k=0; k<(sqrFiltLength+1); k++) 5196 { 5197 for (l=k; l<(sqrFiltLength+1); l++) 5198 { 5199 E[k][l]+=(double)(ELocal[k]*ELocal[l]); 5200 } 5201 yy[k]+=(double)(ELocal[k]*yLocal); 5202 } 5203 #else 5204 for (k=0; k<10; k++) 5205 { 5206 for (l=k; l<10; l++) 5207 { 5208 E[k][l]+=(double)(ELocal[k]*ELocal[l]); 5209 } 5210 yy[k]+=(double)(ELocal[k]*yLocal); 5211 } 5212 #endif 5213 } 5214 } 5215 pImgPad+= stride; 5216 pImgOrg+= stride; 5217 } 5218 5219 } 5220 break; 5221 default: 5222 { 5223 printf("Not a supported filter shape\n"); 5224 assert(0); 5225 exit(1); 5226 } 5227 } 5228 5229 if(bSymmCopyBlockMatrix) 5230 { 5231 for (varInd=0; varInd<NO_VAR_BINS; varInd++) 5232 { 5233 double **pE = EShape[varInd]; 5234 for (k=1; k<sqrFiltLength; k++) 5235 { 5236 for (l=0; l<k; l++) 5237 { 5238 pE[k][l]=pE[l][k]; 5239 } 5240 } 5241 } 5242 } 5243 } 5244 5245 5246 Void TEncAdaptiveLoopFilter::xFilteringFrameLuma(Pel* imgOrg, Pel* imgPad, Pel* imgFilt, ALFParam* ALFp, Int filtNo, Int stride) 5247 { 5248 static double **ySym, ***ESym; 5249 Int filters_per_fr; 5250 Int lambdaVal = (Int) m_dLambdaLuma; 5251 lambdaVal = lambdaVal * (1<<(2*g_uiBitIncrement)); 5252 5253 ESym=m_EGlobalSym[filtNo]; 5254 ySym=m_yGlobalSym[filtNo]; 5255 5256 xfindBestFilterVarPred(ySym, ESym, m_pixAcc, m_filterCoeffSym, m_filterCoeffSymQuant, filtNo, &filters_per_fr,m_varIndTab, NULL, m_varImg, m_maskImg, NULL, lambdaVal); 5257 5258 if(!m_bUseNonCrossALF) 5259 { 5260 filterLuma(imgFilt, imgPad, stride, 0, m_img_height-1, 0, m_img_width-1, ALFp->filter_shape, m_filterCoeffSym, m_varIndTab, m_varImg); 5261 } 5262 else 5263 { 5264 xfilterSlicesEncoder(imgPad, imgFilt, stride, filtNo, m_filterCoeffSym, m_varIndTab, m_varImg); 5265 } 5266 5267 xcodeFiltCoeff(m_filterCoeffSymQuant, filtNo, m_varIndTab, filters_per_fr,ALFp); 5268 } 5269 #endif 5270 5271 #if LCU_SYNTAX_ALF 3786 5272 3787 Void TEncAdaptiveLoopFilter::xfindBestFilterVarPred(double **ySym, double ***ESym, double *pixAcc, Int **filterCoeffSym, Int **filterCoeffSymQuant, Int filter_shape, Int *filters_per_fr_best, Int varIndTab[], Pel **imgY_rec, Pel **varImg, Pel **maskImg, Pel **imgY_pad, double lambda_val, Int numMaxFilters) 5273 #else5274 Void TEncAdaptiveLoopFilter::xfindBestFilterVarPred(double **ySym, double ***ESym, double *pixAcc, Int **filterCoeffSym, Int **filterCoeffSymQuant, Int filter_shape, Int *filters_per_fr_best, Int varIndTab[], Pel **imgY_rec, Pel **varImg, Pel **maskImg, Pel **imgY_pad, double lambda_val)5275 #endif5276 3788 { 5277 3789 Int filters_per_fr, firstFilt, interval[NO_VAR_BINS][2], intervalBest[NO_VAR_BINS][2]; … … 5305 3817 5306 3818 lagrangian=xfindBestCoeffCodMethod(filterCoeffSymQuant, filter_shape, sqrFiltLength, filters_per_fr, errorForce0CoeffTab, lambda_val); 5307 #if LCU_SYNTAX_ALF5308 3819 if (lagrangian<lagrangianMin || firstFilt==1 || filters_per_fr == numMaxFilters) 5309 #else5310 if (lagrangian<lagrangianMin || firstFilt==1 || filters_per_fr == m_iALFMaxNumberFilters)5311 #endif5312 3820 { 5313 3821 firstFilt=0; … … 5319 3827 filters_per_fr--; 5320 3828 } 5321 #if !ALF_16_BA_GROUPS5322 if ( (m_uiVarGenMethod == ALF_BA) && ((*filters_per_fr_best) > 1) )5323 {5324 Int iLastFilter = (*filters_per_fr_best)-1;5325 if (intervalBest[iLastFilter][0] == NO_VAR_BINS-1)5326 {5327 intervalBest[iLastFilter-1][1] = NO_VAR_BINS-1;5328 (*filters_per_fr_best) = iLastFilter;5329 }5330 }5331 #endif5332 3829 findFilterCoeff(ESym, ySym, pixAcc, filterCoeffSym, filterCoeffSymQuant, intervalBest, 5333 3830 varIndTab, sqrFiltLength, (*filters_per_fr_best), weights, errorForce0CoeffTab); … … 5489 3986 * \param [in,out]vAlfCUCtrlParam ALF CU control parameters 5490 3987 */ 5491 #if LCU_SYNTAX_ALF5492 3988 #if HHI_INTERVIEW_SKIP 5493 3989 Void TEncAdaptiveLoopFilter::setCUAlfCtrlFlags(UInt uiAlfCtrlDepth, Pel* imgOrg, Pel* imgDec, Pel* imgRest, Pel* imgUsed, Int stride, UInt64& ruiDist, std::vector<AlfCUCtrlInfo>& vAlfCUCtrlParam) … … 5495 3991 Void TEncAdaptiveLoopFilter::setCUAlfCtrlFlags(UInt uiAlfCtrlDepth, Pel* imgOrg, Pel* imgDec, Pel* imgRest, Int stride, UInt64& ruiDist, std::vector<AlfCUCtrlInfo>& vAlfCUCtrlParam) 5496 3992 #endif 5497 #else5498 #if HHI_INTERVIEW_SKIP5499 Void TEncAdaptiveLoopFilter::xSetCUAlfCtrlFlags_qc(UInt uiAlfCtrlDepth, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, TComPicYuv* pUsedPelMap, UInt64& ruiDist, std::vector<AlfCUCtrlInfo>& vAlfCUCtrlParam)5500 #else5501 Void TEncAdaptiveLoopFilter::xSetCUAlfCtrlFlags_qc(UInt uiAlfCtrlDepth, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiDist, std::vector<AlfCUCtrlInfo>& vAlfCUCtrlParam)5502 #endif5503 #endif5504 3993 { 5505 3994 ruiDist = 0; … … 5520 4009 { 5521 4010 TComDataCU* pcCU = m_pcPic->getCU( CUAddr ); 5522 #if LCU_SYNTAX_ALF5523 4011 #if HHI_INTERVIEW_SKIP 5524 4012 setCUAlfCtrlFlag(pcCU, 0, 0, uiAlfCtrlDepth, imgOrg, imgDec, imgRest, imgUsed, stride, ruiDist, vAlfCUCtrlParam[0].alf_cu_flag); 5525 4013 #else 5526 4014 setCUAlfCtrlFlag(pcCU, 0, 0, uiAlfCtrlDepth, imgOrg, imgDec, imgRest, stride, ruiDist, vAlfCUCtrlParam[0].alf_cu_flag); 5527 #endif5528 #else5529 #if HHI_INTERVIEW_SKIP5530 xSetCUAlfCtrlFlag_qc(pcCU, 0, 0, uiAlfCtrlDepth, pcPicOrg, pcPicDec, pcPicRest,imgUsed, ruiDist, vAlfCUCtrlParam[0].alf_cu_flag);5531 #else5532 xSetCUAlfCtrlFlag_qc(pcCU, 0, 0, uiAlfCtrlDepth, pcPicOrg, pcPicDec, pcPicRest, ruiDist, vAlfCUCtrlParam[0].alf_cu_flag);5533 #endif5534 4015 #endif 5535 4016 } … … 5569 4050 } 5570 4051 5571 #if LCU_SYNTAX_ALF5572 4052 #if HHI_INTERVIEW_SKIP 5573 4053 Void TEncAdaptiveLoopFilter::setCUAlfCtrlFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiAlfCtrlDepth, Pel* imgOrg, Pel* imgDec, Pel* imgRest, Pel* imgUsed, Int stride, UInt64& ruiDist, std::vector<UInt>& vCUCtrlFlag) 5574 4054 #else 5575 4055 Void TEncAdaptiveLoopFilter::setCUAlfCtrlFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiAlfCtrlDepth, Pel* imgOrg, Pel* imgDec, Pel* imgRest, Int stride, UInt64& ruiDist, std::vector<UInt>& vCUCtrlFlag) 5576 #endif5577 #else5578 #if HHI_INTERVIEW_SKIP5579 Void TEncAdaptiveLoopFilter::xSetCUAlfCtrlFlag_qc(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiAlfCtrlDepth, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, TComPicYuv* pcUsedPelMap, UInt64& ruiDist, std::vector<UInt>& vCUCtrlFlag)5580 #else5581 Void TEncAdaptiveLoopFilter::xSetCUAlfCtrlFlag_qc(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiAlfCtrlDepth, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiDist, std::vector<UInt>& vCUCtrlFlag)5582 #endif5583 4056 #endif 5584 4057 { … … 5603 4076 5604 4077 if( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) 5605 #if LCU_SYNTAX_ALF5606 4078 #if HHI_INTERVIEW_SKIP 5607 4079 setCUAlfCtrlFlag(pcCU, uiAbsPartIdx, uiDepth+1, uiAlfCtrlDepth, imgOrg, imgDec, imgRest, imgUsed, stride, ruiDist, vCUCtrlFlag); … … 5609 4081 setCUAlfCtrlFlag(pcCU, uiAbsPartIdx, uiDepth+1, uiAlfCtrlDepth, imgOrg, imgDec, imgRest, stride, ruiDist, vCUCtrlFlag); 5610 4082 #endif 5611 #else5612 #if HHI_INTERVIEW_SKIP5613 xSetCUAlfCtrlFlag_qc(pcCU, uiAbsPartIdx, uiDepth+1, uiAlfCtrlDepth, pcPicOrg, pcPicDec, pcPicRest, imgUsed, ruiDist, vCUCtrlFlag);5614 #else5615 xSetCUAlfCtrlFlag_qc(pcCU, uiAbsPartIdx, uiDepth+1, uiAlfCtrlDepth, pcPicOrg, pcPicDec, pcPicRest, ruiDist, vCUCtrlFlag);5616 #endif5617 #endif5618 4083 } 5619 4084 return; … … 5624 4089 return; 5625 4090 } 5626 #if !LCU_SYNTAX_ALF5627 UInt uiCUAddr = pcCU->getAddr();5628 #endif5629 4091 UInt64 uiRecSSD = 0; 5630 4092 UInt64 uiFiltSSD = 0; … … 5661 4123 } 5662 4124 5663 #if LCU_SYNTAX_ALF5664 4125 Int offset = uiTPelY*stride + uiLPelX; 5665 4126 Pel* pOrg = imgOrg + offset; … … 5679 4140 uiFiltSSD += xCalcSSD( pOrg, pFilt, iWidth, iHeight, stride ); 5680 4141 #endif 5681 #else5682 Pel* pOrg = pcPicOrg->getLumaAddr(uiCUAddr, uiAbsPartIdx);5683 Pel* pRec = pcPicDec->getLumaAddr(uiCUAddr, uiAbsPartIdx);5684 Pel* pFilt = pcPicRest->getLumaAddr(uiCUAddr, uiAbsPartIdx);5685 5686 #if HHI_INTERVIEW_SKIP5687 Pel* pUsed = pcUsedPelMap->getLumaAddr(uiCUAddr, uiAbsPartIdx);5688 uiRecSSD += xCalcSSD( pOrg, pRec, pUsed, iWidth, iHeight, pcPicOrg->getStride() );5689 uiFiltSSD += xCalcSSD( pOrg, pFilt, pUsed, iWidth, iHeight, pcPicOrg->getStride() );5690 #else5691 uiRecSSD += xCalcSSD( pOrg, pRec, iWidth, iHeight, pcPicOrg->getStride() );5692 uiFiltSSD += xCalcSSD( pOrg, pFilt, iWidth, iHeight, pcPicOrg->getStride() );5693 #endif5694 #endif5695 4142 if (uiFiltSSD < uiRecSSD) 5696 4143 { … … 5699 4146 vCUCtrlFlag.push_back(1); 5700 4147 5701 #if LCU_SYNTAX_ALF5702 4148 for (int i=uiTPelY ;i<=min(uiBPelY,(unsigned int)(m_img_height-1)) ;i++) 5703 4149 { 5704 4150 for (int j=uiLPelX ;j<=min(uiRPelX,(unsigned int)(m_img_width-1)) ;j++) 5705 4151 { 5706 #else5707 for (int i=uiTPelY ;i<=min(uiBPelY,(unsigned int)(pcPicOrg->getHeight()-1)) ;i++)5708 {5709 for (int j=uiLPelX ;j<=min(uiRPelX,(unsigned int)(pcPicOrg->getWidth()-1)) ;j++)5710 {5711 #endif5712 4152 m_maskImg[i][j]=1; 5713 4153 } … … 5719 4159 pcCU->setAlfCtrlFlagSubParts(0, uiAbsPartIdx, uiSetDepth); 5720 4160 vCUCtrlFlag.push_back(0); 5721 #if LCU_SYNTAX_ALF5722 4161 for (int i=uiTPelY ;i<=min(uiBPelY,(unsigned int)(m_img_height-1)) ;i++) 5723 4162 { 5724 4163 for (int j=uiLPelX ;j<=min(uiRPelX,(unsigned int)(m_img_width-1)) ;j++) 5725 4164 { 5726 #else5727 for (int i=uiTPelY ;i<=min(uiBPelY,(unsigned int)(pcPicOrg->getHeight()-1)) ;i++)5728 {5729 for (int j=uiLPelX ;j<=min(uiRPelX,(unsigned int)(pcPicOrg->getWidth()-1)) ;j++)5730 {5731 #endif5732 4165 m_maskImg[i][j]=0; 5733 4166 } … … 5736 4169 } 5737 4170 5738 #if !LCU_SYNTAX_ALF5739 5740 Void TEncAdaptiveLoopFilter::xReDesignFilterCoeff_qc(TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, Bool bReadCorr)5741 {5742 Int tap = m_pcTempAlfParam->filter_shape;5743 Int LumaStride = pcPicOrg->getStride();5744 Pel* pOrg = pcPicOrg->getLumaAddr();5745 Pel* pDec = pcPicDec->getLumaAddr();5746 Pel* pRest = pcPicRest->getLumaAddr();5747 xFirstFilteringFrameLuma(pOrg, pDec, pRest, m_pcTempAlfParam, tap, LumaStride);5748 5749 if (m_iALFEncodePassReduction)5750 {5751 if(!m_iUsePreviousFilter)5752 {5753 saveFilterCoeffToBuffer(m_filterCoeffSym, m_pcTempAlfParam->filters_per_group, m_varIndTab, m_pcTempAlfParam->alf_pcr_region_flag, tap);5754 }5755 }5756 }5757 5758 Void TEncAdaptiveLoopFilter::xCUAdaptiveControl_qc(TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiMinRate, UInt64& ruiMinDist, Double& rdMinCost)5759 {5760 if(!m_bAlfCUCtrlEnabled) return;5761 Bool bChanged = false;5762 std::vector<AlfCUCtrlInfo> vAlfCUCtrlParamTemp(m_vBestAlfCUCtrlParam);5763 5764 Pel** maskImgTemp;5765 5766 if(m_iALFEncodePassReduction == 2)5767 {5768 initMatrix_Pel(&maskImgTemp, m_img_height, m_img_width);5769 }5770 5771 m_pcEntropyCoder->setAlfCtrl(true);5772 5773 UInt uiBestDepth = 0;5774 5775 ALFParam cFrmAlfParam;5776 allocALFParam(&cFrmAlfParam);5777 copyALFParam(&cFrmAlfParam, m_pcBestAlfParam);5778 5779 for (UInt uiDepth = 0; uiDepth < g_uiMaxCUDepth; uiDepth++)5780 {5781 m_pcEntropyCoder->setMaxAlfCtrlDepth(uiDepth);5782 pcPicRest->copyToPicLuma(m_pcPicYuvTmp);5783 copyALFParam(m_pcTempAlfParam, &cFrmAlfParam);5784 5785 for (UInt uiRD = 0; uiRD <= m_iALFNumOfRedesign; uiRD++)5786 {5787 if (uiRD)5788 {5789 // re-design filter coefficients5790 xReDesignFilterCoeff_qc(pcPicOrg, pcPicDec, m_pcPicYuvTmp, true); //use filtering of mine5791 }5792 5793 UInt64 uiRate, uiDist;5794 Double dCost;5795 //m_pcPicYuvTmp: filtered signal, pcPicDec: orig reconst5796 xSetCUAlfCtrlFlags_qc(uiDepth, pcPicOrg, pcPicDec, m_pcPicYuvTmp, uiDist, vAlfCUCtrlParamTemp);5797 xCalcRDCost(m_pcTempAlfParam, uiRate, uiDist, dCost, &vAlfCUCtrlParamTemp);5798 if (dCost < rdMinCost)5799 {5800 bChanged = true;5801 m_vBestAlfCUCtrlParam = vAlfCUCtrlParamTemp;5802 uiBestDepth = uiDepth;5803 rdMinCost = dCost;5804 ruiMinDist = uiDist;5805 ruiMinRate = uiRate;5806 m_pcPicYuvTmp->copyToPicLuma(m_pcPicYuvBest);5807 copyALFParam(m_pcBestAlfParam, m_pcTempAlfParam);5808 //save maskImg5809 xCopyTmpAlfCtrlFlagsFrom();5810 if(m_iALFEncodePassReduction == 2)5811 {5812 ::memcpy(maskImgTemp[0], m_maskImg[0], sizeof(Pel)*m_img_height* m_img_width);5813 }5814 }5815 }5816 }5817 5818 if(bChanged)5819 {5820 if(m_iALFEncodePassReduction == 2)5821 {5822 UInt uiDepth = uiBestDepth;5823 ::memcpy(m_maskImg[0], maskImgTemp[0], sizeof(Pel)*m_img_height* m_img_width);5824 xCopyTmpAlfCtrlFlagsTo();5825 5826 copyALFParam(&cFrmAlfParam, m_pcBestAlfParam);5827 5828 m_pcEntropyCoder->setAlfCtrl(true);5829 m_pcEntropyCoder->setMaxAlfCtrlDepth(uiDepth);5830 copyALFParam(m_pcTempAlfParam, &cFrmAlfParam);5831 5832 xReDesignFilterCoeff_qc(pcPicOrg, pcPicDec, m_pcPicYuvTmp, true); //use filtering of mine5833 5834 UInt64 uiRate, uiDist;5835 Double dCost;5836 xSetCUAlfCtrlFlags_qc(uiDepth, pcPicOrg, pcPicDec, m_pcPicYuvTmp, uiDist, vAlfCUCtrlParamTemp);5837 xCalcRDCost(m_pcTempAlfParam, uiRate, uiDist, dCost, &vAlfCUCtrlParamTemp);5838 if (dCost < rdMinCost)5839 {5840 rdMinCost = dCost;5841 ruiMinDist = uiDist;5842 ruiMinRate = uiRate;5843 m_pcPicYuvTmp->copyToPicLuma(m_pcPicYuvBest);5844 copyALFParam(m_pcBestAlfParam, m_pcTempAlfParam);5845 xCopyTmpAlfCtrlFlagsFrom();5846 m_vBestAlfCUCtrlParam = vAlfCUCtrlParamTemp;5847 }5848 }5849 5850 m_pcEntropyCoder->setAlfCtrl(true);5851 m_pcEntropyCoder->setMaxAlfCtrlDepth(uiBestDepth);5852 xCopyTmpAlfCtrlFlagsTo();5853 5854 m_pcPicYuvBest->copyToPicLuma(pcPicRest);//copy m_pcPicYuvBest to pcPicRest5855 xCopyDecToRestCUs(pcPicDec, pcPicRest); //pcPicRest = pcPicDec5856 }5857 else5858 {5859 m_pcEntropyCoder->setAlfCtrl(false);5860 m_pcEntropyCoder->setMaxAlfCtrlDepth(0);5861 }5862 freeALFParam(&cFrmAlfParam);5863 5864 if(m_iALFEncodePassReduction == 2)5865 {5866 destroyMatrix_Pel(maskImgTemp);5867 }5868 }5869 5870 #endif5871 4171 5872 4172 #define ROUND(a) (((a) < 0)? (int)((a) - 0.5) : (int)((a) + 0.5)) … … 6242 4542 { 6243 4543 double error; 6244 #if LCU _SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS4544 #if LCUALF_QP_DEPENDENT_BITS 6245 4545 Int factor = (1<<(getAlfPrecisionBit(m_alfQP))); 6246 4546 #else … … 6384 4684 } 6385 4685 6386 #if !LCU_SYNTAX_ALF6387 6388 /** Save redesigned filter set to buffer6389 * \param filterCoeffPrevSelected filter set buffer6390 */6391 Void TEncAdaptiveLoopFilter::saveFilterCoeffToBuffer(Int **filterSet, Int numFilter, Int* mergeTable, Int mode, Int filtNo)6392 {6393 Int iBufferIndex = m_iCurrentPOC % m_iGOPSize;6394 6395 static Bool bFirst = true;6396 static Bool* pbFirstAccess;6397 if(bFirst)6398 {6399 pbFirstAccess = new Bool[NUM_ALF_CLASS_METHOD];6400 for(Int i=0; i< NUM_ALF_CLASS_METHOD; i++)6401 {6402 pbFirstAccess[i]= true;6403 }6404 bFirst = false;6405 }6406 6407 if(iBufferIndex == 0)6408 {6409 if(pbFirstAccess[mode])6410 {6411 //store merge table6412 ::memcpy(m_mergeTableSavedMethods[mode][m_iGOPSize], mergeTable, sizeof(Int)*NO_VAR_BINS);6413 //store coefficients6414 for(Int varInd=0; varInd< numFilter; varInd++)6415 {6416 ::memcpy(m_aiFilterCoeffSavedMethods[mode][m_iGOPSize][varInd],filterSet[varInd], sizeof(Int)*ALF_MAX_NUM_COEF );6417 }6418 //store filter shape6419 m_iPreviousFilterShapeMethods[mode][m_iGOPSize]= filtNo;6420 6421 pbFirstAccess[mode] = false;6422 }6423 6424 6425 //store merge table6426 ::memcpy(m_mergeTableSavedMethods[mode][0 ], m_mergeTableSavedMethods[mode][m_iGOPSize], sizeof(Int)*NO_VAR_BINS);6427 ::memcpy(m_mergeTableSavedMethods[mode][m_iGOPSize], mergeTable, sizeof(Int)*NO_VAR_BINS);6428 6429 //store coefficients6430 for(Int varInd=0; varInd< NO_VAR_BINS; varInd++)6431 {6432 ::memcpy(m_aiFilterCoeffSavedMethods[mode][0][varInd],m_aiFilterCoeffSavedMethods[mode][m_iGOPSize][varInd], sizeof(Int)*ALF_MAX_NUM_COEF );6433 }6434 6435 for(Int varInd=0; varInd< numFilter; varInd++)6436 {6437 ::memcpy(m_aiFilterCoeffSavedMethods[mode][m_iGOPSize][varInd],filterSet[varInd], sizeof(Int)*ALF_MAX_NUM_COEF );6438 }6439 6440 //store filter shape6441 m_iPreviousFilterShapeMethods[mode][0]= m_iPreviousFilterShapeMethods[mode][m_iGOPSize];6442 m_iPreviousFilterShapeMethods[mode][m_iGOPSize]= filtNo;6443 }6444 else6445 {6446 6447 //store merge table6448 ::memcpy(m_mergeTableSavedMethods[mode][iBufferIndex], mergeTable, sizeof(Int)*NO_VAR_BINS);6449 6450 //store coefficients6451 for(Int varInd=0; varInd< numFilter; varInd++)6452 {6453 ::memcpy(m_aiFilterCoeffSavedMethods[mode][iBufferIndex][varInd],filterSet[varInd], sizeof(Int)*ALF_MAX_NUM_COEF );6454 }6455 //store filter_shape6456 m_iPreviousFilterShapeMethods[mode][iBufferIndex]= filtNo;6457 6458 }6459 }6460 6461 6462 /** set initial m_maskImg with previous (time-delayed) filters6463 * \param pcPicOrg original picture6464 * \param pcPicDec reconstructed picture after deblocking6465 */6466 Void TEncAdaptiveLoopFilter::setMaskWithTimeDelayedResults(TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec)6467 {6468 6469 static Pel** bestImgMask;6470 static Bool bFirst = true;6471 if(bFirst)6472 {6473 initMatrix_Pel(&bestImgMask, m_img_height, m_img_width);6474 bFirst = false;6475 }6476 6477 Pel* pDec = pcPicDec->getLumaAddr();6478 Pel* pOrg = pcPicOrg->getLumaAddr();6479 Pel* pRest = m_pcPicYuvTmp->getLumaAddr();6480 Int LumaStride = pcPicOrg->getStride();6481 Int*** pppCoeffSaved = m_aiFilterCoeffSavedMethods [m_uiVarGenMethod];6482 Int** ppMergeTableSaved = m_mergeTableSavedMethods [m_uiVarGenMethod];6483 Int* pFilterShapeSaved = m_iPreviousFilterShapeMethods[m_uiVarGenMethod];6484 Int iBufIdx;6485 6486 UInt64 uiRate, uiDist;6487 Double dCost, dMinCost = MAX_DOUBLE;6488 ALFParam cAlfParam;6489 allocALFParam(&cAlfParam);6490 cAlfParam.alf_flag = 0;6491 cAlfParam.chroma_idc = 0;6492 6493 //filter frame with the previous time-delayed filters6494 Int filtNo;6495 Int maxDepth = (pcPicOrg->getWidth() < 1000) ?(2):(g_uiMaxCUDepth);6496 m_pcEntropyCoder->setAlfCtrl(true);6497 m_pcTempAlfParam->alf_flag = 1;6498 m_pcTempAlfParam->alf_pcr_region_flag = m_uiVarGenMethod;6499 6500 for (Int index=0; index<2; index++)6501 {6502 iBufIdx = setFilterIdx(index);6503 filtNo = m_pcTempAlfParam->filter_shape = pFilterShapeSaved[iBufIdx];6504 #if ALF_SINGLE_FILTER_SHAPE6505 assert(filtNo == ALF_CROSS9x7_SQUARE3x3);6506 #else6507 assert(filtNo == ALF_STAR5x5 || filtNo == ALF_CROSS9x9);6508 #endif6509 m_pcTempAlfParam->num_coeff = m_sqrFiltLengthTab[filtNo];6510 if(!m_bUseNonCrossALF)6511 {6512 filterLuma(pRest, pDec, LumaStride, 0, m_img_height-1, 0, m_img_width-1, filtNo, pppCoeffSaved[iBufIdx], ppMergeTableSaved[iBufIdx], m_varImg);6513 }6514 else6515 {6516 xfilterSlicesEncoder(pDec, pRest, LumaStride, filtNo, pppCoeffSaved[iBufIdx], ppMergeTableSaved[iBufIdx], m_varImg);6517 }6518 6519 for (UInt uiDepth = 0; uiDepth < maxDepth; uiDepth++)6520 {6521 m_pcEntropyCoder->setMaxAlfCtrlDepth(uiDepth);6522 std::vector<AlfCUCtrlInfo> vAlfCUCtrlParamTemp(m_uiNumSlicesInPic);6523 xSetCUAlfCtrlFlags_qc(uiDepth, pcPicOrg, pcPicDec, m_pcPicYuvTmp, uiDist, vAlfCUCtrlParamTemp);6524 m_pcEntropyCoder->resetEntropy();6525 m_pcEntropyCoder->resetBits();6526 xEncodeCUAlfCtrlFlags(vAlfCUCtrlParamTemp);6527 uiRate = m_pcEntropyCoder->getNumberOfWrittenBits();6528 dCost = (Double)(uiRate) * m_dLambdaLuma + (Double)(uiDist);6529 6530 if (dCost < dMinCost)6531 {6532 dMinCost = dCost;6533 copyALFParam(&cAlfParam, m_pcTempAlfParam);6534 ::memcpy(bestImgMask[0], m_maskImg[0], sizeof(Pel)*m_img_height* m_img_width);6535 }6536 }6537 }6538 filtNo = cAlfParam.filter_shape;6539 6540 6541 ::memcpy(m_maskImg[0], bestImgMask[0], sizeof(Pel)*m_img_height* m_img_width);6542 6543 m_pcEntropyCoder->setAlfCtrl(false);6544 m_pcEntropyCoder->setMaxAlfCtrlDepth(0);6545 6546 // generate filters for future reference6547 m_iDesignCurrentFilter = 0;6548 6549 int filters_per_fr;6550 int lambda_val = (Int)m_dLambdaLuma;6551 6552 lambda_val = lambda_val * (1<<(2*g_uiBitIncrement));6553 6554 if(!m_bUseNonCrossALF)6555 {6556 xstoreInBlockMatrix(0, 0, m_img_height, m_img_width, true, true, pOrg, pDec, cAlfParam.filter_shape, LumaStride);6557 }6558 else6559 {6560 xstoreInBlockMatrixforSlices(pOrg, pDec, cAlfParam.filter_shape, LumaStride);6561 }6562 xfindBestFilterVarPred(m_yGlobalSym[filtNo], m_EGlobalSym[filtNo], m_pixAcc,6563 m_filterCoeffSym, m_filterCoeffSymQuant,6564 filtNo, &filters_per_fr,6565 m_varIndTab, NULL, m_varImg, m_maskImg, NULL, lambda_val);6566 6567 saveFilterCoeffToBuffer(m_filterCoeffSym, filters_per_fr, m_varIndTab, cAlfParam.alf_pcr_region_flag, filtNo);6568 m_iDesignCurrentFilter = 1;6569 6570 freeALFParam(&cAlfParam);6571 6572 }6573 6574 6575 /** set ALF encoding parameters6576 * \param pcPic picture pointer6577 */6578 Void TEncAdaptiveLoopFilter::setALFEncodingParam(TComPic *pcPic)6579 {6580 if(m_iALFEncodePassReduction)6581 {6582 m_iALFNumOfRedesign = 0;6583 m_iCurrentPOC = m_pcPic->getPOC();6584 if((pcPic->getSlice(0)->getSliceType() == I_SLICE) || (m_iGOPSize==8 && (m_iCurrentPOC % 4 == 0)))6585 {6586 m_iUsePreviousFilter = 0;6587 }6588 else6589 {6590 m_iUsePreviousFilter = 1;6591 }6592 }6593 else6594 {6595 m_iALFNumOfRedesign = ALF_NUM_OF_REDESIGN;6596 }6597 m_iDesignCurrentFilter = 1;6598 6599 }6600 6601 /** set filter buffer index6602 * \param index the processing order of time-delayed filtering6603 */6604 Int TEncAdaptiveLoopFilter::setFilterIdx(Int index)6605 {6606 Int iBufIdx;6607 6608 if (m_iGOPSize == 8)6609 {6610 switch(m_iCurrentPOC % m_iGOPSize)6611 {6612 case 0:6613 {6614 iBufIdx = (index == 0)?0:m_iGOPSize;6615 }6616 break;6617 case 1:6618 {6619 iBufIdx = (index == 0)?0:2;6620 }6621 break;6622 case 2:6623 {6624 iBufIdx = (index == 0)?0:4;6625 }6626 break;6627 case 3:6628 {6629 iBufIdx = (index == 0)?2:4;6630 }6631 break;6632 case 4:6633 {6634 iBufIdx = (index == 0)?0:m_iGOPSize;6635 }6636 break;6637 case 5:6638 {6639 iBufIdx = (index == 0)?4:6;6640 }6641 break;6642 case 6:6643 {6644 iBufIdx = (index == 0)?4:m_iGOPSize;6645 }6646 break;6647 case 7:6648 {6649 iBufIdx = (index == 0)?6:m_iGOPSize;6650 }6651 break;6652 default:6653 {6654 printf("error\n");6655 assert(0);6656 }6657 }6658 }6659 else6660 {6661 iBufIdx = (index == 0)?0:m_iGOPSize;6662 }6663 6664 return iBufIdx;6665 }6666 6667 6668 /** set initial m_maskImg6669 * \param pcPicOrg original picture pointer6670 * \param pcPicDec reconstructed picture pointer6671 */6672 Void TEncAdaptiveLoopFilter::setInitialMask(TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec)6673 {6674 Int Height = pcPicOrg->getHeight();6675 Int Width = pcPicOrg->getWidth();6676 Int LumaStride = pcPicOrg->getStride();6677 Pel* pDec = pcPicDec->getLumaAddr();6678 6679 calcVar(m_varImg, pDec, LumaStride, m_uiVarGenMethod);6680 6681 if(!m_iALFEncodePassReduction || !m_iUsePreviousFilter)6682 {6683 for(Int y=0; y<Height; y++)6684 {6685 for(Int x=0; x<Width; x++)6686 {6687 m_maskImg[y][x] = 1;6688 }6689 }6690 }6691 else6692 {6693 setMaskWithTimeDelayedResults(pcPicOrg, pcPicDec);6694 }6695 }6696 6697 6698 6699 /** Estimate RD cost of all filter size & store the best one6700 * \param ImgOrg original picture6701 * \param ImgDec reconstructed picture after deblocking6702 * \param Sride line buffer size of picture buffer6703 * \param pcAlfSaved the best Alf parameters6704 * \returns ruiDist estimated distortion6705 * \returns ruiRate required bits6706 * \returns rdCost estimated R-D cost6707 */6708 6709 Void TEncAdaptiveLoopFilter::decideFilterShapeLuma(Pel* ImgOrg, Pel* ImgDec, Int Stride, ALFParam* pcAlfSaved, UInt64& ruiRate, UInt64& ruiDist, Double& rdCost)6710 {6711 static Double **ySym, ***ESym;6712 Int lambda_val = ((Int) m_dLambdaLuma) * (1<<(2*g_uiBitIncrement));6713 Int filtNo, filters_per_fr;6714 Int64 iEstimatedDist;6715 UInt64 uiRate;6716 Double dEstimatedCost, dEstimatedMinCost = MAX_DOUBLE;;6717 6718 UInt uiBitShift = (g_uiBitIncrement<<1);6719 Int64 iEstimateDistBeforeFilter;6720 Int* coeffNoFilter[NUM_ALF_FILTER_SHAPE][NO_VAR_BINS];6721 for(Int filter_shape = 0; filter_shape < NUM_ALF_FILTER_SHAPE; filter_shape++)6722 {6723 for(Int i=0; i< NO_VAR_BINS; i++)6724 {6725 coeffNoFilter[filter_shape][i]= new Int[ALF_MAX_NUM_COEF];6726 ::memset(coeffNoFilter[filter_shape][i], 0, sizeof(Int)*ALF_MAX_NUM_COEF);6727 coeffNoFilter[filter_shape][i][ m_sqrFiltLengthTab[filter_shape]-1 ] = (1 << ((Int)ALF_NUM_BIT_SHIFT));6728 }6729 }6730 6731 m_pcTempAlfParam->alf_flag = 1;6732 m_pcTempAlfParam->chroma_idc = 0;6733 m_pcTempAlfParam->alf_pcr_region_flag = m_uiVarGenMethod;6734 6735 for (int filter_shape = 0; filter_shape < NUM_ALF_FILTER_SHAPE ;filter_shape ++)6736 {6737 m_pcTempAlfParam->filter_shape = filtNo = filter_shape;6738 m_pcTempAlfParam->num_coeff = m_sqrFiltLengthTab[filtNo] ;6739 6740 ESym = m_EGlobalSym [filtNo];6741 ySym = m_yGlobalSym [filtNo];6742 6743 if(!m_bUseNonCrossALF)6744 {6745 xstoreInBlockMatrix(0, 0, m_img_height, m_img_width, true, true, ImgOrg, ImgDec, filter_shape, Stride);6746 }6747 else6748 {6749 xstoreInBlockMatrixforSlices(ImgOrg, ImgDec, filter_shape, Stride);6750 }6751 xfindBestFilterVarPred(ySym, ESym, m_pixAcc, m_filterCoeffSym, m_filterCoeffSymQuant, filtNo, &filters_per_fr, m_varIndTab, NULL, m_varImg, m_maskImg, NULL, lambda_val);6752 6753 //estimate R-D cost6754 uiRate = xcodeFiltCoeff(m_filterCoeffSymQuant, filtNo, m_varIndTab, filters_per_fr, m_pcTempAlfParam);6755 iEstimatedDist = xEstimateFiltDist(filters_per_fr, m_varIndTab, ESym, ySym, m_filterCoeffSym, m_pcTempAlfParam->num_coeff);6756 iEstimateDistBeforeFilter = xEstimateFiltDist(filters_per_fr, m_varIndTab, ESym, ySym, coeffNoFilter[filter_shape], m_pcTempAlfParam->num_coeff);6757 iEstimatedDist -= iEstimateDistBeforeFilter;6758 dEstimatedCost = (Double)(uiRate) * m_dLambdaLuma + (Double)(iEstimatedDist);6759 6760 if(dEstimatedCost < dEstimatedMinCost)6761 {6762 dEstimatedMinCost = dEstimatedCost;6763 copyALFParam(pcAlfSaved, m_pcTempAlfParam);6764 iEstimatedDist += iEstimateDistBeforeFilter;6765 6766 for(Int i=0; i< filters_per_fr; i++ )6767 {6768 iEstimatedDist += (((Int64)m_pixAcc_merged[i]) >> uiBitShift);6769 }6770 ruiDist = (iEstimatedDist > 0)?((UInt64)iEstimatedDist):(0);6771 rdCost = dEstimatedMinCost + (Double)(ruiDist);6772 ruiRate = uiRate;6773 }6774 }6775 6776 if (!m_iUsePreviousFilter)6777 {6778 decodeFilterSet(pcAlfSaved, m_varIndTab, m_filterCoeffSym);6779 saveFilterCoeffToBuffer(m_filterCoeffSym, pcAlfSaved->filters_per_group, m_varIndTab, pcAlfSaved->alf_pcr_region_flag, pcAlfSaved->filter_shape);6780 }6781 6782 if( m_iUsePreviousFilter )6783 {6784 UInt64 uiOffRegionDistortion = 0;6785 Int iPelDiff;6786 Pel* pOrgTemp = (Pel*)ImgOrg;6787 Pel* pDecTemp = (Pel*)ImgDec;6788 for(Int y=0; y< m_img_height; y++)6789 {6790 for(Int x=0; x< m_img_width; x++)6791 {6792 if(m_maskImg[y][x] == 0)6793 {6794 iPelDiff = pOrgTemp[x] - pDecTemp[x];6795 uiOffRegionDistortion += (UInt64)( (iPelDiff*iPelDiff) >> uiBitShift );6796 }6797 }6798 pOrgTemp += Stride;6799 pDecTemp += Stride;6800 6801 ruiDist += uiOffRegionDistortion;6802 rdCost += (Double)uiOffRegionDistortion;6803 }6804 }6805 6806 #if !ALF_SINGLE_FILTER_SHAPE6807 // if ALF_STAR5x5 is selected, the distortion of 2 skipped lines per LCU should be added.6808 if(pcAlfSaved->filter_shape == ALF_STAR5x5)6809 {6810 Int iPelDiff;6811 UInt64 uiSkipPelsDistortion = 0;6812 Pel *pOrgTemp, *pDecTemp;6813 for(Int y= m_lineIdxPadTop-1; y< m_img_height - m_lcuHeight ; y += m_lcuHeight)6814 {6815 pOrgTemp = ImgOrg + y*Stride;6816 pDecTemp = ImgDec + y*Stride;6817 for(Int x=0; x< m_img_width; x++)6818 {6819 if(m_maskImg[y][x] == 1)6820 {6821 iPelDiff = pOrgTemp[x] - pDecTemp[x];6822 uiSkipPelsDistortion += (UInt64)( (iPelDiff*iPelDiff) >> uiBitShift );6823 }6824 }6825 6826 pOrgTemp += Stride;6827 pDecTemp += Stride;6828 for(Int x=0; x< m_img_width; x++)6829 {6830 if(m_maskImg[y+1][x] == 1)6831 {6832 iPelDiff = pOrgTemp[x] - pDecTemp[x];6833 uiSkipPelsDistortion += (UInt64)( (iPelDiff*iPelDiff) >> uiBitShift );6834 }6835 }6836 }6837 ruiDist += uiSkipPelsDistortion;6838 rdCost += (Double)uiSkipPelsDistortion;6839 }6840 #endif6841 6842 for(Int filter_shape = 0; filter_shape < NUM_ALF_FILTER_SHAPE; filter_shape++)6843 {6844 for(Int i=0; i< NO_VAR_BINS; i++)6845 {6846 delete[] coeffNoFilter[filter_shape][i];6847 }6848 }6849 }6850 6851 6852 #endif6853 4686 6854 4687 /** Estimate filtering distortion by correlation values and filter coefficients … … 6867 4700 Int64 iDist; 6868 4701 Double dDist, dsum; 6869 #if LCU _SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS4702 #if LCUALF_QP_DEPENDENT_BITS 6870 4703 Int alfPrecisionBit = getAlfPrecisionBit( m_alfQP ); 6871 4704 #endif … … 6873 4706 for(i=0; i< iFiltLength; i++) 6874 4707 { 6875 #if LCU _SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS4708 #if LCUALF_QP_DEPENDENT_BITS 6876 4709 pdcoeff[i]= (Double)piCoeff[i] / (Double)(1<<alfPrecisionBit); 6877 4710 #else … … 6908 4741 6909 4742 6910 #if !LCU_SYNTAX_ALF6911 6912 /** Estimate total filtering cost of all groups6913 * \param filters_per_fr number of filters for the slice6914 * \param VarIndTab merge index of all groups6915 * \param pppdE auto-correlation matrix pointer for all groups6916 * \param ppdy cross-correlation array pointer for all groups6917 * \returns estimated distortion6918 */6919 Int64 TEncAdaptiveLoopFilter::xEstimateFiltDist(Int filters_per_fr, Int* VarIndTab,6920 Double*** pppdE, Double** ppdy,6921 Int** ppiCoeffSet, Int iFiltLength)6922 6923 {6924 Int64 iDist;6925 Double** ppdDstE;6926 Double** ppdSrcE;6927 Double* pdDsty;6928 Double* pdSrcy;6929 Int f, j, i, varInd;6930 Int* piCoeff;6931 6932 //clean m_E_merged & m_y_merged6933 for(f=0; f< filters_per_fr; f++)6934 {6935 for(j =0; j < iFiltLength; j++)6936 {6937 //clean m_E_merged one line6938 for(i=0; i < iFiltLength; i++)6939 {6940 m_E_merged[f][j][i] = 0;6941 }6942 6943 //clean m_y_merged6944 m_y_merged[f][j] = 0;6945 }6946 m_pixAcc_merged[f] = 0;6947 }6948 6949 6950 //merge correlation values6951 for (varInd=0; varInd< NO_VAR_BINS; varInd++)6952 {6953 ppdSrcE = pppdE[varInd];6954 ppdDstE = m_E_merged[ VarIndTab[varInd] ];6955 6956 pdSrcy = ppdy[varInd];6957 pdDsty = m_y_merged[ VarIndTab[varInd] ];6958 6959 for(j=0; j< iFiltLength; j++)6960 {6961 for(i=0; i< iFiltLength; i++)6962 {6963 ppdDstE[j][i] += ppdSrcE[j][i];6964 }6965 6966 pdDsty[j] += pdSrcy[j];6967 }6968 m_pixAcc_merged[ VarIndTab[varInd] ] += m_pixAcc[varInd];6969 6970 }6971 6972 //estimate distortion reduction by using FFDE (JCTVC-C143)6973 iDist = 0;6974 for(f=0; f< filters_per_fr; f++)6975 {6976 piCoeff = ppiCoeffSet[f];6977 ppdDstE = m_E_merged [f];6978 pdDsty = m_y_merged [f];6979 6980 iDist += xFastFiltDistEstimation(ppdDstE, pdDsty, piCoeff, iFiltLength);6981 }6982 6983 6984 return iDist;6985 6986 }6987 6988 /** Calculate ALF grouping indices for ALF slices6989 * \param varmap grouping indices buffer6990 * \param imgY_Dec picture buffer6991 * \param pad_size (max. filter tap)/26992 * \param fl VAR_SIZE6993 * \param img_stride picture buffer stride6994 */6995 Void TEncAdaptiveLoopFilter::xfilterSlicesEncoder(Pel* ImgDec, Pel* ImgRest, Int iStride, Int filtNo, Int** filterCoeff, Int* mergeTable, Pel** varImg)6996 {6997 Pel* pPicSrc = (Pel *)ImgDec;6998 Pel* pPicSlice = m_pcSliceYuvTmp->getLumaAddr();6999 7000 for(UInt s=0; s< m_uiNumSlicesInPic; s++)7001 {7002 if(!m_pcPic->getValidSlice(s))7003 {7004 continue;7005 }7006 std::vector< std::vector<AlfLCUInfo*> > & vpSliceTileAlfLCU = m_pvpSliceTileAlfLCU[s];7007 7008 for(Int t=0; t< (Int)vpSliceTileAlfLCU.size(); t++)7009 {7010 std::vector<AlfLCUInfo*> & vpAlfLCU = vpSliceTileAlfLCU[t];7011 copyRegion(vpAlfLCU, pPicSlice, pPicSrc, iStride);7012 extendRegionBorder(vpAlfLCU, pPicSlice, iStride);7013 filterLumaRegion(vpAlfLCU, pPicSlice, ImgRest, iStride, filtNo, filterCoeff, mergeTable, varImg);7014 }7015 }7016 }7017 7018 /** Calculate block autocorrelations and crosscorrelations for ALF slices7019 * \param ImgOrg original picture7020 * \param ImgDec picture before filtering7021 * \param tap filter tap size7022 * \param iStride picture buffer stride7023 */7024 Void TEncAdaptiveLoopFilter::xstoreInBlockMatrixforSlices(Pel* ImgOrg, Pel* ImgDec, Int tap, Int iStride)7025 {7026 Pel* pPicSrc = (Pel *)ImgDec;7027 Pel* pPicSlice = m_pcSliceYuvTmp->getLumaAddr();7028 7029 UInt iLastValidSliceID =0;7030 for(UInt s=0; s< m_uiNumSlicesInPic; s++)7031 {7032 if(m_pcPic->getValidSlice(s))7033 {7034 iLastValidSliceID = s;7035 }7036 }7037 7038 for(UInt s=0; s<= iLastValidSliceID; s++)7039 {7040 if(!m_pcPic->getValidSlice(s))7041 {7042 continue;7043 }7044 std::vector< std::vector<AlfLCUInfo*> > & vpSliceTileAlfLCU = m_pvpSliceTileAlfLCU[s];7045 Int numValidTilesInSlice = (Int)vpSliceTileAlfLCU.size();7046 for(Int t=0; t< numValidTilesInSlice; t++)7047 {7048 std::vector<AlfLCUInfo*> & vpAlfLCU = vpSliceTileAlfLCU[t];7049 copyRegion(vpAlfLCU, pPicSlice, pPicSrc, iStride);7050 extendRegionBorder(vpAlfLCU, pPicSlice, iStride);7051 xstoreInBlockMatrixforRegion(vpAlfLCU, ImgOrg, pPicSlice, tap, iStride, (s==0)&&(t==0), (s== iLastValidSliceID)&&(t==numValidTilesInSlice-1));7052 }7053 }7054 }7055 7056 /** Calculate block autocorrelations and crosscorrelations for one ALF region7057 * \param vpAlfLCU ALF LCU data container7058 * \param ImgOrg original picture7059 * \param ImgDec picture before filtering7060 * \param tap filter tap size7061 * \param iStride picture buffer stride7062 * \param bFirstSlice true for the first processing slice of the picture7063 * \param bLastSlice true for the last processing slice of the picture7064 */7065 Void TEncAdaptiveLoopFilter::xstoreInBlockMatrixforRegion(std::vector< AlfLCUInfo* > &vpAlfLCU,7066 Pel* ImgOrg, Pel* ImgDec,7067 Int tap, Int iStride,7068 Bool bFirstSlice,7069 Bool bLastSlice7070 )7071 {7072 7073 UInt uiNumLCUs = (UInt)vpAlfLCU.size();7074 Int iHeight, iWidth;7075 Int ypos, xpos;7076 Bool bFirstLCU, bLastLCU;7077 Bool bFirstSGU, bLastSGU;7078 UInt numSGUs;7079 7080 for(UInt i=0; i< uiNumLCUs; i++)7081 {7082 bFirstLCU = (i==0);7083 bLastLCU = (i== uiNumLCUs -1);7084 AlfLCUInfo& cAlfLCU = *(vpAlfLCU[i]);7085 numSGUs = cAlfLCU.numSGU;7086 for(UInt j=0; j< numSGUs; j++)7087 {7088 bFirstSGU= (j ==0);7089 bLastSGU = (j == numSGUs -1);7090 7091 ypos = (Int)(cAlfLCU[j].posY );7092 xpos = (Int)(cAlfLCU[j].posX );7093 iHeight = (Int)(cAlfLCU[j].height);7094 iWidth = (Int)(cAlfLCU[j].width );7095 7096 xstoreInBlockMatrix(ypos, xpos, iHeight, iWidth,7097 (bFirstSlice && bFirstLCU && bFirstSGU),(bLastSlice && bLastLCU && bLastSGU),7098 ImgOrg, ImgDec,tap, iStride);7099 }7100 }7101 }7102 7103 7104 /** Calculate autocorrelations and crosscorrelations for chroma slices7105 * \param ComponentID Cb or Cr7106 * \param pOrg original picture7107 * \param pCmp picture before filtering7108 * \param iTap filter tap size7109 * \param iOrgStride picture buffer stride for pOrg7110 * \param iCmpStride picture buffer stride for pCmp7111 */7112 Void TEncAdaptiveLoopFilter::xCalcCorrelationFuncforChromaSlices(Int ComponentID, Pel* pOrg, Pel* pCmp, Int iTap, Int iOrgStride, Int iCmpStride)7113 {7114 7115 assert(iOrgStride == iCmpStride);7116 7117 Pel* pPicSrc = pCmp;7118 Pel* pPicSlice = (ComponentID == ALF_Cb)?(m_pcSliceYuvTmp->getCbAddr()):(m_pcSliceYuvTmp->getCrAddr());7119 Int chromaFormatShift = 1;7120 7121 UInt iLastValidSliceID =0;7122 for(UInt s=0; s< m_uiNumSlicesInPic; s++)7123 {7124 if(m_pcPic->getValidSlice(s))7125 {7126 iLastValidSliceID = s;7127 }7128 }7129 7130 for(UInt s=0; s<= iLastValidSliceID; s++)7131 {7132 if(!m_pcPic->getValidSlice(s))7133 {7134 continue;7135 }7136 std::vector< std::vector<AlfLCUInfo*> > & vpSliceTileAlfLCU = m_pvpSliceTileAlfLCU[s];7137 Int numValidTilesInSlice = (Int)vpSliceTileAlfLCU.size();7138 for(Int t=0; t< numValidTilesInSlice; t++)7139 {7140 std::vector<AlfLCUInfo*> & vpAlfLCU = vpSliceTileAlfLCU[t];7141 copyRegion(vpAlfLCU, pPicSlice, pPicSrc, iCmpStride, chromaFormatShift);7142 extendRegionBorder(vpAlfLCU, pPicSlice, iCmpStride, chromaFormatShift);7143 xCalcCorrelationFuncforChromaRegion(vpAlfLCU, pOrg, pPicSlice, iTap, iCmpStride,(s== iLastValidSliceID)&&(t== numValidTilesInSlice-1), chromaFormatShift);7144 }7145 }7146 }7147 7148 /** Calculate autocorrelations and crosscorrelations for one chroma slice7149 * \param vpAlfLCU ALF LCU data container7150 * \param pOrg original picture7151 * \param pCmp picture before filtering7152 * \param iTap filter tap size7153 * \param iStride picture buffer stride7154 * \param bLastSlice the last processing slice of picture7155 */7156 Void TEncAdaptiveLoopFilter::xCalcCorrelationFuncforChromaRegion(std::vector< AlfLCUInfo* > &vpAlfLCU, Pel* pOrg, Pel* pCmp, Int filtNo, Int iStride, Bool bLastSlice, Int iFormatShift)7157 {7158 UInt uiNumLCUs = (UInt)vpAlfLCU.size();7159 7160 Int iHeight, iWidth;7161 Int ypos, xpos;7162 Bool bLastLCU;7163 Bool bLastSGU;7164 UInt numSGUs;7165 7166 for(UInt i=0; i< uiNumLCUs; i++)7167 {7168 bLastLCU = (i== uiNumLCUs -1);7169 7170 AlfLCUInfo& cAlfLCU = *(vpAlfLCU[i]);7171 numSGUs = cAlfLCU.numSGU;7172 for(UInt j=0; j< numSGUs; j++)7173 {7174 bLastSGU = (j == numSGUs -1);7175 ypos = (Int)(cAlfLCU[j].posY >> iFormatShift);7176 xpos = (Int)(cAlfLCU[j].posX >> iFormatShift);7177 iHeight = (Int)(cAlfLCU[j].height >> iFormatShift);7178 iWidth = (Int)(cAlfLCU[j].width >> iFormatShift);7179 xCalcCorrelationFunc(ypos, xpos, pOrg, pCmp, filtNo, iWidth, iHeight, iStride, iStride, (bLastSlice && bLastLCU && bLastSGU) );7180 }7181 }7182 }7183 7184 // ====================================================================================================================7185 // Protected member functions7186 // ====================================================================================================================7187 7188 Void TEncAdaptiveLoopFilter::xFilterTapDecisionChroma( UInt64 uiLumaRate, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiDist, UInt64& ruiBits )7189 {7190 Int iShape, num_coeff;7191 Int64 iOrgDistCb, iOrgDistCr, iFiltDistCb, iFiltDistCr, iDist;7192 Bool bChanged = false;7193 Int* qh = m_pcTempAlfParam->coeff_chroma;7194 7195 UInt64 uiMinRate = uiLumaRate;7196 UInt64 uiMinDist = MAX_INT;7197 Double dMinCost = MAX_DOUBLE;7198 Double dLocalMinCost = MAX_DOUBLE;7199 7200 copyALFParam(m_pcTempAlfParam, m_pcBestAlfParam);7201 xCalcRDCostChroma(pcPicOrg, pcPicRest, m_pcTempAlfParam, uiMinRate, uiMinDist, dMinCost);7202 7203 #if ALF_SINGLE_FILTER_SHAPE7204 iShape = 0;7205 #else7206 for(iShape = 0; iShape < 2; iShape++)7207 #endif7208 {7209 // set global variables7210 num_coeff = m_sqrFiltLengthTab[iShape];7211 m_pcTempAlfParam->chroma_idc = 3;7212 m_pcTempAlfParam->filter_shape_chroma = iShape;7213 m_pcTempAlfParam->num_coeff_chroma = num_coeff;7214 7215 // keep original corr pointer7216 Double **ppdTmpCorr = m_ppdAlfCorr;7217 7218 // calc Cb matrix7219 m_pcTempAlfParam->chroma_idc = 2;7220 m_ppdAlfCorr = m_ppdAlfCorrCb;7221 for(Int i=0; i<ALF_MAX_NUM_COEF; i++)7222 {7223 ::memset(m_ppdAlfCorr[i], 0, sizeof(Double) * (ALF_MAX_NUM_COEF + 1));7224 }7225 Pel *pOrg = pcPicOrg->getCbAddr();7226 Pel *pCmp = pcPicDec->getCbAddr();7227 if(!m_bUseNonCrossALF)7228 {7229 xCalcCorrelationFunc(0, 0, pOrg, pCmp, iShape, (pcPicOrg->getWidth()>>1), (pcPicOrg->getHeight()>>1), pcPicOrg->getCStride(), pcPicDec->getCStride(), true);7230 }7231 else7232 {7233 xCalcCorrelationFuncforChromaSlices(ALF_Cb, pOrg, pCmp, iShape, pcPicOrg->getCStride(), pcPicDec->getCStride());7234 }7235 7236 // calc Cr matrix7237 m_pcTempAlfParam->chroma_idc = 1;7238 m_ppdAlfCorr = m_ppdAlfCorrCr;7239 for(Int i=0; i<ALF_MAX_NUM_COEF; i++)7240 {7241 ::memset(m_ppdAlfCorr[i], 0, sizeof(Double) * (ALF_MAX_NUM_COEF + 1));7242 }7243 pOrg = pcPicOrg->getCrAddr();7244 pCmp = pcPicDec->getCrAddr();7245 if(!m_bUseNonCrossALF)7246 {7247 xCalcCorrelationFunc(0, 0, pOrg, pCmp, iShape, (pcPicOrg->getWidth()>>1), (pcPicOrg->getHeight()>>1), pcPicOrg->getCStride(), pcPicDec->getCStride(), true);7248 }7249 else7250 {7251 xCalcCorrelationFuncforChromaSlices(ALF_Cr, pOrg, pCmp, iShape, pcPicOrg->getCStride(), pcPicDec->getCStride());7252 }7253 7254 // restore original corr pointer7255 m_ppdAlfCorr = ppdTmpCorr;7256 7257 // calc original dist7258 memset(qh, 0, sizeof(Int)*num_coeff);7259 qh[num_coeff-1] = 1<<((Int)ALF_NUM_BIT_SHIFT);7260 iOrgDistCb = xFastFiltDistEstimationChroma(m_ppdAlfCorrCb, qh, num_coeff);7261 iOrgDistCr = xFastFiltDistEstimationChroma(m_ppdAlfCorrCr, qh, num_coeff);7262 7263 for(Int iCmp=1; iCmp<=3; iCmp++)7264 {7265 m_pcTempAlfParam->chroma_idc = iCmp;7266 xCalcALFCoeffChroma(iCmp, iShape, qh);7267 iFiltDistCb = ((iCmp>>1)&0x1) ? xFastFiltDistEstimationChroma(m_ppdAlfCorrCb, qh, num_coeff) : iOrgDistCb;7268 iFiltDistCr = ((iCmp) &0x1) ? xFastFiltDistEstimationChroma(m_ppdAlfCorrCr, qh, num_coeff) : iOrgDistCr;7269 iDist = iFiltDistCb + iFiltDistCr;7270 UInt64 uiRate = xCalcRateChroma(m_pcTempAlfParam);7271 Double dCost = (Double)iDist + m_dLambdaChroma * (Double)uiRate;7272 if(dCost < dLocalMinCost)7273 {7274 dLocalMinCost = dCost;7275 copyALFParam(m_pcBestAlfParam, m_pcTempAlfParam);7276 bChanged = true;7277 }7278 }7279 }7280 copyALFParam(m_pcTempAlfParam, m_pcBestAlfParam);7281 if(!bChanged)7282 {7283 m_pcBestAlfParam->chroma_idc = 0;7284 return;7285 }7286 7287 // Adaptive in-loop wiener filtering for chroma7288 xFilteringFrameChroma(m_pcTempAlfParam, pcPicOrg, pcPicDec, pcPicRest);7289 7290 // filter on/off decision for chroma7291 Int iCWidth = (pcPicOrg->getWidth()>>1);7292 Int iCHeight = (pcPicOrg->getHeight()>>1);7293 Int iCStride = pcPicOrg->getCStride();7294 UInt64 uiFiltDistCb = xCalcSSD(pcPicOrg->getCbAddr(), pcPicRest->getCbAddr(), iCWidth, iCHeight, iCStride);7295 UInt64 uiFiltDistCr = xCalcSSD(pcPicOrg->getCrAddr(), pcPicRest->getCrAddr(), iCWidth, iCHeight, iCStride);7296 UInt64 uiOrgDistCb = xCalcSSD(pcPicOrg->getCbAddr(), pcPicDec->getCbAddr(), iCWidth, iCHeight, iCStride);7297 UInt64 uiOrgDistCr = xCalcSSD(pcPicOrg->getCrAddr(), pcPicDec->getCrAddr(), iCWidth, iCHeight, iCStride);7298 if(((m_pcTempAlfParam->chroma_idc)>>1 & 0x1) && (uiOrgDistCb<=uiFiltDistCb))7299 {7300 m_pcTempAlfParam->chroma_idc -= 2;7301 pcPicDec->copyToPicCb(pcPicRest);7302 }7303 if(((m_pcTempAlfParam->chroma_idc) & 0x1) && (uiOrgDistCr<=uiFiltDistCr))7304 {7305 m_pcTempAlfParam->chroma_idc -= 1;7306 pcPicDec->copyToPicCr(pcPicRest);7307 }7308 7309 if(m_pcTempAlfParam->chroma_idc)7310 {7311 UInt64 uiRate, uiDist;7312 Double dCost;7313 xCalcRDCostChroma(pcPicOrg, pcPicRest, m_pcTempAlfParam, uiRate, uiDist, dCost);7314 7315 if( dCost < dMinCost )7316 {7317 copyALFParam(m_pcBestAlfParam, m_pcTempAlfParam);7318 predictALFCoeffChroma(m_pcBestAlfParam);7319 7320 ruiBits += uiRate;7321 ruiDist += uiDist;7322 }7323 else7324 {7325 m_pcBestAlfParam->chroma_idc = 0;7326 7327 if((m_pcTempAlfParam->chroma_idc>>1)&0x01)7328 {7329 pcPicDec->copyToPicCb(pcPicRest);7330 }7331 if(m_pcTempAlfParam->chroma_idc&0x01)7332 {7333 pcPicDec->copyToPicCr(pcPicRest);7334 }7335 7336 ruiBits += uiMinRate;7337 ruiDist += uiMinDist;7338 }7339 }7340 else7341 {7342 m_pcBestAlfParam->chroma_idc = 0;7343 7344 ruiBits += uiMinRate;7345 ruiDist += uiMinDist;7346 7347 pcPicDec->copyToPicCb(pcPicRest);7348 pcPicDec->copyToPicCr(pcPicRest);7349 }7350 }7351 7352 Int64 TEncAdaptiveLoopFilter::xFastFiltDistEstimationChroma(Double** ppdCorr, Int* piCoeff, Int iSqrFiltLength)7353 {7354 Double pdcoeff[ALF_MAX_NUM_COEF];7355 Int i,j;7356 Int64 iDist;7357 Double dDist, dsum;7358 for(i=0; i< iSqrFiltLength; i++)7359 {7360 pdcoeff[i]= (Double)piCoeff[i] / (Double)(1<< ((Int)ALF_NUM_BIT_SHIFT) );7361 }7362 7363 dDist =0;7364 for(i=0; i< iSqrFiltLength; i++)7365 {7366 dsum= ((Double)ppdCorr[i][i]) * pdcoeff[i];7367 for(j=i+1; j< iSqrFiltLength; j++)7368 {7369 dsum += (Double)(2*ppdCorr[i][j])* pdcoeff[j];7370 }7371 7372 dDist += ((dsum - 2.0 * ppdCorr[i][iSqrFiltLength])* pdcoeff[i] );7373 }7374 7375 UInt uiShift = g_uiBitIncrement<<1;7376 if(dDist < 0)7377 {7378 iDist = -(((Int64)(-dDist + 0.5)) >> uiShift);7379 }7380 else //dDist >=07381 {7382 iDist= ((Int64)(dDist+0.5)) >> uiShift;7383 }7384 7385 return iDist;7386 }7387 7388 Void TEncAdaptiveLoopFilter::xCalcALFCoeffChroma(Int iChromaIdc, Int iShape, Int* piCoeff)7389 {7390 Int iSqrFiltLength = m_sqrFiltLengthTab[iShape];7391 7392 for(Int i=0; i<iSqrFiltLength; i++)7393 {7394 memset(m_ppdAlfCorr[i], 0, sizeof(Double)*(iSqrFiltLength + 1));7395 }7396 7397 // retrive7398 if((iChromaIdc>>1) & 0x1)7399 {7400 for(Int i=0; i<iSqrFiltLength; i++)7401 {7402 for(Int j=i; j<iSqrFiltLength+1; j++)7403 {7404 m_ppdAlfCorr[i][j] += m_ppdAlfCorrCb[i][j];7405 }7406 }7407 }7408 if(iChromaIdc & 0x1)7409 {7410 for(Int i=0; i<iSqrFiltLength; i++)7411 {7412 for(Int j=i; j<iSqrFiltLength+1; j++)7413 {7414 m_ppdAlfCorr[i][j] += m_ppdAlfCorrCr[i][j];7415 }7416 }7417 }7418 7419 // copy7420 for(Int i=1; i<iSqrFiltLength; i++)7421 {7422 for(Int j=0; j<i; j++)7423 {7424 m_ppdAlfCorr[i][j] = m_ppdAlfCorr[j][i];7425 }7426 }7427 7428 Double *corr = new Double[iSqrFiltLength];7429 for(Int i=0; i<iSqrFiltLength; i++)7430 {7431 corr[i] = m_ppdAlfCorr[i][iSqrFiltLength];7432 }7433 7434 // calc coeff7435 gnsSolveByChol(m_ppdAlfCorr, corr, m_pdDoubleAlfCoeff, iSqrFiltLength);7436 xQuantFilterCoef(m_pdDoubleAlfCoeff, piCoeff, iShape, g_uiBitDepth + g_uiBitIncrement);7437 delete [] corr;7438 }7439 7440 UInt64 TEncAdaptiveLoopFilter::xCalcRateChroma(ALFParam* pAlfParam)7441 {7442 UInt64 uiRate;7443 Int* piTmpCoef;7444 piTmpCoef = new Int[ALF_MAX_NUM_COEF];7445 memcpy(piTmpCoef, pAlfParam->coeff_chroma, sizeof(Int)*pAlfParam->num_coeff_chroma);7446 7447 predictALFCoeffChroma(pAlfParam);7448 7449 m_pcEntropyCoder->resetEntropy();7450 m_pcEntropyCoder->resetBits();7451 m_pcEntropyCoder->encodeAlfParam(pAlfParam);7452 uiRate = m_pcEntropyCoder->getNumberOfWrittenBits();7453 if (m_vBestAlfCUCtrlParam.size() != 0)7454 {7455 for(UInt s=0; s< m_uiNumSlicesInPic; s++)7456 {7457 if(!m_pcPic->getValidSlice(s))7458 {7459 continue;7460 }7461 m_pcEntropyCoder->resetEntropy();7462 m_pcEntropyCoder->resetBits();7463 m_pcEntropyCoder->encodeAlfCtrlParam( m_vBestAlfCUCtrlParam[s], m_uiNumCUsInFrame);7464 uiRate += m_pcEntropyCoder->getNumberOfWrittenBits();7465 }7466 }7467 else7468 {7469 uiRate += m_uiNumSlicesInPic;7470 }7471 memcpy(pAlfParam->coeff_chroma, piTmpCoef, sizeof(int)*pAlfParam->num_coeff_chroma);7472 delete[] piTmpCoef;7473 piTmpCoef = NULL;7474 7475 return uiRate;7476 }7477 #endif7478 4743 7479 4744 //! \} -
trunk/source/Lib/TLibEncoder/TEncAdaptiveLoopFilter.h
r56 r296 49 49 //! \{ 50 50 51 #if LCU_SYNTAX_ALF52 51 #define LCUALF_FILTER_BUDGET_CONTROL_ENC 1 //!< filter budget control 53 52 #define LCUALF_AVOID_USING_BOTTOM_LINES_ENCODER 1 //!< avoid using LCU bottom lines when lcu-based encoder RDO is used 54 #endif55 53 56 54 // ==================================================================================================================== … … 58 56 // ==================================================================================================================== 59 57 60 #if LCU_SYNTAX_ALF61 58 /// correlation info 62 59 struct AlfCorrData … … 110 107 }; 111 108 112 #endif113 109 114 110 … … 120 116 /// variables for correlation calculation 121 117 /// 122 #if !LCU_SYNTAX_ALF123 Double** m_ppdAlfCorr;124 Double* m_pdDoubleAlfCoeff;125 Double** m_ppdAlfCorrCb;126 Double** m_ppdAlfCorrCr;127 double ***m_yGlobalSym;128 double ****m_EGlobalSym;129 double *m_pixAcc;130 #endif131 118 double **m_y_merged; 132 119 double ***m_E_merged; … … 134 121 double *m_y_temp; 135 122 double **m_E_temp; 136 #if LCU_SYNTAX_ALF137 123 static const Int m_alfNumPartsInRowTab[5]; 138 124 static const Int m_alfNumPartsLevelTab[5]; … … 154 140 Int m_alfUsedFilterNum; 155 141 #endif 156 #endif157 142 158 143 /// 159 144 /// ALF parameters 160 145 /// 161 #if !LCU_SYNTAX_ALF162 ALFParam* m_pcBestAlfParam;163 ALFParam* m_pcTempAlfParam;164 ALFParam* pcAlfParamShape0;165 ALFParam* pcAlfParamShape1;166 #endif167 146 ALFParam *m_tempALFp; 168 147 … … 172 151 TComPicYuv* m_pcPicYuvBest; 173 152 TComPicYuv* m_pcPicYuvTmp; 174 #if !LCU_SYNTAX_ALF175 TComPicYuv* pcPicYuvRecShape0;176 TComPicYuv* pcPicYuvRecShape1;177 #endif178 153 179 154 /// … … 186 161 Int **m_diffFilterCoeffQuant; 187 162 Int **m_FilterCoeffQuantTemp; 188 #if !LCU_SYNTAX_ALF189 Int** m_mergeTableSavedMethods[NUM_ALF_CLASS_METHOD];190 Int*** m_aiFilterCoeffSavedMethods[NUM_ALF_CLASS_METHOD]; //!< time-delayed filter set buffer191 Int* m_iPreviousFilterShapeMethods[NUM_ALF_CLASS_METHOD];192 #endif193 163 /// 194 164 /// coding control parameters … … 196 166 Double m_dLambdaLuma; 197 167 Double m_dLambdaChroma; 198 #if !LCU_SYNTAX_ALF199 Int m_iUsePreviousFilter; //!< for N-pass encoding- 1: time-delayed filtering is allowed. 0: not allowed.200 Int m_iDesignCurrentFilter; //!< for N-pass encoding- 1: design filters for current slice. 0: design filters for future slice reference201 Int m_iGOPSize; //!< GOP size202 Int m_iCurrentPOC; //!< POC203 #endif204 168 Int m_iALFEncodePassReduction; //!< 0: 16-pass encoding, 1: 1-pass encoding, 2: 2-pass encoding 205 169 … … 221 185 private: 222 186 223 #if LCU_SYNTAX_ALF224 187 Void disableComponentAlfParam(Int compIdx, AlfParamSet* alfParamSet, AlfUnitParam* alfUnitPic); 225 188 Void copyAlfParamSet(AlfParamSet* dst, AlfParamSet* src); … … 252 215 Void xCopyDecToRestCUs( Pel* imgDec, Pel* imgRest, Int stride ); 253 216 Void xCopyDecToRestCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Pel* imgDec, Pel* imgRest, Int stride ); 254 #if ALF_SINGLE_FILTER_SHAPE255 217 Void calcCorrOneCompRegionChma(Pel* imgOrg, Pel* imgPad, Int stride, Int yPos, Int xPos, Int height, Int width, Double **eCorr, Double *yCorr, Bool isSymmCopyBlockMatrix); //!< Calculate correlations for chroma 256 218 Void calcCorrOneCompRegionLuma(Pel* imgOrg, Pel* imgPad, Int stride, Int yPos, Int xPos, Int height, Int width, Double ***eCorr, Double **yCorr, Double *pixAcc, Bool isforceCollection, Bool isSymmCopyBlockMatrix); 257 #endif258 219 259 220 //LCU-based mode decision … … 291 252 Void transferToAlfParamSet(Int compIdx, AlfUnitParam* alfUnitPic, AlfParamSet* & alfParamSet); 292 253 Int calculateAlfParamSetRateRDO(Int compIdx, AlfParamSet* alfParamSet, std::vector<AlfCUCtrlInfo>* alfCUCtrlParam); 293 #endif294 #if !LCU_SYNTAX_ALF295 // init / uninit internal variables296 Void xInitParam ();297 Void xUninitParam ();298 #endif299 254 // ALF on/off control related functions 300 255 Void xCreateTmpAlfCtrlFlags (); … … 305 260 Void xEncodeCUAlfCtrlFlags (std::vector<AlfCUCtrlInfo> &vAlfCUCtrlParam); 306 261 Void xEncodeCUAlfCtrlFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth); 307 #if !LCU_SYNTAX_ALF308 Void xCUAdaptiveControl_qc ( TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiMinRate, UInt64& ruiMinDist, Double& rdMinCost );309 Void xSetCUAlfCtrlFlags_qc (UInt uiAlfCtrlDepth, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiDist, std::vector<AlfCUCtrlInfo>& vAlfCUCtrlParam);310 Void xSetCUAlfCtrlFlag_qc (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiAlfCtrlDepth, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiDist, std::vector<UInt>& vCUCtrlFlag);311 312 // functions related to correlation computation313 Void xstoreInBlockMatrix(Int ypos, Int xpos, Int iheight, Int iwidth, Bool bResetBlockMatrix, Bool bSymmCopyBlockMatrix, Pel* pImgOrg, Pel* pImgPad, Int filtNo, Int stride); //!< Calculate correlations for luma314 Void xstoreInBlockMatrixforRegion(std::vector< AlfLCUInfo* > &vpAlfLCU, Pel* ImgOrg, Pel* ImgDec, Int tap, Int iStride, Bool bFirstSlice, Bool bLastSlice); //!< Calculate block autocorrelations and crosscorrelations for one ALF slice315 Void xstoreInBlockMatrixforSlices (Pel* ImgOrg, Pel* ImgDec, Int tap, Int iStride); //!< Calculate block autocorrelations and crosscorrelations for ALF slices316 Void xCalcCorrelationFunc(Int ypos, Int xpos, Pel* pImgOrg, Pel* pImgPad, Int filtNo, Int iWidth, Int iHeight, Int iOrgStride, Int iCmpStride, Bool bSymmCopyBlockMatrix); //!< Calculate correlations for chroma317 Void xCalcCorrelationFuncforChromaRegion(std::vector< AlfLCUInfo* > &vpAlfLCU, Pel* pOrg, Pel* pCmp, Int filtNo, Int iStride, Bool bLastSlice, Int iFormatShift); //!< Calculate autocorrelations and crosscorrelations for one chroma slice318 Void xCalcCorrelationFuncforChromaSlices (Int ComponentID, Pel* pOrg, Pel* pCmp, Int iTap, Int iOrgStride, Int iCmpStride); //!< Calculate autocorrelations and crosscorrelations for chroma slices319 #endif320 262 // functions related to filtering 321 263 Void xFilterCoefQuickSort ( Double *coef_data, Int *coef_num, Int upper, Int lower ); 322 264 Void xQuantFilterCoef ( Double* h, Int* qh, Int tap, int bit_depth ); 323 #if !LCU_SYNTAX_ALF324 Void xClearFilterCoefInt ( Int* qh, Int N );325 Void xCopyDecToRestCUs ( TComPicYuv* pcPicDec, TComPicYuv* pcPicRest );326 Void xCopyDecToRestCU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest );327 Void xFilteringFrameChroma (ALFParam* pcAlfParam, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest);328 Int setFilterIdx(Int index); //!< set filter buffer index329 Void setInitialMask(TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec); //!< set initial m_maskImg330 Void saveFilterCoeffToBuffer(Int **filterSet, Int numFilter, Int* mergeTable, Int mode, Int filtNo); //!< save filter coefficients to buffer331 Void setMaskWithTimeDelayedResults(TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec); //!< set initial m_maskImg with previous (time-delayed) filters332 Void decideFilterShapeLuma(Pel* ImgOrg, Pel* ImgDec, Int Stride, ALFParam* pcAlfSaved, UInt64& ruiRate, UInt64& ruiDist,Double& rdCost); //!< Estimate RD cost of all filter size & store the best one333 Void xFilterTapDecisionChroma (UInt64 uiLumaRate, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiDist, UInt64& ruiBits);334 Int64 xFastFiltDistEstimationChroma (Double** ppdCorr, Int* piCoeff, Int iSqrFiltLength);335 Void xfilterSlicesEncoder(Pel* ImgDec, Pel* ImgRest, Int iStride, Int filtNo, Int** filterCoeff, Int* mergeTable, Pel** varImg); //!< Calculate ALF grouping indices for ALF slices336 Void setALFEncodingParam(TComPic *pcPic); //!< set ALF encoding parameters337 Void xReDesignFilterCoeff_qc (TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, Bool bReadCorr);338 Void xFirstFilteringFrameLuma (Pel* imgOrg, Pel* imgDec, Pel* imgRest, ALFParam* ALFp, Int filtNo, Int stride);339 Void xFilteringFrameLuma(Pel* imgOrg, Pel* imgPad, Pel* imgFilt, ALFParam* ALFp, Int filtNo, Int stride);340 Void xEncALFLuma ( TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiMinRate, UInt64& ruiMinDist, Double& rdMinCost ); //!< estimate adaptation mode and filter shape341 #endif342 265 // distortion / misc functions 343 266 #if HHI_INTERVIEW_SKIP … … 346 269 UInt64 xCalcSSD ( Pel* pOrg, Pel* pCmp, Int iWidth, Int iHeight, Int iStride ); 347 270 #endif 348 #if !LCU_SYNTAX_ALF349 #if HHI_INTERVIEW_SKIP350 Void xCalcRDCost ( TComPicYuv* pcPicOrg, TComPicYuv* pcPicCmp, ALFParam* pAlfParam, UInt64& ruiRate, UInt64& ruiDist, Double& rdCost, std::vector<AlfCUCtrlInfo>* pvAlfCUCtrlParam = NULL);351 Void xCalcRDCost ( ALFParam* pAlfParam, UInt64& ruiRate, UInt64 uiDist, Double& rdCost, std::vector<AlfCUCtrlInfo>* pvAlfCUCtrlParam = NULL);352 Void xCalcRDCostChroma ( TComPicYuv* pcPicOrg, TComPicYuv* pcPicCmp, ALFParam* pAlfParam, UInt64& ruiRate, UInt64& ruiDist, Double& rdCost );353 #else354 Void xCalcRDCost ( TComPicYuv* pcPicOrg, TComPicYuv* pcPicCmp, ALFParam* pAlfParam, UInt64& ruiRate, UInt64& ruiDist, Double& rdCost, std::vector<AlfCUCtrlInfo>* pvAlfCUCtrlParam = NULL);355 Void xCalcRDCost ( ALFParam* pAlfParam, UInt64& ruiRate, UInt64 uiDist, Double& rdCost, std::vector<AlfCUCtrlInfo>* pvAlfCUCtrlParam = NULL);356 Void xCalcRDCostChroma ( TComPicYuv* pcPicOrg, TComPicYuv* pcPicCmp, ALFParam* pAlfParam, UInt64& ruiRate, UInt64& ruiDist, Double& rdCost );357 #endif358 #endif359 271 Int64 xFastFiltDistEstimation(Double** ppdE, Double* pdy, Int* piCoeff, Int iFiltLength); //!< Estimate filtering distortion by correlation values and filter coefficients 360 #if !LCU_SYNTAX_ALF361 Int64 xEstimateFiltDist (Int filters_per_fr, Int* VarIndTab, Double*** pppdE, Double** ppdy, Int** ppiCoeffSet, Int iFiltLength); //!< Estimate total filtering cost of all groups362 UInt64 xCalcRateChroma (ALFParam* pAlfParam);363 Void xCalcALFCoeffChroma (Int iChromaIdc, Int iShape, Int* piCoeff);364 #endif365 272 366 273 /// code filter coefficients 367 274 UInt xcodeFiltCoeff(Int **filterCoeffSymQuant, Int filter_shape, Int varIndTab[], Int filters_per_fr_best, ALFParam* ALFp); 368 #if LCU_SYNTAX_ALF369 275 Void xfindBestFilterVarPred(double **ySym, double ***ESym, double *pixAcc, Int **filterCoeffSym, Int **filterCoeffSymQuant,Int filter_shape, Int *filters_per_fr_best, Int varIndTab[], Pel **imgY_rec, Pel **varImg, Pel **maskImg, Pel **imgY_pad, double lambda_val, Int numMaxFilters = NO_FILTERS); 370 #else371 Void xfindBestFilterVarPred(double **ySym, double ***ESym, double *pixAcc, Int **filterCoeffSym, Int **filterCoeffSymQuant,Int filter_shape, Int *filters_per_fr_best, Int varIndTab[], Pel **imgY_rec, Pel **varImg, Pel **maskImg, Pel **imgY_pad, double lambda_val);372 #endif373 276 double xfindBestCoeffCodMethod(int **filterCoeffSymQuant, int filter_shape, int sqrFiltLength, int filters_per_fr, double errorForce0CoeffTab[NO_VAR_BINS][2], double lambda); 374 277 Int xsendAllFiltersPPPred(int **FilterCoeffQuant, int filter_shape, int sqrFiltLength, int filters_per_group, int createBistream, ALFParam* ALFp); … … 400 303 Void startALFEnc(TComPic* pcPic, TEncEntropy* pcEntropyCoder); //!< allocate temporal memory 401 304 Void endALFEnc(); //!< destroy temporal memory 402 #if LCU_SYNTAX_ALF403 305 #if ALF_CHROMA_LAMBDA 404 306 #if HHI_INTERVIEW_SKIP … … 418 320 Void resetPicAlfUnit(); 419 321 Void setAlfCoefInSlice(Bool b) {m_alfCoefInSlice = b;} 420 #else421 #if ALF_CHROMA_LAMBDA422 #if HHI_INTERVIEW_SKIP423 Void ALFProcess(ALFParam* pcAlfParam, std::vector<AlfCUCtrlInfo>* pvAlfCtrlParam, Double dLambdaLuma, Double dLambdaChroma, UInt64& ruiDist, UInt64& ruiBits, Bool bInterviewSkip); //!< estimate ALF parameters424 #else425 Void ALFProcess(ALFParam* pcAlfParam, std::vector<AlfCUCtrlInfo>* pvAlfCtrlParam, Double dLambdaLuma, Double dLambdaChroma, UInt64& ruiDist, UInt64& ruiBits); //!< estimate ALF parameters426 #endif427 #else428 #if HHI_INTERVIEW_SKIP429 Void ALFProcess(ALFParam* pcAlfParam, std::vector<AlfCUCtrlInfo>* pvAlfCtrlParam, Double dLambda, UInt64& ruiDist, UInt64& ruiBits, Bool bInterviewSkip); //!< estimate ALF parameters430 #else431 Void ALFProcess(ALFParam* pcAlfParam, std::vector<AlfCUCtrlInfo>* pvAlfCtrlParam, Double dLambda, UInt64& ruiDist, UInt64& ruiBits); //!< estimate ALF parameters432 #endif433 #endif434 435 Void setGOPSize(Int val) { m_iGOPSize = val; } //!< set GOP size436 #endif437 322 Void setALFEncodePassReduction (Int iVal) {m_iALFEncodePassReduction = iVal;} //!< set N-pass encoding. 0: 16(14)-pass encoding, 1: 1-pass encoding, 2: 2-pass encoding 438 323 439 324 Void setALFMaxNumberFilters (Int iVal) {m_iALFMaxNumberFilters = iVal;} //!< set ALF Max Number of Filters 440 325 441 #if LCU_SYNTAX_ALF442 326 Void createAlfGlobalBuffers(); //!< create ALF global buffers 443 327 Void initPicQuadTreePartition(Bool isPicBasedEncode); 444 #else445 Void createAlfGlobalBuffers(Int iALFEncodePassReduction); //!< create ALF global buffers446 #endif447 328 Void destroyAlfGlobalBuffers(); //!< destroy ALF global buffers 448 329 Void PCMLFDisableProcess (TComPic* pcPic); -
trunk/source/Lib/TLibEncoder/TEncBinCoder.h
r56 r296 56 56 virtual Void finish () = 0; 57 57 virtual Void copyState ( TEncBinIf* pcTEncBinIf ) = 0; 58 #if OL_FLUSH59 58 virtual Void flush () = 0; 60 #endif61 59 62 60 virtual Void encodeFlush (Bool bEnd) = 0; 63 61 64 62 virtual Void resetBac () = 0; 65 #if BURST_IPCM66 63 virtual Void encodeNumSubseqIPCM( Int numSubseqIPCM ) = 0; 67 #endif68 64 virtual Void encodePCMAlignBits() = 0; 69 65 virtual Void xWritePCMCode ( UInt uiCode, UInt uiLength ) = 0; -
trunk/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp
r56 r296 105 105 } 106 106 107 #if OL_FLUSH108 107 Void TEncBinCABAC::flush() 109 108 { … … 117 116 start(); 118 117 } 119 #endif120 118 121 119 /** Reset BAC register and counter values. … … 127 125 } 128 126 129 #if BURST_IPCM130 127 /** Encode # of subsequent IPCM blocks. 131 128 * \param numSubseqIPCM … … 153 150 } 154 151 } 155 #endif156 152 157 153 /** Encode PCM alignment zero bits. … … 160 156 Void TEncBinCABAC::encodePCMAlignBits() 161 157 { 162 #if !BURST_IPCM163 finish();164 m_pcTComBitIf->write( 1, 1 ); // stop bit165 #endif166 158 m_pcTComBitIf->writeAlignZero(); // pcm align zero 167 159 } -
trunk/source/Lib/TLibEncoder/TEncBinCoderCABAC.h
r56 r296 57 57 Void finish (); 58 58 Void copyState ( TEncBinIf* pcTEncBinIf ); 59 #if OL_FLUSH60 59 Void flush (); 61 #endif62 60 63 61 Void resetBac (); 64 #if BURST_IPCM65 62 Void encodeNumSubseqIPCM( Int numSubseqIPCM ); 66 #endif67 63 Void encodePCMAlignBits(); 68 64 Void xWritePCMCode ( UInt uiCode, UInt uiLength ); -
trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
r210 r296 161 161 //DF flag 162 162 WRITE_FLAG(pcAPS->getLoopFilterOffsetInAPS()?1:0, "aps_deblocking_filter_flag"); 163 #if !SAO_UNIT_INTERLEAVING 164 //SAO flag 165 WRITE_FLAG( pcAPS->getSaoEnabled()?1:0, "aps_sample_adaptive_offset_flag"); 166 #endif 167 #if !LCU_SYNTAX_ALF 168 //ALF flag 169 WRITE_FLAG( pcAPS->getAlfEnabled()?1:0, "aps_adaptive_loop_filter_flag"); 170 #endif 171 } 172 #if LCU_SYNTAX_ALF 163 } 173 164 Void TEncCavlc::codeAPSAlflag(UInt uiCode) 174 165 { 175 166 WRITE_FLAG(uiCode, "aps_adaptive_loop_filter_flag"); 176 167 } 177 #endif178 168 179 169 Void TEncCavlc::codeDFFlag(UInt uiCode, const Char *pSymbolName) … … 186 176 } 187 177 188 #if RPS_IN_SPS189 178 Void TEncCavlc::codeShortTermRefPicSet( TComSPS* pcSPS, TComReferencePictureSet* rps ) 190 #else191 Void TEncCavlc::codeShortTermRefPicSet( TComPPS* pcPPS, TComReferencePictureSet* rps )192 #endif193 179 { 194 180 #if PRINT_RPS_INFO … … 245 231 xTracePPSHeader (pcPPS); 246 232 #endif 247 #if !RPS_IN_SPS248 TComRPSList* rpsList = pcPPS->getRPSList();249 #endif250 233 251 234 WRITE_UVLC( pcPPS->getPPSId(), "pic_parameter_set_id" ); 252 235 WRITE_UVLC( pcPPS->getSPSId(), "seq_parameter_set_id" ); 253 236 254 #if MULTIBITS_DATA_HIDING255 237 WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" ); 256 238 if( pcPPS->getSignHideFlag() ) … … 258 240 WRITE_CODE(pcPPS->getTSIG(), 4, "sign_hiding_threshold"); 259 241 } 260 #endif261 242 #if CABAC_INIT_FLAG 262 243 WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0, "cabac_init_present_flag" ); 263 #endif264 #if !RPS_IN_SPS265 // RPS is put before entropy_coding_mode_flag266 // since entropy_coding_mode_flag will probably be removed from the WD267 TComReferencePictureSet* rps;268 269 WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" );270 for(UInt i=0; i < rpsList->getNumberOfReferencePictureSets(); i++)271 {272 rps = rpsList->getReferencePictureSet(i);273 codeShortTermRefPicSet(pcPPS,rps);274 }275 WRITE_FLAG( pcPPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" );276 244 #endif 277 245 // entropy_coding_mode_flag … … 280 248 if (pcPPS->getEntropyCodingMode()) 281 249 { 282 #if !WPP_SIMPLIFICATION 283 WRITE_UVLC( pcPPS->getEntropyCodingSynchro(), "entropy_coding_synchro" ); 284 WRITE_FLAG( pcPPS->getCabacIstateReset() ? 1 : 0, "cabac_istate_reset" ); 285 #endif 286 #if !TILES_OR_ENTROPY_SYNC_IDC 287 #if !WPP_SIMPLIFICATION 288 if ( pcPPS->getEntropyCodingSynchro() ) 289 #endif 290 { 291 WRITE_UVLC( pcPPS->getNumSubstreams()-1, "num_substreams_minus1" ); 292 } 293 #endif 294 } 295 #if !H0566_TLA 296 WRITE_UVLC( pcPPS->getNumTLayerSwitchingFlags(), "num_temporal_layer_switching_point_flags" ); 297 for( UInt i = 0; i < pcPPS->getNumTLayerSwitchingFlags(); i++ ) 298 { 299 WRITE_FLAG( pcPPS->getTLayerSwitchingFlag( i ) ? 1 : 0 , "temporal_layer_switching_point_flag" ); 300 } 301 #endif 250 } 302 251 // num_ref_idx_l0_default_active_minus1 303 252 // num_ref_idx_l1_default_active_minus1 … … 313 262 WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) 314 263 WRITE_CODE( pcPPS->getWPBiPredIdc(), 2, "weighted_bipred_idc" ); // Use of Weighting Bi-Prediction (B_SLICE) 315 #if H0388316 264 WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" ); 317 #endif318 #if TILES_OR_ENTROPY_SYNC_IDC319 265 if(pcPPS->getSPS()->getTilesOrEntropyCodingSyncIdc()==1) 320 266 { 321 #endif322 267 WRITE_FLAG( pcPPS->getColumnRowInfoPresent(), "tile_info_present_flag" ); 323 268 WRITE_FLAG( pcPPS->getTileBehaviorControlPresentFlag(), "tile_control_present_flag"); … … 347 292 if(iNumColTilesMinus1 !=0 || iNumRowTilesMinus1 !=0) 348 293 { 349 #if !REMOVE_TILE_DEPENDENCE350 WRITE_FLAG( pcPPS->getTileBoundaryIndependenceIdr(), "tile_boundary_independence_flag" );351 if(pcPPS->getTileBoundaryIndependenceIdr() == 1)352 {353 #endif354 294 WRITE_FLAG( pcPPS->getLFCrossTileBoundaryFlag()?1 : 0, "loop_filter_across_tile_flag"); 355 #if !REMOVE_TILE_DEPENDENCE 356 } 357 #endif 358 } 359 } 360 #if TILES_OR_ENTROPY_SYNC_IDC 295 } 296 } 361 297 } 362 298 else if(pcPPS->getSPS()->getTilesOrEntropyCodingSyncIdc()==2) … … 364 300 WRITE_UVLC( pcPPS->getNumSubstreams()-1, "num_substreams_minus1" ); 365 301 } 366 #endif 367 368 #if DBL_CONTROL 302 369 303 WRITE_FLAG( pcPPS->getDeblockingFilterControlPresent()?1 : 0, "deblocking_filter_control_present_flag"); 370 #endif371 #if PARALLEL_MERGE372 304 WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2"); 373 #endif374 305 WRITE_FLAG( 0, "pps_extension_flag" ); 375 306 } … … 498 429 } 499 430 } 431 #if INTER_VIEW_VECTOR_SCALING_C0115 432 WRITE_FLAG( pcVPS->getIVScalingFlag(), "inter_view_vector_scaling_flag" ); 433 #endif 500 434 } 501 435 … … 508 442 #endif 509 443 #endif 510 #if HHI_MPI 444 #if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068 511 445 Void TEncCavlc::codeSPS( TComSPS* pcSPS, Bool bIsDepth ) 512 446 #else … … 528 462 WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" ); 529 463 WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); 530 #if PIC_CROPPING531 464 WRITE_FLAG( pcSPS->getPicCroppingFlag(), "pic_cropping_flag" ); 532 465 if (pcSPS->getPicCroppingFlag()) … … 537 470 WRITE_UVLC( pcSPS->getPicCropBottomOffset(), "pic_crop_bottom_offset" ); 538 471 } 539 #endif540 472 541 473 #if FULL_NBIT … … 563 495 564 496 WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); 565 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER566 497 for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) 567 498 { … … 570 501 WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); 571 502 } 572 #else573 WRITE_UVLC( pcSPS->getMaxNumberOfReferencePictures(), "max_num_ref_pics" );574 WRITE_UVLC( pcSPS->getNumReorderFrames(), "num_reorder_frames" );575 WRITE_UVLC(pcSPS->getMaxDecFrameBuffering(), "max_dec_frame_buffering" );576 WRITE_UVLC(pcSPS->getMaxLatencyIncrease(), "max_latency_increase" );577 #endif578 503 assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() ); 579 504 … … 586 511 } 587 512 588 #if H0412_REF_PIC_LIST_RESTRICTION589 513 WRITE_FLAG( pcSPS->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag" ); 590 514 if( pcSPS->getRestrictedRefPicListsFlag() ) … … 592 516 WRITE_FLAG( pcSPS->getListsModificationPresentFlag(), "lists_modification_present_flag" ); 593 517 } 594 #endif595 518 WRITE_UVLC( log2MinCUSize - 3, "log2_min_coding_block_size_minus3" ); 596 519 WRITE_UVLC( pcSPS->getMaxCUDepth()-g_uiAddCUDepth, "log2_diff_max_min_coding_block_size" ); … … 618 541 WRITE_FLAG( pcSPS->getUseSAO() ? 1 : 0, "sample_adaptive_offset_enabled_flag"); 619 542 WRITE_FLAG( pcSPS->getUseALF () ? 1 : 0, "adaptive_loop_filter_enabled_flag"); 620 #if LCU_SYNTAX_ALF621 543 if(pcSPS->getUseALF()) 622 544 { 623 545 WRITE_FLAG( (pcSPS->getUseALFCoefInSlice()) ? 1 : 0, "alf_coef_in_slice_flag"); 624 546 } 625 #endif626 547 627 548 if( pcSPS->getUsePCM() ) … … 634 555 WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "temporal_id_nesting_flag" ); 635 556 636 #if RPS_IN_SPS637 557 TComRPSList* rpsList = pcSPS->getRPSList(); 638 558 TComReferencePictureSet* rps; … … 645 565 } 646 566 WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" ); 647 #endif648 #if !PIC_CROPPING649 //!!!KS: Syntax not in WD !!!650 651 xWriteUvlc ( pcSPS->getPad (0) );652 xWriteUvlc ( pcSPS->getPad (1) );653 #endif654 567 // AMVP mode for each depth 655 568 for (Int i = 0; i < pcSPS->getMaxCUDepth(); i++) … … 658 571 } 659 572 660 #if TILES_WPP_ENTRY_POINT_SIGNALLING661 573 Int tilesOrEntropyCodingSyncIdc = 0; 662 574 if ( pcSPS->getNumColumnsMinus1() > 0 || pcSPS->getNumRowsMinus1() > 0) … … 670 582 pcSPS->setTilesOrEntropyCodingSyncIdc( tilesOrEntropyCodingSyncIdc ); 671 583 WRITE_CODE(tilesOrEntropyCodingSyncIdc, 2, "tiles_or_entropy_coding_sync_idc"); 672 #endif 673 674 #if TILES_OR_ENTROPY_SYNC_IDC 584 675 585 if(tilesOrEntropyCodingSyncIdc == 1) 676 586 { 677 #endif678 587 WRITE_UVLC( pcSPS->getNumColumnsMinus1(), "num_tile_columns_minus1" ); 679 588 WRITE_UVLC( pcSPS->getNumRowsMinus1(), "num_tile_rows_minus1" ); … … 694 603 if( pcSPS->getNumColumnsMinus1() !=0 || pcSPS->getNumRowsMinus1() != 0) 695 604 { 696 #if !REMOVE_TILE_DEPENDENCE697 WRITE_FLAG( pcSPS->getTileBoundaryIndependenceIdr(), "tile_boundary_independence_flag" );698 if(pcSPS->getTileBoundaryIndependenceIdr() == 1)699 {700 #endif701 605 WRITE_FLAG( pcSPS->getLFCrossTileBoundaryFlag()?1 : 0, "loop_filter_across_tile_flag"); 702 #if !REMOVE_TILE_DEPENDENCE 703 } 704 #endif 705 } 706 #if TILES_OR_ENTROPY_SYNC_IDC 707 } 708 #endif 606 } 607 } 709 608 WRITE_FLAG( 1, "sps_extension_flag" ); 710 609 #if !QC_MVHEVC_B0046 … … 792 691 WRITE_SVLC( pcSPS->getPdmOffset ()[ uiId ], "Pdm_offset" ); 793 692 } 794 #if H HI_INTER_VIEW_MOTION_PRED693 #if H3D_IVMP 795 694 WRITE_UVLC( pcSPS->getMultiviewMvPredMode(), "multi_view_mv_pred_mode" ); 796 695 #endif 797 #if H HI_INTER_VIEW_RESIDUAL_PRED696 #if H3D_IVRP 798 697 WRITE_FLAG ( pcSPS->getMultiviewResPredMode(), "multi_view_residual_pred_mode" ); 799 698 #endif … … 866 765 if (address==0) 867 766 { 868 if( pcSlice->getSPS()->getViewId() && !pcSlice->getIsDepth() ) 767 if( pcSlice->getSPS()->getViewId() 768 #if !LGE_ILLUCOMP_DEPTH_C0046 769 && !pcSlice->getIsDepth() 770 #endif 771 ) 869 772 { 870 773 WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "applying IC flag" ); … … 889 792 WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "pic_parameter_set_id" ); 890 793 #endif 891 #if H0388892 794 if( pcSlice->getPPS()->getOutputFlagPresentFlag() ) 893 795 { 894 796 WRITE_FLAG( pcSlice->getPicOutputFlag() ? 1 : 0, "pic_output_flag" ); 895 797 } 896 #endif897 798 #if QC_REM_IDV_B0046 898 799 if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR && pcSlice->getViewId() == 0) … … 917 818 { 918 819 WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); 919 #if RPS_IN_SPS920 820 codeShortTermRefPicSet(pcSlice->getSPS(), rps); 921 #else922 codeShortTermRefPicSet(pcSlice->getPPS(), rps);923 #endif924 821 } 925 822 else … … 928 825 WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); 929 826 } 930 #if RPS_IN_SPS931 827 if(pcSlice->getSPS()->getLongTermRefsPresent()) 932 #else933 if(pcSlice->getPPS()->getLongTermRefsPresent())934 #endif935 828 { 936 829 WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics"); 937 830 Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC(); 938 831 Int prev = 0; 939 #if LTRP_MULT940 832 Int prevDeltaPocLt=0; 941 833 Int currDeltaPocLt=0; 942 #endif943 834 for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--) 944 835 { 945 836 WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt"); 946 837 947 #if LTRP_MULT948 838 currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt; 949 839 … … 976 866 } 977 867 prevDeltaPocLt=currDeltaPocLt; 978 #endif979 868 prev = rps->getDeltaPOC(i); 980 869 WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); … … 988 877 { 989 878 WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); 990 #if RPS_IN_SPS991 879 codeShortTermRefPicSet(pcSlice->getSPS(), rps); 992 #else993 codeShortTermRefPicSet(pcSlice->getPPS(), rps);994 #endif995 880 } 996 881 else … … 999 884 WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); 1000 885 } 1001 #if RPS_IN_SPS1002 886 if(pcSlice->getSPS()->getLongTermRefsPresent()) 1003 #else1004 if(pcSlice->getPPS()->getLongTermRefsPresent())1005 #endif1006 887 { 1007 888 WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics"); 1008 889 Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC(); 1009 890 Int prev = 0; 1010 #if LTRP_MULT1011 891 Int prevDeltaPocLt=0; 1012 892 Int currDeltaPocLt=0; 1013 #endif1014 893 for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--) 1015 894 { 1016 895 WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt"); 1017 896 1018 #if LTRP_MULT1019 897 currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt; 1020 898 … … 1047 925 } 1048 926 prevDeltaPocLt=currDeltaPocLt; 1049 #endif1050 927 prev = rps->getDeltaPOC(i); 1051 928 WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); … … 1059 936 if (pcSlice->getSPS()->getUseALF()) 1060 937 { 1061 #if !LCU_SYNTAX_ALF1062 if (pcSlice->getAlfEnabledFlag())1063 {1064 assert (pcSlice->getAPS()->getAlfEnabled());1065 }1066 #endif1067 938 WRITE_FLAG( pcSlice->getAlfEnabledFlag(), "ALF on/off flag in slice header" ); 1068 939 } 1069 940 if (pcSlice->getSPS()->getUseSAO()) 1070 941 { 1071 #if SAO_UNIT_INTERLEAVING1072 942 WRITE_FLAG( pcSlice->getSaoInterleavingFlag(), "SAO interleaving flag" ); 1073 #endif1074 943 assert (pcSlice->getSaoEnabledFlag() == pcSlice->getAPS()->getSaoEnabled()); 1075 944 WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "SAO on/off flag in slice header" ); 1076 #if SAO_UNIT_INTERLEAVING1077 945 if (pcSlice->getSaoInterleavingFlag()&&pcSlice->getSaoEnabledFlag() ) 1078 946 { … … 1080 948 WRITE_FLAG( pcSlice->getAPS()->getSaoParam()->bSaoFlag[2], "SAO on/off flag for Cr in slice header" ); 1081 949 } 1082 #endif1083 950 } 1084 951 WRITE_UVLC( pcSlice->getAPS()->getAPSID(), "aps_id"); … … 1103 970 pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); 1104 971 } 1105 #if H0412_REF_PIC_LIST_RESTRICTION1106 972 if( pcSlice->getSPS()->getListsModificationPresentFlag() ) 1107 973 { 1108 #endif1109 974 TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); 1110 #if H0137_0138_LIST_MODIFICATION1111 975 if( !pcSlice->isIntra() ) 1112 976 { … … 1151 1015 } 1152 1016 } 1153 #else 1154 if(!pcSlice->isIntra()) 1155 { 1156 WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag" ); 1157 for(Int i = 0; i < refPicListModification->getNumberOfRefPicListModificationsL0(); i++) 1158 { 1159 WRITE_UVLC( refPicListModification->getListIdcL0(i), "ref_pic_list_modification_idc"); 1160 WRITE_UVLC( refPicListModification->getRefPicSetIdxL0(i), "ref_pic_set_idx"); 1161 } 1162 if(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) 1163 WRITE_UVLC( 3, "ref_pic_list_modification_idc"); 1164 } 1165 if(pcSlice->isInterB()) 1166 { 1167 WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag" ); 1168 for(Int i = 0; i < refPicListModification->getNumberOfRefPicListModificationsL1(); i++) 1169 { 1170 WRITE_UVLC( refPicListModification->getListIdcL1(i), "ref_pic_list_modification_idc"); 1171 WRITE_UVLC( refPicListModification->getRefPicSetIdxL1(i), "ref_pic_set_idx"); 1172 } 1173 if(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) 1174 WRITE_UVLC( 3, "ref_pic_list_modification_idc"); 1175 } 1176 #endif 1177 } 1178 #if H0412_REF_PIC_LIST_RESTRICTION 1179 } 1180 #endif 1017 } 1018 } 1181 1019 // ref_pic_list_combination( ) 1182 1020 // maybe move to own function? … … 1188 1026 WRITE_UVLC( pcSlice->getNumRefIdx(REF_PIC_LIST_C) - 1, "num_ref_idx lc_active_minus1"); 1189 1027 1190 #if H0412_REF_PIC_LIST_RESTRICTION1191 1028 if( pcSlice->getSPS()->getListsModificationPresentFlag() ) 1192 1029 { 1193 #endif1194 1030 WRITE_FLAG( pcSlice->getRefPicListModificationFlagLC() ? 1 : 0, "ref_pic_list_modification_flag_lc" ); 1195 1031 if(pcSlice->getRefPicListModificationFlagLC()) … … 1198 1034 { 1199 1035 WRITE_FLAG( pcSlice->getListIdFromIdxOfLC(i), "pic_from_list_0_flag" ); 1200 #if H0137_0138_LIST_MODIFICATION1201 1036 if (((pcSlice->getListIdFromIdxOfLC(i)==REF_PIC_LIST_0) && pcSlice->getNumRefIdx( REF_PIC_LIST_0 )>1 ) || ((pcSlice->getListIdFromIdxOfLC(i)==REF_PIC_LIST_1) && pcSlice->getNumRefIdx( REF_PIC_LIST_1 )>1 ) ) 1202 1037 { 1203 1038 WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i), "ref_idx_list_curr" ); 1204 1039 } 1205 #else1206 WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i), "ref_idx_list_curr" );1207 #endif1208 1040 } 1209 1041 } 1210 #if H0412_REF_PIC_LIST_RESTRICTION 1211 } 1212 #endif 1042 } 1213 1043 } 1214 1044 } 1215 1045 1216 #if H0111_MVD_L1_ZERO1217 1046 if (pcSlice->isInterB()) 1218 1047 { 1219 1048 WRITE_FLAG( pcSlice->getMvdL1ZeroFlag() ? 1 : 0, "mvd_l1_zero_flag"); 1220 1049 } 1221 #endif1222 1050 1223 1051 if(pcSlice->getPPS()->getEntropyCodingMode() && !pcSlice->isIntra()) … … 1242 1070 Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 ); 1243 1071 WRITE_SVLC( iCode, "slice_qp_delta" ); 1244 #if DBL_CONTROL1245 1072 if (pcSlice->getPPS()->getDeblockingFilterControlPresent()) 1246 1073 { … … 1249 1076 WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag"); 1250 1077 } 1251 #else1252 WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag");1253 #endif1254 1078 if (!pcSlice->getInheritDblParamFromAPS()) 1255 1079 { … … 1261 1085 } 1262 1086 } 1263 #if DBL_CONTROL 1264 } 1265 #endif 1087 } 1266 1088 if ( pcSlice->getSliceType() == B_SLICE ) 1267 1089 { … … 1299 1121 } 1300 1122 1301 #if ( HHI_MPI || H HI_INTER_VIEW_MOTION_PRED)1302 #if ( HHI_MPI && H HI_INTER_VIEW_MOTION_PRED)1123 #if ( HHI_MPI || H3D_IVMP ) 1124 #if ( HHI_MPI && H3D_IVMP ) 1303 1125 const int iExtraMergeCandidates = ( pcSlice->getSPS()->getUseMVI() || pcSlice->getSPS()->getMultiviewMvPredMode() ) ? 1 : 0; 1304 1126 #elif HHI_MPI 1305 1127 const int iExtraMergeCandidates = pcSlice->getSPS()->getUseMVI() ? 1 : 0; 1128 #elif MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137 1129 const int iExtraMergeCandidates = ( pcSlice->getIsDepth() || pcSlice->getSPS()->getMultiviewMvPredMode() ) ? 1 : 0; 1306 1130 #else 1307 1131 const int iExtraMergeCandidates = pcSlice->getSPS()->getMultiviewMvPredMode() ? 1 : 0; … … 1332 1156 \param pcSlice Where we find the substream size information. 1333 1157 */ 1334 #if TILES_WPP_ENTRY_POINT_SIGNALLING1335 1158 Void TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice ) 1336 1159 { … … 1432 1255 delete [] entryPointOffset; 1433 1256 } 1434 #else1435 Void TEncCavlc::codeSliceHeaderSubstreamTable( TComSlice* pcSlice )1436 {1437 UInt uiNumSubstreams = pcSlice->getPPS()->getNumSubstreams();1438 UInt*puiSubstreamSizes = pcSlice->getSubstreamSizes();1439 1440 // Write header information for all substreams except the last.1441 for (UInt ui = 0; ui+1 < uiNumSubstreams; ui++)1442 {1443 UInt uiNumbits = puiSubstreamSizes[ui];1444 1445 //the 2 first bits are used to give the size of the header1446 if ( uiNumbits < (1<<8) )1447 {1448 xWriteCode(0, 2 );1449 xWriteCode(uiNumbits, 8 );1450 }1451 else if ( uiNumbits < (1<<16) )1452 {1453 xWriteCode(1, 2 );1454 xWriteCode(uiNumbits, 16 );1455 }1456 else if ( uiNumbits < (1<<24) )1457 {1458 xWriteCode(2, 2 );1459 xWriteCode(uiNumbits, 24 );1460 }1461 else if ( uiNumbits < (1<<31) )1462 {1463 xWriteCode(3, 2 );1464 xWriteCode(uiNumbits, 32 );1465 }1466 else1467 {1468 printf("Error in codeSliceHeaderTable\n");1469 exit(-1);1470 }1471 }1472 }1473 #endif1474 1257 1475 1258 Void TEncCavlc::codeTerminatingBit ( UInt uilsLast ) … … 1481 1264 } 1482 1265 1483 #if H HI_INTER_VIEW_MOTION_PRED1266 #if H3D_IVMP 1484 1267 Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ) 1485 1268 #else … … 1510 1293 } 1511 1294 1512 #if H HI_INTER_VIEW_RESIDUAL_PRED1295 #if H3D_IVRP 1513 1296 Void 1514 1297 TEncCavlc::codeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) … … 1590 1373 } 1591 1374 1592 #if BURST_IPCM1593 1375 /** Code I_PCM information. 1594 1376 * \param pcCU pointer to CU … … 1602 1384 assert(0); 1603 1385 } 1604 #else1605 /** Code I_PCM information.1606 * \param pcCU pointer to CU1607 * \param uiAbsPartIdx CU index1608 * \returns Void1609 *1610 * If I_PCM flag indicates that the CU is I_PCM, code its PCM alignment bits and codes.1611 */1612 Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx)1613 {1614 UInt uiIPCM = (pcCU->getIPCMFlag(uiAbsPartIdx) == true)? 1 : 0;1615 1616 xWriteFlag(uiIPCM);1617 1618 if (uiIPCM)1619 {1620 xWritePCMAlignZero();1621 1622 UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight();1623 UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx;1624 UInt uiChromaOffset = uiLumaOffset>>2;1625 1626 Pel* piPCMSample;1627 UInt uiWidth;1628 UInt uiHeight;1629 UInt uiSampleBits;1630 UInt uiX, uiY;1631 1632 piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset;1633 uiWidth = pcCU->getWidth(uiAbsPartIdx);1634 uiHeight = pcCU->getHeight(uiAbsPartIdx);1635 uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();1636 1637 for(uiY = 0; uiY < uiHeight; uiY++)1638 {1639 for(uiX = 0; uiX < uiWidth; uiX++)1640 {1641 UInt uiSample = piPCMSample[uiX];1642 1643 xWriteCode(uiSample, uiSampleBits);1644 }1645 piPCMSample += uiWidth;1646 }1647 1648 piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset;1649 uiWidth = pcCU->getWidth(uiAbsPartIdx)/2;1650 uiHeight = pcCU->getHeight(uiAbsPartIdx)/2;1651 uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();1652 1653 for(uiY = 0; uiY < uiHeight; uiY++)1654 {1655 for(uiX = 0; uiX < uiWidth; uiX++)1656 {1657 UInt uiSample = piPCMSample[uiX];1658 1659 xWriteCode(uiSample, uiSampleBits);1660 }1661 piPCMSample += uiWidth;1662 }1663 1664 piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset;1665 uiWidth = pcCU->getWidth(uiAbsPartIdx)/2;1666 uiHeight = pcCU->getHeight(uiAbsPartIdx)/2;1667 uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();1668 1669 for(uiY = 0; uiY < uiHeight; uiY++)1670 {1671 for(uiX = 0; uiX < uiWidth; uiX++)1672 {1673 UInt uiSample = piPCMSample[uiX];1674 1675 xWriteCode(uiSample, uiSampleBits);1676 }1677 piPCMSample += uiWidth;1678 }1679 }1680 }1681 #endif1682 1386 1683 1387 Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx ) … … 1710 1414 Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); 1711 1415 1712 #if H0736_AVC_STYLE_QP_RANGE1713 1416 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); 1714 1417 iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); 1715 #endif1716 1418 1717 1419 xWriteSvlc( iDQp ); … … 1744 1446 xWriteSvlc( iCode ); 1745 1447 } 1746 #if LCU_SYNTAX_ALF1747 1448 /** Code the fixed length code (smaller than one max value) in OSALF 1748 1449 * \param idx: coded value … … 1769 1470 } 1770 1471 } 1771 #endif1772 1472 1773 1473 Void TEncCavlc::codeSaoFlag( UInt uiCode ) … … 1785 1485 xWriteSvlc( iCode ); 1786 1486 } 1787 #if SAO_UNIT_INTERLEAVING1788 1487 /** Code SAO run. 1789 1488 * \param uiCode … … 1809 1508 WRITE_CODE( uiCode, uiLength, "sao_run_diff"); 1810 1509 } 1811 #endif1812 1510 1813 1511 Void TEncCavlc::estBit( estBitsSbacStruct* pcEstBitsCabac, Int width, Int height, TextType eTType ) … … 2114 1812 Void TEncCavlc::xCodeScalingList(TComScalingList* scalingList, UInt sizeId, UInt listId) 2115 1813 { 2116 #if SCALING_LIST2117 1814 Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 2118 1815 UInt* scan = g_auiFrameScanXY [ (sizeId == 0)? 1 : 2]; 2119 #else2120 Int coefNum = (Int)g_scalingListSize[sizeId];2121 UInt* scan = g_auiFrameScanXY [ sizeId + 1];2122 #endif2123 1816 Int nextCoef = SCALING_LIST_START_VALUE; 2124 1817 Int data; 2125 1818 Int *src = scalingList->getScalingListAddress(sizeId, listId); 2126 #if SCALING_LIST2127 1819 if(sizeId > SCALING_LIST_8x8 && scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId)) 2128 1820 { … … 2155 1847 } 2156 1848 } 2157 #else2158 for(Int i=0;i<coefNum;i++)2159 {2160 data = src[scan[i]] - nextCoef;2161 nextCoef = src[scan[i]];2162 if(data > 127)2163 {2164 data = data - 256;2165 }2166 if(data < -128)2167 {2168 data = data + 256;2169 }2170 2171 WRITE_SVLC( data, "delta_coef");2172 }2173 #endif2174 1849 } 2175 1850 Bool TComScalingList::checkPredMode(UInt sizeId, UInt listId) … … 2177 1852 for(Int predListIdx = (Int)listId -1 ; predListIdx >= 0; predListIdx--) 2178 1853 { 2179 #if SCALING_LIST2180 1854 if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix 2181 1855 && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value 2182 #else2183 if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*(Int)g_scalingListSize[sizeId])) // check value of matrix2184 #endif2185 1856 { 2186 1857 setRefMatrixId(sizeId, listId, predListIdx); -
trunk/source/Lib/TLibEncoder/TEncCavlc.h
r210 r296 88 88 Void xWriteUnaryMaxSymbol ( UInt uiSymbol, UInt uiMaxSymbol ); 89 89 90 #if RPS_IN_SPS91 90 Void codeShortTermRefPicSet ( TComSPS* pcSPS, TComReferencePictureSet* pcRPS ); 92 #else93 Void codeShortTermRefPicSet ( TComPPS* pcPPS, TComReferencePictureSet* pcRPS );94 #endif95 91 96 92 UInt xConvertToUInt ( Int iValue ) { return ( iValue <= 0) ? -iValue<<1 : (iValue<<1)-1; } … … 118 114 #endif 119 115 120 #if HHI_MPI 116 #if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068 121 117 Void codeSPS ( TComSPS* pcSPS, Bool bIsDepth ); 122 118 #else … … 129 125 Void codeTileMarkerFlag(TComSlice* pcSlice); 130 126 131 #if TILES_WPP_ENTRY_POINT_SIGNALLING132 127 Void codeTilesWPPEntryPoint( TComSlice* pSlice ); 133 #else134 Void codeSliceHeaderSubstreamTable( TComSlice* pcSlice );135 #endif136 128 Void codeTerminatingBit ( UInt uilsLast ); 137 129 Void codeSliceFinish (); … … 139 131 Void encodeStart () {} 140 132 141 #if H HI_INTER_VIEW_MOTION_PRED133 #if H3D_IVMP 142 134 Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ); 143 135 #else … … 148 140 Void codeAlfSvlc ( Int iCode ); 149 141 Void codeAlfCtrlDepth(); 150 #if LCU_SYNTAX_ALF151 142 Void codeAPSAlflag(UInt uiCode); 152 143 Void codeAlfFixedLengthIdx( UInt idx, UInt numFilterSetsInBuffer); 153 #endif154 144 Void codeSaoFlag ( UInt uiCode ); 155 145 Void codeSaoUvlc ( UInt uiCode ); 156 146 Void codeSaoSvlc ( Int iCode ); 157 #if SAO_UNIT_INTERLEAVING158 147 Void codeSaoRun ( UInt uiCode, UInt maxValue ); 159 148 Void codeSaoMergeLeft ( UInt uiCode, UInt compIdx ){;} … … 161 150 Void codeSaoTypeIdx ( UInt uiCode ){ xWriteUvlc(uiCode );} 162 151 Void codeSaoUflc ( UInt uiCode ){ assert(uiCode < 32); xWriteCode(uiCode, 5);} 163 #endif164 152 165 153 Void codeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); … … 169 157 Void codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 170 158 Void codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 171 #if H HI_INTER_VIEW_RESIDUAL_PRED159 #if H3D_IVRP 172 160 Void codeResPredFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 173 161 #endif … … 189 177 Void codePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 190 178 191 #if BURST_IPCM192 179 Void codeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag); 193 #else194 Void codeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx );195 #endif196 180 197 181 Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ); -
trunk/source/Lib/TLibEncoder/TEncCfg.h
r210 r296 109 109 Int m_iSourceWidth; 110 110 Int m_iSourceHeight; 111 #if PIC_CROPPING112 111 Int m_croppingMode; 113 112 Int m_cropLeft; … … 115 114 Int m_cropTop; 116 115 Int m_cropBottom; 117 #endif118 116 Int m_iFrameToBeEncoded; 119 117 Double m_adLambdaModifier[ MAX_TLAYER ]; … … 125 123 GOPEntryMvc m_GOPList[MAX_GOP+1]; 126 124 Int m_extraRPSs; 127 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER128 125 Int m_maxDecPicBuffering[MAX_TLAYER]; 129 126 Int m_numReorderPics[MAX_TLAYER]; 130 #else131 Int m_maxNumberOfReferencePictures;132 Int m_numReorderFrames;133 #endif134 127 135 128 Int m_iQP; // if (AdaptiveQP == OFF) … … 142 135 // TODO: We need to have a common sliding mechanism used by both the encoder and decoder 143 136 144 #if H0566_TLA145 137 Int m_maxTempLayer; ///< Max temporal layer 146 #else147 Bool m_bTLayering; ///< indicates whether temporal IDs are set based on the hierarchical coding structure148 Bool m_abTLayerSwitchingFlag[MAX_TLAYER]; ///< temporal layer switching flags corresponding to temporal layer149 #endif150 138 Bool m_bDisInter4x4; 151 139 Bool m_useAMP; … … 163 151 Int m_loopFilterBetaOffsetDiv2; 164 152 Int m_loopFilterTcOffsetDiv2; 165 #if DBL_CONTROL166 153 Bool m_DeblockingFilterControlPresent; 167 #endif168 154 Bool m_bUseSAO; 169 155 #if LGE_ILLUCOMP_B0045 170 156 Bool m_bUseIC; 171 157 #endif 172 #if SAO_UNIT_INTERLEAVING 158 #if INTER_VIEW_VECTOR_SCALING_C0115 159 Bool m_bUseIVS; 160 #endif 173 161 Int m_maxNumOffsetsPerPic; 174 162 Bool m_saoInterleavingFlag; 175 #endif176 163 177 164 //====== Lossless ======== … … 229 216 230 217 Int m_iALFMaxNumberFilters; 231 #if LCU_SYNTAX_ALF232 218 Bool m_bALFParamInSlice; 233 219 Bool m_bALFPicBasedEncode; 234 #endif235 220 236 221 Bool m_bUseASR; … … 239 224 Bool m_bLCMod; 240 225 Bool m_bUseRDOQ; 241 #if !PIC_CROPPING242 Bool m_bUsePAD;243 #endif244 226 Bool m_bUseFastEnc; 245 227 Bool m_bUseEarlyCU; 246 228 247 #if FAST_DECISION_FOR_MRG_RD_COST248 229 Bool m_useFastDecisionForMerge; 249 #endif250 230 Bool m_bUseCbfFastMode; 251 231 Bool m_bUseLMChroma; … … 305 285 306 286 Bool m_bEnableTMVP; 307 #if MULTIBITS_DATA_HIDING308 287 Int m_signHideFlag; 309 288 Int m_signHidingThreshold; 310 #endif311 289 312 290 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 … … 349 327 #endif 350 328 351 #if H HI_INTER_VIEW_MOTION_PRED329 #if H3D_IVMP 352 330 UInt m_uiMultiviewMvPredMode; 353 331 UInt m_uiMultiviewMvRegMode; 354 332 Double m_dMultiviewMvRegLambdaScale; 355 333 #endif 356 #if H HI_INTER_VIEW_RESIDUAL_PRED334 #if H3D_IVRP 357 335 UInt m_uiMultiviewResPredMode; 358 336 #endif … … 383 361 Void setSourceWidth ( Int i ) { m_iSourceWidth = i; } 384 362 Void setSourceHeight ( Int i ) { m_iSourceHeight = i; } 385 #if PIC_CROPPING386 363 Void setCroppingMode ( Int i ) { m_croppingMode = i; } 387 364 Void setCropLeft ( Int i ) { m_cropLeft = i; } … … 389 366 Void setCropTop ( Int i ) { m_cropTop = i; } 390 367 Void setCropBottom ( Int i ) { m_cropBottom = i; } 391 #endif392 368 Void setFrameToBeEncoded ( Int i ) { m_iFrameToBeEncoded = i; } 393 369 … … 399 375 Void setExtraRPSs ( Int i ) { m_extraRPSs = i; } 400 376 GOPEntryMvc getGOPEntry ( Int i ) { return m_GOPList[i]; } 401 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER402 377 Void setMaxDecPicBuffering ( UInt u, UInt tlayer ) { m_maxDecPicBuffering[tlayer] = u; } 403 378 Void setNumReorderPics ( Int i, UInt tlayer ) { m_numReorderPics[tlayer] = i; } 404 #else405 Void setMaxNumberOfReferencePictures ( Int u ) { m_maxNumberOfReferencePictures = u; }406 Void setNumReorderFrames ( Int i ) { m_numReorderFrames = i; }407 #endif408 379 409 380 #if HHI_INTERVIEW_SKIP … … 423 394 Void setMaxRefPicNum ( Int iMaxRefPicNum ) { m_iMaxRefPicNum = iMaxRefPicNum; } 424 395 425 #if H0566_TLA426 396 Bool getMaxTempLayer () { return m_maxTempLayer; } 427 397 Void setMaxTempLayer ( Int maxTempLayer ) { m_maxTempLayer = maxTempLayer; } 428 #else429 Bool getTLayering () { return m_bTLayering; }430 Void setTLayering ( Bool bTLayering ) { m_bTLayering = bTLayering; }431 Bool getTLayerSwitchingFlag ( UInt uiTLayer ) { assert (uiTLayer < MAX_TLAYER ); return m_abTLayerSwitchingFlag[uiTLayer]; }432 Void setTLayerSwitchingFlag ( Bool* pbTLayerSwitchingFlag ) { for ( Int i = 0; i < MAX_TLAYER; i++ ) m_abTLayerSwitchingFlag[i] = pbTLayerSwitchingFlag[i]; }433 #endif434 398 435 399 Bool getDisInter4x4 () { return m_bDisInter4x4; } … … 444 408 #endif 445 409 446 #if H HI_INTER_VIEW_MOTION_PRED410 #if H3D_IVMP 447 411 Void setMultiviewMvPredMode ( UInt u ) { m_uiMultiviewMvPredMode = u; } 448 412 Void setMultiviewMvRegMode ( UInt u ) { m_uiMultiviewMvRegMode = u; } 449 413 Void setMultiviewMvRegLambdaScale ( Double d) { m_dMultiviewMvRegLambdaScale = d; } 450 414 #endif 451 #if H HI_INTER_VIEW_RESIDUAL_PRED415 #if H3D_IVRP 452 416 Void setMultiviewResPredMode ( UInt u ) { m_uiMultiviewResPredMode = u; } 453 417 #endif … … 467 431 Void setLoopFilterBetaOffset ( Int i ) { m_loopFilterBetaOffsetDiv2 = i; } 468 432 Void setLoopFilterTcOffset ( Int i ) { m_loopFilterTcOffsetDiv2 = i; } 469 #if DBL_CONTROL470 433 Void setDeblockingFilterControlPresent ( Bool b ) { m_DeblockingFilterControlPresent = b; } 471 #endif472 434 473 435 //====== Motion search ======== … … 479 441 Void setVerticalDisparitySearchRange ( Int i ) { m_iVerticalDisparitySearchRange = i; } 480 442 #endif 481 #if H HI_INTER_VIEW_MOTION_PRED443 #if H3D_IVMP 482 444 UInt getMultiviewMvRegMode () { return m_uiMultiviewMvRegMode; } 483 445 Double getMultiviewMvRegLambdaScale () { return m_dMultiviewMvRegLambdaScale; } … … 524 486 Int getSourceWidth () { return m_iSourceWidth; } 525 487 Int getSourceHeight () { return m_iSourceHeight; } 526 #if PIC_CROPPING527 488 Int getCroppingMode () { return m_croppingMode; } 528 489 Int getCropLeft () { return m_cropLeft; } … … 530 491 Int getCropTop () { return m_cropTop; } 531 492 Int getCropBottom () { return m_cropBottom; } 532 #endif533 493 Int getFrameToBeEncoded () { return m_iFrameToBeEncoded; } 534 494 void setLambdaModifier ( UInt uiIndex, Double dValue ) { m_adLambdaModifier[ uiIndex ] = dValue; } … … 539 499 UInt getDecodingRefreshType () { return m_uiDecodingRefreshType; } 540 500 Int getGOPSize () { return m_iGOPSize; } 541 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER542 501 Int getMaxDecPicBuffering (UInt tlayer) { return m_maxDecPicBuffering[tlayer]; } 543 502 Int getNumReorderPics (UInt tlayer) { return m_numReorderPics[tlayer]; } 544 #else545 Int getMaxNumberOfReferencePictures () { return m_maxNumberOfReferencePictures; }546 Int geNumReorderFrames () { return m_numReorderFrames; }547 #endif548 503 Int getQP () { return m_iQP; } 549 504 … … 562 517 Int getLoopFilterBetaOffset () { return m_loopFilterBetaOffsetDiv2; } 563 518 Int getLoopFilterTcOffset () { return m_loopFilterTcOffsetDiv2; } 564 #if DBL_CONTROL565 519 Bool getDeblockingFilterControlPresent() { return m_DeblockingFilterControlPresent; } 566 #endif567 520 568 521 //==== Motion search ======== … … 607 560 Void setLCMod ( Bool b ) { m_bLCMod = b; } 608 561 Void setUseRDOQ ( Bool b ) { m_bUseRDOQ = b; } 609 #if !PIC_CROPPING610 Void setUsePAD ( Bool b ) { m_bUsePAD = b; }611 #endif612 562 #if HHI_VSO 613 563 Void setUseVSO ( Bool b ) { m_bUseVSO = b; } … … 621 571 Void setUseFastEnc ( Bool b ) { m_bUseFastEnc = b; } 622 572 Void setUseEarlyCU ( Bool b ) { m_bUseEarlyCU = b; } 623 #if FAST_DECISION_FOR_MRG_RD_COST624 573 Void setUseFastDecisionForMerge ( Bool b ) { m_useFastDecisionForMerge = b; } 625 #endif626 574 Void setUseCbfFastMode ( Bool b ) { m_bUseCbfFastMode = b; } 627 575 Void setUseConstrainedIntraPred ( Bool b ) { m_bUseConstrainedIntraPred = b; } … … 642 590 Void setALFMaxNumberFilters (Int i) { m_iALFMaxNumberFilters = i; } 643 591 Int getALFMaxNumberFilters () { return m_iALFMaxNumberFilters; } 644 #if LCU_SYNTAX_ALF645 592 Void setALFParamInSlice (Bool b) {m_bALFParamInSlice = b;} 646 593 Bool getALFParamInSlice () {return m_bALFParamInSlice;} 647 594 Void setALFPicBasedEncode (Bool b) {m_bALFPicBasedEncode = b;} 648 595 Bool getALFPicBasedEncode () {return m_bALFPicBasedEncode;} 649 #endif650 596 651 597 Bool getUseLComb () { return m_bUseLComb; } 652 598 Bool getLCMod () { return m_bLCMod; } 653 599 Bool getUseRDOQ () { return m_bUseRDOQ; } 654 #if !PIC_CROPPING655 Bool getUsePAD () { return m_bUsePAD; }656 #endif657 600 658 601 #if HHI_VSO … … 666 609 Bool getUseFastEnc () { return m_bUseFastEnc; } 667 610 Bool getUseEarlyCU () { return m_bUseEarlyCU; } 668 #if FAST_DECISION_FOR_MRG_RD_COST669 611 Bool getUseFastDecisionForMerge () { return m_useFastDecisionForMerge; } 670 #endif671 612 Bool getUseCbfFastMode () { return m_bUseCbfFastMode; } 672 613 Bool getUseConstrainedIntraPred () { return m_bUseConstrainedIntraPred; } … … 714 655 Bool getUseIC () {return m_bUseIC;} 715 656 #endif 716 #if SAO_UNIT_INTERLEAVING 657 #if INTER_VIEW_VECTOR_SCALING_C0115 658 Void setUseIVS ( Bool bVal ) {m_bUseIVS = bVal;} 659 Bool getUseIVS () {return m_bUseIVS;} 660 #endif 717 661 Void setMaxNumOffsetsPerPic (Int iVal) { m_maxNumOffsetsPerPic = iVal; } 718 662 Int getMaxNumOffsetsPerPic () { return m_maxNumOffsetsPerPic; } 719 663 Void setSaoInterleavingFlag (bool bVal) { m_saoInterleavingFlag = bVal; } 720 664 Bool getSaoInterleavingFlag () { return m_saoInterleavingFlag; } 721 #endif722 665 Void setTileBehaviorControlPresentFlag ( Int i ) { m_iTileBehaviorControlPresentFlag = i; } 723 666 Int getTileBehaviorControlPresentFlag () { return m_iTileBehaviorControlPresentFlag; } … … 728 671 Void setUniformSpacingIdr ( Int i ) { m_iUniformSpacingIdr = i; } 729 672 Int getUniformSpacingIdr () { return m_iUniformSpacingIdr; } 730 #if !REMOVE_TILE_DEPENDENCE731 Void setTileBoundaryIndependenceIdr ( Int i ) { m_iTileBoundaryIndependenceIdr = i; }732 Int getTileBoundaryIndependenceIdr () { return m_iTileBoundaryIndependenceIdr; }733 #endif734 673 Void setNumColumnsMinus1 ( Int i ) { m_iNumColumnsMinus1 = i; } 735 674 Int getNumColumnsMinus1 () { return m_iNumColumnsMinus1; } … … 827 766 Void setEnableTMVP ( Bool b ) { m_bEnableTMVP = b; } 828 767 Bool getEnableTMVP () { return m_bEnableTMVP; } 829 #if MULTIBITS_DATA_HIDING830 768 Void setSignHideFlag( Int signHideFlag ) { m_signHideFlag = signHideFlag; } 831 769 Void setTSIG( Int tsig ) { m_signHidingThreshold = tsig; } 832 770 Int getSignHideFlag() { return m_signHideFlag; } 833 771 Int getTSIG() { return m_signHidingThreshold; } 834 #endif835 772 #if VIDYO_VPS_INTEGRATION |QC_MVHEVC_B0046 836 773 Void setLayerId ( UInt layerId ) { m_layerId = layerId; } … … 869 806 Void setCodedOffset ( Int** p ) { m_aaiCodedOffset = p; } 870 807 871 #if SONY_COLPIC_AVAILABILITY872 Int getViewOrderIdx () { return m_iViewOrderIdx; } 808 #if INTER_VIEW_VECTOR_SCALING_C0115 809 Int getViewOrderIdx () { return m_iViewOrderIdx; } // will be changed to view_id 873 810 #endif 874 811 }; -
trunk/source/Lib/TLibEncoder/TEncCu.cpp
r189 r296 72 72 m_ppcRecoYuvTemp = new TComYuv*[m_uhTotalDepth-1]; 73 73 m_ppcOrigYuv = new TComYuv*[m_uhTotalDepth-1]; 74 #if H HI_INTER_VIEW_RESIDUAL_PRED74 #if H3D_IVRP 75 75 m_ppcResPredTmp = new TComYuv*[m_uhTotalDepth-1]; 76 76 #endif … … 101 101 102 102 m_ppcOrigYuv [i] = new TComYuv; m_ppcOrigYuv [i]->create(uiWidth, uiHeight); 103 #if H HI_INTER_VIEW_RESIDUAL_PRED103 #if H3D_IVRP 104 104 m_ppcResPredTmp [i] = new TComYuv; m_ppcResPredTmp [i]->create(uiWidth, uiHeight); 105 105 #endif … … 107 107 108 108 m_bEncodeDQP = false; 109 #if BURST_IPCM110 109 m_checkBurstIPCMFlag = false; 111 #endif112 110 113 111 // initialize partition order. … … 168 166 m_ppcOrigYuv[i]->destroy(); delete m_ppcOrigYuv[i]; m_ppcOrigYuv[i] = NULL; 169 167 } 170 #if H HI_INTER_VIEW_RESIDUAL_PRED168 #if H3D_IVRP 171 169 if(m_ppcResPredTmp[i]) 172 170 { … … 221 219 m_ppcOrigYuv = NULL; 222 220 } 223 #if H HI_INTER_VIEW_RESIDUAL_PRED221 #if H3D_IVRP 224 222 if(m_ppcResPredTmp) 225 223 { … … 285 283 } 286 284 287 #if BURST_IPCM288 285 TComPic* pcPic = pcCU->getPic(); 289 286 Bool checkBurstIPCMFlag = (pcPic->getSlice(0)->getSPS()->getUsePCM())? true : false; … … 293 290 pcCU->setNumSucIPCM(0); 294 291 pcCU->setLastCUSucIPCMFlag(false); 295 #endif296 292 297 293 // Encode CU data 298 294 xEncodeCU( pcCU, 0, 0 ); 299 295 300 #if OL_FLUSH301 296 bool bTerminateSlice = bForceTerminate; 302 297 UInt uiCUAddr = pcCU->getAddr(); 303 298 /* If at the end of an LCU line but not at the end of a substream, perform CABAC flush */ 304 #if WPP_SIMPLIFICATION305 299 if (!bTerminateSlice && pcCU->getSlice()->getPPS()->getNumSubstreams() > 1) 306 #else307 if (!bTerminateSlice && pcCU->getSlice()->getPPS()->getCabacIstateReset())308 #endif309 300 { 310 301 Int iNumSubstreams = pcCU->getSlice()->getPPS()->getNumSubstreams(); … … 312 303 UInt uiCol = uiCUAddr % uiWidthInLCUs; 313 304 UInt uiLin = uiCUAddr / uiWidthInLCUs; 314 #if !REMOVE_TILE_DEPENDENCE315 Int iBreakDep = pcCU->getPic()->getPicSym()->getTileBoundaryIndependenceIdr();316 #endif317 305 UInt uiTileStartLCU = pcCU->getPic()->getPicSym()->getTComTile(pcCU->getPic()->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); 318 306 UInt uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; … … 321 309 UInt uiTileHeight = pcCU->getPic()->getPicSym()->getTComTile(pcCU->getPic()->getPicSym()->getTileIdxMap(uiCUAddr))->getTileHeight(); 322 310 Int iNumSubstreamsPerTile = iNumSubstreams; 323 #if !REMOVE_TILE_DEPENDENCE 324 #if WPP_SIMPLIFICATION 325 if (iBreakDep && pcCU->getSlice()->getPPS()->getNumSubstreams() > 1) 326 #else 327 if (iBreakDep && pcCU->getSlice()->getPPS()->getEntropyCodingSynchro()) 328 #endif 311 if (pcCU->getSlice()->getPPS()->getNumSubstreams() > 1) 312 { 329 313 iNumSubstreamsPerTile /= pcCU->getPic()->getPicSym()->getNumTiles(); 330 if ((iBreakDep && (uiCol == uiTileLCUX+uiTileWidth-1) && (uiLin+iNumSubstreamsPerTile < uiTileLCUY+uiTileHeight))331 || (!iBreakDep && (uiCol == uiWidthInLCUs-1) && (uiLin+iNumSubstreams < pcCU->getPic()->getFrameHeightInCU())))314 } 315 if ((uiCol == uiTileLCUX+uiTileWidth-1) && (uiLin+iNumSubstreamsPerTile < uiTileLCUY+uiTileHeight)) 332 316 { 333 317 m_pcEntropyCoder->encodeFlush(); 334 318 } 335 #else 336 #if WPP_SIMPLIFICATION 337 if (pcCU->getSlice()->getPPS()->getNumSubstreams() > 1) 338 #else 339 if (pcCU->getSlice()->getPPS()->getEntropyCodingSynchro()) 340 #endif 341 { 342 iNumSubstreamsPerTile /= pcCU->getPic()->getPicSym()->getNumTiles(); 343 } 344 if ((uiCol == uiTileLCUX+uiTileWidth-1) && (uiLin+iNumSubstreamsPerTile < uiTileLCUY+uiTileHeight)) 345 { 346 m_pcEntropyCoder->encodeFlush(); 347 } 348 #endif 349 } 350 #endif // OL_FLUSH 319 } 351 320 } 352 321 … … 458 427 Bool bIntraSliceDetect = (rpcBestCU->getSlice()->getSliceType() == I_SLICE); 459 428 429 #if HHI_QTLPC_RAU_OFF_C0160 430 Bool rapPic = (rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); 431 #endif 432 460 433 Bool bTry2NxN = true; 461 434 Bool bTryNx2N = true; … … 494 467 495 468 #if LGE_ILLUCOMP_B0045 496 Bool bICEnabled = (!rpcTempCU->getSlice()->getIsDepth() && rpcTempCU->getSlice()->getViewId()); 469 Bool bICEnabled = ( 470 #if !LGE_ILLUCOMP_DEPTH_C0046 471 !rpcTempCU->getSlice()->getIsDepth() && 472 #endif 473 rpcTempCU->getSlice()->getViewId()); 497 474 498 475 bICEnabled = bICEnabled && rpcTempCU->getSlice()->getApplyIC(); … … 548 525 #if LOSSLESS_CODING 549 526 Bool isAddLowestQP = false; 550 #if H0736_AVC_STYLE_QP_RANGE551 527 Int lowestQP = -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(); 552 #else553 Int lowestQP = 0;554 #endif555 528 #endif 556 529 … … 558 531 { 559 532 Int idQP = m_pcEncCfg->getMaxDeltaQP(); 560 #if H0736_AVC_STYLE_QP_RANGE561 533 iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); 562 534 iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); … … 568 540 569 541 } 570 #endif571 #else572 iMinQP = Clip3( MIN_QP, MAX_QP, iBaseQP-idQP );573 iMaxQP = Clip3( MIN_QP, MAX_QP, iBaseQP+idQP );574 #if LOSSLESS_CODING575 if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() )576 {577 isAddLowestQP = true;578 iMinQP = iMinQP - 1;579 }580 #endif581 542 #endif 582 543 } … … 612 573 #if OL_QTLIMIT_PREDCODING_B0068 613 574 //logic for setting bTrySplit using the partition information that is stored of the texture colocated CU 575 576 #if HHI_QTLPC_RAU_OFF_C0160 577 if(depthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTLPC()) 578 #else 614 579 if(depthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC()) 580 #endif 615 581 { 616 582 TComDataCU* pcTextureCU = pcTexture->getCU( rpcBestCU->getAddr() ); //Corresponding texture LCU … … 635 601 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) 636 602 { 637 #if HHI_INTER_VIEW_RESIDUAL_PRED 603 #if H3D_IVRP 604 #if MTK_MDIVRP_C0138 605 Bool bResPredAvailable = false; 606 UInt uiResPrdId = 0; 607 #else 638 608 // check availability of residual prediction 639 609 Bool bResPredAvailable = false; … … 643 613 if( bResPredAllowed ) 644 614 { 645 bResPredAvailable = rpcBestCU->getResidualSamples( 0, 646 #if QC_SIMPLIFIEDIVRP_M24938 647 true , 648 #endif 649 m_ppcResPredTmp[uiDepth] ); 615 bResPredAvailable = rpcBestCU->getResidualSamples( 0, true , m_ppcResPredTmp[uiDepth] ); 650 616 } 651 617 652 618 for( UInt uiResPrdId = 0; uiResPrdId < ( bResPredAvailable ? 2 : 1 ); uiResPrdId++ ) 619 #endif 653 620 { 654 621 Bool bResPredFlag = ( uiResPrdId > 0 ); … … 660 627 #endif 661 628 #endif 662 #if H HI_INTER_VIEW_RESIDUAL_PRED629 #if H3D_IVRP 663 630 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 664 631 #endif … … 691 658 if ( !bEarlySkip ) 692 659 { 693 #if H HI_INTER_VIEW_RESIDUAL_PRED660 #if H3D_IVRP 694 661 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 662 #endif 663 #if FIX_LGE_ILLUCOMP_B0045 664 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 695 665 #endif 696 666 #if HHI_INTERVIEW_SKIP … … 709 679 } 710 680 #endif 711 #if H HI_INTER_VIEW_RESIDUAL_PRED681 #if H3D_IVRP 712 682 } // uiResPrdId 713 683 #endif … … 719 689 720 690 #if OL_QTLIMIT_PREDCODING_B0068 691 692 #if HHI_QTLPC_RAU_OFF_C0160 693 if(depthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTLPC()) 694 #else 721 695 if(depthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC()) 696 #endif 722 697 { 723 698 bTrySplitDQP = bTrySplit; … … 763 738 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) 764 739 { 765 #if HHI_INTER_VIEW_RESIDUAL_PRED 740 #if H3D_IVRP 741 #if MTK_MDIVRP_C0138 742 Bool bResPredAvailable = false; 743 UInt uiResPrdId = 0; 744 #else 766 745 // check availability of residual prediction 767 746 Bool bResPredAvailable = false; … … 771 750 if( bResPredAllowed ) 772 751 { 773 bResPredAvailable = rpcBestCU->getResidualSamples( 0, 774 #if QC_SIMPLIFIEDIVRP_M24938 775 true, 776 #endif 777 m_ppcResPredTmp[uiDepth] ); 752 bResPredAvailable = rpcBestCU->getResidualSamples( 0, true, m_ppcResPredTmp[uiDepth] ); 778 753 } 779 754 780 755 for( UInt uiResPrdId = 0; uiResPrdId < ( bResPredAvailable ? 2 : 1 ); uiResPrdId++ ) 756 #endif 781 757 { 782 758 Bool bResPredFlag = ( uiResPrdId > 0 ); … … 800 776 { 801 777 #endif 802 #if H HI_INTER_VIEW_RESIDUAL_PRED778 #if H3D_IVRP 803 779 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 804 780 #endif … … 823 799 if(doNotBlockPu) 824 800 { 825 #if H HI_INTER_VIEW_RESIDUAL_PRED801 #if H3D_IVRP 826 802 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 803 #endif 804 #if FIX_LGE_ILLUCOMP_B0045 805 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 827 806 #endif 828 807 #if HHI_INTERVIEW_SKIP … … 847 826 if(doNotBlockPu) 848 827 { 849 #if H HI_INTER_VIEW_RESIDUAL_PRED828 #if H3D_IVRP 850 829 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 830 #endif 831 #if FIX_LGE_ILLUCOMP_B0045 832 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 851 833 #endif 852 834 #if HHI_INTERVIEW_SKIP … … 890 872 if(doNotBlockPu) 891 873 { 892 #if H HI_INTER_VIEW_RESIDUAL_PRED874 #if H3D_IVRP 893 875 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 876 #endif 877 #if FIX_LGE_ILLUCOMP_B0045 878 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 894 879 #endif 895 880 #if HHI_INTERVIEW_SKIP … … 906 891 if(doNotBlockPu) 907 892 { 908 #if H HI_INTER_VIEW_RESIDUAL_PRED893 #if H3D_IVRP 909 894 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 895 #endif 896 #if FIX_LGE_ILLUCOMP_B0045 897 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 910 898 #endif 911 899 #if HHI_INTERVIEW_SKIP … … 933 921 if(doNotBlockPu) 934 922 { 935 #if H HI_INTER_VIEW_RESIDUAL_PRED923 #if H3D_IVRP 936 924 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 925 #endif 926 #if FIX_LGE_ILLUCOMP_B0045 927 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 937 928 #endif 938 929 #if HHI_INTERVIEW_SKIP … … 949 940 if(doNotBlockPu) 950 941 { 951 #if H HI_INTER_VIEW_RESIDUAL_PRED942 #if H3D_IVRP 952 943 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 944 #endif 945 #if FIX_LGE_ILLUCOMP_B0045 946 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 953 947 #endif 954 948 #if HHI_INTERVIEW_SKIP … … 978 972 if(doNotBlockPu) 979 973 { 980 #if H HI_INTER_VIEW_RESIDUAL_PRED974 #if H3D_IVRP 981 975 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 976 #endif 977 #if FIX_LGE_ILLUCOMP_B0045 978 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 982 979 #endif 983 980 #if HHI_INTERVIEW_SKIP … … 994 991 if(doNotBlockPu) 995 992 { 996 #if H HI_INTER_VIEW_RESIDUAL_PRED993 #if H3D_IVRP 997 994 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 995 #endif 996 #if FIX_LGE_ILLUCOMP_B0045 997 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 998 998 #endif 999 999 #if HHI_INTERVIEW_SKIP … … 1017 1017 if(doNotBlockPu) 1018 1018 { 1019 #if H HI_INTER_VIEW_RESIDUAL_PRED1019 #if H3D_IVRP 1020 1020 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 1021 #endif 1022 #if FIX_LGE_ILLUCOMP_B0045 1023 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 1021 1024 #endif 1022 1025 #if HHI_INTERVIEW_SKIP … … 1033 1036 if(doNotBlockPu) 1034 1037 { 1035 #if H HI_INTER_VIEW_RESIDUAL_PRED1038 #if H3D_IVRP 1036 1039 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 1040 #endif 1041 #if FIX_LGE_ILLUCOMP_B0045 1042 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 1037 1043 #endif 1038 1044 #if HHI_INTERVIEW_SKIP … … 1050 1056 1051 1057 #else 1052 #if H HI_INTER_VIEW_RESIDUAL_PRED1058 #if H3D_IVRP 1053 1059 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 1054 1060 #endif … … 1059 1065 #endif 1060 1066 rpcTempCU->initEstData( uiDepth, iQP ); 1061 #if H HI_INTER_VIEW_RESIDUAL_PRED1067 #if H3D_IVRP 1062 1068 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 1063 1069 #endif … … 1068 1074 #endif 1069 1075 rpcTempCU->initEstData( uiDepth, iQP ); 1070 #if H HI_INTER_VIEW_RESIDUAL_PRED1076 #if H3D_IVRP 1071 1077 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 1072 1078 #endif … … 1077 1083 #endif 1078 1084 rpcTempCU->initEstData( uiDepth, iQP ); 1079 #if H HI_INTER_VIEW_RESIDUAL_PRED1085 #if H3D_IVRP 1080 1086 rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); 1081 1087 #endif … … 1093 1099 } 1094 1100 #endif 1095 #if H HI_INTER_VIEW_RESIDUAL_PRED1101 #if H3D_IVRP 1096 1102 } // uiResPrdId 1097 1103 #endif … … 1103 1109 1104 1110 // do normal intra modes 1105 if ( !bEarlySkip ) 1111 if ( !bEarlySkip 1112 #if HHI_DEPTH_INTRA_SEARCH_RAU_C0160 1113 || ((rpcBestCU->getSlice()->getIsDepth() == true) && (rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) 1114 #endif 1115 ) 1106 1116 { 1107 1117 // speedup for inter frames … … 1110 1120 rpcBestCU->getCbf( 0, TEXT_LUMA ) != 0 || 1111 1121 rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0 || 1112 rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0 ) && !bFullyRenderedSec ) // avoid very complex intra if it is unlikely 1122 rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0 1123 #if HHI_DEPTH_INTRA_SEARCH_RAU_C0160 1124 || ((rpcBestCU->getSlice()->getIsDepth() == true) && (rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) 1125 #endif 1126 ) && !bFullyRenderedSec ) // avoid very complex intra if it is unlikely 1113 1127 #else 1114 1128 if( rpcBestCU->getSlice()->getSliceType() == I_SLICE || 1115 1129 rpcBestCU->getCbf( 0, TEXT_LUMA ) != 0 || 1116 1130 rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0 || 1117 rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0 ) // avoid very complex intra if it is unlikely 1131 rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0 1132 #if HHI_DEPTH_INTRA_SEARCH_RAU_C0160 1133 || ((rpcBestCU->getSlice()->getIsDepth() == true) && (rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) 1134 #endif 1135 ) // avoid very complex intra if it is unlikely 1118 1136 #endif 1119 1137 { … … 1168 1186 if( rpcBestCU->getSlice()->getSPS()->getUseMVI() && rpcBestCU->getSlice()->getSliceType() != I_SLICE ) 1169 1187 { 1188 #if LGE_ILLUCOMP_DEPTH_C0046 1189 for(UInt uiICId = 0; uiICId < (bICEnabled ? 2 : 1); uiICId++) 1190 { 1191 Bool bICFlag = (uiICId ? true : false); 1192 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 1193 #endif 1170 1194 xCheckRDCostMvInheritance( rpcBestCU, rpcTempCU, uiDepth, false, false ); 1171 1195 rpcTempCU->initEstData( uiDepth, iQP ); 1196 #if FIX_ILLUCOMP_DEPTH 1197 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 1198 #endif 1172 1199 xCheckRDCostMvInheritance( rpcBestCU, rpcTempCU, uiDepth, true, false ); 1173 1200 rpcTempCU->initEstData( uiDepth, iQP ); 1201 #if LGE_ILLUCOMP_DEPTH_C0046 1202 } 1203 #endif 1174 1204 } 1175 1205 #endif … … 1240 1270 { 1241 1271 Int idQP = m_pcEncCfg->getMaxDeltaQP(); 1242 #if H0736_AVC_STYLE_QP_RANGE1243 1272 iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); 1244 1273 iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); … … 1249 1278 iMinQP = iMinQP - 1; 1250 1279 } 1251 #endif1252 #else1253 iMinQP = Clip3( MIN_QP, MAX_QP, iBaseQP-idQP );1254 iMaxQP = Clip3( MIN_QP, MAX_QP, iBaseQP+idQP );1255 #if LOSSLESS_CODING1256 if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() )1257 {1258 isAddLowestQP = true;1259 iMinQP = iMinQP - 1;1260 }1261 #endif1262 1280 #endif 1263 1281 } … … 1558 1576 &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)); 1559 1577 1560 #if BURST_IPCM1561 1578 if(granularityBoundary && (!(pcCU->getIPCMFlag(uiAbsPartIdx) && ( pcCU->getNumSucIPCM() > 1 )))) 1562 #else1563 if(granularityBoundary)1564 #endif1565 1579 { 1566 1580 // The 1-terminating bit is added to all streams, so don't add it here when it's 1. … … 1654 1668 iQpOffset = Int(floor( dQpOffset + 0.49999 )); 1655 1669 } 1656 #if H0736_AVC_STYLE_QP_RANGE1657 1670 return Clip3(-pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQp+iQpOffset ); 1658 #else1659 return Clip3( MIN_QP, MAX_QP, iBaseQp+iQpOffset );1660 #endif1661 1671 } 1662 1672 … … 1677 1687 UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; 1678 1688 1679 #if BURST_IPCM1680 1689 if( getCheckBurstIPCMFlag() ) 1681 1690 { … … 1683 1692 pcCU->setNumSucIPCM( countNumSucIPCM ( pcCU, uiAbsPartIdx ) ); 1684 1693 } 1685 #endif1686 1694 1687 1695 TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); … … 1728 1736 { 1729 1737 m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx, 0 ); 1738 #if LGE_ILLUCOMP_DEPTH_C0046 1739 m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx, false, uiDepth ); 1740 #endif 1730 1741 finishCU(pcCU,uiAbsPartIdx,uiDepth); 1731 1742 xRestoreDepthWidthHeight( pcCU ); … … 1739 1750 // prediction Info ( Intra : direction mode, Inter : Mv, reference idx ) 1740 1751 m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx ); 1752 #if LGE_ILLUCOMP_DEPTH_C0046 1753 m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx, false, uiDepth ); 1754 #endif 1741 1755 xRestoreDepthWidthHeight( pcCU ); 1742 1756 } … … 1750 1764 setdQPFlag(true); 1751 1765 } 1752 #if BURST_IPCM1753 1766 pcCU->setNumSucIPCM(0); 1754 1767 pcCU->setLastCUSucIPCMFlag(false); 1755 #endif1756 1768 for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx+=uiQNumParts ) 1757 1769 { … … 1787 1799 m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx, 0 ); 1788 1800 #if LGE_ILLUCOMP_B0045 1789 m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx ); 1790 #endif 1791 #if HHI_INTER_VIEW_RESIDUAL_PRED 1801 m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx 1802 #if LGE_ILLUCOMP_DEPTH_C0046 1803 , false, uiDepth 1804 #endif 1805 ); 1806 #endif 1807 #if H3D_IVRP && !MTK_MDIVRP_C0138 1792 1808 m_pcEntropyCoder->encodeResPredFlag( pcCU, uiAbsPartIdx, 0 ); 1793 1809 #endif … … 1818 1834 m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx ); 1819 1835 #if LGE_ILLUCOMP_B0045 1820 m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx ); 1821 #endif 1822 #if HHI_INTER_VIEW_RESIDUAL_PRED 1836 m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx 1837 #if LGE_ILLUCOMP_DEPTH_C0046 1838 ,false, uiDepth 1839 #endif 1840 ); 1841 #endif 1842 #if H3D_IVRP && !MTK_MDIVRP_C0138 1823 1843 if( !pcCU->isIntra( uiAbsPartIdx ) ) 1824 1844 { … … 1851 1871 { 1852 1872 assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE ); 1853 #if H HI_INTER_VIEW_MOTION_PRED1873 #if H3D_IVMP 1854 1874 TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists 1855 1875 UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; … … 1860 1880 Int numValidMergeCand = 0; 1861 1881 1862 #if H HI_INTER_VIEW_RESIDUAL_PRED1882 #if H3D_IVRP && !MTK_MDIVRP_C0138 1863 1883 Bool bResPrdAvail = rpcTempCU->getResPredAvail( 0 ); 1864 1884 Bool bResPrdFlag = rpcTempCU->getResPredFlag ( 0 ); … … 1868 1888 #endif 1869 1889 1870 #if H HI_INTER_VIEW_MOTION_PRED1890 #if H3D_IVMP 1871 1891 for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ++ui ) 1872 1892 #else … … 1890 1910 1891 1911 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level 1892 rpcTempCU->getInterMergeCandidates( 0, 0, uhDepth, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); 1893 1894 #if FAST_DECISION_FOR_MRG_RD_COST 1912 #if MERL_VSP_C0152 1913 Int iVSPIndexTrue[3] = {-1, -1, -1}; 1914 rpcTempCU->getInterMergeCandidates( 0, 0, uhDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, iVSPIndexTrue ); 1915 #else 1916 rpcTempCU->getInterMergeCandidates( 0, 0, uhDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); 1917 #endif 1918 #if MTK_MDIVRP_C0138 1919 Bool bResPredAvail = rpcTempCU->getResPredAvail(0); 1920 #endif 1921 1895 1922 Bool bestIsSkip = false; 1896 #endif1897 1923 1898 1924 for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand ) … … 1924 1950 #endif 1925 1951 { 1926 #if FAST_DECISION_FOR_MRG_RD_COST1927 1952 if( !(bestIsSkip && uiNoResidual == 0) ) 1928 1953 { 1929 #endif1930 1954 // set MC parameters 1931 1955 rpcTempCU->setPredModeSubParts( MODE_SKIP, 0, uhDepth ); // interprets depth relative to LCU level … … 1933 1957 rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level 1934 1958 rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to LCU level 1959 #if MERL_VSP_C0152 1960 { 1961 Int iVSPIdx = 0; 1962 Int numVSPIdx; 1963 numVSPIdx = 3; 1964 for (Int i = 0; i < numVSPIdx; i++) 1965 { 1966 if (iVSPIndexTrue[i] == uiMergeCand) 1967 { 1968 iVSPIdx = i+1; 1969 break; 1970 } 1971 } 1972 rpcTempCU->setVSPIndexSubParts( iVSPIdx, 0, 0, uhDepth ); 1973 } 1974 #endif 1935 1975 rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level 1936 1976 rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level 1937 1977 rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level 1938 1978 1939 #if HHI_INTER_VIEW_RESIDUAL_PRED 1979 #if H3D_IVRP 1980 #if MTK_MDIVRP_C0138 1981 rpcTempCU->setResPredAvailSubParts(bResPredAvail, 0, 0, uhDepth); 1982 #else 1940 1983 rpcTempCU->setResPredAvailSubParts( bResPrdAvail, 0, 0, uhDepth ); 1941 1984 rpcTempCU->setResPredFlagSubParts ( bResPrdFlag, 0, 0, uhDepth ); 1985 #endif 1942 1986 #endif 1943 1987 #if LGE_ILLUCOMP_B0045 … … 1952 1996 #endif 1953 1997 { 1998 #if MERL_VSP_C0152 1999 m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth], rpcTempCU->getZorderIdxInCU() ); 2000 #else 1954 2001 m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); 2002 #endif 2003 #if MTK_MDIVRP_C0138 2004 if (uiMergeCand == 0 && rpcTempCU->getResPredAvail(0)) 2005 { 2006 m_pcPredSearch->residualPrediction(rpcTempCU, m_ppcPredYuvTemp[uhDepth], m_ppcResPredTmp [uhDepth]); 2007 } 2008 #endif 1955 2009 // save pred adress 1956 2010 pcPredYuvTemp = m_ppcPredYuvTemp[uhDepth]; … … 1959 2013 else 1960 2014 { 1961 #if FAST_DECISION_FOR_MRG_RD_COST1962 2015 if( bestIsSkip) 1963 2016 { 2017 #if MERL_VSP_C0152 2018 m_pcPredSearch->motionCompensation( rpcTempCU, m_ppcPredYuvTemp[uhDepth], rpcTempCU->getZorderIdxInCU() ); 2019 #else 1964 2020 m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); 2021 #endif 2022 #if MTK_MDIVRP_C0138 2023 if (uiMergeCand == 0 && rpcTempCU->getResPredAvail(0)) 2024 { 2025 m_pcPredSearch->residualPrediction(rpcTempCU, m_ppcPredYuvTemp[uhDepth], m_ppcResPredTmp [uhDepth]); 2026 } 2027 #endif 1965 2028 // save pred adress 1966 2029 pcPredYuvTemp = m_ppcPredYuvTemp[uhDepth]; … … 1968 2031 else 1969 2032 { 1970 #endif1971 2033 if ( pcPredYuvTemp != m_ppcPredYuvTemp[uhDepth]) 1972 2034 { … … 1974 2036 pcPredYuvTemp = m_ppcPredYuvBest[uhDepth]; 1975 2037 } 1976 #if FAST_DECISION_FOR_MRG_RD_COST1977 2038 } 1978 #endif1979 2039 } 1980 2040 #if HHI_VSO … … 1995 2055 m_ppcResiYuvBest[uhDepth], 1996 2056 m_ppcRecoYuvTemp[uhDepth], 1997 #if H HI_INTER_VIEW_RESIDUAL_PRED2057 #if H3D_IVRP 1998 2058 m_ppcResPredTmp [uhDepth], 1999 2059 #endif … … 2001 2061 Bool bQtRootCbf = rpcTempCU->getQtRootCbf(0) == 1; 2002 2062 2003 #if H0736_AVC_STYLE_QP_RANGE2004 2063 Int orgQP = rpcTempCU->getQP( 0 ); 2005 2064 xCheckDQP( rpcTempCU ); 2006 2065 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); 2007 2066 rpcTempCU->initEstData( uhDepth, orgQP ); 2008 #else 2009 UInt uiOrgQP = rpcTempCU->getQP( 0 ); 2010 xCheckDQP( rpcTempCU ); 2011 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); 2012 rpcTempCU->initEstData( uhDepth, uiOrgQP ); 2013 #endif 2014 2015 #if FAST_DECISION_FOR_MRG_RD_COST 2067 2016 2068 if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip ) 2017 2069 { 2018 2070 bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0; 2019 2071 } 2020 #endif2021 2072 2022 2073 if (!bQtRootCbf) 2023 2074 break; 2024 #if FAST_DECISION_FOR_MRG_RD_COST2025 2075 } 2026 #endif2027 2076 } 2028 2077 } … … 2059 2108 rpcTempCU->setDepthSubParts( uhDepth, 0 ); 2060 2109 2061 #if H HI_INTER_VIEW_RESIDUAL_PRED2110 #if H3D_IVRP 2062 2111 Bool bResPrdAvail = rpcTempCU->getResPredAvail( 0 ); 2063 2112 Bool bResPrdFlag = rpcTempCU->getResPredFlag ( 0 ); … … 2065 2114 2066 2115 rpcTempCU->setPartSizeSubParts ( ePartSize, 0, uhDepth ); 2067 #if HHI_INTER_VIEW_RESIDUAL_PRED 2116 2117 #if H3D_IVRP 2068 2118 rpcTempCU->setResPredAvailSubParts( bResPrdAvail, 0, 0, uhDepth ); 2069 2119 rpcTempCU->setResPredFlagSubParts ( bResPrdFlag, 0, 0, uhDepth ); … … 2071 2121 rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); 2072 2122 2073 #if H HI_INTER_VIEW_RESIDUAL_PRED2123 #if H3D_IVRP 2074 2124 #if !LG_RESTRICTEDRESPRED_M24766 2075 2125 if( rpcTempCU->getResPredFlag( 0 ) ) … … 2083 2133 rpcTempCU->setMergeAMP (true); 2084 2134 #if HHI_INTERVIEW_SKIP 2085 #if LG_RESTRICTEDRESPRED_M24766 2086 m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcResPredTmp[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes, bUseMRG 2135 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 2136 m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcResPredTmp[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes, bUseMRG); 2087 2137 #else 2088 2138 m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes, bUseMRG ); … … 2099 2149 #endif 2100 2150 2101 #if H HI_INTER_VIEW_RESIDUAL_PRED2151 #if H3D_IVRP 2102 2152 #if !LG_RESTRICTEDRESPRED_M24766 2103 2153 if( rpcTempCU->getResPredFlag( 0 ) ) … … 2122 2172 m_ppcResiYuvBest[uhDepth], 2123 2173 m_ppcRecoYuvTemp[uhDepth], 2124 #if H HI_INTER_VIEW_RESIDUAL_PRED2174 #if H3D_IVRP 2125 2175 m_ppcResPredTmp [uhDepth], 2126 2176 #endif … … 2133 2183 m_ppcResiYuvBest[uhDepth], 2134 2184 m_ppcRecoYuvTemp[uhDepth], 2135 #if H HI_INTER_VIEW_RESIDUAL_PRED2185 #if H3D_IVRP 2136 2186 m_ppcResPredTmp [uhDepth], 2137 2187 #endif … … 2375 2425 } 2376 2426 2377 #if BURST_IPCM2378 2427 /** Check whether the last CU shares the same root as the current CU and is IPCM or not. 2379 2428 * \param pcCU … … 2467 2516 return numSucIPCM; 2468 2517 } 2469 #endif2470 2518 2471 2519 Void TEncCu::xCopyAMVPInfo (AMVPInfo* pSrc, AMVPInfo* pDst) … … 2787 2835 assert( rpcTempCU->getInterDir( ui ) != 0 ); 2788 2836 assert( rpcTempCU->getPredictionMode( ui ) != MODE_NONE ); 2789 } 2837 #if MERL_VSP_C0152 2838 Int vspIdx = pcTextureCU->getVSPIndex( rpcTempCU->getZorderIdxInCU() + ui); 2839 rpcTempCU->setVSPIndex( ui , vspIdx); 2840 #endif 2841 } 2842 2790 2843 rpcTempCU->setPredModeSubParts( bSkipResidual ? MODE_SKIP : MODE_INTER, 0, uhDepth ); 2844 #if MERL_VSP_C0152 2845 m_pcPredSearch->motionCompensation( rpcTempCU, m_ppcPredYuvTemp[uhDepth], rpcTempCU->getZorderIdxInCU() ); 2846 #else 2791 2847 m_pcPredSearch->motionCompensation( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); 2792 2848 #endif 2793 2849 // get Original YUV data from picture 2794 2850 m_ppcOrigYuv[uhDepth]->copyFromPicYuv( rpcBestCU->getPic()->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() ); … … 2799 2855 m_ppcResiYuvBest[uhDepth], 2800 2856 m_ppcRecoYuvTemp[uhDepth], 2801 #if H HI_INTER_VIEW_RESIDUAL_PRED2857 #if H3D_IVRP 2802 2858 m_ppcResPredTmp [uhDepth], 2803 2859 #endif … … 2876 2932 m_pcEntropyCoder->encodeMergeIndex( pcCU, 0, 0, true ); 2877 2933 #if LGE_ILLUCOMP_B0045 2878 m_pcEntropyCoder->encodeICFlag( pcCU, 0, true ); 2934 m_pcEntropyCoder->encodeICFlag( pcCU, 0, true 2935 #if LGE_ILLUCOMP_DEPTH_C0046 2936 , uhDepth 2937 #endif 2938 ); 2879 2939 #endif 2880 2940 } … … 2886 2946 m_pcEntropyCoder->encodePredInfo( pcCU, 0, true ); 2887 2947 #if LGE_ILLUCOMP_B0045 2888 m_pcEntropyCoder->encodeICFlag( pcCU, 0, true ); 2948 m_pcEntropyCoder->encodeICFlag( pcCU, 0, true 2949 #if LGE_ILLUCOMP_DEPTH_C0046 2950 , uhDepth 2951 #endif 2952 ); 2889 2953 #endif 2890 2954 } -
trunk/source/Lib/TLibEncoder/TEncCu.h
r56 r296 78 78 TComYuv** m_ppcRecoYuvTemp; ///< Temporary Reconstruction Yuv for each depth 79 79 TComYuv** m_ppcOrigYuv; ///< Original Yuv for each depth 80 #if H HI_INTER_VIEW_RESIDUAL_PRED80 #if H3D_IVRP 81 81 TComYuv** m_ppcResPredTmp; ///< Temporary residual prediction for each depth 82 82 #endif 83 83 84 84 // Data : encoder control 85 85 Bool m_bEncodeDQP; 86 #if BURST_IPCM87 86 Bool m_checkBurstIPCMFlag; 88 #endif89 87 90 88 // Access channel … … 121 119 /// destroy internal buffers 122 120 Void destroy (); 123 121 124 122 /// CU analysis function 125 123 Void compressCU ( TComDataCU*& rpcCU ); … … 173 171 Void setdQPFlag ( Bool b ) { m_bEncodeDQP = b; } 174 172 175 #if BURST_IPCM176 173 Bool getCheckBurstIPCMFlag() { return m_checkBurstIPCMFlag; } 177 174 Void setCheckBurstIPCMFlag( Bool b ) { m_checkBurstIPCMFlag = b; } … … 179 176 Bool checkLastCUSucIPCM ( TComDataCU* pcCU, UInt uiCurAbsPartIdx ); 180 177 Int countNumSucIPCM ( TComDataCU* pcCU, UInt uiCurAbsPartIdx ); 181 #endif182 178 183 179 #if ADAPTIVE_QP_SELECTION -
trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
r210 r296 52 52 Void TEncEntropy::encodeSliceHeader ( TComSlice* pcSlice ) 53 53 { 54 #if SAO_UNIT_INTERLEAVING55 54 if (pcSlice->getSPS()->getUseSAO()) 56 55 { … … 68 67 } 69 68 } 70 #endif71 69 72 70 m_pcEntropyCoderIf->codeSliceHeader( pcSlice ); … … 74 72 } 75 73 76 #if TILES_WPP_ENTRY_POINT_SIGNALLING77 74 Void TEncEntropy::encodeTilesWPPEntryPoint( TComSlice* pSlice ) 78 75 { 79 76 m_pcEntropyCoderIf->codeTilesWPPEntryPoint( pSlice ); 80 77 } 81 #else82 Void TEncEntropy::encodeSliceHeaderSubstreamTable( TComSlice* pcSlice )83 {84 m_pcEntropyCoderIf->codeSliceHeaderSubstreamTable( pcSlice );85 }86 #endif87 78 88 79 Void TEncEntropy::encodeTerminatingBit ( UInt uiIsLast ) … … 98 89 } 99 90 100 #if OL_FLUSH101 91 Void TEncEntropy::encodeFlush() 102 92 { … … 107 97 m_pcEntropyCoderIf->encodeStart(); 108 98 } 109 #endif110 99 111 100 Void TEncEntropy::encodeSEI(const SEI& sei) … … 133 122 #endif 134 123 135 #if HHI_MPI 124 #if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068 136 125 Void TEncEntropy::encodeSPS( TComSPS* pcSPS, Bool bIsDepth ) 137 126 { … … 157 146 uiAbsPartIdx = 0; 158 147 } 159 #if BURST_IPCM160 148 if( !bRD ) 161 149 { … … 165 153 } 166 154 } 167 #endif168 155 m_pcEntropyCoderIf->codeSkipFlag( pcCU, uiAbsPartIdx ); 169 156 } 170 157 171 158 #if LGE_ILLUCOMP_B0045 172 Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 173 { 174 if (pcCU->isIntra(uiAbsPartIdx) || (pcCU->getSlice()->getViewId() == 0) || pcCU->getSlice()->getSPS()->isDepth()) 159 Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD 160 #if LGE_ILLUCOMP_DEPTH_C0046 161 , UInt uiDepth 162 #endif 163 ) 164 { 165 if (pcCU->isIntra(uiAbsPartIdx) || (pcCU->getSlice()->getViewId() == 0) 166 #if !LGE_ILLUCOMP_DEPTH_C0046 167 || pcCU->getSlice()->getSPS()->isDepth() 168 #endif 169 ) 175 170 { 176 171 return; … … 185 180 } 186 181 187 if(pcCU->isICFlagRequired(uiAbsPartIdx)) 182 if(pcCU->isICFlagRequired(uiAbsPartIdx 183 #if LGE_ILLUCOMP_DEPTH_C0046 184 , uiDepth //This modification is not needed after integrating JCT3V-C0137 185 #endif 186 )) 188 187 m_pcEntropyCoderIf->codeICFlag( pcCU, uiAbsPartIdx ); 189 188 } … … 214 213 // m_pcEntropyCoderIf->codeAlfUvlc(pAlfParam->realfiltNo); 215 214 216 #if !LCU_SYNTAX_ALF217 m_pcEntropyCoderIf->codeAlfFlag(pAlfParam->alf_pcr_region_flag);218 #endif219 #if !ALF_SINGLE_FILTER_SHAPE220 m_pcEntropyCoderIf->codeAlfUvlc(pAlfParam->filter_shape);221 #endif222 215 Int noFilters = min(pAlfParam->filters_per_group-1, 2); 223 216 m_pcEntropyCoderIf->codeAlfUvlc(noFilters); … … 229 222 else if (noFilters == 2) 230 223 { 231 #if LCU_SYNTAX_ALF232 #if ALF_16_BA_GROUPS233 224 Int numMergeFlags = 16; 234 #else235 Int numMergeFlags = 15;236 #endif237 #else238 #if ALF_16_BA_GROUPS239 Int numMergeFlags = 16;240 #else241 Int numMergeFlags = pAlfParam->alf_pcr_region_flag ? 16 : 15;242 #endif243 #endif244 225 for (Int i=1; i<numMergeFlags; i++) 245 226 { … … 273 254 pDepthInt = pDepthIntTabShapes[ALFp->filter_shape]; 274 255 maxScanVal = 0; 275 #if ALF_SINGLE_FILTER_SHAPE276 256 int minScanVal = MIN_SCAN_POS_CROSS; 277 #else278 int minScanVal = ( ALFp->filter_shape==ALF_STAR5x5 ) ? 0 : MIN_SCAN_POS_CROSS;279 #endif280 257 281 258 for(i = 0; i < sqrFiltLength; i++) … … 343 320 // Coding parameters 344 321 ALFp->minKStart = minKStart; 345 #if !LCU_SYNTAX_ALF346 ALFp->maxScanVal = maxScanVal;347 #endif348 322 for(scanPos = minScanVal; scanPos < maxScanVal; scanPos++) 349 323 { … … 351 325 } 352 326 353 #if LCU_SYNTAX_ALF354 327 if (ALFp->filters_per_group == 1) 355 328 { … … 358 331 else 359 332 { 360 #endif361 333 len += writeFilterCodingParams(minKStart, minScanVal, maxScanVal, kMinTab); 362 334 363 335 // Filter coefficients 364 336 len += writeFilterCoeffs(sqrFiltLength, filters_per_group, pDepthInt, ALFp->coeffmulti, kMinTab); 365 #if LCU_SYNTAX_ALF 366 } 367 #endif 337 } 368 338 369 339 return len; … … 403 373 { 404 374 scanPos = pDepthInt[i] - 1; 405 #if LCU_SYNTAX_ALF406 375 Int k = (filters_per_group == 1) ? kMinTab[i] : kMinTab[scanPos]; 407 376 golombEncode(FilterCoeff[ind][i], k); 408 #else409 golombEncode(FilterCoeff[ind][i], kMinTab[scanPos]);410 #endif411 377 } 412 378 } … … 489 455 } 490 456 491 #if H HI_INTER_VIEW_RESIDUAL_PRED457 #if H3D_IVRP && !MTK_MDIVRP_C0138 492 458 Void 493 459 TEncEntropy::encodeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD ) … … 514 480 #endif 515 481 516 #if LCU_SYNTAX_ALF517 482 /** parse the fixed length code (smaller than one max value) in ALF 518 483 * \param run: coded value … … 781 746 782 747 } 783 #endif784 748 785 749 786 750 Void TEncEntropy::encodeAlfParam(ALFParam* pAlfParam) 787 751 { 788 #if LCU_SYNTAX_ALF789 752 const Int numCoeff = (Int)ALF_MAX_NUM_COEF; 790 753 … … 814 777 } 815 778 } 816 #else817 if (!pAlfParam->alf_flag)818 {819 return;820 }821 Int pos;822 codeAux(pAlfParam);823 codeFilt(pAlfParam);824 825 // filter parameters for chroma826 m_pcEntropyCoderIf->codeAlfUvlc(pAlfParam->chroma_idc);827 if(pAlfParam->chroma_idc)828 {829 #if !ALF_SINGLE_FILTER_SHAPE830 m_pcEntropyCoderIf->codeAlfUvlc(pAlfParam->filter_shape_chroma);831 #endif832 // filter coefficients for chroma833 for(pos=0; pos<pAlfParam->num_coeff_chroma; pos++)834 {835 m_pcEntropyCoderIf->codeAlfSvlc(pAlfParam->coeff_chroma[pos]);836 }837 }838 #endif839 779 } 840 780 … … 895 835 uiAbsPartIdx = 0; 896 836 } 897 #if BURST_IPCM898 837 if( !bRD ) 899 838 { … … 903 842 } 904 843 } 905 #endif906 844 907 845 #if !RWTH_SDC_DLT_B0036 … … 931 869 uiAbsPartIdx = 0; 932 870 } 933 #if BURST_IPCM934 871 if( !bRD ) 935 872 { … … 939 876 } 940 877 } 941 #endif942 878 943 879 m_pcEntropyCoderIf->codeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); … … 957 893 uiAbsPartIdx = 0; 958 894 } 959 #if BURST_IPCM960 895 if( !bRD ) 961 896 { … … 965 900 } 966 901 } 967 #endif968 902 #if RWTH_SDC_DLT_B0036 969 903 if( !pcCU->getSlice()->isInterB() && pcCU->isIntra(uiAbsPartIdx) && pcCU->getSDCFlag(uiAbsPartIdx) ) … … 1019 953 } 1020 954 1021 #if BURST_IPCM1022 955 Int numIPCM = 0; 1023 956 Bool firstIPCMFlag = false; … … 1035 968 } 1036 969 m_pcEntropyCoderIf->codeIPCMInfo ( pcCU, uiAbsPartIdx, numIPCM, firstIPCMFlag); 1037 #else 1038 m_pcEntropyCoderIf->codeIPCMInfo ( pcCU, uiAbsPartIdx ); 1039 #endif 1040 1041 } 1042 1043 #if UNIFIED_TRANSFORM_TREE 970 971 } 972 1044 973 Void TEncEntropy::xEncodeTransform( TComDataCU* pcCU,UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3, Bool& bCodeDQP ) 1045 #else1046 Void TEncEntropy::xEncodeTransformSubdiv( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 )1047 #endif1048 974 { 1049 975 const UInt uiSubdiv = pcCU->getTransformIdx( uiAbsPartIdx ) + pcCU->getDepth( uiAbsPartIdx ) > uiDepth; 1050 976 const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; 1051 #if UNIFIED_TRANSFORM_TREE1052 977 UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA , uiTrIdx ); 1053 978 UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); … … 1072 997 } 1073 998 } 1074 #endif // UNIFIED_TRANSFORM_TREE1075 999 {//CABAC 1076 1000 if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) … … 1152 1076 if( uiSubdiv ) 1153 1077 { 1154 #if UNIFIED_TRANSFORM_TREE1155 1078 UInt size; 1156 1079 width >>= 1; … … 1158 1081 size = width*height; 1159 1082 uiTrIdx++; 1160 #endif // UNIFIED_TRANSFORM_TREE1161 1083 ++uiDepth; 1162 #if UNIFIED_TRANSFORM_TREE1163 1084 const UInt partNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); 1164 #else1165 const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);1166 #endif1167 1085 1168 1086 UInt uiCurrentCbfY = 0; … … 1170 1088 UInt uiCurrentCbfV = 0; 1171 1089 1172 #if UNIFIED_TRANSFORM_TREE1173 1090 UInt nsAddr = 0; 1174 1091 nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, 0, uiDepth - pcCU->getDepth( uiAbsPartIdx ) ); … … 1186 1103 nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, 3, uiDepth - pcCU->getDepth( uiAbsPartIdx ) ); 1187 1104 xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, nsAddr, uiDepth, width, height, uiTrIdx, 3, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV, bCodeDQP ); 1188 #else // UNIFIED_TRANSFORM_TREE1189 UInt nsAddr = 0;1190 nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, 0, uiDepth - pcCU->getDepth( uiAbsPartIdx ) );1191 xEncodeTransformSubdiv( pcCU, uiAbsPartIdx, nsAddr, uiDepth, 0, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV );1192 1193 uiAbsPartIdx += uiQPartNum;1194 nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, 1, uiDepth - pcCU->getDepth( uiAbsPartIdx ) );1195 xEncodeTransformSubdiv( pcCU, uiAbsPartIdx, nsAddr, uiDepth, 1, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV );1196 1197 uiAbsPartIdx += uiQPartNum;1198 nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, 2, uiDepth - pcCU->getDepth( uiAbsPartIdx ) );1199 xEncodeTransformSubdiv( pcCU, uiAbsPartIdx, nsAddr, uiDepth, 2, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV );1200 1201 uiAbsPartIdx += uiQPartNum;1202 nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, 3, uiDepth - pcCU->getDepth( uiAbsPartIdx ) );1203 xEncodeTransformSubdiv( pcCU, uiAbsPartIdx, nsAddr, uiDepth, 3, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV );1204 #endif // UNIFIED_TRANSFORM_TREE1205 1105 1206 1106 uiYCbfFront3 += uiCurrentCbfY; … … 1246 1146 } 1247 1147 1248 #if UNIFIED_TRANSFORM_TREE1249 1148 if ( cbfY || cbfU || cbfV ) 1250 1149 { … … 1298 1197 } 1299 1198 } 1300 #endif // UNIFIED_TRANSFORM_TREE 1301 } 1302 } 1303 } 1304 1305 #if !UNIFIED_TRANSFORM_TREE 1306 // transform index 1307 Void TEncEntropy::encodeTransformIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD ) 1308 { 1309 assert( !bRD ); // parameter bRD can be removed 1310 if( bRD ) 1311 { 1312 uiAbsPartIdx = 0; 1313 } 1314 1315 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 1316 DTRACE_CABAC_T( "\tdecodeTransformIdx()\tCUDepth=" ) 1317 DTRACE_CABAC_V( uiDepth ) 1318 DTRACE_CABAC_T( "\n" ) 1319 UInt temp = 0; 1320 UInt temp1 = 0; 1321 UInt temp2 = 0; 1322 xEncodeTransformSubdiv( pcCU, uiAbsPartIdx, uiAbsPartIdx, uiDepth, 0, temp, temp1, temp2 ); 1323 } 1324 #endif // !UNIFIED_TRANSFORM_TREE 1199 } 1200 } 1201 } 1202 1325 1203 1326 1204 // Intra direction for Luma … … 1347 1225 uiAbsPartIdx = 0; 1348 1226 } 1349 1227 1350 1228 #if RWTH_SDC_DLT_B0036 1351 1229 if( pcCU->getSDCFlag(uiAbsPartIdx) ) … … 1355 1233 } 1356 1234 #endif 1357 1235 1358 1236 PartSize eSize = pcCU->getPartitionSize( uiAbsPartIdx ); 1359 1237 … … 1496 1374 if ( (pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList )) && (pcCU->getAMVPMode(uiAbsPartIdx) == AM_EXPL) ) 1497 1375 { 1498 #if H HI_INTER_VIEW_MOTION_PRED1376 #if H3D_IVMP 1499 1377 const Int iNumCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 1500 1378 m_pcEntropyCoderIf->codeMVPIdx( pcCU, uiAbsPartIdx, eRefList, iNumCands ); … … 1538 1416 1539 1417 // texture 1540 #if !UNIFIED_TRANSFORM_TREE1541 Void TEncEntropy::xEncodeCoeff( TComDataCU* pcCU, UInt uiLumaOffset, UInt uiChromaOffset, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, Bool& bCodeDQP )1542 {1543 UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ] + 2;1544 UInt uiCbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrIdx );1545 UInt uiCbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );1546 UInt uiCbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );1547 1548 if( uiLog2TrSize == 2 )1549 {1550 UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );1551 if( ( uiAbsPartIdx % uiQPDiv ) == 0 )1552 {1553 m_uiBakAbsPartIdx = uiAbsPartIdx;1554 m_uiBakChromaOffset = uiChromaOffset;1555 }1556 else if( ( uiAbsPartIdx % uiQPDiv ) == (uiQPDiv - 1) )1557 {1558 uiCbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );1559 uiCbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );1560 }1561 }1562 1563 if ( uiCbfY || uiCbfU || uiCbfV )1564 {1565 // dQP: only for LCU once1566 if ( pcCU->getSlice()->getPPS()->getUseDQP() )1567 {1568 if ( bCodeDQP )1569 {1570 encodeQP( pcCU, uiAbsPartIdx );1571 bCodeDQP = false;1572 }1573 }1574 UInt uiLumaTrMode, uiChromaTrMode;1575 pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode );1576 const UInt uiStopTrMode = uiLumaTrMode;1577 1578 assert(1); // as long as quadtrees are not used for residual transform1579 1580 if( uiTrIdx == uiStopTrMode )1581 {1582 if( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrIdx ) )1583 {1584 Int trWidth = uiWidth;1585 Int trHeight = uiHeight;1586 pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight );1587 m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffY()+uiLumaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA );1588 }1589 1590 uiWidth >>= 1;1591 uiHeight >>= 1;1592 1593 if( uiLog2TrSize == 2 )1594 {1595 UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );1596 if( ( uiAbsPartIdx % uiQPDiv ) == (uiQPDiv - 1) )1597 {1598 uiWidth <<= 1;1599 uiHeight <<= 1;1600 Int trWidth = uiWidth;1601 Int trHeight = uiHeight;1602 pcCU->getNSQTSize( uiTrIdx-1, uiAbsPartIdx, trWidth, trHeight );1603 if( pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ) )1604 {1605 m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );1606 }1607 if( pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ) )1608 {1609 m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );1610 }1611 }1612 }1613 else1614 {1615 Int trWidth = uiWidth;1616 Int trHeight = uiHeight;1617 pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight );1618 if( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ) )1619 {1620 m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCb()+uiChromaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );1621 }1622 if( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ) )1623 {1624 m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCr()+uiChromaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );1625 }1626 }1627 }1628 else1629 {1630 {1631 DTRACE_CABAC_VL( g_nSymbolCounter++ );1632 DTRACE_CABAC_T( "\tgoing down\tdepth=" );1633 DTRACE_CABAC_V( uiDepth );1634 DTRACE_CABAC_T( "\ttridx=" );1635 DTRACE_CABAC_V( uiTrIdx );1636 DTRACE_CABAC_T( "\n" );1637 }1638 if( uiCurrTrIdx <= uiTrIdx )1639 assert(1);1640 1641 UInt uiSize;1642 uiWidth >>= 1;1643 uiHeight >>= 1;1644 uiSize = uiWidth*uiHeight;1645 uiDepth++;1646 uiTrIdx++;1647 1648 UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);1649 UInt uiIdx = uiAbsPartIdx;1650 1651 {1652 xEncodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP );1653 uiLumaOffset += uiSize; uiChromaOffset += (uiSize>>2); uiIdx += uiQPartNum;1654 1655 xEncodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP );1656 uiLumaOffset += uiSize; uiChromaOffset += (uiSize>>2); uiIdx += uiQPartNum;1657 1658 xEncodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP );1659 uiLumaOffset += uiSize; uiChromaOffset += (uiSize>>2); uiIdx += uiQPartNum;1660 1661 xEncodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP );1662 }1663 {1664 DTRACE_CABAC_VL( g_nSymbolCounter++ );1665 DTRACE_CABAC_T( "\tgoing up\n" );1666 }1667 }1668 }1669 }1670 #endif // !UNIFIED_TRANSFORM_TREE1671 1418 1672 1419 /** encode coefficients … … 1706 1453 DTRACE_CABAC_V( uiDepth ) 1707 1454 DTRACE_CABAC_T( "\n" ) 1708 #if !UNIFIED_TRANSFORM_TREE1709 UInt temp = 0;1710 UInt temp1 = 0;1711 UInt temp2 = 0;1712 xEncodeTransformSubdiv( pcCU, uiAbsPartIdx, uiAbsPartIdx, uiDepth, 0, temp, temp1, temp2 );1713 #endif // !UNIFIED_TRANSFORM_TREE1714 1455 } 1715 1456 else … … 1735 1476 } 1736 1477 } 1737 #if !UNIFIED_TRANSFORM_TREE1738 encodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) );1739 #endif1740 1478 } 1741 1479 … … 1756 1494 #endif 1757 1495 1758 #if UNIFIED_TRANSFORM_TREE1759 1496 UInt temp = 0; 1760 1497 UInt temp1 = 0; 1761 1498 UInt temp2 = 0; 1762 1499 xEncodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, 0, temp, temp1, temp2, bCodeDQP ); 1763 #else // UNIFIED_TRANSFORM_TREE1764 xEncodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, uiLumaTrMode, bCodeDQP );1765 #endif // UNIFIED_TRANSFORM_TREE1766 1500 1767 1501 #if FIX_MPI_B0065 … … 1785 1519 } 1786 1520 1787 #if SAO_UNIT_INTERLEAVING1788 1521 /** Encode SAO Offset 1789 1522 * \param saoLcuParam SAO LCU paramters … … 1973 1706 } 1974 1707 } 1975 #else1976 /** Encode SAO for one partition1977 * \param pSaoParam, iPartIdx1978 */1979 Void TEncEntropy::encodeSaoOnePart(SAOParam* pSaoParam, Int iPartIdx, Int iYCbCr)1980 {1981 SAOQTPart* pAlfPart = NULL;1982 pAlfPart = &(pSaoParam->psSaoPart[iYCbCr][iPartIdx]);1983 1984 UInt uiSymbol;1985 1986 if(!pAlfPart->bSplit)1987 {1988 if (pAlfPart->bEnableFlag)1989 {1990 uiSymbol = pAlfPart->iBestType + 1;1991 }1992 else1993 {1994 uiSymbol = 0;1995 }1996 1997 m_pcEntropyCoderIf->codeSaoUvlc(uiSymbol);1998 1999 if (pAlfPart->bEnableFlag)2000 {2001 for(Int i=0; i< pAlfPart->iLength; i++)2002 {2003 m_pcEntropyCoderIf->codeSaoSvlc(pAlfPart->iOffset[i]);2004 }2005 }2006 return;2007 }2008 2009 //split2010 if (pAlfPart->PartLevel < pSaoParam->iMaxSplitLevel)2011 {2012 for (Int i=0;i<NUM_DOWN_PART;i++)2013 {2014 encodeSaoOnePart(pSaoParam, pAlfPart->DownPartsIdx[i], iYCbCr);2015 }2016 }2017 }2018 2019 /** Encode quadtree split flag2020 * \param pSaoParam, iPartIdx2021 */2022 Void TEncEntropy::encodeQuadTreeSplitFlag(SAOParam* pSaoParam, Int iPartIdx, Int iYCbCr)2023 {2024 SAOQTPart* pSaoPart = NULL;2025 pSaoPart = &(pSaoParam->psSaoPart[iYCbCr][iPartIdx]);2026 2027 if(pSaoPart->PartLevel < pSaoParam->iMaxSplitLevel)2028 {2029 //send one flag2030 m_pcEntropyCoderIf->codeSaoFlag( (pSaoPart->bSplit)?(1):(0) );2031 2032 if(pSaoPart->bSplit)2033 {2034 for (Int i=0;i<NUM_DOWN_PART;i++)2035 {2036 encodeQuadTreeSplitFlag(pSaoParam, pSaoPart->DownPartsIdx[i], iYCbCr);2037 }2038 }2039 }2040 }2041 /** Encode SAO parameters2042 * \param pSaoParam2043 */2044 Void TEncEntropy::encodeSaoParam(SAOParam* pSaoParam)2045 {2046 if (pSaoParam->bSaoFlag[0])2047 {2048 encodeQuadTreeSplitFlag(pSaoParam, 0, 0);2049 encodeSaoOnePart(pSaoParam, 0, 0);2050 m_pcEntropyCoderIf->codeSaoFlag(pSaoParam->bSaoFlag[1]);2051 if (pSaoParam->bSaoFlag[1])2052 {2053 encodeQuadTreeSplitFlag(pSaoParam, 0, 1);2054 encodeSaoOnePart(pSaoParam, 0, 1);2055 }2056 m_pcEntropyCoderIf->codeSaoFlag(pSaoParam->bSaoFlag[2]);2057 if (pSaoParam->bSaoFlag[2])2058 {2059 encodeQuadTreeSplitFlag(pSaoParam, 0, 2);2060 encodeSaoOnePart(pSaoParam, 0, 2);2061 }2062 }2063 }2064 #endif2065 1708 2066 1709 Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ) -
trunk/source/Lib/TLibEncoder/TEncEntropy.h
r210 r296 80 80 #endif 81 81 82 #if HHI_MPI 82 #if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068 83 83 virtual Void codeSPS ( TComSPS* pcSPS, Bool bIsDepth ) = 0; 84 84 #else … … 90 90 virtual Void codeTileMarkerFlag ( TComSlice* pcSlice ) = 0; 91 91 92 #if TILES_WPP_ENTRY_POINT_SIGNALLING93 92 virtual Void codeTilesWPPEntryPoint ( TComSlice* pSlice ) = 0; 94 #else95 virtual Void codeSliceHeaderSubstreamTable( TComSlice* pcSlice ) = 0;96 #endif97 93 virtual Void codeTerminatingBit ( UInt uilsLast ) = 0; 98 94 virtual Void codeSliceFinish () = 0; 99 #if OL_FLUSH100 95 virtual Void codeFlush () = 0; 101 96 virtual Void encodeStart () = 0; 102 #endif103 97 104 98 virtual Void codeAlfCtrlDepth() = 0; 105 #if H HI_INTER_VIEW_MOTION_PRED99 #if H3D_IVMP 106 100 virtual Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ) = 0; 107 101 #else … … 120 114 virtual Void codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; 121 115 virtual Void codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; 122 #if H HI_INTER_VIEW_RESIDUAL_PRED116 #if H3D_IVRP 123 117 virtual Void codeResPredFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; 124 118 #endif … … 134 128 #endif 135 129 136 #if BURST_IPCM137 130 virtual Void codeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag) = 0; 138 #else139 virtual Void codeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;140 #endif141 131 142 132 virtual Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) = 0; … … 155 145 virtual Void codeAlfUvlc ( UInt uiCode ) = 0; 156 146 virtual Void codeAlfSvlc ( Int iCode ) = 0; 157 #if LCU_SYNTAX_ALF158 147 virtual Void codeAlfFixedLengthIdx( UInt idx, UInt numFilterSetsInBuffer) = 0; 159 148 virtual Void codeAPSAlflag(UInt uiCode) = 0; 160 #endif161 149 /// set slice granularity 162 150 virtual Void setSliceGranularity(Int iSliceGranularity) = 0; … … 169 157 virtual Void codeSaoUvlc ( UInt uiCode ) = 0; 170 158 virtual Void codeSaoSvlc ( Int iCode ) = 0; 171 #if SAO_UNIT_INTERLEAVING172 159 virtual Void codeSaoRun ( UInt uiCode, UInt uiMaxValue ) = 0; 173 160 virtual Void codeSaoMergeLeft ( UInt uiCode, UInt uiCompIdx ) = 0; … … 175 162 virtual Void codeSaoTypeIdx ( UInt uiCode) = 0; 176 163 virtual Void codeSaoUflc ( UInt uiCode) = 0; 177 #endif178 164 virtual Void estBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) = 0; 179 165 … … 198 184 UInt m_uiBakAbsPartIdx; 199 185 UInt m_uiBakChromaOffset; 200 #if UNIFIED_TRANSFORM_TREE201 186 UInt m_bakAbsPartIdxCU; 202 #endif203 187 204 188 public: … … 216 200 Void encodeSliceHeader ( TComSlice* pcSlice ); 217 201 Void encodeTileMarkerFlag (TComSlice* pcSlice) {m_pcEntropyCoderIf->codeTileMarkerFlag(pcSlice);} 218 #if TILES_WPP_ENTRY_POINT_SIGNALLING219 202 Void encodeTilesWPPEntryPoint( TComSlice* pSlice ); 220 #else221 Void encodeSliceHeaderSubstreamTable( TComSlice* pcSlice );222 #endif223 203 Void encodeTerminatingBit ( UInt uiIsLast ); 224 204 Void encodeSliceFinish (); 225 #if OL_FLUSH226 205 Void encodeFlush (); 227 206 Void encodeStart (); 228 #endif229 #if LCU_SYNTAX_ALF230 207 Void encodeAlfFlag(UInt code) {m_pcEntropyCoderIf->codeAlfFlag(code);} 231 208 Void encodeAlfStoredFilterSetIdx(UInt idx, UInt numFilterSetsInBuffer); … … 236 213 Int getAlfRun(Int compIdx, AlfParamSet* pAlfParamSet, Int lcuIdxInSlice, Int lcuPos, Int startlcuPosX, Int endlcuPosX); 237 214 Void encodeAPSAlfFlag(UInt code) {m_pcEntropyCoderIf->codeAPSAlflag(code);} 238 #endif239 215 Void encodeAlfParam(ALFParam* pAlfParam); 240 216 … … 246 222 #endif 247 223 // SPS 248 #if HHI_MPI 224 #if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068 249 225 Void encodeSPS ( TComSPS* pcSPS, Bool bIsDepth ); 250 226 #else … … 260 236 Void encodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false ); 261 237 #if LGE_ILLUCOMP_B0045 262 Void encodeICFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); 238 Void encodeICFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false 239 #if LGE_ILLUCOMP_DEPTH_C0046 240 , UInt uiDepth = 0 241 #endif 242 ); 263 243 #endif 264 244 Void encodeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); … … 270 250 Void encodeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx ); 271 251 Void encodeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD = false ); 272 #if H HI_INTER_VIEW_RESIDUAL_PRED252 #if H3D_IVRP && !MTK_MDIVRP_C0138 273 253 Void encodeResPredFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD = false ); 274 254 #endif … … 293 273 Void encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); 294 274 295 #if !UNIFIED_TRANSFORM_TREE296 Void encodeTransformIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );297 #endif298 275 Void encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ); 299 276 Void encodeQtCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ); … … 316 293 317 294 private: 318 #if UNIFIED_TRANSFORM_TREE319 295 Void xEncodeTransform ( TComDataCU* pcCU,UInt offsetLumaOffset, UInt offsetChroma, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3, Bool& bCodeDQP ); 320 #else321 Void xEncodeTransformSubdiv ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 );322 Void xEncodeCoeff ( TComDataCU* pcCU, UInt uiLumaOffset, UInt uiChromaOffset, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, Bool& bCodeDQP );323 #endif // !UNIFIED_TRANSFORM_TREE324 296 public: 325 297 Void encodeCoeff ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ); … … 341 313 Int golombEncode(int coeff, int k); 342 314 Int lengthGolomb(int coeffVal, int k); 343 #if SAO_UNIT_INTERLEAVING344 315 Void encodeSaoUnit(Int rx, Int ry, Int compIdx, SAOParam* saoParam, Int repeatedRow); 345 316 Void encodeSaoOffset(SaoLcuParam* saoLcuParam); 346 317 Void encodeSaoUnitInterleaving(Int rx, Int ry, SAOParam* saoParam, TComDataCU* cu, Int cuAddrInSlice, Int cuAddrUpInSlice, Bool lfCrossSliceBoundaryFlag); 347 318 Void encodeSaoParam (TComAPS* aps); 348 #else349 Void encodeSaoOnePart (SAOParam* pSaoParam, Int iPartIdx, Int iYCbCr);350 Void encodeQuadTreeSplitFlag(SAOParam* pSaoParam, Int iPartIdx, Int iYCbCr);351 Void encodeSaoParam (SAOParam* pSaoParam);352 #endif353 319 354 320 static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ); -
trunk/source/Lib/TLibEncoder/TEncGOP.cpp
r210 r296 78 78 m_pcDepthMapGenerator = NULL; 79 79 #endif 80 #if H HI_INTER_VIEW_RESIDUAL_PRED80 #if H3D_IVRP 81 81 m_pcResidualGenerator = NULL; 82 82 #endif … … 131 131 m_pcDepthMapGenerator = pcTEncTop->getDepthMapGenerator(); 132 132 #endif 133 #if H HI_INTER_VIEW_RESIDUAL_PRED133 #if H3D_IVRP 134 134 m_pcResidualGenerator = pcTEncTop->getResidualGenerator(); 135 135 #endif … … 159 159 TComOutputBitstream *pcBitstreamRedirect; 160 160 pcBitstreamRedirect = new TComOutputBitstream; 161 #if !REMOVE_TILE_DEPENDENCE162 OutputNALUnit *naluBuffered = NULL;163 Bool bIteratorAtListStart = false;164 #endif165 161 AccessUnit::iterator itLocationToPushSliceHeaderNALU; // used to store location where NALU containing slice header is to be inserted 166 162 UInt uiOneBitstreamPerSliceLength = 0; … … 247 243 std::vector<TComAPS>& vAPS = m_pcEncTop->getAPS(); 248 244 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 245 #if MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137 246 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, uiPOCCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getEncTop()->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), m_pcEncTop->getIsDepth() ); 247 #else 249 248 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, uiPOCCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getEncTop()->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); 249 #endif 250 250 #else 251 251 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, uiPOCCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); … … 254 254 pcSlice->setSliceIdx(0); 255 255 pcSlice->setViewId( m_pcEncTop->getViewId() ); 256 pcSlice->setIsDepth( m_pcEncTop->getIsDepth() ); 256 pcSlice->setIsDepth( m_pcEncTop->getIsDepth() ); 257 #if INTER_VIEW_VECTOR_SCALING_C0115 258 pcSlice->setIVScalingFlag( m_pcEncTop->getUseIVS() ); 259 #endif 257 260 258 261 m_pcEncTop->getSPS()->setDisInter4x4(m_pcEncTop->getDisInter4x4()); … … 276 279 pcSlice->setDefaultScalingList (); 277 280 } 278 #if SCALING_LIST279 281 pcSlice->getScalingList()->checkDcOfMatrix(); 280 #endif281 282 pcSlice->getScalingList()->setScalingListPresentFlag(pcSlice->checkDefaultScalingList()); 282 283 m_pcEncTop->getTrQuant()->setScalingList(pcSlice->getScalingList()); … … 326 327 pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS()); 327 328 328 #if H0566_TLA && H0566_TLA_SET_FOR_SWITCHING_POINTS329 #if H0566_TLA_SET_FOR_SWITCHING_POINTS 329 330 if(pcSlice->getTLayer() > 0) 330 331 { … … 341 342 #else 342 343 343 Bool bNalRAP = ((getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_CRA) || (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDR)) && (pcSlice->getSPS()->getViewId()) ? 1: 0; 344 pcSlice->setNumRefIdx( REF_PIC_LIST_0, min( m_pcCfg->getGOPEntry( bNalRAP ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) ); 345 pcSlice->setNumRefIdx( REF_PIC_LIST_1, min( m_pcCfg->getGOPEntry( bNalRAP ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) ); 346 #endif 347 TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); 348 refPicListModification->setRefPicListModificationFlagL0( false ); 349 #if !H0137_0138_LIST_MODIFICATION 350 refPicListModification->setNumberOfRefPicListModificationsL0(0); 351 #endif 344 Bool bNalRAP = ((getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_CRA) || (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDR)) && (pcSlice->getSPS()->getViewId()) ? 1: 0; 345 pcSlice->setNumRefIdx( REF_PIC_LIST_0, min( m_pcCfg->getGOPEntry( bNalRAP ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) ); 346 pcSlice->setNumRefIdx( REF_PIC_LIST_1, min( m_pcCfg->getGOPEntry( bNalRAP ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) ); 347 #endif 348 TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); 349 refPicListModification->setRefPicListModificationFlagL0( false ); 352 350 refPicListModification->setRefPicListModificationFlagL1( false ); 353 #if !H0137_0138_LIST_MODIFICATION354 refPicListModification->setNumberOfRefPicListModificationsL1(0);355 #endif356 351 xSetRefPicListModificationsMvc( pcSlice, uiPOCCurr, iGOPid ); 357 352 … … 518 513 } 519 514 520 #if H0111_MVD_L1_ZERO521 515 Bool bGPBcheck=false; 522 516 if ( pcSlice->getSliceType() == B_SLICE) … … 545 539 } 546 540 pcPic->getSlice(pcSlice->getSliceIdx())->setMvdL1ZeroFlag(pcSlice->getMvdL1ZeroFlag()); 547 #endif548 541 549 542 UInt uiNumSlices = 1; … … 574 567 UInt uiEncCUAddr; 575 568 576 #if !REMOVE_TILE_DEPENDENCE577 if(pcSlice->getPPS()->getTileBehaviorControlPresentFlag() == 1)578 {579 pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getTileBoundaryIndependenceIdr() );580 }581 else582 {583 pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getSPS()->getTileBoundaryIndependenceIdr() );584 585 }586 #endif587 569 588 570 if( pcSlice->getPPS()->getColumnRowInfoPresent() == 1 ) //derive the tile parameters from PPS … … 747 729 // init view component and predict virtual depth map 748 730 m_pcDepthMapGenerator->initViewComponent( pcPic ); 749 #if ! QC_MULTI_DIS_CAN_A0097731 #if !H3D_NBDV 750 732 m_pcDepthMapGenerator->predictDepthMap ( pcPic ); 751 733 #endif 752 734 #endif 753 #if H HI_INTER_VIEW_MOTION_PRED735 #if H3D_IVMP 754 736 m_pcDepthMapGenerator->covertOrgDepthMap( pcPic ); 755 737 #endif 756 #if H HI_INTER_VIEW_RESIDUAL_PRED738 #if H3D_IVRP 757 739 m_pcResidualGenerator->initViewComponent( pcPic ); 758 740 #endif 759 741 760 #if QC_SIMPLE_NBDV_B0047742 #if H3D_NBDV 761 743 if(pcSlice->getViewId() && pcSlice->getSPS()->getMultiviewMvPredMode()) 762 744 { … … 818 800 pcSlice = pcPic->getSlice(0); 819 801 820 #if H HI_INTER_VIEW_RESIDUAL_PRED802 #if H3D_IVRP 821 803 // set residual picture 822 804 m_pcResidualGenerator->setRecResidualPic( pcPic ); 823 805 #endif 824 806 #if DEPTH_MAP_GENERATION 825 #if ! QC_MULTI_DIS_CAN_A0097807 #if !H3D_NBDV 826 808 // update virtual depth map 827 809 m_pcDepthMapGenerator->updateDepthMap( pcPic ); … … 832 814 Bool bLFCrossTileBoundary = (pcSlice->getPPS()->getTileBehaviorControlPresentFlag() == 1)? 833 815 (pcSlice->getPPS()->getLFCrossTileBoundaryFlag()):(pcSlice->getPPS()->getSPS()->getLFCrossTileBoundaryFlag()); 834 #if DBL_CONTROL835 816 m_pcLoopFilter->setCfg(pcSlice->getPPS()->getDeblockingFilterControlPresent(), pcSlice->getLoopFilterDisable(), pcSlice->getLoopFilterBetaOffset(), pcSlice->getLoopFilterTcOffset(), bLFCrossTileBoundary); 836 #else837 m_pcLoopFilter->setCfg(pcSlice->getLoopFilterDisable(), pcSlice->getLoopFilterBetaOffset(), pcSlice->getLoopFilterTcOffset(), bLFCrossTileBoundary);838 #endif839 817 m_pcLoopFilter->loopFilterPic( pcPic ); 840 818 … … 854 832 } 855 833 856 #if LCU_SYNTAX_ALF857 834 AlfParamSet* alfSliceParams = NULL; 858 835 std::vector<AlfCUCtrlInfo>* alfCUCtrlParam = NULL; 859 #else860 std::vector<AlfCUCtrlInfo> vAlfCUCtrlParam;861 #endif862 836 pcSlice = pcPic->getSlice(0); 863 837 864 838 if(pcSlice->getSPS()->getUseALF()) 865 839 { 866 #if LCU_SYNTAX_ALF867 840 m_pcAdaptiveLoopFilter->createPicAlfInfo(pcPic, uiNumSlices, pcSlice->getSliceQp()); 868 841 m_pcAdaptiveLoopFilter->initALFEnc(m_pcCfg->getALFParamInSlice(), m_pcCfg->getALFPicBasedEncode(), uiNumSlices, alfSliceParams, alfCUCtrlParam); 869 #else870 vAlfCUCtrlParam.resize(uiNumSlices);871 m_pcAdaptiveLoopFilter->createPicAlfInfo(pcPic, uiNumSlices);872 #endif873 842 } 874 843 … … 893 862 } 894 863 #endif 895 #if NAL_REF_FLAG896 864 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 897 865 OutputNALUnit nalu(NAL_UNIT_SPS, true, m_pcEncTop->getLayerId()); … … 899 867 OutputNALUnit nalu(NAL_UNIT_SPS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth()); 900 868 #endif 901 #else902 OutputNALUnit nalu(NAL_UNIT_SPS, NAL_REF_IDC_PRIORITY_HIGHEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());903 #endif904 869 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 905 #if TILES_WPP_ENTRY_POINT_SIGNALLING906 870 pcSlice->getSPS()->setNumSubstreams( pcSlice->getPPS()->getNumSubstreams() ); 907 #endif 908 #if HHI_MPI 871 #if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068 909 872 m_pcEntropyCoder->encodeSPS(pcSlice->getSPS(), m_pcEncTop->getIsDepth()); 910 873 #else … … 914 877 accessUnit.push_back(new NALUnitEBSP(nalu)); 915 878 916 #if NAL_REF_FLAG917 879 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 918 880 #if QC_MVHEVC_B0046 … … 923 885 #else 924 886 nalu = NALUnit(NAL_UNIT_PPS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth()); 925 #endif926 #else927 nalu = NALUnit(NAL_UNIT_PPS, NAL_REF_IDC_PRIORITY_HIGHEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());928 887 #endif 929 888 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); … … 1050 1009 m_pcEntropyCoder->resetEntropy (); 1051 1010 /* start slice NALunit */ 1052 #if H03881053 #if NAL_REF_FLAG1054 1011 OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced(), 1055 1012 #if !VIDYO_VPS_INTEGRATION &!QC_MVHEVC_B0046 … … 1057 1014 #else 1058 1015 m_pcEncTop->getLayerId(), pcSlice->getTLayer() ); 1059 #endif1060 #else1061 OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced() ? NAL_REF_IDC_PRIORITY_HIGHEST: NAL_REF_IDC_PRIORITY_LOWEST,1062 #if !VIDYO_VPS_INTEGRATION1063 m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer() );1064 #else1065 m_pcEncTop->getLayerId(), pcSlice->getTLayer() );1066 #endif1067 #endif1068 #else1069 OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced() ? NAL_REF_IDC_PRIORITY_HIGHEST: NAL_REF_IDC_PRIORITY_LOWEST,1070 #if !VIDYO_VPS_INTEGRATION1071 m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer(), true );1072 #else1073 m_pcEncTop->getLayerId(), pcSlice->getTLayer(), true );1074 #endif1075 1076 1016 #endif 1077 1017 … … 1096 1036 if (pcSlice->getSPS()->getUseALF()) 1097 1037 { 1098 #if LCU_SYNTAX_ALF1099 1038 if(pcSlice->getAlfEnabledFlag()) 1100 #else1101 if(pcSlice->getAPS()->getAlfEnabled())1102 #endif1103 1039 { 1104 1040 1105 #if LCU_SYNTAX_ALF1106 1041 if( pcSlice->getSPS()->getUseALFCoefInSlice()) 1107 1042 { … … 1115 1050 { 1116 1051 AlfCUCtrlInfo& cAlfCUCtrlParam = (*alfCUCtrlParam)[pcSlice->getSliceIdx()]; 1117 #else1118 AlfCUCtrlInfo& cAlfCUCtrlParam = vAlfCUCtrlParam[pcSlice->getSliceIdx()];1119 #endif1120 1052 if(cAlfCUCtrlParam.cu_control_flag) 1121 1053 { … … 1131 1063 m_pcEntropyCoder->encodeAlfCtrlParam(cAlfCUCtrlParam, m_pcAdaptiveLoopFilter->getNumCUsInPic()); 1132 1064 1133 #if LCU_SYNTAX_ALF1134 1065 } 1135 #endif1136 1066 } 1137 1067 } … … 1207 1137 UInt uiTotalCodedSize = 0; // for padding calcs. 1208 1138 UInt uiNumSubstreamsPerTile = iNumSubstreams; 1209 #if !REMOVE_TILE_DEPENDENCE 1210 #if WPP_SIMPLIFICATION 1211 if (pcPic->getPicSym()->getTileBoundaryIndependenceIdr() && iNumSubstreams > 1) 1212 #else 1213 if (pcPic->getPicSym()->getTileBoundaryIndependenceIdr() && pcSlice->getPPS()->getEntropyCodingSynchro()) 1214 #endif 1139 if (iNumSubstreams > 1) 1140 { 1215 1141 uiNumSubstreamsPerTile /= pcPic->getPicSym()->getNumTiles(); 1216 #else 1217 #if WPP_SIMPLIFICATION 1218 if (iNumSubstreams > 1) 1219 #else 1220 if (pcSlice->getPPS()->getEntropyCodingSynchro()) 1221 #endif 1222 { 1223 uiNumSubstreamsPerTile /= pcPic->getPicSym()->getNumTiles(); 1224 } 1225 #endif 1142 } 1226 1143 for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ ) 1227 1144 { … … 1233 1150 m_pcEntropyCoder->encodeSliceFinish(); 1234 1151 pcSubstreamsOut[ui].write( 1, 1 ); // stop bit. 1235 #if TILES_WPP_ENTRY_POINT_SIGNALLING1236 1152 pcSubstreamsOut[ui].writeAlignZero(); 1237 #endif1238 1153 // Byte alignment is necessary between tiles when tiles are independent. 1239 1154 uiTotalCodedSize += pcSubstreamsOut[ui].getNumberOfWrittenBits(); … … 1262 1177 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice ); 1263 1178 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 1264 #if TILES_WPP_ENTRY_POINT_SIGNALLING1265 1179 if (m_pcCfg->getTileLocationInSliceHeaderFlag()==0) 1266 1180 { … … 1268 1182 } 1269 1183 m_pcEntropyCoder->encodeTilesWPPEntryPoint( pcSlice ); 1270 #else1271 m_pcEntropyCoder->encodeSliceHeaderSubstreamTable(pcSlice);1272 #endif1273 1184 // Substreams... 1274 1185 TComOutputBitstream *pcOut = pcBitstreamRedirect; … … 1302 1213 uiBoundingAddrEntropySlice = m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx]; 1303 1214 uiNextCUAddr = min(uiBoundingAddrSlice, uiBoundingAddrEntropySlice); 1304 #if !REMOVE_TILE_DEPENDENCE1305 Bool bNextCUInNewSlice = (uiNextCUAddr >= uiRealEndAddress) || (uiNextCUAddr == m_uiStoredStartCUAddrForEncodingSlice[uiStartCUAddrSliceIdx]);1306 #endif1307 1215 // If current NALU is the first NALU of slice (containing slice header) and more NALUs exist (due to multiple entropy slices) then buffer it. 1308 1216 // If current NALU is the last NALU of slice and a NALU was buffered, then (a) Write current NALU (b) Update an write buffered NALU at approproate location in NALU list. 1309 1217 Bool bNALUAlignedWrittenToList = false; // used to ensure current NALU is not written more than once to the NALU list. 1310 #if !REMOVE_TILE_DEPENDENCE1311 if (pcSlice->getSPS()->getTileBoundaryIndependenceIdr() && !pcSlice->getSPS()->getTileBoundaryIndependenceIdr())1312 {1313 if (bNextCUInNewSlice)1314 {1315 if (!bEntropySlice) // there were no entropy slices1316 {1317 xWriteTileLocationToSliceHeader(nalu, pcBitstreamRedirect, pcSlice);1318 }1319 // (a) writing current NALU1320 writeRBSPTrailingBits(nalu.m_Bitstream);1321 accessUnit.push_back(new NALUnitEBSP(nalu));1322 bNALUAlignedWrittenToList = true;1323 1324 // (b) update and write buffered NALU1325 if (bEntropySlice) // if entropy slices existed in the slice then perform concatenation for the buffered nalu-bitstream and buffered payload bitstream1326 {1327 // Perform bitstream concatenation of slice header and partial slice payload1328 xWriteTileLocationToSliceHeader((*naluBuffered), pcBitstreamRedirect, pcSlice);1329 if (bIteratorAtListStart)1330 {1331 itLocationToPushSliceHeaderNALU = accessUnit.begin();1332 }1333 else1334 {1335 itLocationToPushSliceHeaderNALU++;1336 }1337 accessUnit.insert(itLocationToPushSliceHeaderNALU, (new NALUnitEBSP((*naluBuffered))) );1338 1339 // free buffered nalu1340 delete naluBuffered;1341 naluBuffered = NULL;1342 }1343 }1344 else // another entropy slice exists1345 {1346 // Is this start-of-slice NALU? i.e. the one containing slice header. If Yes, then buffer it.1347 if (!bEntropySlice)1348 {1349 // store a pointer to where NALU for slice header is to be written in NALU list1350 itLocationToPushSliceHeaderNALU = accessUnit.end();1351 if (accessUnit.begin() == accessUnit.end())1352 {1353 bIteratorAtListStart = true;1354 }1355 else1356 {1357 bIteratorAtListStart = false;1358 itLocationToPushSliceHeaderNALU--;1359 }1360 1361 // buffer nalu for later writing1362 #if H03881363 naluBuffered = new OutputNALUnit( pcSlice->getNalUnitType(), pcSlice->isReferenced() ? NAL_REF_IDC_PRIORITY_HIGHEST: NAL_REF_IDC_PRIORITY_LOWEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer() );1364 #else1365 naluBuffered = new OutputNALUnit(pcSlice->getNalUnitType(), pcSlice->isReferenced() ? NAL_REF_IDC_PRIORITY_HIGHEST: NAL_REF_IDC_PRIORITY_LOWEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer(), true);1366 #endif1367 copyNaluData( (*naluBuffered), nalu );1368 1369 // perform byte-alignment to get appropriate bitstream length (used for explicit tile location signaling in slice header)1370 writeRBSPTrailingBits((*pcBitstreamRedirect));1371 bNALUAlignedWrittenToList = true; // This is not really a write to bitsream but buffered for later. The flag is set to prevent writing of current NALU to list.1372 uiOneBitstreamPerSliceLength += pcBitstreamRedirect->getNumberOfWrittenBits(); // length of bitstream after byte-alignment1373 }1374 else // write out entropy slice1375 {1376 writeRBSPTrailingBits(nalu.m_Bitstream);1377 accessUnit.push_back(new NALUnitEBSP(nalu));1378 bNALUAlignedWrittenToList = true;1379 uiOneBitstreamPerSliceLength += nalu.m_Bitstream.getNumberOfWrittenBits(); // length of bitstream after byte-alignment1380 }1381 }1382 }1383 else1384 {1385 #endif1386 1218 xWriteTileLocationToSliceHeader(nalu, pcBitstreamRedirect, pcSlice); 1387 1219 writeRBSPTrailingBits(nalu.m_Bitstream); … … 1389 1221 bNALUAlignedWrittenToList = true; 1390 1222 uiOneBitstreamPerSliceLength += nalu.m_Bitstream.getNumberOfWrittenBits(); // length of bitstream after byte-alignment 1391 #if !REMOVE_TILE_DEPENDENCE1392 }1393 #endif1394 1223 1395 1224 if (!bNALUAlignedWrittenToList) … … 1410 1239 TComAPS cAPS; 1411 1240 allocAPS(&cAPS, pcSlice->getSPS()); 1412 #if SAO_UNIT_INTERLEAVING1413 1241 cAPS.setSaoInterleavingFlag(m_pcCfg->getSaoInterleavingFlag()); 1414 #endif1415 1242 // set entropy coder for RD 1416 1243 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice ); … … 1438 1265 1439 1266 // adaptive loop filter 1440 #if !LCU_SYNTAX_ALF1441 UInt64 uiDist, uiBits;1442 #endif1443 1267 if ( pcSlice->getSPS()->getUseALF()) 1444 1268 { … … 1446 1270 m_pcEntropyCoder->setBitstream ( m_pcBitCounter ); 1447 1271 m_pcAdaptiveLoopFilter->startALFEnc(pcPic, m_pcEntropyCoder ); 1448 #if LCU_SYNTAX_ALF1449 1272 AlfParamSet* pAlfEncParam = (pcSlice->getSPS()->getUseALFCoefInSlice())?( alfSliceParams ):( cAPS.getAlfParam()); 1450 1273 #if ALF_CHROMA_LAMBDA … … 1470 1293 #endif 1471 1294 1472 #else1473 ALFParam& cAlfParam = *( cAPS.getAlfParam());1474 1475 #if ALF_CHROMA_LAMBDA1476 #if HHI_INTERVIEW_SKIP1477 m_pcAdaptiveLoopFilter->ALFProcess( &cAlfParam, &vAlfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma(), uiDist, uiBits, m_pcEncTop->getInterViewSkip());1478 #else1479 m_pcAdaptiveLoopFilter->ALFProcess( &cAlfParam, &vAlfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma(), uiDist, uiBits);1480 #endif1481 #else1482 #if SAO_CHROMA_LAMBDA1483 #if HHI_INTERVIEW_SKIP1484 m_pcAdaptiveLoopFilter->ALFProcess( &cAlfParam, &vAlfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), uiDist, uiBits, m_pcEncTop->getInterViewSkip());1485 #else1486 m_pcAdaptiveLoopFilter->ALFProcess( &cAlfParam, &vAlfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), uiDist, uiBits);1487 #endif1488 #else1489 #if HHI_INTERVIEW_SKIP1490 m_pcAdaptiveLoopFilter->ALFProcess( &cAlfParam, &vAlfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), uiDist, uiBits, m_pcEncTop->getInterViewSkip());1491 #else1492 m_pcAdaptiveLoopFilter->ALFProcess( &cAlfParam, &vAlfCUCtrlParam, pcPic->getSlice(0)->getLambda(), uiDist, uiBits);1493 #endif1494 #endif1495 #endif1496 #endif1497 1295 m_pcAdaptiveLoopFilter->endALFEnc(); 1498 1296 … … 1511 1309 if (pcSlice->getSPS()->getUseALF()) 1512 1310 { 1513 #if LCU_SYNTAX_ALF1514 1311 pcPic->getSlice(s)->setAlfEnabledFlag( (pcSlice->getSPS()->getUseALFCoefInSlice())?(alfSliceParams[s].isEnabled[ALF_Y]):(cAPS.getAlfEnabled()) ); 1515 #else1516 pcPic->getSlice(s)->setAlfEnabledFlag((cAPS.getAlfParam()->alf_flag==1)?true:false);1517 #endif1518 1312 } 1519 1313 if (pcSlice->getSPS()->getUseSAO()) … … 1528 1322 case ENCODE_APS: 1529 1323 { 1530 #if NAL_REF_FLAG1531 1324 #if VIDYO_VPS_INTEGRATION | QC_MVHEVC_B0046 1532 1325 OutputNALUnit nalu(NAL_UNIT_APS, true, m_pcEncTop->getLayerId()); 1533 1326 #else 1534 1327 OutputNALUnit nalu(NAL_UNIT_APS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth()); 1535 #endif1536 #else1537 OutputNALUnit nalu(NAL_UNIT_APS, NAL_REF_IDC_PRIORITY_HIGHEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());1538 1328 #endif 1539 1329 encodeAPS(&(vAPS[iCodedAPSIdx]), nalu.m_Bitstream, pcSliceForAPS); … … 1562 1352 if(pcSlice->getSPS()->getUseALF()) 1563 1353 { 1564 #if LCU_SYNTAX_ALF1565 1354 m_pcAdaptiveLoopFilter->uninitALFEnc(alfSliceParams, alfCUCtrlParam); 1566 #endif1567 1355 m_pcAdaptiveLoopFilter->destroyPicAlfInfo(); 1568 1356 } … … 1575 1363 pcPic->removeUsedPelsMapBuffer() ; 1576 1364 #endif 1577 #if H HI_INTER_VIEW_MOTION_PRED1365 #if H3D_IVMP 1578 1366 pcPic->removeOrgDepthMapBuffer(); 1579 1367 #endif … … 1594 1382 digestStr = digestToString(sei_recon_picture_digest.digest); 1595 1383 1596 #if NAL_REF_FLAG1597 1384 #if VIDYO_VPS_INTEGRATION | QC_MVHEVC_B0046 1598 1385 OutputNALUnit nalu(NAL_UNIT_SEI, false, m_pcEncTop->getLayerId()); 1599 1386 #else 1600 1387 OutputNALUnit nalu(NAL_UNIT_SEI, false, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth()); 1601 #endif1602 #else1603 OutputNALUnit nalu(NAL_UNIT_SEI, NAL_REF_IDC_PRIORITY_LOWEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());1604 1388 #endif 1605 1389 … … 1656 1440 { 1657 1441 pAPS->createAlfParam(); 1658 #if LCU_SYNTAX_ALF1659 1442 //alf Enabled flag in APS is false after pAPS->createAlfParam(); 1660 1443 if(!pSPS->getUseALFCoefInSlice()) … … 1663 1446 pAPS->getAlfParam()->createALFParam(); 1664 1447 } 1665 #else1666 m_pcAdaptiveLoopFilter->allocALFParam(pAPS->getAlfParam());1667 #endif1668 1448 } 1669 1449 } … … 1688 1468 if(pAPS->getAlfParam() != NULL) 1689 1469 { 1690 #if LCU_SYNTAX_ALF1691 1470 if(!pSPS->getUseALFCoefInSlice()) 1692 1471 { 1693 1472 pAPS->getAlfParam()->releaseALFParam(); 1694 1473 } 1695 #else1696 m_pcAdaptiveLoopFilter->freeALFParam(pAPS->getAlfParam());1697 #endif1698 1474 pAPS->destroyAlfParam(); 1699 1475 } … … 1721 1497 1722 1498 cAPS.setSaoEnabled(pcSlice->getSPS()->getUseSAO() ? (cAPS.getSaoParam()->bSaoFlag[0] ):(false)); 1723 #if LCU_SYNTAX_ALF1724 1499 cAPS.setAlfEnabled(pcSlice->getSPS()->getUseALF() ? (cAPS.getAlfParam()->isEnabled[0]):(false)); 1725 #else1726 cAPS.setAlfEnabled(pcSlice->getSPS()->getUseALF() ? (cAPS.getAlfParam()->alf_flag ==1):(false));1727 #endif1728 1500 cAPS.setLoopFilterOffsetInAPS(m_pcCfg->getLoopFilterOffsetInAPS()); 1729 1501 cAPS.setLoopFilterDisable(m_pcCfg->getLoopFilterDisable()); … … 1764 1536 m_pcEntropyCoder->encodeDFParams(pcAPS); 1765 1537 } 1766 #if SAO_UNIT_INTERLEAVING1767 1538 m_pcEntropyCoder->encodeSaoParam(pcAPS); 1768 #else1769 if(pcAPS->getSaoEnabled())1770 {1771 m_pcEntropyCoder->encodeSaoParam(pcAPS->getSaoParam());1772 }1773 #endif1774 #if LCU_SYNTAX_ALF1775 1539 m_pcEntropyCoder->encodeAPSAlfFlag( pcAPS->getAlfEnabled()?1:0); 1776 #endif1777 1540 if(pcAPS->getAlfEnabled()) 1778 1541 { … … 1789 1552 TComSlice* pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); 1790 1553 Bool bCalcDist = false; 1791 #if DBL_CONTROL1792 1554 m_pcLoopFilter->setCfg(pcSlice->getPPS()->getDeblockingFilterControlPresent(), pcSlice->getLoopFilterDisable(), m_pcCfg->getLoopFilterBetaOffset(), m_pcCfg->getLoopFilterTcOffset(), m_pcCfg->getLFCrossTileBoundaryFlag()); 1793 #else1794 m_pcLoopFilter->setCfg(pcSlice->getLoopFilterDisable(), m_pcCfg->getLoopFilterBetaOffset(), m_pcCfg->getLoopFilterTcOffset(), m_pcCfg->getLFCrossTileBoundaryFlag());1795 #endif1796 1555 m_pcLoopFilter->loopFilterPic( pcPic ); 1797 1556 … … 1810 1569 m_pcAdaptiveLoopFilter->createPicAlfInfo(pcPic); 1811 1570 1812 #if LCU_SYNTAX_ALF1813 1571 AlfParamSet* alfParamSet; 1814 1572 std::vector<AlfCUCtrlInfo>* alfCUCtrlParam = NULL; … … 1817 1575 alfParamSet->createALFParam(); 1818 1576 m_pcAdaptiveLoopFilter->initALFEnc(false, true, 1, alfParamSet, alfCUCtrlParam); 1819 #else1820 ALFParam cAlfParam;1821 m_pcAdaptiveLoopFilter->allocALFParam(&cAlfParam);1822 #endif1823 1577 m_pcAdaptiveLoopFilter->startALFEnc(pcPic, m_pcEntropyCoder); 1824 1578 1825 1579 1826 #if LCU_SYNTAX_ALF1827 1580 1828 1581 #if ALF_CHROMA_LAMBDA … … 1848 1601 #endif 1849 1602 1850 #else1851 #if ALF_CHROMA_LAMBDA1852 m_pcAdaptiveLoopFilter->ALFProcess(&cAlfParam, NULL, pcSlice->getLambdaLuma(), pcSlice->getLambdaChroma(), ruiDist, ruiBits, m_pcEncTop->getInterViewSkip());1853 #if HHI_INTERVIEW_SKIP1854 #else1855 m_pcAdaptiveLoopFilter->ALFProcess(&cAlfParam, NULL, pcSlice->getLambdaLuma(), pcSlice->getLambdaChroma(), ruiDist, ruiBits);1856 #endif1857 #else1858 #if SAO_CHROMA_LAMBDA1859 #if HHI_INTERVIEW_SKIP1860 m_pcAdaptiveLoopFilter->ALFProcess(&cAlfParam, NULL, pcSlice->getLambdaLuma(), ruiDist, ruiBits, m_pcEncTop->getInterViewSkip());1861 #else1862 m_pcAdaptiveLoopFilter->ALFProcess(&cAlfParam, NULL, pcSlice->getLambdaLuma(), ruiDist, ruiBits);1863 #endif1864 #else1865 #if HHI_INTERVIEW_SKIP1866 m_pcAdaptiveLoopFilter->ALFProcess(&cAlfParam, NULL, pcSlice->getLambda(), ruiDist, ruiBits, m_pcEncTop->getInterViewSkip());1867 #else1868 m_pcAdaptiveLoopFilter->ALFProcess(&cAlfParam, NULL, pcSlice->getLambda(), ruiDist, ruiBits);1869 #endif1870 #endif1871 1872 #endif1873 #endif1874 1603 m_pcAdaptiveLoopFilter->endALFEnc(); 1875 1604 1876 #if LCU_SYNTAX_ALF1877 1605 alfParamSet->releaseALFParam(); 1878 1606 delete alfParamSet; 1879 1607 delete alfCUCtrlParam; 1880 #else1881 m_pcAdaptiveLoopFilter->freeALFParam(&cAlfParam);1882 #endif1883 1608 m_pcAdaptiveLoopFilter->PCMLFDisableProcess(pcPic); 1884 1609 m_pcAdaptiveLoopFilter->destroyPicAlfInfo(); … … 2032 1757 { 2033 1758 case NAL_UNIT_CODED_SLICE: return "SLICE"; 2034 #if H0566_TLA2035 1759 #if !QC_REM_IDV_B0046 2036 1760 case NAL_UNIT_CODED_SLICE_IDV: return "IDV"; … … 2038 1762 case NAL_UNIT_CODED_SLICE_CRA: return "CRA"; 2039 1763 case NAL_UNIT_CODED_SLICE_TLA: return "TLA"; 2040 #else2041 case NAL_UNIT_CODED_SLICE_CDR: return "CDR";2042 #endif2043 1764 case NAL_UNIT_CODED_SLICE_IDR: return "IDR"; 2044 1765 case NAL_UNIT_SEI: return "SEI"; … … 2275 1996 else 2276 1997 { 2277 #if H0566_TLA2278 1998 return NAL_UNIT_CODED_SLICE_CRA; 2279 #else2280 return NAL_UNIT_CODED_SLICE_CDR;2281 #endif2282 1999 } 2283 2000 } … … 2311 2028 if( m_pcCfg->getDecodingRefreshType() == 1 ) 2312 2029 { 2313 #if H0566_TLA2314 2030 return NAL_UNIT_CODED_SLICE_CRA; 2315 #else2316 return NAL_UNIT_CODED_SLICE_CDR;2317 #endif2318 2031 } 2319 2032 else if( m_pcCfg->getDecodingRefreshType() == 2 ) … … 2377 2090 { 2378 2091 { 2379 #if !TILES_WPP_ENTRY_POINT_SIGNALLING2380 Int iTransmitTileLocationInSliceHeader = (rpcSlice->getTileLocationCount()==0 || m_pcCfg->getTileLocationInSliceHeaderFlag()==0) ? 0 : 1;2381 rNalu.m_Bitstream.write(iTransmitTileLocationInSliceHeader, 1); // write flag indicating whether tile location information communicated in slice header2382 2383 if (iTransmitTileLocationInSliceHeader)2384 {2385 rNalu.m_Bitstream.write(rpcSlice->getTileLocationCount()-1, 5); // write number of tiles2386 2387 Int *aiDiff;2388 aiDiff = new Int [rpcSlice->getTileLocationCount()];2389 2390 // Find largest number of bits required by Diff2391 Int iLastSize = 0, iDiffMax = 0, iDiffMin = 0;2392 for (UInt uiIdx=0; uiIdx<rpcSlice->getTileLocationCount(); uiIdx++)2393 {2394 Int iCurDiff, iCurSize;2395 if (uiIdx==0)2396 {2397 iCurDiff = rpcSlice->getTileLocation( uiIdx );2398 iLastSize = rpcSlice->getTileLocation( uiIdx );2399 }2400 else2401 {2402 iCurSize = rpcSlice->getTileLocation( uiIdx ) - rpcSlice->getTileLocation( uiIdx-1 );2403 iCurDiff = iCurSize - iLastSize;2404 iLastSize = iCurSize;2405 }2406 // Store Diff so it may be written to slice header later without re-calculating.2407 aiDiff[uiIdx] = iCurDiff;2408 2409 if (iCurDiff>iDiffMax)2410 {2411 iDiffMax = iCurDiff;2412 }2413 if (iCurDiff<iDiffMin)2414 {2415 iDiffMin = iCurDiff;2416 }2417 }2418 2419 Int iDiffMinAbs, iDiffMaxAbs;2420 iDiffMinAbs = (iDiffMin<0) ? (-iDiffMin) : iDiffMin;2421 iDiffMaxAbs = (iDiffMax<0) ? (-iDiffMax) : iDiffMax;2422 2423 Int iBitsUsedByDiff = 0, iDiffAbsLargest;2424 iDiffAbsLargest = (iDiffMinAbs < iDiffMaxAbs) ? iDiffMaxAbs : iDiffMinAbs;2425 while (1)2426 {2427 if (iDiffAbsLargest >= (1 << iBitsUsedByDiff) )2428 {2429 iBitsUsedByDiff++;2430 }2431 else2432 {2433 break;2434 }2435 }2436 iBitsUsedByDiff++;2437 2438 if (iBitsUsedByDiff > 32)2439 {2440 printf("\nDiff magnitude uses more than 32-bits");2441 assert ( 0 );2442 exit ( 0 ); // trying to catch any problems with using fixed bits for Diff information2443 }2444 2445 rNalu.m_Bitstream.write( iBitsUsedByDiff-1, 5 ); // write number of bits used by Diff2446 2447 // Write diff to slice header (rNalu)2448 for (UInt uiIdx=0; uiIdx<rpcSlice->getTileLocationCount(); uiIdx++)2449 {2450 Int iCurDiff = aiDiff[uiIdx];2451 2452 // write sign of diff2453 if (uiIdx!=0)2454 {2455 if (iCurDiff<0)2456 {2457 rNalu.m_Bitstream.write(1, 1);2458 }2459 else2460 {2461 rNalu.m_Bitstream.write(0, 1);2462 }2463 }2464 2465 // write abs value of diff2466 Int iAbsDiff = (iCurDiff<0) ? (-iCurDiff) : iCurDiff;2467 if (iAbsDiff > ((((UInt64)1)<<32)-1))2468 {2469 printf("\niAbsDiff exceeds 32-bit limit");2470 exit(0);2471 }2472 rNalu.m_Bitstream.write( iAbsDiff, iBitsUsedByDiff-1 );2473 }2474 2475 delete [] aiDiff;2476 }2477 #endif2478 2092 } 2479 2093 -
trunk/source/Lib/TLibEncoder/TEncGOP.h
r189 r296 97 97 TComDepthMapGenerator* m_pcDepthMapGenerator; 98 98 #endif 99 #if H HI_INTER_VIEW_RESIDUAL_PRED99 #if H3D_IVRP 100 100 TComResidualGenerator* m_pcResidualGenerator; 101 101 #endif -
trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
r56 r296 100 100 * \param *psQTPart, iPartIdx, dLambda 101 101 */ 102 #if SAO_UNIT_INTERLEAVING103 102 Void TEncSampleAdaptiveOffset::rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda) 104 103 { … … 340 339 } 341 340 342 #else343 Void TEncSampleAdaptiveOffset::rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda)344 {345 Int iTypeIdx;346 Int iNumTotalType = MAX_NUM_SAO_TYPE;347 SAOQTPart* pOnePart = &(psQTPart[iPartIdx]);348 349 Int64 iEstDist;350 Int64 iOffsetOrg;351 Int64 iOffset;352 Int64 iCount;353 Int iClassIdx;354 Int uiShift = g_uiBitIncrement << 1;355 356 UInt uiDepth = pOnePart->PartLevel;357 358 m_iDistOrg [iPartIdx] = 0;359 360 for (iTypeIdx=-1; iTypeIdx<iNumTotalType; iTypeIdx++)361 {362 if( m_bUseSBACRD )363 {364 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);365 m_pcRDGoOnSbacCoder->resetBits();366 }367 else368 {369 m_pcEntropyCoder->resetEntropy();370 m_pcEntropyCoder->resetBits();371 }372 373 iEstDist = 0;374 375 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoUvlc(iTypeIdx+1);376 377 if (iTypeIdx>=0)378 {379 380 for(iClassIdx=1; iClassIdx < m_iNumClass[iTypeIdx]+1; iClassIdx++)381 {382 if(m_iCount [iPartIdx][iTypeIdx][iClassIdx])383 {384 #if FULL_NBIT385 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = (Int64) xRoundIbdi((Double)(m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx]<<g_uiBitDepth-8) / (Double)(m_iCount [iPartIdx][iTypeIdx][iClassIdx]<<m_uiSaoBitIncrease));386 #else387 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = (Int64) xRoundIbdi((Double)(m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx]<<g_uiBitIncrement) / (Double)(m_iCount [iPartIdx][iTypeIdx][iClassIdx]<<m_uiSaoBitIncrease));388 #endif389 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = Clip3(-m_iOffsetTh, m_iOffsetTh-1, (Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx]);390 {391 Int64 iterOffset, tempOffset;392 Int64 tempDist, tempRate;393 Double tempCost, tempMinCost;394 UInt codeLength, tempValue;395 396 iterOffset = m_iOffset[iPartIdx][iTypeIdx][iClassIdx];397 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = 0;398 tempMinCost = dLambda; // Assuming sending quantized value 0 results in zero offset and sending the value zero needs 1 bit. entropy coder can be used to measure the exact rate here.399 400 while (iterOffset != 0)401 {402 // Calculate the bits required for signalling the offset403 codeLength = 1;404 tempValue = (UInt)((iterOffset <= 0) ? ( (-iterOffset<<1) + 1 ) : (iterOffset<<1));405 while( 1 != tempValue )406 {407 tempValue >>= 1;408 codeLength += 2;409 }410 tempRate = (codeLength >> 1) + ((codeLength+1) >> 1);411 412 // Do the dequntization before distorion calculation413 tempOffset = iterOffset << m_uiSaoBitIncrease;414 tempDist = (( m_iCount [iPartIdx][iTypeIdx][iClassIdx]*tempOffset*tempOffset-m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx]*tempOffset*2 ) >> uiShift);415 416 tempCost = ((Double)tempDist + dLambda * (Double) tempRate);417 if(tempCost < tempMinCost)418 {419 tempMinCost = tempCost;420 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = iterOffset;421 }422 iterOffset = (iterOffset > 0) ? (iterOffset-1):(iterOffset+1);423 }424 }425 }426 else427 {428 m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx] = 0;429 m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = 0;430 }431 432 iCount = m_iCount [iPartIdx][iTypeIdx][iClassIdx];433 iOffset = m_iOffset[iPartIdx][iTypeIdx][iClassIdx] << m_uiSaoBitIncrease;434 iOffsetOrg = m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx];435 iEstDist += (( iCount*iOffset*iOffset-iOffsetOrg*iOffset*2 ) >> uiShift);436 m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoSvlc((Int)m_iOffset[iPartIdx][iTypeIdx][iClassIdx]);437 }438 m_iDist[iPartIdx][iTypeIdx] = iEstDist;439 m_iRate[iPartIdx][iTypeIdx] = m_pcEntropyCoder->getNumberOfWrittenBits();440 441 m_dCost[iPartIdx][iTypeIdx] = (Double)((Double)m_iDist[iPartIdx][iTypeIdx] + dLambda * (Double) m_iRate[iPartIdx][iTypeIdx]);442 443 if(m_dCost[iPartIdx][iTypeIdx] < m_dCostPartBest[iPartIdx])444 {445 m_iDistOrg [iPartIdx] = 0;446 m_dCostPartBest[iPartIdx] = m_dCost[iPartIdx][iTypeIdx];447 m_iTypePartBest[iPartIdx] = iTypeIdx;448 if( m_bUseSBACRD )449 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] );450 }451 }452 else453 {454 if(m_iDistOrg[iPartIdx] < m_dCostPartBest[iPartIdx] )455 {456 m_dCostPartBest[iPartIdx] = (Double) m_iDistOrg[iPartIdx] + m_pcEntropyCoder->getNumberOfWrittenBits()*dLambda ;457 m_iTypePartBest[iPartIdx] = -1;458 if( m_bUseSBACRD )459 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] );460 }461 }462 }463 464 pOnePart->bProcessed = true;465 pOnePart->bSplit = false;466 pOnePart->iMinDist = m_iTypePartBest[iPartIdx] >= 0 ? m_iDist[iPartIdx][m_iTypePartBest[iPartIdx]] : m_iDistOrg[iPartIdx];467 pOnePart->iMinRate = (Int) (m_iTypePartBest[iPartIdx] >= 0 ? m_iRate[iPartIdx][m_iTypePartBest[iPartIdx]] : 0);468 pOnePart->dMinCost = pOnePart->iMinDist + dLambda * pOnePart->iMinRate;469 pOnePart->iBestType = m_iTypePartBest[iPartIdx];470 if (pOnePart->iBestType != -1)471 {472 pOnePart->bEnableFlag = 1;473 pOnePart->iLength = m_iNumClass[pOnePart->iBestType];474 for (Int i=0; i<pOnePart->iLength ; i++)475 pOnePart->iOffset[i] = (Int) m_iOffset[iPartIdx][pOnePart->iBestType][i+1];476 }477 else478 {479 pOnePart->bEnableFlag = 0;480 pOnePart->iLength = 0;481 }482 }483 484 #endif485 341 /** Run partition tree disable 486 342 */ … … 488 344 { 489 345 SAOQTPart* pOnePart= &(psQTPart[iPartIdx]); 490 #if !SAO_UNIT_INTERLEAVING491 pOnePart->bEnableFlag = false;492 #endif493 346 pOnePart->bSplit = false; 494 347 pOnePart->iLength = 0; … … 556 409 dCostFinal = dCostSplit; 557 410 pOnePart->bSplit = true; 558 #if !SAO_UNIT_INTERLEAVING559 pOnePart->bEnableFlag = false;560 #endif561 411 pOnePart->iLength = 0; 562 412 pOnePart->iBestType = -1; … … 810 660 Int x, y; 811 661 812 #if SAO_UNIT_INTERLEAVING813 662 //--------- Band offset-----------// 814 663 stats = ppStats[SAO_BO]; … … 830 679 pRec += stride; 831 680 } 832 #else833 //--------- Band offset 0-----------//834 stats = ppStats[SAO_BO_0];835 count = ppCount[SAO_BO_0];836 pOrg = pOrgStart;837 pRec = pRecStart;838 for (y=0; y< height; y++)839 {840 for (x=0; x< width; x++)841 {842 classIdx = m_ppLumaTableBo0[pRec[x]];843 if (classIdx)844 {845 stats[classIdx] += (pOrg[x] - pRec[x]);846 count[classIdx] ++;847 }848 }849 pOrg += stride;850 pRec += stride;851 }852 853 //--------- Band offset 1-----------//854 stats = ppStats[SAO_BO_1];855 count = ppCount[SAO_BO_1];856 pOrg = pOrgStart;857 pRec = pRecStart;858 859 for (y=0; y< height; y++)860 {861 for (x=0; x< width; x++)862 {863 classIdx = m_ppLumaTableBo1[pRec[x]];864 if (classIdx)865 {866 stats[classIdx] += (pOrg[x] - pRec[x]);867 count[classIdx] ++;868 }869 }870 pOrg += stride;871 pRec += stride;872 }873 #endif874 681 //---------- Edge offset 0--------------// 875 682 stats = ppStats[SAO_EO_0]; … … 1166 973 1167 974 Int iIsChroma = (iYCbCr!=0)? 1:0; 1168 #if SAO_UNIT_INTERLEAVING1169 975 Int numSkipLine = iIsChroma? 2:4; 1170 976 if (m_saoInterleavingFlag == 0) … … 1172 978 numSkipLine = 0; 1173 979 } 1174 #endif1175 980 1176 981 iPicWidthTmp = m_iPicWidth >> iIsChroma; … … 1194 999 #endif 1195 1000 { 1196 #if SAO_UNIT_INTERLEAVING1197 1001 iStats = m_iOffsetOrg[iPartIdx][SAO_BO]; 1198 1002 iCount = m_iCount [iPartIdx][SAO_BO]; 1199 #else1200 iStats = m_iOffsetOrg[iPartIdx][SAO_BO_0];1201 iCount = m_iCount [iPartIdx][SAO_BO_0];1202 #endif1203 1003 1204 1004 pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr); 1205 1005 pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr); 1206 1006 1207 #if SAO_UNIT_INTERLEAVING1208 1007 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight : iLcuHeight-numSkipLine; 1209 1008 for (y=0; y<iEndY; y++) 1210 #else1211 for (y=0; y<iLcuHeight; y++)1212 #endif1213 1009 { 1214 1010 for (x=0; x<iLcuWidth; x++) 1215 1011 { 1216 #if SAO_UNIT_INTERLEAVING1217 1012 iClassIdx = m_lumaTableBo[pRec[x]]; 1218 #else1219 iClassIdx = m_ppLumaTableBo0[pRec[x]];1220 #endif1221 1013 if (iClassIdx) 1222 1014 { … … 1229 1021 } 1230 1022 1231 #if !SAO_UNIT_INTERLEAVING1232 iStats = m_iOffsetOrg[iPartIdx][SAO_BO_1];1233 iCount = m_iCount [iPartIdx][SAO_BO_1];1234 1235 pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr);1236 pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr);1237 1238 for (y=0; y<iLcuHeight; y++)1239 {1240 for (x=0; x<iLcuWidth; x++)1241 {1242 iClassIdx = m_ppLumaTableBo1[pRec[x]];1243 if (iClassIdx)1244 {1245 iStats[iClassIdx] += (pOrg[x] - pRec[x]);1246 iCount[iClassIdx] ++;1247 }1248 }1249 pOrg += iStride;1250 pRec += iStride;1251 }1252 #endif1253 1023 } 1254 1024 Int iSignLeft; … … 1275 1045 iStartX = (uiLPelX == 0) ? 1 : 0; 1276 1046 iEndX = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth; 1277 #if SAO_UNIT_INTERLEAVING1278 1047 for (y=0; y<iLcuHeight-numSkipLine; y++) 1279 #else1280 for (y=0; y<iLcuHeight; y++)1281 #endif1282 1048 { 1283 1049 iSignLeft = xSign(pRec[iStartX] - pRec[iStartX-1]); … … 1305 1071 1306 1072 iStartY = (uiTPelY == 0) ? 1 : 0; 1307 #if SAO_UNIT_INTERLEAVING1308 1073 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine; 1309 #else1310 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;1311 #endif1312 1074 if (uiTPelY == 0) 1313 1075 { … … 1347 1109 1348 1110 iStartY = (uiTPelY == 0) ? 1 : 0; 1349 #if SAO_UNIT_INTERLEAVING1350 1111 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine; 1351 #else1352 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;1353 #endif1354 1112 if (uiTPelY == 0) 1355 1113 { … … 1394 1152 1395 1153 iStartY = (uiTPelY == 0) ? 1 : 0; 1396 #if SAO_UNIT_INTERLEAVING1397 1154 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine; 1398 #else1399 iEndY = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;1400 #endif1401 1155 if (iStartY == 1) 1402 1156 { … … 1486 1240 for (iTypeIdx=0; iTypeIdx<iNumTotalType; iTypeIdx++) 1487 1241 { 1488 #if SAO_UNIT_INTERLEAVING1489 1242 for (iClassIdx=0; iClassIdx< (iTypeIdx < SAO_BO ? m_iNumClass[iTypeIdx] : SAO_MAX_BO_CLASSES) +1; iClassIdx++) 1490 #else1491 for (iClassIdx=0; iClassIdx<m_iNumClass[iTypeIdx]+1; iClassIdx++)1492 #endif1493 1243 { 1494 1244 m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx] += m_iOffsetOrg[iDownPartIdx][iTypeIdx][iClassIdx]; … … 1574 1324 Double dCostFinal = 0; 1575 1325 1576 #if !SAO_UNIT_INTERLEAVING 1577 Int iCb = 1; 1578 Int iCr = 2; 1579 Double dCostFinalCb = 0; 1580 Double dCostFinalCr = 0; 1581 #endif 1582 1583 #if SAO_UNIT_INTERLEAVING 1326 1584 1327 if ( m_saoInterleavingFlag) 1585 1328 { … … 1616 1359 } 1617 1360 } 1618 #else 1619 getSaoStats(pcSaoParam->psSaoPart[iY], iY); 1620 runQuadTreeDecision(pcSaoParam->psSaoPart[iY], 0, dCostFinal, m_uiMaxSplitLevel, m_dLambdaLuma); 1621 pcSaoParam->bSaoFlag[iY] = dCostFinal < m_iDistOrg[0] ? 1:0; 1622 if(pcSaoParam->bSaoFlag[iY]) 1623 { 1624 processSaoQuadTree(pcSaoParam->psSaoPart[iY], 0, 0); 1625 1626 resetStats(); 1627 getSaoStats(pcSaoParam->psSaoPart[iCb], iCb); 1628 runQuadTreeDecision(pcSaoParam->psSaoPart[iCb], 0, dCostFinalCb, m_uiMaxSplitLevel, m_dLambdaChroma); 1629 pcSaoParam->bSaoFlag[iCb] = dCostFinalCb < 0 ? 1:0; 1630 if (pcSaoParam->bSaoFlag[iCb]) 1631 { 1632 processSaoQuadTree(pcSaoParam->psSaoPart[iCb], 0, iCb); 1633 } 1634 1635 resetStats(); 1636 getSaoStats(pcSaoParam->psSaoPart[iCr], iCr); 1637 runQuadTreeDecision(pcSaoParam->psSaoPart[iCr], 0, dCostFinalCr, m_uiMaxSplitLevel, m_dLambdaChroma); 1638 pcSaoParam->bSaoFlag[iCr] = dCostFinalCr < 0 ? 1:0; 1639 if (pcSaoParam->bSaoFlag[iCr]) 1640 { 1641 processSaoQuadTree(pcSaoParam->psSaoPart[iCr], 0, iCr); 1642 } 1643 } 1644 #endif 1645 } 1646 #if SAO_UNIT_INTERLEAVING 1361 } 1647 1362 /** Check merge SAO unit 1648 1363 * \param saoUnitCurr current SAO unit … … 2260 1975 } 2261 1976 2262 #endif2263 1977 2264 1978 //! \} -
trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h
r56 r296 101 101 Void destroyEncBuffer(); 102 102 Void createEncBuffer(); 103 #if SAO_UNIT_INTERLEAVING104 103 Void assignSaoUnitSyntax(SaoLcuParam* saoLcuParam, SAOQTPart* saoPart, Bool &oneUnitFlag, Int yCbCr); 105 104 Void checkMerge(SaoLcuParam * lcuParamCurr,SaoLcuParam * lcuParamCheck, Int dir); … … 108 107 Void setMaxNumOffsetsPerPic(Int iVal) {m_maxNumOffsetsPerPic = iVal; } 109 108 Int getMaxNumOffsetsPerPic() {return m_maxNumOffsetsPerPic; } 110 #endif111 109 }; 112 110 -
trunk/source/Lib/TLibEncoder/TEncSbac.cpp
r210 r296 70 70 , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) 71 71 , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) 72 #if H HI_INTER_VIEW_RESIDUAL_PRED72 #if H3D_IVRP 73 73 , m_cResPredFlagSCModel ( 1, 1, NUM_RES_PRED_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 74 74 #endif … … 95 95 , m_cALFUvlcSCModel ( 1, 1, NUM_ALF_UVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 96 96 , m_cALFSvlcSCModel ( 1, 1, NUM_ALF_SVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 97 #if AMP_CTX98 97 , m_cCUAMPSCModel ( 1, 1, NUM_CU_AMP_CTX , m_contextModels + m_numContextModels, m_numContextModels) 99 #else100 , m_cCUXPosiSCModel ( 1, 1, NUM_CU_X_POS_CTX , m_contextModels + m_numContextModels, m_numContextModels)101 , m_cCUYPosiSCModel ( 1, 1, NUM_CU_Y_POS_CTX , m_contextModels + m_numContextModels, m_numContextModels)102 #endif103 98 , m_cSaoFlagSCModel ( 1, 1, NUM_SAO_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 104 99 , m_cSaoUvlcSCModel ( 1, 1, NUM_SAO_UVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 105 100 , m_cSaoSvlcSCModel ( 1, 1, NUM_SAO_SVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 106 #if SAO_UNIT_INTERLEAVING107 101 , m_cSaoMergeLeftSCModel ( 1, 1, NUM_SAO_MERGE_LEFT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 108 102 , m_cSaoMergeUpSCModel ( 1, 1, NUM_SAO_MERGE_UP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 109 103 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 110 #endif111 104 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 112 105 , m_cDmmFlagSCModel ( 1, 1, NUM_DMM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) … … 162 155 m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT); 163 156 m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT); 164 #if H HI_INTER_VIEW_RESIDUAL_PRED157 #if H3D_IVRP 165 158 m_cResPredFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_RES_PRED_FLAG ); 166 159 #endif 167 160 m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); 168 #if AMP_CTX169 161 m_cCUAMPSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS ); 170 #else171 m_cCUXPosiSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_X_POS );172 m_cCUYPosiSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_Y_POS );173 #endif174 162 m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); 175 163 m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); … … 195 183 m_cSaoUvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_UVLC ); 196 184 m_cSaoSvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_SVLC ); 197 #if SAO_UNIT_INTERLEAVING198 185 m_cSaoMergeLeftSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG ); 199 186 m_cSaoMergeUpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_UP_FLAG ); 200 187 m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); 201 #endif202 188 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 203 189 m_cDmmFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_FLAG ); … … 255 241 curCost += m_cCUMergeFlagExtSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT); 256 242 curCost += m_cCUMergeIdxExtSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT); 257 #if H HI_INTER_VIEW_RESIDUAL_PRED243 #if H3D_IVRP 258 244 curCost += m_cResPredFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_RES_PRED_FLAG); 259 245 #endif 260 246 curCost += m_cCUPartSizeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_PART_SIZE ); 261 #if AMP_CTX262 247 curCost += m_cCUAMPSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_CU_AMP_POS ); 263 #else264 curCost += m_cCUXPosiSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_CU_X_POS );265 curCost += m_cCUYPosiSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_CU_Y_POS );266 #endif267 248 curCost += m_cCUPredModeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_PRED_MODE ); 268 249 curCost += m_cCUIntraPredSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); … … 288 269 curCost += m_cSaoUvlcSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_UVLC ); 289 270 curCost += m_cSaoSvlcSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_SVLC ); 290 #if SAO_UNIT_INTERLEAVING291 271 curCost += m_cSaoMergeLeftSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG ); 292 272 curCost += m_cSaoMergeUpSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_MERGE_UP_FLAG ); 293 273 curCost += m_cSaoTypeIdxSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); 294 #endif295 274 296 275 if (curCost < bestCost) … … 329 308 m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT); 330 309 m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT); 331 #if H HI_INTER_VIEW_RESIDUAL_PRED310 #if H3D_IVRP 332 311 m_cResPredFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_RES_PRED_FLAG ); 333 312 #endif 334 313 m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); 335 #if AMP_CTX336 314 m_cCUAMPSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS ); 337 #else338 m_cCUXPosiSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_X_POS );339 m_cCUYPosiSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_Y_POS );340 #endif341 315 m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); 342 316 m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); … … 362 336 m_cSaoUvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_UVLC ); 363 337 m_cSaoSvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_SVLC ); 364 #if SAO_UNIT_INTERLEAVING365 338 m_cSaoMergeLeftSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG ); 366 339 m_cSaoMergeUpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_UP_FLAG ); 367 340 m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); 368 #endif369 341 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 370 342 m_cDmmFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_FLAG ); … … 404 376 #endif 405 377 406 #if HHI_MPI 378 #if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068 407 379 Void TEncSbac::codeSPS( TComSPS* pcSPS, Bool bIsDepth ) 408 380 #else … … 426 398 } 427 399 428 #if TILES_WPP_ENTRY_POINT_SIGNALLING429 400 Void TEncSbac::codeTilesWPPEntryPoint( TComSlice* pSlice ) 430 401 { … … 432 403 return; 433 404 } 434 #else435 Void TEncSbac::codeSliceHeaderSubstreamTable( TComSlice* pcSlice )436 {437 assert (0);438 }439 #endif440 405 441 406 Void TEncSbac::codeTerminatingBit( UInt uilsLast ) … … 449 414 } 450 415 451 #if OL_FLUSH452 416 Void TEncSbac::codeFlush() 453 417 { … … 459 423 m_pcBinIf->start(); 460 424 } 461 #endif462 425 463 426 Void TEncSbac::xWriteUnarySymbol( UInt uiSymbol, ContextModel* pcSCModel, Int iOffset ) … … 557 520 m_pcBinIf->encodeBinsEP( ( binValues << ruiGoRiceParam ) + uiCodeWord - ( uiQuotient << ruiGoRiceParam ), numBins + ruiGoRiceParam ); 558 521 559 #if EIGHT_BITS_RICE_CODE560 522 ruiGoRiceParam = g_aauiGoRiceUpdate[ ruiGoRiceParam ][ min<UInt>( uiSymbol, 23 ) ]; 561 #else562 ruiGoRiceParam = g_aauiGoRiceUpdate[ ruiGoRiceParam ][ min<UInt>( uiSymbol, 15 ) ];563 #endif564 523 565 524 if( bExGolomb ) … … 600 559 } 601 560 602 #if H HI_INTER_VIEW_MOTION_PRED561 #if H3D_IVMP 603 562 Void TEncSbac::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ) 604 563 #else … … 607 566 { 608 567 Int iSymbol = pcCU->getMVPIdx(eRefList, uiAbsPartIdx); 609 #if H HI_INTER_VIEW_MOTION_PRED568 #if H3D_IVMP 610 569 #else 611 570 Int iNum = AMVP_MAX_NUM_CANDS; … … 625 584 Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); 626 585 586 #if HHI_QTLPC_RAU_OFF_C0160 587 Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); 588 if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTLPC() && pcCU->getPic()->getReduceBitsFlag()) 589 #else 627 590 if(bDepthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC() && pcCU->getPic()->getReduceBitsFlag()) 591 #endif 628 592 { 629 593 TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); … … 664 628 if (eSize == SIZE_2NxN) 665 629 { 666 #if AMP_CTX667 630 m_pcBinIf->encodeBin(1, m_cCUAMPSCModel.get( 0, 0, 0 )); 668 #else669 m_pcBinIf->encodeBin(1, m_cCUYPosiSCModel.get( 0, 0, 0 ));670 #endif671 631 } 672 632 else 673 633 { 674 #if AMP_CTX675 634 m_pcBinIf->encodeBin(0, m_cCUAMPSCModel.get( 0, 0, 0 )); 676 635 m_pcBinIf->encodeBinEP((eSize == SIZE_2NxnU? 0: 1)); 677 #else678 m_pcBinIf->encodeBin(0, m_cCUYPosiSCModel.get( 0, 0, 0 ));679 m_pcBinIf->encodeBin((eSize == SIZE_2NxnU? 0: 1), m_cCUYPosiSCModel.get( 0, 0, 1 ));680 #endif681 636 } 682 637 } … … 697 652 if (eSize == SIZE_Nx2N) 698 653 { 699 #if AMP_CTX700 654 m_pcBinIf->encodeBin(1, m_cCUAMPSCModel.get( 0, 0, 0 )); 701 #else702 m_pcBinIf->encodeBin(1, m_cCUXPosiSCModel.get( 0, 0, 0 ));703 #endif704 655 } 705 656 else 706 657 { 707 #if AMP_CTX708 658 m_pcBinIf->encodeBin(0, m_cCUAMPSCModel.get( 0, 0, 0 )); 709 659 m_pcBinIf->encodeBinEP((eSize == SIZE_nLx2N? 0: 1)); 710 #else711 m_pcBinIf->encodeBin(0, m_cCUXPosiSCModel.get( 0, 0, 0 ));712 m_pcBinIf->encodeBin((eSize == SIZE_nLx2N? 0: 1), m_cCUXPosiSCModel.get( 0, 0, 1 ));713 #endif714 660 } 715 661 } … … 846 792 { 847 793 UInt uiNumCand = MRG_MAX_NUM_CANDS; 848 #if !MRG_IDX_CTX_RED849 UInt auiCtx[4] = { 0, 1, 2, 3 };850 #endif851 794 UInt uiUnaryIdx = pcCU->getMergeIndex( uiAbsPartIdx ); 852 795 uiNumCand = pcCU->getSlice()->getMaxNumMergeCand(); … … 871 814 { 872 815 const UInt uiSymbol = ui == uiUnaryIdx ? 0 : 1; 873 #if MRG_IDX_CTX_RED874 816 if ( ui==0 ) 875 817 { … … 880 822 m_pcBinIf->encodeBinEP( uiSymbol ); 881 823 } 882 #else883 m_pcBinIf->encodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, auiCtx[ui] ) );884 #endif885 824 if( uiSymbol == 0 ) 886 825 { … … 896 835 } 897 836 898 #if H HI_INTER_VIEW_RESIDUAL_PRED837 #if H3D_IVRP 899 838 Void 900 839 TEncSbac::codeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) … … 924 863 Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); 925 864 865 #if HHI_QTLPC_RAU_OFF_C0160 866 Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); 867 if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTLPC() && pcCU->getPic()->getReduceBitsFlag()) 868 #else 926 869 if(bDepthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC() && pcCU->getPic()->getReduceBitsFlag()) 870 #endif 927 871 { 928 872 TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); … … 1086 1030 1087 1031 if( uiDir == DMM_WEDGE_PREDTEX_D_IDX ) { xCodeWedgePredTexDeltaInfo ( pcCU, uiAbsPartIdx ); } 1032 #if LGE_DMM3_SIMP_C0044 1033 if( uiDir == DMM_WEDGE_PREDTEX_IDX ) { xCodeWedgePredTexInfo ( pcCU, uiAbsPartIdx ); } 1034 #endif 1088 1035 if( uiDir == DMM_CONTOUR_PREDTEX_D_IDX ) { xCodeContourPredTexDeltaInfo( pcCU, uiAbsPartIdx ); } 1089 1036 #endif … … 1122 1069 { 1123 1070 #endif 1124 #if !LOGI_INTRA_NAME_3MPM1125 Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);1126 #endif1127 1071 #if LGE_EDGE_INTRA_A0070 1128 1072 Bool bCodeEdgeIntra = false; … … 1135 1079 #endif 1136 1080 1137 #if LOGI_INTRA_NAME_3MPM1138 1081 Int uiPreds[3] = {-1, -1, -1}; 1139 #else1140 Int uiPreds[2] = {-1, -1};1141 #endif1142 1082 Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); 1143 1083 … … 1155 1095 { 1156 1096 m_pcBinIf->encodeBin( 1, m_cCUIntraPredSCModel.get( 0, 0, 0 ) ); 1157 #if LOGI_INTRA_NAME_3MPM1158 1097 m_pcBinIf->encodeBinEP( uiPredIdx ? 1 : 0 ); 1159 1098 if (uiPredIdx) … … 1161 1100 m_pcBinIf->encodeBinEP( uiPredIdx-1 ); 1162 1101 } 1163 #else1164 m_pcBinIf->encodeBinEP( uiPredIdx );1165 #endif1166 1102 } 1167 1103 else … … 1169 1105 m_pcBinIf->encodeBin( 0, m_cCUIntraPredSCModel.get( 0, 0, 0 ) ); 1170 1106 1171 #if LOGI_INTRA_NAME_3MPM1172 1107 if (uiPreds[0] > uiPreds[1]) 1173 1108 { … … 1182 1117 std::swap(uiPreds[1], uiPreds[2]); 1183 1118 } 1184 #endif1185 1119 1186 1120 for(Int i = (uiPredNum - 1); i >= 0; i--) … … 1189 1123 } 1190 1124 1191 #if LOGI_INTRA_NAME_3MPM1192 1125 m_pcBinIf->encodeBinsEP( uiDir, 5 ); 1193 1126 #if LGE_EDGE_INTRA_A0070 … … 1195 1128 if (uiDir == 31) m_pcBinIf->encodeBinsEP(0,1); 1196 1129 #endif 1197 #else1198 if ( uiDir < 31 )1199 {1200 m_pcBinIf->encodeBinsEP( uiDir, g_aucIntraModeBitsAng[ iIntraIdx ] - 1 );1201 }1202 else1203 {1204 m_pcBinIf->encodeBinsEP( 31, 5 );1205 m_pcBinIf->encodeBinEP( uiDir - 31 );1206 }1207 #endif1208 1130 } 1209 1131 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX … … 1245 1167 m_pcBinIf->encodeBin( 1, m_cCUChromaPredSCModel.get( 0, 0, 1 )); 1246 1168 } 1247 #if CHROMA_MODE_CODING1248 1169 m_pcBinIf->encodeBinsEP( uiIntraDirChroma, 2 ); 1249 #else1250 xWriteUnaryMaxSymbol( uiIntraDirChroma, m_cCUChromaPredSCModel.get( 0, 0 ) + 1, 0, 3 );1251 #endif1252 1170 } 1253 1171 return; … … 1277 1195 xWriteUnaryMaxSymbol( iRefFrame - 1, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_C )-2 ); 1278 1196 } 1197 #if MERL_VSP_C0152 1198 else if (iRefFrame < 0) // NOT_VALID 1199 { 1200 assert(0); 1201 } 1202 #endif 1279 1203 } 1280 1204 else … … 1288 1212 xWriteUnaryMaxSymbol( iRefFrame - 1, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( eRefList )-2 ); 1289 1213 } 1214 #if MERL_VSP_C0152 1215 else if (iRefFrame < 0) // NOT_VALID 1216 { 1217 assert(0); 1218 } 1219 #endif 1290 1220 } 1291 1221 return; … … 1294 1224 Void TEncSbac::codeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) 1295 1225 { 1296 #if H0111_MVD_L1_ZERO1297 1226 if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3) 1298 1227 { 1299 1228 return; 1300 1229 } 1301 #endif1302 1230 1303 1231 const TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefList ); … … 1352 1280 Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); 1353 1281 1354 #if H0736_AVC_STYLE_QP_RANGE1355 1282 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); 1356 1283 iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); 1357 #else1358 #if LOSSLESS_CODING1359 if(pcCU->getSlice()->getSPS()->getUseLossless())1360 {1361 if(iDQp > 25)1362 {1363 iDQp = iDQp - 52;1364 }1365 if(iDQp < -26)1366 {1367 iDQp = iDQp + 52;1368 }1369 }1370 #endif1371 #endif1372 1284 1373 1285 if ( iDQp == 0 ) … … 1380 1292 1381 1293 UInt uiSign = (iDQp > 0 ? 0 : 1); 1382 #if !H0736_AVC_STYLE_QP_RANGE1383 UInt uiQpBdOffsetY = 6*(g_uiBitIncrement + g_uiBitDepth - 8);1384 #endif1385 1294 1386 1295 m_pcBinIf->encodeBinEP(uiSign); 1387 1296 1388 #if H0736_AVC_STYLE_QP_RANGE1389 1297 assert(iDQp >= -(26+(qpBdOffsetY/2))); 1390 1298 assert(iDQp <= (25+(qpBdOffsetY/2))); 1391 1299 1392 1300 UInt uiMaxAbsDQpMinus1 = 24 + (qpBdOffsetY/2) + (uiSign); 1393 #else1394 assert(iDQp >= -(26+(Int)(uiQpBdOffsetY/2)));1395 assert(iDQp <= (25+(Int)(uiQpBdOffsetY/2)));1396 1397 UInt uiMaxAbsDQpMinus1 = 24 + (uiQpBdOffsetY/2) + (uiSign);1398 #endif1399 1301 UInt uiAbsDQpMinus1 = (UInt)((iDQp > 0)? iDQp : (-iDQp)) - 1; 1400 1302 xWriteUnaryMaxSymbol( uiAbsDQpMinus1, &m_cCUDeltaQpSCModel.get( 0, 0, 1 ), 1, uiMaxAbsDQpMinus1); … … 1422 1324 } 1423 1325 1424 #if BURST_IPCM1425 1326 /** Code I_PCM information. 1426 1327 * \param pcCU pointer to CU … … 1431 1332 */ 1432 1333 Void TEncSbac::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag) 1433 #else1434 /** Code I_PCM information.1435 * \param pcCU pointer to CU1436 * \param uiAbsPartIdx CU index1437 * \returns Void1438 *1439 * If I_PCM flag indicates that the CU is I_PCM, code its PCM alignment bits and codes.1440 */1441 Void TEncSbac::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx)1442 #endif1443 1334 { 1444 1335 UInt uiIPCM = (pcCU->getIPCMFlag(uiAbsPartIdx) == true)? 1 : 0; 1445 1336 1446 #if BURST_IPCM1447 1337 Bool writePCMSampleFlag = pcCU->getIPCMFlag(uiAbsPartIdx); 1448 1338 … … 1457 1347 } 1458 1348 } 1459 #else 1460 m_pcBinIf->encodeBinTrm (uiIPCM); 1461 #endif 1462 1463 #if BURST_IPCM 1349 1464 1350 if (writePCMSampleFlag) 1465 #else 1466 if (uiIPCM) 1467 #endif 1468 { 1469 #if !BURST_IPCM 1470 m_pcBinIf->encodePCMAlignBits(); 1471 #endif 1351 { 1472 1352 UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); 1473 1353 UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; … … 1526 1406 piPCMSample += uiWidth; 1527 1407 } 1528 #if BURST_IPCM1529 1408 numIPCM--; 1530 1409 if(numIPCM == 0) … … 1532 1411 m_pcBinIf->resetBac(); 1533 1412 } 1534 #else1535 m_pcBinIf->resetBac();1536 #endif1537 1413 } 1538 1414 } … … 1578 1454 1579 1455 // posX 1580 #if LAST_CTX_REDUCTION1581 1456 Int widthCtx = eTType? 4: width; 1582 1457 const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ widthCtx ] * ( g_aucConvertToBit[ widthCtx ] + 3 ) ); 1583 #else1584 const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ width ] * ( g_aucConvertToBit[ width ] + 3 ) );1585 #endif1586 1458 for( uiCtxLast = 0; uiCtxLast < uiGroupIdxX; uiCtxLast++ ) 1587 1459 { 1588 #if LAST_CTX_REDUCTION1589 1460 if (eTType) 1590 1461 { … … 1593 1464 else 1594 1465 { 1595 #endif1596 1466 m_pcBinIf->encodeBin( 1, *( pCtxX + puiCtxIdxX[ uiCtxLast ] ) ); 1597 #if LAST_CTX_REDUCTION 1598 } 1599 #endif 1467 } 1600 1468 } 1601 1469 if( uiGroupIdxX < g_uiGroupIdx[ width - 1 ]) 1602 1470 { 1603 #if LAST_CTX_REDUCTION1604 1471 if ( eTType ) 1605 1472 { … … 1608 1475 else 1609 1476 { 1610 #endif1611 1477 m_pcBinIf->encodeBin( 0, *( pCtxX + puiCtxIdxX[ uiCtxLast ] ) ); 1612 #if LAST_CTX_REDUCTION 1613 } 1614 #endif 1478 } 1615 1479 } 1616 1480 1617 1481 // posY 1618 #if LAST_CTX_REDUCTION1619 1482 Int heightCtx = eTType? 4: height; 1620 1483 const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ heightCtx ] * ( g_aucConvertToBit[ heightCtx ] + 3 ) ); 1621 #else1622 const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ height ] * ( g_aucConvertToBit[ height ] + 3 ) );1623 #endif1624 1484 for( uiCtxLast = 0; uiCtxLast < uiGroupIdxY; uiCtxLast++ ) 1625 1485 { 1626 #if LAST_CTX_REDUCTION1627 1486 if (eTType) 1628 1487 { … … 1631 1490 else 1632 1491 { 1633 #endif1634 1492 m_pcBinIf->encodeBin( 1, *( pCtxY + puiCtxIdxY[ uiCtxLast ] ) ); 1635 #if LAST_CTX_REDUCTION 1636 } 1637 #endif 1493 } 1638 1494 } 1639 1495 if( uiGroupIdxY < g_uiGroupIdx[ height - 1 ]) 1640 1496 { 1641 #if LAST_CTX_REDUCTION1642 1497 if (eTType) 1643 1498 { … … 1646 1501 else 1647 1502 { 1648 #endif1649 1503 m_pcBinIf->encodeBin( 0, *( pCtxY + puiCtxIdxY[ uiCtxLast ] ) ); 1650 #if LAST_CTX_REDUCTION 1651 } 1652 #endif 1504 } 1653 1505 } 1654 1506 if ( uiGroupIdxX > 3 ) … … 1740 1592 } 1741 1593 1742 #if MULTIBITS_DATA_HIDING1743 1594 UInt const tsig = pcCU->getSlice()->getPPS()->getTSIG(); 1744 1595 #if LOSSLESS_CODING … … 1755 1606 Bool beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; 1756 1607 #endif 1757 #endif1758 1608 1759 1609 // Find position of last coefficient … … 1765 1615 { 1766 1616 scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ]; 1767 #if MULTILEVEL_SIGMAP_EXT1768 1617 if( uiLog2BlockSize == 3 ) 1769 1618 { … … 1774 1623 scanCG = g_sigLastScanCG32x32; 1775 1624 } 1776 #endif1777 1625 } 1778 1626 else … … 1784 1632 const UInt uiNumBlkSide = uiWidth >> uiShift; 1785 1633 1786 #if !MULTILEVEL_SIGMAP_EXT1787 if( blockType > 3 )1788 {1789 #endif1790 1634 ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); 1791 1635 … … 1798 1642 UInt uiPosX = posLast - ( uiPosY << uiLog2BlockSize ); 1799 1643 UInt uiBlkIdx = uiNumBlkSide * (uiPosY >> uiShift) + (uiPosX >> uiShift); 1800 #if MULTILEVEL_SIGMAP_EXT1801 1644 if( uiWidth == 8 && uiHeight == 8 && (uiScanIdx == SCAN_HOR || uiScanIdx == SCAN_VER) ) 1802 1645 { … … 1810 1653 } 1811 1654 } 1812 #endif1813 1655 if( pcCoef[ posLast ] ) 1814 1656 { … … 1819 1661 } 1820 1662 while ( uiNumSig > 0 ); 1821 #if !MULTILEVEL_SIGMAP_EXT1822 }1823 else1824 {1825 1826 do1827 {1828 posLast = scan[ ++scanPosLast ];1829 uiNumSig -= ( pcCoef[ posLast ] != 0 );1830 }1831 while ( uiNumSig > 0 );1832 1833 }1834 #endif1835 1663 1836 1664 // Code position of last coefficient … … 1857 1685 UInt coeffSigns = 0; 1858 1686 1859 #if MULTIBITS_DATA_HIDING1860 1687 Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE; 1861 #endif1862 1688 1863 1689 if( iScanPosSig == scanPosLast ) … … 1866 1692 coeffSigns = ( pcCoef[ posLast ] < 0 ); 1867 1693 numNonZero = 1; 1868 #if MULTIBITS_DATA_HIDING1869 1694 lastNZPosInCG = iScanPosSig; 1870 1695 firstNZPosInCG = iScanPosSig; 1871 #endif1872 1696 iScanPosSig--; 1873 1697 } 1874 1698 1875 #if !MULTILEVEL_SIGMAP_EXT1876 if( blockType > 3 )1877 {1878 #endif1879 1699 // encode significant_coeffgroup_flag 1880 1700 Int iCGBlkPos = scanCG[ iSubSet ]; 1881 1701 Int iCGPosY = iCGBlkPos / uiNumBlkSide; 1882 1702 Int iCGPosX = iCGBlkPos - (iCGPosY * uiNumBlkSide); 1883 #if MULTILEVEL_SIGMAP_EXT1884 1703 if( uiWidth == 8 && uiHeight == 8 && (uiScanIdx == SCAN_HOR || uiScanIdx == SCAN_VER) ) 1885 1704 { … … 1887 1706 iCGPosX = (uiScanIdx == SCAN_VER ? iCGBlkPos : 0); 1888 1707 } 1889 #endif1890 #if !REMOVE_INFER_SIGGRP1891 Bool bInferredCGFlag = false;1892 #endif1893 #if REMOVE_INFER_SIGGRP1894 1708 if( iSubSet == iLastScanSet || iSubSet == 0) 1895 #else1896 if( iSubSet == iLastScanSet )1897 #endif1898 1709 { 1899 1710 uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; … … 1901 1712 else 1902 1713 { 1903 #if !REMOVE_INFER_SIGGRP1904 #if MULTILEVEL_SIGMAP_EXT1905 if( !TComTrQuant::bothCGNeighboursOne( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight ) && ( iSubSet ) )1906 #else1907 if( !TComTrQuant::bothCGNeighboursOne( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ) && ( iSubSet ) )1908 #endif1909 {1910 #endif1911 1714 UInt uiSigCoeffGroup = (uiSigCoeffGroupFlag[ iCGBlkPos ] != 0); 1912 #if MULTILEVEL_SIGMAP_EXT1913 1715 UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight ); 1914 #else1915 UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight );1916 #endif1917 1716 m_pcBinIf->encodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] ); 1918 #if !REMOVE_INFER_SIGGRP1919 }1920 else1921 {1922 uiSigCoeffGroupFlag[ iCGBlkPos ] = 1;1923 bInferredCGFlag = true;1924 }1925 #endif1926 1717 } 1927 1718 … … 1936 1727 uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); 1937 1728 uiSig = (pcCoef[ uiBlkPos ] != 0); 1938 #if REMOVE_INFER_SIGGRP1939 1729 if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) 1940 #else1941 if( iScanPosSig > iSubPos || bInferredCGFlag || numNonZero )1942 #endif1943 1730 { 1944 1731 uiCtxSig = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType ); … … 1950 1737 coeffSigns = 2 * coeffSigns + ( pcCoef[ uiBlkPos ] < 0 ); 1951 1738 numNonZero++; 1952 #if MULTIBITS_DATA_HIDING1953 1739 if( lastNZPosInCG == -1 ) 1954 1740 { … … 1956 1742 } 1957 1743 firstNZPosInCG = iScanPosSig; 1958 #endif1959 1744 } 1960 1745 } … … 1964 1749 iScanPosSig = iSubPos - 1; 1965 1750 } 1966 #if !MULTILEVEL_SIGMAP_EXT1967 }1968 else1969 {1970 1971 for( ; iScanPosSig >= iSubPos; iScanPosSig-- )1972 {1973 UInt uiBlkPos = scan[ iScanPosSig ];1974 UInt uiPosY = uiBlkPos >> uiLog2BlockSize;1975 UInt uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize );1976 UInt uiSig = 0;1977 if( pcCoef[ uiBlkPos ] != 0 )1978 {1979 uiSig = 1;1980 absCoeff[ numNonZero ] = abs( pcCoef[ uiBlkPos ] );1981 coeffSigns = 2 * coeffSigns + ( pcCoef[ uiBlkPos ] < 0 );1982 numNonZero++;1983 #if MULTIBITS_DATA_HIDING1984 if( lastNZPosInCG == -1 )1985 {1986 lastNZPosInCG = iScanPosSig;1987 }1988 firstNZPosInCG = iScanPosSig;1989 #endif1990 }1991 UInt uiCtxSig = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );1992 m_pcBinIf->encodeBin( uiSig, baseCtx[ uiCtxSig ] );1993 }1994 1995 }1996 #endif1997 1751 1998 1752 if( numNonZero > 0 ) 1999 1753 { 2000 #if MULTIBITS_DATA_HIDING2001 1754 Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= (Int)tsig ); 2002 #endif // MULTIBITS_DATA_HIDING2003 1755 2004 1756 UInt c1 = 1; 2005 #if !RESTRICT_GR1GR2FLAG_NUMBER2006 UInt c2 = 0;2007 #endif2008 #if LEVEL_CTX_LUMA_RED2009 1757 UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0; 2010 #else2011 UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 3 : 0;2012 #endif2013 1758 2014 1759 if( uiNumOne > 0 ) 2015 1760 { 2016 1761 uiCtxSet++; 2017 #if !LEVEL_CTX_LUMA_RED2018 if( uiNumOne > 3 && eTType==TEXT_LUMA)2019 {2020 uiCtxSet++;2021 }2022 #endif2023 1762 } 2024 1763 … … 2026 1765 ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet; 2027 1766 2028 #if RESTRICT_GR1GR2FLAG_NUMBER2029 1767 Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); 2030 1768 Int firstC2FlagIdx = -1; 2031 1769 for( Int idx = 0; idx < numC1Flag; idx++ ) 2032 #else2033 for ( Int idx = 0; idx < numNonZero; idx++ )2034 #endif2035 1770 { 2036 1771 UInt uiSymbol = absCoeff[ idx ] > 1; … … 2040 1775 c1 = 0; 2041 1776 2042 #if RESTRICT_GR1GR2FLAG_NUMBER2043 1777 if (firstC2FlagIdx == -1) 2044 1778 { 2045 1779 firstC2FlagIdx = idx; 2046 1780 } 2047 #endif2048 1781 } 2049 1782 else if( (c1 < 3) && (c1 > 0) ) … … 2056 1789 { 2057 1790 2058 #if RESTRICT_GR1GR2FLAG_NUMBER2059 1791 baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet; 2060 1792 if ( firstC2FlagIdx != -1) … … 2063 1795 m_pcBinIf->encodeBin( symbol, baseCtxMod[0] ); 2064 1796 } 2065 #else 2066 baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + 3 * uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + 3 * uiCtxSet; 1797 } 1798 1799 if( beValid && signHidden ) 1800 { 1801 m_pcBinIf->encodeBinsEP( (coeffSigns >> 1), numNonZero-1 ); 1802 } 1803 else 1804 { 1805 m_pcBinIf->encodeBinsEP( coeffSigns, numNonZero ); 1806 } 1807 1808 Int iFirstCoeff2 = 1; 1809 if (c1 == 0 || numNonZero > C1FLAG_NUMBER) 1810 { 2067 1811 for ( Int idx = 0; idx < numNonZero; idx++ ) 2068 1812 { 2069 if( absCoeff[ idx ] > 1 )2070 {2071 UInt symbol = absCoeff[ idx ] > 2;2072 m_pcBinIf->encodeBin( symbol, baseCtxMod[c2] );2073 c2 += (c2 < 2);2074 uiNumOne++;2075 }2076 }2077 #endif2078 }2079 2080 #if MULTIBITS_DATA_HIDING2081 if( beValid && signHidden )2082 {2083 m_pcBinIf->encodeBinsEP( (coeffSigns >> 1), numNonZero-1 );2084 }2085 else2086 {2087 m_pcBinIf->encodeBinsEP( coeffSigns, numNonZero );2088 }2089 #else2090 m_pcBinIf->encodeBinsEP( coeffSigns, numNonZero );2091 #endif2092 2093 #if RESTRICT_GR1GR2FLAG_NUMBER2094 Int iFirstCoeff2 = 1;2095 if (c1 == 0 || numNonZero > C1FLAG_NUMBER)2096 #else2097 if (c1 == 0)2098 #endif2099 {2100 for ( Int idx = 0; idx < numNonZero; idx++ )2101 {2102 #if RESTRICT_GR1GR2FLAG_NUMBER2103 1813 UInt baseLevel = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2 ) : 1; 2104 1814 … … 2112 1822 uiNumOne++; 2113 1823 } 2114 #else2115 if ( absCoeff[ idx ] > 2 )2116 {2117 xWriteGoRiceExGolomb( absCoeff[ idx ] - 3, uiGoRiceParam );2118 }2119 #endif2120 1824 } 2121 1825 } … … 2248 1952 } 2249 1953 } 2250 #if SAO_UNIT_INTERLEAVING2251 1954 /** Code SAO band position 2252 1955 * \param uiCode … … 2308 2011 } 2309 2012 } 2310 #endif2311 2013 /*! 2312 2014 **************************************************************************** … … 2417 2119 const UInt *puiCtxIdx; 2418 2120 Int ctx; 2419 #if LAST_CTX_REDUCTION2420 2121 Int widthCtx = eTType? 4 : width; 2421 2122 puiCtxIdx = g_uiLastCtx + (g_aucConvertToBit[ widthCtx ]*(g_aucConvertToBit[ widthCtx ]+3)); 2422 #else2423 puiCtxIdx = g_uiLastCtx + (g_aucConvertToBit[ width ]*(g_aucConvertToBit[ width ]+3));2424 #endif2425 2123 ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); 2426 2124 for (ctx = 0; ctx < g_uiGroupIdx[ width - 1 ]; ctx++) 2427 2125 { 2428 2126 Int ctxOffset = puiCtxIdx[ ctx ]; 2429 #if LAST_CTX_REDUCTION2430 2127 if (eTType) 2431 2128 { … … 2436 2133 else 2437 2134 { 2438 #endif2439 2135 pcEstBitsSbac->lastXBits[ ctx ] = iBitsX + pCtxX[ ctxOffset ].getEntropyBits( 0 ); 2440 2136 iBitsX += pCtxX[ ctxOffset ].getEntropyBits( 1 ); 2441 #if LAST_CTX_REDUCTION 2442 } 2443 #endif 2137 } 2444 2138 } 2445 2139 pcEstBitsSbac->lastXBits[ctx] = iBitsX; 2446 2140 2447 #if LAST_CTX_REDUCTION2448 2141 Int heightCtx = eTType? 4 : height; 2449 2142 puiCtxIdx = g_uiLastCtx + (g_aucConvertToBit[ heightCtx ]*(g_aucConvertToBit[ heightCtx ]+3)); 2450 #else2451 puiCtxIdx = g_uiLastCtx + (g_aucConvertToBit[ height ]*(g_aucConvertToBit[ height ]+3));2452 #endif2453 2143 ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); 2454 2144 for (ctx = 0; ctx < g_uiGroupIdx[ height - 1 ]; ctx++) 2455 2145 { 2456 2146 Int ctxOffset = puiCtxIdx[ ctx ]; 2457 #if LAST_CTX_REDUCTION2458 2147 if (eTType) 2459 2148 { … … 2464 2153 else 2465 2154 { 2466 #endif2467 2155 pcEstBitsSbac->lastYBits[ ctx ] = iBitsY + pCtxY[ ctxOffset ].getEntropyBits( 0 ); 2468 2156 iBitsY += pCtxY[ ctxOffset ].getEntropyBits( 1 ); 2469 #if LAST_CTX_REDUCTION 2470 } 2471 #endif 2157 } 2472 2158 } 2473 2159 pcEstBitsSbac->lastYBits[ctx] = iBitsY; … … 2661 2347 #endif 2662 2348 #if HHI_DMM_PRED_TEX 2349 #if LGE_DMM3_SIMP_C0044 2350 Void TEncSbac::xCodeWedgePredTexInfo( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2351 { 2352 Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); 2353 Int iBits = g_aucWedgeTexPredBitsListIdx[iIntraIdx]; 2354 2355 UInt uiTabIdx = pcCU->getWedgePredTexIntraTabIdx( uiAbsPartIdx ); 2356 2357 for ( Int i = 0; i < iBits; i++ ) 2358 { 2359 m_pcBinIf->encodeBin( ( uiTabIdx >> i ) & 1, m_cDmmDataSCModel.get(0, 0, 3) ); 2360 } 2361 } 2362 #endif 2363 2663 2364 Void TEncSbac::xCodeWedgePredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2664 2365 { 2366 #if LGE_DMM3_SIMP_C0044 2367 xCodeWedgePredTexInfo( pcCU, uiAbsPartIdx ); 2368 #endif 2665 2369 Int iDeltaDC1 = pcCU->getWedgePredTexDeltaDC1( uiAbsPartIdx ); 2666 2370 Int iDeltaDC2 = pcCU->getWedgePredTexDeltaDC2( uiAbsPartIdx ); -
trunk/source/Lib/TLibEncoder/TEncSbac.h
r210 r296 102 102 #endif 103 103 104 #if HHI_MPI 104 #if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068 105 105 Void codeSPS ( TComSPS* pcSPS, Bool bIsDepth ); 106 106 #else … … 111 111 Void codeSliceHeader ( TComSlice* pcSlice ); 112 112 Void codeTileMarkerFlag(TComSlice* pcSlice) {printf("Not supported\n"); assert(0); exit(1);} 113 #if TILES_WPP_ENTRY_POINT_SIGNALLING114 113 Void codeTilesWPPEntryPoint( TComSlice* pSlice ); 115 #else116 Void codeSliceHeaderSubstreamTable( TComSlice* pcSlice );117 #endif118 114 Void codeTerminatingBit ( UInt uilsLast ); 119 115 Void codeSliceFinish (); 120 #if OL_FLUSH121 116 Void codeFlush (); 122 117 Void encodeStart (); 123 #endif124 118 125 119 Void codeAlfFlag ( UInt uiCode ); … … 127 121 Void codeAlfSvlc ( Int uiCode ); 128 122 Void codeAlfCtrlDepth (); 129 #if LCU_SYNTAX_ALF130 123 Void codeAPSAlflag(UInt uiCode) {assert (0); return;} 131 124 Void codeAlfFixedLengthIdx( UInt idx, UInt maxValue){ assert (0); return;} 132 #endif133 125 134 126 Void codeAlfCtrlFlag ( UInt uiSymbol ); … … 137 129 Void codeSaoUvlc ( UInt uiCode ); 138 130 Void codeSaoSvlc ( Int uiCode ); 139 #if SAO_UNIT_INTERLEAVING140 131 Void codeSaoRun ( UInt uiCode, UInt uiMaxValue ) {;} 141 132 Void codeSaoMergeLeft ( UInt uiCode, UInt uiCompIdx ); … … 143 134 Void codeSaoTypeIdx ( UInt uiCode); 144 135 Void codeSaoUflc ( UInt uiCode); 145 #endif146 136 Void codeScalingList ( TComScalingList* scalingList ){ assert (0); return;}; 147 137 … … 178 168 #endif 179 169 #if HHI_DMM_PRED_TEX 170 #if LGE_DMM3_SIMP_C0044 171 Void xCodeWedgePredTexInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 172 #endif 180 173 Void xCodeWedgePredTexDeltaInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 181 174 Void xCodeContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx ); … … 213 206 Void codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 214 207 Void codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 215 #if H HI_INTER_VIEW_RESIDUAL_PRED208 #if H3D_IVRP 216 209 Void codeResPredFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 217 210 #endif 218 211 Void codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 219 #if H HI_INTER_VIEW_MOTION_PRED212 #if H3D_IVMP 220 213 Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ); 221 214 #else … … 225 218 Void codePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 226 219 Void codePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 227 #if BURST_IPCM228 220 Void codeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag); 229 #else230 Void codeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx );231 #endif232 221 Void codeTransformSubdivFlag ( UInt uiSymbol, UInt uiCtx ); 233 222 Void codeQtCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ); … … 274 263 ContextModel3DBuffer m_cCUMergeFlagExtSCModel; 275 264 ContextModel3DBuffer m_cCUMergeIdxExtSCModel; 276 #if H HI_INTER_VIEW_RESIDUAL_PRED265 #if H3D_IVRP 277 266 ContextModel3DBuffer m_cResPredFlagSCModel; 278 267 #endif … … 302 291 ContextModel3DBuffer m_cALFUvlcSCModel; 303 292 ContextModel3DBuffer m_cALFSvlcSCModel; 304 #if AMP_CTX305 293 ContextModel3DBuffer m_cCUAMPSCModel; 306 #else307 ContextModel3DBuffer m_cCUXPosiSCModel;308 ContextModel3DBuffer m_cCUYPosiSCModel;309 #endif310 294 ContextModel3DBuffer m_cSaoFlagSCModel; 311 295 ContextModel3DBuffer m_cSaoUvlcSCModel; 312 296 ContextModel3DBuffer m_cSaoSvlcSCModel; 313 #if SAO_UNIT_INTERLEAVING314 297 ContextModel3DBuffer m_cSaoMergeLeftSCModel; 315 298 ContextModel3DBuffer m_cSaoMergeUpSCModel; 316 299 ContextModel3DBuffer m_cSaoTypeIdxSCModel; 317 #endif318 300 319 301 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX -
trunk/source/Lib/TLibEncoder/TEncSearch.cpp
r210 r296 205 205 #endif 206 206 207 #if H HI_INTER_VIEW_MOTION_PRED207 #if H3D_IVMP 208 208 const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + 1; 209 209 for( Int iNum = 0; iNum < iNumAMVPCands+1; iNum++) … … 696 696 UInt TEncSearch::xPatternRefinement( TComPattern* pcPatternKey, 697 697 TComMv baseRefMv, 698 Int iFrac, TComMv& rcMvFrac ) 698 Int iFrac, TComMv& rcMvFrac 699 ) 699 700 { 700 701 UInt uiDist; … … 1079 1080 pcCU ->setTrIdxSubParts ( uiTrDepth, uiAbsPartIdx, uiFullDepth ); 1080 1081 1081 #if H0736_AVC_STYLE_QP_RANGE1082 1082 m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); 1083 #else1084 m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 );1085 #endif1086 1083 1087 1084 #if RDOQ_CHROMA_LAMBDA … … 1277 1274 UInt uiAbsSum = 0; 1278 1275 1279 #if H0736_AVC_STYLE_QP_RANGE1280 1276 if(eText == TEXT_CHROMA_U) 1281 1277 { … … 1286 1282 m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() ); 1287 1283 } 1288 #else1289 if(eText == TEXT_CHROMA_U)1290 m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset() );1291 else1292 m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );1293 #endif1294 1284 1295 1285 #if RDOQ_CHROMA_LAMBDA … … 1688 1678 // reconstruct residual based on mask + DC residuals 1689 1679 Pel apDCResiValues[2]; 1690 Pel apDCRecoValues[2];1680 //Pel apDCRecoValues[2]; 1691 1681 for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) 1692 1682 { … … 1695 1685 Pel pRecoValue = GetIdx2DepthValue( pPredIdx + pResiIdx ); 1696 1686 1697 apDCRecoValues[uiSegment] = pRecoValue;1687 //apDCRecoValues[uiSegment] = pRecoValue; 1698 1688 apDCResiValues[uiSegment] = pRecoValue - apDCPredValues[uiSegment]; 1699 1689 } … … 2014 2004 UInt uiQNumParts = pcCU->getTotalNumPart() >> 2; 2015 2005 UInt uiWidthBit = pcCU->getIntraSizeIdx(0); 2016 #if FIX_RDO_NEGDIST2017 2006 Dist uiOverallDistY = 0; 2018 2007 Dist uiOverallDistC = 0; 2019 #else2020 UInt uiOverallDistY = 0;2021 UInt uiOverallDistC = 0;2022 #endif2023 2008 UInt CandNum; 2024 2009 Double CandCostList[ FAST_UDI_MAX_RDMODE_NUM ]; … … 2045 2030 2046 2031 //===== determine set of modes to be tested (using prediction signal only) ===== 2047 #if LOGI_INTRA_NAME_3MPM2048 2032 Int numModesAvailable = 35; //total number of Intra modes 2049 #else2050 Int numModesAvailable = g_aucIntraModeNumAng[uiWidthBit];2051 #endif2052 2033 Pel* piOrg = pcOrgYuv ->getLumaAddr( uiPU, uiWidth ); 2053 2034 Pel* piPred = pcPredYuv->getLumaAddr( uiPU, uiWidth ); … … 2157 2138 CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList ); 2158 2139 2159 #if (HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX) && !FIX_DMM_NEG_DIST2160 if( bTestDmm ) bTestDmm = uiSad ? true : false;2161 #endif2162 2140 #if LGE_EDGE_INTRA_A0070 2163 2141 if ( bTestEdgeIntra ) bTestEdgeIntra = uiSad ? true : false; … … 2166 2144 2167 2145 #if FAST_UDI_USE_MPM 2168 #if LOGI_INTRA_NAME_3MPM2169 2146 Int uiPreds[3] = {-1, -1, -1}; 2170 #else2171 Int uiPreds[2] = {-1, -1};2172 #endif2173 2147 Int iMode = -1; 2174 2148 Int numCand = pcCU->getIntraDirLumaPredictor( uiPartOffset, uiPreds, &iMode ); 2175 #if LOGI_INTRA_NAME_3MPM2176 2149 if( iMode >= 0 ) 2177 2150 { 2178 2151 numCand = iMode; 2179 2152 } 2180 #else2181 if( iMode >= 0 )2182 {2183 numCand = 1;2184 uiPreds[0] = iMode;2185 }2186 #endif2187 2153 2188 2154 for( Int j=0; j < numCand; j++) … … 2252 2218 Int iTexDeltaDC1 = 0; 2253 2219 Int iTexDeltaDC2 = 0; 2220 #if LGE_DMM3_SIMP_C0044 2221 UInt uiTexIntraIdx = 0; 2222 findWedgeTexMinDist( pcCU, uiPartOffset, piOrg, piPred, uiStride, uiWidth, uiHeight, uiTexTabIdx, iTexDeltaDC1, iTexDeltaDC2, bAboveAvail, bLeftAvail, uiTexIntraIdx); 2223 pcCU->setWedgePredTexIntraTabIdxSubParts( uiTexIntraIdx, uiPartOffset, uiDepth + uiInitTrDepth ); 2224 #else 2254 2225 findWedgeTexMinDist( pcCU, uiPartOffset, piOrg, piPred, uiStride, uiWidth, uiHeight, uiTexTabIdx, iTexDeltaDC1, iTexDeltaDC2, bAboveAvail, bLeftAvail ); 2226 #endif 2255 2227 pcCU->setWedgePredTexTabIdxSubParts ( uiTexTabIdx, uiPartOffset, uiDepth + uiInitTrDepth ); 2256 2228 pcCU->setWedgePredTexDeltaDC1SubParts( iTexDeltaDC1, uiPartOffset, uiDepth + uiInitTrDepth ); … … 2295 2267 2296 2268 UInt uiBestPUMode = 0; 2297 #if FIX_RDO_NEGDIST2298 2269 Dist uiBestPUDistY = 0; 2299 2270 Dist uiBestPUDistC = 0; 2300 #else2301 UInt uiBestPUDistY = 0;2302 UInt uiBestPUDistC = 0;2303 #endif2304 2271 Double dBestPUCost = MAX_DOUBLE; 2305 2272 #if RWTH_SDC_DLT_B0036 … … 2344 2311 for( UInt uiSDC=0; uiSDC<=uiUseSDC; uiSDC++ ) 2345 2312 { 2313 #if FIX_SDC_ENC_C0143 2314 for( UInt uiRes = 0; uiRes<=uiSDC; uiRes++ ) 2315 #else 2346 2316 for( UInt uiRes = 0; uiRes<=uiUseSDC; uiRes++ ) 2317 #endif 2347 2318 { 2348 2319 #endif … … 2897 2868 Void TEncSearch::xGetInterPredictionError( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, UInt& ruiErr, Bool bHadamard ) 2898 2869 { 2870 #if !MERL_VSP_C0152 2899 2871 motionCompensation( pcCU, &m_tmpYuvPred, REF_PIC_LIST_X, iPartIdx ); 2900 2872 #endif 2901 2873 UInt uiAbsPartIdx = 0; 2902 2874 Int iWidth = 0; 2903 2875 Int iHeight = 0; 2904 2876 pcCU->getPartIndexAndSize( iPartIdx, uiAbsPartIdx, iWidth, iHeight ); 2905 2877 #if MERL_VSP_C0152 2878 motionCompensation( pcCU, &m_tmpYuvPred, pcCU->getZorderIdxInCU(), REF_PIC_LIST_X, iPartIdx ); 2879 #endif 2906 2880 DistParam cDistParam; 2907 2881 … … 2943 2917 #else 2944 2918 #if LG_RESTRICTEDRESPRED_M24766 2919 #if MERL_VSP_C0152 || MTK_MDIVRP_C0138 2920 #if !MTK_MDIVRP_C0138 2921 Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* rpcResiPredYuv, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost, Int* iVSPIndexTrue ) 2922 #endif 2923 #if !MERL_VSP_C0152 2924 Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost ) 2925 #endif 2926 #if MERL_VSP_C0152 && MTK_MDIVRP_C0138 2927 Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost, Int* iVSPIndexTrue ) 2928 #endif 2929 #else 2945 2930 Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* rpcResiPredYuv, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost ) 2931 #endif 2946 2932 #else 2947 2933 Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost ) … … 2950 2936 { 2951 2937 #if !CU_BASED_MRG_CAND_LIST 2952 #if H HI_INTER_VIEW_MOTION_PRED2938 #if H3D_IVMP 2953 2939 TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists 2954 2940 UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; … … 2988 2974 } 2989 2975 #else 2976 #if MERL_VSP_C0152 2977 pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, uiDepth, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand, iVSPIndexTrue ); 2978 #else 2990 2979 pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, uiDepth, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); 2991 2980 #endif 2992 2993 #if HHI_INTER_VIEW_MOTION_PRED 2981 #endif 2982 2983 2984 #if H3D_IVMP 2994 2985 const int maxNumMergeCand = MRG_MAX_NUM_CANDS_SIGNALED + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 2995 2986 #endif 2996 #if LG_RESTRICTEDRESPRED_M24766 2987 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 2997 2988 Int iPUResiPredShift[4]; 2998 2989 Int iLastAddResiShift = -1000; … … 3009 3000 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx ); 3010 3001 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx ); 3011 #if LG_RESTRICTEDRESPRED_M24766 3002 #if MERL_VSP_C0152 3003 { 3004 Int iVSPIdx = 0; 3005 Int numVSPIdx; 3006 numVSPIdx = 3; 3007 for (Int i = 0; i < numVSPIdx; i++) 3008 { 3009 if (iVSPIndexTrue[i] == uiMergeCand) 3010 { 3011 iVSPIdx = i+1; 3012 break; 3013 } 3014 } 3015 pcCU->setVSPIndexSubParts( iVSPIdx, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) ); 3016 } 3017 #endif 3018 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 3012 3019 Int iAddResiShift; 3013 3020 UInt uiPartAddr; … … 3040 3047 xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() ); 3041 3048 uiBitsCand = uiMergeCand + 1; 3042 #if H HI_INTER_VIEW_MOTION_PRED3049 #if H3D_IVMP 3043 3050 if (uiMergeCand == maxNumMergeCand - 1 ) 3044 3051 #else … … 3059 3066 } 3060 3067 } 3061 #if LG_RESTRICTEDRESPRED_M24766 3068 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 3062 3069 if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0) 3063 3070 { … … 3078 3085 */ 3079 3086 #if AMP_MRG 3080 #if LG_RESTRICTEDRESPRED_M24766 3087 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 3081 3088 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv* rpcResiPredYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG ) 3082 3089 #else 3083 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG 3090 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG) 3084 3091 #endif 3085 3092 #else … … 3135 3142 PartSize ePartSize = pcCU->getPartitionSize( 0 ); 3136 3143 3137 #if H0111_MVD_L1_ZERO3138 3144 Int bestBiPRefIdxL1 = 0; 3139 3145 Int bestBiPMvpL1 = 0; 3140 3146 UInt biPDistTemp = MAX_INT; 3141 #endif3142 3147 3143 3148 #if ZERO_MVD_EST … … 3148 3153 3149 3154 #if CU_BASED_MRG_CAND_LIST 3150 #if H HI_INTER_VIEW_MOTION_PRED3155 #if H3D_IVMP 3151 3156 TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists 3152 3157 UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; … … 3159 3164 #endif 3160 3165 3161 #if H HI_INTER_VIEW_MOTION_PRED3166 #if H3D_IVMP 3162 3167 Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 3163 3168 #endif … … 3178 3183 UInt auiZeroMvdBits[3]; 3179 3184 #endif 3180 #if H0111_MVD_L1_ZERO3181 3185 UInt bestBiPDist = MAX_INT; 3182 #endif3183 3186 3184 3187 UInt uiCostTempL0[MAX_NUM_REF]; 3185 3188 for (Int iNumRef=0; iNumRef < MAX_NUM_REF; iNumRef++) uiCostTempL0[iNumRef] = MAX_UINT; 3186 3189 UInt uiBitsTempL0[MAX_NUM_REF]; 3187 #if LG_RESTRICTEDRESPRED_M24766 3190 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 3188 3191 Int iPUResiPredShift[4] = {0, 0, 0, 0}; 3189 3192 #endif … … 3191 3194 3192 3195 pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight ); 3193 3196 #if MERL_VSP_C0152 3197 //reset the VSP flag to be 0 3198 pcCU->setVSPIndexSubParts( 0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr) ); 3199 #endif 3194 3200 #if AMP_MRG 3195 3201 Bool bTestNormalMC = true; … … 3203 3209 { 3204 3210 #endif 3205 #if LG_RESTRICTEDRESPRED_M24766 3211 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 3206 3212 Bool bLastResiFlag = false; 3207 3213 #endif 3214 3208 3215 // Uni-directional prediction 3209 3216 for ( Int iRefList = 0; iRefList < iNumPredDir; iRefList++ ) … … 3213 3220 for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ ) 3214 3221 { 3215 #if LG_RESTRICTEDRESPRED_M24766 3222 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 3216 3223 if( pcCU->getResPredFlag( 0 )) 3217 3224 { … … 3236 3243 if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--; 3237 3244 } 3238 #if H0111_MVD_L1_ZERO3239 3245 #if ZERO_MVD_EST 3240 3246 xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp, &uiZeroMvdDistTemp); 3241 3247 #else 3242 3248 xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp); 3243 #endif3244 #else3245 #if ZERO_MVD_EST3246 xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &uiZeroMvdDistTemp);3247 #else3248 xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp]);3249 #endif3250 3249 #endif 3251 3250 aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr); 3252 3251 aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr); 3253 3252 3254 #if H0111_MVD_L1_ZERO3255 3253 if(pcCU->getSlice()->getMvdL1ZeroFlag() && iRefList==1 && biPDistTemp < bestBiPDist) 3256 3254 { … … 3259 3257 bestBiPRefIdxL1 = iRefIdxTemp; 3260 3258 } 3261 #endif 3262 3263 #if HHI_INTER_VIEW_MOTION_PRED 3259 3260 #if H3D_IVMP 3264 3261 uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][iNumAMVPCands]; 3265 3262 #else … … 3372 3369 pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 3373 3370 3374 #if H0111_MVD_L1_ZERO3375 3371 if(!pcCU->getSlice()->getMvdL1ZeroFlag()) 3376 3372 { 3377 #endif3378 3373 // storing list 1 prediction signal for iterative bi-directional prediction 3379 3374 if ( eRefPicList == REF_PIC_LIST_1 ) 3380 3375 { 3381 3376 TComYuv* pcYuvPred = &m_acYuvPred[iRefList]; 3377 #if MERL_VSP_C0152 3378 motionCompensation ( pcCU, pcYuvPred, pcCU->getZorderIdxInCU(), eRefPicList, iPartIdx ); 3379 #else 3382 3380 motionCompensation ( pcCU, pcYuvPred, eRefPicList, iPartIdx ); 3381 #endif 3383 3382 } 3384 3383 if ( (pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 )) && eRefPicList == REF_PIC_LIST_0 ) 3385 3384 { 3386 3385 TComYuv* pcYuvPred = &m_acYuvPred[iRefList]; 3386 #if MERL_VSP_C0152 3387 motionCompensation ( pcCU, pcYuvPred, pcCU->getZorderIdxInCU(), eRefPicList, iPartIdx ); 3388 #else 3387 3389 motionCompensation ( pcCU, pcYuvPred, eRefPicList, iPartIdx ); 3390 #endif 3388 3391 } 3389 #if H0111_MVD_L1_ZERO3390 3392 } 3391 #endif3392 3393 } 3393 3394 } 3394 3395 } 3395 #if LG_RESTRICTEDRESPRED_M24766 3396 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 3396 3397 if( pcCU->getResPredFlag( 0 ) && bLastResiFlag) 3397 3398 { // subtract residual prediction from original in motion search … … 3402 3403 if ( pcCU->getSlice()->isInterB() ) 3403 3404 { 3404 #if LG_RESTRICTEDRESPRED_M24766 3405 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 3405 3406 Int iLastAddResiShift = -1000; 3406 3407 #endif … … 3411 3412 ::memcpy(aaiMvpIdxBi, aaiMvpIdx, sizeof(aaiMvpIdx)); 3412 3413 3413 #if H0111_MVD_L1_ZERO3414 3414 UInt uiMotBits[2]; 3415 3415 … … 3426 3426 pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( iRefIdxBi[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3427 3427 TComYuv* pcYuvPred = &m_acYuvPred[1]; 3428 #if MERL_VSP_C0152 3429 motionCompensation( pcCU, pcYuvPred, pcCU->getZorderIdxInCU(), REF_PIC_LIST_1, iPartIdx ); 3430 #else 3428 3431 motionCompensation( pcCU, pcYuvPred, REF_PIC_LIST_1, iPartIdx ); 3429 3432 #endif 3430 3433 uiMotBits[0] = uiBits[0] - uiMbBits[0]; 3431 3434 uiMotBits[1] = uiMbBits[1]; … … 3437 3440 } 3438 3441 3439 #if H HI_INTER_VIEW_MOTION_PRED3442 #if H3D_IVMP 3440 3443 uiMotBits[1] += m_auiMVPIdxCost[aaiMvpIdxBi[1][bestBiPRefIdxL1]][iNumAMVPCands]; 3441 3444 #else … … 3453 3456 uiBits[2] = uiMbBits[2] + uiMotBits[0] + uiMotBits[1]; 3454 3457 } 3455 #else3456 UInt uiMotBits[2] = { uiBits[0] - uiMbBits[0], uiBits[1] - uiMbBits[1] };3457 uiBits[2] = uiMbBits[2] + uiMotBits[0] + uiMotBits[1];3458 #endif3459 3458 3460 3459 // 4-times iteration (default) … … 3462 3461 3463 3462 // fast encoder setting: only one iteration 3464 #if H0111_MVD_L1_ZERO3465 3463 if ( m_pcEncCfg->getUseFastEnc() || pcCU->getSlice()->getMvdL1ZeroFlag()) 3466 #else3467 if ( m_pcEncCfg->getUseFastEnc() )3468 #endif3469 3464 { 3470 3465 iNumIter = 1; … … 3481 3476 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 3482 3477 3483 #if H0111_MVD_L1_ZERO3484 3478 if(pcCU->getSlice()->getMvdL1ZeroFlag()) 3485 3479 { … … 3487 3481 eRefPicList = REF_PIC_LIST_0; 3488 3482 } 3489 #endif3490 3483 3491 3484 Bool bChanged = false; … … 3502 3495 if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--; 3503 3496 } 3504 #if H HI_INTER_VIEW_MOTION_PRED3497 #if H3D_IVMP 3505 3498 uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdxBi[iRefList][iRefIdxTemp]][iNumAMVPCands]; 3506 3499 #else 3507 3500 uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdxBi[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS]; 3508 3501 #endif 3509 #if LG_RESTRICTEDRESPRED_M24766 3502 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 3510 3503 Int iAddResiShift = -1, iPredFrom = 0; 3511 3504 Int iBestRefIdx = pcCU->getCUMvField(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0)->getRefIdx(uiPartAddr); … … 3545 3538 xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPredBi[iRefList][iRefIdxTemp], aaiMvpIdxBi[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); 3546 3539 } 3547 3540 3548 3541 if ( uiCostTemp < uiCostBi ) 3549 3542 { … … 3557 3550 uiBits[2] = uiBitsTemp; 3558 3551 3559 #if H0111_MVD_L1_ZERO3560 3552 if(iNumIter!=1) 3561 3553 { 3562 #endif3563 3554 // Set motion 3564 3555 pcCU->getCUMvField( eRefPicList )->setAllMv( cMvBi[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); … … 3566 3557 3567 3558 TComYuv* pcYuvPred = &m_acYuvPred[iRefList]; 3559 #if MERL_VSP_C0152 3560 motionCompensation( pcCU, pcYuvPred, pcCU->getZorderIdxInCU(), REF_PIC_LIST_1, iPartIdx ); 3561 #else 3568 3562 motionCompensation( pcCU, pcYuvPred, eRefPicList, iPartIdx ); 3569 # if H0111_MVD_L1_ZERO3563 #endif 3570 3564 } 3571 #endif3572 3565 } 3573 3566 } // for loop-iRefIdxTemp … … 3579 3572 xCopyAMVPInfo(&aacAMVPInfo[0][iRefIdxBi[0]], pcCU->getCUMvField(REF_PIC_LIST_0)->getAMVPInfo()); 3580 3573 xCheckBestMVP(pcCU, REF_PIC_LIST_0, cMvBi[0], cMvPredBi[0][iRefIdxBi[0]], aaiMvpIdxBi[0][iRefIdxBi[0]], uiBits[2], uiCostBi); 3581 #if H0111_MVD_L1_ZERO3582 3574 if(!pcCU->getSlice()->getMvdL1ZeroFlag()) 3583 3575 { 3584 #endif3585 3576 xCopyAMVPInfo(&aacAMVPInfo[1][iRefIdxBi[1]], pcCU->getCUMvField(REF_PIC_LIST_1)->getAMVPInfo()); 3586 3577 xCheckBestMVP(pcCU, REF_PIC_LIST_1, cMvBi[1], cMvPredBi[1][iRefIdxBi[1]], aaiMvpIdxBi[1][iRefIdxBi[1]], uiBits[2], uiCostBi); 3587 #if H0111_MVD_L1_ZERO3588 3578 } 3589 #endif3590 3579 } 3591 3580 break; 3592 3581 } 3593 3582 } // for loop-iter 3594 #if LG_RESTRICTEDRESPRED_M24766 3583 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 3595 3584 if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0) 3596 3585 { … … 3793 3782 TComMvField cMRGMvField[2]; 3794 3783 UInt uiMRGIndex = 0; 3795 3784 #if MERL_VSP_C0152 3785 Int iVSPIndexTrue[3] = {-1, -1, -1}; 3786 #endif 3796 3787 UInt uiMEInterDir = 0; 3797 3788 TComMvField cMEMvField[2]; … … 3805 3796 if (bTestNormalMC) 3806 3797 { 3807 #if LG_RESTRICTEDRESPRED_M24766 3798 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 3808 3799 Int iAddResiShift = pcCU->getResiPredMode(uiPartAddr); 3809 3800 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = \ … … 3816 3807 xGetInterPredictionError( pcCU, pcOrgYuv, iPartIdx, uiMEError, m_pcEncCfg->getUseHADME() ); 3817 3808 uiMECost = uiMEError + m_pcRdCost->getCost( uiMEBits ); 3818 #if LG_RESTRICTEDRESPRED_M24766 3809 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 3819 3810 if(pcCU->getResPredFlag(0) && iAddResiShift >= 0) 3820 3811 { … … 3844 3835 #else 3845 3836 #if LG_RESTRICTEDRESPRED_M24766 3837 #if MERL_VSP_C0152 || MTK_MDIVRP_C0138 3838 3839 #if !MTK_MDIVRP_C0138 3840 xMergeEstimation( pcCU, pcOrgYuv, rpcResiPredYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, iVSPIndexTrue ); 3841 #endif 3842 3843 #if !MERL_VSP_C0152 3844 xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost ); 3845 #endif 3846 3847 #if MERL_VSP_C0152 && MTK_MDIVRP_C0138 3848 xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, iVSPIndexTrue ); 3849 #endif 3850 3851 #else 3846 3852 xMergeEstimation( pcCU, pcOrgYuv, rpcResiPredYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost ); 3853 #endif 3854 3855 3847 3856 #else 3848 3857 xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost ); … … 3854 3863 pcCU->setMergeFlagSubParts ( true, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3855 3864 pcCU->setMergeIndexSubParts( uiMRGIndex, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3865 #if MERL_VSP_C0152 3866 { 3867 Int iVSPIdx = 0; 3868 Int numVSPIdx; 3869 numVSPIdx = 3; 3870 for (Int i = 0; i < numVSPIdx; i++) 3871 { 3872 if (iVSPIndexTrue[i] == uiMRGIndex) 3873 { 3874 iVSPIdx = i+1; 3875 break; 3876 } 3877 } 3878 pcCU->setVSPIndexSubParts( iVSPIdx, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3879 } 3880 #endif 3856 3881 pcCU->setInterDirSubParts ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3857 3882 { … … 3873 3898 pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3874 3899 pcCU->setInterDirSubParts ( uiMEInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3900 #if MERL_VSP_C0152 3901 pcCU->setVSPIndexSubParts ( 0 , uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3902 #endif 3875 3903 { 3876 3904 pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMEMvField[0], ePartSize, uiPartAddr, 0, iPartIdx ); … … 3881 3909 3882 3910 // MC 3911 #if MERL_VSP_C0152 3912 motionCompensation ( pcCU, rpcPredYuv, pcCU->getZorderIdxInCU(), REF_PIC_LIST_X, iPartIdx); 3913 #else 3883 3914 motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx ); 3884 3915 #endif 3885 3916 } // end of for ( Int iPartIdx = 0; iPartIdx < iNumPart; iPartIdx++ ) 3886 3917 … … 3891 3922 3892 3923 // AMVP 3893 #if H0111_MVD_L1_ZERO3894 3924 #if ZERO_MVD_EST 3895 3925 Void TEncSearch::xEstimateMvPredAMVP( TComDataCU* pcCU, TComYuv* pcOrgYuv, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred, Bool bFilled, UInt* puiDistBiP, UInt* puiDist ) 3896 3926 #else 3897 3927 Void TEncSearch::xEstimateMvPredAMVP( TComDataCU* pcCU, TComYuv* pcOrgYuv, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred, Bool bFilled, UInt* puiDistBiP ) 3898 #endif3899 #else3900 #if ZERO_MVD_EST3901 Void TEncSearch::xEstimateMvPredAMVP( TComDataCU* pcCU, TComYuv* pcOrgYuv, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred, Bool bFilled, UInt* puiDist )3902 #else3903 Void TEncSearch::xEstimateMvPredAMVP( TComDataCU* pcCU, TComYuv* pcOrgYuv, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred, Bool bFilled )3904 #endif3905 3928 #endif 3906 3929 { … … 3934 3957 pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); 3935 3958 3936 #if H0111_MVD_L1_ZERO3937 3959 if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefPicList==REF_PIC_LIST_1) 3938 3960 { 3939 #if H HI_INTER_VIEW_MOTION_PRED3961 #if H3D_IVMP 3940 3962 Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 3941 3963 #if ZERO_MVD_EST … … 3952 3974 #endif 3953 3975 } 3954 #endif3955 3976 return; 3956 3977 } … … 3973 3994 { 3974 3995 UInt uiTmpCost; 3975 #if H HI_INTER_VIEW_MOTION_PRED3996 #if H3D_IVMP 3976 3997 Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 3977 3998 #if ZERO_MVD_EST … … 3992 4013 cBestMv = pcAMVPInfo->m_acMvCand[i]; 3993 4014 iBestIdx = i; 3994 #if H0111_MVD_L1_ZERO3995 4015 (*puiDistBiP) = uiTmpCost; 3996 #endif3997 4016 #if ZERO_MVD_EST 3998 4017 (*puiDist) = uiDist; … … 4108 4127 Int iBestMVPIdx = riMVPIdx; 4109 4128 4110 #if H HI_INTER_VIEW_MOTION_PRED4129 #if H3D_IVMP 4111 4130 Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 4112 4131 #endif … … 4114 4133 m_pcRdCost->setPredictor( rcMvPred ); 4115 4134 Int iOrgMvBits = m_pcRdCost->getBits(cMv.getHor(), cMv.getVer()); 4116 #if H HI_INTER_VIEW_MOTION_PRED4135 #if H3D_IVMP 4117 4136 iOrgMvBits += m_auiMVPIdxCost[riMVPIdx][iNumAMVPCands]; 4118 4137 #else … … 4128 4147 4129 4148 Int iMvBits = m_pcRdCost->getBits(cMv.getHor(), cMv.getVer()); 4130 #if H HI_INTER_VIEW_MOTION_PRED4149 #if H3D_IVMP 4131 4150 iMvBits += m_auiMVPIdxCost[iMVPIdx][iNumAMVPCands]; 4132 4151 #else … … 4313 4332 m_pcRdCost->setCostScale ( 2 ); 4314 4333 4315 #if H HI_INTER_VIEW_MOTION_PRED4334 #if H3D_IVMP 4316 4335 { // init inter-view regularization 4317 4336 TComMv cOrgDepthMapMv; … … 4338 4357 m_pcRdCost->setMultiviewReg( 0 ); 4339 4358 #endif 4359 4340 4360 setWpScalingDistParam( pcCU, iRefIdxPred, eRefPicList ); 4341 4361 // Do integer search … … 4351 4371 4352 4372 m_pcRdCost->getMotionCost( 1, 0 ); 4373 4353 4374 #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC 4354 4375 if( ! pcCU->getSlice()->getIsDepth() ) … … 4378 4399 ruiCost += m_pcRdCost->getCost( uiMvBits ); 4379 4400 #endif 4380 4401 4381 4402 ruiBits += uiMvBits; 4382 4403 ruiCost = (UInt)( floor( fWeight * ( (Double)ruiCost - (Double)m_pcRdCost->getCost( uiMvBits ) ) ) + (Double)m_pcRdCost->getCost( ruiBits ) ); … … 4723 4744 rcMvQter = *pcMvInt; rcMvQter <<= 1; // for mv-cost 4724 4745 rcMvQter += rcMvHalf; rcMvQter <<= 1; 4725 ruiCost = xPatternRefinement( pcPatternKey, baseRefMv, 1, rcMvQter 4746 ruiCost = xPatternRefinement( pcPatternKey, baseRefMv, 1, rcMvQter); 4726 4747 } 4727 4748 … … 4736 4757 * \returns Void 4737 4758 */ 4738 #if H HI_INTER_VIEW_RESIDUAL_PRED4759 #if H3D_IVRP 4739 4760 Void TEncSearch::encodeResAndCalcRdInterCU( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* pcYuvPred, TComYuv*& rpcYuvResi, TComYuv*& rpcYuvResiBest, TComYuv*& rpcYuvRec, TComYuv*& rpcYuvResPrd, Bool bSkipRes ) 4740 4761 #else … … 4754 4775 UInt uiWidth = pcCU->getWidth ( 0 ); 4755 4776 UInt uiHeight = pcCU->getHeight( 0 ); 4756 #if LG_RESTRICTEDRESPRED_M24766 4777 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 4757 4778 Int iPUResiPredShift[4]; 4758 4779 #endif … … 4764 4785 pcYuvPred->copyToPartYuv( rpcYuvRec, 0 ); 4765 4786 4766 #if HHI_INTER_VIEW_RESIDUAL_PRED 4787 #if MTK_MDIVRP_C0138 4788 if (pcCU->getMergeFlag(0) && pcCU->getMergeIndex(0)==0 && pcCU->getResPredAvail(0)) 4789 { 4790 rpcYuvRec->clip( uiWidth, uiHeight ); 4791 } 4792 #else 4793 #if H3D_IVRP 4767 4794 // add residual prediction 4768 4795 if( pcCU->getResPredFlag( 0 ) ) … … 4776 4803 rpcYuvRec->clip( uiWidth, uiHeight ); 4777 4804 } 4805 #endif 4778 4806 #endif 4779 4807 … … 4819 4847 m_pcEntropyCoder->encodeMergeIndex( pcCU, 0, 0, true ); 4820 4848 #if LGE_ILLUCOMP_B0045 4821 m_pcEntropyCoder->encodeICFlag(pcCU, 0, true); 4822 #endif 4823 #if HHI_INTER_VIEW_RESIDUAL_PRED 4849 m_pcEntropyCoder->encodeICFlag(pcCU, 0, true 4850 #if FIX_ILLUCOMP_DEPTH 4851 , pcCU->getDepth( 0 ) 4852 #endif 4853 ); 4854 #endif 4855 #if H3D_IVRP && !MTK_MDIVRP_C0138 4824 4856 m_pcEntropyCoder->encodeResPredFlag( pcCU, 0, 0, true ); 4825 4857 #endif … … 4868 4900 4869 4901 // Residual coding. 4870 #if H0736_AVC_STYLE_QP_RANGE4871 4902 Int qp, qpBest = 0, qpMin, qpMax; 4872 #else4873 UInt uiQp, uiQpBest = 0, uiQpMin, uiQpMax;4874 #endif4875 4903 Double dCost, dCostBest = MAX_DOUBLE; 4876 4904 … … 4884 4912 while((uiWidth>>uiMaxTrMode) < (g_uiMaxCUWidth>>g_uiMaxCUDepth)) uiMaxTrMode--; 4885 4913 4886 #if H0736_AVC_STYLE_QP_RANGE4887 4914 qpMin = bHighPass ? Clip3( -pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, pcCU->getQP(0) - m_iMaxDeltaQP ) : pcCU->getQP( 0 ); 4888 4915 qpMax = bHighPass ? Clip3( -pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, pcCU->getQP(0) + m_iMaxDeltaQP ) : pcCU->getQP( 0 ); 4889 #else4890 uiQpMin = bHighPass ? min( MAX_QP, max( MIN_QP, pcCU->getQP(0) - m_iMaxDeltaQP ) ) : pcCU->getQP( 0 );4891 uiQpMax = bHighPass ? min( MAX_QP, max( MIN_QP, pcCU->getQP(0) + m_iMaxDeltaQP ) ) : pcCU->getQP( 0 );4892 #endif4893 4916 4894 4917 #if HHI_INTERVIEW_SKIP … … 4899 4922 else 4900 4923 { 4901 #if LG_RESTRICTEDRESPRED_M24766 4924 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 4902 4925 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0; 4903 4926 rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), pcYuvOrg, pcYuvPred, 0, uiWidth ); … … 4905 4928 rpcYuvResi->subtract( pcYuvOrg, pcYuvPred, 0, uiWidth ); 4906 4929 #endif 4907 #if H HI_INTER_VIEW_RESIDUAL_PRED4930 #if H3D_IVRP && !MTK_MDIVRP_C0138 4908 4931 // subtract residual prediction 4909 4932 if( pcCU->getResPredFlag( 0 ) ) … … 4920 4943 #else 4921 4944 rpcYuvResi->subtract( pcYuvOrg, pcYuvPred, 0, uiWidth ); 4922 #if H HI_INTER_VIEW_RESIDUAL_PRED4945 #if H3D_IVRP 4923 4946 // add residual prediction 4924 4947 if( pcCU->getResPredFlag( 0 ) ) … … 4929 4952 #endif 4930 4953 4931 #if H0736_AVC_STYLE_QP_RANGE4932 4954 for ( qp = qpMin; qp <= qpMax; qp++ ) 4933 #else4934 for ( uiQp = uiQpMin; uiQp <= uiQpMax; uiQp++ )4935 #endif4936 4955 { 4937 4956 dCost = 0.; … … 5050 5069 } 5051 5070 5052 #if H0736_AVC_STYLE_QP_RANGE5053 5071 if( qpMin != qpMax && qp != qpMax ) 5054 #else5055 if( uiQpMin != uiQpMax && uiQp != uiQpMax )5056 #endif5057 5072 { 5058 5073 const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (pcCU->getDepth(0) << 1); … … 5073 5088 uiDistortionBest = uiDistortion; 5074 5089 dCostBest = dCost; 5075 #if H0736_AVC_STYLE_QP_RANGE5076 5090 qpBest = qp; 5077 #else5078 uiQpBest = uiQp;5079 #endif5080 5091 if( m_bUseSBACRD ) 5081 5092 { … … 5101 5112 assert ( dCostBest != MAX_DOUBLE ); 5102 5113 5103 #if H0736_AVC_STYLE_QP_RANGE5104 5114 if( qpMin != qpMax && qpBest != qpMax ) 5105 #else5106 if( uiQpMin != uiQpMax && uiQpBest != uiQpMax )5107 #endif5108 5115 { 5109 5116 if( m_bUseSBACRD ) … … 5127 5134 #endif 5128 5135 } 5129 #if H HI_INTER_VIEW_RESIDUAL_PRED5136 #if H3D_IVRP && !MTK_MDIVRP_C0138 5130 5137 // add residual prediction 5131 5138 if( pcCU->getResPredFlag( 0 ) ) … … 5196 5203 } 5197 5204 5198 #if H0736_AVC_STYLE_QP_RANGE5199 5205 pcCU->setQPSubParts( qpBest, 0, pcCU->getDepth(0) ); 5200 #else5201 pcCU->setQPSubParts( uiQpBest, 0, pcCU->getDepth(0) );5202 #endif5203 5206 5204 5207 // set Model … … 5229 5232 const UInt uiLog2TrSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth]+2; 5230 5233 5231 #if G519_TU_AMP_NSQT_HARMONIZATION5232 5234 UInt SplitFlag = ((pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N )); 5233 #else5234 UInt SplitFlag = ((pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && ( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N));5235 #endif5236 5235 Bool bCheckFull; 5237 5236 if ( SplitFlag && uiDepth == pcCU->getDepth(uiAbsPartIdx) && ( uiLog2TrSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) ) … … 5298 5297 } 5299 5298 5300 #if H0736_AVC_STYLE_QP_RANGE5301 5299 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); 5302 #else5303 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 );5304 #endif5305 5300 5306 5301 #if RDOQ_CHROMA_LAMBDA … … 5322 5317 } 5323 5318 5324 #if H0736_AVC_STYLE_QP_RANGE5325 5319 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() ); 5326 #else5327 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset() );5328 #endif5329 5320 5330 5321 #if RDOQ_CHROMA_LAMBDA … … 5337 5328 #endif 5338 5329 trWidthC, trHeightC, uiAbsSumU, TEXT_CHROMA_U, uiAbsPartIdx ); 5339 #if H0736_AVC_STYLE_QP_RANGE5340 5330 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() ); 5341 #else5342 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );5343 #endif5344 5331 m_pcTrQuant->transformNxN( pcCU, pcResi->getCrAddr(absTUPartIdxC), pcResi->getCStride(), pcCoeffCurrV, 5345 5332 #if ADAPTIVE_QP_SELECTION … … 5440 5427 Pel *pcResiCurrY = m_pcQTTempTComYuv[ uiQTTempAccessLayer ].getLumaAddr( absTUPartIdx ); 5441 5428 5442 #if H0736_AVC_STYLE_QP_RANGE5443 5429 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); 5444 #else5445 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 );5446 #endif5447 5430 5448 5431 Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA]; … … 5571 5554 } 5572 5555 5573 #if FIX_RDO_NEGDIST 5556 5574 5557 Dist uiDistU = 0; 5575 5558 Dist uiDistV = 0; 5576 #else5577 UInt uiDistU = 0;5578 UInt uiDistV = 0;5579 #endif5580 5559 if( bCodeChroma ) 5581 5560 { … … 5601 5580 Pel *pcResiCurrU = m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( absTUPartIdxC ); 5602 5581 5603 #if H0736_AVC_STYLE_QP_RANGE5604 5582 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() ); 5605 #else5606 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset() );5607 #endif5608 5583 5609 5584 Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_U]; … … 5615 5590 #endif 5616 5591 5617 #if FIX_RDO_NEGDIST 5592 5618 5593 const Dist uiNonzeroDistU = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( absTUPartIdxC), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), 5619 5594 pcResi->getCbAddr( absTUPartIdxC), pcResi->getCStride(), trWidthC, trHeightC 5620 5595 5621 #else5622 const UInt uiNonzeroDistU = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( absTUPartIdxC), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),5623 pcResi->getCbAddr( absTUPartIdxC), pcResi->getCStride(), trWidthC, trHeightC5624 #endif5625 5596 #if WEIGHTED_CHROMA_DISTORTION 5626 5597 , true … … 5694 5665 if( !uiAbsSumU ) 5695 5666 { 5696 #if H0736_AVC_STYLE_QP_RANGE5697 5667 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() ); 5698 #else5699 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );5700 #endif5701 5668 } 5702 5669 Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_V]; … … 5707 5674 m_pcTrQuant->invtransformNxN( TEXT_CHROMA,REG_DCT, pcResiCurrV, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrV, trWidthC, trHeightC, scalingListType ); 5708 5675 #endif 5709 #if FIX_RDO_NEGDIST5710 5676 const Dist uiNonzeroDistV = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getCrAddr( absTUPartIdxC ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), 5711 5677 pcResi->getCrAddr( absTUPartIdxC ), pcResi->getCStride(), trWidthC, trHeightC 5712 #else5713 const UInt uiNonzeroDistV = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getCrAddr( absTUPartIdxC ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),5714 pcResi->getCrAddr( absTUPartIdxC ), pcResi->getCStride(), trWidthC, trHeightC5715 #endif5716 5678 #if WEIGHTED_CHROMA_DISTORTION 5717 5679 , true … … 6202 6164 m_pcEntropyCoder->encodeMergeIndex(pcCU, 0, 0, true); 6203 6165 #if LGE_ILLUCOMP_B0045 6204 m_pcEntropyCoder->encodeICFlag(pcCU, 0, true); 6205 #endif 6206 #if HHI_INTER_VIEW_RESIDUAL_PRED 6166 m_pcEntropyCoder->encodeICFlag(pcCU, 0, true 6167 #if FIX_ILLUCOMP_DEPTH 6168 , pcCU->getDepth( 0 ) 6169 #endif 6170 ); 6171 #endif 6172 #if H3D_IVRP && !MTK_MDIVRP_C0138 6207 6173 m_pcEntropyCoder->encodeResPredFlag( pcCU, 0, 0, true ); 6208 6174 #endif … … 6225 6191 m_pcEntropyCoder->encodePredInfo( pcCU, 0, true ); 6226 6192 #if LGE_ILLUCOMP_B0045 6227 m_pcEntropyCoder->encodeICFlag(pcCU, 0, true); 6228 #endif 6229 #if HHI_INTER_VIEW_RESIDUAL_PRED 6193 m_pcEntropyCoder->encodeICFlag(pcCU, 0, true 6194 #if FIX_ILLUCOMP_DEPTH 6195 , pcCU->getDepth( 0 ) 6196 #endif 6197 ); 6198 #endif 6199 #if H3D_IVRP && !MTK_MDIVRP_C0138 6230 6200 m_pcEntropyCoder->encodeResPredFlag( pcCU, 0, 0, true ); 6231 6201 #endif … … 6564 6534 Int iFullDeltaDC2 = riDeltaDC2; 6565 6535 6536 #if HHI_DMM_DELTADC_Q1_C0034 6537 #else 6566 6538 xDeltaDCQuantScaleDown( pcCU, iFullDeltaDC1 ); 6567 6539 xDeltaDCQuantScaleDown( pcCU, iFullDeltaDC2 ); 6540 #endif 6568 6541 6569 6542 Dist uiBestDist = RDO_DIST_MAX; … … 6578 6551 uiDeltaDC2Max += (uiDeltaDC2Max>>1); 6579 6552 6553 #if HHI_DMM_DELTADC_Q1_C0034 6554 // limit search range to [0, IBDI_MAX] 6555 if( iFullDeltaDC1 < 0 && uiDeltaDC1Max > abs(iPredDC1) ) { uiDeltaDC1Max = abs(iPredDC1); } 6556 if( iFullDeltaDC1 >= 0 && uiDeltaDC1Max > g_uiIBDI_MAX - abs(iPredDC1) ) { uiDeltaDC1Max = g_uiIBDI_MAX - abs(iPredDC1); } 6557 6558 if( iFullDeltaDC2 < 0 && uiDeltaDC2Max > abs(iPredDC2) ) { uiDeltaDC2Max = abs(iPredDC2); } 6559 if( iFullDeltaDC2 >= 0 && uiDeltaDC2Max > g_uiIBDI_MAX - abs(iPredDC2) ) { uiDeltaDC2Max = g_uiIBDI_MAX - abs(iPredDC2); } 6560 6561 // init dist with original DCs 6562 assignWedgeDCs2Pred( pcWedgelet, piPredic, uiStride, iDC1, iDC2 ); 6563 6564 Dist uiOrgDist = RDO_DIST_MAX; 6565 #if SAIT_VSO_EST_A0033 6566 if ( m_pcRdCost->getUseEstimatedVSD() ) 6567 { 6568 TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv(); 6569 TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv(); 6570 uiOrgDist = m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight ); 6571 #if LGE_WVSO_A0119 6572 if ( m_pcRdCost->getUseWVSO() ) 6573 { 6574 Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight(); 6575 Int iVSDWeight = m_pcRdCost->getVSDWeight() * m_pcRdCost->getVSDWeight(); 6576 Dist iD = (Dist) m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, DF_SAD ); 6577 uiOrgDist = (iDWeight * iD + iVSDWeight * (Dist) uiOrgDist) / ( iDWeight + iVSDWeight); 6578 } 6579 #endif // LGE_WVSO_A0119 6580 } 6581 else 6582 #endif // SAIT_VSO_EST_A0033 6583 { 6584 uiOrgDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, 0 ); 6585 #if LGE_WVSO_A0119 6586 if ( m_pcRdCost->getUseWVSO() ) 6587 { 6588 Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight(); 6589 Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight(); 6590 Dist iD = (Dist) m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, DF_SAD ); 6591 uiOrgDist = (iDWeight * iD + iVSOWeight * (Dist) uiOrgDist) / ( iDWeight + iVSOWeight); 6592 } 6593 #endif // LGE_WVSO_A0119 6594 } 6595 uiBestDist = uiOrgDist; 6596 uiBestQStepDC1 = abs(iFullDeltaDC1); 6597 uiBestQStepDC2 = abs(iFullDeltaDC2); 6598 6599 // coarse search with step size 4 6600 for( UInt uiQStepDC1 = 0; uiQStepDC1 < uiDeltaDC1Max; uiQStepDC1 += 4 ) 6601 { 6602 Int iTestDC1 = Clip( iPredDC1 + ((Int)(uiQStepDC1) * (Int)(( iFullDeltaDC1 < 0 ) ? -1 : 1)) ); 6603 for( UInt uiQStepDC2 = 0; uiQStepDC2 < uiDeltaDC2Max; uiQStepDC2 += 4 ) 6604 { 6605 Int iTestDC2 = Clip( iPredDC2 + ((Int)(uiQStepDC2) * (Int)(( iFullDeltaDC2 < 0 ) ? -1 : 1)) ); 6606 6607 assignWedgeDCs2Pred( pcWedgelet, piPredic, uiStride, iTestDC1, iTestDC2 ); 6608 6609 Dist uiAct4Dist = RDO_DIST_MAX; 6610 #if SAIT_VSO_EST_A0033 6611 if ( m_pcRdCost->getUseEstimatedVSD() ) 6612 { 6613 TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv(); 6614 TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv(); 6615 uiAct4Dist = m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight ); 6616 #if LGE_WVSO_A0119 6617 if ( m_pcRdCost->getUseWVSO() ) 6618 { 6619 Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight(); 6620 Int iVSDWeight = m_pcRdCost->getVSDWeight() * m_pcRdCost->getVSDWeight(); 6621 Dist iD = (Dist) m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, DF_SAD ); 6622 uiAct4Dist = (iDWeight * iD + iVSDWeight * (Dist) uiAct4Dist) / ( iDWeight + iVSDWeight); 6623 } 6624 #endif // LGE_WVSO_A0119 6625 } 6626 else 6627 #endif // SAIT_VSO_EST_A0033 6628 { 6629 uiAct4Dist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, 0 ); 6630 #if LGE_WVSO_A0119 6631 if ( m_pcRdCost->getUseWVSO() ) 6632 { 6633 Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight(); 6634 Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight(); 6635 Dist iD = (Dist) m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, DF_SAD ); 6636 uiAct4Dist = (iDWeight * iD + iVSOWeight * (Dist) uiAct4Dist) / ( iDWeight + iVSOWeight); 6637 } 6638 #endif // LGE_WVSO_A0119 6639 } 6640 6641 if( uiAct4Dist < uiBestDist || uiBestDist == RDO_DIST_MAX ) 6642 { 6643 uiBestDist = uiAct4Dist; 6644 uiBestQStepDC1 = uiQStepDC1; 6645 uiBestQStepDC2 = uiQStepDC2; 6646 } 6647 } 6648 } 6649 6650 // refinement +-3 6651 for( UInt uiQStepDC1 = (UInt)max(0, ((Int)uiBestQStepDC1-3)); uiQStepDC1 <= (uiBestQStepDC1+3); uiQStepDC1++ ) 6652 { 6653 Int iTestDC1 = Clip( iPredDC1 + ((Int)(uiQStepDC1) * (Int)(( iFullDeltaDC1 < 0 ) ? -1 : 1)) ); 6654 for( UInt uiQStepDC2 = (UInt)max(0, ((Int)uiBestQStepDC2-3)); uiQStepDC2 <= (uiBestQStepDC2+3); uiQStepDC2++ ) 6655 { 6656 Int iTestDC2 = Clip( iPredDC2 + ((Int)(uiQStepDC2) * (Int)(( iFullDeltaDC2 < 0 ) ? -1 : 1)) ); 6657 6658 assignWedgeDCs2Pred( pcWedgelet, piPredic, uiStride, iTestDC1, iTestDC2 ); 6659 6660 Dist uiActDist = RDO_DIST_MAX; 6661 #if SAIT_VSO_EST_A0033 6662 if ( m_pcRdCost->getUseEstimatedVSD() ) 6663 { 6664 TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv(); 6665 TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv(); 6666 uiActDist = m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight ); 6667 #if LGE_WVSO_A0119 6668 if ( m_pcRdCost->getUseWVSO() ) 6669 { 6670 Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight(); 6671 Int iVSDWeight = m_pcRdCost->getVSDWeight() * m_pcRdCost->getVSDWeight(); 6672 Dist iD = (Dist) m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, DF_SAD ); 6673 uiActDist = (iDWeight * iD + iVSDWeight * (Dist) uiActDist) / ( iDWeight + iVSDWeight); 6674 } 6675 #endif // LGE_WVSO_A0119 6676 } 6677 else 6678 #endif // SAIT_VSO_EST_A0033 6679 { 6680 uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, 0 ); 6681 #if LGE_WVSO_A0119 6682 if ( m_pcRdCost->getUseWVSO() ) 6683 { 6684 Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight(); 6685 Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight(); 6686 Dist iD = (Dist) m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, DF_SAD ); 6687 uiActDist = (iDWeight * iD + iVSOWeight * (Dist) uiActDist) / ( iDWeight + iVSOWeight); 6688 } 6689 #endif // LGE_WVSO_A0119 6690 } 6691 6692 if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX ) 6693 { 6694 uiBestDist = uiActDist; 6695 uiBestQStepDC1 = uiQStepDC1; 6696 uiBestQStepDC2 = uiQStepDC2; 6697 } 6698 } 6699 } 6700 #else 6580 6701 for( UInt uiQStepDC1 = 1; uiQStepDC1 <= uiDeltaDC1Max; uiQStepDC1++ ) 6581 6702 { … … 6633 6754 } 6634 6755 } 6635 6756 #endif 6636 6757 iFullDeltaDC1 = (Int)(uiBestQStepDC1) * (Int)(( iFullDeltaDC1 < 0 ) ? -1 : 1); 6637 6758 iFullDeltaDC2 = (Int)(uiBestQStepDC2) * (Int)(( iFullDeltaDC2 < 0 ) ? -1 : 1); 6759 #if HHI_DMM_DELTADC_Q1_C0034 6760 #else 6638 6761 xDeltaDCQuantScaleUp( pcCU, iFullDeltaDC1 ); 6639 6762 xDeltaDCQuantScaleUp( pcCU, iFullDeltaDC2 ); 6763 #endif 6640 6764 riDeltaDC1 = iFullDeltaDC1; 6641 6765 riDeltaDC2 = iFullDeltaDC2; … … 6643 6767 #endif 6644 6768 6769 #if HHI_DMM_DELTADC_Q1_C0034 6770 #else 6645 6771 xDeltaDCQuantScaleDown( pcCU, riDeltaDC1 ); 6646 6772 xDeltaDCQuantScaleDown( pcCU, riDeltaDC2 ); 6773 #endif 6647 6774 } 6648 6775 #endif … … 6665 6792 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])]; 6666 6793 Dist iDist = RDO_DIST_MAX; 6667 #if HHIQC_DMMFASTSEARCH_B00396668 6794 WedgeNodeList* pacWedgeNodeList = &g_aacWedgeNodeLists[(g_aucConvertToBit[uiWidth])]; 6669 6795 xSearchWedgeFullMinDistFast( pcCU, uiAbsPtIdx, pacWedgeNodeList, pacWedgeList, piOrig, uiStride, uiWidth, uiHeight, ruiTabIdx, iDist ); 6670 #else6671 xSearchWedgeFullMinDist( pcCU, uiAbsPtIdx, pacWedgeList, piOrig, uiStride, uiWidth, uiHeight, ruiTabIdx, iDist );6672 #endif6673 6796 6674 6797 TComWedgelet* pcBestWedgelet = &(pacWedgeList->at(ruiTabIdx)); … … 6781 6904 } 6782 6905 6783 #if HHIQC_DMMFASTSEARCH_B00396784 6906 Void TEncSearch::xSearchWedgeFullMinDistFast( TComDataCU* pcCU, UInt uiAbsPtIdx, WedgeNodeList* pacWedgeNodeList, WedgeList* pacWedgeList, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, Dist& riDist ) 6785 6907 { … … 6900 7022 return; 6901 7023 } 6902 #endif6903 7024 6904 7025 Void TEncSearch::xSearchWedgePredDirMinDist( TComDataCU* pcCU, UInt uiAbsPtIdx, WedgeList* pacWedgeList, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, Int& riWedgeDeltaEnd ) … … 6991 7112 return; 6992 7113 } 6993 #endif 7114 #endif // HHI_DMM_WEDGE_INTRA 7115 6994 7116 #if HHI_DMM_PRED_TEX 6995 7117 Void TEncSearch::findWedgeTexMinDist( TComDataCU* pcCU, … … 7004 7126 Int& riDeltaDC2, 7005 7127 Bool bAboveAvail, 7006 Bool bLeftAvail ) 7128 Bool bLeftAvail 7129 #if LGE_DMM3_SIMP_C0044 7130 ,UInt& ruiIntraTabIdx 7131 #endif 7132 ) 7007 7133 { 7008 7134 assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE ); 7009 7135 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])]; 7010 7136 7137 #if LGE_DMM3_SIMP_C0044 7138 ruiTabIdx = getBestWedgeFromTex( pcCU, uiAbsPtIdx, uiWidth, uiHeight, piOrig, uiStride, ruiIntraTabIdx ); 7139 #else 7011 7140 ruiTabIdx = getBestWedgeFromTex( pcCU, uiAbsPtIdx, uiWidth, uiHeight ); 7141 #endif 7012 7142 7013 7143 TComWedgelet* pcBestWedgelet = &(pacWedgeList->at(ruiTabIdx)); … … 7036 7166 delete pcContourWedge; 7037 7167 } 7038 #endif 7168 #endif // HHI_DMM_PRED_TEX 7039 7169 7040 7170 #if LGE_EDGE_INTRA_A0070 … … 8136 8266 iDeltaDC1 = iFullDeltaDC1; 8137 8267 } 8138 #endif 8268 #endif // HHI_VSO 8139 8269 8140 8270 xDeltaDCQuantScaleDown( pcCU, iDeltaDC0 ); … … 8144 8274 pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 ); 8145 8275 } 8146 #endif 8147 #endif 8276 #endif // LGE_EDGE_INTRA_DELTA_DC 8277 #endif // LGE_EDGE_INTRA_A0070 8148 8278 8149 8279 #if RWTH_SDC_DLT_B0036 … … 8154 8284 Int iSumPix[2]; 8155 8285 memset(iSumPix, 0, sizeof(Int)*2); 8156 8286 #if HS_REFERENCE_SUBSAMPLE_C0154 8287 Int subSamplePix; 8288 if ( uiSize == 64 || uiSize == 32 ) 8289 { 8290 subSamplePix = 2; 8291 } 8292 else 8293 { 8294 subSamplePix = 1; 8295 } 8296 for (Int y=0; y<uiSize; y+=subSamplePix) 8297 { 8298 for (Int x=0; x<uiSize; x+=subSamplePix) 8299 { 8300 UChar ucSegment = pMask?(UChar)pMask[x]:0; 8301 assert( ucSegment < uiNumSegments ); 8302 8303 iSumDepth[ucSegment] += pOrig[x]; 8304 iSumPix[ucSegment] += 1; 8305 } 8306 8307 pOrig += uiStride*subSamplePix; 8308 pMask += uiMaskStride*subSamplePix; 8309 } 8310 #else //HS_REFERENCE_SUBSAMPLE_C0154 8157 8311 for (Int y=0; y<uiSize; y++) 8158 8312 { … … 8169 8323 pMask += uiMaskStride; 8170 8324 } 8171 8325 #endif // HS_REFERENCE_SUBSAMPLE_C0154 8172 8326 // compute mean for each segment 8173 8327 for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ ) … … 8179 8333 } 8180 8334 } 8181 #endif 8335 #endif // RWTH_SDC_DLT_B0036 8182 8336 8183 8337 //! \} -
trunk/source/Lib/TLibEncoder/TEncSearch.h
r210 r296 121 121 122 122 // AMVP cost computation 123 #if H HI_INTER_VIEW_MOTION_PRED123 #if H3D_IVMP 124 124 UInt m_auiMVPIdxCost[AMVP_MAX_NUM_CANDS+2][AMVP_MAX_NUM_CANDS+2]; //th array bounds 125 125 #else … … 152 152 UInt xPatternRefinement( TComPattern* pcPatternKey, 153 153 TComMv baseRefMv, 154 Int iFrac, TComMv& rcMvFrac 154 Int iFrac, TComMv& rcMvFrac); 155 155 156 156 typedef struct … … 196 196 Void predInterSearch ( TComDataCU* pcCU, 197 197 TComYuv* pcOrgYuv, 198 #if LG_RESTRICTEDRESPRED_M24766 198 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 199 199 TComYuv* rpcResiPredYuv, 200 200 #endif … … 208 208 ); 209 209 210 #if H HI_INTER_VIEW_RESIDUAL_PRED210 #if H3D_IVRP 211 211 /// encode residual and compute rd-cost for inter mode 212 212 Void encodeResAndCalcRdInterCU( TComDataCU* pcCU, … … 401 401 UInt& ruiTabIdx, 402 402 Dist& riDist ); 403 #if HHIQC_DMMFASTSEARCH_B0039 403 404 404 Void xSearchWedgeFullMinDistFast( TComDataCU* pcCU, 405 405 UInt uiAbsPtIdx, … … 412 412 UInt& ruiTabIdx, 413 413 Dist& riDist ); 414 #endif415 414 Void xSearchWedgePredDirMinDist ( TComDataCU* pcCU, 416 415 UInt uiAbsPtIdx, … … 422 421 UInt& ruiTabIdx, 423 422 Int& riWedgeDeltaEnd ); 424 #endif 423 #endif // HHI_DMM_WEDGE_INTRA 425 424 #if HHI_DMM_PRED_TEX 426 425 Void findWedgeTexMinDist ( TComDataCU* pcCU, … … 435 434 Int& riDeltaDC2, 436 435 Bool bAboveAvail, 437 Bool bLeftAvail ); 436 Bool bLeftAvail 437 #if LGE_DMM3_SIMP_C0044 438 ,UInt& ruiIntraTabIdx 439 #endif 440 ); 438 441 Void findContourPredTex ( TComDataCU* pcCU, 439 442 UInt uiAbsPtIdx, … … 447 450 Bool bAboveAvail, 448 451 Bool bLeftAvail ); 449 #endif 452 #endif // HHI_DMM_PRED_TEX 450 453 451 454 // ------------------------------------------------------------------------------------------------------------------- … … 460 463 TComMv& rcMvPred, 461 464 Bool bFilled = false 462 #if H0111_MVD_L1_ZERO463 465 , UInt* puiDistBiP = NULL 464 #endif465 466 #if ZERO_MVD_EST 466 467 , UInt* puiDist = NULL … … 500 501 Void xMergeEstimation ( TComDataCU* pcCU, 501 502 TComYuv* pcYuvOrg, 502 #if LG_RESTRICTEDRESPRED_M24766 503 #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 503 504 TComYuv* rpcResiPredYuv, 504 505 #endif … … 512 513 UChar* uhInterDirNeighbours, 513 514 Int& numValidMergeCand 515 #endif 516 #if MERL_VSP_C0152 517 , Int* iVSPIndexTrue 514 518 #endif 515 519 ); … … 579 583 TComMv& rcMvQter, 580 584 UInt& ruiCost 581 ,Bool biPred 582 ); 585 ,Bool biPred); 583 586 584 587 Void xExtDIFUpSamplingH( TComPattern* pcPattern, Bool biPred ); -
trunk/source/Lib/TLibEncoder/TEncSlice.cpp
r210 r296 163 163 */ 164 164 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 165 #if MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137 166 Void TEncSlice::initEncSlice( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS * pVPS, TComSPS* pSPS, TComPPS *pPPS, bool isDepth ) 167 #else 165 168 Void TEncSlice::initEncSlice( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS * pVPS, TComSPS* pSPS, TComPPS *pPPS ) 169 #endif 166 170 #else 167 171 Void TEncSlice::initEncSlice( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS ) … … 181 185 rpcSlice->initSlice(); 182 186 rpcSlice->initTiles(); 183 #if H0388184 187 rpcSlice->setPicOutputFlag( true ); 185 #endif186 188 rpcSlice->setPOC( uiPOCCurr ); 187 189 188 #if SONY_COLPIC_AVAILABILITY189 rpcSlice->setViewOrderIdx(m_pcCfg->getViewOrderIdx()); 190 #if INTER_VIEW_VECTOR_SCALING_C0115 191 rpcSlice->setViewOrderIdx(m_pcCfg->getViewOrderIdx()); // will be changed to view_id 190 192 #endif 191 193 #if LGE_ILLUCOMP_B0045 … … 258 260 { 259 261 #if LOSSLESS_CODING 260 #if H0736_AVC_STYLE_QP_RANGE261 262 if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless()))) 262 #else263 if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == 0 ) && (rpcSlice->getSPS()->getUseLossless())))264 #endif265 263 #endif 266 264 { … … 330 328 } 331 329 332 #if H0736_AVC_STYLE_QP_RANGE333 330 iQP = max( -pSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) ); 334 #else335 iQP = max( MIN_QP, min( MAX_QP, (Int)floor( dQP + 0.5 ) ) );336 #endif337 331 338 332 m_pdRdPicLambda[iDQpIdx] = dLambda; … … 356 350 // for RDO 357 351 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 358 #if H0736_AVC_STYLE_QP_RANGE359 352 Double weight = 1.0; 360 353 if(iQP >= 0) … … 362 355 weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 ); // takes into account of the chroma qp mapping without chroma qp Offset 363 356 } 364 #else365 Double weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 ); // takes into account of the chroma qp mapping without chroma qp Offset366 #endif367 357 m_pcRdCost ->setChromaDistortionWeight( weight ); 368 358 #endif … … 405 395 #endif 406 396 407 #if H HI_INTER_VIEW_MOTION_PRED397 #if H3D_IVMP 408 398 m_pcRdCost ->setLambdaMVReg ( dLambda * m_pcCfg->getMultiviewMvRegLambdaScale() ); 409 399 #endif … … 428 418 429 419 rpcSlice->setLoopFilterOffsetInAPS( m_pcCfg->getLoopFilterOffsetInAPS() ); 430 #if DBL_CONTROL431 420 if (rpcSlice->getPPS()->getDeblockingFilterControlPresent()) 432 421 { 433 #endif434 422 rpcSlice->setInheritDblParamFromAPS( m_pcCfg->getLoopFilterOffsetInAPS() ? 1 : 0 ); 435 423 rpcSlice->setLoopFilterDisable( m_pcCfg->getLoopFilterDisable() ); … … 439 427 rpcSlice->setLoopFilterTcOffset( m_pcCfg->getLoopFilterTcOffset() ); 440 428 } 441 #if DBL_CONTROL 442 } 443 #endif 429 } 444 430 445 431 rpcSlice->setDepth ( iDepth ); … … 451 437 } 452 438 rpcSlice->setTLayer( pcPic->getTLayer() ); 453 #if !H0566_TLA454 rpcSlice->setTLayerSwitchingFlag( pPPS->getTLayerSwitchingFlag( pcPic->getTLayer() ) );455 #endif456 439 457 440 assert( m_apcPicYuvPred ); … … 465 448 rpcSlice->setEntropySliceArgument ( m_pcCfg->getEntropySliceArgument() ); 466 449 467 #if ( HHI_MPI || H HI_INTER_VIEW_MOTION_PRED)468 #if ( HHI_MPI && H HI_INTER_VIEW_MOTION_PRED)450 #if ( HHI_MPI || H3D_IVMP ) 451 #if ( HHI_MPI && H3D_IVMP ) 469 452 const int iExtraMergeCandidates = ( pSPS->getUseMVI() || pSPS->getMultiviewMvPredMode() ) ? 1 : 0; 470 453 #elif HHI_MPI 471 454 const int iExtraMergeCandidates = pSPS->getUseMVI() ? 1 : 0; 455 #elif MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137 456 const int iExtraMergeCandidates = ( isDepth || pSPS->getMultiviewMvPredMode() ) ? 1 : 0; 472 457 #else 473 458 const int iExtraMergeCandidates = pSPS->getMultiviewMvPredMode() ? 1 : 0; … … 552 537 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 553 538 int iQP = m_piRdPicQp [uiQpIdx]; 554 #if H0736_AVC_STYLE_QP_RANGE555 539 Double weight = 1.0; 556 540 if(iQP >= 0) … … 558 542 weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 ); // takes into account of the chroma qp mapping without chroma qp Offset 559 543 } 560 #else561 Double weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 ); // takes into account of the chroma qp mapping without chroma qp Offset562 #endif563 544 m_pcRdCost ->setChromaDistortionWeight( weight ); 564 545 #endif … … 576 557 pcSlice ->setLambda ( m_pdRdPicLambda[uiQpIdx] ); 577 558 #endif 578 #if H HI_INTER_VIEW_MOTION_PRED559 #if H3D_IVMP 579 560 m_pcRdCost ->setLambdaMVReg ( m_pdRdPicLambda[uiQpIdx] * m_pcCfg->getMultiviewMvRegLambdaScale() ); 580 561 #endif … … 608 589 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 609 590 int iQP = m_piRdPicQp [uiQpIdxBest]; 610 #if H0736_AVC_STYLE_QP_RANGE611 591 Double weight = 1.0; 612 592 if(iQP >= 0) … … 614 594 weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 ); // takes into account of the chroma qp mapping without chroma qp Offset 615 595 } 616 #else617 Double weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 ); // takes into account of the chroma qp mapping without chroma qp Offset618 #endif619 596 m_pcRdCost ->setChromaDistortionWeight( weight ); 620 597 #endif … … 632 609 pcSlice ->setLambda ( m_pdRdPicLambda[uiQpIdxBest] ); 633 610 #endif 634 #if H HI_INTER_VIEW_MOTION_PRED611 #if H3D_IVMP 635 612 m_pcRdCost ->setLambdaMVReg ( m_pdRdPicLambda[uiQpIdxBest] * m_pcCfg->getMultiviewMvRegLambdaScale() ); 636 613 #endif … … 770 747 771 748 #if LGE_ILLUCOMP_B0045 772 if (pcEncTop->getViewId() != 0 && !pcEncTop->isDepthCoder() && pcEncTop->getUseIC()) // DCP of ViewID 0 is not available 749 if (pcEncTop->getViewId() != 0 750 #if !LGE_ILLUCOMP_DEPTH_C0046 751 && !pcEncTop->isDepthCoder() 752 #endif 753 && pcEncTop->getUseIC()) // DCP of ViewID 0 is not available 773 754 { 774 755 pcSlice ->xSetApplyIC(); … … 811 792 m_pcBufferLowLatSbacCoders[ui].load(m_pppcRDSbacCoder[0][CI_CURR_BEST]); //init. state 812 793 } 794 795 #if MERL_VSP_C0152 796 // Send Depth/Texture pointers to slice level 797 pcSlice->setBWVSPLUTParam(m_aiShiftLUT, m_iShiftPrec); 798 pcSlice->setRefPicBaseTxt(m_pPicBaseTxt); 799 pcSlice->setRefPicBaseDepth(m_pPicBaseDepth); 800 #endif 801 813 802 UInt uiWidthInLCUs = rpcPic->getPicSym()->getFrameWidthInCU(); 814 803 //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU(); 815 804 UInt uiCol=0, uiLin=0, uiSubStrm=0; 816 #if !REMOVE_TILE_DEPENDENCE817 Int iBreakDep = 0;818 #endif819 805 UInt uiTileCol = 0; 820 806 UInt uiTileStartLCU = 0; … … 851 837 if( m_pcCfg->getUseSBACRD() ) 852 838 { 853 #if !REMOVE_TILE_DEPENDENCE854 iBreakDep = rpcPic->getPicSym()->getTileBoundaryIndependenceIdr();855 #endif856 839 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in? 857 840 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); … … 860 843 uiCol = uiCUAddr % uiWidthInLCUs; 861 844 uiLin = uiCUAddr / uiWidthInLCUs; 862 #if !REMOVE_TILE_DEPENDENCE863 #if WPP_SIMPLIFICATION864 if (iBreakDep && pcSlice->getPPS()->getNumSubstreams() > 1)865 #else866 if (iBreakDep && pcSlice->getPPS()->getEntropyCodingSynchro())867 #endif868 #else869 #if WPP_SIMPLIFICATION870 845 if (pcSlice->getPPS()->getNumSubstreams() > 1) 871 #else872 if (pcSlice->getPPS()->getEntropyCodingSynchro())873 #endif874 #endif875 846 { 876 847 // independent tiles => substreams are "per tile". iNumSubstreams has already been multiplied. … … 884 855 uiSubStrm = uiLin % iNumSubstreams; 885 856 } 886 #if WPP_SIMPLIFICATION887 857 if ( pcSlice->getPPS()->getNumSubstreams() > 1 && (uiCol == uiTileLCUX) ) 888 #else889 if ( pcSlice->getPPS()->getEntropyCodingSynchro() && (uiCol == uiTileLCUX) )890 #endif891 858 { 892 859 // We'll sync if the TR is available. … … 895 862 UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1); 896 863 TComDataCU *pcCUTR = NULL; 897 #if WPP_SIMPLIFICATION898 864 if ( pcCUUp && ((uiCUAddr%uiWidthInCU+1) < uiWidthInCU) ) 899 865 { 900 866 pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 ); 901 867 } 902 #else903 if ( pcCUUp && ((uiCUAddr%uiWidthInCU+pcSlice->getPPS()->getEntropyCodingSynchro()) < uiWidthInCU) )904 {905 pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + pcSlice->getPPS()->getEntropyCodingSynchro() );906 }907 #endif908 868 if ( ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 909 869 (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) || 910 #if !REMOVE_TILE_DEPENDENCE911 (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr() && (rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))912 #else913 870 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))) 914 #endif915 871 )|| 916 872 ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 917 873 (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getEntropySliceCurStartCUAddr()) || 918 #if !REMOVE_TILE_DEPENDENCE919 (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr() && (rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))920 #else921 874 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))) 922 #endif923 875 ) 924 876 ) … … 957 909 #endif 958 910 } 959 #if !REMOVE_TILE_DEPENDENCE960 if( (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr()==0) && (rpcPic->getPicSym()->getNumColumnsMinus1()!=0) )961 {962 // Synchronize cabac probabilities with LCU among Tiles963 if( (uiTileLCUX != 0) &&964 (uiCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr()) )965 {966 TComDataCU *pcCULeft = pcCU->getCULeft();967 UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1);968 969 if ( (true/*bEnforceSliceRestriction*/ &&970 ((pcCULeft==NULL) || (pcCULeft->getSlice()==NULL) ||971 ((pcCULeft->getSCUAddr()+uiMaxParts-1) < pcSlice->getSliceCurStartCUAddr())972 )973 )||974 (true/*bEnforceEntropySliceRestriction*/ &&975 ((pcCULeft==NULL) || (pcCULeft->getSlice()==NULL) ||976 ((pcCULeft->getSCUAddr()+uiMaxParts-1) < pcSlice->getEntropySliceCurStartCUAddr())977 )978 )979 )980 {981 // Left not available.982 }983 else984 {985 // Left is available, we use it.986 ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->loadContexts( &m_pcBufferLowLatSbacCoders[uiTileCol-1] );987 m_pppcRDSbacCoder[0][CI_CURR_BEST]->loadContexts( ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST] ); //this load is used to simplify the code988 }989 }990 }991 #endif992 911 // if RD based on SBAC is used 993 912 if( m_pcCfg->getUseSBACRD() ) … … 1027 946 1028 947 //Store probabilties of second LCU in line into buffer 1029 #if WPP_SIMPLIFICATION1030 948 if (pcSlice->getPPS()->getNumSubstreams() > 1 && uiCol == uiTileLCUX+1) 1031 #else1032 if (pcSlice->getPPS()->getEntropyCodingSynchro() && uiCol == uiTileLCUX+pcSlice->getPPS()->getEntropyCodingSynchro())1033 #endif1034 949 { 1035 950 m_pcBufferSbacCoders[uiTileCol].loadContexts(ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]); 1036 951 } 1037 952 } 1038 #if !REMOVE_TILE_DEPENDENCE1039 if( (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr()==0) && (rpcPic->getPicSym()->getNumColumnsMinus1()!=0) )1040 {1041 //Store probabilties for next tile1042 if( (uiLin == (rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr() / uiWidthInLCUs )) &&1043 (uiCol == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getRightEdgePosInCU()) )1044 {1045 m_pcBufferLowLatSbacCoders[uiTileCol].loadContexts(ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]);1046 }1047 }1048 #endif1049 953 } 1050 954 // other case: encodeCU is not called … … 1130 1034 UInt uiWidthInLCUs = rpcPic->getPicSym()->getFrameWidthInCU(); 1131 1035 UInt uiCol=0, uiLin=0, uiSubStrm=0; 1132 #if !REMOVE_TILE_DEPENDENCE1133 Int iBreakDep = 0;1134 #endif1135 1036 UInt uiTileCol = 0; 1136 1037 UInt uiTileStartLCU = 0; … … 1138 1039 1139 1040 UInt uiEncCUOrder; 1041 1140 1042 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); /*for tiles, uiStartCUAddr is NOT the real raster scan address, it is actually 1141 1043 an encoding order index, so we need to convert the index (uiStartCUAddr) … … 1147 1049 if( m_pcCfg->getUseSBACRD() ) 1148 1050 { 1149 #if !REMOVE_TILE_DEPENDENCE1150 iBreakDep = rpcPic->getPicSym()->getTileBoundaryIndependenceIdr();1151 #endif1152 1051 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in? 1153 1052 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); … … 1156 1055 uiCol = uiCUAddr % uiWidthInLCUs; 1157 1056 uiLin = uiCUAddr / uiWidthInLCUs; 1158 #if !REMOVE_TILE_DEPENDENCE1159 #if WPP_SIMPLIFICATION1160 if (iBreakDep && pcSlice->getPPS()->getNumSubstreams() > 1)1161 #else1162 if (iBreakDep && pcSlice->getPPS()->getEntropyCodingSynchro())1163 #endif1164 #else1165 #if WPP_SIMPLIFICATION1166 1057 if (pcSlice->getPPS()->getNumSubstreams() > 1) 1167 #else1168 if (pcSlice->getPPS()->getEntropyCodingSynchro())1169 #endif1170 #endif1171 1058 { 1172 1059 // independent tiles => substreams are "per tile". iNumSubstreams has already been multiplied. … … 1184 1071 1185 1072 // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line. 1186 #if WPP_SIMPLIFICATION1187 1073 if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiCol == uiTileLCUX)) 1188 #else1189 if (pcSlice->getPPS()->getEntropyCodingSynchro() && (uiCol == uiTileLCUX))1190 #endif1191 1074 { 1192 1075 // We'll sync if the TR is available. … … 1195 1078 UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1); 1196 1079 TComDataCU *pcCUTR = NULL; 1197 #if WPP_SIMPLIFICATION1198 1080 if ( pcCUUp && ((uiCUAddr%uiWidthInCU+1) < uiWidthInCU) ) 1199 1081 { 1200 1082 pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 ); 1201 1083 } 1202 #else1203 if ( pcCUUp && ((uiCUAddr%uiWidthInCU+pcSlice->getPPS()->getEntropyCodingSynchro()) < uiWidthInCU) )1204 {1205 pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + pcSlice->getPPS()->getEntropyCodingSynchro() );1206 }1207 #endif1208 1084 if ( (true/*bEnforceSliceRestriction*/ && 1209 1085 ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 1210 1086 (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) || 1211 #if !REMOVE_TILE_DEPENDENCE1212 (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr() && (rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))1213 #else1214 1087 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))) 1215 #endif1216 1088 ))|| 1217 1089 (true/*bEnforceEntropySliceRestriction*/ && 1218 1090 ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 1219 1091 (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getEntropySliceCurStartCUAddr()) || 1220 #if !REMOVE_TILE_DEPENDENCE1221 (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr() && (rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))1222 #else1223 1092 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))) 1224 #endif1225 1093 )) 1226 1094 ) … … 1256 1124 // When tiles are independent, we have "substreams per tile". Each substream has already been terminated, and we no longer 1257 1125 // have to perform it here. 1258 #if WPP_SIMPLIFICATION1259 1126 if (pcSlice->getPPS()->getNumSubstreams() > 1) 1260 #else1261 if (pcSlice->getPPS()->getEntropyCodingSynchro())1262 #endif1263 1127 { 1264 1128 ; // do nothing. … … 1310 1174 1311 1175 TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr ); 1312 #if !REMOVE_TILE_DEPENDENCE 1313 if( (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr()==0) && (rpcPic->getPicSym()->getNumColumnsMinus1()!=0) ) 1314 { 1315 // Synchronize cabac probabilities with LCU among Tiles 1316 if( (uiTileLCUX != 0) && 1317 (uiCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr()) ) 1318 { 1319 TComDataCU *pcCULeft = pcCU->getCULeft(); 1320 UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1); 1321 1322 if ( (true/*bEnforceSliceRestriction*/ && 1323 ((pcCULeft==NULL) || (pcCULeft->getSlice()==NULL) || 1324 ((pcCULeft->getSCUAddr()+uiMaxParts-1) < pcSlice->getSliceCurStartCUAddr()) 1325 ) 1326 )|| 1327 (true/*bEnforceEntropySliceRestriction*/ && 1328 ((pcCULeft==NULL) || (pcCULeft->getSlice()==NULL) || 1329 ((pcCULeft->getSCUAddr()+uiMaxParts-1) < pcSlice->getEntropySliceCurStartCUAddr()) 1330 ) 1331 ) 1332 ) 1333 { 1334 // Left not available. 1335 } 1336 else 1337 { 1338 // Left is available, we use it. 1339 pcSbacCoders[uiSubStrm].loadContexts( &m_pcBufferLowLatSbacCoders[uiTileCol-1] ); 1340 m_pcSbacCoder->loadContexts(&pcSbacCoders[uiSubStrm]); //this load is used to simplify the code (avoid to change all the call to m_pcSbacCoder) 1341 } 1342 } 1343 } 1344 #endif 1345 1346 #if SAO_UNIT_INTERLEAVING 1176 1347 1177 if ( pcSlice->getSPS()->getUseSAO() && pcSlice->getAPS()->getSaoInterleavingFlag() && pcSlice->getSaoEnabledFlag() ) 1348 1178 { … … 1354 1184 m_pcEntropyCoder->encodeSaoUnitInterleaving( rx, ry, pcSlice->getAPS()->getSaoParam(),pcCU, iCUAddrInSlice, iCUAddrUpInSlice, pcSlice->getSPS()->getLFCrossSliceBoundaryFlag()); 1355 1185 } 1356 #endif1357 1186 #if ENC_DEC_TRACE 1358 1187 g_bJustDoIt = g_bEncDecTraceEnable; … … 1376 1205 1377 1206 //Store probabilties of second LCU in line into buffer 1378 #if WPP_SIMPLIFICATION1379 1207 if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiCol == uiTileLCUX+1)) 1380 #else1381 if (pcSlice->getPPS()->getEntropyCodingSynchro() && (uiCol == uiTileLCUX+pcSlice->getPPS()->getEntropyCodingSynchro()))1382 #endif1383 1208 { 1384 1209 m_pcBufferSbacCoders[uiTileCol].loadContexts( &pcSbacCoders[uiSubStrm] ); 1385 1210 } 1386 1211 } 1387 #if !REMOVE_TILE_DEPENDENCE1388 if( (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr()==0) && (rpcPic->getPicSym()->getNumColumnsMinus1()!=0) )1389 {1390 pcSbacCoders[uiSubStrm].load(m_pcSbacCoder); //load back status of the entropy coder after encoding the LCU into relevant bitstream entropy coder1391 //Store probabilties for next tile1392 if( (uiLin == (rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr() / uiWidthInLCUs )) &&1393 (uiCol == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getRightEdgePosInCU()) )1394 {1395 m_pcBufferLowLatSbacCoders[uiTileCol].loadContexts( &pcSbacCoders[uiSubStrm] );1396 }1397 }1398 #endif1399 1212 1400 1213 #if OL_QTLIMIT_PREDCODING_B0068 … … 1426 1239 TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx()); 1427 1240 UInt uiStartCUAddrSlice, uiBoundingCUAddrSlice; 1428 #if FIXED_NUMBER_OF_TILES_SLICE_MODE1429 1241 UInt tileIdxIncrement; 1430 1242 UInt tileIdx; … … 1432 1244 UInt tileHeightInLcu; 1433 1245 UInt tileTotalCount; 1434 #endif1435 1246 1436 1247 uiStartCUAddrSlice = pcSlice->getSliceCurStartCUAddr(); … … 1450 1261 uiBoundingCUAddrSlice = pcSlice->getSliceCurEndCUAddr(); 1451 1262 break; 1452 #if FIXED_NUMBER_OF_TILES_SLICE_MODE1453 1263 case AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE: 1454 1264 tileIdx = rpcPic->getPicSym()->getTileIdxMap( … … 1470 1280 uiBoundingCUAddrSlice = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU()) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1471 1281 break; 1472 #endif1473 1282 default: 1474 1283 uiCUAddrIncrement = rpcPic->getNumCUsInFrame(); … … 1487 1296 uiBoundingCUAddrSlice = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU()) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1488 1297 break; 1489 #if FIXED_NUMBER_OF_TILES_SLICE_MODE1490 1298 case AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE: 1491 1299 tileIdx = rpcPic->getPicSym()->getTileIdxMap( … … 1507 1315 uiBoundingCUAddrSlice = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU()) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU(); 1508 1316 break; 1509 #endif1510 1317 default: 1511 1318 uiCUAddrIncrement = rpcPic->getNumCUsInFrame(); … … 1516 1323 } 1517 1324 1518 #if COMPLETE_SLICES_IN_TILE1519 1325 Bool tileBoundary = false; 1520 1326 if ((m_pcCfg->getSliceMode() == AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE || m_pcCfg->getSliceMode() == AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE) && … … 1539 1345 } 1540 1346 } 1541 #endif1542 1347 1543 1348 // Entropy slice … … 1644 1449 || (m_pcCfg->getSliceMode()==0 && m_pcCfg->getEntropySliceMode()==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE) 1645 1450 || (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE && m_pcCfg->getEntropySliceMode()==0) 1646 #if FIXED_NUMBER_OF_TILES_SLICE_MODE1647 1451 || (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE && m_pcCfg->getEntropySliceMode()==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE) 1648 1452 || (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE && m_pcCfg->getEntropySliceMode()==0) 1649 #endif1650 #if COMPLETE_SLICES_IN_TILE1651 1453 || tileBoundary 1652 #endif1653 1454 ) 1654 1455 { -
trunk/source/Lib/TLibEncoder/TEncSlice.h
r210 r296 101 101 102 102 UInt m_uiSliceIdx; 103 104 #if MERL_VSP_C0152 105 // Data temporarily stored, will be sent to TComSlice level where the data will be actually used 106 TComPic* m_pPicBaseTxt; 107 TComPic* m_pPicBaseDepth; 108 Int* m_aiShiftLUT; 109 Int m_iShiftPrec; 110 #endif 111 103 112 public: 104 113 TEncSlice(); … … 111 120 /// preparation of slice encoding (reference marking, QP and lambda) 112 121 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 122 #if MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137 123 Void initEncSlice ( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS, bool isDepth ); 124 #else 113 125 Void initEncSlice ( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS ); 126 #endif 114 127 #else 115 128 Void initEncSlice ( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS ); … … 128 141 UInt getSliceIdx() { return m_uiSliceIdx; } 129 142 Void setSliceIdx(UInt i) { m_uiSliceIdx = i; } 143 144 #if MERL_VSP_C0152 145 Void setBWVSPLUTParam ( Int *pShiftLUT, Int iLoG2LUTPrec ) { m_aiShiftLUT = pShiftLUT; m_iShiftPrec = 2-iLoG2LUTPrec; } 146 Void setRefPicBaseTxt ( TComPic*pPicTxt ) { m_pPicBaseTxt = pPicTxt; } 147 Void setRefPicBaseDepth ( TComPic*pPicDepth ) { m_pPicBaseDepth = pPicDepth;} 148 Void getBWVSPLUTParam ( Int*& pShiftLUT, Int& iShiftPrec ) { pShiftLUT = m_aiShiftLUT; iShiftPrec = m_iShiftPrec; } 149 TComPic* getRefPicBaseTxt () { return m_pPicBaseTxt; } 150 TComPic* getRefPicBaseDepth () { return m_pPicBaseDepth; } 151 #endif 130 152 }; 131 153 -
trunk/source/Lib/TLibEncoder/TEncTop.cpp
r210 r296 103 103 if (m_bUseSAO) 104 104 { 105 #if SAO_UNIT_INTERLEAVING106 105 m_cEncSAO.setSaoInterleavingFlag(getSaoInterleavingFlag()); 107 106 m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic()); 108 #endif109 107 m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 110 108 m_cEncSAO.createEncBuffer(); … … 122 120 m_cDepthMapGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) ); 123 121 #endif 124 #if H HI_INTER_VIEW_RESIDUAL_PRED122 #if H3D_IVRP 125 123 m_cResidualGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement ); 126 124 #endif … … 128 126 if(m_bUseALF) 129 127 { 130 #if LCU_SYNTAX_ALF131 128 m_cAdaptiveLoopFilter.setAlfCoefInSlice(m_bALFParamInSlice); 132 129 m_cAdaptiveLoopFilter.createAlfGlobalBuffers(); 133 #else134 m_cAdaptiveLoopFilter.setGOPSize( getGOPSize() );135 m_cAdaptiveLoopFilter.createAlfGlobalBuffers(m_iALFEncodePassReduction);136 #endif137 130 } 138 131 … … 258 251 m_cDepthMapGenerator. destroy(); 259 252 #endif 260 #if H HI_INTER_VIEW_RESIDUAL_PRED253 #if H3D_IVRP 261 254 m_cResidualGenerator. destroy(); 262 255 #endif … … 333 326 // initialize PPS 334 327 m_cPPS.setSPS(&m_cSPS); 335 #if RPS_IN_SPS336 328 m_cSPS.setRPSList(&m_RPSList); 337 #else338 m_cPPS.setRPSList(&m_RPSList);339 #endif340 329 xInitPPS(); 341 330 xInitRPS(); … … 358 347 #endif 359 348 #endif 360 #if H HI_INTER_VIEW_RESIDUAL_PRED349 #if H3D_IVRP 361 350 m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator ); 362 351 #endif … … 384 373 m_cAdaptiveLoopFilter.setALFEncodePassReduction( m_iALFEncodePassReduction ); 385 374 m_cAdaptiveLoopFilter.setALFMaxNumberFilters( m_iALFMaxNumberFilters ); 386 #if LCU_SYNTAX_ALF387 375 m_cAdaptiveLoopFilter.initPicQuadTreePartition(m_bALFPicBasedEncode ); 388 #endif389 376 } 390 377 … … 404 391 pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); 405 392 406 #if SONY_COLPIC_AVAILABILITY407 pcPicCurr->setViewOrderIdx(m_iViewOrderIdx); 393 #if INTER_VIEW_VECTOR_SCALING_C0115 394 pcPicCurr->setViewOrderIdx(m_iViewOrderIdx); // will be changed to view_id 408 395 #endif 409 396 pcPicCurr->setScaleOffset( m_aaiCodedScale, m_aaiCodedOffset ); 410 397 411 #if H HI_INTER_VIEW_MOTION_PRED398 #if H3D_IVMP 412 399 if( m_uiMultiviewMvRegMode ) 413 400 { … … 486 473 487 474 488 #if HHI_INTERVIEW_SKIP || H HI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED475 #if HHI_INTERVIEW_SKIP || H3D_IVMP || H3D_IVRP 489 476 Void 490 477 TEncTop::deleteExtraPicBuffers( Int iPoc ) … … 504 491 if ( pcPic ) 505 492 { 506 #if H HI_INTER_VIEW_MOTION_PRED493 #if H3D_IVMP 507 494 pcPic->removeOrgDepthMapBuffer(); 508 495 #endif 509 #if H HI_INTER_VIEW_RESIDUAL_PRED496 #if H3D_IVRP 510 497 pcPic->removeResidualBuffer (); 511 498 #endif … … 553 540 TComSlice::sortPicList(m_cListPic); 554 541 555 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER556 542 if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) 557 #else558 if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxNumberOfReferencePictures() + 2) )559 #endif560 543 { 561 544 TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); … … 594 577 m_iNumPicRcvd++; 595 578 596 #if H HI_INTER_VIEW_MOTION_PRED579 #if H3D_IVMP 597 580 if( m_uiMultiviewMvRegMode ) 598 581 { … … 611 594 m_cSPS.setPicWidthInLumaSamples ( m_iSourceWidth ); 612 595 m_cSPS.setPicHeightInLumaSamples ( m_iSourceHeight ); 613 #if PIC_CROPPING614 596 m_cSPS.setPicCroppingFlag( m_croppingMode!= 0 ); 615 597 if (m_croppingMode != 0) … … 620 602 m_cSPS.setPicCropBottomOffset( m_cropBottom ); 621 603 } 622 #else623 m_cSPS.setPad ( m_aiPad );624 #endif625 604 m_cSPS.setMaxCUWidth ( g_uiMaxCUWidth ); 626 605 m_cSPS.setMaxCUHeight ( g_uiMaxCUHeight ); … … 629 608 m_cSPS.setMaxTrDepth ( 1 ); 630 609 631 #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER632 m_cSPS.setMaxNumberOfReferencePictures(m_maxNumberOfReferencePictures);633 m_cSPS.setNumReorderFrames(m_numReorderFrames);634 #endif635 610 m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize); 636 611 m_cSPS.setUsePCM ( m_usePCM ); … … 638 613 639 614 m_cSPS.setUseALF ( m_bUseALF ); 640 #if LCU_SYNTAX_ALF641 615 if(m_bUseALF) 642 616 { 643 617 m_cSPS.setUseALFCoefInSlice(m_bALFParamInSlice); 644 618 } 645 #endif646 619 647 620 #if RWTH_SDC_DLT_B0036 … … 657 630 m_cSPS.setUseLossless ( m_useLossless ); 658 631 #endif 659 #if !PIC_CROPPING660 m_cSPS.setUsePAD ( m_bUsePAD );661 #endif662 632 m_cSPS.setUseLMChroma ( m_bUseLMChroma ); 663 633 … … 696 666 m_cSPS.setBitDepth ( g_uiBitDepth ); 697 667 m_cSPS.setBitIncrement( g_uiBitIncrement ); 698 #if H0736_AVC_STYLE_QP_RANGE699 668 m_cSPS.setQpBDOffsetY ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) ); 700 669 m_cSPS.setQpBDOffsetC ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) ); 701 #endif702 670 703 671 m_cSPS.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); 704 672 m_cSPS.setUseSAO( m_bUseSAO ); 705 673 706 #if !H0566_TLA707 if ( m_bTLayering )708 {709 Int iMaxTLayers = 1;710 for ( i = 1; ; i++)711 {712 iMaxTLayers = i;713 if ( (m_iGOPSize >> i) == 0 )714 {715 break;716 }717 }718 719 m_cSPS.setMaxTLayers( (UInt)iMaxTLayers );720 721 Bool bTemporalIdNestingFlag = true;722 for ( i = 0; i < m_cSPS.getMaxTLayers()-1; i++ )723 {724 if ( !m_abTLayerSwitchingFlag[i] )725 {726 bTemporalIdNestingFlag = false;727 break;728 }729 }730 731 m_cSPS.setTemporalIdNestingFlag( bTemporalIdNestingFlag );732 }733 else734 {735 m_cSPS.setMaxTLayers( 1 );736 m_cSPS.setTemporalIdNestingFlag( false );737 }738 #else739 674 m_cSPS.setMaxTLayers( m_maxTempLayer ); 740 675 m_cSPS.setTemporalIdNestingFlag( false ); 741 #endif742 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER743 676 for ( i = 0; i < m_cSPS.getMaxTLayers(); i++ ) 744 677 { … … 746 679 m_cSPS.setNumReorderPics(m_numReorderPics[i], i); 747 680 } 748 #endif749 681 m_cSPS.setPCMBitDepthLuma (g_uiPCMBitDepthLuma); 750 682 m_cSPS.setPCMBitDepthChroma (g_uiPCMBitDepthChroma); … … 753 685 m_cSPS.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); 754 686 m_cSPS.setUniformSpacingIdr( m_iUniformSpacingIdr ); 755 #if !REMOVE_TILE_DEPENDENCE756 m_cSPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );757 #endif758 687 m_cSPS.setNumColumnsMinus1( m_iNumColumnsMinus1 ); 759 688 m_cSPS.setNumRowsMinus1( m_iNumRowsMinus1 ); … … 787 716 m_cSPS.setPredDepthMapGeneration( m_viewId, true ); 788 717 #endif 789 #if H HI_INTER_VIEW_RESIDUAL_PRED718 #if H3D_IVRP 790 719 m_cSPS.setMultiviewResPredMode ( 0 ); 791 720 #endif … … 801 730 { 802 731 #if DEPTH_MAP_GENERATION 803 #if H HI_INTER_VIEW_MOTION_PRED732 #if H3D_IVMP 804 733 m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, m_uiMultiviewMvPredMode, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset ); 805 734 #else … … 807 736 #endif 808 737 #endif 809 #if H HI_INTER_VIEW_RESIDUAL_PRED738 #if H3D_IVRP 810 739 m_cSPS.setMultiviewResPredMode ( m_uiMultiviewResPredMode ); 811 740 #endif … … 816 745 m_cSPS.setPredDepthMapGeneration( m_viewId, false ); 817 746 #endif 818 #if H HI_INTER_VIEW_RESIDUAL_PRED747 #if H3D_IVRP 819 748 m_cSPS.setMultiviewResPredMode ( 0 ); 820 749 #endif … … 827 756 m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred ); 828 757 m_cPPS.setSliceGranularity(m_iSliceGranularity); 829 #if !H0566_TLA830 if ( m_cSPS.getTemporalIdNestingFlag() )831 {832 m_cPPS.setNumTLayerSwitchingFlags( 0 );833 for ( UInt i = 0; i < m_cSPS.getMaxTLayers() - 1; i++ )834 {835 m_cPPS.setTLayerSwitchingFlag( i, true );836 }837 }838 else839 {840 m_cPPS.setNumTLayerSwitchingFlags( m_cSPS.getMaxTLayers() - 1 );841 for ( UInt i = 0; i < m_cPPS.getNumTLayerSwitchingFlags(); i++ )842 {843 m_cPPS.setTLayerSwitchingFlag( i, m_abTLayerSwitchingFlag[i] );844 }845 }846 #endif847 758 Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; 848 759 849 760 #if LOSSLESS_CODING 850 #if H0736_AVC_STYLE_QP_RANGE851 761 Int lowestQP = - m_cSPS.getQpBDOffsetY(); 852 #else853 Int lowestQP = 0;854 #endif855 762 856 763 if(getUseLossless()) … … 903 810 904 811 m_cPPS.setEntropyCodingMode( 1 ); // In the PPS now, but also remains in slice header! 905 #if !WPP_SIMPLIFICATION906 m_cPPS.setEntropyCodingSynchro(m_iWaveFrontSynchro);907 m_cPPS.setCabacIstateReset(m_iWaveFrontFlush != 0);908 #endif909 812 m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams); 910 813 m_cPPS.setUseWP( m_bUseWeightPred ); 911 814 m_cPPS.setWPBiPredIdc( m_uiBiPredIdc ); 912 815 m_cPPS.setEnableTMVPFlag( m_bEnableTMVP ); 913 #if H0388914 816 m_cPPS.setOutputFlagPresentFlag( false ); 915 #endif916 #if MULTIBITS_DATA_HIDING917 817 m_cPPS.setSignHideFlag(getSignHideFlag()); 918 818 m_cPPS.setTSIG(getTSIG()); 919 #endif920 #if DBL_CONTROL921 819 m_cPPS.setDeblockingFilterControlPresent (m_DeblockingFilterControlPresent ); 922 #endif923 #if PARALLEL_MERGE924 820 m_cPPS.setLog2ParallelMergeLevelMinus2 (LOG2_PARALLEL_MERGE_LEVEL_MINUS2); 925 #endif926 821 #if CABAC_INIT_FLAG 927 822 m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); … … 1102 997 m_cPPS.setColumnRowInfoPresent( m_iColumnRowInfoPresent ); 1103 998 m_cPPS.setUniformSpacingIdr( m_iUniformSpacingIdr ); 1104 #if !REMOVE_TILE_DEPENDENCE1105 m_cPPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );1106 #endif1107 999 m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 ); 1108 1000 m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 ); -
trunk/source/Lib/TLibEncoder/TEncTop.h
r56 r296 103 103 TComDepthMapGenerator m_cDepthMapGenerator; ///< depth map generator 104 104 #endif 105 #if H HI_INTER_VIEW_RESIDUAL_PRED105 #if H3D_IVRP 106 106 TComResidualGenerator m_cResidualGenerator; ///< generator for residual pictures 107 107 #endif … … 173 173 } 174 174 } 175 #if HHI_INTERVIEW_SKIP || H HI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED175 #if HHI_INTERVIEW_SKIP || H3D_IVMP || H3D_IVRP 176 176 Void deleteExtraPicBuffers ( Int iPoc ); 177 177 #endif … … 234 234 TComDepthMapGenerator* getDepthMapGenerator () { return &m_cDepthMapGenerator; } 235 235 #endif 236 #if H HI_INTER_VIEW_RESIDUAL_PRED236 #if H3D_IVRP 237 237 TComResidualGenerator* getResidualGenerator () { return &m_cResidualGenerator; } 238 238 #endif
Note: See TracChangeset for help on using the changeset viewer.