Changeset 466 in SHVCSoftware for branches/SHM-4.0-dev/source/Lib


Ignore:
Timestamp:
13 Nov 2013, 23:25:47 (11 years ago)
Author:
nokia
Message:

Integration of O0194: Support different bit-depth values for different layers, enable weighted prediction for ILR for color gamut scalability.

Location:
branches/SHM-4.0-dev/source/Lib
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-4.0-dev/source/Lib/TLibCommon/CommonDef.h

    r442 r466  
    130130extern Int g_bitDepthY;
    131131extern Int g_bitDepthC;
    132 
     132#if O0194_DIFFERENT_BITDEPTH_EL_BL
     133extern Int  g_bitDepthYLayer[MAX_LAYERS];
     134extern Int  g_bitDepthCLayer[MAX_LAYERS];
     135
     136extern UInt g_uiPCMBitDepthLumaDec[MAX_LAYERS];    // PCM bit-depth
     137extern UInt g_uiPCMBitDepthChromaDec[MAX_LAYERS];    // PCM bit-depth
     138#endif
     139#if O0194_WEIGHTED_PREDICTION_CGS
     140extern void* g_refWeightACDCParam; //type:wpACDCParam
     141#endif
    133142/** clip x, such that 0 <= x <= #g_maxLumaVal */
    134143template <typename T> inline T ClipY(T x) { return std::min<T>(T((1 << g_bitDepthY)-1), std::max<T>( T(0), x)); }
  • branches/SHM-4.0-dev/source/Lib/TLibCommon/TComDataCU.cpp

    r448 r466  
    40044004  uiPelY = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getHeight() - 1, uiPelY);
    40054005
    4006 #if !LAYER_CTB
    40074006  UInt uiMinUnitSize = m_pcPic->getMinCUWidth();
    4008 #endif
    4009 
     4007
     4008#if SCALED_REF_LAYER_OFFSETS
    40104009  Int leftStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow(refLayerIdc).getWindowLeftOffset();
    40114010  Int topStartL  = this->getSlice()->getSPS()->getScaledRefLayerWindow(refLayerIdc).getWindowTopOffset();
    40124011  Int iBX = ((uiPelX - leftStartL)*g_posScalingFactor[refLayerIdc][0] + (1<<15)) >> 16;
    40134012  Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16;
     4013#else
     4014  Int iBX = (uiPelX*g_posScalingFactor[refLayerIdc][0] + (1<<15)) >> 16;
     4015  Int iBY = (uiPelY*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16;
     4016#endif
    40144017
    40154018#if N0139_POSITION_ROUNDING_OFFSET
     
    40214024#endif
    40224025
     4026#if SCALED_REF_LAYER_OFFSETS
    40234027  if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight() ||
    40244028       iBX < 0                                        || iBY < 0                                           )
     4029#else
     4030  if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight())
     4031#endif
    40254032  {
    40264033    return NULL;
    40274034  }
    40284035
    4029 #if LAYER_CTB
    4030   UInt baseMaxCUHeight = cBaseColPic->getPicSym()->getMaxCUHeight();
    4031   UInt baseMaxCUWidth  = cBaseColPic->getPicSym()->getMaxCUWidth();
    4032   UInt baseMinUnitSize = cBaseColPic->getMinCUWidth();
    4033  
    4034   uiCUAddrBase = ( iBY / cBaseColPic->getPicSym()->getMaxCUHeight() ) * cBaseColPic->getFrameWidthInCU() + ( iBX / cBaseColPic->getPicSym()->getMaxCUWidth() );
    4035 #else
    40364036  uiCUAddrBase = (iBY/g_uiMaxCUHeight)*cBaseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth);
    4037 #endif
    40384037
    40394038  assert(uiCUAddrBase < cBaseColPic->getNumCUsInFrame());
    40404039
    4041 #if LAYER_CTB
    4042   UInt uiRasterAddrBase = ( iBY - (iBY/baseMaxCUHeight)*baseMaxCUHeight ) / baseMinUnitSize * cBaseColPic->getNumPartInWidth() + ( iBX - (iBX/baseMaxCUWidth)*baseMaxCUWidth ) / baseMinUnitSize;
    4043  
    4044   uiAbsPartIdxBase = g_auiLayerRasterToZscan[cBaseColPic->getLayerId()][uiRasterAddrBase];
    4045 #else
    40464040  UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*cBaseColPic->getNumPartInWidth()
    40474041    + (iBX - (iBX/g_uiMaxCUWidth)*g_uiMaxCUWidth)/uiMinUnitSize;
    40484042
    40494043  uiAbsPartIdxBase = g_auiRasterToZscan[uiRasterAddrBase];
    4050 #endif
    40514044
    40524045  return cBaseColPic->getCU(uiCUAddrBase);
  • branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicSym.h

    r445 r466  
    126126  TComDataCU*&  getCU( UInt uiCUAddr )  { return m_apcTComDataCU[uiCUAddr];     }
    127127 
    128 #if LAYER_CTB
    129   UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
    130   UInt        getMaxCUHeight()          { return m_uiMaxCUHeight;               }
    131 #endif
    132 
    133128#if AVC_SYNTAX
    134129  UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
  • branches/SHM-4.0-dev/source/Lib/TLibCommon/TComPicYuv.cpp

    r445 r466  
    9090  Int numCuInHeight = m_iPicHeight / m_iCuHeight + (m_iPicHeight % m_iCuHeight != 0);
    9191 
    92 #if LAYER_CTB
    93   m_iLumaMarginX    = uiMaxCUWidth  + 16; // for 16-byte alignment
    94   m_iLumaMarginY    = uiMaxCUHeight + 16;  // margin for 8-tap filter and infinite padding
    95 #else
    9692  m_iLumaMarginX    = g_uiMaxCUWidth  + 16; // for 16-byte alignment
    9793  m_iLumaMarginY    = g_uiMaxCUHeight + 16;  // margin for 8-tap filter and infinite padding
    98 #endif
    9994 
    10095  m_iChromaMarginX  = m_iLumaMarginX>>1;
  • branches/SHM-4.0-dev/source/Lib/TLibCommon/TComRdCost.cpp

    r313 r466  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2013, ITU/ISO/IEC
     
    6161  Double dRdCost = 0.0;
    6262  Double dLambda = 0.0;
    63  
     63
    6464  switch ( eDFunc )
    6565  {
     
    8080      break;
    8181  }
    82  
     82
    8383  if (bFlag)
    8484  {
     
    107107    }
    108108  }
    109  
     109
    110110  return dRdCost;
    111111}
     
    115115  Double dRdCost = 0.0;
    116116  Double dLambda = 0.0;
    117  
     117
    118118  switch ( eDFunc )
    119119  {
     
    134134      break;
    135135  }
    136  
     136
    137137  if (bFlag)
    138138  {
     
    161161    }
    162162  }
    163  
     163
    164164  return dRdCost;
    165165}
     
    178178{
    179179  m_afpDistortFunc[0]  = NULL;                  // for DF_DEFAULT
    180  
     180
    181181  m_afpDistortFunc[1]  = TComRdCost::xGetSSE;
    182182  m_afpDistortFunc[2]  = TComRdCost::xGetSSE4;
     
    186186  m_afpDistortFunc[6]  = TComRdCost::xGetSSE64;
    187187  m_afpDistortFunc[7]  = TComRdCost::xGetSSE16N;
    188  
     188
    189189  m_afpDistortFunc[8]  = TComRdCost::xGetSAD;
    190190  m_afpDistortFunc[9]  = TComRdCost::xGetSAD4;
     
    194194  m_afpDistortFunc[13] = TComRdCost::xGetSAD64;
    195195  m_afpDistortFunc[14] = TComRdCost::xGetSAD16N;
    196  
     196
    197197  m_afpDistortFunc[15] = TComRdCost::xGetSAD;
    198198  m_afpDistortFunc[16] = TComRdCost::xGetSAD4;
     
    202202  m_afpDistortFunc[20] = TComRdCost::xGetSAD64;
    203203  m_afpDistortFunc[21] = TComRdCost::xGetSAD16N;
    204  
     204
    205205#if AMP_SAD
    206206  m_afpDistortFunc[43] = TComRdCost::xGetSAD12;
     
    219219  m_afpDistortFunc[27] = TComRdCost::xGetHADs;
    220220  m_afpDistortFunc[28] = TComRdCost::xGetHADs;
    221  
     221
    222222#if !FIX203
    223223  m_puiComponentCostOriginP = NULL;
     
    239239  iSubPelSearchLimit += 4;
    240240  iSubPelSearchLimit *= 8;
    241  
     241
    242242  if( m_iSearchLimit != iSubPelSearchLimit )
    243243  {
    244244    xUninit();
    245    
     245
    246246    m_iSearchLimit = iSubPelSearchLimit;
    247    
     247
    248248    m_puiComponentCostOriginP = new UInt[ 4 * iSubPelSearchLimit ];
    249249    iSubPelSearchLimit *= 2;
    250    
     250
    251251    m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit;
    252    
     252
    253253    for( Int n = -iSubPelSearchLimit; n < iSubPelSearchLimit; n++)
    254254    {
     
    272272  UInt uiLength = 1;
    273273  UInt uiTemp   = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1);
    274  
     274
    275275  assert ( uiTemp );
    276  
     276
    277277  while ( 1 != uiTemp )
    278278  {
     
    280280    uiLength += 2;
    281281  }
    282  
     282
    283283  return uiLength;
    284284}
     
    290290  rcDistParam.iRows    = uiBlkHeight;
    291291  rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
    292  
     292
    293293  // initialize
    294294  rcDistParam.iSubShift  = 0;
     
    301301  rcDistParam.pOrg = pcPatternKey->getROIY();
    302302  rcDistParam.pCur = piRefY;
    303  
     303
    304304  rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride();
    305305  rcDistParam.iStrideCur = iRefStride;
    306  
     306
    307307  // set Block Width / Height
    308308  rcDistParam.iCols    = pcPatternKey->getROIYWidth();
    309309  rcDistParam.iRows    = pcPatternKey->getROIYHeight();
    310310  rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
    311  
     311
    312312#if AMP_SAD
    313313  if (rcDistParam.iCols == 12)
     
    336336#endif
    337337{
     338#if O0194_WEIGHTED_PREDICTION_CGS
     339  // Bug fix: The correct bit depth has not been used for weighted cost calculation
     340  rcDistParam.bitDepth = g_bitDepthY;
     341#endif
    338342  // set Original & Curr Pointer / Stride
    339343  rcDistParam.pOrg = pcPatternKey->getROIY();
    340344  rcDistParam.pCur = piRefY;
    341  
     345
    342346  rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride();
    343347  rcDistParam.iStrideCur = iRefStride * iStep;
    344  
     348
    345349  // set Step for interpolated buffer
    346350  rcDistParam.iStep = iStep;
    347  
     351
    348352  // set Block Width / Height
    349353  rcDistParam.iCols    = pcPatternKey->getROIYWidth();
     
    352356  rcDistParam.bUseNSHAD = bUseNSHAD;
    353357#endif
    354  
     358
    355359  // set distortion function
    356360  if ( !bHADME )
     
    376380    rcDistParam.DistFunc = m_afpDistortFunc[DF_HADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
    377381  }
    378  
     382
    379383  // initialize
    380384  rcDistParam.iSubShift  = 0;
     
    407411  UInt uiSum = 0;
    408412  Int x, y;
    409  
     413
    410414  if ( ( (iWidth % 8) == 0 ) && ( (iHeight % 8) == 0 ) )
    411415  {
     
    444448    }
    445449  }
    446  
     450
    447451  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8);
    448452
     
    523527  Int  iStrideCur = pcDtParam->iStrideCur;
    524528  Int  iStrideOrg = pcDtParam->iStrideOrg;
    525  
    526   UInt uiSum = 0;
    527  
     529
     530  UInt uiSum = 0;
     531
    528532  for( ; iRows != 0; iRows-- )
    529533  {
     
    535539    piCur += iStrideCur;
    536540  }
    537  
     541
    538542  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    539543}
     
    541545UInt TComRdCost::xGetSAD4( DistParam* pcDtParam )
    542546{
    543   if ( pcDtParam->bApplyWeight ) 
     547  if ( pcDtParam->bApplyWeight )
    544548  {
    545549    return xGetSADw( pcDtParam );
     
    552556  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    553557  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    554  
    555   UInt uiSum = 0;
    556  
     558
     559  UInt uiSum = 0;
     560
    557561  for( ; iRows != 0; iRows-=iSubStep )
    558562  {
     
    561565    uiSum += abs( piOrg[2] - piCur[2] );
    562566    uiSum += abs( piOrg[3] - piCur[3] );
    563    
    564     piOrg += iStrideOrg;
    565     piCur += iStrideCur;
    566   }
    567  
     567
     568    piOrg += iStrideOrg;
     569    piCur += iStrideCur;
     570  }
     571
    568572  uiSum <<= iSubShift;
    569573  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     
    583587  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    584588  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    585  
    586   UInt uiSum = 0;
    587  
     589
     590  UInt uiSum = 0;
     591
    588592  for( ; iRows != 0; iRows-=iSubStep )
    589593  {
     
    596600    uiSum += abs( piOrg[6] - piCur[6] );
    597601    uiSum += abs( piOrg[7] - piCur[7] );
    598    
    599     piOrg += iStrideOrg;
    600     piCur += iStrideCur;
    601   }
    602  
     602
     603    piOrg += iStrideOrg;
     604    piCur += iStrideCur;
     605  }
     606
    603607  uiSum <<= iSubShift;
    604608  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     
    618622  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    619623  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    620  
    621   UInt uiSum = 0;
    622  
     624
     625  UInt uiSum = 0;
     626
    623627  for( ; iRows != 0; iRows-=iSubStep )
    624628  {
     
    639643    uiSum += abs( piOrg[14] - piCur[14] );
    640644    uiSum += abs( piOrg[15] - piCur[15] );
    641    
    642     piOrg += iStrideOrg;
    643     piCur += iStrideCur;
    644   }
    645  
     645
     646    piOrg += iStrideOrg;
     647    piCur += iStrideCur;
     648  }
     649
    646650  uiSum <<= iSubShift;
    647651  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     
    662666  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    663667  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    664  
    665   UInt uiSum = 0;
    666  
     668
     669  UInt uiSum = 0;
     670
    667671  for( ; iRows != 0; iRows-=iSubStep )
    668672  {
     
    679683    uiSum += abs( piOrg[10] - piCur[10] );
    680684    uiSum += abs( piOrg[11] - piCur[11] );
    681    
    682     piOrg += iStrideOrg;
    683     piCur += iStrideCur;
    684   }
    685  
     685
     686    piOrg += iStrideOrg;
     687    piCur += iStrideCur;
     688  }
     689
    686690  uiSum <<= iSubShift;
    687691  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     
    699703  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    700704  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    701  
    702   UInt uiSum = 0;
    703  
     705
     706  UInt uiSum = 0;
     707
    704708  for( ; iRows != 0; iRows-=iSubStep )
    705709  {
     
    726730    piCur += iStrideCur;
    727731  }
    728  
     732
    729733  uiSum <<= iSubShift;
    730734  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     
    744748  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    745749  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    746  
    747   UInt uiSum = 0;
    748  
     750
     751  UInt uiSum = 0;
     752
    749753  for( ; iRows != 0; iRows-=iSubStep )
    750754  {
     
    781785    uiSum += abs( piOrg[30] - piCur[30] );
    782786    uiSum += abs( piOrg[31] - piCur[31] );
    783    
    784     piOrg += iStrideOrg;
    785     piCur += iStrideCur;
    786   }
    787  
     787
     788    piOrg += iStrideOrg;
     789    piCur += iStrideCur;
     790  }
     791
    788792  uiSum <<= iSubShift;
    789793  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     
    804808  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    805809  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    806  
    807   UInt uiSum = 0;
    808  
     810
     811  UInt uiSum = 0;
     812
    809813  for( ; iRows != 0; iRows-=iSubStep )
    810814  {
     
    833837    uiSum += abs( piOrg[22] - piCur[22] );
    834838    uiSum += abs( piOrg[23] - piCur[23] );
    835    
    836     piOrg += iStrideOrg;
    837     piCur += iStrideCur;
    838   }
    839  
     839
     840    piOrg += iStrideOrg;
     841    piCur += iStrideCur;
     842  }
     843
    840844  uiSum <<= iSubShift;
    841845  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     
    857861  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    858862  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    859  
    860   UInt uiSum = 0;
    861  
     863
     864  UInt uiSum = 0;
     865
    862866  for( ; iRows != 0; iRows-=iSubStep )
    863867  {
     
    926930    uiSum += abs( piOrg[62] - piCur[62] );
    927931    uiSum += abs( piOrg[63] - piCur[63] );
    928    
    929     piOrg += iStrideOrg;
    930     piCur += iStrideCur;
    931   }
    932  
     932
     933    piOrg += iStrideOrg;
     934    piCur += iStrideCur;
     935  }
     936
    933937  uiSum <<= iSubShift;
    934938  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     
    949953  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    950954  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    951  
    952   UInt uiSum = 0;
    953  
     955
     956  UInt uiSum = 0;
     957
    954958  for( ; iRows != 0; iRows-=iSubStep )
    955959  {
     
    10021006    uiSum += abs( piOrg[46] - piCur[46] );
    10031007    uiSum += abs( piOrg[47] - piCur[47] );
    1004    
    1005     piOrg += iStrideOrg;
    1006     piCur += iStrideCur;
    1007   }
    1008  
     1008
     1009    piOrg += iStrideOrg;
     1010    piCur += iStrideCur;
     1011  }
     1012
    10091013  uiSum <<= iSubShift;
    10101014  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     
    10281032  Int  iStrideOrg = pcDtParam->iStrideOrg;
    10291033  Int  iStrideCur = pcDtParam->iStrideCur;
    1030  
     1034
    10311035  UInt uiSum = 0;
    10321036  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    1033  
     1037
    10341038  Int iTemp;
    1035  
     1039
    10361040  for( ; iRows != 0; iRows-- )
    10371041  {
     
    10441048    piCur += iStrideCur;
    10451049  }
    1046  
     1050
    10471051  return ( uiSum );
    10481052}
     
    10601064  Int  iStrideOrg = pcDtParam->iStrideOrg;
    10611065  Int  iStrideCur = pcDtParam->iStrideCur;
    1062  
     1066
    10631067  UInt uiSum = 0;
    10641068  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    1065  
     1069
    10661070  Int  iTemp;
    1067  
     1071
    10681072  for( ; iRows != 0; iRows-- )
    10691073  {
    1070    
     1074
    10711075    iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    10721076    iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    10731077    iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    10741078    iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1075    
    1076     piOrg += iStrideOrg;
    1077     piCur += iStrideCur;
    1078   }
    1079  
     1079
     1080    piOrg += iStrideOrg;
     1081    piCur += iStrideCur;
     1082  }
     1083
    10801084  return ( uiSum );
    10811085}
     
    10931097  Int  iStrideOrg = pcDtParam->iStrideOrg;
    10941098  Int  iStrideCur = pcDtParam->iStrideCur;
    1095  
     1099
    10961100  UInt uiSum = 0;
    10971101  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    1098  
     1102
    10991103  Int  iTemp;
    1100  
     1104
    11011105  for( ; iRows != 0; iRows-- )
    11021106  {
     
    11091113    iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift;
    11101114    iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1111    
    1112     piOrg += iStrideOrg;
    1113     piCur += iStrideCur;
    1114   }
    1115  
     1115
     1116    piOrg += iStrideOrg;
     1117    piCur += iStrideCur;
     1118  }
     1119
    11161120  return ( uiSum );
    11171121}
     
    11291133  Int  iStrideOrg = pcDtParam->iStrideOrg;
    11301134  Int  iStrideCur = pcDtParam->iStrideCur;
    1131  
     1135
    11321136  UInt uiSum = 0;
    11331137  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    1134  
     1138
    11351139  Int  iTemp;
    1136  
     1140
    11371141  for( ; iRows != 0; iRows-- )
    11381142  {
    1139    
     1143
    11401144    iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    11411145    iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift;
     
    11541158    iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift;
    11551159    iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1156    
    1157     piOrg += iStrideOrg;
    1158     piCur += iStrideCur;
    1159   }
    1160  
     1160
     1161    piOrg += iStrideOrg;
     1162    piCur += iStrideCur;
     1163  }
     1164
    11611165  return ( uiSum );
    11621166}
     
    11741178  Int  iStrideOrg = pcDtParam->iStrideOrg;
    11751179  Int  iStrideCur = pcDtParam->iStrideCur;
    1176  
     1180
    11771181  UInt uiSum = 0;
    11781182  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    11791183  Int  iTemp;
    1180  
     1184
    11811185  for( ; iRows != 0; iRows-- )
    11821186  {
    11831187    for (Int n = 0; n < iCols; n+=16 )
    11841188    {
    1185      
     1189
    11861190      iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    11871191      iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += ( iTemp * iTemp ) >> uiShift;
     
    12001204      iTemp = piOrg[n+14] - piCur[n+14]; uiSum += ( iTemp * iTemp ) >> uiShift;
    12011205      iTemp = piOrg[n+15] - piCur[n+15]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1202      
    1203     }
    1204     piOrg += iStrideOrg;
    1205     piCur += iStrideCur;
    1206   }
    1207  
     1206
     1207    }
     1208    piOrg += iStrideOrg;
     1209    piCur += iStrideCur;
     1210  }
     1211
    12081212  return ( uiSum );
    12091213}
     
    12211225  Int  iStrideOrg = pcDtParam->iStrideOrg;
    12221226  Int  iStrideCur = pcDtParam->iStrideCur;
    1223  
     1227
    12241228  UInt uiSum = 0;
    12251229  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    12261230  Int  iTemp;
    1227  
     1231
    12281232  for( ; iRows != 0; iRows-- )
    12291233  {
    1230    
     1234
    12311235    iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    12321236    iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift;
     
    12611265    iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift;
    12621266    iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1263    
    1264     piOrg += iStrideOrg;
    1265     piCur += iStrideCur;
    1266   }
    1267  
     1267
     1268    piOrg += iStrideOrg;
     1269    piCur += iStrideCur;
     1270  }
     1271
    12681272  return ( uiSum );
    12691273}
     
    12811285  Int  iStrideOrg = pcDtParam->iStrideOrg;
    12821286  Int  iStrideCur = pcDtParam->iStrideCur;
    1283  
     1287
    12841288  UInt uiSum = 0;
    12851289  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    12861290  Int  iTemp;
    1287  
     1291
    12881292  for( ; iRows != 0; iRows-- )
    12891293  {
     
    13521356    iTemp = piOrg[62] - piCur[62]; uiSum += ( iTemp * iTemp ) >> uiShift;
    13531357    iTemp = piOrg[63] - piCur[63]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1354    
    1355     piOrg += iStrideOrg;
    1356     piCur += iStrideCur;
    1357   }
    1358  
     1358
     1359    piOrg += iStrideOrg;
     1360    piCur += iStrideCur;
     1361  }
     1362
    13591363  return ( uiSum );
    13601364}
     
    13761380  m[2] = diff[0] - diff[2];
    13771381  m[3] = diff[1] - diff[3];
    1378  
     1382
    13791383  satd += abs(m[0] + m[1]);
    13801384  satd += abs(m[0] - m[1]);
    13811385  satd += abs(m[2] + m[3]);
    13821386  satd += abs(m[2] - m[3]);
    1383  
     1387
    13841388  return satd;
    13851389}
     
    13881392{
    13891393  Int k, satd = 0, diff[16], m[16], d[16];
    1390  
     1394
    13911395  assert( iStep == 1 );
    13921396  for( k = 0; k < 16; k+=4 )
     
    13961400    diff[k+2] = piOrg[2] - piCur[2];
    13971401    diff[k+3] = piOrg[3] - piCur[3];
    1398    
    1399     piCur += iStrideCur;
    1400     piOrg += iStrideOrg;
    1401   }
    1402  
     1402
     1403    piCur += iStrideCur;
     1404    piOrg += iStrideOrg;
     1405  }
     1406
    14031407  /*===== hadamard transform =====*/
    14041408  m[ 0] = diff[ 0] + diff[12];
     
    14181422  m[14] = diff[ 2] - diff[14];
    14191423  m[15] = diff[ 3] - diff[15];
    1420  
     1424
    14211425  d[ 0] = m[ 0] + m[ 4];
    14221426  d[ 1] = m[ 1] + m[ 5];
     
    14351439  d[14] = m[14] - m[10];
    14361440  d[15] = m[15] - m[11];
    1437  
     1441
    14381442  m[ 0] = d[ 0] + d[ 3];
    14391443  m[ 1] = d[ 1] + d[ 2];
     
    14521456  m[14] = d[13] - d[14];
    14531457  m[15] = d[12] - d[15];
    1454  
     1458
    14551459  d[ 0] = m[ 0] + m[ 1];
    14561460  d[ 1] = m[ 0] - m[ 1];
     
    14691473  d[14] = m[14] + m[15];
    14701474  d[15] = m[15] - m[14];
    1471  
     1475
    14721476  for (k=0; k<16; ++k)
    14731477  {
     
    14751479  }
    14761480  satd = ((satd+1)>>1);
    1477  
     1481
    14781482  return satd;
    14791483}
     
    14941498    diff[k+6] = piOrg[6] - piCur[6];
    14951499    diff[k+7] = piOrg[7] - piCur[7];
    1496    
    1497     piCur += iStrideCur;
    1498     piOrg += iStrideOrg;
    1499   }
    1500  
     1500
     1501    piCur += iStrideCur;
     1502    piOrg += iStrideOrg;
     1503  }
     1504
    15011505  //horizontal
    15021506  for (j=0; j < 8; j++)
     
    15111515    m2[j][6] = diff[jj+2] - diff[jj+6];
    15121516    m2[j][7] = diff[jj+3] - diff[jj+7];
    1513    
     1517
    15141518    m1[j][0] = m2[j][0] + m2[j][2];
    15151519    m1[j][1] = m2[j][1] + m2[j][3];
     
    15201524    m1[j][6] = m2[j][4] - m2[j][6];
    15211525    m1[j][7] = m2[j][5] - m2[j][7];
    1522    
     1526
    15231527    m2[j][0] = m1[j][0] + m1[j][1];
    15241528    m2[j][1] = m1[j][0] - m1[j][1];
     
    15301534    m2[j][7] = m1[j][6] - m1[j][7];
    15311535  }
    1532  
     1536
    15331537  //vertical
    15341538  for (i=0; i < 8; i++)
     
    15421546    m3[6][i] = m2[2][i] - m2[6][i];
    15431547    m3[7][i] = m2[3][i] - m2[7][i];
    1544    
     1548
    15451549    m1[0][i] = m3[0][i] + m3[2][i];
    15461550    m1[1][i] = m3[1][i] + m3[3][i];
     
    15511555    m1[6][i] = m3[4][i] - m3[6][i];
    15521556    m1[7][i] = m3[5][i] - m3[7][i];
    1553    
     1557
    15541558    m2[0][i] = m1[0][i] + m1[1][i];
    15551559    m2[1][i] = m1[0][i] - m1[1][i];
     
    15611565    m2[7][i] = m1[6][i] - m1[7][i];
    15621566  }
    1563  
     1567
    15641568  for (i = 0; i < 8; i++)
    15651569  {
     
    15691573    }
    15701574  }
    1571  
     1575
    15721576  sad=((sad+2)>>2);
    1573  
     1577
    15741578  return sad;
    15751579}
     
    16811685  //vertical
    16821686  for (i=0; i < 16; i++)
    1683   {   
     1687  {
    16841688    m2[0][i] = m1[0][i] + m1[2][i];
    16851689    m2[1][i] = m1[1][i] + m1[3][i];
     
    18381842  Int  iOffsetOrg = iStrideOrg<<2;
    18391843  Int  iOffsetCur = iStrideCur<<2;
    1840  
    1841   UInt uiSum = 0;
    1842  
     1844
     1845  UInt uiSum = 0;
     1846
    18431847  for ( y=0; y<iRows; y+= 4 )
    18441848  {
     
    18471851    piCur += iOffsetCur;
    18481852  }
    1849  
     1853
    18501854  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    18511855}
     
    18641868  Int  iStep  = pcDtParam->iStep;
    18651869  Int  y;
    1866  
    1867   UInt uiSum = 0;
    1868  
     1870
     1871  UInt uiSum = 0;
     1872
    18691873  if ( iRows == 4 )
    18701874  {
     
    18831887    }
    18841888  }
    1885  
     1889
    18861890  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    18871891}
     
    19001904  Int  iStrideOrg = pcDtParam->iStrideOrg;
    19011905  Int  iStep  = pcDtParam->iStep;
    1902  
     1906
    19031907  Int  x, y;
    1904  
    1905   UInt uiSum = 0;
    1906  
     1908
     1909  UInt uiSum = 0;
     1910
    19071911#if NS_HAD
    19081912  if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) )
     
    19241928  }
    19251929#if NS_HAD
    1926   else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD ) 
     1930  else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD )
    19271931  {
    19281932    Int  iOffsetOrg = iStrideOrg<<2;
     
    19381942    }
    19391943  }
    1940   else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD ) 
     1944  else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD )
    19411945  {
    19421946    Int  iOffsetOrg = iStrideOrg<<4;
     
    19571961    Int  iOffsetOrg = iStrideOrg<<2;
    19581962    Int  iOffsetCur = iStrideCur<<2;
    1959    
     1963
    19601964    for ( y=0; y<iRows; y+= 4 )
    19611965    {
     
    19861990    assert(false);
    19871991  }
    1988  
     1992
    19891993  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    19901994}
  • branches/SHM-4.0-dev/source/Lib/TLibCommon/TComRom.cpp

    r445 r466  
    8686// Data structure related table & variable
    8787// ====================================================================================================================
    88 #if LAYER_CTB
    89 UInt g_auiLayerMaxCUWidth[MAX_LAYERS];
    90 UInt g_auiLayerMaxCUHeight[MAX_LAYERS];
    91 UInt g_auiLayerMaxCUDepth[MAX_LAYERS];
    92 UInt g_auiLayerAddCUDepth[MAX_LAYERS];
    93 UInt g_auiLayerZscanToRaster[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    94 UInt g_auiLayerRasterToZscan[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    95 UInt g_auiLayerRasterToPelX[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    96 UInt g_auiLayerRasterToPelY[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    97 #endif
     88
    9889UInt g_uiMaxCUWidth  = MAX_CU_SIZE;
    9990UInt g_uiMaxCUHeight = MAX_CU_SIZE;
     
    321312UInt g_uiPCMBitDepthLuma     = 8;    // PCM bit-depth
    322313UInt g_uiPCMBitDepthChroma   = 8;    // PCM bit-depth
    323 
     314#if O0194_DIFFERENT_BITDEPTH_EL_BL
     315Int  g_bitDepthYLayer[MAX_LAYERS];
     316Int  g_bitDepthCLayer[MAX_LAYERS];
     317
     318UInt g_uiPCMBitDepthLumaDec[MAX_LAYERS];    // PCM bit-depth
     319UInt g_uiPCMBitDepthChromaDec[MAX_LAYERS];    // PCM bit-depth
     320#endif
     321#if O0194_WEIGHTED_PREDICTION_CGS
     322void * g_refWeightACDCParam; // type=wpACDCParam
     323#endif
    324324// ====================================================================================================================
    325325// Misc.
  • branches/SHM-4.0-dev/source/Lib/TLibCommon/TComRom.h

    r445 r466  
    8181
    8282// global variable (LCU width/height, max. CU depth)
    83 #if LAYER_CTB
    84 extern       UInt g_auiLayerMaxCUWidth[MAX_LAYERS];
    85 extern       UInt g_auiLayerMaxCUHeight[MAX_LAYERS];
    86 extern       UInt g_auiLayerMaxCUDepth[MAX_LAYERS];
    87 extern       UInt g_auiLayerAddCUDepth[MAX_LAYERS];
    88 extern       UInt g_auiLayerZscanToRaster[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    89 extern       UInt g_auiLayerRasterToZscan[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    90 extern       UInt g_auiLayerRasterToPelX[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    91 extern       UInt g_auiLayerRasterToPelY[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
    92 #endif
    9383extern       UInt g_uiMaxCUWidth;
    9484extern       UInt g_uiMaxCUHeight;
  • branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.h

    r464 r466  
    16021602  Int64 iAC;
    16031603  Int64 iDC;
     1604#if O0194_WEIGHTED_PREDICTION_CGS
     1605  Int iSamples;
     1606#endif
    16041607} wpACDCParam;
    16051608
  • branches/SHM-4.0-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp

    r464 r466  
    1717  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    1818  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    19   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
    20   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    21 #endif
    22   { -1, 4, -11, 52, 26,  -8,  3, -1}, // <-> actual phase shift 1/3, used for spatial scalability x1.5     
     19  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
     20  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
     21#endif
     22  { -1, 4, -11, 52, 26,  -8,  3, -1}, // <-> actual phase shift 1/3, used for spatial scalability x1.5
    2323#if ARBITRARY_SPATIAL_RATIO
    2424  { -1, 3,  -9, 47, 31, -10,  4, -1},
    2525  { -1, 4, -11, 45, 34, -10,  4, -1},
    2626#else
    27   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //       
    28   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
     27  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
     28  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    2929#endif
    3030  { -1, 4, -11, 40, 40, -11,  4, -1}, // <-> actual phase shift 1/2, equal to HEVC MC, used for spatial scalability x2
     
    3333  { -1,  4, -10, 31, 47,  -9,  3, -1},
    3434#else
    35   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
    36   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
     35  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
     36  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    3737#endif
    3838  { -1, 3,  -8, 26, 52, -11, 4, -1}, // <-> actual phase shift 2/3, used for spatial scalability x1.5
     
    4343  { 0,  1,  -2,  4, 63,  -3,  1,  0}
    4444#else
    45   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
    46   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
    47   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
    48   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}  // 
     45  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
     46  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
     47  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
     48  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}  //
    4949#endif
    5050};
     
    6060  {CNU,CNU,CNU,CNU},//
    6161  {CNU,CNU,CNU,CNU},//
    62   {CNU,CNU,CNU,CNU},// 
     62  {CNU,CNU,CNU,CNU},//
    6363#endif
    6464  { -4, 54, 16, -2},// <-> actual phase shift 1/4,equal to HEVC MC, used for spatial scalability x1.5 (only for accurate Chroma alignement)
    65   { -6, 52, 20, -2},// <-> actual phase shift 1/3, used for spatial scalability x1.5   
    66   { -6, 46, 28, -4},// <-> actual phase shift 3/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)     
     65  { -6, 52, 20, -2},// <-> actual phase shift 1/3, used for spatial scalability x1.5
     66  { -6, 46, 28, -4},// <-> actual phase shift 3/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)
    6767#if ARBITRARY_SPATIAL_RATIO
    6868  { -4, 42, 30, -4},
    6969#else
    70   {CNU,CNU,CNU,CNU},// 
     70  {CNU,CNU,CNU,CNU},//
    7171#endif
    7272  { -4, 36, 36, -4},// <-> actual phase shift 1/2,equal to HEVC MC, used for spatial scalability x2
     
    7575  { -4, 28, 46, -6},
    7676#else
    77   {CNU,CNU,CNU,CNU},// 
     77  {CNU,CNU,CNU,CNU},//
    7878#endif
    7979  { -2, 20, 52, -6},// <-> actual phase shift 2/3, used for spatial scalability x1.5
     
    8282  {-2, 14, 56, -4},
    8383#else
    84   {CNU,CNU,CNU,CNU},// 
    85   {CNU,CNU,CNU,CNU},// 
    86 #endif
    87   { -2, 10, 58, -2},// <-> actual phase shift 7/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement) 
     84  {CNU,CNU,CNU,CNU},//
     85  {CNU,CNU,CNU,CNU},//
     86#endif
     87  { -2, 10, 58, -2},// <-> actual phase shift 7/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)
    8888  {  0,  4, 62, -2} // <-> actual phase shift 11/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
    8989};
     
    109109
    110110  //========== Y component upsampling ===========
     111#if SCALED_REF_LAYER_OFFSETS
    111112  const Window &scalEL = window;
    112113
     
    118119  Int heightEL  = pcUsPic->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
    119120  Int strideEL  = pcUsPic->getStride();
    120 
     121#else
     122  const Window &confBL = pcBasePic->getConformanceWindow();
     123  const Window &confEL = pcUsPic->getConformanceWindow();
     124
     125  Int widthBL   = pcBasePic->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     126  Int heightBL  = pcBasePic->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     127  Int strideBL  = pcBasePic->getStride();
     128
     129  Int widthEL   = pcUsPic->getWidth () - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     130  Int heightEL  = pcUsPic->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     131  Int strideEL  = pcUsPic->getStride();
     132#endif
    121133  Pel* piTempBufY = pcTempPic->getLumaAddr();
    122134  Pel* piSrcBufY  = pcBasePic->getLumaAddr();
     
    182194    Int refPos16 = 0;
    183195    Int phase    = 0;
    184     Int refPos   = 0; 
     196    Int refPos   = 0;
    185197    Int* coeff = m_chromaFilter[phase];
    186198    for ( i = 0; i < 16; i++)
     
    190202    }
    191203
    192 #if ARBITRARY_SPATIAL_RATIO 
     204#if ARBITRARY_SPATIAL_RATIO
    193205    assert ( widthEL >= widthBL );
    194206    assert ( heightEL >= heightBL );
     
    205217
    206218#if O0215_PHASE_ALIGNMENT //for Luma, if Phase 0, then both PhaseX  and PhaseY should be 0. If symmetric: both PhaseX and PhaseY should be 2
    207     Int   phaseX = 2*phaseAlignFlag; 
    208     Int   phaseY = 2*phaseAlignFlag; 
     219    Int   phaseX = 2*phaseAlignFlag;
     220    Int   phaseY = 2*phaseAlignFlag;
    209221#else
    210222    Int   phaseX = 0;
     
    221233
    222234    Int   deltaX     = 4 * phaseX;
    223     Int   deltaY     = 4 * phaseY; 
     235    Int   deltaY     = 4 * phaseY;
    224236
    225237    Int shiftXM4 = shiftX - 4;
     
    231243    widthBL   = pcBasePic->getWidth ();
    232244    heightBL  = min<Int>( pcBasePic->getHeight(), heightEL );
    233 
     245#if SCALED_REF_LAYER_OFFSETS
    234246    Int leftStartL = scalEL.getWindowLeftOffset();
    235247    Int rightEndL  = pcUsPic->getWidth() - scalEL.getWindowRightOffset();
    236248    Int topStartL  = scalEL.getWindowTopOffset();
    237249    Int bottomEndL = pcUsPic->getHeight() - scalEL.getWindowBottomOffset();
     250#if BUGFIX_RESAMPLE
    238251    Int leftOffset = leftStartL > 0 ? leftStartL : 0;
     252#endif
     253#endif
    239254
    240255#if  N0214_INTERMEDIATE_BUFFER_16BITS
     256#if O0194_JOINT_US_BITSHIFT
     257    // g_bitDepthY was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
     258    Int shift1 = g_bitDepthYLayer[0] - 8;
     259#else
    241260    Int shift1 = g_bitDepthY - 8;
     261#endif
    242262#endif
    243263
     
    245265    for( i = 0; i < widthEL; i++ )
    246266    {
     267#if SCALED_REF_LAYER_OFFSETS
    247268      Int x = Clip3( leftStartL, rightEndL - 1, i );
    248269      refPos16 = (((x - leftStartL)*scaleX + addX) >> shiftXM4) - deltaX;
     270#else
     271      refPos16 = ((i*scaleX + addX) >> shiftXM4) - deltaX;
     272#endif
    249273      phase    = refPos16 & 15;
    250274      refPos   = refPos16 >> 4;
     
    273297
    274298#if  N0214_INTERMEDIATE_BUFFER_16BITS
     299#if O0194_JOINT_US_BITSHIFT
     300  Int nShift = 20 - g_bitDepthYLayer[1];
     301#else
    275302    Int nShift = US_FILTER_PREC*2 - shift1;
     303#endif
    276304#else
    277305    const Int nShift = US_FILTER_PREC*2;
    278306#endif
    279     Int iOffset = 1 << (nShift - 1);
    280 
     307    Int iOffset = 1 << (nShift - 1);
     308
     309#if SCALED_REF_LAYER_OFFSETS
    281310    for( j = 0; j < pcTempPic->getHeight(); j++ )
     311#else
     312    for( j = 0; j < heightEL; j++ )
     313#endif
    282314    {
     315#if SCALED_REF_LAYER_OFFSETS
    283316      Int y = Clip3(topStartL, bottomEndL - 1, j);
    284317      refPos16 = ((( y - topStartL )*scaleY + addY) >> shiftYM4) - deltaY;
     318#else
     319      refPos16 = ((j*scaleY + addY) >> shiftYM4) - deltaY;
     320#endif
    285321      phase    = refPos16 & 15;
    286322      refPos   = refPos16 >> 4;
     
    288324
    289325      piSrcY = piTempBufY + (refPos -((NTAPS_US_LUMA>>1) - 1))*strideEL;
    290       Pel* piDstY0 = piDstBufY + j * strideEL;           
     326#if SCALED_REF_LAYER_OFFSETS
     327#if BUGFIX_RESAMPLE
     328      Pel* piDstY0 = piDstBufY + j * strideEL;
    291329      piDstY = piDstY0 + leftOffset;
    292330      piSrcY += leftOffset;
     
    311349        piDstY++;
    312350      }
    313 
     351#else
     352#if 1 // it should provide identical result
     353      Pel* piDstY0 = piDstBufY + j * strideEL;
     354      piDstY = piDstY0 + ( leftStartL > 0 ? leftStartL : 0 );
     355
     356      for( i = min<Int>(rightEndL, pcTempPic->getWidth()) - max<Int>(0, leftStartL); i > 0; i-- )
     357      {
     358        *piDstY = ClipY( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift));
     359        piSrcY++;
     360        piDstY++;
     361      }
     362
     363      for( i = rightEndL; i < pcTempPic->getWidth(); i++ )
     364      {
     365        *piDstY = piDstY0[rightEndL-1];
     366        piDstY++;
     367      }
     368
     369      piDstY = piDstY0;
     370      for( i = 0; i < leftStartL; i++ )
     371      {
     372        *piDstY = piDstY0[leftStartL];
     373        piDstY++;
     374      }
     375#else
     376      piDstY = piDstBufY + j * strideEL;
     377
     378      for( i = 0; i < pcTempPic->getWidth(); i++ )
     379      {
     380        *piDstY = ClipY( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift));
     381
     382        // Only increase the x position of reference upsample picture when within the window
     383        // "-2" to ensure that pointer doesn't go beyond the boundary rightEndL-1
     384        if( (i >= leftStartL) && (i <= rightEndL-2) )
     385        {
     386          piSrcY++;
     387        }
     388        piDstY++;
     389      }
     390#endif
     391#endif
     392#else
     393      piDstY = piDstBufY + j * strideEL;
     394
     395      for( i = 0; i < widthEL; i++ )
     396      {
     397        *piDstY = ClipY( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift));
     398        piSrcY++;
     399        piDstY++;
     400      }
     401#endif
    314402    }
    315403
     404#if SCALED_REF_LAYER_OFFSETS
    316405    widthBL   = pcBasePic->getWidth ();
    317406    heightBL  = pcBasePic->getHeight();
     
    319408    widthEL   = pcUsPic->getWidth () - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    320409    heightEL  = pcUsPic->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     410#else
     411    widthBL   = pcBasePic->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     412    heightBL  = pcBasePic->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     413
     414    widthEL   = pcUsPic->getWidth () - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     415    heightEL  = pcUsPic->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     416#endif
    321417
    322418    //========== UV component upsampling ===========
     
    330426    strideBL  = pcBasePic->getCStride();
    331427    strideEL  = pcUsPic->getCStride();
    332 
     428#if SCALED_REF_LAYER_OFFSETS
    333429    Int leftStartC = scalEL.getWindowLeftOffset() >> 1;
    334430    Int rightEndC  = (pcUsPic->getWidth() >> 1) - (scalEL.getWindowRightOffset() >> 1);
    335431    Int topStartC  = scalEL.getWindowTopOffset() >> 1;
    336432    Int bottomEndC = (pcUsPic->getHeight() >> 1) - (scalEL.getWindowBottomOffset() >> 1);
     433#if BUGFIX_RESAMPLE
    337434    leftOffset = leftStartC > 0 ? leftStartC : 0;
     435#endif
     436#endif
    338437
    339438    shiftX = 16;
    340439    shiftY = 16;
    341440
    342 #if O0215_PHASE_ALIGNMENT 
    343     Int phaseXC = 0; 
    344     Int phaseYC = 1; 
     441#if O0215_PHASE_ALIGNMENT
     442    Int phaseXC = 0;
     443    Int phaseYC = 1;
    345444
    346445#if ROUNDING_OFFSET
     
    380479
    381480#if  N0214_INTERMEDIATE_BUFFER_16BITS
     481#if O0194_JOINT_US_BITSHIFT
     482    // g_bitDepthC was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
     483    shift1 = g_bitDepthCLayer[0] - 8;
     484#else
    382485    shift1 = g_bitDepthC - 8;
     486#endif
    383487#endif
    384488
     
    386490    for( i = 0; i < widthEL; i++ )
    387491    {
     492#if SCALED_REF_LAYER_OFFSETS
    388493      Int x = Clip3(leftStartC, rightEndC - 1, i);
    389494      refPos16 = (((x - leftStartC)*scaleX + addX) >> shiftXM4) - deltaX;
     495#else
     496      refPos16 = ((i*scaleX + addX) >> shiftXM4) - deltaX;
     497#endif
    390498      phase    = refPos16 & 15;
    391499      refPos   = refPos16 >> 4;
     
    421529
    422530#if  N0214_INTERMEDIATE_BUFFER_16BITS
     531#if O0194_JOINT_US_BITSHIFT
     532    nShift = 20 - g_bitDepthCLayer[1];
     533#else
    423534    nShift = US_FILTER_PREC*2 - shift1;
    424     iOffset = 1 << (nShift - 1);
    425 #endif
    426 
     535#endif
     536    iOffset = 1 << (nShift - 1);
     537#endif
     538
     539#if SCALED_REF_LAYER_OFFSETS
    427540    for( j = 0; j < pcTempPic->getHeight() >> 1; j++ )
     541#else
     542    for( j = 0; j < heightEL; j++ )
     543#endif
    428544    {
     545#if SCALED_REF_LAYER_OFFSETS
    429546      Int y = Clip3(topStartC, bottomEndC - 1, j);
    430547      refPos16 = (((y - topStartC)*scaleY + addY) >> shiftYM4) - deltaY;
     548#else
     549      refPos16 = ((j*scaleY + addY) >> shiftYM4) - deltaY;
     550#endif
    431551      phase    = refPos16 & 15;
    432       refPos   = refPos16 >> 4; 
     552      refPos   = refPos16 >> 4;
    433553      coeff = m_chromaFilter[phase];
    434554
    435555      piSrcU = piTempBufU  + (refPos -((NTAPS_US_CHROMA>>1) - 1))*strideEL;
    436556      piSrcV = piTempBufV  + (refPos -((NTAPS_US_CHROMA>>1) - 1))*strideEL;
    437 
     557#if SCALED_REF_LAYER_OFFSETS
     558#if BUGFIX_RESAMPLE
    438559      Pel* piDstU0 = piDstBufU + j*strideEL;
    439560      Pel* piDstV0 = piDstBufV + j*strideEL;
     
    447568        *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift));
    448569        *piDstV = ClipC( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift));
     570
    449571        piSrcU++;
    450572        piSrcV++;
     
    470592        piDstV++;
    471593      }
    472 
     594#else
     595#if 1 // it should provide identical result
     596      Pel* piDstU0 = piDstBufU + j*strideEL;
     597      Pel* piDstV0 = piDstBufV + j*strideEL;
     598      piDstU = piDstU0 + ( leftStartC > 0 ? leftStartC : 0 );
     599      piDstV = piDstV0 + ( leftStartC > 0 ? leftStartC : 0 );
     600
     601      for( i = min<Int>(rightEndC, pcTempPic->getWidth() >> 1) - max<Int>(0, leftStartC); i > 0; i-- )
     602      {
     603        *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift));
     604        *piDstV = ClipC( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift));
     605        piSrcU++;
     606        piSrcV++;
     607        piDstU++;
     608        piDstV++;
     609      }
     610
     611      for( i = rightEndC; i < pcTempPic->getWidth() >> 1; i++ )
     612      {
     613        *piDstU = piDstU0[rightEndC-1];
     614        *piDstV = piDstV0[rightEndC-1];
     615        piDstU++;
     616        piDstV++;
     617      }
     618
     619      piDstU = piDstU0;
     620      piDstV = piDstV0;
     621      for( i = 0; i < leftStartC; i++ )
     622      {
     623        *piDstU = piDstU0[leftStartC];
     624        *piDstV = piDstV0[leftStartC];
     625        piDstU++;
     626        piDstV++;
     627      }
     628#else
     629      piDstU = piDstBufU + j*strideEL;
     630      piDstV = piDstBufV + j*strideEL;
     631
     632      for( i = 0; i < pcTempPic->getWidth() >> 1; i++ )
     633      {
     634        *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift));
     635        *piDstV = ClipC( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift));
     636
     637        // Only increase the x position of reference upsample picture when within the window
     638        // "-2" to ensure that pointer doesn't go beyond the boundary rightEndC-1
     639        if( (i >= leftStartC) && (i <= rightEndC-2) )
     640        {
     641          piSrcU++;
     642          piSrcV++;
     643        }
     644
     645        piDstU++;
     646        piDstV++;
     647      }
     648#endif
     649#endif
     650#else
     651      piDstU = piDstBufU + j*strideEL;
     652      piDstV = piDstBufV + j*strideEL;
     653
     654      for( i = 0; i < widthEL; i++ )
     655      {
     656        *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift));
     657        *piDstV = ClipC( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift));
     658        piSrcU++;
     659        piSrcV++;
     660        piDstU++;
     661        piDstV++;
     662      }
     663#endif
    473664    }
    474665  }
    475   pcUsPic->setBorderExtension(false);
    476   pcUsPic->extendPicBorder   (); // extend the border.
    477 
    478   //Reset the Border extension flag
    479   pcUsPic->setBorderExtension(false);
    480   pcTempPic->setBorderExtension(false);
    481   pcBasePic->setBorderExtension(false);
     666    pcUsPic->setBorderExtension(false);
     667    pcUsPic->extendPicBorder   (); // extend the border.
     668
     669    //Reset the Border extension flag
     670    pcUsPic->setBorderExtension(false);
     671    pcTempPic->setBorderExtension(false);
     672    pcBasePic->setBorderExtension(false);
    482673}
    483674#endif //SVC_EXTENSION
  • branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h

    r464 r466  
    4646#if SVC_EXTENSION
    4747#define MFM_ENCCONSTRAINT                1      ///< JCTVC-O0216: Encoder constraint for motion field mapping
     48
     49#define O0194_DIFFERENT_BITDEPTH_EL_BL   1      ///< JCTVC-O0194: Support for different bitdepth values for BL and EL, add required configuration parameters
     50#define O0194_JOINT_US_BITSHIFT          1      ///< JCTVC-O0194: Joint Upsampling and bit-shift
     51#define O0194_WEIGHTED_PREDICTION_CGS    1      ///< JCTVC-O0194: Weighted prediciton for color gamut scalability
     52#define O0194_REPN_FORMAT_IN_VPS_BUGFIX  1      ///< JCTVC-O0194: Some bugfixes when REPN_FORMAT_IN_VPS (JCTVC-N0092) is enabled
     53
    4854#define VPS_NUH_LAYER_ID                 1      ///< JCTVC-N0085: Assert that the nuh_layer_id of VPS NAL unit should be 0
    4955#define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
     
    5965#endif
    6066#define IL_SL_SIGNALLING_N0371           0      ///< JCTVC-N0371: inter-layer scaling list
     67#define M0464_TILE_BOUNDARY_ALIGNED_FLAG 0      ///< JCTVC-M0464: VUI flag to indicate tile boundary alignment
    6168#define M0463_VUI_EXT_ILP_REF            0      ///< JCTVC-M0463: VUI extension inter-layer dependency offset signalling
    6269#define SPS_EXTENSION                    1      ///< Define sps_extension() syntax structure
     70#define SCALED_REF_LAYER_OFFSETS         1      ///< JCTVC-M0309: Signal scaled reference layer offsets in SPS
    6371#define VERT_MV_CONSTRAINT               1      ///< Vertical MV component constraint flag
    6472#define SCALABILITY_MASK_E0104           1      ///< JCT3V-E0104: scalability mask for depth
    65 #define LAYER_CTB                        0      ///< enable layer-specific CTB structure
    6673
    6774#define ILP_SSH_SIG                      1      ///< JCTVC-N0195 proposal 2, JCTVC-N0118: add presence flag in VPS ext to condition inter-layer prediction signaling in slice segment header
     
    7986#define VPS_EXTN_PROFILE_INFO            1      ///< Include profile information for layer sets in VPS extension
    8087#define VPS_EXTN_DIRECT_REF_LAYERS       1      ///< Include indication of direct dependency of layers in VPS extension
     88#define VPS_OUTPUT_LAYER_SET_IDX         1      ///< JCTVC-M0268: Signal output_layer_set_idx[i] as output_layer_set_idx_minus1[i]
     89#define VPS_MOVE_DIR_DEPENDENCY_FLAG     1      ///< JCTVC-M0268: Move the syntax element direct_dependency_flag to follow the syntax element dimension_id
     90#define VPS_PROFILE_OUTPUT_LAYERS        1      ///< JCTVC-M0268: Signal profile information and output layer information as in Sec. 3 of M0268v2
     91#define SPS_SUB_LAYER_INFO               1      ///< JCTVC-M0268: Do not signal sps_max_sub_layers_minus1 and sps_temporal_id_nesting_flag for nuh_layer_id greater than 0
     92#define VPS_SPLIT_FLAG                   1      ///< JCTVC-M0163: Do not signal dimension_id and the last dimension_id_len_minus1, when splitting_flag is equal to 1.
    8193#define M0457_PREDICTION_INDICATIONS     1
    8294#define M0040_ADAPTIVE_RESOLUTION_CHANGE 1
     
    8799#define N0160_VUI_EXT_ILP_REF            1      ///< VUI extension inter-layer dependency offset signalling
    88100#define VPS_VUI_BITRATE_PICRATE          1      ///< JCTVC-N0085: Signal bit rate and picture in VPS VUI
     101#else
     102#define M0464_TILE_BOUNDARY_ALIGNED_FLAG 0      ///< VUI flag to indicate tile boundary alignment
    89103#endif //VPS_VUI
    90104
     
    94108#define VPS_EXTN_OFFSET_CALC             1      ///< Calculation of VPS extension offset
    95109#define SPS_PTL_FIX                      1      ///< remove profile_tier_level from enhancement layer SPS
     110#define SH_DISCARDABLE_FLAG              1      ///< JCTVC-M0152: Use one reserved flag in the slice header for discardable flag
    96111
    97112#define DERIVE_LAYER_ID_LIST_VARIABLES   1      ///< Derived variables based on the variables in VPS - for use in syntax table parsing
     
    101116#define N0214_INTERMEDIATE_BUFFER_16BITS 1      ///< JCTVC-N0214: support base layer input more than 8 bits
    102117#define ARBITRARY_SPATIAL_RATIO          1      ///< JCTVC-N0219, JCTVC-N0273: Support arbitrary spatial ratio
     118#define BUGFIX_RESAMPLE                  1      ///< JCTVC-N0055: resampling bug fix for positive left scalled offset
    103119
    104120#define JCTVC_M0259_LAMBDAREFINEMENT     1      ///< JCTVC-M0259: lambda refinement (encoder only optimization)
     
    121137#define JCTVC_M0203_INTERLAYER_PRED_IDC  1      ///< JCTVC-M0203: implementation of Inter-layer Prediction Indication
    122138#if JCTVC_M0203_INTERLAYER_PRED_IDC
     139#define ILR_RESTR                        1      ///< JCTVC-M0209: Inter-layer RPS and RPL
     140#define ILR_RESTR_FIX                    1      ///< Fix encoder crash when temporal layers are used with scalable coding
    123141#define EARLY_REF_PIC_MARKING            1      ///< Decoded picture marking of sub-layer non-reference pictures
    124142#define N0120_MAX_TID_REF_PRESENT_FLAG   1      ///< JCTVC-N0120: max_tid_ref_pics_plus1_present_flag
  • branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r464 r466  
    187187  assert(uiCode <= 63);
    188188  pcPPS->setPPSId (uiCode);
    189  
     189
    190190  READ_UVLC( uiCode, "pps_seq_parameter_set_id");
    191191  assert(uiCode <= 15);
    192192  pcPPS->setSPSId (uiCode);
    193  
     193
    194194  READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag"    );    pcPPS->setDependentSliceSegmentsEnabledFlag   ( uiCode == 1 );
    195195  READ_FLAG( uiCode, "output_flag_present_flag" );                    pcPPS->setOutputFlagPresentFlag( uiCode==1 );
     
    293293
    294294#if IL_SL_SIGNALLING_N0371
    295   pcPPS->setPPS( pcPPS->getLayerId(), pcPPS ); 
     295  pcPPS->setPPS( pcPPS->getLayerId(), pcPPS );
    296296#endif
    297297
     
    301301    pcPPS->getScalingList()->setLayerId( pcPPS->getLayerId() );
    302302
    303     if( pcPPS->getLayerId() > 0 ) 
     303    if( pcPPS->getLayerId() > 0 )
    304304    {
    305305      READ_FLAG( uiCode, "pps_pred_scaling_list_flag" );           pcPPS->setPredScalingListFlag( uiCode ? true : false );
    306306      pcPPS->getScalingList()->setPredScalingListFlag( pcPPS->getPredScalingListFlag() );
    307      
     307
    308308      if( pcPPS->getPredScalingListFlag() )
    309309      {
     
    319319        }
    320320
    321         // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and 
     321        // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and
    322322        // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id
    323323        assert( pcPPS->getPPS( pcPPS->getScalingListRefLayerId() )->getPredScalingListFlag() == false );
    324324
    325         // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, 
     325        // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,
    326326        // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB
    327327        assert( pcPPS->getSPS()->getVPS()->getScalingListLayerDependency( pcPPS->getLayerId(), pcPPS->getScalingListRefLayerId() ) == true );
     
    450450  {
    451451    READ_FLAG(   uiCode, "tiles_fixed_structure_flag");               pcVUI->setTilesFixedStructureFlag(uiCode);
     452#if M0464_TILE_BOUNDARY_ALIGNED_FLAG
     453    if ( pcSPS->getLayerId() > 0 )
     454    {
     455      READ_FLAG( uiCode, "tile_boundaries_aligned_flag" ); pcVUI->setTileBoundariesAlignedFlag( uiCode == 1 );
     456    }
     457#endif
    452458    READ_FLAG(   uiCode, "motion_vectors_over_pic_boundaries_flag");  pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode);
    453459    READ_FLAG(   uiCode, "restricted_ref_pic_lists_flag");            pcVUI->setRestrictedRefPicListsFlag(uiCode);
     
    536542}
    537543
    538 #if SVC_EXTENSION
     544#if SPS_SUB_LAYER_INFO
    539545Void TDecCavlc::parseSPS(TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager)
    540546#else
     
    548554  UInt  uiCode;
    549555  READ_CODE( 4,  uiCode, "sps_video_parameter_set_id");          pcSPS->setVPSId        ( uiCode );
    550 #if SVC_EXTENSION
     556#if SPS_SUB_LAYER_INFO
    551557  if(pcSPS->getLayerId() == 0)
    552558  {
     
    554560    READ_CODE( 3,  uiCode, "sps_max_sub_layers_minus1" );          pcSPS->setMaxTLayers   ( uiCode+1 );
    555561    assert(uiCode <= 6);
    556  
     562
    557563    READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" );               pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false );
    558 #if SVC_EXTENSION
     564#if SPS_SUB_LAYER_INFO
    559565  }
    560566  else
     
    563569    pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() );
    564570  }
     571#endif
    565572#if IL_SL_SIGNALLING_N0371
    566573  pcSPS->setVPS( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId()) );
    567574  pcSPS->setSPS( pcSPS->getLayerId(), pcSPS );
    568575#endif
    569 #endif
    570576  if ( pcSPS->getMaxTLayers() == 1 )
    571577  {
    572578    // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0
    573 #if SVC_EXTENSION
     579#if SPS_SUB_LAYER_INFO
    574580    assert( pcSPS->getTemporalIdNestingFlag() == true );
    575581#else
     
    592598  if( pcSPS->getLayerId() > 0 )
    593599  {
    594     READ_FLAG( uiCode, "update_rep_format_flag" );                 
     600    READ_FLAG( uiCode, "update_rep_format_flag" );
    595601    pcSPS->setUpdateRepFormatFlag( uiCode ? true : false );
    596602  }
     
    599605    pcSPS->setUpdateRepFormatFlag( true );
    600606  }
    601   if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 
     607  if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() )
    602608  {
    603609#endif
     
    633639  }
    634640#if REPN_FORMAT_IN_VPS
    635   if(  pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 
     641  if(  pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() )
    636642  {
    637643#endif
     
    653659  UInt subLayerOrderingInfoPresentFlag;
    654660  READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag");
    655  
     661
    656662  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
    657663  {
     
    722728          }
    723729
    724           // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and 
     730          // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and
    725731          // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id
    726732          assert( pcSPS->getSPS( pcSPS->getScalingListRefLayerId() )->getPredScalingListFlag() == false );
    727733
    728           // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, 
     734          // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,
    729735          // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB
    730736          assert( pcSPS->getVPS()->getScalingListLayerDependency( pcSPS->getLayerId(), pcSPS->getScalingListRefLayerId() ) == true );
     
    835841  assert( uiCode == 0 );
    836842#endif
     843#if SCALED_REF_LAYER_OFFSETS
    837844  if( pcSPS->getLayerId() > 0 )
    838845  {
    839     Int iCode; 
     846    Int iCode;
    840847    READ_UVLC( uiCode,      "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode);
    841848    for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++)
     
    848855    }
    849856  }
     857#endif
    850858#if M0463_VUI_EXT_ILP_REF
    851859  ////   sps_extension_vui_parameters( )
    852860  if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() )
    853   { 
    854     READ_UVLC( uiCode, "num_ilp_restricted_ref_layers" ); pcSPS->setNumIlpRestrictedRefLayers( uiCode ); 
    855     for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ ) 
    856     { 
    857       READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcSPS->setMinSpatialSegmentOffsetPlus1( i, uiCode ); 
    858       if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 ) 
    859       { 
    860         READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[ i ]"); pcSPS->setCtuBasedOffsetEnabledFlag(i, uiCode == 1 ); 
    861         if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) ) 
    862         {
    863           READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[ i ]"); pcSPS->setMinHorizontalCtuOffsetPlus1( i, uiCode ); 
    864         }
    865       } 
    866     } 
    867   } 
     861  {
     862    READ_UVLC( uiCode, "num_ilp_restricted_ref_layers" ); pcSPS->setNumIlpRestrictedRefLayers( uiCode );
     863    for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ )
     864    {
     865      READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcSPS->setMinSpatialSegmentOffsetPlus1( i, uiCode );
     866      if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 )
     867      {
     868        READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[ i ]"); pcSPS->setCtuBasedOffsetEnabledFlag(i, uiCode == 1 );
     869        if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) )
     870        {
     871          READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[ i ]"); pcSPS->setMinHorizontalCtuOffsetPlus1( i, uiCode );
     872        }
     873      }
     874    }
     875  }
    868876  ////   sps_extension_vui_parameters( ) END
    869877#endif
     
    9921000}
    9931001
    994 #if SVC_EXTENSION
    9951002#if VPS_EXTNS
    9961003Void TDecCavlc::parseVPSExtension(TComVPS *vps)
     
    10111018  vps->setNumScalabilityTypes(numScalabilityTypes);
    10121019
     1020#if VPS_SPLIT_FLAG
    10131021  for(j = 0; j < numScalabilityTypes - vps->getSplittingFlag(); j++)
     1022#else
     1023  for(j = 0; j < numScalabilityTypes; j++)
     1024#endif
    10141025  {
    10151026    READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1);
    10161027  }
    1017 
     1028#if VPS_SPLIT_FLAG
    10181029  if(vps->getSplittingFlag())
    10191030  {
     
    10271038    numBits = 6;
    10281039  }
     1040#else
     1041  if(vps->getSplittingFlag())
     1042  {
     1043    UInt numBits = 0;
     1044    for(j = 0; j < numScalabilityTypes; j++)
     1045    {
     1046      numBits += vps->getDimensionIdLen(j);
     1047    }
     1048    assert( numBits <= 6 );
     1049  }
     1050#endif
    10291051
    10301052  READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false);
     
    10441066    vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i);
    10451067
    1046     if( !vps->getSplittingFlag() )
    1047     {
    1048       for(j = 0; j < numScalabilityTypes; j++)
    1049       {
    1050         READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode);
    1051         assert( uiCode <= vps->getMaxLayerId() );
    1052       }
    1053     }
    1054   }
    1055 #endif
    1056 #if VIEW_ID_RELATED_SIGNALING 
    1057   // if ( pcVPS->getNumViews() > 1 ) 
    1058   //   However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val. 
     1068#if VPS_SPLIT_FLAG
     1069    if(!vps->getSplittingFlag())
     1070#endif
     1071    for(j = 0; j < numScalabilityTypes; j++)
     1072    {
     1073      READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode);
     1074      assert( uiCode <= vps->getMaxLayerId() );
     1075    }
     1076  }
     1077#endif
     1078#if VIEW_ID_RELATED_SIGNALING
     1079  // if ( pcVPS->getNumViews() > 1 )
     1080  //   However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val.
    10591081  {
    10601082    READ_CODE( 4, uiCode, "view_id_len_minus1" ); vps->setViewIdLenMinus1( uiCode );
     
    10661088  }
    10671089#endif
     1090#if VPS_MOVE_DIR_DEPENDENCY_FLAG
    10681091#if VPS_EXTN_DIRECT_REF_LAYERS
    10691092  // For layer 0
     
    10851108  }
    10861109#endif
     1110#endif
    10871111#if JCTVC_M0203_INTERLAYER_PRED_IDC
    10881112#if N0120_MAX_TID_REF_PRESENT_FLAG
     
    10951119#if N0120_MAX_TID_REF_CFG
    10961120      assert( uiCode <= vps->getMaxTLayers());
    1097 #else 
     1121#else
    10981122      assert( uiCode <= vps->getMaxTLayers()+ 1 );
    1099 #endif 
    1100     }
    1101   }
    1102   else 
     1123#endif
     1124    }
     1125  }
     1126  else
    11031127  {
    11041128    for(i = 0; i < vps->getMaxLayers() - 1; i++)
     
    11201144#if VPS_EXTN_PROFILE_INFO
    11211145  // Profile-tier-level signalling
     1146#if VPS_PROFILE_OUTPUT_LAYERS
    11221147  READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" );     assert( uiCode == (vps->getNumLayerSets() - 1) );
    11231148  READ_CODE(  6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 );
    11241149  vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel());
    11251150  for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
     1151#else
     1152  vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets());
     1153  for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++)
     1154#endif
    11261155  {
    11271156    READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false);
    11281157    if( !vps->getProfilePresentFlag(idx) )
    11291158    {
     1159#if VPS_PROFILE_OUTPUT_LAYERS
    11301160      READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1);
     1161#else
     1162      READ_UVLC( uiCode, "vps_profile_layer_set_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1);
     1163#endif
    11311164      assert( vps->getProfileLayerSetRef(idx) < idx );
    1132 
    11331165      // Copy profile information as indicated
    11341166      vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) );
     
    11381170#endif
    11391171
     1172#if VPS_PROFILE_OUTPUT_LAYERS
    11401173  READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false );
    11411174  Int numOutputLayerSets = 0;
     
    11981231    READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" );     vps->setProfileLevelTierIdx(i, uiCode);
    11991232  }
    1200 
     1233#else
     1234#if VPS_EXTN_OP_LAYER_SETS
     1235  // Target output layer signalling
     1236  READ_UVLC( uiCode,            "vps_num_output_layer_sets"); vps->setNumOutputLayerSets(uiCode);
     1237  for(i = 0; i < vps->getNumOutputLayerSets(); i++)
     1238  {
     1239#if VPS_OUTPUT_LAYER_SET_IDX
     1240    READ_UVLC( uiCode,           "vps_output_layer_set_idx_minus1[i]"); vps->setOutputLayerSetIdx(i, uiCode + 1);
     1241#else
     1242    READ_UVLC( uiCode,           "vps_output_layer_set_idx[i]"); vps->setOutputLayerSetIdx(i, uiCode);
     1243#endif
     1244    Int lsIdx = vps->getOutputLayerSetIdx(i);
     1245    for(j = 0; j <= vps->getMaxLayerId(); j++)
     1246    {
     1247      if(vps->getLayerIdIncludedFlag(lsIdx, j))
     1248      {
     1249        READ_FLAG( uiCode, "vps_output_layer_flag[lsIdx][j]"); vps->setOutputLayerFlag(lsIdx, j, uiCode);
     1250      }
     1251    }
     1252  }
     1253#endif
     1254#endif
    12011255#if REPN_FORMAT_IN_VPS
    1202   READ_FLAG( uiCode, "rep_format_idx_present_flag"); 
     1256  READ_FLAG( uiCode, "rep_format_idx_present_flag");
    12031257  vps->setRepFormatIdxPresentFlag( uiCode ? true : false );
    12041258
     
    12191273    parseRepFormat( vps->getVpsRepFormat(i) );
    12201274  }
    1221  
     1275
    12221276  // Default assignment for layer 0
    12231277  vps->setVpsRepFormatIdx( 0, 0 );
     
    12581312  READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" );
    12591313  vps->setCrossLayerIrapAlignFlag(uiCode);
    1260 #endif
    1261 
     1314#endif
     1315
     1316#if !VPS_MOVE_DIR_DEPENDENCY_FLAG
     1317#if VPS_EXTN_DIRECT_REF_LAYERS
     1318  // For layer 0
     1319  vps->setNumDirectRefLayers(0, 0);
     1320  // For other layers
     1321  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     1322  {
     1323    UInt numDirectRefLayers = 0;
     1324    for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     1325    {
     1326      READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false);
     1327      if(uiCode)
     1328      {
     1329        vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr);
     1330        numDirectRefLayers++;
     1331      }
     1332    }
     1333    vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers);
     1334  }
     1335#endif
     1336#endif
    12621337#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
    12631338  READ_UVLC( uiCode,           "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2);
     
    12791354    {
    12801355      for(j = 0; j < i; j++)
    1281         {     
     1356        {
    12821357          vps->setScalingListLayerDependency( i, j, vps->checkLayerDependency( i,j ) );
    12831358        }
     
    12981373    }
    12991374    parseVPSVUI(vps);
    1300 #endif 
     1375#endif
    13011376  }
    13021377}
     
    13071382  UInt uiCode;
    13081383  READ_CODE( 2, uiCode, "chroma_format_idc" );               repFormat->setChromaFormatVpsIdc( uiCode );
    1309  
     1384
    13101385  if( repFormat->getChromaFormatVpsIdc() == 3 )
    13111386  {
     
    13151390  READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" );     repFormat->setPicWidthVpsInLumaSamples ( uiCode );
    13161391  READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" );    repFormat->setPicHeightVpsInLumaSamples( uiCode );
    1317  
     1392
    13181393  READ_CODE( 4, uiCode, "bit_depth_luma_minus8" );           repFormat->setBitDepthVpsLuma  ( uiCode + 8 );
    13191394  READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" );         repFormat->setBitDepthVpsChroma( uiCode + 8 );
     
    13811456    for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++)
    13821457    {
    1383       READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1));     
    1384     }
    1385   } 
    1386 #endif 
     1458      READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1));
     1459    }
     1460  }
     1461#endif
    13871462#if N0160_VUI_EXT_ILP_REF
    1388     READ_FLAG( uiCode, "num_ilp_restricted_ref_layers" ); vps->setNumIlpRestrictedRefLayers( uiCode == 1 ); 
     1463    READ_FLAG( uiCode, "num_ilp_restricted_ref_layers" ); vps->setNumIlpRestrictedRefLayers( uiCode == 1 );
    13891464  if( vps->getNumIlpRestrictedRefLayers())
    13901465  {
     
    13931468      for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++)
    13941469      {
    1395         READ_UVLC( uiCode, "min_spatial_segment_offset_plus1[i][j]" ); vps->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); 
    1396         if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) 
    1397         { 
    1398           READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[i][j]"); vps->setCtuBasedOffsetEnabledFlag(i, j, uiCode == 1 ); 
    1399           if(vps->getCtuBasedOffsetEnabledFlag(i,j)) 
     1470        READ_UVLC( uiCode, "min_spatial_segment_offset_plus1[i][j]" ); vps->setMinSpatialSegmentOffsetPlus1( i, j, uiCode );
     1471        if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 )
     1472        {
     1473          READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[i][j]"); vps->setCtuBasedOffsetEnabledFlag(i, j, uiCode == 1 );
     1474          if(vps->getCtuBasedOffsetEnabledFlag(i,j))
    14001475          {
    1401             READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[i][j]"); vps->setMinHorizontalCtuOffsetPlus1( i,j, uiCode ); 
     1476            READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[i][j]"); vps->setMinHorizontalCtuOffsetPlus1( i,j, uiCode );
    14021477          }
    1403         } 
    1404       } 
    1405     }
    1406   }
    1407 #endif
    1408 }
    1409 #endif
    1410 #endif //SVC_EXTENSION
    1411 
     1478        }
     1479      }
     1480    }
     1481  }
     1482#endif
     1483}
     1484#endif
    14121485Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager)
    14131486{
     
    14821555  if(!rpcSlice->getDependentSliceSegmentFlag())
    14831556  {
    1484 #if SVC_EXTENSION
    14851557#if POC_RESET_FLAG
    1486     Int iBits = 0; 
     1558    Int iBits = 0;
    14871559    if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits)
    14881560    {
     
    15001572    }
    15011573#else
     1574#if SH_DISCARDABLE_FLAG
    15021575    if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0)
    15031576    {
     
    15081581      READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored
    15091582    }
    1510 #endif
    1511 #else //SVC_EXTENSION
     1583#else
    15121584    for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)
    15131585    {
    15141586      READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored
    15151587    }
    1516 #endif //SVC_EXTENSION
     1588#endif
     1589#endif
    15171590
    15181591    READ_UVLC (    uiCode, "slice_type" );            rpcSlice->setSliceType((SliceType)uiCode);
     
    16761749            rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt);
    16771750            rps->setCheckLTMSBPresent(j,false);
    1678            
     1751
    16791752            // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present
    16801753            if( j == offset+(numOfLtrp-numLtrpInSPS)-1 )
     
    17791852#else
    17801853    else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == false )
    1781 #endif 
     1854#endif
    17821855    {
    17831856      rpcSlice->setInterLayerPredEnabledFlag(true);
     
    20072080
    20082081#if REPN_FORMAT_IN_VPS
     2082#if O0194_REPN_FORMAT_IN_VPS_BUGFIX
     2083    g_bitDepthYLayer[rpcSlice->getLayerId()]     = rpcSlice->getBitDepthY();
     2084    g_bitDepthCLayer[rpcSlice->getLayerId()]     = rpcSlice->getBitDepthC();
     2085#endif
    20092086    assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() );
    20102087#else
     
    21172194  {
    21182195    Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation();
    2119    
     2196
    21202197    // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header
    21212198    for ( UInt curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
     
    25232600#if IL_SL_SIGNALLING_N0371
    25242601      if ( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() )
    2525       { 
     2602      {
    25262603        READ_FLAG( code, "scaling_list_pred_mode_flag");
    25272604        scalingListPredModeFlag = (code) ? true : false;
  • branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecCAVLC.h

    r452 r466  
    7272  Void  parseQtRootCbf      ( UInt uiAbsPartIdx, UInt& uiQtRootCbf );
    7373  Void  parseVPS            ( TComVPS* pcVPS );
    74 #if SPS_EXTENSION
    7574#if VPS_EXTNS
    7675  Void  parseVPSExtension   ( TComVPS* pcVPS );
     
    8382  Void  parseRepFormat      ( RepFormat *repFormat );
    8483#endif
     84#if SPS_SUB_LAYER_INFO
    8585  Void  parseSPS            ( TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager );
    86   Void  parseSPSExtension    ( TComSPS* pcSPS );
    87 #else //SVC_EXTENSION
     86#else
    8887  Void  parseSPS            ( TComSPS* pcSPS );
    89 #endif //SVC_EXTENSION
     88#endif
     89#if SPS_EXTENSION
     90  Void parseSPSExtension    ( TComSPS* pcSPS );
     91#endif
    9092  Void  parsePPS            ( TComPPS* pcPPS);
    9193  Void  parseVUI            ( TComVUI* pcVUI, TComSPS* pcSPS );
  • branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecCu.cpp

    r442 r466  
    616616    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
    617617  }
     618#if O0194_REPN_FORMAT_IN_VPS_BUGFIX
     619#if REPN_FORMAT_IN_VPS
     620  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getQpBDOffsetC(), curChromaQpOffset );
     621#else
    618622  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
     623#endif
     624#else
     625  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
     626#endif
    619627
    620628  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
     
    768776  // Cb and Cr
    769777  Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
     778#if O0194_REPN_FORMAT_IN_VPS_BUGFIX
     779#if REPN_FORMAT_IN_VPS
     780  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getQpBDOffsetC(), curChromaQpOffset );
     781#else
    770782  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
     783#endif
     784#else
     785  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
     786#endif
    771787
    772788  uiWidth  >>= 1;
     
    776792
    777793  curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
     794#if O0194_REPN_FORMAT_IN_VPS_BUGFIX
     795#if REPN_FORMAT_IN_VPS
     796  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getQpBDOffsetC(), curChromaQpOffset );
     797#else
    778798  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
     799#endif
     800#else
     801  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
     802#endif
    779803
    780804  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
  • branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecEntropy.h

    r452 r466  
    6666
    6767  virtual Void  parseVPS                  ( TComVPS* pcVPS )                       = 0;
    68 #if SVC_EXTENSION
     68#if SPS_SUB_LAYER_INFO
    6969  virtual Void  parseSPS                  ( TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager )           = 0;
    7070#else
     
    134134  Void    resetEntropy                ( TComSlice* p)           { m_pcEntropyDecoderIf->resetEntropy(p);                    }
    135135  Void    decodeVPS                   ( TComVPS* pcVPS ) { m_pcEntropyDecoderIf->parseVPS(pcVPS); }
    136 #if SVC_EXTENSION
     136#if SPS_SUB_LAYER_INFO
    137137  Void    decodeSPS                   ( TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager )    { m_pcEntropyDecoderIf->parseSPS(pcSPS, parameterSetManager);                    }
    138138#else
  • branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecSbac.h

    r452 r466  
    7676  Void  setBitstream              ( TComInputBitstream* p  ) { m_pcBitstream = p; m_pcTDecBinIf->init( p ); }
    7777  Void  parseVPS                  ( TComVPS* /*pcVPS*/ ) {}
    78 #if SVC_EXTENSION
     78#if SPS_SUB_LAYER_INFO
    7979  Void  parseSPS                  ( TComSPS* /*pcSPS*/, ParameterSetManagerDecoder * /*parameterSetManager*/ ) {}
    8080#else
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r464 r466  
    359359  {
    360360    WRITE_FLAG(pcVUI->getTilesFixedStructureFlag(),             "tiles_fixed_structure_flag");
     361#if M0464_TILE_BOUNDARY_ALIGNED_FLAG
     362    if ( pcSPS->getLayerId() > 0 )
     363    {
     364      WRITE_FLAG( pcVUI->getTileBoundariesAlignedFlag( ) ? 1 : 0 , "tile_boundaries_aligned_flag" );
     365    }
     366#endif
    361367    WRITE_FLAG(pcVUI->getMotionVectorsOverPicBoundariesFlag(),  "motion_vectors_over_pic_boundaries_flag");
    362368    WRITE_FLAG(pcVUI->getRestrictedRefPicListsFlag(),           "restricted_ref_pic_lists_flag");
     
    448454#endif
    449455  WRITE_CODE( pcSPS->getVPSId (),          4,       "sps_video_parameter_set_id" );
    450 #if SVC_EXTENSION
     456#if SPS_SUB_LAYER_INFO
    451457  if(pcSPS->getLayerId() == 0)
    452458  {
     
    454460    WRITE_CODE( pcSPS->getMaxTLayers() - 1,  3,       "sps_max_sub_layers_minus1" );
    455461    WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0,                             "sps_temporal_id_nesting_flag" );
    456 #if SVC_EXTENSION
     462#if SPS_SUB_LAYER_INFO
    457463  }
    458464#endif
     
    664670  WRITE_FLAG( 0, "inter_view_mv_vert_constraint_flag" );
    665671#endif
     672#if SCALED_REF_LAYER_OFFSETS
    666673  if( pcSPS->getLayerId() > 0 )
    667674  {
     
    676683    }
    677684  }
     685#endif
    678686#if M0463_VUI_EXT_ILP_REF
    679687  ////   sps_extension_vui_parameters( )
     
    820828}
    821829
    822 #if SVC_EXTENSION
    823830#if VPS_EXTNS
    824831Void TEncCavlc::codeVPSExtension (TComVPS *vps)
     
    836843  }
    837844
     845#if VPS_SPLIT_FLAG
    838846  for(j = 0; j < vps->getNumScalabilityTypes() - vps->getSplittingFlag(); j++)
     847#else
     848  for(j = 0; j < vps->getNumScalabilityTypes(); j++)
     849#endif
    839850  {
    840851    WRITE_CODE( vps->getDimensionIdLen(j) - 1, 3,      "dimension_id_len_minus1[j]" );
     
    860871      WRITE_CODE( vps->getLayerIdInNuh(i),     6,      "layer_id_in_nuh[i]" );
    861872    }
    862 
    863     if( !vps->getSplittingFlag() )
    864     {
    865       for(j = 0; j < vps->getNumScalabilityTypes(); j++)
    866       {
    867         UInt bits = vps->getDimensionIdLen(j);
    868         WRITE_CODE( vps->getDimensionId(i, j),   bits,   "dimension_id[i][j]" );
    869       }
     873#if VPS_SPLIT_FLAG
     874    if(!vps->getSplittingFlag())
     875#endif
     876    for(j = 0; j < vps->getNumScalabilityTypes(); j++)
     877    {
     878      UInt bits = vps->getDimensionIdLen(j);
     879      WRITE_CODE( vps->getDimensionId(i, j),   bits,   "dimension_id[i][j]" );
    870880    }
    871881  }
     
    883893  }
    884894#endif
     895#if VPS_MOVE_DIR_DEPENDENCY_FLAG
    885896#if VPS_EXTN_DIRECT_REF_LAYERS
    886897  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     
    891902    }
    892903  }
     904#endif
    893905#endif
    894906#if JCTVC_M0203_INTERLAYER_PRED_IDC
     
    914926#if VPS_EXTN_PROFILE_INFO
    915927  // Profile-tier-level signalling
     928#if VPS_PROFILE_OUTPUT_LAYERS
    916929  WRITE_CODE( vps->getNumLayerSets() - 1   , 10, "vps_number_layer_sets_minus1" );     
    917930  WRITE_CODE( vps->getNumProfileTierLevel() - 1,  6, "vps_num_profile_tier_level_minus1");
    918931  for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
     932#else
     933  for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++)
     934#endif
    919935  {
    920936    WRITE_FLAG( vps->getProfilePresentFlag(idx),       "vps_profile_present_flag[i]" );
    921937    if( !vps->getProfilePresentFlag(idx) )
    922938    {
     939#if VPS_PROFILE_OUTPUT_LAYERS
    923940      WRITE_CODE( vps->getProfileLayerSetRef(idx) - 1, 6, "profile_ref_minus1[i]" );
     941#else
     942      WRITE_UVLC( vps->getProfileLayerSetRef(idx) - 1, "vps_profile_layer_set_ref_minus1[i]" );
     943#endif
    924944    }
    925945    codePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 );
     
    927947#endif
    928948
     949#if VPS_PROFILE_OUTPUT_LAYERS
    929950  Int numOutputLayerSets = vps->getNumOutputLayerSets() ;
    930951  WRITE_FLAG(  (numOutputLayerSets > vps->getNumLayerSets()), "more_output_layer_sets_than_default_flag" );
     
    961982    WRITE_CODE( vps->getProfileLevelTierIdx(i), numBits, "profile_level_tier_idx[i]" );     
    962983  }
    963  
     984#else
     985#if VPS_EXTN_OP_LAYER_SETS
     986  // Target output layer signalling
     987  WRITE_UVLC( vps->getNumOutputLayerSets(),            "vps_num_output_layer_sets");
     988  for(i = 0; i < vps->getNumOutputLayerSets(); i++)
     989  {
     990#if VPS_OUTPUT_LAYER_SET_IDX
     991    assert(vps->getOutputLayerSetIdx(i) > 0);
     992    WRITE_UVLC( vps->getOutputLayerSetIdx(i) - 1,           "vps_output_layer_set_idx_minus1[i]");
     993#else
     994    WRITE_UVLC( vps->getOutputLayerSetIdx(i),           "vps_output_layer_set_idx[i]");
     995#endif
     996    Int lsIdx = vps->getOutputLayerSetIdx(i);
     997    for(j = 0; j <= vps->getMaxLayerId(); j++)
     998    {
     999      if(vps->getLayerIdIncludedFlag(lsIdx, j))
     1000      {
     1001        WRITE_FLAG( vps->getOutputLayerFlag(lsIdx, j), "vps_output_layer_flag[lsIdx][j]");
     1002      }
     1003    }
     1004  }
     1005#endif
     1006#endif
     1007
    9641008#if REPN_FORMAT_IN_VPS
    9651009  WRITE_FLAG( vps->getRepFormatIdxPresentFlag(), "rep_format_idx_present_flag");
     
    9881032
    9891033#if JCTVC_M0458_INTERLAYER_RPS_SIG
    990   WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag");
     1034      WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag");
    9911035#endif
    9921036#if O0215_PHASE_ALIGNMENT
     
    9941038#endif
    9951039#if N0147_IRAP_ALIGN_FLAG
    996   WRITE_FLAG(vps->getCrossLayerIrapAlignFlag(), "cross_layer_irap_aligned_flag");
     1040      WRITE_FLAG(vps->getCrossLayerIrapAlignFlag(), "cross_layer_irap_aligned_flag");
    9971041#endif
     1042#if !VPS_MOVE_DIR_DEPENDENCY_FLAG
     1043#if VPS_EXTN_DIRECT_REF_LAYERS
     1044  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     1045  {
     1046    for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     1047    {
     1048      WRITE_FLAG(vps->getDirectDependencyFlag(layerCtr, refLayerCtr), "direct_dependency_flag[i][j]" );
     1049    }
     1050  }
     1051#endif
     1052#endif
    9981053#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
    9991054  WRITE_UVLC( vps->getDirectDepTypeLen()-2,                           "direct_dep_type_len_minus2");
     
    11291184}
    11301185#endif
    1131 #endif //SVC_EXTENSION
    11321186
    11331187Void TEncCavlc::codeSliceHeader         ( TComSlice* pcSlice )
     
    11751229  if ( !pcSlice->getDependentSliceSegmentFlag() )
    11761230  {
    1177 #if SVC_EXTENSION
     1231
    11781232#if POC_RESET_FLAG
    11791233    Int iBits = 0;
     
    11951249    }
    11961250#else
     1251#if SH_DISCARDABLE_FLAG
    11971252    if (pcSlice->getPPS()->getNumExtraSliceHeaderBits()>0)
    11981253    {
     
    12051260      WRITE_FLAG(0, "slice_reserved_undetermined_flag[]");
    12061261    }
    1207 #endif
    1208 #else //SVC_EXTENSION
     1262#else
    12091263    for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)
    12101264    {
     
    12121266      WRITE_FLAG(0, "slice_reserved_undetermined_flag[]");
    12131267    }
    1214 #endif //SVC_EXTENSION
     1268#endif
     1269#endif
    12151270
    12161271    WRITE_UVLC( pcSlice->getSliceType(),       "slice_type" );
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r464 r466  
    753753    pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR));
    754754#if SVC_EXTENSION
     755#if ILR_RESTR && ILR_RESTR_FIX
     756    Int interLayerPredLayerIdcTmp[MAX_VPS_LAYER_ID_PLUS1];
     757    Int activeNumILRRefIdxTmp = 0;
     758#endif
    755759    if (m_layerId > 0)
    756760    {
    757       Int interLayerPredLayerIdcTmp[MAX_VPS_LAYER_ID_PLUS1];
    758       Int activeNumILRRefIdxTmp = 0;
    759 
    760761      for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
    761762      {
     
    768769        pcSlice->setBaseColPic( *cListPic, refLayerIdc );
    769770
     771#if ILR_RESTR && ILR_RESTR_FIX
    770772        // Apply temporal layer restriction to inter-layer prediction
    771773        Int maxTidIlRefPicsPlus1 = m_pcEncTop->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getLayerId());
     
    778780          continue; // ILP is not valid due to temporal layer restriction
    779781        }
    780 
     782#endif
     783
     784#if SCALED_REF_LAYER_OFFSETS
    781785        const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow(refLayerIdc);
    782786
     
    786790        Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    787791        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
    788 
     792#else
     793        const Window &confBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getConformanceWindow();
     794        const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
     795
     796        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     797        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     798
     799        Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     800        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     801#endif
    789802        g_mvScalingFactor[refLayerIdc][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
    790803        g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
     
    810823      }
    811824
     825#if ILR_RESTR && ILR_RESTR_FIX
    812826      // Update the list of active inter-layer pictures
    813827      for ( Int i = 0; i < activeNumILRRefIdxTmp; i++)
     
    821835        pcSlice->setInterLayerPredEnabledFlag(false);
    822836      }
     837#endif
    823838     
    824839      if( pocCurr % m_pcCfg->getIntraPeriod() == 0 )
     
    16011616          pcSlice->setSliceSegmentCurStartCUAddr  ( startCUAddrSlice      );
    16021617          pcSlice->setSliceBits(0);
    1603 #if SVC_EXTENSION
    1604           // copy reference list modification info from the first slice, assuming that this information is the same across all slices in the picture
    1605           memcpy( pcSlice->getRefPicListModification(), pcPic->getSlice(0)->getRefPicListModification(), sizeof(TComRefPicListModification) );
    1606 #endif
    16071618          uiNumSlices ++;
    16081619        }
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncSearch.cpp

    r442 r466  
    41194119
    41204120  // prediction pattern
     4121#if O0194_WEIGHTED_PREDICTION_CGS
     4122  // Bug Fix (It did not check WP for BSlices)
     4123  if ( pcCU->getSlice()->getPPS()->getUseWP())
     4124#else
    41214125  if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType()==P_SLICE )
     4126#endif
    41224127  {
    41234128    xPredInterLumaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true );
     
    41284133  }
    41294134
     4135#if O0194_WEIGHTED_PREDICTION_CGS
     4136  if ( pcCU->getSlice()->getPPS()->getUseWP())
     4137  ///< Bug Fix (It did not check WP for BSlices)
     4138#else
    41304139  if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType()==P_SLICE )
     4140#endif
    41314141  {
    41324142    xWeightedPredictionUni( pcCU, pcTemplateCand, uiPartAddr, iSizeX, iSizeY, eRefPicList, pcTemplateCand, iRefIdx );
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncSlice.cpp

    r442 r466  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2013, ITU/ISO/IEC
     
    5151  m_apcPicYuvPred = NULL;
    5252  m_apcPicYuvResi = NULL;
    53  
     53
    5454  m_pdRdPicLambda = NULL;
    5555  m_pdRdPicQp     = NULL;
     
    6969}
    7070
    71 Void TEncSlice::initCtxMem(  UInt i )               
    72 {   
     71Void TEncSlice::initCtxMem(  UInt i )
     72{
    7373  for (std::vector<TEncSbac*>::iterator j = CTXMem.begin(); j != CTXMem.end(); j++)
    7474  {
    7575    delete (*j);
    7676  }
    77   CTXMem.clear(); 
    78   CTXMem.resize(i); 
     77  CTXMem.clear();
     78  CTXMem.resize(i);
    7979}
    8080
     
    8787    m_apcPicYuvPred->create( iWidth, iHeight, iMaxCUWidth, iMaxCUHeight, uhTotalDepth );
    8888  }
    89  
     89
    9090  // create residual picture
    9191  if( m_apcPicYuvResi == NULL )
     
    105105    m_apcPicYuvPred  = NULL;
    106106  }
    107  
     107
    108108  // destroy residual picture
    109109  if ( m_apcPicYuvResi )
     
    113113    m_apcPicYuvResi  = NULL;
    114114  }
    115  
     115
    116116  // free lambda and QP arrays
    117117  if ( m_pdRdPicLambda ) { xFree( m_pdRdPicLambda ); m_pdRdPicLambda = NULL; }
     
    139139#if SVC_EXTENSION
    140140  m_ppcTEncTop        = pcEncTop->getLayerEnc();
    141 #endif 
     141#endif
    142142  m_pcGOPEncoder      = pcEncTop->getGOPEncoder();
    143143  m_pcCuEncoder       = pcEncTop->getCuEncoder();
    144144  m_pcPredSearch      = pcEncTop->getPredSearch();
    145  
     145
    146146  m_pcEntropyCoder    = pcEncTop->getEntropyCoder();
    147147  m_pcCavlcCoder      = pcEncTop->getCavlcCoder();
     
    149149  m_pcBinCABAC        = pcEncTop->getBinCABAC();
    150150  m_pcTrQuant         = pcEncTop->getTrQuant();
    151  
     151
    152152  m_pcBitCounter      = pcEncTop->getBitCounter();
    153153  m_pcRdCost          = pcEncTop->getRdCost();
    154154  m_pppcRDSbacCoder   = pcEncTop->getRDSbacCoder();
    155155  m_pcRDGoOnSbacCoder = pcEncTop->getRDGoOnSbacCoder();
    156  
     156
    157157  // create lambda and QP arrays
    158158  m_pdRdPicLambda     = (Double*)xMalloc( Double, m_pcCfg->getDeltaQpRD() * 2 + 1 );
     
    187187  Double dQP;
    188188  Double dLambda;
    189  
     189
    190190  rpcSlice = pcPic->getSlice(0);
    191191  rpcSlice->setSPS( pSPS );
     
    202202  rpcSlice->setPicOutputFlag( true );
    203203  rpcSlice->setPOC( pocCurr );
    204  
     204
    205205  // depth computation based on GOP size
    206206  Int depth;
     
    230230    }
    231231  }
    232  
     232
    233233  // slice type
    234234  SliceType eSliceType;
    235  
     235
    236236  eSliceType=B_SLICE;
    237237  eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
    238  
     238
    239239  rpcSlice->setSliceType    ( eSliceType );
    240  
     240
    241241  // ------------------------------------------------------------------------------------------------------------------
    242242  // Non-referenced frame marking
    243243  // ------------------------------------------------------------------------------------------------------------------
    244  
     244
    245245  if(pocLast == 0)
    246246  {
     
    252252  }
    253253  rpcSlice->setReferenced(true);
    254  
     254
    255255  // ------------------------------------------------------------------------------------------------------------------
    256256  // QP setting
    257257  // ------------------------------------------------------------------------------------------------------------------
    258  
     258
    259259  dQP = m_pcCfg->getQP();
    260260  if(eSliceType!=I_SLICE)
    261261  {
    262262#if REPN_FORMAT_IN_VPS
    263     if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless()))) 
    264 #else
    265     if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless()))) 
     263    if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless())))
     264#else
     265    if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless())))
    266266#endif
    267267    {
     
    269269    }
    270270  }
    271  
     271
    272272  // modify QP
    273273  Int* pdQPs = m_pcCfg->getdQPs();
     
    285285  // Lambda computation
    286286  // ------------------------------------------------------------------------------------------------------------------
    287  
     287
    288288  Int iQP;
    289289  Double dOrigQP = dQP;
     
    294294    // compute QP value
    295295    dQP = dOrigQP + ((iDQpIdx+1)>>1)*(iDQpIdx%2 ? -1 : 1);
    296    
     296
    297297    // compute lambda value
    298298    Int    NumberBFrames = ( m_pcCfg->getGOPSize() - 1 );
     
    326326#endif
    327327    }
    328    
     328
    329329    // if hadamard is used in ME process
    330330    if ( !m_pcCfg->getUseHADME() && rpcSlice->getSliceType( ) != I_SLICE )
     
    332332      dLambda *= 0.95;
    333333    }
    334    
     334
    335335#if REPN_FORMAT_IN_VPS
    336336    iQP = max( -rpcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
     
    343343    m_piRdPicQp    [iDQpIdx] = iQP;
    344344  }
    345  
     345
    346346  // obtain dQP = 0 case
    347347  dLambda = m_pdRdPicLambda[0];
    348348  dQP     = m_pdRdPicQp    [0];
    349349  iQP     = m_piRdPicQp    [0];
    350  
     350
    351351  if( rpcSlice->getSliceType( ) != I_SLICE )
    352352  {
     
    359359    Int nCurLayer = rpcSlice->getLayerId();
    360360    Double gamma = xCalEnhLambdaFactor( m_ppcTEncTop[nCurLayer-1]->getQP() - m_ppcTEncTop[nCurLayer]->getQP() ,
    361       1.0 * m_ppcTEncTop[nCurLayer]->getSourceWidth() * m_ppcTEncTop[nCurLayer]->getSourceHeight() 
     361      1.0 * m_ppcTEncTop[nCurLayer]->getSourceWidth() * m_ppcTEncTop[nCurLayer]->getSourceHeight()
    362362      / m_ppcTEncTop[nCurLayer-1]->getSourceWidth() / m_ppcTEncTop[nCurLayer-1]->getSourceHeight() );
    363363    dLambda *= gamma;
     
    392392#endif
    393393
    394 #if RDOQ_CHROMA_LAMBDA 
     394#if RDOQ_CHROMA_LAMBDA
    395395// for RDOQ
    396   m_pcTrQuant->setLambda( dLambda, dLambda / weight );   
     396  m_pcTrQuant->setLambda( dLambda, dLambda / weight );
    397397#else
    398398  m_pcTrQuant->setLambda( dLambda );
     
    401401#if SAO_CHROMA_LAMBDA
    402402// For SAO
    403   rpcSlice   ->setLambda( dLambda, dLambda / weight ); 
     403  rpcSlice   ->setLambda( dLambda, dLambda / weight );
    404404#else
    405405  rpcSlice   ->setLambda( dLambda );
    406406#endif
    407  
     407
    408408#if HB_LAMBDA_FOR_LDC
    409409  // restore original slice type
    410410  eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
    411  
     411
    412412#if SVC_EXTENSION
    413413  if(m_pcCfg->getLayerId() > 0)
     
    418418  rpcSlice->setSliceType        ( eSliceType );
    419419#endif
    420  
     420
    421421  if (m_pcCfg->getUseRecalculateQPAccordingToLambda())
    422422  {
    423423    dQP = xGetQPValueAccordingToLambda( dLambda );
    424424#if REPN_FORMAT_IN_VPS
    425     iQP = max( -rpcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );   
    426 #else
    427     iQP = max( -pSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );   
     425    iQP = max( -rpcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
     426#else
     427    iQP = max( -pSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
    428428#endif
    429429  }
     
    438438  rpcSlice->setNumRefIdx(REF_PIC_LIST_0,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
    439439  rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
    440  
     440
    441441  if ( m_pcCfg->getDeblockingFilterMetric() )
    442442  {
     
    479479
    480480  rpcSlice->setDepth            ( depth );
    481  
     481
    482482  pcPic->setTLayer( m_pcCfg->getGOPEntry(iGOPid).m_temporalId );
    483483#if TEMP_SCALABILITY_FIX
     
    493493  assert( m_apcPicYuvPred );
    494494  assert( m_apcPicYuvResi );
    495  
     495
    496496  pcPic->setPicYuvPred( m_apcPicYuvPred );
    497497  pcPic->setPicYuvResi( m_apcPicYuvResi );
     
    557557#endif
    558558
    559 #if RDOQ_CHROMA_LAMBDA 
     559#if RDOQ_CHROMA_LAMBDA
    560560  // for RDOQ
    561561  m_pcTrQuant->setLambda( lambda, lambda / weight );
     
    665665#endif
    666666
    667 #if RDOQ_CHROMA_LAMBDA 
     667#if RDOQ_CHROMA_LAMBDA
    668668  // for RDOQ
    669   m_pcTrQuant->setLambda( lambda, lambda / weight );   
     669  m_pcTrQuant->setLambda( lambda, lambda / weight );
    670670#else
    671671  m_pcTrQuant->setLambda( lambda );
     
    674674#if SAO_CHROMA_LAMBDA
    675675  // For SAO
    676   pcSlice   ->setLambda( lambda, lambda / weight ); 
     676  pcSlice   ->setLambda( lambda, lambda / weight );
    677677#else
    678678  pcSlice   ->setLambda( lambda );
     
    692692  Int iMaxSR = m_pcCfg->getSearchRange();
    693693  Int iNumPredDir = pcSlice->isInterP() ? 1 : 2;
    694  
     694
    695695  for (Int iDir = 0; iDir <= iNumPredDir; iDir++)
    696696  {
     
    726726  }
    727727#endif
    728  
     728
    729729  TComSlice* pcSlice        = rpcPic->getSlice(getSliceIdx());
    730730  Double     dPicRdCostBest = MAX_DOUBLE;
    731731  UInt       uiQpIdxBest = 0;
    732  
     732
    733733  Double dFrameLambda;
    734734#if FULL_NBIT
     
    737737  Int    SHIFT_QP = 12;
    738738#endif
    739  
     739
    740740  // set frame lambda
    741741  if (m_pcCfg->getGOPSize() > 1)
     
    748748  }
    749749  m_pcRdCost      ->setFrameLambda(dFrameLambda);
    750  
     750
    751751  // for each QP candidate
    752752  for ( UInt uiQpIdx = 0; uiQpIdx < 2 * m_pcCfg->getDeltaQpRD() + 1; uiQpIdx++ )
     
    776776#endif
    777777
    778 #if RDOQ_CHROMA_LAMBDA 
     778#if RDOQ_CHROMA_LAMBDA
    779779    // for RDOQ
    780780    m_pcTrQuant   ->setLambda( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight );
     
    784784#if SAO_CHROMA_LAMBDA
    785785    // For SAO
    786     pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight ); 
     786    pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight );
    787787#else
    788788    pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdx] );
    789789#endif
    790    
     790
    791791    // try compress
    792792    compressSlice   ( rpcPic );
    793    
     793
    794794    Double dPicRdCost;
    795795    UInt64 uiPicDist        = m_uiPicDist;
    796796    UInt64 uiALFBits        = 0;
    797    
     797
    798798    m_pcGOPEncoder->preLoopFilterPicAll( rpcPic, uiPicDist, uiALFBits );
    799    
     799
    800800    // compute RD cost and choose the best
    801801    dPicRdCost = m_pcRdCost->calcRdCost64( m_uiPicTotalBits + uiALFBits, uiPicDist, true, DF_SSE_FRAME);
    802    
     802
    803803    if ( dPicRdCost < dPicRdCostBest )
    804804    {
     
    807807    }
    808808  }
    809  
     809
    810810  // set best values
    811811  pcSlice       ->setSliceQp             ( m_piRdPicQp    [uiQpIdxBest] );
     
    832832#endif
    833833
    834 #if RDOQ_CHROMA_LAMBDA 
    835   // for RDOQ 
    836   m_pcTrQuant   ->setLambda( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight ); 
     834#if RDOQ_CHROMA_LAMBDA
     835  // for RDOQ
     836  m_pcTrQuant   ->setLambda( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight );
    837837#else
    838838  m_pcTrQuant   ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest] );
     
    840840#if SAO_CHROMA_LAMBDA
    841841  // For SAO
    842   pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight ); 
     842  pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight );
    843843#else
    844844  pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest] );
     
    862862
    863863  UInt uiEncCUOrder;
    864   uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); 
     864  uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
    865865  for( uiEncCUOrder = uiStartCUAddr/rpcPic->getNumPartInCU();
    866866       uiEncCUOrder < (uiBoundingCUAddr+(rpcPic->getNumPartInCU()-1))/rpcPic->getNumPartInCU();
     
    898898  TComSlice* pcSlice            = rpcPic->getSlice(getSliceIdx());
    899899  xDetermineStartAndBoundingCUAddr ( uiStartCUAddr, uiBoundingCUAddr, rpcPic, false );
    900  
     900
    901901  // initialize cost values
    902902  m_uiPicTotalBits  = 0;
    903903  m_dPicRdCost      = 0;
    904904  m_uiPicDist       = 0;
    905  
     905
    906906  // set entropy coder
    907907  if( m_pcCfg->getUseSBACRD() )
     
    921921    m_pcEntropyCoder->setBitstream    ( m_pcBitCounter );
    922922  }
    923  
     923
    924924  //------------------------------------------------------------------------------
    925925  //  Weighted Prediction parameters estimation.
     
    930930    xCalcACDCParamSlice(pcSlice);
    931931  }
     932#if O0194_WEIGHTED_PREDICTION_CGS
     933  else{
     934    // Calculate for the base layer to be used in EL as Inter layer reference
     935    xCalcACDCParamSlice(pcSlice);
     936    wpACDCParam * temp_weightACDCParam;
     937
     938    pcSlice->getWpAcDcParam(temp_weightACDCParam);
     939    g_refWeightACDCParam = (void *) temp_weightACDCParam;
     940  }
     941#endif
    932942
    933943  Bool bWp_explicit = (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPred());
     
    10211031        m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] );
    10221032        Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles();
    1023         uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); 
     1033        uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
    10241034        uiLin     = uiCUAddr / uiWidthInLCUs;
    10251035        uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(rpcPic->getPicSym()->getCUOrderMap(uiCUAddr))*iNumSubstreamsPerTile
     
    10981108          pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 );
    10991109        }
    1100         if ( ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 
     1110        if ( ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    11011111             (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) ||
    11021112             ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
     
    11371147      m_pcEntropyCoder->setEntropyCoder ( m_pcRDGoOnSbacCoder, pcSlice );
    11381148      m_pcEntropyCoder->setBitstream( &pcBitCounters[uiSubStrm] );
    1139      
     1149
    11401150      ((TEncBinCABAC*)m_pcRDGoOnSbacCoder->getEncBinIf())->setBinCountingEnableFlag(true);
    11411151
     
    12421252        m_pcRdCost->setLambda(oldLambda);
    12431253#if RATE_CONTROL_INTRA
    1244         m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, 
     1254        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
    12451255          pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
    12461256#else
     
    12501260#endif
    12511261#endif
    1252      
     1262
    12531263      // restore entropy coder to an initial stage
    12541264      m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST], pcSlice );
     
    12751285      {
    12761286         ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->load( m_pppcRDSbacCoder[0][CI_CURR_BEST] );
    1277        
     1287
    12781288         //Store probabilties of second LCU in line into buffer
    12791289         if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && m_pcCfg->getWaveFrontsynchro())
     
    13251335
    13261336#if RATE_CONTROL_INTRA
    1327         m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, 
     1337        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
    13281338          pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
    13291339#else
     
    13501360      }
    13511361    }
    1352    
     1362
    13531363    m_uiPicTotalBits += pcCU->getTotalBits();
    13541364    m_dPicRdCost     += pcCU->getTotalCost();
     
    14011411    m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder, pcSlice );
    14021412  }
    1403  
     1413
    14041414  m_pcCuEncoder->setBitCounter( NULL );
    14051415  m_pcBitCounter = NULL;
     
    14271437      m_pcBufferSbacCoders[ui].load(m_pcSbacCoder); //init. state
    14281438    }
    1429    
     1439
    14301440    for (Int iSubstrmIdx=0; iSubstrmIdx < iNumSubstreams; iSubstrmIdx++)
    14311441    {
     
    15241534        }
    15251535        if ( (true/*bEnforceSliceRestriction*/ &&
    1526              ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 
     1536             ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    15271537             (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) ||
    15281538             ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
     
    15791589    }
    15801590
    1581     TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );   
     1591    TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );
    15821592    if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) )
    15831593    {
     
    16131623        if (allowMergeLeft)
    16141624        {
    1615           m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeLeft); 
     1625          m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeLeft);
    16161626        }
    16171627        else
     
    16761686#if ENC_DEC_TRACE
    16771687    g_bJustDoIt = g_bEncDecTraceDisable;
    1678 #endif   
     1688#endif
    16791689    if( m_pcCfg->getUseSBACRD() )
    16801690    {
    16811691       pcSbacCoders[uiSubStrm].load(m_pcSbacCoder);   //load back status of the entropy coder after encoding the LCU into relevant bitstream entropy coder
    1682        
     1692
    16831693
    16841694       //Store probabilties of second LCU in line into buffer
     
    17331743  UInt uiNumberOfCUsInFrame = rpcPic->getNumCUsInFrame();
    17341744  uiBoundingCUAddrSlice     = uiNumberOfCUsInFrame;
    1735   if (bEncodeSlice) 
     1745  if (bEncodeSlice)
    17361746  {
    17371747    UInt uiCUAddrIncrement;
     
    17691779      uiBoundingCUAddrSlice    = uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();
    17701780      break;
    1771     } 
     1781    }
    17721782    // WPP: if a slice does not start at the beginning of a CTB row, it must end within the same CTB row
    17731783    if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU()) != 0))
     
    18091819      uiBoundingCUAddrSlice    = uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();
    18101820      break;
    1811     } 
     1821    }
    18121822    // WPP: if a slice does not start at the beginning of a CTB row, it must end within the same CTB row
    18131823    if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU()) != 0))
     
    18191829
    18201830  Bool tileBoundary = false;
    1821   if ((m_pcCfg->getSliceMode() == FIXED_NUMBER_OF_LCU || m_pcCfg->getSliceMode() == FIXED_NUMBER_OF_BYTES) && 
     1831  if ((m_pcCfg->getSliceMode() == FIXED_NUMBER_OF_LCU || m_pcCfg->getSliceMode() == FIXED_NUMBER_OF_BYTES) &&
    18221832      (m_pcCfg->getNumRowsMinus1() > 0 || m_pcCfg->getNumColumnsMinus1() > 0))
    18231833  {
     
    18321842    }
    18331843    tileBoundingCUAddrSlice = lcuEncAddr*rpcPic->getNumPartInCU();
    1834    
     1844
    18351845    if (tileBoundingCUAddrSlice < uiBoundingCUAddrSlice)
    18361846    {
     
    18451855  startCUAddrSliceSegment    = pcSlice->getSliceSegmentCurStartCUAddr();
    18461856  boundingCUAddrSliceSegment = uiNumberOfCUsInFrame;
    1847   if (bEncodeSlice) 
     1857  if (bEncodeSlice)
    18481858  {
    18491859    UInt uiCUAddrIncrement;
     
    18801890      boundingCUAddrSliceSegment    = uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();
    18811891      break;
    1882     } 
     1892    }
    18831893    // WPP: if a slice segment does not start at the beginning of a CTB row, it must end within the same CTB row
    18841894    if (pcSlice->getPPS()->getNumSubstreams() > 1 && (startCUAddrSliceSegment % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU()) != 0))
     
    19191929      boundingCUAddrSliceSegment    = uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();
    19201930      break;
    1921     } 
     1931    }
    19221932    // WPP: if a slice segment does not start at the beginning of a CTB row, it must end within the same CTB row
    19231933    if (pcSlice->getPPS()->getNumSubstreams() > 1 && (startCUAddrSliceSegment % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU()) != 0))
     
    19271937    pcSlice->setSliceSegmentCurEndCUAddr( boundingCUAddrSliceSegment );
    19281938  }
    1929   if ((m_pcCfg->getSliceSegmentMode() == FIXED_NUMBER_OF_LCU || m_pcCfg->getSliceSegmentMode() == FIXED_NUMBER_OF_BYTES) && 
     1939  if ((m_pcCfg->getSliceSegmentMode() == FIXED_NUMBER_OF_LCU || m_pcCfg->getSliceSegmentMode() == FIXED_NUMBER_OF_BYTES) &&
    19301940    (m_pcCfg->getNumRowsMinus1() > 0 || m_pcCfg->getNumColumnsMinus1() > 0))
    19311941  {
     
    19791989  }
    19801990  UInt uiRealStartAddress = rpcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*rpcPic->getNumPartInCU()+uiInternalAddress);
    1981  
     1991
    19821992  pcSlice->setSliceSegmentCurStartCUAddr(uiRealStartAddress);
    19831993  startCUAddrSliceSegment=uiRealStartAddress;
    1984  
     1994
    19851995  //calculate real slice start address
    19861996  uiInternalAddress = rpcPic->getPicSym()->getPicSCUAddr(pcSlice->getSliceCurStartCUAddr()) % rpcPic->getNumPartInCU();
     
    20072017  }
    20082018  uiRealStartAddress = rpcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*rpcPic->getNumPartInCU()+uiInternalAddress);
    2009  
     2019
    20102020  pcSlice->setSliceCurStartCUAddr(uiRealStartAddress);
    20112021  uiStartCUAddrSlice=uiRealStartAddress;
    2012  
     2022
    20132023  // Make a joint decision based on reconstruction and dependent slice bounds
    20142024  startCUAddr    = max(uiStartCUAddrSlice   , startCUAddrSliceSegment   );
     
    20222032    if ( (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU)
    20232033      || (m_pcCfg->getSliceMode()==0 && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU)
    2024       || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==0) 
     2034      || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==0)
    20252035      || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU)
    2026       || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==0) 
     2036      || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==0)
    20272037      || (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceMode()==0)
    20282038      || tileBoundary
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r460 r466  
    8888  m_bMFMEnabledFlag = false;
    8989#endif
     90#if SCALED_REF_LAYER_OFFSETS
    9091  m_numScaledRefLayerOffsets = 0;
     92#endif
     93#endif
    9194#if POC_RESET_FLAG
    9295  m_pocAdjustmentValue     = 0;
    9396#endif
    94 #endif //SVC_EXTENSION
    9597}
    9698
     
    173175    }
    174176  }
    175 
    176 #if LAYER_CTB
    177   memcpy(g_auiLayerZscanToRaster[m_layerId], g_auiZscanToRaster, sizeof( g_auiZscanToRaster ) );
    178   memcpy(g_auiLayerRasterToZscan[m_layerId], g_auiRasterToZscan, sizeof( g_auiRasterToZscan ) );
    179   memcpy(g_auiLayerRasterToPelX[m_layerId],  g_auiRasterToPelX,  sizeof( g_auiRasterToPelX ) );
    180   memcpy(g_auiLayerRasterToPelY[m_layerId],  g_auiRasterToPelY,  sizeof( g_auiRasterToPelY ) );
    181 #endif
    182177}
    183178
     
    876871#if SVC_EXTENSION
    877872  m_cSPS.setLayerId(m_layerId);
     873#endif
    878874#if REF_IDX_MFM
    879875#if !M0457_COL_PICTURE_SIGNALING
     
    881877#endif
    882878#endif
     879#if SCALED_REF_LAYER_OFFSETS
    883880  m_cSPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets);
    884881  for(Int i = 0; i < m_cSPS.getNumScaledRefLayerOffsets(); i++)
     
    886883    m_cSPS.getScaledRefLayerWindow(i) = m_scaledRefLayerWindow[i];
    887884  }
    888 #endif //SVC_EXTENSION
     885#endif
    889886  ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
    890887  profileTierLevel.setLevelIdc(m_level);
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncTop.h

    r460 r466  
    140140  Int                     m_ilSampleOnlyPred;
    141141#endif
     142#if SCALED_REF_LAYER_OFFSETS
    142143  UInt                    m_numScaledRefLayerOffsets;
    143144  Window                  m_scaledRefLayerWindow[MAX_LAYERS];
     145#endif
    144146#if POC_RESET_FLAG
    145147  Int                     m_pocAdjustmentValue;
    146148#endif
    147 #endif //SVC_EXTENSION
     149#endif
    148150protected:
    149151  Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
     
    207209  Int                     getNumPicRcvd         () { return m_iNumPicRcvd;            }
    208210  Void                    setNumPicRcvd         ( Int num ) { m_iNumPicRcvd = num;      }
     211#if SCALED_REF_LAYER_OFFSETS
    209212  Void                    setNumScaledRefLayerOffsets(Int x) { m_numScaledRefLayerOffsets = x; }
    210213  UInt                    getNumScaledRefLayerOffsets() { return m_numScaledRefLayerOffsets; }
    211214  Window&  getScaledRefLayerWindow(Int x)            { return m_scaledRefLayerWindow[x]; }
    212 #endif //SVC_EXTENSION
     215#endif
     216#endif
    213217
    214218  // -------------------------------------------------------------------------------------------------------------------
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/WeightPredAnalysis.cpp

    r313 r466  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2013, ITU/ISO/IEC
     
    5151  for ( Int iList =0 ; iList<2 ; iList++ )
    5252  {
    53     for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 
     53    for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )
    5454    {
    5555      for ( Int comp=0 ; comp<3 ;comp++ )
     
    7474  TComPicYuv*   pPic = slice->getPic()->getPicYuvOrg();
    7575  Int   iSample  = 0;
     76#if O0194_WEIGHTED_PREDICTION_CGS
     77  // Define here to assign the parameter of "iSample"
     78  wpACDCParam weightACDCParam[3];
     79#endif
    7680
    7781  // calculate DC/AC value for Y
     
    8185  pOrg = pPic->getLumaAddr();
    8286  Int64  iOrgACY  = xCalcACValueSlice(slice, pOrg, iOrgNormDCY);
     87#if O0194_WEIGHTED_PREDICTION_CGS
     88  weightACDCParam[0].iSamples = iSample;
     89#endif
    8390
    8491  // calculate DC/AC value for Cb
     
    8895  pOrg = pPic->getCbAddr();
    8996  Int64  iOrgACCb  = xCalcACValueUVSlice(slice, pOrg, iOrgNormDCCb);
     97#if O0194_WEIGHTED_PREDICTION_CGS
     98  weightACDCParam[1].iSamples = iSample;
     99#endif
    90100
    91101  // calculate DC/AC value for Cr
     
    95105  pOrg = pPic->getCrAddr();
    96106  Int64  iOrgACCr  = xCalcACValueUVSlice(slice, pOrg, iOrgNormDCCr);
    97 
     107#if O0194_WEIGHTED_PREDICTION_CGS
     108  weightACDCParam[2].iSamples = iSample;
     109#endif
     110
     111#if !O0194_WEIGHTED_PREDICTION_CGS
    98112  wpACDCParam weightACDCParam[3];
     113#endif
    99114  weightACDCParam[0].iAC = iOrgACY;
    100115  weightACDCParam[0].iDC = iOrgNormDCY;
     
    138153  for ( Int iList=0 ; iList<2 ; iList++ )
    139154  {
    140     for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 
    141     {
    142       for ( Int iComp=0 ; iComp<3 ;iComp++ ) 
     155    for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )
     156    {
     157      for ( Int iComp=0 ; iComp<3 ;iComp++ )
    143158      {
    144159        wpScalingParam  *pwp = &(m_wp[iList][iRefIdx][iComp]);
     
    154169    for ( Int iList=0 ; iList<2 ; iList++ )
    155170    {
    156       for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 
     171      for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )
    157172      {
    158         for ( Int iComp=0 ; iComp<3 ;iComp++ ) 
     173        for ( Int iComp=0 ; iComp<3 ;iComp++ )
    159174        {
    160175          wpScalingParam  *pwp = &(m_wp[iList][iRefIdx][iComp]);
     
    195210  // selecting whether WP is used, or not
    196211  xSelectWP(slice, m_wp, iDenom);
    197  
     212
    198213  slice->setWpScaling( m_wp );
    199214
     
    216231      slice->getWpAcDcParam(currWeightACDCParam);
    217232      slice->getRefPic(eRefPicList, refIdxTemp)->getSlice(0)->getWpAcDcParam(refWeightACDCParam);
     233#if O0194_WEIGHTED_PREDICTION_CGS
     234      if (slice->getRefPic(eRefPicList, refIdxTemp)->isILR(1)){
     235        refWeightACDCParam = (wpACDCParam *)g_refWeightACDCParam;
     236      }
     237#endif
    218238
    219239      for ( Int comp = 0; comp < 3; comp++ )
     
    229249        Int64 refDC = refWeightACDCParam[comp].iDC;
    230250        Int64 refAC = refWeightACDCParam[comp].iAC;
     251#if O0194_WEIGHTED_PREDICTION_CGS
     252        if (slice->getRefPic(eRefPicList, refIdxTemp)->isILR(1)){
     253          refAC *= (double)currWeightACDCParam[comp].iSamples/refWeightACDCParam[comp].iSamples;
     254#if O0194_JOINT_US_BITSHIFT
     255          refAC *= (1<<(g_bitDepthYLayer[1]-g_bitDepthYLayer[0]));
     256          refDC *= (1<<(g_bitDepthYLayer[1]-g_bitDepthYLayer[0]));
     257#endif
     258         }
     259#endif
    231260
    232261        // calculating iWeight and iOffset params
     
    234263        Int weight = (Int)( 0.5 + dWeight * (Double)(1<<log2Denom) );
    235264        Int offset = (Int)( ((currDC<<log2Denom) - ((Int64)weight * refDC) + (Int64)realOffset) >> realLog2Denom );
     265#if O0194_WEIGHTED_PREDICTION_CGS
     266        if (slice->getRefPic(eRefPicList, refIdxTemp)->isILR(1)){
     267        }
     268        else{
     269          dWeight = 1;
     270          offset  = 0;
     271        }
     272        weight = (Int)( 0.5 + dWeight * (Double)(1<<log2Denom) );
     273#endif
    236274
    237275        // Chroma offset range limitation
     
    253291        if(deltaWeight > 127 || deltaWeight < -128)
    254292          return (false);
     293#if O0194_WEIGHTED_PREDICTION_CGS
     294        // make sure the reference frames other than ILR are not using weighted prediction
     295        if (!(slice->getRefPic(eRefPicList, refIdxTemp)->isILR(1))){
     296          continue;
     297        }
     298#endif
    255299
    256300        m_wp[refList][refIdxTemp][comp].bPresentFlag = true;
     
    264308}
    265309
    266 /** select whether weighted pred enables or not. 
     310/** select whether weighted pred enables or not.
    267311 * \param TComSlice *slice
    268312 * \param wpScalingParam
     
    325369}
    326370
    327 /** calculate DC value of original image for luma. 
     371/** calculate DC value of original image for luma.
    328372 * \param TComSlice *slice
    329373 * \param Pel *pPel
     
    345389}
    346390
    347 /** calculate AC value of original image for luma. 
     391/** calculate AC value of original image for luma.
    348392 * \param TComSlice *slice
    349393 * \param Pel *pPel
     
    363407}
    364408
    365 /** calculate DC value of original image for chroma. 
     409/** calculate DC value of original image for chroma.
    366410 * \param TComSlice *slice
    367411 * \param Pel *pPel
     
    383427}
    384428
    385 /** calculate AC value of original image for chroma. 
     429/** calculate AC value of original image for chroma.
    386430 * \param TComSlice *slice
    387431 * \param Pel *pPel
     
    401445}
    402446
    403 /** calculate DC value. 
     447/** calculate DC value.
    404448 * \param Pel *pPel
    405449 * \param Int iWidth
     
    423467}
    424468
    425 /** calculate AC value. 
     469/** calculate AC value.
    426470 * \param Pel *pPel
    427471 * \param Int iWidth
     
    446490}
    447491
    448 /** calculate SAD values for both WP version and non-WP version. 
     492/** calculate SAD values for both WP version and non-WP version.
    449493 * \param Pel *pOrgPel
    450494 * \param Pel *pRefPel
Note: See TracChangeset for help on using the changeset viewer.