Changeset 100 in 3DVCSoftware


Ignore:
Timestamp:
9 Aug 2012, 12:53:16 (12 years ago)
Author:
tech
Message:

Adopted modifications:

  • disparity vector generation (A0097)
  • inter-view motion prediction modification (A0049)
  • simplification of disparity vector derivation (A0126)
  • region boundary chain coding (A0070)
  • residual skip intra (A0087)
  • VSO modification (A0033/A0093)

+ Clean ups + Bug fixes

Update of cfg files (A0033 modification 2)

Location:
trunk
Files:
70 edited

Legend:

Unmodified
Added
Removed
  • trunk/CommonTestConditionsCfgs/baseCfg_2view+depth.cfg

    r78 r100  
    204204
    205205#========== view synthesis optimization (VSO) ==========
    206 VSOConfig                 : [cx0 B(cc1) I(s0.5)][cx1 B(oo0) I(s0.5)]  # VSO configuration string
    207 
     206VSOConfig                 : [cx0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) I(s0.25 s0.5 s0.75)]  # VSO configuration string
    208207
    209208#============ Misc. ================
  • trunk/CommonTestConditionsCfgs/baseCfg_3view+depth.cfg

    r78 r100  
    208208
    209209#========== view synthesis optimization (VSO) ==========
    210 VSOConfig                 : [cx0 B(cc1) I(s0.5)][cx1 B(oo0) B(oo2) I(s0.5 s1.5)][cx2 B(cc1) I(s1.5)] # VSO configuration string
    211 #VSOConfig                    : [cx0 B(cc1) I(s0.5)][cx1 B(oo0) I(s0.5)]                                  #VSO Configuration (2-View) coding order 1 0
    212 
     210VSOConfig                 : [cx0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) B(oo2) I(s0.25 s0.5 s0.75 s1.125 s1.5 s1.75)][cx2 B(cc1) I(s1.25 s1.5 s1.75)] # VSO configuration string
    213211#============ Misc. ================
    214212SEIpictureDigest          : 0                                      # Control generation of picture_digest SEI messages
  • trunk/cfg/encoder_mvd.cfg

    r78 r100  
    207207
    208208#========== view synthesis optimization (VSO) ==========
    209 VSOConfig                 : [cx0 B(cc1) I(s0.5)][cx1 B(oo0) B(oo2) I(s0.5 s1.5)][cx2 B(cc1) I(s1.5)] # VSO configuration string
     209VSOConfig                 : [cx0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) B(oo2) I(s0.25 s0.5 s0.75 s1.125 s1.5 s1.75)][cx2 B(cc1) I(s1.25 s1.5 s1.75)] # VSO configuration string (3 view)
     210VSOConfig                 : [cx0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0)        I(s0.25 s0.5 s0.75)]                                                   # VSO configuration string (2 view)
    210211
    211212
  • trunk/source/App/TAppDecoder/TAppDecCfg.cpp

    r56 r100  
    115115  size_t iAppendLength = strlen(pchStringToAppend);
    116116
    117   rpchOutputFileName = (Char*) malloc(iInLength+iAppendLength+1);                                                                                               
    118   Char* pCDot = strrchr(pchInputFileName,'.');                          
    119   pCDot = pCDot ? pCDot : pchInputFileName + iInLength;                         
     117  rpchOutputFileName = (Char*) malloc(iInLength+iAppendLength+1);                       
     118  Char* pCDot = strrchr(pchInputFileName,'.');        
     119  pCDot = pCDot ? pCDot : pchInputFileName + iInLength;       
    120120  size_t iCharsToDot = pCDot - pchInputFileName ;
    121   size_t iCharsToEnd = iInLength - iCharsToDot;                                
     121  size_t iCharsToEnd = iInLength - iCharsToDot;        
    122122  strncpy(rpchOutputFileName                            ,  pchInputFileName            , iCharsToDot  );
    123123  strncpy(rpchOutputFileName+ iCharsToDot               ,  pchStringToAppend           , iAppendLength);
    124   strncpy(rpchOutputFileName+ iCharsToDot+iAppendLength ,  pchInputFileName+iCharsToDot, iCharsToEnd  );                               
    125   rpchOutputFileName[iInLength+iAppendLength] = '\0';                          
     124  strncpy(rpchOutputFileName+ iCharsToDot+iAppendLength ,  pchInputFileName+iCharsToDot, iCharsToEnd  );       
     125  rpchOutputFileName[iInLength+iAppendLength] = '\0';        
    126126}
    127127
  • trunk/source/App/TAppDecoder/TAppDecTop.h

    r77 r100  
    8989  Void  decode            (); ///< main decoding function
    9090#if VIDYO_VPS_INTEGRATION
    91   Void  increaseNumberOfViews   (UInt layerId, UInt viewId, UInt isDepth);
     91  Void  increaseNumberOfViews  (UInt layerId, UInt viewId, UInt isDepth);
    9292#else
    93   Void  increaseNumberOfViews   (Int newNumberOfViewDepth);
     93  Void  increaseNumberOfViews  (Int newNumberOfViewDepth);
    9494#endif
    9595  TDecTop* getTDecTop     ( Int viewId, Bool isDepth );
  • trunk/source/App/TAppEncoder/TAppEncCfg.cpp

    r58 r100  
    7474{
    7575  m_aidQP = NULL;
     76#if FIXES
     77  m_aidQPdepth = NULL;
     78#endif
    7679}
    7780
     
    8285    delete[] m_aidQP; m_aidQP = NULL;
    8386  }
     87
     88#if FIXES
     89  if ( m_aidQPdepth )
     90  {
     91    delete[] m_aidQPdepth; m_aidQPdepth = NULL;
     92  }
     93#endif
     94
    8495  for(Int i = 0; i< m_pchInputFileList.size(); i++ )
    8596  {
     
    306317#if HHI_VSO
    307318  ("VSOConfig",                       m_pchVSOConfig            , (Char *) 0    , "VSO configuration")
    308     ("VSO",                             m_bUseVSO                 , false         , "Use VSO" )
    309     // GT: For development, will be removed later
     319  ("VSO",                             m_bUseVSO                 , false         , "Use VSO" )   
    310320  ("VSOMode",                         m_uiVSOMode               , (UInt)   4    , "VSO Mode")
     321  ("LambdaScaleVSO",                  m_dLambdaScaleVSO         , (Double) 1    , "Lambda Scaling for VSO")
     322
    311323#if HHI_VSO_LS_TABLE
    312   ("LambdaScaleVSO",                  m_dLambdaScaleVSO         , (Double) 1  , "Lambda Scaling for VSO")
    313 #else
    314   ("LambdaScaleVSO",                  m_dLambdaScaleVSO         , (Double) 0.5  , "Lambda Scaling for VSO")
    315 #endif
    316     ("ForceLambdaScaleVSO",             m_bForceLambdaScaleVSO    , false         , "Force using Lambda Scale VSO also in non-VSO-Mode")
     324  ("VSOLSTable",                      m_bVSOLSTable             , true          , "Depth QP dependent video/depth rate allocation by Lagrange multiplier" )   
     325#endif
     326
     327#if SAIT_VSO_EST_A0033
     328  ("UseEstimatedVSD",                 m_bUseEstimatedVSD        , true          , "Model based VSD estimation instead of rendering based for some encoder decisions" )     
     329#endif
     330#if LGE_VSO_EARLY_SKIP_A0093
     331  ("VSOEarlySkip",                    m_bVSOEarlySkip           , true          , "Early skip of VSO computation if synthesis error assumed to be zero" )     
     332#endif
     333  ("ForceLambdaScaleVSO",             m_bForceLambdaScaleVSO    , false         , "Force using Lambda Scale VSO also in non-VSO-Mode")
    317334#if HHI_VSO_DIST_INT
    318   ("AllowNegDist",                    m_bAllowNegDist           , true         , "Allow negative Distortion in VSO")
     335  ("AllowNegDist",                    m_bAllowNegDist           , true          , "Allow negative Distortion in VSO")
    319336#endif
    320337
     
    667684     0.753550, 0.800000 
    668685  };
    669   AOT( (m_aiQP[1] < 0) || (m_aiQP[1] > 51));
    670   m_dLambdaScaleVSO *= adLambdaScaleTable[m_aiQP[1]];
     686  if ( m_bVSOLSTable )
     687  {
     688    AOT( (m_aiQP[1] < 0) || (m_aiQP[1] > 51));
     689    m_dLambdaScaleVSO *= adLambdaScaleTable[m_aiQP[1]];
     690  }
    671691#endif
    672692#endif
     
    15621582    printf("VSO Negative Distortion      : %d\n",    m_bAllowNegDist ? 1 : 0);
    15631583#endif
     1584#if HHI_VSO_LS_TABLE
     1585    printf("VSO LS Table                 : %d\n",    m_bVSOLSTable ? 1 : 0);   
     1586#endif
     1587#if SAIT_VSO_EST_A0033
     1588    printf("VSO Estimated VSD            : %d\n",    m_bUseEstimatedVSD ? 1 : 0);       
     1589#endif
     1590#if LGE_VSO_EARLY_SKIP_A0093
     1591    printf("VSO Early Skip               : %d\n",    m_bVSOEarlySkip ? 1 : 0);   
     1592#endif
     1593   
    15641594  }
    15651595#endif
     
    16581688#if HHI_VSO
    16591689  printf("VSO:%d ", m_bUseVSO             );
    1660 #endif
     1690#endif 
    16611691#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    16621692  printf("DMM:%d ", m_bUseDMM );
  • trunk/source/App/TAppEncoder/TAppEncCfg.h

    r56 r100  
    216216#endif
    217217#if HHI_INTER_VIEW_RESIDUAL_PRED
    218   UInt      m_uiMultiviewResPredMode;                         ///< using multiview residual prediction
     218  UInt      m_uiMultiviewResPredMode;          ///< using multiview residual prediction
    219219#endif
    220220
    221221#if FAST_DECISION_FOR_MRG_RD_COST
    222   Bool      m_useFastDecisionForMerge;                        ///< flag for using Fast Decision Merge RD-Cost
    223 #endif
    224   Bool      m_bUseCbfFastMode;                              ///< flag for using Cbf Fast PU Mode Decision
    225   Int       m_iSliceMode;           ///< 0: Disable all Recon slice limits, 1 : Maximum number of largest coding units per slice, 2: Maximum number of bytes in a slice
    226   Int       m_iSliceArgument;       ///< If m_iSliceMode==1, m_iSliceArgument=max. # of largest coding units. If m_iSliceMode==2, m_iSliceArgument=max. # of bytes.
    227   Int       m_iEntropySliceMode;    ///< 0: Disable all entropy slice limits, 1 : Maximum number of largest coding units per slice, 2: Constraint based entropy slice
    228   Int       m_iEntropySliceArgument;///< If m_iEntropySliceMode==1, m_iEntropySliceArgument=max. # of largest coding units. If m_iEntropySliceMode==2, m_iEntropySliceArgument=max. # of bins.
    229 
    230   Int       m_iSliceGranularity;///< 0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.
    231   Bool m_bLFCrossSliceBoundaryFlag;  ///< 0: Cross-slice-boundary in-loop filtering 1: non-cross-slice-boundary in-loop filtering
    232   Int  m_iTileBehaviorControlPresentFlag; //!< 1: tile behavior control parameters are in PPS 0: tile behavior control parameters are not in PPS
    233   Bool m_bLFCrossTileBoundaryFlag;  //!< 1: Cross-tile-boundary in-loop filtering 0: non-cross-tile-boundary in-loop filtering
     222  Bool      m_useFastDecisionForMerge;         ///< flag for using Fast Decision Merge RD-Cost
     223#endif
     224  Bool      m_bUseCbfFastMode;                 ///< flag for using Cbf Fast PU Mode Decision
     225  Int       m_iSliceMode;                      ///< 0: Disable all Recon slice limits, 1 : Maximum number of largest coding units per slice, 2: Maximum number of bytes in a slice
     226  Int       m_iSliceArgument;                  ///< If m_iSliceMode==1, m_iSliceArgument=max. # of largest coding units. If m_iSliceMode==2, m_iSliceArgument=max. # of bytes.
     227  Int       m_iEntropySliceMode;               ///< 0: Disable all entropy slice limits, 1 : Maximum number of largest coding units per slice, 2: Constraint based entropy slice
     228  Int       m_iEntropySliceArgument;           ///< If m_iEntropySliceMode==1, m_iEntropySliceArgument=max. # of largest coding units. If m_iEntropySliceMode==2, m_iEntropySliceArgument=max. # of bins.
     229
     230  Int       m_iSliceGranularity;               ///< 0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.
     231  Bool      m_bLFCrossSliceBoundaryFlag;       ///< 0: Cross-slice-boundary in-loop filtering 1: non-cross-slice-boundary in-loop filtering
     232  Int       m_iTileBehaviorControlPresentFlag; //!< 1: tile behavior control parameters are in PPS 0: tile behavior control parameters are not in PPS
     233  Bool      m_bLFCrossTileBoundaryFlag;        //!< 1: Cross-tile-boundary in-loop filtering 0: non-cross-tile-boundary in-loop filtering
    234234  Int       m_iColumnRowInfoPresent;
    235235  Int       m_iUniformSpacingIdr;
     
    280280  Char*     m_pchVSOConfig;
    281281  Bool      m_bUseVSO;                                    ///< flag for using View Synthesis Optimization
    282 
     282#if HHI_VSO_LS_TABLE
     283  Bool      m_bVSOLSTable;                                ///< Depth QP dependent Lagrange parameter optimization (m23714)
     284#endif
     285#if LGE_VSO_EARLY_SKIP_A0093
     286  Bool      m_bVSOEarlySkip;                              ///< Early skip of VSO computation (JCT3V-A0093 modification 4)
     287#endif
    283288  //// Used for development by GT, might be removed later
    284289  Double    m_dLambdaScaleVSO;                            ///< Scaling factor for Lambda in VSO mode
     
    289294  UInt      m_uiVSOMode;                                  ///< Number of VSO Mode, 1 = , 2 = simple, org vs. ren, 3 = simple, ren vs. ren, 4 = full 
    290295#endif
     296#if SAIT_VSO_EST_A0033
     297  Bool      m_bUseEstimatedVSD;                           ///< Flag for using model based VSD estimation instead of VSO for some encoder decisions (JCT3V-A0033 modification 3)
     298  Double    m_dDispCoeff;
     299#endif
    291300
    292301  // coding tools (depth intra modes)
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r77 r100  
    203203    m_acTEncTopList[iViewIdx]->setLambdaScaleVSO               ( 1     );
    204204    m_acTEncTopList[iViewIdx]->setVSOMode                      ( 0     );
    205     m_acTEncTopList[iViewIdx]->setUseVSO                       ( false ); //GT: might be enabled later for VSO Mode 4
     205    m_acTEncTopList[iViewIdx]->setUseVSO                       ( false );
     206#if SAIT_VSO_EST_A0033
     207    m_acTEncTopList[iViewIdx]->setUseEstimatedVSD              ( false );
     208#endif
    206209#endif
    207210
     
    517520#endif
    518521      m_acTEncDepthTopList[iViewIdx]->setVSOMode                      ( m_uiVSOMode );
     522
     523#if SAIT_VSO_EST_A0033
     524      m_acTEncDepthTopList[iViewIdx]->setUseEstimatedVSD              ( m_bUseEstimatedVSD );
     525#endif
    519526#endif
    520527
     
    648655    if ( m_uiVSOMode == 4 )
    649656    {
     657#if HHI_VSO_SPEEDUP_A033
     658#if LGE_VSO_EARLY_SKIP_A0093
     659      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip );
     660#else
     661      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 );
     662#endif
     663#else
    650664      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, LOG2_DISP_PREC_LUT, 0 );
     665#endif
    651666
    652667      for ( Int iViewNum = 0; iViewNum < m_iNumberOfViews; iViewNum++ )
     
    11411156};
    11421157
     1158#if SAIT_VSO_EST_A0033
     1159TComPicYuv* TAppEncTop::xGetPicYuvFromViewTemp( Int iViewIdx, Int iPoc, Bool bDepth, Bool bRecon )
     1160{
     1161  TComPic*    pcPic = xGetPicFromView( iViewIdx, iPoc, bDepth);
     1162  TComPicYuv* pcPicYuv = NULL;
     1163
     1164  if (pcPic != NULL)
     1165  {
     1166    if( bRecon )
     1167    {
     1168      if ( pcPic->getReconMark() )
     1169      {
     1170        pcPicYuv = pcPic->getPicYuvRec();
     1171      }
     1172    }
     1173    else
     1174    {
     1175      pcPicYuv = pcPic->getPicYuvOrg();
     1176    }
     1177  };
     1178
     1179  return pcPicYuv;
     1180};
     1181#endif
     1182
    11431183/**
    11441184 *
     
    12091249#endif
    12101250#if HHI_VSO
     1251#if HHI_VSO_SPEEDUP_A033
     1252Void TAppEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset )
     1253{
     1254  m_cRendererModel.setHorOffset( iHorOffset );
     1255#else
    12111256Void TAppEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent )
    12121257{
     1258#endif
    12131259  Int iEncViewSIdx = m_cCameraData.getBaseId2SortedId()[ iEncViewIdx ];
    12141260
  • trunk/source/App/TAppEncoder/TAppEncTop.h

    r77 r100  
    6363private:
    6464  // class interface
    65   std::vector<TEncTop*>                           m_acTEncTopList ;
    66   std::vector<TEncTop*>                           m_acTEncDepthTopList ;
    67   std::vector<TVideoIOYuv*>             m_acTVideoIOYuvInputFileList;  ///< input YUV file
     65  std::vector<TEncTop*>      m_acTEncTopList ;
     66  std::vector<TEncTop*>      m_acTEncDepthTopList ;
     67  std::vector<TVideoIOYuv*>  m_acTVideoIOYuvInputFileList;  ///< input YUV file
    6868  std::vector<TVideoIOYuv*>  m_acTVideoIOYuvDepthInputFileList;
    69   std::vector<TVideoIOYuv*>             m_acTVideoIOYuvReconFileList;  ///< output reconstruction file
     69  std::vector<TVideoIOYuv*>  m_acTVideoIOYuvReconFileList;  ///< output reconstruction file
    7070  std::vector<TVideoIOYuv*>  m_acTVideoIOYuvDepthReconFileList;
    7171
     
    7373  std::vector< TComList<TComPicYuv*>* >  m_picYuvDepthRec;         
    7474
    75   std::vector<Int>              m_frameRcvd;                  ///< number of received frames
    76   std::vector<Int>              m_depthFrameRcvd;   
     75  std::vector<Int>           m_frameRcvd;                  ///< number of received frames
     76  std::vector<Int>           m_depthFrameRcvd;   
    7777
    7878  unsigned                   m_essentialBytes;
     
    124124  virtual ~TAppEncTop();
    125125 
     126#if SAIT_VSO_EST_A0033
     127  TComPicYuv* xGetPicYuvFromViewTemp( Int iViewIdx, Int iPoc, Bool bDepth, Bool bRecon );
     128#endif
     129
    126130  Void        encode      ();                               ///< main encoding function
    127131  TEncTop*    getTEncTop( Int viewId, Bool isDepth );   
     
    135139#endif
    136140#if HHI_VSO
     141#if HHI_VSO_SPEEDUP_A033
     142  Void                  setupRenModel    ( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset );
     143#else
    137144  Void                  setupRenModel    ( Int iPoc, Int iEncViewIdx, Int iEncContent );
     145#endif
    138146#endif
    139147 
  • trunk/source/App/TAppRenderer/RendererMain.cpp

    r56 r100  
    4242
    4343int main(int argc, char* argv[])
    44         {
     44  {
    4545  TAppRendererTop  cTAppRendererTop;
    4646
  • trunk/source/App/TAppRenderer/TAppRendererCfg.cpp

    r56 r100  
    5353// ====================================================================================================================
    5454
    55 #define MAX_INPUT_VIEW_NUM                                      10
     55#define MAX_INPUT_VIEW_NUM          10
    5656#define MAX_OUTPUT_VIEW_NUM         64
    5757
  • trunk/source/App/TAppRenderer/TAppRendererCfg.h

    r56 r100  
    8080  ////camera specification ////
    8181  Char*               m_pchCameraParameterFile;         ///< camera parameter file
    82   Char*               m_pchSynthViewCameraNumbers;            ///< numbers of views to synthesize
     82  Char*               m_pchSynthViewCameraNumbers;      ///< numbers of views to synthesize
    8383  Char*               m_pchViewConfig;                  ///< String to setup renderer
    84   Char*               m_pchBaseViewCameraNumbers;             ///< numbers of base views
     84  Char*               m_pchBaseViewCameraNumbers;       ///< numbers of base views
    8585
    8686  // derived
     
    8989  Bool                m_bUseSetupString;                ///< true if setup string is used
    9090
    91   Int                 m_iNumberOfInputViews;                                            ///< number of input Views
    92   Int                 m_iNumberOfOutputViews;                                           ///< number views to synthesize
     91  Int                 m_iNumberOfInputViews;            ///< number of input Views
     92  Int                 m_iNumberOfOutputViews;           ///< number views to synthesize
    9393
    9494  //// renderer Modes ////
    95   Int                 m_iRenderDirection;                  ///< 0: interpolate, 1: extrapolate from left, 2: extrapolate from right
     95  Int                 m_iRenderDirection;               ///< 0: interpolate, 1: extrapolate from left, 2: extrapolate from right
    9696
    9797  Int                 m_iLog2SamplingFactor;            ///< factor for horizontal upsampling before processing
  • trunk/source/App/TAppRenderer/TAppRendererTop.cpp

    r81 r100  
    7070    pcVideoInput->open( m_pchVideoInputFileList[iViewIdx], false, iFileBitDepth, iInteralBitDepth );  // read mode
    7171    pcDepthInput->open( m_pchDepthInputFileList[iViewIdx], false, iFileBitDepth, iInteralBitDepth );  // read mode
    72 #if HHI_FIX
    7372    pcVideoInput->skipFrames(m_iFrameSkip, m_iSourceWidth, m_iSourceHeight  );
    7473    pcDepthInput->skipFrames(m_iFrameSkip, m_iSourceWidth, m_iSourceHeight  );
    75 #endif
     74
    7675    m_apcTVideoIOYuvVideoInput.push_back( pcVideoInput );
    7776    m_apcTVideoIOYuvDepthInput.push_back( pcDepthInput );
     
    186185  while ( ( ( iNumOfRenderedFrames < m_iFramesToBeRendered ) || ( m_iFramesToBeRendered == 0 ) ) && !bAnyEOS )
    187186  {
    188 
    189 #if HHI_FIX
    190187    if ( iFrame >= m_iFrameSkip )
    191188    {
    192 #endif
    193     // read in depth and video
    194     for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    195     {
    196       m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad  ) ;
    197 
    198       apcPicYuvBaseVideo[iBaseViewIdx]->extendPicBorder();
    199 
    200       bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof();
    201 
    202       m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad  ) ;
    203       apcPicYuvBaseDepth[iBaseViewIdx]->extendPicBorder();
    204       bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof();
    205 
    206       if ( m_bTempDepthFilter && (iFrame >= m_iFrameSkip) )
     189      // read in depth and video
     190      for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    207191      {
    208         m_pcRenTop->temporalFilterVSRS( apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], apcPicYuvLastBaseVideo[iBaseViewIdx], apcPicYuvLastBaseDepth[iBaseViewIdx], ( iFrame == m_iFrameSkip) );
     192        m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad  ) ;
     193
     194        apcPicYuvBaseVideo[iBaseViewIdx]->extendPicBorder();
     195
     196        bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof();
     197
     198        m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad  ) ;
     199        apcPicYuvBaseDepth[iBaseViewIdx]->extendPicBorder();
     200        bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof();
     201
     202        if ( m_bTempDepthFilter && (iFrame >= m_iFrameSkip) )
     203        {
     204          m_pcRenTop->temporalFilterVSRS( apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], apcPicYuvLastBaseVideo[iBaseViewIdx], apcPicYuvLastBaseDepth[iBaseViewIdx], ( iFrame == m_iFrameSkip) );
     205        }
    209206      }
    210207    }
    211 
    212 #if HHI_FIX
    213     }
    214     else
    215 #else
    216     if ( iFrame < m_iFrameSkip ) // Skip Frames
    217 #endif
    218    
     208    else   
    219209    {
    220210      std::cout << "Skipping Frame " << iFrame << std::endl;
     
    536526
    537527    AOT( m_iLog2SamplingFactor != 0 );
     528#if LGE_VSO_EARLY_SKIP_A0093
     529    cCurModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin, false );
     530#else
    538531    cCurModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin );
     532#endif
     533
     534#if HHI_VSO_SPEEDUP_A033
     535    cCurModel.setHorOffset( 0 );
     536#endif
    539537
    540538    for ( Int iViewIdx = 0; iViewIdx < m_iNumberOfInputViews; iViewIdx++ )
     
    563561    {
    564562
    565 #if HHI_FIX
    566563      if ( iFrame >= m_iFrameSkip )
    567564      {     
    568 #endif
    569       // read in depth and video
    570       for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    571       {
    572         m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad  ) ;
    573         bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof();
    574 
    575         m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad  ) ;
    576         bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof();
    577       }
    578 #if HHI_FIX
     565        // read in depth and video
     566        for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
     567        {
     568          m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad  ) ;
     569          bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof();
     570
     571          m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad  ) ;
     572          bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof();
     573        }
    579574      }
    580575      else
    581 #else
    582       if ( iFrame < m_iFrameSkip )
    583 #endif
    584576      {
    585 #if HHI_FIX
    586577        iFrame++;
    587 #endif
    588578        continue;
    589579      }
     
    598588      }
    599589
    600 #if HHI_FIX
    601590      m_cCameraData.update( (UInt) ( iFrame - m_iFrameSkip ));
    602 #endif
    603591
    604592      for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    605593      {
    606 #if HHI_FIX
    607 #else
    608         m_cCameraData.update( (UInt)iFrame );
    609 #endif
    610 
    611594        // setup virtual views
    612595        Int iBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iBaseViewIdx];
     
    726709
    727710  AOT( m_iLog2SamplingFactor != 0 );
     711#if HHI_VSO_SPEEDUP_A033
     712  cCurModel.setHorOffset( 0 );
     713#endif
     714#if LGE_VSO_EARLY_SKIP_A0093
     715  cCurModel.create( m_iNumberOfInputViews, m_iNumberOfOutputViews, m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin, false );
     716#else
    728717  cCurModel.create( m_iNumberOfInputViews, m_iNumberOfOutputViews, m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin );
     718#endif
    729719
    730720  for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ )
     
    788778  {
    789779
    790 #if HHI_FIX
    791780    if ( iFrame >= m_iFrameSkip )
    792781    {     
    793 #endif
    794     // read in depth and video
    795     for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    796     {
    797       m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad  ) ;
    798       bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof();
    799 
    800       m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad  ) ;
    801       bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof();
    802 
    803       if ( iFrame >= m_iFrameSkip )
     782      // read in depth and video
     783      for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    804784      {
    805         Int iBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iBaseViewIdx];
    806         cCurModel.setBaseView( iBaseViewSIdx, apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], NULL, NULL );
     785        m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad  ) ;
     786        bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof();
     787
     788        m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad  ) ;
     789        bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof();
     790
     791        if ( iFrame >= m_iFrameSkip )
     792        {
     793          Int iBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iBaseViewIdx];
     794          cCurModel.setBaseView( iBaseViewSIdx, apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], NULL, NULL );
     795        }
    807796      }
    808797    }
    809 
    810 #if HHI_FIX
    811     }
    812798    else
    813 #else
    814     if ( iFrame < m_iFrameSkip ) // Skip Frames
    815 #endif
    816799    {
    817800      iFrame++;
    818801      continue;
    819802    }
    820 
    821 #if HHI_FIX
    822803    m_cCameraData.update( (UInt) (iFrame - m_iFrameSkip ));
    823 #else
    824     m_cCameraData.update( (UInt)iFrame );
    825 #endif
    826 
    827804    for(Int iSynthViewIdx=0; iSynthViewIdx < m_iNumberOfOutputViews; iSynthViewIdx++ )
    828805    {
     
    972949  {
    973950
    974 #if HHI_FIX
     951
    975952    if ( iFrame >= m_iFrameSkip )
    976953    {     
    977 #endif
    978     // read in depth and video
    979     for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    980     {
    981       m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad  ) ;
    982       apcPicYuvBaseVideo[iBaseViewIdx]->extendPicBorder();
    983       bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof();
    984 
    985       m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad  ) ;
    986       apcPicYuvBaseDepth[iBaseViewIdx]->extendPicBorder();
    987       bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof();
    988 
    989       if ( m_bTempDepthFilter && (iFrame >= m_iFrameSkip) )
     954      // read in depth and video
     955      for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    990956      {
    991         m_pcRenTop->temporalFilterVSRS( apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], apcPicYuvLastBaseVideo[iBaseViewIdx], apcPicYuvLastBaseDepth[iBaseViewIdx], ( iFrame == m_iFrameSkip) );
     957        m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad  ) ;
     958        apcPicYuvBaseVideo[iBaseViewIdx]->extendPicBorder();
     959        bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof();
     960
     961        m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad  ) ;
     962        apcPicYuvBaseDepth[iBaseViewIdx]->extendPicBorder();
     963        bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof();
     964
     965        if ( m_bTempDepthFilter && (iFrame >= m_iFrameSkip) )
     966        {
     967          m_pcRenTop->temporalFilterVSRS( apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], apcPicYuvLastBaseVideo[iBaseViewIdx], apcPicYuvLastBaseDepth[iBaseViewIdx], ( iFrame == m_iFrameSkip) );
     968        }
    992969      }
    993970    }
    994 
    995 #if HHI_FIX
    996     }
    997971    else
    998 #else
    999     if ( iFrame < m_iFrameSkip ) // Skip Frames
    1000 #endif
    1001972    {
    1002973      std::cout << "Skipping Frame " << iFrame << std::endl;
     
    1005976      continue;
    1006977    }
    1007 
    1008 #if HHI_FIX
    1009978    m_cCameraData.update( (UInt) ( iFrame - m_iFrameSkip ) );
    1010 #else
    1011     m_cCameraData.update( (UInt)iFrame );
    1012 #endif
    1013979
    1014980    for(Int iViewIdx=1; iViewIdx < m_iNumberOfInputViews; iViewIdx++ )
  • trunk/source/App/TAppRenderer/TAppRendererTop.h

    r56 r100  
    6060private:
    6161  // class interface
    62   std::vector<TVideoIOYuv*>              m_apcTVideoIOYuvVideoInput;
     62  std::vector<TVideoIOYuv*>    m_apcTVideoIOYuvVideoInput;
    6363  std::vector<TVideoIOYuv*>    m_apcTVideoIOYuvDepthInput;
    64   std::vector<TVideoIOYuv*>              m_apcTVideoIOYuvSynthOutput;
     64  std::vector<TVideoIOYuv*>    m_apcTVideoIOYuvSynthOutput;
    6565
    6666  // RendererInterface
  • trunk/source/Lib/TAppCommon/TAppComCamPara.cpp

    r56 r100  
    654654}
    655655
     656#if SAIT_VSO_EST_A0033
     657Double g_dDispCoeff;
     658#endif
    656659
    657660Bool
     
    685688    iTargetViewNum = (Int) uiTargetView;
    686689  }
     690
     691#if SAIT_VSO_EST_A0033
     692  // This part should be modified later.
     693  {
     694    Double dFL1, dCS1, dCP1, dZN1, dZF1;
     695    Bool   bInterpolated;
     696    Double dPos[3];
     697    xGetGeometryData( m_aiBaseViews[0], uiFrame, dFL1, dPos[0], dCS1, bInterpolated );
     698    xGetGeometryData( m_aiBaseViews[1], uiFrame, dFL1, dPos[1], dCS1, bInterpolated );
     699
     700    xGetGeometryData( iSourceViewNum, uiFrame, dFL1, dCP1, dCS1, bInterpolated );
     701    xGetZNearZFar   ( iSourceViewNum, uiFrame, dZN1, dZF1 );
     702
     703    Double dBaseLine = dPos[0] - dPos[1]; //Max(Max(dPos[0],dPos[1]),dPos[2]) - Min(Min(dPos[0],dPos[1]),dPos[2]);
     704    g_dDispCoeff = fabs( dFL1 * ( dBaseLine / 2.0 ) / 255.0 * ( 1.0/dZN1 - 1.0/dZF1 ) );
     705  }
     706#endif
    687707
    688708  xGetGeometryData( iSourceViewNum, uiFrame, dFocalLengthSource, dPositionSource, dIntersectionSource, bInterpolatedSource );
  • trunk/source/Lib/TAppCommon/TAppComCamPara.h

    r56 r100  
    6969  // view lists
    7070  std::vector<Int>    m_aiViewsInCfgFile;                     ///< views for which parameters are specified in cfg file (from left to right)
    71   std::vector<Int>    m_aiSynthViews;                           ///< View numbers of External ViewReferences
    72   std::vector<Int>    m_aiRelSynthViewsNum;                   ///< Relative view numbers of External ViewReferences
     71  std::vector<Int>    m_aiSynthViews;                         ///< View numbers of External ViewReferences
     72  std::vector<Int>    m_aiRelSynthViewsNum;                   ///< Relative view numbers of External ViewReferences
    7373  std::vector<Int>    m_aiBaseViews;                          ///< View numbers of Base View References (in coding order)
    7474  std::vector<Int>    m_aiSortedBaseViews;                    ///< View numbers of Base View References (from left to right)
     
    9292
    9393  // scale and offset parameters
    94   Double***           m_adBaseViewShiftParameter;                                                       ///< ShiftParameters between BaseViews e.g. [2][1][0] shift scale from view 2 to view 1; [2][1][1] shift offset from view 2 to view 1
    95   Int64 ***           m_aiBaseViewShiftParameter;                                       ///< ShiftParameters between BaseViews e.g. [2][1][0] shift scale from view 2 to view 1; [2][1][1] shift offset from view 2 to view 1           /* do we need 64 bit? */
    96   Double***           m_adSynthViewShiftParameter;                                        ///< ShiftParameters between BaseViews and ERViews e.g. [2][1][0] shift scale from base view 2 to er view 1;
    97   Int64 ***           m_aiSynthViewShiftParameter;                              ///< ShiftParameters between BaseViews and ERViews e.g. [2][1][0] shift scale from base view 2 to er view 1;            /* do we need 64 bit? */
     94  Double***           m_adBaseViewShiftParameter;             ///< ShiftParameters between BaseViews e.g. [2][1][0] shift scale from view 2 to view 1; [2][1][1] shift offset from view 2 to view 1
     95  Int64 ***           m_aiBaseViewShiftParameter;             ///< ShiftParameters between BaseViews e.g. [2][1][0] shift scale from view 2 to view 1; [2][1][1] shift offset from view 2 to view 1     /* do we need 64 bit? */
     96  Double***           m_adSynthViewShiftParameter;            ///< ShiftParameters between BaseViews and ERViews e.g. [2][1][0] shift scale from base view 2 to er view 1;
     97  Int64 ***           m_aiSynthViewShiftParameter;            ///< ShiftParameters between BaseViews and ERViews e.g. [2][1][0] shift scale from base view 2 to er view 1;    /* do we need 64 bit? */
    9898
    9999  // look-up tables
    100   Double****          m_adBaseViewShiftLUT;                                                                             ///< Disparity LUT
    101   Int****             m_aiBaseViewShiftLUT;                                                                       ///< Disparity LUT
    102   Double****          m_adSynthViewShiftLUT;                                                                    ///< Disparity LUT
    103   Int****             m_aiSynthViewShiftLUT;                                                                    ///< Disparity LUT
     100  Double****          m_adBaseViewShiftLUT;                    ///< Disparity LUT
     101  Int****             m_aiBaseViewShiftLUT;                    ///< Disparity LUT
     102  Double****          m_adSynthViewShiftLUT;                   ///< Disparity LUT
     103  Int****             m_aiSynthViewShiftLUT;                   ///< Disparity LUT
    104104
    105105
  • trunk/source/Lib/TLibCommon/CommonDef.h

    r77 r100  
    5858
    5959#define HM_VERSION        "6.1"
    60 #define NV_VERSION        "3.1rc1"                 ///< Current software version
     60#define NV_VERSION        "4.0rc1"                 ///< Current software version
    6161
    6262// ====================================================================================================================
     
    130130#if ( HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED )
    131131#define DEPTH_MAP_GENERATION        1
     132#define PDM_REMOVE_DEPENDENCE       1      //bug-fix for DMDV JCT2-A0095
    132133#else
    133134#define DEPTH_MAP_GENERATION        0
     
    138139#define PDM_NO_INTER_UPDATE               1         // no update for inter (but not inter-view) predicted blocks
    139140#define PDM_MERGE_POS                     0         // position of pdm in merge list (0..4)
    140 #if SAIT_IMPROV_MOTION_PRED_M24829
     141#if SAIT_IMPROV_MOTION_PRED_M24829&!QC_MULTI_DIS_CAN
    141142#define PDM_AMVP_POS                      0         // position of pdm in amvp list  (0..3)
    142143#else
     
    170171#define STD_CAM_PARAMETERS_PRECISION 5        ///< quarter luma sample accuarcy for derived disparities (as default)
    171172
    172 #define LOG2_DISP_PREC_LUT                              2                               ///< log2 of disparity precision used in integer disparity LUTs
     173#define LOG2_DISP_PREC_LUT           2          ///< log2 of disparity precision used in integer disparity LUTs
    173174
    174175// ====================================================================================================================
     
    400401#define Clip3( MinVal, MaxVal, a)   ( ((a)<(MinVal)) ? (MinVal) : (((a)>(MaxVal)) ? (MaxVal) :(a)) )  ///< general min/max clip
    401402#define RemoveBitIncrement(x)       ( (x + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
     403
     404#if SAIT_VSO_EST_A0033
     405#define ROUND(a)  (((a) < 0)? (int)((a) - 0.5) : (int)((a) + 0.5))
     406#endif
    402407
    403408// ====================================================================================================================
     
    495500  NAL_UNIT_UNSPECIFIED_24,
    496501#if VIDYO_VPS_INTEGRATION
    497         NAL_UNIT_VPS,
     502  NAL_UNIT_VPS,
    498503#else
    499504  NAL_UNIT_UNSPECIFIED_25,
  • trunk/source/Lib/TLibCommon/ContextTables.h

    r56 r100  
    152152#endif
    153153
     154#if LGE_EDGE_INTRA
     155#define NUM_EDGE_INTRA_CTX            1
     156#if LGE_EDGE_INTRA_DELTA_DC
     157#define NUM_EDGE_INTRA_DELTA_DC_CTX   2 // one for Delta_DC flag, another for Delta_DC value
     158#endif
     159#endif
     160
    154161// ====================================================================================================================
    155162// Tables
     
    12721279  }
    12731280};
     1281
     1282#if LGE_EDGE_INTRA
     1283static const Short
     1284INIT_EDGE_INTRA[3][NUM_EDGE_INTRA_CTX] =
     1285{
     1286  {
     1287    CNU
     1288  },
     1289  {
     1290    CNU
     1291  },
     1292  {
     1293    CNU
     1294  }
     1295};
     1296
     1297#if LGE_EDGE_INTRA_DELTA_DC
     1298static const Short
     1299INIT_EDGE_INTRA_DELTA_DC[3][NUM_EDGE_INTRA_DELTA_DC_CTX] =
     1300{
     1301  {
     1302    CNU, CNU
     1303  },
     1304  {
     1305    CNU, CNU
     1306  },
     1307  {
     1308    CNU, CNU
     1309  }
     1310};
     1311#endif
     1312#endif
     1313
    12741314#endif
    12751315
    12761316//! \}
    12771317
    1278 
    1279 #endif
    1280 
     1318#endif
     1319
  • trunk/source/Lib/TLibCommon/NAL.h

    r77 r100  
    5252#endif
    5353#if VIDYO_VPS_INTEGRATION
    54         unsigned    m_layerId;
     54  unsigned    m_layerId;
    5555  unsigned    m_temporalId;  ///< temporal_id
    5656#else
     
    100100    m_isDepth     = isDepth;
    101101#else
    102                 m_layerId = layerId;
     102    m_layerId = layerId;
    103103#endif
    104104    m_temporalId  = temporalID;
     
    124124    m_isDepth     = isDepth;
    125125#else
    126                 m_layerId = layerId;
     126    m_layerId = layerId;
    127127#endif
    128128    m_temporalId  = temporalID;
  • trunk/source/Lib/TLibCommon/TComDataCU.cpp

    r81 r100  
    141141  m_pbResPredFlag      = NULL;
    142142#endif
     143#if LGE_EDGE_INTRA
     144  m_pucEdgeCode         = NULL;
     145  m_pucEdgeNumber       = NULL;
     146  m_pucEdgeStartPos     = NULL;
     147  m_pbEdgeLeftFirst     = NULL;
     148  m_pbEdgePartition     = NULL;
     149#if LGE_EDGE_INTRA_DELTA_DC
     150  m_piEdgeDeltaDC0      = NULL;
     151  m_piEdgeDeltaDC1      = NULL;
     152#endif
     153#endif
    143154}
    144155
     
    259270    m_piContourPredTexDeltaDC2 = (Int* )xMalloc(Int,  uiNumPartition);
    260271#endif
     272#if LGE_EDGE_INTRA
     273    m_pucEdgeCode       = (UChar*)xMalloc(UChar, uiNumPartition * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4);
     274    m_pucEdgeNumber     = (UChar*)xMalloc(UChar, uiNumPartition);
     275    m_pucEdgeStartPos   = (UChar*)xMalloc(UChar, uiNumPartition);
     276    m_pbEdgeLeftFirst   = (Bool*) xMalloc(Bool,  uiNumPartition);
     277    m_pbEdgePartition   = (Bool*) xMalloc(Bool,  uiNumPartition * 16);
     278#if LGE_EDGE_INTRA_DELTA_DC
     279    m_piEdgeDeltaDC0    = (Int* ) xMalloc(Int,   uiNumPartition);
     280    m_piEdgeDeltaDC1    = (Int* ) xMalloc(Int,   uiNumPartition);
     281#endif
     282#endif
    261283  }
    262284  else
     
    359381    if ( m_piContourPredTexDeltaDC2 ) { xFree(m_piContourPredTexDeltaDC2); m_piContourPredTexDeltaDC2 = NULL; }
    360382#endif   
     383#if LGE_EDGE_INTRA
     384  if ( m_pbEdgeLeftFirst  ) { xFree(m_pbEdgeLeftFirst);   m_pbEdgeLeftFirst = NULL; }
     385  if ( m_pucEdgeStartPos  ) { xFree(m_pucEdgeStartPos);   m_pucEdgeStartPos = NULL; }
     386  if ( m_pucEdgeNumber    ) { xFree(m_pucEdgeNumber);     m_pucEdgeNumber   = NULL; }
     387  if ( m_pucEdgeCode      ) { xFree(m_pucEdgeCode);       m_pucEdgeCode     = NULL; }
     388  if ( m_pbEdgePartition    ) { xFree(m_pbEdgePartition); m_pbEdgePartition = NULL; }
     389#if LGE_EDGE_INTRA_DELTA_DC
     390  if ( m_piEdgeDeltaDC0     ) { xFree(m_piEdgeDeltaDC0);  m_piEdgeDeltaDC0  = NULL; }
     391  if ( m_piEdgeDeltaDC1     ) { xFree(m_piEdgeDeltaDC1);  m_piEdgeDeltaDC1  = NULL; }
     392#endif
     393#endif
    361394    m_acCUMvField[0].destroy();
    362395    m_acCUMvField[1].destroy();
     
    10931126  m_piContourPredTexDeltaDC2 = pcCU->getContourPredTexDeltaDC2() + uiPart;   
    10941127#endif
     1128#if LGE_EDGE_INTRA
     1129  if( pcCU->getSlice()->getSPS()->isDepth() )
     1130  {
     1131    m_pucEdgeCode         = pcCU->getEdgeCode( uiPart );
     1132    m_pucEdgeNumber       = pcCU->getEdgeNumber() + uiPart;
     1133    m_pucEdgeStartPos     = pcCU->getEdgeStartPos() + uiPart;
     1134    m_pbEdgeLeftFirst     = pcCU->getEdgeLeftFirst() + uiPart;
     1135    m_pbEdgePartition     = pcCU->getEdgePartition( uiPart );
     1136#if LGE_EDGE_INTRA_DELTA_DC
     1137    m_piEdgeDeltaDC0      = pcCU->getEdgeDeltaDC0() + uiPart;
     1138    m_piEdgeDeltaDC1      = pcCU->getEdgeDeltaDC1() + uiPart;
     1139#endif
     1140  }
     1141#endif
    10951142}
    10961143
     
    12501297  memcpy( m_piContourPredTexDeltaDC2 + uiOffset, pcCU->getContourPredTexDeltaDC2(), sizeof( Int  ) * uiNumPartition );
    12511298#endif
     1299
     1300#if LGE_EDGE_INTRA
     1301  if( getSlice()->getSPS()->isDepth() )
     1302  {
     1303    memcpy( getEdgeCode( uiOffset ), pcCU->getEdgeCode(0), iSizeInUchar * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 );
     1304    memcpy( getEdgeNumber() + uiOffset, pcCU->getEdgeNumber(), iSizeInUchar );
     1305    memcpy( getEdgeStartPos() + uiOffset, pcCU->getEdgeStartPos(), iSizeInUchar );
     1306    memcpy( getEdgeLeftFirst() + uiOffset, pcCU->getEdgeLeftFirst(), iSizeInBool );
     1307    memcpy( getEdgePartition( uiOffset ), pcCU->getEdgePartition(0), iSizeInBool * 16 );
     1308#if LGE_EDGE_INTRA_DELTA_DC
     1309    memcpy( getEdgeDeltaDC0() + uiOffset, pcCU->getEdgeDeltaDC0(), sizeof( Int  ) * uiNumPartition );
     1310    memcpy( getEdgeDeltaDC1() + uiOffset, pcCU->getEdgeDeltaDC1(), sizeof( Int  ) * uiNumPartition );
     1311#endif
     1312  }
     1313#endif
     1314
    12521315#if HHI_MPI
    12531316  memcpy( m_piTextureModeDepth + uiOffset, pcCU->getTextureModeDepth(), sizeof( Int ) * uiNumPartition );
     
    13521415  memcpy( rpcCU->getContourPredTexDeltaDC2() + m_uiAbsIdxInLCU, m_piContourPredTexDeltaDC2, sizeof( Int  ) * m_uiNumPartition );
    13531416#endif
     1417
     1418#if LGE_EDGE_INTRA
     1419  if( rpcCU->getSlice()->getSPS()->isDepth() )
     1420  {
     1421    memcpy( rpcCU->getEdgeCode( m_uiAbsIdxInLCU ),        m_pucEdgeCode,    iSizeInUchar * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 );
     1422    memcpy( rpcCU->getEdgeNumber()    + m_uiAbsIdxInLCU,  m_pucEdgeNumber,  iSizeInUchar );
     1423    memcpy( rpcCU->getEdgeStartPos()  + m_uiAbsIdxInLCU,  m_pucEdgeStartPos,iSizeInUchar );
     1424    memcpy( rpcCU->getEdgeLeftFirst() + m_uiAbsIdxInLCU,  m_pbEdgeLeftFirst,iSizeInBool );
     1425    memcpy( rpcCU->getEdgePartition( m_uiAbsIdxInLCU ),   m_pbEdgePartition,iSizeInBool * 16 );
     1426#if LGE_EDGE_INTRA_DELTA_DC
     1427    memcpy( rpcCU->getEdgeDeltaDC0() + m_uiAbsIdxInLCU,   m_piEdgeDeltaDC0, sizeof( Int  ) * m_uiNumPartition );
     1428    memcpy( rpcCU->getEdgeDeltaDC1() + m_uiAbsIdxInLCU,   m_piEdgeDeltaDC1, sizeof( Int  ) * m_uiNumPartition );
     1429#endif
     1430  }
     1431#endif
     1432
    13541433#if HHI_MPI
    13551434  memcpy( rpcCU->getTextureModeDepth() + m_uiAbsIdxInLCU, m_piTextureModeDepth, sizeof( Int ) * m_uiNumPartition );
     
    14551534  memcpy( rpcCU->getContourPredTexDeltaDC2() + uiPartOffset, m_piContourPredTexDeltaDC2, sizeof( Int  ) * uiQNumPart );
    14561535#endif
     1536
     1537#if LGE_EDGE_INTRA
     1538  if( rpcCU->getSlice()->getSPS()->isDepth() )
     1539  {
     1540    memcpy( rpcCU->getEdgeCode( uiPartOffset ),       m_pucEdgeCode,    iSizeInUchar * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 );
     1541    memcpy( rpcCU->getEdgeNumber()    + uiPartOffset, m_pucEdgeNumber,  iSizeInUchar );
     1542    memcpy( rpcCU->getEdgeStartPos()  + uiPartOffset, m_pucEdgeStartPos,iSizeInUchar );
     1543    memcpy( rpcCU->getEdgeLeftFirst() + uiPartOffset, m_pbEdgeLeftFirst,iSizeInBool );
     1544    memcpy( rpcCU->getEdgePartition( uiPartOffset ),  m_pbEdgePartition,iSizeInBool * 16 );
     1545#if LGE_EDGE_INTRA_DELTA_DC
     1546    memcpy( rpcCU->getEdgeDeltaDC0() + uiPartOffset,  m_piEdgeDeltaDC0, sizeof( Int  ) * uiQNumPart  );
     1547    memcpy( rpcCU->getEdgeDeltaDC1() + uiPartOffset,  m_piEdgeDeltaDC1, sizeof( Int  ) * uiQNumPart  );
     1548#endif
     1549  }
     1550#endif
     1551
    14571552#if HHI_MPI
    14581553  memcpy( rpcCU->getTextureModeDepth() + uiPartOffset, m_piTextureModeDepth, sizeof( Int ) * uiQNumPart  );
     
    23322427  mapDMMtoIntraMode( iLeftIntraDir );
    23332428#endif
     2429#if LGE_EDGE_INTRA
     2430  mapEdgeIntratoDC( iLeftIntraDir );
     2431#endif
    23342432 
    23352433  // Get intra direction of above PU
     
    23432441#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    23442442  mapDMMtoIntraMode( iAboveIntraDir );
     2443#endif
     2444#if LGE_EDGE_INTRA
     2445  mapEdgeIntratoDC( iAboveIntraDir );
    23452446#endif
    23462447 
     
    24262527  return uiPredNum;
    24272528}
     2529
     2530#if LGE_EDGE_INTRA
     2531UInt TComDataCU::getCtxEdgeIntra( UInt uiAbsPartIdx )
     2532{
     2533  UInt        uiCtx = 0;
     2534  return uiCtx;
     2535}
     2536#endif
    24282537
    24292538UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth )
     
    28862995Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU)
    28872996{
    2888         UInt uiNumPartition  = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition;
    2889         UInt uiTmpAbsPartIdx = bLCU ? uiAbsPartIdx : 0;
    2890 
    2891         switch ( m_pePartSize[uiTmpAbsPartIdx] )
    2892         {
    2893         case SIZE_2NxN:
    2894                 riWidth = getWidth(uiTmpAbsPartIdx);      riHeight = getHeight(uiTmpAbsPartIdx) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1;
    2895                 break;
    2896         case SIZE_Nx2N:
    2897                 riWidth = getWidth(uiTmpAbsPartIdx) >> 1; riHeight = getHeight(uiTmpAbsPartIdx);      ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2;
    2898                 break;
    2899         case SIZE_NxN:
    2900                 riWidth = getWidth(uiTmpAbsPartIdx) >> 1; riHeight = getHeight(uiTmpAbsPartIdx) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx;
    2901                 break;
    2902         case SIZE_2NxnU:
    2903                 riWidth     = getWidth(uiTmpAbsPartIdx);
    2904                 riHeight    = ( uiPartIdx == 0 ) ?  getHeight(uiTmpAbsPartIdx) >> 2 : ( getHeight(uiTmpAbsPartIdx) >> 2 ) + ( getHeight(uiTmpAbsPartIdx) >> 1 );
    2905                 ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3;
    2906                 break;
    2907         case SIZE_2NxnD:
    2908                 riWidth     = getWidth(uiTmpAbsPartIdx);
    2909                 riHeight    = ( uiPartIdx == 0 ) ?  ( getHeight(uiTmpAbsPartIdx) >> 2 ) + ( getHeight(uiTmpAbsPartIdx) >> 1 ) : getHeight(uiTmpAbsPartIdx) >> 2;
    2910                 ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3);
    2911                 break;
    2912         case SIZE_nLx2N:
    2913                 riWidth     = ( uiPartIdx == 0 ) ? getWidth(uiTmpAbsPartIdx) >> 2 : ( getWidth(uiTmpAbsPartIdx) >> 2 ) + ( getWidth(uiTmpAbsPartIdx) >> 1 );
    2914                 riHeight    = getHeight(uiTmpAbsPartIdx);
    2915                 ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4;
    2916                 break;
    2917         case SIZE_nRx2N:
    2918                 riWidth     = ( uiPartIdx == 0 ) ? ( getWidth(uiTmpAbsPartIdx) >> 2 ) + ( getWidth(uiTmpAbsPartIdx) >> 1 ) : getWidth(uiTmpAbsPartIdx) >> 2;
    2919                 riHeight    = getHeight(uiTmpAbsPartIdx);
    2920                 ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4);
    2921                 break;
    2922         default:
    2923 #if HHI_FIX
     2997  UInt uiNumPartition  = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition;
     2998  UInt uiTmpAbsPartIdx = bLCU ? uiAbsPartIdx : 0;
     2999
     3000  switch ( m_pePartSize[uiTmpAbsPartIdx] )
     3001  {
     3002  case SIZE_2NxN:
     3003    riWidth = getWidth(uiTmpAbsPartIdx);      riHeight = getHeight(uiTmpAbsPartIdx) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1;
     3004    break;
     3005  case SIZE_Nx2N:
     3006    riWidth = getWidth(uiTmpAbsPartIdx) >> 1; riHeight = getHeight(uiTmpAbsPartIdx);      ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2;
     3007    break;
     3008  case SIZE_NxN:
     3009    riWidth = getWidth(uiTmpAbsPartIdx) >> 1; riHeight = getHeight(uiTmpAbsPartIdx) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx;
     3010    break;
     3011  case SIZE_2NxnU:
     3012    riWidth     = getWidth(uiTmpAbsPartIdx);
     3013    riHeight    = ( uiPartIdx == 0 ) ?  getHeight(uiTmpAbsPartIdx) >> 2 : ( getHeight(uiTmpAbsPartIdx) >> 2 ) + ( getHeight(uiTmpAbsPartIdx) >> 1 );
     3014    ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3;
     3015    break;
     3016  case SIZE_2NxnD:
     3017    riWidth     = getWidth(uiTmpAbsPartIdx);
     3018    riHeight    = ( uiPartIdx == 0 ) ?  ( getHeight(uiTmpAbsPartIdx) >> 2 ) + ( getHeight(uiTmpAbsPartIdx) >> 1 ) : getHeight(uiTmpAbsPartIdx) >> 2;
     3019    ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3);
     3020    break;
     3021  case SIZE_nLx2N:
     3022    riWidth     = ( uiPartIdx == 0 ) ? getWidth(uiTmpAbsPartIdx) >> 2 : ( getWidth(uiTmpAbsPartIdx) >> 2 ) + ( getWidth(uiTmpAbsPartIdx) >> 1 );
     3023    riHeight    = getHeight(uiTmpAbsPartIdx);
     3024    ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4;
     3025    break;
     3026  case SIZE_nRx2N:
     3027    riWidth     = ( uiPartIdx == 0 ) ? ( getWidth(uiTmpAbsPartIdx) >> 2 ) + ( getWidth(uiTmpAbsPartIdx) >> 1 ) : getWidth(uiTmpAbsPartIdx) >> 2;
     3028    riHeight    = getHeight(uiTmpAbsPartIdx);
     3029    ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4);
     3030    break;
     3031  default:
    29243032    assert ( m_pePartSize[uiTmpAbsPartIdx ] == SIZE_2Nx2N );
    2925 #else
    2926                 assert ( m_pePartSize[0] == SIZE_2Nx2N );
    2927 #endif
    2928                 riWidth = getWidth(uiTmpAbsPartIdx);      riHeight = getHeight(uiTmpAbsPartIdx);      ruiPartAddr = 0;
    2929                 break;
    2930         }
     3033    riWidth = getWidth(uiTmpAbsPartIdx);      riHeight = getHeight(uiTmpAbsPartIdx);      ruiPartAddr = 0;
     3034    break;
     3035  }
    29313036}
    29323037#else
     
    29753080Int TComDataCU::getResiPredMode(UInt uiPartAddr)
    29763081{
    2977         Int iAddResiShift = -1;
    2978 
    2979         for(UInt uiRefIdx = 0; uiRefIdx < 2; uiRefIdx++)
    2980         {
    2981                 RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
    2982                 Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr);
    2983                 if(iBestRefIdx >= 0 && getSlice()->getViewId() == getSlice()->getRefViewId(eRefList, iBestRefIdx))
    2984                         iAddResiShift++;
    2985         }
    2986 
    2987         return iAddResiShift;
     3082  Int iAddResiShift = -1;
     3083
     3084  for(UInt uiRefIdx = 0; uiRefIdx < 2; uiRefIdx++)
     3085  {
     3086    RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
     3087    Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr);
     3088    if(iBestRefIdx >= 0 && getSlice()->getViewId() == getSlice()->getRefViewId(eRefList, iBestRefIdx))
     3089      iAddResiShift++;
     3090  }
     3091
     3092  return iAddResiShift;
    29883093}
    29893094
    29903095Void TComDataCU::getPUResiPredShift(Int *iPUResiPredShift, UInt uiAbsPartIndex)
    29913096{
    2992         UInt uiPartSize = getPartitionSize(uiAbsPartIndex);
    2993         UInt uiPartAddr;
    2994         Int iWidth, iHeight;
    2995         Int iAddResiShift;
    2996 
    2997         if(uiPartSize == SIZE_2Nx2N)
    2998         {
    2999                 iAddResiShift = getResiPredMode(uiAbsPartIndex);
    3000                 for(UInt i = 0; i < 4; i++)
    3001                         iPUResiPredShift[i] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiAbsPartIndex) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
    3002                 return;
    3003         }
    3004 
    3005         if(uiPartSize == SIZE_2NxN || uiPartSize == SIZE_2NxnU || uiPartSize == SIZE_2NxnD)
    3006         {
    3007                 for(UInt i = 0; i < 2; i++)
    3008                 {
    3009                         getPartIndexAndSize(i, uiPartAddr, iWidth, iHeight, uiAbsPartIndex, true);
    3010                         uiPartAddr += uiAbsPartIndex;
    3011                         iAddResiShift = getResiPredMode(uiPartAddr);
    3012                         iPUResiPredShift[2*i] = iPUResiPredShift[2*i+1] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
    3013                 }
    3014                 return;
    3015         }
    3016 
    3017         if(uiPartSize == SIZE_Nx2N || uiPartSize == SIZE_nLx2N || uiPartSize == SIZE_nRx2N)
    3018         {
    3019                 for(UInt i = 0; i < 2; i++)
    3020                 {
    3021                         getPartIndexAndSize(i, uiPartAddr, iWidth, iHeight, uiAbsPartIndex, true);
    3022                         uiPartAddr += uiAbsPartIndex;
    3023                         iAddResiShift = getResiPredMode(uiPartAddr);
    3024                         iPUResiPredShift[i] = iPUResiPredShift[2+i] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
    3025                 }
    3026                 return;
    3027         }
    3028 
    3029         if(uiPartSize == SIZE_NxN)
    3030         {
    3031                 for(UInt i = 0; i < 4; i++)
    3032                 {
    3033                         getPartIndexAndSize(i, uiPartAddr, iWidth, iHeight, uiAbsPartIndex, true);
    3034                         uiPartAddr += uiAbsPartIndex;
    3035                         iAddResiShift = getResiPredMode(uiPartAddr);
    3036                         iPUResiPredShift[i] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
    3037                 }
    3038         }
     3097  UInt uiPartSize = getPartitionSize(uiAbsPartIndex);
     3098  UInt uiPartAddr;
     3099  Int iWidth, iHeight;
     3100  Int iAddResiShift;
     3101
     3102  if(uiPartSize == SIZE_2Nx2N)
     3103  {
     3104    iAddResiShift = getResiPredMode(uiAbsPartIndex);
     3105    for(UInt i = 0; i < 4; i++)
     3106      iPUResiPredShift[i] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiAbsPartIndex) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
     3107    return;
     3108  }
     3109
     3110  if(uiPartSize == SIZE_2NxN || uiPartSize == SIZE_2NxnU || uiPartSize == SIZE_2NxnD)
     3111  {
     3112    for(UInt i = 0; i < 2; i++)
     3113    {
     3114      getPartIndexAndSize(i, uiPartAddr, iWidth, iHeight, uiAbsPartIndex, true);
     3115      uiPartAddr += uiAbsPartIndex;
     3116      iAddResiShift = getResiPredMode(uiPartAddr);
     3117      iPUResiPredShift[2*i] = iPUResiPredShift[2*i+1] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
     3118    }
     3119    return;
     3120  }
     3121
     3122  if(uiPartSize == SIZE_Nx2N || uiPartSize == SIZE_nLx2N || uiPartSize == SIZE_nRx2N)
     3123  {
     3124    for(UInt i = 0; i < 2; i++)
     3125    {
     3126      getPartIndexAndSize(i, uiPartAddr, iWidth, iHeight, uiAbsPartIndex, true);
     3127      uiPartAddr += uiAbsPartIndex;
     3128      iAddResiShift = getResiPredMode(uiPartAddr);
     3129      iPUResiPredShift[i] = iPUResiPredShift[2+i] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
     3130    }
     3131    return;
     3132  }
     3133
     3134  if(uiPartSize == SIZE_NxN)
     3135  {
     3136    for(UInt i = 0; i < 4; i++)
     3137    {
     3138      getPartIndexAndSize(i, uiPartAddr, iWidth, iHeight, uiAbsPartIndex, true);
     3139      uiPartAddr += uiAbsPartIndex;
     3140      iAddResiShift = getResiPredMode(uiPartAddr);
     3141      iPUResiPredShift[i] = (getSlice()->getPPS()->getUseWP() || getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
     3142    }
     3143  }
    30393144
    30403145}
     
    33583463  TComMv  acPdmMv       [2];
    33593464  Int     aiPdmRefIdx   [2] = {-1, -1};
     3465
     3466#if LGE_DVMCP
     3467  acPdmMv[0].m_bDvMcp = acPdmMv[1].m_bDvMcp = false;
     3468#endif
     3469
     3470#if QC_MULTI_DIS_CAN
     3471  DisInfo cDisInfo;
     3472  cDisInfo.iN = 0;
     3473  if(!bNoPdmMerge)
     3474  {
     3475#if LGE_DVMCP
     3476    getDisMvpCand2(uiPUIdx, uiAbsPartIdx, &cDisInfo, true );
     3477#else
     3478    getDisMvpCand (uiPUIdx, uiAbsPartIdx, &cDisInfo );
     3479#endif
     3480  }
     3481  if(cDisInfo.iN==0)
     3482  {
     3483    cDisInfo.iN = 1;
     3484    cDisInfo.m_acMvCand[0].setHor(0);
     3485    cDisInfo.m_acMvCand[0].setVer(0);
     3486    cDisInfo.m_aVIdxCan[0] = 0;
     3487  }
     3488  Int     iPdmInterDir      = cDisInfo.iN==0? 0:getPdmMergeCandidateDisCan ( uiPUIdx, aiPdmRefIdx, acPdmMv, &cDisInfo  );
     3489#else
    33603490  Int     iPdmInterDir      = getPdmMergeCandidate( uiPUIdx, aiPdmRefIdx, acPdmMv );
     3491#endif
    33613492
    33623493  if( iPdmInterDir && !bNoPdmMerge && PDM_MERGE_POS == 0 )
     
    34133544      pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    34143545    }
     3546#if LGE_DVMCP
     3547    pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
     3548    pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
     3549#endif
    34153550#if SIMP_MRG_PRUN
    34163551    if ( mrgCandIdx == iCount )
     
    34853620      pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    34863621    }
     3622#if LGE_DVMCP
     3623    pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
     3624    pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
     3625#endif
    34873626#if SIMP_MRG_PRUN
    34883627    if ( mrgCandIdx == iCount )
     
    35523691      pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    35533692    }
     3693#if LGE_DVMCP
     3694    pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
     3695    pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
     3696#endif
    35543697#if SIMP_MRG_PRUN
    35553698    if ( mrgCandIdx == iCount )
     
    36163759      pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    36173760    }
     3761#if LGE_DVMCP
     3762    pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
     3763    pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
     3764#endif
    36183765#if SIMP_MRG_PRUN
    36193766    if ( mrgCandIdx == iCount )
     
    36893836        pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    36903837      }
     3838#if LGE_DVMCP
     3839      pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
     3840      pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
     3841#endif
    36913842#if SIMP_MRG_PRUN
    36923843      if ( mrgCandIdx == iCount )
     
    38053956        puhInterDirNeighbours[uiArrayAddr] = 1;
    38063957      }
     3958#if LGE_DVMCP
     3959      pcMvFieldNeighbours[uiArrayAddr<<1    ].getMv().m_bDvMcp = false;
     3960      pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv().m_bDvMcp = false;
     3961#endif
    38073962#if SIMP_MRG_PRUN
    38083963      if ( mrgCandIdx == iCount )
     
    42744429  return m_pcSlice->getSPS()->getAMVPMode(m_puhDepth[uiIdx]);
    42754430}
     4431#if QC_MULTI_DIS_CAN
     4432/** construct a list of disparity motion vectors from the neighbouring PUs **/
     4433Void TComDataCU::getDisMvpCand ( UInt uiPartIdx, UInt uiPartAddr,DisInfo* pDInfo )
     4434{
     4435  PartSize eCUMode = getPartitionSize( uiPartAddr );
     4436  TComDataCU* pcTmpCU = NULL;
     4437  pDInfo->iN = 0;
     4438
     4439  RefPicList eRefPicList = REF_PIC_LIST_0 ;
     4440  //-- Get Spatial MV
     4441  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
     4442  UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
     4443
     4444  deriveLeftRightTopIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT );
     4445  deriveLeftBottomIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLB );
     4446
     4447  UInt uiIdx = 0;
     4448#if MVP_AT_ENTROPYSLICE_BOUNDARY
     4449    pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false);
     4450#else
     4451    pcTmpCU = getPULeft(uiIdx, uiPartIdxLB);
     4452#endif
     4453  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
     4454  {
     4455    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     4456    {
     4457      eRefPicList = RefPicList(iList);
     4458      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
     4459      if( refId >= 0)
     4460      {
     4461        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
     4462        if (refViewIdx!= m_pcSlice->getViewId())
     4463        {
     4464           TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4465           clipMv(cMvPred);
     4466           pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     4467           pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     4468           return;
     4469        }
     4470      }
     4471    }
     4472  }
     4473#if MVP_AT_ENTROPYSLICE_BOUNDARY
     4474      pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true);
     4475#else
     4476    pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT);
     4477#endif
     4478
     4479  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
     4480  {
     4481    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     4482    {
     4483      eRefPicList = RefPicList(iList);
     4484      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
     4485      if( refId >= 0)
     4486      {
     4487        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
     4488        if (refViewIdx!= m_pcSlice->getViewId())
     4489        {
     4490           TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4491           clipMv(cMvPred);
     4492           pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     4493           pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     4494           return;
     4495        }
     4496      }
     4497    }
     4498  }
     4499
     4500#if MVP_AT_ENTROPYSLICE_BOUNDARY
     4501      pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, false, true);
     4502#else
     4503      pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, true, true);
     4504#endif
     4505  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
     4506  {
     4507    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     4508    {
     4509      eRefPicList = RefPicList(iList);
     4510      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
     4511      if( refId >= 0)
     4512      {
     4513        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
     4514        if (refViewIdx!= m_pcSlice->getViewId())
     4515        {
     4516           TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4517           clipMv(cMvPred);
     4518           pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     4519           pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     4520           return;
     4521        }
     4522      }
     4523    }
     4524  }
     4525#if MVP_AT_ENTROPYSLICE_BOUNDARY
     4526      pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true, false);
     4527#else
     4528      pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB);
     4529#endif
     4530  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
     4531  {
     4532    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     4533    {
     4534      eRefPicList = RefPicList(iList);
     4535      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
     4536      if( refId >= 0)
     4537      {
     4538        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
     4539        if (refViewIdx!= m_pcSlice->getViewId())
     4540        {
     4541           TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4542           clipMv(cMvPred);
     4543           pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     4544           pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     4545           return;
     4546        }
     4547      }
     4548    }
     4549  }
     4550
     4551  // Above predictor search
     4552#if MVP_AT_ENTROPYSLICE_BOUNDARY
     4553      pcTmpCU = getPUAboveLeft(uiIdx, (m_uiAbsIdxInLCU + uiPartAddr), true, false, true);
     4554    assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr));
     4555#else
     4556      pcTmpCU = getPUAboveLeft(uiIdx, uiPartIdxLT, true, true, true);
     4557#endif
     4558  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
     4559  {
     4560    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     4561    {
     4562      eRefPicList = RefPicList(iList);
     4563      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
     4564      if( refId >= 0)
     4565      {
     4566        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
     4567        if (refViewIdx!= m_pcSlice->getViewId())
     4568        {
     4569           TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4570           clipMv(cMvPred);
     4571           pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     4572           pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     4573           return;
     4574        }
     4575      }
     4576    }
     4577  }
     4578  //Get temporal MV
     4579  TComMv cColMv;
     4580  Int iTargetViewIdx = 0;
     4581  Int iTStartViewIdx = 0;
     4582  UInt uiPartIdxRB, uiBRIdx;
     4583  Int uiViewIdxCurr= getSlice()->getViewId();
     4584
     4585  UInt uiAbsPartAddr;
     4586  int uiLCUIdx = getAddr();
     4587  Int uiLCUnew = uiLCUIdx;
     4588  eCUMode = getPartitionSize( 0 );
     4589  deriveRightBottomIdx( eCUMode, uiPartIdx, uiPartIdxRB ); 
     4590  uiBRIdx = uiPartIdxLT;
     4591  UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
     4592  if ( (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) &&(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ))  // image boundary check
     4593  {
     4594    if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
     4595      ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
     4596    {
     4597      uiBRIdx = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
     4598    }
     4599    else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
     4600    {
     4601      uiBRIdx = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
     4602      uiLCUnew = uiLCUIdx + m_pcPic->getFrameWidthInCU();
     4603    }
     4604    else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
     4605    {
     4606      uiBRIdx = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
     4607      uiLCUnew = uiLCUIdx + 1;
     4608    }
     4609    else //is the right bottom corner of LCU                       
     4610    {
     4611      uiBRIdx = 0;
     4612      uiLCUnew = uiLCUIdx + m_pcPic->getFrameWidthInCU() + 1;
     4613    }
     4614  }
     4615
     4616  Int MaxRef = getSlice()->getNumRefIdx(RefPicList(0));
     4617  UInt uiNumPartInCUHeight = m_pcPic->getNumPartInHeight();
     4618  UInt uiPUVert = (UInt)((Int)g_auiZscanToRaster[uiPartIdxLB]/(Int)(uiNumPartInCUWidth)-(Int)g_auiZscanToRaster[uiPartIdxLT]/(Int)(uiNumPartInCUWidth));
     4619  UInt uiPUHorStart  = g_auiZscanToRaster[uiPartIdxLT];
     4620  UInt uiPUHorEnd    = g_auiZscanToRaster[uiPartIdxRT];
     4621  for( Int i= 0; i< getSlice()->getNumRefIdx(RefPicList(0)); i ++)
     4622  {
     4623    getSlice()->getRefPic( RefPicList(0), i)->setCandPicCheckedFlag(0);
     4624  }
     4625  for( Int i= 0; i< getSlice()->getNumRefIdx(RefPicList(1)); i ++)
     4626  {
     4627    getSlice()->getRefPic( RefPicList(1), i)->setCandPicCheckedFlag(0);
     4628  }
     4629  {
     4630    //check the col-located picture
     4631    eRefPicList = RefPicList(getSlice()->isInterB() ? getSlice()->getColDir() : 0);
     4632#if COLLOCATED_REF_IDX
     4633    Int lpRef = getSlice()->getColRefIdx();
     4634#else
     4635    Int lpRef = 0;
     4636#endif
     4637    if( m_pcSlice->getViewId() == getSlice()->getRefPic( eRefPicList, lpRef)->getViewId() )
     4638    {
     4639      if (uiViewIdxCurr > 1) 
     4640      {
     4641        if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) )
     4642        {
     4643          clipMv(cColMv);
     4644          pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
     4645          pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
     4646          return ;
     4647        }
     4648      }
     4649      for(UInt uiLoopVert = 0; uiLoopVert <= uiPUVert; uiLoopVert+=4)
     4650        for( uiIdx = uiPUHorStart; uiIdx <= uiPUHorEnd; uiIdx +=4 )
     4651        {
     4652          uiAbsPartAddr = g_auiRasterToZscan[uiIdx+uiNumPartInCUWidth*uiLoopVert];
     4653          if ( uiLCUIdx >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetViewIdx, iTStartViewIdx ) )
     4654          {
     4655            clipMv(cColMv);
     4656            pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
     4657            pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
     4658            return ;
     4659          }
     4660        }
     4661        for(UInt uiIdx_y = 0; uiIdx_y <uiNumPartInCUHeight; uiIdx_y +=4 )
     4662          for(UInt uiIdx_X = 0; uiIdx_X <uiNumPartInCUWidth; uiIdx_X +=4 )
     4663          {
     4664            uiIdx = uiIdx_X + uiIdx_y * uiNumPartInCUWidth;
     4665            uiAbsPartAddr = g_auiRasterToZscan[uiIdx];
     4666            if ( uiLCUIdx >= 0 && xGetColDisMV( eRefPicList,  lpRef, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetViewIdx, iTStartViewIdx ) )
     4667            {
     4668              clipMv(cColMv);
     4669              pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
     4670              pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
     4671              return ;
     4672            }
     4673          }
     4674          if (uiViewIdxCurr == 1) 
     4675          {
     4676            if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) )
     4677            {
     4678              clipMv(cColMv);
     4679              pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
     4680              pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
     4681              return ;
     4682            }
     4683          }
     4684    }
     4685    getSlice()->getRefPic( eRefPicList, lpRef)->setCandPicCheckedFlag(1);
     4686  }
     4687  {
     4688    //check the remaining reference pictures in list0 and list1
     4689    if(getSlice()->isInterB())
     4690    {
     4691      if(getSlice()->getNumRefIdx(RefPicList(0))< getSlice()->getNumRefIdx(RefPicList(1)))
     4692        MaxRef = getSlice()->getNumRefIdx(RefPicList(1));
     4693    }
     4694    for(Int lpRef = 0; lpRef < MaxRef; lpRef++)
     4695    {
     4696      for(Int lpNr = 0; lpNr < (getSlice()->isInterB() ? 2: 1); lpNr ++)
     4697      {
     4698        eRefPicList = RefPicList(0);
     4699        if(getSlice()->isInterB())
     4700          eRefPicList = RefPicList(lpNr==0 ? (getSlice()->getColDir()): (1-getSlice()->getColDir()));
     4701        if(getSlice()->getRefPic( eRefPicList, lpRef)->getCandPicCheckedFlag())
     4702          continue;
     4703       
     4704        if(lpRef >= getSlice()->getNumRefIdx(eRefPicList)||(m_pcSlice->getViewId() != getSlice()->getRefPic( eRefPicList, lpRef)->getViewId()))
     4705          continue;
     4706        if (uiViewIdxCurr > 1 )
     4707        {
     4708          if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) )
     4709          {
     4710          clipMv(cColMv);
     4711          pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
     4712          pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
     4713          return ;
     4714          }
     4715        }
     4716        for(UInt uiLoopVert = 0; uiLoopVert <= uiPUVert; uiLoopVert += 4)
     4717          for( uiIdx = uiPUHorStart; uiIdx <= uiPUHorEnd; uiIdx += 4 )
     4718          {
     4719            uiAbsPartAddr = g_auiRasterToZscan[uiIdx+uiNumPartInCUWidth*uiLoopVert];
     4720            if ( uiLCUIdx >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetViewIdx, iTStartViewIdx ) )
     4721            {
     4722              clipMv(cColMv);
     4723              pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
     4724              pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
     4725              return ;
     4726            }
     4727          }
     4728        for(UInt uiIdx_y = 0; uiIdx_y <uiNumPartInCUHeight; uiIdx_y += 4 )
     4729          for(UInt uiIdx_X = 0; uiIdx_X <uiNumPartInCUWidth; uiIdx_X += 4 )
     4730          {
     4731            uiIdx = uiIdx_X + uiIdx_y * uiNumPartInCUWidth;
     4732            uiAbsPartAddr = g_auiRasterToZscan[uiIdx];
     4733            if ( uiLCUIdx >= 0 && xGetColDisMV( eRefPicList,  lpRef, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetViewIdx, iTStartViewIdx ) )
     4734            {
     4735              clipMv(cColMv);
     4736              pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
     4737              pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
     4738              return ;
     4739            }
     4740          }
     4741        if (uiViewIdxCurr == 1 )
     4742        {
     4743          if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) )
     4744          {
     4745            clipMv(cColMv);
     4746            pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
     4747            pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
     4748            return ;
     4749          }
     4750        }
     4751        getSlice()->getRefPic( eRefPicList, lpRef)->setCandPicCheckedFlag(1);
     4752      }//reference lists
     4753    }//reference indices
     4754  }//remaining pictures
     4755}
     4756
     4757#if LGE_DVMCP
     4758Void TComDataCU::getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr,DisInfo* pDInfo, Bool bMerge, RefPicList eRefPicList0, Int iRefIdx0 )
     4759{
     4760  PartSize eCUMode = getPartitionSize( uiPartAddr );
     4761  TComDataCU* pcTmpCU = NULL;
     4762  TComDataCU* pcCULeft = NULL;
     4763  pDInfo->iN = 0;
     4764
     4765  RefPicList eRefPicList = REF_PIC_LIST_0 ;
     4766  //-- Get Spatial MV
     4767  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
     4768  UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
     4769
     4770  Int   aiDvMcpDvCand[2][7] = {{0,},    {0,}}; // dummy, 5 spatial + 1 temporal, DV-MCP ÁÖº¯ ºí·°¿¡¼­ »ç¿ëµÈ DV¸¦ ÀúÀå
     4771  Bool  abDvMcpFlag  [2][7] = {{false,},{false,}};
     4772  //Int   aiRefPOC     [2][7] = {{-1,},{-1}}; // debug
     4773  TComMv cTmpMvPred, cMv;
     4774  Bool  bTmpIsSkipped = false;
     4775  Bool  bDvMcpIsFound = false;
     4776
     4777  deriveLeftRightTopIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT );
     4778  deriveLeftBottomIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLB );
     4779
     4780  UInt uiIdx = 0;
     4781#if MVP_AT_ENTROPYSLICE_BOUNDARY
     4782  pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false);
     4783#else
     4784  pcTmpCU = getPULeft(uiIdx, uiPartIdxLB);
     4785#endif
     4786
     4787  pcCULeft = pcTmpCU;
     4788  UInt uiLeftPartIdx = uiIdx;
     4789  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
     4790  {
     4791    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
     4792    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     4793    {
     4794      eRefPicList = RefPicList(iList);
     4795      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
     4796      if( refId >= 0)
     4797      {
     4798        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
     4799        if (refViewIdx!= m_pcSlice->getViewId()) // DCP
     4800        {
     4801          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4802          clipMv(cMvPred);
     4803          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     4804          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     4805          return;
     4806        }
     4807        else // MCP
     4808        {
     4809          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4810          if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped )
     4811          {
     4812            aiDvMcpDvCand[iList][DVFROM_LEFT] = cTmpMvPred.m_iDvMcpDispX;
     4813            abDvMcpFlag  [iList][DVFROM_LEFT] = true;
     4814            bDvMcpIsFound = true;
     4815          }
     4816        }
     4817      }
     4818    }
     4819  }
     4820
     4821#if MVP_AT_ENTROPYSLICE_BOUNDARY
     4822  pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true);
     4823#else
     4824  pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT);
     4825#endif
     4826
     4827  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
     4828  {
     4829    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
     4830    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     4831    {
     4832      eRefPicList = RefPicList(iList);
     4833      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
     4834      if( refId >= 0)
     4835      {
     4836        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
     4837        if (refViewIdx!= m_pcSlice->getViewId())
     4838        {
     4839          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4840          clipMv(cMvPred);
     4841          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     4842          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     4843          return;
     4844        }
     4845        else // MCP
     4846        {
     4847          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4848          if( cTmpMvPred.m_bDvMcp  && bTmpIsSkipped )
     4849          {
     4850            aiDvMcpDvCand[iList][DVFROM_ABOVE] = cTmpMvPred.m_iDvMcpDispX;
     4851            abDvMcpFlag  [iList][DVFROM_ABOVE] = true;
     4852            bDvMcpIsFound = true;
     4853          }
     4854        }
     4855      }
     4856    }
     4857  }
     4858
     4859#if MVP_AT_ENTROPYSLICE_BOUNDARY
     4860  pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, false, true);
     4861#else
     4862  pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, true, true);
     4863#endif
     4864  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
     4865  {
     4866    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
     4867    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     4868    {
     4869      eRefPicList = RefPicList(iList);
     4870      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
     4871      if( refId >= 0)
     4872      {
     4873        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
     4874        if (refViewIdx!= m_pcSlice->getViewId())
     4875        {
     4876          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4877          clipMv(cMvPred);
     4878          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     4879          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     4880          return;
     4881        }
     4882        else  // MCP
     4883        {
     4884          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4885          if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped )
     4886          {
     4887            aiDvMcpDvCand[iList][DVFROM_ABOVERIGHT] = cTmpMvPred.m_iDvMcpDispX;
     4888            abDvMcpFlag  [iList][DVFROM_ABOVERIGHT] = true;
     4889            bDvMcpIsFound = true;
     4890          }
     4891        }
     4892      }
     4893    }
     4894  }
     4895
     4896#if MVP_AT_ENTROPYSLICE_BOUNDARY
     4897  pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true, false);
     4898#else
     4899  pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB);
     4900#endif
     4901  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
     4902  {
     4903    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
     4904    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     4905    {
     4906      eRefPicList = RefPicList(iList);
     4907      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
     4908      if( refId >= 0)
     4909      {
     4910        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
     4911        if (refViewIdx!= m_pcSlice->getViewId())
     4912        {
     4913          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4914          clipMv(cMvPred);
     4915          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     4916          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     4917          return;
     4918        }
     4919        else // MCP
     4920        {
     4921          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4922          if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped )
     4923          {
     4924            aiDvMcpDvCand[iList][DVFROM_LEFTBELOW] = cTmpMvPred.m_iDvMcpDispX;
     4925            abDvMcpFlag  [iList][DVFROM_LEFTBELOW] = true;
     4926            bDvMcpIsFound = true;
     4927          }
     4928        }
     4929      }
     4930    }
     4931  }
     4932
     4933  // Above predictor search
     4934#if MVP_AT_ENTROPYSLICE_BOUNDARY
     4935  pcTmpCU = getPUAboveLeft(uiIdx, (m_uiAbsIdxInLCU + uiPartAddr), true, false, true);
     4936  assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr));
     4937#else
     4938  pcTmpCU = getPUAboveLeft(uiIdx, uiPartIdxLT, true, true, true);
     4939#endif
     4940  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
     4941  {
     4942    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
     4943    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     4944    {
     4945      eRefPicList = RefPicList(iList);
     4946      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
     4947      if( refId >= 0)
     4948      {
     4949        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
     4950        if (refViewIdx!= m_pcSlice->getViewId())
     4951        {
     4952          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4953          clipMv(cMvPred);
     4954          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
     4955          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
     4956          return;
     4957        }
     4958        else // MCP
     4959        {
     4960          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     4961          if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped )
     4962          {
     4963            aiDvMcpDvCand[iList][DVFROM_ABOVELEFT] = cTmpMvPred.m_iDvMcpDispX;
     4964            abDvMcpFlag  [iList][DVFROM_ABOVELEFT] = true;
     4965            bDvMcpIsFound = true;
     4966          }
     4967        }
     4968      }
     4969    }
     4970  }
     4971
     4972  // copied from getInterMergeCand()
     4973  if ( getSlice()->getPPS()->getEnableTMVPFlag() )
     4974  {
     4975    UInt uiPUIdx = uiPartIdx;
     4976    UInt uiAbsPartAddr = uiPartAddr;
     4977
     4978    // col [2]
     4979    Int iRefIdxSkip[2] = {-1, -1};
     4980    if( !bMerge )
     4981    {
     4982      iRefIdxSkip[ eRefPicList0 ] = iRefIdx0;
     4983    }
     4984    else
     4985    {
     4986      for (Int i=0; i<2; i++)
     4987      {
     4988        RefPicList  eRefPicList1 = ( i==1 ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
     4989#if SET_MERGE_TMVP_REFIDX
     4990        Int iRefIdxTmp;
     4991        if ( uiPUIdx != 0 )
     4992        {
     4993          iRefIdxTmp = 0;
     4994        }
     4995        else
     4996        {   
     4997          iRefIdxTmp = (pcCULeft != NULL) ? pcCULeft->getCUMvField(eRefPicList1)->getRefIdx(uiLeftPartIdx) : -1;
     4998        }
     4999#else     
     5000        Int iRefIdxTmp = (pcCULeft != NULL) ? pcCULeft->getCUMvField(eRefPicList1)->getRefIdx(uiLeftPartIdx) : -1;
     5001#endif
     5002        iRefIdxSkip[i] = (iRefIdxTmp != -1) ? iRefIdxTmp : 0;
     5003      }
     5004    }
     5005
     5006    //>> MTK colocated-RightBottom
     5007    UInt uiPartIdxRB;
     5008    Int uiLCUIdx = getAddr();
     5009    eCUMode = getPartitionSize( 0 );
     5010
     5011    deriveRightBottomIdx( eCUMode, uiPUIdx, uiPartIdxRB ); 
     5012
     5013    UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
     5014    //UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
     5015
     5016    TComMv cColMv;
     5017    Int iRefIdx;
     5018
     5019    if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
     5020    {
     5021      uiLCUIdx = -1;
     5022    }
     5023    else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
     5024    {
     5025      uiLCUIdx = -1;
     5026    }
     5027    else
     5028    {
     5029      if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
     5030        ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
     5031      {
     5032        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
     5033        uiLCUIdx = getAddr();
     5034      }
     5035      else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
     5036      {
     5037        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
     5038        uiLCUIdx = -1 ;
     5039      }
     5040      else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
     5041      {
     5042        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
     5043        uiLCUIdx = getAddr() + 1;
     5044      }
     5045      else //is the right bottom corner of LCU                       
     5046      {
     5047        uiAbsPartAddr = 0;
     5048        uiLCUIdx = -1 ;
     5049      }
     5050    }
     5051
     5052    Bool bExistMV = false;
     5053    UInt uiPartIdxCenter;
     5054    UInt uiCurLCUIdx = getAddr();
     5055    xDeriveCenterIdx( eCUMode, uiPUIdx, uiPartIdxCenter );
     5056
     5057    Int iTargetView, iStartView;
     5058    if( !bMerge ) // AMVP
     5059    {
     5060      bExistMV = uiLCUIdx >= 0 && xGetColDisMV( eRefPicList0, iRefIdx0, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetView, iStartView );
     5061      if( bExistMV == false )
     5062      {
     5063        bExistMV = xGetColDisMV( eRefPicList0, iRefIdx0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iTargetView, iStartView );
     5064      }
     5065      if( bExistMV ) // DV is found
     5066      {
     5067        if( cColMv.m_bDvMcp == false ) //=> DCP, if true => DV-MCP
     5068        {
     5069          clipMv(cColMv);
     5070          pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
     5071          pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetView;
     5072          return;
     5073        }
     5074        else // DV-MCP
     5075        {
     5076          aiDvMcpDvCand[eRefPicList0][DVFROM_COL] = cColMv.getHor();
     5077          abDvMcpFlag  [eRefPicList0][DVFROM_COL] = true;
     5078          bDvMcpIsFound = true;
     5079        }
     5080      }
     5081    }
     5082    else // MERGE
     5083    {
     5084      iRefIdx = iRefIdxSkip[0];
     5085      bExistMV = uiLCUIdx >= 0 && xGetColDisMV( REF_PIC_LIST_0, iRefIdx, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetView, iStartView );
     5086      if( bExistMV == false )
     5087      {
     5088        bExistMV = xGetColDisMV( REF_PIC_LIST_0, iRefIdx, uiCurLCUIdx, uiPartIdxCenter,  cColMv, iTargetView, iStartView );
     5089      }
     5090      if( bExistMV )
     5091      {
     5092        if( cColMv.m_bDvMcp == false ) // DCP
     5093        {
     5094          clipMv(cColMv);
     5095          pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
     5096          pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetView;
     5097          return;
     5098        }
     5099        else { // // DV-MCP
     5100          aiDvMcpDvCand[0][DVFROM_COL] = cColMv.getHor();
     5101          abDvMcpFlag  [0][DVFROM_COL] = true;
     5102          bDvMcpIsFound = true;
     5103        };
     5104
     5105        if ( getSlice()->isInterB() )
     5106        {       
     5107          iRefIdx = iRefIdxSkip[1];
     5108          bExistMV = uiLCUIdx >= 0 && xGetColDisMV( REF_PIC_LIST_1, iRefIdx, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetView, iStartView );
     5109          if( bExistMV == false )
     5110          {
     5111            bExistMV = xGetColDisMV( REF_PIC_LIST_1, iRefIdx, uiCurLCUIdx, uiPartIdxCenter,  cColMv, iTargetView, iStartView );
     5112          }
     5113          if( bExistMV )
     5114          {
     5115            if( cColMv.m_bDvMcp == false ) // DCP
     5116            {
     5117              clipMv(cColMv);
     5118              pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
     5119              pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetView;
     5120              return;
     5121            }
     5122            else // DV-MCP
     5123            {
     5124              aiDvMcpDvCand[1][DVFROM_COL] = cColMv.getHor();
     5125              abDvMcpFlag  [1][DVFROM_COL] = true;
     5126              bDvMcpIsFound = true;
     5127            };
     5128          }
     5129        }
     5130      }
     5131    }
     5132  } // if TMVP Flag
     5133
     5134  if( bDvMcpIsFound ) // skip dvmcp
     5135  {
     5136    for( Int i=1 ; i<7 ; i++ ) // 5 spatial + 1 temporal
     5137    {
     5138      for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
     5139      {
     5140        if( abDvMcpFlag[iList][i]==true )
     5141        {
     5142          TComMv dv( aiDvMcpDvCand[iList][ i ], 0 );
     5143          clipMv( dv );
     5144          pDInfo->m_acMvCand[ pDInfo->iN  ] = dv;
     5145          pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0;
     5146          return;
     5147        }
     5148
     5149      }
     5150    }
     5151  }
     5152
     5153  return;
     5154
     5155}
     5156#endif
     5157
     5158#endif
    42765159
    42775160/** Constructs a list of candidates for AMVP
     
    42955178  }
    42965179 
     5180#if QC_MULTI_DIS_CAN
     5181  DisInfo cDisInfo;
     5182  cDisInfo.iN = 0;
     5183  if(m_pcSlice->getSPS()->getViewId() && m_pcSlice->getSPS()->getMultiviewMvPredMode())
     5184  {
     5185#if LGE_DVMCP
     5186    getDisMvpCand2(uiPartIdx, uiPartAddr, &cDisInfo, false, eRefPicList, iRefIdx );
     5187#else
     5188    getDisMvpCand (uiPartIdx, uiPartAddr, &cDisInfo );
     5189#endif
     5190  }
     5191  if(cDisInfo.iN==0)
     5192  {
     5193    cDisInfo.iN = 1;
     5194    cDisInfo.m_acMvCand[0].setHor(0);
     5195    cDisInfo.m_acMvCand[0].setVer(0);
     5196    cDisInfo.m_aVIdxCan[0] = 0;
     5197  }
     5198#endif
    42975199#if HHI_INTER_VIEW_MOTION_PRED
    42985200#if ( PDM_AMVP_POS == 0 )
    42995201  // get inter-view mv predictor (at position 0)
    43005202  TComMv  cPdmMvPred;
     5203#if QC_MULTI_DIS_CAN
     5204  if( getPdmMvPredDisCan( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred, &cDisInfo ) )
     5205#else
    43015206  if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) )
     5207#endif
    43025208  {
    43035209    clipMv( cPdmMvPred );
     
    43545260  // get inter-view mv predictor (at position 1)
    43555261  TComMv  cPdmMvPred;
     5262#if QC_MULTI_DIS_CAN
     5263  if( getPdmMvPredDisCan( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred, &cDisInfo ) )
     5264#else
    43565265  if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) )
     5266#endif
    43575267  {
    43585268    clipMv( cPdmMvPred );
     
    44025312  // get inter-view mv predictor (at position 2)
    44035313  TComMv  cPdmMvPred;
     5314#if QC_MULTI_DIS_CAN
     5315  if( getPdmMvPredDisCan( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred, &cDisInfo ) )
     5316#else
    44045317  if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) )
     5318#endif
    44055319  {
    44065320    clipMv( cPdmMvPred );
     
    44185332    }
    44195333  }
     5334#if  QC_MULTI_DIS_CAN
     5335  if ( getSlice()->getViewId()!=0 && pInfo->iN == 3 )
     5336  {
     5337    if ( pInfo->m_acMvCand[ 1 ] == pInfo->m_acMvCand[ 2 ] )
     5338    {
     5339      pInfo->iN = 2;
     5340      if( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] )
     5341        pInfo->iN = 1;
     5342    }
     5343    else
     5344    {
     5345      if( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] )
     5346      {
     5347        pInfo->m_acMvCand[1 ] = pInfo->m_acMvCand[ 2 ];
     5348        pInfo->iN = 2;
     5349      }
     5350      else if (pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 2 ])
     5351      {
     5352         pInfo->iN = 2;
     5353      }
     5354    }
     5355  }
     5356#endif
    44205357#endif
    44215358
     
    44885425  // get inter-view mv predictor (at position 3)
    44895426  TComMv  cPdmMvPred;
     5427#if QC_MULTI_DIS_CAN
     5428  if( getPdmMvPredDisCan( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred, &cDisInfo ) )
     5429#else
    44905430  if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) )
     5431#endif
    44915432  {
    44925433    clipMv( cPdmMvPred );
     
    46745615  {
    46755616    TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
    4676    
     5617#if LGE_DVMCP
     5618    cMvPred.m_bDvMcp = false;
     5619#endif
    46775620    pInfo->m_acMvCand[ pInfo->iN++] = cMvPred;
    46785621    return true;
     
    47095652    {
    47105653      TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
     5654#if LGE_DVMCP
     5655      cMvPred.m_bDvMcp = false;
     5656#endif
    47115657      pInfo->m_acMvCand[ pInfo->iN++] = cMvPred;
    47125658      return true;
     
    48405786  Int iNeibRefPOC;
    48415787
    4842 #if HHI_FIX
    48435788  if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 )
    48445789  {
     
    48495794    {
    48505795      TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
    4851 
     5796#if LGE_DVMCP
     5797      cMvPred.m_bDvMcp = false;
     5798#endif
    48525799      clipMv(cMvPred);
    48535800      pInfo->m_acMvCand[ pInfo->iN++] = cMvPred;
     
    48555802    }
    48565803  }
    4857 #endif
     5804
    48585805  //---------------  V1 (END) ------------------//
    48595806  if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0)
     
    48775824      rcMv = cMvPred.scaleMv( iScale );
    48785825    }
     5826#if LGE_DVMCP
     5827    rcMv.m_bDvMcp = false;
     5828#endif
    48795829    pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
    48805830    return true;
     
    49015851      rcMv = cMvPred.scaleMv( iScale );
    49025852    }
     5853#if LGE_DVMCP
     5854    rcMv.m_bDvMcp = false;
     5855#endif
    49035856    pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
    49045857    return true;
     
    49085861}
    49095862
     5863#if QC_MULTI_DIS_CAN
     5864Bool TComDataCU::xGetColDisMV( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx )
     5865{
     5866#if LGE_DVMCP
     5867  Int  iDvMcpDispX[2] = {-1,};
     5868  Bool bDvMcpFlag [2] = { false, };
     5869  Int iCurrViewIdx = m_pcSlice->getViewId();
     5870#endif
     5871
     5872  UInt uiAbsPartAddr = uiPartUnitIdx;
     5873
     5874  RefPicList  eColRefPicList = REF_PIC_LIST_0;
     5875  Int iColViewIdx, iColRefViewIdx;
     5876  TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx);
     5877  TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
     5878  iColViewIdx = pColCU->getSlice()->getViewId();
     5879
     5880
     5881  if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiAbsPartAddr))
     5882  {
     5883    return false;
     5884  }
     5885#if LGE_DVMCP
     5886  Bool bColIsSkipped = pColCU->isSkipped( uiAbsPartAddr );
     5887#endif
     5888  for (Int ilist = 0; ilist < (pColCU->getSlice()->isInterB()? 2:1); ilist++)
     5889  {
     5890    if(pColCU->getSlice()->isInterB())
     5891    {
     5892      if(ilist == 0 )
     5893        eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(1-getSlice()->getColDir());
     5894      else
     5895        eColRefPicList = getSlice()->getCheckLDC() ? (eRefPicList== REF_PIC_LIST_0? REF_PIC_LIST_1:REF_PIC_LIST_0 ): RefPicList(getSlice()->getColDir());
     5896    }
     5897
     5898    Int iColRefIdx = pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr);
     5899
     5900    if (iColRefIdx < 0)
     5901    {
     5902      continue;
     5903    }
     5904
     5905    iColRefViewIdx = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getViewId();
     5906
     5907    if ( iColViewIdx    == iColRefViewIdx ) // temporal vector
     5908    {
     5909#if LGE_DVMCP
     5910      if( iColViewIdx >0 )
     5911      {
     5912        TComMv tmpMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr);
     5913        if( tmpMv.m_bDvMcp && bColIsSkipped ) // DV-MCP SKIP
     5914        {
     5915          iDvMcpDispX[ilist] = tmpMv.m_iDvMcpDispX;
     5916          bDvMcpFlag [ilist] = true;
     5917          iTargetViewIdx  = 0; //iColRefViewIdx ;
     5918          iStartViewIdx   = 0; //iCurrViewIdx; //iColViewIdx   ;
     5919        }
     5920      }
     5921#endif
     5922      continue;
     5923    }
     5924    else
     5925    {
     5926      rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr);
     5927#if LGE_DVMCP
     5928      rcMv.m_bDvMcp = false;
     5929#endif
     5930      iTargetViewIdx  = iColRefViewIdx ;
     5931      iStartViewIdx   = iColViewIdx   ;
     5932      return true;   
     5933    }
     5934  }
     5935
     5936#if LGE_DVMCP
     5937  for( Int ilist=0 ; ilist<2 ; ilist++ )
     5938  {
     5939    if( bDvMcpFlag[ilist] )
     5940    {
     5941      rcMv.setHor( iDvMcpDispX[ilist] );
     5942      rcMv.setVer( 0 );
     5943      rcMv.m_bDvMcp = true;
     5944      iTargetViewIdx  = 0; //iColRefViewIdx ;
     5945      iStartViewIdx   = iCurrViewIdx; //iColViewIdx   ;
     5946      return true;
     5947    }
     5948  }
     5949#endif
     5950
     5951  return false;
     5952}
     5953#endif
    49105954/**
    49115955 * \param eRefPicList
     
    49846028  iColRefViewOrderIdx = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewOrderIdx();
    49856029#else
    4986 #if HHI_FIX
    49876030  if( pColCU->getSlice()->getRefViewId( eColRefPicList, iColRefIdx ) != pColCU->getSlice()->getViewId() )
    4988 #else
    4989   if( pColCU->getSlice()->getRefViewId( eColRefPicList, iColRefIdx ) != m_pcSlice->getRefPic( eRefPicList, riRefIdx )->getViewId() )
    4990 #endif
    49916031  {
    49926032    return false;
     
    50046044  else if((iColPOC == iColRefPOC)&&(iCurrPOC == iCurrRefPOC))
    50056045    iScale = xGetDistScaleFactor(iCurrViewOrderIdx, iCurrRefViewOrderIdx, iColViewOrderIdx, iColRefViewOrderIdx);
    5006 #if HHI_FIX //GT: fix reported by Sony
    50076046  else
    50086047    return false;
    5009 #endif
     6048
    50106049#else
    50116050  iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC);
     
    59516990// -------------------------------------------------------------------------------------------------------------------
    59526991#if HHI_INTER_VIEW_MOTION_PRED
     6992#if !QC_MULTI_DIS_CAN
    59536993Int
    59546994TComDataCU::getPdmMergeCandidate( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv )
     
    59677007  return pcDepthMapGenerator->getPdmMvPred( this, uiPartIdx, eRefPicList, iRefIdx, rcMv, bMerge );
    59687008}
     7009#else
     7010Int
     7011TComDataCU::getPdmMergeCandidateDisCan( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo )
     7012{
     7013  TComDepthMapGenerator* pcDepthMapGenerator = m_pcSlice->getSPS()->getDepthMapGenerator();
     7014  ROFRS( pcDepthMapGenerator, 0 );
     7015  return pcDepthMapGenerator->getPdmMergeCandidate( this, uiPartIdx, paiPdmRefIdx, pacPdmMv, pDInfo );
     7016}
     7017Bool
     7018TComDataCU::getPdmMvPredDisCan( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge )
     7019{
     7020  TComDepthMapGenerator* pcDepthMapGenerator = m_pcSlice->getSPS()->getDepthMapGenerator();
     7021  ROFRS( pcDepthMapGenerator, false );
     7022  if (pDInfo->iN > 0 && pcDepthMapGenerator->getDisCanPdmMvPred(this, uiPartIdx, eRefPicList, iRefIdx, rcMv, pDInfo, bMerge )) //bug fix li
     7023    return true;
     7024  return false;
     7025}
     7026#endif
    59697027
    59707028
     
    59887046  TComResidualGenerator*  pcResidualGenerator = m_pcSlice->getSPS()->getResidualGenerator();
    59897047  ROFRS( pcResidualGenerator, false );
     7048#if QC_MULTI_DIS_CAN
     7049  DisInfo cDisInfo;
     7050  cDisInfo.iN = 0;
     7051  PartSize m_peSaved =  getPartitionSize( 0 );
     7052  m_pePartSize[0] =  SIZE_2Nx2N;
     7053#if LGE_DVMCP
     7054  getDisMvpCand2( 0, 0,  &cDisInfo, true );
     7055#else
     7056  getDisMvpCand        ( 0, 0,  &cDisInfo );
     7057#endif
     7058  if( cDisInfo.iN == 0)
     7059  {
     7060    m_pePartSize[0] = m_peSaved;
     7061    return false;
     7062  }
     7063  else
     7064  {
     7065    Bool bAvailable = pcResidualGenerator->getResidualSamples( this, uiPartIdx, pcYuv, cDisInfo.m_acMvCand[0].getHor()
     7066#if QC_SIMPLIFIEDIVRP_M24938
     7067      , bRecon
     7068#endif
     7069      );
     7070    m_pePartSize[0] = m_peSaved;
     7071    return bAvailable;
     7072  }
     7073#else
    59907074  return pcResidualGenerator->getResidualSamples( this, uiPartIdx, pcYuv
    59917075#if QC_SIMPLIFIEDIVRP_M24938
     
    59937077#endif
    59947078    );
    5995 }
     7079#endif
     7080}
     7081#endif
     7082
     7083#if LGE_EDGE_INTRA
     7084Void TComDataCU::reconPartition( UInt uiAbsPartIdx, UInt uiDepth, Bool bLeft, UChar ucStartPos, UChar ucNumEdge, UChar* pucEdgeCode, Bool* pbRegion )
     7085{
     7086  Int iWidth;
     7087  Int iHeight;
     7088  if( uiDepth == 0 )
     7089  {
     7090    iWidth = 64;
     7091    iHeight = 64;
     7092  }
     7093  else if( uiDepth == 1 )
     7094  {
     7095    iWidth = 32;
     7096    iHeight = 32;
     7097  }
     7098  else if( uiDepth == 2 )
     7099  {
     7100    iWidth = 16;
     7101    iHeight = 16;
     7102  }
     7103  else if( uiDepth == 3 )
     7104  {
     7105    iWidth = 8;
     7106    iHeight = 8;
     7107  }
     7108  else // uiDepth == 4
     7109  {
     7110    iWidth = 4;
     7111    iHeight = 4;
     7112  }
     7113
     7114  Int iPtr = 0;
     7115  Int iX, iY;
     7116  Int iDir = -1;
     7117  Int iDiffX = 0, iDiffY = 0;
     7118
     7119  // 1. Edge Code -> Vert & Horz Edges
     7120  Bool*  pbEdge = (Bool*) xMalloc( Bool, 4 * iWidth * iHeight );
     7121
     7122  for( UInt ui = 0; ui < 4 * iWidth * iHeight; ui++ )
     7123    pbEdge  [ ui ] = false;
     7124
     7125  // Direction : left(0), right(1), top(2), bottom(3), left-top(4), right-top(5), left-bottom(6), right-bottom(7)
     7126  // Code      : 0deg(0), 45deg(1), -45deg(2), 90deg(3), -90deg(4), 135deg(5), -135deg(6)
     7127  const UChar tableDir[8][7] = { { 0, 6, 4, 3, 2, 7, 5 },
     7128  { 1, 5, 7, 2, 3, 4, 6 },
     7129  { 2, 4, 5, 0, 1, 6, 7 },
     7130  { 3, 7, 6, 1, 0, 5, 4 },
     7131  { 4, 0, 2, 6, 5, 3, 1 },
     7132  { 5, 2, 1, 4, 7, 0, 3 },
     7133  { 6, 3, 0, 7, 4, 1, 2 },
     7134  { 7, 1, 3, 5, 6, 2, 0 }};
     7135
     7136  UChar ucCode = pucEdgeCode[iPtr++];
     7137
     7138  if( !bLeft )
     7139  {
     7140    iX = ucStartPos;
     7141    iY = 0;
     7142
     7143    switch(ucCode)
     7144    {
     7145    case 0: // bottom
     7146      iDir = 3;
     7147      if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7148      break;
     7149    case 2: // left-bottom
     7150      iDir = 6;
     7151      if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7152      break;
     7153    case 1: // right-bottom
     7154      iDir = 7;
     7155      if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7156      if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7157      break;
     7158    case 4: // left
     7159      iDir = 0;
     7160      assert(false);
     7161      break;
     7162    case 3: // right
     7163      iDir = 1;
     7164      if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7165      if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7166      break;
     7167    }
     7168  }
     7169  else
     7170  {
     7171    iX = 0;
     7172    iY = ucStartPos;
     7173
     7174    switch(ucCode)
     7175    {
     7176    case 0: // right
     7177      iDir = 1;
     7178      if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7179      break;
     7180    case 1: // right-top
     7181      iDir = 5;
     7182      if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7183      if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7184      break;
     7185    case 2: // right-bottom
     7186      iDir = 7;
     7187      if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7188      break;
     7189    case 3: // top
     7190      iDir = 2;
     7191      if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7192      if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7193      break;
     7194    case 4: // bottom
     7195      iDir = 3;
     7196      assert(false);
     7197      break;
     7198    }
     7199  }
     7200
     7201  switch( iDir )
     7202  {
     7203  case 0: // left
     7204    iDiffX = -1;
     7205    iDiffY = 0;
     7206    break;
     7207  case 1: // right
     7208    iDiffX = +1;
     7209    iDiffY = 0;
     7210    break;
     7211  case 2: // top
     7212    iDiffX = 0;
     7213    iDiffY = -1;
     7214    break;
     7215  case 3: // bottom
     7216    iDiffX = 0;
     7217    iDiffY = +1;
     7218    break;
     7219  case 4: // left-top
     7220    iDiffX = -1;
     7221    iDiffY = -1;
     7222    break;
     7223  case 5: // right-top
     7224    iDiffX = +1;
     7225    iDiffY = -1;
     7226    break;
     7227  case 6: // left-bottom
     7228    iDiffX = -1;
     7229    iDiffY = +1;
     7230    break;
     7231  case 7: // right-bottom
     7232    iDiffX = +1;
     7233    iDiffY = +1;
     7234    break;
     7235  }
     7236
     7237  iX += iDiffX;
     7238  iY += iDiffY;
     7239
     7240  while( iPtr < ucNumEdge )
     7241  {
     7242    ucCode = pucEdgeCode[iPtr++];
     7243
     7244    Int iNewDir = tableDir[iDir][ucCode];
     7245
     7246    switch( iNewDir )
     7247    {
     7248    case 0: // left
     7249      iDiffX = -1;
     7250      iDiffY = 0;
     7251      break;
     7252    case 1: // right
     7253      iDiffX = +1;
     7254      iDiffY = 0;
     7255      break;
     7256    case 2: // top
     7257      iDiffX = 0;
     7258      iDiffY = -1;
     7259      break;
     7260    case 3: // bottom
     7261      iDiffX = 0;
     7262      iDiffY = +1;
     7263      break;
     7264    case 4: // left-top
     7265      iDiffX = -1;
     7266      iDiffY = -1;
     7267      break;
     7268    case 5: // right-top
     7269      iDiffX = +1;
     7270      iDiffY = -1;
     7271      break;
     7272    case 6: // left-bottom
     7273      iDiffX = -1;
     7274      iDiffY = +1;
     7275      break;
     7276    case 7: // right-bottom
     7277      iDiffX = +1;
     7278      iDiffY = +1;
     7279      break;
     7280    }
     7281
     7282    switch( iDir )
     7283    {
     7284    case 0: // left
     7285      switch( ucCode )
     7286      {
     7287      case 0:
     7288      case 2:
     7289        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
     7290        break;
     7291      case 1:
     7292      case 3:
     7293        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
     7294        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7295        break;
     7296      case 4:
     7297      case 6:
     7298        // no
     7299        break;
     7300      case 5:
     7301        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
     7302        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7303        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7304        break;
     7305      }
     7306      break;
     7307    case 1: // right
     7308      switch( ucCode )
     7309      {
     7310      case 0:
     7311      case 2:
     7312        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7313        break;
     7314      case 1:
     7315      case 3:
     7316        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7317        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7318        break;
     7319      case 4:
     7320      case 6:
     7321        // no
     7322        break;
     7323      case 5:
     7324        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
     7325        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7326        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7327        break;
     7328      }
     7329      break;
     7330    case 2: // top
     7331      switch( ucCode )
     7332      {
     7333      case 0:
     7334      case 2:
     7335        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7336        break;
     7337      case 1:
     7338      case 3:
     7339        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
     7340        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7341        break;
     7342      case 4:
     7343      case 6:
     7344        // no
     7345        break;
     7346      case 5:
     7347        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
     7348        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7349        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7350        break;
     7351      }
     7352      break;
     7353    case 3: // bottom
     7354      switch( ucCode )
     7355      {
     7356      case 0:
     7357      case 2:
     7358        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7359        break;
     7360      case 1:
     7361      case 3:
     7362        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7363        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7364        break;
     7365      case 4:
     7366      case 6:
     7367        // no
     7368        break;
     7369      case 5:
     7370        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7371        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7372        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7373        break;
     7374      }
     7375      break;
     7376    case 4: // left-top
     7377      switch( ucCode )
     7378      {
     7379      case 0:
     7380      case 1:
     7381        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
     7382        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7383        break;
     7384      case 2:
     7385      case 4:
     7386        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7387        break;
     7388      case 3:
     7389      case 5:
     7390        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
     7391        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7392        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7393        break;
     7394      case 6:
     7395        // no
     7396        break;
     7397      }
     7398      break;
     7399    case 5: // right-top
     7400      switch( ucCode )
     7401      {
     7402      case 0:
     7403      case 1:
     7404        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7405        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7406        break;
     7407      case 2:
     7408      case 4:
     7409        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7410        break;
     7411      case 3:
     7412      case 5:
     7413        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
     7414        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7415        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7416        break;
     7417      case 6:
     7418        // no
     7419        break;
     7420      }
     7421      break;
     7422    case 6: // left-bottom
     7423      switch( ucCode )
     7424      {
     7425      case 0:
     7426      case 1:
     7427        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
     7428        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7429        break;
     7430      case 2:
     7431      case 4:
     7432        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
     7433        break;
     7434      case 3:
     7435      case 5:
     7436        if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true;
     7437        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7438        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7439        break;
     7440      case 6:
     7441        // no
     7442        break;
     7443      }
     7444      break;
     7445    case 7: // right-bottom
     7446      switch( ucCode )
     7447      {
     7448      case 0:
     7449      case 1:
     7450        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7451        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7452        break;
     7453      case 2:
     7454      case 4:
     7455        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7456        break;
     7457      case 3:
     7458      case 5:
     7459        if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true;
     7460        if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true;
     7461        if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true;
     7462        break;
     7463      case 6:
     7464        // no
     7465        break;
     7466      }
     7467      break;
     7468    }
     7469
     7470    assert( iX >= 0 && iX <= iWidth );
     7471    assert( iY >= 0 && iY <= iHeight );
     7472
     7473    iX += iDiffX;
     7474    iY += iDiffY;
     7475    iDir = iNewDir;
     7476  }
     7477
     7478  // finalize edge chain
     7479  if( iX == iWidth-1 )
     7480  {
     7481    if( iY == 0 )
     7482    {
     7483      if( iDir == 1 )
     7484      {
     7485        pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
     7486      }
     7487      else if( iDir == 5 )
     7488      {
     7489        pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
     7490      }
     7491      else
     7492      {
     7493        assert(false);
     7494      }
     7495    }
     7496    else if( iY == iHeight-1 )
     7497    {
     7498      if( iDir == 3 )
     7499      {
     7500        pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
     7501      }
     7502      else if( iDir == 7 )
     7503      {
     7504        pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
     7505      }
     7506      else
     7507      {
     7508        assert(false);
     7509      }
     7510    }
     7511    else
     7512    {
     7513      if( iDir == 1 )
     7514      {
     7515        pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
     7516      }
     7517      else if( iDir == 3 )
     7518      {
     7519        pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
     7520        pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
     7521      }
     7522      else if( iDir == 5 )
     7523      {
     7524        pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
     7525      }
     7526      else if( iDir == 7 )
     7527      {
     7528        pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
     7529        pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
     7530      }
     7531      else
     7532      {
     7533        assert(false);
     7534      }
     7535    }
     7536  }
     7537  else if( iX == 0 )
     7538  {
     7539    if( iY == 0 )
     7540    {
     7541      if( iDir == 2 )
     7542      {
     7543        pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
     7544      }
     7545      else if( iDir == 4 )
     7546      {
     7547        pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
     7548      }
     7549      else
     7550      {
     7551        assert(false);
     7552      }
     7553    }
     7554    else if( iY == iHeight-1 )
     7555    {
     7556      if( iDir == 0 )
     7557      {
     7558        pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
     7559      }
     7560      else if( iDir == 6 )
     7561      {
     7562        pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
     7563      }
     7564      else
     7565      {
     7566        assert(false);
     7567      }
     7568    }
     7569    else
     7570    {
     7571      if( iDir == 0 )
     7572      {
     7573        pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
     7574      }
     7575      else if( iDir == 2 )
     7576      {
     7577        pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
     7578        pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
     7579      }
     7580      else if( iDir == 4 )
     7581      {
     7582        pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
     7583        pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
     7584      }
     7585      else if( iDir == 6 )
     7586      {
     7587        pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
     7588      }
     7589      else
     7590      {
     7591        assert(false);
     7592      }
     7593    }
     7594  }
     7595  else if( iY == 0 )
     7596  {
     7597    if( iDir == 1 )
     7598    {
     7599      pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
     7600      pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
     7601    }
     7602    else if( iDir == 2 )
     7603    {
     7604      pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
     7605    }
     7606    else if( iDir == 4 )
     7607    {
     7608      pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
     7609    }
     7610    else if( iDir == 5 )
     7611    {
     7612      pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true;
     7613      pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true;
     7614    }
     7615    else
     7616    {
     7617      assert(false);
     7618    }
     7619  }
     7620  else if( iY == iHeight-1 )
     7621  {
     7622    if( iDir == 0 )
     7623    {
     7624      pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
     7625      pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
     7626    }
     7627    else if( iDir == 3 )
     7628    {
     7629      pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
     7630    }
     7631    else if( iDir == 6 )
     7632    {
     7633      pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true;
     7634      pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
     7635    }
     7636    else if( iDir == 7 )
     7637    {
     7638      pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true;
     7639    }
     7640    else
     7641    {
     7642      assert(false);
     7643    }
     7644  }
     7645  else
     7646  {
     7647    printf("xPredIntraEdge: wrong termination\n");
     7648    assert(false);
     7649  }
     7650
     7651  // Reconstruct Region from Chain Code
     7652  Bool* pbVisit  = (Bool*) xMalloc( Bool, iWidth * iHeight );
     7653  Int*  piStack  = (Int* ) xMalloc( Int,  iWidth * iHeight );
     7654
     7655  for( UInt ui = 0; ui < iWidth * iHeight; ui++ )
     7656  {
     7657    pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next)
     7658    pbVisit [ ui ] = false;
     7659  }
     7660
     7661  iPtr = 0;
     7662  piStack[iPtr++] = (0 << 8) | (0);
     7663  pbRegion[ 0 ] = false;
     7664
     7665  while(iPtr > 0)
     7666  {
     7667    Int iTmp = piStack[--iPtr];
     7668    Int iX1, iY1;
     7669    iX1 = iTmp & 0xff;
     7670    iY1 = (iTmp >> 8) & 0xff;
     7671
     7672    pbVisit[ iX1 + iY1 * iWidth ] = true;
     7673
     7674    assert( iX1 >= 0 && iX1 < iWidth );
     7675    assert( iY1 >= 0 && iY1 < iHeight );
     7676
     7677    if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] )
     7678    {
     7679      piStack[iPtr++] = (iY1 << 8) | (iX1 - 1);
     7680      pbRegion[ iX1 - 1 + iY1 * iWidth ] = false;
     7681    }
     7682    if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] )
     7683    {
     7684      piStack[iPtr++] = (iY1 << 8) | (iX1 + 1);
     7685      pbRegion[ iX1 + 1 + iY1 * iWidth ] = false;
     7686    }
     7687    if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] )
     7688    {
     7689      piStack[iPtr++] = ((iY1 - 1) << 8) | iX1;
     7690      pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false;
     7691    }
     7692    if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] )
     7693    {
     7694      piStack[iPtr++] = ((iY1 + 1) << 8) | iX1;
     7695      pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false;
     7696    }
     7697  }
     7698
     7699  xFree( pbEdge );
     7700  xFree( pbVisit );
     7701  xFree( piStack );
     7702}
     7703
    59967704#endif
    59977705
  • trunk/source/Lib/TLibCommon/TComDataCU.h

    r77 r100  
    214214#endif
    215215
     216#if LGE_EDGE_INTRA
     217  UChar*        m_pucEdgeCode;          ///< array of edge code
     218  UChar*        m_pucEdgeNumber;        ///< total number of edge
     219  UChar*        m_pucEdgeStartPos;      ///< starting point position
     220  Bool*         m_pbEdgeLeftFirst;      ///< true if edge should be checked in left boundary first
     221  Bool*         m_pbEdgePartition;      ///< true if it belongs to region 1, otherwise, region 0
     222#if LGE_EDGE_INTRA_DELTA_DC
     223  Int*          m_piEdgeDeltaDC0;
     224  Int*          m_piEdgeDeltaDC1;
     225#endif
     226#endif
     227
    216228  // -------------------------------------------------------------------------------------------------------------------
    217229  // misc. variables
     
    256268  Void          deriveRightBottomIdx        ( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxRB );
    257269  Bool          xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx );
     270#if QC_MULTI_DIS_CAN
     271  Bool          xGetColDisMV( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
     272#endif
    258273 
    259274#if !AMVP_PRUNING_SIMPLIFICATION
     
    503518
    504519#if HHI_INTER_VIEW_MOTION_PRED
     520#if !QC_MULTI_DIS_CAN
    505521  Int           getPdmMergeCandidate( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv );
    506522  Bool          getPdmMvPred( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, Bool bMerge = false );
     523#else
     524  Bool          getPdmMvPredDisCan( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge = false );
     525  Int           getPdmMergeCandidateDisCan( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo );
     526  Void          getDisMvpCand        ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDInfo );
     527#if LGE_DVMCP
     528  Void          getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDInfo, Bool bMerge=false, RefPicList eRefPicList=REF_PIC_LIST_X, Int iRefIdx=-1 );
     529#endif
     530
     531#endif
    507532  Bool          getIViewOrgDepthMvPred( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv );
    508533#endif
     
    659684  UInt          getEntropySliceStartCU  ( UInt pos )                  { return m_uiEntropySliceStartCU[pos-m_uiAbsIdxInLCU];                                                                                   }
    660685  UInt&         getTotalBins            ()                            { return m_uiTotalBins;                                                                                                  }
     686
     687#if LGE_EDGE_INTRA
     688  UInt          getCtxEdgeIntra ( UInt uiAbsPartIdx );
     689#endif
     690
    661691  // -------------------------------------------------------------------------------------------------------------------
    662692  // member functions for RD cost storage
     
    734764  Void  setContourPredTexDeltaDC2SubParts ( Int iDC2, UInt uiAbsPartIdx, UInt uiDepth );
    735765#endif
     766
     767#if LGE_EDGE_INTRA
     768  UChar*        getEdgeCode( UInt uiIdx )                 { return &m_pucEdgeCode[uiIdx * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4]; }
     769  UChar*        getEdgeNumber( )                          { return m_pucEdgeNumber;           }
     770  UChar         getEdgeNumber( UInt uiIdx )               { return m_pucEdgeNumber[uiIdx];    }
     771  Void          setEdgeNumber( UInt uiIdx, UChar val )    { m_pucEdgeNumber[uiIdx] = val;     }
     772  UChar*        getEdgeStartPos( )                        { return m_pucEdgeStartPos;         }
     773  UChar         getEdgeStartPos( UInt uiIdx )             { return m_pucEdgeStartPos[uiIdx];  }
     774  Void          setEdgeStartPos( UInt uiIdx, UChar val )  { m_pucEdgeStartPos[uiIdx] = val;   }
     775  Bool*         getEdgeLeftFirst( )                       { return m_pbEdgeLeftFirst;         }
     776  Bool          getEdgeLeftFirst( UInt uiIdx )            { return m_pbEdgeLeftFirst[uiIdx];  }
     777  Void          setEdgeLeftFirst( UInt uiIdx, Bool val )  { m_pbEdgeLeftFirst[uiIdx] = val;   }
     778  Bool*         getEdgePartition( UInt uiIdx )              { return &m_pbEdgePartition[uiIdx * 16]; }
     779  Void          reconPartition( UInt uiAbsPartIdx, UInt uiDepth, Bool bLeft, UChar ucStartPos, UChar ucNumEdge, UChar* pucEdgeCode, Bool* pbRegion );
     780
     781#if LGE_EDGE_INTRA_DELTA_DC
     782  Int*          getEdgeDeltaDC0( )                          { return m_piEdgeDeltaDC0; }
     783  Int*          getEdgeDeltaDC1( )                          { return m_piEdgeDeltaDC1; }
     784  Int           getEdgeDeltaDC0( UInt uiIdx )               { return m_piEdgeDeltaDC0[uiIdx]; }
     785  Int           getEdgeDeltaDC1( UInt uiIdx )               { return m_piEdgeDeltaDC1[uiIdx]; }
     786  Void          setEdgeDeltaDC0( UInt uiIdx, Int val )      { m_piEdgeDeltaDC0[uiIdx] = val;  }
     787  Void          setEdgeDeltaDC1( UInt uiIdx, Int val )      { m_piEdgeDeltaDC1[uiIdx] = val;  }
     788#endif
     789#endif
    736790};
    737791
  • trunk/source/Lib/TLibCommon/TComDepthMapGenerator.cpp

    r77 r100  
    7878  m_uiSubSampExpX       = uiSubSampExpX;
    7979  m_uiSubSampExpY       = uiSubSampExpY;
     80#if !QC_MULTI_DIS_CAN
    8081  m_ppcYuv              = new TComYuv*    [ m_uiMaxDepth ];
    8182  m_ppcCU               = new TComDataCU* [ m_uiMaxDepth ];
     
    9192  m_cTmpPic.create( uiPicWidth >> m_uiSubSampExpX, uiPicHeight >> m_uiSubSampExpY, uiMaxCUWidth >> m_uiSubSampExpX, uiMaxCUHeight >> m_uiSubSampExpY, uiMaxCUDepth );
    9293  xSetChroma( &m_cTmpPic, ( 1 << uiOrgBitDepth ) >> 1 );
     94#endif
    9395  m_bCreated    = true;
    9496}
     
    100102  {
    101103    m_bCreated    = false;
     104#if !QC_MULTI_DIS_CAN
    102105    for( UInt uiDepth = 0; uiDepth < m_uiMaxDepth; uiDepth++ )
    103106    {
     
    114117    delete [] m_ppcCU;  m_ppcCU  = 0;
    115118    m_cTmpPic.destroy();
     119#endif
    116120    m_uiMaxDepth          = 0;
    117121    m_uiOrgDepthBitDepth  = 0;
     
    163167  m_bPDMAvailable = false;
    164168  m_uiCurrViewId  = pcPic->getSPS()->getViewId();
    165 
     169#if PDM_REMOVE_DEPENDENCE
     170  pcPic->setStoredPDMforV2(0);
     171#endif
    166172  // update SPS list and AU pic list and set depth map generator in SPS
    167173#if VIDYO_VPS_INTEGRATION
     
    218224  if( m_uiCurrViewId )
    219225  {
     226#if PDM_REMOVE_DEPENDENCE
     227    UInt      uiBaseVId   = m_auiBaseIdList[0];
     228#else
    220229    Bool      bCheckVId1  = ( m_uiCurrViewId > 1 && m_auiBaseIdList[0] == 0 );
    221230    UInt      uiBaseVId   = ( bCheckVId1 ? 1 : m_auiBaseIdList[0] );
     231#endif
    222232    TComPic*  pcBasePic   = m_pcAUPicAccess->getPic( uiBaseVId );
    223233    SliceType eSliceType  = pcBasePic->getCurrSlice()->getSliceType();
     
    367377}
    368378
    369 
     379#if !QC_MULTI_DIS_CAN
    370380Bool
    371381TComDepthMapGenerator::predictDepthMap( TComPic* pcPic )
     
    398408        pcBasePic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(m_pcSPSAccess->getPdm()), PDM_SUB_SAMP_EXP_Y(m_pcSPSAccess->getPdm()) );
    399409        xClearDepthMap( pcBasePic );
     410#if PDM_REMOVE_DEPENDENCE
     411        xClearDepthMap( pcBasePic, PDM_UNDEFINED_DEPTH, 1 );
     412#endif
    400413      }
    401414#if PDM_OUTPUT_PRED_DEPTH_MAP
     
    442455  {
    443456    xClearDepthMap( pcPic );
     457#if PDM_REMOVE_DEPENDENCE
     458    xClearDepthMap( pcPic, PDM_UNDEFINED_DEPTH, 1 );
     459#endif
    444460  }
    445461  return bUndefined;
     
    463479
    464480  // predict depth map using current coding symbols
     481#if PDM_REMOVE_DEPENDENCE
     482  pcPic->setStoredPDMforV2(0);
     483  xPredictDepthMap( pcPic );
     484  if(m_uiCurrViewId==0)
     485  {
     486    pcPic->setStoredPDMforV2(1);
     487    xPredictDepthMap( pcPic );
     488    pcPic->setStoredPDMforV2(0);
     489  }
     490#else
    465491  xPredictDepthMap( pcPic );
    466492#if PDM_OUTPUT_PRED_DEPTH_MAP
     
    469495    dumpDepthMap( pcPic, acFilenameBase );
    470496  }
     497#endif
    471498#endif
    472499
     
    481508#endif
    482509  }
     510#if PDM_REMOVE_DEPENDENCE
     511  if( m_uiCurrViewId == 2 )
     512  {
     513    TComPic* pcBasePic = m_pcAUPicAccess->getPic( 0 );
     514    AOF( pcBasePic );
     515    xConvertDepthMapCurr2Ref( pcBasePic, pcPic );
     516#if PDM_OUTPUT_PRED_DEPTH_MAP
     517    dumpDepthMap( pcBasePic, acFilenameBase );
     518#endif
     519  }
     520#endif
    483521}
    484522
     
    501539  Int         iSrcStride  = pcPicYuv->getStride   ();
    502540  Int         iDstStride  = m_cTmpPic.getStride   ();
     541#if PDM_REMOVE_DEPENDENCE
     542  if(pcPic->getStoredPDMforV2())
     543     pcPicYuv    = pcPic->getPredDepthMapTemp();
     544#endif
    503545  Pel*        pSrcSamples = pcPicYuv->getLumaAddr ( 0 );
    504546  Pel*        pDstSamples = m_cTmpPic.getLumaAddr ( 0 );
     
    520562  m_cTmpPic.dump( acFilename, ( pcPic->getPOC() != 0 )  );
    521563}
    522 
     564#endif
    523565
    524566#if HHI_INTER_VIEW_MOTION_PRED
     
    563605
    564606#if HHI_INTER_VIEW_MOTION_PRED
     607#if QC_MULTI_DIS_CAN
     608Int
     609TComDepthMapGenerator::getPdmMergeCandidate( TComDataCU* pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo )
     610#else
    565611Int
    566612TComDepthMapGenerator::getPdmMergeCandidate( TComDataCU* pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv )
    567 {
     613#endif
     614{
     615#if MTK_INTERVIEW_MERGE_A0049
     616  AOF  ( m_bCreated && m_bInit );
     617
     618#if !QC_MULTI_DIS_CAN
     619  ROFRS( m_bPDMAvailable, 0 );
     620#endif
     621
     622  TComSlice*    pcSlice     = pcCU->getSlice ();
     623  TComSPS*      pcSPS       = pcSlice->getSPS();
     624  AOF  ( pcSPS->getViewId() == m_uiCurrViewId );
     625  Bool          bPdmMerge   = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE );
     626  ROTRS( !bPdmMerge, 0 );
     627
     628  Bool abPdmAvailable[2] = {false,false};
     629
     630  Int iValid = 0;
     631  Int iViewId = 0;
     632  for( UInt uiBId = 0; uiBId < m_uiCurrViewId && iValid==0; uiBId++ )
     633  {
     634    UInt        uiBaseId    = m_auiBaseIdList[ uiBId ];
     635    TComPic*    pcBasePic   = m_pcAUPicAccess->getPic( uiBaseId );
     636    for( Int iRefListId = 0; iRefListId < 2 && iValid==0; iRefListId++ )
     637    {
     638      RefPicList  eRefPicListTest = RefPicList( iRefListId );
     639      Int         iNumRefPics = pcSlice->getNumRefIdx( eRefPicListTest ) ;
     640      for( Int iRefIndex = 0; iRefIndex < iNumRefPics; iRefIndex++ )
     641      {
     642        if(pcBasePic->getPOC() == pcSlice->getRefPic( eRefPicListTest, iRefIndex )->getPOC()
     643          && pcBasePic->getViewId() == pcSlice->getRefPic( eRefPicListTest, iRefIndex )->getViewId())
     644        {
     645          iValid=1;
     646          iViewId = uiBaseId;
     647          break;
     648        }
     649      }
     650    }
     651  }
     652  if (iValid == 0)
     653    return 0;
     654
     655  //--- get base CU/PU and check prediction mode ---
     656  TComPic*    pcBasePic   = m_pcAUPicAccess->getPic( iViewId );
     657  TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
     658
     659#if QC_MULTI_DIS_CAN
     660  Int  iCurrPosX, iCurrPosY;
     661  UInt          uiPartAddr;
     662  Int           iWidth;
     663  Int           iHeight;
     664
     665  pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight );
     666  pcBaseRec->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
     667  iCurrPosX  += ( ( iWidth  - 1 ) >> 1 );
     668  iCurrPosY  += ( ( iHeight - 1 ) >> 1 );
     669
     670  Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (pDInfo->m_acMvCand[0].getHor() + 2 ) >> 2 ) );
     671  Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (pDInfo->m_acMvCand[0].getVer() + 2 ) >> 2 ));
     672  Int         iBaseCUAddr;
     673  Int         iBaseAbsPartIdx;
     674  pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
     675#else
     676  Int  iPrdDepth, iCurrPosX, iCurrPosY;
     677  Bool bAvailable  = xGetPredDepth( pcCU, uiPartIdx, iPrdDepth, &iCurrPosX, &iCurrPosY );
     678  AOF( bAvailable );
     679  TComPicYuv* pcBasePdm   = pcBasePic->getPredDepthMap();
     680  Int         iDisparity  = xGetDisparityFromVirtDepth( iViewId, iPrdDepth );
     681  Int         iShiftX     = m_uiSubSampExpX + 2;
     682  Int         iAddX       = ( 1 << iShiftX ) >> 1;
     683  Int         iBasePosX   = Clip3( 0, pcBasePdm->getWidth () - 1, iCurrPosX + ( ( iDisparity + iAddX ) >> iShiftX ) );
     684  Int         iBasePosY   = Clip3( 0, pcBasePdm->getHeight() - 1, iCurrPosY                               );
     685  Int         iBaseCUAddr;
     686  Int         iBaseAbsPartIdx;
     687  pcBaseRec->getCUAddrAndPartIdx( iBasePosX<< m_uiSubSampExpX , iBasePosY<< m_uiSubSampExpY , iBaseCUAddr, iBaseAbsPartIdx );
     688#endif
     689
     690  TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
     691
     692  if( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTER || pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_SKIP )
     693  {
     694    for( UInt uiBaseRefListId = 0; uiBaseRefListId < 2; uiBaseRefListId++ )
     695    {
     696      RefPicList  eBaseRefPicList = RefPicList( uiBaseRefListId );
     697      TComMvField cBaseMvField;
     698      pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
     699      Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
     700
     701      if (iBaseRefIdx >= 0)
     702      {
     703        Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
     704        if (iBaseRefPOC != pcSlice->getPOC())   
     705        {
     706          for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eBaseRefPicList ); iPdmRefIdx++)
     707          {
     708            if (iBaseRefPOC == pcSlice->getRefPOC(eBaseRefPicList, iPdmRefIdx))
     709            {
     710              abPdmAvailable[ uiBaseRefListId ] = true;
     711              paiPdmRefIdx  [ uiBaseRefListId ] = iPdmRefIdx;
     712              TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
     713#if LGE_DVMCP
     714              cMv.m_bDvMcp = true;
     715              cMv.m_iDvMcpDispX = pDInfo->m_acMvCand[0].getHor();
     716#endif
     717              pcCU->clipMv( cMv );
     718              pacPdmMv      [ uiBaseRefListId ] = cMv;
     719              break;
     720            }
     721          }
     722        }
     723      }
     724    }
     725  }
     726  Int iPdmInterDir = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 );
     727
     728  if (iPdmInterDir == 0)
     729  {
     730    for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ )
     731    {
     732      RefPicList  eRefPicList       = RefPicList( iRefListId );
     733      Int         iNumRefPics       = pcSlice->getNumRefIdx( eRefPicList );
     734      for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ )
     735{
     736        if( pcSlice->getRefPOC( eRefPicList, iPdmRefIdx ) == pcSlice->getPOC())
     737        {
     738          abPdmAvailable[ iRefListId ] = true;
     739          paiPdmRefIdx  [ iRefListId ] = iPdmRefIdx;
     740#if QC_MULTI_DIS_CAN
     741          TComMv cMv = pDInfo->m_acMvCand[0];
     742          cMv.setVer(0);
     743#else
     744          TComMv cMv(iDisparity, 0);
     745#endif
     746          pcCU->clipMv( cMv );
     747          pacPdmMv      [ iRefListId ] = cMv;
     748          break;
     749        }
     750      }
     751    }
     752    iPdmInterDir = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 ) ;
     753  }
     754
     755  return iPdmInterDir;
     756
     757#else
    568758  Int  iMaxNumInterPics  = 1;
    569759  Int  iMaxNumAllPics    = 2;
     
    580770      if( pcCU->getSlice()->getRefPOC( eRefPicList, iPdmRefIdx ) != pcCU->getSlice()->getPOC() )
    581771      {
     772#if QC_MULTI_DIS_CAN
     773        if( getDisCanPdmMvPred (pcCU, uiPartIdx, eRefPicList, iPdmRefIdx, cMv, pDInfo, true ) )       
     774#else
    582775        if( getPdmMvPred( pcCU, uiPartIdx, eRefPicList, iPdmRefIdx, cMv, true ) )
     776#endif
    583777        {
    584778          pcCU->clipMv( cMv );
     
    602796      for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ )
    603797      {
     798#if QC_MULTI_DIS_CAN
     799        if ( getDisCanPdmMvPred (pcCU, uiPartIdx, eRefPicList, iPdmRefIdx, cMv, pDInfo, true ) )
     800#else
    604801        if( getPdmMvPred( pcCU, uiPartIdx, eRefPicList, iPdmRefIdx, cMv, true ) )
     802#endif
    605803        {
    606804          pcCU->clipMv( cMv );
     
    615813  }
    616814  return iPdmInterDir;
    617 }
    618 
    619 
     815#endif
     816}
     817
     818#if QC_MULTI_DIS_CAN
     819Bool
     820TComDepthMapGenerator::getDisCanPdmMvPred    ( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge )
     821{
     822#if LGE_DVMCP
     823  rcMv.m_bDvMcp = false;
     824#endif
     825  AOF  ( m_bCreated && m_bInit );
     826  AOF  ( iRefIdx >= 0 );
     827  AOF  ( pcCU );
     828  //ROFRS( m_bPDMAvailable, false );
     829  TComSlice*    pcSlice     = pcCU->getSlice ();
     830  TComSPS*      pcSPS       = pcSlice->getSPS();
     831  AOF  ( pcSPS->getViewId() == m_uiCurrViewId );
     832  TComPic*      pcRefPic    = pcSlice->getRefPic( eRefPicList, iRefIdx );
     833  UInt          uiRefViewId = pcRefPic->getSPS()->getViewId();
     834  Int           iRefPoc     = pcRefPic->getPOC();
     835  Bool          bInterview  = ( uiRefViewId < m_uiCurrViewId );
     836  AOT(  bInterview && iRefPoc != pcSlice->getPOC() );
     837  AOT( !bInterview && iRefPoc == pcSlice->getPOC() );
     838  Bool          bPdmIView   = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_IVIEW ) == PDM_USE_FOR_IVIEW );
     839  Bool          bPdmInter   = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_INTER ) == PDM_USE_FOR_INTER );
     840  Bool          bPdmMerge   = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE );
     841  ROTRS( ( bInterview && !bMerge ) && !bPdmIView, false );
     842  ROTRS( (!bInterview && !bMerge ) && !bPdmInter, false );
     843  ROTRS(                  bMerge   && !bPdmMerge, false );
     844  Int  iCurrPosX, iCurrPosY;
     845  TComMv cDisMv;
     846
     847  if( bInterview )
     848  {
     849    rcMv = pDInfo->m_acMvCand[0];
     850    rcMv.setVer(0);
     851    return      true;
     852  }
     853  for( UInt uiBId = 0; uiBId < m_uiCurrViewId; uiBId++ )
     854  {
     855    UInt        uiBaseId    = uiBId;  //m_auiBaseIdList[ uiBId ];
     856
     857    if (m_uiCurrViewId >1 && uiBaseId ==1 )
     858      continue;
     859
     860    TComPic*    pcBasePic   = m_pcAUPicAccess->getPic( uiBaseId );
     861    TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
     862    UInt          uiPartAddr;
     863    Int           iWidth;
     864    Int           iHeight;
     865
     866    pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight );
     867    pcBaseRec->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
     868    iCurrPosX  += ( ( iWidth  - 1 ) >> 1 );
     869    iCurrPosY  += ( ( iHeight - 1 ) >> 1 );
     870    Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (pDInfo->m_acMvCand[0].getHor() + 2 ) >> 2 ) );
     871    Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (pDInfo->m_acMvCand[0].getVer() + 2 ) >> 2 )); 
     872    Int         iBaseCUAddr;
     873    Int         iBaseAbsPartIdx;
     874    pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
     875    TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
     876    if( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_INTER && pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_SKIP )
     877    {
     878      continue;
     879    }
     880    for( UInt uiBaseRefListId = 0; uiBaseRefListId < 2; uiBaseRefListId++ )
     881    {
     882      RefPicList  eBaseRefPicList = RefPicList( uiBaseRefListId );
     883      TComMvField cBaseMvField;
     884      pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
     885      Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
     886      Int         iBaseRefPoc     = ( iBaseRefIdx >= 0 ? pcBaseCU->getSlice()->getRefPic( eBaseRefPicList, iBaseRefIdx )->getPOC() : -(1<<30) );
     887      if( iBaseRefIdx >= 0 && iBaseRefPoc == iRefPoc )
     888      {
     889        rcMv.set( cBaseMvField.getHor(), cBaseMvField.getVer() );
     890#if LGE_DVMCP
     891        // save disparity vector when a merge candidate for IVMP is set as DV-MCP
     892        if( bMerge )
     893        {
     894          rcMv.m_bDvMcp = true;
     895          rcMv.m_iDvMcpDispX = pDInfo->m_acMvCand[0].getHor();
     896        }
     897        else { // AMVP ?
     898          rcMv.m_bDvMcp = false;
     899        }
     900#endif
     901        return true;
     902      }
     903    }
     904  }
     905  return false;
     906}
     907#else
    620908Bool 
    621909TComDepthMapGenerator::getPdmMvPred( TComDataCU* pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, Bool bMerge )
     
    664952    //--- get base CU/PU and check prediction mode ---
    665953    UInt        uiBaseId    = m_auiBaseIdList[ uiBId ];
     954#if PDM_REMOVE_DEPENDENCE
     955    if( uiBaseId != 0)
     956      continue;
     957#endif
    666958    TComPic*    pcBasePic   = m_pcAUPicAccess->getPic( uiBaseId );
    667959    TComPicYuv* pcBasePdm   = pcBasePic->getPredDepthMap();
     
    697989  return false;
    698990}
     991#endif
    699992
    700993
     
    7441037
    7451038
    746 
     1039#if !QC_MULTI_DIS_CAN
    7471040/*=======================================================*
    7481041 *=====                                             =====*
     
    7601053  AOF( pcRef->getPredDepthMap()->getWidth () == pcCur->getPredDepthMap()->getWidth () );
    7611054  AOF( pcRef->getPredDepthMap()->getHeight() == pcCur->getPredDepthMap()->getHeight() );
    762 
     1055#if PDM_REMOVE_DEPENDENCE
     1056  if( pcCur->getViewId() == 1)
     1057    xClearDepthMap( pcRef );
     1058  else if (pcCur->getViewId() == 2)
     1059    xClearDepthMap( pcRef, PDM_UNDEFINED_DEPTH, 1 );
     1060#else
    7631061  xClearDepthMap( pcRef );
     1062#endif
    7641063  TComPicYuv* pcCurDepthMap =  pcCur->getPredDepthMap    ();
    7651064  TComPicYuv* pcRefDepthMap =  pcRef->getPredDepthMap    ();
     
    7711070  Pel*        pRefSamples   =  pcRefDepthMap->getLumaAddr( 0 );
    7721071  Int         iRefViewIdx   =  pcRef->getViewId();
     1072#if PDM_REMOVE_DEPENDENCE
     1073  if( pcCur->getViewId() == 2)
     1074  {
     1075    pcRefDepthMap =  pcRef->getPredDepthMapTemp();
     1076    pRefSamples   =  pcRefDepthMap->getLumaAddr( 0 );
     1077  }
     1078#endif
    7731079  Int         iShiftX       = m_uiSubSampExpX + 2;
    7741080  Int         iAddX         = ( 1 << iShiftX ) >> 1;
     
    7991105  AOF( pcCur->getSPS()->getViewId()  > pcRef->getSPS()->getViewId() );
    8001106  AOF( pcCur->getPredDepthMap() );
     1107#if PDM_REMOVE_DEPENDENCE
     1108  if(pcCur->getViewId() == 1)
     1109  {
     1110    AOF( pcRef->getPredDepthMap() );
     1111  }else
     1112  {
     1113    AOF( pcRef->getPredDepthMapTemp() );
     1114  }
     1115#else
    8011116  AOF( pcRef->getPredDepthMap() );
     1117#endif
    8021118  AOF( pcRef->getPredDepthMap()->getWidth () == pcCur->getPredDepthMap()->getWidth () );
    8031119  AOF( pcRef->getPredDepthMap()->getHeight() == pcCur->getPredDepthMap()->getHeight() );
     
    8051121  xClearDepthMap( pcCur );
    8061122  TComPicYuv* pcRefDepthMap =  pcRef->getPredDepthMap    ();
     1123#if PDM_REMOVE_DEPENDENCE
     1124  if(pcCur->getViewId() == 2)
     1125    pcRefDepthMap =  pcRef->getPredDepthMapTemp        ();
     1126#endif
    8071127  TComPicYuv* pcCurDepthMap =  pcCur->getPredDepthMap    ();
    8081128  Int         iWidth        =  pcRefDepthMap->getWidth   ();
     
    8441164  }
    8451165  Bool    bUndefined = xFillDepthMapHoles( pcPic );
     1166#if PDM_REMOVE_DEPENDENCE
     1167  if(pcPic->getStoredPDMforV2() == 1){
     1168  pcPic->getPredDepthMapTemp()->setBorderExtension( false );
     1169  pcPic->getPredDepthMapTemp()->extendPicBorder   ();
     1170  }else{
     1171#endif
    8461172  pcPic->getPredDepthMap()->setBorderExtension( false );
    8471173  pcPic->getPredDepthMap()->extendPicBorder   ();
     1174#if PDM_REMOVE_DEPENDENCE
     1175  }
     1176#endif
    8481177  return  bUndefined;
    8491178}
     
    8551184  Bool        bUndefined  = false;     
    8561185  TComPicYuv* pcDepthMap  = pcPic->getPredDepthMap  ();
     1186#if PDM_REMOVE_DEPENDENCE
     1187  if(pcPic->getViewId()==0 && pcPic->getStoredPDMforV2()==1)
     1188    pcDepthMap  = pcPic->getPredDepthMapTemp  ();
     1189#endif
    8571190  Int         iWidth      = pcDepthMap->getWidth    ();
    8581191  Int         iHeight     = pcDepthMap->getHeight   ();
     
    8881221        {
    8891222          bUndefined = true;
    890                   break;
     1223          break;
    8911224        }
    8921225        iX = iE - 1;
     
    9131246
    9141247Void
    915 TComDepthMapGenerator::xClearDepthMap( TComPic* pcPic, Int iVal )
     1248TComDepthMapGenerator::xClearDepthMap( TComPic* pcPic, Int iVal
     1249#if PDM_REMOVE_DEPENDENCE
     1250,
     1251Int forFirstNonBaseView
     1252#endif
     1253)
    9161254{
    9171255  TComPicYuv* pcDepthMap  = pcPic->getPredDepthMap  ();
     
    9201258  Int         iStride     = pcDepthMap->getStride   ();
    9211259  Pel*        pDMSamples  = pcDepthMap->getLumaAddr ( 0 );
     1260#if PDM_REMOVE_DEPENDENCE
     1261  if( forFirstNonBaseView == 1)
     1262  {
     1263    pcDepthMap  = pcPic->getPredDepthMapTemp  ();
     1264    pDMSamples  = pcDepthMap->getLumaAddr ( 0 );
     1265  }
     1266#endif
    9221267  for( Int iY = 0; iY < iHeight; iY++, pDMSamples += iStride )
    9231268  {
     
    9891334  TComYuv*    pcSubDM   = m_ppcYuv[ uiDepth ];
    9901335  TComPicYuv* pcPicDM   = pcCU->getPic()->getPredDepthMap();
     1336#if PDM_REMOVE_DEPENDENCE
     1337  if( pcCU->getPic()->getStoredPDMforV2() == 1)
     1338    pcPicDM   = pcCU->getPic()->getPredDepthMapTemp();
     1339#endif
    9911340  UInt        uiCUAddr  = pcCU->getAddr();
    9921341  pcSubCU->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
     
    10751424    UInt  uiZOrderIdx     = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
    10761425    Pel*  pPicDepthMap    = pcCU->getPic()->getPredDepthMap()->getLumaAddr( pcCU->getAddr(), uiZOrderIdx );
     1426#if PDM_REMOVE_DEPENDENCE
     1427    if(pcCU->getPic()->getStoredPDMforV2()==1)
     1428      pPicDepthMap    = pcCU->getPic()->getPredDepthMapTemp()->getLumaAddr( pcCU->getAddr(), uiZOrderIdx );
     1429#endif
    10771430    Int   iPicStride      = pcCU->getPic()->getPredDepthMap()->getStride  ();
    10781431    for( UInt uiY = 0; uiY < uiHeight; uiY++, pDepthMap += uiStride, pPicDepthMap += iPicStride )
     
    15111864  return        true;
    15121865}
     1866#endif
    15131867
    15141868#endif // DEPTH_MAP_GENERATION
  • trunk/source/Lib/TLibCommon/TComDepthMapGenerator.h

    r77 r100  
    136136
    137137  Void  initViewComponent     ( TComPic*      pcPic );
     138#if !QC_MULTI_DIS_CAN
    138139  Bool  predictDepthMap       ( TComPic*      pcPic );
    139140  Void  updateDepthMap        ( TComPic*      pcPic );
    140141  Void  dumpDepthMap          ( TComPic*      pcPic, char* pFilenameBase );
     142#endif
    141143
    142144#if HHI_INTER_VIEW_MOTION_PRED
     
    149151  Int   getDisparity          ( TComPic*      pcPic, Int iPosX, Int iPosY, UInt uiRefViewId );
    150152#if HHI_INTER_VIEW_MOTION_PRED
     153#if QC_MULTI_DIS_CAN
     154  Int   getPdmMergeCandidate ( TComDataCU*   pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo );
     155  Bool  getPdmMvPredDisCan    ( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge );
     156  Bool  getDisCanPdmMvPred    ( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge );
     157#else
    151158  Int   getPdmMergeCandidate  ( TComDataCU*   pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv );
    152159  Bool  getPdmMvPred          ( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, Bool bMerge );
     160#endif
    153161  Bool  getIViewOrgDepthMvPred( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv );
    154162#endif
     
    163171private:
    164172  // picture operations
     173#if !QC_MULTI_DIS_CAN
    165174  Bool  xConvertDepthMapCurr2Ref  ( TComPic*    pcRef, TComPic* pcCur );
    166175  Bool  xConvertDepthMapRef2Curr  ( TComPic*    pcCur, TComPic* pcRef );
    167176  Bool  xPredictDepthMap          ( TComPic*    pcPic );
    168177  Bool  xFillDepthMapHoles        ( TComPic*    pcPic );
    169   Void  xClearDepthMap            ( TComPic*    pcPic, Int      iVal  = PDM_UNDEFINED_DEPTH );
     178  Void  xClearDepthMap            ( TComPic*    pcPic, Int      iVal  = PDM_UNDEFINED_DEPTH
     179#if PDM_REMOVE_DEPENDENCE
     180  ,
     181  Int forFirstNonBaseView = 0
     182#endif
     183  );
    170184  Void  xSetChroma                ( TComPicYuv* pcPic, Int      iVal  );
    171185
     
    182196  Void  xInterPUDepthMapPrediction( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiPartIdx );                      // PU inter prediction
    183197  Bool  xGetPredDepth             ( TComDataCU* pcCU, UInt uiPartIdx, Int& riPrdDepth, Int* piPosX = 0, Int* piPosY = 0 );
    184 
     198#endif
    185199  // conversion functions
    186200  Int   xGetVirtDepthFromDisparity( UInt uiBaseId, Int iDisparity )
  • trunk/source/Lib/TLibCommon/TComMotionInfo.h

    r56 r100  
    5959
    6060// ====================================================================================================================
     61#if QC_MULTI_DIS_CAN
     62typedef struct _DisCand
     63{
     64  TComMv m_acMvCand[ DIS_CANS ];            ///< array of motion vector predictor candidates
     65  Int    m_aVIdxCan[ DIS_CANS ];            ///< array of motion vector predictor candidates
     66  Int    iN;                                ///< number of motion vector predictor candidates
     67} DisInfo;
     68#endif
    6169// Class definition
    6270// ====================================================================================================================
  • trunk/source/Lib/TLibCommon/TComMv.h

    r56 r100  
    5757public:
    5858 
     59#if LGE_DVMCP
     60  Bool  m_bDvMcp;       // is dv-mcp ?
     61  Int   m_iDvMcpDispX;  // disparity for dv-mcp
     62#endif
     63
    5964  // ------------------------------------------------------------------------------------------------------------------
    6065  // constructors
     
    6469  m_iHor(0),
    6570  m_iVer(0)
     71#if LGE_DVMCP
     72  , m_bDvMcp(false)
     73  , m_iDvMcpDispX(0)
     74#endif
    6675  {
    6776  }
     
    7079  m_iHor(iHor),
    7180  m_iVer(iVer)
     81#if LGE_DVMCP
     82  , m_bDvMcp(false)
     83  , m_iDvMcpDispX(0)
     84#endif
    7285  {
    7386  }
  • trunk/source/Lib/TLibCommon/TComPattern.cpp

    r56 r100  
    675675{
    676676  Int* piSrc;
     677#if LGE_EDGE_INTRA
     678  mapEdgeIntratoDC( uiDirMode );
     679#endif
    677680  assert(log2BlkSize >= 2 && log2BlkSize < 7);
    678681#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
  • trunk/source/Lib/TLibCommon/TComPic.cpp

    r56 r100  
    5555#if DEPTH_MAP_GENERATION
    5656  m_pcPredDepthMap    = NULL;
     57#if PDM_REMOVE_DEPENDENCE
     58  m_pcPredDepthMap_temp    = NULL;
     59#endif
    5760#endif
    5861#if HHI_INTER_VIEW_MOTION_PRED
     
    136139    m_pcPredDepthMap = NULL;
    137140  }
     141#if PDM_REMOVE_DEPENDENCE
     142  if( m_pcPredDepthMap_temp )         //  estimated depth map
     143  {
     144    m_pcPredDepthMap_temp->destroy();
     145    delete m_pcPredDepthMap_temp;
     146    m_pcPredDepthMap_temp = NULL;
     147  }                     
     148#endif
    138149#endif
    139150#if HHI_INTER_VIEW_MOTION_PRED
     
    179190  m_pcPredDepthMap    = new TComPicYuv;
    180191  m_pcPredDepthMap    ->create( iWidth >> uiSubSampExpX, iHeight >> uiSubSampExpY, uiMaxCuWidth >> uiSubSampExpX, uiMaxCuHeight >> uiSubSampExpY, uiMaxCuDepth );
     192#if PDM_REMOVE_DEPENDENCE
     193  m_pcPredDepthMap_temp    = new TComPicYuv;
     194  m_pcPredDepthMap_temp    ->create( iWidth >> uiSubSampExpX, iHeight >> uiSubSampExpY, uiMaxCuWidth >> uiSubSampExpX, uiMaxCuHeight >> uiSubSampExpY, uiMaxCuDepth );
     195#endif
    181196}
    182197#endif
     
    224239    m_pcPredDepthMap = NULL;
    225240  }
     241#if PDM_REMOVE_DEPENDENCE
     242  if(m_pcPredDepthMap_temp)
     243  {
     244    m_pcPredDepthMap_temp->destroy();
     245    delete m_pcPredDepthMap_temp;
     246    m_pcPredDepthMap_temp = NULL;
     247  }
     248#endif
    226249}
    227250#endif
  • trunk/source/Lib/TLibCommon/TComPic.h

    r77 r100  
    6767#if DEPTH_MAP_GENERATION
    6868  TComPicYuv*           m_pcPredDepthMap;         //  estimated depth map
     69#if PDM_REMOVE_DEPENDENCE
     70  TComPicYuv*           m_pcPredDepthMap_temp;         //  estimated depth map
     71  Bool                  m_bPDMV2;                       
     72#endif
     73#endif
     74
     75#if LG_ZEROINTRADEPTHRESI_M26039
     76  Int                   m_uiIntraPeriod;
    6977#endif
    7078
    7179#if HHI_INTER_VIEW_MOTION_PRED
    7280  TComPicYuv*           m_pcOrgDepthMap;          //  original depth map
     81#if QC_MULTI_DIS_CAN
     82  Bool          m_checked;
     83#endif
    7384#endif
    7485#if HHI_INTER_VIEW_RESIDUAL_PRED
     
    123134  TComVPS*      getVPS()              { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getVPS();  }
    124135#endif
     136#if LG_ZEROINTRADEPTHRESI_M26039
     137  Int           getIntraPeriod()                           { return  m_uiIntraPeriod; }
     138  Void          setIntraPeriod(Int uiIntraPeriod)          { m_uiIntraPeriod = uiIntraPeriod; }
     139#endif
    125140  TComSPS*      getSPS()              { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getSPS();  }
    126141  Int           getPOC()              { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getPOC();  }
    127142  Int           getViewId()           { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getViewId(); }
    128   TComDataCU*&  getCU( UInt uiCUAddr )  { return  m_apcPicSym->getCU( uiCUAddr ); }
     143  TComDataCU*&  getCU( UInt uiCUAddr ){ return  m_apcPicSym->getCU( uiCUAddr ); }
    129144 
    130145  TComPicYuv*   getPicYuvOrg()        { return  m_apcPicYuv[0]; }
     
    136151#if DEPTH_MAP_GENERATION
    137152  TComPicYuv*   getPredDepthMap()     { return  m_pcPredDepthMap; }
    138 #endif
    139 
     153#if PDM_REMOVE_DEPENDENCE
     154  TComPicYuv*   getPredDepthMapTemp()           { return  m_pcPredDepthMap_temp; }
     155  Void          setStoredPDMforV2  (Bool flag)  { m_bPDMV2 = flag;}
     156  Bool          getStoredPDMforV2  ()           { return m_bPDMV2;}
     157#endif
     158
     159#endif
    140160#if HHI_INTER_VIEW_MOTION_PRED
    141161  TComPicYuv*   getOrgDepthMap()      { return  m_pcOrgDepthMap; }
     162#if QC_MULTI_DIS_CAN
     163  Void          setCandPicCheckedFlag (Bool bchecked)   { m_checked = bchecked; }
     164  Bool          getCandPicCheckedFlag ()                { return m_checked;}
     165#endif
    142166#endif
    143167
  • trunk/source/Lib/TLibCommon/TComPrediction.cpp

    r56 r100  
    4646// ====================================================================================================================
    4747
     48#if LGE_EDGE_INTRA
     49#define MAX_DISTANCE_EDGEINTRA 255
     50#endif
     51
    4852TComPrediction::TComPrediction()
    4953: m_pLumaRecBuffer(0)
     
    419423}
    420424
     425#if LGE_EDGE_INTRA
     426Void TComPrediction::predIntraLumaEdge ( TComDataCU* pcCU, TComPattern* pcTComPattern, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Pel* piPred, UInt uiStride, Bool bDelta )
     427{
     428  Pel *piDst = piPred;
     429  Int *piSrc;
     430  Int iSrcStride = ( iWidth<<1 ) + 1;
     431  Int iDstStride = uiStride;
     432
     433  piSrc = pcTComPattern->getPredictorPtr( 0, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt );
     434
     435  xPredIntraEdge ( pcCU, uiAbsPartIdx, iWidth, iHeight, piSrc, iSrcStride, piDst, iDstStride
     436#if LGE_EDGE_INTRA_DELTA_DC
     437    , bDelta
     438#endif
     439    );
     440}
     441
     442Pel  TComPrediction::xGetNearestNeighbor( Int x, Int y, Int* pSrc, Int srcStride, Int iWidth, Int iHeight, Bool* bpRegion )
     443{
     444  Bool bLeft = (x < y) ? true : false;
     445  Bool bFound = false;
     446  Int  iFoundX = -1, iFoundY = -1;
     447  Int  cResult = 0;
     448
     449  UChar* piTopDistance = new UChar[iWidth];
     450  UChar* piLeftDistance = new UChar[iHeight];
     451
     452  for( Int i = 0; i < iWidth; i++ )
     453  {
     454    int Abs = x > i ? x - i : i - x;
     455    piTopDistance[ i ] = y + Abs;
     456
     457    Abs = y > i ? y - i : i - y;
     458    piLeftDistance[ i ] = x + Abs;
     459  }
     460
     461  for( Int dist = 0; dist < MAX_DISTANCE_EDGEINTRA && !bFound; dist++ )
     462  {
     463    if( !bLeft )
     464    {
     465      for( Int i = 0; i < iWidth; i++ )
     466      {
     467        if( piTopDistance[ i ] == dist )
     468        {
     469          if( bpRegion[ i ] == bpRegion[ x + y * iWidth ] )
     470          {
     471            iFoundX = i;
     472            iFoundY = 0;
     473            bFound = true;
     474          }
     475        }
     476      }
     477      for( Int i = 0; i < iHeight; i++ )
     478      {
     479        if( piLeftDistance[ i ] == dist )
     480        {
     481          if( bpRegion[ i * iWidth ] == bpRegion[ x + y * iWidth ] )
     482          {
     483            iFoundX = 0;
     484            iFoundY = i;
     485            bFound = true;
     486          }
     487        }
     488      }
     489    }
     490    else
     491    {
     492      for( Int i = 0; i < iHeight; i++ )
     493      {
     494        if( piLeftDistance[ i ] == dist )
     495        {
     496          if( bpRegion[ i * iWidth ] == bpRegion[ x + y * iWidth ] )
     497          {
     498            iFoundX = 0;
     499            iFoundY = i;
     500            bFound = true;
     501          }
     502        }
     503      }
     504      for( Int i = 0; i < iWidth; i++ )
     505      {
     506        if( piTopDistance[ i ] == dist )
     507        {
     508          if( bpRegion[ i ] == bpRegion[ x + y * iWidth ] )
     509          {
     510            iFoundX = i;
     511            iFoundY = 0;
     512            bFound = true;
     513          }
     514        }
     515      }
     516    }
     517  }
     518
     519  if( iFoundY == 0 )
     520  {
     521    cResult = pSrc[ iFoundX + 1 ];
     522  }
     523  else // iFoundX == 0
     524  {
     525    cResult = pSrc[ (iFoundY + 1) * srcStride ];
     526  }
     527
     528  delete[] piTopDistance;  piTopDistance = NULL;
     529  delete[] piLeftDistance; piLeftDistance = NULL;
     530
     531  assert( bFound );
     532
     533  return cResult;
     534}
     535
     536Void TComPrediction::xPredIntraEdge( TComDataCU* pcCU, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, Bool bDelta )
     537{
     538  Pel* pDst = rpDst;
     539  Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx );
     540
     541  // Do prediction
     542  {
     543    //UInt uiSum0 = 0, uiSum1 = 0;
     544    Int iSum0 = 0, iSum1 = 0;
     545    //UInt uiMean0, uiMean1;
     546    Int iMean0, iMean1;
     547    //UInt uiCount0 = 0, uiCount1 = 0;
     548    Int iCount0 = 0, iCount1 = 0;
     549    for( UInt ui = 0; ui < iWidth; ui++ )
     550    {
     551      if( pbRegion[ ui ] == false )
     552      {
     553        iSum0 += (pSrc[ ui + 1 ]);
     554        iCount0++;
     555      }
     556      else
     557      {
     558        iSum1 += (pSrc[ ui + 1 ]);
     559        iCount1++;
     560      }
     561    }
     562    for( UInt ui = 0; ui < iHeight; ui++ ) // (0,0) recount (to avoid division)
     563    {
     564      if( pbRegion[ ui * iWidth ] == false )
     565      {
     566        iSum0 += (pSrc[ (ui + 1) * srcStride ]);
     567        iCount0++;
     568      }
     569      else
     570      {
     571        iSum1 += (pSrc[ (ui + 1) * srcStride ]);
     572        iCount1++;
     573      }
     574    }
     575    if( iCount0 == 0 )
     576      assert(false);
     577    if( iCount1 == 0 )
     578      assert(false);
     579    iMean0 = iSum0 / iCount0; // TODO : integer op.
     580    iMean1 = iSum1 / iCount1;
     581#if LGE_EDGE_INTRA_DELTA_DC
     582    if( bDelta )
     583    {
     584      Int iDeltaDC0 = pcCU->getEdgeDeltaDC0( uiAbsPartIdx );
     585      Int iDeltaDC1 = pcCU->getEdgeDeltaDC1( uiAbsPartIdx );
     586      xDeltaDCQuantScaleUp( pcCU, iDeltaDC0 );
     587      xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );
     588      iMean0 = Clip( iMean0 + iDeltaDC0 );
     589      iMean1 = Clip( iMean1 + iDeltaDC1 );
     590    }
     591#endif
     592    for( UInt ui = 0; ui < iHeight; ui++ )
     593    {
     594      for( UInt uii = 0; uii < iWidth; uii++ )
     595      {
     596        if( pbRegion[ uii + ui * iWidth ] == false )
     597          pDst[ uii + ui * dstStride ] = iMean0;
     598        else
     599          pDst[ uii + ui * dstStride ] = iMean1;
     600      }
     601    }
     602  }
     603}
     604#endif
     605
    421606#if DEPTH_MAP_GENERATION
    422607Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY )
     
    569754  {
    570755    UInt uiRShift = 0;
    571     xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 );
     756#if PDM_REMOVE_DEPENDENCE
     757    if( pcCU->getPic()->getStoredPDMforV2() == 1 )
     758      xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMapTemp(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 );
     759    else
     760#endif
     761      xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 );
     762
    572763    return;
    573764  }
  • trunk/source/Lib/TLibCommon/TComPrediction.h

    r56 r100  
    125125#endif
    126126
     127#if LGE_EDGE_INTRA
     128  Pel  xGetNearestNeighbor  ( Int x, Int y, Int* pSrc, Int srcStride, Int iWidth, Int iHeight, Bool* bpRegion );
     129  Void xPredIntraEdge       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, Bool bDelta = false );
     130#endif
     131
    127132public:
    128133  TComPrediction();
     
    170175  Bool  getWedgePatternIdx      ( WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe );
    171176#endif
     177#if LGE_EDGE_INTRA
     178  Void predIntraLumaEdge          ( TComDataCU* pcCU, TComPattern* pcTComPattern, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Pel* piPred, UInt uiStride, Bool bDelta = false );
     179#endif
    172180
    173181  // simplified intra pred for "virtual" depth maps
  • trunk/source/Lib/TLibCommon/TComRdCost.cpp

    r81 r100  
    4545//! \{
    4646
     47#if SAIT_VSO_EST_A0033
     48Double TComRdCost::m_dDisparityCoeff = 1.0;
     49#endif
     50
    4751TComRdCost::TComRdCost()
    4852{
     
    232236  m_afpDistortFunc[28] = TComRdCost::xGetHADs;
    233237 
     238#if SAIT_VSO_EST_A0033
     239  m_afpDistortFunc[29]  = TComRdCost::xGetVSD;
     240  m_afpDistortFunc[30]  = TComRdCost::xGetVSD4;
     241  m_afpDistortFunc[31]  = TComRdCost::xGetVSD8;
     242  m_afpDistortFunc[32]  = TComRdCost::xGetVSD16;
     243  m_afpDistortFunc[33]  = TComRdCost::xGetVSD32;
     244  m_afpDistortFunc[34]  = TComRdCost::xGetVSD64;
     245  m_afpDistortFunc[35]  = TComRdCost::xGetVSD16N;
     246#endif
     247
    234248#if !FIX203
    235249  m_puiComponentCostOriginP = NULL;
     
    248262  m_uiNumberRefPics         = 0;
    249263  m_bUseVSO                 = false;
     264#if SAIT_VSO_EST_A0033
     265  m_bUseEstimatedVSD        = false;
     266#endif
    250267  m_uiVSOMode               = 0;
    251268  m_fpDistortFuncVSO        = NULL;
     
    273290   
    274291    m_puiComponentCostOriginP = new UInt[ 4 * iSubPelSearchLimit ];
    275 #if HHI_FIX
    276292    m_puiMultiviewRegCostHorOrgP  = new UInt[ 4 * iSubPelSearchLimit ];
    277293    m_puiMultiviewRegCostVerOrgP  = new UInt[ 4 * iSubPelSearchLimit ];
    278 #endif
     294
    279295    iSubPelSearchLimit *= 2;
    280296   
    281297    m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit;
    282 #if HHI_FIX
     298
    283299    m_puiMultiviewRegCostHor = m_puiMultiviewRegCostHorOrgP + iSubPelSearchLimit;
    284300    m_puiMultiviewRegCostVer = m_puiMultiviewRegCostVerOrgP + iSubPelSearchLimit;
    285 #endif
     301
    286302   
    287303    for( Int n = -iSubPelSearchLimit; n < iSubPelSearchLimit; n++)
    288304    {
    289305      m_puiComponentCost[n] = xGetComponentBits( n );
    290 #if HHI_FIX
    291306      m_puiMultiviewRegCostHor[n] = xGetComponentBits( n );  // first version
    292307      m_puiMultiviewRegCostVer[n] = xGetComponentBits( n );  // first version
    293 #endif
    294308    }
    295309  }
     
    303317    m_puiComponentCostOriginP = NULL;
    304318  }
    305 #if HHI_FIX
     319
    306320  if( m_puiMultiviewRegCostHorOrgP )
    307321    {
     
    314328    m_puiMultiviewRegCostVerOrgP = NULL;
    315329  }
    316 #endif
    317330}
    318331#endif
     
    565578}
    566579
     580
     581#if SAIT_VSO_EST_A0033
     582UInt TComRdCost::getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, Pel* piVirRec, Pel* piVirOrg, Int iVirStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc )
     583{
     584  AOT( ( m_dDisparityCoeff <= 0 ) || ( m_dDisparityCoeff > 10 ) );
     585
     586  DistParam cDtParam;
     587  setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam );
     588  cDtParam.pOrg       = piOrg;
     589  cDtParam.pCur       = piCur;
     590  cDtParam.pVirRec    = piVirRec;
     591  cDtParam.pVirOrg    = piVirOrg;
     592  cDtParam.iStrideVir = iVirStride;
     593  cDtParam.iStrideOrg = iOrgStride;
     594  cDtParam.iStrideCur = iCurStride;
     595  cDtParam.iStep      = 1;
     596
     597  cDtParam.bApplyWeight = false;
     598  cDtParam.uiComp       = 255;    // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed.
     599
     600  return cDtParam.DistFunc( &cDtParam );
     601}
     602#endif
    567603
    568604
     
    20262062#endif
    20272063
     2064
     2065#if SAIT_VSO_EST_A0033
     2066UInt TComRdCost::getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride,  Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y )
     2067{
     2068  Double dD;
     2069  Int iTemp;
     2070
     2071  dD = ( (Double) ( dDM >> g_uiBitIncrement ) ) * m_dDisparityCoeff;
     2072
     2073  iTemp = (Int) ROUND( 0.5 * fabs(dD) * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) );
     2074
     2075  return (UInt) ( (iTemp*iTemp)>>1 );
     2076}
     2077
     2078UInt TComRdCost::xGetVSD( DistParam* pcDtParam )
     2079{
     2080  Pel* piOrg    = pcDtParam->pOrg;
     2081  Pel* piCur    = pcDtParam->pCur;
     2082  Pel* piVirRec = pcDtParam->pVirRec;
     2083  Pel* piVirOrg = pcDtParam->pVirOrg;
     2084  Int  iRows    = pcDtParam->iRows;
     2085  Int  iCols    = pcDtParam->iCols;
     2086  Int  iStrideOrg = pcDtParam->iStrideOrg;
     2087  Int  iStrideCur = pcDtParam->iStrideCur;
     2088  Int  iStrideVir = pcDtParam->iStrideVir;
     2089
     2090  UInt uiSum = 0;
     2091  UInt uiShift = g_uiBitIncrement<<1;
     2092
     2093  Int dDM;
     2094
     2095  for ( Int y = 0 ; y < iRows ; y++ )
     2096  {
     2097    for (Int x = 0; x < iCols; x++ )
     2098    {
     2099      dDM = (Int) ( piOrg[x  ] - piCur[x  ] );
     2100      uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
     2101    }
     2102    piOrg += iStrideOrg;
     2103    piCur += iStrideCur;
     2104  }
     2105
     2106  return ( uiSum );
     2107}
     2108
     2109UInt TComRdCost::xGetVSD4( DistParam* pcDtParam )
     2110{
     2111  Pel* piOrg   = pcDtParam->pOrg;
     2112  Pel* piCur   = pcDtParam->pCur;
     2113  Pel* piVirRec = pcDtParam->pVirRec;
     2114  Pel* piVirOrg = pcDtParam->pVirOrg;
     2115  Int  iRows   = pcDtParam->iRows;
     2116  Int  iStrideOrg = pcDtParam->iStrideOrg;
     2117  Int  iStrideCur = pcDtParam->iStrideCur;
     2118  Int  iStrideVir = pcDtParam->iStrideVir;
     2119
     2120  UInt uiSum = 0;
     2121  UInt uiShift = g_uiBitIncrement<<1;
     2122
     2123  Int dDM;
     2124
     2125  for ( Int y = 0 ; y < iRows ; y++ )
     2126  {
     2127    dDM = (Int) ( piOrg[0] - piCur[0] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 0, y ) ) >> uiShift;
     2128    dDM = (Int) ( piOrg[1] - piCur[1] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 1, y ) ) >> uiShift;
     2129    dDM = (Int) ( piOrg[2] - piCur[2] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 2, y ) ) >> uiShift;
     2130    dDM = (Int) ( piOrg[3] - piCur[3] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 3, y ) ) >> uiShift;
     2131
     2132    piOrg += iStrideOrg;
     2133    piCur += iStrideCur;
     2134  }
     2135
     2136  return ( uiSum );
     2137}
     2138
     2139UInt TComRdCost::xGetVSD8( DistParam* pcDtParam )
     2140{
     2141  Pel* piOrg   = pcDtParam->pOrg;
     2142  Pel* piCur   = pcDtParam->pCur;
     2143  Pel* piVirRec = pcDtParam->pVirRec;
     2144  Pel* piVirOrg = pcDtParam->pVirOrg;
     2145  Int  iRows   = pcDtParam->iRows;
     2146  Int  iStrideOrg = pcDtParam->iStrideOrg;
     2147  Int  iStrideCur = pcDtParam->iStrideCur;
     2148  Int  iStrideVir = pcDtParam->iStrideVir;
     2149
     2150  UInt uiSum = 0;
     2151  UInt uiShift = g_uiBitIncrement<<1;
     2152
     2153  Int dDM;
     2154
     2155  for ( Int y = 0 ; y < iRows ; y++ )
     2156  {
     2157    for (Int x = 0; x < 8; x++ )
     2158    {
     2159      dDM = (Int) ( piOrg[x] - piCur[x] );
     2160      uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
     2161    }
     2162    piOrg += iStrideOrg;
     2163    piCur += iStrideCur;
     2164  }
     2165
     2166  return ( uiSum );
     2167}
     2168
     2169UInt TComRdCost::xGetVSD16( DistParam* pcDtParam )
     2170{
     2171  Pel* piOrg   = pcDtParam->pOrg;
     2172  Pel* piCur   = pcDtParam->pCur;
     2173  Pel* piVirRec = pcDtParam->pVirRec;
     2174  Pel* piVirOrg = pcDtParam->pVirOrg;
     2175  Int  iRows   = pcDtParam->iRows;
     2176  Int  iStrideOrg = pcDtParam->iStrideOrg;
     2177  Int  iStrideCur = pcDtParam->iStrideCur;
     2178  Int  iStrideVir = pcDtParam->iStrideVir;
     2179
     2180  UInt uiSum = 0;
     2181  UInt uiShift = g_uiBitIncrement<<1;
     2182
     2183  Int dDM;
     2184
     2185  for ( Int y = 0 ; y < iRows ; y++ )
     2186  {
     2187    for (Int x = 0; x < 16; x++ )
     2188    {
     2189      dDM = (Int) ( piOrg[x] - piCur[x] );
     2190      uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
     2191    }
     2192    piOrg += iStrideOrg;
     2193    piCur += iStrideCur;
     2194  }
     2195
     2196  return ( uiSum );
     2197}
     2198
     2199UInt TComRdCost::xGetVSD16N( DistParam* pcDtParam )
     2200{
     2201  Pel* piOrg   = pcDtParam->pOrg;
     2202  Pel* piCur   = pcDtParam->pCur;
     2203  Pel* piVirRec = pcDtParam->pVirRec;
     2204  Pel* piVirOrg = pcDtParam->pVirOrg;
     2205  Int  iRows   = pcDtParam->iRows;
     2206  Int  iCols   = pcDtParam->iCols;
     2207  Int  iStrideOrg = pcDtParam->iStrideOrg;
     2208  Int  iStrideCur = pcDtParam->iStrideCur;
     2209  Int  iStrideVir = pcDtParam->iStrideVir;
     2210
     2211  UInt uiSum = 0;
     2212  UInt uiShift = g_uiBitIncrement<<1;
     2213
     2214  Int dDM;
     2215
     2216  for ( Int y = 0 ; y < iRows ; y++ )
     2217  {
     2218    for (Int x = 0; x < iCols; x+=16 )
     2219    {
     2220      for ( Int k = 0 ; k < 16 ; k++ )
     2221      {
     2222        dDM = (Int) ( piOrg[x+k] - piCur[x+k] );
     2223        uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x+k, y ) >> uiShift;
     2224      }
     2225    }
     2226    piOrg += iStrideOrg;
     2227    piCur += iStrideCur;
     2228  }
     2229
     2230  return ( uiSum );
     2231}
     2232
     2233UInt TComRdCost::xGetVSD32( DistParam* pcDtParam )
     2234{
     2235  Pel* piOrg   = pcDtParam->pOrg;
     2236  Pel* piCur   = pcDtParam->pCur;
     2237  Pel* piVirRec = pcDtParam->pVirRec;
     2238  Pel* piVirOrg = pcDtParam->pVirOrg;
     2239  Int  iRows   = pcDtParam->iRows;
     2240  Int  iStrideOrg = pcDtParam->iStrideOrg;
     2241  Int  iStrideCur = pcDtParam->iStrideCur;
     2242  Int  iStrideVir = pcDtParam->iStrideVir;
     2243
     2244  UInt uiSum = 0;
     2245  UInt uiShift = g_uiBitIncrement<<1;
     2246
     2247  Int dDM;
     2248
     2249  for ( Int y = 0 ; y < iRows ; y++ )
     2250  {
     2251    for (Int x = 0; x < 32 ; x++ )
     2252    {
     2253      dDM = (Int) ( piOrg[x] - piCur[x] );
     2254      uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
     2255    }
     2256    piOrg += iStrideOrg;
     2257    piCur += iStrideCur;
     2258  }
     2259
     2260  return ( uiSum );
     2261}
     2262
     2263UInt TComRdCost::xGetVSD64( DistParam* pcDtParam )
     2264{
     2265  Pel* piOrg      = pcDtParam->pOrg;
     2266  Pel* piCur      = pcDtParam->pCur;
     2267  Pel* piVirRec   = pcDtParam->pVirRec;
     2268  Pel* piVirOrg   = pcDtParam->pVirOrg;
     2269  Int  iRows      = pcDtParam->iRows;
     2270  Int  iStrideOrg = pcDtParam->iStrideOrg;
     2271  Int  iStrideCur = pcDtParam->iStrideCur;
     2272  Int  iStrideVir = pcDtParam->iStrideVir;
     2273
     2274  UInt uiSum = 0;
     2275  UInt uiShift = g_uiBitIncrement<<1;
     2276
     2277  Int dDM;
     2278
     2279  for ( Int y = 0 ; y < iRows ; y++ )
     2280  {
     2281    for (Int x = 0; x < 64; x++ )
     2282    {
     2283      dDM = (Int) ( piOrg[x] - piCur[x] );
     2284      uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
     2285    }
     2286    piOrg += iStrideOrg;
     2287    piCur += iStrideCur;
     2288  }
     2289
     2290  return ( uiSum );
     2291}
     2292
     2293#endif
     2294
    20282295// --------------------------------------------------------------------------------------------------------------------
    20292296// HADAMARD with step (used in fractional search)
     
    26682935{
    26692936  AOT(bSAD);
     2937#ifdef LGE_VSO_EARLY_SKIP_A0093
     2938  RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur, piOrg, iOrgStride); 
     2939#else
    26702940  RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur ); 
     2941#endif
    26712942
    26722943  RMDist iDistMin = (RMDist) RDO_DIST_MIN;
  • trunk/source/Lib/TLibCommon/TComRdCost.h

    r81 r100  
    8080  Int   iStrideOrg;
    8181  Int   iStrideCur;
     82#if SAIT_VSO_EST_A0033
     83  Pel*  pVirRec;
     84  Pel*  pVirOrg;
     85  Int   iStrideVir;
     86#endif
    8287  Int   iRows;
    8388  Int   iCols;
     
    105110    pOrg = NULL;
    106111    pCur = NULL;
     112#if SAIT_VSO_EST_A0033
     113    pVirRec = NULL;
     114    pVirOrg = NULL;;
     115    iStrideVir = 0;
     116#endif
    107117    iStrideOrg = 0;
    108118    iStrideCur = 0;
     
    145155  UInt                    m_uiLambdaMotionSSE;
    146156  Double                  m_dFrameLambda;
     157#if SAIT_VSO_EST_A0033
     158  static Double           m_dDisparityCoeff;
     159#endif
    147160 
    148161#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
     
    192205  Void    setFrameLambda ( Double dLambda ) { m_dFrameLambda = dLambda; }
    193206 
     207#if SAIT_VSO_EST_A0033
     208  Void    setDisparityCoeff( Double dDisparityCoeff ) { m_dDisparityCoeff = dDisparityCoeff; }
     209  Double  getDisparityCoeff()                         { return m_dDisparityCoeff; }
     210#endif
     211
    194212#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    195213  Void   setLambdaScale  ( Double dLambdaScale) { m_dLambdaScale = dLambdaScale; }
     
    222240{
    223241     m_uiCost = (bSad ? m_uiLambdaMotionSAD + iAdd : m_uiLambdaMotionSSE + iAdd);
    224 #if HHI_FIX
    225242    m_uiLambdaMVReg = ( bSad ? m_uiLambdaMVRegSAD         : m_uiLambdaMVRegSSE         );
    226 #endif
     243
    227244   }
    228245  Void    setPredictor( TComMv& rcMv )
     
    301318  static UInt xGetSAD16N        ( DistParam* pcDtParam );
    302319 
     320#if SAIT_VSO_EST_A0033
     321  static UInt xGetVSD           ( DistParam* pcDtParam );
     322  static UInt xGetVSD4          ( DistParam* pcDtParam );
     323  static UInt xGetVSD8          ( DistParam* pcDtParam );
     324  static UInt xGetVSD16         ( DistParam* pcDtParam );
     325  static UInt xGetVSD32         ( DistParam* pcDtParam );
     326  static UInt xGetVSD64         ( DistParam* pcDtParam );
     327  static UInt xGetVSD16N        ( DistParam* pcDtParam );
     328#endif
     329
    303330#if AMP_SAD
    304331  static UInt xGetSAD12         ( DistParam* pcDtParam );
     
    329356#endif
    330357 
     358#if SAIT_VSO_EST_A0033
     359  UInt   getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, Pel* piVirRec, Pel* piVirOrg, Int iVirStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc = DF_VSD );
     360  static UInt getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride,  Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y );
     361#endif
     362
    331363#if HHI_VSO
    332364private:
     
    340372  Bool                    m_bAllowNegDist;
    341373#endif
     374#if SAIT_VSO_EST_A0033
     375  TComPicYuv *            m_pcVideoRecPicYuv;
     376  TComPicYuv *            m_pcDepthPicYuv;
     377  Bool                    m_bUseEstimatedVSD;
     378#endif
    342379
    343380  Bool                    m_bUseVSO;
     
    357394  Void    setUseVSO ( Bool bIn )         { m_bUseVSO = bIn; };
    358395  Bool    getUseVSO ( )                  { return m_bUseVSO;};
     396#if SAIT_VSO_EST_A0033
     397  Bool    getUseEstimatedVSD( )           { return m_bUseEstimatedVSD; };
     398  Void    setUseEstimatedVSD( Bool bIn )  { m_bUseEstimatedVSD = bIn; };
     399
     400  TComPicYuv* getVideoRecPicYuv ()                               { return m_pcVideoRecPicYuv; };
     401  Void        setVideoRecPicYuv ( TComPicYuv* pcVideoRecPicYuv ) { m_pcVideoRecPicYuv = pcVideoRecPicYuv; };
     402  TComPicYuv* getDepthPicYuv    ()                               { return m_pcDepthPicYuv; };
     403  Void        setDepthPicYuv    ( TComPicYuv* pcDepthPicYuv )    { m_pcDepthPicYuv = pcDepthPicYuv; };
     404#endif
    359405
    360406  Bool    getUseRenModel ( )             { return (m_bUseVSO && m_uiVSOMode == 4); };
  • trunk/source/Lib/TLibCommon/TComResidualGenerator.cpp

    r77 r100  
    219219}
    220220
    221 
     221#if QC_MULTI_DIS_CAN
     222Bool
     223TComResidualGenerator::getResidualSamples( TComDataCU* pcCU, UInt uiPUIdx, TComYuv* pcYuv, Int iDisp
     224#if QC_SIMPLIFIEDIVRP_M24938
     225  , Bool bRecon
     226#endif
     227 )
     228#else
    222229Bool
    223230TComResidualGenerator::getResidualSamples( TComDataCU* pcCU, UInt uiPUIdx, TComYuv* pcYuv
     
    226233#endif
    227234  )
     235#endif
    228236{
    229237  AOF(  pcCU );
     
    235243  iBlkHeight  = pcCU->getHeight ( 0 );
    236244  pcCU->getPic()->getPicYuvRec()->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iXPos, iYPos );
     245#if QC_MULTI_DIS_CAN
     246  return getResidualSamples( pcCU->getPic(), (UInt)iXPos, (UInt)iYPos, (UInt)iBlkWidth, (UInt)iBlkHeight, pcYuv, iDisp
     247#if QC_SIMPLIFIEDIVRP_M24938
     248    , bRecon
     249#endif
     250  );
     251#else
    237252  return getResidualSamples( pcCU->getPic(), (UInt)iXPos, (UInt)iYPos, (UInt)iBlkWidth, (UInt)iBlkHeight, pcYuv
    238253#if QC_SIMPLIFIEDIVRP_M24938
     
    240255#endif
    241256    );
     257#endif
    242258}
    243259 
     260#if QC_MULTI_DIS_CAN
     261Bool
     262TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp
     263#if QC_SIMPLIFIEDIVRP_M24938
     264  , Bool bRecon
     265#endif
     266)
     267#else
    244268Bool
    245269TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv
     
    248272#endif
    249273  )
     274#endif
    250275{
    251276  UInt  uiBaseViewId  = m_pcDepthMapGenerator->getBaseViewId( 0 );
     
    258283  UInt uiXPosInRefView = uiXPos , uiYPosInRefView = uiYPos;
    259284#endif
     285#if QC_MULTI_DIS_CAN
     286  xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv, iDisp
     287#if QC_SIMPLIFIEDIVRP_M24938
     288    , &uiXPosInRefView , &uiYPosInRefView , bRecon
     289#endif 
     290  );
     291#else
    260292  xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv
    261293#if QC_SIMPLIFIEDIVRP_M24938
     
    263295#endif
    264296    );
    265 
     297#endif
    266298#if QC_SIMPLIFIEDIVRP_M24938
    267299  return xIsNonZeroByCBF( uiBaseViewId , uiXPosInRefView , uiYPosInRefView , uiBlkWidth , uiBlkHeight );
     
    423455    AOF( bOK );
    424456#if LG_RESTRICTEDRESPRED_M24766
    425         pcCU->getPUResiPredShift(iPUPredResiShift, 0);
    426         pcCUResidual->add(iPUPredResiShift, pcCU->getPartitionSize(0), m_ppcYuvTmp[0], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
     457    pcCU->getPUResiPredShift(iPUPredResiShift, 0);
     458    pcCUResidual->add(iPUPredResiShift, pcCU->getPartitionSize(0), m_ppcYuvTmp[0], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
    427459#else
    428460    pcCUResidual->add( m_ppcYuvTmp[0], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
     
    485517
    486518
    487 
     519#if QC_MULTI_DIS_CAN
     520Void 
     521TComResidualGenerator::xSetPredResidualBlock( TComPic* pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp
     522#if QC_SIMPLIFIEDIVRP_M24938
     523  , UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon
     524#endif
     525)
     526#else
    488527Void 
    489528TComResidualGenerator::xSetPredResidualBlock( TComPic* pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv
     
    492531#endif
    493532  )
     533#endif
    494534{
    495535  //===== set and check some basic variables =====
     
    508548
    509549  //===== get disparity =====
     550#if QC_MULTI_DIS_CAN
     551  Int iDisparity = iDisp;
     552#else
    510553  Int           iMidPosX    = Int( uiXPos + ( ( uiBlkWidth  - 1 ) >> 1 ) ) >> m_pcDepthMapGenerator->getSubSampExpX();
    511554  Int           iMidPosY    = Int( uiYPos + ( ( uiBlkHeight - 1 ) >> 1 ) ) >> m_pcDepthMapGenerator->getSubSampExpY();
    512555  Int           iDisparity  = m_pcDepthMapGenerator->getDisparity( pcPic, iMidPosX, iMidPosY, uiBaseViewId );
    513 
     556#endif
    514557  //===== compensate luma =====
    515558  Int           iYWidth     = Int( uiBlkWidth  );
  • trunk/source/Lib/TLibCommon/TComResidualGenerator.h

    r77 r100  
    6969  Void  setRecResidualPic     ( TComPic*      pcPic );
    7070
     71#if QC_MULTI_DIS_CAN
     72  Bool  getResidualSamples    ( TComDataCU*   pcCU,  UInt uiPUIdx, TComYuv* pcYuv, Int iDisp
     73#if QC_SIMPLIFIEDIVRP_M24938
     74    , Bool bRecon
     75#endif
     76);
     77  Bool  getResidualSamples    ( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv , Int iDisp
     78#if QC_SIMPLIFIEDIVRP_M24938
     79    , Bool bRecon
     80#endif 
     81  );
     82#else
    7183  Bool  getResidualSamples    ( TComDataCU*   pcCU,  UInt uiPUIdx, TComYuv* pcYuv
    7284#if QC_SIMPLIFIEDIVRP_M24938
     
    7991#endif
    8092    );
     93#endif
    8194
    8295private:
     
    87100  Void  xClearIntViewResidual ( TComDataCU*   pcCU,  TComYuv* pcCUResidual, UInt uiPartIdx    );
    88101  Void  xClearResidual        (                      TComYuv* pcCUResidual, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight );
    89 
     102#if QC_MULTI_DIS_CAN
     103  Void  xSetPredResidualBlock ( TComPic*      pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp
     104#if QC_SIMPLIFIEDIVRP_M24938
     105    , UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon
     106#endif
     107  );
     108#else
    90109  Void  xSetPredResidualBlock ( TComPic*      pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv
    91110#if QC_SIMPLIFIEDIVRP_M24938
     
    93112#endif
    94113    );
     114#endif
    95115  Bool  xIsNonZero            ( TComYuv*      pcYuv, UInt uiBlkWidth, UInt uiBlkHeight );
    96116#if QC_SIMPLIFIEDIVRP_M24938
  • trunk/source/Lib/TLibCommon/TComRom.h

    r56 r100  
    206206#endif
    207207
     208#if LGE_EDGE_INTRA
     209__inline Void mapEdgeIntratoDC( UChar& curDir ) { curDir = (curDir >= EDGE_INTRA_IDX) ? DC_IDX : curDir; }
     210__inline Void mapEdgeIntratoDC(  UInt& curDir ) { curDir = (curDir >= EDGE_INTRA_IDX) ? DC_IDX : curDir; }
     211__inline Void mapEdgeIntratoDC(   Int& curDir ) { curDir = (curDir >= EDGE_INTRA_IDX) ? DC_IDX : curDir; }
     212#endif
     213
    208214// ==========================================
    209215// Mode-Dependent DST Matrices
  • trunk/source/Lib/TLibCommon/TComSlice.cpp

    r77 r100  
    13351335TComVPS::~TComVPS()
    13361336{
    1337        
    1338        
     1337 
     1338 
    13391339}
    13401340
  • trunk/source/Lib/TLibCommon/TComSlice.h

    r77 r100  
    151151private:
    152152  Int         m_VPSId;
    153         UInt                            m_uiMaxTLayers;
    154         UInt                            m_uiMaxLayers;
    155         Bool                            m_bTemporalIdNestingFlag;
    156 
    157         UInt        m_uiExtensionType;
     153  UInt        m_uiMaxTLayers;
     154  UInt        m_uiMaxLayers;
     155  Bool        m_bTemporalIdNestingFlag;
     156
     157  UInt        m_uiExtensionType;
    158158 
    159159  Bool        m_bDependentFlag[MAX_LAYER_NUM];
     
    170170  TComVPS();
    171171  virtual ~TComVPS();
    172        
     172 
    173173  Int     getVPSId       ()                   { return m_VPSId;          }
    174174  Void    setVPSId       (Int i)              { m_VPSId = i;             }
    175        
     175 
    176176  UInt    getMaxTLayers  ()                   { return m_uiMaxTLayers;   }
    177177  Void    setMaxTLayers  (UInt t)             { m_uiMaxTLayers = t; }
    178178   
    179179  UInt    getMaxLayers   ()                   { return m_uiMaxLayers;   }
    180         Void    setMaxLayers   (UInt l)             { m_uiMaxLayers = l; }
    181        
     180  Void    setMaxLayers   (UInt l)             { m_uiMaxLayers = l; }
     181 
    182182  Bool    getTemporalNestingFlag   ()         { return m_uiMaxLayers;   }
    183         Void    setTemporalNestingFlag   (UInt t)   { m_bTemporalIdNestingFlag = t; }
     183  Void    setTemporalNestingFlag   (UInt t)   { m_bTemporalIdNestingFlag = t; }
    184184 
    185185  Void    setExtensionType(UInt v)                     { m_uiExtensionType = v;    }
     
    219219private:
    220220#if VIDYO_VPS_INTEGRATION
    221         Int                                     m_VPSId;
     221  Int          m_VPSId;
    222222#endif
    223223  Int         m_SPSId;
     
    379379  virtual ~TComSPS();
    380380#if VIDYO_VPS_INTEGRATION
    381         Int  getVPSId       ()         { return m_VPSId;          }
     381  Int  getVPSId       ()         { return m_VPSId;          }
    382382  Void setVPSId       (Int i)    { m_VPSId = i;             }
    383383#endif
  • trunk/source/Lib/TLibCommon/TComYuv.cpp

    r77 r100  
    396396TComYuv::add(Int *iPUResiPredShift, PartSize uhPartitionSize,  TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract )
    397397{
    398         addLuma   (iPUResiPredShift, uhPartitionSize, pcYuvAdd, iWidth,    iHeight,    bSubtract );
    399         addChroma (iPUResiPredShift, uhPartitionSize, pcYuvAdd, iWidth>>1, iHeight>>1, bSubtract );
     398  addLuma   (iPUResiPredShift, uhPartitionSize, pcYuvAdd, iWidth,    iHeight,    bSubtract );
     399  addChroma (iPUResiPredShift, uhPartitionSize, pcYuvAdd, iWidth>>1, iHeight>>1, bSubtract );
    400400}
    401401#else
     
    412412TComYuv::getPUXYOffset(PartSize uhPartitionSize, Int iWidth, Int iHeight, Int &iXOffset, Int &iYOffset)
    413413{
    414         switch(uhPartitionSize)
    415         {        
    416         case SIZE_2NxN:
    417                 iXOffset = iWidth;      iYOffset = iHeight >> 1;   break;
    418         case SIZE_2NxnU:
    419                 iXOffset = iWidth;      iYOffset = iHeight >> 2;   break;
    420         case SIZE_2NxnD:
    421                 iXOffset = iWidth;      iYOffset = (iHeight >> 1) + (iHeight >> 2);   break;
    422         case SIZE_Nx2N:
    423                 iXOffset = iWidth >> 1; iYOffset = iHeight; break;
    424         case SIZE_nLx2N:
    425                 iXOffset = iWidth >> 2; iYOffset = iHeight; break;
    426         case SIZE_nRx2N:
    427                 iXOffset = (iWidth >> 1) + (iWidth >> 2); iYOffset = iHeight; break;
    428         case SIZE_NxN:
    429                 iXOffset = iWidth >> 1; iYOffset = iHeight >> 1;  break;
    430         default:
    431                 assert(uhPartitionSize == SIZE_2Nx2N);
    432                 iXOffset = iWidth;        iYOffset = iHeight;     break;
    433         }
     414  switch(uhPartitionSize)
     415  {   
     416  case SIZE_2NxN:
     417    iXOffset = iWidth;      iYOffset = iHeight >> 1;   break;
     418  case SIZE_2NxnU:
     419    iXOffset = iWidth;      iYOffset = iHeight >> 2;   break;
     420  case SIZE_2NxnD:
     421    iXOffset = iWidth;      iYOffset = (iHeight >> 1) + (iHeight >> 2);   break;
     422  case SIZE_Nx2N:
     423    iXOffset = iWidth >> 1; iYOffset = iHeight; break;
     424  case SIZE_nLx2N:
     425    iXOffset = iWidth >> 2; iYOffset = iHeight; break;
     426  case SIZE_nRx2N:
     427    iXOffset = (iWidth >> 1) + (iWidth >> 2); iYOffset = iHeight; break;
     428  case SIZE_NxN:
     429    iXOffset = iWidth >> 1; iYOffset = iHeight >> 1;  break;
     430  default:
     431    assert(uhPartitionSize == SIZE_2Nx2N);
     432    iXOffset = iWidth;     iYOffset = iHeight;    break;
     433  }
    434434}
    435435#endif
     
    456456  for( Int iY = 0; iY < iYOffset; iY++, pDstSamples += iDstStride, pAddSamples += iAddStride )
    457457  {
    458           if(iPUResiPredShift[0] >= 0)
    459           {
    460                   for( Int iX = 0; iX < iXOffset; iX++ )
    461                   {
    462                           pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[0]);
    463                   }
    464           }
    465 
    466           if(iPUResiPredShift[1] >= 0)
    467           {
    468                   for( Int iX = iXOffset; iX < iWidth; iX++ )
    469                   {
    470                           pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[1]);
    471                   }
    472           }
     458    if(iPUResiPredShift[0] >= 0)
     459    {
     460      for( Int iX = 0; iX < iXOffset; iX++ )
     461      {
     462        pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[0]);
     463      }
     464    }
     465
     466    if(iPUResiPredShift[1] >= 0)
     467    {
     468      for( Int iX = iXOffset; iX < iWidth; iX++ )
     469      {
     470        pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[1]);
     471      }
     472    }
    473473  }
    474474
    475475  for( Int iY = iYOffset; iY < iHeight; iY++, pDstSamples += iDstStride, pAddSamples += iAddStride )
    476476  {
    477           if(iPUResiPredShift[2] >= 0)
    478           {
    479                   for( Int iX = 0; iX < iXOffset; iX++ )
    480                   {
    481                           pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[2]);
    482                   }
    483           }
    484 
    485           if(iPUResiPredShift[3] >= 0)
    486           {
    487                   for( Int iX = iXOffset; iX < iWidth; iX++ )
    488                   {
    489                           pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[3]);
    490                   }
    491           }
     477    if(iPUResiPredShift[2] >= 0)
     478    {
     479      for( Int iX = 0; iX < iXOffset; iX++ )
     480      {
     481        pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[2]);
     482      }
     483    }
     484
     485    if(iPUResiPredShift[3] >= 0)
     486    {
     487      for( Int iX = iXOffset; iX < iWidth; iX++ )
     488      {
     489        pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[3]);
     490      }
     491    }
    492492  }
    493493#else
     
    524524
    525525  for( Int iY = 0; iY < iYOffset; iY++, pDstSamplesCb += iDstStride, pAddSamplesCb += iAddStride,
    526           pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride  )
    527   {
    528           if(iPUResiPredShift[0] >= 0)
    529           {
    530                   for( Int iX = 0; iX < iXOffset; iX++ )
    531                   {
    532                           pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[0]);
    533                           pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[0]);
    534                   }
    535           }
    536 
    537           if(iPUResiPredShift[1] >= 0)
    538           {
    539                   for( Int iX = iXOffset; iX < iWidth; iX++ )
    540                   {
    541                           pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[1]);
    542                           pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[1]);
    543                   }
    544           }
     526    pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride  )
     527  {
     528    if(iPUResiPredShift[0] >= 0)
     529    {
     530      for( Int iX = 0; iX < iXOffset; iX++ )
     531      {
     532        pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[0]);
     533        pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[0]);
     534      }
     535    }
     536
     537    if(iPUResiPredShift[1] >= 0)
     538    {
     539      for( Int iX = iXOffset; iX < iWidth; iX++ )
     540      {
     541        pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[1]);
     542        pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[1]);
     543      }
     544    }
    545545  }
    546546
    547547  for( Int iY = iYOffset; iY < iHeight; iY++, pDstSamplesCb += iDstStride, pAddSamplesCb += iAddStride,
    548           pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride  )
    549   {
    550           if(iPUResiPredShift[2] >= 0)
    551           {
    552                   for( Int iX = 0; iX < iXOffset; iX++ )
    553                   {
    554                           pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[2]);
    555                           pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[2]);
    556                   }
    557           }
    558 
    559           if(iPUResiPredShift[3] >= 0)
    560           {
    561                   for( Int iX = iXOffset; iX < iWidth; iX++ )
    562                   {
    563                           pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[3]);
    564                           pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[3]);
    565                   }
    566           }
     548    pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride  )
     549  {
     550    if(iPUResiPredShift[2] >= 0)
     551    {
     552      for( Int iX = 0; iX < iXOffset; iX++ )
     553      {
     554        pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[2]);
     555        pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[2]);
     556      }
     557    }
     558
     559    if(iPUResiPredShift[3] >= 0)
     560    {
     561      for( Int iX = iXOffset; iX < iWidth; iX++ )
     562      {
     563        pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[3]);
     564        pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[3]);
     565      }
     566    }
    567567  }
    568568#else
     
    679679Void TComYuv::subtract(Int *iPUResiPredShift, PartSize uhPartitionSize, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
    680680{
    681         subtractLuma  (iPUResiPredShift, uhPartitionSize, pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize    );
    682         subtractChroma(iPUResiPredShift, uhPartitionSize, pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize>>1 );
     681  subtractLuma  (iPUResiPredShift, uhPartitionSize, pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize    );
     682  subtractChroma(iPUResiPredShift, uhPartitionSize, pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize>>1 );
    683683}
    684684#else
     
    713713  for ( y = uiPartSize-1; y >= iYOffset; y-- )
    714714  {
    715           if(iPUResiPredShift[3] >= 0)
    716           {
    717                   for ( x = uiPartSize-1; x >= iXOffset; x-- )
    718                   {
    719                           pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[3]);
    720                   }
    721           }
    722 
    723           if(iPUResiPredShift[2] >= 0)
    724           {
    725                   for ( x = iXOffset-1; x >= 0; x-- )
    726                   {
    727                           pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[2]);
    728                   }
    729           }
    730           pSrc0 += iSrc0Stride;
    731           pSrc1 += iSrc1Stride;
    732           pDst  += iDstStride;
     715    if(iPUResiPredShift[3] >= 0)
     716    {
     717      for ( x = uiPartSize-1; x >= iXOffset; x-- )
     718      {
     719        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[3]);
     720      }
     721    }
     722
     723    if(iPUResiPredShift[2] >= 0)
     724    {
     725      for ( x = iXOffset-1; x >= 0; x-- )
     726      {
     727        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[2]);
     728      }
     729    }
     730    pSrc0 += iSrc0Stride;
     731    pSrc1 += iSrc1Stride;
     732    pDst  += iDstStride;
    733733  }
    734734
    735735  for ( y = iYOffset-1; y >= 0; y-- )
    736736  {
    737           if(iPUResiPredShift[1] >= 0)
    738           {
    739                   for ( x = uiPartSize-1; x >= iXOffset; x-- )
    740                   {
    741                           pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[3]);
    742                   }
    743           }
    744 
    745           if(iPUResiPredShift[0] >= 0)
    746           {
    747                   for ( x = iXOffset-1; x >= 0; x-- )
    748                   {
    749                           pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[2]);
    750                   }
    751           }
    752           pSrc0 += iSrc0Stride;
    753           pSrc1 += iSrc1Stride;
    754           pDst  += iDstStride;
     737    if(iPUResiPredShift[1] >= 0)
     738    {
     739      for ( x = uiPartSize-1; x >= iXOffset; x-- )
     740      {
     741        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[3]);
     742      }
     743    }
     744
     745    if(iPUResiPredShift[0] >= 0)
     746    {
     747      for ( x = iXOffset-1; x >= 0; x-- )
     748      {
     749        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[2]);
     750      }
     751    }
     752    pSrc0 += iSrc0Stride;
     753    pSrc1 += iSrc1Stride;
     754    pDst  += iDstStride;
    755755  }
    756756
     
    794794  for ( y = uiPartSize-1; y >= iYOffset; y-- )
    795795  {
    796           if(iPUResiPredShift[3] >= 0)
    797           {
    798                   for ( x = uiPartSize-1; x >= iXOffset; x-- )
    799                   {
    800                           pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[3]);
    801                           pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[3]);
    802                   }
    803           }
    804 
    805           if(iPUResiPredShift[2] >= 0)
    806           {
    807                   for ( x = iXOffset-1; x >= 0; x-- )
    808                   {
    809                           pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[2]);
    810                           pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[2]);
    811                   }
    812           }
    813           pSrcU0 += iSrc0Stride;
    814           pSrcU1 += iSrc1Stride;
    815           pSrcV0 += iSrc0Stride;
    816           pSrcV1 += iSrc1Stride;
    817           pDstU  += iDstStride;
    818           pDstV  += iDstStride;
     796    if(iPUResiPredShift[3] >= 0)
     797    {
     798      for ( x = uiPartSize-1; x >= iXOffset; x-- )
     799      {
     800        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[3]);
     801        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[3]);
     802      }
     803    }
     804
     805    if(iPUResiPredShift[2] >= 0)
     806    {
     807      for ( x = iXOffset-1; x >= 0; x-- )
     808      {
     809        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[2]);
     810        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[2]);
     811      }
     812    }
     813    pSrcU0 += iSrc0Stride;
     814    pSrcU1 += iSrc1Stride;
     815    pSrcV0 += iSrc0Stride;
     816    pSrcV1 += iSrc1Stride;
     817    pDstU  += iDstStride;
     818    pDstV  += iDstStride;
    819819  }
    820820
    821821  for ( y = iYOffset-1; y >= 0; y-- )
    822822  {
    823           if(iPUResiPredShift[1] >= 0)
    824           {
    825                   for ( x = uiPartSize-1; x >= iXOffset; x-- )
    826                   {
    827                           pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[1]);
    828                           pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[1]);
    829                   }
    830           }
    831 
    832           if(iPUResiPredShift[0] >= 0)
    833           {
    834                   for ( x = iXOffset-1; x >= 0; x-- )
    835                   {
    836                           pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[0]);
    837                           pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[0]);
    838                   }
    839           }
    840           pSrcU0 += iSrc0Stride;
    841           pSrcU1 += iSrc1Stride;
    842           pSrcV0 += iSrc0Stride;
    843           pSrcV1 += iSrc1Stride;
    844           pDstU  += iDstStride;
    845           pDstV  += iDstStride;
     823    if(iPUResiPredShift[1] >= 0)
     824    {
     825      for ( x = uiPartSize-1; x >= iXOffset; x-- )
     826      {
     827        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[1]);
     828        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[1]);
     829      }
     830    }
     831
     832    if(iPUResiPredShift[0] >= 0)
     833    {
     834      for ( x = iXOffset-1; x >= 0; x-- )
     835      {
     836        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[0]);
     837        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[0]);
     838      }
     839    }
     840    pSrcU0 += iSrc0Stride;
     841    pSrcU1 += iSrc1Stride;
     842    pSrcV0 += iSrc0Stride;
     843    pSrcV1 += iSrc1Stride;
     844    pDstU  += iDstStride;
     845    pDstV  += iDstStride;
    846846  }
    847847#else
  • trunk/source/Lib/TLibCommon/TComYuv.h

    r77 r100  
    167167  Void    removeHighFreq    ( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight );
    168168#if LG_RESTRICTEDRESPRED_M24766
    169   void    getPUXYOffset     (PartSize uhPartitionSize, Int iWidth, Int iHeight, Int &iXOffset, Int &iYOffset);
     169  Void    getPUXYOffset     (PartSize uhPartitionSize, Int iWidth, Int iHeight, Int &iXOffset, Int &iYOffset);
    170170  Void    add               (Int *iPUResiPredShift, PartSize uhPartitionSize, TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract = false );
    171171  Void    addLuma           (Int *iPUResiPredShift, PartSize uhPartitionSize, TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract );
  • trunk/source/Lib/TLibCommon/TypeDef.h

    r77 r100  
    4242//! \{
    4343
     44#define FIXES                           1
     45#define LGE_EDGE_INTRA                  1       //JCT2-A0070
     46#if LGE_EDGE_INTRA
     47#define LGE_EDGE_INTRA_MIN_SIZE         4
     48#define LGE_EDGE_INTRA_MAX_SIZE        32
     49#define LGE_EDGE_INTRA_THRESHOLD       20
     50#define LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 8
     51#define LGE_EDGE_INTRA_DELTA_DC         1
     52#define LGE_EDGE_INTRA_PIXEL_DIFFERENCE 1
     53#endif
     54
     55#define LG_ZEROINTRADEPTHRESI_M26039      1  //JCT2-A0087
     56
    4457#define SONY_COLPIC_AVAILABILITY          1
    4558
    4659#define HHI_INTER_VIEW_MOTION_PRED        1   // inter-view motion parameter prediction
    4760#define HHI_INTER_VIEW_RESIDUAL_PRED      1   // inter-view residual prediction
    48 #define HHI_FIX                           1   // inter-view prediction and other fixes
     61#define QC_MULTI_DIS_CAN                  1         // JCT2-A0097
     62#if QC_MULTI_DIS_CAN
     63    #define DIS_CANS                      1
     64#endif
     65
     66#define MTK_INTERVIEW_MERGE_A0049         1 //  JCT2-A0049 second part
     67
     68#define LGE_DVMCP                         1 //  JCT2-A0126     
     69#if LGE_DVMCP
     70#define DVFROM_LEFTBELOW                  1
     71#define DVFROM_LEFT                       2
     72#define DVFROM_ABOVERIGHT                 3
     73#define DVFROM_ABOVE                      4
     74#define DVFROM_ABOVELEFT                  5
     75#define DVFROM_COL                        6
     76#endif
     77
    4978
    5079#define HHI_VSO                           1
    51 #define HHI_VSO_LS_TABLE                  1
     80#define HHI_VSO_LS_TABLE                  1 // m23714
    5281#define HHI_VSO_DIST_INT                  1
    5382#define HHI_VSO_SYNTH_DIST_OUT            0
    5483#define HHI_VSO_COLOR_PLANES              1
     84#define HHI_VSO_SPEEDUP_A033              1 // JCT2-A0033 modification 1 (changes classes directly related the renderer model
     85                                            // to are not covered by this define, since nearly the entire class has been changed)
     86#define HHI_VSO_RM_ASSERTIONS             0 // output VSO assertions
     87#define HHI_VSO_SET_OPTIM                 1 // remove unnecessary updates (works only with HHI_VSO_FIX 1 properly)
     88#define SAIT_VSO_EST_A0033                1 // JCT2-A0033 modification 3
     89#define LGE_VSO_EARLY_SKIP_A0093          1 // JCT2-A0093 modification 4
     90
    5591
    5692#define HHI_INTERVIEW_SKIP                1
    5793#define HHI_INTERVIEW_SKIP_LAMBDA_SCALE   1
    5894
    59 #define HHI_DMM_WEDGE_INTRA 1   // depth model modes independent on texture (explicit and intra-predicted Wedgelet prediction)
    60 #define HHI_DMM_PRED_TEX    1   // depth model modes dependent on texture (inter-component Wedgelet and Contour prediction )
     95#define HHI_DMM_WEDGE_INTRA               1   // depth model modes independent on texture (explicit and intra-predicted Wedgelet prediction)
     96#define HHI_DMM_PRED_TEX                  1   // depth model modes dependent on texture (inter-component Wedgelet and Contour prediction )
    6197
    6298#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     
    224260#define LOG2_SCAN_SET_SIZE                4
    225261
     262#if LGE_EDGE_INTRA
     263#if LGE_EDGE_INTRA_DELTA_DC
     264#define FAST_UDI_MAX_RDMODE_NUM               37          ///< maximum number of RD comparison in fast-UDI estimation loop
     265#else
     266#define FAST_UDI_MAX_RDMODE_NUM               36          ///< maximum number of RD comparison in fast-UDI estimation loop
     267#endif
     268#else
    226269#define FAST_UDI_MAX_RDMODE_NUM               35          ///< maximum number of RD comparison in fast-UDI estimation loop
     270#endif
    227271
    228272#define ZERO_MVD_EST                          0           ///< Zero Mvd Estimation in normal mode
     
    263307#define NUM_DMM_MODE 4
    264308#endif
     309
     310#if LGE_EDGE_INTRA
     311#if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX
     312#define EDGE_INTRA_IDX  (NUM_INTRA_MODE+NUM_DMM_MODE)
     313#endif // HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX
     314#if LGE_EDGE_INTRA_DELTA_DC
     315#define EDGE_INTRA_DELTA_IDX          (EDGE_INTRA_IDX+1)
     316#endif
     317#endif // LGE_EDGE_INTRA
    265318
    266319#define IBDI_DISTORTION                0           ///< enable/disable SSE modification when IBDI is used (JCTVC-D152)
     
    647700};
    648701
     702#if HHI_VSO_SPEEDUP_A033
     703
     704enum BlenMod
     705{
     706    BLEND_NONE  = -1,
     707    BLEND_AVRG  = 0,
     708    BLEND_LEFT  = 1,
     709    BLEND_RIGHT = 2,
     710    BLEND_GEN   =  3
     711};
     712#endif
     713
    649714/// supported prediction type
    650715enum PredMode
     
    712777  DF_HADS16N  = 28,     ///< 16NxM HAD with step
    713778
     779#if SAIT_VSO_EST_A0033
     780  DF_VSD      = 29,      ///< general size VSD
     781  DF_VSD4     = 30,      ///<   4xM VSD
     782  DF_VSD8     = 31,      ///<   8xM VSD
     783  DF_VSD16    = 32,      ///<  16xM VSD
     784  DF_VSD32    = 33,      ///<  32xM VSD
     785  DF_VSD64    = 34,      ///<  64xM VSD
     786  DF_VSD16N   = 35,      ///< 16NxM VSD
     787#endif
     788
     789
    714790#if AMP_SAD
    715791  DF_SAD12    = 43,
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r77 r100  
    18911891      rpcSlice->setPOC( iPOCmsb+iPOClsb );
    18921892
    1893 #if HHI_FIX
    18941893      if( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && rpcSlice->getPOC() == 0 )
    1895 #else
    1896       if( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV )
    1897 #endif
    18981894      {
    18991895        TComReferencePictureSet* rps = rpcSlice->getLocalRPS();
  • trunk/source/Lib/TLibDecoder/TDecCu.cpp

    r77 r100  
    643643    AOF( bOK );
    644644#if LG_RESTRICTEDRESPRED_M24766
    645         Int iPUResiPredShift[4];
    646         pcCU->getPUResiPredShift(iPUResiPredShift, 0);
    647         m_ppcYuvReco[uiDepth]->add(iPUResiPredShift, pcCU->getPartitionSize(0), m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
     645    Int iPUResiPredShift[4];
     646    pcCU->getPUResiPredShift(iPUResiPredShift, 0);
     647    m_ppcYuvReco[uiDepth]->add(iPUResiPredShift, pcCU->getPartitionSize(0), m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
    648648#else
    649649    m_ppcYuvReco[uiDepth]->add( m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
     
    705705                                     m_pcPrediction->getPredicBufHeight (),
    706706                                     bAboveAvail, bLeftAvail );
     707#if LGE_EDGE_INTRA
     708  if( uiLumaPredMode >= EDGE_INTRA_IDX )
     709  {
     710    m_pcPrediction->predIntraLumaEdge( pcCU, pcCU->getPattern(), uiAbsPartIdx, uiWidth, uiHeight, piPred, uiStride
     711#if LGE_EDGE_INTRA_DELTA_DC
     712      , uiLumaPredMode == EDGE_INTRA_DELTA_IDX
     713#endif
     714      );
     715  }
     716  else
     717#endif
    707718 
    708719  //===== get prediction signal =====
  • trunk/source/Lib/TLibDecoder/TDecEntropy.cpp

    r77 r100  
    109109  {
    110110#if LG_RESTRICTEDRESPRED_M24766
    111           Int iPUResiPredShift[4];
    112           pcCU->getPUResiPredShift(iPUResiPredShift, uiAbsPartIdx);
    113           if(iPUResiPredShift[0] >= 0 || iPUResiPredShift[1] >= 0  || iPUResiPredShift[2] >= 0  || iPUResiPredShift[3] >= 0 )
     111    Int iPUResiPredShift[4];
     112    pcCU->getPUResiPredShift(iPUResiPredShift, uiAbsPartIdx);
     113    if(iPUResiPredShift[0] >= 0 || iPUResiPredShift[1] >= 0  || iPUResiPredShift[2] >= 0  || iPUResiPredShift[3] >= 0 )
    114114#endif
    115115    m_pcEntropyDecoderIf->parseResPredFlag( pcCU, bResPredFlag, uiAbsPartIdx, uiDepth );
  • trunk/source/Lib/TLibDecoder/TDecGop.cpp

    r56 r100  
    303303    {
    304304      m_pcDepthMapGenerator->initViewComponent( rpcPic );
     305#if !QC_MULTI_DIS_CAN
    305306      m_pcDepthMapGenerator->predictDepthMap  ( rpcPic );
     307#endif
    306308#if HHI_INTER_VIEW_RESIDUAL_PRED
    307309      m_pcResidualGenerator->initViewComponent( rpcPic );
     
    339341#endif
    340342#if DEPTH_MAP_GENERATION
     343#if !QC_MULTI_DIS_CAN
    341344    // update virtual depth map
    342345    m_pcDepthMapGenerator->updateDepthMap( rpcPic );
     346#endif
    343347#endif
    344348    // deblocking filter
  • trunk/source/Lib/TLibDecoder/TDecSbac.cpp

    r56 r100  
    9898, m_cDmmDataSCModel           ( 1,             1,               NUM_DMM_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    9999#endif
     100#if LGE_EDGE_INTRA
     101, m_cEdgeIntraSCModel         ( 1,             1,               NUM_EDGE_INTRA_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
     102#if LGE_EDGE_INTRA_DELTA_DC
     103, m_cEdgeIntraDeltaDCSCModel  ( 1,             1,               NUM_EDGE_INTRA_DELTA_DC_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
     104#endif
     105#endif
    100106{
    101107  assert( m_numContextModels <= MAX_NUM_CTX_MOD );
     
    182188
    183189  m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
     190#if LGE_EDGE_INTRA
     191  m_cEdgeIntraSCModel.initBuffer         ( sliceType, qp, (UChar*)INIT_EDGE_INTRA );
     192#if LGE_EDGE_INTRA_DELTA_DC
     193  m_cEdgeIntraDeltaDCSCModel.initBuffer  ( sliceType, qp, (UChar*)INIT_EDGE_INTRA_DELTA_DC );
     194#endif
     195#endif
    184196  m_uiLastDQpNonZero  = 0;
    185197#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     
    815827  {
    816828    UInt uiDMMode;
    817  
     829
    818830#if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX
    819831    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode  = uiSymbol;
     
    847859#endif
    848860#if !LOGI_INTRA_NAME_3MPM
    849   Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
    850 #endif
    851  
     861    Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
     862#endif
     863
     864#if LGE_EDGE_INTRA
     865    Bool bCodeEdgeIntra = false;
     866    if( pcCU->getSlice()->getSPS()->isDepth() )
     867    {
     868      UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0);
     869      if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE )
     870        bCodeEdgeIntra = true;
     871    }
     872#endif
     873
    852874#if LOGI_INTRA_NAME_3MPM
    853   Int uiPreds[3] = {-1, -1, -1};
    854 #else
    855   Int uiPreds[2] = {-1, -1};
    856 #endif
    857   Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); 
    858  
    859   m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) );
    860  
    861   if ( uiSymbol )
    862   {
    863     m_pcTDecBinIf->decodeBinEP( uiSymbol );
     875    Int uiPreds[3] = {-1, -1, -1};
     876#else
     877    Int uiPreds[2] = {-1, -1};
     878#endif
     879    Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); 
     880#if LGE_EDGE_INTRA
     881    UInt uiCheckBit = 0;
     882#endif
     883
     884    m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) );
     885
     886    if ( uiSymbol )
     887    {
     888      m_pcTDecBinIf->decodeBinEP( uiSymbol );
    864889#if LOGI_INTRA_NAME_3MPM
    865     if (uiSymbol)
    866     {
    867       m_pcTDecBinIf->decodeBinEP( uiSymbol );
    868       uiSymbol++;
    869     }
    870 #endif
    871     intraPredMode = uiPreds[uiSymbol];
    872   }
    873   else
    874   {
    875     intraPredMode = 0;
    876    
     890      if (uiSymbol)
     891      {
     892        m_pcTDecBinIf->decodeBinEP( uiSymbol );
     893        uiSymbol++;
     894      }
     895#endif
     896      intraPredMode = uiPreds[uiSymbol];
     897    }
     898    else
     899    {
     900      intraPredMode = 0;
     901
    877902#if LOGI_INTRA_NAME_3MPM
    878    
    879     m_pcTDecBinIf->decodeBinsEP( uiSymbol, 5 );
    880     intraPredMode = uiSymbol;
    881    
    882    //postponed sorting of MPMs (only in remaining branch)
    883     if (uiPreds[0] > uiPreds[1])
    884     {
    885       std::swap(uiPreds[0], uiPreds[1]);
    886     }
    887     if (uiPreds[0] > uiPreds[2])
    888     {
    889       std::swap(uiPreds[0], uiPreds[2]);
    890     }
    891     if (uiPreds[1] > uiPreds[2])
    892     {
    893       std::swap(uiPreds[1], uiPreds[2]);
    894     }
    895 #else
    896     m_pcTDecBinIf->decodeBinsEP( uiSymbol, g_aucIntraModeBitsAng[iIntraIdx] - 1 );
    897     intraPredMode = uiSymbol;
    898    
    899     if ( intraPredMode == 31 )
    900     {
    901       m_pcTDecBinIf->decodeBinEP( uiSymbol );
    902       intraPredMode += uiSymbol;     
    903     }
    904 #endif
    905     for ( Int i = 0; i < uiPredNum; i++ )
    906     {
    907       intraPredMode += ( intraPredMode >= uiPreds[i] );
    908     }
    909   }
     903
     904      m_pcTDecBinIf->decodeBinsEP( uiSymbol, 5 );
     905#if LGE_EDGE_INTRA
     906      if (bCodeEdgeIntra)
     907      {
     908        if (uiSymbol==31)
     909        {
     910          m_pcTDecBinIf->decodeBinsEP(uiCheckBit,1);
     911          if (uiCheckBit)
     912            uiSymbol = EDGE_INTRA_IDX;
     913        }
     914      }
     915#endif
     916      intraPredMode = uiSymbol;
     917
     918      //postponed sorting of MPMs (only in remaining branch)
     919      if (uiPreds[0] > uiPreds[1])
     920      {
     921        std::swap(uiPreds[0], uiPreds[1]);
     922      }
     923      if (uiPreds[0] > uiPreds[2])
     924      {
     925        std::swap(uiPreds[0], uiPreds[2]);
     926      }
     927      if (uiPreds[1] > uiPreds[2])
     928      {
     929        std::swap(uiPreds[1], uiPreds[2]);
     930      }
     931#else
     932      m_pcTDecBinIf->decodeBinsEP( uiSymbol, g_aucIntraModeBitsAng[iIntraIdx] - 1 );
     933      intraPredMode = uiSymbol;
     934
     935      if ( intraPredMode == 31 )
     936      {
     937        m_pcTDecBinIf->decodeBinEP( uiSymbol );
     938        intraPredMode += uiSymbol;     
     939      }
     940#endif
     941#if LGE_EDGE_INTRA
     942      if ( intraPredMode != EDGE_INTRA_IDX)
     943      {
     944#endif
     945        for ( Int i = 0; i < uiPredNum; i++ )
     946        {
     947          intraPredMode += ( intraPredMode >= uiPreds[i] );
     948        }
     949#if LGE_EDGE_INTRA
     950      }
     951#endif
     952    }
     953
     954#if LGE_EDGE_INTRA
     955    if( intraPredMode == EDGE_INTRA_IDX )
     956    {
     957      xParseEdgeIntraInfo( pcCU, uiAbsPartIdx, uiDepth );
     958#if LGE_EDGE_INTRA_DELTA_DC
     959      m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) );
     960      if( uiSymbol )
     961      {
     962        intraPredMode = EDGE_INTRA_DELTA_IDX;
     963        Int iDeltaDC0;
     964        Int iDeltaDC1;
     965
     966        xReadExGolombLevel( (UInt &) iDeltaDC0, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
     967        if( iDeltaDC0 != 0 )
     968        {
     969          UInt uiSign;
     970          m_pcTDecBinIf->decodeBinEP( uiSign );
     971          if ( uiSign )
     972          {
     973            iDeltaDC0 = -iDeltaDC0;
     974          }
     975        }
     976        xReadExGolombLevel( (UInt &) iDeltaDC1, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
     977        if( iDeltaDC1 != 0 )
     978        {
     979          UInt uiSign;
     980          m_pcTDecBinIf->decodeBinEP( uiSign );
     981          if ( uiSign )
     982          {
     983            iDeltaDC1 = -iDeltaDC1;
     984          }
     985        }
     986
     987        pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 );
     988        pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 );
     989      }
     990#endif
     991    }
     992#endif
     993
    910994#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    911995  }
    912996#endif
    913  
     997
    914998  pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, uiAbsPartIdx, uiDepth );
    915999}
     
    20122096#endif
    20132097
    2014 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     2098#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA && LGE_EDGE_INTRA_DELTA_DC)
    20152099Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel  )
    20162100{
     
    22702354}
    22712355#endif
     2356
     2357#if LGE_EDGE_INTRA
     2358Void TDecSbac::xParseEdgeIntraInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     2359{
     2360  UInt uiSymbol = 0;
     2361
     2362  // 1. Top(0) or Left(1)
     2363  UChar ucLeft;
     2364  m_pcTDecBinIf->decodeBinEP( uiSymbol );
     2365  ucLeft = uiSymbol;
     2366
     2367  // 2. Start position (lowest bit first)
     2368  UChar ucStart = 0;
     2369  for( UInt ui = 0; ui < 6 - uiDepth; ui++ )
     2370  {
     2371    m_pcTDecBinIf->decodeBinEP( uiSymbol );
     2372    ucStart |= (uiSymbol << ui);
     2373  }
     2374
     2375  // 3. Number of edges
     2376  UChar ucMax = 0;
     2377  for( UInt ui = 0; ui < 7 - uiDepth; ui++ )
     2378  {
     2379    m_pcTDecBinIf->decodeBinEP( uiSymbol );
     2380    ucMax |= (uiSymbol << ui);
     2381  }
     2382  ucMax++; // +1
     2383
     2384  // 4. Edges
     2385  UChar* pucSymbolList = (UChar*) xMalloc( UChar, 256 * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 );
     2386  UInt uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiAbsPartIdx );
     2387  for( Int iPtr = 0; iPtr < ucMax; iPtr++ )
     2388  {
     2389    UChar ucEdge = 0;
     2390    UInt  uiReorderEdge = 0;
     2391    // Left-friendly direction
     2392    // 0 (   0deg) => 0
     2393    // 1 (  45deg) => 10
     2394    // 2 ( -45deg) => 110
     2395    // 3 (  90deg) => 1110
     2396    // 4 ( -90deg) => 11110
     2397    // 5 ( 135deg) => 111110
     2398    // 6 (-135deg) => 111111
     2399    // Right-friendly direction
     2400    // 0 (   0deg) => 0
     2401    // 1 ( -45deg) => 10
     2402    // 2 (  45deg) => 110
     2403    // 3 ( -90deg) => 1110
     2404    // 4 (  90deg) => 11110
     2405    // 5 (-135deg) => 111110
     2406    // 6 ( 135deg) => 111111
     2407    // refer to a paper "An efficient chain code with Huffman coding"
     2408    for( UInt ui = 0; ui < 6; ui++ )
     2409    {
     2410      m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) );
     2411      ucEdge <<= 1;
     2412      ucEdge |= uiSymbol;
     2413      if( uiSymbol == 0 )
     2414        break;
     2415    }
     2416
     2417    switch( ucEdge )
     2418    {
     2419    case 0 :  // "0"
     2420      uiReorderEdge = 0;
     2421      break;
     2422    case 2 :  // "10"
     2423      uiReorderEdge = 1;
     2424      break;
     2425    case 6 :  // "110"
     2426      uiReorderEdge = 2;
     2427      break;
     2428    case 14 : // "1110"
     2429      uiReorderEdge = 3;
     2430      break;
     2431    case 30 : // "11110"
     2432      uiReorderEdge = 4;
     2433      break;
     2434    case 62 : // "111110"
     2435      uiReorderEdge = 5;
     2436      break;
     2437    case 63 : // "111111"
     2438      uiReorderEdge = 6;
     2439      break;
     2440    default :
     2441      printf("parseIntraEdgeChain: error (unknown code %d)\n",ucEdge);
     2442      assert(false);
     2443      break;
     2444    }
     2445    pucSymbolList[iPtr] = uiReorderEdge;
     2446  }
     2447  /////////////////////
     2448  // Edge Reconstruction
     2449  Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx );
     2450  pcCU->reconPartition( uiAbsPartIdx, uiDepth, ucLeft == 1, ucStart, ucMax, pucSymbolList, pbRegion );
     2451  xFree( pucSymbolList );
     2452}
     2453#endif
     2454
    22722455//! \}
  • trunk/source/Lib/TLibDecoder/TDecSbac.h

    r77 r100  
    146146#endif
    147147 
     148#if LGE_EDGE_INTRA
     149  Void xParseEdgeIntraInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     150#endif
     151 
    148152private:
    149153  TComInputBitstream* m_pcBitstream;
     
    253257  ContextModel3DBuffer m_cDmmDataSCModel;
    254258#endif
     259#if LGE_EDGE_INTRA
     260  ContextModel3DBuffer m_cEdgeIntraSCModel;
     261#if LGE_EDGE_INTRA_DELTA_DC
     262  ContextModel3DBuffer m_cEdgeIntraDeltaDCSCModel;
     263#endif
     264#endif
    255265};
    256266
  • trunk/source/Lib/TLibDecoder/TDecSlice.h

    r77 r100  
    107107  ParameterSetMap<TComAPS> m_apsBuffer;
    108108#if VIDYO_VPS_INTEGRATION
    109         ParameterSetMap<TComVPS> m_vpsBuffer;
     109  ParameterSetMap<TComVPS> m_vpsBuffer;
    110110#endif
    111111};
  • trunk/source/Lib/TLibDecoder/TDecTop.h

    r77 r100  
    176176  Void executeDeblockAndAlf(UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame,  Int& iPOCLastDisplay);
    177177
    178   Void setViewId(Int viewId)                                    { m_viewId = viewId;}
    179   Int  getViewId()                                                                     { return m_viewId  ;}
     178  Void setViewId(Int viewId)      { m_viewId = viewId;}
     179  Int  getViewId()                { return m_viewId  ;}
    180180  Void setIsDepth( Bool isDepth ) { m_isDepth = isDepth; }
    181181
    182182#if SONY_COLPIC_AVAILABILITY
    183   Void setViewOrderIdx(Int i)                                   { m_iViewOrderIdx = i ;}
    184   Int  getViewOrderIdx()                                                        { return m_iViewOrderIdx ; }
     183  Void setViewOrderIdx(Int i)     { m_iViewOrderIdx = i ;}
     184  Int  getViewOrderIdx()          { return m_iViewOrderIdx ; }
    185185#endif
    186186
     
    209209#endif
    210210#if VIDYO_VPS_INTEGRATION
    211         Void      xDecodeVPS();
     211  Void      xDecodeVPS();
    212212#endif
    213213  Void      xDecodeSPS();
  • trunk/source/Lib/TLibEncoder/TEncCavlc.cpp

    r77 r100  
    378378Void TEncCavlc::codeVPS( TComVPS* pcVPS )
    379379{
    380         WRITE_CODE( pcVPS->getMaxTLayers() - 1,     3,        "max_temporal_layers_minus1" );
     380  WRITE_CODE( pcVPS->getMaxTLayers() - 1,     3,        "max_temporal_layers_minus1" );
    381381  WRITE_CODE( pcVPS->getMaxLayers() - 1,      5,        "max_layers_minus1" );
    382382  WRITE_FLAG( pcVPS->getTemporalNestingFlag() - 1,      "temporal_id_nesting_flag" );
     
    775775    {
    776776      WRITE_CODE( (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC()))%(1<<pcSlice->getSPS()->getBitsForPOC()), pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb");
    777 #if HHI_FIX
    778777      if( pcSlice->getPOC() == 0 && pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV )
    779778      {
     
    848847      }
    849848      if( pcSlice->getPOC() != 0 )
    850 #else
    851       if( pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV )
    852 #endif
    853849      {
    854850        TComReferencePictureSet* rps = pcSlice->getRPS();
  • trunk/source/Lib/TLibEncoder/TEncCfg.h

    r77 r100  
    205205  UInt      m_uiVSOMode;
    206206#endif
     207#if SAIT_VSO_EST_A0033
     208  Bool      m_bUseEstimatedVSD;
     209  Double    m_dDispCoeff;
     210#endif
     211
    207212
    208213  //====== Tool list ========
     
    568573#endif
    569574
     575#if SAIT_VSO_EST_A0033
     576  Void      setUseEstimatedVSD              ( Bool  b )     { m_bUseEstimatedVSD = b; }
     577  Void      setDispCoeff                    ( Double  d )   { m_dDispCoeff  = d; }
     578#endif
     579
    570580  Void      setUseFastEnc                   ( Bool  b )     { m_bUseFastEnc = b; }
    571581  Void      setUseEarlyCU                   ( Bool  b )     { m_bUseEarlyCU = b; }
     
    608618  Bool      getUseVSO                       ()      { return m_bUseVSO;     }
    609619#endif
     620#if SAIT_VSO_EST_A0033
     621  Bool      getUseEstimatedVSD              ()      { return m_bUseEstimatedVSD; }
     622  Double    getDispCoeff                    ()      { return m_dDispCoeff;    }
     623#endif
     624
    610625  Bool      getUseFastEnc                   ()      { return m_bUseFastEnc; }
    611626  Bool      getUseEarlyCU                   ()      { return m_bUseEarlyCU; }
  • trunk/source/Lib/TLibEncoder/TEncCu.cpp

    r81 r100  
    11561156      if( m_pcRdCost->getUseRenModel() )
    11571157      {
    1158 #if HHI_FIX
    11591158        UInt  uiWidth     = m_ppcOrigYuv[uiDepth]->getWidth ( );
    11601159        UInt  uiHeight    = m_ppcOrigYuv[uiDepth]->getHeight( );
     
    11621161        UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride();
    11631162        m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1164 #else
    1165         UInt  uiWidth     = m_ppcBestCU[uiDepth]->getWidth ( 0 );
    1166         UInt  uiHeight    = m_ppcBestCU[uiDepth]->getHeight( 0 );
    1167         Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getLumaAddr( 0 );
    1168         UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride();
    1169         m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1170 #endif
    11711163      }
    11721164#endif
     
    12121204
    12131205#if HHI_VSO
     1206#if HHI_VSO_SET_OPTIM
     1207#else
    12141208          if( m_pcRdCost->getUseRenModel() ) // necessary ??
    12151209          {
    1216 #if HHI_FIX
    12171210            UInt  uiWidth     = m_ppcRecoYuvBest[uhNextDepth]->getWidth   (  );
    12181211            UInt  uiHeight    = m_ppcRecoYuvBest[uhNextDepth]->getHeight  (   );
     
    12201213            UInt  uiSrcStride = m_ppcRecoYuvBest[uhNextDepth]->getStride  (   );
    12211214            m_pcRdCost->setRenModelData( pcSubBestPartCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1222 #else
    1223             UInt  uiWidth     = pcSubBestPartCU->getWidth ( 0 );
    1224             UInt  uiHeight    = pcSubBestPartCU->getHeight( 0 );
    1225             Pel*  piSrc       = m_ppcRecoYuvBest[pcSubBestPartCU->getDepth(0)]->getLumaAddr( 0 );
    1226             UInt  uiSrcStride = m_ppcRecoYuvBest[pcSubBestPartCU->getDepth(0)]->getStride();
    1227             m_pcRdCost->setRenModelData( pcSubBestPartCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1228 #endif
    1229           }
     1215          }
     1216#endif
    12301217#endif
    12311218        }
     
    13691356  if( m_pcRdCost->getUseRenModel() )
    13701357  {
    1371 #if HHI_FIX
    13721358      UInt  uiWidth     = m_ppcRecoYuvBest[uiDepth]->getWidth   ( );
    13731359      UInt  uiHeight    = m_ppcRecoYuvBest[uiDepth]->getHeight  ( );
     
    13751361      UInt  uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride  ( );
    13761362      m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1377 #else
    1378     UInt  uiWidth     = rpcBestCU->getWidth ( 0 );
    1379     UInt  uiHeight    = rpcBestCU->getHeight( 0 );
    1380     Pel*  piSrc       = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 );
    1381     UInt  uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride();
    1382     m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1383 #endif
    13841363  }
    13851364#endif
     
    17471726  if( m_pcRdCost->getUseRenModel() )
    17481727  {
    1749 #if HHI_FIX
    17501728    UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( );
    17511729    UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( );
     
    17531731    UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
    17541732    m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1755 #else
    1756     UInt  uiWidth     = rpcTempCU->getWidth ( 0 );
    1757     UInt  uiHeight    = rpcTempCU->getHeight( 0 );
    1758     Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
    1759     UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
    1760     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1761 #endif
    17621733  }
    17631734#endif
     
    18511822          if( m_pcRdCost->getUseRenModel() )
    18521823          { //Reset
    1853 #if HHI_FIX
    18541824            UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ();
    18551825            UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ();
     
    18571827            UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ();
    18581828            m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1859 #else
    1860             UInt  uiWidth     = rpcTempCU->getWidth ( 0 );
    1861             UInt  uiHeight    = rpcTempCU->getHeight( 0 );
    1862             Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
    1863             UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
    1864             m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1865 #endif
    18661829          }
    18671830#endif
     
    19271890  if( m_pcRdCost->getUseRenModel() )
    19281891  {
    1929 #if HHI_FIX
    19301892    UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( );
    19311893    UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( );
     
    19331895    UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
    19341896    m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1935 #else
    1936     UInt  uiWidth     = rpcTempCU->getWidth ( 0 );
    1937     UInt  uiHeight    = rpcTempCU->getHeight( 0 );
    1938     Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
    1939     UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
    1940     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1941 #endif
    19421897  }
    19431898#endif 
     
    20462001  if( m_pcRdCost->getUseRenModel() )
    20472002  {
    2048 #if HHI_FIX
    20492003    UInt  uiWidth     = m_ppcOrigYuv[uiDepth]->getWidth   ();
    20502004    UInt  uiHeight    = m_ppcOrigYuv[uiDepth]->getHeight  ();
     
    20522006    UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride  ();
    20532007    m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2054 #else
    2055     UInt  uiWidth     = rpcTempCU->getWidth ( 0 );
    2056     UInt  uiHeight    = rpcTempCU->getHeight( 0 );
    2057     Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getLumaAddr( );
    2058     UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride();
    2059     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2060 #endif
    20612008  }
    20622009#endif
     
    25572504  if( m_pcRdCost->getUseRenModel() && !bRecursiveCall)
    25582505  {
    2559 #if HHI_FIX
    25602506    UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth   ();
    25612507    UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight  ();
     
    25632509    UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride  ();
    25642510    m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2565 #else
    2566     UInt  uiWidth     = m_ppcTempCU [uhDepth]->getWidth ( 0 );
    2567     UInt  uiHeight    = m_ppcTempCU [uhDepth]->getHeight( 0 );
    2568     Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( 0 );
    2569     UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
    2570     m_pcRdCost->setRenModelData( m_ppcTempCU[uhDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2571 #endif
    25722511  }
    25732512#endif
     
    27172656  if( !bSplit && bRecursiveCall && m_pcRdCost->getUseRenModel() )
    27182657  {
    2719 #if HHI_FIX
    27202658    UInt  uiWidth     = m_ppcRecoYuvBest[uhDepth]->getWidth   (   );
    27212659    UInt  uiHeight    = m_ppcRecoYuvBest[uhDepth]->getHeight  (   );
     
    27232661    Pel*  piSrc       = m_ppcRecoYuvBest[uhDepth]->getLumaAddr( 0 );
    27242662    m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2725 #else
    2726     UInt  uiWidth     = rpcBestCU->getWidth ( 0 );
    2727     UInt  uiHeight    = rpcBestCU->getHeight( 0 );
    2728     Pel*  piSrc       = m_ppcRecoYuvBest[uhDepth]->getLumaAddr( 0 );
    2729     UInt  uiSrcStride = m_ppcRecoYuvBest[uhDepth]->getStride();
    2730     m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2731 #endif
    27322663  }
    27332664#endif
  • trunk/source/Lib/TLibEncoder/TEncEntropy.h

    r77 r100  
    7777
    7878#if VIDYO_VPS_INTEGRATION
    79         virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
    80 #endif
    81        
     79  virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
     80#endif
     81
    8282#if HHI_MPI
    8383  virtual Void  codeSPS                 ( TComSPS* pcSPS, Bool bIsDepth )                       = 0;
     
    234234public:
    235235#if VIDYO_VPS_INTEGRATION
    236         Void encodeVPS               ( TComVPS* pcVPS);
     236  Void encodeVPS               ( TComVPS* pcVPS);
    237237#endif
    238238  // SPS
  • trunk/source/Lib/TLibEncoder/TEncGOP.cpp

    r77 r100  
    436436  Bool bUseVSO = m_pcEncTop->getUseVSO();
    437437  m_pcRdCost->setUseVSO( bUseVSO );
     438#if SAIT_VSO_EST_A0033
     439  m_pcRdCost->setUseEstimatedVSD( m_pcEncTop->getUseEstimatedVSD() );
     440#endif
    438441
    439442  if ( bUseVSO )
     
    445448#endif
    446449
     450#if HHI_VSO_SPEEDUP_A033
     451#else
    447452    if ( iVSOMode == 4 )
    448453    {
     
    453458      AOT(true);
    454459    }
     460#endif
     461
     462#if SAIT_VSO_EST_A0033
     463    m_pcRdCost->setVideoRecPicYuv( m_pcEncTop->getEncTop()->xGetPicYuvFromViewTemp( pcSlice->getViewId(), pcSlice->getPOC(), false, true ) );
     464    m_pcRdCost->setDepthPicYuv   ( m_pcEncTop->getEncTop()->xGetPicYuvFromViewTemp( pcSlice->getViewId(), pcSlice->getPOC(), true, false ) );
     465#endif
     466
     467
    455468  }
    456469#endif
     
    691704      // init view component and predict virtual depth map
    692705      m_pcDepthMapGenerator->initViewComponent( pcPic );
     706#if !QC_MULTI_DIS_CAN
    693707      m_pcDepthMapGenerator->predictDepthMap  ( pcPic );
     708#endif
    694709#endif
    695710#if HHI_INTER_VIEW_MOTION_PRED
     
    758773#endif
    759774#if DEPTH_MAP_GENERATION
     775#if !QC_MULTI_DIS_CAN
    760776      // update virtual depth map
    761777      m_pcDepthMapGenerator->updateDepthMap( pcPic );
     778#endif
    762779#endif
    763780
     
    24752492    if( hasModification )
    24762493    {
    2477             Int temporalRefIdx = 0;
    2478             for( Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++ )
    2479             {
    2480               if( tempListEntryL0[i] >= 0 )
    2481               {
    2482                 refPicListModification->setRefPicSetIdxL0( i, tempListEntryL0[i] );
    2483               }
    2484               else
    2485               {
    2486                 refPicListModification->setRefPicSetIdxL0( i, temporalRefIdx );
    2487                 temporalRefIdx++;
    2488               }
    2489             }
    2490           }
     2494      Int temporalRefIdx = 0;
     2495      for( Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++ )
     2496      {
     2497        if( tempListEntryL0[i] >= 0 )
     2498        {
     2499          refPicListModification->setRefPicSetIdxL0( i, tempListEntryL0[i] );
     2500        }
     2501        else
     2502        {
     2503          refPicListModification->setRefPicSetIdxL0( i, temporalRefIdx );
     2504          temporalRefIdx++;
     2505        }
     2506      }
     2507    }
    24912508    else
    24922509    {
     
    25202537    if( hasModification )
    25212538    {
    2522             Int temporalRefIdx = 0;
    2523             for( Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++ )
    2524             {
    2525               if( tempListEntryL1[i] >= 0 )
    2526               {
    2527                 refPicListModification->setRefPicSetIdxL1( i, tempListEntryL1[i] );
    2528               }
    2529               else
    2530               {
    2531                 refPicListModification->setRefPicSetIdxL1( i, temporalRefIdx );
    2532                 temporalRefIdx++;
    2533               }
    2534             }
     2539      Int temporalRefIdx = 0;
     2540      for( Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++ )
     2541      {
     2542        if( tempListEntryL1[i] >= 0 )
     2543        {
     2544          refPicListModification->setRefPicSetIdxL1( i, tempListEntryL1[i] );
     2545        }
     2546        else
     2547        {
     2548          refPicListModification->setRefPicSetIdxL1( i, temporalRefIdx );
     2549          temporalRefIdx++;
     2550        }
     2551      }
    25352552    }
    25362553    else
  • trunk/source/Lib/TLibEncoder/TEncGOP.h

    r56 r100  
    137137 
    138138  Void  preLoopFilterPicAll  ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits );
     139#if HHI_VSO_SPEEDUP_A033
     140  TEncTop* getEncTop() { return m_pcEncTop; }
     141#endif
    139142 
    140143  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
  • trunk/source/Lib/TLibEncoder/TEncSbac.cpp

    r77 r100  
    106106, m_cDmmDataSCModel           ( 1,             1,               NUM_DMM_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    107107#endif
     108#if LGE_EDGE_INTRA
     109, m_cEdgeIntraSCModel         ( 1,             1,               NUM_EDGE_INTRA_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
     110#if LGE_EDGE_INTRA_DELTA_DC
     111, m_cEdgeIntraDeltaDCSCModel  ( 1,             1,               NUM_EDGE_INTRA_DELTA_DC_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
     112#endif
     113#endif
    108114{
    109115  assert( m_numContextModels <= MAX_NUM_CTX_MOD );
     
    181187  m_cDmmDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_DATA );
    182188#endif
     189#if LGE_EDGE_INTRA
     190  m_cEdgeIntraSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_EDGE_INTRA );
     191#if LGE_EDGE_INTRA_DELTA_DC
     192  m_cEdgeIntraDeltaDCSCModel.initBuffer  ( eSliceType, iQp, (UChar*)INIT_EDGE_INTRA_DELTA_DC );
     193#endif
     194#endif
    183195
    184196  // new structure
     
    345357Void TEncSbac::codeVPS( TComVPS* pcVPS )
    346358{
    347         assert (0);
     359  assert (0);
    348360  return;
    349361}
     
    828840  DTRACE_CABAC_T( "\n" )
    829841}
     842
     843#if LGE_EDGE_INTRA
     844Void TEncSbac::xCodeEdgeIntraInfo( TComDataCU* pcCU, UInt uiPartIdx )
     845{
     846  UInt   uiDepth        = pcCU->getDepth( uiPartIdx ) + (pcCU->getPartitionSize( uiPartIdx ) == SIZE_NxN ? 1 : 0);
     847  UInt   uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiPartIdx );
     848  UChar* pucSymbolList  = pcCU->getEdgeCode( uiPartIdx );
     849  UChar  ucEdgeNumber   = pcCU->getEdgeNumber( uiPartIdx );
     850  Bool   bLeft          = pcCU->getEdgeLeftFirst( uiPartIdx );
     851  UChar  ucStart        = pcCU->getEdgeStartPos( uiPartIdx );
     852  UInt   uiSymbol;
     853
     854  // 1. Top(0) or Left(1)
     855  uiSymbol = (bLeft == false) ? 0 : 1;
     856  m_pcBinIf->encodeBinEP( uiSymbol );
     857
     858  // 2. Start position (lowest bit first)
     859  uiSymbol = ucStart;
     860  for( UInt ui = 6; ui > uiDepth; ui-- ) // 64(0)->6, 32(1)->5, 16(2)->4, 8(3)->3, 4(4)->2
     861  {
     862    m_pcBinIf->encodeBinEP( uiSymbol & 0x1 );
     863    uiSymbol >>= 1;
     864  }
     865
     866  // 3. Number of edges
     867  uiSymbol = ucEdgeNumber > 0 ? ucEdgeNumber - 1 : 0;
     868  for( UInt ui = 7; ui > uiDepth; ui-- ) // 64(0)->7, 32(1)->6, 16(2)->5, 8(3)->4, 4(4)->3
     869  {
     870    m_pcBinIf->encodeBinEP( uiSymbol & 0x1 );
     871    uiSymbol >>= 1;
     872  }
     873
     874  if(uiSymbol != 0)
     875  {
     876    printf(" ucEdgeNumber %d at depth %d\n",ucEdgeNumber, uiDepth);
     877    assert(false);
     878  }
     879
     880  // 4. Edges
     881  for( Int iPtr2 = 0; iPtr2 < ucEdgeNumber; iPtr2++ )
     882  {
     883    UInt uiReorderSymbol = pucSymbolList[iPtr2];
     884
     885    //printf ("Ptr = %d, Symbol = %d\n", iPtr2, uiSymbol);
     886
     887    // Left-friendly direction (Top start)
     888    // 0 (   0deg) => 0
     889    // 1 (  45deg) => 10
     890    // 2 ( -45deg) => 110
     891    // 3 (  90deg) => 1110
     892    // 4 ( -90deg) => 11110
     893    // 5 ( 135deg) => 111110
     894    // 6 (-135deg) => 111111
     895    // Right-friendly direction (Left start)
     896    // 0 (   0deg) => 0
     897    // 2 ( -45deg) => 10
     898    // 1 (  45deg) => 110
     899    // 4 ( -90deg) => 1110
     900    // 3 (  90deg) => 11110
     901    // 6 (-135deg) => 111110
     902    // 5 ( 135deg) => 111111
     903
     904    // refer to a paper "An efficient chain code with Huffman coding"
     905
     906    for( UInt ui = 0; ui < uiReorderSymbol; ui++ )
     907    {
     908      m_pcBinIf->encodeBin( 1, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) );
     909    }
     910
     911    if( uiReorderSymbol != 6 )
     912      m_pcBinIf->encodeBin( 0, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) );
     913  }
     914}
     915#endif
     916
    830917Void TEncSbac::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx )
    831918{
     
    835922  if( pcCU->getSlice()->getSPS()->getUseDMM() && pcCU->getWidth( uiAbsPartIdx ) <= DMM_WEDGEMODEL_MAX_SIZE )
    836923  {
     924#if LGE_EDGE_INTRA
     925    m_pcBinIf->encodeBin( uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX, m_cDmmFlagSCModel.get(0, 0, 0) );
     926#else
    837927    m_pcBinIf->encodeBin( uiDir >= NUM_INTRA_MODE, m_cDmmFlagSCModel.get(0, 0, 0) );
    838   }
     928#endif
     929  }
     930#if LGE_EDGE_INTRA
     931  if( uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX )
     932#else
    839933  if( uiDir >= NUM_INTRA_MODE )
     934#endif
    840935  {
    841936    assert( pcCU->getWidth( uiAbsPartIdx ) <= DMM_WEDGEMODEL_MAX_SIZE );
     
    870965  }
    871966  else
     967#if LGE_EDGE_INTRA
     968    if ( uiDir >= EDGE_INTRA_IDX)
     969    {
     970      m_pcBinIf->encodeBin( 0, m_cCUIntraPredSCModel.get( 0, 0, 0 ) );
     971      m_pcBinIf->encodeBinsEP( 63, 6 );
     972      xCodeEdgeIntraInfo( pcCU, uiAbsPartIdx );
     973#if LGE_EDGE_INTRA_DELTA_DC
     974      m_pcBinIf->encodeBin( (uiDir == EDGE_INTRA_DELTA_IDX), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) );
     975      if( uiDir == EDGE_INTRA_DELTA_IDX )
     976      {
     977        Int iDeltaDC0 = pcCU->getEdgeDeltaDC0( uiAbsPartIdx );
     978        Int iDeltaDC1 = pcCU->getEdgeDeltaDC1( uiAbsPartIdx );
     979
     980        xWriteExGolombLevel( UInt( abs( iDeltaDC0 ) ), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
     981        if ( iDeltaDC0 != 0 )
     982        {
     983          UInt uiSign = iDeltaDC0 > 0 ? 0 : 1;
     984          m_pcBinIf->encodeBinEP( uiSign );
     985        }
     986        xWriteExGolombLevel( UInt( abs( iDeltaDC1 ) ), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
     987        if ( iDeltaDC1 != 0 )
     988        {
     989          UInt uiSign = iDeltaDC1 > 0 ? 0 : 1;
     990          m_pcBinIf->encodeBinEP( uiSign );
     991        }
     992      }
     993#endif
     994    }
     995    else
     996#endif // LGE_EDGE_INTRA
    872997  {
    873998#endif
    874999#if !LOGI_INTRA_NAME_3MPM
    8751000  Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
     1001#endif
     1002#if LGE_EDGE_INTRA
     1003  Bool bCodeEdgeIntra = false;
     1004  if( pcCU->getSlice()->getSPS()->isDepth() )
     1005  {
     1006    UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0);
     1007    if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE )
     1008      bCodeEdgeIntra = true;
     1009  }
    8761010#endif
    8771011 
     
    9321066#if LOGI_INTRA_NAME_3MPM
    9331067    m_pcBinIf->encodeBinsEP( uiDir, 5 );
     1068#if LGE_EDGE_INTRA
     1069  if (bCodeEdgeIntra)
     1070    if (uiDir == 31) m_pcBinIf->encodeBinsEP(0,1);
     1071#endif
    9341072#else
    9351073    if ( uiDir < 31 )
     
    22702408}
    22712409
    2272 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     2410#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA && LGE_EDGE_INTRA_DELTA_DC)
    22732411Void TEncSbac::xWriteExGolombLevel( UInt uiSymbol, ContextModel& rcSCModel  )
    22742412{
  • trunk/source/Lib/TLibEncoder/TEncSbac.h

    r77 r100  
    101101  Void  codeVPS                 ( TComVPS* pcVPS );
    102102#endif
    103        
     103 
    104104#if HHI_MPI
    105105  Void  codeSPS                 ( TComSPS* pcSPS, Bool bIsDepth );
     
    174174  Void  xCodeWedgePredTexDeltaInfo  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    175175  Void  xCodeContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx );
     176#endif
     177#if LGE_EDGE_INTRA
     178  Void  xCodeEdgeIntraInfo( TComDataCU* pcCU, UInt uiPartIdx );
    176179#endif
    177180
     
    307310  ContextModel3DBuffer m_cDmmDataSCModel;
    308311#endif
     312#if LGE_EDGE_INTRA
     313  ContextModel3DBuffer m_cEdgeIntraSCModel;
     314#if LGE_EDGE_INTRA_DELTA_DC
     315  ContextModel3DBuffer m_cEdgeIntraDeltaDCSCModel;
     316#endif
     317#endif
    309318};
    310319
  • trunk/source/Lib/TLibEncoder/TEncSearch.cpp

    r81 r100  
    304304  // motion cost
    305305  uiSad += m_pcRdCost->getCost( iSearchX, iSearchY );
    306 #if HHI_FIX 
     306
    307307  // regularization cost
    308308  if( m_pcRdCost->useMultiviewReg() )
     
    310310    uiSad += m_pcRdCost->getMultiviewRegCost( iSearchX, iSearchY );
    311311  }
    312 #endif
    313312  if( uiSad < rcStruct.uiBestSad )
    314313  {
     
    957956                                TComYuv*    pcPredYuv,
    958957                                TComYuv*    pcResiYuv,
    959                                 Dist&       ruiDist )
     958                                Dist&       ruiDist
     959#if LG_ZEROINTRADEPTHRESI_M26039
     960                                ,Bool        bZeroResi
     961#endif
     962                                )
    960963{
    961964  UInt    uiLumaPredMode    = pcCU     ->getLumaIntraDir     ( uiAbsPartIdx );
     
    989992  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
    990993 
     994#if LGE_EDGE_INTRA
     995  if( uiLumaPredMode >= EDGE_INTRA_IDX )
     996  {
     997#if LGE_EDGE_INTRA_DELTA_DC
     998    if( uiLumaPredMode == EDGE_INTRA_DELTA_IDX )
     999      xAssignEdgeIntraDeltaDCs( pcCU, uiAbsPartIdx, piOrg, uiStride, piPred, uiWidth, uiHeight );
     1000#endif
     1001
     1002    predIntraLumaEdge( pcCU, pcCU->getPattern(), uiAbsPartIdx, uiWidth, uiHeight, piPred, uiStride
     1003#if LGE_EDGE_INTRA_DELTA_DC
     1004     , uiLumaPredMode == EDGE_INTRA_DELTA_IDX
     1005#endif
     1006    );
     1007  }
     1008  else
     1009#endif
     1010 
    9911011  //===== get prediction signal =====
    9921012#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     
    10201040    }
    10211041  }
     1042#if LG_ZEROINTRADEPTHRESI_M26039
     1043  if(bZeroResi)
     1044  {
     1045    Pel* pResi = piResi;
     1046
     1047    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
     1048    {
     1049      memset( pResi, 0, sizeof( Pel ) * uiWidth );
     1050      pResi += uiStride;
     1051    }
     1052  }
     1053#endif
    10221054 
    10231055  //===== transform and quantization =====
     
    13111343                                Bool         bCheckFirst,
    13121344#endif
    1313                                 Double&      dRDCost )
     1345                                Double&      dRDCost
     1346#if LG_ZEROINTRADEPTHRESI_M26039
     1347                               ,Bool         bZeroResi
     1348#endif
     1349                              )
    13141350{
    13151351  UInt    uiFullDepth   = pcCU->getDepth( 0 ) +  uiTrDepth;
     
    13261362#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    13271363  if( pcCU->getLumaIntraDir( uiAbsPartIdx ) >= NUM_INTRA_MODE )
     1364  {
     1365    bCheckSplit = false;
     1366  }
     1367#endif
     1368#if LGE_EDGE_INTRA
     1369  if( pcCU->getLumaIntraDir( uiAbsPartIdx ) >= EDGE_INTRA_IDX )
    13281370  {
    13291371    bCheckSplit = false;
     
    13461388    //----- code luma block with given intra prediction mode and store Cbf-----
    13471389    dSingleCost   = 0.0;
     1390#if LG_ZEROINTRADEPTHRESI_M26039
     1391    xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, uiSingleDistY, bZeroResi );
     1392#else
    13481393    xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, uiSingleDistY );
     1394#endif
    13491395    if( bCheckSplit )
    13501396    {
     
    18081854    Int numModesForFullRD = g_aucIntraModeNumFast[ uiWidthBit ];
    18091855   
     1856#if LGE_EDGE_INTRA
     1857  Bool bTestEdgeIntra = false;
     1858  if ( m_pcEncCfg->isDepthCoder() && uiWidth >= LGE_EDGE_INTRA_MIN_SIZE && uiWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiWidth == uiHeight )
     1859  {
     1860    bTestEdgeIntra = true;
     1861
     1862    Bool bEdgeExist;
     1863
     1864    bEdgeExist = xEdgePartition( pcCU, uiPartOffset, pcCU->getPartitionSize(0) == SIZE_NxN );
     1865
     1866    if( !bEdgeExist )
     1867      bTestEdgeIntra = false;
     1868  }
     1869#endif
     1870   
    18101871#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    18111872    Bool bTestDmm = ( m_pcEncCfg->getUseDMM() );
     
    18281889
    18291890        predIntraLumaAng( pcCU->getPattern(), uiMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
    1830        
     1891
    18311892        // use hadamard transform here
    1832       Dist uiSad;
     1893        Dist uiSad;
    18331894#if HHI_VSO
    1834       if ( m_pcRdCost->getUseVSO() )
    1835       {
    1836         Bool bSad = !m_pcRdCost->getUseRenModel();
    1837         uiSad = m_pcRdCost->getDistVS(pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, bSad, 0 );
    1838       }
    1839       else
    1840 #endif
    1841       {
    1842         uiSad = (Dist) m_pcRdCost->calcHAD( piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight );
    1843       }
    1844        
     1895        if ( m_pcRdCost->getUseVSO() )
     1896        {
     1897#if SAIT_VSO_EST_A0033
     1898          if ( m_pcRdCost->getUseEstimatedVSD() )
     1899          {         
     1900            TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
     1901            TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
     1902
     1903            uiSad = (Dist) ( m_pcRdCost->getDistPart( piPred, uiStride, piOrg, uiStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset), pcVirRec->getStride(), uiWidth, uiHeight ) );
     1904          }
     1905          else
     1906#endif
     1907          {         
     1908            Bool bSad = !m_pcRdCost->getUseRenModel();
     1909            uiSad = m_pcRdCost->getDistVS(pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, bSad, 0 );
     1910          }
     1911
     1912        }
     1913        else
     1914#endif
     1915        {
     1916          uiSad = (Dist) m_pcRdCost->calcHAD( piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight );
     1917        }
     1918
    18451919        UInt   iModeBits = xModeBitsIntra( pcCU, uiMode, uiPU, uiPartOffset, uiDepth, uiInitTrDepth );
    18461920
    1847       Double dLambda;
     1921        Double dLambda;
    18481922#if HHI_VSO
    1849       if ( m_pcRdCost->getUseLambdaScaleVSO() )
    1850       {
    1851         dLambda = m_pcRdCost->getUseRenModel() ? m_pcRdCost->getLambdaVSO() : m_pcRdCost->getSqrtLambdaVSO();
    1852         //GT: Sad is SSE for VSO4
    1853       }
    1854       else
    1855       {
     1923        if ( m_pcRdCost->getUseLambdaScaleVSO() )
     1924        {
     1925          dLambda = m_pcRdCost->getUseRenModel() ? m_pcRdCost->getLambdaVSO() : m_pcRdCost->getSqrtLambdaVSO();
     1926          //GT: Sad is SSE for VSO4
     1927        }
     1928        else
     1929        {
     1930          dLambda = m_pcRdCost->getSqrtLambda();
     1931        }
     1932#else
    18561933        dLambda = m_pcRdCost->getSqrtLambda();
    1857       }
    1858 #else
    1859       dLambda = m_pcRdCost->getSqrtLambda();
    1860 #endif
    1861 
    1862       Double cost = (Double)uiSad + (Double)iModeBits *  dLambda;
    1863        
     1934#endif
     1935
     1936        Double cost = (Double)uiSad + (Double)iModeBits *  dLambda;
     1937
    18641938        CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList );
    18651939
    18661940#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    18671941        if( bTestDmm ) bTestDmm = uiSad ? true : false;
     1942#endif
     1943#if LGE_EDGE_INTRA
     1944        if ( bTestEdgeIntra ) bTestEdgeIntra = uiSad ? true : false;
    18681945#endif
    18691946      }
     
    19742051    }
    19752052#endif
     2053#if LGE_EDGE_INTRA
     2054  if( bTestEdgeIntra )
     2055  {
     2056    uiRdModeList[ numModesForFullRD++ ] = EDGE_INTRA_IDX;
     2057#if LGE_EDGE_INTRA_DELTA_DC
     2058    uiRdModeList[ numModesForFullRD++ ] = EDGE_INTRA_DELTA_IDX;
     2059#endif
     2060  }
     2061#endif
    19762062
    19772063    //===== check modes (using r-d costs) =====
     
    19872073    for( UInt uiMode = 0; uiMode < numModesForFullRD; uiMode++ )
    19882074    {
     2075#if LG_ZEROINTRADEPTHRESI_M26039
     2076    Bool bAllowZeroResi = pcCU->getSlice()->getIsDepth() && (pcCU->getSlice()->getPOC()%pcCU->getPic()->getIntraPeriod());// && (uiMode < NUM_INTRA_MODE);
     2077    for(UInt uiCnt = 0; uiCnt < (bAllowZeroResi ? 2 : 1); uiCnt++)
     2078    {
     2079      Bool bZeroResi = uiCnt ? true : false;
     2080#endif
    19892081      // set luma prediction mode
    19902082      UInt uiOrgMode = uiRdModeList[uiMode];
    1991      
     2083
    19922084#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    1993       if( m_pcEncCfg->getIsDepth() && !predIntraLumaDMMAvailable( uiOrgMode, uiWidth, uiHeight ) )
     2085      if( m_pcEncCfg->getIsDepth() && !predIntraLumaDMMAvailable( uiOrgMode, uiWidth, uiHeight )
     2086#if LGE_EDGE_INTRA
     2087        && uiOrgMode < EDGE_INTRA_IDX
     2088#endif
     2089        )
    19942090      {
    19952091        continue;
     
    20202116
    20212117#if HHI_RQT_INTRA_SPEEDUP
     2118#if LG_ZEROINTRADEPTHRESI_M26039
     2119      xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost, bZeroResi );
     2120#else
    20222121      xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost );
     2122#endif
    20232123#else
    20242124      xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost );
     
    20522152        dSecondBestPUCost = dPUCost;
    20532153      }
     2154#endif
     2155#if LG_ZEROINTRADEPTHRESI_M26039
     2156    }
    20542157#endif
    20552158    } // Mode loop
     
    25792682      pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    25802683#if LG_RESTRICTEDRESPRED_M24766
    2581           Int iAddResiShift;
    2582           UInt uiPartAddr;
    2583           Int iRoiWidth, iRoiHeight;
    2584 
    2585           pcCU->getPartIndexAndSize( iPUIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    2586           iAddResiShift = pcCU->getResiPredMode(uiPartAddr);
    2587           iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || pcCU->getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1 - iAddResiShift : -1);
    2588 
    2589           if( pcCU->getResPredFlag( 0 ))
    2590           { // subtract residual prediction from original in motion search
    2591                   if(iLastAddResiShift != iAddResiShift)
    2592                   {
    2593                           //add subtracted residual last time
    2594                           if(iLastAddResiShift >= 0)
    2595                           {
    2596                                   iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
    2597                                   pcYuvOrg->add(iPUResiPredShift, ePartSize, rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
    2598                           }
    2599                           //subtract residual
    2600                           if(iAddResiShift >= 0)
    2601                           {
    2602                                   iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iAddResiShift;
    2603                                   pcYuvOrg->add(iPUResiPredShift, ePartSize, rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true );
    2604                           }
    2605                           iLastAddResiShift = iAddResiShift;
    2606                   }
    2607           }
     2684      Int iAddResiShift;
     2685      UInt uiPartAddr;
     2686      Int iRoiWidth, iRoiHeight;
     2687
     2688      pcCU->getPartIndexAndSize( iPUIdx, uiPartAddr, iRoiWidth, iRoiHeight );
     2689      iAddResiShift = pcCU->getResiPredMode(uiPartAddr);
     2690      iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || pcCU->getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1 - iAddResiShift : -1);
     2691
     2692      if( pcCU->getResPredFlag( 0 ))
     2693      { // subtract residual prediction from original in motion search
     2694        if(iLastAddResiShift != iAddResiShift)
     2695        {
     2696          //add subtracted residual last time
     2697          if(iLastAddResiShift >= 0)
     2698          {
     2699            iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
     2700            pcYuvOrg->add(iPUResiPredShift, ePartSize, rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
     2701          }
     2702          //subtract residual
     2703          if(iAddResiShift >= 0)
     2704          {
     2705            iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iAddResiShift;
     2706            pcYuvOrg->add(iPUResiPredShift, ePartSize, rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true );
     2707          }
     2708          iLastAddResiShift = iAddResiShift;
     2709        }
     2710      }
    26082711#endif
    26092712      xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() );
     
    26312734  if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0)
    26322735  {
    2633           iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
    2634           pcYuvOrg->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
     2736    iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
     2737    pcYuvOrg->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
    26352738  }
    26362739#endif
     
    27552858    UInt          uiBitsTempL0[MAX_NUM_REF];
    27562859#if LG_RESTRICTEDRESPRED_M24766
    2757         Int iPUResiPredShift[4] = {0, 0, 0, 0};
     2860    Int iPUResiPredShift[4] = {0, 0, 0, 0};
    27582861#endif
    27592862    xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
     
    27732876#endif
    27742877#if LG_RESTRICTEDRESPRED_M24766
    2775                 Bool bLastResiFlag = false;
     2878      Bool bLastResiFlag = false;
    27762879#endif
    27772880    //  Uni-directional prediction
     
    27832886      {
    27842887#if LG_RESTRICTEDRESPRED_M24766
    2785                   if( pcCU->getResPredFlag( 0 ))
    2786                   {
    2787                           if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp))
    2788                           { // subtract residual prediction from original in motion search
    2789                                   if(!bLastResiFlag)
    2790                                           pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true );
    2791                                   bLastResiFlag = true;
    2792                           }
    2793                           else
    2794                           {
    2795                                   if(bLastResiFlag)
    2796                                           pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
    2797                                   bLastResiFlag = false;
    2798                           }
    2799                   }
     2888        if( pcCU->getResPredFlag( 0 ))
     2889        {
     2890          if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp))
     2891          { // subtract residual prediction from original in motion search
     2892            if(!bLastResiFlag)
     2893              pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true );
     2894            bLastResiFlag = true;
     2895          }
     2896          else
     2897          {
     2898            if(bLastResiFlag)
     2899              pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
     2900            bLastResiFlag = false;
     2901          }
     2902        }
    28002903#endif
    28012904        uiBitsTemp = uiMbBits[iRefList];
     
    29633066    }
    29643067#if LG_RESTRICTEDRESPRED_M24766
    2965         if( pcCU->getResPredFlag( 0 ) && bLastResiFlag)
    2966         { // subtract residual prediction from original in motion search
    2967                 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
    2968         }
     3068    if( pcCU->getResPredFlag( 0 ) && bLastResiFlag)
     3069    { // subtract residual prediction from original in motion search
     3070      pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
     3071    }
    29693072#endif
    29703073    //  Bi-directional prediction
     
    29723075    {
    29733076#if LG_RESTRICTEDRESPRED_M24766
    2974                 Int iLastAddResiShift = -1000;
     3077      Int iLastAddResiShift = -1000;
    29753078#endif
    29763079      cMvBi[0] = cMv[0];            cMvBi[1] = cMv[1];
     
    30773180#endif
    30783181#if LG_RESTRICTEDRESPRED_M24766
    3079                   Int iAddResiShift = -1, iPredFrom = 0;
    3080                   Int iBestRefIdx = pcCU->getCUMvField(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
    3081 
    3082                   iPredFrom = iBestRefIdx >= 0 ? 3 : 1;
    3083                   if(iBestRefIdx >= 0 && pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0, iBestRefIdx))
    3084                           iAddResiShift++;
    3085                   if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp))
    3086                           iAddResiShift++;
    3087                   iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || iPredFrom != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
    3088 
    3089                   if( pcCU->getResPredFlag( 0 ) )
    3090                   {
    3091                           if(iLastAddResiShift != iAddResiShift)
    3092                           {
    3093                                   //add substracted residual last time
    3094                                   if(iLastAddResiShift >= 0 )
    3095                                   {
    3096                                           iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
    3097                                           pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
    3098                                   }
    3099                                   //substract residual
    3100                                   if(iAddResiShift >= 0)
    3101                                   {
    3102                                           iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iAddResiShift;
    3103                                           pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true );
    3104                                   }
    3105                                   iLastAddResiShift = iAddResiShift;
    3106                           }
    3107                   }
     3182          Int iAddResiShift = -1, iPredFrom = 0;
     3183          Int iBestRefIdx = pcCU->getCUMvField(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
     3184
     3185          iPredFrom = iBestRefIdx >= 0 ? 3 : 1;
     3186          if(iBestRefIdx >= 0 && pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0, iBestRefIdx))
     3187            iAddResiShift++;
     3188          if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp))
     3189            iAddResiShift++;
     3190          iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || iPredFrom != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
     3191
     3192          if( pcCU->getResPredFlag( 0 ) )
     3193          {
     3194            if(iLastAddResiShift != iAddResiShift)
     3195            {
     3196              //add substracted residual last time
     3197              if(iLastAddResiShift >= 0 )
     3198              {
     3199                iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
     3200                pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
     3201              }
     3202              //substract residual
     3203              if(iAddResiShift >= 0)
     3204              {
     3205                iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iAddResiShift;
     3206                pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true );
     3207              }
     3208              iLastAddResiShift = iAddResiShift;
     3209            }
     3210          }
    31083211#endif
    31093212          // call ME
     
    31623265      } // for loop-iter
    31633266#if LG_RESTRICTEDRESPRED_M24766
    3164           if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0)
    3165           {
    3166                   iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
    3167                   pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
    3168           }
     3267      if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0)
     3268      {
     3269        iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift;
     3270        pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
     3271      }
    31693272#endif
    31703273    } // if (B_SLICE)
     
    33753478      {
    33763479#if LG_RESTRICTEDRESPRED_M24766
    3377                   Int iAddResiShift = pcCU->getResiPredMode(uiPartAddr);
    3378                   iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = \
    3379                           (pcCU->getSlice()->getPPS()->getUseWP() || pcCU->getInterDir(uiPartAddr) != 3)? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
    3380                   if(pcCU->getResPredFlag(0) && iAddResiShift >= 0)
    3381                   {
    3382                           pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true);
    3383                   }
     3480        Int iAddResiShift = pcCU->getResiPredMode(uiPartAddr);
     3481        iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = \
     3482          (pcCU->getSlice()->getPPS()->getUseWP() || pcCU->getInterDir(uiPartAddr) != 3)? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1);
     3483        if(pcCU->getResPredFlag(0) && iAddResiShift >= 0)
     3484        {
     3485          pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true);
     3486        }
    33843487#endif
    33853488        xGetInterPredictionError( pcCU, pcOrgYuv, iPartIdx, uiMEError, m_pcEncCfg->getUseHADME() );
    33863489        uiMECost = uiMEError + m_pcRdCost->getCost( uiMEBits );
    33873490#if LG_RESTRICTEDRESPRED_M24766
    3388                 if(pcCU->getResPredFlag(0) && iAddResiShift >= 0)
    3389                 {
    3390                         pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
    3391                 }
     3491        if(pcCU->getResPredFlag(0) && iAddResiShift >= 0)
     3492        {
     3493          pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ));
     3494        }
    33923495#endif
    33933496      }
     
    38713974  else
    38723975  {
    3873 #if HHI_FIX
    38743976    rcMv = ( m_pcRdCost->useMultiviewReg() ? m_pcRdCost->getMultiviewOrgMvPred() : *pcMvPred );
    3875 #else
    3876     rcMv = *pcMvPred;
    3877 #endif
    38783977    xPatternSearchFast  ( pcCU, pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost );
    38793978  }
     
    39774076      uiSad += m_pcRdCost->getCost( x, y );
    39784077     
    3979 #if HHI_FIX
    39804078      // regularization cost
    39814079      if( m_pcRdCost->useMultiviewReg() )
     
    39834081        uiSad += m_pcRdCost->getMultiviewRegCost( x, y );
    39844082      }
    3985 #endif
    39864083
    39874084      if ( uiSad < uiSadBest )
     
    42814378    {
    42824379#if LG_RESTRICTEDRESPRED_M24766
    4283                 pcCU->getPUResiPredShift(iPUResiPredShift, 0);
    4284                 rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResPrd, uiWidth, uiHeight );
     4380      pcCU->getPUResiPredShift(iPUResiPredShift, 0);
     4381      rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResPrd, uiWidth, uiHeight );
    42854382#else
    42864383      rpcYuvRec->add( rpcYuvResPrd, uiWidth, uiHeight );
     
    42944391    {
    42954392      uiDistortion = m_pcRdCost->getDistVS( pcCU, 0, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight     , false, 0 );
    4296         }
     4393    }
    42974394    else   
    42984395    {
     
    43494446    pcCU->setTrIdxSubParts( 0, 0, pcCU->getDepth(0) );
    43504447   
     4448
    43514449#if HHI_VSO // necessary?
    43524450    // set Model
     4451#if SAIT_VSO_EST_A0033
     4452    if( !m_pcRdCost->getUseEstimatedVSD()&& m_pcRdCost->getUseRenModel() )
     4453#else
    43534454    if( m_pcRdCost->getUseRenModel() )
     4455#endif
    43544456    {
    43554457      Pel*  piSrc       = rpcYuvRec->getLumaAddr();
     
    43954497  {
    43964498#if LG_RESTRICTEDRESPRED_M24766
    4397           iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0;
    4398           rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), pcYuvOrg, pcYuvPred, 0, uiWidth );
     4499    iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0;
     4500    rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), pcYuvOrg, pcYuvPred, 0, uiWidth );
    43994501#else
    44004502  rpcYuvResi->subtract( pcYuvOrg, pcYuvPred, 0, uiWidth );
     
    44054507    {
    44064508#if LG_RESTRICTEDRESPRED_M24766
    4407                 pcCU->getPUResiPredShift(iPUResiPredShift, 0);
    4408                 rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResi, rpcYuvResPrd, 0, uiWidth );
     4509      pcCU->getPUResiPredShift(iPUResiPredShift, 0);
     4510      rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResi, rpcYuvResPrd, 0, uiWidth );
    44094511#else
    44104512      rpcYuvResi->subtract( rpcYuvResi, rpcYuvResPrd, 0, uiWidth );
     
    45794681    }
    45804682
     4683
    45814684#if HHI_VSO
    4582     // GT: reset Model, only fordQP necessary??
     4685#if SAIT_VSO_EST_A0033   
     4686    if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() )
     4687#else
    45834688    if( m_pcRdCost->getUseRenModel() )
     4689#endif
    45844690    {
    45854691      Pel*  piSrc       = pcYuvOrg->getLumaAddr();
     
    46244730    pcYuvPred->copyToPartYuv( rpcYuvRec, 0 );
    46254731#if LG_RESTRICTEDRESPRED_M24766
    4626         pcCU->getPUResiPredShift(iPUResiPredShift, 0);
    4627         rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResPrd,   uiWidth, uiHeight );
    4628         iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0;
     4732    pcCU->getPUResiPredShift(iPUResiPredShift, 0);
     4733    rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResPrd,   uiWidth, uiHeight );
     4734    iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0;
    46294735    rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResiBest, uiWidth, uiHeight );
    46304736#else
     
    46854791
    46864792  // set Model
     4793
    46874794#if HHI_VSO // necessary??
     4795#if SAIT_VSO_EST_A0033   
     4796  if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() )
     4797#else
    46884798  if( m_pcRdCost->getUseRenModel() )
     4799#endif
    46894800  {
    46904801    Pel*  piSrc       = rpcYuvRec->getLumaAddr();
     
    46934804}
    46944805#endif
    4695 
    46964806}
    46974807
     
    48694979    if ( m_pcRdCost->getUseVSO() )
    48704980    {
    4871       uiDistY = m_pcRdCost->getDistVS  ( pcCU, uiAbsPartIdx, pcPred->getLumaAddr( uiAbsPartIdx ), pcPred->getStride(), pcOrg->getLumaAddr( uiAbsPartIdx), pcOrg->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize, false, 0 ); // initialized with zero residual distortion
     4981#if SAIT_VSO_EST_A0033
     4982      if( m_pcRdCost->getUseEstimatedVSD() )
     4983      {
     4984        TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
     4985        TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
     4986        uiDistY = m_pcRdCost->getDistPart( m_pTempPel, 1<< uiLog2TrSize, pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride(), pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPartIdx), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPartIdx), pcVirRec->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize );
     4987      }
     4988      else
     4989#endif
     4990      {     
     4991        uiDistY = m_pcRdCost->getDistVS  ( pcCU, uiAbsPartIdx, pcPred->getLumaAddr( uiAbsPartIdx ), pcPred->getStride(), pcOrg->getLumaAddr( uiAbsPartIdx), pcOrg->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize, false, 0 ); // initialized with zero residual distortion
     4992      }
    48724993    }
    48734994    else
     
    48805001#endif
    48815002    }
    4882 
    48835003
    48845004    if ( puiZeroDist )
     
    49095029      if ( m_pcRdCost->getUseVSO() )
    49105030      {
    4911         static int iCount = 1;
    4912         iCount++;
    4913         m_cYuvRecTemp.addClipPartLuma( &m_pcQTTempTComYuv[uiQTTempAccessLayer], pcPred, uiAbsPartIdx, 1<< uiLog2TrSize  );
    4914         uiNonzeroDistY = m_pcRdCost->getDistVS( pcCU, uiAbsPartIdx, m_cYuvRecTemp.getLumaAddr(uiAbsPartIdx), m_cYuvRecTemp.getStride(),
    4915                                                 pcOrg->getLumaAddr( uiAbsPartIdx ), pcOrg->getStride(), 1<< uiLog2TrSize,   1<< uiLog2TrSize, false, 0 );
     5031#if SAIT_VSO_EST_A0033
     5032        if ( m_pcRdCost->getUseEstimatedVSD() )
     5033        {         
     5034          TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
     5035          TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
     5036          uiNonzeroDistY = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( uiAbsPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride(), pcVirRec->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiAbsPartIdx ), pcVirOrg->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiAbsPartIdx ), pcVirRec->getStride(), 1<< uiLog2TrSize,    1<< uiLog2TrSize );
     5037        }
     5038        else
     5039#endif
     5040        {       
     5041          m_cYuvRecTemp.addClipPartLuma( &m_pcQTTempTComYuv[uiQTTempAccessLayer], pcPred, uiAbsPartIdx, 1<< uiLog2TrSize  );
     5042          uiNonzeroDistY = m_pcRdCost->getDistVS( pcCU, uiAbsPartIdx, m_cYuvRecTemp.getLumaAddr(uiAbsPartIdx), m_cYuvRecTemp.getStride(),
     5043                                                  pcOrg->getLumaAddr( uiAbsPartIdx ), pcOrg->getStride(), 1<< uiLog2TrSize,   1<< uiLog2TrSize, false, 0 );
     5044        }
    49165045      }
    49175046      else
     
    53075436  }
    53085437
     5438
    53095439#if HHI_VSO
     5440#if SAIT_VSO_EST_A0033
     5441  if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() )
     5442#else
    53105443  if ( m_pcRdCost->getUseRenModel() ) //Only done if not split ( see return above )
     5444#endif
    53115445  {
    53125446    UInt  uiWidth     = 1<< uiLog2TrSize;
     
    59776111
    59786112        assignWedgeDCs2Pred( pcWedgelet, piPredic, uiStride, iTestDC1, iTestDC2 );
    5979 
    5980         Dist uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride,  piOrig, uiStride, uiWidth, uiHeight, false, 0 );
     6113       
     6114        Dist uiActDist = RDO_DIST_MAX;
     6115#if SAIT_VSO_EST_A0033
     6116        if ( m_pcRdCost->getUseEstimatedVSD() )
     6117        {         
     6118          TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
     6119          TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
     6120          uiActDist = m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight );
     6121        }
     6122        else       
     6123#else
     6124        {       
     6125          uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride,  piOrig, uiStride, uiWidth, uiHeight, false, 0 );
     6126        }
     6127#endif
     6128
    59816129        if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX )
    59826130        {
     
    60786226    if( m_pcRdCost->getUseVSO() )
    60796227    {
    6080       uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 );
     6228#if SAIT_VSO_EST_A0033
     6229      if ( m_pcRdCost->getUseEstimatedVSD() )
     6230      {         
     6231        TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
     6232        TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
     6233        uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight );
     6234      }
     6235      else
     6236#endif
     6237      {     
     6238        uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 );
     6239      }
    60816240    }
    60826241    else
     
    61336292    if( m_pcRdCost->getUseVSO() )
    61346293    {
    6135       uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 );
     6294#if SAIT_VSO_EST_A0033
     6295      if ( m_pcRdCost->getUseEstimatedVSD() )
     6296      {         
     6297        TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
     6298        TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
     6299        uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPtIdx), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPtIdx), pcVirRec->getStride(), uiWidth, uiHeight );
     6300      }
     6301      else
     6302#endif
     6303      {     
     6304        uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 );
     6305      }
    61366306    }
    61376307    else
     
    62076377}
    62086378#endif
     6379
     6380#if LGE_EDGE_INTRA
     6381Bool TEncSearch::xCheckTerminatedEdge( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight )
     6382{
     6383  if( (iY % 2) == 0 ) // vertical edge
     6384  {
     6385    Bool bTopConnected = false;
     6386    Bool bBottomConnected = false;
     6387
     6388    if( iY != 0 )
     6389    {
     6390      if( pbEdge[ iX + (iY - 2) * 2 * iWidth ] )
     6391        bTopConnected = true;
     6392      if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] )
     6393        bTopConnected = true;
     6394      if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] )
     6395        bTopConnected = true;
     6396    }
     6397    else
     6398    {
     6399      bTopConnected = true;
     6400    }
     6401
     6402
     6403    if( iY != 2 * iHeight - 2 )
     6404    {
     6405      if( pbEdge[ iX + (iY + 2) * 2 * iWidth ] )
     6406        bBottomConnected = true;
     6407      if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] )
     6408        bBottomConnected = true;
     6409      if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] )
     6410        bBottomConnected = true;
     6411    }
     6412    else
     6413    {
     6414      bBottomConnected = true;
     6415    }
     6416
     6417
     6418    if( bTopConnected && bBottomConnected )
     6419    {
     6420      return true;
     6421    }
     6422    else
     6423    {
     6424      return false;
     6425    }
     6426  }
     6427  else
     6428  {
     6429    Bool bLeftConnected = false;
     6430    Bool bRightConnected = false;
     6431
     6432    if( iX != 0 )
     6433    {
     6434      if( pbEdge[ (iX - 2) + iY * 2 * iWidth ] )
     6435        bLeftConnected = true;
     6436      if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] )
     6437        bLeftConnected = true;
     6438      if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] )
     6439        bLeftConnected = true;
     6440    }
     6441    else
     6442    {
     6443      bLeftConnected = true;
     6444    }
     6445
     6446    if( iX != 2 * iWidth - 2 )
     6447    {
     6448      if( pbEdge[ (iX + 2) + iY * 2 * iWidth ] )
     6449        bRightConnected = true;
     6450      if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] )
     6451        bRightConnected = true;
     6452      if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] )
     6453        bRightConnected = true;
     6454    }
     6455    else
     6456    {
     6457      bRightConnected = true;
     6458    }
     6459
     6460
     6461    if( bLeftConnected && bRightConnected )
     6462    {
     6463      return true;
     6464    }
     6465    else
     6466    {
     6467      return false;
     6468    }
     6469  }
     6470}
     6471
     6472#if LGE_EDGE_INTRA_PIXEL_DIFFERENCE
     6473Bool TEncSearch::xEdgePartition( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 )
     6474{
     6475  Pel* pcOrgY   = pcCU->getPic()->getPicYuvOrg()->getLumaAddr(pcCU->getAddr());
     6476  UInt uiStride = pcCU->getPic()->getPicYuvOrg()->getStride();
     6477  Int iWidth    = pcCU->getWidth(uiPartIdx) >> (bPU4x4 ? 1 : 0);
     6478  Int iHeight   = pcCU->getHeight(uiPartIdx) >> (bPU4x4 ? 1 : 0);
     6479  Bool* pbEdge  = (Bool*) xMalloc( Bool, iWidth * iHeight * 4 );
     6480
     6481  {
     6482    UInt uiOffsetX = 0;
     6483    UInt uiOffsetY = 0;
     6484    UInt uiAbsPartIdx = pcCU->getZorderIdxInCU() + uiPartIdx;
     6485
     6486    uiOffsetX =  (uiAbsPartIdx & 0x1) |
     6487      ((uiAbsPartIdx & 0x4)  >> 1) |
     6488      ((uiAbsPartIdx & 0x10) >> 2) |
     6489      ((uiAbsPartIdx & 0x40) >> 3);
     6490    uiOffsetY = ((uiAbsPartIdx & 0x2)  >> 1) |
     6491      ((uiAbsPartIdx & 0x8)  >> 2) |
     6492      ((uiAbsPartIdx & 0x20) >> 3) |
     6493      ((uiAbsPartIdx & 0x80) >> 4);
     6494    uiOffsetX *= 4;
     6495    uiOffsetY *= 4;
     6496    pcOrgY += (uiOffsetX + uiOffsetY * uiStride);
     6497
     6498  }
     6499
     6500  Short* psDiffX = new Short[ iWidth * iHeight ];
     6501  Short* psDiffY = new Short[ iWidth * iHeight ];
     6502  Bool*  pbEdgeX = new Bool [ iWidth * iHeight ];
     6503  Bool*  pbEdgeY = new Bool [ iWidth * iHeight ];
     6504
     6505  // Find Horizontal Gradient & Edge Detection ((x+1, y) - (x,y))
     6506  for( Int y=0; y<iHeight; y++ )
     6507  {
     6508    Short* psDiffXPtr = &psDiffX[ y * iHeight ];
     6509    Bool*  pbEdgeXPtr = &pbEdgeX[ y * iHeight ];
     6510    for(Int x=0; x<iWidth-1; x++ )
     6511    {
     6512      *psDiffXPtr = pcOrgY[ x+1 + y*uiStride ] - pcOrgY[ x + y*uiStride ];
     6513      if(*psDiffXPtr >= LGE_EDGE_INTRA_THRESHOLD || *psDiffXPtr <= (-1)*LGE_EDGE_INTRA_THRESHOLD)
     6514      {
     6515        *pbEdgeXPtr = true;
     6516      }
     6517      else
     6518      {
     6519        *pbEdgeXPtr = false;
     6520      }
     6521
     6522      psDiffXPtr++;
     6523      pbEdgeXPtr++;
     6524    }
     6525  }
     6526
     6527  // Find Vertical Gradient & Edge Detection((x,y+1) - (x,y))
     6528  for( Int y=0; y<iHeight-1; y++ )
     6529  {
     6530    Short* psDiffYPtr = &psDiffY[ y * iHeight ];
     6531    Bool*  pbEdgeYPtr = &pbEdgeY[ y * iHeight ];
     6532    for(Int x=0; x<iWidth; x++ )
     6533    {
     6534      *psDiffYPtr = pcOrgY[ x + (y+1)*uiStride ] - pcOrgY [ x + y*uiStride ];
     6535      if(*psDiffYPtr >= LGE_EDGE_INTRA_THRESHOLD || *psDiffYPtr <= (-1)*LGE_EDGE_INTRA_THRESHOLD)
     6536      {
     6537        *pbEdgeYPtr = true;
     6538      }
     6539      else
     6540      {
     6541        *pbEdgeYPtr = false;
     6542      }
     6543
     6544      psDiffYPtr++;
     6545      pbEdgeYPtr++;
     6546    }
     6547  }
     6548
     6549  // Eliminate local maximum
     6550  for( Int y=0; y<iHeight; y++ )
     6551  {
     6552    Short* psDiffXPtr = &psDiffX[ y * iHeight ];
     6553    Bool*  pbEdgeXPtr = &pbEdgeX[ y * iHeight ];
     6554    for( Int x=0; x<iWidth-1; x++ )
     6555    {
     6556      UShort usAbs0=0, usAbs1=0, usAbs2=0;  // 0 : left, 1 : current, 2 : right
     6557
     6558      if( x > 0 && *(pbEdgeXPtr-1) == true )
     6559      {
     6560        if( *(psDiffXPtr-1) >= 0)
     6561        {
     6562          usAbs0 = *(psDiffXPtr-1);
     6563
     6564        }
     6565        else
     6566        {
     6567          usAbs0 = (-1) * *(psDiffXPtr-1);
     6568        }
     6569      }
     6570      if( *pbEdgeXPtr == true )
     6571      {
     6572        if( *(psDiffXPtr) >= 0)
     6573        {
     6574          usAbs1 = *(psDiffXPtr);
     6575        }
     6576        else
     6577        {
     6578          usAbs1 = (-1) * *(psDiffXPtr);
     6579        }
     6580      }
     6581      if( x < iWidth-2 && *(pbEdgeXPtr+1) == true )
     6582      {
     6583        if( *(psDiffXPtr+1) >= 0)
     6584        {
     6585          usAbs2 = *(psDiffXPtr+1);
     6586          //bSign2 = true;
     6587        }
     6588        else
     6589        {
     6590          usAbs2 = (-1) * *(psDiffXPtr+1);
     6591        }
     6592      }
     6593
     6594      if( x == 0 )
     6595      {
     6596        if( usAbs1 < usAbs2 )
     6597        {
     6598          *pbEdgeXPtr = false;
     6599        }
     6600      }
     6601      else if( x == iWidth-2 )
     6602      {
     6603        if( usAbs1 <= usAbs0 )
     6604          *pbEdgeXPtr = false;
     6605      }
     6606      else
     6607      {
     6608        if( usAbs2 > usAbs0 )
     6609        {
     6610          if( usAbs1 < usAbs2 )
     6611            *pbEdgeXPtr = false;
     6612        }
     6613        else
     6614        {
     6615          if( usAbs1 <= usAbs0 )
     6616            *pbEdgeXPtr = false;
     6617        }
     6618      }
     6619
     6620      psDiffXPtr++;
     6621      pbEdgeXPtr++;
     6622    }
     6623  }
     6624
     6625  for( Int y=0; y<iHeight-1; y++ )
     6626  {
     6627    Short* psDiffYPtr = &psDiffY[ y * iWidth ];
     6628    Bool*  pbEdgeYPtr = &pbEdgeY[ y * iWidth ];
     6629    for( Int x=0; x<iWidth; x++ )
     6630    {
     6631      UShort usAbs0=0, usAbs1=0, usAbs2=0;  // 0 : upper, 1 : current, 2 : bottom
     6632      if( y > 0 && *(pbEdgeYPtr-iWidth) == true )
     6633      {
     6634        if( *(psDiffYPtr-iWidth) >= 0)
     6635        {
     6636          usAbs0 = *(psDiffYPtr-iWidth);
     6637        }
     6638        else
     6639        {
     6640          usAbs0 = (-1) * *(psDiffYPtr-iWidth);         
     6641        }
     6642      }
     6643      if( *pbEdgeYPtr == true )
     6644      {
     6645        if( *(psDiffYPtr) >= 0)
     6646        {
     6647          usAbs1 = *(psDiffYPtr);
     6648        }
     6649        else
     6650        {
     6651          usAbs1 = (-1) * *(psDiffYPtr);
     6652        }
     6653      }
     6654      if( y < iHeight-2 && *(pbEdgeYPtr+iWidth) == true )
     6655      {
     6656        if( *(psDiffYPtr+iWidth) >= 0)
     6657        {
     6658          usAbs2 = *(psDiffYPtr+iWidth);         
     6659        }
     6660        else
     6661        {
     6662          usAbs2 = (-1) * *(psDiffYPtr+iWidth);
     6663        }
     6664      }
     6665
     6666      if( y == 0 )
     6667      {
     6668        if( usAbs1 < usAbs2 )
     6669          *pbEdgeYPtr = false;
     6670      }
     6671      else if( y == iHeight-2 )
     6672      {
     6673        if( usAbs1 <= usAbs0 )
     6674          *pbEdgeYPtr = false;
     6675      }
     6676      else
     6677      {
     6678        if( usAbs2 > usAbs0 )
     6679        {
     6680          if( usAbs1 < usAbs2 )
     6681            *pbEdgeYPtr = false;
     6682        }
     6683        else
     6684        {
     6685          if( usAbs1 <= usAbs0 )
     6686            *pbEdgeYPtr = false;
     6687        }
     6688      }
     6689
     6690      psDiffYPtr++;
     6691      pbEdgeYPtr++;
     6692    }
     6693  }
     6694
     6695  // Edge Merging
     6696  for( Int i=0; i< 4 * iWidth * iHeight; i++ )
     6697    pbEdge[ i ] = false;
     6698  /// Even Line (0,2,4,6,...) => Vertical Edge
     6699  for( Int i=0; i<iHeight; i++)
     6700  {
     6701    for( Int j=0; j<iWidth-1; j++)
     6702    {
     6703      pbEdge[ (2 * j + 1) + (2 * i) * 2 * iWidth ] = pbEdgeX[ j + i * iHeight ];
     6704    }
     6705  }
     6706  /// Odd Line (1,3,5,7,...) => Horizontal Edge
     6707  for( Int i=0; i<iHeight-1; i++)
     6708  {
     6709    for( Int j=0; j<iWidth; j++)
     6710    {
     6711      pbEdge[ (2 * j) + (2 * i + 1) * 2 * iWidth ] = pbEdgeY[ j + i * iHeight ];
     6712    }
     6713  }
     6714
     6715  // Intersection Filling
     6716  /// Vertical Edge between Horizontal Edges
     6717  for( Int i = 1; i < 2 * iHeight - 3; i += 2)
     6718  {
     6719    for( Int j = 0; j < 2 * iWidth - 1; j += 2)
     6720    {
     6721      if( pbEdge[ j + i * 2 * iWidth ] )
     6722      {
     6723        if( j != 0 && pbEdge[ (j - 2) + ((i + 2) * 2 * iWidth) ] )
     6724        {
     6725          if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j - 1) + ((i + 3) * 2 * iWidth) ] )
     6726            pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] = true;
     6727        }
     6728        if( j != 2 * iWidth - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] )
     6729        {
     6730          if( !pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 1) + ((i + 3) * 2 * iWidth) ] )
     6731            pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true;
     6732        }
     6733      }
     6734    }
     6735  }
     6736  /// Horizontal Edge between Vertical Edges
     6737  for( Int j = 1; j < 2 * iWidth - 3; j += 2)
     6738  {
     6739    for( Int i = 0; i < 2 * iHeight - 1; i += 2)
     6740    {
     6741      if( pbEdge[ j + i * 2 * iWidth ] )
     6742      {
     6743        if( i != 0 && pbEdge[ (j + 2) + ((i - 2) * 2 * iWidth) ] )
     6744        {
     6745          if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i - 1) * 2 * iWidth) ] )
     6746            pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] = true;
     6747        }
     6748        if( i != 2 * iHeight - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] )
     6749        {
     6750          if( !pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i + 1) * 2 * iWidth) ] )
     6751            pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true;
     6752        }
     6753      }
     6754    }
     6755  }
     6756
     6757  // Static Pruning Unnecessary Edges
     6758  /// Step1. Stack push the unconnected edges
     6759  UShort* pusUnconnectedEdgeStack = new UShort[ 4 * iWidth * iHeight ]; // approximate size calculation
     6760  Int iUnconnectedEdgeStackPtr = 0;
     6761  //// Vertical Edges
     6762  for( Int i = 0; i < 2 * iHeight - 1; i += 2 )
     6763  {
     6764    for( Int j = 1; j < 2 * iWidth - 2; j += 2 )
     6765    {
     6766      if( pbEdge[ j + i * 2 * iWidth ] )
     6767      {
     6768        if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) )
     6769        {
     6770          pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j);
     6771          iUnconnectedEdgeStackPtr++;
     6772        }
     6773      }
     6774    }
     6775  }
     6776
     6777  //// Horizontal Edges
     6778  for( Int i = 1; i < 2 * iHeight - 2; i += 2 )
     6779  {
     6780    for( Int j = 0; j < 2 * iWidth - 1; j += 2 )
     6781    {
     6782      if( pbEdge[ j + i * 2 * iWidth ] )
     6783      {
     6784        if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) )
     6785        {
     6786          pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j);
     6787          iUnconnectedEdgeStackPtr++;
     6788        }
     6789      }
     6790    }
     6791  }
     6792
     6793  /// Step2. Remove the edges from the stack and push the new unconnected edges
     6794  //// (This step may contain duplicated edges already in the stack)
     6795  //// (But it doesn't cause any functional problems)
     6796  while( iUnconnectedEdgeStackPtr != 0 )
     6797  {
     6798    iUnconnectedEdgeStackPtr--;
     6799    Int iX = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] & 0xff;
     6800    Int iY = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] >> 8;
     6801
     6802    pbEdge[ iX + iY * 2 * iWidth ] = false;
     6803
     6804    if( iY % 2 == 1 && iX > 0 && pbEdge[ iX - 2 + iY * 2 * iWidth ] &&
     6805      !xCheckTerminatedEdge( pbEdge, iX - 2, iY, iWidth, iHeight ) ) // left
     6806    {
     6807      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX - 2);
     6808      iUnconnectedEdgeStackPtr++;
     6809    }
     6810    if( iY % 2 == 1 && iX < 2 * iWidth - 2 && pbEdge[ iX + 2 + iY * 2 * iWidth ] &&
     6811      !xCheckTerminatedEdge( pbEdge, iX + 2, iY, iWidth, iHeight ) ) // right
     6812    {
     6813      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX + 2);
     6814      iUnconnectedEdgeStackPtr++;
     6815    }
     6816    if( iY % 2 == 0 && iY > 0 && pbEdge[ iX + (iY - 2) * 2 * iWidth ] &&
     6817      !xCheckTerminatedEdge( pbEdge, iX, iY - 2, iWidth, iHeight ) ) // top
     6818    {
     6819      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 2) << 8) | (iX + 0);
     6820      iUnconnectedEdgeStackPtr++;
     6821    }
     6822    if( iY % 2 == 0 && iY < 2 * iHeight - 2 && pbEdge[ iX + (iY + 2) * 2 * iWidth ] &&
     6823      !xCheckTerminatedEdge( pbEdge, iX, iY + 2, iWidth, iHeight ) ) // bottom
     6824    {
     6825      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 2) << 8) | (iX + 0);
     6826      iUnconnectedEdgeStackPtr++;
     6827    }
     6828    if( iX > 0 && iY > 0 && pbEdge[ iX - 1 + (iY - 1) * 2 * iWidth ] &&
     6829      !xCheckTerminatedEdge( pbEdge, iX - 1, iY - 1, iWidth, iHeight ) ) // left-top
     6830    {
     6831      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX - 1);
     6832      iUnconnectedEdgeStackPtr++;
     6833    }
     6834    if( iX < 2 * iWidth - 1 && iY > 0 && pbEdge[ iX + 1 + (iY - 1) * 2 * iWidth ] &&
     6835      !xCheckTerminatedEdge( pbEdge, iX + 1, iY - 1, iWidth, iHeight ) ) // right-top
     6836    {
     6837      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX + 1);
     6838      iUnconnectedEdgeStackPtr++;
     6839    }
     6840    if( iX > 0 && iY < 2 * iHeight - 1 && pbEdge[ iX - 1 + (iY + 1) * 2 * iWidth ] &&
     6841      !xCheckTerminatedEdge( pbEdge, iX - 1, iY + 1, iWidth, iHeight ) ) // left-bottom
     6842    {
     6843      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX - 1);
     6844      iUnconnectedEdgeStackPtr++;
     6845    }
     6846    if( iX < 2 * iWidth - 1 && iY < 2 * iHeight - 1 && pbEdge[ iX + 1 + (iY + 1) * 2 * iWidth ] &&
     6847      !xCheckTerminatedEdge( pbEdge, iX + 1, iY + 1, iWidth, iHeight ) ) // right-bottom
     6848    {
     6849      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX + 1);
     6850      iUnconnectedEdgeStackPtr++;
     6851    }
     6852  }
     6853
     6854
     6855  // Region Generation ( edge -> region )
     6856  Bool* pbRegion = pcCU->getEdgePartition( uiPartIdx );
     6857  Bool* pbVisit  = new Bool[ iWidth * iHeight ];
     6858
     6859  for( UInt ui = 0; ui < iWidth * iHeight; ui++ )
     6860  {
     6861    pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next)
     6862    pbVisit [ ui ] = false;
     6863  }
     6864
     6865  Int* piStack = new Int[ iWidth * iHeight ];
     6866
     6867  Int iPtr = 0;
     6868
     6869  piStack[iPtr++] = (0 << 8) | (0);
     6870  pbRegion[ 0 ] = false;
     6871
     6872  while(iPtr > 0)
     6873  {
     6874    Int iTmp = piStack[--iPtr];
     6875    Int iX1, iY1;
     6876    iX1 = iTmp & 0xff;
     6877    iY1 = (iTmp >> 8) & 0xff;
     6878
     6879    pbVisit[ iX1 + iY1 * iWidth ] = true;
     6880
     6881    assert( iX1 >= 0 && iX1 < iWidth );
     6882    assert( iY1 >= 0 && iY1 < iHeight );
     6883
     6884    if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] )
     6885    {
     6886      piStack[iPtr++] = (iY1 << 8) | (iX1 - 1);
     6887      pbRegion[ iX1 - 1 + iY1 * iWidth ] = false;
     6888    }
     6889    if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] )
     6890    {
     6891      piStack[iPtr++] = (iY1 << 8) | (iX1 + 1);
     6892      pbRegion[ iX1 + 1 + iY1 * iWidth ] = false;
     6893    }
     6894    if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] )
     6895    {
     6896      piStack[iPtr++] = ((iY1 - 1) << 8) | iX1;
     6897      pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false;
     6898    }
     6899    if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] )
     6900    {
     6901      piStack[iPtr++] = ((iY1 + 1) << 8) | iX1;
     6902      pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false;
     6903    }
     6904  }
     6905
     6906  ///////////
     6907  iPtr = 0;
     6908  for( Int i = 0; i < iWidth * iHeight; i++ )
     6909    pbVisit[ i ] = false;
     6910  piStack[ iPtr++ ] = (0 << 8) | (0); // initial seed
     6911  while( iPtr > 0 && iPtr < iWidth * iHeight )
     6912  {
     6913    Int iX;
     6914    Int iY;
     6915    iPtr--;
     6916    iX = piStack[ iPtr ] & 0xff;
     6917    iY = piStack[ iPtr ] >> 8;
     6918    pbVisit[ iY * iWidth + iX ] = true;
     6919
     6920    if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] )
     6921    {
     6922      piStack[ iPtr++ ] = ((iY - 1) << 8) | iX;
     6923    }
     6924    if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] )
     6925    {
     6926      piStack[ iPtr++ ] = ((iY + 1) << 8) | iX;
     6927    }
     6928    if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] )
     6929    {
     6930      piStack[ iPtr++ ] = (iY << 8) | (iX - 1);
     6931    }
     6932    if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] )
     6933    {
     6934      piStack[ iPtr++ ] = (iY << 8) | (iX + 1);
     6935    }
     6936  }
     6937  assert( iPtr == 0 || iPtr == iWidth * iHeight );
     6938
     6939  Bool bBipartition;
     6940  if( iPtr == iWidth * iHeight )
     6941  {
     6942    bBipartition = false; // single partition
     6943  }
     6944  else
     6945  {
     6946    for( Int i = 0; i < iWidth * iHeight; i++ )
     6947    {
     6948      if( !pbVisit[ i ] )
     6949      {
     6950        piStack[ iPtr++ ] = (( i / iWidth ) << 8) | ( i % iWidth );
     6951        pbVisit[ i ] = true;
     6952        break;
     6953      }
     6954    }
     6955    while( iPtr > 0 )
     6956    {
     6957      Int iX;
     6958      Int iY;
     6959      iPtr--;
     6960      iX = piStack[ iPtr ] & 0xff;
     6961      iY = piStack[ iPtr ] >> 8;
     6962      pbVisit[ iY * iWidth + iX ] = true;
     6963
     6964      if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] )
     6965      {
     6966        piStack[ iPtr++ ] = ((iY - 1) << 8) | iX;
     6967      }
     6968      if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] )
     6969      {
     6970        piStack[ iPtr++ ] = ((iY + 1) << 8) | iX;
     6971      }
     6972      if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] )
     6973      {
     6974        piStack[ iPtr++ ] = (iY << 8) | (iX - 1);
     6975      }
     6976      if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] )
     6977      {
     6978        piStack[ iPtr++ ] = (iY << 8) | (iX + 1);
     6979      }
     6980    }
     6981    bBipartition = true;
     6982    for( Int i = 0; i < iWidth * iHeight; i++ )
     6983    {
     6984      if( !pbVisit[ i ] )
     6985      {
     6986        bBipartition = false;
     6987        break;
     6988      }
     6989    }
     6990  }
     6991
     6992  xFree( pbEdge );
     6993  delete[] pbEdgeX; pbEdgeX = NULL;
     6994  delete[] pbEdgeY; pbEdgeY = NULL;
     6995  delete[] psDiffX; psDiffX = NULL;
     6996  delete[] psDiffY; psDiffY = NULL;
     6997  delete[] pusUnconnectedEdgeStack; pusUnconnectedEdgeStack = NULL;
     6998  delete[] pbVisit; pbVisit = NULL;
     6999  delete[] piStack; piStack = NULL;
     7000
     7001  Bool bCheckPossibleChain;
     7002
     7003  if( bBipartition )
     7004    bCheckPossibleChain = xConstructChainCode( pcCU, uiPartIdx, bPU4x4 );
     7005  else
     7006    bCheckPossibleChain = false;
     7007
     7008  return bCheckPossibleChain;
     7009}
     7010
     7011#endif
     7012
     7013Bool TEncSearch::xConstructChainCode( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 )
     7014{
     7015  UInt   uiWidth    = pcCU->getWidth( uiPartIdx ) >> (bPU4x4 ? 1 : 0);
     7016  UInt   uiHeight   = pcCU->getHeight( uiPartIdx ) >> (bPU4x4 ? 1 : 0);
     7017  Bool*  pbEdge     = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 );
     7018  Bool*  pbVisit    = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 );
     7019  UInt   uiMaxEdge  = uiWidth * (LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 / 4);
     7020  Bool*  pbRegion   = pcCU->getEdgePartition( uiPartIdx );
     7021  UChar* piEdgeCode = pcCU->getEdgeCode( uiPartIdx );
     7022  Bool   bStartLeft = false;
     7023  Bool   bPossible  = false;
     7024  Bool   bFinish    = false;
     7025  Int    iStartPosition = -1;
     7026  Int    iPtr = 0;
     7027  Int    iDir = -1, iNextDir = -1;
     7028  Int    iArrow = -1, iNextArrow = -1;
     7029  Int    iX = -1, iY = -1;
     7030  Int    iDiffX = 0, iDiffY = 0;
     7031  UChar  iCode = 255;
     7032  UInt   uiWidth2 = uiWidth * 2;
     7033
     7034  for( Int i = 0; i < uiWidth * uiHeight * 4; i++ )
     7035    pbEdge[ i ] = false;
     7036
     7037  for( Int i = 0; i < uiHeight; i++ )
     7038  {
     7039    for( Int j = 0; j < uiWidth - 1; j++ )
     7040    {
     7041      if( pbRegion[ i * uiWidth + j ] != pbRegion[ i * uiWidth + j + 1 ] )
     7042        pbEdge[ i * uiWidth * 4 + j * 2 + 1 ] = true;
     7043    }
     7044  }
     7045
     7046  for( Int i = 0; i < uiHeight - 1; i++ )
     7047  {
     7048    for( Int j = 0; j < uiWidth; j++ )
     7049    {
     7050      if( pbRegion[ (i + 0) * uiWidth + j ] != pbRegion[ (i + 1) * uiWidth + j ] )
     7051        pbEdge[ (2 * i + 1) * 2 * uiWidth + j * 2 ] = true;
     7052    }
     7053  }
     7054
     7055  for( Int i = 1; i < uiWidth2 - 2; i+=2 )
     7056  {
     7057    if(pbEdge[ i ])
     7058    {
     7059      bPossible  = true;
     7060      bStartLeft = false;
     7061      iStartPosition = iX = i;
     7062      iY = 0;
     7063      iDir = 3;
     7064      iArrow = 3;
     7065      break;
     7066    }
     7067  }
     7068
     7069  if( !bPossible )
     7070  {
     7071    for( Int i = 1; i < uiWidth2 - 2; i+=2 )
     7072    {
     7073      if(pbEdge[ i * uiWidth2 ])
     7074      {
     7075        bPossible  = true;
     7076        bStartLeft = true;
     7077        iX = 0;
     7078        iStartPosition = iY = i;
     7079        iDir = 1;
     7080        iArrow = 1;
     7081        break;
     7082      }
     7083    }
     7084  }
     7085
     7086  if( bPossible )
     7087  {
     7088    for( Int i = 0; i < 4 * uiWidth * uiHeight; i++ )
     7089      pbVisit[ i ] = false;
     7090
     7091    while( !bFinish )
     7092    {
     7093      Bool bArrowSkip = false;
     7094      pbVisit[ iX + iY * uiWidth2 ] = true;
     7095
     7096      switch( iDir )
     7097      {
     7098      case 0: // left
     7099        if( iX > 0 && !pbVisit[ (iX - 2) + iY * uiWidth2 ] && pbEdge[ (iX - 2) + iY * uiWidth2 ] ) // left
     7100        {
     7101          iDiffX = -2;
     7102          iDiffY =  0;
     7103          iNextDir = 0;
     7104          iNextArrow = 0;
     7105        }
     7106        else if( iX > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // top
     7107        {
     7108          iDiffX = -1;
     7109          iDiffY = -1;
     7110          iNextDir = 2;
     7111          iNextArrow = 4;
     7112        }
     7113        else if( iX > 0 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // bottom
     7114        {
     7115          iDiffX = -1;
     7116          iDiffY = +1;
     7117          iNextDir = 3;
     7118          iNextArrow = iArrow;
     7119          if( !(iPtr == 0 && iX == uiWidth2 - 2 && iY == uiHeight * 2 - 3) )
     7120            bArrowSkip = true;
     7121          else
     7122            iNextArrow = 3;
     7123        }
     7124        else if( iX == 0 )
     7125        {
     7126          iDiffX = 0;
     7127          iDiffY = 0;
     7128          iNextDir = iDir;
     7129          iNextArrow = iArrow;
     7130          bFinish = true;
     7131          continue;
     7132        }
     7133        else
     7134        {
     7135          iPtr = 0; // edge loop or unwanted case
     7136          bFinish = true;
     7137          //continue;
     7138          assert(false);
     7139        }
     7140        break;
     7141      case 1: // right
     7142        if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 2) + iY * uiWidth2 ] && pbEdge[ (iX + 2) + iY * uiWidth2 ] ) // right
     7143        {
     7144          iDiffX = +2;
     7145          iDiffY =  0;
     7146          iNextDir = 1;
     7147          iNextArrow = 1;
     7148        }
     7149        else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // top
     7150        {
     7151          iDiffX = +1;
     7152          iDiffY = -1;
     7153          iNextDir = 2;
     7154          iNextArrow = iArrow;
     7155          if( !(iPtr == 0 && iX == 0 && iY == 1) )
     7156            bArrowSkip = true;
     7157          else
     7158            iNextArrow = 2;
     7159        }
     7160        else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // bottom
     7161        {
     7162          iDiffX = +1;
     7163          iDiffY = +1;
     7164          iNextDir = 3;
     7165          iNextArrow = 7;
     7166        }
     7167        else if( iX == uiWidth2 - 2 )
     7168        {
     7169          iDiffX = 0;
     7170          iDiffY = 0;
     7171          iNextDir = iDir;
     7172          iNextArrow = iArrow;
     7173          bFinish = true;
     7174          continue;
     7175        }
     7176        else
     7177        {
     7178          iPtr = 0; // edge loop or unwanted case
     7179          bFinish = true;
     7180          //continue;
     7181          assert(false);
     7182        }
     7183        break;
     7184      case 2: // top
     7185        if( iY > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // left
     7186        {
     7187          iDiffX = -1;
     7188          iDiffY = -1;
     7189          iNextDir = 0;
     7190          iNextArrow = iArrow;
     7191          if( !(iPtr == 0 && iX == 1 && iY == uiHeight * 2 - 2) )
     7192            bArrowSkip = true;
     7193          else
     7194            iNextArrow = 0;
     7195        }
     7196        else if( iY > 0 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // right
     7197        {
     7198          iDiffX = +1;
     7199          iDiffY = -1;
     7200          iNextDir = 1;
     7201          iNextArrow = 5;
     7202        }
     7203        else if( iY > 0 && !pbVisit[ iX + (iY - 2) * uiWidth2 ] && pbEdge[ iX + (iY - 2) * uiWidth2 ] ) // top
     7204        {
     7205          iDiffX =  0;
     7206          iDiffY = -2;
     7207          iNextDir = 2;
     7208          iNextArrow = 2;
     7209        }
     7210        else if( iY == 0 )
     7211        {
     7212          iDiffX = 0;
     7213          iDiffY = 0;
     7214          iNextDir = iDir;
     7215          iNextArrow = iArrow;
     7216          bFinish = true;
     7217          continue;
     7218        }
     7219        else
     7220        {
     7221          iPtr = 0; // edge loop or unwanted case
     7222          bFinish = true;
     7223          //continue;
     7224          assert(false);
     7225        }
     7226        break;
     7227      case 3: // bottom
     7228        if( iY < uiWidth2 - 2 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // left
     7229        {
     7230          iDiffX = -1;
     7231          iDiffY = +1;
     7232          iNextDir = 0;
     7233          iNextArrow = 6;
     7234        }
     7235        else if( iY < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // right
     7236        {
     7237          iDiffX = +1;
     7238          iDiffY = +1;
     7239          iNextDir = 1;
     7240          iNextArrow = iArrow;
     7241          if( !(iPtr == 0 && iX == uiWidth * 2 - 3 && iY == 0) )
     7242            bArrowSkip = true;
     7243          else
     7244            iNextArrow = 1;
     7245        }
     7246        else if( iY < uiWidth2 - 2 && !pbVisit[ iX + (iY + 2) * uiWidth2 ] && pbEdge[ iX + (iY + 2) * uiWidth2 ] ) // bottom
     7247        {
     7248          iDiffX =  0;
     7249          iDiffY = +2;
     7250          iNextDir = 3;
     7251          iNextArrow = 3;
     7252        }
     7253        else if( iY == uiWidth2 - 2 )
     7254        {
     7255          iDiffX = 0;
     7256          iDiffY = 0;
     7257          iNextDir = iDir;
     7258          iNextArrow = iArrow;
     7259          bFinish = true;
     7260          continue;
     7261        }
     7262        else
     7263        {
     7264          iPtr = 0; // edge loop or unwanted case
     7265          bFinish = true;
     7266          //continue;
     7267          assert(false);
     7268        }
     7269        break;
     7270      }
     7271
     7272      const UChar tableCode[8][8] = { { 0, -1, 4, 3, 2, 6, 1, 5 }, // iArrow(current direction), iNextArrow(next direction)
     7273      { -1, 0, 3, 4, 5, 1, 6, 2 },
     7274      { 3, 4, 0, -1, 1, 2, 5, 6 },
     7275      { 4, 3, -1, 0, 6, 5, 2, 1 },
     7276      { 1, 6, 2, 5, 0, 4, 3, -1 },
     7277      { 5, 2, 1, 6, 3, 0, -1, 4 },
     7278      { 2, 5, 6, 1, 4, -1, 0, 3 },
     7279      { 6, 1, 5, 2, -1, 3, 4, 0 } };
     7280
     7281      iCode = tableCode[iArrow][iNextArrow];
     7282
     7283      if(iPtr >= uiMaxEdge)
     7284      {
     7285        iPtr = 0; // over the maximum number of edge
     7286        bPossible = false;
     7287        break;
     7288      }
     7289
     7290      if( !bArrowSkip )
     7291      {
     7292        piEdgeCode[iPtr++] = iCode; // first edge coding
     7293        //printf("xEdgeCoding: (%d,%d)->(%d,%d) code %d\n",iX,iY, iX+iDiffX, iY+iDiffY, iCode);
     7294      }
     7295
     7296      iX += iDiffX;
     7297      iY += iDiffY;
     7298      iDir = iNextDir;
     7299      iArrow = iNextArrow;
     7300    }
     7301  }
     7302
     7303  pcCU->setEdgeLeftFirst( uiPartIdx, bStartLeft );
     7304  pcCU->setEdgeStartPos ( uiPartIdx, bStartLeft ? (iStartPosition - 1) >> 1 : (iStartPosition + 1) >> 1);
     7305  pcCU->setEdgeNumber   ( uiPartIdx, iPtr );
     7306
     7307  xFree( pbEdge );
     7308  xFree( pbVisit );
     7309
     7310  return (iPtr != 0);
     7311}
     7312
     7313#if LGE_EDGE_INTRA_DELTA_DC
     7314Void TEncSearch::xAssignEdgeIntraDeltaDCs( TComDataCU*   pcCU,
     7315                                          UInt          uiAbsPartIdx,
     7316                                          Pel*          piOrig,
     7317                                          UInt          uiStride,
     7318                                          Pel*          piPredic,
     7319                                          UInt          uiWidth,
     7320                                          UInt          uiHeight )
     7321{
     7322  Int iDC0 = 0;
     7323  Int iDC1 = 0;
     7324  Int iPredDC0 = 0;
     7325  Int iPredDC1 = 0;
     7326  Int iDeltaDC0 = 0;
     7327  Int iDeltaDC1 = 0;
     7328
     7329  Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx );
     7330
     7331  Int* piMask = pcCU->getPattern()->getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt );
     7332  Int iMaskStride = ( uiWidth<<1 ) + 1;
     7333
     7334  // DC Calculation
     7335  {
     7336    UInt uiSum0 = 0;
     7337    UInt uiSum1 = 0;
     7338    UInt uiCount0 = 0;
     7339    UInt uiCount1 = 0;
     7340
     7341    Pel* piTemp = piOrig;
     7342    for( UInt ui = 0; ui < uiHeight; ui++ )
     7343    {
     7344      for( UInt uii = 0; uii < uiWidth; uii++ )
     7345      {
     7346        if( pbRegion[ ui * uiWidth + uii ] == false )
     7347        {
     7348          uiSum0 += (piTemp[ uii ]);
     7349          uiCount0++;
     7350        }
     7351        else
     7352        {
     7353          uiSum1 += (piTemp[ uii ]);
     7354          uiCount1++;
     7355        }
     7356      }
     7357      piTemp += uiStride;
     7358    }
     7359    if( uiCount0 == 0 )
     7360      assert(false);
     7361    if( uiCount1 == 0 )
     7362      assert(false);
     7363    iDC0 = uiSum0 / uiCount0; // TODO : integer op.
     7364    iDC1 = uiSum1 / uiCount1;
     7365  }
     7366
     7367  // PredDC Calculation
     7368  {
     7369    UInt uiSum0 = 0;
     7370    UInt uiSum1 = 0;
     7371    UInt uiCount0 = 0;
     7372    UInt uiCount1 = 0;
     7373
     7374    for( UInt ui = 0; ui < uiWidth; ui++ )
     7375    {
     7376      if( pbRegion[ ui ] == false )
     7377      {
     7378        uiSum0 += (piMask[ ui + 1 ]);
     7379        uiCount0++;
     7380      }
     7381      else
     7382      {
     7383        uiSum1 += (piMask[ ui + 1 ]);
     7384        uiCount1++;
     7385      }
     7386    }
     7387    for( UInt ui = 0; ui < uiHeight; ui++ ) // (0,0) recount (to avoid division)
     7388    {
     7389      if( pbRegion[ ui * uiWidth ] == false )
     7390      {
     7391        uiSum0 += (piMask[ (ui + 1) * iMaskStride ]);
     7392        uiCount0++;
     7393      }
     7394      else
     7395      {
     7396        uiSum1 += (piMask[ (ui + 1) * iMaskStride ]);
     7397        uiCount1++;
     7398      }
     7399    }
     7400    if( uiCount0 == 0 )
     7401      assert(false);
     7402    if( uiCount1 == 0 )
     7403      assert(false);
     7404    iPredDC0 = uiSum0 / uiCount0; // TODO : integer op.
     7405    iPredDC1 = uiSum1 / uiCount1;
     7406  }
     7407
     7408  iDeltaDC0 = iDC0 - iPredDC0;
     7409  iDeltaDC1 = iDC1 - iPredDC1;
     7410
     7411#if HHI_VSO
     7412  if( m_pcRdCost->getUseVSO() )
     7413  {
     7414    Int iFullDeltaDC0 = iDeltaDC0;
     7415    Int iFullDeltaDC1 = iDeltaDC1;
     7416
     7417    xDeltaDCQuantScaleDown( pcCU, iFullDeltaDC0 );
     7418    xDeltaDCQuantScaleDown( pcCU, iFullDeltaDC1 );
     7419
     7420    Dist  uiBestDist     = RDO_DIST_MAX;
     7421    UInt  uiBestQStepDC0 = 0;
     7422    UInt  uiBestQStepDC1 = 0;
     7423
     7424    UInt uiDeltaDC0Max = abs(iFullDeltaDC0);
     7425    UInt uiDeltaDC1Max = abs(iFullDeltaDC1);
     7426
     7427    //VSO Level delta DC check range extension
     7428    uiDeltaDC0Max += (uiDeltaDC0Max>>1);
     7429    uiDeltaDC1Max += (uiDeltaDC1Max>>1);
     7430
     7431    for( UInt uiQStepDC0 = 1; uiQStepDC0 <= uiDeltaDC0Max; uiQStepDC0++  )
     7432    {
     7433      Int iLevelDeltaDC0 = (Int)(uiQStepDC0) * (Int)(( iFullDeltaDC0 < 0 ) ? -1 : 1);
     7434      xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC0 );
     7435
     7436      Int iTestDC0 = Clip( iPredDC0 + iLevelDeltaDC0 );
     7437      for( UInt uiQStepDC1 = 1; uiQStepDC1 <= uiDeltaDC1Max; uiQStepDC1++  )
     7438      {
     7439        Int iLevelDeltaDC1 = (Int)(uiQStepDC1) * (Int)(( iFullDeltaDC1 < 0 ) ? -1 : 1);
     7440        xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC1 );
     7441
     7442        Int iTestDC1 = Clip( iPredDC1 + iLevelDeltaDC1 );
     7443
     7444        Pel* piTemp = piPredic;
     7445        for( UInt ui = 0; ui < uiHeight; ui++ )
     7446        {
     7447          for( UInt uii = 0; uii < uiWidth; uii++ )
     7448          {
     7449            if( pbRegion[ ui * uiWidth + uii ] == false )
     7450            {
     7451              piTemp[ uii ] = iTestDC0;
     7452            }
     7453            else
     7454            {
     7455              piTemp[ uii ] = iTestDC1;
     7456            }
     7457          }
     7458          piTemp += uiStride;
     7459        }
     7460
     7461        Dist uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride,  piOrig, uiStride, uiWidth, uiHeight, false, 0 );
     7462        if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX )
     7463        {
     7464          uiBestDist     = uiActDist;
     7465          uiBestQStepDC0 = uiQStepDC0;
     7466          uiBestQStepDC1 = uiQStepDC1;
     7467        }
     7468      }
     7469    }
     7470
     7471    iFullDeltaDC0 = (Int)(uiBestQStepDC0) * (Int)(( iFullDeltaDC0 < 0 ) ? -1 : 1);
     7472    iFullDeltaDC1 = (Int)(uiBestQStepDC1) * (Int)(( iFullDeltaDC1 < 0 ) ? -1 : 1);
     7473    xDeltaDCQuantScaleUp( pcCU, iFullDeltaDC0 );
     7474    xDeltaDCQuantScaleUp( pcCU, iFullDeltaDC1 );
     7475    iDeltaDC0 = iFullDeltaDC0;
     7476    iDeltaDC1 = iFullDeltaDC1;
     7477  }
     7478#endif
     7479
     7480  xDeltaDCQuantScaleDown( pcCU, iDeltaDC0 );
     7481  xDeltaDCQuantScaleDown( pcCU, iDeltaDC1 );
     7482
     7483  pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 );
     7484  pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 );
     7485}
     7486#endif
     7487#endif
     7488
    62097489//! \}
  • trunk/source/Lib/TLibEncoder/TEncSearch.h

    r77 r100  
    189189                                  TComYuv*    pcOrgYuv,
    190190#if LG_RESTRICTEDRESPRED_M24766
    191                                                                   TComYuv*     rpcResiPredYuv,
     191                                  TComYuv*    rpcResiPredYuv,
    192192#endif
    193193                                  TComYuv*&   rpcPredYuv,
     
    259259                                    TComYuv*     pcPredYuv,
    260260                                    TComYuv*     pcResiYuv,
    261                                     Dist&        ruiDist );
     261                                    Dist&        ruiDist
     262#if LG_ZEROINTRADEPTHRESI_M26039
     263                                   ,Bool        bZeroResi = false
     264#endif
     265                                   );
    262266  Void  xIntraCodingChromaBlk     ( TComDataCU*  pcCU,
    263267                                    UInt         uiTrDepth,
     
    278282                                    Dist&        ruiDistC,
    279283#if HHI_RQT_INTRA_SPEEDUP
    280                                    Bool         bCheckFirst,
    281 #endif
    282                                    Double&      dRDCost );
     284                                    Bool         bCheckFirst,
     285#endif
     286                                    Double&      dRDCost
     287#if LG_ZEROINTRADEPTHRESI_M26039
     288                                   ,Bool         bZeroResi = false
     289#endif
     290                                  );
    283291 
    284292  Void  xSetIntraResultQT         ( TComDataCU*  pcCU,
     
    321329                                    Bool           bLeftAvail );
    322330#endif
     331
     332#if LGE_EDGE_INTRA
     333  Bool  xEdgePartition       ( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 );
     334  Bool  xCheckTerminatedEdge ( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight );
     335  Bool  xConstructChainCode  ( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 );
     336#if LGE_EDGE_INTRA_DELTA_DC
     337  Void  xAssignEdgeIntraDeltaDCs( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piOrig, UInt uiStride, Pel* piPredic, UInt uiWidth, UInt uiHeight );
     338#endif
     339#endif
     340
    323341#if HHI_DMM_WEDGE_INTRA
    324342  Void findWedgeFullMinDist       ( TComDataCU*    pcCU,
     
    444462                                    TComYuv*        pcYuvOrg,
    445463#if LG_RESTRICTEDRESPRED_M24766
    446                                                                         TComYuv*        rpcResiPredYuv,
     464                                    TComYuv*        rpcResiPredYuv,
    447465#endif
    448466                                    Int             iPartIdx,
  • trunk/source/Lib/TLibEncoder/TEncSlice.cpp

    r77 r100  
    3838#include "TEncTop.h"
    3939#include "TEncSlice.h"
     40#if HHI_VSO_SPEEDUP_A033
     41#include "../../App/TAppEncoder/TAppEncTop.h"
     42#endif
    4043#include <math.h>
     44#if SAIT_VSO_EST_A0033
     45extern Double g_dDispCoeff;
     46#endif
    4147
    4248//! \ingroup TLibEncoder
     
    627633  TComSlice* pcSlice            = rpcPic->getSlice(getSliceIdx());
    628634  xDetermineStartAndBoundingCUAddr ( uiStartCUAddr, uiBoundingCUAddr, rpcPic, false );
     635#if LG_ZEROINTRADEPTHRESI_M26039
     636  rpcPic->setIntraPeriod(this->m_pcCfg->getIntraPeriod());
     637#endif
    629638 
    630639  // initialize cost values
     
    702711  m_pcEntropyCoder->setMaxAlfCtrlDepth(0); //unnecessary
    703712 
     713#if SAIT_VSO_EST_A0033
     714 if( m_pcCfg->getUseVSO() )
     715 {
     716   m_pcRdCost->setDisparityCoeff( g_dDispCoeff );  // Temp. code!!!
     717   //printf( "Disp Coeff : %3.4f \n", m_pcRdCost->getDisparityCoeff() );
     718
     719   Int frameWidth = m_pcCfg->getSourceWidth();
     720   Pel* pVideoRec = m_pcRdCost->getVideoRecPicYuv()->getLumaAddr();
     721   Int iVideoRecStride = m_pcRdCost->getVideoRecPicYuv()->getStride();
     722
     723   Pel* pDepthOrg = m_pcRdCost->getDepthPicYuv()->getLumaAddr();
     724   Int iDepthOrgStride = m_pcRdCost->getDepthPicYuv()->getStride();
     725
     726   for( Int y = 0 ; y < m_pcCfg->getSourceHeight() ; y++ )
     727   {
     728     pVideoRec[-4] = pVideoRec[-3] = pVideoRec[-2] = pVideoRec[-1] = pVideoRec[0];
     729     pVideoRec[frameWidth+3] = pVideoRec[frameWidth+2] = pVideoRec[frameWidth+1] = pVideoRec[frameWidth] = pVideoRec[frameWidth-1];
     730     pDepthOrg[-4] = pDepthOrg[-3] = pDepthOrg[-2] = pDepthOrg[-1] = pDepthOrg[0];
     731     pDepthOrg[frameWidth+3] = pDepthOrg[frameWidth+2] = pDepthOrg[frameWidth+1] = pDepthOrg[frameWidth] = pDepthOrg[frameWidth-1];
     732
     733     pVideoRec += iVideoRecStride;
     734     pDepthOrg += iDepthOrgStride;
     735   }
     736 }
     737#endif
    704738  TEncTop* pcEncTop = (TEncTop*) m_pcCfg;
    705739  TEncSbac**** ppppcRDSbacCoders    = pcEncTop->getRDSbacCoders();
     
    753787  UInt uiTileLCUX     = 0;
    754788
     789#if HHI_VSO_SPEEDUP_A033
     790  Int iLastPosY = -1;
     791#endif
     792
    755793  // for every CU in slice
    756794  UInt uiEncCUOrder;
     
    763801    TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );
    764802    pcCU->initCU( rpcPic, uiCUAddr );
     803
     804#if HHI_VSO_SPEEDUP_A033
     805    if ( m_pcRdCost->getUseRenModel() )
     806    {
     807      // updated renderer model if necessary
     808      Int iCurPosX;
     809      Int iCurPosY;
     810      pcCU->getPosInPic(0, iCurPosX, iCurPosY );
     811      if ( iCurPosY != iLastPosY )
     812      {
     813        iLastPosY = iCurPosY;
     814       
     815        m_pcGOPEncoder->getEncTop()->getEncTop()->setupRenModel( rpcPic->getCurrSlice()->getPOC() , rpcPic->getCurrSlice()->getSPS()->getViewId(), rpcPic->getCurrSlice()->getSPS()->isDepth() ? 1 : 0, iCurPosY );
     816      }
     817    }   
     818#endif
     819
    765820
    766821    // inherit from TR if necessary, select substream to use.
  • trunk/source/Lib/TLibEncoder/TEncTop.cpp

    r77 r100  
    597597  // mark it should be extended
    598598  rpcPic->getPicYuvRec()->setBorderExtension(false);
     599#if FIXES
     600  rpcPic->getPicYuvOrg()->setBorderExtension(false);
     601#endif
    599602}
    600603
     
    981984Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid,TComList<TComPic*>& listPic )
    982985{
    983 #if HHI_FIX
    984986  if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && POCCurr == 0 )
    985 #else
    986   if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV )
    987 #endif
    988987  {
    989988    TComReferencePictureSet* rps = slice->getLocalRPS();
  • trunk/source/Lib/TLibExtractor/TExtrTop.cpp

    r77 r100  
    5656{
    5757#if VIDYO_VPS_INTEGRATION
    58         //extraction now has to be done using layer_id
     58  //extraction now has to be done using layer_id
    5959  UInt uiLayerId = nalu.m_layerId;
    6060#else
  • trunk/source/Lib/TLibRenderer/TRenImage.cpp

    r56 r100  
    106106}
    107107
     108#if HHI_VSO_SPEEDUP_A033
     109template<typename T>
     110Void TRenImage<T>::getDataAndStrides( T** pptData, Int* piStrides )
     111{
     112  for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++ )
     113  {
     114    piStrides[uiCurPlane] = m_apcPlanes[uiCurPlane]->getStride   ();
     115    pptData  [uiCurPlane] = m_apcPlanes[uiCurPlane]->getPlaneData();
     116  }
     117}
     118
     119
     120template<typename T>
     121Void TRenImage<T>::getWidthAndHeight( Int* ppiWidths, Int* ppiHeights )
     122{
     123  for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++ )
     124  {
     125    ppiWidths [uiCurPlane] = m_apcPlanes[uiCurPlane]->getWidth ();
     126    ppiHeights[uiCurPlane] = m_apcPlanes[uiCurPlane]->getHeight();
     127  }
     128}
     129#endif
     130
    108131template<typename T>
    109132Void TRenImage<T>::allocatePlanes( UInt uiWidth, UInt uiHeight, UInt uiNumberOfFullPlanes, UInt uiNumberOfQuaterPlanes )
  • trunk/source/Lib/TLibRenderer/TRenImage.h

    r56 r100  
    6969  TRenImagePlane<T>** getPlanes() const;
    7070
     71#if HHI_VSO_SPEEDUP_A033
     72  Void getDataAndStrides( T**    pptData, Int*  piStrides );
     73  Void getWidthAndHeight( Int*  piWidths, Int*  piHeights );
     74#endif
     75
    7176  UInt getNumberOfPlanes()  const;
    7277  UInt getNumberOfQuaterPlanes() const;
  • trunk/source/Lib/TLibRenderer/TRenModSetupStrParser.cpp

    r56 r100  
    357357  {
    358358  case 'E':
    359     iBlendMode = -1;
     359    iBlendMode = BLEND_NONE;
    360360    break;
    361361  case 'I':
    362     iBlendMode = 0;
     362    iBlendMode = BLEND_AVRG;
    363363    break;
    364364  case 'L':
    365     iBlendMode = 1;
     365    iBlendMode = BLEND_LEFT;
    366366    break;
    367367  case 'R':
    368     iBlendMode = 2;
     368    iBlendMode = BLEND_RIGHT;
    369369    break;
    370370  default:
  • trunk/source/Lib/TLibRenderer/TRenModel.cpp

    r56 r100  
    3232 */
    3333
    34 
    35 
    3634#include "TRenImage.h"
    3735#include "TRenFilter.h"
     
    4846  m_iShiftPrec         =  0;
    4947  m_iHoleMargin        =  1;
     48  m_uiHorOff           = -1;
     49#if LGE_VSO_EARLY_SKIP_A0093
     50  m_bEarlySkip         = false;
     51#endif
    5052
    5153  // Current Error Type ///
     
    211213
    212214Void
     215#if LGE_VSO_EARLY_SKIP_A0093
     216TRenModel::create( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin, Bool bEarlySkip )
     217#else
    213218TRenModel::create( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin )
     219#endif
    214220{
    215221  m_iNumOfBaseViews     = iNumOfBaseViews;
     
    219225  m_iShiftPrec          = iShiftPrec;
    220226  m_iHoleMargin         = iHoleMargin;
     227#if LGE_VSO_EARLY_SKIP_A0093
     228  m_bEarlySkip          = bEarlySkip;
     229#endif
     230
    221231
    222232// LUTs for sub pel shifting
     
    231241
    232242  TRenFilter::setSubPelShiftLUT( m_iShiftPrec, m_aaaiSubPelShiftLut[0], 0 );
    233   TRenFilter::setSubPelShiftLUT( m_iShiftPrec, m_aaaiSubPelShiftLut[1], -1);
     243  TRenFilter::setSubPelShiftLUT( m_iShiftPrec, m_aaaiSubPelShiftLut[1], 0 );
    234244
    235245  m_iSampledWidth       = iWidth << m_iShiftPrec;
     
    268278  for (Int iModelNum = 0; iModelNum < m_iNumOfRenModels; iModelNum++)
    269279  {
    270     m_apcRenModels         [iModelNum] = new TRenSingleModel();
     280    m_apcRenModels         [iModelNum] = NULL;
    271281  }
    272282
     
    339349
    340350  AOT( iMode == -1);
    341   AOT( iModelNum < 0 || iModelNum > m_iNumOfRenModels );
    342   AOF( m_apcRenModels[iModelNum] );
     351  AOT( iModelNum < 0 || iModelNum > m_iNumOfRenModels ); 
    343352  AOT( iLeftViewNum  < -1 || iLeftViewNum  > m_iNumOfBaseViews );
    344353  AOT( iRightViewNum < -1 || iRightViewNum > m_iNumOfBaseViews );
     
    348357  AOT( iBlendMode < -1 || iBlendMode > 2 );
    349358
     359  Bool bBitInc = (g_uiBitIncrement != 0);
     360
     361  AOT( m_apcRenModels[iModelNum] );
     362
     363  if ( bBitInc )
     364  {
     365    if ( iMode != 2 )
     366    { // No Blending
     367      m_apcRenModels[iModelNum]   = new TRenSingleModelC<BLEND_NONE, true>;
     368    }
     369    else
     370    {
     371      switch ( iBlendMode )
     372      {
     373      case BLEND_AVRG: // average
     374        m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_AVRG, true>;       
     375        break;
     376      case BLEND_LEFT: // left  view is main view
     377        m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_LEFT, true>;       
     378        break;
     379      case BLEND_RIGHT: // right view is main view
     380        m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_RIGHT, true>;       
     381        break;
     382      default:
     383        AOT(true);
     384        break;
     385      }   
     386    }
     387  }
     388  else
     389  {
     390    if ( iMode != 2 )
     391    { // No Blending
     392      m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_NONE, false>;
     393    }
     394    else
     395    {
     396      switch ( iBlendMode )
     397      {
     398      case BLEND_AVRG: // average
     399        m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_AVRG, false>;       
     400        break;
     401      case BLEND_LEFT: // left  view is main view
     402        m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_LEFT, false>;       
     403        break;
     404      case BLEND_RIGHT: // right view is main view
     405        m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_RIGHT, false>;       
     406        break;
     407      default:
     408        AOT(true);
     409        break;
     410      }   
     411    }
     412  }
     413
     414
     415#if LGE_VSO_EARLY_SKIP_A0093
     416  m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin,  bUseOrgRef, iBlendMode, m_bEarlySkip );
     417#else
    350418  m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin,  bUseOrgRef, iBlendMode );
     419#endif
    351420
    352421  if ( iLeftViewNum != -1 )
     
    361430}
    362431
    363 
    364432Void
    365433TRenModel::setBaseView( Int iViewNum, TComPicYuv* pcPicYuvVideoData, TComPicYuv* pcPicYuvDepthData, TComPicYuv* pcPicYuvOrgVideoData, TComPicYuv* pcPicYuvOrgDepthData )
    366434{
    367435  AOT( iViewNum < 0 || iViewNum > m_iNumOfBaseViews );
    368   AOF( pcPicYuvVideoData->getHeight() == m_iHeight || pcPicYuvVideoData->getWidth() == m_iWidth );
    369   AOF( pcPicYuvDepthData->getHeight() == m_iHeight || pcPicYuvDepthData->getWidth() == m_iWidth );
     436  AOF( pcPicYuvVideoData->getHeight() <= m_iHeight + m_uiHorOff || pcPicYuvVideoData->getWidth() == m_iWidth );
     437  AOF( pcPicYuvDepthData->getHeight() <= m_iHeight + m_uiHorOff || pcPicYuvDepthData->getWidth() == m_iWidth );
    370438
    371439  pcPicYuvVideoData->extendPicBorder();
    372   TRenFilter::sampleHorUp   ( m_iShiftPrec, pcPicYuvVideoData->getLumaAddr(), pcPicYuvVideoData->getStride() , m_iWidth,      m_iHeight,      m_aapiCurVideoPel[ iViewNum ][0], m_aaiCurVideoStrides[iViewNum][0] );
    373   TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getCbAddr()  , pcPicYuvVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiCurVideoPel[ iViewNum ][1], m_aaiCurVideoStrides[iViewNum][1] );
    374   TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getCrAddr()  , pcPicYuvVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiCurVideoPel[ iViewNum ][2], m_aaiCurVideoStrides[iViewNum][2] );
    375   TRenFilter::copy          (               pcPicYuvDepthData->getLumaAddr(), pcPicYuvDepthData->getStride(),   m_iWidth,     m_iHeight,      m_apiCurDepthPel [ iViewNum],     m_aiCurDepthStrides [iViewNum]    );
     440
     441 
     442
     443
     444  TRenFilter::sampleHorUp   ( m_iShiftPrec, pcPicYuvVideoData->getLumaAddr() +  m_uiHorOff        * pcPicYuvVideoData->getStride () , pcPicYuvVideoData->getStride() , m_iWidth,      m_iHeight,      m_aapiCurVideoPel[ iViewNum ][0], m_aaiCurVideoStrides[iViewNum][0] );
     445  TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getCbAddr()   + (m_uiHorOff >> 1 ) * pcPicYuvVideoData->getCStride() , pcPicYuvVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiCurVideoPel[ iViewNum ][1], m_aaiCurVideoStrides[iViewNum][1] );
     446  TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getCrAddr()   + (m_uiHorOff >> 1 ) * pcPicYuvVideoData->getCStride() , pcPicYuvVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiCurVideoPel[ iViewNum ][2], m_aaiCurVideoStrides[iViewNum][2] );
     447  TRenFilter::copy          (               pcPicYuvDepthData->getLumaAddr() +  m_uiHorOff        * pcPicYuvDepthData->getStride () , pcPicYuvDepthData->getStride(),  m_iWidth,      m_iHeight,      m_apiCurDepthPel [ iViewNum],     m_aiCurDepthStrides [iViewNum]    );
    376448
    377449  // Used for rendering reference pic from original video data
     
    381453  if ( m_abSetupVideoFromOrgForView[iViewNum] )
    382454  {
    383     AOF( pcPicYuvOrgVideoData->getHeight() == m_iHeight || pcPicYuvOrgVideoData->getWidth() == m_iWidth );
     455    AOF( pcPicYuvOrgVideoData->getHeight() <= m_iHeight + m_uiHorOff || pcPicYuvOrgVideoData->getWidth() == m_iWidth );
    384456    pcPicYuvOrgVideoData->extendPicBorder();
    385     TRenFilter::sampleHorUp   ( m_iShiftPrec, pcPicYuvOrgVideoData->getLumaAddr(), pcPicYuvOrgVideoData->getStride() , m_iWidth,      m_iHeight,      m_aapiOrgVideoPel[ iViewNum ][0], m_aaiOrgVideoStrides[iViewNum][0] );
    386     TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getCbAddr()  , pcPicYuvOrgVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][1], m_aaiOrgVideoStrides[iViewNum][1] );
    387     TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getCrAddr()  , pcPicYuvOrgVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][2], m_aaiOrgVideoStrides[iViewNum][2] );
     457    TRenFilter::sampleHorUp   ( m_iShiftPrec, pcPicYuvOrgVideoData->getLumaAddr() +  m_uiHorOff        * pcPicYuvOrgVideoData->getStride() , pcPicYuvOrgVideoData->getStride() , m_iWidth,      m_iHeight,      m_aapiOrgVideoPel[ iViewNum ][0], m_aaiOrgVideoStrides[iViewNum][0] );
     458    TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getCbAddr()   + (m_uiHorOff >> 1 ) * pcPicYuvOrgVideoData->getCStride(), pcPicYuvOrgVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][1], m_aaiOrgVideoStrides[iViewNum][1] );
     459    TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getCrAddr()   + (m_uiHorOff >> 1 ) * pcPicYuvOrgVideoData->getCStride(), pcPicYuvOrgVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][2], m_aaiOrgVideoStrides[iViewNum][2] );
    388460  }
    389461
    390462  if ( m_abSetupDepthFromOrgForView[iViewNum] )
    391463  {
    392     AOF( pcPicYuvOrgDepthData->getHeight() == m_iHeight || pcPicYuvOrgDepthData->getWidth() == m_iWidth );
    393     TRenFilter::copy          (               pcPicYuvOrgDepthData->getLumaAddr(), pcPicYuvOrgDepthData->getStride(),  m_iWidth,     m_iHeight,      m_apiOrgDepthPel [ iViewNum],     m_aiOrgDepthStrides [iViewNum]    );
     464    AOF( pcPicYuvOrgDepthData->getHeight() <= m_iHeight + m_uiHorOff || pcPicYuvOrgDepthData->getWidth() == m_iWidth );
     465    TRenFilter::copy          (               pcPicYuvOrgDepthData->getLumaAddr() +  m_uiHorOff        * pcPicYuvOrgDepthData->getStride() , pcPicYuvOrgDepthData->getStride(),  m_iWidth,     m_iHeight,      m_apiOrgDepthPel [ iViewNum],     m_aiOrgDepthStrides [iViewNum]    );
    394466  }
    395467}
     
    404476  for (Int iBaseViewIdx = 0; iBaseViewIdx < m_iNumOfBaseViews; iBaseViewIdx++ )
    405477  {
     478
    406479    Bool bSetupFromOrgVideo = m_abSetupVideoFromOrgForView[iBaseViewIdx];
    407480    Bool bSetupFromOrgDepth = m_abSetupDepthFromOrgForView[iBaseViewIdx];
    408 
    409     if ( ( bSetupFromOrgVideo || bSetupFromOrgDepth ) && m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum] != VIEWPOS_INVALID )
     481    bAnyRefFromOrg          = bAnyRefFromOrg || bSetupFromOrgVideo || bSetupFromOrgDepth;
     482
     483    if ( m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum] != VIEWPOS_INVALID )
    410484    {
    411485      bAnyRefFromOrg = true;
     
    418492  }
    419493
    420   m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, false );
     494  m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, false, m_uiHorOff );
    421495
    422496  // Setup to Org
     
    438512    }
    439513
    440     // setup keeping reference from original data
    441     m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, true );
     514    // setup keeping reference rendered from original data
     515    m_apcRenModels[iModelNum]->setup     ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, true, m_uiHorOff);
    442516  }
    443517}
     
    468542}
    469543
     544
     545Void 
     546TRenModel::setHorOffset     ( UInt uiHorOff )
     547{
     548    m_uiHorOff = uiHorOff;
     549}
     550
     551#if LGE_VSO_EARLY_SKIP_A0093
     552RMDist
     553TRenModel::getDist( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel * piOrgData, Int iOrgStride)
     554#else
    470555RMDist
    471556TRenModel::getDist( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
    472 {
     557#endif
     558{
     559  iStartPosY -= m_uiHorOff;
     560
    473561  AOT( iWidth  + iStartPosX > m_iWidth  );
    474562  AOT( iHeight + iStartPosY > m_iHeight );
     
    484572    if (m_iCurrentContent == 1)
    485573    {
     574#if LGE_VSO_EARLY_SKIP_A0093
     575      iDist +=  m_apcCurRenModels[iModelNum]->getDistDepth  ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY,  iWidth,  iHeight,  iStride,  piNewData , piOrgData, iOrgStride);
     576#else
    486577      iDist +=  m_apcCurRenModels[iModelNum]->getDistDepth  ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY,  iWidth,  iHeight,  iStride,  piNewData );
     578#endif
    487579    }
    488580    else
     
    498590TRenModel::setData( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
    499591{
     592  iStartPosY -= m_uiHorOff;
     593
    500594  iWidth  = min(iWidth , m_iWidth  - iStartPosX );
    501595  iHeight = min(iHeight, m_iHeight - iStartPosY );
     
    510604    if (m_iCurrentContent == 1)
    511605    {
     606#ifdef LGE_VSO_EARLY_SKIP_A0093
     607      Int iTargetStride = m_aiCurDepthStrides[ m_iCurrentView ];
     608      m_apcCurRenModels[iModelNum]->setDepth  ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData,m_apiCurDepthPel[ m_iCurrentView ] + iStartPosY * iTargetStride + iStartPosX ,iTargetStride );
     609#else
    512610      m_apcCurRenModels[iModelNum]->setDepth  ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData );
    513 
     611#endif
    514612    }
    515613    else
     
    519617  }
    520618
     619#ifdef LGE_VSO_EARLY_SKIP_A0093
    521620  if (m_iCurrentContent == 1)
    522621  {
     
    524623    TRenFilter::copy( piNewData, iStride, iWidth, iHeight,  m_apiCurDepthPel[ m_iCurrentView ] + iStartPosY * iTargetStride + iStartPosX, iTargetStride );
    525624  }
    526   else
    527   {
    528     Int iTargetStride = m_aaiCurVideoStrides[ m_iCurrentView ][m_iCurrentPlane];
    529     TRenFilter::copy( piNewData, iStride, iWidth, iHeight,  m_aapiCurVideoPel[ m_iCurrentView ][m_iCurrentPlane] + iStartPosY * iTargetStride + iStartPosX, iTargetStride);
    530   }
    531 }
    532 
    533 Void
    534 TRenModel::getSynthVideo( Int iModelNum, Int iViewNum, TComPicYuv*& rpcPicYuvSynthVideo )
    535 {
    536   Pel** ppiSynthVideoPel = NULL;
    537   Pel*  ppiSynthDepthPel = NULL;
    538   Int   iStride          = -1;
    539   Int   aiStrides[3];
    540 
    541   m_apcRenModels[iModelNum]->getSynthView(iViewNum, ppiSynthVideoPel, ppiSynthDepthPel, iStride );
    542 
    543   aiStrides[0] = iStride; aiStrides[1] = iStride; aiStrides[2] = iStride;
    544   xCopy2PicYuv( ppiSynthVideoPel, aiStrides, rpcPicYuvSynthVideo  );
    545 }
    546 
    547 Void
    548 TRenModel::getSynthDepth( Int iModelNum, Int iViewNum, TComPicYuv*& rpcPicYuvSynthDepth )
    549 {
    550   Pel** ppiSynthVideoPel = NULL;
    551   Pel*  piSynthDepthPel  = NULL;
    552   Int   iStride          = -1;
    553 
    554   m_apcRenModels[iModelNum]->getSynthView(iViewNum, ppiSynthVideoPel, piSynthDepthPel, iStride );
    555   TRenFilter::copy( piSynthDepthPel, iStride, m_iWidth, m_iHeight, rpcPicYuvSynthDepth->getLumaAddr(), rpcPicYuvSynthDepth->getStride() );
    556   rpcPicYuvSynthDepth->setChromaTo( 128 << g_uiBitIncrement );
    557 }
    558 
     625#endif
     626}
     627
     628Void
     629TRenModel::getSynthVideo( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuv )
     630{
     631  m_apcRenModels[iModelNum]->getSynthVideo(iViewNum, pcPicYuv, m_uiHorOff );
     632}
     633
     634Void
     635TRenModel::getSynthDepth( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuv )
     636{
     637#if HHI_VSO_SPEEDUP_A033
     638  m_apcRenModels[iModelNum]->getSynthDepth(iViewNum, pcPicYuv, m_uiHorOff );
     639#else
     640  m_apcRenModels[iModelNum]->getSynthDepth(iViewNum, pcPicYuv );
     641#endif
     642}
    559643
    560644Void
     
    573657  for (Int iCurModel = 0; iCurModel < m_iNumOfCurRenModels; iCurModel++)
    574658  {
    575     Pel** ppiSynthVideoPel = NULL;
    576     Pel*  ppiSynthDepthPel = NULL;
    577     Pel** ppiRefVideoPel   = NULL;
    578     Int   iSynStride       = -1;
    579     Int*  piRefStrides     = NULL;
    580     Int   aiSynStrides[3];
    581 
    582     m_apcCurRenModels[iCurModel]->getSynthView( m_aiCurPosInModels[iCurModel], ppiSynthVideoPel, ppiSynthDepthPel, iSynStride );
    583     aiSynStrides[0] = iSynStride; aiSynStrides[1] = iSynStride; aiSynStrides[2] = iSynStride;
    584     xCopy2PicYuv( ppiSynthVideoPel, aiSynStrides,  &cPicYuvSynth );
    585 
    586     TComPicYuv* pcPicYuvOrgRef;
    587     TComPicYuv* pcPicYuvRef;
    588     m_apcCurRenModels[iCurModel]->getRefView  ( pcPicYuvOrgRef, ppiRefVideoPel, piRefStrides );
    589 
    590     if (!pcPicYuvOrgRef )
    591     {
    592       xCopy2PicYuv( ppiRefVideoPel, piRefStrides,  &cPicYuvTempRef);
    593       pcPicYuvRef = &cPicYuvTempRef;
    594     }
    595     else
    596     {
    597       pcPicYuvRef = pcPicYuvOrgRef;
    598     }
     659    m_apcCurRenModels[iCurModel]->getSynthVideo( m_aiCurPosInModels[iCurModel], &cPicYuvSynth, 0 );
     660    TComPicYuv* pcPicYuvRef = &cPicYuvTempRef;
     661    m_apcCurRenModels[iCurModel]->getRefVideo  ( m_aiCurPosInModels[iCurModel], pcPicYuvRef  , 0 );
    599662
    600663    iSSEY += TRenFilter::SSE( cPicYuvSynth.getLumaAddr(), cPicYuvSynth.getStride(),  m_iWidth,      m_iHeight     , pcPicYuvRef->getLumaAddr(), pcPicYuvRef->getStride() );
     
    620683  m_aaeBaseViewPosInModel[iBaseViewNum][iModelNum] = iViewPos;
    621684
    622   m_apcRenModels[iModelNum]->setLRView( iViewPos, m_aapiCurVideoPel[iBaseViewNum], m_aaiCurVideoStrides[iBaseViewNum], m_apiCurDepthPel[iBaseViewNum], m_aiCurDepthStrides [iBaseViewNum] );
    623 
    624685  if (bAdd)
    625686  {
     
    639700  }
    640701}
    641 
    642 Void
    643 TRenModel::xCopy2PicYuv( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget )
    644 {
    645   TRenFilter::copy            ( ppiSrcVideoPel[0], piStrides[0], m_iWidth, m_iHeight, rpcPicYuvTarget->getLumaAddr(), rpcPicYuvTarget->getStride() );
    646   TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[1], piStrides[1], m_iWidth, m_iHeight, rpcPicYuvTarget->getCbAddr  (), rpcPicYuvTarget->getCStride() );
    647   TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[2], piStrides[2], m_iWidth, m_iHeight, rpcPicYuvTarget->getCrAddr  (), rpcPicYuvTarget->getCStride() );
    648 }
  • trunk/source/Lib/TLibRenderer/TRenModel.h

    r56 r100  
    5050
    5151  // Creation
     52#if LGE_VSO_EARLY_SKIP_A0093
     53  Void  create           ( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin, Bool bEarlySkip );
     54#else
    5255  Void  create           ( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin );
     56#endif
    5357  Void  createSingleModel( Int iBaseViewNum, Int iContent, Int iModelNum, Int iLeftViewNum, Int iRightViewNum, Bool bUseOrgRef, Int iBlendMode );
    5458
     
    5761  Void  setSingleModel   ( Int iModelNum, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, TComPicYuv* pcPicYuvRefView );
    5862
     63  // Set horizontal offset
     64  Void  setHorOffset     ( UInt uiHorOff );
     65
    5966  // Set Mode
    6067  Void  setErrorMode     ( Int iView, Int iContent, int iPlane );
    6168
    6269  // Get Distortion, set Data
     70#ifdef LGE_VSO_EARLY_SKIP_A0093
     71  Int64 getDist          ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel * piOrgData, Int iOrgStride);
     72#else
    6373  Int64 getDist          ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData  );
     74#endif
    6475  Void  setData          ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData  );
    6576
    6677  // Get Rendered View
    67   Void  getSynthVideo    ( Int iModelNum, Int iViewNum, TComPicYuv*& rpcPicYuvSynthVideo );
    68   Void  getSynthDepth    ( Int iModelNum, Int iViewNum, TComPicYuv*& rpcPicYuvSynthDepth );
     78
     79  Void  getSynthVideo    ( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuvSynthVideo );
     80  Void  getSynthDepth    ( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuvSynthDepth );
    6981
    7082  // Get Total Distortion
     
    7486  // helpers
    7587  Void xSetLRViewAndAddModel( Int iModelNum, Int iBaseViewNum, Int iContent, Int iViewPos, Bool bAdd );
    76   Void xCopy2PicYuv ( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget );
    7788
    7889  // Settings
     
    8091  Int**  m_aaaiSubPelShiftLut[2];
    8192  Int    m_iHoleMargin;
     93#if LGE_VSO_EARLY_SKIP_A0093
     94  Bool   m_bEarlySkip;
     95#endif
    8296
    8397  /// Size of Video and Depth
     
    88102
    89103  Int m_iNumOfBaseViews;
     104
     105#if HHI_VSO_SPEEDUP_A033                 
     106  // Horizontal Offset in input data
     107  UInt m_uiHorOff;         
     108#endif
    90109
    91110  /// Current Error Type ///
  • trunk/source/Lib/TLibRenderer/TRenSingleModel.cpp

    r81 r100  
    3232 */
    3333
    34 
    3534#include "TRenImage.h"
    3635#include "TRenFilter.h"
     
    3837
    3938////////////// TRENSINGLE MODEL ///////////////
    40 TRenSingleModel::TRenSingleModel()
     39template <BlenMod iBM, Bool bBitInc>
     40TRenSingleModelC<iBM,bBitInc>::TRenSingleModelC()
    4141:  m_iDistShift ( g_uiBitIncrement << 1 )
    4242{
     
    5050
    5151  m_pcPicYuvRef          = NULL;
     52
     53  m_pcOutputSamples      = NULL;
     54  m_pcOutputSamplesRow   = NULL;   
     55  m_iOutputSamplesStride = -1;
     56
     57  m_ppiCurLUT            = NULL;
     58  m_piInvZLUTLeft        = NULL;
     59  m_piInvZLUTRight       = NULL;
     60
    5261  m_aapiRefVideoPel[0]   = NULL;
    5362  m_aapiRefVideoPel[1]   = NULL;
    5463  m_aapiRefVideoPel[2]   = NULL;
    5564
    56 
    5765  m_aiRefVideoStrides[0] = -1;
    5866  m_aiRefVideoStrides[1] = -1;
    5967  m_aiRefVideoStrides[2] = -1;
    6068
     69
    6170  for (UInt uiViewNum = 0 ; uiViewNum < 2; uiViewNum++)
    6271  {
    6372    // LUT
    6473    m_appiShiftLut[uiViewNum] = NULL;
     74
     75    m_pcInputSamples[uiViewNum] = NULL;
     76    m_iInputSamplesStride       = -1;
     77
    6578    m_ppiCurLUT               = NULL;
    6679    m_piInvZLUTLeft           = NULL;
    6780    m_piInvZLUTRight          = NULL;
    68 
    69     // Cur Data
    70     m_apiBaseDepthPel      [uiViewNum] = NULL;
    71     m_aiBaseDepthStrides   [uiViewNum] = -1;
    72 
    73     // State Data
    74     m_apbOccluded          [uiViewNum] = NULL;
    75     m_apiFilled            [uiViewNum] = NULL;
    76 
    77     // Cur Data
    78     m_aapiBaseVideoPel     [uiViewNum] = NULL;
    79     m_aaiBaseVideoStrides  [uiViewNum] = NULL;
    80   };
    81 
    82   m_piError                            = NULL;
    83 
    84   for (UInt uiViewNum = 0 ; uiViewNum < 3; uiViewNum++)
    85   {
    86     m_apiSynthDepthPel[uiViewNum] = NULL;
    87     for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++)
    88     {
    89       // Rendered Data
    90       m_aapiSynthVideoPel[uiViewNum][uiPlaneNum] = NULL;
    91     }
    92   }
    93 }
    94 
    95 TRenSingleModel::~TRenSingleModel()
    96 {
    97   if ( m_apbOccluded[0] ) delete[] m_apbOccluded[0];
    98   if ( m_apbOccluded[1] ) delete[] m_apbOccluded[1];
    99 
    100   if ( m_apiFilled  [0] ) delete[] m_apiFilled  [0];
    101   if ( m_apiFilled  [1] ) delete[] m_apiFilled  [1];
    102 
    103   if ( m_piError        ) delete[] m_piError      ;
    104 
    105 
    106   for (UInt uiViewNum = 0 ; uiViewNum < 3; uiViewNum++)
    107   {
    108     for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++)
    109     {
    110       if ( m_aapiSynthVideoPel[uiViewNum] && m_aapiSynthVideoPel[uiViewNum][uiPlaneNum] ) delete[] m_aapiSynthVideoPel[uiViewNum][uiPlaneNum];
    111     }
    112     if ( m_apiSynthDepthPel[uiViewNum] ) delete[] m_apiSynthDepthPel[uiViewNum];
    113   }
    114 
    115   delete[] (m_aapiRefVideoPel[0] - m_iPad * m_aiRefVideoStrides[0] - m_iPad );
    116   delete[] (m_aapiRefVideoPel[1] - m_iPad * m_aiRefVideoStrides[1] - m_iPad );
    117   delete[] (m_aapiRefVideoPel[2] - m_iPad * m_aiRefVideoStrides[2] - m_iPad );
    118 
    119   if ( m_piInvZLUTLeft  ) delete[] m_piInvZLUTLeft;
    120   if ( m_piInvZLUTRight ) delete[] m_piInvZLUTRight;
    121 }
    122 
    123 Void
    124 TRenSingleModel::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode )
    125 {
    126   m_iBlendMode = iBlendMode;
     81  }
     82
     83#ifdef LGE_VSO_EARLY_SKIP_A0093
     84  m_pbHorSkip = NULL;
     85#endif
     86}
     87
     88template <BlenMod iBM, Bool bBitInc>
     89TRenSingleModelC<iBM,bBitInc>::~TRenSingleModelC()
     90{
     91#ifdef LGE_VSO_EARLY_SKIP_A0093
     92  if (m_pbHorSkip)
     93  {
     94    delete[] m_pbHorSkip;
     95    m_pbHorSkip = NULL;
     96  }
     97#endif
     98
     99  if ( m_pcInputSamples [0] ) delete[] m_pcInputSamples [0];
     100  if ( m_pcInputSamples [1] ) delete[] m_pcInputSamples [1];
     101  if ( m_pcOutputSamples    ) delete   m_pcOutputSamples   ;
     102}
     103
     104template <BlenMod iBM, Bool bBitInc> Void
     105#if LGE_VSO_EARLY_SKIP_A0093
     106TRenSingleModelC<iBM,bBitInc>::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bEarlySkip )
     107#else
     108TRenSingleModelC<iBM,bBitInc>::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode )
     109#endif
     110
     111{
     112#if LGE_VSO_EARLY_SKIP_A0093
     113  m_pbHorSkip     = new Bool [MAX_CU_SIZE];
     114  m_bEarlySkip    = bEarlySkip;
     115#endif
     116
     117  AOF( iBlendMode == iBM );
     118
    127119  m_iMode = iMode;
     120
    128121  m_iWidth  = iWidth;
    129122  m_iHeight = iHeight;
     
    160153  m_aapiRefVideoPel  [2] += m_aiRefVideoStrides[2] * m_iPad + m_iPad;
    161154
    162   m_piError               = new Int [m_iStride*m_iHeight];
    163 
    164   // Create Buffers
    165   if ( (m_iMode == 0) || (m_iMode == 2 ) )
    166   {
    167     m_apbOccluded        [0]  = new Bool[m_iStride*m_iHeight];
    168     m_apiFilled          [0]  = new Pel [m_iStride*m_iHeight];
    169 
    170     for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++)
    171     {
    172       m_aapiSynthVideoPel[0][uiPlaneNum] = new Pel[m_iStride*m_iHeight];
    173     }
    174   }
    175 
    176   if ( (m_iMode == 1) || (m_iMode == 2 ) )
    177   {
    178     m_apbOccluded        [1]  = new Bool[m_iStride*m_iHeight];
    179     m_apiFilled          [1]  = new Pel [m_iStride*m_iHeight];
    180 
    181     for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++)
    182     {
    183       m_aapiSynthVideoPel[1][uiPlaneNum] = new Pel[m_iStride*m_iHeight];
    184     }
    185   }
    186 
    187   if ( m_iMode == 2 )
    188   {
    189     m_apiSynthDepthPel[0] = new Pel[m_iStride*m_iHeight];
    190     m_apiSynthDepthPel[1] = new Pel[m_iStride*m_iHeight];
    191     m_apiSynthDepthPel[2] = new Pel[m_iStride*m_iHeight];
    192 
    193     for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++)
    194     {
    195       m_aapiSynthVideoPel[2][uiPlaneNum] = new Pel[m_iStride*m_iHeight];
    196     }
    197   }
    198 }
    199 
    200 Void
    201 TRenSingleModel::setLRView( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride )
     155  m_iInputSamplesStride  = m_iWidth+1;
     156  m_iOutputSamplesStride = m_iWidth;
     157
     158  m_pcInputSamples[0]     = new RenModelInPels[m_iInputSamplesStride*m_iHeight];
     159  m_pcInputSamples[1]     = new RenModelInPels[m_iInputSamplesStride*m_iHeight];
     160
     161  m_pcOutputSamples       = new RenModelOutPels[m_iOutputSamplesStride*m_iHeight]; 
     162}
     163
     164template <BlenMod iBM, Bool bBitInc> Void
     165TRenSingleModelC<iBM,bBitInc>::setLRView( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride )
    202166{
    203167  AOF(( iViewPos == 0) || (iViewPos == 1) );
     168
     169  RenModelInPels* pcCurInputSampleRow = m_pcInputSamples[iViewPos];
     170 
     171  Pel* piDRow = piCurDepthPel;
     172  Pel* piYRow = apiCurVideoPel[0];
     173#if HHI_VSO_COLOR_PLANES
     174  Pel* piURow = apiCurVideoPel[1];
     175  Pel* piVRow = apiCurVideoPel[2];
     176#endif 
     177
     178
     179  Int iOffsetX = ( iViewPos == VIEWPOS_RIGHT ) ? 1 : 0;
     180
     181  for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )
     182  {
     183    if ( iViewPos == VIEWPOS_RIGHT )
     184    {
     185      Int iSubPosX = (1 << m_iShiftPrec);
     186      pcCurInputSampleRow[0].aiY[iSubPosX] = piYRow[0];
     187#if HHI_VSO_COLOR_PLANES
     188      pcCurInputSampleRow[0].aiU[iSubPosX] = piURow[0];
     189      pcCurInputSampleRow[0].aiV[iSubPosX] = piVRow[0];
     190#endif
     191    }
     192
     193    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
     194    {
     195      pcCurInputSampleRow[iPosX].iD = piDRow[iPosX];
     196
     197      for (Int iSubPosX = 0; iSubPosX < (1 << m_iShiftPrec)+1; iSubPosX++ )
     198      {
     199        Int iShift = (iPosX << m_iShiftPrec) + iSubPosX;
     200        pcCurInputSampleRow[iPosX+iOffsetX].aiY[iSubPosX] = piYRow[iShift];
     201#if HHI_VSO_COLOR_PLANES
     202        pcCurInputSampleRow[iPosX+iOffsetX].aiU[iSubPosX] = piURow[iShift];
     203        pcCurInputSampleRow[iPosX+iOffsetX].aiV[iSubPosX] = piVRow[iShift];
     204#endif
     205      }
     206    }
     207
     208    pcCurInputSampleRow += m_iInputSamplesStride;
     209
     210    piDRow += iCurDepthStride;
     211    piYRow += aiCurVideoStride[0];
     212#if HHI_VSO_COLOR_PLANES
     213    piURow += aiCurVideoStride[1];
     214    piVRow += aiCurVideoStride[2];
     215#endif
     216  }
     217
     218 
    204219  m_aapiBaseVideoPel      [iViewPos] = apiCurVideoPel;
    205220  m_aaiBaseVideoStrides   [iViewPos] = aiCurVideoStride;
    206221  m_apiBaseDepthPel       [iViewPos] = piCurDepthPel;
    207222  m_aiBaseDepthStrides    [iViewPos] = iCurDepthStride;
    208 }
    209 
    210 Void
    211 TRenSingleModel::setup( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference )
     223
     224}
     225
     226template <BlenMod iBM, Bool bBitInc> Void
     227TRenSingleModelC<iBM,bBitInc>::setup( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference, UInt uiHorOff )
    212228{
    213229  AOT( !m_bUseOrgRef && pcOrgVideo );
    214230  AOT( (ppiShiftLutLeft  == NULL) && (m_iMode == 0 || m_iMode == 2) );
    215231  AOT( (ppiShiftLutRight == NULL) && (m_iMode == 1 || m_iMode == 2) );
    216 #if HHI_FIX
    217 #else
    218   AOT( pcOrgVideo != NULL && bKeepReference );
    219 #endif
    220232
    221233  m_appiShiftLut[0] = ppiShiftLutLeft;
     
    225237  m_pcPicYuvRef = pcOrgVideo;
    226238
    227 #if HHI_FIX
    228239  if ( pcOrgVideo && !bKeepReference )
    229 #else
    230   if ( pcOrgVideo )
    231 #endif
    232   {
    233     TRenFilter::copy(             pcOrgVideo->getLumaAddr(), pcOrgVideo->getStride() , m_iWidth,      m_iHeight,      m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]);
    234     TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCbAddr()  , pcOrgVideo->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]);
    235     TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCrAddr()  , pcOrgVideo->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]);
     240  {
     241    TRenFilter::copy(             pcOrgVideo->getLumaAddr() +  uiHorOff       * pcOrgVideo->getStride() , pcOrgVideo->getStride() , m_iWidth,      m_iHeight,      m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]);
     242    TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCbAddr()   + (uiHorOff >> 1) * pcOrgVideo->getCStride(), pcOrgVideo->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]);
     243    TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCrAddr()   + (uiHorOff >> 1) * pcOrgVideo->getCStride(), pcOrgVideo->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]);   
     244    xSetStructRefView();
    236245  }
    237246
    238247  // Initial Rendering
    239   xSetInts( m_piError                       , m_iStride, m_iWidth, m_iHeight, 0 );
     248  xResetStructError();
     249  xInitSampleStructs();
    240250
    241251  switch ( m_iMode )
    242   {
    243   case 0:
    244     xInitView( VIEWPOS_LEFT );
    245     xRenderL( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0], true );
     252  { 
     253  case 0:   
     254#if LGE_VSO_EARLY_SKIP_A0093
     255    xRenderL<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false );
     256#else
     257    xRenderL<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] );
     258#endif   
    246259    break;
    247   case 1:
    248     xInitView( VIEWPOS_RIGHT );
    249     xRenderR( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1], true );
     260  case 1:   
     261#ifdef LGE_VSO_EARLY_SKIP_A0093
     262    xRenderR<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false);
     263#else
     264    xRenderR<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] );
     265#endif
    250266    break;
    251267  case 2:
    252268    TRenFilter::setupZLUT( true, 30, iDistToLeft, ppiBaseShiftLutLeft, ppiBaseShiftLutRight, m_iBlendZThres, m_iBlendDistWeight, m_piInvZLUTLeft, m_piInvZLUTRight );
    253     xInitView( VIEWPOS_LEFT   );
    254     xInitView( VIEWPOS_RIGHT  );
    255     xInitView( VIEWPOS_MERGED );
    256     xRenderL( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0], true );
    257     xRenderR( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1], true );
     269#ifdef LGE_VSO_EARLY_SKIP_A0093
     270    xRenderL<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false);
     271    xRenderR<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false);
     272#else     
     273    xRenderL<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] );
     274    xRenderR<true>( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] );
     275#endif
    258276    break;
    259277  default:
     
    264282  if ( !pcOrgVideo && !bKeepReference )
    265283  {
    266     xSetInts        ( m_piError                       , m_iStride, m_iWidth, m_iHeight, 0 );
    267       TRenFilter::copy( m_aapiSynthVideoPel[m_iMode ][0], m_iStride, m_iWidth, m_iHeight , m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]);
    268       TRenFilter::copy( m_aapiSynthVideoPel[m_iMode ][1], m_iStride, m_iWidth, m_iHeight , m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]);
    269       TRenFilter::copy( m_aapiSynthVideoPel[m_iMode ][2], m_iStride, m_iWidth, m_iHeight , m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]);
    270   }
    271 }
    272 
    273 RMDist
    274 TRenSingleModel::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
    275 {
    276   RMDist iSSE = 0;
    277   switch (iViewPos )
     284    xResetStructError();
     285    xSetStructSynthViewAsRefView();
     286  }
     287}
     288
     289template <BlenMod iBM, Bool bBitInc> Void
     290#if HHI_VSO_COLOR_PLANES
     291TRenSingleModelC<iBM,bBitInc>::xGetSampleStrTextPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY, Pel RenModelOutPels::*& rpiSrcU, Pel RenModelOutPels::*& rpiSrcV )
     292#else
     293TRenSingleModelC<iBM,bBitInc>::xGetSampleStrTextPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY )
     294#endif
     295{
     296  switch ( iViewNum )
    278297  {
    279298  case 0:
    280     iSSE = xRenderL( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, false );
     299    rpiSrcY = &RenModelOutPels::iYLeft;
     300#if HHI_VSO_COLOR_PLANES 
     301    rpiSrcU = &RenModelOutPels::iULeft;
     302    rpiSrcV = &RenModelOutPels::iVLeft;
     303#endif
    281304    break;
    282305  case 1:
    283     iSSE = xRenderR( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, false );
     306    rpiSrcY = &RenModelOutPels::iYRight;
     307#if HHI_VSO_COLOR_PLANES 
     308    rpiSrcU = &RenModelOutPels::iURight;
     309    rpiSrcV = &RenModelOutPels::iVRight;
     310#endif
     311    break;
     312  case 2:
     313    rpiSrcY = &RenModelOutPels::iYBlended;
     314#if HHI_VSO_COLOR_PLANES 
     315    rpiSrcU = &RenModelOutPels::iUBlended;
     316    rpiSrcV = &RenModelOutPels::iVBlended;
     317#endif
     318    break;
     319  }
     320}
     321
     322
     323template <BlenMod iBM, Bool bBitInc> Void
     324TRenSingleModelC<iBM,bBitInc>::xGetSampleStrDepthPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcD )
     325{
     326  AOT(iViewNum != 0 && iViewNum != 1); 
     327  rpiSrcD = (iViewNum == 1) ? &RenModelOutPels::iDRight : &RenModelOutPels::iDLeft;
     328}
     329
     330
     331template <BlenMod iBM, Bool bBitInc> Void
     332TRenSingleModelC<iBM,bBitInc>::xSetStructRefView( )
     333{
     334  RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;
     335 
     336  Pel* piYRow = m_aapiRefVideoPel[0];
     337#if HHI_VSO_COLOR_PLANES
     338  Pel* piURow = m_aapiRefVideoPel[1];
     339  Pel* piVRow = m_aapiRefVideoPel[2];
     340#endif 
     341
     342  for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )
     343  {
     344    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
     345    {     
     346      pcCurOutSampleRow[iPosX].iYRef = piYRow[iPosX];
     347#if HHI_VSO_COLOR_PLANES
     348      pcCurOutSampleRow[iPosX].iURef = piURow[iPosX];
     349      pcCurOutSampleRow[iPosX].iVRef = piVRow[iPosX];
     350#endif
     351    }
     352
     353    pcCurOutSampleRow += m_iOutputSamplesStride;
     354   
     355    piYRow += m_aiRefVideoStrides[0];
     356#if HHI_VSO_COLOR_PLANES
     357    piURow += m_aiRefVideoStrides[1];
     358    piVRow += m_aiRefVideoStrides[2];
     359#endif
     360  }
     361}
     362
     363template <BlenMod iBM, Bool bBitInc> Void
     364TRenSingleModelC<iBM,bBitInc>::xResetStructError( )
     365{
     366  RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;
     367
     368  for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )
     369  {
     370    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
     371    {     
     372      pcCurOutSampleRow[iPosX].iError = 0;
     373    }
     374    pcCurOutSampleRow += m_iOutputSamplesStride;
     375  }
     376}
     377
     378template <BlenMod iBM, Bool bBitInc> Void
     379TRenSingleModelC<iBM,bBitInc>::xSetStructSynthViewAsRefView( )
     380{
     381  AOT( m_iMode < 0 || m_iMode > 2);
     382
     383  RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;
     384
     385  Pel RenModelOutPels::* piSrcY = NULL;
     386
     387#if HHI_VSO_COLOR_PLANES 
     388  Pel RenModelOutPels::* piSrcU = NULL;
     389  Pel RenModelOutPels::* piSrcV = NULL;
     390  xGetSampleStrTextPtrs( m_iMode, piSrcY, piSrcU, piSrcV );
     391#else
     392  xGetSampleStrTextPtrs( m_iMode, piSrcY );
     393#endif
     394
     395  for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )
     396  {
     397    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
     398    {     
     399      pcCurOutSampleRow[iPosX].iYRef = pcCurOutSampleRow[iPosX].*piSrcY;
     400#if HHI_VSO_COLOR_PLANES
     401      pcCurOutSampleRow[iPosX].iURef = pcCurOutSampleRow[iPosX].*piSrcU;
     402      pcCurOutSampleRow[iPosX].iVRef = pcCurOutSampleRow[iPosX].*piSrcV;
     403#endif
     404    }
     405    pcCurOutSampleRow += m_iOutputSamplesStride;
     406  }
     407}
     408
     409template <BlenMod iBM, Bool bBitInc> Void
     410TRenSingleModelC<iBM,bBitInc>::xInitSampleStructs()
     411{
     412  RenModelOutPels* pcOutSampleRow      = m_pcOutputSamples;
     413  RenModelInPels * pcLeftInSampleRow   = m_pcInputSamples[0];
     414  RenModelInPels * pcRightInSampleRow  = m_pcInputSamples[1];
     415
     416
     417  for (Int iPosY = 0; iPosY < m_iHeight; iPosY++)
     418  {
     419    for (Int iPosX = 0; iPosX < m_iWidth; iPosX++)
     420    {
     421      //// Output Samples
     422      pcOutSampleRow[iPosX].iFilledLeft   = REN_IS_HOLE;
     423      pcOutSampleRow[iPosX].iFilledRight  = REN_IS_HOLE;
     424
     425      pcOutSampleRow[iPosX].iDLeft        = 0;
     426      pcOutSampleRow[iPosX].iDRight       = 0;
     427      pcOutSampleRow[iPosX].iDBlended     = 0;     
     428                                     
     429      // Y Planes                   
     430      pcOutSampleRow[iPosX].iYLeft        = 0;
     431      pcOutSampleRow[iPosX].iYRight       = 0;
     432      pcOutSampleRow[iPosX].iYBlended     = 0;
     433#if HHI_VSO_COLOR_PLANES             
     434      // U Planes                   
     435      pcOutSampleRow[iPosX].iULeft        = 128 << g_uiBitIncrement;
     436      pcOutSampleRow[iPosX].iURight       = 128 << g_uiBitIncrement;
     437      pcOutSampleRow[iPosX].iUBlended     = 128 << g_uiBitIncrement;
     438                                     
     439      // V Planes                   
     440      pcOutSampleRow[iPosX].iVLeft        = 128 << g_uiBitIncrement;
     441      pcOutSampleRow[iPosX].iVRight       = 128 << g_uiBitIncrement;
     442      pcOutSampleRow[iPosX].iVBlended     = 128 << g_uiBitIncrement;
     443#endif
     444      //// Input Samples
     445      pcLeftInSampleRow [iPosX].bOccluded = false;
     446      pcRightInSampleRow[iPosX].bOccluded = false;
     447    }
     448
     449    pcOutSampleRow     += m_iOutputSamplesStride;
     450    pcLeftInSampleRow  += m_iInputSamplesStride;
     451    pcRightInSampleRow += m_iInputSamplesStride;
     452  } 
     453}
     454
     455
     456#ifdef LGE_VSO_EARLY_SKIP_A0093
     457template <BlenMod iBM, Bool bBitInc> RMDist
     458TRenSingleModelC<iBM,bBitInc>::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData , Pel * piOrgData, Int iOrgStride )
     459#else
     460template <BlenMod iBM, Bool bBitInc> RMDist
     461TRenSingleModelC<iBM,bBitInc>::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
     462#endif
     463{
     464  RMDist iSSE = 0;
     465#ifdef LGE_VSO_EARLY_SKIP_A0093
     466  Bool   bEarlySkip;
     467#endif
     468  switch ( iViewPos )
     469  {
     470  case 0:
     471#ifdef LGE_VSO_EARLY_SKIP_A0093
     472    bEarlySkip = m_bEarlySkip ? xDetectEarlySkipL(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData, iOrgStride) : false;
     473    if( !bEarlySkip )
     474    {
     475      iSSE = xRenderL<false>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
     476    }   
     477#else
     478    iSSE = xRenderL<false>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
     479#endif
     480    break;
     481  case 1:
     482#ifdef LGE_VSO_EARLY_SKIP_A0093
     483    bEarlySkip = m_bEarlySkip ? xDetectEarlySkipR(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData, iOrgStride) : false;
     484    if( !bEarlySkip )
     485    {
     486      iSSE = xRenderR<false>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
     487    }   
     488#else
     489    iSSE = xRenderR<false>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
     490#endif
    284491    break;
    285492  default:
    286493    assert(0);
    287494  }
     495
    288496  return iSSE;
    289497}
    290 
    291 Void
    292 TRenSingleModel::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
    293 {
    294   switch (iViewPos )
    295   {
    296     case 0:
    297       xRenderL( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, true );
    298       break;
    299     case 1:
    300       xRenderR( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, true );
    301       break;
    302     default:
    303       assert(0);
    304   }
    305 }
    306 
    307 
    308 Void
    309 TRenSingleModel::getSynthView( Int iViewPos, Pel**& rppiRenVideoPel, Pel*& rpiRenDepthPel, Int& riStride )
    310 {
    311   rppiRenVideoPel = m_aapiSynthVideoPel[iViewPos];
    312   rpiRenDepthPel  = m_apiSynthDepthPel [iViewPos];
    313   riStride = m_iStride;
    314 }
    315 
    316 
    317 Void
    318 TRenSingleModel::getRefView( TComPicYuv*& rpcPicYuvRefView, Pel**& rppiRefVideoPel, Int*& raiStrides )
    319 {
    320   rpcPicYuvRefView = m_pcPicYuvRef;
    321   rppiRefVideoPel  = m_aapiRefVideoPel;
    322   raiStrides       = m_aiRefVideoStrides;
    323 }
    324 
    325 
    326 RMDist
    327 TRenSingleModel::getDistVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
     498#ifdef LGE_VSO_EARLY_SKIP_A0093
     499template <BlenMod iBM, Bool bBitInc> Void
     500TRenSingleModelC<iBM,bBitInc>::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel* piOrgData, Int iOrgStride )
     501#else
     502template <BlenMod iBM, Bool bBitInc> Void
     503TRenSingleModelC<iBM,bBitInc>::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
     504#endif
     505{
     506#ifdef  LGE_VSO_EARLY_SKIP_A0093
     507  Bool bEarlySkip;
     508#endif
     509  switch ( iViewPos )
     510  {
     511  case 0:
     512#ifdef LGE_VSO_EARLY_SKIP_A0093
     513    bEarlySkip = m_bEarlySkip ? xDetectEarlySkipL(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData,iOrgStride) : false;
     514    if( !bEarlySkip )
     515    {
     516      xRenderL<true>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
     517    }   
     518#else
     519    xRenderL<true>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
     520#endif     
     521    break;
     522  case 1:
     523#ifdef LGE_VSO_EARLY_SKIP_A0093
     524    bEarlySkip = m_bEarlySkip ? xDetectEarlySkipR(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData,iOrgStride) : false;
     525    if( !bEarlySkip )
     526    {
     527      xRenderR<true>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
     528    }   
     529#else
     530    xRenderR<true>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
     531#endif     
     532    break;
     533  default:
     534    assert(0);
     535  }
     536}
     537
     538template <BlenMod iBM, Bool bBitInc> Void
     539TRenSingleModelC<iBM,bBitInc>::getSynthVideo( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset )
     540
     541  AOT( pcPicYuv->getWidth() != m_iWidth );
     542  AOT( pcPicYuv->getHeight() > m_iHeight + uiHorOffset );
     543
     544#if HHI_VSO_COLOR_PLANES
     545  Pel RenModelOutPels::* piText[3] = { NULL, NULL, NULL };
     546  xGetSampleStrTextPtrs(iViewPos, piText[0], piText[1], piText[2]);
     547
     548  // Temp image for chroma down sampling
     549  PelImage cTempImage( m_iWidth, m_iHeight, 3, 0);
     550  Int  aiStrides[3];
     551  Pel* apiData  [3];
     552
     553  cTempImage.getDataAndStrides( apiData, aiStrides );
     554
     555  for (UInt uiCurPlane = 0; uiCurPlane < 3; uiCurPlane++ )
     556  {
     557    xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piText[uiCurPlane], apiData[uiCurPlane], aiStrides[uiCurPlane] , m_iWidth, m_iHeight);
     558  } 
     559
     560  xCopy2PicYuv( apiData, aiStrides, pcPicYuv, uiHorOffset );
     561#else
     562  Pel RenModelOutPels::* piY;
     563  xGetSampleStrTextPtrs(iViewPos, piY);
     564  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piY, pcPicYuv->getLumaAddr() + uiHorOffset * pcPicYuv->getStride(), pcPicYuv->getStride(), m_iWidth, m_iHeight );
     565  pcPicYuv->setChromaTo( 128 << g_uiBitIncrement );   
     566#endif 
     567}
     568
     569
     570template <BlenMod iBM, Bool bBitInc> Void
     571TRenSingleModelC<iBM,bBitInc>::getSynthDepth( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOff )
     572
     573  AOT( iViewPos != 0 && iViewPos != 1);
     574
     575  AOT( pcPicYuv->getWidth()  != m_iWidth  );
     576  AOT( pcPicYuv->getHeight() > m_iHeight + uiHorOff );
     577
     578  Pel RenModelOutPels::* piD = 0;
     579  xGetSampleStrDepthPtrs(iViewPos, piD);
     580  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piD, pcPicYuv->getLumaAddr() + pcPicYuv->getStride() * uiHorOff, pcPicYuv->getStride(), m_iWidth, m_iHeight );
     581  pcPicYuv->setChromaTo( 128 << g_uiBitIncrement );   
     582}
     583
     584template <BlenMod iBM, Bool bBitInc> Void
     585TRenSingleModelC<iBM,bBitInc>::getRefVideo ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset )
     586
     587  AOT( pcPicYuv->getWidth()  != m_iWidth  );
     588  AOT( pcPicYuv->getHeight() >  m_iHeight + uiHorOffset);
     589
     590#if HHI_VSO_COLOR_PLANES
     591  Pel RenModelOutPels::* piText[3];
     592  piText[0] = &RenModelOutPels::iYRef;
     593  piText[1] = &RenModelOutPels::iURef;
     594  piText[2] = &RenModelOutPels::iVRef;
     595
     596  // Temp image for chroma down sampling
     597  PelImage cTempImage( m_iWidth, m_iHeight, 3, 0);
     598  Int  aiStrides[3];
     599  Pel* apiData  [3];
     600
     601  cTempImage.getDataAndStrides( apiData, aiStrides );
     602
     603  for (UInt uiCurPlane = 0; uiCurPlane < 3; uiCurPlane++ )
     604  {
     605    xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piText[uiCurPlane], apiData[uiCurPlane], aiStrides[uiCurPlane] , m_iWidth, m_iHeight);
     606  } 
     607
     608  xCopy2PicYuv( apiData, aiStrides, pcPicYuv, uiHorOffset );
     609#else
     610  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, &RenModelOutPels::iYRef, pcPicYuv->getLumaAddr() *  pcPicYuv->getStride() + uiHorOffset, pcPicYuv->getStride(), m_iWidth, m_iHeight );
     611  pcPicYuv->setChromaTo( 128 << g_uiBitIncrement );   
     612#endif 
     613}
     614
     615
     616template <BlenMod iBM, Bool bBitInc> RMDist
     617TRenSingleModelC<iBM,bBitInc>::getDistVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
    328618{
    329619  AOF(false);
     
    331621}
    332622
    333 Void
    334 TRenSingleModel::setVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
     623template <BlenMod iBM, Bool bBitInc> Void
     624TRenSingleModelC<iBM,bBitInc>::setVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
    335625{
    336626  AOF(false);
     
    339629
    340630
    341 __inline Void
    342 TRenSingleModel::xSetViewRow( Int iPosY )
    343 {
    344   m_aapiBaseVideoPelRow     [m_iCurViewPos][0] = m_aapiBaseVideoPel   [m_iCurViewPos]  [0] + m_aaiBaseVideoStrides [ m_iCurViewPos ][0] * iPosY;
    345   m_aapiBaseVideoPelRow     [m_iCurViewPos][1] = m_aapiBaseVideoPel   [m_iCurViewPos]  [1] + m_aaiBaseVideoStrides [ m_iCurViewPos ][1] * iPosY;
    346   m_aapiBaseVideoPelRow     [m_iCurViewPos][2] = m_aapiBaseVideoPel   [m_iCurViewPos]  [2] + m_aaiBaseVideoStrides [ m_iCurViewPos ][2] * iPosY;
    347 
    348   m_apiBaseDepthPelRow      [m_iCurViewPos]    = m_apiBaseDepthPel    [m_iCurViewPos]      + m_aiBaseDepthStrides  [ m_iCurViewPos]     * iPosY;
    349   m_apbOccludedRow          [m_iCurViewPos]    = m_apbOccluded        [m_iCurViewPos]      + m_iStride                                  * iPosY;
    350   m_apiFilledRow            [m_iCurViewPos]    = m_apiFilled          [m_iCurViewPos]      + m_iStride                                  * iPosY;
    351   m_apiErrorRow                                = m_piError                                 + m_iStride                                  * iPosY;
    352 
    353   m_aapiSynthVideoPelRow    [m_iCurViewPos][0] = m_aapiSynthVideoPel  [m_iCurViewPos]  [0] + m_iStride                                  * iPosY;
    354   m_aapiSynthVideoPelRow    [m_iCurViewPos][1] = m_aapiSynthVideoPel  [m_iCurViewPos]  [1] + m_iStride                                  * iPosY;
    355   m_aapiSynthVideoPelRow    [m_iCurViewPos][2] = m_aapiSynthVideoPel  [m_iCurViewPos]  [2] + m_iStride                                  * iPosY;
    356 
    357   m_aapiRefVideoPelRow                     [0] = m_aapiRefVideoPel                     [0] + m_aiRefVideoStrides                    [0] * iPosY;
    358   m_aapiRefVideoPelRow                     [1] = m_aapiRefVideoPel                     [1] + m_aiRefVideoStrides                    [1] * iPosY;
    359   m_aapiRefVideoPelRow                     [2] = m_aapiRefVideoPel                     [2] + m_aiRefVideoStrides                    [2] * iPosY;
    360 
    361   if (m_iMode == 2)
    362   {
    363     m_apiSynthDepthPelRow [m_iCurViewPos ]     = m_apiSynthDepthPel   [m_iCurViewPos]      + m_iStride                                  * iPosY;
    364     m_aapiSynthVideoPelRow[m_iOtherViewPos][0] = m_aapiSynthVideoPel  [m_iOtherViewPos][0] + m_iStride                                  * iPosY;
    365     m_aapiSynthVideoPelRow[m_iOtherViewPos][1] = m_aapiSynthVideoPel  [m_iOtherViewPos][1] + m_iStride                                  * iPosY;
    366     m_aapiSynthVideoPelRow[m_iOtherViewPos][2] = m_aapiSynthVideoPel  [m_iOtherViewPos][2] + m_iStride                                  * iPosY;
    367 
    368     m_apiFilledRow        [m_iOtherViewPos]    = m_apiFilled          [m_iOtherViewPos]    + m_iStride                                  * iPosY;
    369     m_apiSynthDepthPelRow [m_iOtherViewPos]    = m_apiSynthDepthPel   [m_iOtherViewPos]    + m_iStride                                  * iPosY;
    370 
    371     m_aapiSynthVideoPelRow[2              ][0] = m_aapiSynthVideoPel[2]                [0] + m_iStride                                  * iPosY;
    372     m_aapiSynthVideoPelRow[2              ][1] = m_aapiSynthVideoPel[2]                [1] + m_iStride                                  * iPosY;
    373     m_aapiSynthVideoPelRow[2              ][2] = m_aapiSynthVideoPel[2]                [2] + m_iStride                                  * iPosY;
    374   }
    375 }
    376 
    377 __inline Void
    378 TRenSingleModel::xIncViewRow( )
    379 {
    380   m_aapiBaseVideoPelRow     [m_iCurViewPos][0] += m_aaiBaseVideoStrides [ m_iCurViewPos ][0];
    381   m_aapiBaseVideoPelRow     [m_iCurViewPos][1] += m_aaiBaseVideoStrides [ m_iCurViewPos ][1];
    382   m_aapiBaseVideoPelRow     [m_iCurViewPos][2] += m_aaiBaseVideoStrides [ m_iCurViewPos ][2];
    383 
    384   m_apiBaseDepthPelRow      [m_iCurViewPos]    += m_aiBaseDepthStrides  [ m_iCurViewPos]    ;
    385   m_apbOccludedRow          [m_iCurViewPos]    += m_iStride                                 ;
    386   m_apiFilledRow            [m_iCurViewPos]    += m_iStride                                 ;
    387   m_apiErrorRow                                += m_iStride                                 ;
    388 
    389   m_aapiSynthVideoPelRow    [m_iCurViewPos][0] += m_iStride                                 ;
    390   m_aapiSynthVideoPelRow    [m_iCurViewPos][1] += m_iStride                                 ;
    391   m_aapiSynthVideoPelRow    [m_iCurViewPos][2] += m_iStride                                 ;
    392 
    393   m_aapiRefVideoPelRow                     [0] += m_aiRefVideoStrides                    [0];
    394   m_aapiRefVideoPelRow                     [1] += m_aiRefVideoStrides                    [1];
    395   m_aapiRefVideoPelRow                     [2] += m_aiRefVideoStrides                    [2];
    396 
    397   if (m_iMode == 2)
    398   {
    399     m_apiSynthDepthPelRow [m_iCurViewPos ]     += m_iStride                                 ;    // This is correct!
    400 
    401     m_aapiSynthVideoPelRow[m_iOtherViewPos][0] += m_iStride                                 ;
    402     m_aapiSynthVideoPelRow[m_iOtherViewPos][1] += m_iStride                                 ;
    403     m_aapiSynthVideoPelRow[m_iOtherViewPos][2] += m_iStride                                 ;
    404 
    405     m_apiFilledRow        [m_iOtherViewPos]    += m_iStride                                 ;
    406     m_apiSynthDepthPelRow [m_iOtherViewPos]    += m_iStride                                 ;
    407 
    408     m_aapiSynthVideoPelRow[2              ][0] += m_iStride                                 ;
    409     m_aapiSynthVideoPelRow[2              ][1] += m_iStride                                 ;
    410     m_aapiSynthVideoPelRow[2              ][2] += m_iStride                                 ;
    411   }
    412 }
    413 
    414 __inline RMDist
    415 TRenSingleModel::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bAdd )
    416 {
    417   m_bSet             = bAdd;
    418   m_iCurViewPos      = 0;
    419   m_iOtherViewPos    = 1;
     631template <BlenMod iBM, Bool bBitInc> __inline Void
     632TRenSingleModelC<iBM,bBitInc>::xSetViewRow( Int iPosY )
     633{
     634  m_pcInputSamplesRow[0] = m_pcInputSamples[0] + m_iInputSamplesStride  * iPosY;
     635  m_pcInputSamplesRow[1] = m_pcInputSamples[1] + m_iInputSamplesStride  * iPosY;
     636  m_pcOutputSamplesRow   = m_pcOutputSamples   + m_iOutputSamplesStride * iPosY; 
     637
     638}
     639
     640template <BlenMod iBM, Bool bBitInc> __inline Void
     641TRenSingleModelC<iBM,bBitInc>::xIncViewRow( )
     642{
     643  m_pcInputSamplesRow[0] += m_iInputSamplesStride ;
     644  m_pcInputSamplesRow[1] += m_iInputSamplesStride ;
     645  m_pcOutputSamplesRow   += m_iOutputSamplesStride; 
     646}
     647#if LGE_VSO_EARLY_SKIP_A0093
     648template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist
     649TRenSingleModelC<iBM,bBitInc>::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bFast)
     650#else
     651template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist
     652TRenSingleModelC<iBM,bBitInc>::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData)
     653#endif
     654{
     655  const Int iCurViewPos   = 0;
     656  const Int iOtherViewPos = 1;
     657
     658  m_iCurViewPos   = iCurViewPos  ;
     659  m_iOtherViewPos = iOtherViewPos;
    420660
    421661  m_piNewDepthData   = piNewData;
     
    426666    return 0;
    427667
    428   //TODO: Specialize to left and right; setData and getDist
    429 
    430668  // Get Data
    431   m_ppiCurLUT      = m_appiShiftLut   [m_iCurViewPos];
     669  m_ppiCurLUT      = m_appiShiftLut   [iCurViewPos];
    432670
    433671  xSetViewRow      ( iStartPosY);
     
    441679  for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ )
    442680  {
     681#ifdef LGE_VSO_EARLY_SKIP_A0093
     682    if( m_bEarlySkip && bFast )
     683    {
     684      if ( m_pbHorSkip[iPosY-iStartPosY] )
     685      {
     686        xIncViewRow();
     687        m_piNewDepthData += iStride;
     688        continue;
     689      }
     690    }
     691#endif
    443692    m_bInOcclusion = false;
    444693
     
    454703      m_iLastOccludedSPos   = iCurSPos + 1;
    455704      m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos );
    456       xExtrapolateMarginL  ( iCurSPos, iEndChangePos, iError );
    457       iMinChangedSPos       = Min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( max(m_apiBaseDepthPelRow[m_iCurViewPos][iEndChangePos], m_piNewDepthData[iPosXinNewData] )) ]);
     705      xExtrapolateMarginL<bSet>  ( iCurSPos, iEndChangePos, iError );
     706
     707      iMinChangedSPos       = Min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( Max(m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD, m_piNewDepthData[iPosXinNewData] )) ]);
    458708      iLastSPos             = iCurSPos;
    459709      m_iLastDepth          = m_iCurDepth;
     710
     711      if ( bSet )
     712      {
     713        m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD = m_piNewDepthData[iPosXinNewData];
     714      }
     715
    460716      iPosXinNewData--;
    461717      iEndChangePos--;
     
    464720    {
    465721      iLastSPos    = xShift(iEndChangePos+1);
    466       m_iLastDepth = m_apiBaseDepthPelRow[m_iCurViewPos][iEndChangePos+1];
     722      m_iLastDepth = m_pcInputSamplesRow [iCurViewPos][iEndChangePos+1].iD;
    467723      xInitRenderPartL( iEndChangePos, iLastSPos );
    468724    }
     
    473729    {
    474730      // Get minimal changed sample position
    475       iMinChangedSPos = Min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]);
     731
     732      iMinChangedSPos = Min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( Max(m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD, m_piNewDepthData[iPosXinNewData] )) ]);
    476733      Int iCurSPos    = xShiftNewData(iCurPosX,iPosXinNewData);
    477734      m_iCurDepth     = m_piNewDepthData[iPosXinNewData];
    478       xRenderRangeL(iCurSPos, iLastSPos, iCurPosX, iError );
     735      xRenderRangeL<bSet>(iCurSPos, iLastSPos, iCurPosX, iError );
    479736      iLastSPos       = iCurSPos;
    480737      m_iLastDepth    = m_iCurDepth;
     738
     739      if ( bSet )
     740      {
     741        m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD = m_piNewDepthData[iPosXinNewData];
     742      }
     743
    481744      iPosXinNewData--;
    482745    }
     
    486749    {
    487750      Int iCurSPos = xShift(iCurPosX);
    488       m_iCurDepth  = m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX];
    489       xRenderRangeL( iCurSPos, iLastSPos, iCurPosX, iError );
     751
     752      m_iCurDepth  = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD;
     753      xRenderRangeL<bSet>( iCurSPos, iLastSPos, iCurPosX, iError );
    490754
    491755      if ( iCurSPos < iMinChangedSPos )
     
    499763    }
    500764
     765
    501766    xIncViewRow();
    502767    m_piNewDepthData += iStride;
     
    505770}
    506771
    507 
    508 __inline RMDist
    509 TRenSingleModel::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bAdd )
    510 {
    511   m_bSet             = bAdd;
    512   m_iCurViewPos      = 1;
    513   m_iOtherViewPos    = 0;
     772#ifdef  LGE_VSO_EARLY_SKIP_A0093
     773template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist
     774TRenSingleModelC<iBM,bBitInc>::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData , Bool bFast)
     775#else
     776template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist
     777TRenSingleModelC<iBM,bBitInc>::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )
     778#endif
     779{
     780
     781  const Int iCurViewPos   = 1;
     782  const Int iOtherViewPos = 0;
     783
     784  m_iCurViewPos      = iCurViewPos;
     785  m_iOtherViewPos    = iOtherViewPos;
    514786
    515787  m_piNewDepthData   = piNewData;
     
    521793
    522794  // Get Data
    523   m_ppiCurLUT      = m_appiShiftLut   [m_iCurViewPos];
    524 
     795  m_ppiCurLUT      = m_appiShiftLut   [iCurViewPos];
    525796  xSetViewRow      ( iStartPosY);
    526797
     
    534805  for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ )
    535806  {
     807
     808#ifdef LGE_VSO_EARLY_SKIP_A0093
     809    if( m_bEarlySkip && bFast )
     810    {
     811      if ( m_pbHorSkip[iPosY-iStartPosY] )
     812      {
     813        xIncViewRow();
     814        m_piNewDepthData += iStride;
     815        continue;
     816      }
     817    }
     818#endif
    536819    m_bInOcclusion = false;
    537820
     
    547830      m_iLastOccludedSPos   = iCurSPos - 1;
    548831      m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos );
    549       xExtrapolateMarginR     ( iCurSPos, iStartChangePos, iError );
    550       iMaxChangedSPos       = max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( max(m_apiBaseDepthPelRow[m_iCurViewPos][iStartChangePos], m_piNewDepthData[iPosXinNewData] )) ]);
     832      xExtrapolateMarginR<bSet>     ( iCurSPos, iStartChangePos, iError );
     833
     834      iMaxChangedSPos       = Max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( Max(m_pcInputSamplesRow[iCurViewPos][iStartChangePos].iD, m_piNewDepthData[iPosXinNewData] )) ]);
    551835      iLastSPos             = iCurSPos;
    552836      m_iLastDepth          = m_iCurDepth;
     837      if ( bSet )
     838      {
     839        m_pcInputSamplesRow[iCurViewPos][iStartChangePos].iD = m_piNewDepthData[iPosXinNewData];
     840      }
     841
     842
    553843      iPosXinNewData++;
    554844      iStartChangePos++;
     
    557847    {
    558848      iLastSPos   = xShift(iStartChangePos-1);
    559       m_iLastDepth = m_apiBaseDepthPelRow[m_iCurViewPos][iStartChangePos-1];
     849
     850      m_iLastDepth = m_pcInputSamplesRow[iCurViewPos][iStartChangePos-1].iD;
    560851      xInitRenderPartR( iStartChangePos, iLastSPos );
    561852    }
     
    566857    {
    567858      // Get minimal changed sample position
    568       iMaxChangedSPos = max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]);
     859
     860      iMaxChangedSPos = Max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( Max(m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD, m_piNewDepthData[iPosXinNewData] )) ]);
    569861      Int iCurSPos    = xShiftNewData(iCurPosX,iPosXinNewData);
    570862      m_iCurDepth     = m_piNewDepthData[iPosXinNewData];
    571       xRenderRangeR(iCurSPos, iLastSPos, iCurPosX, iError );
     863      xRenderRangeR<bSet>(iCurSPos, iLastSPos, iCurPosX, iError );
    572864      iLastSPos      = iCurSPos;
    573865      m_iLastDepth    = m_iCurDepth;
     866
     867      if ( bSet )
     868      {
     869        m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD = m_piNewDepthData[iPosXinNewData];
     870      }
     871
    574872      iPosXinNewData++;
    575873    }
     
    579877    {
    580878      Int iCurSPos = xShift(iCurPosX);
    581       m_iCurDepth  = m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX];
    582       xRenderRangeR( iCurSPos, iLastSPos, iCurPosX, iError );
     879
     880      m_iCurDepth  = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD;
     881      xRenderRangeR<bSet>( iCurSPos, iLastSPos, iCurPosX, iError );
    583882
    584883      if ( iCurSPos > iMaxChangedSPos )
     
    590889      m_iLastDepth = m_iCurDepth;
    591890    }
     891
    592892    xIncViewRow();
    593893    m_piNewDepthData += iStride;
     
    597897
    598898
    599 __inline Void
    600 TRenSingleModel::xInitRenderPartL(  Int iEndChangePos, Int iLastSPos )
    601 {
     899template <BlenMod iBM, Bool bBitInc> __inline Void
     900TRenSingleModelC<iBM,bBitInc>::xInitRenderPartL(  Int iEndChangePos, Int iLastSPos )
     901{
     902  const Int iCurViewPos = 0;
    602903  // GET MINIMAL OCCLUDED SAMPLE POSITION
    603904  Int iCurPosX           = iEndChangePos;
    604905
    605   if ( ( iCurPosX + 1 < m_iWidth ) && (m_apbOccludedRow[m_iCurViewPos][ iCurPosX + 1] ) )
     906
     907  if ( ( iCurPosX + 1 < m_iWidth ) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX + 1].bOccluded ) )
    606908  {
    607909    iCurPosX++;
    608     while ( (iCurPosX + 1 < m_iWidth) &&  (m_apbOccludedRow[m_iCurViewPos][ iCurPosX + 1] )  )
     910
     911    while ( (iCurPosX + 1 < m_iWidth) &&  (m_pcInputSamplesRow[iCurViewPos][ iCurPosX + 1].bOccluded  )  )
     912
    609913      iCurPosX++;
    610914
     
    630934};
    631935
    632 __inline Void
    633 TRenSingleModel::xInitRenderPartR(  Int iStartChangePos, Int iLastSPos )
    634 {
     936template <BlenMod iBM, Bool bBitInc> __inline Void
     937TRenSingleModelC<iBM,bBitInc>::xInitRenderPartR(  Int iStartChangePos, Int iLastSPos )
     938{
     939    const Int iCurViewPos = 1;
    635940  // GET MINIMAL OCCLUDED SAMPLE POSITION
    636941  Int iCurPosX           = iStartChangePos;
    637942
    638   if ( ( iCurPosX - 1 > -1 ) && (m_apbOccludedRow[m_iCurViewPos][ iCurPosX - 1] ) )
     943  if ( ( iCurPosX - 1 > -1 ) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX - 1].bOccluded ) )
    639944  {
    640945    iCurPosX--;
    641     while ( (iCurPosX - 1 > -1 ) &&  (m_apbOccludedRow[m_iCurViewPos][ iCurPosX - 1] )  )
     946
     947    while ( (iCurPosX - 1 > -1 ) &&  (m_pcInputSamplesRow[iCurViewPos][ iCurPosX - 1].bOccluded  )  )
    642948      iCurPosX--;
    643949
     
    663969
    664970
    665 __inline Void
    666 TRenSingleModel::xRenderShiftedRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
     971template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     972TRenSingleModelC<iBM,bBitInc>::xRenderShiftedRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
    667973{
    668974  assert( iCurSPos <= iLastSPos );
     
    672978  if ( iDeltaSPos > m_iGapTolerance )
    673979  {
    674     xFillHoleL( iCurSPos, iLastSPos, iCurPos, riError );
     980    xFillHoleL<bSet>( iCurSPos, iLastSPos, iCurPos, riError );
    675981  }
    676982  else
     
    679985      return;
    680986
    681     AOT( iDeltaSPos    > m_iGapTolerance );
     987    RM_AOT( iDeltaSPos    > m_iGapTolerance );
    682988
    683989    m_iThisDepth = m_iCurDepth;
    684     for (Int iFillSPos = max(0, xRangeLeftL(iCurSPos) ); iFillSPos <= min(xRangeRightL( iLastSPos ) ,m_iLastOccludedSPosFP-1); iFillSPos++ )
     990    for (Int iFillSPos = Max(0, xRangeLeftL(iCurSPos) ); iFillSPos <= min(xRangeRightL( iLastSPos ) ,m_iLastOccludedSPosFP-1); iFillSPos++ )
    685991    {
    686992      Int iDeltaCurSPos  = (iFillSPos << m_iShiftPrec) - iCurSPos;
    687993
    688       AOT( iDeltaCurSPos > iDeltaSPos );
    689       AOT( iDeltaCurSPos < 0 );
    690       AOT( m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead);
    691 
    692       Int iSourcePos = (iCurPos  << m_iShiftPrec) +  m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos];   // GT:  = iPosX - iStep + ( iStep * iDeltaCurPos + ( iDeltaPos >> 1) ) / iDeltaPos;
    693       xSetShiftedPel( iSourcePos, iFillSPos, REN_IS_FILLED, riError );
     994      RM_AOT( iDeltaCurSPos > iDeltaSPos );
     995      RM_AOT( iDeltaCurSPos < 0 );
     996      RM_AOT( m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead);
     997
     998      xSetShiftedPelL<bSet>( iCurPos, m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos], iFillSPos, REN_IS_FILLED, riError );
    694999    }
    6951000  };
    6961001}
    6971002
    698 __inline Void
    699 TRenSingleModel::xRenderShiftedRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
     1003template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1004TRenSingleModelC<iBM,bBitInc>::xRenderShiftedRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
    7001005{
    7011006  assert( iCurSPos >= iLastSPos );
    702   //assert( iRightSPos < m_iWidth );
    7031007
    7041008  Int iDeltaSPos = iCurSPos - iLastSPos;
    7051009  if ( iDeltaSPos > m_iGapTolerance )
    7061010  {
    707     xFillHoleR( iCurSPos, iLastSPos, iCurPos, riError );
     1011    xFillHoleR<bSet>( iCurSPos, iLastSPos, iCurPos, riError );
    7081012  }
    7091013  else
     
    7131017
    7141018    m_iThisDepth = m_iCurDepth;
    715     AOT( iDeltaSPos    > m_iGapTolerance );
     1019    RM_AOT( iDeltaSPos    > m_iGapTolerance );
    7161020    for (Int iFillSPos = max(m_iLastOccludedSPosFP+1, xRangeLeftR(iLastSPos) ); iFillSPos <= min(xRangeRightR( iCurSPos ) ,m_iWidth -1); iFillSPos++ )
    7171021    {
    7181022      Int iDeltaCurSPos  = (iFillSPos << m_iShiftPrec) - iLastSPos;
    7191023
    720       AOT( iDeltaCurSPos > iDeltaSPos );
    721       AOT( iDeltaCurSPos < 0 );
    722       AOT( m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead);
    723 
    724       Int iSourcePos = (iCurPos  << m_iShiftPrec) +  m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos];   // GT:  = iPosX - iStep + ( iStep * iDeltaCurPos + ( iDeltaPos >> 1) ) / iDeltaPos;
    725 
    726       xSetShiftedPel( iSourcePos, iFillSPos, REN_IS_FILLED, riError );
     1024      RM_AOT( iDeltaCurSPos > iDeltaSPos );
     1025      RM_AOT( iDeltaCurSPos < 0 );
     1026      RM_AOT( m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead);
     1027
     1028      xSetShiftedPelR<bSet>( iCurPos, m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos], iFillSPos, REN_IS_FILLED, riError );
    7271029    }
    7281030  };
     
    7311033
    7321034
    733 __inline Void
    734 TRenSingleModel::xRenderRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
    735 {
     1035template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1036TRenSingleModelC<iBM,bBitInc>::xRenderRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
     1037{
     1038  const Int iCurViewPos = 0;
    7361039  if (  !m_bInOcclusion )
    7371040  {
     
    7441047      {
    7451048        m_iThisDepth = m_iLastDepth;
    746         xSetShiftedPel( (iCurPos+1) << m_iShiftPrec, iRightSPosFP, REN_IS_FILLED, riError );
     1049
     1050        xSetShiftedPelL<bSet>( iCurPos+1, 0, iRightSPosFP, REN_IS_FILLED, riError );
    7471051      }
    7481052      m_iLastOccludedSPosFP = iRightSPosFP;
     
    7501054      m_bInOcclusion = true;
    7511055
    752       if ( m_bSet )
    753       {
    754         m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true;
     1056      if ( bSet )
     1057      {
     1058        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = true;
    7551059      }
    7561060    }
    7571061    else
    7581062    {
    759       if ( m_bSet )
    760       {
    761         m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false;
    762       }
    763 
    764       xRenderShiftedRangeL(iCurSPos, iLastSPos, iCurPos, riError );
     1063      if ( bSet )
     1064      {
     1065        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = false;
     1066      }
     1067
     1068      xRenderShiftedRangeL<bSet>(iCurSPos, iLastSPos, iCurPos, riError );
    7651069    }
    7661070  }
     
    7701074    {
    7711075      m_bInOcclusion = false;
    772       if ( m_bSet )
    773       {
    774         m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false;
    775       }
    776 
    777       xRenderShiftedRangeL(iCurSPos, iLastSPos, iCurPos, riError );
     1076      if ( bSet )
     1077      {
     1078        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = false;
     1079      }
     1080
     1081      xRenderShiftedRangeL<bSet>(iCurSPos, iLastSPos, iCurPos, riError );
    7781082    }
    7791083    else
    7801084    {
    781       if ( m_bSet )
    782       {
    783         m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true;
    784       }
    785     }
    786   }
    787 }
    788 
    789 __inline Void
    790 TRenSingleModel::xRenderRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
    791 {
     1085      if ( bSet )
     1086      {
     1087        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded  = true;
     1088      }
     1089    }
     1090  }
     1091}
     1092
     1093template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1094TRenSingleModelC<iBM,bBitInc>::xRenderRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
     1095{
     1096  const Int iCurViewPos = 1;
    7921097  // Find out if current sample is occluded
    7931098  if (  !m_bInOcclusion )
     
    8011106      {
    8021107        m_iThisDepth = m_iLastDepth;
    803         xSetShiftedPel( (iCurPos-1) << m_iShiftPrec, iLeftSPosFP, REN_IS_FILLED, riError );
     1108        xSetShiftedPelR<bSet>( iCurPos-1,1 << m_iShiftPrec , iLeftSPosFP, REN_IS_FILLED, riError );
    8041109      }
    8051110      m_iLastOccludedSPosFP = iLeftSPosFP;
     
    8071112      m_bInOcclusion = true;
    8081113
    809       if ( m_bSet )
    810       {
    811         m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true;
     1114      if ( bSet )
     1115      {
     1116        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = true;
    8121117      }
    8131118    }
    8141119    else
    8151120    {
    816       if ( m_bSet )
    817       {
    818         m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false;
    819       }
    820 
    821       xRenderShiftedRangeR(iCurSPos, iLastSPos, iCurPos, riError );
     1121      if ( bSet )
     1122      {
     1123        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = false;
     1124      }
     1125
     1126      xRenderShiftedRangeR<bSet>(iCurSPos, iLastSPos, iCurPos, riError );
    8221127    }
    8231128  }
     
    8271132    {
    8281133      m_bInOcclusion = false;
    829       if ( m_bSet )
    830       {
    831         m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false;
    832       }
    833 
    834       xRenderShiftedRangeR(iCurSPos, iLastSPos, iCurPos, riError );
     1134      if ( bSet )
     1135      {
     1136        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = false;
     1137      }
     1138
     1139      xRenderShiftedRangeR<bSet>(iCurSPos, iLastSPos, iCurPos, riError );
    8351140    }
    8361141    else
    8371142    {
    838       if ( m_bSet )
    839       {
    840         m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true;
    841       }
    842     }
    843   }
    844 }
    845 
    846 __inline Void
    847 TRenSingleModel::xFillHoleL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
     1143      if ( bSet )
     1144      {
     1145        m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = true;
     1146      }
     1147    }
     1148  }
     1149}
     1150
     1151template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1152TRenSingleModelC<iBM,bBitInc>::xFillHoleL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
    8481153{
    8491154  if (iLastSPos < 0)
     
    8611166    {
    8621167      m_iThisDepth = m_iCurDepth;
    863       xSetShiftedPel     ( iStartFillPos << m_iShiftPrec, iStartFillSPosFP, REN_IS_FILLED, riError );
     1168      xSetShiftedPelL<bSet>    ( iStartFillPos, 0, iStartFillSPosFP, REN_IS_FILLED, riError );
    8641169    }
    8651170  }
     
    8701175
    8711176  m_iThisDepth = m_iLastDepth;
    872   for (Int iFillSPos = max(iStartFillSPosFP+1,0); iFillSPos <= min(xRangeRightL( iLastSPos ), m_iLastOccludedSPosFP-1 ); iFillSPos++ )
    873   {
    874     xSetShiftedPel( iLastPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
    875   }
    876 }
    877 
    878 __inline Void
    879 TRenSingleModel::xFillHoleR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
     1177  for (Int iFillSPos = Max(iStartFillSPosFP+1,0); iFillSPos <= min(xRangeRightL( iLastSPos ), m_iLastOccludedSPosFP-1 ); iFillSPos++ )
     1178  {
     1179    xSetShiftedPelL<bSet>( iLastPos, 0, iFillSPos, REN_IS_HOLE, riError );
     1180  }
     1181}
     1182
     1183template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1184TRenSingleModelC<iBM,bBitInc>::xFillHoleR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
    8801185{
    8811186  if (iLastSPos < 0)
     
    8931198    {
    8941199      m_iThisDepth = m_iCurDepth;
    895       xSetShiftedPel( iEndFillPos << m_iShiftPrec, iStartFillSPosFP, REN_IS_FILLED, riError );
     1200      xSetShiftedPelR<bSet>( iEndFillPos, 1 << m_iShiftPrec , iStartFillSPosFP, REN_IS_FILLED, riError );
    8961201    }
    8971202  }
     
    9041209  for (Int iFillSPos = max(xRangeLeftR( iLastSPos ), m_iLastOccludedSPosFP+1); iFillSPos <= min(iStartFillSPosFP,m_iWidth)-1 ; iFillSPos++ )
    9051210  {
    906     xSetShiftedPel( iLastPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
    907   }
    908 }
    909 
    910 __inline Void
    911 TRenSingleModel::xExtrapolateMarginL(Int iCurSPos, Int iCurPos, RMDist& riError )
     1211    xSetShiftedPelR<bSet>( iLastPos, 1 << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
     1212  }
     1213}
     1214
     1215template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1216TRenSingleModelC<iBM,bBitInc>::xExtrapolateMarginL(Int iCurSPos, Int iCurPos, RMDist& riError )
    9121217{
    9131218//  if (iLeftSPos < 0 )
    9141219//    return;
    9151220
    916   Int iSPosFullPel = max(0,xRangeLeftL(iCurSPos));
     1221  Int iSPosFullPel = Max(0,xRangeLeftL(iCurSPos));
    9171222
    9181223  m_iThisDepth = m_iCurDepth;
    9191224  if (iSPosFullPel < m_iWidth)
    9201225  {
    921     xSetShiftedPel( iCurPos << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError );
     1226    xSetShiftedPelL<bSet>( iCurPos, 0, iSPosFullPel, REN_IS_FILLED, riError );
    9221227  }
    9231228
    9241229  for (Int iFillSPos = iSPosFullPel +1; iFillSPos < m_iWidth; iFillSPos++ )
    9251230  {
    926     xSetShiftedPel( iCurPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
    927   }
    928 }
    929 
    930 __inline Void
    931 TRenSingleModel::xExtrapolateMarginR(Int iCurSPos, Int iCurPos, RMDist& riError )
     1231    xSetShiftedPelL<bSet>( iCurPos, 0, iFillSPos, REN_IS_HOLE, riError );
     1232  }
     1233}
     1234
     1235template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1236TRenSingleModelC<iBM,bBitInc>::xExtrapolateMarginR(Int iCurSPos, Int iCurPos, RMDist& riError )
    9321237{
    9331238  //  if (iLeftSPos < 0 )
     
    9391244  if (iSPosFullPel > -1)
    9401245  {
    941     xSetShiftedPel( iCurPos << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError );
     1246    xSetShiftedPelR<bSet>( iCurPos, 1 << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError );
    9421247  }
    9431248
    9441249  for (Int iFillSPos = iSPosFullPel -1; iFillSPos > -1; iFillSPos-- )
    9451250  {
    946     xSetShiftedPel( iCurPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
    947   }
    948 }
    949 
    950 
    951 __inline Int
    952 TRenSingleModel::xShiftNewData( Int iPosX, Int iPosInNewData )
    953 {
    954   AOT( iPosInNewData <               0 );
    955   AOF( iPosInNewData < m_iNewDataWidth );
    956 
    957   return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( m_piNewDepthData[iPosInNewData] )];
    958 }
    959 
    960 __inline Int
    961 TRenSingleModel::xShift( Int iPosX )
    962 {
    963  AOT( iPosX <        0);
    964  AOF( iPosX < m_iWidth);
    965  return (iPosX  << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( m_apiBaseDepthPelRow[m_iCurViewPos][iPosX] )];
    966 }
    967 
    968 
    969 __inline Int
    970 TRenSingleModel::xShift( Int iPos, Int iPosInNewData )
     1251    xSetShiftedPelR<bSet>( iCurPos , 1 << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );
     1252  }
     1253}
     1254
     1255template <BlenMod iBM, Bool bBitInc> __inline Int
     1256TRenSingleModelC<iBM,bBitInc>::xShiftNewData( Int iPosX, Int iPosInNewData )
     1257{
     1258  RM_AOT( iPosInNewData <               0 );
     1259  RM_AOF( iPosInNewData < m_iNewDataWidth );
     1260
     1261  return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( m_piNewDepthData[iPosInNewData] )];
     1262}
     1263
     1264template <BlenMod iBM, Bool bBitInc> __inline Int
     1265TRenSingleModelC<iBM,bBitInc>::xShift( Int iPosX )
     1266{
     1267 RM_AOT( iPosX <        0);
     1268 RM_AOF( iPosX < m_iWidth);
     1269
     1270 return (iPosX  << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( m_pcInputSamplesRow[m_iCurViewPos][iPosX].iD )];
     1271}
     1272
     1273
     1274template <BlenMod iBM, Bool bBitInc> __inline Int
     1275TRenSingleModelC<iBM,bBitInc>::xShift( Int iPos, Int iPosInNewData )
    9711276{
    9721277  if ( (iPosInNewData >= 0) && (iPosInNewData < m_iNewDataWidth) )
     
    9801285}
    9811286
    982 __inline Int
    983 TRenSingleModel::xRangeLeftL( Int iPos )
     1287template <BlenMod iBM, Bool bBitInc> __inline Int
     1288TRenSingleModelC<iBM,bBitInc>::xRangeLeftL( Int iPos )
    9841289{
    9851290  return  ( iPos +  (1 << m_iShiftPrec) - 1) >> m_iShiftPrec;
     
    9871292
    9881293
    989 __inline Int
    990 TRenSingleModel::xRangeLeftR( Int iPos )
     1294template <BlenMod iBM, Bool bBitInc> __inline Int
     1295TRenSingleModelC<iBM,bBitInc>::xRangeLeftR( Int iPos )
    9911296{
    9921297
     
    9951300
    9961301
    997 __inline Int
    998 TRenSingleModel::xRangeRightL( Int iPos )
     1302template <BlenMod iBM, Bool bBitInc> __inline Int
     1303TRenSingleModelC<iBM,bBitInc>::xRangeRightL( Int iPos )
    9991304{
    10001305  return xRangeLeftL(iPos) - 1;
    10011306}
    10021307
    1003 __inline Int
    1004 TRenSingleModel::xRangeRightR( Int iPos )
     1308template <BlenMod iBM, Bool bBitInc> __inline Int
     1309TRenSingleModelC<iBM,bBitInc>::xRangeRightR( Int iPos )
    10051310{
    10061311  return iPos >> m_iShiftPrec;
     
    10081313
    10091314
    1010 __inline Int
    1011 TRenSingleModel::xRoundL( Int iPos )
     1315template <BlenMod iBM, Bool bBitInc> __inline Int
     1316TRenSingleModelC<iBM,bBitInc>::xRoundL( Int iPos )
    10121317{
    10131318  return  (iPos + (( 1 << m_iShiftPrec ) >> 1 )) >> m_iShiftPrec;
    10141319}
    10151320
    1016 __inline Int
    1017 TRenSingleModel::xRoundR( Int iPos )
     1321template <BlenMod iBM, Bool bBitInc> __inline Int
     1322TRenSingleModelC<iBM,bBitInc>::xRoundR( Int iPos )
    10181323{
    10191324  return  (m_iShiftPrec == 0) ? iPos : xRoundL(iPos - 1);
     
    10211326
    10221327
    1023 Void
    1024 TRenSingleModel::xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal )
     1328template <BlenMod iBM, Bool bBitInc> Void
     1329TRenSingleModelC<iBM,bBitInc>::xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal )
    10251330{
    10261331  for (Int iYPos = 0; iYPos < iHeight; iYPos++)
     
    10341339}
    10351340
    1036 Void
    1037 TRenSingleModel::xSetInts( Int* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal )
     1341template <BlenMod iBM, Bool bBitInc> Void
     1342TRenSingleModelC<iBM,bBitInc>::xSetInts( Int* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal )
    10381343{
    10391344  for (Int iYPos = 0; iYPos < iHeight; iYPos++)
     
    10481353
    10491354
    1050 Void
    1051 TRenSingleModel::xSetBools( Bool* pbPelSource , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal )
     1355template <BlenMod iBM, Bool bBitInc> Void
     1356TRenSingleModelC<iBM,bBitInc>::xSetBools( Bool* pbPelSource , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal )
    10521357{
    10531358  for (Int iYPos = 0; iYPos < iHeight; iYPos++)
     
    10611366}
    10621367
    1063 Void
    1064 TRenSingleModel::xInitView( Int iViewPos )
    1065 {
    1066   AOT( iViewPos == VIEWPOS_MERGED && ( m_iMode == 0 || m_iMode == 1 ) );
    1067 
    1068   xSetPels( m_aapiSynthVideoPel[iViewPos][0], m_iStride, m_iWidth, m_iHeight, 0 );
    1069   xSetPels( m_aapiSynthVideoPel[iViewPos][1], m_iStride, m_iWidth, m_iHeight, 128 << g_uiBitIncrement );
    1070   xSetPels( m_aapiSynthVideoPel[iViewPos][2], m_iStride, m_iWidth, m_iHeight, 128 << g_uiBitIncrement );
    1071 
    1072   if ( iViewPos != VIEWPOS_MERGED)
    1073   {
    1074     xSetBools( m_apbOccluded     [iViewPos],  m_iStride, m_iWidth, m_iHeight, false );
    1075     xSetPels ( m_apiFilled       [iViewPos],  m_iStride, m_iWidth, m_iHeight, REN_IS_HOLE);
    1076     if ( m_iMode == 2 )
    1077     {
    1078       xSetPels( m_apiSynthDepthPel [iViewPos],  m_iStride, m_iWidth, m_iHeight, 0);
    1079     }
    1080   }
    1081 }
    1082 
    1083 __inline Void
    1084 TRenSingleModel::xSetShiftedPel(Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError )
    1085 {
    1086   AOT( iSourcePos < 0         );
    1087   AOT( iSourcePos >= m_iSampledWidth );
    1088 
    1089   AOT( iTargetSPos < 0         );
    1090   AOT( iTargetSPos >= m_iWidth );
    1091 //  AOT(  m_apiFilledRow[m_iViewPos][iTargetSPos] != REN_IS_HOLE);
    1092 
    1093   if ( m_iMode == 2)
    1094   {
    1095     xSetShiftedPelBlend(iSourcePos, iTargetSPos, iFilled, riError );
    1096     return;
    1097   }
    1098 
    1099   if ( m_bSet )
    1100   {
    1101     m_aapiSynthVideoPelRow[m_iCurViewPos][0][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][0][iSourcePos];
    1102 #if HHI_VSO_COLOR_PLANES
    1103     m_aapiSynthVideoPelRow[m_iCurViewPos][1][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][1][iSourcePos];
    1104     m_aapiSynthVideoPelRow[m_iCurViewPos][2][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][2][iSourcePos];
    1105 #endif
    1106     m_apiFilledRow        [m_iCurViewPos]   [iTargetSPos] = iFilled;
    1107     Int iDiffY = m_aapiRefVideoPelRow    [0][iTargetSPos] - m_aapiSynthVideoPelRow[m_iCurViewPos][0][iTargetSPos];
    1108 #if HHI_VSO_COLOR_PLANES
    1109     Int iDiffU = m_aapiRefVideoPelRow    [1][iTargetSPos] - m_aapiSynthVideoPelRow[m_iCurViewPos][1][iTargetSPos];
    1110     Int iDiffV = m_aapiRefVideoPelRow    [2][iTargetSPos] - m_aapiSynthVideoPelRow[m_iCurViewPos][2][iTargetSPos];
    1111     m_apiErrorRow                           [iTargetSPos] = xGetDist( iDiffY, iDiffU, iDiffV);
    1112 #else
    1113     m_apiErrorRow                           [iTargetSPos] = xGetDist(iDiffY);
    1114 #endif
     1368template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1369TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelL(Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError )
     1370{
     1371  RM_AOT( iSourcePos    <  0                   );
     1372  RM_AOT( iSourcePos    >= m_iWidth            );
     1373  RM_AOT( iSubSourcePos < 0                    );
     1374  RM_AOT( iSubSourcePos >  (1 << m_iShiftPrec) );
     1375  RM_AOT( iTargetSPos   < 0                    );
     1376  RM_AOT( iTargetSPos   >= m_iWidth            ); 
     1377
     1378  RenModelOutPels* pcOutSample = m_pcOutputSamplesRow              + iTargetSPos;
     1379  RenModelInPels * pcInSample  = m_pcInputSamplesRow[VIEWPOS_LEFT] + iSourcePos ;
     1380
     1381  if ( iBM != BLEND_NONE )
     1382  {
     1383    xSetShiftedPelBlendL<bSet>  (pcInSample, iSubSourcePos, pcOutSample, iFilled, riError);
    11151384  }
    11161385  else
    11171386  {
    1118     Int iSDOld   = m_apiErrorRow            [iTargetSPos];
    1119     Int iDiffY   = m_aapiRefVideoPelRow  [0][iTargetSPos] - m_aapiBaseVideoPelRow [m_iCurViewPos][0][iSourcePos];
    1120 #if HHI_VSO_COLOR_PLANES
    1121     Int iDiffU   = m_aapiRefVideoPelRow  [1][iTargetSPos] - m_aapiBaseVideoPelRow [m_iCurViewPos][1][iSourcePos];
    1122     Int iDiffV   = m_aapiRefVideoPelRow  [2][iTargetSPos] - m_aapiBaseVideoPelRow [m_iCurViewPos][2][iSourcePos];
    1123     riError     += ( xGetDist(iDiffY,iDiffU,iDiffV) - iSDOld  );
    1124 #else
    1125     riError     +=  ( xGetDist( iDiffY ) - iSDOld );
    1126 #endif
    1127   }
    1128 }
    1129 
    1130 __inline Void
    1131 TRenSingleModel::xSetShiftedPelBlend( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError )
    1132 {
    1133   AOT( iSourcePos < 0         );
    1134   AOT( iSourcePos >= m_iSampledWidth );
    1135 
    1136   AOT( iTargetSPos < 0         );
    1137   AOT( iTargetSPos >= m_iWidth );
    1138   //  AOT(  m_apiFilledRow[m_iViewPos][iTargetSPos] != REN_IS_HOLE);
    1139 
     1387    xSetShiftedPelNoBlendL<bSet>(pcInSample, iSubSourcePos, pcOutSample, iFilled, riError);
     1388  }
     1389}
     1390
     1391template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1392TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelNoBlendL(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError )
     1393{
     1394  if ( bSet )
     1395  {
     1396    // Filled
     1397    pcOutSample->iFilledLeft = iFilled;
     1398
     1399    // Yuv
     1400    pcOutSample->iYLeft  = pcInSample->aiY[iSubSourcePos];
     1401#if HHI_VSO_COLOR_PLANES
     1402    pcOutSample->iULeft  = pcInSample->aiU[iSubSourcePos];
     1403    pcOutSample->iVLeft  = pcInSample->aiV[iSubSourcePos];
     1404
     1405    pcOutSample->iError = xGetDist( pcOutSample->iYLeft - pcOutSample->iYRef,
     1406                                    pcOutSample->iULeft - pcOutSample->iURef,   
     1407                                    pcOutSample->iVLeft - pcOutSample->iVRef
     1408                                  );   
     1409#else
     1410    pcOutSample->iError = xGetDist( pcOutSample->iYLeft - pcOutSample->iYRef );   
     1411#endif   
     1412   
     1413  }
     1414  else
     1415  {
     1416#if HHI_VSO_COLOR_PLANES
     1417    riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef,
     1418                         pcInSample->aiU[iSubSourcePos] - pcOutSample->iURef,
     1419                         pcInSample->aiV[iSubSourcePos] - pcOutSample->iVRef
     1420                       );
     1421#else               
     1422    riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef );
     1423#endif
     1424
     1425    riError -= pcOutSample->iError;
     1426  }
     1427}
     1428
     1429template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1430TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelBlendL(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError )
     1431{
    11401432  Pel piBlendedValueY;
    11411433#if HHI_VSO_COLOR_PLANES
     
    11441436#endif
    11451437
    1146 
    1147   if (m_iCurViewPos == 0)
    1148   {
    1149     xGetBlendedValue (
    1150       m_aapiBaseVideoPelRow                                    [0][0][iSourcePos ]  ,
    1151       m_aapiSynthVideoPelRow                                   [1][0][iTargetSPos]  ,
    1152 #if HHI_VSO_COLOR_PLANES
    1153       m_aapiBaseVideoPelRow                                    [0][1][iSourcePos ]  ,
    1154       m_aapiSynthVideoPelRow                                   [1][1][iTargetSPos]  ,
    1155       m_aapiBaseVideoPelRow                                    [0][2][iSourcePos ]  ,
    1156       m_aapiSynthVideoPelRow                                   [1][2][iTargetSPos]  ,
    1157 #endif
    1158       m_piInvZLUTLeft [RemoveBitIncrement(m_iThisDepth)                            ],
    1159       m_piInvZLUTRight[RemoveBitIncrement(m_apiSynthDepthPelRow[1]   [iTargetSPos])],
    1160       iFilled,
    1161       m_apiFilledRow                                           [1]   [iTargetSPos]  ,
    1162       piBlendedValueY
     1438  xGetBlendedValue (
     1439    pcInSample ->aiY[iSubSourcePos],
     1440    pcOutSample->iYRight,   
     1441#if HHI_VSO_COLOR_PLANES
     1442    pcInSample ->aiU[iSubSourcePos],
     1443    pcOutSample->iURight,   
     1444    pcInSample ->aiV[iSubSourcePos],
     1445    pcOutSample->iVRight,   
     1446#endif
     1447    m_piInvZLUTLeft [RenModRemoveBitInc(m_iThisDepth)        ],
     1448    m_piInvZLUTRight[RenModRemoveBitInc(pcOutSample->iDRight)],
     1449    iFilled,
     1450    pcOutSample->iFilledRight  ,
     1451    piBlendedValueY
    11631452#if HHI_VSO_COLOR_PLANES
    11641453    , piBlendedValueU,
    1165       piBlendedValueV
     1454    piBlendedValueV
    11661455#endif
    11671456    );
     1457
     1458  if ( bSet )
     1459  {   
     1460    // Set values
     1461    pcOutSample->iDLeft      = m_iThisDepth;
     1462    pcOutSample->iYLeft      = pcInSample ->aiY[iSubSourcePos];
     1463    pcOutSample->iYBlended   = piBlendedValueY;   
     1464#if HHI_VSO_COLOR_PLANES 
     1465    pcOutSample->iULeft      = pcInSample ->aiU[iSubSourcePos];
     1466    pcOutSample->iUBlended   = piBlendedValueU;   
     1467    pcOutSample->iVLeft      = pcInSample ->aiV[iSubSourcePos];
     1468    pcOutSample->iVBlended   = piBlendedValueV;   
     1469#endif
     1470    pcOutSample->iFilledLeft = iFilled;
     1471
     1472    // Get Error
     1473    Int iDiffY = pcOutSample->iYRef - piBlendedValueY;
     1474#if HHI_VSO_COLOR_PLANES
     1475    Int iDiffU = pcOutSample->iURef - piBlendedValueU;
     1476    Int iDiffV = pcOutSample->iVRef - piBlendedValueV;
     1477    pcOutSample->iError  = xGetDist(iDiffY, iDiffU, iDiffV );
     1478#else
     1479    pcOutSample->iError  = xGetDist(iDiffY );
     1480#endif
    11681481  }
    11691482  else
    11701483  {
    1171     xGetBlendedValue (
    1172       m_aapiSynthVideoPelRow                                   [0][0][iTargetSPos],
    1173       m_aapiBaseVideoPelRow                                    [1][0][iSourcePos ],
    1174 #if HHI_VSO_COLOR_PLANES
    1175       m_aapiSynthVideoPelRow                                   [0][1][iTargetSPos],
    1176       m_aapiBaseVideoPelRow                                    [1][1][iSourcePos ],
    1177       m_aapiSynthVideoPelRow                                   [0][2][iTargetSPos],
    1178       m_aapiBaseVideoPelRow                                    [1][2][iSourcePos ],
    1179 #endif
    1180       m_piInvZLUTLeft [RemoveBitIncrement(m_apiSynthDepthPelRow[0]   [iTargetSPos])],
    1181       m_piInvZLUTRight[RemoveBitIncrement(m_iThisDepth)                            ],
    1182       m_apiFilledRow                                           [0]   [iTargetSPos],
    1183       iFilled                                                                     ,
    1184       piBlendedValueY
     1484    Int iDiffY = pcOutSample->iYRef - piBlendedValueY;
     1485#if HHI_VSO_COLOR_PLANES
     1486    Int iDiffU = pcOutSample->iURef - piBlendedValueU;
     1487    Int iDiffV = pcOutSample->iVRef - piBlendedValueV;
     1488    riError   += ( xGetDist( iDiffY, iDiffU, iDiffV ) - pcOutSample->iError );
     1489
     1490#else
     1491    riError   += ( xGetDist( iDiffY ) - pcOutSample->iError  );
     1492#endif
     1493
     1494  }
     1495}
     1496
     1497
     1498template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1499TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelR(Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError )
     1500{
     1501  RM_AOT( iSourcePos    <  0                     );
     1502  RM_AOT( iSourcePos    >= m_iWidth              );
     1503  RM_AOT( iSubSourcePos <  0                     );
     1504  RM_AOT( iSubSourcePos >= (1 << m_iShiftPrec)+1 );
     1505  RM_AOT( iTargetSPos   < 0                      );
     1506  RM_AOT( iTargetSPos   >= m_iWidth              ); 
     1507
     1508  RenModelOutPels* pcOutSample = m_pcOutputSamplesRow               + iTargetSPos;
     1509  RenModelInPels * pcInSample  = m_pcInputSamplesRow[VIEWPOS_RIGHT] + iSourcePos ;
     1510
     1511  if ( iBM != BLEND_NONE )
     1512  {
     1513    xSetShiftedPelBlendR<bSet>   (pcInSample, iSubSourcePos, pcOutSample, iFilled, riError);
     1514  }
     1515  else
     1516  {
     1517    xSetShiftedPelNoBlendR<bSet> (pcInSample, iSubSourcePos, pcOutSample, iFilled, riError);
     1518  }
     1519}
     1520
     1521template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1522TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelNoBlendR(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError )
     1523{
     1524  if ( bSet )
     1525  {
     1526    // Filled
     1527    pcOutSample->iFilledRight = iFilled;
     1528
     1529    // Yuv
     1530    pcOutSample->iYRight  = pcInSample->aiY[iSubSourcePos];
     1531#if HHI_VSO_COLOR_PLANES
     1532    pcOutSample->iURight  = pcInSample->aiU[iSubSourcePos];
     1533    pcOutSample->iVRight  = pcInSample->aiV[iSubSourcePos];
     1534
     1535    pcOutSample->iError = xGetDist(
     1536      pcOutSample->iYRight - pcOutSample->iYRef,
     1537      pcOutSample->iURight - pcOutSample->iURef,   
     1538      pcOutSample->iVRight - pcOutSample->iVRef
     1539      );   
     1540#else
     1541    pcOutSample->iError = xGetDist( pcOutSample->iYRight - pcOutSample->iYRef );   
     1542#endif   
     1543
     1544  }
     1545  else
     1546  {
     1547#if HHI_VSO_COLOR_PLANES
     1548    riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef,
     1549      pcInSample->aiU[iSubSourcePos] - pcOutSample->iURef,
     1550      pcInSample->aiV[iSubSourcePos] - pcOutSample->iVRef
     1551      );
     1552#else               
     1553    riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef );
     1554#endif
     1555
     1556    riError -= pcOutSample->iError;
     1557  }
     1558}
     1559
     1560template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void
     1561TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelBlendR(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError )
     1562{
     1563  Pel piBlendedValueY;
     1564#if HHI_VSO_COLOR_PLANES
     1565  Pel piBlendedValueU;
     1566  Pel piBlendedValueV;
     1567#endif
     1568
     1569  xGetBlendedValue (
     1570    pcOutSample->iYLeft,
     1571    pcInSample ->aiY[iSubSourcePos],       
     1572#if HHI_VSO_COLOR_PLANES
     1573    pcOutSample->iULeft,   
     1574    pcInSample ->aiU[iSubSourcePos],
     1575    pcOutSample->iVLeft,   
     1576    pcInSample ->aiV[iSubSourcePos],
     1577#endif
     1578    m_piInvZLUTLeft  [RenModRemoveBitInc(pcOutSample->iDLeft)],
     1579    m_piInvZLUTRight [RenModRemoveBitInc(m_iThisDepth)       ],
     1580    pcOutSample->iFilledLeft,
     1581    iFilled,
     1582    piBlendedValueY
    11851583#if HHI_VSO_COLOR_PLANES
    11861584    , piBlendedValueU,
    1187       piBlendedValueV
     1585    piBlendedValueV
    11881586#endif
    11891587    );
    1190   }
    1191 
    1192   if ( m_bSet )
    1193   {
    1194     m_apiSynthDepthPelRow [m_iCurViewPos]   [iTargetSPos] = m_iThisDepth;
    1195     m_aapiSynthVideoPelRow[m_iCurViewPos][0][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][0][iSourcePos];
    1196     m_aapiSynthVideoPelRow[2            ][0][iTargetSPos] = piBlendedValueY;
    1197 #if HHI_VSO_COLOR_PLANES
    1198     m_aapiSynthVideoPelRow[m_iCurViewPos][1][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][1][iSourcePos];
    1199     m_aapiSynthVideoPelRow[2            ][1][iTargetSPos] = piBlendedValueU;
    1200     m_aapiSynthVideoPelRow[m_iCurViewPos][2][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][2][iSourcePos];
    1201     m_aapiSynthVideoPelRow[2            ][2][iTargetSPos] = piBlendedValueV;
    1202 #endif
    1203     m_apiFilledRow        [m_iCurViewPos]   [iTargetSPos] = iFilled;
    1204 
    1205     Int iDiffY = m_aapiRefVideoPelRow    [0][iTargetSPos] - piBlendedValueY;
    1206 #if HHI_VSO_COLOR_PLANES
    1207     Int iDiffU = m_aapiRefVideoPelRow    [1][iTargetSPos] - piBlendedValueU;
    1208     Int iDiffV = m_aapiRefVideoPelRow    [2][iTargetSPos] - piBlendedValueV;
    1209     m_apiErrorRow                           [iTargetSPos] = xGetDist(iDiffY, iDiffU, iDiffV );
    1210 #else
    1211     m_apiErrorRow                           [iTargetSPos] = xGetDist(iDiffY);
     1588
     1589  if ( bSet )
     1590  {   
     1591    // Set values
     1592    pcOutSample->iDRight     = m_iThisDepth;
     1593    pcOutSample->iYRight     = pcInSample ->aiY[iSubSourcePos];
     1594    pcOutSample->iYBlended   = piBlendedValueY;   
     1595#if HHI_VSO_COLOR_PLANES 
     1596    pcOutSample->iURight     = pcInSample ->aiU[iSubSourcePos];
     1597    pcOutSample->iUBlended   = piBlendedValueU;   
     1598    pcOutSample->iVRight     = pcInSample ->aiV[iSubSourcePos];
     1599    pcOutSample->iVBlended   = piBlendedValueV;   
     1600#endif
     1601    pcOutSample->iFilledRight = iFilled;
     1602
     1603    // Get Error
     1604    Int iDiffY = pcOutSample->iYRef - piBlendedValueY;
     1605#if HHI_VSO_COLOR_PLANES
     1606    Int iDiffU = pcOutSample->iURef - piBlendedValueU;
     1607    Int iDiffV = pcOutSample->iVRef - piBlendedValueV;
     1608    pcOutSample->iError  = xGetDist(iDiffY, iDiffU, iDiffV );
     1609#else
     1610    pcOutSample->iError  = xGetDist(iDiffY );
    12121611#endif
    12131612  }
    12141613  else
    12151614  {
    1216     Int iSDOld   = m_apiErrorRow            [iTargetSPos];
    1217     Int iDiffY = m_aapiRefVideoPelRow    [0][iTargetSPos] - piBlendedValueY;
    1218 #if HHI_VSO_COLOR_PLANES
    1219     Int iDiffU = m_aapiRefVideoPelRow    [1][iTargetSPos] - piBlendedValueU;
    1220     Int iDiffV = m_aapiRefVideoPelRow    [2][iTargetSPos] - piBlendedValueV;
    1221     riError   += ( xGetDist( iDiffY, iDiffU, iDiffV ) - iSDOld );
    1222 #else
    1223     riError   += ( xGetDist( iDiffY )- iSDOld  );
    1224 #endif
    1225   }
    1226 }
    1227 
    1228 
    1229 __inline Int
    1230 TRenSingleModel::xGetDist( Int iDiffY, Int iDiffU, Int iDiffV )
    1231 {
    1232   return (          ((iDiffY * iDiffY) >> m_iDistShift)
    1233              +  ((( ((iDiffU * iDiffU) >> m_iDistShift)
    1234                    +((iDiffV * iDiffV) >> m_iDistShift)
     1615    Int iDiffY = pcOutSample->iYRef - piBlendedValueY;
     1616#if HHI_VSO_COLOR_PLANES
     1617    Int iDiffU = pcOutSample->iURef - piBlendedValueU;
     1618    Int iDiffV = pcOutSample->iVRef - piBlendedValueV;
     1619    riError   += ( xGetDist( iDiffY, iDiffU, iDiffV ) - pcOutSample->iError );
     1620#else
     1621    riError   += ( xGetDist( iDiffY ) -  pcOutSample->iError  );
     1622#endif
     1623  }
     1624}
     1625
     1626template <BlenMod iBM, Bool bBitInc> __inline Int
     1627TRenSingleModelC<iBM,bBitInc>::xGetDist( Int iDiffY, Int iDiffU, Int iDiffV )
     1628{
     1629
     1630  if ( !bBitInc )
     1631  {
     1632    return (          (iDiffY * iDiffY )
     1633               +  ((( (iDiffU * iDiffU )
     1634                     +(iDiffV * iDiffV )
     1635                    )
     1636                   ) >> 2
    12351637                  )
    1236                  ) >> 2
    1237                 )
    1238          );
    1239 }
    1240 
    1241 __inline Int
    1242 TRenSingleModel::xGetDist( Int iDiffY )
    1243 {
    1244   return ((iDiffY * iDiffY) >> m_iDistShift);
    1245 }
    1246 
    1247 #if HHI_VSO_COLOR_PLANES
    1248 __inline Void
    1249 TRenSingleModel::xGetBlendedValue( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV )
    1250 #else
    1251 Void
    1252 TRenSingleModel::xGetBlendedValue( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )
    1253 #endif
    1254 {
    1255   if (m_iBlendMode != 0 )
    1256   {
    1257     if (m_iBlendMode == 1 )
     1638           );
     1639  }
     1640  else
     1641  {
     1642    return (          ((iDiffY * iDiffY) >> m_iDistShift)
     1643               +  ((( ((iDiffU * iDiffU) >> m_iDistShift)
     1644                     +((iDiffV * iDiffV) >> m_iDistShift)
     1645                    )
     1646                   ) >> 2
     1647                  )
     1648           );
     1649 
     1650  }
     1651}
     1652
     1653template <BlenMod iBM, Bool bBitInc> __inline Int
     1654TRenSingleModelC<iBM,bBitInc>::xGetDist( Int iDiffY )
     1655{
     1656  if ( !bBitInc )
     1657  {
     1658    return (iDiffY * iDiffY);
     1659  }
     1660  else
     1661  {
     1662    return ((iDiffY * iDiffY) >> m_iDistShift);
     1663  }
     1664
     1665}
     1666
     1667
     1668#if HHI_VSO_COLOR_PLANES
     1669template <BlenMod iBM, Bool bBitInc>  __inline Void
     1670TRenSingleModelC<iBM,bBitInc>::xGetBlendedValue( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV )
     1671#else
     1672template <BlenMod iBM, Bool bBitInc>  __inline Void
     1673TRenSingleModelC<iBM,bBitInc>::xGetBlendedValue( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )
     1674#endif
     1675{
     1676
     1677  RM_AOT( iBM != BLEND_AVRG && iBM != BLEND_LEFT && iBM != BLEND_RIGHT );
     1678
     1679  if (iBM != BLEND_AVRG )
     1680  {
     1681    if (iBM == BLEND_LEFT )
    12581682    {
    12591683#if HHI_VSO_COLOR_PLANES
     
    12991723      else
    13001724      {
    1301 #if HHI_FIX
    13021725        riY = xBlend( iYL, iYR, m_iBlendDistWeight );
    13031726#if HHI_VSO_COLOR_PLANES   
     
    13051728        riV = xBlend( iVL, iVR, m_iBlendDistWeight );
    13061729#endif
    1307 #else
    1308         riY = xBlend( iYR, iYL, m_iBlendDistWeight );
    1309 #if HHI_VSO_COLOR_PLANES
    1310         riU = xBlend( iUR, iUL, m_iBlendDistWeight );
    1311         riV = xBlend( iVR, iVL, m_iBlendDistWeight );
    1312 #endif
    1313 #endif
    13141730      }
    13151731    }
     
    13691785    }
    13701786  }
    1371 
    1372 }
    1373 
    1374 __inline Void
    1375 #if HHI_VSO_COLOR_PLANES
    1376 TRenSingleModel::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV )
    1377 #else
    1378 TRenSingleModel::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )
    1379 #endif
    1380 {
    1381   if      ( iFilledL == REN_IS_FILLED ||  iFilledR == REN_IS_HOLE )
     1787}
     1788
     1789template <BlenMod iBM, Bool bBitInc> __inline Void
     1790#if HHI_VSO_COLOR_PLANES
     1791TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV )
     1792#else
     1793TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )
     1794#endif
     1795{
     1796  if ( iFilledL == REN_IS_FILLED ||  iFilledR == REN_IS_HOLE )
    13821797  {
    13831798    riY = iYL;
     
    14051820}
    14061821
    1407 __inline Void
    1408 #if HHI_VSO_COLOR_PLANES
    1409 TRenSingleModel::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV )
    1410 #else
    1411 TRenSingleModel::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )
     1822template <BlenMod iBM, Bool bBitInc> __inline Void
     1823#if HHI_VSO_COLOR_PLANES
     1824TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV )
     1825#else
     1826TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )
    14121827#endif
    14131828{
     
    14381853}
    14391854
    1440 __inline Pel
    1441 TRenSingleModel::xBlend( Pel pVal1, Pel pVal2, Int iWeightVal2 )
     1855template <BlenMod iBM, Bool bBitInc> __inline Pel
     1856TRenSingleModelC<iBM,bBitInc>::xBlend( Pel pVal1, Pel pVal2, Int iWeightVal2 )
    14421857{
    14431858  return pVal1  +  (Pel) (  ( (Int) ( pVal2 - pVal1) * iWeightVal2 + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC );
    14441859}
     1860
     1861template <BlenMod iBM, Bool bBitInc> Void
     1862TRenSingleModelC<iBM,bBitInc>::xCopy2PicYuv( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget, UInt uiHorOffset )
     1863{
     1864  TRenFilter::copy            ( ppiSrcVideoPel[0], piStrides[0], m_iWidth, m_iHeight, rpcPicYuvTarget->getLumaAddr() +  uiHorOffset       * rpcPicYuvTarget->getStride() , rpcPicYuvTarget->getStride () );
     1865  TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[1], piStrides[1], m_iWidth, m_iHeight, rpcPicYuvTarget->getCbAddr  () + (uiHorOffset >> 1) * rpcPicYuvTarget->getCStride(), rpcPicYuvTarget->getCStride() );
     1866  TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[2], piStrides[2], m_iWidth, m_iHeight, rpcPicYuvTarget->getCrAddr  () + (uiHorOffset >> 1) * rpcPicYuvTarget->getCStride(), rpcPicYuvTarget->getCStride() );
     1867}
     1868
     1869template class TRenSingleModelC<BLEND_NONE ,true>;
     1870template class TRenSingleModelC<BLEND_AVRG ,true>;
     1871template class TRenSingleModelC<BLEND_LEFT ,true>;
     1872template class TRenSingleModelC<BLEND_RIGHT,true>;
     1873
     1874template class TRenSingleModelC<BLEND_NONE ,false>;
     1875template class TRenSingleModelC<BLEND_AVRG ,false>;
     1876template class TRenSingleModelC<BLEND_LEFT ,false>;
     1877template class TRenSingleModelC<BLEND_RIGHT,false>;
     1878
     1879#ifdef LGE_VSO_EARLY_SKIP_A0093
     1880template <BlenMod iBM, Bool bBitInc>
     1881__inline Bool
     1882TRenSingleModelC<iBM,bBitInc>::xDetectEarlySkipL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData,Pel* piOrgData, Int iOrgStride)
     1883{
     1884  RM_AOF( m_bEarlySkip );
     1885  const Int iCurViewPos = 0;
     1886  Int** ppiCurLUT       = m_appiShiftLut   [ iCurViewPos ];
     1887 
     1888  Bool bNoDiff          = true;   
     1889 
     1890  for (Int iPosY=0; iPosY < iHeight; iPosY++)
     1891  {
     1892    m_pbHorSkip[iPosY] = true;
     1893
     1894    for (Int iPosX = 0; iPosX < iWidth; iPosX++)
     1895    {
     1896      Int iDisparityRec = abs(ppiCurLUT[0][ RenModRemoveBitInc(piNewData[iPosX])]);
     1897      Int iDispartyOrg  = abs(ppiCurLUT[0][ RenModRemoveBitInc(piOrgData[iPosX])]);
     1898
     1899      if( iDispartyOrg != iDisparityRec)
     1900      {
     1901        m_pbHorSkip[iPosY] = false;
     1902        bNoDiff            = false;
     1903        break;
     1904      }
     1905    }
     1906    piNewData += iStride;
     1907    piOrgData += iOrgStride;
     1908  }
     1909  return bNoDiff;
     1910}
     1911
     1912template <BlenMod iBM, Bool bBitInc>
     1913__inline Bool
     1914TRenSingleModelC<iBM,bBitInc>::xDetectEarlySkipR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData,Pel* piOrgData, Int iOrgStride)
     1915{
     1916  RM_AOF( m_bEarlySkip );
     1917  Bool bNoDiff  = true;
     1918
     1919  const Int iCurViewPos = 1;
     1920  Int** ppiCurLUT       = m_appiShiftLut   [ iCurViewPos ];
     1921
     1922  for ( Int iPosY = 0; iPosY < iHeight; iPosY++ )
     1923  {
     1924    m_pbHorSkip[iPosY] = true;
     1925
     1926    for (Int iPosX = 0; iPosX < iWidth; iPosX++)
     1927    {
     1928      Int iDisparityRec = abs( ppiCurLUT[0][ RenModRemoveBitInc(piNewData[iPosX])] );
     1929      Int iDisparityOrg = abs( ppiCurLUT[0][ RenModRemoveBitInc(piOrgData[iPosX])] );
     1930
     1931      if( iDisparityRec != iDisparityOrg )
     1932      {
     1933        m_pbHorSkip[iPosY] = false;
     1934        bNoDiff            = false;
     1935        break;
     1936      }
     1937    }
     1938
     1939    piNewData += iStride;
     1940    piOrgData += iOrgStride;
     1941  }
     1942  return bNoDiff;
     1943}
     1944#endif
  • trunk/source/Lib/TLibRenderer/TRenSingleModel.h

    r56 r100  
    5555
    5656
     57#if HHI_VSO_RM_ASSERTIONS
     58#define RM_AOT( exp ) AOT ( exp )
     59#define RM_AOF( exp ) AOF ( exp )
     60#else
     61#define RM_AOT( exp ) ((void)0)
     62#define RM_AOF( exp ) ((void)0)
     63#endif
     64
     65#define RenModRemoveBitInc( exp ) bBitInc ? ( RemoveBitIncrement( exp ) ) : ( exp )
     66
    5767class TRenSingleModel
    5868{
     69public:
     70#if LGE_VSO_EARLY_SKIP_A0093
     71  virtual Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bEarlySkip ) = 0;
     72#else
     73  virtual Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode ) = 0;
     74#endif
     75
     76  // Set Frame dependent data
     77  virtual Void   setLRView ( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride ) = 0;
     78  virtual Void   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference, UInt uiHorOffset ) = 0;
     79
     80  // Set Data
     81#ifdef LGE_VSO_EARLY_SKIP_A0093
     82  virtual Void   setDepth  ( Int iViewPos,                 Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel* piOrgData, Int iOrgStride )  = 0;
     83#else
     84  virtual Void   setDepth  ( Int iViewPos,                 Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )  = 0;
     85#endif
     86  virtual Void   setVideo  ( Int iViewPos,     Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) = 0;
     87
     88  // Get Distortion
     89#ifdef LGE_VSO_EARLY_SKIP_A0093
     90  virtual RMDist getDistDepth  ( Int iViewPos,             Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel * piOrgData , Int iOrgStride)=0;
     91#else
     92  virtual RMDist getDistDepth  ( Int iViewPos,             Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) = 0;
     93#endif
     94  virtual RMDist getDistVideo  ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) = 0;
     95
     96  virtual Void   getSynthVideo  ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset  ) = 0; 
     97  virtual Void   getSynthDepth  ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset  ) = 0;
     98  virtual Void   getRefVideo    ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset  ) = 0;
     99};
     100
     101template < BlenMod iBM, Bool bBitInc >
     102class TRenSingleModelC : public TRenSingleModel
     103{
     104  struct RenModelInPels
     105  {
     106    // video
     107    Pel aiY[5]    ; // y-value
     108#if HHI_VSO_COLOR_PLANES
     109    Pel aiU[5]    ; // u-value
     110    Pel aiV[5]    ; // v-value
     111#endif
     112    // depth
     113    Pel iD        ; // depth
     114
     115    // state
     116    Bool bOccluded; // Occluded
     117  };
     118
     119  struct RenModelOutPels
     120  {
     121    // video
     122    Pel iYLeft    ;
     123    Pel iYRight   ;
     124    Pel iYBlended ;
     125#if HHI_VSO_COLOR_PLANES
     126    Pel iULeft    ;
     127    Pel iURight   ;
     128    Pel iUBlended ;
     129    Pel iVLeft    ;
     130    Pel iVRight   ;
     131    Pel iVBlended ;
     132#endif
     133    // depth
     134    Pel iDLeft    ;
     135    Pel iDRight   ;
     136    Pel iDBlended ;
     137
     138    // state
     139    Int iFilledLeft ;
     140    Int iFilledRight;
     141
     142    // error
     143    Int  iError   ;
     144
     145    // reference
     146    Pel iYRef    ;
     147#if HHI_VSO_COLOR_PLANES
     148    Pel iURef    ;
     149    Pel iVRef    ;
     150#endif       
     151  };
     152
     153
    59154
    60155public:
    61   TRenSingleModel();
    62   ~TRenSingleModel();
     156  TRenSingleModelC();
     157  ~TRenSingleModelC();
    63158
    64159  // Create Model
     160#if LGE_VSO_EARLY_SKIP_A0093
     161  Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bEarlySkip  );
     162#else
    65163  Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode );
     164#endif
    66165
    67166  // Set Frame dependent data
    68167  Void   setLRView ( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride );
    69   Void   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference );
    70 
    71   // Set Data
     168  Void   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference, UInt uiHorOffset );
     169
     170#if LGE_VSO_EARLY_SKIP_A0093
     171  Void   setDepth  ( Int iViewPos,                 Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel* piOrgData, Int iOrgStride );
     172#else
    72173  Void   setDepth  ( Int iViewPos,                 Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
     174#endif
    73175  Void   setVideo  ( Int iViewPos,     Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
    74176
    75177  // Get Distortion
     178#ifdef LGE_VSO_EARLY_SKIP_A0093
     179  RMDist getDistDepth  ( Int iViewPos,             Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel * piOrgData , Int iOrgStride);
     180#else
    76181  RMDist getDistDepth  ( Int iViewPos,             Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
     182#endif
    77183  RMDist getDistVideo  ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
    78184
    79   // Get Rendered Data
    80   Void   getSynthView( Int iViewPos, Pel**& rppiRenVideoPel, Pel*& rpiRenDepthPel, Int& riStride );
    81 
    82   // Get Reference Data
    83   Void   getRefView  ( TComPicYuv*& rpcPicYuvRefView, Pel**& rppiRefVideoPel, Int*& raiStrides );
     185  Void   getSynthVideo  ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset ); 
     186  Void   getSynthDepth  ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset  );
     187  Void   getRefVideo    ( Int iViewPos, TComPicYuv* pcPicYuv, UInt uiHorOffset  );
    84188
    85189private:
     
    90194  /////  Rendering /////
    91195  // Left to Right
    92   __inline RMDist xRenderL            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bSet);
    93   __inline Void   xInitRenderPartL    ( Int iEndChangePos, Int iLastSPos  );
    94   __inline Void   xRenderRangeL       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
    95   __inline Void   xRenderShiftedRangeL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
    96   __inline Void   xFillHoleL          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
    97   __inline Void   xExtrapolateMarginL ( Int iCurSPos,                Int iCurPos, RMDist& riError );
    98   __inline Int    xRangeLeftL         ( Int iPos );
    99   __inline Int    xRangeRightL        ( Int iPos );
    100   __inline Int    xRoundL             ( Int iPos );
     196#ifdef LGE_VSO_EARLY_SKIP_A0093
     197                      __inline Bool   xDetectEarlySkipL   ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData,Pel* piOrgData, Int iOrgStride );
     198                      __inline Bool   xDetectEarlySkipR   ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData,Pel* piOrgData, Int iOrgStride );
     199  template<Bool bSet> __inline RMDist xRenderL            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bFast );
     200  template<Bool bSet> __inline RMDist xRenderR            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bFast );
     201#else
     202  template<Bool bSet> __inline RMDist xRenderR            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
     203  template<Bool bSet> __inline RMDist xRenderL            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
     204#endif
     205                      __inline Void   xInitRenderPartL    ( Int iEndChangePos, Int iLastSPos  );
     206  template<Bool bSet> __inline Void   xRenderRangeL       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
     207  template<Bool bSet> __inline Void   xRenderShiftedRangeL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
     208  template<Bool bSet> __inline Void   xFillHoleL          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
     209  template<Bool bSet> __inline Void   xExtrapolateMarginL ( Int iCurSPos,                Int iCurPos, RMDist& riError );
     210                      __inline Int    xRangeLeftL         ( Int iPos );
     211                      __inline Int    xRangeRightL        ( Int iPos );
     212                      __inline Int    xRoundL             ( Int iPos );
    101213
    102214  // Right to Left
    103   __inline RMDist xRenderR            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bSet );
    104   __inline Void   xInitRenderPartR    ( Int iStartChangePos, Int iLastSPos );
    105   __inline Void   xRenderShiftedRangeR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
    106   __inline Void   xRenderRangeR       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
    107   __inline Void   xFillHoleR          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
    108   __inline Void   xExtrapolateMarginR ( Int iCurSPos,                Int iCurPos, RMDist& riError );
    109   __inline Int    xRangeLeftR         ( Int iPos );
    110   __inline Int    xRangeRightR        ( Int iPos );
    111   __inline Int    xRoundR             ( Int iPos );
     215                      __inline Void   xInitRenderPartR    ( Int iStartChangePos, Int iLastSPos );
     216  template<Bool bSet> __inline Void   xRenderShiftedRangeR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
     217  template<Bool bSet> __inline Void   xRenderRangeR       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
     218  template<Bool bSet> __inline Void   xFillHoleR          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
     219  template<Bool bSet> __inline Void   xExtrapolateMarginR ( Int iCurSPos,                Int iCurPos, RMDist& riError );
     220                      __inline Int    xRangeLeftR         ( Int iPos );
     221                      __inline Int    xRangeRightR        ( Int iPos );
     222                      __inline Int    xRoundR             ( Int iPos );
    112223
    113224  // Blending
    114   __inline Void   xSetShiftedPelBlend ( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );
     225  template<Bool bSet> __inline Void   xSetShiftedPelBlend ( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );
    115226
    116227#if HHI_VSO_COLOR_PLANES
     
    125236  __inline Pel    xBlend              ( Pel pVal1, Pel pVal2, Int iWeightVal2 );
    126237
    127 // General
    128   __inline Void   xSetShiftedPel     ( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );
     238  // General
     239  template<Bool bSet> __inline Void xSetShiftedPelL       (Int iSourcePos,                  Int iSubSourcePos, Int iTargetSPos,                   Pel iFilled, RMDist& riError );
     240  template<Bool bSet> __inline Void xSetShiftedPelBlendL  (RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError );
     241  template<Bool bSet> __inline Void xSetShiftedPelNoBlendL(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError );
     242
     243  template<Bool bSet> __inline Void xSetShiftedPelR       (Int iSourcePos,                  Int iSubSourcePos, Int iTargetSPos,                   Pel iFilled, RMDist& riError );
     244  template<Bool bSet> __inline Void xSetShiftedPelBlendR  (RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError );
     245  template<Bool bSet> __inline Void xSetShiftedPelNoBlendR(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError );
     246
    129247  __inline Int    xShiftNewData      ( Int iPos, Int iPosInNewData );
    130248  __inline Int    xShift             ( Int iPos );
     
    134252
    135253  // Utilities
    136   __inline Void   xInitView  ( Int iViewPos );
    137254  __inline Void   xSetPels   ( Pel*  piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal );
    138255  __inline Void   xSetBools  ( Bool* pbSource    , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal );
    139256  __inline Void   xSetInts   ( Int*  piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal );
     257
     258#if HHI_VSO_COLOR_PLANES
     259  Void            xGetSampleStrTextPtrs ( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY, Pel RenModelOutPels::*& rpiSrcU, Pel RenModelOutPels::*& rpiSrcV );
     260#else 
     261  Void            xGetSampleStrTextPtrs ( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY );
     262#endif
     263  Void            xGetSampleStrDepthPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcD );
     264       
     265  Void            xSetStructRefView            ();
     266  Void            xResetStructError            ();
     267  Void            xInitSampleStructs           ();
     268  Void            xSetStructSynthViewAsRefView ();
     269  Void            xCopy2PicYuv                ( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget, UInt uiHorOffset );
     270
     271
     272  template< typename S, typename T>
     273  Void   xCopyFromSampleStruct ( S* ptSource , Int iSourceStride, T S::* ptSourceElement, T* ptTarget, Int iTargetStride, Int iWidth, Int iHeight )
     274  {
     275    for (Int iPosY = 0; iPosY < m_iHeight; iPosY++)
     276    {
     277      for (Int iPosX = 0; iPosX < m_iWidth; iPosX++)
     278      {
     279        ptTarget[iPosX] = ptSource[iPosX].*ptSourceElement;
     280      }
     281      ptSource += iSourceStride;
     282      ptTarget += iTargetStride;
     283    }   
     284  } 
     285
     286  template< typename S, typename T>
     287  Void   xCopyToSampleStruct ( T* ptSource , Int iSourceStride, S* ptTarget, Int iTargetStride, T S::* ptSourceElement, Int iWidth, Int iHeight )
     288  {
     289    for (Int iPosY = 0; iPosY < m_iHeight; iPosY++)
     290    {
     291      for (Int iPosX = 0; iPosX < m_iWidth; iPosX++)
     292      {
     293        ptTarget[iPosX] = ptSource[iPosX].*ptSourceElement;
     294      }
     295      ptSource += iSourceStride;
     296      ptTarget += iTargetStride;
     297    }   
     298  }   
    140299
    141300private:
     
    151310  Int   m_iSampledStride;
    152311
     312  RenModelInPels* m_pcInputSamples[2];
     313  Int                  m_iInputSamplesStride;
     314
    153315  // Base
    154316  Pel** m_aapiBaseVideoPel     [2]; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane  0-> Y, 1->U, 2->V
     
    157319  Pel*  m_apiBaseDepthPel      [2]; // Dim1: ViewPosition
    158320  Int   m_aiBaseDepthStrides   [2]; // Dim1: ViewPosition
     321
    159322
    160323  // LUT
     
    170333  //// Reference Data  ////
    171334  TComPicYuv* m_pcPicYuvRef       ;    // Reference PIcYuv
     335
     336  //// Output Samples
     337  RenModelOutPels* m_pcOutputSamples;
     338  Int                   m_iOutputSamplesStride;
     339
    172340  Pel*  m_aapiRefVideoPel      [3];    // Dim1: Plane  0-> Y, 1->U, 2->V
    173341  Int   m_aiRefVideoStrides    [3];    // Dim1: Plane  0-> Y, 1->U, 2->V
    174 
    175   // Renderer State
    176   Int*  m_piError                 ;
    177   Pel*  m_apiFilled            [2];    // Dim1: ViewPosition
    178   Bool* m_apbOccluded          [2];    // Dim1: ViewPosition
    179   Pel*  m_aapiSynthVideoPel    [3][3]; // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged, Dim2: Plane  0-> Y, 1->U, 2->V
    180   Pel*  m_apiSynthDepthPel     [3];    // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged, Dim2: Plane  0-> Y, 1->U, 2->V
    181342
    182343  // Rendering State
     
    185346  Int   m_iLastOccludedSPosFP;         // Position of last topmost shifted position in FullPels
    186347
    187   Bool  m_bSet;                        // Set Data, or get Error
    188348  Int   m_iCurViewPos;                 // Current View Position 0: Left, 1: Right
    189349  Int   m_iOtherViewPos;               // Other View Position 0: Left, 1: Right
     
    201361  Int   m_iShiftPrec;
    202362  Int   m_iHoleMargin;
    203   Int   m_iBlendMode;
     363#ifdef LGE_VSO_EARLY_SKIP_A0093
     364  Bool  m_bEarlySkip;
     365#endif
    204366
    205367  // Derived settings
     
    209371
    210372  //// Current Pointers ////
    211   Pel*  m_aapiBaseVideoPelRow  [2][3]; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane  0-> Y, 1->U, 2->V
    212   Pel*  m_apiBaseDepthPelRow   [2];    // Dim1: ViewPosition
    213   Bool* m_apbOccludedRow       [2];    // Dim1: ViewPosition
    214   Pel*  m_apiFilledRow         [2];    // Dim1: ViewPosition
    215   Int*  m_apiErrorRow             ;
    216 
    217   Pel*  m_aapiRefVideoPelRow   [3];    // Dim1: Plane  0-> Y, 1->U, 2->V
    218   Pel*  m_aapiSynthVideoPelRow [3][3]; // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged, Dim2: Plane  0-> Y, 1->U, 2->V
    219   Pel*  m_apiSynthDepthPelRow  [3];    // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged
    220 
     373
     374  RenModelInPels*  m_pcInputSamplesRow [2];
     375  RenModelOutPels* m_pcOutputSamplesRow;
    221376
    222377  //// MISC ////
    223378  const Int m_iDistShift;                  // Shift in Distortion computation
     379
     380  //// Early Skip
     381#ifdef LGE_VSO_EARLY_SKIP_A0093
     382  Bool* m_pbHorSkip;
     383#endif
    224384};
    225385
  • trunk/source/Lib/TLibRenderer/TRenTop.cpp

    r81 r100  
    10131013          if ((iPrevShiftedPos + (iStep >> 1) ) > iPrevShiftedPosCeiled )
    10141014          {
    1015 #if HHI_FIX
    10161015            if ( !((iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth)))
    10171016            {
     
    10261025            iInterPolPos++;
    10271026          }         
    1028 #else
    1029           if ( (iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth))
    1030           {
    1031             // skip Interpolation if Interpolation position is outside frame
    1032             iPrevShiftedPos = iShiftedPos;
    1033             continue;
    1034           };
    1035 
    1036           for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)
    1037           {
    1038               apcOutputData[uiCurPlane][iInterPolPos]  = apcInputData[uiCurPlane][iPosX - iStep];
    1039           }
    1040           pcFilledData[iInterPolPos]  = REN_IS_FILLED;
    1041             iInterPolPos++;
    1042         }
    1043 #endif
    10441027
    10451028          // Fill Disocclusion
     
    10641047        {
    10651048          iInterPolPos = iShiftedPosFloor >> m_iRelShiftLUTPrec;
    1066 #if HHI_FIX
    10671049          if ( !((iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth)))
    10681050          {       
     
    10741056            pcFilledData[iInterPolPos]  = REN_IS_FILLED;
    10751057          }
    1076 #else
    1077           if ( (iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth))
    1078           {
    1079             // skip Interpolation if Interpolation position is outside frame
    1080             iPrevShiftedPos = iShiftedPos;
    1081             continue;
    1082           };
    1083 
    1084           for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)
    1085           {
    1086             apcOutputData[uiCurPlane][iInterPolPos]  = apcInputData[uiCurPlane][iPosX ];
    1087           }
    1088 
    1089           pcFilledData[iInterPolPos]  = REN_IS_FILLED;
    1090 #endif
    10911058        }
    10921059      }
     
    19591926          for( Int iCurPosX = 0; iCurPosX < 4; iCurPosX++)
    19601927          {
    1961             iSAD += abs( pcVideoLastDataBlk[iCurPosX] - pcVideoCurDataBlk[iCurPosX] );  //SAD
     1928            iSAD += abs( pcVideoLastDataBlk[iCurPosX] - pcVideoCurDataBlk[iCurPosX] );  //SAD
    19621929          }
    19631930          pcVideoLastDataBlk += iVideoLastStride;
Note: See TracChangeset for help on using the changeset viewer.