Changeset 296 in 3DVCSoftware for trunk/source/Lib/TLibEncoder


Ignore:
Timestamp:
20 Feb 2013, 22:07:43 (12 years ago)
Author:
tech
Message:

Reintegrated branch 5.1-dev0 rev. 295.

Location:
trunk/source/Lib/TLibEncoder
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibEncoder/NALwrite.cpp

    r210 r296  
    5656
    5757  bsNALUHeader.write(0,1); // forbidden_zero_flag
    58 #if NAL_REF_FLAG
    5958  bsNALUHeader.write(nalu.m_nalRefFlag? 1 : 0, 1); // nal_ref_flag
    6059  bsNALUHeader.write(nalu.m_nalUnitType, 6);          // nal_unit_type
    61 #else
    62   bsNALUHeader.write(nalu.m_nalRefIDC, 2); // nal_ref_idc
    63   bsNALUHeader.write(nalu.m_nalUnitType, 5); // nal_unit_type
    64 #endif
    6560
    6661#if QC_MVHEVC_B0046
     
    7267  bsNALUHeader.write(nalu.m_layerId + 1, 5); // layer_id_plus1
    7368#else
    74 #if H0388
    7569  bsNALUHeader.write(nalu.m_temporalId, 3); // temporal_id
    7670 // bsNALUHeader.write(1, 5); // reserved_one_5bits
    7771  bsNALUHeader.write(nalu.m_viewId+1,4);
    7872  bsNALUHeader.write(nalu.m_isDepth,1);
    79 #else
    80   switch (nalu.m_nalUnitType)
    81   {
    82   case NAL_UNIT_CODED_SLICE:
    83   case NAL_UNIT_CODED_SLICE_IDR:
    84 #if H0566_TLA
    85 #if !QC_REM_IDV_B0046
    86   case NAL_UNIT_CODED_SLICE_IDV:
    87 #endif
    88   case NAL_UNIT_CODED_SLICE_CRA:
    89   case NAL_UNIT_CODED_SLICE_TLA:
    90 #else
    91   case NAL_UNIT_CODED_SLICE_CDR:
    92 #endif
    93     bsNALUHeader.write(nalu.m_temporalId, 3); // temporal_id
    94     bsNALUHeader.write(nalu.m_OutputFlag, 1); // output_flag
    95   //  bsNALUHeader.write(1, 4); // reserved_one_4bits
    96     bsNALUHeader.write(nalu.m_viewId+1,3);
    97     bsNALUHeader.write(nalu.m_isDepth,1);
    98     break;
    99   default: break;
    100   }
    101 #endif
    10273#endif
    10374#endif
     
    209180{
    210181  naluDest.m_nalUnitType = naluSrc.m_nalUnitType;
    211 #if NAL_REF_FLAG
    212182  naluDest.m_nalRefFlag  = naluSrc.m_nalRefFlag;
    213 #else
    214   naluDest.m_nalRefIDC   = naluSrc.m_nalRefIDC;
    215 #endif
    216183#if !VIDYO_VPS_INTEGRATION
    217184  naluDest.m_viewId      = naluSrc.m_viewId;
     
    223190#else
    224191 
    225 #if !H0388
    226   naluDest.m_OutputFlag  = naluSrc.m_OutputFlag;
    227 #endif
    228192#endif
    229193  naluDest.m_Bitstream   = naluSrc.m_Bitstream;
  • trunk/source/Lib/TLibEncoder/NALwrite.h

    r210 r296  
    5454   * written to the bitstream.
    5555   */
    56 #if H0388
    5756  OutputNALUnit(
    5857    NalUnitType nalUnitType,
    59 #if NAL_REF_FLAG
    6058    Bool nalRefFlag,
    61 #else
    62     NalRefIdc nalRefIDC,
    63 #endif
    6459#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    6560    unsigned layerId,
     
    6964#endif
    7065    unsigned temporalID = 0)
    71 #if NAL_REF_FLAG
    7266#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    7367  : NALUnit(nalUnitType, nalRefFlag, layerId, temporalID)
     
    7569  : NALUnit(nalUnitType, nalRefFlag, viewId, isDepth, temporalID)
    7670#endif
    77 #else
    78 #if VIDYO_VPS_INTEGRATION
    79   : NALUnit(nalUnitType, nalRefIDC, layerId, temporalID)
    80 #else
    81   : NALUnit(nalUnitType, nalRefIDC, viewId, isDepth, temporalID)
    82 #endif
    83 #endif
    8471  , m_Bitstream()
    8572  {}
    86 #else
    87   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 #endif
    9873
    9974  OutputNALUnit(const NALUnit& src)
  • trunk/source/Lib/TLibEncoder/TEncAdaptiveLoopFilter.cpp

    r56 r296  
    4747// Constants
    4848// ====================================================================================================================
    49 #if LCU_SYNTAX_ALF
    5049#define ALF_NUM_OF_REDESIGN 1
    51 #else
    52 #define ALF_NUM_OF_REDESIGN 3
    53 #endif
    5450// ====================================================================================================================
    5551// Tables
    5652// ====================================================================================================================
    57 #if LCU_SYNTAX_ALF
    5853const Int TEncAdaptiveLoopFilter::m_alfNumPartsInRowTab[5] =
    5954{
     
    8277  341,  //level 4
    8378};
    84 #endif
    8579// ====================================================================================================================
    8680// Constructor / destructor
    8781// ====================================================================================================================
    8882
    89 #if LCU_SYNTAX_ALF
    9083///AlfCorrData
    9184AlfCorrData::AlfCorrData()
     
    376369  return *this;
    377370}
    378 #endif
    379371
    380372
    381373TEncAdaptiveLoopFilter::TEncAdaptiveLoopFilter()
    382374{
    383 #if !LCU_SYNTAX_ALF
    384   m_ppdAlfCorr = NULL;
    385   m_ppdAlfCorrCb = NULL;
    386   m_ppdAlfCorrCr = NULL;
    387   m_pdDoubleAlfCoeff = NULL;
    388 #endif
    389375  m_pcEntropyCoder = NULL;
    390 #if !LCU_SYNTAX_ALF
    391   m_pcBestAlfParam = NULL;
    392   m_pcTempAlfParam = NULL;
    393 #endif
    394376  m_pcPicYuvBest = NULL;
    395377  m_pcPicYuvTmp = NULL;
    396 #if !LCU_SYNTAX_ALF
    397   pcAlfParamShape0 = NULL;
    398   pcAlfParamShape1 = NULL;
    399   pcPicYuvRecShape0 = NULL;
    400   pcPicYuvRecShape1 = NULL;
    401   m_pcSliceYuvTmp = NULL;
    402 #endif
    403378
    404379  m_iALFMaxNumberFilters = NO_FILTERS;
     
    411386// ====================================================================================================================
    412387
    413 #if LCU_SYNTAX_ALF
    414388/** convert Level Row Col to Idx
    415389 * \param   level,  row,  col
     
    799773}
    800774
    801 #else
    802 
    803 /** create ALF global buffers
    804  * \param iALFEncodePassReduction 0: 16-pass encoding, 1: 1-pass encoding, 2: 2-pass encoding
    805  * 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 buffers
    832  * 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 #endif
    860775/**
    861776 \param pcPic           picture (TComPic) pointer
     
    865780{
    866781  m_pcEntropyCoder = pcEntropyCoder;
    867 #if !LCU_SYNTAX_ALF
    868   xInitParam();
    869 #endif
    870782  xCreateTmpAlfCtrlFlags();
    871783 
     
    876788  m_pcPicYuvTmp->createLuma(iWidth, iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
    877789  m_pcPicYuvBest = pcPic->getPicYuvPred();
    878 #if !LCU_SYNTAX_ALF 
    879   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_filter
    896   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 #endif
    899790  initMatrix_int(&m_filterCoeffSymQuant, NO_VAR_BINS, ALF_MAX_NUM_COEF);
    900 #if !LCU_SYNTAX_ALF
    901   m_pixAcc = (double *) calloc(NO_VAR_BINS, sizeof(double));
    902 #endif
    903791  initMatrix_Pel(&m_maskImg, m_img_height, m_img_width);
    904792  initMatrix_double(&m_E_temp, MAX_SQR_FILT_LENGTH, MAX_SQR_FILT_LENGTH);//
     
    913801  initMatrix_int(&m_FilterCoeffQuantTemp, NO_VAR_BINS, ALF_MAX_NUM_COEF);//
    914802
    915 #if LCU_SYNTAX_ALF
    916803  m_tempALFp = new ALFParam(ALF_Y);
    917 #else
    918   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 #endif
    926804}
    927805
    928806Void TEncAdaptiveLoopFilter::endALFEnc()
    929807{
    930 #if !LCU_SYNTAX_ALF
    931   xUninitParam();
    932 #endif
    933808  xDestroyTmpAlfCtrlFlags();
    934809 
     
    938813  m_pcPic = NULL;
    939814  m_pcEntropyCoder = NULL;
    940 #if !LCU_SYNTAX_ALF
    941   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 filters
    961   destroyMatrix4D_double(m_EGlobalSym, NUM_ALF_FILTER_SHAPE+1,  NO_VAR_BINS);
    962   destroyMatrix3D_double(m_yGlobalSym, NUM_ALF_FILTER_SHAPE+1);
    963 #endif
    964815  destroyMatrix_int(m_filterCoeffSymQuant);
    965 #if !LCU_SYNTAX_ALF 
    966   free(m_pixAcc);
    967 #endif
    968816  destroyMatrix_Pel(m_maskImg);
    969817  destroyMatrix3D_double(m_E_merged, NO_VAR_BINS);
     
    980828  destroyMatrix_int(m_FilterCoeffQuantTemp);
    981829 
    982 #if LCU_SYNTAX_ALF
    983830  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
    998833
    999834/** Assign output ALF parameters
     
    27622597#endif
    27632598
    2764 #if ALF_SINGLE_FILTER_SHAPE
    27652599        calcCorrOneCompRegionChma(pPicOrg, pPicSrc, stride, ypos, xpos, height, width, alfCorr->ECorr[0], alfCorr->yCorr[0], isLastBlock);
    2766 #endif
    27672600      }
    27682601    }
     
    28222655#endif
    28232656
    2824 #if ALF_SINGLE_FILTER_SHAPE
    28252657        calcCorrOneCompRegionLuma(pPicOrg, pPicSrc, stride, ypos, xpos, height, width, alfCorr->ECorr, alfCorr->yCorr, alfCorr->pixAcc, forceCollection, isLastBlock);
    2826 #endif       
    28272658      }
    28282659    }
     
    28382669
    28392670
    2840 #if ALF_SINGLE_FILTER_SHAPE
    28412671/** Gather correlations for one region for chroma component
    28422672 * \param [in] imgOrg picture buffer for original picture
     
    30862916
    30872917}
    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
    32672919
    32682920/** PCM LF disable process.
     
    32842936// Private member functions
    32852937// ====================================================================================================================
    3286 #if !LCU_SYNTAX_ALF
    3287 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   else
    3302   {
    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   else
    3322   {
    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   else
    3340   {
    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   else
    3363   {
    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 #endif
    34192938Void TEncAdaptiveLoopFilter::xCreateTmpAlfCtrlFlags()
    34202939{
     
    35123031}
    35133032
    3514 #if !LCU_SYNTAX_ALF
    3515 
    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_SHAPE
    3537   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         else
    3559         {
    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         else
    3574         {
    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 #else
    3615   case ALF_CROSS9x7_SQUARE3x3:
    3616     {
    3617       Pel *pImgPad5, *pImgPad6;
    3618 #endif
    3619       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_SHAPE
    3633           pImgPad7 = (paddingline < 4) ? pImgPad : pImgPad + 4*iCmpStride;
    3634           pImgPad8 = (paddingline < 4) ? pImgPad : pImgPad - min(paddingline, 4)*iCmpStride;;     
    3635 #endif
    3636         }
    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_SHAPE
    3646           pImgPad7 = pImgPad + 4*iCmpStride;
    3647           pImgPad8 = pImgPad - 4*iCmpStride;
    3648 #endif
    3649         }
    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_SHAPE
    3660           pImgPad7 = (paddingline < 4) ? pImgPad : pImgPad + min(paddingline, 4)*iCmpStride;
    3661           pImgPad8 = (paddingline < 4) ? pImgPad : pImgPad - 4*iCmpStride;
    3662 #endif
    3663         }
    3664         else
    3665         {
    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_SHAPE
    3674           pImgPad7 = (paddingline < 4) ? pImgPad : pImgPad + 4*iCmpStride;
    3675           pImgPad8 = (paddingline < 4) ? pImgPad : pImgPad - min(paddingline, 4)*iCmpStride;
    3676 #endif
    3677         }
    3678 
    3679         for (j= xpos; j<= xposEnd; j++)
    3680         {
    3681           memset(ELocal, 0, N*sizeof(Int));
    3682 #if ALF_SINGLE_FILTER_SHAPE
    3683           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 #else
    3694           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 #endif
    3708           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 #endif
    37483033#if IBDI_DISTORTION
    37493034#if HHI_INTERVIEW_SKIP
     
    39463231  Int    *nc;
    39473232  const Int    *pFiltMag;
    3948 #if LCU_SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS
     3233#if LCUALF_QP_DEPENDENT_BITS
    39493234  Int alfPrecisionBit = getAlfPrecisionBit( m_alfQP );
    39503235#endif
    39513236
    39523237  N = m_sqrFiltLengthTab[tap];
    3953 #if ALF_SINGLE_FILTER_SHAPE
    39543238  pFiltMag = weightsShape1Sym;
    3955 #else
    3956   // star shape
    3957   if(tap == 0)
    3958   {
    3959     pFiltMag = weightsShape0Sym;
    3960   }
    3961   // cross shape
    3962   else
    3963   {
    3964     pFiltMag = weightsShape1Sym;
    3965   }
    3966 #endif
    39673239
    39683240  dh = new Double[N];
    39693241  nc = new Int[N];
    39703242 
    3971 #if LCU_SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS 
     3243#if LCUALF_QP_DEPENDENT_BITS 
    39723244  max_value =   (1<<(1+alfPrecisionBit))-1;
    39733245  min_value = 0-(1<<(1+alfPrecisionBit));
     
    39833255    if(h[i]>=0.0)
    39843256    {
    3985 #if LCU_SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS
     3257#if LCUALF_QP_DEPENDENT_BITS
    39863258      qh[i] =  (Int)( h[i]*(1<<alfPrecisionBit)+0.5);
    39873259#else
     
    39913263    else
    39923264    {
    3993 #if LCU_SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS
     3265#if LCUALF_QP_DEPENDENT_BITS
    39943266      qh[i] = -(Int)(-h[i]*(1<<alfPrecisionBit)+0.5);
    39953267#else
     
    39983270    }
    39993271
    4000 #if LCU_SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS
     3272#if LCUALF_QP_DEPENDENT_BITS
    40013273    dh[i] = (Double)qh[i]/(Double)(1<<alfPrecisionBit) - h[i];
    40023274#else
     
    40103282 
    40113283  // modification of quantized filter coefficients
    4012 #if LCU_SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS
     3284#if LCUALF_QP_DEPENDENT_BITS
    40133285  total_gain = (Int)(dbl_total_gain*(1<<alfPrecisionBit)+0.5);
    40143286#else
     
    40823354  nc = NULL;
    40833355}
    4084 #if !LCU_SYNTAX_ALF
    4085 Void TEncAdaptiveLoopFilter::xClearFilterCoefInt(Int* qh, Int N)
    4086 {
    4087   // clear
    4088   memset( qh, 0, sizeof( Int ) * N );
    4089  
    4090   // center pos
    4091   qh[N-1]  = 1<<ALF_NUM_BIT_SHIFT;
    4092 }
    4093 /** Calculate RD cost
    4094  * \param [in] pAlfParam ALF parameters
    4095  * \param [out] ruiRate coding bits
    4096  * \param [in] uiDist distortion
    4097  * \param [out] rdCost rate-distortion cost
    4098  * \param [in] pvAlfCUCtrlParam ALF CU control parameters
    4099  */
    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     else
    4125     {
    4126       ruiRate += m_uiNumSlicesInPic;
    4127     }
    4128   }
    4129   else
    4130   {
    4131     ruiRate = 1;
    4132   }
    4133  
    4134   rdCost      = (Double)(ruiRate) * m_dLambdaLuma + (Double)(uiDist);
    4135 }
    4136 
    4137 /** Calculate RD cost
    4138  * \param [in] pcPicOrg original picture buffer
    4139  * \param [in] pcPicCmp compared picture buffer
    4140  * \param [in] pAlfParam ALF parameters
    4141  * \param [out] ruiRate coding bits
    4142  * \param [out] ruiDist distortion
    4143  * \param [out] rdCost rate-distortion cost
    4144  * \param [in] pvAlfCUCtrlParam ALF CU control parameters
    4145  */
    4146 #if HHI_INTERVIEW_SKIP
    4147 Void TEncAdaptiveLoopFilter::xCalcRDCost(TComPicYuv* pcPicOrg, TComPicYuv* pcPicCmp, TComPicYuv* pcUsedPelMap, ALFParam* pAlfParam, UInt64& ruiRate, UInt64& ruiDist, Double& rdCost, std::vector<AlfCUCtrlInfo>* pvAlfCUCtrlParam)
    4148 #else
    4149 Void TEncAdaptiveLoopFilter::xCalcRDCost(TComPicYuv* pcPicOrg, TComPicYuv* pcPicCmp, ALFParam* pAlfParam, UInt64& ruiRate, UInt64& ruiDist, Double& rdCost, std::vector<AlfCUCtrlInfo>* pvAlfCUCtrlParam)
    4150 #endif
    4151 {
    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     else
    4176     {
    4177       ruiRate += m_uiNumSlicesInPic;
    4178     }
    4179   }
    4180   else
    4181   {
    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 ALF
    4189  * \param pcPicOrg original picture buffer
    4190  * \param pcPicCmp compared picture buffer
    4191  * \param pAlfParam ALF parameters
    4192  * \returns ruiRate bitrate
    4193  * \returns uiDist distortion
    4194  * \returns rdCost RD cost
    4195  */
    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:0
    4213 
    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     else
    4225     {
    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     else
    4240     {
    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 #endif
    4259 #if LCU_SYNTAX_ALF
    42603356/** Restore the not-filtered pixels
    42613357 * \param [in] imgDec picture buffer before filtering
     
    42643360 */
    42653361Void TEncAdaptiveLoopFilter::xCopyDecToRestCUs(Pel* imgDec, Pel* imgRest, Int stride)
    4266 #else
    4267 /** Restore the not-filtered pixels
    4268  * \param pcPicDec picture buffer before filtering
    4269  * \param pcPicRest picture buffer after filtering
    4270  */
    4271 Void TEncAdaptiveLoopFilter::xCopyDecToRestCUs(TComPicYuv* pcPicDec, TComPicYuv* pcPicRest)
    4272 #endif
    42733362{
    42743363
    42753364  if(m_uiNumSlicesInPic > 1)
    42763365  {
    4277 #if LCU_SYNTAX_ALF
    42783366    Pel* pPicDecLuma  = imgDec;
    42793367    Pel* pPicRestLuma = imgRest;
    4280 #else
    4281     Pel* pPicDecLuma  = pcPicDec->getLumaAddr();
    4282     Pel* pPicRestLuma = pcPicRest->getLumaAddr();
    4283     Int  stride       = pcPicDec->getStride();
    4284 #endif
    42853368    UInt SUWidth      = m_pcPic->getMinCUWidth();
    42863369    UInt SUHeight     = m_pcPic->getMinCUHeight();
     
    43353418  {
    43363419    TComDataCU* pcCU = m_pcPic->getCU( uiCUAddr );
    4337 #if LCU_SYNTAX_ALF
    43383420    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
    43463424Void TEncAdaptiveLoopFilter::xCopyDecToRestCU(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Pel* imgDec, Pel* imgRest, Int stride)
    4347 #else
    4348 Void TEncAdaptiveLoopFilter::xCopyDecToRestCU(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest)
    4349 #endif
    43503425{
    43513426  Bool bBoundary = false;
     
    43693444     
    43703445      if( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )     
    4371 #if LCU_SYNTAX_ALF
    43723446        xCopyDecToRestCU(pcCU, uiAbsPartIdx, uiDepth+1, imgDec, imgRest, stride);
    4373 #else
    4374         xCopyDecToRestCU(pcCU, uiAbsPartIdx, uiDepth+1, pcPicDec, pcPicRest);
    4375 #endif
    43763447    }
    43773448    return;
     
    43803451  if (!pcCU->getAlfCtrlFlag(uiAbsPartIdx))
    43813452  {
    4382 #if !LCU_SYNTAX_ALF
    4383     UInt uiCUAddr = pcCU->getAddr();
    4384 #endif   
    43853453    Int iWidth = pcCU->getWidth(uiAbsPartIdx);
    43863454    Int iHeight = pcCU->getHeight(uiAbsPartIdx);
    4387 #if LCU_SYNTAX_ALF
    43883455    copyPixelsInOneRegion(imgRest, imgDec, stride, (Int)uiTPelY, iHeight, (Int)uiLPelX, iWidth);
    4389 #else
    4390     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 #endif
    44063456  }
    44073457}
     
    44263476Void TEncAdaptiveLoopFilter::predictALFCoeffLumaEnc(ALFParam* pcAlfParam, Int **pfilterCoeffSym, Int filter_shape)
    44273477{
    4428 #if LCU_SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS
     3478#if LCUALF_QP_DEPENDENT_BITS
    44293479  Int alfPrecisionBit = getAlfPrecisionBit( m_alfQP );
    44303480#endif
     
    44423492    if((pcAlfParam->predMethod==0)|(ind==0))
    44433493    {
    4444 #if LCU_SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS
     3494#if LCUALF_QP_DEPENDENT_BITS
    44453495      coeffPred = ((1<<alfPrecisionBit)-sum) >> 2;
    44463496#else
     
    44653515    if((pcAlfParam->predMethod==0)|(ind==0))
    44663516    {
    4467 #if LCU_SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS
     3517#if LCUALF_QP_DEPENDENT_BITS
    44683518      coeffPred = (1<<alfPrecisionBit)-sum;
    44693519#else
     
    46003650    *pDepthInt=NULL, kMinTab[MAX_SCAN_VAL], bitsCoeffScan[MAX_SCAN_VAL][MAX_EXP_GOLOMB],
    46013651  minKStart, minBitsKStart, bitsKStart;
    4602 #if ALF_SINGLE_FILTER_SHAPE
    46033652  Int minScanVal = MIN_SCAN_POS_CROSS;
    4604 #else 
    4605   int minScanVal = (fl==ALF_STAR5x5) ? 0 : MIN_SCAN_POS_CROSS;
    4606 #endif
    46073653  pDepthInt = pDepthIntTabShapes[fl];
    46083654 
     
    46723718  // Coding parameters
    46733719  //  len += lengthFilterCodingParams(minKStart, maxScanVal, kMinTab, createBitstream);
    4674 #if LCU_SYNTAX_ALF
    46753720  if (filters_per_group == 1)
    46763721  {
     
    46803725  else
    46813726  {
    4682 #endif
    46833727  len += (3 + maxScanVal);
    46843728 
     
    46863730  len += lengthFilterCoeffs(sqrFiltLength, filters_per_group, pDepthInt, pDiffQFilterCoeffIntPP,
    46873731                            kMinTab, createBitstream);
    4688 #if LCU_SYNTAX_ALF
    4689   }
    4690 #endif
     3732  }
    46913733
    46923734  return len;
     
    47353777    {
    47363778      scanPos = pDepthInt[i] - 1;
    4737 #if LCU_SYNTAX_ALF
    47383779      Int k = (filters_per_group == 1) ? kMinTab[i] : kMinTab[scanPos];
    47393780      bit_cnt += lengthGolomb(abs(FilterCoeff[ind][i]), k);
    4740 #else
    4741       bit_cnt += lengthGolomb(abs(FilterCoeff[ind][i]), kMinTab[scanPos]);
    4742 #endif
    47433781    }
    47443782  }
     
    47463784}
    47473785
    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
    52723787Void 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 #else
    5274 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 #endif
    52763788{
    52773789  Int filters_per_fr, firstFilt, interval[NO_VAR_BINS][2], intervalBest[NO_VAR_BINS][2];
     
    53053817
    53063818    lagrangian=xfindBestCoeffCodMethod(filterCoeffSymQuant, filter_shape, sqrFiltLength, filters_per_fr, errorForce0CoeffTab, lambda_val);
    5307 #if LCU_SYNTAX_ALF
    53083819    if (lagrangian<lagrangianMin || firstFilt==1 || filters_per_fr == numMaxFilters)
    5309 #else
    5310     if (lagrangian<lagrangianMin || firstFilt==1 || filters_per_fr == m_iALFMaxNumberFilters)
    5311 #endif
    53123820    {
    53133821      firstFilt=0;
     
    53193827    filters_per_fr--;
    53203828  }
    5321 #if !ALF_16_BA_GROUPS
    5322   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 #endif
    53323829  findFilterCoeff(ESym, ySym, pixAcc, filterCoeffSym, filterCoeffSymQuant, intervalBest,
    53333830    varIndTab, sqrFiltLength, (*filters_per_fr_best), weights, errorForce0CoeffTab);
     
    54893986 * \param [in,out]vAlfCUCtrlParam ALF CU control parameters
    54903987 */
    5491 #if LCU_SYNTAX_ALF 
    54923988#if HHI_INTERVIEW_SKIP
    54933989Void TEncAdaptiveLoopFilter::setCUAlfCtrlFlags(UInt uiAlfCtrlDepth, Pel* imgOrg, Pel* imgDec, Pel* imgRest, Pel* imgUsed, Int stride, UInt64& ruiDist, std::vector<AlfCUCtrlInfo>& vAlfCUCtrlParam)
     
    54953991Void TEncAdaptiveLoopFilter::setCUAlfCtrlFlags(UInt uiAlfCtrlDepth, Pel* imgOrg, Pel* imgDec, Pel* imgRest, Int stride, UInt64& ruiDist, std::vector<AlfCUCtrlInfo>& vAlfCUCtrlParam)
    54963992#endif
    5497 #else
    5498 #if HHI_INTERVIEW_SKIP
    5499 Void TEncAdaptiveLoopFilter::xSetCUAlfCtrlFlags_qc(UInt uiAlfCtrlDepth, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, TComPicYuv* pUsedPelMap, UInt64& ruiDist, std::vector<AlfCUCtrlInfo>& vAlfCUCtrlParam)
    5500 #else
    5501 Void TEncAdaptiveLoopFilter::xSetCUAlfCtrlFlags_qc(UInt uiAlfCtrlDepth, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiDist, std::vector<AlfCUCtrlInfo>& vAlfCUCtrlParam)
    5502 #endif
    5503 #endif
    55043993{
    55053994  ruiDist = 0;
     
    55204009  {
    55214010    TComDataCU* pcCU = m_pcPic->getCU( CUAddr );
    5522 #if LCU_SYNTAX_ALF
    55234011#if HHI_INTERVIEW_SKIP
    55244012    setCUAlfCtrlFlag(pcCU, 0, 0, uiAlfCtrlDepth, imgOrg, imgDec, imgRest, imgUsed, stride, ruiDist, vAlfCUCtrlParam[0].alf_cu_flag);
    55254013#else
    55264014    setCUAlfCtrlFlag(pcCU, 0, 0, uiAlfCtrlDepth, imgOrg, imgDec, imgRest, stride, ruiDist, vAlfCUCtrlParam[0].alf_cu_flag);
    5527 #endif
    5528 #else
    5529 #if HHI_INTERVIEW_SKIP
    5530     xSetCUAlfCtrlFlag_qc(pcCU, 0, 0, uiAlfCtrlDepth, pcPicOrg, pcPicDec, pcPicRest,imgUsed, ruiDist, vAlfCUCtrlParam[0].alf_cu_flag);
    5531 #else
    5532     xSetCUAlfCtrlFlag_qc(pcCU, 0, 0, uiAlfCtrlDepth, pcPicOrg, pcPicDec, pcPicRest, ruiDist, vAlfCUCtrlParam[0].alf_cu_flag);
    5533 #endif
    55344015#endif
    55354016  }
     
    55694050}
    55704051
    5571 #if LCU_SYNTAX_ALF
    55724052#if HHI_INTERVIEW_SKIP
    55734053Void 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)
    55744054#else
    55754055Void 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 #endif
    5577 #else
    5578 #if HHI_INTERVIEW_SKIP
    5579 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 #else
    5581 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 #endif
    55834056#endif
    55844057{
     
    56034076     
    56044077      if( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
    5605 #if LCU_SYNTAX_ALF
    56064078#if HHI_INTERVIEW_SKIP
    56074079        setCUAlfCtrlFlag(pcCU, uiAbsPartIdx, uiDepth+1, uiAlfCtrlDepth, imgOrg, imgDec, imgRest, imgUsed, stride, ruiDist, vCUCtrlFlag);
     
    56094081        setCUAlfCtrlFlag(pcCU, uiAbsPartIdx, uiDepth+1, uiAlfCtrlDepth, imgOrg, imgDec, imgRest, stride, ruiDist, vCUCtrlFlag);
    56104082#endif
    5611 #else
    5612 #if HHI_INTERVIEW_SKIP
    5613         xSetCUAlfCtrlFlag_qc(pcCU, uiAbsPartIdx, uiDepth+1, uiAlfCtrlDepth, pcPicOrg, pcPicDec, pcPicRest, imgUsed, ruiDist, vCUCtrlFlag);
    5614 #else
    5615         xSetCUAlfCtrlFlag_qc(pcCU, uiAbsPartIdx, uiDepth+1, uiAlfCtrlDepth, pcPicOrg, pcPicDec, pcPicRest, ruiDist, vCUCtrlFlag);
    5616 #endif
    5617 #endif
    56184083    }
    56194084    return;
     
    56244089    return;
    56254090  }
    5626 #if !LCU_SYNTAX_ALF
    5627   UInt uiCUAddr = pcCU->getAddr();
    5628 #endif
    56294091  UInt64 uiRecSSD = 0;
    56304092  UInt64 uiFiltSSD = 0;
     
    56614123  }
    56624124 
    5663 #if LCU_SYNTAX_ALF
    56644125  Int  offset = uiTPelY*stride + uiLPelX;
    56654126  Pel* pOrg  = imgOrg  + offset;
     
    56794140  uiFiltSSD += xCalcSSD( pOrg, pFilt, iWidth, iHeight, stride );
    56804141#endif
    5681 #else
    5682   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_SKIP
    5687   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 #else
    5691   uiRecSSD  += xCalcSSD( pOrg, pRec,  iWidth, iHeight, pcPicOrg->getStride() );
    5692   uiFiltSSD += xCalcSSD( pOrg, pFilt, iWidth, iHeight, pcPicOrg->getStride() );
    5693 #endif
    5694 #endif
    56954142  if (uiFiltSSD < uiRecSSD)
    56964143  {
     
    56994146    vCUCtrlFlag.push_back(1);
    57004147
    5701 #if LCU_SYNTAX_ALF
    57024148    for (int i=uiTPelY ;i<=min(uiBPelY,(unsigned int)(m_img_height-1))  ;i++)
    57034149    {
    57044150      for (int j=uiLPelX ;j<=min(uiRPelX,(unsigned int)(m_img_width-1)) ;j++)
    57054151      {
    5706 #else
    5707     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 #endif
    57124152        m_maskImg[i][j]=1;
    57134153      }
     
    57194159    pcCU->setAlfCtrlFlagSubParts(0, uiAbsPartIdx, uiSetDepth);
    57204160    vCUCtrlFlag.push_back(0);
    5721 #if LCU_SYNTAX_ALF
    57224161    for (int i=uiTPelY ;i<=min(uiBPelY,(unsigned int)(m_img_height-1))  ;i++)
    57234162    {
    57244163      for (int j=uiLPelX ;j<=min(uiRPelX,(unsigned int)(m_img_width-1)) ;j++)
    57254164      {
    5726 #else
    5727     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 #endif
    57324165        m_maskImg[i][j]=0;
    57334166      }
     
    57364169}
    57374170
    5738 #if !LCU_SYNTAX_ALF
    5739 
    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 coefficients
    5790         xReDesignFilterCoeff_qc(pcPicOrg, pcPicDec, m_pcPicYuvTmp, true); //use filtering of mine
    5791       }
    5792      
    5793       UInt64 uiRate, uiDist;
    5794       Double dCost;
    5795      //m_pcPicYuvTmp: filtered signal, pcPicDec: orig reconst
    5796       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 maskImg
    5809         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 mine
    5833 
    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 pcPicRest
    5855     xCopyDecToRestCUs(pcPicDec, pcPicRest); //pcPicRest = pcPicDec
    5856   }
    5857   else
    5858   {
    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 #endif
    58714171
    58724172#define ROUND(a)  (((a) < 0)? (int)((a) - 0.5) : (int)((a) + 0.5))
     
    62424542{
    62434543  double error;
    6244 #if LCU_SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS
     4544#if LCUALF_QP_DEPENDENT_BITS
    62454545  Int factor = (1<<(getAlfPrecisionBit(m_alfQP)));
    62464546#else
     
    63844684}
    63854685
    6386 #if !LCU_SYNTAX_ALF
    6387 
    6388 /** Save redesigned filter set to buffer
    6389  * \param filterCoeffPrevSelected filter set buffer
    6390  */
    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 table
    6412       ::memcpy(m_mergeTableSavedMethods[mode][m_iGOPSize], mergeTable, sizeof(Int)*NO_VAR_BINS);
    6413       //store coefficients
    6414       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 shape
    6419       m_iPreviousFilterShapeMethods[mode][m_iGOPSize]= filtNo;
    6420 
    6421       pbFirstAccess[mode] = false;
    6422     }
    6423 
    6424 
    6425     //store merge table
    6426     ::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 coefficients
    6430     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 shape
    6441     m_iPreviousFilterShapeMethods[mode][0]= m_iPreviousFilterShapeMethods[mode][m_iGOPSize];
    6442     m_iPreviousFilterShapeMethods[mode][m_iGOPSize]= filtNo;
    6443   }
    6444   else
    6445   {
    6446 
    6447     //store merge table
    6448     ::memcpy(m_mergeTableSavedMethods[mode][iBufferIndex], mergeTable, sizeof(Int)*NO_VAR_BINS);
    6449 
    6450     //store coefficients
    6451     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_shape
    6456     m_iPreviousFilterShapeMethods[mode][iBufferIndex]= filtNo;
    6457 
    6458   }
    6459 }
    6460 
    6461 
    6462 /** set initial m_maskImg with previous (time-delayed) filters
    6463  * \param pcPicOrg original picture
    6464  * \param pcPicDec reconstructed picture after deblocking
    6465  */
    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 filters
    6494   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_SHAPE
    6505     assert(filtNo == ALF_CROSS9x7_SQUARE3x3);
    6506 #else
    6507     assert(filtNo == ALF_STAR5x5 || filtNo == ALF_CROSS9x9);
    6508 #endif
    6509     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     else
    6515     {
    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 reference
    6547   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   else
    6559   {
    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 parameters
    6576  * \param pcPic picture pointer
    6577  */
    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     else
    6589     {
    6590       m_iUsePreviousFilter = 1;
    6591     }
    6592   }
    6593   else
    6594   {
    6595     m_iALFNumOfRedesign = ALF_NUM_OF_REDESIGN;
    6596   }
    6597   m_iDesignCurrentFilter = 1;
    6598 
    6599 }
    6600 
    6601 /** set filter buffer index
    6602  * \param index the processing order of time-delayed filtering
    6603  */
    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   else
    6660   {
    6661     iBufIdx = (index == 0)?0:m_iGOPSize;
    6662   }
    6663 
    6664   return iBufIdx;
    6665 }
    6666 
    6667 
    6668 /** set initial m_maskImg
    6669  * \param pcPicOrg original picture pointer
    6670  * \param pcPicDec reconstructed picture pointer
    6671  */
    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   else
    6692   {
    6693     setMaskWithTimeDelayedResults(pcPicOrg, pcPicDec);
    6694   }
    6695 }
    6696 
    6697 
    6698 
    6699 /** Estimate RD cost of all filter size & store the best one
    6700  * \param ImgOrg original picture
    6701  * \param ImgDec reconstructed picture after deblocking
    6702  * \param Sride  line buffer size of picture buffer
    6703  * \param pcAlfSaved the best Alf parameters
    6704  * \returns ruiDist             estimated distortion
    6705  * \returns ruiRate             required bits
    6706  * \returns rdCost              estimated R-D cost
    6707  */
    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     else
    6748     {
    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 cost
    6754     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_SHAPE
    6807   // 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 #endif
    6841 
    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 #endif
    68534686
    68544687/** Estimate filtering distortion by correlation values and filter coefficients
     
    68674700  Int64  iDist;
    68684701  Double dDist, dsum;
    6869 #if LCU_SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS
     4702#if LCUALF_QP_DEPENDENT_BITS
    68704703  Int alfPrecisionBit = getAlfPrecisionBit( m_alfQP );
    68714704#endif
     
    68734706  for(i=0; i< iFiltLength; i++)
    68744707  {
    6875 #if LCU_SYNTAX_ALF && LCUALF_QP_DEPENDENT_BITS
     4708#if LCUALF_QP_DEPENDENT_BITS
    68764709    pdcoeff[i]= (Double)piCoeff[i] / (Double)(1<<alfPrecisionBit);
    68774710#else
     
    69084741
    69094742
    6910 #if !LCU_SYNTAX_ALF
    6911 
    6912 /** Estimate total filtering cost of all groups
    6913  * \param filters_per_fr number of filters for the slice
    6914  * \param VarIndTab merge index of all groups
    6915  * \param pppdE  auto-correlation matrix pointer for all groups
    6916  * \param ppdy cross-correlation array pointer for all groups
    6917  * \returns estimated distortion
    6918  */
    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_merged
    6933   for(f=0; f< filters_per_fr; f++)
    6934   {
    6935     for(j =0; j < iFiltLength; j++)
    6936     {
    6937       //clean m_E_merged one line
    6938       for(i=0; i < iFiltLength; i++)
    6939       {
    6940         m_E_merged[f][j][i] = 0;
    6941       }
    6942 
    6943       //clean m_y_merged
    6944       m_y_merged[f][j] = 0;
    6945     }
    6946     m_pixAcc_merged[f] = 0;
    6947   }
    6948 
    6949 
    6950   //merge correlation values
    6951   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 slices
    6989  * \param varmap grouping indices buffer
    6990  * \param imgY_Dec picture buffer
    6991  * \param pad_size (max. filter tap)/2
    6992  * \param fl  VAR_SIZE
    6993  * \param img_stride picture buffer stride
    6994  */
    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 slices
    7019  * \param ImgOrg original picture
    7020  * \param ImgDec picture before filtering
    7021  * \param tap  filter tap size
    7022  * \param iStride picture buffer stride
    7023  */
    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 region
    7057  * \param vpAlfLCU ALF LCU data container
    7058  * \param ImgOrg original picture
    7059  * \param ImgDec picture before filtering
    7060  * \param tap  filter tap size
    7061  * \param iStride picture buffer stride
    7062  * \param bFirstSlice  true for the first processing slice of the picture
    7063  * \param bLastSlice true for the last processing slice of the picture
    7064  */
    7065 Void   TEncAdaptiveLoopFilter::xstoreInBlockMatrixforRegion(std::vector< AlfLCUInfo* > &vpAlfLCU,
    7066                                                               Pel* ImgOrg, Pel* ImgDec,
    7067                                                               Int tap, Int iStride,
    7068                                                               Bool bFirstSlice,
    7069                                                               Bool bLastSlice
    7070                                                               )
    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 slices
    7105  * \param ComponentID Cb or Cr
    7106  * \param pOrg original picture
    7107  * \param pCmp picture before filtering
    7108  * \param iTap  filter tap size
    7109  * \param iOrgStride picture buffer stride for pOrg
    7110  * \param iCmpStride picture buffer stride for pCmp
    7111  */
    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 slice
    7149  * \param vpAlfLCU ALF LCU data container
    7150  * \param pOrg original picture
    7151  * \param pCmp picture before filtering
    7152  * \param iTap  filter tap size
    7153  * \param iStride picture buffer stride
    7154  * \param bLastSlice the last processing slice of picture
    7155  */
    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 functions
    7186 // ====================================================================================================================
    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_SHAPE
    7204   iShape = 0;
    7205 #else
    7206   for(iShape = 0; iShape < 2; iShape++)
    7207 #endif 
    7208   {
    7209     // set global variables
    7210     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 pointer
    7216     Double **ppdTmpCorr = m_ppdAlfCorr;
    7217 
    7218     // calc Cb matrix
    7219     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     else
    7232     {
    7233       xCalcCorrelationFuncforChromaSlices(ALF_Cb, pOrg, pCmp, iShape, pcPicOrg->getCStride(), pcPicDec->getCStride());
    7234     }
    7235 
    7236     // calc Cr matrix
    7237     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     else
    7250     {
    7251       xCalcCorrelationFuncforChromaSlices(ALF_Cr, pOrg, pCmp, iShape, pcPicOrg->getCStride(), pcPicDec->getCStride());
    7252     }
    7253 
    7254     // restore original corr pointer
    7255     m_ppdAlfCorr = ppdTmpCorr;
    7256 
    7257     // calc original dist
    7258     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 chroma
    7288   xFilteringFrameChroma(m_pcTempAlfParam, pcPicOrg, pcPicDec, pcPicRest);
    7289 
    7290   // filter on/off decision for chroma
    7291   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     else
    7324     {
    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   else
    7341   {
    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 >=0
    7381   {
    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   // retrive
    7398   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   // copy
    7420   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 coeff
    7435   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   else
    7468   {
    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 #endif
    74784743
    74794744//! \}
  • trunk/source/Lib/TLibEncoder/TEncAdaptiveLoopFilter.h

    r56 r296  
    4949//! \{
    5050
    51 #if LCU_SYNTAX_ALF
    5251#define LCUALF_FILTER_BUDGET_CONTROL_ENC        1 //!< filter budget control
    5352#define LCUALF_AVOID_USING_BOTTOM_LINES_ENCODER 1 //!< avoid using LCU bottom lines when lcu-based encoder RDO is used
    54 #endif
    5553
    5654// ====================================================================================================================
     
    5856// ====================================================================================================================
    5957
    60 #if LCU_SYNTAX_ALF
    6158/// correlation info
    6259struct AlfCorrData
     
    110107};
    111108
    112 #endif
    113109
    114110
     
    120116  /// variables for correlation calculation
    121117  ///
    122 #if !LCU_SYNTAX_ALF
    123   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 #endif
    131118  double **m_y_merged;
    132119  double ***m_E_merged;
     
    134121  double *m_y_temp;
    135122  double **m_E_temp;
    136 #if LCU_SYNTAX_ALF
    137123  static const Int  m_alfNumPartsInRowTab[5];
    138124  static const Int  m_alfNumPartsLevelTab[5];
     
    154140  Int    m_alfUsedFilterNum;
    155141#endif
    156 #endif
    157142
    158143  ///
    159144  /// ALF parameters
    160145  ///
    161 #if !LCU_SYNTAX_ALF
    162   ALFParam* m_pcBestAlfParam;
    163   ALFParam* m_pcTempAlfParam;
    164   ALFParam* pcAlfParamShape0;
    165   ALFParam* pcAlfParamShape1;
    166 #endif
    167146  ALFParam *m_tempALFp;
    168147
     
    172151  TComPicYuv* m_pcPicYuvBest;
    173152  TComPicYuv* m_pcPicYuvTmp;
    174 #if !LCU_SYNTAX_ALF
    175   TComPicYuv* pcPicYuvRecShape0;
    176   TComPicYuv* pcPicYuvRecShape1;
    177 #endif
    178153
    179154  ///
     
    186161  Int    **m_diffFilterCoeffQuant;
    187162  Int    **m_FilterCoeffQuantTemp;
    188 #if !LCU_SYNTAX_ALF
    189   Int**  m_mergeTableSavedMethods[NUM_ALF_CLASS_METHOD];
    190   Int*** m_aiFilterCoeffSavedMethods[NUM_ALF_CLASS_METHOD];  //!< time-delayed filter set buffer
    191   Int*   m_iPreviousFilterShapeMethods[NUM_ALF_CLASS_METHOD];
    192 #endif
    193163  ///
    194164  /// coding control parameters
     
    196166  Double m_dLambdaLuma;
    197167  Double m_dLambdaChroma;
    198 #if !LCU_SYNTAX_ALF
    199   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 reference
    201   Int  m_iGOPSize;                //!< GOP size
    202   Int  m_iCurrentPOC;             //!< POC
    203 #endif
    204168  Int  m_iALFEncodePassReduction; //!< 0: 16-pass encoding, 1: 1-pass encoding, 2: 2-pass encoding
    205169
     
    221185private:
    222186
    223 #if LCU_SYNTAX_ALF
    224187  Void disableComponentAlfParam(Int compIdx, AlfParamSet* alfParamSet, AlfUnitParam* alfUnitPic);
    225188  Void copyAlfParamSet(AlfParamSet* dst, AlfParamSet* src);
     
    252215  Void xCopyDecToRestCUs( Pel* imgDec, Pel* imgRest, Int stride );
    253216  Void xCopyDecToRestCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Pel* imgDec, Pel* imgRest, Int stride );
    254 #if ALF_SINGLE_FILTER_SHAPE
    255217  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                                       
    256218  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 #endif
    258219
    259220  //LCU-based mode decision
     
    291252  Void transferToAlfParamSet(Int compIdx, AlfUnitParam* alfUnitPic, AlfParamSet* & alfParamSet);
    292253  Int  calculateAlfParamSetRateRDO(Int compIdx, AlfParamSet* alfParamSet, std::vector<AlfCUCtrlInfo>* alfCUCtrlParam);
    293 #endif
    294 #if !LCU_SYNTAX_ALF
    295   // init / uninit internal variables
    296   Void xInitParam      ();
    297   Void xUninitParam    ();
    298 #endif
    299254  // ALF on/off control related functions
    300255  Void xCreateTmpAlfCtrlFlags   ();
     
    305260  Void xEncodeCUAlfCtrlFlags  (std::vector<AlfCUCtrlInfo> &vAlfCUCtrlParam);
    306261  Void xEncodeCUAlfCtrlFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth);
    307 #if !LCU_SYNTAX_ALF 
    308   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 computation
    313   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 luma
    314   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 slice
    315   Void xstoreInBlockMatrixforSlices  (Pel* ImgOrg, Pel* ImgDec, Int tap, Int iStride); //!< Calculate block autocorrelations and crosscorrelations for ALF slices
    316   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 chroma
    317   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 slice
    318   Void xCalcCorrelationFuncforChromaSlices  (Int ComponentID, Pel* pOrg, Pel* pCmp, Int iTap, Int iOrgStride, Int iCmpStride); //!< Calculate autocorrelations and crosscorrelations for chroma slices
    319 #endif
    320262  // functions related to filtering
    321263  Void xFilterCoefQuickSort   ( Double *coef_data, Int *coef_num, Int upper, Int lower );
    322264  Void xQuantFilterCoef       ( Double* h, Int* qh, Int tap, int bit_depth );
    323 #if !LCU_SYNTAX_ALF
    324   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 index
    329   Void setInitialMask(TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec); //!< set initial m_maskImg
    330   Void saveFilterCoeffToBuffer(Int **filterSet, Int numFilter, Int* mergeTable, Int mode, Int filtNo); //!< save filter coefficients to buffer
    331   Void setMaskWithTimeDelayedResults(TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec); //!< set initial m_maskImg with previous (time-delayed) filters
    332   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 one
    333   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 slices
    336   Void  setALFEncodingParam(TComPic *pcPic); //!< set ALF encoding parameters
    337   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 shape
    341 #endif
    342265  // distortion / misc functions
    343266#if HHI_INTERVIEW_SKIP
     
    346269  UInt64 xCalcSSD             ( Pel* pOrg, Pel* pCmp, Int iWidth, Int iHeight, Int iStride );
    347270#endif
    348 #if !LCU_SYNTAX_ALF
    349 #if HHI_INTERVIEW_SKIP
    350   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 #else
    354   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 #endif
    358 #endif
    359271  Int64 xFastFiltDistEstimation(Double** ppdE, Double* pdy, Int* piCoeff, Int iFiltLength); //!< Estimate filtering distortion by correlation values and filter coefficients
    360 #if !LCU_SYNTAX_ALF
    361   Int64 xEstimateFiltDist      (Int filters_per_fr, Int* VarIndTab, Double*** pppdE, Double** ppdy, Int** ppiCoeffSet, Int iFiltLength); //!< Estimate total filtering cost of all groups 
    362   UInt64 xCalcRateChroma               (ALFParam* pAlfParam);
    363   Void   xCalcALFCoeffChroma           (Int iChromaIdc, Int iShape, Int* piCoeff);
    364 #endif
    365272
    366273  /// code filter coefficients
    367274  UInt xcodeFiltCoeff(Int **filterCoeffSymQuant, Int filter_shape, Int varIndTab[], Int filters_per_fr_best, ALFParam* ALFp);
    368 #if LCU_SYNTAX_ALF
    369275  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 #else
    371   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 #endif
    373276  double xfindBestCoeffCodMethod(int **filterCoeffSymQuant, int filter_shape, int sqrFiltLength, int filters_per_fr, double errorForce0CoeffTab[NO_VAR_BINS][2], double lambda);
    374277  Int xsendAllFiltersPPPred(int **FilterCoeffQuant, int filter_shape, int sqrFiltLength, int filters_per_group, int createBistream, ALFParam* ALFp);
     
    400303  Void startALFEnc(TComPic* pcPic, TEncEntropy* pcEntropyCoder); //!< allocate temporal memory
    401304  Void endALFEnc(); //!< destroy temporal memory
    402 #if LCU_SYNTAX_ALF
    403305#if ALF_CHROMA_LAMBDA
    404306#if HHI_INTERVIEW_SKIP
     
    418320  Void resetPicAlfUnit();
    419321  Void setAlfCoefInSlice(Bool b) {m_alfCoefInSlice = b;}
    420 #else
    421 #if ALF_CHROMA_LAMBDA 
    422 #if HHI_INTERVIEW_SKIP
    423   Void ALFProcess(ALFParam* pcAlfParam, std::vector<AlfCUCtrlInfo>* pvAlfCtrlParam, Double dLambdaLuma, Double dLambdaChroma, UInt64& ruiDist, UInt64& ruiBits, Bool bInterviewSkip); //!< estimate ALF parameters
    424 #else
    425   Void ALFProcess(ALFParam* pcAlfParam, std::vector<AlfCUCtrlInfo>* pvAlfCtrlParam, Double dLambdaLuma, Double dLambdaChroma, UInt64& ruiDist, UInt64& ruiBits); //!< estimate ALF parameters
    426 #endif
    427 #else
    428 #if HHI_INTERVIEW_SKIP
    429   Void ALFProcess(ALFParam* pcAlfParam, std::vector<AlfCUCtrlInfo>* pvAlfCtrlParam, Double dLambda, UInt64& ruiDist, UInt64& ruiBits, Bool bInterviewSkip); //!< estimate ALF parameters
    430 #else
    431   Void ALFProcess(ALFParam* pcAlfParam, std::vector<AlfCUCtrlInfo>* pvAlfCtrlParam, Double dLambda, UInt64& ruiDist, UInt64& ruiBits); //!< estimate ALF parameters
    432 #endif
    433 #endif
    434 
    435   Void setGOPSize(Int val) { m_iGOPSize = val; } //!< set GOP size
    436 #endif
    437322  Void setALFEncodePassReduction (Int iVal) {m_iALFEncodePassReduction = iVal;} //!< set N-pass encoding. 0: 16(14)-pass encoding, 1: 1-pass encoding, 2: 2-pass encoding
    438323
    439324  Void setALFMaxNumberFilters    (Int iVal) {m_iALFMaxNumberFilters = iVal;} //!< set ALF Max Number of Filters
    440325
    441 #if LCU_SYNTAX_ALF
    442326  Void createAlfGlobalBuffers(); //!< create ALF global buffers
    443327  Void initPicQuadTreePartition(Bool isPicBasedEncode);
    444 #else
    445   Void createAlfGlobalBuffers(Int iALFEncodePassReduction); //!< create ALF global buffers
    446 #endif
    447328  Void destroyAlfGlobalBuffers(); //!< destroy ALF global buffers
    448329  Void PCMLFDisableProcess (TComPic* pcPic);
  • trunk/source/Lib/TLibEncoder/TEncBinCoder.h

    r56 r296  
    5656  virtual Void  finish            ()                                          = 0;
    5757  virtual Void  copyState         ( TEncBinIf* pcTEncBinIf )                  = 0;
    58 #if OL_FLUSH
    5958  virtual Void  flush            ()                                           = 0;
    60 #endif
    6159
    6260  virtual Void  encodeFlush     (Bool bEnd) = 0;
    6361
    6462  virtual Void  resetBac          ()                                          = 0;
    65 #if BURST_IPCM
    6663  virtual Void  encodeNumSubseqIPCM( Int numSubseqIPCM )                   = 0;
    67 #endif
    6864  virtual Void  encodePCMAlignBits()                                          = 0;
    6965  virtual Void  xWritePCMCode     ( UInt uiCode, UInt uiLength )              = 0;
  • trunk/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp

    r56 r296  
    105105}
    106106
    107 #if OL_FLUSH
    108107Void TEncBinCABAC::flush()
    109108{
     
    117116  start();
    118117}
    119 #endif
    120118
    121119/** Reset BAC register and counter values.
     
    127125}
    128126
    129 #if BURST_IPCM
    130127/** Encode # of subsequent IPCM blocks.
    131128 * \param numSubseqIPCM
     
    153150  }
    154151}
    155 #endif
    156152
    157153/** Encode PCM alignment zero bits.
     
    160156Void TEncBinCABAC::encodePCMAlignBits()
    161157{
    162 #if !BURST_IPCM
    163   finish();
    164   m_pcTComBitIf->write( 1, 1 ); // stop bit
    165 #endif
    166158  m_pcTComBitIf->writeAlignZero(); // pcm align zero
    167159}
  • trunk/source/Lib/TLibEncoder/TEncBinCoderCABAC.h

    r56 r296  
    5757  Void  finish            ();
    5858  Void  copyState         ( TEncBinIf* pcTEncBinIf );
    59 #if OL_FLUSH
    6059  Void  flush            ();
    61 #endif
    6260
    6361  Void  resetBac          ();
    64 #if BURST_IPCM
    6562  Void  encodeNumSubseqIPCM( Int numSubseqIPCM );
    66 #endif
    6763  Void  encodePCMAlignBits();
    6864  Void  xWritePCMCode     ( UInt uiCode, UInt uiLength );
  • trunk/source/Lib/TLibEncoder/TEncCavlc.cpp

    r210 r296  
    161161  //DF flag
    162162  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}
    173164Void TEncCavlc::codeAPSAlflag(UInt uiCode)
    174165{
    175166  WRITE_FLAG(uiCode, "aps_adaptive_loop_filter_flag");
    176167}
    177 #endif
    178168
    179169Void TEncCavlc::codeDFFlag(UInt uiCode, const Char *pSymbolName)
     
    186176}
    187177
    188 #if RPS_IN_SPS
    189178Void TEncCavlc::codeShortTermRefPicSet( TComSPS* pcSPS, TComReferencePictureSet* rps )
    190 #else
    191 Void TEncCavlc::codeShortTermRefPicSet( TComPPS* pcPPS, TComReferencePictureSet* rps )
    192 #endif
    193179{
    194180#if PRINT_RPS_INFO
     
    245231  xTracePPSHeader (pcPPS);
    246232#endif
    247 #if !RPS_IN_SPS
    248   TComRPSList* rpsList = pcPPS->getRPSList();
    249 #endif
    250233 
    251234  WRITE_UVLC( pcPPS->getPPSId(),                             "pic_parameter_set_id" );
    252235  WRITE_UVLC( pcPPS->getSPSId(),                             "seq_parameter_set_id" );
    253236
    254 #if MULTIBITS_DATA_HIDING
    255237  WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" );
    256238  if( pcPPS->getSignHideFlag() )
     
    258240    WRITE_CODE(pcPPS->getTSIG(), 4, "sign_hiding_threshold");
    259241  }
    260 #endif
    261242#if CABAC_INIT_FLAG
    262243  WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0,   "cabac_init_present_flag" );
    263 #endif
    264 #if !RPS_IN_SPS
    265   // RPS is put before entropy_coding_mode_flag
    266   // since entropy_coding_mode_flag will probably be removed from the WD
    267   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" );
    276244#endif
    277245  // entropy_coding_mode_flag
     
    280248  if (pcPPS->getEntropyCodingMode())
    281249  {
    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  }
    302251  //   num_ref_idx_l0_default_active_minus1
    303252  //   num_ref_idx_l1_default_active_minus1
     
    313262  WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0,  "weighted_pred_flag" );   // Use of Weighting Prediction (P_SLICE)
    314263  WRITE_CODE( pcPPS->getWPBiPredIdc(), 2, "weighted_bipred_idc" );  // Use of Weighting Bi-Prediction (B_SLICE)
    315 #if H0388
    316264  WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0,  "output_flag_present_flag" );
    317 #endif
    318 #if TILES_OR_ENTROPY_SYNC_IDC
    319265  if(pcPPS->getSPS()->getTilesOrEntropyCodingSyncIdc()==1)
    320266  {
    321 #endif
    322267    WRITE_FLAG( pcPPS->getColumnRowInfoPresent(),           "tile_info_present_flag" );
    323268    WRITE_FLAG( pcPPS->getTileBehaviorControlPresentFlag(),  "tile_control_present_flag");
     
    347292      if(iNumColTilesMinus1 !=0 || iNumRowTilesMinus1 !=0)
    348293      {
    349 #if !REMOVE_TILE_DEPENDENCE
    350         WRITE_FLAG( pcPPS->getTileBoundaryIndependenceIdr(),                         "tile_boundary_independence_flag" );
    351         if(pcPPS->getTileBoundaryIndependenceIdr() == 1)
    352         {
    353 #endif
    354294          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    }
    361297  }
    362298  else if(pcPPS->getSPS()->getTilesOrEntropyCodingSyncIdc()==2)
     
    364300    WRITE_UVLC( pcPPS->getNumSubstreams()-1,               "num_substreams_minus1" );
    365301  }
    366 #endif
    367 
    368 #if DBL_CONTROL
     302
    369303  WRITE_FLAG( pcPPS->getDeblockingFilterControlPresent()?1 : 0, "deblocking_filter_control_present_flag");
    370 #endif
    371 #if PARALLEL_MERGE
    372304  WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2");
    373 #endif
    374305  WRITE_FLAG( 0, "pps_extension_flag" );
    375306}
     
    498429      }
    499430    }
     431#if INTER_VIEW_VECTOR_SCALING_C0115
     432      WRITE_FLAG( pcVPS->getIVScalingFlag(),                      "inter_view_vector_scaling_flag" );
     433#endif
    500434  }
    501435 
     
    508442#endif
    509443#endif
    510 #if HHI_MPI
     444#if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068
    511445Void TEncCavlc::codeSPS( TComSPS* pcSPS, Bool bIsDepth )
    512446#else
     
    528462  WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (),   "pic_width_in_luma_samples" );
    529463  WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(),   "pic_height_in_luma_samples" );
    530 #if PIC_CROPPING
    531464  WRITE_FLAG( pcSPS->getPicCroppingFlag(),          "pic_cropping_flag" );
    532465  if (pcSPS->getPicCroppingFlag())
     
    537470    WRITE_UVLC( pcSPS->getPicCropBottomOffset(),    "pic_crop_bottom_offset" );
    538471  }
    539 #endif
    540472
    541473#if FULL_NBIT
     
    563495
    564496  WRITE_UVLC( pcSPS->getBitsForPOC()-4,                 "log2_max_pic_order_cnt_lsb_minus4" );
    565 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
    566497  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
    567498  {
     
    570501    WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i),           "max_latency_increase[i]" );
    571502  }
    572 #else
    573   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 #endif
    578503  assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() );
    579504 
     
    586511  }
    587512
    588 #if H0412_REF_PIC_LIST_RESTRICTION
    589513  WRITE_FLAG( pcSPS->getRestrictedRefPicListsFlag(),                                 "restricted_ref_pic_lists_flag" );
    590514  if( pcSPS->getRestrictedRefPicListsFlag() )
     
    592516    WRITE_FLAG( pcSPS->getListsModificationPresentFlag(),                            "lists_modification_present_flag" );
    593517  }
    594 #endif
    595518  WRITE_UVLC( log2MinCUSize - 3,                                                     "log2_min_coding_block_size_minus3" );
    596519  WRITE_UVLC( pcSPS->getMaxCUDepth()-g_uiAddCUDepth,                                 "log2_diff_max_min_coding_block_size" );
     
    618541  WRITE_FLAG( pcSPS->getUseSAO() ? 1 : 0,                                            "sample_adaptive_offset_enabled_flag");
    619542  WRITE_FLAG( pcSPS->getUseALF () ? 1 : 0,                                           "adaptive_loop_filter_enabled_flag");
    620 #if LCU_SYNTAX_ALF
    621543  if(pcSPS->getUseALF())
    622544  {
    623545    WRITE_FLAG( (pcSPS->getUseALFCoefInSlice()) ? 1 : 0,                             "alf_coef_in_slice_flag");
    624546  }
    625 #endif
    626547
    627548  if( pcSPS->getUsePCM() )
     
    634555  WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0,                             "temporal_id_nesting_flag" );
    635556
    636 #if RPS_IN_SPS
    637557  TComRPSList* rpsList = pcSPS->getRPSList();
    638558  TComReferencePictureSet*      rps;
     
    645565  }   
    646566  WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0,         "long_term_ref_pics_present_flag" );
    647 #endif
    648 #if !PIC_CROPPING
    649   //!!!KS: Syntax not in WD !!!
    650  
    651   xWriteUvlc  ( pcSPS->getPad (0) );
    652   xWriteUvlc  ( pcSPS->getPad (1) );
    653 #endif
    654567  // AMVP mode for each depth
    655568  for (Int i = 0; i < pcSPS->getMaxCUDepth(); i++)
     
    658571  }
    659572
    660 #if TILES_WPP_ENTRY_POINT_SIGNALLING
    661573  Int tilesOrEntropyCodingSyncIdc = 0;
    662574  if ( pcSPS->getNumColumnsMinus1() > 0 || pcSPS->getNumRowsMinus1() > 0)
     
    670582  pcSPS->setTilesOrEntropyCodingSyncIdc( tilesOrEntropyCodingSyncIdc );
    671583  WRITE_CODE(tilesOrEntropyCodingSyncIdc, 2, "tiles_or_entropy_coding_sync_idc");
    672 #endif
    673 
    674 #if TILES_OR_ENTROPY_SYNC_IDC
     584
    675585  if(tilesOrEntropyCodingSyncIdc == 1)
    676586  {
    677 #endif
    678587    WRITE_UVLC( pcSPS->getNumColumnsMinus1(),                           "num_tile_columns_minus1" );
    679588    WRITE_UVLC( pcSPS->getNumRowsMinus1(),                              "num_tile_rows_minus1" );
     
    694603    if( pcSPS->getNumColumnsMinus1() !=0 || pcSPS->getNumRowsMinus1() != 0)
    695604    {
    696 #if !REMOVE_TILE_DEPENDENCE
    697       WRITE_FLAG( pcSPS->getTileBoundaryIndependenceIdr(),                "tile_boundary_independence_flag" );
    698       if(pcSPS->getTileBoundaryIndependenceIdr() == 1)
    699       {
    700 #endif
    701605        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  }
    709608  WRITE_FLAG( 1, "sps_extension_flag" );
    710609#if !QC_MVHEVC_B0046
     
    792691          WRITE_SVLC( pcSPS->getPdmOffset       ()[ uiId ], "Pdm_offset" );
    793692        }
    794 #if HHI_INTER_VIEW_MOTION_PRED
     693#if H3D_IVMP
    795694        WRITE_UVLC( pcSPS->getMultiviewMvPredMode(), "multi_view_mv_pred_mode" );
    796695#endif
    797 #if HHI_INTER_VIEW_RESIDUAL_PRED
     696#if H3D_IVRP
    798697        WRITE_FLAG  ( pcSPS->getMultiviewResPredMode(), "multi_view_residual_pred_mode" );
    799698#endif
     
    866765  if (address==0)
    867766  {
    868     if( pcSlice->getSPS()->getViewId() && !pcSlice->getIsDepth() )
     767    if( pcSlice->getSPS()->getViewId()
     768#if !LGE_ILLUCOMP_DEPTH_C0046
     769        && !pcSlice->getIsDepth()
     770#endif
     771        )
    869772    {
    870773      WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "applying IC flag" );
     
    889792    WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "pic_parameter_set_id" );
    890793#endif
    891 #if H0388
    892794    if( pcSlice->getPPS()->getOutputFlagPresentFlag() )
    893795    {
    894796      WRITE_FLAG( pcSlice->getPicOutputFlag() ? 1 : 0, "pic_output_flag" );
    895797    }
    896 #endif
    897798#if QC_REM_IDV_B0046
    898799    if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR && pcSlice->getViewId() == 0)
     
    917818        {
    918819          WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag");
    919 #if RPS_IN_SPS
    920820          codeShortTermRefPicSet(pcSlice->getSPS(), rps);
    921 #else
    922           codeShortTermRefPicSet(pcSlice->getPPS(), rps);
    923 #endif
    924821        }
    925822        else
     
    928825          WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" );
    929826        }
    930 #if RPS_IN_SPS
    931827        if(pcSlice->getSPS()->getLongTermRefsPresent())
    932 #else
    933         if(pcSlice->getPPS()->getLongTermRefsPresent())
    934 #endif
    935828        {
    936829          WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics");
    937830          Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC();
    938831          Int prev = 0;
    939 #if LTRP_MULT
    940832          Int prevDeltaPocLt=0;
    941833          Int currDeltaPocLt=0;
    942 #endif
    943834          for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--)
    944835          {
    945836            WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt");
    946837         
    947 #if LTRP_MULT
    948838            currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt;
    949839
     
    976866            }
    977867            prevDeltaPocLt=currDeltaPocLt;
    978 #endif
    979868            prev = rps->getDeltaPOC(i);
    980869            WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag");
     
    988877        {
    989878          WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag");
    990 #if RPS_IN_SPS
    991879          codeShortTermRefPicSet(pcSlice->getSPS(), rps);
    992 #else
    993           codeShortTermRefPicSet(pcSlice->getPPS(), rps);
    994 #endif
    995880        }
    996881        else
     
    999884          WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" );
    1000885        }
    1001 #if RPS_IN_SPS
    1002886        if(pcSlice->getSPS()->getLongTermRefsPresent())
    1003 #else
    1004         if(pcSlice->getPPS()->getLongTermRefsPresent())
    1005 #endif
    1006887        {
    1007888          WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics");
    1008889          Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC();
    1009890          Int prev = 0;
    1010 #if LTRP_MULT
    1011891          Int prevDeltaPocLt=0;
    1012892          Int currDeltaPocLt=0;
    1013 #endif
    1014893          for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--)
    1015894          {
    1016895            WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt");
    1017896         
    1018 #if LTRP_MULT
    1019897            currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt;
    1020898
     
    1047925            }
    1048926            prevDeltaPocLt=currDeltaPocLt;
    1049 #endif
    1050927            prev = rps->getDeltaPOC(i);
    1051928            WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag");
     
    1059936      if (pcSlice->getSPS()->getUseALF())
    1060937      {
    1061 #if !LCU_SYNTAX_ALF
    1062          if (pcSlice->getAlfEnabledFlag())
    1063          {
    1064            assert (pcSlice->getAPS()->getAlfEnabled());
    1065          }
    1066 #endif
    1067938         WRITE_FLAG( pcSlice->getAlfEnabledFlag(), "ALF on/off flag in slice header" );
    1068939      }
    1069940      if (pcSlice->getSPS()->getUseSAO())
    1070941      {
    1071 #if SAO_UNIT_INTERLEAVING
    1072942        WRITE_FLAG( pcSlice->getSaoInterleavingFlag(), "SAO interleaving flag" );
    1073 #endif
    1074943         assert (pcSlice->getSaoEnabledFlag() == pcSlice->getAPS()->getSaoEnabled());
    1075944         WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "SAO on/off flag in slice header" );
    1076 #if SAO_UNIT_INTERLEAVING
    1077945         if (pcSlice->getSaoInterleavingFlag()&&pcSlice->getSaoEnabledFlag() )
    1078946         {
     
    1080948           WRITE_FLAG( pcSlice->getAPS()->getSaoParam()->bSaoFlag[2], "SAO on/off flag for Cr in slice header" );
    1081949         }
    1082 #endif
    1083950      }
    1084951      WRITE_UVLC( pcSlice->getAPS()->getAPSID(), "aps_id");
     
    1103970      pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
    1104971    }
    1105 #if H0412_REF_PIC_LIST_RESTRICTION
    1106972    if( pcSlice->getSPS()->getListsModificationPresentFlag() )
    1107973    {
    1108 #endif
    1109974    TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
    1110 #if H0137_0138_LIST_MODIFICATION
    1111975    if( !pcSlice->isIntra() )
    1112976    {
     
    11511015      }
    11521016    }
    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  }
    11811019  // ref_pic_list_combination( )
    11821020  // maybe move to own function?
     
    11881026      WRITE_UVLC( pcSlice->getNumRefIdx(REF_PIC_LIST_C) - 1,          "num_ref_idx lc_active_minus1");
    11891027     
    1190 #if H0412_REF_PIC_LIST_RESTRICTION
    11911028      if( pcSlice->getSPS()->getListsModificationPresentFlag() )
    11921029      {
    1193 #endif
    11941030        WRITE_FLAG( pcSlice->getRefPicListModificationFlagLC() ? 1 : 0, "ref_pic_list_modification_flag_lc" );
    11951031        if(pcSlice->getRefPicListModificationFlagLC())
     
    11981034          {
    11991035            WRITE_FLAG( pcSlice->getListIdFromIdxOfLC(i),               "pic_from_list_0_flag" );
    1200 #if H0137_0138_LIST_MODIFICATION
    12011036          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 ) )
    12021037          {
    12031038            WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i),               "ref_idx_list_curr" );
    12041039          }
    1205 #else
    1206             WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i),               "ref_idx_list_curr" );
    1207 #endif
    12081040          }
    12091041        }
    1210 #if H0412_REF_PIC_LIST_RESTRICTION
    1211       }
    1212 #endif
     1042      }
    12131043    }
    12141044  }
    12151045   
    1216 #if H0111_MVD_L1_ZERO
    12171046  if (pcSlice->isInterB())
    12181047  {
    12191048    WRITE_FLAG( pcSlice->getMvdL1ZeroFlag() ? 1 : 0,   "mvd_l1_zero_flag");
    12201049  }
    1221 #endif
    12221050
    12231051  if(pcSlice->getPPS()->getEntropyCodingMode() && !pcSlice->isIntra())
     
    12421070    Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 );
    12431071    WRITE_SVLC( iCode, "slice_qp_delta" );
    1244 #if DBL_CONTROL
    12451072    if (pcSlice->getPPS()->getDeblockingFilterControlPresent())
    12461073    {
     
    12491076        WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag");
    12501077      }
    1251 #else
    1252     WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag");
    1253 #endif
    12541078      if (!pcSlice->getInheritDblParamFromAPS())
    12551079      {
     
    12611085        }
    12621086      }
    1263 #if DBL_CONTROL
    1264     }
    1265 #endif
     1087    }
    12661088    if ( pcSlice->getSliceType() == B_SLICE )
    12671089    {
     
    12991121  }
    13001122 
    1301 #if ( HHI_MPI || HHI_INTER_VIEW_MOTION_PRED )
    1302   #if ( HHI_MPI && HHI_INTER_VIEW_MOTION_PRED )
     1123#if ( HHI_MPI || H3D_IVMP )
     1124  #if ( HHI_MPI && H3D_IVMP )
    13031125  const int iExtraMergeCandidates = ( pcSlice->getSPS()->getUseMVI() || pcSlice->getSPS()->getMultiviewMvPredMode() ) ? 1 : 0;
    13041126  #elif HHI_MPI
    13051127  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;
    13061130  #else
    13071131  const int iExtraMergeCandidates = pcSlice->getSPS()->getMultiviewMvPredMode() ? 1 : 0;
     
    13321156 \param pcSlice Where we find the substream size information.
    13331157 */
    1334 #if TILES_WPP_ENTRY_POINT_SIGNALLING
    13351158Void  TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice )
    13361159{
     
    14321255  delete [] entryPointOffset;
    14331256}
    1434 #else
    1435 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 header
    1446     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     else
    1467     {
    1468       printf("Error in codeSliceHeaderTable\n");
    1469       exit(-1);
    1470     }
    1471   }
    1472 }
    1473 #endif
    14741257
    14751258Void TEncCavlc::codeTerminatingBit      ( UInt uilsLast )
     
    14811264}
    14821265
    1483 #if HHI_INTER_VIEW_MOTION_PRED
     1266#if H3D_IVMP
    14841267Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum )
    14851268#else
     
    15101293}
    15111294
    1512 #if HHI_INTER_VIEW_RESIDUAL_PRED
     1295#if H3D_IVRP
    15131296Void
    15141297TEncCavlc::codeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
     
    15901373}
    15911374
    1592 #if BURST_IPCM
    15931375/** Code I_PCM information.
    15941376 * \param pcCU pointer to CU
     
    16021384  assert(0);
    16031385}
    1604 #else
    1605 /** Code I_PCM information.
    1606  * \param pcCU pointer to CU
    1607  * \param uiAbsPartIdx CU index
    1608  * \returns Void
    1609  *
    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 #endif
    16821386
    16831387Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx )
     
    17101414  Int iDQp  = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx );
    17111415
    1712 #if H0736_AVC_STYLE_QP_RANGE
    17131416  Int qpBdOffsetY =  pcCU->getSlice()->getSPS()->getQpBDOffsetY();
    17141417  iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2);
    1715 #endif
    17161418
    17171419  xWriteSvlc( iDQp );
     
    17441446  xWriteSvlc( iCode );
    17451447}
    1746 #if LCU_SYNTAX_ALF
    17471448/** Code the fixed length code (smaller than one max value) in OSALF
    17481449 * \param idx:  coded value
     
    17691470  }
    17701471}
    1771 #endif
    17721472
    17731473Void TEncCavlc::codeSaoFlag( UInt uiCode )
     
    17851485    xWriteSvlc( iCode );
    17861486}
    1787 #if SAO_UNIT_INTERLEAVING
    17881487/** Code SAO run.
    17891488 * \param uiCode
     
    18091508  WRITE_CODE( uiCode, uiLength, "sao_run_diff");
    18101509}
    1811 #endif
    18121510
    18131511Void TEncCavlc::estBit( estBitsSbacStruct* pcEstBitsCabac, Int width, Int height, TextType eTType )
     
    21141812Void TEncCavlc::xCodeScalingList(TComScalingList* scalingList, UInt sizeId, UInt listId)
    21151813{
    2116 #if SCALING_LIST
    21171814  Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]);
    21181815  UInt* scan    = g_auiFrameScanXY [ (sizeId == 0)? 1 : 2];
    2119 #else
    2120   Int coefNum = (Int)g_scalingListSize[sizeId];
    2121   UInt* scan    = g_auiFrameScanXY [ sizeId + 1];
    2122 #endif
    21231816  Int nextCoef = SCALING_LIST_START_VALUE;
    21241817  Int data;
    21251818  Int *src = scalingList->getScalingListAddress(sizeId, listId);
    2126 #if SCALING_LIST
    21271819  if(sizeId > SCALING_LIST_8x8 && scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId))
    21281820  {
     
    21551847    }
    21561848  }
    2157 #else
    2158   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 #endif
    21741849}
    21751850Bool TComScalingList::checkPredMode(UInt sizeId, UInt listId)
     
    21771852  for(Int predListIdx = (Int)listId -1 ; predListIdx >= 0; predListIdx--)
    21781853  {
    2179 #if SCALING_LIST
    21801854    if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix
    21811855     && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value
    2182 #else
    2183     if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*(Int)g_scalingListSize[sizeId])) // check value of matrix
    2184 #endif
    21851856    {
    21861857      setRefMatrixId(sizeId, listId, predListIdx);
  • trunk/source/Lib/TLibEncoder/TEncCavlc.h

    r210 r296  
    8888  Void  xWriteUnaryMaxSymbol  ( UInt uiSymbol, UInt uiMaxSymbol );
    8989
    90 #if RPS_IN_SPS
    9190  Void codeShortTermRefPicSet              ( TComSPS* pcSPS, TComReferencePictureSet* pcRPS );
    92 #else
    93   Void codeShortTermRefPicSet              ( TComPPS* pcPPS, TComReferencePictureSet* pcRPS );
    94 #endif
    9591 
    9692  UInt  xConvertToUInt        ( Int iValue ) {  return ( iValue <= 0) ? -iValue<<1 : (iValue<<1)-1; }
     
    118114#endif
    119115
    120 #if HHI_MPI
     116#if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068
    121117  Void  codeSPS                 ( TComSPS* pcSPS, Bool bIsDepth );
    122118#else
     
    129125  Void codeTileMarkerFlag(TComSlice* pcSlice);
    130126
    131 #if TILES_WPP_ENTRY_POINT_SIGNALLING
    132127  Void  codeTilesWPPEntryPoint( TComSlice* pSlice );
    133 #else
    134   Void  codeSliceHeaderSubstreamTable( TComSlice* pcSlice );
    135 #endif
    136128  Void  codeTerminatingBit      ( UInt uilsLast );
    137129  Void  codeSliceFinish         ();
     
    139131  Void  encodeStart             () {}
    140132 
    141 #if HHI_INTER_VIEW_MOTION_PRED
     133#if H3D_IVMP
    142134  Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum );
    143135#else
     
    148140  Void codeAlfSvlc       ( Int   iCode );
    149141  Void codeAlfCtrlDepth();
    150 #if LCU_SYNTAX_ALF
    151142  Void codeAPSAlflag(UInt uiCode);
    152143  Void codeAlfFixedLengthIdx( UInt idx, UInt numFilterSetsInBuffer);
    153 #endif
    154144  Void codeSaoFlag       ( UInt uiCode );
    155145  Void codeSaoUvlc       ( UInt uiCode );
    156146  Void codeSaoSvlc       ( Int   iCode );
    157 #if SAO_UNIT_INTERLEAVING
    158147  Void codeSaoRun        ( UInt uiCode, UInt maxValue  );
    159148  Void codeSaoMergeLeft  ( UInt uiCode, UInt compIdx ){;}
     
    161150  Void codeSaoTypeIdx    ( UInt uiCode ){ xWriteUvlc(uiCode   );}
    162151  Void codeSaoUflc       ( UInt uiCode ){ assert(uiCode < 32); xWriteCode(uiCode, 5);}
    163 #endif
    164152
    165153  Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
     
    169157  Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    170158  Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    171 #if HHI_INTER_VIEW_RESIDUAL_PRED
     159#if H3D_IVRP
    172160  Void codeResPredFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    173161#endif
     
    189177  Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    190178 
    191 #if BURST_IPCM
    192179  Void codeIPCMInfo      ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag);
    193 #else
    194   Void codeIPCMInfo      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    195 #endif
    196180
    197181  Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx );
  • trunk/source/Lib/TLibEncoder/TEncCfg.h

    r210 r296  
    109109  Int       m_iSourceWidth;
    110110  Int       m_iSourceHeight;
    111 #if PIC_CROPPING
    112111  Int       m_croppingMode;
    113112  Int       m_cropLeft;
     
    115114  Int       m_cropTop;
    116115  Int       m_cropBottom;
    117 #endif
    118116  Int       m_iFrameToBeEncoded;
    119117  Double    m_adLambdaModifier[ MAX_TLAYER ];
     
    125123  GOPEntryMvc m_GOPList[MAX_GOP+1];
    126124  Int       m_extraRPSs;
    127 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
    128125  Int       m_maxDecPicBuffering[MAX_TLAYER];
    129126  Int       m_numReorderPics[MAX_TLAYER];
    130 #else
    131   Int       m_maxNumberOfReferencePictures;
    132   Int       m_numReorderFrames;
    133 #endif
    134127 
    135128  Int       m_iQP;                              //  if (AdaptiveQP == OFF)
     
    142135                                                 // TODO: We need to have a common sliding mechanism used by both the encoder and decoder
    143136
    144 #if H0566_TLA
    145137  Int       m_maxTempLayer;                      ///< Max temporal layer
    146 #else
    147   Bool      m_bTLayering;                        ///< indicates whether temporal IDs are set based on the hierarchical coding structure
    148   Bool      m_abTLayerSwitchingFlag[MAX_TLAYER]; ///< temporal layer switching flags corresponding to temporal layer
    149 #endif
    150138  Bool      m_bDisInter4x4;
    151139  Bool m_useAMP;
     
    163151  Int       m_loopFilterBetaOffsetDiv2;
    164152  Int       m_loopFilterTcOffsetDiv2;
    165 #if DBL_CONTROL
    166153  Bool      m_DeblockingFilterControlPresent;
    167 #endif
    168154  Bool      m_bUseSAO;
    169155#if LGE_ILLUCOMP_B0045
    170156  Bool      m_bUseIC;
    171157#endif
    172 #if SAO_UNIT_INTERLEAVING
     158#if INTER_VIEW_VECTOR_SCALING_C0115
     159  Bool      m_bUseIVS;
     160#endif
    173161  Int       m_maxNumOffsetsPerPic;
    174162  Bool      m_saoInterleavingFlag;
    175 #endif
    176163
    177164  //====== Lossless ========
     
    229216
    230217  Int       m_iALFMaxNumberFilters;
    231 #if LCU_SYNTAX_ALF
    232218  Bool      m_bALFParamInSlice;
    233219  Bool      m_bALFPicBasedEncode;
    234 #endif
    235220
    236221  Bool      m_bUseASR;
     
    239224  Bool      m_bLCMod;
    240225  Bool      m_bUseRDOQ;
    241 #if !PIC_CROPPING
    242   Bool      m_bUsePAD;
    243 #endif
    244226  Bool      m_bUseFastEnc;
    245227  Bool      m_bUseEarlyCU;
    246228
    247 #if FAST_DECISION_FOR_MRG_RD_COST
    248229  Bool      m_useFastDecisionForMerge;
    249 #endif
    250230  Bool      m_bUseCbfFastMode;
    251231  Bool      m_bUseLMChroma;
     
    305285
    306286  Bool      m_bEnableTMVP;
    307 #if MULTIBITS_DATA_HIDING
    308287  Int       m_signHideFlag;
    309288  Int       m_signHidingThreshold;
    310 #endif
    311289
    312290#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
     
    349327#endif
    350328
    351 #if HHI_INTER_VIEW_MOTION_PRED
     329#if H3D_IVMP
    352330  UInt        m_uiMultiviewMvPredMode;
    353331  UInt        m_uiMultiviewMvRegMode;
    354332  Double      m_dMultiviewMvRegLambdaScale;
    355333#endif
    356 #if HHI_INTER_VIEW_RESIDUAL_PRED
     334#if H3D_IVRP
    357335  UInt        m_uiMultiviewResPredMode;
    358336#endif
     
    383361  Void      setSourceWidth                  ( Int   i )      { m_iSourceWidth = i; }
    384362  Void      setSourceHeight                 ( Int   i )      { m_iSourceHeight = i; }
    385 #if PIC_CROPPING
    386363  Void      setCroppingMode                 ( Int   i )      { m_croppingMode = i; }
    387364  Void      setCropLeft                     ( Int   i )      { m_cropLeft = i; }
     
    389366  Void      setCropTop                      ( Int   i )      { m_cropTop = i; }
    390367  Void      setCropBottom                   ( Int   i )      { m_cropBottom = i; }
    391 #endif
    392368  Void      setFrameToBeEncoded             ( Int   i )      { m_iFrameToBeEncoded = i; }
    393369 
     
    399375  Void      setExtraRPSs                    ( Int   i )      { m_extraRPSs = i; }
    400376  GOPEntryMvc getGOPEntry                   ( Int   i )      { return m_GOPList[i]; }
    401 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
    402377  Void      setMaxDecPicBuffering           ( UInt u, UInt tlayer ) { m_maxDecPicBuffering[tlayer] = u;    }
    403378  Void      setNumReorderPics               ( Int  i, UInt tlayer ) { m_numReorderPics[tlayer] = i;    }
    404 #else
    405   Void      setMaxNumberOfReferencePictures ( Int u )       { m_maxNumberOfReferencePictures = u;    }
    406   Void      setNumReorderFrames             ( Int  i )       { m_numReorderFrames = i;    }
    407 #endif
    408379 
    409380#if HHI_INTERVIEW_SKIP
     
    423394  Void      setMaxRefPicNum                 ( Int iMaxRefPicNum )           { m_iMaxRefPicNum = iMaxRefPicNum;  }
    424395
    425 #if H0566_TLA
    426396  Bool      getMaxTempLayer                 ()                              { return m_maxTempLayer;              }
    427397  Void      setMaxTempLayer                 ( Int maxTempLayer )            { m_maxTempLayer = maxTempLayer;      }
    428 #else
    429   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 #endif
    434398
    435399  Bool      getDisInter4x4                  ()              { return m_bDisInter4x4;        }
     
    444408#endif
    445409
    446 #if HHI_INTER_VIEW_MOTION_PRED
     410#if H3D_IVMP
    447411  Void      setMultiviewMvPredMode          ( UInt  u )      { m_uiMultiviewMvPredMode      = u; }
    448412  Void      setMultiviewMvRegMode           ( UInt  u )      { m_uiMultiviewMvRegMode       = u; }
    449413  Void      setMultiviewMvRegLambdaScale    ( Double d)      { m_dMultiviewMvRegLambdaScale = d; }
    450414#endif
    451 #if HHI_INTER_VIEW_RESIDUAL_PRED
     415#if H3D_IVRP
    452416  Void      setMultiviewResPredMode         ( UInt  u )      { m_uiMultiviewResPredMode     = u; }
    453417#endif
     
    467431  Void      setLoopFilterBetaOffset         ( Int   i )      { m_loopFilterBetaOffsetDiv2  = i; }
    468432  Void      setLoopFilterTcOffset           ( Int   i )      { m_loopFilterTcOffsetDiv2    = i; }
    469 #if DBL_CONTROL
    470433  Void      setDeblockingFilterControlPresent ( Bool b ) { m_DeblockingFilterControlPresent = b; }
    471 #endif
    472434
    473435  //====== Motion search ========
     
    479441  Void      setVerticalDisparitySearchRange ( Int   i )      { m_iVerticalDisparitySearchRange = i; }
    480442#endif
    481 #if HHI_INTER_VIEW_MOTION_PRED
     443#if H3D_IVMP
    482444  UInt      getMultiviewMvRegMode           ()      { return  m_uiMultiviewMvRegMode; }
    483445  Double    getMultiviewMvRegLambdaScale    ()      { return  m_dMultiviewMvRegLambdaScale; }
     
    524486  Int       getSourceWidth                  ()      { return  m_iSourceWidth; }
    525487  Int       getSourceHeight                 ()      { return  m_iSourceHeight; }
    526 #if PIC_CROPPING
    527488  Int       getCroppingMode                 ()      { return  m_croppingMode; }
    528489  Int       getCropLeft                     ()      { return  m_cropLeft; }
     
    530491  Int       getCropTop                      ()      { return  m_cropTop; }
    531492  Int       getCropBottom                   ()      { return  m_cropBottom; }
    532 #endif
    533493  Int       getFrameToBeEncoded             ()      { return  m_iFrameToBeEncoded; }
    534494  void setLambdaModifier                    ( UInt uiIndex, Double dValue ) { m_adLambdaModifier[ uiIndex ] = dValue; }
     
    539499  UInt      getDecodingRefreshType          ()      { return  m_uiDecodingRefreshType; }
    540500  Int       getGOPSize                      ()      { return  m_iGOPSize; }
    541 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
    542501  Int       getMaxDecPicBuffering           (UInt tlayer) { return m_maxDecPicBuffering[tlayer]; }
    543502  Int       getNumReorderPics               (UInt tlayer) { return m_numReorderPics[tlayer]; }
    544 #else
    545   Int      getMaxNumberOfReferencePictures ()      { return m_maxNumberOfReferencePictures; }
    546   Int       geNumReorderFrames              ()      { return m_numReorderFrames; }
    547 #endif
    548503  Int       getQP                           ()      { return  m_iQP; }
    549504 
     
    562517  Int       getLoopFilterBetaOffset         ()      { return m_loopFilterBetaOffsetDiv2; }
    563518  Int       getLoopFilterTcOffset           ()      { return m_loopFilterTcOffsetDiv2; }
    564 #if DBL_CONTROL
    565519  Bool      getDeblockingFilterControlPresent()  { return  m_DeblockingFilterControlPresent; }
    566 #endif
    567520
    568521  //==== Motion search ========
     
    607560  Void      setLCMod                        ( Bool  b )     { m_bLCMod   = b;    }
    608561  Void      setUseRDOQ                      ( Bool  b )     { m_bUseRDOQ    = b; }
    609 #if !PIC_CROPPING
    610   Void      setUsePAD                       ( Bool  b )     { m_bUsePAD     = b; }
    611 #endif
    612562#if HHI_VSO
    613563  Void      setUseVSO                       ( Bool  b )     { m_bUseVSO     = b; }
     
    621571  Void      setUseFastEnc                   ( Bool  b )     { m_bUseFastEnc = b; }
    622572  Void      setUseEarlyCU                   ( Bool  b )     { m_bUseEarlyCU = b; }
    623 #if FAST_DECISION_FOR_MRG_RD_COST
    624573  Void      setUseFastDecisionForMerge      ( Bool  b )     { m_useFastDecisionForMerge = b; }
    625 #endif
    626574  Void      setUseCbfFastMode            ( Bool  b )     { m_bUseCbfFastMode = b; }
    627575  Void      setUseConstrainedIntraPred      ( Bool  b )     { m_bUseConstrainedIntraPred = b; }
     
    642590  Void      setALFMaxNumberFilters          (Int i)  { m_iALFMaxNumberFilters = i; }
    643591  Int       getALFMaxNumberFilters          ()       { return m_iALFMaxNumberFilters; }
    644 #if LCU_SYNTAX_ALF
    645592  Void      setALFParamInSlice              (Bool b) {m_bALFParamInSlice = b;}
    646593  Bool      getALFParamInSlice              ()       {return m_bALFParamInSlice;}
    647594  Void      setALFPicBasedEncode            (Bool b) {m_bALFPicBasedEncode = b;}
    648595  Bool      getALFPicBasedEncode            ()       {return m_bALFPicBasedEncode;}
    649 #endif
    650596
    651597  Bool      getUseLComb                     ()      { return m_bUseLComb;   }
    652598  Bool      getLCMod                        ()      { return m_bLCMod; }
    653599  Bool      getUseRDOQ                      ()      { return m_bUseRDOQ;    }
    654 #if !PIC_CROPPING
    655   Bool      getUsePAD                       ()      { return m_bUsePAD;     }
    656 #endif
    657600
    658601#if HHI_VSO
     
    666609  Bool      getUseFastEnc                   ()      { return m_bUseFastEnc; }
    667610  Bool      getUseEarlyCU                   ()      { return m_bUseEarlyCU; }
    668 #if FAST_DECISION_FOR_MRG_RD_COST
    669611  Bool      getUseFastDecisionForMerge      ()      { return m_useFastDecisionForMerge; }
    670 #endif
    671612  Bool      getUseCbfFastMode           ()      { return m_bUseCbfFastMode; }
    672613  Bool      getUseConstrainedIntraPred      ()      { return m_bUseConstrainedIntraPred; }
     
    714655  Bool  getUseIC                       ()              {return m_bUseIC;}
    715656#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
    717661  Void  setMaxNumOffsetsPerPic                   (Int iVal)            { m_maxNumOffsetsPerPic = iVal; }
    718662  Int   getMaxNumOffsetsPerPic                   ()                    { return m_maxNumOffsetsPerPic; }
    719663  Void  setSaoInterleavingFlag                   (bool bVal)           { m_saoInterleavingFlag = bVal; }
    720664  Bool  getSaoInterleavingFlag                   ()                    { return m_saoInterleavingFlag; }
    721 #endif
    722665  Void  setTileBehaviorControlPresentFlag        ( Int i )             { m_iTileBehaviorControlPresentFlag = i;    }
    723666  Int   getTileBehaviorControlPresentFlag        ()                    { return m_iTileBehaviorControlPresentFlag; }
     
    728671  Void  setUniformSpacingIdr           ( Int i )           { m_iUniformSpacingIdr = i; }
    729672  Int   getUniformSpacingIdr           ()                  { return m_iUniformSpacingIdr; }
    730 #if !REMOVE_TILE_DEPENDENCE
    731   Void  setTileBoundaryIndependenceIdr ( Int i )           { m_iTileBoundaryIndependenceIdr = i; }
    732   Int   getTileBoundaryIndependenceIdr ()                  { return m_iTileBoundaryIndependenceIdr; }
    733 #endif
    734673  Void  setNumColumnsMinus1            ( Int i )           { m_iNumColumnsMinus1 = i; }
    735674  Int   getNumColumnsMinus1            ()                  { return m_iNumColumnsMinus1; }
     
    827766  Void      setEnableTMVP          ( Bool b )    { m_bEnableTMVP = b;    }
    828767  Bool      getEnableTMVP          ()            { return m_bEnableTMVP; }
    829 #if MULTIBITS_DATA_HIDING
    830768  Void      setSignHideFlag( Int signHideFlag )  { m_signHideFlag = signHideFlag; }
    831769  Void      setTSIG( Int tsig )                  { m_signHidingThreshold = tsig; }
    832770  Int       getSignHideFlag()                    { return m_signHideFlag; }
    833771  Int       getTSIG()                            { return m_signHidingThreshold; }
    834 #endif
    835772#if VIDYO_VPS_INTEGRATION |QC_MVHEVC_B0046
    836773  Void      setLayerId             ( UInt layerId )   { m_layerId = layerId; }
     
    869806  Void      setCodedOffset                  ( Int** p )      { m_aaiCodedOffset         = p; }
    870807
    871 #if SONY_COLPIC_AVAILABILITY
    872   Int       getViewOrderIdx                 ()      { return  m_iViewOrderIdx; }
     808#if INTER_VIEW_VECTOR_SCALING_C0115
     809  Int       getViewOrderIdx                 ()      { return  m_iViewOrderIdx; }    // will be changed to view_id
    873810#endif
    874811};
  • trunk/source/Lib/TLibEncoder/TEncCu.cpp

    r189 r296  
    7272  m_ppcRecoYuvTemp = new TComYuv*[m_uhTotalDepth-1];
    7373  m_ppcOrigYuv     = new TComYuv*[m_uhTotalDepth-1];
    74 #if HHI_INTER_VIEW_RESIDUAL_PRED
     74#if H3D_IVRP
    7575  m_ppcResPredTmp  = new TComYuv*[m_uhTotalDepth-1];
    7676#endif
     
    101101   
    102102    m_ppcOrigYuv    [i] = new TComYuv; m_ppcOrigYuv    [i]->create(uiWidth, uiHeight);
    103 #if HHI_INTER_VIEW_RESIDUAL_PRED
     103#if H3D_IVRP
    104104    m_ppcResPredTmp [i] = new TComYuv; m_ppcResPredTmp [i]->create(uiWidth, uiHeight);
    105105#endif
     
    107107 
    108108  m_bEncodeDQP = false;
    109 #if BURST_IPCM
    110109  m_checkBurstIPCMFlag = false;
    111 #endif
    112110
    113111  // initialize partition order.
     
    168166      m_ppcOrigYuv[i]->destroy();     delete m_ppcOrigYuv[i];     m_ppcOrigYuv[i] = NULL;
    169167    }
    170 #if HHI_INTER_VIEW_RESIDUAL_PRED
     168#if H3D_IVRP
    171169    if(m_ppcResPredTmp[i])
    172170    {
     
    221219    m_ppcOrigYuv = NULL;
    222220  }
    223 #if HHI_INTER_VIEW_RESIDUAL_PRED
     221#if H3D_IVRP
    224222  if(m_ppcResPredTmp)
    225223  {
     
    285283  }
    286284
    287 #if BURST_IPCM
    288285  TComPic* pcPic = pcCU->getPic();
    289286  Bool checkBurstIPCMFlag = (pcPic->getSlice(0)->getSPS()->getUsePCM())? true : false;
     
    293290  pcCU->setNumSucIPCM(0);
    294291  pcCU->setLastCUSucIPCMFlag(false);
    295 #endif
    296292
    297293  // Encode CU data
    298294  xEncodeCU( pcCU, 0, 0 );
    299295 
    300 #if OL_FLUSH
    301296  bool bTerminateSlice = bForceTerminate;
    302297  UInt uiCUAddr = pcCU->getAddr();
    303298    /* If at the end of an LCU line but not at the end of a substream, perform CABAC flush */
    304 #if WPP_SIMPLIFICATION
    305299    if (!bTerminateSlice && pcCU->getSlice()->getPPS()->getNumSubstreams() > 1)
    306 #else
    307     if (!bTerminateSlice && pcCU->getSlice()->getPPS()->getCabacIstateReset())
    308 #endif
    309300    {
    310301      Int iNumSubstreams = pcCU->getSlice()->getPPS()->getNumSubstreams();
     
    312303      UInt uiCol     = uiCUAddr % uiWidthInLCUs;
    313304      UInt uiLin     = uiCUAddr / uiWidthInLCUs;
    314 #if !REMOVE_TILE_DEPENDENCE
    315       Int iBreakDep = pcCU->getPic()->getPicSym()->getTileBoundaryIndependenceIdr();
    316 #endif
    317305      UInt uiTileStartLCU = pcCU->getPic()->getPicSym()->getTComTile(pcCU->getPic()->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
    318306      UInt uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
     
    321309      UInt uiTileHeight = pcCU->getPic()->getPicSym()->getTComTile(pcCU->getPic()->getPicSym()->getTileIdxMap(uiCUAddr))->getTileHeight();
    322310      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      {
    329313        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))
    332316      {
    333317        m_pcEntropyCoder->encodeFlush();
    334318      }
    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    }
    351320}
    352321
     
    458427  Bool  bIntraSliceDetect = (rpcBestCU->getSlice()->getSliceType() == I_SLICE);
    459428
     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
    460433  Bool bTry2NxN = true;
    461434  Bool bTryNx2N = true;
     
    494467
    495468#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());
    497474
    498475  bICEnabled = bICEnabled && rpcTempCU->getSlice()->getApplyIC();
     
    548525#if LOSSLESS_CODING
    549526  Bool isAddLowestQP = false;
    550 #if H0736_AVC_STYLE_QP_RANGE
    551527  Int lowestQP = -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY();
    552 #else
    553   Int lowestQP = 0;
    554 #endif
    555528#endif
    556529
     
    558531  {
    559532    Int idQP = m_pcEncCfg->getMaxDeltaQP();
    560 #if H0736_AVC_STYLE_QP_RANGE
    561533    iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP );
    562534    iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP );
     
    568540
    569541    }
    570 #endif
    571 #else
    572     iMinQP = Clip3( MIN_QP, MAX_QP, iBaseQP-idQP );
    573     iMaxQP = Clip3( MIN_QP, MAX_QP, iBaseQP+idQP );
    574 #if LOSSLESS_CODING
    575     if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() )
    576     {
    577       isAddLowestQP = true;
    578       iMinQP = iMinQP - 1;
    579     }
    580 #endif
    581542#endif
    582543  }
     
    612573#if OL_QTLIMIT_PREDCODING_B0068
    613574      //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
    614579      if(depthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC())
     580#endif
    615581      {
    616582        TComDataCU* pcTextureCU = pcTexture->getCU( rpcBestCU->getAddr() ); //Corresponding texture LCU
     
    635601      if( rpcBestCU->getSlice()->getSliceType() != I_SLICE )
    636602      {
    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
    638608        // check availability of residual prediction
    639609        Bool  bResPredAvailable   = false;
     
    643613        if( bResPredAllowed )
    644614        {
    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] );
    650616        }
    651617
    652618        for( UInt uiResPrdId = 0; uiResPrdId < ( bResPredAvailable ? 2 : 1 ); uiResPrdId++ )
     619#endif
    653620        {
    654621          Bool bResPredFlag  = ( uiResPrdId > 0 );
     
    660627#endif
    661628#endif
    662 #if HHI_INTER_VIEW_RESIDUAL_PRED
     629#if H3D_IVRP
    663630          rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
    664631#endif
     
    691658          if ( !bEarlySkip )
    692659          {
    693 #if HHI_INTER_VIEW_RESIDUAL_PRED
     660#if H3D_IVRP
    694661            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
     662#endif
     663#if FIX_LGE_ILLUCOMP_B0045
     664            rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    695665#endif
    696666#if HHI_INTERVIEW_SKIP
     
    709679         }
    710680#endif
    711 #if HHI_INTER_VIEW_RESIDUAL_PRED
     681#if H3D_IVRP
    712682        } // uiResPrdId
    713683#endif
     
    719689
    720690#if OL_QTLIMIT_PREDCODING_B0068
     691
     692#if HHI_QTLPC_RAU_OFF_C0160
     693      if(depthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTLPC())
     694#else
    721695      if(depthMapDetect && !bIntraSliceDetect  && sps->getUseQTLPC())
     696#endif
    722697      {
    723698        bTrySplitDQP = bTrySplit;
     
    763738      if( rpcBestCU->getSlice()->getSliceType() != I_SLICE )
    764739      {
    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
    766745        // check availability of residual prediction
    767746        Bool  bResPredAvailable   = false;
     
    771750        if( bResPredAllowed )
    772751        {
    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] );
    778753        }
    779754
    780755        for( UInt uiResPrdId = 0; uiResPrdId < ( bResPredAvailable ? 2 : 1 ); uiResPrdId++ )
     756#endif
    781757        {
    782758          Bool bResPredFlag  = ( uiResPrdId > 0 );
     
    800776                {
    801777#endif
    802 #if HHI_INTER_VIEW_RESIDUAL_PRED
     778#if H3D_IVRP
    803779                  rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
    804780#endif
     
    823799              if(doNotBlockPu)
    824800              {
    825 #if HHI_INTER_VIEW_RESIDUAL_PRED
     801#if H3D_IVRP
    826802                rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
     803#endif
     804#if FIX_LGE_ILLUCOMP_B0045
     805                rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    827806#endif
    828807#if HHI_INTERVIEW_SKIP
     
    847826              if(doNotBlockPu)
    848827              {
    849 #if HHI_INTER_VIEW_RESIDUAL_PRED
     828#if H3D_IVRP
    850829                rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
     830#endif
     831#if FIX_LGE_ILLUCOMP_B0045
     832                rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    851833#endif
    852834#if HHI_INTERVIEW_SKIP
     
    890872                if(doNotBlockPu)
    891873                {
    892 #if HHI_INTER_VIEW_RESIDUAL_PRED
     874#if H3D_IVRP
    893875                  rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
     876#endif
     877#if FIX_LGE_ILLUCOMP_B0045
     878                  rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    894879#endif
    895880#if HHI_INTERVIEW_SKIP
     
    906891                if(doNotBlockPu)
    907892                {
    908 #if HHI_INTER_VIEW_RESIDUAL_PRED
     893#if H3D_IVRP
    909894                  rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
     895#endif
     896#if FIX_LGE_ILLUCOMP_B0045
     897                  rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    910898#endif
    911899#if HHI_INTERVIEW_SKIP
     
    933921                if(doNotBlockPu)
    934922                {
    935 #if HHI_INTER_VIEW_RESIDUAL_PRED
     923#if H3D_IVRP
    936924                  rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
     925#endif
     926#if FIX_LGE_ILLUCOMP_B0045
     927                  rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    937928#endif
    938929#if HHI_INTERVIEW_SKIP
     
    949940                if(doNotBlockPu)
    950941                {
    951 #if HHI_INTER_VIEW_RESIDUAL_PRED
     942#if H3D_IVRP
    952943                  rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
     944#endif
     945#if FIX_LGE_ILLUCOMP_B0045
     946                  rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    953947#endif
    954948#if HHI_INTERVIEW_SKIP
     
    978972                if(doNotBlockPu)
    979973                {
    980 #if HHI_INTER_VIEW_RESIDUAL_PRED
     974#if H3D_IVRP
    981975                  rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
     976#endif
     977#if FIX_LGE_ILLUCOMP_B0045
     978                  rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    982979#endif
    983980#if HHI_INTERVIEW_SKIP
     
    994991                if(doNotBlockPu)
    995992                {
    996 #if HHI_INTER_VIEW_RESIDUAL_PRED
     993#if H3D_IVRP
    997994                  rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
     995#endif
     996#if FIX_LGE_ILLUCOMP_B0045
     997                  rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    998998#endif
    999999#if HHI_INTERVIEW_SKIP
     
    10171017                if(doNotBlockPu)
    10181018                {
    1019 #if HHI_INTER_VIEW_RESIDUAL_PRED
     1019#if H3D_IVRP
    10201020                  rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
     1021#endif
     1022#if FIX_LGE_ILLUCOMP_B0045
     1023                  rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    10211024#endif
    10221025#if HHI_INTERVIEW_SKIP
     
    10331036                if(doNotBlockPu)
    10341037                {
    1035 #if HHI_INTER_VIEW_RESIDUAL_PRED
     1038#if H3D_IVRP
    10361039                  rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
     1040#endif
     1041#if FIX_LGE_ILLUCOMP_B0045
     1042                  rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    10371043#endif
    10381044#if HHI_INTERVIEW_SKIP
     
    10501056
    10511057#else
    1052 #if HHI_INTER_VIEW_RESIDUAL_PRED
     1058#if H3D_IVRP
    10531059            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
    10541060#endif
     
    10591065#endif
    10601066            rpcTempCU->initEstData( uiDepth, iQP );
    1061 #if HHI_INTER_VIEW_RESIDUAL_PRED
     1067#if H3D_IVRP
    10621068            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
    10631069#endif
     
    10681074#endif
    10691075            rpcTempCU->initEstData( uiDepth, iQP );
    1070 #if HHI_INTER_VIEW_RESIDUAL_PRED
     1076#if H3D_IVRP
    10711077            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
    10721078#endif
     
    10771083#endif
    10781084            rpcTempCU->initEstData( uiDepth, iQP );
    1079 #if HHI_INTER_VIEW_RESIDUAL_PRED
     1085#if H3D_IVRP
    10801086            rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag );
    10811087#endif
     
    10931099         }
    10941100#endif
    1095 #if HHI_INTER_VIEW_RESIDUAL_PRED
     1101#if H3D_IVRP
    10961102        } // uiResPrdId
    10971103#endif
     
    11031109
    11041110      // 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        )
    11061116      {
    11071117        // speedup for inter frames
     
    11101120          rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
    11111121          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
    11131127#else
    11141128        if( rpcBestCU->getSlice()->getSliceType() == I_SLICE ||
    11151129          rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
    11161130          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
    11181136#endif
    11191137        {
     
    11681186      if( rpcBestCU->getSlice()->getSPS()->getUseMVI() && rpcBestCU->getSlice()->getSliceType() != I_SLICE )
    11691187      {
     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
    11701194        xCheckRDCostMvInheritance( rpcBestCU, rpcTempCU, uiDepth, false, false );
    11711195        rpcTempCU->initEstData( uiDepth, iQP );
     1196#if FIX_ILLUCOMP_DEPTH
     1197        rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
     1198#endif
    11721199        xCheckRDCostMvInheritance( rpcBestCU, rpcTempCU, uiDepth, true, false );
    11731200        rpcTempCU->initEstData( uiDepth, iQP );
     1201#if LGE_ILLUCOMP_DEPTH_C0046
     1202        }
     1203#endif
    11741204      }
    11751205#endif
     
    12401270  {
    12411271    Int idQP = m_pcEncCfg->getMaxDeltaQP();
    1242 #if H0736_AVC_STYLE_QP_RANGE
    12431272    iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP );
    12441273    iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP );
     
    12491278      iMinQP = iMinQP - 1;     
    12501279    }
    1251 #endif
    1252 #else
    1253     iMinQP = Clip3( MIN_QP, MAX_QP, iBaseQP-idQP );
    1254     iMaxQP = Clip3( MIN_QP, MAX_QP, iBaseQP+idQP );
    1255 #if LOSSLESS_CODING
    1256     if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() )
    1257     {
    1258       isAddLowestQP = true;
    1259       iMinQP = iMinQP - 1;
    1260     }
    1261 #endif
    12621280#endif
    12631281  }
     
    15581576    &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight));
    15591577 
    1560 #if BURST_IPCM
    15611578  if(granularityBoundary && (!(pcCU->getIPCMFlag(uiAbsPartIdx) && ( pcCU->getNumSucIPCM() > 1 ))))
    1562 #else
    1563   if(granularityBoundary)
    1564 #endif
    15651579  {
    15661580    // The 1-terminating bit is added to all streams, so don't add it here when it's 1.
     
    16541668    iQpOffset = Int(floor( dQpOffset + 0.49999 ));
    16551669  }
    1656 #if H0736_AVC_STYLE_QP_RANGE
    16571670  return Clip3(-pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQp+iQpOffset );
    1658 #else
    1659   return Clip3( MIN_QP, MAX_QP, iBaseQp+iQpOffset );
    1660 #endif
    16611671}
    16621672
     
    16771687  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
    16781688 
    1679 #if BURST_IPCM
    16801689  if( getCheckBurstIPCMFlag() )
    16811690  {
     
    16831692    pcCU->setNumSucIPCM( countNumSucIPCM ( pcCU, uiAbsPartIdx ) );
    16841693  }
    1685 #endif
    16861694
    16871695  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
     
    17281736    {
    17291737      m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx, 0 );
     1738#if LGE_ILLUCOMP_DEPTH_C0046
     1739      m_pcEntropyCoder->encodeICFlag  ( pcCU, uiAbsPartIdx, false, uiDepth );
     1740#endif
    17301741      finishCU(pcCU,uiAbsPartIdx,uiDepth);
    17311742      xRestoreDepthWidthHeight( pcCU );
     
    17391750    // prediction Info ( Intra : direction mode, Inter : Mv, reference idx )
    17401751    m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx );
     1752#if LGE_ILLUCOMP_DEPTH_C0046
     1753    m_pcEntropyCoder->encodeICFlag  ( pcCU, uiAbsPartIdx, false, uiDepth );
     1754#endif
    17411755    xRestoreDepthWidthHeight( pcCU );
    17421756  }
     
    17501764      setdQPFlag(true);
    17511765    }
    1752 #if BURST_IPCM
    17531766    pcCU->setNumSucIPCM(0);
    17541767    pcCU->setLastCUSucIPCMFlag(false);
    1755 #endif
    17561768    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx+=uiQNumParts )
    17571769    {
     
    17871799    m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx, 0 );
    17881800#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
    17921808    m_pcEntropyCoder->encodeResPredFlag( pcCU, uiAbsPartIdx, 0 );
    17931809#endif
     
    18181834  m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx );
    18191835#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
    18231843    if( !pcCU->isIntra( uiAbsPartIdx ) )
    18241844    {
     
    18511871{
    18521872  assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE );
    1853 #if HHI_INTER_VIEW_MOTION_PRED
     1873#if H3D_IVMP
    18541874  TComMvField  cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    18551875  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
     
    18601880  Int numValidMergeCand = 0;
    18611881
    1862 #if HHI_INTER_VIEW_RESIDUAL_PRED
     1882#if H3D_IVRP && !MTK_MDIVRP_C0138
    18631883  Bool  bResPrdAvail  = rpcTempCU->getResPredAvail( 0 );
    18641884  Bool  bResPrdFlag   = rpcTempCU->getResPredFlag ( 0 );
     
    18681888#endif
    18691889
    1870 #if HHI_INTER_VIEW_MOTION_PRED
     1890#if H3D_IVMP
    18711891  for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ++ui )
    18721892#else
     
    18901910
    18911911  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
    18951922  Bool bestIsSkip = false;
    1896 #endif
    18971923 
    18981924  for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
     
    19241950#endif
    19251951      {
    1926 #if FAST_DECISION_FOR_MRG_RD_COST
    19271952        if( !(bestIsSkip && uiNoResidual == 0) )
    19281953        {
    1929 #endif
    19301954          // set MC parameters
    19311955          rpcTempCU->setPredModeSubParts( MODE_SKIP, 0, uhDepth ); // interprets depth relative to LCU level
     
    19331957          rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level
    19341958          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
    19351975          rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
    19361976          rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    19371977          rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    19381978
    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
    19401983          rpcTempCU->setResPredAvailSubParts( bResPrdAvail, 0, 0, uhDepth );
    19411984          rpcTempCU->setResPredFlagSubParts ( bResPrdFlag,  0, 0, uhDepth );
     1985#endif
    19421986#endif
    19431987#if LGE_ILLUCOMP_B0045
     
    19521996#endif
    19531997        {
     1998#if MERL_VSP_C0152
     1999            m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth],  rpcTempCU->getZorderIdxInCU() );
     2000#else
    19542001            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
    19552009            // save pred adress
    19562010            pcPredYuvTemp = m_ppcPredYuvTemp[uhDepth];
     
    19592013          else
    19602014          {
    1961 #if FAST_DECISION_FOR_MRG_RD_COST
    19622015            if( bestIsSkip)
    19632016            {
     2017#if MERL_VSP_C0152
     2018              m_pcPredSearch->motionCompensation( rpcTempCU, m_ppcPredYuvTemp[uhDepth], rpcTempCU->getZorderIdxInCU() );
     2019#else
    19642020              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
    19652028              // save pred adress
    19662029              pcPredYuvTemp = m_ppcPredYuvTemp[uhDepth];
     
    19682031            else
    19692032            {
    1970 #endif
    19712033              if ( pcPredYuvTemp != m_ppcPredYuvTemp[uhDepth])
    19722034              {
     
    19742036                pcPredYuvTemp = m_ppcPredYuvBest[uhDepth];
    19752037              }
    1976 #if FAST_DECISION_FOR_MRG_RD_COST
    19772038            }
    1978 #endif
    19792039          }
    19802040#if HHI_VSO
     
    19952055            m_ppcResiYuvBest[uhDepth],
    19962056            m_ppcRecoYuvTemp[uhDepth],
    1997 #if HHI_INTER_VIEW_RESIDUAL_PRED
     2057#if H3D_IVRP
    19982058                                                     m_ppcResPredTmp [uhDepth],
    19992059#endif
     
    20012061          Bool bQtRootCbf = rpcTempCU->getQtRootCbf(0) == 1;
    20022062
    2003 #if H0736_AVC_STYLE_QP_RANGE
    20042063          Int orgQP = rpcTempCU->getQP( 0 );
    20052064          xCheckDQP( rpcTempCU );
    20062065          xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
    20072066          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
    20162068          if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
    20172069          {
    20182070            bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0;
    20192071          }
    2020 #endif
    20212072
    20222073          if (!bQtRootCbf)
    20232074            break;
    2024 #if FAST_DECISION_FOR_MRG_RD_COST
    20252075        }
    2026 #endif
    20272076      }
    20282077    }
     
    20592108  rpcTempCU->setDepthSubParts( uhDepth, 0 );
    20602109 
    2061 #if HHI_INTER_VIEW_RESIDUAL_PRED
     2110#if H3D_IVRP
    20622111  Bool  bResPrdAvail  = rpcTempCU->getResPredAvail( 0 );
    20632112  Bool  bResPrdFlag   = rpcTempCU->getResPredFlag ( 0 );
     
    20652114 
    20662115  rpcTempCU->setPartSizeSubParts  ( ePartSize,  0, uhDepth );
    2067 #if HHI_INTER_VIEW_RESIDUAL_PRED
     2116
     2117#if H3D_IVRP
    20682118  rpcTempCU->setResPredAvailSubParts( bResPrdAvail, 0, 0, uhDepth );
    20692119  rpcTempCU->setResPredFlagSubParts ( bResPrdFlag,  0, 0, uhDepth );
     
    20712121  rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
    20722122 
    2073 #if HHI_INTER_VIEW_RESIDUAL_PRED
     2123#if H3D_IVRP
    20742124#if !LG_RESTRICTEDRESPRED_M24766
    20752125  if( rpcTempCU->getResPredFlag( 0 ) )
     
    20832133  rpcTempCU->setMergeAMP (true);
    20842134  #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);
    20872137#else
    20882138  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes, bUseMRG  );
     
    20992149#endif
    21002150
    2101 #if HHI_INTER_VIEW_RESIDUAL_PRED
     2151#if H3D_IVRP
    21022152#if !LG_RESTRICTEDRESPRED_M24766
    21032153  if( rpcTempCU->getResPredFlag( 0 ) )
     
    21222172                                             m_ppcResiYuvBest[uhDepth],
    21232173                                             m_ppcRecoYuvTemp[uhDepth],
    2124 #if HHI_INTER_VIEW_RESIDUAL_PRED
     2174#if H3D_IVRP
    21252175                                             m_ppcResPredTmp [uhDepth],
    21262176#endif
     
    21332183                                             m_ppcResiYuvBest[uhDepth],
    21342184                                             m_ppcRecoYuvTemp[uhDepth],
    2135 #if HHI_INTER_VIEW_RESIDUAL_PRED
     2185#if H3D_IVRP
    21362186                                             m_ppcResPredTmp [uhDepth],
    21372187#endif
     
    23752425}
    23762426
    2377 #if BURST_IPCM
    23782427/** Check whether the last CU shares the same root as the current CU and is IPCM or not. 
    23792428 * \param pcCU
     
    24672516  return numSucIPCM;
    24682517}
    2469 #endif
    24702518
    24712519Void TEncCu::xCopyAMVPInfo (AMVPInfo* pSrc, AMVPInfo* pDst)
     
    27872835      assert( rpcTempCU->getInterDir( ui ) != 0 );
    27882836      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
    27902843    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
    27912847    m_pcPredSearch->motionCompensation( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
    2792 
     2848#endif
    27932849    // get Original YUV data from picture
    27942850    m_ppcOrigYuv[uhDepth]->copyFromPicYuv( rpcBestCU->getPic()->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
     
    27992855                                               m_ppcResiYuvBest[uhDepth],
    28002856                                               m_ppcRecoYuvTemp[uhDepth],
    2801 #if HHI_INTER_VIEW_RESIDUAL_PRED
     2857#if H3D_IVRP
    28022858                                               m_ppcResPredTmp [uhDepth],
    28032859#endif
     
    28762932    m_pcEntropyCoder->encodeMergeIndex( pcCU, 0, 0, true );
    28772933#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        );
    28792939#endif
    28802940  }
     
    28862946    m_pcEntropyCoder->encodePredInfo( pcCU, 0, true );
    28872947#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        );
    28892953#endif
    28902954  }
  • trunk/source/Lib/TLibEncoder/TEncCu.h

    r56 r296  
    7878  TComYuv**               m_ppcRecoYuvTemp; ///< Temporary Reconstruction Yuv for each depth
    7979  TComYuv**               m_ppcOrigYuv;     ///< Original Yuv for each depth
    80 #if HHI_INTER_VIEW_RESIDUAL_PRED
     80#if H3D_IVRP
    8181  TComYuv**               m_ppcResPredTmp;  ///< Temporary residual prediction for each depth
    8282#endif
    83  
     83
    8484  //  Data : encoder control
    8585  Bool                    m_bEncodeDQP;
    86 #if BURST_IPCM
    8786  Bool                    m_checkBurstIPCMFlag;
    88 #endif
    8987
    9088  //  Access channel
     
    121119  /// destroy internal buffers
    122120  Void  destroy             ();
    123  
     121
    124122  /// CU analysis function
    125123  Void  compressCU          ( TComDataCU*&  rpcCU );
     
    173171  Void setdQPFlag           ( Bool b )                { m_bEncodeDQP = b;           }
    174172
    175 #if BURST_IPCM
    176173  Bool getCheckBurstIPCMFlag()                        { return m_checkBurstIPCMFlag;   }
    177174  Void setCheckBurstIPCMFlag( Bool b )                { m_checkBurstIPCMFlag = b;      }
     
    179176  Bool checkLastCUSucIPCM   ( TComDataCU* pcCU, UInt uiCurAbsPartIdx );
    180177  Int  countNumSucIPCM      ( TComDataCU* pcCU, UInt uiCurAbsPartIdx );
    181 #endif
    182178
    183179#if ADAPTIVE_QP_SELECTION
  • trunk/source/Lib/TLibEncoder/TEncEntropy.cpp

    r210 r296  
    5252Void TEncEntropy::encodeSliceHeader ( TComSlice* pcSlice )
    5353{
    54 #if SAO_UNIT_INTERLEAVING
    5554  if (pcSlice->getSPS()->getUseSAO())
    5655  {
     
    6867    }
    6968  }
    70 #endif
    7169
    7270  m_pcEntropyCoderIf->codeSliceHeader( pcSlice );
     
    7472}
    7573
    76 #if TILES_WPP_ENTRY_POINT_SIGNALLING
    7774Void  TEncEntropy::encodeTilesWPPEntryPoint( TComSlice* pSlice )
    7875{
    7976  m_pcEntropyCoderIf->codeTilesWPPEntryPoint( pSlice );
    8077}
    81 #else
    82 Void TEncEntropy::encodeSliceHeaderSubstreamTable( TComSlice* pcSlice )
    83 {
    84   m_pcEntropyCoderIf->codeSliceHeaderSubstreamTable( pcSlice );
    85 }
    86 #endif
    8778
    8879Void TEncEntropy::encodeTerminatingBit      ( UInt uiIsLast )
     
    9889}
    9990
    100 #if OL_FLUSH
    10191Void TEncEntropy::encodeFlush()
    10292{
     
    10797  m_pcEntropyCoderIf->encodeStart();
    10898}
    109 #endif
    11099
    111100Void TEncEntropy::encodeSEI(const SEI& sei)
     
    133122#endif
    134123
    135 #if HHI_MPI
     124#if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068
    136125Void TEncEntropy::encodeSPS( TComSPS* pcSPS, Bool bIsDepth )
    137126{
     
    157146    uiAbsPartIdx = 0;
    158147  }
    159 #if BURST_IPCM
    160148  if( !bRD )
    161149  {
     
    165153    }
    166154  }
    167 #endif
    168155  m_pcEntropyCoderIf->codeSkipFlag( pcCU, uiAbsPartIdx );
    169156}
    170157
    171158#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())
     159Void 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      )
    175170  {
    176171    return;
     
    185180  }
    186181
    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      ))
    188187    m_pcEntropyCoderIf->codeICFlag( pcCU, uiAbsPartIdx );
    189188}
     
    214213  //  m_pcEntropyCoderIf->codeAlfUvlc(pAlfParam->realfiltNo);
    215214
    216 #if !LCU_SYNTAX_ALF
    217   m_pcEntropyCoderIf->codeAlfFlag(pAlfParam->alf_pcr_region_flag);
    218 #endif
    219 #if !ALF_SINGLE_FILTER_SHAPE
    220   m_pcEntropyCoderIf->codeAlfUvlc(pAlfParam->filter_shape);
    221 #endif
    222215  Int noFilters = min(pAlfParam->filters_per_group-1, 2);
    223216  m_pcEntropyCoderIf->codeAlfUvlc(noFilters);
     
    229222  else if (noFilters == 2)
    230223  {
    231 #if LCU_SYNTAX_ALF
    232 #if ALF_16_BA_GROUPS
    233224    Int numMergeFlags = 16;
    234 #else
    235     Int numMergeFlags = 15;
    236 #endif
    237 #else
    238 #if ALF_16_BA_GROUPS
    239     Int numMergeFlags = 16;
    240 #else
    241     Int numMergeFlags = pAlfParam->alf_pcr_region_flag ? 16 : 15;
    242 #endif
    243 #endif
    244225    for (Int i=1; i<numMergeFlags; i++)
    245226    {
     
    273254  pDepthInt = pDepthIntTabShapes[ALFp->filter_shape];
    274255  maxScanVal = 0;
    275 #if ALF_SINGLE_FILTER_SHAPE
    276256  int minScanVal = MIN_SCAN_POS_CROSS;
    277 #else
    278   int minScanVal = ( ALFp->filter_shape==ALF_STAR5x5 ) ? 0 : MIN_SCAN_POS_CROSS;
    279 #endif
    280257
    281258  for(i = 0; i < sqrFiltLength; i++)
     
    343320  // Coding parameters
    344321  ALFp->minKStart = minKStart;
    345 #if !LCU_SYNTAX_ALF 
    346   ALFp->maxScanVal = maxScanVal;
    347 #endif
    348322  for(scanPos = minScanVal; scanPos < maxScanVal; scanPos++)
    349323  {
     
    351325  }
    352326
    353 #if LCU_SYNTAX_ALF
    354327  if (ALFp->filters_per_group == 1)
    355328  {
     
    358331  else
    359332  {
    360 #endif
    361333  len += writeFilterCodingParams(minKStart, minScanVal, maxScanVal, kMinTab);
    362334
    363335  // Filter coefficients
    364336  len += writeFilterCoeffs(sqrFiltLength, filters_per_group, pDepthInt, ALFp->coeffmulti, kMinTab);
    365 #if LCU_SYNTAX_ALF
    366   }
    367 #endif
     337  }
    368338 
    369339  return len;
     
    403373    {
    404374      scanPos = pDepthInt[i] - 1;
    405 #if LCU_SYNTAX_ALF
    406375      Int k = (filters_per_group == 1) ? kMinTab[i] : kMinTab[scanPos];
    407376      golombEncode(FilterCoeff[ind][i], k);
    408 #else
    409       golombEncode(FilterCoeff[ind][i], kMinTab[scanPos]);
    410 #endif
    411377    }
    412378  }
     
    489455}
    490456
    491 #if HHI_INTER_VIEW_RESIDUAL_PRED
     457#if H3D_IVRP && !MTK_MDIVRP_C0138
    492458Void
    493459TEncEntropy::encodeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD )
     
    514480#endif
    515481
    516 #if LCU_SYNTAX_ALF
    517482/** parse the fixed length code (smaller than one max value) in ALF
    518483 * \param run: coded value
     
    781746
    782747}
    783 #endif
    784748
    785749
    786750Void TEncEntropy::encodeAlfParam(ALFParam* pAlfParam)
    787751{
    788 #if LCU_SYNTAX_ALF
    789752  const Int numCoeff = (Int)ALF_MAX_NUM_COEF;
    790753
     
    814777    }
    815778  }
    816 #else
    817   if (!pAlfParam->alf_flag)
    818   {
    819     return;
    820   }
    821   Int pos;
    822   codeAux(pAlfParam);
    823   codeFilt(pAlfParam);
    824  
    825   // filter parameters for chroma
    826   m_pcEntropyCoderIf->codeAlfUvlc(pAlfParam->chroma_idc);
    827   if(pAlfParam->chroma_idc)
    828   {
    829 #if !ALF_SINGLE_FILTER_SHAPE
    830     m_pcEntropyCoderIf->codeAlfUvlc(pAlfParam->filter_shape_chroma);
    831 #endif
    832     // filter coefficients for chroma
    833     for(pos=0; pos<pAlfParam->num_coeff_chroma; pos++)
    834     {
    835       m_pcEntropyCoderIf->codeAlfSvlc(pAlfParam->coeff_chroma[pos]);
    836     }
    837   }
    838 #endif
    839779}
    840780
     
    895835    uiAbsPartIdx = 0;
    896836  }
    897 #if BURST_IPCM
    898837  if( !bRD )
    899838  {
     
    903842    }
    904843  }
    905 #endif
    906844
    907845#if !RWTH_SDC_DLT_B0036
     
    931869    uiAbsPartIdx = 0;
    932870  }
    933 #if BURST_IPCM
    934871  if( !bRD )
    935872  {
     
    939876    }
    940877  }
    941 #endif
    942878
    943879  m_pcEntropyCoderIf->codeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
     
    957893    uiAbsPartIdx = 0;
    958894  }
    959 #if BURST_IPCM
    960895  if( !bRD )
    961896  {
     
    965900    }
    966901  }
    967 #endif 
    968902#if RWTH_SDC_DLT_B0036
    969903  if( !pcCU->getSlice()->isInterB() && pcCU->isIntra(uiAbsPartIdx) && pcCU->getSDCFlag(uiAbsPartIdx)  )
     
    1019953  }
    1020954 
    1021 #if BURST_IPCM
    1022955  Int numIPCM = 0;
    1023956  Bool firstIPCMFlag = false;
     
    1035968  }
    1036969  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
    1044973Void 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 #else
    1046 Void TEncEntropy::xEncodeTransformSubdiv( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 )
    1047 #endif
    1048974{
    1049975  const UInt uiSubdiv = pcCU->getTransformIdx( uiAbsPartIdx ) + pcCU->getDepth( uiAbsPartIdx ) > uiDepth;
    1050976  const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth;
    1051 #if UNIFIED_TRANSFORM_TREE
    1052977  UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA    , uiTrIdx );
    1053978  UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
     
    1072997    }
    1073998  }
    1074 #endif // UNIFIED_TRANSFORM_TREE
    1075999  {//CABAC
    10761000    if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
     
    11521076    if( uiSubdiv )
    11531077    {
    1154 #if UNIFIED_TRANSFORM_TREE
    11551078      UInt size;
    11561079      width  >>= 1;
     
    11581081      size = width*height;
    11591082      uiTrIdx++;
    1160 #endif // UNIFIED_TRANSFORM_TREE
    11611083      ++uiDepth;
    1162 #if UNIFIED_TRANSFORM_TREE
    11631084      const UInt partNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
    1164 #else
    1165       const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
    1166 #endif
    11671085     
    11681086      UInt uiCurrentCbfY = 0;
     
    11701088      UInt uiCurrentCbfV = 0;
    11711089     
    1172 #if UNIFIED_TRANSFORM_TREE
    11731090      UInt nsAddr = 0;
    11741091      nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, 0, uiDepth - pcCU->getDepth( uiAbsPartIdx ) );
     
    11861103      nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, 3, uiDepth - pcCU->getDepth( uiAbsPartIdx ) );
    11871104      xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, nsAddr, uiDepth, width, height, uiTrIdx, 3, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV, bCodeDQP );     
    1188 #else // UNIFIED_TRANSFORM_TREE
    1189       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_TREE
    12051105     
    12061106      uiYCbfFront3 += uiCurrentCbfY;
     
    12461146      }
    12471147     
    1248 #if UNIFIED_TRANSFORM_TREE
    12491148      if ( cbfY || cbfU || cbfV )
    12501149      {
     
    12981197        }
    12991198      }
    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
    13251203
    13261204// Intra direction for Luma
     
    13471225    uiAbsPartIdx = 0;
    13481226  }
    1349  
     1227
    13501228#if RWTH_SDC_DLT_B0036
    13511229  if( pcCU->getSDCFlag(uiAbsPartIdx) )
     
    13551233  }
    13561234#endif
    1357  
     1235
    13581236  PartSize eSize = pcCU->getPartitionSize( uiAbsPartIdx );
    13591237 
     
    14961374  if ( (pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList )) && (pcCU->getAMVPMode(uiAbsPartIdx) == AM_EXPL) )
    14971375  {
    1498 #if HHI_INTER_VIEW_MOTION_PRED
     1376#if H3D_IVMP
    14991377    const Int iNumCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 );
    15001378    m_pcEntropyCoderIf->codeMVPIdx( pcCU, uiAbsPartIdx, eRefList, iNumCands );
     
    15381416
    15391417// texture
    1540 #if !UNIFIED_TRANSFORM_TREE
    1541 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 once
    1566     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 transform
    1579    
    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       else
    1614       {
    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     else
    1629     {
    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_TREE
    16711418
    16721419/** encode coefficients
     
    17061453    DTRACE_CABAC_V( uiDepth )
    17071454    DTRACE_CABAC_T( "\n" )
    1708 #if !UNIFIED_TRANSFORM_TREE
    1709     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_TREE
    17141455  }
    17151456  else
     
    17351476      }
    17361477    }
    1737 #if !UNIFIED_TRANSFORM_TREE
    1738     encodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) );
    1739 #endif
    17401478  }
    17411479 
     
    17561494#endif
    17571495
    1758 #if UNIFIED_TRANSFORM_TREE
    17591496  UInt temp = 0;
    17601497  UInt temp1 = 0;
    17611498  UInt temp2 = 0;
    17621499  xEncodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, 0, temp, temp1, temp2, bCodeDQP );
    1763 #else // UNIFIED_TRANSFORM_TREE
    1764   xEncodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, uiLumaTrMode, bCodeDQP );
    1765 #endif // UNIFIED_TRANSFORM_TREE
    17661500
    17671501#if FIX_MPI_B0065
     
    17851519}
    17861520
    1787 #if SAO_UNIT_INTERLEAVING
    17881521/** Encode SAO Offset
    17891522 * \param  saoLcuParam SAO LCU paramters
     
    19731706  }
    19741707}
    1975 #else
    1976 /** Encode SAO for one partition
    1977  * \param  pSaoParam, iPartIdx
    1978  */
    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     else
    1993     {
    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   //split
    2010   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 flag
    2020  * \param  pSaoParam, iPartIdx
    2021  */
    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 flag
    2030     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 parameters
    2042  * \param  pSaoParam
    2043  */
    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 #endif
    20651708
    20661709Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize )
  • trunk/source/Lib/TLibEncoder/TEncEntropy.h

    r210 r296  
    8080#endif
    8181
    82 #if HHI_MPI
     82#if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068
    8383  virtual Void  codeSPS                 ( TComSPS* pcSPS, Bool bIsDepth )                       = 0;
    8484#else
     
    9090  virtual Void codeTileMarkerFlag      ( TComSlice* pcSlice )                                  = 0;
    9191
    92 #if TILES_WPP_ENTRY_POINT_SIGNALLING
    9392  virtual Void  codeTilesWPPEntryPoint  ( TComSlice* pSlice )     = 0;
    94 #else
    95   virtual Void  codeSliceHeaderSubstreamTable( TComSlice* pcSlice )                             = 0;
    96 #endif
    9793  virtual Void  codeTerminatingBit      ( UInt uilsLast )                                       = 0;
    9894  virtual Void  codeSliceFinish         ()                                                      = 0;
    99 #if OL_FLUSH
    10095  virtual Void  codeFlush               ()                                                      = 0;
    10196  virtual Void  encodeStart             ()                                                      = 0;
    102 #endif
    10397 
    10498  virtual Void codeAlfCtrlDepth() = 0;
    105 #if HHI_INTER_VIEW_MOTION_PRED
     99#if H3D_IVMP
    106100  virtual Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ) = 0;
    107101#else
     
    120114  virtual Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    121115  virtual Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    122 #if HHI_INTER_VIEW_RESIDUAL_PRED
     116#if H3D_IVRP
    123117  virtual Void codeResPredFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    124118#endif
     
    134128#endif
    135129 
    136 #if BURST_IPCM
    137130  virtual Void codeIPCMInfo      ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag) = 0;
    138 #else
    139   virtual Void codeIPCMInfo      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    140 #endif
    141131
    142132  virtual Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) = 0;
     
    155145  virtual Void codeAlfUvlc          ( UInt uiCode ) = 0;
    156146  virtual Void codeAlfSvlc          ( Int   iCode ) = 0;
    157 #if LCU_SYNTAX_ALF
    158147  virtual Void codeAlfFixedLengthIdx( UInt idx, UInt numFilterSetsInBuffer) = 0;
    159148  virtual Void codeAPSAlflag(UInt uiCode) = 0;
    160 #endif
    161149  /// set slice granularity
    162150  virtual Void setSliceGranularity(Int iSliceGranularity) = 0;
     
    169157  virtual Void codeSaoUvlc          ( UInt uiCode ) = 0;
    170158  virtual Void codeSaoSvlc          ( Int   iCode ) = 0;
    171 #if SAO_UNIT_INTERLEAVING
    172159  virtual Void codeSaoRun          ( UInt   uiCode, UInt uiMaxValue  ) = 0;
    173160  virtual Void codeSaoMergeLeft    ( UInt   uiCode, UInt uiCompIdx  ) = 0;
     
    175162  virtual Void codeSaoTypeIdx      ( UInt   uiCode) = 0;
    176163  virtual Void codeSaoUflc         ( UInt   uiCode) = 0;
    177 #endif
    178164  virtual Void estBit               (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) = 0;
    179165 
     
    198184  UInt    m_uiBakAbsPartIdx;
    199185  UInt    m_uiBakChromaOffset;
    200 #if UNIFIED_TRANSFORM_TREE
    201186  UInt    m_bakAbsPartIdxCU;
    202 #endif
    203187
    204188public:
     
    216200  Void    encodeSliceHeader         ( TComSlice* pcSlice );
    217201  Void    encodeTileMarkerFlag       (TComSlice* pcSlice) {m_pcEntropyCoderIf->codeTileMarkerFlag(pcSlice);}
    218 #if TILES_WPP_ENTRY_POINT_SIGNALLING
    219202  Void    encodeTilesWPPEntryPoint( TComSlice* pSlice );
    220 #else
    221   Void    encodeSliceHeaderSubstreamTable( TComSlice* pcSlice );
    222 #endif
    223203  Void    encodeTerminatingBit      ( UInt uiIsLast );
    224204  Void    encodeSliceFinish         ();
    225 #if OL_FLUSH
    226205  Void    encodeFlush               ();
    227206  Void    encodeStart               ();
    228 #endif
    229 #if LCU_SYNTAX_ALF
    230207  Void encodeAlfFlag(UInt code) {m_pcEntropyCoderIf->codeAlfFlag(code);}
    231208  Void encodeAlfStoredFilterSetIdx(UInt idx, UInt numFilterSetsInBuffer);
     
    236213  Int  getAlfRun(Int compIdx, AlfParamSet* pAlfParamSet, Int lcuIdxInSlice, Int lcuPos, Int startlcuPosX, Int endlcuPosX);
    237214  Void encodeAPSAlfFlag(UInt code) {m_pcEntropyCoderIf->codeAPSAlflag(code);}
    238 #endif 
    239215  Void encodeAlfParam(ALFParam* pAlfParam);
    240216 
     
    246222#endif
    247223  // SPS
    248 #if HHI_MPI
     224#if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068
    249225  Void encodeSPS               ( TComSPS* pcSPS, Bool bIsDepth );
    250226#else
     
    260236  Void encodeSplitFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
    261237#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      );
    263243#endif
    264244  Void encodeSkipFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
     
    270250  Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx );
    271251  Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD = false );
    272 #if HHI_INTER_VIEW_RESIDUAL_PRED
     252#if H3D_IVRP && !MTK_MDIVRP_C0138
    273253  Void encodeResPredFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD = false );
    274254#endif
     
    293273  Void encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    294274 
    295 #if !UNIFIED_TRANSFORM_TREE
    296   Void encodeTransformIdx      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
    297 #endif
    298275  Void encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx );
    299276  Void encodeQtCbf             ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth );
     
    316293
    317294private:
    318 #if UNIFIED_TRANSFORM_TREE
    319295  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 #else
    321   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_TREE
    324296public:
    325297  Void encodeCoeff             ( TComDataCU* pcCU,                 UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP );
     
    341313  Int golombEncode(int coeff, int k);
    342314  Int lengthGolomb(int coeffVal, int k);
    343 #if SAO_UNIT_INTERLEAVING
    344315  Void    encodeSaoUnit(Int rx, Int ry, Int compIdx, SAOParam* saoParam, Int repeatedRow);
    345316  Void    encodeSaoOffset(SaoLcuParam* saoLcuParam);
    346317  Void    encodeSaoUnitInterleaving(Int rx, Int ry, SAOParam* saoParam, TComDataCU* cu, Int cuAddrInSlice, Int cuAddrUpInSlice, Bool lfCrossSliceBoundaryFlag);
    347318  Void    encodeSaoParam         (TComAPS*  aps);
    348 #else
    349   Void    encodeSaoOnePart       (SAOParam* pSaoParam, Int iPartIdx, Int iYCbCr);
    350   Void    encodeQuadTreeSplitFlag(SAOParam* pSaoParam, Int iPartIdx, Int iYCbCr);
    351   Void    encodeSaoParam         (SAOParam* pSaoParam);
    352 #endif
    353319
    354320  static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize );
  • trunk/source/Lib/TLibEncoder/TEncGOP.cpp

    r210 r296  
    7878  m_pcDepthMapGenerator = NULL;
    7979#endif
    80 #if HHI_INTER_VIEW_RESIDUAL_PRED
     80#if H3D_IVRP
    8181  m_pcResidualGenerator = NULL;
    8282#endif
     
    131131  m_pcDepthMapGenerator  = pcTEncTop->getDepthMapGenerator();
    132132#endif
    133 #if HHI_INTER_VIEW_RESIDUAL_PRED
     133#if H3D_IVRP
    134134  m_pcResidualGenerator  = pcTEncTop->getResidualGenerator();
    135135#endif
     
    159159  TComOutputBitstream  *pcBitstreamRedirect;
    160160  pcBitstreamRedirect = new TComOutputBitstream;
    161 #if !REMOVE_TILE_DEPENDENCE
    162   OutputNALUnit        *naluBuffered             = NULL;
    163   Bool                  bIteratorAtListStart     = false;
    164 #endif
    165161  AccessUnit::iterator  itLocationToPushSliceHeaderNALU; // used to store location where NALU containing slice header is to be inserted
    166162  UInt                  uiOneBitstreamPerSliceLength = 0;
     
    247243      std::vector<TComAPS>& vAPS = m_pcEncTop->getAPS();
    248244#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
    249248    m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, uiPOCCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getEncTop()->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS() );
     249#endif
    250250#else
    251251      m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, uiPOCCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() );
     
    254254      pcSlice->setSliceIdx(0);
    255255      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
    257260
    258261      m_pcEncTop->getSPS()->setDisInter4x4(m_pcEncTop->getDisInter4x4());
     
    276279          pcSlice->setDefaultScalingList ();
    277280        }
    278 #if SCALING_LIST
    279281        pcSlice->getScalingList()->checkDcOfMatrix();
    280 #endif
    281282        pcSlice->getScalingList()->setScalingListPresentFlag(pcSlice->checkDefaultScalingList());
    282283        m_pcEncTop->getTrQuant()->setScalingList(pcSlice->getScalingList());
     
    326327      pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS());
    327328
    328 #if H0566_TLA && H0566_TLA_SET_FOR_SWITCHING_POINTS
     329#if H0566_TLA_SET_FOR_SWITCHING_POINTS
    329330      if(pcSlice->getTLayer() > 0)
    330331      {
     
    341342#else
    342343
    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 );
    352350      refPicListModification->setRefPicListModificationFlagL1( false );
    353 #if !H0137_0138_LIST_MODIFICATION
    354       refPicListModification->setNumberOfRefPicListModificationsL1(0);
    355 #endif
    356351      xSetRefPicListModificationsMvc( pcSlice, uiPOCCurr, iGOPid );
    357352
     
    518513      }
    519514
    520 #if H0111_MVD_L1_ZERO
    521515      Bool bGPBcheck=false;
    522516      if ( pcSlice->getSliceType() == B_SLICE)
     
    545539      }
    546540      pcPic->getSlice(pcSlice->getSliceIdx())->setMvdL1ZeroFlag(pcSlice->getMvdL1ZeroFlag());
    547 #endif
    548541
    549542      UInt uiNumSlices = 1;
     
    574567    UInt uiEncCUAddr;
    575568   
    576 #if !REMOVE_TILE_DEPENDENCE
    577     if(pcSlice->getPPS()->getTileBehaviorControlPresentFlag() == 1)
    578     {
    579       pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getTileBoundaryIndependenceIdr() );
    580     }
    581     else
    582     {
    583       pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getSPS()->getTileBoundaryIndependenceIdr() );
    584 
    585     }
    586 #endif
    587569
    588570    if( pcSlice->getPPS()->getColumnRowInfoPresent() == 1 )    //derive the tile parameters from PPS
     
    747729      // init view component and predict virtual depth map
    748730      m_pcDepthMapGenerator->initViewComponent( pcPic );
    749 #if !QC_MULTI_DIS_CAN_A0097
     731#if !H3D_NBDV
    750732      m_pcDepthMapGenerator->predictDepthMap  ( pcPic );
    751733#endif
    752734#endif
    753 #if HHI_INTER_VIEW_MOTION_PRED
     735#if H3D_IVMP
    754736      m_pcDepthMapGenerator->covertOrgDepthMap( pcPic );
    755737#endif
    756 #if HHI_INTER_VIEW_RESIDUAL_PRED
     738#if H3D_IVRP
    757739      m_pcResidualGenerator->initViewComponent( pcPic );
    758740#endif
    759741
    760 #if QC_SIMPLE_NBDV_B0047
     742#if H3D_NBDV
    761743      if(pcSlice->getViewId() && pcSlice->getSPS()->getMultiviewMvPredMode())
    762744      {
     
    818800      pcSlice = pcPic->getSlice(0);
    819801
    820 #if HHI_INTER_VIEW_RESIDUAL_PRED
     802#if H3D_IVRP
    821803      // set residual picture
    822804      m_pcResidualGenerator->setRecResidualPic( pcPic );
    823805#endif
    824806#if DEPTH_MAP_GENERATION
    825 #if !QC_MULTI_DIS_CAN_A0097
     807#if !H3D_NBDV
    826808      // update virtual depth map
    827809      m_pcDepthMapGenerator->updateDepthMap( pcPic );
     
    832814      Bool bLFCrossTileBoundary = (pcSlice->getPPS()->getTileBehaviorControlPresentFlag() == 1)?
    833815                                  (pcSlice->getPPS()->getLFCrossTileBoundaryFlag()):(pcSlice->getPPS()->getSPS()->getLFCrossTileBoundaryFlag());
    834 #if DBL_CONTROL
    835816      m_pcLoopFilter->setCfg(pcSlice->getPPS()->getDeblockingFilterControlPresent(), pcSlice->getLoopFilterDisable(), pcSlice->getLoopFilterBetaOffset(), pcSlice->getLoopFilterTcOffset(), bLFCrossTileBoundary);
    836 #else
    837       m_pcLoopFilter->setCfg(pcSlice->getLoopFilterDisable(), pcSlice->getLoopFilterBetaOffset(), pcSlice->getLoopFilterTcOffset(), bLFCrossTileBoundary);
    838 #endif
    839817      m_pcLoopFilter->loopFilterPic( pcPic );
    840818
     
    854832      }
    855833
    856 #if LCU_SYNTAX_ALF
    857834      AlfParamSet* alfSliceParams = NULL;
    858835      std::vector<AlfCUCtrlInfo>* alfCUCtrlParam = NULL;
    859 #else
    860       std::vector<AlfCUCtrlInfo> vAlfCUCtrlParam;
    861 #endif
    862836      pcSlice = pcPic->getSlice(0);
    863837
    864838      if(pcSlice->getSPS()->getUseALF())
    865839      {
    866 #if LCU_SYNTAX_ALF
    867840        m_pcAdaptiveLoopFilter->createPicAlfInfo(pcPic, uiNumSlices, pcSlice->getSliceQp());
    868841        m_pcAdaptiveLoopFilter->initALFEnc(m_pcCfg->getALFParamInSlice(), m_pcCfg->getALFPicBasedEncode(), uiNumSlices, alfSliceParams, alfCUCtrlParam);
    869 #else
    870         vAlfCUCtrlParam.resize(uiNumSlices);
    871         m_pcAdaptiveLoopFilter->createPicAlfInfo(pcPic, uiNumSlices);
    872 #endif
    873842      }
    874843
     
    893862        }
    894863#endif
    895 #if NAL_REF_FLAG
    896864#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    897865        OutputNALUnit nalu(NAL_UNIT_SPS, true, m_pcEncTop->getLayerId());
     
    899867        OutputNALUnit nalu(NAL_UNIT_SPS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
    900868#endif
    901 #else
    902         OutputNALUnit nalu(NAL_UNIT_SPS, NAL_REF_IDC_PRIORITY_HIGHEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
    903 #endif
    904869        m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    905 #if TILES_WPP_ENTRY_POINT_SIGNALLING
    906870        pcSlice->getSPS()->setNumSubstreams( pcSlice->getPPS()->getNumSubstreams() );
    907 #endif
    908 #if HHI_MPI
     871#if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068
    909872        m_pcEntropyCoder->encodeSPS(pcSlice->getSPS(), m_pcEncTop->getIsDepth());
    910873#else
     
    914877        accessUnit.push_back(new NALUnitEBSP(nalu));
    915878
    916 #if NAL_REF_FLAG
    917879#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    918880#if QC_MVHEVC_B0046
     
    923885#else
    924886        nalu = NALUnit(NAL_UNIT_PPS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
    925 #endif
    926 #else
    927         nalu = NALUnit(NAL_UNIT_PPS, NAL_REF_IDC_PRIORITY_HIGHEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
    928887#endif
    929888        m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    10501009        m_pcEntropyCoder->resetEntropy      ();
    10511010        /* start slice NALunit */
    1052 #if H0388
    1053 #if NAL_REF_FLAG
    10541011        OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced(),
    10551012#if !VIDYO_VPS_INTEGRATION &!QC_MVHEVC_B0046
     
    10571014#else
    10581015                           m_pcEncTop->getLayerId(), pcSlice->getTLayer() );
    1059 #endif
    1060 #else
    1061         OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced() ? NAL_REF_IDC_PRIORITY_HIGHEST: NAL_REF_IDC_PRIORITY_LOWEST,
    1062 #if !VIDYO_VPS_INTEGRATION
    1063                            m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer() );
    1064 #else
    1065                            m_pcEncTop->getLayerId(), pcSlice->getTLayer() );
    1066 #endif
    1067 #endif
    1068 #else
    1069         OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced() ? NAL_REF_IDC_PRIORITY_HIGHEST: NAL_REF_IDC_PRIORITY_LOWEST,
    1070 #if !VIDYO_VPS_INTEGRATION
    1071                            m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer(), true );
    1072 #else
    1073                            m_pcEncTop->getLayerId(), pcSlice->getTLayer(), true );
    1074 #endif
    1075 
    10761016#endif
    10771017           
     
    10961036          if (pcSlice->getSPS()->getUseALF())
    10971037          {
    1098 #if LCU_SYNTAX_ALF
    10991038            if(pcSlice->getAlfEnabledFlag())
    1100 #else
    1101             if(pcSlice->getAPS()->getAlfEnabled())
    1102 #endif
    11031039            {
    11041040
    1105 #if LCU_SYNTAX_ALF
    11061041              if( pcSlice->getSPS()->getUseALFCoefInSlice())
    11071042              {
     
    11151050              {
    11161051                AlfCUCtrlInfo& cAlfCUCtrlParam = (*alfCUCtrlParam)[pcSlice->getSliceIdx()];
    1117 #else
    1118               AlfCUCtrlInfo& cAlfCUCtrlParam = vAlfCUCtrlParam[pcSlice->getSliceIdx()];
    1119 #endif
    11201052              if(cAlfCUCtrlParam.cu_control_flag)
    11211053              {
     
    11311063              m_pcEntropyCoder->encodeAlfCtrlParam(cAlfCUCtrlParam, m_pcAdaptiveLoopFilter->getNumCUsInPic());
    11321064           
    1133 #if LCU_SYNTAX_ALF
    11341065              }
    1135 #endif           
    11361066            }
    11371067          }
     
    12071137          UInt uiTotalCodedSize = 0; // for padding calcs.
    12081138          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          {
    12151141            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          }
    12261143          for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ )
    12271144          {
     
    12331150            m_pcEntropyCoder->encodeSliceFinish();
    12341151            pcSubstreamsOut[ui].write( 1, 1 ); // stop bit.
    1235 #if TILES_WPP_ENTRY_POINT_SIGNALLING
    12361152            pcSubstreamsOut[ui].writeAlignZero();
    1237 #endif
    12381153            // Byte alignment is necessary between tiles when tiles are independent.
    12391154            uiTotalCodedSize += pcSubstreamsOut[ui].getNumberOfWrittenBits();
     
    12621177          m_pcEntropyCoder->setEntropyCoder   ( m_pcCavlcCoder, pcSlice );
    12631178          m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    1264 #if TILES_WPP_ENTRY_POINT_SIGNALLING
    12651179          if (m_pcCfg->getTileLocationInSliceHeaderFlag()==0)
    12661180          {
     
    12681182          }
    12691183          m_pcEntropyCoder->encodeTilesWPPEntryPoint( pcSlice );
    1270 #else
    1271           m_pcEntropyCoder->encodeSliceHeaderSubstreamTable(pcSlice);
    1272 #endif
    12731184          // Substreams...
    12741185          TComOutputBitstream *pcOut = pcBitstreamRedirect;
     
    13021213        uiBoundingAddrEntropySlice = m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx];         
    13031214        uiNextCUAddr               = min(uiBoundingAddrSlice, uiBoundingAddrEntropySlice);
    1304 #if !REMOVE_TILE_DEPENDENCE
    1305         Bool bNextCUInNewSlice     = (uiNextCUAddr >= uiRealEndAddress) || (uiNextCUAddr == m_uiStoredStartCUAddrForEncodingSlice[uiStartCUAddrSliceIdx]);
    1306 #endif
    13071215        // If current NALU is the first NALU of slice (containing slice header) and more NALUs exist (due to multiple entropy slices) then buffer it.
    13081216        // 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.
    13091217        Bool bNALUAlignedWrittenToList    = false; // used to ensure current NALU is not written more than once to the NALU list.
    1310 #if !REMOVE_TILE_DEPENDENCE
    1311         if (pcSlice->getSPS()->getTileBoundaryIndependenceIdr() && !pcSlice->getSPS()->getTileBoundaryIndependenceIdr())
    1312         {
    1313           if (bNextCUInNewSlice)
    1314           {
    1315             if (!bEntropySlice) // there were no entropy slices
    1316             {
    1317               xWriteTileLocationToSliceHeader(nalu, pcBitstreamRedirect, pcSlice);
    1318             }
    1319             // (a) writing current NALU
    1320             writeRBSPTrailingBits(nalu.m_Bitstream);
    1321             accessUnit.push_back(new NALUnitEBSP(nalu));
    1322             bNALUAlignedWrittenToList = true;
    1323 
    1324             // (b) update and write buffered NALU
    1325             if (bEntropySlice) // if entropy slices existed in the slice then perform concatenation for the buffered nalu-bitstream and buffered payload bitstream
    1326             {
    1327               // Perform bitstream concatenation of slice header and partial slice payload
    1328               xWriteTileLocationToSliceHeader((*naluBuffered), pcBitstreamRedirect, pcSlice);
    1329               if (bIteratorAtListStart)
    1330               {
    1331                 itLocationToPushSliceHeaderNALU = accessUnit.begin();
    1332               }
    1333               else
    1334               {
    1335                 itLocationToPushSliceHeaderNALU++;
    1336               }
    1337               accessUnit.insert(itLocationToPushSliceHeaderNALU, (new NALUnitEBSP((*naluBuffered))) );
    1338 
    1339               // free buffered nalu
    1340               delete naluBuffered;
    1341               naluBuffered     = NULL;
    1342             }
    1343           }
    1344           else // another entropy slice exists
    1345           {
    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 list
    1350               itLocationToPushSliceHeaderNALU = accessUnit.end();
    1351               if (accessUnit.begin() == accessUnit.end())
    1352               {
    1353                 bIteratorAtListStart = true;
    1354               }
    1355               else
    1356               {
    1357                 bIteratorAtListStart = false;
    1358                 itLocationToPushSliceHeaderNALU--;
    1359               }
    1360 
    1361               // buffer nalu for later writing
    1362 #if H0388
    1363               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 #else
    1365               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 #endif
    1367               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-alignment
    1373             }
    1374             else // write out entropy slice
    1375             {
    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-alignment
    1380             }
    1381           }
    1382         }
    1383         else
    1384         {
    1385 #endif
    13861218        xWriteTileLocationToSliceHeader(nalu, pcBitstreamRedirect, pcSlice);
    13871219        writeRBSPTrailingBits(nalu.m_Bitstream);
     
    13891221        bNALUAlignedWrittenToList = true;
    13901222        uiOneBitstreamPerSliceLength += nalu.m_Bitstream.getNumberOfWrittenBits(); // length of bitstream after byte-alignment
    1391 #if !REMOVE_TILE_DEPENDENCE
    1392         }
    1393 #endif
    13941223
    13951224        if (!bNALUAlignedWrittenToList)
     
    14101239            TComAPS cAPS;
    14111240            allocAPS(&cAPS, pcSlice->getSPS());
    1412 #if SAO_UNIT_INTERLEAVING
    14131241            cAPS.setSaoInterleavingFlag(m_pcCfg->getSaoInterleavingFlag());
    1414 #endif
    14151242            // set entropy coder for RD
    14161243            m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice );
     
    14381265
    14391266            // adaptive loop filter
    1440 #if !LCU_SYNTAX_ALF
    1441             UInt64 uiDist, uiBits;
    1442 #endif
    14431267            if ( pcSlice->getSPS()->getUseALF())
    14441268            {
     
    14461270              m_pcEntropyCoder->setBitstream    ( m_pcBitCounter );
    14471271              m_pcAdaptiveLoopFilter->startALFEnc(pcPic, m_pcEntropyCoder );
    1448 #if LCU_SYNTAX_ALF
    14491272              AlfParamSet* pAlfEncParam = (pcSlice->getSPS()->getUseALFCoefInSlice())?( alfSliceParams ):( cAPS.getAlfParam());
    14501273#if ALF_CHROMA_LAMBDA
     
    14701293#endif
    14711294
    1472 #else
    1473               ALFParam& cAlfParam = *( cAPS.getAlfParam());
    1474 
    1475 #if ALF_CHROMA_LAMBDA
    1476 #if HHI_INTERVIEW_SKIP
    1477               m_pcAdaptiveLoopFilter->ALFProcess( &cAlfParam, &vAlfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma(), uiDist, uiBits, m_pcEncTop->getInterViewSkip());
    1478 #else
    1479               m_pcAdaptiveLoopFilter->ALFProcess( &cAlfParam, &vAlfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma(), uiDist, uiBits);
    1480 #endif
    1481 #else
    1482 #if SAO_CHROMA_LAMBDA
    1483 #if HHI_INTERVIEW_SKIP
    1484               m_pcAdaptiveLoopFilter->ALFProcess( &cAlfParam, &vAlfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), uiDist, uiBits, m_pcEncTop->getInterViewSkip());
    1485 #else
    1486               m_pcAdaptiveLoopFilter->ALFProcess( &cAlfParam, &vAlfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), uiDist, uiBits);
    1487 #endif
    1488 #else
    1489 #if HHI_INTERVIEW_SKIP
    1490               m_pcAdaptiveLoopFilter->ALFProcess( &cAlfParam, &vAlfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), uiDist, uiBits, m_pcEncTop->getInterViewSkip());
    1491 #else
    1492               m_pcAdaptiveLoopFilter->ALFProcess( &cAlfParam, &vAlfCUCtrlParam, pcPic->getSlice(0)->getLambda(), uiDist, uiBits);
    1493 #endif
    1494 #endif
    1495 #endif
    1496 #endif
    14971295              m_pcAdaptiveLoopFilter->endALFEnc();
    14981296
     
    15111309              if (pcSlice->getSPS()->getUseALF())
    15121310              {
    1513 #if LCU_SYNTAX_ALF
    15141311                pcPic->getSlice(s)->setAlfEnabledFlag(  (pcSlice->getSPS()->getUseALFCoefInSlice())?(alfSliceParams[s].isEnabled[ALF_Y]):(cAPS.getAlfEnabled())   );
    1515 #else
    1516                 pcPic->getSlice(s)->setAlfEnabledFlag((cAPS.getAlfParam()->alf_flag==1)?true:false);
    1517 #endif
    15181312              }
    15191313              if (pcSlice->getSPS()->getUseSAO())
     
    15281322        case ENCODE_APS:
    15291323          {
    1530 #if NAL_REF_FLAG
    15311324#if VIDYO_VPS_INTEGRATION | QC_MVHEVC_B0046
    15321325            OutputNALUnit nalu(NAL_UNIT_APS, true, m_pcEncTop->getLayerId());
    15331326#else
    15341327            OutputNALUnit nalu(NAL_UNIT_APS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
    1535 #endif
    1536 #else
    1537             OutputNALUnit nalu(NAL_UNIT_APS, NAL_REF_IDC_PRIORITY_HIGHEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
    15381328#endif
    15391329            encodeAPS(&(vAPS[iCodedAPSIdx]), nalu.m_Bitstream, pcSliceForAPS);
     
    15621352        if(pcSlice->getSPS()->getUseALF())
    15631353        {
    1564 #if LCU_SYNTAX_ALF
    15651354          m_pcAdaptiveLoopFilter->uninitALFEnc(alfSliceParams, alfCUCtrlParam);
    1566 #endif
    15671355          m_pcAdaptiveLoopFilter->destroyPicAlfInfo();
    15681356        }
     
    15751363        pcPic->removeUsedPelsMapBuffer() ;
    15761364#endif
    1577 #if HHI_INTER_VIEW_MOTION_PRED
     1365#if H3D_IVMP
    15781366      pcPic->removeOrgDepthMapBuffer();
    15791367#endif
     
    15941382        digestStr = digestToString(sei_recon_picture_digest.digest);
    15951383
    1596 #if NAL_REF_FLAG
    15971384#if VIDYO_VPS_INTEGRATION | QC_MVHEVC_B0046
    15981385        OutputNALUnit nalu(NAL_UNIT_SEI, false, m_pcEncTop->getLayerId());
    15991386#else
    16001387        OutputNALUnit nalu(NAL_UNIT_SEI, false, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
    1601 #endif
    1602 #else
    1603         OutputNALUnit nalu(NAL_UNIT_SEI, NAL_REF_IDC_PRIORITY_LOWEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
    16041388#endif
    16051389
     
    16561440  {
    16571441    pAPS->createAlfParam();
    1658 #if LCU_SYNTAX_ALF
    16591442    //alf Enabled flag in APS is false after pAPS->createAlfParam();
    16601443    if(!pSPS->getUseALFCoefInSlice())
     
    16631446      pAPS->getAlfParam()->createALFParam();
    16641447    }
    1665 #else
    1666     m_pcAdaptiveLoopFilter->allocALFParam(pAPS->getAlfParam());
    1667 #endif
    16681448  }
    16691449}
     
    16881468    if(pAPS->getAlfParam() != NULL)
    16891469    {
    1690 #if LCU_SYNTAX_ALF
    16911470      if(!pSPS->getUseALFCoefInSlice())
    16921471      {
    16931472        pAPS->getAlfParam()->releaseALFParam();
    16941473      }
    1695 #else
    1696       m_pcAdaptiveLoopFilter->freeALFParam(pAPS->getAlfParam());
    1697 #endif
    16981474      pAPS->destroyAlfParam();
    16991475    }
     
    17211497
    17221498  cAPS.setSaoEnabled(pcSlice->getSPS()->getUseSAO() ? (cAPS.getSaoParam()->bSaoFlag[0] ):(false));
    1723 #if LCU_SYNTAX_ALF
    17241499  cAPS.setAlfEnabled(pcSlice->getSPS()->getUseALF() ? (cAPS.getAlfParam()->isEnabled[0]):(false));
    1725 #else
    1726   cAPS.setAlfEnabled(pcSlice->getSPS()->getUseALF() ? (cAPS.getAlfParam()->alf_flag ==1):(false));
    1727 #endif
    17281500  cAPS.setLoopFilterOffsetInAPS(m_pcCfg->getLoopFilterOffsetInAPS());
    17291501  cAPS.setLoopFilterDisable(m_pcCfg->getLoopFilterDisable());
     
    17641536    m_pcEntropyCoder->encodeDFParams(pcAPS);
    17651537  }
    1766 #if SAO_UNIT_INTERLEAVING
    17671538  m_pcEntropyCoder->encodeSaoParam(pcAPS);
    1768 #else
    1769   if(pcAPS->getSaoEnabled())
    1770   {
    1771     m_pcEntropyCoder->encodeSaoParam(pcAPS->getSaoParam());
    1772   }
    1773 #endif
    1774 #if LCU_SYNTAX_ALF
    17751539  m_pcEntropyCoder->encodeAPSAlfFlag( pcAPS->getAlfEnabled()?1:0);
    1776 #endif
    17771540  if(pcAPS->getAlfEnabled())
    17781541  {
     
    17891552  TComSlice* pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx());
    17901553  Bool bCalcDist = false;
    1791 #if DBL_CONTROL
    17921554  m_pcLoopFilter->setCfg(pcSlice->getPPS()->getDeblockingFilterControlPresent(), pcSlice->getLoopFilterDisable(), m_pcCfg->getLoopFilterBetaOffset(), m_pcCfg->getLoopFilterTcOffset(), m_pcCfg->getLFCrossTileBoundaryFlag());
    1793 #else
    1794   m_pcLoopFilter->setCfg(pcSlice->getLoopFilterDisable(), m_pcCfg->getLoopFilterBetaOffset(), m_pcCfg->getLoopFilterTcOffset(), m_pcCfg->getLFCrossTileBoundaryFlag());
    1795 #endif
    17961555  m_pcLoopFilter->loopFilterPic( pcPic );
    17971556 
     
    18101569    m_pcAdaptiveLoopFilter->createPicAlfInfo(pcPic);
    18111570
    1812 #if LCU_SYNTAX_ALF
    18131571    AlfParamSet* alfParamSet;
    18141572    std::vector<AlfCUCtrlInfo>* alfCUCtrlParam = NULL;
     
    18171575    alfParamSet->createALFParam();
    18181576    m_pcAdaptiveLoopFilter->initALFEnc(false, true, 1, alfParamSet, alfCUCtrlParam);
    1819 #else
    1820     ALFParam cAlfParam;
    1821     m_pcAdaptiveLoopFilter->allocALFParam(&cAlfParam);
    1822 #endif   
    18231577    m_pcAdaptiveLoopFilter->startALFEnc(pcPic, m_pcEntropyCoder);
    18241578   
    18251579
    1826 #if LCU_SYNTAX_ALF
    18271580
    18281581#if ALF_CHROMA_LAMBDA
     
    18481601#endif
    18491602
    1850 #else
    1851 #if ALF_CHROMA_LAMBDA 
    1852     m_pcAdaptiveLoopFilter->ALFProcess(&cAlfParam, NULL, pcSlice->getLambdaLuma(), pcSlice->getLambdaChroma(), ruiDist, ruiBits, m_pcEncTop->getInterViewSkip());
    1853 #if HHI_INTERVIEW_SKIP
    1854 #else
    1855     m_pcAdaptiveLoopFilter->ALFProcess(&cAlfParam, NULL, pcSlice->getLambdaLuma(), pcSlice->getLambdaChroma(), ruiDist, ruiBits);
    1856 #endif
    1857 #else
    1858 #if SAO_CHROMA_LAMBDA
    1859 #if HHI_INTERVIEW_SKIP
    1860     m_pcAdaptiveLoopFilter->ALFProcess(&cAlfParam, NULL, pcSlice->getLambdaLuma(), ruiDist, ruiBits, m_pcEncTop->getInterViewSkip());
    1861 #else
    1862     m_pcAdaptiveLoopFilter->ALFProcess(&cAlfParam, NULL, pcSlice->getLambdaLuma(), ruiDist, ruiBits);
    1863 #endif
    1864 #else
    1865 #if HHI_INTERVIEW_SKIP
    1866     m_pcAdaptiveLoopFilter->ALFProcess(&cAlfParam, NULL, pcSlice->getLambda(), ruiDist, ruiBits, m_pcEncTop->getInterViewSkip());
    1867 #else
    1868     m_pcAdaptiveLoopFilter->ALFProcess(&cAlfParam, NULL, pcSlice->getLambda(), ruiDist, ruiBits);
    1869 #endif
    1870 #endif
    1871 
    1872 #endif
    1873 #endif
    18741603    m_pcAdaptiveLoopFilter->endALFEnc();
    18751604
    1876 #if LCU_SYNTAX_ALF
    18771605    alfParamSet->releaseALFParam();
    18781606    delete alfParamSet;
    18791607    delete alfCUCtrlParam;
    1880 #else
    1881     m_pcAdaptiveLoopFilter->freeALFParam(&cAlfParam);
    1882 #endif
    18831608    m_pcAdaptiveLoopFilter->PCMLFDisableProcess(pcPic);
    18841609    m_pcAdaptiveLoopFilter->destroyPicAlfInfo();
     
    20321757  {
    20331758  case NAL_UNIT_CODED_SLICE: return "SLICE";
    2034 #if H0566_TLA
    20351759#if !QC_REM_IDV_B0046
    20361760  case NAL_UNIT_CODED_SLICE_IDV: return "IDV";
     
    20381762  case NAL_UNIT_CODED_SLICE_CRA: return "CRA";
    20391763  case NAL_UNIT_CODED_SLICE_TLA: return "TLA";
    2040 #else
    2041   case NAL_UNIT_CODED_SLICE_CDR: return "CDR";
    2042 #endif
    20431764  case NAL_UNIT_CODED_SLICE_IDR: return "IDR";
    20441765  case NAL_UNIT_SEI: return "SEI";
     
    22751996      else
    22761997      {
    2277 #if H0566_TLA
    22781998      return NAL_UNIT_CODED_SLICE_CRA;
    2279 #else
    2280       return NAL_UNIT_CODED_SLICE_CDR;
    2281 #endif
    22821999      }
    22832000    }
     
    23112028    if( m_pcCfg->getDecodingRefreshType() == 1 )
    23122029    {
    2313 #if H0566_TLA
    23142030      return NAL_UNIT_CODED_SLICE_CRA;
    2315 #else
    2316       return NAL_UNIT_CODED_SLICE_CDR;
    2317 #endif
    23182031    }
    23192032    else if( m_pcCfg->getDecodingRefreshType() == 2 )
     
    23772090{
    23782091  {
    2379 #if !TILES_WPP_ENTRY_POINT_SIGNALLING
    2380     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 header
    2382 
    2383     if (iTransmitTileLocationInSliceHeader)
    2384     {
    2385       rNalu.m_Bitstream.write(rpcSlice->getTileLocationCount()-1, 5);   // write number of tiles
    2386 
    2387       Int *aiDiff;
    2388       aiDiff = new Int [rpcSlice->getTileLocationCount()];
    2389 
    2390       // Find largest number of bits required by Diff
    2391       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         else
    2401         {
    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         else
    2432         {
    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 information
    2443       }
    2444 
    2445       rNalu.m_Bitstream.write( iBitsUsedByDiff-1, 5 ); // write number of bits used by Diff
    2446 
    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 diff
    2453         if (uiIdx!=0)
    2454         {
    2455           if (iCurDiff<0)         
    2456           {
    2457             rNalu.m_Bitstream.write(1, 1);
    2458           }
    2459           else
    2460           {
    2461             rNalu.m_Bitstream.write(0, 1);
    2462           }
    2463         }
    2464 
    2465         // write abs value of diff
    2466         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 #endif
    24782092  }
    24792093
  • trunk/source/Lib/TLibEncoder/TEncGOP.h

    r189 r296  
    9797  TComDepthMapGenerator*  m_pcDepthMapGenerator;
    9898#endif
    99 #if HHI_INTER_VIEW_RESIDUAL_PRED
     99#if H3D_IVRP
    100100  TComResidualGenerator*  m_pcResidualGenerator;
    101101#endif
  • trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp

    r56 r296  
    100100 * \param  *psQTPart, iPartIdx, dLambda
    101101 */
    102 #if SAO_UNIT_INTERLEAVING
    103102Void TEncSampleAdaptiveOffset::rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda)
    104103{
     
    340339}
    341340
    342 #else
    343 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     else
    368     {
    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_NBIT
    385           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 #else
    387           m_iOffset[iPartIdx][iTypeIdx][iClassIdx] = (Int64) xRoundIbdi((Double)(m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx]<<g_uiBitIncrement) / (Double)(m_iCount [iPartIdx][iTypeIdx][iClassIdx]<<m_uiSaoBitIncrease));
    388 #endif
    389           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 offset
    403               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 calculation
    413               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         else
    427         {
    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     else
    453     {
    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   else
    478   {
    479     pOnePart->bEnableFlag = 0;
    480     pOnePart->iLength     = 0;
    481   }
    482 }
    483 
    484 #endif
    485341/** Run partition tree disable
    486342 */
     
    488344{
    489345  SAOQTPart*  pOnePart= &(psQTPart[iPartIdx]);
    490 #if !SAO_UNIT_INTERLEAVING
    491   pOnePart->bEnableFlag = false;
    492 #endif
    493346  pOnePart->bSplit      = false;
    494347  pOnePart->iLength     =  0;
     
    556409      dCostFinal = dCostSplit;
    557410      pOnePart->bSplit      = true;
    558 #if !SAO_UNIT_INTERLEAVING
    559       pOnePart->bEnableFlag = false;
    560 #endif
    561411      pOnePart->iLength     =  0;
    562412      pOnePart->iBestType   = -1;
     
    810660  Int x, y;
    811661
    812 #if SAO_UNIT_INTERLEAVING
    813662  //--------- Band offset-----------//
    814663  stats = ppStats[SAO_BO];
     
    830679    pRec += stride;
    831680  }
    832 #else
    833   //--------- 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 #endif
    874681  //---------- Edge offset 0--------------//
    875682  stats = ppStats[SAO_EO_0];
     
    1166973
    1167974  Int iIsChroma = (iYCbCr!=0)? 1:0;
    1168 #if SAO_UNIT_INTERLEAVING
    1169975  Int numSkipLine = iIsChroma? 2:4;
    1170976  if (m_saoInterleavingFlag == 0)
     
    1172978    numSkipLine = 0;
    1173979  }
    1174 #endif
    1175980
    1176981  iPicWidthTmp  = m_iPicWidth  >> iIsChroma;
     
    1194999#endif
    11951000  {
    1196 #if SAO_UNIT_INTERLEAVING
    11971001    iStats = m_iOffsetOrg[iPartIdx][SAO_BO];
    11981002    iCount = m_iCount    [iPartIdx][SAO_BO];
    1199 #else
    1200     iStats = m_iOffsetOrg[iPartIdx][SAO_BO_0];
    1201     iCount = m_iCount    [iPartIdx][SAO_BO_0];
    1202 #endif
    12031003
    12041004    pOrg = getPicYuvAddr(m_pcPic->getPicYuvOrg(), iYCbCr, iAddr);
    12051005    pRec = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr, iAddr);
    12061006
    1207 #if SAO_UNIT_INTERLEAVING
    12081007    iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight : iLcuHeight-numSkipLine;
    12091008    for (y=0; y<iEndY; y++)
    1210 #else
    1211     for (y=0; y<iLcuHeight; y++)
    1212 #endif
    12131009    {
    12141010      for (x=0; x<iLcuWidth; x++)
    12151011      {
    1216 #if SAO_UNIT_INTERLEAVING
    12171012        iClassIdx = m_lumaTableBo[pRec[x]];
    1218 #else
    1219         iClassIdx = m_ppLumaTableBo0[pRec[x]];
    1220 #endif
    12211013        if (iClassIdx)
    12221014        {
     
    12291021    }
    12301022
    1231 #if !SAO_UNIT_INTERLEAVING
    1232     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 #endif
    12531023  }
    12541024  Int iSignLeft;
     
    12751045      iStartX = (uiLPelX == 0) ? 1 : 0;
    12761046      iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth;
    1277 #if SAO_UNIT_INTERLEAVING
    12781047      for (y=0; y<iLcuHeight-numSkipLine; y++)
    1279 #else
    1280       for (y=0; y<iLcuHeight; y++)
    1281 #endif
    12821048      {
    12831049        iSignLeft = xSign(pRec[iStartX] - pRec[iStartX-1]);
     
    13051071
    13061072      iStartY = (uiTPelY == 0) ? 1 : 0;
    1307 #if SAO_UNIT_INTERLEAVING
    13081073      iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine;
    1309 #else
    1310       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;
    1311 #endif
    13121074      if (uiTPelY == 0)
    13131075      {
     
    13471109
    13481110      iStartY = (uiTPelY == 0) ? 1 : 0;
    1349 #if SAO_UNIT_INTERLEAVING
    13501111      iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine;
    1351 #else
    1352       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;
    1353 #endif
    13541112      if (uiTPelY == 0)
    13551113      {
     
    13941152
    13951153      iStartY = (uiTPelY == 0) ? 1 : 0;
    1396 #if SAO_UNIT_INTERLEAVING
    13971154      iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight-numSkipLine;
    1398 #else
    1399       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;
    1400 #endif
    14011155      if (iStartY == 1)
    14021156      {
     
    14861240          for (iTypeIdx=0; iTypeIdx<iNumTotalType; iTypeIdx++)
    14871241          {
    1488 #if SAO_UNIT_INTERLEAVING
    14891242            for (iClassIdx=0; iClassIdx< (iTypeIdx < SAO_BO ? m_iNumClass[iTypeIdx] : SAO_MAX_BO_CLASSES) +1; iClassIdx++)
    1490 #else
    1491             for (iClassIdx=0; iClassIdx<m_iNumClass[iTypeIdx]+1; iClassIdx++)
    1492 #endif
    14931243            {
    14941244              m_iOffsetOrg[iPartIdx][iTypeIdx][iClassIdx] += m_iOffsetOrg[iDownPartIdx][iTypeIdx][iClassIdx];
     
    15741324  Double dCostFinal = 0;
    15751325
    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
    15841327  if ( m_saoInterleavingFlag)
    15851328  {
     
    16161359    }
    16171360  }
    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}
    16471362/** Check merge SAO unit
    16481363 * \param saoUnitCurr current SAO unit
     
    22601975}
    22611976
    2262 #endif
    22631977
    22641978//! \}
  • trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h

    r56 r296  
    101101  Void destroyEncBuffer();
    102102  Void createEncBuffer();
    103 #if SAO_UNIT_INTERLEAVING
    104103  Void assignSaoUnitSyntax(SaoLcuParam* saoLcuParam,  SAOQTPart* saoPart, Bool &oneUnitFlag, Int yCbCr);
    105104  Void checkMerge(SaoLcuParam * lcuParamCurr,SaoLcuParam * lcuParamCheck, Int dir);
     
    108107  Void setMaxNumOffsetsPerPic(Int iVal) {m_maxNumOffsetsPerPic = iVal; }
    109108  Int  getMaxNumOffsetsPerPic() {return m_maxNumOffsetsPerPic; }
    110 #endif
    111109};
    112110
  • trunk/source/Lib/TLibEncoder/TEncSbac.cpp

    r210 r296  
    7070, m_cCUMergeFlagExtSCModel    ( 1,             1,               NUM_MERGE_FLAG_EXT_CTX        , m_contextModels + m_numContextModels, m_numContextModels)
    7171, m_cCUMergeIdxExtSCModel     ( 1,             1,               NUM_MERGE_IDX_EXT_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
    72 #if HHI_INTER_VIEW_RESIDUAL_PRED
     72#if H3D_IVRP
    7373, m_cResPredFlagSCModel       ( 1,             1,               NUM_RES_PRED_FLAG_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
    7474#endif
     
    9595, m_cALFUvlcSCModel           ( 1,             1,               NUM_ALF_UVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    9696, m_cALFSvlcSCModel           ( 1,             1,               NUM_ALF_SVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    97 #if AMP_CTX
    9897, m_cCUAMPSCModel             ( 1,             1,               NUM_CU_AMP_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
    99 #else
    100 , 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 #endif
    10398, m_cSaoFlagSCModel           ( 1,             1,               NUM_SAO_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    10499, m_cSaoUvlcSCModel           ( 1,             1,               NUM_SAO_UVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    105100, m_cSaoSvlcSCModel           ( 1,             1,               NUM_SAO_SVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    106 #if SAO_UNIT_INTERLEAVING
    107101, m_cSaoMergeLeftSCModel      ( 1,             1,               NUM_SAO_MERGE_LEFT_FLAG_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
    108102, m_cSaoMergeUpSCModel        ( 1,             1,               NUM_SAO_MERGE_UP_FLAG_CTX     , m_contextModels + m_numContextModels, m_numContextModels)
    109103, m_cSaoTypeIdxSCModel        ( 1,             1,               NUM_SAO_TYPE_IDX_CTX          , m_contextModels + m_numContextModels, m_numContextModels)
    110 #endif
    111104#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    112105, m_cDmmFlagSCModel           ( 1,             1,               NUM_DMM_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
     
    162155  m_cCUMergeFlagExtSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT);
    163156  m_cCUMergeIdxExtSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT);
    164 #if HHI_INTER_VIEW_RESIDUAL_PRED
     157#if H3D_IVRP
    165158  m_cResPredFlagSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_RES_PRED_FLAG );
    166159#endif
    167160  m_cCUPartSizeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
    168 #if AMP_CTX
    169161  m_cCUAMPSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );
    170 #else
    171   m_cCUXPosiSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_CU_X_POS );
    172   m_cCUYPosiSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_CU_Y_POS );
    173 #endif
    174162  m_cCUPredModeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );
    175163  m_cCUIntraPredSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE );
     
    195183  m_cSaoUvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_SAO_UVLC );
    196184  m_cSaoSvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_SAO_SVLC );
    197 #if SAO_UNIT_INTERLEAVING
    198185  m_cSaoMergeLeftSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG );
    199186  m_cSaoMergeUpSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_UP_FLAG );
    200187  m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
    201 #endif
    202188#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    203189  m_cDmmFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_FLAG );
     
    255241      curCost += m_cCUMergeFlagExtSCModel.calcCost    ( curSliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT);
    256242      curCost += m_cCUMergeIdxExtSCModel.calcCost     ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT);
    257 #if HHI_INTER_VIEW_RESIDUAL_PRED
     243#if H3D_IVRP
    258244      curCost += m_cResPredFlagSCModel.calcCost       ( curSliceType, qp, (UChar*)INIT_RES_PRED_FLAG);
    259245#endif
    260246      curCost += m_cCUPartSizeSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_PART_SIZE );
    261 #if AMP_CTX
    262247      curCost += m_cCUAMPSCModel.calcCost             ( curSliceType, qp, (UChar*)INIT_CU_AMP_POS );
    263 #else
    264       curCost += m_cCUXPosiSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_CU_X_POS );
    265       curCost += m_cCUYPosiSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_CU_Y_POS );
    266 #endif
    267248      curCost += m_cCUPredModeSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_PRED_MODE );
    268249      curCost += m_cCUIntraPredSCModel.calcCost       ( curSliceType, qp, (UChar*)INIT_INTRA_PRED_MODE );
     
    288269      curCost += m_cSaoUvlcSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_SAO_UVLC );
    289270      curCost += m_cSaoSvlcSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_SAO_SVLC );
    290 #if SAO_UNIT_INTERLEAVING
    291271      curCost += m_cSaoMergeLeftSCModel.calcCost      ( curSliceType, qp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG );
    292272      curCost += m_cSaoMergeUpSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_SAO_MERGE_UP_FLAG );
    293273      curCost += m_cSaoTypeIdxSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_SAO_TYPE_IDX );
    294 #endif
    295274
    296275      if (curCost < bestCost)
     
    329308  m_cCUMergeFlagExtSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT);
    330309  m_cCUMergeIdxExtSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT);
    331 #if HHI_INTER_VIEW_RESIDUAL_PRED
     310#if H3D_IVRP
    332311  m_cResPredFlagSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_RES_PRED_FLAG );
    333312#endif
    334313  m_cCUPartSizeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
    335 #if AMP_CTX
    336314  m_cCUAMPSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );
    337 #else
    338   m_cCUXPosiSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_CU_X_POS );
    339   m_cCUYPosiSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_CU_Y_POS );
    340 #endif
    341315  m_cCUPredModeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );
    342316  m_cCUIntraPredSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE );
     
    362336  m_cSaoUvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_SAO_UVLC );
    363337  m_cSaoSvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_SAO_SVLC );
    364 #if SAO_UNIT_INTERLEAVING
    365338  m_cSaoMergeLeftSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG );
    366339  m_cSaoMergeUpSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_UP_FLAG );
    367340  m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
    368 #endif
    369341#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    370342  m_cDmmFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_FLAG );
     
    404376#endif
    405377
    406 #if HHI_MPI
     378#if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068
    407379Void TEncSbac::codeSPS( TComSPS* pcSPS, Bool bIsDepth )
    408380#else
     
    426398}
    427399
    428 #if TILES_WPP_ENTRY_POINT_SIGNALLING
    429400Void TEncSbac::codeTilesWPPEntryPoint( TComSlice* pSlice )
    430401{
     
    432403  return;
    433404}
    434 #else
    435 Void TEncSbac::codeSliceHeaderSubstreamTable( TComSlice* pcSlice )
    436 {
    437   assert (0);
    438 }
    439 #endif
    440405
    441406Void TEncSbac::codeTerminatingBit( UInt uilsLast )
     
    449414}
    450415
    451 #if OL_FLUSH
    452416Void TEncSbac::codeFlush()
    453417{
     
    459423  m_pcBinIf->start();
    460424}
    461 #endif
    462425
    463426Void TEncSbac::xWriteUnarySymbol( UInt uiSymbol, ContextModel* pcSCModel, Int iOffset )
     
    557520  m_pcBinIf->encodeBinsEP( ( binValues << ruiGoRiceParam ) + uiCodeWord - ( uiQuotient << ruiGoRiceParam ), numBins + ruiGoRiceParam );
    558521 
    559 #if EIGHT_BITS_RICE_CODE
    560522  ruiGoRiceParam = g_aauiGoRiceUpdate[ ruiGoRiceParam ][ min<UInt>( uiSymbol, 23 ) ];
    561 #else
    562   ruiGoRiceParam = g_aauiGoRiceUpdate[ ruiGoRiceParam ][ min<UInt>( uiSymbol, 15 ) ];
    563 #endif
    564523 
    565524  if( bExGolomb )
     
    600559}
    601560
    602 #if HHI_INTER_VIEW_MOTION_PRED
     561#if H3D_IVMP
    603562Void TEncSbac::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum )
    604563#else
     
    607566{
    608567  Int iSymbol = pcCU->getMVPIdx(eRefList, uiAbsPartIdx);
    609 #if HHI_INTER_VIEW_MOTION_PRED
     568#if H3D_IVMP
    610569#else
    611570  Int iNum = AMVP_MAX_NUM_CANDS;
     
    625584  Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE);
    626585 
     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
    627590  if(bDepthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC() && pcCU->getPic()->getReduceBitsFlag())
     591#endif
    628592  {
    629593    TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr());
     
    664628        if (eSize == SIZE_2NxN)
    665629        {
    666 #if AMP_CTX           
    667630          m_pcBinIf->encodeBin(1, m_cCUAMPSCModel.get( 0, 0, 0 ));
    668 #else
    669           m_pcBinIf->encodeBin(1, m_cCUYPosiSCModel.get( 0, 0, 0 ));
    670 #endif
    671631        }
    672632        else
    673633        {
    674 #if AMP_CTX
    675634          m_pcBinIf->encodeBin(0, m_cCUAMPSCModel.get( 0, 0, 0 ));         
    676635          m_pcBinIf->encodeBinEP((eSize == SIZE_2NxnU? 0: 1));
    677 #else
    678           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 #endif
    681636        }
    682637      }
     
    697652        if (eSize == SIZE_Nx2N)
    698653        {
    699 #if AMP_CTX
    700654          m_pcBinIf->encodeBin(1, m_cCUAMPSCModel.get( 0, 0, 0 ));
    701 #else
    702           m_pcBinIf->encodeBin(1, m_cCUXPosiSCModel.get( 0, 0, 0 ));
    703 #endif
    704655        }
    705656        else
    706657        {
    707 #if AMP_CTX
    708658          m_pcBinIf->encodeBin(0, m_cCUAMPSCModel.get( 0, 0, 0 ));
    709659          m_pcBinIf->encodeBinEP((eSize == SIZE_nLx2N? 0: 1));
    710 #else
    711           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 #endif
    714660        }
    715661      }
     
    846792{
    847793  UInt uiNumCand = MRG_MAX_NUM_CANDS;
    848 #if !MRG_IDX_CTX_RED
    849   UInt auiCtx[4] = { 0, 1, 2, 3 };
    850 #endif
    851794  UInt uiUnaryIdx = pcCU->getMergeIndex( uiAbsPartIdx );
    852795  uiNumCand = pcCU->getSlice()->getMaxNumMergeCand();
     
    871814    {
    872815      const UInt uiSymbol = ui == uiUnaryIdx ? 0 : 1;
    873 #if MRG_IDX_CTX_RED
    874816      if ( ui==0 )
    875817      {
     
    880822        m_pcBinIf->encodeBinEP( uiSymbol );
    881823      }
    882 #else
    883       m_pcBinIf->encodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, auiCtx[ui] ) );
    884 #endif
    885824      if( uiSymbol == 0 )
    886825      {
     
    896835}
    897836
    898 #if HHI_INTER_VIEW_RESIDUAL_PRED
     837#if H3D_IVRP
    899838Void
    900839TEncSbac::codeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
     
    924863  Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE);
    925864
     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
    926869  if(bDepthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC() && pcCU->getPic()->getReduceBitsFlag())
     870#endif
    927871  {
    928872    TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr());
     
    10861030
    10871031    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
    10881035    if( uiDir == DMM_CONTOUR_PREDTEX_D_IDX )   { xCodeContourPredTexDeltaInfo( pcCU, uiAbsPartIdx ); }
    10891036#endif
     
    11221069  {
    11231070#endif
    1124 #if !LOGI_INTRA_NAME_3MPM
    1125   Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
    1126 #endif
    11271071#if LGE_EDGE_INTRA_A0070
    11281072  Bool bCodeEdgeIntra = false;
     
    11351079#endif
    11361080 
    1137 #if LOGI_INTRA_NAME_3MPM
    11381081  Int uiPreds[3] = {-1, -1, -1};
    1139 #else
    1140   Int uiPreds[2] = {-1, -1};
    1141 #endif
    11421082  Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); 
    11431083
     
    11551095  {
    11561096    m_pcBinIf->encodeBin( 1, m_cCUIntraPredSCModel.get( 0, 0, 0 ) );
    1157 #if LOGI_INTRA_NAME_3MPM
    11581097    m_pcBinIf->encodeBinEP( uiPredIdx ? 1 : 0 );
    11591098    if (uiPredIdx)
     
    11611100      m_pcBinIf->encodeBinEP( uiPredIdx-1 );
    11621101    }
    1163 #else
    1164     m_pcBinIf->encodeBinEP( uiPredIdx );
    1165 #endif
    11661102  }
    11671103  else
     
    11691105    m_pcBinIf->encodeBin( 0, m_cCUIntraPredSCModel.get( 0, 0, 0 ) );
    11701106 
    1171 #if LOGI_INTRA_NAME_3MPM
    11721107    if (uiPreds[0] > uiPreds[1])
    11731108    {
     
    11821117      std::swap(uiPreds[1], uiPreds[2]);
    11831118    }
    1184 #endif
    11851119
    11861120    for(Int i = (uiPredNum - 1); i >= 0; i--)
     
    11891123    }
    11901124
    1191 #if LOGI_INTRA_NAME_3MPM
    11921125    m_pcBinIf->encodeBinsEP( uiDir, 5 );
    11931126#if LGE_EDGE_INTRA_A0070
     
    11951128    if (uiDir == 31) m_pcBinIf->encodeBinsEP(0,1);
    11961129#endif
    1197 #else
    1198     if ( uiDir < 31 )
    1199     {
    1200       m_pcBinIf->encodeBinsEP( uiDir, g_aucIntraModeBitsAng[ iIntraIdx ] - 1 );
    1201     }
    1202     else
    1203     {
    1204       m_pcBinIf->encodeBinsEP( 31, 5 );
    1205       m_pcBinIf->encodeBinEP( uiDir - 31 );
    1206     }
    1207 #endif
    12081130   }
    12091131#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     
    12451167      m_pcBinIf->encodeBin( 1, m_cCUChromaPredSCModel.get( 0, 0, 1 ));
    12461168    }
    1247 #if  CHROMA_MODE_CODING
    12481169    m_pcBinIf->encodeBinsEP( uiIntraDirChroma, 2 );
    1249 #else
    1250     xWriteUnaryMaxSymbol( uiIntraDirChroma, m_cCUChromaPredSCModel.get( 0, 0 ) + 1, 0, 3 );
    1251 #endif
    12521170  }
    12531171  return;
     
    12771195      xWriteUnaryMaxSymbol( iRefFrame - 1, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_C )-2 );
    12781196    }
     1197#if MERL_VSP_C0152
     1198    else if (iRefFrame < 0) // NOT_VALID
     1199    {
     1200      assert(0);
     1201    }
     1202#endif
    12791203  }
    12801204  else
     
    12881212      xWriteUnaryMaxSymbol( iRefFrame - 1, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( eRefList )-2 );
    12891213    }
     1214#if MERL_VSP_C0152
     1215    else if (iRefFrame < 0) // NOT_VALID
     1216    {
     1217      assert(0);
     1218    }
     1219#endif
    12901220  }
    12911221  return;
     
    12941224Void TEncSbac::codeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList )
    12951225{
    1296 #if H0111_MVD_L1_ZERO
    12971226  if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3)
    12981227  {
    12991228    return;
    13001229  }
    1301 #endif
    13021230
    13031231  const TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefList );
     
    13521280  Int iDQp  = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx );
    13531281 
    1354 #if H0736_AVC_STYLE_QP_RANGE
    13551282  Int qpBdOffsetY =  pcCU->getSlice()->getSPS()->getQpBDOffsetY();
    13561283  iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2);
    1357 #else
    1358 #if LOSSLESS_CODING
    1359   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 #endif
    1371 #endif
    13721284
    13731285  if ( iDQp == 0 )
     
    13801292   
    13811293    UInt uiSign = (iDQp > 0 ? 0 : 1);
    1382 #if !H0736_AVC_STYLE_QP_RANGE
    1383     UInt uiQpBdOffsetY = 6*(g_uiBitIncrement + g_uiBitDepth - 8);
    1384 #endif
    13851294
    13861295    m_pcBinIf->encodeBinEP(uiSign);
    13871296
    1388 #if H0736_AVC_STYLE_QP_RANGE
    13891297    assert(iDQp >= -(26+(qpBdOffsetY/2)));
    13901298    assert(iDQp <=  (25+(qpBdOffsetY/2)));
    13911299
    13921300    UInt uiMaxAbsDQpMinus1 = 24 + (qpBdOffsetY/2) + (uiSign);
    1393 #else
    1394     assert(iDQp >= -(26+(Int)(uiQpBdOffsetY/2)));
    1395     assert(iDQp <=  (25+(Int)(uiQpBdOffsetY/2)));
    1396 
    1397     UInt uiMaxAbsDQpMinus1 = 24 + (uiQpBdOffsetY/2) + (uiSign);
    1398 #endif
    13991301    UInt uiAbsDQpMinus1 = (UInt)((iDQp > 0)? iDQp  : (-iDQp)) - 1;
    14001302    xWriteUnaryMaxSymbol( uiAbsDQpMinus1, &m_cCUDeltaQpSCModel.get( 0, 0, 1 ), 1, uiMaxAbsDQpMinus1);
     
    14221324}
    14231325
    1424 #if BURST_IPCM
    14251326/** Code I_PCM information.
    14261327 * \param pcCU pointer to CU
     
    14311332 */
    14321333Void TEncSbac::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag)
    1433 #else
    1434 /** Code I_PCM information.
    1435  * \param pcCU pointer to CU
    1436  * \param uiAbsPartIdx CU index
    1437  * \returns Void
    1438  *
    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 #endif
    14431334{
    14441335  UInt uiIPCM = (pcCU->getIPCMFlag(uiAbsPartIdx) == true)? 1 : 0;
    14451336
    1446 #if BURST_IPCM
    14471337  Bool writePCMSampleFlag = pcCU->getIPCMFlag(uiAbsPartIdx);
    14481338
     
    14571347    }
    14581348  }
    1459 #else
    1460   m_pcBinIf->encodeBinTrm (uiIPCM);
    1461 #endif
    1462 
    1463 #if BURST_IPCM
     1349
    14641350  if (writePCMSampleFlag)
    1465 #else
    1466   if (uiIPCM)
    1467 #endif
    1468   {
    1469 #if !BURST_IPCM
    1470     m_pcBinIf->encodePCMAlignBits();
    1471 #endif
     1351  {
    14721352    UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight();
    14731353    UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
     
    15261406      piPCMSample += uiWidth;
    15271407    }
    1528 #if BURST_IPCM
    15291408    numIPCM--;
    15301409    if(numIPCM == 0)
     
    15321411      m_pcBinIf->resetBac();
    15331412    }
    1534 #else
    1535     m_pcBinIf->resetBac();
    1536 #endif
    15371413  }
    15381414}
     
    15781454
    15791455  // posX
    1580 #if LAST_CTX_REDUCTION
    15811456  Int widthCtx = eTType? 4: width;
    15821457  const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ widthCtx ] * ( g_aucConvertToBit[ widthCtx ] + 3 ) );
    1583 #else
    1584   const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ width ] * ( g_aucConvertToBit[ width ] + 3 ) );
    1585 #endif
    15861458  for( uiCtxLast = 0; uiCtxLast < uiGroupIdxX; uiCtxLast++ )
    15871459  {
    1588 #if LAST_CTX_REDUCTION
    15891460    if (eTType)
    15901461    {
     
    15931464    else
    15941465    {
    1595 #endif
    15961466      m_pcBinIf->encodeBin( 1, *( pCtxX + puiCtxIdxX[ uiCtxLast ] ) );
    1597 #if LAST_CTX_REDUCTION
    1598     }
    1599 #endif
     1467    }
    16001468  }
    16011469  if( uiGroupIdxX < g_uiGroupIdx[ width - 1 ])
    16021470  {
    1603 #if LAST_CTX_REDUCTION
    16041471    if ( eTType )
    16051472    {
     
    16081475    else
    16091476    {
    1610 #endif
    16111477      m_pcBinIf->encodeBin( 0, *( pCtxX + puiCtxIdxX[ uiCtxLast ] ) );
    1612 #if LAST_CTX_REDUCTION
    1613     }
    1614 #endif
     1478    }
    16151479  }
    16161480
    16171481  // posY
    1618 #if LAST_CTX_REDUCTION
    16191482  Int heightCtx = eTType? 4: height;
    16201483  const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ heightCtx ] * ( g_aucConvertToBit[ heightCtx ] + 3 ) );
    1621 #else
    1622   const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ height ] * ( g_aucConvertToBit[ height ] + 3 ) );
    1623 #endif
    16241484  for( uiCtxLast = 0; uiCtxLast < uiGroupIdxY; uiCtxLast++ )
    16251485  {
    1626 #if LAST_CTX_REDUCTION
    16271486    if (eTType)
    16281487    {
     
    16311490    else
    16321491    {
    1633 #endif
    16341492      m_pcBinIf->encodeBin( 1, *( pCtxY + puiCtxIdxY[ uiCtxLast ] ) );
    1635 #if LAST_CTX_REDUCTION
    1636     }
    1637 #endif
     1493    }
    16381494  }
    16391495  if( uiGroupIdxY < g_uiGroupIdx[ height - 1 ])
    16401496  {
    1641 #if LAST_CTX_REDUCTION
    16421497    if (eTType)
    16431498    {
     
    16461501    else
    16471502    {
    1648 #endif
    16491503      m_pcBinIf->encodeBin( 0, *( pCtxY + puiCtxIdxY[ uiCtxLast ] ) );
    1650 #if LAST_CTX_REDUCTION
    1651     }
    1652 #endif
     1504    }
    16531505    }
    16541506  if ( uiGroupIdxX > 3 )
     
    17401592  }
    17411593 
    1742 #if MULTIBITS_DATA_HIDING
    17431594  UInt const tsig = pcCU->getSlice()->getPPS()->getTSIG();
    17441595#if LOSSLESS_CODING
     
    17551606  Bool beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0;
    17561607#endif
    1757 #endif
    17581608
    17591609  // Find position of last coefficient
     
    17651615  {
    17661616    scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ];
    1767 #if MULTILEVEL_SIGMAP_EXT
    17681617    if( uiLog2BlockSize == 3 )
    17691618    {
     
    17741623      scanCG = g_sigLastScanCG32x32;
    17751624    }
    1776 #endif
    17771625  }
    17781626  else
     
    17841632  const UInt uiNumBlkSide = uiWidth >> uiShift;
    17851633
    1786 #if !MULTILEVEL_SIGMAP_EXT
    1787   if( blockType > 3 )
    1788   {
    1789 #endif
    17901634    ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM );
    17911635
     
    17981642      UInt uiPosX    = posLast - ( uiPosY << uiLog2BlockSize );
    17991643      UInt uiBlkIdx  = uiNumBlkSide * (uiPosY >> uiShift) + (uiPosX >> uiShift);
    1800 #if MULTILEVEL_SIGMAP_EXT
    18011644      if( uiWidth == 8 && uiHeight == 8 && (uiScanIdx == SCAN_HOR || uiScanIdx == SCAN_VER) )
    18021645      {
     
    18101653        }
    18111654      }
    1812 #endif
    18131655      if( pcCoef[ posLast ] )
    18141656      {
     
    18191661    }
    18201662    while ( uiNumSig > 0 );
    1821 #if !MULTILEVEL_SIGMAP_EXT
    1822   }
    1823   else
    1824   {
    1825  
    1826   do
    1827   {
    1828     posLast = scan[ ++scanPosLast ];
    1829     uiNumSig -= ( pcCoef[ posLast ] != 0 );
    1830   }
    1831   while ( uiNumSig > 0 );
    1832 
    1833   }
    1834 #endif
    18351663
    18361664  // Code position of last coefficient
     
    18571685    UInt coeffSigns = 0;
    18581686
    1859 #if MULTIBITS_DATA_HIDING
    18601687    Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE;
    1861 #endif
    18621688
    18631689    if( iScanPosSig == scanPosLast )
     
    18661692      coeffSigns    = ( pcCoef[ posLast ] < 0 );
    18671693      numNonZero    = 1;
    1868 #if MULTIBITS_DATA_HIDING
    18691694      lastNZPosInCG  = iScanPosSig;
    18701695      firstNZPosInCG = iScanPosSig;
    1871 #endif
    18721696      iScanPosSig--;
    18731697    }
    18741698
    1875 #if !MULTILEVEL_SIGMAP_EXT
    1876     if( blockType > 3 )
    1877     {
    1878 #endif
    18791699      // encode significant_coeffgroup_flag
    18801700      Int iCGBlkPos = scanCG[ iSubSet ];
    18811701      Int iCGPosY   = iCGBlkPos / uiNumBlkSide;
    18821702      Int iCGPosX   = iCGBlkPos - (iCGPosY * uiNumBlkSide);
    1883 #if MULTILEVEL_SIGMAP_EXT
    18841703      if( uiWidth == 8 && uiHeight == 8 && (uiScanIdx == SCAN_HOR || uiScanIdx == SCAN_VER) )
    18851704      {
     
    18871706        iCGPosX = (uiScanIdx == SCAN_VER ? iCGBlkPos : 0);
    18881707      }
    1889 #endif
    1890 #if !REMOVE_INFER_SIGGRP
    1891       Bool bInferredCGFlag = false;
    1892 #endif
    1893 #if REMOVE_INFER_SIGGRP
    18941708      if( iSubSet == iLastScanSet || iSubSet == 0)
    1895 #else     
    1896       if( iSubSet == iLastScanSet )
    1897 #endif
    18981709      {
    18991710        uiSigCoeffGroupFlag[ iCGBlkPos ] = 1;
     
    19011712      else
    19021713      {
    1903 #if !REMOVE_INFER_SIGGRP
    1904 #if MULTILEVEL_SIGMAP_EXT
    1905         if( !TComTrQuant::bothCGNeighboursOne( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight ) && ( iSubSet ) )
    1906 #else
    1907         if( !TComTrQuant::bothCGNeighboursOne( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ) && ( iSubSet ) )
    1908 #endif
    1909         {
    1910 #endif
    19111714          UInt uiSigCoeffGroup   = (uiSigCoeffGroupFlag[ iCGBlkPos ] != 0);
    1912 #if MULTILEVEL_SIGMAP_EXT
    19131715          UInt uiCtxSig  = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight );
    1914 #else
    1915           UInt uiCtxSig  = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight );
    1916 #endif
    19171716          m_pcBinIf->encodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] );
    1918 #if !REMOVE_INFER_SIGGRP
    1919         }
    1920         else
    1921         {
    1922           uiSigCoeffGroupFlag[ iCGBlkPos ] = 1;
    1923           bInferredCGFlag = true;
    1924         }
    1925 #endif
    19261717      }
    19271718     
     
    19361727          uiPosX    = uiBlkPos - ( uiPosY << uiLog2BlockSize );
    19371728          uiSig     = (pcCoef[ uiBlkPos ] != 0);
    1938 #if REMOVE_INFER_SIGGRP
    19391729          if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero )
    1940 #else
    1941           if( iScanPosSig > iSubPos || bInferredCGFlag || numNonZero )
    1942 #endif
    19431730          {
    19441731            uiCtxSig  = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );
     
    19501737            coeffSigns = 2 * coeffSigns + ( pcCoef[ uiBlkPos ] < 0 );
    19511738            numNonZero++;
    1952 #if MULTIBITS_DATA_HIDING
    19531739            if( lastNZPosInCG == -1 )
    19541740            {
     
    19561742            }
    19571743            firstNZPosInCG = iScanPosSig;
    1958 #endif
    19591744          }
    19601745        }
     
    19641749        iScanPosSig = iSubPos - 1;
    19651750      }
    1966 #if !MULTILEVEL_SIGMAP_EXT
    1967     }
    1968     else
    1969     {
    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_HIDING
    1984         if( lastNZPosInCG == -1 )
    1985         {
    1986           lastNZPosInCG = iScanPosSig;
    1987         }
    1988         firstNZPosInCG = iScanPosSig;
    1989 #endif
    1990       }     
    1991       UInt  uiCtxSig  = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );
    1992       m_pcBinIf->encodeBin( uiSig, baseCtx[ uiCtxSig ] );
    1993     }
    1994 
    1995     }
    1996 #endif
    19971751
    19981752    if( numNonZero > 0 )
    19991753    {
    2000 #if MULTIBITS_DATA_HIDING
    20011754      Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= (Int)tsig );
    2002 #endif  // MULTIBITS_DATA_HIDING
    20031755
    20041756      UInt c1 = 1;
    2005 #if !RESTRICT_GR1GR2FLAG_NUMBER
    2006       UInt c2 = 0;
    2007 #endif
    2008 #if LEVEL_CTX_LUMA_RED
    20091757      UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0;
    2010 #else
    2011       UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 3 : 0;
    2012 #endif
    20131758     
    20141759      if( uiNumOne > 0 )
    20151760      {
    20161761        uiCtxSet++;
    2017 #if !LEVEL_CTX_LUMA_RED
    2018         if( uiNumOne > 3 && eTType==TEXT_LUMA)
    2019         {
    2020           uiCtxSet++;
    2021         }
    2022 #endif
    20231762      }
    20241763     
     
    20261765      ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet;
    20271766     
    2028 #if RESTRICT_GR1GR2FLAG_NUMBER
    20291767      Int numC1Flag = min(numNonZero, C1FLAG_NUMBER);
    20301768      Int firstC2FlagIdx = -1;
    20311769      for( Int idx = 0; idx < numC1Flag; idx++ )
    2032 #else
    2033       for ( Int idx = 0; idx < numNonZero; idx++ )
    2034 #endif
    20351770      {
    20361771        UInt uiSymbol = absCoeff[ idx ] > 1;
     
    20401775          c1 = 0;
    20411776
    2042 #if RESTRICT_GR1GR2FLAG_NUMBER
    20431777          if (firstC2FlagIdx == -1)
    20441778          {
    20451779            firstC2FlagIdx = idx;
    20461780          }
    2047 #endif
    20481781        }
    20491782        else if( (c1 < 3) && (c1 > 0) )
     
    20561789      {
    20571790
    2058 #if RESTRICT_GR1GR2FLAG_NUMBER
    20591791        baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet;
    20601792        if ( firstC2FlagIdx != -1)
     
    20631795          m_pcBinIf->encodeBin( symbol, baseCtxMod[0] );
    20641796        }
    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      {
    20671811        for ( Int idx = 0; idx < numNonZero; idx++ )
    20681812        {
    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 #endif
    2078       }
    2079      
    2080 #if MULTIBITS_DATA_HIDING
    2081       if( beValid && signHidden )
    2082       {
    2083         m_pcBinIf->encodeBinsEP( (coeffSigns >> 1), numNonZero-1 );
    2084       }
    2085       else
    2086       {
    2087         m_pcBinIf->encodeBinsEP( coeffSigns, numNonZero );
    2088       }
    2089 #else
    2090       m_pcBinIf->encodeBinsEP( coeffSigns, numNonZero );
    2091 #endif
    2092      
    2093 #if RESTRICT_GR1GR2FLAG_NUMBER
    2094       Int iFirstCoeff2 = 1;   
    2095       if (c1 == 0 || numNonZero > C1FLAG_NUMBER)
    2096 #else
    2097       if (c1 == 0)
    2098 #endif
    2099       {
    2100         for ( Int idx = 0; idx < numNonZero; idx++ )
    2101         {
    2102 #if RESTRICT_GR1GR2FLAG_NUMBER
    21031813          UInt baseLevel  = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2 ) : 1;
    21041814
     
    21121822            uiNumOne++;
    21131823          }
    2114 #else
    2115           if ( absCoeff[ idx ] > 2 )
    2116           {
    2117             xWriteGoRiceExGolomb( absCoeff[ idx ]  - 3, uiGoRiceParam );           
    2118           }
    2119 #endif
    21201824        }       
    21211825      }
     
    22481952  }
    22491953}
    2250 #if SAO_UNIT_INTERLEAVING
    22511954/** Code SAO band position
    22521955 * \param uiCode
     
    23082011  }
    23092012}
    2310 #endif
    23112013/*!
    23122014 ****************************************************************************
     
    24172119  const UInt *puiCtxIdx;
    24182120  Int ctx;
    2419 #if LAST_CTX_REDUCTION
    24202121  Int widthCtx = eTType? 4 : width;
    24212122  puiCtxIdx = g_uiLastCtx + (g_aucConvertToBit[ widthCtx ]*(g_aucConvertToBit[ widthCtx ]+3));
    2422 #else 
    2423   puiCtxIdx = g_uiLastCtx + (g_aucConvertToBit[ width ]*(g_aucConvertToBit[ width ]+3));
    2424 #endif
    24252123  ContextModel *pCtxX      = m_cCuCtxLastX.get( 0, eTType );
    24262124  for (ctx = 0; ctx < g_uiGroupIdx[ width - 1 ]; ctx++)
    24272125  {
    24282126    Int ctxOffset = puiCtxIdx[ ctx ];
    2429 #if LAST_CTX_REDUCTION
    24302127    if (eTType)
    24312128    {
     
    24362133    else
    24372134    {
    2438 #endif
    24392135      pcEstBitsSbac->lastXBits[ ctx ] = iBitsX + pCtxX[ ctxOffset ].getEntropyBits( 0 );
    24402136      iBitsX += pCtxX[ ctxOffset ].getEntropyBits( 1 );
    2441 #if LAST_CTX_REDUCTION
    2442     }
    2443 #endif
     2137    }
    24442138    }
    24452139  pcEstBitsSbac->lastXBits[ctx] = iBitsX;
    24462140
    2447 #if LAST_CTX_REDUCTION
    24482141  Int heightCtx = eTType? 4 : height;
    24492142  puiCtxIdx = g_uiLastCtx + (g_aucConvertToBit[ heightCtx ]*(g_aucConvertToBit[ heightCtx ]+3));
    2450 #else
    2451   puiCtxIdx = g_uiLastCtx + (g_aucConvertToBit[ height ]*(g_aucConvertToBit[ height ]+3));
    2452 #endif
    24532143  ContextModel *pCtxY      = m_cCuCtxLastY.get( 0, eTType );
    24542144  for (ctx = 0; ctx < g_uiGroupIdx[ height - 1 ]; ctx++)
    24552145  {
    24562146    Int ctxOffset = puiCtxIdx[ ctx ];
    2457 #if LAST_CTX_REDUCTION
    24582147    if (eTType)
    24592148    {
     
    24642153    else
    24652154    {
    2466 #endif
    24672155      pcEstBitsSbac->lastYBits[ ctx ] = iBitsY + pCtxY[ ctxOffset ].getEntropyBits( 0 );
    24682156      iBitsY += pCtxY[ ctxOffset ].getEntropyBits( 1 );
    2469 #if LAST_CTX_REDUCTION
    2470     }
    2471 #endif
     2157    }
    24722158    }
    24732159  pcEstBitsSbac->lastYBits[ctx] = iBitsY;
     
    26612347#endif
    26622348#if HHI_DMM_PRED_TEX
     2349#if LGE_DMM3_SIMP_C0044
     2350Void 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
    26632364Void TEncSbac::xCodeWedgePredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx )
    26642365{
     2366#if LGE_DMM3_SIMP_C0044
     2367  xCodeWedgePredTexInfo( pcCU, uiAbsPartIdx );
     2368#endif
    26652369  Int iDeltaDC1 = pcCU->getWedgePredTexDeltaDC1( uiAbsPartIdx );
    26662370  Int iDeltaDC2 = pcCU->getWedgePredTexDeltaDC2( uiAbsPartIdx );
  • trunk/source/Lib/TLibEncoder/TEncSbac.h

    r210 r296  
    102102#endif
    103103 
    104 #if HHI_MPI
     104#if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068
    105105  Void  codeSPS                 ( TComSPS* pcSPS, Bool bIsDepth );
    106106#else
     
    111111  Void  codeSliceHeader         ( TComSlice* pcSlice );
    112112  Void codeTileMarkerFlag(TComSlice* pcSlice) {printf("Not supported\n"); assert(0); exit(1);}
    113 #if TILES_WPP_ENTRY_POINT_SIGNALLING
    114113  Void  codeTilesWPPEntryPoint( TComSlice* pSlice );
    115 #else
    116   Void  codeSliceHeaderSubstreamTable( TComSlice* pcSlice );
    117 #endif
    118114  Void  codeTerminatingBit      ( UInt uilsLast      );
    119115  Void  codeSliceFinish         ();
    120 #if OL_FLUSH
    121116  Void  codeFlush               ();
    122117  Void  encodeStart             ();
    123 #endif
    124118 
    125119  Void  codeAlfFlag       ( UInt uiCode );
     
    127121  Void  codeAlfSvlc       ( Int  uiCode );
    128122  Void  codeAlfCtrlDepth  ();
    129 #if LCU_SYNTAX_ALF
    130123  Void codeAPSAlflag(UInt uiCode) {assert (0);  return;}
    131124  Void codeAlfFixedLengthIdx( UInt idx, UInt maxValue){ assert (0);  return;}
    132 #endif
    133125
    134126  Void codeAlfCtrlFlag       ( UInt uiSymbol );
     
    137129  Void  codeSaoUvlc       ( UInt uiCode );
    138130  Void  codeSaoSvlc       ( Int  uiCode );
    139 #if SAO_UNIT_INTERLEAVING
    140131  Void  codeSaoRun        ( UInt  uiCode, UInt uiMaxValue  ) {;}
    141132  Void  codeSaoMergeLeft  ( UInt  uiCode, UInt uiCompIdx );
     
    143134  Void  codeSaoTypeIdx    ( UInt  uiCode);
    144135  Void  codeSaoUflc       ( UInt  uiCode);
    145 #endif
    146136  Void  codeScalingList      ( TComScalingList* scalingList     ){ assert (0);  return;};
    147137 
     
    178168#endif
    179169#if HHI_DMM_PRED_TEX
     170#if LGE_DMM3_SIMP_C0044
     171  Void  xCodeWedgePredTexInfo       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
     172#endif
    180173  Void  xCodeWedgePredTexDeltaInfo  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    181174  Void  xCodeContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx );
     
    213206  Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    214207  Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    215 #if HHI_INTER_VIEW_RESIDUAL_PRED
     208#if H3D_IVRP
    216209  Void codeResPredFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    217210#endif
    218211  Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    219 #if HHI_INTER_VIEW_MOTION_PRED
     212#if H3D_IVMP
    220213  Void codeMVPIdx        ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum );
    221214#else
     
    225218  Void codePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    226219  Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    227 #if BURST_IPCM
    228220  Void codeIPCMInfo      ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag);
    229 #else
    230   Void codeIPCMInfo      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    231 #endif
    232221  Void codeTransformSubdivFlag ( UInt uiSymbol, UInt uiCtx );
    233222  Void codeQtCbf               ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth );
     
    274263  ContextModel3DBuffer m_cCUMergeFlagExtSCModel;
    275264  ContextModel3DBuffer m_cCUMergeIdxExtSCModel;
    276 #if HHI_INTER_VIEW_RESIDUAL_PRED
     265#if H3D_IVRP
    277266  ContextModel3DBuffer m_cResPredFlagSCModel;
    278267#endif
     
    302291  ContextModel3DBuffer m_cALFUvlcSCModel;
    303292  ContextModel3DBuffer m_cALFSvlcSCModel;
    304 #if AMP_CTX
    305293  ContextModel3DBuffer m_cCUAMPSCModel;
    306 #else
    307   ContextModel3DBuffer m_cCUXPosiSCModel;
    308   ContextModel3DBuffer m_cCUYPosiSCModel;
    309 #endif
    310294  ContextModel3DBuffer m_cSaoFlagSCModel;
    311295  ContextModel3DBuffer m_cSaoUvlcSCModel;
    312296  ContextModel3DBuffer m_cSaoSvlcSCModel;
    313 #if SAO_UNIT_INTERLEAVING
    314297  ContextModel3DBuffer m_cSaoMergeLeftSCModel;
    315298  ContextModel3DBuffer m_cSaoMergeUpSCModel;
    316299  ContextModel3DBuffer m_cSaoTypeIdxSCModel;
    317 #endif
    318300
    319301#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
  • trunk/source/Lib/TLibEncoder/TEncSearch.cpp

    r210 r296  
    205205#endif
    206206 
    207 #if HHI_INTER_VIEW_MOTION_PRED
     207#if H3D_IVMP
    208208  const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + 1;
    209209  for( Int iNum = 0; iNum < iNumAMVPCands+1; iNum++)
     
    696696UInt TEncSearch::xPatternRefinement( TComPattern* pcPatternKey,
    697697                                    TComMv baseRefMv,
    698                                     Int iFrac, TComMv& rcMvFrac )
     698                                    Int iFrac, TComMv& rcMvFrac
     699                                   )
    699700{
    700701  UInt  uiDist;
     
    10791080  pcCU       ->setTrIdxSubParts ( uiTrDepth, uiAbsPartIdx, uiFullDepth );
    10801081
    1081 #if H0736_AVC_STYLE_QP_RANGE
    10821082  m_pcTrQuant->setQPforQuant    ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
    1083 #else
    1084   m_pcTrQuant->setQPforQuant    ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 );
    1085 #endif
    10861083
    10871084#if RDOQ_CHROMA_LAMBDA
     
    12771274    UInt uiAbsSum = 0;
    12781275
    1279 #if H0736_AVC_STYLE_QP_RANGE
    12801276    if(eText == TEXT_CHROMA_U)
    12811277    {
     
    12861282      m_pcTrQuant->setQPforQuant     ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
    12871283    }
    1288 #else
    1289     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     else
    1292       m_pcTrQuant->setQPforQuant     ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
    1293 #endif
    12941284
    12951285#if RDOQ_CHROMA_LAMBDA
     
    16881678  // reconstruct residual based on mask + DC residuals
    16891679  Pel apDCResiValues[2];
    1690   Pel apDCRecoValues[2];
     1680  //Pel apDCRecoValues[2];
    16911681  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
    16921682  {
     
    16951685    Pel   pRecoValue  = GetIdx2DepthValue( pPredIdx + pResiIdx );
    16961686   
    1697     apDCRecoValues[uiSegment]  = pRecoValue;
     1687    //apDCRecoValues[uiSegment]  = pRecoValue;
    16981688    apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
    16991689  }
     
    20142004  UInt    uiQNumParts    = pcCU->getTotalNumPart() >> 2;
    20152005  UInt    uiWidthBit     = pcCU->getIntraSizeIdx(0);
    2016 #if FIX_RDO_NEGDIST
    20172006  Dist    uiOverallDistY = 0;
    20182007  Dist    uiOverallDistC = 0;
    2019 #else
    2020   UInt    uiOverallDistY = 0;
    2021   UInt    uiOverallDistC = 0;
    2022 #endif
    20232008  UInt    CandNum;
    20242009  Double  CandCostList[ FAST_UDI_MAX_RDMODE_NUM ];
     
    20452030   
    20462031    //===== determine set of modes to be tested (using prediction signal only) =====
    2047 #if LOGI_INTRA_NAME_3MPM
    20482032    Int numModesAvailable     = 35; //total number of Intra modes
    2049 #else
    2050     Int numModesAvailable     = g_aucIntraModeNumAng[uiWidthBit];
    2051 #endif
    20522033    Pel* piOrg         = pcOrgYuv ->getLumaAddr( uiPU, uiWidth );
    20532034    Pel* piPred        = pcPredYuv->getLumaAddr( uiPU, uiWidth );
     
    21572138        CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList );
    21582139
    2159 #if (HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX) && !FIX_DMM_NEG_DIST
    2160         if( bTestDmm ) bTestDmm = uiSad ? true : false;
    2161 #endif
    21622140#if LGE_EDGE_INTRA_A0070
    21632141        if ( bTestEdgeIntra ) bTestEdgeIntra = uiSad ? true : false;
     
    21662144   
    21672145#if FAST_UDI_USE_MPM
    2168 #if LOGI_INTRA_NAME_3MPM
    21692146      Int uiPreds[3] = {-1, -1, -1};
    2170 #else
    2171       Int uiPreds[2] = {-1, -1};
    2172 #endif
    21732147      Int iMode = -1;
    21742148      Int numCand = pcCU->getIntraDirLumaPredictor( uiPartOffset, uiPreds, &iMode );
    2175 #if LOGI_INTRA_NAME_3MPM
    21762149      if( iMode >= 0 )
    21772150      {
    21782151        numCand = iMode;
    21792152      }
    2180 #else
    2181       if( iMode >= 0 )
    2182       {
    2183         numCand = 1;
    2184         uiPreds[0] = iMode;
    2185       }
    2186 #endif
    21872153     
    21882154      for( Int j=0; j < numCand; j++)
     
    22522218      Int  iTexDeltaDC1 = 0;
    22532219      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
    22542225      findWedgeTexMinDist( pcCU, uiPartOffset, piOrg, piPred, uiStride, uiWidth, uiHeight, uiTexTabIdx, iTexDeltaDC1, iTexDeltaDC2, bAboveAvail, bLeftAvail );
     2226#endif
    22552227      pcCU->setWedgePredTexTabIdxSubParts  ( uiTexTabIdx,  uiPartOffset, uiDepth + uiInitTrDepth );
    22562228      pcCU->setWedgePredTexDeltaDC1SubParts( iTexDeltaDC1, uiPartOffset, uiDepth + uiInitTrDepth );
     
    22952267   
    22962268    UInt    uiBestPUMode  = 0;
    2297 #if FIX_RDO_NEGDIST
    22982269    Dist    uiBestPUDistY = 0;
    22992270    Dist    uiBestPUDistC = 0;
    2300 #else
    2301     UInt    uiBestPUDistY = 0;
    2302     UInt    uiBestPUDistC = 0;
    2303 #endif
    23042271    Double  dBestPUCost   = MAX_DOUBLE;
    23052272#if RWTH_SDC_DLT_B0036
     
    23442311      for( UInt uiSDC=0; uiSDC<=uiUseSDC; uiSDC++ )
    23452312      {
     2313#if FIX_SDC_ENC_C0143
     2314        for( UInt uiRes = 0; uiRes<=uiSDC; uiRes++ )
     2315#else
    23462316        for( UInt uiRes = 0; uiRes<=uiUseSDC; uiRes++ )
     2317#endif
    23472318        {
    23482319#endif
     
    28972868Void TEncSearch::xGetInterPredictionError( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, UInt& ruiErr, Bool bHadamard )
    28982869{
     2870#if !MERL_VSP_C0152
    28992871  motionCompensation( pcCU, &m_tmpYuvPred, REF_PIC_LIST_X, iPartIdx );
    2900 
     2872#endif
    29012873  UInt uiAbsPartIdx = 0;
    29022874  Int iWidth = 0;
    29032875  Int iHeight = 0;
    29042876  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
    29062880  DistParam cDistParam;
    29072881
     
    29432917#else
    29442918#if LG_RESTRICTEDRESPRED_M24766
     2919#if MERL_VSP_C0152 || MTK_MDIVRP_C0138
     2920#if !MTK_MDIVRP_C0138
     2921Void 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
     2924Void 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
     2927Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost, Int* iVSPIndexTrue  )
     2928#endif
     2929#else
    29452930Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* rpcResiPredYuv, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost )
     2931#endif
    29462932#else
    29472933Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost )
     
    29502936{
    29512937#if !CU_BASED_MRG_CAND_LIST
    2952 #if HHI_INTER_VIEW_MOTION_PRED
     2938#if H3D_IVMP
    29532939  TComMvField  cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    29542940  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
     
    29882974  }
    29892975#else
     2976#if MERL_VSP_C0152
     2977  pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, uiDepth, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand, iVSPIndexTrue );
     2978#else
    29902979  pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, uiDepth, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
    29912980#endif
    2992 
    2993 #if HHI_INTER_VIEW_MOTION_PRED
     2981#endif
     2982
     2983
     2984#if H3D_IVMP
    29942985  const int maxNumMergeCand = MRG_MAX_NUM_CANDS_SIGNALED + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 );
    29952986#endif
    2996 #if LG_RESTRICTEDRESPRED_M24766
     2987#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    29972988  Int iPUResiPredShift[4];
    29982989  Int iLastAddResiShift = -1000;
     
    30093000      pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    30103001      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
    30123019      Int iAddResiShift;
    30133020      UInt uiPartAddr;
     
    30403047      xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() );
    30413048      uiBitsCand = uiMergeCand + 1;
    3042 #if HHI_INTER_VIEW_MOTION_PRED
     3049#if H3D_IVMP
    30433050      if (uiMergeCand == maxNumMergeCand - 1 )
    30443051#else
     
    30593066    }
    30603067  }
    3061 #if LG_RESTRICTEDRESPRED_M24766
     3068#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    30623069  if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0)
    30633070  {
     
    30783085 */
    30793086#if AMP_MRG
    3080 #if LG_RESTRICTEDRESPRED_M24766
     3087#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    30813088Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv* rpcResiPredYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG )
    30823089#else
    3083 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG )
     3090Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG)
    30843091#endif
    30853092#else
     
    31353142  PartSize      ePartSize = pcCU->getPartitionSize( 0 );
    31363143
    3137 #if H0111_MVD_L1_ZERO
    31383144  Int           bestBiPRefIdxL1 = 0;
    31393145  Int           bestBiPMvpL1 = 0;
    31403146  UInt          biPDistTemp = MAX_INT;
    3141 #endif
    31423147
    31433148#if ZERO_MVD_EST
     
    31483153
    31493154#if CU_BASED_MRG_CAND_LIST
    3150 #if HHI_INTER_VIEW_MOTION_PRED
     3155#if H3D_IVMP
    31513156  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    31523157  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
     
    31593164#endif
    31603165
    3161 #if HHI_INTER_VIEW_MOTION_PRED
     3166#if H3D_IVMP
    31623167  Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 );
    31633168#endif
     
    31783183    UInt          auiZeroMvdBits[3];
    31793184#endif
    3180 #if H0111_MVD_L1_ZERO
    31813185    UInt          bestBiPDist = MAX_INT;
    3182 #endif
    31833186
    31843187    UInt          uiCostTempL0[MAX_NUM_REF];
    31853188    for (Int iNumRef=0; iNumRef < MAX_NUM_REF; iNumRef++) uiCostTempL0[iNumRef] = MAX_UINT;
    31863189    UInt          uiBitsTempL0[MAX_NUM_REF];
    3187 #if LG_RESTRICTEDRESPRED_M24766
     3190#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    31883191    Int iPUResiPredShift[4] = {0, 0, 0, 0};
    31893192#endif
     
    31913194   
    31923195    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
    31943200#if AMP_MRG
    31953201    Bool bTestNormalMC = true;
     
    32033209    {
    32043210#endif
    3205 #if LG_RESTRICTEDRESPRED_M24766
     3211#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    32063212      Bool bLastResiFlag = false;
    32073213#endif
     3214
    32083215    //  Uni-directional prediction
    32093216    for ( Int iRefList = 0; iRefList < iNumPredDir; iRefList++ )
     
    32133220      for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ )
    32143221      {
    3215 #if LG_RESTRICTEDRESPRED_M24766
     3222#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    32163223        if( pcCU->getResPredFlag( 0 ))
    32173224        {
     
    32363243          if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--;
    32373244        }
    3238 #if H0111_MVD_L1_ZERO
    32393245#if ZERO_MVD_EST
    32403246        xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp, &uiZeroMvdDistTemp);
    32413247#else
    32423248        xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp);
    3243 #endif
    3244 #else
    3245 #if ZERO_MVD_EST
    3246         xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &uiZeroMvdDistTemp);
    3247 #else
    3248         xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp]);
    3249 #endif
    32503249#endif
    32513250        aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr);
    32523251        aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr);
    32533252       
    3254 #if H0111_MVD_L1_ZERO
    32553253        if(pcCU->getSlice()->getMvdL1ZeroFlag() && iRefList==1 && biPDistTemp < bestBiPDist)
    32563254        {
     
    32593257          bestBiPRefIdxL1 = iRefIdxTemp;
    32603258        }
    3261 #endif
    3262 
    3263 #if HHI_INTER_VIEW_MOTION_PRED
     3259
     3260#if H3D_IVMP
    32643261        uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][iNumAMVPCands];
    32653262#else
     
    33723369            pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
    33733370
    3374 #if H0111_MVD_L1_ZERO
    33753371            if(!pcCU->getSlice()->getMvdL1ZeroFlag())
    33763372            {
    3377 #endif
    33783373              // storing list 1 prediction signal for iterative bi-directional prediction
    33793374              if ( eRefPicList == REF_PIC_LIST_1 )
    33803375              {
    33813376                TComYuv*  pcYuvPred = &m_acYuvPred[iRefList];
     3377#if MERL_VSP_C0152
     3378                motionCompensation ( pcCU, pcYuvPred, pcCU->getZorderIdxInCU(),  eRefPicList, iPartIdx );
     3379#else
    33823380                motionCompensation ( pcCU, pcYuvPred, eRefPicList, iPartIdx );
     3381#endif
    33833382              }
    33843383              if ( (pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 )) && eRefPicList == REF_PIC_LIST_0 )
    33853384              {
    33863385                TComYuv*  pcYuvPred = &m_acYuvPred[iRefList];
     3386#if MERL_VSP_C0152
     3387                motionCompensation ( pcCU, pcYuvPred, pcCU->getZorderIdxInCU(),  eRefPicList, iPartIdx );
     3388#else
    33873389                motionCompensation ( pcCU, pcYuvPred, eRefPicList, iPartIdx );
     3390#endif
    33883391              }
    3389 #if H0111_MVD_L1_ZERO
    33903392            }
    3391 #endif
    33923393          }
    33933394      }
    33943395    }
    3395 #if LG_RESTRICTEDRESPRED_M24766
     3396#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    33963397    if( pcCU->getResPredFlag( 0 ) && bLastResiFlag)
    33973398    { // subtract residual prediction from original in motion search
     
    34023403    if ( pcCU->getSlice()->isInterB() )
    34033404    {
    3404 #if LG_RESTRICTEDRESPRED_M24766
     3405#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    34053406      Int iLastAddResiShift = -1000;
    34063407#endif
     
    34113412      ::memcpy(aaiMvpIdxBi, aaiMvpIdx, sizeof(aaiMvpIdx));
    34123413     
    3413 #if H0111_MVD_L1_ZERO
    34143414      UInt uiMotBits[2];
    34153415
     
    34263426        pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( iRefIdxBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
    34273427        TComYuv* pcYuvPred = &m_acYuvPred[1];
     3428#if MERL_VSP_C0152
     3429        motionCompensation( pcCU, pcYuvPred, pcCU->getZorderIdxInCU(),  REF_PIC_LIST_1, iPartIdx );
     3430#else
    34283431        motionCompensation( pcCU, pcYuvPred, REF_PIC_LIST_1, iPartIdx );
    3429 
     3432#endif
    34303433        uiMotBits[0] = uiBits[0] - uiMbBits[0];
    34313434        uiMotBits[1] = uiMbBits[1];
     
    34373440        }
    34383441
    3439 #if HHI_INTER_VIEW_MOTION_PRED
     3442#if H3D_IVMP
    34403443        uiMotBits[1] += m_auiMVPIdxCost[aaiMvpIdxBi[1][bestBiPRefIdxL1]][iNumAMVPCands];
    34413444#else
     
    34533456        uiBits[2] = uiMbBits[2] + uiMotBits[0] + uiMotBits[1];
    34543457      }
    3455 #else   
    3456       UInt uiMotBits[2] = { uiBits[0] - uiMbBits[0], uiBits[1] - uiMbBits[1] };
    3457       uiBits[2] = uiMbBits[2] + uiMotBits[0] + uiMotBits[1];
    3458 #endif     
    34593458
    34603459      // 4-times iteration (default)
     
    34623461     
    34633462      // fast encoder setting: only one iteration
    3464 #if H0111_MVD_L1_ZERO
    34653463      if ( m_pcEncCfg->getUseFastEnc() || pcCU->getSlice()->getMvdL1ZeroFlag())
    3466 #else
    3467       if ( m_pcEncCfg->getUseFastEnc() )
    3468 #endif
    34693464      {
    34703465        iNumIter = 1;
     
    34813476        RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
    34823477
    3483 #if H0111_MVD_L1_ZERO
    34843478        if(pcCU->getSlice()->getMvdL1ZeroFlag())
    34853479        {
     
    34873481          eRefPicList = REF_PIC_LIST_0;
    34883482        }
    3489 #endif
    34903483
    34913484        Bool bChanged = false;
     
    35023495            if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--;
    35033496          }
    3504 #if HHI_INTER_VIEW_MOTION_PRED
     3497#if H3D_IVMP
    35053498          uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdxBi[iRefList][iRefIdxTemp]][iNumAMVPCands];
    35063499#else
    35073500          uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdxBi[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
    35083501#endif
    3509 #if LG_RESTRICTEDRESPRED_M24766
     3502#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    35103503          Int iAddResiShift = -1, iPredFrom = 0;
    35113504          Int iBestRefIdx = pcCU->getCUMvField(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
     
    35453538            xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPredBi[iRefList][iRefIdxTemp], aaiMvpIdxBi[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
    35463539          }
    3547          
     3540
    35483541          if ( uiCostTemp < uiCostBi )
    35493542          {
     
    35573550            uiBits[2]           = uiBitsTemp;
    35583551           
    3559 #if H0111_MVD_L1_ZERO
    35603552            if(iNumIter!=1)
    35613553            {
    3562 #endif
    35633554              //  Set motion
    35643555              pcCU->getCUMvField( eRefPicList )->setAllMv( cMvBi[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     
    35663557
    35673558              TComYuv* pcYuvPred = &m_acYuvPred[iRefList];
     3559#if MERL_VSP_C0152
     3560              motionCompensation( pcCU, pcYuvPred, pcCU->getZorderIdxInCU(),  REF_PIC_LIST_1, iPartIdx );
     3561#else
    35683562              motionCompensation( pcCU, pcYuvPred, eRefPicList, iPartIdx );
    3569 #if H0111_MVD_L1_ZERO
     3563#endif
    35703564            }
    3571 #endif
    35723565          }
    35733566        } // for loop-iRefIdxTemp
     
    35793572            xCopyAMVPInfo(&aacAMVPInfo[0][iRefIdxBi[0]], pcCU->getCUMvField(REF_PIC_LIST_0)->getAMVPInfo());
    35803573            xCheckBestMVP(pcCU, REF_PIC_LIST_0, cMvBi[0], cMvPredBi[0][iRefIdxBi[0]], aaiMvpIdxBi[0][iRefIdxBi[0]], uiBits[2], uiCostBi);
    3581 #if H0111_MVD_L1_ZERO
    35823574            if(!pcCU->getSlice()->getMvdL1ZeroFlag())
    35833575            {
    3584 #endif
    35853576              xCopyAMVPInfo(&aacAMVPInfo[1][iRefIdxBi[1]], pcCU->getCUMvField(REF_PIC_LIST_1)->getAMVPInfo());
    35863577              xCheckBestMVP(pcCU, REF_PIC_LIST_1, cMvBi[1], cMvPredBi[1][iRefIdxBi[1]], aaiMvpIdxBi[1][iRefIdxBi[1]], uiBits[2], uiCostBi);
    3587 #if H0111_MVD_L1_ZERO
    35883578            }
    3589 #endif
    35903579          }
    35913580          break;
    35923581        }
    35933582      } // for loop-iter
    3594 #if LG_RESTRICTEDRESPRED_M24766
     3583#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    35953584      if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0)
    35963585      {
     
    37933782      TComMvField cMRGMvField[2];
    37943783      UInt uiMRGIndex = 0;
    3795 
     3784#if MERL_VSP_C0152
     3785      Int iVSPIndexTrue[3] = {-1, -1, -1};
     3786#endif
    37963787      UInt uiMEInterDir = 0;
    37973788      TComMvField cMEMvField[2];
     
    38053796      if (bTestNormalMC)
    38063797      {
    3807 #if LG_RESTRICTEDRESPRED_M24766
     3798#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    38083799        Int iAddResiShift = pcCU->getResiPredMode(uiPartAddr);
    38093800        iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = \
     
    38163807        xGetInterPredictionError( pcCU, pcOrgYuv, iPartIdx, uiMEError, m_pcEncCfg->getUseHADME() );
    38173808        uiMECost = uiMEError + m_pcRdCost->getCost( uiMEBits );
    3818 #if LG_RESTRICTEDRESPRED_M24766
     3809#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    38193810        if(pcCU->getResPredFlag(0) && iAddResiShift >= 0)
    38203811        {
     
    38443835#else
    38453836#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
    38463852      xMergeEstimation( pcCU, pcOrgYuv, rpcResiPredYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost );
     3853#endif
     3854
     3855
    38473856#else
    38483857      xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost );
     
    38543863        pcCU->setMergeFlagSubParts ( true,          uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    38553864        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
    38563881        pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    38573882        {
     
    38733898        pcCU->setMergeFlagSubParts( false,        uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    38743899        pcCU->setInterDirSubParts ( uiMEInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
     3900#if MERL_VSP_C0152
     3901        pcCU->setVSPIndexSubParts ( 0 ,           uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
     3902#endif
    38753903        {
    38763904          pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMEMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
     
    38813909
    38823910    //  MC
     3911#if MERL_VSP_C0152
     3912    motionCompensation ( pcCU, rpcPredYuv, pcCU->getZorderIdxInCU(), REF_PIC_LIST_X, iPartIdx);
     3913#else
    38833914    motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx );
    3884    
     3915#endif
    38853916  } //  end of for ( Int iPartIdx = 0; iPartIdx < iNumPart; iPartIdx++ )
    38863917
     
    38913922
    38923923// AMVP
    3893 #if H0111_MVD_L1_ZERO
    38943924#if ZERO_MVD_EST
    38953925Void TEncSearch::xEstimateMvPredAMVP( TComDataCU* pcCU, TComYuv* pcOrgYuv, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred, Bool bFilled, UInt* puiDistBiP, UInt* puiDist  )
    38963926#else
    38973927Void TEncSearch::xEstimateMvPredAMVP( TComDataCU* pcCU, TComYuv* pcOrgYuv, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred, Bool bFilled, UInt* puiDistBiP )
    3898 #endif
    3899 #else
    3900 #if ZERO_MVD_EST
    3901 Void TEncSearch::xEstimateMvPredAMVP( TComDataCU* pcCU, TComYuv* pcOrgYuv, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred, Bool bFilled, UInt* puiDist )
    3902 #else
    3903 Void TEncSearch::xEstimateMvPredAMVP( TComDataCU* pcCU, TComYuv* pcOrgYuv, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred, Bool bFilled )
    3904 #endif
    39053928#endif
    39063929{
     
    39343957    pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr));
    39353958
    3936 #if H0111_MVD_L1_ZERO
    39373959    if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefPicList==REF_PIC_LIST_1)
    39383960    {
    3939 #if HHI_INTER_VIEW_MOTION_PRED
     3961#if H3D_IVMP
    39403962      Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 );
    39413963#if ZERO_MVD_EST
     
    39523974#endif
    39533975    }
    3954 #endif
    39553976    return;
    39563977  }
     
    39733994    {
    39743995      UInt uiTmpCost;
    3975 #if HHI_INTER_VIEW_MOTION_PRED
     3996#if H3D_IVMP
    39763997      Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 );
    39773998#if ZERO_MVD_EST
     
    39924013        cBestMv   = pcAMVPInfo->m_acMvCand[i];
    39934014        iBestIdx  = i;
    3994         #if H0111_MVD_L1_ZERO
    39954015        (*puiDistBiP) = uiTmpCost;
    3996         #endif
    39974016        #if ZERO_MVD_EST
    39984017        (*puiDist) = uiDist;
     
    41084127  Int iBestMVPIdx = riMVPIdx;
    41094128 
    4110 #if HHI_INTER_VIEW_MOTION_PRED
     4129#if H3D_IVMP
    41114130  Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 );
    41124131#endif
     
    41144133  m_pcRdCost->setPredictor( rcMvPred );
    41154134  Int iOrgMvBits  = m_pcRdCost->getBits(cMv.getHor(), cMv.getVer());
    4116 #if HHI_INTER_VIEW_MOTION_PRED
     4135#if H3D_IVMP
    41174136  iOrgMvBits += m_auiMVPIdxCost[riMVPIdx][iNumAMVPCands];
    41184137#else
     
    41284147   
    41294148    Int iMvBits = m_pcRdCost->getBits(cMv.getHor(), cMv.getVer());
    4130 #if HHI_INTER_VIEW_MOTION_PRED
     4149#if H3D_IVMP
    41314150    iMvBits += m_auiMVPIdxCost[iMVPIdx][iNumAMVPCands];
    41324151#else
     
    43134332  m_pcRdCost->setCostScale  ( 2 );
    43144333
    4315 #if HHI_INTER_VIEW_MOTION_PRED
     4334#if H3D_IVMP
    43164335  { // init inter-view regularization
    43174336    TComMv  cOrgDepthMapMv;
     
    43384357  m_pcRdCost->setMultiviewReg( 0 );
    43394358#endif
     4359
    43404360  setWpScalingDistParam( pcCU, iRefIdxPred, eRefPicList );
    43414361  //  Do integer search
     
    43514371 
    43524372  m_pcRdCost->getMotionCost( 1, 0 );
     4373
    43534374#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
    43544375  if( ! pcCU->getSlice()->getIsDepth() )
     
    43784399    ruiCost += m_pcRdCost->getCost( uiMvBits );
    43794400#endif
    4380  
     4401
    43814402  ruiBits      += uiMvBits;
    43824403  ruiCost       = (UInt)( floor( fWeight * ( (Double)ruiCost - (Double)m_pcRdCost->getCost( uiMvBits ) ) ) + (Double)m_pcRdCost->getCost( ruiBits ) );
     
    47234744  rcMvQter = *pcMvInt;   rcMvQter <<= 1;    // for mv-cost
    47244745  rcMvQter += rcMvHalf;  rcMvQter <<= 1;
    4725   ruiCost = xPatternRefinement( pcPatternKey, baseRefMv, 1, rcMvQter );
     4746  ruiCost = xPatternRefinement( pcPatternKey, baseRefMv, 1, rcMvQter);
    47264747}
    47274748
     
    47364757 * \returns Void
    47374758 */
    4738 #if HHI_INTER_VIEW_RESIDUAL_PRED
     4759#if H3D_IVRP
    47394760Void TEncSearch::encodeResAndCalcRdInterCU( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* pcYuvPred, TComYuv*& rpcYuvResi, TComYuv*& rpcYuvResiBest, TComYuv*& rpcYuvRec, TComYuv*& rpcYuvResPrd, Bool bSkipRes )
    47404761#else
     
    47544775  UInt      uiWidth      = pcCU->getWidth ( 0 );
    47554776  UInt      uiHeight     = pcCU->getHeight( 0 );
    4756 #if LG_RESTRICTEDRESPRED_M24766
     4777#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    47574778  Int       iPUResiPredShift[4];
    47584779#endif
     
    47644785    pcYuvPred->copyToPartYuv( rpcYuvRec, 0 );
    47654786   
    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
    47674794    // add residual prediction
    47684795    if( pcCU->getResPredFlag( 0 ) )
     
    47764803      rpcYuvRec->clip( uiWidth, uiHeight );
    47774804    }
     4805#endif
    47784806#endif
    47794807
     
    48194847    m_pcEntropyCoder->encodeMergeIndex( pcCU, 0, 0, true );
    48204848#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
    48244856    m_pcEntropyCoder->encodeResPredFlag( pcCU, 0, 0, true );
    48254857#endif
     
    48684900 
    48694901  //  Residual coding.
    4870 #if H0736_AVC_STYLE_QP_RANGE
    48714902  Int    qp, qpBest = 0, qpMin, qpMax;
    4872 #else
    4873   UInt    uiQp, uiQpBest = 0, uiQpMin, uiQpMax;
    4874 #endif
    48754903  Double  dCost, dCostBest = MAX_DOUBLE;
    48764904 
     
    48844912  while((uiWidth>>uiMaxTrMode) < (g_uiMaxCUWidth>>g_uiMaxCUDepth)) uiMaxTrMode--;
    48854913 
    4886 #if H0736_AVC_STYLE_QP_RANGE
    48874914  qpMin =  bHighPass ? Clip3( -pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, pcCU->getQP(0) - m_iMaxDeltaQP ) : pcCU->getQP( 0 );
    48884915  qpMax =  bHighPass ? Clip3( -pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, pcCU->getQP(0) + m_iMaxDeltaQP ) : pcCU->getQP( 0 );
    4889 #else
    4890   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 #endif
    48934916
    48944917  #if HHI_INTERVIEW_SKIP
     
    48994922  else
    49004923  {
    4901 #if LG_RESTRICTEDRESPRED_M24766
     4924#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    49024925    iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0;
    49034926    rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), pcYuvOrg, pcYuvPred, 0, uiWidth );
     
    49054928  rpcYuvResi->subtract( pcYuvOrg, pcYuvPred, 0, uiWidth );
    49064929#endif
    4907 #if HHI_INTER_VIEW_RESIDUAL_PRED
     4930#if H3D_IVRP && !MTK_MDIVRP_C0138
    49084931    // subtract residual prediction
    49094932    if( pcCU->getResPredFlag( 0 ) )
     
    49204943#else
    49214944  rpcYuvResi->subtract( pcYuvOrg, pcYuvPred, 0, uiWidth );
    4922 #if HHI_INTER_VIEW_RESIDUAL_PRED
     4945#if H3D_IVRP
    49234946  // add residual prediction
    49244947  if( pcCU->getResPredFlag( 0 ) )
     
    49294952#endif
    49304953
    4931 #if H0736_AVC_STYLE_QP_RANGE
    49324954  for ( qp = qpMin; qp <= qpMax; qp++ )
    4933 #else
    4934   for ( uiQp = uiQpMin; uiQp <= uiQpMax; uiQp++ )
    4935 #endif
    49364955  {
    49374956    dCost = 0.;
     
    50505069      }
    50515070     
    5052 #if H0736_AVC_STYLE_QP_RANGE
    50535071      if( qpMin != qpMax && qp != qpMax )
    5054 #else
    5055       if( uiQpMin != uiQpMax && uiQp != uiQpMax )
    5056 #endif
    50575072      {
    50585073        const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (pcCU->getDepth(0) << 1);
     
    50735088      uiDistortionBest = uiDistortion;
    50745089      dCostBest        = dCost;
    5075 #if H0736_AVC_STYLE_QP_RANGE
    50765090      qpBest           = qp;
    5077 #else
    5078       uiQpBest         = uiQp;
    5079 #endif     
    50805091      if( m_bUseSBACRD )
    50815092      {
     
    51015112  assert ( dCostBest != MAX_DOUBLE );
    51025113 
    5103 #if H0736_AVC_STYLE_QP_RANGE
    51045114  if( qpMin != qpMax && qpBest != qpMax )
    5105 #else
    5106   if( uiQpMin != uiQpMax && uiQpBest != uiQpMax )
    5107 #endif
    51085115  {
    51095116    if( m_bUseSBACRD )
     
    51275134#endif
    51285135  }
    5129 #if HHI_INTER_VIEW_RESIDUAL_PRED
     5136#if H3D_IVRP && !MTK_MDIVRP_C0138
    51305137  // add residual prediction
    51315138  if( pcCU->getResPredFlag( 0 ) )
     
    51965203  }
    51975204 
    5198 #if H0736_AVC_STYLE_QP_RANGE
    51995205  pcCU->setQPSubParts( qpBest, 0, pcCU->getDepth(0) );
    5200 #else
    5201   pcCU->setQPSubParts( uiQpBest, 0, pcCU->getDepth(0) );
    5202 #endif
    52035206
    52045207  // set Model
     
    52295232  const UInt uiLog2TrSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth]+2;
    52305233 
    5231 #if G519_TU_AMP_NSQT_HARMONIZATION
    52325234  UInt SplitFlag = ((pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ));
    5233 #else
    5234   UInt SplitFlag = ((pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && ( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N));
    5235 #endif
    52365235  Bool bCheckFull;
    52375236  if ( SplitFlag && uiDepth == pcCU->getDepth(uiAbsPartIdx) && ( uiLog2TrSize >  pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) )
     
    52985297    }
    52995298
    5300 #if H0736_AVC_STYLE_QP_RANGE
    53015299    m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
    5302 #else
    5303     m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 );
    5304 #endif
    53055300
    53065301#if RDOQ_CHROMA_LAMBDA
     
    53225317      }
    53235318
    5324 #if H0736_AVC_STYLE_QP_RANGE
    53255319      m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() );
    5326 #else
    5327       m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset() );
    5328 #endif
    53295320
    53305321#if RDOQ_CHROMA_LAMBDA
     
    53375328#endif       
    53385329                                 trWidthC, trHeightC, uiAbsSumU, TEXT_CHROMA_U, uiAbsPartIdx );
    5339 #if H0736_AVC_STYLE_QP_RANGE
    53405330      m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
    5341 #else
    5342       m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
    5343 #endif
    53445331      m_pcTrQuant->transformNxN( pcCU, pcResi->getCrAddr(absTUPartIdxC), pcResi->getCStride(), pcCoeffCurrV,
    53455332#if ADAPTIVE_QP_SELECTION
     
    54405427      Pel *pcResiCurrY = m_pcQTTempTComYuv[ uiQTTempAccessLayer ].getLumaAddr( absTUPartIdx );
    54415428
    5442 #if H0736_AVC_STYLE_QP_RANGE
    54435429      m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
    5444 #else
    5445       m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 );
    5446 #endif
    54475430
    54485431      Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA];
     
    55715554    }
    55725555   
    5573 #if FIX_RDO_NEGDIST
     5556
    55745557    Dist uiDistU = 0;
    55755558    Dist uiDistV = 0;
    5576 #else
    5577     UInt uiDistU = 0;
    5578     UInt uiDistV = 0;
    5579 #endif
    55805559    if( bCodeChroma )
    55815560    {
     
    56015580        Pel *pcResiCurrU = m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( absTUPartIdxC );
    56025581
    5603 #if H0736_AVC_STYLE_QP_RANGE
    56045582        m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() );
    5605 #else
    5606         m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset() );
    5607 #endif
    56085583
    56095584        Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_U];
     
    56155590#endif       
    56165591       
    5617 #if FIX_RDO_NEGDIST
     5592
    56185593        const Dist uiNonzeroDistU = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( absTUPartIdxC), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),
    56195594          pcResi->getCbAddr( absTUPartIdxC), pcResi->getCStride(), trWidthC, trHeightC
    56205595
    5621 #else
    5622         const UInt uiNonzeroDistU = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( absTUPartIdxC), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),
    5623           pcResi->getCbAddr( absTUPartIdxC), pcResi->getCStride(), trWidthC, trHeightC
    5624 #endif
    56255596#if WEIGHTED_CHROMA_DISTORTION
    56265597          , true
     
    56945665        if( !uiAbsSumU )
    56955666        {
    5696 #if H0736_AVC_STYLE_QP_RANGE
    56975667          m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
    5698 #else
    5699           m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
    5700 #endif
    57015668        }
    57025669        Int scalingListType = 3 + g_eTTable[(Int)TEXT_CHROMA_V];
     
    57075674        m_pcTrQuant->invtransformNxN( TEXT_CHROMA,REG_DCT, pcResiCurrV, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrV, trWidthC, trHeightC, scalingListType );
    57085675#endif
    5709 #if FIX_RDO_NEGDIST
    57105676        const Dist uiNonzeroDistV = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getCrAddr( absTUPartIdxC ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),
    57115677          pcResi->getCrAddr( absTUPartIdxC ), pcResi->getCStride(), trWidthC, trHeightC
    5712 #else
    5713         const UInt uiNonzeroDistV = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getCrAddr( absTUPartIdxC ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),
    5714           pcResi->getCrAddr( absTUPartIdxC ), pcResi->getCStride(), trWidthC, trHeightC
    5715 #endif
    57165678#if WEIGHTED_CHROMA_DISTORTION
    57175679                                                   , true
     
    62026164    m_pcEntropyCoder->encodeMergeIndex(pcCU, 0, 0, true);
    62036165#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
    62076173    m_pcEntropyCoder->encodeResPredFlag( pcCU, 0, 0, true );
    62086174#endif
     
    62256191    m_pcEntropyCoder->encodePredInfo( pcCU, 0, true );
    62266192#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
    62306200    m_pcEntropyCoder->encodeResPredFlag( pcCU, 0, 0, true );
    62316201#endif
     
    65646534    Int iFullDeltaDC2 = riDeltaDC2;
    65656535
     6536#if HHI_DMM_DELTADC_Q1_C0034
     6537#else
    65666538    xDeltaDCQuantScaleDown( pcCU, iFullDeltaDC1 );
    65676539    xDeltaDCQuantScaleDown( pcCU, iFullDeltaDC2 );
     6540#endif
    65686541
    65696542    Dist uiBestDist     = RDO_DIST_MAX;
     
    65786551    uiDeltaDC2Max += (uiDeltaDC2Max>>1);
    65796552
     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
    65806701    for( UInt uiQStepDC1 = 1; uiQStepDC1 <= uiDeltaDC1Max; uiQStepDC1++  )
    65816702    {
     
    66336754      }
    66346755    }
    6635 
     6756#endif
    66366757    iFullDeltaDC1 = (Int)(uiBestQStepDC1) * (Int)(( iFullDeltaDC1 < 0 ) ? -1 : 1);
    66376758    iFullDeltaDC2 = (Int)(uiBestQStepDC2) * (Int)(( iFullDeltaDC2 < 0 ) ? -1 : 1);
     6759#if HHI_DMM_DELTADC_Q1_C0034
     6760#else
    66386761    xDeltaDCQuantScaleUp( pcCU, iFullDeltaDC1 );
    66396762    xDeltaDCQuantScaleUp( pcCU, iFullDeltaDC2 );
     6763#endif
    66406764    riDeltaDC1 = iFullDeltaDC1;
    66416765    riDeltaDC2 = iFullDeltaDC2;
     
    66436767#endif
    66446768
     6769#if HHI_DMM_DELTADC_Q1_C0034
     6770#else
    66456771  xDeltaDCQuantScaleDown( pcCU, riDeltaDC1 );
    66466772  xDeltaDCQuantScaleDown( pcCU, riDeltaDC2 );
     6773#endif
    66476774}
    66486775#endif
     
    66656792  WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])];
    66666793  Dist iDist = RDO_DIST_MAX;
    6667 #if HHIQC_DMMFASTSEARCH_B0039
    66686794  WedgeNodeList* pacWedgeNodeList = &g_aacWedgeNodeLists[(g_aucConvertToBit[uiWidth])];
    66696795  xSearchWedgeFullMinDistFast( pcCU, uiAbsPtIdx, pacWedgeNodeList, pacWedgeList, piOrig, uiStride, uiWidth, uiHeight, ruiTabIdx, iDist );
    6670 #else
    6671   xSearchWedgeFullMinDist( pcCU, uiAbsPtIdx, pacWedgeList, piOrig, uiStride, uiWidth, uiHeight, ruiTabIdx, iDist );
    6672 #endif
    66736796
    66746797  TComWedgelet* pcBestWedgelet = &(pacWedgeList->at(ruiTabIdx));
     
    67816904}
    67826905
    6783 #if HHIQC_DMMFASTSEARCH_B0039
    67846906Void TEncSearch::xSearchWedgeFullMinDistFast( TComDataCU* pcCU, UInt uiAbsPtIdx, WedgeNodeList* pacWedgeNodeList, WedgeList* pacWedgeList, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, Dist& riDist )
    67856907{
     
    69007022  return;
    69017023}
    6902 #endif
    69037024
    69047025Void TEncSearch::xSearchWedgePredDirMinDist( TComDataCU* pcCU, UInt uiAbsPtIdx, WedgeList* pacWedgeList, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, Int& riWedgeDeltaEnd )
     
    69917112  return;
    69927113}
    6993 #endif
     7114#endif //  HHI_DMM_WEDGE_INTRA
     7115
    69947116#if HHI_DMM_PRED_TEX
    69957117Void TEncSearch::findWedgeTexMinDist( TComDataCU*  pcCU,
     
    70047126                                      Int&         riDeltaDC2,
    70057127                                      Bool         bAboveAvail,
    7006                                       Bool         bLeftAvail )
     7128                                      Bool         bLeftAvail
     7129#if LGE_DMM3_SIMP_C0044
     7130                                      ,UInt&        ruiIntraTabIdx
     7131#endif
     7132                                      )
    70077133{
    70087134  assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE );
    70097135  WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])];
    70107136
     7137#if LGE_DMM3_SIMP_C0044
     7138  ruiTabIdx = getBestWedgeFromTex( pcCU, uiAbsPtIdx, uiWidth, uiHeight, piOrig, uiStride, ruiIntraTabIdx );
     7139#else
    70117140  ruiTabIdx = getBestWedgeFromTex( pcCU, uiAbsPtIdx, uiWidth, uiHeight );
     7141#endif
    70127142
    70137143  TComWedgelet* pcBestWedgelet = &(pacWedgeList->at(ruiTabIdx));
     
    70367166  delete pcContourWedge;
    70377167}
    7038 #endif
     7168#endif // HHI_DMM_PRED_TEX
    70397169
    70407170#if LGE_EDGE_INTRA_A0070
     
    81368266    iDeltaDC1 = iFullDeltaDC1;
    81378267  }
    8138 #endif
     8268#endif // HHI_VSO
    81398269
    81408270  xDeltaDCQuantScaleDown( pcCU, iDeltaDC0 );
     
    81448274  pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 );
    81458275}
    8146 #endif
    8147 #endif
     8276#endif // LGE_EDGE_INTRA_DELTA_DC
     8277#endif // LGE_EDGE_INTRA_A0070
    81488278 
    81498279#if RWTH_SDC_DLT_B0036
     
    81548284  Int iSumPix[2];
    81558285  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
    81578311  for (Int y=0; y<uiSize; y++)
    81588312  {
     
    81698323    pMask  += uiMaskStride;
    81708324  }
    8171  
     8325#endif // HS_REFERENCE_SUBSAMPLE_C0154
    81728326  // compute mean for each segment
    81738327  for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ )
     
    81798333  }
    81808334}
    8181 #endif
     8335#endif // RWTH_SDC_DLT_B0036
    81828336
    81838337//! \}
  • trunk/source/Lib/TLibEncoder/TEncSearch.h

    r210 r296  
    121121 
    122122  // AMVP cost computation
    123 #if HHI_INTER_VIEW_MOTION_PRED
     123#if H3D_IVMP
    124124  UInt            m_auiMVPIdxCost[AMVP_MAX_NUM_CANDS+2][AMVP_MAX_NUM_CANDS+2]; //th array bounds
    125125#else
     
    152152  UInt  xPatternRefinement( TComPattern* pcPatternKey,
    153153                           TComMv baseRefMv,
    154                            Int iFrac, TComMv& rcMvFrac );
     154                           Int iFrac, TComMv& rcMvFrac);
    155155 
    156156  typedef struct
     
    196196  Void predInterSearch          ( TComDataCU* pcCU,
    197197                                  TComYuv*    pcOrgYuv,
    198 #if LG_RESTRICTEDRESPRED_M24766
     198#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    199199                                  TComYuv*    rpcResiPredYuv,
    200200#endif
     
    208208                                );
    209209 
    210 #if HHI_INTER_VIEW_RESIDUAL_PRED
     210#if H3D_IVRP
    211211  /// encode residual and compute rd-cost for inter mode
    212212  Void encodeResAndCalcRdInterCU( TComDataCU* pcCU,
     
    401401                                    UInt&          ruiTabIdx,
    402402                                    Dist&          riDist );
    403 #if HHIQC_DMMFASTSEARCH_B0039
     403
    404404  Void xSearchWedgeFullMinDistFast( TComDataCU*    pcCU,
    405405                                    UInt           uiAbsPtIdx,
     
    412412                                    UInt&          ruiTabIdx,
    413413                                    Dist&          riDist );
    414 #endif
    415414  Void xSearchWedgePredDirMinDist ( TComDataCU*    pcCU,
    416415                                    UInt           uiAbsPtIdx,
     
    422421                                    UInt&          ruiTabIdx,
    423422                                    Int&           riWedgeDeltaEnd );
    424 #endif
     423#endif // HHI_DMM_WEDGE_INTRA
    425424#if HHI_DMM_PRED_TEX
    426425  Void findWedgeTexMinDist        ( TComDataCU*    pcCU,
     
    435434                                    Int&           riDeltaDC2,
    436435                                    Bool           bAboveAvail,
    437                                     Bool           bLeftAvail );
     436                                    Bool           bLeftAvail
     437#if LGE_DMM3_SIMP_C0044
     438                                    ,UInt&         ruiIntraTabIdx
     439#endif
     440                                    );
    438441  Void findContourPredTex         ( TComDataCU*    pcCU,
    439442                                    UInt           uiAbsPtIdx,
     
    447450                                    Bool           bAboveAvail,
    448451                                    Bool           bLeftAvail );
    449 #endif
     452#endif // HHI_DMM_PRED_TEX
    450453
    451454  // -------------------------------------------------------------------------------------------------------------------
     
    460463                                    TComMv&     rcMvPred,
    461464                                    Bool        bFilled = false
    462                                   #if H0111_MVD_L1_ZERO
    463465                                  , UInt*       puiDistBiP = NULL
    464                                   #endif
    465466                                  #if ZERO_MVD_EST
    466467                                  , UInt*       puiDist = NULL
     
    500501  Void xMergeEstimation           ( TComDataCU*     pcCU,
    501502                                    TComYuv*        pcYuvOrg,
    502 #if LG_RESTRICTEDRESPRED_M24766
     503#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
    503504                                    TComYuv*        rpcResiPredYuv,
    504505#endif
     
    512513                                    UChar* uhInterDirNeighbours,
    513514                                    Int& numValidMergeCand
     515#endif
     516#if MERL_VSP_C0152
     517                                  , Int* iVSPIndexTrue
    514518#endif
    515519                                   );
     
    579583                                    TComMv&       rcMvQter,
    580584                                    UInt&         ruiCost
    581                                    ,Bool biPred
    582                                    );
     585                                   ,Bool biPred);
    583586 
    584587  Void xExtDIFUpSamplingH( TComPattern* pcPattern, Bool biPred  );
  • trunk/source/Lib/TLibEncoder/TEncSlice.cpp

    r210 r296  
    163163 */
    164164#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
     165#if MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137
     166Void TEncSlice::initEncSlice( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS * pVPS, TComSPS* pSPS, TComPPS *pPPS, bool isDepth )
     167#else
    165168Void TEncSlice::initEncSlice( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS * pVPS, TComSPS* pSPS, TComPPS *pPPS )
     169#endif
    166170#else
    167171Void TEncSlice::initEncSlice( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS )
     
    181185  rpcSlice->initSlice();
    182186  rpcSlice->initTiles();
    183 #if H0388
    184187  rpcSlice->setPicOutputFlag( true );
    185 #endif
    186188  rpcSlice->setPOC( uiPOCCurr );
    187189 
    188 #if SONY_COLPIC_AVAILABILITY
    189   rpcSlice->setViewOrderIdx(m_pcCfg->getViewOrderIdx());
     190#if INTER_VIEW_VECTOR_SCALING_C0115
     191  rpcSlice->setViewOrderIdx(m_pcCfg->getViewOrderIdx());    // will be changed to view_id
    190192#endif
    191193#if LGE_ILLUCOMP_B0045
     
    258260  {
    259261#if LOSSLESS_CODING
    260 #if H0736_AVC_STYLE_QP_RANGE
    261262    if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless())))
    262 #else
    263     if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == 0 ) && (rpcSlice->getSPS()->getUseLossless())))
    264 #endif
    265263#endif
    266264    {
     
    330328    }
    331329   
    332 #if H0736_AVC_STYLE_QP_RANGE
    333330    iQP = max( -pSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
    334 #else
    335     iQP = max( MIN_QP, min( MAX_QP, (Int)floor( dQP + 0.5 ) ) );
    336 #endif
    337331
    338332    m_pdRdPicLambda[iDQpIdx] = dLambda;
     
    356350// for RDO
    357351  // 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_RANGE
    359352  Double weight = 1.0;
    360353  if(iQP >= 0)
     
    362355    weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 );  // takes into account of the chroma qp mapping without chroma qp Offset
    363356  }
    364 #else
    365   Double weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 );  // takes into account of the chroma qp mapping without chroma qp Offset
    366 #endif
    367357  m_pcRdCost ->setChromaDistortionWeight( weight );     
    368358#endif
     
    405395#endif
    406396 
    407 #if HHI_INTER_VIEW_MOTION_PRED
     397#if H3D_IVMP
    408398  m_pcRdCost ->setLambdaMVReg ( dLambda * m_pcCfg->getMultiviewMvRegLambdaScale() );
    409399#endif
     
    428418 
    429419  rpcSlice->setLoopFilterOffsetInAPS( m_pcCfg->getLoopFilterOffsetInAPS() );
    430 #if DBL_CONTROL
    431420  if (rpcSlice->getPPS()->getDeblockingFilterControlPresent())
    432421  {
    433 #endif
    434422    rpcSlice->setInheritDblParamFromAPS( m_pcCfg->getLoopFilterOffsetInAPS() ? 1 : 0 );
    435423    rpcSlice->setLoopFilterDisable( m_pcCfg->getLoopFilterDisable() );
     
    439427      rpcSlice->setLoopFilterTcOffset( m_pcCfg->getLoopFilterTcOffset() );
    440428    }
    441 #if DBL_CONTROL
    442   }
    443 #endif
     429  }
    444430
    445431  rpcSlice->setDepth            ( iDepth );
     
    451437  }
    452438  rpcSlice->setTLayer( pcPic->getTLayer() );
    453 #if !H0566_TLA
    454   rpcSlice->setTLayerSwitchingFlag( pPPS->getTLayerSwitchingFlag( pcPic->getTLayer() ) );
    455 #endif
    456439
    457440  assert( m_apcPicYuvPred );
     
    465448  rpcSlice->setEntropySliceArgument ( m_pcCfg->getEntropySliceArgument() );
    466449
    467 #if ( HHI_MPI || HHI_INTER_VIEW_MOTION_PRED )
    468   #if ( HHI_MPI && HHI_INTER_VIEW_MOTION_PRED )
     450#if ( HHI_MPI || H3D_IVMP )
     451  #if ( HHI_MPI && H3D_IVMP )
    469452  const int iExtraMergeCandidates = ( pSPS->getUseMVI() || pSPS->getMultiviewMvPredMode() ) ? 1 : 0;
    470453  #elif HHI_MPI
    471454  const int iExtraMergeCandidates = pSPS->getUseMVI() ? 1 : 0;
     455  #elif MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137
     456  const int iExtraMergeCandidates = ( isDepth || pSPS->getMultiviewMvPredMode() ) ? 1 : 0;
    472457  #else
    473458  const int iExtraMergeCandidates = pSPS->getMultiviewMvPredMode() ? 1 : 0;
     
    552537    // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma.
    553538    int iQP = m_piRdPicQp    [uiQpIdx];
    554 #if H0736_AVC_STYLE_QP_RANGE
    555539    Double weight = 1.0;
    556540    if(iQP >= 0)
     
    558542      weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 );  // takes into account of the chroma qp mapping without chroma qp Offset
    559543    }
    560 #else
    561     Double weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 );  // takes into account of the chroma qp mapping without chroma qp Offset
    562 #endif
    563544    m_pcRdCost    ->setChromaDistortionWeight( weight );     
    564545#endif
     
    576557    pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdx] );
    577558#endif
    578 #if HHI_INTER_VIEW_MOTION_PRED
     559#if H3D_IVMP
    579560    m_pcRdCost    ->setLambdaMVReg         ( m_pdRdPicLambda[uiQpIdx] * m_pcCfg->getMultiviewMvRegLambdaScale() );
    580561#endif
     
    608589  // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma.
    609590  int iQP = m_piRdPicQp    [uiQpIdxBest];
    610 #if H0736_AVC_STYLE_QP_RANGE
    611591  Double weight = 1.0;
    612592  if(iQP >= 0)
     
    614594    weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 );  // takes into account of the chroma qp mapping without chroma qp Offset
    615595  }
    616 #else
    617   Double weight = pow( 2.0, (iQP-g_aucChromaScale[iQP])/3.0 );  // takes into account of the chroma qp mapping without chroma qp Offset
    618 #endif
    619596  m_pcRdCost ->setChromaDistortionWeight( weight );     
    620597#endif
     
    632609  pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest] );
    633610#endif
    634 #if HHI_INTER_VIEW_MOTION_PRED
     611#if H3D_IVMP
    635612  m_pcRdCost    ->setLambdaMVReg         ( m_pdRdPicLambda[uiQpIdxBest] * m_pcCfg->getMultiviewMvRegLambdaScale() );
    636613#endif
     
    770747
    771748#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
    773754  {
    774755    pcSlice ->xSetApplyIC();
     
    811792      m_pcBufferLowLatSbacCoders[ui].load(m_pppcRDSbacCoder[0][CI_CURR_BEST]);  //init. state
    812793  }
     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
    813802  UInt uiWidthInLCUs  = rpcPic->getPicSym()->getFrameWidthInCU();
    814803  //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU();
    815804  UInt uiCol=0, uiLin=0, uiSubStrm=0;
    816 #if !REMOVE_TILE_DEPENDENCE
    817   Int  iBreakDep      = 0;
    818 #endif
    819805  UInt uiTileCol      = 0;
    820806  UInt uiTileStartLCU = 0;
     
    851837    if( m_pcCfg->getUseSBACRD() )
    852838    {
    853 #if !REMOVE_TILE_DEPENDENCE
    854       iBreakDep = rpcPic->getPicSym()->getTileBoundaryIndependenceIdr();
    855 #endif
    856839      uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in?
    857840      uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
     
    860843      uiCol     = uiCUAddr % uiWidthInLCUs;
    861844      uiLin     = uiCUAddr / uiWidthInLCUs;
    862 #if !REMOVE_TILE_DEPENDENCE
    863 #if WPP_SIMPLIFICATION
    864       if (iBreakDep && pcSlice->getPPS()->getNumSubstreams() > 1)
    865 #else
    866       if (iBreakDep && pcSlice->getPPS()->getEntropyCodingSynchro())
    867 #endif
    868 #else
    869 #if WPP_SIMPLIFICATION
    870845      if (pcSlice->getPPS()->getNumSubstreams() > 1)
    871 #else
    872       if (pcSlice->getPPS()->getEntropyCodingSynchro())
    873 #endif
    874 #endif
    875846      {
    876847        // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
     
    884855        uiSubStrm = uiLin % iNumSubstreams;
    885856      }
    886 #if WPP_SIMPLIFICATION
    887857      if ( pcSlice->getPPS()->getNumSubstreams() > 1 && (uiCol == uiTileLCUX) )
    888 #else
    889       if ( pcSlice->getPPS()->getEntropyCodingSynchro() && (uiCol == uiTileLCUX) )
    890 #endif
    891858      {
    892859        // We'll sync if the TR is available.
     
    895862        UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1);
    896863        TComDataCU *pcCUTR = NULL;
    897 #if WPP_SIMPLIFICATION
    898864        if ( pcCUUp && ((uiCUAddr%uiWidthInCU+1) < uiWidthInCU)  )
    899865        {
    900866          pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 );
    901867        }
    902 #else
    903         if ( pcCUUp && ((uiCUAddr%uiWidthInCU+pcSlice->getPPS()->getEntropyCodingSynchro()) < uiWidthInCU)  )
    904         {
    905           pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + pcSlice->getPPS()->getEntropyCodingSynchro() );
    906         }
    907 #endif
    908868        if ( ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    909869             (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) ||
    910 #if !REMOVE_TILE_DEPENDENCE
    911              (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr() && (rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
    912 #else
    913870             ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
    914 #endif
    915871             )||
    916872             ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    917873             (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getEntropySliceCurStartCUAddr()) ||
    918 #if !REMOVE_TILE_DEPENDENCE
    919              (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr() && (rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
    920 #else
    921874             ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
    922 #endif
    923875             )
    924876           )
     
    957909#endif
    958910    }
    959 #if !REMOVE_TILE_DEPENDENCE
    960     if( (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr()==0) && (rpcPic->getPicSym()->getNumColumnsMinus1()!=0) )
    961     {
    962       // Synchronize cabac probabilities with LCU among Tiles
    963       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         else
    984         {
    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 code
    988         }
    989       }
    990     }
    991 #endif
    992911    // if RD based on SBAC is used
    993912    if( m_pcCfg->getUseSBACRD() )
     
    1027946       
    1028947         //Store probabilties of second LCU in line into buffer
    1029 #if WPP_SIMPLIFICATION
    1030948        if (pcSlice->getPPS()->getNumSubstreams() > 1 && uiCol == uiTileLCUX+1)
    1031 #else
    1032         if (pcSlice->getPPS()->getEntropyCodingSynchro() && uiCol == uiTileLCUX+pcSlice->getPPS()->getEntropyCodingSynchro())
    1033 #endif
    1034949        {
    1035950          m_pcBufferSbacCoders[uiTileCol].loadContexts(ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]);
    1036951        }
    1037952      }
    1038 #if !REMOVE_TILE_DEPENDENCE
    1039       if( (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr()==0) && (rpcPic->getPicSym()->getNumColumnsMinus1()!=0) )
    1040       {
    1041          //Store probabilties for next tile
    1042         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 #endif
    1049953    }
    1050954    // other case: encodeCU is not called
     
    11301034  UInt uiWidthInLCUs  = rpcPic->getPicSym()->getFrameWidthInCU();
    11311035  UInt uiCol=0, uiLin=0, uiSubStrm=0;
    1132 #if !REMOVE_TILE_DEPENDENCE
    1133   Int  iBreakDep      = 0;
    1134 #endif
    11351036  UInt uiTileCol      = 0;
    11361037  UInt uiTileStartLCU = 0;
     
    11381039
    11391040  UInt uiEncCUOrder;
     1041
    11401042  uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());  /*for tiles, uiStartCUAddr is NOT the real raster scan address, it is actually
    11411043                                                                                              an encoding order index, so we need to convert the index (uiStartCUAddr)
     
    11471049    if( m_pcCfg->getUseSBACRD() )
    11481050    {
    1149 #if !REMOVE_TILE_DEPENDENCE
    1150       iBreakDep = rpcPic->getPicSym()->getTileBoundaryIndependenceIdr();
    1151 #endif
    11521051      uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in?
    11531052      uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
     
    11561055      uiCol     = uiCUAddr % uiWidthInLCUs;
    11571056      uiLin     = uiCUAddr / uiWidthInLCUs;
    1158 #if !REMOVE_TILE_DEPENDENCE
    1159 #if WPP_SIMPLIFICATION
    1160       if (iBreakDep && pcSlice->getPPS()->getNumSubstreams() > 1)
    1161 #else
    1162       if (iBreakDep && pcSlice->getPPS()->getEntropyCodingSynchro())
    1163 #endif
    1164 #else
    1165 #if WPP_SIMPLIFICATION
    11661057      if (pcSlice->getPPS()->getNumSubstreams() > 1)
    1167 #else
    1168       if (pcSlice->getPPS()->getEntropyCodingSynchro())
    1169 #endif
    1170 #endif
    11711058      {
    11721059        // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
     
    11841071
    11851072      // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line.
    1186 #if WPP_SIMPLIFICATION
    11871073      if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiCol == uiTileLCUX))
    1188 #else
    1189       if (pcSlice->getPPS()->getEntropyCodingSynchro() && (uiCol == uiTileLCUX))
    1190 #endif
    11911074      {
    11921075        // We'll sync if the TR is available.
     
    11951078        UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1);
    11961079        TComDataCU *pcCUTR = NULL;
    1197 #if WPP_SIMPLIFICATION
    11981080        if ( pcCUUp && ((uiCUAddr%uiWidthInCU+1) < uiWidthInCU)  )
    11991081        {
    12001082          pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 );
    12011083        }
    1202 #else
    1203         if ( pcCUUp && ((uiCUAddr%uiWidthInCU+pcSlice->getPPS()->getEntropyCodingSynchro()) < uiWidthInCU)  )
    1204         {
    1205           pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + pcSlice->getPPS()->getEntropyCodingSynchro() );
    1206         }
    1207 #endif
    12081084        if ( (true/*bEnforceSliceRestriction*/ &&
    12091085             ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    12101086             (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) ||
    1211 #if !REMOVE_TILE_DEPENDENCE
    1212              (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr() && (rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
    1213 #else
    12141087             ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
    1215 #endif
    12161088             ))||
    12171089             (true/*bEnforceEntropySliceRestriction*/ &&
    12181090             ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    12191091             (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getEntropySliceCurStartCUAddr()) ||
    1220 #if !REMOVE_TILE_DEPENDENCE
    1221              (rpcPic->getPicSym()->getTileBoundaryIndependenceIdr() && (rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
    1222 #else
    12231092             ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
    1224 #endif
    12251093             ))
    12261094           )
     
    12561124        // When tiles are independent, we have "substreams per tile".  Each substream has already been terminated, and we no longer
    12571125        // have to perform it here.
    1258 #if WPP_SIMPLIFICATION
    12591126        if (pcSlice->getPPS()->getNumSubstreams() > 1)
    1260 #else
    1261         if (pcSlice->getPPS()->getEntropyCodingSynchro())
    1262 #endif
    12631127        {
    12641128          ; // do nothing.
     
    13101174
    13111175    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
    13471177    if ( pcSlice->getSPS()->getUseSAO() && pcSlice->getAPS()->getSaoInterleavingFlag() && pcSlice->getSaoEnabledFlag() )
    13481178    {
     
    13541184      m_pcEntropyCoder->encodeSaoUnitInterleaving( rx, ry, pcSlice->getAPS()->getSaoParam(),pcCU, iCUAddrInSlice, iCUAddrUpInSlice, pcSlice->getSPS()->getLFCrossSliceBoundaryFlag());
    13551185    }
    1356 #endif
    13571186#if ENC_DEC_TRACE
    13581187    g_bJustDoIt = g_bEncDecTraceEnable;
     
    13761205
    13771206       //Store probabilties of second LCU in line into buffer
    1378 #if WPP_SIMPLIFICATION
    13791207      if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiCol == uiTileLCUX+1))
    1380 #else
    1381       if (pcSlice->getPPS()->getEntropyCodingSynchro() && (uiCol == uiTileLCUX+pcSlice->getPPS()->getEntropyCodingSynchro()))
    1382 #endif
    13831208      {
    13841209        m_pcBufferSbacCoders[uiTileCol].loadContexts( &pcSbacCoders[uiSubStrm] );
    13851210      }
    13861211    }
    1387 #if !REMOVE_TILE_DEPENDENCE
    1388     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 coder
    1391        //Store probabilties for next tile
    1392       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 #endif
    13991212
    14001213#if OL_QTLIMIT_PREDCODING_B0068
     
    14261239  TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx());
    14271240  UInt uiStartCUAddrSlice, uiBoundingCUAddrSlice;
    1428 #if FIXED_NUMBER_OF_TILES_SLICE_MODE
    14291241  UInt tileIdxIncrement;
    14301242  UInt tileIdx;
     
    14321244  UInt tileHeightInLcu;
    14331245  UInt tileTotalCount;
    1434 #endif
    14351246
    14361247  uiStartCUAddrSlice        = pcSlice->getSliceCurStartCUAddr();
     
    14501261      uiBoundingCUAddrSlice    = pcSlice->getSliceCurEndCUAddr();
    14511262      break;
    1452 #if FIXED_NUMBER_OF_TILES_SLICE_MODE
    14531263    case AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE:
    14541264      tileIdx                = rpcPic->getPicSym()->getTileIdxMap(
     
    14701280      uiBoundingCUAddrSlice    = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU()) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();
    14711281      break;
    1472 #endif
    14731282    default:
    14741283      uiCUAddrIncrement        = rpcPic->getNumCUsInFrame();
     
    14871296      uiBoundingCUAddrSlice    = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU()) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();
    14881297      break;
    1489 #if FIXED_NUMBER_OF_TILES_SLICE_MODE
    14901298    case AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE:
    14911299      tileIdx                = rpcPic->getPicSym()->getTileIdxMap(
     
    15071315      uiBoundingCUAddrSlice    = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*rpcPic->getNumPartInCU()) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();
    15081316      break;
    1509 #endif
    15101317    default:
    15111318      uiCUAddrIncrement        = rpcPic->getNumCUsInFrame();
     
    15161323  }
    15171324
    1518 #if COMPLETE_SLICES_IN_TILE
    15191325  Bool tileBoundary = false;
    15201326  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) &&
     
    15391345    }
    15401346  }
    1541 #endif
    15421347
    15431348  // Entropy slice
     
    16441449      || (m_pcCfg->getSliceMode()==0 && m_pcCfg->getEntropySliceMode()==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE)
    16451450      || (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE && m_pcCfg->getEntropySliceMode()==0)
    1646 #if FIXED_NUMBER_OF_TILES_SLICE_MODE
    16471451      || (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE && m_pcCfg->getEntropySliceMode()==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE)
    16481452      || (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE && m_pcCfg->getEntropySliceMode()==0)
    1649 #endif
    1650 #if COMPLETE_SLICES_IN_TILE
    16511453      || tileBoundary
    1652 #endif
    16531454)
    16541455    {
  • trunk/source/Lib/TLibEncoder/TEncSlice.h

    r210 r296  
    101101 
    102102  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
    103112public:
    104113  TEncSlice();
     
    111120  /// preparation of slice encoding (reference marking, QP and lambda)
    112121#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
    113125  Void    initEncSlice        ( TComPic*  pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS );
     126#endif
    114127#else
    115128  Void    initEncSlice        ( TComPic*  pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS );
     
    128141  UInt    getSliceIdx()         { return m_uiSliceIdx;                    }
    129142  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
    130152};
    131153
  • trunk/source/Lib/TLibEncoder/TEncTop.cpp

    r210 r296  
    103103  if (m_bUseSAO)
    104104  {
    105 #if SAO_UNIT_INTERLEAVING
    106105    m_cEncSAO.setSaoInterleavingFlag(getSaoInterleavingFlag());
    107106    m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic());
    108 #endif
    109107    m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
    110108    m_cEncSAO.createEncBuffer();
     
    122120  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) );
    123121#endif
    124 #if HHI_INTER_VIEW_RESIDUAL_PRED
     122#if H3D_IVRP
    125123  m_cResidualGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement );
    126124#endif
     
    128126  if(m_bUseALF)
    129127  {
    130 #if LCU_SYNTAX_ALF
    131128    m_cAdaptiveLoopFilter.setAlfCoefInSlice(m_bALFParamInSlice);
    132129    m_cAdaptiveLoopFilter.createAlfGlobalBuffers();
    133 #else
    134     m_cAdaptiveLoopFilter.setGOPSize( getGOPSize() );
    135     m_cAdaptiveLoopFilter.createAlfGlobalBuffers(m_iALFEncodePassReduction);
    136 #endif
    137130  }
    138131
     
    258251  m_cDepthMapGenerator. destroy();
    259252#endif
    260 #if HHI_INTER_VIEW_RESIDUAL_PRED
     253#if H3D_IVRP
    261254  m_cResidualGenerator. destroy();
    262255#endif
     
    333326  // initialize PPS
    334327  m_cPPS.setSPS(&m_cSPS);
    335 #if RPS_IN_SPS
    336328  m_cSPS.setRPSList(&m_RPSList);
    337 #else
    338   m_cPPS.setRPSList(&m_RPSList);
    339 #endif
    340329  xInitPPS();
    341330  xInitRPS();
     
    358347#endif
    359348#endif
    360 #if HHI_INTER_VIEW_RESIDUAL_PRED
     349#if H3D_IVRP
    361350  m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator );
    362351#endif
     
    384373    m_cAdaptiveLoopFilter.setALFEncodePassReduction( m_iALFEncodePassReduction );
    385374    m_cAdaptiveLoopFilter.setALFMaxNumberFilters( m_iALFMaxNumberFilters );
    386 #if LCU_SYNTAX_ALF
    387375    m_cAdaptiveLoopFilter.initPicQuadTreePartition(m_bALFPicBasedEncode );   
    388 #endif
    389376  }
    390377
     
    404391  pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );
    405392
    406 #if SONY_COLPIC_AVAILABILITY
    407   pcPicCurr->setViewOrderIdx(m_iViewOrderIdx);
     393#if INTER_VIEW_VECTOR_SCALING_C0115
     394  pcPicCurr->setViewOrderIdx(m_iViewOrderIdx);    // will be changed to view_id
    408395#endif
    409396  pcPicCurr->setScaleOffset( m_aaiCodedScale, m_aaiCodedOffset );
    410397
    411 #if HHI_INTER_VIEW_MOTION_PRED
     398#if H3D_IVMP
    412399  if( m_uiMultiviewMvRegMode )
    413400  {
     
    486473
    487474
    488 #if HHI_INTERVIEW_SKIP || HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED
     475#if HHI_INTERVIEW_SKIP || H3D_IVMP || H3D_IVRP
    489476Void
    490477TEncTop::deleteExtraPicBuffers( Int iPoc )
     
    504491  if ( pcPic )
    505492  {
    506 #if HHI_INTER_VIEW_MOTION_PRED
     493#if H3D_IVMP
    507494    pcPic->removeOrgDepthMapBuffer();
    508495#endif
    509 #if HHI_INTER_VIEW_RESIDUAL_PRED
     496#if H3D_IVRP
    510497    pcPic->removeResidualBuffer   ();
    511498#endif
     
    553540  TComSlice::sortPicList(m_cListPic);
    554541 
    555 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
    556542  if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) )
    557 #else
    558   if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxNumberOfReferencePictures() + 2) )
    559 #endif
    560543  {
    561544    TComList<TComPic*>::iterator iterPic  = m_cListPic.begin();
     
    594577  m_iNumPicRcvd++;
    595578 
    596 #if HHI_INTER_VIEW_MOTION_PRED
     579#if H3D_IVMP
    597580  if( m_uiMultiviewMvRegMode )
    598581  {
     
    611594  m_cSPS.setPicWidthInLumaSamples         ( m_iSourceWidth      );
    612595  m_cSPS.setPicHeightInLumaSamples        ( m_iSourceHeight     );
    613 #if PIC_CROPPING
    614596  m_cSPS.setPicCroppingFlag( m_croppingMode!= 0 );
    615597  if (m_croppingMode != 0)
     
    620602    m_cSPS.setPicCropBottomOffset( m_cropBottom );
    621603  }
    622 #else
    623   m_cSPS.setPad           ( m_aiPad             );
    624 #endif
    625604  m_cSPS.setMaxCUWidth    ( g_uiMaxCUWidth      );
    626605  m_cSPS.setMaxCUHeight   ( g_uiMaxCUHeight     );
     
    629608  m_cSPS.setMaxTrDepth    ( 1                   );
    630609 
    631 #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
    632   m_cSPS.setMaxNumberOfReferencePictures(m_maxNumberOfReferencePictures);
    633   m_cSPS.setNumReorderFrames(m_numReorderFrames);
    634 #endif
    635610  m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize);
    636611  m_cSPS.setUsePCM        ( m_usePCM           );
     
    638613
    639614  m_cSPS.setUseALF        ( m_bUseALF           );
    640 #if LCU_SYNTAX_ALF
    641615  if(m_bUseALF)
    642616  {
    643617    m_cSPS.setUseALFCoefInSlice(m_bALFParamInSlice);
    644618  }
    645 #endif
    646619 
    647620#if RWTH_SDC_DLT_B0036
     
    657630  m_cSPS.setUseLossless   ( m_useLossless  );
    658631#endif
    659 #if !PIC_CROPPING
    660   m_cSPS.setUsePAD        ( m_bUsePAD           );
    661 #endif
    662632  m_cSPS.setUseLMChroma   ( m_bUseLMChroma           ); 
    663633 
     
    696666  m_cSPS.setBitDepth    ( g_uiBitDepth        );
    697667  m_cSPS.setBitIncrement( g_uiBitIncrement    );
    698 #if H0736_AVC_STYLE_QP_RANGE
    699668  m_cSPS.setQpBDOffsetY ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) );
    700669  m_cSPS.setQpBDOffsetC ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) );
    701 #endif
    702670
    703671  m_cSPS.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
    704672  m_cSPS.setUseSAO( m_bUseSAO );
    705673
    706 #if !H0566_TLA
    707   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   else
    734   {
    735     m_cSPS.setMaxTLayers( 1 );
    736     m_cSPS.setTemporalIdNestingFlag( false );
    737   }
    738 #else
    739674  m_cSPS.setMaxTLayers( m_maxTempLayer );
    740675  m_cSPS.setTemporalIdNestingFlag( false );
    741 #endif
    742 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
    743676  for ( i = 0; i < m_cSPS.getMaxTLayers(); i++ )
    744677  {
     
    746679    m_cSPS.setNumReorderPics(m_numReorderPics[i], i);
    747680  }
    748 #endif
    749681  m_cSPS.setPCMBitDepthLuma (g_uiPCMBitDepthLuma);
    750682  m_cSPS.setPCMBitDepthChroma (g_uiPCMBitDepthChroma);
     
    753685  m_cSPS.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
    754686  m_cSPS.setUniformSpacingIdr( m_iUniformSpacingIdr );
    755 #if !REMOVE_TILE_DEPENDENCE
    756   m_cSPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );
    757 #endif
    758687  m_cSPS.setNumColumnsMinus1( m_iNumColumnsMinus1 );
    759688  m_cSPS.setNumRowsMinus1( m_iNumRowsMinus1 );
     
    787716    m_cSPS.setPredDepthMapGeneration( m_viewId, true );
    788717#endif
    789 #if HHI_INTER_VIEW_RESIDUAL_PRED
     718#if H3D_IVRP
    790719    m_cSPS.setMultiviewResPredMode  ( 0 );
    791720#endif
     
    801730    {
    802731#if DEPTH_MAP_GENERATION
    803 #if HHI_INTER_VIEW_MOTION_PRED
     732#if H3D_IVMP
    804733      m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, m_uiMultiviewMvPredMode, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset );
    805734#else
     
    807736#endif
    808737#endif
    809 #if HHI_INTER_VIEW_RESIDUAL_PRED
     738#if H3D_IVRP
    810739      m_cSPS.setMultiviewResPredMode  ( m_uiMultiviewResPredMode );
    811740#endif
     
    816745      m_cSPS.setPredDepthMapGeneration( m_viewId, false );
    817746#endif
    818 #if HHI_INTER_VIEW_RESIDUAL_PRED
     747#if H3D_IVRP
    819748      m_cSPS.setMultiviewResPredMode  ( 0 );
    820749#endif
     
    827756  m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
    828757  m_cPPS.setSliceGranularity(m_iSliceGranularity);
    829 #if !H0566_TLA
    830   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   else
    839   {
    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 #endif
    847758  Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false;
    848759
    849760#if LOSSLESS_CODING
    850 #if H0736_AVC_STYLE_QP_RANGE
    851761  Int lowestQP = - m_cSPS.getQpBDOffsetY();
    852 #else
    853   Int lowestQP = 0;
    854 #endif
    855762
    856763  if(getUseLossless())
     
    903810
    904811  m_cPPS.setEntropyCodingMode( 1 ); // In the PPS now, but also remains in slice header!
    905 #if !WPP_SIMPLIFICATION
    906   m_cPPS.setEntropyCodingSynchro(m_iWaveFrontSynchro);
    907   m_cPPS.setCabacIstateReset(m_iWaveFrontFlush != 0);
    908 #endif
    909812  m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams);
    910813  m_cPPS.setUseWP( m_bUseWeightPred );
    911814  m_cPPS.setWPBiPredIdc( m_uiBiPredIdc );
    912815  m_cPPS.setEnableTMVPFlag( m_bEnableTMVP );
    913 #if H0388
    914816  m_cPPS.setOutputFlagPresentFlag( false );
    915 #endif
    916 #if MULTIBITS_DATA_HIDING
    917817  m_cPPS.setSignHideFlag(getSignHideFlag());
    918818  m_cPPS.setTSIG(getTSIG());
    919 #endif
    920 #if DBL_CONTROL
    921819  m_cPPS.setDeblockingFilterControlPresent (m_DeblockingFilterControlPresent );
    922 #endif
    923 #if PARALLEL_MERGE
    924820  m_cPPS.setLog2ParallelMergeLevelMinus2      (LOG2_PARALLEL_MERGE_LEVEL_MINUS2);
    925 #endif
    926821#if CABAC_INIT_FLAG
    927822  m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
     
    1102997    m_cPPS.setColumnRowInfoPresent( m_iColumnRowInfoPresent );
    1103998    m_cPPS.setUniformSpacingIdr( m_iUniformSpacingIdr );
    1104 #if !REMOVE_TILE_DEPENDENCE
    1105     m_cPPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );
    1106 #endif
    1107999    m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 );
    11081000    m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 );
  • trunk/source/Lib/TLibEncoder/TEncTop.h

    r56 r296  
    103103  TComDepthMapGenerator   m_cDepthMapGenerator;           ///< depth map generator
    104104#endif
    105 #if HHI_INTER_VIEW_RESIDUAL_PRED
     105#if H3D_IVRP
    106106  TComResidualGenerator   m_cResidualGenerator;           ///< generator for residual pictures
    107107#endif
     
    173173    }
    174174  }
    175 #if HHI_INTERVIEW_SKIP || HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED
     175#if HHI_INTERVIEW_SKIP || H3D_IVMP || H3D_IVRP
    176176  Void      deleteExtraPicBuffers   ( Int iPoc );
    177177#endif
     
    234234  TComDepthMapGenerator*  getDepthMapGenerator  () { return  &m_cDepthMapGenerator;   }
    235235#endif
    236 #if HHI_INTER_VIEW_RESIDUAL_PRED
     236#if H3D_IVRP
    237237  TComResidualGenerator*  getResidualGenerator  () { return  &m_cResidualGenerator;   }
    238238#endif
Note: See TracChangeset for help on using the changeset viewer.