Changeset 1390 in 3DVCSoftware


Ignore:
Timestamp:
13 Nov 2015, 17:00:20 (11 years ago)
Author:
tech
Message:

Removed 3D.

Location:
branches/HTM-16.0-MV-draft-5
Files:
5 deleted
97 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-16.0-MV-draft-5/source/App/TAppDecoder/TAppDecCfg.cpp

    r1386 r1390  
    6666  Bool do_help = false;
    6767  string cfg_TargetDecLayerIdSetFile;
    68 #if NH_3D
    69   string cfg_ScaleOffsetFile;
    70 #endif
    7168  string outputColourSpaceConvert;
    7269  Int warnUnknowParameter = 0;
     
    8077  ("ReconFile,o",               m_reconFileName,                       string(""), "reconstructed YUV output file name\n"
    8178                                                                                   "YUV writing is skipped if omitted")
    82 #if NH_3D
    83   ("ScaleOffsetFile,p",         cfg_ScaleOffsetFile,                   string(""), "file with coded scales and offsets")
    84   ("Depth420OutputFlag",        m_depth420OutputFlag,                  true      , "Output depth layers in 4:2:0 ")
    85 #endif
    8679  ("WarnUnknowParameter,w",     warnUnknowParameter,                                  0, "warn for unknown configuration parameters instead of failing")
    8780  ("SkipFrames,s",              m_iSkipFrame,                          0,          "number of frames to skip before random access")
     
    148141  }
    149142
    150 #if NH_3D
    151   m_pchScaleOffsetFile = cfg_ScaleOffsetFile.empty() ? NULL : strdup(cfg_ScaleOffsetFile.c_str());
    152 #endif
    153143
    154144  if (m_bitstreamFileName.empty())
  • branches/HTM-16.0-MV-draft-5/source/App/TAppDecoder/TAppDecCfg.h

    r1386 r1390  
    9696  Bool          m_printPicOutput;                     ///< Print information on picture output
    9797  Bool          m_printReceivedNalus;                 ///< Print information on received NAL units
    98 #if NH_3D
    99   TChar*        m_pchScaleOffsetFile;                   ///< output coded scale and offset parameters
    100   Bool          m_depth420OutputFlag;                   ///< output depth layers in 4:2:0
    101 #endif
    10298
    10399  Void xAppendToFileNameEnd( const TChar* pchInputFileName, const TChar* pchStringToAppend, TChar*& rpchOutputFileName); ///< create filenames
     
    132128      m_outputBitDepth[channelTypeIndex] = 0;
    133129    }
    134 #if NH_3D
    135     m_pchScaleOffsetFile = NULL;
    136 #endif
    137130  }
    138131
  • branches/HTM-16.0-MV-draft-5/source/App/TAppDecoder/TAppDecTop.cpp

    r1386 r1390  
    9494  m_cvsStartFound                   = false;
    9595#endif
    96 #if NH_3D
    97     m_pScaleOffsetFile              = 0;
    98 #endif
    9996}
    10097
     
    131128#endif
    132129  m_reconFileName.clear();
    133 #if NH_3D
    134   if (m_pchScaleOffsetFile)
    135   {
    136     free (m_pchScaleOffsetFile);
    137     m_pchScaleOffsetFile = NULL;
    138   }
    139 #endif
    140130}
    141131
     
    405395  // initialize global variables
    406396  initROM();
    407 #if NH_3D_DMM
    408   initWedgeLists();
    409 #endif
    410397#else
    411398  // create decoder class
     
    453440    m_pcSeiColourRemappingInfoPrevious = NULL;
    454441  }
    455 #if NH_3D
    456   m_cCamParsCollector.uninit();
    457   if( m_pScaleOffsetFile )
    458   {
    459     ::fclose( m_pScaleOffsetFile );
    460   }
    461 #endif
    462442}
    463443
     
    465445{
    466446
    467 #if NH_3D
    468   m_cCamParsCollector.setCodeScaleOffsetFile( m_pScaleOffsetFile );
    469 #endif
    470447#if NH_MV
    471448  m_dpb.setPrintPicOutput(m_printPicOutput);
     
    10591036    xFinalizeAU ( );
    10601037
    1061 #if NH_3D
    1062   if( m_cCamParsCollector.isInitialized() )
    1063   {
    1064     m_cCamParsCollector.setSlice( 0 );
    1065   }
    1066 #endif
    10671038   xFlushOutput();
    10681039   m_dpb.emptyAllSubDpbs();
     
    10921063    m_newVpsActivatedbyCurAu  = true; //TBD
    10931064    m_newVpsActivatedbyCurPic = true;
    1094 #if NH_3D_VSO
    1095     m_dpb.setVPS( m_vps );
    1096 #endif
    10971065  }
    10981066
     
    12161184Void TAppDecTop::xFinalizeAU()
    12171185{
    1218 #if NH_3D
    1219   if ( !m_curAu.empty())
    1220   {
    1221     for (TComList<TComPic*>::iterator it = m_curAu.begin(); it != m_curAu.end(); it++)
    1222     {
    1223       TComPic* pic = (*it);
    1224       if ( !pic->getHasGeneratedRefPics() )
    1225       {
    1226         pic->compressMotion(1);
    1227       }
    1228     }
    1229   }
    1230 #endif
    12311186}
    12321187
     
    26882643      m_tDecTop[ decIdx ]->setDecodedSEIMessageOutputStream(&os);
    26892644    }
    2690 #if NH_3D
    2691    m_tDecTop[ decIdx ]->setCamParsCollector( &m_cCamParsCollector );
    2692 #endif
    26932645
    26942646    // append pic list of new decoder to PicLists
     
    29122864  }
    29132865
    2914 #if NH_3D
    2915   if( m_pchScaleOffsetFile )
    2916   {
    2917     m_pScaleOffsetFile = ::fopen( m_pchScaleOffsetFile, "wt" );
    2918     if (!m_pScaleOffsetFile)
    2919     {
    2920       fprintf(stderr, "\nUnable to open file `%s' for writing decoded Camera Parameters messages\n", m_pchScaleOffsetFile);
    2921       exit(EXIT_FAILURE);
    2922     }
    2923   }
    2924 #endif
    29252866}
    29262867
     
    30112952      conf.getWindowTopOffset()    + defDisp.getWindowTopOffset(),
    30122953      conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(),
    3013 #if NH_3D
    3014       m_depth420OutputFlag && curPic->getIsDepth() ? CHROMA_420 : NUM_CHROMA_FORMAT
    3015 #else
    30162954      NUM_CHROMA_FORMAT
    3017 #endif
    30182955      , m_bClipOutputVideoToRec709Range);
    30192956  }
  • branches/HTM-16.0-MV-draft-5/source/App/TAppDecoder/TAppDecTop.h

    r1386 r1390  
    117117
    118118  Bool                            m_reconOpen           [ MAX_NUM_LAYERS ]; ///< reconstruction file opened
    119 #if NH_3D
    120   FILE*                           m_pScaleOffsetFile;
    121   CamParsCollector                m_cCamParsCollector;
    122 #endif
    123119#else
    124120  TDecTop                         m_cTDecTop;                     ///< decoder class
  • branches/HTM-16.0-MV-draft-5/source/App/TAppEncoder/TAppEncCfg.cpp

    r1386 r1390  
    7373#if NH_MV
    7474  MULTIVIEWMAIN = 6,
    75 #if NH_3D
    76   MAIN3D = 8,
    77 #endif
    7875#endif
    7976  MONOCHROME_8      = 1008,
     
    120117  m_targetPivotValue = NULL;
    121118
    122 #if KWU_RC_MADPRED_E0227
    123   m_depthMADPred = 0;
    124 #endif
    125119}
    126120
     
    181175  {
    182176    free ( m_pchBaseViewCameraNumbers );
    183   }
    184 #endif
    185 #if NH_3D_VSO
    186   if (  m_pchVSOConfig != NULL)
    187   {
    188     free (  m_pchVSOConfig );
    189   }
    190  
    191   if ( m_pchCameraParameterFile != NULL )
    192   {
    193     free ( m_pchCameraParameterFile );
    194177  }
    195178#endif
     
    276259  }
    277260#endif
    278 #if NH_3D
    279   in>>entry.m_interCompPredFlag;
    280 #endif
    281261
    282262  return in;
     
    312292#if NH_MV
    313293  ,{"multiview-main"     , Profile::MULTIVIEWMAIN      },
    314 #if NH_3D
    315    {"3d-main"            , Profile::MAIN3D             }
    316 #endif
    317294#endif
    318295
     
    341318#if NH_MV
    342319    {"multiview-main"     , MULTIVIEWMAIN   },
    343 #if NH_3D
    344     {"3d-main"            , MAIN3D          },
    345 #endif
    346320#endif
    347321    {"monochrome",         MONOCHROME_8     },
     
    726700  string        cfg_levels;
    727701  string        cfg_tiers;
    728 #if NH_3D
    729   cfg_dimensionLength.push_back( 2  );  // depth
    730   cfg_dimensionLength.push_back( 32 );  // texture
    731 #else
    732702  cfg_dimensionLength.push_back( 64 );
    733 #endif
    734703#endif
    735704
     
    807776#if NH_MV
    808777  ("NumberOfLayers",                 m_numberOfLayers     , 1,                     "Number of layers")
    809 #if !NH_3D                           
    810778  ("ScalabilityMask",                m_scalabilityMask    , 2                    , "Scalability Mask: 2: Multiview, 8: Auxiliary, 10: Multiview + Auxiliary")   
    811 #else                               
    812   ("ScalabilityMask",                m_scalabilityMask    , 3                    , "Scalability Mask, 1: Texture 3: Texture + Depth ")   
    813 #endif 
    814779  ("DimensionIdLen",                 m_dimensionIdLen     , cfg_dimensionLength  , "Number of bits used to store dimensions Id")
    815780  ("ViewOrderIndex",                 m_viewOrderIndex              , IntAry1d(1,0),                                 "View Order Index per layer")
    816781  ("ViewId",                         m_viewId                      , IntAry1d(1,0),                                 "View Id per View Order Index")
    817782  ("AuxId",                          m_auxId                       , IntAry1d(1,0),                                 "AuxId per layer")
    818 #if NH_3D_VSO
    819   ("DepthFlag",                      m_depthFlag                   , IntAry1d(1,0),                                 "Depth Flag")
    820 #endif
    821783  ("TargetEncLayerIdList",           m_targetEncLayerIdList        , IntAry1d(0,0),                                 "LayerIds in Nuh to be encoded") 
    822784  ("LayerIdInNuh",                   m_layerIdInNuh                , IntAry1d(1,0),                                 "LayerId in Nuh") 
     
    10951057#endif
    10961058
    1097 #if KWU_RC_VIEWRC_E0227
    1098   ("ViewWiseTargetBits, -vtbr" ,  m_viewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
    1099   ("TargetBitAssign, -ta", m_viewWiseRateCtrl, false, "View-wise rate control on/off")
    1100 #endif
    1101 #if KWU_RC_MADPRED_E0227
    1102   ("DepthMADPred, -dm", m_depthMADPred, (UInt)0, "Depth based MAD prediction on/off")
    1103 #endif
    11041059#if NH_MV
    11051060// A lot of this stuff could should actually be derived by the encoder.
     
    12821237  ("BaseViewCameraNumbers",                           m_pchBaseViewCameraNumbers,   (TChar *) 0                 , "Numbers of base views")
    12831238#endif
    1284 #if NH_3D
    1285   ("Depth420OutputFlag",                              m_depth420OutputFlag,           true                     , "Output depth layers in 4:2:0 ")
    1286 #endif
    1287 #if NH_3D_VSO 
    1288   ("CameraParameterFile,cpf",                         m_pchCameraParameterFile,    (TChar *) 0                 , "Camera Parameter File Name")
    1289   ("CodedCamParsPrecision",                           m_iCodedCamParPrecision,      STD_CAM_PARAMETERS_PRECISION, "precision for coding of camera parameters (in units of 2^(-x) luma samples)" )
    1290 
    1291   /* View Synthesis Optimization */
    1292   ("VSOConfig",                                       m_pchVSOConfig            , (TChar *) 0                   ,"VSO configuration")
    1293   ("VSO",                                             m_bUseVSO                 , false                         ,"Use VSO" )   
    1294   ("VSOMode",                                         m_uiVSOMode               , (UInt)   4                    ,"VSO Mode")
    1295   ("LambdaScaleVSO",                                  m_dLambdaScaleVSO         , (Double) 1                    ,"Lambda Scaling for VSO")
    1296   ("VSOLSTable",                                      m_bVSOLSTable             , true                          ,"Depth QP dependent video/depth rate allocation by Lagrange multiplier" )     
    1297   ("ForceLambdaScaleVSO",                             m_bForceLambdaScaleVSO    , false                         ,"Force using Lambda Scale VSO also in non-VSO-Mode")
    1298   ("AllowNegDist",                                    m_bAllowNegDist           , true                          ,"Allow negative Distortion in VSO")
    1299                                                                                                              
    1300   ("UseEstimatedVSD",                                 m_bUseEstimatedVSD        , true                          ,"Model based VSD estimation instead of rendering based for some encoder decisions" )     
    1301   ("VSOEarlySkip",                                    m_bVSOEarlySkip           , true                          ,"Early skip of VSO computation if synthesis error assumed to be zero" )     
    1302                                                                                                                
    1303   ("WVSO",                                            m_bUseWVSO                , true                          ,"Use depth fidelity term for VSO" )
    1304   ("VSOWeight",                                       m_iVSOWeight              , 10                            ,"Synthesized View Distortion Change weight" )
    1305   ("VSDWeight",                                       m_iVSDWeight              , 1                             ,"View Synthesis Distortion estimate weight" )
    1306   ("DWeight",                                         m_iDWeight                , 1                             ,"Depth Distortion weight" )
    1307 #endif //HHI_VSO
    13081239/* 3D- HEVC Tools */                                                           
    1309 #if NH_3D_QTL
    1310   ("QTL"                   ,                          m_bUseQTL                 , true                          , "Use depth quad tree limitation (encoder only)" )
    1311 #endif
    1312 #if NH_3D
    1313 
    1314   ("IvMvPredFlag"          ,                          m_ivMvPredFlag            , BoolAry1d(2,true)             , "Inter-view motion prediction"              )
    1315   ("IvMvScalingFlag"       ,                          m_ivMvScalingFlag         , BoolAry1d(2,true)             , "Inter-view motion vector scaling"          )
    1316   ("Log2SubPbSizeMinus3"   ,                          m_log2SubPbSizeMinus3     , 0                             , "Log2 minus 3 of sub Pb size"               )
    1317   ("IvResPredFlag"         ,                          m_ivResPredFlag           , true                          , "Inter-view residual prediction"            )
    1318   ("DepthRefinementFlag"   ,                          m_depthRefinementFlag     , true                          , "Depth to refine disparity"                 )
    1319   ("ViewSynthesisPredFlag" ,                          m_viewSynthesisPredFlag   , true                          , "View synthesis prediction"                 )
    1320   ("DepthBasedBlkPartFlag" ,                          m_depthBasedBlkPartFlag   , true                          , "Depth base block partitioning"             )
    1321   ("MpiFlag"               ,                          m_mpiFlag                 , true                          , "Motion inheritance from texture to depth"  )
    1322   ("Log2MpiSubPbSizeMinus3",                          m_log2MpiSubPbSizeMinus3  , 0                             , "Log2 minus 3 of sub Pb size for MPI"       )
    1323   ("IntraContourFlag"      ,                          m_intraContourFlag        , true                          , "Intra contour mode"                        )
    1324   ("IntraWedgeFlag"        ,                          m_intraWedgeFlag          , true                          , "Intra wedge mode and segmental depth DCs"  )
    1325   ("IntraSdcFlag"          ,                          m_intraSdcFlag            , true                          , "Intra depth DCs"                           )
    1326   ("QtPredFlag"            ,                          m_qtPredFlag              , true                          , "Quad tree prediction from texture to depth")
    1327   ("InterSdcFlag"          ,                          m_interSdcFlag            , true                          , "Inter depth DCs"                           )
    1328   ("DepthIntraSkip"        ,                          m_depthIntraSkipFlag      , true                          , "Depth intra skip mode"                     )
    1329   ("DLT"                   ,                          m_useDLT                  , true                          , "Depth lookup table"                        )
    1330   ("IlluCompEnable"        ,                          m_abUseIC                 , true                          , "Enable illumination compensation"          )
    1331   ("IlluCompLowLatencyEnc" ,                          m_bUseLowLatencyICEnc     , false                         , "Enable low-latency illumination compensation encoding")
    1332 #endif //NH_3D
    13331240   
    13341241  ;
     
    15361443  if( cfg_profiles.empty() )
    15371444  {
    1538 #if NH_3D
    1539     cfg_profiles = string("main main 3d-main");
    1540 #else
    15411445    cfg_profiles = string("main main multiview-main");   
    1542 #endif
    15431446    fprintf(stderr, "\nWarning: No profiles given, using defaults: %s", cfg_profiles.c_str() );
    15441447    anyEmpty = true;
     
    18071710  xResizeVector( m_auxId );
    18081711
    1809 #if NH_3D_VSO
    1810   xResizeVector( m_depthFlag );
    1811 #endif
    18121712  xResizeVector( m_fQP );
    18131713
     
    20171917
    20181918
    2019 #if NH_3D_VSO
    2020   // Table base optimization
    2021   // Q&D
    2022   Double adLambdaScaleTable[] =
    2023   {  0.031250, 0.031639, 0.032029, 0.032418, 0.032808, 0.033197, 0.033586, 0.033976, 0.034365, 0.034755,
    2024   0.035144, 0.035533, 0.035923, 0.036312, 0.036702, 0.037091, 0.037480, 0.037870, 0.038259, 0.038648,
    2025   0.039038, 0.039427, 0.039817, 0.040206, 0.040595, 0.040985, 0.041374, 0.041764, 0.042153, 0.042542,
    2026   0.042932, 0.043321, 0.043711, 0.044100, 0.044194, 0.053033, 0.061872, 0.070711, 0.079550, 0.088388,
    2027   0.117851, 0.147314, 0.176777, 0.235702, 0.294628, 0.353553, 0.471405, 0.589256, 0.707107, 0.707100,
    2028   0.753550, 0.800000 
    2029   };
    2030   if ( m_bUseVSO && m_bVSOLSTable )
    2031   {
    2032     Int firstDepthLayer = -1;
    2033     for (Int layer = 0; layer < m_numberOfLayers; layer++ )
    2034     {
    2035       if ( m_depthFlag[ layer ]  || m_auxId[ layer ] == 2 )
    2036       {
    2037         firstDepthLayer = layer;
    2038         break;
    2039       }
    2040     }
    2041     AOT( firstDepthLayer == -1 );
    2042     AOT( (m_iQP[firstDepthLayer] < 0) || (m_iQP[firstDepthLayer] > 51));
    2043     m_dLambdaScaleVSO *= adLambdaScaleTable[m_iQP[firstDepthLayer]];
    2044   }
    2045   if ( m_bUseVSO && m_uiVSOMode == 4)
    2046   {
    2047     m_cRenModStrParser.setString( m_iNumberOfViews, m_pchVSOConfig );
    2048     m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ),
    2049       m_internalBitDepth[ CHANNEL_TYPE_LUMA],
    2050       (UInt)m_iCodedCamParPrecision,
    2051       m_FrameSkip,
    2052       (UInt)m_framesToBeEncoded,
    2053       m_pchCameraParameterFile,
    2054       m_pchBaseViewCameraNumbers,
    2055       NULL,
    2056       m_cRenModStrParser.getSynthViews(),
    2057       LOG2_DISP_PREC_LUT );
    2058   }
    2059   else if ( m_bUseVSO && m_uiVSOMode != 4 )
    2060   {
    2061     m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ),
    2062       m_internalBitDepth[ CHANNEL_TYPE_LUMA],
    2063       (UInt)m_iCodedCamParPrecision,
    2064       m_FrameSkip,
    2065       (UInt)m_framesToBeEncoded,
    2066       m_pchCameraParameterFile,
    2067       m_pchBaseViewCameraNumbers,
    2068       m_pchVSOConfig,
    2069       NULL,
    2070       LOG2_DISP_PREC_LUT );
    2071   }
    2072 #if NH_3D
    2073   else
    2074   {
    2075     m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ),
    2076       m_internalBitDepth[ CHANNEL_TYPE_LUMA],
    2077       (UInt) m_iCodedCamParPrecision,
    2078       m_FrameSkip,
    2079       (UInt) m_framesToBeEncoded,
    2080       m_pchCameraParameterFile,
    2081       m_pchBaseViewCameraNumbers,
    2082       NULL,
    2083       NULL,
    2084       LOG2_DISP_PREC_LUT );
    2085   }
    2086   m_cCameraData.check( false, true );
    2087 #endif
    2088 #endif
    20891919
    20901920  // check validity of input parameters
     
    22642094  xConfirmPara( (m_layerIdInNuh.size()!=1) && (m_layerIdInNuh.size() < m_numberOfLayers) , "LayerIdInNuh must be given for all layers. ");
    22652095
    2266 #if NH_3D
    2267   xConfirmPara( m_scalabilityMask != 2 && m_scalabilityMask != 3, "Scalability Mask must be equal to 2 or 3. ");
    2268 #else
    22692096  xConfirmPara( m_scalabilityMask != 2 && m_scalabilityMask != 8 && m_scalabilityMask != 10, "Scalability Mask must be equal to 2, 8 or 10");
    2270 #endif
    2271 
    2272 #if NH_3D_VSO
    2273   if ( m_scalabilityMask & ( 1 << DEPTH_ID ) )
    2274   {
    2275     m_dimIds.push_back( m_depthFlag );
    2276   }
    2277 #endif
     2097
    22782098
    22792099  m_dimIds.push_back( m_viewOrderIndex );   
     
    23422162      xConfirmPara( allEqual , "Each layer shall have a different position in scalability space." );
    23432163
    2344 #if !H_3D_FCO
    23452164      if ( numDiff  == 1 )
    23462165      {
     
    23532172        xConfirmPara( shallBeButIsNotIncreasing,  "DimensionIds shall be increasing within one dimension. " );
    23542173      }
    2355 #endif
    23562174    }
    23572175  }
     
    25602378  xConfirmPara(  m_maxNumMergeCand < 1,  "MaxNumMergeCand must be 1 or greater.");
    25612379  xConfirmPara(  m_maxNumMergeCand > 5,  "MaxNumMergeCand must be 5 or smaller.");
    2562 #if NH_3D
    2563   xConfirmPara( m_log2SubPbSizeMinus3 < 0,                                        "Log2SubPbSizeMinus3 must be equal to 0 or greater.");
    2564   xConfirmPara( m_log2SubPbSizeMinus3 > 3,                                        "Log2SubPbSizeMinus3 must be equal to 3 or smaller.");
    2565   xConfirmPara( (1<< ( m_log2SubPbSizeMinus3 + 3) ) > m_uiMaxCUWidth,              "Log2SubPbSizeMinus3 must be  equal to log2(maxCUSize)-3 or smaller.");
    2566  
    2567   xConfirmPara( m_log2MpiSubPbSizeMinus3 < 0,                                        "Log2MpiSubPbSizeMinus3 must be equal to 0 or greater.");
    2568   xConfirmPara( m_log2MpiSubPbSizeMinus3 > 3,                                        "Log2MpiSubPbSizeMinus3 must be equal to 3 or smaller.");
    2569   xConfirmPara( (1<< (m_log2MpiSubPbSizeMinus3 + 3)) > m_uiMaxCUWidth,               "Log2MpiSubPbSizeMinus3 must be equal to log2(maxCUSize)-3 or smaller.");
    2570 #endif
    25712380#if ADAPTIVE_QP_SELECTION
    25722381#if NH_MV
     
    26292438  }
    26302439
    2631 #if NH_3D_VSO
    2632   xConfirmPara( m_pchCameraParameterFile    == 0                ,   "CameraParameterFile must be given");
    2633   xConfirmPara( m_pchBaseViewCameraNumbers  == 0                ,   "BaseViewCameraNumbers must be given" );
    2634   xConfirmPara( m_iNumberOfViews != m_cCameraData.getBaseViewNumbers().size() ,   "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" );
    2635   xConfirmPara    ( m_iCodedCamParPrecision < 0 || m_iCodedCamParPrecision > 5,       "CodedCamParsPrecision must be in range of 0..5" );
    2636     if( m_bUseVSO )
    2637     {
    2638       xConfirmPara(   m_pchVSOConfig            == 0                             ,   "VSO Setup string must be given");
    2639       xConfirmPara( m_uiVSOMode > 4 ,                                                "VSO Mode must be less than 5");
    2640     }
    2641 #endif
    26422440  // max CU width and height should be power of 2
    26432441  UInt ui = m_uiMaxCUWidth;
     
    33933191  xPrintParaVector( "AuxId", m_auxId );
    33943192#endif
    3395 #if NH_3D_VSO
    3396   xPrintParaVector( "DepthLayerFlag", m_depthFlag );
    3397   printf("Coded Camera Param. Precision     : %d\n", m_iCodedCamParPrecision); 
    3398 #endif
    33993193#if NH_MV 
    34003194  xPrintParaVector( "QP"               , m_fQP                );
     
    35733367#endif
    35743368
    3575 #if KWU_RC_MADPRED_E0227
    3576     printf("Depth based MAD prediction   : %d\n", m_depthMADPred);
    3577 #endif
    3578 #if KWU_RC_VIEWRC_E0227
    3579     printf("View-wise Rate control       : %d\n", m_viewWiseRateCtrl);
    3580     if(m_viewWiseRateCtrl)
    3581     {
    3582 
    3583       printf("ViewWiseTargetBits           : ");
    3584       for (Int i = 0 ; i < m_iNumberOfViews ; i++)
    3585         printf("%d ", m_viewTargetBits[i]);
    3586       printf("\n");
    3587     }
    3588     else
    3589     {
    3590       printf("TargetBitrate                : %d\n", m_RCTargetBitrate );
    3591     }
    3592 #endif
    35933369
    35943370  }
    35953371
    35963372  printf("Max Num Merge Candidates          : %d\n", m_maxNumMergeCand);
    3597 #if NH_3D_VSO
    3598   printf("BaseViewCameraNumbers             : %s\n", m_pchBaseViewCameraNumbers );
    3599   printf("Coded Camera Param. Precision     : %d\n", m_iCodedCamParPrecision);
    3600   printf("Force use of Lambda Scale         : %d\n", m_bForceLambdaScaleVSO );
    3601 
    3602   if ( m_bUseVSO )
    3603   {   
    3604     printf("VSO Lambda Scale                  : %5.2f\n", m_dLambdaScaleVSO );
    3605     printf("VSO Mode                          : %d\n",    m_uiVSOMode       );
    3606     printf("VSO Config                        : %s\n",    m_pchVSOConfig    );
    3607     printf("VSO Negative Distortion           : %d\n",    m_bAllowNegDist ? 1 : 0);
    3608     printf("VSO LS Table                      : %d\n",    m_bVSOLSTable ? 1 : 0);
    3609     printf("VSO Estimated VSD                 : %d\n",    m_bUseEstimatedVSD ? 1 : 0);
    3610     printf("VSO Early Skip                    : %d\n",    m_bVSOEarlySkip ? 1 : 0);   
    3611     if ( m_bUseWVSO )
    3612     {
    3613       printf("Dist. Weights (VSO/VSD/SAD)       : %d/%d/%d\n ", m_iVSOWeight, m_iVSDWeight, m_iDWeight );   
    3614     }   
    3615   }
    3616 #endif //HHI_VSO
    36173373  printf("\n");
    36183374#if NH_MV
     
    36773433  printf(" SignBitHidingFlag:%d ", m_signHideFlag);
    36783434  printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
    3679 #if NH_3D_VSO
    3680   printf(" VSO:%d ", m_bUseVSO   );
    3681   printf("WVSO:%d ", m_bUseWVSO ); 
    3682 #endif
    3683 #if NH_3D_QTL
    3684   printf( "QTL:%d "                  , m_bUseQTL);
    3685 #endif
    3686 #if NH_3D
    3687   printf( "IlluCompEnable:%d "       , m_abUseIC);
    3688   printf( "IlluCompLowLatencyEnc:%d ",  m_bUseLowLatencyICEnc);
    3689   printf( "DLT:%d ", m_useDLT );
    3690 
    3691 
    3692   printf( "IvMvPred:%d %d "            , m_ivMvPredFlag[0] ? 1 : 0, m_ivMvPredFlag[1]  ? 1 : 0);
    3693   printf( "IvMvScaling:%d %d "         , m_ivMvScalingFlag[0] ? 1 : 0 , m_ivMvScalingFlag[1]  ? 1 : 0);
    3694 
    3695   printf( "Log2SubPbSizeMinus3:%d "    , m_log2SubPbSizeMinus3            );
    3696   printf( "IvResPred:%d "              , m_ivResPredFlag          ? 1 : 0 );
    3697   printf( "DepthRefinement:%d "        , m_depthRefinementFlag    ? 1 : 0 );
    3698   printf( "ViewSynthesisPred:%d "      , m_viewSynthesisPredFlag  ? 1 : 0 );
    3699   printf( "DepthBasedBlkPart:%d "      , m_depthBasedBlkPartFlag  ? 1 : 0 );
    3700   printf( "Mpi:%d "                    , m_mpiFlag                ? 1 : 0 );
    3701   printf( "Log2MpiSubPbSizeMinus3:%d " , m_log2MpiSubPbSizeMinus3         );
    3702   printf( "IntraContour:%d "           , m_intraContourFlag       ? 1 : 0 );
    3703   printf( "IntraWedge:%d "             , m_intraWedgeFlag         ? 1 : 0 );
    3704   printf( "IntraSdc:%d "               , m_intraSdcFlag           ? 1 : 0 );
    3705   printf( "QtPred:%d "                 , m_qtPredFlag             ? 1 : 0 );
    3706   printf( "InterSdc:%d "               , m_interSdcFlag           ? 1 : 0 );
    3707   printf( "DepthIntraSkip:%d "         , m_depthIntraSkipFlag     ? 1 : 0 );
    3708 #endif
    37093435
    37103436  printf("\n\n");
  • branches/HTM-16.0-MV-draft-5/source/App/TAppEncoder/TAppEncCfg.h

    r1386 r1390  
    4444#include <sstream>
    4545#include <vector>
    46 #if NH_3D
    47 #include "TAppCommon/TAppComCamPara.h"
    48 #include "TLibRenderer/TRenModel.h"
    49 #include "TLibRenderer/TRenModSetupStrParser.h"
    50 #endif
    5146//! \ingroup TAppEncoder
    5247//! \{
     
    8075  IntAry1d               m_viewOrderIndex;                    ///< view order index 
    8176  IntAry1d               m_auxId;                             ///< auxiliary id
    82 #if NH_3D_VSO
    83   IntAry1d               m_depthFlag;                         ///< depth flag
    84 #endif
    8577  IntAry1d               m_targetEncLayerIdList;              ///< layer Ids in Nuh to be encoded
    8678  IntAry1d               m_layerIdInNuh;                      ///< layer Id in Nuh for each layer
     
    131123  Bool      m_singleLayerForNonIrapFlag;
    132124  Bool      m_higherLayerIrapSkipFlag;
    133 #if NH_3D
    134   Bool      m_abUseIC;
    135   Bool      m_bUseLowLatencyICEnc;
    136 #endif
    137125#endif
    138126  // Lambda modifiers
     
    464452#endif
    465453
    466 #if KWU_RC_VIEWRC_E0227
    467   vector<Int>     m_viewTargetBits;
    468   Bool      m_viewWiseRateCtrl;                              ///< Flag for using view-wise rate control
    469 #endif
    470 #if KWU_RC_MADPRED_E0227
    471   UInt       m_depthMADPred;
    472 #endif
    473454
    474455  ScalingListMode m_useScalingListId;                         ///< using quantization matrix
     
    527508#endif
    528509
    529 #if NH_3D
    530   // Output Format
    531   Bool      m_depth420OutputFlag;                             ///< Output depth layers in 4:2:0 format
    532 #endif
    533510    // Camera parameters
    534 #if NH_3D_VSO
    535   TChar*    m_pchCameraParameterFile;                         ///< camera parameter file
    536   TAppComCamPara m_cCameraData;
    537   Int       m_iCodedCamParPrecision;                          ///< precision for coding of camera parameters
    538   TChar*    m_pchVSOConfig;
    539   Bool      m_bUseVSO;                                        ///< flag for using View Synthesis Optimization
    540   Bool      m_bVSOLSTable;                                    ///< Depth QP dependent Lagrange parameter optimization (m23714)
    541   Bool      m_bVSOEarlySkip;                                  ///< Early skip of VSO computation (JCT3V-A0093 modification 4)
    542                                                              
    543   //// Used for development by GT, might be removed later     
    544   Double    m_dLambdaScaleVSO;                                ///< Scaling factor for Lambda in VSO mode
    545   Bool      m_bForceLambdaScaleVSO;                           ///< Use Lambda Scale for depth even if VSO is turned off
    546   Bool      m_bAllowNegDist;                                  ///< Allow negative distortion in VSO
    547   UInt      m_uiVSOMode;                                      ///< Number of VSO Mode, 1 = , 2 = simple, org vs. ren, 3 = simple, ren vs. ren, 4 = full 
    548                                                              
    549   // SAIT_VSO_EST_A0033                                       
    550   Bool      m_bUseEstimatedVSD;                               ///< Flag for using model based VSD estimation instead of VSO for some encoder decisions (JCT3V-A0033 modification 3) 
    551                                                              
    552   // LGE_WVSO_A0119                                           
    553   Bool      m_bUseWVSO;                                       ///< flag for using View Synthesis Optimization 
    554   Int       m_iVSOWeight;
    555   Int       m_iVSDWeight;
    556   Int       m_iDWeight;
    557 
    558   // Ren Model String
    559   TRenModSetupStrParser       m_cRenModStrParser;
    560 #endif
    561 #if NH_3D
    562   Bool       m_useDLT;                                        ///< flag for using DLT
    563 #endif
    564 #if NH_3D_QTL
    565   Bool       m_bUseQTL;                                        ///< flag for using depth QuadTree Limitation
    566 #endif
    567 #if NH_3D
    568   BoolAry1d  m_ivMvPredFlag;
    569   BoolAry1d  m_ivMvScalingFlag;
    570   Int        m_log2SubPbSizeMinus3;
    571   Bool       m_ivResPredFlag;
    572   Bool       m_depthRefinementFlag;
    573   Bool       m_viewSynthesisPredFlag;
    574   Bool       m_depthBasedBlkPartFlag;
    575   Bool       m_mpiFlag;
    576   Int        m_log2MpiSubPbSizeMinus3;
    577   Bool       m_intraContourFlag;
    578   Bool       m_intraWedgeFlag;
    579   Bool       m_intraSdcFlag;
    580   Bool       m_qtPredFlag;
    581   Bool       m_interSdcFlag;
    582   Bool       m_depthIntraSkipFlag;
    583 #endif
    584511  // internal member functions
    585512  Void  xCheckParameter ();                                   ///< check validity of configuration values
  • branches/HTM-16.0-MV-draft-5/source/App/TAppEncoder/TAppEncTop.cpp

    r1386 r1390  
    8787#endif
    8888 
    89 #if NH_3D
    90   vps.createCamPars(m_iNumberOfViews); 
    91 #endif
    92 
    93 #if NH_3D_DLT
    94   TComDLT dlt = TComDLT();
    95 #endif
     89
    9690
    9791#if NH_MV
     
    145139  xSetDpbSize              ( vps );
    146140  xSetVPSVUI               ( vps );
    147 #if NH_3D
    148   xSetCamPara              ( vps );
    149 #endif
    150 #if NH_3D_VSO
    151   m_ivPicLists.setVPS      ( &vps );
    152 #endif
    153 #if NH_3D_DLT
    154   xDeriveDltArray          ( vps, &dlt );
    155 #endif
    156141  if ( m_targetEncLayerIdList.size() == 0 )
    157142  {
     
    184169  }
    185170
    186 #if NH_3D
    187   // Set 3d tool parameters
    188   for (Int d = 0; d < 2; d++)
    189   { 
    190     m_sps3dExtension.setIvDiMcEnabledFlag          ( d, m_ivMvPredFlag[d]       );
    191     m_sps3dExtension.setIvMvScalEnabledFlag       ( d, m_ivMvScalingFlag[d]    );
    192     if (d == 0 )
    193     {   
    194       m_sps3dExtension.setLog2IvmcSubPbSizeMinus3   ( d, m_log2SubPbSizeMinus3   );
    195       m_sps3dExtension.setIvResPredEnabledFlag         ( d, m_ivResPredFlag         );
    196       m_sps3dExtension.setDepthRefEnabledFlag   ( d, m_depthRefinementFlag   );
    197       m_sps3dExtension.setVspMcEnabledFlag ( d, m_viewSynthesisPredFlag );
    198       m_sps3dExtension.setDbbpEnabledFlag ( d, m_depthBasedBlkPartFlag );
    199     }
    200     else
    201     {   
    202       m_sps3dExtension.setTexMcEnabledFlag               ( d, m_mpiFlag               );
    203       m_sps3dExtension.setLog2TexmcSubPbSizeMinus3( d, m_log2MpiSubPbSizeMinus3);
    204       m_sps3dExtension.setIntraContourEnabledFlag      ( d, m_intraContourFlag      );
    205       m_sps3dExtension.setIntraDcOnlyWedgeEnabledFlag     ( d, m_intraSdcFlag || m_intraWedgeFlag     );
    206       m_sps3dExtension.setCqtCuPartPredEnabledFlag            ( d, m_qtPredFlag            );
    207       m_sps3dExtension.setInterDcOnlyEnabledFlag          ( d, m_interSdcFlag          );
    208       m_sps3dExtension.setSkipIntraEnabledFlag    ( d, m_depthIntraSkipFlag    ); 
    209     }
    210   }
    211 #endif
    212171
    213172
     
    219178    m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
    220179    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
    221 #if NH_3D   
    222     Int profileIdc = -1;
    223     for (Int olsIdx = 0; olsIdx < vps.getNumOutputLayerSets(); olsIdx++ )
    224     {   
    225       Int lsIdx = vps.olsIdxToLsIdx( olsIdx );
    226       for(Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++ )
    227       {
    228         if( vps.getLayerIdInNuh( layerIdInVps) == vps.getLayerSetLayerIdList(lsIdx, i) )
    229         {
    230           Int ptlIdx = vps.getProfileTierLevelIdx( olsIdx, i );
    231           if ( ptlIdx != -1 )
    232           {
    233             Int curProfileIdc = vps.getPTL(ptlIdx)->getGeneralPTL()->getProfileIdc();
    234             if (profileIdc == -1)   
    235             {
    236               profileIdc = curProfileIdc;
    237             }
    238             else
    239             {   
    240               if ( profileIdc != curProfileIdc )
    241               {             
    242                 fprintf(stderr, "Error: ProfileIdc for layer with index %d in VPS not equal in all OLSs. \n", layerIdInVps );
    243                 exit(EXIT_FAILURE);
    244               }
    245             }
    246           }
    247         }
    248       }
    249     }
    250 
    251     if (profileIdc == -1 )
    252     {
    253       fprintf(stderr, "Error: No profile given for layer with index %d in VPS not equal in all OLS. \n", layerIdInVps );
    254       exit(EXIT_FAILURE);
    255     }
    256     m_acTEncTopList[ layerIdInVps ]->setProfileIdc( profileIdc );
    257 #endif
    258180  }
    259181
     
    278200    m_cTEncTop.setViewId                       ( vps.getViewId      (  layerId ) );
    279201    m_cTEncTop.setViewIndex                    ( vps.getViewIndex   (  layerId ) );
    280 #if NH_3D_VSO
    281     Bool isDepth    = ( vps.getDepthId     ( layerId ) != 0  ) ;
    282     Bool isAuxDepth = ( vps.getAuxId       ( layerId ) ==  2 ) ; // TBD: define 2 as AUX_DEPTH
    283     m_cTEncTop.setIsDepth                  ( isDepth    );
    284     m_cTEncTop.setIsAuxDepth               ( isAuxDepth );
    285     //====== Camera Parameters =========
    286     m_cTEncTop.setCameraParameters             ( &m_cCameraData );     
    287     //====== VSO =========
    288     m_cTEncTop.setRenderModelParameters        ( &m_cRenModStrParser );
    289     m_cTEncTop.setForceLambdaScaleVSO          ( isDepth || isAuxDepth ? m_bForceLambdaScaleVSO : false );
    290     m_cTEncTop.setLambdaScaleVSO               ( isDepth || isAuxDepth ? m_dLambdaScaleVSO      : 1     );
    291     m_cTEncTop.setVSOMode                      ( isDepth || isAuxDepth ? m_uiVSOMode            : 0     );
    292 
    293     m_cTEncTop.setAllowNegDist                 ( isDepth || isAuxDepth ? m_bAllowNegDist        : false );
    294 
    295     // SAIT_VSO_EST_A0033
    296     m_cTEncTop.setUseEstimatedVSD              ( isDepth || isAuxDepth ? m_bUseEstimatedVSD     : false );
    297 
    298     // LGE_WVSO_A0119
    299     m_cTEncTop.setUseWVSO                      ( isDepth || isAuxDepth ? m_bUseWVSO             : false );   
    300     m_cTEncTop.setVSOWeight                    ( isDepth || isAuxDepth ? m_iVSOWeight           : 0     );
    301     m_cTEncTop.setVSDWeight                    ( isDepth || isAuxDepth ? m_iVSDWeight           : 0     );
    302     m_cTEncTop.setDWeight                      ( isDepth || isAuxDepth ? m_iDWeight             : 0     );
    303 #endif // H_3D_VSO
    304 #if NH_3D
    305 #if NH_3D_IC
    306     m_cTEncTop.setUseIC                        ( vps.getViewIndex( layerId ) == 0 || isDepth ? false : m_abUseIC );
    307     m_cTEncTop.setUseICLowLatencyEnc           ( m_bUseLowLatencyICEnc );
    308 #endif
    309 
    310    
    311     m_cTEncTop.setUseDMM                       ( isDepth ? m_intraWedgeFlag   : false );
    312     m_cTEncTop.setUseSDC                       ( isDepth ? m_intraSdcFlag     : false );
    313     m_cTEncTop.setUseDLT                       ( isDepth ? m_useDLT   : false );
    314 #endif
    315 #if NH_3D_QTL
    316     m_cTEncTop.setUseQTL                       ( isDepth || isAuxDepth ? m_bUseQTL  : false );
    317 #endif
    318 #if NH_3D
    319     m_cTEncTop.setSps3dExtension               ( m_sps3dExtension );
    320 #endif // NH_3D
    321202
    322203    m_cTEncTop.setIvPicLists                   ( &m_ivPicLists );
     
    324205  m_cTEncTop.setVPS(&vps);
    325206
    326 #if NH_3D_DLT
    327   m_cTEncTop.setDLT(dlt);
    328 #endif
    329207
    330208#if NH_MV
     
    438316  m_cTEncTop.setChromaCrQpOffset                                  ( m_crQpOffset  );
    439317
    440 #if NH_3D
    441   m_cTEncTop.setChromaFormatIdc                                   ( isDepth ? CHROMA_400 : m_chromaFormatIDC );
    442 #else
    443318  m_cTEncTop.setChromaFormatIdc                                   ( m_chromaFormatIDC  );
    444 #endif
    445319
    446320#if ADAPTIVE_QP_SELECTION
     
    651525  m_cTEncTop.setScalingListFileName                               ( m_scalingListFileName );
    652526  m_cTEncTop.setSignHideFlag                                      ( m_signHideFlag);
    653 #if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227
    654   if(!m_cTEncTop.getIsDepth())    //only for texture
    655   {
    656     m_cTEncTop.setUseRateCtrl                                     ( m_RCEnableRateControl );
    657   }                                                         
    658   else                                                       
    659   {                                                         
    660     m_cTEncTop.setUseRateCtrl                                     ( 0 );
    661   }
    662 #else
    663527  m_cTEncTop.setUseRateCtrl                                       ( m_RCEnableRateControl );
    664 #endif
    665 #if !KWU_RC_VIEWRC_E0227
    666528  m_cTEncTop.setTargetBitrate                                     ( m_RCTargetBitrate );
    667 #endif
    668529  m_cTEncTop.setKeepHierBit                                       ( m_RCKeepHierarchicalBit );
    669530  m_cTEncTop.setLCULevelRC                                        ( m_RCLCULevelRC );
     
    677538#endif
    678539
    679 #if KWU_RC_MADPRED_E0227
    680   if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
    681   {
    682     m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred       : 0);
    683     if(m_cTEncTop.getUseDepthMADPred())
    684     {
    685       m_cTEncTop.setCamParam(&m_cCameraData);
    686     }
    687   }
    688 #endif
    689 #if KWU_RC_VIEWRC_E0227
    690   if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
    691   {
    692     m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl);
    693     if(m_iNumberOfViews == 1)
    694     {
    695       if(m_viewWiseRateCtrl)
    696       {
    697         m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
    698       }
    699       else
    700       {
    701         m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
    702       }
    703     }
    704     else
    705     {
    706       if(m_viewWiseRateCtrl)
    707       {
    708         m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
    709       }
    710       else
    711       {
    712         if(m_iNumberOfViews == 2)
    713         {
    714           if(m_cTEncTop.getViewId() == 0)
    715           {
    716             m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*80)/100 );
    717           }
    718           else if(m_cTEncTop.getViewId() == 1)
    719           {
    720             m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*20)/100 );
    721           }
    722         }
    723         else if(m_iNumberOfViews == 3)
    724         {
    725           if(m_cTEncTop.getViewId() == 0)
    726           {
    727             m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*66)/100 );
    728           }
    729           else if(m_cTEncTop.getViewId() == 1)
    730           {
    731             m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*17)/100 );
    732           }
    733           else if(m_cTEncTop.getViewId() == 2)
    734           {
    735             m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*17)/100 );
    736           }
    737         }
    738         else
    739         {
    740           m_cTEncTop.setTargetBitrate              ( m_RCTargetBitrate );
    741         }
    742       }
    743     }
    744   }
    745 #endif
    746540  m_cTEncTop.setTransquantBypassEnableFlag                        ( m_TransquantBypassEnableFlag );
    747541  m_cTEncTop.setCUTransquantBypassFlagForceValue                  ( m_CUTransquantBypassFlagForce );
     
    790584  }
    791585#endif
    792 #if NH_3D_VSO
    793   if ( m_bUseVSO )
    794   {
    795     if ( m_uiVSOMode == 4 )
    796     {
    797 #if H_3D_VSO_EARLY_SKIP
    798       m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip );
    799 #else
    800       m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 );
    801 #endif
    802       for ( Int layer = 0; layer < m_numberOfLayers ; layer++ )
    803       {
    804         TEncTop* pcEncTop =  m_acTEncTopList[ layer ];
    805         Int iViewNum      = pcEncTop->getViewIndex();
    806         Int iContent      = pcEncTop->getIsDepth() || pcEncTop->getIsAuxDepth() ? 1 : 0;
    807         Int iNumOfModels  = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent);
    808 
    809         Bool bUseVSO      = (iNumOfModels != 0);
    810 
    811         pcEncTop->setUseVSO( bUseVSO );
    812         pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL );
    813 
    814         for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ )
    815         {
    816           Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode;
    817 
    818           m_cRenModStrParser.getSingleModelData  ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ;
    819           m_cRendererModel  .createSingleModel   ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode );
    820         }           
    821       }
    822     }
    823     else
    824     {
    825       AOT(true);
    826     }
    827   }
    828 #endif
    829586}
    830587
     
    834591  // initialize global variables
    835592  initROM();
    836 #if NH_3D_DMM
    837   initWedgeLists( true );
    838 #endif
    839593
    840594  for( Int layer=0; layer < m_numberOfLayers; layer++)
     
    900654  for(Int layer=0; layer<m_numberOfLayers; layer++)
    901655  {
    902 #if KWU_RC_MADPRED_E0227
    903     m_acTEncTopList[layer]->init( isFieldCoding, this );
    904 #else
    905656    m_acTEncTopList[layer]->init( isFieldCoding );
    906 #endif
    907657  }
    908658#else
     
    932682  }
    933683
    934 #if !NH_3D
    935684  TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
    936 #endif
    937685  TComPicYuv*       pcPicYuvRec = NULL;
    938686
     
    968716  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
    969717 
    970 #if NH_3D
    971   TComPicYuv* picYuvOrg[2];
    972   TComPicYuv  picYuvTrueOrg[2];
    973   for (Int d = 0; d < 2 ; d++)
    974   {
    975     picYuvOrg[d] = new TComPicYuv;
    976     picYuvOrg[d]   ->create( m_iSourceWidth, m_isField ? m_iSourceHeightOrg : m_iSourceHeight, ( d > 0 ) ? CHROMA_400 : m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
    977     picYuvTrueOrg[d].create( m_iSourceWidth, m_isField ? m_iSourceHeightOrg : m_iSourceHeight, ( d > 0 ) ? CHROMA_400 : m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
    978   }
    979 #else
    980718  TComPicYuv cPicYuvTrueOrg;
    981719
     
    991729    cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
    992730  }
    993 #endif
    994731#if NH_MV
    995732  while ( (m_targetEncLayerIdList.size() != 0 ) && !allEos )
     
    997734    for(Int layer=0; layer < m_numberOfLayers; layer++ )
    998735    {
    999 #if NH_3D
    1000       TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ m_depthFlag[layer] ];
    1001       TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ m_depthFlag[layer] ];
    1002 #endif
    1003736      if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) ))
    1004737      {
     
    1036769    for ( Int gopId=0; gopId < gopSize; gopId++ )
    1037770    {
    1038 #if NH_3D_VSO
    1039       UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId );
    1040       if ( iNextPoc < m_framesToBeEncoded )
    1041       {
    1042         m_cCameraData.update( iNextPoc );
    1043       }
    1044 #endif
    1045771      for(Int layer=0; layer < m_numberOfLayers; layer++ )
    1046772      {
    1047 #if NH_3D
    1048         TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ m_depthFlag[layer] ];
    1049         TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ m_depthFlag[layer] ];
    1050 #endif
    1051773        if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) ))
    1052774        {
     
    1054776        }
    1055777
    1056 #if NH_3D_VSO       
    1057           if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded )
    1058           {
    1059             m_cCameraData.setDispCoeff( iNextPoc, m_acTEncTopList[layer]->getViewIndex() );
    1060             m_acTEncTopList[layer]  ->setDispCoeff( m_cCameraData.getDispCoeff() );
    1061           }
    1062 #endif
    1063778
    1064779        Int   iNumEncoded = 0;
     
    1127842#endif
    1128843
    1129 #if NH_3D
    1130   // delete original YUV buffer
    1131   for (Int d = 0; d < 2; d++)
    1132   {
    1133     picYuvOrg[d]->destroy();
    1134     delete picYuvOrg[d];
    1135     picYuvOrg[d] = NULL;
    1136 
    1137     picYuvTrueOrg[d].destroy();
    1138   }
    1139 #else
    1140844  // delete original YUV buffer
    1141845  pcPicYuvOrg->destroy();
    1142846  delete pcPicYuvOrg;
    1143847  pcPicYuvOrg = NULL;
    1144 #endif
    1145848
    1146849#if !NH_MV
     
    1148851  m_cTEncTop.deletePicBuffer();
    1149852#endif
    1150 #if !NH_3D
    1151853  cPicYuvTrueOrg.destroy();
    1152 #endif
    1153854
    1154855  // delete buffers & classes
     
    1158859  printRateSummary();
    1159860
    1160 #if NH_3D_REN_MAX_DEV_OUT
    1161   Double dMaxDispDiff = m_cCameraData.getMaxShiftDeviation();
    1162 
    1163   if ( !(dMaxDispDiff < 0) )
    1164   { 
    1165     printf("\n Max. possible shift error: %12.3f samples.\n", dMaxDispDiff );
    1166   }
    1167 #endif
    1168861
    1169862  return;
     
    1202895  {
    1203896    rpcPicYuvRec = new TComPicYuv;
    1204 #if NH_3D
    1205     rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_depthFlag[layer] > 0 ? CHROMA_400 : m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
    1206 #else
    1207897    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
    1208 #endif
    1209898
    1210899  }
     
    1284973      if (m_pchReconFileList[layerIdx])
    1285974      {
    1286 #if NH_3D
    1287         m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT, m_isTopFieldFirst );
    1288 #else
    1289975        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, NUM_CHROMA_FORMAT, m_isTopFieldFirst );
    1290 #endif
    1291976      }
    1292977    }
     
    13411026      if (m_pchReconFileList[layerIdx])
    13421027      {
    1343 #if NH_3D
    1344         m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT  );
    1345 #else
    13461028        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
    1347 #endif
    13481029
    13491030      }   
     
    14701151}
    14711152
    1472 #if NH_3D_DLT
    1473 Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt)
    1474 {
    1475   TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
    1476   TComPicYuv*       pcDepthPicYuvTrueOrg = new TComPicYuv;
    1477   // allocate original YUV buffer
    1478   pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, false );
    1479   pcDepthPicYuvTrueOrg->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, false );
    1480  
    1481   TVideoIOYuv* depthVideoFile = new TVideoIOYuv;
    1482  
    1483   UInt uiMaxDepthValue = ((1 << m_inputBitDepth[CHANNEL_TYPE_LUMA])-1);
    1484  
    1485   std::vector<Bool> abValidDepths(256, false);
    1486  
    1487   depthVideoFile->open( m_pchInputFileList[layer], false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );
    1488  
    1489   Int iHeight   = pcDepthPicYuvOrg->getHeight(COMPONENT_Y);
    1490   Int iWidth    = pcDepthPicYuvOrg->getWidth(COMPONENT_Y);
    1491   Int iStride   = pcDepthPicYuvOrg->getStride(COMPONENT_Y);
    1492  
    1493   Pel* pInDM    = pcDepthPicYuvOrg->getAddr(COMPONENT_Y);
    1494  
    1495   for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ )
    1496   {
    1497     depthVideoFile->read( pcDepthPicYuvOrg, pcDepthPicYuvTrueOrg, IPCOLOURSPACE_UNCHANGED, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
    1498    
    1499     // check all pixel values
    1500     for (Int i=0; i<iHeight; i++)
    1501     {
    1502       Int rowOffset = i*iStride;
    1503      
    1504       for (Int j=0; j<iWidth; j++)
    1505       {
    1506         Pel depthValue = pInDM[rowOffset+j];
    1507         abValidDepths[depthValue] = true;
    1508       }
    1509     }
    1510   }
    1511  
    1512   depthVideoFile->close();
    1513   delete depthVideoFile;
    1514  
    1515   pcDepthPicYuvOrg->destroy();
    1516   delete pcDepthPicYuvOrg;
    1517   pcDepthPicYuvTrueOrg->destroy();
    1518   delete pcDepthPicYuvTrueOrg;
    1519  
    1520   // convert boolean array to idx2Depth LUT
    1521   std::vector<Int> aiIdx2DepthValue(256, 0);
    1522   Int iNumDepthValues = 0;
    1523   for(Int p=0; p<=uiMaxDepthValue; p++)
    1524   {
    1525     if( abValidDepths[p] == true)
    1526     {
    1527       aiIdx2DepthValue[iNumDepthValues++] = p;
    1528     }
    1529   }
    1530  
    1531   if( uiNumFrames == 0 || gCeilLog2(iNumDepthValues) == m_inputBitDepth[CHANNEL_TYPE_LUMA] )
    1532   {
    1533     dlt->setUseDLTFlag(layer, false);
    1534   }
    1535  
    1536   // assign LUT
    1537   if( dlt->getUseDLTFlag(layer) )
    1538   {
    1539     dlt->setDepthLUTs(layer, aiIdx2DepthValue, iNumDepthValues);
    1540   }
    1541 }
    1542 #endif
    15431153
    15441154#if NH_MV
     
    15701180
    15711181
    1572 #if NH_3D
    1573   vps.initViewCompLayer( );
    1574 #endif
    15751182}
    15761183
     
    16491256      Int curLayerIdInNuh = vps.getLayerIdInNuh( curLayerIdInVps );     
    16501257      Int maxTid = -1;
    1651 #if NH_3D
    1652       if ( vps.getDirectDependencyFlag( curLayerIdInVps, refLayerIdInVps ) )
    1653       {
    1654         if ( m_depthFlag[ curLayerIdInVps] == m_depthFlag[ refLayerIdInVps ] )
    1655         {
    1656 #endif
    16571258          for( Int i = 0; i < ( getGOPSize() + 1); i++ )
    16581259          {       
     
    16611262            for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++)
    16621263            {
    1663 #if NH_3D
    1664               if ( vps.getIdRefListLayer( curLayerIdInNuh, geCur.m_interLayerPredLayerIdc[ j ] ) == refLayerIdInNuh )
    1665 #else
    16661264              if ( vps.getIdDirectRefLayer( curLayerIdInNuh, geCur.m_interLayerPredLayerIdc[ j ] ) == refLayerIdInNuh )
    1667 #endif
    16681265              {
    16691266                Bool refLayerZero   = ( i == getGOPSize() ) && ( refLayerIdInVps == 0 );
     
    16721269            }
    16731270          }             
    1674 #if NH_3D
    1675         }
    1676         else
    1677         {       
    1678           if( m_depthFlag[ curLayerIdInVps ] && ( m_mpiFlag|| m_qtPredFlag || m_intraContourFlag ) )
    1679           {         
    1680             Int nuhLayerIdTex = vps.getLayerIdInNuh( vps.getViewIndex( curLayerIdInNuh ), false, 0 );
    1681             if ( nuhLayerIdTex == refLayerIdInNuh )
    1682             {
    1683               for( Int i = 0; i < ( getGOPSize() + 1); i++ )
    1684               {       
    1685                 GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
    1686                 GOPEntry geRef =  m_GOPListMvc[refLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
    1687                 if ( geCur.m_interCompPredFlag )
    1688                 {
    1689                   Bool refLayerZero   = ( i == getGOPSize() ) && ( refLayerIdInVps == 0 );
    1690                   maxTid = std::max( maxTid, refLayerZero ? 0 : geRef.m_temporalId );
    1691                 }
    1692               }
    1693             }
    1694           }
    1695           if( !m_depthFlag[ curLayerIdInVps ] && vps.getNumRefListLayers( curLayerIdInNuh) > 0  && ( m_depthRefinementFlag || m_viewSynthesisPredFlag || m_depthBasedBlkPartFlag ) )
    1696           {             
    1697             for( Int i = 0; i < ( getGOPSize() + 1); i++ )
    1698             {       
    1699               GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
    1700               GOPEntry geRef =  m_GOPListMvc[refLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
    1701 
    1702               if ( geCur.m_interCompPredFlag )
    1703               {
    1704                 for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++ )
    1705                 {
    1706                   Int nuhLayerIdDep = vps.getLayerIdInNuh( vps.getViewIndex( vps.getIdRefListLayer( curLayerIdInNuh, geCur.m_interLayerPredLayerIdc[j] ) ), true, 0 );
    1707                   if ( nuhLayerIdDep == refLayerIdInNuh )
    1708                   {
    1709                     Bool refLayerZero   = ( i == getGOPSize() ) && ( refLayerIdInVps == 0 );
    1710                     maxTid = std::max( maxTid, refLayerZero ? 0 : geRef.m_temporalId );
    1711                   }
    1712                 }
    1713               }
    1714             }
    1715           }       
    1716         }
    1717       } // if ( vps.getDirectDependencyFlag( curLayerIdInVps, refLayerIdInVps ) )
    1718       vps.setMaxTidIlRefPicsPlus1( refLayerIdInVps, curLayerIdInVps, maxTid + 1 );
    1719 #endif
    17201271    }  // Loop curLayerIdInVps
    17211272  } // Loop refLayerIdInVps
     
    17661317     
    17671318      // check if all reference layers when allRefLayerActiveFlag is equal to 1 are reference layer pictures specified in the gop entry
    1768 #if NH_3D
    1769       for (Int k = 0; k < vps.getNumRefListLayers( layerIdInNuh ) && allRefLayersActiveFlag; k++ )
    1770       {
    1771         Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdRefListLayer( layerIdInNuh , k ) );
    1772 #else
    17731319      for (Int k = 0; k < vps.getNumDirectRefLayers( layerIdInNuh ) && allRefLayersActiveFlag; k++ )
    17741320      {
    17751321        Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdDirectRefLayer( layerIdInNuh , k ) );
    1776 #endif
    17771322        if ( vps.getSubLayersVpsMaxMinus1(refLayerIdInVps) >= tId  && ( tId == 0 || vps.getMaxTidIlRefPicsPlus1(refLayerIdInVps,layerIdInVps) > tId )  )
    17781323        {
     
    17921337      {   
    17931338        Bool referenceLayerFoundFlag = false;
    1794 #if NH_3D
    1795         for (Int k = 0; k < vps.getNumRefListLayers( layerIdInNuh ); k++ )
    1796         {
    1797           Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdRefListLayer( layerIdInNuh, k) );
    1798 #else
    17991339        for (Int k = 0; k < vps.getNumDirectRefLayers( layerIdInNuh ); k++ )
    18001340        {
    18011341          Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdDirectRefLayer( layerIdInNuh, k) );
    1802 #endif
    18031342          if ( vps.getSubLayersVpsMaxMinus1(refLayerIdInVps) >= tId  && ( tId == 0 || vps.getMaxTidIlRefPicsPlus1(refLayerIdInVps,layerIdInVps) > tId )  )
    18041343          {         
     
    19291468    break;
    19301469  case Profile::MULTIVIEWMAIN:
    1931 #if NH_3D
    1932   case Profile::MAIN3D:
    1933 #endif
    19341470    ptl->setMax12bitConstraintFlag      ( true  );
    19351471    ptl->setMax12bitConstraintFlag      ( true  );
     
    19531489
    19541490  Bool anyDepth = false;
    1955 #if NH_3D
    1956   for ( Int i = 0; i < m_numberOfLayers; i++ )
    1957   {
    1958     vps.setVpsRepFormatIdx( i, m_depthFlag[ i ] ? 1 : 0 );
    1959     anyDepth = anyDepth || m_depthFlag[ i ];
    1960   }
    1961 #endif
    19621491
    19631492  vps.setRepFormatIdxPresentFlag( anyDepth );
     
    23641893}
    23651894
    2366 #if NH_3D
    2367 Void TAppEncTop::xSetCamPara                ( TComVPS& vps )
    2368 {
    2369   vps.setCpPrecision( m_cCameraData.getCamParsCodedPrecision());
    2370 
    2371   for ( Int n = 1; n < vps.getNumViews(); n++ )
    2372   { 
    2373     Int i      = vps.getViewOIdxList( n );
    2374     Int iInVps = vps.getVoiInVps    ( i );
    2375     vps.setNumCp( iInVps,  n);   
    2376 
    2377     if ( vps.getNumCp( iInVps ) > 0 )
    2378     {
    2379       vps.setCpInSliceSegmentHeaderFlag( iInVps, m_cCameraData.getVaryingCameraParameters() );
    2380 
    2381       for( Int m = 0; m < vps.getNumCp( iInVps ); m++ )
    2382       {
    2383         vps.setCpRefVoi( iInVps, m, vps.getViewOIdxList( m ) );
    2384         if( !vps.getCpInSliceSegmentHeaderFlag( iInVps ) )
    2385         {
    2386           Int j = vps.getCpRefVoi( iInVps, m );
    2387           Int jInVps = vps.getVoiInVps( j );         
    2388 
    2389           vps.setVpsCpScale   ( iInVps, jInVps, m_cCameraData.getCodedScale() [ jInVps ][ iInVps ] ) ;
    2390           vps.setVpsCpInvScale( iInVps, jInVps, m_cCameraData.getCodedScale() [ iInVps ][ jInVps ] ) ;
    2391           vps.setVpsCpOff     ( iInVps, jInVps, m_cCameraData.getCodedOffset()[ jInVps ][ iInVps ] ) ;
    2392           vps.setVpsCpInvOff  ( iInVps, jInVps, m_cCameraData.getCodedOffset()[ iInVps ][ jInVps ] ) ;
    2393         }
    2394       }
    2395     }
    2396   }
    2397   vps.deriveCpPresentFlag();
    2398 }
    2399 #endif
    24001895
    24011896
     
    24091904
    24101905
    2411 #if NH_3D_DLT
    2412 Void TAppEncTop::xDeriveDltArray( TComVPS& vps, TComDLT* dlt )
    2413 {
    2414   Int  iNumDepthViews  = 0;
    2415   Bool bDltPresentFlag = false;
    2416 
    2417   for ( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ )
    2418   {
    2419     Bool isDepth = ( vps.getDepthId( layer ) == 1 );
    2420 
    2421     if ( isDepth )
    2422     {
    2423       iNumDepthViews++;
    2424     }
    2425 
    2426     dlt->setUseDLTFlag( layer , isDepth && m_useDLT );
    2427     if( dlt->getUseDLTFlag( layer ) )
    2428     {
    2429       xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod[layer], 24), &vps, dlt);
    2430       bDltPresentFlag = bDltPresentFlag || dlt->getUseDLTFlag(layer);
    2431       dlt->setInterViewDltPredEnableFlag(layer, (dlt->getUseDLTFlag(layer) && (layer>1)));
    2432      
    2433       // ----------------------------- determine whether to use bit-map -----------------------------
    2434       Bool bDltBitMapRepFlag       = false;
    2435       UInt uiNumBitsNonBitMap      = 0;
    2436       UInt uiNumBitsBitMap         = 0;
    2437      
    2438       UInt uiMaxDiff               = 0;
    2439       UInt uiMinDiff               = MAX_INT;
    2440       UInt uiLengthMinDiff         = 0;
    2441       UInt uiLengthDltDiffMinusMin = 0;
    2442      
    2443       std::vector<Int> aiIdx2DepthValue_coded(256, 0);
    2444       UInt uiNumDepthValues_coded = 0;
    2445      
    2446       uiNumDepthValues_coded = dlt->getNumDepthValues(layer);
    2447       for( UInt ui = 0; ui<uiNumDepthValues_coded; ui++ )
    2448       {
    2449         aiIdx2DepthValue_coded[ui] = dlt->idx2DepthValue(layer, ui);
    2450       }
    2451      
    2452       if( dlt->getInterViewDltPredEnableFlag( layer ) )
    2453       {
    2454         AOF( vps.getDepthId( 1 ) == 1 );
    2455         AOF( layer > 1 );
    2456         // assumes ref layer id to be 1
    2457         std::vector<Int> piRefDLT = dlt->idx2DepthValue( 1 );
    2458         UInt uiRefNum = dlt->getNumDepthValues( 1 );
    2459         dlt->getDeltaDLT(layer, piRefDLT, uiRefNum, aiIdx2DepthValue_coded, uiNumDepthValues_coded);
    2460       }
    2461      
    2462       std::vector<UInt> puiDltDiffValues(uiNumDepthValues_coded, 0);
    2463      
    2464       for (UInt d = 1; d < uiNumDepthValues_coded; d++)
    2465       {
    2466         puiDltDiffValues[d] = aiIdx2DepthValue_coded[d] - aiIdx2DepthValue_coded[d-1];
    2467        
    2468         if ( uiMaxDiff < puiDltDiffValues[d] )
    2469         {
    2470           uiMaxDiff = puiDltDiffValues[d];
    2471         }
    2472        
    2473         if ( uiMinDiff > puiDltDiffValues[d] )
    2474         {
    2475           uiMinDiff = puiDltDiffValues[d];
    2476         }
    2477       }
    2478      
    2479       // counting bits
    2480       // diff coding branch
    2481       uiNumBitsNonBitMap += 8;                          // u(v) bits for num_depth_values_in_dlt[layerId] (i.e. num_entry[ layerId ])
    2482      
    2483       if ( uiNumDepthValues_coded > 1 )
    2484       {
    2485         uiNumBitsNonBitMap += 8;                        // u(v) bits for max_diff[ layerId ]
    2486       }
    2487      
    2488       if ( uiNumDepthValues_coded > 2 )
    2489       {
    2490         uiLengthMinDiff    = (UInt) gCeilLog2(uiMaxDiff + 1);
    2491         uiNumBitsNonBitMap += uiLengthMinDiff;          // u(v)  bits for min_diff[ layerId ]
    2492       }
    2493      
    2494       uiNumBitsNonBitMap += 8;                          // u(v) bits for dlt_depth_value0[ layerId ]
    2495      
    2496       if (uiMaxDiff > uiMinDiff)
    2497       {
    2498         uiLengthDltDiffMinusMin = (UInt) gCeilLog2(uiMaxDiff - uiMinDiff + 1);
    2499         uiNumBitsNonBitMap += uiLengthDltDiffMinusMin * (uiNumDepthValues_coded - 1);  // u(v) bits for dlt_depth_value_diff_minus_min[ layerId ][ j ]
    2500       }
    2501      
    2502       // bit map branch
    2503       uiNumBitsBitMap = 1 << m_inputBitDepth[CHANNEL_TYPE_LUMA];
    2504      
    2505       // determine bDltBitMapFlag
    2506       bDltBitMapRepFlag = (uiNumBitsBitMap > uiNumBitsNonBitMap) ? false : true;
    2507      
    2508       dlt->setUseBitmapRep(layer, bDltBitMapRepFlag);
    2509     }
    2510   }
    2511 
    2512   dlt->setDltPresentFlag( bDltPresentFlag );
    2513   dlt->setNumDepthViews ( iNumDepthViews  );
    2514   dlt->setDepthViewBitDepth( m_inputBitDepth[CHANNEL_TYPE_LUMA] );
    2515 }
    2516 #endif
    25171906//! \}
  • branches/HTM-16.0-MV-draft-5/source/App/TAppEncoder/TAppEncTop.h

    r1386 r1390  
    4646#include "TLibCommon/AccessUnit.h"
    4747#include "TAppEncCfg.h"
    48 #if NH_3D_VSO
    49 #include "../../Lib/TLibRenderer/TRenTop.h"
    50 #endif
    5148
    52 #if KWU_RC_MADPRED_E0227
    53 class TEncTop;
    54 #endif
    5549//! \ingroup TAppEncoder
    5650//! \{
     
    9084#endif
    9185
    92 #if NH_3D
    93   TComSps3dExtension         m_sps3dExtension;              ///< Currently all layers share the same sps 3D Extension 
    94 #endif
    9586
    9687  UInt m_essentialBytes;
    9788  UInt m_totalBytes;
    98 #if NH_3D_VSO
    99   TRenTop                     m_cRendererTop;
    100   TRenModel                   m_cRendererModel;   
    101 #endif
    10289protected:
    10390  // initialization
     
    144131  Void xSetDpbSize                ( TComVPS& vps );
    145132  Void xSetVPSVUI                 ( TComVPS& vps );
    146 #if NH_3D
    147   Void xSetCamPara                ( TComVPS& vps );
    148 #endif
    149133  GOPEntry* xGetGopEntry( Int layerIdInVps, Int poc );
    150134  Int  xGetMax( std::vector<Int>& vec);
    151135  Bool xLayerIdInTargetEncLayerIdList( Int nuhLayerId );
    152 #endif
    153 #if NH_3D_DLT
    154   Void xDeriveDltArray( TComVPS& vps, TComDLT* dlt );
    155   Void xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt);
    156136#endif
    157137
  • branches/HTM-16.0-MV-draft-5/source/App/TAppRenderer/RendererMain.cpp

    r1386 r1390  
    3535#include <time.h>
    3636#include "../../Lib/TLibCommon/CommonDef.h"
    37 #if NH_3D_VSO
    38 #include "TAppRendererTop.h"
    39 // ====================================================================================================================
    40 // Main function
    41 // ====================================================================================================================
    42 
    43 int main(int argc, char* argv[])
    44   {
    45 
    46   TAppRendererTop  cTAppRendererTop;
    47 
    48   // print information
    49   fprintf( stdout, "\n" );
    50   fprintf( stdout, "3D-HTM software: Renderer Version [%s]", NV_VERSION); 
    51   fprintf( stdout, NVM_ONOS );
    52   fprintf( stdout, NVM_COMPILEDBY );
    53   fprintf( stdout, NVM_BITS );
    54   fprintf( stdout, "\n" );
    55 
    56   // create application renderer class
    57   cTAppRendererTop.create();
    58 
    59   // parse configuration
    60   if(!cTAppRendererTop.parseCfg( argc, argv ))
    61   {
    62     cTAppRendererTop.destroy();
    63     return 1;
    64   }
    65 
    66   // starting time
    67   double dResult;
    68   long lBefore = clock();
    69 
    70   // call rendering function
    71   cTAppRendererTop.go();
    72 
    73   // ending time
    74   dResult = (double)(clock()-lBefore) / CLOCKS_PER_SEC;
    75   printf("\n Total Time: %12.3f sec.\n", dResult);
    76 
    77   // destroy application renderer class
    78   cTAppRendererTop.destroy();
    79 
    80   return 0;
    81 }
    82 #else
    8337
    8438#include <iostream>
     
    8943}
    9044
    91 #endif // NH_3D
    9245
  • branches/HTM-16.0-MV-draft-5/source/App/TAppRenderer/TAppRendererCfg.cpp

    r1386 r1390  
    4444#include "../../Lib/TAppCommon/program_options_lite.h"
    4545
    46 #if NH_3D_VSO
    47 
    48 using namespace std;
    49 namespace po = df::program_options_lite;
    50 
    51 // ====================================================================================================================
    52 // Local constants
    53 // ====================================================================================================================
    54 
    55 #define MAX_INPUT_VIEW_NUM          10
    56 #define MAX_OUTPUT_VIEW_NUM         64
    57 
    58 // ====================================================================================================================
    59 // Constructor / destructor / initialization / destroy
    60 // ====================================================================================================================
    61 
    62 
    63 TAppRendererCfg::TAppRendererCfg()
    64 {
    65  
    66 }
    67 
    68 TAppRendererCfg::~TAppRendererCfg()
    69 {
    70   for(Int i = 0; i< m_pchVideoInputFileList.size(); i++ )
    71   {
    72     if ( m_pchVideoInputFileList[i] != NULL )
    73       free (m_pchVideoInputFileList[i]);
    74   }
    75 
    76   for(Int i = 0; i< m_pchDepthInputFileList.size(); i++ )
    77   {
    78     if ( m_pchDepthInputFileList[i] != NULL )
    79       free (m_pchDepthInputFileList[i]);
    80   }
    81 
    82   for(Int i = 0; i< m_pchSynthOutputFileList.size(); i++ )
    83   {
    84     if ( m_pchSynthOutputFileList[i] != NULL )
    85       free (m_pchSynthOutputFileList[i]);
    86   }
    87 
    88   if ( m_pchVideoInputFileBaseName  ) free( m_pchVideoInputFileBaseName );
    89   if ( m_pchDepthInputFileBaseName  ) free( m_pchDepthInputFileBaseName );
    90   if ( m_pchSynthOutputFileBaseName ) free( m_pchSynthOutputFileBaseName);
    91   if ( m_pchCameraParameterFile     ) free( m_pchCameraParameterFile    );
    92   if ( m_pchBaseViewCameraNumbers   ) free( m_pchBaseViewCameraNumbers  );
    93   if ( m_pchSynthViewCameraNumbers  ) free( m_pchSynthViewCameraNumbers );
    94   if ( m_pchViewConfig              ) free( m_pchViewConfig         );
    95 }
    96 
    97 Void TAppRendererCfg::create()
    98 {
    99 }
    100 
    101 Void TAppRendererCfg::destroy()
    102 {
    103 }
    104 
    105 // ====================================================================================================================
    106 // Public member functions
    107 // ====================================================================================================================
    108 
    109 /** \param  argc        number of arguments
    110 \param  argv        array of arguments
    111 \retval             true when success
    112 */
    113 Bool TAppRendererCfg::parseCfg( Int argc, TChar* argv[] )
    114 {
    115   bool do_help = false;
    116 
    117   po::Options opts;
    118   opts.addOptions()
    119     ("help", do_help, false, "this help text")
    120     ("c", po::parseConfigFile, "configuration file name")
    121 
    122     /* File I/O */
    123     ("VideoInputFileBaseName,v",  m_pchVideoInputFileBaseName,  (TChar*) 0, "Basename to generate video input file names")
    124     ("DepthInputFileBaseName,d",  m_pchDepthInputFileBaseName,  (TChar*) 0, "Basename to generate depth input file names")
    125     ("SynthOutputFileBaseName,s", m_pchSynthOutputFileBaseName, (TChar*) 0, "Basename to generate synthesized output file names")
    126     ("ContOutputFileNumbering", m_bContOutputFileNumbering  ,  false   , "Continuous Output File Numbering")
    127     ("Sweep"                  , m_bSweep                    ,  false   , "Store all views in first Output File")
    128 
    129     ("VideoInputFile_%d,v_%d",  m_pchVideoInputFileList ,    (TChar *) 0, MAX_INPUT_VIEW_NUM , "Original Yuv video input file name %d")
    130     ("DepthInputFile_%d,d_%d",  m_pchDepthInputFileList ,    (TChar *) 0, MAX_INPUT_VIEW_NUM , "Original Yuv depth input file name %d")
    131     ("SynthOutputFile_%d,s_%d", m_pchSynthOutputFileList,    (TChar *) 0, MAX_OUTPUT_VIEW_NUM, "Synthesized Yuv output file name %d")
    132 
    133     ("InputBitDepth",           m_inputBitDepth[0],                     8, "Bit-depth of input file")
    134     ("OutputBitDepth",          m_outputBitDepth[0],                    0, "Bit-depth of output file (default:InternalBitDepth)")
    135     ("InternalBitDepth",        m_internalBitDepth[0],                  0, "Bit-depth the renderer operates at. (default:InputBitDepth)"                                                                          "If different to InputBitDepth, source data will be converted")
    136 
    137     ("InputBitDepthC",        m_inputBitDepth[1],    0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
    138     ("OutputBitDepthC",       m_outputBitDepth[1],   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
    139     ("InternalBitDepthC",     m_internalBitDepth[1], 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
    140 
    141     /* Source Specification */
    142     ("SourceWidth,-wdt",        m_iSourceWidth,                       0, "Source picture width")
    143     ("SourceHeight,-hgt",       m_iSourceHeight,                      0, "Source picture height")
    144     ("FrameSkip,-fs",           m_iFrameSkip,                         0, "Number of frames to skip at start of input YUV")
    145     ("FramesToBeRendered,f",    m_iFramesToBeRendered,                0, "Number of frames to be rendered (default=all)")
    146 
    147     /* Camera Specification */
    148     ("CameraParameterFile,-cpf", m_pchCameraParameterFile,         (TChar *) 0, "Camera Parameter File Name")
    149     ("BaseViewCameraNumbers"  , m_pchBaseViewCameraNumbers,        (TChar *) 0, "Numbers of base views")
    150     ("SynthViewCameraNumbers" , m_pchSynthViewCameraNumbers,       (TChar *) 0, "Numbers of views to synthesis")
    151     ("ViewConfig"             , m_pchViewConfig,                   (TChar *) 0, "View Configuration"               )
    152 
    153     /* Renderer Modes */
    154     ("Log2SamplingFactor",      m_iLog2SamplingFactor,                0, "Factor for horizontal up sampling before processing"     )
    155     ("UVup"              ,      m_bUVUp               ,            true, "Up sampling of chroma planes before processing"          )
    156     ("PreProcMode"       ,      m_iPreProcMode        ,               0, "Depth preprocessing: 0 = None, 1 = Binomial filtering"   )
    157     ("PreFilterSize"     ,      m_iPreFilterSize      ,               0, "For PreProcMode 1: Half Size of filter kernel"           )
    158     ("SimEnhance"        ,      m_bSimEnhance         ,           true, "Similarity enhancement of video" )
    159     ("BlendMode"         ,      m_iBlendMode          ,               0, "Blending of left and right image: 0: average, 1: only holes from right, 2: only holes from left, 3: first view in BaseViewOrder as main view" )
    160     ("BlendZThresPerc"   ,      m_iBlendZThresPerc    ,              30, "Z-difference threshold for blending in percent of total Z-range"   )
    161     ("BlendUseDistWeight",      m_bBlendUseDistWeight ,            true, "0: blend using average; 1: blend factor depends on view distance"  )
    162     ("BlendHoleMargin"   ,      m_iBlendHoleMargin    ,               6, "Margin around holes to fill with other view"                       )
    163     ("InterpolationMode" ,      m_iInterpolationMode  ,               4, "0: NN, 1:linear (int), 2:linear (double) , 3:cubic Hermite spline (double), 4: 8-tap (int)" )
    164     ("HoleFillingMode"   ,      m_iHoleFillingMode    ,               1, "0: None, 1: line wise background extension"              )
    165     ("PostProcMode"      ,      m_iPostProcMode       ,               0, "0: None, 1: horizontal 3-tap median"                     )
    166     ("RenderMode"        ,      m_iRenderMode         ,               0, "0: Use renderer, 1: use model renderer, 10: create used pels map")
    167     ("ShiftPrecision"    ,      m_iShiftPrecision     ,               2, "Shift Precision for Interpolation Mode 4"                )
    168     ("TemporalDepthFilter",     m_bTempDepthFilter    ,           false, "Temporal depth filtering"                                )
    169     ("RenderDirection"   ,      m_iRenderDirection    ,               0, "0: Interpolate, 1: Extrapolate from left, 2: Extrapolate from right")
    170     ("UsedPelMapMarExt"  ,      m_iUsedPelMapMarExt   ,               0, "Margin Extension in Pels for used pels map generation"   );
    171 
    172   po::setDefaults(opts);
    173   po::scanArgv(opts, argc, (const char**) argv);
    174 
    175   if (argc == 1 || do_help)
    176   {
    177     /* argc == 1: no options have been specified */
    178     po::doHelp(cout, opts);
    179     xPrintUsage();
    180     return false;
    181   }
    182 
    183   /*
    184   * Set any derived parameters before checking
    185   */
    186 
    187   /* rules for input, output and internal bitdepths as per help text */
    188   if (!m_internalBitDepth[0]) { m_internalBitDepth[0] = m_inputBitDepth[0]; }
    189   if (!m_internalBitDepth[1]) { m_internalBitDepth[1] = m_internalBitDepth[0]; }
    190   if (!m_inputBitDepth[1])    { m_inputBitDepth[1]    = m_inputBitDepth[0]; }
    191   if (!m_outputBitDepth[0])   { m_outputBitDepth[0]   = m_internalBitDepth[0]; }
    192   if (!m_outputBitDepth[1])   { m_outputBitDepth[1]   = m_internalBitDepth[1]; }
    193 
    194   UInt  uiInputBitDepth   = 8;
    195   UInt  uiCamParPrecision = 5;
    196 
    197   m_bUseSetupString = ( m_pchViewConfig != NULL ) && ( m_iRenderMode != 0);
    198 
    199   if ( m_iRenderMode == 10 )
    200   {
    201     m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
    202       m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, NULL, m_iLog2SamplingFactor+m_iShiftPrecision );
    203     m_iNumberOfInputViews  = (Int) m_cCameraData.getBaseViewNumbers() .size();
    204     m_iNumberOfOutputViews = m_iNumberOfInputViews - 1;
    205     m_iRenderDirection     = 1;
    206   }
    207   else
    208   {
    209   if ( m_bUseSetupString )
    210   {
    211     std::vector<Int>  iaTempViews;
    212     std::vector<Int>* piaTempViews;
    213     m_cCameraData     .convertNumberString( m_pchBaseViewCameraNumbers, iaTempViews, VIEW_NUM_PREC );
    214     m_cRenModStrParser.setString( (Int) iaTempViews.size(), m_pchViewConfig );
    215     piaTempViews               = m_cRenModStrParser.getSynthViews();
    216     m_iNumberOfOutputViews     = (Int) m_cRenModStrParser.getNumOfModels();
    217     m_iNumberOfInputViews      = (Int) m_cRenModStrParser.getNumOfBaseViews();
    218     m_bContOutputFileNumbering = true;
    219 
    220   m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
    221       m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, piaTempViews, m_iLog2SamplingFactor+m_iShiftPrecision );
    222   }
    223   else
    224   {
    225   m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
    226       m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, m_pchSynthViewCameraNumbers, NULL, m_iLog2SamplingFactor+m_iShiftPrecision );
    227   m_iNumberOfOutputViews = (Int) m_cCameraData.getSynthViewNumbers().size();
    228   m_iNumberOfInputViews  = (Int) m_cCameraData.getBaseViewNumbers() .size();
    229   }
    230   }
    231 
    232   if (m_pchSynthOutputFileBaseName != NULL)
    233     xConfirmParameter( strrchr(m_pchSynthOutputFileBaseName,'$')  == 0, "'$' must be a character in SynthOutputFileBaseName");
    234 
    235   if (m_pchDepthInputFileBaseName != NULL)
    236     xConfirmParameter( strrchr(m_pchDepthInputFileBaseName, '$')  == 0, "'$' must be a character in DepthInputFileBaseName" );
    237 
    238   if (m_pchVideoInputFileBaseName != NULL)
    239     xConfirmParameter( strrchr(m_pchVideoInputFileBaseName, '$')  == 0, "'$' must be a character in VideoInputFileBaseName" );
    240 
    241   xCreateFileNames();
    242 
    243   /*
    244   * check validity of input parameters
    245   */
    246   xCheckParameter();
    247   m_cCameraData.check( m_iRenderDirection == 0, m_iFramesToBeRendered != 0 );
    248 
    249   // print-out parameters
    250   xPrintParameter();
    251 
    252   return true;
    253 }
    254 
    255 
    256 // ====================================================================================================================
    257 // Private member functions
    258 // ====================================================================================================================
    259 
    260 Void TAppRendererCfg::xCheckParameter()
    261 {
    262   bool check_failed = false; /* abort if there is a fatal configuration problem */
    263 #define xConfirmPara(a,b) check_failed |= xConfirmParameter(a,b)
    264   // check range of parameters
    265 
    266   /// File I/O
    267 
    268   // source specification
    269   xConfirmPara( m_iSourceWidth        <= 0,                   "Source width  must be greater than 0" );
    270   xConfirmPara( m_iSourceHeight       <= 0,                   "Source height must be greater than 0" );
    271   xConfirmPara( m_iFrameSkip          <  0,                   "Frame Skipping must be more than or equal to 0" );
    272   xConfirmPara( m_iFramesToBeRendered <  0,                   "Total Number Of Frames rendered must be more than 1" );
    273 
    274   // bit depth
    275   xConfirmPara( m_internalBitDepth[0] != m_internalBitDepth[1],  "InternalBitDepth for luma and chroma must be equal. ");
    276   xConfirmPara( m_inputBitDepth[0] < 8,                        "InputBitDepth must be at least 8" );
    277   xConfirmPara( m_inputBitDepth[1] < 8,                        "InputBitDepthC must be at least 8" );
    278 
    279   // camera specification
    280   xConfirmPara( m_iNumberOfInputViews  > MAX_INPUT_VIEW_NUM , "NumberOfInputViews must be less than of equal to MAX_INPUT_VIEW_NUM");
    281   xConfirmPara( m_iNumberOfOutputViews > MAX_OUTPUT_VIEW_NUM, "NumberOfOutputViews must be less than of equal to MAX_OUTPUT_VIEW_NUM");
    282 
    283 
    284   xConfirmPara( m_iRenderDirection < 0 || m_iRenderDirection > 2  , "RenderDirection must be greater than or equal to 0 and less than 3");
    285   xConfirmPara(m_iNumberOfOutputViews < 1,                    "Number of OutputViews must be greater or equal to 1");
    286   if ( m_iRenderDirection == 0 )
    287   {
    288     xConfirmPara( m_iNumberOfInputViews < 2,                  "Number of InputViews must be more than or equal to 2");
    289   }
    290   else
    291   {
    292     xConfirmPara( m_iNumberOfInputViews < 1,                  "Number of InputViews must be more than or equal to 1");
    293   }
    294 
    295   xConfirmPara( m_iLog2SamplingFactor < 0 || m_iLog2SamplingFactor >  4, "Log2SamplingFactor must be more than or equal to 0 and less than 5"  );
    296   xConfirmPara( m_iPreProcMode        < 0 || m_iPreProcMode        >  1, "PreProcMode        must be more than or equal to 0 and less than 2"  );
    297 
    298 
    299   xConfirmPara( m_iPreFilterSize      < 0 || m_iPreFilterSize      >  3, "PreFilterSize      must be more than or equal to 0 and less than 4" );
    300   xConfirmPara( m_iBlendMode          < 0 || m_iBlendMode          >  3, "BlendMode          must be more than or equal to 0 and less than 4"  );
    301   xConfirmPara( m_iBlendZThresPerc    < 0 || m_iBlendZThresPerc    > 100,"BlendZThresPerc    must be more than or equal to 0 and less than 101"  );
    302   xConfirmPara( m_iBlendHoleMargin    < 0 || m_iBlendHoleMargin    >  20,"BlendHoleMargin    must be more than or equal to 0 and less than 19"  );
    303   xConfirmPara( m_iInterpolationMode  < 0 || m_iInterpolationMode  >  4, "InterpolationMode  must be more than or equal to 0 and less than 5"  );
    304   xConfirmPara( m_iHoleFillingMode    < 0 || m_iHoleFillingMode    >  1, "HoleFillingMode    must be more than or equal to 0 and less than 2"  );
    305   xConfirmPara( m_iPostProcMode       < 0 || m_iPostProcMode       >  2, "PostProcMode       must be more than or equal to 0 and less than 3"  );
    306 
    307   Int iNumNonNULL;
    308   for (iNumNonNULL = 0; (iNumNonNULL < m_iNumberOfInputViews)  && m_pchDepthInputFileList[iNumNonNULL]; iNumNonNULL++) {};  xConfirmPara( iNumNonNULL < m_iNumberOfInputViews,  "Number of DepthInputFiles  must be greater than or equal to number of BaseViewNumbers" );
    309   for (iNumNonNULL = 0; (iNumNonNULL < m_iNumberOfInputViews)  && m_pchVideoInputFileList[iNumNonNULL]; iNumNonNULL++) {};  xConfirmPara( iNumNonNULL < m_iNumberOfInputViews,  "Number of DepthInputFiles  must be greater than or equal to number of BaseViewNumbers" );
    310 
    311 
    312   if ( !m_bSweep )
    313   {
    314     for (iNumNonNULL = 0; (iNumNonNULL < m_iNumberOfOutputViews) && m_pchSynthOutputFileList[iNumNonNULL]; iNumNonNULL++) {}; xConfirmPara( iNumNonNULL < m_iNumberOfOutputViews, "Number of SynthOutputFiles must be greater than or equal to number of SynthViewNumbers" );
    315   }
    316   else
    317   {
    318       xConfirmPara( iNumNonNULL < 1, "Number of SynthOutputFiles must be equal to or more than 1" );
    319   }
    320 
    321 #undef xConfirmPara
    322   if ( check_failed )
    323   {
    324     exit(EXIT_FAILURE);
    325   }
    326 
    327 }
    328 
    329 
    330 
    331 Void TAppRendererCfg::xPrintParameter()
    332 {
    333   printf("\n");
    334   for( Int iCounter = 0; iCounter < m_iNumberOfInputViews; iCounter++)
    335   {
    336     printf("InputVideoFile_%i        : %s\n", iCounter, m_pchVideoInputFileList[iCounter]);
    337   }
    338   for( Int iCounter = 0; iCounter < m_iNumberOfInputViews; iCounter++)
    339   {
    340     printf("InputDepthFile_%i        : %s\n", iCounter, m_pchDepthInputFileList[iCounter]);
    341   }
    342 
    343   for( Int iCounter = 0; iCounter < m_iNumberOfOutputViews; iCounter++)
    344   {
    345     printf("SynthOutputFile_%i       : %s\n", iCounter, m_pchSynthOutputFileList[iCounter]);
    346   }
    347 
    348   printf("Format                  : %dx%d \n", m_iSourceWidth, m_iSourceHeight );
    349   printf("Frame index             : %d - %d (%d frames)\n", m_iFrameSkip, m_iFrameSkip+m_iFramesToBeRendered-1, m_iFramesToBeRendered);
    350   printf("CameraParameterFile     : %s\n", m_pchCameraParameterFile );
    351   printf("BaseViewNumbers         : %s  (%d views) \n", m_pchBaseViewCameraNumbers , m_iNumberOfInputViews  );
    352   printf("Sweep                   : %d\n", m_bSweep               );
    353 
    354   if ( m_bUseSetupString )
    355   {
    356     printf("ViewConfig              : %s\n", m_pchViewConfig );
    357   }
    358   else
    359   {
    360   printf("SynthViewNumbers        : %s  (%d views) \n", m_pchSynthViewCameraNumbers, m_iNumberOfOutputViews );
    361   }
    362 
    363   printf("Log2SamplingFactor      : %d\n", m_iLog2SamplingFactor );
    364   printf("UVUp                    : %d\n", m_bUVUp               );
    365   printf("PreProcMode             : %d\n", m_iPreProcMode        );
    366   printf("PreFilterSize           : %d\n", m_iPreFilterSize      );
    367   printf("SimEnhance              : %d\n", m_bSimEnhance         );
    368   printf("BlendMode               : %d\n", m_iBlendMode          );
    369   printf("BlendZThresPerc         : %d\n", m_iBlendZThresPerc    );
    370   printf("BlendUseDistWeight      : %d\n", m_bBlendUseDistWeight );
    371   printf("BlendHoleMargin         : %d\n", m_iBlendHoleMargin    );
    372   printf("InterpolationMode       : %d\n", m_iInterpolationMode  );
    373   printf("HoleFillingMode         : %d\n", m_iHoleFillingMode    );
    374   printf("PostProcMode            : %d\n", m_iPostProcMode       );
    375   printf("ShiftPrecision          : %d\n", m_iShiftPrecision     );
    376   printf("TemporalDepthFilter     : %d\n", m_bTempDepthFilter    );
    377   printf("RenderMode              : %d\n", m_iRenderMode         );
    378   printf("RendererDirection       : %d\n", m_iRenderDirection       );
    379 
    380   if (m_iRenderMode == 10 )
    381   {
    382     printf("UsedPelMapMarExt        : %d\n", m_iUsedPelMapMarExt );
    383   }
    384 
    385   printf("\n");
    386 
    387   //  printf("TOOL CFG: ");
    388   //  printf("ALF:%d ", m_bUseALF             );
    389   //  printf("\n");
    390 
    391   fflush(stdout);
    392 }
    393 
    394 Void TAppRendererCfg::xPrintUsage()
    395 {
    396   printf( "\n" );
    397   printf( "  Example: TAppRenderer.exe -c test.cfg\n\n");
    398 }
    399 
    400 Bool TAppRendererCfg::xConfirmParameter(Bool bflag, const char* message)
    401 {
    402   if (!bflag)
    403     return false;
    404 
    405   printf("Error: %s\n",message);
    406   return true;
    407 }
    408 
    409 
    410 Void TAppRendererCfg::xCreateFileNames()
    411 {
    412   if ( m_iRenderMode == 10 )
    413     return;
    414 
    415   Int iPrecBefore;
    416   Int iPrecAfter;
    417 
    418   xGetMaxPrecision( m_cCameraData.getSynthViewNumbers(), iPrecBefore, iPrecAfter );
    419 
    420 
    421   if (iPrecBefore > LOG10_VIEW_NUM_PREC )
    422   {
    423     std::cerr << "Error: View Numbers with more than " << LOG10_VIEW_NUM_PREC << " digits are not supported" << std::endl;
    424     exit(EXIT_FAILURE);
    425   }
    426 
    427   AOT( !m_bContOutputFileNumbering && (m_cCameraData.getSynthViewNumbers().size() != m_iNumberOfOutputViews ));
    428   for(Int iIdx = 0; iIdx < m_iNumberOfOutputViews; iIdx++)
    429   {
    430     //GT; Create ReconFileNames
    431     if (m_pchSynthOutputFileList[iIdx] == NULL )
    432     {
    433       if ( m_bContOutputFileNumbering )
    434       {
    435         xAddNumberToFileName( m_pchSynthOutputFileBaseName, m_pchSynthOutputFileList[iIdx], (Int) ((iIdx+1) * VIEW_NUM_PREC) , 2, 0  );
    436       }
    437       else
    438       {
    439         xAddNumberToFileName( m_pchSynthOutputFileBaseName, m_pchSynthOutputFileList[iIdx], m_cCameraData.getSynthViewNumbers()[iIdx], iPrecBefore, iPrecAfter  );
    440       }
    441     }
    442   }
    443 
    444   xGetMaxPrecision( m_cCameraData.getBaseViewNumbers(), iPrecBefore, iPrecAfter );
    445   for(Int iIdx = 0; iIdx < m_cCameraData.getBaseViewNumbers().size() ; iIdx++)
    446   {
    447     //GT; Create ReconFileNames
    448     if (m_pchVideoInputFileList[iIdx] == NULL )
    449     {
    450       xAddNumberToFileName( m_pchVideoInputFileBaseName, m_pchVideoInputFileList[iIdx], m_cCameraData.getBaseViewNumbers()[iIdx], iPrecBefore, iPrecAfter  );
    451     }
    452 
    453     if (m_pchDepthInputFileList[iIdx] == NULL )
    454     {
    455       xAddNumberToFileName( m_pchDepthInputFileBaseName, m_pchDepthInputFileList[iIdx], m_cCameraData.getBaseViewNumbers()[iIdx], iPrecBefore, iPrecAfter  );
    456     }
    457   }
    458 }
    459 
    460 Void TAppRendererCfg::xAddNumberToFileName( TChar* pchSourceFileName, TChar*& rpchTargetFileName, Int iNumberToAdd, UInt uiPrecBefore, UInt uiPrecAfter )
    461 {
    462 
    463   if ( pchSourceFileName == NULL )
    464   {
    465     std::cerr << "No BaseName for file name generation given." << std::endl;
    466     AOT(true);
    467     exit(EXIT_FAILURE);
    468   }
    469 
    470   TChar pchNumberBuffer[2* LOG10_VIEW_NUM_PREC + 2];
    471   TChar pchPrintBuffer[10];
    472 
    473   Double dNumberToAdd = ( (Double) iNumberToAdd ) / VIEW_NUM_PREC;
    474 
    475   UInt uiWidth = uiPrecBefore;
    476 
    477   if (uiPrecAfter != 0)
    478   {
    479     uiWidth += uiPrecAfter + 1;
    480   }
    481 
    482   sprintf( pchPrintBuffer, "%%0%d.%df", uiWidth, uiPrecAfter );
    483   sprintf( pchNumberBuffer, pchPrintBuffer, dNumberToAdd );
    484 
    485   if ( uiPrecAfter > 0 ) pchNumberBuffer[ uiPrecBefore ] = '_';
    486 
    487   size_t iInLength  = strlen(pchSourceFileName);
    488   size_t iAddLength = strlen(pchNumberBuffer);
    489 
    490   rpchTargetFileName = (TChar*) malloc(iInLength+iAddLength+1);
    491 
    492   TChar* pchPlaceHolder = strrchr(pchSourceFileName,'$');
    493   assert( pchPlaceHolder );
    494 
    495   size_t iCharsToPlaceHolder = pchPlaceHolder - pchSourceFileName;
    496   size_t iCharsToEnd         = iInLength      - iCharsToPlaceHolder;
    497 
    498   strncpy(rpchTargetFileName                               , pchSourceFileName                      , iCharsToPlaceHolder);
    499   strncpy(rpchTargetFileName+iCharsToPlaceHolder           , pchNumberBuffer                        , iAddLength         );
    500   strncpy(rpchTargetFileName+iCharsToPlaceHolder+iAddLength, pchSourceFileName+iCharsToPlaceHolder+1, iCharsToEnd-1      );
    501   rpchTargetFileName[iInLength+iAddLength-1] = '\0';
    502 }
    503 
    504 Void TAppRendererCfg::xGetMaxPrecision( IntAry1d aiIn, Int& iPrecBefore, Int& iPrecAfter )
    505 {
    506   iPrecBefore = 0;
    507   iPrecAfter  = 0;
    508 
    509   for (UInt uiK = 0; uiK < aiIn.size(); uiK ++ )
    510   {
    511     if ( aiIn[uiK] == 0 ) continue;
    512 
    513     Int iCurPrec;
    514     iCurPrec = 0;
    515     for ( Int iCur = aiIn[uiK]; iCur != 0; iCur /= 10, iCurPrec++ );
    516     iPrecBefore = max(iPrecBefore, iCurPrec - LOG10_VIEW_NUM_PREC );
    517 
    518     iCurPrec = 0;
    519     for ( Int iCur = 1;  aiIn[uiK] % iCur == 0; iCur *= 10, iCurPrec++);
    520     iCurPrec = LOG10_VIEW_NUM_PREC - std::min((Int) LOG10_VIEW_NUM_PREC, iCurPrec-1 );
    521     iPrecAfter = max(iPrecAfter, iCurPrec );
    522   }
    523 }
    524 
    525 #endif
  • branches/HTM-16.0-MV-draft-5/source/App/TAppRenderer/TAppRendererCfg.h

    r1386 r1390  
    4747#include <vector>
    4848
    49 #if NH_3D_VSO
    50 
    51 // ====================================================================================================================
    52 // Class definition
    53 // ====================================================================================================================
    54 
    55 /// encoder configuration class
    56 class TAppRendererCfg
    57 {
    58 protected:
    59 
    60   //// file I/O ////
    61   TChar*             m_pchVideoInputFileBaseName;      ///< input video  file base name, placeholder for numbering $$
    62   TChar*             m_pchDepthInputFileBaseName;      ///< input depth  file base name, placeholder for numbering $$
    63   TChar*             m_pchSynthOutputFileBaseName;     ///< output synth file base name, placeholder for numbering $$
    64   Bool               m_bContOutputFileNumbering;       ///< use continous numbering instead of view numbering
    65   Bool               m_bSweep;                         ///< 1: Store view range in file
    66 
    67 
    68   // bit-depth      ( Currently internal, output and input luma and chroma bit-depth are required to be equal to 8 )
    69   Int                m_inputBitDepth[2];               ///< bit-depth of input file (luma/chroma component) 
    70   Int                m_outputBitDepth[2];              ///< bit-depth of output file (luma/chroma component)   
    71   Int                m_internalBitDepth[2];            ///< bit-depth renderer operates at in luma/chroma (input/output files will be converted)
    72 
    73 
    74   // derived
    75   std::vector<TChar*> m_pchVideoInputFileList;         ///< source file names
    76   std::vector<TChar*> m_pchDepthInputFileList;         ///< source depth file names
    77   std::vector<TChar*> m_pchSynthOutputFileList;        ///< output reconstruction file names
    78 
    79   //// source specification ////
    80   Int                m_iSourceWidth;                   ///< source width in pixel
    81   Int                m_iSourceHeight;                  ///< source height in pixel
    82   Int                m_iFrameSkip;                     ///< number of skipped frames from the beginning
    83   Int                m_iFramesToBeRendered;            ///< number of rendered frames
    84 
    85   ////camera specification ////
    86   TChar*             m_pchCameraParameterFile;         ///< camera parameter file
    87   TChar*             m_pchSynthViewCameraNumbers;      ///< numbers of views to synthesize
    88   TChar*             m_pchViewConfig;                  ///< String to setup renderer
    89   TChar*             m_pchBaseViewCameraNumbers;       ///< numbers of base views
    90 
    91   // derived
    92   TAppComCamPara      m_cCameraData;                    ///< class to store camera parameters
    93   TRenModSetupStrParser m_cRenModStrParser;             ///< class to manage View to be rendered
    94   Bool                m_bUseSetupString;                ///< true if setup string is used
    95 
    96   Int                 m_iNumberOfInputViews;            ///< number of input Views
    97   Int                 m_iNumberOfOutputViews;           ///< number views to synthesize
    98 
    99   //// renderer Modes ////
    100   Int                 m_iRenderDirection;               ///< 0: interpolate, 1: extrapolate from left, 2: extrapolate from right
    101 
    102   Int                 m_iLog2SamplingFactor;            ///< factor for horizontal upsampling before processing
    103   Bool                m_bUVUp;                          ///< upsampling of chroma planes before processing
    104   Int                 m_iPreProcMode;                   ///< depth pre-processing: 0 = none, 1 = binominal filtering
    105   Int                 m_iPreFilterSize;                 ///< for PreProcMode = 1: size of filter kernel
    106   Bool                m_bSimEnhance;                    ///< Similarity enhancement before blending
    107   Int                 m_iBlendMode;                     ///< merging of left and right image: 0 = average, 1 = only holes from right, 2 = only holes from left
    108   Int                 m_iBlendZThresPerc;               ///< z-difference threshold for blending in percent of total z-range
    109   Bool                m_bBlendUseDistWeight;            ///< 0: blend using average; 1: blend factor depends on view distance
    110   Int                 m_iBlendHoleMargin;               ///< Margin around boundaries
    111   Bool                m_bTempDepthFilter;               ///< Zheijang temporal enhancement filter
    112   Int                 m_iInterpolationMode;             ///< 0: NN, 1: linear, 2: cspline
    113   Int                 m_iHoleFillingMode;               ///< 0: none, 1: line wise background extension
    114   Int                 m_iPostProcMode;                  ///< 0: none, 1: horizontal 3-tap median
    115   Int                 m_iRenderMode;                      ///< 0: use renderer
    116   Int                 m_iShiftPrecision;                ///< Precision used for Interpolation Mode 4
    117   Int                 m_iUsedPelMapMarExt;              ///< Used Pel map extra margin
    118 
    119   Void xCheckParameter ();                              ///< check validity of configuration values
    120   Void xPrintParameter ();                              ///< print configuration values
    121   Void xPrintUsage     ();                              ///< print usage
    122 
    123   Void xCreateFileNames();
    124   Void xGetMaxPrecision( IntAry1d adIn, Int& iPrecBefore, Int& iPrecAfter );
    125   Void xAddNumberToFileName( TChar* pchSourceFileName, TChar*& rpchTargetFileName, Int iNumberToAdd, UInt uiPrecBefore, UInt uiPrecAfter );
    126 public:
    127   TAppRendererCfg();
    128   virtual ~TAppRendererCfg();
    129 
    130 public:
    131   Void  create    ();                                         ///< create option handling class
    132   Void  destroy   ();                                         ///< destroy option handling class
    133   Bool  parseCfg  ( Int argc, TChar* argv[] );                 ///< parse configuration file to fill member variables
    134   Bool  xConfirmParameter(Bool bflag, const TChar* message);
    135 
    136 
    137 };// END CLASS DEFINITION TAppRendererCfg
    138 
    139 #endif // __TAppRENDERERCFG__
    14049#endif // NH_3D
  • branches/HTM-16.0-MV-draft-5/source/App/TAppRenderer/TAppRendererTop.cpp

    r1386 r1390  
    4141#include "TAppRendererTop.h"
    4242
    43 #if NH_3D_VSO
    44 
    45 // ====================================================================================================================
    46 // Constructor / destructor / initialization / destroy
    47 // ====================================================================================================================
    48 
    49 TAppRendererTop::TAppRendererTop()
    50 {
    51 
    52 }
    53 
    54 TAppRendererTop::~TAppRendererTop()
    55 {
    56 
    57 }
    58 
    59 
    60 Void TAppRendererTop::xCreateLib()
    61 {
    62   m_pcRenTop = new TRenTop();
    63 
    64   for(Int iViewIdx=0; iViewIdx<m_iNumberOfInputViews; iViewIdx++)
    65   {
    66     TVideoIOYuv* pcVideoInput = new TVideoIOYuv;
    67     TVideoIOYuv* pcDepthInput = new TVideoIOYuv;
    68 
    69 //    ( Char* pchFile, Bool bWriteMode, const Int fileBitDepth[MAX_NUM_CHANNEL_TYPE], const Int MSBExtendedBitDepth[MAX_NUM_CHANNEL_TYPE], const Int internalBitDepth[MAX_NUM_CHANNEL_TYPE] )
    70 
    71     pcVideoInput->open( m_pchVideoInputFileList[iViewIdx], false, m_inputBitDepth, m_internalBitDepth, m_internalBitDepth );  // read mode
    72     pcDepthInput->open( m_pchDepthInputFileList[iViewIdx], false, m_inputBitDepth, m_internalBitDepth, m_internalBitDepth );  // read mode
    73     pcVideoInput->skipFrames(m_iFrameSkip, m_iSourceWidth, m_iSourceHeight, CHROMA_420 );
    74     pcDepthInput->skipFrames(m_iFrameSkip, m_iSourceWidth, m_iSourceHeight, CHROMA_420 );
    75 
    76     m_apcTVideoIOYuvVideoInput.push_back( pcVideoInput );
    77     m_apcTVideoIOYuvDepthInput.push_back( pcDepthInput );
    78   }
    79 
    80   for(Int iViewIdx=0; iViewIdx<m_iNumberOfOutputViews; iViewIdx++)
    81   {
    82     TVideoIOYuv* pcSynthOutput = new TVideoIOYuv;
    83     pcSynthOutput->open( m_pchSynthOutputFileList[iViewIdx], true, m_outputBitDepth, m_internalBitDepth, m_internalBitDepth );  // write mode
    84     m_apcTVideoIOYuvSynthOutput.push_back( pcSynthOutput );
    85   }
    86 }
    87 
    88 
    89 Void TAppRendererTop::xDestroyLib()
    90 {
    91   delete m_pcRenTop;
    92 
    93   for ( Int iViewIdx = 0; iViewIdx < m_iNumberOfInputViews; iViewIdx++ )
    94   {
    95     m_apcTVideoIOYuvVideoInput[iViewIdx]->close();
    96     m_apcTVideoIOYuvDepthInput[iViewIdx]->close();
    97 
    98     delete m_apcTVideoIOYuvDepthInput[iViewIdx];
    99     delete m_apcTVideoIOYuvVideoInput[iViewIdx];
    100   };
    101 
    102   for ( Int iViewIdx = 0; iViewIdx < m_iNumberOfOutputViews; iViewIdx++ )
    103   {
    104     m_apcTVideoIOYuvSynthOutput[iViewIdx]->close();
    105     delete m_apcTVideoIOYuvSynthOutput[iViewIdx];
    106   };
    107 }
    108 
    109 Void TAppRendererTop::xInitLib()
    110 {
    111     m_pcRenTop->init(
    112     m_iSourceWidth,
    113     m_iSourceHeight,
    114     (m_iRenderDirection != 0),
    115     m_iLog2SamplingFactor,
    116     m_iLog2SamplingFactor+m_iShiftPrecision,
    117     m_bUVUp,
    118     m_iPreProcMode,
    119     m_iPreFilterSize,
    120     m_iBlendMode,
    121     m_iBlendZThresPerc,
    122     m_bBlendUseDistWeight,
    123     m_iBlendHoleMargin,
    124     m_iInterpolationMode,
    125     m_iHoleFillingMode,
    126     m_iPostProcMode,
    127     m_iUsedPelMapMarExt
    128     );
    129 }
    130 
    131 // ====================================================================================================================
    132 // Public member functions
    133 // ====================================================================================================================
    134 
    135 
    136 
    137 Void TAppRendererTop::render()
    138 {
    139   xCreateLib();
    140   xInitLib();
    141 
    142   // Create Buffers Input Views;
    143   std::vector<TComPicYuv*> apcPicYuvBaseVideo;
    144   std::vector<TComPicYuv*> apcPicYuvBaseDepth;
    145 
    146   // TemporalImprovement Filter
    147   std::vector<TComPicYuv*> apcPicYuvLastBaseVideo;
    148   std::vector<TComPicYuv*> apcPicYuvLastBaseDepth;
    149 
    150   Int aiPad[2] = { 0, 0 };
    151 
    152   TComPicYuv* pcNewOrg = new TComPicYuv;
    153   pcNewOrg->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    154 
    155   for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ )
    156   {
    157     TComPicYuv* pcNewVideoPic = new TComPicYuv;
    158     TComPicYuv* pcNewDepthPic = new TComPicYuv;
    159 
    160     pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    161     apcPicYuvBaseVideo.push_back(pcNewVideoPic);
    162 
    163     pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true);
    164     apcPicYuvBaseDepth.push_back(pcNewDepthPic);
    165 
    166     //Temporal improvement Filter
    167     if ( m_bTempDepthFilter )
    168     {
    169       pcNewVideoPic = new TComPicYuv;
    170       pcNewDepthPic = new TComPicYuv;
    171 
    172       pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    173       apcPicYuvLastBaseVideo.push_back(pcNewVideoPic);
    174 
    175       pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    176       apcPicYuvLastBaseDepth.push_back(pcNewDepthPic);
    177     }
    178   }
    179 
    180   // Create Buffer for synthesized View
    181   TComPicYuv* pcPicYuvSynthOut = new TComPicYuv;
    182   pcPicYuvSynthOut->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    183 
    184   Bool bAnyEOS = false;
    185 
    186   Int iNumOfRenderedFrames = 0;
    187   Int iFrame = 0;
    188 
    189   while ( ( ( iNumOfRenderedFrames < m_iFramesToBeRendered ) || ( m_iFramesToBeRendered == 0 ) ) && !bAnyEOS )
    190   {
    191     if ( iFrame >= m_iFrameSkip )
    192     {
    193       // read in depth and video
    194       for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    195       {
    196         m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx],pcNewOrg, IPCOLOURSPACE_UNCHANGED, aiPad, CHROMA_420  ) ;
    197 
    198         apcPicYuvBaseVideo[iBaseViewIdx]->extendPicBorder();
    199 
    200         bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof();
    201 
    202         m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx],pcNewOrg, IPCOLOURSPACE_UNCHANGED, aiPad, CHROMA_420  ) ;
    203         apcPicYuvBaseDepth[iBaseViewIdx]->extendPicBorder();
    204         bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof();
    205 
    206         if ( m_bTempDepthFilter && (iFrame >= m_iFrameSkip) )
    207         {
    208           m_pcRenTop->temporalFilterVSRS( apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], apcPicYuvLastBaseVideo[iBaseViewIdx], apcPicYuvLastBaseDepth[iBaseViewIdx], ( iFrame == m_iFrameSkip) );
    209         }
    210       }
    211     }
    212     else   
    213     {
    214       std::cout << "Skipping Frame " << iFrame << std::endl;
    215 
    216       iFrame++;
    217       continue;
    218     }
    219 
    220     m_cCameraData.update( (UInt)iFrame - m_iFrameSkip );
    221 
    222     for(Int iSynthViewIdx=0; iSynthViewIdx < m_iNumberOfOutputViews; iSynthViewIdx++ )
    223     {
    224       Int  iLeftBaseViewIdx  = -1;
    225       Int  iRightBaseViewIdx = -1;
    226 
    227       Bool bIsBaseView = false;
    228 
    229       Int iRelDistToLeft;
    230       Bool bHasLRView = m_cCameraData.getLeftRightBaseView( iSynthViewIdx, iLeftBaseViewIdx, iRightBaseViewIdx, iRelDistToLeft, bIsBaseView );
    231       Bool bHasLView = ( iLeftBaseViewIdx != -1 );
    232       Bool bHasRView = ( iRightBaseViewIdx != -1 );
    233       Bool bRender   = true;
    234 
    235       Int  iBlendMode = m_iBlendMode;
    236       Int  iSimEnhBaseView = 0;
    237 
    238       switch( m_iRenderDirection )
    239       {
    240       /// INTERPOLATION
    241       case 0:
    242         AOF( bHasLRView || bIsBaseView );
    243 
    244         if ( !bHasLRView && bIsBaseView && m_iBlendMode == 0 )
    245         {
    246           bRender = false;
    247         }
    248         else
    249         {
    250           if ( bIsBaseView )
    251           {
    252             AOF( iLeftBaseViewIdx == iRightBaseViewIdx );
    253             Int iSortedBaseViewIdx = m_cCameraData.getBaseId2SortedId() [iLeftBaseViewIdx];
    254 
    255             if ( m_iBlendMode == 1 )
    256             {
    257               if ( iSortedBaseViewIdx - 1 >= 0 )
    258               {
    259                 iLeftBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iSortedBaseViewIdx - 1];
    260                 bRender = true;
    261               }
    262               else
    263               {
    264                 bRender = false;
    265               }
    266             }
    267             else if ( m_iBlendMode == 2 )
    268             {
    269               if ( iSortedBaseViewIdx + 1 < m_iNumberOfInputViews )
    270               {
    271                 iRightBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iSortedBaseViewIdx + 1];
    272                 bRender = true;
    273               }
    274               else
    275               {
    276                 bRender = false;
    277               }
    278             }
    279           }
    280 
    281           if ( m_iBlendMode == 3 )
    282           {
    283             if ( bIsBaseView && (iLeftBaseViewIdx == 0) )
    284             {
    285               bRender = false;
    286             }
    287             else
    288             {
    289               Int iDistLeft  = abs( m_cCameraData.getBaseId2SortedId()[0] - m_cCameraData.getBaseId2SortedId() [iLeftBaseViewIdx ]  );
    290               Int iDistRight = abs( m_cCameraData.getBaseId2SortedId()[0] - m_cCameraData.getBaseId2SortedId() [iRightBaseViewIdx]  );
    291 
    292               Int iFillViewIdx = iDistLeft > iDistRight ? iLeftBaseViewIdx : iRightBaseViewIdx;
    293 
    294               if( m_cCameraData.getBaseId2SortedId()[0] < m_cCameraData.getBaseId2SortedId() [iFillViewIdx] )
    295               {
    296                 iBlendMode        = 1;
    297                 iLeftBaseViewIdx  = 0;
    298                 iRightBaseViewIdx = iFillViewIdx;
    299               }
    300               else
    301               {
    302                 iBlendMode        = 2;
    303                 iLeftBaseViewIdx  = iFillViewIdx;
    304                 iRightBaseViewIdx = 0;
    305               }
    306 
    307             }
    308           }
    309           else
    310           {
    311             iBlendMode = m_iBlendMode;
    312           }
    313         }
    314 
    315         if ( m_bSimEnhance )
    316         {
    317           if ( m_iNumberOfInputViews == 3 && m_cCameraData.getRelSynthViewNumbers()[ iSynthViewIdx ] < VIEW_NUM_PREC  )
    318           {
    319             iSimEnhBaseView = 2; // Take middle view
    320           }
    321           else
    322           {
    323             iSimEnhBaseView = 1; // Take left view
    324           }
    325         }
    326 
    327           if ( bRender )
    328           {
    329           std::cout << "Rendering Frame "    << iFrame
    330                     << " of View "           << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx    ] / VIEW_NUM_PREC
    331                     << "   Left BaseView: "  << (Double) m_cCameraData.getBaseViewNumbers() [iLeftBaseViewIdx ] / VIEW_NUM_PREC
    332                     << "   Right BaseView: " << (Double) m_cCameraData.getBaseViewNumbers() [iRightBaseViewIdx] / VIEW_NUM_PREC
    333                     << "   BlendMode: "      << iBlendMode
    334                     << std::endl;
    335 
    336           m_pcRenTop->setShiftLUTs(
    337             m_cCameraData.getSynthViewShiftLUTD()[iLeftBaseViewIdx ][iSynthViewIdx],
    338             m_cCameraData.getSynthViewShiftLUTI()[iLeftBaseViewIdx ][iSynthViewIdx],
    339             m_cCameraData.getBaseViewShiftLUTI ()[iLeftBaseViewIdx ][iRightBaseViewIdx],
    340             m_cCameraData.getSynthViewShiftLUTD()[iRightBaseViewIdx][iSynthViewIdx],
    341             m_cCameraData.getSynthViewShiftLUTI()[iRightBaseViewIdx][iSynthViewIdx],
    342             m_cCameraData.getBaseViewShiftLUTI ()[iRightBaseViewIdx][iLeftBaseViewIdx ],
    343 
    344             iRelDistToLeft
    345           );
    346 
    347           m_pcRenTop->interpolateView(
    348             apcPicYuvBaseVideo[iLeftBaseViewIdx ],
    349             apcPicYuvBaseDepth[iLeftBaseViewIdx ],
    350             apcPicYuvBaseVideo[iRightBaseViewIdx],
    351             apcPicYuvBaseDepth[iRightBaseViewIdx],
    352             pcPicYuvSynthOut,
    353             iBlendMode,
    354             iSimEnhBaseView
    355             );
    356         }
    357         else
    358         {
    359           AOT(iLeftBaseViewIdx != iRightBaseViewIdx );
    360           apcPicYuvBaseVideo[iLeftBaseViewIdx]->copyToPic( pcPicYuvSynthOut );
    361           std::cout << "Copied    Frame " << iFrame
    362                     << " of View "        << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC
    363                     << "   (BaseView)  "    << std::endl;
    364         }
    365 
    366         break;
    367       /// EXTRAPOLATION FROM LEFT
    368       case 1:
    369         if ( !bHasLView ) // View to render is BaseView
    370         {
    371           bRender = false;
    372         }
    373 
    374           if (  bIsBaseView )
    375           {
    376           AOF( iLeftBaseViewIdx == iRightBaseViewIdx );
    377           Int iSortedBaseViewIdx = m_cCameraData.getBaseId2SortedId() [iLeftBaseViewIdx];
    378           if ( iSortedBaseViewIdx - 1 >= 0 )
    379           {
    380             iLeftBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iSortedBaseViewIdx - 1];
    381           }
    382           else
    383           {
    384             std::cout << "Copied    Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC  << std::endl;
    385             apcPicYuvBaseVideo[iLeftBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original
    386             bRender = false;
    387           }
    388         }
    389 
    390 
    391         if (bRender)
    392         {
    393           std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC  << std::endl;
    394           m_pcRenTop->setShiftLUTs( m_cCameraData.getSynthViewShiftLUTD()[iLeftBaseViewIdx ][iSynthViewIdx],
    395             m_cCameraData.getSynthViewShiftLUTI()[iLeftBaseViewIdx ][iSynthViewIdx], NULL, NULL, NULL, NULL, -1 );
    396           m_pcRenTop->extrapolateView( apcPicYuvBaseVideo[iLeftBaseViewIdx ], apcPicYuvBaseDepth[iLeftBaseViewIdx ], pcPicYuvSynthOut, true );
    397         }
    398         break;
    399       /// EXTRAPOLATION FROM RIGHT
    400       case 2:            // extrapolation from right
    401         if ( !bHasRView ) // View to render is BaseView
    402         {
    403           bRender = false;
    404         }
    405 
    406           if (  bIsBaseView )
    407           {
    408 
    409           AOF( iLeftBaseViewIdx == iRightBaseViewIdx );
    410           Int iSortedBaseViewIdx = m_cCameraData.getBaseId2SortedId() [iLeftBaseViewIdx];
    411           if ( iSortedBaseViewIdx + 1 < m_iNumberOfInputViews )
    412           {
    413             iRightBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iSortedBaseViewIdx + 1];
    414           }
    415           else
    416           {
    417             std::cout << "Copied    Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC  << std::endl;
    418             apcPicYuvBaseVideo[iLeftBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original
    419             bRender = false;
    420           }
    421         }
    422 
    423         if ( bRender )
    424         {
    425           std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC  << std::endl;
    426           m_pcRenTop->setShiftLUTs( NULL, NULL,NULL, m_cCameraData.getSynthViewShiftLUTD()[iRightBaseViewIdx ][iSynthViewIdx],
    427             m_cCameraData.getSynthViewShiftLUTI()[iRightBaseViewIdx ][iSynthViewIdx],NULL, iRelDistToLeft);
    428           m_pcRenTop->extrapolateView( apcPicYuvBaseVideo[iRightBaseViewIdx ], apcPicYuvBaseDepth[iRightBaseViewIdx ], pcPicYuvSynthOut, false);
    429         }
    430         break;
    431       }
    432 
    433       // Write Output
    434 
    435       m_apcTVideoIOYuvSynthOutput[m_bSweep ? 0 : iSynthViewIdx]->write( pcPicYuvSynthOut, IPCOLOURSPACE_UNCHANGED, 0, 0, 0, 0, CHROMA_420 );
    436     }
    437     iFrame++;
    438     iNumOfRenderedFrames++;
    439   }
    440 
    441   // Delete Buffers
    442   pcNewOrg->destroy();
    443   delete pcNewOrg;
    444 
    445   for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ )
    446   {
    447     apcPicYuvBaseVideo[uiBaseView]->destroy();
    448     delete apcPicYuvBaseVideo[uiBaseView];
    449 
    450     apcPicYuvBaseDepth[uiBaseView]->destroy();
    451     delete apcPicYuvBaseDepth[uiBaseView];
    452 
    453     // Temporal Filter
    454     if ( m_bTempDepthFilter )
    455     {
    456       apcPicYuvLastBaseVideo[uiBaseView]->destroy();
    457       delete apcPicYuvLastBaseVideo[uiBaseView];
    458 
    459       apcPicYuvLastBaseDepth[uiBaseView]->destroy();
    460       delete apcPicYuvLastBaseDepth[uiBaseView];
    461     }
    462   }
    463 
    464   pcPicYuvSynthOut->destroy();
    465   delete pcPicYuvSynthOut;
    466 
    467   xDestroyLib();
    468 
    469 }
    470 
    471 Void TAppRendererTop::go()
    472 {
    473   switch ( m_iRenderMode )
    474   {
    475   case 0:
    476     render();
    477     break;
    478 #if NH_3D_VSO
    479   case 1:
    480     renderModel();
    481     break;
    482 #endif
    483   case 10:
    484     renderUsedPelsMap( );
    485       break;
    486   default:
    487     AOT(true);
    488   }
    489 
    490 #if NH_3D_REN_MAX_DEV_OUT
    491   Double dMaxDispDiff = m_cCameraData.getMaxShiftDeviation();
    492 
    493   if ( !(dMaxDispDiff < 0) )
    494   { 
    495     printf("\n Max. possible shift error: %12.3f samples.\n", dMaxDispDiff );
    496   }
    497 #endif
    498 }
    499 
    500 #if NH_3D_VSO
    501 Void TAppRendererTop::renderModel()
    502 {
    503   if ( m_bUseSetupString )
    504   {
    505     xRenderModelFromString();
    506   }
    507   else
    508   {
    509     xRenderModelFromNums();
    510   }
    511 }
    512 
    513 
    514 
    515 Void TAppRendererTop::xRenderModelFromString()
    516 {
    517     xCreateLib();
    518     xInitLib();
    519 
    520     // Create Buffers Input Views;
    521     std::vector<TComPicYuv*> apcPicYuvBaseVideo;
    522     std::vector<TComPicYuv*> apcPicYuvBaseDepth;
    523 
    524 
    525     for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ )
    526     {
    527       TComPicYuv* pcNewVideoPic = new TComPicYuv;
    528       TComPicYuv* pcNewDepthPic = new TComPicYuv;
    529 
    530       pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    531       apcPicYuvBaseVideo.push_back(pcNewVideoPic);
    532 
    533       pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    534       apcPicYuvBaseDepth.push_back(pcNewDepthPic);
    535     }
    536 
    537     Int aiPad[2] = { 0, 0 };
    538     TComPicYuv* pcNewOrg = new TComPicYuv;
    539     pcNewOrg->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    540 
    541     // Init Model
    542     TRenModel cCurModel;
    543 
    544     AOT( m_iLog2SamplingFactor != 0 );
    545 #if H_3D_VSO_EARLY_SKIP
    546     cCurModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin, false );
    547 #else
    548     cCurModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin );
    549 #endif
    550 
    551     cCurModel.setupPart( 0, m_iSourceHeight  );
    552 
    553     for ( Int iViewIdx = 0; iViewIdx < m_iNumberOfInputViews; iViewIdx++ )
    554     {
    555       Int iNumOfModels   = m_cRenModStrParser.getNumOfModelsForView(iViewIdx, 1);
    556 
    557       for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ )
    558       {
    559         Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode;
    560         m_cRenModStrParser.getSingleModelData  ( iViewIdx, 1, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ;
    561         cCurModel         .createSingleModel   ( iViewIdx, 1, iModelNum, iLeftViewNum, iRightViewNum, false, iBlendMode );
    562       }
    563     }
    564 
    565     // Create Buffer for synthesized View
    566     TComPicYuv* pcPicYuvSynthOut = new TComPicYuv;
    567     pcPicYuvSynthOut->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    568 
    569     Bool bAnyEOS = false;
    570 
    571     Int iNumOfRenderedFrames = 0;
    572     Int iFrame = 0;
    573 
    574     while ( ( ( iNumOfRenderedFrames < m_iFramesToBeRendered ) || ( m_iFramesToBeRendered == 0 ) ) && !bAnyEOS )
    575     {
    576 
    577       if ( iFrame >= m_iFrameSkip )
    578       {     
    579         // read in depth and video
    580         for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    581         {
    582           m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], pcNewOrg, IPCOLOURSPACE_UNCHANGED, aiPad, CHROMA_420  ) ;
    583           bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof();
    584 
    585           m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], pcNewOrg, IPCOLOURSPACE_UNCHANGED, aiPad, CHROMA_420  ) ;
    586           bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof();
    587         }
    588       }
    589       else
    590       {
    591         iFrame++;
    592         continue;
    593       }
    594 
    595 
    596       for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    597       {
    598         TComPicYuv* pcPicYuvVideo = apcPicYuvBaseVideo[iBaseViewIdx];
    599         TComPicYuv* pcPicYuvDepth = apcPicYuvBaseDepth[iBaseViewIdx];
    600         Int iBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iBaseViewIdx ];
    601         cCurModel.setBaseView( iBaseViewSIdx, pcPicYuvVideo, pcPicYuvDepth, NULL, NULL );
    602       }
    603 
    604       m_cCameraData.update( (UInt) ( iFrame - m_iFrameSkip ));
    605 
    606       for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    607       {
    608         // setup virtual views
    609         Int iBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iBaseViewIdx];
    610 
    611         cCurModel.setErrorMode( iBaseViewSIdx, 1, 0 );
    612         Int iNumOfSV  = m_cRenModStrParser.getNumOfModelsForView( iBaseViewSIdx, 1);
    613         for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ )
    614         {
    615           Int iOrgRefBaseViewSIdx;
    616           Int iLeftBaseViewSIdx;
    617           Int iRightBaseViewSIdx;
    618           Int iSynthViewRelNum;
    619           Int iModelNum;
    620           Int iBlendMode;
    621 
    622           m_cRenModStrParser.getSingleModelData(iBaseViewSIdx, 1, iCurView, iModelNum, iBlendMode, iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum );
    623 
    624           Int iLeftBaseViewIdx    = -1;
    625           Int iRightBaseViewIdx   = -1;
    626 
    627           TComPicYuv* pcPicYuvOrgRef  = NULL;
    628           Int**      ppiShiftLUTLeft  = NULL;
    629           Int**      ppiShiftLUTRight = NULL;
    630           Int**      ppiBaseShiftLUTLeft  = NULL;
    631           Int**      ppiBaseShiftLUTRight = NULL;
    632 
    633 
    634           Int        iDistToLeft      = -1;
    635 
    636           Int iSynthViewIdx = m_cCameraData.synthRelNum2Idx( iSynthViewRelNum );
    637 
    638           if ( iLeftBaseViewSIdx != -1 )
    639           {
    640             iLeftBaseViewIdx   = m_cCameraData.getBaseSortedId2Id()   [ iLeftBaseViewSIdx ];
    641             ppiShiftLUTLeft    = m_cCameraData.getSynthViewShiftLUTI()[ iLeftBaseViewIdx  ][ iSynthViewIdx  ];
    642           }
    643 
    644           if ( iRightBaseViewSIdx != -1 )
    645           {
    646             iRightBaseViewIdx  = m_cCameraData.getBaseSortedId2Id()   [iRightBaseViewSIdx ];
    647             ppiShiftLUTRight   = m_cCameraData.getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ];
    648           }
    649 
    650           if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 )
    651           {
    652 
    653             ppiBaseShiftLUTLeft  = m_cCameraData.getBaseViewShiftLUTI() [ iLeftBaseViewIdx  ][ iRightBaseViewIdx ];
    654             ppiBaseShiftLUTRight = m_cCameraData.getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx  ];
    655             iDistToLeft    = m_cCameraData.getRelDistLeft(  iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx);
    656           }
    657 
    658           std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC  << std::endl;
    659 
    660           cCurModel.setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef );
    661 
    662           Int iViewPos;
    663           if (iLeftBaseViewSIdx != -1 && iRightBaseViewSIdx != -1)
    664           {
    665             iViewPos = VIEWPOS_MERGED;
    666           }
    667           else if ( iLeftBaseViewSIdx != -1 )
    668           {
    669             iViewPos = VIEWPOS_LEFT;
    670           }
    671           else if ( iRightBaseViewSIdx != -1 )
    672           {
    673             iViewPos = VIEWPOS_RIGHT;
    674           }
    675           else
    676           {
    677             AOT(true);
    678           }
    679 
    680           cCurModel.getSynthVideo ( iModelNum, iViewPos, pcPicYuvSynthOut );
    681 
    682           // Write Output
    683           m_apcTVideoIOYuvSynthOutput[m_bSweep ? 0 : iModelNum]->write( pcPicYuvSynthOut, IPCOLOURSPACE_UNCHANGED,  0 ,0 ,0, 0, CHROMA_420 );
    684         }
    685       }
    686       iFrame++;
    687       iNumOfRenderedFrames++;
    688   }
    689 
    690     // Delete Buffers
    691     for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ )
    692     {
    693       apcPicYuvBaseVideo[uiBaseView]->destroy();
    694       delete apcPicYuvBaseVideo[uiBaseView];
    695 
    696       apcPicYuvBaseDepth[uiBaseView]->destroy();
    697       delete apcPicYuvBaseDepth[uiBaseView];
    698 }
    699     pcPicYuvSynthOut->destroy();
    700     delete pcPicYuvSynthOut;
    701 
    702     xDestroyLib();
    703 }
    704 
    705 
    706 Void TAppRendererTop::xRenderModelFromNums()
    707 {
    708   xCreateLib();
    709   xInitLib();
    710 
    711   // Create Buffers Input Views;
    712   std::vector<TComPicYuv*> apcPicYuvBaseVideo;
    713   std::vector<TComPicYuv*> apcPicYuvBaseDepth;
    714 
    715 
    716   Int aiPad[2] = { 0, 0 };
    717   TComPicYuv* pcNewOrg = new TComPicYuv;
    718   pcNewOrg->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    719 
    720 
    721   // Init Model
    722   TRenModel cCurModel;
    723 
    724   AOT( m_iLog2SamplingFactor != 0 );
    725 
    726 #if H_3D_VSO_EARLY_SKIP
    727   cCurModel.create( m_iNumberOfInputViews, m_iNumberOfOutputViews, m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin, false );
    728 #else
    729   cCurModel.create( m_iNumberOfInputViews, m_iNumberOfOutputViews, m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin );
    730 #endif
    731   cCurModel.setupPart( 0, m_iSourceHeight  );
    732 
    733   for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ )
    734   {
    735     TComPicYuv* pcNewVideoPic = new TComPicYuv;
    736     TComPicYuv* pcNewDepthPic = new TComPicYuv;
    737 
    738     pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    739     apcPicYuvBaseVideo.push_back(pcNewVideoPic);
    740 
    741     pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    742     apcPicYuvBaseDepth.push_back(pcNewDepthPic);
    743   }
    744 
    745   for(Int iSynthViewIdx=0; iSynthViewIdx < m_iNumberOfOutputViews; iSynthViewIdx++ )
    746   {
    747     Int  iLeftBaseViewIdx  = -1;
    748     Int  iRightBaseViewIdx = -1;
    749     Bool bIsBaseView = false;
    750 
    751     Int iRelDistToLeft;
    752     m_cCameraData.getLeftRightBaseView( iSynthViewIdx, iLeftBaseViewIdx, iRightBaseViewIdx, iRelDistToLeft,  bIsBaseView );
    753 
    754     if (m_iRenderDirection == 1 )
    755     {
    756       iRightBaseViewIdx = -1;
    757       AOT( iLeftBaseViewIdx == -1);
    758     }
    759 
    760     if (m_iRenderDirection == 2 )
    761     {
    762       iLeftBaseViewIdx = -1;
    763       AOT( iRightBaseViewIdx == -1);
    764     }
    765 
    766     Int iLeftBaseViewSIdx  = -1;
    767     Int iRightBaseViewSIdx = -1;
    768 
    769     if (iLeftBaseViewIdx != -1 )
    770     {
    771       iLeftBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iLeftBaseViewIdx];
    772     }
    773 
    774     if (iRightBaseViewIdx != -1 )
    775     {
    776       iRightBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iRightBaseViewIdx];
    777     }
    778     cCurModel.createSingleModel(-1, -1, iSynthViewIdx, iLeftBaseViewSIdx, iRightBaseViewSIdx, false, m_iBlendMode );
    779   }
    780 
    781   // Create Buffer for synthesized View
    782   TComPicYuv* pcPicYuvSynthOut = new TComPicYuv;
    783   pcPicYuvSynthOut->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    784 
    785   Bool bAnyEOS = false;
    786 
    787   Int iNumOfRenderedFrames = 0;
    788   Int iFrame = 0;
    789 
    790   while ( ( ( iNumOfRenderedFrames < m_iFramesToBeRendered ) || ( m_iFramesToBeRendered == 0 ) ) && !bAnyEOS )
    791   {
    792 
    793     if ( iFrame >= m_iFrameSkip )
    794     {     
    795       // read in depth and video
    796       for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    797       {
    798         m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], pcNewOrg, IPCOLOURSPACE_UNCHANGED, aiPad, CHROMA_420  ) ;
    799         bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof();
    800 
    801         m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], pcNewOrg, IPCOLOURSPACE_UNCHANGED, aiPad, CHROMA_420  ) ;
    802         bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof();
    803 
    804         if ( iFrame >= m_iFrameSkip )
    805         {
    806           Int iBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iBaseViewIdx];
    807           cCurModel.setBaseView( iBaseViewSIdx, apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], NULL, NULL );
    808         }
    809       }
    810     }
    811     else
    812     {
    813       iFrame++;
    814       continue;
    815     }
    816     m_cCameraData.update( (UInt) (iFrame - m_iFrameSkip ));
    817     for(Int iSynthViewIdx=0; iSynthViewIdx < m_iNumberOfOutputViews; iSynthViewIdx++ )
    818     {
    819 
    820       Int  iLeftBaseViewIdx  = -1;
    821       Int  iRightBaseViewIdx = -1;
    822 
    823       Bool bIsBaseView = false;
    824 
    825       Int iRelDistToLeft;
    826       Bool bHasLRView = m_cCameraData.getLeftRightBaseView( iSynthViewIdx, iLeftBaseViewIdx, iRightBaseViewIdx, iRelDistToLeft, bIsBaseView );
    827       Bool bHasLView = ( iLeftBaseViewIdx != -1 );
    828       Bool bHasRView = ( iRightBaseViewIdx != -1 );
    829 
    830       switch( m_iRenderDirection )
    831       {
    832         /// INTERPOLATION
    833       case 0:
    834         assert( bHasLRView || bIsBaseView );
    835 
    836         if ( !bHasLRView && bIsBaseView ) // View to render is BaseView
    837         {
    838           std::cout << "Copied    Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC  << std::endl;
    839           apcPicYuvBaseVideo[iLeftBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original
    840         }
    841         else  // Render
    842         {
    843           std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC  << std::endl;
    844           cCurModel.setSingleModel( iSynthViewIdx,
    845                                     m_cCameraData.getSynthViewShiftLUTI()[iLeftBaseViewIdx ][iSynthViewIdx]    ,
    846                                     m_cCameraData.getBaseViewShiftLUTI ()[iLeftBaseViewIdx ][iRightBaseViewIdx],
    847                                     m_cCameraData.getSynthViewShiftLUTI()[iRightBaseViewIdx][iSynthViewIdx]    ,
    848                                     m_cCameraData.getBaseViewShiftLUTI ()[iRightBaseViewIdx][iLeftBaseViewIdx] ,
    849                                     iRelDistToLeft,
    850                                     NULL );
    851           cCurModel.getSynthVideo ( iSynthViewIdx, VIEWPOS_MERGED, pcPicYuvSynthOut );
    852         }
    853         break;
    854         /// EXTRAPOLATION FROM LEFT
    855       case 1:
    856 
    857         if ( !bHasLView ) // View to render is BaseView
    858         {
    859           std::cout << "Copied    Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC  << std::endl;
    860           apcPicYuvBaseVideo[iLeftBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original
    861         }
    862         else  // Render
    863         {
    864           std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC  << std::endl;
    865           cCurModel.setSingleModel( iSynthViewIdx, m_cCameraData.getSynthViewShiftLUTI()[iLeftBaseViewIdx ][iSynthViewIdx], NULL, NULL, NULL, -1,  NULL);
    866           cCurModel.getSynthVideo ( iSynthViewIdx, VIEWPOS_LEFT, pcPicYuvSynthOut );
    867         }
    868         break;
    869         /// EXTRAPOLATION FROM RIGHT
    870       case 2:            // extrapolation from right
    871         if ( !bHasRView ) // View to render is BaseView
    872         {
    873           std::cout << "Copied    Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC  << std::endl;
    874           apcPicYuvBaseVideo[iRightBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original
    875         }
    876         else  // Render
    877         {
    878           std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC  << std::endl;
    879           cCurModel.setSingleModel( iSynthViewIdx, NULL , NULL, m_cCameraData.getSynthViewShiftLUTI()[iRightBaseViewIdx ][iSynthViewIdx], NULL, -1, NULL);
    880           cCurModel.getSynthVideo ( iSynthViewIdx, VIEWPOS_RIGHT, pcPicYuvSynthOut );
    881         }
    882         break;
    883       }
    884 
    885       // Write Output
    886       m_apcTVideoIOYuvSynthOutput[m_bSweep ? 0 : iSynthViewIdx]->write( pcPicYuvSynthOut, IPCOLOURSPACE_UNCHANGED,  0 ,0 ,0, 0, CHROMA_420 );
    887     }
    888     iFrame++;
    889     iNumOfRenderedFrames++;
    890   }
    891 
    892   // Delete Buffers
    893   for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ )
    894   {
    895     apcPicYuvBaseVideo[uiBaseView]->destroy();
    896     delete apcPicYuvBaseVideo[uiBaseView];
    897 
    898     apcPicYuvBaseDepth[uiBaseView]->destroy();
    899     delete apcPicYuvBaseDepth[uiBaseView];
    900   }
    901   pcPicYuvSynthOut->destroy();
    902   delete pcPicYuvSynthOut;
    903 
    904   xDestroyLib();
    905 
    906 }
    907 #endif
    908 
    909 Void TAppRendererTop::renderUsedPelsMap( )
    910 {
    911   xCreateLib();
    912   xInitLib();
    913 
    914   // Create Buffers Input Views;
    915   std::vector<TComPicYuv*> apcPicYuvBaseVideo;
    916   std::vector<TComPicYuv*> apcPicYuvBaseDepth;
    917 
    918   // TemporalImprovement Filter
    919   std::vector<TComPicYuv*> apcPicYuvLastBaseVideo;
    920   std::vector<TComPicYuv*> apcPicYuvLastBaseDepth;
    921 
    922   Int aiPad[2] = { 0, 0 };
    923 
    924   TComPicYuv* pcNewOrg = new TComPicYuv;
    925   pcNewOrg->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    926 
    927   for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ )
    928   {
    929     TComPicYuv* pcNewVideoPic = new TComPicYuv;
    930     TComPicYuv* pcNewDepthPic = new TComPicYuv;
    931 
    932     pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight,CHROMA_420, 1, 1, 1, true );
    933     apcPicYuvBaseVideo.push_back(pcNewVideoPic);
    934 
    935     pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1, true );
    936     apcPicYuvBaseDepth.push_back(pcNewDepthPic);
    937 
    938 
    939     //Temporal improvement Filter
    940     if ( m_bTempDepthFilter )
    941     {
    942       pcNewVideoPic = new TComPicYuv;
    943       pcNewDepthPic = new TComPicYuv;
    944 
    945       pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1, 1 , true);
    946       apcPicYuvLastBaseVideo.push_back(pcNewVideoPic);
    947 
    948       pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight,CHROMA_420, 1, 1, 1 , true);
    949       apcPicYuvLastBaseDepth.push_back(pcNewDepthPic);
    950     }
    951   }
    952 
    953   // Create Buffer for synthesized View
    954   TComPicYuv* pcPicYuvSynthOut = new TComPicYuv;
    955   pcPicYuvSynthOut->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, 1, 1 ,1, true);
    956 
    957   Bool bAnyEOS = false;
    958 
    959   Int iNumOfRenderedFrames = 0;
    960   Int iFrame = 0;
    961 
    962   while ( ( ( iNumOfRenderedFrames < m_iFramesToBeRendered ) || ( m_iFramesToBeRendered == 0 ) ) && !bAnyEOS )
    963   {
    964     if ( iFrame >= m_iFrameSkip )
    965     {     
    966       // read in depth and video
    967       for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ )
    968       {
    969         m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], pcNewOrg, IPCOLOURSPACE_UNCHANGED,  aiPad, CHROMA_420  ) ;
    970         apcPicYuvBaseVideo[iBaseViewIdx]->extendPicBorder();
    971         bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof();
    972 
    973         m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], pcNewOrg, IPCOLOURSPACE_UNCHANGED,  aiPad, CHROMA_420  ) ;
    974         apcPicYuvBaseDepth[iBaseViewIdx]->extendPicBorder();
    975         bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof();
    976 
    977         if ( m_bTempDepthFilter && (iFrame >= m_iFrameSkip) )
    978         {
    979           m_pcRenTop->temporalFilterVSRS( apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], apcPicYuvLastBaseVideo[iBaseViewIdx], apcPicYuvLastBaseDepth[iBaseViewIdx], ( iFrame == m_iFrameSkip) );
    980         }
    981       }
    982     }
    983     else
    984     {
    985       std::cout << "Skipping Frame " << iFrame << std::endl;
    986 
    987       iFrame++;
    988       continue;
    989     }
    990     m_cCameraData.update( (UInt) ( iFrame - m_iFrameSkip ) );
    991 
    992     for(Int iViewIdx=1; iViewIdx < m_iNumberOfInputViews; iViewIdx++ )
    993     {
    994       std::cout << "Rendering UsedPelsMap for Frame " << iFrame << " of View " << (Double) m_cCameraData.getBaseViewNumbers()[iViewIdx] << std::endl;
    995 
    996       Int iViewSIdx      = m_cCameraData.getBaseId2SortedId()[iViewIdx];
    997       Int iFirstViewSIdx = m_cCameraData.getBaseId2SortedId()[0];
    998 
    999       AOT( iViewSIdx == iFirstViewSIdx );
    1000 
    1001       Bool bFirstIsLeft = (iFirstViewSIdx < iViewSIdx);
    1002 
    1003       m_pcRenTop->setShiftLUTs(
    1004         m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx],
    1005         m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
    1006         m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
    1007         m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx],
    1008         m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
    1009         m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
    1010         -1
    1011         );
    1012 
    1013       m_pcRenTop->getUsedSamplesMap( apcPicYuvBaseDepth[0], pcPicYuvSynthOut, bFirstIsLeft );
    1014 
    1015       // Write Output
    1016       m_apcTVideoIOYuvSynthOutput[iViewIdx-1]->write( pcPicYuvSynthOut,  IPCOLOURSPACE_UNCHANGED, 0, 0, 0, 0, CHROMA_420 );
    1017 
    1018     }
    1019     iFrame++;
    1020     iNumOfRenderedFrames++;
    1021   }
    1022 
    1023   // Delete Buffers
    1024 
    1025   pcNewOrg->destroy();
    1026   delete pcNewOrg;
    1027 
    1028   for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ )
    1029   {
    1030     apcPicYuvBaseVideo[uiBaseView]->destroy();
    1031     delete apcPicYuvBaseVideo[uiBaseView];
    1032 
    1033     apcPicYuvBaseDepth[uiBaseView]->destroy();
    1034     delete apcPicYuvBaseDepth[uiBaseView];
    1035 
    1036     // Temporal Filter
    1037     if ( m_bTempDepthFilter )
    1038     {
    1039       apcPicYuvLastBaseVideo[uiBaseView]->destroy();
    1040       delete apcPicYuvLastBaseVideo[uiBaseView];
    1041 
    1042       apcPicYuvLastBaseDepth[uiBaseView]->destroy();
    1043       delete apcPicYuvLastBaseDepth[uiBaseView];
    1044     }
    1045   }
    1046   pcPicYuvSynthOut->destroy();
    1047   delete pcPicYuvSynthOut;
    1048 
    1049   xDestroyLib();
    1050 
    1051 }
    1052 #endif
  • branches/HTM-16.0-MV-draft-5/source/App/TAppRenderer/TAppRendererTop.h

    r1386 r1390  
    4040#define __TAppRendererTOP__
    4141#include "../../Lib/TLibCommon/CommonDef.h"
    42 #if NH_3D_VSO
    43 #include "../../Lib/TLibRenderer/TRenTop.h"
    44 #include "../../Lib/TLibVideoIO/TVideoIOYuv.h"
    45 #include "TAppRendererCfg.h"
    46 #include "TAppRendererTop.h"
    47 #include "../../Lib/TLibRenderer/TRenModel.h"
    48 
    49 // ====================================================================================================================
    50 // Class definition
    51 // ====================================================================================================================
    52 
    53 /// encoder application class
    54 class TAppRendererTop : public TAppRendererCfg
    55 {
    56 private:
    57   // class interface
    58   std::vector<TVideoIOYuv*>     m_apcTVideoIOYuvVideoInput;
    59   std::vector<TVideoIOYuv*>    m_apcTVideoIOYuvDepthInput;
    60   std::vector<TVideoIOYuv*>     m_apcTVideoIOYuvSynthOutput;
    61 
    62   // RendererInterface
    63   TRenTop*                     m_pcRenTop;
    64 
    65 protected:
    66   // initialization
    67   Void  xCreateLib        ();                               ///< create renderer class and video io
    68   Void  xInitLib          ();                               ///< initialize renderer class
    69   Void  xDestroyLib       ();                               ///< destroy renderer class and video io
    70 #if NH_3D_VSO
    71   Void  xRenderModelFromString();                           ///< render using model using setup string
    72   Void  xRenderModelFromNums();                             ///< render using model using synth view numbers
    73 #endif
    74 
    75 public:
    76   TAppRendererTop();
    77   virtual ~TAppRendererTop();
    78 
    79   Void  render      ();                               ///< main encoding function
    80 #if NH_3D_VSO
    81   Void  renderModel ();
    82 #endif
    83   Void  go          ();
    84   Void  renderUsedPelsMap();
    85 
    86 };// END CLASS DEFINITION TAppRendererTop
    87 
    88 
    89 #endif // NH_3D
    9042#endif // __TAppRendererTOP__
  • branches/HTM-16.0-MV-draft-5/source/Lib/TAppCommon/TAppComCamPara.cpp

    r1386 r1390  
    4949#include <functional>
    5050#include <string>
    51 #if NH_3D_VSO
    52 
    53 
    54 Void
    55 TAppComCamPara::xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT, Double***& radShiftParams, Int64***& raiShiftParams )
    56 {
    57   AOF( m_uiBitDepthForLUT == 8 );
    58   AOF( radShiftParams == NULL && raiShiftParams == NULL && radLUT == NULL && raiLUT == NULL );
    59 
    60   uiNumberSourceViews = std::max( (UInt) 1, uiNumberSourceViews );
    61   uiNumberTargetViews = std::max( (UInt) 1, uiNumberTargetViews );
    62 
    63   radShiftParams = new Double** [ uiNumberSourceViews ];
    64   raiShiftParams = new Int64 ** [ uiNumberSourceViews ];
    65   radLUT         = new Double***[ uiNumberSourceViews ];
    66   raiLUT         = new Int   ***[ uiNumberSourceViews ];
    67 
    68   for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ )
    69   {
    70     radShiftParams[ uiSourceView ] = new Double* [ uiNumberTargetViews ];
    71     raiShiftParams[ uiSourceView ] = new Int64 * [ uiNumberTargetViews ];
    72     radLUT        [ uiSourceView ] = new Double**[ uiNumberTargetViews ];
    73     raiLUT        [ uiSourceView ] = new Int   **[ uiNumberTargetViews ];
    74 
    75     for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ )
    76     {
    77       radShiftParams[ uiSourceView ][ uiTargetView ]      = new Double [ 2 ];
    78       raiShiftParams[ uiSourceView ][ uiTargetView ]      = new Int64  [ 2 ];
    79 
    80       radLUT        [ uiSourceView ][ uiTargetView ]      = new Double*[ 2 ];
    81       radLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ];
    82       radLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ];
    83 
    84       raiLUT        [ uiSourceView ][ uiTargetView ]      = new Int*   [ 2 ];
    85       raiLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Int    [ 257 ];
    86       raiLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Int    [ 257 ];
    87     }
    88   }
    89 }
    90 
    91 Void
    92 TAppComCamPara::xCreate2dArray( UInt uiNum1Ids, UInt uiNum2Ids, Int**& raaiArray )
    93 {
    94   AOT( raaiArray || uiNum1Ids == 0 || uiNum2Ids == 0 );
    95   raaiArray = new Int* [ uiNum1Ids ];
    96   for( UInt uiId1 = 0; uiId1 < uiNum1Ids; uiId1++ )
    97   {
    98     raaiArray[ uiId1 ] = new Int [ uiNum2Ids ];
    99   }
    100 }
    101 
    102 
    103 Void
    104 TAppComCamPara::xInit2dArray( UInt uiNum1Ids, UInt uiNum2Ids, Int**& raaiArray, Int iValue )
    105 {
    106   for( UInt uiId1 = 0; uiId1 < uiNum1Ids; uiId1++ )
    107   {
    108     for( UInt uiId2 = 0; uiId2 < uiNum2Ids; uiId2++ )
    109     {
    110       raaiArray[ uiId1 ][ uiId2 ] = iValue;
    111     }
    112   }
    113 }
    114 
    115 
    116 Void
    117 TAppComCamPara::convertNumberString( TChar* pchViewNumberString, std::vector<Int>& raiViewNumbers, Double dViewNumPrec )
    118 {
    119   Bool bStringIsRange = false;
    120   Int  iIdx           = 0;
    121   std::vector<Double> adViewNumbers;
    122 
    123   while( pchViewNumberString != 0 && pchViewNumberString[ iIdx ] != 0 )
    124   {
    125     if( pchViewNumberString[ iIdx ] == ':' )
    126     {
    127       bStringIsRange              = true;
    128       pchViewNumberString[ iIdx ] = ' ';
    129     }
    130     iIdx++;
    131   }
    132 
    133   TChar* pcNextStart = pchViewNumberString;
    134   TChar* pcEnd       = pcNextStart + iIdx;
    135   TChar* pcOldStart  = 0;
    136 
    137   while( pcNextStart < pcEnd )
    138   {
    139     errno = 0;
    140     adViewNumbers.push_back( ( strtod( pcNextStart, &pcNextStart ) ) );
    141 
    142     if( errno == ERANGE || pcNextStart == pcOldStart )
    143     {
    144       std::cerr << "Error Parsing View Number String: `" << pchViewNumberString << "'" << std::endl;
    145       AOT(true);
    146       exit( EXIT_FAILURE );
    147     };
    148 
    149     while( pcNextStart < pcEnd && ( *pcNextStart == ' ' || *pcNextStart == '\t' || *pcNextStart == '\r' ) ) pcNextStart++;
    150 
    151     pcOldStart = pcNextStart;
    152   }
    153 
    154   if( bStringIsRange )
    155   {
    156     if( adViewNumbers.size() != 3 )
    157     {
    158       std::cerr << "Error Parsing SynthViewNumbers: `" << pchViewNumberString << "'" << std::endl;
    159       AOT(true);
    160       exit( EXIT_FAILURE );
    161     }
    162 
    163     Double dRangeBegin = adViewNumbers[0];
    164     Double dRangeStep  = adViewNumbers[1];
    165     Double dRangeEnd   = adViewNumbers[2];
    166 
    167     if( ( ( dRangeEnd - dRangeBegin > 0 ) != ( dRangeStep > 0 ) ) || dRangeStep == 0 )
    168     {
    169       std::cerr << "Error Parsing SynthViewNumbers: `" << pchViewNumberString << "'" << std::endl;
    170       AOT(true);
    171       exit( EXIT_FAILURE );
    172     }
    173 
    174     raiViewNumbers.clear();
    175 
    176     Double dFac = ( dRangeBegin > dRangeEnd ? -1 : 1 );
    177 
    178     for( Double dViewNumber = dRangeBegin; ( dViewNumber - dRangeEnd ) * dFac <= 0; dViewNumber += dRangeStep )
    179     {
    180       raiViewNumbers.push_back( (Int)( dViewNumber * dViewNumPrec ) );
    181     }
    182   }
    183   else
    184   {
    185     for( UInt uiViewNum = 0; uiViewNum < adViewNumbers.size(); uiViewNum++ )
    186     {
    187       raiViewNumbers.push_back( (Int)( adViewNumbers[ uiViewNum ] * dViewNumPrec ) );
    188     }
    189   }
    190 }
    191 
    192 
    193 Void
    194 TAppComCamPara::xReadCameraParameterFile( TChar* pchCfgFileName )
    195 {
    196   assert( pchCfgFileName != NULL );
    197 
    198   std::ifstream cCfgStream( pchCfgFileName, std::ifstream::in );
    199   if( !cCfgStream )
    200   {
    201     std::cerr << "Failed to open camera parameter file: `" << pchCfgFileName << "'" << std::endl;
    202     exit( EXIT_FAILURE );
    203   }
    204 
    205   Int iLineNumber = 0;
    206   do
    207   {
    208     std::string cLine;
    209     getline( cCfgStream, cLine );
    210     iLineNumber++;
    211 
    212     size_t iStart = cLine.find_first_not_of( " \t\n\r" );
    213 
    214     if( iStart == std::string::npos )
    215     {
    216       continue;
    217     }
    218 
    219     if( cLine[iStart] == '#' )
    220     {
    221       continue;
    222     }
    223 
    224     TChar* pcNextStart = (TChar*) cLine.data();
    225     TChar* pcEnd = pcNextStart + cLine.length();
    226 
    227     std::vector<Double> caNewLine;
    228     caNewLine.clear();
    229 
    230     TChar* pcOldStart = 0;
    231     while( pcNextStart < pcEnd )
    232     {
    233       errno = 0;
    234       caNewLine.push_back( strtod( pcNextStart, &pcNextStart ) ) ;
    235 
    236       if( errno == ERANGE || ( pcNextStart == pcOldStart ) )
    237       {
    238         std::cerr << "Failed reading config file: `" << pchCfgFileName << "' Error parsing double values in Line: " << iLineNumber << ' ' << std::endl;
    239         assert( 0 );
    240         exit( EXIT_FAILURE );
    241       };
    242       pcOldStart = pcNextStart;
    243 
    244       while( ( pcNextStart < pcEnd ) && ( *pcNextStart == ' ' || *pcNextStart == '\t' || *pcNextStart == '\r' ) ) pcNextStart++;
    245     }
    246 
    247     if ( ( caNewLine.size() != 2 ) && ( caNewLine.size() != 7 ) && ( caNewLine.size() != 6 ) && ( caNewLine.size() != 8 ) )
    248     {
    249       std::cerr << "Failed reading config file: `" << pchCfgFileName << "'" << std::endl;
    250       std::cerr << "Invalid number of entries" << std::endl;
    251       AOF(false);
    252       exit( EXIT_FAILURE );
    253     }
    254     m_aadCameraParameters.push_back( caNewLine );
    255   }
    256   while( cCfgStream );
    257 }
    258 
    259 Void
    260 TAppComCamPara::xGetCodedCameraData( UInt uiSourceView, UInt uiTargetView, Bool bByIdx,  UInt uiFrame, Int& riScale, Int& riOffset, Int& riPrecision )
    261 {
    262   if( bByIdx )
    263   {
    264     uiSourceView = m_aiBaseViews[ uiSourceView ];
    265     uiTargetView = m_aiBaseViews[ uiTargetView ];
    266   }
    267 
    268   Int iFoundLine = -1;
    269   for( UInt uiCurViewLine = 0; uiCurViewLine < m_aadCameraParameters.size(); uiCurViewLine++ )
    270   {
    271     if ( m_aadCameraParameters[uiCurViewLine].size() == 2 )
    272       continue;
    273 
    274     if(      ( (Int)( m_aadCameraParameters[ uiCurViewLine ][ 3 ] * m_dViewNumPrec ) == uiSourceView )
    275           && ( (Int)( m_aadCameraParameters[ uiCurViewLine ][ 2 ] * m_dViewNumPrec ) == uiTargetView )
    276       )
    277     {
    278       if( ( (UInt)m_aadCameraParameters[ uiCurViewLine ][ 0 ] <= uiFrame ) && ( (UInt)m_aadCameraParameters[ uiCurViewLine ][ 1 ] >= uiFrame ) )
    279       {
    280         if( iFoundLine != -1 )
    281         {
    282           std::cerr << "Error CameraParameters for SourceView " << (Double) uiSourceView / m_dViewNumPrec << " and Target View " << (Double) uiTargetView / m_dViewNumPrec << " and Frame " << uiFrame << " given multiple times."  << std::endl;
    283           AOT(true);
    284           exit( EXIT_FAILURE );
    285         }
    286         else
    287         {
    288           iFoundLine = uiCurViewLine;
    289         }
    290       }
    291     }
    292   }
    293 
    294   if ( iFoundLine == -1 )
    295   {
    296     std::cerr << "Error CameraParameters for SourceView " << (Double) uiSourceView / m_dViewNumPrec << " and Target View " << (Double) uiTargetView / m_dViewNumPrec << " and Frame " << uiFrame << " not found."  << std::endl;
    297     AOT(true);
    298     exit( EXIT_FAILURE );
    299   }
    300 
    301   riScale     = (Int)( m_aadCameraParameters[ iFoundLine ][ 4 ] );
    302   riOffset    = (Int)( m_aadCameraParameters[ iFoundLine ][ 5 ] );
    303   riPrecision = (Int)( m_aadCameraParameters[ iFoundLine ][ 6 ] );
    304 }
    305 
    306 Bool
    307 TAppComCamPara::xGetCameraDataRow( Int iView, UInt uiFrame, UInt& ruiFoundLine )
    308 {
    309   ruiFoundLine = -1;
    310   for( UInt uiCurViewLine = 0; uiCurViewLine < m_aadCameraParameters.size(); uiCurViewLine++ )
    311   {
    312     if( (Int)( m_aadCameraParameters[ uiCurViewLine ][ 0 ] * m_dViewNumPrec ) == iView )
    313     {
    314       if( ( (UInt)m_aadCameraParameters[ uiCurViewLine ][ 1 ] <= uiFrame ) && ( (UInt)m_aadCameraParameters[ uiCurViewLine ][ 2 ] >= uiFrame ) )
    315       {
    316         if( ruiFoundLine != -1 )
    317         {
    318           std::cerr << "Error CameraParameters for View " << (Double) iView / m_dViewNumPrec << " and Frame " << uiFrame << " given multiple times."  << std::endl;
    319           exit( EXIT_FAILURE );
    320         }
    321         else
    322         {
    323           ruiFoundLine = uiCurViewLine;
    324         }
    325       }
    326     }
    327   }
    328   return ( ruiFoundLine == -1 );
    329 }
    330 
    331 
    332 Void
    333 TAppComCamPara::xGetSortedViewList( const std::vector<Int>& raiViews, std::vector<Int>& raiSortedViews, std::vector<Int>& raiId2SortedId, std::vector<Int>& raiSortedId2Id )
    334 {
    335   AOF( raiViews.size() > 0 );
    336   Int iNumViews   = (Int)raiViews.size();
    337   raiId2SortedId  = std::vector<Int>( raiViews.size(), -1 );
    338   raiSortedId2Id.clear();
    339   raiSortedViews.clear();
    340   for( Int iSortId = 0; iSortId < iNumViews; iSortId++ )
    341   {
    342     Int  iLeftMostBaseId = -1;
    343     for( Int iBaseId = 0; iLeftMostBaseId == -1 && iBaseId < iNumViews; iBaseId++ )
    344     {
    345       if( raiId2SortedId[ iBaseId ] == -1 )
    346       {
    347         UInt   uiFoundLine   = -1;
    348         xGetCameraDataRow( raiViews[ iBaseId ], 0, uiFoundLine );
    349         AOT(   uiFoundLine  == -1 ); // something wrong
    350         Double dXPos         = m_aadCameraParameters[ uiFoundLine ][ 4 ];
    351         Double dZNear        = m_aadCameraParameters[ uiFoundLine ][ 6 ];
    352         Double dZFar         = m_aadCameraParameters[ uiFoundLine ][ 7 ];
    353         Double dSign         = ( dZFar > 0 ? 1.0 : -1.0 );
    354         Bool   bLeftMost     = true;
    355         AOF( dZNear * dZFar  > 0.0 ); // otherwise, z parameters are not correct
    356 
    357         for( Int iTestBaseId = 0; bLeftMost && iTestBaseId < iNumViews; iTestBaseId++ )
    358         {
    359           if( iTestBaseId != iBaseId && raiId2SortedId[ iTestBaseId ] == -1 )
    360           {
    361             UInt   uiFoundLineTest  = -1;
    362             xGetCameraDataRow( raiViews[ iTestBaseId ], 0, uiFoundLineTest );
    363             AOT(   uiFoundLineTest == -1 ); // something wrong
    364             Double dXPosTest        = m_aadCameraParameters[ uiFoundLineTest ][ 4 ];
    365             Double dZNearTest       = m_aadCameraParameters[ uiFoundLineTest ][ 6 ];
    366             Double dZFarTest        = m_aadCameraParameters[ uiFoundLineTest ][ 7 ];
    367             AOF( dZNearTest * dZFarTest > 0.0 ); // otherwise, z parameters are not correct
    368             AOF( dZNearTest * dSign     > 0.0 ); // otherwise, z parameters are not consistent
    369             Double dDeltaXPos       = dSign * ( dXPosTest - dXPos );
    370             bLeftMost               = ( bLeftMost && dDeltaXPos > 0.0 );
    371           }
    372         }
    373         if( bLeftMost )
    374         {
    375           iLeftMostBaseId = iBaseId;
    376         }
    377       }
    378     }
    379     AOT( iLeftMostBaseId == -1 ); // something wrong
    380     raiId2SortedId[ iLeftMostBaseId ] = iSortId;
    381     raiSortedId2Id.push_back( iLeftMostBaseId );
    382     raiSortedViews.push_back( raiViews[ iLeftMostBaseId ] );
    383   }
    384 
    385   // sanity check
    386   if( iNumViews > 2 )
    387   {
    388     Int   iDeltaView  = gSign( raiSortedViews[ 1 ] - raiSortedViews[ 0 ] );
    389     Bool  bOutOfOrder = false;
    390     for(  Int  iSIdx  = 2; iSIdx < iNumViews; iSIdx++ )
    391     {
    392       bOutOfOrder = ( bOutOfOrder || iDeltaView * gSign( raiSortedViews[ iSIdx ] - raiSortedViews[ iSIdx - 1 ] ) < 0 );
    393     }
    394     if( bOutOfOrder )
    395     {
    396       std::cerr << "ERROR: View numbering must be strictly increasing or decreasing from left to right" << std::endl;
    397       exit(EXIT_FAILURE);
    398     }
    399   }
    400 }
    401 
    402 
    403 
    404 
    405 Bool
    406 TAppComCamPara::xGetCamParsChangeFlag()
    407 {
    408   Bool bChangeDetected = false;
    409   for( Int iBaseViewId = 0; !bChangeDetected && iBaseViewId < m_iNumberOfBaseViews; iBaseViewId++ )
    410   {
    411     if ( m_bSetupFromCoded )
    412     {
    413       for( Int iTargetViewId = 0; !bChangeDetected && iTargetViewId < m_iNumberOfBaseViews; iTargetViewId++ )
    414       {
    415         Int iTargetView = m_aiBaseViews[iTargetViewId];
    416         Int iSourceView = m_aiBaseViews[iBaseViewId  ];
    417 
    418         Int iS1 ,iSX;
    419         Int iO1 ,iOX;
    420         Int iP1 ,iPX;
    421 
    422         if ( iSourceView == iTargetView )
    423           continue;
    424 
    425         xGetCodedCameraData( iSourceView, iTargetView, false, 0, iS1, iO1, iP1 );
    426         for( UInt uiFrameId = m_uiFirstFrameId + 1; !bChangeDetected && uiFrameId <= m_uiLastFrameId; uiFrameId++ )
    427         {
    428           xGetCodedCameraData( iSourceView, iTargetView, false, uiFrameId, iSX, iOX, iPX );
    429 
    430           if( iS1 != iSX || iO1 != iOX || iP1 != iPX )
    431           {
    432             bChangeDetected = true;
    433           }
    434         }
    435       }
    436     }
    437     else
    438     {
    439       Int     iBaseView  = m_aiBaseViews[ iBaseViewId ];
    440       Double  dFL1, dFLX;
    441       Double  dCP1, dCPX;
    442       Double  dCS1, dCSX;
    443       Double  dZN1, dZNX;
    444       Double  dZF1, dZFX;
    445       Bool    bInterpolated;
    446       xGetGeometryData( iBaseView, m_uiFirstFrameId, dFL1, dCP1, dCS1, bInterpolated );  AOT( bInterpolated );
    447       xGetZNearZFar   ( iBaseView, m_uiFirstFrameId, dZN1, dZF1 );
    448 
    449       for( UInt uiFrameId = m_uiFirstFrameId + 1; !bChangeDetected && uiFrameId <= m_uiLastFrameId; uiFrameId++ )
    450       {
    451         xGetGeometryData( iBaseView, uiFrameId, dFLX, dCPX, dCSX, bInterpolated );  AOT( bInterpolated );
    452         xGetZNearZFar   ( iBaseView, uiFrameId, dZNX, dZFX );
    453 
    454         if( dFL1 != dFLX || dCP1 != dCPX || dCS1 != dCSX || dZN1 != dZNX || dZF1 != dZFX )
    455         {
    456           bChangeDetected = true;
    457         }
    458       }
    459     }
    460   }
    461   return bChangeDetected;
    462 }
    463 
    464 Int
    465 TAppComCamPara::xGetViewId( std::vector<Int> aiViewList, Int iBaseView )
    466 {
    467   Int  iViewId = -1;
    468   for( Int iId = 0; iId < (Int)aiViewList.size(); iId++ )
    469   {
    470     if( aiViewList[ iId ] == iBaseView )
    471     {
    472       iViewId = iId;
    473       break;
    474     }
    475   }
    476   AOT(   iViewId == -1 );
    477   return iViewId;
    478 }
    479 
    480 Int
    481 TAppComCamPara::xGetBaseViewId( Int iBaseView )
    482 {
    483   return xGetViewId( m_aiBaseViews, iBaseView );
    484 }
    485 
    486 
    487 Bool
    488 TAppComCamPara::xGetLeftRightView( Int iView, std::vector<Int> aiSortedViews, Int& riLeftView, Int& riRightView, Int& riLeftSortedViewIdx, Int& riRightSortedViewIdx )
    489 {
    490   Bool bFoundLRView  = false;
    491   Int  iLeftView     = -1;
    492   Int  iRightView    = -1;
    493   Int  iLeftViewIdx  = -1;
    494   Int  iRightViewIdx = -1;
    495   Bool bDecencdingVN = ( aiSortedViews.size() >= 2 && aiSortedViews[ 0 ] > aiSortedViews[ 1 ] );
    496   Int  iFactor       = ( bDecencdingVN ? -1 : 1 );
    497 
    498   for( Int iIdx = -1; iIdx < (Int)aiSortedViews.size(); iIdx++ )
    499   {
    500     if( iIdx == -1 )
    501     {
    502       if( ( aiSortedViews[ iIdx + 1 ] - iView ) * iFactor > 0  )
    503       {
    504         bFoundLRView  = false;
    505         iLeftView     = -1;
    506         iRightView    = aiSortedViews[ iIdx + 1 ];
    507         iLeftViewIdx  = -1;
    508         iRightViewIdx = iIdx + 1;
    509         break;
    510       }
    511     }
    512     else if ( iIdx == (Int)aiSortedViews.size() - 1 )
    513     {
    514       if( ( aiSortedViews[ iIdx ] - iView ) * iFactor < 0  )
    515       {
    516         bFoundLRView  = false;
    517         iLeftView     = aiSortedViews[ iIdx ];
    518         iRightView    = -1;
    519         iLeftViewIdx  = iIdx;
    520         iRightViewIdx = -1;
    521         break;
    522       }
    523     }
    524     else
    525     {
    526       if( ( ( aiSortedViews[ iIdx ] - iView ) * iFactor <= 0 ) && ( ( aiSortedViews[ iIdx + 1 ] - iView ) * iFactor >= 0 ) )
    527       {
    528         bFoundLRView  = true;
    529         iLeftView     = aiSortedViews[ iIdx ];
    530         iRightView    = aiSortedViews[ iIdx + 1 ];
    531         iLeftViewIdx  = iIdx;
    532         iRightViewIdx = iIdx + 1;
    533         break;
    534       }
    535     }
    536   }
    537 
    538   if ( ( iView == iLeftView ) || ( iView == iRightView ) )
    539   {
    540     iLeftViewIdx  = ( iView == iLeftView ) ? iLeftViewIdx : iRightViewIdx;
    541     iRightViewIdx = iLeftViewIdx;
    542     iLeftView     = iView;
    543     iRightView    = iView;
    544     bFoundLRView  = false;
    545   }
    546 
    547   riLeftView           = iLeftView;
    548   riRightView          = iRightView;
    549   riLeftSortedViewIdx  = iLeftViewIdx;
    550   riRightSortedViewIdx = iRightViewIdx;
    551 
    552   return bFoundLRView;
    553 }
    554 
    555 
    556 Void
    557 TAppComCamPara::xGetPrevAndNextBaseView( Int iSourceViewNum, Int iTargetViewNum, Int& riPrevBaseViewNum, Int& riNextBaseViewNum )
    558 {
    559   Int iLeftView;
    560   Int iRightView;
    561   Int iDummy;
    562   xGetLeftRightView( iTargetViewNum, m_aiSortedBaseViews, iLeftView, iRightView, iDummy, iDummy );
    563 
    564   if( iLeftView == iRightView )
    565   {
    566     riPrevBaseViewNum = iLeftView;
    567     riNextBaseViewNum = iLeftView;
    568   }
    569   else
    570   {
    571     Bool bDecencdingVN   = ( m_aiSortedBaseViews.size() >= 2 && m_aiSortedBaseViews[ 0 ] > m_aiSortedBaseViews[ 1 ] );
    572     Bool bNextViewIsLeft = ( bDecencdingVN ? ( iSourceViewNum < iTargetViewNum ) : ( iSourceViewNum > iTargetViewNum ) );
    573     if ( bNextViewIsLeft )
    574     {
    575       riPrevBaseViewNum = iRightView;
    576       riNextBaseViewNum = iLeftView;
    577     }
    578     else
    579     {
    580       riPrevBaseViewNum = iLeftView;
    581       riNextBaseViewNum = iRightView;
    582     }
    583   }
    584 }
    585 
    586 
    587 Void
    588 TAppComCamPara::xGetZNearZFar( Int iView, UInt uiFrame, Double& rdZNear, Double& rdZFar )
    589 {
    590   UInt uiFoundLine = -1;
    591   if( !xGetCameraDataRow( iView, uiFrame, uiFoundLine ) || !( m_aadCameraParameters[ uiFoundLine ].size() < 8 ) )
    592   {
    593     rdZNear = m_aadCameraParameters[ uiFoundLine ][ 6 ];
    594     rdZFar  = m_aadCameraParameters[ uiFoundLine ][ 7 ];
    595   }
    596   else
    597   {
    598     std::cerr << "No ZNear or no ZFar for View " << (Double)iView / m_dViewNumPrec << " and Frame " << uiFrame << " given in CameraParameterFile" << std::endl;
    599     exit( EXIT_FAILURE );
    600   }
    601 }
    602 
    603 Void
    604 TAppComCamPara::xGetGeometryData( Int iView, UInt uiFrame, Double& rdFocalLength, Double& rdPosition, Double& rdCameraShift, Bool& rbInterpolated )
    605 {
    606   UInt uiFoundLine = -1;
    607   if ( !xGetCameraDataRow( iView, uiFrame, uiFoundLine ) && xIsIn( m_aiSortedBaseViews, iView ))
    608   {
    609     AOT( m_aadCameraParameters[ uiFoundLine ].size() < 6 );
    610     rbInterpolated = false;
    611     rdFocalLength =  m_aadCameraParameters[ uiFoundLine ][ 3 ];
    612     rdPosition    =  m_aadCameraParameters[ uiFoundLine ][ 4 ];
    613     rdCameraShift =  m_aadCameraParameters[ uiFoundLine ][ 5 ];
    614   }
    615   else
    616   {
    617     UInt uiLeftViewLine;
    618     UInt uiRightViewLine;
    619     Int  iLeftView;
    620     Int  iRightView;
    621     Int  iDummy;
    622 
    623     if( !xGetLeftRightView( iView, m_aiSortedBaseViews, iLeftView, iRightView, iDummy, iDummy ) ||
    624          xGetCameraDataRow( iLeftView,  uiFrame, uiLeftViewLine  )                             ||
    625          xGetCameraDataRow( iRightView, uiFrame, uiRightViewLine )
    626       )
    627     {
    628       std::cerr << "No left or no right base view next to view " << (Double)iView / m_dViewNumPrec << " for Frame " << uiFrame << " given in CameraParameterFile" << std::endl;
    629       AOT(true);
    630       exit( EXIT_FAILURE );
    631     }
    632     AOT( m_aadCameraParameters[ uiLeftViewLine  ].size() < 6 );
    633     AOT( m_aadCameraParameters[ uiRightViewLine ].size() < 6 );
    634 
    635     // Linear Interpolation
    636     Double dFactor = ( (Double)( iView - iLeftView ) ) / ( (Double)( iRightView - iLeftView ) );
    637     rdFocalLength  = m_aadCameraParameters[ uiLeftViewLine ][ 3 ] + dFactor * ( m_aadCameraParameters[ uiRightViewLine ][ 3 ] - m_aadCameraParameters[ uiLeftViewLine ][ 3 ] );
    638     rdPosition     = m_aadCameraParameters[ uiLeftViewLine ][ 4 ] + dFactor * ( m_aadCameraParameters[ uiRightViewLine ][ 4 ] - m_aadCameraParameters[ uiLeftViewLine ][ 4 ] );
    639     rdCameraShift  = m_aadCameraParameters[ uiLeftViewLine ][ 5 ] + dFactor * ( m_aadCameraParameters[ uiRightViewLine ][ 5 ] - m_aadCameraParameters[ uiLeftViewLine ][ 5 ] );
    640     rbInterpolated = true;
    641   }
    642 }
    643 
    644 Bool
    645 TAppComCamPara::xGetShiftParameterReal( UInt uiSourceView, UInt uiTargetView, UInt uiFrame, Bool bExternal, Bool bByIdx, Double& rdScale, Double& rdOffset )
    646 {
    647   AOT( m_bSetupFromCoded );
    648 
    649   Bool   bInterpolatedSource;
    650   Double dMinDepthSource;
    651   Double dMaxDepthSource;
    652   Double dFocalLengthSource;
    653   Double dPositionSource;
    654   Double dIntersectionSource;
    655 
    656   Bool   bInterpolatedTarget;
    657   Double dPositionTarget;
    658   Double dIntersectionTarget;
    659   Double dFocalLengthTarget;
    660 
    661   Int    iTargetViewNum;
    662   Int    iSourceViewNum;
    663 
    664   if( bByIdx )
    665   {
    666     iSourceViewNum = m_aiBaseViews[ uiSourceView ];
    667     iTargetViewNum = ( bExternal ? m_aiSynthViews[ uiTargetView ] : m_aiBaseViews[ uiTargetView ] );
    668   }
    669   else
    670   {
    671     iSourceViewNum = (Int) uiSourceView;
    672     iTargetViewNum = (Int) uiTargetView;
    673   }
    674 
    675   xGetGeometryData( iSourceViewNum, uiFrame, dFocalLengthSource, dPositionSource, dIntersectionSource, bInterpolatedSource );
    676   xGetZNearZFar   ( iSourceViewNum, uiFrame, dMinDepthSource,    dMaxDepthSource );
    677   xGetGeometryData( iTargetViewNum, uiFrame, dFocalLengthTarget, dPositionTarget, dIntersectionTarget, bInterpolatedTarget );
    678 
    679   Double dFactor = dFocalLengthSource * ( dPositionTarget - dPositionSource );
    680   rdScale        = dFactor * ( 1.0 / dMinDepthSource - 1.0 / dMaxDepthSource ) / (Double)( ( 1 << m_uiInputBitDepth ) - 1 );
    681   rdOffset       = dFactor / dMaxDepthSource - dIntersectionTarget + dIntersectionSource;
    682 
    683   return ( bInterpolatedSource || bInterpolatedTarget );
    684 }
    685 
    686 
    687 Void
    688 TAppComCamPara::xGetShiftParameterCoded( UInt uiSourceView, UInt uiTargetView, UInt uiFrame, Bool bByIdx, Int& riScale, Int& riOffset )
    689 {
    690   if ( m_bSetupFromCoded )
    691   {
    692     if ( uiSourceView == uiTargetView )
    693     {
    694       riScale  = 0;
    695       riOffset = 0;
    696       return;
    697     }
    698     Int iCamParsCodedPrecision;
    699     xGetCodedCameraData( uiSourceView, uiTargetView,  bByIdx, uiFrame, riScale, riOffset, iCamParsCodedPrecision );
    700 
    701     if ( m_bCamParsCodedPrecSet )
    702     {
    703       AOT( m_uiCamParsCodedPrecision != (UInt) iCamParsCodedPrecision );
    704     }
    705     else
    706     {
    707       m_uiCamParsCodedPrecision = (UInt) iCamParsCodedPrecision;
    708       m_bCamParsCodedPrecSet    = true;
    709     }
    710   }
    711   else
    712   {
    713     Double  dScale, dOffset;
    714     Bool    bInterpolated = xGetShiftParameterReal( uiSourceView, uiTargetView, uiFrame, false, bByIdx, dScale, dOffset );
    715     AOT(    bInterpolated ); // must be base view
    716 
    717     Double  dMultOffset   = (Double)( 1 << ( m_uiCamParsCodedPrecision + 1 ) );
    718     Double  dMultScale    = (Double)( 1 << ( m_uiCamParsCodedPrecision + 1 + m_uiInputBitDepth ) );
    719     riOffset              = (Int)floor( dMultOffset * dOffset + .5 );
    720     riScale               = (Int)floor( dMultScale  * dScale  + .5 );
    721   }
    722 }
    723 
    724 
    725 Void
    726 TAppComCamPara::xGetShiftParameterInt( UInt uiSourceView, UInt uiTargetView, UInt uiFrame, Bool bExternal, Bool bByIdx, Int64& riScale, Int64& riOffset )
    727 {
    728   Int    iTargetViewNum;
    729   Int    iSourceViewNum;
    730   Int    iPrevBaseViewNum;
    731   Int    iNextBaseViewNum;
    732   Int    iTargetViewRelNum;
    733 
    734   if( bByIdx )
    735   {
    736 
    737     iSourceViewNum = m_aiBaseViews[ uiSourceView ];
    738 
    739     if ( bExternal )
    740     {
    741       iTargetViewNum    = m_aiSynthViews      [ uiTargetView ];
    742       iTargetViewRelNum = m_aiRelSynthViewsNum[ uiTargetView ];
    743     }
    744     else
    745     {
    746       iTargetViewNum    = m_aiBaseViews       [ uiTargetView ];
    747       iTargetViewRelNum = m_aiBaseId2SortedId [ uiTargetView ] * ((Int) m_dViewNumPrec );
    748     }
    749   }
    750   else
    751   {
    752     iSourceViewNum = (Int) uiSourceView;
    753     iTargetViewNum = (Int) uiTargetView;
    754 
    755     if ( bExternal )
    756     {
    757       iTargetViewRelNum = m_aiRelSynthViewsNum[ xGetViewId( m_aiSynthViews, (Int) uiTargetView )];
    758     }
    759     else
    760     {
    761       iTargetViewRelNum = m_aiBaseId2SortedId[ xGetBaseViewId( uiTargetView) ] * ((Int) m_dViewNumPrec );
    762     }
    763   }
    764   xGetPrevAndNextBaseView( iSourceViewNum, iTargetViewNum, iPrevBaseViewNum, iNextBaseViewNum );
    765   AOT( iPrevBaseViewNum == -1 ); // should not happen
    766   AOT( iNextBaseViewNum == -1 ); // should not happen
    767 
    768   Int iSrcId    = xGetBaseViewId( iSourceViewNum   );
    769   Int iPrevId   = xGetBaseViewId( iPrevBaseViewNum );
    770   Int iNextId   = xGetBaseViewId( iNextBaseViewNum );
    771   AOF( m_aaiScaleAndOffsetSet[ iSrcId ][ iPrevId ] ); // coded scale and offset must be set
    772   AOF( m_aaiScaleAndOffsetSet[ iSrcId ][ iNextId ] ); // coded scale and offset must be set
    773 
    774   Int iNextBaseViewRelNum = m_aiBaseId2SortedId[ iNextId ] * ((Int) m_dViewNumPrec );
    775   Int iPrevBaseViewRelNum = m_aiBaseId2SortedId[ iPrevId ] * ((Int) m_dViewNumPrec );
    776 
    777   Int64 iPrevScale  = (Int64)m_aaiCodedScale [ iSrcId ][ iPrevId ];
    778   Int64 iNextScale  = (Int64)m_aaiCodedScale [ iSrcId ][ iNextId ];
    779   Int64 iPrevOffset = (Int64)m_aaiCodedOffset[ iSrcId ][ iPrevId ] << m_uiBitDepthForLUT;
    780   Int64 iNextOffset = (Int64)m_aaiCodedOffset[ iSrcId ][ iNextId ] << m_uiBitDepthForLUT;
    781 
    782   if( iPrevBaseViewNum == iNextBaseViewNum )
    783   {
    784     riScale   = iNextScale;
    785     riOffset  = iNextOffset;
    786   }
    787   else
    788   {
    789     riScale   = Int64( iTargetViewRelNum    - iPrevBaseViewRelNum ) * iNextScale;
    790     riScale  += Int64( iNextBaseViewRelNum  - iTargetViewRelNum   ) * iPrevScale;
    791     riOffset  = Int64( iTargetViewRelNum   - iPrevBaseViewRelNum ) * iNextOffset;
    792     riOffset += Int64( iNextBaseViewRelNum - iTargetViewRelNum   ) * iPrevOffset;
    793     Int64 iD  = Int64( iNextBaseViewRelNum - iPrevBaseViewRelNum );
    794     Int64 iSA = ( riScale  > 0 ? iD / 2 : -iD / 2 );
    795     Int64 iOA = ( riOffset > 0 ? iD / 2 : -iD / 2 );
    796     riScale   = ( riScale  + iSA  ) / iD;
    797     riOffset  = ( riOffset + iOA  ) / iD;
    798   }
    799 }
    800 
    801 
    802 Void
    803 TAppComCamPara::xSetCodedScaleOffset( UInt uiFrame )
    804 {
    805   for( UInt uiSourceId = 0; uiSourceId < m_iNumberOfBaseViews; uiSourceId++ )
    806   {
    807     for( UInt uiTargetId = 0; uiTargetId < m_iNumberOfBaseViews; uiTargetId++ )
    808     {
    809       Int iScale, iOffset;
    810       xGetShiftParameterCoded( uiSourceId, uiTargetId, uiFrame, true, iScale, iOffset );
    811       m_aaiCodedScale        [ uiSourceId ][ uiTargetId ] = iScale;
    812       m_aaiCodedOffset       [ uiSourceId ][ uiTargetId ] = iOffset;
    813       m_aaiScaleAndOffsetSet [ uiSourceId ][ uiTargetId ] = 1;
    814     }
    815   }
    816 }
    817 
    818 
    819 Void
    820 TAppComCamPara::xSetShiftParametersAndLUT( UInt uiNumberSourceViews, UInt uiNumberTargetViews, UInt uiFrame, Bool bExternalReference , Double****& radLUT, Int****& raiLUT, Double***& radShiftParams, Int64***& raiShiftParams )
    821 {
    822   if( uiNumberSourceViews <= 1 || uiNumberTargetViews == 0 )
    823   {
    824     return;
    825   }
    826   AOF( radShiftParams != NULL && raiShiftParams != NULL && radLUT != NULL && raiLUT != NULL );
    827   AOF( m_uiBitDepthForLUT == 8 );
    828 
    829   Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_uiCamParsCodedPrecision + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
    830   Int     iLog2DivChroma = iLog2DivLuma + 1;
    831 
    832   Double  dMaxDispDev    = 0.0;
    833   Double  dMaxRndDispDvL = 0.0;
    834   Double  dMaxRndDispDvC = 0.0;
    835 
    836   for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ )
    837   {
    838     for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ )
    839     {
    840 
    841       // integer-valued scale and offset
    842       Int64 iScale, iOffset;
    843       xGetShiftParameterInt ( uiSourceView, uiTargetView, uiFrame, bExternalReference, true, iScale, iOffset );
    844       raiShiftParams[ uiSourceView][ uiTargetView ][ 0 ] = iScale;
    845       raiShiftParams[ uiSourceView][ uiTargetView ][ 1 ] = iOffset;
    846 
    847       // offsets including rounding offsets
    848       Int64 iOffsetLuma   = iOffset + ( ( 1 << iLog2DivLuma   ) >> 1 );
    849       Int64 iOffsetChroma = iOffset + ( ( 1 << iLog2DivChroma ) >> 1 );
    850 
    851       // real-valued scale and offset
    852       Double dScale, dOffset;
    853 
    854       if ( m_bSetupFromCoded )
    855       {
    856         dScale  = (Double) iScale  / (( Double ) ( 1 << iLog2DivLuma ));
    857         dOffset = (Double) iOffset / (( Double ) ( 1 << iLog2DivLuma ));
    858       }
    859       else
    860       {
    861         xGetShiftParameterReal( uiSourceView, uiTargetView, uiFrame, bExternalReference, true, dScale, dOffset );
    862       }
    863 
    864       radShiftParams[ uiSourceView][ uiTargetView ][ 0 ] = dScale;
    865       radShiftParams[ uiSourceView][ uiTargetView ][ 1 ] = dOffset;
    866 
    867       for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ )
    868       {
    869         // real-valued look-up tables
    870         Double  dShiftLuma      = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
    871         Double  dShiftChroma    = dShiftLuma / 2;
    872         radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma;
    873         radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = dShiftChroma;
    874 
    875         // integer-valued look-up tables
    876         Int64   iTempScale      = (Int64)uiDepthValue * iScale;
    877         Int64   iTestScale      = ( iTempScale + iOffset       );   // for checking accuracy of camera parameters
    878         Int64   iShiftLuma      = ( iTempScale + iOffsetLuma   ) >> iLog2DivLuma;
    879         Int64   iShiftChroma    = ( iTempScale + iOffsetChroma ) >> iLog2DivChroma;
    880         raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = (Int)iShiftLuma;
    881         raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = (Int)iShiftChroma;
    882 
    883         // maximum deviation
    884 #if NH_3D_REN_MAX_DEV_OUT
    885         m_dMaxShiftDeviation = std::max( m_dMaxShiftDeviation, fabs( Double( (Int) iShiftLuma   ) - dShiftLuma   ) / Double( 1 << m_iLog2Precision ) );       
    886 #endif
    887         dMaxDispDev     = std::max( dMaxDispDev,    fabs( Double( (Int) iTestScale   ) - dShiftLuma * Double( 1 << iLog2DivLuma ) ) / Double( 1 << iLog2DivLuma ) );
    888         dMaxRndDispDvL  = std::max( dMaxRndDispDvL, fabs( Double( (Int) iShiftLuma   ) - dShiftLuma   ) );
    889         dMaxRndDispDvC  = std::max( dMaxRndDispDvC, fabs( Double( (Int) iShiftChroma ) - dShiftChroma ) );
    890       }
    891 
    892       radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
    893       radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
    894       raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
    895       raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
    896     }
    897   }
    898 
    899   // check maximum deviation
    900   Double  dMaxAllowedDispDev    =       Double( 1 << m_iLog2Precision ) / Double( 1 << m_uiCamParsCodedPrecision );       //  counting only the impact of camera parameter rounding
    901   Double  dMaxAllowedRndDispDvL = 0.5 + Double( 1 << m_iLog2Precision ) / Double( 1 << m_uiCamParsCodedPrecision );       // final rounding and impact of camera parameter rounding
    902   Double  dMaxAllowedRndDispDvC = 0.5 + Double( 1 << m_iLog2Precision ) / Double( 1 << m_uiCamParsCodedPrecision ) / 2.0; // final rounding and impact of camera parameter rounding
    903 
    904   if( ( dMaxDispDev >= dMaxAllowedDispDev || dMaxRndDispDvL >= dMaxAllowedRndDispDvL || dMaxRndDispDvC >= dMaxAllowedRndDispDvC ) && !m_bSetupFromCoded )
    905   {
    906     std::cout << "Warning: Something wrong with the accuracy of coded camera parameters:" << std::endl;
    907     if( dMaxDispDev    >= dMaxAllowedDispDev    )
    908     {
    909       std::cout << "   max disparity difference is " << dMaxDispDev    << " (allowed: " << dMaxAllowedDispDev    << ")" << std::endl;
    910     }
    911     if( dMaxRndDispDvL >= dMaxAllowedRndDispDvL )
    912     {
    913       std::cout << "   max rnd luma   disp diff is " << dMaxRndDispDvL << " (allowed: " << dMaxAllowedRndDispDvL << ")" << std::endl;
    914     }
    915     if( dMaxRndDispDvC >= dMaxAllowedRndDispDvC )
    916     {
    917       std::cout << "   max rnd chroma disp diff is " << dMaxRndDispDvC << " (allowed: " << dMaxAllowedRndDispDvC << ")" << std::endl;
    918     }
    919   }
    920 }
    921 
    922 Void
    923 TAppComCamPara::xSetShiftParametersAndLUT( UInt uiFrame )
    924 {
    925   xInit2dArray             ( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiScaleAndOffsetSet, 0 );
    926   xSetCodedScaleOffset     (                                                          uiFrame );
    927   xSetShiftParametersAndLUT( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  uiFrame, false, m_adBaseViewShiftLUT,  m_aiBaseViewShiftLUT,  m_adBaseViewShiftParameter,  m_aiBaseViewShiftParameter  );
    928   xSetShiftParametersAndLUT( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfSynthViews, uiFrame, true,  m_adSynthViewShiftLUT, m_aiSynthViewShiftLUT, m_adSynthViewShiftParameter, m_aiSynthViewShiftParameter );
    929 };
    930 
    931 
    932 Void
    933 TAppComCamPara::xGetCameraShifts( UInt uiSourceView, UInt uiTargetView, UInt uiFrame, Double& rdCamPosShift, Double& rdPicPosShift )
    934 {
    935   Double  dDummy, dCamPosSource, dCamPosTarget, dPicPosSource, dPicPosTarget;
    936   Bool    bInterpolatedSource, bInterpolatedTarget;
    937   Int     iTargetViewNum = m_aiBaseViews[ uiTargetView ];
    938   Int     iSourceViewNum = m_aiBaseViews[ uiSourceView ];
    939 
    940   xGetGeometryData( iSourceViewNum, uiFrame, dDummy, dCamPosSource, dPicPosSource, bInterpolatedSource );
    941   xGetGeometryData( iTargetViewNum, uiFrame, dDummy, dCamPosTarget, dPicPosTarget, bInterpolatedTarget );
    942   AOT( bInterpolatedSource || bInterpolatedTarget );
    943 
    944   rdCamPosShift =  ( dCamPosTarget - dCamPosSource );
    945   rdPicPosShift = -( dPicPosTarget - dPicPosSource ); // to be consistent
    946 }
    947 
    948 
    949 
    950 
    951 
    952 
    953 TAppComCamPara::TAppComCamPara()
    954 {
    955   m_dViewNumPrec              = VIEW_NUM_PREC;  // fixed
    956   m_iLog2Precision            = -1;
    957   m_uiInputBitDepth           = 0;
    958   m_uiBitDepthForLUT          = 8;              // fixed
    959   m_uiFirstFrameId            = 0;
    960   m_uiLastFrameId             = 0;
    961 
    962   m_iNumberOfBaseViews        = -1;
    963   m_iNumberOfSynthViews       = -1;
    964 
    965   m_uiCamParsCodedPrecision   = 0;
    966   m_bCamParsVaryOverTime      = true;
    967 
    968   m_aaiCodedScale             = 0;
    969   m_aaiCodedOffset            = 0;
    970   m_aaiScaleAndOffsetSet      = 0;
    971 
    972   m_adBaseViewShiftParameter  = 0;
    973   m_aiBaseViewShiftParameter  = 0;
    974   m_adSynthViewShiftParameter = 0;
    975   m_aiSynthViewShiftParameter = 0;
    976 
    977   m_adBaseViewShiftLUT        = 0;
    978   m_aiBaseViewShiftLUT        = 0;
    979   m_adSynthViewShiftLUT       = 0;
    980   m_aiSynthViewShiftLUT       = 0;
    981 
    982   m_bSetupFromCoded           = false;
    983   m_bCamParsCodedPrecSet      = false;
    984 
    985 #if NH_3D_REN_MAX_DEV_OUT
    986   m_dMaxShiftDeviation        = -1;
    987 #endif
    988 
    989 }
    990 
    991 
    992 TAppComCamPara::~TAppComCamPara()
    993 {
    994   xDeleteArray( m_adBaseViewShiftParameter,  m_iNumberOfBaseViews, m_iNumberOfBaseViews     );
    995   xDeleteArray( m_aiBaseViewShiftParameter,  m_iNumberOfBaseViews, m_iNumberOfBaseViews     );
    996   xDeleteArray( m_adBaseViewShiftLUT,        m_iNumberOfBaseViews, m_iNumberOfBaseViews,  2 );
    997   xDeleteArray( m_aiBaseViewShiftLUT,        m_iNumberOfBaseViews, m_iNumberOfBaseViews,  2 );
    998 
    999   xDeleteArray( m_adSynthViewShiftParameter, m_iNumberOfBaseViews, std::max((Int) 1 ,m_iNumberOfSynthViews));
    1000   xDeleteArray( m_aiSynthViewShiftParameter, m_iNumberOfBaseViews, std::max((Int) 1 ,m_iNumberOfSynthViews));
    1001   xDeleteArray( m_adSynthViewShiftLUT,       m_iNumberOfBaseViews, std::max((Int) 1 ,m_iNumberOfSynthViews), 2 );
    1002   xDeleteArray( m_aiSynthViewShiftLUT,       m_iNumberOfBaseViews, std::max( (Int)1 ,m_iNumberOfSynthViews), 2 );
    1003 
    1004   xDeleteArray( m_aaiCodedScale,             m_iNumberOfBaseViews );
    1005   xDeleteArray( m_aaiCodedOffset,            m_iNumberOfBaseViews );
    1006   xDeleteArray( m_aaiScaleAndOffsetSet,      m_iNumberOfBaseViews );
    1007 
    1008 }
    1009 
    1010 Void
    1011 TAppComCamPara::xSetupBaseViewsFromCoded()
    1012 {
    1013   //===== get and sort views given in camera parameter file and set list of base views and related arrays =====
    1014   // get left-right order and coding order from cfg-file
    1015   std::vector<Int> aiViewOrderIdx;   // Left Right Order
    1016   std::vector<Int> aiViewId ;        // Coding     Order
    1017 
    1018   Int iMinViewOrderIdx = MAX_INT;
    1019   for( UInt uiRow = 0; uiRow < m_aadCameraParameters.size(); uiRow++ )
    1020   {
    1021     if (m_aadCameraParameters[uiRow].size() != 2 )
    1022       break;
    1023 
    1024     Int iViewOrderIdx  = (Int)( m_aadCameraParameters[ uiRow ][ 1 ] );
    1025     iMinViewOrderIdx   = std::min( iViewOrderIdx, iMinViewOrderIdx );
    1026 
    1027     aiViewOrderIdx     .push_back( iViewOrderIdx );
    1028     aiViewId           .push_back( (Int) m_aadCameraParameters[ uiRow ][ 0 ]  );
    1029   }
    1030 
    1031   // create base view numbers
    1032   AOT( aiViewId.size() != aiViewOrderIdx.size() );
    1033   m_iNumberOfBaseViews = (Int) aiViewId.size();
    1034   for (Int iCurBaseView = 0; iCurBaseView < m_iNumberOfBaseViews; iCurBaseView++ )
    1035   {
    1036     aiViewOrderIdx[iCurBaseView] = ( aiViewOrderIdx[iCurBaseView] - iMinViewOrderIdx);
    1037     m_aiBaseViews      .push_back(  aiViewOrderIdx[iCurBaseView] * ( (Int) m_dViewNumPrec) );
    1038     m_aiBaseId2SortedId.push_back( iCurBaseView );
    1039     m_aiBaseSortedId2Id.push_back( iCurBaseView );
    1040   }
    1041 
    1042   m_iNumberOfBaseViews = (Int) m_aiBaseViews.size();
    1043 
    1044   std::vector<Int> aiSortedViewOrderIdx = aiViewOrderIdx;
    1045 
    1046   // sort base views according to View Order Idx
    1047   m_aiSortedBaseViews = m_aiBaseViews;
    1048   for (Int iCurBaseView = 1; iCurBaseView < m_iNumberOfBaseViews; iCurBaseView++ )
    1049   {
    1050     Int iCurViewOrder = aiSortedViewOrderIdx[iCurBaseView];
    1051     for (Int iCurSearchPos = iCurBaseView; iCurSearchPos >= 0; iCurSearchPos-- )
    1052     {
    1053       if ( iCurViewOrder < aiSortedViewOrderIdx[iCurSearchPos] )
    1054       {
    1055         Int iTempViewId = m_aiSortedBaseViews[iCurSearchPos];
    1056         m_aiSortedBaseViews[iCurSearchPos] = m_aiSortedBaseViews[iCurBaseView];
    1057         m_aiSortedBaseViews[iCurBaseView ] = iTempViewId;
    1058 
    1059         Int iTempViewOrderIdx = aiSortedViewOrderIdx[iCurSearchPos];
    1060         aiSortedViewOrderIdx[iCurSearchPos] = aiSortedViewOrderIdx[iCurBaseView];
    1061         aiSortedViewOrderIdx[iCurBaseView ] = iTempViewOrderIdx;
    1062 
    1063         Int iTempPos = m_aiBaseSortedId2Id[iCurSearchPos];
    1064         m_aiBaseSortedId2Id[iCurSearchPos] = m_aiBaseSortedId2Id[iCurBaseView];
    1065         m_aiBaseSortedId2Id[iCurBaseView] = iTempPos;
    1066         iCurBaseView--;
    1067       }
    1068     }
    1069   }
    1070 
    1071   for (Int iCurBaseView = 0; iCurBaseView < m_iNumberOfBaseViews; iCurBaseView++ )
    1072   {
    1073     m_aiBaseId2SortedId[m_aiBaseSortedId2Id[iCurBaseView]] = iCurBaseView;
    1074   }
    1075 
    1076   m_aiViewsInCfgFile = m_aiSortedBaseViews;
    1077 
    1078   // check
    1079   if( m_aiViewsInCfgFile.size() < 2 )
    1080   {
    1081     std::cerr << "Failed reading camera parameter file" << std::endl;
    1082     std::cerr << "At least two views must be given" << std::endl;
    1083     AOT(true);
    1084     exit( EXIT_FAILURE );
    1085   }
    1086 
    1087   // translate coding order to view order
    1088   for( UInt uiRow = 0; uiRow < m_aadCameraParameters.size(); uiRow++ )
    1089 {
    1090     if (m_aadCameraParameters[uiRow].size() == 2 )
    1091       continue;
    1092 
    1093     m_aadCameraParameters[ uiRow ][ 2 ] = (Double) aiViewOrderIdx[ xGetViewId( aiViewId, (Int) m_aadCameraParameters[ uiRow ][ 2 ] ) ];
    1094     m_aadCameraParameters[ uiRow ][ 3 ] = (Double) aiViewOrderIdx[ xGetViewId( aiViewId, (Int) m_aadCameraParameters[ uiRow ][ 3 ] ) ];
    1095   }
    1096 }
    1097 
    1098 Void TAppComCamPara::xSetupBaseViews( TChar* pchBaseViewNumbers, UInt uiNumBaseViews )
    1099   {
    1100     // init list
    1101     std::vector<Int> aiViewsInCfg;
    1102     for( UInt uiRow = 0; uiRow < m_aadCameraParameters.size(); uiRow++ )
    1103     {
    1104       aiViewsInCfg.push_back( (Int)( m_aadCameraParameters[ uiRow ][ 0 ] * m_dViewNumPrec ) );
    1105     }
    1106     // remove duplicated items
    1107     std::sort( aiViewsInCfg.begin(), aiViewsInCfg.end() );
    1108     std::vector<Int>::iterator cIterNewEnd = std::unique( aiViewsInCfg.begin(), aiViewsInCfg.end() );
    1109     aiViewsInCfg.erase( cIterNewEnd, aiViewsInCfg.end() );
    1110     // sort (from left to right)
    1111     std::vector<Int> aiDummyI2SI, aiDummySI2I;
    1112     xGetSortedViewList( aiViewsInCfg, m_aiViewsInCfgFile, aiDummyI2SI, aiDummySI2I );
    1113     // check
    1114     if( m_aiViewsInCfgFile.size() < 2 )
    1115     {
    1116       std::cerr << "Failed reading config file" << std::endl;
    1117       std::cerr << "At least two views must be given" << std::endl;
    1118       exit( EXIT_FAILURE );
    1119     }
    1120 
    1121 
    1122 
    1123   //===== set list of base views and related arrays =====
    1124   if( pchBaseViewNumbers == 0 )
    1125   {
    1126     std::cerr << "BaseViewCameraNumbers must be given" << std::endl;
    1127     exit( EXIT_FAILURE );
    1128   };
    1129 
    1130   convertNumberString( pchBaseViewNumbers, m_aiBaseViews, m_dViewNumPrec  );
    1131   while( (UInt)m_aiBaseViews.size() > uiNumBaseViews )
    1132   {
    1133     m_aiBaseViews.pop_back();
    1134   }
    1135   xGetSortedViewList( m_aiBaseViews, m_aiSortedBaseViews, m_aiBaseId2SortedId, m_aiBaseSortedId2Id );
    1136   m_iNumberOfBaseViews = (Int)m_aiBaseViews.size();
    1137 }
    1138 
    1139 
    1140 Void
    1141 TAppComCamPara::init( UInt   uiNumBaseViews,
    1142                       UInt   uiInputBitDepth,
    1143                       UInt   uiCodedCamParsPrecision,
    1144                       UInt   uiStartFrameId,
    1145                       UInt   uiNumFrames,
    1146                       TChar* pchCfgFileName,
    1147                       TChar* pchBaseViewNumbers,
    1148                       TChar* pchSynthViewNumbers,
    1149                       std::vector<Int>* paiSynthViewNumbers,
    1150                       Int    iLog2Precision )
    1151 {
    1152   //===== set miscellaneous variables =====
    1153   m_uiInputBitDepth         = uiInputBitDepth;
    1154   m_uiFirstFrameId          = uiStartFrameId;
    1155   m_uiLastFrameId           = uiStartFrameId + uiNumFrames - 1;
    1156   m_uiCamParsCodedPrecision = uiCodedCamParsPrecision;
    1157   m_iLog2Precision          = iLog2Precision;
    1158 
    1159   xReadCameraParameterFile( pchCfgFileName );
    1160 
    1161   m_bSetupFromCoded         = ( m_aadCameraParameters[ 0 ].size() == 2 );
    1162 
    1163   if ( m_bSetupFromCoded )
    1164   {
    1165     std::cout << "Detected decoded camera parameter file. Overwriting base view settings from cfg file. " << std::endl;
    1166     xSetupBaseViewsFromCoded();
    1167   }
    1168   else
    1169   {
    1170     xSetupBaseViews( pchBaseViewNumbers, uiNumBaseViews );
    1171   }
    1172 
    1173   //===== set list of external (virtual) views =====
    1174   m_aiSynthViews.clear();
    1175 
    1176   if( pchSynthViewNumbers != 0 || paiSynthViewNumbers != 0)
    1177   {
    1178     std::vector<Int> aiTmpSynthViews;
    1179 
    1180     AOT( ( pchSynthViewNumbers != NULL ) && ( paiSynthViewNumbers != NULL ) );
    1181 
    1182     if ( pchSynthViewNumbers != NULL )
    1183     {
    1184       convertNumberString( pchSynthViewNumbers, aiTmpSynthViews, m_dViewNumPrec );
    1185     }
    1186     else
    1187     {
    1188       aiTmpSynthViews = (*paiSynthViewNumbers);
    1189     }
    1190 
    1191     for( UInt uiSId = 0; uiSId < (UInt)aiTmpSynthViews.size(); uiSId++ )
    1192     {
    1193 
    1194       Int iViewNumPrec        = (Int) m_dViewNumPrec;
    1195       Int iLeftBaseViewIdx    =   aiTmpSynthViews[ uiSId ]                        / iViewNumPrec;
    1196       Int iRightBaseViewIdx   = ( aiTmpSynthViews[ uiSId ] + (iViewNumPrec - 1) ) / iViewNumPrec;
    1197 
    1198       if ( iLeftBaseViewIdx < 0 || iRightBaseViewIdx >= m_iNumberOfBaseViews )
    1199       {
    1200         std::cerr << "SynthViewCameraNumbers must be greater and equal to 0 and smaller than number of base views" << std::endl;
    1201         AOT(true);
    1202         exit( EXIT_FAILURE );
    1203       }
    1204 
    1205       Int64  iLeftBaseViewRelNum = iLeftBaseViewIdx  * iViewNumPrec;
    1206       Int64 iRightBaseViewRelNum = iRightBaseViewIdx * iViewNumPrec;
    1207 
    1208       Int64 iDiffBaseViewRelNum  = iRightBaseViewRelNum - iLeftBaseViewRelNum;
    1209 
    1210       Int64 iSynthViewRelNum     = aiTmpSynthViews[ uiSId ];
    1211       Int64 iLeftBaseNum         = m_aiSortedBaseViews[ iLeftBaseViewIdx  ];
    1212       Int64 iRightBaseNum        = m_aiSortedBaseViews[ iRightBaseViewIdx ];
    1213       Int64 iDiffBaseNum         = iRightBaseNum - iLeftBaseNum;
    1214       Int64 iSynthViewNum;
    1215 
    1216       if ( iDiffBaseViewRelNum != 0)
    1217       {
    1218         AOT( (Int) iDiffBaseViewRelNum != iViewNumPrec );
    1219         Int iFact = iDiffBaseNum > 0 ? 1 : -1;
    1220         iSynthViewNum = iLeftBaseNum + ( iDiffBaseNum * ( iSynthViewRelNum - iLeftBaseViewRelNum ) + (iViewNumPrec >> 1) * iFact ) / ( iViewNumPrec );
    1221       }
    1222       else
    1223       {
    1224         iSynthViewNum = iLeftBaseNum;
    1225       }
    1226 
    1227       m_aiRelSynthViewsNum.push_back(  aiTmpSynthViews[ uiSId ] );
    1228       m_aiSynthViews      .push_back(  (Int) iSynthViewNum  );
    1229     }
    1230   }
    1231   m_iNumberOfSynthViews = (Int)m_aiSynthViews.size();
    1232 
    1233 
    1234   //===== set derived parameters =====
    1235   m_bCamParsVaryOverTime = xGetCamParsChangeFlag();
    1236 
    1237 
    1238   //===== create arrays =====
    1239   xCreateLUTs   ( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_adBaseViewShiftLUT,  m_aiBaseViewShiftLUT,  m_adBaseViewShiftParameter,  m_aiBaseViewShiftParameter  );
    1240   xCreateLUTs   ( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfSynthViews, m_adSynthViewShiftLUT, m_aiSynthViewShiftLUT, m_adSynthViewShiftParameter, m_aiSynthViewShiftParameter );
    1241   xCreate2dArray( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiCodedScale           );
    1242   xCreate2dArray( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiCodedOffset          );
    1243   xCreate2dArray( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiScaleAndOffsetSet    );
    1244   xInit2dArray  ( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiScaleAndOffsetSet, 0 );
    1245 
    1246   //===== init arrays for first frame =====
    1247   xSetShiftParametersAndLUT( m_uiFirstFrameId );
    1248 }
    1249 
    1250 
    1251 Void
    1252 TAppComCamPara::check( Bool bCheckViewRange, Bool bCheckFrameRange )
    1253 {
    1254   if( bCheckFrameRange )
    1255   {
    1256     Double dDummy;
    1257 
    1258     for( UInt uiBaseView = 0; uiBaseView < m_aiBaseViews.size(); uiBaseView++ )
    1259     {
    1260       if ( m_bSetupFromCoded )
    1261       {
    1262         for( UInt uiTargetView = 0; uiTargetView < m_aiBaseViews.size(); uiTargetView++ )
    1263         {
    1264           if ( uiTargetView == uiBaseView )
    1265             continue;
    1266 
    1267           for( UInt uiFrame = m_uiFirstFrameId; uiFrame <= m_uiLastFrameId; uiFrame++ )
    1268           {
    1269             Int iDummy;
    1270 
    1271             xGetCodedCameraData( uiBaseView, uiTargetView, true , uiFrame, iDummy, iDummy, iDummy );
    1272           }
    1273         }
    1274       }
    1275       else
    1276       {
    1277         for( UInt uiFrame = m_uiFirstFrameId; uiFrame <= m_uiLastFrameId; uiFrame++ )
    1278         {
    1279           Bool bInterpolatedCur;
    1280           xGetGeometryData( m_aiBaseViews[ uiBaseView ], uiFrame, dDummy, dDummy, dDummy, bInterpolatedCur );
    1281           xGetZNearZFar   ( m_aiBaseViews[ uiBaseView ], uiFrame, dDummy, dDummy );
    1282 
    1283           if( bInterpolatedCur )
    1284           {
    1285             std::cerr << "Error: CameraParameters for BaseView " << (Double)m_aiBaseViews[ uiBaseView ] / m_dViewNumPrec << " and Frame " << uiFrame << " not defined. "  << std::endl;
    1286             exit( EXIT_FAILURE );
    1287           }
    1288         }
    1289       }
    1290     }
    1291 
    1292     Bool bIgnoreFirst = true;     
    1293     for( UInt uiERView = 0; uiERView < m_aiSynthViews.size() && !m_bSetupFromCoded; uiERView++ )
    1294     {
    1295       if ( xIsIn(m_aiViewsInCfgFile, m_aiSynthViews[ uiERView ] ) )
    1296       {
    1297         if ( bIgnoreFirst )
    1298         {
    1299           std::cout << "Ignoring CameraParameterFile entries for virtual view(s): " ;
    1300           //GT: Integer precision virtual view camera parameters are always interpolated from coded views camera parameters.
    1301           bIgnoreFirst = false;
    1302         }
    1303         std::cout << (Double)m_aiSynthViews[ uiERView ] / m_dViewNumPrec << " " ;
    1304       }
    1305     }
    1306     if ( !bIgnoreFirst )
    1307     {
    1308       std::cout << std::endl;
    1309     }
    1310 
    1311     Bool bInterpolateFirst = true;
    1312     Bool bAnyInterpolated  = false;
    1313     for( UInt uiERView = 0; uiERView < m_aiSynthViews.size() && !m_bSetupFromCoded; uiERView++ )
    1314     {
    1315       Bool bInterpolated = false;
    1316       for( UInt uiFrame = m_uiFirstFrameId; uiFrame <= m_uiLastFrameId; uiFrame++ )
    1317       {
    1318         Bool bInterpolatedCur;
    1319         xGetGeometryData( m_aiSynthViews[ uiERView ], uiFrame, dDummy, dDummy, dDummy, bInterpolatedCur );
    1320         bInterpolated |= bInterpolatedCur;
    1321       }
    1322      
    1323       if( bInterpolated )
    1324       {
    1325         bAnyInterpolated = true;
    1326         if ( bInterpolateFirst )
    1327         {
    1328           std::cout << "Interpolating camera parameters      for virtual view(s): " ;
    1329             bInterpolateFirst = false;
    1330         }         
    1331         std::cout << (Double)m_aiSynthViews[ uiERView ] / m_dViewNumPrec << " " ;
    1332       }
    1333     }
    1334     if ( bAnyInterpolated )
    1335       std::cout << std::endl;
    1336   }
    1337 
    1338   if( bCheckViewRange )
    1339   {
    1340     Bool bAllExist = true;
    1341     for( Int iSynthViewIdx = 0; iSynthViewIdx < m_iNumberOfSynthViews; iSynthViewIdx++ )
    1342     {
    1343       Bool bIsBaseView;
    1344       Int  iDummy;
    1345       Bool bExist = getLeftRightBaseView( iSynthViewIdx, iDummy, iDummy, iDummy, bIsBaseView );
    1346       bAllExist  &= ( bExist || bIsBaseView );
    1347     }
    1348     if( !bAllExist )
    1349     {
    1350       std::cerr << "SynthViewNumbers must be within the range of BaseViewNumbers"  << std::endl;
    1351       exit( EXIT_FAILURE );
    1352     }
    1353   }
    1354 }
    1355 
    1356 
    1357 Void
    1358 TAppComCamPara::update( UInt uiFrameId )
    1359 {
    1360 
    1361   m_iCurrentFrameId = uiFrameId;
    1362   m_bCamParsCodedPrecSet = false;
    1363 
    1364   if ( m_bCamParsVaryOverTime )
    1365   {
    1366     xSetShiftParametersAndLUT( m_uiFirstFrameId + uiFrameId );
    1367   }
    1368 }
    1369 
    1370 #if NH_3D_VSO
    1371 Void
    1372 TAppComCamPara::setDispCoeff( UInt uiFrameId, Int iViewIdx )
    1373 {
    1374   UInt uiFrame = m_uiFirstFrameId + uiFrameId;
    1375   Int  iSourceViewNum = m_aiBaseViews[ iViewIdx ];
    1376   Double dBaseLine = 0.0;
    1377   Double dFL1 = 1.0, dCS1 = 1.0, dCP1 = 1.0, dZN1 = 1.0, dZF1 = 1.0;
    1378   Bool bInterpolated = false;
    1379   double dPos[3] = {0.0, 0.0, 0.0};
    1380 
    1381   if( m_iNumberOfBaseViews == 3 )
    1382   {
    1383     xGetGeometryData( m_aiBaseViews[0], uiFrame, dFL1, dPos[0], dCS1, bInterpolated );
    1384     xGetGeometryData( m_aiBaseViews[1], uiFrame, dFL1, dPos[1], dCS1, bInterpolated );
    1385     xGetGeometryData( m_aiBaseViews[2], uiFrame, dFL1, dPos[2], dCS1, bInterpolated );
    1386 
    1387     xGetGeometryData( iSourceViewNum, uiFrame, dFL1, dCP1, dCS1, bInterpolated );
    1388     xGetZNearZFar   ( iSourceViewNum, uiFrame, dZN1, dZF1 );
    1389 
    1390     dBaseLine = ( std::max( dPos[0], std::max( dPos[1], dPos[2] ) ) - std::min( dPos[0], std::min( dPos[1], dPos[2] ) ) ) / 2.0;
    1391   }
    1392   else if( m_iNumberOfBaseViews == 2 )
    1393   {
    1394     xGetGeometryData( m_aiBaseViews[0], uiFrame, dFL1, dPos[0], dCS1, bInterpolated );
    1395     xGetGeometryData( m_aiBaseViews[1], uiFrame, dFL1, dPos[1], dCS1, bInterpolated );
    1396 
    1397     xGetGeometryData( iSourceViewNum, uiFrame, dFL1, dCP1, dCS1, bInterpolated );
    1398     xGetZNearZFar   ( iSourceViewNum, uiFrame, dZN1, dZF1 );
    1399 
    1400     dBaseLine = dPos[0] - dPos[1];
    1401   }
    1402 
    1403   m_dDispCoeff = fabs( dFL1 * ( dBaseLine / 2.0 ) / 255.0 * ( 1.0/dZN1 - 1.0/dZF1 ) );
    1404 }
    1405 #endif
    1406 
    1407 Bool
    1408 TAppComCamPara::getLeftRightBaseView( Int iSynthViewIdx, Int &riLeftViewIdx, Int &riRightViewIdx, Int &riRelDistToLeft, Bool& rbIsBaseView )
    1409 {
    1410   Int    iLeftSortedViewIdx, iRightSortedViewIdx, iDummy;
    1411   Bool   bExist  = xGetLeftRightView( m_aiSynthViews[ iSynthViewIdx ], m_aiSortedBaseViews, iDummy, iDummy, iLeftSortedViewIdx, iRightSortedViewIdx );
    1412   rbIsBaseView   = ( iLeftSortedViewIdx == iRightSortedViewIdx && iLeftSortedViewIdx != -1 );
    1413 
    1414   Int iLeftViewIdx  = ( iLeftSortedViewIdx  != -1 ? m_aiBaseSortedId2Id[ iLeftSortedViewIdx  ] : -1 );
    1415   Int iRightViewIdx = ( iRightSortedViewIdx != -1 ? m_aiBaseSortedId2Id[ iRightSortedViewIdx ] : -1 );
    1416 
    1417   if ( iLeftSortedViewIdx != -1 && iRightSortedViewIdx != -1 )
    1418   {
    1419     riRelDistToLeft = getRelDistLeft(  iSynthViewIdx, iLeftViewIdx, iRightViewIdx);
    1420   }
    1421   else
    1422   {
    1423     riRelDistToLeft = -1;
    1424   }
    1425 
    1426   riLeftViewIdx  = iLeftViewIdx;
    1427   riRightViewIdx = iRightViewIdx;
    1428 
    1429   return bExist;
    1430 }
    1431 
    1432 Bool
    1433   TAppComCamPara::xIsIn( std::vector<Int>& rVec, Int iElem)
    1434 {
    1435   Bool bFound = false;
    1436   for (Int idx = 0; idx < rVec.size() && !bFound; idx++)
    1437   {
    1438     bFound = bFound || rVec[idx] == iElem;
    1439   }
    1440   return bFound;
    1441 }
    1442 
    1443 Int TAppComCamPara::getRelDistLeft( Int iSynthViewIdx, Int iLeftViewIdx, Int iRightViewIdx )
    1444 {
    1445   //GT: Get normalized distance
    1446   Int iLeftViewDist  = abs ( m_aiBaseId2SortedId[ iLeftViewIdx  ] * ((Int) m_dViewNumPrec) - m_aiRelSynthViewsNum [ iSynthViewIdx ]);
    1447   Int iRightViewDist = abs ( m_aiBaseId2SortedId[ iRightViewIdx ] * ((Int) m_dViewNumPrec) - m_aiRelSynthViewsNum [ iSynthViewIdx ]);
    1448   Int64 iDistSum = iLeftViewDist + iRightViewDist;
    1449   return (iDistSum == 0) ? (1 << (REN_VDWEIGHT_PREC -1) ) : (Int) (( (((Int64) iLeftViewDist ) << REN_VDWEIGHT_PREC ) + (iDistSum >> 1) )  / iDistSum );
    1450 }
    1451 
    1452 Int
    1453 TAppComCamPara::synthRelNum2Idx( Int iRelNum )
    1454 {
    1455   return xGetViewId(m_aiRelSynthViewsNum, iRelNum );
    1456 }
    1457 #endif
  • branches/HTM-16.0-MV-draft-5/source/Lib/TAppCommon/TAppComCamPara.h

    r1386 r1390  
    6767  Bool                m_bCamParsCodedPrecSet;                 ///< Coded Cam Para precision set for current frame;
    6868 
    69 #if NH_3D_REN_MAX_DEV_OUT
    70   Double              m_dMaxShiftDeviation;                   ///< Maximum deviation of shifts with integer precision compare to double precision
    71 #endif
    7269  //SAIT_VSO_EST_A0033
    7370  Double              m_dDispCoeff;
     
    124121  Bool  xGetLeftRightView         ( Int iView, std::vector<Int> aiSortedViews, Int& riLeftView, Int& riRightView, Int& riLeftSortedViewIdx, Int& riRightSortedViewIdx );
    125122  Void  xGetPrevAndNextBaseView   ( Int iSourceViewNum, Int iTargetViewNum, Int& riPrevBaseViewNum, Int& riNextBaseViewNum );
    126 #if !KWU_RC_MADPRED_E0227
    127123  Void  xGetZNearZFar             ( Int iView, UInt uiFrame, Double& rdZNear, Double& rdZFar );
    128124  Void  xGetGeometryData          ( Int dView, UInt uiFrame, Double& rdFocalLength, Double& rdPosition, Double& rdCameraShift, Bool& rbInterpolated );
    129 #endif
    130125  Void  xSetupBaseViewsFromCoded  ();
    131126  Void  xSetupBaseViews           ( TChar* pchBaseViewNumbers, UInt uiNumBaseViews );
     
    184179  UInt                getCurFrameId             ()  { return m_iCurrentFrameId;   }
    185180  static Void         convertNumberString       ( TChar* pchViewNumberString, std::vector<Int>& raiViewNumbers, Double dViewNumPrec );
    186 #if NH_3D_REN_MAX_DEV_OUT
    187   Double              getMaxShiftDeviation      () { return m_dMaxShiftDeviation; };
    188 #endif
    189 
    190 #if NH_3D_VSO
    191   // SAIT_VSO_EST_A033
    192   Void                setDispCoeff              ( UInt uiStartFrameId, Int iViewIdx );
    193   Double              getDispCoeff              () { return m_dDispCoeff; }
    194 #endif
     181
    195182
    196183  // function for getting parameters and parameter arrays
     
    217204  Int**               getCodedOffset            ()  { return m_aaiCodedOffset;          }
    218205
    219 #if KWU_RC_MADPRED_E0227
    220   Void  xGetZNearZFar             ( Int iView, UInt uiFrame, Double& rdZNear, Double& rdZFar );
    221   Void  xGetGeometryData          ( Int dView, UInt uiFrame, Double& rdFocalLength, Double& rdPosition, Double& rdCameraShift, Bool& rbInterpolated );
    222 #endif
    223206};
    224207
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/CommonDef.h

    r1387 r1390  
    7171// ====================================================================================================================
    7272#if NH_MV
    73 #define NV_VERSION        "16.0"                ///< Current software version
    74 #define HM_VERSION        "16.7"                ///<
     73#define NV_VERSION        "15.2"                ///< Current software version
     74#define HM_VERSION        "16.6"                ///<
    7575#else
    7676#define NV_VERSION        "16.7"                 ///< Current software version
     
    368368#endif
    369369
    370 #if NH_3D_MLC  || NH_3D_ARP
    371 #define MRG_MAX_NUM_CANDS_MEM       (MRG_MAX_NUM_CANDS+1) // one extra for inter-view motion prediction
    372 #endif
    373370
    374371#if NH_MV
     
    442439#endif
    443440
    444 #if NH_3D_VSO
    445 //PICYUV
    446 #define PICYUV_PAD         16
    447 
    448 //RENDERER
    449 
    450 
    451 #define REN_BIT_DEPTH     8
    452 #define REN_LUMA_MARGIN   ( PICYUV_PAD + 1 ) // + g_uiMaxCuWidth instead of 1 ???
    453 #define REN_VDWEIGHT_PREC  8
    454 #define REN_IS_FILLED     ( 1 << REN_VDWEIGHT_PREC )
    455 #define REN_USED_PEL       ( (1 << REN_BIT_DEPTH) - 1 )
    456 #define REN_UNUSED_PEL     0
    457 #define REN_IS_HOLE        0
    458 #if NH_3D_VSO
    459 #define ENC_INTERNAL_BIT_DEPTH  REN_BIT_DEPTH // consider making this a variable
    460 #endif
    461 
    462 
    463 // CAMERA PARAMETERS
    464 #define LOG2_DISP_PREC_LUT           2           ///< log2 of disparity precision used in integer disparity LUTs
    465 #define STD_CAM_PARAMETERS_PRECISION 5        ///< quarter luma sample accuarcy for derived disparities (as default)
    466 
    467 #endif // end of NH_3D
    468441//! \}
    469442
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/ContextTables.h

    r1313 r1390  
    5151#define NUM_SPLIT_FLAG_CTX            3       ///< number of context models for split flag
    5252#define NUM_SKIP_FLAG_CTX             3       ///< number of context models for skip flag
    53 #if NH_3D_DIS
    54 #define NUM_DIS_FLAG_CTX              1
    55 #define NUM_DIS_TYPE_CTX              1       
    56 #endif
    5753#define NUM_MERGE_FLAG_EXT_CTX        1       ///< number of context models for merge flag of merge extended
    5854#define NUM_MERGE_IDX_EXT_CTX         1       ///< number of context models for merge index of merge extended
     
    162158#define NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX  1
    163159
    164 #if NH_3D_ARP
    165 #define NUM_ARPW_CTX                  3       ///< number of context models for weighting factor index used by advanced residual prediction
    166 #endif
    167 
    168 #if NH_3D_IC
    169 #define NUM_IC_FLAG_CTX               1       ///< number of context models for illumination compensation flag
    170 #endif
     160
    171161#define NUM_CROSS_COMPONENT_PREDICTION_CTX 10
    172162
    173163#define CNU                          154      ///< dummy initialization value for unused context models 'Context model Not Used'
    174164
    175 #if NH_3D_DMM
    176 #define NUM_NOTDMM_FLAG_CTX           1       ///< number of context models for not-DMM flag
    177 #define NUM_DMM_MODE_CTX              1       ///< number of context models for DMM modes
    178 #endif
    179 #if NH_3D_DMM || NH_3D_SDC_INTRA
    180 #define NUM_DDC_DATA_CTX              1       ///< number of context models for deltaDC data (DMM or SDC)
    181 #endif
    182 #if NH_3D_SDC_INTRA
    183 #define SDC_NUM_RESIDUAL_FLAG_CTX     1
    184 #define SDC_NUM_RESIDUAL_CTX          1
    185 #define NUM_SDC_FLAG_CTX              1      ///< number of context
    186 #define NUM_DDC_FLAG_CTX              2       ///< number of context models for deltaDC flag (SDC only)
    187 #endif
    188 #if NH_3D_DBBP
    189 #define DBBP_NUM_FLAG_CTX                 1
    190 #endif
    191165// ====================================================================================================================
    192166// Tables
     
    218192  { CNU,  CNU,  CNU, },
    219193};
    220 #if NH_3D_DIS
    221 static const UChar
    222 INIT_DIS_FLAG[3][NUM_DIS_FLAG_CTX] = 
    223 {
    224     { 185 },
    225     { 185 },
    226     { 185 },
    227 };
    228 static const UChar
    229 INIT_DIS_TYPE[3][NUM_DIS_TYPE_CTX] =
    230 {
    231     { 137 },
    232     { 137 },
    233     { 137 },
    234 };
    235 #endif
    236194static const UChar
    237195INIT_MERGE_FLAG_EXT[NUMBER_OF_SLICE_TYPES][NUM_MERGE_FLAG_EXT_CTX] =
     
    540498//! \}
    541499
    542 #if NH_3D_ARP
    543 static const UChar
    544 INIT_ARPW[3][NUM_ARPW_CTX] =
    545 {
    546     { 162, 153, 162 },
    547     { 162, 153, 162 },
    548     { 162, 153, 162 },
    549 };
     500
    550501
    551502#endif
    552 #if NH_3D_IC
    553 static const UChar
    554 INIT_IC_FLAG[3][NUM_IC_FLAG_CTX] = 
    555 {
    556     { 154 },
    557     { 154 },
    558     { 154 },
    559 };
    560 
    561 #endif
    562 
    563 #if NH_3D_DMM
    564 static const UChar
    565 INIT_NOTDMM_FLAG[3][NUM_NOTDMM_FLAG_CTX] =
    566 {
    567   { 154 },
    568   { 141 },
    569   { 155 },
    570 };
    571 static const UChar
    572 INIT_DMM_MODE[3][NUM_DMM_MODE_CTX] =
    573 {
    574   { CNU },
    575   { CNU },
    576   { CNU }
    577 };
    578 #endif
    579 #if NH_3D_DMM || NH_3D_SDC_INTRA
    580 static const UChar
    581 INIT_DDC_DATA[3][NUM_DDC_DATA_CTX] =
    582 {
    583   { CNU },
    584   { CNU },
    585   { CNU },
    586 };
    587 #endif
    588 #if NH_3D_SDC_INTRA
    589 static const UChar
    590 INIT_SDC_RESIDUAL_FLAG[3][SDC_NUM_RESIDUAL_FLAG_CTX] =
    591 {
    592   { CNU },
    593   { CNU },
    594   { CNU },
    595 };
    596 static const UChar
    597 INIT_SDC_RESIDUAL[3][SDC_NUM_RESIDUAL_CTX] =
    598 {
    599   { 155 },
    600   { 155 },
    601   { 155 },
    602 };
    603 static const UChar
    604 INIT_SDC_FLAG[3][NUM_SDC_FLAG_CTX] =
    605 {
    606   { 154 }, 
    607   { 154 },
    608   { 154 },
    609 };
    610 static const UChar
    611 INIT_DDC_FLAG[3][NUM_DDC_FLAG_CTX] =
    612 {
    613   {0 , CNU},
    614   {0 , CNU},
    615   {64, CNU}
    616 };
    617 #endif
    618 #if NH_3D_DBBP
    619 static const UChar INIT_DBBP_FLAG[3][DBBP_NUM_FLAG_CTX] =
    620 {
    621   { CNU },
    622   { CNU },
    623   { CNU },
    624 };
    625 #endif
    626 
    627 #endif
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/SEI.cpp

    r1386 r1390  
    170170    case SEI::MULTIVIEW_ACQUISITION_INFO:                return "Multiview acquisition information";
    171171    case SEI::MULTIVIEW_VIEW_POSITION:                   return "Multiview view position";
    172 #if NH_3D
    173     case SEI::ALTERNATIVE_DEPTH_INFO:                    return "Alternative depth information";
    174 #endif
    175172#endif
    176173    default:                                        return "Unknown";
     
    242239  case SEI::MULTIVIEW_ACQUISITION_INFO            :               return new SEIMultiviewAcquisitionInfo;
    243240  case SEI::MULTIVIEW_VIEW_POSITION               :               return new SEIMultiviewViewPosition;
    244 #if NH_3D
    245   case SEI::ALTERNATIVE_DEPTH_INFO                :               return new SEIAlternativeDepthInfo;
    246 #endif
    247241  default:                                        assert( false ); return NULL;
    248242  }
     
    14471441
    14481442
    1449 #if NH_3D
    1450 Void SEIAlternativeDepthInfo::setupFromCfgFile(const TChar* cfgFile)
    1451 {
    1452   // Set default values
    1453   IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
    1454 
    1455   defAppLayerIds    .clear();
    1456   defAppPocs        .clear();
    1457   defAppTids        .clear();
    1458   defAppVclNaluTypes.clear();
    1459 
    1460   Int      defSeiNaluId                  = 0;
    1461   Int      defPositionInSeiNalu          = 0;
    1462   Bool     defModifyByEncoder            = false;
    1463 
    1464   // Setup config file options
    1465   po::Options opts;
    1466   xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
    1467 
    1468   opts.addOptions()
    1469     ("AlternativeDepthInfoCancelFlag" , m_alternativeDepthInfoCancelFlag  , false               , "AlternativeDepthInfoCancelFlag"  )
    1470     ("DepthType"                      , m_depthType                       , 1                   , "DepthType"                       )
    1471     ("NumConstituentViewsGvdMinus1"   , m_numConstituentViewsGvdMinus1    , 1                   , "NumConstituentViewsGvdMinus1"    )
    1472     ("DepthPresentGvdFlag"            , m_depthPresentGvdFlag             , false               , "DepthPresentGvdFlag"             )
    1473     ("ZGvdFlag"                       , m_zGvdFlag                        , false               , "ZGvdFlag"                        )
    1474     ("IntrinsicParamGvdFlag"          , m_intrinsicParamGvdFlag           , false               , "IntrinsicParamGvdFlag"           )
    1475     ("RotationGvdFlag"                , m_rotationGvdFlag                 , false               , "RotationGvdFlag"                 )
    1476     ("TranslationGvdFlag"             , m_translationGvdFlag              , false               , "TranslationGvdFlag"              )
    1477     ("SignGvdZNearFlag_%d"            , m_signGvdZNearFlag                , BoolAry1d(3,0), 3   , "SignGvdZNearFlag"                )
    1478     ("ExpGvdZNear_%d"                 , m_expGvdZNear                     , IntAry1d (3,0), 3   , "ExpGvdZNear"                     )
    1479     ("ManLenGvdZNearMinus1_%d"        , m_manLenGvdZNearMinus1            , IntAry1d (3,0), 3   , "ManLenGvdZNearMinus1"            )
    1480     ("ManGvdZNear_%d"                 , m_manGvdZNear                     , IntAry1d (3,0), 3   , "ManGvdZNear"                     )
    1481     ("SignGvdZFarFlag_%d"             , m_signGvdZFarFlag                 , BoolAry1d(3,0), 3   , "SignGvdZFarFlag"                 )
    1482     ("ExpGvdZFar_%d"                  , m_expGvdZFar                      , IntAry1d (3,0), 3   , "ExpGvdZFar"                      )
    1483     ("ManLenGvdZFarMinus1_%d"         , m_manLenGvdZFarMinus1             , IntAry1d (3,0), 3   , "ManLenGvdZFarMinus1"             )
    1484     ("ManGvdZFar_%d"                  , m_manGvdZFar                      , IntAry1d (3,0), 3   , "ManGvdZFar"                      )
    1485     ("PrecGvdFocalLength"             , m_precGvdFocalLength              , 18                  , "PrecGvdFocalLength"              )
    1486     ("PrecGvdPrincipalPoint"          , m_precGvdPrincipalPoint           , 18                  , "PrecGvdPrincipalPoint"           )
    1487     ("PrecGvdRotationParam"           , m_precGvdRotationParam            , 18                  , "PrecGvdRotationParam"            )
    1488     ("PrecGvdTranslationParam"        , m_precGvdTranslationParam         , 18                  , "PrecGvdTranslationParam"         )
    1489     ("SignGvdFocalLengthX_%d"         , m_signGvdFocalLengthX             , BoolAry1d(3,0), 3   ,"SignGvdFocalLengthX"              )
    1490     ("ExpGvdFocalLengthX_%d"          , m_expGvdFocalLengthX              , IntAry1d (3,0), 3   ,"ExpGvdFocalLengthX"               )
    1491     ("ManGvdFocalLengthX_%d"          , m_manGvdFocalLengthX              , IntAry1d (3,0), 3   ,"ManGvdFocalLengthX"               )
    1492     ("SignGvdFocalLengthY_%d"         , m_signGvdFocalLengthY             , BoolAry1d(3,0), 3   ,"SignGvdFocalLengthY"              )
    1493     ("ExpGvdFocalLengthY_%d"          , m_expGvdFocalLengthY              , IntAry1d (3,0), 3   ,"ExpGvdFocalLengthY"               )
    1494     ("ManGvdFocalLengthY_%d"          , m_manGvdFocalLengthY              , IntAry1d (3,0), 3   ,"ManGvdFocalLengthY"               )
    1495     ("SignGvdPrincipalPointX_%d"      , m_signGvdPrincipalPointX          , BoolAry1d(3,0), 3   ,"SignGvdPrincipalPointX"           )
    1496     ("ExpGvdPrincipalPointX_%d"       , m_expGvdPrincipalPointX           , IntAry1d (3,0), 3   ,"ExpGvdPrincipalPointX"            )
    1497     ("ManGvdPrincipalPointX_%d"       , m_manGvdPrincipalPointX           , IntAry1d (3,0), 3   ,"ManGvdPrincipalPointX"            )
    1498     ("SignGvdPrincipalPointY_%d"      , m_signGvdPrincipalPointY          , BoolAry1d(3,0), 3   ,"SignGvdPrincipalPointY"           )
    1499     ("ExpGvdPrincipalPointY_%d"       , m_expGvdPrincipalPointY           , IntAry1d (3,0), 3   ,"ExpGvdPrincipalPointY"            )
    1500     ("ManGvdPrincipalPointY_%d"       , m_manGvdPrincipalPointY           , IntAry1d (3,0), 3   ,"ManGvdPrincipalPointY"            )
    1501     ("SignGvdR00_%d"                  , m_signGvdR00                      , BoolAry1d(3,0), 3   ,"SignGvdR00"                       )
    1502     ("ExpGvdR00_%d"                   , m_expGvdR00                       , IntAry1d (3,0), 3   ,"ExpGvdR00"                        )
    1503     ("ManGvdR00_%d"                   , m_manGvdR00                       , IntAry1d (3,0), 3   ,"ManGvdR00"                        )
    1504     ("SignGvdR01_%d"                  , m_signGvdR01                      , BoolAry1d(3,0), 3   ,"SignGvdR01"                       )
    1505     ("ExpGvdR01_%d"                   , m_expGvdR01                       , IntAry1d (3,0), 3   ,"ExpGvdR01"                        )
    1506     ("ManGvdR01_%d"                   , m_manGvdR01                       , IntAry1d (3,0), 3   ,"ManGvdR01"                        )
    1507     ("SignGvdR02_%d"                  , m_signGvdR02                      , BoolAry1d(3,0), 3   ,"SignGvdR02"                       )
    1508     ("ExpGvdR02_%d"                   , m_expGvdR02                       , IntAry1d (3,0), 3   ,"ExpGvdR02"                        )
    1509     ("ManGvdR02_%d"                   , m_manGvdR02                       , IntAry1d (3,0), 3   ,"ManGvdR02"                        )
    1510     ("SignGvdR10_%d"                  , m_signGvdR10                      , BoolAry1d(3,0), 3   ,"SignGvdR10"                       )
    1511     ("ExpGvdR10_%d"                   , m_expGvdR10                       , IntAry1d (3,0), 3   ,"ExpGvdR10"                        )
    1512     ("ManGvdR10_%d"                   , m_manGvdR10                       , IntAry1d (3,0), 3   ,"ManGvdR10"                        )
    1513     ("SignGvdR11_%d"                  , m_signGvdR11                      , BoolAry1d(3,0), 3   ,"SignGvdR11"                       )
    1514     ("ExpGvdR11_%d"                   , m_expGvdR11                       , IntAry1d (3,0), 3   ,"ExpGvdR11"                        )
    1515     ("ManGvdR11_%d"                   , m_manGvdR11                       , IntAry1d (3,0), 3   ,"ManGvdR11"                        )
    1516     ("SignGvdR12_%d"                  , m_signGvdR12                      , BoolAry1d(3,0), 3   ,"SignGvdR12"                       )
    1517     ("ExpGvdR12_%d"                   , m_expGvdR12                       , IntAry1d (3,0), 3   ,"ExpGvdR12"                        )
    1518     ("ManGvdR12_%d"                   , m_manGvdR12                       , IntAry1d (3,0), 3   ,"ManGvdR12"                        )
    1519     ("SignGvdR20_%d"                  , m_signGvdR20                      , BoolAry1d(3,0), 3   ,"SignGvdR20"                       )
    1520     ("ExpGvdR20_%d"                   , m_expGvdR20                       , IntAry1d (3,0), 3   ,"ExpGvdR20"                        )
    1521     ("ManGvdR20_%d"                   , m_manGvdR20                       , IntAry1d (3,0), 3   ,"ManGvdR20"                        )
    1522     ("SignGvdR21_%d"                  , m_signGvdR21                      , BoolAry1d(3,0), 3   ,"SignGvdR21"                       )
    1523     ("ExpGvdR21_%d"                   , m_expGvdR21                       , IntAry1d (3,0), 3   ,"ExpGvdR21"                        )
    1524     ("ManGvdR21_%d"                   , m_manGvdR21                       , IntAry1d (3,0), 3   ,"ManGvdR21"                        )
    1525     ("SignGvdR22_%d"                  , m_signGvdR22                      , BoolAry1d(3,0), 3   ,"SignGvdR22"                       )
    1526     ("ExpGvdR22_%d"                   , m_expGvdR22                       , IntAry1d (3,0), 3   ,"ExpGvdR22"                        )
    1527     ("ManGvdR22_%d"                   , m_manGvdR22                       , IntAry1d (3,0), 3   ,"ManGvdR22"                        )
    1528     ("SignGvdTX_%d"                   , m_signGvdTX                       , BoolAry1d(3,0), 3   ,"SignGvdTX"                        )
    1529     ("ExpGvdTX_%d"                    , m_expGvdTX                        , IntAry1d (3,0), 3   ,"ExpGvdTX"                         )
    1530     ("ManGvdTX_%d"                    , m_manGvdTX                        , IntAry1d (3,0), 3   ,"ManGvdTX"                         )
    1531     ("MinOffsetXInt"                  , m_minOffsetXInt                   , 0                   , "MinOffsetXInt"                   )
    1532     ("MinOffsetXFrac"                 , m_minOffsetXFrac                  , 0                   , "MinOffsetXFrac"                  )
    1533     ("MaxOffsetXInt"                  , m_maxOffsetXInt                   , 0                   , "MaxOffsetXInt"                   )
    1534     ("MaxOffsetXFrac"                 , m_maxOffsetXFrac                  , 0                   , "MaxOffsetXFrac"                  )
    1535     ("OffsetYPresentFlag"             , m_offsetYPresentFlag              , false               , "OffsetYPresentFlag"              )
    1536     ("MinOffsetYInt"                  , m_minOffsetYInt                   , 0                   , "MinOffsetYInt"                   )
    1537     ("MinOffsetYFrac"                 , m_minOffsetYFrac                  , 0                   , "MinOffsetYFrac"                  )
    1538     ("MaxOffsetYInt"                  , m_maxOffsetYInt                   , 0                   , "MaxOffsetYInt"                   )
    1539     ("MaxOffsetYFrac"                 , m_maxOffsetYFrac                  , 0                   , "MaxOffsetYFrac"                  )
    1540     ("WarpMapSizePresentFlag"         , m_warpMapSizePresentFlag          , false               , "WarpMapSizePresentFlag"          )
    1541     ("WarpMapWidthMinus2"             , m_warpMapWidthMinus2              , 0                   , "WarpMapWidthMinus2"              )
    1542     ("WarpMapHeightMinus2"            , m_warpMapHeightMinus2             , 0                   , "WarpMapHeightMinus2"             )
    1543     ;
    1544 
    1545   po::setDefaults(opts);
    1546 
    1547   // Parse the cfg file
    1548   po::ErrorReporter err;
    1549   po::parseConfigFile( opts, cfgFile, err );
    1550 };
    1551 Bool SEIAlternativeDepthInfo::checkCfg( const TComSlice* slice )
    1552 {
    1553   // Check config values
    1554   Bool wrongConfig = false;
    1555 
    1556 
    1557   xCheckCfgRange( wrongConfig, m_alternativeDepthInfoCancelFlag , 0 , 1, "alternative_depth_info_cancel_flag");
    1558   xCheckCfgRange( wrongConfig, m_depthType                      , 0 , 1, "depth_type"                       );
    1559 
    1560   xCheckCfgRange( wrongConfig, m_numConstituentViewsGvdMinus1   , 1 , 1, "num_constituent_views_gvd_minus1 "); // 1: 3 views only, cuurent.
    1561   xCheckCfgRange( wrongConfig, m_depthPresentGvdFlag            , 0 , 1, "depth_present_gvd_flag"           );
    1562   xCheckCfgRange( wrongConfig, m_zGvdFlag                       , 0 , 1, "z_gvd_flag"                       );
    1563   xCheckCfgRange( wrongConfig, m_intrinsicParamGvdFlag          , 0 , 1, "intrinsic_param_gvd_flag"         );
    1564   xCheckCfgRange( wrongConfig, m_rotationGvdFlag                , 0 , 1, "rotation_gvd_flag"                );
    1565   xCheckCfgRange( wrongConfig, m_translationGvdFlag             , 0 , 1, "translation_gvd_flag"             );
    1566 
    1567   return wrongConfig;
    1568 
    1569 };
    1570 
    1571 UInt SEIAlternativeDepthInfo::getManGvdFocalLengthXLen       ( Int i, int j ) const
    1572 {
    1573   UInt rval;
    1574   rval = xGetSyntaxElementLen( m_expGvdFocalLengthX[i][j], m_precGvdFocalLength, m_manGvdFocalLengthX[i][j]  );
    1575   if (rval == 0)
    1576     return m_precGvdFocalLength;
    1577   else
    1578     return rval;
    1579 };
    1580 
    1581 UInt SEIAlternativeDepthInfo::getManGvdFocalLengthYLen       ( Int i, int j ) const
    1582 {
    1583   UInt rval;
    1584   rval = xGetSyntaxElementLen( m_expGvdFocalLengthY[i][j], m_precGvdFocalLength, m_manGvdFocalLengthY[i][j]  );
    1585   if (rval == 0)
    1586     return m_precGvdFocalLength;
    1587   else
    1588     return rval;
    1589 };
    1590 
    1591 UInt SEIAlternativeDepthInfo::getManGvdPrincipalPointXLen    ( Int i, int j ) const
    1592 {
    1593   UInt rval;
    1594   rval = xGetSyntaxElementLen( m_expGvdPrincipalPointX[i][j], m_precGvdPrincipalPoint, m_manGvdPrincipalPointX[i][j]  );
    1595   if (rval == 0)
    1596     return m_precGvdPrincipalPoint;
    1597   else
    1598     return rval;
    1599 };
    1600 
    1601 UInt SEIAlternativeDepthInfo::getManGvdPrincipalPointYLen    ( Int i, int j ) const
    1602 {
    1603   UInt rval;
    1604   rval = xGetSyntaxElementLen( m_expGvdPrincipalPointY[i][j], m_precGvdPrincipalPoint, m_manGvdPrincipalPointY[i][j]  );
    1605   if (rval == 0)
    1606     return m_precGvdPrincipalPoint;
    1607   else
    1608     return rval;
    1609 };
    1610 
    1611 UInt SEIAlternativeDepthInfo::getManGvdTXLen                 ( Int i, int j ) const
    1612 {
    1613   UInt rval;
    1614   rval = xGetSyntaxElementLen( m_expGvdTX[i][j], m_precGvdTranslationParam, m_manGvdTX[i][j]  );
    1615   if (rval == 0)
    1616     return m_precGvdTranslationParam;
    1617   else
    1618     return rval;
    1619 };
    1620 
    1621 UInt SEIAlternativeDepthInfo::xGetSyntaxElementLen( Int expo, Int prec, Int val ) const
    1622 {
    1623   UInt len;
    1624   if( expo == 0 )
    1625   {
    1626     len = std::max(0, prec - 30 );
    1627   }
    1628   else
    1629   {
    1630     len = std::max( 0, expo + prec - 31 );
    1631   }
    1632 
    1633   assert( val >= 0 );
    1634   assert( val <= ( ( 1 << len )- 1) );
    1635   return len;
    1636 }
    16371443
    16381444#endif
    1639 
    1640 #endif
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/SEI.h

    r1386 r1390  
    112112    MULTIVIEW_ACQUISITION_INFO                = 179,
    113113    MULTIVIEW_VIEW_POSITION                   = 180
    114 #if NH_3D
    115     ,ALTERNATIVE_DEPTH_INFO                    = 181
    116 #endif
    117114
    118115  };
     
    11321129};
    11331130
    1134 #if NH_3D
    1135 class SEIAlternativeDepthInfo : public SEI
    1136 {
    1137 public:
    1138   PayloadType payloadType( ) const { return ALTERNATIVE_DEPTH_INFO; }
    1139   SEIAlternativeDepthInfo ( ) { };
    1140   ~SEIAlternativeDepthInfo( ) { };
    1141   SEI* getCopy( ) const { return new SEIAlternativeDepthInfo(*this); };
    1142 
    1143   Void setupFromCfgFile( const TChar*     cfgFile );
    1144   Bool checkCfg        ( const TComSlice* slice   );
    1145 
    1146   UInt getManGvdFocalLengthXLen       ( Int i, Int j ) const;
    1147   UInt getManGvdFocalLengthYLen       ( Int i, Int j ) const;
    1148   UInt getManGvdPrincipalPointXLen    ( Int i, Int j ) const;
    1149   UInt getManGvdPrincipalPointYLen    ( Int i, Int j ) const;
    1150   //UInt getManGvdRLen                  ( Int i, int j ) const;
    1151   UInt getManGvdTXLen                 ( Int i, Int j ) const;
    1152   UInt xGetSyntaxElementLen           ( Int expo, Int prec, Int val ) const;
    1153 
    1154   Void resizeArrays( )
    1155   {
    1156     const Int numViews = 3; // getNumConstituentViewsGvdMinus1() + 1;
    1157 
    1158     m_signGvdZNearFlag.resize(3);
    1159     m_expGvdZNear.resize(3);
    1160     m_manLenGvdZNearMinus1.resize(3);
    1161     m_manGvdZNear.resize(3);
    1162     m_signGvdZFarFlag.resize(3);
    1163     m_expGvdZFar.resize(3);
    1164     m_manLenGvdZFarMinus1.resize(3);
    1165     m_manGvdZFar.resize(3);
    1166 
    1167     m_signGvdFocalLengthX.resize(3);
    1168     m_expGvdFocalLengthX.resize(3);
    1169     m_manGvdFocalLengthX.resize(3);
    1170     m_signGvdFocalLengthY.resize(3);
    1171     m_expGvdFocalLengthY.resize(3);
    1172     m_manGvdFocalLengthY.resize(3);
    1173     m_signGvdPrincipalPointX.resize(3);
    1174     m_expGvdPrincipalPointX.resize(3);
    1175     m_manGvdPrincipalPointX.resize(3);
    1176     m_signGvdPrincipalPointY.resize(3);
    1177     m_expGvdPrincipalPointY.resize(3);
    1178     m_manGvdPrincipalPointY.resize(3);
    1179 
    1180     m_signGvdR00.resize(3);
    1181     m_expGvdR00.resize(3);
    1182     m_manGvdR00.resize(3);
    1183     m_signGvdR01.resize(3);
    1184     m_expGvdR01.resize(3);
    1185     m_manGvdR01.resize(3);
    1186     m_signGvdR02.resize(3);
    1187     m_expGvdR02.resize(3);
    1188     m_manGvdR02.resize(3);
    1189     m_signGvdR10.resize(3);
    1190     m_expGvdR10.resize(3);
    1191     m_manGvdR10.resize(3);
    1192     m_signGvdR11.resize(3);
    1193     m_expGvdR11.resize(3);
    1194     m_manGvdR11.resize(3);
    1195     m_signGvdR12.resize(3);
    1196     m_expGvdR12.resize(3);
    1197     m_manGvdR12.resize(3);
    1198     m_signGvdR20.resize(3);
    1199     m_expGvdR20.resize(3);
    1200     m_manGvdR20.resize(3);
    1201     m_signGvdR21.resize(3);
    1202     m_expGvdR21.resize(3);
    1203     m_manGvdR21.resize(3);
    1204     m_signGvdR22.resize(3);
    1205     m_expGvdR22.resize(3);
    1206     m_manGvdR22.resize(3);
    1207 
    1208     m_signGvdTX.resize(3);
    1209     m_expGvdTX.resize(3);
    1210     m_manGvdTX.resize(3);
    1211 
    1212     for( Int i = 0; i < numViews; i++ )
    1213     {
    1214       m_signGvdZNearFlag[i].resize(3);
    1215       m_expGvdZNear[i].resize(3);
    1216       m_manLenGvdZNearMinus1[i].resize(3);
    1217       m_manGvdZNear[i].resize(3);
    1218       m_signGvdZFarFlag[i].resize(3);
    1219       m_expGvdZFar[i].resize(3);
    1220       m_manLenGvdZFarMinus1[i].resize(3);
    1221       m_manGvdZFar[i].resize(3);
    1222 
    1223       m_signGvdFocalLengthX[i].resize(3);
    1224       m_expGvdFocalLengthX[i].resize(3);
    1225       m_manGvdFocalLengthX[i].resize(3);
    1226       m_signGvdFocalLengthY[i].resize(3);
    1227       m_expGvdFocalLengthY[i].resize(3);
    1228       m_manGvdFocalLengthY[i].resize(3);
    1229       m_signGvdPrincipalPointX[i].resize(3);
    1230       m_expGvdPrincipalPointX[i].resize(3);
    1231       m_manGvdPrincipalPointX[i].resize(3);
    1232       m_signGvdPrincipalPointY[i].resize(3);
    1233       m_expGvdPrincipalPointY[i].resize(3);
    1234       m_manGvdPrincipalPointY[i].resize(3);
    1235 
    1236       m_signGvdR00[i].resize(3);
    1237       m_expGvdR00[i].resize(3);
    1238       m_manGvdR00[i].resize(3);
    1239       m_signGvdR01[i].resize(3);
    1240       m_expGvdR01[i].resize(3);
    1241       m_manGvdR01[i].resize(3);
    1242       m_signGvdR02[i].resize(3);
    1243       m_expGvdR02[i].resize(3);
    1244       m_manGvdR02[i].resize(3);
    1245       m_signGvdR10[i].resize(3);
    1246       m_expGvdR10[i].resize(3);
    1247       m_manGvdR10[i].resize(3);
    1248       m_signGvdR11[i].resize(3);
    1249       m_expGvdR11[i].resize(3);
    1250       m_manGvdR11[i].resize(3);
    1251       m_signGvdR12[i].resize(3);
    1252       m_expGvdR12[i].resize(3);
    1253       m_manGvdR12[i].resize(3);
    1254       m_signGvdR20[i].resize(3);
    1255       m_expGvdR20[i].resize(3);
    1256       m_manGvdR20[i].resize(3);
    1257       m_signGvdR21[i].resize(3);
    1258       m_expGvdR21[i].resize(3);
    1259       m_manGvdR21[i].resize(3);
    1260       m_signGvdR22[i].resize(3);
    1261       m_expGvdR22[i].resize(3);
    1262       m_manGvdR22[i].resize(3);
    1263 
    1264       m_signGvdTX[i].resize(3);
    1265       m_expGvdTX[i].resize(3);
    1266       m_manGvdTX[i].resize(3);
    1267     }
    1268 
    1269   }
    1270 
    1271   Bool      m_alternativeDepthInfoCancelFlag;
    1272   Int       m_depthType;
    1273   Int       m_numConstituentViewsGvdMinus1;
    1274   Bool      m_depthPresentGvdFlag;
    1275   Bool      m_zGvdFlag;
    1276   Bool      m_intrinsicParamGvdFlag;
    1277   Bool      m_rotationGvdFlag;
    1278   Bool      m_translationGvdFlag;
    1279   BoolAry2d m_signGvdZNearFlag;
    1280   IntAry2d  m_expGvdZNear;
    1281   IntAry2d  m_manLenGvdZNearMinus1;
    1282   IntAry2d  m_manGvdZNear;
    1283   BoolAry2d m_signGvdZFarFlag;
    1284   IntAry2d  m_expGvdZFar;
    1285   IntAry2d  m_manLenGvdZFarMinus1;
    1286   IntAry2d  m_manGvdZFar;
    1287   Int       m_precGvdFocalLength;
    1288   Int       m_precGvdPrincipalPoint;
    1289   Int       m_precGvdRotationParam;
    1290   Int       m_precGvdTranslationParam;
    1291   BoolAry2d m_signGvdFocalLengthX;
    1292   IntAry2d  m_expGvdFocalLengthX;
    1293   IntAry2d  m_manGvdFocalLengthX;
    1294   BoolAry2d m_signGvdFocalLengthY;
    1295   IntAry2d  m_expGvdFocalLengthY;
    1296   IntAry2d  m_manGvdFocalLengthY;
    1297   BoolAry2d m_signGvdPrincipalPointX;
    1298   IntAry2d  m_expGvdPrincipalPointX;
    1299   IntAry2d  m_manGvdPrincipalPointX;
    1300   BoolAry2d m_signGvdPrincipalPointY;
    1301   IntAry2d  m_expGvdPrincipalPointY;
    1302   IntAry2d  m_manGvdPrincipalPointY;
    1303 
    1304   BoolAry2d m_signGvdR00;
    1305   IntAry2d  m_expGvdR00;
    1306   IntAry2d  m_manGvdR00;
    1307   BoolAry2d m_signGvdR01;
    1308   IntAry2d  m_expGvdR01;
    1309   IntAry2d  m_manGvdR01;
    1310   BoolAry2d m_signGvdR02;
    1311   IntAry2d  m_expGvdR02;
    1312   IntAry2d  m_manGvdR02;
    1313   BoolAry2d m_signGvdR10;
    1314   IntAry2d  m_expGvdR10;
    1315   IntAry2d  m_manGvdR10;
    1316   BoolAry2d m_signGvdR11;
    1317   IntAry2d  m_expGvdR11;
    1318   IntAry2d  m_manGvdR11;
    1319   BoolAry2d m_signGvdR12;
    1320   IntAry2d  m_expGvdR12;
    1321   IntAry2d  m_manGvdR12;
    1322   BoolAry2d m_signGvdR20;
    1323   IntAry2d  m_expGvdR20;
    1324   IntAry2d  m_manGvdR20;
    1325   BoolAry2d m_signGvdR21;
    1326   IntAry2d  m_expGvdR21;
    1327   IntAry2d  m_manGvdR21;
    1328   BoolAry2d m_signGvdR22;
    1329   IntAry2d  m_expGvdR22;
    1330   IntAry2d  m_manGvdR22;
    1331 
    1332   BoolAry2d m_signGvdTX;
    1333   IntAry2d  m_expGvdTX;
    1334   IntAry2d  m_manGvdTX;
    1335 
    1336   Int       m_minOffsetXInt;
    1337   Int       m_minOffsetXFrac;
    1338   Int       m_maxOffsetXInt;
    1339   Int       m_maxOffsetXFrac;
    1340   Bool      m_offsetYPresentFlag;
    1341   Int       m_minOffsetYInt;
    1342   Int       m_minOffsetYFrac;
    1343   Int       m_maxOffsetYInt;
    1344   Int       m_maxOffsetYFrac;
    1345   Bool      m_warpMapSizePresentFlag;
    1346   Int       m_warpMapWidthMinus2;
    1347   Int       m_warpMapHeightMinus2;
    1348 };
    1349 
    13501131#endif
    13511132#endif
    1352 #endif
    13531133
    13541134//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComCodingStatistics.h

    r1386 r1390  
    8181  STATS__CABAC_BITS__ESCAPE_BITS,
    8282
    83 #if NH_3D_DBBP
    84   STATS__CABAC_BITS__DBBP_FLAG,
    85 #endif
    86 #if NH_3D_ARP
    87   STATS__CABAC_BITS__ARP_FLAG,
    88 #endif
    8983  STATS__CABAC_BITS__SAO,
    9084  STATS__CABAC_TRM_BITS,
     
    9993  STATS__CABAC_BITS__ALIGNED_ESCAPE_BITS,
    10094
    101 #if NH_3D_IC
    102   STATS__CABAC_BITS__3D_IC,
    103 #endif
    104 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    105   STATS__CABAC_BITS__DELTADC_SIGN_EP,
    106   STATS__CABAC_BITS__DELTADC_PREFIX,
    107   STATS__CABAC_BITS__DELTADC_SUFFIX_EP,
    108 #endif
    109 #if NH_3D_DMM
    110   STATS__CABAC_BITS__NOTDMM_FLAG,
    111   STATS__CABAC_BITS__DMMMODE,
    112   STATS__CABAC_BITS__DMM1_BITS_EP,
    113 #endif
    114 #if NH_3D_SDC_INTRA
    115   STATS__CABAC_BITS__SDC_INTRA_FLAG,
    116   STATS__CABAC_BITS__SDC_DELTADC_FLAG,
    117 #endif
    11895
    11996  STATS__NUM_STATS
     
    156133    "CABAC_BITS__SIGN_BIT",
    157134    "CABAC_BITS__ESCAPE_BITS",
    158 #if NH_3D_DBBP
    159     "CABAC_BITS__DBBP_FLAG",
    160 #endif
    161135    "CABAC_BITS__SAO",
    162136    "CABAC_TRM_BITS",
     
    171145    "CABAC_BITS__ALIGNED_ESCAPE_BITS"
    172146
    173 #if NH_3D_IC
    174     "CABAC_BITS__3D_IC"
    175 #endif
    176 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    177    ,"STATS__CABAC_BITS__DELTADC_SIGN_EP"
    178    ,"STATS__CABAC_BITS__DELTADC_PREFIX"
    179    ,"STATS__CABAC_BITS__DELTADC_SUFFIX_EP"
    180 #endif
    181 #if NH_3D_DMM
    182    ,"STATS__CABAC_BITS__NOTDMM_FLAG"
    183    ,"STATS__CABAC_BITS__DMMMODE"
    184    ,"STATS__CABAC_BITS__DMM1_BITS_EP"
    185 #endif
    186 #if NH_3D_SDC_INTRA
    187     ,"STATS__CABAC_BITS__SDC_INTRA_FLAG"
    188     ,"STATS__CABAC_BITS__SDC_DELTADC_FLAG"
    189 #endif
    190147  };
    191148  assert(STATS__NUM_STATS == sizeof(statNames)/sizeof(TChar *) && name < STATS__NUM_STATS);
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComDataCU.cpp

    r1386 r1390  
    5555
    5656  m_skipFlag           = NULL;
    57 #if NH_3D_DIS
    58   m_bDISFlag           = NULL;
    59   m_ucDISType          = NULL;
    60 #endif
    6157  m_pePartSize         = NULL;
    6258  m_pePredMode         = NULL;
     
    104100  }
    105101
    106 #if NH_3D_DMM
    107   for( Int i = 0; i < NUM_DMM; i++ )
    108   {
    109     m_dmmDeltaDC[i][0] = NULL;
    110     m_dmmDeltaDC[i][1] = NULL;
    111   }
    112   m_dmm1WedgeTabIdx = NULL;
    113 #endif
    114 #if NH_3D_SDC_INTRA
    115   m_pbSDCFlag             = NULL;
    116   m_apSegmentDCOffset[0]  = NULL;
    117   m_apSegmentDCOffset[1]  = NULL;
    118 #endif
    119102
    120103  m_bDecSubCu          = false;
    121104
    122 #if NH_3D_NBDV
    123   m_pDvInfo              = NULL;
    124 #endif
    125 #if NH_3D_VSP
    126   m_piVSPFlag            = NULL;
    127 #endif
    128 #if NH_3D_SPIVMP
    129   m_pbSPIVMPFlag         = NULL;
    130 #endif
    131 #if NH_3D_ARP
    132   m_puhARPW              = NULL;
    133 #endif
    134 #if NH_3D_IC
    135   m_pbICFlag             = NULL;
    136 #endif
    137 #if NH_3D_DBBP
    138   m_pbDBBPFlag         = NULL;
    139 #endif
    140105
    141106}
     
    167132    m_ChromaQpAdj        = new UChar[ uiNumPartition ];
    168133    m_skipFlag           = new Bool[ uiNumPartition ];
    169 #if NH_3D_DIS
    170     m_bDISFlag           = new Bool[ uiNumPartition ];
    171     m_ucDISType          = (UChar*)xMalloc(UChar, uiNumPartition);
    172 #endif
    173134    m_pePartSize         = new SChar[ uiNumPartition ];
    174135    memset( m_pePartSize, NUMBER_OF_PART_SIZES,uiNumPartition * sizeof( *m_pePartSize ) );
     
    178139    m_pbMergeFlag        = (Bool*  )xMalloc(Bool,   uiNumPartition);
    179140    m_puhMergeIndex      = (UChar* )xMalloc(UChar,  uiNumPartition);
    180 #if NH_3D_VSP
    181     m_piVSPFlag          = (SChar* )xMalloc(SChar, uiNumPartition);
    182 #endif
    183 #if NH_3D_SPIVMP
    184     m_pbSPIVMPFlag       = (Bool*  )xMalloc(Bool,   uiNumPartition);
    185 #endif
    186141
    187142    for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
     
    201156    }
    202157
    203 #if NH_3D_NBDV
    204     m_pDvInfo            = (DisInfo* )xMalloc(DisInfo,  uiNumPartition);
    205 #endif
    206158
    207159
     
    242194    }
    243195
    244 #if NH_3D_ARP
    245     m_puhARPW            = (UChar*  )xMalloc(UChar,   uiNumPartition);
    246 #endif
    247 #if NH_3D_IC
    248     m_pbICFlag           = (Bool* )xMalloc(Bool,   uiNumPartition);
    249 #endif
    250 #if NH_3D_DMM
    251     for( Int i = 0; i < NUM_DMM; i++ )
    252     {
    253       m_dmmDeltaDC[i][0] = (Pel* )xMalloc(Pel, uiNumPartition);
    254       m_dmmDeltaDC[i][1] = (Pel* )xMalloc(Pel, uiNumPartition);
    255     }
    256     m_dmm1WedgeTabIdx    = (UInt*)xMalloc(UInt, uiNumPartition);
    257 #endif
    258 #if NH_3D_SDC_INTRA
    259     m_pbSDCFlag             = (Bool*)xMalloc(Bool, uiNumPartition);
    260     m_apSegmentDCOffset[0]  = (Pel*)xMalloc(Pel, uiNumPartition);
    261     m_apSegmentDCOffset[1]  = (Pel*)xMalloc(Pel, uiNumPartition);
    262 #endif
    263 #if NH_3D_DBBP
    264     m_pbDBBPFlag         = (Bool*  )xMalloc(Bool,   uiNumPartition);
    265 #endif
    266196
    267197  }
     
    319249    }
    320250
    321 #if NH_3D_DIS
    322     if ( m_bDISFlag           ) { delete[] m_bDISFlag;   m_bDISFlag     = NULL; }
    323     if ( m_ucDISType         ) { xFree(m_ucDISType);  m_ucDISType    = NULL; }
    324 #endif
    325251
    326252    if ( m_pePartSize )
     
    360286    }
    361287
    362 #if NH_3D_VSP
    363     if ( m_piVSPFlag )
    364     {
    365       xFree(m_piVSPFlag);
    366       m_piVSPFlag = NULL;
    367     }
    368 #endif
    369 #if NH_3D_SPIVMP
    370     if ( m_pbSPIVMPFlag       ) { xFree(m_pbSPIVMPFlag);           m_pbSPIVMPFlag         = NULL; }
    371 #endif
    372288
    373289
     
    455371      m_acCUMvField[rpl].destroy();
    456372    }
    457 #if NH_3D_NBDV
    458     if ( m_pDvInfo            ) { xFree(m_pDvInfo);             m_pDvInfo           = NULL; }
    459 #endif
    460 
    461 
    462 #if NH_3D_ARP
    463     if ( m_puhARPW            ) { xFree(m_puhARPW);             m_puhARPW           = NULL; }
    464 #endif
    465 #if NH_3D_IC
    466     if ( m_pbICFlag           ) { xFree(m_pbICFlag);            m_pbICFlag          = NULL; }
    467 #endif
    468 
    469 #if NH_3D_DMM
    470     for( Int i = 0; i < NUM_DMM; i++ )
    471     {
    472       if ( m_dmmDeltaDC[i][0] ) { xFree( m_dmmDeltaDC[i][0] ); m_dmmDeltaDC[i][0] = NULL; }
    473       if ( m_dmmDeltaDC[i][1] ) { xFree( m_dmmDeltaDC[i][1] ); m_dmmDeltaDC[i][1] = NULL; }
    474     }
    475     if ( m_dmm1WedgeTabIdx    ) { xFree( m_dmm1WedgeTabIdx );  m_dmm1WedgeTabIdx = NULL;  }
    476 #endif
    477 #if NH_3D_SDC_INTRA
    478     if ( m_pbSDCFlag            ) { xFree(m_pbSDCFlag);             m_pbSDCFlag             = NULL; }
    479     if ( m_apSegmentDCOffset[0] ) { xFree(m_apSegmentDCOffset[0]);  m_apSegmentDCOffset[0]  = NULL; }
    480     if ( m_apSegmentDCOffset[1] ) { xFree(m_apSegmentDCOffset[1]);  m_apSegmentDCOffset[1]  = NULL; }
    481 #endif   
    482 #if NH_3D_DBBP
    483     if ( m_pbDBBPFlag         ) { xFree(m_pbDBBPFlag);          m_pbDBBPFlag        = NULL; }
    484 #endif
     373
     374
     375
    485376
    486377  }
     
    572463  memset( m_skipFlag          , false,                      m_uiNumPartition * sizeof( *m_skipFlag ) );
    573464
    574 #if NH_3D_DIS
    575     memset( m_bDISFlag        , false,                      m_uiNumPartition * sizeof( *m_bDISFlag ) );
    576     memset( m_ucDISType       , false,                      m_uiNumPartition * sizeof( *m_ucDISType ) );
    577 #endif
    578465
    579466  memset( m_pePartSize        , NUMBER_OF_PART_SIZES,       m_uiNumPartition * sizeof( *m_pePartSize ) );
     
    585472  memset( m_puhHeight         , maxCUHeight,                m_uiNumPartition * sizeof( *m_puhHeight ) );
    586473
    587 #if NH_3D_IC
    588   memset( m_pbICFlag          , false,                      m_uiNumPartition * sizeof( *m_pbICFlag ) );
    589 #endif
    590474  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    591475  {
     
    606490  memset( m_puhMergeIndex     , 0,                        m_uiNumPartition * sizeof( *m_puhMergeIndex ) );
    607491
    608 #if NH_3D_VSP
    609   memset( m_piVSPFlag         , 0,                        m_uiNumPartition * sizeof( *m_piVSPFlag ) );
    610 #endif
    611 #if NH_3D_SPIVMP
    612   memset( m_pbSPIVMPFlag      , 0,                     m_uiNumPartition * sizeof( *m_pbSPIVMPFlag ) );   
    613 #endif
    614 #if NH_3D_SDC_INTRA
    615   memset( m_pbSDCFlag, false, m_uiNumPartition * sizeof( *m_pbSDCFlag ) );
    616 #endif
    617 #if NH_3D_DBBP
    618   memset( m_pbDBBPFlag , false, m_uiNumPartition * sizeof( *m_pbDBBPFlag ));
    619 #endif
    620492
    621493  for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
     
    624496  }
    625497
    626 #if NH_3D_ARP
    627   memset( m_puhARPW      ,      0,        m_uiNumPartition * sizeof( *m_puhARPW )         );
    628 #endif
    629 
    630 
    631 #if NH_3D_DMM
    632   for( Int i = 0; i < NUM_DMM; i++ )
    633   {
    634     memset( m_dmmDeltaDC[i][0], 0,                        m_uiNumPartition * sizeof( *m_dmmDeltaDC[i][0] ) );
    635     memset( m_dmmDeltaDC[i][1], 0,                        m_uiNumPartition * sizeof( *m_dmmDeltaDC[i][1] ) );
    636   }
    637   memset( m_dmm1WedgeTabIdx,    0,                        m_uiNumPartition * sizeof( *m_dmm1WedgeTabIdx   ) );
    638 #endif
    639 #if NH_3D_SDC_INTRA
    640     memset( m_pbSDCFlag,     false,                m_uiNumPartition * sizeof( *m_pbSDCFlag ) );
    641     memset( m_apSegmentDCOffset[0],     0,                m_uiNumPartition * sizeof( *m_apSegmentDCOffset[0] ) );
    642     memset( m_apSegmentDCOffset[1],     0,                m_uiNumPartition * sizeof( *m_apSegmentDCOffset[1] ) );
    643 #endif
     498
     499
    644500
    645501  memset( m_puhInterDir       , 0,                        m_uiNumPartition * sizeof( *m_puhInterDir ) );
     
    743599    }
    744600    m_skipFlag[ui]      = false;
    745 #if NH_3D_DIS
    746     m_bDISFlag[ui]      = false;
    747     m_ucDISType[ui]     = 0;
    748 #endif
    749601    m_pePartSize[ui]    = NUMBER_OF_PART_SIZES;
    750602    m_pePredMode[ui]    = NUMBER_OF_PREDICTION_MODES;
     
    755607    m_pbMergeFlag[ui]   = 0;
    756608    m_puhMergeIndex[ui] = 0;
    757 #if NH_3D_VSP
    758     m_piVSPFlag[ui]     = 0;
    759 #endif
    760 #if NH_3D_SPIVMP
    761     m_pbSPIVMPFlag[ui] = 0;
    762 #endif
    763609
    764610    for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
     
    772618      m_puhCbf[comp][ui] = 0;
    773619    }
    774 #if NH_3D_ARP
    775       m_puhARPW[ui] = 0;
    776 #endif
    777 #if NH_3D_IC
    778       m_pbICFlag[ui]  = false;
    779 #endif
    780 
    781 
    782 #if NH_3D_DMM
    783     for( Int i = 0; i < NUM_DMM; i++ )
    784     {
    785       m_dmmDeltaDC[i][0] [ui] = 0;
    786       m_dmmDeltaDC[i][1] [ui] = 0;
    787     }
    788     m_dmm1WedgeTabIdx    [ui] = 0;
    789 #endif
    790 #if NH_3D_SDC_INTRA
    791       m_pbSDCFlag           [ui] = false;
    792       m_apSegmentDCOffset[0][ui] = 0;
    793       m_apSegmentDCOffset[1][ui] = 0;
    794 #endif
    795 #if NH_3D_DBBP
    796       m_pbDBBPFlag[ui] = false;
    797 #endif
     620
     621
    798622  }
    799623
     
    849673  memset( m_pbMergeFlag,        0, iSizeInBool  );
    850674  memset( m_puhMergeIndex,      0, iSizeInUchar );
    851 #if NH_3D_VSP
    852   memset( m_piVSPFlag,          0, sizeof( SChar ) * m_uiNumPartition );
    853 #endif
    854 #if NH_3D_SPIVMP
    855   memset( m_pbSPIVMPFlag,       0, sizeof( Bool  ) * m_uiNumPartition );
    856 #endif
    857675
    858676  for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
     
    876694  memset( m_puhHeight,         uhHeight, iSizeInUchar );
    877695  memset( m_pbIPCMFlag,        0, iSizeInBool  );
    878 #if NH_3D_ARP
    879   memset( m_puhARPW,           0, iSizeInUchar  );
    880 #endif
    881 #if NH_3D_IC
    882   memset( m_pbICFlag,          0, iSizeInBool  );
    883 #endif
    884 #if NH_3D_DMM
    885   for( Int i = 0; i < NUM_DMM; i++ )
    886   {
    887     memset( m_dmmDeltaDC[i][0], 0, sizeof(Pel ) * m_uiNumPartition );
    888     memset( m_dmmDeltaDC[i][1], 0, sizeof(Pel ) * m_uiNumPartition );
    889   }
    890   memset( m_dmm1WedgeTabIdx,    0, sizeof(UInt) * m_uiNumPartition );
    891 #endif
    892 #if NH_3D_SDC_INTRA
    893   memset( m_pbSDCFlag,            0, sizeof(Bool) * m_uiNumPartition  );
    894   memset( m_apSegmentDCOffset[0], 0, sizeof(Pel) * m_uiNumPartition   );
    895   memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition   );
    896 #endif
    897 #if NH_3D_DBBP
    898   memset( m_pbDBBPFlag,         0, sizeof(Bool) * m_uiNumPartition  );
    899 #endif
    900696
    901697  for (UInt ui = 0; ui < m_uiNumPartition; ui++)
    902698  {
    903699    m_skipFlag[ui]   = false;
    904 #if NH_3D_DIS
    905     m_bDISFlag[ui]   = false;
    906     m_ucDISType[ui]  = 0;
    907 #endif
    908700
    909701    m_pePartSize[ui] = NUMBER_OF_PART_SIZES;
     
    918710      m_apiMVPNum[rpl][ui] = -1;
    919711    }
    920 #if NH_3D_DIS
    921       m_bDISFlag[ui]    = pcCU->getDISFlag(uiPartOffset+ui);
    922       m_ucDISType[ui]   = pcCU->getDISType(uiPartOffset+ui);
    923 #endif
    924 #if NH_3D_VSP
    925     m_piVSPFlag[ui] = pcCU->m_piVSPFlag[uiPartOffset+ui];
    926     m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui];
    927 #endif
    928 #if NH_3D_SPIVMP
    929     m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];
    930 #endif
    931 #if NH_3D_ARP
    932       m_puhARPW           [ui] = pcCU->getARPW( uiPartOffset+ui );
    933 #endif
    934 #if NH_3D_IC
    935       m_pbICFlag          [ui] = pcCU->m_pbICFlag[uiPartOffset+ui];
    936 #endif
    937 #if NH_3D_DMM
    938   for( Int i = 0; i < NUM_DMM; i++ )
    939   {
    940     m_dmmDeltaDC[i][0] [ui] = pcCU->m_dmmDeltaDC[i][0] [uiPartOffset+ui];
    941     m_dmmDeltaDC[i][1] [ui] = pcCU->m_dmmDeltaDC[i][1] [uiPartOffset+ui];
    942   }
    943   m_dmm1WedgeTabIdx    [ui] = pcCU->m_dmm1WedgeTabIdx  [uiPartOffset+ui];
    944 #endif
    945 #if NH_3D_SDC_INTRA
    946     m_pbSDCFlag           [ui] = pcCU->m_pbSDCFlag            [ uiPartOffset + ui ];
    947     m_apSegmentDCOffset[0][ui] = pcCU->m_apSegmentDCOffset[0] [ uiPartOffset + ui ];
    948     m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1] [ uiPartOffset + ui ];
    949 #endif
    950 #if NH_3D_DBBP
    951       m_pbDBBPFlag[ui]=pcCU->m_pbDBBPFlag[uiPartOffset+ui];
    952 #endif
    953712  }
    954713
     
    1009768
    1010769  m_skipFlag=pcCU->getSkipFlag()          + uiPart;
    1011 #if NH_3D_DIS
    1012   m_bDISFlag     = pcCU->getDISFlag()     + uiPart;
    1013   m_ucDISType    = pcCU->getDISType()     + uiPart;
    1014 #endif
    1015770
    1016771  m_phQP=pcCU->getQP()                    + uiPart;
     
    1019774  m_pePredMode=pcCU->getPredictionMode()  + uiPart;
    1020775  m_CUTransquantBypass  = pcCU->getCUTransquantBypass()+uiPart;
    1021 #if NH_3D_NBDV
    1022   m_pDvInfo             = pcCU->getDvInfo()           + uiPart;
    1023 #endif
    1024776
    1025777  m_pbMergeFlag         = pcCU->getMergeFlag()        + uiPart;
    1026778  m_puhMergeIndex       = pcCU->getMergeIndex()       + uiPart;
    1027 #if NH_3D_VSP
    1028   m_piVSPFlag           = pcCU->getVSPFlag()          + uiPart;
    1029 #endif
    1030 #if NH_3D_SPIVMP
    1031   m_pbSPIVMPFlag        = pcCU->getSPIVMPFlag()          + uiPart;
    1032 #endif
    1033 #if NH_3D_ARP
    1034   m_puhARPW             = pcCU->getARPW()             + uiPart;
    1035 #endif
    1036 #if NH_3D_IC
    1037   m_pbICFlag            = pcCU->getICFlag()           + uiPart;
    1038 #endif
    1039779
    1040780  for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
     
    1053793    m_explicitRdpcmMode[comp]             = pcCU->getExplicitRdpcmMode(ComponentID(comp))             + uiPart;
    1054794  }
    1055 #if NH_3D_DMM
    1056   for( Int i = 0; i < NUM_DMM; i++ )
    1057   {
    1058     m_dmmDeltaDC[i][0] = pcCU->getDmmDeltaDC( (DmmID)i, 0 ) + uiPart;
    1059     m_dmmDeltaDC[i][1] = pcCU->getDmmDeltaDC( (DmmID)i, 1 ) + uiPart;
    1060   }
    1061   m_dmm1WedgeTabIdx    = pcCU->getDmm1WedgeTabIdx()  + uiPart;
    1062 #endif
    1063 #if NH_3D_SDC_INTRA
    1064   m_pbSDCFlag               = pcCU->getSDCFlag()              + uiPart;
    1065   m_apSegmentDCOffset[0]    = pcCU->getSDCSegmentDCOffset(0)  + uiPart;
    1066   m_apSegmentDCOffset[1]    = pcCU->getSDCSegmentDCOffset(1)  + uiPart;
    1067 #endif 
    1068 #if NH_3D_DBBP
    1069   m_pbDBBPFlag              = pcCU->getDBBPFlag()         + uiPart;
    1070 #endif
    1071795
    1072796  m_puhDepth=pcCU->getDepth()                     + uiPart;
     
    1113837}
    1114838
    1115 #if NH_3D_NBDV
    1116 Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx)
    1117 {
    1118   m_pDvInfo            = pcCU->getDvInfo()                + uiAbsPartIdx;
    1119 }
    1120 #endif
    1121839
    1122840// Copy inter prediction info from the biggest CU
    1123 #if NH_3D_NBDV
    1124 Void TComDataCU::copyInterPredInfoFrom    ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList   , Bool bNBDV )
    1125 #else
    1126841Void TComDataCU::copyInterPredInfoFrom    ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList )
    1127 #endif
    1128842{
    1129843  m_pcPic              = pcCU->getPic();
     
    1147861
    1148862  m_skipFlag           = pcCU->getSkipFlag ()             + uiAbsPartIdx;
    1149 #if NH_3D_DIS
    1150   m_bDISFlag           = pcCU->getDISFlag ()              + uiAbsPartIdx;
    1151   m_ucDISType          = pcCU->getDISType()               + uiAbsPartIdx;
    1152 #endif
    1153863
    1154864  m_pePartSize         = pcCU->getPartitionSize ()        + uiAbsPartIdx;
    1155 #if NH_3D_NBDV
    1156   if(bNBDV == true)
    1157   {
    1158     m_puhWidth           = pcCU->getWidth ()                + uiAbsPartIdx;
    1159     m_puhHeight          = pcCU->getHeight()                + uiAbsPartIdx;
    1160     m_puhDepth           = pcCU->getDepth ()                + uiAbsPartIdx;
    1161   }
    1162   else
    1163   {
    1164 #endif
    1165865  m_pePredMode         = pcCU->getPredictionMode()        + uiAbsPartIdx;
    1166866  m_ChromaQpAdj        = pcCU->getChromaQpAdj()           + uiAbsPartIdx;
     
    1174874  m_pbMergeFlag        = pcCU->getMergeFlag()             + uiAbsPartIdx;
    1175875  m_puhMergeIndex      = pcCU->getMergeIndex()            + uiAbsPartIdx;
    1176 #if NH_3D_VSP
    1177   m_piVSPFlag          = pcCU->getVSPFlag()               + uiAbsPartIdx;
    1178   m_pDvInfo            = pcCU->getDvInfo()                + uiAbsPartIdx;
    1179 #endif
    1180 #if NH_3D_SPIVMP
    1181   m_pbSPIVMPFlag       = pcCU->getSPIVMPFlag()            + uiAbsPartIdx;
    1182 #endif
    1183876
    1184877  m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx;
    1185878  m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx;
    1186 #if NH_3D_ARP
    1187   m_puhARPW            = pcCU->getARPW()                  + uiAbsPartIdx;
    1188 #endif   
    1189 #if NH_3D_DBBP
    1190   m_pbDBBPFlag       = pcCU->getDBBPFlag()              + uiAbsPartIdx;
    1191 #endif
    1192879
    1193880  m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx );
    1194 #if NH_3D_NBDV
    1195   }
    1196 #endif
    1197 #if NH_3D_IC
    1198   m_pbICFlag           = pcCU->getICFlag()                + uiAbsPartIdx;
    1199 #endif
    1200881
    1201882}
     
    1221902  Int sizeInChar  = sizeof( SChar ) * uiNumPartition;
    1222903  memcpy( m_skipFlag   + uiOffset, pcCU->getSkipFlag(),       sizeof( *m_skipFlag )   * uiNumPartition );
    1223 #if NH_3D_DIS
    1224   memcpy( m_bDISFlag   + uiOffset, pcCU->getDISFlag(),        sizeof( *m_bDISFlag )   * uiNumPartition );
    1225   memcpy( m_ucDISType  + uiOffset, pcCU->getDISType(),        sizeof( *m_ucDISType )  * uiNumPartition);
    1226 #endif
    1227904  memcpy( m_phQP       + uiOffset, pcCU->getQP(),             sizeInChar                        );
    1228905  memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(),  sizeof( *m_pePartSize ) * uiNumPartition );
     
    1232909  memcpy( m_pbMergeFlag         + uiOffset, pcCU->getMergeFlag(),         iSizeInBool  );
    1233910  memcpy( m_puhMergeIndex       + uiOffset, pcCU->getMergeIndex(),        iSizeInUchar );
    1234 #if NH_3D_VSP
    1235   memcpy( m_piVSPFlag           + uiOffset, pcCU->getVSPFlag(),           sizeof( SChar ) * uiNumPartition );
    1236   memcpy( m_pDvInfo             + uiOffset, pcCU->getDvInfo(),            sizeof( *m_pDvInfo ) * uiNumPartition );
    1237 #endif
    1238 #if NH_3D_SPIVMP  || NH_3D_DBBP
    1239   memcpy( m_pbSPIVMPFlag        + uiOffset, pcCU->getSPIVMPFlag(),        sizeof( Bool ) * uiNumPartition );
    1240 #endif
    1241911
    1242912  for (UInt ch=0; ch<numValidChan; ch++)
     
    1255925    memcpy( m_explicitRdpcmMode[comp]             + uiOffset, pcCU->getExplicitRdpcmMode(ComponentID(comp))            , iSizeInUchar );
    1256926  }
    1257 #if NH_3D_DMM
    1258   for( Int i = 0; i < NUM_DMM; i++ )
    1259   {
    1260     memcpy( m_dmmDeltaDC[i][0] + uiOffset, pcCU->getDmmDeltaDC( (DmmID)i, 0 ), sizeof(Pel ) * uiNumPartition );
    1261     memcpy( m_dmmDeltaDC[i][1] + uiOffset, pcCU->getDmmDeltaDC( (DmmID)i, 1 ), sizeof(Pel ) * uiNumPartition );
    1262   }
    1263   memcpy( m_dmm1WedgeTabIdx    + uiOffset, pcCU->getDmm1WedgeTabIdx(),         sizeof(UInt) * uiNumPartition );
    1264 #endif
    1265 #if NH_3D_SDC_INTRA
    1266   memcpy( m_pbSDCFlag             + uiOffset, pcCU->getSDCFlag(), sizeof( *m_pbSDCFlag ) * uiNumPartition  );
    1267   memcpy( m_apSegmentDCOffset[0]  + uiOffset, pcCU->getSDCSegmentDCOffset(0), sizeof( Pel ) * uiNumPartition);
    1268   memcpy( m_apSegmentDCOffset[1]  + uiOffset, pcCU->getSDCSegmentDCOffset(1), sizeof( Pel ) * uiNumPartition);
    1269 #endif
    1270 #if NH_3D_DBBP
    1271   memcpy( m_pbDBBPFlag          + uiOffset, pcCU->getDBBPFlag(),          iSizeInBool  );
    1272 #endif
    1273 #if NH_3D_ARP
    1274   memcpy( m_puhARPW             + uiOffset, pcCU->getARPW(),              iSizeInUchar );
    1275 #endif
    1276927
    1277928  memcpy( m_puhDepth  + uiOffset, pcCU->getDepth(),  iSizeInUchar );
     
    1314965  }
    1315966
    1316 #if NH_3D_IC
    1317   memcpy( m_pbICFlag            + uiOffset, pcCU->getICFlag(),            iSizeInBool );
    1318 #endif
    1319967
    1320968  m_uiTotalBins += pcCU->getTotalBins();
     
    1338986
    1339987  memcpy( pCtu->getSkipFlag() + m_absZIdxInCtu, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition );
    1340 #if NH_3D_DIS
    1341   memcpy( pCtu->getDISFlag()  + m_absZIdxInCtu, m_bDISFlag, sizeof( *m_bDISFlag )  * m_uiNumPartition );
    1342   memcpy( pCtu->getDISType()  + m_absZIdxInCtu, m_ucDISType, sizeof( *m_ucDISType ) * m_uiNumPartition );
    1343 #endif
    1344988
    1345989  memcpy( pCtu->getQP() + m_absZIdxInCtu, m_phQP, sizeInChar  );
    1346 #if NH_3D_NBDV
    1347   memcpy( pCtu->getDvInfo() + m_absZIdxInCtu, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition );
    1348 #endif
    1349990
    1350991  memcpy( pCtu->getPartitionSize()  + m_absZIdxInCtu, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition );
     
    1354995  memcpy( pCtu->getMergeFlag()         + m_absZIdxInCtu, m_pbMergeFlag,         iSizeInBool  );
    1355996  memcpy( pCtu->getMergeIndex()        + m_absZIdxInCtu, m_puhMergeIndex,       iSizeInUchar );
    1356 #if NH_3D_VSP
    1357   memcpy( pCtu->getVSPFlag()           + m_absZIdxInCtu, m_piVSPFlag,           sizeof( SChar ) * m_uiNumPartition );
    1358 #endif
    1359 #if NH_3D_DBBP
    1360   memcpy( pCtu->getDvInfo()            + m_absZIdxInCtu, m_pDvInfo,             sizeof( *m_pDvInfo ) * m_uiNumPartition );
    1361 #endif
    1362 #if NH_3D_SPIVMP
    1363   memcpy( pCtu->getSPIVMPFlag()        + m_absZIdxInCtu, m_pbSPIVMPFlag,        sizeof( Bool ) * m_uiNumPartition );
    1364 #endif
    1365997
    1366998for (UInt ch=0; ch<numValidChan; ch++)
     
    13801012  }
    13811013
    1382 #if NH_3D_DMM
    1383   for( Int i = 0; i < NUM_DMM; i++ )
    1384   {
    1385     memcpy( pCtu->getDmmDeltaDC( (DmmID)i, 0 ) + m_absZIdxInCtu, m_dmmDeltaDC[i][0], sizeof(Pel ) * m_uiNumPartition );
    1386     memcpy( pCtu->getDmmDeltaDC( (DmmID)i, 1 ) + m_absZIdxInCtu, m_dmmDeltaDC[i][1], sizeof(Pel ) * m_uiNumPartition );
    1387   }
    1388   memcpy( pCtu->getDmm1WedgeTabIdx()           + m_absZIdxInCtu, m_dmm1WedgeTabIdx,  sizeof(UInt) * m_uiNumPartition );
    1389 #endif
    1390 #if NH_3D_SDC_INTRA
    1391   memcpy( pCtu->getSDCFlag()             + m_absZIdxInCtu, m_pbSDCFlag, sizeof(Bool) * m_uiNumPartition );
    1392   memcpy( pCtu->getSDCSegmentDCOffset(0) + m_absZIdxInCtu, m_apSegmentDCOffset[0], sizeof( Pel ) * m_uiNumPartition);
    1393   memcpy( pCtu->getSDCSegmentDCOffset(1) + m_absZIdxInCtu, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition);
    1394 #endif
    1395 #if NH_3D_DBBP
    1396   memcpy( pCtu->getDBBPFlag()          + m_absZIdxInCtu, m_pbDBBPFlag,          iSizeInBool  );
    1397 #endif
    1398 #if NH_3D_ARP
    1399   memcpy( pCtu->getARPW()              + m_absZIdxInCtu, m_puhARPW,             iSizeInUchar );
    1400 #endif
    14011014
    14021015  memcpy( pCtu->getDepth()  + m_absZIdxInCtu, m_puhDepth,  iSizeInUchar );
     
    14321045  }
    14331046
    1434 #if NH_3D_IC
    1435   memcpy( pCtu->getICFlag() + m_absZIdxInCtu, m_pbICFlag, sizeof( *m_pbICFlag ) * m_uiNumPartition );
    1436 #endif
    14371047  pCtu->getTotalBins() = m_uiTotalBins;
    14381048}
    1439 #if H_3D_SPIVMP
    1440   memcpy( rpcCU->getSPIVMPFlag()        + uiPartOffset, m_pbSPIVMPFlag,        sizeof(Bool) * uiQNumPart );
    1441 #endif
    14421049
    14431050
     
    18421449  }
    18431450  iLeftIntraDir  = pcCULeft ? ( pcCULeft->isIntra( LeftPartIdx ) ? pcCULeft->getIntraDir( chType, LeftPartIdx ) : DC_IDX ) : DC_IDX;
    1844 #if NH_3D_DMM
    1845   mapDmmToIntraDir( iLeftIntraDir );
    1846 #endif
    18471451
    18481452  // Get intra direction of above PU
     
    18541458  }
    18551459  iAboveIntraDir = pcCUAbove ? ( pcCUAbove->isIntra( AbovePartIdx ) ? pcCUAbove->getIntraDir( chType, AbovePartIdx ) : DC_IDX ) : DC_IDX;
    1856 #if NH_3D_DMM
    1857   mapDmmToIntraDir( iAboveIntraDir );
    1858 #endif
    18591460
    18601461
     
    19901591  return uiCtx;
    19911592}
    1992 #if NH_3D_ARP
    1993 UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx )
    1994 {
    1995   const TComDataCU* pcTempCU;
    1996   UInt        uiTempPartIdx;
    1997   UInt        uiCtx = 0;
    1998 
    1999   pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
    2000   uiCtx    = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0;
    2001   return uiCtx;
    2002 }
    2003 #endif
    2004 #if NH_3D_DBBP
    2005 Pel* TComDataCU::getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride)
    2006 {
    2007   const TComSPS* sps = getSlice()->getSPS();
    2008   UInt uiMaxCUWidth = sps->getMaxCUWidth();
    2009   UInt uiMaxCUHeight = sps->getMaxCUHeight();
    2010  
    2011   // get coded and reconstructed depth view
    2012   TComPicYuv* depthPicYuv = NULL;
    2013   Pel* pDepthPels = NULL;
    2014  
    2015   // DBBP is a texture coding tool
    2016   assert( !getSlice()->getIsDepth() );
    2017  
    2018 #if H_3D_FCO
    2019   TComPic* depthPic = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    2020  
    2021   if( depthPic && depthPic->getPicYuvRec() != NULL && depthPic->getIsDepth() )  // depth first
    2022   {
    2023     depthPicYuv = depthPic->getPicYuvRec();
    2024     depthPicYuv->extendPicBorder();
    2025    
    2026     // get collocated depth block for current CU
    2027     uiDepthStride = depthPicYuv->getStride();
    2028     pDepthPels    = depthPicYuv->getLumaAddr( getAddr(), uiAbsPartIdx );
    2029   }
    2030   else  // texture first
    2031 #else
    2032   {
    2033     DisInfo DvInfo = getDvInfo(uiAbsPartIdx);
    2034    
    2035     TComPic* baseDepthPic = getSlice()->getIvPic (true, DvInfo.m_aVIdxCan);
    2036    
    2037     if( baseDepthPic == NULL || baseDepthPic->getPicYuvRec() == NULL )
    2038     {
    2039       return NULL;
    2040     }
    2041    
    2042     depthPicYuv   = baseDepthPic->getPicYuvRec();
    2043     depthPicYuv->extendPicBorder();
    2044     uiDepthStride = depthPicYuv->getStride(COMPONENT_Y);
    2045    
    2046     Int iBlkX = ( getCtuRsAddr() % baseDepthPic->getFrameWidthInCtus() ) * uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCtu()+uiAbsPartIdx ] ];
    2047     Int iBlkY = ( getCtuRsAddr() / baseDepthPic->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCtu()+uiAbsPartIdx ] ];
    2048    
    2049     Int iPictureWidth  = depthPicYuv->getWidth(COMPONENT_Y);
    2050     Int iPictureHeight = depthPicYuv->getHeight(COMPONENT_Y);
    2051    
    2052    
    2053     Bool depthRefineFlag = false;
    2054 #if NH_3D_NBDV_REF
    2055     depthRefineFlag = m_pcSlice->getDepthRefinementFlag();
    2056 #endif // NH_3D_NBDV_REF
    2057    
    2058     TComMv cDv = depthRefineFlag ? DvInfo.m_acDoNBDV : DvInfo.m_acNBDV;
    2059     if( depthRefineFlag )
    2060     {
    2061       cDv.setVer(0);
    2062     }
    2063    
    2064     Int depthPosX = Clip3(0,   iPictureWidth - 1,  iBlkX + ((cDv.getHor()+2)>>2));
    2065     Int depthPosY = Clip3(0,   iPictureHeight - 1, iBlkY + ((cDv.getVer()+2)>>2));
    2066    
    2067     pDepthPels = depthPicYuv->getAddr(COMPONENT_Y) + depthPosX + depthPosY * uiDepthStride;
    2068   }
    2069 #endif
    2070  
    2071   AOF( depthPicYuv != NULL );
    2072   AOF( pDepthPels != NULL );
    2073   AOF( uiDepthStride != 0 );
    2074  
    2075   return pDepthPels;
    2076 }
    2077 #endif
    2078 
    2079 #if NH_3D_DBBP
    2080 Void TComDataCU::setDBBPFlagSubParts ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    2081 {
    2082   setSubPart( bDBBPFlag, m_pbDBBPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
    2083 }
    2084 #endif
     1593
    20851594
    20861595
     
    21701679}
    21711680
    2172 #if NH_3D_DIS
    2173 Void TComDataCU::setDISFlagSubParts( Bool bDIS, UInt uiAbsPartIdx, UInt uiDepth )
    2174 {
    2175     assert( sizeof( *m_bDISFlag) == 1 );
    2176     memset( m_bDISFlag + uiAbsPartIdx, bDIS, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) );
    2177 }
    2178 
    2179 Void TComDataCU::setDISTypeSubParts(UChar ucDISType, UInt uiAbsPartIdx, UInt uiDepth )
    2180 {
    2181   assert( sizeof( *m_ucDISType) == 1 );
    2182   memset( m_ucDISType + uiAbsPartIdx, ucDISType, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) );
    2183 }
    2184 #endif
    21851681
    21861682Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth )
     
    23361832}
    23371833
    2338 #if NH_3D_SDC_INTRA
    2339 Void TComDataCU::setSDCFlagSubParts ( Bool bSDCFlag, UInt absPartIdx, UInt depth )
    2340 {
    2341   assert( sizeof( *m_pbSDCFlag) == 1 );
    2342   memset( m_pbSDCFlag + absPartIdx, bSDCFlag, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) );
    2343 }
    2344 
    2345 Bool TComDataCU::getSDCAvailable( UInt uiAbsPartIdx )
    2346 {
    2347   if( getSlice()->getIsDepth() && isIntra(uiAbsPartIdx) && getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N )
    2348   {
    2349     UInt lumaPredMode = getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx );
    2350     if( lumaPredMode < NUM_INTRA_MODE ) { return true; }
    2351 #if NH_3D_DMM
    2352     if( isDmmMode( lumaPredMode )     ) { return true; }
    2353 #endif
    2354   }
    2355   return false;
    2356 }
    2357 #endif
    23581834
    23591835Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     
    23671843}
    23681844
    2369 #if NH_3D_SPIVMP
    2370 Void TComDataCU::setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    2371 {
    2372   setSubPart<Bool>( bSPIVMPFlag, m_pbSPIVMPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
    2373 }
    2374 #endif
    2375 
    2376 #if NH_3D_VSP
    2377 Void TComDataCU::setVSPFlagSubParts( SChar iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    2378 {
    2379   setSubPart<SChar>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
    2380 }
    2381 template<typename T>
    2382 Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx )
    2383 {
    2384   UInt uiCurrPartNumQ = (m_pcPic->getNumPartitionsInCtu() >> (2 * uiCUDepth)) >> 2;
    2385   switch ( m_pePartSize[ uiCUAddr ] )
    2386   {
    2387   case SIZE_2Nx2N:
    2388     for (UInt ui = 0; ui < 4 * uiCurrPartNumQ; ui++)
    2389       puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2390 
    2391     break;
    2392   case SIZE_2NxN:
    2393     for (UInt ui = 0; ui < 2 * uiCurrPartNumQ; ui++)
    2394       puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2395     break;
    2396   case SIZE_Nx2N:
    2397     for (UInt ui = 0; ui < uiCurrPartNumQ; ui++)
    2398       puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2399     for (UInt ui = 0; ui < uiCurrPartNumQ; ui++)
    2400       puhBaseLCU[uiCUAddr + 2 * uiCurrPartNumQ + ui] = uiParameter;
    2401     break;
    2402   case SIZE_NxN:
    2403     for (UInt ui = 0; ui < uiCurrPartNumQ; ui++)
    2404       puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2405     break;
    2406   case SIZE_2NxnU:
    2407     if ( uiPUIdx == 0 )
    2408     {
    2409       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++)
    2410         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2411       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++)
    2412         puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter;
    2413 
    2414     }
    2415     else if ( uiPUIdx == 1 )
    2416     {
    2417       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++)
    2418         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2419       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1); ui++)
    2420         puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter;
    2421 
    2422     }
    2423     else
    2424     {
    2425       assert(0);
    2426     }
    2427     break;
    2428   case SIZE_2NxnD:
    2429     if ( uiPUIdx == 0 )
    2430     {
    2431       for (UInt ui = 0; ui < ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)); ui++)
    2432         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2433       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++)
    2434         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + ui] = uiParameter;
    2435 
    2436     }
    2437     else if ( uiPUIdx == 1 )
    2438     {
    2439       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++)
    2440         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2441       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++)
    2442         puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter;
    2443 
    2444     }
    2445     else
    2446     {
    2447       assert(0);
    2448     }
    2449     break;
    2450   case SIZE_nLx2N:
    2451     if ( uiPUIdx == 0 )
    2452     {
    2453       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2454         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2455       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2456         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2457       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2458         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter;
    2459       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2460         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2461 
    2462     }
    2463     else if ( uiPUIdx == 1 )
    2464     {
    2465       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2466         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2467       for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++)
    2468         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2469       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2470         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter;
    2471       for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++)
    2472         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2473 
    2474     }
    2475     else
    2476     {
    2477       assert(0);
    2478     }
    2479     break;
    2480   case SIZE_nRx2N:
    2481     if ( uiPUIdx == 0 )
    2482     {
    2483       for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++)
    2484         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2485       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2486         puhBaseLCU[uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2487       for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++)
    2488         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter;
    2489       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2490         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2491 
    2492     }
    2493     else if ( uiPUIdx == 1 )
    2494     {
    2495       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2496         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2497       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2498         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2499       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2500         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter;
    2501       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2502         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2503 
    2504     }
    2505     else
    2506     {
    2507       assert(0);
    2508     }
    2509     break;
    2510   default:
    2511     assert( 0 );
    2512   }
    2513 
    2514 }
    2515 #endif
     1845
    25161846
    25171847Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     
    25991929
    26001930// This is for use by a leaf/sub CU object only, with no additional AbsPartIdx
    2601 #if NH_3D_IC || NH_3D_VSP
    2602 Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU) const
    2603 {
    2604   UInt uiNumPartition  = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition;
    2605   UInt  uiTmpAbsPartIdx  = bLCU ? uiAbsPartIdx : 0;
    2606 
    2607   switch ( m_pePartSize[uiTmpAbsPartIdx] )
    2608   {
    2609   case SIZE_2NxN:
    2610     riWidth = getWidth( uiTmpAbsPartIdx );      riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1;
    2611     break;
    2612   case SIZE_Nx2N:
    2613     riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx );      ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2;
    2614     break;
    2615   case SIZE_NxN:
    2616     riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx;
    2617     break;
    2618   case SIZE_2NxnU:
    2619     riWidth     = getWidth( uiTmpAbsPartIdx );
    2620     riHeight    = ( uiPartIdx == 0 ) ?  getHeight( uiTmpAbsPartIdx ) >> 2 : ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 );
    2621     ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3;
    2622     break;
    2623   case SIZE_2NxnD:
    2624     riWidth     = getWidth( uiTmpAbsPartIdx );
    2625     riHeight    = ( uiPartIdx == 0 ) ?  ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ) : getHeight( uiTmpAbsPartIdx ) >> 2;
    2626     ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3);
    2627     break;
    2628   case SIZE_nLx2N:
    2629     riWidth     = ( uiPartIdx == 0 ) ? getWidth( uiTmpAbsPartIdx ) >> 2 : ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 );
    2630     riHeight    = getHeight( uiTmpAbsPartIdx );
    2631     ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4;
    2632     break;
    2633   case SIZE_nRx2N:
    2634     riWidth     = ( uiPartIdx == 0 ) ? ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ) : getWidth( uiTmpAbsPartIdx ) >> 2;
    2635     riHeight    = getHeight( uiTmpAbsPartIdx );
    2636     ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4);
    2637     break;
    2638   default:
    2639     assert ( m_pePartSize[uiTmpAbsPartIdx] == SIZE_2Nx2N );
    2640     riWidth = getWidth( uiTmpAbsPartIdx );      riHeight = getHeight( uiTmpAbsPartIdx );      ruiPartAddr = 0;
    2641     break;
    2642   }
    2643 }
    2644 #else
    26451931
    26461932Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight )  const
     
    26831969  }
    26841970}
    2685 #endif
    26861971
    26871972// static member function
     
    29332218}
    29342219
    2935 #if NH_3D
    2936 Bool TComDataCU::hasEqualMotion( Int dirA, const TComMvField* mvFieldA, Int dirB, const TComMvField* mvFieldB )
    2937 {
    2938   return  ( dirA == dirB  &&
    2939     ( ( dirA & 1 ) == 0 || mvFieldA[0] == mvFieldB[0]  ) &&
    2940     ( ( dirA & 2 ) == 0 || mvFieldA[1] == mvFieldB[1]  )
    2941     );
    2942 }
    2943 #endif
    2944 
    2945 #if NH_3D_VSP
    2946 /** Add a VSP merging candidate
    2947  * \Inputs
    2948  * \param uiPUIdx: PU index within a CU
    2949  * \param ucVspMergePos: Specify the VSP merge candidate position
    2950  * \param mrgCandIdx: Target merge candidate index. At encoder, it is set equal to -1, such that the whole merge candidate list will be constructed.
    2951  * \param pDinfo: The "disparity information" derived from neighboring blocks. Type 1 MV.
    2952  * \param uiCount: The next position to add VSP merge candidate
    2953  *
    2954  * \Outputs
    2955  * \param uiCount: The next position to add merge candidate. Will be updated if VSP is successfully added
    2956  * \param abCandIsInter: abCandIsInter[iCount] tells that VSP candidate is an Inter candidate, if VSP is successfully added
    2957  * \param pcMvFieldNeighbours:   Return combined motion information, then stored to a global buffer
    2958  *                                    1) the "disparity vector". Type 1 MV. To be used to fetch a depth block.
    2959  *                                    2) the ref index /list.    Type 2 reference picture pointer, typically for texture
    2960  * \param puhInterDirNeighbours: Indicate the VSP prediction direction.
    2961  * \param vspFlag: vspFlag[iCount] will be set (equal to 1), if VSP is successfully added. To be used to indicate the actual position of the VSP candidate
    2962  *
    2963  * \Return
    2964  *   true:  if the VSP candidate is added at the target position
    2965  *   false: otherwise
    2966  */
    2967 inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount)
    2968 {
    2969   if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getViewSynthesisPredFlag( ) || m_pcSlice->getIsDepth() || pDInfo->m_aVIdxCan == -1)
    2970   {
    2971     return false;
    2972   }
    2973 
    2974   Int refViewIdx = pDInfo->m_aVIdxCan;
    2975   TComPic* picDepth = getSlice()->getIvPic( true, refViewIdx );
    2976 
    2977   if( picDepth == NULL ) // No depth reference avail
    2978   {
    2979     // Is this allowed to happen? When not an assertion should be added here!
    2980     return false;
    2981   }
    2982 
    2983   TComMvField mvVSP[2];
    2984   UChar dirVSP;
    2985   Bool  refViewAvailFlag = false;
    2986   UChar predFlag[2]      = {0, 0};
    2987 
    2988   for( Int iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ )
    2989   {
    2990     RefPicList eRefPicListX = RefPicList( iRefListIdX );
    2991     for ( Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicListX) && !refViewAvailFlag; i++ )
    2992     {
    2993       Int viewIdxRefInListX = m_pcSlice->getRefPic(eRefPicListX, i)->getViewIndex();
    2994       if ( viewIdxRefInListX == refViewIdx )
    2995       {
    2996         refViewAvailFlag      = true;
    2997         predFlag[iRefListIdX] = 1;
    2998         mvVSP[0+iRefListIdX].setMvField( pDInfo->m_acNBDV, i );
    2999 #if NH_3D_NBDV
    3000         mvVSP[0+iRefListIdX].getMv().setIDVFlag (false);
    3001 #endif
    3002       }
    3003     }
    3004   }
    3005 
    3006   dirVSP = (predFlag[0] | (predFlag[1] << 1));
    3007   m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true
    3008 #if NH_3D_SPIVMP
    3009     , false
    3010 #endif
    3011     );
    3012   if ( mrgCandIdx == iCount )
    3013   {
    3014     return true;
    3015   }
    3016 
    3017   iCount++;
    3018 
    3019   return false;
    3020 }
    3021 #endif
    3022 
    3023 #if NH_3D_IV_MERGE
    3024 inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx )
    3025 {
    3026   for(Int iLoop = 0; iLoop < 2; iLoop ++ )
    3027   {
    3028     /// iLoop = 0 --> IvMCShift
    3029     /// iLoop = 1 --> IvDCShift  (Derived from IvDC)
    3030     if(ivCandDir[iLoop + 2])
    3031     {
    3032       TComMvField tmpMV[2];
    3033       UChar tmpDir = ivCandDir[iLoop + 2];
    3034       if( ( ivCandDir[iLoop + 2] & 1 ) == 1 )
    3035       {
    3036         tmpMV[0].setMvField( ivCandMv[ (iLoop<<1) + 4 ], ivCandRefIdx[ (iLoop<<1) + 4 ] );
    3037       }
    3038       if( ( ivCandDir[iLoop + 2] & 2 ) == 2 )
    3039       {
    3040         tmpMV[1].setMvField( ivCandMv[ (iLoop<<1) + 5 ], ivCandRefIdx[ (iLoop<<1) + 5 ] );
    3041       }
    3042      
    3043       // Prune IvMC vs. IvMcShift
    3044       Bool bRemove = false;     
    3045       if( !iLoop && ivCandDir[0] > 0)
    3046       {
    3047         if( hasEqualMotion(tmpDir, tmpMV, m_mergCands[MRG_IVMC].m_uDir, m_mergCands[MRG_IVMC].m_cMvField ))
    3048         {
    3049             bRemove                         = true;
    3050         }
    3051       }
    3052       if(!bRemove)
    3053       {
    3054 #if NH_3D_NBDV
    3055         if(iLoop) // For IvMcShift candidate
    3056         {
    3057           tmpMV[0].getMv().setIDVFlag (false);
    3058           tmpMV[1].getMv().setIDVFlag (false);
    3059         }
    3060 #endif
    3061         m_mergCands[MRG_IVSHIFT].setCand(tmpMV, tmpDir, false, false);
    3062         if( mrgCandIdx == iCount )
    3063         {
    3064           return true;
    3065         }
    3066         iCount++;
    3067       }
    3068       break;
    3069     }
    3070   }
    3071   return false;
    3072 }
    3073 
    3074 #endif
    3075 #if NH_3D_MLC
    3076 /** Construct a extended list of merging candidates
    3077  * \param pcMvFieldNeighbours
    3078  * \param puhInterDirNeighbours
    3079  * \param vspFlag
    3080  * \param pbSPIVMPFlag
    3081  * \param numValidMergeCand
    3082  */
    3083 Void TComDataCU::buildMCL(TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    3084 #if NH_3D_VSP
    3085   , Int* vspFlag
    3086 #endif
    3087 #if NH_3D_SPIVMP
    3088   , Bool* pbSPIVMPFlag
    3089 #endif
    3090   , Int& numValidMergeCand
    3091   )
    3092 {
    3093   if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))
    3094   {
    3095     return;
    3096   }
    3097 
    3098 
    3099 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC
    3100   if ( g_traceMergeCandListConst )
    3101   {
    3102     for (Int i = 0; i<MRG_IVSHIFT+1; i++)
    3103     {
    3104       m_mergCands[i].print( i );
    3105     }
    3106   }
    3107 #endif
    3108 
    3109 
    3110   Int iCount = 0;
    3111   TComMv cZeroMv;
    3112 
    3113   // init temporal list
    3114   TComMvField extMergeCandList[MRG_MAX_NUM_CANDS_MEM << 1];
    3115   UChar uhInterDirNeighboursExt[MRG_MAX_NUM_CANDS_MEM];
    3116   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
    3117   {
    3118     uhInterDirNeighboursExt[ui] = puhInterDirNeighbours[ui];
    3119     extMergeCandList[ui<<1].setMvField(cZeroMv, NOT_VALID);
    3120     extMergeCandList[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID);
    3121 #if NH_3D_VSP
    3122     vspFlag[ui] = 0;
    3123 #endif
    3124   }
    3125 
    3126   // insert MPI ... IvShift candidate to extMergeCandList
    3127   for (Int i=0; i<=MRG_IVSHIFT; i++)
    3128   {
    3129     if (m_mergCands[i].m_bAvailable)
    3130     {
    3131       m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt
    3132 #if NH_3D_VSP
    3133         , vspFlag
    3134 #endif
    3135 #if NH_3D_SPIVMP
    3136         , pbSPIVMPFlag
    3137 #endif
    3138         );
    3139       iCount++;
    3140       if (iCount >= getSlice()->getMaxNumMergeCand())
    3141         break;
    3142     }
    3143   }
    3144 
    3145   Int iCountBase = m_numSpatialCands;
    3146   // insert remaining base candidates to extMergeCandList
    3147   while (iCount < getSlice()->getMaxNumMergeCand() && iCountBase < getSlice()->getMaxNumMergeCand())
    3148   {
    3149     uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[iCountBase];
    3150     extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[iCountBase<<1].getMv(), pcMvFieldNeighbours[iCountBase<<1].getRefIdx());
    3151     if ( getSlice()->isInterB() )
    3152     {
    3153       extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(iCountBase<<1)+1].getMv(), pcMvFieldNeighbours[(iCountBase<<1)+1].getRefIdx());
    3154     }
    3155     iCountBase++;
    3156     iCount++;
    3157   }
    3158 
    3159   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ )
    3160   {
    3161     puhInterDirNeighbours[ui] = 0;
    3162     pcMvFieldNeighbours[ui<<1].setMvField(cZeroMv, NOT_VALID);
    3163     pcMvFieldNeighbours[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID);
    3164   }
    3165 
    3166   // copy extMergeCandList to output
    3167   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ )
    3168   {
    3169     puhInterDirNeighbours[ui] = uhInterDirNeighboursExt[ui];
    3170     pcMvFieldNeighbours[ui<<1].setMvField(extMergeCandList[ui<<1].getMv(), extMergeCandList[ui<<1].getRefIdx());
    3171 
    3172     if ( getSlice()->isInterB() )
    3173     {
    3174       pcMvFieldNeighbours[(ui<<1)+1].setMvField(extMergeCandList[(ui<<1)+1].getMv(), extMergeCandList[(ui<<1)+1].getRefIdx());
    3175     }
    3176   }
    3177 
    3178 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC
    3179   if ( g_traceMergeCandListConst )
    3180   {
    3181     std::cout << std::setfill(' ')                          << std::setw( 15 )
    3182       <<  "Num"                                             << std::setw( 15 )
    3183       <<  "Dir "                                            << std::setw( 15 )
    3184       <<  "L0 RefIdx"                                       << std::setw( 15 )
    3185       <<  "L0 Hor"                                          << std::setw( 15 )
    3186       <<  "L0 Ver"                                          << std::setw( 15 )
    3187       <<  "L1 RefIdx"                                       << std::setw( 15 )
    3188       <<  "L1 Hor"                                          << std::setw( 15 )
    3189       <<  "L1 Ver"                                          << std::setw( 15 )
    3190       << std::endl;
    3191 
    3192     // copy extMergeCandList to output
    3193     for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ )
    3194     {
    3195       UChar curDir        = puhInterDirNeighbours[ui];
    3196       TComMvField& curf   = pcMvFieldNeighbours[ui<<1];
    3197       TComMvField& curf2  = pcMvFieldNeighbours[(ui<<1)+1];
    3198 
    3199       std::cout << std::setfill(' ')                         << std::setw( 15 )
    3200         << ui                                                << std::setw( 15 )       
    3201         << (UInt) curDir                                     << std::setw( 15 )   
    3202         << ((curDir & 1) ? curf.getRefIdx()       : MIN_INT) << std::setw( 15 )
    3203         << ((curDir & 1) ? curf.getMv().getHor()  : MIN_INT) << std::setw( 15 )
    3204         << ((curDir & 1) ? curf.getMv().getVer()  : MIN_INT) << std::setw( 15 );
    3205 
    3206       if ( getSlice()->isInterB() )
    3207       {     
    3208         std::cout << ((curDir & 2) ? curf2.getRefIdx() : MIN_INT) << std::setw( 15 )
    3209           << ((curDir & 1) ? curf2.getMv().getHor()    : MIN_INT) << std::setw( 15 )
    3210           << ((curDir & 1) ? curf2.getMv().getVer()    : MIN_INT) << std::setw( 15 );
    3211       }
    3212       std::cout << std::endl;
    3213     }
    3214   }
    3215 #endif
    3216   numValidMergeCand = iCount;
    3217   assert(iCount == getSlice()->getMaxNumMergeCand());
    3218 }
    3219 
    3220 
    3221 
    3222 /** Derive 3D merge candidates
    3223  * \param uiAbsPartIdx
    3224  * \param uiPUIdx
    3225  * \param pcMvFieldNeighbours
    3226  * \param puhInterDirNeighbours
    3227  * \param pcMvFieldSP
    3228  * \param puhInterDirNeighbours
    3229  * \param numValidMergeCand
    3230  */
    3231 Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
    3232 #if NH_3D_SPIVMP
    3233       , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    3234 #endif
    3235       , Int& numValidMergeCand, Int mrgCandIdx
    3236 )
    3237 {
    3238 #if NH_3D_IV_MERGE
    3239   TComMv cZeroMv;
    3240   TComMvField tmpMV[2]; 
    3241 #endif
    3242 
    3243   //////////////////////////////////
    3244   //////// GET DISPARITIES  ////////
    3245   //////////////////////////////////
    3246 #if NH_3D_IV_MERGE
    3247   DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
    3248   m_cDefaultDisInfo = cDisInfo;
    3249 #elif NH_3D_VSP
    3250   // for xAddVspCand()
    3251   DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
    3252 #endif
    3253 
    3254   if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))
    3255   {
    3256     return;
    3257   }
    3258   numValidMergeCand = getSlice()->getMaxNumMergeCand();
    3259   //////////////////////////////////
    3260   //////// DERIVE LOCATIONS ////////
    3261   //////////////////////////////////
    3262   // compute the location of the current PU
    3263   Int xP, yP, nPSW, nPSH;
    3264   this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
    3265 
    3266   Int iCount = 0;
    3267   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    3268   deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
    3269   deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
    3270 #if NH_3D_TEXT_MERGE
    3271   Bool bMPIFlag   = getSlice()->getMpiFlag();
    3272   Int  tmpDir;
    3273 #endif
    3274 #if NH_3D_IV_MERGE || NH_3D_TEXT_MERGE
    3275   Bool bIsDepth = getSlice()->getIsDepth();
    3276 #endif
    3277 
    3278 #if NH_3D_IC
    3279   Bool bICFlag = getICFlag(uiAbsPartIdx);
    3280 #endif
    3281 #if NH_3D_ARP
    3282   Bool bARPFlag = getARPW(uiAbsPartIdx) > 0;
    3283 #endif
    3284 #if NH_3D_DBBP
    3285   Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx);
    3286   assert(bDBBPFlag == getDBBPFlag(0)); 
    3287 #endif
    3288 
    3289 #if NH_3D_NBDV
    3290   for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++) 
    3291   {
    3292     pcMFieldNeighbours[i<<1    ].getMv().setIDVFlag (false);
    3293     pcMFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false);
    3294   }
    3295 #endif
    3296   // init containers
    3297   for (Int i = 0; i<MRG_IVSHIFT+1; i++)
    3298     m_mergCands[i].init();
    3299 
    3300   m_numSpatialCands = 0;
    3301 
    3302   //////////////////////////////////
    3303   ///////// GET VSP FLAGS //////////
    3304   //////////////////////////////////
    3305   //left
    3306   UInt uiLeftPartIdx = 0;
    3307   const TComDataCU* pcCULeft = 0;
    3308   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); 
    3309 
    3310   if (getAvailableFlagA1())
    3311   {
    3312     m_mergCands[MRG_A1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
    3313 #if NH_3D_VSP
    3314     , (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0
    3315 #if NH_3D_IC
    3316       && !bICFlag
    3317 #endif
    3318 #if NH_3D_ARP
    3319       && !bARPFlag
    3320 #endif
    3321 #if NH_3D_DBBP
    3322       && !bDBBPFlag
    3323 #endif
    3324       )
    3325 #endif
    3326 #if NH_3D_SPIVMP
    3327       , false
    3328 #endif
    3329       );
    3330     m_numSpatialCands++;
    3331   }
    3332 
    3333   // above
    3334   if (getAvailableFlagB1())
    3335   {
    3336     m_mergCands[MRG_B1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
    3337 #if NH_3D_VSP
    3338     , false
    3339 #endif
    3340 #if NH_3D_SPIVMP
    3341       , false
    3342 #endif
    3343       );
    3344     m_numSpatialCands++;
    3345   }
    3346 
    3347   // above right
    3348   if (getAvailableFlagB0())
    3349   {
    3350     m_mergCands[MRG_B0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
    3351 #if NH_3D_VSP
    3352     , false
    3353 #endif
    3354 #if NH_3D_SPIVMP
    3355       , false
    3356 #endif
    3357       );
    3358     m_numSpatialCands++;
    3359   }
    3360 
    3361   // left bottom
    3362   if (getAvailableFlagA0())
    3363   {
    3364     m_mergCands[MRG_A0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
    3365 #if NH_3D_VSP
    3366     , false
    3367 #endif
    3368 #if NH_3D_SPIVMP
    3369       , false
    3370 #endif
    3371       );
    3372     m_numSpatialCands++;
    3373   }
    3374 
    3375   // above left
    3376   if (getAvailableFlagB2())
    3377   {
    3378     m_mergCands[MRG_B2].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
    3379 #if NH_3D_VSP
    3380     , false
    3381 #endif
    3382 #if NH_3D_SPIVMP
    3383       , false
    3384 #endif
    3385       );
    3386     m_numSpatialCands++;
    3387   }
    3388 
    3389 
    3390 #if NH_3D_TEXT_MERGE
    3391 
    3392   /////////////////////////////////////////////
    3393   //////// TEXTURE MERGE CANDIDATE (T) ////////
    3394   /////////////////////////////////////////////
    3395 
    3396   bMPIFlag &= (nPSW + nPSH > 12);
    3397   if( bMPIFlag)
    3398   {
    3399     tmpMV[0].setMvField( cZeroMv, NOT_VALID );
    3400     tmpMV[1].setMvField( cZeroMv, NOT_VALID );
    3401     tmpDir        =  0;
    3402 
    3403     Bool bSPIVMPFlag = false;
    3404 
    3405     TComPic * pcTexPic = m_pcSlice->getTexturePic();
    3406 #if H_3D_FCO
    3407     if (pcTexPic && pcTexPic->getReconMark())
    3408     {
    3409 #endif   
    3410       TComPicYuv*   pcTexRec = pcTexPic->getPicYuvRec  ();
    3411       UInt          uiPartAddr;
    3412       Int           iWidth, iHeight;
    3413       Int           iCurrPosX, iCurrPosY;
    3414 
    3415       this->getPartIndexAndSize( uiPUIdx, uiPartAddr, iWidth, iHeight );
    3416       pcTexRec->getTopLeftSamplePos( this->getCtuRsAddr(), this->getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY );
    3417 
    3418       Int iPUWidth, iPUHeight, iNumPart, iNumPartLine;
    3419       this->getSPPara(iWidth, iHeight, iNumPart, iNumPartLine, iPUWidth, iPUHeight);
    3420 
    3421       for (Int i=0; i<iNumPart; i++)
    3422       {
    3423         puhInterDirSP[i] = 0;
    3424         pcMvFieldSP[2*i].getMv().set(0, 0);
    3425         pcMvFieldSP[2*i+1].getMv().set(0, 0);
    3426         pcMvFieldSP[2*i].setRefIdx(-1);
    3427         pcMvFieldSP[2*i+1].setRefIdx(-1);
    3428       }
    3429 
    3430       Int         iTexCUAddr;
    3431       Int         iTexAbsPartIdx;
    3432       TComDataCU* pcTexCU;
    3433       Int iPartition = 0;
    3434       Int iInterDirSaved = 0;
    3435       TComMvField cMvFieldSaved[2];
    3436 
    3437       Int iOffsetX = iPUWidth/2;;
    3438       Int iOffsetY = iPUHeight/2;
    3439 
    3440       Int         iTexPosX, iTexPosY;
    3441 #if NH_3D_INTEGER_MV_DEPTH
    3442       const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
    3443 #endif
    3444       Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iPUWidth ) >> 1 )  * iPUWidth + ( iPUWidth >> 1 );
    3445       Int         iCenterPosY = iCurrPosY + ( ( iHeight /  iPUHeight ) >> 1 )  * iPUHeight + (iPUHeight >> 1);
    3446       Int         iTexCenterCUAddr, iTexCenterAbsPartIdx;
    3447 
    3448       if(iWidth == iPUWidth && iHeight == iPUHeight)
    3449       {
    3450         iCenterPosX = iCurrPosX + (iWidth >> 1);
    3451         iCenterPosY = iCurrPosY + (iHeight >> 1);
    3452       }
    3453 
    3454       // derivation of center motion parameters from the collocated texture CU
    3455 
    3456       pcTexRec->getCUAddrAndPartIdx( iCenterPosX , iCenterPosY , iTexCenterCUAddr, iTexCenterAbsPartIdx );
    3457       TComDataCU* pcDefaultCU    = pcTexPic->getCtu( iTexCenterCUAddr );
    3458 
    3459       if( pcDefaultCU->getPredictionMode( iTexCenterAbsPartIdx ) != MODE_INTRA )
    3460       {
    3461         for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
    3462         {
    3463           RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
    3464 
    3465           TComMvField cDefaultMvField;
    3466           pcDefaultCU->getMvField( pcDefaultCU, iTexCenterAbsPartIdx, eCurrRefPicList, cDefaultMvField );
    3467           Int         iDefaultRefIdx     = cDefaultMvField.getRefIdx();
    3468           if (iDefaultRefIdx >= 0)
    3469           {
    3470             Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eCurrRefPicList, iDefaultRefIdx);
    3471             for (Int iRefPicList = 0; iRefPicList < m_pcSlice->getNumRefIdx( eCurrRefPicList ); iRefPicList++)
    3472             {
    3473               if (iDefaultRefPOC == m_pcSlice->getRefPOC(eCurrRefPicList, iRefPicList))
    3474               {
    3475                 bSPIVMPFlag = true;
    3476 #if NH_3D_INTEGER_MV_DEPTH
    3477                 TComMv cMv = cDefaultMvField.getMv() + cMvRounding;
    3478                 cMv >>= 2;
    3479 #else
    3480                 TComMv cMv = cDefaultMvField.getMv();
    3481 #endif
    3482                 cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ;
    3483                 break;
    3484               }
    3485             }
    3486           }
    3487         }
    3488       }
    3489       if ( bSPIVMPFlag == true )
    3490       {   
    3491         iInterDirSaved = (cMvFieldSaved[0].getRefIdx()!=-1 ? 1: 0) + (cMvFieldSaved[1].getRefIdx()!=-1 ? 2: 0);
    3492         tmpDir = iInterDirSaved;
    3493         tmpMV[0] = cMvFieldSaved[0];
    3494         tmpMV[1] = cMvFieldSaved[1];
    3495       }
    3496 
    3497       if ( iInterDirSaved != 0 )
    3498       {
    3499         for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iPUHeight)
    3500         {
    3501           for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iPUWidth)
    3502           {
    3503             iTexPosX     = j + iOffsetX;
    3504             iTexPosY     = i + iOffsetY;
    3505             pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx );
    3506             pcTexCU  = pcTexPic->getCtu( iTexCUAddr );
    3507 
    3508             if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) )
    3509             {
    3510               for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
    3511               {
    3512                 RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
    3513                 TComMvField cTexMvField;
    3514                 pcTexCU->getMvField( pcTexCU, iTexAbsPartIdx, eCurrRefPicList, cTexMvField );
    3515                 Int iValidDepRef = getPic()->isTextRefValid( eCurrRefPicList, cTexMvField.getRefIdx() );
    3516                 if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) )
    3517                 {
    3518 #if NH_3D_INTEGER_MV_DEPTH
    3519                   TComMv cMv = cTexMvField.getMv() + cMvRounding;
    3520                   cMv >>=2;         
    3521 #else
    3522                   TComMv cMv = cTexMvField.getMv();
    3523 #endif         
    3524                   pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef);
    3525                 }
    3526               }
    3527             }
    3528             puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0);
    3529             if (puhInterDirSP[iPartition] == 0)
    3530             {
    3531               if (iInterDirSaved != 0)
    3532               {
    3533                 puhInterDirSP[iPartition] = iInterDirSaved;
    3534                 pcMvFieldSP[2*iPartition] = cMvFieldSaved[0];
    3535                 pcMvFieldSP[2*iPartition + 1] = cMvFieldSaved[1];
    3536               }
    3537             }
    3538 
    3539             iPartition ++;
    3540           }
    3541         }
    3542       }
    3543 #if H_3D_FCO
    3544     }
    3545 #endif
    3546     if( tmpDir != 0 )
    3547     {
    3548       Int iCnloop = 0;
    3549       for(iCnloop = 0; iCnloop < 2; iCnloop ++)
    3550       {
    3551         if ( !m_mergCands[MRG_A1+iCnloop].m_bAvailable )  // pruning to A1, B1
    3552         {
    3553           continue;
    3554         }
    3555         if (hasEqualMotion( tmpDir, tmpMV, m_mergCands[MRG_A1+iCnloop].m_uDir, m_mergCands[MRG_A1+iCnloop].m_cMvField ) )
    3556         {
    3557           m_mergCands[MRG_A1+iCnloop].m_bAvailable = false;
    3558           break;
    3559         }     
    3560       }
    3561       m_mergCands[MRG_T].setCand( tmpMV, tmpDir, false, bSPIVMPFlag);
    3562 
    3563       if ( mrgCandIdx == iCount )
    3564       {
    3565         return;
    3566       }
    3567       iCount ++;
    3568     }
    3569   }
    3570 #endif
    3571 
    3572 #if NH_3D_IV_MERGE
    3573   /////////////////////////////////////////////////////////////////
    3574   //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC  Candidates /////
    3575   /////////////////////////////////////////////////////////////////
    3576 
    3577   // { IvMCL0, IvMCL1, IvDCL0, IvDCL1, IvMCL0Shift, IvMCL1Shift, IvDCL0Shift, IvDCL1Shift }; 
    3578   // An enumerator would be appropriate here!
    3579   TComMv ivCandMv    [8];
    3580   Int    ivCandRefIdx[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
    3581 
    3582   // { IvMC, IvDC, IvMCShift, IvDCShift }; 
    3583   Int    ivCandDir   [4] = {0, 0, 0, 0};
    3584 
    3585   Bool ivMvPredFlag   = getSlice()->getIvMvPredFlag();
    3586 
    3587   ivMvPredFlag &= (nPSW + nPSH > 12);
    3588   if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1)
    3589   {
    3590 #if NH_3D_IC
    3591     getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, bICFlag );
    3592 #else
    3593     getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, false );
    3594 #endif
    3595   } 
    3596 
    3597   ///////////////////////////////////////////////
    3598   //////// INTER VIEW MOTION COMP(IvMC) /////////
    3599   ///////////////////////////////////////////////
    3600   if( getSlice()->getIsDepth() )
    3601   {
    3602     ivCandDir[1] = ivCandDir[2] = ivCandDir[3] = 0;
    3603   }
    3604 
    3605   if( ivCandDir[0] )
    3606   {
    3607     tmpMV[0].setMvField( cZeroMv, NOT_VALID );
    3608     tmpMV[1].setMvField( cZeroMv, NOT_VALID );
    3609 
    3610     if( ( ivCandDir[0] & 1 ) == 1 )
    3611     {
    3612       tmpMV[0].setMvField( ivCandMv[ 0 ], ivCandRefIdx[ 0 ] );
    3613     }
    3614     if( ( ivCandDir[0] & 2 ) == 2 )
    3615     {
    3616       tmpMV[1].setMvField( ivCandMv[ 1 ], ivCandRefIdx[ 1 ] );
    3617     }
    3618 
    3619     Bool bRemoveSpa = false; //pruning
    3620 
    3621     if (!bIsDepth)
    3622     {
    3623       for(Int i = 0; i < 2; i ++)
    3624       {
    3625         if ( !m_mergCands[MRG_A1 + i].m_bAvailable ) // pruning to A1, B1
    3626         {
    3627           continue;
    3628         }
    3629         if (hasEqualMotion(ivCandDir[0], tmpMV, m_mergCands[MRG_A1+i].m_uDir,  m_mergCands[MRG_A1+i].m_cMvField) )
    3630         {
    3631           m_mergCands[MRG_A1+i].m_bAvailable = false;
    3632           break;
    3633         }     
    3634       }
    3635     }
    3636     else
    3637     {
    3638       if( hasEqualMotion( ivCandDir[0], tmpMV, m_mergCands[MRG_T].m_uDir, m_mergCands[MRG_T].m_cMvField ) )
    3639       {
    3640         bRemoveSpa                      = true;
    3641       }
    3642     }
    3643     if (!bRemoveSpa)
    3644     {
    3645       Bool spiMvpFlag = false;
    3646       if(!m_pcSlice->getIsDepth())
    3647       {
    3648         spiMvpFlag = true;
    3649       }
    3650 #if NH_3D_DBBP
    3651       spiMvpFlag &= !bDBBPFlag;
    3652 #endif
    3653 
    3654       m_mergCands[MRG_IVMC].setCand( tmpMV, ivCandDir[0], false, spiMvpFlag);
    3655 
    3656       if ( mrgCandIdx == iCount )
    3657       {
    3658         return;
    3659       }
    3660       iCount ++;
    3661     }
    3662   }
    3663 
    3664   // early termination
    3665   if (iCount == getSlice()->getMaxNumMergeCand())
    3666   {
    3667     return;
    3668   }
    3669 #endif
    3670 
    3671   iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable;
    3672 
    3673 #if NH_3D_VSP
    3674   /////////////////////////////////////////////////
    3675   //////// VIEW SYNTHESIS PREDICTION (VSP) ////////
    3676   /////////////////////////////////////////////////
    3677   if (iCount<getSlice()->getMaxNumMergeCand())
    3678   {
    3679     if (
    3680       (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) &&
    3681 #if NH_3D_IC
    3682       !bICFlag &&
    3683 #endif
    3684 #if NH_3D_ARP
    3685       !bARPFlag &&
    3686 #endif
    3687 #if NH_3D
    3688       (nPSW + nPSH > 12) &&
    3689 #endif
    3690 #if NH_3D_DBBP
    3691       !bDBBPFlag &&
    3692 #endif
    3693       xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) )
    3694     {
    3695       return;
    3696     }
    3697 
    3698     // early termination
    3699     if (iCount == getSlice()->getMaxNumMergeCand())
    3700     {
    3701       return;
    3702     }
    3703   }
    3704 #endif
    3705 
    3706   iCount += m_mergCands[MRG_B0].m_bAvailable;
    3707 
    3708 #if NH_3D_IV_MERGE
    3709   /////////////////////////////////////////////
    3710   //////// INTER VIEW DISP COMP (IvDC) ////////
    3711   /////////////////////////////////////////////
    3712   if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
    3713   {
    3714     assert(iCount < getSlice()->getMaxNumMergeCand());
    3715 
    3716     tmpMV[0].setMvField( cZeroMv, NOT_VALID );
    3717     tmpMV[1].setMvField( cZeroMv, NOT_VALID );
    3718     if( ( ivCandDir[1] & 1 ) == 1 )
    3719     {
    3720       tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
    3721     }
    3722     if( ( ivCandDir[1] & 2 ) == 2 )
    3723     {
    3724       tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
    3725     }
    3726 
    3727     Bool bRemoveSpa = false; //pruning to A1, B1
    3728     for(Int i = 0; i < 2; i ++)
    3729     {
    3730       if ( !m_mergCands[MRG_A1+i].m_bAvailable )
    3731       {
    3732         continue;
    3733       }
    3734       if ( hasEqualMotion(ivCandDir[1], tmpMV, m_mergCands[MRG_A1+i].m_uDir, m_mergCands[MRG_A1+i].m_cMvField) )
    3735       {
    3736         bRemoveSpa                      = true;
    3737         break;
    3738       }     
    3739     }
    3740     if(!bRemoveSpa)
    3741     {
    3742 #if NH_3D_NBDV
    3743       tmpMV[0].getMv().setIDVFlag (false);
    3744       tmpMV[1].getMv().setIDVFlag (false);
    3745 #endif
    3746       m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false);
    3747 
    3748       if ( mrgCandIdx == iCount )
    3749         return;
    3750       iCount ++;
    3751 
    3752       // early termination
    3753       if (iCount == getSlice()->getMaxNumMergeCand())
    3754       {
    3755         return;
    3756       }
    3757     }
    3758   }
    3759 #endif // H_3D_IV_MERGE
    3760 
    3761   iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable;
    3762 
    3763 #if NH_3D_IV_MERGE
    3764   ////////////////////////////////////////////////////
    3765   //////// SHIFTED IV (IvMCShift + IvDCShift) ////////
    3766   ////////////////////////////////////////////////////
    3767   if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
    3768   {
    3769     if(xAddIvMRGCand( mrgCandIdx,  iCount, ivCandDir, ivCandMv, ivCandRefIdx ) )
    3770     {
    3771       return;
    3772     }
    3773     //early termination
    3774     if (iCount == getSlice()->getMaxNumMergeCand())
    3775     {
    3776       return;
    3777     }
    3778   }
    3779 #endif
    3780 }
    3781 #endif
     2220
     2221
    37822222
    37832223//! Construct a list of merging candidates
    3784 #if NH_3D
    3785 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
    3786 #else
    37872224Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) const
    3788 #endif
    37892225{
    37902226  UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx;
    3791 #if NH_3D_MLC
    3792   Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
    3793 #else
    37942227  Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
    3795 #endif
    37962228  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
    37972229  {
     
    38232255  if ( isAvailableA1 )
    38242256  {
    3825 #if NH_3D_MLC
    3826     m_bAvailableFlagA1 = 1;
    3827 #endif
    38282257    abCandIsInter[iCount] = true;
    38292258    // get Inter Dir
     
    38582287  if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
    38592288  {
    3860 #if NH_3D_MLC
    3861     m_bAvailableFlagB1 = 1;
    3862 #endif
    38632289    abCandIsInter[iCount] = true;
    38642290    // get Inter Dir
     
    38922318  if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
    38932319  {
    3894 #if NH_3D_MLC
    3895     m_bAvailableFlagB0 = 1;
    3896 #endif
    38972320    abCandIsInter[iCount] = true;
    38982321    // get Inter Dir
     
    39262349  if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
    39272350  {
    3928 #if NH_3D_MLC
    3929     m_bAvailableFlagA0 = 1;
    3930 #endif
    39312351    abCandIsInter[iCount] = true;
    39322352    // get Inter Dir
     
    39632383        && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
    39642384    {
    3965 #if NH_3D_MLC
    3966       m_bAvailableFlagB2 = 1;
    3967 #endif
    39682385      abCandIsInter[iCount] = true;
    39692386      // get Inter Dir
     
    40472464    if ( getSlice()->isInterB() )
    40482465    {
    4049 #if NH_3D_TMVP
    4050       iRefIdx = 0;
    4051 #endif
    40522466      bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx);
    40532467      if( bExistMV == false )
     
    40662480      puhInterDirNeighbours[uiArrayAddr] = dir;
    40672481      abCandIsInter[uiArrayAddr] = true;
    4068 #if NH_3D_NBDV
    4069       pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
    4070       pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
    4071 #endif
    40722482
    40732483      if ( mrgCandIdx == iCount )
     
    40872497  UInt uiCutoff = uiArrayAddr;
    40882498
    4089 #if NH_3D_MLC
    4090   if ( getSlice()->isInterB() && iCount<5)
    4091 #else
    40922499  if ( getSlice()->isInterB() )
    4093 #endif
    40942500  {
    40952501    static const UInt NUM_PRIORITY_LIST=12;
     
    43342740    const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
    43352741    const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
    4336 #if NH_3D_TMVP
    4337     Int refIdx_Col = refIdx;
    4338 #else
    43392742    const Int refIdx_Col = refIdx;
    4340 #endif
    43412743    TComMv cColMv;
    43422744    UInt partIdxRB;
     
    43722774      }
    43732775    }
    4374 #if NH_3D_TMVP
    4375         if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, absPartAddr, cColMv, refIdx_Col  , 0 ) )
    4376 #else
    43772776    if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, absPartAddr, cColMv, refIdx_Col ) )
    4378 #endif
    43792777    {
    43802778      pInfo->m_acMvCand[pInfo->iN++] = cColMv;
     
    43842782      UInt uiPartIdxCenter;
    43852783      xDeriveCenterIdx( partIdx, uiPartIdxCenter );
    4386 #if NH_3D_TMVP
    4387       if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter,  cColMv, refIdx_Col , 0 ))
    4388 #else
    43892784      if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter,  cColMv, refIdx_Col ))
    4390 #endif
    43912785      {
    43922786        pInfo->m_acMvCand[pInfo->iN++] = cColMv;
     
    44112805  UInt partAddr;
    44122806
    4413 #if NH_3D_DBBP
    4414   if( getDBBPFlag(0) )
    4415   {
    4416     return true;
    4417   }
    4418 #endif
    44192807
    44202808  getPartIndexAndSize( puIdx, partAddr, width, height );
     
    44312819  const TComSPS &sps=*(m_pcSlice->getSPS());
    44322820  Int  iMvShift = 2;
    4433 #if NH_3D_INTEGER_MV_DEPTH
    4434   if( getSlice()->getIsDepth() )
    4435     iMvShift = 0;
    4436 #endif
    44372821
    44382822  Int iOffset = 8;
     
    46633047}
    46643048
    4665 #if NH_3D_TMVP
    4666 Bool TComDataCU::xGetColMVP( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, Int& refIdx, Bool bMRG  ) const
    4667 #else
    46683049Bool TComDataCU::xGetColMVP( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, const Int refIdx ) const
    4669 #endif
    46703050{
    46713051  const UInt absPartAddr = partUnitIdx;
     
    46983078  }
    46993079
    4700 #if NH_3D_TMVP
    4701   Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();
    4702 #else
    47033080  const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();
    4704 #endif
    47053081  const Bool bIsColRefLongTerm  = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx);
    47063082
    47073083  if ( bIsCurrRefLongTerm != bIsColRefLongTerm )
    47083084  {
    4709 #if NH_3D_TMVP
    4710     Int iAlterRefIdx  = m_pcSlice->getAlterRefIdx(eRefPicList);
    4711     if(bMRG && iAlterRefIdx > 0)
    4712     {
    4713       refIdx = iAlterRefIdx;
    4714       bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();
    4715       assert(bIsCurrRefLongTerm == bIsColRefLongTerm);
    4716     }
    4717     else
    4718     {
    4719 #endif
    47203085      return false;
    4721 #if NH_3D_TMVP
    4722     }
    4723 #endif
    47243086  }
    47253087  // Scale the vector.
    47263088  const TComMv &cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(absPartAddr);
    47273089
    4728 #if NH_3D_TMVP
    4729   if ( bIsCurrRefLongTerm || bIsColRefLongTerm )
    4730 #else
    47313090  if ( bIsCurrRefLongTerm /*|| bIsColRefLongTerm*/ )
    4732 #endif
    4733   {
    4734 #if NH_3D_TMVP
    4735     const Int iCurrViewId    = m_pcSlice->getViewId ();
    4736     const Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, refIdx)->getViewId ();
    4737     const Int iColViewId     = pColCtu->getSlice()->getViewId();
    4738     const Int iColRefViewId  = pColCtu->getSlice()->getRefPic( eColRefPicList, pColCtu->getCUMvField(eColRefPicList)->getRefIdx(absPartAddr))->getViewId();
    4739     Int scale = 4096;
    4740     if ( iCurrRefViewId != iCurrViewId && iColViewId != iColRefViewId )
    4741     {
    4742       scale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId );
    4743     }
    4744     if ( bMRG && scale != 4096 && m_pcSlice->getIvMvScalingFlag( ) )
    4745     {
    4746       rcMv = cColMv.scaleMv( scale );
    4747     }
    4748     else
    4749     {
    4750 #endif
     3091  {
    47513092      rcMv = cColMv;
    4752 #if NH_3D_TMVP
    4753     }
    4754 #endif
    47553093  }
    47563094  else
     
    48073145}
    48083146
    4809 #if NH_3D
    4810 Void TComDataCU::compressMV(Int scale)
    4811 {
    4812    Int scaleFactor = (4 / scale ) * AMVP_DECIMATION_FACTOR / m_unitSize;
    4813 #else
    48143147Void TComDataCU::compressMV()
    48153148{
    48163149  Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize;
    4817 #endif
    48183150  if (scaleFactor > 0)
    48193151  {
     
    48243156  }
    48253157}
    4826 #if NH_3D
    4827 Void TComDataCU::printMV( )
    4828 
    4829 
    4830   for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    4831   {
    4832     std::cout << "L" << i;
    4833     m_acCUMvField[i].print(m_pePredMode);
    4834   }
    4835 
    4836 }
    4837 #endif
    48383158
    48393159UInt TComDataCU::getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const
     
    48673187
    48683188  UInt uiDirMode  = getIntraDir(toChannelType(compID), uiAbsPartIdx);
    4869 #if NH_3D_DMM
    4870   mapDmmToIntraDir( uiDirMode );
    4871 #endif
    48723189
    48733190  if (uiDirMode==DM_CHROMA_IDX)
     
    48763193    const UInt partsPerMinCU = 1<<(2*(sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize()));
    48773194    uiDirMode = getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, getPic()->getChromaFormat(), partsPerMinCU));
    4878 #if NH_3D_DMM
    4879     mapDmmToIntraDir( uiDirMode );
    4880 #endif
    48813195  }
    48823196
     
    49023216}
    49033217
    4904 #if NH_3D_VSO
    4905 Void TComDataCU::getPosInPic( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) const
    4906 {
    4907   riPosX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelX();
    4908   riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY(); 
    4909 }
    4910 #endif
    4911 
    4912 #if NH_3D_IV_MERGE
    4913 Void TComDataCU::getDispforDepth (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp)
    4914 {
    4915   assert(getPartitionSize( uiPartAddr ) == SIZE_2Nx2N);
    4916 
    4917   TComMv cMv;
    4918   if ( getSlice()->getDefaultRefViewIdxAvailableFlag() )
    4919   {
    4920     Int iViewIdx = getSlice()->getDefaultRefViewIdx();
    4921     pDisp->m_aVIdxCan = iViewIdx;
    4922     Int iDisp     = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 )) ];
    4923 
    4924     cMv.setHor(iDisp);
    4925     cMv.setVer(0);
    4926     pDisp->m_acNBDV = cMv;
    4927     pDisp->m_aVIdxCan = iViewIdx;
    4928   }
    4929 }
    4930 #endif
    4931 
    4932 #if NH_3D_DIS
    4933 Bool TComDataCU::getNeighDepth ( UInt uiPartIdx, UInt uiPartAddr, Pel* pNeighDepth, Int index )
    4934 {
    4935   assert(uiPartIdx==0);
    4936   const UInt uiPartIdxLT      = getZorderIdxInCtu() + uiPartAddr;
    4937   const Int  iPartIdxStride   = getPic()->getNumPartInCtuWidth();
    4938  
    4939   UInt uiMidPart, uiPartNeighbor; 
    4940   const TComDataCU* pcCUNeighbor;
    4941   Bool bDepAvail = false;
    4942   Pel *pDepth  = this->getPic()->getPicYuvRec()->getAddr(COMPONENT_Y);
    4943   Int iDepStride =  this->getPic()->getPicYuvRec()->getStride(COMPONENT_Y);
    4944 
    4945   Int xP, yP, nPSW, nPSH;
    4946   this->getPartPosition( uiPartIdx, xP, yP, nPSW, nPSH );
    4947 
    4948   switch( index )
    4949   {
    4950   case 0: // Mid Left
    4951     uiMidPart = g_auiZscanToRaster[uiPartIdxLT] + (nPSH>>1) / this->getPic()->getMinCUHeight() * iPartIdxStride;
    4952     pcCUNeighbor = this->getPULeft( uiPartNeighbor, g_auiRasterToZscan[uiMidPart] );
    4953     if ( pcCUNeighbor )
    4954     {
    4955       if( !this->getSlice()->getPPS()->getConstrainedIntraPred() )
    4956       {
    4957         *pNeighDepth = pDepth[ (yP+(nPSH>>1)) * iDepStride + (xP-1) ];
    4958         bDepAvail = true;
    4959       }
    4960       else if ( pcCUNeighbor->getPredictionMode( uiPartNeighbor ) == MODE_INTRA )
    4961       {
    4962         *pNeighDepth = pDepth[ (yP+(nPSH>>1)) * iDepStride + (xP-1) ];
    4963         bDepAvail = true;
    4964       }
    4965     }
    4966     break;
    4967   case 1: // Mid Above
    4968     uiMidPart = g_auiZscanToRaster[uiPartIdxLT] + (nPSW>>1) / this->getPic()->getMinCUWidth();
    4969     pcCUNeighbor = this->getPUAbove( uiPartNeighbor, g_auiRasterToZscan[uiMidPart] );
    4970     if( pcCUNeighbor )
    4971     {
    4972       if( !this->getSlice()->getPPS()->getConstrainedIntraPred() )
    4973       {
    4974         *pNeighDepth = pDepth[ (yP-1) * iDepStride + (xP + (nPSW>>1)) ];
    4975         bDepAvail = true;
    4976       }
    4977       else if ( pcCUNeighbor->getPredictionMode( uiPartNeighbor ) == MODE_INTRA )
    4978       {
    4979         *pNeighDepth = pDepth[ (yP-1) * iDepStride + (xP + (nPSW>>1)) ];
    4980         bDepAvail = true;
    4981       }
    4982     }
    4983     break;
    4984   default:
    4985     break;
    4986   }
    4987 
    4988   return bDepAvail;
    4989 }
    4990 #endif
    4991 #if NH_3D_NBDV
    4992 //Notes from QC:
    4993 //TBD#1: DoNBDV related contributions are just partially integrated under the marco of NH_3D_NBDV_REF, remove this comment once DoNBDV and BVSP are done
    4994 //TBD#2: set of DvMCP values need to be done as part of inter-view motion prediction process. Remove this comment once merge related integration is done
    4995 //To be checked: Parallel Merge features for NBDV, related to DV_DERIVATION_PARALLEL_B0096 and LGE_IVMP_PARALLEL_MERGE_B0136 are not integrated. The need of these features due to the adoption of CU-based NBDV is not clear. We need confirmation on this, especially by proponents
    4996 Void TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo
    4997 #if NH_3D_NBDV_REF
    4998 , Bool bDepthRefine
    4999 #endif
    5000 )
    5001 {
    5002   //// ******* Init variables ******* /////
    5003   // Init disparity struct for results
    5004   pDInfo->m_aVIdxCan = -1;
    5005 
    5006   // Init struct for disparities from MCP neighboring blocks
    5007   IDVInfo cIDVInfo;
    5008   cIDVInfo.m_bFound = false;
    5009   UInt uiPartIdx = 0;
    5010   UInt uiPartAddr = 0;
    5011   for (UInt iCurDvMcpCand = 0; iCurDvMcpCand < IDV_CANDS; iCurDvMcpCand++)
    5012   {
    5013     for (UInt iList = 0; iList < 2; iList++)
    5014     {
    5015       cIDVInfo.m_acMvCand[iList][iCurDvMcpCand].setZero();
    5016       cIDVInfo.m_aVIdxCan[iList][iCurDvMcpCand] = 0;
    5017       cIDVInfo.m_bAvailab[iList][iCurDvMcpCand] = false;
    5018     }
    5019   }
    5020 #if NH_3D_NBDV_REF
    5021   if( !m_pcSlice->getDepthRefinementFlag( ) )
    5022   {
    5023     bDepthRefine = false;
    5024   }
    5025 #endif
    5026   // Get Positions 
    5027   PartSize eCUMode    = getPartitionSize( uiPartAddr );   
    5028   assert(eCUMode == SIZE_2Nx2N);
    5029   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; 
    5030 
    5031   deriveLeftRightTopIdxGeneral(uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT );
    5032   deriveLeftBottomIdxGeneral  (uiPartAddr, uiPartIdx, uiPartIdxLB );
    5033 
    5034   //// ******* Get disparity from temporal neighboring blocks ******* /////
    5035   if ( getSlice()->getEnableTMVPFlag() )
    5036   {
    5037     TComMv cColMv;
    5038     Int iTargetViewIdx = 0;
    5039     Int iTStartViewIdx = 0;   
    5040 
    5041     ///*** Derive center position ***
    5042     UInt uiPartIdxCenter;
    5043     Int  uiLCUIdx = getCtuRsAddr();
    5044     xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter );
    5045 
    5046     ///*** Search temporal candidate pictures for disparity vector ***
    5047     const Int iNumCandPics = getPic()->getNumDdvCandPics();
    5048     for(Int curCandPic = 0; curCandPic < iNumCandPics; curCandPic++)
    5049     {
    5050       RefPicList eCurRefPicList   = REF_PIC_LIST_0 ;
    5051       Int        curCandPicRefIdx = 0;
    5052       if( curCandPic == 0 )
    5053       {
    5054         eCurRefPicList   = RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0);
    5055         curCandPicRefIdx = getSlice()->getColRefIdx();
    5056       }
    5057       else                 
    5058       {
    5059         eCurRefPicList   = getPic()->getRapRefList();
    5060         curCandPicRefIdx = getPic()->getRapRefIdx();
    5061       }
    5062 
    5063       Bool bCheck = xGetColDisMV( curCandPic, eCurRefPicList, curCandPicRefIdx, uiLCUIdx,   uiPartIdxCenter,  cColMv, iTargetViewIdx, iTStartViewIdx );
    5064 
    5065       if( bCheck )
    5066       {
    5067         pDInfo->m_acNBDV = cColMv;
    5068         pDInfo->m_aVIdxCan  = iTargetViewIdx;
    5069 
    5070 #if NH_3D_NBDV_REF
    5071         TComPic* picDepth = NULL;   
    5072 #if H_3D_FCO
    5073         picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    5074         if ( picDepth->getPicYuvRec() != NULL  ) 
    5075         {
    5076           cColMv.setZero();
    5077         }
    5078         else // Go back with virtual depth
    5079         {
    5080           picDepth = getSlice()->getIvPic( true, iTargetViewIdx );
    5081         }
    5082 
    5083         assert(picDepth != NULL);
    5084 #else
    5085         picDepth = getSlice()->getIvPic( true, iTargetViewIdx );
    5086 #endif
    5087         if (picDepth && bDepthRefine)
    5088         {
    5089           estimateDVFromDM(iTargetViewIdx, uiPartIdx, picDepth, uiPartAddr, &cColMv );
    5090         }
    5091         pDInfo->m_acDoNBDV  = cColMv;
    5092 #endif //NH_3D_NBDV_REF
    5093         return;
    5094       }
    5095     }
    5096   }
    5097 
    5098   UInt uiIdx = 0;
    5099   Bool        bCheckMcpDv = false;   
    5100   const TComDataCU* pcTmpCU     = NULL;
    5101 
    5102   //// ******* Get disparity from left block ******* /////
    5103 #if NH_3D_FIX_TICKET_91
    5104     pcTmpCU = getPULeft(uiIdx, uiPartIdxLB);
    5105 #else
    5106   pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false);
    5107 #endif
    5108   bCheckMcpDv = true;
    5109   if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT
    5110 #if NH_3D_NBDV_REF
    5111     , bDepthRefine
    5112 #endif
    5113     ) )
    5114     return;
    5115 
    5116   //// ******* Get disparity from above block ******* /////
    5117   pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true);
    5118   if(pcTmpCU != NULL )
    5119   {
    5120     bCheckMcpDv = ( ( getCtuRsAddr() - pcTmpCU->getCtuRsAddr() ) == 0);
    5121     if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE
    5122 #if NH_3D_NBDV_REF
    5123       , bDepthRefine
    5124 #endif
    5125       ) )
    5126       return;
    5127   }
    5128 
    5129   //// ******* Search MCP blocks ******* /////
    5130   if( cIDVInfo.m_bFound )
    5131   {
    5132     for( Int curPos = 0 ; curPos < IDV_CANDS ; curPos++ )
    5133     {
    5134       for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
    5135       {
    5136         if( cIDVInfo.m_bAvailab[iList][curPos] )
    5137         {
    5138           TComMv cDispVec = cIDVInfo.m_acMvCand[iList][ curPos ];
    5139           pDInfo->m_acNBDV = cDispVec;
    5140           pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ];
    5141 #if NH_3D_NBDV_REF
    5142 #if H_3D_FCO
    5143           TComPic* picDepth  = NULL;
    5144 
    5145           picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    5146           if ( picDepth->getPicYuvRec() != NULL ) 
    5147           {
    5148             cDispVec.setZero();
    5149           }
    5150           else // Go back with virtual depth
    5151           {
    5152             picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan );
    5153           }
    5154 
    5155           assert(picDepth != NULL);
    5156 #else
    5157           TComPic* picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan );
    5158 #endif
    5159 
    5160           if (picDepth && bDepthRefine)
    5161           {
    5162             estimateDVFromDM (pDInfo->m_aVIdxCan, uiPartIdx, picDepth, uiPartAddr, &cDispVec);
    5163           }
    5164           pDInfo->m_acDoNBDV = cDispVec;
    5165 #endif
    5166           return;
    5167         }
    5168       }
    5169     }
    5170   }
    5171 
    5172   TComMv defaultDV(0, 0);
    5173   pDInfo->m_acNBDV = defaultDV;
    5174 
    5175   if (getSlice()->getDefaultRefViewIdxAvailableFlag())
    5176   {
    5177     pDInfo->m_aVIdxCan = getSlice()->getDefaultRefViewIdx();
    5178 
    5179 #if NH_3D_NBDV_REF
    5180     TComPic* picDepth = NULL;
    5181 #if H_3D_FCO
    5182     picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    5183     if ( picDepth->getPicYuvRec() != NULL ) 
    5184     {
    5185       defaultDV.setZero();
    5186     }
    5187     else // Go back with virtual depth
    5188     {
    5189       picDepth = getSlice()->getIvPic( true, getSlice()->getDefaultRefViewIdx());
    5190     }
    5191 
    5192     assert(picDepth != NULL);
    5193 #else
    5194     picDepth = getSlice()->getIvPic( true, getSlice()->getDefaultRefViewIdx());
    5195 #endif
    5196     if (picDepth && bDepthRefine)
    5197     {
    5198       estimateDVFromDM(getSlice()->getDefaultRefViewIdx(), uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view
    5199     }
    5200     pDInfo->m_acDoNBDV = defaultDV;
    5201 #endif
    5202   }
    5203 }
    5204 
    5205 #if NH_3D_NBDV_REF
    5206 Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT )
    5207 {
    5208   Int iPictureWidth  = pcBaseViewDepthPicYuv->getWidth(COMPONENT_Y);
    5209   Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight(COMPONENT_Y);
    5210 
    5211   Int depthStartPosX = Clip3(0,   iPictureWidth - 1,  iBlkX + ((mv->getHor()+2)>>2));
    5212   Int depthStartPosY = Clip3(0,   iPictureHeight - 1, iBlkY + ((mv->getVer()+2)>>2));
    5213   Int depthEndPosX   = Clip3(0,   iPictureWidth - 1,  iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2));
    5214   Int depthEndPosY   = Clip3(0,   iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2));
    5215 
    5216   Pel* depthTL  = pcBaseViewDepthPicYuv->getAddr(COMPONENT_Y);
    5217   Int depStride =  pcBaseViewDepthPicYuv->getStride(COMPONENT_Y);
    5218 
    5219   Pel  maxDepthVal = 0;
    5220   maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthStartPosX ]);      // Left Top
    5221   maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY)   * depStride + depthStartPosX ]);      // Left Bottom
    5222   maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthEndPosX   ]);      // Right Top
    5223   maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY)   * depStride + depthEndPosX   ]);      // Right Bottom
    5224 
    5225   return aiShiftLUT[ maxDepthVal ];
    5226 }
    5227 
    5228 Void TComDataCU::estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred )
    5229 {
    5230   if (picDepth)
    5231   {
    5232     UInt uiAbsPartAddrCurrCU = m_absZIdxInCtu + uiPartAddr;
    5233     Int iWidth, iHeight;
    5234     getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more
    5235 
    5236     TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec();
    5237     const TComSPS   &sps =*(getSlice()->getSPS());
    5238     Int iBlkX = ( getCtuRsAddr() % picDepth->getFrameWidthInCtus() ) * sps.getMaxCUWidth()  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
    5239     Int iBlkY = ( getCtuRsAddr() / picDepth->getFrameWidthInCtus() ) * sps.getMaxCUHeight() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
    5240 
    5241     Int* aiShiftLUT = getSlice()->getDepthToDisparityB(refViewIdx );
    5242 
    5243     Pel iDisp = getMcpFromDM( pcBaseViewDepthPicYuv, cMvPred, iBlkX, iBlkY, iWidth, iHeight, aiShiftLUT );
    5244     cMvPred->setHor( iDisp );
    5245   }
    5246 }
    5247 #endif //NH_3D_NBDV_REF
    5248 
    5249 
    5250 Bool TComDataCU::xCheckSpatialNBDV( const TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos
    5251 #if NH_3D_NBDV_REF
    5252 , Bool bDepthRefine
    5253 #endif
    5254 )
    5255 {
    5256   if( pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
    5257   {
    5258     Bool bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
    5259     for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
    5260     {
    5261       RefPicList eRefPicList = RefPicList(iList);
    5262       Int      refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
    5263       TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
    5264 
    5265       if( refId >= 0)
    5266       {
    5267         Int refViewIdx  = pcTmpCU->getSlice()->getRefPic(eRefPicList, refId)->getViewIndex();
    5268         if (refViewIdx != m_pcSlice->getViewIndex())
    5269         {
    5270           pNbDvInfo->m_acNBDV = cMvPred;
    5271           pNbDvInfo->m_aVIdxCan = refViewIdx;
    5272 #if NH_3D_NBDV_REF
    5273           TComPic* picDepth = NULL;
    5274           assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());           
    5275 #if H_3D_FCO
    5276           picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    5277           if ( picDepth->getPicYuvRec() != NULL ) 
    5278           {
    5279             cMvPred.setZero();
    5280           }
    5281           else// Go back with virtual depth
    5282           {
    5283             picDepth = getSlice()->getIvPic (true, refViewIdx );
    5284           }
    5285           assert(picDepth != NULL);
    5286 #else
    5287           picDepth   = getSlice()->getIvPic (true, refViewIdx );
    5288 #endif
    5289           UInt uiPartIdx = 0;   //Notes from MTK: Please confirm that using 0 as partition index and partition address is correct for CU-level DoNBDV
    5290           UInt uiPartAddr = 0;  //QC: confirmed
    5291 
    5292           if (picDepth && bDepthRefine)
    5293           {
    5294             estimateDVFromDM(refViewIdx, uiPartIdx, picDepth, uiPartAddr, &cMvPred );
    5295           }
    5296           pNbDvInfo->m_acDoNBDV = cMvPred;
    5297 #endif
    5298           return true;
    5299         }
    5300         else if ( bSearchForMvpDv && cMvPred.getIDVFlag() && bTmpIsSkipped )
    5301         {
    5302           assert( uiMvpDvPos < IDV_CANDS );
    5303           paIDVInfo->m_acMvCand[iList][ uiMvpDvPos ] = TComMv( cMvPred.getIDVHor(), cMvPred.getIDVVer() );
    5304           //Notes from QC: DvMCP is implemented in a way that doesnot carry the reference view identifier as NBDV. It only works for CTC and needs to be fixed to be aligned with other part of the NBDV design.
    5305           paIDVInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = cMvPred.getIDVVId();
    5306           paIDVInfo->m_bAvailab[iList][ uiMvpDvPos ] = true;
    5307           paIDVInfo->m_bFound                        = true;
    5308         }
    5309       }
    5310     }
    5311   }
    5312   return false;
    5313 }
    5314  
    5315 Void TComDataCU::xDeriveRightBottomNbIdx(Int &riLCUIdxRBNb, Int &riPartIdxRBNb )
    5316 {
    5317   UInt uiPartIdx = 0;
    5318   UInt uiNumPartInCUWidth = m_pcPic->getNumPartInCtuWidth(); 
    5319   Int uiLCUIdx = getCtuRsAddr();
    5320 
    5321   UInt uiPartIdxRB;
    5322   deriveRightBottomIdx(uiPartIdx, uiPartIdxRB ); 
    5323   UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
    5324 
    5325   if (( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )
    5326   {
    5327     riLCUIdxRBNb  = -1;
    5328     riPartIdxRBNb = -1;
    5329   }
    5330   else if(( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
    5331   {
    5332     riLCUIdxRBNb  = -1;
    5333     riPartIdxRBNb = -1;
    5334   }
    5335   else
    5336   {
    5337     if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
    5338       ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInCtuHeight() - 1 ) ) // is not at the last row    of LCU
    5339     {
    5340       riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
    5341       riLCUIdxRBNb  = uiLCUIdx;
    5342     }
    5343     else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
    5344     {
    5345       riPartIdxRBNb = -1;
    5346       riLCUIdxRBNb  = -1;
    5347     }
    5348     else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInCtuHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
    5349     {
    5350       riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
    5351       riLCUIdxRBNb = uiLCUIdx + 1;
    5352     }
    5353     else //is the right bottom corner of LCU                       
    5354     {
    5355       riPartIdxRBNb = -1;
    5356       riLCUIdxRBNb  = -1;
    5357     }
    5358   }
    5359 }
    5360 
    5361 
    5362 Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth )
    5363 {
    5364 #if NH_3D_VSP // bug fix
    5365   UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1);
    5366   assert(m_pcPic->getNumPartitionsInCtu() ==m_pcPic->getNumPartInCtuWidth()*m_pcPic->getNumPartInCtuHeight());
    5367 
    5368 #else
    5369   UInt uiCurrPartNumb = m_pcPic->getNumPartInCtuWidth() >> (uiDepth << 1);
    5370 #endif
    5371   for (UInt ui = 0; ui < uiCurrPartNumb; ui++ )
    5372   {
    5373     m_pDvInfo[uiAbsPartIdx + ui] = cDvInfo;
    5374   }
    5375 }
    5376 #if NH_3D_VSP  || NH_3D_DBBP
    5377 Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth )
    5378 {
    5379   setSubPartT<DisInfo>( cDvInfo, m_pDvInfo, uiAbsPartIdx, uiDepth, uiPUIdx );
    5380 }
    5381 #endif
    5382 
    5383 Bool TComDataCU::xGetColDisMV( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx )
    5384 {
    5385 
    5386   RefPicList  eColRefPicList = REF_PIC_LIST_0;
    5387   Int iColViewIdx, iColRefViewIdx;
    5388   TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx);
    5389   TComDataCU *pColCU = pColPic->getCtu( uiCUAddr );
    5390   iColViewIdx = pColCU->getSlice()->getViewIndex();
    5391   if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==NUMBER_OF_PART_SIZES||pColCU->isIntra(uiPartUnitIdx))
    5392   {
    5393     return false;
    5394   }
    5395   for (Int ilist = 0; ilist < (pColCU->getSlice()->isInterB()? 2:1); ilist++)
    5396   {
    5397     if(pColCU->getSlice()->isInterB())
    5398     {
    5399       eColRefPicList = RefPicList(ilist);
    5400     }
    5401 
    5402     Int iColRefIdx = pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartUnitIdx);
    5403 
    5404     if (iColRefIdx < 0)
    5405     {
    5406       continue;
    5407     }
    5408 
    5409     // The picture pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx) might not be in DPB anymore
    5410     // So don't access it directly.
    5411     iColRefViewIdx = pColCU->getSlice()->getVPS()->getViewOrderIdx( pColCU->getSlice()->getRefLayerId( eColRefPicList, iColRefIdx ) );       
    5412 
    5413 
    5414     if ( iColViewIdx    == iColRefViewIdx ) // temporal vector
    5415     {
    5416       continue;
    5417     }
    5418     else
    5419     {
    5420       if(getPic()->isTempIVRefValid(currCandPic, ilist,  iColRefIdx))
    5421       {
    5422         rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartUnitIdx);
    5423         rcMv.setIDVFlag(0);
    5424         iTargetViewIdx  = iColRefViewIdx ;
    5425         iStartViewIdx   = iColViewIdx   ;
    5426         return true;   
    5427       }
    5428     }
    5429   }
    5430 
    5431   return false;
    5432 }
    5433 #endif
    5434 #if  NH_3D_FAST_TEXTURE_ENCODING
    5435 Void
    5436 TComDataCU::getIVNStatus       ( UInt uiPartIdx,  DisInfo* pDInfo, Bool& bIVFMerge, Int& iIVFMaxD)
    5437 {
    5438   TComSlice*    pcSlice         = getSlice (); 
    5439   Int iViewIndex = pDInfo->m_aVIdxCan;
    5440   //--- get base CU/PU and check prediction mode ---
    5441   TComPic*    pcBasePic   = pcSlice->getIvPic( false, iViewIndex );
    5442   TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
    5443 
    5444   UInt          uiPartAddr;
    5445   Int           iWidth;
    5446   Int           iHeight;
    5447   getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight );
    5448 
    5449   Int  iCurrPosX, iCurrPosY;
    5450   pcBaseRec->getTopLeftSamplePos( this->getCtuRsAddr(), this->getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY );
    5451 
    5452   iCurrPosX  += ( ( iWidth  - 1 ) >> 1 );
    5453   iCurrPosY  += ( ( iHeight - 1 ) >> 1 );
    5454 
    5455   Bool depthRefineFlag = false;
    5456 #if NH_3D_NBDV_REF
    5457   depthRefineFlag = m_pcSlice->getDepthRefinementFlag( );
    5458 #endif // NH_3D_NBDV_REF
    5459 
    5460   TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
    5461   if( depthRefineFlag )
    5462   {
    5463     cDv.setVer(0);
    5464   }
    5465 
    5466   Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
    5467   Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 ));
    5468   Int         iBaseLPosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX - (iWidth >> 1) + ( (cDv.getHor() + 2 ) >> 2 ) );
    5469   Int         iBaseLPosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 ));
    5470   Int         iBaseRPosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + (iWidth >> 1) + 1 + ( (cDv.getHor() + 2 ) >> 2 ) );
    5471   Int         iBaseRPosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 ));
    5472   Int         iBaseUPosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
    5473   Int         iBaseUPosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY - (iHeight >> 1) + ( (cDv.getVer() + 2 ) >> 2 ));
    5474   Int         iBaseDPosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
    5475   Int         iBaseDPosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + (iHeight >> 1) + 1 + ( (cDv.getVer() + 2 ) >> 2 ));
    5476 
    5477   Int         iBaseCUAddr;
    5478   Int         iBaseAbsPartIdx;
    5479   Int         iBaseLCUAddr;
    5480   Int         iBaseLAbsPartIdx;
    5481   Int         iBaseRCUAddr;
    5482   Int         iBaseRAbsPartIdx;
    5483   Int         iBaseUCUAddr;
    5484   Int         iBaseUAbsPartIdx;
    5485   Int         iBaseDCUAddr;
    5486   Int         iBaseDAbsPartIdx;
    5487   pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
    5488   pcBaseRec->getCUAddrAndPartIdx( iBaseLPosX , iBaseLPosY , iBaseLCUAddr, iBaseLAbsPartIdx );
    5489   pcBaseRec->getCUAddrAndPartIdx( iBaseRPosX , iBaseRPosY , iBaseRCUAddr, iBaseRAbsPartIdx );
    5490   pcBaseRec->getCUAddrAndPartIdx( iBaseUPosX , iBaseUPosY , iBaseUCUAddr, iBaseUAbsPartIdx );
    5491   pcBaseRec->getCUAddrAndPartIdx( iBaseDPosX , iBaseDPosY , iBaseDCUAddr, iBaseDAbsPartIdx );
    5492   TComDataCU* pcBaseCU     = pcBasePic->getCtu( iBaseCUAddr );
    5493   TComDataCU* pcBaseLCU    = pcBasePic->getCtu( iBaseLCUAddr );
    5494   TComDataCU* pcBaseRCU    = pcBasePic->getCtu( iBaseRCUAddr );
    5495   TComDataCU* pcBaseUCU    = pcBasePic->getCtu( iBaseUCUAddr );
    5496   TComDataCU* pcBaseDCU    = pcBasePic->getCtu( iBaseDCUAddr );
    5497   bIVFMerge = pcBaseLCU->getMergeFlag( iBaseLAbsPartIdx ) && pcBaseCU->getMergeFlag( iBaseAbsPartIdx ) && pcBaseRCU->getMergeFlag( iBaseRAbsPartIdx ) && pcBaseUCU->getMergeFlag( iBaseUAbsPartIdx ) && pcBaseDCU->getMergeFlag( iBaseDAbsPartIdx );
    5498   Int aiDepthL[5]; //depth level
    5499   aiDepthL[0] = pcBaseCU->getDepth(iBaseAbsPartIdx);
    5500   aiDepthL[1] = pcBaseLCU->getDepth(iBaseLAbsPartIdx);
    5501   aiDepthL[2] = pcBaseRCU->getDepth(iBaseRAbsPartIdx);
    5502   aiDepthL[3] = pcBaseUCU->getDepth(iBaseUAbsPartIdx);
    5503   aiDepthL[4] = pcBaseDCU->getDepth(iBaseDAbsPartIdx);
    5504   for (Int i = 0; i < 5; i++)
    5505   {
    5506     if (iIVFMaxD < aiDepthL[i])
    5507       iIVFMaxD = aiDepthL[i];
    5508   }
    5509 }
    5510 #endif
    5511 
    5512 #if NH_3D_SPIVMP
    5513 Void TComDataCU::getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight)
    5514 {
    5515   Int iSubPUSize = ( getSlice()->getIsDepth() ? getSlice()->getMpiSubPbSize() : getSlice()->getSubPbSize() );
    5516 
    5517   iNumSPInOneLine = iPUWidth/iSubPUSize;
    5518   Int iNumSPInOneColumn = iPUHeight/iSubPUSize;
    5519   iNumSPInOneLine = (iPUHeight % iSubPUSize != 0 || iPUWidth % iSubPUSize != 0 ) ? 1 : iNumSPInOneLine;
    5520   iNumSPInOneColumn = (iPUHeight % iSubPUSize != 0  || iPUWidth % iSubPUSize != 0 ) ? 1 : iNumSPInOneColumn;
    5521   iNumSP = iNumSPInOneLine * iNumSPInOneColumn;
    5522 
    5523   iSPWidth = iNumSPInOneLine == 1 ? iPUWidth: iSubPUSize;
    5524   iSPHeight = iNumSPInOneColumn == 1 ? iPUHeight: iSubPUSize;
    5525 }
    5526 
    5527 Void TComDataCU::getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr )
    5528 {
    5529   uiBaseAbsPartIdx += m_absZIdxInCtu;
    5530   Int iBasePelX = g_auiRasterToPelX[g_auiZscanToRaster[uiBaseAbsPartIdx]];
    5531   Int iBasePelY = g_auiRasterToPelY[g_auiZscanToRaster[uiBaseAbsPartIdx]];
    5532   Int iCurrPelX = iBasePelX + iPartIdx%iNumPartLine * iWidth;
    5533   Int iCurrPelY = iBasePelY + iPartIdx/iNumPartLine * iHeight;
    5534   Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInCtuWidth() + iCurrPelX/getPic()->getMinCUWidth();
    5535   ruiPartAddr = g_auiRasterToZscan[iCurrRaster];
    5536   ruiPartAddr -= m_absZIdxInCtu; 
    5537 }
    5538 
    5539 Void TComDataCU::setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight )
    5540 {
    5541   uiAbsPartIdx += getZorderIdxInCtu();
    5542   Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]];
    5543   Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]];
    5544   Int iEndPelX = iStartPelX + iWidth;
    5545   Int iEndPelY = iStartPelY + iHeight;
    5546 
    5547   Int iCurrRaster, uiPartAddr;
    5548 
    5549   for (Int i=iStartPelY; i<iEndPelY; i+=getPic()->getMinCUHeight())
    5550   {
    5551     for (Int j=iStartPelX; j < iEndPelX; j += getPic()->getMinCUWidth())
    5552     {
    5553       iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInCtuWidth() + j/getPic()->getMinCUWidth();
    5554       uiPartAddr = g_auiRasterToZscan[iCurrRaster];
    5555       uiPartAddr -= getZorderIdxInCtu(); 
    5556 
    5557       m_puhInterDir[uiPartAddr] = uiDir;
    5558     }
    5559   }
    5560 }
    5561 #endif
    5562 
    5563 #if NH_3D_IV_MERGE
    5564 Bool
    5565 TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc , Bool bIsDepth           
    5566 #if NH_3D_SPIVMP
    5567 , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    5568 #endif
    5569 , Bool bICFlag
    5570 )
    5571 {
    5572   TComSlice*    pcSlice = getSlice (); 
    5573   Int iViewIndex        = pDInfo->m_aVIdxCan;
    5574 
    5575   //--- get base CU/PU and check prediction mode ---
    5576   TComPic*    pcBasePic   = pcSlice->getIvPic( bIsDepth, iViewIndex );
    5577   TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
    5578 
    5579   UInt          uiPartAddr;
    5580   Int           iWidth;
    5581   Int           iHeight;
    5582   getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight );
    5583 
    5584   Int  iCurrPosX, iCurrPosY;
    5585   pcBaseRec->getTopLeftSamplePos( getCtuRsAddr(), getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY );
    5586 
    5587 #if !NH_3D_SPIVMP
    5588   iCurrPosX  += ( iWidth  >> 1 );
    5589   iCurrPosY  += ( iHeight >> 1 );
    5590 #endif
    5591 
    5592   Bool depthRefineFlag = false;
    5593 #if NH_3D_NBDV_REF
    5594   depthRefineFlag = m_pcSlice->getDepthRefinementFlag( );
    5595 #endif // NH_3D_NBDV_REF
    5596 
    5597   TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
    5598   if( depthRefineFlag )
    5599   {
    5600     cDv.setVer(0);
    5601   }
    5602 
    5603   Bool abPdmAvailable[8] =  {false, false, false, false, false, false, false, false};
    5604 #if NH_3D_NBDV
    5605   for( Int i = 0; i < 8; i++)
    5606   {
    5607     pacPdmMv[i].setIDVFlag   (false);
    5608   }
    5609 #endif
    5610 
    5611   if(!bICFlag)
    5612   {
    5613 
    5614 #if NH_3D_SPIVMP
    5615     ////////////////////////////////
    5616     //////////sub-PU IvMC///////////
    5617     ////////////////////////////////
    5618     if(!m_pcSlice->getIsDepth())
    5619     {
    5620 #if NH_3D_DBBP
    5621       if (!getDBBPFlag(0))
    5622 #else
    5623       if (1)
    5624 #endif
    5625       {
    5626         Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    5627         getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    5628 
    5629         for (Int i=0; i<iNumSP; i++)
    5630         {
    5631           puhInterDirSP[i] = 0;
    5632           pcMvFieldSP[2*i].getMv().set(0, 0);
    5633           pcMvFieldSP[2*i+1].getMv().set(0,0);
    5634           pcMvFieldSP[2*i].setRefIdx(-1);
    5635           pcMvFieldSP[2*i+1].setRefIdx(-1);
    5636         }
    5637 
    5638         Int         iBaseCUAddr;
    5639         Int         iBaseAbsPartIdx;
    5640         TComDataCU* pcBaseCU;
    5641         Int iPartition = 0;
    5642 
    5643         Int iDelX = iSPWidth/2;
    5644         Int iDelY = iSPHeight/2;
    5645 
    5646         Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iSPWidth ) >> 1 )  * iSPWidth + ( iSPWidth >> 1 );
    5647         Int         iCenterPosY = iCurrPosY + ( ( iHeight /  iSPHeight ) >> 1 )  * iSPHeight + (iSPHeight >> 1);
    5648         Int         iRefCenterCUAddr, iRefCenterAbsPartIdx;
    5649 
    5650         if(iWidth == iSPWidth && iHeight == iSPHeight)
    5651         {
    5652           iCenterPosX = iCurrPosX + (iWidth >> 1);
    5653           iCenterPosY = iCurrPosY + (iHeight >> 1);
    5654         }
    5655 
    5656         Int iRefCenterPosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
    5657         Int iRefCenterPosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) );
    5658 
    5659         pcBaseRec->getCUAddrAndPartIdx( iRefCenterPosX , iRefCenterPosY , iRefCenterCUAddr, iRefCenterAbsPartIdx );
    5660         TComDataCU* pcDefaultCU    = pcBasePic->getCtu( iRefCenterCUAddr );
    5661         if(!( pcDefaultCU->getPredictionMode( iRefCenterAbsPartIdx ) == MODE_INTRA ))
    5662         {
    5663           for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )       
    5664           {
    5665             RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
    5666             Bool stopLoop = false;
    5667             for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop)
    5668             {
    5669               RefPicList eDefaultRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
    5670               TComMvField cDefaultMvField;
    5671               pcDefaultCU->getMvField( pcDefaultCU, iRefCenterAbsPartIdx, eDefaultRefPicList, cDefaultMvField );
    5672               Int         iDefaultRefIdx     = cDefaultMvField.getRefIdx();
    5673               if (iDefaultRefIdx >= 0)
    5674               {
    5675                 Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eDefaultRefPicList, iDefaultRefIdx);
    5676                 if (iDefaultRefPOC != pcSlice->getPOC())   
    5677                 {
    5678                   for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
    5679                   {
    5680                     if (iDefaultRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
    5681                     {
    5682                       abPdmAvailable[ uiCurrRefListId ] = true;
    5683                       TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer());
    5684 #if NH_3D_NBDV
    5685 #if NH_3D_IV_MERGE
    5686                       if( !bIsDepth )
    5687                       {
    5688 #endif
    5689                         cMv.setIDVFlag   (true);
    5690                         cMv.setIDVHor    (cDv.getHor());                 
    5691                         cMv.setIDVVer    (cDv.getVer()); 
    5692                         cMv.setIDVVId    (iViewIndex);
    5693 #if NH_3D_IV_MERGE
    5694                       }
    5695 #endif
    5696 #endif
    5697                       paiPdmRefIdx  [ uiCurrRefListId ] = iPdmRefIdx;
    5698                       pacPdmMv      [ uiCurrRefListId ] = cMv;
    5699                       stopLoop = true;
    5700                       break;
    5701                     }
    5702                   }
    5703                 }
    5704               }
    5705             }
    5706           }
    5707         }
    5708         availableMcDc[0] = ( abPdmAvailable[0]? 1 : 0) + (abPdmAvailable[1]? 2 : 0);
    5709 
    5710         if(availableMcDc[0])
    5711         {
    5712 
    5713           Int         iBasePosX, iBasePosY;
    5714           for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iSPHeight)
    5715           {
    5716             for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iSPWidth)
    5717             {
    5718               iBasePosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 ));
    5719               iBasePosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 ));
    5720 
    5721               pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY, iBaseCUAddr, iBaseAbsPartIdx );
    5722               pcBaseCU    = pcBasePic->getCtu( iBaseCUAddr );
    5723               if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
    5724               {
    5725                 for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
    5726                 {
    5727                   RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
    5728                   Bool bLoopStop = false;
    5729                   for(Int iLoop = 0; iLoop < 2 && !bLoopStop; ++iLoop)
    5730                   {
    5731                     RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
    5732                     TComMvField cBaseMvField;
    5733                     pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
    5734                     Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
    5735                     if (iBaseRefIdx >= 0)
    5736                     {
    5737                       Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
    5738                       if (iBaseRefPOC != pcSlice->getPOC())   
    5739                       {
    5740                         for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
    5741                         {
    5742                           if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
    5743                           {
    5744                             abPdmAvailable[ uiCurrRefListId ] = true;
    5745                             TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
    5746 
    5747                             if( !bIsDepth )
    5748                             {
    5749                               cMv.setIDVFlag   (true);
    5750                               cMv.setIDVHor    (cDv.getHor());                 
    5751                               cMv.setIDVVer    (cDv.getVer()); 
    5752                               cMv.setIDVVId    (iViewIndex);
    5753                             }
    5754 
    5755                             bLoopStop = true;
    5756 
    5757                             pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iPdmRefIdx);
    5758                             break;
    5759                           }
    5760                         }
    5761                       }
    5762                     }
    5763                   }
    5764                 }
    5765               }
    5766 
    5767               puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0);
    5768               if (puhInterDirSP[iPartition] == 0)
    5769               {
    5770                 puhInterDirSP[iPartition] = availableMcDc[0];
    5771                 pcMvFieldSP[2*iPartition].setMvField(pacPdmMv[0], paiPdmRefIdx[0]);
    5772                 pcMvFieldSP[2*iPartition + 1].setMvField(pacPdmMv[1], paiPdmRefIdx[1]);
    5773 
    5774               }
    5775               iPartition ++;
    5776             }
    5777           }
    5778         }
    5779       }
    5780 
    5781       iCurrPosX  += ( iWidth  >> 1 );
    5782       iCurrPosY  += ( iHeight >> 1 );
    5783     }
    5784 #endif
    5785 
    5786     ////////////////////////////////
    5787     /////// IvMC + IvMCShift ///////
    5788     ////////////////////////////////
    5789 
    5790 #if NH_3D_SPIVMP
    5791     if(m_pcSlice->getIsDepth())
    5792     {
    5793       iCurrPosX  += ( iWidth  >> 1 );
    5794       iCurrPosY  += ( iHeight >> 1 );
    5795     }
    5796 #if NH_3D_DBBP
    5797     for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
    5798 #else
    5799     for(Int iLoopCan = ( m_pcSlice->getIsDepth() ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
    5800 #endif
    5801 #else
    5802     for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    5803 #endif
    5804     {
    5805       // iLoopCan == 0 --> IvMC
    5806       // iLoopCan == 1 --> IvMCShift
    5807 
    5808       Int         iBaseCUAddr;
    5809       Int         iBaseAbsPartIdx;
    5810 
    5811       Int offsetW = (iLoopCan == 0) ? 0 : ( iWidth  * 2);
    5812       Int offsetH = (iLoopCan == 0) ? 0 : ( iHeight * 2);
    5813 
    5814       Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
    5815       Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) );
    5816       pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
    5817 
    5818       TComDataCU* pcBaseCU    = pcBasePic->getCtu( iBaseCUAddr );
    5819       if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
    5820       {
    5821         // Loop reference picture list of current slice (X in spec).
    5822         for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )       
    5823         {
    5824           RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
    5825 
    5826           Bool stopLoop = false;
    5827           // Loop reference picture list of candidate slice (Y in spec)
    5828           for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop)
    5829           {
    5830             RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
    5831             TComMvField cBaseMvField;
    5832             pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
    5833             Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
    5834             if (iBaseRefIdx >= 0)
    5835             {
    5836               Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
    5837               if (iBaseRefPOC != pcSlice->getPOC())   
    5838               {
    5839                 for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
    5840                 {
    5841                   if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
    5842                   {
    5843                     abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true;
    5844                     TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
    5845 #if NH_3D_NBDV
    5846 #if NH_3D_IV_MERGE
    5847                     if( !bIsDepth )
    5848                     {
    5849 #endif
    5850                       cMv.setIDVFlag   (true);
    5851                       cMv.setIDVHor    (cDv.getHor());                 
    5852                       cMv.setIDVVer    (cDv.getVer()); 
    5853                       cMv.setIDVVId    (iViewIndex);
    5854 #if NH_3D_IV_MERGE
    5855                     }
    5856 #endif
    5857 #endif
    5858                     paiPdmRefIdx  [ (uiCurrRefListId + (iLoopCan<<2)) ] = iPdmRefIdx;
    5859                     pacPdmMv      [ (uiCurrRefListId + (iLoopCan<<2)) ] = cMv;
    5860                     stopLoop = true;
    5861                     break;
    5862                   }
    5863                 }
    5864               }
    5865             }
    5866           }
    5867         }
    5868       }
    5869     }
    5870 #if NH_3D_SPIVMP
    5871 #if NH_3D_DBBP
    5872     for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
    5873 #else
    5874     for(Int iLoopCan = ( m_pcSlice->getIsDepth()  ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
    5875 #endif
    5876 #else
    5877     for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    5878 #endif
    5879     {
    5880       availableMcDc[(iLoopCan << 1)] = ( abPdmAvailable[(iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[1 + (iLoopCan<<2)] ? 2 : 0);
    5881     }
    5882 
    5883   }
    5884 
    5885   ////////////////////////////////
    5886   /////// IvDC + IvDCShift ///////
    5887   ////////////////////////////////
    5888 
    5889   if( !getSlice()->getIsDepth() )
    5890   {
    5891     for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ )
    5892     {
    5893       RefPicList  eRefPicListDMV       = RefPicList( iRefListId );
    5894       Int         iNumRefPics       = pcSlice->getNumRefIdx( eRefPicListDMV );
    5895       for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ )
    5896       {
    5897         if(( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC()) && (pcSlice->getRefPic( eRefPicListDMV, iPdmRefIdx )->getViewIndex() == pDInfo->m_aVIdxCan))
    5898         {
    5899           for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    5900           {
    5901             Int ioffsetDV = (iLoopCan == 0) ? 0 : 4;
    5902             abPdmAvailable[ iRefListId + 2 + (iLoopCan<<2) ] = true;
    5903             paiPdmRefIdx  [ iRefListId + 2 + (iLoopCan<<2) ] = iPdmRefIdx;
    5904 #if NH_3D_NBDV_REF
    5905             TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
    5906 #endif
    5907             cMv.setHor( cMv.getHor() + ioffsetDV );
    5908 #if NH_3D_IV_MERGE
    5909             if( bIsDepth )
    5910             {
    5911               cMv.setHor((cMv.getHor()+2)>>2);
    5912             }
    5913 #endif
    5914             cMv.setVer( 0 );
    5915             pacPdmMv      [iRefListId + 2 + (iLoopCan<<2)] = cMv;
    5916           }
    5917           break;
    5918         }
    5919       }
    5920     }
    5921     for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    5922     {
    5923       availableMcDc[1 + (iLoopCan << 1)] = ( abPdmAvailable[2 + (iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[3 + (iLoopCan<<2)] ? 2 : 0 );
    5924     }
    5925   }
    5926   return false;
    5927 }
    5928 #endif
    5929 #if NH_3D_ARP
    5930 Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth )
    5931 {
    5932   setSubPart<UChar>( w, m_puhARPW, uiAbsPartIdx, uiDepth, 0 );
    5933 }
    5934 #endif
    5935 
    5936 #if NH_3D_IC
    5937 Void TComDataCU::setICFlagSubParts( Bool bICFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    5938 {
    5939   memset( m_pbICFlag + uiAbsPartIdx, bICFlag, (m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ))*sizeof(Bool) );
    5940 }
    5941 
    5942 Bool TComDataCU::isICFlagRequired( UInt uiAbsPartIdx )
    5943 {
    5944   UInt uiPartAddr;
    5945   UInt iNumbPart;
    5946 
    5947   if( !( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) )
    5948   {
    5949     return false;
    5950   }
    5951 
    5952   if( getSlice()->getIcSkipParseFlag() )
    5953   {
    5954     if( getMergeFlag( uiAbsPartIdx ) && getMergeIndex( uiAbsPartIdx ) == 0 )
    5955     {
    5956       return false;
    5957     }
    5958   }
    5959 
    5960   if( getMergeFlag( uiAbsPartIdx ) )
    5961   {
    5962     return true;
    5963   }
    5964 
    5965 
    5966   Int iWidth, iHeight;
    5967 
    5968   iNumbPart = ( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ? 1 : ( getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 4 : 2 ) );
    5969 
    5970   for(UInt i = 0; i < iNumbPart; i++)
    5971   {
    5972     getPartIndexAndSize( i, uiPartAddr, iWidth, iHeight, uiAbsPartIdx, true );
    5973     uiPartAddr += uiAbsPartIdx;
    5974 
    5975     for(UInt uiRefIdx = 0; uiRefIdx < 2; uiRefIdx++)
    5976     {
    5977       RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
    5978       Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr);
    5979 
    5980       if( ( getInterDir( uiPartAddr ) & ( uiRefIdx+1 ) ) && iBestRefIdx >= 0 && getSlice()->getViewIndex() != getSlice()->getRefPic( eRefList, iBestRefIdx )->getViewIndex() )
    5981       {
    5982         return true;
    5983       }
    5984     }
    5985   }
    5986 
    5987   return false;
    5988 }
    5989 #endif
    5990 #if NH_3D_DMM
    5991 Void TComDataCU::setDmm1WedgeTabIdxSubParts( UInt tabIdx, UInt uiAbsPartIdx, UInt uiDepth )
    5992 {
    5993   UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1);
    5994   for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmm1WedgeTabIdx[uiAbsPartIdx+ui] = tabIdx; }
    5995 }
    5996 #endif
    5997 
    5998 #if NH_3D_VSP
    5999 Void TComDataCU::setMvFieldPUForVSP( TComDataCU* pcCU, UInt partAddr, Int width, Int height, RefPicList eRefPicList, Int iRefIdx, Int &vspSize )
    6000 {
    6001   // Get depth reference
    6002   Int depthRefViewIdx = pcCU->getDvInfo(partAddr).m_aVIdxCan;
    6003  
    6004 #if H_3D_FCO
    6005   TComPic* pRefPicBaseDepth = 0;
    6006   Bool     bIsCurrDepthCoded = false;
    6007   pRefPicBaseDepth  = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() );
    6008   if ( pRefPicBaseDepth->getPicYuvRec() != NULL  )
    6009   {
    6010     bIsCurrDepthCoded = true;
    6011   }
    6012   else
    6013   {
    6014     pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx );
    6015   }
    6016 #else
    6017   TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx );
    6018 #endif
    6019   assert(pRefPicBaseDepth != NULL);
    6020   TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec();
    6021   assert(pcBaseViewDepthPicYuv != NULL);
    6022   pcBaseViewDepthPicYuv->extendPicBorder();
    6023 
    6024   // Get texture reference
    6025   assert(iRefIdx >= 0);
    6026   TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx );
    6027   TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec();
    6028   assert(pcBaseViewTxtPicYuv != NULL);
    6029 
    6030   // Initialize LUT according to the reference viewIdx
    6031   Int txtRefViewIdx = pRefPicBaseTxt->getViewIndex();
    6032   Int* pShiftLUT    = pcCU->getSlice()->getDepthToDisparityB( txtRefViewIdx );
    6033   assert( txtRefViewIdx < pcCU->getSlice()->getViewIndex() );
    6034 
    6035   // prepare Dv to access depth map or reference view
    6036   TComMv cDv  = pcCU->getDvInfo(partAddr).m_acNBDV;
    6037   pcCU->clipMv(cDv);
    6038 
    6039 #if H_3D_FCO
    6040   if ( bIsCurrDepthCoded )
    6041   {
    6042       cDv.setZero();
    6043   }
    6044 #endif
    6045 
    6046   // fetch virtual depth map & convert depth to motion vector, which are stored in the motion memory
    6047   xSetMvFieldForVSP( pcCU, pcBaseViewDepthPicYuv, &cDv, partAddr, width, height, pShiftLUT, eRefPicList, iRefIdx, pcCU->getSlice()->getIsDepth(), vspSize );
    6048 }
    6049 
    6050 Void TComDataCU::xSetMvFieldForVSP( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, Int *shiftLUT, RefPicList refPicList, Int refIdx, Bool isDepth, Int &vspSize )
    6051 {
    6052   TComCUMvField *cuMvField = cu->getCUMvField( refPicList );
    6053   Int partAddrRasterSubPULine  = g_auiZscanToRaster[ partAddr ];
    6054   Int numPartsLine    = cu->getPic()->getNumPartInCtuWidth();
    6055 
    6056   Int nTxtPerMvInfoX = 4; // cu->getPic()->getMinCUWidth();
    6057   Int nTxtPerMvInfoY = 4; // cu->getPic()->getMinCUHeight();
    6058 
    6059   Int refDepStride = picRefDepth->getStride( COMPONENT_Y );
    6060 
    6061   TComMv tmpMv(0, 0);
    6062   tmpMv.setIDVFlag(false);
    6063 
    6064   Int refDepOffset  = ( (dv->getHor()+2) >> 2 ) + ( (dv->getVer()+2) >> 2 ) * refDepStride;
    6065   Pel *refDepth     = picRefDepth->getAddr( COMPONENT_Y, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refDepOffset;
    6066 
    6067   if ((height % 8))
    6068   {
    6069     vspSize = 1; // 8x4
    6070   }
    6071   else if ((width % 8))
    6072   {
    6073     vspSize = 0; // 4x8
    6074   }
    6075   else
    6076   {
    6077     Bool ULvsBR, URvsBL;
    6078     ULvsBR = refDepth[0]       < refDepth[refDepStride * (height-1) + width-1];
    6079     URvsBL = refDepth[width-1] < refDepth[refDepStride * (height-1)];
    6080     vspSize = ( ULvsBR ^ URvsBL ) ? 0 : 1;
    6081   }
    6082  
    6083   Int subBlockW, subBlockH;
    6084   if (vspSize)
    6085   {
    6086     subBlockW = 8;
    6087     subBlockH = 4;
    6088   }
    6089   else
    6090   {
    6091     subBlockW = 4;
    6092     subBlockH = 8;
    6093   }
    6094  
    6095   Int numPartsInSubPUW = subBlockW / nTxtPerMvInfoX;
    6096   Int numPartsInSubPUH = subBlockH / nTxtPerMvInfoY * numPartsLine;
    6097 
    6098   for( Int y=0; y<height; y+=subBlockH, partAddrRasterSubPULine+=numPartsInSubPUH )
    6099   {
    6100     Pel *refDepthTmp[4];
    6101     refDepthTmp[0] = refDepth + refDepStride * y;
    6102     refDepthTmp[1] = refDepthTmp[0] + subBlockW - 1;
    6103     refDepthTmp[2] = refDepthTmp[0] + refDepStride * (subBlockH - 1);
    6104     refDepthTmp[3] = refDepthTmp[2] + subBlockW - 1;
    6105 
    6106     Int partAddrRasterSubPU = partAddrRasterSubPULine;
    6107     for( Int x=0; x<width; x+=subBlockW, partAddrRasterSubPU+=numPartsInSubPUW )
    6108     {
    6109       Pel  maxDepthVal;
    6110       maxDepthVal = refDepthTmp[0][x];
    6111       maxDepthVal = std::max( maxDepthVal, refDepthTmp[1][x]);
    6112       maxDepthVal = std::max( maxDepthVal, refDepthTmp[2][x]);
    6113       maxDepthVal = std::max( maxDepthVal, refDepthTmp[3][x]);
    6114       tmpMv.setHor( (Short) shiftLUT[ maxDepthVal ] );
    6115 
    6116       Int partAddrRasterPartLine = partAddrRasterSubPU;
    6117       for( Int sY=0; sY<numPartsInSubPUH; sY+=numPartsLine, partAddrRasterPartLine += numPartsLine )
    6118       {
    6119         Int partAddrRasterPart = partAddrRasterPartLine;
    6120         for( Int sX=0; sX<numPartsInSubPUW; sX+=1, partAddrRasterPart++ )
    6121         {
    6122           cuMvField->setMv    ( g_auiRasterToZscan[ partAddrRasterPart ], tmpMv );
    6123           cuMvField->setRefIdx( g_auiRasterToZscan[ partAddrRasterPart ], refIdx );
    6124         }
    6125       }
    6126     }
    6127   }
    6128 
    6129   vspSize = (vspSize<<2)+1;
    6130 
    6131 }
    6132 #endif
     3218
     3219
     3220
     3221
     3222
     3223
    61333224
    61343225//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComDataCU.h

    r1386 r1390  
    5757static const UInt NUM_MOST_PROBABLE_MODES=3;
    5858
    59 #if NH_3D_DBBP
    60 typedef struct _DBBPTmpData
    61 {
    62   TComMv      acMvd[2][2];          // for two segments and two lists
    63   TComMvField acMvField[2][2];      // for two segments and two lists
    64   Int         aiMvpNum[2][2];       // for two segments and two lists
    65   Int         aiMvpIdx[2][2];       // for two segments and two lists
    66   UChar       auhInterDir[2];       // for two segments
    67   Bool        abMergeFlag[2];       // for two segments
    68   UChar       auhMergeIndex[2];     // for two segments
    69   PartSize    eVirtualPartSize;
    70   UInt        uiVirtualPartIndex;
    71 } DbbpTmpData;
    72 #endif
    7359
    7460
     
    10894
    10995  Bool*          m_skipFlag;           ///< array of skip flags
    110 #if NH_3D_DIS
    111   Bool*          m_bDISFlag;         
    112   UChar*         m_ucDISType;
    113 #endif
    11496  SChar*          m_pePartSize;         ///< array of partition sizes
    11597  SChar*        m_pePredMode;                           ///< array of prediction modes
     
    159141  SChar*        m_apiMVPNum[NUM_REF_PIC_LIST_01];       ///< array of number of possible motion vectors predictors
    160142  Bool*         m_pbIPCMFlag;         ///< array of intra_pcm flags
    161 #if NH_3D_NBDV
    162   DisInfo*      m_pDvInfo;
    163 #endif
    164 #if NH_3D_VSP
    165   SChar*        m_piVSPFlag;          ///< array of VSP flags to indicate whehter a block uses VSP or not  ///< 0: non-VSP; 1: VSP
    166 #endif
    167 #if NH_3D_SPIVMP
    168   Bool*         m_pbSPIVMPFlag;       ///< array of sub-PU IVMP flags to indicate whehter a block uses sub-PU IVMP ///< 0: non-SPIVMP; 1: SPIVMP
    169 #endif
    170 #if NH_3D_ARP
    171   UChar*        m_puhARPW;
    172 #endif
    173 #if NH_3D_IC
    174   Bool*         m_pbICFlag;           ///< array of IC flags
    175 #endif
    176 #if NH_3D_DMM
    177   Pel*          m_dmmDeltaDC[NUM_DMM][2];
    178   UInt*         m_dmm1WedgeTabIdx;
    179 #endif
    180 #if NH_3D_SDC_INTRA
    181   Bool*         m_pbSDCFlag;
    182   Pel*          m_apSegmentDCOffset[2];
    183 #endif
    184 #if NH_3D_DBBP
    185   Bool*         m_pbDBBPFlag;        ///< array of DBBP flags
    186   DbbpTmpData   m_sDBBPTmpData;
    187 #endif
    188 #if NH_3D_MLC
    189   Bool          m_bAvailableFlagA1;    ///< A1 available flag
    190   Bool          m_bAvailableFlagB1;    ///< B1 available flag
    191   Bool          m_bAvailableFlagB0;    ///< B0 available flag
    192   Bool          m_bAvailableFlagA0;    ///< A0 available flag
    193   Bool          m_bAvailableFlagB2;    ///< B2 available flag
    194 #endif
    195143
    196144
     
    201149  Bool          m_bDecSubCu;          ///< indicates decoder-mode
    202150  Double        m_dTotalCost;         ///< sum of partition RD costs
    203 #if NH_3D_VSO
    204   Dist          m_uiTotalDistortion;  ///< sum of partition distortion
    205 #else
    206151  Distortion    m_uiTotalDistortion;  ///< sum of partition distortion
    207 #endif
    208152  UInt          m_uiTotalBits;        ///< sum of partition bits
    209153  UInt          m_uiTotalBins;        ///< sum of partition bins
    210154  SChar         m_codedQP;
    211 #if NH_3D_MLC
    212   DisInfo         m_cDefaultDisInfo;    ///< Default disparity information for initializing
    213   TComMotionCand  m_mergCands[MRG_IVSHIFT+1];   ///< Motion candidates for merge mode
    214   Int             m_numSpatialCands;
    215 #endif
    216155
    217156  UChar*        m_explicitRdpcmMode[MAX_NUM_COMPONENT]; ///< Stores the explicit RDPCM mode for all TUs belonging to this CU
     
    223162  Bool          xAddMVPCandWithScaling        ( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const;
    224163
    225 #if NH_3D_VSP
    226   Bool          xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount);
    227 #endif
    228 #if NH_3D_IV_MERGE
    229   Bool          xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int*   ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx );
    230 #endif
    231164
    232165  Void          deriveRightBottomIdx          ( UInt uiPartIdx, UInt& ruiPartIdxRB ) const;
    233166
    234 #if NH_3D_TMVP
    235   Bool          xGetColMVP                    ( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, Int& refIdx, Bool bMRG = true  ) const;
    236 #else
    237167  Bool          xGetColMVP                    ( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, const Int refIdx ) const;
    238 #endif
    239168
    240169  /// compute scaling factor from POC difference
    241 #if !NH_3D_ARP
    242170  static Int    xGetDistScaleFactor           ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
    243 #endif
    244171  Void          xDeriveCenterIdx              ( UInt uiPartIdx, UInt& ruiPartIdxCenter ) const;
    245172
    246 #if NH_3D_VSP
    247   Void xSetMvFieldForVSP  ( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, Int *shiftLUT, RefPicList refPicList, Int refIdx, Bool isDepth, Int &vspSize );
    248 #endif
    249173
    250174public:
    251175
    252 #if NH_3D_ARP
    253   static Int    xGetDistScaleFactor           ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
    254 #endif
    255176
    256177  TComDataCU();
     
    271192  Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
    272193  Void          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );
    273 #if NH_3D_NBDV
    274   Void          copyDVInfoFrom        (TComDataCU* pcCU, UInt uiAbsPartIdx);
    275 #endif
    276194
    277195  Void          copySubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx );
    278 #if NH_3D_NBDV
    279     Void          copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, Bool bNBDV = false );
    280 #else
    281196  Void          copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList );
    282 #endif
    283197  Void          copyPartFrom          ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
    284198
     
    304218
    305219  Void          setDepthSubParts      ( UInt uiDepth, UInt uiAbsPartIdx );
    306 #if NH_3D_VSO
    307   Void          getPosInPic           ( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) const;
    308 #endif
    309 
    310 #if NH_3D_ARP
    311   Void          setSlice              ( TComSlice* pcSlice)     { m_pcSlice = pcSlice;       }
    312   Void          setPic                ( TComDataCU* pcCU  )     { m_pcPic              = pcCU->getPic(); }
    313 #endif
     220
    314221  // -------------------------------------------------------------------------------------------------------------------
    315222  // member functions for CU data
     
    322229  Void          setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth );
    323230
    324 #if NH_3D_DBBP
    325   Pel*          getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride);
    326 #endif
    327231 
    328232  Bool*         getSkipFlag            ()                        { return m_skipFlag;          }
     
    330234  Void          setSkipFlag           ( UInt idx, Bool skip)     { m_skipFlag[idx] = skip;   }
    331235  Void          setSkipFlagSubParts   ( Bool skip, UInt absPartIdx, UInt depth );
    332 #if NH_3D_DIS
    333   Bool*        getDISFlag            ()                         { return m_bDISFlag;          }
    334   Bool         getDISFlag            ( UInt idx)                { return m_bDISFlag[idx];     }
    335   Void         setDISFlag            ( UInt idx, Bool bDIS)     { m_bDISFlag[idx] = bDIS;   }
    336   Void         setDISFlagSubParts    ( Bool bDIS, UInt uiAbsPartIdx, UInt uiDepth );
    337 
    338   UChar*       getDISType            ()                         { return m_ucDISType; }
    339   UChar        getDISType            ( UInt idx)                { return m_ucDISType[idx];     }
    340   Void         getDISType            ( UInt idx, UChar ucDISType)     { m_ucDISType[idx] = ucDISType;   }
    341   Void         setDISTypeSubParts    ( UChar ucDISType, UInt uiAbsPartIdx, UInt uiDepth );
    342 #endif
    343236  SChar*        getPredictionMode             ( )                                                          { return m_pePredMode;                       }
    344237  PredMode      getPredictionMode             ( UInt uiIdx ) const                                         { return static_cast<PredMode>( m_pePredMode[uiIdx] ); }
     
    346239  Void          setPredModeSubParts   ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth );
    347240
    348 #if NH_3D_DBBP
    349   Bool*         getDBBPFlag           ()                        const { return m_pbDBBPFlag;               }
    350   Bool          getDBBPFlag           ( UInt uiIdx )            const { return m_pbDBBPFlag[uiIdx];        }
    351   Void          setDBBPFlag           ( UInt uiIdx, Bool b )    { m_pbDBBPFlag[uiIdx] = b;           }
    352   Void          setDBBPFlagSubParts   ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    353   DbbpTmpData*  getDBBPTmpData        () { return &m_sDBBPTmpData; }
    354 #endif
    355241
    356242  SChar*        getCrossComponentPredictionAlpha( ComponentID compID )                                     { return m_crossComponentPredictionAlpha[compID];        }
     
    448334  template <typename T>
    449335  Void          setSubPart            ( T bParameter, T* pbBaseCtu, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
    450 #if H_3D_VSP || NH_3D_DBBP
    451   template<typename T>
    452   Void          setSubPartT           ( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
    453 #endif
    454336
    455337#if AMP_MRG
     
    474356  Void          setIPCMFlag           (UInt uiIdx, Bool b )     { m_pbIPCMFlag[uiIdx] = b;           }
    475357  Void          setIPCMFlagSubParts   (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth);
    476 #if NH_3D_NBDV
    477   Void          setDvInfoSubParts     ( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth );
    478 #if H_3D_VSP || NH_3D_DBBP
    479   Void          setDvInfoSubParts     ( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth);
    480 #endif
    481   DisInfo*      getDvInfo             ()                        { return m_pDvInfo;                 }
    482   DisInfo       getDvInfo             (UInt uiIdx)              { return m_pDvInfo[uiIdx];          }
    483 #endif
    484 #if NH_3D_NBDV
    485   Void          xDeriveRightBottomNbIdx(Int &uiLCUIdxRBNb, Int &uiPartIdxRBNb );
    486   Bool          xCheckSpatialNBDV (const TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paMvpDvInfo,
    487                                    UInt uiMvpDvPos
    488 #if NH_3D_NBDV_REF
    489   , Bool bDepthRefine = false
    490 #endif
    491   );
    492   Bool          xGetColDisMV      ( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
    493   Void          getDisMvpCandNBDV ( DisInfo* pDInfo
    494 #if NH_3D_NBDV_REF
    495    , Bool bDepthRefine = false
    496 #endif
    497    );
    498    
    499 #if NH_3D_IV_MERGE
    500   Void          getDispforDepth  ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* cDisp);
    501 #endif
    502 
    503 #if NH_3D_NBDV_REF
    504   Pel           getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT );
    505   Void          estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred );
    506 #endif //NH_3D_NBDV_REF
    507 #endif
    508 #if NH_3D_DIS
    509    Bool          getNeighDepth (UInt uiPartIdx, UInt uiPartAddr, Pel* pNeighDepth, Int index);
    510 #endif
    511 #if  NH_3D_FAST_TEXTURE_ENCODING
    512   Void          getIVNStatus       ( UInt uiPartIdx,  DisInfo* pDInfo, Bool& bIVFMerge,  Int& iIVFMaxD);
    513 #endif
    514 #if NH_3D_SPIVMP
    515   Void          getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight);
    516   Void          getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr );
    517   Void          setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight );
    518 #endif
    519 #if NH_3D_IV_MERGE
    520   Bool          getInterViewMergeCands          ( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc, Bool bIsDepth           
    521 
    522 #if NH_3D_SPIVMP
    523     , TComMvField* pcMFieldSP, UChar* puhInterDirSP
    524 #endif   
    525     , Bool bICFlag
    526     );   
    527 #endif
    528 #if NH_3D_ARP
    529   UChar*        getARPW            ()              const          { return m_puhARPW;               }
    530   UChar         getARPW            ( UInt uiIdx )  const          { return m_puhARPW[uiIdx];        }
    531   Void          setARPW            ( UInt uiIdx, UChar w )   { m_puhARPW[uiIdx] = w;           }
    532   Void          setARPWSubParts    ( UChar w, UInt uiAbsPartIdx, UInt uiDepth );
    533 #endif
    534 #if NH_3D_IC
    535   Bool*         getICFlag          ()                        { return m_pbICFlag;               }
    536   Bool          getICFlag          ( UInt uiIdx )            { return m_pbICFlag[uiIdx];        }
    537   Void          setICFlag          ( UInt uiIdx, Bool  uh )  { m_pbICFlag[uiIdx] = uh;          }
    538   Void          setICFlagSubParts  ( Bool bICFlag,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    539   Bool          isICFlagRequired   ( UInt uiAbsPartIdx );
    540   Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false) const;
    541 #elif NH_3D_VSP
    542   Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false) const;
    543 #else
    544358  // -------------------------------------------------------------------------------------------------------------------
    545359  // member functions for accessing partition information
     
    547361
    548362  Void          getPartIndexAndSize           ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) const; // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx
    549 #endif
    550363  UChar         getNumPartitions              ( const UInt uiAbsPartIdx = 0 ) const;
    551364  Bool          isFirstAbsZorderIdxInDepth    ( UInt uiAbsPartIdx, UInt uiDepth ) const;
    552365
    553 #if NH_3D_DMM
    554   Pel*  getDmmDeltaDC                 ( DmmID dmmType, UInt segId )                      { return m_dmmDeltaDC[dmmType][segId];        }
    555   Pel   getDmmDeltaDC                 ( DmmID dmmType, UInt segId, UInt uiIdx )          { return m_dmmDeltaDC[dmmType][segId][uiIdx]; }
    556   Void  setDmmDeltaDC                 ( DmmID dmmType, UInt segId, UInt uiIdx, Pel val ) { m_dmmDeltaDC[dmmType][segId][uiIdx] = val;  }
    557 
    558   UInt* getDmm1WedgeTabIdx            ()                                                { return m_dmm1WedgeTabIdx;          }       
    559   UInt  getDmm1WedgeTabIdx            ( UInt uiIdx )                                    { return m_dmm1WedgeTabIdx[uiIdx];   }
    560   Void  setDmm1WedgeTabIdx            ( UInt uiIdx, UInt tabIdx )                       { m_dmm1WedgeTabIdx[uiIdx] = tabIdx; }
    561   Void  setDmm1WedgeTabIdxSubParts    ( UInt tabIdx, UInt uiAbsPartIdx, UInt uiDepth );
    562 #endif
    563 #if NH_3D_SDC_INTRA
    564   Bool*         getSDCFlag          ()                        { return m_pbSDCFlag;               }
    565   Bool          getSDCFlag          ( UInt uiIdx )            { return m_pbSDCFlag[uiIdx];        }
    566   Void          setSDCFlagSubParts  ( Bool bSDCFlag, UInt uiAbsPartIdx, UInt uiDepth );
    567  
    568   Bool          getSDCAvailable             ( UInt uiAbsPartIdx );
    569  
    570   Pel*          getSDCSegmentDCOffset( UInt uiSeg ) { return m_apSegmentDCOffset[uiSeg]; }
    571   Pel           getSDCSegmentDCOffset( UInt uiSeg, UInt uiPartIdx ) { return m_apSegmentDCOffset[uiSeg][uiPartIdx]; }
    572   Void          setSDCSegmentDCOffset( Pel pOffset, UInt uiSeg, UInt uiPartIdx) { m_apSegmentDCOffset[uiSeg][uiPartIdx] = pOffset; }
    573 #endif
    574366 
    575367  // -------------------------------------------------------------------------------------------------------------------
     
    602394  Void          getMvPredAbove                ( TComMv&     rcMvPred ) const                               { rcMvPred = m_cMvFieldB.getMv();            }
    603395  Void          getMvPredAboveRight           ( TComMv&     rcMvPred ) const                               { rcMvPred = m_cMvFieldC.getMv();            }
    604 #if NH_3D
    605   Void          compressMV            ( Int scale );
    606   Void          printMV               ( );
    607 #else           
    608396  Void          compressMV            ();
    609 #endif 
    610397  // -------------------------------------------------------------------------------------------------------------------
    611398  // utility functions for neighbouring information
     
    650437  Void          deriveLeftBottomIdx           ( UInt uiPartIdx, UInt& ruiPartIdxLB ) const;
    651438
    652 #if NH_3D
    653   Bool          hasEqualMotion              ( Int dirA, const TComMvField* mvFieldA,  Int dirB, const TComMvField* mvFieldB  );
    654 #endif
    655439  Bool          hasEqualMotion                ( UInt uiAbsPartIdx, const TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) const;
    656440
    657 #if NH_3D_MLC
    658   Bool          getAvailableFlagA1() { return m_bAvailableFlagA1;   }
    659   Bool          getAvailableFlagB1() { return m_bAvailableFlagB1;   }
    660   Bool          getAvailableFlagB0() { return m_bAvailableFlagB0;   }
    661   Bool          getAvailableFlagA0() { return m_bAvailableFlagA0;   }
    662   Bool          getAvailableFlagB2() { return m_bAvailableFlagB2;   }
    663   Void          initAvailableFlags() { m_bAvailableFlagA1 = m_bAvailableFlagB1 = m_bAvailableFlagB0 = m_bAvailableFlagA0 = m_bAvailableFlagB2 = 0;  }
    664   Void          buildMCL(TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
    665 #if NH_3D_VSP
    666     , Int* vspFlag
    667 #endif
    668 #if NH_3D_SPIVMP
    669     , Bool* pbSPIVMPFlag
    670 #endif
    671     , Int& numValidMergeCand
    672     );
    673   Void          xGetInterMergeCandidates      ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
    674 #if NH_3D_SPIVMP
    675   , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    676 #endif
    677   , Int& numValidMergeCand, Int mrgCandIdx = -1 );
    678 #endif
    679 #if NH_3D
    680   Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 );
    681 #else
    682441  Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 ) const;
    683 #endif
    684 
    685 #if NH_3D_VSP
    686 #if NH_3D_SPIVMP
    687   Bool*         getSPIVMPFlag        ()                        const { return m_pbSPIVMPFlag;          }
    688   Bool          getSPIVMPFlag        ( UInt uiIdx )            const { return m_pbSPIVMPFlag[uiIdx];   }
    689   Void          setSPIVMPFlag        ( UInt uiIdx, Bool n )     { m_pbSPIVMPFlag[uiIdx] = n;      }
    690   Void          setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    691 #endif
    692 
    693   SChar*        getVSPFlag        ()                        const { return m_piVSPFlag;          }
    694   SChar         getVSPFlag        ( UInt uiIdx )            const { return m_piVSPFlag[uiIdx];   }
    695   Void          setVSPFlag        ( UInt uiIdx, Int n )     { m_piVSPFlag[uiIdx] = n;      }
    696   Void          setVSPFlagSubParts( SChar iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    697   Void          setMvFieldPUForVSP    ( TComDataCU* cu, UInt partAddr, Int width, Int height, RefPicList refPicList, Int refIdx, Int &vspSize );
    698 #endif
     442
    699443  Void          deriveLeftRightTopIdxGeneral  ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const;
    700444  Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) const;
     
    726470  UInt          getCtxSkipFlag                ( UInt   uiAbsPartIdx ) const;
    727471  UInt          getCtxInterDir                ( UInt   uiAbsPartIdx ) const;
    728 #if NH_3D_ARP
    729   UInt          getCTXARPWFlag                  ( UInt   uiAbsPartIdx                                 );
    730 #endif 
    731472
    732473  UInt&         getTotalBins            ()                            { return m_uiTotalBins;                              }
     
    736477
    737478  Double&       getTotalCost()                  { return m_dTotalCost;        }
    738 #if NH_3D_VSO
    739   Dist&         getTotalDistortion()            { return m_uiTotalDistortion; }
    740 #else
    741479  Distortion&   getTotalDistortion()            { return m_uiTotalDistortion; }
    742 #endif
    743480  UInt&         getTotalBits()                  { return m_uiTotalBits;       }
    744481  UInt&         getTotalNumPart()               { return m_uiNumPartition;    }
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComInterpolationFilter.cpp

    r1386 r1390  
    7575};
    7676
    77 #if NH_3D_ARP
    78 const Short TComInterpolationFilter::m_lumaFilterARP[4][NTAPS_LUMA_ARP] =
    79 {
    80   {64,  0},
    81   {48, 16},
    82   {32, 32},
    83   {16, 48}
    84 };
    85 const Short TComInterpolationFilter::m_chromaFilterARP[8][NTAPS_CHROMA_ARP] =
    86 {
    87   {64,  0},
    88   {56,  8},
    89   {48, 16},
    90   {40, 24},
    91   {32, 32},
    92   {24, 40},
    93   {16, 48},
    94   {8,  56}
    95 };
    96 #endif
    9777
    9878// ====================================================================================================================
     
    360340 * \param  bitDepth   Bit depth
    361341 */
    362 #if NH_3D_ARP
    363 Void TComInterpolationFilter::filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast, const ChromaFormat fmt, const Int bitDepth, Bool filterType )
    364 #else
    365342Void TComInterpolationFilter::filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast, const ChromaFormat fmt, const Int bitDepth )
    366 #endif
    367343
    368344{
     
    374350  {
    375351    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
    376 #if NH_3D_ARP
    377     if(filterType)
    378     {
    379       filterHor<NTAPS_LUMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilterARP[frac]);
    380     }
    381     else
    382     {
    383 #endif
    384352    filterHor<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
    385 #if NH_3D_ARP
    386     }
    387 #endif
    388353
    389354  }
     
    392357    const UInt csx = getComponentScaleX(compID, fmt);
    393358    assert(frac >=0 && csx<2 && (frac<<(1-csx)) < CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
    394 #if NH_3D_ARP
    395     if(filterType)
    396     {
    397       filterHor<NTAPS_CHROMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilterARP[frac]);
    398     }
    399     else
    400     {
    401 #endif
    402359    filterHor<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac<<(1-csx)]);
    403 #if NH_3D_ARP
    404     }
    405 #endif
    406360  }
    407361}
     
    424378 * \param  bitDepth   Bit depth
    425379 */
    426 #if NH_3D_ARP
    427 Void TComInterpolationFilter::filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth, Bool filterType )
    428 #else
    429380Void TComInterpolationFilter::filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth )
    430 #endif
    431381{
    432382  if ( frac == 0 )
     
    437387  {
    438388    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
    439 #if NH_3D_ARP
    440     if(filterType)
    441     {
    442       filterVer<NTAPS_LUMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilterARP[frac]);   
    443     }
    444     else
    445     {
    446 #endif
    447389    filterVer<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilter[frac]);
    448 #if NH_3D_ARP
    449     }
    450 #endif
    451390
    452391  }
     
    455394    const UInt csy = getComponentScaleY(compID, fmt);
    456395    assert(frac >=0 && csy<2 && (frac<<(1-csy)) < CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
    457 #if NH_3D_ARP
    458     if(filterType)
    459     {
    460       filterVer<NTAPS_CHROMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilterARP[frac]);   
    461     }
    462     else
    463     {
    464 #endif
    465396    filterVer<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac<<(1-csy)]);
    466 #if NH_3D_ARP
    467     }
    468 #endif
    469397    }
    470398    }
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComInterpolationFilter.h

    r1386 r1390  
    4545//! \{
    4646
    47 #if NH_3D_ARP
    48 #define NTAPS_LUMA_ARP    2 ///< Number of taps for luma
    49 #define NTAPS_CHROMA_ARP  2 ///< Number of taps for chroma
    50 #endif
    5147
    5248#define NTAPS_LUMA        8 ///< Number of taps for luma
     
    6359  static const TFilterCoeff m_lumaFilter[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA];     ///< Luma filter taps
    6460  static const TFilterCoeff m_chromaFilter[CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_CHROMA]; ///< Chroma filter taps
    65 #if NH_3D_ARP
    66   static const Short m_lumaFilterARP  [4][NTAPS_LUMA_ARP];     ///< Luma filter taps for ARP
    67   static const Short m_chromaFilterARP[8][NTAPS_CHROMA_ARP];   ///< Chroma filter taps for ARP
    68 #endif
    6961
    7062  static Void filterCopy(Int bitDepth, const Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Bool isFirst, Bool isLast);
     
    8274  ~TComInterpolationFilter() {}
    8375
    84 #if NH_3D_ARP
    85   Void filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast, const ChromaFormat fmt, const Int bitDepth , Bool filterType = false );
    86 #else
    8776  Void filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast, const ChromaFormat fmt, const Int bitDepth );
    88 #endif
    8977
    90 #if NH_3D_ARP
    91   Void filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac,               Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth , Bool filterType = false );
    92 #else
    9378  Void filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac,               Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth );
    94 #endif
    9579};
    9680
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComMotionInfo.cpp

    r1386 r1390  
    4040#include "assert.h"
    4141#include <stdlib.h>
    42 #if NH_3D_SPIVMP
    43 #include "TComDataCU.h"
    44 #include "TComPic.h"
    45 #endif
    4642#if NH_MV
    4743#include <iomanip>
     
    330326}
    331327
    332 #if NH_3D_SPIVMP
    333 Void TComCUMvField::setMvFieldSP( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  )
    334 {
    335   uiAbsPartIdx += pcCU->getZorderIdxInCtu();
    336   Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]];
    337   Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]];
    338   Int iEndPelX = iStartPelX + iWidth;
    339   Int iEndPelY = iStartPelY + iHeight; 
    340 
    341   for (Int i=iStartPelY; i<iEndPelY; i+=pcCU->getPic()->getMinCUHeight())
    342   {
    343     for (Int j=iStartPelX; j < iEndPelX; j += pcCU->getPic()->getMinCUWidth())
    344     {
    345       Int iCurrRaster = i / pcCU->getPic()->getMinCUHeight() * pcCU->getPic()->getNumPartInCtuWidth() + j/pcCU->getPic()->getMinCUWidth();
    346       Int uiPartAddr = g_auiRasterToZscan[iCurrRaster];
    347       uiPartAddr -= pcCU->getZorderIdxInCtu(); 
    348 
    349       m_pcMv[uiPartAddr] = cMvField.getMv();
    350       m_piRefIdx[uiPartAddr] = cMvField.getRefIdx();
    351     }
    352   }
    353 }
    354 #endif
    355328
    356329/**Subsampling of the stored prediction mode, reference index and motion vector
     
    405378}
    406379
    407 #if NH_3D_MLC
    408 Void TComMotionCand::print( Int i )
    409 {
    410   if (i == 0  )
    411   {
    412 
    413     std::cout << std::setfill(' ')                          << std::setw( 15 )
    414       << "Num"                                              << std::setw( 15 )
    415       << "Avai"                                             << std::setw( 15 )
    416       << "Dir "                                             << std::setw( 15 )
    417       <<  "L0 RefIdx"                                       << std::setw( 15 )
    418       <<  "L0 Hor"                                          << std::setw( 15 )
    419       <<  "L0 Ver"                                          << std::setw( 15 )
    420       <<  "L1 RefIdx"                                       << std::setw( 15 )
    421       <<  "L1 Hor"                                          << std::setw( 15 )
    422       <<  "L1 Ver"                                          << std::setw( 15 )
    423       << "VspFlag"                                          << std::setw( 15 )
    424       << "SPIVMPFlag"                                       
    425       << std::endl;
    426   }
    427 
    428   std::cout << std::setfill(' ')                                  << std::setw( 15 )
    429     << i                                                          << std::setw( 15 )
    430     << m_bAvailable                                               << std::setw( 15 )
    431     << (UInt) m_uDir                                              << std::setw( 15 )
    432     << ((m_uDir & 1) ? m_cMvField[0].getRefIdx()       : MIN_INT) << std::setw( 15 )
    433     << ((m_uDir & 1) ? m_cMvField[0].getMv().getHor()  : MIN_INT) << std::setw( 15 )
    434     << ((m_uDir & 1) ? m_cMvField[0].getMv().getVer()  : MIN_INT) << std::setw( 15 )
    435     << ((m_uDir & 2) ? m_cMvField[1].getRefIdx()       : MIN_INT) << std::setw( 15 )
    436     << ((m_uDir & 2) ? m_cMvField[1].getMv().getHor()  : MIN_INT) << std::setw( 15 )
    437     << ((m_uDir & 2) ? m_cMvField[1].getMv().getVer()  : MIN_INT) << std::setw( 15 )
    438     << m_iVspFlag                                                 << std::setw( 15 )
    439     << m_bSPIVMPFlag                                              << std::setw( 15 )
    440     << std::endl;
    441 }
    442 #endif
    443380#endif
    444381//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComMotionInfo.h

    r1386 r1390  
    5151// ====================================================================================================================
    5252
    53 #if NH_3D_SPIVMP
    54 class TComDataCU;
    55 #endif
    5653/// parameters for AMVP
    5754typedef struct _AMVPInfo
     
    6158} AMVPInfo;
    6259
    63 #if NH_3D_NBDV
    64 typedef struct _DisCand
    65 {
    66   TComMv m_acNBDV;              // DV from NBDV
    67 #if NH_3D_NBDV_REF
    68   TComMv m_acDoNBDV;            // DV from DoNBDV
    69 #endif 
    70   Int    m_aVIdxCan;            // View order index (the same with the NBDV and the DoNBDV)
    71 } DisInfo;
    72 
    73 typedef struct _IDVCand // IDV
    74 {
    75   TComMv m_acMvCand[2][ IDV_CANDS ];           
    76   Int    m_aVIdxCan[2][ IDV_CANDS ];           
    77   Bool   m_bAvailab[2][ IDV_CANDS ];
    78   Bool   m_bFound;                               
    79 } IDVInfo;
    80 #endif
    8160
    8261// ====================================================================================================================
     
    10887  Int getHor   () const { return  m_acMv.getHor(); }
    10988  Int getVer   () const { return  m_acMv.getVer(); }
    110 #if NH_3D_IV_MERGE
    111   Bool operator== ( const TComMvField& rcMv ) const
    112   {
    113     return (m_acMv.getHor()==rcMv.getHor() && m_acMv.getVer()==rcMv.getVer() && m_iRefIdx == rcMv.getRefIdx());
    114   }
    115 #endif
    11689};
    11790
     
    168141  Void    setAllRefIdx ( Int iRefIdx,                 PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
    169142  Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
    170 #if NH_3D_SPIVMP
    171   Void    setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  );
    172 #endif
    173 #if NH_3D_VSP
    174   Void    setMv         ( Int iIdx, TComMv const & rcMv ) { m_pcMv[iIdx] = rcMv; }
    175   Void    setRefIdx     ( Int iIdx, Int iRefIdx )         { m_piRefIdx[iIdx] = iRefIdx; }
    176 #endif
    177143
    178144  Void setNumPartition( Int iNumPart )
     
    196162//! \}
    197163
    198 #if NH_3D_MLC
    199 /// class for container of merge candidate
    200 class TComMotionCand
    201 {
    202 public:
    203   Bool                  m_bAvailable;
    204   TComMvField           m_cMvField[2];
    205   UChar                 m_uDir;
    206 #if NH_3D_VSP
    207   Int                   m_iVspFlag;
    208 #endif
    209 #if NH_3D_SPIVMP
    210   Bool                  m_bSPIVMPFlag;
    211 #endif
    212 
    213 public:
    214   TComMotionCand()
    215   {
    216     m_bAvailable = false;
    217     m_uDir = 0;
    218 #if NH_3D_VSP
    219     m_iVspFlag = 0;
    220 #endif
    221 #if NH_3D_SPIVMP
    222     m_bSPIVMPFlag = false;
    223 #endif
    224   }
    225 
    226   ~TComMotionCand()
    227   {
    228 
    229   }
    230 
    231   Void init()
    232   {
    233     TComMv cZeroMv;
    234 
    235     m_bAvailable = false;
    236     m_uDir = 0;
    237 #if NH_3D_VSP
    238     m_iVspFlag = 0;
    239 #endif
    240 #if NH_3D_SPIVMP
    241     m_bSPIVMPFlag = false;
    242 #endif
    243     m_cMvField[0].setMvField(cZeroMv, NOT_VALID);
    244     m_cMvField[1].setMvField(cZeroMv, NOT_VALID);
    245   }
    246 
    247   Void setCand(TComMvField* pcMvFieldNeighbours, UChar uhInterDirNeighbours
    248 #if NH_3D_VSP
    249     , Int vspFlag
    250 #endif
    251 #if NH_3D_SPIVMP
    252     , Bool bSPIVMPFlag
    253 #endif
    254     )
    255   {
    256     m_bAvailable = true;
    257     m_cMvField[0] = pcMvFieldNeighbours[0];
    258     m_cMvField[1] = pcMvFieldNeighbours[1];
    259     m_uDir = uhInterDirNeighbours;
    260 #if NH_3D_VSP
    261     m_iVspFlag = vspFlag;
    262 #endif
    263 #if NH_3D_SPIVMP
    264     m_bSPIVMPFlag = bSPIVMPFlag;
    265 #endif
    266   }
    267  
    268   Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    269 #if NH_3D_VSP
    270     , Int* vspFlag
    271 #endif
    272 #if NH_3D_SPIVMP
    273     , Bool* pbSPIVMPFlag
    274 #endif
    275     )
    276   {
    277     pcMvFieldNeighbours[iCount<<1] = m_cMvField[0];
    278     pcMvFieldNeighbours[(iCount<<1) + 1] = m_cMvField[1];
    279     puhInterDirNeighbours[iCount] = m_uDir;
    280 #if NH_3D_VSP
    281     vspFlag[iCount] = m_iVspFlag;
    282 #endif
    283 #if NH_3D_SPIVMP
    284     pbSPIVMPFlag[iCount] = m_bSPIVMPFlag;
    285 #endif
    286   }
    287 
    288 
    289   Void print( Int i );
    290 
    291 };
    292 
    293 
    294 #endif
    295164
    296165
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComMv.h

    r1386 r1390  
    4040
    4141#include "CommonDef.h"
    42 #if NH_3D
    43 #include <cstdlib>
    44 #endif
    4542
    4643//! \ingroup TLibCommon
     
    5754  Short m_iHor;     ///< horizontal component of motion vector
    5855  Short m_iVer;     ///< vertical component of motion vector
    59 #if NH_3D_NBDV
    60   Bool  m_bIDV;       
    61   Short m_iIDVHor;   
    62   Short m_iIDVVer;   
    63   Short m_iIDVVId;  //view index of the IDV
    64 #endif
    6556public:
    6657
     
    7263  m_iHor(0),
    7364  m_iVer(0)
    74 #if NH_3D_NBDV
    75   , m_bIDV(false)
    76   , m_iIDVHor(0)
    77   , m_iIDVVer(0)
    78   , m_iIDVVId(0)
    79 #endif
    8065  {
    8166  }
     
    8469  m_iHor(iHor),
    8570  m_iVer(iVer)
    86  #if NH_3D_NBDV
    87   , m_bIDV(false)
    88   , m_iIDVHor(0)
    89   , m_iIDVVer(0)
    90   , m_iIDVVId(0)
    91 #endif
    9271  {
    9372  }
     
    10079  Void  setHor    ( Short i )                   { m_iHor = i;                               }
    10180  Void  setVer    ( Short i )                   { m_iVer = i;                               }
    102 #if NH_3D_NBDV
    103   Void  setZero   ()                            { m_iHor = m_iVer = 0; m_bIDV = false; m_iIDVHor = m_iIDVVer = 0; m_iIDVVId = 0;  }
    104   Void   setIDVHor  (Short i)                    {m_iIDVHor = i;}
    105   Void   setIDVVer  (Short i)                    {m_iIDVVer = i;}
    106   Void   setIDVFlag (Bool b )                    {m_bIDV    = b;}
    107   Void   setIDVVId  (Short i)                    {m_iIDVVId = i;}
    108 #else
    10981  Void  setZero   ()                            { m_iHor = m_iVer = 0;  }
    110 #endif
    11182  // ------------------------------------------------------------------------------------------------------------------
    11283  // get
     
    11788  Int   getAbsHor () const { return abs( m_iHor );   }
    11889  Int   getAbsVer () const { return abs( m_iVer );   }
    119 #if NH_3D_NBDV
    120   Short getIDVHor () const { return m_iIDVHor;       }
    121   Short getIDVVer () const { return m_iIDVVer;       }
    122   Bool  getIDVFlag() const { return m_bIDV;          }
    123   Short getIDVVId () const { return m_iIDVVId;       }
    124 
    125 #endif
    12690  // ------------------------------------------------------------------------------------------------------------------
    12791  // operations
     
    142106  }
    143107
    144 #if NH_3D
    145 #if ME_ENABLE_ROUNDING_OF_MVS
    146 
    147   const TComMv& operator>>= (const Int i)
    148   {
    149     m_iHor >>= i;
    150     m_iVer >>= i;
    151     return  *this;
    152   }
    153 #endif
    154 #endif
    155108
    156109#if !ME_ENABLE_ROUNDING_OF_MVS
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComPattern.h

    r1386 r1390  
    8585//  TComPatternParam  m_cPatternCb;
    8686  //TComPatternParam  m_cPatternCr;
    87 #if NH_3D_IC
    88   Bool              m_bICFlag;
    89 #endif
    90 #if NH_3D_SDC_INTER
    91   Bool              m_bSDCMRSADFlag;
    92 #endif
    9387
    9488
     
    10397  Int   getBitDepthY() const      { return m_cPatternY.m_bitDepth;        }
    10498
    105 #if NH_3D_IC
    106   Bool  getICFlag()               const { return m_bICFlag; }
    107   Void  setICFlag( Bool bICFlag ) { m_bICFlag = bICFlag; }
    108 #endif
    109 #if NH_3D_SDC_INTER
    110   Bool  getSDCMRSADFlag()         const { return m_bSDCMRSADFlag; }
    111   Void  setSDCMRSADFlag( Bool bSDCMRSADFlag )    { m_bSDCMRSADFlag = bSDCMRSADFlag; }
    112 #endif
    11399
    114100  // -------------------------------------------------------------------------------------------------------------------
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComPic.cpp

    r1386 r1390  
    6060, m_viewId                                (0)
    6161, m_bPicOutputFlag                        (false)
    62 #if NH_3D_VSO
    63 , m_viewIndex                             (0)
    64 , m_isDepth                               (false)
    65 , m_aaiCodedScale                         (0)
    66 , m_aaiCodedOffset                        (0)
    6762#endif
    68 #endif
    6963
    7064{
     
    7367    m_apcPicYuv[i]      = NULL;
    7468  }
    75 #if NH_3D_QTLPC
    76   m_bReduceBitsQTL    = 0;
    77 #endif
    78 #if NH_3D_NBDV
    79   m_iNumDdvCandPics   = 0;
    80   m_eRapRefList       = REF_PIC_LIST_0;
    81   m_uiRapRefIdx       = 0;
    82 #endif
    8369#if NH_MV
    8470  m_isPocResettingPic = false;   
     
    123109  m_bUsedByCurr = false;
    124110
    125 #if H_3D_FCO
    126 /* initialize the texture to depth reference status */
    127   for (int j=0; j<2; j++)
    128   {
    129       for (int i=0; i<MAX_NUM_REF; i++)
    130       {
    131           m_aiTexToDepRef[j][i] = -1;
    132       }
    133   }
    134 #endif
    135111
    136112}
     
    152128  deleteSEIs(m_SEIs);
    153129}
    154 #if NH_3D
    155 #if NH_3D_ARP
    156 Void TComPic::getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx )
    157 {
    158   Int iMaxCUWidth   = (Int) ( getPicSym()->getSPS().getMaxCUWidth()  );
    159   Int iMaxCuHeight  = (Int) ( getPicSym()->getSPS().getMaxCUHeight() );
    160 
    161   UInt uiMaxTotalCUDepth = getPicSym()->getSPS().getMaxTotalCUDepth();
    162   Int iBaseUnitWidth  = iMaxCUWidth >> uiMaxTotalCUDepth;
    163   Int iBaseUnitHeight = iMaxCUWidth >> uiMaxTotalCUDepth;
    164 
    165   Int iNumCuInWidth   = getPicYuvRec()->getWidth(COMPONENT_Y) / iMaxCUWidth;
    166   iNumCuInWidth      += ( getPicYuvRec()->getWidth(COMPONENT_Y) % iMaxCUWidth ) ? 1 : 0;
    167 
    168 
    169   Int iCuX            = iX / iMaxCUWidth;
    170   Int iCuY            = iY / iMaxCuHeight;
    171   Int iBaseX          = ( iX - iCuX * iMaxCUWidth  ) / iBaseUnitWidth;
    172   Int iBaseY          = ( iY - iCuY * iMaxCuHeight ) / iBaseUnitHeight;
    173   Int iCuSizeInBases  = iMaxCuHeight                 / iBaseUnitWidth;
    174 
    175   riCuAddr            = iCuY   * iNumCuInWidth + iCuX;
    176   Int iRastPartIdx    = iBaseY * iCuSizeInBases  + iBaseX;
    177   riAbsZorderIdx      = g_auiRasterToZscan[ iRastPartIdx ];
    178 }
    179 #endif
    180 Void TComPic::compressMotion(Int scale)
    181 #else
    182130Void TComPic::compressMotion()
    183 #endif
    184131{
    185132  TComPicSym* pPicSym = getPicSym();
     
    187134  {
    188135    TComDataCU* pCtu = pPicSym->getCtu(uiCUAddr);
    189 #if NH_3D
    190     pCtu->compressMV(scale);
    191 #else
    192136    pCtu->compressMV();
    193 #endif
    194137   
    195138  }
     
    327270}
    328271
    329 #if NH_3D
    330 Void TComPic::printMotion()
    331 {
    332   TComPicSym* pPicSym = getPicSym();
    333   for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getNumberOfCtusInFrame(); uiCUAddr++ )
    334   {
    335     TComDataCU* pCtu = pPicSym->getCtu(uiCUAddr);
    336     std::cout << "CUAddr " << uiCUAddr << std::endl;
    337     pCtu->printMV();
    338     std::cout << std::endl;
    339   }
    340 }
    341 
    342 #if NH_3D_NBDV
    343 Int TComPic::getDisCandRefPictures(Int iColPOC)
    344 {
    345   UInt       uiTempLayerCurr = 7;
    346   TComSlice* currSlice       = getSlice(getCurrSliceIdx());
    347   UInt       numDdvCandPics  = 0;
    348 
    349   if(!currSlice->getEnableTMVPFlag())
    350   {
    351     return numDdvCandPics;
    352   }
    353 
    354   numDdvCandPics += 1;
    355 
    356   UInt pocCurr = currSlice->getPOC();
    357   UInt pocDiff = 255;
    358 
    359   for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr++)
    360   {
    361     Bool x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
    362 
    363     for(UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
    364     {
    365       if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex()
    366          && (x == currSlice->getColFromL0Flag() || currSlice->getRefPOC((RefPicList)x, i) != iColPOC) && numDdvCandPics != 2)
    367       {
    368         TComSlice* refSlice    = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx());
    369         Bool       bRAP        = (refSlice->getViewIndex() && refSlice->isIRAP()) ? 1 : 0;
    370         UInt       uiTempLayer = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer();
    371        
    372         if(bRAP)
    373         {
    374           this->setRapRefIdx(i);
    375           this->setRapRefList((RefPicList)x);
    376           numDdvCandPics = 2;
    377 
    378           return numDdvCandPics;
    379         }
    380         else if (uiTempLayerCurr > uiTempLayer)
    381         {
    382            uiTempLayerCurr = uiTempLayer;
    383         }
    384       }
    385     }
    386   }
    387 
    388   UInt z   = -1; // GT: Added to make code compile needs to be checked!
    389   UInt idx = 0;
    390  
    391   for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2 : 1); lpNr++)
    392   {
    393     Bool x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
    394    
    395     for(UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
    396     {
    397       Int iTempPoc = currSlice->getRefPic((RefPicList)x, i)->getPOC();
    398       Int iTempDiff = (iTempPoc > pocCurr) ? (iTempPoc - pocCurr) : (pocCurr - iTempPoc);
    399      
    400       if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() && (x == currSlice->getColFromL0Flag() || currSlice->getRefPOC((RefPicList)x, i) != iColPOC)
    401          && currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer() == uiTempLayerCurr && pocDiff > iTempDiff)
    402       {
    403         pocDiff = iTempDiff;
    404         z       = x;
    405         idx     = i;
    406       }
    407     }
    408   }
    409 
    410   if(pocDiff < 255)
    411   {
    412     this->setRapRefIdx(idx);
    413     this->setRapRefList((RefPicList) z);
    414     numDdvCandPics = 2;
    415   }
    416 
    417   return numDdvCandPics;
    418 }
    419 
    420 Void TComPic::checkTemporalIVRef()
    421 {
    422   TComSlice* currSlice = getSlice(getCurrSliceIdx());
    423   const Int numCandPics = this->getNumDdvCandPics();
    424 
    425   for(Int curCandPic = 0; curCandPic < numCandPics; curCandPic++)
    426   {
    427     RefPicList eCurRefPicList   = REF_PIC_LIST_0 ;
    428     Int        curCandPicRefIdx = 0;
    429     if(curCandPic == 0)
    430     {
    431       eCurRefPicList   = RefPicList(currSlice->isInterB() ? 1 - currSlice->getColFromL0Flag() : 0);
    432       curCandPicRefIdx = currSlice->getColRefIdx();
    433     }
    434     else                 
    435     {
    436       eCurRefPicList   = this->getRapRefList();
    437       curCandPicRefIdx = this->getRapRefIdx();
    438     }
    439 
    440     TComPic* pcCandColPic = currSlice->getRefPic(eCurRefPicList, curCandPicRefIdx);
    441     TComSlice* pcCandColSlice = pcCandColPic->getSlice(0); // currently only support single slice
    442 
    443     if(!pcCandColSlice->isIntra())
    444     {
    445       for(Int iColRefDir = 0; iColRefDir < (pcCandColSlice->isInterB() ? 2 : 1); iColRefDir++)
    446       {
    447         for(Int iColRefIdx = 0; iColRefIdx < pcCandColSlice->getNumRefIdx((RefPicList)iColRefDir); iColRefIdx++)
    448         {
    449           m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = false;
    450           Int iColViewIdx    = pcCandColSlice->getViewIndex();
    451           // The picture pcCandColSlice->getRefPic((RefPicList)iColRefDir, iColRefIdx) might not be in DPB anymore
    452           // So don't access it directly.
    453           Int iColRefViewIdx = pcCandColSlice->getVPS()->getViewOrderIdx( pcCandColSlice->getRefLayerId( (RefPicList)iColRefDir, iColRefIdx ) );       
    454           if(iColViewIdx == iColRefViewIdx)
    455           {
    456             continue;
    457           }
    458 
    459           for(Int iCurrRefDir = 0; (iCurrRefDir < (currSlice->isInterB() ? 2 : 1)) && (m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] == false); iCurrRefDir++)
    460           {
    461             for(Int iCurrRefIdx = 0; iCurrRefIdx < currSlice->getNumRefIdx((RefPicList)iCurrRefDir); iCurrRefIdx++)
    462             {
    463               if(currSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iColRefViewIdx)
    464               { 
    465                 m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = true;
    466                 break;
    467               }
    468             }
    469           }
    470         }
    471       }
    472     }
    473   }
    474 }
    475 
    476 Bool TComPic::isTempIVRefValid(Int currCandPic, Int iColRefDir, Int iColRefIdx)
    477 {
    478   return m_abTIVRINCurrRL[currCandPic][iColRefDir][iColRefIdx];
    479 }
    480 
    481 Void TComPic::checkTextureRef()
    482 {
    483   TComSlice* pcCurrSlice = getSlice(getCurrSliceIdx());
    484   TComPic* pcTextPic = pcCurrSlice->getIvPic(0, getViewIndex());
    485 #if H_3D_FCO
    486   if ( pcTextPic )
    487   {
    488 #endif
    489     TComSlice* pcTextSlice = pcTextPic->getSlice(0); // currently only support single slice
    490 
    491     for(Int iTextRefDir = 0; (iTextRefDir < (pcTextSlice->isInterB() ? 2 :1) ) && !pcTextSlice->isIntra(); iTextRefDir++)
    492     {
    493       for(Int iTextRefIdx =0; iTextRefIdx < pcTextSlice->getNumRefIdx((RefPicList)iTextRefDir); iTextRefIdx++)
    494       {
    495         Int iTextRefPOC    = pcTextSlice->getRefPOC((RefPicList)iTextRefDir, iTextRefIdx);
    496         Int iTextRefViewId = pcTextSlice->getRefPic((RefPicList)iTextRefDir, iTextRefIdx)->getViewIndex();
    497         m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = -1;
    498         Int iCurrRefDir = iTextRefDir;
    499 
    500         for(Int iCurrRefIdx = 0; (iCurrRefIdx<pcCurrSlice->getNumRefIdx((RefPicList)iCurrRefDir)) && (m_aiTexToDepRef[iTextRefDir][iTextRefIdx] < 0); iCurrRefIdx++)
    501         {
    502           if(pcCurrSlice->getRefPOC((RefPicList)iCurrRefDir, iCurrRefIdx ) == iTextRefPOC &&
    503             pcCurrSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId)
    504           { 
    505             m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;           
    506           }
    507         }
    508       }
    509     }
    510 #if H_3D_FCO
    511   }
    512 #endif
    513 }
    514 
    515 Int TComPic::isTextRefValid(Int iTextRefDir, Int iTextRefIdx)
    516 {
    517   return m_aiTexToDepRef[iTextRefDir][iTextRefIdx];
    518 }
    519 #endif
    520 #endif
    521272
    522273Void TComAu::setPicLatencyCount( Int picLatenyCount )
     
    989740}
    990741
    991 #if NH_3D_VSO
    992 TComPicYuv* TComPicLists::getPicYuv( Int viewIndex, Bool depthFlag, Int auxId, Int poc, Bool recon )
    993 
    994   Int layerIdInNuh = m_vps->getLayerIdInNuh( viewIndex, depthFlag, auxId );
    995   return getPicYuv( layerIdInNuh, poc, recon );
    996 }
    997 
    998 TComPic* TComPicLists::getPic( Int viewIndex, Bool depthFlag, Int auxId, Int poc )
    999 {
    1000   return getPic   ( m_vps->getLayerIdInNuh( viewIndex, depthFlag, auxId ), poc );
    1001 }
    1002742
    1003743#endif
    1004744
    1005 #endif
    1006 
    1007745
    1008746
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComPic.h

    r1386 r1390  
    154154  TComDecodedRps        m_decodedRps;
    155155#endif
    156 #if NH_3D_VSO
    157   Int                   m_viewIndex;
    158   Bool                  m_isDepth;
    159   Int**                 m_aaiCodedScale;
    160   Int**                 m_aaiCodedOffset;
    161 #if NH_3D_QTLPC
    162   Bool                  m_bReduceBitsQTL;
    163 #endif
    164 #if NH_3D_NBDV
    165   UInt                   m_uiRapRefIdx;
    166   RefPicList             m_eRapRefList;
    167   Int                    m_iNumDdvCandPics;
    168   Bool                   m_abTIVRINCurrRL [2][2][MAX_NUM_REF]; //whether an inter-view reference picture with the same view index of the inter-view reference picture of temporal reference picture of current picture exists in current reference picture lists
    169   Int                    m_aiTexToDepRef  [2][MAX_NUM_REF];
    170 #endif
    171 #endif
    172156public:
    173157  TComPic();
     
    223207  Bool          getOutputMark () const      { return m_bNeededForOutput;  }
    224208
    225 #if !NH_3D
    226209  Void          compressMotion();
    227 #endif
    228210  UInt          getCurrSliceIdx() const           { return m_uiCurrSliceIdx;                }
    229211  Void          setCurrSliceIdx(UInt i)      { m_uiCurrSliceIdx = i;                   }
     
    311293   Void          print( Int outputLevel );
    312294
    313 #if NH_3D_VSO
    314    Void          setViewIndex          ( Int viewIndex )  { m_viewIndex = viewIndex;   }
    315    Int           getViewIndex          () const           { return m_viewIndex;     }
    316 
    317    Void          setIsDepth            ( Bool isDepth )   { m_isDepth = isDepth; }
    318    Bool          getIsDepth            ()                 { return m_isDepth; }
    319 
    320    Void          setScaleOffset( Int** pS, Int** pO )     { m_aaiCodedScale = pS; m_aaiCodedOffset = pO; }
    321    Int**         getCodedScale ()                         { return m_aaiCodedScale;  }
    322    Int**         getCodedOffset()                         { return m_aaiCodedOffset; }
    323 
    324    Void          compressMotion(Int scale);
    325    Void          printMotion( );
    326 #if NH_3D_ARP
    327    Void          getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
    328 #endif
    329 #if NH_3D_QTLPC
    330    Bool          getReduceBitsFlag ()                     { return m_bReduceBitsQTL;     }
    331    Void          setReduceBitsFlag ( Bool bFlag )         { m_bReduceBitsQTL = bFlag;    }
    332 #endif
    333 #if NH_3D_NBDV
    334   Int            getNumDdvCandPics()                      { return m_iNumDdvCandPics;    }
    335   Int            getDisCandRefPictures(Int iColPOC);       
    336   Void           setRapRefIdx(UInt uiRapRefIdx)           { m_uiRapRefIdx = uiRapRefIdx; }
    337   Void           setRapRefList(RefPicList eRefPicList)    { m_eRapRefList = eRefPicList; }
    338   Void           setNumDdvCandPics (Int i)                { m_iNumDdvCandPics = i;       }
    339   UInt           getRapRefIdx()                           { return m_uiRapRefIdx;        }
    340   RefPicList     getRapRefList()                          { return m_eRapRefList;        }
    341   Void           checkTemporalIVRef();                     
    342   Bool           isTempIVRefValid(Int currCandPic, Int iTempRefDir, Int iTempRefIdx);
    343   Void           checkTextureRef(  );
    344   Int            isTextRefValid(Int iTextRefDir, Int iTextRefIdx);
    345 #endif
    346 #endif
    347295#endif
    348296
     
    404352  TComList<TComSubDpb*>       m_subDpbs;
    405353  Bool                        m_printPicOutput;
    406 #if NH_3D_VSO
    407   const TComVPS*              m_vps;
    408 #endif
    409354public:
    410355  TComPicLists() { m_printPicOutput = false; };
     
    448393  Void                   print();
    449394
    450 #if NH_3D_VSO
    451   Void                   setVPS                        ( const TComVPS* vps ) { m_vps = vps;  };
    452   TComPic*               getPic                        ( Int viewIndex, Bool depthFlag, Int auxId, Int poc );
    453   TComPicYuv*            getPicYuv                     ( Int viewIndex, Bool depthFlag, Int auxId, Int poc, Bool recon );
    454 #endif 
    455395
    456396};
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComPicYuv.cpp

    r1386 r1390  
    9090  m_picHeight         = picHeight;
    9191
    92 #if NH_3D_IV_MERGE
    93   m_iCuWidth        = maxCUWidth;
    94   m_iCuHeight       = maxCUHeight;
    95 
    96   m_iNumCuInWidth   = picWidth / m_iCuWidth;
    97   m_iNumCuInWidth  += ( picHeight % m_iCuWidth ) ? 1 : 0;
    98   // Check if m_iBaseUnitWidth and m_iBaseUnitHeight need to be derived here
    99 #endif
    10092
    10193  m_chromaFormatIDC   = chromaFormatIDC;
     
    138130  createWithoutCUInfo(picWidth, picHeight, chromaFormatIDC, bUseMargin, maxCUWidth, maxCUHeight);
    139131
    140 #if NH_3D_IV_MERGE
    141   m_iBaseUnitWidth  = maxCUWidth  >> maxCUDepth;
    142   m_iBaseUnitHeight = maxCUHeight >> maxCUDepth;
    143 #endif
    144132
    145133
     
    347335  fclose(pFile);
    348336}
    349 #if NH_3D_IV_MERGE
    350 Void
    351 TComPicYuv::getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY )
    352 {
    353   Int iRastPartIdx    = g_auiZscanToRaster[iAbsZorderIdx];
    354   Int iCuSizeInBases  = m_iCuWidth   / m_iBaseUnitWidth;
    355   Int iCuX            = iCuAddr      % m_iNumCuInWidth;
    356   Int iCuY            = iCuAddr      / m_iNumCuInWidth;
    357   Int iBaseX          = iRastPartIdx % iCuSizeInBases;
    358   Int iBaseY          = iRastPartIdx / iCuSizeInBases;
    359   riX                 = iCuX * m_iCuWidth  + iBaseX * m_iBaseUnitWidth;
    360   riY                 = iCuY * m_iCuHeight + iBaseY * m_iBaseUnitHeight;
    361 }
    362 
    363 Void
    364 TComPicYuv::getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx )
    365 {
    366   Int iCuX            = iX / m_iCuWidth;
    367   Int iCuY            = iY / m_iCuHeight;
    368   Int iBaseX          = ( iX - iCuX * m_iCuWidth  ) / m_iBaseUnitWidth;
    369   Int iBaseY          = ( iY - iCuY * m_iCuHeight ) / m_iBaseUnitHeight;
    370   Int iCuSizeInBases  = m_iCuWidth                  / m_iBaseUnitWidth;
    371   riCuAddr            = iCuY   * m_iNumCuInWidth + iCuX;
    372   Int iRastPartIdx    = iBaseY * iCuSizeInBases  + iBaseX;
    373   riAbsZorderIdx      = g_auiRasterToZscan[ iRastPartIdx ];
    374 }
    375 
    376 #endif
    377 
    378 #if NH_3D_VSO
    379 Void TComPicYuv::setChromaTo( Pel pVal )
    380 {
    381   xSetPels( getAddr( COMPONENT_Cb ), getStride( COMPONENT_Cb ), getWidth( COMPONENT_Cb), getHeight( COMPONENT_Cb ), pVal );
    382   xSetPels( getAddr( COMPONENT_Cr ), getStride( COMPONENT_Cr ), getWidth( COMPONENT_Cr), getHeight( COMPONENT_Cr ), pVal );
    383 }
    384 
    385 Void TComPicYuv::xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal )
    386 {
    387   for (Int iYPos = 0; iYPos < iHeight; iYPos++)
    388   {
    389     for (Int iXPos = 0; iXPos < iWidth; iXPos++)
    390     {
    391       piPelSource[iXPos] = iVal;
    392     }
    393     piPelSource += iSourceStride;
    394   }
    395 }
    396 #endif
     337
    397338//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComPicYuv.h

    r1386 r1390  
    8080
    8181  Bool  m_bIsBorderExtended;
    82 #if NH_3D_IV_MERGE
    83   Int   m_iBaseUnitWidth;       ///< Width of Base Unit (with maximum depth or minimum size, m_iCuWidth >> Max. Depth)
    84   Int   m_iBaseUnitHeight;      ///< Height of Base Unit (with maximum depth or minimum size, m_iCuHeight >> Max. Depth)
    85   Int   m_iNumCuInWidth;
    86   Int   m_iCuWidth;             ///< Width of Coding Unit (CU)
    87   Int   m_iCuHeight;            ///< Height of Coding Unit (CU)
    88 #endif
    8982
    90 #if NH_3D_VSO
    91   Void  xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal );
    92 #endif
    9383
    9484public:
     
    183173  Bool          getBorderExtension( )     { return m_bIsBorderExtended; }
    184174#endif
    185 #if NH_3D_VSO
    186   // Set Function
    187   Void  setLumaTo    ( Pel pVal ); 
    188   Void  setChromaTo  ( Pel pVal ); 
    189 #endif
    190 #if NH_3D
    191 #if NH_3D_IV_MERGE
    192   // sample to block and block to sample conversion
    193   Void  getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY );
    194   Void  getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
    195 #endif
    196 #endif
    197175
    198176};// END CLASS DEFINITION TComPicYuv
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComPrediction.cpp

    r1386 r1390  
    8282    }
    8383  }
    84 #if NH_3D_VSP
    85   m_pDepthBlock = (Int*) malloc(MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH*sizeof(Int));
    86   if (m_pDepthBlock == NULL)
    87   {
    88       printf("ERROR: UKTGHU, No memory allocated.\n");
    89   }
    90 #endif
    9184
    9285}
     
    9487TComPrediction::~TComPrediction()
    9588{
    96 #if NH_3D_VSP
    97   if (m_pDepthBlock != NULL)
    98   {
    99     free(m_pDepthBlock);
    100   }
    101   m_cYuvDepthOnVsp.destroy();
    102 #endif
    10389
    10490  destroy();
     
    123109  m_cYuvPredTemp.destroy();
    124110
    125 #if NH_3D_ARP
    126   m_acYuvPredBase[0].destroy();
    127   m_acYuvPredBase[1].destroy();
    128 #endif
    129111  if( m_pLumaRecBuffer )
    130112  {
     
    182164
    183165    m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
    184 #if NH_3D_ARP
    185     m_acYuvPredBase[0] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
    186     m_acYuvPredBase[1] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
    187 #endif
    188 #if NH_3D_VSP
    189     m_cYuvDepthOnVsp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
    190 #endif
    191166
    192167  }
     
    201176    }
    202177  }
    203 #if NH_3D_IC
    204   m_uiaShift[0] = 0;
    205   for( Int i = 1; i < 64; i++ )
    206   {
    207     m_uiaShift[i] = ( (1 << 15) + i/2 ) / i;
    208   }
    209 #endif
    210178}
    211179
     
    508476}
    509477
    510 #if NH_3D_DMM
    511 Void TComPrediction::predIntraLumaDmm( TComDataCU* pcCU, UInt uiAbsPartIdx, DmmID dmmType, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight )
    512 {
    513   assert( iWidth == iHeight  );
    514   assert( iWidth >= DMM_MIN_SIZE && iWidth <= DMM_MAX_SIZE );
    515 #if NH_3D_SDC_INTRA
    516   assert( !pcCU->getSDCFlag( uiAbsPartIdx ) );
    517 #endif
    518 
    519   // get partition
    520   Bool* biSegPattern  = new Bool[ (UInt)(iWidth*iHeight) ];
    521   UInt  patternStride = (UInt)iWidth;
    522   switch( dmmType )
    523   {
    524   case( DMM1_IDX ): { (getWedgeListScaled( (UInt)iWidth )->at( pcCU->getDmm1WedgeTabIdx( uiAbsPartIdx ) )).getPatternScaledCopy( (UInt)iWidth, biSegPattern ); } break;
    525   case( DMM4_IDX ): { predContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, biSegPattern );                                                                 } break;
    526   default: assert(0);
    527   }
    528 
    529   // get predicted partition values
    530   Pel predDC1 = 0, predDC2 = 0;
    531   predBiSegDCs( pcCU, uiAbsPartIdx, iWidth, iHeight, biSegPattern, patternStride, predDC1, predDC2 );
    532 
    533   // set segment values with deltaDC offsets
    534   Pel segDC1 = 0, segDC2 = 0;
    535   Pel deltaDC1 = pcCU->getDmmDeltaDC( dmmType, 0, uiAbsPartIdx );
    536   Pel deltaDC2 = pcCU->getDmmDeltaDC( dmmType, 1, uiAbsPartIdx );
    537 #if NH_3D_DLT
    538   segDC1 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 ) + deltaDC1 );
    539   segDC2 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 ) + deltaDC2 );
    540 #else
    541   segDC1 = ClipBD( predDC1 + deltaDC1, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
    542   segDC2 = ClipBD( predDC2 + deltaDC2, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
    543 #endif
    544 
    545   // set prediction signal
    546   Pel* pDst = piPred;
    547   assignBiSegDCs( pDst, uiStride, biSegPattern, patternStride, segDC1, segDC2 );
    548  
    549   delete[] biSegPattern;
    550 }
    551 #endif
    552478
    553479/** Check for identical motion in both motion vector direction of a bi-directional predicted CU
     
    565491      Int layerIdL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getLayerId();
    566492      Int layerIdL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getLayerId();
    567 #if NH_3D_ARP
    568       if(!pcCU->getARPW(PartAddr) && RefPOCL0 == RefPOCL1 && layerIdL0 == layerIdL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
    569 #else
    570493      if(RefPOCL0 == RefPOCL1 && layerIdL0 == layerIdL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
    571 #endif
    572494#else
    573495      if(RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
     
    581503}
    582504
    583 #if NH_3D_SPIVMP
    584 Void TComPrediction::xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr )
    585 {
    586   for (Int i = 0; i < iNumSP; i++)
    587   {
    588     uiMergedSPW[i] = iSPWidth;
    589     uiMergedSPH[i] = iSPHeight;
    590     pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, i, iNumSPInOneLine, uiSPAddr[i]);
    591   }
    592 #if NH_3D_ARP
    593   if( pcCU->getARPW( uiPartAddr ) != 0 )
    594   {
    595     return;
    596   }
    597 #endif
    598 
    599   // horizontal sub-PU merge
    600   for (Int i=0; i<iNumSP; i++)
    601   {
    602     if (i % iNumSPInOneLine == iNumSPInOneLine - 1 || uiMergedSPW[i]==0 || uiMergedSPH[i]==0)
    603     {
    604       continue;
    605     }
    606     for (Int j=i+1; j<i+iNumSPInOneLine-i%iNumSPInOneLine; j++)
    607     {
    608       if (xCheckTwoSPMotion(pcCU, uiSPAddr[i], uiSPAddr[j]))
    609       {
    610         uiMergedSPW[i] += iSPWidth;
    611         uiMergedSPW[j] = uiMergedSPH[j] = 0;
    612       }
    613       else
    614       {
    615         break;
    616       }
    617     }
    618   }
    619   //vertical sub-PU merge
    620   for (Int i=0; i<iNumSP-iNumSPInOneLine; i++)
    621   {
    622     if (uiMergedSPW[i]==0 || uiMergedSPH[i]==0)
    623     {
    624       continue;
    625     }
    626     for (Int j=i+iNumSPInOneLine; j<iNumSP; j+=iNumSPInOneLine)
    627     {
    628       if (xCheckTwoSPMotion(pcCU, uiSPAddr[i], uiSPAddr[j]) && uiMergedSPW[i]==uiMergedSPW[j])
    629       {
    630         uiMergedSPH[i] += iSPHeight;
    631         uiMergedSPH[j] = uiMergedSPW[j] = 0;
    632       }
    633       else
    634       {
    635         break;
    636       }
    637     }
    638   }
    639 }
    640 
    641 Bool TComPrediction::xCheckTwoSPMotion ( TComDataCU* pcCU, UInt PartAddr0, UInt PartAddr1 )
    642 {
    643   if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr1))
    644   {
    645     return false;
    646   }
    647   if( pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr1))
    648   {
    649     return false;
    650   }
    651 
    652   if (pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr0) >= 0)
    653   {
    654     if (pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr1))
    655     {
    656       return false;
    657     }
    658   }
    659 
    660   if (pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr0) >= 0)
    661   {
    662     if (pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr1))
    663     {
    664       return false;
    665     }
    666   }
    667   return true;
    668 }
    669 #endif
    670 
    671 #if NH_3D_DBBP
    672 PartSize TComPrediction::getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize, TComDataCU*& pcCU)
    673 {
    674   const TComSPS* sps = pcCU->getSlice()->getSPS();
    675   UInt uiMaxCUWidth = sps->getMaxCUWidth();
    676   UInt uiMaxCUHeight = sps->getMaxCUHeight();
    677  
    678   // find virtual partitioning for this CU based on depth block
    679   // segmentation of texture block --> mask IDs
    680   Pel*  pDepthBlockStart      = pDepthPels;
    681 
    682   // first compute average of depth block for thresholding
    683   Int iSumDepth = 0;
    684   Int iSubSample = 4;
    685   Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(COMPONENT_Y);
    686   Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(COMPONENT_Y);
    687   TComMv cDv = pcCU->getSlice()->getDepthRefinementFlag(  ) ? pcCU->getDvInfo(0).m_acDoNBDV : pcCU->getDvInfo(0).m_acNBDV;
    688   if( pcCU->getSlice()->getDepthRefinementFlag(  ) )
    689   {
    690     cDv.setVer(0);
    691   }
    692   Int iBlkX = ( pcCU->getCtuRsAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getHor()+2)>>2);
    693   Int iBlkY = ( pcCU->getCtuRsAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getVer()+2)>>2);
    694  
    695   UInt t=0;
    696 
    697   for (Int y=0; y<uiSize; y+=iSubSample)
    698   {
    699     for (Int x=0; x<uiSize; x+=iSubSample)
    700     {
    701       if (iBlkX+x>iPictureWidth)
    702       {
    703         Int depthPel = pDepthPels[t];
    704         iSumDepth += depthPel;
    705       }
    706       else
    707       {
    708         Int depthPel = pDepthPels[x];
    709         t=x;
    710         iSumDepth += depthPel;
    711       }
    712     }
    713 
    714     // next row
    715     if (!(iBlkY+y+4>iPictureHeight))
    716     {
    717       pDepthPels += uiDepthStride*iSubSample;
    718     }
    719   }
    720 
    721   Int iSizeInBits = g_aucConvertToBit[uiSize] - g_aucConvertToBit[iSubSample];  // respect sub-sampling factor
    722   Int iMean = iSumDepth >> iSizeInBits*2;       // iMean /= (uiSize*uiSize);
    723 
    724   // start again for segmentation
    725   pDepthPels = pDepthBlockStart;
    726 
    727   // start mapping process
    728   Int matchedPartSum[2][2] = {{0,0},{0,0}}; // counter for each part size and boolean option
    729   PartSize virtualPartSizes[2] = { SIZE_Nx2N, SIZE_2NxN};
    730 
    731   UInt uiHalfSize = uiSize>>1;
    732   for (Int y=0; y<uiSize; y+=iSubSample)
    733   {
    734     for (Int x=0; x<uiSize; x+=iSubSample)
    735     {
    736       Int depthPel = 0;
    737       if (iBlkX+x>iPictureWidth)
    738       {
    739         depthPel = pDepthPels[t];
    740       }
    741       else
    742       {
    743         depthPel = pDepthPels[x];
    744         t=x;
    745       }
    746 
    747       // decide which segment this pixel belongs to
    748       Int ucSegment = (Int)(depthPel>iMean);
    749 
    750       // Matched Filter to find optimal (conventional) partitioning
    751 
    752       // SIZE_Nx2N
    753       if(x<uiHalfSize)  // left
    754       {
    755         matchedPartSum[0][ucSegment]++;
    756       }
    757       else  // right
    758       {
    759         matchedPartSum[0][1-ucSegment]++;
    760       }
    761 
    762       // SIZE_2NxN
    763       if(y<uiHalfSize)  // top
    764       {
    765         matchedPartSum[1][ucSegment]++;
    766       }
    767       else  // bottom
    768       {
    769         matchedPartSum[1][1-ucSegment]++;
    770       }
    771     }
    772 
    773     // next row
    774     if (!(iBlkY+y+4>iPictureHeight))
    775     {
    776       pDepthPels += uiDepthStride*iSubSample;
    777     }
    778   }
    779 
    780   PartSize matchedPartSize = NUMBER_OF_PART_SIZES;
    781 
    782   Int iMaxMatchSum = 0;
    783   for(Int p=0; p<2; p++)  // loop over partition
    784   {
    785     for( Int b=0; b<=1; b++ ) // loop over boolean options
    786     {
    787       if(matchedPartSum[p][b] > iMaxMatchSum)
    788       {
    789         iMaxMatchSum = matchedPartSum[p][b];
    790         matchedPartSize = virtualPartSizes[p];
    791       }
    792     }
    793   }
    794 
    795   AOF( matchedPartSize != NUMBER_OF_PART_SIZES );
    796 
    797   return matchedPartSize;
    798 }
    799 
    800 Bool TComPrediction::getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask, TComDataCU*& pcCU)
    801 {
    802   const TComSPS* sps = pcCU->getSlice()->getSPS();
    803   UInt uiMaxCUWidth = sps->getMaxCUWidth();
    804   UInt uiMaxCUHeight = sps->getMaxCUHeight();
    805  
    806   // segmentation of texture block --> mask IDs
    807   Pel*  pDepthBlockStart      = pDepthPels;
    808 
    809   // first compute average of depth block for thresholding
    810   Int iSumDepth = 0;
    811   Int uiMinDepth = MAX_INT;
    812   Int uiMaxDepth = 0;
    813   uiMinDepth = pDepthPels[ 0 ];
    814   uiMaxDepth = pDepthPels[ 0 ];
    815   iSumDepth  = pDepthPels[ 0 ];
    816  
    817   Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(COMPONENT_Y);
    818   Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(COMPONENT_Y); 
    819   TComMv cDv = pcCU->getSlice()->getDepthRefinementFlag(  ) ? pcCU->getDvInfo(0).m_acDoNBDV : pcCU->getDvInfo(0).m_acNBDV;
    820   if( pcCU->getSlice()->getDepthRefinementFlag(  ) )
    821   {
    822     cDv.setVer(0);
    823   }
    824   Int iBlkX = ( pcCU->getCtuRsAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getHor()+2)>>2);
    825   Int iBlkY = ( pcCU->getCtuRsAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getVer()+2)>>2);
    826   if (iBlkX>(Int)(iPictureWidth - uiWidth))
    827   {
    828     iSumDepth += pDepthPels[ iPictureWidth - iBlkX - 1 ];
    829     uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ iPictureWidth - iBlkX - 1 ]);
    830     uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ iPictureWidth - iBlkX - 1 ]);
    831   }
    832   else
    833   {
    834     iSumDepth += pDepthPels[ uiWidth - 1 ];
    835     uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiWidth - 1 ]);
    836     uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiWidth - 1 ]);
    837   }
    838   if (iBlkY>(Int)(iPictureHeight - uiHeight))
    839   {
    840     iSumDepth += pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) ];
    841     uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) ]);
    842     uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) ]);
    843   }
    844   else
    845   {
    846     iSumDepth += pDepthPels[ uiDepthStride * (uiHeight - 1) ];
    847     uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) ]);
    848     uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) ]);
    849   }
    850   if (iBlkY>(Int)(iPictureHeight - uiHeight) && iBlkX>(Int)(iPictureWidth - uiWidth))
    851   {
    852     iSumDepth += pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) + iPictureWidth - iBlkX - 1 ];
    853     uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) + iPictureWidth - iBlkX - 1 ]);
    854     uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) + iPictureWidth - iBlkX - 1 ]);
    855   }
    856   else if (iBlkY>(Int)(iPictureHeight - uiHeight))
    857   {
    858     iSumDepth += pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) + uiWidth - 1 ];
    859     uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) + uiWidth - 1 ]);
    860     uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) + uiWidth - 1 ]);
    861   }
    862   else if (iBlkX>(Int)(iPictureWidth - uiWidth))
    863   {
    864     iSumDepth += pDepthPels[ uiDepthStride * (uiHeight - 1) + iPictureWidth - iBlkX - 1 ];
    865     uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + iPictureWidth - iBlkX - 1 ]);
    866     uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + iPictureWidth - iBlkX - 1 ]);
    867   }
    868   else
    869   {
    870     iSumDepth += pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ];
    871     uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]);
    872     uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]);
    873   }
    874 
    875   // don't generate mask for blocks with small depth range (encoder decision)
    876   if( uiMaxDepth - uiMinDepth < 10 )
    877   {
    878     return false;
    879   }
    880 
    881   AOF(uiWidth==uiHeight);
    882   Int iMean = iSumDepth >> 2;
    883 
    884   // start again for segmentation
    885   pDepthPels = pDepthBlockStart;
    886 
    887   Bool bInvertMask = pDepthPels[0]>iMean; // top-left segment needs to be mapped to partIdx 0
    888 
    889   // generate mask
    890   UInt t=0;
    891   UInt uiSumPix[2] = {0,0};
    892   for (Int y=0; y<uiHeight; y++)
    893   {
    894     for (Int x=0; x<uiHeight; x++)
    895     {
    896       Int depthPel = 0;
    897       if (iBlkX+x>iPictureWidth)
    898       {
    899         depthPel = pDepthPels[t];
    900       }
    901       else
    902       {
    903         depthPel = pDepthPels[x];
    904         t=x;
    905       }
    906 
    907       // decide which segment this pixel belongs to
    908       Int ucSegment = (Int)(depthPel>iMean);
    909 
    910       if( bInvertMask )
    911       {
    912         ucSegment = 1-ucSegment;
    913       }
    914 
    915       // count pixels for each segment
    916       uiSumPix[ucSegment]++;
    917 
    918       // set mask value
    919       pMask[x] = (Bool)ucSegment;
    920     }
    921 
    922     // next row
    923     if (!(iBlkY+y+1>iPictureHeight))
    924       pDepthPels += uiDepthStride;
    925     pMask += MAX_CU_SIZE;
    926   }
    927 
    928   // don't generate valid mask for tiny segments (encoder decision)
    929   // each segment needs to cover at least 1/8th of block
    930   UInt uiMinPixPerSegment = (uiWidth*uiHeight) >> 3;
    931   if( !( uiSumPix[0] > uiMinPixPerSegment && uiSumPix[1] > uiMinPixPerSegment ) )
    932   {
    933     return false;
    934   }
    935 
    936   // all good
    937   return true;
    938 }
    939 
    940 Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize, Int bitDepthY )
    941 {
    942   Pel*  piSrc[2]    = {pInYuv[0]->getAddr(COMPONENT_Y, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Y, uiPartAddr)};
    943   UInt  uiSrcStride = pInYuv[0]->getStride(COMPONENT_Y);
    944   Pel*  piDst       = pOutYuv->getAddr(COMPONENT_Y, uiPartAddr);
    945   UInt  uiDstStride = pOutYuv->getStride(COMPONENT_Y);
    946  
    947   UInt  uiMaskStride= MAX_CU_SIZE;
    948   Pel* tmpTar = 0;
    949   tmpTar = (Pel *)xMalloc(Pel, uiWidth*uiHeight);
    950  
    951   // backup pointer
    952   Bool* pMaskStart = pMask;
    953  
    954   // combine luma first
    955   for (Int y=0; y<uiHeight; y++)
    956   {
    957     for (Int x=0; x<uiWidth; x++)
    958     {
    959       UChar ucSegment = (UChar)pMask[x];
    960       AOF( ucSegment < 2 );
    961      
    962       // filtering
    963       tmpTar[y*uiWidth+x] = piSrc[ucSegment][x];
    964     }
    965    
    966     piSrc[0]  += uiSrcStride;
    967     piSrc[1]  += uiSrcStride;
    968     pMask     += uiMaskStride;
    969   }
    970  
    971   if (partSize == SIZE_Nx2N)
    972   {
    973     for (Int y=0; y<uiHeight; y++)
    974     {
    975       for (Int x=0; x<uiWidth; x++)
    976       {
    977         Bool l = (x==0)?pMaskStart[y*uiMaskStride+x]:pMaskStart[y*uiMaskStride+x-1];
    978         Bool r = (x==uiWidth-1)?pMaskStart[y*uiMaskStride+x]:pMaskStart[y*uiMaskStride+x+1];
    979        
    980         Pel left, right;
    981         left   = (x==0)          ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x-1];
    982         right  = (x==uiWidth-1)  ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x+1];
    983        
    984         piDst[x] = (l!=r) ? ClipBD( Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 ), bitDepthY) : tmpTar[y*uiWidth+x];
    985       }
    986       piDst     += uiDstStride;
    987     }
    988   }
    989   else // SIZE_2NxN
    990   {
    991     for (Int y=0; y<uiHeight; y++)
    992     {
    993       for (Int x=0; x<uiWidth; x++)
    994       {
    995         Bool t = (y==0)?pMaskStart[y*uiMaskStride+x]:pMaskStart[(y-1)*uiMaskStride+x];
    996         Bool b = (y==uiHeight-1)?pMaskStart[y*uiMaskStride+x]:pMaskStart[(y+1)*uiMaskStride+x];
    997        
    998         Pel top, bottom;
    999         top    = (y==0)          ? tmpTar[y*uiWidth+x] : tmpTar[(y-1)*uiWidth+x];
    1000         bottom = (y==uiHeight-1) ? tmpTar[y*uiWidth+x] : tmpTar[(y+1)*uiWidth+x];
    1001        
    1002         piDst[x] = (t!=b) ? ClipBD( Pel(( top + (tmpTar[y*uiWidth+x] << 1) + bottom ) >> 2 ), bitDepthY) : tmpTar[y*uiWidth+x];
    1003       }
    1004       piDst     += uiDstStride;
    1005     }
    1006   }
    1007 
    1008   if ( tmpTar    )
    1009   {
    1010     xFree(tmpTar);             
    1011     tmpTar        = NULL;
    1012   }
    1013  
    1014   // now combine chroma
    1015   Pel*  piSrcU[2]       = { pInYuv[0]->getAddr(COMPONENT_Cb, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Cb, uiPartAddr) };
    1016   Pel*  piSrcV[2]       = { pInYuv[0]->getAddr(COMPONENT_Cr, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Cr, uiPartAddr) };
    1017   UInt  uiSrcStrideC    = pInYuv[0]->getStride(COMPONENT_Cb);
    1018   Pel*  piDstU          = pOutYuv->getAddr(COMPONENT_Cb, uiPartAddr);
    1019   Pel*  piDstV          = pOutYuv->getAddr(COMPONENT_Cr, uiPartAddr);
    1020   UInt  uiDstStrideC    = pOutYuv->getStride(COMPONENT_Cb);
    1021   UInt  uiWidthC        = uiWidth >> 1;
    1022   UInt  uiHeightC       = uiHeight >> 1;
    1023   Pel  filSrcU = 0, filSrcV = 0;
    1024   Pel* tmpTarU = 0, *tmpTarV = 0;
    1025   tmpTarU = (Pel *)xMalloc(Pel, uiWidthC*uiHeightC);
    1026   tmpTarV = (Pel *)xMalloc(Pel, uiWidthC*uiHeightC);
    1027   pMask = pMaskStart;
    1028  
    1029   for (Int y=0; y<uiHeightC; y++)
    1030   {
    1031     for (Int x=0; x<uiWidthC; x++)
    1032     {
    1033       UChar ucSegment = (UChar)pMask[x*2];
    1034       AOF( ucSegment < 2 );
    1035      
    1036       // filtering
    1037       tmpTarU[y*uiWidthC+x] = piSrcU[ucSegment][x];
    1038       tmpTarV[y*uiWidthC+x] = piSrcV[ucSegment][x];
    1039     }
    1040    
    1041     piSrcU[0]   += uiSrcStrideC;
    1042     piSrcU[1]   += uiSrcStrideC;
    1043     piSrcV[0]   += uiSrcStrideC;
    1044     piSrcV[1]   += uiSrcStrideC;
    1045     pMask       += 2*uiMaskStride;
    1046   }
    1047 
    1048   if (partSize == SIZE_Nx2N)
    1049   {
    1050     for (Int y=0; y<uiHeightC; y++)
    1051     {
    1052       for (Int x=0; x<uiWidthC; x++)
    1053       {
    1054         Bool l = (x==0)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[y*2*uiMaskStride+(x-1)*2];
    1055         Bool r = (x==uiWidthC-1)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[y*2*uiMaskStride+(x+1)*2];
    1056 
    1057         Pel leftU, rightU;
    1058         leftU   = (x==0)           ? tmpTarU[y*uiWidthC+x] : tmpTarU[y*uiWidthC+x-1];
    1059         rightU  = (x==uiWidthC-1)  ? tmpTarU[y*uiWidthC+x] : tmpTarU[y*uiWidthC+x+1];
    1060         Pel leftV, rightV;
    1061         leftV   = (x==0)           ? tmpTarV[y*uiWidthC+x] : tmpTarV[y*uiWidthC+x-1];
    1062         rightV  = (x==uiWidthC-1)  ? tmpTarV[y*uiWidthC+x] : tmpTarV[y*uiWidthC+x+1];
    1063 
    1064         if (l!=r)
    1065         {
    1066           filSrcU = ClipBD( Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 ), bitDepthY);
    1067           filSrcV = ClipBD( Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 ), bitDepthY);
    1068         }
    1069         else
    1070         {
    1071           filSrcU = tmpTarU[y*uiWidthC+x];
    1072           filSrcV = tmpTarV[y*uiWidthC+x];
    1073         }
    1074         piDstU[x] = filSrcU;
    1075         piDstV[x] = filSrcV;
    1076       }
    1077       piDstU      += uiDstStrideC;
    1078       piDstV      += uiDstStrideC;
    1079     }
    1080   }
    1081   else
    1082   {
    1083     for (Int y=0; y<uiHeightC; y++)
    1084     {
    1085       for (Int x=0; x<uiWidthC; x++)
    1086       {
    1087         Bool t = (y==0)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[(y-1)*2*uiMaskStride+x*2];
    1088         Bool b = (y==uiHeightC-1)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[(y+1)*2*uiMaskStride+x*2];
    1089 
    1090         Pel topU, bottomU;
    1091         topU    = (y==0)           ? tmpTarU[y*uiWidthC+x] : tmpTarU[(y-1)*uiWidthC+x];
    1092         bottomU = (y==uiHeightC-1) ? tmpTarU[y*uiWidthC+x] : tmpTarU[(y+1)*uiWidthC+x];
    1093         Pel topV, bottomV;
    1094         topV    = (y==0)           ? tmpTarV[y*uiWidthC+x] : tmpTarV[(y-1)*uiWidthC+x];
    1095         bottomV = (y==uiHeightC-1) ? tmpTarV[y*uiWidthC+x] : tmpTarV[(y+1)*uiWidthC+x];
    1096 
    1097         if (t!=b)
    1098         {
    1099           filSrcU = ClipBD( Pel(( topU + (tmpTarU[y*uiWidthC+x] << 1) + bottomU ) >> 2 ), bitDepthY);
    1100           filSrcV = ClipBD( Pel(( topV + (tmpTarV[y*uiWidthC+x] << 1) + bottomV ) >> 2 ), bitDepthY);
    1101         }
    1102         else
    1103         {
    1104           filSrcU = tmpTarU[y*uiWidthC+x];
    1105           filSrcV = tmpTarV[y*uiWidthC+x];
    1106         }
    1107         piDstU[x] = filSrcU;
    1108         piDstV[x] = filSrcV;
    1109       }
    1110       piDstU      += uiDstStrideC;
    1111       piDstV      += uiDstStrideC;
    1112     }
    1113   }
    1114 
    1115   if( tmpTarU )
    1116   {
    1117     xFree(tmpTarU);
    1118     tmpTarU        = NULL;
    1119   }
    1120   if ( tmpTarV    )
    1121   {
    1122     xFree(tmpTarV);
    1123     tmpTarV        = NULL;
    1124   }
    1125 }
    1126 #endif
     505
    1127506
    1128507Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )
     
    1138517  {
    1139518    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
    1140 #if NH_3D_VSP
    1141     if ( pcCU->getVSPFlag(uiPartAddr) == 0)
    1142     {
    1143 #endif
    1144519     if ( eRefPicList != REF_PIC_LIST_X )
    1145520     {
     
    1156531     else
    1157532     {
    1158 #if NH_3D_SPIVMP
    1159         if ( pcCU->getSPIVMPFlag(uiPartAddr)!=0) 
    1160         {
    1161           Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    1162 
    1163           pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    1164 
    1165           UInt uiW[256], uiH[256];
    1166           UInt uiSPAddr[256];
    1167 
    1168           xGetSubPUAddrAndMerge(pcCU, uiPartAddr, iSPWidth, iSPHeight, iNumSPInOneLine, iNumSP, uiW, uiH, uiSPAddr);
    1169 
    1170           //MC
    1171           for (Int i = 0; i < iNumSP; i++)
    1172           {
    1173             if (uiW[i]==0 || uiH[i]==0)
    1174             {
    1175               continue;
    1176             }
    1177             if( xCheckIdenticalMotion( pcCU, uiSPAddr[i] ))
    1178             {
    1179               xPredInterUni (pcCU, uiSPAddr[i], uiW[i], uiH[i], REF_PIC_LIST_0, pcYuvPred );
    1180             }
    1181             else
    1182             {
    1183               xPredInterBi  (pcCU, uiSPAddr[i], uiW[i], uiH[i], pcYuvPred);
    1184             }
    1185           }
    1186         }
    1187         else
    1188         {
    1189 #endif
    1190533          if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    1191534          {
     
    1196539            xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1197540          }
    1198 #if NH_3D_SPIVMP
    1199         }
    1200 #endif
    1201       }
    1202 #if NH_3D_VSP
    1203     }
    1204     else
    1205     {
    1206       if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    1207       {
    1208         xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
    1209       }
    1210       else
    1211       {
    1212         xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1213       }
    1214     }
    1215 #endif
     541      }
    1216542    return;
    1217543  }
     
    1221547    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
    1222548
    1223 #if NH_3D_VSP
    1224     if ( pcCU->getVSPFlag(uiPartAddr) == 0 )
    1225     {
    1226 #endif
    1227549    if ( eRefPicList != REF_PIC_LIST_X )
    1228550    {
     
    1239561    else
    1240562    {
    1241 #if NH_3D_SPIVMP
    1242       if (pcCU->getSPIVMPFlag(uiPartAddr)!=0) 
    1243       {
    1244         Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    1245 
    1246         pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    1247 
    1248         UInt uiW[256], uiH[256];
    1249         UInt uiSPAddr[256];
    1250 
    1251         xGetSubPUAddrAndMerge(pcCU, uiPartAddr, iSPWidth, iSPHeight, iNumSPInOneLine, iNumSP, uiW, uiH, uiSPAddr);
    1252         //MC
    1253         for (Int i = 0; i < iNumSP; i++)
    1254         {
    1255           if (uiW[i]==0 || uiH[i]==0)
    1256           {
    1257             continue;
    1258           }
    1259           if( xCheckIdenticalMotion( pcCU, uiSPAddr[i] ))
    1260           {
    1261             xPredInterUni (pcCU, uiSPAddr[i], uiW[i], uiH[i], REF_PIC_LIST_0, pcYuvPred );
    1262           }
    1263           else
    1264           {
    1265             xPredInterBi  (pcCU, uiSPAddr[i], uiW[i], uiH[i], pcYuvPred);
    1266           }
    1267         }
    1268       }
    1269       else
    1270       {
    1271 #endif
    1272563        if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    1273564        {
     
    1278569          xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1279570        }
    1280 #if NH_3D_SPIVMP
    1281       }
    1282 #endif
    1283     }
    1284 #if NH_3D_VSP
    1285     }
    1286     else
    1287     {
    1288       if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    1289       {
    1290         xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
    1291       }
    1292       else
    1293       {
    1294         xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1295       }
    1296     }
    1297 #endif
     571    }
    1298572  }
    1299573  return;
     
    1319593  pcCU->checkMvVertRest(cMv, eRefPicList, iRefIdx );
    1320594#endif
    1321 #if NH_3D_ARP
    1322   if(  pcCU->getARPW( uiPartAddr ) > 0 )
    1323   {
    1324     if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC() )
    1325     {
    1326       xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , pcYuvPred , bi );
    1327     }
    1328     else
    1329     {
    1330       xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, bi );
    1331     }     
    1332   }
    1333   else
    1334   {
    1335 #endif
    1336595
    1337596    for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++)
    1338597    {
    1339598      const ComponentID compID=ComponentID(comp);
    1340 #if NH_3D_IC
    1341       Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ) && ( isLuma(compID) || (iWidth > 8) );
    1342       xPredInterBlk(compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID))
    1343 #if NH_3D_ARP
    1344         , false
    1345 #endif
    1346         , bICFlag );
    1347 #else
    1348599      xPredInterBlk  (compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) );
    1349 #endif
    1350     }
    1351 #if NH_3D_ARP
    1352   }
    1353 #endif
    1354 }
    1355 
    1356 #if NH_3D_VSP
    1357 Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
    1358 {
    1359   Int vspSize = pcCU->getVSPFlag( uiPartAddr ) >> 1;
    1360 
    1361   Int widthSubPU, heightSubPU;
    1362   if (vspSize)
    1363   {
    1364     widthSubPU  = 8;
    1365     heightSubPU = 4;
    1366   }
    1367   else
    1368   {
    1369     widthSubPU  = 4;
    1370     heightSubPU = 8;
    1371   }
    1372   xPredInterUniSubPU( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi, widthSubPU, heightSubPU );
    1373 }
    1374 
    1375 Void TComPrediction::xPredInterUniSubPU( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU, Int heightSubPU )
    1376 {
    1377   UInt numPartsInLine       = pcCU->getPic()->getNumPartInCtuWidth();
    1378   UInt horiNumPartsInSubPU  = widthSubPU >> 2;
    1379   UInt vertNumPartsInSubPU  = (heightSubPU >> 2) * numPartsInLine;
    1380 
    1381   UInt partAddrRasterLine = g_auiZscanToRaster[ uiPartAddr ];
    1382 
    1383   for( Int posY=0; posY<iHeight; posY+=heightSubPU, partAddrRasterLine+=vertNumPartsInSubPU )
    1384   {
    1385     UInt partAddrRasterSubPU = partAddrRasterLine;
    1386     for( Int posX=0; posX<iWidth; posX+=widthSubPU, partAddrRasterSubPU+=horiNumPartsInSubPU )
    1387     {
    1388       UInt    partAddrSubPU = g_auiRasterToZscan[ partAddrRasterSubPU ];
    1389       Int     refIdx        = pcCU->getCUMvField( eRefPicList )->getRefIdx( partAddrSubPU );           assert (refIdx >= 0);
    1390       TComMv  cMv           = pcCU->getCUMvField( eRefPicList )->getMv( partAddrSubPU );
    1391       pcCU->clipMv(cMv);
    1392 
    1393       xPredInterBlk( COMPONENT_Y,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
    1394       xPredInterBlk( COMPONENT_Cb, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) );
    1395       xPredInterBlk( COMPONENT_Cr, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) );
    1396     }
    1397   }
    1398 }
    1399 #endif
    1400 
    1401 #if NH_3D_ARP
    1402 //temporal ARP
    1403 Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
    1404 {
    1405   Int         iRefIdx      = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
    1406   TComMv      cMv          = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
    1407   Bool        bTobeScaled  = false;
    1408   TComPic* pcPicYuvBaseCol = NULL;
    1409   TComPic* pcPicYuvBaseRef = NULL;
    1410 
    1411 #if NH_3D_NBDV
    1412   DisInfo cDistparity;
    1413   cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV;
    1414   cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan;
    1415 #else
    1416   assert(0); // ARP can be applied only when a DV is available
    1417 #endif
    1418   UChar dW = pcCU->getARPW ( uiPartAddr );
    1419 
    1420     Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList);
    1421   if (arpRefIdx < 0 || !pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan))
    1422     {
    1423       dW = 0;
    1424       bTobeScaled = false;
    1425     }
    1426     else
    1427     {
    1428     if( arpRefIdx != iRefIdx )
    1429     {
    1430       bTobeScaled = true;
    1431     }
    1432     pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan );
    1433     pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan );
    1434     }
    1435 
    1436     if(bTobeScaled)
    1437     {     
    1438       Int iCurrPOC    = pcCU->getSlice()->getPOC();
    1439       Int iColRefPOC  = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx );
    1440       Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, arpRefIdx );
    1441       Int iScale      = pcCU->xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC);
    1442       if ( iScale != 4096 )
    1443       {
    1444         cMv = cMv.scaleMv( iScale );
    1445       }
    1446       iRefIdx = arpRefIdx;
    1447     }
    1448 
    1449   pcCU->clipMv(cMv);
    1450   TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec();
    1451 
    1452   for (UInt comp=COMPONENT_Y; comp< rpcYuvPred->getNumberValidComponents(); comp++)
    1453   {
    1454     const ComponentID compID=ComponentID(comp);
    1455     xPredInterBlk  ( compID,  pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
    1456   }
    1457 
    1458   if( dW > 0 )
    1459   {
    1460     TComYuv * pYuvB0 = &m_acYuvPredBase[0];
    1461     TComYuv * pYuvB1  = &m_acYuvPredBase[1];
    1462 
    1463     TComMv cMVwithDisparity = cMv + cDistparity.m_acNBDV;
    1464     pcCU->clipMv(cMVwithDisparity);
    1465     if (iWidth <= 8)
    1466     {
    1467       pYuvB0->clear(); pYuvB1->clear();
    1468     }
    1469     TComMv cNBDV = cDistparity.m_acNBDV;
    1470     pcCU->clipMv( cNBDV );
    1471    
    1472     TComPicYuv* pcPicYuvBaseColRec = pcPicYuvBaseCol->getPicYuvRec();
    1473     TComPicYuv* pcPicYuvBaseRefRec = pcPicYuvBaseRef->getPicYuvRec();
    1474    
    1475     UInt uiCompNum = ( iWidth > 8 ) ? 3: 1;
    1476     for (UInt comp=COMPONENT_Y; comp< uiCompNum; comp++)
    1477     {
    1478       const ComponentID compID=ComponentID(comp);
    1479       xPredInterBlk  ( compID,  pcCU, pcPicYuvBaseColRec, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
    1480       xPredInterBlk  ( compID,  pcCU, pcPicYuvBaseRefRec, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
    1481     }   
    1482    
    1483     pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight );
    1484 
    1485     if( 2 == dW )
    1486     {
    1487       pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
    1488     }
    1489     rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi, pcCU->getSlice()->getSPS()->getBitDepths() );
    1490   }
    1491 }
    1492 
    1493 Bool TComPrediction::xCheckBiInterviewARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eBaseRefPicList, TComPic*& pcPicYuvCurrTRef, TComMv& cBaseTMV, Int& iCurrTRefPoc )
    1494 {
    1495   Int         iRefIdx       = pcCU->getCUMvField( eBaseRefPicList )->getRefIdx( uiPartAddr );
    1496   TComMv      cDMv          = pcCU->getCUMvField( eBaseRefPicList )->getMv( uiPartAddr );
    1497   TComPic* pcPicYuvBaseCol  = pcCU->getSlice()->getRefPic( eBaseRefPicList, iRefIdx ); 
    1498   Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
    1499   Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
    1500 
    1501   irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
    1502   irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); 
    1503 
    1504   Int uiLCUAddr,uiAbsPartAddr;
    1505   pcPicYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
    1506   TComDataCU *pColCU = pcPicYuvBaseCol->getCtu( uiLCUAddr );
    1507 
    1508   TComPic* pcPicYuvBaseTRef = NULL;
    1509   pcPicYuvCurrTRef = NULL;
    1510 
    1511   //If there is available motion in base reference list, use it
    1512   if(!pColCU->isIntra(uiAbsPartAddr))
    1513   {
    1514     for(Int iList = 0; iList < (pColCU->getSlice()->isInterB() ? 2: 1); iList ++)
    1515     {
    1516       RefPicList eRefPicListCurr = RefPicList(iList);
    1517       Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr);
    1518       if( iRef != -1)
    1519       {
    1520         pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef); 
    1521         Int  iCurrPOC    = pColCU->getSlice()->getPOC();
    1522         Int  iCurrRefPOC = pcPicYuvBaseTRef->getPOC();
    1523         Int  iCurrRef    = pcCU->getSlice()->getFirstTRefIdx(eRefPicListCurr);
    1524 
    1525         if( iCurrRef >= 0 && iCurrPOC != iCurrRefPOC)
    1526         {
    1527           pcPicYuvCurrTRef =  pcCU->getSlice()->getRefPic(eRefPicListCurr,iCurrRef); 
    1528           Int iTargetPOC = pcPicYuvCurrTRef->getPOC();
    1529           pcPicYuvBaseTRef =  pcCU->getSlice()->getBaseViewRefPic(iTargetPOC,  pcPicYuvBaseCol->getViewIndex() ); 
    1530           if(pcPicYuvBaseTRef)
    1531           {
    1532             cBaseTMV = pColCU->getCUMvField(eRefPicListCurr)->getMv(uiAbsPartAddr);
    1533             Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC);
    1534             if ( iScale != 4096 )
    1535             {
    1536               cBaseTMV = cBaseTMV.scaleMv( iScale );
    1537             }
    1538             iCurrTRefPoc = iTargetPOC;
    1539             return true;
    1540           }
    1541         }
    1542       }
    1543     }
    1544   }
    1545 
    1546   //If there is no available motion in base reference list, use ( 0, 0 )
    1547   if( pcCU->getSlice()->getFirstTRefIdx( eBaseRefPicList ) >= 0 )
    1548   {
    1549     cBaseTMV.set( 0, 0 );
    1550     pcPicYuvCurrTRef = pcCU->getSlice()->getRefPic( eBaseRefPicList,  pcCU->getSlice()->getFirstTRefIdx( eBaseRefPicList ) );
    1551     iCurrTRefPoc = pcPicYuvCurrTRef->getPOC();
    1552     return true;
    1553   }
    1554 
    1555   return false;
    1556 }
    1557 
    1558 //inter-view ARP
    1559 Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
    1560 {
    1561   Int         iRefIdx       = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
    1562   TComMv      cDMv          = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
    1563   TComMv      cTempDMv      = cDMv;
    1564   UChar       dW            = pcCU->getARPW ( uiPartAddr );
    1565 
    1566   TComPic* pcPicYuvBaseTRef = NULL;
    1567   TComPic* pcPicYuvCurrTRef = NULL;
    1568   TComPic* pcPicYuvBaseCol  = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); 
    1569   TComPicYuv* pcYuvBaseCol  = pcPicYuvBaseCol->getPicYuvRec();   
    1570   Bool bTMVAvai = false;     
    1571   TComMv cBaseTMV;
    1572 
    1573   pcCU->clipMv(cTempDMv);
    1574 
    1575   Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
    1576   Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
    1577 
    1578   irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
    1579   irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); 
    1580  
    1581   Int uiLCUAddr,uiAbsPartAddr;
    1582   pcPicYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
    1583   TComDataCU *pColCU = pcPicYuvBaseCol->getCtu( uiLCUAddr );
    1584   if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getIsDepth() )
    1585   {
    1586     RefPicList eOtherRefList = ( eRefPicList == REF_PIC_LIST_0 ) ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
    1587     Int iOtherRefIdx = pcCU->getCUMvField( eOtherRefList )->getRefIdx( uiPartAddr );
    1588     //The other prediction direction is temporal ARP
    1589     if( iOtherRefIdx >= 0 && pcCU->getSlice()->getViewIndex() == pcCU->getSlice()->getRefPic( eOtherRefList, iOtherRefIdx )->getViewIndex() )
    1590     {
    1591       bTMVAvai = true;
    1592       pcPicYuvBaseTRef = pcCU->getSlice()->getRefPic( eOtherRefList, iOtherRefIdx );
    1593       Int  iCurrPOC    = pcCU->getSlice()->getPOC();
    1594       Int  iCurrRefPOC = pcPicYuvBaseTRef->getPOC();
    1595       Int  iCurrRef    = pcCU->getSlice()->getFirstTRefIdx( eOtherRefList );
    1596      
    1597       if( iCurrRef >= 0 )
    1598       {
    1599         pcPicYuvCurrTRef =  pcCU->getSlice()->getRefPic( eOtherRefList,iCurrRef ); 
    1600         Int iTargetPOC = pcPicYuvCurrTRef->getPOC();
    1601         pcPicYuvBaseTRef =  pcCU->getSlice()->getBaseViewRefPic( iTargetPOC,  pcPicYuvBaseCol->getViewIndex() );
    1602         if( pcPicYuvBaseTRef )
    1603         {
    1604           cBaseTMV = pcCU->getCUMvField( eOtherRefList )->getMv( uiPartAddr );
    1605           Int iScale = pcCU-> xGetDistScaleFactor( iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC );
    1606           if ( iScale != 4096 )
    1607           {
    1608             cBaseTMV = cBaseTMV.scaleMv( iScale );
    1609           }
    1610         }
    1611         else
    1612         {
    1613           dW = 0;
    1614         }
    1615       }
    1616       else
    1617       {
    1618         dW = 0;
    1619       }
    1620     }
    1621 
    1622     //Both prediction directions are inter-view ARP
    1623     if ( iOtherRefIdx >= 0 && !bTMVAvai )
    1624     {
    1625       RefPicList eBaseList = REF_PIC_LIST_0;
    1626       Int iCurrTRefPoc;
    1627       bTMVAvai = ( eBaseList != eRefPicList ) && ( pcCU->getSlice()->getViewIndex() != pcCU->getSlice()->getRefPic( eOtherRefList, iOtherRefIdx )->getViewIndex() );
    1628 
    1629       if ( bTMVAvai )
    1630       {
    1631         if( xCheckBiInterviewARP( pcCU, uiPartAddr, iWidth, iHeight, eBaseList, pcPicYuvCurrTRef, cBaseTMV, iCurrTRefPoc ) )
    1632         {
    1633           pcPicYuvBaseTRef = pcCU->getSlice()->getBaseViewRefPic( iCurrTRefPoc,  pcPicYuvBaseCol->getViewIndex() );
    1634           if ( pcPicYuvBaseTRef == NULL )
    1635           {
    1636             dW = 0;
    1637           }
    1638         }
    1639         else
    1640         {
    1641           dW = 0;
    1642         }
    1643       }
    1644     }
    1645   }
    1646 
    1647   if( !pColCU->isIntra( uiAbsPartAddr ) && !bTMVAvai )
    1648   {
    1649     TComMvField puMVField;
    1650     for(Int iList = 0; iList < (pColCU->getSlice()->isInterB() ? 2: 1) && !bTMVAvai; iList ++)
    1651     {
    1652       RefPicList eRefPicListCurr = RefPicList(iList);
    1653       Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr);
    1654       if( iRef != -1 && pcCU->getSlice()->getArpRefPicAvailable( eRefPicListCurr, pcPicYuvBaseCol->getViewIndex()))
    1655       {
    1656         pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef); 
    1657         Int  iCurrPOC    = pColCU->getSlice()->getPOC();
    1658         Int  iCurrRefPOC = pcPicYuvBaseTRef->getPOC();
    1659         Int  iCurrRef    = pcCU->getSlice()->getFirstTRefIdx(eRefPicListCurr);
    1660         if (iCurrRef >= 0 && iCurrRefPOC != iCurrPOC)
    1661         {
    1662           pcPicYuvCurrTRef =  pcCU->getSlice()->getRefPic(eRefPicListCurr,iCurrRef); 
    1663           Int iTargetPOC = pcPicYuvCurrTRef->getPOC();
    1664           {
    1665             pcPicYuvBaseTRef =  pcCU->getSlice()->getBaseViewRefPic(iTargetPOC,  pcPicYuvBaseCol->getViewIndex() ); 
    1666             if(pcPicYuvBaseTRef)
    1667             {
    1668               cBaseTMV = pColCU->getCUMvField(eRefPicListCurr)->getMv(uiAbsPartAddr);
    1669               Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC);
    1670               if ( iScale != 4096 )
    1671                 cBaseTMV = cBaseTMV.scaleMv( iScale );                 
    1672               bTMVAvai = true;
    1673               break;
    1674             }
    1675           }
    1676         }
    1677       }
    1678     }
    1679   }
    1680   if (bTMVAvai == false)
    1681   {
    1682     bTMVAvai = true;
    1683     cBaseTMV.set(0, 0);
    1684     pcPicYuvBaseTRef =  pColCU->getSlice()->getRefPic(eRefPicList,  pcCU->getSlice()->getFirstTRefIdx(eRefPicList)); 
    1685     pcPicYuvCurrTRef =  pcCU->getSlice()->getRefPic  (eRefPicList,  pcCU->getSlice()->getFirstTRefIdx(eRefPicList));     
    1686   }
    1687 
    1688   for (UInt comp=COMPONENT_Y; comp< rpcYuvPred->getNumberValidComponents(); comp++)
    1689   {
    1690     const ComponentID compID=ComponentID(comp);
    1691     xPredInterBlk  ( compID,  pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ), pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), bTMVAvai );
    1692   }
    1693 
    1694   if( dW > 0 )
    1695   {
    1696     assert ( bTMVAvai );
    1697     TComYuv*    pYuvCurrTRef    = &m_acYuvPredBase[0];
    1698     TComYuv*    pYuvBaseTRef    = &m_acYuvPredBase[1];
    1699     TComPicYuv* pcYuvCurrTref   = pcPicYuvCurrTRef->getPicYuvRec();       
    1700     TComPicYuv* pcYuvBaseTref   = pcPicYuvBaseTRef->getPicYuvRec(); 
    1701     TComMv      cTempMv         = cDMv + cBaseTMV;
    1702 
    1703     pcCU->clipMv(cBaseTMV);
    1704     pcCU->clipMv(cTempMv);
    1705 
    1706     if (iWidth <= 8)
    1707     {
    1708       pYuvCurrTRef->clear(); pYuvBaseTRef->clear();
    1709     }
    1710 
    1711     UInt uiCompNum = ( iWidth > 8 ) ? 3: 1;
    1712     for (UInt comp=COMPONENT_Y; comp< uiCompNum; comp++)
    1713     {
    1714       const ComponentID compID=ComponentID(comp);
    1715       xPredInterBlk  ( compID,  pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
    1716       xPredInterBlk  ( compID,  pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
    1717     }
    1718 
    1719     pYuvCurrTRef->subtractARP( pYuvCurrTRef , pYuvBaseTRef , uiPartAddr , iWidth , iHeight ); 
    1720     if(dW == 2)
    1721     {
    1722       pYuvCurrTRef->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
    1723     }
    1724     rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi, pcCU->getSlice()->getSPS()->getBitDepths() );
    1725   }
    1726 }
    1727 #endif
     600    }
     601}
     602
     603
    1728604
    1729605Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* pcYuvPred )
     
    1777653}
    1778654
    1779 #if NH_3D_VSP
    1780 Void TComPrediction::xPredInterBiVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred )
    1781 {
    1782   TComYuv* pcMbYuv;
    1783   Int      iRefIdx[2] = {-1, -1};
    1784   Bool     bi = (pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0);
    1785 
    1786   for ( Int iRefList = 0; iRefList < 2; iRefList++ )
    1787   {
    1788     RefPicList eRefPicList = RefPicList(iRefList);
    1789     iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );
    1790 
    1791     if ( iRefIdx[iRefList] < 0 )
    1792     {
    1793       continue;
    1794     }
    1795     assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) );
    1796 
    1797     pcMbYuv = &m_acYuvPred[iRefList];
    1798     xPredInterUniVSP ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, bi );
    1799   }
    1800 
    1801   xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, pcCU->getSlice()->getSPS()->getBitDepths() );
    1802 }
    1803 #endif
    1804655
    1805656/**
     
    1819670
    1820671
    1821 #if NH_3D
    1822 Void TComPrediction::xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth
    1823 #if NH_3D_ARP
    1824     , Bool filterType
    1825 #endif
    1826 #if NH_3D_IC
    1827     , Bool bICFlag
    1828 #endif
    1829 )
    1830 #else
    1831672Void TComPrediction::xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth )
    1832 #endif
    1833673{
    1834674#if NH_MV
     
    1849689  Int     yFrac  = mv->getVer() & ((1<<shiftVer)-1);
    1850690
    1851 #if NH_3D_INTEGER_MV_DEPTH
    1852   if( cu->getSlice()->getIsDepth() )
    1853   {
    1854     refOffset = mv->getHor() + mv->getVer() * refStride;
    1855     ref       = refPic->getAddr(compID, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refOffset;
    1856     xFrac     = 0;
    1857     yFrac     = 0;
    1858   }
    1859 #endif
    1860691
    1861692  UInt    cxWidth  = width  >> refPic->getComponentScaleX(compID);
     
    1866697  if ( yFrac == 0 )
    1867698  {
    1868 #if NH_3D
    1869     m_if.filterHor(compID, ref, refStride, dst,  dstStride, cxWidth, cxHeight, xFrac, !bi
    1870 #if NH_3D_IC
    1871      || bICFlag
    1872 #endif
    1873     , chFmt, bitDepth
    1874 #if NH_3D_ARP
    1875     , filterType
    1876 #endif
    1877 );
    1878 #else
    1879699    m_if.filterHor(compID, ref, refStride, dst,  dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt, bitDepth );
    1880 #endif
    1881700  }
    1882701  else if ( xFrac == 0 )
    1883702  {
    1884 #if NH_3D
    1885   m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi
    1886 #if NH_3D_IC
    1887     || bICFlag
    1888 #endif
    1889     , chFmt, bitDepth
    1890 #if NH_3D_ARP
    1891     , filterType
    1892 #endif
    1893 );
    1894 #else
    1895703    m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt, bitDepth );
    1896704
    1897 #endif
    1898705  }
    1899706  else
     
    1904711    const Int vFilterSize = isLuma(compID) ? NTAPS_LUMA : NTAPS_CHROMA;
    1905712
    1906 #if NH_3D_ARP
    1907     m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false,      chFmt, bitDepth, filterType );
    1908 #else
    1909713    m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false,      chFmt, bitDepth );
    1910 #endif
    1911 
    1912 #if NH_3D
    1913     m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight,               yFrac, false, !bi
    1914 #if NH_3D_IC
    1915     || bICFlag
    1916 #endif
    1917     , chFmt, bitDepth
    1918 #if NH_3D_ARP
    1919     , filterType
    1920 #endif
    1921 );
    1922 #else
     714
    1923715    m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight,               yFrac, false, !bi, chFmt, bitDepth );
    1924 #endif
    1925   }
    1926 
    1927 #if NH_3D_IC
    1928   if( bICFlag )
    1929   {
    1930     Int a, b, i, j;
    1931     const Int iShift = IC_CONST_SHIFT;
    1932     Pel *dst2 = dst;
    1933 
    1934     xGetLLSICPrediction( compID, cu, mv, refPic, a, b, bitDepth );
    1935 
    1936     for ( i = 0; i < cxHeight; i++ )
    1937     {
    1938       for ( j = 0; j < cxWidth; j++ )
    1939       {
    1940         dst[j] = Clip3( 0, ( 1 << bitDepth ) - 1, ( ( a*dst[j] ) >> iShift ) + b );
    1941       }
    1942       dst += dstStride;
    1943     }
    1944 
    1945     if(bi)
    1946     {
    1947       Int shift = IF_INTERNAL_PREC - bitDepth;
    1948       for (i = 0; i < cxHeight; i++)
    1949       {
    1950         for (j = 0; j < cxWidth; j++)
    1951         {
    1952           Pel val = dst2[j] << shift;
    1953           dst2[j] = val - (Pel)IF_INTERNAL_OFFS;
    1954         }
    1955         dst2 += dstStride;
    1956       }
    1957     }
    1958   }
    1959 #endif
     716  }
     717
    1960718
    1961719}
     
    2104862          (uiDirMode==HOR_IDX || uiDirMode==VER_IDX);
    2105863}
    2106 #if NH_3D_IC
    2107 /** Function for deriving the position of first non-zero binary bit of a value
    2108  * \param x input value
    2109  *
    2110  * This function derives the position of first non-zero binary bit of a value
    2111  */
    2112 Int GetMSB( UInt x )
    2113 {
    2114   Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1;
    2115 
    2116   while( x > 1 )
    2117   {
    2118     bits >>= 1;
    2119     y = x >> bits;
    2120 
    2121     if( y )
    2122     {
    2123       x = y;
    2124       iMSB += bits;
    2125     }
    2126   }
    2127 
    2128   iMSB+=y;
    2129 
    2130   return iMSB;
    2131 }
    2132 
    2133 
    2134 /** Function for deriving LM illumination compensation.
    2135  */
    2136 Void TComPrediction::xGetLLSICPrediction( const ComponentID compID, TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, const Int bitDepth )
    2137 {
    2138   TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec();
    2139   Pel *pRec = NULL, *pRef = NULL;
    2140   UInt uiWidth, uiHeight, uiTmpPartIdx;
    2141   Int iRecStride = pRecPic->getStride(compID);
    2142   Int iRefStride = pRefPic->getStride(compID);
    2143   Int iRefOffset, iHor, iVer;
    2144   iHor = pcCU->getSlice()->getIsDepth() ? pMv->getHor() : ( ( pMv->getHor() + 2 ) >> 2 );
    2145   iVer = pcCU->getSlice()->getIsDepth() ? pMv->getVer() : ( ( pMv->getVer() + 2 ) >> 2 );
    2146   if( !isLuma(compID) )
    2147   {
    2148     iHor = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getHor() + 1 ) >> 1 ) : ( ( pMv->getHor() + 4 ) >> 3 );
    2149     iVer = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getVer() + 1 ) >> 1 ) : ( ( pMv->getVer() + 4 ) >> 3 );
    2150   }
    2151   uiWidth  = pcCU->getWidth( 0 ) >> pRefPic->getComponentScaleX(compID);
    2152   uiHeight = pcCU->getHeight( 0 ) >> pRefPic->getComponentScaleY(compID);
    2153 
    2154   Int i, j, iCountShift = 0;
    2155 
    2156   // LLS parameters estimation
    2157 
    2158   Int x = 0, y = 0, xx = 0, xy = 0;
    2159   Int precShift = std::max(0, bitDepth - 12);
    2160 
    2161   UInt partAddr = 0;
    2162   if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCtu() ) )
    2163   {
    2164     iRefOffset = iHor + iVer * iRefStride - iRefStride;
    2165     pRef = pRefPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) + iRefOffset;
    2166     pRec = pRecPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) - iRecStride;
    2167     for( j = 0; j < uiWidth; j+=2 )
    2168     {
    2169       x += pRef[j];
    2170       y += pRec[j];
    2171       if( isLuma(compID) )
    2172       {
    2173         xx += (pRef[j] * pRef[j])>>precShift;
    2174         xy += (pRef[j] * pRec[j])>>precShift;
    2175       }
    2176     }
    2177     iCountShift += g_aucConvertToBit[ uiWidth ] + 1;
    2178   }
    2179 
    2180   if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCtu() ) )
    2181   {
    2182     iRefOffset = iHor + iVer * iRefStride - 1;
    2183     pRef = pRefPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) + iRefOffset;
    2184     pRec = pRecPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) - 1;
    2185     for( i = 0; i < uiHeight; i+=2 )
    2186     {
    2187       x += pRef[0];
    2188       y += pRec[0];
    2189       if( isLuma(compID) )
    2190       {
    2191         xx += (pRef[0] * pRef[0])>>precShift;
    2192         xy += (pRef[0] * pRec[0])>>precShift;
    2193       }
    2194       pRef += iRefStride*2;
    2195       pRec += iRecStride*2;
    2196     }
    2197     iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 1 );
    2198   }
    2199 
    2200   if( iCountShift == 0 )
    2201   {
    2202     a = ( 1 << IC_CONST_SHIFT );
    2203     b = 0;
    2204     return;
    2205   }
    2206 
    2207   if( !isLuma(compID) )
    2208   {
    2209     a = ( 1 << IC_CONST_SHIFT );
    2210     b = (  y - x + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift;
    2211   }
    2212   else
    2213   {
    2214   xy += xx >> IC_REG_COST_SHIFT;
    2215   xx += xx >> IC_REG_COST_SHIFT;
    2216   Int a1 = ( xy << iCountShift ) - ((y * x) >> precShift);
    2217   Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift);
    2218   const Int iShift = IC_CONST_SHIFT;
    2219       const Int iShiftA2 = 6;
    2220       const Int iAccuracyShift = 15;
    2221 
    2222       Int iScaleShiftA2 = 0;
    2223       Int iScaleShiftA1 = 0;
    2224     Int a1s;
    2225     Int a2s;
    2226 
    2227       a1 = Clip3(0, 2*a2, a1);
    2228       iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2;
    2229       iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF;
    2230 
    2231       if( iScaleShiftA1 < 0 )
    2232       {
    2233         iScaleShiftA1 = 0;
    2234       }
    2235 
    2236       if( iScaleShiftA2 < 0 )
    2237       {
    2238         iScaleShiftA2 = 0;
    2239       }
    2240 
    2241       Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1;
    2242 
    2243 
    2244       a2s = a2 >> iScaleShiftA2;
    2245 
    2246       a1s = a1 >> iScaleShiftA1;
    2247 
    2248       a = a1s * m_uiaShift[ a2s ];
    2249       a = a >> iScaleShiftA;
    2250       b = (  y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift;
    2251     }
    2252   }   
    2253 #endif
    2254 
    2255 #if NH_3D_SDC_INTRA
    2256 Void TComPrediction::predConstantSDC( Pel* ptrSrc, UInt srcStride, UInt uiSize, Pel& predDC )
    2257 {
    2258   Pel* pLeftTop     =  ptrSrc;
    2259   Pel* pRightTop    =  ptrSrc                          + (uiSize-1);
    2260   Pel* pLeftBottom  = (ptrSrc+ (srcStride*(uiSize-1))              );
    2261   Pel* pRightBottom = (ptrSrc+ (srcStride*(uiSize-1))  + (uiSize-1));
    2262   predDC = (*pLeftTop + *pRightTop + *pLeftBottom + *pRightBottom + 2)>>2;
    2263 }
    2264 #endif // NH_3D_SDC_INTRA
    2265 
    2266 #if NH_3D_DMM
    2267 Void TComPrediction::predContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool* segPattern )
    2268 {
    2269   // get copy of co-located texture luma block
    2270   TComYuv cTempYuv;
    2271   cTempYuv.create( uiWidth, uiHeight, CHROMA_400 );
    2272   cTempYuv.clear();
    2273   Pel* piRefBlkY = cTempYuv.getAddr( COMPONENT_Y );
    2274   TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec();
    2275   assert( pcPicYuvRef != NULL );
    2276   Int  iRefStride = pcPicYuvRef->getStride( COMPONENT_Y );
    2277   Pel* piRefY     = pcPicYuvRef->getAddr  ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
    2278 
    2279   for( Int y = 0; y < uiHeight; y++ )
    2280   {
    2281     ::memcpy(piRefBlkY, piRefY, sizeof(Pel)*uiWidth);
    2282     piRefBlkY += uiWidth;
    2283     piRefY += iRefStride;
    2284   }
    2285 
    2286 
    2287   // find contour for texture luma block
    2288   piRefBlkY = cTempYuv.getAddr( COMPONENT_Y );
    2289   UInt iDC = 0;
    2290   iDC  = piRefBlkY[ 0 ];
    2291   iDC += piRefBlkY[ uiWidth - 1 ];
    2292   iDC += piRefBlkY[ uiWidth * (uiHeight - 1) ];
    2293   iDC += piRefBlkY[ uiWidth * (uiHeight - 1) + uiWidth - 1 ];
    2294   iDC = iDC >> 2;
    2295 
    2296   piRefBlkY = cTempYuv.getAddr( COMPONENT_Y );
    2297   for( UInt k = 0; k < (uiWidth*uiHeight); k++ )
    2298   {
    2299     segPattern[k] = (piRefBlkY[k] > iDC) ? true : false;
    2300   }
    2301 
    2302   cTempYuv.destroy();
    2303 }
    2304 
    2305 Void TComPrediction::predBiSegDCs( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 )
    2306 {
    2307   assert( biSegPattern );
    2308   const Pel *piMask = getPredictorPtr( COMPONENT_Y, false );
    2309   assert( piMask );
    2310   Int srcStride = 2*uiWidth + 1;
    2311   const Pel *ptrSrc = piMask+srcStride+1;
    2312 
    2313   Int  refDC1, refDC2;
    2314   const Int  iTR = (   patternStride - 1        ) - srcStride;
    2315   const Int  iTM = ( ( patternStride - 1 ) >> 1 ) - srcStride;
    2316   const Int  iLB = (   patternStride - 1        ) * srcStride - 1;
    2317   const Int  iLM = ( ( patternStride - 1 ) >> 1 ) * srcStride - 1;
    2318 
    2319   Bool bL = ( biSegPattern[0] != biSegPattern[(patternStride-1)*patternStride] );
    2320   Bool bT = ( biSegPattern[0] != biSegPattern[(patternStride-1)]               );
    2321 
    2322   if( bL == bT )
    2323   {
    2324     const Int  iTRR = ( patternStride * 2 - 1  ) - srcStride;
    2325     const Int  iLBB = ( patternStride * 2 - 1  ) * srcStride - 1;
    2326     refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : (abs(ptrSrc[iTRR] - ptrSrc[-(Int)srcStride]) > abs(ptrSrc[iLBB] - ptrSrc[ -1]) ? ptrSrc[iTRR] : ptrSrc[iLBB]);
    2327     refDC2 =      ( ptrSrc[ -1] + ptrSrc[-(Int)srcStride] )>>1;
    2328   }
    2329   else
    2330   {
    2331     refDC1 = bL ? ptrSrc[iLB] : ptrSrc[iTR];
    2332     refDC2 = bL ? ptrSrc[iTM] : ptrSrc[iLM];
    2333   }
    2334 
    2335   predDC1 = biSegPattern[0] ? refDC1 : refDC2;
    2336   predDC2 = biSegPattern[0] ? refDC2 : refDC1;
    2337 }
    2338 
    2339 Void TComPrediction::assignBiSegDCs( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 )
    2340 {
    2341   assert( biSegPattern );
    2342   if( dstStride == patternStride )
    2343   {
    2344     for( UInt k = 0; k < (patternStride * patternStride); k++ )
    2345     {
    2346       if( true == biSegPattern[k] ) { ptrDst[k] = valDC2; }
    2347       else                          { ptrDst[k] = valDC1; }
    2348     }
    2349   }
    2350   else
    2351   {
    2352     Pel* piTemp = ptrDst;
    2353     for( UInt uiY = 0; uiY < patternStride; uiY++ )
    2354     {
    2355       for( UInt uiX = 0; uiX < patternStride; uiX++ )
    2356       {
    2357         if( true == biSegPattern[uiX] ) { piTemp[uiX] = valDC2; }
    2358         else                            { piTemp[uiX] = valDC1; }
    2359       }
    2360       piTemp       += dstStride;
    2361       biSegPattern += patternStride;
    2362     }
    2363   }
    2364 }
    2365 #endif
     864
     865
    2366866//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComPrediction.h

    r1386 r1390  
    4545#include "TComWeightPrediction.h"
    4646
    47 #if NH_3D_ARP
    48 #include "TComPic.h"
    49 #endif
    5047// forward declaration
    5148class TComMv;
     
    8077  TComYuv   m_acYuvPred[NUM_REF_PIC_LIST_01];
    8178  TComYuv   m_cYuvPredTemp;
    82 #if NH_3D_ARP
    83   TComYuv   m_acYuvPredBase[2];
    84 #endif
    8579  TComYuv m_filteredBlock[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS];
    8680  TComYuv m_filteredBlockTmp[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS];
     
    9084  Pel*   m_pLumaRecBuffer;       ///< array for downsampled reconstructed luma sample
    9185  Int    m_iLumaRecStride;       ///< stride of #m_pLumaRecBuffer array
    92 #if NH_3D_IC
    93   UInt   m_uiaShift[ 64 ];       // Table for multiplication to substitue of division operation
    94 #endif
    9586
    96 #if NH_3D_VSP
    97   Int*    m_pDepthBlock;         ///< Store a depth block, local variable, to prevent memory allocation every time
    98   TComYuv m_cYuvDepthOnVsp;
    99 #endif
    10087  Void xPredIntraAng            ( Int bitDepth, const Pel* pSrc, Int srcStride, Pel* pDst, Int dstStride, UInt width, UInt height, ChannelType channelType, UInt dirMode, const Bool bEnableEdgeFilters );
    10188  Void xPredIntraPlanar         ( const Pel* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height );
    10289
    10390  // motion compensation functions
    104 #if NH_3D_ARP
    105   Void xPredInterUniARP         ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi );
    106   Void xPredInterUniARPviewRef  ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi );
    107   Bool xCheckBiInterviewARP     ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eBaseRefPicList, TComPic*& pcPicYuvCurrTRef, TComMv& cBaseTMV, Int& iCurrTRefPoc );
    108 #endif
    10991
    11092  Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv* pcYuvPred, Bool bi=false          );
    11193  Void xPredInterBi             ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv* pcYuvPred          );
    112 #if NH_3D_VSP
    113   Void xPredInterUniVSP         ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi=false          );
    114   Void xPredInterBiVSP          ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv*& rpcYuvPred );
    115 #endif
    11694
    117 #if NH_3D
    118   Void xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth
    119 #if NH_3D_ARP
    120     , Bool filterType = false
    121 #endif
    122 #if NH_3D_IC
    123     , Bool bICFlag    = false
    124 #endif
    125  );
    126 #else
    12795  Void xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth );
    128 #endif
    129 #if NH_3D_VSP
    130   Void xPredInterUniSubPU        ( TComDataCU *cu, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU=4, Int heightSubPU=4 );
    131 #endif
    13296
    13397  Void xWeightedAverage         ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* pcYuvDst, const BitDepths &clipBitDepths  );
    13498
    13599  Void xGetLLSPrediction ( const Pel* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0, const ChromaFormat chFmt  DEBUG_STRING_FN_DECLARE(sDebug) );
    136 #if NH_3D_IC
    137   Void xGetLLSICPrediction( const ComponentID compID, TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, const Int bitDepth);
    138 #endif
    139100  Void xDCPredFiltering( const Pel* pSrc, Int iSrcStride, Pel* pDst, Int iDstStride, Int iWidth, Int iHeight, ChannelType channelType );
    140101  Bool xCheckIdenticalMotion    ( TComDataCU* pcCU, UInt PartAddr);
    141 #if NH_3D_SPIVMP
    142   Bool xCheckTwoSPMotion ( TComDataCU* pcCU, UInt PartAddr0, UInt PartAddr1 );
    143   Void xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr );
    144 #endif
    145102
    146103  Void destroy();
     
    164121
    165122  Pel  predIntraGetPredValDC      ( const Pel* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight);
    166 #if NH_3D_DMM
    167   Void predIntraLumaDmm           ( TComDataCU* pcCU, UInt uiAbsPartIdx, DmmID dmmType, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight );
    168   Void predContourFromTex         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool* segPattern );
    169   Void predBiSegDCs               ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 );
    170   Void assignBiSegDCs             ( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 );
    171 #endif
    172 #if NH_3D_SDC_INTRA
    173   Void predConstantSDC            ( Pel* ptrSrc, UInt srcStride, UInt uiSize, Pel& predDC );
    174 #endif
    175123 
    176 #if NH_3D_DBBP
    177   PartSize      getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize, TComDataCU*& pcCU);
    178   Bool          getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask, TComDataCU*& pcCU);
    179   Void          combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize, Int bitDepthY );
    180 #endif
    181 #if NH_3D
    182   Pel  predIntraGetPredValDC      ( const Pel* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft );
    183 #endif
    184124  Pel*  getPredictorPtr           ( const ComponentID compID, const Bool bUseFilteredPredictions )
    185125  {
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComRdCost.cpp

    r1386 r1390  
    4141#include "TComRom.h"
    4242#include "TComRdCost.h"
    43 #if NH_3D_VSO
    44 #include "TComDataCU.h"
    45 #include "TComRectangle.h"
    46 #endif
    4743
    4844//! \ingroup TLibCommon
    4945//! \{
    5046
    51 #if NH_3D_VSO
    52 // SAIT_VSO_EST_A0033
    53 Double TComRdCost::m_dDisparityCoeff = 1.0;
    54 #endif
    5547TComRdCost::TComRdCost()
    5648{
     
    6355
    6456// Calculate RD functions
    65 #if NH_3D_VSO
    66 Double TComRdCost::calcRdCost( Double numBits, Dist intDistortion, DFunc eDFunc )
    67 {
    68   Double distortion = (Double) intDistortion;
    69 #else
    7057Double TComRdCost::calcRdCost( Double numBits, Double distortion, DFunc eDFunc )
    7158{
    72 #endif
    7359 
    7460  Double lambda = 1.0;
     
    183169  m_afpDistortFunc[DF_HADS16N] = TComRdCost::xGetHADs;
    184170
    185 #if NH_3D_VSO
    186   // SAIT_VSO_EST_A0033
    187   m_afpDistortFunc[29]  = TComRdCost::xGetVSD;
    188   m_afpDistortFunc[30]  = TComRdCost::xGetVSD4;
    189   m_afpDistortFunc[31]  = TComRdCost::xGetVSD8;
    190   m_afpDistortFunc[32]  = TComRdCost::xGetVSD16;
    191   m_afpDistortFunc[33]  = TComRdCost::xGetVSD32;
    192   m_afpDistortFunc[34]  = TComRdCost::xGetVSD64;
    193   m_afpDistortFunc[35]  = TComRdCost::xGetVSD16N;
    194 #endif
    195171
    196172  m_costMode                   = COST_STANDARD_LOSSY;
     
    199175  m_iCostScale                 = 0;
    200176
    201 #if NH_3D_VSO
    202   m_bUseVSO                 = false;
    203   m_uiVSOMode               = 0;
    204   m_fpDistortFuncVSO        = NULL;
    205   m_pcRenModel              = NULL;
    206 
    207   // SAIT_VSO_EST_A0033
    208   m_bUseEstimatedVSD        = false;
    209 #endif
    210 #if NH_3D_DBBP
    211   m_bUseMask                = false;
    212 #endif
    213177
    214178}
     
    237201  rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
    238202
    239 #if NH_3D_DBBP
    240   if( m_bUseMask )
    241   {
    242     if( eDFunc >= DF_SSE && eDFunc <= DF_SSE16N )
    243     {
    244       rcDistParam.DistFunc = TComRdCost::xGetMaskedSSE;
    245     }
    246     else if( eDFunc >= DF_SAD && eDFunc <= DF_SADS16N )
    247     {
    248       rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD;
    249     }
    250     else if( eDFunc >= DF_HADS && eDFunc <= DF_HADS16N )
    251     {
    252       rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD;
    253     }
    254     else if( eDFunc >= DF_VSD && eDFunc <= DF_VSD16N )
    255     {
    256       rcDistParam.DistFunc = TComRdCost::xGetMaskedVSD;
    257     }
    258     else if( eDFunc >= DF_SAD12 && eDFunc <= DF_SADS48 )
    259     {
    260       rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD;
    261     }
    262   }
    263 #endif
    264203  // initialize
    265204  rcDistParam.iSubShift  = 0;
     
    296235  }
    297236
    298 #if NH_3D_DBBP
    299   if( m_bUseMask )
    300   {
    301     rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD;
    302   }
    303 #endif
    304237  // initialize
    305238  rcDistParam.iSubShift  = 0;
     
    347280  }
    348281
    349 #if NH_3D_DBBP
    350   if( m_bUseMask )
    351   {
    352     rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD;
    353   }
    354 #endif
    355282  // initialize
    356283  rcDistParam.iSubShift  = 0;
     
    370297  rcDP.DistFunc   = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ];
    371298  rcDP.m_maximumDistortionForEarlyExit = std::numeric_limits<Distortion>::max();
    372 #if NH_3D_DBBP
    373   if( m_bUseMask )
    374   {
    375     rcDP.DistFunc = TComRdCost::xGetMaskedSAD;
    376   }
    377 #endif
    378299}
    379300
     
    413334}
    414335
    415 #if NH_3D_ENC_DEPTH
    416 UInt TComRdCost::calcVAR (Pel* pi0, Int stride, Int width, Int height, Int cuDepth, UInt maxCuWidth)
    417 {
    418   Int temp = 0;
    419 
    420   for (Int y = 0; y < height; y++)
    421   {
    422     for (Int x = 0; x < width; x++)
    423     {
    424       temp += pi0[ y * stride + x ];
    425     }
    426   }
    427 
    428   Int cuMaxLog2Size = g_aucConvertToBit[maxCuWidth]+2;
    429  
    430   if ( width == 4 )
    431   {
    432     cuDepth = cuMaxLog2Size - 2;
    433   }
    434 
    435   temp = temp >> (cuMaxLog2Size-cuDepth) * 2;
    436 
    437   UInt sum = 0;
    438   for (Int y = 0; y < height; y++)
    439   {
    440     for (Int x = 0; x <  width; x++)
    441     {
    442       sum += (pi0[ y * stride + x ] - temp ) * (pi0[ y * stride + x ] - temp );
    443     }
    444   }
    445   return (sum >> (cuMaxLog2Size-cuDepth)*2);
    446 
    447 }
    448 #endif
    449336
    450337
     
    463350  cDtParam.bitDepth     = bitDepth;
    464351
    465 #if NH_3D_IC
    466   cDtParam.bUseIC       = false;
    467 #endif
    468 #if NH_3D_SDC_INTER
    469   cDtParam.bUseSDCMRSAD = false;
    470 #endif
    471352
    472353  if (isChroma(compID))
     
    479360  }
    480361}
    481 #if NH_3D_VSO
    482 // SAIT_VSO_EST_A0033
    483 UInt TComRdCost::getDistPartVSD( TComDataCU* pcCU, UInt uiPartOffset, Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight,  Bool bHAD, DFunc eDFunc )
    484 {
    485   AOT( ( m_dDisparityCoeff <= 0 ) || ( m_dDisparityCoeff > 10 ) );
    486 
    487   Pel* piVirRec  = m_pcVideoRecPicYuv->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr( ), pcCU->getZorderIdxInCtu()+uiPartOffset );
    488   Pel* piVirOrg  = m_pcDepthPicYuv   ->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr( ), pcCU->getZorderIdxInCtu()+uiPartOffset );
    489   Int iVirStride = m_pcVideoRecPicYuv->getStride( COMPONENT_Y );   
    490 
    491   DistParam cDtParam;
    492   setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam );
    493   cDtParam.pOrg       = piOrg;
    494   cDtParam.pCur       = piCur;
    495   cDtParam.pVirRec    = piVirRec;
    496   cDtParam.pVirOrg    = piVirOrg;
    497   cDtParam.iStrideVir = iVirStride;
    498   cDtParam.iStrideOrg = iOrgStride;
    499   cDtParam.iStrideCur = iCurStride;
    500   cDtParam.iStep      = 1;
    501 
    502   cDtParam.bApplyWeight = false; 
    503 
    504   cDtParam.bitDepth   = bitDepth;
    505 #if NH_3D
    506   cDtParam.bUseIC       = false;
    507 #endif
    508 #if NH_3D_SDC_INTER
    509   cDtParam.bUseSDCMRSAD = false;
    510 #endif
    511 
    512   Dist dist = cDtParam.DistFunc( &cDtParam );
    513 
    514   if ( m_bUseWVSO )   
    515   {
    516     Int iDWeight   = m_iDWeight   * m_iDWeight;
    517     Int iVSOWeight = m_iVSDWeight * m_iVSDWeight;
    518     Dist distDepth;
    519 
    520     if ( !bHAD )
    521     {
    522       distDepth = (Dist) getDistPart( bitDepth, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight, COMPONENT_Y);
    523     }
    524     else
    525     {
    526       distDepth = (Dist) calcHAD( bitDepth, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
    527     }
    528 
    529     dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight);
    530   }
    531 
    532   return (UInt) dist;
    533 }
    534 #endif
    535 
    536 #if KWU_RC_MADPRED_E0227
    537 UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height )
    538 {
    539   UInt SAD = 0;
    540   Int shift = DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8);
    541   for ( Int i=0; i<height; i++ )
    542   {
    543     for( Int j=0; j<width; j++ )
    544     {
    545       SAD += abs((pelCur[j] - pelOrg[j])) >> shift;
    546     }
    547     pelCur = pelCur + curStride;
    548     pelOrg = pelOrg + orgStride;
    549   }
    550   return SAD;
    551 }
    552 #endif
     362
    553363
    554364// ====================================================================================================================
     
    556366// ====================================================================================================================
    557367
    558 #if NH_3D_DBBP
    559 // --------------------------------------------------------------------------------------------------------------------
    560 // Masked distortion functions
    561 // --------------------------------------------------------------------------------------------------------------------
    562 
    563 UInt TComRdCost::xGetMaskedSSE( DistParam* pcDtParam )
    564 {
    565   const Pel* piOrg   = pcDtParam->pOrg;
    566   const Pel* piCur   = pcDtParam->pCur;
    567   Int  iRows   = pcDtParam->iRows;
    568   Int  iCols   = pcDtParam->iCols;
    569   Int  iStrideOrg = pcDtParam->iStrideOrg;
    570   Int  iStrideCur = pcDtParam->iStrideCur;
    571  
    572   UInt uiSum = 0;
    573  
    574   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    575  
    576   Int iTemp;
    577  
    578   for( ; iRows != 0; iRows-- )
    579   {
    580     for (Int n = 0; n < iCols; n++ )
    581     {
    582       if( piOrg[n] != DBBP_INVALID_SHORT )
    583       {
    584         iTemp = piOrg[n  ] - piCur[n  ];
    585         uiSum += ( iTemp * iTemp ) >> uiShift;
    586       }
    587     }
    588     piOrg += iStrideOrg;
    589     piCur += iStrideCur;
    590   }
    591  
    592   return ( uiSum );
    593 }
    594 
    595 UInt TComRdCost::xGetMaskedSAD( DistParam* pcDtParam )
    596 {
    597  
    598   AOF(!pcDtParam->bApplyWeight);
    599 #if NH_3D_IC
    600   AOF(!pcDtParam->bUseIC);
    601 #endif
    602  
    603   const Pel* piOrg   = pcDtParam->pOrg;
    604   const Pel* piCur   = pcDtParam->pCur;
    605   Int  iRows   = pcDtParam->iRows;
    606   Int  iCols   = pcDtParam->iCols;
    607   Int  iStrideCur = pcDtParam->iStrideCur;
    608   Int  iStrideOrg = pcDtParam->iStrideOrg;
    609  
    610   UInt uiSum = 0;
    611  
    612   for( ; iRows != 0; iRows-- )
    613   {
    614     for (Int n = 0; n < iCols; n++ )
    615     {
    616       if( piOrg[n] != DBBP_INVALID_SHORT )
    617       {
    618         uiSum += abs( piOrg[n] - piCur[n] );
    619       }
    620     }
    621     piOrg += iStrideOrg;
    622     piCur += iStrideCur;
    623   }
    624  
    625   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    626 }
    627 
    628 
    629 UInt TComRdCost::xGetMaskedVSD( DistParam* pcDtParam )
    630 {
    631   const Pel* piOrg    = pcDtParam->pOrg;
    632   const Pel* piCur    = pcDtParam->pCur;
    633   const Pel* piVirRec = pcDtParam->pVirRec;
    634   const Pel* piVirOrg = pcDtParam->pVirOrg;
    635   Int  iRows    = pcDtParam->iRows;
    636   Int  iCols    = pcDtParam->iCols;
    637   Int  iStrideOrg = pcDtParam->iStrideOrg;
    638   Int  iStrideCur = pcDtParam->iStrideCur;
    639   Int  iStrideVir = pcDtParam->iStrideVir;
    640  
    641   UInt uiSum = 0;
    642   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    643  
    644   Int dDM;
    645  
    646   for ( Int y = 0 ; y < iRows ; y++ )
    647   {
    648     for (Int x = 0; x < iCols; x++ )
    649     {
    650       if( piOrg[x] != DBBP_INVALID_SHORT )
    651       {
    652         dDM = (Int) ( piOrg[x  ] - piCur[x  ] );
    653         uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
    654       }
    655     }
    656     piOrg += iStrideOrg;
    657     piCur += iStrideCur;
    658   }
    659  
    660   return ( uiSum );
    661 }
    662 #endif
    663368// --------------------------------------------------------------------------------------------------------------------
    664369// SAD
     
    671376    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    672377  }
    673 #if NH_3D_IC
    674   if( pcDtParam->bUseIC )
    675   {
    676     return xGetSADic( pcDtParam );
    677   }
    678 #endif
    679 #if NH_3D_SDC_INTER
    680   if( pcDtParam->bUseSDCMRSAD )
    681   {
    682     return xGetSADic( pcDtParam );
    683   }
    684 #endif
    685378
    686379  const Pel* piOrg   = pcDtParam->pOrg;
     
    717410  }
    718411
    719 #if NH_3D_IC
    720   if( pcDtParam->bUseIC )
    721   {
    722     return xGetSAD4ic( pcDtParam );
    723   }
    724 #endif
    725 #if NH_3D_SDC_INTER
    726   if( pcDtParam->bUseSDCMRSAD )
    727   {
    728     return xGetSAD4ic( pcDtParam );
    729   }
    730 #endif
    731412
    732413  const Pel* piOrg   = pcDtParam->pOrg;
     
    762443  }
    763444
    764 #if NH_3D_IC
    765   if( pcDtParam->bUseIC )
    766   {
    767     return xGetSAD8ic( pcDtParam );
    768   }
    769 #endif
    770 #if NH_3D_SDC_INTER
    771   if( pcDtParam->bUseSDCMRSAD )
    772   {
    773     return xGetSAD8ic( pcDtParam );
    774   }
    775 #endif
    776445
    777446  const Pel* piOrg      = pcDtParam->pOrg;
     
    811480  }
    812481
    813 #if NH_3D_IC
    814   if( pcDtParam->bUseIC )
    815   {
    816     return xGetSAD16ic( pcDtParam );
    817   }
    818 #endif
    819 #if NH_3D_SDC_INTER
    820   if( pcDtParam->bUseSDCMRSAD )
    821   {
    822     return xGetSAD16ic( pcDtParam );
    823   }
    824 #endif
    825482
    826483  const Pel* piOrg   = pcDtParam->pOrg;
     
    867524    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    868525  }
    869 #if NH_3D_IC
    870   if( pcDtParam->bUseIC )
    871   {
    872     return xGetSAD12ic( pcDtParam );
    873   }
    874 #endif
    875 #if NH_3D_SDC_INTER
    876   if( pcDtParam->bUseSDCMRSAD )
    877   {
    878     return xGetSAD12ic( pcDtParam );
    879   }
    880 #endif
    881526
    882527  const Pel* piOrg   = pcDtParam->pOrg;
     
    915560Distortion TComRdCost::xGetSAD16N( DistParam* pcDtParam )
    916561{
    917 #if NH_3D_IC
    918   if( pcDtParam->bUseIC )
    919   {
    920     return xGetSAD16Nic( pcDtParam );
    921   }
    922 #endif
    923 #if NH_3D_SDC_INTER
    924   if( pcDtParam->bUseSDCMRSAD )
    925   {
    926     return xGetSAD16Nic( pcDtParam );
    927   }
    928 #endif
    929562
    930563  const Pel* piOrg   = pcDtParam->pOrg;
     
    975608  }
    976609
    977 #if NH_3D_IC
    978   if( pcDtParam->bUseIC )
    979   {
    980     return xGetSAD32ic( pcDtParam );
    981   }
    982 #endif
    983 #if NH_3D_SDC_INTER
    984   if( pcDtParam->bUseSDCMRSAD )
    985   {
    986     return xGetSAD32ic( pcDtParam );
    987   }
    988 #endif
    989610
    990611  const Pel* piOrg   = pcDtParam->pOrg;
     
    1048669  }
    1049670
    1050 #if NH_3D_IC
    1051   if( pcDtParam->bUseIC )
    1052   {
    1053     return xGetSAD24ic( pcDtParam );
    1054   }
    1055 #endif
    1056 #if NH_3D_SDC_INTER
    1057   if( pcDtParam->bUseSDCMRSAD )
    1058   {
    1059     return xGetSAD24ic( pcDtParam );
    1060   }
    1061 #endif
    1062671
    1063672  const Pel* piOrg   = pcDtParam->pOrg;
     
    1113722  }
    1114723
    1115 #if NH_3D_IC
    1116   if( pcDtParam->bUseIC )
    1117   {
    1118     return xGetSAD64ic( pcDtParam );
    1119   }
    1120 #endif
    1121 #if NH_3D_SDC_INTER
    1122   if( pcDtParam->bUseSDCMRSAD )
    1123   {
    1124     return xGetSAD64ic( pcDtParam );
    1125   }
    1126 #endif
    1127724
    1128725  const Pel* piOrg   = pcDtParam->pOrg;
     
    1217814    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    1218815  }
    1219 #if NH_3D_IC
    1220   if( pcDtParam->bUseIC )
    1221   {
    1222     return xGetSAD48ic( pcDtParam );
    1223   }
    1224 #endif
    1225 #if NH_3D_SDC_INTER
    1226   if( pcDtParam->bUseSDCMRSAD )
    1227   {
    1228     return xGetSAD48ic( pcDtParam );
    1229   }
    1230 #endif
    1231816
    1232817  const Pel* piOrg   = pcDtParam->pOrg;
     
    1300885
    1301886
    1302 #if NH_3D_IC || NH_3D_SDC_INTER
    1303 UInt TComRdCost::xGetSADic( DistParam* pcDtParam )
    1304 {
    1305   if ( pcDtParam->bApplyWeight )
    1306   {
    1307     return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    1308   }
    1309   const Pel* piOrg   = pcDtParam->pOrg;
    1310   const Pel* piCur   = pcDtParam->pCur;
    1311   Int  iRows   = pcDtParam->iRows;
    1312   Int  iCols   = pcDtParam->iCols;
    1313   Int  iStrideCur = pcDtParam->iStrideCur;
    1314   Int  iStrideOrg = pcDtParam->iStrideOrg;
    1315 
    1316   UInt uiSum = 0;
    1317 
    1318   Int  iOrigAvg = 0, iCurAvg = 0;
    1319   Int  iDeltaC;
    1320 
    1321   for( ; iRows != 0; iRows-- )
    1322   {
    1323     for (Int n = 0; n < iCols; n++ )
    1324     {
    1325       iOrigAvg += piOrg[n];
    1326       iCurAvg  += piCur[n];
    1327     }
    1328     piOrg += iStrideOrg;
    1329     piCur += iStrideCur;
    1330   }
    1331 
    1332   piOrg   = pcDtParam->pOrg;
    1333   piCur   = pcDtParam->pCur;
    1334   iRows   = pcDtParam->iRows;
    1335 
    1336   iDeltaC = (iOrigAvg - iCurAvg)/iCols/iRows;
    1337 
    1338   for( ; iRows != 0; iRows-- )
    1339   {
    1340     for (Int n = 0; n < iCols; n++ )
    1341     {
    1342       uiSum += abs( piOrg[n] - piCur[n] - iDeltaC );
    1343     }
    1344     piOrg += iStrideOrg;
    1345     piCur += iStrideCur;
    1346   }
    1347 
    1348   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1349 }
    1350 
    1351 UInt TComRdCost::xGetSAD4ic( DistParam* pcDtParam )
    1352 {
    1353   if ( pcDtParam->bApplyWeight )
    1354   {
    1355     return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    1356   }
    1357   const Pel* piOrg   = pcDtParam->pOrg;
    1358   const Pel* piCur   = pcDtParam->pCur;
    1359   Int  iRows   = pcDtParam->iRows;
    1360   Int  iSubShift  = pcDtParam->iSubShift;
    1361   Int  iSubStep   = ( 1 << iSubShift );
    1362   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1363   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1364 
    1365   UInt uiSum = 0;
    1366 
    1367   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    1368   Int  iDeltaC;
    1369 
    1370   for( ; iRows != 0; iRows-=iSubStep )
    1371   {
    1372     iOrigAvg += piOrg[0];
    1373     iOrigAvg += piOrg[1];
    1374     iOrigAvg += piOrg[2];
    1375     iOrigAvg += piOrg[3];
    1376 
    1377     iCurAvg  += piCur[0];
    1378     iCurAvg  += piCur[1];
    1379     iCurAvg  += piCur[2];
    1380     iCurAvg  += piCur[3];
    1381 
    1382     piOrg += iStrideOrg;
    1383     piCur += iStrideCur;
    1384     uiRowCnt++;
    1385   }
    1386 
    1387   piOrg   = pcDtParam->pOrg;
    1388   piCur   = pcDtParam->pCur;
    1389   iRows   = pcDtParam->iRows;
    1390 
    1391   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/4) : 0;
    1392 
    1393   for( ; iRows != 0; iRows-=iSubStep )
    1394   {
    1395     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    1396     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    1397     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    1398     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    1399 
    1400     piOrg += iStrideOrg;
    1401     piCur += iStrideCur;
    1402   }
    1403 
    1404   uiSum <<= iSubShift;
    1405   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1406 }
    1407 
    1408 UInt TComRdCost::xGetSAD8ic( DistParam* pcDtParam )
    1409 {
    1410   if ( pcDtParam->bApplyWeight )
    1411   {
    1412     return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    1413   }
    1414   const Pel* piOrg      = pcDtParam->pOrg;
    1415   const Pel* piCur      = pcDtParam->pCur;
    1416   Int  iRows      = pcDtParam->iRows;
    1417   Int  iSubShift  = pcDtParam->iSubShift;
    1418   Int  iSubStep   = ( 1 << iSubShift );
    1419   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1420   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1421 
    1422   UInt uiSum = 0;
    1423 
    1424   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    1425   Int  iDeltaC;
    1426 
    1427   for( ; iRows != 0; iRows-=iSubStep )
    1428   {
    1429     iOrigAvg += piOrg[0];
    1430     iOrigAvg += piOrg[1];
    1431     iOrigAvg += piOrg[2];
    1432     iOrigAvg += piOrg[3];
    1433     iOrigAvg += piOrg[4];
    1434     iOrigAvg += piOrg[5];
    1435     iOrigAvg += piOrg[6];
    1436     iOrigAvg += piOrg[7];
    1437 
    1438     iCurAvg  += piCur[0];
    1439     iCurAvg  += piCur[1];
    1440     iCurAvg  += piCur[2];
    1441     iCurAvg  += piCur[3];
    1442     iCurAvg  += piCur[4];
    1443     iCurAvg  += piCur[5];
    1444     iCurAvg  += piCur[6];
    1445     iCurAvg  += piCur[7];
    1446 
    1447     piOrg += iStrideOrg;
    1448     piCur += iStrideCur;
    1449     uiRowCnt++;
    1450   }
    1451 
    1452   piOrg   = pcDtParam->pOrg;
    1453   piCur   = pcDtParam->pCur;
    1454   iRows   = pcDtParam->iRows;
    1455 
    1456   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/8) : 0;
    1457 
    1458   for( ; iRows != 0; iRows-=iSubStep )
    1459   {
    1460     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    1461     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    1462     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    1463     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    1464     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    1465     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    1466     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    1467     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    1468 
    1469     piOrg += iStrideOrg;
    1470     piCur += iStrideCur;
    1471   }
    1472 
    1473   uiSum <<= iSubShift;
    1474   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1475 }
    1476 
    1477 UInt TComRdCost::xGetSAD16ic( DistParam* pcDtParam )
    1478 {
    1479   if ( pcDtParam->bApplyWeight )
    1480   {
    1481     return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    1482   }
    1483   const Pel* piOrg   = pcDtParam->pOrg;
    1484   const Pel* piCur   = pcDtParam->pCur;
    1485   Int  iRows   = pcDtParam->iRows;
    1486   Int  iSubShift  = pcDtParam->iSubShift;
    1487   Int  iSubStep   = ( 1 << iSubShift );
    1488   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1489   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1490 
    1491   UInt uiSum = 0;
    1492 
    1493   Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    1494   Int iDeltaC;
    1495 
    1496   for( ; iRows != 0; iRows-=iSubStep )
    1497   {
    1498     iOrigAvg += piOrg[0];
    1499     iOrigAvg += piOrg[1];
    1500     iOrigAvg += piOrg[2];
    1501     iOrigAvg += piOrg[3];
    1502     iOrigAvg += piOrg[4];
    1503     iOrigAvg += piOrg[5];
    1504     iOrigAvg += piOrg[6];
    1505     iOrigAvg += piOrg[7];
    1506     iOrigAvg += piOrg[8];
    1507     iOrigAvg += piOrg[9];
    1508     iOrigAvg += piOrg[10];
    1509     iOrigAvg += piOrg[11];
    1510     iOrigAvg += piOrg[12];
    1511     iOrigAvg += piOrg[13];
    1512     iOrigAvg += piOrg[14];
    1513     iOrigAvg += piOrg[15];
    1514 
    1515     iCurAvg  += piCur[0];
    1516     iCurAvg  += piCur[1];
    1517     iCurAvg  += piCur[2];
    1518     iCurAvg  += piCur[3];
    1519     iCurAvg  += piCur[4];
    1520     iCurAvg  += piCur[5];
    1521     iCurAvg  += piCur[6];
    1522     iCurAvg  += piCur[7];
    1523     iCurAvg  += piCur[8];
    1524     iCurAvg  += piCur[9];
    1525     iCurAvg  += piCur[10];
    1526     iCurAvg  += piCur[11];
    1527     iCurAvg  += piCur[12];
    1528     iCurAvg  += piCur[13];
    1529     iCurAvg  += piCur[14];
    1530     iCurAvg  += piCur[15];
    1531 
    1532     piOrg += iStrideOrg;
    1533     piCur += iStrideCur;
    1534     uiRowCnt++;
    1535   }
    1536 
    1537   piOrg   = pcDtParam->pOrg;
    1538   piCur   = pcDtParam->pCur;
    1539   iRows   = pcDtParam->iRows;
    1540 
    1541   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/16) : 0;
    1542 
    1543   for( ; iRows != 0; iRows-=iSubStep )
    1544   {
    1545     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    1546     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    1547     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    1548     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    1549     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    1550     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    1551     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    1552     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    1553     uiSum += abs( piOrg[8] - piCur[8] - iDeltaC );
    1554     uiSum += abs( piOrg[9] - piCur[9] - iDeltaC );
    1555     uiSum += abs( piOrg[10] - piCur[10] - iDeltaC );
    1556     uiSum += abs( piOrg[11] - piCur[11] - iDeltaC );
    1557     uiSum += abs( piOrg[12] - piCur[12] - iDeltaC );
    1558     uiSum += abs( piOrg[13] - piCur[13] - iDeltaC );
    1559     uiSum += abs( piOrg[14] - piCur[14] - iDeltaC );
    1560     uiSum += abs( piOrg[15] - piCur[15] - iDeltaC );
    1561 
    1562     piOrg += iStrideOrg;
    1563     piCur += iStrideCur;
    1564   }
    1565 
    1566   uiSum <<= iSubShift;
    1567   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1568 }
    1569 
    1570 UInt TComRdCost::xGetSAD12ic( DistParam* pcDtParam )
    1571 {
    1572   if ( pcDtParam->bApplyWeight )
    1573   {
    1574     return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    1575   }
    1576   const Pel* piOrg   = pcDtParam->pOrg;
    1577   const Pel* piCur   = pcDtParam->pCur;
    1578   Int  iRows   = pcDtParam->iRows;
    1579   Int  iSubShift  = pcDtParam->iSubShift;
    1580   Int  iSubStep   = ( 1 << iSubShift );
    1581   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1582   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1583 
    1584   UInt uiSum = 0;
    1585 
    1586   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    1587   Int  iDeltaC;
    1588 
    1589   for( ; iRows != 0; iRows-=iSubStep )
    1590   {
    1591     iOrigAvg += piOrg[0];
    1592     iOrigAvg += piOrg[1];
    1593     iOrigAvg += piOrg[2];
    1594     iOrigAvg += piOrg[3];
    1595     iOrigAvg += piOrg[4];
    1596     iOrigAvg += piOrg[5];
    1597     iOrigAvg += piOrg[6];
    1598     iOrigAvg += piOrg[7];
    1599     iOrigAvg += piOrg[8];
    1600     iOrigAvg += piOrg[9];
    1601     iOrigAvg += piOrg[10];
    1602     iOrigAvg += piOrg[11];
    1603 
    1604     iCurAvg  += piCur[0];
    1605     iCurAvg  += piCur[1];
    1606     iCurAvg  += piCur[2];
    1607     iCurAvg  += piCur[3];
    1608     iCurAvg  += piCur[4];
    1609     iCurAvg  += piCur[5];
    1610     iCurAvg  += piCur[6];
    1611     iCurAvg  += piCur[7];
    1612     iCurAvg  += piCur[8];
    1613     iCurAvg  += piCur[9];
    1614     iCurAvg  += piCur[10];
    1615     iCurAvg  += piCur[11];
    1616 
    1617     piOrg += iStrideOrg;
    1618     piCur += iStrideCur;
    1619     uiRowCnt++;
    1620   }
    1621 
    1622   piOrg   = pcDtParam->pOrg;
    1623   piCur   = pcDtParam->pCur;
    1624   iRows   = pcDtParam->iRows;
    1625 
    1626   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/12) : 0;
    1627 
    1628   for( ; iRows != 0; iRows-=iSubStep )
    1629   {
    1630     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    1631     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    1632     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    1633     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    1634     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    1635     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    1636     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    1637     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    1638     uiSum += abs( piOrg[8] - piCur[8] - iDeltaC );
    1639     uiSum += abs( piOrg[9] - piCur[9] - iDeltaC );
    1640     uiSum += abs( piOrg[10] - piCur[10] - iDeltaC );
    1641     uiSum += abs( piOrg[11] - piCur[11] - iDeltaC );
    1642 
    1643     piOrg += iStrideOrg;
    1644     piCur += iStrideCur;
    1645   }
    1646 
    1647   uiSum <<= iSubShift;
    1648   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1649 }
    1650 
    1651 
    1652 UInt TComRdCost::xGetSAD16Nic( DistParam* pcDtParam )
    1653 {
    1654   const Pel* piOrg   = pcDtParam->pOrg;
    1655   const Pel* piCur   = pcDtParam->pCur;
    1656   Int  iRows   = pcDtParam->iRows;
    1657   Int  iCols   = pcDtParam->iCols;
    1658   Int  iSubShift  = pcDtParam->iSubShift;
    1659   Int  iSubStep   = ( 1 << iSubShift );
    1660   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1661   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1662 
    1663   UInt uiSum = 0;
    1664 
    1665   Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0, uiColCnt = (iCols-1)/16 + 1;
    1666   Int  iDeltaC;
    1667 
    1668   for( ; iRows != 0; iRows-=iSubStep )
    1669   {
    1670     for (Int n = 0; n < iCols; n+=16 )
    1671     {
    1672       iOrigAvg += piOrg[n + 0];
    1673       iOrigAvg += piOrg[n + 1];
    1674       iOrigAvg += piOrg[n + 2];
    1675       iOrigAvg += piOrg[n + 3];
    1676       iOrigAvg += piOrg[n + 4];
    1677       iOrigAvg += piOrg[n + 5];
    1678       iOrigAvg += piOrg[n + 6];
    1679       iOrigAvg += piOrg[n + 7];
    1680       iOrigAvg += piOrg[n + 8];
    1681       iOrigAvg += piOrg[n + 9];
    1682       iOrigAvg += piOrg[n + 10];
    1683       iOrigAvg += piOrg[n + 11];
    1684       iOrigAvg += piOrg[n + 12];
    1685       iOrigAvg += piOrg[n + 13];
    1686       iOrigAvg += piOrg[n + 14];
    1687       iOrigAvg += piOrg[n + 15];
    1688 
    1689       iCurAvg  += piCur[n + 0];
    1690       iCurAvg  += piCur[n + 1];
    1691       iCurAvg  += piCur[n + 2];
    1692       iCurAvg  += piCur[n + 3];
    1693       iCurAvg  += piCur[n + 4];
    1694       iCurAvg  += piCur[n + 5];
    1695       iCurAvg  += piCur[n + 6];
    1696       iCurAvg  += piCur[n + 7];
    1697       iCurAvg  += piCur[n + 8];
    1698       iCurAvg  += piCur[n + 9];
    1699       iCurAvg  += piCur[n + 10];
    1700       iCurAvg  += piCur[n + 11];
    1701       iCurAvg  += piCur[n + 12];
    1702       iCurAvg  += piCur[n + 13];
    1703       iCurAvg  += piCur[n + 14];
    1704       iCurAvg  += piCur[n + 15];
    1705     }
    1706     piOrg += iStrideOrg;
    1707     piCur += iStrideCur;
    1708     uiRowCnt++;
    1709   }
    1710   piOrg   = pcDtParam->pOrg;
    1711   piCur   = pcDtParam->pCur;
    1712   iRows   = pcDtParam->iRows;
    1713 
    1714   iDeltaC = (uiRowCnt && uiColCnt) ? ((iOrigAvg - iCurAvg)/uiRowCnt/uiColCnt/16) : 0;
    1715 
    1716   for( ; iRows != 0; iRows-=iSubStep )
    1717   {
    1718     for (Int n = 0; n < iCols; n+=16 )
    1719     {
    1720       uiSum += abs( piOrg[n+ 0] - piCur[n+ 0] - iDeltaC );
    1721       uiSum += abs( piOrg[n+ 1] - piCur[n+ 1] - iDeltaC );
    1722       uiSum += abs( piOrg[n+ 2] - piCur[n+ 2] - iDeltaC );
    1723       uiSum += abs( piOrg[n+ 3] - piCur[n+ 3] - iDeltaC );
    1724       uiSum += abs( piOrg[n+ 4] - piCur[n+ 4] - iDeltaC );
    1725       uiSum += abs( piOrg[n+ 5] - piCur[n+ 5] - iDeltaC );
    1726       uiSum += abs( piOrg[n+ 6] - piCur[n+ 6] - iDeltaC );
    1727       uiSum += abs( piOrg[n+ 7] - piCur[n+ 7] - iDeltaC );
    1728       uiSum += abs( piOrg[n+ 8] - piCur[n+ 8] - iDeltaC );
    1729       uiSum += abs( piOrg[n+ 9] - piCur[n+ 9] - iDeltaC );
    1730       uiSum += abs( piOrg[n+10] - piCur[n+10] - iDeltaC );
    1731       uiSum += abs( piOrg[n+11] - piCur[n+11] - iDeltaC );
    1732       uiSum += abs( piOrg[n+12] - piCur[n+12] - iDeltaC );
    1733       uiSum += abs( piOrg[n+13] - piCur[n+13] - iDeltaC );
    1734       uiSum += abs( piOrg[n+14] - piCur[n+14] - iDeltaC );
    1735       uiSum += abs( piOrg[n+15] - piCur[n+15] - iDeltaC );
    1736     }
    1737     piOrg += iStrideOrg;
    1738     piCur += iStrideCur;
    1739   }
    1740 
    1741   uiSum <<= iSubShift;
    1742   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1743 }
    1744 
    1745 UInt TComRdCost::xGetSAD32ic( DistParam* pcDtParam )
    1746 {
    1747   if ( pcDtParam->bApplyWeight )
    1748   {
    1749     return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    1750   }
    1751   const Pel* piOrg   = pcDtParam->pOrg;
    1752   const Pel* piCur   = pcDtParam->pCur;
    1753   Int  iRows   = pcDtParam->iRows;
    1754   Int  iSubShift  = pcDtParam->iSubShift;
    1755   Int  iSubStep   = ( 1 << iSubShift );
    1756   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1757   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1758 
    1759   UInt uiSum = 0;
    1760 
    1761   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    1762   Int  iDeltaC;
    1763 
    1764   for( ; iRows != 0; iRows-=iSubStep )
    1765   {
    1766     iOrigAvg += piOrg[0];
    1767     iOrigAvg += piOrg[1];
    1768     iOrigAvg += piOrg[2];
    1769     iOrigAvg += piOrg[3];
    1770     iOrigAvg += piOrg[4];
    1771     iOrigAvg += piOrg[5];
    1772     iOrigAvg += piOrg[6];
    1773     iOrigAvg += piOrg[7];
    1774     iOrigAvg += piOrg[8];
    1775     iOrigAvg += piOrg[9];
    1776     iOrigAvg += piOrg[10];
    1777     iOrigAvg += piOrg[11];
    1778     iOrigAvg += piOrg[12];
    1779     iOrigAvg += piOrg[13];
    1780     iOrigAvg += piOrg[14];
    1781     iOrigAvg += piOrg[15];
    1782     iOrigAvg += piOrg[16];
    1783     iOrigAvg += piOrg[17];
    1784     iOrigAvg += piOrg[18];
    1785     iOrigAvg += piOrg[19];
    1786     iOrigAvg += piOrg[20];
    1787     iOrigAvg += piOrg[21];
    1788     iOrigAvg += piOrg[22];
    1789     iOrigAvg += piOrg[23];
    1790     iOrigAvg += piOrg[24];
    1791     iOrigAvg += piOrg[25];
    1792     iOrigAvg += piOrg[26];
    1793     iOrigAvg += piOrg[27];
    1794     iOrigAvg += piOrg[28];
    1795     iOrigAvg += piOrg[29];
    1796     iOrigAvg += piOrg[30];
    1797     iOrigAvg += piOrg[31];
    1798 
    1799     iCurAvg  += piCur[0];
    1800     iCurAvg  += piCur[1];
    1801     iCurAvg  += piCur[2];
    1802     iCurAvg  += piCur[3];
    1803     iCurAvg  += piCur[4];
    1804     iCurAvg  += piCur[5];
    1805     iCurAvg  += piCur[6];
    1806     iCurAvg  += piCur[7];
    1807     iCurAvg  += piCur[8];
    1808     iCurAvg  += piCur[9];
    1809     iCurAvg  += piCur[10];
    1810     iCurAvg  += piCur[11];
    1811     iCurAvg  += piCur[12];
    1812     iCurAvg  += piCur[13];
    1813     iCurAvg  += piCur[14];
    1814     iCurAvg  += piCur[15];
    1815     iCurAvg  += piCur[16];
    1816     iCurAvg  += piCur[17];
    1817     iCurAvg  += piCur[18];
    1818     iCurAvg  += piCur[19];
    1819     iCurAvg  += piCur[20];
    1820     iCurAvg  += piCur[21];
    1821     iCurAvg  += piCur[22];
    1822     iCurAvg  += piCur[23];
    1823     iCurAvg  += piCur[24];
    1824     iCurAvg  += piCur[25];
    1825     iCurAvg  += piCur[26];
    1826     iCurAvg  += piCur[27];
    1827     iCurAvg  += piCur[28];
    1828     iCurAvg  += piCur[29];
    1829     iCurAvg  += piCur[30];
    1830     iCurAvg  += piCur[31];
    1831 
    1832     piOrg += iStrideOrg;
    1833     piCur += iStrideCur;
    1834     uiRowCnt++;
    1835   }
    1836 
    1837   piOrg   = pcDtParam->pOrg;
    1838   piCur   = pcDtParam->pCur;
    1839   iRows   = pcDtParam->iRows;
    1840 
    1841   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/32) : 0;
    1842 
    1843   for( ; iRows != 0; iRows-=iSubStep )
    1844   {
    1845     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    1846     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    1847     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    1848     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    1849     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    1850     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    1851     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    1852     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    1853     uiSum += abs( piOrg[8] - piCur[8] - iDeltaC );
    1854     uiSum += abs( piOrg[9] - piCur[9] - iDeltaC );
    1855     uiSum += abs( piOrg[10] - piCur[10] - iDeltaC );
    1856     uiSum += abs( piOrg[11] - piCur[11] - iDeltaC );
    1857     uiSum += abs( piOrg[12] - piCur[12] - iDeltaC );
    1858     uiSum += abs( piOrg[13] - piCur[13] - iDeltaC );
    1859     uiSum += abs( piOrg[14] - piCur[14] - iDeltaC );
    1860     uiSum += abs( piOrg[15] - piCur[15] - iDeltaC );
    1861     uiSum += abs( piOrg[16] - piCur[16] - iDeltaC );
    1862     uiSum += abs( piOrg[17] - piCur[17] - iDeltaC );
    1863     uiSum += abs( piOrg[18] - piCur[18] - iDeltaC );
    1864     uiSum += abs( piOrg[19] - piCur[19] - iDeltaC );
    1865     uiSum += abs( piOrg[20] - piCur[20] - iDeltaC );
    1866     uiSum += abs( piOrg[21] - piCur[21] - iDeltaC );
    1867     uiSum += abs( piOrg[22] - piCur[22] - iDeltaC );
    1868     uiSum += abs( piOrg[23] - piCur[23] - iDeltaC );
    1869     uiSum += abs( piOrg[24] - piCur[24] - iDeltaC );
    1870     uiSum += abs( piOrg[25] - piCur[25] - iDeltaC );
    1871     uiSum += abs( piOrg[26] - piCur[26] - iDeltaC );
    1872     uiSum += abs( piOrg[27] - piCur[27] - iDeltaC );
    1873     uiSum += abs( piOrg[28] - piCur[28] - iDeltaC );
    1874     uiSum += abs( piOrg[29] - piCur[29] - iDeltaC );
    1875     uiSum += abs( piOrg[30] - piCur[30] - iDeltaC );
    1876     uiSum += abs( piOrg[31] - piCur[31] - iDeltaC );
    1877 
    1878     piOrg += iStrideOrg;
    1879     piCur += iStrideCur;
    1880   }
    1881 
    1882   uiSum <<= iSubShift;
    1883   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1884 }
    1885 
    1886 
    1887 UInt TComRdCost::xGetSAD24ic( DistParam* pcDtParam )
    1888 {
    1889   if ( pcDtParam->bApplyWeight )
    1890   {
    1891     return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    1892   }
    1893   const Pel* piOrg   = pcDtParam->pOrg;
    1894   const Pel* piCur   = pcDtParam->pCur;
    1895   Int  iRows   = pcDtParam->iRows;
    1896   Int  iSubShift  = pcDtParam->iSubShift;
    1897   Int  iSubStep   = ( 1 << iSubShift );
    1898   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1899   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1900 
    1901   UInt uiSum = 0;
    1902 
    1903   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    1904   Int  iDeltaC;
    1905 
    1906   for( ; iRows != 0; iRows-=iSubStep )
    1907   {
    1908     iOrigAvg += piOrg[0];
    1909     iOrigAvg += piOrg[1];
    1910     iOrigAvg += piOrg[2];
    1911     iOrigAvg += piOrg[3];
    1912     iOrigAvg += piOrg[4];
    1913     iOrigAvg += piOrg[5];
    1914     iOrigAvg += piOrg[6];
    1915     iOrigAvg += piOrg[7];
    1916     iOrigAvg += piOrg[8];
    1917     iOrigAvg += piOrg[9];
    1918     iOrigAvg += piOrg[10];
    1919     iOrigAvg += piOrg[11];
    1920     iOrigAvg += piOrg[12];
    1921     iOrigAvg += piOrg[13];
    1922     iOrigAvg += piOrg[14];
    1923     iOrigAvg += piOrg[15];
    1924     iOrigAvg += piOrg[16];
    1925     iOrigAvg += piOrg[17];
    1926     iOrigAvg += piOrg[18];
    1927     iOrigAvg += piOrg[19];
    1928     iOrigAvg += piOrg[20];
    1929     iOrigAvg += piOrg[21];
    1930     iOrigAvg += piOrg[22];
    1931     iOrigAvg += piOrg[23];
    1932 
    1933     iCurAvg  += piCur[0];
    1934     iCurAvg  += piCur[1];
    1935     iCurAvg  += piCur[2];
    1936     iCurAvg  += piCur[3];
    1937     iCurAvg  += piCur[4];
    1938     iCurAvg  += piCur[5];
    1939     iCurAvg  += piCur[6];
    1940     iCurAvg  += piCur[7];
    1941     iCurAvg  += piCur[8];
    1942     iCurAvg  += piCur[9];
    1943     iCurAvg  += piCur[10];
    1944     iCurAvg  += piCur[11];
    1945     iCurAvg  += piCur[12];
    1946     iCurAvg  += piCur[13];
    1947     iCurAvg  += piCur[14];
    1948     iCurAvg  += piCur[15];
    1949     iCurAvg  += piCur[16];
    1950     iCurAvg  += piCur[17];
    1951     iCurAvg  += piCur[18];
    1952     iCurAvg  += piCur[19];
    1953     iCurAvg  += piCur[20];
    1954     iCurAvg  += piCur[21];
    1955     iCurAvg  += piCur[22];
    1956     iCurAvg  += piCur[23];
    1957 
    1958     piOrg += iStrideOrg;
    1959     piCur += iStrideCur;
    1960     uiRowCnt++;
    1961   }
    1962 
    1963   piOrg   = pcDtParam->pOrg;
    1964   piCur   = pcDtParam->pCur;
    1965   iRows   = pcDtParam->iRows;
    1966 
    1967   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/24) : 0;
    1968 
    1969   for( ; iRows != 0; iRows-=iSubStep )
    1970   {
    1971     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    1972     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    1973     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    1974     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    1975     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    1976     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    1977     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    1978     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    1979     uiSum += abs( piOrg[8] - piCur[8] - iDeltaC );
    1980     uiSum += abs( piOrg[9] - piCur[9] - iDeltaC );
    1981     uiSum += abs( piOrg[10] - piCur[10] - iDeltaC );
    1982     uiSum += abs( piOrg[11] - piCur[11] - iDeltaC );
    1983     uiSum += abs( piOrg[12] - piCur[12] - iDeltaC );
    1984     uiSum += abs( piOrg[13] - piCur[13] - iDeltaC );
    1985     uiSum += abs( piOrg[14] - piCur[14] - iDeltaC );
    1986     uiSum += abs( piOrg[15] - piCur[15] - iDeltaC );
    1987     uiSum += abs( piOrg[16] - piCur[16] - iDeltaC );
    1988     uiSum += abs( piOrg[17] - piCur[17] - iDeltaC );
    1989     uiSum += abs( piOrg[18] - piCur[18] - iDeltaC );
    1990     uiSum += abs( piOrg[19] - piCur[19] - iDeltaC );
    1991     uiSum += abs( piOrg[20] - piCur[20] - iDeltaC );
    1992     uiSum += abs( piOrg[21] - piCur[21] - iDeltaC );
    1993     uiSum += abs( piOrg[22] - piCur[22] - iDeltaC );
    1994     uiSum += abs( piOrg[23] - piCur[23] - iDeltaC );
    1995 
    1996     piOrg += iStrideOrg;
    1997     piCur += iStrideCur;
    1998   }
    1999 
    2000   uiSum <<= iSubShift;
    2001   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    2002 }
    2003 
    2004 UInt TComRdCost::xGetSAD64ic( DistParam* pcDtParam )
    2005 {
    2006   if ( pcDtParam->bApplyWeight )
    2007   {
    2008     return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    2009   }
    2010   const Pel* piOrg   = pcDtParam->pOrg;
    2011   const Pel* piCur   = pcDtParam->pCur;
    2012   Int  iRows   = pcDtParam->iRows;
    2013   Int  iSubShift  = pcDtParam->iSubShift;
    2014   Int  iSubStep   = ( 1 << iSubShift );
    2015   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    2016   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    2017 
    2018   UInt uiSum = 0;
    2019 
    2020   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    2021   Int  iDeltaC;
    2022 
    2023   for( ; iRows != 0; iRows-=iSubStep )
    2024   {
    2025     iOrigAvg += piOrg[0] ;
    2026     iOrigAvg += piOrg[1] ;
    2027     iOrigAvg += piOrg[2] ;
    2028     iOrigAvg += piOrg[3] ;
    2029     iOrigAvg += piOrg[4] ;
    2030     iOrigAvg += piOrg[5] ;
    2031     iOrigAvg += piOrg[6] ;
    2032     iOrigAvg += piOrg[7] ;
    2033     iOrigAvg += piOrg[8] ;
    2034     iOrigAvg += piOrg[9] ;
    2035     iOrigAvg += piOrg[10] ;
    2036     iOrigAvg += piOrg[11] ;
    2037     iOrigAvg += piOrg[12] ;
    2038     iOrigAvg += piOrg[13] ;
    2039     iOrigAvg += piOrg[14] ;
    2040     iOrigAvg += piOrg[15] ;
    2041     iOrigAvg += piOrg[16] ;
    2042     iOrigAvg += piOrg[17] ;
    2043     iOrigAvg += piOrg[18] ;
    2044     iOrigAvg += piOrg[19] ;
    2045     iOrigAvg += piOrg[20] ;
    2046     iOrigAvg += piOrg[21] ;
    2047     iOrigAvg += piOrg[22] ;
    2048     iOrigAvg += piOrg[23] ;
    2049     iOrigAvg += piOrg[24] ;
    2050     iOrigAvg += piOrg[25] ;
    2051     iOrigAvg += piOrg[26] ;
    2052     iOrigAvg += piOrg[27] ;
    2053     iOrigAvg += piOrg[28] ;
    2054     iOrigAvg += piOrg[29] ;
    2055     iOrigAvg += piOrg[30] ;
    2056     iOrigAvg += piOrg[31] ;
    2057     iOrigAvg += piOrg[32] ;
    2058     iOrigAvg += piOrg[33] ;
    2059     iOrigAvg += piOrg[34] ;
    2060     iOrigAvg += piOrg[35] ;
    2061     iOrigAvg += piOrg[36] ;
    2062     iOrigAvg += piOrg[37] ;
    2063     iOrigAvg += piOrg[38] ;
    2064     iOrigAvg += piOrg[39] ;
    2065     iOrigAvg += piOrg[40] ;
    2066     iOrigAvg += piOrg[41] ;
    2067     iOrigAvg += piOrg[42] ;
    2068     iOrigAvg += piOrg[43] ;
    2069     iOrigAvg += piOrg[44] ;
    2070     iOrigAvg += piOrg[45] ;
    2071     iOrigAvg += piOrg[46] ;
    2072     iOrigAvg += piOrg[47] ;
    2073     iOrigAvg += piOrg[48] ;
    2074     iOrigAvg += piOrg[49] ;
    2075     iOrigAvg += piOrg[50] ;
    2076     iOrigAvg += piOrg[51] ;
    2077     iOrigAvg += piOrg[52] ;
    2078     iOrigAvg += piOrg[53] ;
    2079     iOrigAvg += piOrg[54] ;
    2080     iOrigAvg += piOrg[55] ;
    2081     iOrigAvg += piOrg[56] ;
    2082     iOrigAvg += piOrg[57] ;
    2083     iOrigAvg += piOrg[58] ;
    2084     iOrigAvg += piOrg[59] ;
    2085     iOrigAvg += piOrg[60] ;
    2086     iOrigAvg += piOrg[61] ;
    2087     iOrigAvg += piOrg[62] ;
    2088     iOrigAvg += piOrg[63] ;
    2089 
    2090     iCurAvg += piCur[0] ;
    2091     iCurAvg += piCur[1] ;
    2092     iCurAvg += piCur[2] ;
    2093     iCurAvg += piCur[3] ;
    2094     iCurAvg += piCur[4] ;
    2095     iCurAvg += piCur[5] ;
    2096     iCurAvg += piCur[6] ;
    2097     iCurAvg += piCur[7] ;
    2098     iCurAvg += piCur[8] ;
    2099     iCurAvg += piCur[9] ;
    2100     iCurAvg += piCur[10] ;
    2101     iCurAvg += piCur[11] ;
    2102     iCurAvg += piCur[12] ;
    2103     iCurAvg += piCur[13] ;
    2104     iCurAvg += piCur[14] ;
    2105     iCurAvg += piCur[15] ;
    2106     iCurAvg += piCur[16] ;
    2107     iCurAvg += piCur[17] ;
    2108     iCurAvg += piCur[18] ;
    2109     iCurAvg += piCur[19] ;
    2110     iCurAvg += piCur[20] ;
    2111     iCurAvg += piCur[21] ;
    2112     iCurAvg += piCur[22] ;
    2113     iCurAvg += piCur[23] ;
    2114     iCurAvg += piCur[24] ;
    2115     iCurAvg += piCur[25] ;
    2116     iCurAvg += piCur[26] ;
    2117     iCurAvg += piCur[27] ;
    2118     iCurAvg += piCur[28] ;
    2119     iCurAvg += piCur[29] ;
    2120     iCurAvg += piCur[30] ;
    2121     iCurAvg += piCur[31] ;
    2122     iCurAvg += piCur[32] ;
    2123     iCurAvg += piCur[33] ;
    2124     iCurAvg += piCur[34] ;
    2125     iCurAvg += piCur[35] ;
    2126     iCurAvg += piCur[36] ;
    2127     iCurAvg += piCur[37] ;
    2128     iCurAvg += piCur[38] ;
    2129     iCurAvg += piCur[39] ;
    2130     iCurAvg += piCur[40] ;
    2131     iCurAvg += piCur[41] ;
    2132     iCurAvg += piCur[42] ;
    2133     iCurAvg += piCur[43] ;
    2134     iCurAvg += piCur[44] ;
    2135     iCurAvg += piCur[45] ;
    2136     iCurAvg += piCur[46] ;
    2137     iCurAvg += piCur[47] ;
    2138     iCurAvg += piCur[48] ;
    2139     iCurAvg += piCur[49] ;
    2140     iCurAvg += piCur[50] ;
    2141     iCurAvg += piCur[51] ;
    2142     iCurAvg += piCur[52] ;
    2143     iCurAvg += piCur[53] ;
    2144     iCurAvg += piCur[54] ;
    2145     iCurAvg += piCur[55] ;
    2146     iCurAvg += piCur[56] ;
    2147     iCurAvg += piCur[57] ;
    2148     iCurAvg += piCur[58] ;
    2149     iCurAvg += piCur[59] ;
    2150     iCurAvg += piCur[60] ;
    2151     iCurAvg += piCur[61] ;
    2152     iCurAvg += piCur[62] ;
    2153     iCurAvg += piCur[63] ;
    2154 
    2155     piOrg += iStrideOrg;
    2156     piCur += iStrideCur;
    2157     uiRowCnt++;
    2158   }
    2159 
    2160   piOrg   = pcDtParam->pOrg;
    2161   piCur   = pcDtParam->pCur;
    2162   iRows   = pcDtParam->iRows;
    2163 
    2164   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/64) : 0;
    2165 
    2166   for( ; iRows != 0; iRows-=iSubStep )
    2167   {
    2168     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    2169     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    2170     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    2171     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    2172     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    2173     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    2174     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    2175     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    2176     uiSum += abs( piOrg[8] - piCur[8] - iDeltaC );
    2177     uiSum += abs( piOrg[9] - piCur[9] - iDeltaC );
    2178     uiSum += abs( piOrg[10] - piCur[10] - iDeltaC );
    2179     uiSum += abs( piOrg[11] - piCur[11] - iDeltaC );
    2180     uiSum += abs( piOrg[12] - piCur[12] - iDeltaC );
    2181     uiSum += abs( piOrg[13] - piCur[13] - iDeltaC );
    2182     uiSum += abs( piOrg[14] - piCur[14] - iDeltaC );
    2183     uiSum += abs( piOrg[15] - piCur[15] - iDeltaC );
    2184     uiSum += abs( piOrg[16] - piCur[16] - iDeltaC );
    2185     uiSum += abs( piOrg[17] - piCur[17] - iDeltaC );
    2186     uiSum += abs( piOrg[18] - piCur[18] - iDeltaC );
    2187     uiSum += abs( piOrg[19] - piCur[19] - iDeltaC );
    2188     uiSum += abs( piOrg[20] - piCur[20] - iDeltaC );
    2189     uiSum += abs( piOrg[21] - piCur[21] - iDeltaC );
    2190     uiSum += abs( piOrg[22] - piCur[22] - iDeltaC );
    2191     uiSum += abs( piOrg[23] - piCur[23] - iDeltaC );
    2192     uiSum += abs( piOrg[24] - piCur[24] - iDeltaC );
    2193     uiSum += abs( piOrg[25] - piCur[25] - iDeltaC );
    2194     uiSum += abs( piOrg[26] - piCur[26] - iDeltaC );
    2195     uiSum += abs( piOrg[27] - piCur[27] - iDeltaC );
    2196     uiSum += abs( piOrg[28] - piCur[28] - iDeltaC );
    2197     uiSum += abs( piOrg[29] - piCur[29] - iDeltaC );
    2198     uiSum += abs( piOrg[30] - piCur[30] - iDeltaC );
    2199     uiSum += abs( piOrg[31] - piCur[31] - iDeltaC );
    2200     uiSum += abs( piOrg[32] - piCur[32] - iDeltaC );
    2201     uiSum += abs( piOrg[33] - piCur[33] - iDeltaC );
    2202     uiSum += abs( piOrg[34] - piCur[34] - iDeltaC );
    2203     uiSum += abs( piOrg[35] - piCur[35] - iDeltaC );
    2204     uiSum += abs( piOrg[36] - piCur[36] - iDeltaC );
    2205     uiSum += abs( piOrg[37] - piCur[37] - iDeltaC );
    2206     uiSum += abs( piOrg[38] - piCur[38] - iDeltaC );
    2207     uiSum += abs( piOrg[39] - piCur[39] - iDeltaC );
    2208     uiSum += abs( piOrg[40] - piCur[40] - iDeltaC );
    2209     uiSum += abs( piOrg[41] - piCur[41] - iDeltaC );
    2210     uiSum += abs( piOrg[42] - piCur[42] - iDeltaC );
    2211     uiSum += abs( piOrg[43] - piCur[43] - iDeltaC );
    2212     uiSum += abs( piOrg[44] - piCur[44] - iDeltaC );
    2213     uiSum += abs( piOrg[45] - piCur[45] - iDeltaC );
    2214     uiSum += abs( piOrg[46] - piCur[46] - iDeltaC );
    2215     uiSum += abs( piOrg[47] - piCur[47] - iDeltaC );
    2216     uiSum += abs( piOrg[48] - piCur[48] - iDeltaC );
    2217     uiSum += abs( piOrg[49] - piCur[49] - iDeltaC );
    2218     uiSum += abs( piOrg[50] - piCur[50] - iDeltaC );
    2219     uiSum += abs( piOrg[51] - piCur[51] - iDeltaC );
    2220     uiSum += abs( piOrg[52] - piCur[52] - iDeltaC );
    2221     uiSum += abs( piOrg[53] - piCur[53] - iDeltaC );
    2222     uiSum += abs( piOrg[54] - piCur[54] - iDeltaC );
    2223     uiSum += abs( piOrg[55] - piCur[55] - iDeltaC );
    2224     uiSum += abs( piOrg[56] - piCur[56] - iDeltaC );
    2225     uiSum += abs( piOrg[57] - piCur[57] - iDeltaC );
    2226     uiSum += abs( piOrg[58] - piCur[58] - iDeltaC );
    2227     uiSum += abs( piOrg[59] - piCur[59] - iDeltaC );
    2228     uiSum += abs( piOrg[60] - piCur[60] - iDeltaC );
    2229     uiSum += abs( piOrg[61] - piCur[61] - iDeltaC );
    2230     uiSum += abs( piOrg[62] - piCur[62] - iDeltaC );
    2231     uiSum += abs( piOrg[63] - piCur[63] - iDeltaC );
    2232 
    2233     piOrg += iStrideOrg;
    2234     piCur += iStrideCur;
    2235   }
    2236 
    2237   uiSum <<= iSubShift;
    2238   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    2239 }
    2240 
    2241 
    2242 UInt TComRdCost::xGetSAD48ic( DistParam* pcDtParam )
    2243 {
    2244   if ( pcDtParam->bApplyWeight )
    2245   {
    2246     return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    2247   }
    2248 
    2249   const Pel* piOrg   = pcDtParam->pOrg;
    2250   const Pel* piCur   = pcDtParam->pCur;
    2251   Int  iRows   = pcDtParam->iRows;
    2252   Int  iSubShift  = pcDtParam->iSubShift;
    2253   Int  iSubStep   = ( 1 << iSubShift );
    2254   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    2255   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    2256 
    2257   UInt uiSum = 0;
    2258 
    2259   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    2260   Int  iDeltaC;
    2261 
    2262   for( ; iRows != 0; iRows-=iSubStep )
    2263   {
    2264     iOrigAvg += piOrg[0] ;
    2265     iOrigAvg += piOrg[1] ;
    2266     iOrigAvg += piOrg[2] ;
    2267     iOrigAvg += piOrg[3] ;
    2268     iOrigAvg += piOrg[4] ;
    2269     iOrigAvg += piOrg[5] ;
    2270     iOrigAvg += piOrg[6] ;
    2271     iOrigAvg += piOrg[7] ;
    2272     iOrigAvg += piOrg[8] ;
    2273     iOrigAvg += piOrg[9] ;
    2274     iOrigAvg += piOrg[10] ;
    2275     iOrigAvg += piOrg[11] ;
    2276     iOrigAvg += piOrg[12] ;
    2277     iOrigAvg += piOrg[13] ;
    2278     iOrigAvg += piOrg[14] ;
    2279     iOrigAvg += piOrg[15] ;
    2280     iOrigAvg += piOrg[16] ;
    2281     iOrigAvg += piOrg[17] ;
    2282     iOrigAvg += piOrg[18] ;
    2283     iOrigAvg += piOrg[19] ;
    2284     iOrigAvg += piOrg[20] ;
    2285     iOrigAvg += piOrg[21] ;
    2286     iOrigAvg += piOrg[22] ;
    2287     iOrigAvg += piOrg[23] ;
    2288     iOrigAvg += piOrg[24] ;
    2289     iOrigAvg += piOrg[25] ;
    2290     iOrigAvg += piOrg[26] ;
    2291     iOrigAvg += piOrg[27] ;
    2292     iOrigAvg += piOrg[28] ;
    2293     iOrigAvg += piOrg[29] ;
    2294     iOrigAvg += piOrg[30] ;
    2295     iOrigAvg += piOrg[31] ;
    2296     iOrigAvg += piOrg[32] ;
    2297     iOrigAvg += piOrg[33] ;
    2298     iOrigAvg += piOrg[34] ;
    2299     iOrigAvg += piOrg[35] ;
    2300     iOrigAvg += piOrg[36] ;
    2301     iOrigAvg += piOrg[37] ;
    2302     iOrigAvg += piOrg[38] ;
    2303     iOrigAvg += piOrg[39] ;
    2304     iOrigAvg += piOrg[40] ;
    2305     iOrigAvg += piOrg[41] ;
    2306     iOrigAvg += piOrg[42] ;
    2307     iOrigAvg += piOrg[43] ;
    2308     iOrigAvg += piOrg[44] ;
    2309     iOrigAvg += piOrg[45] ;
    2310     iOrigAvg += piOrg[46] ;
    2311     iOrigAvg += piOrg[47] ;
    2312 
    2313     iCurAvg += piCur[0] ;
    2314     iCurAvg += piCur[1] ;
    2315     iCurAvg += piCur[2] ;
    2316     iCurAvg += piCur[3] ;
    2317     iCurAvg += piCur[4] ;
    2318     iCurAvg += piCur[5] ;
    2319     iCurAvg += piCur[6] ;
    2320     iCurAvg += piCur[7] ;
    2321     iCurAvg += piCur[8] ;
    2322     iCurAvg += piCur[9] ;
    2323     iCurAvg += piCur[10] ;
    2324     iCurAvg += piCur[11] ;
    2325     iCurAvg += piCur[12] ;
    2326     iCurAvg += piCur[13] ;
    2327     iCurAvg += piCur[14] ;
    2328     iCurAvg += piCur[15] ;
    2329     iCurAvg += piCur[16] ;
    2330     iCurAvg += piCur[17] ;
    2331     iCurAvg += piCur[18] ;
    2332     iCurAvg += piCur[19] ;
    2333     iCurAvg += piCur[20] ;
    2334     iCurAvg += piCur[21] ;
    2335     iCurAvg += piCur[22] ;
    2336     iCurAvg += piCur[23] ;
    2337     iCurAvg += piCur[24] ;
    2338     iCurAvg += piCur[25] ;
    2339     iCurAvg += piCur[26] ;
    2340     iCurAvg += piCur[27] ;
    2341     iCurAvg += piCur[28] ;
    2342     iCurAvg += piCur[29] ;
    2343     iCurAvg += piCur[30] ;
    2344     iCurAvg += piCur[31] ;
    2345     iCurAvg += piCur[32] ;
    2346     iCurAvg += piCur[33] ;
    2347     iCurAvg += piCur[34] ;
    2348     iCurAvg += piCur[35] ;
    2349     iCurAvg += piCur[36] ;
    2350     iCurAvg += piCur[37] ;
    2351     iCurAvg += piCur[38] ;
    2352     iCurAvg += piCur[39] ;
    2353     iCurAvg += piCur[40] ;
    2354     iCurAvg += piCur[41] ;
    2355     iCurAvg += piCur[42] ;
    2356     iCurAvg += piCur[43] ;
    2357     iCurAvg += piCur[44] ;
    2358     iCurAvg += piCur[45] ;
    2359     iCurAvg += piCur[46] ;
    2360     iCurAvg += piCur[47] ;
    2361 
    2362     piOrg += iStrideOrg;
    2363     piCur += iStrideCur;
    2364     uiRowCnt++;
    2365   }
    2366 
    2367   piOrg   = pcDtParam->pOrg;
    2368   piCur   = pcDtParam->pCur;
    2369   iRows   = pcDtParam->iRows;
    2370 
    2371   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/48) : 0;
    2372 
    2373   for( ; iRows != 0; iRows-=iSubStep )
    2374   {
    2375     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    2376     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    2377     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    2378     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    2379     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    2380     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    2381     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    2382     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    2383     uiSum += abs( piOrg[8] - piCur[8] - iDeltaC );
    2384     uiSum += abs( piOrg[9] - piCur[9] - iDeltaC );
    2385     uiSum += abs( piOrg[10] - piCur[10] - iDeltaC );
    2386     uiSum += abs( piOrg[11] - piCur[11] - iDeltaC );
    2387     uiSum += abs( piOrg[12] - piCur[12] - iDeltaC );
    2388     uiSum += abs( piOrg[13] - piCur[13] - iDeltaC );
    2389     uiSum += abs( piOrg[14] - piCur[14] - iDeltaC );
    2390     uiSum += abs( piOrg[15] - piCur[15] - iDeltaC );
    2391     uiSum += abs( piOrg[16] - piCur[16] - iDeltaC );
    2392     uiSum += abs( piOrg[17] - piCur[17] - iDeltaC );
    2393     uiSum += abs( piOrg[18] - piCur[18] - iDeltaC );
    2394     uiSum += abs( piOrg[19] - piCur[19] - iDeltaC );
    2395     uiSum += abs( piOrg[20] - piCur[20] - iDeltaC );
    2396     uiSum += abs( piOrg[21] - piCur[21] - iDeltaC );
    2397     uiSum += abs( piOrg[22] - piCur[22] - iDeltaC );
    2398     uiSum += abs( piOrg[23] - piCur[23] - iDeltaC );
    2399     uiSum += abs( piOrg[24] - piCur[24] - iDeltaC );
    2400     uiSum += abs( piOrg[25] - piCur[25] - iDeltaC );
    2401     uiSum += abs( piOrg[26] - piCur[26] - iDeltaC );
    2402     uiSum += abs( piOrg[27] - piCur[27] - iDeltaC );
    2403     uiSum += abs( piOrg[28] - piCur[28] - iDeltaC );
    2404     uiSum += abs( piOrg[29] - piCur[29] - iDeltaC );
    2405     uiSum += abs( piOrg[30] - piCur[30] - iDeltaC );
    2406     uiSum += abs( piOrg[31] - piCur[31] - iDeltaC );
    2407     uiSum += abs( piOrg[32] - piCur[32] - iDeltaC );
    2408     uiSum += abs( piOrg[33] - piCur[33] - iDeltaC );
    2409     uiSum += abs( piOrg[34] - piCur[34] - iDeltaC );
    2410     uiSum += abs( piOrg[35] - piCur[35] - iDeltaC );
    2411     uiSum += abs( piOrg[36] - piCur[36] - iDeltaC );
    2412     uiSum += abs( piOrg[37] - piCur[37] - iDeltaC );
    2413     uiSum += abs( piOrg[38] - piCur[38] - iDeltaC );
    2414     uiSum += abs( piOrg[39] - piCur[39] - iDeltaC );
    2415     uiSum += abs( piOrg[40] - piCur[40] - iDeltaC );
    2416     uiSum += abs( piOrg[41] - piCur[41] - iDeltaC );
    2417     uiSum += abs( piOrg[42] - piCur[42] - iDeltaC );
    2418     uiSum += abs( piOrg[43] - piCur[43] - iDeltaC );
    2419     uiSum += abs( piOrg[44] - piCur[44] - iDeltaC );
    2420     uiSum += abs( piOrg[45] - piCur[45] - iDeltaC );
    2421     uiSum += abs( piOrg[46] - piCur[46] - iDeltaC );
    2422     uiSum += abs( piOrg[47] - piCur[47] - iDeltaC );
    2423 
    2424     piOrg += iStrideOrg;
    2425     piCur += iStrideCur;
    2426   }
    2427 
    2428   uiSum <<= iSubShift;
    2429   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    2430 }
    2431 #endif
    2432887// --------------------------------------------------------------------------------------------------------------------
    2433888// SSE
     
    27811236}
    27821237
    2783 #if NH_3D_VSO
    2784 //SAIT_VSO_EST_A0033
    2785 UInt TComRdCost::getVSDEstimate( Int dDM, const Pel* pOrg, Int iOrgStride, const Pel* pVirRec, const Pel* pVirOrg, Int iVirStride, Int x, Int y )
    2786 {
    2787   // change to use bit depth from DistParam struct
    2788   Double  dD = ( (Double) ( dDM >> ( ENC_INTERNAL_BIT_DEPTH - 8 ) ) ) * m_dDisparityCoeff;
    2789 
    2790   Double dDepthWeight = ( pOrg[x] >=  ( (1<<(REN_BIT_DEPTH - 3)) + (1<<(REN_BIT_DEPTH - 2)) ) ? 4 : pOrg[x] > ((1<<REN_BIT_DEPTH) >> 4) ? (Float)(pOrg[x] - ((1<<REN_BIT_DEPTH) >> 4))/(Float)((1<<REN_BIT_DEPTH) >> 3) + 1 : 1.0 );
    2791 
    2792   Double dTemp = ( 0.5 * fabs(dD) * dDepthWeight * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) );
    2793   Int iTemp = (Int) (((dTemp) < 0)? (Int)((dTemp) - 0.5) : (Int)((dTemp) + 0.5));
    2794 
    2795   return (UInt) ( (iTemp*iTemp)>>1 );
    2796 }
    2797 
    2798 UInt TComRdCost::xGetVSD( DistParam* pcDtParam )
    2799 {
    2800   const Pel* piOrg    = pcDtParam->pOrg;
    2801   const Pel* piCur    = pcDtParam->pCur;
    2802   const Pel* piVirRec = pcDtParam->pVirRec;
    2803   const Pel* piVirOrg = pcDtParam->pVirOrg;
    2804   Int  iRows    = pcDtParam->iRows;
    2805   Int  iCols    = pcDtParam->iCols;
    2806   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2807   Int  iStrideCur = pcDtParam->iStrideCur;
    2808   Int  iStrideVir = pcDtParam->iStrideVir;
    2809 
    2810   UInt uiSum = 0;
    2811   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    2812 
    2813   Int dDM;
    2814 
    2815   for ( Int y = 0 ; y < iRows ; y++ )
    2816   {
    2817     for (Int x = 0; x < iCols; x++ )
    2818     {
    2819       dDM = (Int) ( piOrg[x  ] - piCur[x  ] );
    2820       uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
    2821     }
    2822     piOrg += iStrideOrg;
    2823     piCur += iStrideCur;
    2824   }
    2825 
    2826   return ( uiSum );
    2827 }
    2828 
    2829 UInt TComRdCost::xGetVSD4( DistParam* pcDtParam )
    2830 {
    2831   const Pel* piOrg   = pcDtParam->pOrg;
    2832   const Pel* piCur   = pcDtParam->pCur;
    2833   const Pel* piVirRec = pcDtParam->pVirRec;
    2834   const Pel* piVirOrg = pcDtParam->pVirOrg;
    2835   Int  iRows   = pcDtParam->iRows;
    2836   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2837   Int  iStrideCur = pcDtParam->iStrideCur;
    2838   Int  iStrideVir = pcDtParam->iStrideVir;
    2839 
    2840   UInt uiSum = 0;
    2841   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    2842 
    2843   Int dDM;
    2844 
    2845   for ( Int y = 0 ; y < iRows ; y++ )
    2846   {
    2847     dDM = (Int) ( piOrg[0] - piCur[0] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 0, y ) ) >> uiShift;
    2848     dDM = (Int) ( piOrg[1] - piCur[1] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 1, y ) ) >> uiShift;
    2849     dDM = (Int) ( piOrg[2] - piCur[2] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 2, y ) ) >> uiShift;
    2850     dDM = (Int) ( piOrg[3] - piCur[3] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 3, y ) ) >> uiShift;
    2851 
    2852     piOrg += iStrideOrg;
    2853     piCur += iStrideCur;
    2854   }
    2855 
    2856   return ( uiSum );
    2857 }
    2858 
    2859 UInt TComRdCost::xGetVSD8( DistParam* pcDtParam )
    2860 {
    2861   const Pel* piOrg   = pcDtParam->pOrg;
    2862   const Pel* piCur   = pcDtParam->pCur;
    2863   const Pel* piVirRec = pcDtParam->pVirRec;
    2864   const Pel* piVirOrg = pcDtParam->pVirOrg;
    2865   Int  iRows   = pcDtParam->iRows;
    2866   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2867   Int  iStrideCur = pcDtParam->iStrideCur;
    2868   Int  iStrideVir = pcDtParam->iStrideVir;
    2869 
    2870   UInt uiSum = 0;
    2871   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    2872 
    2873   Int dDM;
    2874 
    2875   for ( Int y = 0 ; y < iRows ; y++ )
    2876   {
    2877     for (Int x = 0; x < 8; x++ )
    2878     {
    2879       dDM = (Int) ( piOrg[x] - piCur[x] );
    2880       uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
    2881     }
    2882     piOrg += iStrideOrg;
    2883     piCur += iStrideCur;
    2884   }
    2885 
    2886   return ( uiSum );
    2887 }
    2888 
    2889 UInt TComRdCost::xGetVSD16( DistParam* pcDtParam )
    2890 {
    2891   const Pel* piOrg   = pcDtParam->pOrg;
    2892   const Pel* piCur   = pcDtParam->pCur;
    2893   const Pel* piVirRec = pcDtParam->pVirRec;
    2894   const Pel* piVirOrg = pcDtParam->pVirOrg;
    2895   Int  iRows   = pcDtParam->iRows;
    2896   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2897   Int  iStrideCur = pcDtParam->iStrideCur;
    2898   Int  iStrideVir = pcDtParam->iStrideVir;
    2899 
    2900   UInt uiSum = 0;
    2901   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    2902 
    2903   Int dDM;
    2904 
    2905   for ( Int y = 0 ; y < iRows ; y++ )
    2906   {
    2907     for (Int x = 0; x < 16; x++ )
    2908     {
    2909       dDM = (Int) ( piOrg[x] - piCur[x] );
    2910       uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
    2911     }
    2912     piOrg += iStrideOrg;
    2913     piCur += iStrideCur;
    2914   }
    2915 
    2916   return ( uiSum );
    2917 }
    2918 
    2919 UInt TComRdCost::xGetVSD16N( DistParam* pcDtParam )
    2920 {
    2921   const Pel* piOrg   = pcDtParam->pOrg;
    2922   const Pel* piCur   = pcDtParam->pCur;
    2923   const Pel* piVirRec = pcDtParam->pVirRec;
    2924   const Pel* piVirOrg = pcDtParam->pVirOrg;
    2925   Int  iRows   = pcDtParam->iRows;
    2926   Int  iCols   = pcDtParam->iCols;
    2927   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2928   Int  iStrideCur = pcDtParam->iStrideCur;
    2929   Int  iStrideVir = pcDtParam->iStrideVir;
    2930 
    2931   UInt uiSum = 0;
    2932   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    2933 
    2934   Int dDM;
    2935 
    2936   for ( Int y = 0 ; y < iRows ; y++ )
    2937   {
    2938     for (Int x = 0; x < iCols; x+=16 )
    2939     {
    2940       for ( Int k = 0 ; k < 16 ; k++ )
    2941       {
    2942         dDM = (Int) ( piOrg[x+k] - piCur[x+k] );
    2943         uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x+k, y ) >> uiShift;
    2944       }
    2945     }
    2946     piOrg += iStrideOrg;
    2947     piCur += iStrideCur;
    2948   }
    2949 
    2950   return ( uiSum );
    2951 }
    2952 
    2953 UInt TComRdCost::xGetVSD32( DistParam* pcDtParam )
    2954 {
    2955   const Pel* piOrg   = pcDtParam->pOrg;
    2956   const Pel* piCur   = pcDtParam->pCur;
    2957   const Pel* piVirRec = pcDtParam->pVirRec;
    2958   const Pel* piVirOrg = pcDtParam->pVirOrg;
    2959   Int  iRows   = pcDtParam->iRows;
    2960   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2961   Int  iStrideCur = pcDtParam->iStrideCur;
    2962   Int  iStrideVir = pcDtParam->iStrideVir;
    2963 
    2964   UInt uiSum = 0;
    2965   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    2966 
    2967   Int dDM;
    2968 
    2969   for ( Int y = 0 ; y < iRows ; y++ )
    2970   {
    2971     for (Int x = 0; x < 32 ; x++ )
    2972     {
    2973       dDM = (Int) ( piOrg[x] - piCur[x] );
    2974       uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
    2975     }
    2976     piOrg += iStrideOrg;
    2977     piCur += iStrideCur;
    2978   }
    2979 
    2980   return ( uiSum );
    2981 }
    2982 
    2983 UInt TComRdCost::xGetVSD64( DistParam* pcDtParam )
    2984 {
    2985   const Pel* piOrg      = pcDtParam->pOrg;
    2986   const Pel* piCur      = pcDtParam->pCur;
    2987   const Pel* piVirRec   = pcDtParam->pVirRec;
    2988   const Pel* piVirOrg   = pcDtParam->pVirOrg;
    2989   Int  iRows      = pcDtParam->iRows;
    2990   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2991   Int  iStrideCur = pcDtParam->iStrideCur;
    2992   Int  iStrideVir = pcDtParam->iStrideVir;
    2993 
    2994   UInt uiSum = 0;
    2995   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    2996 
    2997   Int dDM;
    2998 
    2999   for ( Int y = 0 ; y < iRows ; y++ )
    3000   {
    3001     for (Int x = 0; x < 64; x++ )
    3002     {
    3003       dDM = (Int) ( piOrg[x] - piCur[x] );
    3004       uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
    3005     }
    3006     piOrg += iStrideOrg;
    3007     piCur += iStrideCur;
    3008   }
    3009 
    3010   return ( uiSum );
    3011 }
    3012 
    3013 #endif
    30141238
    30151239// --------------------------------------------------------------------------------------------------------------------
     
    32391463    return TComRdCostWeightPrediction::xGetHADsw( pcDtParam );
    32401464  }
    3241 #if NH_3D_IC
    3242   if( pcDtParam->bUseIC )
    3243   {
    3244     return xGetHADsic( pcDtParam );
    3245   }
    3246 #endif
    3247 #if NH_3D_SDC_INTER
    3248   if( pcDtParam->bUseSDCMRSAD )
    3249   {
    3250     return xGetHADsic( pcDtParam );
    3251   }
    3252 #endif
    32531465
    32541466  const Pel* piOrg      = pcDtParam->pOrg;
     
    33151527}
    33161528
    3317 #if NH_3D_IC || NH_3D_SDC_INTER
    3318 UInt TComRdCost::xGetHADsic( DistParam* pcDtParam )
    3319 {
    3320   if ( pcDtParam->bApplyWeight )
    3321   {
    3322     return TComRdCostWeightPrediction::xGetHADsw( pcDtParam );
    3323   }
    3324   const Pel* piOrg   = pcDtParam->pOrg;
    3325   const Pel* piCur   = pcDtParam->pCur;
    3326  
    3327   Int  iRows   = pcDtParam->iRows;
    3328   Int  iCols   = pcDtParam->iCols;
    3329   Int  iStrideCur = pcDtParam->iStrideCur;
    3330   Int  iStrideOrg = pcDtParam->iStrideOrg;
    3331   Int  iStep  = pcDtParam->iStep;
    3332 
    3333   Int  x, y;
    3334 
    3335   UInt uiSum = 0;
    3336 
    3337   Int  iOrigAvg = 0, iCurAvg = 0;
    3338   Int  iDeltaC;
    3339 
    3340   for ( y=0; y<iRows; y++ )
    3341   {
    3342     for ( x=0; x<iCols; x++ )
    3343     {       
    3344       iOrigAvg += piOrg[x];
    3345       iCurAvg  += piCur[x];
    3346     }
    3347     piOrg += iStrideOrg;
    3348     piCur += iStrideCur;
    3349   }
    3350 
    3351   piOrg   = pcDtParam->pOrg;
    3352   piCur   = pcDtParam->pCur;
    3353 
    3354   iDeltaC = (iOrigAvg - iCurAvg)/iRows/iCols;
    3355 
    3356   const Int orgMaxSize = MAX_CU_SIZE*MAX_CU_SIZE;
    3357   assert( iRows * iCols <= orgMaxSize );
    3358  
    3359   Pel orgMinusDeltaDc[ orgMaxSize ];
    3360   Pel* tempOrgMinusDeltaDc = orgMinusDeltaDc;
    3361  
    3362   for ( y=0; y<iRows; y++ )
    3363   {
    3364     for ( x=0; x<iCols; x++ )
    3365     {       
    3366       tempOrgMinusDeltaDc[x] = (piOrg[x] - iDeltaC);
    3367     }
    3368     piOrg               += iStrideOrg;
    3369     tempOrgMinusDeltaDc += iStrideOrg;
    3370   }
    3371 
    3372   tempOrgMinusDeltaDc = orgMinusDeltaDc;
    3373 
    3374   piOrg   = pcDtParam->pOrg;
    3375 
    3376 #if NS_HAD
    3377   if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) )
    3378 #else
    3379   if( ( iRows % 8 == 0) && (iCols % 8 == 0) )
    3380 #endif
    3381   {
    3382     Int  iOffsetOrg = iStrideOrg<<3;
    3383     Int  iOffsetCur = iStrideCur<<3;
    3384     for ( y=0; y<iRows; y+= 8 )
    3385     {
    3386       for ( x=0; x<iCols; x+= 8 )
    3387       {
    3388         uiSum += xCalcHADs8x8( &tempOrgMinusDeltaDc[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3389       }
    3390       tempOrgMinusDeltaDc += iOffsetOrg;
    3391       piCur               += iOffsetCur;
    3392     }
    3393   }
    3394 #if NS_HAD
    3395   else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD )
    3396   {
    3397     Int  iOffsetOrg = iStrideOrg<<2;
    3398     Int  iOffsetCur = iStrideCur<<2;
    3399     for ( y=0; y<iRows; y+= 4 )
    3400     {
    3401       for ( x=0; x<iCols; x+= 16 )
    3402       {
    3403         uiSum += xCalcHADs16x4( &tempOrgMinusDeltaDc[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3404       }
    3405       tempOrgMinusDeltaDc += iOffsetOrg;
    3406       piCur               += iOffsetCur;
    3407     }
    3408   }
    3409   else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD )
    3410   {
    3411     Int  iOffsetOrg = iStrideOrg<<4;
    3412     Int  iOffsetCur = iStrideCur<<4;
    3413     for ( y=0; y<iRows; y+= 16 )
    3414     {
    3415       for ( x=0; x<iCols; x+= 4 )
    3416       {
    3417         uiSum += xCalcHADs4x16( &tempOrgMinusDeltaDc[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3418       }
    3419       tempOrgMinusDeltaDc += iOffsetOrg;
    3420       piCur               += iOffsetCur;
    3421     }
    3422   }
    3423 #endif
    3424   else if( ( iRows % 4 == 0) && (iCols % 4 == 0) )
    3425   {
    3426     Int  iOffsetOrg = iStrideOrg<<2;
    3427     Int  iOffsetCur = iStrideCur<<2;
    3428 
    3429     for ( y=0; y<iRows; y+= 4 )
    3430     {
    3431       for ( x=0; x<iCols; x+= 4 )
    3432       {
    3433         uiSum += xCalcHADs4x4( &tempOrgMinusDeltaDc[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3434       }
    3435       tempOrgMinusDeltaDc += iOffsetOrg;
    3436       piCur               += iOffsetCur;
    3437     }
    3438   }
    3439   else if( ( iRows % 2 == 0) && (iCols % 2 == 0) )
    3440   {
    3441     Int  iOffsetOrg = iStrideOrg<<1;
    3442     Int  iOffsetCur = iStrideCur<<1;
    3443     for ( y=0; y<iRows; y+=2 )
    3444     {
    3445       for ( x=0; x<iCols; x+=2 )
    3446       {
    3447         uiSum += xCalcHADs2x2( &tempOrgMinusDeltaDc[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3448       }
    3449       tempOrgMinusDeltaDc += iOffsetOrg;
    3450       piCur               += iOffsetCur;
    3451     }
    3452   }
    3453   else
    3454   {
    3455     assert(false);
    3456   }
    3457 
    3458   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    3459 }
    3460 #endif
    3461 #if NH_3D_VSO
    3462 Void TComRdCost::setLambdaVSO( Double dLambdaVSO )
    3463 {
    3464   m_dLambdaVSO           = dLambdaVSO;
    3465   m_dSqrtLambdaVSO       = sqrt(m_dLambdaVSO);
    3466   m_uiLambdaMotionSADVSO = (UInt)floor(65536.0 *       m_dSqrtLambdaVSO);
    3467   m_uiLambdaMotionSSEVSO = (UInt)floor(65536.0 *       m_dLambdaVSO    );
    3468 }
    3469 #endif
    3470 #if NH_3D_VSO
    3471 Dist TComRdCost::xGetDistVSOMode4( Int iStartPosX, Int iStartPosY, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD )
    3472 {
    3473   AOT(bSAD);
    3474 #if H_3D_VSO_EARLY_SKIP
    3475   RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur, piOrg, iOrgStride); 
    3476 #else
    3477   RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur ); 
    3478 #endif
    3479 
    3480   RMDist iDistMin = (RMDist) RDO_DIST_MIN;
    3481   iDistMin = m_bAllowNegDist ? RDO_DIST_MIN : 0;
    3482  
    3483   iDist = std::min( iDist, (RMDist) RDO_DIST_MAX);
    3484   iDist = std::max( iDist, iDistMin);
    3485   return (Dist) iDist;
    3486 }
    3487 
    3488 
    3489 Dist TComRdCost::getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHAD )
    3490 {
    3491   assert( m_bUseVSO ); 
    3492   assert( this->m_fpDistortFuncVSO != 0 );
    3493 
    3494   Int iPosX;
    3495   Int iPosY;
    3496  
    3497   pcCU->getPosInPic( uiAbsPartIndex, iPosX, iPosY );
    3498    
    3499   Dist dist = (this->*m_fpDistortFuncVSO) ( iPosX, iPosY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight, bHAD ); 
    3500  
    3501   if ( m_bUseWVSO )   
    3502   {
    3503     Int iDWeight   = m_iDWeight   * m_iDWeight  ;
    3504     Int iVSOWeight = m_iVSOWeight * m_iVSOWeight;
    3505     Dist distDepth;
    3506    
    3507     if ( !bHAD )
    3508     {
    3509        distDepth = (Dist) getDistPart( bitDepth, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight, COMPONENT_Y);
    3510     }
    3511     else
    3512     {
    3513        distDepth = (Dist) calcHAD    ( bitDepth, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
    3514     }
    3515    
    3516     dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight);
    3517   }
    3518   return dist;
    3519 };
    3520 
    3521 
    3522 Void TComRdCost::setVSOMode( UInt uiIn )
    3523 {
    3524   m_uiVSOMode = uiIn;
    3525   switch (m_uiVSOMode )
    3526   {
    3527   case   4:
    3528     m_fpDistortFuncVSO = &TComRdCost::xGetDistVSOMode4;
    3529     break;
    3530   default:
    3531     assert(0);
    3532     break;
    3533   }
    3534 }
    3535 
    3536 
    3537 Double TComRdCost::calcRdCostVSO( UInt uiBits, Dist uiDistortion, Bool bFlag, DFunc eDFunc )
    3538 {
    3539   assert( m_bUseLambdaScaleVSO );   
    3540 
    3541   Double dRdCost = 0.0;
    3542   Double dLambda = 0.0;   
    3543 
    3544   switch ( eDFunc )
    3545   {
    3546   case DF_SSE:
    3547     assert(0);
    3548     break;
    3549   case DF_SAD:
    3550     dLambda = (Double)m_uiLambdaMotionSADVSO;
    3551     break;
    3552   case DF_DEFAULT:
    3553     dLambda =         m_dLambdaVSO;
    3554     break;
    3555   case DF_SSE_FRAME:
    3556     dLambda =         m_dFrameLambdaVSO;
    3557     break;
    3558   default:
    3559     assert (0);
    3560     break;
    3561   }
    3562 
    3563   if (bFlag)
    3564   {
    3565     // Intra8x8, Intra4x4 Block only...
    3566 #if SEQUENCE_LEVEL_LOSSLESS
    3567     dRdCost = (Double)(uiBits);
    3568 #else
    3569     dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda));
    3570 #endif
    3571   }
    3572   else
    3573   {
    3574     if (eDFunc == DF_SAD)
    3575     {
    3576       dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)>>16));
    3577       dRdCost = (Double)(Dist)floor(dRdCost);
    3578     }
    3579     else
    3580     {
    3581 #if SEQUENCE_LEVEL_LOSSLESS
    3582       dRdCost = (Double)(uiBits);
    3583 #else
    3584       dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)));
    3585       dRdCost = (Double)(Dist)floor(dRdCost);
    3586 #endif
    3587     }
    3588   }
    3589 
    3590 #if NH_MV
    3591   D_PRINT_INDENT( g_traceRDCost, "VSO Dist: " + n2s(uiDistortion) + " Bits: " + n2s(uiBits) + " RD Cost: " + n2s(dRdCost));
    3592 #endif
    3593 
    3594   return dRdCost;
    3595 }
    3596 
    3597 Void TComRdCost::setRenModelData( const TComDataCU* pcCU, UInt uiAbsPartIndex, const TComYuv* pcYuv, const TComTURecurse* tuRecurseWithPU )
    3598 {
    3599   const TComRectangle &puRect=tuRecurseWithPU->getRect(COMPONENT_Y);
    3600   const UInt  uiCompWidth   = puRect.width;
    3601   const UInt  uiCompHeight  = puRect.height;
    3602 
    3603   const Pel*  piSrc         = pcYuv->getAddr( COMPONENT_Y, uiAbsPartIndex );
    3604   const UInt  uiSrcStride   = pcYuv->getStride( COMPONENT_Y);
    3605   setRenModelData( pcCU, uiAbsPartIndex, piSrc, uiSrcStride, uiCompWidth, uiCompHeight );
    3606 }
    3607 
    3608 Void TComRdCost::setRenModelData( const TComDataCU* pcCU, UInt uiAbsPartIndex, const Pel* piData, Int iStride, Int iBlkWidth, Int iBlkHeight )
    3609 {
    3610   UInt iBlkX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]];
    3611   UInt iBlkY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]];
    3612 
    3613   Int iStartPosX = iBlkX + pcCU->getCUPelX();
    3614   Int iStartPosY = iBlkY + pcCU->getCUPelY();
    3615 
    3616   m_pcRenModel->setData( iStartPosX, iStartPosY, iBlkWidth, iBlkHeight, iStride, piData );
    3617 }
    3618 
    3619 Void TComRdCost::setAllowNegDist( Bool bAllowNegDist )
    3620 {
    3621   m_bAllowNegDist = bAllowNegDist;
    3622 }
    3623 #endif
    36241529
    36251530//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComRdCost.h

    r1386 r1390  
    4646#include "TComSlice.h"
    4747#include "TComRdCostWeightPrediction.h"
    48 #if NH_3D_VSO
    49 #include "../TLibRenderer/TRenModel.h"
    50 #include "TComYuv.h"
    51 #include "TComTU.h"
    52 #endif
    5348
    5449//! \ingroup TLibCommon
     
    5752class DistParam;
    5853class TComPattern;
    59 #if NH_3D_VSO
    60 class TComRdCost;
    61 #endif
    6254
    6355// ====================================================================================================================
     
    6961
    7062
    71 #if NH_3D_VSO
    72 typedef Dist (TComRdCost::*FpDistFuncVSO) ( Int, Int, Pel*, Int, Pel*, Int, UInt, UInt, Bool );
    73 #endif
    7463// ====================================================================================================================
    7564// Class definition
     
    8473  Int   iStrideOrg;
    8574  Int   iStrideCur;
    86 #if NH_3D_VSO
    87   // SAIT_VSO_EST_A0033
    88   Pel*  pVirRec;
    89   Pel*  pVirOrg;
    90   Int   iStrideVir;
    91 #endif
    92 #if NH_3D_IC
    93   Bool  bUseIC;
    94 #endif
    95 #if NH_3D_SDC_INTER
    96   Bool  bUseSDCMRSAD;
    97 #endif
    9875  Int   iRows;
    9976  Int   iCols;
     
    130107     iSubShift(0)
    131108  {
    132 #if NH_3D_VSO
    133     // SAIT_VSO_EST_A0033
    134     pVirRec = NULL;
    135     pVirOrg = NULL;
    136     iStrideVir = 0;
    137 #endif
    138 #if NH_3D_SDC_INTER
    139     bUseSDCMRSAD = false;
    140 #endif
    141109  }
    142110};
     
    156124  Double                  m_dLambdaMotionSSE[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/];
    157125  Double                  m_dFrameLambda;
    158 #if NH_3D_VSO
    159   // SAIT_VSO_EST_A0033
    160   static Double           m_dDisparityCoeff;
    161 #endif
    162126
    163127  // for motion cost
     
    165129  Double                  m_motionLambda;
    166130  Int                     m_iCostScale;
    167 #if NH_3D_DBBP
    168   Bool                    m_bUseMask;
    169 #endif
    170131
    171132public:
    172133  TComRdCost();
    173134  virtual ~TComRdCost();
    174 #if NH_3D_VSO
    175   Double  calcRdCost64( UInt64 uiBits , Dist64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    176   Double  calcRdCost( Double numBits, Dist intDistortion, DFunc eDFunc  = DF_DEFAULT );
    177 #else
    178135  Double calcRdCost( Double numBits, Double distortion, DFunc eDFunc = DF_DEFAULT );
    179 #endif
    180136
    181137
     
    185141
    186142  Double  getSqrtLambda ()   { return m_sqrtLambda; }
    187 #if NH_3D_VSO
    188   // SAIT_VSO_EST_A0033
    189   Void    setDisparityCoeff( Double dDisparityCoeff ) { m_dDisparityCoeff = dDisparityCoeff; }
    190   Double  getDisparityCoeff()                         { return m_dDisparityCoeff; }
    191 #endif
    192143
    193144  Double  getLambda() { return m_dLambda; }
     
    204155  Void    setDistParam( DistParam& rcDP, Int bitDepth, const Pel* p1, Int iStride1, const Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false );
    205156
    206 #if NH_3D_DBBP
    207   Void    setUseMask(Bool b) { m_bUseMask = b; }
    208 #endif
    209157
    210158  Distortion calcHAD(Int bitDepth, const Pel* pi0, Int iStride0, const Pel* pi1, Int iStride1, Int iWidth, Int iHeight );
    211159
    212 #if NH_3D_ENC_DEPTH
    213   UInt    calcVAR(Pel* pi0, Int stride, Int width, Int height, Int cuDepth, UInt maxCuWidth );
    214 #endif 
    215160
    216161  // for motion cost
     
    242187  static Distortion xGetSSE64         ( DistParam* pcDtParam );
    243188  static Distortion xGetSSE16N        ( DistParam* pcDtParam );
    244 #if NH_3D_IC || NH_3D_SDC_INTER
    245   static UInt xGetSADic         ( DistParam* pcDtParam );
    246   static UInt xGetSAD4ic        ( DistParam* pcDtParam );
    247   static UInt xGetSAD8ic        ( DistParam* pcDtParam );
    248   static UInt xGetSAD16ic       ( DistParam* pcDtParam );
    249   static UInt xGetSAD32ic       ( DistParam* pcDtParam );
    250   static UInt xGetSAD64ic       ( DistParam* pcDtParam );
    251   static UInt xGetSAD16Nic      ( DistParam* pcDtParam );
    252 #endif
    253189
    254190  static Distortion xGetSAD           ( DistParam* pcDtParam );
     
    259195  static Distortion xGetSAD64         ( DistParam* pcDtParam );
    260196  static Distortion xGetSAD16N        ( DistParam* pcDtParam );
    261 #if NH_3D_VSO
    262   static UInt xGetVSD           ( DistParam* pcDtParam );
    263   static UInt xGetVSD4          ( DistParam* pcDtParam );
    264   static UInt xGetVSD8          ( DistParam* pcDtParam );
    265   static UInt xGetVSD16         ( DistParam* pcDtParam );
    266   static UInt xGetVSD32         ( DistParam* pcDtParam );
    267   static UInt xGetVSD64         ( DistParam* pcDtParam );
    268   static UInt xGetVSD16N        ( DistParam* pcDtParam );
    269 #endif
    270 
    271 #if NH_3D_IC || NH_3D_SDC_INTER
    272   static UInt xGetSAD12ic       ( DistParam* pcDtParam );
    273   static UInt xGetSAD24ic       ( DistParam* pcDtParam );
    274   static UInt xGetSAD48ic       ( DistParam* pcDtParam );
    275 #endif
     197
    276198
    277199  static Distortion xGetSAD12         ( DistParam* pcDtParam );
     
    280202
    281203
    282 #if NH_3D_IC || NH_3D_SDC_INTER
    283   static UInt xGetHADsic          ( DistParam* pcDtParam );
    284 #endif
    285204
    286205  static Distortion xGetHADs          ( DistParam* pcDtParam );
     
    288207  static Distortion xCalcHADs4x4      ( const Pel *piOrg, const Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    289208  static Distortion xCalcHADs8x8      ( const Pel *piOrg, const Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    290 #if NH_3D_DBBP
    291   static UInt xGetMaskedSSE     ( DistParam* pcDtParam );
    292   static UInt xGetMaskedSAD     ( DistParam* pcDtParam );
    293   static UInt xGetMaskedVSD     ( DistParam* pcDtParam );
    294 #endif
    295209
    296210
     
    299213  Distortion   getDistPart(Int bitDepth, const Pel* piCur, Int iCurStride, const Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, const ComponentID compID, DFunc eDFunc = DF_SSE );
    300214
    301 #if KWU_RC_MADPRED_E0227
    302   UInt   getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height );
    303 #endif
    304 
    305 #if NH_3D_VSO
    306   // SAIT_VSO_EST_A0033
    307   UInt        getDistPartVSD( TComDataCU* pcCu, UInt uiPartOffset, Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHad, DFunc eDFunc = DF_VSD);
    308   static UInt getVSDEstimate( Int dDM, const Pel* pOrg, Int iOrgStride,  const Pel* pVirRec, const Pel* pVirOrg, Int iVirStride, Int x, Int y );
    309 
    310 private:
    311   Double                  m_dLambdaVSO;
    312   Double                  m_dSqrtLambdaVSO;
    313   UInt                    m_uiLambdaMotionSADVSO;
    314   UInt                    m_uiLambdaMotionSSEVSO;
    315   Double                  m_dFrameLambdaVSO;
    316   Bool                    m_bAllowNegDist;
    317   Bool                    m_bUseVSO;
    318   Bool                    m_bUseLambdaScaleVSO;
    319   UInt                    m_uiVSOMode;
    320 
    321   FpDistFuncVSO           m_fpDistortFuncVSO;
    322   TRenModel*              m_pcRenModel;
    323 
    324 
    325   // SAIT_VSO_EST_A0033
    326   TComPicYuv *            m_pcVideoRecPicYuv;
    327   TComPicYuv *            m_pcDepthPicYuv;
    328   Bool                    m_bUseEstimatedVSD;
    329 
    330   // LGE_WVSO_A0119
    331   Int                     m_iDWeight;
    332   Int                     m_iVSOWeight;
    333   Int                     m_iVSDWeight;
    334   Bool                    m_bUseWVSO;
    335 
    336 public:
    337 
    338   Void    setRenModel       ( TRenModel* pcRenModel ) { m_pcRenModel = pcRenModel; }
    339   TRenModel* getRenModel    ( )                       { return m_pcRenModel; }
    340   Void    setRenModelData   ( const TComDataCU* pcCU, UInt uiAbsPartIndex, const TComYuv* pcYuv, const TComTURecurse* tuRecurseWithPU );
    341   Void    setRenModelData   ( const TComDataCU* pcCU, UInt uiAbsPartIndex, const Pel* piData, Int iStride, Int iBlkWidth, Int iBlkHeight );
    342 
    343   Void    setLambdaVSO      ( Double dLambda );
    344   Void    setFrameLambdaVSO ( Double dLambda ) { m_dFrameLambdaVSO = dLambda; };
    345 
    346 
    347   Void    setUseVSO ( Bool bIn )         { m_bUseVSO = bIn; };
    348   Bool    getUseVSO ( )                  { return m_bUseVSO;};
    349 
    350   Bool    getUseRenModel ( )             { return (m_bUseVSO && m_uiVSOMode == 4); };
    351   Void    setUseLambdaScaleVSO(Bool bIn) { m_bUseLambdaScaleVSO = bIn; };
    352   Bool    getUseLambdaScaleVSO( )        { return m_bUseLambdaScaleVSO; };
    353 
    354   Void    setVSOMode( UInt uiIn);
    355   UInt    getVSOMode( )                  { return m_uiVSOMode; }
    356   Void    setAllowNegDist ( Bool bAllowNegDist );
    357 
    358   Double  getSqrtLambdaVSO ()   { return m_dSqrtLambdaVSO; }
    359   Double  getLambdaVSO ()       { return m_dLambdaVSO; }
    360 
    361   Dist    getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Int bitdDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD );
    362   Double  calcRdCostVSO ( UInt   uiBits, Dist   uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    363 
    364   // SAIT_VSO_EST_A0033
    365   Bool    getUseEstimatedVSD( )           { return m_bUseEstimatedVSD; };
    366   Void    setUseEstimatedVSD( Bool bIn )  { m_bUseEstimatedVSD = bIn; };
    367 
    368   TComPicYuv* getVideoRecPicYuv ()                               { return m_pcVideoRecPicYuv; };
    369   Void        setVideoRecPicYuv ( TComPicYuv* pcVideoRecPicYuv ) { m_pcVideoRecPicYuv = pcVideoRecPicYuv; };
    370   TComPicYuv* getDepthPicYuv    ()                               { return m_pcDepthPicYuv; };
    371   Void        setDepthPicYuv    ( TComPicYuv* pcDepthPicYuv )    { m_pcDepthPicYuv = pcDepthPicYuv; };
    372 
    373   // LGE_WVSO_A0119
    374   Void    setUseWVSO ( Bool bIn )         { m_bUseWVSO = bIn; };
    375   Bool    getUseWVSO ( )                  { return m_bUseWVSO;};
    376   Void    setDWeight   ( Int iDWeight   ) { m_iDWeight = iDWeight; };
    377   Int     getDWeight   ()                 { return m_iDWeight; };
    378   Void    setVSOWeight ( Int iVSOWeight ) { m_iVSOWeight = iVSOWeight; };
    379   Int     getVSOWeight ()                 { return m_iVSOWeight; };
    380   Void    setVSDWeight ( Int iVSDWeight ) { m_iVSDWeight = iVSDWeight; };
    381   Int     getVSDWeight ()                 { return m_iVSDWeight; };
    382 
    383 private:
    384   Dist xGetDistVSOMode4( Int iStartPosX, Int iStartPosY, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD );
    385 
    386 #endif // NH_3D_VSO
     215
    387216
    388217
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComRom.cpp

    r1386 r1390  
    253253    }
    254254  }
    255 #if NH_3D_DMM
    256   if( !g_dmmWedgeLists.empty() )
    257   {
    258     for( UInt ui = 0; ui < g_dmmWedgeLists.size(); ui++ ) { g_dmmWedgeLists[ui].clear(); }
    259     g_dmmWedgeLists.clear();
    260   }
    261   if( !g_dmmWedgeNodeLists.empty() )
    262   {
    263     for( UInt ui = 0; ui < g_dmmWedgeNodeLists.size(); ui++ ) { g_dmmWedgeNodeLists[ui].clear(); }
    264     g_dmmWedgeNodeLists.clear();
    265   }
    266 #endif
    267255}
    268256// ====================================================================================================================
     
    509497  //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, DM
    510498  { 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31, DM_CHROMA_IDX};
    511 #if NH_3D_DMM
    512 // ====================================================================================================================
    513 // Depth coding modes
    514 // ====================================================================================================================
    515 const WedgeResolution g_dmmWedgeResolution[6] =
    516 {
    517   HALF_PEL,    //   4x4
    518   HALF_PEL,    //   8x8
    519   FULL_PEL,    //  16x16
    520   FULL_PEL,    //  32x32
    521   FULL_PEL,    //  64x64
    522   FULL_PEL     // 128x128
    523 };
    524 const UChar g_dmm1TabIdxBits[6] =
    525 { //2x2   4x4   8x8 16x16 32x32 64x64
    526      0,    7,   10,   9,    9,   13 };
    527 Bool g_wedgePattern[32*32];
    528 extern std::vector< std::vector<TComWedgelet> >   g_dmmWedgeLists;
    529 extern std::vector< std::vector<TComWedgeNode> >  g_dmmWedgeNodeLists;
    530 #endif
    531499// ====================================================================================================================
    532500// Misc.
     
    790758#endif
    791759#endif
    792 #if NH_3D_DMM
    793 std::vector< std::vector<TComWedgelet>  > g_dmmWedgeLists;
    794 std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists;
    795 Void initWedgeLists( Bool initNodeList )
    796 {
    797   if( !g_dmmWedgeLists.empty() ) return;
    798   for( UInt ui = g_aucConvertToBit[DMM_MIN_SIZE]; ui < (g_aucConvertToBit[DMM_MAX_SIZE]); ui++ )
    799   {
    800     UInt uiWedgeBlockSize = ((UInt)DMM_MIN_SIZE)<<ui;
    801     std::vector<TComWedgelet> acWedgeList;
    802     std::vector<TComWedgeRef> acWedgeRefList;
    803     createWedgeList( uiWedgeBlockSize, uiWedgeBlockSize, acWedgeList, acWedgeRefList, g_dmmWedgeResolution[ui] );
    804     g_dmmWedgeLists.push_back( acWedgeList );
    805     if( initNodeList )
    806     {
    807       // create WedgeNodeList
    808       std::vector<TComWedgeNode> acWedgeNodeList;
    809       for( UInt uiPos = 0; uiPos < acWedgeList.size(); uiPos++ )
    810       {
    811         if( acWedgeList[uiPos].getIsCoarse() )
    812         {
    813           TComWedgeNode cWedgeNode;
    814           cWedgeNode.setPatternIdx( uiPos );
    815           UInt uiRefPos = 0;
    816           for( Int iOffS = -1; iOffS <= 1; iOffS++ )
    817           {
    818             for( Int iOffE = -1; iOffE <= 1; iOffE++ )
    819             {
    820               if( iOffS == 0 && iOffE == 0 ) { continue; }
    821               Int iSx = (Int)acWedgeList[uiPos].getStartX();
    822               Int iSy = (Int)acWedgeList[uiPos].getStartY();
    823               Int iEx = (Int)acWedgeList[uiPos].getEndX();
    824               Int iEy = (Int)acWedgeList[uiPos].getEndY();
    825               switch( acWedgeList[uiPos].getOri() )
    826               {
    827               case( 0 ): { iSx += iOffS; iEy += iOffE; } break;
    828               case( 1 ): { iSy += iOffS; iEx -= iOffE; } break;
    829               case( 2 ): { iSx -= iOffS; iEy -= iOffE; } break;
    830               case( 3 ): { iSy -= iOffS; iEx += iOffE; } break;
    831               case( 4 ): { iSx += iOffS; iEx += iOffE; } break;
    832               case( 5 ): { iSy += iOffS; iEy += iOffE; } break;
    833               default: assert( 0 );
    834               }
    835               for( UInt k = 0; k < acWedgeRefList.size(); k++ )
    836               {
    837                 if( iSx == (Int)acWedgeRefList[k].getStartX() &&
    838                   iSy == (Int)acWedgeRefList[k].getStartY() &&
    839                   iEx == (Int)acWedgeRefList[k].getEndX()   &&
    840                   iEy == (Int)acWedgeRefList[k].getEndY()      )
    841                 {
    842                   if( acWedgeRefList[k].getRefIdx() != cWedgeNode.getPatternIdx() )
    843                   {
    844                     Bool bNew = true;
    845                     for( UInt m = 0; m < uiRefPos; m++ ) { if( acWedgeRefList[k].getRefIdx() == cWedgeNode.getRefineIdx( m ) ) { bNew = false; break; } }
    846                     if( bNew )
    847                     {
    848                       cWedgeNode.setRefineIdx( acWedgeRefList[k].getRefIdx(), uiRefPos );
    849                       uiRefPos++;
    850                       break;
    851                     }
    852                   }
    853                 }
    854               }
    855             }
    856           }
    857           acWedgeNodeList.push_back( cWedgeNode );
    858         }
    859       }
    860       g_dmmWedgeNodeLists.push_back( acWedgeNodeList );
    861     }
    862   }
    863 }
    864 Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes )
    865 {
    866   assert( uiWidth == uiHeight );
    867   Int posStart = 0, posEnd = 0;
    868   UInt uiBlockSize = 0;
    869   switch( eWedgeRes )
    870   {
    871   case(   FULL_PEL ): { uiBlockSize =  uiWidth;     break; }
    872   case(   HALF_PEL ): { uiBlockSize = (uiWidth<<1); break; }
    873   }
    874   TComWedgelet cTempWedgelet( uiWidth, uiHeight );
    875   for( UInt uiOri = 0; uiOri < 6; uiOri++ )
    876   {
    877     posEnd = (Int) racWedgeList.size();
    878     if (uiOri == 0 || uiOri == 4)
    879     {
    880     for( Int iK = 0; iK < uiBlockSize; iK += (uiWidth>=16 ?2:1))
    881     {
    882       for( Int iL = 0; iL < uiBlockSize; iL += ((uiWidth>=16 && uiOri<4)?2:1) )
    883       {
    884         Int xS = iK;
    885         Int yS = 0;
    886         Int xE = (uiOri == 0) ? 0 : iL;
    887         Int yE = (uiOri == 0) ? iL : uiBlockSize - 1;
    888         cTempWedgelet.setWedgelet( xS, yS, xE, yE, uiOri, eWedgeRes, ((iL%2)==0 && (iK%2)==0) );
    889         addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList );
    890       }
    891     }
    892     }
    893     else
    894     {
    895       for (Int pos = posStart; pos < posEnd; pos++)
    896       {
    897         cTempWedgelet.generateWedgePatternByRotate(racWedgeList[pos], uiOri);
    898         addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList );
    899       }
    900     }
    901     posStart = posEnd;
    902   }
    903 }
    904 Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList )
    905 {
    906   Bool bValid = cWedgelet.checkNotPlain();
    907   if( bValid )
    908   {
    909     for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ )
    910     {
    911       if( cWedgelet.checkIdentical( racWedgeList[uiPos].getPattern() ) )
    912       {
    913         TComWedgeRef cWedgeRef;
    914         cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos );
    915         racWedgeRefList.push_back( cWedgeRef );
    916         bValid = false;
    917         return;
    918       }
    919     }
    920   }
    921   if( bValid )
    922   {
    923     for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ )
    924     {
    925       if( cWedgelet.checkInvIdentical( racWedgeList[uiPos].getPattern() ) )
    926       {
    927         TComWedgeRef cWedgeRef;
    928         cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos );
    929         racWedgeRefList.push_back( cWedgeRef );
    930         bValid = false;
    931         return;
    932       }
    933     }
    934   }
    935   if( bValid )
    936   {
    937     racWedgeList.push_back( cWedgelet );
    938     TComWedgeRef cWedgeRef;
    939     cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), (UInt)(racWedgeList.size()-1) );
    940     racWedgeRefList.push_back( cWedgeRef );
    941   }
    942 }
    943 WedgeList* getWedgeListScaled( UInt blkSize )
    944 {
    945   return &g_dmmWedgeLists[ g_aucConvertToBit[( 16 >= blkSize ) ? blkSize : 16] ];
    946 }
    947 WedgeNodeList* getWedgeNodeListScaled( UInt blkSize )
    948 {
    949   return &g_dmmWedgeNodeLists[ g_aucConvertToBit[( 16 >= blkSize ) ? blkSize : 16] ];
    950 }
    951 #endif //NH_3D_DMM
    952760//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComRom.h

    r1386 r1390  
    3939#include<stdio.h>
    4040#include<iostream>
    41 #if NH_3D_DMM
    42 #include "TComWedgelet.h"
    43 #endif
    4441//! \ingroup TLibCommon
    4542//! \{
     
    9188extern const UChar  g_aucIntraModeNumFast_NotUseMPM[MAX_CU_DEPTH];
    9289extern const UChar  g_chroma422IntraAngleMappingTable[NUM_INTRA_MODE];
    93 #if NH_3D_DMM
    94 // ====================================================================================================================
    95 // Depth coding modes
    96 // ====================================================================================================================
    97 extern const WedgeResolution                                 g_dmmWedgeResolution [6];
    98 extern const UChar                                           g_dmm1TabIdxBits     [6];
    99 extern Bool                                                  g_wedgePattern[32*32];
    100 extern       std::vector< std::vector<TComWedgelet> >        g_dmmWedgeLists;
    101 extern       std::vector< std::vector<TComWedgeNode> >       g_dmmWedgeNodeLists;
    102 Void initWedgeLists( Bool initNodeList = false );
    103 Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes );
    104 Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList );
    105 WedgeList*     getWedgeListScaled    ( UInt blkSize );
    106 WedgeNodeList* getWedgeNodeListScaled( UInt blkSize );
    107 __inline Void mapDmmToIntraDir( UInt& intraMode ) { if( isDmmMode( intraMode ) ) intraMode = DC_IDX; }
    108 __inline Void mapDmmToIntraDir(  Int& intraMode ) { if( isDmmMode( intraMode ) ) intraMode = DC_IDX; }
    109 #endif
    11090// ====================================================================================================================
    11191// Mode-Dependent DST Matrices
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComSlice.cpp

    r1386 r1390  
    118118, m_viewId                        (0)
    119119, m_viewIndex                     (0)
    120 #if NH_3D_VSO
    121 , m_isDepth                       (false)
    122 #endif
    123120#if NH_MV
    124121, m_pocResetFlag                  (false)
     
    139136, m_pocMsbValRequiredFlag         (false)
    140137#endif
    141 #if NH_3D_IC
    142 , m_bApplyIC                      (false)
    143 , m_icSkipParseFlag               (false)
    144 #endif
    145 #if NH_3D
    146 , m_inCmpPredFlag                 (false)
    147 , m_numViews                      (0)
    148 , m_depthToDisparityB             (NULL)
    149 , m_depthToDisparityF             (NULL)
    150 #endif
    151 #if NH_3D_DIS
    152 , m_bApplyDIS                     (false)
    153 #endif
    154138#endif
    155139{
     
    210194  }
    211195#endif
    212 #if NH_3D
    213   m_iDefaultRefViewIdx = -1;
    214   m_bDefaultRefViewIdxAvailableFlag = false;
    215   m_ivMvPredFlag           = false;
    216   m_ivMvScalingFlag        = false;
    217   m_ivResPredFlag          = false; 
    218   m_depthRefinementFlag    = false;
    219   m_viewSynthesisPredFlag  = false;
    220   m_depthBasedBlkPartFlag  = false;
    221   m_mpiFlag                = false;
    222   m_intraContourFlag       = false;
    223   m_intraSdcWedgeFlag      = false;
    224   m_qtPredFlag             = false;
    225   m_interSdcFlag           = false;
    226   m_depthIntraSkipFlag     = false;
    227   m_subPbSize              =  1 << 6;
    228   m_mpiSubPbSize           =  1 << 6;
    229 
    230   m_aaiCodedOffset.resize(2);
    231   m_aaiCodedScale .resize(2);
    232   for (Int i = 0; i < 2; i++)
    233   {
    234     m_aaiCodedOffset[i].resize(MAX_NUM_LAYERS);
    235     m_aaiCodedScale [i].resize(MAX_NUM_LAYERS);
    236   }
    237  
    238 #endif
    239196
    240197}
     
    242199TComSlice::~TComSlice()
    243200{
    244 #if NH_3D
    245   for( UInt i = 0; i < m_numViews; i++ )
    246   {
    247     if ( m_depthToDisparityB && m_depthToDisparityB[ i ] )
    248     {
    249       delete[] m_depthToDisparityB [ i ];
    250     }
    251 
    252     if ( m_depthToDisparityF && m_depthToDisparityF[ i ] )
    253     {
    254       delete[] m_depthToDisparityF [ i ];
    255     }
    256   }
    257 
    258   if ( m_depthToDisparityF )
    259   {
    260     delete[] m_depthToDisparityF;
    261   }
    262 
    263   m_depthToDisparityF = NULL;
    264 
    265   if ( m_depthToDisparityB )
    266     delete[] m_depthToDisparityB;
    267 
    268   m_depthToDisparityB = NULL;
    269 #endif
    270201
    271202}
     
    289220    m_iSliceChromaQpDelta[component] = 0;
    290221  }
    291 #if NH_3D_IV_MERGE
    292   m_maxNumMergeCand = MRG_MAX_NUM_CANDS_MEM;
    293 #else
    294222  m_maxNumMergeCand = MRG_MAX_NUM_CANDS;
    295 #endif
    296223
    297224  m_bFinalized=false;
     
    300227  m_cabacInitFlag        = false;
    301228  m_enableTMVPFlag = true;
    302 #if NH_3D_TMVP
    303   m_aiAlterRefIdx[0]                  = -1;
    304   m_aiAlterRefIdx[1]                  = -1;
    305 #endif
    306229}
    307230
     
    619542  UInt NumPocLtCurr = 0;
    620543  Int i;
    621 #if NH_3D
    622   m_pocsInCurrRPSs.clear();
    623 #endif
    624544  for(i=0; i < m_pRPS->getNumberOfNegativePictures(); i++)
    625545  {
     
    632552      NumPocStCurr0++;
    633553      pcRefPic->setCheckLTMSBPresent(false); 
    634 #if NH_3D
    635       m_pocsInCurrRPSs.push_back( pcRefPic->getPOC() );
    636 #endif
    637554    }
    638555  }
     
    648565      NumPocStCurr1++;
    649566      pcRefPic->setCheckLTMSBPresent(false); 
    650 #if NH_3D
    651       m_pocsInCurrRPSs.push_back( pcRefPic->getPOC() );
    652 #endif
    653567    }
    654568  }
     
    663577      RefPicSetLtCurr[NumPocLtCurr] = pcRefPic;
    664578      NumPocLtCurr++;
    665 #if NH_3D
    666       m_pocsInCurrRPSs.push_back( pcRefPic->getPOC() );
    667 #endif
    668579    }
    669580    if(pcRefPic==NULL)
     
    675586
    676587  Int numPocInterCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr;
    677 #if NH_3D
    678   assert( numPocInterCurr == (Int) m_pocsInCurrRPSs.size() );
    679 #endif
    680588  numPocTotalCurr = numPocInterCurr + getNumActiveRefLayerPics( );
    681589  assert( numPocTotalCurr == getNumRpsCurrTempList() );
     
    827735  }
    828736}
    829 #if NH_3D
    830 #if NH_3D_TMVP
    831 Void TComSlice::generateAlterRefforTMVP()
    832 {
    833   for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    834   {       
    835     if ( this->getNumRefIdx( RefPicList( uiRefListIdx ) ) == 0)
    836     {
    837         continue;
    838     }
    839     Bool bZeroIdxLtFlag = this->getRefPic(RefPicList(uiRefListIdx), 0)->getIsLongTerm();
    840     for(Int i = 1; i < this->getNumRefIdx(RefPicList(uiRefListIdx)); i++ )
    841     {
    842       if ( ( bZeroIdxLtFlag && !this->getRefPic(RefPicList(uiRefListIdx), i)->getIsLongTerm() ) ||
    843            (!bZeroIdxLtFlag &&  this->getRefPic(RefPicList(uiRefListIdx), i)->getIsLongTerm() ) )
    844       {
    845         this->setAlterRefIdx(RefPicList(uiRefListIdx),i);
    846         break;
    847       }
    848     }
    849   }
    850 }
    851 #endif
    852 #endif
    853 
    854 #if NH_3D
    855 Void TComSlice::setCamparaSlice( Int** aaiScale, Int** aaiOffset )
    856 
    857   Int voiInVps      = m_pcVPS->getVoiInVps(getViewIndex() );
    858   if( m_pcVPS->getNumCp( voiInVps ) > 0 )
    859   {   
    860     if( m_pcVPS->getCpInSliceSegmentHeaderFlag( voiInVps ) )
    861     {
    862       for( Int m = 0; m < m_pcVPS->getNumCp( voiInVps ); m++ )
    863       {     
    864         Int j      = m_pcVPS->getCpRefVoi( voiInVps, m );
    865         Int jInVps = m_pcVPS->getVoiInVps( j );
    866 
    867         setCpScale   ( jInVps , aaiScale [ jInVps   ][ voiInVps ]);
    868         setCpInvScale( jInVps , aaiScale [ voiInVps ][ jInVps   ]);
    869         setCpOff     ( jInVps , aaiOffset[ jInVps   ][ voiInVps ]);
    870         setCpInvOff  ( jInVps , aaiOffset[ voiInVps ][ jInVps   ]);
    871       }
    872     }
    873   }
    874 }
    875 #endif
     737
    876738
    877739Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic)
     
    11691031  }
    11701032#endif
    1171 #if NH_3D_DIS
    1172   m_bApplyDIS = pSrc->m_bApplyDIS;
    1173 #endif
    1174 #if NH_3D_IC
    1175   m_bApplyIC = pSrc->m_bApplyIC;
    1176   m_icSkipParseFlag = pSrc->m_icSkipParseFlag;
    1177 #endif
    11781033
    11791034}
     
    19231778  for ( Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++)
    19241779  {
    1925 #if !NH_3D_FIX_TICKET_107
    19261780    m_layerSetIdxForOlsMinus1[i]  = -1;
    1927 #endif
    19281781    for ( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++)
    19291782    {
     
    19721825    m_layerIdInNuh      [i] = ( i == 0 ) ? 0 : -1;
    19731826    m_numDirectRefLayers[i] = 0;
    1974 #if NH_3D
    1975     m_numRefListLayers[i] = 0;
    1976 #endif
    19771827    m_vpsRepFormatIdx    [i] = 0;
    19781828    m_pocLsbNotPresentFlag[i] = 0;   
    19791829    m_viewIdVal          [i] = 0;
    19801830
    1981 #if NH_3D
    1982     m_viewIndex         [i] = -1;
    1983 #endif
    19841831
    19851832    for( Int j = 0; j < MAX_NUM_LAYERS; j++ )
     
    19891836      m_dependencyFlag  [i][j]    = false;
    19901837      m_idDirectRefLayer[i][j]    = -1;
    1991 #if NH_3D
    1992       m_idRefListLayer[i][j]    = -1;
    1993 #endif
    19941838      m_idPredictedLayer[i][j]    = -1;
    19951839      m_idRefLayer      [i][j]    = -1;
     
    20011845      m_dimensionId[i][j] = 0;
    20021846    }
    2003 #if NH_3D_ARP
    2004 #endif
    20051847  } 
    20061848#endif
     
    20781920    Int iNuhLId = getLayerIdInNuh( i );
    20791921    Int d = 0;
    2080 #if NH_3D
    2081     Int l = 0;
    2082 #endif
    20831922    Int r = 0;
    20841923    Int p = 0;
     
    20911930        m_idDirectRefLayer[iNuhLId][d++] = jNuhLid;
    20921931      }
    2093 #if NH_3D
    2094       if( getDirectDependencyFlag( i , j ) && ( getDepthId( iNuhLId ) == getDepthId( jNuhLid ) ))
    2095       {
    2096         m_idRefListLayer [iNuhLId][l++] = jNuhLid;
    2097       }
    2098 #endif
    20991932
    21001933      if( getDependencyFlag( i , j ) )
     
    21081941    }
    21091942    m_numDirectRefLayers[ iNuhLId ] = d;
    2110 #if NH_3D
    2111     m_numRefListLayers[ iNuhLId ] = l;
    2112 #endif
    21131943
    21141944    m_numRefLayers      [ iNuhLId ] = r;
     
    21491979{
    21501980  m_numViews = 1;
    2151 #if NH_3D
    2152   AOF( m_viewOIdxList.size() == 0 );   
    2153   m_viewOIdxList.push_back( 0 );       
    2154 #endif
    21551981
    21561982  for( Int i = 0; i <=  getMaxLayersMinus1(); i++ )
     
    21701996      {
    21711997        m_numViews++;
    2172 #if NH_3D
    2173         m_viewOIdxList.push_back( getViewOrderIdx( lId ) );       
    2174 #endif
    21751998      }
    21761999    }
     
    21842007}
    21852008
    2186 #if NH_3D_VSO
    2187 Int TComVPS::getLayerIdInNuh( Int viewIndex, Bool depthFlag, Int auxId ) const
    2188 {
    2189   Int foundLayerIdinNuh = -1;
    2190 
    2191   for (Int layerIdInVps = 0 ; layerIdInVps <= getMaxLayersMinus1(); layerIdInVps++ )
    2192   {
    2193     Int layerIdInNuh = getLayerIdInNuh( layerIdInVps );
    2194 #if !NH_3D
    2195     if( ( getViewIndex( layerIdInNuh ) == viewIndex ) && ( getAuxId( layerIdInNuh ) == ( depthFlag ? 2 : 0 ) )  )
    2196 #else
    2197     if( ( getViewIndex( layerIdInNuh ) == viewIndex ) && ( getDepthId( layerIdInNuh ) == ( depthFlag ? 1 : 0 ) )  )
    2198 #endif
    2199     {
    2200       foundLayerIdinNuh = layerIdInNuh;
    2201       break;
    2202     }
    2203   }
    2204   return foundLayerIdinNuh;
    2205 }
    2206 #endif
    2207 #if NH_3D
    2208 Void TComVPS::createCamPars(Int iNumViews)
    2209 {
    2210   m_numCp                     .resize( iNumViews );
    2211   m_cpRefVoi                  .resize( iNumViews );
    2212   m_cpInSliceSegmentHeaderFlag.resize( iNumViews );
    2213   m_cpPresentFlag             .resize( iNumViews );
    2214   m_aaaiCodedScale            .resize( iNumViews );
    2215   m_aaaiCodedOffset           .resize( iNumViews );
    2216 
    2217   for ( Int i = 0; i < iNumViews ; i++ )
    2218   {
    2219     m_numCp                     [i] = 0;
    2220     m_cpRefVoi                  [i].resize( iNumViews );
    2221     m_cpInSliceSegmentHeaderFlag[i] = false;         
    2222     m_aaaiCodedScale            [i].resize( 2 );
    2223     m_aaaiCodedOffset           [i].resize( 2 );       
    2224     m_cpPresentFlag             [i].resize( iNumViews );
    2225 
    2226     for ( Int j = 0; j < iNumViews; j++)
    2227     {
    2228       m_cpRefVoi             [i][j] = 0;
    2229       m_cpPresentFlag        [i][j] = false;
    2230     }
    2231 
    2232     for ( Int j = 0; j < 2; j++ )
    2233     {
    2234       m_aaaiCodedScale       [i][j].resize( MAX_NUM_LAYERS );
    2235       m_aaaiCodedOffset      [i][j].resize( MAX_NUM_LAYERS );
    2236 
    2237       for ( Int k = 0; k < MAX_NUM_LAYERS; k++ )
    2238       {
    2239         m_aaaiCodedScale [i][j][k] = 0;
    2240         m_aaaiCodedOffset[i][j][k] = 0;
    2241       }
    2242     }
    2243   }
    2244 }
    2245 #endif // NH_3D
    22462009
    22472010
     
    24962259  vector<Int> range;
    24972260
    2498 #if NH_3D
    2499   vector<Int> depthId;
    2500 #endif
    25012261
    25022262  vector<Int> viewOrderIndex;
     
    25122272    auxId         .push_back( getAuxId       ( i ) );     
    25132273    viewId        .push_back( getViewId      ( getLayerIdInNuh( i ) ) );
    2514 #if NH_3D 
    2515     depthId.push_back( getDepthId( i ) );
    2516 #endif
    25172274  }
    25182275  std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Layer Dependencies" << std::endl;
     
    25232280  xPrintArray( "IdRefLayer"      , getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numRefLayers, m_idRefLayer, true );
    25242281  xPrintArray( "IdDirectRefLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numDirectRefLayers, m_idDirectRefLayer, true );
    2525 #if NH_3D
    2526   xPrintArray( "IdRefListLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numRefListLayers, m_idRefListLayer, true );
    2527 #endif
    25282282
    25292283  std::cout << std::endl;
     
    26192373}
    26202374
    2621 #if NH_3D
    2622 Void TComVPS::initViewCompLayer()
    2623 {
    2624   assert( m_viewCompLayerId.size() == 0 && m_viewCompLayerPresentFlag.size() == 0  );
    2625   for( Int i = 0; i < getNumViews(); i++ )
    2626   {
    2627     m_viewCompLayerId         .push_back( std::vector<Int>(0)  );
    2628     m_viewCompLayerPresentFlag.push_back( std::vector<Bool>(0) );     
    2629 
    2630     for( Int depFlag = 0; depFlag  <=  1; depFlag++ )
    2631     {
    2632       Int iViewOIdx = getViewOIdxList( i );
    2633       Int layerId = -1;
    2634       for( Int j = 0; j  <=  getMaxLayersMinus1(); j++ )
    2635       {
    2636         Int jNuhLId = getLayerIdInNuh( j );
    2637         if( getVpsDepthFlag( jNuhLId ) == ( (Bool) depFlag )  &&  getViewOrderIdx( jNuhLId )  ==  iViewOIdx 
    2638           &&  getDependencyId( jNuhLId )  ==  0  &&  getAuxId( jNuhLId )  ==  0 )
    2639         {
    2640           layerId = jNuhLId;
    2641         }
    2642       }
    2643       m_viewCompLayerPresentFlag[ i ].push_back( layerId  !=  -1 );
    2644       m_viewCompLayerId         [ i ].push_back( layerId );       
    2645     }
    2646   }
    2647 }
    2648 
    2649 Int TComVPS::getVoiInVps(Int viewOIdx) const
    2650 {
    2651   for ( Int i = 0; i < m_viewOIdxList.size(); i++ )
    2652   {
    2653     if  ( m_viewOIdxList[ i ] == viewOIdx )
    2654     {
    2655       return i;
    2656     }
    2657   }
    2658   assert( 0 );   
    2659   return -1;
    2660 }
    2661 
    2662 Void TComVPS::deriveCpPresentFlag()
    2663 {
    2664   for( Int nInVps = 0; nInVps < getNumViews(); nInVps++  )
    2665   {
    2666     for( Int mInVps = 0; mInVps < getNumViews(); mInVps++ )
    2667     {
    2668       m_cpPresentFlag[nInVps][mInVps] = 0;
    2669     }
    2670   }
    2671 
    2672   for( Int n = 1; n < getNumViews(); n++ )
    2673   {
    2674     Int iInVps = getVoiInVps(  getViewOIdxList( n ) );     
    2675     for( Int m = 0; m < getNumCp( iInVps ); m++ )
    2676     {
    2677       m_cpPresentFlag[ iInVps ][ getVoiInVps( getCpRefVoi( iInVps, m ) ) ] = 1;
    2678     }
    2679   }
    2680 }
    2681 
    2682 #endif
    26832375#endif // NH_MV
    26842376
     
    28452537, m_pocResetInfoPresentFlag          (false)
    28462538#endif
    2847 #if NH_3D_DLT
    2848 , m_cDLT                             ()
    2849 #endif
    28502539{
    28512540#if NH_MV
     
    28622551}
    28632552
    2864 #if NH_3D_DLT
    2865 TComDLT::TComDLT()
    2866 : m_bDltPresentFlag(false)
    2867 , m_iNumDepthViews(0)
    2868 , m_uiDepthViewBitDepth(8)
    2869 {
    2870   for( Int i = 0; i < MAX_NUM_LAYERS; i++ )
    2871   {
    2872     m_bUseDLTFlag                 [i] = false;
    2873     m_bInterViewDltPredEnableFlag [i] = false;
    2874     m_bDltBitMapRepFlag           [i] = false;
    2875 
    2876     // allocate some memory and initialize with default mapping
    2877     m_iNumDepthmapValues[i] = ((1 << m_uiDepthViewBitDepth)-1)+1;
    2878     m_iDepthValue2Idx[i]    = std::vector<Int>(m_iNumDepthmapValues[i]);
    2879     m_iIdx2DepthValue[i]    = std::vector<Int>(m_iNumDepthmapValues[i]);
    2880    
    2881     m_iDepthIdxToLayerId[i] = i;
    2882 
    2883     //default mapping
    2884     for (Int d=0; d<m_iNumDepthmapValues[i]; d++)
    2885     {
    2886       m_iDepthValue2Idx[i][d] = d;
    2887       m_iIdx2DepthValue[i][d] = d;
    2888     }
    2889   }
    2890 }
    2891 
    2892 TComDLT::~TComDLT()
    2893 {
    2894  
    2895 }
    2896 
    2897 Void TComDLT::setDepthLUTs(Int layerIdInVps, std::vector<Int> idxToDepthValueTable, Int iNumDepthValues)
    2898 {
    2899   if( iNumDepthValues == 0 ) // default mapping only
    2900     return;
    2901 
    2902   // copy idx2DepthValue to internal array
    2903   m_iIdx2DepthValue[layerIdInVps] = idxToDepthValueTable;
    2904 
    2905   UInt uiMaxDepthValue = ((1 << m_uiDepthViewBitDepth)-1);
    2906   for(Int p=0; p<=uiMaxDepthValue; p++)
    2907   {
    2908     Int iIdxDown    = 0;
    2909     Int iIdxUp      = iNumDepthValues-1;
    2910     Bool bFound     = false;
    2911 
    2912     // iterate over indices to find lower closest depth
    2913     Int i = 1;
    2914     while(!bFound && i<iNumDepthValues)
    2915     {
    2916       if( m_iIdx2DepthValue[layerIdInVps][i] > p )
    2917       {
    2918         iIdxDown  = i-1;
    2919         bFound    = true;
    2920       }
    2921 
    2922       i++;
    2923     }
    2924     iIdxUp = bFound ?  iIdxDown + 1 : iNumDepthValues-1;
    2925 
    2926     // assign closer depth value/idx
    2927     if( abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxDown]) < abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxUp]) )
    2928     {
    2929       m_iDepthValue2Idx[layerIdInVps][p] = iIdxDown;
    2930     }
    2931     else
    2932     {
    2933       m_iDepthValue2Idx[layerIdInVps][p] = iIdxUp;
    2934     }
    2935 
    2936   }
    2937 
    2938   // update DLT variables
    2939   m_iNumDepthmapValues[layerIdInVps] = iNumDepthValues;
    2940 }
    2941 
    2942 Void TComDLT::getDeltaDLT( Int layerIdInVps, std::vector<Int> piDLTInRef, UInt uiDLTInRefNum, std::vector<Int>& riDeltaDLTOut, UInt&ruiDeltaDLTOutNum ) const
    2943 {
    2944   Bool abBM0[ 256 ];
    2945   Bool abBM1[ 256 ];
    2946  
    2947   memset( abBM0, 0, sizeof( abBM0 ));
    2948   memset( abBM1, 0, sizeof( abBM1 ));
    2949  
    2950   // convert reference DLT to bit string
    2951   for( Int i = 0; i < uiDLTInRefNum; i++ )
    2952   {
    2953     abBM0[ piDLTInRef[ i ] ] = true;
    2954   }
    2955   // convert internal DLT to bit string
    2956   for( Int i = 0; i < m_iNumDepthmapValues[ layerIdInVps ]; i++ )
    2957   {
    2958     abBM1[ m_iIdx2DepthValue[ layerIdInVps ][ i ] ] = true;
    2959   }
    2960  
    2961   ruiDeltaDLTOutNum = 0;
    2962   for( Int i = 0; i < 256; i++ )
    2963   {
    2964     if( abBM0[ i ] ^ abBM1[ i ] )
    2965     {
    2966       riDeltaDLTOut[ ruiDeltaDLTOutNum++ ] = i;
    2967     }
    2968   }
    2969 }
    2970 
    2971 Void TComDLT::setDeltaDLT( Int layerIdInVps, std::vector<Int> piDLTInRef, UInt uiDLTInRefNum, std::vector<Int> piDeltaDLTIn, UInt uiDeltaDLTInNum )
    2972 {
    2973   Bool abBM0[ 256 ];
    2974   Bool abBM1[ 256 ];
    2975  
    2976   memset( abBM0, 0, sizeof( abBM0 ));
    2977   memset( abBM1, 0, sizeof( abBM1 ));
    2978  
    2979   // convert reference DLT to bit string
    2980   for( Int i = 0; i < uiDLTInRefNum; i++ )
    2981   {
    2982     abBM0[ piDLTInRef[ i ] ] = true;
    2983   }
    2984   // convert delta DLT to bit string
    2985   for( Int i = 0; i < uiDeltaDLTInNum; i++ )
    2986   {
    2987     abBM1[ piDeltaDLTIn[ i ] ] = true;
    2988   }
    2989  
    2990   std::vector<Int> aiIdx2DepthValue(256, 0);
    2991   UInt uiNumDepthValues = 0;
    2992   std::fill(aiIdx2DepthValue.begin(), aiIdx2DepthValue.end(), 0);
    2993  
    2994   for( Int i = 0; i < 256; i++ )
    2995   {
    2996     if( abBM0[ i ] ^ abBM1[ i ] )
    2997     {
    2998       aiIdx2DepthValue[ uiNumDepthValues++ ] = i;
    2999     }
    3000   }
    3001  
    3002   // update internal tables
    3003   setDepthLUTs(layerIdInVps, aiIdx2DepthValue, uiNumDepthValues);
    3004 }
    3005 
    3006 #endif
    30072553
    30082554#if NH_MV
     
    35123058{
    35133059  const TComVPS* vps = getVPS();
    3514 #if NH_3D
    3515   Int refLayerIdx = vps->getLayerIdInVps( vps->getIdRefListLayer( getLayerId(), i ) );
    3516 #else
    35173060  Int refLayerIdx = vps->getLayerIdInVps( vps->getIdDirectRefLayer( getLayerId(), i ) );
    3518 #endif
    35193061
    35203062  Bool refLayerPicFlag = ( vps->getSubLayersVpsMaxMinus1( refLayerIdx ) >=  getTLayer()  && ( getTLayer() == 0   ||
     
    35273069  Int refLayerPicIdc = -1;
    35283070  Int curj = 0;
    3529 #if NH_3D
    3530   for( Int i = 0;  i < getVPS()->getNumRefListLayers( getLayerId()) ; i++ )
    3531 #else
    35323071  for( Int i = 0;  i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ )
    3533 #endif
    35343072  {
    35353073    if( getRefLayerPicFlag( i ) )
     
    35523090
    35533091  Int numRefLayerPics = 0;
    3554 #if NH_3D
    3555   for( Int i = 0;  i < getVPS()->getNumRefListLayers( getLayerId()) ; i++ )
    3556 #else
    35573092  for( Int i = 0;  i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ )
    3558 #endif
    35593093  {
    35603094    numRefLayerPics += getRefLayerPicFlag( i );
     
    35813115    numActiveRefLayerPics = 0;
    35823116  }
    3583 #if NH_3D
    3584   else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumRefListLayers( getLayerId() ) == 1 )
    3585 #else
    35863117  else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumDirectRefLayers( getLayerId() ) == 1 )
    3587 #endif
    35883118  {
    35893119    numActiveRefLayerPics = 1;
     
    35983128Int TComSlice::getRefPicLayerId( Int i ) const
    35993129{
    3600 #if NH_3D
    3601   return getVPS()->getIdRefListLayer( getLayerId(), getInterLayerPredLayerIdc( i ) );
    3602 #else
    36033130  return getVPS()->getIdDirectRefLayer( getLayerId(), getInterLayerPredLayerIdc( i ) );
    3604 #endif
    3605 }
    3606 #endif
    3607 #if NH_3D_NBDV
    3608 Void TComSlice::setDefaultRefView()
    3609 {
    3610   setDefaultRefViewIdx(-1);
    3611   setDefaultRefViewIdxAvailableFlag(false);
    3612 
    3613   Int valid = 0;
    3614   Int DefaultRefViewIdx = -1;
    3615 
    3616   for(UInt curViewIdx = 0; curViewIdx < getViewIndex() && valid == 0; curViewIdx++)
    3617   {
    3618     for(Int iRefListId = 0; (iRefListId < (isInterB() ? 2 : 1)) && !isIntra() && valid == 0; iRefListId++)
    3619     {
    3620       RefPicList eRefPicList = RefPicList(iRefListId);
    3621       Int        iNumRefPics = getNumRefIdx(eRefPicList);
    3622 
    3623       for(Int i = 0; i < iNumRefPics; i++)
    3624       {
    3625         if(getPOC() == getRefPic(eRefPicList, i)->getPOC() && curViewIdx == getRefPic(eRefPicList, i)->getViewIndex())
    3626         {
    3627           valid = 1;
    3628           DefaultRefViewIdx = curViewIdx;
    3629           break;
    3630         }
    3631       }
    3632     }
    3633   }
    3634 
    3635   if(valid)
    3636   {
    3637     setDefaultRefViewIdx(DefaultRefViewIdx);
    3638     setDefaultRefViewIdxAvailableFlag(true);
    3639   }
    3640 }
    3641 #endif
    3642 
    3643 #if NH_3D_ARP
    3644 Void TComSlice::setARPStepNum( TComPicLists*ivPicLists )
    3645 {
    3646   Bool tempRefPicInListsFlag = false;
    3647   if( !getIvResPredFlag() || this->isIRAP())
    3648   {
    3649     m_nARPStepNum = 0;
    3650   }
    3651   else
    3652   {
    3653     setFirstTRefIdx (REF_PIC_LIST_0, -1);
    3654     setFirstTRefIdx (REF_PIC_LIST_1, -1);
    3655     for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ )
    3656     {
    3657       Int diffPOC=MAX_INT;
    3658       Int idx=-1;
    3659       for(Int i = 0; i < getNumRefIdx(RefPicList(refListIdx)); i++ )
    3660       {
    3661         if ( getRefPic(RefPicList(refListIdx), i)->getPOC() != getPOC() )
    3662         {
    3663           if( abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC()) < diffPOC)
    3664           {
    3665             diffPOC=abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC());
    3666             idx=i;
    3667           }
    3668         }
    3669         if(idx>=0)
    3670         {
    3671           setFirstTRefIdx (RefPicList(refListIdx), idx);
    3672         }
    3673       }
    3674     }
    3675     tempRefPicInListsFlag = (getFirstTRefIdx(REF_PIC_LIST_0) >= 0 || getFirstTRefIdx(REF_PIC_LIST_1) >= 0) && getDefaultRefViewIdxAvailableFlag();
    3676     m_nARPStepNum = tempRefPicInListsFlag ? 3 : 0;
    3677   }
    3678 
    3679   if (tempRefPicInListsFlag)
    3680   {
    3681     for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ )
    3682     {
    3683       RefPicList eRefPicList = RefPicList( refListIdx );
    3684       Int prevPOC = getRefPic(eRefPicList, getFirstTRefIdx(eRefPicList) )->getPOC();
    3685       for( Int i = 0; i < getNumActiveRefLayerPics(); i++ )
    3686       {
    3687         Int layerIdInNuh = getRefPicLayerId( i );
    3688 
    3689         TComPic* picV = getIvPic( getIsDepth(), getVPS()->getViewIndex( layerIdInNuh ) );
    3690         assert( picV != NULL );
    3691         IntAry1d pocsInCurrRPSsPicV = picV->getSlice(0)->getPocsInCurrRPSs();
    3692         Bool refRpRefAvailFlag = false;
    3693         for (Int idx = 0; idx < pocsInCurrRPSsPicV.size(); idx++)
    3694         {
    3695           if ( pocsInCurrRPSsPicV[idx] == prevPOC )
    3696           {
    3697             refRpRefAvailFlag = true;
    3698             break;
    3699           }
    3700         }
    3701 
    3702         if (getFirstTRefIdx(eRefPicList) >= 0 && refRpRefAvailFlag )
    3703         {
    3704           m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = true;
    3705         }
    3706         else
    3707         {
    3708           m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = false;
    3709         }
    3710       }
    3711     }
    3712   }
    3713   if( m_nARPStepNum > 1)
    3714   {
    3715     for(Int i = 0; i < getNumActiveRefLayerPics(); i ++ )
    3716     {
    3717       Int  iLayerId = getRefPicLayerId( i );
    3718       Int  iViewIdx =   getVPS()->getViewIndex(iLayerId);
    3719       Bool bIsDepth = ( getVPS()->getDepthId  ( iLayerId ) == 1 );
    3720       if( iViewIdx<getViewIndex() && !bIsDepth )
    3721       {
    3722         setBaseViewRefPicList( ivPicLists->getSubDpb( iLayerId, false ), iViewIdx );
    3723       }
    3724     }
    3725   }
    3726 }
    3727 #endif
    3728 
    3729 #if NH_3D_IC
    3730 // This is an encoder only function and should be moved to TEncSlice or TEncSearch!!
    3731 Void TComSlice::xSetApplyIC(Bool bUseLowLatencyICEnc)
    3732 {
    3733   if(bUseLowLatencyICEnc)
    3734   {
    3735     Bool existInterViewRef=false;
    3736     TComPic* pcCurrPic = getPic();
    3737     TComPic* pcRefPic = NULL;
    3738     for ( Int i = 0; (i < getNumRefIdx( REF_PIC_LIST_0 )) && !existInterViewRef; i++ )
    3739     {
    3740       pcRefPic = getRefPic( REF_PIC_LIST_0, i );
    3741       if ( pcRefPic != NULL )
    3742       {
    3743         if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() )
    3744         {
    3745           existInterViewRef = true;
    3746         }
    3747       }
    3748     }
    3749 
    3750     for ( Int i = 0; (i < getNumRefIdx( REF_PIC_LIST_1 )) && !existInterViewRef; i++ )
    3751     {
    3752       pcRefPic = getRefPic( REF_PIC_LIST_1, i );
    3753       if ( pcRefPic != NULL )
    3754       {
    3755         if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() )
    3756         {
    3757           existInterViewRef = true;       
    3758         }
    3759       }
    3760     }
    3761 
    3762     if(!existInterViewRef)
    3763     {
    3764       m_bApplyIC = false;
    3765     }
    3766     else
    3767     {
    3768       Int curLayer=getDepth();
    3769       if( curLayer>9) curLayer=9; // Max layer is 10
    3770 
    3771       m_bApplyIC = true;
    3772       Int refLayer = curLayer-1;
    3773 
    3774       Int ICEnableCandidate = getICEnableCandidate(refLayer);
    3775       Int ICEnableNum = getICEnableNum(refLayer);
    3776       if( (refLayer>=0) && (ICEnableCandidate>0) )
    3777       {   
    3778         Double ratio=Double(ICEnableNum/Double(ICEnableCandidate));
    3779 
    3780         if( ratio > IC_LOW_LATENCY_ENCODING_THRESHOLD)
    3781         {
    3782           m_bApplyIC=true;
    3783         }
    3784         else
    3785         {
    3786           m_bApplyIC=false;
    3787         }
    3788       }
    3789       setICEnableCandidate(curLayer, 0);
    3790       setICEnableNum(curLayer, 0);
    3791     }
    3792   }
    3793   else
    3794   {       
    3795     TComPic*    pcCurrPic = getPic();
    3796     TComPicYuv* pcCurrPicYuv = pcCurrPic->getPicYuvOrg();
    3797    
    3798     // Get InterView Reference picture
    3799     // !!!!! Assume only one Interview Reference Picture in L0
    3800     // GT: Is this assumption correct?
    3801 
    3802     TComPicYuv* pcRefPicYuvOrg = NULL;
    3803     for ( Int i = 0; i < getNumRefIdx( REF_PIC_LIST_0 ); i++ )
    3804     {
    3805       TComPic* pcRefPic = getRefPic( REF_PIC_LIST_0, i );
    3806       if ( pcRefPic != NULL )
    3807       {
    3808         if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() )
    3809         {
    3810           pcRefPicYuvOrg = pcRefPic->getPicYuvOrg();
    3811         }
    3812       }
    3813     }
    3814 
    3815     if ( pcRefPicYuvOrg != NULL )
    3816     {
    3817       // Histogram building - luminance
    3818       Int iMaxPelValue = ( 1 << getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
    3819       Int *aiRefOrgHist = (Int *) xMalloc( Int,iMaxPelValue );
    3820       Int *aiCurrHist   = (Int *) xMalloc( Int,iMaxPelValue );
    3821       memset( aiRefOrgHist, 0, iMaxPelValue*sizeof(Int) );
    3822       memset( aiCurrHist, 0, iMaxPelValue*sizeof(Int) );
    3823 
    3824       Int iWidth   = pcCurrPicYuv->getWidth(COMPONENT_Y);
    3825       Int iHeight  = pcCurrPicYuv->getHeight(COMPONENT_Y);
    3826       Pel* pCurrY   = pcCurrPicYuv->getAddr(COMPONENT_Y);
    3827       Pel* pRefOrgY = pcRefPicYuvOrg->getAddr(COMPONENT_Y);
    3828       Int iCurrStride = pcCurrPicYuv->getStride(COMPONENT_Y);
    3829       Int iRefStride = pcRefPicYuvOrg->getStride(COMPONENT_Y);
    3830       for ( Int y = 0; y < iHeight; y++ )
    3831       {
    3832         for ( Int x = 0; x < iWidth; x++ )
    3833         {
    3834           aiCurrHist[pCurrY[x]]++;
    3835           aiRefOrgHist[pRefOrgY[x]]++;
    3836         }
    3837         pCurrY += iCurrStride;
    3838         pRefOrgY += iRefStride;
    3839       }
    3840 
    3841       // Histogram SAD
    3842       Int iSumOrgSAD = 0;
    3843       for ( Int i = 0; i < iMaxPelValue; i++ )
    3844       {
    3845         iSumOrgSAD += abs( aiCurrHist[i] - aiRefOrgHist[i] );
    3846       }
    3847 
    3848       // Setting
    3849       Double dThresholdOrgSAD = getIsDepth() ? 0.1 : 0.05;
    3850 
    3851       if ( iSumOrgSAD > Int( dThresholdOrgSAD * iWidth * iHeight ) )
    3852       {
    3853         m_bApplyIC = true;
    3854       }
    3855       else
    3856       {
    3857         m_bApplyIC = false;
    3858       }
    3859 
    3860       xFree( aiCurrHist   );
    3861       xFree( aiRefOrgHist );
    3862     }
    3863   }//if(bUseLowLatencyICEnc)
    3864 }
    3865 #endif
    3866 #if NH_3D_QTL
    3867 Void TComSlice::setIvPicLists( TComPicLists* m_ivPicLists )
    3868 
    3869   for (Int i = 0; i < MAX_NUM_LAYERS; i++ )
    3870   {
    3871     for ( Int depthId = 0; depthId < 2; depthId++ )
    3872     {
    3873       m_ivPicsCurrPoc[ depthId ][ i ] = ( i <= m_viewIndex ) ? m_ivPicLists->getPic( i, ( depthId == 1) , 0, getPOC() ) : NULL;
    3874     }       
    3875   } 
    3876 }
    3877 #endif
    3878 #if NH_3D
    3879 Void TComSlice::setDepthToDisparityLUTs()
    3880 {
    3881   Bool setupLUT = false;
    3882  
    3883   setupLUT = setupLUT || getViewSynthesisPredFlag( );
    3884 
    3885 #if NH_3D_NBDV_REF
    3886   setupLUT = setupLUT || getDepthRefinementFlag( );
    3887 #endif 
    3888 
    3889 #if NH_3D_IV_MERGE
    3890   setupLUT = setupLUT || ( getIvMvPredFlag() && getIsDepth() );
    3891 #endif
    3892 
    3893   Int bitDepthY = getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
    3894 
    3895   if( !setupLUT )
    3896   {
    3897     return;
    3898   }
    3899 
    3900   m_numViews = getVPS()->getNumViews();
    3901   /// GT: Allocation should be moved to a better place later;
    3902   if ( m_depthToDisparityB == NULL )
    3903   {
    3904     m_depthToDisparityB = new Int*[ m_numViews ];
    3905     for ( Int i = 0; i < getVPS()->getNumViews(); i++ )
    3906     {
    3907       m_depthToDisparityB[ i ] = new Int[ Int(1 << bitDepthY) ];
    3908     }
    3909   }
    3910 
    3911  
    3912   if ( m_depthToDisparityF == NULL )
    3913   {
    3914     m_depthToDisparityF = new Int*[ m_numViews ];
    3915     for ( Int i = 0; i < m_numViews; i++ )
    3916     {
    3917       m_depthToDisparityF[ i ] = new Int[ Int(1 << bitDepthY) ];
    3918     }
    3919   }
    3920 
    3921   assert( m_depthToDisparityB != NULL );
    3922   assert( m_depthToDisparityF != NULL );
    3923 
    3924   const TComVPS* vps = getVPS();
    3925 
    3926   Int log2Div = bitDepthY - 1 + vps->getCpPrecision();
    3927   Int voiInVps = vps->getVoiInVps( getViewIndex() );
    3928   Bool camParaSH = vps->getCpInSliceSegmentHeaderFlag( voiInVps ); 
    3929 
    3930   const IntAry1d codScale     = camParaSH ? m_aaiCodedScale [ 0 ] : vps->getCodedScale    ( voiInVps );
    3931   const IntAry1d codOffset    = camParaSH ? m_aaiCodedOffset[ 0 ] : vps->getCodedOffset   ( voiInVps );
    3932   const IntAry1d invCodScale  = camParaSH ? m_aaiCodedScale [ 1 ] : vps->getInvCodedScale ( voiInVps );
    3933   const IntAry1d invCodOffset = camParaSH ? m_aaiCodedOffset[ 1 ] : vps->getInvCodedOffset( voiInVps );
    3934 
    3935 
    3936   for (Int i = 0; i < voiInVps; i++)
    3937   {
    3938     Int iInVoi = vps->getVoiInVps( i );
    3939 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC
    3940     if ( g_traceCameraParameters )
    3941     {
    3942       std::cout << "Cp: " << codScale   [ iInVoi ] << " " <<    codOffset[ iInVoi ] << " "
    3943                 << invCodScale[ iInVoi ] << " " << invCodOffset[ iInVoi ] << " " << log2Div << std::endl ;
    3944     }
    3945 #endif
    3946     for ( Int d = 0; d <= ( ( 1 << bitDepthY ) - 1 ); d++ )
    3947     {     
    3948       Int offset =    ( codOffset  [ iInVoi ] << bitDepthY ) + ( ( 1 << log2Div ) >> 1 );         
    3949       m_depthToDisparityB[ iInVoi ][ d ] = ( codScale [ iInVoi ] * d + offset ) >> log2Div;
    3950 
    3951       Int invOffset = ( invCodOffset[ iInVoi ] << bitDepthY ) + ( ( 1 << log2Div ) >> 1 );         
    3952       m_depthToDisparityF[ iInVoi ][ d ] = ( invCodScale[ iInVoi ] * d + invOffset ) >> log2Div;
    3953     }
    3954   }
    3955 }
    3956 #endif
     3131}
     3132#endif
     3133
     3134
    39573135
    39583136
     
    43113489
    43123490
    4313 #if NH_3D
    4314 Void TComSlice::init3dToolParameters()
    4315 {
    4316   Bool depthFlag = getIsDepth();
    4317 
    4318   Bool nRLLG0 =  ( getVPS()->getNumRefListLayers( getLayerId() ) > 0 );     
    4319 
    4320   const TComSps3dExtension* sps3dExt = getSPS()->getSps3dExtension();
    4321 
    4322   m_ivMvPredFlag           = sps3dExt->getIvDiMcEnabledFlag          ( depthFlag ) && nRLLG0                       ;                             
    4323   m_ivMvScalingFlag        = sps3dExt->getIvMvScalEnabledFlag        ( depthFlag )                                 ;                             
    4324   m_ivResPredFlag          = sps3dExt->getIvResPredEnabledFlag       ( depthFlag ) && nRLLG0                       ;                               
    4325   m_depthRefinementFlag    = sps3dExt->getDepthRefEnabledFlag        ( depthFlag )           && getInCompPredFlag() && m_cpAvailableFlag;
    4326   m_viewSynthesisPredFlag  = sps3dExt->getVspMcEnabledFlag           ( depthFlag ) && nRLLG0 && getInCompPredFlag() && m_cpAvailableFlag;
    4327   m_depthBasedBlkPartFlag  = sps3dExt->getDbbpEnabledFlag            ( depthFlag )           && getInCompPredFlag();                         
    4328   m_mpiFlag                = sps3dExt->getTexMcEnabledFlag           ( depthFlag )           && getInCompPredFlag();
    4329   m_intraContourFlag       = sps3dExt->getIntraContourEnabledFlag    ( depthFlag )           && getInCompPredFlag();
    4330   m_intraSdcWedgeFlag      = sps3dExt->getIntraDcOnlyWedgeEnabledFlag( depthFlag )                                 ;                         
    4331   m_qtPredFlag             = sps3dExt->getCqtCuPartPredEnabledFlag   ( depthFlag )           && getInCompPredFlag();
    4332   m_interSdcFlag           = sps3dExt->getInterDcOnlyEnabledFlag     ( depthFlag )                                 ; 
    4333   m_depthIntraSkipFlag     = sps3dExt->getSkipIntraEnabledFlag       ( depthFlag )                                 ;                         
    4334 
    4335   m_subPbSize              =  1 << ( sps3dExt->getLog2IvmcSubPbSizeMinus3 ( depthFlag ) + 3 ); 
    4336   m_mpiSubPbSize           =  1 << ( sps3dExt->getLog2TexmcSubPbSizeMinus3( depthFlag ) + 3 );
    4337 
    4338 
    4339 #if NH_3D_OUTPUT_ACTIVE_TOOLS
    4340   std::cout << "Layer:                  :" << getLayerId()             << std::endl;
    4341   std::cout << "DepthFlag:              :" << getIsDepth()             << std::endl;
    4342   std::cout << "ViewOrderIdx:           :" << getViewIndex()           << std::endl;
    4343   std::cout << "InterCmpPredAvailableFlag:" << getInCmpPredAvailFlag() << std::endl;
    4344   std::cout << "InterCompPredFlag       :"  << getInCompPredFlag()     << std::endl;
    4345  
    4346   std::cout << "ivMvPredFlag            :" << m_ivMvPredFlag           << std::endl;
    4347   std::cout << "ivMvScalingFlag         :" << m_ivMvScalingFlag        << std::endl;
    4348   std::cout << "ivResPredFlag           :" << m_ivResPredFlag          << std::endl;
    4349   std::cout << "depthRefinementFlag     :" << m_depthRefinementFlag    << std::endl;
    4350   std::cout << "viewSynthesisPredFlag   :" << m_viewSynthesisPredFlag  << std::endl;
    4351   std::cout << "depthBasedBlkPartFlag   :" << m_depthBasedBlkPartFlag  << std::endl;
    4352   std::cout << "mpiFlag                 :" << m_mpiFlag                << std::endl;
    4353   std::cout << "intraContourFlag        :" << m_intraContourFlag       << std::endl;
    4354   std::cout << "intraSdcWedgeFlag       :" << m_intraSdcWedgeFlag      << std::endl;
    4355   std::cout << "qtPredFlag              :" << m_qtPredFlag             << std::endl;
    4356   std::cout << "interSdcFlag            :" << m_interSdcFlag           << std::endl;
    4357   std::cout << "depthIntraSkipFlag      :" << m_depthIntraSkipFlag     << std::endl;   
    4358   std::cout << "subPbSize               :" << m_subPbSize              << std::endl;
    4359   std::cout << "mpiSubPbSize            :" << m_mpiSubPbSize           << std::endl;
    4360 #endif
    4361 }
    4362 
    4363 Void TComSlice::deriveInCmpPredAndCpAvailFlag( )
    4364 {
    4365   Int numCurCmpLIds = getIsDepth() ? 1 : getNumActiveRefLayerPics();
    4366   std::vector<Int> curCmpLIds;
    4367   if ( getIsDepth() )
    4368   {
    4369     curCmpLIds.push_back( getLayerId() );
    4370   }
    4371   else
    4372   {
    4373     for (Int i = 0; i < numCurCmpLIds; i++)
    4374     {
    4375       curCmpLIds.push_back( getRefPicLayerId( i ) );
    4376     }
    4377   }
    4378 
    4379   m_cpAvailableFlag = true;
    4380   m_inCmpRefViewIdcs.clear();
    4381   Bool allRefCmpLayersAvailFlag = true;
    4382 
    4383   for( Int i = 0; i <= numCurCmpLIds - 1; i++ )
    4384   {     
    4385     m_inCmpRefViewIdcs.push_back( getVPS()->getViewOrderIdx( curCmpLIds[ i ] ));
    4386     if( !getVPS()->getCpPresentFlag( getVPS()->getVoiInVps( getViewIndex() ),  getVPS()->getVoiInVps( m_inCmpRefViewIdcs[ i ] ) ) )
    4387     {
    4388       m_cpAvailableFlag = false;
    4389     }
    4390     Bool refCmpCurLIdAvailFlag = false;
    4391     if( getVPS()->getViewCompLayerPresentFlag( m_inCmpRefViewIdcs[ i ], !getIsDepth() ) )
    4392     {
    4393       Int j = getVPS()->getLayerIdInVps( getVPS()->getViewCompLayerId( m_inCmpRefViewIdcs[ i ],  !getIsDepth() ) );
    4394       if  ( getVPS()->getDirectDependencyFlag( getVPS()->getLayerIdInVps( getLayerId() ) ,  j ) &&
    4395         getVPS()->getSubLayersVpsMaxMinus1( j ) >= getTemporalId()   &&
    4396         ( getTemporalId() == 0 || getVPS()->getMaxTidIlRefPicsPlus1( j , getVPS()->getLayerIdInVps( getLayerId() ) ) > getTemporalId() )       
    4397         )
    4398       {
    4399         refCmpCurLIdAvailFlag = true;
    4400       }
    4401     }
    4402     if( !refCmpCurLIdAvailFlag )
    4403     {
    4404       allRefCmpLayersAvailFlag = false;
    4405     }
    4406   }
    4407 
    4408   if( !allRefCmpLayersAvailFlag )
    4409   {
    4410     m_inCmpPredAvailFlag = false;
    4411   } 
    4412   else
    4413   {
    4414     const TComSps3dExtension* sps3dExt = getSPS()->getSps3dExtension();
    4415     if( !getIsDepth() )
    4416     {
    4417       m_inCmpPredAvailFlag = sps3dExt->getVspMcEnabledFlag( getIsDepth() ) ||
    4418         sps3dExt->getDbbpEnabledFlag( getIsDepth() ) ||
    4419         sps3dExt->getDepthRefEnabledFlag  ( getIsDepth() );                           
    4420     }
    4421     else
    4422     {
    4423       m_inCmpPredAvailFlag = sps3dExt->getIntraContourEnabledFlag( getIsDepth() ) ||
    4424         sps3dExt->getCqtCuPartPredEnabledFlag( getIsDepth() ) ||
    4425         sps3dExt->getTexMcEnabledFlag( getIsDepth() );                                 
    4426     }
    4427   }
    4428 }
    4429 
    4430 Void TComSlice::checkInCompPredRefLayers()
    4431 
    4432   if ( getInCompPredFlag() )
    4433   {
    4434     for (Int i = 0; i < getNumCurCmpLIds(); i++ )
    4435     {     
    4436       assert( getIvPic(!getIsDepth(), getInCmpRefViewIdcs( i ) ) != NULL );       
    4437       //  It is a requirement of bitstream conformance that there
    4438       //  is a picture in the DPB with PicOrderCntVal equal to the PicOrderCntVal of the current picture,
    4439       //  and a nuh_layer_id value equal to ViewCompLayerId[ inCmpRefViewIdcs[ i ] ][ !DepthFlag ].
    4440     }
    4441   }
    4442 }
    4443 
    4444 Void TComSlice::setPocsInCurrRPSs()
    4445 {
    4446   // Currently only needed at decoder side;
    4447   m_pocsInCurrRPSs.clear();   
    4448   std::vector<TComPic*>** rpsCurr = getPic()->getDecodedRps()->m_refPicSetsCurr;
    4449   for (Int i = 0 ; i < 3; i++ )
    4450   {
    4451     for( Int j = 0; j < rpsCurr[i]->size(); j++ )
    4452     {
    4453       m_pocsInCurrRPSs.push_back( (*rpsCurr[i])[j]->getPOC() );
    4454     }
    4455   }
    4456 }
    4457 
    4458 #endif
    44593491
    44603492/** get scaling matrix from RefMatrixID
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComSlice.h

    r1386 r1390  
    10301030  Int         m_numDirectRefLayers       [MAX_NUM_LAYERS];
    10311031  Int         m_idDirectRefLayer         [MAX_NUM_LAYERS][MAX_NUM_LAYERS]; 
    1032 #if NH_3D
    1033   Int         m_numRefListLayers         [MAX_NUM_LAYERS];
    1034   Int         m_idRefListLayer           [MAX_NUM_LAYERS][MAX_NUM_LAYERS]; 
    1035 #endif
    10361032
    10371033
     
    10591055
    10601056  // VPS EXTENSION 2 SYNTAX ELEMENTS
    1061 #if NH_3D
    1062   IntAry1d       m_numCp; 
    1063   IntAry2d       m_cpRefVoi;
    1064   BoolAry2d      m_cpPresentFlag;
    1065   Int            m_cpPrecision;
    1066   BoolAry1d      m_cpInSliceSegmentHeaderFlag;
    1067   IntAry3d       m_aaaiCodedScale ;
    1068   IntAry3d       m_aaaiCodedOffset;
    1069 
    1070   IntAry1d       m_viewOIdxList;
    1071   BoolAry2d      m_viewCompLayerPresentFlag;
    1072   IntAry2d       m_viewCompLayerId;
    1073 #endif
    10741057
    10751058#endif
     
    13071290  Int     getNumViews()                        const                            { return m_numViews; }
    13081291  Void    initNumViews();
    1309 #if NH_3D
    1310   Void    initViewCompLayer( );
    1311   Int     getViewOIdxList( Int i )             const                            { return m_viewOIdxList[i]; }
    1312   std::vector<Int> getViewOIdxList( )          const                            { return m_viewOIdxList; }
    1313 
    1314   Int     getVoiInVps( Int viewOIdx )          const;
    1315 
    1316   Bool    getViewCompLayerPresentFlag (Int i, Bool d ) const                    { return  m_viewCompLayerPresentFlag[ getVoiInVps(i) ][d]; }
    1317   Bool    getViewCompLayerId          (Int i, Bool d ) const                    { return  m_viewCompLayerId         [ getVoiInVps(i) ][d]; }
    1318 #endif
    13191292  Bool    getDependencyFlag( Int i, Int j ) const                               { return m_dependencyFlag[i][j]; }
    13201293  Int     getNumDirectRefLayers( Int layerIdInNuh ) const                       { return m_numDirectRefLayers[ layerIdInNuh ];  };                               
    1321 #if NH_3D                                                                     
    1322   Int     getNumRefListLayers( Int layerIdInNuh )   const                       { return m_numRefListLayers[ layerIdInNuh ];  };                               
    1323 #endif
    13241294
    13251295  Int     getNumRefLayers            ( Int i )      const                       { return m_numRefLayers[i]; }
     
    13291299  Int     getIdPredictedLayer        ( Int i, Int j ) const                     { assert( j >= 0 && j < getNumPredictedLayers( i )); return m_idPredictedLayer[i][j]; }
    13301300  Int     getIdDirectRefLayer        ( Int i, Int j ) const                     { assert( j >= 0 && j < getNumDirectRefLayers( i )); return m_idDirectRefLayer[i][j]; }
    1331 #if NH_3D                                                                     
    1332   Int     getIdRefListLayer          ( Int i, Int j ) const                     { assert( j >= 0 && j < getNumRefListLayers   ( i )); return m_idRefListLayer[i][j]; }
    1333 #endif                                                                         
    13341301  Int     getNumIndependentLayers    (  )             const                     { return m_numIndependentLayers; }
    13351302  Int     getNumLayersInTreePartition( Int i )        const                     { return m_numLayersInTreePartition[i]; }
     
    13841351  /// VPS EXTENSION 2 SYNTAX ELEMENTS
    13851352  Int     getDepthId                   ( Int layerIdInNuh)             const    { return getScalabilityId( getLayerIdInVps(layerIdInNuh), DEPTH_ID ); }
    1386 #if NH_3D_VSO                                                             
    1387   Bool    getVpsDepthFlag              ( Int layerIdInNuh)             const    { return (getDepthId( layerIdInNuh ) > 0);  }
    1388   Int     getLayerIdInNuh              ( Int viewIndex, Bool depthFlag, Int auxId ) const;   
    1389 #endif
    1390 #if NH_3D
    1391   Void    createCamPars                ( Int iNumViews ); 
    1392   Void    initCamParaVPS               ( Int vOIdxInVps, Int numCp, Bool cpInSliceSegmentHeaderFlag, Int* cpRefVoi, Int** aaiScale, Int** aaiOffset );                                               
    1393                                        
    1394   Void    setCpPrecision               ( Int  val )                             { m_cpPrecision = val;                       }
    1395   Int     getCpPrecision               (  )                            const    { return m_cpPrecision;                      }
    1396                                                                                                                
    1397   Void    setNumCp                     ( Int i, Int  val )                      { m_numCp[i] = val;                          }
    1398   Int     getNumCp                     ( Int i )                       const    { return m_numCp[i];                         }
    1399                                                                                                                
    1400   Void    setCpRefVoi                  ( Int i, Int m, Int  val )               { m_cpRefVoi[i][m] = val;                    }
    1401   Int     getCpRefVoi                  ( Int i, Int m )                const    { return m_cpRefVoi[i][m];                   }
    1402                                                                                                                
    1403   Void    setCpInSliceSegmentHeaderFlag( Int i, Bool flag )                     { m_cpInSliceSegmentHeaderFlag[i] = flag;    }
    1404   Bool    getCpInSliceSegmentHeaderFlag( Int i )                       const    { return m_cpInSliceSegmentHeaderFlag[i];    }
    1405                                                                                                                
    1406   Void    setVpsCpScale                ( Int i, Int j, Int val )                { m_aaaiCodedScale [i][0][j] = val;          }
    1407   Int     getVpsCpScale                ( Int i, Int j )                const    { return m_aaaiCodedScale[i][0][j];          }
    1408                                                                                                                
    1409   Void    setVpsCpOff                  ( Int i, Int j, Int val )                { m_aaaiCodedOffset[i][0][j] = val;          }
    1410   Int     getVpsCpOff                  ( Int i, Int j )                const    { return m_aaaiCodedOffset[i][0][j];         }
    1411                                                                                                                
    1412   Void    setVpsCpInvScale             ( Int i, Int j, Int val )                { m_aaaiCodedScale[i][1][j] = val;           }
    1413   Int     getVpsCpInvScale             ( Int i, Int j )                const    { return m_aaaiCodedScale[i][1][j];          }
    1414                                                                                                                
    1415   Void    setVpsCpInvOff               ( Int i, Int j, Int val )                { m_aaaiCodedOffset[i][1][j] = val;          }
    1416   Int     getVpsCpInvOff               ( Int i, Int j )                const    { return m_aaaiCodedOffset[i][1][j];         }
    1417 
    1418 // Derived
    1419   Void    deriveCpPresentFlag          ( );                 
    1420   Void    setCpPresentFlag             ( Int i, Int m, Bool flag )              { m_cpPresentFlag[i][m] = flag;             }
    1421   Bool    getCpPresentFlag             ( Int i, Int m )                const    { return m_cpPresentFlag[i][m];             }   
    1422                                                                        
    1423   const IntAry1d& getCodedScale        ( Int viewIndex )               const    { return m_aaaiCodedScale [viewIndex][0];   }
    1424   const IntAry1d& getCodedOffset       ( Int viewIndex )               const    { return m_aaaiCodedOffset[viewIndex][0];   }
    1425   const IntAry1d& getInvCodedScale     ( Int viewIndex )               const    { return m_aaaiCodedScale [viewIndex][1];   }
    1426   const IntAry1d& getInvCodedOffset    ( Int viewIndex )               const    { return m_aaaiCodedOffset[viewIndex][1];   }
    1427 #endif
    14281353
    14291354  template <typename T, typename S, typename U> Void xPrintArray( const TChar* name, Int numElemDim1, U idx, S numElemDim2, T vec, Bool printNumber, Bool printIdx = true ) const
     
    14711396};
    14721397
    1473 #if NH_3D_DLT
    1474 class TComDLT
    1475 {
    1476 private:
    1477   Bool              m_bDltPresentFlag;
    1478   Bool              m_bUseDLTFlag                 [ MAX_NUM_LAYERS ];
    1479   Bool              m_bInterViewDltPredEnableFlag [ MAX_NUM_LAYERS ];
    1480   Bool              m_bDltBitMapRepFlag           [ MAX_NUM_LAYERS ];
    1481 
    1482   Int               m_iNumDepthmapValues          [ MAX_NUM_LAYERS ];
    1483   std::vector<Int>  m_iDepthValue2Idx             [ MAX_NUM_LAYERS ];
    1484   std::vector<Int>  m_iIdx2DepthValue             [ MAX_NUM_LAYERS ];
    1485 
    1486   Int               m_iNumDepthViews;
    1487   UInt              m_uiDepthViewBitDepth;
    1488  
    1489   // mapping
    1490   Int               m_iDepthIdxToLayerId          [ MAX_NUM_LAYERS ];
    1491 
    1492 public:
    1493   TComDLT();
    1494   ~TComDLT();
    1495  
    1496   Int     getDepthIdxToLayerId(Int depthIdx) const        { return m_iDepthIdxToLayerId[depthIdx]; }
    1497   Void    setDepthIdxToLayerId(Int depthIdx, Int layerId) { m_iDepthIdxToLayerId[depthIdx] = layerId; }
    1498 
    1499   Bool    getDltPresentFlag  ()                           const   { return m_bDltPresentFlag; }
    1500   Void    setDltPresentFlag  ( Bool b )                   { m_bDltPresentFlag = b;    }
    1501 
    1502   Bool    getUseDLTFlag      ( Int layerIdInVps )         const   { return m_bUseDLTFlag[ layerIdInVps ]; }
    1503   Void    setUseDLTFlag      ( Int layerIdInVps, Bool b ) { m_bUseDLTFlag[ layerIdInVps ]  = b;   }
    1504  
    1505   Bool    getInterViewDltPredEnableFlag( Int layerIdInVps )         const   { return m_bInterViewDltPredEnableFlag[ layerIdInVps ]; }
    1506   Void    setInterViewDltPredEnableFlag( Int layerIdInVps, Bool b ) { m_bInterViewDltPredEnableFlag[ layerIdInVps ] = b;    }
    1507  
    1508   Bool    getUseBitmapRep      ( Int layerIdInVps )         const   { return m_bDltBitMapRepFlag[ layerIdInVps ]; }
    1509   Void    setUseBitmapRep      ( Int layerIdInVps, Bool b ) { m_bDltBitMapRepFlag[ layerIdInVps ]  = b;   }
    1510 
    1511   Void    setNumDepthViews   ( Int n )                    { m_iNumDepthViews = n; }
    1512   Int     getNumDepthViews   ()                           const   { return m_iNumDepthViews; }
    1513 
    1514   Void    setDepthViewBitDepth( UInt n )                  { m_uiDepthViewBitDepth = n; }
    1515   UInt    getDepthViewBitDepth()                          const   { return m_uiDepthViewBitDepth; }
    1516 
    1517   Int     getNumDepthValues( Int layerIdInVps )           const   { return getUseDLTFlag(layerIdInVps)?m_iNumDepthmapValues[layerIdInVps]:(1 << m_uiDepthViewBitDepth); }
    1518   Int     depthValue2idx( Int layerIdInVps, Pel value )   const   { return getUseDLTFlag(layerIdInVps)?m_iDepthValue2Idx[layerIdInVps][value]:value; }
    1519   Pel     idx2DepthValue( Int layerIdInVps, UInt uiIdx )  const   { return getUseDLTFlag(layerIdInVps)?m_iIdx2DepthValue[layerIdInVps][ClipBD(uiIdx,m_uiDepthViewBitDepth)]:uiIdx; }
    1520   Void    setDepthLUTs( Int layerIdInVps, std::vector<Int> idx2DepthValue, Int iNumDepthValues = 0 );
    1521   std::vector<Int>    idx2DepthValue( Int layerIdInVps )  const   { return m_iIdx2DepthValue[layerIdInVps]; }
    1522   Void    getDeltaDLT( Int layerIdInVps, std::vector<Int> piDLTInRef, UInt uiDLTInRefNum, std::vector<Int>& riDeltaDLTOut, UInt& ruiDeltaDLTOutNum ) const;
    1523   Void    setDeltaDLT( Int layerIdInVps, std::vector<Int> piDLTInRef, UInt uiDLTInRefNum, std::vector<Int> piDeltaDLTIn, UInt uiDeltaDLTInNum );
    1524 };
    1525 #endif
    15261398
    15271399
     
    18031675
    18041676
    1805 #if NH_3D
    1806 class TComSps3dExtension
    1807 {
    1808 public:
    1809   TComSps3dExtension()
    1810   {
    1811     for (Int d = 0; d < 2; d++)
    1812     {
    1813       m_ivDiMcEnabledFlag          [d] = false;
    1814       m_ivMvScalEnabledFlag       [d] = false;
    1815       m_log2IvmcSubPbSizeMinus3   [d] = 3;
    1816       m_ivResPredEnabledFlag         [d] = false;
    1817       m_depthRefEnabledFlag   [d] = false;
    1818       m_vspMcEnabledFlag [d] = false;
    1819       m_dbbpEnabledFlag [d] = false;
    1820       m_texMcEnabledFlag               [d] = false;
    1821       m_log2TexmcSubPbSizeMinus3[d] = 3;
    1822       m_intraContourEnabledFlag      [d] = false;
    1823       m_intraDcOnlyWedgeEnabledFlag     [d] = false;
    1824       m_cqtCuPartPredEnabledFlag            [d] = false;
    1825       m_interDcOnlyEnabledFlag          [d] = false;
    1826       m_skipIntraEnabledFlag    [d] = false;   
    1827     }
    1828   }
    1829 
    1830   Void          setIvDiMcEnabledFlag( Int d, Bool flag )        { m_ivDiMcEnabledFlag[d] = flag;             }
    1831   Bool          getIvDiMcEnabledFlag( Int d ) const             { return m_ivDiMcEnabledFlag[d];             }
    1832 
    1833   Void          setIvMvScalEnabledFlag( Int d, Bool flag )      { m_ivMvScalEnabledFlag[d] = flag;          }
    1834   Bool          getIvMvScalEnabledFlag( Int d ) const           { return m_ivMvScalEnabledFlag[d];          }
    1835 
    1836   Void          setLog2IvmcSubPbSizeMinus3( Int d, Int  val )   { m_log2IvmcSubPbSizeMinus3[d] = val;       }
    1837   Int           getLog2IvmcSubPbSizeMinus3( Int d ) const       { return m_log2IvmcSubPbSizeMinus3[d];      }
    1838 
    1839   Void          setIvResPredEnabledFlag( Int d, Bool flag )     { m_ivResPredEnabledFlag[d] = flag;            }
    1840   Bool          getIvResPredEnabledFlag( Int d ) const          { return m_ivResPredEnabledFlag[d];            }
    1841 
    1842   Void          setDepthRefEnabledFlag( Int d, Bool flag )      { m_depthRefEnabledFlag[d] = flag;      }
    1843   Bool          getDepthRefEnabledFlag( Int d ) const           { return m_depthRefEnabledFlag[d];      }
    1844 
    1845   Void          setVspMcEnabledFlag( Int d, Bool flag )         { m_vspMcEnabledFlag[d] = flag;   }
    1846   Bool          getVspMcEnabledFlag( Int d ) const              { return m_vspMcEnabledFlag[d];    }
    1847 
    1848   Void          setDbbpEnabledFlag( Int d, Bool flag )          { m_dbbpEnabledFlag[d] = flag;   }
    1849   Bool          getDbbpEnabledFlag( Int d ) const               { return m_dbbpEnabledFlag[d];    }
    1850 
    1851   Void          setTexMcEnabledFlag( Int d, Bool flag )         { m_texMcEnabledFlag[d] = flag;                  }
    1852   Bool          getTexMcEnabledFlag( Int d ) const              { return m_texMcEnabledFlag[d];                  }
    1853 
    1854   Void          setLog2TexmcSubPbSizeMinus3( Int d, Int  val )  { m_log2TexmcSubPbSizeMinus3[d] = val;   }
    1855   Int           getLog2TexmcSubPbSizeMinus3( Int d ) const      { return m_log2TexmcSubPbSizeMinus3[d];   }
    1856 
    1857   Void          setIntraContourEnabledFlag( Int d, Bool flag )  { m_intraContourEnabledFlag[d] = flag;         }
    1858   Bool          getIntraContourEnabledFlag( Int d ) const       { return m_intraContourEnabledFlag[d];         }
    1859 
    1860   Void          setIntraDcOnlyWedgeEnabledFlag( Int d, Bool flag ) { m_intraDcOnlyWedgeEnabledFlag[d] = flag;        }
    1861   Bool          getIntraDcOnlyWedgeEnabledFlag( Int d ) const      { return m_intraDcOnlyWedgeEnabledFlag[d];        }
    1862 
    1863   Void          setCqtCuPartPredEnabledFlag( Int d, Bool flag )    { m_cqtCuPartPredEnabledFlag[d] = flag;               }
    1864   Bool          getCqtCuPartPredEnabledFlag( Int d ) const         { return m_cqtCuPartPredEnabledFlag[d];               }
    1865 
    1866   Void          setInterDcOnlyEnabledFlag( Int d, Bool flag )      { m_interDcOnlyEnabledFlag[d] = flag;             }
    1867   Bool          getInterDcOnlyEnabledFlag( Int d ) const           { return m_interDcOnlyEnabledFlag[d];             }
    1868 
    1869   Void          setSkipIntraEnabledFlag( Int d, Bool flag )        { m_skipIntraEnabledFlag[d] = flag;       }
    1870   Bool          getSkipIntraEnabledFlag( Int d ) const             { return m_skipIntraEnabledFlag[d];       }
    1871 private:
    1872 
    1873   Bool        m_ivDiMcEnabledFlag          [2];
    1874   Bool        m_ivMvScalEnabledFlag        [2];
    1875   Int         m_log2IvmcSubPbSizeMinus3    [2];
    1876   Bool        m_ivResPredEnabledFlag       [2];
    1877   Bool        m_depthRefEnabledFlag        [2];
    1878   Bool        m_vspMcEnabledFlag           [2];
    1879   Bool        m_dbbpEnabledFlag            [2];
    1880   Bool        m_texMcEnabledFlag           [2];
    1881   Int         m_log2TexmcSubPbSizeMinus3   [2];
    1882   Bool        m_intraContourEnabledFlag    [2];
    1883   Bool        m_intraDcOnlyWedgeEnabledFlag[2];
    1884   Bool        m_cqtCuPartPredEnabledFlag   [2];
    1885   Bool        m_interDcOnlyEnabledFlag     [2];
    1886   Bool        m_skipIntraEnabledFlag       [2]; 
    1887 };
    1888 
    1889 #endif
    18901677
    18911678
     
    19941781  Bool             m_interViewMvVertConstraintFlag;
    19951782#endif
    1996 #if NH_3D
    1997   TComSps3dExtension m_sps3dExtension;
    1998   Int              m_aaiCodedScale [2][MAX_NUM_LAYERS];
    1999   Int              m_aaiCodedOffset[2][MAX_NUM_LAYERS];
    2000 #endif             
    20011783#if NH_MV           
    20021784  Int              m_layerId;
     
    22121994  Bool                   getInterViewMvVertConstraintFlag()         const                                { return m_interViewMvVertConstraintFlag;                              }
    22131995                                                                                                                                                                               
    2214 #if NH_3D
    2215   Void                   setSps3dExtension ( TComSps3dExtension& sps3dExtension )                        { m_sps3dExtension = sps3dExtension;                                   }
    2216   const TComSps3dExtension* getSps3dExtension ( )  const                                                 { return &m_sps3dExtension;                                            }
    2217 #endif                 
    22181996                       
    22191997  // Inference         
     
    24032181#endif
    24042182
    2405 #if NH_3D_DLT
    2406   TComDLT                m_cDLT;
    2407 #endif
    24082183
    24092184public:
     
    24282203  UInt                   getMaxCuDQPDepth() const                                         { return m_uiMaxCuDQPDepth;                     }
    24292204
    2430 #if NH_3D_DLT
    2431   Void                   setDLT( TComDLT cDLT )                                           { m_cDLT = cDLT;                                }
    2432   const TComDLT*         getDLT() const                                                   { return &m_cDLT;                               }
    2433   TComDLT*               getDLT()                                                         { return &m_cDLT;                               }
    2434 #endif
    24352205
    24362206
     
    27012471  Int        m_viewId;
    27022472  Int        m_viewIndex;
    2703 #if NH_3D_VSO
    2704   Bool       m_isDepth;
    2705 #endif
    27062473
    27072474// Additional slice header syntax elements
     
    27272494  Bool       m_pocMsbValRequiredFlag;
    27282495
    2729 #if NH_3D
    2730   IntAry2d   m_aaiCodedScale ;
    2731   IntAry2d   m_aaiCodedOffset;
    2732 #endif
    2733 #if NH_3D_TMVP
    2734   Int        m_aiAlterRefIdx   [2];
    2735 #endif
    2736 #if NH_3D_ARP
    2737   Bool       m_arpRefPicAvailable[2][MAX_NUM_LAYERS];
    2738   TComList<TComPic*> * m_pBaseViewRefPicList[MAX_NUM_LAYERS];
    2739   UInt        m_nARPStepNum;
    2740   Int         m_aiFirstTRefIdx    [2];   
    2741 #endif
    2742 #if NH_3D
    2743   std::vector<Int> m_pocsInCurrRPSs;
    2744 #endif
    2745 #if NH_3D_IC
    2746   Bool       m_bApplyIC;
    2747   Bool       m_icSkipParseFlag;
    2748 #endif
    2749 #if NH_3D
    2750   std::vector<Int> m_inCmpRefViewIdcs;
    2751   Bool       m_inCmpPredAvailFlag;
    2752   Bool       m_inCmpPredFlag;
    2753   Bool       m_cpAvailableFlag;
    2754   Int        m_numViews;
    2755 #endif
    2756 #if NH_3D_QTL
    2757   TComPic*   m_ivPicsCurrPoc [2][MAX_NUM_LAYERS]; 
    2758 #endif
    2759 #if NH_3D
    2760   Int**      m_depthToDisparityB;
    2761   Int**      m_depthToDisparityF;
    2762   Bool       m_bApplyDIS;
    2763 #endif
    2764 #endif
    2765 #if NH_3D_IC
    2766   Int*       m_aICEnableCandidate;
    2767   Int*       m_aICEnableNum;
    2768 #endif       
    2769 #if NH_3D   
    2770   Int        m_iDefaultRefViewIdx;
    2771   Bool       m_bDefaultRefViewIdxAvailableFlag;
    2772              
    2773   Bool       m_ivMvPredFlag         ;
    2774   Bool       m_ivMvScalingFlag      ;
    2775   Bool       m_ivResPredFlag        ;
    2776   Bool       m_depthRefinementFlag  ;
    2777   Bool       m_viewSynthesisPredFlag;
    2778   Bool       m_depthBasedBlkPartFlag;
    2779   Bool       m_mpiFlag              ;
    2780   Bool       m_intraContourFlag     ;
    2781   Bool       m_intraSdcWedgeFlag    ;
    2782   Bool       m_qtPredFlag           ;
    2783   Bool       m_interSdcFlag         ;
    2784   Bool       m_depthIntraSkipFlag   ;
    2785   Int        m_mpiSubPbSize         ;
    2786   Int        m_subPbSize            ;
    27872496#endif
    27882497public:
     
    28472556  const TComPic*              getRefPic( RefPicList e, Int iRefIdx) const            { return m_apcRefPicList[e][iRefIdx];                           }
    28482557  Int                         getRefPOC( RefPicList e, Int iRefIdx) const            { return m_aiRefPOCList[e][iRefIdx];                            }
    2849 #if NH_3D
    2850   Bool                        getInCmpPredAvailFlag( )                 const         { return m_inCmpPredAvailFlag;                                  }
    2851   Bool                        getCpAvailableFlag( )                    const         { return m_cpAvailableFlag;                                     }
    2852   Bool                        getInCompPredFlag( )                     const         { return m_inCmpPredFlag;                                       }
    2853   Void                        setInCompPredFlag( Bool b )                            { m_inCmpPredFlag = b;                                          }
    2854   Int                         getInCmpRefViewIdcs( Int i )             const         { return m_inCmpRefViewIdcs  [i];                               }
    2855   Int                         getNumCurCmpLIds( )                      const         { return (Int) m_inCmpRefViewIdcs.size();                       }
    2856   TComPic*                    getIvPic( Bool depthFlag, Int viewIndex) const         { return  m_ivPicsCurrPoc[ depthFlag ? 1 : 0 ][ viewIndex ];    }
    2857 #endif
    2858 #if NH_3D_QTL
    2859   TComPic*                    getTexturePic       ()                                 { return  m_ivPicsCurrPoc[0][ m_viewIndex ];                    }
    2860 
    2861 #endif                           
    2862 #if NH_3D_IC                                                                                                                                         
    2863   Void                        setApplyIC( Bool b )                                   { m_bApplyIC = b;                                               }
    2864   Bool                        getApplyIC()                                           { return m_bApplyIC;                                            }
    2865   Void                        xSetApplyIC();                                                                                                         
    2866   Void                        xSetApplyIC(Bool bUseLowLatencyICEnc);                                                                                 
    2867   Void                        setIcSkipParseFlag( Bool b )                           { m_icSkipParseFlag = b;                                        }
    2868   Bool                        getIcSkipParseFlag()                                   { return m_icSkipParseFlag;                                     }
    2869 #endif                                                                                                                                               
    2870 #if NH_3D_ARP                                                                                                                                         
    2871   Void                        setBaseViewRefPicList( TComList<TComPic*> *pListPic, Int iViewIdx )      { m_pBaseViewRefPicList[iViewIdx] = pListPic; }                 
    2872   Void                        setARPStepNum( TComPicLists*ivPicLists );                                                                             
    2873   Void                        setPocsInCurrRPSs( );
    2874 
    2875   TComPic*                    getBaseViewRefPic    ( UInt uiPOC , Int iViewIdx )     { return xGetRefPic( *m_pBaseViewRefPicList[iViewIdx], uiPOC ); }
    2876   UInt                        getARPStepNum( )                                       { return m_nARPStepNum;                                         } 
    2877 #endif
    28782558  Int                         getDepth() const                                       { return m_iDepth;                                              }
    28792559  Bool                        getColFromL0Flag() const                               { return m_colFromL0Flag;                                       }
     
    31542834
    31552835
    3156 #if NH_3D
    3157 #if NH_3D_TMVP
    3158   Void                        generateAlterRefforTMVP ();   
    3159   Void                        setAlterRefIdx          ( RefPicList e, Int i )        { m_aiAlterRefIdx[e]    = i;                                    }
    3160   Int                         getAlterRefIdx          ( RefPicList e )               { return  m_aiAlterRefIdx[e];                                   }
    3161 #endif                                                                                                                                               
    3162 #if NH_3D_ARP                                                                                                                                         
    3163   Int                         getFirstTRefIdx        ( RefPicList e )                { return  m_aiFirstTRefIdx[e];                                  }
    3164   Void                        setFirstTRefIdx        ( RefPicList e, Int i )         { m_aiFirstTRefIdx[e]    = i;                                   }
    3165 
    3166   Bool                        getArpRefPicAvailable  ( RefPicList e, Int viewIdx)    { return m_arpRefPicAvailable[e][getVPS()->getLayerIdInNuh(viewIdx, false, 0 )]; }
    3167   IntAry1d                    getPocsInCurrRPSs()                                    { return m_pocsInCurrRPSs;                                      }
    3168 #endif                       
    3169 #endif
    3170 #if NH_3D_VSO
    3171   Void                        setIsDepth            ( Bool isDepth )                 { m_isDepth = isDepth;                                          }
    3172   Bool                        getIsDepth            () const                         { return m_isDepth;                                             }
    3173 #endif
    3174 #if NH_3D
    3175   Void                        setCamparaSlice       ( Int** aaiScale = 0, Int** aaiOffset = 0 );     
    3176 
    3177   IntAry1d                    getCodedScale         () const                         { return m_aaiCodedScale [0];                                   }
    3178   IntAry1d                    getCodedOffset        () const                         { return m_aaiCodedOffset[0];                                   }
    3179   IntAry1d                    getInvCodedScale      () const                         { return m_aaiCodedScale [1];                                   }
    3180   IntAry1d                    getInvCodedOffset     () const                         { return m_aaiCodedOffset[1];                                   }
    3181                                                                                                                                                      
    3182   Void                        setCpScale( Int j, Int  val )                          { m_aaiCodedScale[0][j] = val;                                  }
    3183   Int                         getCpScale( Int j )                                    { return m_aaiCodedScale[0][j];                                 }
    3184                                                                                                                                                      
    3185   Void                        setCpOff( Int j, Int  val )                            { m_aaiCodedOffset[0][j] = val;                                 }
    3186   Int                         getCpOff( Int j )                                      { return m_aaiCodedOffset[0][j];                                }
    3187                                                                                                                                                      
    3188   Void                        setCpInvScale( Int j, Int  val )                       { m_aaiCodedScale[1][j] = val;                                  }
    3189   Int                         getCpInvScale( Int j )                                 { return m_aaiCodedScale[1][j];                                 }
    3190                                                                                                                                                      
    3191   Void                        setCpInvOff( Int j, Int  val )                         { m_aaiCodedOffset[1][j] = val;                                 }
    3192   Int                         getCpInvOff( Int j )                                   { return m_aaiCodedOffset[1][j];                                }
    3193                                                                                                                                                        
    3194 #endif
    3195 #if NH_3D_QTL
    3196   Void                        setIvPicLists( TComPicLists* m_ivPicLists );                                                                             
    3197 #endif
    3198 #if NH_3D
    3199   Void                        setDepthToDisparityLUTs();                                                                                               
    3200                                                                                                                                                        
    3201   Int*                        getDepthToDisparityB( Int refViewIdx )                 { return m_depthToDisparityB[ getVPS()->getVoiInVps( refViewIdx) ];}
    3202   Int*                        getDepthToDisparityF( Int refViewIdx )                 { return m_depthToDisparityF[ getVPS()->getVoiInVps( refViewIdx) ];}
    3203 #if NH_3D_IC                                                                                                                                             
    3204   Void                        setICEnableCandidate( Int* icEnableCandidate)          { m_aICEnableCandidate = icEnableCandidate;                     }
    3205   Void                        setICEnableNum( Int* icEnableNum)                      { m_aICEnableNum = icEnableNum;                                 }
    3206   Void                        setICEnableCandidate( UInt layer, Int value)           { m_aICEnableCandidate[ layer ] = value;                        }
    3207   Void                        setICEnableNum( UInt layer, Int value)                 { m_aICEnableNum[ layer ] = value; ;                            }
    3208                                                                                                                                                      
    3209   Int                         getICEnableCandidate( Int layer)                       { return  m_aICEnableCandidate[ layer ];                        }
    3210   Int                         getICEnableNum( Int layer)                             { return m_aICEnableNum[ layer ];                               }
    3211 #endif
    3212 #endif
    32132836// Additional slice header syntax elements
    32142837
     
    32922915
    32932916  // Additional variables derived in slice header semantics
    3294 #if NH_3D
    3295   Int                         getNumInterLayerRefPicsMinus1Len( ) const              { return gCeilLog2(  getVPS()->getNumRefListLayers( getLayerId() )); }
    3296   Int                         getInterLayerPredLayerIdcLen    ( ) const              { return gCeilLog2(  getVPS()->getNumRefListLayers( getLayerId() )); }
    3297 #else
    32982917  Int                         getNumInterLayerRefPicsMinus1Len( ) const              { return gCeilLog2(  getVPS()->getNumDirectRefLayers( getLayerId() )); }
    32992918  Int                         getInterLayerPredLayerIdcLen    ( ) const              { return gCeilLog2(  getVPS()->getNumDirectRefLayers( getLayerId() )); }
    3300 #endif
    33012919
    33022920  Int                         getRefLayerPicFlag( Int i ) const;
     
    33142932  TComPic*                    getPicFromRefPicSetInterLayer ( Int setIdc, Int layerId ) const ;
    33152933
    3316 #if NH_3D
    3317   // 3D-HEVC tool parameters
    3318   Void                        deriveInCmpPredAndCpAvailFlag( );
    3319   Void                        init3dToolParameters();
    3320   Void                        checkInCompPredRefLayers();
    3321 
    3322   Bool                        getIvMvPredFlag           ( )                          { return m_ivMvPredFlag           ;                             };
    3323   Bool                        getIvMvScalingFlag        ( )                          { return m_ivMvScalingFlag        ;                             };
    3324   Bool                        getIvResPredFlag          ( )                          { return m_ivResPredFlag          ;                             };
    3325   Bool                        getDepthRefinementFlag    ( )                          { return m_depthRefinementFlag    ;                             };
    3326   Bool                        getViewSynthesisPredFlag  ( )                          { return m_viewSynthesisPredFlag  ;                             };
    3327   Bool                        getDepthBasedBlkPartFlag  ( )                          { return m_depthBasedBlkPartFlag  ;                             };
    3328   Bool                        getMpiFlag                ( )                          { return m_mpiFlag                ;                             };
    3329   Bool                        getIntraContourFlag       ( )                          { return m_intraContourFlag       ;                             };
    3330   Bool                        getIntraSdcWedgeFlag      ( )                          { return m_intraSdcWedgeFlag      ;                             };
    3331   Bool                        getQtPredFlag             ( )                          { return m_qtPredFlag             ;                             };
    3332   Bool                        getInterSdcFlag           ( )                          { return m_interSdcFlag           ;                             };
    3333   Bool                        getDepthIntraSkipFlag     ( )                          { return m_depthIntraSkipFlag     ;                             };
    3334 
    3335   Int                         getMpiSubPbSize           ( )                          { return m_mpiSubPbSize           ;                             };
    3336   Int                         getSubPbSize              ( )                          { return m_subPbSize              ;                             };
    3337 #if NH_3D_NBDV
    3338   Int                         getDefaultRefViewIdx()                                 { return m_iDefaultRefViewIdx;                                  }
    3339   Void                        setDefaultRefViewIdx(Int iViewIdx)                     { m_iDefaultRefViewIdx = iViewIdx;                              }
    3340 
    3341   Bool                        getDefaultRefViewIdxAvailableFlag()                    { return m_bDefaultRefViewIdxAvailableFlag;                     }
    3342   Void                        setDefaultRefViewIdxAvailableFlag(Bool bViewIdx)       { m_bDefaultRefViewIdxAvailableFlag = bViewIdx;                 }
    3343   Void                        setDefaultRefView( );
    3344 #endif
    3345 #endif
    33462934#if NH_MV
    33472935 TComPic*                     getRefPicSetInterLayer( Int setIdc, Int i ) const;
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComWedgelet.cpp

    r1313 r1390  
    4545using namespace std;
    4646
    47 #if NH_3D_DMM
    48 TComWedgelet::TComWedgelet( UInt uiWidth, UInt uiHeight ) : m_uhXs     ( 0 ),
    49                                                             m_uhYs     ( 0 ),
    50                                                             m_uhXe     ( 0 ),
    51                                                             m_uhYe     ( 0 ),
    52                                                             m_uhOri    ( 0 ),
    53                                                             m_eWedgeRes( FULL_PEL ),
    54                                                             m_bIsCoarse( false )
    55 {
    56   create( uiWidth, uiHeight );
    57 }
    58 
    59 TComWedgelet::TComWedgelet( const TComWedgelet &rcWedge ) : m_uhXs     ( rcWedge.m_uhXs      ),
    60                                                             m_uhYs     ( rcWedge.m_uhYs      ),
    61                                                             m_uhXe     ( rcWedge.m_uhXe      ),
    62                                                             m_uhYe     ( rcWedge.m_uhYe      ),
    63                                                             m_uhOri    ( rcWedge.m_uhOri     ),
    64                                                             m_eWedgeRes( rcWedge.m_eWedgeRes ),
    65                                                             m_bIsCoarse( rcWedge.m_bIsCoarse ),
    66                                                             m_uiWidth  ( rcWedge.m_uiWidth   ),
    67                                                             m_uiHeight ( rcWedge.m_uiHeight  ),
    68                                                             m_pbPattern( (Bool*)xMalloc( Bool, (m_uiWidth * m_uiHeight) ) ),
    69                                                             m_pbScaledPattern( g_wedgePattern )
    70 {
    71   ::memcpy( m_pbPattern, rcWedge.m_pbPattern, sizeof(Bool) * (m_uiWidth * m_uiHeight));
    72 }
    73 
    74 TComWedgelet::~TComWedgelet(void)
    75 {
    76   destroy();
    77 }
    78 
    79 Void TComWedgelet::create( UInt uiWidth, UInt uiHeight )
    80 {
    81   assert( uiWidth > 0 && uiHeight > 0 );
    82 
    83   m_uiWidth   = uiWidth;
    84   m_uiHeight  = uiHeight;
    85 
    86   m_pbPattern = (Bool*)xMalloc( Bool, (m_uiWidth * m_uiHeight) );
    87   m_pbScaledPattern = g_wedgePattern;
    88 }
    89 
    90 Void TComWedgelet::destroy()
    91 {
    92   if( m_pbPattern ) { xFree( m_pbPattern ); m_pbPattern = NULL; }
    93 }
    94 
    95 Void TComWedgelet::clear()
    96 {
    97   ::memset( m_pbPattern, 0, (m_uiWidth * m_uiHeight) * sizeof(Bool) );
    98 }
    99 
    100 Void TComWedgelet::setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse )
    101 {
    102   m_uhXs      = uhXs;
    103   m_uhYs      = uhYs;
    104   m_uhXe      = uhXe;
    105   m_uhYe      = uhYe;
    106   m_uhOri     = uhOri;
    107   m_eWedgeRes = eWedgeRes;
    108   m_bIsCoarse = bIsCoarse;
    109 
    110   xGenerateWedgePattern();
    111 }
    112 
    113 Bool TComWedgelet::checkNotPlain()
    114 {
    115   for( UInt k = 1; k < (m_uiWidth * m_uiHeight); k++ )
    116   {
    117     if( m_pbPattern[0] != m_pbPattern[k] )
    118     {
    119       return true;
    120     }
    121   }
    122   return false;
    123 }
    124 
    125 Bool TComWedgelet::checkIdentical( Bool* pbRefPattern )
    126 {
    127   for( UInt k = 0; k < (m_uiWidth * m_uiHeight); k++ )
    128   {
    129     if( m_pbPattern[k] != pbRefPattern[k] )
    130     {
    131       return false;
    132     }
    133   }
    134   return true;
    135 }
    136 
    137 Bool TComWedgelet::checkInvIdentical( Bool* pbRefPattern )
    138 {
    139   for( UInt k = 0; k < (m_uiWidth * m_uiHeight); k++ )
    140   {
    141     if( m_pbPattern[k] == pbRefPattern[k] )
    142     {
    143       return false;
    144     }
    145   }
    146   return true;
    147 }
    148 
    149 Void TComWedgelet::generateWedgePatternByRotate(const TComWedgelet &rcWedge, Int rotate)
    150 {
    151   Int stride = m_uiWidth;
    152   Int sinc, offsetI, offsetJ;
    153  
    154   sinc = 1;
    155   offsetI = ( sinc) < 0 ? stride-1 : 0; // 0
    156   offsetJ = (-sinc) < 0 ? stride-1 : 0; // stride - 1
    157 
    158   for (Int y = 0; y < stride; y++)
    159   {
    160     for (Int x = 0; x < stride; x++)
    161     {
    162       Int i = offsetI + sinc * y; // y
    163       Int j = offsetJ - sinc * x; // stride - 1 - x
    164       m_pbPattern[(y * stride) + x] = !rcWedge.m_pbPattern[(j * stride) + i];
    165     }
    166   }
    167   Int blocksize = rcWedge.m_uiWidth * (rcWedge.m_eWedgeRes == HALF_PEL ? 2 : 1);
    168   Int offsetX = (-sinc) < 0 ? blocksize - 1 : 0;
    169   Int offsetY = ( sinc) < 0 ? blocksize - 1 : 0;
    170   m_uhXs = offsetX - sinc * rcWedge.m_uhYs;
    171   m_uhYs = offsetY + sinc * rcWedge.m_uhXs;
    172   m_uhXe = offsetX - sinc * rcWedge.m_uhYe;
    173   m_uhYe = offsetY + sinc * rcWedge.m_uhXe;
    174   m_uhOri = rotate;
    175   m_eWedgeRes = rcWedge.m_eWedgeRes;
    176   m_bIsCoarse = rcWedge.m_bIsCoarse;
    177   m_uiWidth  = rcWedge.m_uiWidth;
    178   m_uiHeight = rcWedge.m_uiHeight;
    179 }
    180 
    181 Void TComWedgelet::xGenerateWedgePattern()
    182 {
    183   UInt uiTempBlockSize = 0;
    184   UChar uhXs = 0, uhYs = 0, uhXe = 0, uhYe = 0;
    185   switch( m_eWedgeRes )
    186   {
    187   case(   FULL_PEL ): { uiTempBlockSize =  m_uiWidth;     uhXs =  m_uhXs;     uhYs =  m_uhYs;     uhXe =  m_uhXe;     uhYe =  m_uhYe;     } break;
    188   case(   HALF_PEL ): { uiTempBlockSize = (m_uiWidth<<1); uhXs =  m_uhXs;     uhYs =  m_uhYs;     uhXe =  m_uhXe;     uhYe =  m_uhYe;     } break;
    189   }
    190 
    191   Bool* pbTempPattern = new Bool[ (uiTempBlockSize * uiTempBlockSize) ];
    192   ::memset( pbTempPattern, 0, (uiTempBlockSize * uiTempBlockSize) * sizeof(Bool) );
    193   Int iTempStride = uiTempBlockSize;
    194 
    195   xDrawEdgeLine( uhXs, uhYs, uhXe, uhYe, pbTempPattern, iTempStride );
    196 
    197   Int shift = (m_eWedgeRes == HALF_PEL) ? 1 : 0;
    198   Int endPos = uhYe>>shift;
    199   for (Int y = 0; y <= endPos; y++)
    200   {
    201     for (Int x = 0; x < m_uiWidth && pbTempPattern[(y * m_uiWidth) + x] == 0; x++)
    202     {
    203       pbTempPattern[(y * m_uiWidth) + x] = true;
    204     }
    205   }
    206   for( UInt k = 0; k < (m_uiWidth * m_uiHeight); k++ )
    207   {
    208     m_pbPattern[k] = pbTempPattern[k];
    209   };
    210 
    211   if( pbTempPattern )
    212   {
    213     delete [] pbTempPattern;
    214     pbTempPattern = NULL;
    215   }
    216 }
    217 
    218 Void TComWedgelet::xDrawEdgeLine( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, Bool* pbPattern, Int iPatternStride )
    219 {
    220   Int x0 = (Int)uhXs;
    221   Int y0 = (Int)uhYs;
    222   Int x1 = (Int)uhXe;
    223   Int y1 = (Int)uhYe;
    224 
    225   // direction independent Bresenham line
    226   bool steep = (abs(y1 - y0) > abs(x1 - x0));
    227   if( steep )
    228   {
    229     std::swap( x0, y0 );
    230     std::swap( x1, y1 );
    231   }
    232 
    233   bool backward = ( x0 > x1 );
    234   if( backward )
    235   {
    236     std::swap( x0, x1 );
    237     std::swap( y0, y1 );
    238   }
    239 
    240   Int deltax = x1 - x0;
    241   Int deltay = abs(y1 - y0);
    242   Int error = 0;
    243   Int deltaerr = (deltay<<1);
    244 
    245   Int ystep;
    246   Int y = y0;
    247   if( y0 < y1 ) ystep =  1;
    248   else          ystep = -1;
    249 
    250   for( Int x = x0; x <= x1; x++ )
    251   {
    252     Int shift = (m_eWedgeRes == HALF_PEL) ? 1 : 0;
    253     Int stride = iPatternStride >> shift;
    254     if( steep ) { pbPattern[((x>>shift) * stride) + (y>>shift)] = true; }
    255     else        { pbPattern[((y>>shift) * stride) + (x>>shift)] = true; }
    256 
    257     error += deltaerr;
    258     if( error >= deltax )
    259     {
    260       y += ystep;
    261       error = error - (deltax<<1);
    262     }
    263   }
    264 }
    265 
    266 Bool* TComWedgelet::getPatternScaled( UInt dstSize )
    267 {
    268   Bool *pbSrcPat = this->getPattern();
    269   UInt uiSrcSize = this->getStride();
    270 
    271   if( 16 >= dstSize )
    272   {
    273     assert( dstSize == uiSrcSize );
    274     return pbSrcPat;
    275   }
    276   else
    277   {
    278     Int scale = (g_aucConvertToBit[dstSize] - g_aucConvertToBit[uiSrcSize]);
    279     assert(scale>=0);
    280     for (Int y=0; y<dstSize; y++)
    281     {
    282       for (Int x=0; x<dstSize; x++)
    283       {
    284         Int srcX = x>>scale;
    285         Int srcY = y>>scale;
    286         m_pbScaledPattern[y*dstSize + x] = pbSrcPat[ srcY*uiSrcSize + srcX ];
    287       }
    288     }
    289     return m_pbScaledPattern;
    290   }
    291 }
    292 
    293 Void TComWedgelet::getPatternScaledCopy( UInt dstSize, Bool* dstBuf )
    294 {
    295   Bool *pbSrcPat = this->getPattern();
    296   UInt uiSrcSize = this->getStride();
    297 
    298   if( 16 >= dstSize )
    299   {
    300     assert( dstSize == uiSrcSize );
    301     memcpy( dstBuf, pbSrcPat, (dstSize*dstSize) );
    302   }
    303   else
    304   {
    305     Int scale = (g_aucConvertToBit[dstSize] - g_aucConvertToBit[uiSrcSize]);
    306     assert(scale>=0);
    307     for (Int y=0; y<dstSize; y++)
    308     {
    309       for (Int x=0; x<dstSize; x++)
    310       {
    311         Int srcX = x>>scale;
    312         Int srcY = y>>scale;
    313         dstBuf[y*dstSize + x] = pbSrcPat[ srcY*uiSrcSize + srcX ];
    314       }
    315     }
    316   }
    317 }
    318 
    319 
    320 TComWedgeNode::TComWedgeNode()
    321 {
    322   m_uiPatternIdx = DMM_NO_WEDGE_IDX;
    323   for( UInt uiPos = 0; uiPos < DMM_NUM_WEDGE_REFINES; uiPos++ )
    324   {
    325     m_uiRefineIdx[uiPos] = DMM_NO_WEDGE_IDX;
    326   }
    327 }
    328 
    329 UInt TComWedgeNode::getPatternIdx()
    330 {
    331   return m_uiPatternIdx;
    332 }
    333 UInt TComWedgeNode::getRefineIdx( UInt uiPos )
    334 {
    335   assert( uiPos < DMM_NUM_WEDGE_REFINES );
    336   return m_uiRefineIdx[uiPos];
    337 }
    338 Void TComWedgeNode::setPatternIdx( UInt uiIdx )
    339 {
    340   m_uiPatternIdx = uiIdx;
    341 }
    342 Void TComWedgeNode::setRefineIdx( UInt uiIdx, UInt uiPos )
    343 {
    344   assert( uiPos < DMM_NUM_WEDGE_REFINES );
    345   m_uiRefineIdx[uiPos] = uiIdx; 
    346 }
    347 #endif //NH_3D_DMM
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComWedgelet.h

    r1313 r1390  
    4343#include <vector>
    4444
    45 #if NH_3D_DMM
    46 #define DMM_OFFSET     (NUM_INTRA_MODE+1) // offset for DMM and RBC mode numbers
    47 #define DMM_MIN_SIZE                   4  // min. block size for DMM and RBC modes
    48 #define DMM_MAX_SIZE                  32  // max. block size for DMM and RBC modes
    49 
    50 enum DmmID
    51 {
    52   DMM1_IDX = 0,
    53   DMM4_IDX = 1,
    54   NUM_DMM  = 2,
    55   DMM_NO_IDX = MAX_UINT
    56 };
    57 
    58 __inline DmmID getDmmType( Int intraMode )
    59 {
    60     Int dmmType = intraMode-DMM_OFFSET;
    61     return (dmmType >= 0 && dmmType < NUM_DMM) ? (DmmID)dmmType : DMM_NO_IDX;
    62 }
    63 __inline Bool isDmmMode( Int intraMode ) { return ((UInt)getDmmType( intraMode ) < NUM_DMM); }
    64 
    65 
    66 // Wedgelets
    67 #define DMM_NO_WEDGE_IDX       MAX_UINT
    68 #define DMM_NUM_WEDGE_REFINES   8
    69 
    70 enum WedgeResolution
    71 {
    72   FULL_PEL,
    73   HALF_PEL
    74 };
    75 
    76 
    77 // ====================================================================================================================
    78 // Class definition TComWedgelet
    79 // ====================================================================================================================
    80 class TComWedgelet
    81 {
    82 private:
    83   UChar           m_uhXs;                       // line start X pos
    84   UChar           m_uhYs;                       // line start Y pos
    85   UChar           m_uhXe;                       // line end   X pos
    86   UChar           m_uhYe;                       // line end   Y pos
    87   UChar           m_uhOri;                      // orientation index
    88   WedgeResolution m_eWedgeRes;                  // start/end pos resolution
    89   Bool            m_bIsCoarse;
    90 
    91   UInt  m_uiWidth;
    92   UInt  m_uiHeight;
    93 
    94   Bool* m_pbPattern;
    95   Bool* m_pbScaledPattern;
    96 
    97   Void  xGenerateWedgePattern();
    98   Void  xDrawEdgeLine( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, Bool* pbPattern, Int iPatternStride );
    99 
    100 public:
    101   TComWedgelet( UInt uiWidth, UInt uiHeight );
    102   TComWedgelet( const TComWedgelet &rcWedge );
    103   virtual ~TComWedgelet();
    104 
    105   Void  create ( UInt iWidth, UInt iHeight );   ///< create  wedgelet pattern
    106   Void  destroy();                              ///< destroy wedgelet pattern
    107   Void  clear  ();                              ///< clear   wedgelet pattern
    108 
    109   UInt            getWidth   () { return m_uiWidth; }
    110   UInt            getStride  () { return m_uiWidth; }
    111   UInt            getHeight  () { return m_uiHeight; }
    112   WedgeResolution getWedgeRes() { return m_eWedgeRes; }
    113   Bool*           getPattern () { return m_pbPattern; }
    114   UChar           getStartX  () { return m_uhXs; }
    115   UChar           getStartY  () { return m_uhYs; }
    116   UChar           getEndX    () { return m_uhXe; }
    117   UChar           getEndY    () { return m_uhYe; }
    118   UChar           getOri     () { return m_uhOri; }
    119   Bool            getIsCoarse() { return m_bIsCoarse; }
    120 
    121   Void  generateWedgePatternByRotate(const TComWedgelet &rcWedge, Int rotate);
    122   Void  setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse = false );
    123 
    124   Bool  checkNotPlain();
    125   Bool  checkIdentical( Bool* pbRefPattern );
    126   Bool  checkInvIdentical( Bool* pbRefPattern );
    127 
    128   Bool* getPatternScaled    ( UInt dstSize );
    129   Void  getPatternScaledCopy( UInt dstSize, Bool* dstBuf );
    130 
    131 };  // END CLASS DEFINITION TComWedgelet
    132 
    133 // type definition wedgelet pattern list
    134 typedef std::vector<TComWedgelet> WedgeList;
    135 
    136 // ====================================================================================================================
    137 // Class definition TComWedgeRef
    138 // ====================================================================================================================
    139 class TComWedgeRef
    140 {
    141 private:
    142   UChar           m_uhXs;                       // line start X pos
    143   UChar           m_uhYs;                       // line start Y pos
    144   UChar           m_uhXe;                       // line end   X pos
    145   UChar           m_uhYe;                       // line end   Y pos
    146   UInt            m_uiRefIdx;                   // index of corresponding pattern of TComWedgelet object in wedge list
    147 
    148 public:
    149   TComWedgeRef() {}
    150   virtual ~TComWedgeRef() {}
    151 
    152   UChar           getStartX  () { return m_uhXs; }
    153   UChar           getStartY  () { return m_uhYs; }
    154   UChar           getEndX    () { return m_uhXe; }
    155   UChar           getEndY    () { return m_uhYe; }
    156   UInt            getRefIdx  () { return m_uiRefIdx; }
    157 
    158   Void  setWedgeRef( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UInt uiRefIdx ) { m_uhXs = uhXs; m_uhYs = uhYs; m_uhXe = uhXe; m_uhYe = uhYe; m_uiRefIdx = uiRefIdx; }
    159 };  // END CLASS DEFINITION TComWedgeRef
    160 
    161 
    162 // ====================================================================================================================
    163 // Class definition TComWedgeNode
    164 // ====================================================================================================================
    165 class TComWedgeNode
    166 {
    167 private:
    168   UInt            m_uiPatternIdx;
    169   UInt            m_uiRefineIdx[DMM_NUM_WEDGE_REFINES];
    170 
    171 public:
    172   TComWedgeNode();
    173   virtual ~TComWedgeNode() {}
    174 
    175   UInt            getPatternIdx();
    176   UInt            getRefineIdx ( UInt uiPos );
    177 
    178   Void            setPatternIdx( UInt uiIdx );
    179   Void            setRefineIdx ( UInt uiIdx, UInt uiPos );
    180 };  // END CLASS DEFINITION TComWedgeNode
    181 
    182 // type definition wedgelet node list
    183 typedef std::vector<TComWedgeNode> WedgeNodeList;
    184 #endif //NH_3D_DMM
    18545
    18646#endif // __TCOMWEDGELET__
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComYuv.cpp

    r1386 r1390  
    464464}
    465465
    466 #if NH_3D_VSO
    467 Void TComYuv::addClipPartLuma( Int bitDepth, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
    468 {
    469   Int x, y;
    470 
    471   Pel* pSrc0 = pcYuvSrc0->getAddr( COMPONENT_Y, uiTrUnitIdx);
    472   Pel* pSrc1 = pcYuvSrc1->getAddr( COMPONENT_Y, uiTrUnitIdx);
    473   Pel* pDst  =            getAddr( COMPONENT_Y, uiTrUnitIdx);
    474 
    475   UInt iSrc0Stride = pcYuvSrc0->getStride( COMPONENT_Y );
    476   UInt iSrc1Stride = pcYuvSrc1->getStride( COMPONENT_Y );
    477   UInt iDstStride  =            getStride( COMPONENT_Y );
    478   for ( y = uiPartSize-1; y >= 0; y-- )
    479   {
    480     for ( x = uiPartSize-1; x >= 0; x-- )
    481     {
    482       pDst[x] = ClipBD( pSrc0[x] + pSrc1[x], bitDepth );     
    483     }
    484     pSrc0 += iSrc0Stride;
    485     pSrc1 += iSrc1Stride;
    486     pDst  += iDstStride;
    487   }
    488 }
    489 
    490 #if NH_3D_ARP
    491 Void TComYuv::addARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip, const BitDepths &clipBitDepths )
    492 {
    493   addARPLuma   ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth   , uiHeight    , bClip , clipBitDepths);
    494   addARPChroma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth>>1, uiHeight>>1 , bClip , clipBitDepths);
    495 }
    496 
    497 Void TComYuv::addARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip, const BitDepths &clipBitDepths )
    498 {
    499   Int x, y;
    500 
    501   Pel* pSrc0 = pcYuvSrc0->getAddr( COMPONENT_Y, uiAbsPartIdx );
    502   Pel* pSrc1 = pcYuvSrc1->getAddr( COMPONENT_Y, uiAbsPartIdx );
    503   Pel* pDst  = getAddr( COMPONENT_Y, uiAbsPartIdx );
    504 
    505   UInt iSrc0Stride = pcYuvSrc0->getStride(COMPONENT_Y);
    506   UInt iSrc1Stride = pcYuvSrc1->getStride(COMPONENT_Y);
    507   UInt iDstStride  = getStride(COMPONENT_Y);
    508   const Int clipbd = clipBitDepths.recon[CHANNEL_TYPE_LUMA];
    509   Int iIFshift = IF_INTERNAL_PREC - clipbd;
    510   Int iOffSet  = ( 1 << ( iIFshift - 1 ) ) + IF_INTERNAL_OFFS;
    511   for ( y = uiHeight-1; y >= 0; y-- )
    512   {
    513     for ( x = uiWidth-1; x >= 0; x-- )
    514     {
    515       pDst[x] = pSrc0[x] + pSrc1[x];
    516       if( bClip )
    517       {
    518         pDst[x] = Pel(ClipBD<Int>(Int( ( pDst[x] + iOffSet ) >> iIFshift ), clipbd));
    519       }
    520     }
    521     pSrc0 += iSrc0Stride;
    522     pSrc1 += iSrc1Stride;
    523     pDst  += iDstStride;
    524   }
    525 }
    526 
    527 Void TComYuv::addARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip, const BitDepths &clipBitDepths )
    528 {
    529   Int x, y;
    530 
    531   Pel* pSrcU0 = pcYuvSrc0->getAddr( COMPONENT_Cb, uiAbsPartIdx );
    532   Pel* pSrcU1 = pcYuvSrc1->getAddr( COMPONENT_Cb, uiAbsPartIdx );
    533   Pel* pSrcV0 = pcYuvSrc0->getAddr( COMPONENT_Cr, uiAbsPartIdx );
    534   Pel* pSrcV1 = pcYuvSrc1->getAddr( COMPONENT_Cr, uiAbsPartIdx );
    535   Pel* pDstU = getAddr( COMPONENT_Cb, uiAbsPartIdx );
    536   Pel* pDstV = getAddr( COMPONENT_Cr, uiAbsPartIdx );
    537 
    538   UInt  iSrc0StrideCb = pcYuvSrc0->getStride(COMPONENT_Cb);
    539   UInt  iSrc1StrideCb = pcYuvSrc1->getStride(COMPONENT_Cb);
    540   UInt  iDstStrideCb  = getStride(COMPONENT_Cb);
    541 
    542   UInt  iSrc0StrideCr = pcYuvSrc0->getStride(COMPONENT_Cr);
    543   UInt  iSrc1StrideCr = pcYuvSrc1->getStride(COMPONENT_Cr);
    544   UInt  iDstStrideCr  = getStride(COMPONENT_Cr);
    545 
    546   const Int clipbd = clipBitDepths.recon[CHANNEL_TYPE_CHROMA];
    547   Int iIFshift = IF_INTERNAL_PREC - clipbd;
    548   Int iOffSet  = ( 1 << ( iIFshift - 1 ) ) + IF_INTERNAL_OFFS;
    549 
    550   for ( y = uiHeight-1; y >= 0; y-- )
    551   {
    552     for ( x = uiWidth-1; x >= 0; x-- )
    553     {
    554       pDstU[x] = pSrcU0[x] + pSrcU1[x];
    555       pDstV[x] = pSrcV0[x] + pSrcV1[x];
    556       if( bClip )
    557       {
    558         pDstU[x] = Pel(ClipBD<Int>( Int( ( pDstU[x] + iOffSet ) >> iIFshift ), clipbd));
    559         pDstV[x] = Pel(ClipBD<Int>( Int( ( pDstV[x] + iOffSet ) >> iIFshift ), clipbd));
    560       }
    561     }
    562 
    563     pSrcU0 += iSrc0StrideCb;
    564     pSrcU1 += iSrc1StrideCb;
    565     pSrcV0 += iSrc0StrideCr;
    566     pSrcV1 += iSrc1StrideCr;
    567     pDstU  += iDstStrideCb;
    568     pDstV  += iDstStrideCr;
    569   }
    570 }
    571 
    572 Void TComYuv::subtractARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
    573 {
    574   subtractARPLuma  ( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth    , uiHeight    );
    575 
    576   if (uiWidth > 8 && pcYuvSrc1->getNumberValidComponents() > 1)
    577   {
    578     subtractARPChroma( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth>>1 , uiHeight>>1 );
    579 }
    580 }
    581 
    582 Void TComYuv::subtractARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
    583 {
    584   Int x, y;
    585 
    586   Pel* pSrc0 = pcYuvSrc0->getAddr(COMPONENT_Y, uiAbsPartIdx );
    587   Pel* pSrc1 = pcYuvSrc1->getAddr(COMPONENT_Y, uiAbsPartIdx );
    588   Pel* pDst  = getAddr           (COMPONENT_Y, uiAbsPartIdx );
    589 
    590   Int  iSrc0Stride = pcYuvSrc0->getStride(COMPONENT_Y);
    591   Int  iSrc1Stride = pcYuvSrc1->getStride(COMPONENT_Y);
    592   Int  iDstStride  = getStride(COMPONENT_Y);
    593   for ( y = uiHeight-1; y >= 0; y-- )
    594   {
    595     for ( x = uiWidth-1; x >= 0; x-- )
    596     {
    597       pDst[x] = pSrc0[x] - pSrc1[x];
    598     }
    599     pSrc0 += iSrc0Stride;
    600     pSrc1 += iSrc1Stride;
    601     pDst  += iDstStride;
    602   }
    603 }
    604 
    605 Void TComYuv::subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
    606 {
    607   Int x, y;
    608 
    609   Pel* pSrcU0 = pcYuvSrc0->getAddr(COMPONENT_Cb, uiAbsPartIdx );
    610   Pel* pSrcU1 = pcYuvSrc1->getAddr(COMPONENT_Cb, uiAbsPartIdx );
    611   Pel* pSrcV0 = pcYuvSrc0->getAddr(COMPONENT_Cr, uiAbsPartIdx );
    612   Pel* pSrcV1 = pcYuvSrc1->getAddr(COMPONENT_Cr, uiAbsPartIdx );
    613   Pel* pDstU  = getAddr(COMPONENT_Cb, uiAbsPartIdx );
    614   Pel* pDstV  = getAddr(COMPONENT_Cr, uiAbsPartIdx );
    615 
    616   Int  iSrc0Stride = pcYuvSrc0->getStride(COMPONENT_Cb);
    617   Int  iSrc1Stride = pcYuvSrc1->getStride(COMPONENT_Cb);
    618   Int  iDstStride  = getStride( COMPONENT_Cb );
    619   for ( y = uiHeight-1; y >= 0; y-- )
    620   {
    621     for ( x = uiWidth-1; x >= 0; x-- )
    622     {
    623       pDstU[x] = pSrcU0[x] - pSrcU1[x];
    624       pDstV[x] = pSrcV0[x] - pSrcV1[x];
    625     }
    626     pSrcU0 += iSrc0Stride;
    627     pSrcU1 += iSrc1Stride;
    628     pSrcV0 += iSrc0Stride;
    629     pSrcV1 += iSrc1Stride;
    630     pDstU  += iDstStride;
    631     pDstV  += iDstStride;
    632   }
    633 }
    634 
    635 Void TComYuv::multiplyARP( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
    636 {
    637   multiplyARPLuma( uiAbsPartIdx , uiWidth , uiHeight , dW );
    638 
    639   if ( uiWidth > 8 && getNumberValidComponents() > 1 )
    640   {
    641     multiplyARPChroma( uiAbsPartIdx , uiWidth >> 1 , uiHeight >> 1 , dW );
    642 }
    643 }
    644 
    645 Void TComYuv::xxMultiplyLine( Pel* pSrcDst , UInt uiWidth , UChar dW )
    646 {
    647   assert( dW == 2 );
    648   for( UInt x = 0 ; x < uiWidth ; x++ )
    649     pSrcDst[x] =  pSrcDst[x] >> 1;
    650 }
    651 
    652 Void TComYuv::multiplyARPLuma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
    653 {
    654   Pel* pDst  = getAddr(COMPONENT_Y, uiAbsPartIdx );
    655   Int  iDstStride  = getStride(COMPONENT_Y);
    656   for ( Int y = uiHeight-1; y >= 0; y-- )
    657   {
    658     xxMultiplyLine( pDst , uiWidth , dW );
    659     pDst  += iDstStride;
    660   }
    661 }
    662 
    663 Void TComYuv::multiplyARPChroma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
    664 {
    665   Pel* pDstU  = getAddr( COMPONENT_Cb, uiAbsPartIdx );
    666   Pel* pDstV  = getAddr( COMPONENT_Cr, uiAbsPartIdx );
    667 
    668   Int  iDstStride  = getStride( COMPONENT_Cb );
    669   for ( Int y = uiHeight-1; y >= 0; y-- )
    670   {
    671     xxMultiplyLine( pDstU , uiWidth , dW );
    672     xxMultiplyLine( pDstV , uiWidth , dW );
    673     pDstU  += iDstStride;
    674     pDstV  += iDstStride;
    675   }
    676 }
    677 #endif
    678 #endif
    679466
    680467//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComYuv.h

    r1386 r1390  
    204204  UInt         getComponentScaleX         (const ComponentID id) const { return ::getComponentScaleX(id, m_chromaFormatIDC); }
    205205  UInt         getComponentScaleY         (const ComponentID id) const { return ::getComponentScaleY(id, m_chromaFormatIDC); }
    206 #if NH_3D_VSO
    207   Void         addClipPartLuma( Int bitDepth, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
    208 #endif
    209 #if NH_3D
    210 #if NH_3D_ARP
    211   Void         addARP                     ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip, const BitDepths &clipBitDepths );
    212   Void         addARPLuma                 ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip, const BitDepths &clipBitDepths );
    213   Void         addARPChroma               ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip, const BitDepths &clipBitDepths );
    214   Void         subtractARP                ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
    215   Void         subtractARPLuma            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
    216   Void         subtractARPChroma          ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
    217   Void         multiplyARP                ( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW );
    218   Void         multiplyARPLuma            ( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW );
    219   Void         multiplyARPChroma          ( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW );
    220 private:                                 
    221   Void         xxMultiplyLine             ( Pel * pSrcDst , UInt uiWidth , UChar dW );
    222 #endif
    223 #endif
    224206
    225207};// END CLASS DEFINITION TComYuv
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TypeDef.h

    r1386 r1390  
    4949   make             -> HEVC_EXT not defined
    5050   make HEVC_EXT=0  -> NH_MV=0 H_3D=0   --> plain HM
    51    make HEVC_EXT=1  -> NH_MV=1 H_3D=0   --> MV only
    52    make HEVC_EXT=2  -> NH_MV=1 H_3D=1   --> full 3D
     51   make HEVC_EXT=1  -> NH_MV=1 H_3D=0   --> MV   
    5352*/
    5453#ifndef HEVC_EXT
    55 #define HEVC_EXT                    2
    56 #endif
    57 #if ( HEVC_EXT < 0 )||( HEVC_EXT > 2 )
    58 #error HEVC_EXT must be in the range of 0 to 2, inclusive.
     54#define HEVC_EXT                    1
     55#endif
     56#if ( HEVC_EXT < 0 )||( HEVC_EXT > 1 )
     57#error HEVC_EXT must be in the range of 0 to 1, inclusive.
    5958#endif
    6059#define NH_MV          ( HEVC_EXT != 0)
    61 #define NH_3D          ( HEVC_EXT == 2)
    6260/////////////////////////////////////////////////////////////////////////////////////////
    6361///////////////////////////////////   FIXES AND INTEGRATIONS     ////////////////////////
     
    6563#if NH_MV
    6664// Recent bug fixes
    67 #define NH_3D_FIX_TICKET_107                     1 // Clean up.
    68 #define NH_3D_FIX_TICKET_91                      1 // NBDV availability in case of tiles.
    6965// Things that needs to be fixed also in the Specification ...
    7066#define NH_MV_FIX_NO_REF_PICS_CHECK               1 // !!SPEC!!
     
    7268#define NH_MV_FIX_NUM_POC_TOTAL_CUR               1 // Derivation of NumPocTotalCur for IDR pictures. !!SPEC!!
    7369// To be done
    74 #define NH_MV_HLS_PTL_LIMITS                       0
     70#define NH_MV_HLS_PTL_LIMITS                      0
    7571#define NH_MV_SEI_TBD                             0
    7672#endif
     
    8076#if NH_MV
    8177#define NH_MV_ENC_DEC_TRAC                 1  //< CU/PU level tracking
    82 #if NH_3D
    83 #define NH_3D_INTEGER_MV_DEPTH            1
    84 #define NH_3D_ENC_DEPTH                   1   // Encoder optimizations for depth, incl.
    85                                               // HHI_DEPTH_INTRA_SEARCH_RAU_C0160
    86                                               // LG_ZEROINTRADEPTHRESI_A0087
    87                                               // HHI_DMM4_ENC_I0066
    88                                               // H_3D_FAST_DEPTH_INTRA
    89 #define NH_3D_FAST_TEXTURE_ENCODING       1   // Fast merge mode decision and early CU determination for texture component of dependent view, JCT3V-E0173
    90 #define NH_3D_ARP                         1  // Advanced residual prediction (ARP), JCT3V-D0177
    91                                              // QC_MTK_INTERVIEW_ARP_F0123_F0108 JCT3V-F0123; JCT3V-F0108
    92                                              // SHARP_ARP_REF_CHECK_F0105        ARP reference picture selection and DPB check
    93                                              // LGE_ARP_CTX_F0161                JCT3V-F0161
    94                                              // MTK_ARP_FLAG_CABAC_SIMP_G0061 Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
    95                                              // MTK_ARP_REF_SELECTION_G0053 ARP Reference picture selection in JCT3V-G0053
    96                                              // MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085  Align the SW and WD for the bi-prediction ARP PUs by disallowing non-normative fast bi-prediction for ARP PUs, JCT3V-H0085
    97                                              // QC_I0051_ARP_SIMP
    98                                              // SHARP_ARP_CHROMA_I0104
    99                                              // MTK_I0072_IVARP_SCALING_FIX
    100                                              // SEC_ARP_VIEW_REF_CHECK_J0037    Signaling iv_res_pred_weight_idx when the current slice has both view and temporal reference picture(s), JCT3V-J0037 item1
    101                                              // SEC_ARP_REM_ENC_RESTRICT_K0035    Removal of encoder restriction of ARP, JCT3V-K0035
    102 #define NH_3D_QTL                          1
    103 #define NH_3D_QTLPC                        1   // OL_QTLIMIT_PREDCODING_B0068 //JCT3V-B0068
    104                                               // HHI_QTLPC_RAU_OFF_C0160 JCT3V-C0160 change 2: quadtree limitation and predictive coding switched off in random access units
    105                                               // MTK_TEX_DEP_PAR_G0055 Texture-partition-dependent depth partition. JCT3V-G0055
    106 #define NH_3D_VSO                          1   // VSO, View synthesis optimization, includes:
    107                                               // HHI_VSO
    108                                               // HHI_VSO_LS_TABLE_M23714 enable table base Lagrange multiplier optimization
    109                                               // SAIT_VSO_EST_A0033, JCT3V-A0033 modification 3
    110                                               // LGE_WVSO_A0119
    111                                               // SCU_HS_VSD_BUGFIX_IMPROV_G0163
    112 #define NH_3D_NBDV                         1   // Neighboring block disparity derivation
    113                                               // QC_JCT3V-A0097
    114                                               // LGE_DVMCP_A0126
    115                                               // LGE_DVMCP_MEM_REDUCTION_B0135
    116                                               // QC_SIMPLE_NBDV_B0047
    117                                               // FIX_LGE_DVMCP_B0133
    118                                               // QC_NBDV_LDB_FIX_C0055
    119                                               // MTK_SAIT_TEMPORAL_FIRST_ORDER_C0141_C0097
    120                                               // MTK_SIMPLIFY_DVTC_C0135
    121                                               // QC_CU_NBDV_D0181
    122                                               // SEC_DEFAULT_DV_D0112
    123                                               // MTK_DVMCP_FIX_E0172       fix the mismatch between software and WD for DV derivation from DVMCP blocks, issue 2 in JCT3V-E0172
    124                                               // SEC_SIMPLIFIED_NBDV_E0142 Simplified NBDV, JCT3V-E0142 and JCT3V-E0190
    125                                               // MTK_NBDV_TN_FIX_E0172     fix the issue of DV derivation from the temporal neighboring blocks, issue 7 in JCT3V-E0172
    126                                               // MTK_TEXTURE_MRGCAND_BUGFIX_E0182  Bug fix for TEXTURE MERGING CANDIDATE     , JCT3V-E0182
    127                                               // LGE_SIMP_DISP_AVAIL_J0041    // Use 2 status for disparity availability - DISP_AVAILABLE and DISP_NONE
    128 #define NH_3D_IC                          1   // Illumination Compensation, JCT3V-B0045, JCT3V-C0046, JCT3V-D0060
    129                                               // Unifying rounding offset, for IC part, JCT3V-D0135
    130                                               // Full Pel Interpolation for Depth, HHI_FULL_PEL_DEPTH_MAP_MV_ACC
    131                                               // SHARP_ILLUCOMP_REFINE_E0046
    132                                               // MTK_CLIPPING_ALIGN_IC_E0168       // To support simplify bi-prediction PU with identical motion checking, JCT3V-E0168
    133                                               // LGE_IC_CTX_F0160 //JCT3V-F0160
    134                                               // SEC_ONLY_TEXTURE_IC_F0151
    135                                               // MTK_IC_FLAG_CABAC_SIMP_G0061
    136                                               // SEC_IC_ARP_SIG_G0072, Disabling IC when ARP is enabled, option 1 in JCT3V-G0072, part 2 in JCT3V-G0121
    137                                               // MTK_LOW_LATENCY_IC_ENCODING_H0086  Low-latency IC encoding in JCT3V-H0086
    138                                               // MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX  1  // Remove the global variables used in JCT3V-H0086
    139                                               // SEC_IC_NEIGHBOR_CLIP_I0080    // Clipping of neighboring sample position, JCT3V-I0080
    140                                               // LGE_CHROMA_IC_J0050_J0034
    141 #if NH_3D_NBDV
    142 #define NH_3D_NBDV_REF                     1   // Depth oriented neighboring block disparity derivation
    143                                               // MTK_D0156
    144                                               // MERL_D0166: Reference view selection in NBDV & Bi-VSP
    145                                               // MERL_C0152: Basic VSP
    146                                               // NBDV_DEFAULT_VIEWIDX_BUGFIX Bug fix for invalid default view index for NBDV
    147                                               // NTT_DoNBDV_VECTOR_CLIP_E0141 disparity vector clipping in DoNBDV, JCT3V-E0141 and JCT3V-E0209
    148                                               // SEC_VER_DONBDV_H0103          Vertical DV Restriction for DoNBDV
    149 #endif
    150 #define NH_3D_VSP                          1   // View synthesis prediction
    151                                               // MERL_C0152: Basic VSP
    152                                               // MERL_D0166: Reference view selection in NBDV & Bi-VSP
    153                                               // MTK_D0105, LG_D0139: No VSP for depth
    154                                               // QC_D0191: Clean up
    155                                               // LG_D0092: Multiple VSP candidate allowed
    156                                               // MTK_VSP_FIX_ALIGN_WD_E0172
    157                                               // NTT_VSP_ADAPTIVE_SPLIT_E0207 adaptive sub-PU partitioning in VSP, JCT3V-E0207
    158                                               // NTT_VSP_DC_BUGFIX_E0208 bugfix for sub-PU based DC in VSP, JCT3V-E0208
    159                                               // NTT_VSP_COMMON_E0207_E0208 common part of JCT3V-E0207 and JCT3V-E0208
    160                                               // MTK_F0109_LG_F0120_VSP_BLOCK MTK_LG_SIMPLIFY_VSP_BLOCK_PARTITION_F0109_F0120
    161                                               // SHARP_VSP_BLOCK_IN_AMP_F0102 VSP partitioning for AMP
    162                                               // MTK_VSP_SIMPLIFICATION_F0111 1. Inherited VSP also use NBDV of current CU, 2. VSP cannot be inherited from above LCU rowss
    163                                               // LGE_SHARP_VSP_INHERIT_F0104
    164                                               // NTT_STORE_SPDV_VSP_G0148 Storing Sub-PU based DV for VSP
    165                                               // Restricted bi-prediction for VSP
    166                                               // MTK_MRG_LIST_SIZE_CLEANUP_J0059   1   // Include VSP for deriving merge candidate list size, JCT3V-J0059
    167                                               // SEC_A1_BASED_VSP_J0039            1   // Removal of redundant VSP in Merge list
    168 #define NH_3D_MLC                          1
    169 #define NH_3D_IV_MERGE                     1  // Inter-view motion merge candidate
    170                                               // HHI_INTER_VIEW_MOTION_PRED
    171                                               // SAIT_IMPROV_MOTION_PRED_M24829, improved inter-view motion vector prediction
    172                                               // QC_MRG_CANS_B0048             , JCT3V-B0048, B0086, B0069
    173                                               // OL_DISMV_POS_B0069            , different pos for disparity MV candidate, B0069
    174                                               // MTK_INTERVIEW_MERGE_A0049     , second part
    175                                               // QC_AMVP_MRG_UNIFY_IVCAN_C0051
    176                                               // QC_INRIA_MTK_MRG_E0126
    177                                               // ETRIKHU_MERGE_REUSE_F0093 QC_DEPTH_IV_MRG_F0125, JCT3V-F0125: Depth oriented Inter-view MV candidate
    178                                               // MTK_NBDV_IVREF_FIX_G0067      , Disable IvMC, VSP when IVREF is not available, JCT3V-G0067
    179                                               // SEC_DEPTH_DV_DERIVAITON_G0074, Simplification of DV derivation for depth, JCT3V-G0074
    180                                               // QC_DEPTH_MERGE_SIMP_G0127 Remove DV candidate and shifting candidate for depth coding
    181                                               // QC_IV_PRED_CONSTRAINT_H0137   Constraint on inter-view (motion) prediction tools
    182                                               // ETRIKHU_BUGFIX_H0083          bug-fix for DV candidate pruning
    183                                               // ETRIKHU_CLEANUP_H0083         cleaned-up source code for constructing merging candidate list
    184                                               // ETRIKHU_CLEANUP_H0083_MISSING missing guard macros added by GT
    185                                               // SHARP_SIMPLE_MERGE_H0062      Restrict 3D-HEVC merge cand in small PUs
    186                                               // MTK_DIS_SPBIP8X4_H0205        Disable bi-prediction for 8x4 and 4x8 sub PU and remove the SPIVMP 2Nx2N restriction
    187                                               // SEC_ADAPT_DISABLE_IVMP        Disabling IVMP merge candidates when IC is enabled, JCT3V-H0070
    188                                               // SEC_SIMP_SHIFTED_DV_I0086     Simplification of Shifted DV candidate, JCT3V-I0086
    189                                               // SEC_SHIFTED_IVMC_POS_K0036    Position Derivation for Shifted-IVMC, JCT3V-K0036
    190 #define NH_3D_TEXT_MERGE                  1
    191                                               // TEXTURE MERGING CANDIDATE     , JCT3V-C0137
    192                                               // EC_MPI_ENABLING_MERGE_F0150, MPI flag in VPS and enabling in Merge mode
    193 #define NH_3D_TMVP                        1   // QC_TMVP_C0047
    194                                               // Sony_M23639
    195                                               // H_3D_TMVP_SCALING_FIX_K0053       1   // QC/CY for K0053
    196 #define NH_3D_DMM                         1   // Depth modeling modes
    197                                               // HHI_DMM_PRED_TEX
    198                                               // HHI_DMM_WEDGE_INTRA
    199                                               // FIX_WEDGE_NOFLOAT_D0036
    200                                               // LGE_EDGE_INTRA_A0070
    201                                               // LGE_DMM3_SIMP_C0044
    202                                               // QC_DC_PREDICTOR_D0183
    203                                               // LGE_CONCATENATE_D0141
    204                                               // PKU_QC_DEPTH_INTRA_UNI_D0195
    205                                               // SEC_DMM2_E0146_HHIFIX Removal of DMM2 from DMMs
    206                                               // ZJU_DEPTH_INTRA_MODE_E0204 Simplified Binarization for depth_intra_mode
    207                                               // SCU_HS_DMM4_REMOVE_DIV_E0242 DMM4 Division Removal
    208                                               // LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX 1   Removal of overlap between DMM3 and DMM1
    209                                               // SEC_DMM3_RBC_F0147 Removal of DMM3 and RBC from DMMs
    210                                               // HHI_DIM_PREDSAMP_FIX_F0171
    211                                               // QC_DIM_DELTADC_UNIFY_F0132 Unify delta DC coding in depth intra modes
    212                                               // LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135  Use only one context for CABAC of dim_not_present_flag
    213                                               // QC_SIMP_DELTADC_CODING_H0131   Simplify detaDC entropy coding
    214                                               // MTK_DMM_SIMP_CODE_H0092        Remove CABAC context for DMM1 mode coding
    215                                               // MTK_DELTA_DC_FLAG_ONE_CONTEXT_H0084_H0100_H0113 Use only one context for CABAC of delta_dc_flag as in JCTVC-H0084, JCTVC-H0100 and JCTVC-H0113
    216                                               // HS_DMM_SIGNALLING_I0120
    217                                               // SHARP_DMM1_I0110 LUT size reduction for DMM1 proposed in JCT3V-I0110
    218                                               // MTK_DMM_SIM_J0035
    219                                               // SHARP_DMM_CLEAN_K0042             1   // Generate DMM pattern with rotation
    220 #define NH_3D_DLT                         1   // Depth Lookup Table
    221                                               // HHI_DELTADC_DLT_D0035
    222                                               // LGE_PRED_RES_CODING_DLT_DOMAIN_F0159 JCT3V-F0159
    223                                               // SEC_NO_RESI_DLT_H0105
    224                                               // MTK_DLT_CODING_FIX_H0091
    225                                               // H_3D_DELTA_DLT
    226                                               // RWTH_DLT_CLIP_I0057
    227                                               // SHARP_DLT_SIMP_J0029 DLT(DepthValue2Idx[]) table derivation cleanup
    228 #define NH_3D_SDC_INTRA                   1   // Segment-wise DC Coding method for INTRA
    229 #define NH_3D_SDC_INTER                   1   // Segment-wise DC Coding method for INTER
    230                                               // RWTH_SDC_DLT_B0036
    231                                               // INTEL_SDC64_D0193
    232                                               // RWTH_SDC_CTX_SIMPL_D0032
    233                                               // FIX_SDC_ENC_RD_WVSO_D0163
    234                                               // MTK_SAMPLE_BASED_SDC_D0110
    235                                               // KWU_SDC_SIMPLE_DC_E0117 Simplified DC calculation for SDC
    236                                               // LGE_SDC_REMOVE_DC_E0158 Removal of DC mode from SDC
    237                                               // Unify intra SDC and inter SDC
    238                                               // QC_GENERIC_SDC_G0122 Generalize SDC to all depth intra modes
    239                                               // SCU_HS_DEPTH_DC_PRED_G0143
    240                                               // HS_TSINGHUA_SDC_SPLIT_G0111
    241                                               // QC_PKU_SDC_SPLIT_G0123 Intra SDC Split
    242                                               // HS_DMM_SDC_PREDICTOR_UNIFY_H0108  Unification of DMM and SDC predictor derivation
    243                                               // MTK_SDC_FLAG_FIX_H0095                          Remove conditional check of PCM flag based on SDC flag, JCTVC-H0095
    244                                               // FAST_SDC_OFFSET_DECISION_I0084
    245                                               // SEPARATE_FLAG_I0085
    246                                               // MTK_J0033
    247                                               // LGE_INTER_SDC_E0156 Enable inter SDC for depth coding
    248                                               // SEC_INTER_SDC_G0101 Improved inter SDC with multiple DC candidates
    249 #define NH_3D_SPIVMP                       1   // H_3D_SPIVMP JCT3V-F0110: Sub-PU level inter-view motion prediction
    250                                               // SEC_SPIVMP_MCP_SIZE_G0077, Apply SPIVMP only to 2Nx2N partition, JCT3V-G0077
    251                                               // QC_SPIVMP_MPI_G0119 Sub-PU level MPI merge candidate
    252                                               // Simplification on Sub-PU level temporal interview motion prediction
    253                                               // MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133
    254 #define NH_3D_DBBP                         1   // DBBP: Depth-based Block Partitioning and Merging
    255                                               // MTK_DBBP_AMP_REM_H0072
    256                                               // RWTH_DBBP_NO_SPU_H0057
    257                                               // SEC_DBBP_FILTERING_H0104
    258                                               // MTK_DBBP_SIGNALING_H0094
    259                                               // H_3D_FIX_DBBP_IVMP Fix . Enable IVMP is always disabled, when DBBP is enabled. The original intention is to disable Sub-PU IVMP when DBBP is enabled, not to disable IVMP itself.
    260                                               // SEC_DBBP_EXPLICIT_SIG_I0077 Remove the partition derivation and signal dbbp_flag only when the partition mode is 2NxN/Nx2N, JCT3V-I0077
    261                                               // Disallow DBBP in 8x8 CU, JCT3V-I0078
    262                                               // SHARP_DBBP_SIMPLE_FLTER_I0109 Simple condition and one dimensional filter for DBBP
    263                                               // SEC_DBBP_DMM4_THRESHOLD_I0076 Simplification of threshold derivation for DBBP and DMM4, JCT3V-I0076
    264                                               // SEC_DBBP_VIEW_REF_CHECK_J0037 Signaling dbbp_flag when the current slice has view reference picture(s), JCT3V-J0037 item4
    265                                               // RWTH_DBBP_NO_SATD_K0028
    266                                               // HS_DBBP_CLEAN_K0048
    267 #define NH_3D_DIS                         1   // Depth intra skip
    268                                               // SEC_DEPTH_INTRA_SKIP_MODE_K0033  Depth intra skip mode
    269 #define H_3D_FCO                          0   // Flexible coding order for 3D
    270 // OTHERS
    271                                               // MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 // Progressive MV Compression, JCT3V-E0170
    272                                               // MTK_FAST_TEXTURE_ENCODING_E0173
    273 //HLS
    274                                               // HHI_DEPENDENCY_SIGNALLING_I1_J0107
    275                                               // HHI_TOOL_PARAMETERS_I2_J0107
    276                                               // HHI_VPS_3D_EXTENSION_I3_J0107
    277                                               // HHI_INTER_COMP_PRED_K0052
    278                                               // HHI_RES_PRED_K0052
    279                                               // HHI_CAM_PARA_K0052
    280                                               // H_3D_DIRECT_DEP_TYPE
    281 #endif // NH_3D
    282 #if NH_MV
    28378////////////////////////
    28479/// Consider Removal
    28580////////////////////////
    286 // Rate Control
    287 #define KWU_FIX_URQ                       0
    288 #define KWU_RC_VIEWRC_E0227               0  ///< JCT3V-E0227, view-wise target bitrate allocation
    289 #define KWU_RC_MADPRED_E0227              0  ///< JCT3V-E0227, inter-view MAD prediction
    29081#define NH_MV_HLS_PTL_LIMITS               0
    291 #if NH_3D
    292 // Unclear Fix
    293 #define H_3D_PPS_FIX_DEPTH                     0
    294 #endif
    295 #endif
    296 /////////////////////////////////////////////////////////////////////////////////////////
    297 ///////////////////////////////////   DERIVED DEFINES ///////////////////////////////////
    298 /////////////////////////////////////////////////////////////////////////////////////////
    299 #if NH_3D
    300 #define NH_3D_OUTPUT_ACTIVE_TOOLS               0
    301 #define NH_3D_REN_MAX_DEV_OUT                   0
    302 #endif
    303 ///// ***** VIEW SYNTHESIS OPTIMIZAION *********
    304 #if NH_3D_VSO
    305 #define H_3D_VSO_DIST_INT                 1   // Allow negative synthesized view distortion change
    306 #define H_3D_VSO_COLOR_PLANES             1   // Compute VSO distortion on color planes
    307 #define H_3D_VSO_EARLY_SKIP               1   // LGE_VSO_EARLY_SKIP_A0093, A0093 modification 4
    308 #define H_3D_VSO_RM_ASSERTIONS            0   // Output VSO assertions
    309 #define H_3D_VSO_SYNTH_DIST_OUT           0   // Output of synthesized view distortion instead of depth distortion in encoder output
    310 #endif
    311 ////   ****** NEIGHBOURING BLOCK-BASED DISPARITY VECTOR  *********
    312 #if NH_3D_NBDV
    313 #define DVFROM_LEFT                       0
    314 #define DVFROM_ABOVE                      1
    315 #define IDV_CANDS                         2
    316 #endif
    317 /////////////////////////////////////////////////////////////////////////////////////
    318 /// GT: Move values which are not flags to CommonDef.h and convert to static int !!
    319 ///////////////////////////////////////////////////////////////////////////////////
    320 ///// ***** ILLUMATION COMPENSATION *********
    321 #if NH_3D_IC
    322 #define IC_REG_COST_SHIFT                 7
    323 #define IC_CONST_SHIFT                    5
    324 #define IC_SHIFT_DIFF                     12
    325 #define IC_LOW_LATENCY_ENCODING_THRESHOLD 0.1 // Threshold for low-latency IC encoding in JCT3V-H0086
    326 #endif
    327 ///// ***** DEPTH BASED BLOCK PARTITIONING *********
    328 #if NH_3D_DBBP
    329 #define DBBP_INVALID_SHORT                (-4)
    330 #endif
    331 /////////////////////////////////////////////////////////////////////////////////////////
    332 ///////////////////////////////////   HM RELATED DEFINES ////////////////////////////////
    333 /////////////////////////////////////////////////////////////////////////////////////////
    33482#endif
    33583// ====================================================================================================================
     
    493241typedef std::vector< BoolAry3d >   BoolAry4d;
    494242typedef std::vector< BoolAry4d >   BoolAry5d;
    495 #endif
    496 #if NH_3D_VSO
    497 // ====================================================================================================================
    498 // Define Distortion Types
    499 // ====================================================================================================================
    500 typedef       Int64           RMDist;     ///< renderer model distortion
    501 #if H_3D_VSO_DIST_INT
    502 typedef       Int64            Dist;       ///< RDO distortion
    503 typedef       Int64            Dist64;
    504 #define       RDO_DIST_MIN     MIN_INT
    505 #define       RDO_DIST_MAX     MAX_INT
    506 #else
    507 typedef       UInt             Dist;       ///< RDO distortion
    508 typedef       UInt64           Dist;
    509 #define       RDO_DIST_MIN     0
    510 #define       RDO_DIST_MAX     MAX_UINT
    511 #endif
    512243#endif
    513244// ====================================================================================================================
     
    645376  DF_HADS64          = 27,     ///<  64xM HAD with step
    646377  DF_HADS16N         = 28,     ///< 16NxM HAD with step
    647 #if NH_3D_VSO
    648   DF_VSD      = 29,      ///< general size VSD
    649   DF_VSD4     = 30,      ///<   4xM VSD
    650   DF_VSD8     = 31,      ///<   8xM VSD
    651   DF_VSD16    = 32,      ///<  16xM VSD
    652   DF_VSD32    = 33,      ///<  32xM VSD
    653   DF_VSD64    = 34,      ///<  64xM VSD
    654   DF_VSD16N   = 35,      ///< 16NxM VSD
    655 #endif
    656378  DF_SAD12           = 43,
    657379  DF_SAD24           = 44,
     
    683405  MD_ABOVE_LEFT         ///< MVP of above left block
    684406};
    685 #if NH_3D_MLC
    686 enum DefaultMergCandOrder
    687 {
    688   MRG_T = 0,            ///< MPI
    689   MRG_D,                ///< DDD
    690   MRG_IVMC,             ///< Temporal inter-view
    691   MRG_A1,               ///< Left
    692   MRG_B1,               ///< Above
    693   MRG_VSP,              ///< VSP
    694   MRG_B0,               ///< Above right
    695   MRG_IVDC,             ///< Disparity inter-view
    696   MRG_A0,               ///< Left bottom
    697   MRG_B2,               ///< Above left
    698   MRG_IVSHIFT,          ///< Shifted IVMC or Shifted IVDC. (These are mutually exclusive)
    699   MRG_COL               ///< Temporal co-located
    700 };
    701 #endif
    702407enum StoredResidualType
    703408{
     
    835540#if NH_MV
    836541    ,MULTIVIEWMAIN = 6,
    837 #if NH_3D
    838     MAIN3D = 8,
    839 #endif
    840542#endif
    841543  };
     
    990692};
    991693#endif
    992 #if NH_3D_VSO
    993 // Renderer
    994 enum BlenMod
    995 {
    996   BLEND_NONE  = -1,
    997   BLEND_AVRG  = 0,
    998   BLEND_LEFT  = 1,
    999   BLEND_RIGHT = 2,
    1000   BLEND_GEN   =  3
    1001 };
    1002 enum
    1003 {
    1004   VIEWPOS_INVALID = -1,
    1005   VIEWPOS_LEFT    = 0,
    1006   VIEWPOS_RIGHT   = 1,
    1007   VIEWPOS_MERGED  = 2
    1008 };
    1009 #endif
    1010694// ====================================================================================================================
    1011695// Type definition
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/SEIread.cpp

    r1386 r1390  
    381381      xParseSEIMultiviewViewPosition((SEIMultiviewViewPosition&) *sei, payloadSize, pDecodedMessageOutputStream );
    382382      break;
    383 #if NH_3D
    384     case SEI::ALTERNATIVE_DEPTH_INFO:
    385       sei = new SEIAlternativeDepthInfo;
    386       xParseSEIAlternativeDepthInfo((SEIAlternativeDepthInfo&) *sei, payloadSize, pDecodedMessageOutputStream );
    387       break;
    388 #endif
    389383#endif
    390384    default:
     
    17401734};
    17411735
    1742 #if NH_3D
    1743 Void SEIReader::xParseSEIAlternativeDepthInfo(SEIAlternativeDepthInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    1744 {
    1745   UInt code;
    1746   Int scode;
    1747   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    1748 
    1749   sei.resizeArrays( );
    1750   sei_read_flag( pDecodedMessageOutputStream, code, "alternative_depth_info_cancel_flag" ); sei.m_alternativeDepthInfoCancelFlag = (code == 1);
    1751   if( sei.m_alternativeDepthInfoCancelFlag  ==  0 )
    1752   {
    1753     sei_read_code( pDecodedMessageOutputStream, 2, code, "depth_type" ); sei.m_depthType = code;
    1754     if( sei.m_depthType  ==  0 )
    1755     {
    1756       sei_read_uvlc( pDecodedMessageOutputStream, code, "num_constituent_views_gvd_minus1" ); sei.m_numConstituentViewsGvdMinus1 = code;
    1757       sei_read_flag( pDecodedMessageOutputStream, code, "depth_present_gvd_flag" ); sei.m_depthPresentGvdFlag = (code == 1);
    1758       sei_read_flag( pDecodedMessageOutputStream, code, "z_gvd_flag" ); sei.m_zGvdFlag = (code == 1);
    1759       sei_read_flag( pDecodedMessageOutputStream, code, "intrinsic_param_gvd_flag" ); sei.m_intrinsicParamGvdFlag = (code == 1);
    1760       sei_read_flag( pDecodedMessageOutputStream, code, "rotation_gvd_flag" ); sei.m_rotationGvdFlag = (code == 1);
    1761       sei_read_flag( pDecodedMessageOutputStream, code, "translation_gvd_flag" ); sei.m_translationGvdFlag = (code == 1);
    1762       if( sei.m_zGvdFlag )
    1763       {
    1764         for( Int i = 0, j = 0; j <=  sei.m_numConstituentViewsGvdMinus1 + 1; j++ )
    1765         {
    1766           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_z_near_flag" ); sei.m_signGvdZNearFlag[i][j] = (code == 1);
    1767           sei_read_code( pDecodedMessageOutputStream, 7, code, "exp_gvd_z_near" ); sei.m_expGvdZNear[i][j] = code;
    1768           sei_read_code( pDecodedMessageOutputStream, 5, code, "man_len_gvd_z_near_minus1" ); sei.m_manLenGvdZNearMinus1[i][j] = code;
    1769           sei_read_code( pDecodedMessageOutputStream, sei.m_manLenGvdZNearMinus1[i][j]+1, code, "man_gvd_z_near" ); sei.m_manGvdZNear[i][j] = code;
    1770           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_z_far_flag" ); sei.m_signGvdZFarFlag[i][j] = (code == 1);
    1771           sei_read_code( pDecodedMessageOutputStream, 7, code, "exp_gvd_z_far" ); sei.m_expGvdZFar[i][j] = code;
    1772           sei_read_code( pDecodedMessageOutputStream, 5, code, "man_len_gvd_z_far_minus1" ); sei.m_manLenGvdZFarMinus1[i][j] = code;
    1773           sei_read_code( pDecodedMessageOutputStream, sei.m_manLenGvdZFarMinus1[i][j]+1, code, "man_gvd_z_far" ); sei.m_manGvdZFar[i][j] = code;
    1774         }
    1775       }
    1776       if( sei.m_intrinsicParamGvdFlag )
    1777       {
    1778         sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_gvd_focal_length" ); sei.m_precGvdFocalLength = code;
    1779         sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_gvd_principal_point" ); sei.m_precGvdPrincipalPoint = code;
    1780       }
    1781       if( sei.m_rotationGvdFlag )
    1782       {
    1783         sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_gvd_rotation_param" ); sei.m_precGvdRotationParam = code;
    1784       }
    1785       if( sei.m_translationGvdFlag )
    1786       {
    1787         sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_gvd_translation_param" ); sei.m_precGvdTranslationParam = code;
    1788       }
    1789       for( Int i = 0, j = 0; j <= sei.m_numConstituentViewsGvdMinus1 + 1; j++ )
    1790       {
    1791         if( sei.m_intrinsicParamGvdFlag )
    1792         {
    1793           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_focal_length_x" ); sei.m_signGvdFocalLengthX[i][j] = (code == 1);
    1794           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_focal_length_x" ); sei.m_expGvdFocalLengthX[i][j] = code;
    1795           sei_read_code( pDecodedMessageOutputStream, sei.getManGvdFocalLengthXLen(i,j), code, "man_gvd_focal_length_x" ); sei.m_manGvdFocalLengthX[i][j] = code;
    1796           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_focal_length_y" ); sei.m_signGvdFocalLengthY[i][j] = (code == 1);
    1797           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_focal_length_y" ); sei.m_expGvdFocalLengthY[i][j] = code;
    1798           sei_read_code( pDecodedMessageOutputStream, sei.getManGvdFocalLengthYLen(i,j), code, "man_gvd_focal_length_y" ); sei.m_manGvdFocalLengthY[i][j] = code;
    1799           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_principal_point_x" ); sei.m_signGvdPrincipalPointX[i][j] = (code == 1);
    1800           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_principal_point_x" ); sei.m_expGvdPrincipalPointX[i][j] = code;
    1801           sei_read_code( pDecodedMessageOutputStream, sei.getManGvdPrincipalPointXLen(i,j), code, "man_gvd_principal_point_x" ); sei.m_manGvdPrincipalPointX[i][j] = code;
    1802           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_principal_point_y" ); sei.m_signGvdPrincipalPointY[i][j] = (code == 1);
    1803           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_principal_point_y" ); sei.m_expGvdPrincipalPointY[i][j] = code;
    1804           sei_read_code( pDecodedMessageOutputStream, sei.getManGvdPrincipalPointYLen(i,j), code, "man_gvd_principal_point_y" ); sei.m_manGvdPrincipalPointY[i][j] = code;
    1805         }
    1806         if( sei.m_rotationGvdFlag )
    1807         {
    1808           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_r00" ); sei.m_signGvdR00[i][j] = (code == 1);
    1809           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_r00" ); sei.m_expGvdR00[i][j] = code;
    1810           sei_read_code( pDecodedMessageOutputStream, sei.m_precGvdRotationParam, code, "man_gvd_r00" ); sei.m_manGvdR00[i][j] = code;
    1811           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_r01" ); sei.m_signGvdR01[i][j] = (code == 1);
    1812           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_r01" ); sei.m_expGvdR01[i][j] = code;
    1813           sei_read_code( pDecodedMessageOutputStream, sei.m_precGvdRotationParam, code, "man_gvd_r01" ); sei.m_manGvdR01[i][j] = code;
    1814           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_r02" ); sei.m_signGvdR02[i][j] = (code == 1);
    1815           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_r02" ); sei.m_expGvdR02[i][j] = code;
    1816           sei_read_code( pDecodedMessageOutputStream, sei.m_precGvdRotationParam, code, "man_gvd_r02" ); sei.m_manGvdR02[i][j] = code;
    1817           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_r10" ); sei.m_signGvdR10[i][j] = (code == 1);
    1818           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_r10" ); sei.m_expGvdR10[i][j] = code;
    1819           sei_read_code( pDecodedMessageOutputStream, sei.m_precGvdRotationParam, code, "man_gvd_r10" ); sei.m_manGvdR10[i][j] = code;
    1820           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_r11" ); sei.m_signGvdR11[i][j] = (code == 1);
    1821           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_r11" ); sei.m_expGvdR11[i][j] = code;
    1822           sei_read_code( pDecodedMessageOutputStream, sei.m_precGvdRotationParam, code, "man_gvd_r11" ); sei.m_manGvdR11[i][j] = code;
    1823           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_r12" ); sei.m_signGvdR12[i][j] = (code == 1);
    1824           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_r12" ); sei.m_expGvdR12[i][j] = code;
    1825           sei_read_code( pDecodedMessageOutputStream, sei.m_precGvdRotationParam, code, "man_gvd_r12" ); sei.m_manGvdR12[i][j] = code;
    1826           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_r20" ); sei.m_signGvdR20[i][j] = (code == 1);
    1827           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_r20" ); sei.m_expGvdR20[i][j] = code;
    1828           sei_read_code( pDecodedMessageOutputStream, sei.m_precGvdRotationParam, code, "man_gvd_r20" ); sei.m_manGvdR20[i][j] = code;
    1829           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_r21" ); sei.m_signGvdR21[i][j] = (code == 1);
    1830           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_r21" ); sei.m_expGvdR21[i][j] = code;
    1831           sei_read_code( pDecodedMessageOutputStream, sei.m_precGvdRotationParam, code, "man_gvd_r21" ); sei.m_manGvdR21[i][j] = code;
    1832           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_r22" ); sei.m_signGvdR22[i][j] = (code == 1);
    1833           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_r22" ); sei.m_expGvdR22[i][j] = code;
    1834           sei_read_code( pDecodedMessageOutputStream, sei.m_precGvdRotationParam, code, "man_gvd_r22" ); sei.m_manGvdR22[i][j] = code;
    1835           //sei_read_code( pDecodedMessageOutputStream, sei.getManGvdRLen(i,j,k), code, "man_gvd_r" ); sei.m_manGvdR[i][j] = code;
    1836         }
    1837         if( sei.m_translationGvdFlag )
    1838         {
    1839           sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_t_x" ); sei.m_signGvdTX[i][j] = (code == 1);
    1840           sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_t_x" ); sei.m_expGvdTX[i][j] = code;
    1841           sei_read_code( pDecodedMessageOutputStream, sei.getManGvdTXLen(i,j), code, "man_gvd_t_x" ); sei.m_manGvdTX[i][j] = code;
    1842         }
    1843       }
    1844     }
    1845 
    1846     if( sei.m_depthType  ==  1 )
    1847     {
    1848       sei_read_svlc( pDecodedMessageOutputStream, scode, "min_offset_x_int" ); sei.m_minOffsetXInt = scode;
    1849       sei_read_code( pDecodedMessageOutputStream, 8, code, "min_offset_x_frac" ); sei.m_minOffsetXFrac = code;
    1850       sei_read_svlc( pDecodedMessageOutputStream, scode, "max_offset_x_int" ); sei.m_maxOffsetXInt = scode;
    1851       sei_read_code( pDecodedMessageOutputStream, 8, code, "max_offset_x_frac" ); sei.m_maxOffsetXFrac = code;
    1852       sei_read_flag( pDecodedMessageOutputStream, code, "offset_y_present_flag" ); sei.m_offsetYPresentFlag = (code == 1);
    1853       if( sei.m_offsetYPresentFlag )
    1854       {
    1855         sei_read_svlc( pDecodedMessageOutputStream, scode, "min_offset_y_int" ); sei.m_minOffsetYInt = scode;
    1856         sei_read_code( pDecodedMessageOutputStream, 8, code, "min_offset_y_frac" ); sei.m_minOffsetYFrac = code;
    1857         sei_read_svlc( pDecodedMessageOutputStream, scode, "max_offset_y_int" ); sei.m_maxOffsetYInt = scode;
    1858         sei_read_code( pDecodedMessageOutputStream, 8, code, "max_offset_y_frac" ); sei.m_maxOffsetYFrac = code;
    1859       }
    1860       sei_read_flag( pDecodedMessageOutputStream, code, "warp_map_size_present_flag" ); sei.m_warpMapSizePresentFlag = (code == 1);
    1861       if( sei.m_warpMapSizePresentFlag )
    1862       {
    1863         sei_read_uvlc( pDecodedMessageOutputStream, code, "warp_map_width_minus2" ); sei.m_warpMapWidthMinus2 = code;
    1864         sei_read_uvlc( pDecodedMessageOutputStream, code, "warp_map_height_minus2" ); sei.m_warpMapHeightMinus2 = code;
    1865       }
    1866     }
    1867   }
    1868 };
    18691736#endif
    1870 #endif
    18711737
    18721738//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/SEIread.h

    r1386 r1390  
    115115  Void xParseSEIMultiviewAcquisitionInfo      (SEIMultiviewAcquisitionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream);
    116116  Void xParseSEIMultiviewViewPosition         (SEIMultiviewViewPosition& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream);
    117 #if NH_3D
    118   Void xParseSEIAlternativeDepthInfo          (SEIAlternativeDepthInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream);
    119 #endif
    120117#endif
    121118  Void sei_read_code(std::ostream *pOS, UInt uiLength, UInt& ruiCode, const TChar *pSymbolName);
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r1386 r1390  
    436436    if ( pcPPS->getPps3dExtensionFlag() )
    437437    {
    438 #if NH_3D
    439       parsePps3dExtension( pcPPS );
    440 #endif
    441     }
    442 #if NH_3D
    443     if ( pcPPS->getPpsExtension5bits() )
    444 #else
     438    }
    445439    if ( pcPPS->getPpsExtension5bits() || pcPPS->getPps3dExtensionFlag() )
    446 #endif
    447440    {
    448441      while ( xMoreRbspData() )
     
    543536}
    544537
    545 #if NH_3D
    546 Void TDecCavlc::parsePps3dExtension( TComPPS* pcPPS )
    547 {
    548 #if NH_3D_DLT
    549   UInt uiCode = 0;
    550   //
    551   TComDLT* pcDLT = pcPPS->getDLT();
    552 
    553   READ_FLAG(uiCode, "dlts_present_flag");
    554   pcDLT->setDltPresentFlag( (uiCode == 1) ? true : false );
    555 
    556   if ( pcDLT->getDltPresentFlag() )
    557   {
    558     READ_CODE(6, uiCode, "pps_depth_layers_minus1");
    559     pcDLT->setNumDepthViews( uiCode+1 );
    560    
    561     READ_CODE(4, uiCode, "pps_bit_depth_for_depth_layers_minus8");
    562     pcDLT->setDepthViewBitDepth( (uiCode+8) );
    563    
    564     for( Int i = 0; i <= pcDLT->getNumDepthViews()-1; i++ )
    565     {
    566       Int layerId = pcDLT->getDepthIdxToLayerId(i);
    567      
    568       READ_FLAG(uiCode, "dlt_flag[i]");
    569       pcDLT->setUseDLTFlag(layerId, (uiCode == 1) ? true : false);
    570      
    571       if ( pcDLT->getUseDLTFlag( layerId ) )
    572       {
    573         Bool bDltBitMapRepFlag    = false;
    574         UInt uiMaxDiff            = MAX_INT;
    575         UInt uiMinDiff            = 0;
    576         UInt uiCodeLength         = 0;
    577        
    578         READ_FLAG(uiCode, "dlt_pred_flag[i]");
    579        
    580         if( uiCode )
    581         {
    582           assert( pcDLT->getUseDLTFlag( 1 ));
    583         }
    584         pcDLT->setInterViewDltPredEnableFlag( layerId, (uiCode == 1) ? true : false );
    585        
    586         if ( pcDLT->getInterViewDltPredEnableFlag( layerId ) == false )
    587         {
    588           READ_FLAG(uiCode, "dlt_val_flags_present_flag[i]");
    589           bDltBitMapRepFlag = (uiCode == 1) ? true : false;
    590         }
    591         else
    592         {
    593           bDltBitMapRepFlag = false;
    594         }
    595        
    596         UInt uiNumDepthValues = 0;
    597         std::vector<Int> aiIdx2DepthValue(256, 0);
    598        
    599         // Bit map
    600         if ( bDltBitMapRepFlag )
    601         {
    602           for (UInt d=0; d<256; d++)
    603           {
    604             READ_FLAG(uiCode, "dlt_value_flag[i][j]");
    605             if (uiCode == 1)
    606             {
    607               aiIdx2DepthValue[uiNumDepthValues] = d;
    608               uiNumDepthValues++;
    609             }
    610           }
    611         }
    612         // Diff Coding
    613         else
    614         {
    615           READ_CODE(8, uiNumDepthValues, "num_val_delta_dlt");   // num_entry
    616          
    617           {
    618             // The condition if( pcVPS->getNumDepthValues(i) > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component.
    619            
    620             if (uiNumDepthValues > 1)
    621             {
    622               READ_CODE(8, uiCode, "max_diff");
    623               uiMaxDiff = uiCode;
    624             }
    625             else
    626             {
    627               uiMaxDiff = 0;           // when there is only one value in DLT
    628             }
    629            
    630             if (uiNumDepthValues > 2)
    631             {
    632               uiCodeLength = (UInt) gCeilLog2(uiMaxDiff + 1);
    633               READ_CODE(uiCodeLength, uiCode, "min_diff_minus1");
    634               uiMinDiff = uiCode + 1;
    635             }
    636             else
    637             {
    638               uiMinDiff = uiMaxDiff;   // when there are only one or two values in DLT
    639             }
    640            
    641             READ_CODE(8, uiCode, "delta_dlt_val0");   // entry0
    642             aiIdx2DepthValue[0] = uiCode;
    643            
    644             if (uiMaxDiff == uiMinDiff)
    645             {
    646               for (UInt d=1; d<uiNumDepthValues; d++)
    647               {
    648                 aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + 0;
    649               }
    650             }
    651             else
    652             {
    653               uiCodeLength = (UInt) gCeilLog2(uiMaxDiff - uiMinDiff + 1);
    654               for (UInt d=1; d<uiNumDepthValues; d++)
    655               {
    656                 READ_CODE(uiCodeLength, uiCode, "delta_val_diff_minus_min[k]");
    657                 aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + uiCode;
    658               }
    659             }
    660            
    661           }
    662         }
    663        
    664         if( pcDLT->getInterViewDltPredEnableFlag( layerId ) )
    665         {
    666           // interpret decoded values as delta DLT
    667           AOF( layerId > 1 );
    668           // assumes ref layer id to be 1
    669           std::vector<Int> viRefDLT = pcDLT->idx2DepthValue( 1 );
    670           UInt uiRefNum = pcDLT->getNumDepthValues( 1 );
    671           pcDLT->setDeltaDLT(layerId, viRefDLT, uiRefNum, aiIdx2DepthValue, uiNumDepthValues);
    672         }
    673         else
    674         {
    675           // store final DLT
    676           pcDLT->setDepthLUTs(layerId, aiIdx2DepthValue, uiNumDepthValues);
    677         }
    678       }
    679     }
    680   }
    681 #endif
    682 }
    683 #endif
    684538
    685539
     
    11841038    if ( pcSPS->getSps3dExtensionFlag() )
    11851039    {
    1186 #if NH_3D
    1187       parseSps3dExtension( pcSPS );
    1188 #endif
    1189     }
    1190 
    1191 #if NH_3D
    1192     if ( pcSPS->getSpsExtension5bits() )
    1193 #else
     1040    }
     1041
    11941042    if ( pcSPS->getSpsExtension5bits() || pcSPS->getSps3dExtensionFlag() )
    1195 #endif
    11961043    {
    11971044      while ( xMoreRbspData() )
     
    12701117}
    12711118
    1272 #if NH_3D
    1273 Void TDecCavlc::parseSps3dExtension( TComSPS* pcSPS )
    1274 {
    1275   TComSps3dExtension sps3dExt;
    1276   UInt uiCode;
    1277   for( Int d = 0; d  <=  1; d++ )
    1278   {
    1279     READ_FLAG( uiCode, "iv_di_mc_enabled_flag" );              sps3dExt.setIvDiMcEnabledFlag( d, uiCode == 1 );
    1280     READ_FLAG( uiCode, "iv_mv_scal_enabled_flag" );            sps3dExt.setIvMvScalEnabledFlag( d, uiCode == 1 );
    1281     if( d  ==  0 )
    1282     {
    1283       READ_UVLC( uiCode, "log2_sub_pb_size_minus3" );          sps3dExt.setLog2IvmcSubPbSizeMinus3( d, uiCode );
    1284       READ_FLAG( uiCode, "iv_res_pred_enabled_flag" );         sps3dExt.setIvResPredEnabledFlag( d, uiCode == 1 );
    1285       READ_FLAG( uiCode, "depth_ref_enabled_flag" );           sps3dExt.setDepthRefEnabledFlag( d, uiCode == 1 );
    1286       READ_FLAG( uiCode, "vsp_mc_enabled_flag" );              sps3dExt.setVspMcEnabledFlag( d, uiCode == 1 );
    1287       READ_FLAG( uiCode, "dbbp_enabled_flag" );                sps3dExt.setDbbpEnabledFlag( d, uiCode == 1 );
    1288     }
    1289     else
    1290     {
    1291       READ_FLAG( uiCode, "tex_mc_enabled_flag" );              sps3dExt.setTexMcEnabledFlag( d, uiCode == 1 );
    1292       READ_UVLC( uiCode, "log2_texmc_sub_pb_size_minus3" );    sps3dExt.setLog2TexmcSubPbSizeMinus3( d, uiCode );
    1293       READ_FLAG( uiCode, "intra_contour_enabled_flag" );       sps3dExt.setIntraContourEnabledFlag( d, uiCode == 1 );
    1294       READ_FLAG( uiCode, "intra_dc_only_wedge_enabled_flag" ); sps3dExt.setIntraDcOnlyWedgeEnabledFlag( d, uiCode == 1 );
    1295       READ_FLAG( uiCode, "cqt_cu_part_pred_enabled_flag" );    sps3dExt.setCqtCuPartPredEnabledFlag( d, uiCode == 1 );
    1296       READ_FLAG( uiCode, "inter_dc_only_enabled_flag" );       sps3dExt.setInterDcOnlyEnabledFlag( d, uiCode == 1 );
    1297       READ_FLAG( uiCode, "skip_intra_enabled_flag" );          sps3dExt.setSkipIntraEnabledFlag( d, uiCode == 1 );
    1298     }
    1299   }
    1300   pcSPS->setSps3dExtension( sps3dExt );
    1301 }
    1302 #endif
    13031119
    13041120Void TDecCavlc::parsePpsMultilayerExtension(TComPPS* pcPPS)
     
    14821298    if (uiCode)
    14831299    {
    1484 #if NH_3D
    1485       READ_FLAG( uiCode,  "vps_3d_extension_flag" );
    1486       if ( uiCode )
    1487       {
    1488         m_pcBitstream->readOutTrailingBits();
    1489         pcVPS->createCamPars(pcVPS->getNumViews());
    1490         parseVps3dExtension( pcVPS );   
    1491       }
    1492       READ_FLAG( uiCode,  "vps_extension3_flag" );
    1493       if (uiCode)
    1494       {     
    1495 #endif
    14961300#endif 
    14971301        while ( xMoreRbspData() )
     
    15001304        }
    15011305#if NH_MV
    1502 #if NH_3D
    1503       }
    1504 #endif
    15051306    }
    15061307#endif
     
    15871388  }
    15881389
    1589 #if NH_3D
    1590   pcVPS->initViewCompLayer( );
    1591 #endif
    15921390
    15931391  for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
     
    21781976}
    21791977
    2180 #if NH_3D
    2181 Void TDecCavlc::parseVps3dExtension( TComVPS* pcVPS )
    2182 {
    2183   UInt uiCode;   
    2184   READ_UVLC( uiCode, "cp_precision"); pcVPS->setCpPrecision( uiCode ) ;
    2185  
    2186   for (Int n = 1; n < pcVPS->getNumViews(); n++)
    2187   {
    2188     Int i      = pcVPS->getViewOIdxList( n );
    2189     Int iInVps = pcVPS->getVoiInVps( i );
    2190     READ_CODE( 6, uiCode, "num_cp" ); pcVPS->setNumCp( iInVps, uiCode );
    2191 
    2192     if( pcVPS->getNumCp( iInVps ) > 0 )
    2193     {
    2194       READ_FLAG( uiCode, "cp_in_slice_segment_header_flag" ); pcVPS->setCpInSliceSegmentHeaderFlag( iInVps, uiCode == 1 );
    2195       for( Int m = 0; m < pcVPS->getNumCp( iInVps ); m++ )
    2196       {
    2197         READ_UVLC( uiCode, "cp_ref_voi" ); pcVPS->setCpRefVoi( iInVps, m, uiCode );
    2198         if( !pcVPS->getCpInSliceSegmentHeaderFlag( iInVps ) )
    2199         {
    2200           Int j      = pcVPS->getCpRefVoi( iInVps, m );
    2201           Int jInVps = pcVPS->getVoiInVps( j );
    2202           Int iCode;
    2203           READ_SVLC( iCode, "vps_cp_scale" );                pcVPS->setVpsCpScale   ( iInVps, jInVps, iCode );
    2204           READ_SVLC( iCode, "vps_cp_off" );                  pcVPS->setVpsCpOff     ( iInVps, jInVps, iCode );
    2205           READ_SVLC( iCode, "vps_cp_inv_scale_plus_scale" ); pcVPS->setVpsCpInvScale( iInVps, jInVps, iCode - pcVPS->getVpsCpScale( iInVps, jInVps ) );
    2206           READ_SVLC( iCode, "vps_cp_inv_off_plus_off" );     pcVPS->setVpsCpInvOff  ( iInVps, jInVps, iCode - pcVPS->getVpsCpOff  ( iInVps, jInVps ) );
    2207         }
    2208       }
    2209     }   
    2210   }
    2211   pcVPS->deriveCpPresentFlag();
    2212 }
    2213 #endif
    22141978#endif
    22151979
     
    23042068  pcSlice->setViewId   ( vps->getViewId   ( pcSlice->getLayerId() )      );
    23052069  pcSlice->setViewIndex( vps->getViewIndex( pcSlice->getLayerId() )      ); 
    2306 #if NH_3D
    2307   pcSlice->setIsDepth  ( vps->getDepthId  ( pcSlice->getLayerId() ) == 1 );
    2308 #endif
    23092070#endif
    23102071
     
    26222383    Bool interLayerPredLayerIdcPresentFlag = false;
    26232384    Int layerId       = pcSlice->getLayerId();
    2624 #if NH_3D
    2625     if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumRefListLayers( layerId ) > 0 )
    2626 #else
    26272385    if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 )
    2628 #endif
    26292386    {   
    26302387      READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); pcSlice->setInterLayerPredEnabledFlag( uiCode == 1 );
    2631 #if NH_3D
    2632       if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumRefListLayers( layerId ) > 1 )
    2633 #else
    26342388      if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 )
    2635 #endif
    26362389      {           
    26372390        if( !vps->getMaxOneActiveRefLayerFlag()) 
     
    26392392          READ_CODE( pcSlice->getNumInterLayerRefPicsMinus1Len( ), uiCode, "num_inter_layer_ref_pics_minus1" ); pcSlice->setNumInterLayerRefPicsMinus1( uiCode );
    26402393        }
    2641 #if NH_3D
    2642         if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumRefListLayers( layerId ) )
    2643 #else
    26442394        if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) )
    2645 #endif
    26462395        {
    26472396          interLayerPredLayerIdcPresentFlag = true;
     
    26602409      }
    26612410    }
    2662 #if NH_3D
    2663     if ( getDecTop()->decProcAnnexI() )
    2664     {   
    2665       pcSlice->deriveInCmpPredAndCpAvailFlag( );
    2666       if ( pcSlice->getInCmpPredAvailFlag() )
    2667       {
    2668         READ_FLAG(uiCode, "in_comp_pred_flag");  pcSlice->setInCompPredFlag((Bool)uiCode);     
    2669       }
    2670       pcSlice->init3dToolParameters();
    2671     }
    2672 #endif
    26732411#endif
    26742412    if(sps->getUseSAO())
     
    28772615    }
    28782616
    2879 #if NH_3D_IC
    2880     else if(    pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE )
    2881              && !pcSlice->getIsDepth() && vps->getNumRefListLayers( layerId ) > 0
    2882              && getDecTop()->decProcAnnexI()
    2883            )
    2884     {
    2885       UInt uiCodeTmp = 0;
    2886 
    2887       READ_FLAG ( uiCodeTmp, "slice_ic_enable_flag" );
    2888       pcSlice->setApplyIC( uiCodeTmp );
    2889 
    2890       if ( uiCodeTmp )
    2891       {
    2892         READ_FLAG ( uiCodeTmp, "slice_ic_disabled_merge_zero_idx_flag" );
    2893         pcSlice->setIcSkipParseFlag( uiCodeTmp );
    2894       }
    2895     }
    2896 #endif
    28972617
    28982618    if (!pcSlice->isIntra())
    28992619    {
    29002620      READ_UVLC( uiCode, "five_minus_max_num_merge_cand");
    2901 #if NH_3D_IV_MERGE
    2902       pcSlice->setMaxNumMergeCand(( ( pcSlice->getMpiFlag() || pcSlice->getIvMvPredFlag() || pcSlice->getViewSynthesisPredFlag() ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode);
    2903 #else
    29042621      pcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode);
    2905 #endif
    29062622    }
    29072623
     
    29942710    pcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false);
    29952711
    2996 #if NH_3D
    2997     if ( getDecTop()->decProcAnnexI() )
    2998     {
    2999       Int voiInVps = vps->getVoiInVps( pcSlice->getViewIndex() );
    3000       if( vps->getCpInSliceSegmentHeaderFlag( voiInVps ) )
    3001       {
    3002         for( Int m = 0; m < vps->getNumCp( voiInVps ); m++ )
    3003         {
    3004           Int jInVps = vps->getVoiInVps( vps->getCpRefVoi( voiInVps, m ));
    3005           READ_SVLC( iCode, "cp_scale" );                pcSlice->setCpScale   ( jInVps, iCode );
    3006           READ_SVLC( iCode, "cp_off" );                  pcSlice->setCpOff     ( jInVps, iCode );
    3007           READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); pcSlice->setCpInvScale( jInVps, iCode - pcSlice->getCpScale   ( jInVps ));
    3008           READ_SVLC( iCode, "cp_inv_off_plus_off" );     pcSlice->setCpInvOff  ( jInVps, iCode - pcSlice->getCpOff     ( jInVps ));
    3009         }
    3010       }
    3011     }
    3012 #endif
    30132712
    30142713  }
     
    33513050}
    33523051
    3353 #if NH_3D_DIS
    3354 Void TDecCavlc::parseDIS( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
    3355 {
    3356   assert(0);
    3357 }
    3358 #endif
    33593052
    33603053Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
     
    34933186}
    34943187
    3495 #if NH_3D_ARP
    3496 Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    3497 {
    3498   assert(0);
    3499 }
    3500 #endif
    3501 #if NH_3D_IC
    3502 Void TDecCavlc::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    3503 {
    3504   assert(0);
    3505 }
    3506 #endif
    3507 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    3508 Void TDecCavlc::parseSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    3509 {
    3510   assert(0);
    3511 }
    3512 
    3513 #endif
    3514 #if NH_3D_DBBP
    3515   Void TDecCavlc::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    3516   {
    3517     assert(0);
    3518   }
    3519 #endif
    35203188// ====================================================================================================================
    35213189// Protected member functions
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/TDecCAVLC.h

    r1321 r1390  
    9494  Void  setDecTop           ( TDecTop* decTop ) { m_decTop = decTop; };
    9595#endif
    96 #if NH_3D
    97   Void  parseVps3dExtension  ( TComVPS* pcVPS );
    98   Void  parseSps3dExtension  ( TComSPS* pcSPS ); 
    99   Void  parsePps3dExtension  ( TComPPS* pcPPS );
    100 #endif
    10196
    10297  Void  parseSPS            ( TComSPS* pcSPS );
     
    121116       
    122117  Void  parseSkipFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    123 #if NH_3D_DIS
    124   Void  parseDIS             ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    125 #endif
    126118  Void parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    127119  Void parseMergeFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
    128120  Void parseMergeIndex      ( TComDataCU* pcCU, UInt& ruiMergeIndex );
    129 #if NH_3D_ARP
    130   Void parseARPW            ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    131 #endif
    132 #if NH_3D_IC
    133   Void  parseICFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    134 #endif
    135 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    136   Void  parseDeltaDC        ( TComDataCU* /*pcCU*/, UInt /*absPartIdx*/, UInt /*depth*/ ) { assert(0); };
    137 #endif
    138 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    139   Void  parseSDCFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    140 #endif
    141 #if NH_3D_DBBP
    142   Void  parseDBBPFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    143 #endif
    144121  Void parseSplitFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    145122  Void parsePartSize        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/TDecCu.cpp

    r1386 r1390  
    5252  m_ppcYuvReco = NULL;
    5353  m_ppcCU      = NULL;
    54 #if NH_3D_DBBP
    55   m_ppcYuvRecoDBBP = NULL;
    56 #endif
    5754}
    5855
     
    8178  m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
    8279  m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
    83 #if NH_3D_DBBP
    84   m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1];
    85 #endif
    8680
    8781  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
     
    10296    m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight, chromaFormatIDC );
    10397    m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( chromaFormatIDC, uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
    104 #if NH_3D_DBBP
    105     m_ppcYuvRecoDBBP[ui] = new TComYuv;    m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight, chromaFormatIDC );
    106 #endif
    10798}
    10899
     
    126117    m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
    127118    m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
    128 #if NH_3D_DBBP
    129     m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL;
    130 #endif
    131119  }
    132120
     
    134122  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
    135123  delete [] m_ppcCU     ; m_ppcCU      = NULL;
    136 #if NH_3D_DBBP
    137   delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL;
    138 #endif
    139124}
    140125
     
    170155Void TDecCu::decompressCtu( TComDataCU* pCtu )
    171156{
    172 #if !NH_3D_IV_MERGE
    173157  xDecompressCU( pCtu, 0,  0 );
    174 #endif
    175158}
    176159
     
    290273    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
    291274  }
    292 #if NH_3D_NBDV
    293   DisInfo DvInfo;
    294   DvInfo.m_acNBDV.setZero();
    295   DvInfo.m_aVIdxCan = 0;
    296 #if NH_3D_NBDV_REF 
    297   DvInfo.m_acDoNBDV.setZero();
    298 #endif
    299  
    300 if(!pcCU->getSlice()->isIntra())
    301   {
    302 #if NH_3D_ARP && NH_3D_IV_MERGE && NH_3D_VSP
    303     if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
    304 #else
    305 #if NH_3D_IV_MERGE && NH_3D_VSP
    306     if( pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
    307 #else
    308 #if NH_3D_ARP && NH_3D_VSP
    309     if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
    310 #else
    311 #if NH_3D_VSP
    312     if( pcCU->getSlice()->getViewSynthesisPredFlag() )
    313 #else
    314 #if H_3D_ARP
    315     if( pcCU->getSlice()->getIvResPredFlag( ) )
    316 #else
    317 #if H_3D_IV_MERGE
    318     if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) )
    319 #else
    320 #if NH_3D_DBBP
    321     if( pcCU->getSlice()->getDepthBasedBlkPartFlag() )
    322 #else
    323     if (0)
    324 #endif
    325 #endif
    326 #endif
    327 #endif
    328 #endif
    329 #endif
    330 #endif
    331     {
    332       m_ppcCU[uiDepth]->copyInterPredInfoFrom(pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true);
    333       m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
    334       PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0);
    335       UChar cWidTemp     = m_ppcCU[uiDepth]->getWidth(0);
    336       UChar cHeightTemp  = m_ppcCU[uiDepth]->getHeight(0);
    337       m_ppcCU[uiDepth]->setWidth (0, pcCU->getSlice()->getSPS()->getMaxCUWidth () / (1 << uiDepth));
    338       m_ppcCU[uiDepth]->setHeight(0, pcCU->getSlice()->getSPS()->getMaxCUHeight() / (1 << uiDepth));
    339       m_ppcCU[uiDepth]->setPartSizeSubParts(SIZE_2Nx2N, 0, uiDepth);     
    340 #if NH_3D_IV_MERGE
    341       if( pcCU->getSlice()->getIsDepth())
    342       {
    343         m_ppcCU[uiDepth]->getDispforDepth(0, 0, &DvInfo);
    344       }
    345       else
    346       {
    347 #endif
    348 #if NH_3D_NBDV_REF
    349       if( pcCU->getSlice()->getDepthBasedBlkPartFlag() )  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
    350       {
    351         m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true);
    352       }
    353       else
    354 #endif
    355       {
    356         m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
    357       }
    358 #if NH_3D_IV_MERGE
    359       }
    360 #endif
    361 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC   
    362       if ( g_decTraceDispDer )
    363       {
    364         DTRACE_CU( "RefViewIdx",  DvInfo.m_aVIdxCan );       
    365         DTRACE_CU( "MvDisp[x]", DvInfo.m_acNBDV.getHor() );
    366         DTRACE_CU( "MvDisp[y]", DvInfo.m_acNBDV.getVer() );
    367         DTRACE_CU( "MvRefinedDisp[x]", DvInfo.m_acDoNBDV.getHor() );
    368         DTRACE_CU( "MvRefinedDisp[y]", DvInfo.m_acDoNBDV.getVer() );
    369       }
    370 #endif
    371       pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
    372       m_ppcCU[uiDepth]->setPartSizeSubParts(ePartTemp, 0, uiDepth);
    373       m_ppcCU[uiDepth]->setWidth(0, cWidTemp);
    374       m_ppcCU[uiDepth]->setHeight(0, cHeightTemp);
    375      }
    376   }
    377 #endif
    378275
    379276  if( uiDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() )
     
    403300    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
    404301    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
    405 #if NH_3D_IV_MERGE
    406     m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
    407     TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    408     UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
    409 #else
    410 #if NH_3D_MLC
    411     TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    412     UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
    413 #else
    414302    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
    415303    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    416 #endif
    417 #endif
    418304    Int numValidMergeCand = 0;
    419305    for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
     
    423309    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
    424310    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
    425 #if NH_3D_ARP
    426     m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
    427 #endif
    428 #if NH_3D_IC
    429     m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
    430 #endif
    431 
    432 
    433 #if NH_3D_VSP
    434     Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    435     memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    436 #endif
    437 #if NH_3D_SPIVMP
    438     Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
    439     memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    440     TComMvField*  pcMvFieldSP;
    441     UChar* puhInterDirSP;
    442     pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2];
    443     puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()];
    444 #endif
    445 
    446 #if NH_3D_MLC
    447     m_ppcCU[uiDepth]->initAvailableFlags();
    448 #endif
     311
     312
     313
    449314    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    450 #if NH_3D_MLC
    451     m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
    452 #if NH_3D_SPIVMP
    453       , pcMvFieldSP, puhInterDirSP
    454 #endif
    455       , numValidMergeCand, uiMergeIndex );
    456 
    457     m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
    458 #if NH_3D_VSP
    459       , vspFlag
    460 #endif
    461 #if NH_3D_SPIVMP
    462       , bSPIVMPFlag
    463 #endif
    464       , numValidMergeCand );
    465 #endif
    466 #if NH_3D_VSP
    467     pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
    468 #endif
    469315
    470316    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
     
    479325        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
    480326        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
    481 #if NH_3D_VSP
    482         if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 )
    483         {
    484           if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
    485           {
    486             UInt dummy;
    487             Int vspSize;
    488             Int width, height;
    489             m_ppcCU[uiDepth]->getPartIndexAndSize( uiAbsPartIdx, dummy, width, height );
    490             m_ppcCU[uiDepth]->setMvFieldPUForVSP( pcCU, uiAbsPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
    491             pcCU->setVSPFlag( uiAbsPartIdx, vspSize );
    492           }
    493         }
    494 #endif
    495327#if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC   
    496328        if ( g_decTraceMvFromMerge )
     
    512344      }
    513345    }
    514 #if NH_3D_SPIVMP
    515     pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
    516     if (bSPIVMPFlag[uiMergeIndex])
    517     {
    518       UInt uiSPAddr;
    519       Int iWidth = pcCU->getWidth(uiAbsPartIdx);
    520       Int iHeight = pcCU->getHeight(uiAbsPartIdx);
    521 
    522       Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    523 
    524       pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    525 
    526       for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    527       {
    528         pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
    529         pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
    530         pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
    531         pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
    532       }
    533 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC
    534       if ( g_traceSubPBMotion )
    535       {
    536         std::cout << std::setfill(' ')                          << std::setw( 15 )
    537           << "Num"                                              << std::setw( 15 )
    538           << "Dir "                                             << std::setw( 15 )
    539           <<  "L0 RefIdx"                                       << std::setw( 15 )
    540           <<  "L0 Hor"                                          << std::setw( 15 )
    541           <<  "L0 Ver"                                          << std::setw( 15 )
    542           <<  "L1 RefIdx"                                       << std::setw( 15 )
    543           <<  "L1 Hor"                                          << std::setw( 15 )
    544           <<  "L1 Ver"                                          << std::setw( 15 )
    545           << std::endl;
    546 
    547         for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    548         {
    549           UChar        dir = puhInterDirSP[iPartitionIdx];
    550           TComMvField& mv0 = pcMvFieldSP  [2*iPartitionIdx];
    551           TComMvField& mv1 = pcMvFieldSP  [2*iPartitionIdx+1];
    552 
    553           std::cout << std::setfill(' ')                                  << std::setw( 15 )
    554             << iPartitionIdx                                              << std::setw( 15 )
    555             << (UInt) dir                                                 << std::setw( 15 )
    556             << ((dir & 1) ? mv0.getRefIdx()       : MIN_INT)              << std::setw( 15 )
    557             << ((dir & 1) ? mv0.getMv().getHor()  : MIN_INT)              << std::setw( 15 )
    558             << ((dir & 1) ? mv0.getMv().getVer()  : MIN_INT)              << std::setw( 15 )
    559             << ((dir & 2) ? mv1.getRefIdx()       : MIN_INT)              << std::setw( 15 )
    560             << ((dir & 2) ? mv1.getMv().getHor()  : MIN_INT)              << std::setw( 15 )
    561             << ((dir & 2) ? mv1.getMv().getVer()  : MIN_INT)              << std::setw( 15 )
    562             << std::endl;
    563         }
    564       }
    565 #endif
    566     }
    567     delete[] pcMvFieldSP;
    568     delete[] puhInterDirSP;
    569 #endif
    570346
    571347    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
    572 #if NH_3D_IV_MERGE
    573     xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
    574 #endif
    575348
    576349    return;
    577350  }
    578 #if NH_3D_DIS
    579   m_pcEntropyDecoder->decodeDIS( pcCU, uiAbsPartIdx, uiDepth );
    580   if(!pcCU->getDISFlag(uiAbsPartIdx))
    581   {
    582 #endif
    583351
    584352  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
     
    591359    if(pcCU->getIPCMFlag(uiAbsPartIdx))
    592360    {
    593 #if NH_3D_SDC_INTRA
    594       m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
    595 #endif
    596361      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
    597 #if NH_3D_IV_MERGE
    598       xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
    599 #endif
    600362      return;
    601363    }
     
    611373  setIsChromaQpAdjCoded( isChromaQpAdjCoded );
    612374  setdQPFlag( bCodeDQP );
    613 #if NH_3D_DIS
    614   }
    615 #endif
    616375  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
    617 #if NH_3D_IV_MERGE
    618   xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
    619 #endif
    620376}
    621377
     
    638394{
    639395  TComPic* pcPic = pCtu->getPic();
    640 #if !NH_3D_IV_MERGE
    641396  TComSlice * pcSlice = pCtu->getSlice();
    642397  const TComSPS &sps=*(pcSlice->getSPS());
     
    672427    return;
    673428  }
    674 #endif
    675429  // Residual reconstruction
    676430  m_ppcYuvResi[uiDepth]->clear();
     
    681435  {
    682436    case MODE_INTER:
    683 #if NH_3D_DBBP
    684     if( m_ppcCU[uiDepth]->getDBBPFlag(0) )
    685     {
    686       xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
    687     }
    688     else
    689     {
    690 #endif
    691 #if NH_3D_SDC_INTER
    692       if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) )
    693       {
    694         xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
    695       }
    696       else
    697       {
    698 #endif
    699437      xReconInter( m_ppcCU[uiDepth], uiDepth );
    700 #if NH_3D_SDC_INTER
    701       }
    702 #endif
    703 #if NH_3D_DBBP
    704     }
    705 #endif
    706438      break;
    707439    case MODE_INTRA:
    708 #if NH_3D
    709 #if NH_3D_DIS
    710     if( m_ppcCU[uiDepth]->getDISFlag(0) )
    711     {
    712       xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
    713     }
    714 #else
    715     if(false )
    716     {
    717      // xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
    718     }
    719 #endif
    720 #if NH_3D_SDC_INTRA
    721     else if( m_ppcCU[uiDepth]->getSDCFlag(0) )
    722     {
    723       xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
    724     }
    725 #endif
    726     else
    727 #endif
    728440      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
    729441      break;
     
    794506}
    795507
    796 #if NH_3D_DIS
    797 Void TDecCu::xReconDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    798 {
    799   UInt uiWidth        = pcCU->getWidth  ( 0 );
    800   UInt uiHeight       = pcCU->getHeight ( 0 );
    801 
    802   TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
    803 
    804   UInt    uiStride    = pcRecoYuv->getStride  (COMPONENT_Y);
    805   Pel*    piReco      = pcRecoYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
    806 
    807 
    808   AOF( uiWidth == uiHeight );
    809   AOF( uiAbsPartIdx == 0 );
    810  
    811   TComTURecurse rTu(pcCU, 0);
    812   const ChromaFormat chFmt     = rTu.GetChromaFormat();
    813 
    814   DEBUG_STRING_NEW(sTemp)
    815   if ( pcCU->getDISType(uiAbsPartIdx) == 0 )
    816   {
    817     const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, VER_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
    818     m_pcPrediction->initIntraPatternChType( rTu, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
    819     m_pcPrediction->predIntraAng( COMPONENT_Y,   VER_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bUseFilteredPredictions );
    820   }
    821   else if ( pcCU->getDISType(uiAbsPartIdx) == 1 )
    822   {
    823     const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, HOR_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
    824     m_pcPrediction->initIntraPatternChType( rTu, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
    825     m_pcPrediction->predIntraAng( COMPONENT_Y,   HOR_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bUseFilteredPredictions );
    826   }
    827   else if ( pcCU->getDISType(uiAbsPartIdx) == 2 )
    828   {
    829     Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
    830     pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 0 );
    831     for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    832     {
    833       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    834       {
    835         piReco[ uiX ] = pSingleDepth;
    836       }
    837       piReco+= uiStride;
    838     }
    839   }
    840   else if ( pcCU->getDISType(uiAbsPartIdx) == 3 )
    841   {
    842     Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
    843     pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 1 );
    844     for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    845     {
    846       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    847       {
    848         piReco[ uiX ] = pSingleDepth;
    849       }
    850       piReco+= uiStride;
    851     }
    852   }
    853 
    854   // clear UV
    855   UInt  uiStrideC     = pcRecoYuv->getStride(COMPONENT_Cb);
    856   Pel   *pRecCb       = pcRecoYuv->getAddr(COMPONENT_Cb);
    857   Pel   *pRecCr       = pcRecoYuv->getAddr(COMPONENT_Cr);
    858 
    859   for (Int y=0; y<uiHeight/2; y++)
    860   {
    861     for (Int x=0; x<uiWidth/2; x++)
    862     {
    863       pRecCb[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
    864       pRecCr[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
    865     }
    866 
    867     pRecCb += uiStrideC;
    868     pRecCr += uiStrideC;
    869   }
    870 }
    871 #endif
    872 #if NH_3D_SDC_INTER
    873 Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    874 {
    875   // inter prediction
    876   m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
    877 
    878   UInt  uiWidth      = pcCU->getWidth ( 0 );
    879   UInt  uiHeight     = pcCU->getHeight( 0 );
    880 
    881   Pel  *pResi;
    882   UInt uiPelX, uiPelY;
    883   UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride( COMPONENT_Y );
    884   Int  bitDepthC = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA);
    885 
    886   pResi = m_ppcYuvResi[uiDepth]->getAddr( COMPONENT_Y );
    887   for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
    888   {
    889     for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
    890     {
    891       pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 );
    892     }
    893     pResi += uiResiStride;
    894   }
    895 
    896   m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
    897 
    898   // clear UV
    899   UInt  uiStrideC     = m_ppcYuvReco[uiDepth]->getStride( COMPONENT_Cb );
    900   Pel   *pRecCb       = m_ppcYuvReco[uiDepth]->getAddr( COMPONENT_Cb );
    901   Pel   *pRecCr       = m_ppcYuvReco[uiDepth]->getAddr( COMPONENT_Cr );
    902 
    903   for (Int y = 0; y < uiHeight/2; y++)
    904   {
    905     for (Int x = 0; x < uiWidth/2; x++)
    906     {
    907       pRecCb[x] = (Pel)( 1 << ( bitDepthC - 1 ) );
    908       pRecCr[x] = (Pel)( 1 << ( bitDepthC - 1 ) );
    909     }
    910 
    911     pRecCb += uiStrideC;
    912     pRecCr += uiStrideC;
    913   }
    914 }
    915 #endif
    916 
    917 #if NH_3D_DBBP
    918 Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    919 {
    920   AOF(!pcCU->getSlice()->getIsDepth());
    921   AOF(!pcCU->getSlice()->isIntra());
    922   PartSize ePartSize = pcCU->getPartitionSize( 0 );
    923  
    924   Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
    925  
    926   // get collocated depth block
    927   UInt uiDepthStride = 0;
    928 #if H_3D_FCO
    929   Pel* pDepthPels = pcCU->getVirtualDepthBlock(pcCU->getZorderIdxInCU(), pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
    930 #else
    931   Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
    932 #endif
    933   AOF( pDepthPels != NULL );
    934   AOF( uiDepthStride != 0 );
    935  
    936   // compute mask by segmenting depth block
    937   Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE];
    938   Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask, pcCU);
    939   AOF(bValidMask);
    940  
    941   DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
    942   TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] };
    943  
    944   // first, extract the two sets of motion parameters
    945   UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
    946   for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
    947   {
    948     UInt uiPartAddr = uiSegment*uiPUOffset;
    949    
    950     pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr);
    951     assert( pDBBPTmpData->auhInterDir[uiSegment] == 1 || pDBBPTmpData->auhInterDir[uiSegment] == 2  );  // only uni-prediction allowed
    952    
    953     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    954     {
    955       RefPicList eRefList = (RefPicList)uiRefListIdx;
    956       pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]);
    957     }
    958    
    959 #if NH_3D
    960     AOF( pcCU->getARPW(uiPartAddr) == 0 );
    961     AOF( pcCU->getICFlag(uiPartAddr) == false );
    962     AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false );
    963     AOF( pcCU->getVSPFlag(uiPartAddr) == 0 );
    964 #endif
    965   }
    966  
    967   // do motion compensation for each segment as 2Nx2N
    968   pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
    969   pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
    970   for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
    971   {
    972     pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth );
    973  
    974     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    975     {
    976       RefPicList eRefList = (RefPicList)uiRefListIdx;
    977 
    978       pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 );
    979     }
    980    
    981     // inter prediction
    982     m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] );
    983   }
    984  
    985   // restore motion information in both segments again
    986   pcCU->setPartSizeSubParts( ePartSize,  0, uiDepth );
    987   pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
    988   for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
    989   {
    990     UInt uiPartAddr = uiSegment*uiPUOffset;
    991    
    992     pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth);
    993     pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level
    994    
    995     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    996     {
    997       RefPicList eRefList = (RefPicList)uiRefListIdx;
    998 
    999       pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level
    1000     }
    1001   }
    1002  
    1003   // reconstruct final prediction signal by combining both segments
    1004   m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize, bitDepthY);
    1005 
    1006   // inter recon
    1007   xDecodeInterTexture( pcCU, uiDepth );
    1008  
    1009   // clip for only non-zero cbp case
    1010   if  ( ( pcCU->getCbf( 0, COMPONENT_Y ) ) || ( pcCU->getCbf( 0, COMPONENT_Cb ) ) || ( pcCU->getCbf(0, COMPONENT_Cr ) ) )
    1011   {
    1012     m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
    1013   }
    1014   else
    1015   {
    1016     m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
    1017   }
    1018 }
    1019 #endif
     508
    1020509
    1021510
     
    1081570
    1082571  //===== get prediction signal =====
    1083 #if NH_3D_DMM
    1084   if( bIsLuma && isDmmMode( uiChFinalMode ) )
    1085   {
    1086     m_pcPrediction->predIntraLumaDmm( pcCU, uiAbsPartIdx, getDmmType( uiChFinalMode ), piPred, uiStride, uiWidth, uiHeight );
    1087   }
    1088   else
    1089   {
    1090 #endif
    1091572  m_pcPrediction->predIntraAng( compID,   uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bUseFilteredPredictions );
    1092 #if NH_3D_DMM
    1093   }
    1094 #endif
    1095573
    1096574#if DEBUG_STRING
     
    1110588  std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0;
    1111589#endif
    1112 #if H_3D
    1113   Bool useDltFlag = (isDmmMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps());
    1114 
    1115   if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag )
    1116 #else
    1117590  if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0)
    1118 #endif
    1119591  {
    1120592    m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) );
     
    1255727}
    1256728
    1257 #if NH_3D_SDC_INTRA
    1258 Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    1259 {
    1260   TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
    1261   TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
    1262   TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
    1263 
    1264   UInt uiWidth        = pcCU->getWidth ( 0 );
    1265   UInt uiHeight       = pcCU->getHeight( 0 );
    1266   UInt uiLumaPredMode = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx );
    1267   const Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
    1268   const TComSPS     &sps    = *(pcCU->getSlice()->getSPS());
    1269   const ChromaFormat chFmt  = pcCU->getPic()->getChromaFormat();
    1270 
    1271   UInt sdcDepth = 0;
    1272   UInt uiStride;
    1273   Pel* piReco;
    1274   Pel* piPred;
    1275   Pel* piResi;
    1276 
    1277   Pel* piRecIPred;
    1278   UInt uiRecIPredStride;
    1279  
    1280   Pel apDCPredValues[2];
    1281   UInt uiNumSegments;
    1282 
    1283   Bool* pbMask = NULL;
    1284   UInt uiMaskStride = 0;
    1285 
    1286 #if NH_3D_DMM
    1287   if( isDmmMode( uiLumaPredMode ) )
    1288   {
    1289     assert( uiWidth == uiHeight  );
    1290     assert( uiWidth >= DMM_MIN_SIZE && uiWidth <= DMM_MAX_SIZE );
    1291     assert( !((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1) );
    1292 
    1293     uiNumSegments     = 2;
    1294 
    1295     uiStride          = pcRecoYuv->getStride( COMPONENT_Y );
    1296     piReco            = pcRecoYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
    1297     piPred            = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
    1298     piResi            = pcResiYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
    1299 
    1300     piRecIPred        = pcCU->getPic()->getPicYuvRec()->getAddr  ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
    1301     uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y );
    1302 
    1303     //===== init availability pattern =====
    1304     TComTURecurse tuRecurseCU(pcCU, 0);
    1305     TComTURecurse tuRecurseWithPU(tuRecurseCU, false, TComTU::DONT_SPLIT);
    1306 
    1307     DEBUG_STRING_NEW(sTemp)
    1308     m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, false DEBUG_STRING_PASS_INTO(sTemp) );
    1309 
    1310     // get partition
    1311     pbMask       = new Bool[ uiWidth*uiHeight ];
    1312     uiMaskStride = uiWidth;
    1313     switch( getDmmType( uiLumaPredMode ) )
    1314     {
    1315     case( DMM1_IDX ): { (getWedgeListScaled( uiWidth )->at( pcCU->getDmm1WedgeTabIdx( uiAbsPartIdx ) )).getPatternScaledCopy( uiWidth, pbMask ); } break;
    1316     case( DMM4_IDX ): { m_pcPrediction->predContourFromTex( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask );                                     } break;
    1317     default: assert(0);
    1318     }
    1319 
    1320     // get predicted partition values
    1321     Pel predDC1 = 0, predDC2 = 0;
    1322     m_pcPrediction->predBiSegDCs( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask, uiMaskStride, predDC1, predDC2 );
    1323 
    1324     // set prediction signal
    1325     Pel* pDst = piPred;
    1326     m_pcPrediction->assignBiSegDCs( pDst, uiStride, pbMask, uiMaskStride, predDC1, predDC2 );
    1327     apDCPredValues[0] = predDC1;
    1328     apDCPredValues[1] = predDC2;
    1329   }
    1330   else // regular HEVC intra modes
    1331   {
    1332 #endif
    1333     uiNumSegments = 1;
    1334 
    1335     if( ( uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) > 1 )
    1336     {
    1337       sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
    1338     }
    1339    
    1340     //===== loop over partitions =====
    1341     TComTURecurse tuRecurseCU(pcCU, 0);
    1342     TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (sdcDepth==0)?TComTU::DONT_SPLIT:TComTU::QUAD_SPLIT);
    1343 
    1344     do
    1345     {
    1346       const TComRectangle &puRect = tuRecurseWithPU.getRect(COMPONENT_Y);
    1347       const UInt uiAbsPartIdxTU = tuRecurseWithPU.GetAbsPartIdxTU();
    1348      
    1349       Pel* piPredTU       = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdxTU );
    1350       UInt uiStrideTU     = pcPredYuv->getStride( COMPONENT_Y );
    1351      
    1352       Pel* piRecIPredTU   = pcCU->getPic()->getPicYuvRec()->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdxTU );
    1353       UInt uiRecIPredStrideTU  = pcCU->getPic()->getPicYuvRec()->getStride(COMPONENT_Y);
    1354      
    1355       const Bool bUseFilter = TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiLumaPredMode, puRect.width, puRect.height, chFmt, sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag());
    1356      
    1357       //===== init pattern for luma prediction =====
    1358       DEBUG_STRING_NEW(sTemp)
    1359       m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, bUseFilter  DEBUG_STRING_PASS_INTO(sTemp) );
    1360      
    1361       m_pcPrediction->predIntraAng( COMPONENT_Y, uiLumaPredMode, NULL, uiStrideTU, piPredTU, uiStrideTU, tuRecurseWithPU, bUseFilter );
    1362      
    1363       // copy for prediction of next part
    1364       for( UInt uiY = 0; uiY < puRect.height; uiY++ )
    1365       {
    1366         for( UInt uiX = 0; uiX < puRect.width; uiX++ )
    1367         {
    1368           piPredTU      [ uiX ] = ClipBD( piPredTU[ uiX ], bitDepthY );
    1369           piRecIPredTU  [ uiX ] = piPredTU[ uiX ];
    1370         }
    1371         piPredTU     += uiStrideTU;
    1372         piRecIPredTU += uiRecIPredStrideTU;
    1373       }
    1374      
    1375      
    1376     } while (tuRecurseWithPU.nextSection(tuRecurseCU));
    1377 
    1378     // reset to full block
    1379     uiWidth  = pcCU->getWidth( 0 );
    1380     uiHeight = pcCU->getHeight( 0 );
    1381 
    1382     uiStride          = pcRecoYuv->getStride( COMPONENT_Y );
    1383     piReco            = pcRecoYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
    1384     piPred            = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
    1385     piResi            = pcResiYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
    1386    
    1387     piRecIPred        = pcCU->getPic()->getPicYuvRec()->getAddr  ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
    1388     uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y );
    1389 
    1390     m_pcPrediction->predConstantSDC( piPred, uiStride, uiWidth, apDCPredValues[0] ); apDCPredValues[1] = 0;
    1391 #if NH_3D_DMM
    1392   }
    1393 #endif
    1394  
    1395   // reconstruct residual based on mask + DC residuals
    1396   Pel apDCResiValues[2];
    1397   for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
    1398   {
    1399 #if NH_3D_DLT
    1400     Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
    1401     Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
    1402     Pel   pRecoValue  = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
    1403 
    1404     apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
    1405 #else
    1406     apDCResiValues[uiSegment]  = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
    1407 #endif
    1408   }
    1409  
    1410   //===== reconstruction =====
    1411   Bool*pMask      = pbMask;
    1412   Pel* pPred      = piPred;
    1413   Pel* pResi      = piResi;
    1414   Pel* pReco      = piReco;
    1415   Pel* pRecIPred  = piRecIPred;
    1416  
    1417   for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    1418   {
    1419     for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    1420     {
    1421       UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
    1422       assert( ucSegment < uiNumSegments );
    1423      
    1424       Pel pResiDC = apDCResiValues[ucSegment];
    1425      
    1426       pReco    [ uiX ] = ClipBD( pPred[ uiX ] + pResiDC, bitDepthY );
    1427       pRecIPred[ uiX ] = pReco[ uiX ];
    1428     }
    1429     pPred     += uiStride;
    1430     pResi     += uiStride;
    1431     pReco     += uiStride;
    1432     pRecIPred += uiRecIPredStride;
    1433     pMask     += uiMaskStride;
    1434   }
    1435  
    1436   // clear chroma
    1437   UInt  uiStrideC     = pcPredYuv->getStride( COMPONENT_Cb );
    1438   Pel   *pRecCb       = pcPredYuv->getAddr  ( COMPONENT_Cb, uiAbsPartIdx );
    1439   Pel   *pRecCr       = pcPredYuv->getAddr  ( COMPONENT_Cr, uiAbsPartIdx );
    1440  
    1441   for (Int y=0; y<uiHeight/2; y++)
    1442   {
    1443     for (Int x=0; x<uiWidth/2; x++)
    1444     {
    1445       pRecCb[x] = 128;
    1446       pRecCr[x] = 128;
    1447     }
    1448    
    1449     pRecCb += uiStrideC;
    1450     pRecCr += uiStrideC;
    1451   }
    1452 #if NH_3D_DMM
    1453   if( pbMask ) { delete[] pbMask; }
    1454 #endif
    1455 }
    1456 #endif
    1457729
    1458730
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/TDecCu.h

    r1313 r1390  
    6262  TComDataCU**        m_ppcCU;            ///< CU data array
    6363
    64 #if NH_3D_DBBP
    65   TComYuv**           m_ppcYuvRecoDBBP;
    66 #endif
    6764 
    6865  // access channel
     
    10299  Void xReconInter              ( TComDataCU* pcCU, UInt uiDepth );
    103100
    104 #if NH_3D_DBBP
    105   Void xReconInterDBBP          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    106 #endif
    107101 
    108102  Void xReconIntraQT            ( TComDataCU* pcCU, UInt uiDepth );
     
    124118  Void xFillPCMBuffer           (TComDataCU* pCU, UInt depth);
    125119
    126 #if NH_3D_DIS
    127   Void xReconDIS               ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    128 #endif
    129 #if NH_3D_SDC_INTRA
    130   Void xReconIntraSDC           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    131 #endif
    132 #if NH_3D_SDC_INTER
    133   Void xReconInterSDC           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    134 #endif
    135120
    136121};
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/TDecEntropy.cpp

    r1386 r1390  
    6060  m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
    6161}
    62 #if NH_3D_DIS
    63 Void TDecEntropy::decodeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    64 {
    65   if( !pcCU->getSlice()->getDepthIntraSkipFlag() )
    66   {
    67     return;
    68   } 
    69   m_pcEntropyDecoderIf->parseDIS( pcCU, uiAbsPartIdx, uiDepth );
    70 }
    71 #endif
    7262
    7363Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     
    10494}
    10595
    106 #if NH_3D_ARP
    107 Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    108 {
    109   if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) )
    110   {
    111     return;
    112   }
    113 
    114   if( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N )
    115   {
    116     pcCU->setARPWSubParts( 0 , uiAbsPartIdx, uiDepth );
    117   }
    118   else
    119   {
    120     m_pcEntropyDecoderIf->parseARPW( pcCU , uiAbsPartIdx , uiDepth );
    121   }
    122 }
    123 #endif
    124 
    125 #if NH_3D_IC
    126 Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    127 {
    128   pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
    129 
    130 #if NH_3D_ARP
    131   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
    132 #else
    133   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() )
    134 #endif
    135   {
    136     return;
    137   }
    138 
    139   if( !pcCU->getSlice()->getApplyIC() )
    140     return;
    141 
    142   if( pcCU->isICFlagRequired( uiAbsPartIdx ) )
    143     m_pcEntropyDecoderIf->parseICFlag( pcCU, uiAbsPartIdx, uiDepth );
    144 }
    145 #endif
     96
    14697
    14798Void TDecEntropy::decodeSplitFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     
    165116  {
    166117    decodeIntraDirModeLuma  ( pcCU, uiAbsPartIdx, uiDepth );
    167 #if NH_3D_SDC_INTRA
    168     decodeSDCFlag   ( pcCU, uiAbsPartIdx, uiDepth );
    169 #endif
    170118    if (pcCU->getPic()->getChromaFormat()!=CHROMA_400)
    171119    {
     
    239187  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
    240188
    241 #if NH_3D_MLC
    242 //#if H_3D_IV_MERGE
    243   TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    244   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
    245 #else
    246189  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
    247190  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    248 #endif
    249 #if NH_3D_SPIVMP
    250   Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];     
    251   TComMvField*  pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2];
    252   UChar* puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()];
    253 #endif
    254 #if NH_3D_IV_MERGE
    255   pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx);
    256 #endif
    257191  for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
    258192  {
     
    264198  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
    265199  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
    266 #if NH_3D
    267200  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
    268201  {
     
    273206    //DTRACE_PU("x1", uiTPelY)
    274207#endif
    275 
    276     ////// Parse PUs syntax
    277208    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
    278209    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
    279210    {
    280       decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );     
    281     }
    282     else
    283     {
    284       decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
    285       for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    286       {       
    287         if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
    288         {
    289           decodeRefFrmIdxPU( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
    290           decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
    291           decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
    292         }
    293       }
    294     }
    295   }
    296 
    297   ////// Parse CUs extension syntax
    298 #if NH_3D_DBBP
    299   decodeDBBPFlag( pcCU, uiAbsPartIdx, uiDepth );
    300 #endif
    301 #if NH_3D_SDC_INTER
    302   decodeSDCFlag ( pcCU, uiAbsPartIdx, uiDepth );
    303 #endif
    304 #if NH_3D_ARP
    305   decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
    306 #endif
    307 #if NH_3D_IC
    308   decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
    309 #endif
    310 
    311   ////// Decode motion vectors
    312   for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
    313   {
    314     if ( pcCU->getMergeFlag( uiSubPartIdx ) )
    315     {
    316       UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
     211      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
    317212#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
    318213      if (bDebugPredEnabled)
     
    323218#endif
    324219
    325 #if NH_3D_DBBP
    326       if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false )
    327 #else
    328       if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 )
    329 #endif
     220      const UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
     221      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 )
    330222      {
    331223        if ( !hasMergedCandList )
     
    333225          pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set.
    334226
    335 #if NH_3D_MLC
    336 #if NH_3D_VSP
    337           Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    338           memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    339 #endif
    340 #if NH_3D_SPIVMP
    341           memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    342 #endif
    343           pcSubCU->initAvailableFlags();
    344 #endif
    345227          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    346 #if NH_3D_MLC
    347           pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
    348 #if NH_3D_SPIVMP
    349             , pcMvFieldSP, puhInterDirSP
    350 #endif
    351             , numValidMergeCand );
    352           pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
    353 #if NH_3D_VSP
    354             , vspFlag
    355 #endif
    356 #if NH_3D_SPIVMP
    357             , bSPIVMPFlag
    358 #endif
    359             , numValidMergeCand );
    360 #if NH_3D_VSP
    361           pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    362 #endif
    363 #endif
    364228          pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); // restore.
    365229          hasMergedCandList = true;
     
    368232      else
    369233      {
    370 #if NH_3D_MLC
    371 #if NH_3D_VSP
    372         Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    373         memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    374 #endif
    375 #if NH_3D_SPIVMP
    376         memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    377 #endif
    378         pcSubCU->initAvailableFlags();
    379 #endif
     234
    380235        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    381 #if NH_3D_MLC
    382         pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
    383 #if NH_3D_SPIVMP
    384           , pcMvFieldSP, puhInterDirSP
    385 #endif
    386           ,numValidMergeCand, uiMergeIndex );
    387         pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
    388 #if NH_3D_VSP
    389           , vspFlag
    390 #endif
    391 #if NH_3D_SPIVMP
    392           , bSPIVMPFlag
    393 #endif
    394           ,numValidMergeCand );
    395 #if NH_3D_VSP
    396         pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    397 #endif
    398 #endif
    399       }
     236      }
     237
    400238      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    401239
     
    409247          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
    410248          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
    411 #if NH_3D_VSP
    412 #if NH_3D_DBBP
    413           if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) )
    414 #else
    415           if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 )
    416 #endif
    417           {
    418             if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
    419             {
    420               UInt dummy;
    421               Int vspSize;
    422               Int width, height;
    423               pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 );
    424               pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
    425               pcCU->setVSPFlag( uiSubPartIdx, vspSize );
    426             }
    427           }
    428 #endif
    429249        }
    430250      }
    431 #if NH_3D_SPIVMP
    432       pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); 
    433       if (bSPIVMPFlag[uiMergeIndex] != 0)
    434       {
    435         Int iWidth, iHeight;
    436         UInt uiIdx;
    437         pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true );
    438 
    439         UInt uiSPAddr;
    440 
    441         Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    442 
    443         pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    444 
    445         for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    446         {
    447           pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
    448           pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
    449           pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
    450           pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
    451         }
    452       }
    453 #endif
    454251    }
    455252    else
    456253    {
     254      decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
    457255      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    458       {       
     256      {
    459257        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
    460258        {
    461           decodeMvsAMVP   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
     259          decodeRefFrmIdxPU( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
     260          decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
     261          decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
    462262#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
    463263          if (bDebugPredEnabled)
     
    471271#endif
    472272        }
    473       }
     273      } 
    474274    }
    475275
     
    481281    }
    482282  }
    483 #else
    484   for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
    485   {
    486 #if NH_MV_ENC_DEC_TRAC
    487     DTRACE_PU_S("=========== prediction_unit ===========\n")
    488     // ToDo:
    489     //DTRACE_PU("x0", uiLPelX)
    490     //DTRACE_PU("x1", uiTPelY)
    491 #endif
    492     decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
    493     if ( pcCU->getMergeFlag( uiSubPartIdx ) )
    494     {
    495       decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
    496 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
    497       if (bDebugPredEnabled)
    498       {
    499         std::cout << "Coded merge flag, CU absPartIdx: " << uiAbsPartIdx << " PU(" << uiPartIdx << ") absPartIdx: " << uiSubPartIdx;
    500         std::cout << " merge index: " << (UInt)pcCU->getMergeIndex(uiSubPartIdx) << std::endl;
    501       }
    502 #endif
    503 #if NH_3D_IC
    504       decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
    505 #endif
    506 
    507       const UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
    508       if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 )
    509       {
    510         if ( !hasMergedCandList )
    511         {
    512           pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set.
    513 
    514 #if NH_3D_MLC
    515 #if NH_3D_VSP
    516           Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    517           memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    518 #endif
    519 #if NH_3D_SPIVMP
    520           memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    521 #endif
    522           pcSubCU->initAvailableFlags();
    523 #endif
    524           pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    525 #if NH_3D_MLC
    526           pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
    527 #if NH_3D_SPIVMP
    528             , pcMvFieldSP, puhInterDirSP
    529 #endif
    530             , numValidMergeCand );
    531           pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
    532 #if NH_3D_VSP
    533             , vspFlag
    534 #endif
    535 #if NH_3D_SPIVMP
    536             , bSPIVMPFlag
    537 #endif
    538             , numValidMergeCand );
    539 #if NH_3D_VSP
    540           pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    541 #endif
    542 #endif
    543           pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); // restore.
    544           hasMergedCandList = true;
    545         }
    546       }
    547       else
    548       {
    549 
    550 #if NH_3D_MLC
    551 #if NH_3D_VSP
    552         Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    553         memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    554 #endif
    555 #if NH_3D_SPIVMP
    556         memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    557 #endif
    558         pcSubCU->initAvailableFlags();
    559 #endif
    560         pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    561 #if NH_3D_MLC
    562         pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
    563 #if NH_3D_SPIVMP
    564           , pcMvFieldSP, puhInterDirSP
    565 #endif
    566           ,numValidMergeCand, uiMergeIndex );
    567         pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
    568 #if NH_3D_VSP
    569           , vspFlag
    570 #endif
    571 #if NH_3D_SPIVMP
    572           , bSPIVMPFlag
    573 #endif
    574           ,numValidMergeCand );
    575 #if NH_3D_VSP
    576         pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    577 #endif
    578 #endif
    579       }
    580 
    581       pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    582 
    583       TComMv cTmpMv( 0, 0 );
    584       for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    585       {
    586         if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
    587         {
    588           pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
    589           pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
    590           pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
    591           pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
    592 #if NH_3D_VSP
    593           if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 )
    594           {
    595             if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
    596             {
    597               UInt dummy;
    598               Int vspSize;
    599               Int width, height;
    600               pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 );
    601               pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
    602               pcCU->setVSPFlag( uiSubPartIdx, vspSize );
    603             }
    604           }
    605 #endif
    606         }
    607       }
    608 #if NH_3D_SPIVMP
    609       pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); 
    610       if (bSPIVMPFlag[uiMergeIndex] != 0)
    611       {
    612         Int iWidth, iHeight;
    613         UInt uiIdx;
    614         pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true );
    615 
    616         UInt uiSPAddr;
    617 
    618         Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    619 
    620         pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    621 
    622         for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    623         {
    624           pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
    625           pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
    626           pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
    627           pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
    628         }
    629       }
    630 #endif
    631     }
    632     else
    633     {
    634       decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
    635       for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    636       {
    637         if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
    638         {
    639           decodeRefFrmIdxPU( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
    640           decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
    641           decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
    642 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
    643           if (bDebugPredEnabled)
    644           {
    645             std::cout << "refListIdx: " << uiRefListIdx << std::endl;
    646             std::cout << "MVD horizontal: " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getHor() << std::endl;
    647             std::cout << "MVD vertical:   " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getVer() << std::endl;
    648             std::cout << "MVPIdxPU: " << pcCU->getMVPIdx(RefPicList( uiRefListIdx ), uiSubPartIdx) << std::endl;
    649             std::cout << "InterDir: " << (UInt)pcCU->getInterDir(uiSubPartIdx) << std::endl;
    650           }
    651 #endif
    652         }
    653       }
    654 #if NH_3D_IC
    655       decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
    656 #endif
    657     }
    658 
    659     if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
    660     {
    661       pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
    662       pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
    663       pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth);
    664     }
    665   }
    666 #endif
    667 #if NH_3D_SPIVMP
    668   delete[] pcMvFieldSP;
    669   delete[] puhInterDirSP;
    670 #endif
    671283  return;
    672284}
     
    733345}
    734346
    735 #if NH_3D
    736347Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
    737348{
    738349  Int iMVPIdx = -1;
     350
     351  TComMv cZeroMv( 0, 0 );
     352  TComMv cMv     = cZeroMv;
     353  Int    iRefIdx = -1;
     354
     355  TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
     356  AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
     357
     358  iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
     359  cMv = cZeroMv;
    739360
    740361  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) )
     
    754375#endif
    755376  }
    756   pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
    757 }
    758 
    759 Void TDecEntropy::decodeMvsAMVP( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
    760 {
    761   TComMv cZeroMv( 0, 0 );
    762   TComMv cMv     = cZeroMv;
    763   Int    iRefIdx = -1;
    764 
    765   TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
    766   AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
    767 
    768   iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
    769   cMv = cZeroMv;
    770 
    771   pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
    772   pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
    773   if ( iRefIdx >= 0 )
    774   {
    775     m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv);
    776     cMv += pcSubCUMvField->getMvd( uiPartAddr );
    777   }
    778 
    779   PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
    780   pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
    781 }
    782 #else
    783 Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
    784 {
    785   Int iMVPIdx = -1;
    786 
    787   TComMv cZeroMv( 0, 0 );
    788   TComMv cMv     = cZeroMv;
    789   Int    iRefIdx = -1;
    790 
    791   TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
    792   AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
    793 
    794   iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
    795   cMv = cZeroMv;
    796 
    797   if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) )
    798   {
    799     m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
    800 #if NH_MV_ENC_DEC_TRAC
    801 #if ENC_DEC_TRACE
    802     if ( eRefList == REF_PIC_LIST_0 )
    803     {
    804       DTRACE_PU("mvp_l0_flag", iMVPIdx)
    805     }
    806     else
    807     {
    808       DTRACE_PU("mvp_l1_flag", iMVPIdx)
    809     }
    810 #endif
    811 #endif
    812   }
    813377  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
    814378  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
     
    823387  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
    824388}
    825 #endif
    826389
    827390Void TDecEntropy::xDecodeTransform        ( Bool& bCodeDQP, Bool& isChromaQpAdjCoded, TComTU &rTu, const Int quadtreeTULog2MinSizeInCU )
     
    1085648Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool& bCodeDQP, Bool& isChromaQpAdjCoded )
    1086649{
    1087 #if NH_3D_SDC_INTRA
    1088   if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx) )
    1089   {
    1090     assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
    1091     assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 );
    1092     assert( pcCU->getCbf(uiAbsPartIdx, COMPONENT_Y) == 1 );
    1093 }
    1094 #endif
    1095 #if NH_3D_SDC_INTER
    1096   if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx) )
    1097   {
    1098     assert( !pcCU->isSkipped( uiAbsPartIdx ) );
    1099     assert( !pcCU->isIntra( uiAbsPartIdx) );
    1100     assert( pcCU->getSlice()->getIsDepth() );
    1101   }
    1102 #endif
    1103 #if NH_3D
    1104   if( pcCU->getSlice()->getIsDepth() )
    1105   {
    1106 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    1107     if( pcCU->getSDCFlag( uiAbsPartIdx ) )
    1108     {
    1109       m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx, uiDepth );
    1110       return;
    1111     }
    1112 #endif
    1113 #if NH_3D_DMM
    1114     if( pcCU->isIntra( uiAbsPartIdx ) )
    1115     {
    1116       Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
    1117       UInt uiPartOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
    1118       for( Int iPart = 0; iPart < iPartNum; iPart++ )
    1119       {
    1120         if( isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx + uiPartOffset*iPart ) ) )
    1121         {
    1122           m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) );
    1123         }
    1124       }
    1125     }
    1126 #endif
    1127   }
    1128 #endif
    1129650
    1130651  if( pcCU->isIntra(uiAbsPartIdx) )
     
    1162683}
    1163684
    1164 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    1165 Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    1166 {
    1167   pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth );
    1168   if ( pcCU->isSkipped( uiAbsPartIdx ) )
    1169   {
    1170     return;
    1171   }
    1172 
    1173 
    1174   if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getInterSdcFlag() ) ||
    1175     ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getIntraSdcWedgeFlag() ) )
    1176   {
    1177     return;
    1178   }
    1179 
    1180   if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) )
    1181   {
    1182     return;
    1183   }
    1184 
    1185   assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
    1186   m_pcEntropyDecoderIf->parseSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
    1187 }
    1188 #endif
    1189 #if NH_3D_DBBP
    1190 Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    1191 {
    1192   if( pcCU->getSlice()->getDepthBasedBlkPartFlag() && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 && pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
    1193   {
    1194     m_pcEntropyDecoderIf->parseDBBPFlag( pcCU, uiAbsPartIdx, uiDepth );
    1195   }
    1196 }
    1197 #endif
    1198685
    1199686
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/TDecEntropy.h

    r1321 r1390  
    8181public:
    8282  virtual Void parseSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    83 #if NH_3D_DIS
    84   virtual Void parseDIS           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    85 #endif
    8683  virtual Void parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    8784  virtual Void parseSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    8885  virtual Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) = 0;
    8986  virtual Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex ) = 0;
    90 #if NH_3D_ARP
    91   virtual Void parseARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    92 #endif
    93 #if NH_3D_IC
    94   virtual Void parseICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    95 #endif
    96 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    97   virtual Void  parseDeltaDC      ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) = 0;
    98 #endif
    99 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    100   virtual Void parseSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    101 #endif
    102 #if NH_3D_DBBP
    103   virtual Void parseDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    104 #endif
    10587  virtual Void parsePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    10688  virtual Void parsePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
     
    150132  Void decodeMvdPU        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList );
    151133  Void decodeMVPIdxPU     ( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList );
    152 #if NH_3D
    153   Void decodeMvsAMVP      ( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx,
    154 RefPicList eRefList );
    155 #endif
    156134  Void    setEntropyDecoder           ( TDecEntropyIf* p );
    157135  Void    setBitstream                ( TComInputBitstream* p ) { m_pcEntropyDecoderIf->setBitstream(p);                    }
     
    177155  Void decodeSplitFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    178156  Void decodeSkipFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    179 #if NH_3D_DIS
    180   Void decodeDIS               ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) ;
    181 #endif
    182157  Void decodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    183158  Void decodeMergeFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
     
    186161  Void decodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    187162
    188 #if NH_3D_ARP
    189   Void decodeARPW              ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    190 #endif
    191 #if NH_3D_IC
    192   Void decodeICFlag            ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    193 #endif
    194163
    195 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    196   Void decodeSDCFlag           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    197 #endif
    198 #if NH_3D_DBBP
    199   Void decodeDBBPFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    200 #endif
    201164  Void decodeIPCMInfo          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    202165
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/TDecGop.cpp

    r1386 r1390  
    122122  }
    123123
    124 #if NH_3D_NBDV
    125   if(pcSlice->getViewIndex() && !pcSlice->getIsDepth()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
    126   {
    127     Int iColPoc = pcSlice->getRefPOC(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
    128     pcPic->setNumDdvCandPics(pcPic->getDisCandRefPictures(iColPoc));
    129   }
    130 
    131   if(pcSlice->getViewIndex() && !pcSlice->getIsDepth() && !pcSlice->isIntra()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
    132   {
    133     pcPic->checkTemporalIVRef();
    134   }
    135 
    136   if(pcSlice->getIsDepth())
    137   {
    138     pcPic->checkTextureRef();
    139   }
    140 #endif
    141 #if NH_3D
    142   pcSlice->setDepthToDisparityLUTs();
    143 #endif
    144124
    145125  m_pcSliceDecoder->decompressSlice( ppcSubstreams, pcPic, m_pcSbacDecoder);
     
    172152    m_pcSAO->PCMLFDisableProcess(pcPic);
    173153  }
    174 #if NH_3D
    175   pcPic->compressMotion(2);
    176 #else
    177154  pcPic->compressMotion();
    178 #endif
    179155  TChar c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B');
    180156  if (!pcSlice->isReferenced())
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/TDecSbac.cpp

    r1386 r1390  
    6767, m_cCUSplitFlagSCModel                      ( 1,             1,                      NUM_SPLIT_FLAG_CTX                   , m_contextModels + m_numContextModels, m_numContextModels)
    6868, m_cCUSkipFlagSCModel                       ( 1,             1,                      NUM_SKIP_FLAG_CTX                    , m_contextModels + m_numContextModels, m_numContextModels)
    69 #if NH_3D_DIS
    70 , m_cCUDISFlagSCModel                        ( 1,             1,                      NUM_DIS_FLAG_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
    71 , m_cCUDISTypeSCModel                        ( 1,             1,                      NUM_DIS_TYPE_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
    72 #endif
    7369, m_cCUMergeFlagExtSCModel                   ( 1,             1,                      NUM_MERGE_FLAG_EXT_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
    7470, m_cCUMergeIdxExtSCModel                    ( 1,             1,                      NUM_MERGE_IDX_EXT_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
    75 #if NH_3D_ARP
    76 , m_cCUPUARPWSCModel          ( 1,             1,               NUM_ARPW_CTX                  , m_contextModels + m_numContextModels, m_numContextModels)
    77 #endif
    78 #if NH_3D_IC
    79 , m_cCUICFlagSCModel          ( 1,             1,               NUM_IC_FLAG_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
    80 #endif
    8171, m_cCUPartSizeSCModel                       ( 1,             1,                      NUM_PART_SIZE_CTX                    , m_contextModels + m_numContextModels, m_numContextModels)
    8272, m_cCUPredModeSCModel                       ( 1,             1,                      NUM_PRED_MODE_CTX                    , m_contextModels + m_numContextModels, m_numContextModels)
     
    10797, m_ChromaQpAdjIdcSCModel                    ( 1,             1,                      NUM_CHROMA_QP_ADJ_IDC_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
    10898
    109 #if NH_3D_DMM
    110 , m_cNotDmmFlagSCModel                       ( 1,             1,                      NUM_NOTDMM_FLAG_CTX                  , m_contextModels + m_numContextModels, m_numContextModels)
    111 , m_cDmmModeSCModel                          ( 1,             1,                      NUM_DMM_MODE_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
    112 #endif
    113 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    114 , m_cDdcDataSCModel                          ( 1,             1,                      NUM_DDC_DATA_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
    115 , m_cSDCFlagSCModel                          ( 1,             1,                     NUM_SDC_FLAG_CTX                      , m_contextModels + m_numContextModels, m_numContextModels)
    116 #endif
    117 #if NH_3D_SDC_INTRA
    118 , m_cSDCResidualFlagSCModel                  ( 1,             1,                     SDC_NUM_RESIDUAL_FLAG_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
    119 , m_cSDCResidualSCModel                      ( 1,             1,                     SDC_NUM_RESIDUAL_CTX                  , m_contextModels + m_numContextModels, m_numContextModels)
    120 , m_cDdcFlagSCModel                          ( 1,             1,                     NUM_DDC_FLAG_CTX                      , m_contextModels + m_numContextModels, m_numContextModels)
    121 #endif
    122 #if NH_3D_DBBP
    123 , m_cDBBPFlagSCModel                         ( 1,             1,                     DBBP_NUM_FLAG_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
    124 #endif
    12599
    126100{
     
    159133  m_cCUSplitFlagSCModel.initBuffer                ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG );
    160134  m_cCUSkipFlagSCModel.initBuffer                 ( sliceType, qp, (UChar*)INIT_SKIP_FLAG );
    161 #if NH_3D_DIS
    162   m_cCUDISFlagSCModel.initBuffer                  ( sliceType, qp, (UChar*)INIT_DIS_FLAG );
    163   m_cCUDISTypeSCModel.initBuffer                  ( sliceType, qp, (UChar*)INIT_DIS_TYPE );
    164 #endif
    165135  m_cCUMergeFlagExtSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT );
    166136  m_cCUMergeIdxExtSCModel.initBuffer              ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT );
    167 #if NH_3D_ARP
    168   m_cCUPUARPWSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_ARPW );
    169 #endif
    170 #if NH_3D_IC
    171   m_cCUICFlagSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_IC_FLAG );
    172 #endif
    173137  m_cCUPartSizeSCModel.initBuffer                 ( sliceType, qp, (UChar*)INIT_PART_SIZE );
    174138  m_cCUPredModeSCModel.initBuffer                 ( sliceType, qp, (UChar*)INIT_PRED_MODE );
     
    198162  m_ChromaQpAdjFlagSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_CHROMA_QP_ADJ_FLAG );
    199163  m_ChromaQpAdjIdcSCModel.initBuffer              ( sliceType, qp, (UChar*)INIT_CHROMA_QP_ADJ_IDC );
    200 #if NH_3D_DMM
    201   m_cNotDmmFlagSCModel.initBuffer                 ( sliceType, qp, (UChar*)INIT_NOTDMM_FLAG );
    202   m_cDmmModeSCModel.initBuffer                    ( sliceType, qp, (UChar*)INIT_DMM_MODE );
    203 #endif
    204 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    205   m_cDdcDataSCModel.initBuffer                    ( sliceType, qp, (UChar*)INIT_DDC_DATA );
    206   m_cSDCFlagSCModel.initBuffer                    ( sliceType, qp, (UChar*)INIT_SDC_FLAG );
    207 #endif
    208 #if NH_3D_SDC_INTRA
    209   m_cSDCResidualFlagSCModel.initBuffer            ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
    210   m_cSDCResidualSCModel.initBuffer                ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL );
    211   m_cDdcFlagSCModel.initBuffer                    ( sliceType, qp, (UChar*)INIT_DDC_FLAG );
    212 #endif
    213 #if NH_3D_DBBP
    214   m_cDBBPFlagSCModel.initBuffer                   ( sliceType, qp, (UChar*)INIT_DBBP_FLAG );
    215 #endif
    216164
    217165  for (UInt statisticIndex = 0; statisticIndex < RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS ; statisticIndex++)
     
    512460
    513461}
    514 #if NH_3D_DIS
    515 Void TDecSbac::parseDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    516 {
    517   pcCU->setDISFlagSubParts( false,        uiAbsPartIdx, uiDepth );
    518   UInt uiSymbol = 0;
    519   m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUDISFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SKIP_FLAG) );
    520   if( uiSymbol )
    521   {
    522     pcCU->setDISFlagSubParts( true,        uiAbsPartIdx, uiDepth );
    523     pcCU->setSkipFlagSubParts( false,        uiAbsPartIdx, uiDepth );
    524     pcCU->setSDCFlagSubParts( false,        uiAbsPartIdx, uiDepth );
    525     pcCU->setPredModeSubParts( MODE_INTRA,  uiAbsPartIdx, uiDepth );
    526     pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
    527     pcCU->setIntraDirSubParts(CHANNEL_TYPE_LUMA, DC_IDX, uiAbsPartIdx, uiDepth );
    528     pcCU->setSizeSubParts( pcCU->getSlice()->getSPS()->getMaxCUWidth()>>uiDepth, pcCU->getSlice()->getSPS()->getMaxCUHeight()>>uiDepth, uiAbsPartIdx, uiDepth );
    529     pcCU->setMergeFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
    530     pcCU->setTrIdxSubParts(0, uiAbsPartIdx, uiDepth);
    531     pcCU->setCbfSubParts(0, COMPONENT_Y, uiAbsPartIdx, uiDepth);
    532 
    533     UInt uiUnaryIdx = 0;
    534     UInt uiNumCand  = 4;
    535 
    536     if ( uiNumCand > 1 )
    537     {
    538       for( ; uiUnaryIdx < uiNumCand - 1; ++uiUnaryIdx )
    539       {
    540         UInt uiSymbol2 = 0;
    541         if ( uiUnaryIdx==0 )
    542         {
    543           m_pcTDecBinIf->decodeBin( uiSymbol2, m_cCUDISTypeSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SKIP_FLAG) );
    544         }
    545         else
    546         {
    547           m_pcTDecBinIf->decodeBinEP( uiSymbol2 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SKIP_FLAG));
    548         }
    549         if( uiSymbol2 == 0 )
    550         {
    551           break;
    552         }
    553       }
    554     }
    555     pcCU->setDISTypeSubParts((UChar)uiUnaryIdx, uiAbsPartIdx, uiDepth);
    556   }
    557 }
    558 #endif
    559462
    560463
     
    642545
    643546  UInt uiSymbol;
    644 #if NH_3D_QTLPC
    645   Bool bParseSplitFlag    = true;
    646   Bool    bLimQtPredFlag = pcCU->getPic()->getSlice(0)->getQtPredFlag();
    647   TComPic *pcTexture      = pcCU->getSlice()->getTexturePic();
    648   Bool bDepthMapDetect    = (pcTexture != NULL);
    649   Bool bIntraSliceDetect  = (pcCU->getSlice()->getSliceType() == I_SLICE);
    650 
    651   Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA);
    652 
    653 #if H_3D_FCO
    654   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && bLimQtPredFlag && pcTexture->getReconMark())
    655 #else
    656   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && bLimQtPredFlag)
    657 #endif
    658   {
    659     TComDataCU *pcTextureCU = pcTexture->getCtu(pcCU->getCtuRsAddr());
    660     assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth);
    661     bParseSplitFlag         = (pcTextureCU->getDepth(uiAbsPartIdx) > uiDepth);
    662   }
    663 
    664   if(bParseSplitFlag)
    665   {
    666 #endif
    667547  m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) );
    668548#if NH_MV_ENC_DEC_TRAC
     
    671551  DTRACE_CABAC_VL( g_nSymbolCounter++ )
    672552  DTRACE_CABAC_T( "\tSplitFlag\n" )
    673 #endif
    674 #if NH_3D_QTLPC
    675   }
    676   else
    677   {
    678     uiSymbol = 0;
    679   }
    680553#endif
    681554  pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx );
     
    704577  assert ( pcCU->getSlice()->getSPS()->getLog2DiffMaxMinCodingBlockSize() == log2DiffMaxMinCodingBlockSize);
    705578
    706 #if NH_3D_QTLPC
    707   Bool bParsePartSize    = true;
    708 
    709   Bool    bLimQtPredFlag = pcCU->getPic()->getSlice(0)->getQtPredFlag();
    710   TComPic *pcTexture     = pcCU->getSlice()->getTexturePic();
    711   Bool bDepthMapDetect   = (pcTexture != NULL);
    712   Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE);
    713 
    714   Bool rapPic     = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA);
    715 
    716   Bool depthDependent = false;
    717   UInt uiTexturePart = uiMode;
    718 
    719 #if H_3D_FCO
    720   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && bLimQtPredFlag && pcTexture->getReconMark())
    721 #else
    722   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && bLimQtPredFlag )
    723 #endif
    724   {
    725     TComDataCU *pcTextureCU = pcTexture->getCtu(pcCU->getCtuRsAddr());
    726     assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth);
    727     if(pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth )
    728     {
    729       depthDependent = true;
    730       uiTexturePart = pcTextureCU->getPartitionSize( uiAbsPartIdx );
    731     }
    732     if (pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth && pcTextureCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N)
    733     {
    734       bParsePartSize = false;
    735       eMode          = SIZE_2Nx2N;
    736     }
    737   }
    738 #endif
    739579
    740580  if ( pcCU->isIntra( uiAbsPartIdx ) )
    741581  {
    742 #if NH_3D_QTLPC
    743     if(bParsePartSize)
    744     {
    745 #endif
    746582    uiSymbol = 1;
    747583    if( uiDepth == log2DiffMaxMinCodingBlockSize )
     
    753589    }
    754590    eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN;
    755 #if NH_3D_QTLPC
    756     }
    757 #endif
    758591    UInt uiTrLevel = 0;
    759592    UInt uiWidthInBit  = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2;
     
    771604  else
    772605  {
    773 #if NH_3D_QTLPC
    774     if(bParsePartSize)
    775     {
    776       if (depthDependent==false || uiTexturePart == SIZE_NxN|| uiTexturePart == SIZE_2Nx2N)
    777       {
    778 #endif
    779606    UInt uiMaxNumBits = 2;
    780607
     
    815642      }
    816643    }
    817 #if NH_3D_QTLPC
    818       }
    819       else if(uiTexturePart == SIZE_2NxN || uiTexturePart == SIZE_2NxnU || uiTexturePart == SIZE_2NxnD)
    820       {
    821         UInt uiMaxNumBits = 1;
    822         if ( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize )
    823         {
    824           uiMaxNumBits ++;
    825         }
    826         for ( UInt ui = 0; ui < uiMaxNumBits; ui++ )
    827         {
    828           m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) );
    829           if ( uiSymbol )
    830           {
    831             break;
    832           }
    833           uiMode++;
    834         }
    835         eMode = (PartSize) uiMode;
    836         if(uiMode && ( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiSymbol==1 )
    837         {
    838           eMode = SIZE_2NxN;
    839         }
    840         else if (uiMode && (( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize )==0)  && uiSymbol==0)
    841         {
    842           eMode = SIZE_2NxN;
    843         }
    844         else if (uiMode && ( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiSymbol==0)
    845         {
    846           m_pcTDecBinIf->decodeBinEP(uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype));
    847           eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD);
    848         }
    849       }
    850       else if(uiTexturePart == SIZE_Nx2N|| uiTexturePart==SIZE_nLx2N || uiTexturePart==SIZE_nRx2N)
    851       {
    852         UInt uiMaxNumBits = 1;
    853         if (  ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize )
    854         {
    855           uiMaxNumBits ++;
    856         }
    857         for ( UInt ui = 0; ui < uiMaxNumBits; ui++ )
    858         {
    859           m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype));
    860           if ( uiSymbol )
    861           {
    862             break;
    863           }
    864           uiMode++;
    865         }
    866         eMode = (PartSize) uiMode;
    867         if(uiMode && ( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiSymbol==1 )
    868         {
    869           eMode = SIZE_Nx2N;
    870         }
    871         else if (uiMode && (( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize )==0)  && uiSymbol==0)
    872         {
    873           eMode = SIZE_Nx2N;
    874         }
    875         else if (uiMode && ( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiSymbol==0)
    876         {
    877           m_pcTDecBinIf->decodeBinEP(uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype));
    878           eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N);
    879         }
    880       }
    881       else
    882       {
    883         assert(0);
    884       }
    885 #endif
    886644#if NH_MV_ENC_DEC_TRAC         
    887645      DTRACE_CU("part_mode", eMode )
    888 #endif
    889 #if NH_3D_QTLPC
    890     }
    891646#endif
    892647  }
     
    937692  for (j=0;j<partNum;j++)
    938693  {
    939 #if NH_3D_DMM
    940     if( pcCU->getSlice()->getIntraSdcWedgeFlag() || pcCU->getSlice()->getIntraContourFlag() )
    941     {
    942       xParseIntraDepthMode( pcCU, absPartIdx+partOffset*j, depth );
    943       xParseDmmData       ( pcCU, absPartIdx+partOffset*j, depth );
    944     }
    945     if( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
    946     {
    947 #endif
    948694    m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) );
    949695    mpmPred[j] = symbol;
     
    951697      DTRACE_CU("prev_intra_luma_pred_flag", symbol)
    952698#endif
    953 #if NH_3D_DMM
    954     }
    955 #endif
    956699  }
    957700  for (j=0;j<partNum;j++)
    958701  {
    959 #if NH_3D_DMM
    960     if( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
    961     {
    962 #endif
    963702    Int preds[NUM_MOST_PROBABLE_MODES] = {-1, -1, -1};
    964703    pcCU->getIntraDirPredictor(absPartIdx+partOffset*j, preds, COMPONENT_Y);
     
    1003742    }
    1004743    pcCU->setIntraDirSubParts(CHANNEL_TYPE_LUMA, (UChar)intraPredMode, absPartIdx+partOffset*j, depth );
    1005 #if NH_3D_DMM
    1006     }
    1007 #endif
    1008744  }
    1009745}
     
    22692005}
    22702006
    2271 #if NH_3D_ARP
    2272 Void TDecSbac::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    2273 {
    2274   UInt uiW = 0;
    2275   UInt uiOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx);
    2276   UInt uiCode = 0;
    2277 
    2278   m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 0 + uiOffset ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__ARP_FLAG));
    2279 
    2280   uiW = uiCode;
    2281   if( 1 == uiW )   
    2282   {
    2283     m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 2 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__ARP_FLAG));
    2284     uiW += ( 1 == uiCode ? 1 : 0 );
    2285   }
    2286 #if NH_MV_ENC_DEC_TRAC
    2287   DTRACE_CU("iv_res_pred_weight_idx", uiW )
    2288 #endif
    2289   pcCU->setARPWSubParts( ( UChar )( uiW ) , uiAbsPartIdx, uiDepth ); 
    2290 }
    2291 #endif
    2292 
    2293 #if NH_3D_IC
    2294 /** parse illumination compensation flag
    2295  * \param pcCU
    2296  * \param uiAbsPartIdx
    2297  * \param uiDepth
    2298  * \returns Void
    2299  */
    2300 Void TDecSbac::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    2301 {
    2302   UInt uiSymbol = 0;
    2303   m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__3D_IC) );
    2304 
    2305 #if !NH_MV_ENC_DEC_TRAC
    2306   DTRACE_CABAC_VL( g_nSymbolCounter++ );
    2307   DTRACE_CABAC_T( "\tICFlag" );
    2308   DTRACE_CABAC_T( "\tuiCtxIC: ");
    2309   DTRACE_CABAC_V( uiCtxIC );
    2310   DTRACE_CABAC_T( "\tuiSymbol: ");
    2311   DTRACE_CABAC_V( uiSymbol );
    2312   DTRACE_CABAC_T( "\n");
    2313 #else
    2314   DTRACE_CU("ic_flag", uiSymbol)
    2315 #endif
    2316  
    2317   pcCU->setICFlagSubParts( uiSymbol ? true : false , uiAbsPartIdx, 0, uiDepth );
    2318 }
    2319 #endif
    2320 
    2321 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    2322 Void TDecSbac::parseDeltaDC( TComDataCU* pcCU, UInt absPartIdx, UInt depth )
    2323 {
    2324 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    2325   if( !(pcCU->getSDCFlag( absPartIdx )) )
    2326 #endif
    2327 #if NH_3D_DMM
    2328   if( !(pcCU->isIntra( absPartIdx ) && isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ) )) )
    2329 #endif
    2330     assert( 0 );
    2331 
    2332   UInt symbol = 1;
    2333 #if NH_3D_SDC_INTRA
    2334   if( pcCU->isIntra( absPartIdx ) && pcCU->getSDCFlag( absPartIdx ))
    2335   {
    2336     m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SDC_DELTADC_FLAG) );
    2337     assert( pcCU->getPartitionSize( absPartIdx ) == SIZE_2Nx2N );
    2338     assert( pcCU->getTransformIdx(absPartIdx) == 0 );
    2339     assert( pcCU->getCbf(absPartIdx, COMPONENT_Y) == 1 );
    2340     }
    2341 #endif
    2342   UInt uiNumSegments = 1;
    2343 #if NH_3D_DMM
    2344   uiNumSegments = isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ) ) ? 2 : 1;
    2345 #endif
    2346 
    2347   for( UInt segment = 0; segment < uiNumSegments; segment++ )
    2348   {
    2349     Pel valDeltaDC = 0;
    2350     if( symbol )
    2351     {
    2352       xParseDeltaDC( valDeltaDC, uiNumSegments );
    2353     }
    2354 
    2355     if( pcCU->isIntra( absPartIdx ) )
    2356     {
    2357 #if NH_3D_SDC_INTRA
    2358       if( pcCU->getSDCFlag( absPartIdx ) )
    2359       {
    2360         pcCU->setSDCSegmentDCOffset( valDeltaDC, segment, absPartIdx );
    2361       }
    2362       else
    2363       {
    2364 #endif
    2365 #if NH_3D_DMM
    2366         pcCU->setDmmDeltaDC( getDmmType( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ) ), segment, absPartIdx, valDeltaDC );
    2367 #endif
    2368 #if NH_3D_SDC_INTRA
    2369       }
    2370 #endif
    2371     }
    2372 #if NH_3D_SDC_INTER
    2373     else
    2374     {
    2375       pcCU->setSDCSegmentDCOffset( valDeltaDC, segment, absPartIdx );
    2376     }
    2377 #endif
    2378   }
    2379 }
    2380 
    2381 Void TDecSbac::xParseDeltaDC( Pel& rValDeltaDC, UInt uiNumSeg )
    2382 {
    2383   UInt absValDeltaDC = 0;
    2384   xReadExGolombLevelDdc( absValDeltaDC );
    2385   rValDeltaDC = (Pel)absValDeltaDC + ( uiNumSeg > 1 ? 0 : 1 );
    2386 
    2387   if( rValDeltaDC != 0 )
    2388   {
    2389     UInt uiSign;
    2390     m_pcTDecBinIf->decodeBinEP( uiSign RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTADC_SIGN_EP) );
    2391     if ( uiSign )
    2392     {
    2393       rValDeltaDC = -rValDeltaDC;
    2394     }
    2395   }
    2396 #if NH_MV_ENC_DEC_TRAC
    2397   DTRACE_CU("delta_dc", rValDeltaDC);
    2398 #endif
    2399 }
    2400 
    2401 Void TDecSbac::xReadExGolombLevelDdc( UInt& ruiSymbol )
    2402 {
    2403   UInt uiSymbol;
    2404   UInt uiCount = 0;
    2405   do
    2406   {
    2407     m_pcTDecBinIf->decodeBin( uiSymbol, m_cDdcDataSCModel.get(0, 0, 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTADC_PREFIX) );
    2408     uiCount++;
    2409   }
    2410   while( uiSymbol && ( uiCount != 3 ) );
    2411   ruiSymbol = uiCount - 1;
    2412 
    2413   if( uiSymbol )
    2414   {
    2415     xReadEpExGolomb( uiSymbol, 0 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTADC_SUFFIX_EP) );
    2416     ruiSymbol += uiSymbol + 1;
    2417   }
    2418 
    2419   return;
    2420 }
    2421 #endif
    2422 #if NH_3D_DMM
    2423 Void TDecSbac::xParseIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx, UInt depth )
    2424 {
    2425   pcCU->setIntraDirSubParts( CHANNEL_TYPE_LUMA, 0, absPartIdx, depth );
    2426 
    2427   UInt uiSymbol;
    2428   if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed
    2429   {
    2430     m_pcTDecBinIf->decodeBin( uiSymbol, m_cNotDmmFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__NOTDMM_FLAG) );
    2431   }
    2432   else
    2433   {
    2434     uiSymbol = 1;
    2435   }
    2436 
    2437   //decode DMM mode index
    2438   if( !uiSymbol )
    2439   {
    2440     if( pcCU->getSlice()->getIntraSdcWedgeFlag() && pcCU->getSlice()->getIntraContourFlag() )
    2441     {
    2442       m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DMMMODE) );
    2443       if( !uiSymbol )
    2444       {
    2445         pcCU->setIntraDirSubParts( CHANNEL_TYPE_LUMA, DMM_OFFSET, absPartIdx, depth );
    2446       }
    2447       else
    2448       {
    2449         pcCU->setIntraDirSubParts( CHANNEL_TYPE_LUMA, ( 1+ DMM_OFFSET ), absPartIdx, depth );
    2450       }
    2451     }
    2452     else if( pcCU->getSlice()->getIntraSdcWedgeFlag() )
    2453     {
    2454       pcCU->setIntraDirSubParts( CHANNEL_TYPE_LUMA, DMM_OFFSET, absPartIdx, depth );
    2455     }
    2456     else if( pcCU->getSlice()->getIntraContourFlag() )
    2457     {
    2458       pcCU->setIntraDirSubParts( CHANNEL_TYPE_LUMA, ( 1+ DMM_OFFSET ), absPartIdx, depth );
    2459     }
    2460   }
    2461 }
    2462 
    2463 Void TDecSbac::xParseDmmData( TComDataCU* pcCU, UInt absPartIdx, UInt depth )
    2464 {
    2465   UInt dir = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx );
    2466   switch( getDmmType( dir ) )
    2467   {
    2468   case( DMM1_IDX ):
    2469     {
    2470       UInt uiTabIdx = 0;
    2471       xParseDmm1WedgeIdx( uiTabIdx, g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] );
    2472       assert( uiTabIdx < getWedgeListScaled( pcCU->getWidth( absPartIdx ) )->size() );
    2473       pcCU->setDmm1WedgeTabIdxSubParts( uiTabIdx, absPartIdx, depth );
    2474     } break;
    2475   case( DMM4_IDX ): break;
    2476   default: break;
    2477   }
    2478 }
    2479 
    2480 Void TDecSbac::xParseDmm1WedgeIdx( UInt& ruiTabIdx, Int iNumBit )
    2481 {
    2482   UInt uiSymbol, uiIdx = 0;
    2483   for( Int i = 0; i < iNumBit; i++ )
    2484   {
    2485     m_pcTDecBinIf->decodeBinEP( uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DMM1_BITS_EP) );
    2486     uiIdx += uiSymbol << i;
    2487   }
    2488   ruiTabIdx = uiIdx;
    2489 }
    2490 #endif
    2491 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    2492 Void TDecSbac::parseSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    2493 {
    2494   UInt uiSymbol = 0;
    2495 
    2496   m_pcTDecBinIf->decodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SDC_INTRA_FLAG) );
    2497 #if NH_MV_ENC_DEC_TRAC
    2498   DTRACE_CU("dc_only_flag", uiSymbol)
    2499 #endif
    2500   if( uiSymbol )
    2501   {
    2502     pcCU->setSDCFlagSubParts( true, uiAbsPartIdx, uiDepth );
    2503     pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth );
    2504     pcCU->setCbfSubParts(1, COMPONENT_Y, uiAbsPartIdx, uiDepth);
    2505   }
    2506   else
    2507   {
    2508     pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth );
    2509   }
    2510 }
    2511 
    2512 #endif
    2513 
    2514 #if NH_3D_DBBP
    2515 Void TDecSbac::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    2516 {
    2517   AOF( pcCU->getSlice()->getDepthBasedBlkPartFlag() );
    2518   AOF( !pcCU->getSlice()->getIsDepth() );
    2519  
    2520   UInt uiSymbol = 0;
    2521  
    2522   m_pcTDecBinIf->decodeBin( uiSymbol, m_cDBBPFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DBBP_FLAG) );
    2523   DTRACE_CU("dbbp_flag", uiSymbol)
    2524   PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
    2525   AOF( ePartSize == SIZE_2NxN || ePartSize == SIZE_Nx2N );
    2526   UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
    2527   pcCU->setDBBPFlagSubParts(uiSymbol, uiAbsPartIdx, 0, uiDepth);
    2528   pcCU->setDBBPFlagSubParts(uiSymbol, uiAbsPartIdx+uiPUOffset, 1, uiDepth);
    2529 }
    2530 #endif
     2007
     2008
     2009
    25312010
    25322011
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/TDecSbac.h

    r1321 r1390  
    108108  Void  xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam, const Bool useLimitedPrefixLength, const Int maxLog2TrDynamicRange );
    109109#endif
    110 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    111   Void  xReadExGolombLevelDdc( UInt& ruiSymbol );
    112   Void  xParseDeltaDC        ( Pel& rValDeltaDC, UInt uiNumSeg );
    113 #endif
    114 #if NH_3D_DMM
    115   Void  xParseIntraDepthMode ( TComDataCU* pcCU, UInt absPartIdx, UInt depth );
    116   Void  xParseDmmData        ( TComDataCU* pcCU, UInt absPartIdx, UInt depth );
    117   Void  xParseDmm1WedgeIdx   ( UInt& ruiTabIdx, Int iNumBit );
    118 #endif
    119 #if NH_3D_SDC_INTRA
    120   Void  xParseSDCResidualData     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart );
    121 #endif
    122 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    123   Void  parseSDCFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    124 #endif
    125 #if NH_3D_DBBP
    126   Void parseDBBPFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    127 #endif
    128110
    129111private:
     
    134116
    135117  Void parseSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    136 #if NH_3D_DIS
    137   Void parseDIS          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    138 #endif
    139 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    140   Void  parseDeltaDC      ( TComDataCU* pcCU, UInt absPartIdx, UInt depth );
    141 #endif
    142118  Void parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    143119  Void parseSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    144120  Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
    145121  Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex );
    146 #if NH_3D_ARP
    147   Void parseARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    148 #endif
    149 #if NH_3D_IC
    150   Void parseICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    151 #endif
    152122  Void parsePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    153123  Void parsePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     
    183153  ContextModel3DBuffer m_cCUSplitFlagSCModel;
    184154  ContextModel3DBuffer m_cCUSkipFlagSCModel;
    185 #if NH_3D_DIS
    186   ContextModel3DBuffer m_cCUDISFlagSCModel;
    187   ContextModel3DBuffer m_cCUDISTypeSCModel;
    188 #endif
    189155  ContextModel3DBuffer m_cCUMergeFlagExtSCModel;
    190156  ContextModel3DBuffer m_cCUMergeIdxExtSCModel;
    191 #if NH_3D_ARP
    192   ContextModel3DBuffer m_cCUPUARPWSCModel;
    193 #endif
    194 #if NH_3D_IC
    195   ContextModel3DBuffer m_cCUICFlagSCModel;
    196 #endif
    197157  ContextModel3DBuffer m_cCUPartSizeSCModel;
    198158  ContextModel3DBuffer m_cCUPredModeSCModel;
     
    226186  ContextModel3DBuffer m_ChromaQpAdjFlagSCModel;
    227187  ContextModel3DBuffer m_ChromaQpAdjIdcSCModel;
    228 #if NH_3D_DMM
    229   ContextModel3DBuffer m_cNotDmmFlagSCModel;
    230   ContextModel3DBuffer m_cDmmModeSCModel;
    231 #endif
    232 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    233   ContextModel3DBuffer m_cDdcDataSCModel;
    234   ContextModel3DBuffer m_cSDCFlagSCModel;
    235 #endif
    236 #if NH_3D_SDC_INTRA 
    237   ContextModel3DBuffer m_cSDCResidualFlagSCModel;
    238   ContextModel3DBuffer m_cSDCResidualSCModel;
    239   ContextModel3DBuffer m_cDdcFlagSCModel;
    240 #endif
    241 #if NH_3D_DBBP
    242   ContextModel3DBuffer m_cDBBPFlagSCModel;
    243 #endif
    244188
    245189
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/TDecSlice.cpp

    r1386 r1390  
    130130    }
    131131  }
    132 #if  NH_3D_DLT
    133   if( pcSlice->getPPS()->getDLT() != NULL )
    134   {
    135       assert( pcSlice->getSPS()->getBitDepth( CHANNEL_TYPE_LUMA ) == pcSlice->getPPS()->getDLT()->getDepthViewBitDepth() );
    136   }
    137 #endif
    138132
    139133  // for every CTU in the slice segment...
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/TDecTop.cpp

    r1386 r1390  
    4444//! \{
    4545
    46 #if NH_3D
    47 CamParsCollector::CamParsCollector()
    48 : m_bInitialized( false )
    49 {
    50   m_aaiCodedOffset         = new Int* [ MAX_NUM_LAYERS ];
    51   m_aaiCodedScale          = new Int* [ MAX_NUM_LAYERS ];
    52   for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ )
    53   {
    54     m_aaiCodedOffset      [ uiId ] = new Int [ MAX_NUM_LAYERS ];
    55     m_aaiCodedScale       [ uiId ] = new Int [ MAX_NUM_LAYERS ];
    56   }
    57 
    58   xCreateLUTs( (UInt)MAX_NUM_LAYERS, (UInt)MAX_NUM_LAYERS, m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
    59   m_iLog2Precision   = LOG2_DISP_PREC_LUT;
    60   m_uiBitDepthForLUT = 8; // fixed
    61   m_receivedIdc = NULL;
    62   m_vps         = NULL;
    63 }
    64 
    65 CamParsCollector::~CamParsCollector()
    66 {
    67   for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ )
    68   {
    69     delete [] m_aaiCodedOffset      [ uiId ];
    70     delete [] m_aaiCodedScale       [ uiId ];
    71   }
    72   delete [] m_aaiCodedOffset;
    73   delete [] m_aaiCodedScale;
    74 
    75   xDeleteArray( m_adBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 );
    76   xDeleteArray( m_aiBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 );
    77   if ( m_receivedIdc != NULL )
    78   {
    79     xDeleteArray( m_receivedIdc, m_vps->getNumViews() );
    80   }
    81 }
    82 
    83 
    84 Void
    85 CamParsCollector::init( const TComVPS* vps)
    86 {
    87   assert( !isInitialized() ); // Only one initialization currently supported
    88   m_bInitialized            = true;
    89   m_vps                     = vps;
    90   m_bCamParsVaryOverTime    = false;
    91   m_lastPoc                 = -1;
    92   m_firstReceivedPoc        = -2;
    93 
    94   for (Int i = 0; i <= vps->getMaxLayersMinus1(); i++)
    95   {
    96     Int curViewIdxInVps = m_vps->getVoiInVps( m_vps->getViewIndex( m_vps->getLayerIdInNuh( i ) ) ) ;
    97     m_bCamParsVaryOverTime = m_bCamParsVaryOverTime || vps->getCpInSliceSegmentHeaderFlag( curViewIdxInVps );
    98   }
    99 
    100   assert( m_receivedIdc == NULL );
    101   m_receivedIdc = new Int*[ m_vps->getNumViews() ];
    102   for (Int i = 0; i < m_vps->getNumViews(); i++)
    103   {
    104     m_receivedIdc[i] = new Int[ m_vps->getNumViews() ];
    105   }
    106 
    107   xResetReceivedIdc( true );
    108 
    109   for (Int voiInVps = 0; voiInVps < m_vps->getNumViews(); voiInVps++ )
    110   {
    111     if( !m_vps->getCpInSliceSegmentHeaderFlag( voiInVps ) )
    112     {
    113       for (Int baseVoiInVps = 0; baseVoiInVps < m_vps->getNumViews(); baseVoiInVps++ )
    114       {
    115         if( m_vps->getCpPresentFlag( voiInVps, baseVoiInVps ) )
    116         {
    117           m_receivedIdc   [ baseVoiInVps ][ voiInVps ] = -1;
    118           m_aaiCodedScale [ baseVoiInVps ][ voiInVps ] = m_vps->getCodedScale    (voiInVps) [ baseVoiInVps ];
    119           m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ] = m_vps->getCodedOffset   (voiInVps) [ baseVoiInVps ];
    120 
    121           m_receivedIdc   [ voiInVps ][ baseVoiInVps ] = -1;
    122           m_aaiCodedScale [ voiInVps ][ baseVoiInVps ] = m_vps->getInvCodedScale (voiInVps) [ baseVoiInVps ];
    123           m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ] = m_vps->getInvCodedOffset(voiInVps) [ baseVoiInVps ];
    124           xInitLUTs( baseVoiInVps, voiInVps, m_aaiCodedScale[ baseVoiInVps ][ voiInVps ], m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
    125           xInitLUTs( voiInVps, baseVoiInVps, m_aaiCodedScale[ voiInVps ][ baseVoiInVps ], m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
    126         }
    127       }
    128     }
    129   }
    130 }
    131 
    132 Void
    133 CamParsCollector::xResetReceivedIdc( Bool overWriteFlag )
    134 {
    135   for (Int i = 0; i < m_vps->getNumViews(); i++)
    136   {
    137     for (Int j = 0; j < m_vps->getNumViews(); j++)
    138     {
    139       if ( overWriteFlag ||  ( m_receivedIdc[i][j] != -1 ) )
    140       {
    141         m_receivedIdc[i][j] = 0;
    142       }
    143     }
    144   }
    145 }
    146 
    147 
    148 Void
    149 CamParsCollector::xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT)
    150 {
    151 
    152   uiNumberSourceViews = std::max( (UInt) 1, uiNumberSourceViews );
    153   uiNumberTargetViews = std::max( (UInt) 1, uiNumberTargetViews );
    154 
    155   radLUT         = new Double***[ uiNumberSourceViews ];
    156   raiLUT         = new Int   ***[ uiNumberSourceViews ];
    157 
    158   for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ )
    159   {
    160     radLUT        [ uiSourceView ] = new Double**[ uiNumberTargetViews ];
    161     raiLUT        [ uiSourceView ] = new Int   **[ uiNumberTargetViews ];
    162 
    163     for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ )
    164     {
    165       radLUT        [ uiSourceView ][ uiTargetView ]      = new Double*[ 2 ];
    166       radLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ];
    167       radLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ];
    168 
    169       raiLUT        [ uiSourceView ][ uiTargetView ]      = new Int*   [ 2 ];
    170       raiLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Int    [ 257 ];
    171       raiLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Int    [ 257 ];
    172     }
    173   }
    174 }
    175 
    176 Void
    177   CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT)
    178 {
    179   Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_vps->getCpPrecision() + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
    180   Int     iLog2DivChroma = iLog2DivLuma + 1;
    181 
    182   iOffset <<= m_uiBitDepthForLUT;
    183 
    184   Double dScale  = (Double) iScale  / (( Double ) ( 1 << iLog2DivLuma ));
    185   Double dOffset = (Double) iOffset / (( Double ) ( 1 << iLog2DivLuma ));
    186 
    187   // offsets including rounding offsets
    188   Int64 iOffsetLuma   = iOffset + ( ( 1 << iLog2DivLuma   ) >> 1 );
    189   Int64 iOffsetChroma = iOffset + ( ( 1 << iLog2DivChroma ) >> 1 );
    190 
    191 
    192   for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ )
    193   {
    194 
    195     // real-valued look-up tables
    196     Double  dShiftLuma      = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
    197     Double  dShiftChroma    = dShiftLuma / 2;
    198     radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma;
    199     radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = dShiftChroma;
    200 
    201     // integer-valued look-up tables
    202     Int64   iTempScale      = (Int64)uiDepthValue * iScale;
    203     Int64   iShiftLuma      = ( iTempScale + iOffsetLuma   ) >> iLog2DivLuma;
    204     Int64   iShiftChroma    = ( iTempScale + iOffsetChroma ) >> iLog2DivChroma;
    205     raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = (Int)iShiftLuma;
    206     raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = (Int)iShiftChroma;
    207   }
    208 
    209   radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
    210   radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
    211   raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
    212   raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
    213 }
    214 
    215 Void
    216 CamParsCollector::uninit()
    217 {
    218   m_bInitialized = false;
    219 }
    220 
    221 Void CamParsCollector::setSlice( const TComSlice* pcSlice )
    222 {
    223   if( pcSlice == 0 )
    224   {
    225     xOutput( m_lastPoc );
    226     return;
    227   }
    228 
    229 #if !H_3D_FCO
    230   if ( pcSlice->getIsDepth())
    231   {
    232     return;
    233   }
    234 #endif
    235 
    236   Int curPoc = pcSlice->getPOC();
    237   if( m_firstReceivedPoc == -2 )
    238   {
    239     m_firstReceivedPoc = curPoc;
    240   }
    241 
    242   Bool newPocFlag = ( m_lastPoc != curPoc );
    243 
    244   if ( newPocFlag )
    245   {
    246     if( m_lastPoc != -1 )
    247     {
    248       xOutput( m_lastPoc );
    249     }
    250 
    251     xResetReceivedIdc( false );
    252     m_lastPoc = pcSlice->getPOC();
    253   }
    254 
    255   UInt voiInVps          = m_vps->getVoiInVps(pcSlice->getViewIndex());
    256   if( m_vps->getCpInSliceSegmentHeaderFlag( voiInVps ) ) // check consistency of slice parameters here
    257   {
    258     for( Int baseVoiInVps = 0; baseVoiInVps < m_vps->getNumViews(); baseVoiInVps++ )
    259     {
    260       if ( m_vps->getCpPresentFlag( voiInVps, baseVoiInVps ) )
    261       {
    262         if ( m_receivedIdc[ voiInVps ][ baseVoiInVps ] != 0 )
    263         {
    264           AOF( m_aaiCodedScale [ voiInVps ][ baseVoiInVps ] == pcSlice->getInvCodedScale () [ baseVoiInVps ] );
    265           AOF( m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ] == pcSlice->getInvCodedOffset() [ baseVoiInVps ] );
    266         }
    267         else
    268         {
    269           m_receivedIdc   [ voiInVps ][ baseVoiInVps ]  = 1;
    270           m_aaiCodedScale [ voiInVps ][ baseVoiInVps ]  = pcSlice->getInvCodedScale () [ baseVoiInVps ];
    271           m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ]  = pcSlice->getInvCodedOffset() [ baseVoiInVps ];
    272           xInitLUTs( voiInVps, baseVoiInVps, m_aaiCodedScale[ voiInVps ][ baseVoiInVps ], m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
    273         }
    274         if ( m_receivedIdc[ baseVoiInVps ][ voiInVps ] != 0 )
    275         {
    276           AOF( m_aaiCodedScale [ baseVoiInVps ][ voiInVps ] == pcSlice->getCodedScale    () [ baseVoiInVps ] );
    277           AOF( m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ] == pcSlice->getCodedOffset   () [ baseVoiInVps ] );
    278         }
    279         else
    280         {
    281           m_receivedIdc   [ baseVoiInVps ][ voiInVps ]  = 1;
    282           m_aaiCodedScale [ baseVoiInVps ][ voiInVps ]  = pcSlice->getCodedScale    () [ baseVoiInVps ];
    283           m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ]  = pcSlice->getCodedOffset   () [ baseVoiInVps ];
    284           xInitLUTs( baseVoiInVps, voiInVps, m_aaiCodedScale[ baseVoiInVps ][ voiInVps ], m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
    285         }
    286       }
    287     }
    288   }
    289 }
    290 
    291 Void
    292 CamParsCollector::xOutput( Int iPOC )
    293 {
    294   if( m_pCodedScaleOffsetFile )
    295   {
    296     if( iPOC == m_firstReceivedPoc )
    297     {
    298       fprintf( m_pCodedScaleOffsetFile, "#ViewOrderIdx     ViewIdVal\n" );
    299       fprintf( m_pCodedScaleOffsetFile, "#------------ -------------\n" );
    300 
    301       for( UInt voiInVps = 0; voiInVps < m_vps->getNumViews(); voiInVps++ )
    302       {
    303         fprintf( m_pCodedScaleOffsetFile, "%13d %13d\n", m_vps->getViewOIdxList( voiInVps ), m_vps->getViewIdVal( m_vps->getViewOIdxList( voiInVps ) ) );
    304       }
    305       fprintf( m_pCodedScaleOffsetFile, "\n\n");
    306       fprintf( m_pCodedScaleOffsetFile, "# StartFrame     EndFrame    TargetVOI      BaseVOI   CodedScale  CodedOffset    Precision\n" );
    307       fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" );
    308     }
    309     if( iPOC == m_firstReceivedPoc || m_bCamParsVaryOverTime  )
    310     {
    311       Int iS = iPOC;
    312       Int iE = ( m_bCamParsVaryOverTime ? iPOC : ~( 1 << 31 ) );
    313       for( UInt voiInVps = 0; voiInVps < m_vps->getNumViews(); voiInVps++ )
    314       {
    315         for( UInt baseVoiInVps = 0; baseVoiInVps < m_vps->getNumViews(); baseVoiInVps++ )
    316         {
    317           if( voiInVps != baseVoiInVps )
    318           {
    319             if ( m_receivedIdc[baseVoiInVps][voiInVps] != 0 )
    320             {
    321               fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n",
    322                 iS, iE, m_vps->getViewOIdxList( voiInVps ), m_vps->getViewOIdxList( baseVoiInVps ),
    323                 m_aaiCodedScale [ baseVoiInVps ][ voiInVps ],
    324                 m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ], m_vps->getCpPrecision() );
    325             }
    326           }
    327         }
    328       }
    329     }
    330   }
    331 }
    332 #endif
    33346
    33447
     
    393106  m_viewId                        = 0;
    394107
    395 #if NH_3D
    396   m_viewIndex                     = 0;
    397   m_isDepth                       = false;
    398   m_pcCamParsCollector            = 0;
    399 #endif
    400108
    401109  m_decodingProcess               = CLAUSE_8;
     
    735443#endif
    736444
    737 #if NH_3D
    738     if ( !m_pcCamParsCollector->isInitialized() )
    739     {
    740       m_pcCamParsCollector->init( vps );
    741     }
    742 #endif
    743445    // Initialise the various objects for the new set of settings
    744446    m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxTotalCUDepth(), pps->getPpsRangeExtension().getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), pps->getPpsRangeExtension().getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA) );
     
    1063765    m_pcPic->setLayerId( nalu.m_nuhLayerId );
    1064766    m_pcPic->setViewId ( getViewId() );
    1065 #if NH_3D
    1066     m_pcPic->setViewIndex( getViewIndex() );
    1067     m_pcPic->setIsDepth  ( getIsDepth  () );
    1068     pcSlice->setIvPicLists( m_dpb );
    1069 #endif
    1070767#endif
    1071768
     
    1105802        }
    1106803      }
    1107 #if NH_3D_NBDV
    1108       pcSlice->setDefaultRefView();
    1109 #endif
    1110 #if NH_3D_ARP
    1111       pcSlice->setPocsInCurrRPSs();
    1112       pcSlice->setARPStepNum(m_dpb);
    1113 #endif
    1114804#endif
    1115805
     
    1155845      //---------------
    1156846      pcSlice->setRefPOCList();
    1157 #if  NH_3D_TMVP
    1158       if(pcSlice->getLayerId())
    1159       {
    1160         pcSlice->generateAlterRefforTMVP();
    1161       }
    1162 #endif
    1163847    }
    1164848
     
    1193877    }
    1194878
    1195 #if NH_3D
    1196     if ( decProcAnnexI() )
    1197     {
    1198       pcSlice->checkInCompPredRefLayers();
    1199     }
    1200 #endif
    1201879
    1202880    //  Decode a picture
    1203881    m_cGopDecoder.decompressSlice(&(nalu.getBitstream()), m_pcPic);
    1204882
    1205 #if NH_3D
    1206     if( m_pcCamParsCollector )
    1207     {
    1208       m_pcCamParsCollector->setSlice( pcSlice );
    1209     }
    1210 #endif
    1211883
    1212884#if !NH_MV
     
    1240912  sps->setForceDecodeBitDepth(m_forceDecodeBitDepth);
    1241913#endif
    1242 #if NH_3D
    1243   // GT: Please don't add parsing dependency of SPS from VPS here again!!!
    1244 #endif
    1245914  m_cEntropyDecoder.decodeSPS( sps );
    1246915  m_parameterSetManager.storeSPS(sps, naluData);
     
    1252921#if NH_MV
    1253922  pps->setLayerId( getLayerId() );
    1254 #endif
    1255 #if NH_3D_DLT
    1256   // create mapping from depth layer indexes to layer ids
    1257   Int j=0;
    1258   for( Int i=0; i<=m_parameterSetManager.getFirstVPS()->getMaxLayersMinus1(); i++ )
    1259   {
    1260     Int layerId = m_parameterSetManager.getFirstVPS()->getLayerIdInNuh(i);
    1261     if( m_parameterSetManager.getFirstVPS()->getDepthId(layerId) )
    1262       pps->getDLT()->setDepthIdxToLayerId(j++, layerId);
    1263   }
    1264923#endif
    1265924  m_cEntropyDecoder.decodePPS( pps );
     
    18061465{
    18071466  setViewId   ( vps->getViewId   ( getLayerId() )      );
    1808 #if NH_3D
    1809   setViewIndex( vps->getViewIndex( getLayerId() )      );
    1810   setIsDepth  ( vps->getDepthId  ( getLayerId() ) == 1 );
    1811 #endif
    18121467
    18131468  if ( !vps->getVpsExtensionFlag() )
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibDecoder/TDecTop.h

    r1321 r1390  
    6565class TAppDecTop;
    6666#endif
    67 #if NH_3D
    68 class CamParsCollector
    69 {
    70 public:
    71   CamParsCollector  ();
    72   ~CamParsCollector ();
    73 
    74   Void  init        ( const TComVPS* vps );
    75   Void  setCodeScaleOffsetFile( FILE* pCodedScaleOffsetFile ) { m_pCodedScaleOffsetFile = pCodedScaleOffsetFile; };     
    76 
    77   Void  uninit      ();
    78   Void setSlice ( const TComSlice* pcSlice );
    79 
    80   Bool  isInitialized() const     { return m_bInitialized; }
    81   Int**** getBaseViewShiftLUTI()  { return m_aiBaseViewShiftLUT;   }
    82 
    83 private:
    84   Void xResetReceivedIdc( Bool overWriteFlag );
    85   Void  xOutput     ( Int iPOC );
    86 
    87 private:
    88   Bool    m_bInitialized;
    89   FILE*   m_pCodedScaleOffsetFile;
    90 
    91   Int**   m_aaiCodedOffset;
    92   Int**   m_aaiCodedScale;
    93  
    94   const TComVPS* m_vps;
    95   Int**    m_receivedIdc;
    96   Int      m_lastPoc;
    97   Int      m_firstReceivedPoc;
    98 
    99  
    100   Bool    m_bCamParsVaryOverTime;
    101 
    102   UInt    m_uiBitDepthForLUT;
    103   UInt    m_iLog2Precision;
    104   // UInt    m_uiInputBitDepth;
    105 
    106   // look-up tables
    107   Double****   m_adBaseViewShiftLUT;       ///< Disparity LUT
    108   Int****      m_aiBaseViewShiftLUT;       ///< Disparity LUT
    109   Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT);
    110   Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT);
    111   template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 );
    112   template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2 );
    113   template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize );
    114 
    115 };
    116 
    117 template <class T>
    118 Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 )
    119 {
    120   if( rpt )
    121   {
    122     for( UInt uiK = 0; uiK < uiSize1; uiK++ )
    123     {
    124       for( UInt uiL = 0; uiL < uiSize2; uiL++ )
    125       {
    126         for( UInt uiM = 0; uiM < uiSize3; uiM++ )
    127         {
    128           delete[] rpt[ uiK ][ uiL ][ uiM ];
    129         }
    130         delete[] rpt[ uiK ][ uiL ];
    131       }
    132       delete[] rpt[ uiK ];
    133     }
    134     delete[] rpt;
    135   }
    136   rpt = NULL;
    137 };
    138 
    139 
    140 template <class T>
    141 Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 )
    142 {
    143   if( rpt )
    144   {
    145     for( UInt uiK = 0; uiK < uiSize1; uiK++ )
    146     {
    147       for( UInt uiL = 0; uiL < uiSize2; uiL++ )
    148       {
    149         delete[] rpt[ uiK ][ uiL ];
    150       }
    151       delete[] rpt[ uiK ];
    152     }
    153     delete[] rpt;
    154   }
    155   rpt = NULL;
    156 };
    157 
    158 
    159 template <class T>
    160 Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize )
    161 {
    162   if( rpt )
    163   {
    164     for( UInt uiK = 0; uiK < uiSize; uiK++ )
    165     {
    166       delete[] rpt[ uiK ];
    167     }
    168     delete[] rpt;
    169   }
    170   rpt = NULL;
    171 };
    172 
    173 #endif //NH_3D
    17467/// decoder class
    17568class TDecTop
     
    240133  static ParameterSetManager  m_parameterSetManager;  // storage for parameter sets
    241134  TComPicLists*           m_dpb;
    242 #if NH_3D
    243   CamParsCollector*       m_pcCamParsCollector;
    244 #endif
    245135
    246136  // Layer identification
    247137  Int                     m_layerId;
    248138  Int                     m_viewId;
    249 #if NH_3D                 
    250   Int                     m_viewIndex;
    251   Bool                    m_isDepth;
    252 #endif
    253139
    254140  // Layer set
     
    349235  Void       setViewId             ( Int viewId )      { m_viewId  = viewId;  }
    350236  Int        getViewId             ( )                 { return m_viewId;     } 
    351 #if NH_3D   
    352   Void       setViewIndex          ( Int viewIndex )   { m_viewIndex  = viewIndex;  }
    353   Int        getViewIndex          ( )                 { return m_viewIndex;     } 
    354   Void       setIsDepth            ( Bool isDepth )    { m_isDepth = isDepth; }
    355   Bool       getIsDepth            ( )                 { return m_isDepth;    }
    356 #endif
    357237
    358238  // Classes
    359239  Void       setDpb                ( TComPicLists* picLists) { m_dpb = picLists; }
    360 #if NH_3D                                       
    361   Void       setCamParsCollector   ( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
    362 #endif
    363240
    364241  // Slice pilot access
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/SEIwrite.cpp

    r1386 r1390  
    172172     xWriteSEIMultiviewViewPosition(*static_cast<const SEIMultiviewViewPosition*>(&sei));
    173173     break;
    174 #if NH_3D
    175    case SEI::ALTERNATIVE_DEPTH_INFO:
    176      xWriteSEIAlternativeDepthInfo(*static_cast<const SEIAlternativeDepthInfo*>(&sei));
    177      break;
    178 #endif
    179174#endif
    180175
     
    12951290};
    12961291
    1297 #if NH_3D
    1298 Void SEIWriter::xWriteSEIAlternativeDepthInfo( const SEIAlternativeDepthInfo& sei)
    1299 {
    1300   WRITE_FLAG( ( sei.m_alternativeDepthInfoCancelFlag ? 1 : 0 ), "alternative_depth_info_cancel_flag" );
    1301   if( sei.m_alternativeDepthInfoCancelFlag  ==  0 )
    1302   {
    1303     WRITE_CODE( sei.m_depthType, 2, "depth_type" );
    1304 
    1305     if( sei.m_depthType  ==  0 )
    1306     {
    1307       WRITE_UVLC( sei.m_numConstituentViewsGvdMinus1, "num_constituent_views_gvd_minus1" );
    1308       WRITE_FLAG( ( sei.m_depthPresentGvdFlag ? 1 : 0 ), "depth_present_gvd_flag" );
    1309       WRITE_FLAG( ( sei.m_zGvdFlag ? 1 : 0 ), "z_gvd_flag" );
    1310       WRITE_FLAG( ( sei.m_intrinsicParamGvdFlag ? 1 : 0 ), "intrinsic_param_gvd_flag" );
    1311       WRITE_FLAG( ( sei.m_rotationGvdFlag ? 1 : 0 ), "rotation_gvd_flag" );
    1312       WRITE_FLAG( ( sei.m_translationGvdFlag ? 1 : 0 ), "translation_gvd_flag" );
    1313       if( sei.m_zGvdFlag )
    1314       {
    1315         for( Int i = 0, j = 0; j  <=  sei.m_numConstituentViewsGvdMinus1 + 1; j++ )
    1316         {
    1317           WRITE_FLAG( ( sei.m_signGvdZNearFlag[i][j] ? 1 : 0 ), "sign_gvd_z_near_flag" );
    1318           WRITE_CODE( sei.m_expGvdZNear[i][j], 7, "exp_gvd_z_near" );
    1319           WRITE_CODE( sei.m_manLenGvdZNearMinus1[i][j], 5, "man_len_gvd_z_near_minus1" );
    1320           WRITE_CODE( sei.m_manGvdZNear[i][j], sei.m_manLenGvdZNearMinus1[i][j] + 1, "man_gvd_z_near" );
    1321           WRITE_FLAG( ( sei.m_signGvdZFarFlag[i][j] ? 1 : 0 ), "sign_gvd_z_far_flag" );
    1322           WRITE_CODE( sei.m_expGvdZFar[i][j], 7, "exp_gvd_z_far" );
    1323           WRITE_CODE( sei.m_manLenGvdZFarMinus1[i][j], 5, "man_len_gvd_z_far_minus1" );
    1324           WRITE_CODE( sei.m_manGvdZFar[i][j], sei.m_manLenGvdZFarMinus1[i][j] + 1, "man_gvd_z_far" );
    1325         }
    1326       }
    1327       if( sei.m_intrinsicParamGvdFlag )
    1328       {
    1329         WRITE_UVLC( sei.m_precGvdFocalLength, "prec_gvd_focal_length" );
    1330         WRITE_UVLC( sei.m_precGvdPrincipalPoint, "prec_gvd_principal_point" );
    1331       }
    1332       if( sei.m_rotationGvdFlag )
    1333       {
    1334         WRITE_UVLC( sei.m_precGvdRotationParam, "prec_gvd_rotation_param" );
    1335       }
    1336       if( sei.m_translationGvdFlag )
    1337       {
    1338         WRITE_UVLC( sei.m_precGvdTranslationParam, "prec_gvd_translation_param" );
    1339       }
    1340       for( Int i = 0, j = 0; j  <=  sei.m_numConstituentViewsGvdMinus1 + 1; j++ )
    1341       {
    1342         if( sei.m_intrinsicParamGvdFlag )
    1343         {
    1344           WRITE_FLAG( ( sei.m_signGvdFocalLengthX[i][j] ? 1 : 0 ), "sign_gvd_focal_length_x" );
    1345           WRITE_CODE( sei.m_expGvdFocalLengthX[i][j], 6, "exp_gvd_focal_length_x" );
    1346           WRITE_CODE( sei.m_manGvdFocalLengthX[i][j], sei.getManGvdFocalLengthXLen(i,j), "man_gvd_focal_length_x" );
    1347           WRITE_FLAG( ( sei.m_signGvdFocalLengthY[i][j] ? 1 : 0 ), "sign_gvd_focal_length_y" );
    1348           WRITE_CODE( sei.m_expGvdFocalLengthY[i][j], 6, "exp_gvd_focal_length_y" );
    1349           WRITE_CODE( sei.m_manGvdFocalLengthY[i][j], sei.getManGvdFocalLengthYLen(i,j), "man_gvd_focal_length_y" );
    1350           WRITE_FLAG( ( sei.m_signGvdPrincipalPointX[i][j] ? 1 : 0 ), "sign_gvd_principal_point_x" );
    1351           WRITE_CODE( sei.m_expGvdPrincipalPointX[i][j], 6, "exp_gvd_principal_point_x" );
    1352           WRITE_CODE( sei.m_manGvdPrincipalPointX[i][j], sei.getManGvdPrincipalPointXLen(i,j), "man_gvd_principal_point_x" );
    1353           WRITE_FLAG( ( sei.m_signGvdPrincipalPointY[i][j] ? 1 : 0 ), "sign_gvd_principal_point_y" );
    1354           WRITE_CODE( sei.m_expGvdPrincipalPointY[i][j], 6, "exp_gvd_principal_point_y" );
    1355           WRITE_CODE( sei.m_manGvdPrincipalPointY[i][j], sei.getManGvdPrincipalPointYLen(i,j), "man_gvd_principal_point_y" );
    1356         }
    1357         if( sei.m_rotationGvdFlag )
    1358         {
    1359           WRITE_FLAG( ( sei.m_signGvdR00[i][j] ? 1 : 0 ), "sign_gvd_r00" );
    1360           WRITE_CODE( sei.m_expGvdR00[i][j], 6, "exp_gvd_r00" );
    1361           WRITE_CODE( sei.m_manGvdR00[i][j], sei.m_precGvdRotationParam, "man_gvd_r00" );
    1362           WRITE_FLAG( ( sei.m_signGvdR01[i][j] ? 1 : 0 ), "sign_gvd_r01" );
    1363           WRITE_CODE( sei.m_expGvdR01[i][j], 6, "exp_gvd_r01" );
    1364           WRITE_CODE( sei.m_manGvdR01[i][j], sei.m_precGvdRotationParam, "man_gvd_r01" );
    1365           WRITE_FLAG( ( sei.m_signGvdR02[i][j] ? 1 : 0 ), "sign_gvd_r02" );
    1366           WRITE_CODE( sei.m_expGvdR02[i][j], 6, "exp_gvd_r02" );
    1367           WRITE_CODE( sei.m_manGvdR02[i][j], sei.m_precGvdRotationParam, "man_gvd_r02" );
    1368           WRITE_FLAG( ( sei.m_signGvdR10[i][j] ? 1 : 0 ), "sign_gvd_r10" );
    1369           WRITE_CODE( sei.m_expGvdR10[i][j], 6, "exp_gvd_r10" );
    1370           WRITE_CODE( sei.m_manGvdR10[i][j], sei.m_precGvdRotationParam, "man_gvd_r10" );
    1371           WRITE_FLAG( ( sei.m_signGvdR11[i][j] ? 1 : 0 ), "sign_gvd_r11" );
    1372           WRITE_CODE( sei.m_expGvdR11[i][j], 6, "exp_gvd_r11" );
    1373           WRITE_CODE( sei.m_manGvdR11[i][j], sei.m_precGvdRotationParam, "man_gvd_r11" );
    1374           WRITE_FLAG( ( sei.m_signGvdR12[i][j] ? 1 : 0 ), "sign_gvd_r12" );
    1375           WRITE_CODE( sei.m_expGvdR12[i][j], 6, "exp_gvd_r12" );
    1376           WRITE_CODE( sei.m_manGvdR12[i][j], sei.m_precGvdRotationParam, "man_gvd_r12" );
    1377           WRITE_FLAG( ( sei.m_signGvdR20[i][j] ? 1 : 0 ), "sign_gvd_r20" );
    1378           WRITE_CODE( sei.m_expGvdR20[i][j], 6, "exp_gvd_r20" );
    1379           WRITE_CODE( sei.m_manGvdR20[i][j], sei.m_precGvdRotationParam, "man_gvd_r20" );
    1380           WRITE_FLAG( ( sei.m_signGvdR21[i][j] ? 1 : 0 ), "sign_gvd_r21" );
    1381           WRITE_CODE( sei.m_expGvdR21[i][j], 6, "exp_gvd_r21" );
    1382           WRITE_CODE( sei.m_manGvdR21[i][j], sei.m_precGvdRotationParam, "man_gvd_r21" );
    1383           WRITE_FLAG( ( sei.m_signGvdR22[i][j] ? 1 : 0 ), "sign_gvd_r22" );
    1384           WRITE_CODE( sei.m_expGvdR22[i][j], 6, "exp_gvd_r22" );
    1385           WRITE_CODE( sei.m_manGvdR22[i][j], sei.m_precGvdRotationParam, "man_gvd_r22" );
    1386         }
    1387         if( sei.m_translationGvdFlag )
    1388         {
    1389           WRITE_FLAG( ( sei.m_signGvdTX[i][j] ? 1 : 0 ), "sign_gvd_t_x" );
    1390           WRITE_CODE( sei.m_expGvdTX[i][j], 6, "exp_gvd_t_x" );
    1391           WRITE_CODE( sei.m_manGvdTX[i][j], sei.getManGvdTXLen(i,j), "man_gvd_t_x" );
    1392         }
    1393       }
    1394     }
    1395 
    1396     if( sei.m_depthType  ==  1 )
    1397     {
    1398       WRITE_SVLC( sei.m_minOffsetXInt, "min_offset_x_int" );
    1399       WRITE_CODE( sei.m_minOffsetXFrac, 8, "min_offset_x_frac" );
    1400       WRITE_SVLC( sei.m_maxOffsetXInt, "max_offset_x_int" );
    1401       WRITE_CODE( sei.m_maxOffsetXFrac, 8, "max_offset_x_frac" );
    1402       WRITE_FLAG( ( sei.m_offsetYPresentFlag ? 1 : 0 ), "offset_y_present_flag" );
    1403       if( sei.m_offsetYPresentFlag )
    1404       {
    1405         WRITE_SVLC( sei.m_minOffsetYInt, "min_offset_y_int" );
    1406         WRITE_CODE( sei.m_minOffsetYFrac, 8, "min_offset_y_frac" );
    1407         WRITE_SVLC( sei.m_maxOffsetYInt, "max_offset_y_int" );
    1408         WRITE_CODE( sei.m_maxOffsetYFrac, 8, "max_offset_y_frac" );
    1409       }
    1410       WRITE_FLAG( ( sei.m_warpMapSizePresentFlag ? 1 : 0 ), "warp_map_size_present_flag" );
    1411       if( sei.m_warpMapSizePresentFlag )
    1412       {
    1413         WRITE_UVLC( sei.m_warpMapWidthMinus2, "warp_map_width_minus2" );
    1414         WRITE_UVLC( sei.m_warpMapHeightMinus2, "warp_map_height_minus2" );
    1415       }
    1416     }
    1417   }
    1418 };
    14191292#endif
    1420 #endif
    14211293
    14221294//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/SEIwrite.h

    r1386 r1390  
    9696  Void xWriteSEIMultiviewAcquisitionInfo      ( const SEIMultiviewAcquisitionInfo& sei);
    9797  Void xWriteSEIMultiviewViewPosition         ( const SEIMultiviewViewPosition& sei);
    98 #if NH_3D
    99   Void xWriteSEIAlternativeDepthInfo          ( const SEIAlternativeDepthInfo& sei);
    100 #endif
    10198#endif
    10299
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncCavlc.cpp

    r1386 r1390  
    186186  WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" );
    187187  WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0,   "cabac_init_present_flag" );
    188 #if H_3D_PPS_FIX_DEPTH
    189   if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) )
    190   {
    191     WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive(),     "num_ref_idx_l0_default_active_minus1");
    192     WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive(),     "num_ref_idx_l1_default_active_minus1");
    193   }
    194   else
    195   {
    196 #endif
    197188  WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive()-1,     "num_ref_idx_l0_default_active_minus1");
    198189  WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive()-1,     "num_ref_idx_l1_default_active_minus1");
    199 #if H_3D_PPS_FIX_DEPTH
    200   }
    201 #endif
    202190  WRITE_SVLC( pcPPS->getPicInitQPMinus26(),                  "init_qp_minus26");
    203191  WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0,      "constrained_intra_pred_flag" );
     
    257245    codeScalingList( pcPPS->getScalingList() );
    258246  }
    259 #if H_3D_PPS_FIX_DEPTH
    260   if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) )
    261   {
    262     WRITE_FLAG( 1, "lists_modification_present_flag" );
    263   }
    264   else
    265 #endif
    266247  WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag");
    267248  WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2");
     
    379360    }
    380361
    381 #if NH_3D
    382     if( pcPPS->getPps3dExtensionFlag( )  ) // This probably needs to be aligned with Rext and SHVC
    383     {
    384       codePps3dExtension( pcPPS );
    385     }
    386 #endif
    387362#endif
    388363  xWriteRbspTrailingBits();
    389364}
    390365
    391 #if NH_3D
    392 Void  TEncCavlc::codePps3dExtension        ( const TComPPS* pcPPS )
    393 {
    394 #if NH_3D_DLT
    395   WRITE_FLAG( pcPPS->getDLT()->getDltPresentFlag() ? 1 : 0, "dlts_present_flag" );
    396 
    397   if ( pcPPS->getDLT()->getDltPresentFlag() )
    398   {
    399     WRITE_CODE(pcPPS->getDLT()->getNumDepthViews() - 1, 6, "pps_depth_layers_minus1");
    400     WRITE_CODE((pcPPS->getDLT()->getDepthViewBitDepth() - 8), 4, "pps_bit_depth_for_depth_layers_minus8");
    401    
    402     for( Int i = 0; i <= pcPPS->getDLT()->getNumDepthViews()-1; i++ )
    403     {
    404       Int layerId = pcPPS->getDLT()->getDepthIdxToLayerId(i);
    405      
    406       WRITE_FLAG( pcPPS->getDLT()->getUseDLTFlag( layerId ) ? 1 : 0, "dlt_flag[i]" );
    407      
    408       if ( pcPPS->getDLT()->getUseDLTFlag( layerId ) )
    409       {
    410         std::vector<Int> aiIdx2DepthValue_coded(256, 0);
    411         UInt uiNumDepthValues_coded = pcPPS->getDLT()->getNumDepthValues(layerId);
    412        
    413         // ----------------------------- Actual coding -----------------------------
    414         WRITE_FLAG( pcPPS->getDLT()->getInterViewDltPredEnableFlag( layerId ) ? 1 : 0, "dlt_pred_flag[i]");
    415         if ( pcPPS->getDLT()->getInterViewDltPredEnableFlag( layerId ) == false )
    416         {
    417           WRITE_FLAG( pcPPS->getDLT()->getUseBitmapRep( layerId ) ? 1 : 0, "dlt_val_flags_present_flag[i]" );
    418          
    419           for( UInt ui = 0; ui<uiNumDepthValues_coded; ui++ )
    420           {
    421             aiIdx2DepthValue_coded[ui] = pcPPS->getDLT()->idx2DepthValue(layerId, ui);
    422           }
    423         }
    424         else
    425         {
    426           AOF( layerId > 1 );
    427           // assumes ref layer id to be 1
    428           std::vector<Int> viRefDLT = pcPPS->getDLT()->idx2DepthValue( 1 );
    429           UInt uiRefNum = pcPPS->getDLT()->getNumDepthValues( 1 );
    430           pcPPS->getDLT()->getDeltaDLT(layerId, viRefDLT, uiRefNum, aiIdx2DepthValue_coded, uiNumDepthValues_coded);
    431         }
    432        
    433         // bit map coding
    434         if ( pcPPS->getDLT()->getUseBitmapRep( layerId ) )
    435         {
    436           UInt uiDltArrayIndex = 0;
    437           for (UInt d=0; d < 256; d++)
    438           {
    439             if ( d == aiIdx2DepthValue_coded[uiDltArrayIndex] )
    440             {
    441               WRITE_FLAG(1, "dlt_value_flag[i][j]");
    442               uiDltArrayIndex++;
    443             }
    444             else
    445             {
    446               WRITE_FLAG(0, "dlt_value_flag[i][j]");
    447             }
    448           }
    449         }
    450         // Diff Coding
    451         else
    452         {
    453           UInt uiMaxDiff               = 0;
    454           UInt uiMinDiff               = MAX_INT;
    455           UInt uiLengthMinDiff         = 0;
    456           UInt uiLengthDltDiffMinusMin = 0;
    457          
    458           std::vector<UInt> puiDltDiffValues(uiNumDepthValues_coded, 0);
    459          
    460           for (UInt d = 1; d < uiNumDepthValues_coded; d++)
    461           {
    462             puiDltDiffValues[d] = aiIdx2DepthValue_coded[d] - aiIdx2DepthValue_coded[d-1];
    463            
    464             if ( uiMaxDiff < puiDltDiffValues[d] )
    465             {
    466               uiMaxDiff = puiDltDiffValues[d];
    467             }
    468            
    469             if ( uiMinDiff > puiDltDiffValues[d] )
    470             {
    471               uiMinDiff = puiDltDiffValues[d];
    472             }
    473           }
    474          
    475           if ( uiNumDepthValues_coded > 2 )
    476           {
    477             uiLengthMinDiff    = (UInt) gCeilLog2(uiMaxDiff + 1);
    478           }
    479           if (uiMaxDiff > uiMinDiff)
    480           {
    481             uiLengthDltDiffMinusMin = (UInt) gCeilLog2(uiMaxDiff - uiMinDiff + 1);
    482           }
    483          
    484           WRITE_CODE(uiNumDepthValues_coded, 8, "num_val_delta_dlt");    // num_entry
    485           {
    486             // The condition if( uiNumDepthValues_coded > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component.
    487             if ( uiNumDepthValues_coded > 1 )
    488             {
    489               WRITE_CODE(uiMaxDiff, 8, "max_diff");        // max_diff
    490             }
    491            
    492             if ( uiNumDepthValues_coded > 2 )
    493             {
    494               WRITE_CODE((uiMinDiff - 1), uiLengthMinDiff, "min_diff_minus1");     // min_diff_minus1
    495             }
    496            
    497             WRITE_CODE(aiIdx2DepthValue_coded[0], 8, "delta_dlt_val0");          // entry0
    498            
    499             if (uiMaxDiff > uiMinDiff)
    500             {
    501               for (UInt d=1; d < uiNumDepthValues_coded; d++)
    502               {
    503                 WRITE_CODE( (puiDltDiffValues[d] - uiMinDiff), uiLengthDltDiffMinusMin, "delta_val_diff_minus_min[k]");    // entry_value_diff_minus_min[ k ]
    504               }
    505             }
    506           }
    507          
    508         }
    509       }
    510     }
    511   }
    512 #endif
    513 }
    514 #endif
    515366
    516367Void TEncCavlc::codeVUI( const TComVUI *pcVUI, const TComSPS* pcSPS )
     
    951802  }
    952803
    953 #if NH_3D
    954   if ( pcSPS->getSps3dExtensionFlag() )
    955   {
    956     codeSPS3dExtension( pcSPS );
    957   }
    958 
    959 #endif
    960804#endif
    961805  xWriteRbspTrailingBits();
     
    984828#endif
    985829
    986 #if NH_3D
    987 Void TEncCavlc::codeSPS3dExtension( const TComSPS* pcSPS )
    988 {
    989   const TComSps3dExtension* sps3dExt = pcSPS->getSps3dExtension();
    990   for( Int d = 0; d  <=  1; d++ )
    991   {
    992     WRITE_FLAG( sps3dExt->getIvDiMcEnabledFlag( d ) ? 1 : 0 , "iv_di_mc_enabled_flag" );
    993     WRITE_FLAG( sps3dExt->getIvMvScalEnabledFlag( d ) ? 1 : 0 , "iv_mv_scal_enabled_flag" );
    994     if( d  ==  0 )
    995     {
    996       WRITE_UVLC( sps3dExt->getLog2IvmcSubPbSizeMinus3( d ), "log2_sub_pb_size_minus3" );
    997       WRITE_FLAG( sps3dExt->getIvResPredEnabledFlag( d ) ? 1 : 0 , "iv_res_pred_enabled_flag" );
    998       WRITE_FLAG( sps3dExt->getDepthRefEnabledFlag( d ) ? 1 : 0 , "depth_ref_enabled_flag" );
    999       WRITE_FLAG( sps3dExt->getVspMcEnabledFlag( d ) ? 1 : 0 , "vsp_mc_enabled_flag" );
    1000       WRITE_FLAG( sps3dExt->getDbbpEnabledFlag( d ) ? 1 : 0 , "dbbp_enabled_flag" );
    1001     }
    1002     else
    1003     {
    1004       WRITE_FLAG( sps3dExt->getTexMcEnabledFlag( d ) ? 1 : 0 , "tex_mc_enabled_flag" );
    1005       WRITE_UVLC( sps3dExt->getLog2TexmcSubPbSizeMinus3( d ), "log2_texmc_sub_pb_size_minus3" );
    1006       WRITE_FLAG( sps3dExt->getIntraContourEnabledFlag( d ) ? 1 : 0 , "intra_contour_enabled_flag" );
    1007       WRITE_FLAG( sps3dExt->getIntraDcOnlyWedgeEnabledFlag( d ) ? 1 : 0 , "intra_dc_only_wedge_enabled_flag" );
    1008       WRITE_FLAG( sps3dExt->getCqtCuPartPredEnabledFlag( d ) ? 1 : 0 , "cqt_cu_part_pred_enabled_flag" );
    1009       WRITE_FLAG( sps3dExt->getInterDcOnlyEnabledFlag( d ) ? 1 : 0 , "inter_dc_only_enabled_flag" );
    1010       WRITE_FLAG( sps3dExt->getSkipIntraEnabledFlag( d ) ? 1 : 0 , "skip_intra_enabled_flag" );
    1011     }
    1012   }
    1013 }
    1014 #endif
    1015830
    1016831
     
    1111926  m_pcBitIf->writeAlignOne();
    1112927  codeVPSExtension( pcVPS );                           
    1113 #if NH_3D
    1114   WRITE_FLAG( 1,                     "vps_extension2_flag" ); 
    1115   WRITE_FLAG( 1,                     "vps_3d_extension_flag" );
    1116   m_pcBitIf->writeAlignOne();     
    1117   codeVPS3dExtension( pcVPS );
    1118   WRITE_FLAG( 0,                     "vps_extension3_flag" );
    1119 #else
    1120928  WRITE_FLAG( 0,                     "vps_extension2_flag" );
    1121 #endif
    1122929#else
    1123930  WRITE_FLAG( 0,                     "vps_extension_flag" );
     
    17111518#endif
    17121519
    1713 #if NH_3D
    1714 Void TEncCavlc::codeVPS3dExtension( const TComVPS* pcVPS )
    1715 {
    1716   WRITE_UVLC( pcVPS->getCpPrecision( ), "cp_precision" );
    1717   for (Int n = 1; n < pcVPS->getNumViews(); n++)
    1718   {
    1719     Int i      = pcVPS->getViewOIdxList( n );
    1720     Int iInVps = pcVPS->getVoiInVps( i );
    1721     WRITE_CODE( pcVPS->getNumCp( iInVps ), 6, "num_cp" );
    1722 
    1723     if( pcVPS->getNumCp( iInVps ) > 0 )
    1724     {
    1725       WRITE_FLAG( pcVPS->getCpInSliceSegmentHeaderFlag( iInVps ) ? 1 : 0 , "cp_in_slice_segment_header_flag" );
    1726       for( Int m = 0; m < pcVPS->getNumCp( iInVps ); m++ )
    1727       {
    1728         WRITE_UVLC( pcVPS->getCpRefVoi( iInVps, m ), "cp_ref_voi" );
    1729         if( !pcVPS->getCpInSliceSegmentHeaderFlag( iInVps ) )
    1730         {
    1731           Int j      = pcVPS->getCpRefVoi( iInVps, m );
    1732           Int jInVps = pcVPS->getVoiInVps( j );
    1733           WRITE_SVLC( pcVPS->getVpsCpScale   ( iInVps, jInVps ), "vps_cp_scale" );
    1734           WRITE_SVLC( pcVPS->getVpsCpOff     ( iInVps, jInVps ), "vps_cp_off" );
    1735           WRITE_SVLC( pcVPS->getVpsCpInvScale( iInVps, jInVps ) + pcVPS->getVpsCpScale( iInVps, jInVps ), "vps_cp_inv_scale_plus_scale" );
    1736           WRITE_SVLC( pcVPS->getVpsCpInvOff  ( iInVps, jInVps ) + pcVPS->getVpsCpOff  ( iInVps, jInVps ), "vps_cp_inv_off_plus_off" );
    1737         }
    1738       }
    1739     }
    1740   } 
    1741 }
    1742 #endif
    17431520
    17441521
     
    17831560    WRITE_FLAG( pcSlice->getNoOutputPriorPicsFlag() ? 1 : 0, "no_output_of_prior_pics_flag" );
    17841561  }
    1785 #if H_3D_PPS_FIX_DEPTH
    1786   if( pcSlice->getIsDepth() )
    1787   {
    1788     WRITE_UVLC( 1, "slice_pic_parameter_set_id" );
    1789   }
    1790   else
    1791 #endif
    17921562  WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" );
    17931563  if ( pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag() && (sliceSegmentRsAddress!=0) )
     
    19901760    Bool interLayerPredLayerIdcPresentFlag = false;
    19911761    Int layerId = pcSlice->getLayerId();
    1992 #if NH_3D
    1993     if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumRefListLayers( layerId ) > 0 )
    1994 #else
    19951762    if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 )
    1996 #endif
    19971763    {   
    19981764      WRITE_FLAG( pcSlice->getInterLayerPredEnabledFlag( ) ? 1 : 0 , "inter_layer_pred_enabled_flag" );
    1999 #if NH_3D
    2000       if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumRefListLayers( layerId ) > 1 )
    2001 #else
    20021765      if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 )
    2003 #endif
    20041766      {           
    20051767        if( !vps->getMaxOneActiveRefLayerFlag()) 
     
    20071769          WRITE_CODE( pcSlice->getNumInterLayerRefPicsMinus1( ), pcSlice->getNumInterLayerRefPicsMinus1Len( ), "num_inter_layer_ref_pics_minus1" );
    20081770        }
    2009 #if NH_3D
    2010         if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumRefListLayers( layerId ) )
    2011 #else
    20121771        if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) )
    2013 #endif
    20141772        {       
    20151773          interLayerPredLayerIdcPresentFlag = true;
     
    20301788#endif
    20311789
    2032 #if NH_3D     
    2033   if( getEncTop()->decProcAnnexI() )
    2034   {
    2035       if ( pcSlice->getInCmpPredAvailFlag() )
    2036       {
    2037         WRITE_FLAG( pcSlice->getInCompPredFlag(), "in_comp_pred_flag" );
    2038       }
    2039   }
    2040 #endif
    20411790
    20421791    if(pcSlice->getSPS()->getUseSAO())
     
    20541803    {
    20551804      Bool overrideFlag = (pcSlice->getNumRefIdx( REF_PIC_LIST_0 )!=pcSlice->getPPS()->getNumRefIdxL0DefaultActive()||(pcSlice->isInterB()&&pcSlice->getNumRefIdx( REF_PIC_LIST_1 )!=pcSlice->getPPS()->getNumRefIdxL1DefaultActive()));
    2056 #if H_3D_PPS_FIX_DEPTH
    2057       overrideFlag |= (pcSlice->getIsDepth() && !pcSlice->getViewIndex());
    2058 #endif
    20591805      WRITE_FLAG( overrideFlag ? 1 : 0,                               "num_ref_idx_active_override_flag");
    20601806      if (overrideFlag)
     
    20761822      pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
    20771823    }
    2078 #if H_3D_PPS_FIX_DEPTH
    2079     if( (pcSlice->getPPS()->getListsModificationPresentFlag() || (pcSlice->getIsDepth() && !pcSlice->getViewIndex())) && pcSlice->getNumRpsCurrTempList() > 1)
    2080 #else
    20811824    if( pcSlice->getPPS()->getListsModificationPresentFlag() && pcSlice->getNumRpsCurrTempList() > 1)
    2082 #endif
    20831825    {
    20841826      TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
     
    21621904      xCodePredWeightTable( pcSlice );
    21631905    }
    2164 #if NH_3D_IC
    2165     else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE )
    2166       && !pcSlice->getIsDepth() && vps->getNumRefListLayers( layerId ) > 0
    2167       && getEncTop()->decProcAnnexI()       
    2168       )
    2169     {
    2170       WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "slice_ic_enable_flag" );
    2171       if( pcSlice->getApplyIC() )
    2172       {
    2173         WRITE_FLAG( pcSlice->getIcSkipParseFlag() ? 1 : 0, "slice_ic_disabled_merge_zero_idx_flag" );
    2174       }
    2175     }
    2176 #endif
    2177 #if NH_3D_IV_MERGE
    2178     assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS_MEM);
    2179 #else
    21801906    assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS);
    2181 #endif
    21821907    if (!pcSlice->isIntra())
    21831908    {
    2184 #if NH_3D_IV_MERGE
    2185       WRITE_UVLC( ( ( pcSlice->getMpiFlag( ) || pcSlice->getIvMvPredFlag( ) || pcSlice->getViewSynthesisPredFlag( ) ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
    2186 #else
    21871909      WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
    2188 #endif
    21891910    }
    21901911    Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 );
     
    22321953      WRITE_FLAG(pcSlice->getLFCrossSliceBoundaryFlag()?1:0, "slice_loop_filter_across_slices_enabled_flag");
    22331954    }
    2234 #if NH_3D
    2235     if (getEncTop()->decProcAnnexI() )
    2236     {
    2237       Int voiInVps = vps->getVoiInVps( pcSlice->getViewIndex() );
    2238       if( vps->getCpInSliceSegmentHeaderFlag( voiInVps ) )
    2239       {
    2240         for( Int m = 0; m < vps->getNumCp( voiInVps ); m++ )
    2241         {
    2242           Int jInVps = vps->getVoiInVps( vps->getCpRefVoi( voiInVps, m ));
    2243           WRITE_SVLC( pcSlice->getCpScale   ( jInVps )   , "cp_scale" );
    2244           WRITE_SVLC( pcSlice->getCpOff     ( jInVps )   , "cp_off" );
    2245           WRITE_SVLC( pcSlice->getCpInvScale( jInVps ) + pcSlice->getCpScale( jInVps ) , "cp_inv_scale_plus_scale" );
    2246           WRITE_SVLC( pcSlice->getCpInvOff  ( jInVps ) + pcSlice->getCpOff  ( jInVps ) , "cp_inv_off_plus_off" );
    2247         }
    2248       }
    2249     }
    2250 #endif
    22511955
    22521956  }
     
    25542258}
    25552259
    2556 #if NH_3D_ARP
    2557 Void TEncCavlc::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
     2260
     2261
     2262Void TEncCavlc::codeInterModeFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiEncMode*/ )
    25582263{
    25592264  assert(0);
    25602265}
    2561 #endif
    2562 
    2563 #if NH_3D_IC
    2564 Void TEncCavlc::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
     2266
     2267Void TEncCavlc::codeCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
    25652268{
    25662269  assert(0);
    25672270}
    2568 #endif
    2569 
    2570 Void TEncCavlc::codeInterModeFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiEncMode*/ )
     2271
     2272Void TEncCavlc::codeSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
    25712273{
    25722274  assert(0);
    25732275}
    2574 
    2575 Void TEncCavlc::codeCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
    2576 {
    2577   assert(0);
    2578 }
    2579 
    2580 Void TEncCavlc::codeSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
    2581 {
    2582   assert(0);
    2583 }
    2584 #if NH_3D_DIS
    2585 Void TEncCavlc::codeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx )
    2586 {
    2587   assert(0);
    2588 }
    2589 #endif
    25902276
    25912277Void TEncCavlc::codeSplitFlag   ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
     
    28632549   assert(0);
    28642550 }
    2865 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    2866 Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx )
    2867 {
    2868   assert(0);
    2869 }
    2870 #endif
    28712551   
    2872 #if NH_3D_DBBP
    2873 Void TEncCavlc::codeDBBPFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx )
    2874 {
    2875   assert(0);
    2876 }
    2877 #endif
    28782552
    28792553
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncCavlc.h

    r1386 r1390  
    106106  Void  codeSPSExtension        ( const TComSPS* pcSPS );
    107107#endif
    108 #if NH_3D
    109   Void  codeVPS3dExtension      ( const TComVPS* pcVPS );
    110   Void  codeSPS3dExtension      ( const TComSPS* pcSPS );
    111 #endif
    112108  Void  codeSPS                 ( const TComSPS* pcSPS );
    113109  Void  codePPS                 ( const TComPPS* pcPPS );
    114110#if NH_MV
    115111  Void  codePpsMultilayerExtension( const TComPPS* pcPPS );
    116 #endif
    117 #if NH_3D
    118   Void  codePps3dExtension       ( const TComPPS* pcPPS );
    119112#endif
    120113  Void  codeSliceHeader         ( TComSlice* pcSlice );
     
    130123  Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx );
    131124  Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    132 #if NH_3D_DIS
    133   Void codeDIS           ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    134 #endif
    135125  Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    136126  Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    137 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    138   Void  codeDeltaDC      ( TComDataCU* /*pcCU*/, UInt /*absPartIdx*/ ) { assert(0); };
    139 #endif
    140 #if NH_3D_ARP
    141   Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    142 #endif
    143 #if NH_3D_IC
    144   Void codeICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    145 #endif
    146127
    147 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    148   Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    149 #endif
    150 #if NH_3D_DBBP
    151   Void codeDBBPFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    152 #endif
    153128  Void codeAlfCtrlFlag   ( ComponentID /*component*/, UInt /*code*/ ) {printf("Not supported\n"); assert(0);}
    154129  Void codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode );
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncCfg.h

    r1386 r1390  
    4646#include "TLibCommon/TComSlice.h"
    4747#include <assert.h>
    48 #if NH_3D_VSO
    49 #include "TAppCommon/TAppComCamPara.h"
    50 #include "TLibRenderer/TRenModSetupStrParser.h"
    51 #endif
    5248
    5349#if NH_MV
     
    7975  Int m_interViewRefPosL[2][MAX_NUM_REF_PICS]; 
    8076#endif
    81 #if NH_3D
    82   Bool m_interCompPredFlag;
    83 #endif
    8477
    8578GOPEntry()
     
    10093#if NH_MV
    10194  , m_numActiveRefLayerPics(0)
    102 #endif
    103 #if NH_3D
    104   , m_interCompPredFlag(false)
    10595#endif
    10696
     
    386376#endif
    387377
    388 #if KWU_RC_MADPRED_E0227
    389   UInt       m_depthMADPred;
    390 #endif
    391 #if KWU_RC_VIEWRC_E0227
    392   Bool      m_bViewWiseRateCtrl;
    393 #endif
    394378  Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
    395379  Bool      m_CUTransquantBypassFlagForce;                    ///< if transquant_bypass_enable_flag, then, if true, all CU transquant bypass flags will be set to true.
     
    403387#endif
    404388
    405 #if NH_3D_DLT
    406   TComDLT   m_cDLT;
    407 #endif
    408389  Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
    409390  Int       m_activeParameterSetsSEIEnabled;                  ///< enable active parameter set SEI message
     
    458439#endif
    459440
    460 #if NH_3D_VSO
    461   Bool      m_isDepth;
    462   Bool      m_isAuxDepth;
    463 
    464   //====== Camera Parameters ======
    465   TAppComCamPara* m_cameraParameters;
    466  
    467   //====== View Synthesis Optimization ======
    468   TRenModSetupStrParser* m_renderModelParameters;
    469   Bool      m_bUseVSO;
    470   Bool      m_bForceLambdaScale;
    471   Bool      m_bAllowNegDist;
    472   Double    m_dLambdaScaleVSO;
    473   UInt      m_uiVSOMode;
    474   // LGE_WVSO_A0119
    475   Bool      m_bUseWVSO;
    476   Int       m_iVSOWeight;
    477   Int       m_iVSDWeight;
    478   Int       m_iDWeight;
    479   // SAIT_VSO_EST_A0033
    480   Bool      m_bUseEstimatedVSD;
    481   Double    m_dDispCoeff;
    482 #endif
    483 #if NH_3D
    484 
    485   Bool      m_bUseIC;
    486   Bool      m_bUseICLowLatencyEnc; 
    487   Bool      m_useDMM;
    488   Bool      m_useSDC;
    489   Bool      m_useDLT;
    490 #endif
    491 #if NH_3D_QTL
    492   Bool      m_bUseQTL;
    493 #endif
    494 #if NH_3D
    495   Int       m_profileIdc;
    496 #endif
    497441public:
    498442  TEncCfg()
     
    504448  , m_viewId(-1)
    505449  , m_viewIndex(-1)
    506 #if NH_3D_VSO
    507   , m_isDepth(false)
    508   , m_isAuxDepth(false)
    509   , m_bUseVSO(false)
    510 #endif
    511 #if NH_3D
    512   , m_profileIdc( -1 )
    513 #endif
    514450#endif
    515451
     
    555491  Void      setViewIndex                     ( Int viewIndex  )   { m_viewIndex  = viewIndex;  }
    556492  Int       getViewIndex                     ()                   { return m_viewIndex;    }
    557 #if NH_3D_VSO
    558   Void      setIsDepth                       ( Bool isDepth )   { m_isDepth = isDepth; }
    559   Bool      getIsDepth                       ()                 { return m_isDepth; }
    560   Void      setIsAuxDepth                    ( Bool isAuxDepth ) { m_isAuxDepth = isAuxDepth; }
    561   Bool      getIsAuxDepth                       ()               { return m_isAuxDepth; }
    562 
    563 
    564 #endif
    565493#endif
    566494  //====== Coding Structure ========
     
    592520  Void      setMaxTotalCUDepth              ( UInt  u )      { m_maxTotalCUDepth = u; }
    593521  Void      setLog2DiffMaxMinCodingBlockSize( UInt  u )      { m_log2DiffMaxMinCodingBlockSize = u; }
    594 #if NH_3D_IC
    595   Void       setUseIC                       ( Bool bVal )    { m_bUseIC = bVal; }
    596   Bool       getUseIC                       ()               { return m_bUseIC; }
    597   Void       setUseICLowLatencyEnc          ( Bool bVal )    { m_bUseICLowLatencyEnc = bVal; }
    598   Bool       getUseICLowLatencyEnc          ()               { return m_bUseICLowLatencyEnc; }
    599 #endif
    600522
    601523  //======== Transform =============
     
    1015937#endif
    1016938
    1017 #if KWU_RC_MADPRED_E0227
    1018   UInt         getUseDepthMADPred     ()                             { return m_depthMADPred;        }
    1019   Void         setUseDepthMADPred     (UInt b)                       { m_depthMADPred    = b;        }
    1020 #endif                                                             
    1021 #if KWU_RC_VIEWRC_E0227                                           
    1022   Bool         getUseViewWiseRateCtrl ()                             { return m_bViewWiseRateCtrl;        }
    1023   Void         setUseViewWiseRateCtrl (Bool b)                       { m_bViewWiseRateCtrl    = b;        }
    1024 #endif
    1025939  Bool         getTransquantBypassEnableFlag()                       { return m_TransquantBypassEnableFlag; }
    1026940  Void         setTransquantBypassEnableFlag(Bool flag)              { m_TransquantBypassEnableFlag = flag; }
     
    1037951#endif
    1038952
    1039 #if NH_3D_DLT
    1040   Void         setDLT( TComDLT p )                                   { m_cDLT = p; }
    1041   TComDLT*     getDLT()                                              { return &m_cDLT; }
    1042 #endif
    1043953  Void         setUseRecalculateQPAccordingToLambda (Bool b)         { m_recalculateQPAccordingToLambda = b;    }
    1044954  Bool         getUseRecalculateQPAccordingToLambda ()               { return m_recalculateQPAccordingToLambda; }
     
    11571067  UInt      getSummaryVerboseness( ) const                           { return m_summaryVerboseness; }
    11581068
    1159 #if NH_3D_VSO
    1160   // Only flags that are not in the SPS3dExtension should go here.
    1161   /// 3D Tools
    1162 
    1163  //==== CAMERA PARAMETERS  ==========
    1164   Void      setCameraParameters             ( TAppComCamPara* c) { m_cameraParameters   = c; }
    1165  //==== VSO  ==========
    1166   Void      setRenderModelParameters ( TRenModSetupStrParser* c ) { m_renderModelParameters = c; }
    1167   Bool      getUseVSO                       ()              { return m_bUseVSO;     }
    1168   Void      setUseVSO                       ( Bool  b  )    { m_bUseVSO     = b; }
    1169   UInt      getVSOMode                      ()              { return m_uiVSOMode; }
    1170   Void      setVSOMode                      ( UInt  ui )    { m_uiVSOMode   = ui; }
    1171   Bool      getForceLambdaScaleVSO          ()              { return m_bForceLambdaScale; }
    1172   Void      setForceLambdaScaleVSO          ( Bool   b )    { m_bForceLambdaScale = b; };
    1173   Double    getLambdaScaleVSO               ()              { return m_dLambdaScaleVSO;   }
    1174   Void      setLambdaScaleVSO               ( Double d )    { m_dLambdaScaleVSO   = d; };
    1175   Bool      getAllowNegDist                 ()              { return m_bAllowNegDist;     }
    1176   Void      setAllowNegDist                 ( Bool   b )    { m_bAllowNegDist     = b; };
    1177 
    1178   // LGE_WVSO_A0119
    1179   Bool      getUseWVSO                      ()              { return m_bUseWVSO;     }
    1180   Void      setUseWVSO                      ( Bool  b )     { m_bUseWVSO   = b; }
    1181   Int       getVSOWeight                    ()              { return m_iVSOWeight;    }
    1182   Void      setVSOWeight                    ( Int   i )     { m_iVSOWeight = i; }
    1183   Int       getVSDWeight                    ()              { return m_iVSDWeight;    }
    1184   Void      setVSDWeight                    ( Int   i )     { m_iVSDWeight = i; }
    1185   Int       getDWeight                      ()              { return m_iDWeight;    }
    1186   Void      setDWeight                      ( Int   i )     { m_iDWeight   = i; }
    1187 
    1188   // SAIT_VSO_EST_A0033
    1189   Bool      getUseEstimatedVSD              ()              { return m_bUseEstimatedVSD; }
    1190   Void      setUseEstimatedVSD              ( Bool  b )     { m_bUseEstimatedVSD = b; }
    1191   Double    getDispCoeff                    ()              { return m_dDispCoeff;    }
    1192   Void      setDispCoeff                    ( Double  d )   { m_dDispCoeff  = d; }
    1193 #endif // NH_3D_VSO
    1194 #if NH_3D
    1195   Bool      getUseDMM                       ()        { return m_useDMM; }
    1196   Void      setUseDMM                       ( Bool b) { m_useDMM = b;    }
    1197   Bool      getUseSDC                       ()        { return m_useSDC; }
    1198   Void      setUseSDC                       ( Bool b) { m_useSDC = b;    }
    1199 
    1200   Bool      getUseDLT                       ()        { return m_useDLT; }
    1201   Void      setUseDLT                       ( Bool b) { m_useDLT = b;    }
    1202 #endif
    1203 
    1204 #if NH_3D_QTL
    1205   Void      setUseQTL                       ( Bool b ) { m_bUseQTL = b;    }
    1206   Bool      getUseQTL                       ()         { return m_bUseQTL; }
    1207 #endif
    1208 #if NH_3D
    1209 
    1210   Void      setProfileIdc( Int a )    { assert( a == 1 || a == 6 || a == 8 ); m_profileIdc = a;  }
    1211   Bool      decProcAnnexI()           { assert( m_profileIdc != -1 ); return ( m_profileIdc == Profile::MAIN3D ); }   
    1212 #endif // NH_3D
     1069
    12131070};
    12141071
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncCu.cpp

    r1386 r1390  
    6868  m_ppcTempCU      = new TComDataCU*[m_uhTotalDepth-1];
    6969
    70 #if NH_3D_ARP
    71   m_ppcWeightedTempCU = new TComDataCU*[m_uhTotalDepth-1];
    72 #endif
    7370
    7471  m_ppcPredYuvBest = new TComYuv*[m_uhTotalDepth-1];
     
    7976  m_ppcRecoYuvTemp = new TComYuv*[m_uhTotalDepth-1];
    8077  m_ppcOrigYuv     = new TComYuv*[m_uhTotalDepth-1];
    81 #if NH_3D_DBBP
    82   m_ppcOrigYuvDBBP = new TComYuv*[m_uhTotalDepth-1];
    83 #endif
    8478
    8579  UInt uiNumPartitions;
     
    9286    m_ppcBestCU[i] = new TComDataCU; m_ppcBestCU[i]->create( chromaFormat, uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
    9387    m_ppcTempCU[i] = new TComDataCU; m_ppcTempCU[i]->create( chromaFormat, uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
    94 #if NH_3D_ARP
    95     m_ppcWeightedTempCU[i] = new TComDataCU; m_ppcWeightedTempCU[i]->create( chromaFormat, uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
    96 #endif 
    9788
    9889    m_ppcPredYuvBest[i] = new TComYuv; m_ppcPredYuvBest[i]->create(uiWidth, uiHeight, chromaFormat);
     
    10596
    10697    m_ppcOrigYuv    [i] = new TComYuv; m_ppcOrigYuv    [i]->create(uiWidth, uiHeight, chromaFormat);
    107 #if NH_3D_DBBP
    108     m_ppcOrigYuvDBBP[i] = new TComYuv; m_ppcOrigYuvDBBP[i]->create(uiWidth, uiHeight, chromaFormat);
    109 #endif
    11098
    11199  }
     
    113101  m_bEncodeDQP          = false;
    114102
    115 #if KWU_RC_MADPRED_E0227
    116   m_LCUPredictionSAD = 0;
    117   m_addSADDepth      = 0;
    118   m_temporalSAD      = 0;
    119   m_spatialSAD       = 0;
    120 #endif
    121103
    122104  m_stillToCodeChromaQpOffsetFlag  = false;
     
    147129      m_ppcTempCU[i]->destroy();      delete m_ppcTempCU[i];      m_ppcTempCU[i] = NULL;
    148130    }
    149 #if NH_3D_ARP
    150     if(m_ppcWeightedTempCU[i])
    151     {
    152       m_ppcWeightedTempCU[i]->destroy(); delete m_ppcWeightedTempCU[i]; m_ppcWeightedTempCU[i] = NULL;
    153     }
    154 #endif
    155131    if(m_ppcPredYuvBest[i])
    156132    {
     
    181157      m_ppcOrigYuv[i]->destroy();     delete m_ppcOrigYuv[i];     m_ppcOrigYuv[i] = NULL;
    182158    }
    183 #if NH_3D_DBBP
    184     if(m_ppcOrigYuvDBBP[i])
    185     {
    186       m_ppcOrigYuvDBBP[i]->destroy(); delete m_ppcOrigYuvDBBP[i]; m_ppcOrigYuvDBBP[i] = NULL;
    187     }
    188 #endif
    189159  }
    190160  if(m_ppcBestCU)
     
    199169  }
    200170
    201 #if NH_3D_ARP
    202   if(m_ppcWeightedTempCU)
    203   {
    204     delete [] m_ppcWeightedTempCU;
    205     m_ppcWeightedTempCU = NULL;
    206   }
    207 #endif
    208171  if(m_ppcPredYuvBest)
    209172  {
     
    241204    m_ppcOrigYuv = NULL;
    242205  }
    243 #if NH_3D_DBBP
    244   if(m_ppcOrigYuvDBBP)
    245   {
    246     delete [] m_ppcOrigYuvDBBP;
    247     m_ppcOrigYuvDBBP = NULL;
    248   }
    249 #endif
    250206}
    251207
     
    281237  m_ppcTempCU[0]->initCtu( pCtu->getPic(), pCtu->getCtuRsAddr() );
    282238
    283 #if NH_3D_ARP
    284   m_ppcWeightedTempCU[0]->initCtu( pCtu->getPic(), pCtu->getCtuRsAddr() );
    285 #endif
    286 
    287 #if KWU_RC_MADPRED_E0227
    288   m_LCUPredictionSAD = 0;
    289   m_addSADDepth      = 0;
    290   m_temporalSAD      = 0;
    291   m_spatialSAD       = 0;
    292 #endif
     239
    293240
    294241  // analysis of CU
     
    420367  const UInt fastDeltaQPCuMaxSize    = Clip3(sps.getMaxCUHeight()>>sps.getLog2DiffMaxMinCodingBlockSize(), sps.getMaxCUHeight(), 32u);
    421368
    422 #if NH_3D_QTL
    423 #if NH_3D_QTLPC
    424   Bool  bLimQtPredFalg    = pcPic->getSlice(0)->getQtPredFlag();
    425 #else
    426   Bool  bLimQtPredFalg    = false;
    427 #endif
    428   TComPic *pcTexture      = rpcBestCU->getSlice()->getTexturePic();
    429 
    430   Bool  depthMapDetect    = (pcTexture != NULL);
    431   Bool  bIntraSliceDetect = (rpcBestCU->getSlice()->getSliceType() == I_SLICE);
    432 
    433   Bool rapPic             = (rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA);
    434 
    435   Bool bTry2NxN           = true;
    436   Bool bTryNx2N           = true;
    437 #endif
    438369
    439370  // get Original YUV data from picture
    440371  m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getCtuRsAddr(), rpcBestCU->getZorderIdxInCtu() );
    441372
    442 #if NH_3D_QTL 
    443   Bool    bTrySplit     = true;
    444   Bool    bTrySplitDQP  = true;
    445 #endif
    446373  // variable for Cbf fast mode PU decision
    447374  Bool    doNotBlockPu = true;
    448375  Bool    earlyDetectionSkipMode = false;
    449376
    450 #if NH_3D_NBDV
    451   DisInfo DvInfo;
    452   DvInfo.m_acNBDV.setZero();
    453   DvInfo.m_aVIdxCan = 0;
    454 #if NH_3D_NBDV_REF
    455   DvInfo.m_acDoNBDV.setZero();
    456 #endif
    457 #endif
    458377  const UInt uiLPelX   = rpcBestCU->getCUPelX();
    459378  const UInt uiRPelX   = uiLPelX + rpcBestCU->getWidth(0)  - 1;
     
    512431  }
    513432
    514 #if NH_3D_IC
    515   Bool bICEnabled = rpcTempCU->getSlice()->getViewIndex() && ( rpcTempCU->getSlice()->getSliceType() == P_SLICE || rpcTempCU->getSlice()->getSliceType() == B_SLICE ) && !rpcTempCU->getSlice()->getIsDepth();
    516   bICEnabled = bICEnabled && rpcTempCU->getSlice()->getApplyIC();
    517 #endif
    518433
    519434  TComSlice * pcSlice = rpcTempCU->getPic()->getSlice(rpcTempCU->getPic()->getCurrSliceIdx());
    520435
    521436  const Bool bBoundary = !( uiRPelX < sps.getPicWidthInLumaSamples() && uiBPelY < sps.getPicHeightInLumaSamples() );
    522 #if  NH_3D_FAST_TEXTURE_ENCODING
    523     Bool bIVFMerge = false;
    524     Int  iIVFMaxD = 0;
    525     Bool bFMD = false;
    526     Bool bSubBranch = true;
    527 #endif
    528437  if ( !bBoundary )
    529438  {
     
    537446      }
    538447
    539 #if NH_3D_QTL
    540       bTrySplit    = true;
    541 #endif
    542448
    543449      m_cuChromaQpOffsetIdxPlus1 = 0;
     
    555461
    556462      rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    557 #if NH_3D_QTL
    558       //logic for setting bTrySplit using the partition information that is stored of the texture colocated CU
    559 #if H_3D_FCO
    560       if(depthMapDetect && !bIntraSliceDetect && !rapPic && ( m_pcEncCfg->getUseQTL() || bLimQtPredFalg ) && pcTexture->getReconMark())
    561 #else
    562       if(depthMapDetect && !bIntraSliceDetect && !rapPic && ( m_pcEncCfg->getUseQTL() || bLimQtPredFalg ))
    563 #endif
    564       {
    565         TComDataCU* pcTextureCU = pcTexture->getCtu( rpcBestCU->getCtuRsAddr() ); //Corresponding texture LCU
    566         UInt uiCUIdx            = rpcBestCU->getZorderIdxInCtu();
    567         assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth); //Depth cannot be more partitioned than the texture.
    568         if (pcTextureCU->getDepth(uiCUIdx) > uiDepth || pcTextureCU->getPartitionSize(uiCUIdx) == SIZE_NxN) //Texture was split.
    569         {
    570           bTrySplit = true;
    571           bTryNx2N  = true;
    572           bTry2NxN  = true;
    573         }
    574         else
    575         {
    576           bTrySplit = false;
    577           bTryNx2N  = false;
    578           bTry2NxN  = false;
    579           if( pcTextureCU->getDepth(uiCUIdx) == uiDepth && pcTextureCU->getPartitionSize(uiCUIdx) != SIZE_2Nx2N)
    580           {
    581             if(pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxN || pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxnU|| pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxnD)
    582             {
    583               bTry2NxN  = true;
    584             }
    585             else
    586             {
    587               bTryNx2N  = true;
    588             }
    589           }
    590         }
    591       }
    592 #endif
    593 
    594 #if NH_3D_NBDV
    595       if( rpcTempCU->getSlice()->getSliceType() != I_SLICE )
    596       {
    597 #if NH_3D_ARP && NH_3D_IV_MERGE && NH_3D_VSP
    598         if( rpcTempCU->getSlice()->getIvResPredFlag() || rpcTempCU->getSlice()->getIvMvPredFlag() || rpcTempCU->getSlice()->getViewSynthesisPredFlag() )
    599 #else
    600 #if NH_3D_IV_MERGE && NH_3D_VSP
    601         if( rpcTempCU->getSlice()->getIvMvPredFlag() || rpcTempCU->getSlice()->getViewSynthesisPredFlag() )
    602 #else
    603 #if NH_3D_ARP && NH_3D_VSP
    604         if( rpcTempCU->getSlice()->getIvResPredFlag() || rpcTempCU->getSlice()->getViewSynthesisPredFlag() )
    605 #else
    606 #if NH_3D_VSP
    607         if( rpcTempCU->getSlice()->getViewSynthesisPredFlag() )
    608 #else
    609 #if NH_3D_ARP
    610         if( rpcTempCU->getSlice()->getIvResPredFlag() )
    611 #else
    612 #if H_3D_IV_MERGE
    613         if( rpcTempCU->getSlice()->getVPS()->getIvMvPredFlag(rpcTempCU->getSlice()->getLayerId()) )
    614 #else
    615 #if NH_3D_DBBP
    616         if( rpcTempCU->getSlice()->getDepthBasedBlkPartFlag() )
    617 #else
    618         if (0)
    619 #endif
    620 #endif
    621 #endif
    622 #endif
    623 #endif
    624 #endif
    625 #endif
    626         {
    627           PartSize ePartTemp = rpcTempCU->getPartitionSize(0);
    628           rpcTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, uiDepth);
    629 #if NH_3D_IV_MERGE
    630           if (rpcTempCU->getSlice()->getIsDepth() )
    631           {
    632             rpcTempCU->getDispforDepth(0, 0, &DvInfo);
    633           }
    634           else
    635           {
    636 #endif
    637 #if NH_3D_NBDV_REF
    638             if( rpcTempCU->getSlice()->getDepthRefinementFlag() )
    639             {
    640               rpcTempCU->getDisMvpCandNBDV(&DvInfo, true);
    641             }
    642             else
    643 #endif
    644             {
    645               rpcTempCU->getDisMvpCandNBDV(&DvInfo);
    646             }
    647 #if NH_3D_IV_MERGE
    648           }
    649 #endif
    650           rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    651           rpcBestCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    652           rpcTempCU->setPartSizeSubParts( ePartTemp, 0, uiDepth );
    653         }
    654       }
    655 #if  NH_3D_FAST_TEXTURE_ENCODING
    656       if(rpcTempCU->getSlice()->getViewIndex() && !rpcTempCU->getSlice()->getIsDepth() && rpcTempCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
    657       {
    658         PartSize ePartTemp = rpcTempCU->getPartitionSize(0);
    659         rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
    660         rpcTempCU->getIVNStatus( 0, &DvInfo,  bIVFMerge, iIVFMaxD);
    661         rpcTempCU->setPartSizeSubParts( ePartTemp, 0, uiDepth );
    662       }
    663 #endif
    664 #endif
     463
    665464      // do inter modes, SKIP and 2Nx2N
    666465      if( rpcBestCU->getSlice()->getSliceType() != I_SLICE )
    667466      {
    668 #if NH_3D_IC
    669         for( UInt uiICId = 0; uiICId < ( bICEnabled ? 2 : 1 ); uiICId++ )
    670         {
    671           Bool bICFlag = uiICId ? true : false;
    672 #endif
    673467        // 2Nx2N
    674468        if(m_pcEncCfg->getUseEarlySkipDetection())
    675469        {
    676 #if NH_3D_IC
    677             rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    678 #endif
    679 #if  NH_3D_FAST_TEXTURE_ENCODING
    680           xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD );  rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode  );//by Competition for inter_2Nx2N
    681 #else
    682470          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug) );
    683471          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N
    684 #endif
    685 #if NH_3D_VSP  || NH_3D_DBBP
    686           rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    687 #endif
    688472        }
    689473        // SKIP
    690 #if NH_3D_IC
    691           rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    692 #endif
    693474        xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU DEBUG_STRING_PASS_INTO(sDebug), &earlyDetectionSkipMode );//by Merge for inter_2Nx2N
    694 #if  NH_3D_FAST_TEXTURE_ENCODING
    695           bFMD = bIVFMerge && rpcBestCU->isSkipped(0);
    696 #endif
    697475
    698476        rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    699 #if NH_3D_VSP  || NH_3D_DBBP
    700         rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    701 #endif
    702477
    703478        if(!m_pcEncCfg->getUseEarlySkipDetection())
    704479        {
    705480          // 2Nx2N, NxN
    706 #if NH_3D_IC
    707             rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    708 #endif
    709 #if  NH_3D_FAST_TEXTURE_ENCODING
    710             xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD );  rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    711 #else
    712481
    713482          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug) );
    714483          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    715 #endif
    716 #if NH_3D_VSP  || NH_3D_DBBP
    717           rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    718 #endif
    719 #if NH_3D_DBBP
    720             if( rpcTempCU->getSlice()->getDepthBasedBlkPartFlag() && rpcTempCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
    721             {
    722               xCheckRDCostInterDBBP( rpcBestCU, rpcTempCU DEBUG_STRING_PASS_INTO(sDebug), false );
    723               rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode  );
    724 #if NH_3D_VSP  || NH_3D_DBBP
    725               rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    726 #endif
    727             }
    728 #endif
    729484
    730485          if(m_pcEncCfg->getUseCbfFastMode())
     
    733488          }
    734489        }
    735 #if NH_3D_IC
    736         }
    737 #endif
    738490      }
    739 #if NH_3D_QTL
    740       if(depthMapDetect && !bIntraSliceDetect && !rapPic && ( m_pcEncCfg->getUseQTL() || bLimQtPredFalg ))
    741       {
    742         bTrySplitDQP = bTrySplit;
    743       }
    744 #endif
    745491
    746492      if (bIsLosslessMode) // Restore loop variable if lossless mode was searched.
     
    750496    }
    751497
    752 #if KWU_RC_MADPRED_E0227
    753     if ( uiDepth <= m_addSADDepth )
    754     {
    755       m_LCUPredictionSAD += m_temporalSAD;
    756       m_addSADDepth = uiDepth;
    757     }
    758 #endif
    759 #if NH_3D_ENC_DEPTH
    760     if( rpcBestCU->getSlice()->getIsDepth() && rpcBestCU->getSlice()->isIRAP() )
    761     {
    762       earlyDetectionSkipMode = false;
    763     }
    764 #endif
    765 #if NH_3D_DIS
    766     rpcTempCU->initEstData( uiDepth, iMinQP, isAddLowestQP  );
    767     if( rpcBestCU->getSlice()->getDepthIntraSkipFlag() )
    768     {
    769       xCheckRDCostDIS( rpcBestCU, rpcTempCU, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug) );
    770       rpcTempCU->initEstData( uiDepth, iMinQP, isAddLowestQP  );
    771     }
    772 #endif
    773498    if(!earlyDetectionSkipMode)
    774499    {
     
    792517          {
    793518            if( uiDepth == sps.getLog2DiffMaxMinCodingBlockSize() && doNotBlockPu
    794 #if NH_3D_QTL
    795                 && bTrySplit
    796 #endif
    797519)
    798520            {
    799 #if  NH_3D_FAST_TEXTURE_ENCODING
    800               xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN DEBUG_STRING_PASS_INTO(sDebug), bFMD  );
    801 #else
    802521
    803522              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN DEBUG_STRING_PASS_INTO(sDebug)   );
    804 #endif
    805523              rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    806 #if NH_3D_VSP || NH_3D_DBBP
    807               rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    808 #endif
    809524
    810525            }
     
    812527
    813528          if(doNotBlockPu
    814 #if NH_3D_QTL
    815             && bTryNx2N
    816 #endif
    817529)
    818530          {
    819 #if  NH_3D_FAST_TEXTURE_ENCODING
    820             xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD  );
    821 #else
    822531            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N DEBUG_STRING_PASS_INTO(sDebug)  );
    823 #endif
    824532            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    825 #if NH_3D_VSP || NH_3D_DBBP
    826             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    827 #endif
    828533
    829534            if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_Nx2N )
     
    833538          }
    834539          if(doNotBlockPu
    835 #if NH_3D_QTL
    836             && bTry2NxN
    837 #endif
    838540)
    839541          {
    840 #if  NH_3D_FAST_TEXTURE_ENCODING
    841             xCheckRDCostInter      ( rpcBestCU, rpcTempCU, SIZE_2NxN DEBUG_STRING_PASS_INTO(sDebug), bFMD  );
    842 #else
    843542
    844543            xCheckRDCostInter      ( rpcBestCU, rpcTempCU, SIZE_2NxN DEBUG_STRING_PASS_INTO(sDebug)  );
    845 #endif
    846544
    847545            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    848 #if NH_3D_VSP || NH_3D_DBBP
    849             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    850 #endif
    851546
    852547            if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxN)
     
    874569            {
    875570              if(doNotBlockPu
    876 #if NH_3D_QTL
    877                 && bTry2NxN
    878 #endif
    879571)
    880572              {
    881 #if  NH_3D_FAST_TEXTURE_ENCODING
    882                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU DEBUG_STRING_PASS_INTO(sDebug), bFMD );
    883 #else
    884573                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU DEBUG_STRING_PASS_INTO(sDebug) );
    885 #endif
    886574                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    887 #if NH_3D_VSP || NH_3D_DBBP
    888                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    889 #endif
    890575                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU )
    891576                {
     
    894579              }
    895580              if(doNotBlockPu
    896 #if NH_3D_QTL
    897                 && bTry2NxN
    898 #endif
    899581)
    900582              {
    901 #if  NH_3D_FAST_TEXTURE_ENCODING
    902                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD DEBUG_STRING_PASS_INTO(sDebug), bFMD );
    903 #else
    904583                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD DEBUG_STRING_PASS_INTO(sDebug) );
    905 #endif
    906584
    907585                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    908 #if NH_3D_VSP || NH_3D_DBBP
    909                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    910 #endif
    911586
    912587                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
     
    920595            {
    921596              if(doNotBlockPu
    922 #if NH_3D_QTL
    923                 && bTry2NxN
    924 #endif
    925597)
    926598              {
    927 #if  NH_3D_FAST_TEXTURE_ENCODING
    928                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU DEBUG_STRING_PASS_INTO(sDebug), bFMD, true );
    929 #else
    930599
    931600                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU DEBUG_STRING_PASS_INTO(sDebug), true );
    932 #endif
    933601
    934602                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    935 #if NH_3D_VSP || NH_3D_DBBP
    936                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    937 #endif
    938603                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU )
    939604                {
     
    942607              }
    943608              if(doNotBlockPu
    944 #if NH_3D_QTL
    945                 && bTry2NxN
    946 #endif
    947609)
    948610              {
    949 #if  NH_3D_FAST_TEXTURE_ENCODING
    950                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD DEBUG_STRING_PASS_INTO(sDebug), bFMD, true );
    951 #else
    952611                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD DEBUG_STRING_PASS_INTO(sDebug), true );
    953 #endif
    954612                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    955 #if NH_3D_VSP || NH_3D_DBBP
    956                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    957 #endif
    958613
    959614                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
     
    969624            {
    970625              if(doNotBlockPu
    971 #if NH_3D_QTL
    972                 && bTryNx2N
    973 #endif
    974626)
    975627              {
    976 #if  NH_3D_FAST_TEXTURE_ENCODING
    977                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD );
    978 #else
    979628                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N DEBUG_STRING_PASS_INTO(sDebug) );
    980 #endif
    981629
    982630                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    983 #if NH_3D_VSP || NH_3D_DBBP
    984                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    985 #endif
    986631                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N )
    987632                {
     
    990635              }
    991636              if(doNotBlockPu
    992 #if NH_3D_QTL
    993                 && bTryNx2N
    994 #endif
    995637)
    996638              {
    997 #if  NH_3D_FAST_TEXTURE_ENCODING
    998                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD );
    999 #else
    1000639                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N DEBUG_STRING_PASS_INTO(sDebug) );
    1001 #endif
    1002640                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1003 #if NH_3D_VSP || NH_3D_DBBP
    1004                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    1005 #endif
    1006641              }
    1007642            }
     
    1010645            {
    1011646              if(doNotBlockPu
    1012 #if NH_3D_QTL
    1013                 && bTryNx2N
    1014 #endif
    1015647)
    1016648              {
    1017 #if  NH_3D_FAST_TEXTURE_ENCODING
    1018                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD, true );
    1019 #else
    1020649                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N DEBUG_STRING_PASS_INTO(sDebug), true );
    1021 #endif
    1022650                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1023 #if NH_3D_VSP || NH_3D_DBBP
    1024                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    1025 #endif
    1026651                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N )
    1027652                {
     
    1030655              }
    1031656              if(doNotBlockPu
    1032 #if NH_3D_QTL
    1033                 && bTryNx2N
    1034 #endif
    1035657)
    1036658              {
    1037 #if  NH_3D_FAST_TEXTURE_ENCODING
    1038                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD, true );
    1039 #else
    1040659
    1041660                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N DEBUG_STRING_PASS_INTO(sDebug), true );
    1042 #endif
    1043661                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1044 #if NH_3D_VSP || NH_3D_DBBP
    1045                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    1046 #endif
    1047662
    1048663              }
     
    1051666
    1052667#else
    1053 #if NH_3D_QTL
    1054             if (bTry2NxN)
    1055             {
    1056 #endif
    1057668
    1058669            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
    1059670            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1060 #if NH_3D_VSP || NH_3D_DBBP
    1061             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    1062 #endif
    1063671            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
    1064672            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1065 #if NH_3D_VSP || NH_3D_DBBP
    1066             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    1067 #endif
    1068 #if NH_3D_QTL
    1069             }
    1070             if (bTryNx2N)
    1071             {
    1072 #endif
    1073673            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
    1074674            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1075 #if NH_3D_VSP || NH_3D_DBBP
    1076             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    1077 #endif
    1078675            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
    1079676            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1080 #if NH_3D_VSP || NH_3D_DBBP
    1081             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    1082 #endif
    1083 #if NH_3D_QTL
    1084             }
    1085 #endif
    1086677
    1087678
     
    1089680          }
    1090681        }
    1091 #if  NH_3D_FAST_TEXTURE_ENCODING
    1092         if(!bFMD)
    1093         {
    1094 #endif
    1095682
    1096683        // do normal intra modes
     
    1103690          ((rpcBestCU->getCbf( 0, COMPONENT_Cb ) != 0) && (numberValidComponents > COMPONENT_Cb)) ||
    1104691          ((rpcBestCU->getCbf( 0, COMPONENT_Cr ) != 0) && (numberValidComponents > COMPONENT_Cr))   // avoid very complex intra if it is unlikely
    1105  #if NH_3D_ENC_DEPTH
    1106             || rpcBestCU->getSlice()->getIsDepth()
    1107 #endif
    1108692            )))
    1109693        {
    1110 #if NH_3D_ENC_DEPTH
    1111             Bool bOnlyIVP = false;
    1112             Bool bUseIVP = true;
    1113             if( (rpcBestCU->getSlice()->getSliceType() != I_SLICE) &&
    1114                 !( (rpcBestCU->getCbf( 0, COMPONENT_Y  ) != 0)                                            ||
    1115                   ((rpcBestCU->getCbf( 0, COMPONENT_Cb ) != 0) && (numberValidComponents > COMPONENT_Cb)) ||
    1116                   ((rpcBestCU->getCbf( 0, COMPONENT_Cr ) != 0) && (numberValidComponents > COMPONENT_Cr))   ) &&
    1117                   (rpcBestCU->getSlice()->getIsDepth() && !(rpcBestCU->getSlice()->isIRAP())) )
    1118             {
    1119               bOnlyIVP = true;
    1120               bUseIVP = rpcBestCU->getSlice()->getIntraContourFlag();
    1121             }
    1122             if( bUseIVP )
    1123             {
    1124               xCheckRDCostIntra( rpcBestCU, rpcTempCU, intraCost, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug), bOnlyIVP );
    1125 #else
    1126694          xCheckRDCostIntra( rpcBestCU, rpcTempCU, intraCost, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug) );
    1127 #endif
    1128 #if KWU_RC_MADPRED_E0227
    1129             if ( uiDepth <= m_addSADDepth )
    1130             {
    1131               m_LCUPredictionSAD += m_spatialSAD;
    1132               m_addSADDepth = uiDepth;
    1133             }
    1134 #endif
    1135695
    1136696          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1137697          if( uiDepth == sps.getLog2DiffMaxMinCodingBlockSize() )
    1138698          {
    1139 #if NH_3D_QTL //Try IntraNxN
    1140               if(bTrySplit)
    1141               {
    1142 #endif
    1143699            if( rpcTempCU->getWidth(0) > ( 1 << sps.getQuadtreeTULog2MinSize() ) )
    1144700            {
    1145701              Double tmpIntraCost;
    1146 #if NH_3D_ENC_DEPTH
    1147               xCheckRDCostIntra( rpcBestCU, rpcTempCU, tmpIntraCost, SIZE_NxN DEBUG_STRING_PASS_INTO(sDebug), bOnlyIVP );
    1148 #else
    1149702              xCheckRDCostIntra( rpcBestCU, rpcTempCU, tmpIntraCost, SIZE_NxN DEBUG_STRING_PASS_INTO(sDebug)   );
    1150 #endif
    1151703
    1152704              intraCost = std::min(intraCost, tmpIntraCost);
    1153705              rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1154706            }
    1155 #if NH_3D_QTL
    1156               }
    1157 #endif
    1158707          }
    1159 #if NH_3D_ENC_DEPTH
    1160           }
    1161 #endif
    1162708        }
    1163709
     
    1169715          UInt uiRawBits = getTotalBits(rpcBestCU->getWidth(0), rpcBestCU->getHeight(0), rpcBestCU->getPic()->getChromaFormat(), sps.getBitDepths().recon);
    1170716          UInt uiBestBits = rpcBestCU->getTotalBits();
    1171 #if NH_3D_VSO // M7
    1172           Double dRDCostTemp = m_pcRdCost->getUseLambdaScaleVSO() ? m_pcRdCost->calcRdCostVSO(uiRawBits, 0) : m_pcRdCost->calcRdCost(uiRawBits, 0);
    1173           if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > dRDCostTemp ))
    1174 #else
    1175717          if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > m_pcRdCost->calcRdCost(uiRawBits, 0)))
    1176 #endif
    1177718
    1178719          {
     
    1181722          }
    1182723        }
    1183 #if  NH_3D_FAST_TEXTURE_ENCODING
    1184         }
    1185 #endif
    1186724        if (bIsLosslessMode) // Restore loop variable if lossless mode was searched.
    1187725        {
     
    1198736      rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits
    1199737      rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    1200 #if NH_3D_VSO // M8
    1201     if ( m_pcRdCost->getUseVSO() )   
    1202     {
    1203       rpcBestCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() );   
    1204     }
    1205     else
    1206 #endif
    1207738      rpcBestCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() );
    1208739      m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]);
    1209740    }
    1210 #if  NH_3D_FAST_TEXTURE_ENCODING
    1211     if(rpcBestCU->getSlice()->getViewIndex() && !rpcBestCU->getSlice()->getIsDepth() && (uiDepth >=iIVFMaxD) && rpcBestCU->isSkipped(0))
    1212     {
    1213       bSubBranch = false;
    1214     }
    1215 #endif
    1216741  }
    1217742
     
    1250775    iMaxQP = iMinQP; // If all TUs are forced into using transquant bypass, do not loop here.
    1251776  }
    1252 #if  NH_3D_FAST_TEXTURE_ENCODING
    1253   bSubBranch = bSubBranch && (bBoundary || !( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->getTotalCost()!=MAX_DOUBLE && rpcBestCU->isSkipped(0) ));
    1254 #else
    1255777  const Bool bSubBranch = bBoundary || !( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->getTotalCost()!=MAX_DOUBLE && rpcBestCU->isSkipped(0) );
    1256 #endif
    1257 #if NH_3D_QTL
    1258   if( bSubBranch && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() && (!getFastDeltaQp() || uiWidth > fastDeltaQPCuMaxSize || bBoundary) && bTrySplitDQP )
    1259 #else
    1260778  if( bSubBranch && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() && (!getFastDeltaQp() || uiWidth > fastDeltaQPCuMaxSize || bBoundary))
    1261 #endif
    1262779  {
    1263780    // further split
     
    1268785      rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1269786
    1270 #if NH_3D_VSO // M9
    1271       // reset Model
    1272       if( m_pcRdCost->getUseRenModel() )
    1273       {
    1274         UInt  uiWidthOy     = m_ppcOrigYuv[uiDepth]->getWidth ( COMPONENT_Y );
    1275         UInt  uiHeightOy    = m_ppcOrigYuv[uiDepth]->getHeight( COMPONENT_Y );
    1276         Pel*  piSrc         = m_ppcOrigYuv[uiDepth]->getAddr  ( COMPONENT_Y, 0 );
    1277         UInt  uiSrcStride   = m_ppcOrigYuv[uiDepth]->getStride( COMPONENT_Y  );
    1278         m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidthOy, uiHeightOy );
    1279       }
    1280 #endif
    1281787      UChar       uhNextDepth         = uiDepth+1;
    1282788      TComDataCU* pcSubBestPartCU     = m_ppcBestCU[uhNextDepth];
     
    1284790      DEBUG_STRING_NEW(sTempDebug)
    1285791
    1286 #if NH_3D_ARP
    1287       m_ppcWeightedTempCU[uhNextDepth]->setSlice( m_ppcWeightedTempCU[ uiDepth]->getSlice());
    1288       m_ppcWeightedTempCU[uhNextDepth]->setPic  ( m_ppcWeightedTempCU[ uiDepth] );
    1289 #endif
    1290792      for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
    1291793      {
     
    1339841        rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    1340842      }
    1341 #if NH_3D_VSO // M10
    1342       if ( m_pcRdCost->getUseVSO() )
    1343       {
    1344         rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    1345       }
    1346       else
    1347 #endif
    1348843        rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    1349844
     
    1368863          rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits
    1369864          rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    1370 #if NH_3D_VSO // M11
    1371           if ( m_pcRdCost->getUseLambdaScaleVSO())         
    1372           {
    1373             rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );         
    1374           }
    1375           else
    1376 #endif
    1377865            rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    1378866
     
    1414902    }
    1415903  }
    1416 #if NH_3D_VSO // M12
    1417   if( m_pcRdCost->getUseRenModel() )
    1418   {
    1419     UInt  uiWidthRy     = m_ppcRecoYuvBest[uiDepth]->getWidth   ( COMPONENT_Y );
    1420     UInt  uiHeightRy    = m_ppcRecoYuvBest[uiDepth]->getHeight  ( COMPONENT_Y );
    1421     Pel*  piSrc       = m_ppcRecoYuvBest[uiDepth]->getAddr    ( COMPONENT_Y,  0 );
    1422     UInt  uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride  ( COMPONENT_Y );
    1423     m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidthRy, uiHeightRy );
    1424   }
    1425 #endif
    1426904
    1427905  DEBUG_STRING_APPEND(sDebug_, sDebug);
     
    15951073
    15961074    m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx );
    1597 #if NH_3D_ARP
    1598     m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx );
    1599 #endif
    1600 #if NH_3D_IC
    1601     m_pcEntropyCoder->encodeICFlag  ( pcCU, uiAbsPartIdx );
    1602 #endif
    16031075
    16041076    finishCU(pcCU,uiAbsPartIdx);
     
    16061078  }
    16071079
    1608 #if NH_3D_DIS
    1609   m_pcEntropyCoder->encodeDIS( pcCU, uiAbsPartIdx );
    1610   if(!pcCU->getDISFlag(uiAbsPartIdx))
    1611   {
    1612 #endif
    16131080  m_pcEntropyCoder->encodePredMode( pcCU, uiAbsPartIdx );
    16141081  m_pcEntropyCoder->encodePartSize( pcCU, uiAbsPartIdx, uiDepth );
     
    16201087    if(pcCU->getIPCMFlag(uiAbsPartIdx))
    16211088    {
    1622 #if NH_3D_SDC_INTRA
    1623       m_pcEntropyCoder->encodeSDCFlag( pcCU, uiAbsPartIdx );
    1624 #endif 
    16251089
    16261090      // Encode slice finish
     
    16321096  // prediction Info ( Intra : direction mode, Inter : Mv, reference idx )
    16331097  m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx );
    1634 #if NH_3D_DBBP
    1635   m_pcEntropyCoder->encodeDBBPFlag( pcCU, uiAbsPartIdx );
    1636 #endif
    1637 #if NH_3D_SDC_INTRA
    1638   m_pcEntropyCoder->encodeSDCFlag( pcCU, uiAbsPartIdx );
    1639 #endif 
    1640 #if NH_3D_ARP
    1641   m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx );
    1642 #endif
    1643 #if NH_3D_IC
    1644   m_pcEntropyCoder->encodeICFlag  ( pcCU, uiAbsPartIdx );
    1645 #endif
    16461098
    16471099  // Encode Coefficients
     
    16511103  setCodeChromaQpAdjFlag( codeChromaQpAdj );
    16521104  setdQPFlag( bCodeDQP );
    1653 #if NH_3D_DIS
    1654   }
    1655 #endif
    16561105
    16571106
     
    17921241#endif
    17931242
    1794 #if NH_3D_MLC
    1795   TComMvField  cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    1796   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
    1797 #else
    17981243  TComMvField  cMvFieldNeighbours[2 * MRG_MAX_NUM_CANDS]; // double length for mv of both lists
    17991244  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    1800 #endif
    18011245  Int numValidMergeCand = 0;
    18021246  const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0);
     
    18071251  }
    18081252  UChar uhDepth = rpcTempCU->getDepth( 0 );
    1809 #if NH_3D_IC
    1810   Bool bICFlag = rpcTempCU->getICFlag( 0 );
    1811 #endif
    1812 #if NH_3D_VSO // M1  //necessary here?
    1813   if( m_pcRdCost->getUseRenModel() )
    1814   {
    1815     UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( COMPONENT_Y );
    1816     UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( COMPONENT_Y );
    1817     Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getAddr  ( COMPONENT_Y );
    1818     UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride( COMPONENT_Y );
    1819     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1820   }
    1821 #endif
    1822 
    1823 #if NH_3D_ARP
    1824   DisInfo cOrigDisInfo = rpcTempCU->getDvInfo(0);
    1825 #else
    1826 #endif
     1253
    18271254
    18281255  rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to CTU level
    18291256
    1830 #if NH_3D_SPIVMP
    1831   Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
    1832   memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    1833   TComMvField*  pcMvFieldSP;
    1834   UChar* puhInterDirSP;
    1835   pcMvFieldSP = new TComMvField[rpcTempCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2];
    1836   puhInterDirSP = new UChar[rpcTempCU->getPic()->getPicSym()->getNumPartitionsInCtu()];
    1837 #endif
    1838 
    1839 #if NH_3D_VSP
    1840 #if !NH_3D_ARP
    1841   Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    1842   memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    1843 #if NH_3D_MLC
    1844   rpcTempCU->initAvailableFlags();
    1845 #endif
    1846   rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    1847 #if NH_3D_MLC
    1848   rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
    1849 #if NH_3D_SPIVMP
    1850     , pcMvFieldSP, puhInterDirSP
    1851 #endif
    1852     , numValidMergeCand
    1853     );
    1854 
    1855   rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours, vspFlag
    1856 #if NH_3D_SPIVMP
    1857     , bSPIVMPFlag
    1858 #endif
    1859     , numValidMergeCand
    1860     );
    1861 #endif
    1862 #endif
    1863 #else
    1864 #if NH_3D_MLC
    1865   rpcTempCU->initAvailableFlags();
    1866 #endif
     1257
    18671258  rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
    1868 #if NH_3D_MLC
    1869   rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
    1870 #if H_3D_SPIVMP
    1871     , pcMvFieldSP, puhInterDirSP
    1872 #endif
    1873     , numValidMergeCand
    1874     );
    1875 #if NH_3D_MLC
    1876   rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours
    1877 #if H_3D_SPIVMP
    1878     , bSPIVMPFlag
    1879 #endif
    1880     , numValidMergeCand
    1881     );
    1882 #endif
    1883 #endif
    1884 #endif
    1885 
    1886 #if NH_3D_MLC
    1887   Int mergeCandBuffer[MRG_MAX_NUM_CANDS_MEM];
    1888 #else
     1259
    18891260  Int mergeCandBuffer[MRG_MAX_NUM_CANDS];
    1890 #endif
    1891 #if NH_3D_MLC
    1892   for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
    1893 #else
    18941261  for( UInt ui = 0; ui < numValidMergeCand; ++ui )
    1895 #endif
    18961262  {
    18971263    mergeCandBuffer[ui] = 0;
     
    19111277  DEBUG_STRING_NEW(bestStr)
    19121278
    1913 #if NH_3D_ARP
    1914   Int nARPWMax = rpcTempCU->getSlice()->getARPStepNum() - 1;
    1915 #if NH_3D_IC
    1916   if( nARPWMax < 0 || bICFlag )
    1917 #else
    1918   if( nARPWMax < 0 )
    1919 #endif
    1920   {
    1921     nARPWMax = 0;
    1922   }
    1923   for( Int nARPW=nARPWMax; nARPW >= 0 ; nARPW-- )
    1924   {
    1925 #if NH_3D
    1926 #if DEBUG_STRING
    1927     bestStr.clear();
    1928 #endif
    1929 #endif
    1930 #if NH_3D_IV_MERGE
    1931     memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS_MEM*sizeof(Int) );
    1932 #else
    1933     memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS * sizeof(Int) );
    1934 #endif
    1935     rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
    1936     rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
    1937 #if NH_3D_IC
    1938     rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth );
    1939 #endif
    1940     rpcTempCU->getDvInfo(0) = cOrigDisInfo;
    1941     rpcTempCU->setDvInfoSubParts(cOrigDisInfo, 0, uhDepth );
    1942 #if NH_3D_VSP
    1943     Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    1944     memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    1945 #endif
    1946 #if NH_3D
    1947 #if NH_3D_MLC
    1948     rpcTempCU->initAvailableFlags();
    1949 #endif
    1950     rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    1951     rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
    1952 #if NH_3D_SPIVMP
    1953       , pcMvFieldSP, puhInterDirSP
    1954 #endif
    1955       , numValidMergeCand
    1956       );
    1957 
    1958     rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours
    1959 #if NH_3D_VSP
    1960       , vspFlag
    1961 #endif
    1962 #if NH_3D_SPIVMP
    1963       , bSPIVMPFlag
    1964 #endif
    1965       , numValidMergeCand
    1966       );
    1967 
    1968 #else
    1969     rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
    1970 #endif
    1971 
    1972 
    1973 #endif
    19741279
    19751280  for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual )
     
    19811286    for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
    19821287    {
    1983 #if NH_3D_IC
    1984       if( rpcTempCU->getSlice()->getApplyIC() && rpcTempCU->getSlice()->getIcSkipParseFlag() )
    1985       {
    1986         if( bICFlag && uiMergeCand == 0 )
    1987         {
    1988           continue;
    1989         }
    1990       }
    1991 #endif
    19921288#if NH_MV
    19931289      D_PRINT_INC_INDENT ( g_traceModeCheck, "uiMergeCand: "+  n2s(uiMergeCand) );
     
    20011297          // set MC parameters
    20021298          rpcTempCU->setPredModeSubParts( MODE_INTER, 0, uhDepth ); // interprets depth relative to CTU level
    2003 #if NH_3D_IC
    2004           rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth );
    2005 #endif
    20061299          rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag, 0, uhDepth );
    20071300          rpcTempCU->setChromaQpAdjSubParts( bTransquantBypassFlag ? 0 : m_cuChromaQpOffsetIdxPlus1, 0, uhDepth );
     
    20091302          rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to CTU level
    20101303          rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to CTU level
    2011 #if NH_3D_ARP
    2012           rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
    2013 #endif
    2014 
    2015 #if NH_3D_VSP
    2016           rpcTempCU->setVSPFlagSubParts( vspFlag[uiMergeCand], 0, 0, uhDepth );
    2017 #endif
    2018 #if NH_3D_SPIVMP
    2019           rpcTempCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeCand], 0, 0, uhDepth);
    2020           if (bSPIVMPFlag[uiMergeCand])
     1304
    20211305          {
    2022             UInt uiSPAddr;
    2023             Int iWidth = rpcTempCU->getWidth(0);
    2024             Int iHeight = rpcTempCU->getHeight(0);
    2025             Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    2026             rpcTempCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    2027             for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    2028             {
    2029               rpcTempCU->getSPAbsPartIdx(0, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
    2030               rpcTempCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
    2031               rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(rpcTempCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
    2032               rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(rpcTempCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
    2033             }
    2034           }
    2035           else
    2036 #endif
    2037           {
    2038 #if NH_3D_VSP
    2039             if ( vspFlag[uiMergeCand] )
    2040             {
    2041               UInt partAddr;
    2042               Int vspSize;
    2043               Int width, height;
    2044               rpcTempCU->getPartIndexAndSize( 0, partAddr, width, height );
    2045               if( uhInterDirNeighbours[ uiMergeCand ] & 0x01 )
    2046               {
    2047                 rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_0, cMvFieldNeighbours[ 2*uiMergeCand + 0 ].getRefIdx(), vspSize );
    2048                 rpcTempCU->setVSPFlag( partAddr, vspSize );
    2049               }
    2050               else
    2051               {
    2052                 rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    2053               }
    2054               if( uhInterDirNeighbours[ uiMergeCand ] & 0x02 )
    2055               {
    2056                 rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_1 , cMvFieldNeighbours[ 2*uiMergeCand + 1 ].getRefIdx(), vspSize );
    2057                 rpcTempCU->setVSPFlag( partAddr, vspSize );
    2058               }
    2059               else
    2060               {
    2061                 rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    2062               }
    2063               rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
    2064             }
    2065             else
    2066             {
    2067 #endif
    20681306            rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to CTU level
    20691307            rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    20701308            rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    2071 #if NH_3D_VSP
    2072             }
    2073 #endif
    20741309          }
    20751310          // do MC
    20761311          m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
    20771312          // estimate residual and encode everything
    2078 #if NH_3D_VSO //M2
    2079           if( m_pcRdCost->getUseRenModel() )
    2080           { //Reset
    2081             UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ( COMPONENT_Y );
    2082             UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ( COMPONENT_Y );
    2083             Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getAddr     ( COMPONENT_Y );
    2084             UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ( COMPONENT_Y );
    2085             m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2086           }
    2087 #endif
    20881313          m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU,
    20891314                                                     m_ppcOrigYuv    [uhDepth],
     
    21031328            mergeCandBuffer[uiMergeCand] = 1;
    21041329          }
    2105 #if NH_3D_DIS
    2106           rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
    2107 #endif
    2108 #if NH_3D_VSP
    2109           if( rpcTempCU->getSkipFlag(0) )
    2110           {
    2111             rpcTempCU->setTrIdxSubParts(0, 0, uhDepth);
    2112           }
    2113 #endif
    2114 #if NH_3D_SDC_INTER
    2115           TComDataCU *rpcTempCUPre = rpcTempCU;
    2116 #endif
    21171330          Int orgQP = rpcTempCU->getQP( 0 );
    21181331          xCheckDQP( rpcTempCU );
    21191332          xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth DEBUG_STRING_PASS_INTO(bestStr) DEBUG_STRING_PASS_INTO(tmpStr));
    2120 #if NH_3D_SDC_INTER
    2121           if( rpcTempCU->getSlice()->getInterSdcFlag() && !uiNoResidual )
    2122           {
    2123             Double dOffsetCost[3] = {MAX_DOUBLE,MAX_DOUBLE,MAX_DOUBLE};
    2124             for( Int uiOffest = 1 ; uiOffest <= 5 ; uiOffest++ )
    2125             {
    2126               if( uiOffest > 3)
    2127               {
    2128                 if ( dOffsetCost[0] < (0.9*dOffsetCost[1]) && dOffsetCost[0] < (0.9*dOffsetCost[2]) )
    2129                 {
    2130                   continue;
    2131                 }
    2132                 if ( dOffsetCost[1] < dOffsetCost[0] && dOffsetCost[0] < dOffsetCost[2] &&  uiOffest == 5)
    2133                 {
    2134                   continue;
    2135                 }
    2136                 if ( dOffsetCost[0] < dOffsetCost[1] && dOffsetCost[2] < dOffsetCost[0] &&  uiOffest == 4)
    2137                 {
    2138                   continue;
    2139                 }
    2140               }
    2141               if( rpcTempCU != rpcTempCUPre )
    2142               {
    2143                 rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag  );
    2144                 rpcTempCU->copyPartFrom( rpcBestCU, 0, uhDepth );
    2145               }
    2146               rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
    2147 #if NH_3D_DIS
    2148               rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
    2149 #endif
    2150               rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth );
    2151               rpcTempCU->setCbfSubParts( 1, COMPONENT_Y, 0, uhDepth );
    2152 #if NH_3D_VSO //M2
    2153               if( m_pcRdCost->getUseRenModel() )
    2154               { //Reset
    2155                 UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ( COMPONENT_Y );
    2156                 UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ( COMPONENT_Y );
    2157                 Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getAddr     ( COMPONENT_Y );
    2158                 UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ( COMPONENT_Y );
    2159                 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2160               }
    2161 #endif
    2162               Int iSdcOffset = 0;
    2163               if(uiOffest % 2 == 0)
    2164               {
    2165                 iSdcOffset = uiOffest >> 1;
    2166               }
    2167               else
    2168               {
    2169                 iSdcOffset = -1 * (uiOffest >> 1);
    2170               }
    2171               m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU,
    2172                 m_ppcOrigYuv[uhDepth],
    2173                 ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth],
    2174                 m_ppcResiYuvTemp[uhDepth],
    2175                 m_ppcRecoYuvTemp[uhDepth],
    2176                 iSdcOffset,
    2177                 uhDepth );
    2178               if (uiOffest <= 3 )
    2179               {
    2180                 dOffsetCost [uiOffest -1] = rpcTempCU->getTotalCost();
    2181               }
    2182 
    2183               xCheckDQP( rpcTempCU );
    2184               xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth DEBUG_STRING_PASS_INTO(bestStr) DEBUG_STRING_PASS_INTO(tmpStr) );
    2185             }
    2186           }
    2187 #endif
    21881333
    21891334          rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag );
     
    21911336          if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
    21921337          {
    2193 #if NH_3D_SDC_INTER
    2194             if( rpcTempCU->getSlice()->getInterSdcFlag() )
    2195             {
    2196               bestIsSkip = !rpcBestCU->getSDCFlag( 0 ) && ( rpcBestCU->getQtRootCbf(0) == 0 );
    2197             }
    2198             else
    2199             {
    2200 #endif
    22011338            bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0;
    2202 #if NH_3D_SDC_INTER
    2203             }
    2204 #endif
    22051339          }
    22061340        }
     
    22451379  }
    22461380  DEBUG_STRING_APPEND(sDebug, bestStr)
    2247 #if NH_3D_ARP
    2248  }
    2249 #endif
    2250 #if NH_3D_SPIVMP
    2251  delete[] pcMvFieldSP;
    2252  delete[] puhInterDirSP;
    2253 #endif
    22541381#if NH_MV
    22551382 D_DEC_INDENT( g_traceModeCheck );
     
    22591386
    22601387#if AMP_MRG
    2261 #if  NH_3D_FAST_TEXTURE_ENCODING
    2262 Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug), Bool bFMD, Bool bUseMRG)
    2263 #else
    22641388Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug), Bool bUseMRG)
    2265 #endif
    22661389#else
    22671390Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize )
     
    22861409
    22871410  // prior to this, rpcTempCU will have just been reset using rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    2288 #if NH_3D_ARP
    2289   const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0);
    2290 #endif
    2291 #if  NH_3D_FAST_TEXTURE_ENCODING
    2292   if(!(bFMD && (ePartSize == SIZE_2Nx2N)))  //have  motion estimation or merge check
    2293   {
    2294 #endif
    22951411  UChar uhDepth = rpcTempCU->getDepth( 0 );
    2296 #if NH_3D_ARP
    2297     Bool bFirstTime = true;
    2298     Int nARPWMax    = rpcTempCU->getSlice()->getARPStepNum() - 1;
    2299 #if NH_3D_IC
    2300     if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N || rpcTempCU->getICFlag(0) )
    2301 #else
    2302     if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N )
    2303 #endif
    2304     {
    2305       nARPWMax = 0;
    2306     }
    2307 
    2308     for( Int nARPW = 0; nARPW <= nARPWMax; nARPW++ )
    2309     {
    2310 #if DEBUG_STRING && NH_MV_ENC_DEC_TRAC
    2311       sTest.clear();
    2312 #endif
    2313 
    2314       if( !bFirstTime && rpcTempCU->getSlice()->getIvResPredFlag() )
    2315       {
    2316         rpcTempCU->initEstData( rpcTempCU->getDepth(0), rpcTempCU->getQP(0),bTransquantBypassFlag );     
    2317       }
    2318 #endif
    2319 #if NH_3D_VSO // M3
    2320       if( m_pcRdCost->getUseRenModel() )
    2321       {
    2322         UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( COMPONENT_Y );
    2323         UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( COMPONENT_Y );
    2324         Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getAddr  ( COMPONENT_Y );
    2325         UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride( COMPONENT_Y );
    2326         m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2327       }
    2328 #endif
    2329 #if NH_3D_DIS
    2330       rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
    2331 #endif
    23321412  rpcTempCU->setPartSizeSubParts  ( ePartSize,  0, uhDepth );
    23331413  rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
    23341414  rpcTempCU->setChromaQpAdjSubParts( rpcTempCU->getCUTransquantBypass(0) ? 0 : m_cuChromaQpOffsetIdxPlus1, 0, uhDepth );
    2335 #if NH_3D_ARP
    2336       rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
    2337 #endif
    2338 #if NH_3D_ARP
    2339       if( bFirstTime == false && nARPWMax )
    2340       {
    2341         rpcTempCU->copyPartFrom( m_ppcWeightedTempCU[uhDepth] , 0 , uhDepth );
    2342         rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
    2343 
    2344         m_pcPredSearch->motionCompensation( rpcTempCU , m_ppcPredYuvTemp[uhDepth] );
    2345       }
    2346       else
    2347       {
    2348         bFirstTime = false;
    2349 #endif
    23501415#if AMP_MRG
    23511416  rpcTempCU->setMergeAMP (true);
    2352 #if  NH_3D_FAST_TEXTURE_ENCODING
    2353         m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] DEBUG_STRING_PASS_INTO(sTest), bFMD, false, bUseMRG );
    2354 #else
    23551417  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] DEBUG_STRING_PASS_INTO(sTest), false, bUseMRG );
    2356 #endif
    23571418
    23581419#else
    23591420  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
    23601421#endif
    2361 #if NH_3D_ARP
    2362         if( nARPWMax )
    2363         {
    2364           m_ppcWeightedTempCU[uhDepth]->copyPartFrom( rpcTempCU , 0 , uhDepth );
    2365         }
    2366       }
    2367 #endif
    23681422
    23691423#if AMP_MRG
    23701424  if ( !rpcTempCU->getMergeAMP() )
    23711425  {
    2372 #if NH_3D_ARP
    2373         if( nARPWMax )
    2374         {
    2375           continue;
    2376         }
    2377         else
    2378 #endif
    23791426    {
    23801427#if NH_MV
     
    23851432  }
    23861433#endif
    2387 #if KWU_RC_MADPRED_E0227
    2388       if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth )
    2389       {
    2390         UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(),
    2391           m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(),
    2392           rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) );
    2393         m_temporalSAD = (Int)SAD;
    2394       }
    2395 #endif
    23961434
    23971435  m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false DEBUG_STRING_PASS_INTO(sTest) );
    2398 #if NH_3D_VSP
    2399   if( rpcTempCU->getQtRootCbf(0)==0 )
    2400   {
    2401     rpcTempCU->setTrIdxSubParts(0, 0, uhDepth);
    2402   }
    2403 #endif
    2404 #if NH_3D_VSO // M4
    2405   if( m_pcRdCost->getUseLambdaScaleVSO() )
    2406   {
    2407     rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    2408   }
    2409   else           
    2410 #endif
    24111436    rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    24121437
     
    24141439  DebugInterPredResiReco(sTest, *(m_ppcPredYuvTemp[uhDepth]), *(m_ppcResiYuvBest[uhDepth]), *(m_ppcRecoYuvTemp[uhDepth]), DebugStringGetPredModeMask(rpcTempCU->getPredictionMode(0)));
    24151440#endif
    2416 #if NH_3D_SDC_INTER
    2417       TComDataCU *rpcTempCUPre = rpcTempCU;
    2418 #endif
    24191441
    24201442  xCheckDQP( rpcTempCU );
    24211443  xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest));
    2422 #if NH_3D_SDC_INTER
    2423       if( rpcTempCU->getSlice()->getInterSdcFlag() && ePartSize == SIZE_2Nx2N)
    2424       {
    2425         Double dOffsetCost[3] = {MAX_DOUBLE,MAX_DOUBLE,MAX_DOUBLE};
    2426         for( Int uiOffest = 1 ; uiOffest <= 5 ; uiOffest++ )
    2427         {
    2428           if( uiOffest > 3)
    2429           {
    2430             if ( dOffsetCost[0] < (0.9*dOffsetCost[1]) && dOffsetCost[0] < (0.9*dOffsetCost[2]) )
    2431             {
    2432               continue;
    2433             }
    2434             if ( dOffsetCost[1] < dOffsetCost[0] && dOffsetCost[0] < dOffsetCost[2] &&  uiOffest == 5)
    2435             {
    2436               continue;
    2437             }
    2438             if ( dOffsetCost[0] < dOffsetCost[1] && dOffsetCost[2] < dOffsetCost[0] &&  uiOffest == 4)
    2439             {
    2440               continue;
    2441             }
    2442           }
    2443 
    2444           if( rpcTempCU != rpcTempCUPre )
    2445           {
    2446             Int orgQP = rpcBestCU->getQP( 0 );
    2447             rpcTempCU->initEstData( uhDepth, orgQP ,bTransquantBypassFlag );     
    2448             rpcTempCU->copyPartFrom( rpcBestCU, 0, uhDepth );
    2449           }
    2450           rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
    2451 #if NH_3D_DIS
    2452           rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
    2453 #endif
    2454           rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth );
    2455           rpcTempCU->setCbfSubParts( 1, COMPONENT_Y, 0, uhDepth );
    2456 #if NH_3D_VSO // M3
    2457           if( m_pcRdCost->getUseRenModel() )
    2458           {
    2459             UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( COMPONENT_Y );
    2460             UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( COMPONENT_Y  );
    2461             Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getAddr  ( COMPONENT_Y  );
    2462             UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride( COMPONENT_Y  );
    2463             m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2464           }
    2465 #endif
    2466 
    2467           Int iSdcOffset = 0;
    2468           if(uiOffest % 2 == 0)
    2469           {
    2470             iSdcOffset = uiOffest >> 1;
    2471           }
    2472           else
    2473           {
    2474             iSdcOffset = -1 * (uiOffest >> 1);
    2475           }
    2476           m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU,
    2477             m_ppcOrigYuv[uhDepth],
    2478             ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth],
    2479             m_ppcResiYuvTemp[uhDepth],
    2480             m_ppcRecoYuvTemp[uhDepth],
    2481             iSdcOffset,
    2482             uhDepth );
    2483           if (uiOffest <= 3 )
    2484           {
    2485             dOffsetCost [uiOffest -1] = rpcTempCU->getTotalCost();
    2486           }
    2487 
    2488           xCheckDQP( rpcTempCU );
    2489           xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest));
    2490         }
    2491 
    2492       }
    2493 #endif
    2494 #if NH_3D_ARP
    2495     }
    2496 #endif
    2497 #if  NH_3D_FAST_TEXTURE_ENCODING
    2498   }
    2499 #endif
    25001444#if NH_MV
    25011445  D_DEC_INDENT( g_traceModeCheck );
     
    25031447}
    25041448
    2505 #if NH_3D_DBBP
    2506 Void TEncCu::xInvalidateOriginalSegments( TComYuv* pOrigYuv, TComYuv* pOrigYuvTemp, Bool* pMask, UInt uiValidSegment )
    2507 {
    2508   UInt  uiWidth     = pOrigYuv->getWidth (COMPONENT_Y);
    2509   UInt  uiHeight    = pOrigYuv->getHeight(COMPONENT_Y);
    2510   Pel*  piSrc       = pOrigYuv->getAddr(COMPONENT_Y);
    2511   UInt  uiSrcStride = pOrigYuv->getStride(COMPONENT_Y);
    2512   Pel*  piDst       = pOrigYuvTemp->getAddr(COMPONENT_Y);
    2513   UInt  uiDstStride = pOrigYuvTemp->getStride(COMPONENT_Y);
    2514  
    2515   UInt  uiMaskStride= MAX_CU_SIZE;
    2516  
    2517   AOF( uiWidth == uiHeight );
    2518  
    2519   // backup pointer
    2520   Bool* pMaskStart = pMask;
    2521  
    2522   for (Int y=0; y<uiHeight; y++)
    2523   {
    2524     for (Int x=0; x<uiWidth; x++)
    2525     {
    2526       UChar ucSegment = (UChar)pMask[x];
    2527       AOF( ucSegment < 2 );
    2528      
    2529       piDst[x] = (ucSegment==uiValidSegment)?piSrc[x]:DBBP_INVALID_SHORT;
    2530     }
    2531    
    2532     piSrc  += uiSrcStride;
    2533     piDst  += uiDstStride;
    2534     pMask  += uiMaskStride;
    2535   }
    2536  
    2537   // now invalidate chroma
    2538   Pel*  piSrcU       = pOrigYuv->getAddr(COMPONENT_Cb);
    2539   Pel*  piSrcV       = pOrigYuv->getAddr(COMPONENT_Cr);
    2540   UInt  uiSrcStrideC = pOrigYuv->getStride(COMPONENT_Cb);
    2541   Pel*  piDstU       = pOrigYuvTemp->getAddr(COMPONENT_Cb);
    2542   Pel*  piDstV       = pOrigYuvTemp->getAddr(COMPONENT_Cr);
    2543   UInt  uiDstStrideC = pOrigYuvTemp->getStride(COMPONENT_Cb);
    2544   pMask = pMaskStart;
    2545  
    2546   for (Int y=0; y<uiHeight/2; y++)
    2547   {
    2548     for (Int x=0; x<uiWidth/2; x++)
    2549     {
    2550       UChar ucSegment = (UChar)pMask[x*2];
    2551       AOF( ucSegment < 2 );
    2552      
    2553       piDstU[x] = (ucSegment==uiValidSegment)?piSrcU[x]:DBBP_INVALID_SHORT;
    2554       piDstV[x] = (ucSegment==uiValidSegment)?piSrcV[x]:DBBP_INVALID_SHORT;
    2555     }
    2556    
    2557     piSrcU  += uiSrcStrideC;
    2558     piSrcV  += uiSrcStrideC;
    2559     piDstU  += uiDstStrideC;
    2560     piDstV  += uiDstStrideC;
    2561     pMask   += 2*uiMaskStride;
    2562   }
    2563 }
    2564 #endif
    2565 
    2566 #if NH_3D_DBBP
    2567 Void TEncCu::xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU  DEBUG_STRING_FN_DECLARE(sDebug), Bool bUseMRG )
    2568 {
    2569   DEBUG_STRING_NEW(sTest)
    2570   AOF( !rpcTempCU->getSlice()->getIsDepth() );
    2571  
    2572   UChar uhDepth = rpcTempCU->getDepth( 0 );
    2573  
    2574 #if NH_3D_VSO
    2575   if( m_pcRdCost->getUseRenModel() )
    2576   {
    2577     UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( COMPONENT_Y );
    2578     UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( COMPONENT_Y );
    2579     Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getAddr  ( COMPONENT_Y );
    2580     UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride( COMPONENT_Y );
    2581     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2582   }
    2583 #endif
    2584  
    2585   UInt uiWidth  = rpcTempCU->getWidth(0);
    2586   UInt uiHeight = rpcTempCU->getHeight(0);
    2587   AOF( uiWidth == uiHeight );
    2588  
    2589 #if NH_3D_DBBP
    2590   if(uiWidth <= 8)
    2591   {
    2592     return;
    2593   }
    2594 #endif
    2595  
    2596   rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N,  0, uhDepth );
    2597  
    2598   // fetch virtual depth block
    2599   UInt uiDepthStride = 0;
    2600 #if H_3D_FCO
    2601   Pel* pDepthPels = rpcTempCU->getVirtualDepthBlock(rpcTempCU->getZorderIdxInCU(), uiWidth, uiHeight, uiDepthStride);
    2602 #else
    2603   Pel* pDepthPels = rpcTempCU->getVirtualDepthBlock(0, uiWidth, uiHeight, uiDepthStride);
    2604 #endif
    2605   AOF( pDepthPels != NULL );
    2606   AOF( uiDepthStride != 0 );
    2607  
    2608   PartSize eVirtualPartSize = m_pcPredSearch->getPartitionSizeFromDepth(pDepthPels, uiDepthStride, uiWidth, rpcTempCU);
    2609 
    2610   // derive partitioning from depth
    2611   Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE];
    2612   Bool bValidMask = m_pcPredSearch->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, uiWidth, uiHeight, pMask, rpcTempCU);
    2613  
    2614   if( !bValidMask )
    2615   {
    2616     return;
    2617   }
    2618  
    2619   // find optimal motion/disparity vector for each segment
    2620   DisInfo originalDvInfo = rpcTempCU->getDvInfo(0);
    2621   DbbpTmpData* pDBBPTmpData = rpcTempCU->getDBBPTmpData();
    2622   TComYuv* apPredYuv[2] = { m_ppcRecoYuvTemp[uhDepth], m_ppcPredYuvTemp[uhDepth] };
    2623  
    2624   // find optimal motion vector fields for both segments (as 2Nx2N)
    2625   rpcTempCU->setDepthSubParts( uhDepth, 0 );
    2626   rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N,  0, uhDepth );
    2627   rpcTempCU->setPredModeSubParts( MODE_INTER, 0, uhDepth );
    2628   for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
    2629   {
    2630     rpcTempCU->setDBBPFlagSubParts(true, 0, 0, uhDepth);
    2631     rpcTempCU->setDvInfoSubParts(originalDvInfo, 0, uhDepth);
    2632    
    2633     // invalidate all other segments in original YUV
    2634     xInvalidateOriginalSegments(m_ppcOrigYuv[uhDepth], m_ppcOrigYuvDBBP[uhDepth], pMask, uiSegment);
    2635    
    2636     // do motion estimation for this segment
    2637     m_pcRdCost->setUseMask(true);
    2638     rpcTempCU->getDBBPTmpData()->eVirtualPartSize = eVirtualPartSize;
    2639     rpcTempCU->getDBBPTmpData()->uiVirtualPartIndex = uiSegment;
    2640     m_pcPredSearch->predInterSearch( rpcTempCU, m_ppcOrigYuvDBBP[uhDepth], apPredYuv[uiSegment], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth] DEBUG_STRING_PASS_INTO(sTest), false, bUseMRG );
    2641     m_pcRdCost->setUseMask(false);
    2642    
    2643     // extract motion parameters of full block for this segment
    2644     pDBBPTmpData->auhInterDir[uiSegment] = rpcTempCU->getInterDir(0);
    2645    
    2646     pDBBPTmpData->abMergeFlag[uiSegment] = rpcTempCU->getMergeFlag(0);
    2647     pDBBPTmpData->auhMergeIndex[uiSegment] = rpcTempCU->getMergeIndex(0);
    2648    
    2649 #if NH_3D_VSP
    2650     AOF( rpcTempCU->getSPIVMPFlag(0) == false );
    2651     AOF( rpcTempCU->getVSPFlag(0) == 0 );
    2652 #endif
    2653    
    2654     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    2655     {
    2656       RefPicList eRefList = (RefPicList)uiRefListIdx;
    2657      
    2658       pDBBPTmpData->acMvd[uiSegment][eRefList] = rpcTempCU->getCUMvField(eRefList)->getMvd(0);
    2659       pDBBPTmpData->aiMvpNum[uiSegment][eRefList] = rpcTempCU->getMVPNum(eRefList, 0);
    2660       pDBBPTmpData->aiMvpIdx[uiSegment][eRefList] = rpcTempCU->getMVPIdx(eRefList, 0);
    2661      
    2662       rpcTempCU->getMvField(rpcTempCU, 0, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]);
    2663     }
    2664   }
    2665  
    2666   // store final motion/disparity information in each PU using derived partitioning
    2667   rpcTempCU->setDepthSubParts( uhDepth, 0 );
    2668   rpcTempCU->setPartSizeSubParts  ( eVirtualPartSize,  0, uhDepth );
    2669   rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
    2670  
    2671   UInt uiPUOffset = ( g_auiPUOffset[UInt( eVirtualPartSize )] << ( ( rpcTempCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uhDepth ) << 1 ) ) >> 4;
    2672   for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
    2673   {
    2674     UInt uiPartAddr = uiSegment*uiPUOffset;
    2675    
    2676     rpcTempCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uhDepth);
    2677    
    2678     // now set stored information from 2Nx2N motion search to each partition
    2679     rpcTempCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uhDepth); // interprets depth relative to LCU level
    2680    
    2681     rpcTempCU->setMergeFlagSubParts(pDBBPTmpData->abMergeFlag[uiSegment], uiPartAddr, uiSegment, uhDepth);
    2682     rpcTempCU->setMergeIndexSubParts(pDBBPTmpData->auhMergeIndex[uiSegment], uiPartAddr, uiSegment, uhDepth);
    2683        
    2684     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    2685     {
    2686       RefPicList eRefList = (RefPicList)uiRefListIdx;
    2687      
    2688       rpcTempCU->getCUMvField( eRefList )->setAllMvd(pDBBPTmpData->acMvd[uiSegment][eRefList], eVirtualPartSize, uiPartAddr, 0, uiSegment);
    2689       rpcTempCU->setMVPNum(eRefList, uiPartAddr, pDBBPTmpData->aiMvpNum[uiSegment][eRefList]);
    2690       rpcTempCU->setMVPIdx(eRefList, uiPartAddr, pDBBPTmpData->aiMvpIdx[uiSegment][eRefList]);
    2691      
    2692       rpcTempCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], eVirtualPartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level
    2693     }
    2694   }
    2695  
    2696   // reconstruct final prediction signal by combining both segments
    2697   Int bitDepthY = rpcTempCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
    2698   m_pcPredSearch->combineSegmentsWithMask(apPredYuv, m_ppcPredYuvTemp[uhDepth], pMask, uiWidth, uiHeight, 0, eVirtualPartSize, bitDepthY);
    2699   m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false DEBUG_STRING_PASS_INTO(sTest) );
    2700  
    2701   xCheckDQP( rpcTempCU );
    2702   xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth  DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest) );
    2703 }
    2704 #endif
    2705 #if NH_3D_DIS
    2706 Void TEncCu::xCheckRDCostDIS( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize DEBUG_STRING_FN_DECLARE(sDebug) )
    2707 {
    2708   DEBUG_STRING_NEW(sTest)
    2709   UInt uiDepth = rpcTempCU->getDepth( 0 );
    2710   if( !rpcBestCU->getSlice()->getIsDepth() || (eSize != SIZE_2Nx2N))
    2711   {
    2712     return;
    2713   }
    2714 
    2715 #if NH_MV
    2716   D_PRINT_INC_INDENT(g_traceModeCheck, "xCheckRDCostDIS" );
    2717 #endif
    2718 
    2719 #if NH_3D_VSO // M5
    2720   if( m_pcRdCost->getUseRenModel() )
    2721   {
    2722     UInt  uiWidth     = m_ppcOrigYuv[uiDepth]->getWidth   ( COMPONENT_Y );
    2723     UInt  uiHeight    = m_ppcOrigYuv[uiDepth]->getHeight  ( COMPONENT_Y );
    2724     Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getAddr    ( COMPONENT_Y );
    2725     UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride  ( COMPONENT_Y );
    2726     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2727   }
    2728 #endif
    2729 
    2730   rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth );
    2731   rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
    2732   rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth );
    2733   rpcTempCU->setCUTransquantBypassSubParts( rpcTempCU->getCUTransquantBypass(0), 0, uiDepth );
    2734 
    2735   rpcTempCU->setTrIdxSubParts(0, 0, uiDepth);
    2736   rpcTempCU->setCbfSubParts(0, COMPONENT_Y, 0, uiDepth);
    2737   rpcTempCU->setDISFlagSubParts(true, 0, uiDepth);
    2738   rpcTempCU->setIntraDirSubParts(CHANNEL_TYPE_LUMA, DC_IDX, 0, uiDepth);
    2739 #if NH_3D_SDC_INTRA
    2740   rpcTempCU->setSDCFlagSubParts( false, 0, uiDepth);
    2741 #endif
    2742 
    2743   UInt uiPreCalcDistC;
    2744   m_pcPredSearch  ->estIntraPredDIS      ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, false );
    2745 
    2746 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC
    2747   Int oldTraceCopyBack = g_traceCopyBack;
    2748   g_traceCopyBack = false; 
    2749 #endif
    2750   m_ppcRecoYuvTemp[uiDepth]->copyToPicComponent(COMPONENT_Y, rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getCtuRsAddr(), rpcTempCU->getZorderIdxInCtu() );
    2751 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC 
    2752   g_traceCopyBack = oldTraceCopyBack;
    2753 #endif
    2754 
    2755   m_pcEntropyCoder->resetBits();
    2756   if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
    2757   {
    2758     m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0,          true );
    2759   }
    2760   m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0,          true );
    2761   m_pcEntropyCoder->encodeDIS( rpcTempCU, 0,          true );
    2762 
    2763   m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
    2764 
    2765   rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
    2766   rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    2767 
    2768 #if NH_3D_VSO // M6
    2769   if( m_pcRdCost->getUseLambdaScaleVSO())
    2770   {
    2771     rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 
    2772   }
    2773   else
    2774 #endif
    2775   rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    2776 
    2777   xCheckDQP( rpcTempCU );
    2778   xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth  DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest) );
    2779 #if NH_MV
    2780   D_DEC_INDENT( g_traceModeCheck ); 
    2781 #endif
    2782 }
    2783 #endif
     1449
    27841450Void TEncCu::xCheckRDCostIntra( TComDataCU *&rpcBestCU,
    27851451                                TComDataCU *&rpcTempCU,
     
    27871453                                PartSize     eSize
    27881454                                DEBUG_STRING_FN_DECLARE(sDebug)
    2789 #if NH_3D_ENC_DEPTH
    2790                               , Bool bOnlyIVP
    2791 #endif
    27921455                              )
    27931456{
     
    28081471
    28091472  UInt uiDepth = rpcTempCU->getDepth( 0 );
    2810 #if NH_3D_VSO // M5
    2811   if( m_pcRdCost->getUseRenModel() )
    2812   {
    2813     UInt  uiWidth     = m_ppcOrigYuv[uiDepth]->getWidth   ( COMPONENT_Y );
    2814     UInt  uiHeight    = m_ppcOrigYuv[uiDepth]->getHeight  ( COMPONENT_Y );
    2815     Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getAddr    ( COMPONENT_Y );
    2816     UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride  ( COMPONENT_Y );
    2817     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2818   }
    2819 #endif
    28201473
    28211474  rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth );
    2822 #if NH_3D_DIS
    2823   rpcTempCU->setDISFlagSubParts( false, 0, uiDepth );
    2824 #endif
    28251475
    28261476
     
    28321482
    28331483  m_pcPredSearch->estIntraPredLumaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], resiLuma DEBUG_STRING_PASS_INTO(sTest)
    2834 #if NH_3D_ENC_DEPTH
    2835                                     , bOnlyIVP
    2836 #endif
    28371484                                    );
    28381485
     
    28441491  }
    28451492 
    2846 #if NH_3D_SDC_INTRA
    2847   if( rpcTempCU->getSDCFlag( 0 ) )
    2848   {
    2849     assert( rpcTempCU->getTransformIdx(0) == 0 );
    2850     assert( rpcTempCU->getCbf(0, COMPONENT_Y) == 1 );
    2851   }
    2852 #endif
    28531493
    28541494  m_pcEntropyCoder->resetBits();
     
    28591499  }
    28601500  m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0,          true );
    2861 #if NH_3D_DIS
    2862   m_pcEntropyCoder->encodeDIS( rpcTempCU, 0,          true );
    2863   if(!rpcTempCU->getDISFlag(0))
    2864   {
    2865 #endif
    28661501    m_pcEntropyCoder->encodePredMode( rpcTempCU, 0,          true );
    28671502    m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true );
    28681503    m_pcEntropyCoder->encodePredInfo( rpcTempCU, 0 );
    28691504    m_pcEntropyCoder->encodeIPCMInfo(rpcTempCU, 0, true );
    2870 #if NH_3D_SDC_INTRA
    2871     m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true );
    2872 #endif
    28731505
    28741506    // Encode Coefficients
     
    28781510    setCodeChromaQpAdjFlag( codeChromaQpAdjFlag );
    28791511    setdQPFlag( bCodeDQP );
    2880 #if NH_3D_DIS
    2881   }
    2882 #endif
    28831512  m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
    28841513
    28851514  rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
    28861515  rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    2887 #if NH_3D_VSO // M6
    2888   if( m_pcRdCost->getUseLambdaScaleVSO()) 
    2889   {
    2890     rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 
    2891   }
    2892   else
    2893 #endif
    28941516    rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    28951517
     
    29271549  UInt uiDepth = rpcTempCU->getDepth( 0 );
    29281550
    2929 #if NH_3D_VSO // VERY NEW
    2930   if( m_pcRdCost->getUseRenModel() )
    2931   {
    2932     UInt  uiWidth     = m_ppcOrigYuv[uiDepth]->getWidth   ( COMPONENT_Y );
    2933     UInt  uiHeight    = m_ppcOrigYuv[uiDepth]->getHeight  ( COMPONENT_Y );
    2934     Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getAddr    ( COMPONENT_Y );
    2935     UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride  ( COMPONENT_Y );
    2936     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2937   }
    2938 #endif
    29391551  rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth );
    2940 #if NH_3D_DIS
    2941   rpcTempCU->setDISFlagSubParts( false, 0, uiDepth );
    2942 #endif
    29431552  rpcTempCU->setIPCMFlag(0, true);
    29441553  rpcTempCU->setIPCMFlagSubParts (true, 0, rpcTempCU->getDepth(0));
     
    29601569
    29611570  m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0,          true );
    2962 #if NH_3D_DIS
    2963   m_pcEntropyCoder->encodeDIS( rpcTempCU, 0,          true );
    2964 #endif
    29651571  m_pcEntropyCoder->encodePredMode ( rpcTempCU, 0,          true );
    29661572  m_pcEntropyCoder->encodePartSize ( rpcTempCU, 0, uiDepth, true );
    29671573  m_pcEntropyCoder->encodeIPCMInfo ( rpcTempCU, 0, true );
    2968 #if NH_3D_SDC_INTRA
    2969   m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true );
    2970 #endif
    29711574  m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
    29721575
    29731576  rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
    29741577  rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    2975 #if NH_3D_VSO // M44
    2976   if ( m_pcRdCost->getUseVSO() )
    2977   {
    2978     rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    2979   }
    2980   else
    2981 #endif
    29821578    rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    29831579
     
    30461642      pcCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits
    30471643      pcCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    3048 #if NH_3D_VSO // M45
    3049       if ( m_pcRdCost->getUseVSO() )     
    3050       {
    3051         pcCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( pcCU->getTotalBits(), pcCU->getTotalDistortion() );     
    3052       }
    3053       else
    3054 #endif
    30551644        pcCU->getTotalCost() = m_pcRdCost->calcRdCost( pcCU->getTotalBits(), pcCU->getTotalDistortion() );
    30561645    }
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncCu.h

    r1321 r1390  
    6969  TComDataCU**            m_ppcBestCU;      ///< Best CUs in each depth
    7070  TComDataCU**            m_ppcTempCU;      ///< Temporary CUs in each depth
    71 #if NH_3D_ARP
    72   TComDataCU**            m_ppcWeightedTempCU;
    73 #endif
    7471  UChar                   m_uhTotalDepth;
    7572
     
    8279  TComYuv**               m_ppcOrigYuv;     ///< Original Yuv for each depth
    8380
    84 #if NH_3D_DBBP
    85   TComYuv**               m_ppcOrigYuvDBBP;
    86 #endif
    8781 
    8882  //  Data : encoder control
     
    106100  TEncRateCtrl*           m_pcRateCtrl;
    107101
    108 #if KWU_RC_MADPRED_E0227
    109   UInt                    m_LCUPredictionSAD;
    110   Int                     m_addSADDepth;
    111   Int                     m_temporalSAD;
    112   Int                     m_spatialSAD;
    113 #endif
    114102public:
    115103  /// copy parameters from encoder class
     
    129117
    130118  Int   updateCtuDataISlice ( TComDataCU* pCtu, Int width, Int height );
    131 #if KWU_RC_MADPRED_E0227
    132   UInt getLCUPredictionSAD() { return m_LCUPredictionSAD; }
    133 #endif
    134119
    135120  Void setFastDeltaQp       ( Bool b)                 { m_bFastDeltaQP = b;         }
     
    150135
    151136#if AMP_MRG
    152 #if  NH_3D_FAST_TEXTURE_ENCODING
    153   Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug),  Bool bFMD, Bool bUseMRG = false  ) ;
    154 #else
    155137  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug), Bool bUseMRG = false  );
    156 #endif
    157138#else
    158139  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
    159 #endif
    160 #if NH_3D_DBBP
    161   Void  xInvalidateOriginalSegments( TComYuv* pOrigYuv, TComYuv* pOrigYuvTemp, Bool* pMask, UInt uiValidSegment );
    162   Void  xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU  DEBUG_STRING_FN_DECLARE(sDebug),  Bool bUseMRG = false );
    163 #endif
    164 #if NH_3D_DIS
    165   Void  xCheckRDCostDIS   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug) );
    166140#endif
    167141  Void  xCheckRDCostIntra   ( TComDataCU *&rpcBestCU,
     
    170144                              PartSize     ePartSize
    171145                              DEBUG_STRING_FN_DECLARE(sDebug)
    172 #if NH_3D_ENC_DEPTH
    173                             , Bool bOnlyIVP
    174 #endif
    175146                            );
    176147  Void  xCheckDQP           ( TComDataCU*  pcCU );
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncEntropy.cpp

    r1386 r1390  
    116116  m_pcEntropyCoderIf->codeSkipFlag( pcCU, uiAbsPartIdx );
    117117}
    118 #if NH_3D_DIS
    119 Void TEncEntropy::encodeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    120 {
    121   if( !pcCU->getSlice()->getDepthIntraSkipFlag() )
    122   {
    123     return;
    124   }
    125   if( bRD )
    126   {
    127     uiAbsPartIdx = 0;
    128   }
    129   m_pcEntropyCoderIf->codeDIS( pcCU, uiAbsPartIdx );
    130 }
    131 #endif
    132118//! encode merge flag
    133119Void TEncEntropy::encodeMergeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
     
    148134}
    149135
    150 #if NH_3D_IC
    151 Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    152 {
    153 #if NH_3D_ARP
    154   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
    155 #else
    156   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() )
    157 #endif
    158   {
    159     return;
    160   }
    161 
    162   if( !pcCU->getSlice()->getApplyIC() )
    163   {
    164     return;
    165   }
    166 
    167   if( bRD )
    168   {
    169     uiAbsPartIdx = 0;
    170   }
    171   else
    172   {
    173     Int ICEnableCandidate = pcCU->getSlice()->getICEnableCandidate(pcCU->getSlice()->getDepth());
    174     Int ICEnableNum = pcCU->getSlice()->getICEnableNum(pcCU->getSlice()->getDepth());
    175     ICEnableCandidate++;
    176     if(pcCU->getICFlag(uiAbsPartIdx))
    177     {
    178       ICEnableNum++;
    179     }
    180     pcCU->getSlice()->setICEnableCandidate(pcCU->getSlice()->getDepth(), ICEnableCandidate);
    181     pcCU->getSlice()->setICEnableNum(pcCU->getSlice()->getDepth(), ICEnableNum);
    182   }
    183   if( pcCU->isICFlagRequired( uiAbsPartIdx ) )
    184   {
    185     m_pcEntropyCoderIf->codeICFlag( pcCU, uiAbsPartIdx );
    186   }
    187 }
    188 #endif
    189 
    190 #if NH_3D_ARP
    191 Void TEncEntropy::encodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
    192 {
    193   if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) )
    194   {
    195     return;
    196   }
    197 
    198   if ( pcCU->getPartitionSize(uiAbsPartIdx)!=SIZE_2Nx2N )
    199   {
    200     assert(pcCU->getARPW (uiAbsPartIdx) == 0);
    201   }
    202   else
    203   {
    204     m_pcEntropyCoderIf->codeARPW( pcCU, uiAbsPartIdx );
    205   }
    206 }
    207 #endif
     136
    208137
    209138
     
    715644#endif
    716645
    717 #if NH_3D_SDC_INTRA
    718   if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx ) )
    719   {
    720     assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
    721     assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 );
    722     assert( pcCU->getCbf(uiAbsPartIdx, COMPONENT_Y) == 1 );
    723   }
    724 #endif
    725 #if NH_3D_SDC_INTER
    726   if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx ) )
    727   {
    728     assert( !pcCU->isSkipped( uiAbsPartIdx ) );
    729     assert( !pcCU->isIntra( uiAbsPartIdx) );
    730     assert( pcCU->getSlice()->getIsDepth() );
    731   }
    732 #endif
    733 #if NH_3D
    734   if( pcCU->getSlice()->getIsDepth() )
    735   {
    736 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    737     if( pcCU->getSDCFlag( uiAbsPartIdx ) )
    738     {
    739       m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx );
    740       return;
    741     }
    742 #endif
    743 #if NH_3D_DMM
    744     if( pcCU->isIntra(uiAbsPartIdx) )
    745   {
    746     Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
    747       UInt uiPartOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
    748       for( Int iPart = 0; iPart < iPartNum; iPart++ )
    749       {
    750         if( isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx + uiPartOffset*iPart ) ) )
    751         {
    752           m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart );
    753         }
    754       }
    755     }
    756 #endif
    757   }
    758 #endif
    759646
    760647  if( pcCU->isIntra(uiAbsPartIdx) )
     
    851738}
    852739
    853 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    854 Void TEncEntropy::encodeDeltaDC  ( TComDataCU* pcCU, UInt absPartIdx )
    855 {
    856   m_pcEntropyCoderIf->codeDeltaDC( pcCU, absPartIdx );
    857 }
    858 #endif
    859 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    860 Void TEncEntropy::encodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    861 {
    862   if( bRD )
    863   {
    864     uiAbsPartIdx = 0;
    865   }
    866  
    867   if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getInterSdcFlag() ) ||
    868     ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getIntraSdcWedgeFlag() ) )
    869   {
    870     return;
    871   }
    872 
    873   if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) )
    874   {
    875     return;
    876   }
    877 
    878   assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N );
    879 
    880   m_pcEntropyCoderIf->codeSDCFlag( pcCU, uiAbsPartIdx );
    881 }
    882 
    883 #endif
    884 #if NH_3D_DBBP
    885 Void TEncEntropy::encodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    886 {
    887   if( bRD )
    888   {
    889     uiAbsPartIdx = 0;
    890   }
    891  
    892   if( pcCU->getSlice()->getDepthBasedBlkPartFlag() &&
    893     ( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN ||
    894       pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) &&
    895       pcCU->getWidth(uiAbsPartIdx) > 8 &&
    896       pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
    897   {
    898     m_pcEntropyCoderIf->codeDBBPFlag( pcCU, uiAbsPartIdx );
    899   }
    900 }
    901 #endif
    902740
    903741//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncEntropy.h

    r1386 r1390  
    7979  virtual Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    8080  virtual Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    81 #if NH_3D_DIS
    82   virtual Void codeDIS          ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    83 #endif
    8481  virtual Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    8582  virtual Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    86 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    87   virtual Void codeDeltaDC       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    88 #endif
    89 #if NH_3D_ARP 
    90   virtual Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    91 #endif
    92 #if NH_3D_IC
    93   virtual Void codeICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    94 #endif
    95 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    96   virtual Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    97 #endif
    98 #if NH_3D_DBBP
    99   virtual Void codeDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    100 #endif
    10183  virtual Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    10284
     
    163145  Void encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    164146  Void encodeSkipFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    165 #if NH_3D_DIS
    166   Void encodeDIS               ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD=false );
    167 #endif
    168147  Void encodePUWise       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    169148  Void encodeInterDirPU   ( TComDataCU* pcSubCU, UInt uiAbsPartIdx  );
     
    173152  Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    174153  Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    175 #if NH_3D_ARP
    176   Void encodeARPW         ( TComDataCU* pcCU, UInt uiAbspartIdx );
    177 #endif
    178 #if NH_3D_IC
    179   Void encodeICFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    180 #endif
    181 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    182   Void encodeDeltaDC      ( TComDataCU* pcCU, UInt absPartIdx );
    183 #endif
    184 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    185   Void encodeSDCFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    186 #endif
    187 #if NH_3D_DBBP
    188   Void encodeDBBPFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    189 #endif
    190154  Void encodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    191155  Void encodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncGOP.cpp

    r1386 r1390  
    101101  m_viewId       = 0;
    102102  m_pocLastCoded = -1;
    103 #if NH_3D
    104   m_viewIndex  =   0;
    105   m_isDepth = false;
    106 #endif
    107103#endif
    108104  m_associatedIRAPType = NAL_UNIT_CODED_SLICE_IDR_N_LP;
     
    150146  m_layerId              = pcTEncTop->getLayerId();
    151147  m_viewId               = pcTEncTop->getViewId();
    152 #if NH_3D
    153   m_viewIndex            = pcTEncTop->getViewIndex();
    154   m_isDepth              = pcTEncTop->getIsDepth();
    155 #endif
    156 #endif
    157 #if NH_3D_IC
    158   m_aICEnableCandidate   = pcTEncTop->getICEnableCandidate();
    159   m_aICEnableNum         = pcTEncTop->getICEnableNum();
    160 #endif
    161 #if KWU_FIX_URQ
    162   m_pcRateCtrl           = pcTEncTop->getRateCtrl();
    163148#endif
    164149}
     
    12381223    pcPic  ->setLayerId     ( getLayerId()   );
    12391224    pcPic  ->setViewId      ( getViewId()    );
    1240 #if !NH_3D
    12411225    pcSlice->setLayerId     ( getLayerId() );
    12421226    pcSlice->setViewId      ( getViewId()  );
    12431227    pcSlice->setVPS         ( m_pcEncTop->getVPS() );
    1244 #else
    1245     pcPic  ->setViewIndex   ( getViewIndex() );
    1246     pcPic  ->setIsDepth( getIsDepth() );
    1247     pcSlice->setCamparaSlice( pcPic->getCodedScale(), pcPic->getCodedOffset() );
    1248 #endif
    12491228#endif
    12501229    //set default slice level flag to the same as SPS level flag
     
    14171396
    14181397    const TComVPS*           vps = pcSlice->getVPS();
    1419 #if NH_3D
    1420     Int numDirectRefLayers = vps    ->getNumRefListLayers( getLayerId() );
    1421 #else
    14221398    Int numDirectRefLayers = vps    ->getNumDirectRefLayers( getLayerId() );
    1423 #endif
    1424 #if NH_3D_QTL
    1425     pcSlice->setIvPicLists( m_ivPicLists );
    1426 #endif
    1427 #if NH_3D
    1428 
    1429 
    1430     Int gopNum = (pcSlice->getRapPicFlag() && getLayerId() > 0) ? MAX_GOP : iGOPid;
    1431     GOPEntry gopEntry      = m_pcCfg->getGOPEntry( gopNum );
    1432 #else
    14331399    GOPEntry gopEntry      = m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && getLayerId() > 0) ? MAX_GOP : iGOPid );
    1434 #endif
    14351400
    14361401
     
    14461411          pcSlice->setNumInterLayerRefPicsMinus1( gopEntry.m_numActiveRefLayerPics - 1 );
    14471412        }
    1448 #if NH_3D
    1449         if ( gopEntry.m_numActiveRefLayerPics != vps->getNumRefListLayers( getLayerId() ) )
    1450 #else
    14511413        if ( gopEntry.m_numActiveRefLayerPics != vps->getNumDirectRefLayers( getLayerId() ) )
    1452 #endif
    14531414        {
    14541415          interLayerPredLayerIdcPresentFlag = true;
     
    14711432    assert( pcSlice->getNumActiveRefLayerPics() == gopEntry.m_numActiveRefLayerPics );
    14721433
    1473 #if NH_3D
    1474     if ( m_pcEncTop->decProcAnnexI() )
    1475     {
    1476       pcSlice->deriveInCmpPredAndCpAvailFlag( );
    1477       if ( pcSlice->getInCmpPredAvailFlag() )
    1478       {
    1479         pcSlice->setInCompPredFlag( gopEntry.m_interCompPredFlag );
    1480       }
    1481       else
    1482       {
    1483         if (gopEntry.m_interCompPredFlag )
    1484         {
    1485           if ( gopNum == MAX_GOP)
    1486           {
    1487             printf( "\nError: FrameI_l%d cannot enable inter-component prediction on slice level. All reference layers need to be available and at least one tool using inter-component prediction must be enabled in the SPS. \n", pcSlice->getVPS()->getLayerIdInVps( getLayerId() ) );
    1488           }
    1489           else
    1490           {
    1491             printf( "\nError: Frame%d_l%d cannot enable inter-component prediction on slice level. All reference layers need to be available and at least one tool using inter-component prediction must be enabled in the SPS. \n", gopNum, pcSlice->getVPS()->getLayerIdInVps( getLayerId() ) );
    1492           }
    1493 
    1494           exit(EXIT_FAILURE);
    1495         }
    1496       }
    1497       pcSlice->init3dToolParameters();
    1498       pcSlice->checkInCompPredRefLayers();
    1499     }
    1500 #if NH_3D_IV_MERGE
    1501     // This needs to be done after initialization of 3D tool parameters.
    1502     pcSlice->setMaxNumMergeCand      ( m_pcCfg->getMaxNumMergeCand()   + ( ( pcSlice->getMpiFlag( ) || pcSlice->getIvMvPredFlag( ) || pcSlice->getViewSynthesisPredFlag( )   ) ? 1 : 0 ));
    1503 #endif
    1504 #endif
    15051434
    15061435    pcSlice->createInterLayerReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer0, m_refPicSetInterLayer1 );
     
    15261455    pcSlice->setRefPicList ( rcListPic );
    15271456#endif
    1528 #if NH_3D_NBDV
    1529     pcSlice->setDefaultRefView();
    1530 #endif
    1531 #if NH_3D_ARP
    1532     //GT: This seems to be broken when layerId in vps is not equal to layerId in nuh
    1533     pcSlice->setARPStepNum(m_ivPicLists);
    1534 #endif
    1535 #if NH_3D_IC
    1536     pcSlice->setICEnableCandidate( m_aICEnableCandidate );
    1537     pcSlice->setICEnableNum( m_aICEnableNum );
    1538 #endif
    15391457
    15401458    //  Slice info. refinement
     
    15901508
    15911509    pcSlice->setList1IdxToList0Idx();
    1592 #if NH_3D_TMVP
    1593     if(pcSlice->getLayerId())
    1594       pcSlice->generateAlterRefforTMVP();
    1595 #endif
    15961510
    15971511    if (m_pcEncTop->getTMVPModeId() == 2)
     
    16221536#endif
    16231537
    1624 #if NH_3D_VSO
    1625   // Should be moved to TEncTop !!!
    1626   Bool bUseVSO = m_pcEncTop->getUseVSO();
    1627 
    1628   TComRdCost* pcRdCost = m_pcEncTop->getRdCost();
    1629 
    1630   pcRdCost->setUseVSO( bUseVSO );
    1631 
    1632   // SAIT_VSO_EST_A0033
    1633   pcRdCost->setUseEstimatedVSD( m_pcEncTop->getUseEstimatedVSD() );
    1634 
    1635   if ( bUseVSO )
    1636   {
    1637     Int iVSOMode = m_pcEncTop->getVSOMode();
    1638     pcRdCost->setVSOMode( iVSOMode  );
    1639     pcRdCost->setAllowNegDist( m_pcEncTop->getAllowNegDist() );
    1640 
    1641     // SAIT_VSO_EST_A0033
    1642 #if H_3D_FCO
    1643     Bool flagRec;
    1644     flagRec =  ((m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), false, pcSlice->getPOC(), true) == NULL) ? false: true);
    1645     pcRdCost->setVideoRecPicYuv( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), false, pcSlice->getPOC(), flagRec ) );
    1646     pcRdCost->setDepthPicYuv   ( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), true, pcSlice->getPOC(), false ) );
    1647 #else   
    1648     Int curAuxId     = pcSlice->getVPS()->getAuxId( getLayerId() );
    1649     Int curDepthFlag = pcSlice->getIsDepth();
    1650     assert( curAuxId == 2 || curDepthFlag  );
    1651     pcRdCost->setVideoRecPicYuv( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), false       , 0       , pcSlice->getPOC(), true ) );
    1652     pcRdCost->setDepthPicYuv   ( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), curDepthFlag, curAuxId, pcSlice->getPOC(), false ) );
    1653 #endif
    1654     // LGE_WVSO_A0119
    1655     Bool bUseWVSO  = m_pcEncTop->getUseWVSO();
    1656     pcRdCost->setUseWVSO( bUseWVSO );
    1657 
    1658   }
    1659 #endif
    16601538    // set adaptive search range for non-intra-slices
    16611539    if (m_pcCfg->getUseASR() && pcSlice->getSliceType()!=I_SLICE)
     
    17071585      estimatedBits = m_pcRateCtrl->getRCPic()->getTargetBits();
    17081586
    1709 #if KWU_RC_MADPRED_E0227
    1710       if(m_pcCfg->getLayerId() != 0)
    1711       {
    1712         m_pcRateCtrl->getRCPic()->setIVPic( m_pcEncTop->getEncTop()->getTEncTop(0)->getRateCtrl()->getRCPic() );
    1713       }
    1714 #endif
    17151587
    17161588#if U0132_TARGET_BITS_SATURATION
     
    17901662      else    // normal case
    17911663      {
    1792 #if KWU_RC_MADPRED_E0227
    1793         if(m_pcRateCtrl->getLayerID() != 0)
    1794         {
    1795           list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
    1796           lambda  = m_pcRateCtrl->getRCPic()->estimatePicLambdaIV( listPreviousPicture, pcSlice->getPOC() );
    1797           sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
    1798         }
    1799         else
    1800         {
    1801 #endif
    18021664        list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
    18031665        lambda  = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->getSliceType());
    18041666        sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
    1805 #if KWU_RC_MADPRED_E0227
    1806         }
    1807 #endif
    18081667      }
    18091668
     
    18161675    UInt uiNumSliceSegments = 1;
    18171676
    1818 #if NH_3D_NBDV
    1819       if(pcSlice->getViewIndex() && !pcSlice->getIsDepth()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
    1820       {
    1821         Int iColPoc = pcSlice->getRefPOC(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
    1822         pcPic->setNumDdvCandPics(pcPic->getDisCandRefPictures(iColPoc));
    1823       }
    1824 #endif
    1825 #if NH_3D
    1826       pcSlice->setDepthToDisparityLUTs();
    1827 
    1828 #endif
    1829 
    1830 #if NH_3D_NBDV
    1831       if(pcSlice->getViewIndex() && !pcSlice->getIsDepth() && !pcSlice->isIntra()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
    1832       {
    1833         pcPic->checkTemporalIVRef();
    1834       }
    1835 
    1836       if(pcSlice->getIsDepth())
    1837       {
    1838         pcPic->checkTextureRef();
    1839       }
    1840 #endif
     1677
    18411678    // Allocate some coders, now the number of tiles are known.
    18421679    const Int numSubstreamsColumns = (pcSlice->getPPS()->getNumTileColumnsMinus1() + 1);
     
    19131750      // write various parameter sets
    19141751      actualTotalBits += xWriteParameterSets(accessUnit, pcSlice);
    1915 #if H_3D_PPS_FIX_DEPTH
    1916       if(!pcSlice->getIsDepth() || !pcSlice->getViewIndex() )
    1917       {
    1918 #endif
    1919 #if H_3D_PPS_FIX_DEPTH
    1920       }
    1921 #endif
    19221752
    19231753
     
    20861916    // cabac_zero_words processing
    20871917    cabac_zero_word_padding(pcSlice, pcPic, binCountsInNalUnits, numBytesInVclNalUnits, accessUnit.back()->m_nalUnitData, m_pcCfg->getCabacZeroWordPaddingEnabled());
    2088 #if NH_3D
    2089       pcPic->compressMotion(2);
    2090 #else
    20911918    pcPic->compressMotion();
    2092 #endif
    20931919#if NH_MV
    20941920      m_pocLastCoded = pcPic->getPOC();
     
    22402066}
    22412067
    2242 #if NH_3D_VSO
    2243 Void TEncGOP::preLoopFilterPicAll( TComPic* pcPic, Dist64& ruiDist )
    2244 #else
    22452068Void TEncGOP::preLoopFilterPicAll( TComPic* pcPic, UInt64& ruiDist )
    2246 #endif
    22472069{
    22482070  Bool bCalcDist = false;
     
    23252147}
    23262148
    2327 #if NH_3D_VSO
    2328 Dist64 TEncGOP::xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1, const BitDepths &bitDepths)
    2329 #else
    23302149UInt64 TEncGOP::xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1, const BitDepths &bitDepths)
    2331 #endif
    2332 {
    2333 #if NH_3D_VSO
    2334   Dist64  uiTotalDiff = 0;
    2335 #else
     2150{
    23362151  UInt64  uiTotalDiff = 0;
    2337 #endif
    23382152
    23392153  for(Int chan=0; chan<pcPic0 ->getNumberValidComponents(); chan++)
     
    24752289      pRec += iRecStride;
    24762290    }
    2477 #if NH_3D_VSO
    2478 #if H_3D_VSO_SYNTH_DIST_OUT
    2479   if ( m_pcRdCost->getUseRenModel() )
    2480   {
    2481     unsigned int maxval = 255 * (1<<(g_uiBitDepth + g_uiBitIncrement -8));
    2482     Double fRefValueY = (double) maxval * maxval * iSize;
    2483     Double fRefValueC = fRefValueY / 4.0;
    2484     TRenModel*  pcRenModel = m_pcEncTop->getEncTop()->getRenModel();
    2485     Int64 iDistVSOY, iDistVSOU, iDistVSOV;
    2486     pcRenModel->getTotalSSE( iDistVSOY, iDistVSOU, iDistVSOV );
    2487     dYPSNR = ( iDistVSOY ? 10.0 * log10( fRefValueY / (Double) iDistVSOY ) : 99.99 );
    2488     dUPSNR = ( iDistVSOU ? 10.0 * log10( fRefValueC / (Double) iDistVSOU ) : 99.99 );
    2489     dVPSNR = ( iDistVSOV ? 10.0 * log10( fRefValueC / (Double) iDistVSOV ) : 99.99 );
    2490   }
    2491   else
    2492   {
    2493 #endif
    2494 #endif
    24952291    const Int maxval = 255 << (pcPic->getPicSym()->getSPS().getBitDepth(toChannelType(ch)) - 8);
    24962292    const Double fRefValue = (Double) maxval * maxval * iSize;
     
    24992295  }
    25002296
    2501 #if NH_3D_VSO
    2502 #if H_3D_VSO_SYNTH_DIST_OUT
    2503 }
    2504 #endif
    2505 #endif
    25062297  /* calculate the size of the access unit, excluding:
    25072298   *  - any AnnexB contributions (start_code_prefix, zero_byte, etc.,)
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncGOP.h

    r1386 r1390  
    5858#include "TEncAnalyze.h"
    5959#include "TEncRateCtrl.h"
    60 #if KWU_RC_MADPRED_E0227
    61 #include "../App/TAppEncoder/TAppEncTop.h"
    62 #endif
    6360#include <vector>
    6461
     
    127124  Int                     m_layerId; 
    128125  Int                     m_viewId;
    129 #if NH_3D
    130   Int                     m_viewIndex;
    131   Bool                    m_isDepth;
    132 #endif
    133 #endif
    134 #if NH_3D_IC
    135   Int*                    m_aICEnableCandidate;
    136   Int*                    m_aICEnableNum;
    137126#endif
    138127  //--Adaptive Loop filter
     
    176165  Int       getLayerId       ()                 { return m_layerId;    } 
    177166  Int       getViewId        ()                 { return m_viewId;    }
    178 #if NH_3D
    179   Int       getViewIndex     ()                 { return m_viewIndex;    }
    180   Bool      getIsDepth       ()                 { return m_isDepth; }
    181 #endif
    182167#endif
    183168
     
    186171  TComList<TComPic*>*   getListPic()      { return m_pcListPic; }
    187172  Void  printOutSummary      ( UInt uiNumAllPicCoded, Bool isField, const Bool printMSEBasedSNR, const Bool printSequenceMSE, const BitDepths &bitDepths );
    188 #if NH_3D_VSO
    189   Void  preLoopFilterPicAll  ( TComPic* pcPic, Dist64& ruiDist);
    190 #else
    191173  Void  preLoopFilterPicAll  ( TComPic* pcPic, UInt64& ruiDist );
    192 #endif
    193 
    194 #if KWU_RC_MADPRED_E0227
    195   TEncTop* getEncTop() { return m_pcEncTop; }
    196 #endif
     174
    197175
    198176  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
     
    213191                                     TComPicYuv* pcPicRecFirstField, TComPicYuv* pcPicRecSecondField,
    214192                                     const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
    215 #if NH_3D_VSO
    216   Dist64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1, const BitDepths &bitDepths);
    217 #else 
    218193  UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1, const BitDepths &bitDepths);
    219 #endif
    220194  Double xCalculateRVM();
    221195
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncRateCtrl.cpp

    r1386 r1390  
    482482
    483483  m_LCUs         = NULL;
    484 #if KWU_RC_MADPRED_E0227
    485   m_lastIVPicture = NULL;
    486 #endif
    487484
    488485  m_picActualHeaderBits = 0;
     
    491488  m_picLambda           = 0.0;
    492489
    493 #if KWU_RC_MADPRED_E0227
    494   m_IVtotalMAD            = 0.0;
    495 #endif
    496490}
    497491
     
    567561}
    568562
    569 #if KWU_RC_MADPRED_E0227
    570 Void TEncRCPic::addToPictureLsitIV( list<TEncRCPic*>& listPreviousPictures )
    571 {
    572   m_lastIVPicture = NULL;
    573   m_lastIVPicture = this;
    574 }
    575 
    576 Void TEncRCPic::setIVPic( TEncRCPic* BaseRCPic )
    577 {
    578   m_lastIVPicture = BaseRCPic;
    579 }
    580 #endif
    581 
    582 #if KWU_RC_MADPRED_E0227
    583 Void TEncRCPic::create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures, Int layerID )
    584 #else
     563
    585564Void TEncRCPic::create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures )
    586 #endif
    587565{
    588566  destroy();
     
    633611      m_LCUs[LCUIdx].m_numberOfPixel = currWidth * currHeight;
    634612
    635 #if KWU_RC_MADPRED_E0227
    636       m_LCUs[LCUIdx].m_CUWidth = currWidth;
    637       m_LCUs[LCUIdx].m_CUHeight = currHeight;
    638       m_LCUs[LCUIdx].m_IVMAD = -1.0;
    639 #endif
    640613    }
    641614  }
     
    646619
    647620
    648 #if KWU_RC_MADPRED_E0227
    649   m_LayerID = layerID;
    650   m_lastIVPicture = NULL;
    651   m_IVtotalMAD            = 0.0;
    652 #endif
    653 
    654 
    655 #if KWU_RC_MADPRED_E0227
    656   list<TEncRCPic*>::reverse_iterator it;
    657   if( m_LayerID != 0)
    658   {
    659     m_lastIVPicture = NULL;
    660     for ( it = listPreviousPictures.rbegin(); it != listPreviousPictures.rend(); it++ )
    661     {
    662       if ( (*it)->getLayerID() == 0 )
    663       {
    664         m_lastIVPicture = (*it);
    665         break;
    666       }
    667     }
    668   }
    669 
    670   m_lastPicture = NULL;
    671   for ( it = listPreviousPictures.rbegin(); it != listPreviousPictures.rend(); it++ )
    672   {
    673     if ( (*it)->getFrameLevel() == m_frameLevel )
    674     {
    675       m_lastPicture = (*it);
    676       break;
    677     }
    678   }
    679 #endif
     621
     622
    680623}
    681624
     
    825768
    826769
    827 #if KWU_RC_MADPRED_E0227
    828 Double TEncRCPic::estimatePicLambdaIV( list<TEncRCPic*>& listPreviousPictures, Int CurPOC )
    829 {
    830   Double alpha         = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha;
    831   Double beta          = m_encRCSeq->getPicPara( m_frameLevel ).m_beta;
    832   Double bpp       = (Double)m_targetBits/(Double)m_numberOfPixel;
    833   Double estLambda = alpha * pow( bpp, beta );
    834   Double lastLevelLambda = -1.0;
    835   Double lastPicLambda   = -1.0;
    836   Double lastValidLambda = -1.0;
    837   list<TEncRCPic*>::iterator it;
    838 
    839   if(listPreviousPictures.size() == 0 || CurPOC%8 == 0)
    840   {
    841     lastLevelLambda = m_lastIVPicture->getPicActualLambda();
    842     lastPicLambda     = m_lastIVPicture->getPicActualLambda();
    843   }
    844   else
    845   {
    846     for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ )
    847     {
    848       if ( (*it)->getFrameLevel() == m_frameLevel )
    849       {
    850         lastLevelLambda = (*it)->getPicActualLambda();
    851       }
    852       lastPicLambda     = (*it)->getPicActualLambda();
    853 
    854       if ( lastPicLambda > 0.0 )
    855       {
    856         lastValidLambda = lastPicLambda;
    857       }
    858     }
    859   }
    860 
    861   if ( lastLevelLambda > 0.0 )
    862   {
    863     lastLevelLambda = Clip3( 0.1, 10000.0, lastLevelLambda );
    864     estLambda = Clip3( lastLevelLambda * pow( 2.0, -3.0/3.0 ), lastLevelLambda * pow( 2.0, 3.0/3.0 ), estLambda );
    865   }
    866 
    867   if ( lastPicLambda > 0.0 )
    868   {
    869     lastPicLambda = Clip3( 0.1, 2000.0, lastPicLambda );
    870     estLambda = Clip3( lastPicLambda * pow( 2.0, -10.0/3.0 ), lastPicLambda * pow( 2.0, 10.0/3.0 ), estLambda );
    871   }
    872   else if ( lastValidLambda > 0.0 )
    873   {
    874     lastValidLambda = Clip3( 0.1, 2000.0, lastValidLambda );
    875     estLambda = Clip3( lastValidLambda * pow(2.0, -10.0/3.0), lastValidLambda * pow(2.0, 10.0/3.0), estLambda );
    876   }
    877   else
    878   {
    879     estLambda = Clip3( 0.1, 10000.0, estLambda );
    880   }
    881 
    882   if ( estLambda < 0.1 )
    883   {
    884     estLambda = 0.1;
    885   }
    886 
    887   m_estPicLambda = estLambda;
    888   return estLambda;
    889 }
    890 #endif
    891770
    892771
     
    937816
    938817
    939 #if KWU_RC_MADPRED_E0227
    940 Double TEncRCPic::getLCUTargetBppforInterView( list<TEncRCPic*>& listPreviousPictures, TComDataCU* pcCU, Double basePos, Double curPos, Double focalLen, Double znear, Double zfar, Int direction, Int* disparity )
    941 {
    942   Int   LCUIdx    = getLCUCoded();
    943   Double bpp      = -1.0;
    944   Int avgBits     = 0;
    945 #if !M0036_RC_IMPROVEMENT
    946   Double totalMAD = -1.0;
    947   Double MAD      = -1.0;
    948 #endif
    949 
    950   Double totalMAD = -1.0;
    951   Double MAD      = -1.0;
    952 
    953   Double IVMAD      = -1.0;
    954   Double SAD = 0.0;
    955   Int     x, y;
    956   Int Sum = 0;
    957 
    958   {
    959     Pel*  pOrg    = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
    960     Pel*  pRec    = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), 0);
    961     Pel*  pDep    = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
    962     Int   iStride = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getStride();
    963 
    964     Int   width  = m_LCUs[ LCUIdx ].m_CUWidth;
    965     Int   height = m_LCUs[ LCUIdx ].m_CUHeight;
    966 
    967     for( y = 0 ; y < pcCU->getSlice()->getSPS()->getMaxCUHeight() ; y+=8)
    968     {
    969       for( x = 0 ; x < pcCU->getSlice()->getSPS()->getMaxCUWidth() ; x+=8)
    970       {
    971         Sum += pDep[x];
    972       }
    973       pDep += iStride;
    974     }
    975 
    976     Double AvgDepth = (Double)Sum/((pcCU->getSlice()->getSPS()->getMaxCUHeight()/8)*(pcCU->getSlice()->getSPS()->getMaxCUWidth()/8));
    977 
    978     Double fL = focalLen * abs( basePos - curPos );
    979     Double z  = abs( 1.0 / znear - 1.0 / zfar ) * ((Double)(AvgDepth) / (( 1 << g_bitDepthY ) - 1) ) + abs(1.0 / zfar);
    980     *disparity = (Int)(direction*fL * z);
    981     Int shift = DISTORTION_PRECISION_ADJUSTMENT(g_bitDepthY-8);
    982 
    983     Int disp = *disparity;
    984     Int posX, posY;
    985     pcCU->getPosInPic(0, posX, posY);
    986     if((posX + *disparity) < 0 || (posX + *disparity + width) >= pcCU->getSlice()->getSPS()->getMaxCUWidth())
    987     {
    988       disp = 0;
    989     }
    990 
    991     for( y = 0; y < height; y++ )
    992     {
    993       for( x = 0; x < width; x++ )
    994       {
    995         SAD += abs( pOrg[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)]
    996                   - pRec[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)] )>>shift;
    997       }
    998       pOrg += iStride;
    999       pRec += iStride;
    1000     }
    1001     IVMAD = SAD / (Double)(height * width);
    1002     IVMAD = IVMAD * IVMAD;
    1003 
    1004     m_LCUs[ LCUIdx ].m_IVMAD = IVMAD;
    1005     if(m_lastPicture)
    1006     {
    1007       m_LCUs[ LCUIdx ].m_MAD = m_lastPicture->getLCU(LCUIdx).m_MAD;
    1008     }
    1009 
    1010     MAD = m_LCUs[ LCUIdx ].m_IVMAD;
    1011 
    1012     if(m_lastPicture)
    1013     {
    1014       totalMAD = m_lastPicture->getTotalMAD();      // get total MAD of temporal frame
    1015       for ( Int i=0; i<LCUIdx; i++ )
    1016       {
    1017         totalMAD -= m_lastPicture->getLCU(i).m_MAD;
    1018       }
    1019     }
    1020     else
    1021     {
    1022       totalMAD = m_lastIVPicture->getTotalMAD();      // get total MAD of inter-view frame
    1023       for ( Int i=0; i<LCUIdx; i++ )
    1024       {
    1025         totalMAD -= m_lastIVPicture->getLCU(i).m_MAD;
    1026       }
    1027     }
    1028 
    1029 
    1030     if ( totalMAD > 0.1 )
    1031     {
    1032       avgBits = Int( (m_bitsLeft * MAD) / totalMAD );
    1033     }
    1034     else
    1035     {
    1036       avgBits = Int( (m_bitsLeft) / m_LCULeft );
    1037     }
    1038   }
    1039 
    1040   if ( avgBits < 5 )
    1041   {
    1042     avgBits = 5;
    1043   }
    1044 
    1045   bpp = ( Double )avgBits/( Double )m_LCUs[ LCUIdx ].m_numberOfPixel;
    1046   m_LCUs[ LCUIdx ].m_targetBits = avgBits;
    1047 
    1048   return bpp;
    1049 }
    1050 #endif
    1051818
    1052819
     
    12611028  }
    12621029  m_picLambda           = averageLambda;
    1263 #if KWU_RC_MADPRED_E0227
    1264   m_totalMAD = 0;
    1265   for ( Int i=0; i<m_numberOfLCU; i++ )
    1266   {
    1267     m_totalMAD += m_LCUs[i].m_MAD;
    1268   }
    1269 #endif
    12701030
    12711031  Double alpha = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha;
     
    14461206}
    14471207
    1448 #if KWU_RC_MADPRED_E0227
    1449 Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Bool keepHierBits, Bool useLCUSeparateModel, GOPEntry  GOPList[MAX_GOP], Int layerID )
    1450 #else
    14511208Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry  GOPList[MAX_GOP] )
    1452 #endif
    14531209{
    14541210  destroy();
     
    16461402#endif
    16471403
    1648 #if KWU_RC_MADPRED_E0227
    1649   setLayerID(layerID);
    1650 #endif
    16511404
    16521405  delete[] bitsRatio;
     
    16571410{
    16581411  m_encRCPic = new TEncRCPic;
    1659 #if KWU_RC_MADPRED_E0227
    1660   m_encRCPic->create( m_encRCSeq, m_encRCGOP, frameLevel, m_listRCPictures, m_LayerID );
    1661 #else
    16621412  m_encRCPic->create( m_encRCSeq, m_encRCGOP, frameLevel, m_listRCPictures );
    1663 #endif
    16641413}
    16651414
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncRateCtrl.h

    r1386 r1390  
    8787  Double m_costIntra;
    8888  Int m_targetBitsLeft;
    89 #if KWU_RC_MADPRED_E0227
    90   Double m_MAD;
    91   Int m_CUWidth;
    92   Int m_CUHeight;
    93   Double m_IVMAD;
    94 #endif
    9589};
    9690
     
    228222
    229223public:
    230 #if KWU_RC_MADPRED_E0227
    231   Void create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures, Int layerID );
    232 #else
    233224  Void create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures );
    234 #endif
    235225  Void destroy();
    236226
    237 #if KWU_RC_MADPRED_E0227
    238   Double estimatePicLambdaIV( list<TEncRCPic*>& listPreviousPictures, Int curPOC );
    239 #endif
    240227  Int    estimatePicQP    ( Double lambda, list<TEncRCPic*>& listPreviousPictures );
    241228  Int    getRefineBitsForIntra(Int orgBits);
     
    247234  Double getLCUTargetBpp(SliceType eSliceType);
    248235  Double getLCUEstLambdaAndQP(Double bpp, Int clipPicQP, Int *estQP);
    249 #if KWU_RC_MADPRED_E0227
    250   Double getLCUTargetBppforInterView( list<TEncRCPic*>& listPreviousPictures, TComDataCU* pcCU, Double basePos, Double curPos, Double focalLen, Double znear, Double zfar, Int direction, Int* disparity );
    251 #endif
    252236  Double getLCUEstLambda( Double bpp );
    253237  Int    getLCUEstQP( Double lambda, Int clipPicQP );
     
    257241
    258242  Void addToPictureLsit( list<TEncRCPic*>& listPreviousPictures );
    259 #if KWU_RC_MADPRED_E0227
    260   Void addToPictureLsitIV( list<TEncRCPic*>& listPreviousPictures );
    261   Void setIVPic( TEncRCPic* baseRCPic );
    262 #endif
    263243  Double calAverageQP();
    264244  Double calAverageLambda();
     
    291271  Void setTotalIntraCost(Double cost)                     { m_totalCostIntra = cost; }
    292272  Void getLCUInitTargetBits();
    293 #if KWU_RC_MADPRED_E0227
    294   Double getTotalMAD()                                    { return m_totalMAD; }
    295   Void   setTotalMAD( Double MAD )                        { m_totalMAD = MAD; }
    296 
    297   Double getIVTotalMAD()                                    { return m_IVtotalMAD; }
    298   Void   setIVTotalMAD( Double MAD )                        { m_IVtotalMAD = MAD; }
    299 #endif
    300273
    301274  Int  getPicActualBits()                                 { return m_picActualBits; }
     
    307280  Void setPicEstLambda( Double lambda )                   { m_picLambda = lambda; }
    308281
    309 #if KWU_RC_MADPRED_E0227
    310   Int getLayerID()                                         { return m_LayerID; }
    311   Void setLayerID(Int layerid)                              { m_LayerID = layerid; }
    312 #endif
    313282private:
    314283  TEncRCSeq* m_encRCSeq;
     
    334303  Int m_picQP;                  // in integer form
    335304  Double m_picLambda;
    336 #if KWU_RC_MADPRED_E0227
    337   Double m_totalMAD;
    338   TEncRCPic* m_lastPicture;
    339   Int m_LayerID;
    340   TEncRCPic* m_lastIVPicture;
    341   Double m_IVtotalMAD;
    342 #endif
    343305};
    344306
     
    350312
    351313public:
    352 #if KWU_RC_MADPRED_E0227
    353   Void init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Bool keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP], Int layerID );
    354 #else
    355314  Void init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] );
    356 #endif
    357315  Void destroy();
    358316  Void initRCPic( Int frameLevel );
     
    368326  list<TEncRCPic*>& getPicList() { return m_listRCPictures; }
    369327
    370 #if KWU_RC_MADPRED_E0227
    371   Int getLayerID()                { return m_LayerID; }
    372   Void setLayerID(Int layerid)     { m_LayerID = layerid; }
    373 #endif
    374328#if U0132_TARGET_BITS_SATURATION
    375329  Bool       getCpbSaturationEnabled()  { return m_CpbSaturationEnabled;  }
     
    394348#endif
    395349
    396 #if KWU_RC_MADPRED_E0227
    397   Int m_LayerID;
     350};
     351
    398352#endif
    399 };
    400 
    401 #endif
    402 
    403 
     353
     354
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncSbac.cpp

    r1386 r1390  
    6262, m_cCUSplitFlagSCModel                ( 1,             1,                      NUM_SPLIT_FLAG_CTX                   , m_contextModels + m_numContextModels, m_numContextModels)
    6363, m_cCUSkipFlagSCModel                 ( 1,             1,                      NUM_SKIP_FLAG_CTX                    , m_contextModels + m_numContextModels, m_numContextModels)
    64 #if NH_3D_DIS
    65 , m_cCUDISFlagSCModel                  ( 1,             1,                      NUM_DIS_FLAG_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
    66 , m_cCUDISTypeSCModel                  ( 1,             1,                      NUM_DIS_TYPE_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
    67 #endif
    6864, m_cCUMergeFlagExtSCModel             ( 1,             1,                      NUM_MERGE_FLAG_EXT_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
    6965, m_cCUMergeIdxExtSCModel              ( 1,             1,                      NUM_MERGE_IDX_EXT_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
    70 #if NH_3D_ARP
    71 , m_cCUPUARPWSCModel                   ( 1,             1,                      NUM_ARPW_CTX                         , m_contextModels + m_numContextModels, m_numContextModels)
    72 #endif                                                                                                               
    73 #if NH_3D_IC                                                                                                         
    74 , m_cCUICFlagSCModel                   ( 1,             1,                      NUM_IC_FLAG_CTX                      , m_contextModels + m_numContextModels, m_numContextModels)
    75 #endif
    7666, m_cCUPartSizeSCModel                 ( 1,             1,                      NUM_PART_SIZE_CTX                    , m_contextModels + m_numContextModels, m_numContextModels)
    7767, m_cCUPredModeSCModel                 ( 1,             1,                      NUM_PRED_MODE_CTX                    , m_contextModels + m_numContextModels, m_numContextModels)
     
    10292, m_ChromaQpAdjIdcSCModel              ( 1,             1,                      NUM_CHROMA_QP_ADJ_IDC_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
    10393
    104 #if NH_3D_DMM
    105 , m_cNotDmmFlagSCModel                 ( 1,             1,                      NUM_NOTDMM_FLAG_CTX                  , m_contextModels + m_numContextModels, m_numContextModels)
    106 , m_cDmmModeSCModel                    ( 1,             1,                      NUM_DMM_MODE_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
    107 #endif
    108 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    109 , m_cDdcDataSCModel                    ( 1,             1,                      NUM_DDC_DATA_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
    110 , m_cSDCFlagSCModel                    ( 1,             1,                       NUM_SDC_FLAG_CTX                    , m_contextModels + m_numContextModels, m_numContextModels)
    111 #endif
    112 #if NH_3D_SDC_INTRA
    113 , m_cSDCResidualFlagSCModel            ( 1,             1,                      SDC_NUM_RESIDUAL_FLAG_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
    114 , m_cSDCResidualSCModel                ( 1,             1,                      SDC_NUM_RESIDUAL_CTX                 , m_contextModels + m_numContextModels, m_numContextModels)
    115 , m_cDdcFlagSCModel                    ( 1,             1,                      NUM_DDC_FLAG_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
    116 #endif                                                                                                         
    117 #if NH_3D_DBBP
    118 , m_cDBBPFlagSCModel                   ( 1,             1,                       DBBP_NUM_FLAG_CTX                   , m_contextModels + m_numContextModels, m_numContextModels)
    119 #endif
    12094{
    12195  assert( m_numContextModels <= MAX_NUM_CTX_MOD );
     
    143117  m_cCUSplitFlagSCModel.initBuffer                ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG );
    144118  m_cCUSkipFlagSCModel.initBuffer                 ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG );
    145 #if NH_3D_DIS
    146   m_cCUDISFlagSCModel.initBuffer                  ( eSliceType, iQp, (UChar*)INIT_DIS_FLAG );
    147   m_cCUDISTypeSCModel.initBuffer                  ( eSliceType, iQp, (UChar*)INIT_DIS_TYPE );
    148 #endif
    149119  m_cCUMergeFlagExtSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT);
    150120  m_cCUMergeIdxExtSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT);
    151 #if NH_3D_ARP
    152   m_cCUPUARPWSCModel.initBuffer                   ( eSliceType, iQp, (UChar*)INIT_ARPW );
    153 #endif
    154 #if NH_3D_IC
    155   m_cCUICFlagSCModel.initBuffer                   ( eSliceType, iQp, (UChar*)INIT_IC_FLAG );
    156 #endif
    157121  m_cCUPartSizeSCModel.initBuffer                 ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
    158122  m_cCUPredModeSCModel.initBuffer                 ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );
     
    183147  m_ChromaQpAdjIdcSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_CHROMA_QP_ADJ_IDC );
    184148
    185 #if NH_3D_DMM
    186   m_cNotDmmFlagSCModel.initBuffer                 ( eSliceType, iQp, (UChar*)INIT_NOTDMM_FLAG );
    187   m_cDmmModeSCModel.initBuffer                    ( eSliceType, iQp, (UChar*)INIT_DMM_MODE );
    188 #endif
    189 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    190   m_cDdcDataSCModel.initBuffer                    ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );
    191   m_cSDCFlagSCModel.initBuffer                    ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
    192 #endif
    193 #if NH_3D_SDC_INTRA
    194   m_cSDCResidualFlagSCModel.initBuffer            ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
    195   m_cSDCResidualSCModel.initBuffer                ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL );
    196   m_cDdcFlagSCModel.initBuffer                    ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG );
    197 #endif                                           
    198 #if NH_3D_DBBP
    199   m_cDBBPFlagSCModel.initBuffer                   ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG );
    200 #endif
    201149
    202150  for (UInt statisticIndex = 0; statisticIndex < RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS ; statisticIndex++)
     
    231179      curCost  = m_cCUSplitFlagSCModel.calcCost                ( curSliceType, qp, (UChar*)INIT_SPLIT_FLAG );
    232180      curCost += m_cCUSkipFlagSCModel.calcCost                 ( curSliceType, qp, (UChar*)INIT_SKIP_FLAG );
    233 #if NH_3D_DIS
    234       curCost += m_cCUDISFlagSCModel.calcCost                  ( curSliceType, qp, (UChar*)INIT_DIS_FLAG );
    235       curCost += m_cCUDISTypeSCModel.calcCost                  ( curSliceType, qp, (UChar*)INIT_DIS_TYPE );
    236 #endif
    237181      curCost += m_cCUMergeFlagExtSCModel.calcCost             ( curSliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT);
    238182      curCost += m_cCUMergeIdxExtSCModel.calcCost              ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT);
    239 #if NH_3D_ARP
    240       curCost += m_cCUPUARPWSCModel.calcCost                   ( curSliceType, qp, (UChar*)INIT_ARPW );
    241 #endif                                                     
    242 #if NH_3D_IC                                               
    243       curCost += m_cCUICFlagSCModel.calcCost                   ( curSliceType, qp, (UChar*)INIT_IC_FLAG );
    244 #endif                                                     
    245 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    246       curCost += m_cSDCFlagSCModel.calcCost                    ( curSliceType, qp, (UChar*)INIT_SDC_FLAG );
    247 #endif                                                     
    248 #if NH_3D_DBBP
    249       curCost += m_cDBBPFlagSCModel.calcCost                   ( curSliceType, qp, (UChar*)INIT_DBBP_FLAG );
    250 #endif
    251183      curCost += m_cCUPartSizeSCModel.calcCost                 ( curSliceType, qp, (UChar*)INIT_PART_SIZE );
    252184      curCost += m_cCUPredModeSCModel.calcCost                 ( curSliceType, qp, (UChar*)INIT_PRED_MODE );
     
    276208      curCost += m_ChromaQpAdjFlagSCModel.calcCost             ( curSliceType, qp, (UChar*)INIT_CHROMA_QP_ADJ_FLAG );
    277209      curCost += m_ChromaQpAdjIdcSCModel.calcCost              ( curSliceType, qp, (UChar*)INIT_CHROMA_QP_ADJ_IDC );
    278 #if NH_3D_DMM
    279       curCost += m_cNotDmmFlagSCModel.calcCost                 ( curSliceType, qp, (UChar*)INIT_NOTDMM_FLAG ); 
    280       curCost += m_cDmmModeSCModel.calcCost                    ( curSliceType, qp, (UChar*)INIT_DMM_MODE );
    281 #endif
    282 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    283       curCost += m_cDdcDataSCModel.calcCost                    ( curSliceType, qp, (UChar*)INIT_DDC_DATA );
    284 #endif
    285210
    286211      if (curCost < bestCost)
     
    406331}
    407332
    408 #if NH_3D_DIS
    409 Void TEncSbac::codeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx )
    410 {
    411   UInt uiSymbol = pcCU->getDISFlag(uiAbsPartIdx ) ? 1 : 0;
    412   m_pcBinIf->encodeBin( uiSymbol, m_cCUDISFlagSCModel.get( 0, 0, 0 ) );
    413   if(uiSymbol)
    414   {
    415     UInt uiUnaryIdx = (UInt) pcCU->getDISType(uiAbsPartIdx);
    416     UInt uiNumCand  = 4;
    417 
    418     if ( uiNumCand > 1 )
    419     {
    420       for( UInt ui = 0; ui < uiNumCand - 1; ++ui )
    421       {
    422         const UInt uiSymbol2 = ui == uiUnaryIdx ? 0 : 1;
    423         if ( ui == 0 )
    424         {
    425           m_pcBinIf->encodeBin( uiSymbol2, m_cCUDISTypeSCModel.get( 0, 0, 0 ) );
    426         }
    427         else
    428         {
    429           m_pcBinIf->encodeBinEP( uiSymbol2 );
    430         }
    431         if( uiSymbol2 == 0 )
    432         {
    433           break;
    434         }
    435       }
    436     }
    437   }
    438 }
    439 #endif
    440333
    441334
     
    522415}
    523416
    524 #if NH_3D_DMM
    525 Void TEncSbac::loadIntraDepthDmm( const TEncSbac* pSrc )
    526 {
    527   m_pcBinIf->copyState( pSrc->m_pcBinIf );
    528   this->m_cNotDmmFlagSCModel.copyFrom( &pSrc->m_cNotDmmFlagSCModel );
    529   this->m_cDmmModeSCModel   .copyFrom( &pSrc->m_cDmmModeSCModel );
    530 }
    531 #endif
    532417
    533418
     
    567452{
    568453  PartSize eSize         = pcCU->getPartitionSize( uiAbsPartIdx );
    569 #if NH_3D_QTLPC
    570   Bool    bLimQtPredFlag = pcCU->getPic()->getSlice(0)->getQtPredFlag();
    571   TComPic *pcTexture     = pcCU->getSlice()->getTexturePic();
    572   Bool bDepthMapDetect   = (pcTexture != NULL);
    573   Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE);
    574 
    575   Bool rapPic     = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA);
    576 
    577   Bool depthDependent = false;
    578   UInt uiTexturePart = eSize;
    579 
    580 #if H_3D_FCO
    581   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && bLimQtPredFlag && pcTexture->getReconMark())
    582 #else
    583   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && bLimQtPredFlag )
    584 #endif
    585   {
    586     TComDataCU *pcTextureCU = pcTexture->getCtu(pcCU->getCtuRsAddr());
    587     UInt uiCUIdx            = (pcCU->getZorderIdxInCtu() == 0) ? uiAbsPartIdx : pcCU->getZorderIdxInCtu();
    588     assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth);
    589     if(pcTextureCU->getDepth(uiCUIdx) == uiDepth )
    590     {
    591       depthDependent = true;
    592       uiTexturePart = pcTextureCU->getPartitionSize( uiCUIdx );
    593     }
    594     if (pcTextureCU->getDepth(uiCUIdx) == uiDepth && pcTextureCU->getPartitionSize( uiCUIdx ) == SIZE_2Nx2N)
    595     {
    596       assert( eSize == SIZE_2Nx2N );
    597       return;
    598     }
    599   }
    600 #endif
    601454  const UInt log2DiffMaxMinCodingBlockSize = pcCU->getSlice()->getSPS()->getLog2DiffMaxMinCodingBlockSize();
    602455
     
    616469  DTRACE_CU("part_mode", eSize )
    617470#endif       
    618 #if NH_3D_QTLPC
    619     if (depthDependent==false || uiTexturePart == SIZE_NxN|| uiTexturePart == SIZE_2Nx2N)
    620     {
    621 #endif
    622471
    623472  switch(eSize)
     
    690539    }
    691540  }
    692 #if NH_3D_QTLPC
    693     }
    694     else if(uiTexturePart == SIZE_2NxN || uiTexturePart == SIZE_2NxnU || uiTexturePart == SIZE_2NxnD)
    695     {
    696       //assert(eSize!=SIZE_NxN);
    697       //assert(eSize!=SIZE_Nx2N);
    698       //assert(eSize==SIZE_2Nx2N || eSize==SIZE_2NxN || eSize==SIZE_2NxnU || eSize==SIZE_2NxnD);
    699       switch(eSize)
    700       {
    701       case SIZE_2Nx2N:
    702         {
    703           m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) );
    704           break;
    705         }
    706       case SIZE_2NxN:
    707         {
    708           m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
    709           if (  pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize  )
    710           {     
    711             m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 1) );
    712           }
    713           break;
    714         }
    715       case SIZE_2NxnU:
    716       case SIZE_2NxnD:
    717         {
    718           m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
    719           m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) );
    720           m_pcBinIf->encodeBinEP((eSize == SIZE_2NxnU? 0: 1));
    721           break;
    722         }
    723       default:
    724         {
    725           assert(0);
    726         }
    727       }
    728     }
    729     else if(uiTexturePart == SIZE_Nx2N|| uiTexturePart==SIZE_nLx2N || uiTexturePart==SIZE_nRx2N)
    730     {
    731       //assert(eSize!=SIZE_NxN);
    732       //assert(eSize!=SIZE_2NxN);
    733       //assert(eSize==SIZE_2Nx2N ||eSize==SIZE_Nx2N || eSize==SIZE_nLx2N || eSize==SIZE_nRx2N);
    734       switch(eSize)
    735       {
    736       case SIZE_2Nx2N:
    737         {
    738           m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) );
    739           break;
    740         }
    741       case SIZE_Nx2N:
    742         {
    743           m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
    744           if ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize )
    745           {     
    746             m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 1) );
    747           }
    748           break;
    749         }
    750       case SIZE_nLx2N:
    751       case SIZE_nRx2N:
    752         {
    753           m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
    754           m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) );
    755           m_pcBinIf->encodeBinEP((eSize == SIZE_nLx2N? 0: 1));
    756           break;
    757         }
    758       default:
    759         {
    760           assert(0);
    761         }
    762       }
    763     }
    764     else
    765     {
    766       printf("uiTexturePart=%d",uiTexturePart);
    767       assert(0);
    768     }
    769 #endif
    770541
    771542}
     
    885656}
    886657
    887 #if NH_3D_ARP
    888 Void TEncSbac::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
    889 {
    890   Int  iW = (Int)pcCU->getARPW( uiAbsPartIdx );
    891   Int  iMaxW = pcCU->getSlice()->getARPStepNum() - 1;
    892   assert( iMaxW > 0);
    893 
    894   Int nOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx);
    895   Int nBinNum = iW + ( iW != iMaxW );
    896   m_pcBinIf->encodeBin( iW ? 1 : 0 , m_cCUPUARPWSCModel.get( 0, 0, 0 + nOffset ) );
    897   if( nBinNum > 1 )
    898   {
    899      m_pcBinIf->encodeBin( ( iW == iMaxW ) ? 1 : 0, m_cCUPUARPWSCModel.get( 0, 0, 2 ) );
    900   }
    901 #if NH_MV_ENC_DEC_TRAC
    902   DTRACE_CU("iv_res_pred_weight_idx", iW);
    903 #endif
    904 }
    905 #endif
    906 
    907 #if NH_3D_IC
    908 /** code Illumination Compensation flag
    909  * \param pcCU
    910  * \param uiAbsPartIdx
    911  * \returns Void
    912  */
    913 Void TEncSbac::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
    914 {
    915   // get context function is here
    916   UInt uiSymbol = pcCU->getICFlag( uiAbsPartIdx ) ? 1 : 0;
    917   m_pcBinIf->encodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, 0 ) );
    918 #if !NH_MV_ENC_DEC_TRAC
    919   DTRACE_CABAC_VL( g_nSymbolCounter++ );
    920   DTRACE_CABAC_T( "\tICFlag" );
    921   DTRACE_CABAC_T( "\tuiSymbol: ");
    922   DTRACE_CABAC_V( uiSymbol );
    923   DTRACE_CABAC_T( "\n");
    924 #else
    925   DTRACE_CU("ic_flag", uiSymbol );
    926 #endif
    927 }
    928 #endif
     658
    929659
    930660
     
    940670
    941671  assert( uiCtx < 3 );
    942 #if NH_3D_QTLPC
    943   Bool bCodeSplitFlag    = true;
    944 
    945  
    946   Bool    bLimQtPredFlag = pcCU->getPic()->getSlice(0)->getQtPredFlag();
    947   TComPic *pcTexture     = pcCU->getSlice()->getTexturePic();
    948   Bool bDepthMapDetect   = (pcTexture != NULL);
    949   Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE);
    950 
    951   Bool rapPic     = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA);
    952 
    953 #if H_3D_FCO
    954   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && bLimQtPredFlag && pcTexture->getReconMark() )
    955 #else
    956   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && bLimQtPredFlag  )
    957 #endif
    958   {
    959     TComDataCU *pcTextureCU = pcTexture->getCtu(pcCU->getCtuRsAddr());
    960     UInt uiCUIdx            = (pcCU->getZorderIdxInCtu() == 0) ? uiAbsPartIdx : pcCU->getZorderIdxInCtu();
    961     assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth);
    962     bCodeSplitFlag          = (pcTextureCU->getDepth(uiCUIdx) > uiDepth);
    963   }
    964 
    965   if(!bCodeSplitFlag)
    966   {
    967     assert(uiCurrSplitFlag == 0);
    968     return;
    969   }
    970 #endif
    971672
    972673  m_pcBinIf->encodeBin( uiCurrSplitFlag, m_cCUSplitFlagSCModel.get( 0, 0, uiCtx ) );
     
    1009710  {
    1010711    dir[j] = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx+partOffset*j );
    1011 #if NH_3D_DMM
    1012     if( pcCU->getSlice()->getIntraSdcWedgeFlag() ||  pcCU->getSlice()->getIntraContourFlag() )
    1013     {
    1014       xCodeIntraDepthMode( pcCU, absPartIdx+partOffset*j );
    1015       xCodeDmmData       ( pcCU, absPartIdx+partOffset*j );
    1016     }
    1017     if( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
    1018     {
    1019 #endif
    1020712    pcCU->getIntraDirPredictor(absPartIdx+partOffset*j, preds[j], COMPONENT_Y);
    1021713    for(UInt i = 0; i < NUM_MOST_PROBABLE_MODES; i++)
     
    1030722      DTRACE_CU("prev_intra_luma_pred_flag", (predIdx[j] != -1)? 1 : 0);
    1031723#endif
    1032 #if NH_3D_DMM
    1033     }
    1034 #endif
    1035724
    1036725  }
    1037726  for (j=0;j<partNum;j++)
    1038727  {
    1039 #if NH_3D_DMM
    1040     if( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
    1041     {
    1042 #endif
    1043728    if(predIdx[j] != -1)
    1044729    {
     
    1075760#endif
    1076761    }
    1077 #if NH_3D_DMM
    1078     }
    1079 #endif
    1080762  }
    1081763  return;
     
    24592141}
    24602142
    2461 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    2462 Void TEncSbac::codeDeltaDC( TComDataCU* pcCU, UInt absPartIdx )
    2463 {
    2464 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    2465   if( !(pcCU->getSDCFlag( absPartIdx )) )
    2466 #endif
    2467 #if NH_3D_DMM
    2468     if( !(pcCU->isIntra( absPartIdx ) && isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ) )) )
    2469 #endif
    2470     assert( 0 );
    2471 
    2472   UInt uiNumSegments = 1;
    2473 #if NH_3D_DMM
    2474   uiNumSegments = isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ) ) ? 2 : 1;
    2475 #endif
    2476 
    2477   UInt hasDeltaDC = 1;
    2478 #if NH_3D_SDC_INTRA
    2479   if( pcCU->isIntra( absPartIdx ) && pcCU->getSDCFlag( absPartIdx ))
    2480   {
    2481     if( uiNumSegments == 1 )
    2482     {
    2483       hasDeltaDC = pcCU->getSDCSegmentDCOffset( 0, absPartIdx ) ? 1 : 0;
    2484     }
    2485     else
    2486     {
    2487       hasDeltaDC = ( pcCU->getSDCSegmentDCOffset( 0, absPartIdx ) || pcCU->getSDCSegmentDCOffset( 1, absPartIdx ) ) ? 1 : 0;
    2488     }
    2489     m_pcBinIf->encodeBin( hasDeltaDC, m_cDdcFlagSCModel.get( 0, 0, 0 ) );
    2490   }
    2491 #endif
    2492 
    2493   if( hasDeltaDC )
    2494   {
    2495     for( UInt segment = 0; segment < uiNumSegments; segment++ )
    2496     {
    2497       Pel deltaDC = 0;
    2498       if( pcCU->isIntra( absPartIdx ) )
    2499       {
    2500 #if NH_3D_SDC_INTRA
    2501         if( pcCU->getSDCFlag( absPartIdx ) )
    2502         {
    2503           deltaDC = pcCU->getSDCSegmentDCOffset( segment, absPartIdx );
    2504         }
    2505         else
    2506         {
    2507 #endif
    2508 #if NH_3D_DMM
    2509         deltaDC = pcCU->getDmmDeltaDC( getDmmType( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ) ), segment, absPartIdx );
    2510 #endif
    2511 #if NH_3D_SDC_INTRA
    2512         }
    2513 #endif
    2514       }
    2515 #if NH_3D_SDC_INTER
    2516       else
    2517       {
    2518         deltaDC = pcCU->getSDCSegmentDCOffset( segment, absPartIdx );
    2519       }
    2520 #endif
    2521       xCodeDeltaDC( deltaDC, uiNumSegments );
    2522     }
    2523   }
    2524 }
    2525 
    2526 Void TEncSbac::xCodeDeltaDC( Pel valDeltaDC, UInt uiNumSeg )
    2527 {
    2528 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC
    2529   DTRACE_CU("delta_dc", valDeltaDC);
    2530 #endif
    2531   xWriteExGolombLevelDdc( UInt( abs( valDeltaDC ) - ( uiNumSeg > 1 ? 0 : 1 ) ) );
    2532   if( valDeltaDC != 0 )
    2533   {
    2534     UInt uiSign = valDeltaDC > 0 ? 0 : 1;
    2535     m_pcBinIf->encodeBinEP( uiSign );
    2536   }
    2537 }
    2538 
    2539 Void TEncSbac::xWriteExGolombLevelDdc( UInt uiSymbol )
    2540 {
    2541   if( uiSymbol )
    2542   {
    2543     m_pcBinIf->encodeBin( 1, m_cDdcDataSCModel.get(0, 0, 0) );
    2544     UInt uiCount = 0;
    2545     Bool bNoExGo = ( uiSymbol < 3 );
    2546 
    2547     while( --uiSymbol && ++uiCount < 3 )
    2548     {
    2549       m_pcBinIf->encodeBin( 1, m_cDdcDataSCModel.get(0, 0, 0) );
    2550     }
    2551     if( bNoExGo )
    2552     {
    2553       m_pcBinIf->encodeBin( 0, m_cDdcDataSCModel.get(0, 0, 0) );
    2554     }
    2555     else
    2556     {
    2557       xWriteEpExGolomb( uiSymbol, 0 );
    2558     }
    2559   }
    2560   else
    2561   {
    2562     m_pcBinIf->encodeBin( 0, m_cDdcDataSCModel.get(0, 0, 0) );
    2563   }
    2564 
    2565   return;
    2566 }
    2567 #endif
    2568 
    2569 #if NH_3D_DMM
    2570 Void TEncSbac::xCodeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx )
    2571 {
    2572   UInt dir = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx );
    2573 
    2574   if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed
    2575   {
    2576     m_pcBinIf->encodeBin( isDmmMode( dir ) ? 0 : 1, m_cNotDmmFlagSCModel.get( 0, 0, 0 ) );
    2577   }
    2578   if( isDmmMode( dir ) )
    2579   {
    2580     UInt uiCodeIdx = 0;
    2581 
    2582     switch( getDmmType( dir ) )
    2583     {
    2584     case DMM1_IDX: uiCodeIdx = 0; break;
    2585     case DMM4_IDX: uiCodeIdx = 1; break;
    2586     default:                      break;
    2587     }
    2588     //mode coding
    2589     if( pcCU->getSlice()->getIntraSdcWedgeFlag() && pcCU->getSlice()->getIntraContourFlag())
    2590     {
    2591       m_pcBinIf->encodeBin( uiCodeIdx == 0 ? 0 : 1, m_cDmmModeSCModel.get( 0, 0, 0 ) );
    2592     }
    2593   }
    2594 }
    2595 
    2596 Void TEncSbac::xCodeDmmData( TComDataCU* pcCU, UInt absPartIdx )
    2597 {
    2598   UInt dir = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx );
    2599   switch( getDmmType( dir ) )
    2600   {
    2601   case( DMM1_IDX ): { xCodeDmm1WedgeIdx( pcCU->getDmm1WedgeTabIdx( absPartIdx ), g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); } break;
    2602   case( DMM4_IDX ): break;
    2603   default:          break;
    2604   }
    2605 }
    2606 
    2607 Void TEncSbac::xCodeDmm1WedgeIdx( UInt uiTabIdx, Int iNumBit )
    2608 {
    2609   for ( Int i = 0; i < iNumBit; i++ )
    2610   {
    2611     m_pcBinIf->encodeBinEP( ( uiTabIdx >> i ) & 1 );
    2612   }
    2613 }
    2614 #endif
    2615 
    2616 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    2617 Void TEncSbac::codeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
    2618 {
    2619   UInt uiSymbol = pcCU->getSDCFlag( uiAbsPartIdx ) ? 1 : 0;
    2620 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC
    2621   DTRACE_CU("dc_only_flag", uiSymbol)
    2622 #endif
    2623   m_pcBinIf->encodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, 0 ) );
    2624 }
    2625 
    2626 #endif
    2627 
    2628 #if NH_3D_DBBP
    2629 Void TEncSbac::codeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
    2630 {
    2631   PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
    2632   AOF( ePartSize == SIZE_2NxN || ePartSize == SIZE_Nx2N );
    2633   AOF( pcCU->getSlice()->getDepthBasedBlkPartFlag() );
    2634   AOF( !pcCU->getSlice()->getIsDepth() );
    2635  
    2636   UInt uiSymbol = pcCU->getDBBPFlag( uiAbsPartIdx ) ? 1 : 0;
    2637   m_pcBinIf->encodeBin( uiSymbol, m_cDBBPFlagSCModel.get( 0, 0, 0 ) );
    2638   DTRACE_CU("dbbp_flag", uiSymbol)
    2639 }
    2640 #endif
     2143
     2144
     2145
    26412146
    26422147//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncSbac.h

    r1313 r1390  
    8080  Void  load                   ( const TEncSbac* pSrc  );
    8181  Void  loadIntraDirMode       ( const TEncSbac* pScr, const ChannelType chType  );
    82 #if NH_3D_DMM
    83   Void  loadIntraDepthDmm      ( const TEncSbac* pSrc );
    84 #endif
    8582  Void  store                  ( TEncSbac* pDest ) const;
    8683  Void  loadContexts           ( const TEncSbac* pSrc  );
     
    115112  Void  xWriteEpExGolomb     ( UInt uiSymbol, UInt uiCount );
    116113  Void  xWriteCoefRemainExGolomb ( UInt symbol, UInt &rParam, const Bool useLimitedPrefixLength, const Int maxLog2TrDynamicRange );
    117 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    118   Void  xWriteExGolombLevelDdc( UInt uiSymbol );
    119   Void  xCodeDeltaDC         ( Pel valDeltaDC, UInt uiNumSeg );
    120 #endif
    121 #if NH_3D_DMM
    122   Void  xCodeIntraDepthMode  ( TComDataCU* pcCU, UInt absPartIdx );
    123   Void  xCodeDmmData         ( TComDataCU* pcCU, UInt absPartIdx );
    124   Void  xCodeDmm1WedgeIdx    ( UInt uiTabIdx, Int iNumBit );
    125 #endif
    126114
    127115
     
    138126  Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx );
    139127  Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    140 #if NH_3D_DIS
    141   Void codeDIS           ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    142 #endif
    143128  Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    144129  Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    145 #if NH_3D_ARP
    146   Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    147 #endif
    148 #if NH_3D_IC
    149   Void codeICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    150 #endif
    151 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    152   Void  codeDeltaDC      ( TComDataCU* pcCU, UInt absPartIdx );
    153 #endif
    154 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    155   Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    156 #endif
    157 #if NH_3D_DBBP
    158   Void codeDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    159 #endif
    160130  Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    161131  Void codeMVPIdx        ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
     
    204174  ContextModel3DBuffer m_cCUSplitFlagSCModel;
    205175  ContextModel3DBuffer m_cCUSkipFlagSCModel;
    206 #if NH_3D_DIS
    207   ContextModel3DBuffer m_cCUDISFlagSCModel;
    208   ContextModel3DBuffer m_cCUDISTypeSCModel;
    209 #endif
    210176  ContextModel3DBuffer m_cCUMergeFlagExtSCModel;
    211177  ContextModel3DBuffer m_cCUMergeIdxExtSCModel;
    212 #if NH_3D_ARP
    213   ContextModel3DBuffer m_cCUPUARPWSCModel;
    214 #endif
    215 #if NH_3D_IC
    216   ContextModel3DBuffer m_cCUICFlagSCModel;
    217 #endif
    218178  ContextModel3DBuffer m_cCUPartSizeSCModel;
    219179  ContextModel3DBuffer m_cCUPredModeSCModel;
     
    248208  ContextModel3DBuffer m_ChromaQpAdjIdcSCModel;
    249209
    250 #if NH_3D_DMM
    251   ContextModel3DBuffer m_cNotDmmFlagSCModel;
    252   ContextModel3DBuffer m_cDmmModeSCModel;
    253 #endif
    254 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    255   ContextModel3DBuffer m_cDdcDataSCModel;
    256   ContextModel3DBuffer m_cSDCFlagSCModel;
    257 #endif
    258 #if NH_3D_SDC_INTRA 
    259   ContextModel3DBuffer m_cSDCResidualFlagSCModel;
    260   ContextModel3DBuffer m_cSDCResidualSCModel;
    261   ContextModel3DBuffer m_cDdcFlagSCModel;
    262 #endif
    263 #if NH_3D_DBBP
    264   ContextModel3DBuffer m_cDBBPFlagSCModel;
    265 #endif
    266210
    267211  UInt m_golombRiceAdaptationStatistics[RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS];
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncSearch.cpp

    r1386 r1390  
    316316  const Pel* const  piRefSrch = rcStruct.piRefY + iSearchY * rcStruct.iYStride + iSearchX;
    317317
    318 #if NH_3D_IC
    319   m_cDistParam.bUseIC = pcPatternKey->getICFlag();
    320 #endif
    321 #if NH_3D_SDC_INTER
    322   m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
    323 #endif
    324318  //-- jclee for using the SAD function pointer
    325319  m_pcRdCost->setDistParam( pcPatternKey, piRefSrch, rcStruct.iYStride,  m_cDistParam );
     
    868862
    869863    setDistParamComp(COMPONENT_Y);
    870 #if NH_3D_IC
    871     m_cDistParam.bUseIC = pcPatternKey->getICFlag();
    872 #endif
    873 #if NH_3D_SDC_INTER
    874     m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
    875 #endif
    876864
    877865    m_cDistParam.pCur = piRefPos;
     
    10251013        }
    10261014        m_pcEntropyCoder->encodeSkipFlag( pcCU, 0, true );
    1027 #if NH_3D_DIS
    1028         m_pcEntropyCoder->encodeDIS(pcCU, 0, true );
    1029         if(!pcCU->getDISFlag(uiAbsPartIdx))
    1030 #endif
    10311015        m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
    10321016      }
    1033 #if NH_3D_DIS
    1034       else
    1035       {
    1036         m_pcEntropyCoder->encodeDIS(pcCU, 0, true );
    1037       }
    1038 #endif
    1039 #if NH_3D_DIS
    1040       if(!pcCU->getDISFlag(uiAbsPartIdx))
    1041       {
    1042 #endif
    10431017      m_pcEntropyCoder  ->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
    10441018
     
    10491023        if ( pcCU->getIPCMFlag (0))
    10501024        {
    1051 #if NH_3D_SDC_INTRA
    1052             m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
    1053 #endif
    10541025          return;
    10551026        }
    10561027      }
    1057 #if NH_3D_DIS
    1058     }
    1059 #endif
    1060   }
    1061 #if NH_3D_DIS
    1062     if(!pcCU->getDISFlag(uiAbsPartIdx))
    1063     {
    1064 #endif
     1028  }
    10651029    // luma prediction mode
    10661030    if( pcCU->getPartitionSize(0) == SIZE_2Nx2N )
     
    10691033      {
    10701034        m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, 0 );
    1071 #if NH_3D_SDC_INTRA
    1072           m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
    1073 #if NH_3D_DMM
    1074           if( pcCU->getSlice()->getIsDepth() && ( !pcCU->getSDCFlag( 0 ) ) && isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, 0 ) ) )
    1075           {
    1076             m_pcEntropyCoder->encodeDeltaDC( pcCU, 0 );
    1077           }
    1078 #endif
    1079 #endif
    10801035      }
    10811036    }
     
    10861041      {
    10871042        m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, uiAbsPartIdx );
    1088 #if NH_3D_SDC_INTRA
    1089           if( uiAbsPartIdx == 0 ) 
    1090           {
    1091             m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
    1092           }
    1093 #if NH_3D_DMM
    1094           if( pcCU->getSlice()->getIsDepth() && ( !pcCU->getSDCFlag( uiAbsPartIdx ) ) && isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ) ) )
    1095           {
    1096             m_pcEntropyCoder->encodeDeltaDC( pcCU, uiAbsPartIdx );
    1097           }
    1098 #endif
    1099 #endif
    1100 #if NH_3D_DIS
    1101       }
    1102 #endif
    11031043      }
    11041044    }
     
    11711111                                            Pel         resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE],
    11721112                                      const Bool        checkCrossCPrediction,
    1173 #if NH_3D_VSO
    1174                                             Dist&       ruiDist,
    1175 #else
    11761113                                            Distortion& ruiDist,
    1177 #endif
    11781114                                      const ComponentID compID,
    11791115                                            TComTU&     rTu
    11801116                                      DEBUG_STRING_FN_DECLARE(sDebug)
    11811117                                           ,Int         default0Save1Load2
    1182 #if NH_3D_ENC_DEPTH
    1183                                           , Bool        zeroResiFlag
    1184 #endif
    11851118
    11861119                                     )
     
    12531186
    12541187    //===== get prediction signal =====
    1255 #if NH_3D_DMM
    1256     if( bIsLuma && isDmmMode( uiChFinalMode ) )
    1257     {
    1258       predIntraLumaDmm( pcCU, uiAbsPartIdx, getDmmType( uiChFinalMode ), piPred, uiStride, uiWidth, uiHeight );
    1259     }
    1260     else
    1261     {
    1262 #endif
    12631188    predIntraAng( compID, uiChFinalMode, piOrg, uiStride, piPred, uiStride, rTu, bUseFilteredPredictions );
    1264 #if NH_3D_DMM
    1265     }
    1266 #endif
    12671189
    12681190    // save prediction
     
    13091231    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    13101232    {
    1311 #if NH_3D_ENC_DEPTH
    1312       if( zeroResiFlag )
    1313       {
    1314         memset( pResi, 0, sizeof( Pel ) * uiWidth );
    1315         pResi += uiStride;
    1316       }
    1317       else
    1318       {
    1319 #endif
    13201233      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    13211234      {
     
    13261239      pResi += uiStride;
    13271240      pPred += uiStride;
    1328 #if NH_3D_ENC_DEPTH
    1329       }
    1330 #endif
    13311241
    13321242    }
     
    14911401
    14921402  //===== update distortion =====
    1493 #if NH_3D_VSO // M39
    1494   if ( m_pcRdCost->getUseVSO() ) 
    1495   {
    1496       ruiDist += m_pcRdCost->getDistPartVSO  ( pcCU, uiAbsPartIdx, bitDepth, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, false ); 
    1497   }
    1498   else
    1499 #endif
    15001403    ruiDist += m_pcRdCost->getDistPart( bitDepth, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, compID );
    15011404}
     
    15071410                                    TComYuv*    pcResiYuv,
    15081411                                    Pel         resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE],
    1509 #if NH_3D_VSO
    1510                                     Dist&        ruiDistY,
    1511 #else
    15121412                                    Distortion& ruiDistY,
    1513 #endif
    15141413#if HHI_RQT_INTRA_SPEEDUP
    15151414                                    Bool        bCheckFirst,
     
    15181417                                    TComTU&     rTu
    15191418                                    DEBUG_STRING_FN_DECLARE(sDebug)
    1520 #if NH_3D_ENC_DEPTH
    1521                                   , Bool        zeroResiFlag
    1522 #endif                               
    15231419                                  )
    15241420{
     
    15761472  }
    15771473#endif
    1578 #if NH_3D_DMM
    1579   if( isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ) ) )
    1580   {
    1581     bCheckSplit = false;
    1582   }
    1583 #endif
    15841474  Double     dSingleCost                        = MAX_DOUBLE;
    1585 #if NH_3D_VSO
    1586   Dist       uiSingleDistLuma                   = 0;
    1587 #else
    15881475  Distortion uiSingleDistLuma                   = 0;
    1589 #endif
    15901476  UInt       uiSingleCbfLuma                    = 0;
    15911477  Bool       checkTransformSkip  = pcCU->getSlice()->getPPS()->getUseTransformSkip();
     
    16081494      //----- store original entropy coding status -----
    16091495      m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
    1610 #if NH_3D_VSO
    1611       Dist       singleDistTmpLuma                    = 0;
    1612 #else
    16131496      Distortion singleDistTmpLuma                    = 0;
    1614 #endif
    16151497      UInt       singleCbfTmpLuma                     = 0;
    16161498      Double     singleCostTmp                        = 0;
     
    16461528        {
    16471529          UInt uiSingleBits = xGetIntraBitsQT( rTu, true, false, false );
    1648 #if NH_3D_VSO // M NEW
    1649           if ( m_pcRdCost->getUseRenModel() )
    1650           {
    1651             singleCostTmp     = m_pcRdCost->calcRdCostVSO( uiSingleBits, singleDistTmpLuma );
    1652           }
    1653           else
    1654 #endif
    16551530            singleCostTmp     = m_pcRdCost->calcRdCost( uiSingleBits, singleDistTmpLuma );
    16561531        }
     
    17071582      //----- code luma/chroma block with given intra prediction mode and store Cbf-----
    17081583      dSingleCost   = 0.0;
    1709 #if NH_3D_ENC_DEPTH
    1710       xIntraCodingTUBlock( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSingle, false, uiSingleDistLuma, COMPONENT_Y, rTu DEBUG_STRING_PASS_INTO(sDebug), 0, zeroResiFlag );
    1711 #else
    17121584      pcCU ->setTransformSkipSubParts ( 0, COMPONENT_Y, uiAbsPartIdx, totalAdjustedDepthChan );
    17131585      xIntraCodingTUBlock( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSingle, false, uiSingleDistLuma, COMPONENT_Y, rTu DEBUG_STRING_PASS_INTO(sDebug));
    1714 #endif
    17151586
    17161587      if( bCheckSplit )
     
    17251596        uiSingleBits=uiSingleBits*4;
    17261597      }
    1727 #if NH_3D_VSO // M40
    1728       if ( m_pcRdCost->getUseLambdaScaleVSO())     
    1729       {
    1730         dSingleCost = m_pcRdCost->calcRdCostVSO( uiSingleBits, uiSingleDistLuma );     
    1731       }
    1732       else
    1733 #endif
    17341598      dSingleCost       = m_pcRdCost->calcRdCost( uiSingleBits, uiSingleDistLuma );
    17351599
     
    17631627    //----- code splitted block -----
    17641628    Double     dSplitCost      = 0.0;
    1765 #if NH_3D_VSO
    1766     Dist       uiSplitDistLuma = 0;
    1767 #else
    17681629    Distortion uiSplitDistLuma = 0;
    1769 #endif
    17701630
    17711631    UInt       uiSplitCbfLuma  = 0;
     
    18031663
    18041664    UInt uiSplitBits = xGetIntraBitsQT( rTu, true, false, false );
    1805 #if NH_3D_VSO // M41
    1806     if( m_pcRdCost->getUseLambdaScaleVSO() )   
    1807     {
    1808       dSplitCost = m_pcRdCost->calcRdCostVSO( uiSplitBits, uiSplitDistLuma );   
    1809     }
    1810     else
    1811 #endif
    18121665    dSplitCost       = m_pcRdCost->calcRdCost( uiSplitBits, uiSplitDistLuma );
    18131666
     
    18661719  }
    18671720
    1868 #if NH_3D_VSO // M42
    1869   if ( m_pcRdCost->getUseRenModel() && bCheckFull )
    1870   {
    1871     UInt  uiWidth     = pcCU->getWidth ( 0 ) >> uiTrDepth;
    1872     UInt  uiHeight    = pcCU->getHeight( 0 ) >> uiTrDepth;
    1873     UInt  uiQTLayer   = pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - uiLog2TrSize;
    1874     Pel*  piSrc       = m_pcQTTempTComYuv[ uiQTLayer ].getAddr( COMPONENT_Y, uiAbsPartIdx );
    1875     UInt  uiSrcStride = m_pcQTTempTComYuv[ uiQTLayer ].getStride( COMPONENT_Y );
    1876 
    1877     m_pcRdCost->setRenModelData( pcCU, uiAbsPartIdx, piSrc, (Int) uiSrcStride, (Int) uiWidth, (Int) uiHeight );
    1878   }
    1879 #endif
    18801721
    18811722  ruiDistY += uiSingleDistLuma;
     
    18861727}
    18871728
    1888 #if NH_3D_DIS
    1889 Void TEncSearch::xIntraCodingDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, UInt uiPredMode )
    1890 {
    1891   UInt    uiWidth           = pcCU     ->getWidth   ( 0 );
    1892   UInt    uiHeight          = pcCU     ->getHeight  ( 0 );
    1893   UInt    uiStride          = pcOrgYuv ->getStride  (COMPONENT_Y);
    1894   Pel*    piOrg             = pcOrgYuv ->getAddr(COMPONENT_Y, uiAbsPartIdx );
    1895   Pel*    piPred            = pcPredYuv->getAddr(COMPONENT_Y, uiAbsPartIdx );
    1896 
    1897   AOF( uiWidth == uiHeight );
    1898   AOF( uiAbsPartIdx == 0 );
    1899   pcCU->setDISTypeSubParts((UChar)uiPredMode, uiAbsPartIdx, pcCU->getDepth(0)); 
    1900   //===== reconstruction =====
    1901 
    1902   TComTURecurse rTu(pcCU, 0);
    1903   const ChromaFormat chFmt     = rTu.GetChromaFormat();
    1904   DEBUG_STRING_NEW(sTemp)
    1905   if ( uiPredMode == 0 )
    1906   {
    1907     const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, VER_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
    1908     initIntraPatternChType( rTu, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
    1909     predIntraAng( COMPONENT_Y, VER_IDX, 0, uiStride, piPred, uiStride, rTu, bUseFilteredPredictions );
    1910   }
    1911   else if ( uiPredMode == 1 )
    1912   {
    1913     const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, HOR_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
    1914     initIntraPatternChType( rTu, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
    1915     predIntraAng( COMPONENT_Y, HOR_IDX, 0, uiStride, piPred, uiStride, rTu, bUseFilteredPredictions );
    1916   }
    1917   else if ( uiPredMode == 2 )
    1918   {
    1919     Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
    1920     pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 0 );
    1921     for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    1922     {
    1923       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    1924       {
    1925         piPred[ uiX ] = pSingleDepth;
    1926       }
    1927       piPred+= uiStride;
    1928     }
    1929   }
    1930   else if ( uiPredMode == 3 )
    1931   {
    1932     Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
    1933     pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 1 );
    1934     for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    1935     {
    1936       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    1937       {
    1938         piPred[ uiX ] = pSingleDepth;
    1939       }
    1940       piPred+= uiStride;
    1941     }
    1942   }
    1943 
    1944   // clear UV
    1945   UInt  uiStrideC     = pcPredYuv->getStride(COMPONENT_Cb);
    1946   Pel   *pRecCb       = pcPredYuv->getAddr(COMPONENT_Cb);
    1947   Pel   *pRecCr       = pcPredYuv->getAddr(COMPONENT_Cr);
    1948 
    1949   for (Int y=0; y<uiHeight/2; y++)
    1950   {
    1951     for (Int x=0; x<uiWidth/2; x++)
    1952     {
    1953       pRecCb[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
    1954       pRecCr[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
    1955     }
    1956 
    1957     pRecCb += uiStrideC;
    1958     pRecCr += uiStrideC;
    1959   }
    1960 
    1961   piPred            = pcPredYuv->getAddr(COMPONENT_Y, uiAbsPartIdx );
    1962   //===== determine distortion =====
    1963 #if NH_3D_VSO
    1964   if ( m_pcRdCost->getUseVSO() )
    1965     ruiDist = m_pcRdCost->getDistPartVSO  ( pcCU, uiAbsPartIdx, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA), piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, false );
    1966   else
    1967 #endif
    1968     ruiDist = m_pcRdCost->getDistPart(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA), piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, COMPONENT_Y );
    1969 
    1970   //===== determine rate and r-d cost =====
    1971   m_pcEntropyCoder->resetBits();
    1972   m_pcEntropyCoder->encodeDIS( pcCU, 0, true );
    1973   UInt uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    1974 
    1975 #if NH_3D_VSO
    1976   if ( m_pcRdCost->getUseLambdaScaleVSO())
    1977     dRDCost = m_pcRdCost->calcRdCostVSO( uiBits, ruiDist );
    1978   else
    1979 #endif
    1980     dRDCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
    1981 }
    1982 #endif
    1983 #if NH_3D_SDC_INTRA
    1984 Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi  )
    1985 {
    1986   UInt uiWidth        = pcCU->getWidth ( 0 );
    1987   UInt uiHeight       = pcCU->getHeight( 0 );
    1988   UInt uiLumaPredMode = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx );
    1989   const Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
    1990   const TComSPS     &sps    = *(pcCU->getSlice()->getSPS());
    1991   const ChromaFormat chFmt  = pcCU->getPic()->getChromaFormat();
    1992 
    1993   UInt sdcDepth = 0;
    1994   UInt uiStride;         
    1995   Pel* piOrg;         
    1996   Pel* piPred;         
    1997   Pel* piReco;       
    1998 
    1999   Pel* piRecIPred;
    2000   UInt uiRecIPredStride;
    2001 
    2002   Pel apDCPredValues[2];
    2003   Pel apDCOrigValues[2];
    2004   UInt uiNumSegments;
    2005 
    2006   Bool* pbMask = NULL;
    2007   UInt uiMaskStride = 0;
    2008 #if NH_3D_DMM
    2009   if( isDmmMode( uiLumaPredMode ) )
    2010   {
    2011     assert( uiWidth == uiHeight  );
    2012     assert( uiWidth >= DMM_MIN_SIZE && uiWidth <= DMM_MAX_SIZE );
    2013     assert( !(( uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) > 1) );
    2014 
    2015     uiNumSegments     = 2;
    2016 
    2017     uiStride          = pcOrgYuv ->getStride( COMPONENT_Y );
    2018     piOrg             = pcOrgYuv ->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
    2019     piPred            = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
    2020     piReco            = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
    2021 
    2022     piRecIPred        = pcCU->getPic()->getPicYuvRec()->getAddr  ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
    2023     uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y );
    2024 
    2025     //===== init availability pattern =====
    2026     TComTURecurse tuRecurseCU(pcCU, 0);
    2027     TComTURecurse tuRecurseWithPU(tuRecurseCU, false, TComTU::DONT_SPLIT);
    2028     DEBUG_STRING_NEW(sTemp)
    2029     initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, false DEBUG_STRING_PASS_INTO(sTemp) );
    2030 
    2031     // get partition
    2032     pbMask       = new Bool[ uiWidth*uiHeight ];
    2033     uiMaskStride = uiWidth;
    2034     switch( getDmmType( uiLumaPredMode ) )
    2035     {
    2036     case( DMM1_IDX ): { (getWedgeListScaled( uiWidth )->at( pcCU->getDmm1WedgeTabIdx( uiAbsPartIdx ) )).getPatternScaledCopy( uiWidth, pbMask ); } break;
    2037     case( DMM4_IDX ): { predContourFromTex( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask );                                                     } break;
    2038     default: assert(0);
    2039     }
    2040 
    2041     // get predicted partition values
    2042     Pel predDC1 = 0, predDC2 = 0;
    2043     predBiSegDCs( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask, uiMaskStride, predDC1, predDC2 );
    2044 
    2045     // set prediction signal
    2046     Pel* pDst = piPred;
    2047     assignBiSegDCs( pDst, uiStride, pbMask, uiMaskStride, predDC1, predDC2 );
    2048     apDCPredValues[0] = predDC1;
    2049     apDCPredValues[1] = predDC2;
    2050 
    2051     // get original partition values
    2052     xCalcBiSegDCs( piOrg, uiStride, pbMask, uiMaskStride, apDCOrigValues[0], apDCOrigValues[1], 0, (uiMaskStride > 16) );
    2053   }
    2054   else // regular HEVC intra modes
    2055   {
    2056 #endif
    2057     uiNumSegments = 1;
    2058    
    2059     if( ( uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) > 1 )
    2060     {
    2061       sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
    2062     }
    2063    
    2064     //===== loop over partitions =====
    2065     TComTURecurse tuRecurseCU(pcCU, 0);
    2066     TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (sdcDepth==0)?TComTU::DONT_SPLIT:TComTU::QUAD_SPLIT);
    2067    
    2068     do
    2069     {
    2070       const TComRectangle &puRect = tuRecurseWithPU.getRect(COMPONENT_Y);
    2071       const UInt uiAbsPartIdxTU = tuRecurseWithPU.GetAbsPartIdxTU();
    2072      
    2073       Pel* piOrgTU         = pcOrgYuv ->getAddr   ( COMPONENT_Y, uiAbsPartIdxTU );
    2074       Pel* piPredTU        = pcPredYuv->getAddr   ( COMPONENT_Y, uiAbsPartIdxTU );
    2075       UInt uiStrideTU      = pcPredYuv->getStride ( COMPONENT_Y );
    2076      
    2077       Pel* piRecIPredTU   = pcCU->getPic()->getPicYuvRec()->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdxTU );
    2078       UInt uiRecIPredStrideTU  = pcCU->getPic()->getPicYuvRec()->getStride(COMPONENT_Y);
    2079      
    2080       const Bool bUseFilter = TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiLumaPredMode, puRect.width, puRect.height, chFmt, sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag());
    2081      
    2082       //===== init pattern for luma prediction =====
    2083       DEBUG_STRING_NEW(sTemp2)
    2084       initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, bUseFilter DEBUG_STRING_PASS_INTO(sTemp2) );
    2085      
    2086       predIntraAng( COMPONENT_Y, uiLumaPredMode, piOrgTU, uiStrideTU, piPredTU, uiStrideTU, tuRecurseWithPU, bUseFilter );
    2087      
    2088       // copy for prediction of next part
    2089       for( UInt uiY = 0; uiY < puRect.height; uiY++ )
    2090       {
    2091         for( UInt uiX = 0; uiX < puRect.width; uiX++ )
    2092         {
    2093           piPredTU      [ uiX ] = ClipBD( piPredTU[ uiX ], bitDepthY );
    2094           piRecIPredTU  [ uiX ] = piPredTU[ uiX ];
    2095         }
    2096         piPredTU     += uiStrideTU;
    2097         piRecIPredTU += uiRecIPredStrideTU;
    2098       }
    2099      
    2100     } while (tuRecurseWithPU.nextSection(tuRecurseCU));
    2101 
    2102     // reset to full block
    2103     uiWidth  = pcCU->getWidth( 0 );
    2104     uiHeight = pcCU->getHeight( 0 );
    2105 
    2106     uiStride          = pcOrgYuv ->getStride( COMPONENT_Y );
    2107     piOrg             = pcOrgYuv ->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
    2108     piPred            = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
    2109     piReco            = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
    2110    
    2111     piRecIPred        = pcCU->getPic()->getPicYuvRec()->getAddr  ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
    2112     uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y );
    2113 
    2114     // get predicted and original DC
    2115     predConstantSDC( piPred, uiStride, uiWidth, apDCPredValues[0] ); apDCPredValues[1] = 0;
    2116     xCalcConstantSDC( piOrg, uiStride, uiWidth, apDCOrigValues[0] ); apDCOrigValues[1] = 0;
    2117 #if NH_3D_DMM 
    2118   }
    2119 #endif
    2120 
    2121   for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
    2122   {
    2123     // remap reconstructed value to valid depth values
    2124     Pel pDCRec = ( !bZeroResidual ) ? apDCOrigValues[uiSegment] : apDCPredValues[uiSegment];
    2125     // get residual (idx)
    2126 #if NH_3D_DLT
    2127     Pel pResidualIdx = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pDCRec ) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
    2128 #else
    2129     Pel pResidualIdx = pDCRec - apDCPredValues[uiSegment];
    2130 #endif
    2131     if( !bZeroResidual )
    2132     {
    2133 #if NH_3D_DLT
    2134       Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
    2135       Int   pTestIdx    = pPredIdx + pResidualIdx + iSDCDeltaResi;
    2136       if( pTestIdx >= 0 && pTestIdx < pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) )
    2137       {
    2138         pResidualIdx += iSDCDeltaResi;
    2139       }
    2140 #else
    2141       pResidualIdx += iSDCDeltaResi;
    2142 #endif
    2143     }
    2144     // save SDC DC offset
    2145     pcCU->setSDCSegmentDCOffset(pResidualIdx, uiSegment, uiAbsPartIdx);
    2146   }
    2147 
    2148   // reconstruct residual based on mask + DC residuals
    2149   Pel apDCResiValues[2];
    2150   for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
    2151   {
    2152 #if NH_3D_DLT
    2153     Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
    2154     Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
    2155     Pel   pRecoValue  = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
    2156 
    2157     apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
    2158 #else
    2159     apDCResiValues[uiSegment]  = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
    2160 #endif
    2161   }
    2162 
    2163   //===== reconstruction =====
    2164   Bool* pMask     = pbMask;
    2165   Pel* pPred      = piPred;
    2166   Pel* pReco      = piReco;
    2167   Pel* pRecIPred  = piRecIPred;
    2168 
    2169   for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    2170   {
    2171     for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    2172     {
    2173       UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
    2174       assert( ucSegment < uiNumSegments );
    2175 
    2176       Pel pResiDC = apDCResiValues[ucSegment];
    2177 
    2178       pReco    [ uiX ] = ClipBD( pPred[ uiX ] + pResiDC, bitDepthY);
    2179       pRecIPred[ uiX ] = pReco[ uiX ];
    2180     }
    2181     pPred     += uiStride;
    2182     pReco     += uiStride;
    2183     pRecIPred += uiRecIPredStride;
    2184     pMask     += uiMaskStride;
    2185   }
    2186 
    2187   // clear chroma
    2188   UInt  uiStrideC     = pcPredYuv->getStride( COMPONENT_Cb );
    2189   Pel   *pRecCb       = pcPredYuv->getAddr  ( COMPONENT_Cb, uiAbsPartIdx );
    2190   Pel   *pRecCr       = pcPredYuv->getAddr  ( COMPONENT_Cr, uiAbsPartIdx );
    2191 
    2192   for (Int y=0; y<uiHeight/2; y++)
    2193   {
    2194     for (Int x=0; x<uiWidth/2; x++)
    2195     {
    2196       pRecCb[x] = 128;
    2197       pRecCr[x] = 128;
    2198     }
    2199 
    2200     pRecCb += uiStrideC;
    2201     pRecCr += uiStrideC;
    2202   }
    2203 
    2204 #if NH_3D_DMM
    2205   if( pbMask ) { delete[] pbMask; }
    2206 #endif
    2207 
    2208   //===== determine distortion ===== 
    2209 #if NH_3D_VSO 
    2210   if( m_pcRdCost->getUseVSO() )
    2211   {
    2212     ruiDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPartIdx, bitDepthY, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, false );
    2213   }
    2214   else
    2215 #endif
    2216   {
    2217     ruiDist = m_pcRdCost->getDistPart( bitDepthY, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, COMPONENT_Y, DF_SAD );
    2218   }
    2219 
    2220   //===== determine rate and r-d cost =====
    2221   m_pcEntropyCoder->resetBits();
    2222 
    2223   // encode reduced intra header
    2224   if( !pcCU->getSlice()->isIntra() )
    2225   {
    2226     if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
    2227     {
    2228       m_pcEntropyCoder->encodeCUTransquantBypassFlag( pcCU, 0, true );
    2229     }
    2230     m_pcEntropyCoder->encodeSkipFlag( pcCU, 0, true );
    2231     m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
    2232   }
    2233 
    2234   m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth( 0 ), true );
    2235 
    2236   // encode pred direction + DC residual data
    2237   m_pcEntropyCoder->encodePredInfo( pcCU, 0 );
    2238   m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
    2239 
    2240   Bool bDummy = false;
    2241   m_pcEntropyCoder->encodeCoeff( pcCU, 0, pcCU->getDepth( 0 ), bDummy, bDummy );
    2242   UInt uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    2243 
    2244 #if NH_3D_VSO
    2245   if ( m_pcRdCost->getUseLambdaScaleVSO())
    2246     dRDCost = m_pcRdCost->calcRdCostVSO( uiBits, ruiDist );
    2247   else
    2248 #endif
    2249     dRDCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
    2250 }
    2251 #endif
    22521729
    22531730
     
    24561933                                      TComYuv*    pcResiYuv,
    24571934                                      Pel         resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE],
    2458 #if NH_3D_VSO
    2459                                       Dist&       ruiDist,
    2460 #else
    24611935                                      Distortion& ruiDist,
    2462 #endif
    24631936                                      TComTU&     rTu
    24641937                                      DEBUG_STRING_FN_DECLARE(sDebug))
     
    25201993        Double     dSingleCost               = MAX_DOUBLE;
    25211994        Int        bestModeId                = 0;
    2522 #if NH_3D_VSO
    2523         Dist       singleDistC               = 0;
    2524 #else
    25251995        Distortion singleDistC               = 0;
    2526 #endif
    25271996        UInt       singleCbfC                = 0;
    2528 #if NH_3D_VSO
    2529         Dist       singleDistCTmp            = 0;
    2530 #else
    25311997        Distortion singleDistCTmp            = 0;
    2532 #endif
    25331998        Double     singleCostTmp             = 0;
    25341999        UInt       singleCbfCTmp             = 0;
     
    27232188}
    27242189
    2725 #if NH_3D_DIS
    2726 Void TEncSearch::estIntraPredDIS( TComDataCU* pcCU,
    2727                                   TComYuv*    pcOrgYuv,
    2728                                   TComYuv*    pcPredYuv,
    2729                                   TComYuv*    pcResiYuv,
    2730                                   TComYuv*    pcRecoYuv,
    2731                                   UInt&       ruiDistC,
    2732                                   Bool        bLumaOnly )
    2733 {
    2734 #if NH_MV
    2735   D_PRINT_INC_INDENT(g_traceModeCheck, "estIntraPredDis");
    2736 #endif
    2737 
    2738   UInt    uiDepth        = pcCU->getDepth(0);
    2739   UInt    uiWidth        = pcCU->getWidth (0);
    2740   UInt    uiHeight       = pcCU->getHeight(0);
    2741 
    2742 #if NH_3D_VSO // M36
    2743   Pel* piOrg         = pcOrgYuv ->getAddr(COMPONENT_Y, 0, uiWidth );
    2744   UInt uiStride      = pcPredYuv->getStride(COMPONENT_Y);
    2745 #endif
    2746   Dist   uiDist = 0;
    2747   Double dCost   = 0.0;
    2748   Dist    uiBestDist = 0;
    2749   Double  dBestCost   = MAX_DOUBLE;
    2750   UInt     uiBestDISType = 0;
    2751 
    2752   for( UInt uiPredMode = 0; uiPredMode < 4 ; uiPredMode++ )
    2753   {
    2754 #if NH_MV
    2755     D_PRINT_INC_INDENT(g_traceModeCheck, "uiPredMode" +  n2s(uiPredMode ) );
    2756 #endif
    2757 
    2758     // set context models
    2759     m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    2760 
    2761     // determine residual for partition
    2762     uiDist = 0;
    2763     dCost   = 0.0;
    2764 #if NH_3D_VSO // M36
    2765     if( m_pcRdCost->getUseRenModel() )
    2766     {
    2767       m_pcRdCost->setRenModelData( pcCU, 0, piOrg, uiStride, uiWidth, uiHeight );
    2768     }
    2769 #endif
    2770     xIntraCodingDIS(pcCU, 0, pcOrgYuv, pcPredYuv, uiDist, dCost, uiPredMode);
    2771     // check r-d cost
    2772     if( dCost < dBestCost )
    2773     {
    2774       uiBestDist = uiDist;
    2775       dBestCost   = dCost;
    2776       uiBestDISType = pcCU->getDISType(0);
    2777       // copy reconstruction
    2778       pcPredYuv->copyPartToPartYuv(pcRecoYuv, 0, uiWidth, uiHeight);
    2779     }
    2780 #if NH_MV
    2781       D_DEC_INDENT( g_traceModeCheck ); 
    2782 #endif
    2783   }
    2784 
    2785 
    2786   pcCU->setDISTypeSubParts((UChar)uiBestDISType, 0, uiDepth); 
    2787 
    2788   //===== reset context models =====
    2789   m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
    2790 
    2791   //===== set distortion (rate and r-d costs are determined later) =====
    2792   pcCU->getTotalDistortion() = uiBestDist;
    2793 #if NH_MV
    2794   D_DEC_INDENT( g_traceModeCheck );
    2795 #endif
    2796 }
    2797 #endif
    27982190
    27992191
     
    28072199                               Pel         resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE]
    28082200                               DEBUG_STRING_FN_DECLARE(sDebug)
    2809 #if NH_3D_ENC_DEPTH
    2810                              , Bool        bOnlyIVP
    2811 #endif
    28122201                              )
    28132202{
     
    28252214  const TComSPS     &sps                   = *(pcCU->getSlice()->getSPS());
    28262215  const TComPPS     &pps                   = *(pcCU->getSlice()->getPPS());
    2827 #if NH_3D_VSO
    2828         Dist         uiOverallDistY        = 0;
    2829 #else
    28302216        Distortion   uiOverallDistY        = 0;
    2831 #endif
    28322217        UInt         CandNum;
    28332218        Double       CandCostList[ FAST_UDI_MAX_RDMODE_NUM ];
     
    28872272    assert (tuRecurseWithPU.ProcessComponentSection(COMPONENT_Y));
    28882273    initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, true DEBUG_STRING_PASS_INTO(sTemp2) );
    2889 #if NH_3D_ENC_DEPTH
    2890     if( bOnlyIVP )
    2891     {
    2892       numModesForFullRD = 0;
    2893     }
    2894     else
    2895     {
    2896 #endif
    28972274
    28982275    Bool doFastSearch = (numModesForFullRD != numModesAvailable);
     
    29172294      m_pcRdCost->setDistParam(distParam, sps.getBitDepth(CHANNEL_TYPE_LUMA), piOrg, uiStride, piPred, uiStride, puRect.width, puRect.height, bUseHadamard);
    29182295
    2919 #if NH_3D
    2920       distParam.bUseIC = false;
    2921 #endif
    2922 #if NH_3D_SDC_INTER
    2923       distParam.bUseSDCMRSAD = false;
    2924 #endif
    29252296      distParam.bApplyWeight = false;
    29262297      for( Int modeIdx = 0; modeIdx < numModesAvailable; modeIdx++ )
    29272298      {
    29282299        UInt       uiMode = modeIdx;
    2929 #if !NH_3D_VSO
    29302300        Distortion uiSad  = 0;
    2931 #endif
    29322301#if NH_MV
    29332302        D_PRINT_INC_INDENT(g_traceModeCheck, "preTest; uiMode " + n2s(uiMode) );
     
    29372306
    29382307        predIntraAng( COMPONENT_Y, uiMode, piOrg, uiStride, piPred, uiStride, tuRecurseWithPU, bUseFilter, TComPrediction::UseDPCMForFirstPassIntraEstimation(tuRecurseWithPU, uiMode) );
    2939 #if NH_3D_VSO // M34
    2940         Dist uiSad;           
    2941         if ( m_pcRdCost->getUseVSO() )
    2942         {
    2943           if ( m_pcRdCost->getUseEstimatedVSD() )
    2944           {         
    2945             uiSad = (Dist) ( m_pcRdCost->getDistPartVSD( pcCU, uiPartOffset, distParam.bitDepth , piPred, uiStride, piOrg, uiStride, distParam.iCols, distParam.iRows, true ) );
    2946           }
    2947           else
    2948           {   
    2949             uiSad = m_pcRdCost->getDistPartVSO( pcCU, uiPartOffset, distParam.bitDepth , piPred, uiStride, piOrg, uiStride, distParam.iCols, distParam.iRows, true );
    2950           }
    2951         }
    2952         else
    2953         {
    2954           uiSad = distParam.DistFunc(&distParam);
    2955         }
    2956 #else       
    29572308        // use hadamard transform here
    29582309        uiSad+=distParam.DistFunc(&distParam);
    2959 #endif
    29602310
    29612311        UInt   iModeBits = 0;
     
    29642314        iModeBits+=xModeBitsIntra( pcCU, uiMode, uiPartOffset, uiDepth, CHANNEL_TYPE_LUMA );
    29652315
    2966 #if NH_3D_VSO // M35
    2967         Double dLambda;
    2968         if ( m_pcRdCost->getUseLambdaScaleVSO() )
    2969         {
    2970           dLambda = m_pcRdCost->getUseRenModel() ? m_pcRdCost->getLambdaVSO() : sqrtLambdaForFirstPass;
    2971         }
    2972         else       
    2973         {
    2974           dLambda = m_pcRdCost->getSqrtLambda();       
    2975         }
    2976 
    2977         Double cost      = (Double)uiSad + (Double)iModeBits * dLambda;
    2978 #else
    29792316        Double cost      = (Double)uiSad + (Double)iModeBits * sqrtLambdaForFirstPass;
    2980 #endif
    29812317
    29822318#if DEBUG_INTRA_SEARCH_COSTS
     
    30222358      }
    30232359    }
    3024 #if NH_3D_ENC_DEPTH
    3025     }
    3026 #endif
    3027 
    3028 #if NH_3D_DMM
    3029     if( m_pcEncCfg->getIsDepth() )
    3030     {
    3031       const TComRectangle &puRect=tuRecurseWithPU.getRect(COMPONENT_Y);
    3032       const UInt uiAbsPartIdx=tuRecurseWithPU.GetAbsPartIdxTU();
    3033 
    3034       Pel* piOrg         = pcOrgYuv ->getAddr( COMPONENT_Y, uiAbsPartIdx );
    3035       Pel* piPred        = pcPredYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
    3036       UInt uiStride      = pcPredYuv->getStride( COMPONENT_Y );
    3037 
    3038       if( puRect.width >= DMM_MIN_SIZE && puRect.width <= DMM_MAX_SIZE &&  puRect.width == puRect.height &&
    3039           ((m_pcEncCfg->getUseDMM() &&  pcCU->getSlice()->getIntraSdcWedgeFlag()) || pcCU->getSlice()->getIntraContourFlag()) )
    3040       {
    3041 #if NH_3D_ENC_DEPTH
    3042         if( bOnlyIVP )
    3043         {
    3044           Bool* dmm4Pattern   = new Bool[ puRect.width*puRect.height ];
    3045           UInt  patternStride = puRect.width;
    3046           predContourFromTex( pcCU, uiPartOffset, puRect.width, puRect.height, dmm4Pattern );
    3047 
    3048           Pel deltaDC1 = 0; Pel deltaDC2 = 0;
    3049           xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, dmm4Pattern, patternStride, puRect.width, puRect.height, deltaDC1, deltaDC2 );
    3050           pcCU->setDmmDeltaDC( DMM4_IDX, 0, uiPartOffset, deltaDC1 );
    3051           pcCU->setDmmDeltaDC( DMM4_IDX, 1, uiPartOffset, deltaDC2 );
    3052 
    3053           uiRdModeList[ numModesForFullRD++ ] = (DMM4_IDX+DMM_OFFSET);
    3054           delete[] dmm4Pattern;
    3055         }
    3056         else
    3057         {
    3058           Int  threshold    = max(((pcCU->getQP(0))>>3)-1,3);
    3059           Int  varThreshold = (Int)( threshold * threshold - 8 );
    3060           UInt varCU        = m_pcRdCost->calcVAR( piOrg, uiStride, puRect.width, puRect.height, pcCU->getDepth(0), pcCU->getSlice()->getSPS()->getMaxCUWidth() );
    3061           if( uiRdModeList[0] != PLANAR_IDX || varCU >= varThreshold )
    3062           {
    3063 #endif
    3064             UInt startIdx = ( m_pcEncCfg->getUseDMM() &&  pcCU->getSlice()->getIntraSdcWedgeFlag() ) ? 0 : 1;
    3065             UInt endIdx   = (                             pcCU->getSlice()->getIntraContourFlag()  ) ? 1 : 0;
    3066             for( UInt dmmType = startIdx; dmmType <= endIdx; dmmType++ )
    3067             {
    3068 #if H_3D_FCO
    3069               if ( !(pcCU->getSlice()->getIvPic(false, pcCU->getSlice()->getViewIndex() )->getReconMark()) && (DMM4_IDX == dmmType ) ) { continue; }
    3070 #endif
    3071               Bool* biSegPattern  = new Bool[ puRect.width*puRect.height ];
    3072               UInt  patternStride = puRect.width;
    3073               Pel deltaDC1 = 0; Pel deltaDC2 = 0;
    3074               switch( dmmType )
    3075               {
    3076               case( DMM1_IDX ):
    3077                 {
    3078                   UInt uiTabIdx = 0;
    3079                   xSearchDmm1Wedge( pcCU, uiPartOffset, piOrg, uiStride, puRect.width, puRect.height, uiTabIdx );
    3080                   pcCU->setDmm1WedgeTabIdxSubParts( uiTabIdx,  uiPartOffset, uiDepth + uiInitTrDepth );
    3081                   (getWedgeListScaled( puRect.width )->at( pcCU->getDmm1WedgeTabIdx( uiAbsPartIdx ) )).getPatternScaledCopy( puRect.width, biSegPattern );
    3082                 } break;
    3083               case( DMM4_IDX ):
    3084                 {
    3085                   predContourFromTex( pcCU, uiPartOffset, puRect.width, puRect.height, biSegPattern );
    3086                 } break;
    3087               default: assert(0);
    3088               }
    3089 
    3090               if( biSegPattern )
    3091               {
    3092                 xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, biSegPattern, patternStride, puRect.width, puRect.height, deltaDC1, deltaDC2 );
    3093                 pcCU->setDmmDeltaDC( (DmmID)dmmType, 0, uiPartOffset, deltaDC1 );
    3094                 pcCU->setDmmDeltaDC( (DmmID)dmmType, 1, uiPartOffset, deltaDC2 );
    3095  
    3096                 uiRdModeList[ numModesForFullRD++ ] = (dmmType+DMM_OFFSET);
    3097                 delete[] biSegPattern;
    3098               }
    3099             }
    3100 #if NH_3D_ENC_DEPTH
    3101           }
    3102         }
    3103 #endif
    3104       }
    3105     }
    3106 #endif
     2360
    31072361
    31082362    //===== check modes (using r-d costs) =====
     
    31132367    DEBUG_STRING_NEW(sPU)
    31142368    UInt       uiBestPUMode  = 0;
    3115 #if NH_3D_ENC_DEPTH
    3116     UInt    uiBestPUModeConv  = 0;
    3117     UInt    uiSecondBestPUModeConv  = 0;
    3118     UInt    uiThirdBestPUModeConv  = 0;
    3119 #endif
    3120 
    3121 #if NH_3D_VSO
    3122     Dist       uiBestPUDistY = 0;
    3123 #else
     2369
    31242370    Distortion uiBestPUDistY = 0;
    3125 #endif
    31262371    Double     dBestPUCost   = MAX_DOUBLE;
    31272372
    3128 #if NH_3D_ENC_DEPTH
    3129     Double  dBestPUCostConv   = MAX_DOUBLE;
    3130     UInt rdSDC = m_pcEncCfg->getIsDepth() ? numModesForFullRD : 0;
    3131 #endif
    3132 #if NH_3D_SDC_INTRA
    3133     Bool    bBestUseSDC   = false;
    3134     Pel     apBestDCOffsets[2] = {0,0};
    3135 #endif
    3136 #if NH_3D_ENC_DEPTH
    3137     for( UInt uiMode = 0; uiMode < numModesForFullRD + rdSDC; uiMode++ )
    3138 #else
    31392373#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
    31402374    UInt max=numModesForFullRD;
     
    31492383#endif
    31502384
    3151 #endif
    31522385    {
    31532386      // set luma prediction mode
    3154 #if !NH_3D_ENC_DEPTH
    31552387      UInt uiOrgMode = uiRdModeList[uiMode];
    3156 #endif
    3157 
    3158 #if NH_3D_ENC_DEPTH
    3159       UInt uiOrgMode;
    3160       if (uiMode < numModesForFullRD)
    3161       {   
    3162         uiOrgMode = uiRdModeList[uiMode];
    3163       }
    3164       else
    3165       {
    3166         const TComRectangle &puRect=tuRecurseWithPU.getRect(COMPONENT_Y);
    3167         const UInt uiAbsPartIdx=tuRecurseWithPU.GetAbsPartIdxTU();
    3168        
    3169         Pel* piOrg         = pcOrgYuv ->getAddr( COMPONENT_Y, uiAbsPartIdx );
    3170         UInt uiStride      = pcPredYuv->getStride( COMPONENT_Y );
    3171        
    3172         UInt varCU      = m_pcRdCost->calcVAR(piOrg, uiStride, puRect.width, puRect.height, pcCU->getDepth(0), pcCU->getSlice()->getSPS()->getMaxCUWidth());
    3173        
    3174         uiOrgMode = uiRdModeList[uiMode - numModesForFullRD];
    3175 
    3176         if (uiBestPUModeConv <= 1 )
    3177         {
    3178           if (uiOrgMode > 1 && varCU < 1) continue;         
    3179         }
    3180         else
    3181         {
    3182           if (uiOrgMode != uiBestPUModeConv && uiOrgMode != uiSecondBestPUModeConv && uiOrgMode != uiThirdBestPUModeConv
    3183             && uiOrgMode > 1 && uiOrgMode < NUM_INTRA_MODE && varCU < 4)
    3184             continue;
    3185         }
    3186       }
    3187 #endif
     2388
    31882389
    31892390#if NH_MV
     
    31932394      pcCU->setIntraDirSubParts ( CHANNEL_TYPE_LUMA, uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
    31942395
    3195 #if NH_3D_SDC_INTRA
    3196 #if NH_3D_ENC_DEPTH
    3197       Bool bTestSDC = ( ( m_pcEncCfg->getUseSDC() &&  pcCU->getSlice()->getIntraSdcWedgeFlag() ) && pcCU->getSDCAvailable(uiPartOffset) && uiMode >= numModesForFullRD);
    3198 #else
    3199       Bool bTestSDC = ( m_pcEncCfg->getUseSDC() && pcCU->getSDCAvailable(uiPartOffset) );
    3200 #endif
    3201 
    3202       for( UInt uiSDC=0; uiSDC<=(bTestSDC?1:0); uiSDC++ )
    3203       {
    3204 #if NH_3D_ENC_DEPTH
    3205         if (!uiSDC && uiMode >= numModesForFullRD) continue;
    3206 #endif
    3207         pcCU->setSDCFlagSubParts( (uiSDC != 0), uiPartOffset, uiDepth + uiInitTrDepth );
    3208         Double dOffsetCost[3] = {MAX_DOUBLE,MAX_DOUBLE,MAX_DOUBLE};
    3209         for( Int iOffset = 1; iOffset <= 5; iOffset++ )
    3210         {
    3211           Int iSDCDeltaResi = 0;
    3212           if(iOffset % 2 == 0)
    3213           {
    3214             iSDCDeltaResi = iOffset >> 1;
    3215           }
    3216           else
    3217           {
    3218             iSDCDeltaResi = -1 * (iOffset >> 1);
    3219           }
    3220           if( ( uiSDC == 0 ) && iSDCDeltaResi != 0 )
    3221           {
    3222             continue;
    3223           }
    3224           if( iOffset > 3)
    3225           {
    3226             if ( dOffsetCost[0] < (0.9*dOffsetCost[1]) && dOffsetCost[0] < (0.9*dOffsetCost[2]) )
    3227             {
    3228               continue;
    3229             }
    3230             if ( dOffsetCost[1] < dOffsetCost[0] && dOffsetCost[0] < dOffsetCost[2] &&  iOffset == 5)
    3231             {
    3232               continue;
    3233             }
    3234             if ( dOffsetCost[0] < dOffsetCost[1] && dOffsetCost[2] < dOffsetCost[0] &&  iOffset == 4)
    3235             {
    3236               continue;
    3237             }
    3238           }
    3239 #endif
    3240 #if NH_3D_ENC_DEPTH
    3241           Bool zeroResiTest = (pcCU->getSlice()->getIsDepth() && !pcCU->getSlice()->isIRAP());
    3242 #if NH_3D_SDC_INTRA
    3243           zeroResiTest = zeroResiTest || pcCU->getSDCFlag(uiPartOffset);
    3244           if( uiSDC != 0 && iSDCDeltaResi != 0 )
    3245           {
    3246             zeroResiTest = false;
    3247           }
    3248 #endif
    3249           for( UInt zeroResi = 0; zeroResi <= ( zeroResiTest ? 1 : 0 ); zeroResi++ )
    3250           {
    3251 #endif
    32522396      DEBUG_STRING_NEW(sMode)
    32532397      // set context models
     
    32552399
    32562400      // determine residual for partition
    3257 #if NH_3D_VSO
    3258       Dist       uiPUDistY = 0;
    3259 #else
    32602401      Distortion uiPUDistY = 0;
    3261 #endif
    32622402      Double     dPUCost   = 0.0;
    3263 #if NH_3D_VSO // M36
    3264       if( m_pcRdCost->getUseRenModel() )
    3265       {
    3266         m_pcRdCost->setRenModelData( pcCU, uiPartOffset, pcOrgYuv, &tuRecurseWithPU );
    3267       }
    3268 #endif
    3269 #if NH_3D_SDC_INTRA
    3270             if( pcCU->getSDCFlag(uiPartOffset) )
    3271             {
    3272               pcCU->setTrIdxSubParts(0, uiPartOffset, uiDepth + uiInitTrDepth);
    3273               pcCU->setCbfSubParts(1, COMPONENT_Y, uiPartOffset, uiDepth + uiInitTrDepth);
    3274 
    3275               // start encoding with SDC
    3276               xIntraCodingSDC(pcCU, uiPartOffset, pcOrgYuv, pcPredYuv, uiPUDistY, dPUCost, ( zeroResi != 0 ), iSDCDeltaResi );
    3277               if ( zeroResi == 0 && iOffset <= 3 )
    3278               {
    3279                 dOffsetCost [iOffset -1] = dPUCost;
    3280               }
    3281             }
    3282             else
    3283             {
    3284 #endif
    32852403
    32862404#if HHI_RQT_INTRA_SPEEDUP
    3287 #if NH_3D_ENC_DEPTH
    3288       xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, true, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode), (zeroResi != 0) );
    3289 #if NH_3D_ENC_DEPTH
    3290               if( dPUCost < dBestPUCostConv )
    3291               {
    3292                 uiThirdBestPUModeConv = uiSecondBestPUModeConv;
    3293                 uiSecondBestPUModeConv = uiBestPUModeConv;
    3294                 uiBestPUModeConv  = uiOrgMode;
    3295                 dBestPUCostConv   = dPUCost;
    3296               }
    3297 #endif
    3298 #else
    32992405      xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, true, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode) );
    3300 #endif
    3301 #else
    3302 #if NH_3D_ENC_DEPTH
    3303       xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode), (zeroResi != 0) );
    33042406#else
    33052407      xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode) );
    3306 #endif
    3307 #endif
    3308 #if NH_3D_SDC_INTRA
    3309             }
    33102408#endif
    33112409
     
    33272425        dBestPUCost   = dPUCost;
    33282426
    3329 #if NH_3D_SDC_INTRA
    3330               if( pcCU->getSDCFlag(uiPartOffset) )
    3331               {
    3332                 bBestUseSDC = true;
    3333 
    3334                 // copy reconstruction
    3335                 UInt uiWidthPU  = tuRecurseWithPU.getRect( COMPONENT_Y ).width;
    3336                 UInt uiHeightPU = tuRecurseWithPU.getRect( COMPONENT_Y ).height;
    3337                 UInt    uiWidth        = pcCU->getWidth (0) >> uiInitTrDepth;
    3338                 UInt    uiHeight       = pcCU->getHeight(0) >> uiInitTrDepth;
    3339                 AOF(uiWidth==uiWidthPU);
    3340                 AOF(uiHeight==uiHeightPU);
    3341                 pcPredYuv->copyPartToPartComponent(COMPONENT_Y, pcRecoYuv, uiPartOffset, uiWidth, uiHeight);
    3342 
    3343                 // copy DC values
    3344                 apBestDCOffsets[0] = pcCU->getSDCSegmentDCOffset(0, uiPartOffset);
    3345                 apBestDCOffsets[1] = pcCU->getSDCSegmentDCOffset(1, uiPartOffset);
    3346               }
    3347               else
    3348               {
    3349                 bBestUseSDC = false;
    3350 #endif
    33512427        xSetIntraResultLumaQT( pcRecoYuv, tuRecurseWithPU );
    33522428
     
    33732449          ::memcpy( m_puhQTTempTransformSkipFlag[compID],  pcCU->getTransformSkip(compID)  + uiPartOffset, uiQPartNum * sizeof( UChar ) );
    33742450        }
    3375 #if NH_3D_SDC_INTRA
    3376         }
    3377 #endif
    33782451      }
    33792452#if HHI_RQT_INTRA_SPEEDUP_MOD
     
    33832456        dSecondBestPUCost = dPUCost;
    33842457      }
    3385 #endif
    3386 #if NH_3D_ENC_DEPTH
    3387           }
    3388 #endif
    3389 #if NH_3D_SDC_INTRA
    3390         } // SDC residual loop
    3391       } // SDC loop
    33922458#endif
    33932459#if NH_MV
     
    34202486
    34212487      pcCU->setIntraDirSubParts ( CHANNEL_TYPE_LUMA, uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
    3422 #if NH_3D_SDC_INTRA
    3423       pcCU->setSDCFlagSubParts(false, uiPartOffset, uiDepth + uiInitTrDepth);
    3424 #endif
    34252488
    34262489      DEBUG_STRING_NEW(sModeTree)
     
    34302493
    34312494      // determine residual for partition
    3432 #if NH_3D_VSO
    3433       Dist       uiPUDistY = 0;
    3434 #else
    34352495      Distortion uiPUDistY = 0;
    3436 #endif
    34372496      Double     dPUCost   = 0.0;
    3438 #if NH_3D_VSO // M37  //check if necessary
    3439       // reset Model
    3440       if( m_pcRdCost->getUseRenModel() )
    3441       {
    3442         m_pcRdCost->setRenModelData( pcCU, uiPartOffset, pcOrgYuv, &tuRecurseWithPU );       
    3443       }
    3444 #endif
    34452497
    34462498      xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, false, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sModeTree));
     
    34532505        uiBestPUDistY = uiPUDistY;
    34542506        dBestPUCost   = dPUCost;
    3455 #if NH_3D_SDC_INTRA
    3456         bBestUseSDC   = false;
    3457 #endif
    34582507
    34592508
     
    34902539    //--- update overall distortion ---
    34912540    uiOverallDistY += uiBestPUDistY;
    3492 #if NH_3D_SDC_INTRA
    3493     if( bBestUseSDC )
    3494     {
    3495       pcCU->setTrIdxSubParts(0, uiPartOffset, uiDepth + uiInitTrDepth);
    3496       pcCU->setCbfSubParts(1, COMPONENT_Y, uiPartOffset, uiDepth + uiInitTrDepth);
    3497 
    3498       //=== copy best DC segment values back to CU ====
    3499       pcCU->setSDCSegmentDCOffset(apBestDCOffsets[0], 0, uiPartOffset);
    3500       pcCU->setSDCSegmentDCOffset(apBestDCOffsets[1], 1, uiPartOffset);
    3501     }
    3502     else
    3503     {
    3504 #endif
    35052541
    35062542    //--- update transform index and cbf ---
     
    35122548      ::memcpy( pcCU->getCbf( compID  ) + uiPartOffset, m_puhQTTempCbf[compID], uiQPartNum * sizeof( UChar ) );
    35132549      ::memcpy( pcCU->getTransformSkip( compID  ) + uiPartOffset, m_puhQTTempTransformSkipFlag[compID ], uiQPartNum * sizeof( UChar ) );
    3514 #if NH_3D_SDC_INTRA
    3515     }
    3516 #endif
    35172550
    35182551    }
     
    35382571        }
    35392572      }
    3540 #if NH_3D_VSO // M38
    3541       // set model
    3542       if( m_pcRdCost->getUseRenModel() )
    3543       {       
    3544         m_pcRdCost->setRenModelData( pcCU, uiPartOffset, pcRecoYuv, &tuRecurseWithPU );
    3545       }
    3546 #endif
    35472573    }
    35482574
    35492575    //=== update PU data ====
    35502576    pcCU->setIntraDirSubParts     ( CHANNEL_TYPE_LUMA, uiBestPUMode, uiPartOffset, uiDepth + uiInitTrDepth );
    3551 #if NH_3D_SDC_INTRA
    3552     pcCU->setSDCFlagSubParts          ( bBestUseSDC, uiPartOffset, uiDepth + uiInitTrDepth );
    3553 #endif
    35542577#if NH_MV
    35552578    D_DEC_INDENT( g_traceModeCheck );
     
    36112634  {
    36122635    UInt       uiBestMode  = 0;
    3613 #if NH_3D_VSO
    3614     Dist       uiBestDist  = 0;
    3615 #else
    36162636    Distortion uiBestDist  = 0;
    3617 #endif
    36182637    Double     dBestCost   = MAX_DOUBLE;
    36192638
     
    36522671          DEBUG_STRING_NEW(sMode)
    36532672          //----- chroma coding -----
    3654 #if NH_3D_VSO
    3655           Dist       uiDist = 0;
    3656 #else
    36572673          Distortion uiDist = 0;
    3658 #endif
    36592674          pcCU->setIntraDirSubParts  ( CHANNEL_TYPE_CHROMA, uiModeList[uiMode], uiPartOffset, uiDepthCU+uiInitTrDepth );
    36602675          xRecurIntraChromaCodingQT       ( pcOrgYuv, pcPredYuv, pcResiYuv, resiLuma, uiDist, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode) );
     
    38322847  uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    38332848
    3834 #if NH_3D_VSO // M43
    3835 
    3836   // GT:  This needs to be checked distortion is not necessarily 0 in case of VSO.
    3837   if( m_pcRdCost->getUseLambdaScaleVSO() ) 
    3838   {
    3839     dCost =  m_pcRdCost->calcRdCostVSO( uiBits, uiDistortion ); 
    3840   }
    3841   else
    3842 #endif
    38432849    dCost = m_pcRdCost->calcRdCost( uiBits, uiDistortion );
    38442850
     
    38742880                            iWidth, iHeight, m_pcEncCfg->getUseHADME() && (pcCU->getCUTransquantBypass(iPartIdx) == 0) );
    38752881
    3876 #if NH_3D_IC
    3877   cDistParam.bUseIC = false;
    3878 #endif
    3879 #if NH_3D_SDC_INTER
    3880   cDistParam.bUseSDCMRSAD = false;
    3881 #endif
    38822882
    38832883  ruiErr = cDistParam.DistFunc( &cDistParam );
     
    38862886//! estimation of best merge coding
    38872887Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, Distortion& ruiCost, TComMvField* cMvFieldNeighbours, UChar* uhInterDirNeighbours, Int& numValidMergeCand
    3888 #if NH_3D_VSP
    3889                                  , Int* vspFlag
    3890 #endif
    3891 #if NH_3D_SPIVMP
    3892                                  , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    3893 #endif
    38942888)
    38952889{
     
    39052899  UInt uiDepth = pcCU->getDepth( uiAbsPartIdx );
    39062900
    3907 #if NH_3D_DBBP
    3908   DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
    3909   if( pcCU->getDBBPFlag(0) )
    3910   {
    3911     AOF( uiAbsPartIdx == 0 );
    3912     AOF( iPUIdx == 0 );
    3913     AOF( pcCU->getPartitionSize(0) == SIZE_2Nx2N );
    3914     AOF( pDBBPTmpData->eVirtualPartSize != NUMBER_OF_PART_SIZES );
    3915    
    3916     // temporary change of partition size for candidate derivation
    3917     pcCU->setPartSizeSubParts( pDBBPTmpData->eVirtualPartSize, 0, pcCU->getDepth(0));
    3918     iPUIdx = pcCU->getDBBPTmpData()->uiVirtualPartIndex;
    3919    
    3920     // if this is handling the second segment, make sure that motion info of first segment is available
    3921     if( iPUIdx == 1 )
    3922     {
    3923       pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[0], 0, 0, pcCU->getDepth(0)); // interprets depth relative to LCU level
    3924      
    3925       for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    3926       {
    3927         RefPicList eRefList = (RefPicList)uiRefListIdx;
    3928        
    3929         pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[0][eRefList], pDBBPTmpData->eVirtualPartSize, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
    3930       }
    3931     }
    3932    
    3933     // update these values to virtual partition size
    3934     pcCU->getPartIndexAndSize( iPUIdx, uiAbsPartIdx, iWidth, iHeight );
    3935   }
    3936 #endif
    39372901
    39382902  PartSize partSize = pcCU->getPartitionSize( 0 );
    3939 #if NH_3D_DBBP
    3940   if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && partSize != SIZE_2Nx2N && pcCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(0) == false )
    3941 #else
    39422903  if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && partSize != SIZE_2Nx2N && pcCU->getWidth( 0 ) <= 8 )
    3943 #endif
    39442904  {
    39452905    if ( iPUIdx == 0 )
    39462906    {
    39472907      pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set
    3948 #if NH_3D_MLC
    3949       pcCU->initAvailableFlags();
    39502908      pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
    3951       pcCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
    3952 #if NH_3D_SPIVMP
    3953         , pcMvFieldSP, puhInterDirSP
    3954 #endif
    3955         , numValidMergeCand
    3956         );
    3957 
    3958       pcCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours
    3959 #if NH_3D_VSP
    3960         , vspFlag
    3961 #endif
    3962 #if NH_3D_SPIVMP
    3963         , pbSPIVMPFlag
    3964 #endif
    3965         , numValidMergeCand
    3966         );
    3967 #else
    3968       pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
    3969 #endif
    39702909      pcCU->setPartSizeSubParts( partSize, 0, uiDepth ); // restore
    39712910    }
     
    39732912  else
    39742913  {
    3975 #if NH_3D_MLC
    3976     pcCU->initAvailableFlags();
    39772914    pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    3978     pcCU->xGetInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours
    3979 #if NH_3D_SPIVMP
    3980       , pcMvFieldSP, puhInterDirSP
    3981 #endif
    3982       , numValidMergeCand
    3983       );
    3984 
    3985     pcCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
    3986 #if NH_3D_VSP
    3987       , vspFlag
    3988 #endif
    3989 #if NH_3D_SPIVMP
    3990       , pbSPIVMPFlag
    3991 #endif
    3992       , numValidMergeCand
    3993       );
    3994 #else
    3995     pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    3996 #endif
    39972915  }
    39982916
    39992917  xRestrictBipredMergeCand( pcCU, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    40002918
    4001 #if NH_3D_DBBP
    4002   if( pcCU->getDBBPFlag(0) )
    4003   {
    4004     // reset to 2Nx2N for actual motion search
    4005     iPUIdx = 0;
    4006     AOF( pcCU->getPartitionSize(0) == pDBBPTmpData->eVirtualPartSize );
    4007     pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, pcCU->getDepth(0));
    4008    
    4009     // restore values for 2Nx2N partition size
    4010     pcCU->getPartIndexAndSize( iPUIdx, uiAbsPartIdx, iWidth, iHeight );
    4011    
    4012     AOF( uiAbsPartIdx == 0 );
    4013     AOF( iWidth == iHeight );
    4014   }
    4015 #endif
    40162919
    40172920  ruiCost = std::numeric_limits<Distortion>::max();
     
    40252928
    40262929    PartSize ePartSize = pcCU->getPartitionSize( 0 );
    4027 #if NH_3D_VSP
    4028     pcCU->setVSPFlagSubParts( vspFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
    4029 #endif
    4030 
    4031 #if NH_3D_SPIVMP
    4032     pcCU->setSPIVMPFlagSubParts( pbSPIVMPFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ));
    4033     if (pbSPIVMPFlag[uiMergeCand])
    4034     {
    4035       UInt uiSPAddr;
    4036 
    4037       Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    4038 
    4039       pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    4040 
    4041       for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    4042       {
    4043         pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
    4044         pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
    4045         pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
    4046       }
    4047     }
    4048     else
    4049 #endif
    4050 #if NH_3D_VSP
    4051 #if NH_3D_DBBP
    4052       if ( vspFlag[uiMergeCand] && !pcCU->getDBBPFlag(0) )
    4053 #else
    4054       if ( vspFlag[uiMergeCand] )
    4055 #endif
    4056       {
    4057         UInt partAddr;
    4058         Int vspSize;
    4059         Int width, height;
    4060         pcCU->getPartIndexAndSize( iPUIdx, partAddr, width, height );
    4061 
    4062         if( uhInterDirNeighbours[ uiMergeCand ] & 0x01 )
    4063         {
    4064           pcCU->setMvFieldPUForVSP( pcCU, partAddr, width, height, REF_PIC_LIST_0, cMvFieldNeighbours[ 2*uiMergeCand + 0 ].getRefIdx(), vspSize );
    4065           pcCU->setVSPFlag( partAddr, vspSize );
    4066         }
    4067         else
    4068         {
    4069           pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    4070         }
    4071         if( uhInterDirNeighbours[ uiMergeCand ] & 0x02 )
    4072         {
    4073           pcCU->setMvFieldPUForVSP( pcCU, partAddr, width, height, REF_PIC_LIST_1, cMvFieldNeighbours[ 2*uiMergeCand + 1 ].getRefIdx(), vspSize );
    4074           pcCU->setVSPFlag( partAddr, vspSize );
    4075         }
    4076         else
    4077         {
    4078           pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    4079         }
    4080       }
    4081       else
    4082       {
    4083 #endif
     2930
    40842931
    40852932    pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    40862933    pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    4087 #if NH_3D_VSP
    4088       }
    4089 #endif
    40902934
    40912935
     
    41442988//! search of the best candidate for inter prediction
    41452989#if AMP_MRG
    4146 #if  NH_3D_FAST_TEXTURE_ENCODING
    4147 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv, TComYuv* pcRecoYuv DEBUG_STRING_FN_DECLARE(sDebug), Bool bFMD, Bool bUseRes, Bool bUseMRG )
    4148 #else
    41492990Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv, TComYuv* pcRecoYuv DEBUG_STRING_FN_DECLARE(sDebug), Bool bUseRes, Bool bUseMRG )
    4150 #endif
    41512991#else
    41522992Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv, TComYuv* pcRecoYuv, Bool bUseRes )
     
    42123052  Distortion   biPDistTemp = std::numeric_limits<Distortion>::max();
    42133053
    4214 #if NH_3D_IV_MERGE
    4215   TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    4216   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
    4217 #else
    42183054  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
    42193055  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    4220 #endif
    42213056
    42223057  Int numValidMergeCand = 0 ;
     
    42513086
    42523087    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    4253 #if NH_3D_VSP
    4254     pcCU->setVSPFlagSubParts( 0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr) );
    4255 #endif
    42563088
    42573089#if AMP_MRG
    42583090    Bool bTestNormalMC = true;
    4259 #if  NH_3D_FAST_TEXTURE_ENCODING
    4260     if (bFMD||( bUseMRG && pcCU->getWidth( 0 ) > 8 && iNumPart == 2 ))
    4261 #else           
    42623091    if ( bUseMRG && pcCU->getWidth( 0 ) > 8 && iNumPart == 2 )
    4263 #endif
    42643092
    42653093    {
     
    46083436    } // end if bTestNormalMC
    46093437#endif
    4610 #if NH_3D_DBBP
    4611     // test merge mode for DBBP (2Nx2N)
    4612     if ( pcCU->getPartitionSize( uiPartAddr ) != SIZE_2Nx2N || pcCU->getDBBPFlag(0) )
    4613 #else
    46143438    if ( pcCU->getPartitionSize( uiPartAddr ) != SIZE_2Nx2N )
    4615 #endif
    46163439    {
    46173440      UInt uiMRGInterDir = 0;
     
    46513474      Distortion uiMRGCost = std::numeric_limits<Distortion>::max();
    46523475
    4653 #if NH_3D_VSP
    4654       Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    4655       memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    4656       UInt uiAbsPartIdx = 0;
    4657       Int iWidth = 0;
    4658       Int iHeight = 0;
    4659       pcCU->getPartIndexAndSize( iPartIdx, uiAbsPartIdx, iWidth, iHeight );
    4660       DisInfo OriginalDvInfo = pcCU->getDvInfo(uiAbsPartIdx);
    4661 #endif
    4662 #if NH_3D_SPIVMP
    4663       Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
    4664       memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    4665       TComMvField*  pcMvFieldSP;
    4666       UChar* puhInterDirSP;
    4667       pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2];
    4668       puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()];
    4669 #endif
    46703476      xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand
    4671 #if NH_3D_VSP
    4672                       , vspFlag
    4673 #endif
    4674 #if NH_3D_SPIVMP
    4675                       , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
    4676 #endif
    46773477                      );
    46783478
     
    46823482        pcCU->setMergeFlagSubParts ( true,          uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    46833483        pcCU->setMergeIndexSubParts( uiMRGIndex,    uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4684 #if NH_3D_VSP
    4685         pcCU->setVSPFlagSubParts( vspFlag[uiMRGIndex], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4686 #endif
    4687 #if NH_3D_SPIVMP
    4688         pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMRGIndex], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 
    4689         if (bSPIVMPFlag[uiMRGIndex]!=0)
    4690         {
    4691           UInt uiSPAddr;
    4692           Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    4693           pcCU->getSPPara(iRoiWidth, iRoiHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    4694           for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    4695           {
    4696             pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
    4697             pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
    4698             pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
    4699             pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
    4700           }
    4701           if ( pcCU->getInterDir(uiPartAddr) == 3 && pcCU->isBipredRestriction(iPartIdx) )
    4702           {
    4703             pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiPartAddr, 0, iPartIdx);
    4704             pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiPartAddr, 0, iPartIdx);
    4705             pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ));
    4706           }
    4707         }
    4708         else
    4709 #endif
    4710 #if NH_3D_VSP
    4711 #if NH_3D_DBBP
    4712         if ( vspFlag[uiMRGIndex] && !pcCU->getDBBPFlag(uiPartAddr) )
    4713 #else
    4714         if ( vspFlag[uiMRGIndex] )
    4715 #endif
    4716         {
    4717           UInt partAddrTemp;
    4718           Int vspSize;
    4719           Int width, height;
    4720           pcCU->getPartIndexAndSize( iPartIdx, partAddrTemp, width, height ); // true or pcCU->getTotalNumPart()==256
    4721           if( uiMRGInterDir & 0x01 )
    4722           {
    4723             pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_0, cMRGMvField[0].getRefIdx(), vspSize );
    4724             pcCU->setVSPFlag( partAddrTemp, vspSize );
    4725           }
    4726           else
    4727           {
    4728             pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
    4729           }
    4730           if( uiMRGInterDir & 0x02 )
    4731           {
    4732             pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_1, cMRGMvField[1].getRefIdx(), vspSize );
    4733             pcCU->setVSPFlag( partAddrTemp, vspSize );
    4734           }
    4735           else
    4736           {
    4737             pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    4738           }
    4739           pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4740         }
    4741         else
    4742           {
    4743 #endif
    47443484        pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    47453485        pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
    47463486        pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    4747 #if NH_3D_VSP
    4748           }
    4749 #endif
    4750 #if H_3D
    4751           }
    4752 #endif
    47533487        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
    47543488        pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
     
    47613495      else
    47623496      {
    4763 #if NH_3D_SPIVMP       
    4764         pcCU->setSPIVMPFlagSubParts(0, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4765 #endif
    47663497        // set ME result
    47673498        pcCU->setMergeFlagSubParts( false,        uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    47683499        pcCU->setInterDirSubParts ( uiMEInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4769 #if NH_3D_VSP
    4770         pcCU->setVSPFlagSubParts ( 0,             uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4771         pcCU->setDvInfoSubParts(OriginalDvInfo, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4772 #endif
    47733500        pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMEMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
    47743501        pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMEMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    47753502      }
    4776 #if NH_3D_SPIVMP
    4777       delete[] pcMvFieldSP;
    4778       delete[] puhInterDirSP;
    4779 #endif
    47803503    }
    47813504
     
    48193542  {
    48203543
    4821 #if NH_3D_DBBP
    4822     DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
    4823     if( pcCU->getDBBPFlag(0) )
    4824     {
    4825       AOF( uiPartAddr == 0 );
    4826       AOF( uiPartIdx == 0 );
    4827       AOF( pcCU->getPartitionSize(0) == SIZE_2Nx2N );
    4828       AOF( pDBBPTmpData->eVirtualPartSize != NUMBER_OF_PART_SIZES );
    4829       AOF( iRoiWidth == iRoiHeight );
    4830      
    4831       // temporary change of partition size for candidate derivation
    4832       pcCU->setPartSizeSubParts( pDBBPTmpData->eVirtualPartSize, 0, pcCU->getDepth(0));
    4833       uiPartIdx = pcCU->getDBBPTmpData()->uiVirtualPartIndex;
    4834      
    4835       // if this is handling the second segment, make sure that motion info of first segment is set to first segment
    4836       if( uiPartIdx == 1 )
    4837       {
    4838         pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[0], 0, 0, pcCU->getDepth(0)); // interprets depth relative to LCU level
    4839        
    4840         for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    4841         {
    4842           RefPicList eRefList = (RefPicList)uiRefListIdx;
    4843           pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[0][eRefList], pDBBPTmpData->eVirtualPartSize, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
    4844         }
    4845       }
    4846      
    4847       // update values to virtual partition size
    4848       pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    4849     }
    4850 #endif
    48513544
    48523545    pcCU->fillMvpCand( uiPartIdx, uiPartAddr, eRefPicList, iRefIdx, pcAMVPInfo );
    4853 #if NH_3D_DBBP
    4854     if( pcCU->getDBBPFlag(0) )
    4855     {
    4856       // restore 2Nx2N partitioning for motion estimation
    4857       uiPartIdx = 0;
    4858       AOF( pcCU->getPartitionSize(0) == pDBBPTmpData->eVirtualPartSize );
    4859       pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, pcCU->getDepth(0));
    4860      
    4861       // restore values for 2Nx2N partition size
    4862       pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    4863       AOF(uiPartAddr==0);
    4864     }
    4865 #endif
    48663546
    48673547  }
     
    50933773  pcCU->clipMv( cMvCand );
    50943774
    5095 #if NH_3D_IC
    5096   Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getViewIndex() != pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() );
    5097 #endif
    50983775
    50993776  // prediction pattern
     
    51013778  {
    51023779    xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA)
    5103 #if NH_3D_ARP
    5104       , false //add this for IC, otherwise, it could be removed
    5105 #endif
    51063780      );
    51073781  }
     
    51093783  {
    51103784    xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, false, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA)
    5111 #if NH_3D_ARP
    5112       , false
    5113 #endif
    5114 #if NH_3D_IC
    5115     , bICFlag
    5116 #endif
    51173785
    51183786);
     
    51613829  pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    51623830
    5163 #if NH_3D_IC
    5164   Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getViewIndex() != pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->getViewIndex() );
    5165   pcPatternKey->setICFlag( bICFlag );
    5166 #endif
    5167 #if NH_3D_SDC_INTER
    5168    pcPatternKey->setSDCMRSADFlag( pcCU->getSlice()->getInterSdcFlag() );
    5169 #endif
    51703831
    51713832  if ( bBi ) // Bipredictive ME
     
    52093870
    52103871  m_pcRdCost->setPredictor  ( *pcMvPred );
    5211 #if NH_3D_INTEGER_MV_DEPTH
    5212   if( pcCU->getSlice()->getIsDepth() )
    5213   {
    5214     m_pcRdCost->setCostScale  ( 0 );
    5215   }
    5216   else
    5217   {
    5218 #endif
    52193872    m_pcRdCost->setCostScale  ( 2 );   
    5220 #if NH_3D_INTEGER_MV_DEPTH
    5221   }
    5222 #endif
    52233873
    52243874
     
    52453895
    52463896  m_pcRdCost->selectMotionLambda( true, 0, pcCU->getCUTransquantBypass(uiPartAddr) );
    5247 #if NH_3D_INTEGER_MV_DEPTH
    5248   if( ! pcCU->getSlice()->getIsDepth() )
    5249   {
    5250 #endif
    52513897  m_pcRdCost->setCostScale ( 1 );
    52523898
     
    52583904  rcMv += (cMvHalf <<= 1);
    52593905  rcMv +=  cMvQter;
    5260 #if NH_3D_INTEGER_MV_DEPTH
    5261   }
    5262 #endif
    52633906
    52643907  UInt uiMvBits = m_pcRdCost->getBitsOfVectorWithPredictor( rcMv.getHor(), rcMv.getVer() );
    5265 #if NH_3D_INTEGER_MV_DEPTH
    5266   if( pcCU->getSlice()->getIsDepth() )
    5267   {
    5268     ruiCost += m_pcRdCost->getCost( uiMvBits );
    5269   }
    5270 #endif
    52713908  ruiBits      += uiMvBits;
    52723909  ruiCost       = (Distortion)( floor( fWeight * ( (Double)ruiCost - (Double)m_pcRdCost->getCost( uiMvBits ) ) ) + (Double)m_pcRdCost->getCost( ruiBits ) );
     
    52833920{
    52843921  Int  iMvShift = 2;
    5285 #if NH_3D_INTEGER_MV_DEPTH
    5286   if( pcCU->getSlice()->getIsDepth() )
    5287   {
    5288     iMvShift = 0;
    5289   }
    5290 #endif
    52913922  TComMv cTmpMvPred = cMvPred;
    52923923  pcCU->clipMv( cTmpMvPred );
     
    53643995      m_cDistParam.bitDepth = pcPatternKey->getBitDepthY();
    53653996
    5366 #if NH_3D_IC
    5367       m_cDistParam.bUseIC = pcPatternKey->getICFlag();
    5368 #endif
    5369 #if NH_3D_SDC_INTER
    5370       m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
    5371 #endif
    53723997
    53733998      uiSad = m_cDistParam.DistFunc( &m_cDistParam );
     
    54704095  UInt uiSearchRange = m_iSearchRange;
    54714096  pcCU->clipMv( rcMv );
    5472 #if NH_3D_INTEGER_MV_DEPTH
    5473   if( ! pcCU->getSlice()->getIsDepth() )
    5474 #endif
    54754097#if ME_ENABLE_ROUNDING_OF_MVS
    54764098  rcMv.divideByPowerOf2(2);
     
    54954117      TComMv cMv = m_acMvPredictors[index];
    54964118      pcCU->clipMv( cMv );
    5497 #if NH_3D_INTEGER_MV_DEPTH
    5498       if( ! pcCU->getSlice()->getIsDepth() )
    5499       {     
    5500 #endif
    55014119#if ME_ENABLE_ROUNDING_OF_MVS
    55024120      cMv.divideByPowerOf2(2);
     
    55054123#endif
    55064124
    5507 #if NH_3D_INTEGER_MV_DEPTH
    5508       }
    5509 #endif
    55104125      if (cMv != rcMv && (cMv.getHor() != cStruct.iBestX && cMv.getVer() != cStruct.iBestY))
    55114126      {
     
    59934608
    59944609    pcYuvPred->copyToPartYuv( pcYuvRec, 0 );
    5995 #if NH_3D_VSO
    5996     Dist       distortion = 0;
    5997 #else
    59984610    Distortion distortion = 0;
    5999 #endif
    60004611
    60014612    for (Int comp=0; comp < numValidComponents; comp++)
     
    60044615      const UInt csx=pcYuvOrg->getComponentScaleX(compID);
    60054616      const UInt csy=pcYuvOrg->getComponentScaleY(compID);
    6006 #if NH_3D_VSO // M13
    6007       if ( m_pcRdCost->getUseVSO() )
    6008       {
    6009         distortion += m_pcRdCost->getDistPartVSO( pcCU, 0, sps.getBitDepth(toChannelType(compID)), pcYuvRec->getAddr(compID), pcYuvRec->getStride(compID), pcYuvOrg->getAddr(compID),
    6010           pcYuvOrg->getStride(compID), cuWidthPixels >> csx, cuHeightPixels >> csy, false );
    6011       }
    6012       else   
    6013       {
    6014 #endif
    60154617        distortion += m_pcRdCost->getDistPart( sps.getBitDepth(toChannelType(compID)), pcYuvRec->getAddr(compID), pcYuvRec->getStride(compID), pcYuvOrg->getAddr(compID),
    60164618          pcYuvOrg->getStride(compID), cuWidthPixels >> csx, cuHeightPixels >> csy, compID);
    6017 #if NH_3D_VSO // MIgnore
    6018       }
    6019 #endif
    60204619    }
    60214620    m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST]);
     
    60294628    m_pcEntropyCoder->encodeSkipFlag(pcCU, 0, true);
    60304629    m_pcEntropyCoder->encodeMergeIndex( pcCU, 0, true );
    6031 #if NH_3D_ARP
    6032     m_pcEntropyCoder->encodeARPW( pcCU, 0 );
    6033 #endif
    6034 #if NH_3D_IC
    6035     m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
    6036 #endif
    60374630    UInt uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    60384631    pcCU->getTotalBits()       = uiBits;
    60394632    pcCU->getTotalDistortion() = distortion;
    6040 #if NH_3D_VSO //M 14
    6041     if ( m_pcRdCost->getUseLambdaScaleVSO() )   
    6042     {
    6043       pcCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( uiBits, distortion );   
    6044     }
    6045     else
    6046 #endif   
    60474633      pcCU->getTotalCost()       = m_pcRdCost->calcRdCost( uiBits, distortion );
    60484634
     
    60574643#endif
    60584644
    6059 #if NH_3D_VSO // necessary? // M15
    6060     // set Model
    6061     if( !m_pcRdCost->getUseEstimatedVSD() && m_pcRdCost->getUseRenModel() )
    6062     {     
    6063       const UInt csx    = pcYuvRec->getComponentScaleX( COMPONENT_Y );
    6064       const UInt csy    = pcYuvRec->getComponentScaleY( COMPONENT_Y );
    6065 
    6066       Pel*  piSrc       = pcYuvRec->getAddr  ( COMPONENT_Y );
    6067       UInt  uiSrcStride = pcYuvRec->getStride( COMPONENT_Y );
    6068       m_pcRdCost->setRenModelData( pcCU, 0, piSrc, uiSrcStride, cuWidthPixels >> csx, cuHeightPixels >> csy);
    6069     }
    6070 #endif
    60714645#if NH_MV
    60724646    D_DEC_INDENT( g_traceModeCheck );
     
    60844658  Double     nonZeroCost       = 0;
    60854659  UInt       nonZeroBits       = 0;
    6086 #if NH_3D_VSO
    6087   Dist       nonZeroDistortion = 0;
    6088   Dist       zeroDistortion    = 0;
    6089 #else
    60904660  Distortion nonZeroDistortion = 0;
    60914661  Distortion zeroDistortion    = 0;
    6092 #endif
    60934662
    60944663  m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_CURR_BEST ] );
    6095 #if NH_3D_VSO // M16 // M18 
    6096   if ( m_pcRdCost->getUseVSO() )  // This creating and destroying need to be fixed.
    6097   {
    6098     m_cYuvRecTemp.create( pcYuvPred->getWidth( COMPONENT_Y ), pcYuvPred->getHeight( COMPONENT_Y ), CHROMA_400  );
    6099   }
    6100 
    6101 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC
    6102   Bool oldTraceRDCost = g_traceRDCost;     
    6103   g_traceRDCost = false;
    6104 
    6105   Bool oldTraceModeCheck = g_traceModeCheck;
    6106   g_traceModeCheck = false;
    6107 
    6108   Bool oldTraceFracBits = g_traceEncFracBits;
    6109   g_traceEncFracBits = false;
    6110  
    6111 #endif
    6112   xEstimateInterResidualQT( pcYuvResi,  pcYuvOrg, pcYuvPred, nonZeroCost, nonZeroBits, nonZeroDistortion, &zeroDistortion, tuLevel0 DEBUG_STRING_PASS_INTO(sDebug) );   
    6113 
    6114 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC
    6115   g_traceRDCost = oldTraceRDCost;
    6116   g_traceEncFracBits = oldTraceFracBits;
    6117   g_traceModeCheck = oldTraceModeCheck;
    6118 #endif
    6119 
    6120   if ( m_pcRdCost->getUseVSO() )
    6121   {
    6122     m_cYuvRecTemp.destroy();
    6123   }
    6124 #else
    61254664  xEstimateInterResidualQT( pcYuvResi,  nonZeroCost, nonZeroBits, nonZeroDistortion, &zeroDistortion, tuLevel0 DEBUG_STRING_PASS_INTO(sDebug) );
    6126 #endif
    61274665  // -------------------------------------------------------
    61284666  // set the coefficients in the pcCU, and also calculates the residual data.
     
    61334671  m_pcEntropyCoder->encodeQtRootCbfZero( );
    61344672  const UInt   zeroResiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    6135 #if NH_3D_VSO  // M19
    6136     Double zeroCost;
    6137     if( m_pcRdCost->getUseLambdaScaleVSO() )   
    6138     {
    6139       zeroCost = (pcCU->isLosslessCoded( 0 )) ? (nonZeroCost+1) : (m_pcRdCost->calcRdCostVSO( zeroResiBits, zeroDistortion ));
    6140     }
    6141     else
    6142     {
    6143       zeroCost = (pcCU->isLosslessCoded( 0 )) ? (nonZeroCost+1) : (m_pcRdCost->calcRdCost( zeroResiBits, zeroDistortion ));
    6144     }
    6145 #else
    61464673  const Double zeroCost     = (pcCU->isLosslessCoded( 0 )) ? (nonZeroCost+1) : (m_pcRdCost->calcRdCost( zeroResiBits, zeroDistortion ));
    6147 #endif
    6148 #if NH_3D_SPIVMP
    6149     if ( zeroCost < nonZeroCost || pcCU->getQtRootCbf(0)==0)
    6150 #else
    61514674  if ( zeroCost < nonZeroCost || !pcCU->getQtRootCbf(0) )
    6152 #endif
    61534675  {
    61544676    const UInt uiQPartNum = tuLevel0.GetAbsPartIdxNumParts();
     
    61964718  // update with clipped distortion and cost (previously unclipped reconstruction values were used)
    61974719
    6198 #if NH_3D_VSO
    6199   Dist finalDistortion = 0;
    6200 #else
    62014720  Distortion finalDistortion = 0;
    6202 #endif
    62034721  for(Int comp=0; comp<numValidComponents; comp++)
    62044722  { 
    62054723    const ComponentID compID=ComponentID(comp);
    6206 #if NH_3D_VSO    // M22 // GT: might be removed since VSO already provided clipped distortion
    6207     if ( m_pcRdCost->getUseVSO() )
    6208     {
    6209       finalDistortion += m_pcRdCost->getDistPartVSO  ( pcCU, 0, sps.getBitDepth(toChannelType(compID)),  pcYuvRec->getAddr( compID ), pcYuvRec->getStride( compID ),  pcYuvOrg->getAddr( compID ), pcYuvOrg->getStride( compID ), cuWidthPixels >> pcYuvOrg->getComponentScaleX(compID), cuHeightPixels >> pcYuvOrg->getComponentScaleY(compID), false );
    6210     }
    6211     else
    6212     {
    6213 #endif     
    62144724      finalDistortion += m_pcRdCost->getDistPart( sps.getBitDepth(toChannelType(compID)), pcYuvRec->getAddr(compID ), pcYuvRec->getStride(compID ), pcYuvOrg->getAddr(compID ), pcYuvOrg->getStride(compID), cuWidthPixels >> pcYuvOrg->getComponentScaleX(compID), cuHeightPixels >> pcYuvOrg->getComponentScaleY(compID), compID);
    6215 #if NH_3D_VSO // M23
    6216     }
    6217 #endif
    62184725  }
    62194726
    62204727  pcCU->getTotalBits()       = finalBits;
    62214728  pcCU->getTotalDistortion() = finalDistortion;
    6222 #if NH_3D_VSO
    6223   if ( m_pcRdCost->getUseLambdaScaleVSO() )
    6224   {
    6225     pcCU->getTotalCost()       = m_pcRdCost->calcRdCostVSO( finalBits, finalDistortion );
    6226   }
    6227   else
    6228 #endif
    62294729    pcCU->getTotalCost()       = m_pcRdCost->calcRdCost( finalBits, finalDistortion );
    62304730
    6231 #if NH_3D_VSO // M24 // necessary??
    6232   if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() )
    6233   {
    6234     Pel*  piSrc       = pcYuvRec->getAddr  ( COMPONENT_Y );
    6235     UInt  uiSrcStride = pcYuvRec->getStride( COMPONENT_Y );
    6236     m_pcRdCost->setRenModelData( pcCU, 0, piSrc, uiSrcStride, cuWidthPixels >> pcYuvOrg->getComponentScaleX(COMPONENT_Y), cuHeightPixels >> pcYuvOrg->getComponentScaleY(COMPONENT_Y));
    6237   }
    6238 #endif
    62394731#if NH_MV
    62404732  D_DEC_INDENT( g_traceModeCheck );
     
    62424734}
    62434735
    6244 #if NH_3D_SDC_INTER
    6245 Void TEncSearch::encodeResAndCalcRdInterSDCCU( TComDataCU* pcCU, TComYuv* pcOrg, TComYuv* pcPred, TComYuv* pcResi, TComYuv* pcRec, Int uiOffest, const UInt uiDepth )
    6246 {
    6247   if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( 0 ) )
    6248   {
    6249     return;
    6250   }
    6251   pcCU->setSDCFlagSubParts( true, 0, uiDepth );
    6252 
    6253   UInt  uiWidth   = pcCU->getWidth ( 0 );
    6254   UInt  uiHeight  = pcCU->getHeight( 0 );
    6255   UInt  uiSegSize = 0;
    6256 
    6257   Pel *pPred, *pOrg;
    6258   UInt uiPredStride = pcPred->getStride( COMPONENT_Y );
    6259   UInt uiOrgStride  = pcOrg->getStride( COMPONENT_Y );
    6260   UInt uiPelX, uiPelY;
    6261 
    6262   pPred = pcPred->getAddr( COMPONENT_Y );
    6263   pOrg  = pcOrg->getAddr( COMPONENT_Y );
    6264   Int pResDC = 0;
    6265   Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
    6266   Int bitDepthC = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA);
    6267 
    6268   //calculate dc value for prediction and original signal, and calculate residual and reconstruction
    6269   for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
    6270   {
    6271     for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
    6272     {
    6273       pResDC += (Int)( pOrg [uiPelX] - pPred[uiPelX] );
    6274       uiSegSize++;
    6275     }
    6276     pOrg  += uiOrgStride;
    6277     pPred += uiPredStride;
    6278   }
    6279 
    6280   Int iResiOffset = ( pResDC  > 0 ? ( uiSegSize >> 1 ) : -1*( uiSegSize >> 1 ) );
    6281   pResDC          = ( pResDC + iResiOffset ) / (Int) uiSegSize;
    6282 
    6283   pcCU->setSDCSegmentDCOffset( pResDC + uiOffest, 0, 0 );
    6284 
    6285 
    6286   Pel *pRec;
    6287   UInt uiRecStride  = pcRec->getStride( COMPONENT_Y );
    6288   pPred = pcPred->getAddr( COMPONENT_Y );
    6289   pRec  = pcRec->getAddr( COMPONENT_Y );
    6290 
    6291   for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
    6292   {
    6293     for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
    6294     {
    6295       pRec[ uiPelX ] = Clip3( 0, (1 << bitDepthY) - 1, pPred[uiPelX] + pcCU->getSDCSegmentDCOffset(0, 0) );
    6296     }
    6297     pPred     += uiPredStride;
    6298     pRec      += uiRecStride;
    6299   }
    6300 
    6301   // clear UV
    6302   UInt  uiStrideC     = pcRec->getStride( COMPONENT_Cb );
    6303   Pel   *pRecCb       = pcRec->getAddr( COMPONENT_Cb );
    6304   Pel   *pRecCr       = pcRec->getAddr( COMPONENT_Cr );
    6305 
    6306   for (Int y=0; y < uiHeight/2; y++)
    6307   {
    6308     for (Int x=0; x < uiWidth/2; x++)
    6309     {
    6310       pRecCb[x] = (Pel)( 1 << ( bitDepthC - 1 ) );
    6311       pRecCr[x] = (Pel)( 1 << ( bitDepthC - 1 ) );
    6312     }
    6313 
    6314     pRecCb += uiStrideC;
    6315     pRecCr += uiStrideC;
    6316   }
    6317 
    6318   Dist ruiDist;
    6319   Double rdCost;
    6320 #if NH_3D_VSO // M13
    6321   if ( m_pcRdCost->getUseVSO() )
    6322   {
    6323     ruiDist = m_pcRdCost->getDistPartVSO( pcCU, 0, bitDepthY, pcRec->getAddr( COMPONENT_Y ), pcRec->getStride( COMPONENT_Y ),  pcOrg->getAddr( COMPONENT_Y ), pcOrg->getStride( COMPONENT_Y ),  uiWidth,      uiHeight     , false );
    6324   }
    6325   else   
    6326   {
    6327 #endif
    6328     {
    6329       ruiDist = m_pcRdCost->getDistPart( bitDepthY, pcRec->getAddr( COMPONENT_Y ), uiRecStride, pcOrg->getAddr( COMPONENT_Y ), uiOrgStride, uiWidth, uiHeight, COMPONENT_Y );
    6330     }
    6331 #if NH_3D_VSO
    6332   }
    6333 #endif
    6334 
    6335   Bool bNonSkip = false;
    6336   bNonSkip |= ( pcCU->getSDCSegmentDCOffset( 0, 0 ) != 0 ) ? 1 : 0;
    6337   if( !bNonSkip )
    6338   {
    6339     pcCU->getTotalBits()       = MAX_INT;
    6340     pcCU->getTotalDistortion() = MAX_INT;
    6341     pcCU->getTotalCost()       = MAX_DOUBLE;
    6342   }
    6343   else
    6344   {
    6345     //----- determine rate and r-d cost -----
    6346     UInt uiBits = 0;
    6347     m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] );
    6348 
    6349     xAddSymbolBitsInter( pcCU, uiBits );
    6350 
    6351 #if NH_3D_VSO //M 14
    6352     if ( m_pcRdCost->getUseLambdaScaleVSO() )   
    6353     {
    6354       rdCost = m_pcRdCost->calcRdCostVSO( uiBits, ruiDist );   
    6355     }
    6356     else
    6357 #endif
    6358     {
    6359       rdCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
    6360     }
    6361 
    6362     pcCU->getTotalBits()       = m_pcEntropyCoder->getNumberOfWrittenBits();
    6363     pcCU->getTotalDistortion() = ruiDist;
    6364     pcCU->getTotalCost()       = rdCost;
    6365 
    6366     m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] );
    6367   }
    6368 
    6369 #if NH_3D_VSO // necessary? // M15
    6370   // set Model
    6371   if( !m_pcRdCost->getUseEstimatedVSD() && m_pcRdCost->getUseRenModel() )
    6372   {
    6373     Pel*  piSrc       = pcRec->getAddr( COMPONENT_Y );
    6374     UInt  uiSrcStride = pcRec->getStride( COMPONENT_Y );
    6375     m_pcRdCost->setRenModelData( pcCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    6376   }
    6377 #endif
    6378 }
    6379 #endif
    63804736
    63814737
    63824738Void TEncSearch::xEstimateInterResidualQT( TComYuv    *pcResi,
    6383 #if NH_3D_VSO // M25
    6384                                            TComYuv    *pcOrg,
    6385                                            TComYuv    *pcPred,
    6386 #endif
    63874739                                           Double     &rdCost,
    63884740                                           UInt       &ruiBits,
    6389 #if NH_3D_VSO
    6390                                            Dist       &ruiDist,
    6391                                            Dist       *puiZeroDist,
    6392 #else
    63934741                                           Distortion &ruiDist,
    63944742                                           Distortion *puiZeroDist,
    6395 #endif
    63964743                                           TComTU     &rTu
    63974744                                           DEBUG_STRING_FN_DECLARE(sDebug) )
     
    64354782  Double     dSingleCost = MAX_DOUBLE;
    64364783  UInt       uiSingleBits                                                                                                        = 0;
    6437 #if NH_3D_VSO
    6438   Dist       uiSingleDistComp            [MAX_NUM_COMPONENT][2/*0 = top (or whole TU for non-4:2:2) sub-TU, 1 = bottom sub-TU*/] = {{0,0},{0,0},{0,0}};
    6439   Dist       uiSingleDist                                                                                                       = 0;
    6440 #else
    64414784  Distortion uiSingleDistComp            [MAX_NUM_COMPONENT][2/*0 = top (or whole TU for non-4:2:2) sub-TU, 1 = bottom sub-TU*/] = {{0,0},{0,0},{0,0}};
    64424785  Distortion uiSingleDist                                                                                                        = 0;
    6443 #endif
    64444786  TCoeff     uiAbsSum                    [MAX_NUM_COMPONENT][2/*0 = top (or whole TU for non-4:2:2) sub-TU, 1 = bottom sub-TU*/] = {{0,0},{0,0},{0,0}};
    64454787  UInt       uiBestTransformMode         [MAX_NUM_COMPONENT][2/*0 = top (or whole TU for non-4:2:2) sub-TU, 1 = bottom sub-TU*/] = {{0,0},{0,0},{0,0}};
     
    65844926              TCoeff     currAbsSum   = 0;
    65854927              UInt       currCompBits = 0;
    6586 #if NH_3D_VSO
    6587               Dist       currCompDist = 0;
    6588 #else
    65894928              Distortion currCompDist = 0;
    6590 #endif
    65914929              Double     currCompCost = 0;
    65924930              UInt       nonCoeffBits = 0;
    6593 #if NH_3D_VSO
    6594               Dist       nonCoeffDist = 0;
    6595 #else
    65964931              Distortion nonCoeffDist = 0;
    6597 #endif
    65984932              Double     nonCoeffCost = 0;
    65994933
     
    66544988                                                        m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(compID),
    66554989                                                        true);
    6656 #if NH_3D_VSO     
    6657                   // No VSO needed here.
    6658                   assert( !m_pcRdCost->getUseVSO() );
    6659 #endif
    66604990                  nonCoeffDist = m_pcRdCost->getDistPart( channelBitDepth, m_pcQTTempTComYuv[uiQTTempAccessLayer].getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
    66614991                                                          m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride( compID ), pcResi->getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
     
    66644994                else
    66654995                {
    6666 #if NH_3D_VSO // M27                 
    6667                   if ( m_pcRdCost->getUseVSO() )
    6668                   {
    6669                     if( m_pcRdCost->getUseEstimatedVSD() )
    6670                     {
    6671                       nonCoeffDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPartIdx, channelBitDepth, m_pTempPel, tuCompRect.width, pcResi->getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
    6672                                                           pcResi->getStride( compID ), tuCompRect.width, tuCompRect.height, false );
    6673                     }
    6674                     else
    6675                     {     
    6676                       nonCoeffDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPartIdx, channelBitDepth, pcPred->getAddr( compID, uiAbsPartIdx ),
    6677                                                           pcPred->getStride( compID ), pcOrg->getAddr( compID, uiAbsPartIdx), pcOrg->getStride( compID ),
    6678                                                           tuCompRect.width, tuCompRect.height, false ); // initialized with zero residual distortion
    6679                     }
    6680                   }
    6681                   else
    6682 #endif
    66834996                    nonCoeffDist = m_pcRdCost->getDistPart( channelBitDepth, m_pTempPel, tuCompRect.width, pcResi->getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
    66844997                                                          pcResi->getStride(compID), tuCompRect.width, tuCompRect.height, compID); // initialized with zero residual distortion
     
    66945007
    66955008                nonCoeffBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    6696 #if NH_3D_VSO // M29               
    6697                 if ( m_pcRdCost->getUseLambdaScaleVSO())
    6698                 {
    6699                    nonCoeffCost = m_pcRdCost->calcRdCostVSO( nonCoeffBits, nonCoeffDist );       
    6700                 }         
    6701                 else         
    6702 #endif
    67035009                  nonCoeffCost = m_pcRdCost->calcRdCost( nonCoeffBits, nonCoeffDist );
    67045010              }
     
    67405046                if (bUseCrossCPrediction)
    67415047                {
    6742 #if NH_3D_VSO     
    6743                   assert( !m_pcRdCost->getUseVSO() );
    6744 #endif
    67455048                  TComTrQuant::crossComponentPrediction(TUIterator,
    67465049                                                        compID,
     
    67565059                }
    67575060
    6758 #if NH_3D_VSO // M28     
    6759                 if ( m_pcRdCost->getUseVSO() )
    6760                 {
    6761                   if ( m_pcRdCost->getUseEstimatedVSD() )
    6762                   {         
    6763                     currCompDist  = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPartIdx, channelBitDepth, m_pcQTTempTComYuv[uiQTTempAccessLayer].getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
    6764                       m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(compID),
    6765                       pcResi->getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
    6766                       pcResi->getStride(compID),
    6767                       tuCompRect.width, tuCompRect.height, false);
    6768                   }
    6769                   else
    6770                   {       
    6771                     m_cYuvRecTemp.addClipPartLuma( channelBitDepth, &m_pcQTTempTComYuv[uiQTTempAccessLayer], pcPred, uiAbsPartIdx, tuCompRect.width );
    6772                     currCompDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPartIdx, channelBitDepth,
    6773                                                       m_cYuvRecTemp.getAddr(compID, uiAbsPartIdx),
    6774                                                       m_cYuvRecTemp.getStride( compID),
    6775                                                       pcOrg->getAddr  ( compID, uiAbsPartIdx ),
    6776                                                       pcOrg->getStride( compID ),
    6777                                                       tuCompRect.width, tuCompRect.height, false );
    6778                   }
    6779                 }
    6780                 else
    6781 #endif
    67825061                currCompDist = m_pcRdCost->getDistPart( channelBitDepth, m_pcQTTempTComYuv[uiQTTempAccessLayer].getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
    67835062                                                        m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(compID),
     
    67865065                                                        tuCompRect.width, tuCompRect.height, compID);
    67875066
    6788 #if NH_3D_VSO // M NEW01
    6789                if ( m_pcRdCost->getUseRenModel() )
    6790                {
    6791                  currCompCost = m_pcRdCost->calcRdCostVSO(currCompBits, currCompDist);
    6792                }
    6793                else
    6794 #endif
    67955067                currCompCost = m_pcRdCost->calcRdCost(currCompBits, currCompDist);
    67965068                 
     
    69545226    uiSingleBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    69555227
    6956 #if NH_3D_VSO
    6957     if ( m_pcRdCost->getUseRenModel() )
    6958     {
    6959       dSingleCost = m_pcRdCost->calcRdCostVSO( uiSingleBits, uiSingleDist );
    6960     }
    6961     else
    6962 #endif
    69635228      dSingleCost = m_pcRdCost->calcRdCost( uiSingleBits, uiSingleDist );
    69645229
     
    69805245      m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    69815246    }
    6982 #if NH_3D_VSO
    6983     Dist       uiSubdivDist = 0;
    6984 #else
    69855247    Distortion uiSubdivDist = 0;
    6986 #endif
    69875248    UInt       uiSubdivBits = 0;
    69885249    Double     dSubdivCost = 0.0;
     
    70215282    {
    70225283      DEBUG_STRING_NEW(childString)
    7023 #if NH_3D_VSO
    7024       xEstimateInterResidualQT( pcResi, pcOrg, pcPred, dSubdivCost, uiSubdivBits, uiSubdivDist, bCheckFull ? NULL : puiZeroDist,  tuRecurseChild DEBUG_STRING_PASS_INTO(childString));
    7025 #else
    70265284      xEstimateInterResidualQT( pcResi, dSubdivCost, uiSubdivBits, uiSubdivDist, bCheckFull ? NULL : puiZeroDist,  tuRecurseChild DEBUG_STRING_PASS_INTO(childString));
    7027 #endif
    70285285#if DEBUG_STRING
    70295286      // split the string by component and append to the relevant output (because decoder decodes in channel order, whereas this search searches by TU-order)
     
    70765333
    70775334    uiSubdivBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    7078 #if NH_3D_VSO
    7079     if( m_pcRdCost->getUseLambdaScaleVSO())
    7080     {
    7081       dSubdivCost  = m_pcRdCost->calcRdCostVSO( uiSubdivBits, uiSubdivDist );
    7082     }
    7083     else
    7084 #endif
    70855335      dSubdivCost  = m_pcRdCost->calcRdCost( uiSubdivBits, uiSubdivDist );
    70865336
     
    73315581  // Reload only contexts required for coding intra mode information
    73325582  m_pcRDGoOnSbacCoder->loadIntraDirMode( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST], chType );
    7333 #if NH_3D_DMM
    7334   if( pcCU->getSlice()->getIsDepth() && isLuma(chType) )
    7335   {
    7336     m_pcRDGoOnSbacCoder->loadIntraDepthDmm( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    7337   }
    7338 #endif
    73395583
    73405584  // Temporarily set the intra dir being tested, and only
     
    74145658    m_pcEntropyCoder->encodeSkipFlag(pcCU, 0, true);
    74155659    m_pcEntropyCoder->encodeMergeIndex(pcCU, 0, true);
    7416 #if NH_3D_ARP
    7417     m_pcEntropyCoder->encodeARPW( pcCU, 0 );
    7418 #endif
    7419 #if NH_3D_IC
    7420     m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
    7421 #endif
    74225660    ruiBits += m_pcEntropyCoder->getNumberOfWrittenBits();
    74235661  }
     
    74325670
    74335671    m_pcEntropyCoder->encodeSkipFlag ( pcCU, 0, true );
    7434 #if NH_3D_DIS
    7435     m_pcEntropyCoder->encodeDIS ( pcCU, 0, true );
    7436 #endif
    74375672    m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
    74385673    m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
    74395674    m_pcEntropyCoder->encodePredInfo( pcCU, 0 );
    7440 #if NH_3D_SDC_INTRA
    7441     m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
    7442 #endif
    7443 #if NH_3D_ARP
    7444     m_pcEntropyCoder->encodeARPW( pcCU , 0  );
    7445 #endif
    7446 #if NH_3D_IC
    7447     m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
    7448 #endif
    7449 #if NH_3D_DBBP
    7450     m_pcEntropyCoder->encodeDBBPFlag( pcCU, 0, true );
    7451 #endif
    74525675
    74535676    Bool codeDeltaQp = false;
     
    77185941}
    77195942
    7720 #if NH_3D_DMM
    7721   // -------------------------------------------------------------------------------------------------------------------
    7722   // Depth intra search
    7723   // -------------------------------------------------------------------------------------------------------------------
    7724 Void TEncSearch::xCalcBiSegDCs( Pel* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& valDC1, Pel& valDC2, Pel defaultVal, Bool subSamp )
    7725 {
    7726   valDC1 = defaultVal;
    7727   valDC2 = defaultVal;
    7728 
    7729   UInt uiDC1 = 0;
    7730   UInt uiDC2 = 0;
    7731   UInt uiNumPixDC1 = 0, uiNumPixDC2 = 0;
    7732  
    7733   Int subSamplePix = subSamp ? 2 : 1;
    7734 
    7735   Pel* piTemp = ptrSrc;
    7736   for( UInt uiY = 0; uiY < patternStride; uiY += subSamplePix )
    7737   {
    7738     for( UInt uiX = 0; uiX < patternStride; uiX += subSamplePix )
    7739     {
    7740       if( true == biSegPattern[uiX] )
    7741       {
    7742         uiDC2 += piTemp[uiX];
    7743         uiNumPixDC2++;
    7744       }
    7745       else
    7746       {
    7747         uiDC1 += piTemp[uiX];
    7748         uiNumPixDC1++;
    7749       }
    7750     }
    7751     piTemp       += subSamplePix*srcStride;
    7752     biSegPattern += subSamplePix*patternStride;
    7753   }
    7754 
    7755   if( uiNumPixDC1 > 0 ) { valDC1 = uiDC1 / uiNumPixDC1; }
    7756   if( uiNumPixDC2 > 0 ) { valDC2 = uiDC2 / uiNumPixDC2; }
    7757 }
    7758 
    7759 Void TEncSearch::xSearchDmmDeltaDCs( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 )
    7760 {
    7761   assert( biSegPattern );
    7762   Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
    7763 
    7764   Pel origDC1 = 0; Pel origDC2 = 0;
    7765   xCalcBiSegDCs  ( piOrig,   uiStride, biSegPattern, patternStride, origDC1, origDC2, (1<<(bitDepthY-1)) );
    7766   assignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, origDC1, origDC2 );
    7767 
    7768   Pel  predDC1 = 0; Pel predDC2 = 0;
    7769   predBiSegDCs( pcCU, uiAbsPtIdx, uiWidth, uiHeight, biSegPattern, patternStride, predDC1, predDC2 );
    7770 
    7771   rDeltaDC1 = origDC1 - predDC1;
    7772   rDeltaDC2 = origDC2 - predDC2;
    7773 
    7774 #if NH_3D_VSO
    7775   if( m_pcRdCost->getUseVSO() )
    7776   {
    7777     Pel fullDeltaDC1 = rDeltaDC1;
    7778     Pel fullDeltaDC2 = rDeltaDC2;
    7779 
    7780     Dist uiBestDist      = RDO_DIST_MAX;
    7781     UInt  uiBestQStepDC1 = 0;
    7782     UInt  uiBestQStepDC2 = 0;
    7783 
    7784     UInt uiDeltaDC1Max = abs(fullDeltaDC1);
    7785     UInt uiDeltaDC2Max = abs(fullDeltaDC2);
    7786 
    7787     //VSO Level delta DC check range extension
    7788     uiDeltaDC1Max += (uiDeltaDC1Max>>1);
    7789     uiDeltaDC2Max += (uiDeltaDC2Max>>1);
    7790 
    7791     // limit search range to [0, IBDI_MAX]
    7792     if( fullDeltaDC1 <  0 && uiDeltaDC1Max >                          abs(predDC1) ) { uiDeltaDC1Max =                          abs(predDC1); }
    7793     if( fullDeltaDC1 >= 0 && uiDeltaDC1Max > ((1<<bitDepthY)-1) - abs(predDC1) ) { uiDeltaDC1Max = ((1<<bitDepthY)-1) - abs(predDC1); }
    7794 
    7795     if( fullDeltaDC2 <  0 && uiDeltaDC2Max >                          abs(predDC2) ) { uiDeltaDC2Max =                          abs(predDC2); }
    7796     if( fullDeltaDC2 >= 0 && uiDeltaDC2Max > ((1<<bitDepthY)-1) - abs(predDC2) ) { uiDeltaDC2Max = ((1<<bitDepthY)-1) - abs(predDC2); }
    7797 
    7798     // init dist with original segment DCs
    7799     assignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, origDC1, origDC2 );
    7800 
    7801     Dist uiOrgDist = RDO_DIST_MAX;
    7802     if( m_pcRdCost->getUseEstimatedVSD() )
    7803     {
    7804       uiOrgDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, bitDepthY, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
    7805     }
    7806     else
    7807     {
    7808       uiOrgDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, bitDepthY, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
    7809     }
    7810 
    7811     uiBestDist     = uiOrgDist;
    7812     uiBestQStepDC1 = abs(fullDeltaDC1);
    7813     uiBestQStepDC2 = abs(fullDeltaDC2);
    7814 
    7815     // coarse search with step size 4
    7816     for( UInt uiQStepDC1 = 0; uiQStepDC1 < uiDeltaDC1Max; uiQStepDC1 += 4 )
    7817     {
    7818       Pel testDC1 = ClipBD( predDC1 + ((Int)(uiQStepDC1) * (( fullDeltaDC1 < 0 ) ? -1 : 1)), bitDepthY );
    7819       for( UInt uiQStepDC2 = 0; uiQStepDC2 < uiDeltaDC2Max; uiQStepDC2 += 4 )
    7820       {
    7821         Pel testDC2 = ClipBD( predDC2 + ((Int)(uiQStepDC2) * (( fullDeltaDC2 < 0 ) ? -1 : 1)), bitDepthY );
    7822         assignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, testDC1, testDC2 );
    7823 
    7824         Dist uiAct4Dist = RDO_DIST_MAX;
    7825         if( m_pcRdCost->getUseEstimatedVSD() )
    7826         {
    7827           uiAct4Dist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, bitDepthY, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
    7828         }
    7829         else
    7830         {
    7831           uiAct4Dist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, bitDepthY, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
    7832         }
    7833 
    7834         if( uiAct4Dist < uiBestDist || uiBestDist == RDO_DIST_MAX )
    7835         {
    7836           uiBestDist     = uiAct4Dist;
    7837           uiBestQStepDC1 = uiQStepDC1;
    7838           uiBestQStepDC2 = uiQStepDC2;
    7839         }
    7840       }
    7841     }
    7842 
    7843     // refinement +-3
    7844     for( UInt uiQStepDC1 = (UInt)max(0, ((Int)uiBestQStepDC1-3)); uiQStepDC1 <= (uiBestQStepDC1+3); uiQStepDC1++ )
    7845     {
    7846       Pel testDC1 = ClipBD( predDC1 + ((Int)(uiQStepDC1) * (( fullDeltaDC1 < 0 ) ? -1 : 1)), bitDepthY );
    7847       for( UInt uiQStepDC2 = (UInt)max(0, ((Int)uiBestQStepDC2-3)); uiQStepDC2 <= (uiBestQStepDC2+3); uiQStepDC2++ )
    7848       {
    7849         Pel testDC2 = ClipBD( predDC2 + ((Int)(uiQStepDC2) * (( fullDeltaDC2 < 0 ) ? -1 : 1)), bitDepthY );
    7850         assignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, testDC1, testDC2 );
    7851 
    7852         Dist uiActDist = RDO_DIST_MAX;
    7853         if( m_pcRdCost->getUseEstimatedVSD() )
    7854         {
    7855           uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, bitDepthY, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
    7856         }
    7857         else
    7858         {
    7859           uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, bitDepthY, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
    7860         }
    7861 
    7862         if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX )
    7863         {
    7864           uiBestDist     = uiActDist;
    7865           uiBestQStepDC1 = uiQStepDC1;
    7866           uiBestQStepDC2 = uiQStepDC2;
    7867         }
    7868       }
    7869     }
    7870     rDeltaDC1 = (Int)(uiBestQStepDC1) * (Int)(( fullDeltaDC1 < 0 ) ? -1 : 1);
    7871     rDeltaDC2 = (Int)(uiBestQStepDC2) * (Int)(( fullDeltaDC2 < 0 ) ? -1 : 1);
    7872   }
    7873 #endif
    7874 
    7875 #if NH_3D_DLT
    7876   rDeltaDC1 = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), ClipBD(predDC1 + rDeltaDC1, bitDepthY )) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 );
    7877   rDeltaDC2 = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), ClipBD(predDC2 + rDeltaDC2, bitDepthY )) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 );
    7878 #endif
    7879 }
    7880 
    7881 Void TEncSearch::xSearchDmm1Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx )
    7882 {
    7883   ruiTabIdx = 0;
    7884   Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
    7885 
    7886   // local pred buffer
    7887   TComYuv cPredYuv;
    7888   cPredYuv.create( uiWidth, uiHeight, CHROMA_400 );
    7889   cPredYuv.clear();
    7890 
    7891   UInt uiPredStride = cPredYuv.getStride( COMPONENT_Y );
    7892   Pel* piPred       = cPredYuv.getAddr( COMPONENT_Y );
    7893 
    7894   Pel refDC1 = 0; Pel refDC2 = 0;
    7895 
    7896   WedgeList*     pacWedgeList     = getWedgeListScaled    ( uiWidth );
    7897   WedgeNodeList* pacWedgeNodeList = getWedgeNodeListScaled( uiWidth );
    7898 
    7899   // coarse wedge search
    7900   Dist uiBestDist   = RDO_DIST_MAX;
    7901   UInt uiBestNodeId = 0;
    7902   for( UInt uiNodeId = 0; uiNodeId < pacWedgeNodeList->size(); uiNodeId++ )
    7903   {
    7904     TComWedgelet* pcWedgelet = &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx()));
    7905     Bool *pbPattern = pcWedgelet->getPatternScaled(uiWidth);
    7906     UInt uiStride   = uiWidth;
    7907     xCalcBiSegDCs  ( piRef,  uiRefStride,  pbPattern, uiStride, refDC1, refDC2, (1<<(bitDepthY-1)) );
    7908     assignBiSegDCs( piPred, uiPredStride, pbPattern, uiStride, refDC1, refDC2 );
    7909 
    7910     Dist uiActDist = RDO_DIST_MAX;
    7911 #if NH_3D_VSO
    7912     if( m_pcRdCost->getUseVSO() )
    7913     {
    7914       if( m_pcRdCost->getUseEstimatedVSD() )
    7915       {
    7916         uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false );
    7917       }
    7918       else
    7919       {
    7920         uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false );
    7921       }
    7922     }
    7923     else
    7924 #endif
    7925     {
    7926       uiActDist = m_pcRdCost->getDistPart( bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, COMPONENT_Y, DF_SAD );
    7927     }
    7928 
    7929     if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX )
    7930     {
    7931       uiBestDist   = uiActDist;
    7932       uiBestNodeId = uiNodeId;
    7933     }
    7934   }
    7935 
    7936   // refinement
    7937   Dist uiBestDistRef = uiBestDist;
    7938   UInt uiBestTabIdxRef  = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx();
    7939   for( UInt uiRefId = 0; uiRefId < DMM_NUM_WEDGE_REFINES; uiRefId++ )
    7940   {
    7941     if( pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ) != DMM_NO_WEDGE_IDX )
    7942     {
    7943       TComWedgelet* pcWedgelet = &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId )));
    7944       Bool *pbPattern = pcWedgelet->getPatternScaled(uiWidth);
    7945       UInt uiStride   = uiWidth;
    7946       xCalcBiSegDCs  ( piRef,  uiRefStride,  pbPattern, uiStride, refDC1, refDC2, (1<<(bitDepthY-1)) );
    7947       assignBiSegDCs( piPred, uiPredStride, pbPattern, uiStride, refDC1, refDC2 );
    7948       Dist uiActDist = RDO_DIST_MAX;
    7949 #if NH_3D_VSO
    7950       if( m_pcRdCost->getUseVSO() )
    7951       {
    7952         if( m_pcRdCost->getUseEstimatedVSD() )
    7953         {
    7954           uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false );
    7955         }
    7956         else
    7957         {
    7958           uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false );
    7959         }
    7960       }
    7961       else
    7962 #endif
    7963       {
    7964         uiActDist = m_pcRdCost->getDistPart( bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, COMPONENT_Y, DF_SAD );
    7965       }
    7966 
    7967       if( uiActDist < uiBestDistRef || uiBestDistRef == RDO_DIST_MAX )
    7968       {
    7969         uiBestDistRef   = uiActDist;
    7970         uiBestTabIdxRef = pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId );
    7971       }
    7972     }
    7973   }
    7974 
    7975   ruiTabIdx = uiBestTabIdxRef;
    7976 
    7977   cPredYuv.destroy();
    7978   return;
    7979 }
    7980 
    7981 #endif
    7982 #if NH_3D_SDC_INTRA
    7983 Void TEncSearch::xCalcConstantSDC( Pel* ptrSrc, UInt srcStride, UInt uiSize, Pel& valDC )
    7984 {
    7985   valDC = 0;
    7986   UInt       uiDC = 0;
    7987   UInt uiNumPixDC = 0;
    7988 
    7989   Int subSamplePix = ( uiSize > 16 ) ? 2 : 1;
    7990 
    7991   Pel* piTemp = ptrSrc;
    7992   for( UInt uiY = 0; uiY < uiSize; uiY += subSamplePix )
    7993   {
    7994     for( UInt uiX = 0; uiX < uiSize; uiX += subSamplePix )
    7995     {
    7996       uiDC += piTemp[uiX];
    7997       uiNumPixDC++;
    7998     }
    7999     piTemp += subSamplePix*srcStride;
    8000   }
    8001 
    8002   if( uiNumPixDC > 0 ) { valDC = uiDC / uiNumPixDC; }
    8003 }
    8004 #endif
    80055943//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncSearch.h

    r1386 r1390  
    113113  Pel*            m_pTempPel;
    114114
    115 #if NH_3D_VSO // M17
    116   TComYuv         m_cYuvRecTemp;
    117 #endif
    118115  // AMVP cost computation
    119116  // UInt            m_auiMVPIdxCost[AMVP_MAX_NUM_CANDS+1][AMVP_MAX_NUM_CANDS];
     
    178175                                  Pel         resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE]
    179176                                  DEBUG_STRING_FN_DECLARE(sDebug)
    180 #if NH_3D_ENC_DEPTH
    181                                 , Bool        bOnlyIVP
    182 #endif
    183177                                );
    184178
     
    190184                                  Pel         resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE]
    191185                                  DEBUG_STRING_FN_DECLARE(sDebug));
    192 #if NH_3D_DIS
    193   Void  estIntraPredDIS        ( TComDataCU* pcCU,
    194                                  TComYuv*    pcOrgYuv,
    195                                  TComYuv*    pcPredYuv,
    196                                  TComYuv*    pcResiYuv,
    197                                  TComYuv*    pcRecoYuv,
    198                                  UInt&       ruiDistC,
    199                                  Bool        bLumaOnly );
    200 #endif 
    201186
    202187  /// encoder estimation - inter prediction (non-skip)
     
    207192                                  TComYuv*    pcRecoYuv
    208193                                  DEBUG_STRING_FN_DECLARE(sDebug),
    209 #if NH_3D_FAST_TEXTURE_ENCODING
    210                                   Bool        bFMD,
    211 #endif
    212194                                  Bool        bUseRes = false
    213195#if AMP_MRG
     
    225207                                  Bool        bSkipResidual
    226208                                  DEBUG_STRING_FN_DECLARE(sDebug) );
    227 #if NH_3D_SDC_INTER
    228   Void encodeResAndCalcRdInterSDCCU( TComDataCU* pcCU,
    229                                      TComYuv* pcOrg,
    230                                      TComYuv* pcPred,
    231                                      TComYuv* pcResi,
    232                                      TComYuv* pcRec,
    233                                      Int      uiOffset,
    234                                      const UInt uiDepth );
    235 #endif
    236209
    237210  /// set ME search range
     
    272245                                          Pel           resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE],
    273246                                    const Bool          checkCrossCPrediction,
    274 #if NH_3D_VSO
    275                                     Dist&        ruiDist,
    276 #else
    277247                                    Distortion&   ruiDist,
    278 #endif
    279248const ComponentID   compID,
    280249                                          TComTU        &rTu
    281250                                    DEBUG_STRING_FN_DECLARE(sTest)
    282251                                         ,Int           default0Save1Load2 = 0
    283 #if NH_3D_ENC_DEPTH
    284                                   , Bool          zeroResiFlag = false
    285 #endif
    286252                                   );
    287253
     
    290256                                    TComYuv*    pcResiYuv,
    291257                                    Pel         resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE],
    292 #if NH_3D_VSO
    293                                     Dist&        ruiDistY,
    294 #else
    295258                                    Distortion& ruiDistY,
    296 #endif
    297259#if HHI_RQT_INTRA_SPEEDUP
    298260                                    Bool         bCheckFirst,
     
    301263                                    TComTU      &rTu
    302264                                    DEBUG_STRING_FN_DECLARE(sDebug)
    303 #if NH_3D_ENC_DEPTH
    304                                   , Bool        zeroResiFlag = false
    305 #endif
    306265                                  );
    307266
     
    330289                                    TComYuv*    pcResiYuv,
    331290                                    Pel         resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE],
    332 #if NH_3D_VSO
    333                                     Dist&       ruiDist,
    334 #else
    335291                                    Distortion& ruiDist,
    336 #endif
    337292                                    TComTU      &rTu
    338293                                    DEBUG_STRING_FN_DECLARE(sDebug));
     
    342297  Void  xStoreIntraResultQT       ( const ComponentID compID, TComTU &rTu);
    343298  Void  xLoadIntraResultQT        ( const ComponentID compID, TComTU &rTu);
    344 #if NH_3D_DIS
    345   Void xIntraCodingDIS           ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, UInt uiPredMode );
    346 #endif
    347 
    348 #if NH_3D_DMM
    349   // -------------------------------------------------------------------------------------------------------------------
    350   // Depth intra search
    351   // -------------------------------------------------------------------------------------------------------------------
    352 
    353   Void xCalcBiSegDCs              ( Pel* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& valDC1, Pel& valDC2, Pel defaultVal, Bool subSamp = false );
    354   Void xSearchDmmDeltaDCs         ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 );
    355   Void xSearchDmm1Wedge           ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx );
    356 #endif
    357 #if NH_3D_SDC_INTRA
    358   Void xIntraCodingSDC            ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi    );
    359   Void xCalcConstantSDC           ( Pel* ptrSrc, UInt srcStride, UInt uiSize, Pel& valDC );
    360 #endif
     299
    361300
    362301
     
    411350                                    UChar*       uhInterDirNeighbours,
    412351                                    Int&         numValidMergeCand
    413 #if NH_3D_VSP
    414                                   , Int* vspFlag
    415 #endif
    416 #if NH_3D_SPIVMP
    417                                   , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    418 #endif
    419352                                   );
    420353
     
    508441
    509442  Void xEncodeInterResidualQT( const ComponentID compID, TComTU &rTu );
    510 #if NH_3D_VSO // M26
    511   Void xEstimateInterResidualQT( TComYuv* pcResi, TComYuv* pcOrg, TComYuv* pcPred,  Double &rdCost, UInt &ruiBits, Dist       &ruiDist, Dist       *puiZeroDist, TComTU &rTu DEBUG_STRING_FN_DECLARE(sDebug) );
    512 #else
    513443  Void xEstimateInterResidualQT( TComYuv* pcResi                                  , Double &rdCost, UInt &ruiBits, Distortion &ruiDist, Distortion *puiZeroDist, TComTU &rTu DEBUG_STRING_FN_DECLARE(sDebug) );
    514 #endif
    515444  Void xSetInterResidualQTData( TComYuv* pcResi, Bool bSpatial, TComTU &rTu  );
    516445
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncSlice.cpp

    r1386 r1390  
    136136  m_pdRdPicQp         = (Double*)xMalloc( Double, m_pcCfg->getDeltaQpRD() * 2 + 1 );
    137137  m_piRdPicQp         = (Int*   )xMalloc( Int,    m_pcCfg->getDeltaQpRD() * 2 + 1 );
    138 #if KWU_RC_MADPRED_E0227
    139   if(m_pcCfg->getUseRateCtrl())
    140   {
    141     m_pcRateCtrl        = pcEncTop->getRateCtrl();
    142   }
    143   else
    144   {
    145     m_pcRateCtrl        = NULL;
    146   }
    147 #else
    148138  m_pcRateCtrl        = pcEncTop->getRateCtrl();
    149 #endif
    150139
    151140}
     
    217206  rpcSlice->setViewId      ( pVPS->getViewId      ( layerId ) );   
    218207  rpcSlice->setViewIndex   ( pVPS->getViewIndex   ( layerId ) );
    219 #if NH_3D
    220   rpcSlice->setIsDepth     ( pVPS->getDepthId     ( layerId ) != 0 );   
    221 #endif
    222208#endif
    223209  rpcSlice->setSliceBits(0);
     
    226212  rpcSlice->setPicOutputFlag( true );
    227213  rpcSlice->setPOC( pocCurr );
    228 #if NH_3D_IC
    229   rpcSlice->setApplyIC( false );
    230 #endif
    231214  // depth computation based on GOP size
    232215  Int depth;
     
    460443  setUpLambda(rpcSlice, dLambda, iQP);
    461444
    462 #if NH_3D_VSO
    463   m_pcRdCost->setUseLambdaScaleVSO  ( (m_pcCfg->getUseVSO() ||  m_pcCfg->getForceLambdaScaleVSO()) && ( m_pcCfg->getIsDepth()  | m_pcCfg->getIsAuxDepth() ) );
    464   m_pcRdCost->setLambdaVSO          ( dLambda * m_pcCfg->getLambdaScaleVSO() );
    465 
    466   // Should be moved to TEncTop
    467  
    468   // SAIT_VSO_EST_A0033
    469   m_pcRdCost->setDisparityCoeff( m_pcCfg->getDispCoeff() );
    470 
    471   // LGE_WVSO_A0119
    472   if( m_pcCfg->getUseWVSO() && ( m_pcCfg->getIsDepth() || m_pcCfg->getIsAuxDepth() ) )
    473   {
    474     m_pcRdCost->setDWeight  ( m_pcCfg->getDWeight()   );
    475     m_pcRdCost->setVSOWeight( m_pcCfg->getVSOWeight() );
    476     m_pcRdCost->setVSDWeight( m_pcCfg->getVSDWeight() );
    477   }
    478 
    479 #endif
    480445
    481446  if (m_pcCfg->getFastMEForGenBLowDelayEnabled())
     
    584549  rpcSlice->setSliceSegmentMode     ( m_pcCfg->getSliceSegmentMode()     );
    585550  rpcSlice->setSliceSegmentArgument ( m_pcCfg->getSliceSegmentArgument() );
    586 #if NH_3D_IV_MERGE
    587 #else
    588551  rpcSlice->setMaxNumMergeCand        ( m_pcCfg->getMaxNumMergeCand()        );
    589 #endif
    590552}
    591553
     
    699661    compressSlice   ( pcPic, true, m_pcCfg->getFastDeltaQp());
    700662
    701 #if NH_3D_VSO
    702     Dist64 uiPicDist        = m_uiPicDist;
    703 #else
    704663    UInt64 uiPicDist        = m_uiPicDist; // Distortion, as calculated by compressSlice.
    705664    // NOTE: This distortion is the chroma-weighted SSE distortion for the slice.
     
    710669    // m_pcGOPEncoder->preLoopFilterPicAll( pcPic, uiPicDist );
    711670
    712 #endif
    713671
    714672    // compute RD cost and choose the best
    715 #if NH_3D_VSO
    716     Double dPicRdCost = m_pcRdCost->calcRdCost( (Double)m_uiPicTotalBits, uiPicDist, DF_SSE_FRAME);
    717 #else
    718673    Double dPicRdCost = m_pcRdCost->calcRdCost( (Double)m_uiPicTotalBits, (Double)uiPicDist, DF_SSE_FRAME);
    719 #endif
    720 #if H_3D
    721     // Above calculation need to be fixed for VSO, including frameLambda value.
    722 #endif
    723674
    724675    if ( dPicRdCost < dPicRdCostBest )
     
    846797#endif
    847798
    848 #if NH_3D_IC
    849   if ( m_pcCfg->getViewIndex() && m_pcCfg->getUseIC() &&
    850        !( ( pcSlice->getSliceType() == P_SLICE && pcSlice->getPPS()->getUseWP() ) || ( pcSlice->getSliceType() == B_SLICE && pcSlice->getPPS()->getWPBiPred() ) )
    851      )
    852   {
    853     pcSlice ->xSetApplyIC(m_pcCfg->getUseICLowLatencyEnc());
    854     if ( pcSlice->getApplyIC() )
    855     {
    856       pcSlice->setIcSkipParseFlag( pcSlice->getPOC() % m_pcCfg->getIntraPeriod() != 0 );
    857     }
    858   }
    859 #endif
    860799
    861800
     
    878817
    879818  // for every CTU in the slice segment (may terminate sooner if there is a byte limit on the slice-segment)
    880 #if NH_3D_VSO
    881   Int iLastPosY = -1;
    882 #endif
    883819
    884820  for( UInt ctuTsAddr = startCtuTsAddr; ctuTsAddr < boundingCtuTsAddr; ++ctuTsAddr )
     
    888824    TComDataCU* pCtu = pcPic->getCtu( ctuRsAddr );
    889825    pCtu->initCtu( pcPic, ctuRsAddr );
    890 #if NH_3D_VSO
    891     if ( m_pcRdCost->getUseRenModel() )
    892     {
    893       // updated renderer model if necessary
    894       Int iCurPosX;
    895       Int iCurPosY;
    896       pCtu->getPosInPic(0, iCurPosX, iCurPosY );
    897       if ( iCurPosY != iLastPosY )
    898       {
    899         iLastPosY = iCurPosY;         
    900         TEncTop* pcEncTop = (TEncTop*) m_pcCfg; // Fix this later.
    901         pcEncTop->setupRenModel( pcSlice->getPOC() , pcSlice->getViewIndex(), pcSlice->getIsDepth() || pcSlice->getVPS()->getAuxId( pcSlice->getLayerId()  ) ? 1 : 0, iCurPosY, pcSlice->getSPS()->getMaxCUHeight() );
    902       }
    903     }
    904 #endif
    905826
    906827    // update CABAC state
     
    952873      else
    953874      {
    954 #if KWU_RC_MADPRED_E0227
    955           if(pcSlice->getLayerId() != 0 && m_pcCfg->getUseDepthMADPred() && !pcSlice->getIsDepth())
    956           {
    957             Double zn, zf, focallength, position, camShift;
    958             Double basePos;
    959             Bool bInterpolated;
    960             Int direction = pcSlice->getViewId() - pcCU->getSlice()->getIvPic(false, 0)->getViewId();
    961             Int disparity;
    962 
    963             pcEncTop->getCamParam()->xGetZNearZFar(pcEncTop->getCamParam()->getBaseViewNumbers()[pcSlice->getViewIndex()], pcSlice->getPOC(), zn, zf);
    964             pcEncTop->getCamParam()->xGetGeometryData(pcEncTop->getCamParam()->getBaseViewNumbers()[0], pcSlice->getPOC(), focallength, basePos, camShift, bInterpolated);
    965             pcEncTop->getCamParam()->xGetGeometryData(pcEncTop->getCamParam()->getBaseViewNumbers()[pcSlice->getViewIndex()], pcSlice->getPOC(), focallength, position, camShift, bInterpolated);
    966             bpp       = m_pcRateCtrl->getRCPic()->getLCUTargetBppforInterView( m_pcRateCtrl->getPicList(), pcCU,
    967               basePos, position, focallength, zn, zf, (direction > 0 ? 1 : -1), &disparity );
    968           }
    969           else
    970           {
    971 #endif
    972875        bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType());
    973876        if ( pcPic->getSlice( 0 )->getSliceType() == I_SLICE)
     
    980883          estQP     = m_pcRateCtrl->getRCPic()->getLCUEstQP    ( estLambda, pcSlice->getSliceQp() );
    981884        }
    982 #if KWU_RC_MADPRED_E0227
    983           estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp );
    984           estQP     = m_pcRateCtrl->getRCPic()->getLCUEstQP    ( estLambda, pcSlice->getSliceQp() );
    985 #endif
    986885
    987886        estQP     = Clip3( -pcSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, estQP );
     
    1060959    if ( m_pcCfg->getUseRateCtrl() )
    1061960    {
    1062 #if KWU_RC_MADPRED_E0227
    1063         UInt SAD    = m_pcCuEncoder->getLCUPredictionSAD();
    1064         Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
    1065         Int width   = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );
    1066         Double MAD = (Double)SAD / (Double)(height * width);
    1067         MAD = MAD * MAD;
    1068         ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD;
    1069 #endif
    1070961
    1071962      Int actualQP        = g_RCInvalidQPValue;
     
    12241115    }
    12251116
    1226 #if NH_3D_QTLPC
    1227     pcPic->setReduceBitsFlag(true);
    1228 #endif
    12291117    if ( pcSlice->getSPS()->getUseSAO() )
    12301118    {
     
    12961184      }
    12971185    }
    1298 #if NH_3D_QTLPC
    1299     pcPic->setReduceBitsFlag(false);
    1300 #endif
    13011186  } // CTU-loop
    13021187
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncSlice.h

    r1386 r1390  
    8989  TEncSbac*               m_pcRDGoOnSbacCoder;                  ///< go-on SBAC encoder
    9090  UInt64                  m_uiPicTotalBits;                     ///< total bits for the picture
    91 #if NH_3D_VSO
    92   Dist64                  m_uiPicDist;                          ///< total distortion for the picture
    93 #else
    9491  UInt64                  m_uiPicDist;                          ///< total distortion for the picture
    95 #endif
    9692  Double                  m_dPicRdCost;                         ///< picture-level RD cost
    9793  Double*                 m_pdRdPicLambda;                      ///< array of lambda candidates
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncTop.cpp

    r1386 r1390  
    7979  m_ivPicLists = NULL;
    8080#endif
    81 #if NH_3D_IC
    82   m_aICEnableCandidate = NULL;
    83   m_aICEnableNum = NULL;
    84 #endif
    8581#if NH_MV
    8682  m_cCavlcCoder.setEncTop(this);
     
    126122  if ( m_RCEnableRateControl )
    127123  {
    128 #if KWU_RC_MADPRED_E0227
    129     m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight,
    130       g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList, getLayerId() );
    131 #else
    132124    m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight,
    133125        m_maxCUWidth, m_maxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList );
    134 #endif
    135126  }
    136127
     
    202193}
    203194
    204 #if KWU_RC_MADPRED_E0227
    205 Void TEncTop::init(TAppEncTop* pcTAppEncTop, Bool isFieldCoding)
    206 #else
    207195Void TEncTop::init(Bool isFieldCoding)
    208 #endif
    209196{
    210197  // initialize SPS
    211 #if H_3D
    212   // Assuming that all PPS indirectly refer to the same VPS via different SPS
    213   m_cSPS.setVPS(m_cVPS);
    214 #endif
    215198  xInitSPS();
    216199  xInitVPS();
     
    234217
    235218  xInitPPSforTiles();
    236 #if NH_3D_IC
    237   m_aICEnableCandidate = new Int[ 10 ];
    238   m_aICEnableNum = new Int[ 10 ];
    239 
    240   for(int i=0;i<10;i++)
    241   {
    242     m_aICEnableCandidate[i]=0;
    243     m_aICEnableNum[i]=0;
    244   }
    245 #endif
    246219
    247220  // initialize processing unit classes
     
    250223  m_cCuEncoder.   init( this );
    251224
    252 #if KWU_RC_MADPRED_E0227
    253   m_pcTAppEncTop = pcTAppEncTop;
    254 #endif
    255225  // initialize transform & quantization class
    256226  m_pcCavlcCoder = getCavlcCoder();
     
    357327  }
    358328  pcPicCurr->setLayerId( getLayerId());
    359 #if NH_3D
    360   pcPicCurr->setScaleOffset( m_cameraParameters->getCodedScale(), m_cameraParameters->getCodedOffset() );
    361 #endif
    362329}
    363330#endif
     
    399366Void TEncTop::encode( Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded )
    400367{
    401 #endif
    402 #if NH_3D
    403   TComPic* picLastCoded = getPic( getGOPEncoder()->getPocLastCoded() );
    404   if( picLastCoded )
    405   {
    406     picLastCoded->compressMotion(1);
    407   }
    408368#endif
    409369#if NH_MV
     
    717677  m_cSPS.setSpsExtensionPresentFlag       ( true );
    718678  m_cSPS.setSpsMultilayerExtensionFlag    ( true );
    719 #if NH_3D
    720   m_cSPS.setSps3dExtensionFlag            ( true );
    721 #endif
    722679#endif
    723680
     
    728685  m_cSPS.setMaxCUHeight            ( m_maxCUHeight       );
    729686  m_cSPS.setMaxTotalCUDepth        ( m_maxTotalCUDepth   );
    730 #if NH_3D
    731   assert( !getIsDepth()  || m_chromaFormatIDC == CHROMA_400 );
    732 #endif
    733687  m_cSPS.setChromaFormatIdc( m_chromaFormatIDC);
    734688  m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_log2DiffMaxMinCodingBlockSize);
     
    1043997#if NH_MV
    1044998  m_cPPS.setLayerId( getLayerId() );
    1045 #if NH_3D
    1046   // Check if this condition is still correct
    1047   if( getVPS()->getNumRefListLayers( getLayerId() ) > 0 )
    1048 #else
    1049999  if( getVPS()->getNumDirectRefLayers( getLayerId() ) > 0 )
    1050 #endif
    10511000  {
    10521001    m_cPPS.setListsModificationPresentFlag( true );
     
    10551004  m_cPPS.setSPSId( getLayerIdInVps() );
    10561005  m_cPPS.setPpsMultilayerExtensionFlag    ( true );
    1057 #if NH_3D
    1058   // Might be used for DLT
    1059   m_cPPS.setPps3dExtensionFlag            ( getIsDepth() );
    1060 #endif
    1061 #endif
    1062 
    1063 #if NH_3D_DLT
    1064   // create mapping from depth layer indexes to layer ids
    1065   Int j=0;
    1066   for( Int i=0; i<=getVPS()->getMaxLayersMinus1(); i++ )
    1067   {
    1068     Int layerId = getVPS()->getLayerIdInNuh(i);
    1069     if( getVPS()->getDepthId(layerId) )
    1070       m_cDLT.setDepthIdxToLayerId(j++, layerId);
    1071   }
    1072   m_cPPS.setDLT( m_cDLT );
    1073 #endif
     1006#endif
     1007
    10741008
    10751009  m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
     
    15421476#endif
    15431477
    1544 #if NH_3D_VSO
    1545 Void TEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset, Int maxCuHeight )
    1546 {
    1547   TRenModel* rendererModel = m_cRdCost.getRenModel();
    1548   rendererModel->setupPart( iHorOffset, std::min( maxCuHeight, (Int) ( m_iSourceHeight - iHorOffset ) )) ;
    1549  
    1550   Int iEncViewSIdx = m_cameraParameters->getBaseId2SortedId()[ iEncViewIdx ];
    1551 
    1552   // setup base views
    1553   Int iNumOfBV = m_renderModelParameters->getNumOfBaseViewsForView( iEncViewSIdx, iEncContent );
    1554 
    1555   for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ )
    1556   {
    1557     Int iBaseViewSIdx;
    1558     Int iVideoDistMode;
    1559     Int iDepthDistMode;
    1560 
    1561     m_renderModelParameters->getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode );
    1562 
    1563     AOT( iVideoDistMode < 0 || iVideoDistMode > 2 );
    1564 
    1565     Int iBaseViewIdx = m_cameraParameters->getBaseSortedId2Id()[ iBaseViewSIdx ];
    1566 
    1567     Int  auxId     =   getVPS()->getAuxId  ( getLayerId() );     
    1568     Bool depthFlag = ( getVPS()->getDepthId( getLayerId() ) == 1 );
    1569 
    1570     if( auxId == 0 && !depthFlag  )
    1571     {
    1572       // Defaults for texture layers
    1573 #if NH_3D
    1574       depthFlag = true;
    1575       auxId     = 0;
    1576 #else
    1577       depthFlag = false;
    1578       auxId     = 2;
    1579 #endif
    1580     }
    1581 
    1582     TComPicYuv* pcPicYuvVideoRec  = m_ivPicLists->getPicYuv( iBaseViewIdx, false    , 0    , iPoc, true  );
    1583     TComPicYuv* pcPicYuvDepthRec  = m_ivPicLists->getPicYuv( iBaseViewIdx, depthFlag, auxId, iPoc, true  );
    1584     TComPicYuv* pcPicYuvVideoOrg  = m_ivPicLists->getPicYuv( iBaseViewIdx, false,     0    , iPoc, false );
    1585     TComPicYuv* pcPicYuvDepthOrg  = m_ivPicLists->getPicYuv( iBaseViewIdx, depthFlag, auxId, iPoc, false );   
    1586 
    1587     TComPicYuv* pcPicYuvVideoRef  = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg  : NULL;
    1588     TComPicYuv* pcPicYuvDepthRef  = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg  : NULL;
    1589 
    1590     TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg  : pcPicYuvVideoRec;
    1591     TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg  : pcPicYuvDepthRec;
    1592 
    1593     AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) );
    1594     AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) );
    1595     AOT( pcPicYuvDepthTest == NULL );
    1596     AOT( pcPicYuvVideoTest == NULL );
    1597 
    1598     rendererModel->setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef );
    1599   }
    1600 
    1601   rendererModel->setErrorMode( iEncViewSIdx, iEncContent, 0 );
    1602   // setup virtual views
    1603   Int iNumOfSV  = m_renderModelParameters->getNumOfModelsForView( iEncViewSIdx, iEncContent );
    1604   for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ )
    1605   {
    1606     Int iOrgRefBaseViewSIdx;
    1607     Int iLeftBaseViewSIdx;
    1608     Int iRightBaseViewSIdx;
    1609     Int iSynthViewRelNum;
    1610     Int iModelNum;
    1611     Int iBlendMode;
    1612     m_renderModelParameters->getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum );
    1613 
    1614     Int iLeftBaseViewIdx    = -1;
    1615     Int iRightBaseViewIdx   = -1;
    1616 
    1617     TComPicYuv* pcPicYuvOrgRef  = NULL;
    1618     Int**      ppiShiftLUTLeft  = NULL;
    1619     Int**      ppiShiftLUTRight = NULL;
    1620     Int**      ppiBaseShiftLUTLeft  = NULL;
    1621     Int**      ppiBaseShiftLUTRight = NULL;
    1622 
    1623 
    1624     Int        iDistToLeft      = -1;
    1625 
    1626     Int iSynthViewIdx = m_cameraParameters->synthRelNum2Idx( iSynthViewRelNum );
    1627 
    1628     if ( iLeftBaseViewSIdx != -1 )
    1629     {
    1630       iLeftBaseViewIdx   = m_cameraParameters->getBaseSortedId2Id()   [ iLeftBaseViewSIdx ];
    1631       ppiShiftLUTLeft    = m_cameraParameters->getSynthViewShiftLUTI()[ iLeftBaseViewIdx  ][ iSynthViewIdx  ];
    1632     }
    1633 
    1634     if ( iRightBaseViewSIdx != -1 )
    1635     {
    1636       iRightBaseViewIdx  = m_cameraParameters->getBaseSortedId2Id()   [iRightBaseViewSIdx ];
    1637       ppiShiftLUTRight   = m_cameraParameters->getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ];
    1638     }
    1639 
    1640     if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 )
    1641     {
    1642       iDistToLeft          = m_cameraParameters->getRelDistLeft(  iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx);
    1643       ppiBaseShiftLUTLeft  = m_cameraParameters->getBaseViewShiftLUTI() [ iLeftBaseViewIdx  ][ iRightBaseViewIdx ];
    1644       ppiBaseShiftLUTRight = m_cameraParameters->getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx  ];
    1645 
    1646     }
    1647 
    1648     if ( iOrgRefBaseViewSIdx != -1 )
    1649     {
    1650       pcPicYuvOrgRef = m_ivPicLists->getPicYuv(  m_cameraParameters->getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , false, 0, iPoc, false );
    1651       AOF ( pcPicYuvOrgRef );
    1652     }
    1653 
    1654     rendererModel->setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef );
    1655   }
    1656 }
    1657 #endif
    16581478
    16591479//! \}
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibEncoder/TEncTop.h

    r1321 r1390  
    6565// ====================================================================================================================
    6666
    67 #if KWU_RC_MADPRED_E0227
    68 class TAppEncTop;
    69 #endif
    7067/// encoder class
    7168class TEncTop : public TEncCfg
     
    8279#if NH_MV
    8380  TComPicLists*           m_ivPicLists;                   ///< access to picture lists of other layers
    84 #endif
    85 #if NH_3D_IC
    86   Int *m_aICEnableCandidate;
    87   Int *m_aICEnableNum;
    8881#endif
    8982  // encoder search
     
    124117  TEncRateCtrl            m_cRateCtrl;                    ///< Rate control class
    125118
    126 #if KWU_RC_MADPRED_E0227
    127   TAppEncTop*             m_pcTAppEncTop;
    128   TAppComCamPara*         m_cCamParam;
    129 #endif
    130119#if NH_MV
    131120  TEncAnalyze             m_cAnalyzeAll;
     
    152141  Void      create          ();
    153142  Void      destroy         ();
    154 #if KWU_RC_MADPRED_E0227
    155   Void      init            ( TAppEncTop* pcTAppEncTop, Bool isFieldCoding );
    156 #else
    157143  Void      init            (Bool isFieldCoding);
    158 #endif
    159144#if NH_MV 
    160145  TComPicLists* getIvPicLists() { return m_ivPicLists; }
    161 #endif
    162 #if NH_3D_IC
    163   Int*      getICEnableCandidate() { return m_aICEnableCandidate; }
    164   Int*      getICEnableNum() { return m_aICEnableNum; }
    165146#endif
    166147  Void      deletePicBuffer ();
     
    194175  TEncSbac*               getRDGoOnSbacCoder    () { return  &m_cRDGoOnSbacCoder;     }
    195176  TEncRateCtrl*           getRateCtrl           () { return &m_cRateCtrl;             }
    196 #if KWU_RC_MADPRED_E0227
    197   TAppEncTop*             getEncTop             () { return m_pcTAppEncTop; }
    198   TAppComCamPara*         getCamParam()                 { return m_cCamParam;}
    199   Void                    setCamParam(TAppComCamPara * pCamparam)                 { m_cCamParam = pCamparam;}
    200 #endif
    201177  Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid );
    202178  Int getReferencePictureSetIdxForSOP(Int POCCurr, Int GOPid );
     
    210186  TComPic*                getPic                ( Int poc );
    211187  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
    212 #endif
    213 #if NH_3D
    214   Void                    setSps3dExtension     ( TComSps3dExtension sps3dExtension ) { m_cSPS.setSps3dExtension( sps3dExtension );  };
    215 #endif
    216 #if NH_3D_IC
    217   Void                    setICEnableCandidate         ( Int* ICEnableCandidate) { m_aICEnableCandidate = ICEnableCandidate; }
    218   Void                    setICEnableNum         ( Int* ICEnableNum) { m_aICEnableNum = ICEnableNum; }
    219188#endif
    220189  // -------------------------------------------------------------------------------------------------------------------
     
    250219  Void printSummary(Bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField, m_printMSEBasedSequencePSNR, m_printSequenceMSE, m_cSPS.getBitDepths()); }
    251220
    252 #if NH_3D_VSO
    253    Void setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset, Int maxCuHeight );
    254 #endif
    255221};
    256222
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenFilter.cpp

    r1386 r1390  
    3636#include "TRenFilter.h"
    3737#include "TRenInterpFilter.h"
    38 #if NH_3D_VSO
    3938
    40 ///// COMMON /////