Changeset 1072 in 3DVCSoftware


Ignore:
Timestamp:
13 Oct 2014, 16:44:51 (12 years ago)
Author:
tech
Message:

Removed 3D-HEVC related integrations.

Location:
branches/HTM-12.1-MV-draft-1
Files:
3 deleted
90 edited

Legend:

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

    r1066 r1072  
    6868  string cfg_ReconFile;
    6969  string cfg_TargetDecLayerIdSetFile;
    70 #if H_3D
    71   string cfg_ScaleOffsetFile;
    72 #endif
    7370
    7471  po::Options opts;
     
    7875  ("ReconFile,o",     cfg_ReconFile,     string(""), "reconstructed YUV output file name\n"
    7976                                                     "YUV writing is skipped if omitted")
    80 #if H_3D
    81   ("ScaleOffsetFile,p", cfg_ScaleOffsetFile, string(""), "file with coded scales and offsets")
    82 #endif
    8377  ("SkipFrames,s", m_iSkipFrame, 0, "number of frames to skip before random access")
    8478  ("OutputBitDepth,d", m_outputBitDepthY, 0, "bit depth of YUV output luma component (default: use 0 for native depth)")
     
    118112  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
    119113
    120 #if H_3D
    121   m_pchScaleOffsetFile = cfg_ScaleOffsetFile.empty() ? NULL : strdup(cfg_ScaleOffsetFile.c_str());
    122 #endif
    123114  if (!m_pchBitstreamFile)
    124115  {
  • branches/HTM-12.1-MV-draft-1/source/App/TAppDecoder/TAppDecCfg.h

    r1066 r1072  
    6363#endif
    6464  Char*         m_pchReconFile;                       ///< output reconstruction file name
    65 #if H_3D
    66   Char*         m_pchScaleOffsetFile;                 ///< output coded scale and offset parameters
    67 #endif
    6865  Int           m_iSkipFrame;                         ///< counter for frames prior to the random access point to skip
    6966  Int           m_outputBitDepthY;                    ///< bit depth used for writing output (luma)
  • branches/HTM-12.1-MV-draft-1/source/App/TAppDecoder/TAppDecTop.cpp

    r1066 r1072  
    6767  }
    6868#endif
    69 #if H_3D
    70     m_pScaleOffsetFile  = 0;
    71 #endif
    7269
    7370#if H_MV
     
    103100    m_pchReconFile = NULL;
    104101  }
    105 #if H_3D
    106   if (m_pchScaleOffsetFile)
    107   {
    108     free (m_pchScaleOffsetFile);
    109     m_pchScaleOffsetFile = NULL;
    110   }
    111 #endif
    112102}
    113103
     
    139129  }
    140130
    141 #if H_3D
    142   if( m_pchScaleOffsetFile )
    143   {
    144     m_pScaleOffsetFile = ::fopen( m_pchScaleOffsetFile, "wt" );
    145     AOF( m_pScaleOffsetFile );
    146   }
    147 #endif
    148131  InputByteStream bytestream(bitstreamFile);
    149132
     
    269252#endif
    270253        }
    271 #if H_3D
    272         if (nalu.m_nalUnitType == NAL_UNIT_VPS )
    273         {                 
    274           m_cCamParsCollector.init( m_pScaleOffsetFile, m_tDecTop[decIdx]->getPrefetchedVPS() );
    275         }       
    276 #endif
    277254        bNewPicture       = ( newSliceDiffLayer || newSliceDiffPoc ) && !sliceSkippedFlag;
    278255        if ( nalu.isSlice() && firstSlice && !sliceSkippedFlag )       
     
    350327#endif
    351328#endif
    352 #if H_3D
    353     if ( allLayersDecoded || !bitstreamFile )
    354     {
    355       for( Int dI = 0; dI < m_numDecoders; dI++ )
    356       {
    357         TComPic* picLastCoded = m_ivPicLists.getPic( m_tDecTop[dI]->getLayerId(), pocLastPic );
    358         assert( picLastCoded != NULL );       
    359         picLastCoded->compressMotion(1);
    360       }
    361     }
    362 #endif
    363329
    364330    if( pcListPic )
     
    473439  }
    474440#if H_MV
    475 #if H_3D
    476   if( m_cCamParsCollector.isInitialized() )
    477   {
    478     m_cCamParsCollector.setSlice( 0 );
    479   }
    480 #endif
    481441  for(UInt decIdx = 0; decIdx < m_numDecoders; decIdx++)
    482442  {
     
    502462  // initialize global variables
    503463  initROM(); 
    504 #if H_3D_DIM_DMM
    505   initWedgeLists();
    506 #endif
    507464#else
    508465  // create decoder class
     
    542499  // destroy decoder class
    543500  m_cTDecTop.destroy();
    544 #endif
    545 #if H_3D
    546   m_cCamParsCollector.uninit();
    547   if( m_pScaleOffsetFile )
    548   {
    549     ::fclose( m_pScaleOffsetFile );
    550   }
    551501#endif
    552502}
     
    10601010    m_tDecTop[ decIdx ]->setTargetOptLayerSetIdx( m_targetOptLayerSetIdx );   
    10611011
    1062 #if H_3D
    1063    m_tDecTop[ decIdx ]->setCamParsCollector( &m_cCamParsCollector );
    1064 #endif
    10651012
    10661013    // append pic list of new decoder to PicLists
  • branches/HTM-12.1-MV-draft-1/source/App/TAppDecoder/TAppDecTop.h

    r976 r1072  
    8282#endif
    8383
    84 #if H_3D
    85   FILE*                           m_pScaleOffsetFile;
    86   CamParsCollector                m_cCamParsCollector;
    87 #endif
    8884public:
    8985  TAppDecTop();
  • branches/HTM-12.1-MV-draft-1/source/App/TAppEncoder/TAppEncCfg.cpp

    r1066 r1072  
    8383  m_targetPivotValue = NULL;
    8484
    85 #if KWU_RC_MADPRED_E0227
    86   m_depthMADPred = 0;
    87 #endif
    8885}
    8986
     
    151148    }
    152149  }
    153 #endif
    154 #if H_3D
    155 #if H_3D_VSO
    156   if (  m_pchVSOConfig != NULL)
    157     free (  m_pchVSOConfig );
    158 #endif
    159   if ( m_pchCameraParameterFile != NULL )
    160     free ( m_pchCameraParameterFile );
    161 
    162   if ( m_pchBaseViewCameraNumbers != NULL )
    163     free ( m_pchBaseViewCameraNumbers );
    164150#endif
    165151}
     
    243229#if H_MV_HLS10_PTL
    244230  {"multiview-main", Profile::MULTIVIEWMAIN},
    245 #if H_3D
    246   {"3d-main"       , Profile::MAIN3D},
    247 #endif
    248231
    249232#else
    250233  {"main-stereo",    Profile::MAINSTEREO},
    251234  {"main-multiview", Profile::MAINMULTIVIEW},
    252 #if H_3D
    253   {"main-3d"    , Profile::MAIN3D},
    254 #endif
    255235#endif
    256236#endif
     
    346326  string        cfg_tiers;
    347327#endif
    348 #if H_3D
    349   cfg_dimensionLength.push_back( 2  );  // depth
    350   cfg_dimensionLength.push_back( 32 );  // texture
    351 #else
    352328  cfg_dimensionLength.push_back( 64 );
    353 #endif
    354329#endif
    355330  string cfg_dQPFile;
     
    379354#if H_MV
    380355  ("NumberOfLayers",        m_numberOfLayers     , 1,                     "Number of layers")
    381 #if !H_3D
    382356#if H_MV_HLS10_AUX
    383357  ("ScalabilityMask",       m_scalabilityMask    , 2                    , "Scalability Mask: 2: Multiview, 8: Auxiliary, 10: Multiview + Auxiliary")   
     
    385359  ("ScalabilityMask",       m_scalabilityMask    , 2                    , "Scalability Mask")   
    386360#endif
    387 #else
    388   ("ScalabilityMask",       m_scalabilityMask    , 3                    , "Scalability Mask, 1: Texture 3: Texture + Depth ")   
    389 #endif 
    390361  ("DimensionIdLen",        m_dimensionIdLen     , cfg_dimensionLength  , "Number of bits used to store dimensions Id")
    391362  ("ViewOrderIndex",        m_viewOrderIndex     , std::vector<Int>(1,0), "View Order Index per layer")
     
    393364#if H_MV_HLS10_AUX
    394365  ("AuxId",                 m_auxId              , std::vector<Int>(1,0), "AuxId per layer")
    395 #endif
    396 #if H_3D
    397   ("DepthFlag",             m_depthFlag          , std::vector<Int>(1,0), "Depth Flag")
    398 #if H_3D_DIM
    399   ("DMM",                   m_useDMM,           true,  "Depth intra model modes")
    400 #if SEPARATE_FLAG_I0085
    401   ("IVP",                   m_useIVP,           true,  "intra-view prediction")
    402 #endif
    403   ("SDC",                   m_useSDC,           true,  "Simplified depth coding")
    404   ("DLT",                   m_useDLT,           true,  "Depth lookup table")
    405 #endif
    406 #if MTK_SINGLE_DEPTH_MODE_I0095
    407   ("SingleDepthMode",    m_useSingleDepthMode, true, "Single depth mode")                         
    408 #endif
    409366#endif
    410367#if H_MV_HLS10_GEN_FIX
     
    555512  ("DeblockingFilterMetric",         m_DeblockingFilterMetric,         false )
    556513
    557 #if H_3D_ARP
    558   ("AdvMultiviewResPred",      m_uiUseAdvResPred,           (UInt)1, "Usage of Advanced Residual Prediction" )
    559 #endif
    560 #if H_3D_SPIVMP
    561   ("SubPULog2Size", m_iSubPULog2Size, (Int)3, "Sub-PU size index: 2^n")
    562   ("SubPUMPILog2Size", m_iSubPUMPILog2Size, (Int)3, "Sub-PU MPI size index: 2^n")
    563 #endif
    564 #if H_3D_IC
    565   ("IlluCompEnable",           m_abUseIC, true, "Enable illumination compensation")
    566   ("IlluCompLowLatencyEnc",    m_bUseLowLatencyICEnc, false, "Enable low-latency illumination compensation encoding")
    567 #endif
    568 #if H_3D_INTER_SDC
    569   ("InterSDC",                 m_bDepthInterSDCFlag,        true, "Enable depth inter SDC")
    570 #endif
    571 #if H_3D_DBBP
    572   ("DBBP",                     m_bUseDBBP,   true, "Enable depth-based block partitioning" )
    573 #endif
    574 #if H_3D_IV_MERGE
    575   ("MPI",                      m_bMPIFlag,        true, "Enable MPI")
    576 #endif
    577514  // Coding tools
    578515  ("AMP",                      m_enableAMP,                 true,  "Enable asymmetric motion partitions")
     
    642579  ( "RCForceIntraQP",      m_RCForceIntraQP,        false, "Rate control: force intra QP to be equal to initial QP" )
    643580
    644 #if KWU_RC_VIEWRC_E0227
    645   ("ViewWiseTargetBits, -vtbr" ,  m_viewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
    646   ("TargetBitAssign, -ta", m_viewWiseRateCtrl, false, "View-wise rate control on/off")
    647 #endif
    648 #if KWU_RC_MADPRED_E0227
    649   ("DepthMADPred, -dm", m_depthMADPred, (UInt)0, "Depth based MAD prediction on/off")
    650 #endif
    651581#if H_MV
    652582#if H_MV_HLS10_GEN_FIX
     
    790720#endif
    791721#endif
    792 #if H_3D
    793   ("CameraParameterFile,cpf", m_pchCameraParameterFile,    (Char *) 0, "Camera Parameter File Name")
    794   ("BaseViewCameraNumbers" ,  m_pchBaseViewCameraNumbers,  (Char *) 0, "Numbers of base views")
    795   ("CodedCamParsPrecision",   m_iCodedCamParPrecision,  STD_CAM_PARAMETERS_PRECISION, "precision for coding of camera parameters (in units of 2^(-x) luma samples)" )
    796 /* View Synthesis Optimization */
    797 
    798 #if H_3D_VSO
    799   ("VSOConfig",                       m_pchVSOConfig            , (Char *) 0    , "VSO configuration")
    800   ("VSO",                             m_bUseVSO                 , false         , "Use VSO" )   
    801   ("VSOMode",                         m_uiVSOMode               , (UInt)   4    , "VSO Mode")
    802   ("LambdaScaleVSO",                  m_dLambdaScaleVSO         , (Double) 1    , "Lambda Scaling for VSO")
    803   ("VSOLSTable",                      m_bVSOLSTable             , true          , "Depth QP dependent video/depth rate allocation by Lagrange multiplier" )     
    804   ("ForceLambdaScaleVSO",             m_bForceLambdaScaleVSO    , false         , "Force using Lambda Scale VSO also in non-VSO-Mode")
    805   ("AllowNegDist",                    m_bAllowNegDist           , true          , "Allow negative Distortion in VSO")
    806  
    807   ("UseEstimatedVSD",                 m_bUseEstimatedVSD        , true          , "Model based VSD estimation instead of rendering based for some encoder decisions" )     
    808   ("VSOEarlySkip",                    m_bVSOEarlySkip           , true          , "Early skip of VSO computation if synthesis error assumed to be zero" )     
    809  
    810   ("WVSO",                            m_bUseWVSO                , true          , "Use depth fidelity term for VSO" )
    811   ("VSOWeight",                       m_iVSOWeight              , 10            , "Synthesized View Distortion Change weight" )
    812   ("VSDWeight",                       m_iVSDWeight              , 1             , "View Synthesis Distortion estimate weight" )
    813   ("DWeight",                         m_iDWeight                , 1             , "Depth Distortion weight" )
    814 
    815 #endif //HHI_VSO
    816 #if MTK_I0099_VPS_EX2
    817   ("LimQtPredFlag",                   m_bLimQtPredFlag          , true          , "Use Predictive Coding with QTL" )
    818 #endif
    819 #if !MTK_I0099_VPS_EX2 || MTK_I0099_FIX
    820 #if H_3D_QTLPC
    821   ("QTL",                             m_bUseQTL                 , true          , "Use depth Quadtree Limitation" )
    822 #if !MTK_I0099_VPS_EX2
    823   ("PC",                              m_bUsePC                  , true          , "Use Predictive Coding with QTL" )
    824 #endif
    825 #endif
    826 #endif
    827 #if H_3D_IV_MERGE
    828   ("IvMvPred",                        m_ivMvPredFlag            , std::vector<Bool>(2, true)            , "inter view motion prediction " )
    829 #endif
    830 #if H_3D_NBDV_REF
    831   ("DepthRefinement",                 m_depthRefinementFlag,    true           , "depth refinement by DoNBDV" ) 
    832 #endif
    833 #if H_3D_VSP
    834   ("ViewSynthesisPred",               m_viewSynthesisPredFlag,  true           , "view synthesis prediction " ) 
    835 #endif
    836 #if H_3D
    837   ("IvMvScaling",                     m_ivMvScalingFlag      ,  true            , "inter view motion vector scaling" )   
    838 #endif
    839 #endif //H_3D
    840722  ;
    841723
     
    1086968#endif
    1087969
    1088 #if H_3D
    1089   xResizeVector( m_depthFlag );
    1090 #endif
    1091970  xResizeVector( m_fQP );
    1092971
     
    12391118  if( cfg_profiles.empty() )
    12401119  {
    1241 #if H_3D
    1242     cfg_profiles = string("main main 3d-main");
    1243 #else
    12441120    cfg_profiles = string("main main multiview-main");   
    1245 #endif
    12461121    fprintf(stderr, "\nWarning: No profiles given, using defaults: %s", cfg_profiles.c_str() );
    12471122    anyEmpty = true;
     
    12831158#endif
    12841159#endif
    1285 #if H_3D
     1160  // check validity of input parameters
     1161  xCheckParameter();
     1162
    12861163  // set global varibles
    12871164  xSetGlobal();
    1288 #if H_3D_VSO
    1289 // Table base optimization
    1290   // Q&D
    1291   Double adLambdaScaleTable[] =
    1292   {  0.031250, 0.031639, 0.032029, 0.032418, 0.032808, 0.033197, 0.033586, 0.033976, 0.034365, 0.034755,
    1293      0.035144, 0.035533, 0.035923, 0.036312, 0.036702, 0.037091, 0.037480, 0.037870, 0.038259, 0.038648,
    1294      0.039038, 0.039427, 0.039817, 0.040206, 0.040595, 0.040985, 0.041374, 0.041764, 0.042153, 0.042542,
    1295      0.042932, 0.043321, 0.043711, 0.044100, 0.044194, 0.053033, 0.061872, 0.070711, 0.079550, 0.088388,
    1296      0.117851, 0.147314, 0.176777, 0.235702, 0.294628, 0.353553, 0.471405, 0.589256, 0.707107, 0.707100,
    1297      0.753550, 0.800000 
    1298   };
    1299   if ( m_bUseVSO && m_bVSOLSTable )
    1300   {
    1301     Int firstDepthLayer = -1;
    1302     for (Int layer = 0; layer < m_numberOfLayers; layer++ )
    1303     {
    1304       if ( m_depthFlag[ layer ])
    1305       {
    1306         firstDepthLayer = layer;
    1307         break;
    1308       }
    1309     }
    1310     AOT( firstDepthLayer == -1 );
    1311     AOT( (m_iQP[firstDepthLayer] < 0) || (m_iQP[firstDepthLayer] > 51));
    1312     m_dLambdaScaleVSO *= adLambdaScaleTable[m_iQP[firstDepthLayer]];
    1313   }
    1314 #endif
    1315 #if H_3D_VSO
    1316 if ( m_bUseVSO && m_uiVSOMode == 4)
    1317 {
    1318   m_cRenModStrParser.setString( m_iNumberOfViews, m_pchVSOConfig );
    1319   m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ),
    1320                                       g_bitDepthY,
    1321                                 (UInt)m_iCodedCamParPrecision,
    1322                                       m_FrameSkip,
    1323                                 (UInt)m_framesToBeEncoded,
    1324                                       m_pchCameraParameterFile,
    1325                                       m_pchBaseViewCameraNumbers,
    1326                                       NULL,
    1327                                       m_cRenModStrParser.getSynthViews(),
    1328                                       LOG2_DISP_PREC_LUT );
    1329 }
    1330 else if ( m_bUseVSO && m_uiVSOMode != 4 )
    1331 {
    1332   m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ),
    1333                                       g_bitDepthY,
    1334                                 (UInt)m_iCodedCamParPrecision,
    1335                                       m_FrameSkip,
    1336                                 (UInt)m_framesToBeEncoded,
    1337                                       m_pchCameraParameterFile,
    1338                                       m_pchBaseViewCameraNumbers,
    1339                                       m_pchVSOConfig,
    1340                                       NULL,
    1341                                       LOG2_DISP_PREC_LUT );
    1342 }
    1343 else
    1344 {
    1345   m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ),
    1346     g_bitDepthY,
    1347     (UInt) m_iCodedCamParPrecision,
    1348     m_FrameSkip,
    1349     (UInt) m_framesToBeEncoded,
    1350     m_pchCameraParameterFile,
    1351     m_pchBaseViewCameraNumbers,
    1352     NULL,
    1353     NULL,
    1354     LOG2_DISP_PREC_LUT );
    1355 }
    1356 #else
    1357   m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ),
    1358     g_bitDepthY,
    1359     (UInt) m_iCodedCamParPrecision,
    1360     m_FrameSkip,
    1361     (UInt) m_framesToBeEncoded,
    1362     m_pchCameraParameterFile,
    1363     m_pchBaseViewCameraNumbers,
    1364     NULL,
    1365     NULL,
    1366     LOG2_DISP_PREC_LUT );
    1367 #endif
    1368   m_cCameraData.check( false, true );
    1369 #endif
    1370   // check validity of input parameters
    1371   xCheckParameter();
    1372 
    1373 #if !H_3D
    1374   // set global varibles
    1375   xSetGlobal();
    1376 #endif
    13771165 
    13781166  // print-out parameters
     
    14281216  xConfirmPara( (m_layerIdInNuh.size()!=1) && (m_layerIdInNuh.size() < m_numberOfLayers) , "LayerIdInNuh must be given for all layers. ");
    14291217 
    1430 #if H_3D
    1431   xConfirmPara( m_scalabilityMask != 2 && m_scalabilityMask != 3, "Scalability Mask must be equal to 2 or 3. ");
    1432 #else
    14331218#if H_MV_HLS10_AUX
    14341219  xConfirmPara( m_scalabilityMask != 2 && m_scalabilityMask != 8 && m_scalabilityMask != 10, "Scalability Mask must be equal to 2, 8 or 10");
     
    14361221  xConfirmPara( m_scalabilityMask != 2 , "Scalability Mask must be equal to 2. ");
    14371222#endif
    1438 #endif
    1439 
    1440 #if H_3D
    1441   if ( m_scalabilityMask & ( 1 << DEPTH_ID ) )
    1442   {
    1443     m_dimIds.push_back( m_depthFlag );
    1444   }
    1445 #endif
     1223
    14461224
    14471225  m_dimIds.push_back( m_viewOrderIndex );   
     
    15121290     xConfirmPara( allEqual , "Each layer shall have a different position in scalability space." );
    15131291
    1514 #if !H_3D_FCO
    15151292     if ( numDiff  == 1 )
    15161293     {
     
    15231300       xConfirmPara( shallBeButIsNotIncreasing,  "DimensionIds shall be increasing within one dimension. " );
    15241301     }
    1525 #endif
    15261302   }
    15271303 }
     
    17251501  xConfirmPara(  m_maxNumMergeCand > 5,  "MaxNumMergeCand must be 5 or smaller.");
    17261502
    1727 #if H_3D_ARP
    1728   xConfirmPara( ( 0 != m_uiUseAdvResPred ) &&  ( 1 != m_uiUseAdvResPred ), "UseAdvResPred must be 0 or 1." );
    1729 #endif
    1730 #if H_3D_SPIVMP
    1731   xConfirmPara( m_iSubPULog2Size < 3,                                        "SubPULog2Size must be 3 or greater.");
    1732   xConfirmPara( m_iSubPULog2Size > 6,                                        "SubPULog2Size must be 6 or smaller.");
    1733   xConfirmPara( (1<<m_iSubPULog2Size) > m_uiMaxCUWidth,                      "SubPULog2Size must be log2(maxCUSize) or smaller.");
    1734  
    1735   xConfirmPara( m_iSubPUMPILog2Size < 3,                                        "SubPUMPILog2Size must be 3 or greater.");
    1736   xConfirmPara( m_iSubPUMPILog2Size > 6,                                        "SubPUMPILog2Size must be 6 or smaller.");
    1737   xConfirmPara( ( 1 << m_iSubPUMPILog2Size ) > m_uiMaxCUWidth,                  "SubPUMPILog2Size must be log2(maxCUSize) or smaller.");
    1738 #endif
    17391503#if ADAPTIVE_QP_SELECTION
    17401504#if H_MV
     
    17831547  xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
    17841548
    1785 #if H_3D
    1786   xConfirmPara( m_pchCameraParameterFile    == 0                ,   "CameraParameterFile must be given");
    1787   xConfirmPara( m_pchBaseViewCameraNumbers  == 0                ,   "BaseViewCameraNumbers must be given" );
    1788 #if BUG_FIX_TK65
    1789   xConfirmPara( ( ((UInt) m_numberOfLayers >> 1 ) != m_cCameraData.getBaseViewNumbers().size() ) && ( m_numberOfLayers != m_cCameraData.getBaseViewNumbers().size() ),   "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" );
    1790 #else
    1791   xConfirmPara( ((UInt) m_numberOfLayers >> 1 ) != m_cCameraData.getBaseViewNumbers().size(),   "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" );
    1792 #endif
    1793   xConfirmPara    ( m_iCodedCamParPrecision < 0 || m_iCodedCamParPrecision > 5,       "CodedCamParsPrecision must be in range of 0..5" );
    1794 #if H_3D_VSO
    1795     if( m_bUseVSO )
    1796     {
    1797       xConfirmPara(   m_pchVSOConfig            == 0                             ,   "VSO Setup string must be given");
    1798       xConfirmPara( m_uiVSOMode > 4 ,                                                "VSO Mode must be less than 5");
    1799     }
    1800 #endif
    1801 #endif
    18021549  // max CU width and height should be power of 2
    18031550  UInt ui = m_uiMaxCUWidth;
     
    25122259#endif
    25132260#endif
    2514 #if H_3D
    2515   xPrintParaVector( "DepthFlag", m_depthFlag );
    2516   printf("Coded Camera Param. Precision: %d\n", m_iCodedCamParPrecision);
    2517 #endif
    25182261#if H_MV 
    25192262  xPrintParaVector( "QP"               , m_fQP                );
     
    25752318    printf("ForceIntraQP                 : %d\n", m_RCForceIntraQP );
    25762319
    2577 #if KWU_RC_MADPRED_E0227
    2578     printf("Depth based MAD prediction   : %d\n", m_depthMADPred);
    2579 #endif
    2580 #if KWU_RC_VIEWRC_E0227
    2581     printf("View-wise Rate control       : %d\n", m_viewWiseRateCtrl);
    2582     if(m_viewWiseRateCtrl)
    2583     {
    2584 
    2585       printf("ViewWiseTargetBits           : ");
    2586       for (Int i = 0 ; i < m_iNumberOfViews ; i++)
    2587         printf("%d ", m_viewTargetBits[i]);
    2588       printf("\n");
    2589     }
    2590     else
    2591     {
    2592       printf("TargetBitrate                : %d\n", m_RCTargetBitrate );
    2593     }
    2594 #endif
    25952320  }
    25962321  printf("Max Num Merge Candidates     : %d\n", m_maxNumMergeCand);
    2597 #if H_3D
    2598   printf("BaseViewCameraNumbers        : %s\n", m_pchBaseViewCameraNumbers );
    2599   printf("Coded Camera Param. Precision: %d\n", m_iCodedCamParPrecision);
    2600 #if H_3D_VSO
    2601   printf("Force use of Lambda Scale    : %d\n", m_bForceLambdaScaleVSO );
    2602 
    2603   if ( m_bUseVSO )
    2604   {   
    2605     printf("VSO Lambda Scale             : %5.2f\n", m_dLambdaScaleVSO );
    2606     printf("VSO Mode                     : %d\n",    m_uiVSOMode       );
    2607     printf("VSO Config                   : %s\n",    m_pchVSOConfig    );
    2608     printf("VSO Negative Distortion      : %d\n",    m_bAllowNegDist ? 1 : 0);
    2609     printf("VSO LS Table                 : %d\n",    m_bVSOLSTable ? 1 : 0);
    2610     printf("VSO Estimated VSD            : %d\n",    m_bUseEstimatedVSD ? 1 : 0);
    2611     printf("VSO Early Skip               : %d\n",    m_bVSOEarlySkip ? 1 : 0);   
    2612     if ( m_bUseWVSO )
    2613     printf("Dist. Weights (VSO/VSD/SAD)  : %d/%d/%d\n ", m_iVSOWeight, m_iVSDWeight, m_iDWeight );
    2614   }
    2615 #endif //HHI_VSO
    2616 #endif //H_3D
    26172322  printf("\n");
    26182323#if H_MV
     
    26722377  printf(" SignBitHidingFlag:%d ", m_signHideFlag);
    26732378  printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 );
    2674 #if H_3D_VSO
    2675   printf("VSO:%d ", m_bUseVSO   );
    2676   printf("WVSO:%d ", m_bUseWVSO ); 
    2677 #endif
    2678 #if MTK_I0099_VPS_EX2
    2679   printf("LimQtPredFlag:%d ", m_bLimQtPredFlag ? 1 : 0);
    2680 #endif
    2681 #if !MTK_I0099_VPS_EX2 || MTK_I0099_FIX
    2682 #if H_3D_QTLPC
    2683   printf("QTL:%d ", m_bUseQTL);
    2684 #if !MTK_I0099_VPS_EX2
    2685   printf("PC:%d " , m_bUsePC );
    2686 #endif
    2687 #endif
    2688 #endif
    2689 #if H_3D_IV_MERGE
    2690   printf("IvMvPred:%d %d", m_ivMvPredFlag[0] ? 1 : 0, m_ivMvPredFlag[1] ? 1 : 0);
    2691 #if H_3D_SPIVMP
    2692   printf(" SubPULog2Size:%d  " , m_iSubPULog2Size  );
    2693   printf(" SubPUMPILog2Size:%d  " , m_iSubPUMPILog2Size  );
    2694 #endif
    2695 #endif
    2696 #if H_3D_ARP
    2697   printf(" ARP:%d  ", m_uiUseAdvResPred  );
    2698 #endif
    2699 #if H_3D_IC
    2700   printf( "IlluCompEnable:%d ", m_abUseIC);
    2701   printf ("IlluCompLowLatencyEnc:%d ",  m_bUseLowLatencyICEnc);
    2702 #endif
    2703 #if H_3D_NBDV_REF
    2704   printf("DepthRefinement:%d ", m_depthRefinementFlag ); 
    2705 #endif
    2706 #if H_3D_VSP
    2707   printf("ViewSynthesisPred:%d ", m_viewSynthesisPredFlag );
    2708 #endif
    2709 #if H_3D
    2710   printf("IvMvScaling:%d ", m_ivMvScalingFlag ? 1 : 0  );
    2711 #endif
    2712 #if H_3D_DIM
    2713   printf("DMM:%d ", m_useDMM );
    2714 #if SEPARATE_FLAG_I0085
    2715   printf("IVP:%d ", m_useIVP );
    2716 #endif
    2717   printf("SDC:%d ", m_useSDC );
    2718   printf("DLT:%d ", m_useDLT );
    2719 #endif
    2720 #if MTK_SINGLE_DEPTH_MODE_I0095
    2721   printf("SingleDepthMode:%d ",    m_useSingleDepthMode);
    2722 #endif
    2723 #if H_3D_INTER_SDC
    2724   printf( "interSDC:%d ", m_bDepthInterSDCFlag ? 1 : 0 );
    2725 #endif
    2726 #if H_3D_DBBP
    2727   printf("DBBP:%d ", m_bUseDBBP ? 1 : 0);
    2728 #endif
    2729 #if H_3D_IV_MERGE
    2730   printf( "MPI:%d ", m_bMPIFlag ? 1 : 0 );
    2731 #endif
    27322379  printf("\n\n"); 
    27332380
  • branches/HTM-12.1-MV-draft-1/source/App/TAppEncoder/TAppEncCfg.h

    r1066 r1072  
    4343#include "TLibEncoder/TEncCfg.h"
    4444#include <sstream>
    45 #if H_3D
    46 #include "TAppCommon/TAppComCamPara.h"
    47 #include "TLibRenderer/TRenModel.h"
    48 #include "TLibRenderer/TRenModSetupStrParser.h"
    49 #endif
    5045//! \ingroup TAppEncoder
    5146//! \{
     
    8075#if H_MV_HLS10_AUX
    8176  std::vector<Int>       m_auxId;                             ///< auxiliary id
    82 #endif
    83 #if H_3D
    84   std::vector<Int>       m_depthFlag;                         ///< depth flag
    8577#endif
    8678#if H_MV_HLS10_GEN_FIX
     
    144136
    145137
    146 #if H_3D_IV_MERGE
    147   vector<Bool>           m_ivMvPredFlag;                      ///< Interview motion vector prediction
    148 #if H_3D_SPIVMP
    149   Int                    m_iSubPULog2Size;                   
    150   Int                    m_iSubPUMPILog2Size;                   
    151 #endif
    152 #endif
    153 #if MTK_I0099_VPS_EX2
    154   Bool                   m_bLimQtPredFlag;
    155 #endif
    156 #if H_3D_ARP                                                  /// < flag and number of weighting factors in ARP
    157   UInt                   m_uiUseAdvResPred;
    158   UInt                   m_uiARPStepNum;
    159 #endif
    160 #if H_3D_IC
    161   Bool   m_abUseIC;
    162   Bool   m_bUseLowLatencyICEnc;
    163 #endif
    164 #if H_3D_NBDV_REF
    165   Bool m_depthRefinementFlag; 
    166 #endif
    167 #if H_3D_VSP
    168   Bool m_viewSynthesisPredFlag;
    169 #endif
    170 #if H_3D
    171   Bool m_ivMvScalingFlag;
    172 #endif
    173138#endif
    174139  Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
     
    409374  Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
    410375
    411 #if KWU_RC_VIEWRC_E0227
    412   vector<Int>     m_viewTargetBits;
    413   Bool      m_viewWiseRateCtrl;                              ///< Flag for using view-wise rate control
    414 #endif
    415 #if KWU_RC_MADPRED_E0227
    416   UInt       m_depthMADPred;
    417 #endif
    418376  Int       m_useScalingListId;                               ///< using quantization matrix
    419377  Char*     m_scalingListFile;                                ///< quantization matrix file name
     
    472430#endif
    473431#endif
    474 #if H_3D
    475   // Camera parameters
    476   Char*     m_pchCameraParameterFile;                         ///< camera parameter file
    477   Char*     m_pchBaseViewCameraNumbers;
    478   TAppComCamPara m_cCameraData;
    479   Int       m_iCodedCamParPrecision;                          ///< precision for coding of camera parameters
    480 #if H_3D_VSO
    481   Char*     m_pchVSOConfig;
    482   Bool      m_bUseVSO;                                    ///< flag for using View Synthesis Optimization
    483   Bool      m_bVSOLSTable;                                ///< Depth QP dependent Lagrange parameter optimization (m23714)
    484   Bool      m_bVSOEarlySkip;                              ///< Early skip of VSO computation (JCT3V-A0093 modification 4)
    485 
    486   //// Used for development by GT, might be removed later
    487   Double    m_dLambdaScaleVSO;                            ///< Scaling factor for Lambda in VSO mode
    488   Bool      m_bForceLambdaScaleVSO;                       ///< Use Lambda Scale for depth even if VSO is turned off
    489   Bool      m_bAllowNegDist;                              ///< Allow negative distortion in VSO
    490   UInt      m_uiVSOMode;                                  ///< Number of VSO Mode, 1 = , 2 = simple, org vs. ren, 3 = simple, ren vs. ren, 4 = full 
    491 
    492   // SAIT_VSO_EST_A0033
    493   Bool      m_bUseEstimatedVSD;                           ///< Flag for using model based VSD estimation instead of VSO for some encoder decisions (JCT3V-A0033 modification 3) 
    494 
    495   // LGE_WVSO_A0119
    496   Bool      m_bUseWVSO;                                    ///< flag for using View Synthesis Optimization 
    497   Int       m_iVSOWeight;
    498   Int       m_iVSDWeight;
    499   Int       m_iDWeight;
    500 
    501   // Ren Model String
    502   TRenModSetupStrParser       m_cRenModStrParser;
    503 #endif
    504 #if H_3D_DIM
    505   Bool      m_useDMM;                                        ///< flag for using DMM
    506 #if SEPARATE_FLAG_I0085
    507   Bool      m_useIVP;
    508 #endif
    509   Bool      m_useSDC;                                        ///< flag for using SDC
    510   Bool      m_useDLT;                                        ///< flag for using DLT
    511 #endif
    512 #if MTK_SINGLE_DEPTH_MODE_I0095
    513   Bool     m_useSingleDepthMode;                          ///< flag for using single depth mode
    514 #endif
    515 #if !MTK_I0099_VPS_EX2 || MTK_I0099_FIX
    516 #if H_3D_QTLPC
    517   Bool      m_bUseQTL;                                        ///< flag for using depth QuadTree Limitation
    518 #if !MTK_I0099_VPS_EX2
    519   Bool      m_bUsePC;                                         ///< flag for using Predictive Coding with QTL
    520 #endif
    521 #endif
    522 #endif
    523 #if H_3D_INTER_SDC
    524   Bool m_bDepthInterSDCFlag;                                ///< flag for inter SDC of depth map coding
    525 #endif
    526 #if H_3D_DBBP
    527   Bool      m_bUseDBBP;                                     ///< flag for depth-based block partitioning
    528 #endif
    529 #if H_3D_IV_MERGE
    530   Bool m_bMPIFlag;                                           ///< flag for MPI of depth map coding
    531 #endif
    532 #endif
    533432  // internal member functions
    534433  Void  xSetGlobal      ();                                   ///< set global variables
  • branches/HTM-12.1-MV-draft-1/source/App/TAppEncoder/TAppEncTop.cpp

    r1066 r1072  
    8686#endif
    8787 
    88 #if H_3D
    89   vps.createCamPars(m_iNumberOfViews);
    90   TComDLT& dlt = m_dlt;
    91 #endif
    9288
    9389#if H_MV
     
    139135  xSetDpbSize              ( vps );
    140136  xSetVPSVUI               ( vps );
    141 #if H_3D
    142   xSetVPSExtension2        ( vps );
    143   m_ivPicLists.setVPS      ( &vps );
    144   xDeriveDltArray          ( vps, dlt );
    145 #endif
    146137#if H_MV_HLS10_GEN_FIX
    147138  if ( m_targetEncLayerIdList.size() == 0 )
     
    195186    m_cTEncTop.setViewId                       ( vps.getViewId      (  layerId ) );
    196187    m_cTEncTop.setViewIndex                    ( vps.getViewIndex   (  layerId ) );
    197 #if H_3D
    198     Bool isDepth = ( vps.getDepthId     ( layerId ) != 0 ) ;
    199     m_cTEncTop.setIsDepth                      ( isDepth );
    200     //====== Camera Parameters =========
    201     m_cTEncTop.setCameraParameters             ( &m_cCameraData );     
    202     m_cTEncTop.setCamParPrecision              ( m_cCameraData.getCamParsCodedPrecision  () );
    203     m_cTEncTop.setCamParInSliceHeader          ( m_cCameraData.getVaryingCameraParameters() );
    204     m_cTEncTop.setCodedScale                   ( m_cCameraData.getCodedScale             () );
    205     m_cTEncTop.setCodedOffset                  ( m_cCameraData.getCodedOffset            () );
    206 #if H_3D_VSO
    207     //====== VSO =========
    208     m_cTEncTop.setRenderModelParameters        ( &m_cRenModStrParser );
    209     m_cTEncTop.setForceLambdaScaleVSO          ( isDepth ? m_bForceLambdaScaleVSO : false );
    210     m_cTEncTop.setLambdaScaleVSO               ( isDepth ? m_dLambdaScaleVSO      : 1     );
    211     m_cTEncTop.setVSOMode                      ( isDepth ? m_uiVSOMode            : 0     );
    212 
    213     m_cTEncTop.setAllowNegDist                 ( isDepth ? m_bAllowNegDist        : false );
    214 
    215     // SAIT_VSO_EST_A0033
    216     m_cTEncTop.setUseEstimatedVSD              ( isDepth ? m_bUseEstimatedVSD     : false );
    217 
    218     // LGE_WVSO_A0119
    219     m_cTEncTop.setUseWVSO                      ( isDepth ? m_bUseWVSO             : false );   
    220     m_cTEncTop.setVSOWeight                    ( isDepth ? m_iVSOWeight           : 0     );
    221     m_cTEncTop.setVSDWeight                    ( isDepth ? m_iVSDWeight           : 0     );
    222     m_cTEncTop.setDWeight                      ( isDepth ? m_iDWeight             : 0     );
    223 #endif // H_3D_VSO
    224 #if H_3D_SPIVMP
    225     m_cTEncTop.setSubPULog2Size                 (( isDepth || 0==layerIdInVps ) ? 0 : m_iSubPULog2Size   );
    226     m_cTEncTop.setSubPUMPILog2Size              ( !isDepth ? 0 : m_iSubPUMPILog2Size   );
    227 #endif
    228 #if H_3D_IC
    229     m_cTEncTop.setUseIC                        ( vps.getViewIndex( layerId ) == 0 || isDepth ? false : m_abUseIC );
    230     m_cTEncTop.setUseICLowLatencyEnc           ( m_bUseLowLatencyICEnc );
    231 #endif
    232   //========== Depth intra modes ==========
    233 #if H_3D_DIM
    234     m_cTEncTop.setUseDMM                       ( isDepth ? m_useDMM               : false );
    235 #if SEPARATE_FLAG_I0085
    236 #if LGE_FCO_I0116
    237     m_cTEncTop.setUseIVP                       ( vps.getViewIndex( layerId ) == 0 && isDepth ? m_useIVP               : false );
    238 #else
    239     m_cTEncTop.setUseIVP                       ( isDepth ? m_useIVP               : false );
    240 #endif
    241 #endif
    242     m_cTEncTop.setUseSDC                       ( isDepth ? m_useSDC               : false );
    243     m_cTEncTop.setUseDLT                       ( isDepth ? m_useDLT               : false );
    244 #endif
    245 #if MTK_SINGLE_DEPTH_MODE_I0095
    246     m_cTEncTop.setUseSingleDepthMode           ( isDepth ? m_useSingleDepthMode   : false );
    247 #endif
    248 #if !MTK_I0099_VPS_EX2 || MTK_I0099_FIX
    249 #if H_3D_QTLPC
    250 #if LGE_FCO_I0116
    251     m_cTEncTop.setUseQTL                       ( vps.getViewIndex( layerId ) == 0 && isDepth ? m_bUseQTL               : false );
    252 #else
    253     m_cTEncTop.setUseQTL                       ( isDepth ? m_bUseQTL               : false );
    254 #endif
    255 #if !MTK_I0099_VPS_EX2   
    256     m_cTEncTop.setUsePC                        ( isDepth ? m_bUsePC                : false );
    257 #endif
    258 #endif
    259 #endif
    260     //====== Depth Inter SDC =========
    261 #if H_3D_INTER_SDC
    262     m_cTEncTop.setInterSDCEnable               ( isDepth ? m_bDepthInterSDCFlag    : false );
    263 #endif
    264 #if H_3D_DBBP
    265     m_cTEncTop.setUseDBBP                      ( vps.getViewIndex( layerId ) == 0 || isDepth ? false : m_bUseDBBP );
    266 #endif
    267 #if H_3D_IV_MERGE
    268 #if LGE_FCO_I0116
    269     m_cTEncTop.setUseMPI                       ( vps.getViewIndex( layerId ) == 0 && isDepth ? m_bMPIFlag    : false );
    270 #else
    271     m_cTEncTop.setUseMPI                       ( isDepth ? m_bMPIFlag    : false );
    272 #endif
    273 #endif
    274 #endif // H_3D
    275188
    276189    m_cTEncTop.setIvPicLists                   ( &m_ivPicLists );
     
    278191  m_cTEncTop.setVPS(&vps);
    279192
    280 #if H_3D
    281   m_cTEncTop.setDLT(&dlt);
    282 #endif
    283193
    284194#if H_MV
     
    527437  m_cTEncTop.setScalingListFile            ( m_scalingListFile   );
    528438  m_cTEncTop.setSignHideFlag(m_signHideFlag);
    529 #if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227
    530   if(!m_cTEncTop.getIsDepth())    //only for texture
    531   {
    532439    m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
    533   }
    534   else
    535   {
    536     m_cTEncTop.setUseRateCtrl         ( 0 );
    537   }
    538 #else
    539     m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
    540 #endif
    541 #if !KWU_RC_VIEWRC_E0227
    542440  m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
    543 #endif
    544441  m_cTEncTop.setKeepHierBit         ( m_RCKeepHierarchicalBit );
    545442  m_cTEncTop.setLCULevelRC          ( m_RCLCULevelRC );
     
    547444  m_cTEncTop.setInitialQP           ( m_RCInitialQP );
    548445  m_cTEncTop.setForceIntraQP        ( m_RCForceIntraQP );
    549 #if KWU_RC_MADPRED_E0227
    550   if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
    551   {
    552     m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred       : 0);
    553     if(m_cTEncTop.getUseDepthMADPred())
    554     {
    555       m_cTEncTop.setCamParam(&m_cCameraData);
    556     }
    557   }
    558 #endif
    559 #if KWU_RC_VIEWRC_E0227
    560   if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
    561   {
    562     m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl);
    563     if(m_iNumberOfViews == 1)
    564     {
    565       if(m_viewWiseRateCtrl)
    566       {
    567         m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
    568       }
    569       else
    570       {
    571         m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
    572       }
    573     }
    574     else
    575     {
    576       if(m_viewWiseRateCtrl)
    577       {
    578         m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
    579       }
    580       else
    581       {
    582         if(m_iNumberOfViews == 2)
    583         {
    584           if(m_cTEncTop.getViewId() == 0)
    585           {
    586             m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*80)/100 );
    587           }
    588           else if(m_cTEncTop.getViewId() == 1)
    589           {
    590             m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*20)/100 );
    591           }
    592         }
    593         else if(m_iNumberOfViews == 3)
    594         {
    595           if(m_cTEncTop.getViewId() == 0)
    596           {
    597             m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*66)/100 );
    598           }
    599           else if(m_cTEncTop.getViewId() == 1)
    600           {
    601             m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*17)/100 );
    602           }
    603           else if(m_cTEncTop.getViewId() == 2)
    604           {
    605             m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*17)/100 );
    606           }
    607         }
    608         else
    609         {
    610           m_cTEncTop.setTargetBitrate              ( m_RCTargetBitrate );
    611         }
    612       }
    613     }
    614   }
    615 #endif
    616446  m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
    617447  m_cTEncTop.setCUTransquantBypassFlagForceValue(m_CUTransquantBypassFlagForce);
     
    651481  }
    652482#endif
    653 #if H_3D_VSO
    654   if ( m_bUseVSO )
    655   {
    656     if ( m_uiVSOMode == 4 )
    657     {
    658 #if H_3D_VSO_EARLY_SKIP
    659       m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip );
    660 #else
    661       m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 );
    662 #endif
    663       for ( Int layer = 0; layer < m_numberOfLayers ; layer++ )
    664       {
    665         TEncTop* pcEncTop =  m_acTEncTopList[ layer ];
    666         Int iViewNum      = pcEncTop->getViewIndex();
    667         Int iContent      = pcEncTop->getIsDepth() ? 1 : 0;
    668         Int iNumOfModels  = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent);
    669 
    670         Bool bUseVSO      = (iNumOfModels != 0);
    671 
    672         pcEncTop->setUseVSO( bUseVSO );
    673         pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL );
    674 
    675         for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ )
    676         {
    677           Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode;
    678 
    679           m_cRenModStrParser.getSingleModelData  ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ;
    680           m_cRendererModel  .createSingleModel   ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode );
    681         }           
    682       }
    683     }
    684     else
    685     {
    686       AOT(true);
    687     }
    688   }
    689 #endif
    690483}
    691484
     
    695488  // initialize global variables
    696489  initROM();
    697 #if H_3D_DIM_DMM
    698   initWedgeLists( true );
    699 #endif
    700490
    701491  for( Int layer=0; layer < m_numberOfLayers; layer++)
     
    756546Void TAppEncTop::xInitLib(Bool isFieldCoding)
    757547{
    758 #if H_3D
    759   for ( Int viewIndex = 0; viewIndex < m_vps->getNumViews(); viewIndex++ )
    760   {
    761     m_vps->initCamParaVPS( viewIndex, true, m_cCameraData.getCamParsCodedPrecision(),
    762       m_cCameraData.getVaryingCameraParameters(), m_cCameraData.getCodedScale(), m_cCameraData.getCodedOffset() );
    763   }
    764 #endif
    765548
    766549#if H_MV
    767550  for(Int layer=0; layer<m_numberOfLayers; layer++)
    768551  {
    769 #if KWU_RC_MADPRED_E0227
    770     m_acTEncTopList[layer]->init( isFieldCoding, this );
    771 #else
    772552    m_acTEncTopList[layer]->init( isFieldCoding );
    773 #endif
    774553  }
    775554#else
     
    885664    for ( Int gopId=0; gopId < gopSize; gopId++ )
    886665    {
    887 #if H_3D
    888       UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId );
    889       if ( iNextPoc < m_framesToBeEncoded )
    890       {
    891         m_cCameraData.update( iNextPoc );
    892       }
    893 #endif
    894666      for(Int layer=0; layer < m_numberOfLayers; layer++ )
    895667      {
     
    901673#endif
    902674
    903 #if H_3D_VSO       
    904           if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded )
    905           {
    906             m_cCameraData.setDispCoeff( iNextPoc, m_acTEncTopList[layer]->getViewIndex() );
    907             m_acTEncTopList[layer]  ->setDispCoeff( m_cCameraData.getDispCoeff() );
    908           }
    909 #endif
    910 
    911 #if H_3D_DDD
    912           m_acTEncTopList[ layer ]->getSliceEncoder()->setDDDPar( m_cCameraData.getCodedScale()[0][ m_acTEncTopList[layer]->getViewIndex() ],
    913               m_cCameraData.getCodedOffset()[0][ m_acTEncTopList[layer]->getViewIndex() ],
    914               m_cCameraData.getCamParsCodedPrecision() );
    915 #endif
     675
    916676        Int   iNumEncoded = 0;
    917677
     
    996756  printRateSummary();
    997757
    998 #if H_3D_REN_MAX_DEV_OUT
    999   Double dMaxDispDiff = m_cCameraData.getMaxShiftDeviation();
    1000 
    1001   if ( !(dMaxDispDiff < 0) )
    1002   { 
    1003     printf("\n Max. possible shift error: %12.3f samples.\n", dMaxDispDiff );
    1004   }
    1005 #endif
    1006758
    1007759  return;
     
    12491001}
    12501002
    1251 #if H_3D_DIM_DLT
    1252 Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt)
    1253 {
    1254   TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
    1255   // allocate original YUV buffer
    1256   pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    1257  
    1258   TVideoIOYuv* depthVideoFile = new TVideoIOYuv;
    1259  
    1260   UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1);
    1261  
    1262   Bool abValidDepths[256];
    1263  
    1264   depthVideoFile->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
    1265  
    1266   // initialize boolean array
    1267   for(Int p=0; p<=uiMaxDepthValue; p++)
    1268     abValidDepths[p] = false;
    1269  
    1270   Int iHeight   = pcDepthPicYuvOrg->getHeight();
    1271   Int iWidth    = pcDepthPicYuvOrg->getWidth();
    1272   Int iStride   = pcDepthPicYuvOrg->getStride();
    1273  
    1274   Pel* pInDM    = pcDepthPicYuvOrg->getLumaAddr();
    1275  
    1276   for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ )
    1277   {
    1278     depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad );
    1279    
    1280     // check all pixel values
    1281     for (Int i=0; i<iHeight; i++)
    1282     {
    1283       Int rowOffset = i*iStride;
    1284      
    1285       for (Int j=0; j<iWidth; j++)
    1286       {
    1287         Pel depthValue = pInDM[rowOffset+j];
    1288         abValidDepths[depthValue] = true;
    1289       }
    1290     }
    1291   }
    1292  
    1293   depthVideoFile->close();
    1294   delete depthVideoFile;
    1295  
    1296   pcDepthPicYuvOrg->destroy();
    1297   delete pcDepthPicYuvOrg;
    1298  
    1299   // convert boolean array to idx2Depth LUT
    1300   Int* aiIdx2DepthValue = (Int*) calloc(uiMaxDepthValue, sizeof(Int));
    1301   Int iNumDepthValues = 0;
    1302   for(Int p=0; p<=uiMaxDepthValue; p++)
    1303   {
    1304     if( abValidDepths[p] == true)
    1305     {
    1306       aiIdx2DepthValue[iNumDepthValues++] = p;
    1307     }
    1308   }
    1309  
    1310   if( uiNumFrames == 0 || numBitsForValue(iNumDepthValues) == g_bitDepthY )
    1311   {
    1312     dlt->setUseDLTFlag(layer, false);
    1313   }
    1314  
    1315   // assign LUT
    1316   if( dlt->getUseDLTFlag(layer) )
    1317   {
    1318     dlt->setDepthLUTs(layer, aiIdx2DepthValue, iNumDepthValues);
    1319   }
    1320  
    1321   // free temporary memory
    1322   free(aiIdx2DepthValue);
    1323 }
    1324 #endif
    13251003
    13261004#if H_MV
     
    16401318    break;
    16411319  case Profile::MULTIVIEWMAIN:
    1642 #if H_3D
    1643   case Profile::MAIN3D:
    1644 #endif
    16451320    ptl->setMax12bitConstraintFlag      ( true  );
    16461321    ptl->setMax12bitConstraintFlag      ( true  );
     
    21521827
    21531828
    2154 #if H_3D
    2155 Void TAppEncTop::xSetVPSExtension2( TComVPS& vps )
    2156 {
    2157   for ( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ )
    2158   {
    2159     Bool isDepth      = ( vps.getDepthId( layer ) == 1 ) ;
    2160     Bool isLayerZero  = ( layer == 0 );
    2161 #if LGE_FCO_I0116
    2162     Bool isDepthFirst = (layer > 1 ? true : false);
    2163 #endif
    2164 
    2165 #if H_3D_ARP
    2166     vps.setUseAdvRP        ( layer, ( isDepth || isLayerZero || !vps.getNumDirectRefLayers(layer) ) ? 0 : m_uiUseAdvResPred );
    2167     vps.setARPStepNum      ( layer, ( isDepth || isLayerZero || !vps.getNumDirectRefLayers(layer) ) ? 1 : H_3D_ARP_WFNR     );
    2168 #endif 
    2169 #if H_3D_SPIVMP
    2170     if( isDepth )
    2171     {
    2172       vps.setSubPULog2Size         ( layer, (layer != 1) ? 6: 0 );
    2173 #if MTK_I0099_VPS_EX2
    2174       vps.setSubPUMPILog2Size      ( layer, (!isLayerZero) ? m_iSubPUMPILog2Size: 0 );
    2175 #endif
    2176     }
    2177     else
    2178     {
    2179       vps.setSubPULog2Size         ( layer, (!isLayerZero) ? m_iSubPULog2Size: 0 );
    2180     }
    2181 #endif
    2182 
    2183 #if H_3D_DIM
    2184     vps.setVpsDepthModesFlag( layer, isDepth && !isLayerZero && (m_useDMM || m_useSDC || m_useDLT ) );
    2185 #if SEPARATE_FLAG_I0085
    2186 #if LGE_FCO_I0116
    2187     vps.setIVPFlag          ( layer, isDepth && !isLayerZero && m_useIVP && !isDepthFirst );
    2188 #else
    2189     vps.setIVPFlag          ( layer, isDepth && !isLayerZero && m_useIVP );
    2190 #endif
    2191 #endif
    2192 #endif
    2193 
    2194 #if H_3D_IV_MERGE
    2195     if( !vps.getNumDirectRefLayers(layer) )
    2196     {
    2197       vps.setIvMvPredFlag    (layer, false);
    2198 #if SEC_HLS_CLEANUP_I0100
    2199       vps.setIvMvScalingFlag (layer, false);
    2200 #endif
    2201     }
    2202     else
    2203     {
    2204       if( isDepth )
    2205       {
    2206         vps.setIvMvPredFlag         ( layer, (layer != 1) && m_ivMvPredFlag[1] );
    2207       }
    2208       else
    2209       {
    2210         vps.setIvMvPredFlag         ( layer, !isLayerZero && m_ivMvPredFlag[0] );
    2211       }
    2212 #if SEC_HLS_CLEANUP_I0100
    2213       vps.setIvMvScalingFlag (layer, m_ivMvScalingFlag);
    2214 #endif
    2215     }
    2216 #endif
    2217 #if MTK_I0099_VPS_EX2
    2218 #if LGE_FCO_I0116
    2219     vps.setLimQtPredFlag         ( layer, isDepth && m_bLimQtPredFlag && !isDepthFirst );
    2220 #else
    2221     vps.setLimQtPredFlag         ( layer, isDepth && m_bLimQtPredFlag );
    2222 #endif
    2223 #endif
    2224 #if H_3D_NBDV_REF
    2225     vps.setDepthRefinementFlag  ( layer, !isLayerZero && !isDepth && m_depthRefinementFlag );         
    2226 #endif
    2227 #if H_3D_VSP
    2228     vps.setViewSynthesisPredFlag( layer, !isLayerZero && !isDepth && vps.getNumDirectRefLayers(layer) && m_viewSynthesisPredFlag );         
    2229 #endif
    2230 #if H_3D_DBBP
    2231     vps.setUseDBBP              ( layer, !isLayerZero && !isDepth && m_bUseDBBP );
    2232 #endif
    2233 #if H_3D_INTER_SDC
    2234     vps.setInterSDCFlag( layer, !isLayerZero && isDepth && m_bDepthInterSDCFlag );
    2235 #endif
    2236 #if H_3D_IV_MERGE
    2237 #if LGE_FCO_I0116
    2238     vps.setMPIFlag( layer, !isLayerZero && isDepth && m_bMPIFlag && !isDepthFirst );
    2239 #else
    2240     vps.setMPIFlag( layer, !isLayerZero && isDepth && m_bMPIFlag );
    2241 #endif
    2242 #endif
    2243   } 
    2244 #if !MTK_I0099_VPS_EX2
    2245 #if H_3D_SPIVMP
    2246   vps.setSubPUMPILog2Size( m_iSubPUMPILog2Size );
    2247 #endif
    2248 #endif
    2249 #if H_3D
    2250 #if !SEC_HLS_CLEANUP_I0100
    2251   vps.setIvMvScalingFlag( m_ivMvScalingFlag );   
    2252 #endif
    2253 #endif
    2254 }
    2255 
    2256 Void TAppEncTop::xDeriveDltArray( TComVPS& vps, TComDLT& dlt )
    2257 {
    2258   Int  iNumDepthViews  = 0;
    2259   Bool bDltPresentFlag = false;
    2260 
    2261   for ( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ )
    2262   {
    2263     Bool isDepth = ( vps.getDepthId( layer ) == 1 );
    2264 
    2265     if ( isDepth )
    2266     {
    2267       iNumDepthViews++;
    2268     }
    2269 
    2270     dlt.setUseDLTFlag( layer , isDepth && m_useDLT );
    2271     if( dlt.getUseDLTFlag( layer ) )
    2272     {
    2273       xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod[layer], 24), &vps, &dlt);
    2274       bDltPresentFlag = bDltPresentFlag || dlt.getUseDLTFlag(layer);
    2275 #if H_3D_DELTA_DLT
    2276       dlt.setInterViewDltPredEnableFlag(layer, (dlt.getUseDLTFlag(layer) && (layer>1)));
    2277 #endif
    2278     }
    2279   }
    2280 
    2281   dlt.setDltPresentFlag( bDltPresentFlag );
    2282   dlt.setNumDepthViews ( iNumDepthViews  );
    2283 }
    2284 #endif
    22851829//! \}
  • branches/HTM-12.1-MV-draft-1/source/App/TAppEncoder/TAppEncTop.h

    r1066 r1072  
    4646#include "TLibCommon/AccessUnit.h"
    4747#include "TAppEncCfg.h"
    48 #if H_3D
    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 H_3D
    93   TComDLT                    m_dlt;                         ///< dlt
    94 #endif
    9586
    9687  UInt m_essentialBytes;
    9788  UInt m_totalBytes;
    98 #if H_3D_VSO
    99   TRenTop                     m_cRendererTop;
    100   TRenModel                   m_cRendererModel;   
    101 #endif
    10289protected:
    10390  // initialization
     
    149136#endif
    150137#endif
    151 #if H_3D
    152   Void xSetVPSExtension2( TComVPS& vps );
    153   Void xDeriveDltArray( TComVPS& vps, TComDLT& dlt );
    154 #endif
    155 #if H_3D_DIM_DLT
    156   Void  xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt);
    157 #endif
    158138public:
    159139  TAppEncTop();
  • branches/HTM-12.1-MV-draft-1/source/App/TAppRenderer/RendererMain.cpp

    r608 r1072  
    3535#include <time.h>
    3636#include "../../Lib/TLibCommon/TypeDef.h"
    37 #if H_3D
    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 // H_3D
    9245
  • branches/HTM-12.1-MV-draft-1/source/App/TAppRenderer/TAppRendererCfg.cpp

    r608 r1072  
    4444#include "../../Lib/TAppCommon/program_options_lite.h"
    4545
    46 #if H_3D
    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, Char* 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,  (Char*) 0, "Basename to generate video input file names")
    124     ("DepthInputFileBaseName,d",  m_pchDepthInputFileBaseName,  (Char*) 0, "Basename to generate depth input file names")
    125     ("SynthOutputFileBaseName,s", m_pchSynthOutputFileBaseName, (Char*) 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 ,    (Char *) 0, MAX_INPUT_VIEW_NUM , "Original Yuv video input file name %d")
    130     ("DepthInputFile_%d,d_%d",  m_pchDepthInputFileList ,    (Char *) 0, MAX_INPUT_VIEW_NUM , "Original Yuv depth input file name %d")
    131     ("SynthOutputFile_%d,s_%d", m_pchSynthOutputFileList,    (Char *) 0, MAX_OUTPUT_VIEW_NUM, "Synthesized Yuv output file name %d")
    132 
    133     ("InputBitDepth",           m_inputBitDepthY,                     8, "Bit-depth of input file")
    134     ("OutputBitDepth",          m_outputBitDepthY,                    0, "Bit-depth of output file (default:InternalBitDepth)")
    135     ("InternalBitDepth",        m_internalBitDepthY,                  0, "Bit-depth the renderer operates at. (default:InputBitDepth)"                                                                          "If different to InputBitDepth, source data will be converted")
    136 
    137     ("InputBitDepthC",        m_inputBitDepthC,    0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
    138     ("OutputBitDepthC",       m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
    139     ("InternalBitDepthC",     m_internalBitDepthC, 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,          (Char *) 0, "Camera Parameter File Name")
    149     ("BaseViewCameraNumbers"  , m_pchBaseViewCameraNumbers,        (Char *) 0, "Numbers of base views")
    150     ("SynthViewCameraNumbers" , m_pchSynthViewCameraNumbers,       (Char *) 0, "Numbers of views to synthesis")
    151     ("ViewConfig"             , m_pchViewConfig,                   (Char *) 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_internalBitDepthY) { m_internalBitDepthY = m_inputBitDepthY; }
    189   if (!m_internalBitDepthC) { m_internalBitDepthC = m_internalBitDepthY; }
    190   if (!m_inputBitDepthC)    { m_inputBitDepthC    = m_inputBitDepthY; }
    191   if (!m_outputBitDepthY)   { m_outputBitDepthY   = m_internalBitDepthY; }
    192   if (!m_outputBitDepthC)   { m_outputBitDepthC   = m_internalBitDepthC; }
    193 
    194   xSetGlobal();
    195 
    196   UInt  uiInputBitDepth   = 8;
    197   UInt  uiCamParPrecision = 5;
    198 
    199   m_bUseSetupString = ( m_pchViewConfig != NULL ) && ( m_iRenderMode != 0);
    200 
    201   if ( m_iRenderMode == 10 )
    202   {
    203     m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
    204       m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, NULL, m_iLog2SamplingFactor+m_iShiftPrecision );
    205     m_iNumberOfInputViews  = (Int) m_cCameraData.getBaseViewNumbers() .size();
    206     m_iNumberOfOutputViews = m_iNumberOfInputViews - 1;
    207     m_iRenderDirection     = 1;
    208   }
    209   else
    210   {
    211   if ( m_bUseSetupString )
    212   {
    213     std::vector<Int>  iaTempViews;
    214     std::vector<Int>* piaTempViews;
    215     m_cCameraData     .convertNumberString( m_pchBaseViewCameraNumbers, iaTempViews, VIEW_NUM_PREC );
    216     m_cRenModStrParser.setString( (Int) iaTempViews.size(), m_pchViewConfig );
    217     piaTempViews               = m_cRenModStrParser.getSynthViews();
    218     m_iNumberOfOutputViews     = (Int) m_cRenModStrParser.getNumOfModels();
    219     m_iNumberOfInputViews      = (Int) m_cRenModStrParser.getNumOfBaseViews();
    220     m_bContOutputFileNumbering = true;
    221 
    222   m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
    223       m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, piaTempViews, m_iLog2SamplingFactor+m_iShiftPrecision );
    224   }
    225   else
    226   {
    227   m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
    228       m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, m_pchSynthViewCameraNumbers, NULL, m_iLog2SamplingFactor+m_iShiftPrecision );
    229   m_iNumberOfOutputViews = (Int) m_cCameraData.getSynthViewNumbers().size();
    230   m_iNumberOfInputViews  = (Int) m_cCameraData.getBaseViewNumbers() .size();
    231   }
    232   }
    233 
    234   if (m_pchSynthOutputFileBaseName != NULL)
    235     xConfirmParameter( strrchr(m_pchSynthOutputFileBaseName,'$')  == 0, "'$' must be a character in SynthOutputFileBaseName");
    236 
    237   if (m_pchDepthInputFileBaseName != NULL)
    238     xConfirmParameter( strrchr(m_pchDepthInputFileBaseName, '$')  == 0, "'$' must be a character in DepthInputFileBaseName" );
    239 
    240   if (m_pchVideoInputFileBaseName != NULL)
    241     xConfirmParameter( strrchr(m_pchVideoInputFileBaseName, '$')  == 0, "'$' must be a character in VideoInputFileBaseName" );
    242 
    243   xCreateFileNames();
    244 
    245   /*
    246   * check validity of input parameters
    247   */
    248   xCheckParameter();
    249   m_cCameraData.check( m_iRenderDirection == 0, m_iFramesToBeRendered != 0 );
    250 
    251   // print-out parameters
    252   xPrintParameter();
    253 
    254   return true;
    255 }
    256 
    257 
    258 // ====================================================================================================================
    259 // Private member functions
    260 // ====================================================================================================================
    261 
    262 Void TAppRendererCfg::xCheckParameter()
    263 {
    264   bool check_failed = false; /* abort if there is a fatal configuration problem */
    265 #define xConfirmPara(a,b) check_failed |= xConfirmParameter(a,b)
    266   // check range of parameters
    267 
    268   /// File I/O
    269 
    270   // source specification
    271   xConfirmPara( m_iSourceWidth        <= 0,                   "Source width  must be greater than 0" );
    272   xConfirmPara( m_iSourceHeight       <= 0,                   "Source height must be greater than 0" );
    273   xConfirmPara( m_iFrameSkip          <  0,                   "Frame Skipping must be more than or equal to 0" );
    274   xConfirmPara( m_iFramesToBeRendered <  0,                   "Total Number Of Frames rendered must be more than 1" );
    275 
    276   // bit depth
    277   xConfirmPara( m_internalBitDepthC != m_internalBitDepthY,  "InternalBitDepth for luma and chroma must be equal. ");
    278   xConfirmPara( m_inputBitDepthY < 8,                        "InputBitDepth must be at least 8" );
    279   xConfirmPara( m_inputBitDepthC < 8,                        "InputBitDepthC must be at least 8" );
    280 
    281   // camera specification
    282   xConfirmPara( m_iNumberOfInputViews  > MAX_INPUT_VIEW_NUM , "NumberOfInputViews must be less than of equal to MAX_INPUT_VIEW_NUM");
    283   xConfirmPara( m_iNumberOfOutputViews > MAX_OUTPUT_VIEW_NUM, "NumberOfOutputViews must be less than of equal to MAX_OUTPUT_VIEW_NUM");
    284 
    285 
    286   xConfirmPara( m_iRenderDirection < 0 || m_iRenderDirection > 2  , "RenderDirection must be greater than or equal to 0 and less than 3");
    287   xConfirmPara(m_iNumberOfOutputViews < 1,                    "Number of OutputViews must be greater or equal to 1");
    288   if ( m_iRenderDirection == 0 )
    289   {
    290     xConfirmPara( m_iNumberOfInputViews < 2,                  "Number of InputViews must be more than or equal to 2");
    291   }
    292   else
    293   {
    294     xConfirmPara( m_iNumberOfInputViews < 1,                  "Number of InputViews must be more than or equal to 1");
    295   }
    296 
    297   xConfirmPara( m_iLog2SamplingFactor < 0 || m_iLog2SamplingFactor >  4, "Log2SamplingFactor must be more than or equal to 0 and less than 5"  );
    298   xConfirmPara( m_iPreProcMode        < 0 || m_iPreProcMode        >  1, "PreProcMode        must be more than or equal to 0 and less than 2"  );
    299 
    300 
    301   xConfirmPara( m_iPreFilterSize      < 0 || m_iPreFilterSize      >  3, "PreFilterSize      must be more than or equal to 0 and less than 4" );
    302   xConfirmPara( m_iBlendMode          < 0 || m_iBlendMode          >  3, "BlendMode          must be more than or equal to 0 and less than 4"  );
    303   xConfirmPara( m_iBlendZThresPerc    < 0 || m_iBlendZThresPerc    > 100,"BlendZThresPerc    must be more than or equal to 0 and less than 101"  );
    304   xConfirmPara( m_iBlendHoleMargin    < 0 || m_iBlendHoleMargin    >  20,"BlendHoleMargin    must be more than or equal to 0 and less than 19"  );
    305   xConfirmPara( m_iInterpolationMode  < 0 || m_iInterpolationMode  >  4, "InterpolationMode  must be more than or equal to 0 and less than 5"  );
    306   xConfirmPara( m_iHoleFillingMode    < 0 || m_iHoleFillingMode    >  1, "HoleFillingMode    must be more than or equal to 0 and less than 2"  );
    307   xConfirmPara( m_iPostProcMode       < 0 || m_iPostProcMode       >  2, "PostProcMode       must be more than or equal to 0 and less than 3"  );
    308 
    309   Int iNumNonNULL;
    310   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" );
    311   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" );
    312 
    313 
    314   if ( !m_bSweep )
    315   {
    316   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" );
    317   }
    318   else
    319   {
    320       xConfirmPara( iNumNonNULL < 1, "Number of SynthOutputFiles must be equal to or more than 1" );
    321   }
    322 
    323 #undef xConfirmPara
    324   if ( check_failed )
    325   {
    326     exit(EXIT_FAILURE);
    327   }
    328 
    329 }
    330 
    331 
    332 
    333 Void TAppRendererCfg::xPrintParameter()
    334 {
    335   printf("\n");
    336   for( Int iCounter = 0; iCounter < m_iNumberOfInputViews; iCounter++)
    337   {
    338     printf("InputVideoFile_%i        : %s\n", iCounter, m_pchVideoInputFileList[iCounter]);
    339   }
    340   for( Int iCounter = 0; iCounter < m_iNumberOfInputViews; iCounter++)
    341   {
    342     printf("InputDepthFile_%i        : %s\n", iCounter, m_pchDepthInputFileList[iCounter]);
    343   }
    344 
    345   for( Int iCounter = 0; iCounter < m_iNumberOfOutputViews; iCounter++)
    346   {
    347     printf("SynthOutputFile_%i       : %s\n", iCounter, m_pchSynthOutputFileList[iCounter]);
    348   }
    349 
    350   printf("Format                  : %dx%d \n", m_iSourceWidth, m_iSourceHeight );
    351   printf("Frame index             : %d - %d (%d frames)\n", m_iFrameSkip, m_iFrameSkip+m_iFramesToBeRendered-1, m_iFramesToBeRendered);
    352   printf("CameraParameterFile     : %s\n", m_pchCameraParameterFile );
    353   printf("BaseViewNumbers         : %s  (%d views) \n", m_pchBaseViewCameraNumbers , m_iNumberOfInputViews  );
    354   printf("Sweep                   : %d\n", m_bSweep               );
    355 
    356   if ( m_bUseSetupString )
    357   {
    358     printf("ViewConfig              : %s\n", m_pchViewConfig );
    359   }
    360   else
    361   {
    362   printf("SynthViewNumbers        : %s  (%d views) \n", m_pchSynthViewCameraNumbers, m_iNumberOfOutputViews );
    363   }
    364 
    365   printf("Log2SamplingFactor      : %d\n", m_iLog2SamplingFactor );
    366   printf("UVUp                    : %d\n", m_bUVUp               );
    367   printf("PreProcMode             : %d\n", m_iPreProcMode        );
    368   printf("PreFilterSize           : %d\n", m_iPreFilterSize      );
    369   printf("SimEnhance              : %d\n", m_bSimEnhance         );
    370   printf("BlendMode               : %d\n", m_iBlendMode          );
    371   printf("BlendZThresPerc         : %d\n", m_iBlendZThresPerc    );
    372   printf("BlendUseDistWeight      : %d\n", m_bBlendUseDistWeight );
    373   printf("BlendHoleMargin         : %d\n", m_iBlendHoleMargin    );
    374   printf("InterpolationMode       : %d\n", m_iInterpolationMode  );
    375   printf("HoleFillingMode         : %d\n", m_iHoleFillingMode    );
    376   printf("PostProcMode            : %d\n", m_iPostProcMode       );
    377   printf("ShiftPrecision          : %d\n", m_iShiftPrecision     );
    378   printf("TemporalDepthFilter     : %d\n", m_bTempDepthFilter    );
    379   printf("RenderMode              : %d\n", m_iRenderMode         );
    380   printf("RendererDirection       : %d\n", m_iRenderDirection       );
    381 
    382   if (m_iRenderMode == 10 )
    383   {
    384     printf("UsedPelMapMarExt        : %d\n", m_iUsedPelMapMarExt );
    385   }
    386 
    387   printf("\n");
    388 
    389   //  printf("TOOL CFG: ");
    390   //  printf("ALF:%d ", m_bUseALF             );
    391   //  printf("\n");
    392 
    393   fflush(stdout);
    394 }
    395 
    396 Void TAppRendererCfg::xPrintUsage()
    397 {
    398   printf( "\n" );
    399   printf( "  Example: TAppRenderer.exe -c test.cfg\n\n");
    400 }
    401 
    402 Bool TAppRendererCfg::xConfirmParameter(Bool bflag, const char* message)
    403 {
    404   if (!bflag)
    405     return false;
    406 
    407   printf("Error: %s\n",message);
    408   return true;
    409 }
    410 
    411 
    412 Void TAppRendererCfg::xCreateFileNames()
    413 {
    414   if ( m_iRenderMode == 10 )
    415     return;
    416 
    417   Int iPrecBefore;
    418   Int iPrecAfter;
    419 
    420   xGetMaxPrecision( m_cCameraData.getSynthViewNumbers(), iPrecBefore, iPrecAfter );
    421 
    422 
    423   if (iPrecBefore > LOG10_VIEW_NUM_PREC )
    424   {
    425     std::cerr << "Error: View Numbers with more than " << LOG10_VIEW_NUM_PREC << " digits are not supported" << std::endl;
    426     exit(EXIT_FAILURE);
    427   }
    428 
    429   AOT( !m_bContOutputFileNumbering && (m_cCameraData.getSynthViewNumbers().size() != m_iNumberOfOutputViews ));
    430   for(Int iIdx = 0; iIdx < m_iNumberOfOutputViews; iIdx++)
    431   {
    432     //GT; Create ReconFileNames
    433     if (m_pchSynthOutputFileList[iIdx] == NULL )
    434     {
    435       if ( m_bContOutputFileNumbering )
    436       {
    437         xAddNumberToFileName( m_pchSynthOutputFileBaseName, m_pchSynthOutputFileList[iIdx], (Int) ((iIdx+1) * VIEW_NUM_PREC) , 2, 0  );
    438       }
    439       else
    440       {
    441         xAddNumberToFileName( m_pchSynthOutputFileBaseName, m_pchSynthOutputFileList[iIdx], m_cCameraData.getSynthViewNumbers()[iIdx], iPrecBefore, iPrecAfter  );
    442       }
    443     }
    444   }
    445 
    446   xGetMaxPrecision( m_cCameraData.getBaseViewNumbers(), iPrecBefore, iPrecAfter );
    447   for(Int iIdx = 0; iIdx < m_cCameraData.getBaseViewNumbers().size() ; iIdx++)
    448   {
    449     //GT; Create ReconFileNames
    450     if (m_pchVideoInputFileList[iIdx] == NULL )
    451     {
    452       xAddNumberToFileName( m_pchVideoInputFileBaseName, m_pchVideoInputFileList[iIdx], m_cCameraData.getBaseViewNumbers()[iIdx], iPrecBefore, iPrecAfter  );
    453     }
    454 
    455     if (m_pchDepthInputFileList[iIdx] == NULL )
    456     {
    457       xAddNumberToFileName( m_pchDepthInputFileBaseName, m_pchDepthInputFileList[iIdx], m_cCameraData.getBaseViewNumbers()[iIdx], iPrecBefore, iPrecAfter  );
    458     }
    459   }
    460 }
    461 
    462 Void TAppRendererCfg::xAddNumberToFileName( Char* pchSourceFileName, Char*& rpchTargetFileName, Int iNumberToAdd, UInt uiPrecBefore, UInt uiPrecAfter )
    463 {
    464 
    465   if ( pchSourceFileName == NULL )
    466   {
    467     std::cerr << "No BaseName for file name generation given." << std::endl;
    468     AOT(true);
    469     exit(EXIT_FAILURE);
    470   }
    471 
    472   Char pchNumberBuffer[2* LOG10_VIEW_NUM_PREC + 2];
    473   Char pchPrintBuffer[10];
    474 
    475   Double dNumberToAdd = ( (Double) iNumberToAdd ) / VIEW_NUM_PREC;
    476 
    477   UInt uiWidth = uiPrecBefore;
    478 
    479   if (uiPrecAfter != 0)
    480   {
    481     uiWidth += uiPrecAfter + 1;
    482   }
    483 
    484   sprintf( pchPrintBuffer, "%%0%d.%df", uiWidth, uiPrecAfter );
    485   sprintf( pchNumberBuffer, pchPrintBuffer, dNumberToAdd );
    486 
    487   if ( uiPrecAfter > 0 ) pchNumberBuffer[ uiPrecBefore ] = '_';
    488 
    489   size_t iInLength  = strlen(pchSourceFileName);
    490   size_t iAddLength = strlen(pchNumberBuffer);
    491 
    492   rpchTargetFileName = (Char*) malloc(iInLength+iAddLength+1);
    493 
    494   Char* pchPlaceHolder = strrchr(pchSourceFileName,'$');
    495   assert( pchPlaceHolder );
    496 
    497   size_t iCharsToPlaceHolder = pchPlaceHolder - pchSourceFileName;
    498   size_t iCharsToEnd         = iInLength      - iCharsToPlaceHolder;
    499 
    500   strncpy(rpchTargetFileName                               , pchSourceFileName                      , iCharsToPlaceHolder);
    501   strncpy(rpchTargetFileName+iCharsToPlaceHolder           , pchNumberBuffer                        , iAddLength         );
    502   strncpy(rpchTargetFileName+iCharsToPlaceHolder+iAddLength, pchSourceFileName+iCharsToPlaceHolder+1, iCharsToEnd-1      );
    503   rpchTargetFileName[iInLength+iAddLength-1] = '\0';
    504 }
    505 
    506 Void TAppRendererCfg::xGetMaxPrecision( std::vector< Int > aiIn, Int& iPrecBefore, Int& iPrecAfter )
    507 {
    508   iPrecBefore = 0;
    509   iPrecAfter  = 0;
    510 
    511   for (UInt uiK = 0; uiK < aiIn.size(); uiK ++ )
    512   {
    513     if ( aiIn[uiK] == 0 ) continue;
    514 
    515     Int iCurPrec;
    516     iCurPrec = 0;
    517     for ( Int iCur = aiIn[uiK]; iCur != 0; iCur /= 10, iCurPrec++ );
    518     iPrecBefore = max(iPrecBefore, iCurPrec - LOG10_VIEW_NUM_PREC );
    519 
    520     iCurPrec = 0;
    521     for ( Int iCur = 1;  aiIn[uiK] % iCur == 0; iCur *= 10, iCurPrec++);
    522     iCurPrec = LOG10_VIEW_NUM_PREC - std::min((Int) LOG10_VIEW_NUM_PREC, iCurPrec-1 );
    523     iPrecAfter = max(iPrecAfter, iCurPrec );
    524   }
    525 }
    526 
    527 Void TAppRendererCfg::xSetGlobal()
    528 {
    529   // set max CU width & height 
    530   g_uiMaxCUWidth   = 0;
    531   g_uiMaxCUHeight  = 0; 
    532 }
    533 
    534 #endif
  • branches/HTM-12.1-MV-draft-1/source/App/TAppRenderer/TAppRendererCfg.h

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

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

    r608 r1072  
    4040#define __TAppRendererTOP__
    4141#include "../../Lib/TLibCommon/TypeDef.h"
    42 #if H_3D
    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 H_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 H_3D_VSO
    81   Void  renderModel ();
    82 #endif
    83   Void  go          ();
    84   Void  renderUsedPelsMap();
    85 
    86 };// END CLASS DEFINITION TAppRendererTop
    87 
    88 
    89 #endif // H_3D
    9042#endif // __TAppRendererTOP__
  • branches/HTM-12.1-MV-draft-1/source/Lib/TAppCommon/TAppComCamPara.cpp

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

    r655 r1072  
    6767  Bool                m_bCamParsCodedPrecSet;                 ///< Coded Cam Para precision set for current frame;
    6868 
    69 #if H_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;
     
    125122  Bool  xGetLeftRightView         ( Int iView, std::vector<Int> aiSortedViews, Int& riLeftView, Int& riRightView, Int& riLeftSortedViewIdx, Int& riRightSortedViewIdx );
    126123  Void  xGetPrevAndNextBaseView   ( Int iSourceViewNum, Int iTargetViewNum, Int& riPrevBaseViewNum, Int& riNextBaseViewNum );
    127 #if !KWU_RC_MADPRED_E0227
    128124  Void  xGetZNearZFar             ( Int iView, UInt uiFrame, Double& rdZNear, Double& rdZFar );
    129125  Void  xGetGeometryData          ( Int dView, UInt uiFrame, Double& rdFocalLength, Double& rdPosition, Double& rdCameraShift, Bool& rbInterpolated );
    130 #endif
    131126  Void  xSetupBaseViewsFromCoded  ();
    132127  Void  xSetupBaseViews           ( Char* pchBaseViewNumbers, UInt uiNumBaseViews );
     
    186181  UInt                getCurFrameId             ()  { return m_iCurrentFrameId;   }
    187182  static Void         convertNumberString       ( Char* pchViewNumberString, std::vector<Int>& raiViewNumbers, Double dViewNumPrec );
    188 #if H_3D_REN_MAX_DEV_OUT
    189   Double              getMaxShiftDeviation      () { return m_dMaxShiftDeviation; };
    190 #endif
    191 
    192 #if H_3D_VSO
    193   // SAIT_VSO_EST_A033
    194   Void                setDispCoeff              ( UInt uiStartFrameId, Int iViewIdx );
    195   Double              getDispCoeff              () { return m_dDispCoeff; }
    196 #endif
     183
    197184
    198185  // function for getting parameters and parameter arrays
     
    220207  Int**               getCodedOffset            ()  { return m_aaiCodedOffset;          }
    221208
    222 #if KWU_RC_MADPRED_E0227
    223   Void  xGetZNearZFar             ( Int iView, UInt uiFrame, Double& rdZNear, Double& rdZFar );
    224   Void  xGetGeometryData          ( Int dView, UInt uiFrame, Double& rdFocalLength, Double& rdPosition, Double& rdCameraShift, Bool& rbInterpolated );
    225 #endif
    226209};
    227210
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/CommonDef.h

    r1067 r1072  
    6060
    6161#if H_MV
    62 #define NV_VERSION        "12.1"                ///< Current software version
     62#define NV_VERSION        "12.0"                ///< Current software version
    6363#define HM_VERSION        "14.0"                ///<
    6464#else
     
    208208// MERGE
    209209#define MRG_MAX_NUM_CANDS           5
    210 #if H_3D_IV_MERGE
    211 #define MRG_MAX_NUM_CANDS_MEM       (MRG_MAX_NUM_CANDS+1) // one extra for inter-view motion prediction
    212 #endif
    213210// Reference memory management
    214211#define DYN_REF_FREE                0           ///< dynamic free of reference memories
     
    318315};
    319316
    320 #if H_3D
    321 //PICYUV
    322 #define PICYUV_PAD         16
    323 
    324 //RENDERER
    325 #define REN_LUMA_MARGIN   ( g_uiMaxCUWidth + PICYUV_PAD )
    326 #define REN_VDWEIGHT_PREC  8
    327 #define REN_IS_FILLED     ( 1 << REN_VDWEIGHT_PREC )
    328 #define REN_USED_PEL       ( (1 << g_bitDepthY) - 1 )
    329 #define REN_UNUSED_PEL     0
    330 #define REN_IS_HOLE        0
    331 
    332 
    333 // CAMERA PARAMETERS
    334 #define LOG2_DISP_PREC_LUT           2           ///< log2 of disparity precision used in integer disparity LUTs
    335 #define STD_CAM_PARAMETERS_PRECISION 5        ///< quarter luma sample accuarcy for derived disparities (as default)
    336 
    337 #endif // end of H_3D
    338317//! \}
    339318
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/ContextTables.h

    r1039 r1072  
    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 MTK_SINGLE_DEPTH_MODE_I0095
    54 #define NUM_SINGLEDEPTH_FLAG_CTX                     1
    55 #define NUM_SINGLE_DEPTH_VALUE_DATA_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
     
    9692#define NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX  1
    9793
    98 #if H_3D_ARP
    99 #define NUM_ARPW_CTX                  3       ///< number of context models for weighting factor index used by advanced residual prediction
    100 #endif
    101 
    102 #if H_3D_IC
    103 #define NUM_IC_FLAG_CTX               1       ///< number of context models for illumination compensation flag
    104 #endif
     94
    10595
    10696#define CNU                          154      ///< dummy initialization value for unused context models 'Context model Not Used'
    10797
    108 #if H_3D_DIM
    109 #define NUM_DEPTH_INTRA_MODE_CTX      1       ///< number of context models for depth intra modes
    110 #define NUM_DDC_FLAG_CTX              2       ///< number of context models for deltaDC flag (DMM or RBC)
    111 #define NUM_DDC_DATA_CTX              1       ///< number of context models for deltaDC data (DMM or RBC)
    112 #if H_3D_DIM_DMM
    113 #define NUM_DMM1_DATA_CTX             1       ///< number of context models for DMM1 data
    114 #endif
    115 #define NUM_ANGLE_FLAG_CTX            1
    116 #endif
    117 
    118 #if H_3D_DIM_SDC
    119 #define SDC_NUM_RESIDUAL_FLAG_CTX     1
    120 #define SDC_NUM_RESIDUAL_CTX          1
    121 #define NUM_SDC_FLAG_CTX              1      ///< number of context
    122 #endif
    123 #if H_3D_DBBP
    124 #define DBBP_NUM_FLAG_CTX                 1
    125 #endif
     98
    12699// ====================================================================================================================
    127100// Tables
     
    153126  { CNU,  CNU,  CNU, },
    154127};
    155 #if MTK_SINGLE_DEPTH_MODE_I0095
    156 static const UChar
    157 INIT_SINGLEDEPTH_FLAG[3][NUM_SINGLEDEPTH_FLAG_CTX] = 
    158 {
    159   { 185 },
    160   { 185 },
    161   { 185 },
    162 };
    163 static const UChar
    164 INIT_SINGLE_DEPTH_VALUE_DATA[3][NUM_SINGLE_DEPTH_VALUE_DATA_CTX] =
    165 {
    166   { 137 },
    167   { 137 },
    168   { 137 },
    169 };
    170 #endif
    171128static const UChar
    172129INIT_MERGE_FLAG_EXT[3][NUM_MERGE_FLAG_EXT_CTX] =
     
    357314};
    358315
    359 #if H_3D_ARP
    360 static const UChar
    361 INIT_ARPW[3][NUM_ARPW_CTX] =
    362 {
    363     { 162, 153, 162 },
    364     { 162, 153, 162 },
    365     { 162, 153, 162 },
    366 };
     316
     317
     318//! \}
     319
    367320
    368321#endif
    369 #if H_3D_IC
    370 static const UChar
    371 INIT_IC_FLAG[3][NUM_IC_FLAG_CTX] = 
    372 {
    373     { 154 },
    374     { 154 },
    375     { 154 },
    376 };
    377 
    378 #endif
    379 #if H_3D_DIM
    380 static const UChar
    381 INIT_DEPTH_INTRA_MODE[3][NUM_DEPTH_INTRA_MODE_CTX] =
    382 {
    383   { 154, },
    384   { 154, },
    385   { 154, }
    386 };
    387 
    388 static const UChar
    389 INIT_ANGLE_FLAG[3][NUM_ANGLE_FLAG_CTX] =
    390 {
    391   { 154 },
    392   { 141 },
    393   { 155 },
    394 };
    395 
    396 static const UChar
    397 INIT_DDC_FLAG[3][NUM_DDC_FLAG_CTX] =
    398 {
    399   {0 , CNU},
    400   {0 , CNU},
    401   {64, CNU}
    402 };
    403 static const UChar
    404 INIT_DDC_DATA[3][NUM_DDC_DATA_CTX] =
    405 {
    406   { 154 },
    407   { 154 },
    408   { 154 },
    409 };
    410 #if H_3D_DIM_DMM
    411 static const UChar
    412 INIT_DMM1_DATA[3][NUM_DMM1_DATA_CTX] =
    413 {
    414   { CNU },
    415   { CNU },
    416   { CNU },
    417 };
    418 #endif
    419 #if H_3D_DIM_SDC
    420 static const UChar
    421 INIT_SDC_RESIDUAL_FLAG[3][SDC_NUM_RESIDUAL_FLAG_CTX] =
    422 {
    423   { CNU },
    424   { CNU },
    425   { CNU },
    426 };
    427 static const UChar
    428 INIT_SDC_RESIDUAL[3][SDC_NUM_RESIDUAL_CTX] =
    429 {
    430   { 155 },
    431   { 155 },
    432   { 155 },
    433 };
    434 #endif
    435 #endif
    436 
    437 
    438 //! \}
    439 #if H_3D_DIM_SDC
    440 static const UChar
    441 INIT_SDC_FLAG[3][NUM_SDC_FLAG_CTX] =
    442 {
    443   { 154 }, 
    444   { 154 },
    445   { 154 },
    446 };
    447 #endif
    448 
    449 #if H_3D_DBBP
    450 static const UChar INIT_DBBP_FLAG[3][DBBP_NUM_FLAG_CTX] =
    451 {
    452 #if SEC_DBBP_EXPLICIT_SIG_I0077
    453   { CNU },
    454   { CNU },
    455   { CNU },
    456 #else
    457   { 161 },
    458   { 161 },
    459   { 161 },
    460 #endif
    461 };
    462 #endif
    463 
    464 #endif
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComDataCU.cpp

    r1066 r1072  
    6060 
    6161  m_skipFlag           = NULL;
    62 #if MTK_SINGLE_DEPTH_MODE_I0095
    63   m_singleDepthFlag     = NULL;
    64   m_apSingleDepthValue  = NULL;
    65 #endif 
    6662  m_pePartSize         = NULL;
    6763  m_pePredMode         = NULL;
     
    112108  m_apiMVPNum[1]       = NULL;
    113109
    114 #if H_3D_DIM
    115   for( Int i = 0; i < DIM_NUM_TYPE; i++ )
    116   {
    117     m_dimDeltaDC[i][0] = NULL;
    118     m_dimDeltaDC[i][1] = NULL;
    119   }
    120 #if H_3D_DIM_DMM
    121   for( Int i = 0; i < DMM_NUM_TYPE; i++ )
    122   {
    123     m_dmmWedgeTabIdx[i] = NULL;
    124   }
    125 #endif
    126 #if H_3D_DIM_SDC
    127   m_pbSDCFlag             = NULL;
    128   m_apSegmentDCOffset[0]  = NULL;
    129   m_apSegmentDCOffset[1]  = NULL;
    130 #endif
    131 #endif
    132110  m_bDecSubCu          = false;
    133111  m_sliceStartCU        = 0;
    134112  m_sliceSegmentStartCU = 0;
    135 #if H_3D_NBDV
    136   m_pDvInfo              = NULL;
    137 #endif
    138 #if H_3D_VSP
    139   m_piVSPFlag            = NULL;
    140 #endif
    141 #if H_3D_SPIVMP
    142   m_pbSPIVMPFlag         = NULL;
    143 #endif
    144 #if H_3D_ARP
    145   m_puhARPW              = NULL;
    146 #endif
    147 #if H_3D_IC
    148   m_pbICFlag             = NULL;
    149 #endif
    150 #if H_3D_INTER_SDC
    151 #endif
    152 #if H_3D_DBBP
    153   m_pbDBBPFlag         = NULL;
    154 #endif
    155 
    156 #if H_3D_DDD
    157   m_pucDisparityDerivedDepth = NULL;
    158   m_pbUseDDD = NULL;
    159 #endif
     113
    160114}
    161115
     
    185139
    186140    m_skipFlag           = new Bool[ uiNumPartition ];
    187 #if MTK_SINGLE_DEPTH_MODE_I0095
    188     m_singleDepthFlag     = new Bool[ uiNumPartition ];
    189     m_apSingleDepthValue  = (Pel*)xMalloc(Pel, uiNumPartition);
    190 #endif
    191141    m_pePartSize         = new Char[ uiNumPartition ];
    192142    memset( m_pePartSize, SIZE_NONE,uiNumPartition * sizeof( *m_pePartSize ) );
     
    195145    m_pbMergeFlag        = (Bool*  )xMalloc(Bool,   uiNumPartition);
    196146    m_puhMergeIndex      = (UChar* )xMalloc(UChar,  uiNumPartition);
    197 #if H_3D_VSP
    198     m_piVSPFlag          = (Char*  )xMalloc(Char,   uiNumPartition);
    199 #endif
    200 #if H_3D_SPIVMP
    201     m_pbSPIVMPFlag       = (Bool*  )xMalloc(Bool,   uiNumPartition);
    202 #endif
    203147    m_puhLumaIntraDir    = (UChar* )xMalloc(UChar,  uiNumPartition);
    204148    m_puhChromaIntraDir  = (UChar* )xMalloc(UChar,  uiNumPartition);
     
    224168    m_pcTrCoeffCb        = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4);
    225169    m_pcTrCoeffCr        = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4);
    226 #if H_3D_NBDV
    227     m_pDvInfo            = (DisInfo* )xMalloc(DisInfo,  uiNumPartition);
    228 #endif
    229170    memset( m_pcTrCoeffY, 0,uiWidth*uiHeight * sizeof( TCoeff ) );
    230171    memset( m_pcTrCoeffCb, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) );
     
    260201    m_acCUMvField[1].create( uiNumPartition );
    261202   
    262 #if H_3D_ARP
    263     m_puhARPW            = new UChar[ uiNumPartition];
    264 #endif
    265 #if H_3D_IC
    266     m_pbICFlag           = (Bool* )xMalloc(Bool,   uiNumPartition);
    267 #endif
    268 #if H_3D_DIM
    269     for( Int i = 0; i < DIM_NUM_TYPE; i++ )
    270     {
    271       m_dimDeltaDC[i][0] = (Pel* )xMalloc(Pel, uiNumPartition);
    272       m_dimDeltaDC[i][1] = (Pel* )xMalloc(Pel, uiNumPartition);
    273     }
    274 #if H_3D_DIM_DMM
    275     for( Int i = 0; i < DMM_NUM_TYPE; i++ )
    276     {
    277       m_dmmWedgeTabIdx[i]    = (UInt*)xMalloc(UInt, uiNumPartition);
    278     }
    279 #endif
    280 #if H_3D_DIM_SDC
    281     m_pbSDCFlag             = (Bool*)xMalloc(Bool, uiNumPartition);
    282     m_apSegmentDCOffset[0]  = (Pel*)xMalloc(Pel, uiNumPartition);
    283     m_apSegmentDCOffset[1]  = (Pel*)xMalloc(Pel, uiNumPartition);
    284 #endif
    285 #endif
    286 #if H_3D_DBBP
    287     m_pbDBBPFlag         = (Bool*  )xMalloc(Bool,   uiNumPartition);
    288 #endif
    289203  }
    290204  else
     
    299213  m_pcPattern            = (TComPattern*)xMalloc(TComPattern, 1);
    300214 
    301 #if H_3D_DDD
    302   m_pucDisparityDerivedDepth         = (UChar*  )xMalloc( UChar,  uiNumPartition);
    303   m_pbUseDDD                         = (Bool*  ) xMalloc( Bool,   uiNumPartition);
    304 #endif
    305215
    306216  // create motion vector fields
     
    335245
    336246    if ( m_skipFlag           ) { delete[] m_skipFlag;          m_skipFlag          = NULL; }
    337 #if MTK_SINGLE_DEPTH_MODE_I0095
    338     if ( m_singleDepthFlag    ) { delete[] m_singleDepthFlag;   m_singleDepthFlag     = NULL; }
    339     if ( m_apSingleDepthValue ) { xFree(m_apSingleDepthValue);  m_apSingleDepthValue  = NULL; }
    340 #endif
    341247    if ( m_pePartSize         ) { delete[] m_pePartSize;        m_pePartSize        = NULL; }
    342248    if ( m_pePredMode         ) { delete[] m_pePredMode;        m_pePredMode        = NULL; }
     
    348254    if ( m_pbMergeFlag        ) { xFree(m_pbMergeFlag);         m_pbMergeFlag       = NULL; }
    349255    if ( m_puhMergeIndex      ) { xFree(m_puhMergeIndex);       m_puhMergeIndex     = NULL; }
    350 #if H_3D_VSP
    351     if ( m_piVSPFlag          ) { xFree(m_piVSPFlag);           m_piVSPFlag         = NULL; }
    352 #endif
    353 #if H_3D_SPIVMP
    354     if ( m_pbSPIVMPFlag       ) { xFree(m_pbSPIVMPFlag);           m_pbSPIVMPFlag         = NULL; }
    355 #endif
    356256    if ( m_puhLumaIntraDir    ) { xFree(m_puhLumaIntraDir);     m_puhLumaIntraDir   = NULL; }
    357257    if ( m_puhChromaIntraDir  ) { xFree(m_puhChromaIntraDir);   m_puhChromaIntraDir = NULL; }
     
    382282    if ( m_apiMVPNum[0]       ) { delete[] m_apiMVPNum[0];      m_apiMVPNum[0]      = NULL; }
    383283    if ( m_apiMVPNum[1]       ) { delete[] m_apiMVPNum[1];      m_apiMVPNum[1]      = NULL; }
    384 #if H_3D_NBDV
    385     if ( m_pDvInfo            ) { xFree(m_pDvInfo);             m_pDvInfo           = NULL; }
    386 #endif
    387 
    388 #if H_3D_DDD
    389     if ( m_pucDisparityDerivedDepth ) { xFree(m_pucDisparityDerivedDepth);          m_pucDisparityDerivedDepth        = NULL; }
    390     if ( m_pbUseDDD                 ) { xFree(m_pbUseDDD);                          m_pbUseDDD                        = NULL; }
    391 #endif
    392 
    393 #if H_3D_ARP
    394     if ( m_puhARPW            ) { delete[] m_puhARPW;           m_puhARPW           = NULL; }
    395 #endif
    396 #if H_3D_IC
    397     if ( m_pbICFlag           ) { xFree(m_pbICFlag);            m_pbICFlag          = NULL; }
    398 #endif
     284
     285
    399286    m_acCUMvField[0].destroy();
    400287    m_acCUMvField[1].destroy();
    401288
    402 #if H_3D_DIM
    403     for( Int i = 0; i < DIM_NUM_TYPE; i++ )
    404     {
    405       if ( m_dimDeltaDC[i][0] ) { xFree( m_dimDeltaDC[i][0] ); m_dimDeltaDC[i][0] = NULL; }
    406       if ( m_dimDeltaDC[i][1] ) { xFree( m_dimDeltaDC[i][1] ); m_dimDeltaDC[i][1] = NULL; }
    407     }
    408 #if H_3D_DIM_DMM
    409     for( Int i = 0; i < DMM_NUM_TYPE; i++ )
    410     {
    411       if ( m_dmmWedgeTabIdx[i] ) { xFree( m_dmmWedgeTabIdx[i] ); m_dmmWedgeTabIdx[i] = NULL; }
    412     }
    413 #endif
    414 #if H_3D_DIM_SDC
    415     if ( m_pbSDCFlag            ) { xFree(m_pbSDCFlag);             m_pbSDCFlag             = NULL; }
    416     if ( m_apSegmentDCOffset[0] ) { xFree(m_apSegmentDCOffset[0]);  m_apSegmentDCOffset[0]  = NULL; }
    417     if ( m_apSegmentDCOffset[1] ) { xFree(m_apSegmentDCOffset[1]);  m_apSegmentDCOffset[1]  = NULL; }
    418 #endif   
    419 #endif   
    420 #if H_3D_DBBP
    421     if ( m_pbDBBPFlag         ) { xFree(m_pbDBBPFlag);          m_pbDBBPFlag        = NULL; }
    422 #endif
    423289  }
    424290  m_pcCUAboveLeft       = NULL;
     
    503369    TComDataCU * pcFrom = pcPic->getCU(getAddr());
    504370    m_skipFlag[ui]   = pcFrom->getSkipFlag(ui);
    505 #if MTK_SINGLE_DEPTH_MODE_I0095
    506     m_singleDepthFlag[ui]    = pcFrom->getSingleDepthFlag(ui);
    507     m_apSingleDepthValue[ui] = pcFrom->getSingleDepthValue(ui);
    508 #endif
    509371    m_pePartSize[ui] = pcFrom->getPartitionSize(ui);
    510372    m_pePredMode[ui] = pcFrom->getPredictionMode(ui);
    511373    m_CUTransquantBypass[ui] = pcFrom->getCUTransquantBypass(ui);
    512374    m_puhDepth[ui] = pcFrom->getDepth(ui);
    513 #if H_3D_ARP
    514     m_puhARPW   [ui] = pcFrom->getARPW( ui );
    515 #endif
    516 #if H_3D_IC
    517     m_pbICFlag[ui]   =  pcFrom->m_pbICFlag[ui];
    518 #endif
    519 
    520 #if H_3D_DDD
    521     m_pucDisparityDerivedDepth[ui] = pcFrom->m_pucDisparityDerivedDepth[ui];
    522     m_pbUseDDD[ui] = pcFrom->m_pbUseDDD[ui];
    523 #endif
     375
    524376
    525377    m_puhWidth  [ui] = pcFrom->getWidth(ui);
     
    536388    m_pbMergeFlag[ui]=pcFrom->m_pbMergeFlag[ui];
    537389    m_puhMergeIndex[ui]=pcFrom->m_puhMergeIndex[ui];
    538 #if H_3D_VSP
    539     m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui];
    540 #endif
    541 #if H_3D_SPIVMP
    542     m_pbSPIVMPFlag[ui] = pcFrom->m_pbSPIVMPFlag[ui];
    543 #endif
    544390    m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui];
    545391    m_puhChromaIntraDir[ui]=pcFrom->m_puhChromaIntraDir[ui];
     
    549395    m_puhCbf[2][ui]=pcFrom->m_puhCbf[2][ui];
    550396    m_pbIPCMFlag[ui] = pcFrom->m_pbIPCMFlag[ui];
    551 #if H_3D_DIM_SDC
    552     m_pbSDCFlag[ui] = pcFrom->m_pbSDCFlag[ui];
    553 #endif
    554 #if H_3D_DBBP
    555     m_pbDBBPFlag[ui] = pcFrom->m_pbDBBPFlag[ui];
    556 #endif
    557397  }
    558398 
     
    563403  {
    564404    memset( m_skipFlag          + firstElement, false,                    numElements * sizeof( *m_skipFlag ) );
    565 #if MTK_SINGLE_DEPTH_MODE_I0095
    566     memset( m_singleDepthFlag     + firstElement, false,                  numElements * sizeof( *m_singleDepthFlag ) );
    567     memset( m_apSingleDepthValue  + firstElement,     0,                  numElements * sizeof( *m_apSingleDepthValue ) );
    568 #endif
    569405    memset( m_pePartSize        + firstElement, SIZE_NONE,                numElements * sizeof( *m_pePartSize ) );
    570406    memset( m_pePredMode        + firstElement, MODE_NONE,                numElements * sizeof( *m_pePredMode ) );
     
    584420    memset( m_pbMergeFlag       + firstElement, false,                    numElements * sizeof( *m_pbMergeFlag ) );
    585421    memset( m_puhMergeIndex     + firstElement, 0,                        numElements * sizeof( *m_puhMergeIndex ) );
    586 #if H_3D_VSP
    587     memset( m_piVSPFlag         + firstElement, 0,                        numElements * sizeof( *m_piVSPFlag ) );
    588 #endif
    589 #if H_3D_SPIVMP
    590     memset( m_pbSPIVMPFlag      + firstElement, 0,                        numElements * sizeof( *m_pbSPIVMPFlag ) );
    591 #endif
    592422    memset( m_puhLumaIntraDir   + firstElement, DC_IDX,                   numElements * sizeof( *m_puhLumaIntraDir ) );
    593423    memset( m_puhChromaIntraDir + firstElement, 0,                        numElements * sizeof( *m_puhChromaIntraDir ) );
     
    597427    memset( m_puhCbf[2]         + firstElement, 0,                        numElements * sizeof( *m_puhCbf[2] ) );
    598428    memset( m_pbIPCMFlag        + firstElement, false,                    numElements * sizeof( *m_pbIPCMFlag ) );
    599 #if H_3D_ARP
    600     memset( m_puhARPW           + firstElement, 0,                        numElements * sizeof( UChar )         );
    601 #endif
    602 #if H_3D_IC
    603     memset( m_pbICFlag          + firstElement, false,                    numElements * sizeof( *m_pbICFlag )   );
    604 #endif
    605 
    606 #if H_3D_DDD
    607     memset( m_pucDisparityDerivedDepth        + firstElement, 0,           numElements * sizeof( *m_pucDisparityDerivedDepth ) );
    608     memset( m_pbUseDDD                        + firstElement, 0,           numElements * sizeof( *m_pbUseDDD ) );
    609 #endif
    610 
    611 #if H_3D_DIM
    612     for( Int i = 0; i < DIM_NUM_TYPE; i++ )
    613     {
    614       memset( m_dimDeltaDC[i][0] + firstElement, 0,                       numElements * sizeof( *m_dimDeltaDC[i][0] ) );
    615       memset( m_dimDeltaDC[i][1] + firstElement, 0,                       numElements * sizeof( *m_dimDeltaDC[i][1] ) );
    616     }
    617 #if H_3D_DIM_DMM
    618     for( Int i = 0; i < DMM_NUM_TYPE; i++ )
    619     {
    620       memset( m_dmmWedgeTabIdx[i] + firstElement, 0,                      numElements * sizeof( *m_dmmWedgeTabIdx[i] ) );
    621     }
    622 #endif
    623 #if H_3D_DIM_SDC
    624     memset( m_pbSDCFlag             + firstElement,     0,                numElements * sizeof( *m_pbSDCFlag            ) );
    625     memset( m_apSegmentDCOffset[0]  + firstElement,     0,                numElements * sizeof( *m_apSegmentDCOffset[0] ) );
    626     memset( m_apSegmentDCOffset[1]  + firstElement,     0,                numElements * sizeof( *m_apSegmentDCOffset[1] ) );
    627 #endif
    628     m_apDmmPredictor[0] = 0;
    629     m_apDmmPredictor[1] = 0;
    630 #endif
    631 #if H_3D_DBBP
    632     memset( m_pbDBBPFlag        + firstElement, false,                    numElements * sizeof( *m_pbDBBPFlag ) );
    633 #endif
     429
     430
    634431  }
    635432 
     
    754551      m_puhTransformSkip[2][ui] = 0;
    755552      m_skipFlag[ui]   = false;
    756 #if MTK_SINGLE_DEPTH_MODE_I0095
    757       m_singleDepthFlag[ui]     = false;
    758       m_apSingleDepthValue[ui]  = 0;
    759 #endif
    760553      m_pePartSize[ui] = SIZE_NONE;
    761554      m_pePredMode[ui] = MODE_NONE;
     
    765558      m_pbMergeFlag[ui] = 0;
    766559      m_puhMergeIndex[ui] = 0;
    767 #if H_3D_VSP
    768       m_piVSPFlag[ui] = 0;
    769 #endif
    770 #if H_3D_SPIVMP
    771       m_pbSPIVMPFlag[ui] = 0;
    772 #endif
    773560      m_puhLumaIntraDir[ui] = DC_IDX;
    774561      m_puhChromaIntraDir[ui] = 0;
     
    777564      m_puhCbf[1][ui] = 0;
    778565      m_puhCbf[2][ui] = 0;
    779 #if H_3D_ARP
    780       m_puhARPW[ui] = 0;
    781 #endif
    782 #if H_3D_IC
    783       m_pbICFlag[ui]  = false;
    784 #endif
    785 
    786 #if H_3D_DDD
    787       m_pucDisparityDerivedDepth[ui] = 0;
    788       m_pbUseDDD[ui] = 0;
    789 #endif
    790 
    791 #if H_3D_DIM
    792       for( Int i = 0; i < DIM_NUM_TYPE; i++ )
    793       {
    794         m_dimDeltaDC[i][0] [ui] = 0;
    795         m_dimDeltaDC[i][1] [ui] = 0;
    796       }
    797 #if H_3D_DIM_DMM
    798       for( Int i = 0; i < DMM_NUM_TYPE; i++ )
    799       {
    800         m_dmmWedgeTabIdx[i] [ui] = 0;
    801       }
    802 #endif
    803 #if H_3D_DIM_SDC
    804       m_pbSDCFlag           [ui] = false;
    805       m_apSegmentDCOffset[0][ui] = 0;
    806       m_apSegmentDCOffset[1][ui] = 0;
    807 #endif
    808       m_apDmmPredictor[0] = 0;
    809       m_apDmmPredictor[1] = 0;
    810 #endif
    811 #if H_3D_DBBP
    812       m_pbDBBPFlag[ui] = false;
    813 #endif
     566
     567
    814568    }
    815569  }
     
    869623  memset( m_pbMergeFlag,        0, iSizeInBool  );
    870624  memset( m_puhMergeIndex,      0, iSizeInUchar );
    871 #if H_3D_VSP
    872   memset( m_piVSPFlag,          0, sizeof( Char  ) * m_uiNumPartition );
    873 #endif
    874 #if H_3D_SPIVMP
    875   memset( m_pbSPIVMPFlag,       0, sizeof( Bool  ) * m_uiNumPartition );
    876 #endif
    877625  memset( m_puhLumaIntraDir,    DC_IDX, iSizeInUchar );
    878626  memset( m_puhChromaIntraDir,  0, iSizeInUchar );
     
    886634  memset( m_puhCbf[2],          0, iSizeInUchar );
    887635  memset( m_puhDepth,     uiDepth, iSizeInUchar );
    888 #if H_3D_NBDV
    889   m_pDvInfo->bDV = false;
    890 #endif
    891 #if H_3D_ARP
    892   memset( m_puhARPW,            0, iSizeInUchar  );
    893 #endif
    894 
    895 #if H_3D_DDD
    896   memset( m_pucDisparityDerivedDepth,         0, iSizeInUchar );
    897   memset( m_pbUseDDD,                         0, iSizeInBool );
    898 #endif
     636
    899637
    900638  UChar uhWidth  = g_uiMaxCUWidth  >> uiDepth;
     
    903641  memset( m_puhHeight,         uhHeight, iSizeInUchar );
    904642  memset( m_pbIPCMFlag,        0, iSizeInBool  );
    905 #if H_3D_IC
    906   memset( m_pbICFlag,          0, iSizeInBool  );
    907 #endif
    908 #if H_3D_DIM
    909   for( Int i = 0; i < DIM_NUM_TYPE; i++ )
    910   {
    911     memset( m_dimDeltaDC[i][0], 0, sizeof(Pel ) * m_uiNumPartition );
    912     memset( m_dimDeltaDC[i][1], 0, sizeof(Pel ) * m_uiNumPartition );
    913   }
    914 #if H_3D_DIM_DMM
    915   for( Int i = 0; i < DMM_NUM_TYPE; i++ )
    916   {
    917     memset( m_dmmWedgeTabIdx[i], 0, sizeof(UInt) * m_uiNumPartition );
    918   }
    919 #endif
    920 #if H_3D_DIM_SDC
    921   memset( m_pbSDCFlag,            0, sizeof(Bool) * m_uiNumPartition  );
    922   memset( m_apSegmentDCOffset[0], 0, sizeof(Pel) * m_uiNumPartition   );
    923   memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition   );
    924 #endif
    925   m_apDmmPredictor[0] = 0;
    926   m_apDmmPredictor[1] = 0;
    927 #endif
    928 #if H_3D_DBBP
    929   memset( m_pbDBBPFlag,         0, iSizeInBool  );
    930 #endif
    931643
    932644  for (UInt ui = 0; ui < m_uiNumPartition; ui++)
    933645  {
    934646    m_skipFlag[ui]   = false;
    935 #if MTK_SINGLE_DEPTH_MODE_I0095
    936     m_singleDepthFlag[ui]   = false;
    937     m_apSingleDepthValue[ui]= 0;
    938 #endif
    939647    m_pePartSize[ui] = SIZE_NONE;
    940648    m_pePredMode[ui] = MODE_NONE;
     
    958666      m_puhTransformSkip[2][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_V);
    959667      m_skipFlag[ui]   = pcCU->getSkipFlag(uiPartOffset+ui);
    960 #if MTK_SINGLE_DEPTH_MODE_I0095
    961       m_singleDepthFlag[ui]    = pcCU->getSingleDepthFlag(uiPartOffset+ui);
    962       m_apSingleDepthValue[ui] = pcCU->getSingleDepthValue(uiPartOffset+ui);
    963 #endif
    964668      m_pePartSize[ui] = pcCU->getPartitionSize(uiPartOffset+ui);
    965669      m_pePredMode[ui] = pcCU->getPredictionMode(uiPartOffset+ui);
     
    969673      m_pbMergeFlag[ui]=pcCU->m_pbMergeFlag[uiPartOffset+ui];
    970674      m_puhMergeIndex[ui]=pcCU->m_puhMergeIndex[uiPartOffset+ui];
    971 #if H_3D_VSP
    972       m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui];
    973       m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui];
    974 #endif
    975 #if H_3D_SPIVMP
    976       m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];
    977 #endif
    978675      m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui];
    979676      m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui];
     
    983680      m_puhCbf[2][ui]=pcCU->m_puhCbf[2][uiPartOffset+ui];
    984681
    985 #if H_3D_ARP
    986       m_puhARPW           [ui] = pcCU->getARPW( uiPartOffset+ui );
    987 #endif
    988 #if H_3D_IC
    989       m_pbICFlag          [ui] = pcCU->m_pbICFlag[uiPartOffset+ui];
    990 #endif
    991 
    992 #if H_3D_DDD
    993       m_pucDisparityDerivedDepth[ui] = pcCU->m_pucDisparityDerivedDepth[uiPartOffset+ui];
    994       m_pbUseDDD[ui]                 = pcCU->m_pbUseDDD[uiPartOffset+ui];
    995 #endif
    996 
    997 #if H_3D_DIM
    998       for( Int i = 0; i < DIM_NUM_TYPE; i++ )
    999       {
    1000         m_dimDeltaDC[i][0] [ui] = pcCU->m_dimDeltaDC[i][0] [uiPartOffset+ui];
    1001         m_dimDeltaDC[i][1] [ui] = pcCU->m_dimDeltaDC[i][1] [uiPartOffset+ui];
    1002       }
    1003 #if H_3D_DIM_DMM
    1004       for( Int i = 0; i < DMM_NUM_TYPE; i++ )
    1005       {
    1006         m_dmmWedgeTabIdx[i] [ui] = pcCU->m_dmmWedgeTabIdx[i] [uiPartOffset+ui];
    1007       }
    1008 #endif
    1009 #if H_3D_DIM_SDC
    1010       m_pbSDCFlag           [ui] = pcCU->m_pbSDCFlag            [ uiPartOffset + ui ];
    1011       m_apSegmentDCOffset[0][ui] = pcCU->m_apSegmentDCOffset[0] [ uiPartOffset + ui ];
    1012       m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1] [ uiPartOffset + ui ];
    1013 #endif
    1014 #endif
    1015 #if H_3D_DBBP
    1016       m_pbDBBPFlag[ui]=pcCU->m_pbDBBPFlag[uiPartOffset+ui];
    1017 #endif
     682
     683
    1018684    }
    1019685  }
     
    1111777 
    1112778  m_skipFlag=pcCU->getSkipFlag()          + uiPart;
    1113 #if MTK_SINGLE_DEPTH_MODE_I0095
    1114   m_singleDepthFlag     = pcCU->getSingleDepthFlag()   + uiPart;
    1115   m_apSingleDepthValue  = pcCU->getSingleDepthValue()  + uiPart;
    1116 #endif 
    1117779  m_phQP=pcCU->getQP()                    + uiPart;
    1118780  m_pePartSize = pcCU->getPartitionSize() + uiPart;
     
    1120782  m_CUTransquantBypass  = pcCU->getCUTransquantBypass()+uiPart;
    1121783 
    1122 #if H_3D_NBDV
    1123   m_pDvInfo             = pcCU->getDvInfo()           + uiPart;
    1124 #endif
    1125784  m_pbMergeFlag         = pcCU->getMergeFlag()        + uiPart;
    1126785  m_puhMergeIndex       = pcCU->getMergeIndex()       + uiPart;
    1127 #if H_3D_VSP
    1128   m_piVSPFlag           = pcCU->getVSPFlag()          + uiPart;
    1129 #endif
    1130 #if H_3D_SPIVMP
    1131   m_pbSPIVMPFlag        = pcCU->getSPIVMPFlag()          + uiPart;
    1132 #endif
    1133 
    1134 #if H_3D_ARP
    1135   m_puhARPW             = pcCU->getARPW()             + uiPart;
    1136 #endif
    1137 #if H_3D_IC
    1138   m_pbICFlag            = pcCU->getICFlag()           + uiPart;
    1139 #endif
    1140 
    1141 #if H_3D_DDD
    1142   m_pucDisparityDerivedDepth          = pcCU->getDDDepth()        + uiPart;
    1143   m_pbUseDDD                          = pcCU->getUseDDD()         + uiPart;
    1144 #endif
     786
     787
    1145788
    1146789  m_puhLumaIntraDir     = pcCU->getLumaIntraDir()     + uiPart;
     
    1155798  m_puhCbf[1]= pcCU->getCbf(TEXT_CHROMA_U)        + uiPart;
    1156799  m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V)        + uiPart;
    1157 #if H_3D_DIM
    1158   for( Int i = 0; i < DIM_NUM_TYPE; i++ )
    1159   {
    1160     m_dimDeltaDC[i][0] = pcCU->getDimDeltaDC( i, 0 ) + uiPart;
    1161     m_dimDeltaDC[i][1] = pcCU->getDimDeltaDC( i, 1 ) + uiPart;
    1162   }
    1163 #if H_3D_DIM_DMM
    1164   for( Int i = 0; i < DMM_NUM_TYPE; i++ )
    1165   {
    1166     m_dmmWedgeTabIdx[i] = pcCU->getDmmWedgeTabIdx( i ) + uiPart;
    1167   }
    1168 #endif
    1169 #if H_3D_DIM_SDC
    1170   m_pbSDCFlag               = pcCU->getSDCFlag()              + uiPart;
    1171   m_apSegmentDCOffset[0]    = pcCU->getSDCSegmentDCOffset(0)  + uiPart;
    1172   m_apSegmentDCOffset[1]    = pcCU->getSDCSegmentDCOffset(1)  + uiPart;
    1173 #endif 
    1174 #endif 
    1175 #if H_3D_DBBP
    1176   m_pbDBBPFlag              = pcCU->getDBBPFlag()         + uiPart;
    1177 #endif
    1178800  m_puhDepth=pcCU->getDepth()                     + uiPart;
    1179801  m_puhWidth=pcCU->getWidth()                     + uiPart;
     
    1221843  memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPart,sizeof(UInt)*m_uiNumPartition);
    1222844}
    1223 #if H_3D_NBDV
    1224 Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx)
    1225 {
    1226   m_pDvInfo            = pcCU->getDvInfo()                + uiAbsPartIdx;
    1227 }
    1228 #endif
    1229845// Copy inter prediction info from the biggest CU
    1230846Void TComDataCU::copyInterPredInfoFrom    ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList
    1231 #if H_3D_NBDV
    1232   , Bool bNBDV
    1233 #endif
    1234847  )
    1235848{
     
    1252865 
    1253866  m_skipFlag           = pcCU->getSkipFlag ()             + uiAbsPartIdx;
    1254 #if MTK_SINGLE_DEPTH_MODE_I0095
    1255   m_singleDepthFlag     = pcCU->getSingleDepthFlag ()             + uiAbsPartIdx;
    1256   m_apSingleDepthValue  = pcCU->getSingleDepthValue ()            + uiAbsPartIdx;
    1257 #endif 
    1258867  m_pePartSize         = pcCU->getPartitionSize ()        + uiAbsPartIdx;
    1259 #if H_3D_NBDV
    1260   if(bNBDV == true)
    1261   {
    1262     m_puhWidth           = pcCU->getWidth ()                + uiAbsPartIdx;
    1263     m_puhHeight          = pcCU->getHeight()                + uiAbsPartIdx;
    1264     m_puhDepth           = pcCU->getDepth ()                + uiAbsPartIdx;
    1265   }
    1266   else
    1267   {
    1268 #endif
    1269868  m_pePredMode         = pcCU->getPredictionMode()        + uiAbsPartIdx;
    1270869  m_CUTransquantBypass = pcCU->getCUTransquantBypass()    + uiAbsPartIdx;
     
    1277876  m_pbMergeFlag        = pcCU->getMergeFlag()             + uiAbsPartIdx;
    1278877  m_puhMergeIndex      = pcCU->getMergeIndex()            + uiAbsPartIdx;
    1279 #if H_3D_VSP
    1280   m_piVSPFlag          = pcCU->getVSPFlag()               + uiAbsPartIdx;
    1281   m_pDvInfo            = pcCU->getDvInfo()                + uiAbsPartIdx;
    1282 #endif
    1283 #if H_3D_SPIVMP
    1284   m_pbSPIVMPFlag       = pcCU->getSPIVMPFlag()               + uiAbsPartIdx;
    1285 #endif
    1286878
    1287879  m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx;
    1288880  m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx;
    1289881 
    1290 #if H_3D_ARP
    1291   m_puhARPW            = pcCU->getARPW()                  + uiAbsPartIdx;
    1292 #endif
    1293 
    1294 #if H_3D_DDD
    1295   m_pucDisparityDerivedDepth         = pcCU->getDDDepth()              + uiAbsPartIdx;
    1296   m_pbUseDDD                         = pcCU->getUseDDD()              + uiAbsPartIdx;
    1297 #endif
     882
    1298883   
    1299 #if H_3D_DBBP
    1300   m_pbDBBPFlag       = pcCU->getDBBPFlag()              + uiAbsPartIdx;
    1301 #endif
    1302884
    1303885  m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx );
     
    1305887  memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition);
    1306888  memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition);
    1307 #if H_3D_NBDV
    1308   }
    1309 #endif
    1310 #if H_3D_IC
    1311   m_pbICFlag           = pcCU->getICFlag()                + uiAbsPartIdx;
    1312 #endif
    1313889}
    1314890
     
    1331907  Int sizeInChar  = sizeof( Char ) * uiNumPartition;
    1332908  memcpy( m_skipFlag   + uiOffset, pcCU->getSkipFlag(),       sizeof( *m_skipFlag )   * uiNumPartition );
    1333 #if MTK_SINGLE_DEPTH_MODE_I0095
    1334   memcpy( m_singleDepthFlag     + uiOffset, pcCU->getSingleDepthFlag(),       sizeof( *m_singleDepthFlag )   * uiNumPartition );
    1335   memcpy( m_apSingleDepthValue  + uiOffset, pcCU->getSingleDepthValue(),      sizeof( *m_apSingleDepthValue ) * uiNumPartition);
    1336 #endif
    1337909  memcpy( m_phQP       + uiOffset, pcCU->getQP(),             sizeInChar                        );
    1338910  memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(),  sizeof( *m_pePartSize ) * uiNumPartition );
     
    1341913  memcpy( m_pbMergeFlag         + uiOffset, pcCU->getMergeFlag(),         iSizeInBool  );
    1342914  memcpy( m_puhMergeIndex       + uiOffset, pcCU->getMergeIndex(),        iSizeInUchar );
    1343 #if H_3D_VSP
    1344   memcpy( m_piVSPFlag           + uiOffset, pcCU->getVSPFlag(),           sizeof( Char ) * uiNumPartition );
    1345   memcpy( m_pDvInfo             + uiOffset, pcCU->getDvInfo(),            sizeof( *m_pDvInfo ) * uiNumPartition );
    1346 
    1347 #endif
    1348 #if H_3D_SPIVMP
    1349   memcpy( m_pbSPIVMPFlag        + uiOffset, pcCU->getSPIVMPFlag(),        sizeof( Bool ) * uiNumPartition );
    1350 #endif
    1351915  memcpy( m_puhLumaIntraDir     + uiOffset, pcCU->getLumaIntraDir(),      iSizeInUchar );
    1352916  memcpy( m_puhChromaIntraDir   + uiOffset, pcCU->getChromaIntraDir(),    iSizeInUchar );
     
    1361925  memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar );
    1362926 
    1363 #if H_3D_DDD
    1364   memcpy( m_pucDisparityDerivedDepth          + uiOffset, pcCU->getDDDepth(),         iSizeInUchar );
    1365   memcpy( m_pbUseDDD                          + uiOffset, pcCU->getUseDDD(),          iSizeInBool );
    1366 #endif
    1367 
    1368 
    1369 #if H_3D_DIM
    1370   for( Int i = 0; i < DIM_NUM_TYPE; i++ )
    1371   {
    1372     memcpy( m_dimDeltaDC[i][0] + uiOffset, pcCU->getDimDeltaDC( i, 0 ), sizeof(Pel ) * uiNumPartition );
    1373     memcpy( m_dimDeltaDC[i][1] + uiOffset, pcCU->getDimDeltaDC( i, 1 ), sizeof(Pel ) * uiNumPartition );
    1374   }
    1375 #if H_3D_DIM_DMM
    1376   for( Int i = 0; i < DMM_NUM_TYPE; i++ )
    1377   {
    1378     memcpy( m_dmmWedgeTabIdx[i] + uiOffset, pcCU->getDmmWedgeTabIdx( i ), sizeof(UInt) * uiNumPartition );
    1379   }
    1380 #endif
    1381 #if H_3D_DIM_SDC
    1382   memcpy( m_pbSDCFlag             + uiOffset, pcCU->getSDCFlag(),             iSizeInBool  );
    1383   memcpy( m_apSegmentDCOffset[0]  + uiOffset, pcCU->getSDCSegmentDCOffset(0), sizeof( Pel ) * uiNumPartition);
    1384   memcpy( m_apSegmentDCOffset[1]  + uiOffset, pcCU->getSDCSegmentDCOffset(1), sizeof( Pel ) * uiNumPartition);
    1385 #endif
    1386 #endif
    1387 #if H_3D_DBBP
    1388   memcpy( m_pbDBBPFlag          + uiOffset, pcCU->getDBBPFlag(),          iSizeInBool  );
    1389 #endif
     927
     928
    1390929
    1391930  memcpy( m_puhDepth  + uiOffset, pcCU->getDepth(),  iSizeInUchar );
     
    1431970  memcpy( m_sliceStartCU        + uiOffset, pcCU->m_sliceStartCU,        sizeof( UInt ) * uiNumPartition  );
    1432971  memcpy( m_sliceSegmentStartCU + uiOffset, pcCU->m_sliceSegmentStartCU, sizeof( UInt ) * uiNumPartition  );
    1433 #if H_3D_ARP
    1434   memcpy( m_puhARPW             + uiOffset, pcCU->getARPW(),              iSizeInUchar );
    1435 #endif
    1436 #if H_3D_IC
    1437   memcpy( m_pbICFlag            + uiOffset, pcCU->getICFlag(),            iSizeInBool );
    1438 #endif
    1439972}
    1440973
     
    1455988
    1456989  memcpy( rpcCU->getSkipFlag() + m_uiAbsIdxInLCU, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition );
    1457 #if MTK_SINGLE_DEPTH_MODE_I0095
    1458   memcpy( rpcCU->getSingleDepthFlag()  + m_uiAbsIdxInLCU, m_singleDepthFlag,    sizeof( *m_singleDepthFlag ) * m_uiNumPartition );
    1459   memcpy( rpcCU->getSingleDepthValue() + m_uiAbsIdxInLCU, m_apSingleDepthValue, sizeof( *m_apSingleDepthValue ) * m_uiNumPartition);
    1460 #endif
    1461990  memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, sizeInChar  );
    1462 #if H_3D_NBDV
    1463   memcpy( rpcCU->getDvInfo()         + m_uiAbsIdxInLCU, m_pDvInfo,    sizeof(* m_pDvInfo)     * m_uiNumPartition );
    1464 #endif
    1465 
    1466 #if H_3D_DDD
    1467   memcpy( rpcCU->getDDDepth()          + m_uiAbsIdxInLCU, m_pucDisparityDerivedDepth,         iSizeInUchar  );
    1468   memcpy( rpcCU->getUseDDD()           + m_uiAbsIdxInLCU, m_pbUseDDD,                         iSizeInBool  );
    1469 #endif
     991
    1470992
    1471993  memcpy( rpcCU->getPartitionSize()  + m_uiAbsIdxInLCU, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition );
     
    1474996  memcpy( rpcCU->getMergeFlag()         + m_uiAbsIdxInLCU, m_pbMergeFlag,         iSizeInBool  );
    1475997  memcpy( rpcCU->getMergeIndex()        + m_uiAbsIdxInLCU, m_puhMergeIndex,       iSizeInUchar );
    1476 #if H_3D_VSP
    1477   memcpy( rpcCU->getVSPFlag()           + m_uiAbsIdxInLCU, m_piVSPFlag,           sizeof( Char ) * m_uiNumPartition );
    1478   memcpy( rpcCU->getDvInfo()            + m_uiAbsIdxInLCU, m_pDvInfo,             sizeof( *m_pDvInfo ) * m_uiNumPartition );
    1479 #endif
    1480 #if H_3D_SPIVMP
    1481   memcpy( rpcCU->getSPIVMPFlag()        + m_uiAbsIdxInLCU, m_pbSPIVMPFlag,        sizeof( Bool ) * m_uiNumPartition );
    1482 #endif
    1483998  memcpy( rpcCU->getLumaIntraDir()      + m_uiAbsIdxInLCU, m_puhLumaIntraDir,     iSizeInUchar );
    1484999  memcpy( rpcCU->getChromaIntraDir()    + m_uiAbsIdxInLCU, m_puhChromaIntraDir,   iSizeInUchar );
     
    14931008  memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar );
    14941009 
    1495 #if H_3D_DIM
    1496   for( Int i = 0; i < DIM_NUM_TYPE; i++ )
    1497   {
    1498     memcpy( rpcCU->getDimDeltaDC( i, 0 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][0], sizeof(Pel ) * m_uiNumPartition );
    1499     memcpy( rpcCU->getDimDeltaDC( i, 1 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][1], sizeof(Pel ) * m_uiNumPartition );
    1500   }
    1501 #if H_3D_DIM_DMM
    1502   for( Int i = 0; i < DMM_NUM_TYPE; i++ )
    1503   {
    1504     memcpy( rpcCU->getDmmWedgeTabIdx( i ) + m_uiAbsIdxInLCU, m_dmmWedgeTabIdx[i], sizeof(UInt) * m_uiNumPartition );
    1505   }
    1506 #endif
    1507 #if H_3D_DIM_SDC
    1508   memcpy( rpcCU->getSDCFlag()             + m_uiAbsIdxInLCU, m_pbSDCFlag,      iSizeInBool  );
    1509   memcpy( rpcCU->getSDCSegmentDCOffset(0) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[0], sizeof( Pel ) * m_uiNumPartition);
    1510   memcpy( rpcCU->getSDCSegmentDCOffset(1) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition);
    1511 #endif
    1512 #endif
    1513 #if H_3D_DBBP
    1514   memcpy( rpcCU->getDBBPFlag()          + m_uiAbsIdxInLCU, m_pbDBBPFlag,          iSizeInBool  );
    1515 #endif
    15161010 
    15171011  memcpy( rpcCU->getDepth()  + m_uiAbsIdxInLCU, m_puhDepth,  iSizeInUchar );
     
    15491043  memcpy( rpcCU->m_sliceStartCU        + m_uiAbsIdxInLCU, m_sliceStartCU,        sizeof( UInt ) * m_uiNumPartition  );
    15501044  memcpy( rpcCU->m_sliceSegmentStartCU + m_uiAbsIdxInLCU, m_sliceSegmentStartCU, sizeof( UInt ) * m_uiNumPartition  );
    1551 #if H_3D_ARP
    1552   memcpy( rpcCU->getARPW()             + m_uiAbsIdxInLCU, m_puhARPW,             iSizeInUchar );
    1553 #endif
    1554 #if H_3D_IC
    1555   memcpy( rpcCU->getICFlag()           + m_uiAbsIdxInLCU, m_pbICFlag,            iSizeInBool );
    1556 #endif
    15571045}
    15581046
     
    15741062  Int sizeInChar  = sizeof( Char ) * uiQNumPart;
    15751063  memcpy( rpcCU->getSkipFlag()       + uiPartOffset, m_skipFlag,   sizeof( *m_skipFlag )   * uiQNumPart );
    1576 #if MTK_SINGLE_DEPTH_MODE_I0095
    1577   memcpy( rpcCU->getSingleDepthFlag()  + uiPartOffset, m_singleDepthFlag,    sizeof( *m_singleDepthFlag )   * uiQNumPart );
    1578   memcpy( rpcCU->getSingleDepthValue() + uiPartOffset, m_apSingleDepthValue, sizeof( *m_apSingleDepthValue ) * uiQNumPart);
    1579 #endif
    15801064  memcpy( rpcCU->getQP() + uiPartOffset, m_phQP, sizeInChar );
    15811065  memcpy( rpcCU->getPartitionSize()  + uiPartOffset, m_pePartSize, sizeof( *m_pePartSize ) * uiQNumPart );
     
    15841068  memcpy( rpcCU->getMergeFlag()         + uiPartOffset, m_pbMergeFlag,         iSizeInBool  );
    15851069  memcpy( rpcCU->getMergeIndex()        + uiPartOffset, m_puhMergeIndex,       iSizeInUchar );
    1586 #if H_3D_VSP
    1587   memcpy( rpcCU->getVSPFlag()           + uiPartOffset, m_piVSPFlag,           sizeof(Char) * uiQNumPart );
    1588 #endif
    1589 #if H_3D_SPIVMP
    1590   memcpy( rpcCU->getSPIVMPFlag()        + uiPartOffset, m_pbSPIVMPFlag,        sizeof(Bool) * uiQNumPart );
    1591 #endif
    15921070  memcpy( rpcCU->getLumaIntraDir()      + uiPartOffset, m_puhLumaIntraDir,     iSizeInUchar );
    15931071  memcpy( rpcCU->getChromaIntraDir()    + uiPartOffset, m_puhChromaIntraDir,   iSizeInUchar );
     
    16011079  memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar );
    16021080 
    1603 #if H_3D_DDD
    1604   memcpy( rpcCU->getDDDepth()          + uiPartOffset, m_pucDisparityDerivedDepth,         iSizeInUchar );
    1605   memcpy( rpcCU->getUseDDD()           + uiPartOffset, m_pbUseDDD,                         iSizeInBool );
    1606 #endif
    1607 
    1608 #if H_3D_DIM
    1609   for( Int i = 0; i < DMM_NUM_TYPE; i++ )
    1610   {
    1611     memcpy( rpcCU->getDimDeltaDC( i, 0 ) + uiPartOffset, m_dimDeltaDC[i][0], sizeof(Pel ) * uiQNumPart );
    1612     memcpy( rpcCU->getDimDeltaDC( i, 1 ) + uiPartOffset, m_dimDeltaDC[i][1], sizeof(Pel ) * uiQNumPart );
    1613   }
    1614 #if H_3D_DIM_DMM
    1615   for( Int i = 0; i < DMM_NUM_TYPE; i++ )
    1616   {
    1617     memcpy( rpcCU->getDmmWedgeTabIdx( i ) + uiPartOffset, m_dmmWedgeTabIdx[i], sizeof(UInt) * uiQNumPart );
    1618   }
    1619 #endif
    1620 #if H_3D_DIM_SDC
    1621   memcpy( rpcCU->getSDCFlag()             + uiPartOffset, m_pbSDCFlag,      iSizeInBool  );
    1622   memcpy( rpcCU->getSDCSegmentDCOffset(0) + uiPartOffset, m_apSegmentDCOffset[0], sizeof( Pel ) * uiQNumPart);
    1623   memcpy( rpcCU->getSDCSegmentDCOffset(1) + uiPartOffset, m_apSegmentDCOffset[1], sizeof( Pel ) * uiQNumPart);
    1624 #endif
    1625 #endif
    1626 #if H_3D_DBBP
    1627   memcpy( rpcCU->getDBBPFlag()          + uiPartOffset, m_pbDBBPFlag,          iSizeInBool  );
    1628 #endif
     1081
    16291082 
    16301083  memcpy( rpcCU->getDepth()  + uiPartOffset, m_puhDepth,  iSizeInUchar );
     
    16631116  memcpy( rpcCU->m_sliceStartCU        + uiPartOffset, m_sliceStartCU,        sizeof( UInt ) * uiQNumPart  );
    16641117  memcpy( rpcCU->m_sliceSegmentStartCU + uiPartOffset, m_sliceSegmentStartCU, sizeof( UInt ) * uiQNumPart  );
    1665 #if H_3D_ARP
    1666   memcpy( rpcCU->getARPW()             + uiPartOffset, m_puhARPW,             iSizeInUchar );
    1667 #endif
    1668 #if H_3D_IC
    1669   memcpy( rpcCU->getICFlag()           + uiPartOffset, m_pbICFlag,            iSizeInBool );
    1670 #endif
    1671 }
    1672 
    1673 #if H_3D_DDD
    1674 Void TComDataCU::setDDDepthSubParts ( UChar ucDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    1675 {
    1676     setSubPart<UChar>( ucDDD, m_pucDisparityDerivedDepth, uiAbsPartIdx, uiDepth, uiPartIdx );
    1677 }
    1678 
    1679 Void TComDataCU::setUseDDD        ( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    1680 {
    1681     setSubPart<Bool>( bUseDDD, m_pbUseDDD, uiAbsPartIdx, uiDepth, uiPartIdx );
    1682 }
    1683 
    1684 Void TComDataCU::setUseDDD( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiDepth )
    1685 {
    1686     memset( m_pbUseDDD + uiAbsPartIdx, bUseDDD, (m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ))*sizeof(Bool) );
    1687 }
    1688 
    1689 #endif
     1118}
     1119
    16901120
    16911121// --------------------------------------------------------------------------------------------------------------------
     
    22061636 
    22071637  iLeftIntraDir  = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
    2208 #if H_3D_DIM
    2209   mapDepthModeToIntraDir( iLeftIntraDir );
    2210 #endif
    22111638 
    22121639  // Get intra direction of above PU
     
    22141641 
    22151642  iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
    2216 #if H_3D_DIM
    2217   mapDepthModeToIntraDir( iAboveIntraDir );
    2218 #endif
    22191643 
    22201644  uiPredNum = 3;
     
    23341758}
    23351759
    2336 #if H_3D_ARP
    2337 UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx )
    2338 {
    2339   TComDataCU* pcTempCU;
    2340   UInt        uiTempPartIdx;
    2341   UInt        uiCtx = 0;
    2342  
    2343   pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
    2344   uiCtx    = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0;
    2345     return uiCtx;
    2346 }
    2347 #endif
    2348 #if H_3D_DBBP
    2349 Pel* TComDataCU::getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride)
    2350 {
    2351   // get coded and reconstructed depth view
    2352   TComPicYuv* depthPicYuv = NULL;
    2353   Pel* pDepthPels = NULL;
    2354  
    2355   // DBBP is a texture coding tool
    2356   if( getSlice()->getIsDepth() )
    2357   {
    2358     return NULL;
    2359   }
    2360  
    2361 #if H_3D_FCO
    2362   TComPic* depthPic = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    2363  
    2364   if( depthPic && depthPic->getPicYuvRec() != NULL && depthPic->getIsDepth() )  // depth first
    2365   {
    2366     depthPicYuv = depthPic->getPicYuvRec();
    2367     depthPicYuv->extendPicBorder();
    2368    
    2369     // get collocated depth block for current CU
    2370     uiDepthStride = depthPicYuv->getStride();
    2371     pDepthPels    = depthPicYuv->getLumaAddr( getAddr(), uiAbsPartIdx );
    2372   }
    2373   else  // texture first
    2374 #else
    2375   {
    2376     DisInfo DvInfo = getDvInfo(uiAbsPartIdx);
    2377    
    2378     TComPic* baseDepthPic = getSlice()->getIvPic (true, DvInfo.m_aVIdxCan);
    2379    
    2380     if( baseDepthPic == NULL || baseDepthPic->getPicYuvRec() == NULL )
    2381     {
    2382       return NULL;
    2383     }
    2384    
    2385     depthPicYuv   = baseDepthPic->getPicYuvRec();
    2386     depthPicYuv->extendPicBorder();
    2387     uiDepthStride = depthPicYuv->getStride();
    2388    
    2389     Int iBlkX = ( getAddr() % baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ];
    2390     Int iBlkY = ( getAddr() / baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ];
    2391    
    2392     Int iPictureWidth  = depthPicYuv->getWidth();
    2393     Int iPictureHeight = depthPicYuv->getHeight();
    2394    
    2395     Int iWidth  = uiWidth;
    2396     Int iHeight = uiHeight;
    2397    
    2398     Bool depthRefineFlag = false;
    2399 #if H_3D_NBDV_REF
    2400     depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() );
    2401 #endif // H_3D_NBDV_REF
    2402    
    2403     TComMv cDv = depthRefineFlag ? DvInfo.m_acDoNBDV : DvInfo.m_acNBDV;
    2404     if( depthRefineFlag )
    2405     {
    2406       cDv.setVer(0);
    2407     }
    2408    
    2409     Int depthPosX = Clip3(0,   iPictureWidth - iWidth,  iBlkX + ((cDv.getHor()+2)>>2));
    2410     Int depthPosY = Clip3(0,   iPictureHeight- iHeight, iBlkY + ((cDv.getVer()+2)>>2));
    2411    
    2412     pDepthPels = depthPicYuv->getLumaAddr() + depthPosX + depthPosY * uiDepthStride;
    2413   }
    2414 #endif
    2415  
    2416   AOF( depthPicYuv != NULL );
    2417   AOF( pDepthPels != NULL );
    2418   AOF( uiDepthStride != 0 );
    2419  
    2420   return pDepthPels;
    2421 }
    2422 #endif
    2423 
    2424 #if H_3D_DBBP
    2425 Void TComDataCU::setDBBPFlagSubParts ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    2426 {
    2427   setSubPart( bDBBPFlag, m_pbDBBPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
    2428 }
    2429 #endif
    2430 
    2431 #if H_3D_DIM_SDC
    2432 UInt TComDataCU::getCtxSDCFlag( UInt uiAbsPartIdx )
    2433 {
    2434   return 0;
    2435 }
    2436 
    2437 #endif
     1760
     1761
    24381762
    24391763UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx )
     
    24971821  memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartInCU() >> ( 2 * depth ) );
    24981822}
    2499 #if MTK_SINGLE_DEPTH_MODE_I0095
    2500 Void TComDataCU::setSingleDepthFlagSubParts( Bool singleDepth, UInt absPartIdx, UInt depth )
    2501 {
    2502   assert( sizeof( *m_singleDepthFlag) == 1 );
    2503   memset( m_singleDepthFlag + absPartIdx, singleDepth, m_pcPic->getNumPartInCU() >> ( 2 * depth ) );
    2504 }
    2505 
    2506 Void TComDataCU::setSingleDepthValueSubParts(Pel singleDepthValue, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth )
    2507 {
    2508   setSubPartT<Pel>( singleDepthValue, m_apSingleDepthValue, uiAbsPartIdx, uiDepth, uiPUIdx );
    2509 }
    2510 #endif
    25111823Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth )
    25121824{
     
    26621974}
    26631975
    2664 #if H_3D_DIM_SDC
    2665 Void TComDataCU::setSDCFlagSubParts ( Bool bSDCFlag, UInt uiAbsPartIdx, UInt uiDepth )
    2666 {
    2667   assert( sizeof( *m_pbSDCFlag) == 1 );
    2668   memset( m_pbSDCFlag + uiAbsPartIdx, bSDCFlag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) );
    2669 }
    2670 
    2671 Bool TComDataCU::getSDCAvailable( UInt uiAbsPartIdx )
    2672 {
    2673   // check general CU information
    2674   if( !getSlice()->getIsDepth() || !isIntra(uiAbsPartIdx) || getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N )
    2675   {
    2676     return false;
    2677   }
    2678 
    2679 #if HS_DMM_SIGNALLING_I0120
    2680   if( isDimMode( getLumaIntraDir( uiAbsPartIdx ) ) )
    2681 #else
    2682   if( isDimMode( getLumaIntraDir( uiAbsPartIdx ) ) && !isDimDeltaDC( getLumaIntraDir( uiAbsPartIdx ) ) )
    2683 #endif
    2684   {
    2685     return true;
    2686   }
    2687  
    2688   if( getLumaIntraDir( uiAbsPartIdx ) < NUM_INTRA_MODE )
    2689   {
    2690     return true;
    2691   }
    2692 
    2693   return false;
    2694   // check prediction mode
    2695   UInt uiLumaPredMode = getLumaIntraDir( uiAbsPartIdx ); 
    2696 #if HS_DMM_SIGNALLING_I0120
    2697   if( uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX  ) )
    2698 #else
    2699   if( uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX && !isDimDeltaDC( uiLumaPredMode ) ) )
    2700 #endif
    2701     return true;
    2702  
    2703   // else
    2704   return false;
    2705 }
    2706 #endif
    27071976Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    27081977{
     
    27151984}
    27161985
    2717 #if H_3D_SPIVMP
    2718 Void TComDataCU::setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    2719 {
    2720   setSubPart<Bool>( bSPIVMPFlag, m_pbSPIVMPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
    2721 }
    2722 #endif
    2723 
    2724 #if H_3D_VSP
    2725 Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    2726 {
    2727   setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
    2728 }
    2729 #if H_3D_VSP
    2730 template<typename T>
    2731 Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx )
    2732 {
    2733   UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2;
    2734   switch ( m_pePartSize[ uiCUAddr ] )
    2735   {
    2736   case SIZE_2Nx2N:
    2737     for (UInt ui = 0; ui < 4 * uiCurrPartNumQ; ui++)
    2738       puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2739 
    2740     break;
    2741   case SIZE_2NxN:
    2742     for (UInt ui = 0; ui < 2 * uiCurrPartNumQ; ui++)
    2743       puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2744     break;
    2745   case SIZE_Nx2N:
    2746     for (UInt ui = 0; ui < uiCurrPartNumQ; ui++)
    2747       puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2748     for (UInt ui = 0; ui < uiCurrPartNumQ; ui++)
    2749       puhBaseLCU[uiCUAddr + 2 * uiCurrPartNumQ + ui] = uiParameter;
    2750     break;
    2751   case SIZE_NxN:
    2752     for (UInt ui = 0; ui < uiCurrPartNumQ; ui++)
    2753       puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2754     break;
    2755   case SIZE_2NxnU:
    2756     if ( uiPUIdx == 0 )
    2757     {
    2758       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++)
    2759         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2760       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++)
    2761         puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter;
    2762 
    2763     }
    2764     else if ( uiPUIdx == 1 )
    2765     {
    2766       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++)
    2767         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2768       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1); ui++)
    2769         puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter;
    2770 
    2771     }
    2772     else
    2773     {
    2774       assert(0);
    2775     }
    2776     break;
    2777   case SIZE_2NxnD:
    2778     if ( uiPUIdx == 0 )
    2779     {
    2780       for (UInt ui = 0; ui < ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)); ui++)
    2781         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2782       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++)
    2783         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + ui] = uiParameter;
    2784 
    2785     }
    2786     else if ( uiPUIdx == 1 )
    2787     {
    2788       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++)
    2789         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2790       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++)
    2791         puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter;
    2792 
    2793     }
    2794     else
    2795     {
    2796       assert(0);
    2797     }
    2798     break;
    2799   case SIZE_nLx2N:
    2800     if ( uiPUIdx == 0 )
    2801     {
    2802       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2803         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2804       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2805         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2806       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2807         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter;
    2808       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2809         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2810 
    2811     }
    2812     else if ( uiPUIdx == 1 )
    2813     {
    2814       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2815         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2816       for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++)
    2817         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2818       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2819         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter;
    2820       for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++)
    2821         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2822 
    2823     }
    2824     else
    2825     {
    2826       assert(0);
    2827     }
    2828     break;
    2829   case SIZE_nRx2N:
    2830     if ( uiPUIdx == 0 )
    2831     {
    2832       for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++)
    2833         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2834       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2835         puhBaseLCU[uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2836       for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++)
    2837         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter;
    2838       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2839         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2840 
    2841     }
    2842     else if ( uiPUIdx == 1 )
    2843     {
    2844       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2845         puhBaseLCU[uiCUAddr + ui] = uiParameter;
    2846       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2847         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2848       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2849         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter;
    2850       for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++)
    2851         puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter;
    2852 
    2853     }
    2854     else
    2855     {
    2856       assert(0);
    2857     }
    2858     break;
    2859   default:
    2860     assert( 0 );
    2861   }
    2862 
    2863 }
    2864 #endif
    2865 #endif
     1986
    28661987Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth )
    28671988{
     
    29382059}
    29392060
    2940 #if H_3D_IC
    2941 Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU)
    2942 {
    2943   UInt uiNumPartition  = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition;
    2944   UInt  uiTmpAbsPartIdx  = bLCU ? uiAbsPartIdx : 0;
    2945 
    2946   switch ( m_pePartSize[uiTmpAbsPartIdx] )
    2947   {
    2948   case SIZE_2NxN:
    2949     riWidth = getWidth( uiTmpAbsPartIdx );      riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1;
    2950     break;
    2951   case SIZE_Nx2N:
    2952     riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx );      ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2;
    2953     break;
    2954   case SIZE_NxN:
    2955     riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx;
    2956     break;
    2957   case SIZE_2NxnU:
    2958     riWidth     = getWidth( uiTmpAbsPartIdx );
    2959     riHeight    = ( uiPartIdx == 0 ) ?  getHeight( uiTmpAbsPartIdx ) >> 2 : ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 );
    2960     ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3;
    2961     break;
    2962   case SIZE_2NxnD:
    2963     riWidth     = getWidth( uiTmpAbsPartIdx );
    2964     riHeight    = ( uiPartIdx == 0 ) ?  ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ) : getHeight( uiTmpAbsPartIdx ) >> 2;
    2965     ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3);
    2966     break;
    2967   case SIZE_nLx2N:
    2968     riWidth     = ( uiPartIdx == 0 ) ? getWidth( uiTmpAbsPartIdx ) >> 2 : ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 );
    2969     riHeight    = getHeight( uiTmpAbsPartIdx );
    2970     ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4;
    2971     break;
    2972   case SIZE_nRx2N:
    2973     riWidth     = ( uiPartIdx == 0 ) ? ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ) : getWidth( uiTmpAbsPartIdx ) >> 2;
    2974     riHeight    = getHeight( uiTmpAbsPartIdx );
    2975     ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4);
    2976     break;
    2977   default:
    2978     assert ( m_pePartSize[uiTmpAbsPartIdx] == SIZE_2Nx2N );
    2979     riWidth = getWidth( uiTmpAbsPartIdx );      riHeight = getHeight( uiTmpAbsPartIdx );      ruiPartAddr = 0;
    2980     break;
    2981   }
    2982 }
    2983 #else
    29842061Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight )
    29852062{
     
    30212098  }
    30222099}
    3023 #endif
    30242100
    30252101
     
    32922368}
    32932369
    3294 #if H_3D_VSP
    3295 
    3296 /** Add a VSP merging candidate
    3297  * \Inputs
    3298  * \param uiPUIdx: PU index within a CU
    3299  * \param ucVspMergePos: Specify the VSP merge candidate position
    3300  * \param mrgCandIdx: Target merge candidate index. At encoder, it is set equal to -1, such that the whole merge candidate list will be constructed.
    3301  * \param pDinfo: The "disparity information" derived from neighboring blocks. Type 1 MV.
    3302  * \param uiCount: The next position to add VSP merge candidate
    3303  *
    3304  * \Outputs
    3305  * \param uiCount: The next position to add merge candidate. Will be updated if VSP is successfully added
    3306  * \param abCandIsInter: abCandIsInter[iCount] tells that VSP candidate is an Inter candidate, if VSP is successfully added
    3307  * \param pcMvFieldNeighbours:   Return combined motion information, then stored to a global buffer
    3308  *                                    1) the "disparity vector". Type 1 MV. To be used to fetch a depth block.
    3309  *                                    2) the ref index /list.    Type 2 reference picture pointer, typically for texture
    3310  * \param puhInterDirNeighbours: Indicate the VSP prediction direction.
    3311  * \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
    3312  *
    3313  * \Return
    3314  *   true:  if the VSP candidate is added at the target position
    3315  *   false: otherwise
    3316  */
    3317 inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount)
    3318 {
    3319   if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) || m_pcSlice->getIsDepth() || pDInfo->m_aVIdxCan == -1)
    3320   {
    3321     return false;
    3322   }
    3323 
    3324   Int refViewIdx = pDInfo->m_aVIdxCan;
    3325   TComPic* picDepth = getSlice()->getIvPic( true, refViewIdx );
    3326 
    3327   if( picDepth == NULL ) // No depth reference avail
    3328   {
    3329     // Is this allowed to happen? When not an assertion should be added here!
    3330     return false;
    3331   }
    3332 
    3333   TComMvField mvVSP[2];
    3334   UChar dirVSP;
    3335   Bool  refViewAvailFlag = false;
    3336   UChar predFlag[2]      = {0, 0};
    3337 
    3338   for( Int iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ )
    3339   {
    3340     RefPicList eRefPicListX = RefPicList( iRefListIdX );
    3341     for ( Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicListX) && !refViewAvailFlag; i++ )
    3342     {
    3343       Int viewIdxRefInListX = m_pcSlice->getRefPic(eRefPicListX, i)->getViewIndex();
    3344       if ( viewIdxRefInListX == refViewIdx )
    3345       {
    3346         refViewAvailFlag      = true;
    3347         predFlag[iRefListIdX] = 1;
    3348         mvVSP[0+iRefListIdX].setMvField( pDInfo->m_acNBDV, i );
    3349 #if H_3D_NBDV
    3350         mvVSP[0+iRefListIdX].getMv().setIDVFlag (false);
    3351 #endif
    3352       }
    3353     }
    3354   }
    3355 
    3356   dirVSP = (predFlag[0] | (predFlag[1] << 1));
    3357   m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true, false);
    3358   if ( mrgCandIdx == iCount )
    3359   {
    3360     return true;
    3361   }
    3362 
    3363   iCount++;
    3364 
    3365   return false;
    3366 }
    3367 
    3368 #endif
    3369 
    3370 #if H_3D_IV_MERGE
    3371 inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx )
    3372 {
    3373   for(Int iLoop = 0; iLoop < 2; iLoop ++ )
    3374   {
    3375 #if !SEC_SIMP_SHIFTED_DV_I0086
    3376     // IvDcShift (Derived from spatial Iv neighboring blocks)
    3377     if( iLoop == 1 )
    3378     {
    3379       Int iFirDispCand = -1;
    3380       TComMvField mvIvDcShift[2];
    3381       UChar dirIvDcShift;
    3382 
    3383       if (xGetPosFirstAvailDmvCand(MRG_IVSHIFT, iFirDispCand))
    3384       {
    3385         TComMv cMv;
    3386         cMv = m_mergCands[iFirDispCand].m_cMvField[0].getMv();
    3387         cMv.setHor(cMv.getHor()+4);
    3388         if(m_pcSlice->getVPS()->getViewSynthesisPredFlag(m_pcSlice->getLayerIdInVps()))
    3389         {
    3390           cMv.setVer(0);
    3391         }
    3392 #if !(NTT_BUG_FIX_TK54)
    3393         clipMv( cMv );
    3394 #endif
    3395 
    3396         dirIvDcShift = m_mergCands[iFirDispCand].m_uDir;
    3397         mvIvDcShift[0].setMvField(cMv, m_mergCands[iFirDispCand].m_cMvField[0].getRefIdx() );
    3398         mvIvDcShift[1].setMvField(m_mergCands[iFirDispCand].m_cMvField[1].getMv(), m_mergCands[iFirDispCand].m_cMvField[1].getRefIdx() );
    3399         m_mergCands[MRG_IVSHIFT].setCand(mvIvDcShift, dirIvDcShift, false, false);
    3400        
    3401         if( mrgCandIdx == iCount )
    3402         {
    3403           return true;
    3404         }
    3405         iCount++;
    3406         break;
    3407       }
    3408     }
    3409 #endif
    3410 
    3411     /// iLoop = 0 --> IvMCShift
    3412     /// iLoop = 1 --> IvDCShift  (Derived from IvDC)
    3413     if(ivCandDir[iLoop + 2])
    3414     {
    3415       TComMvField tmpMV[2];
    3416       UChar tmpDir = ivCandDir[iLoop + 2];
    3417       if( ( ivCandDir[iLoop + 2] & 1 ) == 1 )
    3418       {
    3419         tmpMV[0].setMvField( ivCandMv[ (iLoop<<1) + 4 ], ivCandRefIdx[ (iLoop<<1) + 4 ] );
    3420       }
    3421       if( ( ivCandDir[iLoop + 2] & 2 ) == 2 )
    3422       {
    3423         tmpMV[1].setMvField( ivCandMv[ (iLoop<<1) + 5 ], ivCandRefIdx[ (iLoop<<1) + 5 ] );
    3424       }
    3425      
    3426       // Prune IvMC vs. IvMcShift
    3427       Bool bRemove = false;     
    3428       if( !iLoop && ivCandDir[0] > 0)
    3429       {
    3430         if(tmpDir == m_mergCands[MRG_IVMC].m_uDir && m_mergCands[MRG_IVMC].m_cMvField[0]==tmpMV[0] && m_mergCands[MRG_IVMC].m_cMvField[1]==tmpMV[1])
    3431         {
    3432             bRemove                         = true;
    3433         }
    3434       }
    3435       if(!bRemove)
    3436       {
    3437 #if H_3D_NBDV
    3438         if(iLoop) // For IvMcShift candidate
    3439         {
    3440           tmpMV[0].getMv().setIDVFlag (false);
    3441           tmpMV[1].getMv().setIDVFlag (false);
    3442         }
    3443 #endif
    3444         m_mergCands[MRG_IVSHIFT].setCand(tmpMV, tmpDir, false, false);
    3445         if( mrgCandIdx == iCount )
    3446         {
    3447           return true;
    3448         }
    3449         iCount++;
    3450       }
    3451       break;
    3452     }
    3453   }
    3454   return false;
    3455 }
    3456 
    3457 #if !SEC_SIMP_SHIFTED_DV_I0086
    3458 inline Bool TComDataCU::xGetPosFirstAvailDmvCand(Int iCount, Int& posFirstAvailDmvCand )
    3459 {
    3460   for ( Int currListPos = 0; currListPos < iCount; currListPos++ )
    3461   {
    3462     if ( !m_mergCands[currListPos].m_bAvailable || ( currListPos == MRG_IVMC ) || ( currListPos == MRG_IVDC ) || ( m_mergCands[currListPos].m_iVspFlag != 0 ))
    3463     {
    3464       continue;
    3465     }
    3466     else if((m_mergCands[currListPos].m_bAvailable) && (m_mergCands[currListPos].m_cMvField[0].getRefIdx() != -1 ) && (getSlice()->getViewIndex() != getSlice()->getRefPic(RefPicList(0), m_mergCands[currListPos].m_cMvField[0].getRefIdx())->getViewIndex()))
    3467     {
    3468       posFirstAvailDmvCand = currListPos;
    3469       return true;
    3470     }
    3471   }
    3472   return false; 
    3473 }
    3474 #endif
    3475                                      
    3476 #endif
    3477 
    3478 #if H_3D
    3479 Void TComDataCU::buildMCL(TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    3480 #if H_3D_VSP
    3481   , Int* vspFlag
    3482 #endif
    3483 #if H_3D_SPIVMP
    3484   , Bool* pbSPIVMPFlag
    3485 #endif
    3486   , Int& numValidMergeCand
    3487   )
    3488 {
    3489   if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))  // for only dependent texture
    3490   {
    3491     return;
    3492   }
    3493 
    3494   Int iCount = 0;
    3495   TComMv cZeroMv;
    3496 
    3497   // init temporal list
    3498   TComMvField extMergeCandList[MRG_MAX_NUM_CANDS_MEM << 1];
    3499   UChar uhInterDirNeighboursExt[MRG_MAX_NUM_CANDS_MEM];
    3500   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
    3501   {
    3502     uhInterDirNeighboursExt[ui] = puhInterDirNeighbours[ui];
    3503     extMergeCandList[ui<<1].setMvField(cZeroMv, NOT_VALID);
    3504     extMergeCandList[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID);
    3505     vspFlag[ui] = 0;
    3506   }
    3507 
    3508   // add candidates to temporal list
    3509   // insert MPI ... IvShift candidate
    3510   for (Int i=0; i<=MRG_IVSHIFT; i++)
    3511   {
    3512     if (m_mergCands[i].m_bAvailable)
    3513     {
    3514       m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt, vspFlag, pbSPIVMPFlag);
    3515       iCount++;
    3516       if (iCount >= getSlice()->getMaxNumMergeCand())
    3517         break;
    3518     }
    3519   }
    3520 
    3521   // insert remaining base candidates
    3522   while (iCount < getSlice()->getMaxNumMergeCand() && m_baseListidc < getSlice()->getMaxNumMergeCand())
    3523   {
    3524     uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[m_baseListidc];
    3525     extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[m_baseListidc<<1].getMv(), pcMvFieldNeighbours[m_baseListidc<<1].getRefIdx());
    3526     if ( getSlice()->isInterB() )
    3527     {
    3528       extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(m_baseListidc<<1)+1].getMv(), pcMvFieldNeighbours[(m_baseListidc<<1)+1].getRefIdx());
    3529     }
    3530     m_baseListidc++;
    3531     iCount++;
    3532   }
    3533 
    3534   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ )
    3535   {
    3536     puhInterDirNeighbours[ui] = 0;
    3537     pcMvFieldNeighbours[ui<<1].setMvField(cZeroMv, NOT_VALID);
    3538     pcMvFieldNeighbours[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID);
    3539   }
    3540   // copy extMergeCandList to output
    3541   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ )
    3542   {
    3543     puhInterDirNeighbours[ui] = uhInterDirNeighboursExt[ui];
    3544     pcMvFieldNeighbours[ui<<1].setMvField(extMergeCandList[ui<<1].getMv(), extMergeCandList[ui<<1].getRefIdx());
    3545     if ( getSlice()->isInterB() )
    3546       pcMvFieldNeighbours[(ui<<1)+1].setMvField(extMergeCandList[(ui<<1)+1].getMv(), extMergeCandList[(ui<<1)+1].getRefIdx());
    3547   }
    3548   numValidMergeCand = iCount;
    3549   assert(iCount == getSlice()->getMaxNumMergeCand());
    3550 }
     2370
     2371
    35512372
    35522373/** Constructs a list of merging candidates
     
    35582379 * \param numValidMergeCand
    35592380 */
    3560 // HM 12.0 based merge candidate list construction
    3561 
    3562 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
    3563 {
    3564 
     2381Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
     2382      , Int& numValidMergeCand, Int mrgCandIdx
     2383)
     2384{
    35652385  UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx;
    3566   Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
    3567   TComMv cZeroMv;
     2386  Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
    35682387  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
    35692388  {
    35702389    abCandIsInter[ui] = false;
    3571     pcMvFieldNeighbours[ ( ui << 1 )     ].setMvField(cZeroMv, NOT_VALID);
    3572     pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID);
     2390    pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
     2391    pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
    35732392  }
    35742393  numValidMergeCand = getSlice()->getMaxNumMergeCand();
     
    35892408  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
    35902409  Bool isAvailableA1 = pcCULeft &&
    3591     pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
    3592     !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
    3593     !pcCULeft->isIntra( uiLeftPartIdx ) ;
     2410  pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
     2411  !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
     2412  !pcCULeft->isIntra( uiLeftPartIdx ) ;
    35942413  if ( isAvailableA1 )
    35952414  {
    3596     m_bAvailableFlagA1 = 1;
    35972415    abCandIsInter[iCount] = true;
    35982416    // get Inter Dir
     
    36042422      pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    36052423    }
    3606 
     2424    if ( mrgCandIdx == iCount )
     2425    {
     2426      return;
     2427    }
    36072428    iCount ++;
    36082429  }
     
    36132434    return;
    36142435  }
     2436
    36152437  // above
    36162438  UInt uiAbovePartIdx = 0;
     
    36232445  if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
    36242446  {
    3625     m_bAvailableFlagB1 = 1;
    36262447    abCandIsInter[iCount] = true;
    36272448    // get Inter Dir
     
    36332454      pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    36342455    }
     2456
    36352457    if ( mrgCandIdx == iCount )
    36362458    {
     
    36442466    return;
    36452467  }
     2468
    36462469
    36472470  // above right
     
    36542477  if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
    36552478  {
    3656     m_bAvailableFlagB0 = 1;
    36572479    abCandIsInter[iCount] = true;
    36582480    // get Inter Dir
     
    36852507  if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
    36862508  {
    3687     m_bAvailableFlagA0 = 1;
    36882509    abCandIsInter[iCount] = true;
    36892510    // get Inter Dir
     
    36952516      pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    36962517    }
     2518
    36972519    if ( mrgCandIdx == iCount )
    36982520    {
     
    37062528    return;
    37072529  }
     2530
    37082531  // above left
    37092532  if( iCount < 4 )
     
    37182541        && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
    37192542    {
    3720       m_bAvailableFlagB2 = 1;
    37212543      abCandIsInter[iCount] = true;
    37222544      // get Inter Dir
     
    37402562    return;
    37412563  }
    3742   if ( getSlice()->getEnableTMVPFlag())
    3743   {
    3744     //>> MTK colocated-RightBottom
    3745     UInt uiPartIdxRB;
    3746 
    3747     deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 
    3748 
    3749     UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
    3750     UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
    3751 
    3752     TComMv cColMv;
    3753     Int iRefIdx;
    3754     Int uiLCUIdx = -1;
    3755 
    3756     if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
    3757     {
    3758     }
    3759     else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
    3760     {
    3761     }
    3762     else
    3763     {
    3764       if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
    3765         ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
    3766       {
    3767         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
    3768         uiLCUIdx = getAddr();
    3769       }
    3770       else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
    3771       {
    3772         uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
    3773       }
    3774       else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
    3775       {
    3776         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
    3777         uiLCUIdx = getAddr() + 1;
    3778       }
    3779       else //is the right bottom corner of LCU                       
    3780       {
    3781         uiAbsPartAddr = 0;
    3782       }
    3783     }
    3784 
    3785     iRefIdx = 0;
    3786     Bool bExistMV = false;
    3787     UInt uiPartIdxCenter;
    3788     UInt uiCurLCUIdx = getAddr();
    3789     Int dir = 0;
    3790     UInt uiArrayAddr = iCount;
    3791     xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
    3792     bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx );
    3793     if( bExistMV == false )
    3794     {
    3795       bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
    3796     }
    3797     if( bExistMV )
    3798     {
    3799       dir |= 1;
    3800       pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx );
    3801     }
    3802 
    3803     if ( getSlice()->isInterB() )
    3804     {
    3805 #if H_3D_TMVP
    3806       iRefIdx = 0;
    3807 #endif
    3808       bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
    3809       if( bExistMV == false )
    3810       {
    3811         bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
    3812       }
    3813       if( bExistMV )
    3814       {
    3815         dir |= 2;
    3816         pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx );
    3817       }
    3818     }
    3819 
    3820     if (dir != 0)
    3821     {
    3822       puhInterDirNeighbours[uiArrayAddr] = dir;
    3823       abCandIsInter[uiArrayAddr] = true;
    3824 #if H_3D_NBDV
    3825       pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
    3826       pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
    3827 #endif
    3828       if ( mrgCandIdx == iCount )
    3829       {
    3830         return;
    3831       }
    3832       iCount++;
    3833     }
    3834   }
    3835   // early termination
    3836   if (iCount == getSlice()->getMaxNumMergeCand())
    3837   {
    3838     return;
    3839   }
    3840   UInt uiArrayAddr = iCount;
    3841   UInt uiCutoff = uiArrayAddr;
    3842  
    3843   if ( getSlice()->isInterB() && iCount<5)  // JCT3V-F0129 by Qualcomm
    3844   {
    3845     UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
    3846     UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
    3847 
    3848     for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
    3849     {
    3850       Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx];
    3851       if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
    3852       {
    3853         abCandIsInter[uiArrayAddr] = true;
    3854         puhInterDirNeighbours[uiArrayAddr] = 3;
    3855 
    3856         // get Mv from cand[i] and cand[j]
    3857         pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx());
    3858         pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx());
    3859 
    3860         Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() );
    3861         Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() );
    3862         if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv())
    3863         {
    3864           abCandIsInter[uiArrayAddr] = false;
    3865         }
    3866         else
    3867         {
    3868           uiArrayAddr++;
    3869         }
    3870       }
    3871     }
    3872   }
    3873   // early termination
    3874   if (uiArrayAddr == getSlice()->getMaxNumMergeCand())
    3875   {
    3876     return;
    3877   }
    3878  
    3879   Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0);
    3880   Int r = 0;
    3881   Int refcnt = 0;
    3882   while (uiArrayAddr < getSlice()->getMaxNumMergeCand())
    3883   {
    3884     abCandIsInter[uiArrayAddr] = true;
    3885     puhInterDirNeighbours[uiArrayAddr] = 1;
    3886     pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r);
    3887 
    3888     if ( getSlice()->isInterB() )
    3889     {
    3890       puhInterDirNeighbours[uiArrayAddr] = 3;
    3891       pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r);
    3892     }
    3893     uiArrayAddr++;
    3894     if ( refcnt == iNumRefIdx - 1 )
    3895     {
    3896       r = 0;
    3897     }
    3898     else
    3899     {
    3900       ++r;
    3901       ++refcnt;
    3902     }
    3903   }
    3904  
    3905   numValidMergeCand = uiArrayAddr;
    3906 }
    3907 
    3908 
    3909 
    3910 /** Constructs a list of merging candidates
    3911  * \param uiAbsPartIdx
    3912  * \param uiPUIdx
    3913  * \param uiDepth
    3914  * \param pcMvFieldNeighbours
    3915  * \param puhInterDirNeighbours
    3916  * \param numValidMergeCand
    3917  */
    3918 #if H_3D
    3919 Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    3920 #else
    3921 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    3922 #endif
    3923 #if H_3D_VSP && !FIX_TICKET_79
    3924       , InheritedVSPDisInfo*  inheritedVSPDisInfo
    3925 #endif
    3926 #if H_3D_SPIVMP
    3927       , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    3928 #endif
    3929       , Int& numValidMergeCand, Int mrgCandIdx
    3930 )
    3931 {
    3932   UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx;
    3933 #if H_3D_IV_MERGE
    3934   ////////////////////////////
    3935   //////// INIT LISTS ////////
    3936   ////////////////////////////
    3937   TComMv cZeroMv;
    3938 #else
    3939   Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
    3940 #endif
    3941 #if H_3D
    3942   TComMvField tmpMV[2];
    3943   UChar tmpDir;
    3944 
    3945 #if H_3D_DDD
    3946   m_iUseDDDCandIdx = -1;
    3947 #endif
    3948 
    3949   //////////////////////////////////
    3950   //////// GET DISPARITIES  ////////
    3951   //////////////////////////////////
    3952   DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
    3953 #if !FIX_TICKET_79
    3954   for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++)
    3955   {
    3956     inheritedVSPDisInfo[i].m_acDvInfo = cDisInfo;   // To prevent run-time error, this code must be executed always for merging process.
    3957   }
    3958 #endif
    3959   m_cDefaultDisInfo = cDisInfo;
    3960 
    3961   if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))  // current slice is not both dependent view or depth
    3962   {
    3963     return;
    3964   }
    3965 #else
    3966   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
    3967   {
    3968     abCandIsInter[ui] = false;
    3969     pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
    3970     pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
    3971   }
    3972 #endif
    3973 
    3974   numValidMergeCand = getSlice()->getMaxNumMergeCand();
    3975 #if H_3D
    3976   //////////////////////////////////
    3977   //////// DERIVE LOCATIONS ////////
    3978   //////////////////////////////////
    3979 #endif
    3980   // compute the location of the current PU
    3981   Int xP, yP, nPSW, nPSH;
    3982   this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
    3983 
    3984   Int iCount = 0;
    3985 
    3986   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    3987 #if !H_3D
    3988   PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
    3989 #endif
    3990   deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
    3991   deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
    3992 #if H_3D
    3993   Bool bMPIFlag   = getSlice()->getVPS()->getMPIFlag( getSlice()->getLayerIdInVps() );
    3994   Bool bIsDepth = getSlice()->getIsDepth();
    3995 #endif
    3996 
    3997 #if H_3D_IC
    3998   Bool bICFlag = getICFlag(uiAbsPartIdx);
    3999 #endif
    4000 #if H_3D_ARP
    4001   Bool bARPFlag = getARPW(uiAbsPartIdx)>0 ? true : false;
    4002 #endif
    4003 #if H_3D_DBBP
    4004   Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx);
    4005   assert(bDBBPFlag == getDBBPFlag(0)); 
    4006 #endif
    4007 
    4008 #if H_3D
    4009 #if H_3D_NBDV
    4010   for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++) 
    4011   {
    4012     pcMvFieldNeighbours[i<<1    ].getMv().setIDVFlag (false);
    4013     pcMvFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false);
    4014   }
    4015 #endif
    4016   // Clean version for MCL construction align with WD
    4017   // init mergCands list
    4018   for (Int i = 0; i<MRG_IVSHIFT+1; i++)
    4019   {
    4020     m_mergCands[i].init();
    4021   }
    4022 
    4023   m_baseListidc = 0;
    4024 
    4025   //left
    4026   UInt uiLeftPartIdx = 0;
    4027   TComDataCU* pcCULeft = 0;
    4028   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); 
    4029 
    4030   if (getAvailableFlagA1())
    4031   {
    4032     m_mergCands[MRG_A1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    4033 #if H_3D_VSP
    4034     ,
    4035       (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0
    4036 #if H_3D_IC
    4037       && !bICFlag
    4038 #endif
    4039 #if H_3D_ARP
    4040       && !bARPFlag
    4041 #endif
    4042 #if H_3D_DBBP
    4043       && !bDBBPFlag
    4044 #endif
    4045       )
    4046 #endif
    4047       , false
    4048       );
    4049     m_baseListidc++;
    4050   }
    4051 
    4052   // above
    4053   UInt uiAbovePartIdx = 0;
    4054   TComDataCU* pcCUAbove = 0;
    4055   pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
    4056 
    4057   if (getAvailableFlagB1())
    4058   {
    4059     m_mergCands[MRG_B1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    4060 #if H_3D_VSP
    4061     ,
    4062       ( ( ( getAddr() - pcCUAbove->getAddr() ) == 0) && (pcCUAbove->getVSPFlag(uiAbovePartIdx) != 0)
    4063 #if H_3D_IC
    4064       && !bICFlag
    4065 #endif
    4066 #if H_3D_ARP
    4067       && !bARPFlag
    4068 #endif
    4069 #if H_3D_DBBP
    4070       && !bDBBPFlag
    4071 #endif
    4072       )
    4073 #endif
    4074       , false
    4075       );
    4076     m_baseListidc++;
    4077   }
    4078 
    4079   // above right
    4080   UInt uiAboveRightPartIdx = 0;
    4081   TComDataCU* pcCUAboveRight = 0;
    4082   pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
    4083 
    4084   if (getAvailableFlagB0())
    4085   {
    4086     m_mergCands[MRG_B0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    4087 #if H_3D_VSP
    4088     ,
    4089       ( ( ( getAddr() - pcCUAboveRight->getAddr() ) == 0) && (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) != 0)
    4090 #if H_3D_IC
    4091       && !bICFlag
    4092 #endif
    4093 #if H_3D_ARP
    4094       && !bARPFlag
    4095 #endif
    4096 #if H_3D_DBBP
    4097       && !bDBBPFlag
    4098 #endif
    4099       )
    4100 #endif
    4101       , false
    4102       );
    4103     m_baseListidc++;
    4104   }
    4105 
    4106   // left bottom
    4107   UInt uiLeftBottomPartIdx = 0;
    4108   TComDataCU* pcCULeftBottom = getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
    4109 
    4110   if (getAvailableFlagA0())
    4111   {
    4112     m_mergCands[MRG_A0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    4113 #if H_3D_VSP
    4114     ,
    4115       (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) != 0
    4116 #if H_3D_IC
    4117       && !bICFlag
    4118 #endif
    4119 #if H_3D_ARP
    4120       && !bARPFlag
    4121 #endif
    4122 #if H_3D_DBBP
    4123       && !bDBBPFlag
    4124 #endif
    4125       )
    4126 #endif
    4127       , false
    4128       );
    4129     m_baseListidc++;
    4130   }
    4131 
    4132   // above left
    4133   UInt uiAboveLeftPartIdx = 0;
    4134   TComDataCU* pcCUAboveLeft = 0;
    4135   pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
    4136 
    4137   if (getAvailableFlagB2())
    4138   {
    4139     m_mergCands[MRG_B2].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
    4140 #if H_3D_VSP
    4141     ,
    4142       ( ( ( getAddr() - pcCUAboveLeft->getAddr() ) == 0) && (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) != 0)
    4143 #if H_3D_IC
    4144       && !bICFlag
    4145 #endif
    4146 #if H_3D_ARP
    4147       && !bARPFlag
    4148 #endif
    4149 #if H_3D_DBBP
    4150       && !bDBBPFlag
    4151 #endif
    4152       )
    4153 #endif
    4154       , false
    4155       );
    4156     m_baseListidc++;
    4157   }
    4158 
    4159 #endif
    4160 
    4161 
    4162 #if H_3D_IV_MERGE
    4163 
    4164   /////////////////////////////////////////////
    4165   //////// TEXTURE MERGE CANDIDATE (T) ////////
    4166   /////////////////////////////////////////////
    4167 
    4168   bMPIFlag &= (nPSW + nPSH > 12);
    4169   if( bMPIFlag)
    4170   {
    4171     tmpMV[0].setMvField( cZeroMv, NOT_VALID );
    4172     tmpMV[1].setMvField( cZeroMv, NOT_VALID );
    4173     tmpDir        =  0;
    4174 
    4175     Bool bSPIVMPFlag = false;
    4176 
    4177     TComPic * pcTexPic = m_pcSlice->getTexturePic();
    4178 #if H_3D_FCO
    4179 #if LGE_FCO_I0116
    4180     if (pcTexPic && pcTexPic->getReconMark())
    4181 #else
    4182     if (pcTexturePic->getReconMark())
    4183 #endif
    4184     {
    4185 #endif   
    4186       TComPicYuv*   pcTexRec = pcTexPic->getPicYuvRec  ();
    4187       UInt          uiPartAddr;
    4188       Int           iWidth, iHeight;
    4189       Int           iCurrPosX, iCurrPosY;
    4190 
    4191       this->getPartIndexAndSize( uiPUIdx, uiPartAddr, iWidth, iHeight );
    4192       pcTexRec->getTopLeftSamplePos( this->getAddr(), this->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
    4193 
    4194       Int iPUWidth, iPUHeight, iNumPart, iNumPartLine;
    4195       this->getSPPara(iWidth, iHeight, iNumPart, iNumPartLine, iPUWidth, iPUHeight);
    4196 
    4197       for (Int i=0; i<iNumPart; i++)
    4198       {
    4199         puhInterDirSP[i] = 0;
    4200         pcMvFieldSP[2*i].getMv().set(0, 0);
    4201         pcMvFieldSP[2*i+1].getMv().set(0, 0);
    4202         pcMvFieldSP[2*i].setRefIdx(-1);
    4203         pcMvFieldSP[2*i+1].setRefIdx(-1);
    4204       }
    4205 
    4206       Int         iTexCUAddr;
    4207       Int         iTexAbsPartIdx;
    4208       TComDataCU* pcTexCU;
    4209       Int iPartition = 0;
    4210       Int iInterDirSaved = 0;
    4211       TComMvField cMvFieldSaved[2];
    4212 
    4213       Int iOffsetX = iPUWidth/2;;
    4214       Int iOffsetY = iPUHeight/2;
    4215 
    4216       Int         iTexPosX, iTexPosY;
    4217       const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
    4218      
    4219       Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iPUWidth ) >> 1 )  * iPUWidth + ( iPUWidth >> 1 );
    4220       Int         iCenterPosY = iCurrPosY + ( ( iHeight /  iPUHeight ) >> 1 )  * iPUHeight + (iPUHeight >> 1);
    4221       Int         iTexCenterCUAddr, iTexCenterAbsPartIdx;
    4222 
    4223       if(iWidth == iPUWidth && iHeight == iPUHeight)
    4224       {
    4225           iCenterPosX = iCurrPosX + (iWidth >> 1);
    4226           iCenterPosY = iCurrPosY + (iHeight >> 1);
    4227       }
    4228 
    4229       // derivation of center motion parameters from the collocated texture CU
    4230 
    4231       pcTexRec->getCUAddrAndPartIdx( iCenterPosX , iCenterPosY , iTexCenterCUAddr, iTexCenterAbsPartIdx );
    4232       TComDataCU* pcDefaultCU    = pcTexPic->getCU( iTexCenterCUAddr );
    4233 
    4234       if( pcDefaultCU->getPredictionMode( iTexCenterAbsPartIdx ) != MODE_INTRA )
    4235       {
    4236         for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
    4237         {
    4238           RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
    4239 
    4240           TComMvField cDefaultMvField;
    4241           pcDefaultCU->getMvField( pcDefaultCU, iTexCenterAbsPartIdx, eCurrRefPicList, cDefaultMvField );
    4242           Int         iDefaultRefIdx     = cDefaultMvField.getRefIdx();
    4243           if (iDefaultRefIdx >= 0)
    4244           {
    4245             Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eCurrRefPicList, iDefaultRefIdx);
    4246             for (Int iRefPicList = 0; iRefPicList < m_pcSlice->getNumRefIdx( eCurrRefPicList ); iRefPicList++)
    4247             {
    4248               if (iDefaultRefPOC == m_pcSlice->getRefPOC(eCurrRefPicList, iRefPicList))
    4249               {
    4250                 bSPIVMPFlag = true;
    4251                 TComMv cMv = cDefaultMvField.getMv() + cMvRounding;
    4252                 cMv >>= 2;
    4253 #if !FIX_TICKET_68
    4254                 clipMv( cMv );
    4255 #endif
    4256                 cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ;
    4257                 break;
    4258               }
    4259             }
    4260           }
    4261         }
    4262       }
    4263       if ( bSPIVMPFlag == true )
    4264       {   
    4265           iInterDirSaved = (cMvFieldSaved[0].getRefIdx()!=-1 ? 1: 0) + (cMvFieldSaved[1].getRefIdx()!=-1 ? 2: 0);
    4266           tmpDir = iInterDirSaved;
    4267           tmpMV[0] = cMvFieldSaved[0];
    4268           tmpMV[1] = cMvFieldSaved[1];
    4269       }
    4270 
    4271       if ( iInterDirSaved != 0 )
    4272       {
    4273         for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iPUHeight)
    4274         {
    4275           for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iPUWidth)
    4276           {
    4277             iTexPosX     = j + iOffsetX;
    4278             iTexPosY     = i + iOffsetY;
    4279             pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx );
    4280             pcTexCU  = pcTexPic->getCU( iTexCUAddr );
    4281 
    4282             if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) )
    4283             {
    4284               for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
    4285               {
    4286                 RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
    4287                 TComMvField cTexMvField;
    4288                 pcTexCU->getMvField( pcTexCU, iTexAbsPartIdx, eCurrRefPicList, cTexMvField );
    4289                 Int iValidDepRef = getPic()->isTextRefValid( eCurrRefPicList, cTexMvField.getRefIdx() );
    4290                 if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) )
    4291                 {
    4292                   TComMv cMv = cTexMvField.getMv() + cMvRounding;
    4293                   cMv >>=2;         
    4294 #if !(NTT_BUG_FIX_TK54)
    4295                   this->clipMv( cMv );
    4296 #endif
    4297                   pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef);
    4298                 }
    4299               }
    4300             }
    4301             puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0);
    4302             if (puhInterDirSP[iPartition] == 0)
    4303             {
    4304               if (iInterDirSaved != 0)
    4305               {
    4306                 puhInterDirSP[iPartition] = iInterDirSaved;
    4307                 pcMvFieldSP[2*iPartition] = cMvFieldSaved[0];
    4308                 pcMvFieldSP[2*iPartition + 1] = cMvFieldSaved[1];
    4309               }
    4310             }
    4311             if (iPUHeight + iPUWidth == 12)
    4312             {
    4313               if (puhInterDirSP[iPartition] == 3)
    4314               {
    4315                 puhInterDirSP[iPartition] = 1;
    4316                 pcMvFieldSP[2*iPartition + 1].setMvField(TComMv(0,0), -1);
    4317               }
    4318             }
    4319 
    4320             iPartition ++;
    4321           }
    4322         }
    4323 #if H_3D
    4324       }
    4325 #endif
    4326 #if H_3D_FCO
    4327     }
    4328 #endif
    4329     if( tmpDir != 0 )
    4330     {
    4331       Int iCnloop = 0;
    4332       for(iCnloop = 0; iCnloop < 2; iCnloop ++)
    4333       {
    4334         if ( !m_mergCands[MRG_A1+iCnloop].m_bAvailable )  // prunning to A1, B1
    4335         {
    4336           continue;
    4337         }
    4338         if (tmpDir == m_mergCands[MRG_A1+iCnloop].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+iCnloop].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+iCnloop].m_cMvField[1])
    4339         {
    4340           m_mergCands[MRG_A1+iCnloop].m_bAvailable = false;
    4341           break;
    4342         }     
    4343       }
    4344       m_mergCands[MRG_T].setCand( tmpMV, tmpDir, false, bSPIVMPFlag);
    4345 
    4346       if ( mrgCandIdx == iCount )
    4347       {
    4348         return;
    4349       }
    4350       iCount ++;
    4351     }
    4352   }
    4353 #if H_3D_DDD
    4354   if( m_pcSlice->getIsDepth() && m_pcSlice->getViewIndex() != 0  && bMPIFlag )
    4355   {
    4356     UInt uiPartIdx;
    4357     TComDataCU *pcTextureCU = m_pcSlice->getTexturePic()->getCU( getAddr() );
    4358     TComSlice *pcTextureSlice = pcTextureCU->getSlice(); 
    4359 
    4360 
    4361     tmpMV[0].setMvField( cZeroMv, NOT_VALID );
    4362     tmpMV[1].setMvField( cZeroMv, NOT_VALID );
    4363     tmpDir = 0;
    4364 
    4365     xDeriveCenterIdx( uiPUIdx, uiPartIdx);
    4366 
    4367     if ( pcTextureCU && !pcTextureCU->isIntra( uiPartIdx ) )
    4368     {
    4369 
    4370       TComMvField cMVField;
    4371       Int iDV = 0;
    4372       Int iViewIdx = 0;
    4373       pcTextureCU->getMvField( pcTextureCU, uiPartIdx, REF_PIC_LIST_0, cMVField );
    4374       if( cMVField.getRefIdx() >= 0 )
    4375       {
    4376         if( pcTextureSlice->getRefPOC( REF_PIC_LIST_0, cMVField.getRefIdx()) == pcTextureSlice->getPOC() )
    4377         {
    4378           iViewIdx = pcTextureSlice->getRefPic( REF_PIC_LIST_0, cMVField.getRefIdx())->getViewIndex();
    4379           iDV = cMVField.getHor();
    4380 
    4381 
    4382           Int iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_0, cMVField.getRefIdx() );
    4383 
    4384           if( iValidDepRef >= 0 )
    4385           {
    4386             const TComMv cAdd( 2, 2 );
    4387             cMVField.getMv() += cAdd;
    4388             cMVField.getMv() >>= 2;
    4389 #if !(NTT_BUG_FIX_TK54)
    4390             clipMv( cMVField.getMv() );
    4391 #endif
    4392             tmpMV[ 0 ].setMvField( cMVField.getMv(), iValidDepRef );
    4393             tmpDir = 1;
    4394           }
    4395         }
    4396       }
    4397 
    4398       pcTextureCU->getMvField( pcTextureCU, uiPartIdx, REF_PIC_LIST_1, cMVField );
    4399 
    4400       if( !tmpDir && cMVField.getRefIdx() >= 0 )
    4401       {
    4402         if( pcTextureSlice->getRefPOC( REF_PIC_LIST_1, cMVField.getRefIdx()) == pcTextureSlice->getPOC() )
    4403         {
    4404           iViewIdx = pcTextureSlice->getRefPic( REF_PIC_LIST_1, cMVField.getRefIdx())->getViewIndex();
    4405           iDV = cMVField.getHor();
    4406 
    4407           Int iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_1, cMVField.getRefIdx() );
    4408 
    4409           if( iValidDepRef >= 0 )
    4410           {
    4411             const TComMv cAdd( 2, 2 );
    4412             cMVField.getMv() += cAdd;
    4413             cMVField.getMv() >>= 2;
    4414 #if !(NTT_BUG_FIX_TK54)
    4415             clipMv( cMVField.getMv() );
    4416 #endif
    4417             tmpMV[ 1 ].setMvField( cMVField.getMv(), iValidDepRef );
    4418             tmpDir = 2;
    4419           }
    4420         }
    4421       }
    4422       if( tmpDir != 0 )
    4423       {
    4424         m_ucDDTmpDepth = m_pcSlice->getDepthFromDV( iDV,  iViewIdx );
    4425         m_iUseDDDCandIdx = iCount;
    4426 
    4427         m_mergCands[MRG_D].setCand( tmpMV, tmpDir, false, false);
    4428         if ( mrgCandIdx == iCount )
    4429         {
    4430           return;
    4431         }
    4432         iCount ++;
    4433       }
    4434     }
    4435   }
    4436 #endif
    4437   /////////////////////////////////////////////////////////////////
    4438   //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC  Candidates /////
    4439   /////////////////////////////////////////////////////////////////
    4440 
    4441   // { IvMCL0, IvMCL1, IvDCL0, IvDCL1, IvMCL0Shift, IvMCL1Shift, IvDCL0Shift, IvDCL1Shift }; 
    4442   // An enumerator would be appropriate here!
    4443   TComMv ivCandMv    [8];
    4444   Int    ivCandRefIdx[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
    4445 
    4446   // { IvMC, IvDC, IvMCShift, IvDCShift }; 
    4447   Int    ivCandDir   [4] = {0, 0, 0, 0};
    4448 
    4449   Bool ivMvPredFlag   = getSlice()->getVPS()->getIvMvPredFlag( getSlice()->getLayerIdInVps() );
    4450 
    4451   ivMvPredFlag &= (nPSW + nPSH > 12);
    4452   if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1)
    4453   {
    4454     getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, bICFlag );
    4455   } 
    4456 
    4457   ///////////////////////////////////////////////
    4458   //////// INTER VIEW MOTION COMP(IvMC) /////////
    4459   ///////////////////////////////////////////////
    4460   if( getSlice()->getIsDepth() )
    4461   {
    4462     ivCandDir[1] = ivCandDir[2] = ivCandDir[3] = 0;
    4463   }
    4464 
    4465   if( ivCandDir[0] )
    4466   {
    4467     tmpMV[0].setMvField( cZeroMv, NOT_VALID );
    4468     tmpMV[1].setMvField( cZeroMv, NOT_VALID );
    4469 
    4470     if( ( ivCandDir[0] & 1 ) == 1 )
    4471     {
    4472       tmpMV[0].setMvField( ivCandMv[ 0 ], ivCandRefIdx[ 0 ] );
    4473     }
    4474     if( ( ivCandDir[0] & 2 ) == 2 )
    4475     {
    4476       tmpMV[1].setMvField( ivCandMv[ 1 ], ivCandRefIdx[ 1 ] );
    4477     }
    4478 
    4479     Bool bRemoveSpa = false; //pruning
    4480 
    4481     if (!bIsDepth)
    4482     {
    4483       for(Int i = 0; i < 2; i ++)
    4484       {
    4485         if ( !m_mergCands[MRG_A1 + i].m_bAvailable ) // prunning to A1, B1
    4486         {
    4487           continue;
    4488         }
    4489         if (ivCandDir[0] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1])
    4490         {
    4491           m_mergCands[MRG_A1+i].m_bAvailable = false;
    4492           break;
    4493         }     
    4494       }
    4495     }
    4496     if (bIsDepth)
    4497     {
    4498       if (m_mergCands[MRG_T].m_bAvailable && ivCandDir[0] == m_mergCands[MRG_T].m_uDir && tmpMV[0]==m_mergCands[MRG_T].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_T].m_cMvField[1])
    4499       {
    4500         bRemoveSpa                      = true;
    4501       }
    4502     }
    4503     if (!bRemoveSpa)
    4504     {
    4505       Bool SPIVMPFlag = false;
    4506       if(!m_pcSlice->getIsDepth())
    4507       {
    4508         SPIVMPFlag = true;
    4509       }
    4510 #if H_3D_DBBP
    4511       SPIVMPFlag &= !bDBBPFlag;
    4512 #endif
    4513 
    4514       m_mergCands[MRG_IVMC].setCand( tmpMV, ivCandDir[0], false, SPIVMPFlag);
    4515 
    4516       if ( mrgCandIdx == iCount )
    4517       {
    4518         return;
    4519       }
    4520       iCount ++;
    4521     }
    4522   }
    4523 
    4524   // early termination
    4525   if (iCount == getSlice()->getMaxNumMergeCand())
    4526   {
    4527     return;
    4528   }
    4529 #endif
    4530 
    4531 #if H_3D
    4532   iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable + m_mergCands[MRG_B0].m_bAvailable;
    4533 #else
    4534   //left
    4535   UInt uiLeftPartIdx = 0;
    4536   TComDataCU* pcCULeft = 0;
    4537   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
    4538   Bool isAvailableA1 = pcCULeft &&
    4539     pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
    4540     !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
    4541     !pcCULeft->isIntra( uiLeftPartIdx ) ;
    4542   if ( isAvailableA1 )
    4543   {
    4544     abCandIsInter[iCount] = true;
    4545     // get Inter Dir
    4546     puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
    4547     // get Mv from Left
    4548     pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4549     if ( getSlice()->isInterB() )
    4550     {
    4551       pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4552     }
    4553 
    4554     if ( mrgCandIdx == iCount )
    4555     {
    4556       return;
    4557     }
    4558     iCount ++;
    4559   }
    4560 
    4561   // early termination
    4562   if (iCount == getSlice()->getMaxNumMergeCand())
    4563   {
    4564     return;
    4565   }
    4566 
    4567   // above
    4568   UInt uiAbovePartIdx = 0;
    4569   TComDataCU* pcCUAbove = 0;
    4570   pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
    4571   Bool isAvailableB1 = pcCUAbove &&
    4572     pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
    4573     !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
    4574     !pcCUAbove->isIntra( uiAbovePartIdx );
    4575   if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
    4576   {
    4577     abCandIsInter[iCount] = true;
    4578     // get Inter Dir
    4579     puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
    4580     // get Mv from Left
    4581     pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4582     if ( getSlice()->isInterB() )
    4583     {
    4584       pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4585     }
    4586 
    4587     if ( mrgCandIdx == iCount )
    4588     {
    4589       return;
    4590     }
    4591     iCount ++;
    4592   }
    4593   // early termination
    4594   if (iCount == getSlice()->getMaxNumMergeCand())
    4595   {
    4596     return;
    4597   }
    4598 
    4599   // above right
    4600   UInt uiAboveRightPartIdx = 0;
    4601   TComDataCU* pcCUAboveRight = 0;
    4602   pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
    4603   Bool isAvailableB0 = pcCUAboveRight &&
    4604     pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
    4605     !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
    4606   if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
    4607   {
    4608     abCandIsInter[iCount] = true;
    4609     // get Inter Dir
    4610     puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
    4611     // get Mv from Left
    4612     pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4613     if ( getSlice()->isInterB() )
    4614     {
    4615       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4616     }
    4617 
    4618     if ( mrgCandIdx == iCount )
    4619     {
    4620       return;
    4621     }
    4622     iCount ++;
    4623   }
    4624   // early termination
    4625   if (iCount == getSlice()->getMaxNumMergeCand())
    4626   {
    4627     return;
    4628   }
    4629 #endif
    4630 
    4631 #if H_3D_DDD
    4632   // early termination
    4633   if ( iCount >= getSlice()->getMaxNumMergeCand())
    4634   {
    4635       return;
    4636   }
    4637 #endif
    4638 
    4639 #if H_3D_IV_MERGE
    4640   /////////////////////////////////////////////
    4641   //////// INTER VIEW DISP COMP (IvDC) ////////
    4642   /////////////////////////////////////////////
    4643   if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
    4644   {
    4645     assert(iCount < getSlice()->getMaxNumMergeCand());
    4646 
    4647     tmpMV[0].setMvField( cZeroMv, NOT_VALID );
    4648     tmpMV[1].setMvField( cZeroMv, NOT_VALID );
    4649     if( ( ivCandDir[1] & 1 ) == 1 )
    4650     {
    4651       tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
    4652     }
    4653     if( ( ivCandDir[1] & 2 ) == 2 )
    4654     {
    4655       tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
    4656     }
    4657 
    4658     Bool bRemoveSpa = false; //pruning to A1, B1
    4659     for(Int i = 0; i < 2; i ++)
    4660     {
    4661       if ( !m_mergCands[MRG_A1+i].m_bAvailable )
    4662       {
    4663         continue;
    4664       }
    4665       if (ivCandDir[1] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1])
    4666       {
    4667         bRemoveSpa                      = true;
    4668         break;
    4669       }     
    4670     }
    4671     if(!bRemoveSpa)
    4672     {
    4673 #if H_3D_NBDV
    4674       tmpMV[0].getMv().setIDVFlag (false);
    4675       tmpMV[1].getMv().setIDVFlag (false);
    4676 #endif
    4677       m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false);
    4678 
    4679       if ( mrgCandIdx == iCount )
    4680         return;
    4681       iCount ++;
    4682 
    4683       // early termination
    4684       if (iCount == getSlice()->getMaxNumMergeCand())
    4685       {
    4686         return;
    4687       }
    4688     }
    4689   }
    4690 #endif // H_3D_IV_MERGE
    4691 
    4692 #if H_3D_VSP
    4693   /////////////////////////////////////////////////
    4694   //////// VIEW SYNTHESIS PREDICTION (VSP) ////////
    4695   /////////////////////////////////////////////////
    4696   if (iCount<getSlice()->getMaxNumMergeCand())
    4697   {
    4698 
    4699   if (
    4700 #if H_3D_IC
    4701       !bICFlag &&
    4702 #endif
    4703 #if H_3D_ARP
    4704       !bARPFlag &&
    4705 #endif
    4706 #if H_3D
    4707       (nPSW + nPSH > 12) &&
    4708 #endif
    4709 #if H_3D_DBBP
    4710       !bDBBPFlag &&
    4711 #endif
    4712       xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) )
    4713   {
    4714     return;
    4715   }
    4716 
    4717   // early termination
    4718   if (iCount == getSlice()->getMaxNumMergeCand())
    4719   {
    4720     return;
    4721   }
    4722 #endif
    4723 #if H_3D
    4724   }
    4725 #endif
    4726 
    4727 #if H_3D
    4728   iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable;
    4729 #else
    4730   //left bottom
    4731   UInt uiLeftBottomPartIdx = 0;
    4732   TComDataCU* pcCULeftBottom = 0;
    4733   pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
    4734   Bool isAvailableA0 = pcCULeftBottom &&
    4735   pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
    4736   !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
    4737   if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
    4738   {
    4739     abCandIsInter[iCount] = true;
    4740     // get Inter Dir
    4741     puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
    4742     // get Mv from Left
    4743     pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4744     if ( getSlice()->isInterB() )
    4745     {
    4746       pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4747     }
    4748     if ( mrgCandIdx == iCount )
    4749     {
    4750       return;
    4751     }
    4752     iCount ++;
    4753   }
    4754   // early termination
    4755   if (iCount == getSlice()->getMaxNumMergeCand())
    4756   {
    4757     return;
    4758   }
    4759 
    4760   // above left
    4761   if( iCount < 4 )
    4762   {
    4763     UInt uiAboveLeftPartIdx = 0;
    4764     TComDataCU* pcCUAboveLeft = 0;
    4765     pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
    4766     Bool isAvailableB2 = pcCUAboveLeft &&
    4767     pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
    4768     !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
    4769     if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
    4770         && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
    4771     {
    4772       abCandIsInter[iCount] = true;
    4773       // get Inter Dir
    4774       puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
    4775       // get Mv from Left
    4776       pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    4777       if ( getSlice()->isInterB() )
    4778       {
    4779         pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    4780       }
    4781       if ( mrgCandIdx == iCount )
    4782       {
    4783         return;
    4784       }
    4785       iCount ++;
    4786     }
    4787   }
    4788   // early termination
    4789   if (iCount == getSlice()->getMaxNumMergeCand())
    4790   {
    4791     return;
    4792   }
    4793 #endif
    4794 
    4795 
    4796 #if H_3D_IV_MERGE
    4797   ////////////////////////////////////////////////////
    4798   //////// SHIFTED IV (IvMCShift + IvDCShift) ////////
    4799   ////////////////////////////////////////////////////
    4800   if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
    4801   {
    4802     if(xAddIvMRGCand( mrgCandIdx,  iCount, ivCandDir, ivCandMv, ivCandRefIdx ) )
    4803     {
    4804       return;
    4805     }
    4806     //early termination
    4807     if (iCount == getSlice()->getMaxNumMergeCand())
    4808     {
    4809       return;
    4810     }
    4811   }
    4812 #endif
    4813 #if !H_3D
     2564
    48142565  if ( getSlice()->getEnableTMVPFlag())
    48152566  {
     
    48992650    }
    49002651  }
    4901   // early termination 
     2652  // early termination
    49022653  if (iCount == getSlice()->getMaxNumMergeCand())
    49032654  {
     
    49692720
    49702721  numValidMergeCand = uiArrayAddr;
    4971 #endif
    4972 }
    4973 #else
    4974 
    4975 /** Constructs a list of merging candidates
    4976  * \param uiAbsPartIdx
    4977  * \param uiPUIdx
    4978  * \param uiDepth
    4979  * \param pcMvFieldNeighbours
    4980  * \param puhInterDirNeighbours
    4981  * \param numValidMergeCand
    4982  */
    4983 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    4984       , Int& numValidMergeCand, Int mrgCandIdx
    4985 )
    4986 {
    4987   UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx;
    4988   Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
    4989   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
    4990   {
    4991     abCandIsInter[ui] = false;
    4992     pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
    4993     pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
    4994   }
    4995   numValidMergeCand = getSlice()->getMaxNumMergeCand();
    4996   // compute the location of the current PU
    4997   Int xP, yP, nPSW, nPSH;
    4998   this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
    4999 
    5000   Int iCount = 0;
    5001 
    5002   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    5003   PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
    5004   deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
    5005   deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
    5006 
    5007   //left
    5008   UInt uiLeftPartIdx = 0;
    5009   TComDataCU* pcCULeft = 0;
    5010   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
    5011   Bool isAvailableA1 = pcCULeft &&
    5012   pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
    5013   !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
    5014   !pcCULeft->isIntra( uiLeftPartIdx ) ;
    5015   if ( isAvailableA1 )
    5016   {
    5017     abCandIsInter[iCount] = true;
    5018     // get Inter Dir
    5019     puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
    5020     // get Mv from Left
    5021     pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    5022     if ( getSlice()->isInterB() )
    5023     {
    5024       pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    5025     }
    5026     if ( mrgCandIdx == iCount )
    5027     {
    5028       return;
    5029     }
    5030     iCount ++;
    5031   }
    5032  
    5033   // early termination
    5034   if (iCount == getSlice()->getMaxNumMergeCand())
    5035   {
    5036     return;
    5037   }
    5038 
    5039   // above
    5040   UInt uiAbovePartIdx = 0;
    5041   TComDataCU* pcCUAbove = 0;
    5042   pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
    5043   Bool isAvailableB1 = pcCUAbove &&
    5044   pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
    5045   !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
    5046   !pcCUAbove->isIntra( uiAbovePartIdx );
    5047   if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
    5048   {
    5049     abCandIsInter[iCount] = true;
    5050     // get Inter Dir
    5051     puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
    5052     // get Mv from Left
    5053     pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    5054     if ( getSlice()->isInterB() )
    5055     {
    5056       pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    5057     }
    5058 
    5059     if ( mrgCandIdx == iCount )
    5060     {
    5061       return;
    5062     }
    5063     iCount ++;
    5064   }
    5065   // early termination
    5066   if (iCount == getSlice()->getMaxNumMergeCand())
    5067   {
    5068     return;
    5069   }
    5070 
    5071 
    5072   // above right
    5073   UInt uiAboveRightPartIdx = 0;
    5074   TComDataCU* pcCUAboveRight = 0;
    5075   pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
    5076   Bool isAvailableB0 = pcCUAboveRight &&
    5077   pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
    5078   !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
    5079   if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
    5080   {
    5081     abCandIsInter[iCount] = true;
    5082     // get Inter Dir
    5083     puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
    5084     // get Mv from Left
    5085     pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    5086     if ( getSlice()->isInterB() )
    5087     {
    5088       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    5089     }
    5090     if ( mrgCandIdx == iCount )
    5091     {
    5092       return;
    5093     }
    5094     iCount ++;
    5095   }
    5096   // early termination
    5097   if (iCount == getSlice()->getMaxNumMergeCand())
    5098   {
    5099     return;
    5100   }
    5101 
    5102   //left bottom
    5103   UInt uiLeftBottomPartIdx = 0;
    5104   TComDataCU* pcCULeftBottom = 0;
    5105   pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
    5106   Bool isAvailableA0 = pcCULeftBottom &&
    5107   pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
    5108   !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
    5109   if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
    5110   {
    5111     abCandIsInter[iCount] = true;
    5112     // get Inter Dir
    5113     puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
    5114     // get Mv from Left
    5115     pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    5116     if ( getSlice()->isInterB() )
    5117     {
    5118       pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    5119     }
    5120 
    5121     if ( mrgCandIdx == iCount )
    5122     {
    5123       return;
    5124     }
    5125     iCount ++;
    5126   }
    5127   // early termination
    5128   if (iCount == getSlice()->getMaxNumMergeCand())
    5129   {
    5130     return;
    5131   }
    5132 
    5133   // above left
    5134   if( iCount < 4 )
    5135   {
    5136     UInt uiAboveLeftPartIdx = 0;
    5137     TComDataCU* pcCUAboveLeft = 0;
    5138     pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
    5139     Bool isAvailableB2 = pcCUAboveLeft &&
    5140     pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
    5141     !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
    5142     if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
    5143         && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
    5144     {
    5145       abCandIsInter[iCount] = true;
    5146       // get Inter Dir
    5147       puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
    5148       // get Mv from Left
    5149       pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    5150       if ( getSlice()->isInterB() )
    5151       {
    5152         pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    5153       }
    5154       if ( mrgCandIdx == iCount )
    5155       {
    5156         return;
    5157       }
    5158       iCount ++;
    5159     }
    5160   }
    5161   // early termination
    5162   if (iCount == getSlice()->getMaxNumMergeCand())
    5163   {
    5164     return;
    5165   }
    5166 
    5167   if ( getSlice()->getEnableTMVPFlag())
    5168   {
    5169     //>> MTK colocated-RightBottom
    5170     UInt uiPartIdxRB;
    5171 
    5172     deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 
    5173 
    5174     UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
    5175     UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
    5176 
    5177     TComMv cColMv;
    5178     Int iRefIdx;
    5179     Int uiLCUIdx = -1;
    5180 
    5181     if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
    5182     {
    5183     }
    5184     else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
    5185     {
    5186     }
    5187     else
    5188     {
    5189       if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
    5190         ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
    5191       {
    5192         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
    5193         uiLCUIdx = getAddr();
    5194       }
    5195       else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
    5196       {
    5197         uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
    5198       }
    5199       else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
    5200       {
    5201         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
    5202         uiLCUIdx = getAddr() + 1;
    5203       }
    5204       else //is the right bottom corner of LCU                       
    5205       {
    5206         uiAbsPartAddr = 0;
    5207       }
    5208     }
    5209    
    5210    
    5211     iRefIdx = 0;
    5212     Bool bExistMV = false;
    5213     UInt uiPartIdxCenter;
    5214     UInt uiCurLCUIdx = getAddr();
    5215     Int dir = 0;
    5216     UInt uiArrayAddr = iCount;
    5217     xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
    5218     bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx );
    5219     if( bExistMV == false )
    5220     {
    5221       bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
    5222     }
    5223     if( bExistMV )
    5224     {
    5225       dir |= 1;
    5226       pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx );
    5227     }
    5228 
    5229     if ( getSlice()->isInterB() )
    5230     {
    5231       bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
    5232       if( bExistMV == false )
    5233       {
    5234         bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
    5235       }
    5236       if( bExistMV )
    5237       {
    5238         dir |= 2;
    5239         pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx );
    5240       }
    5241     }
    5242    
    5243     if (dir != 0)
    5244     {
    5245       puhInterDirNeighbours[uiArrayAddr] = dir;
    5246       abCandIsInter[uiArrayAddr] = true;
    5247       if ( mrgCandIdx == iCount )
    5248       {
    5249         return;
    5250       }
    5251       iCount++;
    5252     }
    5253   }
    5254   // early termination
    5255   if (iCount == getSlice()->getMaxNumMergeCand())
    5256   {
    5257     return;
    5258   }
    5259   UInt uiArrayAddr = iCount;
    5260   UInt uiCutoff = uiArrayAddr;
    5261    
    5262   if ( getSlice()->isInterB())
    5263   {
    5264     UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
    5265     UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
    5266 
    5267     for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
    5268     {
    5269       Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx];
    5270       if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
    5271       {
    5272         abCandIsInter[uiArrayAddr] = true;
    5273         puhInterDirNeighbours[uiArrayAddr] = 3;
    5274 
    5275         // get Mv from cand[i] and cand[j]
    5276         pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx());
    5277         pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx());
    5278 
    5279         Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() );
    5280         Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() );
    5281         if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv())
    5282         {
    5283           abCandIsInter[uiArrayAddr] = false;
    5284         }
    5285         else
    5286         {
    5287           uiArrayAddr++;
    5288         }
    5289       }
    5290     }
    5291   }
    5292   // early termination
    5293   if (uiArrayAddr == getSlice()->getMaxNumMergeCand())
    5294   {
    5295     return;
    5296   }
    5297   Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0);
    5298   Int r = 0;
    5299   Int refcnt = 0;
    5300   while (uiArrayAddr < getSlice()->getMaxNumMergeCand())
    5301   {
    5302     abCandIsInter[uiArrayAddr] = true;
    5303     puhInterDirNeighbours[uiArrayAddr] = 1;
    5304     pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r);
    5305 
    5306     if ( getSlice()->isInterB() )
    5307     {
    5308       puhInterDirNeighbours[uiArrayAddr] = 3;
    5309       pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r);
    5310     }
    5311     uiArrayAddr++;
    5312     if ( refcnt == iNumRefIdx - 1 )
    5313     {
    5314       r = 0;
    5315     }
    5316     else
    5317     {
    5318       ++r;
    5319       ++refcnt;
    5320     }
    5321   }
    5322 
    5323   numValidMergeCand = uiArrayAddr;
    5324 }
    5325 #endif
     2722}
    53262723
    53272724#if !FIX_TICKET_76
    5328 #if H_3D_VSP
    5329 inline Void TComDataCU::xInheritVSPDisInfo(TComDataCU* pcCURef, UInt uiAbsPartIdx, Int iCount, InheritedVSPDisInfo*  inheritedVSPDisInfo)
    5330 {
    5331   inheritedVSPDisInfo[iCount].m_acDvInfo.m_acNBDV   = pcCURef->getDvInfo(uiAbsPartIdx).m_acNBDV;
    5332   inheritedVSPDisInfo[iCount].m_acDvInfo.m_aVIdxCan = pcCURef->getDvInfo(uiAbsPartIdx).m_aVIdxCan;
    5333 }
    5334 #endif
    53352725#endif
    53362726/** Check whether the current PU and a spatial neighboring PU are in a same ME region.
     
    55512941    }
    55522942    if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col
    5553 #if H_3D_TMVP
    5554          , 0
    5555 #endif
    55562943    ) )
    55572944    {
     
    55642951      xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter );
    55652952      if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter,  cColMv, iRefIdx_Col
    5566 #if H_3D_TMVP
    5567          , 0
    5568 #endif
    55692953      ))
    55702954      {
     
    55932977  UInt partAddr;
    55942978 
    5595 #if H_3D_DBBP
    5596   if( getDBBPFlag(0) )
    5597   {
    5598     return true;
    5599   }
    5600 #endif
    56012979
    56022980  getPartIndexAndSize( puIdx, partAddr, width, height );
     
    56112989{
    56122990  Int  iMvShift = 2;
    5613 #if H_3D_IC
    5614   if( getSlice()->getIsDepth() )
    5615     iMvShift = 0;
    5616 #endif
    56172991  Int iOffset = 8;
    56182992  Int iHorMax = ( m_pcSlice->getSPS()->getPicWidthInLumaSamples() + iOffset - m_uiCUPelX - 1 ) << iMvShift;
     
    56683042}
    56693043
    5670 #if H_3D_IC
    5671 Bool TComDataCU::isIC( UInt uiPartIdx )
    5672 {
    5673     if ( m_pcSlice->isIntra () )
    5674     {
    5675         return false;
    5676     }
    5677     return ( ( getSkipFlag(uiPartIdx) || getPredictionMode(uiPartIdx) == MODE_INTER) && getICFlag( uiPartIdx ) && isICFlagRequired( uiPartIdx ) );
    5678 }
    5679 #endif
    56803044
    56813045// ====================================================================================================================
     
    59003264 */
    59013265Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx
    5902 #if H_3D_TMVP
    5903   , Bool bMRG
    5904 #endif
    59053266  )
    59063267{
     
    59503311  if ( bIsCurrRefLongTerm != bIsColRefLongTerm )
    59513312  {
    5952 #if H_3D_TMVP
    5953     Int iAlterRefIdx  = m_pcSlice->getAlterRefIdx(eRefPicList);
    5954     if(bMRG && iAlterRefIdx > 0)
    5955     {
    5956       riRefIdx = iAlterRefIdx;
    5957       bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm();
    5958       iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC();
    5959       assert(bIsCurrRefLongTerm == bIsColRefLongTerm);
    5960     }
    5961     else
    5962     {
    5963 #endif
    59643313      return false;
    5965 #if H_3D_TMVP
    5966     }
    5967 #endif
    59683314  }
    59693315
    59703316  if ( bIsCurrRefLongTerm || bIsColRefLongTerm )
    59713317  {
    5972 #if H_3D_TMVP
    5973     Int iCurrViewId    = m_pcSlice->getViewIndex ();
    5974     Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewIndex ();
    5975     Int iColViewId     = pColCU->getSlice()->getViewIndex();
    5976     Int iColRefViewId  = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewIndex();
    5977     iScale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId );
    5978 #if SEC_HLS_CLEANUP_I0100
    5979     if ( iScale != 4096 && m_pcSlice->getVPS()->getIvMvScalingFlag(getSlice()->getLayerIdInVps()) )
    5980 #else
    5981     if ( iScale != 4096 && m_pcSlice->getVPS()->getIvMvScalingFlag() )
    5982 #endif
    5983     {
    5984       rcMv = cColMv.scaleMv( iScale );
    5985     }
    5986     else
    5987     {
    5988 #endif
    59893318       rcMv = cColMv;
    5990 #if H_3D_TMVP
    5991     }
    5992 #endif
    59933319  }
    59943320  else
     
    60663392                                        + ( iPartWidth/m_pcPic->getMinCUWidth()  )/2];
    60673393}
    6068 #if H_3D
    6069 Void TComDataCU::compressMV(Int scale)
    6070 #else
    60713394Void TComDataCU::compressMV()
    6072 #endif
    6073 {
    6074 #if H_3D
    6075   Int scaleFactor = (4 / scale ) * AMVP_DECIMATION_FACTOR / m_unitSize;
    6076 #else
     3395{
    60773396  Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize;
    6078 #endif
    60793397  if (scaleFactor > 0)
    60803398  {
     
    61103428  {
    61113429    uiDirMode = getLumaIntraDir(uiAbsPartIdx);
    6112 #if H_3D_DIM
    6113     mapDepthModeToIntraDir( uiDirMode );
    6114 #endif
    61153430    uiScanIdx = SCAN_DIAG;
    61163431    if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size
     
    61303445      // get luma mode from upper-left corner of current CU
    61313446      uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts);
    6132 #if H_3D_DIM
    6133       mapDepthModeToIntraDir( uiDirMode );
    6134 #endif
    61353447    }
    61363448    uiScanIdx = SCAN_DIAG;
     
    61493461}
    61503462
    6151 #if H_3D
    6152 Void TComDataCU::getPosInPic( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY )
    6153 {
    6154   riPosX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelX();
    6155   riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY(); 
    6156 }
    6157 #endif
    6158 #if H_3D_IV_MERGE
    6159 Bool TComDataCU::getDispforDepth (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp)
    6160 {
    6161 
    6162   assert(getPartitionSize( uiPartAddr ) == SIZE_2Nx2N);
    6163 
    6164   TComMv cMv;
    6165 #if MTK_I0093
    6166 #if H_3D_FIX_64BIT_SHIFT
    6167   Int iDisp     = getSlice()->getDepthToDisparityB( 0 )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepthY() - 1 )) ];
    6168 #else
    6169   Int iDisp     = getSlice()->getDepthToDisparityB( 0 )[  1 << ( getSlice()->getSPS()->getBitDepthY() - 1 ) ];
    6170 #endif
    6171 #else
    6172   Int iDisp     = getSlice()->getDepthToDisparityB( 0 )[ 128 ];
    6173 #endif
    6174   cMv.setHor(iDisp);
    6175   cMv.setVer(0);
    6176   pDisp->m_acNBDV = cMv;
    6177   pDisp->m_aVIdxCan = 0;
    6178 
    6179   return true;
    6180 }
    6181 #endif
    6182 
    6183 #if MTK_SINGLE_DEPTH_MODE_I0095
    6184 Bool TComDataCU::getNeighDepth (UInt uiPartIdx, UInt uiPartAddr, Pel* pNeighDepth, Int index)
    6185 {
    6186 
    6187   Bool bDepAvail = false;
    6188   Pel *pDepth  = this->getPic()->getPicYuvRec()->getLumaAddr();
    6189   Int iDepStride =  this->getPic()->getPicYuvRec()->getStride();
    6190 
    6191   Int xP, yP, nPSW, nPSH;
    6192   this->getPartPosition(uiPartIdx, xP, yP, nPSW, nPSH);
    6193   UInt PicHeight=this->getPic()->getPicYuvRec()->getHeight();
    6194   UInt PicWidth=this->getPic()->getPicYuvRec()->getWidth();
    6195   switch(index)
    6196   {
    6197   case 0: // Mid Left
    6198     if( ( xP != 0 ) && ( ( yP + ( nPSH >> 1 ) ) < PicHeight ) )
    6199     {
    6200       *pNeighDepth = pDepth[ (yP+(nPSH>>1)) * iDepStride + (xP-1) ];
    6201       bDepAvail = true;
    6202     }
    6203     break;
    6204   case 1: // Mid Above
    6205     if( ( yP != 0 ) && ( ( xP + ( nPSW >> 1 ) ) < PicWidth ) )
    6206     {
    6207       *pNeighDepth = pDepth[ (yP-1) * iDepStride + (xP + (nPSW>>1)) ];
    6208       bDepAvail = true;
    6209     }
    6210     break;
    6211   case 2: // Above
    6212     if(yP != 0)
    6213     {
    6214       *pNeighDepth = pDepth[ (yP-1) * iDepStride + (xP) ];
    6215       bDepAvail = true;
    6216     }
    6217     break;
    6218   case 3: // Left
    6219     if(xP != 0)
    6220     {
    6221       *pNeighDepth = pDepth[ (yP) * iDepStride + (xP-1) ];
    6222       bDepAvail = true;
    6223     }
    6224     break;
    6225   case 4: // Above_Left
    6226     if(xP != 0 && yP != 0)
    6227     {
    6228       *pNeighDepth = pDepth[ (yP-1) * iDepStride + (xP-1) ];
    6229       bDepAvail = true;
    6230     }
    6231     break;
    6232   default:
    6233       break;
    6234   }
    6235   return bDepAvail;
    6236 }
    6237 
    6238 #endif
    6239 #if H_3D_NBDV
    6240 //Notes from QC:
    6241 //TBD#1: DoNBDV related contributions are just partially integrated under the marco of H_3D_NBDV_REF, remove this comment once DoNBDV and BVSP are done
    6242 //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
    6243 //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
    6244 Bool TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo
    6245 #if H_3D_NBDV_REF
    6246 , Bool bDepthRefine
    6247 #endif
    6248 )
    6249 {
    6250   //// ******* Init variables ******* /////
    6251   // Init disparity struct for results
    6252   pDInfo->bDV = false;   
    6253   pDInfo->m_aVIdxCan = -1;
    6254 
    6255   // Init struct for disparities from MCP neighboring blocks
    6256   IDVInfo cIDVInfo;
    6257   cIDVInfo.m_bFound = false;
    6258   UInt uiPartIdx = 0;
    6259   UInt uiPartAddr = 0;
    6260   for (UInt iCurDvMcpCand = 0; iCurDvMcpCand < IDV_CANDS; iCurDvMcpCand++)
    6261   {
    6262     for (UInt iList = 0; iList < 2; iList++)
    6263     {
    6264       cIDVInfo.m_acMvCand[iList][iCurDvMcpCand].setZero();
    6265       cIDVInfo.m_aVIdxCan[iList][iCurDvMcpCand] = 0;
    6266       cIDVInfo.m_bAvailab[iList][iCurDvMcpCand] = false;
    6267     }
    6268   }
    6269 #if H_3D_NBDV_REF
    6270   if( !m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ) )
    6271   {
    6272     bDepthRefine = false;
    6273   }
    6274 #endif
    6275   // Get Positions 
    6276   PartSize eCUMode    = getPartitionSize( uiPartAddr );   
    6277   assert(eCUMode == SIZE_2Nx2N);
    6278   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; 
    6279 
    6280   deriveLeftRightTopIdxGeneral(uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT );
    6281   deriveLeftBottomIdxGeneral  (uiPartAddr, uiPartIdx, uiPartIdxLB );
    6282 
    6283   //// ******* Get disparity from temporal neighboring blocks ******* /////
    6284   if ( getSlice()->getEnableTMVPFlag() )
    6285   {
    6286     TComMv cColMv;
    6287     Int iTargetViewIdx = 0;
    6288     Int iTStartViewIdx = 0;   
    6289 
    6290     ///*** Derive center position ***
    6291     UInt uiPartIdxCenter;
    6292     Int  uiLCUIdx   = getAddr();
    6293     xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter );
    6294 
    6295     ///*** Search temporal candidate pictures for disparity vector ***
    6296     const Int iNumCandPics = getPic()->getNumDdvCandPics();
    6297     for(Int curCandPic = 0; curCandPic < iNumCandPics; curCandPic++)
    6298     {
    6299       RefPicList eCurRefPicList   = REF_PIC_LIST_0 ;
    6300       Int        curCandPicRefIdx = 0;
    6301       if( curCandPic == 0 )
    6302       {
    6303         eCurRefPicList   = RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0);
    6304         curCandPicRefIdx = getSlice()->getColRefIdx();
    6305       }
    6306       else                 
    6307       {
    6308         eCurRefPicList   = getPic()->getRapRefList();
    6309         curCandPicRefIdx = getPic()->getRapRefIdx();
    6310       }
    6311 
    6312       Bool bCheck = xGetColDisMV( curCandPic, eCurRefPicList, curCandPicRefIdx, uiLCUIdx,   uiPartIdxCenter,  cColMv, iTargetViewIdx, iTStartViewIdx );
    6313 
    6314       if( bCheck )
    6315       {
    6316 #if !(NTT_BUG_FIX_TK54)
    6317         clipMv(cColMv);
    6318 #endif
    6319         pDInfo->m_acNBDV = cColMv;
    6320         pDInfo->m_aVIdxCan  = iTargetViewIdx;
    6321 
    6322 #if H_3D_NBDV_REF
    6323         TComPic* picDepth = NULL;   
    6324 #if H_3D_FCO_VSP_DONBDV_E0163
    6325         picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    6326         if ( picDepth->getPicYuvRec() != NULL  ) 
    6327         {
    6328           cColMv.setZero();
    6329         }
    6330         else // Go back with virtual depth
    6331         {
    6332           picDepth = getSlice()->getIvPic( true, iTargetViewIdx );
    6333         }
    6334 
    6335         assert(picDepth != NULL);
    6336 #else
    6337         picDepth = getSlice()->getIvPic( true, iTargetViewIdx );
    6338 #if !BUG_FIX_TK65
    6339         assert(picDepth != NULL);
    6340 #endif
    6341 #endif
    6342         if (picDepth && bDepthRefine)
    6343           estimateDVFromDM(iTargetViewIdx, uiPartIdx, picDepth, uiPartAddr, &cColMv );
    6344 
    6345         pDInfo->m_acDoNBDV  = cColMv;
    6346 #endif //H_3D_NBDV_REF
    6347         return true;
    6348       }
    6349     }
    6350   }
    6351 
    6352   UInt uiIdx = 0;
    6353   Bool        bCheckMcpDv = false;   
    6354   TComDataCU* pcTmpCU     = NULL;
    6355 
    6356   //// ******* Get disparity from left block ******* /////
    6357   pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false);
    6358   bCheckMcpDv = true;
    6359   if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT
    6360 #if H_3D_NBDV_REF
    6361     , bDepthRefine
    6362 #endif
    6363     ) )
    6364     return true;
    6365 
    6366   //// ******* Get disparity from above block ******* /////
    6367   pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true);
    6368   if(pcTmpCU != NULL )
    6369   {
    6370     bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0);
    6371     if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE
    6372 #if H_3D_NBDV_REF
    6373       , bDepthRefine
    6374 #endif
    6375       ) )
    6376       return true;
    6377   }
    6378 
    6379   //// ******* Search MCP blocks ******* /////
    6380   if( cIDVInfo.m_bFound )
    6381   {
    6382     for( Int curPos = 0 ; curPos < IDV_CANDS ; curPos++ )
    6383     {
    6384       for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
    6385       {
    6386         if( cIDVInfo.m_bAvailab[iList][curPos] )
    6387         {
    6388           TComMv cDispVec = cIDVInfo.m_acMvCand[iList][ curPos ];
    6389 #if !(NTT_BUG_FIX_TK54)
    6390           clipMv( cDispVec );
    6391 #endif
    6392           pDInfo->m_acNBDV = cDispVec;
    6393           pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ];
    6394 #if H_3D_NBDV_REF
    6395 #if H_3D_FCO_VSP_DONBDV_E0163
    6396           TComPic* picDepth  = NULL;
    6397 
    6398           picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    6399           if ( picDepth->getPicYuvRec() != NULL ) 
    6400           {
    6401             cDispVec.setZero();
    6402           }
    6403           else // Go back with virtual depth
    6404           {
    6405             picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan );
    6406           }
    6407 
    6408           assert(picDepth != NULL);
    6409 #else
    6410           TComPic* picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan );
    6411 #if !BUG_FIX_TK65
    6412           assert(picDepth!=NULL);
    6413 #endif
    6414 #endif
    6415 
    6416           if (picDepth && bDepthRefine)
    6417           {
    6418             estimateDVFromDM (pDInfo->m_aVIdxCan, uiPartIdx, picDepth, uiPartAddr, &cDispVec);
    6419           }
    6420           pDInfo->m_acDoNBDV = cDispVec;
    6421 #endif
    6422           return true;
    6423         }
    6424       }
    6425     }
    6426   }
    6427 
    6428   TComMv defaultDV(0, 0);
    6429   pDInfo->m_acNBDV = defaultDV;
    6430 
    6431   Int valid = 0;
    6432   Int viewIndex = 0;
    6433   for( UInt uiBId = 0; uiBId < getSlice()->getViewIndex() && valid==0; uiBId++ )
    6434   {
    6435     UInt        uiBaseId    = uiBId;
    6436     TComPic*    pcBasePic   = getSlice()->getIvPic( false, uiBaseId );
    6437     for( Int iRefListId = 0; ( iRefListId < (getSlice()->isInterB()? 2:1) ) && !getSlice()->isIntra() && valid==0; iRefListId++ )
    6438     {
    6439       RefPicList  eRefPicListTest = RefPicList( iRefListId );
    6440       Int         iNumRefPics = getSlice()->getNumRefIdx( eRefPicListTest ) ;
    6441       for( Int iRefIndex = 0; iRefIndex < iNumRefPics; iRefIndex++ )
    6442       {
    6443         if(pcBasePic->getPOC() == getSlice()->getRefPic( eRefPicListTest, iRefIndex )->getPOC()
    6444           && pcBasePic->getViewIndex() == getSlice()->getRefPic( eRefPicListTest, iRefIndex )->getViewIndex())
    6445         {
    6446           valid=1;
    6447           viewIndex = uiBaseId;
    6448           break;
    6449         }
    6450       }
    6451     }
    6452   }
    6453   if(valid)
    6454   {
    6455     pDInfo->m_aVIdxCan = viewIndex;
    6456 #if H_3D_NBDV_REF
    6457     TComPic* picDepth = NULL;
    6458 #if H_3D_FCO_VSP_DONBDV_E0163
    6459     picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    6460     if ( picDepth->getPicYuvRec() != NULL ) 
    6461     {
    6462       defaultDV.setZero();
    6463     }
    6464     else // Go back with virtual depth
    6465     {
    6466       picDepth = getSlice()->getIvPic( true, viewIndex );
    6467     }
    6468 
    6469     assert(picDepth != NULL);
    6470 #else
    6471     picDepth = getSlice()->getIvPic( true, viewIndex );
    6472 #if !BUG_FIX_TK65
    6473     assert(picDepth!=NULL);
    6474 #endif
    6475 #endif
    6476     if (picDepth && bDepthRefine)
    6477     {
    6478       estimateDVFromDM(viewIndex, uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view
    6479     }
    6480     pDInfo->m_acDoNBDV = defaultDV;
    6481 #endif
    6482   }
    6483   return false;
    6484 }
    6485 
    6486 #if H_3D_NBDV_REF
    6487 Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT )
    6488 {
    6489   Int iPictureWidth  = pcBaseViewDepthPicYuv->getWidth();
    6490   Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight();
    6491  
    6492   Int depthStartPosX = Clip3(0,   iPictureWidth - 1,  iBlkX + ((mv->getHor()+2)>>2));
    6493   Int depthStartPosY = Clip3(0,   iPictureHeight - 1, iBlkY + ((mv->getVer()+2)>>2));
    6494   Int depthEndPosX   = Clip3(0,   iPictureWidth - 1,  iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2));
    6495   Int depthEndPosY   = Clip3(0,   iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2));
    6496 
    6497   Pel* depthTL  = pcBaseViewDepthPicYuv->getLumaAddr();
    6498   Int depStride =  pcBaseViewDepthPicYuv->getStride();
    6499 
    6500   Pel  maxDepthVal = 0;
    6501   maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthStartPosX ]);      // Left Top
    6502   maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY)   * depStride + depthStartPosX ]);      // Left Bottom
    6503   maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthEndPosX   ]);      // Right Top
    6504   maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY)   * depStride + depthEndPosX   ]);      // Right Bottom
    6505 
    6506   return aiShiftLUT[ maxDepthVal ];
    6507 }
    6508 
    6509 Void TComDataCU::estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred )
    6510 {
    6511   if (picDepth)
    6512   {
    6513     UInt uiAbsPartAddrCurrCU = m_uiAbsIdxInLCU + uiPartAddr;
    6514     Int iWidth, iHeight;
    6515     getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more
    6516 
    6517     TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec();
    6518     Int iBlkX = ( getAddr() % picDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
    6519     Int iBlkY = ( getAddr() / picDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
    6520 
    6521     Int* aiShiftLUT = getSlice()->getDepthToDisparityB(refViewIdx );
    6522 
    6523     Pel iDisp = getMcpFromDM( pcBaseViewDepthPicYuv, cMvPred, iBlkX, iBlkY, iWidth, iHeight, aiShiftLUT );
    6524     cMvPred->setHor( iDisp );
    6525 #if !(NTT_BUG_FIX_TK54)
    6526     clipMv(*cMvPred);
    6527 #endif
    6528   }
    6529 }
    6530 #endif //H_3D_NBDV_REF
    6531 
    6532 
    6533 Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos
    6534 #if H_3D_NBDV_REF
    6535 , Bool bDepthRefine
    6536 #endif
    6537 )
    6538 {
    6539   if( pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
    6540   {
    6541     Bool bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
    6542     for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
    6543     {
    6544       RefPicList eRefPicList = RefPicList(iList);
    6545       Int      refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
    6546       TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
    6547 
    6548       if( refId >= 0)
    6549       {
    6550         Int refViewIdx  = pcTmpCU->getSlice()->getRefPic(eRefPicList, refId)->getViewIndex();
    6551         if (refViewIdx != m_pcSlice->getViewIndex())
    6552         {
    6553 #if !(NTT_BUG_FIX_TK54)
    6554           clipMv(cMvPred);
    6555 #endif
    6556           pNbDvInfo->m_acNBDV = cMvPred;
    6557           pNbDvInfo->m_aVIdxCan = refViewIdx;
    6558 #if H_3D_NBDV_REF
    6559           TComPic* picDepth = NULL;
    6560           assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());         
    6561 #if H_3D_FCO_VSP_DONBDV_E0163
    6562           picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
    6563           if ( picDepth->getPicYuvRec() != NULL ) 
    6564           {
    6565             cMvPred.setZero();
    6566           }
    6567           else// Go back with virtual depth
    6568           {
    6569             picDepth = getSlice()->getIvPic (true, refViewIdx );
    6570           }
    6571           assert(picDepth != NULL);
    6572 #else
    6573           picDepth   = getSlice()->getIvPic (true, refViewIdx );
    6574 #if !BUG_FIX_TK65
    6575           assert(picDepth != NULL);
    6576 #endif
    6577 #endif
    6578           UInt uiPartIdx = 0;   //Notes from MTK: Please confirm that using 0 as partition index and partition address is correct for CU-level DoNBDV
    6579           UInt uiPartAddr = 0;  //QC: confirmed
    6580 
    6581           if (picDepth && bDepthRefine)
    6582             estimateDVFromDM(refViewIdx, uiPartIdx, picDepth, uiPartAddr, &cMvPred );
    6583 
    6584           pNbDvInfo->m_acDoNBDV = cMvPred;
    6585 #endif
    6586           return true;
    6587         }
    6588         else if ( bSearchForMvpDv && cMvPred.getIDVFlag() && bTmpIsSkipped )
    6589         {
    6590           assert( uiMvpDvPos < IDV_CANDS );
    6591           paIDVInfo->m_acMvCand[iList][ uiMvpDvPos ] = TComMv( cMvPred.getIDVHor(), cMvPred.getIDVVer() );
    6592           //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.
    6593           paIDVInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = cMvPred.getIDVVId();
    6594           paIDVInfo->m_bAvailab[iList][ uiMvpDvPos ] = true;
    6595           paIDVInfo->m_bFound                        = true;
    6596         }
    6597       }
    6598     }
    6599   }
    6600   return false;
    6601 }
    6602  
    6603 Void TComDataCU::xDeriveRightBottomNbIdx(Int &riLCUIdxRBNb, Int &riPartIdxRBNb )
    6604 {
    6605   UInt uiPartIdx = 0;
    6606   UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 
    6607   Int uiLCUIdx = getAddr();
    6608 
    6609   UInt uiPartIdxRB;
    6610   deriveRightBottomIdx(uiPartIdx, uiPartIdxRB ); 
    6611   UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
    6612 
    6613   if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )
    6614   {
    6615     riLCUIdxRBNb  = -1;
    6616     riPartIdxRBNb = -1;
    6617   }
    6618   else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
    6619   {
    6620     riLCUIdxRBNb  = -1;
    6621     riPartIdxRBNb = -1;
    6622   }
    6623   else
    6624   {
    6625     if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU
    6626       ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
    6627     {
    6628       riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
    6629       riLCUIdxRBNb  = uiLCUIdx;
    6630     }
    6631     else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
    6632     {
    6633       riPartIdxRBNb = -1;
    6634       riLCUIdxRBNb  = -1;
    6635     }
    6636     else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
    6637     {
    6638       riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
    6639       riLCUIdxRBNb = uiLCUIdx + 1;
    6640     }
    6641     else //is the right bottom corner of LCU                       
    6642     {
    6643       riPartIdxRBNb = -1;
    6644       riLCUIdxRBNb  = -1;
    6645     }
    6646   }
    6647 }
    6648 
    6649 
    6650 Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth )
    6651 {
    6652   UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1);
    6653   for (UInt ui = 0; ui < uiCurrPartNumb; ui++ )
    6654   {
    6655     m_pDvInfo[uiAbsPartIdx + ui] = cDvInfo;
    6656   }
    6657 }
    6658 #if H_3D_VSP
    6659 Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth )
    6660 {
    6661   setSubPartT<DisInfo>( cDvInfo, m_pDvInfo, uiAbsPartIdx, uiDepth, uiPUIdx );
    6662 }
    6663 #endif
    6664 
    6665 Bool TComDataCU::xGetColDisMV( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx )
    6666 {
    6667 
    6668   RefPicList  eColRefPicList = REF_PIC_LIST_0;
    6669   Int iColViewIdx, iColRefViewIdx;
    6670   TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx);
    6671   TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
    6672   iColViewIdx = pColCU->getSlice()->getViewIndex();
    6673   if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiPartUnitIdx))
    6674   {
    6675     return false;
    6676   }
    6677   for (Int ilist = 0; ilist < (pColCU->getSlice()->isInterB()? 2:1); ilist++)
    6678   {
    6679     if(pColCU->getSlice()->isInterB())
    6680     {
    6681       eColRefPicList = RefPicList(ilist);
    6682     }
    6683 
    6684     Int iColRefIdx = pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartUnitIdx);
    6685 
    6686     if (iColRefIdx < 0)
    6687     {
    6688       continue;
    6689     }
    6690 
    6691     iColRefViewIdx = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getViewIndex();
    6692 
    6693     if ( iColViewIdx    == iColRefViewIdx ) // temporal vector
    6694     {
    6695       continue;
    6696     }
    6697     else
    6698     {
    6699       if(getPic()->isTempIVRefValid(currCandPic, ilist,  iColRefIdx))
    6700       {
    6701         rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartUnitIdx);
    6702         rcMv.setIDVFlag(0);
    6703         iTargetViewIdx  = iColRefViewIdx ;
    6704         iStartViewIdx   = iColViewIdx   ;
    6705         return true;   
    6706       }
    6707     }
    6708   }
    6709 
    6710   return false;
    6711 }
    6712 #endif
    6713 #if  H_3D_FAST_TEXTURE_ENCODING
    6714 Void
    6715 TComDataCU::getIVNStatus       ( UInt uiPartIdx,  DisInfo* pDInfo, Bool& bIVFMerge, Int& iIVFMaxD)
    6716 {
    6717   TComSlice*    pcSlice         = getSlice (); 
    6718   Int iViewIndex = pDInfo->m_aVIdxCan;
    6719   //--- get base CU/PU and check prediction mode ---
    6720   TComPic*    pcBasePic   = pcSlice->getIvPic( false, iViewIndex );
    6721   TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
    6722 
    6723   UInt          uiPartAddr;
    6724   Int           iWidth;
    6725   Int           iHeight;
    6726   getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight );
    6727 
    6728   Int  iCurrPosX, iCurrPosY;
    6729   pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
    6730 
    6731   iCurrPosX  += ( ( iWidth  - 1 ) >> 1 );
    6732   iCurrPosY  += ( ( iHeight - 1 ) >> 1 );
    6733 
    6734   Bool depthRefineFlag = false;
    6735 #if H_3D_NBDV_REF
    6736   depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() );
    6737 #endif // H_3D_NBDV_REF
    6738 
    6739   TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
    6740   if( depthRefineFlag )
    6741   {
    6742     cDv.setVer(0);
    6743   }
    6744 
    6745   Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
    6746   Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 ));
    6747   Int         iBaseLPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX - (iWidth >> 1) + ( (cDv.getHor() + 2 ) >> 2 ) );
    6748   Int         iBaseLPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 ));
    6749   Int         iBaseRPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + (iWidth >> 1) + 1 + ( (cDv.getHor() + 2 ) >> 2 ) );
    6750   Int         iBaseRPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 ));
    6751   Int         iBaseUPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
    6752   Int         iBaseUPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY - (iHeight >> 1) + ( (cDv.getVer() + 2 ) >> 2 ));
    6753   Int         iBaseDPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
    6754   Int         iBaseDPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + (iHeight >> 1) + 1 + ( (cDv.getVer() + 2 ) >> 2 ));
    6755 
    6756   Int         iBaseCUAddr;
    6757   Int         iBaseAbsPartIdx;
    6758   Int         iBaseLCUAddr;
    6759   Int         iBaseLAbsPartIdx;
    6760   Int         iBaseRCUAddr;
    6761   Int         iBaseRAbsPartIdx;
    6762   Int         iBaseUCUAddr;
    6763   Int         iBaseUAbsPartIdx;
    6764   Int         iBaseDCUAddr;
    6765   Int         iBaseDAbsPartIdx;
    6766   pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
    6767   pcBaseRec->getCUAddrAndPartIdx( iBaseLPosX , iBaseLPosY , iBaseLCUAddr, iBaseLAbsPartIdx );
    6768   pcBaseRec->getCUAddrAndPartIdx( iBaseRPosX , iBaseRPosY , iBaseRCUAddr, iBaseRAbsPartIdx );
    6769   pcBaseRec->getCUAddrAndPartIdx( iBaseUPosX , iBaseUPosY , iBaseUCUAddr, iBaseUAbsPartIdx );
    6770   pcBaseRec->getCUAddrAndPartIdx( iBaseDPosX , iBaseDPosY , iBaseDCUAddr, iBaseDAbsPartIdx );
    6771   TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
    6772   TComDataCU* pcBaseLCU    = pcBasePic->getCU( iBaseLCUAddr );
    6773   TComDataCU* pcBaseRCU    = pcBasePic->getCU( iBaseRCUAddr );
    6774   TComDataCU* pcBaseUCU    = pcBasePic->getCU( iBaseUCUAddr );
    6775   TComDataCU* pcBaseDCU    = pcBasePic->getCU( iBaseDCUAddr );
    6776   bIVFMerge = pcBaseLCU->getMergeFlag( iBaseLAbsPartIdx ) && pcBaseCU->getMergeFlag( iBaseAbsPartIdx ) && pcBaseRCU->getMergeFlag( iBaseRAbsPartIdx ) && pcBaseUCU->getMergeFlag( iBaseUAbsPartIdx ) && pcBaseDCU->getMergeFlag( iBaseDAbsPartIdx );
    6777   Int aiDepthL[5]; //depth level
    6778   aiDepthL[0] = pcBaseCU->getDepth(iBaseAbsPartIdx);
    6779   aiDepthL[1] = pcBaseLCU->getDepth(iBaseLAbsPartIdx);
    6780   aiDepthL[2] = pcBaseRCU->getDepth(iBaseRAbsPartIdx);
    6781   aiDepthL[3] = pcBaseUCU->getDepth(iBaseUAbsPartIdx);
    6782   aiDepthL[4] = pcBaseDCU->getDepth(iBaseDAbsPartIdx);
    6783   for (Int i = 0; i < 5; i++)
    6784   {
    6785     if (iIVFMaxD < aiDepthL[i])
    6786       iIVFMaxD = aiDepthL[i];
    6787   }
    6788 }
    6789 #endif
    6790 
    6791 #if H_3D_SPIVMP
    6792 Void TComDataCU::getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight)
    6793 {
    6794   Int iSubPUSize = 1<<getSlice()->getVPS()->getSubPULog2Size(getSlice()->getLayerId());
    6795   if( getSlice()->getIsDepth() )
    6796   {
    6797 #if MTK_I0099_VPS_EX2
    6798     iSubPUSize = 1<<getSlice()->getVPS()->getSubPUMPILog2Size(getSlice()->getLayerId());
    6799 #else
    6800     iSubPUSize = 1 << getSlice()->getVPS()->getSubPUMPILog2Size();
    6801 #endif
    6802   }
    6803 
    6804   iNumSPInOneLine = iPUWidth/iSubPUSize;
    6805   iNumSPInOneLine = iNumSPInOneLine < 1 ? 1: iNumSPInOneLine;
    6806   Int iNumSPInOneColumn = iPUHeight/iSubPUSize;
    6807   iNumSPInOneColumn = iNumSPInOneColumn < 1 ? 1: iNumSPInOneColumn;
    6808   iNumSP = iNumSPInOneLine * iNumSPInOneColumn;
    6809 
    6810   iSPWidth = iNumSPInOneLine == 1 ? iPUWidth: iSubPUSize;
    6811   iSPHeight = iNumSPInOneColumn == 1 ? iPUHeight: iSubPUSize;
    6812 }
    6813 
    6814 Void TComDataCU::getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr )
    6815 {
    6816   uiBaseAbsPartIdx += m_uiAbsIdxInLCU;
    6817   Int iBasePelX = g_auiRasterToPelX[g_auiZscanToRaster[uiBaseAbsPartIdx]];
    6818   Int iBasePelY = g_auiRasterToPelY[g_auiZscanToRaster[uiBaseAbsPartIdx]];
    6819   Int iCurrPelX = iBasePelX + iPartIdx%iNumPartLine * iWidth;
    6820   Int iCurrPelY = iBasePelY + iPartIdx/iNumPartLine * iHeight;
    6821   Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + iCurrPelX/getPic()->getMinCUWidth();
    6822   ruiPartAddr = g_auiRasterToZscan[iCurrRaster];
    6823   ruiPartAddr -= m_uiAbsIdxInLCU; 
    6824 }
    6825 
    6826 Void TComDataCU::setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight )
    6827 {
    6828   uiAbsPartIdx += getZorderIdxInCU();
    6829   Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]];
    6830   Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]];
    6831   Int iEndPelX = iStartPelX + iWidth;
    6832   Int iEndPelY = iStartPelY + iHeight;
    6833 
    6834   Int iCurrRaster, uiPartAddr;
    6835 
    6836   for (Int i=iStartPelY; i<iEndPelY; i+=getPic()->getMinCUHeight())
    6837   {
    6838     for (Int j=iStartPelX; j < iEndPelX; j += getPic()->getMinCUWidth())
    6839     {
    6840       iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + j/getPic()->getMinCUWidth();
    6841       uiPartAddr = g_auiRasterToZscan[iCurrRaster];
    6842       uiPartAddr -= getZorderIdxInCU(); 
    6843 
    6844       m_puhInterDir[uiPartAddr] = uiDir;
    6845     }
    6846   }
    6847 }
    6848 #endif
    6849 
    6850 #if H_3D_IV_MERGE
    6851 Bool
    6852 TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc , Bool bIsDepth           
    6853 #if H_3D_SPIVMP
    6854 , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    6855 #endif
    6856 , Bool bICFlag
    6857 )
    6858 {
    6859   TComSlice*    pcSlice = getSlice (); 
    6860   Int iViewIndex        = pDInfo->m_aVIdxCan;
    6861 
    6862   //--- get base CU/PU and check prediction mode ---
    6863   TComPic*    pcBasePic   = pcSlice->getIvPic( bIsDepth, iViewIndex );
    6864   TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
    6865 
    6866   UInt          uiPartAddr;
    6867   Int           iWidth;
    6868   Int           iHeight;
    6869   getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight );
    6870 
    6871   Int  iCurrPosX, iCurrPosY;
    6872   pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
    6873 
    6874 #if !H_3D_SPIVMP
    6875   iCurrPosX  += ( iWidth  >> 1 );
    6876   iCurrPosY  += ( iHeight >> 1 );
    6877 #endif
    6878 
    6879   Bool depthRefineFlag = false;
    6880 #if H_3D_NBDV_REF
    6881   depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() );
    6882 #endif // H_3D_NBDV_REF
    6883 
    6884   TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
    6885   if( depthRefineFlag )
    6886   {
    6887     cDv.setVer(0);
    6888   }
    6889 
    6890   Bool abPdmAvailable[8] =  {false, false, false, false, false, false, false, false};
    6891 #if H_3D_NBDV
    6892   for( Int i = 0; i < 8; i++)
    6893   {
    6894     pacPdmMv[i].setIDVFlag   (false);
    6895   }
    6896 #endif
    6897 
    6898   if(!bICFlag)
    6899   {
    6900 
    6901 #if H_3D_SPIVMP
    6902     ////////////////////////////////
    6903     //////////sub-PU IvMC///////////
    6904     ////////////////////////////////
    6905     if(!m_pcSlice->getIsDepth())
    6906     {
    6907       if (!getDBBPFlag(0))
    6908       {
    6909         Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    6910         getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    6911 
    6912         for (Int i=0; i<iNumSP; i++)
    6913         {
    6914           puhInterDirSP[i] = 0;
    6915           pcMvFieldSP[2*i].getMv().set(0, 0);
    6916           pcMvFieldSP[2*i+1].getMv().set(0,0);
    6917           pcMvFieldSP[2*i].setRefIdx(-1);
    6918           pcMvFieldSP[2*i+1].setRefIdx(-1);
    6919         }
    6920 
    6921         Int         iBaseCUAddr;
    6922         Int         iBaseAbsPartIdx;
    6923         TComDataCU* pcBaseCU;
    6924         Int iPartition = 0;
    6925 
    6926         Int iDelX = iSPWidth/2;
    6927         Int iDelY = iSPHeight/2;
    6928 
    6929         Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iSPWidth ) >> 1 )  * iSPWidth + ( iSPWidth >> 1 );
    6930         Int         iCenterPosY = iCurrPosY + ( ( iHeight /  iSPHeight ) >> 1 )  * iSPHeight + (iSPHeight >> 1);
    6931         Int         iRefCenterCUAddr, iRefCenterAbsPartIdx;
    6932 
    6933         if(iWidth == iSPWidth && iHeight == iSPHeight)
    6934         {
    6935           iCenterPosX = iCurrPosX + (iWidth >> 1);
    6936           iCenterPosY = iCurrPosY + (iHeight >> 1);
    6937         }
    6938 
    6939         Int iRefCenterPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
    6940         Int iRefCenterPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) );
    6941 
    6942         pcBaseRec->getCUAddrAndPartIdx( iRefCenterPosX , iRefCenterPosY , iRefCenterCUAddr, iRefCenterAbsPartIdx );
    6943         TComDataCU* pcDefaultCU    = pcBasePic->getCU( iRefCenterCUAddr );
    6944         if(!( pcDefaultCU->getPredictionMode( iRefCenterAbsPartIdx ) == MODE_INTRA ))
    6945         {
    6946           for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )       
    6947           {
    6948             RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
    6949             Bool stopLoop = false;
    6950             for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop)
    6951             {
    6952               RefPicList eDefaultRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
    6953               TComMvField cDefaultMvField;
    6954               pcDefaultCU->getMvField( pcDefaultCU, iRefCenterAbsPartIdx, eDefaultRefPicList, cDefaultMvField );
    6955               Int         iDefaultRefIdx     = cDefaultMvField.getRefIdx();
    6956               if (iDefaultRefIdx >= 0)
    6957               {
    6958                 Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eDefaultRefPicList, iDefaultRefIdx);
    6959                 if (iDefaultRefPOC != pcSlice->getPOC())   
    6960                 {
    6961                   for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
    6962                   {
    6963                     if (iDefaultRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
    6964                     {
    6965                       abPdmAvailable[ uiCurrRefListId ] = true;
    6966                       TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer());
    6967 #if H_3D_NBDV
    6968 #if H_3D_IV_MERGE
    6969                       if( !bIsDepth )
    6970                       {
    6971 #endif
    6972                         cMv.setIDVFlag   (true);
    6973                         cMv.setIDVHor    (cDv.getHor());                 
    6974                         cMv.setIDVVer    (cDv.getVer()); 
    6975                         cMv.setIDVVId    (iViewIndex);
    6976 #if H_3D_IV_MERGE
    6977                       }
    6978 #endif
    6979 #endif
    6980 #if !(NTT_BUG_FIX_TK54)
    6981                       clipMv( cMv );
    6982 #endif
    6983                       paiPdmRefIdx  [ uiCurrRefListId ] = iPdmRefIdx;
    6984                       pacPdmMv      [ uiCurrRefListId ] = cMv;
    6985                       stopLoop = true;
    6986                       break;
    6987                     }
    6988                   }
    6989                 }
    6990               }
    6991             }
    6992           }
    6993         }
    6994         availableMcDc[0] = ( abPdmAvailable[0]? 1 : 0) + (abPdmAvailable[1]? 2 : 0);
    6995 
    6996         if(availableMcDc[0])
    6997         {
    6998 
    6999           Int         iBasePosX, iBasePosY;
    7000           for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iSPHeight)
    7001           {
    7002             for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iSPWidth)
    7003             {
    7004               iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 ));
    7005               iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 ));
    7006 
    7007               pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY, iBaseCUAddr, iBaseAbsPartIdx );
    7008               pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
    7009               if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
    7010               {
    7011                 for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
    7012                 {
    7013                   RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
    7014                   Bool bLoop_stop = false;
    7015                   for(Int iLoop = 0; iLoop < 2 && !bLoop_stop; ++iLoop)
    7016                   {
    7017                     RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
    7018                     TComMvField cBaseMvField;
    7019                     pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
    7020                     Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
    7021                     if (iBaseRefIdx >= 0)
    7022                     {
    7023                       Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
    7024                       if (iBaseRefPOC != pcSlice->getPOC())   
    7025                       {
    7026                         for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
    7027                         {
    7028                           if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
    7029                           {
    7030                             abPdmAvailable[ uiCurrRefListId ] = true;
    7031                             TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
    7032 
    7033                             if( !bIsDepth )
    7034                             {
    7035                               cMv.setIDVFlag   (true);
    7036                               cMv.setIDVHor    (cDv.getHor());                 
    7037                               cMv.setIDVVer    (cDv.getVer()); 
    7038                               cMv.setIDVVId    (iViewIndex);
    7039                             }
    7040 
    7041 #if !(NTT_BUG_FIX_TK54)
    7042                             clipMv( cMv );
    7043 #endif
    7044                             bLoop_stop = true;
    7045 
    7046                             pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iPdmRefIdx);
    7047                             break;
    7048                           }
    7049                         }
    7050                       }
    7051                     }
    7052                   }
    7053                 }
    7054               }
    7055 
    7056               puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0);
    7057               if (puhInterDirSP[iPartition] == 0)
    7058               {
    7059                 puhInterDirSP[iPartition] = availableMcDc[0];
    7060                 pcMvFieldSP[2*iPartition].setMvField(pacPdmMv[0], paiPdmRefIdx[0]);
    7061                 pcMvFieldSP[2*iPartition + 1].setMvField(pacPdmMv[1], paiPdmRefIdx[1]);
    7062 
    7063               }
    7064               if (iSPHeight + iSPWidth == 12)
    7065               {
    7066                 if (puhInterDirSP[iPartition] == 3)
    7067                 {
    7068                   puhInterDirSP[iPartition] = 1;
    7069                   pcMvFieldSP[2*iPartition + 1].setMvField(TComMv(0,0), -1);
    7070                 }
    7071               }
    7072               iPartition ++;
    7073             }
    7074           }
    7075         }
    7076       }
    7077 
    7078       iCurrPosX  += ( iWidth  >> 1 );
    7079       iCurrPosY  += ( iHeight >> 1 );
    7080     }
    7081 #endif
    7082 
    7083     ////////////////////////////////
    7084     /////// IvMC + IvMCShift ///////
    7085     ////////////////////////////////
    7086 
    7087 #if H_3D_SPIVMP
    7088     if(m_pcSlice->getIsDepth())
    7089     {
    7090       iCurrPosX  += ( iWidth  >> 1 );
    7091       iCurrPosY  += ( iHeight >> 1 );
    7092     }
    7093     for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
    7094 #else
    7095     for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    7096 #endif
    7097     {
    7098       // iLoopCan == 0 --> IvMC
    7099       // iLoopCan == 1 --> IvMCShift
    7100 
    7101       Int         iBaseCUAddr;
    7102       Int         iBaseAbsPartIdx;
    7103 
    7104       Int offsetW = (iLoopCan == 0) ? 0 : ( ((iWidth /2)*4) + 4 );
    7105       Int offsetH = (iLoopCan == 0) ? 0 : ( ((iHeight/2)*4) + 4 );
    7106 
    7107       Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
    7108       Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) );
    7109       pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
    7110 
    7111       TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
    7112       if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
    7113       {
    7114         // Loop reference picture list of current slice (X in spec).
    7115         for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )       
    7116         {
    7117           RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
    7118 
    7119           Bool stopLoop = false;
    7120           // Loop reference picture list of candidate slice (Y in spec)
    7121           for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop)
    7122           {
    7123             RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
    7124             TComMvField cBaseMvField;
    7125             pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
    7126             Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
    7127             if (iBaseRefIdx >= 0)
    7128             {
    7129               Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
    7130               if (iBaseRefPOC != pcSlice->getPOC())   
    7131               {
    7132                 for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
    7133                 {
    7134                   if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
    7135                   {
    7136                     abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true;
    7137                     TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
    7138 #if H_3D_NBDV
    7139 #if H_3D_IV_MERGE
    7140                     if( !bIsDepth )
    7141                     {
    7142 #endif
    7143                       cMv.setIDVFlag   (true);
    7144                       cMv.setIDVHor    (cDv.getHor());                 
    7145                       cMv.setIDVVer    (cDv.getVer()); 
    7146                       cMv.setIDVVId    (iViewIndex);
    7147 #if H_3D_IV_MERGE
    7148                     }
    7149 #endif
    7150 #endif
    7151 #if !(NTT_BUG_FIX_TK54)
    7152                     clipMv( cMv );
    7153 #endif
    7154                     paiPdmRefIdx  [ (uiCurrRefListId + (iLoopCan<<2)) ] = iPdmRefIdx;
    7155                     pacPdmMv      [ (uiCurrRefListId + (iLoopCan<<2)) ] = cMv;
    7156                     stopLoop = true;
    7157                     break;
    7158                   }
    7159                 }
    7160               }
    7161             }
    7162           }
    7163         }
    7164       }
    7165     }
    7166 #if H_3D_SPIVMP
    7167     for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
    7168 #else
    7169     for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    7170 #endif
    7171     {
    7172       availableMcDc[(iLoopCan << 1)] = ( abPdmAvailable[(iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[1 + (iLoopCan<<2)] ? 2 : 0);
    7173     }
    7174 
    7175   }
    7176 
    7177   ////////////////////////////////
    7178   /////// IvDC + IvDCShift ///////
    7179   ////////////////////////////////
    7180 
    7181   if( !getSlice()->getIsDepth() )
    7182   {
    7183     for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ )
    7184     {
    7185       RefPicList  eRefPicListDMV       = RefPicList( iRefListId );
    7186       Int         iNumRefPics       = pcSlice->getNumRefIdx( eRefPicListDMV );
    7187       for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ )
    7188       {
    7189         if(( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC()) && (pcSlice->getRefPic( eRefPicListDMV, iPdmRefIdx )->getViewIndex() == pDInfo->m_aVIdxCan))
    7190         {
    7191           for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    7192           {
    7193             Int ioffsetDV = (iLoopCan == 0) ? 0 : 4;
    7194             abPdmAvailable[ iRefListId + 2 + (iLoopCan<<2) ] = true;
    7195             paiPdmRefIdx  [ iRefListId + 2 + (iLoopCan<<2) ] = iPdmRefIdx;
    7196 #if H_3D_NBDV_REF
    7197             TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
    7198 #endif
    7199             cMv.setHor( cMv.getHor() + ioffsetDV );
    7200 #if H_3D_IV_MERGE
    7201             if( bIsDepth )
    7202             {
    7203               cMv.setHor((cMv.getHor()+2)>>2);
    7204             }
    7205 #endif
    7206             cMv.setVer( 0 );
    7207 #if !(NTT_BUG_FIX_TK54)
    7208             clipMv( cMv );
    7209 #endif
    7210             pacPdmMv      [iRefListId + 2 + (iLoopCan<<2)] = cMv;
    7211           }
    7212           break;
    7213         }
    7214       }
    7215     }
    7216     for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    7217     {
    7218       availableMcDc[1 + (iLoopCan << 1)] = ( abPdmAvailable[2 + (iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[3 + (iLoopCan<<2)] ? 2 : 0 );
    7219     }
    7220   }
    7221   return false;
    7222 }
    7223 #endif
    7224 #if H_3D_ARP
    7225 Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth )
    7226 {
    7227   assert( sizeof( *m_puhARPW) == 1 );
    7228   memset( m_puhARPW + uiAbsPartIdx, w, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) );
    7229 }
    7230 #endif
    7231 
    7232 #if H_3D_IC
    7233 Void TComDataCU::setICFlagSubParts( Bool bICFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    7234 {
    7235   memset( m_pbICFlag + uiAbsPartIdx, bICFlag, (m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ))*sizeof(Bool) );
    7236 }
    7237 
    7238 Bool TComDataCU::isICFlagRequired( UInt uiAbsPartIdx )
    7239 {
    7240   UInt uiPartAddr;
    7241   UInt iNumbPart;
    7242 
    7243   if( !( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) )
    7244   {
    7245     return false;
    7246   }
    7247 
    7248   if( getSlice()->getIcSkipParseFlag() )
    7249   {
    7250     if( getMergeFlag( uiAbsPartIdx ) && getMergeIndex( uiAbsPartIdx ) == 0 )
    7251     {
    7252       return false;
    7253     }
    7254   }
    7255 
    7256   if( getMergeFlag( uiAbsPartIdx ) )
    7257   {
    7258     return true;
    7259   }
    7260 
    7261 
    7262   Int iWidth, iHeight;
    7263 
    7264   iNumbPart = ( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ? 1 : ( getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 4 : 2 ) );
    7265 
    7266   for(UInt i = 0; i < iNumbPart; i++)
    7267   {
    7268     getPartIndexAndSize( i, uiPartAddr, iWidth, iHeight, uiAbsPartIdx, true );
    7269     uiPartAddr += uiAbsPartIdx;
    7270 
    7271     for(UInt uiRefIdx = 0; uiRefIdx < 2; uiRefIdx++)
    7272     {
    7273       RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
    7274       Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr);
    7275 
    7276       if( ( getInterDir( uiPartAddr ) & ( uiRefIdx+1 ) ) && iBestRefIdx >= 0 && getSlice()->getViewIndex() != getSlice()->getRefPic( eRefList, iBestRefIdx )->getViewIndex() )
    7277       {
    7278         return true;
    7279       }
    7280     }
    7281   }
    7282 
    7283   return false;
    7284 }
    7285 #endif
    7286 #if H_3D_DIM_DMM
    7287 Void TComDataCU::setDmmWedgeTabIdxSubParts( UInt tabIdx, UInt dmmType, UInt uiAbsPartIdx, UInt uiDepth )
    7288 {
    7289   UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1);
    7290   for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmmWedgeTabIdx[dmmType][uiAbsPartIdx+ui] = tabIdx; }
    7291 }
    7292 #endif
    7293 
    7294 #if H_3D_VSP
    7295 Void TComDataCU::setMvFieldPUForVSP( TComDataCU* pcCU, UInt partAddr, Int width, Int height, RefPicList eRefPicList, Int iRefIdx, Int &vspSize )
    7296 {
    7297   // Get depth reference
    7298   Int depthRefViewIdx = pcCU->getDvInfo(partAddr).m_aVIdxCan;
    7299  
    7300 #if H_3D_FCO_VSP_DONBDV_E0163
    7301   TComPic* pRefPicBaseDepth = 0;
    7302   Bool     bIsCurrDepthCoded = false;
    7303   pRefPicBaseDepth  = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() );
    7304   if ( pRefPicBaseDepth->getPicYuvRec() != NULL  )
    7305   {
    7306     bIsCurrDepthCoded = true;
    7307   }
    7308   else
    7309   {
    7310     pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx );
    7311   }
    7312 #else
    7313   TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx );
    7314 #endif
    7315   assert(pRefPicBaseDepth != NULL);
    7316   TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec();
    7317   assert(pcBaseViewDepthPicYuv != NULL);
    7318   pcBaseViewDepthPicYuv->extendPicBorder();
    7319 
    7320   // Get texture reference
    7321   assert(iRefIdx >= 0);
    7322   TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx );
    7323   TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec();
    7324   assert(pcBaseViewTxtPicYuv != NULL);
    7325 
    7326   // Initialize LUT according to the reference viewIdx
    7327   Int txtRefViewIdx = pRefPicBaseTxt->getViewIndex();
    7328   Int* pShiftLUT    = pcCU->getSlice()->getDepthToDisparityB( txtRefViewIdx );
    7329   assert( txtRefViewIdx < pcCU->getSlice()->getViewIndex() );
    7330 
    7331   // prepare Dv to access depth map or reference view
    7332   TComMv cDv  = pcCU->getDvInfo(partAddr).m_acNBDV;
    7333   pcCU->clipMv(cDv);
    7334 
    7335 #if H_3D_FCO_VSP_DONBDV_E0163
    7336   if ( bIsCurrDepthCoded )
    7337   {
    7338       cDv.setZero();
    7339   }
    7340 #endif
    7341 
    7342   // fetch virtual depth map & convert depth to motion vector, which are stored in the motion memory
    7343   xSetMvFieldForVSP( pcCU, pcBaseViewDepthPicYuv, &cDv, partAddr, width, height, pShiftLUT, eRefPicList, iRefIdx, pcCU->getSlice()->getIsDepth(), vspSize );
    7344 }
    7345 
    7346 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 )
    7347 {
    7348   TComCUMvField *cuMvField = cu->getCUMvField( refPicList );
    7349   Int partAddrRasterSubPULine  = g_auiZscanToRaster[ partAddr ];
    7350   Int numPartsLine    = cu->getPic()->getNumPartInWidth();
    7351 
    7352   Int nTxtPerMvInfoX = 4; // cu->getPic()->getMinCUWidth();
    7353   Int nTxtPerMvInfoY = 4; // cu->getPic()->getMinCUHeight();
    7354 
    7355   Int refDepStride = picRefDepth->getStride();
    7356 
    7357   TComMv tmpMv(0, 0);
    7358   tmpMv.setIDVFlag(false);
    7359 
    7360   Int refDepOffset  = ( (dv->getHor()+2) >> 2 ) + ( (dv->getVer()+2) >> 2 ) * refDepStride;
    7361   Pel *refDepth     = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refDepOffset;
    7362 
    7363   if ((height % 8))
    7364   {
    7365     vspSize = 1; // 8x4
    7366   }
    7367   else if ((width % 8))
    7368   {
    7369     vspSize = 0; // 4x8
    7370   }
    7371   else
    7372   {
    7373     Bool ULvsBR, URvsBL;
    7374     ULvsBR = refDepth[0]       < refDepth[refDepStride * (height-1) + width-1];
    7375     URvsBL = refDepth[width-1] < refDepth[refDepStride * (height-1)];
    7376     vspSize = ( ULvsBR ^ URvsBL ) ? 0 : 1;
    7377   }
    7378  
    7379   Int subBlockW, subBlockH;
    7380   if (vspSize)
    7381   {
    7382     subBlockW = 8;
    7383     subBlockH = 4;
    7384   }
    7385   else
    7386   {
    7387     subBlockW = 4;
    7388     subBlockH = 8;
    7389   }
    7390  
    7391   Int numPartsInSubPUW = subBlockW / nTxtPerMvInfoX;
    7392   Int numPartsInSubPUH = subBlockH / nTxtPerMvInfoY * numPartsLine;
    7393 
    7394   for( Int y=0; y<height; y+=subBlockH, partAddrRasterSubPULine+=numPartsInSubPUH )
    7395   {
    7396     Pel *refDepthTmp[4];
    7397     refDepthTmp[0] = refDepth + refDepStride * y;
    7398     refDepthTmp[1] = refDepthTmp[0] + subBlockW - 1;
    7399     refDepthTmp[2] = refDepthTmp[0] + refDepStride * (subBlockH - 1);
    7400     refDepthTmp[3] = refDepthTmp[2] + subBlockW - 1;
    7401 
    7402     Int partAddrRasterSubPU = partAddrRasterSubPULine;
    7403     for( Int x=0; x<width; x+=subBlockW, partAddrRasterSubPU+=numPartsInSubPUW )
    7404     {
    7405       Pel  maxDepthVal;
    7406       maxDepthVal = refDepthTmp[0][x];
    7407       maxDepthVal = std::max( maxDepthVal, refDepthTmp[1][x]);
    7408       maxDepthVal = std::max( maxDepthVal, refDepthTmp[2][x]);
    7409       maxDepthVal = std::max( maxDepthVal, refDepthTmp[3][x]);
    7410       tmpMv.setHor( (Short) shiftLUT[ maxDepthVal ] );
    7411 
    7412       Int partAddrRasterPartLine = partAddrRasterSubPU;
    7413       for( Int sY=0; sY<numPartsInSubPUH; sY+=numPartsLine, partAddrRasterPartLine += numPartsLine )
    7414       {
    7415         Int partAddrRasterPart = partAddrRasterPartLine;
    7416         for( Int sX=0; sX<numPartsInSubPUW; sX+=1, partAddrRasterPart++ )
    7417         {
    7418           cuMvField->setMv    ( g_auiRasterToZscan[ partAddrRasterPart ], tmpMv );
    7419           cuMvField->setRefIdx( g_auiRasterToZscan[ partAddrRasterPart ], refIdx );
    7420         }
    7421       }
    7422     }
    7423   }
    7424 
    7425   vspSize = (vspSize<<2)+1;
    7426 
    7427 }
    7428 #endif
     3463
     3464
     3465
     3466
     3467
    74293468
    74303469//! \}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComDataCU.h

    r1039 r1072  
    4949#include "TComPattern.h"
    5050
    51 #if H_3D_ARP
    52 #include "TComYuv.h"
    53 #endif
    5451
    5552#include <algorithm>
     
    6057
    6158
    62 #if H_3D_DBBP
    63 typedef struct _DBBPTmpData
    64 {
    65   TComMv      acMvd[2][2];          // for two segments and two lists
    66   TComMvField acMvField[2][2];      // for two segments and two lists
    67   Int         aiMvpNum[2][2];       // for two segments and two lists
    68   Int         aiMvpIdx[2][2];       // for two segments and two lists
    69   UChar       auhInterDir[2];       // for two segments
    70   Bool        abMergeFlag[2];       // for two segments
    71   UChar       auhMergeIndex[2];     // for two segments
    72   PartSize    eVirtualPartSize;
    73   UInt        uiVirtualPartIndex;
    74 } DBBPTmpData;
    75 #endif
    7659
    7760// ====================================================================================================================
     
    11093  // -------------------------------------------------------------------------------------------------------------------
    11194  Bool*         m_skipFlag;           ///< array of skip flags
    112 #if MTK_SINGLE_DEPTH_MODE_I0095
    113   Bool*         m_singleDepthFlag;           ///< array of single depth flags
    114   Pel*          m_apSingleDepthValue;
    115 #endif
    11695  Char*         m_pePartSize;         ///< array of partition sizes
    11796  Char*         m_pePredMode;         ///< array of prediction modes
     
    169148  Char*         m_apiMVPNum[2];       ///< array of number of possible motion vectors predictors
    170149  Bool*         m_pbIPCMFlag;         ///< array of intra_pcm flags
    171 #if H_3D_NBDV
    172   DisInfo*      m_pDvInfo;
    173 #endif
    174 #if H_3D_VSP
    175   Char*         m_piVSPFlag;          ///< array of VSP flags to indicate whehter a block uses VSP or not
    176                                       ///< 0: non-VSP; 1: VSP
    177 #endif
    178 #if H_3D_SPIVMP
    179   Bool*         m_pbSPIVMPFlag;       ///< array of sub-PU IVMP flags to indicate whehter a block uses sub-PU IVMP
    180                                       ///< 0: non-SPIVMP; 1: SPIVMP
    181 #endif
    182 #if H_3D_ARP
    183   UChar*        m_puhARPW;
    184 #endif
    185 #if H_3D_IC
    186   Bool*         m_pbICFlag;           ///< array of IC flags
    187 #endif
    188 #if H_3D_DIM
    189   Pel*          m_dimDeltaDC[DIM_NUM_TYPE][2];
    190 #if H_3D_DIM_DMM
    191   UInt*         m_dmmWedgeTabIdx[DMM_NUM_TYPE];
    192 #endif
    193 #if H_3D_DIM_SDC
    194   Bool*         m_pbSDCFlag;
    195   Pel*          m_apSegmentDCOffset[2];
    196   Pel          m_apDmmPredictor[2];
    197 #endif
    198 #endif
    199 #if H_3D_DBBP
    200   Bool*         m_pbDBBPFlag;        ///< array of DBBP flags
    201   DBBPTmpData   m_sDBBPTmpData;
    202 #endif
    203 #if H_3D
    204   Bool          m_bAvailableFlagA1;    ///< A1 available flag
    205   Bool          m_bAvailableFlagB1;    ///< B1 available flag
    206   Bool          m_bAvailableFlagB0;    ///< B0 available flag
    207   Bool          m_bAvailableFlagA0;    ///< A0 available flag
    208   Bool          m_bAvailableFlagB2;    ///< B2 available flag
    209 #endif
    210150  // -------------------------------------------------------------------------------------------------------------------
    211151  // misc. variables
     
    214154  Bool          m_bDecSubCu;          ///< indicates decoder-mode
    215155  Double        m_dTotalCost;         ///< sum of partition RD costs
    216 #if H_3D_VSO
    217   Dist          m_uiTotalDistortion;  ///< sum of partition distortion
    218 #else
    219156  UInt          m_uiTotalDistortion;  ///< sum of partition distortion
    220 #endif
    221157  UInt          m_uiTotalBits;        ///< sum of partition bits
    222158  UInt          m_uiTotalBins;       ///< sum of partition bins
     
    224160  UInt*         m_sliceSegmentStartCU; ///< Start CU address of current slice
    225161  Char          m_codedQP;
    226 #if H_3D
    227   DisInfo       m_cDefaultDisInfo;    ///< Default disparity information for initializing
    228 #endif
    229 
    230 #if H_3D_DDD
    231   UChar*        m_pucDisparityDerivedDepth;
    232   Bool*         m_pbUseDDD;
    233   Int           m_iUseDDDCandIdx;
    234   UChar         m_ucDDTmpDepth;
    235 #endif
    236 
    237 #if H_3D_IV_MERGE
    238   TComMotionCand  m_mergCands[MRG_IVSHIFT+1];
    239   Int           m_baseListidc;
    240 #endif
     162
     163
    241164
    242165protected:
     
    245168  Bool          xAddMVPCand           ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
    246169  Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
    247 #if H_3D_VSP
    248   Bool          xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount);
    249 #endif
    250 #if H_3D_IV_MERGE
    251   Bool          xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int*   ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx );
    252 #if! SEC_SIMP_SHIFTED_DV_I0086
    253   Bool          xGetPosFirstAvailDmvCand( Int iCount, Int& iFirDispCand );
    254 #endif
    255 #endif
    256170
    257171  Void          deriveRightBottomIdx        ( UInt uiPartIdx, UInt& ruiPartIdxRB );
    258172  Bool          xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx
    259 #if H_3D_TMVP
    260   ,
    261   Bool bMRG = true
    262 #endif
    263173  );
    264174 
     
    268178 
    269179  /// compute scaling factor from POC difference
    270 #if !H_3D_ARP
    271180  Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
    272 #endif
    273181
    274182  Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter );
    275183
    276 #if H_3D_VSP
    277   Void xSetMvFieldForVSP  ( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, Int *shiftLUT, RefPicList refPicList, Int refIdx, Bool isDepth, Int &vspSize );
    278 #endif
    279184
    280185public:
     
    285190  // create / destroy / initialize / copy
    286191  // -------------------------------------------------------------------------------------------------------------------
    287 #if H_3D_ARP
    288   Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
    289 #endif
    290192  Void          create                ( UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize
    291193#if ADAPTIVE_QP_SELECTION
     
    299201  Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
    300202  Void          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );
    301 #if H_3D_NBDV
    302   Void          copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx);
    303 #endif
    304203  Void          copySubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
    305204  Void          copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList
    306 #if H_3D_NBDV
    307   , Bool bNBDV = false
    308 #endif
    309205  );
    310206  Void          copyPartFrom          ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
     
    331227 
    332228  Void          setDepthSubParts      ( UInt uiDepth, UInt uiAbsPartIdx );
    333 #if H_3D
    334   Void          getPosInPic           ( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY );
    335 #endif
    336229 
    337230  // -------------------------------------------------------------------------------------------------------------------
     
    345238  Void          setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth );
    346239 
    347 #if H_3D_DBBP
    348   Pel*          getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride);
    349 #endif
    350240 
    351241  Bool*        getSkipFlag            ()                        { return m_skipFlag;          }
     
    353243  Void         setSkipFlag           ( UInt idx, Bool skip)     { m_skipFlag[idx] = skip;   }
    354244  Void         setSkipFlagSubParts   ( Bool skip, UInt absPartIdx, UInt depth );
    355 #if MTK_SINGLE_DEPTH_MODE_I0095
    356   Bool*        getSingleDepthFlag            ()                        { return m_singleDepthFlag;          }
    357   Bool         getSingleDepthFlag            (UInt idx)                { return m_singleDepthFlag[idx];     }
    358   Void         setSingleDepthFlag           ( UInt idx, Bool singleDepth)     { m_singleDepthFlag[idx] = singleDepth;   }
    359   Void         setSingleDepthFlagSubParts   ( Bool singleDepth, UInt absPartIdx, UInt depth );
    360 
    361   Pel*         getSingleDepthValue( ) { return m_apSingleDepthValue; }
    362   Pel          getSingleDepthValue            (UInt idx)                { return m_apSingleDepthValue[idx];     }
    363   Void         setSingleDepthValue           ( UInt idx, Pel pDepthValue)     { m_apSingleDepthValue[idx] = pDepthValue;   }
    364   Void         setSingleDepthValueSubParts   (Pel singleDepthValue, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth );
    365 #endif 
    366245  Char*         getPredictionMode     ()                        { return m_pePredMode;        }
    367246  PredMode      getPredictionMode     ( UInt uiIdx )            { return static_cast<PredMode>( m_pePredMode[uiIdx] ); }
     
    371250  Void          setPredModeSubParts   ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth );
    372251 
    373 #if H_3D_DBBP
    374   Bool*         getDBBPFlag           ()                        { return m_pbDBBPFlag;               }
    375   Bool          getDBBPFlag           ( UInt uiIdx )            { return m_pbDBBPFlag[uiIdx];        }
    376   Void          setDBBPFlag           ( UInt uiIdx, Bool b )    { m_pbDBBPFlag[uiIdx] = b;           }
    377   Void          setDBBPFlagSubParts   ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    378   DBBPTmpData*  getDBBPTmpData        () { return &m_sDBBPTmpData; }
    379 #endif
    380252 
    381253  UChar*        getWidth              ()                        { return m_puhWidth;          }
     
    453325  template <typename T>
    454326  Void          setSubPart            ( T bParameter, T* pbBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
    455 #if H_3D_VSP
    456   template<typename T>
    457   Void          setSubPartT           ( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
    458 #endif
    459327#if AMP_MRG
    460328  Void          setMergeAMP( Bool b )      { m_bIsMergeAMP = b; }
     
    480348  Void          setIPCMFlag           (UInt uiIdx, Bool b )     { m_pbIPCMFlag[uiIdx] = b;           }
    481349  Void          setIPCMFlagSubParts   (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth);
    482 #if H_3D_NBDV
    483   Void          setDvInfoSubParts     ( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth );
    484   Void          setDvInfoSubParts     ( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth);
    485   DisInfo*      getDvInfo             ()                        { return m_pDvInfo;                 }
    486   DisInfo       getDvInfo             (UInt uiIdx)              { return m_pDvInfo[uiIdx];          }
    487 #endif
    488 #if H_3D_NBDV
    489   Void          xDeriveRightBottomNbIdx(Int &uiLCUIdxRBNb, Int &uiPartIdxRBNb );
    490   Bool          xCheckSpatialNBDV (TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paMvpDvInfo,
    491                                    UInt uiMvpDvPos
    492 #if H_3D_NBDV_REF
    493   , Bool bDepthRefine = false
    494 #endif
    495   );
    496   Bool          xGetColDisMV      ( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
    497   Bool          getDisMvpCandNBDV ( DisInfo* pDInfo
    498 #if H_3D_NBDV_REF
    499    , Bool bDepthRefine = false
    500 #endif
    501    );
    502    
    503 #if H_3D
    504   Bool          getDispforDepth  ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* cDisp);
    505   Bool          getDispMvPredCan(UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDis, Int* iPdm );
    506 #endif
    507 #if MTK_SINGLE_DEPTH_MODE_I0095
    508    Bool          getNeighDepth (UInt uiPartIdx, UInt uiPartAddr, Pel* pNeighDepth, Int index);
    509 #endif
    510 #if H_3D_NBDV_REF
    511   Pel           getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT );
    512   Void          estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred );
    513 #endif //H_3D_NBDV_REF
    514 #endif
    515 #if  H_3D_FAST_TEXTURE_ENCODING
    516   Void          getIVNStatus       ( UInt uiPartIdx,  DisInfo* pDInfo, Bool& bIVFMerge,  Int& iIVFMaxD);
    517 #endif
    518 #if H_3D_SPIVMP
    519   Void          getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight);
    520   Void          getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr );
    521   Void          setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight );
    522 #endif
    523 #if H_3D_IV_MERGE
    524   Bool          getInterViewMergeCands          ( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc, Bool bIsDepth           
    525 
    526 #if H_3D_SPIVMP
    527     , TComMvField* pcMFieldSP, UChar* puhInterDirSP
    528 #endif   
    529     , Bool bICFlag
    530     );   
    531 #endif
    532 #if H_3D_ARP
    533   UChar*        getARPW            ()                        { return m_puhARPW;               }
    534   UChar         getARPW            ( UInt uiIdx )            { return m_puhARPW[uiIdx];        }
    535   Void          setARPW            ( UInt uiIdx, UChar w )   { m_puhARPW[uiIdx] = w;           }
    536   Void          setARPWSubParts    ( UChar w, UInt uiAbsPartIdx, UInt uiDepth );
    537   Double        getARPWFactor      ( UInt uiIdx );
    538 #endif
    539 #if H_3D_IC
    540   Bool*         getICFlag          ()                        { return m_pbICFlag;               }
    541   Bool          getICFlag          ( UInt uiIdx )            { return m_pbICFlag[uiIdx];        }
    542   Void          setICFlag          ( UInt uiIdx, Bool  uh )  { m_pbICFlag[uiIdx] = uh;          }
    543   Void          setICFlagSubParts  ( Bool bICFlag,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    544   Bool          isICFlagRequired   ( UInt uiAbsPartIdx );
    545   Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false);
    546 #else
    547350  // -------------------------------------------------------------------------------------------------------------------
    548351  // member functions for accessing partition information
     
    550353 
    551354  Void          getPartIndexAndSize   ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight );
    552 #endif
    553355UChar         getNumPartitions       ();
    554356  Bool          isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth);
    555357
    556 #if H_3D_DIM
    557   Pel*  getDimDeltaDC                 ( UInt dimType, UInt segId )                      { return m_dimDeltaDC[dimType][segId];        }
    558   Pel   getDimDeltaDC                 ( UInt dimType, UInt segId, UInt uiIdx )          { return m_dimDeltaDC[dimType][segId][uiIdx]; }
    559   Void  setDimDeltaDC                 ( UInt dimType, UInt segId, UInt uiIdx, Pel val ) { m_dimDeltaDC[dimType][segId][uiIdx] = val;  }
    560 #if H_3D_DIM_DMM
    561   UInt* getDmmWedgeTabIdx             ( UInt dmmType )                          { return m_dmmWedgeTabIdx[dmmType];          }       
    562   UInt  getDmmWedgeTabIdx             ( UInt dmmType, UInt uiIdx )              { return m_dmmWedgeTabIdx[dmmType][uiIdx];   }
    563   Void  setDmmWedgeTabIdx             ( UInt dmmType, UInt uiIdx, UInt tabIdx ) { m_dmmWedgeTabIdx[dmmType][uiIdx] = tabIdx; }
    564   Void  setDmmWedgeTabIdxSubParts     ( UInt tabIdx, UInt dmmType, UInt uiAbsPartIdx, UInt uiDepth );
    565 
    566 #endif
    567 #if H_3D_DIM_SDC
    568   Bool*         getSDCFlag          ()                        { return m_pbSDCFlag;               }
    569   Bool          getSDCFlag          ( UInt uiIdx )            { return m_pbSDCFlag[uiIdx];        }
    570   Void          setSDCFlagSubParts  ( Bool bSDCFlag, UInt uiAbsPartIdx, UInt uiDepth );
    571  
    572   Bool          getSDCAvailable             ( UInt uiAbsPartIdx );
    573  
    574   Pel*          getSDCSegmentDCOffset( UInt uiSeg ) { return m_apSegmentDCOffset[uiSeg]; }
    575   Pel           getSDCSegmentDCOffset( UInt uiSeg, UInt uiPartIdx ) { return m_apSegmentDCOffset[uiSeg][uiPartIdx]; }
    576   Void          setSDCSegmentDCOffset( Pel pOffset, UInt uiSeg, UInt uiPartIdx) { m_apSegmentDCOffset[uiSeg][uiPartIdx] = pOffset; }
    577   Void          setDmmPredictor ( Pel pOffset, UInt uiSeg) { m_apDmmPredictor[uiSeg] = pOffset; }
    578   Pel           getDmmPredictor ( UInt uiSeg) { return m_apDmmPredictor[uiSeg]; }
    579   UInt          getCtxSDCFlag          ( UInt   uiAbsPartIdx );
    580 #endif
    581 #endif
    582358 
    583359  // -------------------------------------------------------------------------------------------------------------------
     
    605381  Void          getMvPredAbove        ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldB.getMv(); }
    606382  Void          getMvPredAboveRight   ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldC.getMv(); }
    607 #if H_3D
    608   Void          compressMV            ( Int scale );
    609 #else           
    610383  Void          compressMV            ();
    611 #endif 
    612384  // -------------------------------------------------------------------------------------------------------------------
    613385  // utility functions for neighbouring information
     
    649421  Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );
    650422
    651 #if H_3D
    652   Bool          getAvailableFlagA1() { return m_bAvailableFlagA1;}
    653   Bool          getAvailableFlagB1() { return m_bAvailableFlagB1;}
    654   Bool          getAvailableFlagB0() { return m_bAvailableFlagB0;}
    655   Bool          getAvailableFlagA0() { return m_bAvailableFlagA0;}
    656   Bool          getAvailableFlagB2() { return m_bAvailableFlagB2;}
    657   Void          initAvailableFlags() { m_bAvailableFlagA1 = m_bAvailableFlagB1 = m_bAvailableFlagB0 = m_bAvailableFlagA0 = m_bAvailableFlagB2 = 0;  }
    658   Void          buildMCL(TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
    659 #if H_3D_VSP
    660     , Int* vspFlag
    661 #endif
    662 #if H_3D_SPIVMP
    663     , Bool* pbSPIVMPFlag
    664 #endif
    665     , Int& numValidMergeCand
    666     );
    667   Void          getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1);
    668   Void          xGetInterMergeCandidates ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
    669 #else
    670423  Void          getInterMergeCandidates ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
    671 #endif
    672 #if H_3D_VSP && !FIX_TICKET_79
    673                                             , InheritedVSPDisInfo*  inheritedVSPDisInfo
    674 #endif
    675 #if H_3D_SPIVMP
    676                                             , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    677 #endif
    678424                                            , Int& numValidMergeCand, Int mrgCandIdx = -1
    679425                                            );
    680426
    681 #if H_3D_VSP
    682 #if !FIX_TICKET_76
    683   inline Void   xInheritVSPDisInfo(TComDataCU* pcCURef, UInt uiAbsPartIdx, Int iCount,  InheritedVSPDisInfo*  inheritedVSPDisInfo);
    684 #endif
    685 
    686 #if H_3D_SPIVMP
    687   Bool*         getSPIVMPFlag        ()                        { return m_pbSPIVMPFlag;          }
    688   Bool          getSPIVMPFlag        ( UInt uiIdx )            { 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   Char*         getVSPFlag        ()                        { return m_piVSPFlag;          }
    694   Char          getVSPFlag        ( UInt uiIdx )            { return m_piVSPFlag[uiIdx];   }
    695   Void          setVSPFlag        ( UInt uiIdx, Int n )     { m_piVSPFlag[uiIdx] = n;      }
    696   Void          setVSPFlagSubParts( Char 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
    699427  Void          deriveLeftRightTopIdxGeneral  ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
    700428  Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );
     
    709437  Bool          isBipredRestriction( UInt puIdx );
    710438
    711 #if H_3D_IC
    712   Bool          isIC      ( UInt uiPartIdx );
    713 #endif
    714439
    715440  // -------------------------------------------------------------------------------------------------------------------
     
    732457  UInt          getCtxInterDir                  ( UInt   uiAbsPartIdx                                 );
    733458 
    734 #if H_3D_ARP
    735   UInt          getCTXARPWFlag                  ( UInt   uiAbsPartIdx                                 );
    736 #endif 
    737459  UInt          getSliceStartCU         ( UInt pos )                  { return m_sliceStartCU[pos-m_uiAbsIdxInLCU];                                                                                          }
    738460  UInt          getSliceSegmentStartCU  ( UInt pos )                  { return m_sliceSegmentStartCU[pos-m_uiAbsIdxInLCU];                                                                                   }
     
    743465 
    744466  Double&       getTotalCost()                  { return m_dTotalCost;        }
    745 #if H_3D_VSO
    746   Dist&         getTotalDistortion()            { return m_uiTotalDistortion; }
    747 #else
    748467  UInt&         getTotalDistortion()            { return m_uiTotalDistortion; }
    749 #endif
    750468  UInt&         getTotalBits()                  { return m_uiTotalBits;       }
    751469  UInt&         getTotalNumPart()               { return m_uiNumPartition;    }
     
    753471  UInt          getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra);
    754472
    755 #if H_3D_DDD
    756   UChar*       getDDDepth        ()                        { return m_pucDisparityDerivedDepth;        }
    757   UChar        getDDDepth        ( UInt uiIdx )            { return m_pucDisparityDerivedDepth[uiIdx]; }
    758   Void         setDDDepth        ( UInt uiIdx, UChar n )   { m_pucDisparityDerivedDepth[uiIdx] = n;    }
    759   Void         setDDDepthSubParts( UChar ucDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    760 
    761   Bool*        getUseDDD        ()                        { return m_pbUseDDD;        }
    762   Bool         getUseDDD        ( UInt uiIdx )            { return m_pbUseDDD[uiIdx]; }
    763   Void         setUseDDD        ( UInt uiIdx, Bool n )     { m_pbUseDDD[uiIdx] = n;    }
    764   Void         setUseDDD( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiDepth );
    765 
    766   Void         setUseDDD        ( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    767 
    768   UChar        getDDTmpDepth(){ return m_ucDDTmpDepth; }
    769   Int          getUseDDDCandIdx(){ return m_iUseDDDCandIdx;}
    770 
    771 #endif
    772 
    773 #if SHARP_DMM1_I0110
    774   Bool         isDMM1UpscaleMode       ( UInt uiWidth ){ Bool bDMM1UpsampleModeFlag = true; UInt uiBaseWidth = 16; if( uiBaseWidth >= uiWidth ){ bDMM1UpsampleModeFlag = false; } return bDMM1UpsampleModeFlag; };
    775   UInt         getDMM1BasePatternWidth ( UInt uiWidth ){ UInt uiBaseWidth = 16; if( uiBaseWidth >= uiWidth ){ uiBaseWidth =  uiWidth; } return uiBaseWidth; }
    776 #endif
     473
    777474
    778475};
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComInterpolationFilter.cpp

    r872 r1072  
    7373};
    7474
    75 #if H_3D_ARP
    76 const Short TComInterpolationFilter::m_lumaFilterARP[4][NTAPS_LUMA_ARP] =
    77 {
    78   {64,  0},
    79   {48, 16},
    80   {32, 32},
    81   {16, 48}
    82 };
    83 const Short TComInterpolationFilter::m_chromaFilterARP[8][NTAPS_CHROMA_ARP] =
    84 {
    85   {64,  0},
    86   {56,  8},
    87   {48, 16},
    88   {40, 24},
    89   {32, 32},
    90   {24, 40},
    91   {16, 48},
    92   {8,  56}
    93 };
    94 #endif
    9575
    9676// ====================================================================================================================
     
    347327 */
    348328Void TComInterpolationFilter::filterHorLuma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast
    349 #if H_3D_ARP
    350     , Bool filterType
    351 #endif
    352329  )
    353330{
     
    360337  else
    361338  {
    362 #if H_3D_ARP
    363     if(filterType)
    364     {
    365       filterHor<NTAPS_LUMA_ARP>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilterARP[frac]);
    366     }
    367     else
    368     {
    369 #endif
    370339    filterHor<NTAPS_LUMA>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
    371 #if H_3D_ARP
    372     }
    373 #endif
    374340  }
    375341}
     
    389355 */
    390356Void TComInterpolationFilter::filterVerLuma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast
    391 #if H_3D_ARP
    392     , Bool filterType
    393 #endif
    394357  )
    395358{
     
    402365  else
    403366  {
    404 #if H_3D_ARP
    405     if(filterType)
    406     {
    407       filterVer<NTAPS_LUMA_ARP>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilterARP[frac]);   
    408     }
    409     else
    410     {
    411 #endif
    412367    filterVer<NTAPS_LUMA>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilter[frac]);
    413 #if H_3D_ARP
    414     }
    415 #endif
    416368  }
    417369}
     
    430382 */
    431383Void TComInterpolationFilter::filterHorChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast
    432 #if H_3D_ARP
    433     , Bool filterType
    434 #endif
    435384  )
    436385{
     
    443392  else
    444393  {
    445 #if H_3D_ARP
    446     if(filterType)
    447     {
    448       filterHor<NTAPS_CHROMA_ARP>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilterARP[frac]);
    449     }
    450     else
    451     {
    452 #endif
    453394    filterHor<NTAPS_CHROMA>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac]);
    454 #if H_3D_ARP
    455     }
    456 #endif
    457395  }
    458396}
     
    472410 */
    473411Void TComInterpolationFilter::filterVerChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast
    474 #if H_3D_ARP
    475     , Bool filterType
    476 #endif
    477412  )
    478413{
     
    485420  else
    486421  {
    487 #if H_3D_ARP
    488     if(filterType)
    489     {
    490       filterVer<NTAPS_CHROMA_ARP>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilterARP[frac]);
    491     }
    492     else
    493     {
    494 #endif
    495422    filterVer<NTAPS_CHROMA>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac]);
    496 #if H_3D_ARP
    497     }
    498 #endif
    499423  }
    500424}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComInterpolationFilter.h

    r872 r1072  
    4545//! \{
    4646
    47 #if H_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 Short m_lumaFilter[4][NTAPS_LUMA];     ///< Luma filter taps
    6460  static const Short m_chromaFilter[8][NTAPS_CHROMA]; ///< Chroma filter taps
    65 #if H_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  static Void filterCopy(Int bitDepth, const Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Bool isFirst, Bool isLast);
    7062 
     
    8274
    8375  Void filterHorLuma  (Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast
    84 #if H_3D_ARP
    85     , Bool filterType = false
    86 #endif
    8776    );
    8877  Void filterVerLuma  (Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast
    89 #if H_3D_ARP
    90     , Bool filterType = false
    91 #endif
    9278    );
    9379  Void filterHorChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast
    94 #if H_3D_ARP
    95     , Bool filterType = false
    96 #endif
    9780    );
    9881  Void filterVerChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast
    99 #if H_3D_ARP
    100     , Bool filterType = false
    101 #endif
    10282    );
    10383};
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComMotionInfo.cpp

    r872 r1072  
    4040#include "assert.h"
    4141#include <stdlib.h>
    42 #if H_3D_SPIVMP
    43 #include "TComDataCU.h"
    44 #include "TComPic.h"
    45 #endif
    4642
    4743//! \ingroup TLibCommon
     
    328324}
    329325
    330 #if H_3D_SPIVMP
    331 Void TComCUMvField::setMvFieldSP( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  )
    332 {
    333   uiAbsPartIdx += pcCU->getZorderIdxInCU();
    334   Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]];
    335   Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]];
    336   Int iEndPelX = iStartPelX + iWidth;
    337   Int iEndPelY = iStartPelY + iHeight;
    338 
    339   Int iCurrRaster, uiPartAddr;
    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       iCurrRaster = i / pcCU->getPic()->getMinCUHeight() * pcCU->getPic()->getNumPartInWidth() + j/pcCU->getPic()->getMinCUWidth();
    346       uiPartAddr = g_auiRasterToZscan[iCurrRaster];
    347       uiPartAddr -= pcCU->getZorderIdxInCU(); 
    348 
    349       m_pcMv[uiPartAddr] = cMvField.getMv();
    350       m_piRefIdx[uiPartAddr] = cMvField.getRefIdx();
    351     }
    352   }
    353 }
    354 #endif
    355326
    356327/**Subsampling of the stored prediction mode, reference index and motion vector
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComMotionInfo.h

    r1039 r1072  
    5050// ====================================================================================================================
    5151
    52 #if H_3D_SPIVMP
    53 class TComDataCU;
    54 #endif
    5552/// parameters for AMVP
    5653typedef struct _AMVPInfo
     
    6057} AMVPInfo;
    6158
    62 #if H_3D_NBDV
    63 typedef struct _DisCand
    64 {
    65   Bool bDV;
    66   TComMv m_acNBDV;              // DV from NBDV
    67 #if H_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
    81 #if H_3D_VSP && !FIX_TICKET_79
    82 typedef struct _InheritedVSPDisCand
    83 {
    84   DisInfo m_acDvInfo;
    85 } InheritedVSPDisInfo;
    86 #endif
    8759// ====================================================================================================================
    8860// Class definition
     
    11385  Int getHor   () const { return  m_acMv.getHor(); }
    11486  Int getVer   () const { return  m_acMv.getVer(); }
    115 #if H_3D_IV_MERGE
    116   Bool operator== ( const TComMvField& rcMv ) const
    117   {
    118     return (m_acMv.getHor()==rcMv.getHor() && m_acMv.getVer()==rcMv.getVer() && m_iRefIdx == rcMv.getRefIdx());
    119   }
    120 #endif
    12187};
    12288
     
    173139  Void    setAllRefIdx ( Int iRefIdx,                 PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
    174140  Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
    175 #if H_3D_SPIVMP
    176   Void    setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  );
    177 #endif
    178 #if H_3D_VSP
    179   Void    setMv         ( Int iIdx, TComMv const & rcMv ) { m_pcMv[iIdx] = rcMv; }
    180   Void    setRefIdx     ( Int iIdx, Int iRefIdx )         { m_piRefIdx[iIdx] = iRefIdx; }
    181 #endif
    182141
    183142  Void setNumPartition( Int iNumPart )
     
    198157//! \}
    199158
    200 #if H_3D_IV_MERGE
    201 class TComMotionCand
    202 {
    203 public:
    204   Bool                  m_bAvailable;
    205   TComMvField           m_cMvField[2];
    206   UChar                 m_uDir;
    207 #if H_3D_VSP
    208   Int                   m_iVspFlag;
    209 #endif 
    210   Bool                  m_bSPIVMPFlag;
    211 
    212 public:
    213   TComMotionCand()
    214   {
    215     m_bAvailable = false;
    216     m_uDir = 0;
    217 #if H_3D_VSP
    218     m_iVspFlag = 0;
    219 #endif
    220     m_bSPIVMPFlag = false;
    221   }
    222 
    223   ~TComMotionCand()
    224   {
    225 
    226   }
    227 
    228   Void init()
    229   {
    230     TComMv cZeroMv;
    231 
    232     m_bAvailable = false;
    233     m_uDir = 0;
    234 #if H_3D_VSP
    235     m_iVspFlag = 0;
    236 #endif
    237     m_bSPIVMPFlag = false;
    238     m_cMvField[0].setMvField(cZeroMv, NOT_VALID);
    239     m_cMvField[1].setMvField(cZeroMv, NOT_VALID);
    240   }
    241 
    242   Void setCand(TComMvField* pcMvFieldNeighbours, UChar uhInterDirNeighbours
    243 #if H_3D_VSP
    244     , Int vspFlag
    245 #endif
    246     , Bool bSPIVMPFlag
    247     )
    248   {
    249     m_bAvailable = true;
    250     m_cMvField[0] = pcMvFieldNeighbours[0];
    251     m_cMvField[1] = pcMvFieldNeighbours[1];
    252     m_uDir = uhInterDirNeighbours;
    253 #if H_3D_VSP
    254     m_iVspFlag = vspFlag;
    255 #endif
    256     m_bSPIVMPFlag = bSPIVMPFlag;
    257   }
    258 
    259 
    260   Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
    261 #if H_3D_VSP
    262     , Int* vspFlag
    263 #endif
    264     , Bool* pbSPIVMPFlag
    265     )
    266   {
    267     pcMvFieldNeighbours[iCount<<1] = m_cMvField[0];
    268     pcMvFieldNeighbours[(iCount<<1) + 1] = m_cMvField[1];
    269     puhInterDirNeighbours[iCount] = m_uDir;
    270 #if H_3D_VSP
    271     vspFlag[iCount] = m_iVspFlag;
    272 #endif
    273     pbSPIVMPFlag[iCount] = m_bSPIVMPFlag;
    274   }
    275 };
    276 #endif
    277159
    278160
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComMv.h

    r872 r1072  
    5555  Short m_iHor;     ///< horizontal component of motion vector
    5656  Short m_iVer;     ///< vertical component of motion vector
    57 #if H_3D_NBDV
    58   Bool  m_bIDV;       
    59   Short m_iIDVHor;   
    60   Short m_iIDVVer;   
    61   Short m_iIDVVId;  //view index of the IDV
    62 #endif
    6357public:
    6458 
     
    7064  m_iHor(0),
    7165  m_iVer(0)
    72 #if H_3D_NBDV
    73   , m_bIDV(false)
    74   , m_iIDVHor(0)
    75   , m_iIDVVer(0)
    76   , m_iIDVVId(0)
    77 #endif
    7866  {
    7967  }
     
    8270  m_iHor(iHor),
    8371  m_iVer(iVer)
    84  #if H_3D_NBDV
    85   , m_bIDV(false)
    86   , m_iIDVHor(0)
    87   , m_iIDVVer(0)
    88   , m_iIDVVId(0)
    89 #endif
    9072  {
    9173  }
     
    9981  Void  setVer    ( Short i )                   { m_iVer = i;                               }
    10082  Void  setZero   ()                            { m_iHor = m_iVer = 0; 
    101  #if H_3D_NBDV
    102    m_bIDV = false; m_iIDVHor = m_iIDVVer = 0;
    103    m_iIDVVId = 0;
    104 #endif
    10583  }
    106 #if H_3D_NBDV
    107   Void   setIDVHor  (Short i)                    {m_iIDVHor = i;}
    108   Void   setIDVVer  (Short i)                    {m_iIDVVer = i;}
    109   Void   setIDVFlag (Bool b )                    {m_bIDV    = b;}
    110   Void   setIDVVId  (Short i)                    {m_iIDVVId = i;}
    111 #endif
    11284  // ------------------------------------------------------------------------------------------------------------------
    11385  // get
     
    11890  Int   getAbsHor () const { return abs( m_iHor );   }
    11991  Int   getAbsVer () const { return abs( m_iVer );   }
    120 #if H_3D_NBDV
    121   Short getIDVHor () const { return m_iIDVHor;       }
    122   Short getIDVVer () const { return m_iIDVVer;       }
    123   Bool  getIDVFlag() const { return m_bIDV;          }
    124   Short getIDVVId () const { return m_iIDVVId;       }
    125 
    126 #endif
    12792  // ------------------------------------------------------------------------------------------------------------------
    12893  // operations
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComPattern.h

    r872 r1072  
    9999  TComPatternParam  m_cPatternCb;
    100100  TComPatternParam  m_cPatternCr;
    101 #if H_3D_IC
    102   Bool              m_bICFlag;
    103 #endif
    104 #if H_3D_INTER_SDC
    105   Bool              m_bSDCMRSADFlag;
    106 #endif
    107101  static const UChar m_aucIntraFilter[5];
    108102 
     
    115109  Int   getPatternLStride()       { return m_cPatternY.m_iPatternStride;  }
    116110
    117 #if H_3D_IC
    118   Bool  getICFlag()               { return m_bICFlag; }
    119   Void  setICFlag( Bool bICFlag ) { m_bICFlag = bICFlag; }
    120 #endif
    121 #if H_3D_INTER_SDC
    122   Bool  getSDCMRSADFlag()         { return m_bSDCMRSADFlag; }
    123   Void  setSDCMRSADFlag( Bool bSDCMRSADFlag )    { m_bSDCMRSADFlag = bSDCMRSADFlag; }
    124 #endif
    125111
    126112  // access functions of ADI buffers
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComPic.cpp

    r976 r1072  
    6363, m_layerId                               (0)
    6464, m_viewId                                (0)
    65 #if H_3D
    66 , m_viewIndex                             (0)
    67 , m_isDepth                               (false)
    68 , m_aaiCodedScale                         (0)
    69 , m_aaiCodedOffset                        (0)
    70 #endif
    7165#endif
    7266{
    7367  m_apcPicYuv[0]      = NULL;
    7468  m_apcPicYuv[1]      = NULL;
    75 #if H_3D_QTLPC
    76   m_bReduceBitsQTL    = 0;
    77 #endif
    78 #if H_3D_NBDV
    79   m_iNumDdvCandPics   = 0;
    80   m_eRapRefList       = REF_PIC_LIST_0;
    81   m_uiRapRefIdx       = 0;
    82 #endif
    8369}
    8470
     
    114100  memcpy(m_numReorderPics, numReorderPics, MAX_TLAYER*sizeof(Int));
    115101
    116 #if H_3D_FCO
    117 /* initialize the texture to depth reference status */
    118   for (int j=0; j<2; j++)
    119   {
    120       for (int i=0; i<MAX_NUM_REF; i++)
    121       {
    122           m_aiTexToDepRef[j][i] = -1;
    123       }
    124   }
    125 #endif
    126102
    127103  return;
     
    153129  deleteSEIs(m_SEIs);
    154130}
    155 #if H_3D
    156 Void TComPic::compressMotion(Int scale)
    157 #else
    158131Void TComPic::compressMotion()
    159 #endif
    160132{
    161133  TComPicSym* pPicSym = getPicSym();
     
    163135  {
    164136    TComDataCU* pcCU = pPicSym->getCU(uiCUAddr);
    165 #if H_3D
    166     pcCU->compressMV(scale);
    167 #else
    168137    pcCU->compressMV();
    169 #endif
    170138  }
    171139}
     
    204172}
    205173
    206 #if H_3D
    207 TComPic* TComPicLists::getPic( Int viewIndex, Bool depthFlag, Int poc )
    208 {
    209   return getPic   ( m_vps->getLayerIdInNuh( viewIndex, depthFlag ), poc );
    210 }
    211 #endif
    212174Void TComPicLists::print()
    213175{
     
    250212}
    251213
    252 #if H_3D
    253 TComPicYuv* TComPicLists::getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon )
    254 
    255   Int layerIdInNuh = m_vps->getLayerIdInNuh( viewIndex, depthFlag );
    256   return getPicYuv( layerIdInNuh, poc, recon );
    257 }
    258 #if H_3D_ARP
    259 TComList<TComPic*>* TComPicLists::getPicList( Int layerIdInNuh )
    260 {
    261   TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin();
    262   Int iLayer = 0;
    263 
    264   assert( layerIdInNuh < m_lists.size() );
    265 
    266   while( iLayer != layerIdInNuh )
    267   {
    268     itL++;
    269     iLayer++;
    270   }
    271 
    272   return *itL;
    273 }
    274 #endif
    275 #endif
    276214#endif // H_MV
    277215
    278 #if H_3D_NBDV
    279 Int TComPic::getDisCandRefPictures( Int iColPOC )
    280 {
    281   UInt       uiTempLayerCurr = 7;
    282   TComSlice* currSlice       = getSlice(getCurrSliceIdx());
    283   UInt       numDdvCandPics  = 0;
    284 
    285   if ( !currSlice->getEnableTMVPFlag() )
    286     return numDdvCandPics;
    287 
    288   numDdvCandPics += 1;
    289 
    290   UInt pocCurr = currSlice->getPOC();
    291   UInt pocDiff = 255;
    292 
    293   for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
    294   {
    295     UInt x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
    296 
    297     for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
    298     {
    299       if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex()
    300         && (x == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)x, i)!= iColPOC) && numDdvCandPics!=2)
    301       {
    302         TComSlice* refSlice    = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx());
    303         Bool       bRAP        = (refSlice->getViewIndex() && refSlice->isIRAP())? 1: 0;
    304         UInt       uiTempLayer = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer();
    305        
    306         if( bRAP )
    307         {
    308           this->setRapRefIdx(i);
    309           this->setRapRefList((RefPicList)x);
    310           numDdvCandPics = 2;
    311 
    312           return numDdvCandPics;
    313         }
    314         else if (uiTempLayerCurr > uiTempLayer)
    315         {
    316            uiTempLayerCurr = uiTempLayer;
    317         }
    318       }
    319     }
    320   }
    321 
    322   UInt z   = -1; // GT: Added to make code compile needs to be checked!
    323   UInt idx = 0;
    324  
    325   for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
    326   {
    327     UInt x = lpNr? currSlice->getColFromL0Flag() : 1-currSlice->getColFromL0Flag();
    328    
    329     for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
    330     {
    331       Int iTempPoc = currSlice->getRefPic((RefPicList)x, i)->getPOC();
    332       Int iTempDiff = (iTempPoc > pocCurr) ? (iTempPoc - pocCurr): (pocCurr - iTempPoc);
    333      
    334       if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() &&  (x == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)x, i)!= iColPOC)
    335         && currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer() == uiTempLayerCurr && pocDiff > iTempDiff)
    336       {
    337         pocDiff = iTempDiff;
    338         z       = x;
    339         idx     = i;
    340       }
    341     }
    342   }
    343 
    344   if( pocDiff < 255 )
    345   {
    346     this->setRapRefIdx(idx);
    347     this->setRapRefList((RefPicList) z );
    348     numDdvCandPics = 2;
    349   }
    350 
    351   return numDdvCandPics;
    352 }
    353 
    354 Void TComPic::checkTemporalIVRef()
    355 {
    356   TComSlice* currSlice = getSlice(getCurrSliceIdx());
    357   const Int numCandPics = this->getNumDdvCandPics();
    358   for(Int curCandPic = 0; curCandPic < numCandPics; curCandPic++)
    359   {
    360     RefPicList eCurRefPicList   = REF_PIC_LIST_0 ;
    361     Int        curCandPicRefIdx = 0;
    362     if( curCandPic == 0 )
    363     {
    364       eCurRefPicList   = RefPicList(currSlice->isInterB() ? 1-currSlice->getColFromL0Flag() : 0);
    365       curCandPicRefIdx = currSlice->getColRefIdx();
    366     }
    367     else                 
    368     {
    369       eCurRefPicList   = this->getRapRefList();
    370       curCandPicRefIdx = this->getRapRefIdx();
    371     }
    372     TComPic* pcCandColPic = currSlice->getRefPic( eCurRefPicList, curCandPicRefIdx);
    373     TComSlice* pcCandColSlice = pcCandColPic->getSlice(0);// currently only support single slice
    374 
    375     if(!pcCandColSlice->isIntra())
    376     {
    377       for( Int iColRefDir = 0; iColRefDir < (pcCandColSlice->isInterB() ? 2: 1); iColRefDir ++ )
    378       {
    379         for( Int iColRefIdx =0; iColRefIdx < pcCandColSlice->getNumRefIdx(( RefPicList )iColRefDir ); iColRefIdx++)
    380         {
    381           m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = false;
    382           Int iColViewIdx    = pcCandColSlice->getViewIndex();
    383           Int iColRefViewIdx = pcCandColSlice->getRefPic( ( RefPicList )iColRefDir, iColRefIdx)->getViewIndex();
    384           if(iColViewIdx == iColRefViewIdx)
    385             continue;
    386 
    387           for(Int iCurrRefDir = 0;(iCurrRefDir < (currSlice->isInterB() ? 2: 1)) && (m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] == false ); iCurrRefDir++)
    388           {
    389             for( Int iCurrRefIdx =0; iCurrRefIdx < currSlice->getNumRefIdx(( RefPicList )iCurrRefDir ); iCurrRefIdx++)
    390             {
    391               if( currSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx )->getViewIndex() == iColRefViewIdx )
    392               { 
    393                 m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = true;
    394                 break;
    395               }
    396             }
    397           }
    398         }
    399       }
    400     }
    401   }
    402 }
    403 Bool TComPic::isTempIVRefValid(Int currCandPic, Int iColRefDir, Int iColRefIdx)
    404 {
    405   return m_abTIVRINCurrRL[currCandPic][iColRefDir][iColRefIdx];
    406 }
    407 
    408 Void TComPic::checkTextureRef(  )
    409 {
    410   TComSlice* pcCurrSlice = getSlice(getCurrSliceIdx());
    411   TComPic* pcTextPic = pcCurrSlice->getTexturePic();
    412 #if H_3D_FCO
    413   if ( pcTextPic )
    414   {
    415 #endif
    416 
    417   TComSlice* pcTextSlice = pcTextPic->getSlice(0); // currently only support single slice
    418 
    419   for( Int iTextRefDir = 0; (iTextRefDir < (pcTextSlice->isInterB()? 2:1) ) && !pcTextSlice->isIntra(); iTextRefDir ++ )
    420   {
    421     for( Int iTextRefIdx =0; iTextRefIdx<pcTextSlice->getNumRefIdx(( RefPicList )iTextRefDir ); iTextRefIdx++)
    422     {
    423       Int iTextRefPOC    = pcTextSlice->getRefPOC( ( RefPicList )iTextRefDir, iTextRefIdx);
    424       Int iTextRefViewId = pcTextSlice->getRefPic( ( RefPicList )iTextRefDir, iTextRefIdx)->getViewIndex();
    425       m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = -1;
    426       Int iCurrRefDir = iTextRefDir;
    427       for( Int iCurrRefIdx =0; ( iCurrRefIdx<pcCurrSlice->getNumRefIdx(( RefPicList )iCurrRefDir ) ) && ( m_aiTexToDepRef[iTextRefDir][iTextRefIdx] < 0 ) ; iCurrRefIdx++)
    428       {
    429         if( pcCurrSlice->getRefPOC( ( RefPicList )iCurrRefDir, iCurrRefIdx ) == iTextRefPOC &&
    430           pcCurrSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId )
    431         { 
    432           m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;
    433         }
    434       }
    435     }
    436 
    437   }
    438 #if H_3D_FCO
    439   }
    440 #endif
    441 
    442 }
    443 
    444 Int TComPic::isTextRefValid(Int iTextRefDir, Int iTextRefIdx)
    445 {
    446   return m_aiTexToDepRef[iTextRefDir][iTextRefIdx];
    447 }
    448 #endif
    449216//! \}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComPic.h

    r976 r1072  
    8989  Int                   m_layerId;
    9090  Int                   m_viewId;
    91 #if H_3D
    92   Int                   m_viewIndex;
    93   Bool                  m_isDepth;
    94   Int**                 m_aaiCodedScale;
    95   Int**                 m_aaiCodedOffset;
    96 #endif
    97 #endif
    98 #if H_3D_QTLPC
    99   Bool                  m_bReduceBitsQTL;
    100 #endif
    101 #if H_3D_NBDV
    102   UInt        m_uiRapRefIdx;
    103   RefPicList  m_eRapRefList;
    104   Int         m_iNumDdvCandPics;
    105   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
    106   Int         m_aiTexToDepRef  [2][MAX_NUM_REF];
    10791#endif
    10892public:
     
    123107  Void          setViewId             ( Int viewId )     { m_viewId = viewId;   }
    124108  Int           getViewId             ()                 { return m_viewId;     }
    125 #if H_3D
    126   Void          setViewIndex          ( Int viewIndex )  { m_viewIndex = viewIndex;   }
    127   Int           getViewIndex          ()                 { return m_viewIndex;     }
    128 
    129   Void          setIsDepth            ( Bool isDepth )   { m_isDepth = isDepth; }
    130   Bool          getIsDepth            ()                 { return m_isDepth; }
    131 
    132   Void          setScaleOffset( Int** pS, Int** pO )  { m_aaiCodedScale = pS; m_aaiCodedOffset = pO; }
    133   Int**         getCodedScale ()                      { return m_aaiCodedScale;  }
    134   Int**         getCodedOffset()                      { return m_aaiCodedOffset; }
    135 #endif
    136 #endif
    137 #if H_3D_QTLPC
    138   Bool          getReduceBitsFlag ()             { return m_bReduceBitsQTL;     }
    139   Void          setReduceBitsFlag ( Bool bFlag ) { m_bReduceBitsQTL = bFlag;    }
    140109#endif
    141110  Bool          getUsedByCurr()             { return m_bUsedByCurr; }
     
    185154  Void          setNumReorderPics(Int i, UInt tlayer) { m_numReorderPics[tlayer] = i;    }
    186155  Int           getNumReorderPics(UInt tlayer)        { return m_numReorderPics[tlayer]; }
    187 #if H_3D
    188   Void          compressMotion(Int scale);
    189 #else   
    190156  Void          compressMotion();
    191 #endif
    192157  UInt          getCurrSliceIdx()            { return m_uiCurrSliceIdx;                }
    193158  Void          setCurrSliceIdx(UInt i)      { m_uiCurrSliceIdx = i;                   }
     
    211176  Void          print( Bool legend );
    212177#endif
    213 #if H_3D_NBDV
    214   Int           getNumDdvCandPics()                    {return m_iNumDdvCandPics;   }
    215   Int           getDisCandRefPictures(Int iColPOC);
    216   Void          setRapRefIdx(UInt uiRapRefIdx)         {m_uiRapRefIdx = uiRapRefIdx;}
    217   Void          setRapRefList(RefPicList eRefPicList)  {m_eRapRefList = eRefPicList;}
    218   Void          setNumDdvCandPics (Int i)              {m_iNumDdvCandPics = i;       }
    219   UInt          getRapRefIdx()                         {return m_uiRapRefIdx;       }
    220   RefPicList    getRapRefList()                        {return m_eRapRefList;       }
    221   Void          checkTemporalIVRef();
    222   Bool          isTempIVRefValid(Int currCandPic, Int iTempRefDir, Int iTempRefIdx);
    223   Void          checkTextureRef(  );
    224   Int           isTextRefValid(Int iTextRefDir, Int iTextRefIdx);
    225 #endif
    226178  /** transfer ownership of seis to this picture */
    227179  void setSEIs(SEIMessages& seis) { m_SEIs = seis; }
     
    244196private:
    245197  TComList<TComList<TComPic*>*> m_lists;
    246 #if H_3D
    247   TComVPS*                     m_vps;
    248 #endif
    249198public:
    250199  Void        push_back( TComList<TComPic*>* list ) { m_lists.push_back( list );   }
    251200  Int         size     ()                           { return (Int) m_lists.size(); }
    252 #if H_3D_ARP
    253   TComList<TComPic*>*  getPicList   ( Int layerIdInNuh );
    254 #endif
    255201  TComPic*    getPic   ( Int layerIdInNuh,              Int poc );   
    256202  TComPicYuv* getPicYuv( Int layerIdInNuh,              Int poc, Bool recon );
    257 #if H_3D
    258   Void        setVPS   ( TComVPS* vps ) { m_vps = vps;  };
    259   TComPic*    getPic   ( Int viewIndex, Bool depthFlag, Int poc );
    260   TComPicYuv* getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon );
    261 #endif 
    262203
    263204  Void print( ); 
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComPicYuv.cpp

    r872 r1072  
    7777  m_iCuHeight       = uiMaxCUHeight;
    7878
    79 #if H_3D_IV_MERGE
    80   m_iNumCuInWidth   = m_iPicWidth / m_iCuWidth;
    81   m_iNumCuInWidth  += ( m_iPicWidth % m_iCuWidth ) ? 1 : 0;
    82 
    83   m_iBaseUnitWidth  = uiMaxCUWidth  >> uiMaxCUDepth;
    84   m_iBaseUnitHeight = uiMaxCUHeight >> uiMaxCUDepth;
    85 #endif
    8679  Int numCuInWidth  = m_iPicWidth  / m_iCuWidth  + (m_iPicWidth  % m_iCuWidth  != 0);
    8780  Int numCuInHeight = m_iPicHeight / m_iCuHeight + (m_iPicHeight % m_iCuHeight != 0);
     
    331324}
    332325
    333 #if H_3D
    334 #if H_3D_IV_MERGE
    335 Void
    336 TComPicYuv::getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY )
    337 {
    338   Int iRastPartIdx    = g_auiZscanToRaster[iAbsZorderIdx];
    339   Int iCuSizeInBases  = m_iCuWidth   / m_iBaseUnitWidth;
    340   Int iCuX            = iCuAddr      % m_iNumCuInWidth;
    341   Int iCuY            = iCuAddr      / m_iNumCuInWidth;
    342   Int iBaseX          = iRastPartIdx % iCuSizeInBases;
    343   Int iBaseY          = iRastPartIdx / iCuSizeInBases;
    344   riX                 = iCuX * m_iCuWidth  + iBaseX * m_iBaseUnitWidth;
    345   riY                 = iCuY * m_iCuHeight + iBaseY * m_iBaseUnitHeight;
    346 }
    347 
    348 Void
    349 TComPicYuv::getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx )
    350 {
    351   Int iCuX            = iX / m_iCuWidth;
    352   Int iCuY            = iY / m_iCuHeight;
    353   Int iBaseX          = ( iX - iCuX * m_iCuWidth  ) / m_iBaseUnitWidth;
    354   Int iBaseY          = ( iY - iCuY * m_iCuHeight ) / m_iBaseUnitHeight;
    355   Int iCuSizeInBases  = m_iCuWidth                  / m_iBaseUnitWidth;
    356   riCuAddr            = iCuY   * m_iNumCuInWidth + iCuX;
    357   Int iRastPartIdx    = iBaseY * iCuSizeInBases  + iBaseX;
    358   riAbsZorderIdx      = g_auiRasterToZscan[ iRastPartIdx ];
    359 }
    360 #endif
    361 Void TComPicYuv::setLumaTo( Pel pVal )
    362 {
    363   xSetPels( getLumaAddr(), getStride(), getWidth(), getHeight(), pVal );
    364 }
    365 
    366 Void TComPicYuv::setChromaTo( Pel pVal )
    367 {
    368   xSetPels( getCbAddr(), getCStride(), getWidth() >> 1, getHeight() >> 1, pVal );
    369   xSetPels( getCrAddr(), getCStride(), getWidth() >> 1, getHeight() >> 1, pVal );
    370 }
    371 
    372 Void TComPicYuv::xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal )
    373 {
    374   for (Int iYPos = 0; iYPos < iHeight; iYPos++)
    375   {
    376     for (Int iXPos = 0; iXPos < iWidth; iXPos++)
    377     {
    378       piPelSource[iXPos] = iVal;
    379     }
    380     piPelSource += iSourceStride;
    381   }
    382 }
    383 #endif
    384326
    385327//! \}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComPicYuv.h

    r872 r1072  
    8888  Bool  m_bIsBorderExtended;
    8989 
    90 #if H_3D_IV_MERGE
    91   Int   m_iBaseUnitWidth;       ///< Width of Base Unit (with maximum depth or minimum size, m_iCuWidth >> Max. Depth)
    92   Int   m_iBaseUnitHeight;      ///< Height of Base Unit (with maximum depth or minimum size, m_iCuHeight >> Max. Depth)
    93   Int   m_iNumCuInWidth;
    94 #endif
    9590protected:
    9691  Void  xExtendPicCompBorder (Pel* piTxt, Int iStride, Int iWidth, Int iHeight, Int iMarginX, Int iMarginY);
    97 #if H_3D
    98   Void  xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal );
    99 #endif
    10092 
    10193public:
     
    166158  // Set border extension flag
    167159  Void  setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
    168 #if H_3D
    169   // Set Function
    170   Void  setLumaTo    ( Pel pVal ); 
    171   Void  setChromaTo  ( Pel pVal ); 
    172 #if H_3D_IV_MERGE
    173   // sample to block and block to sample conversion
    174   Void  getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY );
    175   Void  getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
    176 #endif
    177 #endif
    178160};// END CLASS DEFINITION TComPicYuv
    179161
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComPrediction.cpp

    r1039 r1072  
    5151{
    5252  m_piYuvExt = NULL;
    53 #if H_3D_VSP
    54   m_pDepthBlock = (Int*) malloc(MAX_NUM_SPU_W*MAX_NUM_SPU_W*sizeof(Int));
    55   if (m_pDepthBlock == NULL)
    56       printf("ERROR: UKTGHU, No memory allocated.\n");
    57 #endif
    5853}
    5954
    6055TComPrediction::~TComPrediction()
    6156{
    62 #if H_3D_VSP
    63   if (m_pDepthBlock != NULL)
    64       free(m_pDepthBlock);
    65   m_cYuvDepthOnVsp.destroy();
    66 #endif
    6757
    6858  delete[] m_piYuvExt;
     
    7363  m_cYuvPredTemp.destroy();
    7464
    75 #if H_3D_ARP
    76   m_acYuvPredBase[0].destroy();
    77   m_acYuvPredBase[1].destroy();
    78 #endif
    7965  if( m_pLumaRecBuffer )
    8066  {
     
    117103
    118104    m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE );
    119 #if H_3D_ARP
    120     m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    121     m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    122 #endif
    123 #if H_3D_VSP
    124     m_cYuvDepthOnVsp.create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    125 #endif
    126105  }
    127106
     
    134113    }
    135114  }
    136 #if H_3D_IC
    137   m_uiaShift[0] = 0;
    138   for( Int i = 1; i < 64; i++ )
    139   {
    140     m_uiaShift[i] = ( (1 << 15) + i/2 ) / i;
    141   }
    142 #endif
    143115}
    144116
     
    415387}
    416388
    417 #if H_3D_DIM
    418 Void TComPrediction::predIntraLumaDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc, TComWedgelet* dmm4Segmentation  )
    419 {
    420   assert( iWidth == iHeight  );
    421   assert( iWidth >= DIM_MIN_SIZE && iWidth <= DIM_MAX_SIZE );
    422   assert( isDimMode( uiIntraMode ) );
    423 
    424   UInt dimType    = getDimType  ( uiIntraMode );
    425 #if !HS_DMM_SIGNALLING_I0120
    426   Bool dimDeltaDC = isDimDeltaDC( uiIntraMode );
    427 #endif
    428   Bool isDmmMode  = (dimType <  DMM_NUM_TYPE);
    429 
    430   Bool* biSegPattern  = NULL;
    431   UInt  patternStride = 0;
    432 
    433   // get partiton
    434 #if H_3D_DIM_DMM
    435   TComWedgelet* dmmSegmentation = NULL;
    436   if( isDmmMode )
    437   {
    438     switch( dimType )
    439     {
    440     case( DMM1_IDX ):
    441       {
    442 #if SHARP_DMM1_I0110
    443         dmmSegmentation = pcCU->isDMM1UpscaleMode((UInt)iWidth) ?
    444             &(g_dmmWedgeLists[ g_aucConvertToBit[pcCU->getDMM1BasePatternWidth((UInt)iWidth)] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]) :
    445             &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]);
    446 #else
    447         dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]);
    448 #endif
    449       } break;
    450     case( DMM4_IDX ):
    451       {
    452         if( dmm4Segmentation == NULL )
    453         {
    454           dmmSegmentation = new TComWedgelet( iWidth, iHeight );
    455           xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmmSegmentation );
    456         }
    457         else
    458         {
    459           xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmm4Segmentation );
    460           dmmSegmentation = dmm4Segmentation;
    461         }
    462       } break;
    463     default: assert(0);
    464     }
    465     assert( dmmSegmentation );
    466 #if SHARP_DMM1_I0110
    467     if( dimType == DMM1_IDX && pcCU->isDMM1UpscaleMode((UInt)iWidth) )
    468     {
    469         biSegPattern = dmmSegmentation->getScaledPattern((UInt)iWidth);
    470         patternStride = iWidth;
    471     }
    472     else
    473     {
    474         biSegPattern  = dmmSegmentation->getPattern();
    475         patternStride = dmmSegmentation->getStride ();
    476     }
    477 #else
    478     biSegPattern  = dmmSegmentation->getPattern();
    479     patternStride = dmmSegmentation->getStride ();
    480 #endif
    481   }
    482 #endif
    483 
    484   // get predicted partition values
    485   assert( biSegPattern );
    486   Int* piMask = NULL;
    487   piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); // no filtering
    488   assert( piMask );
    489   Int maskStride = 2*iWidth + 1; 
    490   Int* ptrSrc = piMask+maskStride+1;
    491   Pel predDC1 = 0; Pel predDC2 = 0;
    492   xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 );
    493 
    494   // set segment values with deltaDC offsets
    495   Pel segDC1 = 0;
    496   Pel segDC2 = 0;
    497 #if HS_DMM_SIGNALLING_I0120
    498   if( !pcCU->getSDCFlag( uiAbsPartIdx ) )
    499 #else
    500   if( dimDeltaDC )
    501 #endif
    502   {
    503     Pel deltaDC1 = pcCU->getDimDeltaDC( dimType, 0, uiAbsPartIdx );
    504     Pel deltaDC2 = pcCU->getDimDeltaDC( dimType, 1, uiAbsPartIdx );
    505 #if H_3D_DIM_DMM
    506     if( isDmmMode )
    507     {
    508 #if H_3D_DIM_DLT
    509       segDC1 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 ) + deltaDC1 );
    510       segDC2 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 ) + deltaDC2 );
    511 #else
    512       segDC1 = ClipY( predDC1 + deltaDC1 );
    513       segDC2 = ClipY( predDC2 + deltaDC2 );
    514 #endif
    515     }
    516 #endif
    517   }
    518   else
    519   {
    520     segDC1 = predDC1;
    521     segDC2 = predDC2;
    522   }
    523 
    524   // set prediction signal
    525   Pel* pDst = piPred;
    526   xAssignBiSegDCs( pDst, uiStride, biSegPattern, patternStride, segDC1, segDC2 );
    527   pcCU->setDmmPredictor(segDC1, 0);
    528   pcCU->setDmmPredictor(segDC2, 1);
    529 
    530 #if H_3D_DIM_DMM
    531   if( dimType == DMM4_IDX && dmm4Segmentation == NULL ) { dmmSegmentation->destroy(); delete dmmSegmentation; }
    532 #endif
    533 }
    534 #endif
    535389
    536390/** Function for checking identical motion.
     
    546400      Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC();
    547401      Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC();
    548 #if H_3D_ARP
    549       if(!pcCU->getARPW(PartAddr) && RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
    550 #else
    551402      if(RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
    552 #endif
    553403      {
    554404        return true;
     
    559409}
    560410
    561 #if H_3D_SPIVMP
    562 Void TComPrediction::xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr )
    563 {
    564   for (Int i = 0; i < iNumSP; i++)
    565   {
    566     uiMergedSPW[i] = iSPWidth;
    567     uiMergedSPH[i] = iSPHeight;
    568     pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, i, iNumSPInOneLine, uiSPAddr[i]);
    569   }
    570 #if SHARP_ARP_CHROMA_I0104
    571   if( pcCU->getARPW( uiPartAddr ) != 0 )
    572   {
    573     return;
    574   }
    575 #endif
    576   // horizontal sub-PU merge
    577   for (Int i=0; i<iNumSP; i++)
    578   {
    579     if (i % iNumSPInOneLine == iNumSPInOneLine - 1 || uiMergedSPW[i]==0 || uiMergedSPH[i]==0)
    580     {
    581       continue;
    582     }
    583     for (Int j=i+1; j<i+iNumSPInOneLine-i%iNumSPInOneLine; j++)
    584     {
    585       if (xCheckTwoSPMotion(pcCU, uiSPAddr[i], uiSPAddr[j]))
    586       {
    587         uiMergedSPW[i] += iSPWidth;
    588         uiMergedSPW[j] = uiMergedSPH[j] = 0;
    589       }
    590       else
    591       {
    592         break;
    593       }
    594     }
    595   }
    596   //vertical sub-PU merge
    597   for (Int i=0; i<iNumSP-iNumSPInOneLine; i++)
    598   {
    599     if (uiMergedSPW[i]==0 || uiMergedSPH[i]==0)
    600     {
    601       continue;
    602     }
    603     for (Int j=i+iNumSPInOneLine; j<iNumSP; j+=iNumSPInOneLine)
    604     {
    605       if (xCheckTwoSPMotion(pcCU, uiSPAddr[i], uiSPAddr[j]) && uiMergedSPW[i]==uiMergedSPW[j])
    606       {
    607         uiMergedSPH[i] += iSPHeight;
    608         uiMergedSPH[j] = uiMergedSPW[j] = 0;
    609       }
    610       else
    611       {
    612         break;
    613       }
    614     }
    615   }
    616 }
    617 
    618 Bool TComPrediction::xCheckTwoSPMotion ( TComDataCU* pcCU, UInt PartAddr0, UInt PartAddr1 )
    619 {
    620   if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr1))
    621   {
    622     return false;
    623   }
    624   if( pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr1))
    625   {
    626     return false;
    627   }
    628 
    629   if (pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr0) >= 0)
    630   {
    631     if (pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr1))
    632     {
    633       return false;
    634     }
    635   }
    636 
    637   if (pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr0) >= 0)
    638   {
    639     if (pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr1))
    640     {
    641       return false;
    642     }
    643   }
    644   return true;
    645 }
    646 #endif
    647 
    648 #if H_3D_DBBP
    649 PartSize TComPrediction::getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize)
    650 {
    651   // find virtual partitioning for this CU based on depth block
    652   // segmentation of texture block --> mask IDs
    653   Pel*  pDepthBlockStart      = pDepthPels;
    654  
    655   // first compute average of depth block for thresholding
    656   Int iSumDepth = 0;
    657   Int iSubSample = 4;
    658   for (Int y=0; y<uiSize; y+=iSubSample)
    659   {
    660     for (Int x=0; x<uiSize; x+=iSubSample)
    661     {
    662       Int depthPel = pDepthPels[x];
    663      
    664       iSumDepth += depthPel;
    665     }
    666    
    667     // next row
    668     pDepthPels += uiDepthStride*iSubSample;
    669   }
    670  
    671   Int iSizeInBits = g_aucConvertToBit[uiSize] - g_aucConvertToBit[iSubSample];  // respect sub-sampling factor
    672   Int iMean = iSumDepth >> iSizeInBits*2;       // iMean /= (uiSize*uiSize);
    673  
    674   // start again for segmentation
    675   pDepthPels = pDepthBlockStart;
    676  
    677   // start mapping process
    678   Int matchedPartSum[2][2] = {{0,0},{0,0}}; // counter for each part size and boolean option
    679   PartSize virtualPartSizes[2] = { SIZE_Nx2N, SIZE_2NxN};
    680  
    681   UInt uiHalfSize = uiSize>>1;
    682   for (Int y=0; y<uiSize; y+=iSubSample)
    683   {
    684     for (Int x=0; x<uiSize; x+=iSubSample)
    685     {
    686       Int depthPel = pDepthPels[x];
    687      
    688       // decide which segment this pixel belongs to
    689       Int ucSegment = (Int)(depthPel>iMean);
    690      
    691       // Matched Filter to find optimal (conventional) partitioning
    692      
    693       // SIZE_Nx2N
    694       if(x<uiHalfSize)  // left
    695       {
    696         matchedPartSum[0][ucSegment]++;
    697       }
    698       else  // right
    699       {
    700         matchedPartSum[0][1-ucSegment]++;
    701       }
    702      
    703       // SIZE_2NxN
    704       if(y<uiHalfSize)  // top
    705       {
    706         matchedPartSum[1][ucSegment]++;
    707       }
    708       else  // bottom
    709       {
    710         matchedPartSum[1][1-ucSegment]++;
    711       }
    712     }
    713    
    714     // next row
    715     pDepthPels += uiDepthStride*iSubSample;
    716   }
    717  
    718   PartSize matchedPartSize = SIZE_NONE;
    719  
    720   Int iMaxMatchSum = 0;
    721   for(Int p=0; p<2; p++)  // loop over partition
    722   {
    723     for( Int b=0; b<=1; b++ ) // loop over boolean options
    724     {
    725       if(matchedPartSum[p][b] > iMaxMatchSum)
    726       {
    727         iMaxMatchSum = matchedPartSum[p][b];
    728         matchedPartSize = virtualPartSizes[p];
    729       }
    730     }
    731   }
    732  
    733   AOF( matchedPartSize != SIZE_NONE );
    734  
    735   return matchedPartSize;
    736 }
    737 
    738 Bool TComPrediction::getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask )
    739 {
    740   // segmentation of texture block --> mask IDs
    741   Pel*  pDepthBlockStart      = pDepthPels;
    742  
    743   // first compute average of depth block for thresholding
    744   Int iSumDepth = 0;
    745   Int uiMinDepth = MAX_INT;
    746   Int uiMaxDepth = 0;
    747 #if SEC_DBBP_DMM4_THRESHOLD_I0076
    748   iSumDepth  = pDepthPels[ 0 ];
    749   iSumDepth += pDepthPels[ uiWidth - 1 ];
    750   iSumDepth += pDepthPels[ uiDepthStride * (uiHeight - 1) ];
    751   iSumDepth += pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ];
    752 
    753   uiMinDepth = pDepthPels[ 0 ];
    754   uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiWidth - 1 ]);
    755   uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) ]);
    756   uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]);
    757 
    758   uiMaxDepth = pDepthPels[ 0 ];
    759   uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiWidth - 1 ]);
    760   uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) ]);
    761   uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]);
    762 #else
    763   for (Int y=0; y<uiHeight; y++)
    764   {
    765     for (Int x=0; x<uiWidth; x++)
    766     {
    767       Int depthPel = pDepthPels[x];
    768       iSumDepth += depthPel;
    769      
    770       if( depthPel > uiMaxDepth )
    771       {
    772         uiMaxDepth = depthPel;
    773       }
    774       if( depthPel < uiMinDepth )
    775       {
    776         uiMinDepth = depthPel;
    777       }
    778     }
    779    
    780     // next row
    781     pDepthPels += uiDepthStride;
    782   }
    783 #endif
    784  
    785   // don't generate mask for blocks with small depth range (encoder decision)
    786   if( uiMaxDepth - uiMinDepth < 10 )
    787   {
    788     return false;
    789   }
    790  
    791   AOF(uiWidth==uiHeight);
    792 #if SEC_DBBP_DMM4_THRESHOLD_I0076
    793   Int iMean = iSumDepth >> 2;
    794 #else
    795   Int iSizeInBits = g_aucConvertToBit[uiWidth]+2;
    796   Int iMean = iSumDepth >> iSizeInBits*2;       // iMean /= (uiWidth*uiHeight);
    797 #endif
    798  
    799   // start again for segmentation
    800   pDepthPels = pDepthBlockStart;
    801  
    802   Bool bInvertMask = pDepthPels[0]>iMean; // top-left segment needs to be mapped to partIdx 0
    803  
    804   // generate mask
    805   UInt uiSumPix[2] = {0,0};
    806   for (Int y=0; y<uiHeight; y++)
    807   {
    808     for (Int x=0; x<uiHeight; x++)
    809     {
    810       Int depthPel = pDepthPels[x];
    811      
    812       // decide which segment this pixel belongs to
    813       Int ucSegment = (Int)(depthPel>iMean);
    814      
    815       if( bInvertMask )
    816       {
    817         ucSegment = 1-ucSegment;
    818       }
    819      
    820       // count pixels for each segment
    821       uiSumPix[ucSegment]++;
    822      
    823       // set mask value
    824       pMask[x] = (Bool)ucSegment;
    825     }
    826    
    827     // next row
    828     pDepthPels += uiDepthStride;
    829     pMask += MAX_CU_SIZE;
    830   }
    831  
    832   // don't generate valid mask for tiny segments (encoder decision)
    833   // each segment needs to cover at least 1/8th of block
    834   UInt uiMinPixPerSegment = (uiWidth*uiHeight) >> 3;
    835   if( !( uiSumPix[0] > uiMinPixPerSegment && uiSumPix[1] > uiMinPixPerSegment ) )
    836   {
    837     return false;
    838   }
    839  
    840   // all good
    841   return true;
    842 }
    843 
    844 #if SHARP_DBBP_SIMPLE_FLTER_I0109
    845 Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize )
    846 #else
    847 Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr )
    848 #endif
    849 {
    850   Pel*  piSrc[2]    = {pInYuv[0]->getLumaAddr(uiPartAddr), pInYuv[1]->getLumaAddr(uiPartAddr)};
    851   UInt  uiSrcStride = pInYuv[0]->getStride();
    852   Pel*  piDst       = pOutYuv->getLumaAddr(uiPartAddr);
    853   UInt  uiDstStride = pOutYuv->getStride();
    854  
    855   UInt  uiMaskStride= MAX_CU_SIZE;
    856 #if !SHARP_DBBP_SIMPLE_FLTER_I0109
    857   Pel  filSrc = 0;
    858 #endif
    859   Pel* tmpTar = 0;
    860   tmpTar = (Pel *)xMalloc(Pel, uiWidth*uiHeight);
    861  
    862   // backup pointer
    863   Bool* pMaskStart = pMask;
    864  
    865   // combine luma first
    866   for (Int y=0; y<uiHeight; y++)
    867   {
    868     for (Int x=0; x<uiWidth; x++)
    869     {
    870       UChar ucSegment = (UChar)pMask[x];
    871       AOF( ucSegment < 2 );
    872      
    873       // filtering
    874       tmpTar[y*uiWidth+x] = piSrc[ucSegment][x];
    875     }
    876    
    877     piSrc[0]  += uiSrcStride;
    878     piSrc[1]  += uiSrcStride;
    879     pMask     += uiMaskStride;
    880   }
    881  
    882 #if SHARP_DBBP_SIMPLE_FLTER_I0109
    883   if (partSize == SIZE_Nx2N)
    884   {
    885     for (Int y=0; y<uiHeight; y++)
    886     {
    887       for (Int x=0; x<uiWidth; x++)
    888       {
    889         Bool l = (x==0)?pMaskStart[y*uiMaskStride+x]:pMaskStart[y*uiMaskStride+x-1];
    890         Bool r = (x==uiWidth-1)?pMaskStart[y*uiMaskStride+x]:pMaskStart[y*uiMaskStride+x+1];
    891        
    892         Pel left, right;
    893         left   = (x==0)          ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x-1];
    894         right  = (x==uiWidth-1)  ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x+1];
    895        
    896         piDst[x] = (l!=r) ? ClipY( Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 )) : tmpTar[y*uiWidth+x];
    897       }
    898       piDst     += uiDstStride;
    899     }
    900   }
    901   else // SIZE_2NxN
    902   {
    903     for (Int y=0; y<uiHeight; y++)
    904     {
    905       for (Int x=0; x<uiWidth; x++)
    906       {
    907         Bool t = (y==0)?pMaskStart[y*uiMaskStride+x]:pMaskStart[(y-1)*uiMaskStride+x];
    908         Bool b = (y==uiHeight-1)?pMaskStart[y*uiMaskStride+x]:pMaskStart[(y+1)*uiMaskStride+x];
    909        
    910         Pel top, bottom;
    911         top    = (y==0)          ? tmpTar[y*uiWidth+x] : tmpTar[(y-1)*uiWidth+x];
    912         bottom = (y==uiHeight-1) ? tmpTar[y*uiWidth+x] : tmpTar[(y+1)*uiWidth+x];
    913        
    914         piDst[x] = (t!=b) ? ClipY( Pel(( top + (tmpTar[y*uiWidth+x] << 1) + bottom ) >> 2 )) : tmpTar[y*uiWidth+x];
    915       }
    916       piDst     += uiDstStride;
    917     }
    918   }
    919 #else
    920   for (Int y=0; y<uiHeight; y++)
    921   {
    922     for (Int x=0; x<uiWidth; x++)
    923     {
    924       Bool t = (y==0)?pMaskStart[y*uiMaskStride+x]:pMaskStart[(y-1)*uiMaskStride+x];
    925       Bool l = (x==0)?pMaskStart[y*uiMaskStride+x]:pMaskStart[y*uiMaskStride+x-1];
    926       Bool b = (y==uiHeight-1)?pMaskStart[y*uiMaskStride+x]:pMaskStart[(y+1)*uiMaskStride+x];
    927       Bool r = (x==uiWidth-1)?pMaskStart[y*uiMaskStride+x]:pMaskStart[y*uiMaskStride+x+1];
    928       Bool c =pMaskStart[y*uiMaskStride+x];
    929 
    930       Pel left, right, top, bottom;
    931       left   = (x==0)          ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x-1];
    932       right  = (x==uiWidth-1)  ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x+1];
    933       top    = (y==0)          ? tmpTar[y*uiWidth+x] : tmpTar[(y-1)*uiWidth+x];
    934       bottom = (y==uiHeight-1) ? tmpTar[y*uiWidth+x] : tmpTar[(y+1)*uiWidth+x];
    935 
    936       if(!((l&&r&&c) || (!l&&!r&&!c)))
    937       {
    938         filSrc = Clip3( Pel( 0 ), Pel( 255 ), Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 ));
    939       }
    940       else
    941       {
    942         filSrc = tmpTar[y*uiWidth+x];
    943       }
    944 
    945       if(!((t&&b&&c) || (!t&&!b&&!c)))
    946       {
    947         filSrc = Clip3( Pel( 0 ), Pel( 255 ), Pel(( top + (filSrc << 1) + bottom ) >> 2 ));
    948       }
    949       piDst[x] = filSrc;
    950     }
    951     piDst     += uiDstStride;
    952   }
    953 #endif
    954 
    955   if ( tmpTar    ) { xFree(tmpTar);             tmpTar        = NULL; }
    956  
    957   // now combine chroma
    958   Pel*  piSrcU[2]       = { pInYuv[0]->getCbAddr(uiPartAddr), pInYuv[1]->getCbAddr(uiPartAddr) };
    959   Pel*  piSrcV[2]       = { pInYuv[0]->getCrAddr(uiPartAddr), pInYuv[1]->getCrAddr(uiPartAddr) };
    960   UInt  uiSrcStrideC    = pInYuv[0]->getCStride();
    961   Pel*  piDstU          = pOutYuv->getCbAddr(uiPartAddr);
    962   Pel*  piDstV          = pOutYuv->getCrAddr(uiPartAddr);
    963   UInt  uiDstStrideC    = pOutYuv->getCStride();
    964   UInt  uiWidthC        = uiWidth >> 1;
    965   UInt  uiHeightC       = uiHeight >> 1;
    966   Pel  filSrcU = 0, filSrcV = 0;
    967   Pel* tmpTarU = 0, *tmpTarV = 0;
    968   tmpTarU = (Pel *)xMalloc(Pel, uiWidthC*uiHeightC);
    969   tmpTarV = (Pel *)xMalloc(Pel, uiWidthC*uiHeightC);
    970   pMask = pMaskStart;
    971  
    972   for (Int y=0; y<uiHeightC; y++)
    973   {
    974     for (Int x=0; x<uiWidthC; x++)
    975     {
    976       UChar ucSegment = (UChar)pMask[x*2];
    977       AOF( ucSegment < 2 );
    978      
    979       // filtering
    980       tmpTarU[y*uiWidthC+x] = piSrcU[ucSegment][x];
    981       tmpTarV[y*uiWidthC+x] = piSrcV[ucSegment][x];
    982     }
    983    
    984     piSrcU[0]   += uiSrcStrideC;
    985     piSrcU[1]   += uiSrcStrideC;
    986     piSrcV[0]   += uiSrcStrideC;
    987     piSrcV[1]   += uiSrcStrideC;
    988     pMask       += 2*uiMaskStride;
    989   }
    990 
    991 #if SHARP_DBBP_SIMPLE_FLTER_I0109
    992   if (partSize == SIZE_Nx2N)
    993   {
    994     for (Int y=0; y<uiHeightC; y++)
    995     {
    996       for (Int x=0; x<uiWidthC; x++)
    997       {
    998         Bool l = (x==0)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[y*2*uiMaskStride+(x-1)*2];
    999         Bool r = (x==uiWidthC-1)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[y*2*uiMaskStride+(x+1)*2];
    1000 
    1001         Pel leftU, rightU;
    1002         leftU   = (x==0)           ? tmpTarU[y*uiWidthC+x] : tmpTarU[y*uiWidthC+x-1];
    1003         rightU  = (x==uiWidthC-1)  ? tmpTarU[y*uiWidthC+x] : tmpTarU[y*uiWidthC+x+1];
    1004         Pel leftV, rightV;
    1005         leftV   = (x==0)           ? tmpTarV[y*uiWidthC+x] : tmpTarV[y*uiWidthC+x-1];
    1006         rightV  = (x==uiWidthC-1)  ? tmpTarV[y*uiWidthC+x] : tmpTarV[y*uiWidthC+x+1];
    1007 
    1008         if (l!=r)
    1009         {
    1010           filSrcU = ClipC( Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 ));
    1011           filSrcV = ClipC( Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 ));
    1012         }
    1013         else
    1014         {
    1015           filSrcU = tmpTarU[y*uiWidthC+x];
    1016           filSrcV = tmpTarV[y*uiWidthC+x];
    1017         }
    1018         piDstU[x] = filSrcU;
    1019         piDstV[x] = filSrcV;
    1020       }
    1021       piDstU      += uiDstStrideC;
    1022       piDstV      += uiDstStrideC;
    1023     }
    1024   }
    1025   else
    1026   {
    1027     for (Int y=0; y<uiHeightC; y++)
    1028     {
    1029       for (Int x=0; x<uiWidthC; x++)
    1030       {
    1031         Bool t = (y==0)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[(y-1)*2*uiMaskStride+x*2];
    1032         Bool b = (y==uiHeightC-1)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[(y+1)*2*uiMaskStride+x*2];
    1033 
    1034         Pel topU, bottomU;
    1035         topU    = (y==0)           ? tmpTarU[y*uiWidthC+x] : tmpTarU[(y-1)*uiWidthC+x];
    1036         bottomU = (y==uiHeightC-1) ? tmpTarU[y*uiWidthC+x] : tmpTarU[(y+1)*uiWidthC+x];
    1037         Pel topV, bottomV;
    1038         topV    = (y==0)           ? tmpTarV[y*uiWidthC+x] : tmpTarV[(y-1)*uiWidthC+x];
    1039         bottomV = (y==uiHeightC-1) ? tmpTarV[y*uiWidthC+x] : tmpTarV[(y+1)*uiWidthC+x];
    1040 
    1041         if (t!=b)
    1042         {
    1043           filSrcU = ClipC( Pel(( topU + (tmpTarU[y*uiWidthC+x] << 1) + bottomU ) >> 2 ));
    1044           filSrcV = ClipC( Pel(( topV + (tmpTarV[y*uiWidthC+x] << 1) + bottomV ) >> 2 ));
    1045         }
    1046         else
    1047         {
    1048           filSrcU = tmpTarU[y*uiWidthC+x];
    1049           filSrcV = tmpTarV[y*uiWidthC+x];
    1050         }
    1051         piDstU[x] = filSrcU;
    1052         piDstV[x] = filSrcV;
    1053       }
    1054       piDstU      += uiDstStrideC;
    1055       piDstV      += uiDstStrideC;
    1056     }
    1057   }
    1058 #else
    1059   for (Int y=0; y<uiHeightC; y++)
    1060   {
    1061     for (Int x=0; x<uiWidthC; x++)
    1062     {
    1063       Bool t = (y==0)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[(y-1)*2*uiMaskStride+x*2];
    1064       Bool l = (x==0)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[y*2*uiMaskStride+(x-1)*2];
    1065       Bool b = (y==uiHeightC-1)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[(y+1)*2*uiMaskStride+x*2];
    1066       Bool r = (x==uiWidthC-1)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[y*2*uiMaskStride+(x+1)*2];
    1067       Bool c =pMaskStart[y*2*uiMaskStride+x*2];
    1068 
    1069       Pel leftU, rightU, topU, bottomU;
    1070       leftU   = (x==0)           ? tmpTarU[y*uiWidthC+x] : tmpTarU[y*uiWidthC+x-1];
    1071       rightU  = (x==uiWidthC-1)  ? tmpTarU[y*uiWidthC+x] : tmpTarU[y*uiWidthC+x+1];
    1072       topU    = (y==0)           ? tmpTarU[y*uiWidthC+x] : tmpTarU[(y-1)*uiWidthC+x];
    1073       bottomU = (y==uiHeightC-1) ? tmpTarU[y*uiWidthC+x] : tmpTarU[(y+1)*uiWidthC+x];
    1074 
    1075       Pel leftV, rightV, topV, bottomV;
    1076       leftV   = (x==0)           ? tmpTarV[y*uiWidthC+x] : tmpTarV[y*uiWidthC+x-1];
    1077       rightV  = (x==uiWidthC-1)  ? tmpTarV[y*uiWidthC+x] : tmpTarV[y*uiWidthC+x+1];
    1078       topV    = (y==0)           ? tmpTarV[y*uiWidthC+x] : tmpTarV[(y-1)*uiWidthC+x];
    1079       bottomV = (y==uiHeightC-1) ? tmpTarV[y*uiWidthC+x] : tmpTarV[(y+1)*uiWidthC+x];
    1080 
    1081       if(!((l&&r&&c) || (!l&&!r&&!c)))
    1082       {
    1083         filSrcU = Clip3( Pel( 0 ), Pel( 255 ), Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 ));
    1084         filSrcV = Clip3( Pel( 0 ), Pel( 255 ), Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 ));
    1085       }
    1086       else
    1087       {
    1088         filSrcU = tmpTarU[y*uiWidthC+x];
    1089         filSrcV = tmpTarV[y*uiWidthC+x];
    1090       }
    1091 
    1092       if(!((t&&b&&c) || (!t&&!b&&!c)))
    1093       {
    1094         filSrcU = Clip3( Pel( 0 ), Pel( 255 ), Pel(( topU + (filSrcU << 1) + bottomU ) >> 2 ));
    1095         filSrcV = Clip3( Pel( 0 ), Pel( 255 ), Pel(( topV + (filSrcV << 1) + bottomV ) >> 2 ));
    1096       }
    1097 
    1098       piDstU[x] = filSrcU;
    1099       piDstV[x] = filSrcV;
    1100     }
    1101     piDstU      += uiDstStrideC;
    1102     piDstV      += uiDstStrideC;
    1103   }
    1104 #endif
    1105   if ( tmpTarU    ) { xFree(tmpTarU);             tmpTarU        = NULL; }
    1106   if ( tmpTarV    ) { xFree(tmpTarV);             tmpTarV        = NULL; }
    1107 }
    1108 #endif
     411
    1109412
    1110413Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )
     
    1117420  {
    1118421    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
    1119 #if H_3D_VSP
    1120     if ( pcCU->getVSPFlag(uiPartAddr) == 0)
    1121     {
    1122 #endif
    1123422      if ( eRefPicList != REF_PIC_LIST_X )
    1124423      {
     
    1138437      else
    1139438      {
    1140 #if H_3D_SPIVMP
    1141         if ( pcCU->getSPIVMPFlag(uiPartAddr)!=0) 
    1142         {
    1143           Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    1144 
    1145           pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    1146 
    1147           UInt uiW[256], uiH[256];
    1148           UInt uiSPAddr[256];
    1149 
    1150           xGetSubPUAddrAndMerge(pcCU, uiPartAddr, iSPWidth, iSPHeight, iNumSPInOneLine, iNumSP, uiW, uiH, uiSPAddr);
    1151 
    1152           //MC
    1153           for (Int i = 0; i < iNumSP; i++)
    1154           {
    1155             if (uiW[i]==0 || uiH[i]==0)
    1156             {
    1157               continue;
    1158             }
    1159             if( xCheckIdenticalMotion( pcCU, uiSPAddr[i] ))
    1160             {
    1161               xPredInterUni (pcCU, uiSPAddr[i], uiW[i], uiH[i], REF_PIC_LIST_0, pcYuvPred );
    1162             }
    1163             else
    1164             {
    1165               xPredInterBi  (pcCU, uiSPAddr[i], uiW[i], uiH[i], pcYuvPred);
    1166             }
    1167           }
    1168         }
    1169         else
    1170         {
    1171 #endif
    1172439          if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    1173440          {
     
    1178445            xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1179446          }
    1180 #if H_3D_SPIVMP
    1181         }
    1182 #endif
    1183       }
    1184 #if H_3D_VSP
    1185     }
    1186     else
    1187     {
    1188       if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    1189       {
    1190         xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
     447      }
     448    return;
     449  }
     450
     451  for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ )
     452  {
     453    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
     454
     455      if ( eRefPicList != REF_PIC_LIST_X )
     456      {
     457        if( pcCU->getSlice()->getPPS()->getUseWP())
     458        {
     459          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
     460        }
     461        else
     462        {
     463          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
     464        }
     465        if ( pcCU->getSlice()->getPPS()->getUseWP() )
     466        {
     467          xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
     468        }
    1191469      }
    1192470      else
    1193471      {
    1194         xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1195       }
    1196     }
    1197 #endif
    1198     return;
    1199   }
    1200 
    1201   for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ )
    1202   {
    1203     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
    1204 
    1205 #if H_3D_VSP
    1206     if ( pcCU->getVSPFlag(uiPartAddr) == 0 )
    1207     {
    1208 #endif
    1209       if ( eRefPicList != REF_PIC_LIST_X )
    1210       {
    1211         if( pcCU->getSlice()->getPPS()->getUseWP())
    1212         {
    1213           xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
     472        if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
     473        {
     474          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
    1214475        }
    1215476        else
    1216477        {
    1217           xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1218         }
    1219         if ( pcCU->getSlice()->getPPS()->getUseWP() )
    1220         {
    1221           xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1222         }
    1223       }
    1224       else
    1225       {
    1226 #if H_3D_SPIVMP
    1227        if (pcCU->getSPIVMPFlag(uiPartAddr)!=0) 
    1228       {
    1229         Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    1230 
    1231         pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    1232 
    1233         UInt uiW[256], uiH[256];
    1234         UInt uiSPAddr[256];
    1235 
    1236         xGetSubPUAddrAndMerge(pcCU, uiPartAddr, iSPWidth, iSPHeight, iNumSPInOneLine, iNumSP, uiW, uiH, uiSPAddr);
    1237         //MC
    1238         for (Int i = 0; i < iNumSP; i++)
    1239         {
    1240           if (uiW[i]==0 || uiH[i]==0)
    1241           {
    1242             continue;
    1243           }
    1244           if( xCheckIdenticalMotion( pcCU, uiSPAddr[i] ))
    1245           {
    1246             xPredInterUni (pcCU, uiSPAddr[i], uiW[i], uiH[i], REF_PIC_LIST_0, pcYuvPred );
    1247           }
    1248           else
    1249           {
    1250             xPredInterBi  (pcCU, uiSPAddr[i], uiW[i], uiH[i], pcYuvPred);
    1251           }
    1252         }
    1253       }
    1254       else
    1255       {
    1256 #endif
    1257         if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    1258         {
    1259           xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
    1260         }
    1261         else
    1262         {
    1263478          xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1264479        }
    1265 #if H_3D_SPIVMP
    1266        }
    1267 #endif
    1268       }
    1269 #if H_3D_VSP
    1270     }
    1271     else
    1272     {
    1273       if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    1274       {
    1275         xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
    1276       }
    1277       else
    1278       {
    1279         xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1280       }
    1281     }
    1282 #endif
     480      }
    1283481  }
    1284482  return;
     
    1291489  pcCU->clipMv(cMv);
    1292490
    1293 #if H_3D_DDD
    1294   if( pcCU->getUseDDD( uiPartAddr ) )
    1295   {
    1296       assert( pcCU->getSPIVMPFlag( uiPartAddr ) == 0 );
    1297       assert( pcCU->getSlice()->getViewIndex() != 0 );
    1298 
    1299       Int dstStride = rpcYuvPred->getStride();
    1300       Int dstStrideC = rpcYuvPred->getCStride();
    1301       Pel *dst      = rpcYuvPred->getLumaAddr( uiPartAddr );
    1302       Pel *dstU     = rpcYuvPred->getCbAddr( uiPartAddr );
    1303       Pel *dstV     = rpcYuvPred->getCrAddr( uiPartAddr );
    1304 
    1305       Int iWidthC  = iWidth >> 1;
    1306       Int iHeightC = iHeight >> 1;
    1307       Int DefaultC = 1 << ( g_bitDepthY - 1);
    1308       for ( Int i = 0; i < iHeight; i++)
    1309       {
    1310           for ( Int j = 0; j < iWidth ; j++)
    1311           {
    1312               dst[j] = pcCU->getDDDepth( uiPartAddr );
    1313           }
    1314           dst += dstStride;
    1315       }
    1316       for ( Int i = 0; i < iHeightC; i++)
    1317       {
    1318           for ( Int j = 0; j < iWidthC; j++)
    1319           {
    1320               dstU[j] = dstV[j] = DefaultC;
    1321           }
    1322           dstU += dstStrideC;
    1323           dstV += dstStrideC;
    1324       }
    1325 
    1326       //return;
    1327   } else
    1328 #endif
    1329 #if H_3D_ARP
    1330   if(pcCU->getARPW( uiPartAddr ) > 0  && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC())
    1331   {
    1332     xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , bi );
    1333   }
    1334   else
    1335   {
    1336     if(  pcCU->getARPW( uiPartAddr ) > 0
    1337       && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N
    1338       && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC()
    1339       )
    1340     {
    1341       xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi );
    1342     }
    1343     else
    1344     {
    1345 #endif
    1346 #if H_3D_IC
    1347       Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() );
    1348       xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
    1349 #if H_3D_ARP
    1350         , false
    1351 #endif
    1352         , bICFlag );
    1353       bICFlag = bICFlag && (iWidth > 8);
    1354       xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
    1355 #if H_3D_ARP
    1356         , false
    1357 #endif
    1358         , bICFlag );
    1359 #else
    1360491      xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi );
    1361492      xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi );
    1362 #endif
    1363 #if H_3D_ARP
    1364     }
    1365   }
    1366 #endif
    1367 }
    1368 
    1369 #if H_3D_VSP
    1370 Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
    1371 {
    1372   Int vspSize = pcCU->getVSPFlag( uiPartAddr ) >> 1;
    1373 
    1374   Int widthSubPU, heightSubPU;
    1375   if (vspSize)
    1376   {
    1377     widthSubPU  = 8;
    1378     heightSubPU = 4;
    1379   }
    1380   else
    1381   {
    1382     widthSubPU  = 4;
    1383     heightSubPU = 8;
    1384   }
    1385   xPredInterUniSubPU( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi, widthSubPU, heightSubPU );
    1386 }
    1387 
    1388 Void TComPrediction::xPredInterUniSubPU( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU, Int heightSubPU )
    1389 {
    1390   UInt numPartsInLine       = pcCU->getPic()->getNumPartInWidth();
    1391   UInt horiNumPartsInSubPU  = widthSubPU >> 2;
    1392   UInt vertNumPartsInSubPU  = (heightSubPU >> 2) * numPartsInLine;
    1393 
    1394   UInt partAddrRasterLine = g_auiZscanToRaster[ uiPartAddr ];
    1395 
    1396   for( Int posY=0; posY<iHeight; posY+=heightSubPU, partAddrRasterLine+=vertNumPartsInSubPU )
    1397   {
    1398     UInt partAddrRasterSubPU = partAddrRasterLine;
    1399     for( Int posX=0; posX<iWidth; posX+=widthSubPU, partAddrRasterSubPU+=horiNumPartsInSubPU )
    1400     {
    1401       UInt    partAddrSubPU = g_auiRasterToZscan[ partAddrRasterSubPU ];
    1402       Int     refIdx        = pcCU->getCUMvField( eRefPicList )->getRefIdx( partAddrSubPU );           assert (refIdx >= 0);
    1403       TComMv  cMv           = pcCU->getCUMvField( eRefPicList )->getMv( partAddrSubPU );
    1404       pcCU->clipMv(cMv);
    1405 
    1406       xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi );
    1407       xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi );
    1408 
    1409     }
    1410   }
    1411 }
    1412 
    1413 #endif
    1414 
    1415 #if H_3D_ARP
    1416 Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
    1417 {
    1418   Int         iRefIdx      = pNewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
    1419   TComMv      cMv          = pNewMvFiled ? pNewMvFiled->getMv()     : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
    1420   Bool        bTobeScaled  = false;
    1421   TComPic* pcPicYuvBaseCol = NULL;
    1422   TComPic* pcPicYuvBaseRef = NULL;
    1423 
    1424 #if H_3D_NBDV
    1425   DisInfo cDistparity;
    1426   cDistparity.bDV           = pcCU->getDvInfo(uiPartAddr).bDV;
    1427   if( cDistparity.bDV )
    1428   {
    1429     cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV;
    1430     assert(pcCU->getDvInfo(uiPartAddr).bDV ==  pcCU->getDvInfo(0).bDV);
    1431     cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan;
    1432   }
    1433 #else
    1434   assert(0); // ARP can be applied only when a DV is available
    1435 #endif
    1436 
    1437   UChar dW = cDistparity.bDV ? pcCU->getARPW ( uiPartAddr ) : 0;
    1438 
    1439   if( cDistparity.bDV )
    1440   {
    1441     Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList);
    1442     if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() )
    1443     {
    1444       bTobeScaled = true;
    1445     }
    1446 
    1447     pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan );
    1448 
    1449     pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan );
    1450 
    1451     if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan))
    1452     {
    1453       dW = 0;
    1454       bTobeScaled = false;
    1455     }
    1456     else
    1457     {
    1458       assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC() );
    1459     }
    1460 
    1461     if(bTobeScaled)
    1462     {     
    1463       Int iCurrPOC    = pcCU->getSlice()->getPOC();
    1464       Int iColRefPOC  = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx );
    1465       Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList,  0);
    1466       Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC);
    1467       if ( iScale != 4096 )
    1468       {
    1469         cMv = cMv.scaleMv( iScale );
    1470       }
    1471       iRefIdx = 0;
    1472     }
    1473   }
    1474 
    1475   pcCU->clipMv(cMv);
    1476   TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec();
    1477 #if QC_I0129_ARP_FIX
    1478   xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true );
    1479   xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true );
    1480 #else
    1481   xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true );
    1482   xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true );
    1483 #endif
    1484   if( dW > 0 )
    1485   {
    1486     TComYuv * pYuvB0 = &m_acYuvPredBase[0];
    1487     TComYuv * pYuvB1  = &m_acYuvPredBase[1];
    1488 
    1489     TComMv cMVwithDisparity = cMv + cDistparity.m_acNBDV;
    1490     pcCU->clipMv(cMVwithDisparity);
    1491 #if SHARP_ARP_CHROMA_I0104
    1492     if (iWidth <= 8)
    1493     {
    1494       pYuvB0->clear(); pYuvB1->clear();
    1495     }
    1496 #endif
    1497 
    1498     assert ( cDistparity.bDV );
    1499    
    1500 #if NTT_BUG_FIX_TK54
    1501     TComMv cNBDV = cDistparity.m_acNBDV;
    1502     pcCU->clipMv( cNBDV );
    1503    
    1504     pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec();
    1505 #if QC_I0129_ARP_FIX
    1506     xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true );
    1507 #if SHARP_ARP_CHROMA_I0104
    1508     if (iWidth > 8)
    1509 #endif
    1510     xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true );
    1511 #else
    1512     xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, bi, true );
    1513     xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, bi, true );
    1514 #endif
    1515 #else
    1516     pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec();
    1517     xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true );
    1518     xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true );
    1519 #endif
    1520    
    1521     pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec();
    1522 #if QC_I0129_ARP_FIX
    1523     xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true );
    1524 #if SHARP_ARP_CHROMA_I0104
    1525     if (iWidth > 8)
    1526 #endif
    1527     xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true );
    1528 #else
    1529     xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true );
    1530     xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true );
    1531 #endif
    1532     pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight );
    1533 
    1534     if( 2 == dW )
    1535     {
    1536       pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
    1537     }
    1538     rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi );
    1539   }
    1540 }
    1541 
    1542 #if QC_I0051_ARP_SIMP
    1543 Bool TComPrediction::xCheckBiInterviewARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eBaseRefPicList, TComPic*& pcPicYuvCurrTRef, TComMv& cBaseTMV, Int& iCurrTRefPoc )
    1544 {
    1545   Int         iRefIdx       = pcCU->getCUMvField( eBaseRefPicList )->getRefIdx( uiPartAddr );
    1546   TComMv      cDMv          = pcCU->getCUMvField( eBaseRefPicList )->getMv( uiPartAddr );
    1547   TComPic* pcPicYuvBaseCol  = pcCU->getSlice()->getRefPic( eBaseRefPicList, iRefIdx ); 
    1548   TComPicYuv* pcYuvBaseCol  = pcPicYuvBaseCol->getPicYuvRec();
    1549   Int uiLCUAddr,uiAbsPartAddr;
    1550   Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
    1551   Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
    1552 
    1553   irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
    1554   irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); 
    1555   pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
    1556   TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr );
    1557 
    1558   TComPic* pcPicYuvBaseTRef = NULL;
    1559   pcPicYuvCurrTRef = NULL;
    1560 
    1561   //If there is available motion in base reference list, use it
    1562   if(!pColCU->isIntra(uiAbsPartAddr))
    1563   {
    1564     for(Int iList = 0; iList < (pColCU->getSlice()->isInterB() ? 2: 1); iList ++)
    1565     {
    1566       RefPicList eRefPicListCurr = RefPicList(iList);
    1567       Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr);
    1568       if( iRef != -1)
    1569       {
    1570         pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef); 
    1571         Int  iCurrPOC    = pColCU->getSlice()->getPOC();
    1572         Int  iCurrRefPOC = pcPicYuvBaseTRef->getPOC();
    1573         Int  iCurrRef    = pcCU->getSlice()->getFirstTRefIdx(eRefPicListCurr);
    1574 #if MTK_I0072_IVARP_SCALING_FIX
    1575         if( iCurrRef >= 0 && iCurrPOC != iCurrRefPOC)
    1576 #else
    1577         if( iCurrRef >= 0)
    1578 #endif
    1579         {
    1580           pcPicYuvCurrTRef =  pcCU->getSlice()->getRefPic(eRefPicListCurr,iCurrRef); 
    1581           Int iTargetPOC = pcPicYuvCurrTRef->getPOC();
    1582           pcPicYuvBaseTRef =  pcCU->getSlice()->getBaseViewRefPic(iTargetPOC,  pcPicYuvBaseCol->getViewIndex() ); 
    1583           if(pcPicYuvBaseTRef)
    1584           {
    1585             cBaseTMV = pColCU->getCUMvField(eRefPicListCurr)->getMv(uiAbsPartAddr);
    1586             Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC);
    1587             if ( iScale != 4096 )
    1588             {
    1589               cBaseTMV = cBaseTMV.scaleMv( iScale );
    1590             }
    1591             iCurrTRefPoc = iTargetPOC;
    1592             return true;
    1593           }
    1594         }
    1595       }
    1596     }
    1597   }
    1598 
    1599   //If there is no available motion in base reference list, use ( 0, 0 )
    1600   if( pcCU->getSlice()->getFirstTRefIdx( eBaseRefPicList ) >= 0 )
    1601   {
    1602     cBaseTMV.set( 0, 0 );
    1603     pcPicYuvCurrTRef = pcCU->getSlice()->getRefPic( eBaseRefPicList,  pcCU->getSlice()->getFirstTRefIdx( eBaseRefPicList ) );
    1604     iCurrTRefPoc = pcPicYuvCurrTRef->getPOC();
    1605     return true;
    1606   }
    1607 
    1608   return false;
    1609 }
    1610 #endif
    1611 
    1612 Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
    1613 {
    1614   Int         iRefIdx       = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
    1615   TComMv      cDMv          = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
    1616   TComMv      cTempDMv      = cDMv;
    1617   UChar       dW            = pcCU->getARPW ( uiPartAddr );
    1618 
    1619   TComPic* pcPicYuvBaseTRef = NULL;
    1620   TComPic* pcPicYuvCurrTRef = NULL;
    1621   TComPic* pcPicYuvBaseCol  = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); 
    1622   TComPicYuv* pcYuvBaseCol  = pcPicYuvBaseCol->getPicYuvRec();   
    1623   Bool bTMVAvai = false;     
    1624   TComMv cBaseTMV;
    1625   if( pNewMvFiled )
    1626   {
    1627     iRefIdx = pNewMvFiled->getRefIdx();
    1628     cDMv = pNewMvFiled->getMv();
    1629   }
    1630   pcCU->clipMv(cTempDMv);
    1631 
    1632   assert(dW > 0);
    1633   if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, pcPicYuvBaseCol->getViewIndex()))
    1634   {
    1635     dW = 0;
    1636   }
    1637   Int uiLCUAddr,uiAbsPartAddr;
    1638   Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
    1639   Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
    1640 
    1641   irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
    1642   irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); 
    1643   pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
    1644   TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr );
    1645 #if QC_I0051_ARP_SIMP
    1646   if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getIsDepth() )
    1647   {
    1648     RefPicList eOtherRefList = ( eRefPicList == REF_PIC_LIST_0 ) ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
    1649     Int iOtherRefIdx = pcCU->getCUMvField( eOtherRefList )->getRefIdx( uiPartAddr );
    1650     //The other prediction direction is temporal ARP
    1651     if( iOtherRefIdx >= 0 && pcCU->getSlice()->getViewIndex() == pcCU->getSlice()->getRefPic( eOtherRefList, iOtherRefIdx )->getViewIndex() )
    1652     {
    1653       bTMVAvai = true;
    1654       pcPicYuvBaseTRef = pcCU->getSlice()->getRefPic( eOtherRefList, iOtherRefIdx );
    1655       Int  iCurrPOC    = pcCU->getSlice()->getPOC();
    1656       Int  iCurrRefPOC = pcPicYuvBaseTRef->getPOC();
    1657       Int  iCurrRef    = pcCU->getSlice()->getFirstTRefIdx( eOtherRefList );
    1658      
    1659       if( iCurrRef >= 0 )
    1660       {
    1661         pcPicYuvCurrTRef =  pcCU->getSlice()->getRefPic( eOtherRefList,iCurrRef ); 
    1662         Int iTargetPOC = pcPicYuvCurrTRef->getPOC();
    1663         pcPicYuvBaseTRef =  pcCU->getSlice()->getBaseViewRefPic( iTargetPOC,  pcPicYuvBaseCol->getViewIndex() );
    1664         if( pcPicYuvBaseTRef )
    1665         {
    1666           cBaseTMV = pcCU->getCUMvField( eOtherRefList )->getMv( uiPartAddr );
    1667           Int iScale = pcCU-> xGetDistScaleFactor( iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC );
    1668           if ( iScale != 4096 )
    1669           {
    1670             cBaseTMV = cBaseTMV.scaleMv( iScale );
    1671           }
    1672         }
    1673         else
    1674         {
    1675           dW = 0;
    1676         }
    1677       }
    1678       else
    1679       {
    1680         dW = 0;
    1681       }
    1682     }
    1683 
    1684     //Both prediction directions are inter-view ARP
    1685     if ( iOtherRefIdx >= 0 && !bTMVAvai )
    1686     {
    1687       RefPicList eBaseList = REF_PIC_LIST_0;
    1688       Int iCurrTRefPoc;
    1689       bTMVAvai = ( eBaseList != eRefPicList ) && ( pcCU->getSlice()->getViewIndex() != pcCU->getSlice()->getRefPic( eOtherRefList, iOtherRefIdx )->getViewIndex() );
    1690 
    1691       if ( bTMVAvai )
    1692       {
    1693         if( xCheckBiInterviewARP( pcCU, uiPartAddr, iWidth, iHeight, eBaseList, pcPicYuvCurrTRef, cBaseTMV, iCurrTRefPoc ) )
    1694         {
    1695           pcPicYuvBaseTRef = pcCU->getSlice()->getBaseViewRefPic( iCurrTRefPoc,  pcPicYuvBaseCol->getViewIndex() );
    1696           if ( pcPicYuvBaseTRef == NULL )
    1697           {
    1698             dW = 0;
    1699           }
    1700         }
    1701         else
    1702         {
    1703           dW = 0;
    1704         }
    1705       }
    1706     }
    1707   }
    1708 
    1709   if( !pColCU->isIntra( uiAbsPartAddr ) && !bTMVAvai )
    1710 #else
    1711   if(!pColCU->isIntra(uiAbsPartAddr))
    1712 #endif
    1713   {
    1714     TComMvField puMVField;
    1715     for(Int iList = 0; iList < (pColCU->getSlice()->isInterB() ? 2: 1) && !bTMVAvai; iList ++)
    1716     {
    1717       RefPicList eRefPicListCurr = RefPicList(iList);
    1718       Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr);
    1719       if( iRef != -1)
    1720       {
    1721         pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef); 
    1722         Int  iCurrPOC    = pColCU->getSlice()->getPOC();
    1723         Int  iCurrRefPOC = pcPicYuvBaseTRef->getPOC();
    1724         Int  iCurrRef    = pcCU->getSlice()->getFirstTRefIdx(eRefPicListCurr);
    1725 #if MTK_I0072_IVARP_SCALING_FIX
    1726         if (iCurrRef >= 0 && iCurrRefPOC != iCurrPOC)
    1727 #else
    1728         if( iCurrRef >= 0)
    1729 #endif
    1730         {
    1731           pcPicYuvCurrTRef =  pcCU->getSlice()->getRefPic(eRefPicListCurr,iCurrRef); 
    1732           Int iTargetPOC = pcPicYuvCurrTRef->getPOC();
    1733           {
    1734             pcPicYuvBaseTRef =  pcCU->getSlice()->getBaseViewRefPic(iTargetPOC,  pcPicYuvBaseCol->getViewIndex() ); 
    1735             if(pcPicYuvBaseTRef)
    1736             {
    1737               cBaseTMV = pColCU->getCUMvField(eRefPicListCurr)->getMv(uiAbsPartAddr);
    1738               Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC);
    1739               if ( iScale != 4096 )
    1740                 cBaseTMV = cBaseTMV.scaleMv( iScale );                 
    1741               bTMVAvai = true;
    1742               break;
    1743             }
    1744           }
    1745         }
    1746       }
    1747     }
    1748   }
    1749   if (bTMVAvai == false)
    1750   {
    1751     bTMVAvai = true;
    1752     cBaseTMV.set(0, 0);
    1753     pcPicYuvBaseTRef =  pColCU->getSlice()->getRefPic(eRefPicList,  pcCU->getSlice()->getFirstTRefIdx(eRefPicList)); 
    1754     pcPicYuvCurrTRef =  pcCU->getSlice()->getRefPic  (eRefPicList,  pcCU->getSlice()->getFirstTRefIdx(eRefPicList));     
    1755   }
    1756 #if QC_I0129_ARP_FIX
    1757   xPredInterLumaBlk  ( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ),        bTMVAvai);
    1758   xPredInterChromaBlk( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ),        bTMVAvai);
    1759 #else
    1760   xPredInterLumaBlk  ( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi,        bTMVAvai);
    1761   xPredInterChromaBlk( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi,        bTMVAvai);
    1762 #endif
    1763   if( dW > 0 && bTMVAvai )
    1764   {
    1765     TComYuv*    pYuvCurrTRef    = &m_acYuvPredBase[0];
    1766     TComYuv*    pYuvBaseTRef    = &m_acYuvPredBase[1];
    1767     TComPicYuv* pcYuvCurrTref   = pcPicYuvCurrTRef->getPicYuvRec();       
    1768     TComPicYuv* pcYuvBaseTref   = pcPicYuvBaseTRef->getPicYuvRec(); 
    1769     TComMv      cTempMv         = cDMv + cBaseTMV;
    1770 
    1771     pcCU->clipMv(cBaseTMV);
    1772     pcCU->clipMv(cTempMv);
    1773 #if SHARP_ARP_CHROMA_I0104
    1774     if (iWidth <= 8)
    1775     {
    1776       pYuvCurrTRef->clear(); pYuvBaseTRef->clear();
    1777     }
    1778 #endif
    1779 #if QC_I0129_ARP_FIX
    1780     xPredInterLumaBlk  ( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true,   true);
    1781 #if SHARP_ARP_CHROMA_I0104
    1782     if (iWidth > 8)
    1783 #endif
    1784     xPredInterChromaBlk( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true,   true);
    1785     xPredInterLumaBlk  ( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, true,   true);
    1786 #if SHARP_ARP_CHROMA_I0104
    1787     if (iWidth > 8)
    1788 #endif
    1789     xPredInterChromaBlk( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, true,   true);
    1790 #else
    1791     xPredInterLumaBlk  ( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, bi,   true);
    1792     xPredInterChromaBlk( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, bi,   true);
    1793     xPredInterLumaBlk  ( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, bi,   true);
    1794     xPredInterChromaBlk( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, bi,   true);
    1795 
    1796 #endif
    1797     pYuvCurrTRef->subtractARP( pYuvCurrTRef , pYuvBaseTRef , uiPartAddr , iWidth , iHeight ); 
    1798     if(dW == 2)
    1799     {
    1800       pYuvCurrTRef->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
    1801     }
    1802     rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi );
    1803   }
    1804 }
    1805 
    1806 #endif
     493}
     494
     495
    1807496
    1808497Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred )
     
    1856545}
    1857546
    1858 #if H_3D_VSP
    1859 
    1860 Void TComPrediction::xPredInterBiVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred )
    1861 {
    1862   TComYuv* pcMbYuv;
    1863   Int      iRefIdx[2] = {-1, -1};
    1864   Bool     bi = (pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0);
    1865 
    1866   for ( Int iRefList = 0; iRefList < 2; iRefList++ )
    1867   {
    1868     RefPicList eRefPicList = RefPicList(iRefList);
    1869     iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );
    1870 
    1871     if ( iRefIdx[iRefList] < 0 )
    1872     {
    1873       continue;
    1874     }
    1875     assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) );
    1876 
    1877     pcMbYuv = &m_acYuvPred[iRefList];
    1878     xPredInterUniVSP ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, bi );
    1879   }
    1880 
    1881   xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
    1882 }
    1883 
    1884 #endif
    1885547
    1886548/**
     
    1897559 */
    1898560Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi
    1899 #if H_3D_ARP
    1900     , Bool filterType
    1901 #endif
    1902 #if H_3D_IC
    1903     , Bool bICFlag
    1904 #endif
    1905561  )
    1906562{
     
    1915571  Int yFrac = mv->getVer() & 0x3;
    1916572
    1917 #if H_3D_IC
    1918   if( cu->getSlice()->getIsDepth() )
    1919   {
    1920     refOffset = mv->getHor() + mv->getVer() * refStride;
    1921     ref       = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset;
    1922     xFrac     = 0;
    1923     yFrac     = 0;
    1924   }
    1925 #endif
    1926573  if ( yFrac == 0 )
    1927574  {
    1928 #if H_3D_IC
    1929     m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac,       !bi || bICFlag
    1930 #else
    1931575    m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac,       !bi
    1932 #endif
    1933 #if H_3D_ARP
    1934     , filterType
    1935 #endif
    1936576      );
    1937577  }
    1938578  else if ( xFrac == 0 )
    1939579  {
    1940 #if H_3D_IC
    1941     m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi || bICFlag
    1942 #else
    1943580    m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi
    1944 #endif
    1945 #if H_3D_ARP
    1946     , filterType
    1947 #endif
    1948581      );
    1949582  }
     
    1957590
    1958591    m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false     
    1959 #if H_3D_ARP
    1960     , filterType
    1961 #endif
    1962592      );
    1963 #if H_3D_IC
    1964     m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi || bICFlag
    1965 #else
    1966593    m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi
    1967 #endif
    1968 #if H_3D_ARP
    1969     , filterType
    1970 #endif
    1971594      );   
    1972595  }
    1973596
    1974 #if H_3D_IC
    1975   if( bICFlag )
    1976   {
    1977     Int a, b, i, j;
    1978     const Int iShift = IC_CONST_SHIFT;
    1979 
    1980     xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_LUMA );
    1981 
    1982 
    1983     for ( i = 0; i < height; i++ )
    1984     {
    1985       for ( j = 0; j < width; j++ )
    1986       {
    1987           dst[j] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, ( ( a*dst[j] ) >> iShift ) + b );
    1988       }
    1989       dst += dstStride;
    1990     }
    1991 
    1992     if(bi)
    1993     {
    1994       Pel *dst2      = dstPic->getLumaAddr( partAddr );
    1995       Int shift = IF_INTERNAL_PREC - g_bitDepthY;
    1996       for (i = 0; i < height; i++)
    1997       {
    1998         for (j = 0; j < width; j++)
    1999         {
    2000           Short val = dst2[j] << shift;
    2001           dst2[j] = val - (Short)IF_INTERNAL_OFFS;
    2002         }
    2003         dst2 += dstStride;
    2004       }
    2005     }
    2006   }
    2007 #endif
    2008597}
    2009598
     
    2021610 */
    2022611Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi
    2023 #if H_3D_ARP
    2024     , Bool filterType
    2025 #endif
    2026 #if H_3D_IC
    2027     , Bool bICFlag
    2028 #endif
    2029612  )
    2030613{
     
    2054637  if ( yFrac == 0 )
    2055638  {
    2056 #if H_3D_IC
    2057     m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag
    2058 #else
    2059639    m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi
    2060 #endif
    2061 #if H_3D_ARP
    2062     , filterType
    2063 #endif
    2064640    );   
    2065 #if H_3D_IC
    2066     m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag
    2067 #else
    2068641    m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi
    2069 #endif
    2070 #if H_3D_ARP
    2071     , filterType
    2072 #endif
    2073642    );
    2074643  }
    2075644  else if ( xFrac == 0 )
    2076645  {
    2077 #if H_3D_IC
    2078     m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag
    2079 #else
    2080646    m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi
    2081 #endif
    2082 #if H_3D_ARP
    2083     , filterType
    2084 #endif
    2085647    );
    2086 #if H_3D_IC
    2087     m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag
    2088 #else
    2089648    m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi
    2090 #endif
    2091 #if H_3D_ARP
    2092     , filterType
    2093 #endif
    2094649    );
    2095650  }
     
    2097652  {
    2098653    m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false
    2099 #if H_3D_ARP
    2100     , filterType
    2101 #endif 
    2102654      );
    2103 #if H_3D_IC
    2104     m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi || bICFlag
    2105 #else
    2106655    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi
    2107 #endif
    2108 #if H_3D_ARP
    2109     , filterType
    2110 #endif
    2111656      );
    2112657   
    2113658    m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false
    2114 #if H_3D_ARP
    2115     , filterType
    2116 #endif
    2117659      );
    2118 #if H_3D_IC
    2119     m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi || bICFlag
    2120 #else
    2121660    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi
    2122 #endif
    2123 #if H_3D_ARP
    2124     , filterType
    2125 #endif
    2126661      );   
    2127662  }
    2128663
    2129 #if H_3D_IC
    2130   if( bICFlag )
    2131   {
    2132     Int a, b, i, j;
    2133     const Int iShift = IC_CONST_SHIFT;
    2134     xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_U ); // Cb
    2135     for ( i = 0; i < cxHeight; i++ )
    2136     {
    2137       for ( j = 0; j < cxWidth; j++ )
    2138       {
    2139           dstCb[j] = Clip3(  0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b );
    2140       }
    2141       dstCb += dstStride;
    2142     }
    2143     xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_V ); // Cr
    2144     for ( i = 0; i < cxHeight; i++ )
    2145     {
    2146       for ( j = 0; j < cxWidth; j++ )
    2147       {
    2148           dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b );
    2149       }
    2150       dstCr += dstStride;
    2151     }
    2152 
    2153     if(bi)
    2154     {
    2155       Pel* dstCb2 = dstPic->getCbAddr( partAddr );
    2156       Pel* dstCr2 = dstPic->getCrAddr( partAddr );
    2157       Int shift = IF_INTERNAL_PREC - g_bitDepthC;
    2158       for (i = 0; i < cxHeight; i++)
    2159       {
    2160         for (j = 0; j < cxWidth; j++)
    2161         {
    2162           Short val = dstCb2[j] << shift;
    2163           dstCb2[j] = val - (Short)IF_INTERNAL_OFFS;
    2164 
    2165           val = dstCr2[j] << shift;
    2166           dstCr2[j] = val - (Short)IF_INTERNAL_OFFS;
    2167         }
    2168         dstCb2 += dstStride;
    2169         dstCr2 += dstStride;
    2170       }
    2171     }
    2172   }
    2173 #endif
    2174664}
    2175665
     
    2291781  return;
    2292782}
    2293 #if H_3D_IC
    2294 /** Function for deriving the position of first non-zero binary bit of a value
    2295  * \param x input value
    2296  *
    2297  * This function derives the position of first non-zero binary bit of a value
    2298  */
    2299 Int GetMSB( UInt x )
    2300 {
    2301   Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1;
    2302 
    2303   while( x > 1 )
    2304   {
    2305     bits >>= 1;
    2306     y = x >> bits;
    2307 
    2308     if( y )
    2309     {
    2310       x = y;
    2311       iMSB += bits;
    2312     }
    2313   }
    2314 
    2315   iMSB+=y;
    2316 
    2317   return iMSB;
    2318 }
    2319 
    2320 
    2321 /** Function for deriving LM illumination compensation.
    2322  */
    2323 Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType )
    2324 {
    2325   TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec();
    2326   Pel *pRec = NULL, *pRef = NULL;
    2327   UInt uiWidth, uiHeight, uiTmpPartIdx;
    2328   Int iRecStride = ( eType == TEXT_LUMA ) ? pRecPic->getStride() : pRecPic->getCStride();
    2329   Int iRefStride = ( eType == TEXT_LUMA ) ? pRefPic->getStride() : pRefPic->getCStride();
    2330 #if SEC_IC_NEIGHBOR_CLIP_I0080
    2331   Int iRefOffset, iHor, iVer;
    2332 #else
    2333   Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset, iHor, iVer;
    2334 
    2335   iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]];
    2336   iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]];
    2337 #endif
    2338   iHor = pcCU->getSlice()->getIsDepth() ? pMv->getHor() : ( ( pMv->getHor() + 2 ) >> 2 );
    2339   iVer = pcCU->getSlice()->getIsDepth() ? pMv->getVer() : ( ( pMv->getVer() + 2 ) >> 2 );
    2340 #if !SEC_IC_NEIGHBOR_CLIP_I0080
    2341   iRefX   = iCUPelX + iHor;
    2342   iRefY   = iCUPelY + iVer;
    2343 #endif
    2344   if( eType != TEXT_LUMA )
    2345   {
    2346     iHor = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getHor() + 1 ) >> 1 ) : ( ( pMv->getHor() + 4 ) >> 3 );
    2347     iVer = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getVer() + 1 ) >> 1 ) : ( ( pMv->getVer() + 4 ) >> 3 );
    2348   }
    2349   uiWidth  = ( eType == TEXT_LUMA ) ? pcCU->getWidth( 0 )  : ( pcCU->getWidth( 0 )  >> 1 );
    2350   uiHeight = ( eType == TEXT_LUMA ) ? pcCU->getHeight( 0 ) : ( pcCU->getHeight( 0 ) >> 1 );
    2351 
    2352   Int i, j, iCountShift = 0;
    2353 
    2354   // LLS parameters estimation -->
    2355 
    2356   Int x = 0, y = 0, xx = 0, xy = 0;
    2357   Int precShift = std::max(0, (( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC) - 12);
    2358 
    2359 #if SEC_IC_NEIGHBOR_CLIP_I0080
    2360   if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) )
    2361 #else
    2362   if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelY > 0 && iRefY > 0 )
    2363 #endif
    2364   {
    2365     iRefOffset = iHor + iVer * iRefStride - iRefStride;
    2366     if( eType == TEXT_LUMA )
    2367     {
    2368       pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    2369       pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride;
    2370     }
    2371     else if( eType == TEXT_CHROMA_U )
    2372     {
    2373       pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    2374       pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride;
    2375     }
    2376     else
    2377     {
    2378       assert( eType == TEXT_CHROMA_V );
    2379       pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    2380       pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride;
    2381     }
    2382 
    2383     for( j = 0; j < uiWidth; j+=2 )
    2384     {
    2385       x += pRef[j];
    2386       y += pRec[j];
    2387       xx += (pRef[j] * pRef[j])>>precShift;
    2388       xy += (pRef[j] * pRec[j])>>precShift;
    2389     }
    2390     iCountShift += g_aucConvertToBit[ uiWidth ] + 1;
    2391   }
    2392 
    2393 #if SEC_IC_NEIGHBOR_CLIP_I0080
    2394   if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) )
    2395 #else
    2396   if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelX > 0 && iRefX > 0 )
    2397 #endif
    2398   {
    2399     iRefOffset = iHor + iVer * iRefStride - 1;
    2400     if( eType == TEXT_LUMA )
    2401     {
    2402       pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    2403       pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1;
    2404     }
    2405     else if( eType == TEXT_CHROMA_U )
    2406     {
    2407       pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    2408       pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1;
    2409     }
    2410     else
    2411     {
    2412       assert( eType == TEXT_CHROMA_V );
    2413       pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    2414       pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1;
    2415     }
    2416 
    2417     for( i = 0; i < uiHeight; i+=2 )
    2418     {
    2419       x += pRef[0];
    2420       y += pRec[0];
    2421 
    2422       xx += (pRef[0] * pRef[0])>>precShift;
    2423       xy += (pRef[0] * pRec[0])>>precShift;
    2424 
    2425       pRef += iRefStride*2;
    2426       pRec += iRecStride*2;
    2427     }
    2428     iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 1 );
    2429   }
    2430 
    2431 #if FIX_TICKET_71
    2432   if( iCountShift == 0 )
    2433   {
    2434     a = ( 1 << IC_CONST_SHIFT );
    2435     b = 0;
    2436     return;
    2437   }
    2438 #endif
    2439 
    2440   xy += xx >> IC_REG_COST_SHIFT;
    2441   xx += xx >> IC_REG_COST_SHIFT;
    2442   Int a1 = ( xy << iCountShift ) - ((y * x) >> precShift);
    2443   Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift);
    2444   const Int iShift = IC_CONST_SHIFT;
    2445   {
    2446     {
    2447       const Int iShiftA2 = 6;
    2448       const Int iAccuracyShift = 15;
    2449 
    2450       Int iScaleShiftA2 = 0;
    2451       Int iScaleShiftA1 = 0;
    2452       Int a1s = a1;
    2453       Int a2s = a2;
    2454 
    2455       a1 = Clip3(0, 2*a2, a1);
    2456       iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2;
    2457       iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF;
    2458 
    2459       if( iScaleShiftA1 < 0 )
    2460       {
    2461         iScaleShiftA1 = 0;
    2462       }
    2463 
    2464       if( iScaleShiftA2 < 0 )
    2465       {
    2466         iScaleShiftA2 = 0;
    2467       }
    2468 
    2469       Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1;
    2470 
    2471 
    2472       a2s = a2 >> iScaleShiftA2;
    2473 
    2474       a1s = a1 >> iScaleShiftA1;
    2475 
    2476       a = a1s * m_uiaShift[ a2s ];
    2477       a = a >> iScaleShiftA;
    2478       b = (  y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift;
    2479     }
    2480   }   
    2481 }
    2482 #endif
    2483 
    2484 #if H_3D_DIM
    2485 Void TComPrediction::xPredBiSegDCs( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 )
    2486 {
    2487   Int  refDC1, refDC2;
    2488   const Int  iTR = (   patternStride - 1        ) - srcStride;
    2489   const Int  iTM = ( ( patternStride - 1 ) >> 1 ) - srcStride;
    2490   const Int  iLB = (   patternStride - 1        ) * srcStride - 1;
    2491   const Int  iLM = ( ( patternStride - 1 ) >> 1 ) * srcStride - 1;
    2492 
    2493   Bool bL = ( biSegPattern[0] != biSegPattern[(patternStride-1)*patternStride] );
    2494   Bool bT = ( biSegPattern[0] != biSegPattern[(patternStride-1)]               );
    2495 
    2496   if( bL == bT )
    2497   {
    2498     const Int  iTRR = ( patternStride * 2 - 1  ) - srcStride;
    2499     const Int  iLBB = ( patternStride * 2 - 1  ) * srcStride - 1;
    2500     refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : (abs(ptrSrc[iTRR] - ptrSrc[-(Int)srcStride]) > abs(ptrSrc[iLBB] - ptrSrc[ -1]) ? ptrSrc[iTRR] : ptrSrc[iLBB]);
    2501     refDC2 =      ( ptrSrc[ -1] + ptrSrc[-(Int)srcStride] )>>1;
    2502   }
    2503   else
    2504   {
    2505     refDC1 = bL ? ptrSrc[iLB] : ptrSrc[iTR];
    2506     refDC2 = bL ? ptrSrc[iTM] : ptrSrc[iLM];
    2507   }
    2508 
    2509   predDC1 = biSegPattern[0] ? refDC1 : refDC2;
    2510   predDC2 = biSegPattern[0] ? refDC2 : refDC1;
    2511 }
    2512 
    2513 Void TComPrediction::xAssignBiSegDCs( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 )
    2514 {
    2515   if( dstStride == patternStride )
    2516   {
    2517     for( UInt k = 0; k < (patternStride * patternStride); k++ )
    2518     {
    2519       if( true == biSegPattern[k] ) { ptrDst[k] = valDC2; }
    2520       else                          { ptrDst[k] = valDC1; }
    2521     }
    2522   }
    2523   else
    2524   {
    2525     Pel* piTemp = ptrDst;
    2526     for( UInt uiY = 0; uiY < patternStride; uiY++ )
    2527     {
    2528       for( UInt uiX = 0; uiX < patternStride; uiX++ )
    2529       {
    2530         if( true == biSegPattern[uiX] ) { piTemp[uiX] = valDC2; }
    2531         else                            { piTemp[uiX] = valDC1; }
    2532       }
    2533       piTemp       += dstStride;
    2534       biSegPattern += patternStride;
    2535     }
    2536   }
    2537 }
    2538 
    2539 #if H_3D_DIM_DMM
    2540 
    2541 Void TComPrediction::xPredContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge )
    2542 {
    2543   pcContourWedge->clear();
    2544 
    2545   // get copy of co-located texture luma block
    2546   TComYuv cTempYuv;
    2547   cTempYuv.create( uiWidth, uiHeight );
    2548   cTempYuv.clear();
    2549   Pel* piRefBlkY = cTempYuv.getLumaAddr();
    2550   xCopyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight );
    2551   piRefBlkY = cTempYuv.getLumaAddr();
    2552 
    2553   // find contour for texture luma block
    2554   UInt iDC = 0;
    2555 #if SEC_DBBP_DMM4_THRESHOLD_I0076
    2556   iDC  = piRefBlkY[ 0 ];
    2557   iDC += piRefBlkY[ uiWidth - 1 ];
    2558   iDC += piRefBlkY[ uiWidth * (uiHeight - 1) ];
    2559   iDC += piRefBlkY[ uiWidth * (uiHeight - 1) + uiWidth - 1 ];
    2560   iDC = iDC >> 2;
    2561 #else
    2562   for( UInt k = 0; k < (uiWidth*uiHeight); k++ )
    2563   {
    2564     iDC += piRefBlkY[k];
    2565   }
    2566 
    2567   Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2;   //
    2568   iDC = iDC >> (cuMaxLog2Size - pcCU->getDepth(0))*2;        //  iDC /= (uiWidth*uiHeight);
    2569 #endif
    2570 
    2571   piRefBlkY = cTempYuv.getLumaAddr();
    2572 
    2573   Bool* pabContourPattern = pcContourWedge->getPattern();
    2574   for( UInt k = 0; k < (uiWidth*uiHeight); k++ )
    2575   {
    2576     pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false;
    2577   }
    2578 
    2579   cTempYuv.destroy();
    2580 }
    2581 
    2582 
    2583 Void TComPrediction::xCopyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight )
    2584 {
    2585   TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec();
    2586   assert( pcPicYuvRef != NULL );
    2587   Int         iRefStride = pcPicYuvRef->getStride();
    2588   Pel*        piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx );
    2589 
    2590   for ( Int y = 0; y < uiHeight; y++ )
    2591   {
    2592     ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth);
    2593     piDestBlockY += uiWidth;
    2594     piRefY += iRefStride;
    2595   }
    2596 }
    2597 #endif
    2598 
    2599 
    2600 #if H_3D_DIM_SDC
    2601 Void TComPrediction::analyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride
    2602                                          ,UInt uiIntraMode
    2603                                          ,Bool orgDC
    2604                                         )
    2605 {
    2606   Int iSumDepth[2];
    2607   memset(iSumDepth, 0, sizeof(Int)*2);
    2608   Int iSumPix[2];
    2609   memset(iSumPix, 0, sizeof(Int)*2);
    2610   for( Int i = 0; i < uiNumSegments; i++ )
    2611   {
    2612     rpSegMeans[i] = 0;
    2613   }
    2614   if (orgDC == false)
    2615   {
    2616     Pel* pLeftTop = pOrig;
    2617     Pel* pRightTop = pOrig + (uiSize-1);
    2618     Pel* pLeftBottom = (pOrig+ (uiStride*(uiSize-1)));
    2619     Pel* pRightBottom = (pOrig+ (uiStride*(uiSize-1)) + (uiSize-1));
    2620 
    2621     rpSegMeans[0] = (*pLeftTop + *pRightTop + *pLeftBottom + *pRightBottom + 2)>>2;
    2622     return;
    2623   }
    2624 
    2625   Int subSamplePix;
    2626   if ( uiSize == 64 || uiSize == 32 )
    2627   {
    2628     subSamplePix = 2;
    2629   }
    2630   else
    2631   {
    2632     subSamplePix = 1;
    2633   }
    2634   for (Int y=0; y<uiSize; y+=subSamplePix)
    2635   {
    2636     for (Int x=0; x<uiSize; x+=subSamplePix)
    2637     {
    2638       UChar ucSegment = pMask?(UChar)pMask[x]:0;
    2639       assert( ucSegment < uiNumSegments );
    2640      
    2641       iSumDepth[ucSegment] += pOrig[x];
    2642       iSumPix[ucSegment]   += 1;
    2643     }
    2644    
    2645     pOrig  += uiStride*subSamplePix;
    2646     pMask  += uiMaskStride*subSamplePix;
    2647   }
    2648  
    2649   // compute mean for each segment
    2650   for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ )
    2651   {
    2652     if( iSumPix[ucSeg] > 0 )
    2653       rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg];
    2654     else
    2655       rpSegMeans[ucSeg] = 0;  // this happens for zero-segments
    2656   }
    2657 }
    2658 #endif // H_3D_DIM_SDC
    2659 #endif
     783
    2660784//! \}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComPrediction.h

    r1039 r1072  
    6565  TComYuv   m_acYuvPred[2];
    6666  TComYuv   m_cYuvPredTemp;
    67 #if H_3D_ARP
    68   TComYuv   m_acYuvPredBase[2];
    69 #endif
    7067  TComYuv m_filteredBlock[4][4];
    7168  TComYuv m_filteredBlockTmp[4];
     
    7572  Pel*   m_pLumaRecBuffer;       ///< array for downsampled reconstructed luma sample
    7673  Int    m_iLumaRecStride;       ///< stride of #m_pLumaRecBuffer array
    77 #if H_3D_IC
    78   UInt   m_uiaShift[ 64 ];       // Table for multiplication to substitue of division operation
    79 #endif
    8074
    81 #if H_3D_VSP
    82   Int*    m_pDepthBlock;         ///< Store a depth block, local variable, to prevent memory allocation every time
    83   TComYuv m_cYuvDepthOnVsp;
    84 #endif
    8575
    8676  Void xPredIntraAng            (Int bitDepth, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable, Bool bFilter );
     
    8878 
    8979  // motion compensation functions
    90 #if H_3D_ARP
    91   Void xPredInterUniARP         ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi=false, TComMvField * pNewMvFiled = NULL );
    92 #if QC_I0051_ARP_SIMP
    93   Bool xCheckBiInterviewARP     ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eBaseRefPicList, TComPic*& pcPicYuvCurrTRef, TComMv& cBaseTMV, Int& iCurrTRefPoc );
    94 #endif
    95   Void xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled = NULL );
    96 #endif
    9780  Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi=false          );
    9881  Void xPredInterBi             ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv*& rpcYuvPred );
    99 #if H_3D_VSP
    100   Void xPredInterUniVSP         ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi=false          );
    101   Void xPredInterBiVSP          ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv*& rpcYuvPred );
    102 #endif
    10382
    10483  Void xPredInterLumaBlk  ( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi
    105 #if H_3D_ARP
    106     , Bool filterType = false
    107 #endif
    108 #if H_3D_IC
    109     , Bool bICFlag    = false
    110 #endif
    11184    );
    11285  Void xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi
    11386
    114 #if H_3D_ARP
    115     , Bool filterType = false
    116 #endif
    117 #if H_3D_IC
    118     , Bool bICFlag    = false
    119 #endif
    12087    );
    12188
    122 #if H_3D_VSP
    123   Void xPredInterUniSubPU        ( TComDataCU *cu, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU=4, Int heightSubPU=4 );
    124 #endif
    12589
    12690  Void xWeightedAverage         ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst );
    12791 
    12892  Void xGetLLSPrediction ( TComPattern* pcPattern, Int* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0 );
    129 #if H_3D_IC
    130   Void xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType );
    131 #endif
    13293  Void xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight );
    13394  Bool xCheckIdenticalMotion    ( TComDataCU* pcCU, UInt PartAddr);
    134 #if H_3D_SPIVMP
    135   Bool xCheckTwoSPMotion ( TComDataCU* pcCU, UInt PartAddr0, UInt PartAddr1 );
    136   Void xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr );
    137 #endif
    138 #if H_3D_DIM
    139   // depth intra functions
    140   Void xPredBiSegDCs            ( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 );
    141   Void xAssignBiSegDCs          ( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel   valDC1, Pel   valDC2 );
    142 #if H_3D_DIM_DMM
    143   UInt xPredWedgeFromTex        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt intraTabIdx );
    144   Void xPredContourFromTex      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge );
    145   Void xCopyTextureLumaBlock    ( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight );
    146 #endif
    147 #endif
    14895
    14996public:
     
    163110  Void predIntraChromaAng         ( Int* piSrc, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft );
    164111 
    165 #if H_3D_DIM
    166   // Depth intra
    167   Void predIntraLumaDepth         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc = false
    168     , TComWedgelet* dmm4Segmentation = NULL
    169     );
    170 #if H_3D_DIM_SDC
    171   Void analyzeSegmentsSDC         ( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride
    172                                     ,UInt uiIntraMode
    173                                     ,Bool orgDC=false
    174     );
    175 #endif
    176 #endif
    177112 
    178 #if H_3D_DBBP
    179   PartSize      getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize);
    180   Bool          getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask );
    181 #if SHARP_DBBP_SIMPLE_FLTER_I0109
    182   Void          combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize );
    183 #else
    184   Void          combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr = 0 );
    185 #endif
    186 #endif
    187113
    188114  Pel  predIntraGetPredValDC      ( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft );
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComRdCost.cpp

    r884 r1072  
    4040#include "TComRom.h"
    4141#include "TComRdCost.h"
    42 #if H_3D
    43 #include "TComDataCU.h"
    44 #endif
    4542
    4643//! \ingroup TLibCommon
    4744//! \{
    4845
    49 #if H_3D_VSO
    50 // SAIT_VSO_EST_A0033
    51 Double TComRdCost::m_dDisparityCoeff = 1.0;
    52 #endif
    5346TComRdCost::TComRdCost()
    5447{
     
    6457
    6558// Calculate RD functions
    66 #if H_3D_VSO
    67 Double TComRdCost::calcRdCost( UInt uiBits, Dist uiDistortion, Bool bFlag, DFunc eDFunc )
    68 #else
    6959Double TComRdCost::calcRdCost( UInt uiBits, UInt uiDistortion, Bool bFlag, DFunc eDFunc )
    70 #endif
    7160{
    7261  Double dRdCost = 0.0;
     
    122111}
    123112
    124 #if H_3D_VSO
    125 Double TComRdCost::calcRdCost64( UInt64 uiBits, Dist64 uiDistortion, Bool bFlag, DFunc eDFunc )
    126 #else
    127113Double TComRdCost::calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag, DFunc eDFunc )
    128 #endif
    129114{
    130115  Double dRdCost = 0.0;
     
    235220  m_afpDistortFunc[28] = TComRdCost::xGetHADs;
    236221
    237 #if H_3D_VSO
    238   // SAIT_VSO_EST_A0033
    239   m_afpDistortFunc[29]  = TComRdCost::xGetVSD;
    240   m_afpDistortFunc[30]  = TComRdCost::xGetVSD4;
    241   m_afpDistortFunc[31]  = TComRdCost::xGetVSD8;
    242   m_afpDistortFunc[32]  = TComRdCost::xGetVSD16;
    243   m_afpDistortFunc[33]  = TComRdCost::xGetVSD32;
    244   m_afpDistortFunc[34]  = TComRdCost::xGetVSD64;
    245   m_afpDistortFunc[35]  = TComRdCost::xGetVSD16N;
    246 #endif
    247222#if !FIX203
    248223  m_puiComponentCostOriginP = NULL;
     
    256231  m_iSearchLimit            = 0xdeaddead;
    257232#endif
    258 #if H_3D_VSO
    259   m_bUseVSO                 = false;
    260   m_uiVSOMode               = 0;
    261   m_fpDistortFuncVSO        = NULL;
    262   m_pcRenModel              = NULL;
    263 
    264   // SAIT_VSO_EST_A0033
    265   m_bUseEstimatedVSD        = false;
    266 #endif
    267 #if H_3D_DBBP
    268   m_bUseMask                = false;
    269 #endif
    270233}
    271234
     
    328291  rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
    329292 
    330 #if H_3D_DBBP
    331   if( m_bUseMask )
    332   {
    333     if( eDFunc >= DF_SSE && eDFunc <= DF_SSE16N )
    334     {
    335       rcDistParam.DistFunc = TComRdCost::xGetMaskedSSE;
    336     }
    337     else if( eDFunc >= DF_SAD && eDFunc <= DF_SADS16N )
    338     {
    339       rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD;
    340     }
    341     else if( eDFunc >= DF_HADS && eDFunc <= DF_HADS16N )
    342     {
    343       rcDistParam.DistFunc = TComRdCost::xGetMaskedHADs;
    344     }
    345     else if( eDFunc >= DF_VSD && eDFunc <= DF_VSD16N )
    346     {
    347       rcDistParam.DistFunc = TComRdCost::xGetMaskedVSD;
    348     }
    349     else if( eDFunc >= DF_SAD12 && eDFunc <= DF_SADS48 )
    350     {
    351       rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD;
    352     }
    353   }
    354 #endif
    355293  // initialize
    356294  rcDistParam.iSubShift  = 0;
     
    387325#endif
    388326 
    389 #if H_3D_DBBP
    390   if( m_bUseMask )
    391   {
    392     rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD;
    393   }
    394 #endif
    395327  // initialize
    396328  rcDistParam.iSubShift  = 0;
     
    438370  }
    439371 
    440 #if H_3D_DBBP
    441   if( m_bUseMask )
    442   {
    443     rcDistParam.DistFunc = (bHADME)?TComRdCost::xGetMaskedHADs:TComRdCost::xGetMaskedSAD;
    444   }
    445 #endif
    446372  // initialize
    447373  rcDistParam.iSubShift  = 0;
     
    461387  rcDP.bitDepth   = bitDepth;
    462388  rcDP.DistFunc   = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ];
    463 #if H_3D_DBBP
    464   if( m_bUseMask )
    465   {
    466     rcDP.DistFunc = (bHadamard)?TComRdCost::xGetMaskedHADs:TComRdCost::xGetMaskedSAD;
    467   }
    468 #endif
    469389}
    470390
     
    505425}
    506426
    507 #if H_3D_FAST_DEPTH_INTRA
    508 
    509 UInt TComRdCost::calcVAR (Pel* pi0, Int stride, Int width, Int height, Int cuDepth)
    510 {
    511   Int temp = 0;
    512 
    513   for (Int y = 0; y < height; y++)
    514   {
    515     for (Int x = 0; x < width; x++)
    516     {
    517       temp += pi0[ y * stride + x ];
    518     }
    519   }
    520 
    521   Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2;
    522  
    523   if ( width == 4 )
    524   {
    525     cuDepth = cuMaxLog2Size - 2;
    526   }
    527 
    528   temp = temp >> (cuMaxLog2Size-cuDepth) * 2;
    529 
    530   UInt sum = 0;
    531   for (Int y = 0; y < height; y++)
    532   {
    533     for (Int x = 0; x <  width; x++)
    534     {
    535       sum += (pi0[ y * stride + x ] - temp ) * (pi0[ y * stride + x ] - temp );
    536     }
    537   }
    538   return (sum >> (cuMaxLog2Size-cuDepth)*2);
    539 
    540 }
    541 #endif
    542427
    543428
     
    556441  cDtParam.bitDepth = bitDepth;
    557442
    558 #if H_3D_IC
    559   cDtParam.bUseIC       = false;
    560 #endif
    561 #if H_3D_INTER_SDC
    562   cDtParam.bUseSDCMRSAD = false;
    563 #endif
    564443  if (eText == TEXT_CHROMA_U)
    565444  {
     
    575454  }
    576455}
    577 #if H_3D_VSO
    578 // SAIT_VSO_EST_A0033
    579 UInt TComRdCost::getDistPartVSD( TComDataCU* pcCU, UInt uiPartOffset, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight,  Bool bHAD, DFunc eDFunc )
    580 {
    581   AOT( ( m_dDisparityCoeff <= 0 ) || ( m_dDisparityCoeff > 10 ) );
    582 
    583   Pel* piVirRec  = m_pcVideoRecPicYuv->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset);
    584   Pel* piVirOrg  = m_pcDepthPicYuv   ->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset);
    585   Int iVirStride = m_pcVideoRecPicYuv->getStride();   
    586 
    587   DistParam cDtParam;
    588   setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam );
    589   cDtParam.pOrg       = piOrg;
    590   cDtParam.pCur       = piCur;
    591   cDtParam.pVirRec    = piVirRec;
    592   cDtParam.pVirOrg    = piVirOrg;
    593   cDtParam.iStrideVir = iVirStride;
    594   cDtParam.iStrideOrg = iOrgStride;
    595   cDtParam.iStrideCur = iCurStride;
    596   cDtParam.iStep      = 1;
    597 
    598   cDtParam.bApplyWeight = false;
    599   cDtParam.uiComp       = 255;    // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed.
    600 
    601   cDtParam.bitDepth   = g_bitDepthY;
    602 
    603   Dist dist = cDtParam.DistFunc( &cDtParam );
    604 
    605   if ( m_bUseWVSO )   
    606   {
    607     Int iDWeight   = m_iDWeight   * m_iDWeight;
    608     Int iVSOWeight = m_iVSDWeight * m_iVSDWeight;
    609     Dist distDepth;
    610 
    611     if ( !bHAD )
    612     {
    613       distDepth = (Dist) getDistPart( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
    614     }
    615     else
    616     {
    617       distDepth = (Dist) calcHAD( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
    618     }
    619 
    620     dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight);
    621   }
    622 
    623   return (UInt) dist;
    624 }
    625 #endif
    626 
    627 #if KWU_RC_MADPRED_E0227
    628 UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height )
    629 {
    630   UInt SAD = 0;
    631   Int shift = DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8);
    632   for ( Int i=0; i<height; i++ )
    633   {
    634     for( Int j=0; j<width; j++ )
    635     {
    636       SAD += abs((pelCur[j] - pelOrg[j])) >> shift;
    637     }
    638     pelCur = pelCur + curStride;
    639     pelOrg = pelOrg + orgStride;
    640   }
    641   return SAD;
    642 }
    643 #endif
     456
    644457
    645458// ====================================================================================================================
     
    647460// ====================================================================================================================
    648461
    649 #if H_3D_DBBP
    650462// --------------------------------------------------------------------------------------------------------------------
    651 // Masked distortion functions
     463// SAD
    652464// --------------------------------------------------------------------------------------------------------------------
    653465
    654 UInt TComRdCost::xGetMaskedSSE( DistParam* pcDtParam )
    655 {
    656   Pel* piOrg   = pcDtParam->pOrg;
    657   Pel* piCur   = pcDtParam->pCur;
    658   Int  iRows   = pcDtParam->iRows;
    659   Int  iCols   = pcDtParam->iCols;
    660   Int  iStrideOrg = pcDtParam->iStrideOrg;
    661   Int  iStrideCur = pcDtParam->iStrideCur;
    662  
    663   UInt uiSum = 0;
    664  
    665   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    666  
    667   Int iTemp;
    668  
    669   for( ; iRows != 0; iRows-- )
    670   {
    671     for (Int n = 0; n < iCols; n++ )
    672     {
    673       if( piOrg[n] != DBBP_INVALID_SHORT )
    674       {
    675         iTemp = piOrg[n  ] - piCur[n  ];
    676         uiSum += ( iTemp * iTemp ) >> uiShift;
    677       }
    678     }
    679     piOrg += iStrideOrg;
    680     piCur += iStrideCur;
    681   }
    682  
    683   return ( uiSum );
    684 }
    685 
    686 UInt TComRdCost::xGetMaskedSAD( DistParam* pcDtParam )
    687 {
    688  
    689   AOF(!pcDtParam->bApplyWeight);
    690 #if H_3D_IC
    691   AOF(!pcDtParam->bUseIC);
    692 #endif
    693  
     466UInt TComRdCost::xGetSAD( DistParam* pcDtParam )
     467{
     468  if ( pcDtParam->bApplyWeight )
     469  {
     470    return xGetSADw( pcDtParam );
     471  }
    694472  Pel* piOrg   = pcDtParam->pOrg;
    695473  Pel* piCur   = pcDtParam->pCur;
     
    705483    for (Int n = 0; n < iCols; n++ )
    706484    {
    707       if( piOrg[n] != DBBP_INVALID_SHORT )
    708       {
    709         uiSum += abs( piOrg[n] - piCur[n] );
    710       }
     485      uiSum += abs( piOrg[n] - piCur[n] );
    711486    }
    712487    piOrg += iStrideOrg;
     
    717492}
    718493
    719 UInt TComRdCost::xGetMaskedHADs( DistParam* pcDtParam )
    720 {
    721   AOF(!pcDtParam->bApplyWeight);
    722 #if H_3D_IC
    723   AOF(!pcDtParam->bUseIC);
    724 #endif
    725   Pel* piOrg   = pcDtParam->pOrg;
    726   Pel* piCur   = pcDtParam->pCur;
    727   Int  iRows   = pcDtParam->iRows;
    728   Int  iCols   = pcDtParam->iCols;
    729   Int  iStrideCur = pcDtParam->iStrideCur;
    730   Int  iStrideOrg = pcDtParam->iStrideOrg;
    731   Int  iStep  = pcDtParam->iStep;
    732  
    733   Int  x, y;
    734  
    735   UInt uiSum = 0;
    736  
    737 #if NS_HAD
    738   if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) )
    739 #else
    740     if( ( iRows % 8 == 0) && (iCols % 8 == 0) )
    741 #endif
    742     {
    743       Int  iOffsetOrg = iStrideOrg<<3;
    744       Int  iOffsetCur = iStrideCur<<3;
    745       for ( y=0; y<iRows; y+= 8 )
    746       {
    747         for ( x=0; x<iCols; x+= 8 )
    748         {
    749           if( piOrg[x] != DBBP_INVALID_SHORT )
    750           {
    751             uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    752           }
    753         }
    754         piOrg += iOffsetOrg;
    755         piCur += iOffsetCur;
    756       }
    757     }
    758 #if NS_HAD
    759     else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD )
    760     {
    761       Int  iOffsetOrg = iStrideOrg<<2;
    762       Int  iOffsetCur = iStrideCur<<2;
    763       for ( y=0; y<iRows; y+= 4 )
    764       {
    765         for ( x=0; x<iCols; x+= 16 )
    766         {
    767           if( piOrg[x] != DBBP_INVALID_SHORT )
    768           {
    769             uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    770           }
    771         }
    772         piOrg += iOffsetOrg;
    773         piCur += iOffsetCur;
    774       }
    775     }
    776     else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD )
    777     {
    778       Int  iOffsetOrg = iStrideOrg<<4;
    779       Int  iOffsetCur = iStrideCur<<4;
    780       for ( y=0; y<iRows; y+= 16 )
    781       {
    782         for ( x=0; x<iCols; x+= 4 )
    783         {
    784           if( piOrg[x] != DBBP_INVALID_SHORT )
    785           {
    786             uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    787           }
    788         }
    789         piOrg += iOffsetOrg;
    790         piCur += iOffsetCur;
    791       }
    792     }
    793 #endif
    794     else if( ( iRows % 4 == 0) && (iCols % 4 == 0) )
    795     {
    796       Int  iOffsetOrg = iStrideOrg<<2;
    797       Int  iOffsetCur = iStrideCur<<2;
    798      
    799       for ( y=0; y<iRows; y+= 4 )
    800       {
    801         for ( x=0; x<iCols; x+= 4 )
    802         {
    803           if( piOrg[x] != DBBP_INVALID_SHORT )
    804           {
    805             uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    806           }
    807         }
    808         piOrg += iOffsetOrg;
    809         piCur += iOffsetCur;
    810       }
    811     }
    812     else if( ( iRows % 2 == 0) && (iCols % 2 == 0) )
    813     {
    814       Int  iOffsetOrg = iStrideOrg<<1;
    815       Int  iOffsetCur = iStrideCur<<1;
    816       for ( y=0; y<iRows; y+=2 )
    817       {
    818         for ( x=0; x<iCols; x+=2 )
    819         {
    820           if( piOrg[x] != DBBP_INVALID_SHORT )
    821           {
    822             uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    823           }
    824         }
    825         piOrg += iOffsetOrg;
    826         piCur += iOffsetCur;
    827       }
    828     }
    829     else
    830     {
    831       assert(false);
    832     }
    833  
    834   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    835 }
    836 
    837 UInt TComRdCost::xGetMaskedVSD( DistParam* pcDtParam )
    838 {
    839   Pel* piOrg    = pcDtParam->pOrg;
    840   Pel* piCur    = pcDtParam->pCur;
    841   Pel* piVirRec = pcDtParam->pVirRec;
    842   Pel* piVirOrg = pcDtParam->pVirOrg;
    843   Int  iRows    = pcDtParam->iRows;
    844   Int  iCols    = pcDtParam->iCols;
    845   Int  iStrideOrg = pcDtParam->iStrideOrg;
    846   Int  iStrideCur = pcDtParam->iStrideCur;
    847   Int  iStrideVir = pcDtParam->iStrideVir;
    848  
    849   UInt uiSum = 0;
    850   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    851  
    852   Int dDM;
    853  
    854   for ( Int y = 0 ; y < iRows ; y++ )
    855   {
    856     for (Int x = 0; x < iCols; x++ )
    857     {
    858       if( piOrg[x] != DBBP_INVALID_SHORT )
    859       {
    860         dDM = (Int) ( piOrg[x  ] - piCur[x  ] );
    861         uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
    862       }
    863     }
    864     piOrg += iStrideOrg;
    865     piCur += iStrideCur;
    866   }
    867  
    868   return ( uiSum );
    869 }
    870 #endif
    871 // --------------------------------------------------------------------------------------------------------------------
    872 // SAD
    873 // --------------------------------------------------------------------------------------------------------------------
    874 
    875 UInt TComRdCost::xGetSAD( DistParam* pcDtParam )
    876 {
    877   if ( pcDtParam->bApplyWeight )
     494UInt TComRdCost::xGetSAD4( DistParam* pcDtParam )
     495{
     496  if ( pcDtParam->bApplyWeight )
    878497  {
    879498    return xGetSADw( pcDtParam );
    880499  }
    881 #if H_3D_IC
    882   if( pcDtParam->bUseIC )
    883   {
    884     return xGetSADic( pcDtParam );
    885   }
    886 #endif
    887 #if H_3D_INTER_SDC
    888   if( pcDtParam->bUseSDCMRSAD )
    889   {
    890     return xGetSADic( pcDtParam );
    891   }
    892 #endif
    893   Pel* piOrg   = pcDtParam->pOrg;
    894   Pel* piCur   = pcDtParam->pCur;
    895   Int  iRows   = pcDtParam->iRows;
    896   Int  iCols   = pcDtParam->iCols;
    897   Int  iStrideCur = pcDtParam->iStrideCur;
    898   Int  iStrideOrg = pcDtParam->iStrideOrg;
    899  
    900   UInt uiSum = 0;
    901  
    902   for( ; iRows != 0; iRows-- )
    903   {
    904     for (Int n = 0; n < iCols; n++ )
    905     {
    906       uiSum += abs( piOrg[n] - piCur[n] );
    907     }
    908     piOrg += iStrideOrg;
    909     piCur += iStrideCur;
    910   }
    911  
    912   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    913 }
    914 
    915 UInt TComRdCost::xGetSAD4( DistParam* pcDtParam )
    916 {
    917   if ( pcDtParam->bApplyWeight )
    918   {
    919     return xGetSADw( pcDtParam );
    920   }
    921 #if H_3D_IC
    922   if( pcDtParam->bUseIC )
    923   {
    924     return xGetSAD4ic( pcDtParam );
    925   }
    926 #endif
    927 #if H_3D_INTER_SDC
    928   if( pcDtParam->bUseSDCMRSAD )
    929   {
    930     return xGetSAD4ic( pcDtParam );
    931   }
    932 #endif
    933500  Pel* piOrg   = pcDtParam->pOrg;
    934501  Pel* piCur   = pcDtParam->pCur;
     
    962529    return xGetSADw( pcDtParam );
    963530  }
    964 #if H_3D_IC
    965   if( pcDtParam->bUseIC )
    966   {
    967     return xGetSAD8ic( pcDtParam );
    968   }
    969 #endif
    970 #if H_3D_INTER_SDC
    971   if( pcDtParam->bUseSDCMRSAD )
    972   {
    973     return xGetSAD8ic( pcDtParam );
    974   }
    975 #endif
    976531  Pel* piOrg      = pcDtParam->pOrg;
    977532  Pel* piCur      = pcDtParam->pCur;
     
    1009564    return xGetSADw( pcDtParam );
    1010565  }
    1011 #if H_3D_IC
    1012   if( pcDtParam->bUseIC )
    1013   {
    1014     return xGetSAD16ic( pcDtParam );
    1015   }
    1016 #endif
    1017 #if H_3D_INTER_SDC
    1018   if( pcDtParam->bUseSDCMRSAD )
    1019   {
    1020     return xGetSAD16ic( pcDtParam );
    1021   }
    1022 #endif
    1023566  Pel* piOrg   = pcDtParam->pOrg;
    1024567  Pel* piCur   = pcDtParam->pCur;
     
    1065608    return xGetSADw( pcDtParam );
    1066609  }
    1067 #if H_3D_IC
    1068   if( pcDtParam->bUseIC )
    1069   {
    1070     return xGetSAD12ic( pcDtParam );
    1071   }
    1072 #endif
    1073 #if H_3D_INTER_SDC
    1074   if( pcDtParam->bUseSDCMRSAD )
    1075   {
    1076     return xGetSAD12ic( pcDtParam );
    1077   }
    1078 #endif
    1079610  Pel* piOrg   = pcDtParam->pOrg;
    1080611  Pel* piCur   = pcDtParam->pCur;
     
    1113644UInt TComRdCost::xGetSAD16N( DistParam* pcDtParam )
    1114645{
    1115 #if H_3D_IC
    1116   if( pcDtParam->bUseIC )
    1117   {
    1118     return xGetSAD16Nic( pcDtParam );
    1119   }
    1120 #endif
    1121 #if H_3D_INTER_SDC
    1122   if( pcDtParam->bUseSDCMRSAD )
    1123   {
    1124     return xGetSAD16Nic( pcDtParam );
    1125   }
    1126 #endif
    1127646  Pel* piOrg   = pcDtParam->pOrg;
    1128647  Pel* piCur   = pcDtParam->pCur;
     
    1171690    return xGetSADw( pcDtParam );
    1172691  }
    1173 #if H_3D_IC
    1174   if( pcDtParam->bUseIC )
    1175   {
    1176     return xGetSAD32ic( pcDtParam );
    1177   }
    1178 #endif
    1179 #if H_3D_INTER_SDC
    1180   if( pcDtParam->bUseSDCMRSAD )
    1181   {
    1182     return xGetSAD32ic( pcDtParam );
    1183   }
    1184 #endif
    1185692  Pel* piOrg   = pcDtParam->pOrg;
    1186693  Pel* piCur   = pcDtParam->pCur;
     
    1243750    return xGetSADw( pcDtParam );
    1244751  }
    1245 #if H_3D_IC
    1246   if( pcDtParam->bUseIC )
    1247   {
    1248     return xGetSAD24ic( pcDtParam );
    1249   }
    1250 #endif
    1251 #if H_3D_INTER_SDC
    1252   if( pcDtParam->bUseSDCMRSAD )
    1253   {
    1254     return xGetSAD24ic( pcDtParam );
    1255   }
    1256 #endif
    1257752  Pel* piOrg   = pcDtParam->pOrg;
    1258753  Pel* piCur   = pcDtParam->pCur;
     
    1308803    return xGetSADw( pcDtParam );
    1309804  }
    1310 #if H_3D_IC
    1311   if( pcDtParam->bUseIC )
    1312   {
    1313     return xGetSAD64ic( pcDtParam );
    1314   }
    1315 #endif
    1316 #if H_3D_INTER_SDC
    1317   if( pcDtParam->bUseSDCMRSAD )
    1318   {
    1319     return xGetSAD64ic( pcDtParam );
    1320   }
    1321 #endif
    1322805  Pel* piOrg   = pcDtParam->pOrg;
    1323806  Pel* piCur   = pcDtParam->pCur;
     
    1412895    return xGetSADw( pcDtParam );
    1413896  }
    1414 #if H_3D_IC
    1415   if( pcDtParam->bUseIC )
    1416   {
    1417     return xGetSAD48ic( pcDtParam );
    1418   }
    1419 #endif
    1420 #if H_3D_INTER_SDC
    1421   if( pcDtParam->bUseSDCMRSAD )
    1422   {
    1423     return xGetSAD48ic( pcDtParam );
    1424   }
    1425 #endif
    1426897  Pel* piOrg   = pcDtParam->pOrg;
    1427898  Pel* piCur   = pcDtParam->pCur;
     
    1494965#endif
    1495966
    1496 #if H_3D_IC || H_3D_INTER_SDC
    1497 UInt TComRdCost::xGetSADic( DistParam* pcDtParam )
    1498 {
    1499   if ( pcDtParam->bApplyWeight )
    1500   {
    1501     return xGetSADw( pcDtParam );
    1502   }
    1503   Pel* piOrg   = pcDtParam->pOrg;
    1504   Pel* piCur   = pcDtParam->pCur;
    1505   Int  iRows   = pcDtParam->iRows;
    1506   Int  iCols   = pcDtParam->iCols;
    1507   Int  iStrideCur = pcDtParam->iStrideCur;
    1508   Int  iStrideOrg = pcDtParam->iStrideOrg;
    1509 
    1510   UInt uiSum = 0;
    1511 
    1512   Int  iOrigAvg = 0, iCurAvg = 0;
    1513   Int  iDeltaC;
    1514 
    1515   for( ; iRows != 0; iRows-- )
    1516   {
    1517     for (Int n = 0; n < iCols; n++ )
    1518     {
    1519       iOrigAvg += piOrg[n];
    1520       iCurAvg  += piCur[n];
    1521     }
    1522     piOrg += iStrideOrg;
    1523     piCur += iStrideCur;
    1524   }
    1525 
    1526   piOrg   = pcDtParam->pOrg;
    1527   piCur   = pcDtParam->pCur;
    1528   iRows   = pcDtParam->iRows;
    1529 
    1530   iDeltaC = (iOrigAvg - iCurAvg)/iCols/iRows;
    1531 
    1532   for( ; iRows != 0; iRows-- )
    1533   {
    1534     for (Int n = 0; n < iCols; n++ )
    1535     {
    1536       uiSum += abs( piOrg[n] - piCur[n] - iDeltaC );
    1537     }
    1538     piOrg += iStrideOrg;
    1539     piCur += iStrideCur;
    1540   }
    1541 
    1542   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1543 }
    1544 
    1545 UInt TComRdCost::xGetSAD4ic( DistParam* pcDtParam )
    1546 {
    1547   if ( pcDtParam->bApplyWeight )
    1548   {
    1549     return xGetSADw( pcDtParam );
    1550   }
    1551   Pel* piOrg   = pcDtParam->pOrg;
    1552   Pel* piCur   = pcDtParam->pCur;
    1553   Int  iRows   = pcDtParam->iRows;
    1554   Int  iSubShift  = pcDtParam->iSubShift;
    1555   Int  iSubStep   = ( 1 << iSubShift );
    1556   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1557   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1558 
    1559   UInt uiSum = 0;
    1560 
    1561   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    1562   Int  iDeltaC;
    1563 
    1564   for( ; iRows != 0; iRows-=iSubStep )
    1565   {
    1566     iOrigAvg += piOrg[0];
    1567     iOrigAvg += piOrg[1];
    1568     iOrigAvg += piOrg[2];
    1569     iOrigAvg += piOrg[3];
    1570 
    1571     iCurAvg  += piCur[0];
    1572     iCurAvg  += piCur[1];
    1573     iCurAvg  += piCur[2];
    1574     iCurAvg  += piCur[3];
    1575 
    1576     piOrg += iStrideOrg;
    1577     piCur += iStrideCur;
    1578     uiRowCnt++;
    1579   }
    1580 
    1581   piOrg   = pcDtParam->pOrg;
    1582   piCur   = pcDtParam->pCur;
    1583   iRows   = pcDtParam->iRows;
    1584 
    1585   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/4) : 0;
    1586 
    1587   for( ; iRows != 0; iRows-=iSubStep )
    1588   {
    1589     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    1590     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    1591     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    1592     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    1593 
    1594     piOrg += iStrideOrg;
    1595     piCur += iStrideCur;
    1596   }
    1597 
    1598   uiSum <<= iSubShift;
    1599   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1600 }
    1601 
    1602 UInt TComRdCost::xGetSAD8ic( DistParam* pcDtParam )
    1603 {
    1604   if ( pcDtParam->bApplyWeight )
    1605   {
    1606     return xGetSADw( pcDtParam );
    1607   }
    1608   Pel* piOrg      = pcDtParam->pOrg;
    1609   Pel* piCur      = pcDtParam->pCur;
    1610   Int  iRows      = pcDtParam->iRows;
    1611   Int  iSubShift  = pcDtParam->iSubShift;
    1612   Int  iSubStep   = ( 1 << iSubShift );
    1613   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1614   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1615 
    1616   UInt uiSum = 0;
    1617 
    1618   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    1619   Int  iDeltaC;
    1620 
    1621   for( ; iRows != 0; iRows-=iSubStep )
    1622   {
    1623     iOrigAvg += piOrg[0];
    1624     iOrigAvg += piOrg[1];
    1625     iOrigAvg += piOrg[2];
    1626     iOrigAvg += piOrg[3];
    1627     iOrigAvg += piOrg[4];
    1628     iOrigAvg += piOrg[5];
    1629     iOrigAvg += piOrg[6];
    1630     iOrigAvg += piOrg[7];
    1631 
    1632     iCurAvg  += piCur[0];
    1633     iCurAvg  += piCur[1];
    1634     iCurAvg  += piCur[2];
    1635     iCurAvg  += piCur[3];
    1636     iCurAvg  += piCur[4];
    1637     iCurAvg  += piCur[5];
    1638     iCurAvg  += piCur[6];
    1639     iCurAvg  += piCur[7];
    1640 
    1641     piOrg += iStrideOrg;
    1642     piCur += iStrideCur;
    1643     uiRowCnt++;
    1644   }
    1645 
    1646   piOrg   = pcDtParam->pOrg;
    1647   piCur   = pcDtParam->pCur;
    1648   iRows   = pcDtParam->iRows;
    1649 
    1650   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/8) : 0;
    1651 
    1652   for( ; iRows != 0; iRows-=iSubStep )
    1653   {
    1654     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    1655     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    1656     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    1657     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    1658     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    1659     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    1660     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    1661     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    1662 
    1663     piOrg += iStrideOrg;
    1664     piCur += iStrideCur;
    1665   }
    1666 
    1667   uiSum <<= iSubShift;
    1668   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1669 }
    1670 
    1671 UInt TComRdCost::xGetSAD16ic( DistParam* pcDtParam )
    1672 {
    1673   if ( pcDtParam->bApplyWeight )
    1674   {
    1675     return xGetSADw( pcDtParam );
    1676   }
    1677   Pel* piOrg   = pcDtParam->pOrg;
    1678   Pel* piCur   = pcDtParam->pCur;
    1679   Int  iRows   = pcDtParam->iRows;
    1680   Int  iSubShift  = pcDtParam->iSubShift;
    1681   Int  iSubStep   = ( 1 << iSubShift );
    1682   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1683   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1684 
    1685   UInt uiSum = 0;
    1686 
    1687   Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    1688   Int iDeltaC;
    1689 
    1690   for( ; iRows != 0; iRows-=iSubStep )
    1691   {
    1692     iOrigAvg += piOrg[0];
    1693     iOrigAvg += piOrg[1];
    1694     iOrigAvg += piOrg[2];
    1695     iOrigAvg += piOrg[3];
    1696     iOrigAvg += piOrg[4];
    1697     iOrigAvg += piOrg[5];
    1698     iOrigAvg += piOrg[6];
    1699     iOrigAvg += piOrg[7];
    1700     iOrigAvg += piOrg[8];
    1701     iOrigAvg += piOrg[9];
    1702     iOrigAvg += piOrg[10];
    1703     iOrigAvg += piOrg[11];
    1704     iOrigAvg += piOrg[12];
    1705     iOrigAvg += piOrg[13];
    1706     iOrigAvg += piOrg[14];
    1707     iOrigAvg += piOrg[15];
    1708 
    1709     iCurAvg  += piCur[0];
    1710     iCurAvg  += piCur[1];
    1711     iCurAvg  += piCur[2];
    1712     iCurAvg  += piCur[3];
    1713     iCurAvg  += piCur[4];
    1714     iCurAvg  += piCur[5];
    1715     iCurAvg  += piCur[6];
    1716     iCurAvg  += piCur[7];
    1717     iCurAvg  += piCur[8];
    1718     iCurAvg  += piCur[9];
    1719     iCurAvg  += piCur[10];
    1720     iCurAvg  += piCur[11];
    1721     iCurAvg  += piCur[12];
    1722     iCurAvg  += piCur[13];
    1723     iCurAvg  += piCur[14];
    1724     iCurAvg  += piCur[15];
    1725 
    1726     piOrg += iStrideOrg;
    1727     piCur += iStrideCur;
    1728     uiRowCnt++;
    1729   }
    1730 
    1731   piOrg   = pcDtParam->pOrg;
    1732   piCur   = pcDtParam->pCur;
    1733   iRows   = pcDtParam->iRows;
    1734 
    1735   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/16) : 0;
    1736 
    1737   for( ; iRows != 0; iRows-=iSubStep )
    1738   {
    1739     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    1740     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    1741     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    1742     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    1743     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    1744     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    1745     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    1746     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    1747     uiSum += abs( piOrg[8] - piCur[8] - iDeltaC );
    1748     uiSum += abs( piOrg[9] - piCur[9] - iDeltaC );
    1749     uiSum += abs( piOrg[10] - piCur[10] - iDeltaC );
    1750     uiSum += abs( piOrg[11] - piCur[11] - iDeltaC );
    1751     uiSum += abs( piOrg[12] - piCur[12] - iDeltaC );
    1752     uiSum += abs( piOrg[13] - piCur[13] - iDeltaC );
    1753     uiSum += abs( piOrg[14] - piCur[14] - iDeltaC );
    1754     uiSum += abs( piOrg[15] - piCur[15] - iDeltaC );
    1755 
    1756     piOrg += iStrideOrg;
    1757     piCur += iStrideCur;
    1758   }
    1759 
    1760   uiSum <<= iSubShift;
    1761   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1762 }
    1763 
    1764 #if AMP_SAD
    1765 UInt TComRdCost::xGetSAD12ic( DistParam* pcDtParam )
    1766 {
    1767   if ( pcDtParam->bApplyWeight )
    1768   {
    1769     return xGetSADw( pcDtParam );
    1770   }
    1771   Pel* piOrg   = pcDtParam->pOrg;
    1772   Pel* piCur   = pcDtParam->pCur;
    1773   Int  iRows   = pcDtParam->iRows;
    1774   Int  iSubShift  = pcDtParam->iSubShift;
    1775   Int  iSubStep   = ( 1 << iSubShift );
    1776   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1777   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1778 
    1779   UInt uiSum = 0;
    1780 
    1781   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    1782   Int  iDeltaC;
    1783 
    1784   for( ; iRows != 0; iRows-=iSubStep )
    1785   {
    1786     iOrigAvg += piOrg[0];
    1787     iOrigAvg += piOrg[1];
    1788     iOrigAvg += piOrg[2];
    1789     iOrigAvg += piOrg[3];
    1790     iOrigAvg += piOrg[4];
    1791     iOrigAvg += piOrg[5];
    1792     iOrigAvg += piOrg[6];
    1793     iOrigAvg += piOrg[7];
    1794     iOrigAvg += piOrg[8];
    1795     iOrigAvg += piOrg[9];
    1796     iOrigAvg += piOrg[10];
    1797     iOrigAvg += piOrg[11];
    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 
    1812     piOrg += iStrideOrg;
    1813     piCur += iStrideCur;
    1814     uiRowCnt++;
    1815   }
    1816 
    1817   piOrg   = pcDtParam->pOrg;
    1818   piCur   = pcDtParam->pCur;
    1819   iRows   = pcDtParam->iRows;
    1820 
    1821   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/12) : 0;
    1822 
    1823   for( ; iRows != 0; iRows-=iSubStep )
    1824   {
    1825     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    1826     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    1827     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    1828     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    1829     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    1830     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    1831     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    1832     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    1833     uiSum += abs( piOrg[8] - piCur[8] - iDeltaC );
    1834     uiSum += abs( piOrg[9] - piCur[9] - iDeltaC );
    1835     uiSum += abs( piOrg[10] - piCur[10] - iDeltaC );
    1836     uiSum += abs( piOrg[11] - piCur[11] - iDeltaC );
    1837 
    1838     piOrg += iStrideOrg;
    1839     piCur += iStrideCur;
    1840   }
    1841 
    1842   uiSum <<= iSubShift;
    1843   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1844 }
    1845 #endif
    1846 
    1847 UInt TComRdCost::xGetSAD16Nic( DistParam* pcDtParam )
    1848 {
    1849   Pel* piOrg   = pcDtParam->pOrg;
    1850   Pel* piCur   = pcDtParam->pCur;
    1851   Int  iRows   = pcDtParam->iRows;
    1852   Int  iCols   = pcDtParam->iCols;
    1853   Int  iSubShift  = pcDtParam->iSubShift;
    1854   Int  iSubStep   = ( 1 << iSubShift );
    1855   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1856   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1857 
    1858   UInt uiSum = 0;
    1859 
    1860   Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0, uiColCnt = (iCols-1)/16 + 1;
    1861   Int  iDeltaC;
    1862 
    1863   for( ; iRows != 0; iRows-=iSubStep )
    1864   {
    1865     for (Int n = 0; n < iCols; n+=16 )
    1866     {
    1867       iOrigAvg += piOrg[n + 0];
    1868       iOrigAvg += piOrg[n + 1];
    1869       iOrigAvg += piOrg[n + 2];
    1870       iOrigAvg += piOrg[n + 3];
    1871       iOrigAvg += piOrg[n + 4];
    1872       iOrigAvg += piOrg[n + 5];
    1873       iOrigAvg += piOrg[n + 6];
    1874       iOrigAvg += piOrg[n + 7];
    1875       iOrigAvg += piOrg[n + 8];
    1876       iOrigAvg += piOrg[n + 9];
    1877       iOrigAvg += piOrg[n + 10];
    1878       iOrigAvg += piOrg[n + 11];
    1879       iOrigAvg += piOrg[n + 12];
    1880       iOrigAvg += piOrg[n + 13];
    1881       iOrigAvg += piOrg[n + 14];
    1882       iOrigAvg += piOrg[n + 15];
    1883 
    1884       iCurAvg  += piCur[n + 0];
    1885       iCurAvg  += piCur[n + 1];
    1886       iCurAvg  += piCur[n + 2];
    1887       iCurAvg  += piCur[n + 3];
    1888       iCurAvg  += piCur[n + 4];
    1889       iCurAvg  += piCur[n + 5];
    1890       iCurAvg  += piCur[n + 6];
    1891       iCurAvg  += piCur[n + 7];
    1892       iCurAvg  += piCur[n + 8];
    1893       iCurAvg  += piCur[n + 9];
    1894       iCurAvg  += piCur[n + 10];
    1895       iCurAvg  += piCur[n + 11];
    1896       iCurAvg  += piCur[n + 12];
    1897       iCurAvg  += piCur[n + 13];
    1898       iCurAvg  += piCur[n + 14];
    1899       iCurAvg  += piCur[n + 15];
    1900     }
    1901     piOrg += iStrideOrg;
    1902     piCur += iStrideCur;
    1903     uiRowCnt++;
    1904   }
    1905   piOrg   = pcDtParam->pOrg;
    1906   piCur   = pcDtParam->pCur;
    1907   iRows   = pcDtParam->iRows;
    1908 
    1909   iDeltaC = (uiRowCnt && uiColCnt) ? ((iOrigAvg - iCurAvg)/uiRowCnt/uiColCnt/16) : 0;
    1910 
    1911   for( ; iRows != 0; iRows-=iSubStep )
    1912   {
    1913     for (Int n = 0; n < iCols; n+=16 )
    1914     {
    1915       uiSum += abs( piOrg[n+ 0] - piCur[n+ 0] - iDeltaC );
    1916       uiSum += abs( piOrg[n+ 1] - piCur[n+ 1] - iDeltaC );
    1917       uiSum += abs( piOrg[n+ 2] - piCur[n+ 2] - iDeltaC );
    1918       uiSum += abs( piOrg[n+ 3] - piCur[n+ 3] - iDeltaC );
    1919       uiSum += abs( piOrg[n+ 4] - piCur[n+ 4] - iDeltaC );
    1920       uiSum += abs( piOrg[n+ 5] - piCur[n+ 5] - iDeltaC );
    1921       uiSum += abs( piOrg[n+ 6] - piCur[n+ 6] - iDeltaC );
    1922       uiSum += abs( piOrg[n+ 7] - piCur[n+ 7] - iDeltaC );
    1923       uiSum += abs( piOrg[n+ 8] - piCur[n+ 8] - iDeltaC );
    1924       uiSum += abs( piOrg[n+ 9] - piCur[n+ 9] - iDeltaC );
    1925       uiSum += abs( piOrg[n+10] - piCur[n+10] - iDeltaC );
    1926       uiSum += abs( piOrg[n+11] - piCur[n+11] - iDeltaC );
    1927       uiSum += abs( piOrg[n+12] - piCur[n+12] - iDeltaC );
    1928       uiSum += abs( piOrg[n+13] - piCur[n+13] - iDeltaC );
    1929       uiSum += abs( piOrg[n+14] - piCur[n+14] - iDeltaC );
    1930       uiSum += abs( piOrg[n+15] - piCur[n+15] - iDeltaC );
    1931     }
    1932     piOrg += iStrideOrg;
    1933     piCur += iStrideCur;
    1934   }
    1935 
    1936   uiSum <<= iSubShift;
    1937   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    1938 }
    1939 
    1940 UInt TComRdCost::xGetSAD32ic( DistParam* pcDtParam )
    1941 {
    1942   if ( pcDtParam->bApplyWeight )
    1943   {
    1944     return xGetSADw( pcDtParam );
    1945   }
    1946   Pel* piOrg   = pcDtParam->pOrg;
    1947   Pel* piCur   = pcDtParam->pCur;
    1948   Int  iRows   = pcDtParam->iRows;
    1949   Int  iSubShift  = pcDtParam->iSubShift;
    1950   Int  iSubStep   = ( 1 << iSubShift );
    1951   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    1952   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1953 
    1954   UInt uiSum = 0;
    1955 
    1956   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    1957   Int  iDeltaC;
    1958 
    1959   for( ; iRows != 0; iRows-=iSubStep )
    1960   {
    1961     iOrigAvg += piOrg[0];
    1962     iOrigAvg += piOrg[1];
    1963     iOrigAvg += piOrg[2];
    1964     iOrigAvg += piOrg[3];
    1965     iOrigAvg += piOrg[4];
    1966     iOrigAvg += piOrg[5];
    1967     iOrigAvg += piOrg[6];
    1968     iOrigAvg += piOrg[7];
    1969     iOrigAvg += piOrg[8];
    1970     iOrigAvg += piOrg[9];
    1971     iOrigAvg += piOrg[10];
    1972     iOrigAvg += piOrg[11];
    1973     iOrigAvg += piOrg[12];
    1974     iOrigAvg += piOrg[13];
    1975     iOrigAvg += piOrg[14];
    1976     iOrigAvg += piOrg[15];
    1977     iOrigAvg += piOrg[16];
    1978     iOrigAvg += piOrg[17];
    1979     iOrigAvg += piOrg[18];
    1980     iOrigAvg += piOrg[19];
    1981     iOrigAvg += piOrg[20];
    1982     iOrigAvg += piOrg[21];
    1983     iOrigAvg += piOrg[22];
    1984     iOrigAvg += piOrg[23];
    1985     iOrigAvg += piOrg[24];
    1986     iOrigAvg += piOrg[25];
    1987     iOrigAvg += piOrg[26];
    1988     iOrigAvg += piOrg[27];
    1989     iOrigAvg += piOrg[28];
    1990     iOrigAvg += piOrg[29];
    1991     iOrigAvg += piOrg[30];
    1992     iOrigAvg += piOrg[31];
    1993 
    1994     iCurAvg  += piCur[0];
    1995     iCurAvg  += piCur[1];
    1996     iCurAvg  += piCur[2];
    1997     iCurAvg  += piCur[3];
    1998     iCurAvg  += piCur[4];
    1999     iCurAvg  += piCur[5];
    2000     iCurAvg  += piCur[6];
    2001     iCurAvg  += piCur[7];
    2002     iCurAvg  += piCur[8];
    2003     iCurAvg  += piCur[9];
    2004     iCurAvg  += piCur[10];
    2005     iCurAvg  += piCur[11];
    2006     iCurAvg  += piCur[12];
    2007     iCurAvg  += piCur[13];
    2008     iCurAvg  += piCur[14];
    2009     iCurAvg  += piCur[15];
    2010     iCurAvg  += piCur[16];
    2011     iCurAvg  += piCur[17];
    2012     iCurAvg  += piCur[18];
    2013     iCurAvg  += piCur[19];
    2014     iCurAvg  += piCur[20];
    2015     iCurAvg  += piCur[21];
    2016     iCurAvg  += piCur[22];
    2017     iCurAvg  += piCur[23];
    2018     iCurAvg  += piCur[24];
    2019     iCurAvg  += piCur[25];
    2020     iCurAvg  += piCur[26];
    2021     iCurAvg  += piCur[27];
    2022     iCurAvg  += piCur[28];
    2023     iCurAvg  += piCur[29];
    2024     iCurAvg  += piCur[30];
    2025     iCurAvg  += piCur[31];
    2026 
    2027     piOrg += iStrideOrg;
    2028     piCur += iStrideCur;
    2029     uiRowCnt++;
    2030   }
    2031 
    2032   piOrg   = pcDtParam->pOrg;
    2033   piCur   = pcDtParam->pCur;
    2034   iRows   = pcDtParam->iRows;
    2035 
    2036   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/32) : 0;
    2037 
    2038   for( ; iRows != 0; iRows-=iSubStep )
    2039   {
    2040     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    2041     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    2042     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    2043     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    2044     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    2045     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    2046     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    2047     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    2048     uiSum += abs( piOrg[8] - piCur[8] - iDeltaC );
    2049     uiSum += abs( piOrg[9] - piCur[9] - iDeltaC );
    2050     uiSum += abs( piOrg[10] - piCur[10] - iDeltaC );
    2051     uiSum += abs( piOrg[11] - piCur[11] - iDeltaC );
    2052     uiSum += abs( piOrg[12] - piCur[12] - iDeltaC );
    2053     uiSum += abs( piOrg[13] - piCur[13] - iDeltaC );
    2054     uiSum += abs( piOrg[14] - piCur[14] - iDeltaC );
    2055     uiSum += abs( piOrg[15] - piCur[15] - iDeltaC );
    2056     uiSum += abs( piOrg[16] - piCur[16] - iDeltaC );
    2057     uiSum += abs( piOrg[17] - piCur[17] - iDeltaC );
    2058     uiSum += abs( piOrg[18] - piCur[18] - iDeltaC );
    2059     uiSum += abs( piOrg[19] - piCur[19] - iDeltaC );
    2060     uiSum += abs( piOrg[20] - piCur[20] - iDeltaC );
    2061     uiSum += abs( piOrg[21] - piCur[21] - iDeltaC );
    2062     uiSum += abs( piOrg[22] - piCur[22] - iDeltaC );
    2063     uiSum += abs( piOrg[23] - piCur[23] - iDeltaC );
    2064     uiSum += abs( piOrg[24] - piCur[24] - iDeltaC );
    2065     uiSum += abs( piOrg[25] - piCur[25] - iDeltaC );
    2066     uiSum += abs( piOrg[26] - piCur[26] - iDeltaC );
    2067     uiSum += abs( piOrg[27] - piCur[27] - iDeltaC );
    2068     uiSum += abs( piOrg[28] - piCur[28] - iDeltaC );
    2069     uiSum += abs( piOrg[29] - piCur[29] - iDeltaC );
    2070     uiSum += abs( piOrg[30] - piCur[30] - iDeltaC );
    2071     uiSum += abs( piOrg[31] - piCur[31] - iDeltaC );
    2072 
    2073     piOrg += iStrideOrg;
    2074     piCur += iStrideCur;
    2075   }
    2076 
    2077   uiSum <<= iSubShift;
    2078   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    2079 }
    2080 
    2081 #if AMP_SAD
    2082 UInt TComRdCost::xGetSAD24ic( DistParam* pcDtParam )
    2083 {
    2084   if ( pcDtParam->bApplyWeight )
    2085   {
    2086     return xGetSADw( pcDtParam );
    2087   }
    2088   Pel* piOrg   = pcDtParam->pOrg;
    2089   Pel* piCur   = pcDtParam->pCur;
    2090   Int  iRows   = pcDtParam->iRows;
    2091   Int  iSubShift  = pcDtParam->iSubShift;
    2092   Int  iSubStep   = ( 1 << iSubShift );
    2093   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    2094   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    2095 
    2096   UInt uiSum = 0;
    2097 
    2098   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    2099   Int  iDeltaC;
    2100 
    2101   for( ; iRows != 0; iRows-=iSubStep )
    2102   {
    2103     iOrigAvg += piOrg[0];
    2104     iOrigAvg += piOrg[1];
    2105     iOrigAvg += piOrg[2];
    2106     iOrigAvg += piOrg[3];
    2107     iOrigAvg += piOrg[4];
    2108     iOrigAvg += piOrg[5];
    2109     iOrigAvg += piOrg[6];
    2110     iOrigAvg += piOrg[7];
    2111     iOrigAvg += piOrg[8];
    2112     iOrigAvg += piOrg[9];
    2113     iOrigAvg += piOrg[10];
    2114     iOrigAvg += piOrg[11];
    2115     iOrigAvg += piOrg[12];
    2116     iOrigAvg += piOrg[13];
    2117     iOrigAvg += piOrg[14];
    2118     iOrigAvg += piOrg[15];
    2119     iOrigAvg += piOrg[16];
    2120     iOrigAvg += piOrg[17];
    2121     iOrigAvg += piOrg[18];
    2122     iOrigAvg += piOrg[19];
    2123     iOrigAvg += piOrg[20];
    2124     iOrigAvg += piOrg[21];
    2125     iOrigAvg += piOrg[22];
    2126     iOrigAvg += piOrg[23];
    2127 
    2128     iCurAvg  += piCur[0];
    2129     iCurAvg  += piCur[1];
    2130     iCurAvg  += piCur[2];
    2131     iCurAvg  += piCur[3];
    2132     iCurAvg  += piCur[4];
    2133     iCurAvg  += piCur[5];
    2134     iCurAvg  += piCur[6];
    2135     iCurAvg  += piCur[7];
    2136     iCurAvg  += piCur[8];
    2137     iCurAvg  += piCur[9];
    2138     iCurAvg  += piCur[10];
    2139     iCurAvg  += piCur[11];
    2140     iCurAvg  += piCur[12];
    2141     iCurAvg  += piCur[13];
    2142     iCurAvg  += piCur[14];
    2143     iCurAvg  += piCur[15];
    2144     iCurAvg  += piCur[16];
    2145     iCurAvg  += piCur[17];
    2146     iCurAvg  += piCur[18];
    2147     iCurAvg  += piCur[19];
    2148     iCurAvg  += piCur[20];
    2149     iCurAvg  += piCur[21];
    2150     iCurAvg  += piCur[22];
    2151     iCurAvg  += piCur[23];
    2152 
    2153     piOrg += iStrideOrg;
    2154     piCur += iStrideCur;
    2155     uiRowCnt++;
    2156   }
    2157 
    2158   piOrg   = pcDtParam->pOrg;
    2159   piCur   = pcDtParam->pCur;
    2160   iRows   = pcDtParam->iRows;
    2161 
    2162   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/24) : 0;
    2163 
    2164   for( ; iRows != 0; iRows-=iSubStep )
    2165   {
    2166     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    2167     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    2168     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    2169     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    2170     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    2171     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    2172     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    2173     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    2174     uiSum += abs( piOrg[8] - piCur[8] - iDeltaC );
    2175     uiSum += abs( piOrg[9] - piCur[9] - iDeltaC );
    2176     uiSum += abs( piOrg[10] - piCur[10] - iDeltaC );
    2177     uiSum += abs( piOrg[11] - piCur[11] - iDeltaC );
    2178     uiSum += abs( piOrg[12] - piCur[12] - iDeltaC );
    2179     uiSum += abs( piOrg[13] - piCur[13] - iDeltaC );
    2180     uiSum += abs( piOrg[14] - piCur[14] - iDeltaC );
    2181     uiSum += abs( piOrg[15] - piCur[15] - iDeltaC );
    2182     uiSum += abs( piOrg[16] - piCur[16] - iDeltaC );
    2183     uiSum += abs( piOrg[17] - piCur[17] - iDeltaC );
    2184     uiSum += abs( piOrg[18] - piCur[18] - iDeltaC );
    2185     uiSum += abs( piOrg[19] - piCur[19] - iDeltaC );
    2186     uiSum += abs( piOrg[20] - piCur[20] - iDeltaC );
    2187     uiSum += abs( piOrg[21] - piCur[21] - iDeltaC );
    2188     uiSum += abs( piOrg[22] - piCur[22] - iDeltaC );
    2189     uiSum += abs( piOrg[23] - piCur[23] - iDeltaC );
    2190 
    2191     piOrg += iStrideOrg;
    2192     piCur += iStrideCur;
    2193   }
    2194 
    2195   uiSum <<= iSubShift;
    2196   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    2197 }
    2198 #endif
    2199 
    2200 UInt TComRdCost::xGetSAD64ic( DistParam* pcDtParam )
    2201 {
    2202   if ( pcDtParam->bApplyWeight )
    2203   {
    2204     return xGetSADw( pcDtParam );
    2205   }
    2206   Pel* piOrg   = pcDtParam->pOrg;
    2207   Pel* piCur   = pcDtParam->pCur;
    2208   Int  iRows   = pcDtParam->iRows;
    2209   Int  iSubShift  = pcDtParam->iSubShift;
    2210   Int  iSubStep   = ( 1 << iSubShift );
    2211   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    2212   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    2213 
    2214   UInt uiSum = 0;
    2215 
    2216   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    2217   Int  iDeltaC;
    2218 
    2219   for( ; iRows != 0; iRows-=iSubStep )
    2220   {
    2221     iOrigAvg += piOrg[0] ;
    2222     iOrigAvg += piOrg[1] ;
    2223     iOrigAvg += piOrg[2] ;
    2224     iOrigAvg += piOrg[3] ;
    2225     iOrigAvg += piOrg[4] ;
    2226     iOrigAvg += piOrg[5] ;
    2227     iOrigAvg += piOrg[6] ;
    2228     iOrigAvg += piOrg[7] ;
    2229     iOrigAvg += piOrg[8] ;
    2230     iOrigAvg += piOrg[9] ;
    2231     iOrigAvg += piOrg[10] ;
    2232     iOrigAvg += piOrg[11] ;
    2233     iOrigAvg += piOrg[12] ;
    2234     iOrigAvg += piOrg[13] ;
    2235     iOrigAvg += piOrg[14] ;
    2236     iOrigAvg += piOrg[15] ;
    2237     iOrigAvg += piOrg[16] ;
    2238     iOrigAvg += piOrg[17] ;
    2239     iOrigAvg += piOrg[18] ;
    2240     iOrigAvg += piOrg[19] ;
    2241     iOrigAvg += piOrg[20] ;
    2242     iOrigAvg += piOrg[21] ;
    2243     iOrigAvg += piOrg[22] ;
    2244     iOrigAvg += piOrg[23] ;
    2245     iOrigAvg += piOrg[24] ;
    2246     iOrigAvg += piOrg[25] ;
    2247     iOrigAvg += piOrg[26] ;
    2248     iOrigAvg += piOrg[27] ;
    2249     iOrigAvg += piOrg[28] ;
    2250     iOrigAvg += piOrg[29] ;
    2251     iOrigAvg += piOrg[30] ;
    2252     iOrigAvg += piOrg[31] ;
    2253     iOrigAvg += piOrg[32] ;
    2254     iOrigAvg += piOrg[33] ;
    2255     iOrigAvg += piOrg[34] ;
    2256     iOrigAvg += piOrg[35] ;
    2257     iOrigAvg += piOrg[36] ;
    2258     iOrigAvg += piOrg[37] ;
    2259     iOrigAvg += piOrg[38] ;
    2260     iOrigAvg += piOrg[39] ;
    2261     iOrigAvg += piOrg[40] ;
    2262     iOrigAvg += piOrg[41] ;
    2263     iOrigAvg += piOrg[42] ;
    2264     iOrigAvg += piOrg[43] ;
    2265     iOrigAvg += piOrg[44] ;
    2266     iOrigAvg += piOrg[45] ;
    2267     iOrigAvg += piOrg[46] ;
    2268     iOrigAvg += piOrg[47] ;
    2269     iOrigAvg += piOrg[48] ;
    2270     iOrigAvg += piOrg[49] ;
    2271     iOrigAvg += piOrg[50] ;
    2272     iOrigAvg += piOrg[51] ;
    2273     iOrigAvg += piOrg[52] ;
    2274     iOrigAvg += piOrg[53] ;
    2275     iOrigAvg += piOrg[54] ;
    2276     iOrigAvg += piOrg[55] ;
    2277     iOrigAvg += piOrg[56] ;
    2278     iOrigAvg += piOrg[57] ;
    2279     iOrigAvg += piOrg[58] ;
    2280     iOrigAvg += piOrg[59] ;
    2281     iOrigAvg += piOrg[60] ;
    2282     iOrigAvg += piOrg[61] ;
    2283     iOrigAvg += piOrg[62] ;
    2284     iOrigAvg += piOrg[63] ;
    2285 
    2286     iCurAvg += piCur[0] ;
    2287     iCurAvg += piCur[1] ;
    2288     iCurAvg += piCur[2] ;
    2289     iCurAvg += piCur[3] ;
    2290     iCurAvg += piCur[4] ;
    2291     iCurAvg += piCur[5] ;
    2292     iCurAvg += piCur[6] ;
    2293     iCurAvg += piCur[7] ;
    2294     iCurAvg += piCur[8] ;
    2295     iCurAvg += piCur[9] ;
    2296     iCurAvg += piCur[10] ;
    2297     iCurAvg += piCur[11] ;
    2298     iCurAvg += piCur[12] ;
    2299     iCurAvg += piCur[13] ;
    2300     iCurAvg += piCur[14] ;
    2301     iCurAvg += piCur[15] ;
    2302     iCurAvg += piCur[16] ;
    2303     iCurAvg += piCur[17] ;
    2304     iCurAvg += piCur[18] ;
    2305     iCurAvg += piCur[19] ;
    2306     iCurAvg += piCur[20] ;
    2307     iCurAvg += piCur[21] ;
    2308     iCurAvg += piCur[22] ;
    2309     iCurAvg += piCur[23] ;
    2310     iCurAvg += piCur[24] ;
    2311     iCurAvg += piCur[25] ;
    2312     iCurAvg += piCur[26] ;
    2313     iCurAvg += piCur[27] ;
    2314     iCurAvg += piCur[28] ;
    2315     iCurAvg += piCur[29] ;
    2316     iCurAvg += piCur[30] ;
    2317     iCurAvg += piCur[31] ;
    2318     iCurAvg += piCur[32] ;
    2319     iCurAvg += piCur[33] ;
    2320     iCurAvg += piCur[34] ;
    2321     iCurAvg += piCur[35] ;
    2322     iCurAvg += piCur[36] ;
    2323     iCurAvg += piCur[37] ;
    2324     iCurAvg += piCur[38] ;
    2325     iCurAvg += piCur[39] ;
    2326     iCurAvg += piCur[40] ;
    2327     iCurAvg += piCur[41] ;
    2328     iCurAvg += piCur[42] ;
    2329     iCurAvg += piCur[43] ;
    2330     iCurAvg += piCur[44] ;
    2331     iCurAvg += piCur[45] ;
    2332     iCurAvg += piCur[46] ;
    2333     iCurAvg += piCur[47] ;
    2334     iCurAvg += piCur[48] ;
    2335     iCurAvg += piCur[49] ;
    2336     iCurAvg += piCur[50] ;
    2337     iCurAvg += piCur[51] ;
    2338     iCurAvg += piCur[52] ;
    2339     iCurAvg += piCur[53] ;
    2340     iCurAvg += piCur[54] ;
    2341     iCurAvg += piCur[55] ;
    2342     iCurAvg += piCur[56] ;
    2343     iCurAvg += piCur[57] ;
    2344     iCurAvg += piCur[58] ;
    2345     iCurAvg += piCur[59] ;
    2346     iCurAvg += piCur[60] ;
    2347     iCurAvg += piCur[61] ;
    2348     iCurAvg += piCur[62] ;
    2349     iCurAvg += piCur[63] ;
    2350 
    2351     piOrg += iStrideOrg;
    2352     piCur += iStrideCur;
    2353     uiRowCnt++;
    2354   }
    2355 
    2356   piOrg   = pcDtParam->pOrg;
    2357   piCur   = pcDtParam->pCur;
    2358   iRows   = pcDtParam->iRows;
    2359 
    2360   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/64) : 0;
    2361 
    2362   for( ; iRows != 0; iRows-=iSubStep )
    2363   {
    2364     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    2365     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    2366     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    2367     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    2368     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    2369     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    2370     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    2371     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    2372     uiSum += abs( piOrg[8] - piCur[8] - iDeltaC );
    2373     uiSum += abs( piOrg[9] - piCur[9] - iDeltaC );
    2374     uiSum += abs( piOrg[10] - piCur[10] - iDeltaC );
    2375     uiSum += abs( piOrg[11] - piCur[11] - iDeltaC );
    2376     uiSum += abs( piOrg[12] - piCur[12] - iDeltaC );
    2377     uiSum += abs( piOrg[13] - piCur[13] - iDeltaC );
    2378     uiSum += abs( piOrg[14] - piCur[14] - iDeltaC );
    2379     uiSum += abs( piOrg[15] - piCur[15] - iDeltaC );
    2380     uiSum += abs( piOrg[16] - piCur[16] - iDeltaC );
    2381     uiSum += abs( piOrg[17] - piCur[17] - iDeltaC );
    2382     uiSum += abs( piOrg[18] - piCur[18] - iDeltaC );
    2383     uiSum += abs( piOrg[19] - piCur[19] - iDeltaC );
    2384     uiSum += abs( piOrg[20] - piCur[20] - iDeltaC );
    2385     uiSum += abs( piOrg[21] - piCur[21] - iDeltaC );
    2386     uiSum += abs( piOrg[22] - piCur[22] - iDeltaC );
    2387     uiSum += abs( piOrg[23] - piCur[23] - iDeltaC );
    2388     uiSum += abs( piOrg[24] - piCur[24] - iDeltaC );
    2389     uiSum += abs( piOrg[25] - piCur[25] - iDeltaC );
    2390     uiSum += abs( piOrg[26] - piCur[26] - iDeltaC );
    2391     uiSum += abs( piOrg[27] - piCur[27] - iDeltaC );
    2392     uiSum += abs( piOrg[28] - piCur[28] - iDeltaC );
    2393     uiSum += abs( piOrg[29] - piCur[29] - iDeltaC );
    2394     uiSum += abs( piOrg[30] - piCur[30] - iDeltaC );
    2395     uiSum += abs( piOrg[31] - piCur[31] - iDeltaC );
    2396     uiSum += abs( piOrg[32] - piCur[32] - iDeltaC );
    2397     uiSum += abs( piOrg[33] - piCur[33] - iDeltaC );
    2398     uiSum += abs( piOrg[34] - piCur[34] - iDeltaC );
    2399     uiSum += abs( piOrg[35] - piCur[35] - iDeltaC );
    2400     uiSum += abs( piOrg[36] - piCur[36] - iDeltaC );
    2401     uiSum += abs( piOrg[37] - piCur[37] - iDeltaC );
    2402     uiSum += abs( piOrg[38] - piCur[38] - iDeltaC );
    2403     uiSum += abs( piOrg[39] - piCur[39] - iDeltaC );
    2404     uiSum += abs( piOrg[40] - piCur[40] - iDeltaC );
    2405     uiSum += abs( piOrg[41] - piCur[41] - iDeltaC );
    2406     uiSum += abs( piOrg[42] - piCur[42] - iDeltaC );
    2407     uiSum += abs( piOrg[43] - piCur[43] - iDeltaC );
    2408     uiSum += abs( piOrg[44] - piCur[44] - iDeltaC );
    2409     uiSum += abs( piOrg[45] - piCur[45] - iDeltaC );
    2410     uiSum += abs( piOrg[46] - piCur[46] - iDeltaC );
    2411     uiSum += abs( piOrg[47] - piCur[47] - iDeltaC );
    2412     uiSum += abs( piOrg[48] - piCur[48] - iDeltaC );
    2413     uiSum += abs( piOrg[49] - piCur[49] - iDeltaC );
    2414     uiSum += abs( piOrg[50] - piCur[50] - iDeltaC );
    2415     uiSum += abs( piOrg[51] - piCur[51] - iDeltaC );
    2416     uiSum += abs( piOrg[52] - piCur[52] - iDeltaC );
    2417     uiSum += abs( piOrg[53] - piCur[53] - iDeltaC );
    2418     uiSum += abs( piOrg[54] - piCur[54] - iDeltaC );
    2419     uiSum += abs( piOrg[55] - piCur[55] - iDeltaC );
    2420     uiSum += abs( piOrg[56] - piCur[56] - iDeltaC );
    2421     uiSum += abs( piOrg[57] - piCur[57] - iDeltaC );
    2422     uiSum += abs( piOrg[58] - piCur[58] - iDeltaC );
    2423     uiSum += abs( piOrg[59] - piCur[59] - iDeltaC );
    2424     uiSum += abs( piOrg[60] - piCur[60] - iDeltaC );
    2425     uiSum += abs( piOrg[61] - piCur[61] - iDeltaC );
    2426     uiSum += abs( piOrg[62] - piCur[62] - iDeltaC );
    2427     uiSum += abs( piOrg[63] - piCur[63] - iDeltaC );
    2428 
    2429     piOrg += iStrideOrg;
    2430     piCur += iStrideCur;
    2431   }
    2432 
    2433   uiSum <<= iSubShift;
    2434   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    2435 }
    2436 
    2437 #if AMP_SAD
    2438 UInt TComRdCost::xGetSAD48ic( DistParam* pcDtParam )
    2439 {
    2440   if ( pcDtParam->bApplyWeight )
    2441   {
    2442     return xGetSADw( pcDtParam );
    2443   }
    2444 
    2445   Pel* piOrg   = pcDtParam->pOrg;
    2446   Pel* piCur   = pcDtParam->pCur;
    2447   Int  iRows   = pcDtParam->iRows;
    2448   Int  iSubShift  = pcDtParam->iSubShift;
    2449   Int  iSubStep   = ( 1 << iSubShift );
    2450   Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    2451   Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    2452 
    2453   UInt uiSum = 0;
    2454 
    2455   Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    2456   Int  iDeltaC;
    2457 
    2458   for( ; iRows != 0; iRows-=iSubStep )
    2459   {
    2460     iOrigAvg += piOrg[0] ;
    2461     iOrigAvg += piOrg[1] ;
    2462     iOrigAvg += piOrg[2] ;
    2463     iOrigAvg += piOrg[3] ;
    2464     iOrigAvg += piOrg[4] ;
    2465     iOrigAvg += piOrg[5] ;
    2466     iOrigAvg += piOrg[6] ;
    2467     iOrigAvg += piOrg[7] ;
    2468     iOrigAvg += piOrg[8] ;
    2469     iOrigAvg += piOrg[9] ;
    2470     iOrigAvg += piOrg[10] ;
    2471     iOrigAvg += piOrg[11] ;
    2472     iOrigAvg += piOrg[12] ;
    2473     iOrigAvg += piOrg[13] ;
    2474     iOrigAvg += piOrg[14] ;
    2475     iOrigAvg += piOrg[15] ;
    2476     iOrigAvg += piOrg[16] ;
    2477     iOrigAvg += piOrg[17] ;
    2478     iOrigAvg += piOrg[18] ;
    2479     iOrigAvg += piOrg[19] ;
    2480     iOrigAvg += piOrg[20] ;
    2481     iOrigAvg += piOrg[21] ;
    2482     iOrigAvg += piOrg[22] ;
    2483     iOrigAvg += piOrg[23] ;
    2484     iOrigAvg += piOrg[24] ;
    2485     iOrigAvg += piOrg[25] ;
    2486     iOrigAvg += piOrg[26] ;
    2487     iOrigAvg += piOrg[27] ;
    2488     iOrigAvg += piOrg[28] ;
    2489     iOrigAvg += piOrg[29] ;
    2490     iOrigAvg += piOrg[30] ;
    2491     iOrigAvg += piOrg[31] ;
    2492     iOrigAvg += piOrg[32] ;
    2493     iOrigAvg += piOrg[33] ;
    2494     iOrigAvg += piOrg[34] ;
    2495     iOrigAvg += piOrg[35] ;
    2496     iOrigAvg += piOrg[36] ;
    2497     iOrigAvg += piOrg[37] ;
    2498     iOrigAvg += piOrg[38] ;
    2499     iOrigAvg += piOrg[39] ;
    2500     iOrigAvg += piOrg[40] ;
    2501     iOrigAvg += piOrg[41] ;
    2502     iOrigAvg += piOrg[42] ;
    2503     iOrigAvg += piOrg[43] ;
    2504     iOrigAvg += piOrg[44] ;
    2505     iOrigAvg += piOrg[45] ;
    2506     iOrigAvg += piOrg[46] ;
    2507     iOrigAvg += piOrg[47] ;
    2508 
    2509     iCurAvg += piCur[0] ;
    2510     iCurAvg += piCur[1] ;
    2511     iCurAvg += piCur[2] ;
    2512     iCurAvg += piCur[3] ;
    2513     iCurAvg += piCur[4] ;
    2514     iCurAvg += piCur[5] ;
    2515     iCurAvg += piCur[6] ;
    2516     iCurAvg += piCur[7] ;
    2517     iCurAvg += piCur[8] ;
    2518     iCurAvg += piCur[9] ;
    2519     iCurAvg += piCur[10] ;
    2520     iCurAvg += piCur[11] ;
    2521     iCurAvg += piCur[12] ;
    2522     iCurAvg += piCur[13] ;
    2523     iCurAvg += piCur[14] ;
    2524     iCurAvg += piCur[15] ;
    2525     iCurAvg += piCur[16] ;
    2526     iCurAvg += piCur[17] ;
    2527     iCurAvg += piCur[18] ;
    2528     iCurAvg += piCur[19] ;
    2529     iCurAvg += piCur[20] ;
    2530     iCurAvg += piCur[21] ;
    2531     iCurAvg += piCur[22] ;
    2532     iCurAvg += piCur[23] ;
    2533     iCurAvg += piCur[24] ;
    2534     iCurAvg += piCur[25] ;
    2535     iCurAvg += piCur[26] ;
    2536     iCurAvg += piCur[27] ;
    2537     iCurAvg += piCur[28] ;
    2538     iCurAvg += piCur[29] ;
    2539     iCurAvg += piCur[30] ;
    2540     iCurAvg += piCur[31] ;
    2541     iCurAvg += piCur[32] ;
    2542     iCurAvg += piCur[33] ;
    2543     iCurAvg += piCur[34] ;
    2544     iCurAvg += piCur[35] ;
    2545     iCurAvg += piCur[36] ;
    2546     iCurAvg += piCur[37] ;
    2547     iCurAvg += piCur[38] ;
    2548     iCurAvg += piCur[39] ;
    2549     iCurAvg += piCur[40] ;
    2550     iCurAvg += piCur[41] ;
    2551     iCurAvg += piCur[42] ;
    2552     iCurAvg += piCur[43] ;
    2553     iCurAvg += piCur[44] ;
    2554     iCurAvg += piCur[45] ;
    2555     iCurAvg += piCur[46] ;
    2556     iCurAvg += piCur[47] ;
    2557 
    2558     piOrg += iStrideOrg;
    2559     piCur += iStrideCur;
    2560     uiRowCnt++;
    2561   }
    2562 
    2563   piOrg   = pcDtParam->pOrg;
    2564   piCur   = pcDtParam->pCur;
    2565   iRows   = pcDtParam->iRows;
    2566 
    2567   iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/48) : 0;
    2568 
    2569   for( ; iRows != 0; iRows-=iSubStep )
    2570   {
    2571     uiSum += abs( piOrg[0] - piCur[0] - iDeltaC );
    2572     uiSum += abs( piOrg[1] - piCur[1] - iDeltaC );
    2573     uiSum += abs( piOrg[2] - piCur[2] - iDeltaC );
    2574     uiSum += abs( piOrg[3] - piCur[3] - iDeltaC );
    2575     uiSum += abs( piOrg[4] - piCur[4] - iDeltaC );
    2576     uiSum += abs( piOrg[5] - piCur[5] - iDeltaC );
    2577     uiSum += abs( piOrg[6] - piCur[6] - iDeltaC );
    2578     uiSum += abs( piOrg[7] - piCur[7] - iDeltaC );
    2579     uiSum += abs( piOrg[8] - piCur[8] - iDeltaC );
    2580     uiSum += abs( piOrg[9] - piCur[9] - iDeltaC );
    2581     uiSum += abs( piOrg[10] - piCur[10] - iDeltaC );
    2582     uiSum += abs( piOrg[11] - piCur[11] - iDeltaC );
    2583     uiSum += abs( piOrg[12] - piCur[12] - iDeltaC );
    2584     uiSum += abs( piOrg[13] - piCur[13] - iDeltaC );
    2585     uiSum += abs( piOrg[14] - piCur[14] - iDeltaC );
    2586     uiSum += abs( piOrg[15] - piCur[15] - iDeltaC );
    2587     uiSum += abs( piOrg[16] - piCur[16] - iDeltaC );
    2588     uiSum += abs( piOrg[17] - piCur[17] - iDeltaC );
    2589     uiSum += abs( piOrg[18] - piCur[18] - iDeltaC );
    2590     uiSum += abs( piOrg[19] - piCur[19] - iDeltaC );
    2591     uiSum += abs( piOrg[20] - piCur[20] - iDeltaC );
    2592     uiSum += abs( piOrg[21] - piCur[21] - iDeltaC );
    2593     uiSum += abs( piOrg[22] - piCur[22] - iDeltaC );
    2594     uiSum += abs( piOrg[23] - piCur[23] - iDeltaC );
    2595     uiSum += abs( piOrg[24] - piCur[24] - iDeltaC );
    2596     uiSum += abs( piOrg[25] - piCur[25] - iDeltaC );
    2597     uiSum += abs( piOrg[26] - piCur[26] - iDeltaC );
    2598     uiSum += abs( piOrg[27] - piCur[27] - iDeltaC );
    2599     uiSum += abs( piOrg[28] - piCur[28] - iDeltaC );
    2600     uiSum += abs( piOrg[29] - piCur[29] - iDeltaC );
    2601     uiSum += abs( piOrg[30] - piCur[30] - iDeltaC );
    2602     uiSum += abs( piOrg[31] - piCur[31] - iDeltaC );
    2603     uiSum += abs( piOrg[32] - piCur[32] - iDeltaC );
    2604     uiSum += abs( piOrg[33] - piCur[33] - iDeltaC );
    2605     uiSum += abs( piOrg[34] - piCur[34] - iDeltaC );
    2606     uiSum += abs( piOrg[35] - piCur[35] - iDeltaC );
    2607     uiSum += abs( piOrg[36] - piCur[36] - iDeltaC );
    2608     uiSum += abs( piOrg[37] - piCur[37] - iDeltaC );
    2609     uiSum += abs( piOrg[38] - piCur[38] - iDeltaC );
    2610     uiSum += abs( piOrg[39] - piCur[39] - iDeltaC );
    2611     uiSum += abs( piOrg[40] - piCur[40] - iDeltaC );
    2612     uiSum += abs( piOrg[41] - piCur[41] - iDeltaC );
    2613     uiSum += abs( piOrg[42] - piCur[42] - iDeltaC );
    2614     uiSum += abs( piOrg[43] - piCur[43] - iDeltaC );
    2615     uiSum += abs( piOrg[44] - piCur[44] - iDeltaC );
    2616     uiSum += abs( piOrg[45] - piCur[45] - iDeltaC );
    2617     uiSum += abs( piOrg[46] - piCur[46] - iDeltaC );
    2618     uiSum += abs( piOrg[47] - piCur[47] - iDeltaC );
    2619 
    2620     piOrg += iStrideOrg;
    2621     piCur += iStrideCur;
    2622   }
    2623 
    2624   uiSum <<= iSubShift;
    2625   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    2626 }
    2627 #endif
    2628 
    2629 #endif
    2630967// --------------------------------------------------------------------------------------------------------------------
    2631968// SSE
     
    29751312  return ( uiSum );
    29761313}
    2977 #if H_3D_VSO
    2978 //SAIT_VSO_EST_A0033
    2979 UInt TComRdCost::getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride,  Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y )
    2980 {
    2981   Double dD;
    2982   Int iTemp;
    2983 
    2984   dD = ( (Double) ( dDM >> DISTORTION_PRECISION_ADJUSTMENT( g_bitDepthY - 8 ) ) ) * m_dDisparityCoeff;
    2985 
    2986   Double dDepthWeight = ( pOrg[x] >=  ( (1<<(g_bitDepthY - 3)) + (1<<(g_bitDepthY - 2)) ) ? 4 : pOrg[x] > ((1<<g_bitDepthY) >> 4) ? (Float)(pOrg[x] - ((1<<g_bitDepthY) >> 4))/(Float)((1<<g_bitDepthY) >> 3) + 1 : 1.0 );
    2987   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 ] ) ) );
    2988   iTemp = (Int) (((dTemp) < 0)? (Int)((dTemp) - 0.5) : (Int)((dTemp) + 0.5));
    2989 
    2990   return (UInt) ( (iTemp*iTemp)>>1 );
    2991 }
    2992 
    2993 UInt TComRdCost::xGetVSD( DistParam* pcDtParam )
    2994 {
    2995   Pel* piOrg    = pcDtParam->pOrg;
    2996   Pel* piCur    = pcDtParam->pCur;
    2997   Pel* piVirRec = pcDtParam->pVirRec;
    2998   Pel* piVirOrg = pcDtParam->pVirOrg;
    2999   Int  iRows    = pcDtParam->iRows;
    3000   Int  iCols    = pcDtParam->iCols;
    3001   Int  iStrideOrg = pcDtParam->iStrideOrg;
    3002   Int  iStrideCur = pcDtParam->iStrideCur;
    3003   Int  iStrideVir = pcDtParam->iStrideVir;
    3004 
    3005   UInt uiSum = 0;
    3006   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    3007 
    3008   Int dDM;
    3009 
    3010   for ( Int y = 0 ; y < iRows ; y++ )
    3011   {
    3012     for (Int x = 0; x < iCols; x++ )
    3013     {
    3014       dDM = (Int) ( piOrg[x  ] - piCur[x  ] );
    3015       uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
    3016     }
    3017     piOrg += iStrideOrg;
    3018     piCur += iStrideCur;
    3019   }
    3020 
    3021   return ( uiSum );
    3022 }
    3023 
    3024 UInt TComRdCost::xGetVSD4( DistParam* pcDtParam )
    3025 {
    3026   Pel* piOrg   = pcDtParam->pOrg;
    3027   Pel* piCur   = pcDtParam->pCur;
    3028   Pel* piVirRec = pcDtParam->pVirRec;
    3029   Pel* piVirOrg = pcDtParam->pVirOrg;
    3030   Int  iRows   = pcDtParam->iRows;
    3031   Int  iStrideOrg = pcDtParam->iStrideOrg;
    3032   Int  iStrideCur = pcDtParam->iStrideCur;
    3033   Int  iStrideVir = pcDtParam->iStrideVir;
    3034 
    3035   UInt uiSum = 0;
    3036   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    3037 
    3038   Int dDM;
    3039 
    3040   for ( Int y = 0 ; y < iRows ; y++ )
    3041   {
    3042     dDM = (Int) ( piOrg[0] - piCur[0] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 0, y ) ) >> uiShift;
    3043     dDM = (Int) ( piOrg[1] - piCur[1] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 1, y ) ) >> uiShift;
    3044     dDM = (Int) ( piOrg[2] - piCur[2] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 2, y ) ) >> uiShift;
    3045     dDM = (Int) ( piOrg[3] - piCur[3] );  uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 3, y ) ) >> uiShift;
    3046 
    3047     piOrg += iStrideOrg;
    3048     piCur += iStrideCur;
    3049   }
    3050 
    3051   return ( uiSum );
    3052 }
    3053 
    3054 UInt TComRdCost::xGetVSD8( DistParam* pcDtParam )
    3055 {
    3056   Pel* piOrg   = pcDtParam->pOrg;
    3057   Pel* piCur   = pcDtParam->pCur;
    3058   Pel* piVirRec = pcDtParam->pVirRec;
    3059   Pel* piVirOrg = pcDtParam->pVirOrg;
    3060   Int  iRows   = pcDtParam->iRows;
    3061   Int  iStrideOrg = pcDtParam->iStrideOrg;
    3062   Int  iStrideCur = pcDtParam->iStrideCur;
    3063   Int  iStrideVir = pcDtParam->iStrideVir;
    3064 
    3065   UInt uiSum = 0;
    3066   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    3067 
    3068   Int dDM;
    3069 
    3070   for ( Int y = 0 ; y < iRows ; y++ )
    3071   {
    3072     for (Int x = 0; x < 8; x++ )
    3073     {
    3074       dDM = (Int) ( piOrg[x] - piCur[x] );
    3075       uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
    3076     }
    3077     piOrg += iStrideOrg;
    3078     piCur += iStrideCur;
    3079   }
    3080 
    3081   return ( uiSum );
    3082 }
    3083 
    3084 UInt TComRdCost::xGetVSD16( DistParam* pcDtParam )
    3085 {
    3086   Pel* piOrg   = pcDtParam->pOrg;
    3087   Pel* piCur   = pcDtParam->pCur;
    3088   Pel* piVirRec = pcDtParam->pVirRec;
    3089   Pel* piVirOrg = pcDtParam->pVirOrg;
    3090   Int  iRows   = pcDtParam->iRows;
    3091   Int  iStrideOrg = pcDtParam->iStrideOrg;
    3092   Int  iStrideCur = pcDtParam->iStrideCur;
    3093   Int  iStrideVir = pcDtParam->iStrideVir;
    3094 
    3095   UInt uiSum = 0;
    3096   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    3097 
    3098   Int dDM;
    3099 
    3100   for ( Int y = 0 ; y < iRows ; y++ )
    3101   {
    3102     for (Int x = 0; x < 16; x++ )
    3103     {
    3104       dDM = (Int) ( piOrg[x] - piCur[x] );
    3105       uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
    3106     }
    3107     piOrg += iStrideOrg;
    3108     piCur += iStrideCur;
    3109   }
    3110 
    3111   return ( uiSum );
    3112 }
    3113 
    3114 UInt TComRdCost::xGetVSD16N( DistParam* pcDtParam )
    3115 {
    3116   Pel* piOrg   = pcDtParam->pOrg;
    3117   Pel* piCur   = pcDtParam->pCur;
    3118   Pel* piVirRec = pcDtParam->pVirRec;
    3119   Pel* piVirOrg = pcDtParam->pVirOrg;
    3120   Int  iRows   = pcDtParam->iRows;
    3121   Int  iCols   = pcDtParam->iCols;
    3122   Int  iStrideOrg = pcDtParam->iStrideOrg;
    3123   Int  iStrideCur = pcDtParam->iStrideCur;
    3124   Int  iStrideVir = pcDtParam->iStrideVir;
    3125 
    3126   UInt uiSum = 0;
    3127   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    3128 
    3129   Int dDM;
    3130 
    3131   for ( Int y = 0 ; y < iRows ; y++ )
    3132   {
    3133     for (Int x = 0; x < iCols; x+=16 )
    3134     {
    3135       for ( Int k = 0 ; k < 16 ; k++ )
    3136       {
    3137         dDM = (Int) ( piOrg[x+k] - piCur[x+k] );
    3138         uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x+k, y ) >> uiShift;
    3139       }
    3140     }
    3141     piOrg += iStrideOrg;
    3142     piCur += iStrideCur;
    3143   }
    3144 
    3145   return ( uiSum );
    3146 }
    3147 
    3148 UInt TComRdCost::xGetVSD32( DistParam* pcDtParam )
    3149 {
    3150   Pel* piOrg   = pcDtParam->pOrg;
    3151   Pel* piCur   = pcDtParam->pCur;
    3152   Pel* piVirRec = pcDtParam->pVirRec;
    3153   Pel* piVirOrg = pcDtParam->pVirOrg;
    3154   Int  iRows   = pcDtParam->iRows;
    3155   Int  iStrideOrg = pcDtParam->iStrideOrg;
    3156   Int  iStrideCur = pcDtParam->iStrideCur;
    3157   Int  iStrideVir = pcDtParam->iStrideVir;
    3158 
    3159   UInt uiSum = 0;
    3160   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    3161 
    3162   Int dDM;
    3163 
    3164   for ( Int y = 0 ; y < iRows ; y++ )
    3165   {
    3166     for (Int x = 0; x < 32 ; x++ )
    3167     {
    3168       dDM = (Int) ( piOrg[x] - piCur[x] );
    3169       uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
    3170     }
    3171     piOrg += iStrideOrg;
    3172     piCur += iStrideCur;
    3173   }
    3174 
    3175   return ( uiSum );
    3176 }
    3177 
    3178 UInt TComRdCost::xGetVSD64( DistParam* pcDtParam )
    3179 {
    3180   Pel* piOrg      = pcDtParam->pOrg;
    3181   Pel* piCur      = pcDtParam->pCur;
    3182   Pel* piVirRec   = pcDtParam->pVirRec;
    3183   Pel* piVirOrg   = pcDtParam->pVirOrg;
    3184   Int  iRows      = pcDtParam->iRows;
    3185   Int  iStrideOrg = pcDtParam->iStrideOrg;
    3186   Int  iStrideCur = pcDtParam->iStrideCur;
    3187   Int  iStrideVir = pcDtParam->iStrideVir;
    3188 
    3189   UInt uiSum = 0;
    3190   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    3191 
    3192   Int dDM;
    3193 
    3194   for ( Int y = 0 ; y < iRows ; y++ )
    3195   {
    3196     for (Int x = 0; x < 64; x++ )
    3197     {
    3198       dDM = (Int) ( piOrg[x] - piCur[x] );
    3199       uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
    3200     }
    3201     piOrg += iStrideOrg;
    3202     piCur += iStrideCur;
    3203   }
    3204 
    3205   return ( uiSum );
    3206 }
    3207 
    3208 #endif
    32091314
    32101315// --------------------------------------------------------------------------------------------------------------------
     
    34931598    return xGetHADsw( pcDtParam );
    34941599  }
    3495 #if H_3D_IC
    3496   if( pcDtParam->bUseIC )
    3497   {
    3498     return xGetHADsic( pcDtParam );
    3499   }
    3500 #endif
    3501 #if H_3D_INTER_SDC
    3502   if( pcDtParam->bUseSDCMRSAD )
    3503   {
    3504     return xGetHADsic( pcDtParam );
    3505   }
    3506 #endif
    35071600  Pel* piOrg   = pcDtParam->pOrg;
    35081601  Pel* piCur   = pcDtParam->pCur;
     
    35681661}
    35691662
    3570 #if H_3D_IC || H_3D_INTER_SDC
    3571 UInt TComRdCost::xGetHADsic( DistParam* pcDtParam )
    3572 {
    3573   if ( pcDtParam->bApplyWeight )
    3574   {
    3575     return xGetHADsw( pcDtParam );
    3576   }
    3577   Pel* piOrg   = pcDtParam->pOrg;
    3578   Pel* piCur   = pcDtParam->pCur;
    3579   Int  iRows   = pcDtParam->iRows;
    3580   Int  iCols   = pcDtParam->iCols;
    3581   Int  iStrideCur = pcDtParam->iStrideCur;
    3582   Int  iStrideOrg = pcDtParam->iStrideOrg;
    3583   Int  iStep  = pcDtParam->iStep;
    3584 
    3585   Int  x, y;
    3586 
    3587   UInt uiSum = 0;
    3588 
    3589   Int  iOrigAvg = 0, iCurAvg = 0;
    3590   Int  iDeltaC;
    3591 
    3592   for ( y=0; y<iRows; y++ )
    3593   {
    3594     for ( x=0; x<iCols; x++ )
    3595     {       
    3596       iOrigAvg += piOrg[x];
    3597       iCurAvg  += piCur[x];
    3598     }
    3599     piOrg += iStrideOrg;
    3600     piCur += iStrideCur;
    3601   }
    3602 
    3603   piOrg   = pcDtParam->pOrg;
    3604   piCur   = pcDtParam->pCur;
    3605 
    3606   iDeltaC = (iOrigAvg - iCurAvg)/iRows/iCols;
    3607 
    3608   for ( y=0; y<iRows; y++ )
    3609   {
    3610     for ( x=0; x<iCols; x++ )
    3611     {       
    3612       piOrg[x] -= iDeltaC;
    3613     }
    3614     piOrg += iStrideOrg;
    3615   }
    3616 
    3617   piOrg   = pcDtParam->pOrg;
    3618 
    3619 #if NS_HAD
    3620   if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) )
    3621 #else
    3622   if( ( iRows % 8 == 0) && (iCols % 8 == 0) )
    3623 #endif
    3624   {
    3625     Int  iOffsetOrg = iStrideOrg<<3;
    3626     Int  iOffsetCur = iStrideCur<<3;
    3627     for ( y=0; y<iRows; y+= 8 )
    3628     {
    3629       for ( x=0; x<iCols; x+= 8 )
    3630       {
    3631         uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3632       }
    3633       piOrg += iOffsetOrg;
    3634       piCur += iOffsetCur;
    3635     }
    3636   }
    3637 #if NS_HAD
    3638   else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD )
    3639   {
    3640     Int  iOffsetOrg = iStrideOrg<<2;
    3641     Int  iOffsetCur = iStrideCur<<2;
    3642     for ( y=0; y<iRows; y+= 4 )
    3643     {
    3644       for ( x=0; x<iCols; x+= 16 )
    3645       {
    3646         uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3647       }
    3648       piOrg += iOffsetOrg;
    3649       piCur += iOffsetCur;
    3650     }
    3651   }
    3652   else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD )
    3653   {
    3654     Int  iOffsetOrg = iStrideOrg<<4;
    3655     Int  iOffsetCur = iStrideCur<<4;
    3656     for ( y=0; y<iRows; y+= 16 )
    3657     {
    3658       for ( x=0; x<iCols; x+= 4 )
    3659       {
    3660         uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3661       }
    3662       piOrg += iOffsetOrg;
    3663       piCur += iOffsetCur;
    3664     }
    3665   }
    3666 #endif
    3667   else if( ( iRows % 4 == 0) && (iCols % 4 == 0) )
    3668   {
    3669     Int  iOffsetOrg = iStrideOrg<<2;
    3670     Int  iOffsetCur = iStrideCur<<2;
    3671 
    3672     for ( y=0; y<iRows; y+= 4 )
    3673     {
    3674       for ( x=0; x<iCols; x+= 4 )
    3675       {
    3676         uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3677       }
    3678       piOrg += iOffsetOrg;
    3679       piCur += iOffsetCur;
    3680     }
    3681   }
    3682   else if( ( iRows % 2 == 0) && (iCols % 2 == 0) )
    3683   {
    3684     Int  iOffsetOrg = iStrideOrg<<1;
    3685     Int  iOffsetCur = iStrideCur<<1;
    3686     for ( y=0; y<iRows; y+=2 )
    3687     {
    3688       for ( x=0; x<iCols; x+=2 )
    3689       {
    3690         uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3691       }
    3692       piOrg += iOffsetOrg;
    3693       piCur += iOffsetCur;
    3694     }
    3695   }
    3696   else
    3697   {
    3698     assert(false);
    3699   }
    3700 
    3701   piOrg   = pcDtParam->pOrg;
    3702 
    3703   for ( y=0; y<iRows; y++ )
    3704   {
    3705     for ( x=0; x<iCols; x++ )
    3706     {       
    3707       piOrg[x] += iDeltaC;
    3708     }
    3709     piOrg += iStrideOrg;
    3710   }
    3711 
    3712   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    3713 }
    3714 #endif
    3715 
    3716 #if H_3D_VSO
    3717 Void TComRdCost::setLambdaVSO( Double dLambdaVSO )
    3718 {
    3719   m_dLambdaVSO           = dLambdaVSO;
    3720   m_dSqrtLambdaVSO       = sqrt(m_dLambdaVSO);
    3721   m_uiLambdaMotionSADVSO = (UInt)floor(65536.0 *       m_dSqrtLambdaVSO);
    3722   m_uiLambdaMotionSSEVSO = (UInt)floor(65536.0 *       m_dLambdaVSO    );
    3723 }
    3724 
    3725 Dist TComRdCost::xGetDistVSOMode4( Int iStartPosX, Int iStartPosY, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD )
    3726 {
    3727   AOT(bSAD);
    3728 #if H_3D_VSO_EARLY_SKIP
    3729   RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur, piOrg, iOrgStride); 
    3730 #else
    3731   RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur ); 
    3732 #endif
    3733 
    3734   RMDist iDistMin = (RMDist) RDO_DIST_MIN;
    3735   iDistMin = m_bAllowNegDist ? RDO_DIST_MIN : 0;
    3736  
    3737   iDist = std::min( iDist, (RMDist) RDO_DIST_MAX);
    3738   iDist = std::max( iDist, iDistMin);
    3739   return (Dist) iDist;
    3740 }
    3741 
    3742 
    3743 Dist TComRdCost::getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHAD )
    3744 {
    3745   assert( m_bUseVSO ); 
    3746   assert( this->m_fpDistortFuncVSO != 0 );
    3747 
    3748   Int iPosX;
    3749   Int iPosY;
    3750  
    3751   pcCU->getPosInPic( uiAbsPartIndex, iPosX, iPosY );
    3752    
    3753   Dist dist = (this->*m_fpDistortFuncVSO) ( iPosX, iPosY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight, bHAD ); 
    3754  
    3755   if ( m_bUseWVSO )   
    3756   {
    3757     Int iDWeight   = m_iDWeight   * m_iDWeight;
    3758     Int iVSOWeight = m_iVSOWeight * m_iVSOWeight;
    3759     Dist distDepth;
    3760    
    3761     if ( !bHAD )
    3762     {
    3763        distDepth = (Dist) getDistPart( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
    3764     }
    3765     else
    3766     {
    3767        distDepth = (Dist) calcHAD( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
    3768     }
    3769    
    3770     dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight);
    3771   }
    3772   return dist;
    3773 };
    3774 
    3775 
    3776 Void TComRdCost::setVSOMode( UInt uiIn )
    3777 {
    3778   m_uiVSOMode = uiIn;
    3779   switch (m_uiVSOMode )
    3780   {
    3781   case   4:
    3782     m_fpDistortFuncVSO = &TComRdCost::xGetDistVSOMode4;
    3783     break;
    3784   default:
    3785     assert(0);
    3786     break;
    3787   }
    3788 }
    3789 
    3790 
    3791 Double TComRdCost::calcRdCostVSO( UInt uiBits, Dist uiDistortion, Bool bFlag, DFunc eDFunc )
    3792 {
    3793   assert( m_bUseLambdaScaleVSO );   
    3794 
    3795   Double dRdCost = 0.0;
    3796   Double dLambda = 0.0;   
    3797 
    3798   switch ( eDFunc )
    3799   {
    3800   case DF_SSE:
    3801     assert(0);
    3802     break;
    3803   case DF_SAD:
    3804     dLambda = (Double)m_uiLambdaMotionSADVSO;
    3805     break;
    3806   case DF_DEFAULT:
    3807     dLambda =         m_dLambdaVSO;
    3808     break;
    3809   case DF_SSE_FRAME:
    3810     dLambda =         m_dFrameLambdaVSO;
    3811     break;
    3812   default:
    3813     assert (0);
    3814     break;
    3815   }
    3816 
    3817   if (bFlag)
    3818   {
    3819     // Intra8x8, Intra4x4 Block only...
    3820 #if SEQUENCE_LEVEL_LOSSLESS
    3821     dRdCost = (Double)(uiBits);
    3822 #else
    3823     dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda));
    3824 #endif
    3825   }
    3826   else
    3827   {
    3828     if (eDFunc == DF_SAD)
    3829     {
    3830       dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)>>16));
    3831       dRdCost = (Double)(Dist)floor(dRdCost);
    3832     }
    3833     else
    3834     {
    3835 #if SEQUENCE_LEVEL_LOSSLESS
    3836       dRdCost = (Double)(uiBits);
    3837 #else
    3838       dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)));
    3839       dRdCost = (Double)(Dist)floor(dRdCost);
    3840 #endif
    3841     }
    3842   }
    3843 
    3844   return dRdCost;
    3845 }
    3846 
    3847 Void TComRdCost::setRenModelData( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piData, Int iStride, Int iBlkWidth, Int iBlkHeight )
    3848 {
    3849   UInt iBlkX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]];
    3850   UInt iBlkY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]];
    3851 
    3852   Int iStartPosX = iBlkX + pcCU->getCUPelX();
    3853   Int iStartPosY = iBlkY + pcCU->getCUPelY();
    3854 
    3855   m_pcRenModel->setData( iStartPosX, iStartPosY, iBlkWidth, iBlkHeight, iStride, piData );
    3856 }
    3857 
    3858 Void TComRdCost::setAllowNegDist( Bool bAllowNegDist )
    3859 {
    3860   m_bAllowNegDist = bAllowNegDist;
    3861 }
    3862 #endif
     1663
    38631664
    38641665//! \}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComRdCost.h

    r872 r1072  
    4646#include "TComSlice.h"
    4747#include "TComRdCostWeightPrediction.h"
    48 #if H_3D
    49 #include "../TLibRenderer/TRenModel.h"
    50 #endif
    5148
    5249//! \ingroup TLibCommon
     
    5754class DistParam;
    5855class TComPattern;
    59 #if H_3D
    60 class TComRdCost;
    61 #endif
    6256
    6357// ====================================================================================================================
     
    6862typedef UInt (*FpDistFunc) (DistParam*);
    6963
    70 #if H_3D
    71 #if H_3D_VSO
    72 typedef Dist (TComRdCost::*FpDistFuncVSO) ( Int, Int, Pel*, Int, Pel*, Int, UInt, UInt, Bool );
    73 #endif
    74 #endif
    7564// ====================================================================================================================
    7665// Class definition
     
    8574  Int   iStrideOrg;
    8675  Int   iStrideCur;
    87 #if H_3D_VSO
    88   // SAIT_VSO_EST_A0033
    89   Pel*  pVirRec;
    90   Pel*  pVirOrg;
    91   Int   iStrideVir;
    92 #endif
    93 #if H_3D_IC
    94   Bool  bUseIC;
    95 #endif
    96 #if H_3D_INTER_SDC
    97   Bool  bUseSDCMRSAD;
    98 #endif
    9976  Int   iRows;
    10077  Int   iCols;
     
    123100    iSubShift = 0;
    124101    bitDepth = 0;
    125 #if H_3D_VSO
    126     // SAIT_VSO_EST_A0033
    127     pVirRec = NULL;
    128     pVirOrg = NULL;
    129     iStrideVir = 0;
    130 #endif
    131 #if H_3D_INTER_SDC
    132     bUseSDCMRSAD = false;
    133 #endif
    134102  }
    135103};
     
    155123  UInt                    m_uiLambdaMotionSSE;
    156124  Double                  m_dFrameLambda;
    157 #if H_3D_VSO
    158   // SAIT_VSO_EST_A0033
    159   static Double           m_dDisparityCoeff;
    160 #endif
    161125 
    162126  // for motion cost
     
    175139#endif
    176140 
    177 #if H_3D_DBBP
    178   Bool                    m_bUseMask;
    179 #endif
    180141 
    181142public:
     
    183144  virtual ~TComRdCost();
    184145
    185 #if H_3D_VSO
    186   Double  calcRdCost  ( UInt   uiBits, Dist   uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    187   Double  calcRdCost64( UInt64 uiBits, Dist64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    188 #else
    189146  Double  calcRdCost  ( UInt   uiBits, UInt   uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    190147  Double  calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    191 #endif
    192148
    193149 
     
    198154 
    199155  Double  getSqrtLambda ()   { return m_sqrtLambda; }
    200 #if H_3D_VSO
    201   // SAIT_VSO_EST_A0033
    202   Void    setDisparityCoeff( Double dDisparityCoeff ) { m_dDisparityCoeff = dDisparityCoeff; }
    203   Double  getDisparityCoeff()                         { return m_dDisparityCoeff; }
    204 #endif
    205156
    206157  Double  getLambda() { return m_dLambda; }
     
    215166  Void    setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false );
    216167 
    217 #if H_3D_DBBP
    218   Void    setUseMask(Bool b) { m_bUseMask = b; }
    219 #endif
    220168 
    221169  UInt    calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight );
    222170 
    223 #if H_3D_FAST_DEPTH_INTRA
    224   UInt    calcVAR(Pel* pi0, Int stride, Int width, Int height, Int cuDepth);
    225 #endif 
    226171  // for motion cost
    227172#if !FIX203
     
    269214  static UInt xGetSSE64         ( DistParam* pcDtParam );
    270215  static UInt xGetSSE16N        ( DistParam* pcDtParam );
    271 #if H_3D_IC || H_3D_INTER_SDC
    272   static UInt xGetSADic         ( DistParam* pcDtParam );
    273   static UInt xGetSAD4ic        ( DistParam* pcDtParam );
    274   static UInt xGetSAD8ic        ( DistParam* pcDtParam );
    275   static UInt xGetSAD16ic       ( DistParam* pcDtParam );
    276   static UInt xGetSAD32ic       ( DistParam* pcDtParam );
    277   static UInt xGetSAD64ic       ( DistParam* pcDtParam );
    278   static UInt xGetSAD16Nic      ( DistParam* pcDtParam );
    279 #endif
    280216  static UInt xGetSAD           ( DistParam* pcDtParam );
    281217  static UInt xGetSAD4          ( DistParam* pcDtParam );
     
    286222  static UInt xGetSAD16N        ( DistParam* pcDtParam );
    287223 
    288 #if H_3D_VSO
    289   static UInt xGetVSD           ( DistParam* pcDtParam );
    290   static UInt xGetVSD4          ( DistParam* pcDtParam );
    291   static UInt xGetVSD8          ( DistParam* pcDtParam );
    292   static UInt xGetVSD16         ( DistParam* pcDtParam );
    293   static UInt xGetVSD32         ( DistParam* pcDtParam );
    294   static UInt xGetVSD64         ( DistParam* pcDtParam );
    295   static UInt xGetVSD16N        ( DistParam* pcDtParam );
    296 #endif
    297224
    298225#if AMP_SAD
    299 #if H_3D_IC || H_3D_INTER_SDC
    300   static UInt xGetSAD12ic       ( DistParam* pcDtParam );
    301   static UInt xGetSAD24ic       ( DistParam* pcDtParam );
    302   static UInt xGetSAD48ic       ( DistParam* pcDtParam );
    303 #endif
    304226  static UInt xGetSAD12         ( DistParam* pcDtParam );
    305227  static UInt xGetSAD24         ( DistParam* pcDtParam );
     
    308230#endif
    309231
    310 #if H_3D_IC || H_3D_INTER_SDC
    311   static UInt xGetHADsic          ( DistParam* pcDtParam );
    312 #endif
    313232  static UInt xGetHADs4         ( DistParam* pcDtParam );
    314233  static UInt xGetHADs8         ( DistParam* pcDtParam );
     
    317236  static UInt xCalcHADs4x4      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    318237  static UInt xCalcHADs8x8      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    319 #if H_3D_DBBP
    320   static UInt xGetMaskedSSE     ( DistParam* pcDtParam );
    321   static UInt xGetMaskedSAD     ( DistParam* pcDtParam );
    322   static UInt xGetMaskedHADs    ( DistParam* pcDtParam );
    323   static UInt xGetMaskedVSD     ( DistParam* pcDtParam );
    324 #endif
    325238 
    326239public:
    327240  UInt   getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText = TEXT_LUMA, DFunc eDFunc = DF_SSE );
    328241
    329 #if KWU_RC_MADPRED_E0227
    330   UInt   getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height );
    331 #endif
    332 
    333 #if H_3D_VSO
    334   // SAIT_VSO_EST_A0033
    335   UInt        getDistPartVSD( TComDataCU* pcCu, UInt uiPartOffset, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHad, DFunc eDFunc = DF_VSD);
    336   static UInt getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride,  Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y );
    337 
    338 private:
    339   Double                  m_dLambdaVSO;
    340   Double                  m_dSqrtLambdaVSO;
    341   UInt                    m_uiLambdaMotionSADVSO;
    342   UInt                    m_uiLambdaMotionSSEVSO;
    343   Double                  m_dFrameLambdaVSO;
    344   Bool                    m_bAllowNegDist;
    345   Bool                    m_bUseVSO;
    346   Bool                    m_bUseLambdaScaleVSO;
    347   UInt                    m_uiVSOMode;
    348 
    349   FpDistFuncVSO           m_fpDistortFuncVSO;
    350   TRenModel*              m_pcRenModel;
    351 
    352 
    353   // SAIT_VSO_EST_A0033
    354   TComPicYuv *            m_pcVideoRecPicYuv;
    355   TComPicYuv *            m_pcDepthPicYuv;
    356   Bool                    m_bUseEstimatedVSD;
    357 
    358   // LGE_WVSO_A0119
    359   Int                     m_iDWeight;
    360   Int                     m_iVSOWeight;
    361   Int                     m_iVSDWeight;
    362   Bool                    m_bUseWVSO;
    363 
    364 public:
    365 
    366   Void    setRenModel       ( TRenModel* pcRenModel ) { m_pcRenModel = pcRenModel; }
    367   TRenModel* getRenModel    ( )                       { return m_pcRenModel; }
    368   Void    setRenModelData   ( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piData, Int iStride, Int iBlkWidth, Int iBlkHeight );
    369   Void    setLambdaVSO      ( Double dLambda );
    370   Void    setFrameLambdaVSO ( Double dLambda ) { m_dFrameLambdaVSO = dLambda; };
    371 
    372 
    373   Void    setUseVSO ( Bool bIn )         { m_bUseVSO = bIn; };
    374   Bool    getUseVSO ( )                  { return m_bUseVSO;};
    375 
    376   Bool    getUseRenModel ( )             { return (m_bUseVSO && m_uiVSOMode == 4); };
    377   Void    setUseLambdaScaleVSO(Bool bIn) { m_bUseLambdaScaleVSO = bIn; };
    378   Bool    getUseLambdaScaleVSO( )        { return m_bUseLambdaScaleVSO; };
    379 
    380   Void    setVSOMode( UInt uiIn);
    381   UInt    getVSOMode( )                  { return m_uiVSOMode; }
    382   Void    setAllowNegDist ( Bool bAllowNegDist );
    383 
    384   Double  getSqrtLambdaVSO ()   { return m_dSqrtLambdaVSO; }
    385   Double  getLambdaVSO ()       { return m_dLambdaVSO; }
    386 
    387   Dist   getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD );
    388   Double calcRdCostVSO ( UInt   uiBits, Dist   uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    389 
    390   // SAIT_VSO_EST_A0033
    391   Bool    getUseEstimatedVSD( )           { return m_bUseEstimatedVSD; };
    392   Void    setUseEstimatedVSD( Bool bIn )  { m_bUseEstimatedVSD = bIn; };
    393 
    394   TComPicYuv* getVideoRecPicYuv ()                               { return m_pcVideoRecPicYuv; };
    395   Void        setVideoRecPicYuv ( TComPicYuv* pcVideoRecPicYuv ) { m_pcVideoRecPicYuv = pcVideoRecPicYuv; };
    396   TComPicYuv* getDepthPicYuv    ()                               { return m_pcDepthPicYuv; };
    397   Void        setDepthPicYuv    ( TComPicYuv* pcDepthPicYuv )    { m_pcDepthPicYuv = pcDepthPicYuv; };
    398 
    399   // LGE_WVSO_A0119
    400   Void    setUseWVSO ( Bool bIn )         { m_bUseWVSO = bIn; };
    401   Bool    getUseWVSO ( )                  { return m_bUseWVSO;};
    402   Void    setDWeight   ( Int iDWeight   ) { m_iDWeight = iDWeight; };
    403   Int     getDWeight   ()                 { return m_iDWeight; };
    404   Void    setVSOWeight ( Int iVSOWeight ) { m_iVSOWeight = iVSOWeight; };
    405   Int     getVSOWeight ()                 { return m_iVSOWeight; };
    406   Void    setVSDWeight ( Int iVSDWeight ) { m_iVSDWeight = iVSDWeight; };
    407   Int     getVSDWeight ()                 { return m_iVSDWeight; };
    408 
    409 private:
    410   Dist xGetDistVSOMode4( Int iStartPosX, Int iStartPosY, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD );
    411 
    412 #endif // H_3D_VSO
     242
    413243
    414244};// END CLASS DEFINITION TComRdCost
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComRom.cpp

    r1066 r1072  
    101101  }
    102102
    103 #if H_3D_DIM_DMM
    104   if( !g_dmmWedgeLists.empty() )
    105   {
    106     for( UInt ui = 0; ui < g_dmmWedgeLists.size(); ui++ ) { g_dmmWedgeLists[ui].clear(); }
    107     g_dmmWedgeLists.clear();
    108   }
    109   if( !g_dmmWedgeRefLists.empty() )
    110   {
    111     for( UInt ui = 0; ui < g_dmmWedgeRefLists.size(); ui++ ) { g_dmmWedgeRefLists[ui].clear(); }
    112     g_dmmWedgeRefLists.clear();
    113   }
    114 
    115   if( !g_dmmWedgeNodeLists.empty() )
    116   {
    117     for( UInt ui = 0; ui < g_dmmWedgeNodeLists.size(); ui++ ) { g_dmmWedgeNodeLists[ui].clear(); }
    118     g_dmmWedgeNodeLists.clear();
    119   }
    120 #endif
    121103}
    122104
     
    346328UInt g_uiPCMBitDepthChroma   = 8;    // PCM bit-depth
    347329
    348 #if H_3D_DIM_DMM
    349 // ====================================================================================================================
    350 // Depth coding modes
    351 // ====================================================================================================================
    352 const WedgeResolution g_dmmWedgeResolution[6] =
    353 {
    354   HALF_PEL,    //   4x4
    355   HALF_PEL,    //   8x8
    356   FULL_PEL,    //  16x16
    357 #if SHARP_DMM1_I0110
    358   FULL_PEL,    //  32x32
    359   FULL_PEL,    //  64x64
    360   FULL_PEL     // 128x128
    361 #else
    362   DOUBLE_PEL,  //  32x32
    363   DOUBLE_PEL,  //  64x64
    364   DOUBLE_PEL   // 128x128
    365 #endif
    366 };
    367 
    368 const UChar g_dmm1TabIdxBits[6] =
    369 { //2x2   4x4   8x8 16x16 32x32 64x64
    370      0,    7,   10,   11,   11,   13 };
    371 
    372 const UChar g_dmm3IntraTabIdxBits[6] =
    373 { //2x2   4x4   8x8 16x16 32x32 64x64
    374      0,    4,    7,    8,    8,    0 };
    375 
    376 #if SHARP_DMM1_I0110
    377 Bool g_wedgePattern[32*32];
    378 #endif
    379 
    380 extern std::vector< std::vector<TComWedgelet> >   g_dmmWedgeLists;
    381 extern std::vector< std::vector<TComWedgeRef> >   g_dmmWedgeRefLists;
    382 extern std::vector< std::vector<TComWedgeNode> >  g_dmmWedgeNodeLists;
    383 #endif
    384330
    385331// ====================================================================================================================
     
    388334
    389335Char  g_aucConvertToBit  [ MAX_CU_SIZE+1 ];
    390 #if !MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX
    391 #if H_3D_IC
    392 UInt g_aICEnableCANDIDATE[10] = { 0, };
    393 UInt g_aICEnableNUM[ 10 ] = { 0, };
    394 Int g_lastlayer=0;
    395 #endif
    396 #endif
    397336#if ENC_DEC_TRACE
    398337FILE*  g_hTrace = NULL;
     
    667606#endif
    668607#endif
    669 #if H_3D_DIM_DMM
    670 std::vector< std::vector<TComWedgelet>  > g_dmmWedgeLists;
    671 std::vector< std::vector<TComWedgeRef>  > g_dmmWedgeRefLists;
    672 std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists;
    673 
    674 Void initWedgeLists( Bool initNodeList )
    675 {
    676   if( !g_dmmWedgeLists.empty() ) return;
    677 
    678 #if SHARP_DMM1_I0110
    679   for( UInt ui = g_aucConvertToBit[DIM_MIN_SIZE]; ui < (g_aucConvertToBit[DIM_MAX_SIZE]); ui++ )
    680 #else
    681   for( UInt ui = g_aucConvertToBit[DIM_MIN_SIZE]; ui < (g_aucConvertToBit[DIM_MAX_SIZE]+1); ui++ )
    682 #endif
    683   {
    684     UInt uiWedgeBlockSize = ((UInt)DIM_MIN_SIZE)<<ui;
    685     std::vector<TComWedgelet> acWedgeList;
    686     std::vector<TComWedgeRef> acWedgeRefList;
    687     createWedgeList( uiWedgeBlockSize, uiWedgeBlockSize, acWedgeList, acWedgeRefList, g_dmmWedgeResolution[ui] );
    688     g_dmmWedgeLists.push_back( acWedgeList );
    689     g_dmmWedgeRefLists.push_back( acWedgeRefList );
    690 
    691     if( initNodeList )
    692     {
    693       // create WedgeNodeList
    694       std::vector<TComWedgeNode> acWedgeNodeList;
    695       for( UInt uiPos = 0; uiPos < acWedgeList.size(); uiPos++ )
    696       {
    697         if( acWedgeList[uiPos].getIsCoarse() )
    698         {
    699           TComWedgeNode cWedgeNode;
    700           cWedgeNode.setPatternIdx( uiPos );
    701 
    702           UInt uiRefPos = 0;
    703           for( Int iOffS = -1; iOffS <= 1; iOffS++ )
    704           {
    705             for( Int iOffE = -1; iOffE <= 1; iOffE++ )
    706             {
    707               if( iOffS == 0 && iOffE == 0 ) { continue; }
    708 
    709               Int iSx = (Int)acWedgeList[uiPos].getStartX();
    710               Int iSy = (Int)acWedgeList[uiPos].getStartY();
    711               Int iEx = (Int)acWedgeList[uiPos].getEndX();
    712               Int iEy = (Int)acWedgeList[uiPos].getEndY();
    713 
    714               switch( acWedgeList[uiPos].getOri() )
    715               {
    716               case( 0 ): { iSx += iOffS; iEy += iOffE; } break;
    717               case( 1 ): { iSy += iOffS; iEx -= iOffE; } break;
    718               case( 2 ): { iSx -= iOffS; iEy -= iOffE; } break;
    719               case( 3 ): { iSy -= iOffS; iEx += iOffE; } break;
    720               case( 4 ): { iSx += iOffS; iEx += iOffE; } break;
    721               case( 5 ): { iSy += iOffS; iEy += iOffE; } break;
    722               default: assert( 0 );
    723               }
    724 
    725               for( UInt k = 0; k < acWedgeRefList.size(); k++ )
    726               {
    727                 if( iSx == (Int)acWedgeRefList[k].getStartX() &&
    728                   iSy == (Int)acWedgeRefList[k].getStartY() &&
    729                   iEx == (Int)acWedgeRefList[k].getEndX()   &&
    730                   iEy == (Int)acWedgeRefList[k].getEndY()      )
    731                 {
    732                   if( acWedgeRefList[k].getRefIdx() != cWedgeNode.getPatternIdx() )
    733                   {
    734                     Bool bNew = true;
    735                     for( UInt m = 0; m < uiRefPos; m++ ) { if( acWedgeRefList[k].getRefIdx() == cWedgeNode.getRefineIdx( m ) ) { bNew = false; break; } }
    736 
    737                     if( bNew )
    738                     {
    739                       cWedgeNode.setRefineIdx( acWedgeRefList[k].getRefIdx(), uiRefPos );
    740                       uiRefPos++;
    741                       break;
    742                     }
    743                   }
    744                 }
    745               }
    746             }
    747           }
    748           acWedgeNodeList.push_back( cWedgeNode );
    749         }
    750       }
    751       g_dmmWedgeNodeLists.push_back( acWedgeNodeList );
    752     }
    753   }
    754 }
    755 
    756 Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes )
    757 {
    758   assert( uiWidth == uiHeight );
    759 
    760   UChar    uhStartX = 0,    uhStartY = 0,    uhEndX = 0,    uhEndY = 0;
    761   Int   iStepStartX = 0, iStepStartY = 0, iStepEndX = 0, iStepEndY = 0;
    762 
    763   UInt uiBlockSize = 0;
    764   switch( eWedgeRes )
    765   {
    766 #if !SHARP_DMM1_I0110
    767   case( DOUBLE_PEL ): { uiBlockSize = (uiWidth>>1); break; }
    768 #endif
    769   case(   FULL_PEL ): { uiBlockSize =  uiWidth;     break; }
    770   case(   HALF_PEL ): { uiBlockSize = (uiWidth<<1); break; }
    771   }
    772 
    773   TComWedgelet cTempWedgelet( uiWidth, uiHeight );
    774   for( UInt uiOri = 0; uiOri < 6; uiOri++ )
    775   {
    776     // init the edge line parameters for each of the 6 wedgelet types
    777     switch( uiOri )
    778     {
    779     case( 0 ): {  uhStartX = 0;               uhStartY = 0;               uhEndX = 0;               uhEndY = 0;               iStepStartX = +1; iStepStartY =  0; iStepEndX =  0; iStepEndY = +1; break; }
    780     case( 1 ): {  uhStartX = (uiBlockSize-1); uhStartY = 0;               uhEndX = (uiBlockSize-1); uhEndY = 0;               iStepStartX =  0; iStepStartY = +1; iStepEndX = -1; iStepEndY =  0; break; }
    781     case( 2 ): {  uhStartX = (uiBlockSize-1); uhStartY = (uiBlockSize-1); uhEndX = (uiBlockSize-1); uhEndY = (uiBlockSize-1); iStepStartX = -1; iStepStartY =  0; iStepEndX =  0; iStepEndY = -1; break; }
    782     case( 3 ): {  uhStartX = 0;               uhStartY = (uiBlockSize-1); uhEndX = 0;               uhEndY = (uiBlockSize-1); iStepStartX =  0; iStepStartY = -1; iStepEndX = +1; iStepEndY =  0; break; }
    783     case( 4 ): {  uhStartX = 0;               uhStartY = 0;               uhEndX = 0;               uhEndY = (uiBlockSize-1); iStepStartX = +1; iStepStartY =  0; iStepEndX = +1; iStepEndY =  0; break; }
    784     case( 5 ): {  uhStartX = (uiBlockSize-1); uhStartY = 0;               uhEndX = 0;               uhEndY = 0;               iStepStartX =  0; iStepStartY = +1; iStepEndX =  0; iStepEndY = +1; break; }
    785     }
    786 
    787     for( Int iK = 0; iK < uiBlockSize; iK++ )
    788     {
    789       for( Int iL = 0; iL < uiBlockSize; iL++ )
    790       {
    791         cTempWedgelet.setWedgelet( uhStartX + (iK*iStepStartX) , uhStartY + (iK*iStepStartY), uhEndX + (iL*iStepEndX), uhEndY + (iL*iStepEndY), (UChar)uiOri, eWedgeRes, ((iL%2)==0 && (iK%2)==0) );
    792         addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList );
    793       }
    794     }
    795   }
    796 
    797 
    798 }
    799 
    800 Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList )
    801 {
    802   Bool bValid = cWedgelet.checkNotPlain();
    803   if( bValid )
    804   {
    805     for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ )
    806     {
    807       if( cWedgelet.checkIdentical( racWedgeList[uiPos].getPattern() ) )
    808       {
    809         TComWedgeRef cWedgeRef;
    810         cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos );
    811         racWedgeRefList.push_back( cWedgeRef );
    812         bValid = false;
    813         return;
    814       }
    815     }
    816   }
    817   if( bValid )
    818   {
    819     for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ )
    820     {
    821       if( cWedgelet.checkInvIdentical( racWedgeList[uiPos].getPattern() ) )
    822       {
    823         TComWedgeRef cWedgeRef;
    824         cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos );
    825         racWedgeRefList.push_back( cWedgeRef );
    826         bValid = false;
    827         return;
    828       }
    829     }
    830   }
    831   if( bValid )
    832   {
    833     cWedgelet.findClosestAngle();
    834     racWedgeList.push_back( cWedgelet );
    835     TComWedgeRef cWedgeRef;
    836     cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), (UInt)(racWedgeList.size()-1) );
    837     racWedgeRefList.push_back( cWedgeRef );
    838   }
    839 }
    840 #endif //H_3D_DIM_DMM
    841608
    842609//! \}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComRom.h

    r1066 r1072  
    4545#include<iostream>
    4646
    47 #if H_3D_DIM
    48 #include "TComWedgelet.h"
    49 #endif
    5047
    5148//! \ingroup TLibCommon
     
    150147extern const UChar g_aucConvertTxtTypeToIdx[4];
    151148
    152 #if H_3D_DIM
    153 // ====================================================================================================================
    154 // Depth coding modes
    155 // ====================================================================================================================
    156 __inline Void mapDepthModeToIntraDir( UInt& intraMode ) { if( isDimMode( intraMode ) ) intraMode = DC_IDX; }
    157 __inline Void mapDepthModeToIntraDir(  Int& intraMode ) { if( isDimMode( intraMode ) ) intraMode = DC_IDX; }
    158 
    159 #if H_3D_DIM_SDC || H_3D_DIM_DLT
    160 __inline UInt numBitsForValue( UInt value ) { UInt bits = 0; while (value != 0) { value >>= 1; bits++; } return bits; };
    161 #endif
    162 
    163 #if H_3D_DIM_DMM
    164 extern const WedgeResolution                                 g_dmmWedgeResolution [6];
    165 extern const UChar                                           g_dmm1TabIdxBits     [6];
    166 extern const UChar                                           g_dmm3IntraTabIdxBits[6];
    167 
    168 #if SHARP_DMM1_I0110
    169 extern Bool                                                  g_wedgePattern[32*32];
    170 #endif
    171 
    172 extern       std::vector< std::vector<TComWedgelet> >        g_dmmWedgeLists;
    173 extern       std::vector< std::vector<TComWedgeRef> >        g_dmmWedgeRefLists;
    174 extern       std::vector< std::vector<TComWedgeNode> >       g_dmmWedgeNodeLists;
    175 
    176 Void initWedgeLists( Bool initNodeList = false );
    177 Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes );
    178 Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList );
    179 #endif
    180 #endif
    181149
    182150// ==========================================
     
    230198
    231199extern       Char   g_aucConvertToBit  [ MAX_CU_SIZE+1 ];   // from width to log2(width)-2
    232 #if !MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX
    233 #if H_3D_IC
    234 extern UInt g_aICEnableCANDIDATE[10];
    235 extern UInt g_aICEnableNUM[ 10 ]; //10 layers
    236 extern Int  g_lastlayer;
    237 #endif
    238 #endif
    239200
    240201#ifndef ENC_DEC_TRACE
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComSlice.cpp

    r1066 r1072  
    112112, m_viewId                        (0)
    113113, m_viewIndex                     (0)
    114 #if H_3D
    115 , m_isDepth                       (false)
    116 #endif
    117114#if !H_MV_HLS7_GEN
    118115, m_pocResetFlag                  (false)
     
    134131, m_pocMsbValRequiredFlag         ( false )
    135132#endif
    136 #if H_3D_IC
    137 , m_bApplyIC                      ( false )
    138 , m_icSkipParseFlag               ( false )
    139 #endif
    140 #if H_3D
    141 , m_depthToDisparityB             ( NULL )
    142 , m_depthToDisparityF             ( NULL )
    143 #endif
    144 #if MTK_SINGLE_DEPTH_MODE_I0095
    145 , m_bApplySingleDepthMode         (false)
    146 #endif
    147133#endif
    148134{
     
    187173  delete[] m_puiSubstreamSizes;
    188174  m_puiSubstreamSizes = NULL;
    189 #if H_3D
    190   for( UInt i = 0; i < getViewIndex(); i++ )
    191   {
    192     if ( m_depthToDisparityB && m_depthToDisparityB[ i ] )
    193     {
    194       delete[] m_depthToDisparityB [ i ];
    195     }
    196 
    197     if ( m_depthToDisparityF && m_depthToDisparityF[ i ] )
    198     {
    199       delete[] m_depthToDisparityF [ i ];
    200   }
    201   }
    202 
    203   if ( m_depthToDisparityF )
    204   {
    205     delete[] m_depthToDisparityF;
    206   }
    207 
    208   m_depthToDisparityF = NULL;
    209 
    210   if ( m_depthToDisparityB )
    211     delete[] m_depthToDisparityB;
    212 
    213   m_depthToDisparityB = NULL;
    214 #endif
    215175}
    216176
     
    229189  m_iSliceQpDeltaCr = 0;
    230190
    231 #if H_3D_IV_MERGE
    232   m_maxNumMergeCand = MRG_MAX_NUM_CANDS_MEM;
    233 #else
    234191  m_maxNumMergeCand = MRG_MAX_NUM_CANDS;
    235 #endif
    236192
    237193  m_bFinalized=false;
     
    241197  m_numEntryPointOffsets = 0;
    242198  m_enableTMVPFlag = true;
    243 #if H_3D_TMVP
    244   m_aiAlterRefIdx[0]                  = -1;
    245   m_aiAlterRefIdx[1]                  = -1;
    246 #endif
    247199}
    248200
     
    650602 
    651603  TComPic**             refPicSetStCurr    [2] = { RefPicSetStCurr0, RefPicSetStCurr1 };
    652 #if FIX_WARNING
    653   Int numPocStCurr[2] = { (Int)NumPocStCurr0, (Int)NumPocStCurr1 };
    654 #else
    655604  Int numPocStCurr[2] = { NumPocStCurr0, NumPocStCurr1 };
    656 #endif
    657605
    658606  for (Int li = 0; li < ((m_eSliceType==B_SLICE) ? 2 : 1); li++)
     
    772720  }
    773721}
    774 #if H_3D
    775 #if H_3D_TMVP
    776 Void TComSlice::generateAlterRefforTMVP()
    777 {
    778   for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    779   {       
    780     if ( this->getNumRefIdx( RefPicList( uiRefListIdx ) ) == 0)
    781     {
    782         continue;
    783     }
    784     Bool bZeroIdxLtFlag = this->getRefPic(RefPicList(uiRefListIdx), 0)->getIsLongTerm();
    785     for(Int i = 1; i < this->getNumRefIdx(RefPicList(uiRefListIdx)); i++ )
    786     {
    787       if ( ( bZeroIdxLtFlag && !this->getRefPic(RefPicList(uiRefListIdx), i)->getIsLongTerm() ) ||
    788            (!bZeroIdxLtFlag &&  this->getRefPic(RefPicList(uiRefListIdx), i)->getIsLongTerm() ) )
    789       {
    790         this->setAlterRefIdx(RefPicList(uiRefListIdx),i);
    791         break;
    792       }
    793     }
    794   }
    795 }
    796 #endif
    797 Void TComSlice::setCamparaSlice( Int** aaiScale, Int** aaiOffset )
    798 
    799   if( m_pcVPS->hasCamParInSliceHeader( m_viewIndex ) )
    800   {   
    801     for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < m_viewIndex; uiBaseViewIndex++ )
    802     {
    803       m_aaiCodedScale [ 0 ][ uiBaseViewIndex ] = aaiScale [ uiBaseViewIndex ][     m_viewIndex ];
    804       m_aaiCodedScale [ 1 ][ uiBaseViewIndex ] = aaiScale [     m_viewIndex ][ uiBaseViewIndex ];
    805       m_aaiCodedOffset[ 0 ][ uiBaseViewIndex ] = aaiOffset[ uiBaseViewIndex ][     m_viewIndex ];
    806       m_aaiCodedOffset[ 1 ][ uiBaseViewIndex ] = aaiOffset[     m_viewIndex ][ uiBaseViewIndex ];
    807     }
    808   }
    809 }
    810 #endif
    811722
    812723Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic)
     
    11041015    m_interLayerPredLayerIdc[ layer ] = pSrc->m_interLayerPredLayerIdc[ layer ];
    11051016  }
    1106 #endif
    1107 #if MTK_SINGLE_DEPTH_MODE_I0095
    1108   m_bApplySingleDepthMode = pSrc->m_bApplySingleDepthMode;
    1109 #endif
    1110 #if H_3D_IC
    1111   m_bApplyIC = pSrc->m_bApplyIC;
    1112   m_icSkipParseFlag = pSrc->m_icSkipParseFlag;
    11131017#endif
    11141018}
     
    19671871    m_viewIdVal          [i] = 0;
    19681872
    1969 #if H_3D
    1970     m_viewIndex         [i] = -1;
    1971     m_vpsDepthModesFlag [i] = false;
    1972 #if SEC_HLS_CLEANUP_I0100
    1973     m_ivMvScalingFlag[i] = true;
    1974 #else
    1975     m_ivMvScalingFlag = true;
    1976 #endif
    1977 #if SEPARATE_FLAG_I0085
    1978     m_bIVPFlag [i]      = false;
    1979 #endif
    1980 #endif
    19811873
    19821874    for( Int j = 0; j < MAX_NUM_LAYERS; j++ )
     
    19991891      m_dimensionId[i][j] = 0;
    20001892    }
    2001 #if H_3D_ARP
    2002     m_uiUseAdvResPred[i]  = 0;
    2003     m_uiARPStepNum[i]     = 1;
    2004 #endif
    20051893  }
    20061894  m_vpsVUI = new TComVPSVUI;
    20071895  m_dpbSize = new TComDpbSize;
    20081896
    2009 #if H_3D
    2010   for( Int i = 0; i < MAX_NUM_LAYERS; i++ )
    2011   {
    2012 #if H_3D_IV_MERGE
    2013     m_ivMvPredFlag         [ i ] = false;
    2014 #if H_3D_SPIVMP
    2015     m_iSubPULog2Size       [ i ] = 0;
    2016 #endif
    2017 #endif
    2018 #if MTK_I0099_VPS_EX2
    2019     m_bLimQtPredFlag       [ i ] = false;
    2020 #endif
    2021 #if H_3D_VSP
    2022     m_viewSynthesisPredFlag[ i ] = false;
    2023 #endif
    2024 #if H_3D_NBDV_REF
    2025     m_depthRefinementFlag  [ i ] = false;
    2026 #endif
    2027 #if H_3D_INTER_SDC
    2028     m_bInterSDCFlag        [ i ] = false;
    2029 #endif
    2030 #if SEPARATE_FLAG_I0085
    2031     m_bIVPFlag             [ i ] = false;
    2032 #endif
    2033 #if H_3D_DBBP
    2034     m_dbbpFlag             [ i ] = false;
    2035 #endif
    2036 #if H_3D_IV_MERGE
    2037     m_bMPIFlag             [ i ] = false;
    2038 #endif
    2039   } 
    2040 #endif
    20411897#endif
    20421898}
     
    20561912  }
    20571913#endif
    2058 #if H_3D
    2059   deleteCamPars();
    2060 #endif
    20611914}
    20621915
     
    22782131}
    22792132
    2280 #if H_3D
    2281 Int TComVPS::getLayerIdInNuh( Int viewIndex, Bool depthFlag )
    2282 {
    2283   Int foundLayerIdinNuh = -1;
    2284 
    2285   for (Int layerIdInVps = 0 ; layerIdInVps <= getMaxLayersMinus1(); layerIdInVps++ )
    2286   {
    2287     Int layerIdInNuh = getLayerIdInNuh( layerIdInVps );
    2288     if( ( getViewIndex( layerIdInNuh ) == viewIndex ) && ( getDepthId( layerIdInNuh ) == ( depthFlag ? 1 : 0 ) )  )
    2289     {
    2290       foundLayerIdinNuh = layerIdInNuh;
    2291       break;
    2292     }
    2293   }
    2294 #if !BUG_FIX_TK65
    2295   assert( foundLayerIdinNuh != -1 );
    2296 #endif
    2297   return foundLayerIdinNuh;
    2298 }
    2299 
    2300 Void TComVPS::createCamPars(Int iNumViews)
    2301 {
    2302   Int i = 0, j = 0;
    2303 
    2304   m_bCamParPresent = new Bool[ iNumViews ];
    2305   m_bCamParInSliceHeader = new Bool[ iNumViews ];
    2306 
    2307   m_aaaiCodedScale = new Int**[ iNumViews ];
    2308   m_aaaiCodedOffset = new Int**[ iNumViews ];
    2309   for ( i = 0; i < iNumViews ; i++ )
    2310   {
    2311 #if H_3D_FIX_UNINIT
    2312     m_bCamParPresent[i] = false;
    2313 #endif
    2314     m_bCamParInSliceHeader[i] = false;
    2315     m_aaaiCodedScale[i] = new Int*[ 2 ];
    2316     m_aaaiCodedOffset[i] = new Int*[ 2 ];
    2317     for ( j = 0; j < 2; j++ )
    2318     {
    2319       m_aaaiCodedScale[i][j] = new Int[ MAX_NUM_LAYERS ];
    2320       m_aaaiCodedOffset[i][j] = new Int[ MAX_NUM_LAYERS ];
    2321       for ( Int k = 0; k < MAX_NUM_LAYERS; k++ )
    2322       {
    2323         m_aaaiCodedScale[i][j][k] = 0;
    2324         m_aaaiCodedOffset[i][j][k] = 0;
    2325       }
    2326     }
    2327   }
    2328 }
    2329 
    2330 Void TComVPS::deleteCamPars()
    2331 {
    2332   Int iNumViews = getNumViews();
    2333   Int i = 0, j = 0;
    2334 
    2335   if ( m_bCamParPresent != NULL )
    2336   {
    2337     delete [] m_bCamParPresent;
    2338   }
    2339   if ( m_bCamParInSliceHeader != NULL )
    2340   {
    2341     delete [] m_bCamParInSliceHeader;
    2342   }
    2343 
    2344   if ( m_aaaiCodedScale != NULL )
    2345   {
    2346     for ( i = 0; i < iNumViews ; i++ )
    2347     {
    2348       for ( j = 0; j < 2; j++ )
    2349       {
    2350         delete [] m_aaaiCodedScale[i][j];
    2351       }
    2352       delete [] m_aaaiCodedScale[i];
    2353     }
    2354     delete [] m_aaaiCodedScale;
    2355   }
    2356 
    2357   if ( m_aaaiCodedOffset != NULL )
    2358   {
    2359     for ( i = 0; i < iNumViews ; i++ )
    2360     {
    2361       for ( j = 0; j < 2; j++ )
    2362       {
    2363         delete [] m_aaaiCodedOffset[i][j];
    2364       }
    2365       delete [] m_aaaiCodedOffset[i];
    2366     }
    2367     delete [] m_aaaiCodedOffset;
    2368   }
    2369 }
    2370 
    2371 
    2372 Void
    2373   TComVPS::initCamParaVPS( UInt uiViewIndex, Bool bCamParPresent, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset )
    2374 {
    2375   AOT( uiViewIndex != 0 && !bCamParSlice && ( aaiScale == 0 || aaiOffset == 0 ) ); 
    2376 
    2377   m_uiCamParPrecision = ( ( uiViewIndex != 0 )? uiCamParPrecision : 0 );
    2378   m_bCamParPresent[ uiViewIndex ] = (( uiViewIndex != 0 )? bCamParPresent  : false );
    2379   m_bCamParInSliceHeader[ uiViewIndex ]  = ( (uiViewIndex != 0)? bCamParSlice  : false );
    2380 
    2381   if( !m_bCamParInSliceHeader[ uiViewIndex ] )
    2382   {
    2383     for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < uiViewIndex; uiBaseViewIndex++ )
    2384     {
    2385       m_aaaiCodedScale [ uiViewIndex ][ 0 ][ uiBaseViewIndex ] = aaiScale [ uiBaseViewIndex ][     uiViewIndex ];
    2386       m_aaaiCodedScale [ uiViewIndex ][ 1 ][ uiBaseViewIndex ] = aaiScale [     uiViewIndex ][ uiBaseViewIndex ];
    2387       m_aaaiCodedOffset[ uiViewIndex ][ 0 ][ uiBaseViewIndex ] = aaiOffset[ uiBaseViewIndex ][     uiViewIndex ];
    2388       m_aaaiCodedOffset[ uiViewIndex ][ 1 ][ uiBaseViewIndex ] = aaiOffset[     uiViewIndex ][ uiBaseViewIndex ];
    2389     }
    2390   }
    2391 }
    2392 
    2393 #endif // H_3D
    23942133
    23952134
     
    27532492  vector<Int> range;
    27542493
    2755 #if H_3D
    2756   vector<Int> depthId;
    2757 #endif
    27582494
    27592495#if H_MV_HLS10_AUX
     
    27722508    auxId         .push_back( getAuxId       ( i ) );     
    27732509    viewId        .push_back( getViewId      ( getLayerIdInNuh( i ) ) );
    2774 #if H_3D 
    2775     depthId.push_back( getDepthId( i ) );
    2776 #endif
    27772510#endif
    27782511  }
     
    27922525  vector<Int> layerIdxInVps;
    27932526
    2794 #if H_3D
    2795   vector<Int> depthId;
    2796 #endif
    27972527
    27982528  vector<Int> viewOrderIndex;
     
    28092539    auxId         .push_back( getAuxId       ( layerIdInNuh ) );     
    28102540    viewId        .push_back( getViewId      ( layerIdInNuh ) );
    2811 #if H_3D 
    2812     depthId       .push_back( getDepthId     ( layerIdInNuh ) );
    2813 #endif
    28142541  }
    28152542
     
    29102637, m_pcmLog2MaxSize            (  5)
    29112638, m_uiPCMLog2MinSize          (  7)
    2912 #if !MTK_I0099_VPS_EX2
    2913 #if H_3D_QTLPC
    2914 , m_bUseQTL                   (false)
    2915 , m_bUsePC                    (false)
    2916 #endif
    2917 #endif
    29182639, m_bitDepthY                 (  8)
    29192640, m_bitDepthC                 (  8)
     
    29412662, m_interViewMvVertConstraintFlag (false)
    29422663#endif
    2943 #if H_3D
    2944 , m_bCamParInSliceHeader      (false)
    2945 #endif
    29462664{
    29472665  for ( Int i = 0; i < MAX_TLAYER; i++ )
     
    29572675  m_spsRangeExtensionsFlag     = false;
    29582676  m_spsMultilayerExtensionFlag = false;
    2959 #if H_3D
    2960   m_spsExtension5bits          = 0;
    2961   m_sps3dExtensionFlag         = false;
    2962 #else
    29632677  m_spsExtension6bits          = 0;
    2964 #endif
    29652678
    29662679#if !H_MV_HLS10_PPS
     
    31372850, m_ppsScalingListRefLayerId(0)
    31382851, m_pocResetInfoPresentFlag(false)
    3139 #if H_3D
    3140 , m_pcDLT(NULL)
    3141 #endif
    31422852#endif
    31432853{
     
    31472857  m_ppsRangeExtensionsFlag     = false;
    31482858  m_ppsMultilayerExtensionFlag = false;
    3149 #if !H_3D
    31502859  m_ppsExtension6bits          = 0;
    3151 #else
    3152   m_pps3dExtensionFlag         = false;
    3153   m_ppsExtension5bits          = 0;
    3154 #endif
    31552860#endif
    31562861}
     
    31712876}
    31722877
    3173 #if H_3D
    3174 TComDLT::TComDLT()
    3175 : m_bDltPresentFlag(false)
    3176 , m_iNumDepthViews(0)
    3177 , m_uiDepthViewBitDepth(8)
    3178 {
    3179   m_uiDepthViewBitDepth = g_bitDepthY;
    3180 
    3181   for( Int i = 0; i < MAX_NUM_LAYERS; i++ )
    3182   {
    3183     m_bUseDLTFlag                 [i] = false;
    3184     m_bInterViewDltPredEnableFlag [i] = false;
    3185 
    3186     // allocate some memory and initialize with default mapping
    3187     m_iNumDepthmapValues[i] = ((1 << m_uiDepthViewBitDepth)-1)+1;
    3188 #if !FIX_TICKET_77
    3189     m_iBitsPerDepthValue[i] = numBitsForValue(m_iNumDepthmapValues[i]);
    3190 #endif
    3191     m_iDepthValue2Idx[i]    = (Int*) xMalloc(Int, m_iNumDepthmapValues[i]);
    3192     m_iIdx2DepthValue[i]    = (Int*) xMalloc(Int, m_iNumDepthmapValues[i]);
    3193 
    3194     //default mapping
    3195     for (Int d=0; d<m_iNumDepthmapValues[i]; d++)
    3196     {
    3197       m_iDepthValue2Idx[i][d] = d;
    3198       m_iIdx2DepthValue[i][d] = d;
    3199     }
    3200   }
    3201 }
    3202 
    3203 TComDLT::~TComDLT()
    3204 {
    3205   for( Int i = 0; i < MAX_NUM_LAYERS; i++ )
    3206   {
    3207     if ( m_iDepthValue2Idx[i] != NULL )
    3208     {
    3209       xFree( m_iDepthValue2Idx[i] );
    3210       m_iDepthValue2Idx[i] = NULL;
    3211     }
    3212 
    3213     if ( m_iIdx2DepthValue[i] != NULL )
    3214     {
    3215       xFree( m_iIdx2DepthValue[i] );
    3216       m_iIdx2DepthValue[i] = NULL;
    3217     }
    3218   }
    3219 }
    3220 
    3221 Void TComDLT::setDepthLUTs(Int layerIdInVps, Int* idxToDepthValueTable, Int iNumDepthValues)
    3222 {
    3223   if( idxToDepthValueTable == NULL || iNumDepthValues == 0 ) // default mapping only
    3224     return;
    3225 
    3226   // copy idx2DepthValue to internal array
    3227   memcpy(m_iIdx2DepthValue[layerIdInVps], idxToDepthValueTable, iNumDepthValues*sizeof(UInt));
    3228 
    3229   UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1);
    3230   for(Int p=0; p<=uiMaxDepthValue; p++)
    3231   {
    3232     Int iIdxDown    = 0;
    3233     Int iIdxUp      = iNumDepthValues-1;
    3234     Bool bFound     = false;
    3235 
    3236     // iterate over indices to find lower closest depth
    3237     Int i = 1;
    3238     while(!bFound && i<iNumDepthValues)
    3239     {
    3240       if( m_iIdx2DepthValue[layerIdInVps][i] > p )
    3241       {
    3242         iIdxDown  = i-1;
    3243         bFound    = true;
    3244       }
    3245 
    3246       i++;
    3247     }
    3248     // iterate over indices to find upper closest depth
    3249     i = iNumDepthValues-2;
    3250     bFound = false;
    3251     while(!bFound && i>=0)
    3252     {
    3253       if( m_iIdx2DepthValue[layerIdInVps][i] < p )
    3254       {
    3255         iIdxUp  = i+1;
    3256         bFound    = true;
    3257       }
    3258 
    3259       i--;
    3260     }
    3261 
    3262     // assert monotony
    3263     assert(iIdxDown<=iIdxUp);
    3264 
    3265     // assign closer depth value/idx
    3266     if( abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxDown]) < abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxUp]) )
    3267     {
    3268       m_iDepthValue2Idx[layerIdInVps][p] = iIdxDown;
    3269     }
    3270     else
    3271     {
    3272       m_iDepthValue2Idx[layerIdInVps][p] = iIdxUp;
    3273     }
    3274 
    3275   }
    3276 
    3277   // update DLT variables
    3278   m_iNumDepthmapValues[layerIdInVps] = iNumDepthValues;
    3279 #if !FIX_TICKET_77
    3280   m_iBitsPerDepthValue[layerIdInVps] = numBitsForValue(m_iNumDepthmapValues[layerIdInVps]);
    3281 #endif
    3282 }
    3283 
    3284 #if H_3D_DELTA_DLT
    3285 Void TComDLT::getDeltaDLT( Int layerIdInVps, Int* piDLTInRef, UInt uiDLTInRefNum, Int* piDeltaDLTOut, UInt *puiDeltaDLTOutNum )
    3286 {
    3287   Bool abBM0[ 256 ];
    3288   Bool abBM1[ 256 ];
    3289  
    3290   memset( abBM0, 0, sizeof( abBM0 ));
    3291   memset( abBM1, 0, sizeof( abBM1 ));
    3292  
    3293   // convert reference DLT to bit string
    3294   for( Int i = 0; i < uiDLTInRefNum; i++ )
    3295   {
    3296     abBM0[ piDLTInRef[ i ] ] = true;
    3297   }
    3298   // convert internal DLT to bit string
    3299   for( Int i = 0; i < m_iNumDepthmapValues[ layerIdInVps ]; i++ )
    3300   {
    3301     abBM1[ m_iIdx2DepthValue[ layerIdInVps ][ i ] ] = true;
    3302   }
    3303  
    3304   *puiDeltaDLTOutNum = 0;
    3305   for( Int i = 0; i < 256; i++ )
    3306   {
    3307     if( abBM0[ i ] ^ abBM1[ i ] )
    3308     {
    3309       piDeltaDLTOut[ *puiDeltaDLTOutNum ] = i;
    3310       *puiDeltaDLTOutNum = *puiDeltaDLTOutNum + 1;
    3311     }
    3312   }
    3313 }
    3314 
    3315 Void TComDLT::setDeltaDLT( Int layerIdInVps, Int* piDLTInRef, UInt uiDLTInRefNum, Int* piDeltaDLTIn, UInt uiDeltaDLTInNum )
    3316 {
    3317   Bool abBM0[ 256 ];
    3318   Bool abBM1[ 256 ];
    3319  
    3320   memset( abBM0, 0, sizeof( abBM0 ));
    3321   memset( abBM1, 0, sizeof( abBM1 ));
    3322  
    3323   // convert reference DLT to bit string
    3324   for( Int i = 0; i < uiDLTInRefNum; i++ )
    3325   {
    3326     abBM0[ piDLTInRef[ i ] ] = true;
    3327   }
    3328   // convert delta DLT to bit string
    3329   for( Int i = 0; i < uiDeltaDLTInNum; i++ )
    3330   {
    3331     abBM1[ piDeltaDLTIn[ i ] ] = true;
    3332   }
    3333  
    3334   Int aiIdx2DepthValue[256];
    3335   UInt uiNumDepthValues = 0;
    3336   memset( aiIdx2DepthValue, 0, sizeof( aiIdx2DepthValue ));
    3337  
    3338   for( Int i = 0; i < 256; i++ )
    3339   {
    3340     if( abBM0[ i ] ^ abBM1[ i ] )
    3341     {
    3342       aiIdx2DepthValue[ uiNumDepthValues++ ] = i;
    3343     }
    3344   }
    3345  
    3346   // update internal tables
    3347   setDepthLUTs(layerIdInVps, aiIdx2DepthValue, uiNumDepthValues);
    3348 }
    3349 #endif
    3350 
    3351 #endif
    33522878
    33532879#if H_MV
     
    39623488}
    39633489
    3964 #if H_3D_ARP
    3965 Void TComSlice::setARPStepNum( TComPicLists*ivPicLists )
    3966 {
    3967   Bool tempRefPicInListsFlag = false;
    3968   if(!getVPS()->getUseAdvRP(getLayerId()) || this->isIRAP())
    3969   {
    3970     m_nARPStepNum = 0;
    3971   }
    3972   else
    3973   {
    3974     setFirstTRefIdx (REF_PIC_LIST_0, -1);
    3975     setFirstTRefIdx (REF_PIC_LIST_1, -1);
    3976     for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ )
    3977     {
    3978       Int diffPOC=MAX_INT;
    3979       Int idx=-1;
    3980       for(Int i = 0; i < getNumRefIdx(RefPicList(refListIdx)); i++ )
    3981       {
    3982         if ( getRefPic(RefPicList(refListIdx), i)->getPOC() != getPOC() )
    3983         {
    3984           if( abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC()) < diffPOC)
    3985           {
    3986             diffPOC=abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC());
    3987             idx=i;
    3988           }
    3989         }
    3990         if(idx>=0)
    3991         {
    3992           setFirstTRefIdx (RefPicList(refListIdx), idx);
    3993         }
    3994       }
    3995     }
    3996     tempRefPicInListsFlag = getFirstTRefIdx(REF_PIC_LIST_0) >= 0 || getFirstTRefIdx(REF_PIC_LIST_1) >= 0;
    3997     m_nARPStepNum = tempRefPicInListsFlag ? getVPS()->getARPStepNum(getLayerId()) : 0;
    3998   }
    3999 
    4000   if (tempRefPicInListsFlag)
    4001   {
    4002     for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ )
    4003     {
    4004       RefPicList eRefPicList = RefPicList( refListIdx );
    4005       Int prevPOC = getRefPic(eRefPicList, getFirstTRefIdx(eRefPicList) )->getPOC();
    4006       for( Int i = 0; i < getNumActiveRefLayerPics(); i++ )
    4007       {
    4008         Int layerIdInNuh = getRefPicLayerId( i );
    4009         Int viewIdx = getVPS()->getViewId( layerIdInNuh );
    4010         TComPic*pcPicPrev = ivPicLists->getPic(viewIdx, 0, prevPOC);
    4011         if (getFirstTRefIdx(eRefPicList) >= 0 && pcPicPrev && pcPicPrev->getSlice( 0 )->isReferenced())
    4012         {
    4013           m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = true;
    4014         }
    4015         else
    4016         {
    4017           m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = false;
    4018         }
    4019       }
    4020     }
    4021   }
    4022 }
    4023 #endif
    4024 #if H_3D_IC
    4025 Void TComSlice::xSetApplyIC(Bool bUseLowLatencyICEnc)
    4026 {
    4027   if(bUseLowLatencyICEnc)
    4028   {
    4029     Bool existInterViewRef=false;
    4030     TComPic* pcCurrPic = getPic();
    4031     TComPic* pcRefPic = NULL;
    4032     for ( Int i = 0; (i < getNumRefIdx( REF_PIC_LIST_0 )) && !existInterViewRef; i++ )
    4033     {
    4034       pcRefPic = getRefPic( REF_PIC_LIST_0, i );
    4035       if ( pcRefPic != NULL )
    4036       {
    4037         if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() )
    4038         {
    4039           existInterViewRef = true;       
    4040         }
    4041       }
    4042     }
    4043 
    4044     for ( Int i = 0; (i < getNumRefIdx( REF_PIC_LIST_1 )) && !existInterViewRef; i++ )
    4045     {
    4046       pcRefPic = getRefPic( REF_PIC_LIST_1, i );
    4047       if ( pcRefPic != NULL )
    4048       {
    4049         if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() )
    4050         {
    4051           existInterViewRef = true;       
    4052         }
    4053       }
    4054     }
    4055 
    4056     if(!existInterViewRef)
    4057     {
    4058       m_bApplyIC = false;
    4059     }
    4060     else
    4061     {
    4062       Int curLayer=getDepth();
    4063       if( curLayer>9) curLayer=9; // Max layer is 10
    4064 
    4065       m_bApplyIC = true;
    4066       Int refLayer = curLayer-1;
    4067 #if MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX
    4068       Int ICEnableCandidate = getICEnableCandidate(refLayer);
    4069       Int ICEnableNum = getICEnableNum(refLayer);
    4070       if( (refLayer>=0) && (ICEnableCandidate>0) )
    4071       {   
    4072         Double ratio=Double(ICEnableNum/Double(ICEnableCandidate));
    4073 
    4074         if( ratio > IC_LOW_LATENCY_ENCODING_THRESHOLD)
    4075         {
    4076           m_bApplyIC=true;
    4077         }
    4078         else
    4079         {
    4080           m_bApplyIC=false;
    4081         }
    4082       }
    4083       setICEnableCandidate(curLayer, 0);
    4084       setICEnableNum(curLayer, 0);
    4085 #else
    4086       if( (refLayer>=0) && (g_aICEnableCANDIDATE[refLayer]>0) )
    4087       {   
    4088         Double ratio=Double(g_aICEnableNUM[refLayer])/Double(g_aICEnableCANDIDATE[refLayer]);
    4089 
    4090         if( ratio > IC_LOW_LATENCY_ENCODING_THRESHOLD)
    4091 {
    4092           m_bApplyIC=true;
    4093         }
    4094         else
    4095         {
    4096           m_bApplyIC=false;
    4097         }
    4098       }
    4099       g_aICEnableNUM[curLayer]=0;
    4100       g_aICEnableCANDIDATE[curLayer]=0;
    4101       g_lastlayer=getDepth();
    4102 #endif
    4103     }
    4104   }
    4105   else
    4106   {
    4107   Int iMaxPelValue = ( 1 << g_bitDepthY );
    4108   Int *aiRefOrgHist;
    4109   Int *aiCurrHist;
    4110   aiRefOrgHist = (Int *) xMalloc( Int,iMaxPelValue );
    4111   aiCurrHist   = (Int *) xMalloc( Int,iMaxPelValue );
    4112   memset( aiRefOrgHist, 0, iMaxPelValue*sizeof(Int) );
    4113   memset( aiCurrHist, 0, iMaxPelValue*sizeof(Int) );
    4114   // Reference Idx Number
    4115   Int iNumRefIdx = getNumRefIdx( REF_PIC_LIST_0 );
    4116   TComPic* pcCurrPic = NULL;
    4117   TComPic* pcRefPic = NULL;
    4118   TComPicYuv* pcCurrPicYuv = NULL;
    4119   TComPicYuv* pcRefPicYuvOrg = NULL;
    4120   pcCurrPic = getPic();
    4121   pcCurrPicYuv = pcCurrPic->getPicYuvOrg();
    4122   Int iWidth = pcCurrPicYuv->getWidth();
    4123   Int iHeight = pcCurrPicYuv->getHeight();
    4124 
    4125 
    4126   // Get InterView Reference picture
    4127   // !!!!! Assume only one Interview Reference Picture in L0
    4128   for ( Int i = 0; i < iNumRefIdx; i++ )
    4129   {
    4130     pcRefPic = getRefPic( REF_PIC_LIST_0, i );
    4131     if ( pcRefPic != NULL )
    4132     {
    4133       if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() )
    4134       {
    4135         pcRefPicYuvOrg = pcRefPic->getPicYuvOrg();
    4136       }
    4137     }
    4138   }
    4139 
    4140   if ( pcRefPicYuvOrg != NULL )
    4141   {
    4142     Pel* pCurrY = pcCurrPicYuv ->getLumaAddr();
    4143     Pel* pRefOrgY = pcRefPicYuvOrg  ->getLumaAddr();
    4144     Int iCurrStride = pcCurrPicYuv->getStride();
    4145     Int iRefStride = pcRefPicYuvOrg->getStride();
    4146     Int iSumOrgSAD = 0;
    4147     Double dThresholdOrgSAD = getIsDepth() ? 0.1 : 0.05;
    4148 
    4149     // Histogram building - luminance
    4150     for ( Int y = 0; y < iHeight; y++ )
    4151     {
    4152       for ( Int x = 0; x < iWidth; x++ )
    4153       {
    4154         aiCurrHist[pCurrY[x]]++;
    4155         aiRefOrgHist[pRefOrgY[x]]++;
    4156       }
    4157       pCurrY += iCurrStride;
    4158       pRefOrgY += iRefStride;
    4159     }
    4160     // Histogram SAD
    4161     for ( Int i = 0; i < iMaxPelValue; i++ )
    4162     {
    4163       iSumOrgSAD += abs( aiCurrHist[i] - aiRefOrgHist[i] );
    4164     }
    4165     // Setting
    4166     if ( iSumOrgSAD > Int( dThresholdOrgSAD * iWidth * iHeight ) )
    4167     {
    4168       m_bApplyIC = true;
    4169     }
    4170     else
    4171     {
    4172       m_bApplyIC = false;
    4173     }
    4174   }
    4175 
    4176   xFree( aiCurrHist   );
    4177   xFree( aiRefOrgHist );
    4178   aiCurrHist = NULL;
    4179   aiRefOrgHist = NULL;
    4180   }//if(bUseLowLatencyICEnc)
    4181 }
    4182 #endif
    4183 #if H_3D
    4184 Void TComSlice::setIvPicLists( TComPicLists* m_ivPicLists )
    4185 {
    4186   for (Int i = 0; i < MAX_NUM_LAYERS; i++ )
    4187   {     
    4188     for ( Int depthId = 0; depthId < 2; depthId++ )
    4189     {
    4190       m_ivPicsCurrPoc[ depthId ][ i ] = ( i <= m_viewIndex ) ? m_ivPicLists->getPic( i, ( depthId == 1) , getPOC() ) : NULL;
    4191     }       
    4192   } 
    4193 }
    4194 Void TComSlice::setDepthToDisparityLUTs()
    4195 {
    4196   Bool setupLUT = false;
    4197   Int layerIdInVPS = getVPS()->getLayerIdInNuh( m_layerId );
    4198 
    4199 #if H_3D_VSP
    4200   setupLUT = setupLUT || getVPS()->getViewSynthesisPredFlag( layerIdInVPS);
    4201 #endif
    4202 
    4203 #if H_3D_NBDV_REF
    4204   setupLUT = setupLUT || getVPS()->getDepthRefinementFlag( layerIdInVPS );
    4205 #endif
    4206 
    4207 #if H_3D_IV_MERGE
    4208   setupLUT = setupLUT || ( getVPS()->getIvMvPredFlag(layerIdInVPS ) && getIsDepth() );
    4209 #endif
    4210 
    4211 #if H_3D_DDD
    4212 #if LGE_FCO_I0116
    4213   if( getIsDepth() && getViewIndex() > 0 && getVPS()->getMPIFlag(layerIdInVPS))
    4214 #else
    4215   if( getIsDepth() && getViewIndex() > 0 )
    4216 #endif
    4217   {
    4218       TComSlice *pcTextSlice = getTexturePic()->getSlice( 0 );
    4219       memcpy( m_aiDDDInvScale, pcTextSlice->m_aiDDDInvScale, sizeof( Int ) * getViewIndex() );
    4220       memcpy( m_aiDDDInvOffset, pcTextSlice->m_aiDDDInvOffset, sizeof( Int ) * getViewIndex() );
    4221       memcpy( m_aiDDDShift, pcTextSlice->m_aiDDDShift, sizeof( Int ) * getViewIndex() );             
    4222   } 
    4223 #endif
    4224 
    4225   if( !setupLUT )
    4226     return;
    4227 
    4228   /// GT: Allocation should be moved to a better place later;
    4229   if ( m_depthToDisparityB == NULL )
    4230   {
    4231     m_depthToDisparityB = new Int*[ getViewIndex() ];
    4232     for ( Int i = 0; i < getViewIndex(); i++ )
    4233     {
    4234       m_depthToDisparityB[ i ] = new Int[ Int(1 << g_bitDepthY) ];
    4235     }
    4236   }
    4237 
    4238   if ( m_depthToDisparityF == NULL )
    4239   {
    4240     m_depthToDisparityF= new Int*[ getViewIndex() ];
    4241     for ( Int i = 0; i < getViewIndex(); i++ )
    4242     {
    4243       m_depthToDisparityF[ i ] = new Int[ Int(1 << g_bitDepthY) ];
    4244     }
    4245   }
    4246 
    4247   assert( m_depthToDisparityB != NULL );
    4248   assert( m_depthToDisparityF != NULL );
    4249 
    4250   TComVPS* vps = getVPS();
    4251 
    4252   Int log2Div = g_bitDepthY - 1 + vps->getCamParPrecision();
    4253   Int viewIndex = getViewIndex();
    4254 
    4255   Bool camParaSH = vps->hasCamParInSliceHeader( viewIndex );
    4256 
    4257   Int* codScale     = camParaSH ? m_aaiCodedScale [ 0 ] : vps->getCodedScale    ( viewIndex );
    4258   Int* codOffset    = camParaSH ? m_aaiCodedOffset[ 0 ] : vps->getCodedOffset   ( viewIndex );
    4259   Int* invCodScale  = camParaSH ? m_aaiCodedScale [ 1 ] : vps->getInvCodedScale ( viewIndex );
    4260   Int* invCodOffset = camParaSH ? m_aaiCodedOffset[ 1 ] : vps->getInvCodedOffset( viewIndex );
    4261 
    4262   for (Int i = 0; i <= ( getViewIndex() - 1); i++)
    4263   {
    4264     for ( Int d = 0; d <= ( ( 1 << g_bitDepthY ) - 1 ); d++ )
    4265     {
    4266       Int offset =    ( codOffset  [ i ] << g_bitDepthY ) + ( ( 1 << log2Div ) >> 1 );         
    4267       m_depthToDisparityB[ i ][ d ] = ( codScale [ i ] * d + offset ) >> log2Div;
    4268 
    4269       Int invOffset = ( invCodOffset[ i ] << g_bitDepthY ) + ( ( 1 << log2Div ) >> 1 );         
    4270       m_depthToDisparityF[ i ][ d ] = ( invCodScale[ i ] * d + invOffset ) >> log2Div;
    4271     }
    4272 
    4273 #if H_3D_DDD
    4274     initializeDDDPara( vps->getCamParPrecision(), codScale[ i ], codOffset[ i ], i );
    4275 #endif
    4276   }
    4277 }
    4278 #endif
    4279 #endif
    4280 
    4281 #if H_3D_DDD
    4282 Void TComSlice::initializeDDDPara( UInt uiCamParsCodedPrecision, Int  iCodedScale,Int  iCodedOffset, Int iBaseViewIdx )
    4283 {
    4284     UInt uiViewId     = getViewIndex();
    4285 
    4286     if( uiViewId == 0 )
    4287     {
    4288         m_aiDDDInvScale[ iBaseViewIdx ] = m_aiDDDInvOffset[ iBaseViewIdx ] = m_aiDDDShift[ iBaseViewIdx ] = 0;
    4289         return;
    4290     }
    4291 
    4292 
    4293     Int iSign = iCodedScale >= 0 ? 1 : -1;
    4294     iCodedScale = abs( iCodedScale );
    4295 
    4296     Int iBitWidth = 0;
    4297 
    4298     const Int iInvPres = 9;
    4299 
    4300     while( ((( 1 << iBitWidth ) << 1 ) <= iCodedScale ) )
    4301     {
    4302         iBitWidth ++;
    4303     }
    4304     iBitWidth += iInvPres;
    4305     Int iTargetValue =  1 << iBitWidth;
    4306 
    4307     Int iMinError = MAX_INT;
    4308     Int iBestD = 1 << ( iInvPres - 1 );
    4309     for( Int d = 1 << ( iInvPres - 1 ); d < ( 1 << iInvPres ); d++ )
    4310     {
    4311         Int iError = abs( iCodedScale * d - iTargetValue );
    4312         if( iError < iMinError )
    4313         {
    4314             iMinError = iError;
    4315             iBestD = d;
    4316         }
    4317         if( iMinError == 0 )
    4318         {
    4319             break;
    4320         }
    4321     }
    4322     Int iRoundingDir = 0;
    4323     if( iCodedScale * iBestD > iTargetValue )
    4324     {
    4325         iRoundingDir = -1;
    4326     }
    4327     else if( iCodedScale * iBestD < iTargetValue )
    4328     {
    4329         iRoundingDir = 1;
    4330     }
    4331     Int iCamPres = uiCamParsCodedPrecision - 1;
    4332     m_aiDDDInvScale [ iBaseViewIdx ] = ( iBestD << ( iCamPres + g_bitDepthY )) * iSign;
    4333     m_aiDDDInvOffset[ iBaseViewIdx ] = -iSign * iBestD * ( iCodedOffset << g_bitDepthY );
    4334     m_aiDDDShift    [ iBaseViewIdx ] = iBitWidth;
    4335     m_aiDDDInvOffset[ iBaseViewIdx ] += 1 << ( m_aiDDDShift[ iBaseViewIdx ] - 1 );
    4336     m_aiDDDInvOffset[ iBaseViewIdx ] += ( 1 << ( m_aiDDDShift[ iBaseViewIdx ] - 4 ) ) * iRoundingDir;
    4337 
    4338     return;
    4339 }
    4340 
    4341 
    4342 #endif
     3490#endif
     3491
    43433492
    43443493#if H_MV
     
    43743523#endif
    43753524
    4376 #if H_3D_DBBP
    4377 Int TComSlice::getDepthFromDV( Int iDV, Int iBaseViewIdx )
    4378 {
    4379   return ClipY(( iDV * m_aiDDDInvScale[ iBaseViewIdx ] + m_aiDDDInvOffset[ iBaseViewIdx ] ) >> m_aiDDDShift[ iBaseViewIdx ]);
    4380 }
    4381 #endif
    43823525
    43833526/** get scaling matrix from RefMatrixID
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComSlice.h

    r1066 r1072  
    10031003#endif
    10041004  // VPS EXTENSION 2 SYNTAX ELEMENTS
    1005 #if H_3D_ARP
    1006   UInt        m_uiUseAdvResPred          [MAX_NUM_LAYERS   ];
    1007   UInt        m_uiARPStepNum             [MAX_NUM_LAYERS   ];
    1008 #endif
    1009 #if H_3D_IV_MERGE
    1010   Bool        m_ivMvPredFlag             [ MAX_NUM_LAYERS ];
    1011 #if SEC_HLS_CLEANUP_I0100
    1012   Bool        m_ivMvScalingFlag          [ MAX_NUM_LAYERS ];
    1013 #endif
    1014 #if H_3D_SPIVMP
    1015   Int         m_iSubPULog2Size           [MAX_NUM_LAYERS   ];
    1016 #if MTK_I0099_VPS_EX2
    1017   Int         m_iSubPUMPILog2Size        [MAX_NUM_LAYERS   ];
    1018 #else
    1019   Int         m_iSubPUMPILog2Size;
    1020 #endif
    1021 #endif
    1022 #endif
    1023 #if MTK_I0099_VPS_EX2
    1024   Bool        m_bLimQtPredFlag           [ MAX_NUM_LAYERS ];
    1025 #endif
    1026 #if H_3D_VSP
    1027   Bool        m_viewSynthesisPredFlag    [ MAX_NUM_LAYERS ];
    1028 #endif
    1029 #if H_3D_NBDV_REF
    1030   Bool        m_depthRefinementFlag      [ MAX_NUM_LAYERS ];
    1031 #endif
    10321005  Bool        m_vpsDepthModesFlag        [MAX_NUM_LAYERS   ];
    1033 #if SEPARATE_FLAG_I0085
    1034   Bool        m_bIVPFlag                 [MAX_NUM_LAYERS   ];
    1035 #endif
    1036 
    1037 #if H_3D
    1038   UInt        m_uiCamParPrecision;
    1039   Bool*       m_bCamParInSliceHeader;
    1040   Bool*       m_bCamParPresent;
    1041   Int         ***m_aaaiCodedScale ;
    1042   Int         ***m_aaaiCodedOffset;
    1043 
    1044 #if !SEC_HLS_CLEANUP_I0100
    1045   Bool        m_ivMvScalingFlag;
    1046 #endif
    1047 
    1048 #endif
    1049 #if H_3D_INTER_SDC
    1050   Bool        m_bInterSDCFlag[MAX_NUM_LAYERS   ];
    1051 #endif
    1052 #if H_3D_DBBP
    1053   Bool        m_dbbpFlag[MAX_NUM_LAYERS];
    1054 #endif
    1055 #if H_3D_IV_MERGE
    1056   Bool        m_bMPIFlag[MAX_NUM_LAYERS   ];
    1057 #endif
     1006
    10581007
    10591008#endif
     
    14401389
    14411390  /// VPS EXTENSION 2 SYNTAX ELEMENTS
    1442 #if H_3D 
    1443   Int     getDepthId      ( Int layerIdInNuh)                             { return getScalabilityId( getLayerIdInVps(layerIdInNuh), DEPTH_ID ); }
    1444   Int     getLayerIdInNuh( Int viewIndex, Bool depthFlag );   
    1445 
    1446 #if H_3D_ARP
    1447   UInt    getUseAdvRP  ( Int layerIdInVps )                                { return m_uiUseAdvResPred[layerIdInVps];    }
    1448   UInt    getARPStepNum( Int layerIdInVps )                                { return m_uiARPStepNum[layerIdInVps];       }
    1449   Void    setUseAdvRP  ( Int layerIdInVps, UInt val )                      { m_uiUseAdvResPred[layerIdInVps] = val;     }
    1450   Void    setARPStepNum( Int layerIdInVps, UInt val )                      { m_uiARPStepNum[layerIdInVps]    = val;     }
    1451 #endif
    1452 
    1453   Void createCamPars(Int iNumViews);
    1454   Void deleteCamPars();
    1455   Void initCamParaVPS      (  UInt uiViewIndex, Bool bCamParPresent = false, UInt uiCamParPrecision = 0, Bool bCamParSlice = false, Int** aaiScale = 0, Int** aaiOffset = 0 );
    1456   UInt getCamParPrecision    ()  { return m_uiCamParPrecision; }
    1457   Bool getCamParPresent      ( Int viewIndex )  { return m_bCamParPresent[viewIndex]; }
    1458   Void setCamParPresent      ( Int viewIndex, Bool val )  { m_bCamParPresent[viewIndex] = val; }
    1459   Bool hasCamParInSliceHeader( Int viewIndex )  { return m_bCamParInSliceHeader[viewIndex]; }
    1460   Void setHasCamParInSliceHeader( Int viewIndex, Bool b )  { m_bCamParInSliceHeader[viewIndex] = b; }
    1461   Int* getCodedScale         ( Int viewIndex )  { return m_aaaiCodedScale [viewIndex][0]; }
    1462   Int* getCodedOffset        ( Int viewIndex )  { return m_aaaiCodedOffset[viewIndex][0]; }
    1463   Int* getInvCodedScale      ( Int viewIndex )  { return m_aaaiCodedScale [viewIndex][1]; }
    1464   Int* getInvCodedOffset     ( Int viewIndex )  { return m_aaaiCodedOffset[viewIndex][1]; }
    1465 
    1466 #if H_3D_IV_MERGE
    1467   Void    setIvMvPredFlag     ( Int layerIdInVps, Bool val )  { m_ivMvPredFlag[ layerIdInVps ] = val; }
    1468   Bool    getIvMvPredFlag     ( Int layerIdInVps )            { return m_ivMvPredFlag[ layerIdInVps ]; };
    1469 #if H_3D_SPIVMP
    1470   Int     getSubPULog2Size(Int layerIdInVps)           { return m_iSubPULog2Size[layerIdInVps]; }
    1471   Void    setSubPULog2Size(Int layerIdInVps, Int u)    { m_iSubPULog2Size[layerIdInVps] = u;}
    1472 #if MTK_I0099_VPS_EX2
    1473   Int     getSubPUMPILog2Size(Int layerIdInVps)           { return m_iSubPUMPILog2Size[layerIdInVps]; }
    1474   Void    setSubPUMPILog2Size(Int layerIdInVps, Int u)    { m_iSubPUMPILog2Size[layerIdInVps] = u;}
    1475 #else
    1476   Int     getSubPUMPILog2Size( )           { return m_iSubPUMPILog2Size; }
    1477   Void    setSubPUMPILog2Size( Int u )     { m_iSubPUMPILog2Size = u;    }
    1478 #endif
    1479 #endif
    1480 #endif
    1481 #if MTK_I0099_VPS_EX2
    1482   Void    setLimQtPredFlag    ( Int layerIdInVps, Bool val )  { m_bLimQtPredFlag[ layerIdInVps ] = val; }
    1483   Bool    getLimQtPredFlag    ( Int layerIdInVps ) { return m_bLimQtPredFlag[layerIdInVps];}
    1484 #endif
    1485 #if H_3D_VSP
    1486   Void    setViewSynthesisPredFlag  ( Int layerIdInVps, Bool val )  { m_viewSynthesisPredFlag[ layerIdInVps ] = val; }
    1487   Bool    getViewSynthesisPredFlag  ( Int layerIdInVps )            { return m_viewSynthesisPredFlag[ layerIdInVps ]; };
    1488 #endif
    1489 #if H_3D_NBDV_REF
    1490   Void    setDepthRefinementFlag  ( Int layerIdInVps, Bool val )  { m_depthRefinementFlag[ layerIdInVps ] = val; }
    1491   Bool    getDepthRefinementFlag  ( Int layerIdInVps )            { return m_depthRefinementFlag[ layerIdInVps ]; };
    1492 #endif
    1493   Void    setVpsDepthModesFlag( Int layerIdInVps, Bool val )               { m_vpsDepthModesFlag[ layerIdInVps ] = val; }
    1494   Bool    getVpsDepthModesFlag( Int layerIdInVps )                         { return m_vpsDepthModesFlag[ layerIdInVps ]; }
    1495 #if SEPARATE_FLAG_I0085
    1496   Void    setIVPFlag( Int layerIdInVps, Bool val )                    { m_bIVPFlag[ layerIdInVps ] = val; }
    1497   Bool    getIVPFlag( Int layerIdInVps )                              { return m_bIVPFlag[ layerIdInVps ]; }
    1498 #endif
    1499 
    1500 #if SEC_HLS_CLEANUP_I0100
    1501   Bool    getIvMvScalingFlag   ( Int layerIdInVps )                        { return m_ivMvScalingFlag[ layerIdInVps ]; }
    1502   Void    setIvMvScalingFlag   (Int layerIdInVps, Bool b )                 { m_ivMvScalingFlag[ layerIdInVps ] = b;    } 
    1503 #else
    1504   Bool    getIvMvScalingFlag   (  )                       { return m_ivMvScalingFlag; }
    1505   Void    setIvMvScalingFlag   ( Bool b )                 { m_ivMvScalingFlag = b;    } 
    1506 #endif
    1507 
    1508 #if H_3D_INTER_SDC
    1509   Bool    getInterSDCFlag      ( Int layerIdInVps )           { return m_bInterSDCFlag[layerIdInVps]; }
    1510   Void    setInterSDCFlag      ( Int layerIdInVps, Bool bval ){ m_bInterSDCFlag[layerIdInVps] = bval; }
    1511 #endif
    1512 #if H_3D_DBBP
    1513   Bool getUseDBBP              ( Int layerIdInVps )         { return m_dbbpFlag[layerIdInVps]; }
    1514   Void setUseDBBP              ( Int layerIdInVps, Bool bval ){ m_dbbpFlag[layerIdInVps] = bval; }
    1515 #endif
    1516 #if H_3D_IV_MERGE
    1517   Bool    getMPIFlag      ( Int layerIdInVps )           { return m_bMPIFlag[layerIdInVps]; }
    1518   Void    setMPIFlag      ( Int layerIdInVps, Bool bval ){ m_bMPIFlag[layerIdInVps] = bval; }
    1519 #endif
    1520 #endif 
    15211391#endif
    15221392};
    15231393
    1524 #if H_3D
    1525 class TComDLT
    1526 {
    1527 private:
    1528   Bool        m_bDltPresentFlag;
    1529   Bool        m_bUseDLTFlag              [ MAX_NUM_LAYERS ];
    1530   Bool        m_bInterViewDltPredEnableFlag[ MAX_NUM_LAYERS ];
    1531 
    1532 #if !FIX_TICKET_77
    1533   Int         m_iBitsPerDepthValue       [ MAX_NUM_LAYERS ];
    1534 #endif
    1535   Int         m_iNumDepthmapValues       [ MAX_NUM_LAYERS ];
    1536   Int*        m_iDepthValue2Idx          [ MAX_NUM_LAYERS ];
    1537   Int*        m_iIdx2DepthValue          [ MAX_NUM_LAYERS ];
    1538 
    1539   Int         m_iNumDepthViews;
    1540   UInt        m_uiDepthViewBitDepth;
    1541 
    1542 public:
    1543   TComDLT();
    1544   ~TComDLT();
    1545 
    1546   Bool    getDltPresentFlag  ()                           { return m_bDltPresentFlag; }
    1547   Void    setDltPresentFlag  ( Bool b )                   { m_bDltPresentFlag = b;    }
    1548 
    1549   Bool    getUseDLTFlag      ( Int layerIdInVps )         { return m_bUseDLTFlag[ layerIdInVps ]; }
    1550   Void    setUseDLTFlag      ( Int layerIdInVps, Bool b ) { m_bUseDLTFlag[ layerIdInVps ]  = b;   }
    1551  
    1552   Bool    getInterViewDltPredEnableFlag( Int layerIdInVps )         { return m_bInterViewDltPredEnableFlag[ layerIdInVps ]; }
    1553   Void    setInterViewDltPredEnableFlag( Int layerIdInVps, Bool b ) { m_bInterViewDltPredEnableFlag[ layerIdInVps ] = b;    }
    1554 
    1555   Void    setNumDepthViews   ( Int n )                    { m_iNumDepthViews = n; }
    1556   Int     getNumDepthViews   ()                           { return m_iNumDepthViews; }
    1557 
    1558   Void    setDepthViewBitDepth( UInt n )                  { m_uiDepthViewBitDepth = n; }
    1559   UInt    getDepthViewBitDepth()                          { return m_uiDepthViewBitDepth; }
    1560 
    1561 #if !FIX_TICKET_77
    1562   Int     getBitsPerDepthValue( Int layerIdInVps )        { return getUseDLTFlag(layerIdInVps)?m_iBitsPerDepthValue[layerIdInVps]:g_bitDepthY; }
    1563 #endif
    1564   Int     getNumDepthValues( Int layerIdInVps )           { return getUseDLTFlag(layerIdInVps)?m_iNumDepthmapValues[layerIdInVps]:((1 << g_bitDepthY)-1); }
    1565   Int     depthValue2idx( Int layerIdInVps, Pel value )   { return getUseDLTFlag(layerIdInVps)?m_iDepthValue2Idx[layerIdInVps][value]:value; }
    1566 #if RWTH_DLT_CLIP_I0057
    1567   Pel     idx2DepthValue( Int layerIdInVps, UInt uiIdx )  { return getUseDLTFlag(layerIdInVps)?m_iIdx2DepthValue[layerIdInVps][ClipY(uiIdx)]:uiIdx; }
    1568 #else
    1569   Pel     idx2DepthValue( Int layerIdInVps, UInt uiIdx )  { return getUseDLTFlag(layerIdInVps)?m_iIdx2DepthValue[layerIdInVps][uiIdx]:uiIdx; }
    1570 #endif
    1571   Void    setDepthLUTs( Int layerIdInVps, Int* idx2DepthValue = NULL, Int iNumDepthValues = 0 );
    1572 #if H_3D_DELTA_DLT
    1573   Int*    idx2DepthValue( Int layerIdInVps )  { return m_iIdx2DepthValue[layerIdInVps]; }
    1574   Void    getDeltaDLT( Int layerIdInVps, Int* piDLTInRef, UInt uiDLTInRefNum, Int* piDeltaDLTOut, UInt *puiDeltaDLTOutNum );
    1575   Void    setDeltaDLT( Int layerIdInVps, Int* piDLTInRef, UInt uiDLTInRefNum, Int* piDeltaDLTIn, UInt uiDeltaDLTInNum );
    1576 #endif
    1577 };
    1578 #endif
    15791394
    15801395class Window
     
    18331648  Bool        m_useAMP;
    18341649
    1835 #if !MTK_I0099_VPS_EX2
    1836 #if H_3D_QTLPC
    1837   Bool        m_bUseQTL;
    1838   Bool        m_bUsePC;
    1839 #endif
    1840 #endif
    18411650  // Parameter
    18421651  Int         m_bitDepthY;
     
    18881697  Bool        m_spsRangeExtensionsFlag;
    18891698  Bool        m_spsMultilayerExtensionFlag;
    1890 #if H_3D
    1891   Bool        m_sps3dExtensionFlag;
    1892   Int         m_spsExtension5bits;
    1893 #else
    18941699  Int         m_spsExtension6bits;
    1895 #endif
    18961700
    18971701  Bool        m_spsInferScalingListFlag;
     
    19091713  Int         m_scaledRefLayerBottomOffset[MAX_NUM_LAYERS];
    19101714#endif
    1911 #endif
    1912 #if H_3D
    1913   UInt        m_uiCamParPrecision;
    1914   Bool        m_bCamParInSliceHeader;
    1915   Int         m_aaiCodedScale [2][MAX_NUM_LAYERS];
    1916   Int         m_aaiCodedOffset[2][MAX_NUM_LAYERS];
    19171715#endif
    19181716#if H_MV
     
    20641862  Void setSpsMultilayerExtensionFlag( Bool flag )        { m_spsMultilayerExtensionFlag = flag; }
    20651863  Bool getSpsMultilayerExtensionFlag( )                  { return m_spsMultilayerExtensionFlag; }
    2066 #if H_3D
    2067   Void setSps3dExtensionFlag( Bool flag )                { m_sps3dExtensionFlag = flag; }
    2068   Bool getSps3dExtensionFlag(  )                        { return m_sps3dExtensionFlag; }
    2069 
    2070   Void setSpsExtension5bits( Int  val )                  { m_spsExtension5bits = val; }
    2071   Int  getSpsExtension5bits(  )                          { return m_spsExtension5bits; }
    2072 #else
    20731864  Void setSpsExtension6bits( Int  val )                  { m_spsExtension6bits = val; }
    20741865  Int  getSpsExtension6bits(  )                          { return m_spsExtension6bits; }
    2075 #endif
    20761866 
    20771867  Void      setVPS          ( TComVPS* pcVPS ) { m_pcVPS = pcVPS; }
     
    21191909  Void checkRpsMaxNumPics( TComVPS* vps, Int currLayerId );
    21201910
    2121 #endif
    2122 #if !MTK_I0099_VPS_EX2
    2123 #if H_3D_QTLPC
    2124   Void setUseQTL( Bool b ) { m_bUseQTL = b;    }
    2125   Bool getUseQTL()         { return m_bUseQTL; }
    2126   Void setUsePC ( Bool b ) { m_bUsePC  = b;    }
    2127   Bool getUsePC ()         { return m_bUsePC;  }
    2128 #endif
    21291911#endif
    21301912#if H_MV
     
    22342016  Bool m_ppsRangeExtensionsFlag;
    22352017  Bool m_ppsMultilayerExtensionFlag;
    2236 #if !H_3D
    22372018  Int  m_ppsExtension6bits;
    2238 #else
    2239   Bool m_pps3dExtensionFlag;
    2240   Int  m_ppsExtension5bits;
    2241 #endif
    22422019
    22432020  Bool m_pocResetInfoPresentFlag;
    22442021#endif
    22452022
    2246 #if H_3D
    2247   TComDLT*  m_pcDLT;
    2248 #endif
    22492023
    22502024public:
     
    22732047  UInt      getMinCuDQPSize     ()         { return m_uiMinCuDQPSize; }
    22742048
    2275 #if H_3D
    2276   Void      setDLT              ( TComDLT* pcDLT ) { m_pcDLT = pcDLT; }
    2277   TComDLT*  getDLT              ()                 { return m_pcDLT; }
    2278 #endif
    22792049
    22802050  Void      setChromaCbQpOffset( Int i ) { m_chromaCbQpOffset = i;    }
     
    23902160  Bool getPpsMultilayerExtensionFlag(  ) { return m_ppsMultilayerExtensionFlag; }
    23912161
    2392 #if !H_3D
    23932162  Void setPpsExtension6bits( Int  val ) { m_ppsExtension6bits = val; }
    23942163  Int  getPpsExtension6bits(  ) { return m_ppsExtension6bits; }
    2395 #else
    2396   Void setPps3dExtensionFlag( Bool flag ) { m_pps3dExtensionFlag = flag; }
    2397   Bool getPps3dExtensionFlag(  ) { return m_pps3dExtensionFlag; }
    2398 
    2399   Void setPpsExtension5bits( Int  val ) { m_ppsExtension5bits = val; }
    2400   Int  getPpsExtension5bits(  ) { return m_ppsExtension5bits; }
    2401 #endif
    24022164
    24032165  Void setPocResetInfoPresentFlag( Bool flag ) { m_pocResetInfoPresentFlag = flag; }
     
    25472309  Int        m_viewId;
    25482310  Int        m_viewIndex;
    2549 #if H_3D
    2550   Bool       m_isDepth;
    2551 #endif
    25522311
    25532312// Additional slice header syntax elements
     
    25702329  Bool       m_pocMsbValRequiredFlag;
    25712330
    2572 #if H_3D
    2573   Int        m_aaiCodedScale [2][MAX_NUM_LAYERS];
    2574   Int        m_aaiCodedOffset[2][MAX_NUM_LAYERS];
    2575 #endif
    2576 #if H_3D_TMVP
    2577   Int        m_aiAlterRefIdx   [2];
    2578 #endif
    2579 #if H_3D_ARP
    2580   Bool m_arpRefPicAvailable[2][MAX_NUM_LAYERS];
    2581   TComList<TComPic*> * m_pBaseViewRefPicList[MAX_NUM_LAYERS];
    2582   UInt                 m_nARPStepNum;
    2583   Int         m_aiFirstTRefIdx    [2];
    2584 #endif
    2585 #if H_3D_IC
    2586   Bool      m_bApplyIC;
    2587   Bool      m_icSkipParseFlag;
    2588 #endif
    2589 #if H_3D
    2590   TComPic*   m_ivPicsCurrPoc [2][MAX_NUM_LAYERS]; 
    2591   Int**      m_depthToDisparityB;
    2592   Int**      m_depthToDisparityF;
    2593 #endif
    2594 #endif
    2595 
    2596 #if H_3D_DDD
    2597   Int          m_aiDDDInvScale [MAX_NUM_LAYERS];
    2598   Int          m_aiDDDInvOffset[MAX_NUM_LAYERS];
    2599   UInt         m_aiDDDShift    [MAX_NUM_LAYERS];
    2600 #endif
    2601 #if MTK_SINGLE_DEPTH_MODE_I0095
    2602   Bool      m_bApplySingleDepthMode;
    2603 #endif
    2604 #if MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX
    2605   Int *m_aICEnableCandidate;
    2606   Int *m_aICEnableNum;
    2607 #endif
     2331#endif
     2332
    26082333public:
    26092334  TComSlice();
     
    26702395  TComPic*  getRefPic           ( RefPicList e, Int iRefIdx)    { return  m_apcRefPicList[e][iRefIdx];  }
    26712396  Int       getRefPOC           ( RefPicList e, Int iRefIdx)    { return  m_aiRefPOCList[e][iRefIdx];   }
    2672 #if H_3D
    2673   TComPic*  getIvPic            ( Bool depthFlag, Int viewIndex){ return  m_ivPicsCurrPoc[ depthFlag ? 1 : 0 ][ viewIndex ]; }
    2674 #endif
    2675 #if H_3D
    2676   TComPic*  getTexturePic       ()                              { return  m_ivPicsCurrPoc[0][ m_viewIndex ]; }
    2677 #endif
    2678 #if MTK_SINGLE_DEPTH_MODE_I0095
    2679   Void      setApplySingleDepthMode( Bool b )                                { m_bApplySingleDepthMode = b; }
    2680   Bool      getApplySingleDepthMode()                                        { return m_bApplySingleDepthMode; }
    2681 #endif
    2682 #if H_3D_IC
    2683   Void      setApplyIC( Bool b )                                { m_bApplyIC = b; }
    2684   Bool      getApplyIC()                                        { return m_bApplyIC; }
    2685   Void      xSetApplyIC();
    2686   Void      xSetApplyIC(Bool bUseLowLatencyICEnc);
    2687   Void      setIcSkipParseFlag( Bool b )                        { m_icSkipParseFlag = b; }
    2688   Bool      getIcSkipParseFlag()                                { return m_icSkipParseFlag; }
    2689 #endif
    2690 #if H_3D_ARP
    2691   Void      setBaseViewRefPicList( TComList<TComPic*> *pListPic, Int iViewIdx )      { m_pBaseViewRefPicList[iViewIdx] = pListPic;                   }
    2692   Void      setARPStepNum( TComPicLists*ivPicLists );
    2693   TComPic*  getBaseViewRefPic    ( UInt uiPOC , Int iViewIdx )                       { return xGetRefPic( *m_pBaseViewRefPicList[iViewIdx], uiPOC ); }
    2694   UInt      getARPStepNum( )                                                         { return m_nARPStepNum;                                         } 
    2695 #endif
    26962397  Int       getDepth            ()                              { return  m_iDepth;                     }
    26972398  UInt      getColFromL0Flag    ()                              { return  m_colFromL0Flag;              }
     
    28902591  Void      setViewIndex          ( Int viewIndex )  { m_viewIndex = viewIndex;   }
    28912592  Int       getViewIndex          ()                 { return m_viewIndex;     }
    2892 #if H_3D
    2893 #if H_3D_TMVP
    2894   Void      generateAlterRefforTMVP ();   
    2895   Void      setAlterRefIdx          ( RefPicList e, Int i ) { m_aiAlterRefIdx[e]    = i;      }
    2896   Int       getAlterRefIdx          ( RefPicList e )        { return  m_aiAlterRefIdx[e];     }
    2897 #endif
    2898 #if H_3D_ARP
    2899   Int       getFirstTRefIdx        ( RefPicList e )                { return  m_aiFirstTRefIdx[e];     }
    2900   Void      setFirstTRefIdx        ( RefPicList e, Int i )         { m_aiFirstTRefIdx[e]    = i;      }
    2901   Bool      getArpRefPicAvailable( RefPicList e, Int viewIdx) {return m_arpRefPicAvailable[e][getVPS()->getLayerIdInNuh(viewIdx, 0)]; }
    2902 #endif
    2903   Void      setIsDepth            ( Bool isDepth )   { m_isDepth = isDepth; }
    2904   Bool      getIsDepth            ()                 { return m_isDepth; }
    2905   Void      setCamparaSlice       ( Int** aaiScale = 0, Int** aaiOffset = 0 );
    2906   Int*      getCodedScale         ()  { return m_aaiCodedScale [0]; }
    2907   Int*      getCodedOffset        ()  { return m_aaiCodedOffset[0]; }
    2908   Int*      getInvCodedScale      ()  { return m_aaiCodedScale [1]; }
    2909   Int*      getInvCodedOffset     ()  { return m_aaiCodedOffset[1]; }
    2910 #endif
    2911 #endif
    2912 #if H_3D
    2913   Void    setIvPicLists( TComPicLists* m_ivPicLists );
    2914   Void    setDepthToDisparityLUTs();
    2915 
    2916   Int* getDepthToDisparityB( Int refViewIdx ) { return m_depthToDisparityB[ refViewIdx ]; };
    2917   Int* getDepthToDisparityF( Int refViewIdx ) { return m_depthToDisparityF[ refViewIdx ]; };
    2918   Bool getVpsDepthModesFlag  ()  { return getVPS()->getVpsDepthModesFlag( getVPS()->getLayerIdInVps( m_layerId ) ); }
    2919 #if SEPARATE_FLAG_I0085
    2920   Bool getIVPFlag       ()  { return getVPS()->getIVPFlag( getVPS()->getLayerIdInVps( m_layerId ) ); }
    2921 #endif
    2922 #endif
    2923 #if MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX
    2924   Void    setICEnableCandidate( Int* ICEnableCandidate)   { m_aICEnableCandidate = ICEnableCandidate; };
    2925   Void    setICEnableNum( Int* ICEnableNum)   { m_aICEnableNum = ICEnableNum; };
    2926   Void    setICEnableCandidate( UInt layer, Int value)   { m_aICEnableCandidate[ layer ] = value; };
    2927   Void    setICEnableNum( UInt layer, Int value)   { m_aICEnableNum[ layer ] = value; };
    2928 
    2929   Int    getICEnableCandidate( Int layer){ return  m_aICEnableCandidate[ layer ]; };
    2930   Int    getICEnableNum( Int layer){ return m_aICEnableNum[ layer ]; };
    29312593#endif
    29322594#if H_MV
     
    30152677  Bool inferPocMsbValPresentFlag(); 
    30162678#endif
    3017 #if H_3D_DDD
    3018   Void initializeDDDPara( UInt uiCamParsCodedPrecision, Int  iCodedScale,Int  iCodedOffset, Int iBaseViewIdx );
    3019   Int  getDepthFromDV( Int iDV, Int iBaseViewIdx );
    3020 #endif
    30212679
    30222680protected:
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComWedgelet.cpp

    r1039 r1072  
    4545using namespace std;
    4646
    47 #if H_3D_DIM_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_uiAng    ( rcWedge.m_uiAng     ),
    67                                                             m_uiWidth  ( rcWedge.m_uiWidth   ),
    68                                                             m_uiHeight ( rcWedge.m_uiHeight  ),
    69                                                             m_pbPattern( (Bool*)xMalloc( Bool, (m_uiWidth * m_uiHeight) ) )
    70 #if SHARP_DMM1_I0110
    71                                                             ,m_pbScaledPattern( g_wedgePattern )
    72 #endif
    73 {
    74   ::memcpy( m_pbPattern, rcWedge.m_pbPattern, sizeof(Bool) * (m_uiWidth * m_uiHeight));
    75 }
    76 
    77 TComWedgelet::~TComWedgelet(void)
    78 {
    79   destroy();
    80 }
    81 
    82 Void TComWedgelet::create( UInt uiWidth, UInt uiHeight )
    83 {
    84   assert( uiWidth > 0 && uiHeight > 0 );
    85 
    86   m_uiWidth   = uiWidth;
    87   m_uiHeight  = uiHeight;
    88 
    89   m_pbPattern = (Bool*)xMalloc( Bool, (m_uiWidth * m_uiHeight) );
    90 #if SHARP_DMM1_I0110
    91   m_pbScaledPattern = g_wedgePattern;
    92 #endif
    93 }
    94 
    95 Void TComWedgelet::destroy()
    96 {
    97   if( m_pbPattern ) { xFree( m_pbPattern ); m_pbPattern = NULL; }
    98 }
    99 
    100 Void TComWedgelet::clear()
    101 {
    102   ::memset( m_pbPattern, 0, (m_uiWidth * m_uiHeight) * sizeof(Bool) );
    103 }
    104 
    105 Void TComWedgelet::findClosestAngle()
    106 {
    107   UInt uiAng=0,uiOptAng=0;
    108   UInt uiMinD=MAX_UINT;
    109   UInt uiTmpD=0;
    110   Int angTable[9]    = {0,    2,    5,   9,  13,  17,  21,  26,  32};
    111  
    112   UChar uhXs = m_uhXs;
    113   UChar uhYs = m_uhYs;
    114   UChar uhXe = m_uhXe;
    115   UChar uhYe = m_uhYe;
    116 
    117   for(uiAng=2; uiAng<=34; uiAng++)
    118   {
    119     Int iSign    = (uiAng<VER_IDX && uiAng>HOR_IDX ) ? -1 : 1;
    120     Int iVer     = uiAng>17 ? 32 : angTable[(uiAng>10) ? (uiAng-10) : (10-uiAng)];
    121     Int iHor     = uiAng<19 ? 32 : angTable[(uiAng>26) ? (uiAng-26) : (26-uiAng)];
    122 
    123     uiTmpD  = abs(iVer*iSign*(uhXs-uhXe) - iHor*(uhYe-uhYs));
    124    
    125     if( uiTmpD < uiMinD )
    126     {
    127       uiMinD = uiTmpD;
    128       uiOptAng = uiAng;
    129     }
    130   }
    131   m_uiAng = uiOptAng;
    132 }
    133 
    134 Void TComWedgelet::setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse )
    135 {
    136   m_uhXs      = uhXs;
    137   m_uhYs      = uhYs;
    138   m_uhXe      = uhXe;
    139   m_uhYe      = uhYe;
    140   m_uhOri     = uhOri;
    141   m_eWedgeRes = eWedgeRes;
    142   m_bIsCoarse = bIsCoarse;
    143 
    144   xGenerateWedgePattern();
    145 }
    146 
    147 Bool TComWedgelet::checkNotPlain()
    148 {
    149   for( UInt k = 1; k < (m_uiWidth * m_uiHeight); k++ )
    150   {
    151     if( m_pbPattern[0] != m_pbPattern[k] )
    152     {
    153       return true;
    154     }
    155   }
    156   return false;
    157 }
    158 
    159 Bool TComWedgelet::checkIdentical( Bool* pbRefPattern )
    160 {
    161   for( UInt k = 0; k < (m_uiWidth * m_uiHeight); k++ )
    162   {
    163     if( m_pbPattern[k] != pbRefPattern[k] )
    164     {
    165       return false;
    166     }
    167   }
    168   return true;
    169 }
    170 
    171 Bool TComWedgelet::checkInvIdentical( Bool* pbRefPattern )
    172 {
    173   for( UInt k = 0; k < (m_uiWidth * m_uiHeight); k++ )
    174   {
    175     if( m_pbPattern[k] == pbRefPattern[k] )
    176     {
    177       return false;
    178     }
    179   }
    180   return true;
    181 }
    182 
    183 Void TComWedgelet::xGenerateWedgePattern()
    184 {
    185   UInt uiTempBlockSize = 0;
    186   UChar uhXs = 0, uhYs = 0, uhXe = 0, uhYe = 0;
    187   switch( m_eWedgeRes )
    188   {
    189 #if !SHARP_DMM1_I0110
    190   case( DOUBLE_PEL ): { uiTempBlockSize =  m_uiWidth;     uhXs = (m_uhXs<<1); uhYs = (m_uhYs<<1); uhXe = (m_uhXe<<1); uhYe = (m_uhYe<<1); } break;
    191 #endif
    192   case(   FULL_PEL ): { uiTempBlockSize =  m_uiWidth;     uhXs =  m_uhXs;     uhYs =  m_uhYs;     uhXe =  m_uhXe;     uhYe =  m_uhYe;     } break;
    193   case(   HALF_PEL ): { uiTempBlockSize = (m_uiWidth<<1); uhXs =  m_uhXs;     uhYs =  m_uhYs;     uhXe =  m_uhXe;     uhYe =  m_uhYe;     } break;
    194   }
    195 
    196 #if !SHARP_DMM1_I0110
    197   if( m_eWedgeRes == DOUBLE_PEL) // adjust line-end for DOUBLE_PEL resolution
    198   {
    199     if( m_uhOri == 1 ) { uhXs = uiTempBlockSize-1; }
    200     if( m_uhOri == 2 ) { uhXe = uiTempBlockSize-1; uhYs = uiTempBlockSize-1; }
    201     if( m_uhOri == 3 ) { uhYe = uiTempBlockSize-1; }
    202     if( m_uhOri == 4 ) { uhYe = uiTempBlockSize-1; }
    203     if( m_uhOri == 5 ) { uhXs = uiTempBlockSize-1; }
    204   }
    205 #endif
    206 
    207   Bool* pbTempPattern = new Bool[ (uiTempBlockSize * uiTempBlockSize) ];
    208   ::memset( pbTempPattern, 0, (uiTempBlockSize * uiTempBlockSize) * sizeof(Bool) );
    209   Int iTempStride = uiTempBlockSize;
    210 
    211   xDrawEdgeLine( uhXs, uhYs, uhXe, uhYe, pbTempPattern, iTempStride );
    212 
    213   switch( m_uhOri )
    214   {
    215   case( 0 ): { for( UInt iX = 0;                 iX < uhXs;            iX++ ) { UInt iY = 0;                 while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY++; } } } break;
    216   case( 1 ): { for( UInt iY = 0;                 iY < uhYs;            iY++ ) { UInt iX = uiTempBlockSize-1; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX--; } } } break;
    217   case( 2 ): { for( UInt iX = uiTempBlockSize-1; iX > uhXs;            iX-- ) { UInt iY = uiTempBlockSize-1; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY--; } } } break;
    218   case( 3 ): { for( UInt iY = uiTempBlockSize-1; iY > uhYs;            iY-- ) { UInt iX = 0;                 while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX++; } } } break;
    219   case( 4 ):
    220     {
    221       if( (uhXs+uhXe) < uiTempBlockSize ) { for( UInt iY = 0; iY < uiTempBlockSize; iY++ ) { UInt iX = 0;                 while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX++; } } }
    222       else                                { for( UInt iY = 0; iY < uiTempBlockSize; iY++ ) { UInt iX = uiTempBlockSize-1; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX--; } } }
    223     }
    224     break;
    225   case( 5 ):
    226     {
    227       if( (uhYs+uhYe) < uiTempBlockSize ) { for( UInt iX = 0; iX < uiTempBlockSize; iX++ ) { UInt iY = 0;                 while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY++; } } }
    228       else                                { for( UInt iX = 0; iX < uiTempBlockSize; iX++ ) { UInt iY = uiTempBlockSize-1; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY--; } } }
    229     }
    230   }
    231 
    232   clear();
    233   switch( m_eWedgeRes )
    234   {
    235 #if !SHARP_DMM1_I0110
    236   case( DOUBLE_PEL ): { for( UInt k = 0; k < (m_uiWidth * m_uiHeight); k++ ) { m_pbPattern[k] = pbTempPattern[k]; }; } break;
    237 #endif
    238   case(   FULL_PEL ): { for( UInt k = 0; k < (m_uiWidth * m_uiHeight); k++ ) { m_pbPattern[k] = pbTempPattern[k]; }; } break;
    239   case(   HALF_PEL ): // sub-sampling by factor 2
    240     {
    241       Int iStride = getStride();
    242 
    243       UInt uiOffX, uiOffY;
    244       switch( m_uhOri )
    245       {
    246       case( 0 ): { uiOffX = 0; uiOffY = 0; } break;
    247       case( 1 ): { uiOffX = 1; uiOffY = 0; } break;
    248       case( 2 ): { uiOffX = 1; uiOffY = 1; } break;
    249       case( 3 ): { uiOffX = 0; uiOffY = 1; } break;
    250       case( 4 ):
    251         {
    252           if( (uhXs+uhXe) < uiTempBlockSize ) { uiOffX = 0; uiOffY = 0; }
    253           else                                { uiOffX = 1; uiOffY = 0; }
    254         }
    255         break;
    256       case( 5 ):
    257         {
    258           if( (uhYs+uhYe) < uiTempBlockSize ) { uiOffX = 0; uiOffY = 0; }
    259           else                                { uiOffX = 0; uiOffY = 1; }
    260         }
    261         break;
    262       default:   { uiOffX = 0; uiOffY = 0; } break;
    263       }
    264 
    265       for(Int iY = 0; iY < m_uiHeight; iY++)
    266       {
    267         for(Int iX = 0; iX < m_uiWidth; iX++)
    268         {
    269           m_pbPattern[(iY * iStride) + iX] = pbTempPattern[(((iY<<1)+uiOffY) * iTempStride) + ((iX<<1)+uiOffX)];
    270         }
    271       }
    272     }
    273     break;
    274   }
    275 
    276   if( pbTempPattern )
    277   {
    278     delete [] pbTempPattern;
    279     pbTempPattern = NULL;
    280   }
    281 }
    282 
    283 Void TComWedgelet::xDrawEdgeLine( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, Bool* pbPattern, Int iPatternStride )
    284 {
    285   Int x0 = (Int)uhXs;
    286   Int y0 = (Int)uhYs;
    287   Int x1 = (Int)uhXe;
    288   Int y1 = (Int)uhYe;
    289 
    290   // direction independent Bresenham line
    291   bool steep = (abs(y1 - y0) > abs(x1 - x0));
    292   if( steep )
    293   {
    294     std::swap( x0, y0 );
    295     std::swap( x1, y1 );
    296   }
    297 
    298   bool backward = ( x0 > x1 );
    299   if( backward )
    300   {
    301     std::swap( x0, x1 );
    302     std::swap( y0, y1 );
    303   }
    304 
    305   Int deltax = x1 - x0;
    306   Int deltay = abs(y1 - y0);
    307   Int error = 0;
    308   Int deltaerr = (deltay<<1);
    309 
    310   Int ystep;
    311   Int y = y0;
    312   if( y0 < y1 ) ystep =  1;
    313   else          ystep = -1;
    314 
    315   for( Int x = x0; x <= x1; x++ )
    316   {
    317     if( steep ) { pbPattern[(x * iPatternStride) + y] = true; }
    318     else        { pbPattern[(y * iPatternStride) + x] = true; }
    319 
    320     error += deltaerr;
    321     if( error >= deltax )
    322     {
    323       y += ystep;
    324       error = error - (deltax<<1);
    325     }
    326   }
    327 }
    328 
    329 #if SHARP_DMM1_I0110
    330 Bool* TComWedgelet::getScaledPattern(UInt uiDstSize)
    331 {
    332     Bool *pbSrcPat = this->getPattern();
    333     UInt uiSrcSize = this->getStride();
    334 
    335     Int scale = (g_aucConvertToBit[uiDstSize] - g_aucConvertToBit[uiSrcSize]);
    336     assert(scale>=0);
    337     for (Int y=0; y<uiDstSize; y++)
    338     {
    339        for (Int x=0; x<uiDstSize; x++)
    340        {
    341            Int srcX = x>>scale;
    342            Int srcY = y>>scale;
    343            m_pbScaledPattern[y*uiDstSize + x] = pbSrcPat[ srcY*uiSrcSize + srcX ];
    344        }
    345    }
    346    return m_pbScaledPattern;
    347 }
    348 #endif
    349 
    350 TComWedgeNode::TComWedgeNode()
    351 {
    352   m_uiPatternIdx = DMM_NO_WEDGEINDEX;
    353   for( UInt uiPos = 0; uiPos < DMM_NUM_WEDGE_REFINES; uiPos++ )
    354   {
    355     m_uiRefineIdx[uiPos] = DMM_NO_WEDGEINDEX;
    356   }
    357 }
    358 
    359 UInt TComWedgeNode::getPatternIdx()
    360 {
    361   return m_uiPatternIdx;
    362 }
    363 UInt TComWedgeNode::getRefineIdx( UInt uiPos )
    364 {
    365   assert( uiPos < DMM_NUM_WEDGE_REFINES );
    366   return m_uiRefineIdx[uiPos];
    367 }
    368 Void TComWedgeNode::setPatternIdx( UInt uiIdx )
    369 {
    370   m_uiPatternIdx = uiIdx;
    371 }
    372 Void TComWedgeNode::setRefineIdx( UInt uiIdx, UInt uiPos )
    373 {
    374   assert( uiPos < DMM_NUM_WEDGE_REFINES );
    375   m_uiRefineIdx[uiPos] = uiIdx; 
    376 }
    377 #endif //H_3D_DIM_DMM
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComWedgelet.h

    r1039 r1072  
    4343#include <vector>
    4444
    45 #if H_3D_DIM
    46 #define DIM_OFFSET     (NUM_INTRA_MODE+1) // offset for DMM and RBC mode numbers (PM: not consistent with spec, but non-overlapping with chroma, see DM_CHROMA_IDX)
    47 #define DIM_MIN_SIZE                   4  // min. block size for DMM and RBC modes
    48 #define DIM_MAX_SIZE                  32  // max. block size for DMM and RBC modes
    4945
    50 enum DIM_IDX
    51 {
    52   DMM1_IDX = 0,
    53   DMM4_IDX = 1,
    54 };
    55 
    56 #define DMM_NUM_TYPE   2
    57 #define DIM_NUM_TYPE   (DMM_NUM_TYPE)
    58 #define DIM_NO_IDX     MAX_UINT
    59 
    60 #if HS_DMM_SIGNALLING_I0120
    61 __inline UInt getDimType  ( Int intraMode )
    62 {
    63     Int dimType = intraMode-DIM_OFFSET;
    64     return (dimType >= 0 && dimType < DIM_NUM_TYPE) ? (UInt)dimType : DIM_NO_IDX;
    65 }
    66 #else
    67 __inline UInt getDimType  ( Int intraMode ) { Int dimType = (intraMode-DIM_OFFSET)/2; return (dimType >= 0 && dimType < DIM_NUM_TYPE) ? (UInt)dimType : DIM_NO_IDX; }
    68 #endif
    69 __inline Bool isDimMode   ( Int intraMode ) { return (getDimType( intraMode ) < DIM_NUM_TYPE); }
    70 #if !HS_DMM_SIGNALLING_I0120
    71 __inline Bool isDimDeltaDC( Int intraMode ) { return (isDimMode( intraMode ) && ((intraMode-DIM_OFFSET)%2) == 1); }
    72 #endif
    73 #endif
    74 
    75 #if H_3D_DIM_DMM
    76 #define DMM_NO_WEDGEINDEX       MAX_UINT
    77 #define DMM_NUM_WEDGE_REFINES   8
    78 
    79 enum WedgeResolution
    80 {
    81 #if !SHARP_DMM1_I0110
    82   DOUBLE_PEL,
    83 #endif
    84   FULL_PEL,
    85   HALF_PEL
    86 };
    87 
    88 
    89 // ====================================================================================================================
    90 // Class definition TComWedgelet
    91 // ====================================================================================================================
    92 class TComWedgelet
    93 {
    94 private:
    95   UChar           m_uhXs;                       // line start X pos
    96   UChar           m_uhYs;                       // line start Y pos
    97   UChar           m_uhXe;                       // line end   X pos
    98   UChar           m_uhYe;                       // line end   Y pos
    99   UChar           m_uhOri;                      // orientation index
    100   WedgeResolution m_eWedgeRes;                  // start/end pos resolution
    101   Bool            m_bIsCoarse;
    102   UInt            m_uiAng;
    103 
    104   UInt  m_uiWidth;
    105   UInt  m_uiHeight;
    106 
    107   Bool* m_pbPattern;
    108 #if SHARP_DMM1_I0110
    109   Bool* m_pbScaledPattern;
    110 #endif
    111 
    112   Void  xGenerateWedgePattern();
    113   Void  xDrawEdgeLine( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, Bool* pbPattern, Int iPatternStride );
    114 
    115 public:
    116   TComWedgelet( UInt uiWidth, UInt uiHeight );
    117   TComWedgelet( const TComWedgelet &rcWedge );
    118   virtual ~TComWedgelet();
    119 
    120   Void  create ( UInt iWidth, UInt iHeight );   ///< create  wedgelet pattern
    121   Void  destroy();                              ///< destroy wedgelet pattern
    122   Void  clear  ();                              ///< clear   wedgelet pattern
    123 
    124   UInt            getWidth   () { return m_uiWidth; }
    125   UInt            getStride  () { return m_uiWidth; }
    126   UInt            getHeight  () { return m_uiHeight; }
    127   WedgeResolution getWedgeRes() { return m_eWedgeRes; }
    128   Bool*           getPattern () { return m_pbPattern; }
    129   UChar           getStartX  () { return m_uhXs; }
    130   UChar           getStartY  () { return m_uhYs; }
    131   UChar           getEndX    () { return m_uhXe; }
    132   UChar           getEndY    () { return m_uhYe; }
    133   UChar           getOri     () { return m_uhOri; }
    134   Bool            getIsCoarse() { return m_bIsCoarse; }
    135   UInt            getAng     () { return m_uiAng; }
    136 #if SHARP_DMM1_I0110
    137   Bool*           getScaledPattern(UInt uiWidth);
    138 #endif
    139 
    140   Void  setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse = false );
    141   Void  findClosestAngle();
    142 
    143   Bool  checkNotPlain();
    144   Bool  checkIdentical( Bool* pbRefPattern );
    145   Bool  checkInvIdentical( Bool* pbRefPattern );
    146 
    147 };  // END CLASS DEFINITION TComWedgelet
    148 
    149 // type definition wedgelet pattern list
    150 typedef std::vector<TComWedgelet> WedgeList;
    151 
    152 // ====================================================================================================================
    153 // Class definition TComWedgeRef
    154 // ====================================================================================================================
    155 class TComWedgeRef
    156 {
    157 private:
    158   UChar           m_uhXs;                       // line start X pos
    159   UChar           m_uhYs;                       // line start Y pos
    160   UChar           m_uhXe;                       // line end   X pos
    161   UChar           m_uhYe;                       // line end   Y pos
    162   UInt            m_uiRefIdx;                   // index of corresponding pattern of TComWedgelet object in wedge list
    163 
    164 public:
    165   TComWedgeRef() {}
    166   virtual ~TComWedgeRef() {}
    167 
    168   UChar           getStartX  () { return m_uhXs; }
    169   UChar           getStartY  () { return m_uhYs; }
    170   UChar           getEndX    () { return m_uhXe; }
    171   UChar           getEndY    () { return m_uhYe; }
    172   UInt            getRefIdx  () { return m_uiRefIdx; }
    173 
    174   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; }
    175 };  // END CLASS DEFINITION TComWedgeRef
    176 
    177 // type definition wedgelet reference list
    178 typedef std::vector<TComWedgeRef> WedgeRefList;
    179 
    180 // ====================================================================================================================
    181 // Class definition TComWedgeNode
    182 // ====================================================================================================================
    183 class TComWedgeNode
    184 {
    185 private:
    186   UInt            m_uiPatternIdx;
    187   UInt            m_uiRefineIdx[DMM_NUM_WEDGE_REFINES];
    188 
    189 public:
    190   TComWedgeNode();
    191   virtual ~TComWedgeNode() {}
    192 
    193   UInt            getPatternIdx();
    194   UInt            getRefineIdx ( UInt uiPos );
    195 
    196   Void            setPatternIdx( UInt uiIdx );
    197   Void            setRefineIdx ( UInt uiIdx, UInt uiPos );
    198 };  // END CLASS DEFINITION TComWedgeNode
    199 
    200 // type definition wedgelet node list
    201 typedef std::vector<TComWedgeNode> WedgeNodeList;
    202 #endif //H_3D_DIM_DMM
    20346
    20447
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComYuv.cpp

    r1039 r1072  
    647647  }
    648648}
    649 #if H_3D
    650 Void TComYuv::addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
    651 {
    652   Int x, y;
    653 
    654   Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx);
    655   Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx);
    656   Pel* pDst  = getLumaAddr( uiTrUnitIdx);
    657 
    658   UInt iSrc0Stride = pcYuvSrc0->getStride();
    659   UInt iSrc1Stride = pcYuvSrc1->getStride();
    660   UInt iDstStride  = getStride();
    661   for ( y = uiPartSize-1; y >= 0; y-- )
    662   {
    663     for ( x = uiPartSize-1; x >= 0; x-- )
    664     {
    665       pDst[x] = ClipY( pSrc0[x] + pSrc1[x] );     
    666     }
    667     pSrc0 += iSrc0Stride;
    668     pSrc1 += iSrc1Stride;
    669     pDst  += iDstStride;
    670   }
    671 }
    672 
    673 #if H_3D_ARP
    674 Void TComYuv::addARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
    675 {
    676   addARPLuma   ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth   , uiHeight    , bClip );
    677   addARPChroma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth>>1, uiHeight>>1 , bClip );
    678 }
    679 
    680 Void TComYuv::addARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
    681 {
    682   Int x, y;
    683 
    684   Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx );
    685   Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx );
    686   Pel* pDst  = getLumaAddr( uiAbsPartIdx );
    687 
    688   UInt iSrc0Stride = pcYuvSrc0->getStride();
    689   UInt iSrc1Stride = pcYuvSrc1->getStride();
    690   UInt iDstStride  = getStride();
    691 #if QC_I0129_ARP_FIX
    692   Int iIFshift = IF_INTERNAL_PREC - g_bitDepthY;
    693   Int iOffSet  = ( 1 << ( iIFshift - 1 ) ) + IF_INTERNAL_OFFS;
    694 #endif
    695   for ( y = uiHeight-1; y >= 0; y-- )
    696   {
    697     for ( x = uiWidth-1; x >= 0; x-- )
    698     {
    699       pDst[x] = pSrc0[x] + pSrc1[x];
    700       if( bClip )
    701       {
    702 #if QC_I0129_ARP_FIX
    703         pDst[x] = ClipY( ( pDst[x] + iOffSet ) >> iIFshift );
    704 #else
    705         pDst[x] = ClipY( pDst[x] );
    706 #endif
    707       }
    708     }
    709     pSrc0 += iSrc0Stride;
    710     pSrc1 += iSrc1Stride;
    711     pDst  += iDstStride;
    712   }
    713 }
    714 
    715 Void TComYuv::addARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
    716 {
    717   Int x, y;
    718 
    719   Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx );
    720   Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx );
    721   Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx );
    722   Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx );
    723   Pel* pDstU = getCbAddr( uiAbsPartIdx );
    724   Pel* pDstV = getCrAddr( uiAbsPartIdx );
    725 
    726   UInt  iSrc0Stride = pcYuvSrc0->getCStride();
    727   UInt  iSrc1Stride = pcYuvSrc1->getCStride();
    728   UInt  iDstStride  = getCStride();
    729 #if QC_I0129_ARP_FIX
    730   Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC;
    731   Int iOffSet  = ( 1 << ( iIFshift - 1 ) ) + IF_INTERNAL_OFFS;
    732 #endif
    733   for ( y = uiHeight-1; y >= 0; y-- )
    734   {
    735     for ( x = uiWidth-1; x >= 0; x-- )
    736     {
    737       pDstU[x] = pSrcU0[x] + pSrcU1[x];
    738       pDstV[x] = pSrcV0[x] + pSrcV1[x];
    739       if( bClip )
    740       {
    741 #if QC_I0129_ARP_FIX
    742         pDstU[x] = ClipC( ( pDstU[x] + iOffSet ) >> iIFshift );
    743         pDstV[x] = ClipC( ( pDstV[x] + iOffSet ) >> iIFshift );
    744 #else
    745         pDstU[x] = ClipC( pDstU[x] );
    746         pDstV[x] = ClipC( pDstV[x] );
    747 #endif
    748       }
    749     }
    750 
    751     pSrcU0 += iSrc0Stride;
    752     pSrcU1 += iSrc1Stride;
    753     pSrcV0 += iSrc0Stride;
    754     pSrcV1 += iSrc1Stride;
    755     pDstU  += iDstStride;
    756     pDstV  += iDstStride;
    757   }
    758 }
    759 
    760 Void TComYuv::subtractARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
    761 {
    762   subtractARPLuma  ( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth    , uiHeight    );
    763 #if SHARP_ARP_CHROMA_I0104
    764   if (uiWidth > 8)
    765 #endif
    766   subtractARPChroma( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth>>1 , uiHeight>>1 );
    767 }
    768 
    769 Void TComYuv::subtractARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
    770 {
    771   Int x, y;
    772 
    773   Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx );
    774   Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx );
    775   Pel* pDst  = getLumaAddr( uiAbsPartIdx );
    776 
    777   Int  iSrc0Stride = pcYuvSrc0->getStride();
    778   Int  iSrc1Stride = pcYuvSrc1->getStride();
    779   Int  iDstStride  = getStride();
    780   for ( y = uiHeight-1; y >= 0; y-- )
    781   {
    782     for ( x = uiWidth-1; x >= 0; x-- )
    783     {
    784       pDst[x] = pSrc0[x] - pSrc1[x];
    785     }
    786     pSrc0 += iSrc0Stride;
    787     pSrc1 += iSrc1Stride;
    788     pDst  += iDstStride;
    789   }
    790 }
    791 
    792 Void TComYuv::subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
    793 {
    794   Int x, y;
    795 
    796   Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx );
    797   Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx );
    798   Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx );
    799   Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx );
    800   Pel* pDstU  = getCbAddr( uiAbsPartIdx );
    801   Pel* pDstV  = getCrAddr( uiAbsPartIdx );
    802 
    803   Int  iSrc0Stride = pcYuvSrc0->getCStride();
    804   Int  iSrc1Stride = pcYuvSrc1->getCStride();
    805   Int  iDstStride  = getCStride();
    806   for ( y = uiHeight-1; y >= 0; y-- )
    807   {
    808     for ( x = uiWidth-1; x >= 0; x-- )
    809     {
    810       pDstU[x] = pSrcU0[x] - pSrcU1[x];
    811       pDstV[x] = pSrcV0[x] - pSrcV1[x];
    812     }
    813     pSrcU0 += iSrc0Stride;
    814     pSrcU1 += iSrc1Stride;
    815     pSrcV0 += iSrc0Stride;
    816     pSrcV1 += iSrc1Stride;
    817     pDstU  += iDstStride;
    818     pDstV  += iDstStride;
    819   }
    820 }
    821 
    822 Void TComYuv::multiplyARP( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
    823 {
    824   multiplyARPLuma( uiAbsPartIdx , uiWidth , uiHeight , dW );
    825 #if SHARP_ARP_CHROMA_I0104
    826   if (uiWidth > 8)
    827 #endif
    828   multiplyARPChroma( uiAbsPartIdx , uiWidth >> 1 , uiHeight >> 1 , dW );
    829 }
    830 
    831 Void TComYuv::xxMultiplyLine( Pel* pSrcDst , UInt uiWidth , UChar dW )
    832 {
    833   assert( dW == 2 );
    834   for( UInt x = 0 ; x < uiWidth ; x++ )
    835     pSrcDst[x] =  pSrcDst[x] >> 1;
    836 }
    837 
    838 Void TComYuv::multiplyARPLuma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
    839 {
    840   Pel* pDst  = getLumaAddr( uiAbsPartIdx );
    841   Int  iDstStride  = getStride();
    842   for ( Int y = uiHeight-1; y >= 0; y-- )
    843   {
    844     xxMultiplyLine( pDst , uiWidth , dW );
    845     pDst  += iDstStride;
    846   }
    847 }
    848 
    849 Void TComYuv::multiplyARPChroma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
    850 {
    851   Pel* pDstU  = getCbAddr( uiAbsPartIdx );
    852   Pel* pDstV  = getCrAddr( uiAbsPartIdx );
    853 
    854   Int  iDstStride  = getCStride();
    855   for ( Int y = uiHeight-1; y >= 0; y-- )
    856   {
    857     xxMultiplyLine( pDstU , uiWidth , dW );
    858     xxMultiplyLine( pDstV , uiWidth , dW );
    859     pDstU  += iDstStride;
    860     pDstV  += iDstStride;
    861   }
    862 }
    863 #endif
    864 #endif
    865649
    866650//! \}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TComYuv.h

    r872 r1072  
    180180  UInt    getCHeight  ()    { return  m_iCHeight; }
    181181  UInt    getCWidth   ()    { return  m_iCWidth;  } 
    182 #if H_3D
    183   Void addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
    184 
    185 #if H_3D_ARP
    186   Void    addARP           ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip );
    187   Void    addARPLuma       ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip );
    188   Void    addARPChroma     ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip );
    189   Void    subtractARP      ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
    190   Void    subtractARPLuma  ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
    191   Void    subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
    192   Void    multiplyARP      ( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW );
    193   Void    multiplyARPLuma  ( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW );
    194   Void    multiplyARPChroma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW );
    195 private:
    196   Void    xxMultiplyLine( Pel * pSrcDst , UInt uiWidth , UChar dW );
    197 #endif
    198 #endif
    199182
    200183};// END CLASS DEFINITION TComYuv
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibCommon/TypeDef.h

    r1066 r1072  
    4949   Linux makefiles support the following settings:   
    5050   make             -> HEVC_EXT not defined   
    51    make HEVC_EXT=0  -> H_MV=0 H_3D=0   --> plain HM
    52    make HEVC_EXT=1  -> H_MV=1 H_3D=0   --> MV only
    53    make HEVC_EXT=2  -> H_MV=1 H_3D=1   --> full 3D
     51   make HEVC_EXT=0  -> H_MV=0 --> plain HM
     52   make HEVC_EXT=1  -> H_MV=1 --> MV only
    5453*/
    5554
    5655#ifndef HEVC_EXT
    57 #define HEVC_EXT                    2
    58 #endif
    59 
    60 #if ( HEVC_EXT < 0 )||( HEVC_EXT > 2 )
    61 #error HEVC_EXT must be in the range of 0 to 2, inclusive.
     56#define HEVC_EXT                    1
     57#endif
     58
     59#if ( HEVC_EXT < 0 )||( HEVC_EXT > 1 )
     60#error HEVC_EXT must be in the range of 0 to 1, inclusive.
    6261#endif
    6362
    6463#define H_MV          ( HEVC_EXT != 0)
    65 #define H_3D          ( HEVC_EXT == 2)
    66 
    67 #define NTT_BUG_FIX_TK54    1
    68 #define BUG_FIX_TK65        1
    69 
    70 #define MTK_I0093           1
     64
    7165/////////////////////////////////////////////////////////////////////////////////////////
    7266///////////////////////////////////   MAJOR DEFINES   /////////////////////////////////// 
     
    7670#define H_MV_ENC_DEC_TRAC                 1  //< CU/PU level tracking
    7771#endif
    78 
    79 #if H_3D
    80 #define H_3D_QTLPC                        1   // OL_QTLIMIT_PREDCODING_B0068 //JCT3V-B0068
    81                                               // HHI_QTLPC_RAU_OFF_C0160 JCT3V-C0160 change 2: quadtree limitation and predictive coding switched off in random access units
    82                                               // MTK_TEX_DEP_PAR_G0055 Texture-partition-dependent depth partition. JCT3V-G0055
    83 
    84 #define H_3D_VSO                          1   // VSO, View synthesis optimization, includes:
    85                                               // HHI_VSO
    86                                               // HHI_VSO_LS_TABLE_M23714 enable table base Lagrange multiplier optimization
    87                                               // SAIT_VSO_EST_A0033, JCT3V-A0033 modification 3
    88                                               // LGE_WVSO_A0119
    89                                               // SCU_HS_VSD_BUGFIX_IMPROV_G0163
    90 #define H_3D_NBDV                         1   // Neighboring block disparity derivation
    91                                               // QC_JCT3V-A0097
    92                                               // LGE_DVMCP_A0126
    93                                               // LGE_DVMCP_MEM_REDUCTION_B0135     
    94                                               // QC_SIMPLE_NBDV_B0047
    95                                               // FIX_LGE_DVMCP_B0133
    96                                               // QC_NBDV_LDB_FIX_C0055
    97                                               // MTK_SAIT_TEMPORAL_FIRST_ORDER_C0141_C0097
    98                                               // MTK_SIMPLIFY_DVTC_C0135           
    99                                               // QC_CU_NBDV_D0181
    100                                               // SEC_DEFAULT_DV_D0112
    101                                               // MTK_DVMCP_FIX_E0172       fix the mismatch between software and WD for DV derivation from DVMCP blocks, issue 2 in JCT3V-E0172
    102                                               // SEC_SIMPLIFIED_NBDV_E0142 Simplified NBDV, JCT3V-E0142 and JCT3V-E0190
    103                                               // MTK_NBDV_TN_FIX_E0172     fix the issue of DV derivation from the temporal neighboring blocks, issue 7 in JCT3V-E0172
    104                                               // MTK_TEXTURE_MRGCAND_BUGFIX_E0182  Bug fix for TEXTURE MERGING CANDIDATE     , JCT3V-E0182
    105 
    106 #define H_3D_ARP                          1   // Advanced residual prediction (ARP), JCT3V-D0177
    107                                               // QC_MTK_INTERVIEW_ARP_F0123_F0108 JCT3V-F0123; JCT3V-F0108
    108                                               // SHARP_ARP_REF_CHECK_F0105        ARP reference picture selection and DPB check
    109                                               // LGE_ARP_CTX_F0161                JCT3V-F0161
    110                                               // MTK_ARP_FLAG_CABAC_SIMP_G0061 Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
    111                                               // MTK_ARP_REF_SELECTION_G0053 ARP Reference picture selection in JCT3V-G0053
    112                                               // 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
    113 
    114 
    115 #define H_3D_IC                           1   // Illumination Compensation, JCT3V-B0045, JCT3V-C0046, JCT3V-D0060
    116                                               // Unifying rounding offset, for IC part, JCT3V-D0135
    117                                               // Full Pel Interpolation for Depth, HHI_FULL_PEL_DEPTH_MAP_MV_ACC
    118                                               // SHARP_ILLUCOMP_REFINE_E0046
    119                                               // MTK_CLIPPING_ALIGN_IC_E0168       // To support simplify bi-prediction PU with identical motion checking, JCT3V-E0168
    120                                               // LGE_IC_CTX_F0160 //JCT3V-F0160
    121                                               // SEC_ONLY_TEXTURE_IC_F0151
    122                                               // MTK_IC_FLAG_CABAC_SIMP_G0061
    123                                               // SEC_IC_ARP_SIG_G0072, Disabling IC when ARP is enabled, option 1 in JCT3V-G0072, part 2 in JCT3V-G0121
    124                                               // MTK_LOW_LATENCY_IC_ENCODING_H0086  Low-latency IC encoding in JCT3V-H0086
    125 
    126 #define MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX  1  // Remove the global variables used in JCT3V-H0086
    127 
    128 
    129 #define SEC_IC_NEIGHBOR_CLIP_I0080        1   // Clipping of neighboring sample position, JCT3V-I0080
    130 
    131 
    132 #if H_3D_NBDV
    133 #define H_3D_NBDV_REF                     1   // Depth oriented neighboring block disparity derivation
    134                                               // MTK_D0156
    135                                               // MERL_D0166: Reference view selection in NBDV & Bi-VSP
    136                                               // MERL_C0152: Basic VSP
    137                                               // NBDV_DEFAULT_VIEWIDX_BUGFIX Bug fix for invalid default view index for NBDV
    138                                               // NTT_DoNBDV_VECTOR_CLIP_E0141 disparity vector clipping in DoNBDV, JCT3V-E0141 and JCT3V-E0209
    139                                               // SEC_VER_DONBDV_H0103          Vertical DV Restriction for DoNBDV
    140 #endif
    141 
    142 #define H_3D_VSP                          1   // View synthesis prediction
    143                                               // MERL_C0152: Basic VSP
    144                                               // MERL_D0166: Reference view selection in NBDV & Bi-VSP
    145                                               // MTK_D0105, LG_D0139: No VSP for depth
    146                                               // QC_D0191: Clean up
    147                                               // LG_D0092: Multiple VSP candidate allowed
    148                                               // MTK_VSP_FIX_ALIGN_WD_E0172
    149                                               // NTT_VSP_ADAPTIVE_SPLIT_E0207 adaptive sub-PU partitioning in VSP, JCT3V-E0207
    150                                               // NTT_VSP_DC_BUGFIX_E0208 bugfix for sub-PU based DC in VSP, JCT3V-E0208
    151                                               // NTT_VSP_COMMON_E0207_E0208 common part of JCT3V-E0207 and JCT3V-E0208
    152                                               // MTK_F0109_LG_F0120_VSP_BLOCK MTK_LG_SIMPLIFY_VSP_BLOCK_PARTITION_F0109_F0120 
    153                                               // SHARP_VSP_BLOCK_IN_AMP_F0102 VSP partitioning for AMP
    154                                               // MTK_VSP_SIMPLIFICATION_F0111 1. Inherited VSP also use NBDV of current CU, 2. VSP cannot be inherited from above LCU rowss
    155                                               // LGE_SHARP_VSP_INHERIT_F0104
    156                                               // NTT_STORE_SPDV_VSP_G0148 Storing Sub-PU based DV for VSP
    157                                               // Restricted bi-prediction for VSP
    158 
    159 #define H_3D_IV_MERGE                     1   // Inter-view motion merge candidate
    160                                               // HHI_INTER_VIEW_MOTION_PRED
    161                                               // SAIT_IMPROV_MOTION_PRED_M24829, improved inter-view motion vector prediction
    162                                               // QC_MRG_CANS_B0048             , JCT3V-B0048, B0086, B0069
    163                                               // OL_DISMV_POS_B0069            , different pos for disparity MV candidate, B0069
    164                                               // MTK_INTERVIEW_MERGE_A0049     , second part
    165                                               // QC_AMVP_MRG_UNIFY_IVCAN_C0051     
    166                                               // TEXTURE MERGING CANDIDATE     , JCT3V-C0137
    167                                               // QC_INRIA_MTK_MRG_E0126
    168                                               // ETRIKHU_MERGE_REUSE_F0093 QC_DEPTH_IV_MRG_F0125, JCT3V-F0125: Depth oriented Inter-view MV candidate
    169                                               // EC_MPI_ENABLING_MERGE_F0150, MPI flag in VPS and enabling in Merge mode
    170                                               // MTK_NBDV_IVREF_FIX_G0067      , Disable IvMC, VSP when IVREF is not available, JCT3V-G0067
    171                                               // SEC_DEPTH_DV_DERIVAITON_G0074, Simplification of DV derivation for depth, JCT3V-G0074
    172                                               // QC_DEPTH_MERGE_SIMP_G0127 Remove DV candidate and shifting candidate for depth coding
    173                                               // QC_IV_PRED_CONSTRAINT_H0137   Constraint on inter-view (motion) prediction tools
    174                                               // ETRIKHU_BUGFIX_H0083          bug-fix for DV candidate pruning
    175                                               // ETRIKHU_CLEANUP_H0083         cleaned-up source code for constructing merging candidate list
    176                                               // ETRIKHU_CLEANUP_H0083_MISSING missing guard macros added by GT
    177                                               // SHARP_SIMPLE_MERGE_H0062      Restrict 3D-HEVC merge cand in small PUs
    178                                               // MTK_DIS_SPBIP8X4_H0205        Disable bi-prediction for 8x4 and 4x8 sub PU and remove the SPIVMP 2Nx2N restriction
    179                                               // SEC_ADAPT_DISABLE_IVMP        Disalbing IVMP merge candidates when IC is enabled, JCT3V-H0070
    180 
    181 #define SEC_SIMP_SHIFTED_DV_I0086         1   // Simplification of Shifted DV candidate, JCT3V-I0086
    182 
    183 #define H_3D_TMVP                         1   // QC_TMVP_C0047
    184                                               // Sony_M23639
    185 
    186 #define H_3D_DIM                          1   // DIM, Depth intra modes, includes:
    187                                               // HHI_DMM_WEDGE_INTRA
    188                                               // HHI_DMM_PRED_TEX
    189                                               // FIX_WEDGE_NOFLOAT_D0036
    190                                               // LGE_EDGE_INTRA_A0070
    191                                               // LGE_DMM3_SIMP_C0044
    192                                               // QC_DC_PREDICTOR_D0183
    193                                               // HHI_DELTADC_DLT_D0035
    194                                               // PKU_QC_DEPTH_INTRA_UNI_D0195
    195                                               // RWTH_SDC_DLT_B0036
    196                                               // INTEL_SDC64_D0193
    197                                               // RWTH_SDC_CTX_SIMPL_D0032
    198                                               // LGE_CONCATENATE_D0141
    199                                               // FIX_SDC_ENC_RD_WVSO_D0163
    200                                               // MTK_SAMPLE_BASED_SDC_D0110
    201                                               // SEC_DMM2_E0146_HHIFIX Removal of DMM2 from DMMs
    202                                               // ZJU_DEPTH_INTRA_MODE_E0204 Simplified Binarization for depth_intra_mode
    203                                               // KWU_SDC_SIMPLE_DC_E0117 Simplified DC calculation for SDC
    204                                               // SCU_HS_DMM4_REMOVE_DIV_E0242 DMM4 Division Removal
    205                                               // LGE_SDC_REMOVE_DC_E0158 Removal of DC mode from SDC
    206                                               // LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX 1   Removal of overlap between DMM3 and DMM1
    207                                               // LGE_PRED_RES_CODING_DLT_DOMAIN_F0159 JCT3V-F0159
    208                                               // HHI_DIM_PREDSAMP_FIX_F0171
    209                                               // SEC_DMM3_RBC_F0147 Removal of DMM3 and RBC from DMMs
    210                                               // QC_DIM_DELTADC_UNIFY_F0132 Unify delta DC coding in depth intra modes
    211                                               // Unify intra SDC and inter SDC
    212                                               // QC_GENERIC_SDC_G0122 Generalize SDC to all depth intra modes
    213                                               // SCU_HS_DEPTH_DC_PRED_G0143
    214                                               // HS_TSINGHUA_SDC_SPLIT_G0111
    215                                               // QC_PKU_SDC_SPLIT_G0123 Intra SDC Split
    216                                               // HS_DMM_SDC_PREDICTOR_UNIFY_H0108  Unification of DMM and SDC predictor derivation
    217                                               // LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135  Use only one context for CABAC of dim_not_present_flag
    218                                               // QC_SIMP_DELTADC_CODING_H0131   Simplify detaDC entropy coding
    219                                               // MTK_DMM_SIMP_CODE_H0092        Remove CABAC context for DMM1 mode coding
    220                                               // 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
    221                                               // MTK_SDC_FLAG_FIX_H0095                          Remove conditional check of PCM flag based on SDC flag, JCTVC-H0095
    222                                               // SEC_NO_RESI_DLT_H0105   
    223                                               // MTK_DLT_CODING_FIX_H0091
    224 
    225 #define MTK_SINGLE_DEPTH_MODE_I0095       1   // Single depth mode proposed in JCT3V-I0095
    226 #if MTK_SINGLE_DEPTH_MODE_I0095
    227 #define MTK_SINGLE_DEPTH_MODE_CANDIDATE_LIST_SIZE            2 // size of the sample candidate list
    228 #endif
    229 
    230 #define H_3D_FIX_UNINIT                   1   // Fix uninitialized flag
    231 #define H_3D_INTER_SDC                    1   // INTER SDC, Inter simplified depth coding
    232                                               // LGE_INTER_SDC_E0156 Enable inter SDC for depth coding
    233                                               // SEC_INTER_SDC_G0101 Improved inter SDC with multiple DC candidates
    234 
    235 #define H_3D_SPIVMP                       1   // H_3D_SPIVMP    // JCT3V-F0110: Sub-PU level inter-view motion prediction
    236                                               // SEC_SPIVMP_MCP_SIZE_G0077, Apply SPIVMP only to 2Nx2N partition, JCT3V-G0077
    237                                               // QC_SPIVMP_MPI_G0119 Sub-PU level MPI merge candidate
    238                                               // Simplification on Sub-PU level temporal interview motion prediction
    239                                               // MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133
    240 
    241 #define H_3D_DBBP                         1   // DBBP: Depth-based Block Partitioning and Merging
    242                                               // MTK_DBBP_AMP_REM_H0072   
    243                                               // RWTH_DBBP_NO_SPU_H0057   
    244                                               // SEC_DBBP_FILTERING_H0104
    245                                               // MTK_DBBP_SIGNALING_H0094   
    246                                               // 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.
    247 
    248 #define SEC_DBBP_EXPLICIT_SIG_I0077       1   // Remove the partition derivation and signal dbbp_flag only when the partion mode is 2NxN/Nx2N, JCT3V-I0077
    249 #define SEC_DBBP_DISALLOW_8x8_I0078       1   // Disallow DBBP in 8x8 CU, JCT3V-I0078
    250 #define SHARP_DBBP_SIMPLE_FLTER_I0109     1   // Simple condition and one dimensional dilter for DBBP
    251 #define SEC_DBBP_DMM4_THRESHOLD_I0076     1   // Simplification of threshold derivation for DBBP and DMM4, JCT3V-I0076
    252 
    253 
    254 #define H_3D_DDD                          1   // Disparity derived depth coding
    255 
    256 #define H_3D_FCO                          0   // Flexible coding order for 3D
    257 #if H_3D_FCO
    258 #define LGE_FCO_I0116                     1
    259 #endif
    260 
    261 #define SCU_HS_FAST_INTRA_SDC_I0123       1
    262 
    263 // OTHERS
    264                                               // MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 // Progressive MV Compression, JCT3V-E0170
    265 #define H_3D_REN_MAX_DEV_OUT              0   // Output maximal possible shift deviation
    266 #define H_3D_FAST_TEXTURE_ENCODING        1   // Fast merge mode decision and early CU determination for texture component of dependent view, JCT3V-E0173
    267                                               // MTK_FAST_TEXTURE_ENCODING_E0173
    268 #if H_3D_DIM
    269 #define H_3D_FAST_DEPTH_INTRA             1   // Fast DMM and RBC Mode Selection
    270                                               // SCU_HS_FAST_DEPTH_INTRA_E0238_HHIFIX
    271 #endif
    272 
    273 #define MTK_I0099_VPS_EX2                 1  ///< JCT3V-I0099, sub-PU size signaling and lim_qt_pred_flag in VPS extension 2
    274 #define MTK_I0099_FIX                     1  ///< Fix the problem of removing encoder only QTL
    275 
    276 // Rate Control
    277 #define KWU_FIX_URQ                       1
    278 #define KWU_RC_VIEWRC_E0227               0  ///< JCT3V-E0227, view-wise target bitrate allocation
    279 #define KWU_RC_MADPRED_E0227              0  ///< JCT3V-E0227, inter-view MAD prediction
    280 
    281 #define SEC_VPS_CLEANUP_I0090             1
    282 #define SEC_HLS_CLEANUP_I0100             1
    283 
    284 #define H_3D_FIX_64BIT_SHIFT              1
    285 #endif // H_3D
    286 
    287 
    28872
    28973/////////////////////////////////////////////////////////////////////////////////////////
     
    30084#define FIX_TICKET_62                     1    // buffer overflow for print
    30185#define FIX_TICKET_61                     1    // layerIdsInSets size check
    302 
    303 ///// ***** VIEW SYNTHESIS OPTIMIZAION *********
    304 #if H_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 #define H_3D_VSO_FIX                      1   // This fix should be enabled after verification
    311 #endif
    312 
    313 ////   ****** NEIGHBOURING BLOCK-BASED DISPARITY VECTOR  *********
    314 #if H_3D_NBDV
    315 #define DVFROM_LEFT                       0
    316 #define DVFROM_ABOVE                      1
    317 #define IDV_CANDS                         2
    318 #endif
    319 
    320 ///// ***** ADVANCED INTERVIEW RESIDUAL PREDICTION *********
    321 #if H_3D_ARP
    322 #define H_3D_ARP_WFNR                     3
    323 #define QC_I0129_ARP_FIX                  1
    324 #define QC_I0051_ARP_SIMP                 1
    325 #define SHARP_ARP_CHROMA_I0104            1
    326 #define MTK_I0072_IVARP_SCALING_FIX       1
    327 #endif
    328 
    329 ///// ***** DEPTH INTRA MODES *********
    330 #if H_3D_DIM
    331 #define H_3D_DIM_DMM                      1   // Depth Modeling Modes
    332 #define H_3D_DIM_SDC                      1   // Simplified Depth Coding method
    333 #define H_3D_DIM_DLT                      1   // Depth Lookup Table
    334 #define HS_DMM_SIGNALLING_I0120  1   
    335 #define SHARP_DMM1_I0110                  1   // LUT size reduction for DMM1 proposed in JCT3V-I0110
    336 #define FIX_WARNING                       1   // fix narrowing conversion of NumPocStCurr0,NumPocStCurr1 at TComSlice.cpp
    337 #define FAST_SDC_OFFSET_DECISION_I0084    1
    338 #define SEPARATE_FLAG_I0085               1
    339 
    340 #if H_3D_DIM_DLT
    341 #define H_3D_DELTA_DLT                    1
    342 #define RWTH_DLT_CLIP_I0057               1
    343 #endif
    344 #define H_3D_DIM_ENC                      1   // Depth Intra encoder optimizations, includes:
    345                                               // HHI_DEPTH_INTRA_SEARCH_RAU_C0160
    346                                               // LG_ZEROINTRADEPTHRESI_A0087
    347 #define HHI_DMM4_ENC_I0066                1
    348 #endif
    349 ///// ***** VIEW SYNTHESIS PREDICTION *********
    350 #if H_3D_VSP
    351 #define H_3D_VSP_BLOCKSIZE                4   // Supported values: 1, 2, and 4
    352 #if H_3D_VSP_BLOCKSIZE == 1
    353 #define H_3D_VSP_CONSTRAINED              1   // Constrained VSP @ 1x1
    354 #else
    355 #define H_3D_VSP_CONSTRAINED              0
    356 #endif
    357 #endif
    358 
    359 
    360 ///// ***** ILLUMATION COMPENSATION *********
    361 #if H_3D_IC
    362 #define IC_REG_COST_SHIFT                 7
    363 #define IC_CONST_SHIFT                    5
    364 #define IC_SHIFT_DIFF                     12
    365 #define IC_LOW_LATENCY_ENCODING_THRESHOLD 0.1 // Threshold for low-latency IC encoding in JCT3V-H0086
    366 #endif
    367 
    368 
    369 ///// ***** DEPTH BASED BLOCK PARTITIONING *********
    370 #if H_3D_DBBP
    371 #define DBBP_INVALID_SHORT                (-4)
    372 #define RWTH_DBBP_PACK_MODE               SIZE_2NxN
    373 #endif
    374 
    375 
    376 ///// ***** FCO *********
    377 #if H_3D_FCO
    378 #define H_3D_FCO_VSP_DONBDV_E0163               1   // Adaptive depth reference for flexible coding order
    379 #else
    380 #define H_3D_FCO_VSP_DONBDV_E0163               0   // Adaptive depth reference for flexible coding order
    381 #endif
    382 
    383 #if H_3D
    384 #define PPS_FIX_DEPTH                           1
    385 #endif
    38686
    38787/////////////////////////////////////////////////////////////////////////////////
     
    432132
    433133
    434 // POC
    435 // #define H_MV_HLS_7_POC_P0041_3            0 // (POC/P0041/POC reset) #3 It was remarked that we should require each non-IRAP picture that has discardable_flag equal to 1 to have NUT value indicating that it is a sub-layer non-reference picture. This was agreed. Decision: Adopt (with constraint for discardable_flag as described above)
    436 // #define H_MV_HLS_7_POC_P0041_FIXES        0 // (POC/P0041/Fixes) For each non-IRAP picture that has discardable_flag equal to 1 to have NUT value indicating that it is a sub-layer non-reference picture.
    437 // #define H_MV_HLS_7_POC_P0056_4            0 // (POC/P0056/layer tree poc) #4 Proposal 1: If the POC reset approach is adopted as the basis for multi-layer POC derivation, it is proposed to derive the POC anchor picture from the previous TID0 picture (that is not a RASL picture, a RADL picture or a sub-layer non-reference picture and not with discardable_flag equal to 1) of  the current layer or any of its reference layer. This is asserted to improve loss resilience and reduce bit rate overhead. Decision: Adopt Proposal 1 (with the suggested modifications Ewith text provided as P0297).
    438 
    439 // SEI related
    440 //#define H_MV_HLS_8_SEI_NODOC_53  0 // #53 (SEI    /NODOC/Added Multiview view position SEI message) Plain copy from AVC.
    441 //#define H_MV_HLS_8_SEI_NODOC_52  0 // #52 (SEI    /NODOC/Added Multiview acquisition information SEI) Plain copy from AVC.
    442 //#define H_MV_HLS_8_SEI_NODOC_51  0 // #51 (SEI    /NODOC/Added Multiview scene information SEI message)
    443 //#define H_MV_HLS_8_SEI_Q0189_35  0 // #35 (SEI    /Q0189/SEI message for indicating constraints on TMVP) Proposal 2.3,  SEI message for indicating constraints on TMVP
    444 //#define H_MV_HLS_8_EDF_Q0116_29  0 // #29 (ED.FIX /Q0116/Recovery point SEI) , consider adding a note regarding how random accessibility is affected by the recovery point SEI message
    445 //#define H_MV_HLS_8_GEN_Q0183_23  0 // #23 (GEN    /Q0183/SEI clean-ups) numerous small clean-ups on SEI messages.
    446 //#define H_MV_HLS_8_MIS_Q0247_49  0 // #49 (MISC   /Q0247/frame-field information SEI message)
    447 //#define H_MV_HLS_8_MIS_Q0189_34  0 // #34 (MISC   /Q0189/slice temporal mvp enabled flag) Proposal 2.2, clarification of semantics of slice temporal mvp enabled flag
    448 //#define H_MV_HLS_8_EDF_Q0081_01  0 // #1  (ED.FIX /Q0081/alpha channel persist) On reuse of alpha planes in auxiliary pictures. It was asked why there would not be a presumption that the alpha channel content would simply persist, without needing the flag to indicate it. Decision (Ed.): Delegated to editors to clarify, as necessary, that the alpha channel content persists until cancelled or updated in output order.
    449 //#define H_MV_HLS_8_SEI_Q0253_37  0 // #37 (SEI    /Q0253/layer not present), modified semantics of layers not present SEI message to correct bug introduced during editing
    450 //#define H_MV_HLS_8_SEI_Q0045_11  0 // #11 (SEI    /Q0045/Overlay) Proposal for an SEI message on selectable overlays. Decision: Adopt (modified for variable-length strings).
    451 //#define H_MV_HLS_7_SEI_P0133_28  0 // (SEI/P0133/Recovery point SEI) #28 Decision: Adopt change to recover point semantics only (-v3)
    452 //#define H_MV_HLS_7_SEI_P0123_25  0 // (SEI/P0123/Alpha channel info) #25 Add alpha channel information SEI message Decision: Adopt. Constrain the bit depth indicated to be equal to the coded bit depth of the aux picture.
    453 
    454 // Auxiliary picture related
    455 //#define H_MV_HLS_8_AUX_NODOC_40  0 // #40 (AUX    /NODOC/primary pic) Clarify that an auxiliary picture can be associated with more than one primary picture. Consider if the language associating an alpha auxiliary picture with a primary picture in the semantics of dimension_id[ ][ ] near the AuxId derivation could be moved to the alpha SEI message.
    456 //#define H_MV_HLS_8_AUX_Q0081_2   0 // #2  (AUX    /Q0081/primary) Decision: Remove the constraint that an alpha picture must be accompanied by a primary picture.
    457 //#define H_MV_HLS_8_AUX_Q0078_44  0 // #44 (AUX    /Q0078/concepts Auxiliary picture concepts:
    458 //#define H_MV_HLS_8_AUX_Q0078_39  0 // #39 (AUX    /Q0078/conformance): mechanism for signaling a profile/tier/level conformance point for auxiliary pictures
    459 
    460 // Profiles
    461 //#define H_MV_HLS_8_PRO_NODOC_50  0 // #50 (PROF   /NODOC/Monochrome) Add Monochrome 8-bit profile
    462 //#define H_MV_HLS_8_PRO_NODOC_31  0 // #31 (PROF   /NODOC/Profile constraint) Add a profile constraint to the Scalable Main, Scalable Main 10, and Stereo Main profiles against allowing layers with duplicate values of DependencyId (or ViewOrderIdx) when AuxId equal to 0.
    463 //#define H_MV_HLS_8_PRO_H0126_45  0 // #45 (PROF   /H0126/Stereo main) Phrasing used in specifying the Stereo Main profile.
    464 //#define H_MV_HLS_8_PRO_Q0160_33  0 // #33 (PROF   /Q0160/alt_output_flag) v2: Add constraint to stereo main profile that it must contain exactly two texture views, and add a note to state that the constraint implies a restriction that alt_output_flag equal to 0.
    465 
    466 // DPB
    467 //#define H_MV_HLS_8_HRD_Q0102_09  0 // #9  (HRD    /Q0102/NoOutputOfPriorPicsFlag) It was suggested that also the separate_colour_plane_flag should affect inference of NoOutputOfPriorPicsFlag. Decision (Ed.): Agreed (affects RExt text).
    468 //#define H_MV_HLS_8_DBP_Q0154_38  0 // #38 (DBP    /Q0154/VPS DPB) Proposal in C.5.2.1: Add in the decoding process that when a new VPS is activated, all pictures in the DPB are marked as unused for reference
    469 //#define H_MV_HLS_8_HRD_Q0154_10  0 // #10 (HRD    /Q0154/DPB Flushing and parameters) On picture flushing and DPB parameters Decision: Adopted (some details to be discussed further in BoG).
    470 //#define H_MV_HLS_7_OTHER_P0187_1 0 // (OTHER/P0187/NoOutputOfPriorPicsFlag) #1 Inference of NoOutputOfPriorPicsFlag and proposes to take into account colour format and bit depth for the inference in addition to spatial resolution
    471 
    472 // OTHERS
    473 //#define H_MV_HLS_8_HSB_Q0041_03  0 // #3  (HS     /Q0041/hybrid scalability) The proposed text was endorsed, with non-editorial open issues considered as follows ?// #define H_MV_HLS_7_OTHER_P0187_1          0 // (OTHER/P0187/NoOutputOfPriorPicsFlag) #1 Inference of NoOutputOfPriorPicsFlag and proposes to take into account colour format and bit depth for the inference in addition to spatial resolution
    474 //#define H_MV_HLS_8_MIS_Q0078_24  0 // #24 (MISC   /Q0078/scan and pic type) , Items 3 b,c and 4, clarifying which pictures in an output layer sets are applied the values of general_progressive_source_flag, general_interlaced_source_flag, general_non_packed_constraint_flag and general_frame_only_constraint_flag.
    475 //#define H_MV_HLS_7_HRD_P0138_6   0 //     (HRD/P0138/HRD parameters for bitstreams excluding) #6 Decision: Adopt (as revised in updated contribution, with the specification of a flag in the BP SEI (HRD/P0192/sub-DPB) #12 Establish sub-DPBs based on the representation format indicated at the VPS level. It was suggested that the expressed shared capacity limit would need to be less than or equal to the sum of the individual capacity limits. Decision: Adopt as modified. Further study is encouraged on profile/level constraint selections.
    476 
    477134/////////////////////////////////////////////////////////////////////////////////////////
    478135///////////////////////////////////   HM RELATED DEFINES ////////////////////////////////
     
    708365typedef       Int             TCoeff;     ///< transform coefficient
    709366
    710 #if H_3D_VSO
    711 // ====================================================================================================================
    712 // Define Distortion Types
    713 // ====================================================================================================================
    714 typedef       Int64           RMDist;     ///< renderer model distortion
    715 
    716 #if H_3D_VSO_DIST_INT
    717 typedef       Int64            Dist;       ///< RDO distortion
    718 typedef       Int64            Dist64;
    719 #define       RDO_DIST_MIN     MIN_INT
    720 #define       RDO_DIST_MAX     MAX_INT
    721 #else
    722 typedef       UInt             Dist;       ///< RDO distortion
    723 typedef       UInt64           Dist;
    724 #define       RDO_DIST_MIN     0
    725 #define       RDO_DIST_MAX     MAX_UINT
    726 #endif
    727 #endif
    728367/// parameters for adaptive loop filter
    729368class TComPicSym;
     
    933572  DF_HADS64   = 27,     ///<  64xM HAD with step
    934573  DF_HADS16N  = 28,     ///< 16NxM HAD with step
    935 #if H_3D_VSO
    936   DF_VSD      = 29,      ///< general size VSD
    937   DF_VSD4     = 30,      ///<   4xM VSD
    938   DF_VSD8     = 31,      ///<   8xM VSD
    939   DF_VSD16    = 32,      ///<  16xM VSD
    940   DF_VSD32    = 33,      ///<  32xM VSD
    941   DF_VSD64    = 34,      ///<  64xM VSD
    942   DF_VSD16N   = 35,      ///< 16NxM VSD
    943 #endif
    944574
    945575#if AMP_SAD
     
    981611
    982612/// merging candidates
    983 #if H_3D
    984 enum DefaultMergCandOrder
    985 {
    986   MRG_T = 0,            ///< MPI
    987   MRG_D,                ///< DDD
    988   MRG_IVMC,             ///< Temporal inter-view
    989   MRG_A1,               ///< Left
    990   MRG_B1,               ///< Above
    991   MRG_B0,               ///< Above right
    992   MRG_IVDC,             ///< Disparity inter-view
    993   MRG_VSP,              ///< VSP
    994   MRG_A0,               ///< Left bottom
    995   MRG_B2,               ///< Above left
    996   MRG_IVSHIFT,          ///< Shifted IVMC of Shifted IVDC. (These are mutually exclusive)
    997   MRG_COL               ///< Temporal co-located
    998 };
    999 #endif
    1000613
    1001614/// coefficient scanning type used in ACS
     
    1018631#if H_MV_HLS10_PTL
    1019632    MULTIVIEWMAIN = 6,
    1020 #if H_3D
    1021     MAIN3D = 8,
    1022 #endif
    1023633#else
    1024634    MAINSTEREO = 4,
    1025635    MAINMULTIVIEW = 5,
    1026 #if H_3D
    1027     MAIN3D = 6,
    1028 #endif
    1029636#endif
    1030637#endif
     
    1065672  enum ScalabilityType
    1066673  {
    1067 #if H_3D
    1068     DEPTH_ID = 0,   
    1069 #endif   
    1070674    VIEW_ORDER_INDEX  = 1,
    1071675#if H_MV_HLS10_AUX
     
    1075679  };
    1076680#endif
    1077 #if H_3D
    1078   // Renderer
    1079   enum BlenMod
    1080   {
    1081     BLEND_NONE  = -1,
    1082     BLEND_AVRG  = 0,
    1083     BLEND_LEFT  = 1,
    1084     BLEND_RIGHT = 2,
    1085     BLEND_GEN   =  3
    1086   };
    1087 
    1088  
    1089   enum
    1090   {
    1091     VIEWPOS_INVALID = -1,
    1092     VIEWPOS_LEFT    = 0,
    1093     VIEWPOS_RIGHT   = 1,
    1094     VIEWPOS_MERGED  = 2
    1095   };
    1096 
    1097 #define Log2( n ) ( log((double)n) / log(2.0) ) // Ed.(GT): This is very very bad and should be fixed to used integer arithmetics ( see gCeilLog2 ) moreover it should not be defined in the tool macro section!
    1098 #endif
    1099 #endif
     681#endif
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r1066 r1072  
    9999TDecCavlc::TDecCavlc()
    100100{
    101 #if H_3D
    102   m_aaiTempScale            = new Int* [ MAX_NUM_LAYERS ];
    103   m_aaiTempOffset           = new Int* [ MAX_NUM_LAYERS ];
    104   for( UInt uiVId = 0; uiVId < MAX_NUM_LAYERS; uiVId++ )
    105   {
    106     m_aaiTempScale            [ uiVId ] = new Int [ MAX_NUM_LAYERS ];
    107     m_aaiTempOffset           [ uiVId ] = new Int [ MAX_NUM_LAYERS ];
    108   }
    109 #endif
    110101}
    111102
    112103TDecCavlc::~TDecCavlc()
    113104{
    114 #if H_3D
    115   for( UInt uiVId = 0; uiVId < MAX_NUM_LAYERS; uiVId++ )
    116   {
    117     delete [] m_aaiTempScale            [ uiVId ];
    118     delete [] m_aaiTempOffset           [ uiVId ];
    119   }
    120   delete [] m_aaiTempScale;
    121   delete [] m_aaiTempOffset;
    122 #endif
    123105}
    124106
     
    223205}
    224206
    225 #if H_3D
    226 Void TDecCavlc::parsePPS(TComPPS* pcPPS, TComVPS* pcVPS )
    227 #else
    228207Void TDecCavlc::parsePPS(TComPPS* pcPPS)
    229 #endif
    230208{
    231209#if ENC_DEC_TRACE 
     
    387365    READ_FLAG( uiCode, "pps_range_extensions_flag" ); pcPPS->setPpsRangeExtensionsFlag( uiCode == 1 );
    388366    READ_FLAG( uiCode, "pps_multilayer_extension_flag" ); pcPPS->setPpsMultilayerExtensionFlag( uiCode == 1 );
    389 #if !H_3D
    390367    READ_CODE( 6, uiCode, "pps_extension_6bits" ); pcPPS->setPpsExtension6bits( uiCode );
    391 #else
    392     READ_FLAG( uiCode, "pps_3d_extension_flag" ); pcPPS->setPps3dExtensionFlag( uiCode == 1 );
    393     READ_CODE( 5, uiCode, "pps_extension_5bits" ); pcPPS->setPpsExtension5bits( uiCode );
    394 #endif
    395368    if ( pcPPS->getPpsRangeExtensionsFlag() )
    396369    {
     
    407380#endif
    408381    }
    409 #if !H_3D
    410382    if ( pcPPS->getPpsExtension6bits() )
    411383    {
    412 #else
    413     if ( pcPPS->getPps3dExtensionFlag() )
    414     {
    415       parsePPSExtension( pcPPS, pcVPS );
    416     }
    417     if ( pcPPS->getPpsExtension5bits() )
    418     {
    419 #endif
    420384
    421385#endif
     
    432396
    433397
    434 #if H_3D
    435 Void TDecCavlc::parsePPSExtension( TComPPS* pcPPS, TComVPS* pcVPS )
    436 {
    437   //Ed.(GT): pcVPS should not be used here. Needs to be fixed.
    438   UInt uiCode = 0;
    439   TComDLT* pcDLT = new TComDLT;
    440 
    441   READ_FLAG(uiCode, "dlt_present_flag");
    442   pcDLT->setDltPresentFlag( (uiCode == 1) ? true : false );
    443 
    444   if ( pcDLT->getDltPresentFlag() )
    445   {
    446     READ_CODE(6, uiCode, "pps_depth_layers_minus1");
    447     pcDLT->setNumDepthViews( uiCode );
    448 
    449     READ_CODE(4, uiCode, "pps_bit_depth_for_depth_views_minus8");
    450     pcDLT->setDepthViewBitDepth( (uiCode+8) );
    451 
    452     for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
    453     {
    454       if ( i != 0 )
    455       {
    456         if( pcVPS->getDepthId( i ) == 1 )
    457         {
    458           READ_FLAG(uiCode, "dlt_flag[i]");
    459           pcDLT->setUseDLTFlag(i, (uiCode == 1) ? true : false);
    460 
    461           if ( pcDLT->getUseDLTFlag( i ) )
    462           {
    463             Bool bDltBitMapRepFlag    = false;
    464             UInt uiMaxDiff            = 0xffffffff;
    465             UInt uiMinDiff            = 0;
    466             UInt uiCodeLength         = 0;
    467 
    468             READ_FLAG(uiCode, "inter_view_dlt_pred_enable_flag[ i ]");
    469 
    470             if( uiCode )
    471             {
    472                 assert( pcDLT->getUseDLTFlag( 1 ));
    473             }
    474             pcDLT->setInterViewDltPredEnableFlag( i, (uiCode == 1) ? true : false );
    475 
    476             if ( pcDLT->getInterViewDltPredEnableFlag( i ) == false )
    477             {
    478               READ_FLAG(uiCode, "dlt_bit_map_rep_flag[ layerId ]");
    479               bDltBitMapRepFlag = (uiCode == 1) ? true : false;
    480             }
    481             else
    482             {
    483               bDltBitMapRepFlag = false;
    484             }
    485            
    486             UInt uiNumDepthValues = 0;
    487             Int  aiIdx2DepthValue[256];
    488 
    489             // Bit map
    490             if ( bDltBitMapRepFlag )
    491             {
    492               for (UInt d=0; d<256; d++)
    493               {
    494                 READ_FLAG(uiCode, "dlt_bit_map_flag[ layerId ][ j ]");
    495                 if (uiCode == 1)
    496                 {
    497                   aiIdx2DepthValue[uiNumDepthValues] = d;
    498                   uiNumDepthValues++;
    499                 }
    500               }
    501             }
    502             // Diff Coding
    503             else
    504             {
    505               READ_CODE(8, uiNumDepthValues, "num_depth_values_in_dlt[i]");   // num_entry
    506 
    507 #if !H_3D_DELTA_DLT
    508               if ( pcDLT->getInterViewDltPredEnableFlag( i ) == false )       // Single-view DLT Diff Coding
    509 #endif
    510               {
    511                 // 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.
    512 
    513                 if (uiNumDepthValues > 1)
    514                 {
    515                   READ_CODE(8, uiCode, "max_diff[ layerId ]");
    516                   uiMaxDiff = uiCode;
    517                 }
    518                 else
    519                 {
    520                   uiMaxDiff = 0;           // when there is only one value in DLT
    521                 }
    522 
    523                 if (uiNumDepthValues > 2)
    524                 {
    525                   uiCodeLength = (UInt) ceil(Log2(uiMaxDiff + 1));
    526                   READ_CODE(uiCodeLength, uiCode, "min_diff_minus1[ layerId ]");
    527                   uiMinDiff = uiCode + 1;
    528                 }
    529                 else
    530                 {
    531                   uiMinDiff = uiMaxDiff;   // when there are only one or two values in DLT
    532                 }
    533 
    534                 READ_CODE(8, uiCode, "dlt_depth_value0[layerId]");   // entry0
    535                 aiIdx2DepthValue[0] = uiCode;
    536 
    537                 if (uiMaxDiff == uiMinDiff)
    538                 {
    539                   for (UInt d=1; d<uiNumDepthValues; d++)
    540                   {
    541                     aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + 0;
    542                   }
    543                 }
    544                 else
    545                 {
    546                   uiCodeLength = (UInt) ceil(Log2(uiMaxDiff - uiMinDiff + 1));
    547                   for (UInt d=1; d<uiNumDepthValues; d++)
    548                   {
    549                     READ_CODE(uiCodeLength, uiCode, "dlt_depth_value_diff_minus_min[ layerId ][ j ]");
    550                     aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + uiCode;
    551                   }
    552                 }
    553 
    554               }
    555             }
    556            
    557 #if H_3D_DELTA_DLT
    558             if( pcDLT->getInterViewDltPredEnableFlag( i ) )
    559             {
    560               // interpret decoded values as delta DLT
    561               AOF( pcVPS->getDepthId( 1 ) == 1 );
    562               AOF( i > 1 );
    563               // assumes ref layer id to be 1
    564               Int* piRefDLT = pcDLT->idx2DepthValue( 1 );
    565               UInt uiRefNum = pcDLT->getNumDepthValues( 1 );
    566               pcDLT->setDeltaDLT(i, piRefDLT, uiRefNum, aiIdx2DepthValue, uiNumDepthValues);
    567             }
    568             else
    569             {
    570               // store final DLT
    571               pcDLT->setDepthLUTs(i, aiIdx2DepthValue, uiNumDepthValues);
    572             }
    573 #else
    574             // store final DLT
    575             pcDLT->setDepthLUTs(i, aiIdx2DepthValue, uiNumDepthValues);
    576 #endif
    577           }
    578         }
    579       }
    580     }
    581   }
    582 
    583   pcPPS->setDLT( pcDLT );
    584 }
    585 #endif
    586398
    587399Void  TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS)
     
    763575}
    764576
    765 #if H_3D
    766 Void TDecCavlc::parseSPS(TComSPS* pcSPS, Int viewIndex, Bool depthFlag )
    767 #else
    768577Void TDecCavlc::parseSPS(TComSPS* pcSPS)
    769 #endif
    770578{
    771579#if ENC_DEC_TRACE 
     
    1041849    READ_FLAG( uiCode, "sps_range_extensions_flag" ); pcSPS->setSpsRangeExtensionsFlag( uiCode == 1 );
    1042850    READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); pcSPS->setSpsMultilayerExtensionFlag( uiCode == 1 );
    1043 #if !H_3D
    1044851    READ_CODE( 6, uiCode, "sps_extension_6bits" ); pcSPS->setSpsExtension6bits( uiCode );
    1045 #else
    1046     READ_FLAG( uiCode, "sps_3d_extension_flag" ); pcSPS->setSps3dExtensionFlag( uiCode == 1 );
    1047     READ_CODE( 5, uiCode, "sps_extension_5bits" ); pcSPS->setSpsExtension5bits( uiCode );
    1048 #endif
    1049852  }
    1050853
     
    1059862  }
    1060863
    1061 #if H_3D
    1062   if ( pcSPS->getSps3dExtensionFlag() )
    1063   {
    1064     parseSPSExtension2( pcSPS, viewIndex, depthFlag  );
    1065   }
    1066 
    1067   if ( pcSPS->getSpsExtension5bits() )
    1068   {
    1069 #else
    1070864  if ( pcSPS->getSpsExtension6bits() )
    1071865  {
    1072 #endif
    1073866
    1074867#endif
     
    1104897}
    1105898
    1106 #if H_3D
    1107 Void TDecCavlc::parseSPSExtension2( TComSPS* pcSPS, Int viewIndex, Bool depthFlag )
    1108 {
    1109 #if !MTK_I0099_VPS_EX2
    1110   UInt uiCode;
    1111 #if H_3D_QTLPC
    1112   //GT: This has to go to VPS
    1113   if( depthFlag )
    1114   {
    1115     READ_FLAG( uiCode, "use_qtl_flag" );
    1116     pcSPS->setUseQTL( uiCode );
    1117     READ_FLAG( uiCode, "use_pc_flag" );
    1118     pcSPS->setUsePC( uiCode );
    1119   }
    1120 #endif
    1121 #endif
    1122 }
    1123 #endif
    1124899
    1125900#if H_MV_HLS10_PPS
     
    12581033    if (uiCode)
    12591034    {
    1260 #if H_3D
    1261       m_pcBitstream->readOutTrailingBits();
    1262       pcVPS->createCamPars(pcVPS->getNumViews());
    1263       parseVPSExtension2( pcVPS );   
    1264       READ_FLAG( uiCode,  "vps_extension3_flag" );
    1265       if (uiCode)
    1266       {     
    1267 #endif
    12681035#endif 
    12691036        while ( xMoreRbspData() )
     
    12721039        }
    12731040#if H_MV
    1274 #if H_3D
    1275       }
    1276 #endif
    12771041    }
    12781042#endif
     
    21021866}
    21031867
    2104 #if H_3D
    2105 Void TDecCavlc::parseVPSExtension2( TComVPS* pcVPS )
    2106 {
    2107   UInt uiCode;
    2108 #if SEC_VPS_CLEANUP_I0090
    2109   for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
    2110 #else
    2111   for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
    2112 #endif
    2113   {
    2114 #if H_3D_ARP
    2115     pcVPS->setUseAdvRP  ( i, 0 );
    2116     pcVPS->setARPStepNum( i, 1 );
    2117 #endif 
    2118 #if H_3D_SPIVMP
    2119     pcVPS->setSubPULog2Size(i, 0);
    2120 #endif
    2121 #if !SEC_VPS_CLEANUP_I0090
    2122     if ( i != 0 )
    2123 #endif
    2124     {
    2125 #if MTK_I0099_VPS_EX2
    2126       READ_FLAG( uiCode, "iv_mv_pred_flag[i]");          pcVPS->setIvMvPredFlag         ( i, uiCode == 1 ? true : false );
    2127 #if SEC_HLS_CLEANUP_I0100
    2128       READ_FLAG( uiCode, "iv_mv_scaling_flag[i]");       pcVPS->setIvMvScalingFlag         ( i, uiCode == 1 ? true : false );
    2129 #endif
    2130 #endif
    2131       if( !( pcVPS->getDepthId( i ) == 1 ) )
    2132       {
    2133 #if H_3D_IV_MERGE
    2134 #if !MTK_I0099_VPS_EX2
    2135         READ_FLAG( uiCode, "iv_mv_pred_flag[i]");          pcVPS->setIvMvPredFlag         ( i, uiCode == 1 ? true : false );
    2136 #endif
    2137         if( !pcVPS->getNumDirectRefLayers(i) )
    2138         {
    2139           assert( !uiCode );         
    2140         }
    2141 #if H_3D_SPIVMP
    2142         READ_UVLC (uiCode, "log2_sub_PU_size_minus3[i]");     pcVPS->setSubPULog2Size(i, uiCode+3);
    2143 #endif
    2144 #endif
    2145 #if H_3D_ARP
    2146         READ_FLAG( uiCode, "iv_res_pred_flag[i]"  );       pcVPS->setUseAdvRP  ( i, uiCode ); pcVPS->setARPStepNum( i, uiCode ? H_3D_ARP_WFNR : 1 );
    2147         if( !pcVPS->getNumDirectRefLayers(i) )
    2148         {
    2149           assert( !uiCode );         
    2150         }
    2151 #endif
    2152 #if H_3D_NBDV_REF
    2153         READ_FLAG( uiCode, "depth_refinement_flag[i]");    pcVPS->setDepthRefinementFlag  ( i, uiCode == 1 ? true : false );
    2154 #endif
    2155 #if H_3D_VSP
    2156         READ_FLAG( uiCode, "view_synthesis_pred_flag[i]"); pcVPS->setViewSynthesisPredFlag( i, uiCode == 1 ? true : false );
    2157         if( !pcVPS->getNumDirectRefLayers(i) )
    2158         {
    2159           assert( !uiCode );         
    2160         }
    2161 #endif
    2162 #if H_3D_DBBP
    2163           READ_FLAG( uiCode, "use_dbbp_flag[i]" ); pcVPS->setUseDBBP( i, uiCode == 1 ? true : false );
    2164 #endif
    2165       }
    2166       else
    2167       {
    2168 #if !MTK_I0099_VPS_EX2
    2169 #if H_3D_IV_MERGE
    2170         if(i!=1)
    2171         {
    2172           READ_FLAG( uiCode, "iv_mv_pred_flag[i]");          pcVPS->setIvMvPredFlag         ( i, uiCode == 1 ? true : false );
    2173           if( !pcVPS->getNumDirectRefLayers(i) )
    2174           {
    2175             assert( !uiCode );         
    2176           }
    2177         }
    2178 #endif
    2179 #if H_3D_SPIVMP
    2180         if (i!=1)
    2181         {
    2182           READ_UVLC (uiCode, "log2_sub_PU_size_minus3[i]");     pcVPS->setSubPULog2Size(i, uiCode+3);
    2183         }
    2184 #endif
    2185 #endif
    2186 #if H_3D_IV_MERGE
    2187         READ_FLAG( uiCode, "mpi_flag[i]" );             pcVPS->setMPIFlag( i, uiCode == 1 ? true : false );
    2188 #endif
    2189 #if MTK_I0099_VPS_EX2
    2190         READ_UVLC (uiCode, "log2_mpi_sub_PU_size_minus3[i]");     pcVPS->setSubPUMPILog2Size(i, uiCode+3);
    2191 #endif
    2192         READ_FLAG( uiCode, "vps_depth_modes_flag[i]" );             pcVPS->setVpsDepthModesFlag( i, uiCode == 1 ? true : false );
    2193 #if SEPARATE_FLAG_I0085
    2194         READ_FLAG( uiCode, "ivp_flag[i]" );                   pcVPS->setIVPFlag( i, uiCode == 1 ? true : false );
    2195 #endif
    2196 #if MTK_I0099_VPS_EX2
    2197         READ_FLAG( uiCode, "lim_qt_pred_flag[i]");                  pcVPS->setLimQtPredFlag     ( i, uiCode == 1 ? true : false );
    2198 #endif
    2199 #if H_3D_INTER_SDC
    2200             READ_FLAG( uiCode, "depth_inter_SDC_flag" );              pcVPS->setInterSDCFlag( i, uiCode ? true : false );
    2201 #endif
    2202       }
    2203     }
    2204   }
    2205 
    2206   UInt uiCamParPrecision = 0;
    2207   Bool bCamParSlice      = false;
    2208   Bool bCamParPresentFlag = false;
    2209 
    2210   READ_UVLC( uiCamParPrecision, "cp_precision" );
    2211 #if SEC_VPS_CLEANUP_I0090
    2212   for (UInt viewIndex=1; viewIndex<pcVPS->getNumViews(); viewIndex++)
    2213 #else
    2214   for (UInt viewIndex=0; viewIndex<pcVPS->getNumViews(); viewIndex++)
    2215 #endif
    2216   {
    2217     pcVPS->setCamParPresent         ( viewIndex, false );
    2218     pcVPS->setHasCamParInSliceHeader( viewIndex, false );
    2219     READ_FLAG( uiCode, "cp_present_flag[i]" );                  bCamParPresentFlag = ( uiCode == 1);
    2220     if ( bCamParPresentFlag )
    2221     {
    2222       READ_FLAG( uiCode, "cp_in_slice_segment_header_flag[i]" );          bCamParSlice = ( uiCode == 1);
    2223       if ( !bCamParSlice )
    2224       {
    2225         for( UInt uiBaseIndex = 0; uiBaseIndex < viewIndex; uiBaseIndex++ )
    2226         {
    2227           Int iCode;
    2228           READ_SVLC( iCode, "vps_cp_scale" );                m_aaiTempScale  [ uiBaseIndex ][ viewIndex ]   = iCode;
    2229           READ_SVLC( iCode, "vps_cp_off" );                  m_aaiTempOffset [ uiBaseIndex ][ viewIndex ]   = iCode;
    2230           READ_SVLC( iCode, "vps_cp_inv_scale_plus_scale" ); m_aaiTempScale  [ viewIndex   ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ viewIndex ];
    2231           READ_SVLC( iCode, "vps_cp_inv_off_plus_off" );     m_aaiTempOffset [ viewIndex   ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ viewIndex ];
    2232         }
    2233       }
    2234       pcVPS->initCamParaVPS( viewIndex, bCamParPresentFlag, uiCamParPrecision, bCamParSlice, m_aaiTempScale, m_aaiTempOffset );
    2235     }
    2236   }
    2237 #if !MTK_I0099_VPS_EX2
    2238   READ_UVLC (uiCode, "log2_sub_PU_MPI_size_minus3");              pcVPS->setSubPUMPILog2Size( uiCode + 3 );
    2239 #endif
    2240 #if !SEC_HLS_CLEANUP_I0100
    2241   READ_FLAG( uiCode, "iv_mv_scaling_flag");                       pcVPS->setIvMvScalingFlag( uiCode == 1 ? true : false );
    2242 #endif
    2243 }
    2244 #endif
    22451868#endif
    22461869#if H_MV
     
    22991922  rpcSlice->setViewId   ( vps->getViewId   ( rpcSlice->getLayerId() )      );
    23001923  rpcSlice->setViewIndex( vps->getViewIndex( rpcSlice->getLayerId() )      ); 
    2301 #if H_3D 
    2302   rpcSlice->setIsDepth  ( vps->getDepthId  ( rpcSlice->getLayerId() ) == 1 );
    2303 #endif
    23041924#endif
    23051925  rpcSlice->setSPS(sps);
     
    28642484      rpcSlice->initWpScaling();
    28652485    }
    2866 #if H_3D_IC
    2867 #if SEC_HLS_CLEANUP_I0100
    2868     else if( rpcSlice->getViewIndex() && ( rpcSlice->getSliceType() == P_SLICE || rpcSlice->getSliceType() == B_SLICE ) && !rpcSlice->getIsDepth() && vps->getNumDirectRefLayers( layerId ) > 0 )
    2869 #else
    2870     else if( rpcSlice->getViewIndex() && ( rpcSlice->getSliceType() == P_SLICE || rpcSlice->getSliceType() == B_SLICE ) && !rpcSlice->getIsDepth())
    2871 #endif
    2872     {
    2873       UInt uiCodeTmp = 0;
    2874 
    2875       READ_FLAG ( uiCodeTmp, "slice_ic_enable_flag" );
    2876       rpcSlice->setApplyIC( uiCodeTmp );
    2877 
    2878       if ( uiCodeTmp )
    2879       {
    2880         READ_FLAG ( uiCodeTmp, "ic_skip_mergeidx0" );
    2881         rpcSlice->setIcSkipParseFlag( uiCodeTmp );
    2882       }
    2883     }
    2884 #endif
    2885 #if MTK_SINGLE_DEPTH_MODE_I0095
    2886     if(rpcSlice->getIsDepth())
    2887     {
    2888       UInt uiCodeTmp = 0;
    2889       READ_FLAG( uiCodeTmp, "slice_enable_single_depth_mode" );
    2890       rpcSlice->setApplySingleDepthMode(uiCodeTmp);
    2891     }
    2892 #endif
    28932486    if (!rpcSlice->isIntra())
    28942487    {
    28952488      READ_UVLC( uiCode, "five_minus_max_num_merge_cand");
    2896 #if H_3D_IV_MERGE
    2897       if(rpcSlice->getIsDepth())
    2898       {
    2899         Bool bMPIFlag = rpcSlice->getVPS()->getMPIFlag( rpcSlice->getLayerIdInVps() ) ;
    2900         Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ;
    2901         rpcSlice->setMaxNumMergeCand(( ( bMPIFlag || ivMvPredFlag ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode);
    2902       }
    2903       else
    2904       {
    2905         Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ;
    2906         rpcSlice->setMaxNumMergeCand(( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode);
    2907       }
    2908 
    2909 #else
    29102489      rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode);
    2911 #endif
    29122490    }
    29132491
     
    30082586  }
    30092587
    3010 #if H_3D
    3011 #if LGE_FCO_I0116
    3012   if( rpcSlice->getVPS()->hasCamParInSliceHeader( rpcSlice->getViewIndex() )  && rpcSlice->getIsDepth() )
    3013 #else
    3014   if( rpcSlice->getVPS()->hasCamParInSliceHeader( rpcSlice->getViewIndex() )  && !rpcSlice->getIsDepth() )
    3015 #endif
    3016   {
    3017     UInt uiViewIndex = rpcSlice->getViewIndex();
    3018     for( UInt uiBaseIndex = 0; uiBaseIndex < uiViewIndex; uiBaseIndex++ )
    3019     {
    3020       READ_SVLC( iCode, "cp_scale" );                m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ] = iCode;
    3021       READ_SVLC( iCode, "cp_off" );                  m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ] = iCode;
    3022       READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); m_aaiTempScale [ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ];
    3023       READ_SVLC( iCode, "cp_inv_off_plus_off" );     m_aaiTempOffset[ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ];
    3024     }
    3025     rpcSlice->setCamparaSlice( m_aaiTempScale, m_aaiTempOffset );
    3026   }
    3027 #endif
    30282588
    30292589  if(pps->getSliceHeaderExtensionPresentFlag())
     
    33312891  assert(0);
    33322892}
    3333 #if MTK_SINGLE_DEPTH_MODE_I0095
    3334 Void TDecCavlc::parseSingleDepthMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
    3335 {
    3336   assert(0);
    3337 }
    3338 #endif
    33392893Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
    33402894{
     
    34513005}
    34523006
    3453 #if H_3D_ARP
    3454 Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    3455 {
    3456   assert(0);
    3457 }
    3458 #endif
    3459 #if H_3D_IC
    3460 Void TDecCavlc::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    3461 {
    3462   assert(0);
    3463 }
    3464 #endif
    3465 #if H_3D_INTER_SDC
    3466 Void TDecCavlc::parseDeltaDC( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
    3467 {
    3468   assert(0);
    3469 }
    3470 
    3471 Void TDecCavlc::parseSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    3472 {
    3473   assert(0);
    3474 }
    3475 
    3476 #endif
    3477 #if H_3D_DBBP
    3478   Void TDecCavlc::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    3479   {
    3480     assert(0);
    3481   }
    3482 #endif
    34833007// ====================================================================================================================
    34843008// Protected member functions
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecCAVLC.h

    r1066 r1072  
    6363  void  parseShortTermRefPicSet            (TComSPS* pcSPS, TComReferencePictureSet* pcRPS, Int idx);
    6464 
    65 #if H_3D
    66   Int**    m_aaiTempScale;
    67   Int**    m_aaiTempOffset;
    68 #endif
    6965
    7066public:
     
    8985  Void  parseSPSExtension   ( TComSPS* pcSPS ); 
    9086#endif
    91 #if H_3D
    92   Void  parseVPSExtension2  ( TComVPS* pcVPS );
    93   Void  parseSPSExtension2  ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag );
    94   Void  parseSPS            ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag );
    95 #else
    9687  Void  parseSPS            ( TComSPS* pcSPS );
    97 #endif
    9888
    9989#if H_MV_HLS10_PPS
     
    10494
    10595
    106 #if H_3D
    107   Void  parsePPS            ( TComPPS* pcPPS, TComVPS* pcVPS );
    108   Void  parsePPSExtension   ( TComPPS* pcPPS, TComVPS* pcVPS );
    109 #else
    11096  Void  parsePPS            ( TComPPS* pcPPS);
    111 #endif
    11297
    11398  Void  parseVUI            ( TComVUI* pcVUI, TComSPS* pcSPS );
     
    126111 
    127112  Void  parseSkipFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    128 #if MTK_SINGLE_DEPTH_MODE_I0095
    129   Void  parseSingleDepthMode        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    130 #endif 
    131113  Void  parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    132114  Void parseMergeFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
    133115  Void parseMergeIndex      ( TComDataCU* pcCU, UInt& ruiMergeIndex );
    134 #if H_3D_ARP
    135   Void parseARPW            ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    136 #endif
    137 #if H_3D_IC
    138   Void  parseICFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    139 #endif
    140 #if H_3D_INTER_SDC
    141   Void  parseDeltaDC        ( TComDataCU* pcCU, UInt absPartIdx, UInt depth );
    142   Void  parseSDCFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    143 #endif
    144 #if H_3D_DBBP
    145   Void  parseDBBPFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    146 #endif
    147116  Void parseSplitFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    148117  Void parsePartSize        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecCu.cpp

    r1066 r1072  
    5050  m_ppcYuvReco = NULL;
    5151  m_ppcCU      = NULL;
    52 #if H_3D_DBBP
    53   m_ppcYuvRecoDBBP = NULL;
    54 #endif
    5552}
    5653
     
    7875  m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
    7976  m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
    80 #if H_3D_DBBP
    81   m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1];
    82 #endif
    8377 
    8478  UInt uiNumPartitions;
     
    9286    m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight );
    9387    m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
    94 #if H_3D_DBBP
    95     m_ppcYuvRecoDBBP[ui] = new TComYuv;    m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight );
    96 #endif
    9788  }
    9889 
     
    115106    m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
    116107    m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
    117 #if H_3D_DBBP
    118     m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL;
    119 #endif
    120108  }
    121109 
     
    123111  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
    124112  delete [] m_ppcCU     ; m_ppcCU      = NULL;
    125 #if H_3D_DBBP
    126   delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL;
    127 #endif
    128113}
    129114
     
    150135Void TDecCu::decompressCU( TComDataCU* pcCU )
    151136{
    152 #if !H_3D_IV_MERGE
    153137  xDecompressCU( pcCU, 0,  0 );
    154 #endif
    155138}
    156139
     
    293276
    294277
    295 #if H_3D_DDD
    296       pcCU->setUseDDD( false, uiAbsPartIdx, uiDepth );
    297 #endif
    298278
    299279  if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     
    302282    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
    303283  }
    304 #if H_3D_NBDV
    305   DisInfo DvInfo;
    306   DvInfo.bDV = false;
    307   DvInfo.m_acNBDV.setZero();
    308   DvInfo.m_aVIdxCan = 0;
    309 #if H_3D_NBDV_REF 
    310   DvInfo.m_acDoNBDV.setZero();
    311 #endif
    312  
    313  
    314   if(!pcCU->getSlice()->isIntra())
    315   {
    316 #if H_3D_ARP && H_3D_IV_MERGE
    317     if( pcCU->getSlice()->getVPS()->getUseAdvRP( pcCU->getSlice()->getLayerId() ) || pcCU->getSlice()->getVPS()->getIvMvPredFlag( pcCU->getSlice()->getLayerId() ))
    318 #else
    319 #if H_3D_ARP
    320     if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) )
    321 #else
    322 #if H_3D_IV_MERGE
    323     if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) )
    324 #else
    325     if (0)
    326 #endif
    327 #endif
    328 #endif
    329     {
    330       m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true );
    331       m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx);
    332       PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0);
    333       UChar cWidTemp     = m_ppcCU[uiDepth]->getWidth(0);
    334       UChar cHeightTemp  = m_ppcCU[uiDepth]->getHeight(0);
    335       m_ppcCU[uiDepth]->setWidth  ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth)  );
    336       m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth)  );
    337       m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
    338 #if H_3D_IV_MERGE
    339       if( pcCU->getSlice()->getIsDepth())
    340       {
    341         DvInfo.bDV = m_ppcCU[uiDepth]->getDispforDepth(0, 0, &DvInfo);
    342       }
    343       else
    344       {
    345 #endif
    346 #if H_3D_NBDV_REF
    347       if(pcCU->getSlice()->getVPS()->getDepthRefinementFlag( pcCU->getSlice()->getLayerIdInVps() ))  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
    348       {
    349         DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true);
    350       }
    351       else
    352 #endif
    353       {
    354         DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
    355       }
    356 #if H_3D_IV_MERGE
    357       }
    358 #endif
    359 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
    360       if ( g_decTraceDispDer )
    361       {
    362         DTRACE_CU( "RefViewIdx",  DvInfo.m_aVIdxCan );       
    363         DTRACE_CU( "MvDisp[x]", DvInfo.m_acNBDV.getHor() );
    364         DTRACE_CU( "MvDisp[y]", DvInfo.m_acNBDV.getVer() );
    365         DTRACE_CU( "MvRefinedDisp[x]", DvInfo.m_acDoNBDV.getHor() );
    366         DTRACE_CU( "MvRefinedDisp[y]", DvInfo.m_acDoNBDV.getVer() );
    367       }
    368 #endif
    369 
    370       pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
    371       m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth );
    372       m_ppcCU[uiDepth]->setWidth  ( 0, cWidTemp );
    373       m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp );
    374      }
    375   }
    376 #endif
    377284  if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
    378285  {
     
    395302    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
    396303    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
    397 #if H_3D_IV_MERGE
    398     m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
    399     TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    400     UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
    401 #else
    402304    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
    403305    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    404 #endif
    405306    Int numValidMergeCand = 0;
    406307    for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
     
    410311    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
    411312    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
    412 #if H_3D_ARP
    413     m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
    414 #endif
    415 #if H_3D_IC
    416     m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
    417 #endif
    418 
    419 #if H_3D_VSP
    420     Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    421     memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    422 #if !FIX_TICKET_79
    423     InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
    424 #endif
    425 #if H_3D_SPIVMP
    426     Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
    427     memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    428     TComMvField*  pcMvFieldSP;
    429     UChar* puhInterDirSP;
    430     pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2];
    431     puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()];
    432 #endif
    433     m_ppcCU[uiDepth]->initAvailableFlags();
     313
    434314    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    435     m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
    436 #if !FIX_TICKET_79
    437       , inheritedVSPDisInfo
    438 #endif
    439 #if H_3D_SPIVMP
    440       , pcMvFieldSP, puhInterDirSP
    441 #endif
    442       , numValidMergeCand, uiMergeIndex );
    443 
    444     m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
    445 #if H_3D_SPIVMP
    446       , bSPIVMPFlag
    447 #endif
    448       , numValidMergeCand );
    449     pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
    450 #else
    451 #if H_3D
    452     m_ppcCU[uiDepth]->initAvailableFlags();
    453     m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    454     m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    455 #else
    456     m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    457 #endif
    458 #endif
    459 #if H_3D_VSP && !FIX_TICKET_79
    460     if(vspFlag[uiMergeIndex])
    461     {
    462       pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiAbsPartIdx, 0, uiDepth);
    463     }
    464 #endif
    465315    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
    466316
    467 #if H_3D_DDD
    468     if( uiMergeIndex == m_ppcCU[uiDepth]->getUseDDDCandIdx() )
    469     {
    470         assert( pcCU->getSlice()->getViewIndex() != 0 );
    471         pcCU->setUseDDD( true, uiAbsPartIdx, 0, uiDepth );
    472         pcCU->setDDDepthSubParts( m_ppcCU[uiDepth]->getDDTmpDepth(),uiAbsPartIdx, 0, uiDepth );
    473     }
    474 #endif
    475317
    476318    TComMv cTmpMv( 0, 0 );
     
    483325        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
    484326        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
    485 #if H_3D_VSP
    486         if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 )
    487         {
    488           if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
    489           {
    490             UInt dummy;
    491             Int vspSize;
    492             Int width, height;
    493             m_ppcCU[uiDepth]->getPartIndexAndSize( uiAbsPartIdx, dummy, width, height );
    494             m_ppcCU[uiDepth]->setMvFieldPUForVSP( pcCU, uiAbsPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
    495             pcCU->setVSPFlag( uiAbsPartIdx, vspSize );
    496           }
    497         }
    498 #endif
    499327#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
    500328        if ( g_decTraceMvFromMerge )
     
    516344      }
    517345    }
    518 #if H_3D_SPIVMP
    519     pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
    520     if (bSPIVMPFlag[uiMergeIndex])
    521     {
    522       UInt uiSPAddr;
    523       Int iWidth = pcCU->getWidth(uiAbsPartIdx);
    524       Int iHeight = pcCU->getHeight(uiAbsPartIdx);
    525 
    526       Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    527 
    528       pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    529 
    530       for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    531       {
    532         pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
    533         pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
    534         pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
    535         pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
    536       }
    537     }
    538     delete[] pcMvFieldSP;
    539     delete[] puhInterDirSP;
    540 #endif
    541346
    542347    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
    543 #if H_3D_IV_MERGE
    544     xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
    545 #endif
    546348    return;
    547349  }
    548 #if MTK_SINGLE_DEPTH_MODE_I0095
    549   m_pcEntropyDecoder->decodeSingleDepthMode( pcCU, uiAbsPartIdx, uiDepth );
    550   if(!pcCU->getSingleDepthFlag(uiAbsPartIdx))
    551   {
    552 #endif
    553350  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
    554351  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
    555352
    556 #if H_3D_DIM_SDC
    557   m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
    558 #endif
    559353  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
    560354  {
     
    564358    {
    565359      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
    566 #if H_3D_IV_MERGE
    567       xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
    568 #endif
    569360      return;
    570361    }
     
    580371  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
    581372  setdQPFlag( bCodeDQP );
    582 #if MTK_SINGLE_DEPTH_MODE_I0095
    583   }
    584 #endif
    585373  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
    586 #if H_3D_IV_MERGE
    587   xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
    588 #endif
    589374}
    590375
     
    602387{
    603388  TComPic* pcPic = pcCU->getPic();
    604 #if !H_3D_IV_MERGE
    605389  Bool bBoundary = false;
    606390  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
     
    637421    return;
    638422  }
    639 #endif 
    640423  // Residual reconstruction
    641424  m_ppcYuvResi[uiDepth]->clear();
     
    657440  {
    658441    case MODE_INTER:
    659 #if H_3D_DBBP
    660       if( m_ppcCU[uiDepth]->getDBBPFlag(0) )
    661       {
    662         xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
    663       }
    664       else
    665       {
    666 #endif
    667 #if H_3D_INTER_SDC
    668       if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) )
    669       {
    670         xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
    671       }
    672       else
    673       {
    674 #endif
    675442      xReconInter( m_ppcCU[uiDepth], uiDepth );
    676 #if H_3D_INTER_SDC
    677       }
    678 #endif
    679 #if H_3D_DBBP
    680       }
    681 #endif
    682443      break;
    683444    case MODE_INTRA:
    684 #if MTK_SINGLE_DEPTH_MODE_I0095
    685       if( m_ppcCU[uiDepth]->getSingleDepthFlag(0) )
    686         xReconIntraSingleDepth( m_ppcCU[uiDepth], 0, uiDepth );
    687 #if H_3D_DIM_SDC
    688       else if( m_ppcCU[uiDepth]->getSDCFlag(0) )
    689         xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
    690 #endif
    691       else
    692 #else
    693 #if H_3D_DIM_SDC
    694       if( m_ppcCU[uiDepth]->getSDCFlag(0) )
    695         xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
    696       else
    697 #endif
    698 #endif
    699445      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
    700446      break;
     
    730476  }
    731477}
    732 #if MTK_SINGLE_DEPTH_MODE_I0095
    733 Void TDecCu::xReconIntraSingleDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    734 {
    735   UInt uiWidth        = pcCU->getWidth  ( 0 );
    736   UInt uiHeight       = pcCU->getHeight ( 0 );
    737 
    738   TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
    739 
    740   UInt    uiStride    = pcRecoYuv->getStride  ();
    741   Pel*    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
    742 
    743 
    744   AOF( uiWidth == uiHeight );
    745   AOF( uiAbsPartIdx == 0 );
    746 
    747   //construction of depth candidates
    748   Pel testDepth;
    749   Pel DepthNeighbours[5];
    750   Int index =0;
    751   for( Int i = 0; (i < 5) && (index<MTK_SINGLE_DEPTH_MODE_CANDIDATE_LIST_SIZE) ; i++ )
    752   {
    753     if(!pcCU->getNeighDepth (0, uiAbsPartIdx, &testDepth, i))
    754     {
    755       continue;
    756     }
    757     DepthNeighbours[index]=testDepth;
    758     index++;
    759     for(Int j=0;j<index-1;j++)
    760     {
    761      if( (DepthNeighbours[index-1]==DepthNeighbours[j]) )
    762      {
    763        index--;
    764        break;
    765      }
    766     }
    767   }
    768 
    769   if(index==0)
    770   {
    771     DepthNeighbours[index]=1<<(g_bitDepthY-1);
    772     index++;
    773   }
    774 
    775   if(index==1)
    776   {
    777     DepthNeighbours[index]=ClipY(DepthNeighbours[0] + 1 );
    778     index++;
    779   }
    780 
    781   for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    782   {
    783     for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    784     {
    785       piReco[ uiX ] =DepthNeighbours[(Int)pcCU->getSingleDepthValue(uiAbsPartIdx)];
    786     }
    787     piReco     += uiStride;
    788   }
    789 
    790   // clear UV
    791   UInt  uiStrideC     = pcRecoYuv->getCStride();
    792   Pel   *pRecCb       = pcRecoYuv->getCbAddr();
    793   Pel   *pRecCr       = pcRecoYuv->getCrAddr();
    794 
    795   for (Int y=0; y<uiHeight/2; y++)
    796   {
    797     for (Int x=0; x<uiWidth/2; x++)
    798     {
    799       pRecCb[x] = 1<<(g_bitDepthC-1);
    800       pRecCr[x] = 1<<(g_bitDepthC-1);
    801     }
    802 
    803     pRecCb += uiStrideC;
    804     pRecCr += uiStrideC;
    805   }
    806 }
    807 #endif
    808 #if H_3D_INTER_SDC
    809 Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    810 {
    811   // inter prediction
    812   m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
    813 
    814   UInt  uiWidth      = pcCU->getWidth ( 0 );
    815   UInt  uiHeight     = pcCU->getHeight( 0 );
    816 
    817   Pel  *pResi;
    818   UInt uiPelX, uiPelY;
    819   UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride();
    820 
    821   pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 );
    822   for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
    823   {
    824     for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
    825     {
    826       pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 );
    827     }
    828     pResi += uiResiStride;
    829   }
    830 
    831   m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
    832 
    833   // clear UV
    834   UInt  uiStrideC     = m_ppcYuvReco[uiDepth]->getCStride();
    835   Pel   *pRecCb       = m_ppcYuvReco[uiDepth]->getCbAddr();
    836   Pel   *pRecCr       = m_ppcYuvReco[uiDepth]->getCrAddr();
    837 
    838   for (Int y = 0; y < uiHeight/2; y++)
    839   {
    840     for (Int x = 0; x < uiWidth/2; x++)
    841     {
    842       pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
    843       pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
    844     }
    845 
    846     pRecCb += uiStrideC;
    847     pRecCr += uiStrideC;
    848   }
    849 }
    850 #endif
    851 
    852 #if H_3D_DBBP
    853 Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    854 {
    855   AOF(!pcCU->getSlice()->getIsDepth());
    856   AOF(!pcCU->getSlice()->isIntra());
    857   PartSize ePartSize = pcCU->getPartitionSize( 0 );
    858  
    859   // get collocated depth block
    860   UInt uiDepthStride = 0;
    861 #if LGE_FCO_I0116
    862   Pel* pDepthPels = pcCU->getVirtualDepthBlock(pcCU->getZorderIdxInCU(), pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
    863 #else
    864   Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
    865 #endif
    866   AOF( pDepthPels != NULL );
    867   AOF( uiDepthStride != 0 );
    868  
    869   // compute mask by segmenting depth block
    870   Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE];
    871   Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask);
    872   AOF(bValidMask);
    873  
    874   DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
    875   TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] };
    876  
    877   // first, extract the two sets of motion parameters
    878   UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
    879   for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
    880   {
    881     UInt uiPartAddr = uiSegment*uiPUOffset;
    882    
    883     pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr);
    884    
    885     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    886     {
    887       RefPicList eRefList = (RefPicList)uiRefListIdx;
    888       pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]);
    889     }
    890    
    891     AOF( pcCU->getARPW(uiPartAddr) == 0 );
    892     AOF( pcCU->getICFlag(uiPartAddr) == false );
    893     AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false );
    894     AOF( pcCU->getVSPFlag(uiPartAddr) == 0 );
    895   }
    896  
    897   // do motion compensation for each segment as 2Nx2N
    898   pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
    899   pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
    900   for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
    901   {
    902     pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth );
    903  
    904     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    905     {
    906       RefPicList eRefList = (RefPicList)uiRefListIdx;
    907 
    908       pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 );
    909     }
    910    
    911     // inter prediction
    912     m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] );
    913   }
    914  
    915   // restore motion information in both segments again
    916   pcCU->setPartSizeSubParts( ePartSize,  0, uiDepth );
    917   pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
    918   for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
    919   {
    920     UInt uiPartAddr = uiSegment*uiPUOffset;
    921    
    922     pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth);
    923     pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level
    924    
    925     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    926     {
    927       RefPicList eRefList = (RefPicList)uiRefListIdx;
    928 
    929       pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level
    930     }
    931   }
    932  
    933   // reconstruct final prediction signal by combining both segments
    934 #if SHARP_DBBP_SIMPLE_FLTER_I0109
    935   m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize);
    936 #else
    937   m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0));
    938 #endif
    939  
    940   // inter recon
    941   xDecodeInterTexture( pcCU, 0, uiDepth );
    942  
    943   // clip for only non-zero cbp case
    944   if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
    945   {
    946     m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
    947   }
    948   else
    949   {
    950     m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
    951   }
    952 }
    953 #endif
     478
    954479
    955480Void
     
    988513 
    989514  //===== get prediction signal =====
    990 #if H_3D_DIM
    991   if( isDimMode( uiLumaPredMode ) )
    992   {
    993     m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
    994   }
    995   else
    996   {
    997 #endif
    998515  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
    999 #if H_3D_DIM
    1000   }
    1001 #endif
    1002  
    1003 #if H_3D
    1004   Bool useDltFlag = (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps());
    1005 
    1006   if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag )
    1007 #else
     516 
    1008517  if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) )
    1009 #endif
    1010518  {
    1011519  //===== inverse transform =====
     
    1114622    {
    1115623      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
    1116 #if H_3D_DIM
    1117       mapDepthModeToIntraDir( uiChromaPredMode );
    1118 #endif
    1119624    }
    1120625    m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 
     
    1203708}
    1204709
    1205 #if H_3D_DIM_SDC
    1206 Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    1207 {
    1208   UInt uiWidth        = pcCU->getWidth  ( 0 );
    1209   UInt uiHeight       = pcCU->getHeight ( 0 );
    1210   TComWedgelet* dmm4SegmentationOrg = new TComWedgelet( uiWidth, uiHeight );
    1211   UInt numParts = 1;
    1212   UInt sdcDepth    = 0;
    1213   TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
    1214   TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
    1215   TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
    1216 
    1217   UInt    uiStride = 0;
    1218   Pel*    piReco;
    1219   Pel*    piPred;
    1220   Pel*    piResi;
    1221 
    1222   UInt    uiZOrder;       
    1223   Pel*    piRecIPred;     
    1224   UInt    uiRecIPredStride;
    1225 
    1226   UInt    uiLumaPredMode = 0; 
    1227 
    1228   if ((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1)
    1229   {
    1230     numParts = uiWidth * uiWidth >> (2 * pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize());
    1231     sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
    1232     uiWidth = uiHeight = (1 << pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize());
    1233   }
    1234 
    1235   for ( Int i = 0; i < numParts; i++ )
    1236   {
    1237     uiStride    = pcRecoYuv->getStride  ();
    1238     piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
    1239     piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
    1240     piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
    1241 
    1242     uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
    1243     piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
    1244     uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
    1245 
    1246     uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
    1247 
    1248     AOF( uiWidth == uiHeight );
    1249 
    1250     //===== init availability pattern =====
    1251     Bool  bAboveAvail = false;
    1252     Bool  bLeftAvail  = false;
    1253 
    1254     pcCU->getPattern()->initPattern   ( pcCU, sdcDepth, uiAbsPartIdx );
    1255     pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, sdcDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
    1256 
    1257     TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
    1258     //===== get prediction signal =====
    1259     if( isDimMode( uiLumaPredMode ) )
    1260     {
    1261       m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, false, dmm4Segmentation  );
    1262       Bool* dmm4PatternSplit = dmm4Segmentation->getPattern();
    1263       Bool* dmm4PatternOrg = dmm4SegmentationOrg->getPattern();
    1264       for( UInt k = 0; k < (uiWidth*uiHeight); k++ )
    1265       {
    1266         dmm4PatternOrg[k+(uiAbsPartIdx<<4)] = dmm4PatternSplit[k];
    1267       }
    1268     }
    1269     else
    1270     {
    1271       m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
    1272     }
    1273 
    1274     if ( numParts > 1 )
    1275     {
    1276       for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    1277       {
    1278         for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    1279         {
    1280           piReco        [ uiX ] = ClipY( piPred[ uiX ] );
    1281           piRecIPred    [ uiX ] = piReco[ uiX ];
    1282         }
    1283         piPred     += uiStride;
    1284         piReco     += uiStride;
    1285         piRecIPred += uiRecIPredStride;
    1286       }
    1287     }
    1288     uiAbsPartIdx += ( (uiWidth * uiWidth) >> 4 );
    1289     dmm4Segmentation->destroy(); delete dmm4Segmentation;
    1290   }
    1291   uiAbsPartIdx = 0;
    1292  
    1293   if ( numParts > 1 )
    1294   {
    1295     uiWidth = pcCU->getWidth( 0 );
    1296     uiHeight = pcCU->getHeight( 0 );
    1297   }
    1298   piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
    1299   piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
    1300   piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
    1301   uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
    1302   piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
    1303   uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
    1304   // number of segments depends on prediction mode
    1305   UInt uiNumSegments = 1;
    1306   Bool* pbMask = NULL;
    1307   UInt uiMaskStride = 0;
    1308  
    1309   if( getDimType( uiLumaPredMode ) == DMM1_IDX )
    1310   {
    1311     Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx);
    1312 
    1313 #if SHARP_DMM1_I0110
    1314     WedgeList* pacWedgeList  = pcCU->isDMM1UpscaleMode(uiWidth) ? &g_dmmWedgeLists[(g_aucConvertToBit[pcCU->getDMM1BasePatternWidth(uiWidth)])] :  &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
    1315 #else
    1316     WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
    1317 #endif
    1318     TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
    1319 
    1320     uiNumSegments = 2;
    1321 
    1322 #if SHARP_DMM1_I0110
    1323     pbMask       = pcCU->isDMM1UpscaleMode( uiWidth ) ? pcWedgelet->getScaledPattern(uiWidth) : pcWedgelet->getPattern();
    1324     uiMaskStride = pcCU->isDMM1UpscaleMode( uiWidth ) ? uiWidth : pcWedgelet->getStride();
    1325 #else
    1326     pbMask = pcWedgelet->getPattern();
    1327     uiMaskStride = pcWedgelet->getStride();
    1328 #endif
    1329   }
    1330   if( getDimType( uiLumaPredMode ) == DMM4_IDX )
    1331   {
    1332     uiNumSegments = 2;
    1333     pbMask  = dmm4SegmentationOrg->getPattern();
    1334     uiMaskStride = dmm4SegmentationOrg->getStride();
    1335   }
    1336   // get DC prediction for each segment
    1337   Pel apDCPredValues[2];
    1338   if ( getDimType( uiLumaPredMode ) == DMM1_IDX || getDimType( uiLumaPredMode ) == DMM4_IDX )
    1339   {
    1340     apDCPredValues[0] = pcCU->getDmmPredictor( 0 );
    1341     apDCPredValues[1] = pcCU->getDmmPredictor( 1 );
    1342   }
    1343   else
    1344   {
    1345     m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode);
    1346   }
    1347  
    1348   // reconstruct residual based on mask + DC residuals
    1349   Pel apDCResiValues[2];
    1350   for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
    1351   {
    1352 #if H_3D_DIM_DLT
    1353     Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
    1354     Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
    1355     Pel   pRecoValue  = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
    1356 
    1357     apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
    1358 #else
    1359     apDCResiValues[uiSegment]  = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
    1360 #endif
    1361   }
    1362  
    1363   //===== reconstruction =====
    1364   Bool*pMask      = pbMask;
    1365   Pel* pPred      = piPred;
    1366   Pel* pResi      = piResi;
    1367   Pel* pReco      = piReco;
    1368   Pel* pRecIPred  = piRecIPred;
    1369  
    1370   for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    1371   {
    1372     for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    1373     {
    1374       UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
    1375       assert( ucSegment < uiNumSegments );
    1376      
    1377       Pel pResiDC = apDCResiValues[ucSegment];
    1378      
    1379       pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResiDC );
    1380       pRecIPred[ uiX ] = pReco[ uiX ];
    1381     }
    1382     pPred     += uiStride;
    1383     pResi     += uiStride;
    1384     pReco     += uiStride;
    1385     pRecIPred += uiRecIPredStride;
    1386     pMask     += uiMaskStride;
    1387   }
    1388  
    1389   // clear UV
    1390   UInt  uiStrideC     = pcPredYuv->getCStride();
    1391   Pel   *pRecCb       = pcPredYuv->getCbAddr();
    1392   Pel   *pRecCr       = pcPredYuv->getCrAddr();
    1393  
    1394   for (Int y=0; y<uiHeight/2; y++)
    1395   {
    1396     for (Int x=0; x<uiWidth/2; x++)
    1397     {
    1398       pRecCb[x] = 128;
    1399       pRecCr[x] = 128;
    1400     }
    1401    
    1402     pRecCb += uiStrideC;
    1403     pRecCr += uiStrideC;
    1404   }
    1405   dmm4SegmentationOrg->destroy(); delete dmm4SegmentationOrg;
    1406 }
    1407 #endif
    1408710
    1409711/** Function for deriving recontructed PU/CU Luma sample with QTree structure
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecCu.h

    r1039 r1072  
    6363  TComDataCU**        m_ppcCU;            ///< CU data array
    6464 
    65 #if H_3D_DBBP
    66   TComYuv**           m_ppcYuvRecoDBBP;
    67 #endif
    6865 
    6966  // access channel
     
    10299  Void xReconInter              ( TComDataCU* pcCU, UInt uiDepth );
    103100 
    104 #if H_3D_DBBP
    105   Void xReconInterDBBP          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    106 #endif
    107101 
    108102  Void  xReconIntraQT           ( TComDataCU* pcCU, UInt uiDepth );
     
    123117  Void setdQPFlag               ( Bool b )                { m_bDecodeDQP = b;           }
    124118  Void xFillPCMBuffer           (TComDataCU* pCU, UInt depth);
    125 #if MTK_SINGLE_DEPTH_MODE_I0095
    126   Void xReconIntraSingleDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    127 #endif
    128 #if H_3D_DIM_SDC
    129   Void xReconIntraSDC           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    130 #endif
    131 #if H_3D_INTER_SDC
    132   Void xReconInterSDC           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    133 #endif
    134119};
    135120
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecEntropy.cpp

    r1039 r1072  
    5252  m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
    5353}
    54 #if MTK_SINGLE_DEPTH_MODE_I0095
    55 Void TDecEntropy::decodeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    56 {
    57   if ( !pcCU->getSlice()->getIsDepth() )
    58   {
    59     return;
    60   }
    61   if(!pcCU->getSlice()->getApplySingleDepthMode())
    62   {
    63      return;
    64   }
    65   m_pcEntropyDecoderIf->parseSingleDepthMode( pcCU, uiAbsPartIdx, uiDepth );
    66 }
    67 #endif
    6854Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    6955{
     
    10086}
    10187
    102 #if H_3D_ARP
    103 Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    104 {
    105   if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) )
    106   {
    107     return;
    108   }
    109 
    110   if( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N )
    111   {
    112     pcCU->setARPWSubParts( 0 , uiAbsPartIdx, uiDepth );
    113   }
    114   else
    115   {
    116     m_pcEntropyDecoderIf->parseARPW( pcCU , uiAbsPartIdx , uiDepth );
    117   }
    118 }
    119 #endif
    120 
    121 #if H_3D_IC
    122 Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    123 {
    124   pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
    125 
    126   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
    127   {
    128     return;
    129   }
    130 
    131   if( !pcCU->getSlice()->getApplyIC() )
    132     return;
    133 
    134   if( pcCU->isICFlagRequired( uiAbsPartIdx ) )
    135     m_pcEntropyDecoderIf->parseICFlag( pcCU, uiAbsPartIdx, uiDepth );
    136 }
    137 #endif
     88
    13889
    13990Void TDecEntropy::decodeSplitFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     
    151102  m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth );
    152103 
    153 #if H_3D_DBBP
    154 
    155 #if SEC_DBBP_EXPLICIT_SIG_I0077
    156 #if SEC_DBBP_DISALLOW_8x8_I0078
    157   if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 )
    158 #else
    159   if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) )
    160 #endif
    161 #else
    162 #if SEC_DBBP_DISALLOW_8x8_I0078
    163   if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && pcCU->getWidth(uiAbsPartIdx) > 8 )
    164 #else
    165   if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) )
    166 #endif
    167 #endif
    168   {
    169     decodeDBBPFlag(pcCU, uiAbsPartIdx, uiDepth);
    170 #if !SEC_DBBP_EXPLICIT_SIG_I0077   
    171     if( pcCU->getDBBPFlag(uiAbsPartIdx) )
    172     {
    173      
    174       // get collocated depth block
    175       UInt uiDepthStride = 0;
    176       Pel* pDepthPels = NULL;
    177       pDepthPels = pcCU->getVirtualDepthBlock(uiAbsPartIdx, pcCU->getWidth(uiAbsPartIdx), pcCU->getHeight(uiAbsPartIdx), uiDepthStride);
    178      
    179       AOF( pDepthPels != NULL );
    180       AOF( uiDepthStride != 0 );
    181      
    182       // derive true partitioning for this CU based on depth
    183       // (needs to be done in parsing process as motion vector predictors are also derived during parsing)
    184       PartSize eVirtualPartSize = m_pcPrediction->getPartitionSizeFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(uiAbsPartIdx));
    185       AOF( eVirtualPartSize != SIZE_NONE );
    186      
    187       pcCU->setPartSizeSubParts(eVirtualPartSize, uiAbsPartIdx, uiDepth);
    188      
    189       // make sure that DBBP flag is set for both segments
    190       UInt uiPUOffset = ( g_auiPUOffset[UInt( eVirtualPartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
    191       pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx, 0, uiDepth);
    192       pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx+uiPUOffset, 1, uiDepth);
    193     }
    194 #endif
    195   }
    196 #endif
    197104}
    198105
     
    202109  {
    203110    decodeIntraDirModeLuma  ( pcCU, uiAbsPartIdx, uiDepth );
    204 #if H_3D_DIM_SDC
    205     if(!pcCU->getSDCFlag(uiAbsPartIdx))
    206 #endif
    207111    decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth );
    208112  }
     
    254158  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
    255159
    256 #if H_3D_IV_MERGE
    257   TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    258   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
    259 #else
    260160  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
    261161  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    262 #endif
    263 #if H_3D_SPIVMP
    264   Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
    265   TComMvField*  pcMvFieldSP;
    266   UChar* puhInterDirSP;
    267   pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2];
    268   puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()];
    269 #endif
    270162  for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
    271163  {
     
    277169  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
    278170  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
    279 #if H_3D_IV_MERGE
    280   pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx);
    281 #endif
    282171  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
    283172  {
     
    293182      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
    294183      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
    295 #if H_3D_ARP
    296       decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
    297 #endif
    298 #if H_3D_IC
    299       decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
    300 #endif
    301 #if H_3D_DBBP
    302       if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false )
    303 #else
    304184      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 )
    305 #endif
    306185      {
    307186        pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
    308187        if ( !isMerged )
    309188        {
    310 #if H_3D_VSP
    311           Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    312           memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    313 #if !FIX_TICKET_79
    314           InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
    315 #endif
    316 #if H_3D_SPIVMP
    317           memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    318 #endif
    319           pcSubCU->initAvailableFlags();
    320           pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
    321           pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
    322 #if !FIX_TICKET_79
    323             , inheritedVSPDisInfo
    324 #endif
    325 #if H_3D_SPIVMP
    326             , pcMvFieldSP, puhInterDirSP
    327 #endif
    328             , numValidMergeCand );
    329           pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
    330 #if H_3D_SPIVMP
    331             , bSPIVMPFlag
    332 #endif
    333             , numValidMergeCand );
    334           pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    335 
    336 #if !FIX_TICKET_79
    337           if(vspFlag[uiMergeIndex])
    338           {
    339             pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiSubPartIdx, uiPartIdx, uiDepth);
    340           }
    341 #endif
    342 #else
    343 #if H_3D
    344           pcSubCU->initAvailableFlags();
    345           pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
    346           pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    347 
    348 #else
    349189          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    350 #endif
    351 #endif
    352190          isMerged = true;
    353191        }
     
    357195      {
    358196        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
    359 #if H_3D_VSP
    360         Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    361         memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    362 #if !FIX_TICKET_79
    363         InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
    364 #endif
    365 #if H_3D_SPIVMP
    366         memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    367 #endif
    368         pcSubCU->initAvailableFlags();
    369197        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    370         pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
    371 #if !FIX_TICKET_79
    372           , inheritedVSPDisInfo
    373 #endif
    374 #if H_3D_SPIVMP
    375           , pcMvFieldSP, puhInterDirSP
    376 #endif
    377           ,numValidMergeCand, uiMergeIndex );
    378         pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
    379 #if H_3D_SPIVMP
    380           , bSPIVMPFlag
    381 #endif
    382           ,numValidMergeCand );
    383         pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    384 #if !FIX_TICKET_79
    385         if(vspFlag[uiMergeIndex])
    386         {
    387           pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiSubPartIdx, uiPartIdx, uiDepth);
    388         }
    389 #endif
    390 #else
    391 #if H_3D
    392         pcSubCU->initAvailableFlags();
    393         pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    394         pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    395 #else
    396         pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    397 #endif
    398 #endif
    399198      }
    400199      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    401200
    402 #if H_3D_DDD
    403       if( uiMergeIndex == pcSubCU->getUseDDDCandIdx() )
    404       {
    405           assert( pcCU->getSlice()->getViewIndex() != 0 );
    406           pcCU->setUseDDD( true, uiSubPartIdx, uiPartIdx, uiDepth );
    407           pcCU->setDDDepthSubParts( pcSubCU->getDDTmpDepth(),uiSubPartIdx, uiPartIdx, uiDepth );
    408       }
    409       else
    410       {
    411           pcCU->setUseDDD( false, uiSubPartIdx, uiPartIdx, uiDepth );
    412       }
    413 #endif
    414201
    415202      TComMv cTmpMv( 0, 0 );
     
    422209          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
    423210          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
    424 #if H_3D_VSP
    425 #if H_3D_DBBP
    426           if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) )
    427 #else
    428           if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 )
    429 #endif
    430           {
    431             if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
    432             {
    433               UInt dummy;
    434               Int vspSize;
    435               Int width, height;
    436               pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 );
    437               pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
    438               pcCU->setVSPFlag( uiSubPartIdx, vspSize );
    439             }
    440           }
    441 #endif
    442211        }
    443212      }
    444 #if H_3D_SPIVMP
    445       pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); 
    446       if (bSPIVMPFlag[uiMergeIndex] != 0)
    447       {
    448         Int iWidth, iHeight;
    449         UInt uiIdx;
    450         pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true );
    451 
    452         UInt uiSPAddr;
    453 
    454         Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    455 
    456         pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    457 
    458         for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    459         {
    460           pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
    461           pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
    462           pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
    463           pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
    464         }
    465       }
    466 #endif
    467213    }
    468214    else
     
    478224        }
    479225      }
    480 #if H_3D_ARP
    481       decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
    482 #endif
    483 #if H_3D_IC
    484       decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
    485 #endif
    486     }
    487 #if H_3D_VSP && !FIX_TICKET_75
    488     if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) && (pcCU->getVSPFlag(uiSubPartIdx) == 0))
    489 #else
     226    }
    490227    if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
    491 #endif
    492228    {
    493229      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
     
    496232    }
    497233  }
    498 #if H_3D_SPIVMP
    499   delete[] pcMvFieldSP;
    500   delete[] puhInterDirSP;
    501 #endif
    502234  return;
    503235}
     
    824556  UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
    825557  UInt uiChromaOffset = uiLumaOffset>>2;
    826 #if H_3D_DIM_SDC
    827   if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx) )
    828   {
    829     assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
    830     assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 );
    831     assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 );
    832     assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
    833     assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
    834   }
    835 
    836 #if H_3D_INTER_SDC
    837   if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx) )
    838   {
    839     assert( !pcCU->isSkipped( uiAbsPartIdx ) );
    840     assert( !pcCU->isIntra( uiAbsPartIdx) );
    841     assert( pcCU->getSlice()->getIsDepth() );
    842   }
    843 #endif
    844   if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) )
    845   {
    846     Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
    847     UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
    848  
    849     if( !pcCU->getSDCFlag( uiAbsPartIdx ) )
    850     {
    851       for( Int iPart = 0; iPart < iPartNum; iPart++ )
    852       {
    853         if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE )
    854         {
    855           m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) );
    856         }
    857       }
    858     }
    859     else
    860     {
    861       m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx, uiDepth );
    862       return;
    863     }
    864   }
    865 #endif
    866558
    867559  if( pcCU->isIntra(uiAbsPartIdx) )
     
    889581}
    890582
    891 #if H_3D_INTER_SDC
    892 Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    893 {
    894   pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth );
    895 
    896   if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) ) ||
    897     ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getVpsDepthModesFlag( pcCU->getSlice()->getLayerIdInVps() ) ) )
    898   {
    899     return;
    900   }
    901 
    902   if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) )
    903   {
    904     return;
    905   }
    906 
    907   assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
    908   m_pcEntropyDecoderIf->parseSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
    909 }
    910 #endif
    911 #if H_3D_DBBP
    912 Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    913 {
    914   m_pcEntropyDecoderIf->parseDBBPFlag( pcCU, uiAbsPartIdx, uiDepth );
    915 }
    916 #endif
    917583
    918584//! \}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecEntropy.h

    r1039 r1072  
    6666
    6767  virtual Void  parseVPS                  ( TComVPS* pcVPS )                       = 0;
    68 #if H_3D
    69   virtual Void  parseSPS                  ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag  )                    = 0;
    70 #else
    7168  virtual Void  parseSPS                  ( TComSPS* pcSPS )                                      = 0;
    72 #endif
    73 #if H_3D
    74   virtual Void  parsePPS                  ( TComPPS* pcPPS, TComVPS* pcVPS )                      = 0;
    75 #else
    7669  virtual Void  parsePPS                  ( TComPPS* pcPPS )                                      = 0;
    77 #endif
    7870
    7971#if H_MV
     
    8981public:
    9082  virtual Void parseSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    91 #if MTK_SINGLE_DEPTH_MODE_I0095
    92   virtual Void parseSingleDepthMode       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    93 #endif
    9483  virtual Void parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    9584  virtual Void parseSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    9685  virtual Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) = 0;
    9786  virtual Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex ) = 0;
    98 #if H_3D_ARP
    99   virtual Void parseARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    100 #endif
    101 #if H_3D_IC
    102   virtual Void parseICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    103 #endif
    104 #if H_3D_INTER_SDC
    105   virtual Void parseDeltaDC       ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) = 0;
    106   virtual Void parseSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    107 #endif
    108 #if H_3D_DBBP
    109   virtual Void parseDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    110 #endif
    11187  virtual Void parsePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    11288  virtual Void parsePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
     
    157133  Void    resetEntropy                ( TComSlice* p)           { m_pcEntropyDecoderIf->resetEntropy(p);                    }
    158134  Void    decodeVPS                   ( TComVPS* pcVPS ) { m_pcEntropyDecoderIf->parseVPS(pcVPS); }
    159 #if H_3D
    160   Void    decodeSPS                   ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag )    { m_pcEntropyDecoderIf->parseSPS(pcSPS, viewIndex, depthFlag );                    }
    161 #else
    162135  Void    decodeSPS                   ( TComSPS* pcSPS     )    { m_pcEntropyDecoderIf->parseSPS(pcSPS);                    }
    163 #endif
    164 #if H_3D
    165   Void    decodePPS                   ( TComPPS* pcPPS, TComVPS* pcVPS )    { m_pcEntropyDecoderIf->parsePPS(pcPPS, pcVPS);                    }
    166 #else
    167136  Void    decodePPS                   ( TComPPS* pcPPS )    { m_pcEntropyDecoderIf->parsePPS(pcPPS);                    }
    168 #endif
    169137#if H_MV
    170138  Void    decodeSliceHeader           ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, Int targetOlsIdx)  { m_pcEntropyDecoderIf->parseSliceHeader(rpcSlice, parameterSetManager, targetOlsIdx );         }
     
    179147  Void decodeSplitFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    180148  Void decodeSkipFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    181 #if MTK_SINGLE_DEPTH_MODE_I0095
    182   Void decodeSingleDepthMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) ;
    183 #endif
    184149  Void decodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    185150  Void decodeMergeFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
     
    188153  Void decodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    189154 
    190 #if H_3D_ARP
    191   Void decodeARPW              ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    192 #endif
    193 #if H_3D_IC
    194   Void decodeICFlag            ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    195 #endif
    196 #if H_3D_INTER_SDC
    197   Void decodeSDCFlag           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    198 #endif
    199 #if H_3D_DBBP
    200   Void decodeDBBPFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    201 #endif
    202155  Void decodeIPCMInfo          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    203156
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecGop.cpp

    r976 r1072  
    138138  m_pcEntropyDecoder->setBitstream      ( ppcSubstreams[0] );
    139139  m_pcEntropyDecoder->resetEntropy      (pcSlice);
    140 #if H_3D_NBDV
    141   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.
    142   {
    143     Int iColPoc = pcSlice->getRefPOC(RefPicList(1-pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
    144     rpcPic->setNumDdvCandPics(rpcPic->getDisCandRefPictures(iColPoc));
    145   }
    146 
    147   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.
    148   {
    149     rpcPic->checkTemporalIVRef();
    150   }
    151 
    152   if(pcSlice->getIsDepth())
    153   {
    154     rpcPic->checkTextureRef();
    155   }
    156 #endif
    157 #if H_3D
    158   pcSlice->setDepthToDisparityLUTs();
    159 #endif
    160140  m_pcSbacDecoders[0].load(m_pcSbacDecoder);
    161141  m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders);
     
    191171    m_pcSAO->PCMLFDisableProcess(rpcPic);
    192172  }
    193 #if H_3D
    194   rpcPic->compressMotion(2);
    195 #endif
    196 #if !H_3D
    197173  rpcPic->compressMotion();
    198 #endif
    199174  Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B');
    200175  if (!pcSlice->isReferenced()) c += 32;
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecSbac.cpp

    r1066 r1072  
    5252, m_cCUSplitFlagSCModel       ( 1,             1,               NUM_SPLIT_FLAG_CTX            , m_contextModels + m_numContextModels, m_numContextModels )
    5353, m_cCUSkipFlagSCModel        ( 1,             1,               NUM_SKIP_FLAG_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
    54 #if MTK_SINGLE_DEPTH_MODE_I0095
    55 , m_cCUSingleDepthFlagSCModel        ( 1,             1,               NUM_SINGLEDEPTH_FLAG_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
    56 , m_cSingleDepthValueSCModel         ( 1,             1,               NUM_SINGLE_DEPTH_VALUE_DATA_CTX      , m_contextModels + m_numContextModels, m_numContextModels)
    57 #endif
    5854, m_cCUMergeFlagExtSCModel    ( 1,             1,               NUM_MERGE_FLAG_EXT_CTX        , m_contextModels + m_numContextModels, m_numContextModels)
    5955, m_cCUMergeIdxExtSCModel     ( 1,             1,               NUM_MERGE_IDX_EXT_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
    60 #if H_3D_ARP
    61 , m_cCUPUARPWSCModel          ( 1,             1,               NUM_ARPW_CTX                  , m_contextModels + m_numContextModels, m_numContextModels)
    62 #endif
    63 #if H_3D_IC
    64 , m_cCUICFlagSCModel          ( 1,             1,               NUM_IC_FLAG_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
    65 #endif
    6656, m_cCUPartSizeSCModel        ( 1,             1,               NUM_PART_SIZE_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
    6757, m_cCUPredModeSCModel        ( 1,             1,               NUM_PRED_MODE_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
     
    8676, m_cTransformSkipSCModel     ( 1,             2,               NUM_TRANSFORMSKIP_FLAG_CTX    , m_contextModels + m_numContextModels, m_numContextModels)
    8777, m_CUTransquantBypassFlagSCModel( 1,          1,               NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels)
    88 #if H_3D_DIM
    89 , m_cDepthIntraModeSCModel    ( 1,             1,               NUM_DEPTH_INTRA_MODE_CTX      , m_contextModels + m_numContextModels, m_numContextModels)
    90 , m_cDdcFlagSCModel           ( 1,             1,               NUM_DDC_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    91 , m_cDdcDataSCModel           ( 1,             1,               NUM_DDC_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    92 , m_cAngleFlagSCModel         ( 1,             1,               NUM_ANGLE_FLAG_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
    93 #if H_3D_DIM_SDC
    94 , m_cSDCResidualFlagSCModel     ( 1,             1,             SDC_NUM_RESIDUAL_FLAG_CTX     , m_contextModels + m_numContextModels, m_numContextModels)
    95 , m_cSDCResidualSCModel         ( 1,             1,             SDC_NUM_RESIDUAL_CTX          , m_contextModels + m_numContextModels, m_numContextModels)
    96 #endif
    97 #endif
    98 #if H_3D_DIM_SDC
    99 , m_cSDCFlagSCModel                  ( 1,             1,  NUM_SDC_FLAG_CTX                 , m_contextModels + m_numContextModels, m_numContextModels)
    100 #endif
    101 #if H_3D_DBBP
    102 , m_cDBBPFlagSCModel             ( 1,             1,                 DBBP_NUM_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
    103 #endif
    10478{
    10579  assert( m_numContextModels <= MAX_NUM_CTX_MOD );
     
    136110  m_cCUSplitFlagSCModel.initBuffer       ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG );
    137111  m_cCUSkipFlagSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SKIP_FLAG );
    138 #if MTK_SINGLE_DEPTH_MODE_I0095
    139   m_cCUSingleDepthFlagSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SINGLEDEPTH_FLAG );
    140   m_cSingleDepthValueSCModel.initBuffer         ( sliceType, qp, (UChar*)INIT_SINGLE_DEPTH_VALUE_DATA );
    141 #endif
    142112  m_cCUMergeFlagExtSCModel.initBuffer    ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT );
    143113  m_cCUMergeIdxExtSCModel.initBuffer     ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT );
    144 #if H_3D_ARP
    145   m_cCUPUARPWSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_ARPW );
    146 #endif
    147 #if H_3D_IC
    148   m_cCUICFlagSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_IC_FLAG );
    149 #endif
    150114  m_cCUPartSizeSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_PART_SIZE );
    151115  m_cCUPredModeSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_PRED_MODE );
     
    171135  m_cTransformSkipSCModel.initBuffer     ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
    172136  m_CUTransquantBypassFlagSCModel.initBuffer( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );
    173 #if H_3D_DIM
    174   m_cDepthIntraModeSCModel.initBuffer    ( sliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE );
    175   m_cDdcFlagSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DDC_FLAG );
    176   m_cDdcDataSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DDC_DATA );
    177   m_cAngleFlagSCModel.initBuffer         ( sliceType, qp, (UChar*)INIT_ANGLE_FLAG );
    178 #if H_3D_DIM_SDC
    179   m_cSDCResidualFlagSCModel.initBuffer    ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
    180   m_cSDCResidualSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL );
    181 #endif
    182 #endif
    183 #if H_3D_DIM_SDC
    184   m_cSDCFlagSCModel.initBuffer            ( sliceType, qp, (UChar*)INIT_SDC_FLAG );
    185 #endif
    186 #if H_3D_DBBP
    187   m_cDBBPFlagSCModel.initBuffer              ( sliceType, qp, (UChar*)INIT_DBBP_FLAG );
    188 #endif
    189137  m_uiLastDQpNonZero  = 0;
    190138 
     
    207155  m_cCUSplitFlagSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG );
    208156  m_cCUSkipFlagSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG );
    209 #if MTK_SINGLE_DEPTH_MODE_I0095
    210   m_cCUSingleDepthFlagSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SINGLEDEPTH_FLAG );
    211   m_cSingleDepthValueSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_SINGLE_DEPTH_VALUE_DATA );
    212 #endif
    213157  m_cCUMergeFlagExtSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT );
    214158  m_cCUMergeIdxExtSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT );
    215 #if H_3D_ARP
    216   m_cCUPUARPWSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_ARPW );
    217 #endif
    218 #if H_3D_IC
    219   m_cCUICFlagSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_IC_FLAG );
    220 #endif
    221159  m_cCUPartSizeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
    222160  m_cCUPredModeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );
     
    242180  m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );
    243181
    244 #if H_3D_DIM
    245   m_cDepthIntraModeSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE );
    246   m_cDdcFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG );
    247   m_cDdcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );
    248   m_cAngleFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG );
    249 #if H_3D_DIM_SDC
    250   m_cSDCResidualFlagSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
    251   m_cSDCResidualSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL );
    252 #endif
    253 #endif
    254 #if H_3D_DIM_SDC
    255   m_cSDCFlagSCModel.initBuffer            ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
    256 #endif
    257 #if H_3D_DBBP
    258   m_cDBBPFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG );
    259 #endif
    260182  m_pcTDecBinIf->start();
    261183}
     
    379301}
    380302
    381 #if H_3D_DIM
    382 Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel  )
    383 {
    384   UInt uiSymbol;
    385   UInt uiCount = 0;
    386   do
    387   {
    388     m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel );
    389     uiCount++;
    390   }
    391   while( uiSymbol && ( uiCount != 3 ) );
    392   ruiSymbol = uiCount - 1;
    393 
    394   if( uiSymbol )
    395   {
    396     xReadEpExGolomb( uiSymbol, 0 );
    397     ruiSymbol += uiSymbol + 1;
    398   }
    399 
    400   return;
    401 }
    402 
    403 Void TDecSbac::xParseDimDeltaDC( Pel& rValDeltaDC, UInt uiNumSeg )
    404 {
    405   UInt absValDeltaDC = 0;
    406   xReadExGolombLevel( absValDeltaDC, m_cDdcDataSCModel.get(0, 0, 0) );
    407   rValDeltaDC = (Pel)absValDeltaDC + ( uiNumSeg > 1 ? 0 : 1 );
    408 
    409   if( rValDeltaDC != 0 )
    410   {
    411     UInt uiSign;
    412     m_pcTDecBinIf->decodeBinEP( uiSign );
    413     if ( uiSign )
    414     {
    415       rValDeltaDC = -rValDeltaDC;
    416     }
    417   }
    418 }
    419 
    420 
    421 #if H_3D_DIM_DMM
    422 Void TDecSbac::xParseDmm1WedgeIdx( UInt& ruiTabIdx, Int iNumBit )
    423 {
    424   UInt uiSymbol, uiIdx = 0;
    425   for( Int i = 0; i < iNumBit; i++ )
    426   {
    427     m_pcTDecBinIf->decodeBinEP( uiSymbol );
    428     uiIdx += uiSymbol << i;
    429   }
    430   ruiTabIdx = uiIdx;
    431 }
    432 #endif
    433 
    434 #if !FIX_TICKET_76
    435 #if H_3D_DIM_SDC
    436 Void TDecSbac::xParseSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSegment )
    437 {
    438   assert( pcCU->getSlice()->getIsDepth() );
    439   assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
    440   assert( pcCU->getSDCFlag(uiAbsPartIdx) );
    441   assert( uiSegment < 2 );
    442  
    443   UInt uiResidual = 0;
    444   UInt uiBit      = 0;
    445   UInt uiAbsIdx   = 0;
    446   UInt uiSign     = 0;
    447   Int  iIdx       = 0;
    448  
    449 #if H_3D_DIM_DLT
    450   UInt uiMaxResidualBits = pcCU->getSlice()->getPPS()->getDLT()->getBitsPerDepthValue( pcCU->getSlice()->getLayerIdInVps() );
    451 #else
    452   UInt uiMaxResidualBits = g_bitDepthY;
    453 #endif
    454   assert( uiMaxResidualBits <= g_bitDepthY );
    455  
    456   m_pcTDecBinIf->decodeBin(uiResidual, m_cSDCResidualFlagSCModel.get( 0, 0, 0 ) );
    457  
    458 #if H_MV_ENC_DEC_TRAC
    459   DTRACE_CU("sdc_residual_flag[i]", uiResidual)
    460 #endif
    461  
    462   if (uiResidual)
    463   {
    464     // decode residual sign bit
    465     m_pcTDecBinIf->decodeBinEP(uiSign);
    466 #if H_MV_ENC_DEC_TRAC
    467     DTRACE_CU("sdc_residual_sign_flag[i]", uiSign)
    468 #endif
    469    
    470     // decode residual magnitude
    471     // prefix part
    472     UInt uiCount = 0;
    473 #if H_3D_DIM_DLT
    474     UInt uiNumDepthValues = pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() );
    475 #else
    476     UInt uiNumDepthValues = ((1 << g_bitDepthY)-1);
    477 #endif
    478     UInt uiPrefixThreshold = ((uiNumDepthValues * 3) >> 2);
    479     for ( UInt ui = 0; ui < uiPrefixThreshold; ui++)
    480     {
    481       m_pcTDecBinIf->decodeBin( uiBit, m_cSDCResidualSCModel.get(0, 0, 0) );
    482       if ( uiBit == 0 )
    483         break;
    484       else
    485         uiCount++;
    486     }
    487     // suffix part
    488     if ( uiCount == uiPrefixThreshold )
    489     {
    490       for ( UInt ui = 0; ui < numBitsForValue(uiNumDepthValues - uiPrefixThreshold); ui++ )
    491       {
    492         m_pcTDecBinIf->decodeBinEP( uiBit );
    493         uiAbsIdx |= uiBit << ui;
    494       }
    495       uiAbsIdx += uiCount;
    496     }
    497     else
    498     {
    499       uiAbsIdx = uiCount;
    500     }
    501  
    502 #if H_MV_ENC_DEC_TRAC
    503     DTRACE_CU("sdc_residual_abs_minus1[i]", uiAbsIdx)
    504 #endif
    505    
    506     uiAbsIdx += 1;
    507     iIdx =(Int)(uiSign ? -1 : 1)*uiAbsIdx;
    508   }
    509  
    510   pcCU->setSDCSegmentDCOffset(iIdx, uiSegment, uiAbsPartIdx);
    511 }
    512 #endif
    513 #endif
    514 #endif
    515303/** Parse I_PCM information.
    516304 * \param pcCU
     
    649437#endif
    650438}
    651 #if MTK_SINGLE_DEPTH_MODE_I0095
    652 Void TDecSbac::parseSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    653 {
    654   pcCU->setSingleDepthFlagSubParts( false,        uiAbsPartIdx, uiDepth );
    655   UInt uiSymbol = 0;
    656   m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSingleDepthFlagSCModel.get( 0, 0, 0 ) );
    657   if( uiSymbol )
    658   {
    659     pcCU->setSingleDepthFlagSubParts( true,        uiAbsPartIdx, uiDepth );
    660     pcCU->setSkipFlagSubParts( false,        uiAbsPartIdx, uiDepth );
    661     pcCU->setSDCFlagSubParts( false,        uiAbsPartIdx, uiDepth );
    662     pcCU->setPredModeSubParts( MODE_INTRA,  uiAbsPartIdx, uiDepth );
    663     pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
    664     pcCU->setLumaIntraDirSubParts (DC_IDX, uiAbsPartIdx, uiDepth );
    665     pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
    666     pcCU->setMergeFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
    667     pcCU->setTrIdxSubParts(0, uiAbsPartIdx, uiDepth);
    668     pcCU->setCbfSubParts(0, 1, 1, uiAbsPartIdx, uiDepth);
    669 
    670     UInt absValDeltaDC = 0;
    671 
    672     UInt uiUnaryIdx = 0;
    673     UInt uiNumCand = MTK_SINGLE_DEPTH_MODE_CANDIDATE_LIST_SIZE;
    674     if ( uiNumCand > 1 )
    675     {
    676       for( ; uiUnaryIdx < uiNumCand - 1; ++uiUnaryIdx )
    677       {
    678         UInt uiSymbol2 = 0;
    679         if ( uiUnaryIdx==0 )
    680         {
    681           m_pcTDecBinIf->decodeBin( uiSymbol2, m_cSingleDepthValueSCModel.get( 0, 0, 0 ) );
    682         }
    683         else
    684         {
    685           m_pcTDecBinIf->decodeBinEP( uiSymbol2);
    686         }
    687         if( uiSymbol2 == 0 )
    688         {
    689           break;
    690         }
    691       }
    692     }
    693     absValDeltaDC = uiUnaryIdx;
    694     pcCU->setSingleDepthValueSubParts((Pel)absValDeltaDC,uiAbsPartIdx, 0, uiDepth);
    695   }
    696 }
    697 
    698 #endif
    699439/** parse merge flag
    700440 * \param pcCU
     
    778518
    779519  UInt uiSymbol;
    780 #if H_3D_QTLPC
    781   Bool bParseSplitFlag    = true;
    782 
    783 #if MTK_I0099_VPS_EX2
    784   TComVPS *vps           = pcCU->getPic()->getSlice(0)->getVPS();
    785   Bool    bLimQtPredFlag = vps->getLimQtPredFlag(pcCU->getPic()->getSlice(0)->getLayerId());
    786 #else
    787   TComSPS *sps            = pcCU->getPic()->getSlice(0)->getSPS();
    788 #endif
    789   TComPic *pcTexture      = pcCU->getSlice()->getTexturePic();
    790   Bool bDepthMapDetect    = (pcTexture != NULL);
    791   Bool bIntraSliceDetect  = (pcCU->getSlice()->getSliceType() == I_SLICE);
    792 
    793   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);
    794 
    795 #if MTK_I0099_VPS_EX2
    796 #if LGE_FCO_I0116
    797   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && bLimQtPredFlag && pcTexture->getReconMark())
    798 #else
    799   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && bLimQtPredFlag)
    800 #endif
    801 #else
    802   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL() && sps->getUsePC())
    803 #endif
    804   {
    805     TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr());
    806     assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth);
    807     bParseSplitFlag         = (pcTextureCU->getDepth(uiAbsPartIdx) > uiDepth);
    808   }
    809 
    810   if(bParseSplitFlag)
    811   {
    812 #endif
    813520    m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) );
    814521#if H_MV_ENC_DEC_TRAC
     
    817524    DTRACE_CABAC_VL( g_nSymbolCounter++ )
    818525    DTRACE_CABAC_T( "\tSplitFlag\n" )
    819 #endif
    820 #if H_3D_QTLPC
    821   }
    822   else
    823   {
    824     uiSymbol = 0;
    825   }
    826526#endif
    827527  pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx );
     
    841541  PartSize eMode;
    842542
    843 #if H_3D_QTLPC
    844   Bool bParsePartSize    = true;
    845 #if MTK_I0099_VPS_EX2
    846   TComVPS *vps           = pcCU->getPic()->getSlice(0)->getVPS();
    847   Bool    bLimQtPredFlag = vps->getLimQtPredFlag(pcCU->getPic()->getSlice(0)->getLayerId());
    848 #else
    849   TComSPS *sps           = pcCU->getPic()->getSlice(0)->getSPS();
    850 #endif
    851   TComPic *pcTexture     = pcCU->getSlice()->getTexturePic();
    852   Bool bDepthMapDetect   = (pcTexture != NULL);
    853   Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE);
    854 
    855   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);
    856 
    857   Bool depthDependent = false;
    858   UInt uiTexturePart = uiMode;
    859 #if MTK_I0099_VPS_EX2
    860 #if LGE_FCO_I0116
    861   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && bLimQtPredFlag && pcTexture->getReconMark())
    862 #else
    863   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && bLimQtPredFlag )
    864 #endif
    865 #else
    866   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL() && sps->getUsePC())
    867 #endif
    868   {
    869     TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr());
    870     assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth);
    871     if(pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth )
    872     {
    873       depthDependent = true;
    874       uiTexturePart = pcTextureCU->getPartitionSize( uiAbsPartIdx );
    875     }
    876     if (pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth && pcTextureCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N)
    877     {
    878       bParsePartSize = false;
    879       eMode          = SIZE_2Nx2N;
    880     }
    881   }
    882 #endif
    883543
    884544 
    885545  if ( pcCU->isIntra( uiAbsPartIdx ) )
    886546  {
    887 #if H_3D_QTLPC
    888     if(bParsePartSize)
    889     {
    890 #endif
    891547     uiSymbol = 1;
    892548      if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
     
    898554      }
    899555      eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN;
    900 #if H_3D_QTLPC
    901     }
    902 #endif
    903556    UInt uiTrLevel = 0;   
    904557    UInt uiWidthInBit  = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2;
     
    916569  else
    917570  {
    918 #if H_3D_QTLPC
    919     if(bParsePartSize)
    920     {
    921       if (depthDependent==false || uiTexturePart == SIZE_NxN|| uiTexturePart == SIZE_2Nx2N)
    922       {
    923 #endif
    924571      UInt uiMaxNumBits = 2;
    925572      if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) )
     
    958605        }
    959606      }
    960 #if H_3D_QTLPC
    961       }
    962       else if(uiTexturePart == SIZE_2NxN || uiTexturePart == SIZE_2NxnU || uiTexturePart == SIZE_2NxnD)
    963       {
    964         UInt uiMaxNumBits = 1;
    965         if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
    966         {
    967           uiMaxNumBits ++;
    968         }
    969         for ( UInt ui = 0; ui < uiMaxNumBits; ui++ )
    970         {
    971           m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) );
    972           if ( uiSymbol )
    973           {
    974             break;
    975           }
    976           uiMode++;
    977         }
    978         eMode = (PartSize) uiMode;
    979         if(uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==1 )
    980         {
    981           eMode = SIZE_2NxN;
    982         }
    983         else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth )==0  && uiSymbol==0)
    984         {
    985           eMode = SIZE_2NxN;
    986         }
    987         else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==0)
    988         {
    989           m_pcTDecBinIf->decodeBinEP(uiSymbol);
    990           eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD);
    991         }
    992       }
    993       else if(uiTexturePart == SIZE_Nx2N|| uiTexturePart==SIZE_nLx2N || uiTexturePart==SIZE_nRx2N)
    994       {
    995         UInt uiMaxNumBits = 1;
    996         if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
    997         {
    998           uiMaxNumBits ++;
    999         }
    1000         for ( UInt ui = 0; ui < uiMaxNumBits; ui++ )
    1001         {
    1002           m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) );
    1003           if ( uiSymbol )
    1004           {
    1005             break;
    1006           }
    1007           uiMode++;
    1008         }
    1009         eMode = (PartSize) uiMode;
    1010         if(uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==1 )
    1011         {
    1012           eMode = SIZE_Nx2N;
    1013         }
    1014         else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth )==0  && uiSymbol==0)
    1015         {
    1016           eMode = SIZE_Nx2N;
    1017         }
    1018         else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==0)
    1019         {
    1020           m_pcTDecBinIf->decodeBinEP(uiSymbol);
    1021           eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N);
    1022         }
    1023       }
    1024       else
    1025       {
    1026         assert(0);
    1027       }
    1028 #endif
    1029607#if H_MV_ENC_DEC_TRAC         
    1030608      DTRACE_CU("part_mode", eMode )
    1031 #endif
    1032 #if H_3D_QTLPC
    1033     }
    1034609#endif
    1035610  }
     
    1075650  for (j=0;j<partNum;j++)
    1076651  {
    1077 #if H_3D_DIM
    1078 #if SEPARATE_FLAG_I0085
    1079     if( pcCU->getSlice()->getVpsDepthModesFlag() || pcCU->getSlice()->getIVPFlag() )
    1080 #else
    1081     if( pcCU->getSlice()->getVpsDepthModesFlag() )
    1082 #endif
    1083     {
    1084       parseIntraDepth( pcCU, absPartIdx+partOffset*j, depth );
    1085     }
    1086     if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
    1087     {
    1088 #endif
    1089652    m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) );
    1090653    mpmPred[j] = symbol;
     
    1092655    DTRACE_CU("prev_intra_luma_pred_flag", symbol)
    1093656#endif
    1094 #if H_3D_DIM
    1095     }
    1096 #endif
    1097657  }
    1098658  for (j=0;j<partNum;j++)
    1099659  {
    1100 #if H_3D_DIM
    1101     if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
    1102     {
    1103 #endif
    1104660    Int preds[3] = {-1, -1, -1};
    1105661    Int predNum = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds); 
     
    1143699    }
    1144700    pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, absPartIdx+partOffset*j, depth );
    1145 #if H_3D_DIM
    1146     }
    1147 #endif
    1148701  }
    1149702}
     
    1179732}
    1180733
    1181 #if H_3D_DIM
    1182 Void TDecSbac::parseIntraDepth( TComDataCU* pcCU, UInt absPartIdx, UInt depth )
    1183 {
    1184   parseIntraDepthMode( pcCU, absPartIdx, depth );
    1185 
    1186   UInt dir     = pcCU->getLumaIntraDir( absPartIdx );
    1187   UInt dimType = getDimType( dir );
    1188 
    1189   switch( dimType )
    1190   {
    1191 #if H_3D_DIM_DMM
    1192   case( DMM1_IDX ):
    1193     {
    1194       UInt uiTabIdx = 0;
    1195       xParseDmm1WedgeIdx( uiTabIdx, g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] );
    1196       pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, absPartIdx, depth );
    1197     } break;
    1198   case( DMM4_IDX ): break;
    1199 #endif
    1200   default: break;
    1201   }
    1202 
    1203   pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth );
    1204 }
    1205 
    1206 Void TDecSbac::parseIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx, UInt depth )
    1207 {
    1208   UInt uiSymbol, uiIsDimMode;
    1209 
    1210   if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed
    1211   {
    1212     m_pcTDecBinIf->decodeBin( uiSymbol, m_cAngleFlagSCModel.get( 0, 0, 0 ) );
    1213   }
    1214   else
    1215   {
    1216     uiSymbol = 1;
    1217   }
    1218   uiIsDimMode = uiSymbol ? 0 : 1;
    1219   pcCU->setLumaIntraDirSubParts( 0, absPartIdx, depth );
    1220 
    1221   //decode DMM index
    1222   if( uiIsDimMode )
    1223   {
    1224 #if SEPARATE_FLAG_I0085
    1225     if( pcCU->getSlice()->getVpsDepthModesFlag() && pcCU->getSlice()->getIVPFlag() )
    1226     {
    1227       m_pcTDecBinIf->decodeBin( uiSymbol, m_cDepthIntraModeSCModel.get( 0, 0, 0 ) );
    1228       if( !uiSymbol )
    1229       {
    1230 #if HS_DMM_SIGNALLING_I0120
    1231         pcCU->setLumaIntraDirSubParts( DIM_OFFSET, absPartIdx, depth );
    1232 #else
    1233         pcCU->setLumaIntraDirSubParts( ( 2 * DMM1_IDX + DIM_OFFSET ), absPartIdx, depth );
    1234 #endif
    1235       }
    1236       else
    1237       {
    1238 #if HS_DMM_SIGNALLING_I0120
    1239         pcCU->setLumaIntraDirSubParts( ( 1+ DIM_OFFSET ), absPartIdx, depth );
    1240 #else
    1241         pcCU->setLumaIntraDirSubParts( ( 2 * DMM4_IDX + DIM_OFFSET ), absPartIdx, depth );
    1242 #endif
    1243       }
    1244     }
    1245     else if ( pcCU->getSlice()->getVpsDepthModesFlag() )
    1246     {
    1247 #if HS_DMM_SIGNALLING_I0120
    1248       pcCU->setLumaIntraDirSubParts( DIM_OFFSET, absPartIdx, depth );
    1249 #else
    1250       pcCU->setLumaIntraDirSubParts( ( 2 * DMM1_IDX + DIM_OFFSET ), absPartIdx, depth );
    1251 #endif
    1252     }
    1253     else if( pcCU->getSlice()->getIVPFlag() )
    1254     {
    1255 #if HS_DMM_SIGNALLING_I0120
    1256       pcCU->setLumaIntraDirSubParts( ( 1+ DIM_OFFSET ), absPartIdx, depth );
    1257 #else
    1258       pcCU->setLumaIntraDirSubParts( ( 2 * DMM4_IDX + DIM_OFFSET ), absPartIdx, depth );
    1259 #endif
    1260     }
    1261 #else
    1262     m_pcTDecBinIf->decodeBin( uiSymbol, m_cDepthIntraModeSCModel.get( 0, 0, 0 ) );
    1263     if( !uiSymbol )
    1264     {
    1265 #if HS_DMM_SIGNALLING_I0120
    1266       pcCU->setLumaIntraDirSubParts( DIM_OFFSET, absPartIdx, depth );
    1267 #else
    1268       pcCU->setLumaIntraDirSubParts( ( 2 * DMM1_IDX + DIM_OFFSET ), absPartIdx, depth );
    1269 #endif
    1270     }
    1271     else
    1272     {
    1273 #if HS_DMM_SIGNALLING_I0120
    1274       pcCU->setLumaIntraDirSubParts( ( 1+ DIM_OFFSET ), absPartIdx, depth );
    1275 #else
    1276       pcCU->setLumaIntraDirSubParts( ( 2 * DMM4_IDX + DIM_OFFSET ), absPartIdx, depth );
    1277 #endif
    1278     }
    1279 #endif
    1280   }
    1281 }
    1282 #endif
    1283734
    1284735Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx )
     
    21301581}
    21311582
    2132 #if H_3D_ARP
    2133 Void TDecSbac::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    2134 {
    2135   UInt uiMaxW = pcCU->getSlice()->getARPStepNum() - 1;
    2136   UInt uiW = 0;
    2137   UInt uiOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx);
    2138   UInt uiCode = 0;
    2139 
    2140   assert ( uiMaxW > 0 );
    2141 
    2142   m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 0 + uiOffset ) );
    2143 
    2144   uiW = uiCode;
    2145   if( 1 == uiW )   
    2146   {
    2147     m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 2 ) );
    2148     uiW += ( 1 == uiCode ? 1 : 0 );
    2149   }
    2150 #if H_MV_ENC_DEC_TRAC
    2151   DTRACE_CU("iv_res_pred_weight_idx", uiW )
    2152 #endif
    2153   pcCU->setARPWSubParts( ( UChar )( uiW ) , uiAbsPartIdx, uiDepth ); 
    2154 }
    2155 #endif
    2156 
    2157 #if H_3D_IC
    2158 /** parse illumination compensation flag
    2159  * \param pcCU
    2160  * \param uiAbsPartIdx
    2161  * \param uiDepth
    2162  * \returns Void
    2163  */
    2164 Void TDecSbac::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    2165 {
    2166   UInt uiSymbol = 0;
    2167   m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, 0 ) );
    2168 #if !H_MV_ENC_DEC_TRAC
    2169   DTRACE_CABAC_VL( g_nSymbolCounter++ );
    2170   DTRACE_CABAC_T( "\tICFlag" );
    2171   DTRACE_CABAC_T( "\tuiCtxIC: ");
    2172   DTRACE_CABAC_V( uiCtxIC );
    2173   DTRACE_CABAC_T( "\tuiSymbol: ");
    2174   DTRACE_CABAC_V( uiSymbol );
    2175   DTRACE_CABAC_T( "\n");
    2176 #else
    2177   DTRACE_CU("ic_flag", uiSymbol)
    2178 #endif
    2179  
    2180   pcCU->setICFlagSubParts( uiSymbol ? true : false , uiAbsPartIdx, 0, uiDepth );
    2181 }
    2182 #endif
    2183 
    2184 #if H_3D_INTER_SDC
    2185 Void TDecSbac::parseDeltaDC( TComDataCU* pcCU, UInt absPartIdx, UInt depth )
    2186 {
    2187   if( ! ( pcCU->getSDCFlag( absPartIdx ) || ( pcCU->isIntra( absPartIdx ) && getDimType( pcCU->getLumaIntraDir( absPartIdx ) ) < DIM_NUM_TYPE ) ) )
    2188   {
    2189     assert( 0 );
    2190   }
    2191 
    2192 #if HS_DMM_SIGNALLING_I0120
    2193   UInt symbol = 1;
    2194   UInt uiNumSegments = isDimMode( pcCU->getLumaIntraDir( absPartIdx ) ) ? 2 : 1;
    2195 #else
    2196   UInt symbol = 0;
    2197   UInt uiNumSegments = 0;
    2198 #endif
    2199 
    2200 #if HS_DMM_SIGNALLING_I0120
    2201   if( pcCU->isIntra( absPartIdx ) && pcCU->getSDCFlag( absPartIdx ))
    2202   {
    2203 #else
    2204   if( pcCU->isIntra( absPartIdx ) )
    2205   {
    2206     UInt dir     = pcCU->getLumaIntraDir( absPartIdx );
    2207     uiNumSegments = isDimMode( dir ) ? 2 : 1;
    2208 #endif
    2209     m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get( 0, 0, 0 ) );
    2210 #if !HS_DMM_SIGNALLING_I0120
    2211     if( pcCU->getSDCFlag( absPartIdx ) )
    2212     {
    2213 #endif
    2214       assert( pcCU->getPartitionSize( absPartIdx ) == SIZE_2Nx2N );
    2215       pcCU->setTrIdxSubParts( 0, absPartIdx, depth );
    2216       pcCU->setCbfSubParts( 1, 1, 1, absPartIdx, depth );
    2217     }
    2218 #if !HS_DMM_SIGNALLING_I0120
    2219     else
    2220     {
    2221       pcCU->setLumaIntraDirSubParts( dir + symbol, absPartIdx, depth );
    2222     }
    2223   }
    2224   else
    2225   {
    2226     uiNumSegments = 1;
    2227     symbol = 1;
    2228   }
    2229 #endif
    2230 
    2231 
    2232   for( UInt segment = 0; segment < uiNumSegments; segment++ )
    2233   {
    2234     Pel valDeltaDC = 0;
    2235     if( symbol )
    2236     {
    2237       xParseDimDeltaDC( valDeltaDC, uiNumSegments );
    2238     }
    2239 
    2240     if( pcCU->isIntra( absPartIdx ) )
    2241     {
    2242       UInt dir     = pcCU->getLumaIntraDir( absPartIdx );
    2243 
    2244       if( pcCU->getSDCFlag( absPartIdx ) )
    2245       {
    2246         pcCU->setSDCSegmentDCOffset( valDeltaDC, segment, absPartIdx );
    2247       }
    2248       else
    2249       {
    2250         pcCU->setDimDeltaDC( getDimType( dir ), segment, absPartIdx, valDeltaDC );
    2251       }
    2252     }
    2253     else
    2254     {
    2255       pcCU->setSDCSegmentDCOffset( valDeltaDC, segment, absPartIdx );
    2256     }
    2257   }
    2258 }
    2259 
    2260 Void TDecSbac::parseSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    2261 {
    2262   UInt uiSymbol = 0;
    2263   UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx );
    2264 
    2265   m_pcTDecBinIf->decodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) );
    2266 
    2267   if( uiSymbol )
    2268   {
    2269     pcCU->setSDCFlagSubParts( true, uiAbsPartIdx, uiDepth );
    2270     pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth );
    2271     pcCU->setCbfSubParts( 1, 1, 1, uiAbsPartIdx, uiDepth );
    2272   }
    2273   else
    2274   {
    2275     pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth );
    2276   }
    2277 }
    2278 
    2279 #endif
    2280 
    2281 #if H_3D_DBBP
    2282 Void TDecSbac::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    2283 {
    2284   AOF( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) );
    2285   AOF( !pcCU->getSlice()->getIsDepth() );
    2286  
    2287   UInt uiSymbol = 0;
    2288  
    2289   m_pcTDecBinIf->decodeBin( uiSymbol, m_cDBBPFlagSCModel.get( 0, 0, 0 ) );
    2290  
    2291 #if SEC_DBBP_EXPLICIT_SIG_I0077
    2292   PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
    2293   AOF( ePartSize == SIZE_2NxN || ePartSize == SIZE_Nx2N );
    2294   UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
    2295   pcCU->setDBBPFlagSubParts(uiSymbol, uiAbsPartIdx, 0, uiDepth);
    2296   pcCU->setDBBPFlagSubParts(uiSymbol, uiAbsPartIdx+uiPUOffset, 1, uiDepth);
    2297 #else
    2298   if( uiSymbol )
    2299   {
    2300     pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx, 0, uiDepth);
    2301     UInt uiCurrPartNumQ = (pcCU->getPic()->getNumPartInCU() >> (2 * uiDepth)) >> 2;
    2302     pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx + 2*uiCurrPartNumQ, 1, uiDepth);
    2303   }
    2304 #endif
    2305 }
    2306 #endif
     1583
     1584
     1585
    23071586
    23081587
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecSbac.h

    r1039 r1072  
    7676  Void  setBitstream              ( TComInputBitstream* p  ) { m_pcBitstream = p; m_pcTDecBinIf->init( p ); }
    7777  Void  parseVPS                  ( TComVPS* /*pcVPS*/ ) {}
    78 #if H_3D
    79   Void  parseSPS                  ( TComSPS* /*pcSPS*/ , Int /*viewIndex*/, Bool /*depthFlag*/ ) {}
    80 #else
    8178  Void  parseSPS                  ( TComSPS* /*pcSPS*/ ) {}
    82 #endif
    83 #if H_3D
    84   Void  parsePPS                  ( TComPPS* /*pcPPS*/, TComVPS* /*pcVPS*/ ) {}
    85 #else
    8679  Void  parsePPS                  ( TComPPS* /*pcPPS*/ ) {}
    87 #endif
    8880
    8981#if H_MV
     
    10597  Void  xReadEpExGolomb     ( UInt& ruiSymbol, UInt uiCount );
    10698  Void  xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam );
    107 #if H_3D_DIM
    108   Void  xReadExGolombLevel   ( UInt& ruiSymbol, ContextModel& rcSCModel  );
    109   Void  xParseDimDeltaDC     ( Pel& rValDeltaDC, UInt uiNumSeg );
    110 #if H_3D_DIM_DMM
    111   Void  xParseDmm1WedgeIdx   ( UInt& ruiTabIdx, Int iNumBit );
    112 #endif
    113 #if H_3D_DIM_SDC
    114   Void  xParseSDCResidualData     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart );
    115 #endif
    116 #endif
    117 #if H_3D_INTER_SDC
    118   Void  parseDeltaDC         ( TComDataCU* pcCU, UInt absPartIdx, UInt depth );
    119   Void  parseSDCFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    120 #endif
    121 #if H_3D_DBBP
    122   Void parseDBBPFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    123 #endif
    12499private:
    125100  TComInputBitstream* m_pcBitstream;
     
    129104 
    130105  Void parseSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    131 #if MTK_SINGLE_DEPTH_MODE_I0095 
    132   Void parseSingleDepthMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    133 #endif 
    134106  Void parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    135107  Void parseSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    136108  Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
    137109  Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex );
    138 #if H_3D_ARP
    139   Void parseARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    140 #endif
    141 #if H_3D_IC
    142   Void parseICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    143 #endif
    144110  Void parsePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    145111  Void parsePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     
    149115  Void parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    150116 
    151 #if H_3D_DIM
    152   Void parseIntraDepth     ( TComDataCU* pcCU, UInt absPartIdx, UInt depth );
    153   Void parseIntraDepthMode ( TComDataCU* pcCU, UInt absPartIdx, UInt depth );
    154 #endif
    155117
    156118  Void parseInterDir      ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx );
     
    182144  ContextModel3DBuffer m_cCUSplitFlagSCModel;
    183145  ContextModel3DBuffer m_cCUSkipFlagSCModel;
    184 #if MTK_SINGLE_DEPTH_MODE_I0095
    185   ContextModel3DBuffer m_cCUSingleDepthFlagSCModel;
    186   ContextModel3DBuffer m_cSingleDepthValueSCModel;
    187 #endif
    188146  ContextModel3DBuffer m_cCUMergeFlagExtSCModel;
    189147  ContextModel3DBuffer m_cCUMergeIdxExtSCModel;
    190 #if H_3D_ARP
    191   ContextModel3DBuffer m_cCUPUARPWSCModel;
    192 #endif
    193 #if H_3D_IC
    194   ContextModel3DBuffer m_cCUICFlagSCModel;
    195 #endif
    196148  ContextModel3DBuffer m_cCUPartSizeSCModel;
    197149  ContextModel3DBuffer m_cCUPredModeSCModel;
     
    220172  ContextModel3DBuffer m_CUTransquantBypassFlagSCModel;
    221173
    222 #if H_3D_DIM
    223   ContextModel3DBuffer m_cDepthIntraModeSCModel;
    224   ContextModel3DBuffer m_cDdcFlagSCModel;
    225   ContextModel3DBuffer m_cDdcDataSCModel;
    226   ContextModel3DBuffer m_cAngleFlagSCModel;
    227 #if H_3D_DIM_SDC 
    228   ContextModel3DBuffer m_cSDCResidualFlagSCModel;
    229   ContextModel3DBuffer m_cSDCResidualSCModel;
    230 #endif
    231 #endif
    232 #if H_3D_DIM_SDC 
    233   ContextModel3DBuffer m_cSDCFlagSCModel;
    234 #endif
    235 #if H_3D_DBBP
    236   ContextModel3DBuffer m_cDBBPFlagSCModel;
    237 #endif
    238174};
    239175
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecSlice.cpp

    r976 r1072  
    221221    }
    222222  }
    223 #if  H_3D
    224   if( pcSlice->getPPS()->getDLT() != NULL )
    225   {
    226       assert( pcSlice->getSPS()->getBitDepthY() == pcSlice->getPPS()->getDLT()->getDepthViewBitDepth() );
    227   }
    228 #endif
    229223  for( Int iCUAddr = iStartCUAddr; !uiIsLast && iCUAddr < rpcPic->getNumCUsInFrame(); iCUAddr = rpcPic->getPicSym()->xCalculateNxtCUAddr(iCUAddr) )
    230224  {
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecTop.cpp

    r1066 r1072  
    4545//! \{
    4646
    47 #if H_3D
    48 CamParsCollector::CamParsCollector()
    49 : m_bInitialized( false )
    50 {
    51   m_aaiCodedOffset         = new Int* [ MAX_NUM_LAYERS ];
    52   m_aaiCodedScale          = new Int* [ MAX_NUM_LAYERS ];
    53   for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ )
    54   {
    55     m_aaiCodedOffset      [ uiId ] = new Int [ MAX_NUM_LAYERS ];
    56     m_aaiCodedScale       [ uiId ] = new Int [ MAX_NUM_LAYERS ];
    57   }
    58 
    59   xCreateLUTs( (UInt)MAX_NUM_LAYERS, (UInt)MAX_NUM_LAYERS, m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
    60   m_iLog2Precision   = LOG2_DISP_PREC_LUT;
    61   m_uiBitDepthForLUT = 8; // fixed
    62   m_receivedIdc = NULL;
    63   m_vps         = NULL;
    64 }
    65 
    66 CamParsCollector::~CamParsCollector()
    67 {
    68   for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ )
    69   {
    70     delete [] m_aaiCodedOffset      [ uiId ];
    71     delete [] m_aaiCodedScale       [ uiId ];
    72   }
    73   delete [] m_aaiCodedOffset;
    74   delete [] m_aaiCodedScale;
    75 
    76   xDeleteArray( m_adBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 );
    77   xDeleteArray( m_aiBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 );
    78   xDeleteArray( m_receivedIdc, m_uiMaxViewIndex + 1 );
    79 }
    80 
    81 
    82 Void
    83 CamParsCollector::init( FILE* pCodedScaleOffsetFile, TComVPS* vps)
    84 {
    85   assert( !isInitialized() ); // Only one initialization currently supported
    86   m_bInitialized            = true;
    87   m_vps                     = vps;
    88   m_bCamParsVaryOverTime    = false;
    89   m_pCodedScaleOffsetFile   = pCodedScaleOffsetFile;
    90   m_lastPoc                 = -1;   
    91   m_firstReceivedPoc        = -2;
    92 
    93   m_uiMaxViewIndex            = -1;
    94   for (Int i = 0; i <= vps->getMaxLayersMinus1(); i++)
    95   {
    96     Int curViewIdx = m_vps->getViewIndex( m_vps->getLayerIdInNuh( i ));
    97     m_bCamParsVaryOverTime = m_bCamParsVaryOverTime || vps->hasCamParInSliceHeader( curViewIdx );
    98     m_uiMaxViewIndex = std::max( m_uiMaxViewIndex, curViewIdx  ) ;
    99   }
    100 
    101   assert( m_receivedIdc == NULL );
    102   m_receivedIdc = new Int*[ m_uiMaxViewIndex + 1];
    103   for (Int i = 0; i <= m_uiMaxViewIndex; i++)
    104   {
    105     m_receivedIdc[i] = new Int[ m_uiMaxViewIndex + 1 ];
    106   }
    107 
    108   xResetReceivedIdc( true );
    109 
    110   for (Int viewIndex = 0; viewIndex <= m_uiMaxViewIndex ; viewIndex++ )
    111   {
    112     if (m_vps->getCamParPresent( viewIndex ) )
    113     {   
    114       if( !m_vps->hasCamParInSliceHeader( viewIndex ) )
    115       {
    116         for (Int baseViewIndex = 0; baseViewIndex < viewIndex ; baseViewIndex++ )
    117         {
    118           m_receivedIdc   [ baseViewIndex ][ viewIndex ] = -1;
    119           m_aaiCodedScale [ baseViewIndex ][ viewIndex ] = m_vps->getCodedScale    (viewIndex) [ baseViewIndex ];
    120           m_aaiCodedOffset[ baseViewIndex ][ viewIndex ] = m_vps->getCodedOffset   (viewIndex) [ baseViewIndex ];
    121 
    122           m_receivedIdc   [ viewIndex ][ baseViewIndex ] = -1;
    123           m_aaiCodedScale [ viewIndex ][ baseViewIndex ] = m_vps->getInvCodedScale (viewIndex) [ baseViewIndex ];
    124           m_aaiCodedOffset[ viewIndex ][ baseViewIndex ] = m_vps->getInvCodedOffset(viewIndex) [ baseViewIndex ];
    125           xInitLUTs( baseViewIndex, viewIndex, m_aaiCodedScale[ baseViewIndex ][ viewIndex ], m_aaiCodedOffset[ baseViewIndex ][ viewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
    126           xInitLUTs( viewIndex, baseViewIndex, m_aaiCodedScale[ viewIndex ][ baseViewIndex ], m_aaiCodedOffset[ viewIndex ][ baseViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
    127         }
    128       }
    129     }
    130   }
    131 }
    132 
    133 Void
    134 CamParsCollector::xResetReceivedIdc( Bool overWriteFlag )
    135 {
    136   for (Int i = 0; i <= m_uiMaxViewIndex; i++)
    137   { 
    138     for (Int j = 0; j <= m_uiMaxViewIndex; j++)
    139     {
    140       if ( overWriteFlag ||  ( m_receivedIdc[i][j] != -1 ) )
    141       {
    142         m_receivedIdc[i][j] = 0;
    143       }     
    144     }
    145   }
    146 }
    147 
    148 
    149 Void
    150 CamParsCollector::xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT)
    151 {
    152 
    153   uiNumberSourceViews = std::max( (UInt) 1, uiNumberSourceViews );
    154   uiNumberTargetViews = std::max( (UInt) 1, uiNumberTargetViews );
    155 
    156   radLUT         = new Double***[ uiNumberSourceViews ];
    157   raiLUT         = new Int   ***[ uiNumberSourceViews ];
    158 
    159   for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ )
    160   {
    161     radLUT        [ uiSourceView ] = new Double**[ uiNumberTargetViews ];
    162     raiLUT        [ uiSourceView ] = new Int   **[ uiNumberTargetViews ];
    163 
    164     for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ )
    165     {
    166       radLUT        [ uiSourceView ][ uiTargetView ]      = new Double*[ 2 ];
    167       radLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ];
    168       radLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ];
    169 
    170       raiLUT        [ uiSourceView ][ uiTargetView ]      = new Int*   [ 2 ];
    171       raiLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Int    [ 257 ];
    172       raiLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Int    [ 257 ];
    173     }
    174   }
    175 }
    176 
    177 Void
    178   CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT)
    179 {
    180   Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_vps->getCamParPrecision() + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
    181   Int     iLog2DivChroma = iLog2DivLuma + 1;
    182 
    183   iOffset <<= m_uiBitDepthForLUT;
    184 
    185   Double dScale  = (Double) iScale  / (( Double ) ( 1 << iLog2DivLuma ));
    186   Double dOffset = (Double) iOffset / (( Double ) ( 1 << iLog2DivLuma ));
    187 
    188   // offsets including rounding offsets
    189   Int64 iOffsetLuma   = iOffset + ( ( 1 << iLog2DivLuma   ) >> 1 );
    190   Int64 iOffsetChroma = iOffset + ( ( 1 << iLog2DivChroma ) >> 1 );
    191 
    192 
    193   for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ )
    194   {
    195 
    196     // real-valued look-up tables
    197     Double  dShiftLuma      = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
    198     Double  dShiftChroma    = dShiftLuma / 2;
    199     radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma;
    200     radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = dShiftChroma;
    201 
    202     // integer-valued look-up tables
    203     Int64   iTempScale      = (Int64)uiDepthValue * iScale;
    204     Int64   iShiftLuma      = ( iTempScale + iOffsetLuma   ) >> iLog2DivLuma;
    205     Int64   iShiftChroma    = ( iTempScale + iOffsetChroma ) >> iLog2DivChroma;
    206     raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = (Int)iShiftLuma;
    207     raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = (Int)iShiftChroma;
    208   }
    209 
    210   radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
    211   radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
    212   raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
    213   raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
    214 }
    215 
    216 Void
    217 CamParsCollector::uninit()
    218 {
    219   m_bInitialized = false;
    220 }
    221 
    222 Void
    223 CamParsCollector::setSlice( TComSlice* pcSlice )
    224 {
    225   if( pcSlice == 0 )
    226   {
    227     xOutput( m_lastPoc );
    228     return;
    229   }
    230 
    231 #if !LGE_FCO_I0116
    232   if ( pcSlice->getIsDepth())
    233   {
    234     return;
    235   }
    236 #endif
    237 
    238   Int curPoc = pcSlice->getPOC();
    239   if( m_firstReceivedPoc == -2 )
    240   {
    241     m_firstReceivedPoc = curPoc;
    242   }
    243 
    244   Bool newPocFlag = ( m_lastPoc != curPoc ); 
    245 
    246   if ( newPocFlag )
    247   {   
    248     if( m_lastPoc != -1 )
    249     {
    250       xOutput( m_lastPoc );
    251     }
    252 
    253     xResetReceivedIdc( false );
    254     m_lastPoc = pcSlice->getPOC();
    255   }
    256 
    257   UInt uiViewIndex          = pcSlice->getViewIndex(); 
    258   if( m_vps->getCamParPresent( uiViewIndex ) )
    259   {   
    260     if( m_vps->hasCamParInSliceHeader( uiViewIndex ) ) // check consistency of slice parameters here
    261     {   
    262       for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < uiViewIndex; uiBaseViewIndex++ )
    263       {       
    264         if ( m_receivedIdc[ uiViewIndex ][ uiBaseViewIndex ] != 0 )
    265         {     
    266           AOF( m_aaiCodedScale [ uiViewIndex ][ uiBaseViewIndex ] == pcSlice->getInvCodedScale () [ uiBaseViewIndex ] );
    267           AOF( m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ] == pcSlice->getInvCodedOffset() [ uiBaseViewIndex ] );
    268         }
    269         else
    270         {         
    271           m_receivedIdc   [ uiViewIndex ][ uiBaseViewIndex ]  = 1;
    272           m_aaiCodedScale [ uiViewIndex ][ uiBaseViewIndex ]  = pcSlice->getInvCodedScale () [ uiBaseViewIndex ];
    273           m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ]  = pcSlice->getInvCodedOffset() [ uiBaseViewIndex ];
    274           xInitLUTs( uiViewIndex, uiBaseViewIndex, m_aaiCodedScale[ uiViewIndex ][ uiBaseViewIndex ], m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
    275         }
    276         if ( m_receivedIdc[ uiBaseViewIndex ][ uiViewIndex ] != 0 )
    277         {     
    278           AOF( m_aaiCodedScale [ uiBaseViewIndex ][ uiViewIndex ] == pcSlice->getCodedScale    () [ uiBaseViewIndex ] );
    279           AOF( m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ] == pcSlice->getCodedOffset   () [ uiBaseViewIndex ] );
    280         }
    281         else
    282         {       
    283           m_receivedIdc   [ uiBaseViewIndex ][ uiViewIndex ]  = 1;
    284           m_aaiCodedScale [ uiBaseViewIndex ][ uiViewIndex ]  = pcSlice->getCodedScale    () [ uiBaseViewIndex ];
    285           m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ]  = pcSlice->getCodedOffset   () [ uiBaseViewIndex ];
    286           xInitLUTs( uiBaseViewIndex, uiViewIndex, m_aaiCodedScale[ uiBaseViewIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
    287         }
    288       }
    289     }
    290   }
    291 }
    292 
    293 
    294 #if H_3D_IV_MERGE
    295 Void
    296 CamParsCollector::copyCamParamForSlice( TComSlice* pcSlice )
    297 {
    298   if( m_bCamParsVaryOverTime )
    299   {
    300     pcSlice->setCamparaSlice( m_aaiCodedScale, m_aaiCodedOffset );
    301   }
    302 }
    303 #endif
    304 
    305 
    306 Void
    307 CamParsCollector::xOutput( Int iPOC )
    308 {
    309   if( m_pCodedScaleOffsetFile )
    310   {
    311     if( iPOC == m_firstReceivedPoc )
    312     {
    313       fprintf( m_pCodedScaleOffsetFile, "#  ViewIndex       ViewId\n" );
    314       fprintf( m_pCodedScaleOffsetFile, "#----------- ------------\n" );
    315       for( UInt uiViewIndex = 0; uiViewIndex <= m_uiMaxViewIndex; uiViewIndex++ )
    316       {
    317         fprintf( m_pCodedScaleOffsetFile, "%12d %12d\n", uiViewIndex, m_vps->getViewIdVal( uiViewIndex ) );
    318       }
    319       fprintf( m_pCodedScaleOffsetFile, "\n\n");
    320       fprintf( m_pCodedScaleOffsetFile, "# StartFrame     EndFrame   TargetView     BaseView   CodedScale  CodedOffset    Precision\n" );
    321       fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" );
    322     }
    323     if( iPOC == m_firstReceivedPoc || m_bCamParsVaryOverTime  )
    324     {
    325       Int iS = iPOC;
    326       Int iE = ( m_bCamParsVaryOverTime ? iPOC : ~( 1 << 31 ) );
    327       for( UInt uiViewIndex = 0; uiViewIndex <= m_uiMaxViewIndex; uiViewIndex++ )
    328       {
    329         for( UInt uiBaseIndex = 0; uiBaseIndex <= m_uiMaxViewIndex; uiBaseIndex++ )
    330         {
    331           if( uiViewIndex != uiBaseIndex )
    332           {
    333             if ( m_receivedIdc[uiBaseIndex][uiViewIndex] != 0 )
    334             {           
    335               fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n",
    336                 iS, iE, uiViewIndex, uiBaseIndex, m_aaiCodedScale[ uiBaseIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ], m_vps->getCamParPrecision() );
    337             }           
    338           }
    339         }
    340       }
    341     }
    342   }
    343 }
    344 #endif
    34547TDecTop::TDecTop()
    34648{
     
    37779  m_layerId = 0;
    37880  m_viewId = 0;
    379 #if H_3D
    380   m_viewIndex = 0;
    381   m_isDepth = false;
    382   m_pcCamParsCollector = 0;
    383 #endif
    38481#if H_MV
    38582  m_targetOptLayerSetIdx = -1;
     
    821518  Int layerId  = nalu.m_layerId;   
    822519  setViewId   ( vps->getViewId   ( layerId )      ); 
    823 #if H_3D
    824   setViewIndex( vps->getViewIndex( layerId )      ); 
    825   setIsDepth  ( vps->getDepthId  ( layerId ) == 1 ); 
    826   m_ivPicLists->setVPS( vps );
    827 #endif
    828520#endif
    829521
     
    1146838  pcPic->setLayerId( nalu.m_layerId );
    1147839  pcPic->setViewId ( getViewId() );
    1148 #if H_3D
    1149   pcPic->setViewIndex( getViewIndex() );
    1150   pcPic->setIsDepth  ( getIsDepth  () );
    1151 #endif
    1152840#endif
    1153841  if (bNextSlice)
     
    1162850    pcSlice->getTempRefPicLists( m_cListPic, m_refPicSetInterLayer0, m_refPicSetInterLayer1, tempRefPicLists, usedAsLongTerm, numPocTotalCurr);
    1163851    pcSlice->setRefPicList     ( tempRefPicLists, usedAsLongTerm, numPocTotalCurr, true );
    1164 #if H_3D_ARP
    1165     pcSlice->setARPStepNum(m_ivPicLists);
    1166     if( pcSlice->getARPStepNum() > 1 )
    1167     {
    1168       // GT: This seems to be broken, not all nuh_layer_ids are necessarily present
    1169       for(Int iLayerId = 0; iLayerId < nalu.m_layerId; iLayerId ++ )
    1170       {
    1171         Int  iViewIdx =   pcSlice->getVPS()->getViewIndex(iLayerId);
    1172         Bool bIsDepth = ( pcSlice->getVPS()->getDepthId  ( iLayerId ) == 1 );
    1173         if( iViewIdx<getViewIndex() && !bIsDepth )
    1174         {
    1175           pcSlice->setBaseViewRefPicList( m_ivPicLists->getPicList( iLayerId ), iViewIdx );
    1176         }
    1177       }
    1178     }
    1179 #endif
    1180852#else
    1181853    pcSlice->setRefPicList( m_cListPic, true );
    1182854#endif
    1183855
    1184 #if H_3D
    1185     pcSlice->setIvPicLists( m_ivPicLists );         
    1186 #if H_3D_IV_MERGE
    1187 #if H_3D_FCO
    1188     //assert( !getIsDepth() );
    1189 #else
    1190     assert( !getIsDepth() || ( pcSlice->getTexturePic() != 0 ) );
    1191 #endif
    1192 #endif   
    1193 #endif
    1194856    // For generalized B
    1195857#if I0044_SLICE_TMVP
     
    1244906    //---------------
    1245907    pcSlice->setRefPOCList();
    1246 #if  H_3D_TMVP
    1247     if(pcSlice->getLayerId())
    1248       pcSlice->generateAlterRefforTMVP();
    1249 #endif
    1250908  }
    1251909
     
    1271929  }
    1272930
    1273 #if H_3D_IV_MERGE
    1274 #if LGE_FCO_I0116
    1275   if( !pcSlice->getIsDepth() && m_pcCamParsCollector )
    1276 #else
    1277   if( pcSlice->getIsDepth() && m_pcCamParsCollector )
    1278 #endif
    1279   {
    1280     m_pcCamParsCollector->copyCamParamForSlice( pcSlice );
    1281   }
    1282 #endif
    1283931
    1284932  //  Decode a picture
    1285933  m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic);
    1286 #if H_3D
    1287   if( m_pcCamParsCollector )
    1288   {
    1289     m_pcCamParsCollector->setSlice( pcSlice );
    1290   }
    1291 #endif
    1292934  m_bFirstSliceInPicture = false;
    1293935  m_uiSliceIdx++;
     
    1310952  sps->setLayerId( getLayerId() );
    1311953#endif
    1312 #if H_3D
    1313   // Preliminary fix. assuming that all sps refer to the same VPS.
    1314   // Parsing dependency should be resolved!
    1315   TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 );
    1316   assert( vps != 0 );
    1317   m_cEntropyDecoder.decodeSPS( sps, vps->getViewIndex( m_layerId ), ( vps->getDepthId( m_layerId ) == 1 ) );
    1318 #else
    1319954  m_cEntropyDecoder.decodeSPS( sps );
    1320 #endif
    1321955  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
    1322956}
     
    1328962  pps->setLayerId( getLayerId() );
    1329963#endif
    1330 #if H_3D
    1331   // Assuming that all PPS indirectly refer to the same VPS via different SPS
    1332   // There is no parsing dependency in decoding DLT in PPS.
    1333   // The VPS information passed to decodePPS() is used to arrange the decoded DLT tables to their corresponding layers.
    1334   // This is equivalent to the process of
    1335   //   Step 1) decoding DLT tables based on the number of depth layers, and
    1336   //   Step 2) mapping DLT tables to the depth layers
    1337   // as described in the 3D-HEVC WD.
    1338   TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 );
    1339   m_cEntropyDecoder.decodePPS( pps, vps );
    1340 #else
    1341964  m_cEntropyDecoder.decodePPS( pps );
    1342 #endif
    1343965  m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
    1344966}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecTop.h

    r976 r1072  
    6464class TAppDecTop;
    6565#endif
    66 #if H_3D
    67 class CamParsCollector
    68 {
    69 public:
    70   CamParsCollector  ();
    71   ~CamParsCollector ();
    72 
    73   Void  init        ( FILE* pCodedScaleOffsetFile, TComVPS* vps );
    74 
    75   Void  uninit      ();
    76   Void  setSlice    ( TComSlice* pcSlice );
    77 
    78   Bool  isInitialized() const     { return m_bInitialized; }
    79   Int**** getBaseViewShiftLUTI()  { return m_aiBaseViewShiftLUT;   }
    80 
    81 #if H_3D_IV_MERGE
    82   Void  copyCamParamForSlice( TComSlice* pcSlice );
    83 #endif
    84 
    85 #if H_3D_DDD
    86   Int getCodedScale( Int iBaseView, Int iCureView){ return m_aaiCodedScale[ iBaseView ][ iCureView ];}
    87   Int getCodedOffset( Int iBaseView, Int iCureView){ return m_aaiCodedOffset[ iBaseView ][ iCureView ];}
    88   UInt getCamParsCodedPrecision(){ return m_vps->getCamParPrecision(); }
    89 #endif
    90 
    91 private:
    92   Void xResetReceivedIdc( Bool overWriteFlag );
    93   Void  xOutput     ( Int iPOC );
    94 
    95 private:
    96   Bool    m_bInitialized;
    97   FILE*   m_pCodedScaleOffsetFile;
    98 
    99   Int**   m_aaiCodedOffset;
    100   Int**   m_aaiCodedScale;
    101  
    102   TComVPS* m_vps;
    103   Int**    m_receivedIdc;
    104   Int      m_uiMaxViewIndex;
    105   Int      m_lastPoc;
    106   Int      m_firstReceivedPoc;
    107 
    108  
    109   Bool    m_bCamParsVaryOverTime;
    110 
    111   UInt    m_uiBitDepthForLUT;
    112   UInt    m_iLog2Precision;
    113   UInt    m_uiInputBitDepth;
    114 
    115   // look-up tables
    116   Double****   m_adBaseViewShiftLUT;       ///< Disparity LUT
    117   Int****      m_aiBaseViewShiftLUT;       ///< Disparity LUT
    118   Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT);
    119   Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT);
    120   template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 );
    121   template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2 );
    122   template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize );
    123 
    124 };
    125 
    126 template <class T>
    127 Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 )
    128 {
    129   if( rpt )
    130   {
    131     for( UInt uiK = 0; uiK < uiSize1; uiK++ )
    132     {
    133       for( UInt uiL = 0; uiL < uiSize2; uiL++ )
    134       {
    135         for( UInt uiM = 0; uiM < uiSize3; uiM++ )
    136         {
    137           delete[] rpt[ uiK ][ uiL ][ uiM ];
    138         }
    139         delete[] rpt[ uiK ][ uiL ];
    140       }
    141       delete[] rpt[ uiK ];
    142     }
    143     delete[] rpt;
    144   }
    145   rpt = NULL;
    146 };
    147 
    148 
    149 template <class T>
    150 Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 )
    151 {
    152   if( rpt )
    153   {
    154     for( UInt uiK = 0; uiK < uiSize1; uiK++ )
    155     {
    156       for( UInt uiL = 0; uiL < uiSize2; uiL++ )
    157       {
    158         delete[] rpt[ uiK ][ uiL ];
    159       }
    160       delete[] rpt[ uiK ];
    161     }
    162     delete[] rpt;
    163   }
    164   rpt = NULL;
    165 };
    166 
    167 
    168 template <class T>
    169 Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize )
    170 {
    171   if( rpt )
    172   {
    173     for( UInt uiK = 0; uiK < uiSize; uiK++ )
    174     {
    175       delete[] rpt[ uiK ];
    176     }
    177     delete[] rpt;
    178   }
    179   rpt = NULL;
    180 };
    181 
    182 #endif //H_3D
    18366/// decoder class
    18467class TDecTop
     
    243126  std::vector<TComPic*>   m_refPicSetInterLayer0;
    244127  std::vector<TComPic*>   m_refPicSetInterLayer1;
    245 #if H_3D
    246   Int                     m_viewIndex;
    247   Bool                    m_isDepth;
    248   CamParsCollector*       m_pcCamParsCollector;
    249 #endif
    250128#endif
    251129
     
    299177  Void                    setViewId             ( Int viewId  )  { m_viewId  = viewId;  }
    300178  Int                     getViewId             ()               { return m_viewId;     } 
    301 #if H_3D   
    302   Void                    setViewIndex          ( Int viewIndex  )  { m_viewIndex  = viewIndex;  }
    303   Int                     getViewIndex          ()               { return m_viewIndex;     } 
    304   Void                    setIsDepth            ( Bool isDepth ) { m_isDepth = isDepth; }
    305   Bool                    getIsDepth            ()               { return m_isDepth;    }
    306   Void                    setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
    307 #endif
    308179#endif
    309180protected:
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncCavlc.cpp

    r1066 r1072  
    185185  WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" );
    186186  WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0,   "cabac_init_present_flag" );
    187 #if PPS_FIX_DEPTH
    188   if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) )
    189   {
    190     WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive(),     "num_ref_idx_l0_default_active_minus1");
    191     WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive(),     "num_ref_idx_l1_default_active_minus1");
    192   }
    193   else
    194   {
    195 #endif
    196187  WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive()-1,     "num_ref_idx_l0_default_active_minus1");
    197188  WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive()-1,     "num_ref_idx_l1_default_active_minus1");
    198 #if PPS_FIX_DEPTH
    199   }
    200 #endif
    201189  WRITE_SVLC( pcPPS->getPicInitQPMinus26(),                  "init_qp_minus26");
    202190  WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0,      "constrained_intra_pred_flag" );
     
    274262#endif
    275263#endif
    276 #if PPS_FIX_DEPTH
    277   if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) )
    278   {
    279     WRITE_FLAG( 1, "lists_modification_present_flag" );
    280   }
    281   else
    282 #endif
    283264  WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag");
    284265  WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2");
    285266  WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag");
    286267
    287   #if H_3D
    288     if(( !pcPPS->getSPS()->getVPS()->getDepthId( pcPPS->getSPS()->getLayerId() ) )||
    289         pcPPS->getLayerId() != 1  )
    290     {
    291       pcPPS->setPps3dExtensionFlag( false );
    292     }
    293   #endif
    294268
    295269#if !H_MV
     
    300274    WRITE_FLAG( pcPPS->getPpsRangeExtensionsFlag( ) ? 1 : 0 , "pps_range_extensions_flag" );
    301275    WRITE_FLAG( pcPPS->getPpsMultilayerExtensionFlag( ) ? 1 : 0 , "pps_multilayer_extension_flag" );
    302 #if !H_3D
    303276    WRITE_CODE( pcPPS->getPpsExtension6bits( ), 6, "pps_extension_6bits" );
    304 #else
    305     WRITE_FLAG( pcPPS->getPps3dExtensionFlag( ) ? 1 : 0 , "pps_3d_extension_flag" );
    306     WRITE_CODE( pcPPS->getPpsExtension5bits( ), 5, "pps_extension_5bits" );
    307 #endif
    308277    if ( pcPPS->getPpsRangeExtensionsFlag() )
    309278    {
     
    321290    }
    322291
    323 #if H_3D
    324     if( pcPPS->getPps3dExtensionFlag( )  ) // This probably needs to be aligned with Rext and SHVC
    325     {
    326       codePPSExtension( pcPPS );
    327     }
    328 #endif
    329 #endif
    330 
    331 }
    332 
    333 #if H_3D
    334 Void  TEncCavlc::codePPSExtension        ( TComPPS* pcPPS )
    335 {
    336   // Assuming that all PPS indirectly refer to the same VPS via different SPS
    337   // There is no parsing dependency in decoding DLT in PPS.
    338   // The VPS information passed to decodePPS() is used to arrange the decoded DLT tables to their corresponding layers.
    339   // This is equivalent to the process of
    340   //   Step 1) decoding DLT tables based on the number of depth layers, and
    341   //   Step 2) mapping DLT tables to the depth layers
    342   // as described in the 3D-HEVC WD.
    343   TComVPS* pcVPS = pcPPS->getSPS()->getVPS();
    344 
    345   TComDLT* pcDLT = pcPPS->getDLT();
    346 
    347   WRITE_FLAG( pcDLT->getDltPresentFlag() ? 1 : 0, "dlt_present_flag" );
    348 
    349   if ( pcDLT->getDltPresentFlag() )
    350   {
    351     WRITE_CODE(pcDLT->getNumDepthViews(), 6, "pps_depth_layers_minus1");
    352     WRITE_CODE((pcDLT->getDepthViewBitDepth() - 8), 4, "pps_bit_depth_for_depth_views_minus8");
    353 
    354     for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
    355     {
    356       if ( i != 0 )
    357       {
    358         if ( pcVPS->getDepthId( i ) == 1 )
    359         {
    360           WRITE_FLAG( pcDLT->getUseDLTFlag( i ) ? 1 : 0, "dlt_flag[i]" );
    361 
    362           if ( pcDLT->getUseDLTFlag( i ) )
    363           {
    364             WRITE_FLAG( pcDLT->getInterViewDltPredEnableFlag( i ) ? 1 : 0, "inter_view_dlt_pred_enable_flag[ i ]");
    365 
    366             // ----------------------------- determine whether to use bit-map -----------------------------
    367             Bool bDltBitMapRepFlag       = false;
    368             UInt uiNumBitsNonBitMap      = 0;
    369             UInt uiNumBitsBitMap         = 0;
    370 
    371             UInt uiMaxDiff               = 0;
    372             UInt uiMinDiff               = 0xffffffff;
    373             UInt uiLengthMinDiff         = 0;
    374             UInt uiLengthDltDiffMinusMin = 0;
    375 
    376             UInt* puiDltDiffValues       = NULL;
    377            
    378             Int aiIdx2DepthValue_coded[256];
    379             UInt uiNumDepthValues_coded = 0;
    380            
    381             uiNumDepthValues_coded = pcDLT->getNumDepthValues(i);
    382             for( UInt ui = 0; ui<uiNumDepthValues_coded; ui++ )
    383             {
    384               aiIdx2DepthValue_coded[ui] = pcDLT->idx2DepthValue(i, ui);
    385             }
    386            
    387 #if H_3D_DELTA_DLT
    388             if( pcDLT->getInterViewDltPredEnableFlag( i ) )
    389             {
    390               AOF( pcVPS->getDepthId( 1 ) == 1 );
    391               AOF( i > 1 );
    392               // assumes ref layer id to be 1
    393               Int* piRefDLT = pcDLT->idx2DepthValue( 1 );
    394               UInt uiRefNum = pcDLT->getNumDepthValues( 1 );
    395               pcDLT->getDeltaDLT(i, piRefDLT, uiRefNum, aiIdx2DepthValue_coded, &uiNumDepthValues_coded);
    396             }
    397 #endif
    398 
    399             if ( NULL == (puiDltDiffValues = (UInt *)calloc(uiNumDepthValues_coded, sizeof(UInt))) )
    400             {
    401               exit(-1);
    402             }
    403 
    404             for (UInt d = 1; d < uiNumDepthValues_coded; d++)
    405             {
    406               puiDltDiffValues[d] = aiIdx2DepthValue_coded[d] - aiIdx2DepthValue_coded[d-1];
    407 
    408               if ( uiMaxDiff < puiDltDiffValues[d] )
    409               {
    410                 uiMaxDiff = puiDltDiffValues[d];
    411               }
    412 
    413               if ( uiMinDiff > puiDltDiffValues[d] )
    414               {
    415                 uiMinDiff = puiDltDiffValues[d];
    416               }
    417             }
    418 
    419             // counting bits
    420             // diff coding branch
    421             uiNumBitsNonBitMap += 8;                          // u(v) bits for num_depth_values_in_dlt[layerId] (i.e. num_entry[ layerId ])
    422 
    423             if ( uiNumDepthValues_coded > 1 )
    424             {
    425               uiNumBitsNonBitMap += 8;                        // u(v) bits for max_diff[ layerId ]
    426             }
    427 
    428             if ( uiNumDepthValues_coded > 2 )
    429             {
    430               uiLengthMinDiff    = (UInt) ceil(Log2(uiMaxDiff + 1));
    431               uiNumBitsNonBitMap += uiLengthMinDiff;          // u(v)  bits for min_diff[ layerId ]
    432             }
    433 
    434             uiNumBitsNonBitMap += 8;                          // u(v) bits for dlt_depth_value0[ layerId ]
    435 
    436             if (uiMaxDiff > uiMinDiff)
    437             {
    438               uiLengthDltDiffMinusMin = (UInt) ceil(Log2(uiMaxDiff - uiMinDiff + 1));
    439               uiNumBitsNonBitMap += uiLengthDltDiffMinusMin * (uiNumDepthValues_coded - 1);  // u(v) bits for dlt_depth_value_diff_minus_min[ layerId ][ j ]
    440             }
    441 
    442             // bit map branch
    443             uiNumBitsBitMap = 256;   // uiNumBitsBitMap = 1 << pcDLT->getDepthViewBitDepth();
    444 
    445             // determine bDltBitMapFlag
    446             bDltBitMapRepFlag = (uiNumBitsBitMap > uiNumBitsNonBitMap) ? false : true;
    447 
    448             // ----------------------------- Actual coding -----------------------------
    449             if ( pcDLT->getInterViewDltPredEnableFlag( i ) == false )
    450             {
    451               WRITE_FLAG( bDltBitMapRepFlag ? 1 : 0, "dlt_bit_map_rep_flag[ layerId ]" );
    452             }
    453             else
    454             {
    455               bDltBitMapRepFlag = false;
    456             }
    457 
    458             // bit map coding
    459             if ( bDltBitMapRepFlag )
    460             {
    461               UInt uiDltArrayIndex = 0;
    462               for (UInt d=0; d < 256; d++)
    463               {
    464                 if ( d == aiIdx2DepthValue_coded[uiDltArrayIndex] )
    465                 {                 
    466                   WRITE_FLAG(1, "dlt_bit_map_flag[ layerId ][ j ]");
    467                   uiDltArrayIndex++;
    468                 }
    469                 else
    470                 {
    471                   WRITE_FLAG(0, "dlt_bit_map_flag[ layerId ][ j ]");
    472                 }
    473               }
    474             }
    475             // Diff Coding
    476             else
    477             {
    478               WRITE_CODE(uiNumDepthValues_coded, 8, "num_depth_values_in_dlt[i]");    // num_entry
    479 
    480 #if !H_3D_DELTA_DLT
    481               if ( pcDLT->getInterViewDltPredEnableFlag( i ) == false )   // Single-view DLT Diff Coding
    482 #endif
    483               {
    484                 // 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.
    485                 if ( uiNumDepthValues_coded > 1 )
    486                 {
    487                   WRITE_CODE(uiMaxDiff, 8, "max_diff[ layerId ]");        // max_diff
    488                 }
    489 
    490                 if ( uiNumDepthValues_coded > 2 )
    491                 {
    492                   WRITE_CODE((uiMinDiff - 1), uiLengthMinDiff, "min_diff_minus1[ layerId ]");     // min_diff_minus1
    493                 }
    494 
    495                 WRITE_CODE(aiIdx2DepthValue_coded[0], 8, "dlt_depth_value0[layerId]");          // entry0
    496 
    497                 if (uiMaxDiff > uiMinDiff)
    498                 {
    499                   for (UInt d=1; d < uiNumDepthValues_coded; d++)
    500                   {
    501                     WRITE_CODE( (puiDltDiffValues[d] - uiMinDiff), uiLengthDltDiffMinusMin, "dlt_depth_value_diff_minus_min[ layerId ][ j ]");    // entry_value_diff_minus_min[ k ]
    502                   }
    503                 }
    504               }
    505             }
    506 
    507             free(puiDltDiffValues);
    508           }
    509         }
    510       }
    511     }
    512   }
    513 }
    514 #endif
     292#endif
     293
     294}
     295
    515296
    516297Void TEncCavlc::codeVUI( TComVUI *pcVUI, TComSPS* pcSPS )
     
    676457}
    677458
    678 #if H_3D
    679 Void TEncCavlc::codeSPS( TComSPS* pcSPS, Int viewIndex, Bool depthFlag )
    680 #else
    681459Void TEncCavlc::codeSPS( TComSPS* pcSPS )
    682 #endif
    683460{
    684461#if ENC_DEC_TRACE 
     
    884661    WRITE_FLAG( pcSPS->getSpsRangeExtensionsFlag( ) ? 1 : 0 , "sps_range_extensions_flag" );
    885662    WRITE_FLAG( pcSPS->getSpsMultilayerExtensionFlag( ) ? 1 : 0 , "sps_multilayer_extension_flag" );
    886 #if !H_3D
    887663    WRITE_CODE( pcSPS->getSpsExtension6bits( ), 6, "sps_extension_6bits" ); 
    888 #else
    889     WRITE_FLAG( pcSPS->getSps3dExtensionFlag( ) ? 1 : 0 , "sps_3d_extension_flag" );
    890     WRITE_CODE( pcSPS->getSpsExtension5bits( ), 5, "sps_extension_5bits" );
    891 #endif
    892664  }
    893665
     
    902674  }
    903675
    904 #if H_3D
    905   if ( pcSPS->getSps3dExtensionFlag() )
    906   {
    907     codeSPSExtension2( pcSPS, viewIndex, depthFlag  );
    908   }
    909 
    910 #endif
    911676#endif
    912677
     
    948713#endif
    949714
    950 #if H_3D
    951 Void TEncCavlc::codeSPSExtension2( TComSPS* pcSPS, Int viewIndex, Bool depthFlag )
    952 {
    953 #if H_3D_QTLPC
    954 #if !MTK_I0099_VPS_EX2
    955 //GT: This has to go to VPS
    956 if( depthFlag )
    957 {
    958   WRITE_FLAG( pcSPS->getUseQTL() ? 1 : 0, "use_qtl_flag");
    959   WRITE_FLAG( pcSPS->getUsePC()  ? 1 : 0, "use_pc_flag");
    960 }
    961 #endif
    962 #endif
    963 }
    964 
    965 
    966 #endif
    967715
    968716
     
    1068816  m_pcBitIf->writeAlignOne();
    1069817  codeVPSExtension( pcVPS );                           
    1070 #if H_3D
    1071   WRITE_FLAG( 1,                     "vps_extension2_flag" );
    1072   m_pcBitIf->writeAlignOne();     
    1073   codeVPSExtension2( pcVPS );
    1074   WRITE_FLAG( 0,                     "vps_extension3_flag" );
    1075 #else
    1076818  WRITE_FLAG( 0,                     "vps_extension2_flag" );
    1077 #endif
    1078819#else
    1079820  WRITE_FLAG( 0,                     "vps_extension_flag" );
     
    18021543#endif
    18031544
    1804 #if H_3D
    1805 Void TEncCavlc::codeVPSExtension2( TComVPS* pcVPS )
    1806 {
    1807 #if SEC_VPS_CLEANUP_I0090
    1808   for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
    1809 #else
    1810   for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
    1811 #endif
    1812   {
    1813 #if !SEC_VPS_CLEANUP_I0090
    1814     if (i!= 0)
    1815 #endif
    1816     {
    1817 #if MTK_I0099_VPS_EX2
    1818       WRITE_FLAG( pcVPS->getIvMvPredFlag         ( i ) ? 1 : 0 , "iv_mv_pred_flag[i]");
    1819 #if SEC_HLS_CLEANUP_I0100
    1820       WRITE_FLAG( pcVPS->getIvMvScalingFlag( i ) ? 1 : 0 ,       "iv_mv_scaling_flag[i]" );
    1821 #endif
    1822 
    1823 #endif
    1824       if ( !( pcVPS->getDepthId( i ) == 1 ) )
    1825       {
    1826 #if H_3D_IV_MERGE
    1827 #if !MTK_I0099_VPS_EX2
    1828         WRITE_FLAG( pcVPS->getIvMvPredFlag         ( i ) ? 1 : 0 , "iv_mv_pred_flag[i]");
    1829 #endif
    1830 #if H_3D_SPIVMP
    1831         WRITE_UVLC( pcVPS->getSubPULog2Size(i)-3, "log2_sub_PU_size_minus3[i]");
    1832 #endif
    1833 #endif
    1834 #if H_3D_ARP
    1835         WRITE_FLAG( pcVPS->getUseAdvRP             ( i ) ? 1 : 0,  "iv_res_pred_flag[i]"  );
    1836 #endif
    1837 #if H_3D_NBDV_REF
    1838         WRITE_FLAG( pcVPS->getDepthRefinementFlag  ( i ) ? 1 : 0 , "depth_refinement_flag[i]");
    1839 #endif
    1840 #if H_3D_VSP
    1841         WRITE_FLAG( pcVPS->getViewSynthesisPredFlag( i ) ? 1 : 0 , "view_synthesis_pred_flag[i]");
    1842 #endif
    1843 #if H_3D_DBBP
    1844         WRITE_FLAG( pcVPS->getUseDBBP( i ) ? 1 : 0, "use_dbbp_flag[i]" );
    1845 #endif
    1846       }         
    1847       else
    1848       {
    1849 #if !MTK_I0099_VPS_EX2
    1850         if(i!=1)
    1851         {
    1852           WRITE_FLAG( pcVPS->getIvMvPredFlag         ( i ) ? 1 : 0 , "iv_mv_pred_flag[i]");
    1853         }
    1854 #if H_3D_SPIVMP
    1855         if (i!=1)
    1856         {
    1857           WRITE_UVLC( pcVPS->getSubPULog2Size(i)-3, "log2_sub_PU_size_minus3[i]");
    1858         }
    1859 #endif
    1860 #endif
    1861 #if H_3D_IV_MERGE
    1862         WRITE_FLAG( pcVPS->getMPIFlag( i ) ? 1 : 0 ,          "mpi_flag[i]" );
    1863 #endif
    1864 #if MTK_I0099_VPS_EX2
    1865         WRITE_UVLC( pcVPS->getSubPUMPILog2Size(i)-3, "log2_mpi_sub_PU_size_minus3[i]");
    1866 #endif
    1867         WRITE_FLAG( pcVPS->getVpsDepthModesFlag( i ) ? 1 : 0 ,          "vps_depth_modes_flag[i]" );
    1868 #if SEPARATE_FLAG_I0085
    1869         WRITE_FLAG( pcVPS->getIVPFlag( i ) ? 1 : 0 ,               "IVP_flag[i]" );
    1870 #endif
    1871 #if MTK_I0099_VPS_EX2
    1872         WRITE_FLAG( pcVPS->getLimQtPredFlag    ( i ) ? 1 : 0 ,          "lim_qt_pred_flag[i]"     );
    1873 #endif
    1874 
    1875 #if H_3D_INTER_SDC
    1876         WRITE_FLAG( pcVPS->getInterSDCFlag( i ) ? 1 : 0, "depth_inter_SDC_flag" );
    1877 #endif
    1878       }
    1879     } 
    1880   }
    1881   WRITE_UVLC( pcVPS->getCamParPrecision(), "cp_precision" );
    1882 #if SEC_VPS_CLEANUP_I0090
    1883   for (UInt viewIndex=1; viewIndex<pcVPS->getNumViews(); viewIndex++)
    1884 #else
    1885   for (UInt viewIndex=0; viewIndex<pcVPS->getNumViews(); viewIndex++)
    1886 #endif
    1887   {
    1888     WRITE_FLAG( pcVPS->getCamParPresent(viewIndex) ? 1 : 0, "cp_present_flag[i]" );
    1889     if ( pcVPS->getCamParPresent(viewIndex) )
    1890     {
    1891       WRITE_FLAG( pcVPS->hasCamParInSliceHeader(viewIndex) ? 1 : 0, "cp_in_slice_segment_header_flag[i]" );
    1892       if ( !pcVPS->hasCamParInSliceHeader(viewIndex) )
    1893       {
    1894         for( UInt uiIndex = 0; uiIndex < viewIndex; uiIndex++ )
    1895         {
    1896           WRITE_SVLC( pcVPS->getCodedScale    (viewIndex)[ uiIndex ],                                               "vps_cp_scale" );
    1897           WRITE_SVLC( pcVPS->getCodedOffset   (viewIndex)[ uiIndex ],                                               "vps_cp_off" );
    1898           WRITE_SVLC( pcVPS->getInvCodedScale (viewIndex)[ uiIndex ] + pcVPS->getCodedScale (viewIndex)[ uiIndex ], "vps_cp_inv_scale_plus_scale" );
    1899           WRITE_SVLC( pcVPS->getInvCodedOffset(viewIndex)[ uiIndex ] + pcVPS->getCodedOffset(viewIndex)[ uiIndex ], "vps_cp_inv_off_plus_off" );
    1900         }
    1901       }
    1902     }
    1903   }
    1904 #if !MTK_I0099_VPS_EX2
    1905   WRITE_UVLC( pcVPS->getSubPUMPILog2Size( ) - 3, "log2_sub_PU_MPI_size_minus3");
    1906 #endif
    1907 #if H_3D_TMVP
    1908 #if !SEC_HLS_CLEANUP_I0100
    1909   WRITE_FLAG( pcVPS->getIvMvScalingFlag( ) ? 1 : 0 ,          "iv_mv_scaling_flag" );
    1910 #endif
    1911 #endif
    1912 }
    1913 #endif
    19141545
    19151546Void TEncCavlc::codeSliceHeader         ( TComSlice* pcSlice )
     
    19521583#endif
    19531584  }
    1954 #if PPS_FIX_DEPTH
    1955   if( pcSlice->getIsDepth() )
    1956   {
    1957     WRITE_UVLC( 1, "slice_pic_parameter_set_id" );
    1958   }
    1959   else
    1960 #endif
    19611585  WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" );
    19621586  pcSlice->setDependentSliceSegmentFlag(!pcSlice->isNextSlice());
     
    21991823    {
    22001824      Bool overrideFlag = (pcSlice->getNumRefIdx( REF_PIC_LIST_0 )!=pcSlice->getPPS()->getNumRefIdxL0DefaultActive()||(pcSlice->isInterB()&&pcSlice->getNumRefIdx( REF_PIC_LIST_1 )!=pcSlice->getPPS()->getNumRefIdxL1DefaultActive()));
    2201 #if PPS_FIX_DEPTH
    2202       overrideFlag |= (pcSlice->getIsDepth() && !pcSlice->getViewIndex());
    2203 #endif
    22041825      WRITE_FLAG( overrideFlag ? 1 : 0,                               "num_ref_idx_active_override_flag");
    22051826      if (overrideFlag)
     
    22211842      pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
    22221843    }
    2223 #if PPS_FIX_DEPTH
    2224     if( (pcSlice->getPPS()->getListsModificationPresentFlag() || (pcSlice->getIsDepth() && !pcSlice->getViewIndex())) && pcSlice->getNumRpsCurrTempList() > 1)
    2225 #else
    22261844    if( pcSlice->getPPS()->getListsModificationPresentFlag() && pcSlice->getNumRpsCurrTempList() > 1)
    2227 #endif
    22281845    {
    22291846      TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
     
    23071924      xCodePredWeightTable( pcSlice );
    23081925    }
    2309 #if H_3D_IC
    2310 #if SEC_HLS_CLEANUP_I0100
    2311     else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE ) && !pcSlice->getIsDepth() && vps->getNumDirectRefLayers( layerId ) > 0 )
    2312 #else
    2313     else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE ) && !pcSlice->getIsDepth())
    2314 #endif
    2315     {
    2316       WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "slice_ic_enable_flag" );
    2317       if( pcSlice->getApplyIC() )
    2318       {
    2319         WRITE_FLAG( pcSlice->getIcSkipParseFlag() ? 1 : 0, "ic_skip_mergeidx0" );
    2320       }
    2321     }
    2322 #endif
    2323 #if MTK_SINGLE_DEPTH_MODE_I0095
    2324     if(pcSlice->getIsDepth())
    2325     {
    2326       WRITE_FLAG( pcSlice->getApplySingleDepthMode() ? 1 : 0, "slice_enable_single_depth_mode" );
    2327     }
    2328 #endif
    2329 #if H_3D_IV_MERGE
    2330     assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS_MEM);
    2331 #else
    23321926    assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS);
    2333 #endif
    23341927    if (!pcSlice->isIntra())
    23351928    {
    2336 #if H_3D_IV_MERGE
    2337       if(pcSlice->getIsDepth())
    2338       {
    2339         Bool bMPIFlag = pcSlice->getVPS()->getMPIFlag( pcSlice->getLayerIdInVps() ) ;
    2340         Bool ivMvPredFlag = pcSlice->getVPS()->getIvMvPredFlag( pcSlice->getLayerIdInVps() ) ;
    2341         WRITE_UVLC( ( ( bMPIFlag || ivMvPredFlag ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
    2342       }
    2343       else
    2344       {
    2345         Bool ivMvPredFlag = pcSlice->getVPS()->getIvMvPredFlag( pcSlice->getLayerIdInVps() ) ;
    2346         WRITE_UVLC( ( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
    2347       }
    2348 #else
    23491929      WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
    2350 #endif
    23511930    }
    23521931    Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 );
     
    23841963    }
    23851964  }
    2386 #if H_3D
    2387 #if LGE_FCO_I0116
    2388   if( pcSlice->getVPS()->hasCamParInSliceHeader( pcSlice->getViewIndex() ) && pcSlice->getIsDepth() )
    2389 #else
    2390   if( pcSlice->getVPS()->hasCamParInSliceHeader( pcSlice->getViewIndex() ) && !pcSlice->getIsDepth() )
    2391 #endif
    2392   {
    2393     for( UInt uiId = 0; uiId < pcSlice->getViewIndex(); uiId++ )
    2394     {
    2395       WRITE_SVLC( pcSlice->getCodedScale    ()[ uiId ],                                     "cp_scale" );
    2396       WRITE_SVLC( pcSlice->getCodedOffset   ()[ uiId ],                                     "cp_off" );
    2397       WRITE_SVLC( pcSlice->getInvCodedScale ()[ uiId ] + pcSlice->getCodedScale ()[ uiId ], "cp_inv_scale_plus_scale" );
    2398       WRITE_SVLC( pcSlice->getInvCodedOffset()[ uiId ] + pcSlice->getCodedOffset()[ uiId ], "cp_inv_off_plus_off" );
    2399     }
    2400   }
    2401 #endif
    24021965
    24031966
     
    27342297}
    27352298
    2736 #if H_3D_ARP
    2737 Void TEncCavlc::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
     2299
     2300
     2301Void TEncCavlc::codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode )
    27382302{
    27392303  assert(0);
    27402304}
    2741 #endif
    2742 
    2743 #if H_3D_IC
    2744 Void TEncCavlc::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
     2305
     2306Void TEncCavlc::codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
    27452307{
    27462308  assert(0);
    27472309}
    2748 #endif
    2749 
    2750 Void TEncCavlc::codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode )
     2310
     2311Void TEncCavlc::codeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
    27512312{
    27522313  assert(0);
    27532314}
    2754 
    2755 Void TEncCavlc::codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
    2756 {
    2757   assert(0);
    2758 }
    2759 
    2760 Void TEncCavlc::codeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
    2761 {
    2762   assert(0);
    2763 }
    2764 #if MTK_SINGLE_DEPTH_MODE_I0095
    2765 Void TEncCavlc::codeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx )
    2766 {
    2767   assert(0);
    2768 }
    2769 #endif
    27702315Void TEncCavlc::codeSplitFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    27712316{
     
    30352580}
    30362581
    3037 #if H_3D_INTER_SDC
    3038 Void TEncCavlc::codeDeltaDC( TComDataCU* pcCU, UInt uiAbsPartIdx )
    3039 {
    3040   assert(0);
    3041 }
    3042 
    3043 Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx )
    3044 {
    3045   assert(0);
    3046 }
    3047 
    3048 #endif
    30492582   
    3050 #if H_3D_DBBP
    3051 Void TEncCavlc::codeDBBPFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx )
    3052 {
    3053   assert(0);
    3054 }
    3055 #endif
    30562583//! \}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncCavlc.h

    r1066 r1072  
    9898  Void  codeSPSExtension        ( TComSPS* pcSPS );
    9999#endif
    100 #if H_3D
    101   Void  codeVPSExtension2       ( TComVPS* pcVPS );
    102   Void  codeSPSExtension2       ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag  );
    103   Void  codeSPS                 ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag );
    104 #else
    105100  Void  codeSPS                 ( TComSPS* pcSPS );
    106 #endif
    107101  Void  codePPS                 ( TComPPS* pcPPS );
    108102
     
    113107#endif
    114108
    115 #if H_3D
    116   Void  codePPSExtension        ( TComPPS* pcPPS );
    117 #endif
    118109
    119110  Void  codeSliceHeader         ( TComSlice* pcSlice );
     
    129120  Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx );
    130121  Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    131 #if MTK_SINGLE_DEPTH_MODE_I0095
    132   Void codeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx );
    133 #endif
    134122  Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    135123  Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    136124 
    137 #if H_3D_ARP
    138   Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    139 #endif
    140 #if H_3D_IC
    141   Void codeICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    142 #endif
    143 #if H_3D_INTER_SDC
    144   Void codeDeltaDC       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    145   Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    146 #endif
    147 #if H_3D_DBBP
    148   Void codeDBBPFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    149 #endif
    150125
    151126  Void codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode );
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncCfg.h

    r1039 r1072  
    4646#include "TLibCommon/TComSlice.h"
    4747#include <assert.h>
    48 #if H_3D
    49 #include "TAppCommon/TAppComCamPara.h"
    50 #include "TLibRenderer/TRenModSetupStrParser.h"
    51 #endif
    5248
    5349struct GOPEntry
     
    297293  Bool      m_RCForceIntraQP;
    298294
    299 #if KWU_RC_MADPRED_E0227
    300   UInt       m_depthMADPred;
    301 #endif
    302 #if KWU_RC_VIEWRC_E0227
    303   Bool      m_bViewWiseRateCtrl;
    304 #endif
    305295  Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
    306296  Bool      m_CUTransquantBypassFlagForce;                    ///< if transquant_bypass_enable_flag, then, if true, all CU transquant bypass flags will be set to true.
     
    311301#endif
    312302
    313 #if H_3D
    314   TComDLT*  m_cDLT;
    315 #endif
    316303
    317304  Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
     
    366353#endif
    367354
    368 #if H_3D
    369   Bool      m_isDepth;
    370 
    371   //====== Camera Parameters ======
    372   UInt      m_uiCamParPrecision;
    373   Bool      m_bCamParInSliceHeader;
    374   Int**     m_aaiCodedScale;
    375   Int**     m_aaiCodedOffset;
    376   TAppComCamPara* m_cameraParameters;
    377  
    378 #if H_3D_VSO
    379   //====== View Synthesis Optimization ======
    380   TRenModSetupStrParser* m_renderModelParameters;
    381   Bool      m_bUseVSO;
    382   Bool      m_bForceLambdaScale;
    383   Bool      m_bAllowNegDist;
    384   Double    m_dLambdaScaleVSO;
    385   UInt      m_uiVSOMode;
    386   // LGE_WVSO_A0119
    387   Bool      m_bUseWVSO;
    388   Int       m_iVSOWeight;
    389   Int       m_iVSDWeight;
    390   Int       m_iDWeight;
    391   // SAIT_VSO_EST_A0033
    392   Bool      m_bUseEstimatedVSD;
    393   Double    m_dDispCoeff;
    394 #endif
    395 #if H_3D_ARP
    396   UInt      m_uiUseAdvResPred;
    397   UInt      m_uiARPStepNum;
    398 #endif
    399 #if H_3D_SPIVMP
    400   Int      m_iSubPULog2Size;
    401   Int      m_iSubPUMPILog2Size;
    402 #endif
    403 #if H_3D_IC
    404   Bool      m_bUseIC;
    405   Bool      m_bUseICLowLatencyEnc;
    406 #endif
    407 #if H_3D_INTER_SDC
    408   bool      m_bInterSDC;
    409 #endif
    410 #if H_3D_DBBP
    411   Bool      m_bUseDBBP;
    412 #endif
    413   //====== Depth Intra Modes ======
    414 #if H_3D_DIM
    415   Bool      m_useDMM;
    416 #if SEPARATE_FLAG_I0085
    417   Bool      m_useIVP;
    418 #endif
    419   Bool      m_useSDC;
    420   Bool      m_useDLT;
    421 #endif
    422 #if MTK_SINGLE_DEPTH_MODE_I0095
    423   Bool      m_useSingleDepthMode;
    424 #endif
    425 #if H_3D_IV_MERGE
    426   Bool      m_useMPI;
    427 #endif
    428 #if !MTK_I0099_VPS_EX2 || MTK_I0099_FIX
    429 #if H_3D_QTLPC
    430   Bool      m_bUseQTL;
    431 #if !MTK_I0099_VPS_EX2
    432   Bool      m_bUsePC;
    433 #endif
    434 #endif
    435 #endif
    436 #endif
    437355public:
    438356  TEncCfg()
     
    444362  , m_viewId(-1)
    445363  , m_viewIndex(-1)
    446 #if H_3D
    447   , m_isDepth(false)
    448   , m_bUseVSO(false)
    449 #endif
    450364#endif
    451365  {}
     
    479393  Void      setViewIndex                     ( Int viewIndex  )   { m_viewIndex  = viewIndex;  }
    480394  Int       getViewIndex                     ()                   { return m_viewIndex;    }
    481 #if H_3D
    482   Void      setIsDepth                       ( Bool isDepth )   { m_isDepth = isDepth; }
    483   Bool      getIsDepth                       ()                 { return m_isDepth; }
    484 #endif
    485395#endif
    486396  //====== Coding Structure ========
     
    508418  Void      setMaxTempLayer                 ( Int maxTempLayer )            { m_maxTempLayer = maxTempLayer;      }
    509419
    510 #if H_3D_ARP
    511   UInt       getUseAdvRP                    ( )              { return m_uiUseAdvResPred; }
    512   Void       setUseAdvRP                    ( UInt  u )      { m_uiUseAdvResPred = u;    }
    513 
    514   UInt       getARPStepNum                  ()               { return m_uiARPStepNum;    }
    515   Void       setARPStepNum                  ( UInt  u )      { m_uiARPStepNum = u;       }
    516 #endif
    517 #if H_3D_SPIVMP
    518   Int        getSubPULog2Size                   ()                   { return m_iSubPULog2Size;}
    519   Void       setSubPULog2Size                   (Int u)              { m_iSubPULog2Size = u; }     
    520   Int        getSubPUMPILog2Size            ()               { return m_iSubPUMPILog2Size;}
    521   Void       setSubPUMPILog2Size            (Int u)          { m_iSubPUMPILog2Size = u;   }     
    522 #endif
    523 #if H_3D_IC
    524   Void       setUseIC                       ( Bool bVal )    { m_bUseIC = bVal; }
    525   Bool       getUseIC                       ()               { return m_bUseIC; }
    526   Void       setUseICLowLatencyEnc          ( Bool bVal )    { m_bUseICLowLatencyEnc = bVal; }
    527   Bool       getUseICLowLatencyEnc          ()               { return m_bUseICLowLatencyEnc; }
    528 #endif
    529 #if H_3D_INTER_SDC
    530   Void       setInterSDCEnable              ( Bool bVal )    { m_bInterSDC = bVal; }
    531   Bool       getInterSDCEnable              ()               { return m_bInterSDC; }
    532 #endif
    533 #if H_3D_DBBP
    534   Void       setUseDBBP                     ( Bool  b )      { m_bUseDBBP   = b; }
    535   Bool       getUseDBBP()                                    { return m_bUseDBBP;     }
    536 #endif
    537420  //======== Transform =============
    538421  Void      setQuadtreeTULog2MaxSize        ( UInt  u )      { m_uiQuadtreeTULog2MaxSize = u; }
     
    863746  Void      setForceIntraQP        ( Bool b )      { m_RCForceIntraQP = b;           }
    864747
    865 #if KWU_RC_MADPRED_E0227
    866   UInt      getUseDepthMADPred    ()                { return m_depthMADPred;        }
    867   Void      setUseDepthMADPred    (UInt b)          { m_depthMADPred    = b;        }
    868 #endif
    869 #if KWU_RC_VIEWRC_E0227
    870   Bool      getUseViewWiseRateCtrl    ()                { return m_bViewWiseRateCtrl;        }
    871   Void      setUseViewWiseRateCtrl    (Bool b)          { m_bViewWiseRateCtrl    = b;        }
    872 #endif
    873748  Bool      getTransquantBypassEnableFlag()           { return m_TransquantBypassEnableFlag; }
    874749  Void      setTransquantBypassEnableFlag(Bool flag)  { m_TransquantBypassEnableFlag = flag; }
     
    883758#endif
    884759
    885 #if H_3D
    886   Void      setDLT           ( TComDLT *p ) { m_cDLT = p; }
    887   TComDLT*  getDLT           ()             { return m_cDLT; }
    888 #endif
    889760
    890761  Void      setUseRecalculateQPAccordingToLambda ( Bool b ) { m_recalculateQPAccordingToLambda = b;    }
     
    968839  Bool getFrameOnlyConstraintFlag() const { return m_frameOnlyConstraintFlag; }
    969840  Void setFrameOnlyConstraintFlag(Bool b) { m_frameOnlyConstraintFlag = b; }
    970 #if H_3D
    971   /// 3D Tools
    972 
    973  //==== CAMERA PARAMETERS  ==========
    974   Void      setCamParPrecision              ( UInt  u )      { m_uiCamParPrecision      = u; }
    975   Void      setCamParInSliceHeader          ( Bool  b )      { m_bCamParInSliceHeader   = b; }
    976   Void      setCodedScale                   ( Int** p )      { m_aaiCodedScale          = p; }
    977   Void      setCodedOffset                  ( Int** p )      { m_aaiCodedOffset         = p; }
    978   Void      setCameraParameters             ( TAppComCamPara* c) { m_cameraParameters   = c; }
    979 
    980 #if H_3D_VSO
    981  //==== VSO  ==========
    982   Void      setRenderModelParameters ( TRenModSetupStrParser* c ) { m_renderModelParameters = c; }
    983   Bool      getUseVSO                       ()              { return m_bUseVSO;     }
    984   Void      setUseVSO                       ( Bool  b  )    { m_bUseVSO     = b; }
    985   UInt      getVSOMode                      ()              { return m_uiVSOMode; }
    986   Void      setVSOMode                      ( UInt  ui )    { m_uiVSOMode   = ui; }
    987   Bool      getForceLambdaScaleVSO          ()              { return m_bForceLambdaScale; }
    988   Void      setForceLambdaScaleVSO          ( Bool   b )    { m_bForceLambdaScale = b; };
    989   Double    getLambdaScaleVSO               ()              { return m_dLambdaScaleVSO;   }
    990   Void      setLambdaScaleVSO               ( Double d )    { m_dLambdaScaleVSO   = d; };
    991   Bool      getAllowNegDist                 ()              { return m_bAllowNegDist;     }
    992   Void      setAllowNegDist                 ( Bool   b )    { m_bAllowNegDist     = b; };
    993 
    994   // LGE_WVSO_A0119
    995   Bool      getUseWVSO                      ()              { return m_bUseWVSO;     }
    996   Void      setUseWVSO                      ( Bool  b )     { m_bUseWVSO   = b; }
    997   Int       getVSOWeight                    ()              { return m_iVSOWeight;    }
    998   Void      setVSOWeight                    ( Int   i )     { m_iVSOWeight = i; }
    999   Int       getVSDWeight                    ()              { return m_iVSDWeight;    }
    1000   Void      setVSDWeight                    ( Int   i )     { m_iVSDWeight = i; }
    1001   Int       getDWeight                      ()              { return m_iDWeight;    }
    1002   Void      setDWeight                      ( Int   i )     { m_iDWeight   = i; }
    1003 
    1004   // SAIT_VSO_EST_A0033
    1005   Bool      getUseEstimatedVSD              ()              { return m_bUseEstimatedVSD; }
    1006   Void      setUseEstimatedVSD              ( Bool  b )     { m_bUseEstimatedVSD = b; }
    1007   Double    getDispCoeff                    ()              { return m_dDispCoeff;    }
    1008   Void      setDispCoeff                    ( Double  d )   { m_dDispCoeff  = d; }
    1009 #endif // H_3D_VSO
    1010 
    1011  //==== DIM  ==========
    1012 #if H_3D_DIM
    1013   Bool      getUseDMM                       ()        { return m_useDMM; }
    1014   Void      setUseDMM                       ( Bool b) { m_useDMM = b;    }
    1015 #if SEPARATE_FLAG_I0085
    1016   Bool      getUseIVP                       ()        { return m_useIVP; }
    1017   Void      setUseIVP                       ( Bool b) { m_useIVP = b;    }
    1018 #endif
    1019   Bool      getUseSDC                       ()        { return m_useSDC; }
    1020   Void      setUseSDC                       ( Bool b) { m_useSDC = b;    }
    1021   Bool      getUseDLT                       ()        { return m_useDLT; }
    1022   Void      setUseDLT                       ( Bool b) { m_useDLT = b;    }
    1023 #endif
    1024 #if MTK_SINGLE_DEPTH_MODE_I0095
    1025   Void       setUseSingleDepthMode          ( Bool bVal )    { m_useSingleDepthMode = bVal; }
    1026   Bool       getUseSingleDepthMode          ()               { return m_useSingleDepthMode; }
    1027 #endif
    1028 #if !MTK_I0099_VPS_EX2 || MTK_I0099_FIX
    1029 #if H_3D_QTLPC
    1030   Void      setUseQTL                       ( Bool b ) { m_bUseQTL = b;    }
    1031   Bool      getUseQTL                       ()         { return m_bUseQTL; }
    1032 #if !MTK_I0099_VPS_EX2
    1033   Void      setUsePC                        ( Bool b ) { m_bUsePC  = b;    }
    1034   Bool      getUsePC                        ()         { return m_bUsePC;  }
    1035 #endif
    1036 #endif
    1037 #endif
    1038 #if H_3D_IV_MERGE
    1039   Void      setUseMPI                       ( Bool b ) { m_useMPI = b;    }
    1040   Bool      getUseMPI                       ()         { return m_useMPI; }
    1041 #endif
    1042 #endif // H_3D
    1043841};
    1044842
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncCu.cpp

    r1066 r1072  
    6565  m_ppcTempCU      = new TComDataCU*[m_uhTotalDepth-1];
    6666   
    67 #if H_3D_ARP
    68   m_ppcWeightedTempCU = new TComDataCU*[m_uhTotalDepth-1];
    69 #endif
    7067
    7168  m_ppcPredYuvBest = new TComYuv*[m_uhTotalDepth-1];
     
    7673  m_ppcRecoYuvTemp = new TComYuv*[m_uhTotalDepth-1];
    7774  m_ppcOrigYuv     = new TComYuv*[m_uhTotalDepth-1];
    78 #if H_3D_DBBP
    79   m_ppcOrigYuvDBBP = new TComYuv*[m_uhTotalDepth-1];
    80 #endif
    8175 
    8276  UInt uiNumPartitions;
     
    9084    m_ppcTempCU[i] = new TComDataCU; m_ppcTempCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
    9185   
    92 #if H_3D_ARP
    93     m_ppcWeightedTempCU[i] = new TComDataCU; m_ppcWeightedTempCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
    94 #endif 
    9586
    9687    m_ppcPredYuvBest[i] = new TComYuv; m_ppcPredYuvBest[i]->create(uiWidth, uiHeight);
     
    10394   
    10495    m_ppcOrigYuv    [i] = new TComYuv; m_ppcOrigYuv    [i]->create(uiWidth, uiHeight);
    105 #if H_3D_DBBP
    106     m_ppcOrigYuvDBBP[i] = new TComYuv; m_ppcOrigYuvDBBP[i]->create(uiWidth, uiHeight);
    107 #endif
    10896  }
    10997 
    11098  m_bEncodeDQP = false;
    111 #if KWU_RC_MADPRED_E0227
    112   m_LCUPredictionSAD = 0;
    113   m_addSADDepth      = 0;
    114   m_temporalSAD      = 0;
    115   m_spatialSAD       = 0;
    116 #endif
    11799
    118100  // initialize partition order.
     
    139121      m_ppcTempCU[i]->destroy();      delete m_ppcTempCU[i];      m_ppcTempCU[i] = NULL;
    140122    }
    141 #if H_3D_ARP
    142     if(m_ppcWeightedTempCU[i])
    143     {
    144       m_ppcWeightedTempCU[i]->destroy(); delete m_ppcWeightedTempCU[i]; m_ppcWeightedTempCU[i] = NULL;
    145     }
    146 #endif
    147123    if(m_ppcPredYuvBest[i])
    148124    {
     
    173149      m_ppcOrigYuv[i]->destroy();     delete m_ppcOrigYuv[i];     m_ppcOrigYuv[i] = NULL;
    174150    }
    175 #if H_3D_DBBP
    176     if(m_ppcOrigYuvDBBP[i])
    177     {
    178       m_ppcOrigYuvDBBP[i]->destroy(); delete m_ppcOrigYuvDBBP[i]; m_ppcOrigYuvDBBP[i] = NULL;
    179     }
    180 #endif
    181151  }
    182152  if(m_ppcBestCU)
     
    191161  }
    192162
    193 #if H_3D_ARP
    194   if(m_ppcWeightedTempCU)
    195   {
    196     delete [] m_ppcWeightedTempCU;
    197     m_ppcWeightedTempCU = NULL;
    198   }
    199 #endif
    200163  if(m_ppcPredYuvBest)
    201164  {
     
    233196    m_ppcOrigYuv = NULL;
    234197  }
    235 #if H_3D_DBBP
    236   if(m_ppcOrigYuvDBBP)
    237   {
    238     delete [] m_ppcOrigYuvDBBP;
    239     m_ppcOrigYuvDBBP = NULL;
    240   }
    241 #endif
    242198}
    243199
     
    275231  m_ppcTempCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() );
    276232
    277 #if KWU_RC_MADPRED_E0227
    278   m_LCUPredictionSAD = 0;
    279   m_addSADDepth      = 0;
    280   m_temporalSAD      = 0;
    281   m_spatialSAD       = 0;
    282 #endif
    283233
    284234  // analysis of CU
     
    408358  TComPic* pcPic = rpcBestCU->getPic();
    409359
    410 #if H_3D_QTLPC
    411 #if MTK_I0099_VPS_EX2
    412   TComVPS *vps            = pcPic->getSlice(0)->getVPS();
    413   Bool  bLimQtPredFalg    = vps->getLimQtPredFlag(pcPic->getSlice(0)->getLayerId());
    414 #else
    415   TComSPS *sps            = pcPic->getSlice(0)->getSPS();
    416 #endif
    417   TComPic *pcTexture      = rpcBestCU->getSlice()->getTexturePic();
    418 
    419   Bool  depthMapDetect    = (pcTexture != NULL);
    420   Bool  bIntraSliceDetect = (rpcBestCU->getSlice()->getSliceType() == I_SLICE);
    421 
    422   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);
    423 
    424   Bool bTry2NxN           = true;
    425   Bool bTryNx2N           = true;
    426 #endif
    427360  // get Original YUV data from picture
    428361  m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
    429362
    430 #if H_3D_QTLPC 
    431   Bool    bTrySplit     = true;
    432   Bool    bTrySplitDQP  = true;
    433 #endif
    434363
    435364  // variable for Early CU determination
     
    440369  Bool earlyDetectionSkipMode = false;
    441370
    442 #if H_3D_VSP
    443   DisInfo DvInfo;
    444   DvInfo.bDV = false;
    445   DvInfo.m_acNBDV.setZero();
    446   DvInfo.m_aVIdxCan = 0;
    447 #if H_3D_NBDV_REF
    448   DvInfo.m_acDoNBDV.setZero();
    449 #endif
    450 #endif
    451371  Bool bBoundary = false;
    452372  UInt uiLPelX   = rpcBestCU->getCUPelX();
     
    502422  }
    503423
    504 #if H_3D_IC
    505   Bool bICEnabled = rpcTempCU->getSlice()->getViewIndex() && ( rpcTempCU->getSlice()->getSliceType() == P_SLICE || rpcTempCU->getSlice()->getSliceType() == B_SLICE ) && !rpcTempCU->getSlice()->getIsDepth();
    506   bICEnabled = bICEnabled && rpcTempCU->getSlice()->getApplyIC();
    507 #endif
    508424  // If slice start or slice end is within this cu...
    509425  TComSlice * pcSlice = rpcTempCU->getPic()->getSlice(rpcTempCU->getPic()->getCurrSliceIdx());
     
    514430  if(!bSliceEnd && !bSliceStart && bInsidePicture )
    515431  {
    516 #if  H_3D_FAST_TEXTURE_ENCODING
    517     Bool bIVFMerge = false;
    518     Int  iIVFMaxD = 0;
    519     Bool bFMD = false;
    520 #endif
    521432    for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
    522433    {
     
    528439      }
    529440
    530 #if H_3D_QTLPC
    531       bTrySplit    = true;
    532 #endif
    533441
    534442      rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    535 #if H_3D_QTLPC
    536       //logic for setting bTrySplit using the partition information that is stored of the texture colocated CU
    537 
    538 #if MTK_I0099_VPS_EX2
    539 #if MTK_I0099_FIX
    540 #if LGE_FCO_I0116
    541       if(depthMapDetect && !bIntraSliceDetect && !rapPic && ( m_pcEncCfg->getUseQTL() || bLimQtPredFalg ) && pcTexture->getReconMark())
    542 #else
    543       if(depthMapDetect && !bIntraSliceDetect && !rapPic && ( m_pcEncCfg->getUseQTL() || bLimQtPredFalg ))
    544 #endif
    545 #else
    546       if(depthMapDetect && !bIntraSliceDetect && !rapPic && bLimQtPredFalg)
    547 #endif
    548 #else
    549       if(depthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL())
    550 #endif
    551       {
    552         TComDataCU* pcTextureCU = pcTexture->getCU( rpcBestCU->getAddr() ); //Corresponding texture LCU
    553         UInt uiCUIdx            = rpcBestCU->getZorderIdxInCU();
    554         assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth); //Depth cannot be more partitionned than the texture.
    555         if (pcTextureCU->getDepth(uiCUIdx) > uiDepth || pcTextureCU->getPartitionSize(uiCUIdx) == SIZE_NxN) //Texture was split.
    556         {
    557           bTrySplit = true;
    558           bTryNx2N  = true;
    559           bTry2NxN  = true;
    560         }
    561         else
    562         {
    563           bTrySplit = false;
    564           bTryNx2N  = false;
    565           bTry2NxN  = false;
    566           if( pcTextureCU->getDepth(uiCUIdx) == uiDepth && pcTextureCU->getPartitionSize(uiCUIdx) != SIZE_2Nx2N)
    567           {
    568             if(pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxN || pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxnU|| pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxnD)
    569               bTry2NxN  = true;
    570             else
    571               bTryNx2N  = true;
    572           }
    573         }
    574       }
    575 #endif
    576 
    577 #if H_3D_NBDV
    578       if( rpcTempCU->getSlice()->getSliceType() != I_SLICE )
    579       {
    580 #if H_3D_ARP && H_3D_IV_MERGE
    581         if( rpcTempCU->getSlice()->getVPS()->getUseAdvRP(rpcTempCU->getSlice()->getLayerId()) || rpcTempCU->getSlice()->getVPS()->getIvMvPredFlag(rpcTempCU->getSlice()->getLayerId()) )
    582 #else
    583 #if H_3D_ARP
    584         if( rpcTempCU->getSlice()->getVPS()->getUseAdvRP(rpcTempCU->getSlice()->getLayerId()) )
    585 #else
    586 #if H_3D_IV_MERGE
    587         if( rpcTempCU->getSlice()->getVPS()->getIvMvPredFlag(rpcTempCU->getSlice()->getLayerId()) )
    588 #else
    589         if (0)
    590 #endif
    591 #endif
    592 #endif
    593         {
    594           PartSize ePartTemp = rpcTempCU->getPartitionSize(0);
    595           rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
    596 #if H_3D_IV_MERGE
    597           if (rpcTempCU->getSlice()->getIsDepth() )
    598           {
    599             DvInfo.bDV = rpcTempCU->getDispforDepth(0, 0, &DvInfo);
    600           }
    601           else
    602           {
    603 #endif
    604 #if H_3D_NBDV_REF
    605           if(rpcTempCU->getSlice()->getVPS()->getDepthRefinementFlag( rpcTempCU->getSlice()->getLayerIdInVps()))
    606             DvInfo.bDV = rpcTempCU->getDisMvpCandNBDV(&DvInfo, true);
    607           else
    608 #endif
    609             DvInfo.bDV = rpcTempCU->getDisMvpCandNBDV(&DvInfo);
    610 
    611 #if H_3D_IV_MERGE
    612           }
    613 #endif
    614           rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    615           rpcBestCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    616           rpcTempCU->setPartSizeSubParts( ePartTemp, 0, uiDepth );
    617         }
    618       }
    619 #if  H_3D_FAST_TEXTURE_ENCODING
    620       if(rpcTempCU->getSlice()->getViewIndex() && !rpcTempCU->getSlice()->getIsDepth())
    621       {
    622         PartSize ePartTemp = rpcTempCU->getPartitionSize(0);
    623         rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
    624         rpcTempCU->getIVNStatus( 0, &DvInfo,  bIVFMerge, iIVFMaxD);
    625         rpcTempCU->setPartSizeSubParts( ePartTemp, 0, uiDepth );
    626       }
    627 #endif
    628 #endif
     443
    629444      // do inter modes, SKIP and 2Nx2N
    630445      if( rpcBestCU->getSlice()->getSliceType() != I_SLICE )
    631446      {
    632 #if H_3D_IC
    633         for( UInt uiICId = 0; uiICId < ( bICEnabled ? 2 : 1 ); uiICId++ )
    634         {
    635           Bool bICFlag = uiICId ? true : false;
    636 #endif
    637447        // 2Nx2N
    638448        if(m_pcEncCfg->getUseEarlySkipDetection())
    639449        {
    640 #if H_3D_IC
    641           rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    642 #endif
    643 #if  H_3D_FAST_TEXTURE_ENCODING
    644           xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD );  rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode  );//by Competition for inter_2Nx2N
    645 #else
    646450          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
    647451          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N
    648 #endif
    649 #if H_3D_VSP
    650           rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    651 #endif
    652452        }
    653453        // SKIP
    654 #if H_3D_IC
    655         rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    656 #endif
    657454        xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N
    658 #if  H_3D_FAST_TEXTURE_ENCODING
    659         bFMD = bIVFMerge && rpcBestCU->isSkipped(0);
    660 #endif
    661455        rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    662 #if H_3D_VSP
    663         rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    664 #endif
    665456
    666457        if(!m_pcEncCfg->getUseEarlySkipDetection())
    667458        {
    668459          // 2Nx2N, NxN
    669 #if H_3D_IC
    670             rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
    671 #endif
    672 #if  H_3D_FAST_TEXTURE_ENCODING
    673             xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD );  rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    674 #else
    675460          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
    676461          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    677 #endif
    678 #if H_3D_VSP
    679             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    680 #endif
    681462         
    682 #if H_3D_DBBP
    683           if( m_pcEncCfg->getUseDBBP() )
    684           {
    685             xCheckRDCostInterDBBP( rpcBestCU, rpcTempCU, false );
    686             rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode  );
    687 #if H_3D_VSP
    688             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    689 #endif
    690           }
    691 #endif
    692463         
    693464            if(m_pcEncCfg->getUseCbfFastMode())
     
    696467            }
    697468        }
    698 #if H_3D_IC
    699         }
    700 #endif
    701469      }
    702470
    703 #if H_3D_QTLPC     
    704 #if MTK_I0099_VPS_EX2
    705 #if MTK_I0099_FIX
    706       if(depthMapDetect && !bIntraSliceDetect && !rapPic && ( m_pcEncCfg->getUseQTL() || bLimQtPredFalg ))
    707 #else
    708       if(depthMapDetect && !bIntraSliceDetect && !rapPic && bLimQtPredFalg)
    709 #endif
    710 #else
    711       if(depthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL())
    712 #endif
    713       {
    714         bTrySplitDQP = bTrySplit;
    715       }
    716 #endif
    717471      if ( bIsLosslessMode )
    718472      {
     
    721475    }
    722476
    723 #if KWU_RC_MADPRED_E0227
    724     if ( uiDepth <= m_addSADDepth )
    725     {
    726       m_LCUPredictionSAD += m_temporalSAD;
    727       m_addSADDepth = uiDepth;
    728     }
    729 #endif
    730 #if H_3D_DIM_ENC
    731     if( rpcBestCU->getSlice()->getIsDepth() && rpcBestCU->getSlice()->isIRAP() )
    732     {
    733       earlyDetectionSkipMode = false;
    734     }
    735 #endif
    736 #if MTK_SINGLE_DEPTH_MODE_I0095
    737     rpcTempCU->initEstData( uiDepth, iMinQP, isAddLowestQP  );
    738     if(rpcBestCU->getSlice()->getApplySingleDepthMode())
    739     {
    740       xCheckRDCostSingleDepth( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
    741       rpcTempCU->initEstData( uiDepth, iMinQP, isAddLowestQP  );
    742     }
    743 #endif
    744477    if(!earlyDetectionSkipMode)
    745478    {
     
    761494            {
    762495              if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu
    763 #if H_3D_QTLPC
    764                 && bTrySplit
    765 #endif
    766496                )
    767497              {
    768 #if  H_3D_FAST_TEXTURE_ENCODING
    769                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN, bFMD  );
    770 #else
    771498                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN   );
    772 #endif
    773499                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    774 #if H_3D_VSP
    775                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    776 #endif
    777500              }
    778501            }
     
    780503          // 2NxN, Nx2N
    781504          if(doNotBlockPu
    782 #if H_3D_QTLPC
    783             && bTryNx2N
    784 #endif
    785505            )
    786506          {
    787 #if  H_3D_FAST_TEXTURE_ENCODING
    788             xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N, bFMD  );
    789 #else
    790507            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N  );
    791 #endif
    792508            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    793 #if H_3D_VSP
    794             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    795 #endif
    796509            if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_Nx2N )
    797510            {
     
    800513          }
    801514          if(doNotBlockPu
    802 #if H_3D_QTLPC
    803             && bTry2NxN
    804 #endif
    805515            )
    806516          {
    807 #if  H_3D_FAST_TEXTURE_ENCODING
    808             xCheckRDCostInter      ( rpcBestCU, rpcTempCU, SIZE_2NxN, bFMD  );
    809 #else
    810517            xCheckRDCostInter      ( rpcBestCU, rpcTempCU, SIZE_2NxN  );
    811 #endif
    812518            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    813 #if H_3D_VSP
    814             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    815 #endif
    816519            if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxN)
    817520            {
     
    839542            {
    840543              if(doNotBlockPu
    841 #if H_3D_QTLPC
    842                 && bTry2NxN
    843 #endif
    844544                )
    845545              {
    846 #if  H_3D_FAST_TEXTURE_ENCODING
    847                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFMD );
    848 #else
    849546                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
    850 #endif
    851547                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    852 #if H_3D_VSP
    853                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    854 #endif
    855548                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU )
    856549                {
     
    859552              }
    860553              if(doNotBlockPu
    861 #if H_3D_QTLPC
    862                 && bTry2NxN
    863 #endif
    864554                )
    865555              {
    866 #if  H_3D_FAST_TEXTURE_ENCODING
    867                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFMD );
    868 #else
    869556                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
    870 #endif
    871557                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    872 #if H_3D_VSP
    873                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    874 #endif
    875558                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
    876559                {
     
    883566            {
    884567              if(doNotBlockPu
    885 #if H_3D_QTLPC
    886                 && bTry2NxN
    887 #endif
    888568                )
    889569              {
    890 #if  H_3D_FAST_TEXTURE_ENCODING
    891                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFMD, true );
    892 #else
    893570                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true );
    894 #endif
    895571                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    896 #if H_3D_VSP
    897                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    898 #endif
    899572                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU )
    900573                {
     
    903576              }
    904577              if(doNotBlockPu
    905 #if H_3D_QTLPC
    906                 && bTry2NxN
    907 #endif
    908578                )
    909579              {
    910 #if  H_3D_FAST_TEXTURE_ENCODING
    911                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFMD, true );
    912 #else
    913580                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, true );
    914 #endif
    915581                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    916 #if H_3D_VSP
    917                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    918 #endif
    919582                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD )
    920583                {
     
    929592            {
    930593              if(doNotBlockPu
    931 #if H_3D_QTLPC
    932                 && bTryNx2N
    933 #endif
    934594                )
    935595              {
    936 #if  H_3D_FAST_TEXTURE_ENCODING
    937                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFMD );
    938 #else
    939596                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
    940 #endif
    941597                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    942 #if H_3D_VSP
    943                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    944 #endif
    945598                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N )
    946599                {
     
    949602              }
    950603              if(doNotBlockPu
    951 #if H_3D_QTLPC
    952                 && bTryNx2N
    953 #endif
    954604                )
    955605              {
    956 #if  H_3D_FAST_TEXTURE_ENCODING
    957                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFMD );
    958 #else
    959606                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
    960 #endif
    961607                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    962 #if H_3D_VSP
    963                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    964 #endif
    965608              }
    966609            }
     
    969612            {
    970613              if(doNotBlockPu
    971 #if H_3D_QTLPC
    972                 && bTryNx2N
    973 #endif
    974614                )
    975615              {
    976 #if  H_3D_FAST_TEXTURE_ENCODING
    977                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFMD, true );
    978 #else
    979616                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, true );
    980 #endif
    981617                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    982 #if H_3D_VSP
    983                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    984 #endif
    985618                if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N )
    986619                {
     
    989622              }
    990623              if(doNotBlockPu
    991 #if H_3D_QTLPC
    992                 && bTryNx2N
    993 #endif
    994624                )
    995625              {
    996 #if  H_3D_FAST_TEXTURE_ENCODING
    997                 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFMD, true );
    998 #else
    999626                xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true );
    1000 #endif
    1001627                rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1002 #if H_3D_VSP
    1003                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    1004 #endif
    1005628              }
    1006629            }
     
    1008631
    1009632#else
    1010 #if H_3D_QTLPC
    1011             if (bTry2NxN)
    1012             {
    1013 #endif
    1014633              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
    1015634              rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1016 #if H_3D_VSP
    1017               rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    1018 #endif
    1019635              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
    1020636              rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1021 #if H_3D_VSP
    1022               rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    1023 #endif
    1024 #if H_3D_QTLPC
    1025             }
    1026             if (bTryNx2N)
    1027             {
    1028 #endif
    1029637              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
    1030638              rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1031 #if H_3D_VSP
    1032               rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    1033 #endif
    1034639              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
    1035640              rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1036 #if H_3D_VSP
    1037               rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    1038 #endif
    1039 #if H_3D_QTLPC
    1040             }
    1041 #endif
    1042641
    1043642#endif
     
    1045644#endif
    1046645        }
    1047 #if  H_3D_FAST_TEXTURE_ENCODING
    1048         if(!bFMD)
    1049         {
    1050 #endif
    1051646        // do normal intra modes
    1052647       
     
    1056651              rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0   ||
    1057652              rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0     
    1058 #if H_3D_DIM_ENC
    1059 #if HHI_DMM4_ENC_I0066
    1060               || rpcBestCU->getSlice()->getIsDepth()
    1061 #else
    1062             || ( rpcBestCU->getSlice()->getIsDepth() && rpcBestCU->getSlice()->isIRAP() )
    1063 #endif
    1064 #endif
    1065653            ) // avoid very complex intra if it is unlikely
    1066654          {
    1067 #if HHI_DMM4_ENC_I0066
    1068             Bool bOnlyIVP = false;
    1069             if( rpcBestCU->getSlice()->getIsDepth() && !(rpcBestCU->getSlice()->isIRAP()) &&
    1070                 rpcBestCU->getSlice()->getSliceType() != I_SLICE &&
    1071                 rpcBestCU->getCbf( 0, TEXT_LUMA     ) == 0 &&
    1072                 rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) == 0 &&
    1073                 rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) == 0
    1074               )
    1075             {
    1076               bOnlyIVP = true;
    1077             }
    1078             xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bOnlyIVP );
    1079 #else
    1080655            xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
    1081 #endif
    1082 
    1083 #if KWU_RC_MADPRED_E0227
    1084             if ( uiDepth <= m_addSADDepth )
    1085             {
    1086               m_LCUPredictionSAD += m_spatialSAD;
    1087               m_addSADDepth = uiDepth;
    1088             }
    1089 #endif
     656
    1090657
    1091658            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1092659            if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
    1093660            {
    1094 #if H_3D_QTLPC //Try IntraNxN
    1095               if(bTrySplit)
    1096               {
    1097 #endif
    1098661                if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) )
    1099662                {
    1100 #if HHI_DMM4_ENC_I0066
    1101                   xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN, bOnlyIVP );
    1102 #else
    1103663                  xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN   );
    1104 #endif
    1105664                  rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1106665                }
    1107 #if H_3D_QTLPC
    1108               }
    1109 #endif
    1110666            }
    1111667          }
     
    1117673          UInt uiRawBits = (2 * g_bitDepthY + g_bitDepthC) * rpcBestCU->getWidth(0) * rpcBestCU->getHeight(0) / 2;
    1118674          UInt uiBestBits = rpcBestCU->getTotalBits();
    1119 #if H_3D_VSO // M7
    1120           Double dRDCostTemp = m_pcRdCost->getUseVSO() ? m_pcRdCost->calcRdCostVSO(uiRawBits, 0) : m_pcRdCost->calcRdCost(uiRawBits, 0);
    1121           if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > dRDCostTemp ))
    1122 #else
    1123675          if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > m_pcRdCost->calcRdCost(uiRawBits, 0)))
    1124 #endif
    1125676          {
    1126677            xCheckIntraPCM (rpcBestCU, rpcTempCU);
     
    1128679          }
    1129680        }
    1130 #if  H_3D_FAST_TEXTURE_ENCODING
    1131         }
    1132 #endif
    1133681        if (bIsLosslessMode)
    1134682        {
     
    1142690    rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits
    1143691      rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    1144     #if H_3D_VSO // M8
    1145     if ( m_pcRdCost->getUseVSO() )   
    1146       rpcBestCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() );   
    1147     else
    1148 #endif
    1149692    rpcBestCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() );
    1150693
     
    1158701      bSubBranch = true;
    1159702    }
    1160 #if  H_3D_FAST_TEXTURE_ENCODING
    1161     if(rpcBestCU->getSlice()->getViewIndex() && !rpcBestCU->getSlice()->getIsDepth() && (uiDepth >=iIVFMaxD) && rpcBestCU->isSkipped(0))
    1162     {
    1163       bSubBranch = false;
    1164     }
    1165 #endif
    1166703  }
    1167704  else if(!(bSliceEnd && bInsidePicture))
     
    1217754
    1218755    // further split
    1219 #if H_3D_QTLPC
    1220     if( bSubBranch && bTrySplitDQP && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth )
    1221 #else
    1222756    if( bSubBranch && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth )
    1223 #endif
    1224     {
    1225 #if H_3D_VSO // M9
    1226       // reset Model
    1227       if( m_pcRdCost->getUseRenModel() )
    1228       {
    1229         UInt  uiWidth     = m_ppcOrigYuv[uiDepth]->getWidth ( );
    1230         UInt  uiHeight    = m_ppcOrigYuv[uiDepth]->getHeight( );
    1231         Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getLumaAddr( 0 );
    1232         UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride();
    1233         m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1234       }
    1235 #endif
     757    {
    1236758
    1237759      UChar       uhNextDepth         = uiDepth+1;
     
    1287809          rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    1288810        }
    1289 #if H_3D_VSO // M10
    1290       if ( m_pcRdCost->getUseVSO() )
    1291         rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    1292       else
    1293 #endif
    1294811      rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    1295812
     
    1323840          rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits
    1324841            rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    1325 #if H_3D_VSO // M11
    1326           if ( m_pcRdCost->getUseLambdaScaleVSO())         
    1327             rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );         
    1328           else
    1329 #endif
    1330842          rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    1331843#endif
     
    1354866    }
    1355867
    1356 #if H_3D_VSO // M12
    1357   if( m_pcRdCost->getUseRenModel() )
    1358   {
    1359     UInt  uiWidth     = m_ppcRecoYuvBest[uiDepth]->getWidth   ( );
    1360     UInt  uiHeight    = m_ppcRecoYuvBest[uiDepth]->getHeight  ( );
    1361     Pel*  piSrc       = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 );
    1362     UInt  uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride  ( );
    1363     m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1364   }
    1365 #endif
    1366868  rpcBestCU->copyToPic(uiDepth);                                                     // Copy Best data to Picture for next partition prediction.
    1367869
     
    15811083#endif
    15821084    m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx );
    1583 #if H_3D_ARP
    1584     m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx );
    1585 #endif
    1586 #if H_3D_IC
    1587     m_pcEntropyCoder->encodeICFlag  ( pcCU, uiAbsPartIdx );
    1588 #endif
    15891085    finishCU(pcCU,uiAbsPartIdx,uiDepth);
    15901086    return;
    15911087  }
    1592 #if MTK_SINGLE_DEPTH_MODE_I0095
    1593   m_pcEntropyCoder->encodeSingleDepthMode( pcCU, uiAbsPartIdx );
    1594   if(!pcCU->getSingleDepthFlag(uiAbsPartIdx))
    1595   {
    1596 #endif
    15971088  m_pcEntropyCoder->encodePredMode( pcCU, uiAbsPartIdx );
    15981089 
    15991090  m_pcEntropyCoder->encodePartSize( pcCU, uiAbsPartIdx, uiDepth );
    16001091 
    1601 #if H_3D_DIM_SDC
    1602   m_pcEntropyCoder->encodeSDCFlag( pcCU, uiAbsPartIdx, false );
    1603 #endif
    16041092  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
    16051093  {
     
    16171105  m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx );
    16181106
    1619 #if H_3D_ARP
    1620   m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx );
    1621 #endif
    1622 #if H_3D_IC
    1623   m_pcEntropyCoder->encodeICFlag  ( pcCU, uiAbsPartIdx );
    1624 #endif
    16251107  // Encode Coefficients
    16261108  Bool bCodeDQP = getdQPFlag();
    16271109  m_pcEntropyCoder->encodeCoeff( pcCU, uiAbsPartIdx, uiDepth, pcCU->getWidth (uiAbsPartIdx), pcCU->getHeight(uiAbsPartIdx), bCodeDQP );
    16281110  setdQPFlag( bCodeDQP );
    1629 #if MTK_SINGLE_DEPTH_MODE_I0095
    1630   }
    1631 #endif
    16321111  // --- write terminating bit ---
    16331112  finishCU(pcCU,uiAbsPartIdx,uiDepth);
     
    17571236{
    17581237  assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE );
    1759 #if H_3D_IV_MERGE
    1760   TComMvField  cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    1761   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
    1762 #else
    17631238  TComMvField  cMvFieldNeighbours[2 * MRG_MAX_NUM_CANDS]; // double length for mv of both lists
    17641239  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    1765 #endif
    17661240  Int numValidMergeCand = 0;
    17671241  const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0);
     
    17721246  }
    17731247  UChar uhDepth = rpcTempCU->getDepth( 0 );
    1774 #if H_3D_IC
    1775   Bool bICFlag = rpcTempCU->getICFlag( 0 );
    1776 #endif
    1777 #if H_3D_VSO // M1  //nececcary here?
    1778   if( m_pcRdCost->getUseRenModel() )
    1779   {
    1780     UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( );
    1781     UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( );
    1782     Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
    1783     UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
    1784     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    1785   }
    1786 #endif
    1787 
    1788 #if H_3D_ARP
    1789   DisInfo cOrigDisInfo = rpcTempCU->getDvInfo(0);
    1790 #else
     1248
    17911249  rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
    1792 #endif
    1793 
    1794 #if H_3D_VSP
    1795 #if !H_3D_ARP
    1796   Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    1797   memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    1798   InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
    1799   rpcTempCU->m_bAvailableFlagA1 = 0;
    1800   rpcTempCU->m_bAvailableFlagB1 = 0;
    1801   rpcTempCU->m_bAvailableFlagB0 = 0;
    1802   rpcTempCU->m_bAvailableFlagA0 = 0;
    1803   rpcTempCU->m_bAvailableFlagB2 = 0;
    1804   rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    1805   rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag,inheritedVSPDisInfo, numValidMergeCand );
    1806 #endif
    1807 #else
    1808 #if H_3D
    1809   rpcTempCU->m_bAvailableFlagA1 = 0;
    1810   rpcTempCU->m_bAvailableFlagB1 = 0;
    1811   rpcTempCU->m_bAvailableFlagB0 = 0;
    1812   rpcTempCU->m_bAvailableFlagA0 = 0;
    1813   rpcTempCU->m_bAvailableFlagB2 = 0;
    1814   rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    1815   rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
    1816 #else
     1250
    18171251  rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
    1818 #endif
    1819 #endif
    1820 
    1821 #if H_3D_IV_MERGE
    1822   Int mergeCandBuffer[MRG_MAX_NUM_CANDS_MEM];
    1823 #else
     1252
    18241253  Int mergeCandBuffer[MRG_MAX_NUM_CANDS];
    1825 #endif
    1826 #if H_3D_ARP
    1827 for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
    1828 #else
    18291254for( UInt ui = 0; ui < numValidMergeCand; ++ui )
    1830 #endif
    18311255  {
    18321256    mergeCandBuffer[ui] = 0;
     
    18451269  }
    18461270
    1847 #if H_3D_ARP
    1848   Int nARPWMax = rpcTempCU->getSlice()->getARPStepNum() - 1;
    1849   if( nARPWMax < 0 || !rpcTempCU->getDvInfo(0).bDV || bICFlag )
    1850   {
    1851     nARPWMax = 0;
    1852   }
    1853   for( Int nARPW=nARPWMax; nARPW >= 0 ; nARPW-- )
    1854   {
    1855     memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS_MEM*sizeof(Int) );
    1856     rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
    1857     rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
    1858 #if H_3D_IC
    1859     rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth );
    1860 #endif
    1861     rpcTempCU->getDvInfo(0) = cOrigDisInfo;
    1862     rpcTempCU->setDvInfoSubParts(cOrigDisInfo, 0, 0, uhDepth );
    1863     Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    1864     memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    1865 #if !FIX_TICKET_79
    1866     InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
    1867 #endif
    1868 #if H_3D_SPIVMP
    1869     Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
    1870     memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    1871     TComMvField*  pcMvFieldSP;
    1872     UChar* puhInterDirSP;
    1873     pcMvFieldSP = new TComMvField[rpcTempCU->getPic()->getPicSym()->getNumPartition()*2];
    1874     puhInterDirSP = new UChar[rpcTempCU->getPic()->getPicSym()->getNumPartition()];
    1875 #endif
    1876 #if H_3D
    1877     rpcTempCU->initAvailableFlags();
    1878     rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    1879     rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
    1880 #if !FIX_TICKET_79
    1881       , inheritedVSPDisInfo
    1882 #endif
    1883 #if H_3D_SPIVMP
    1884       , pcMvFieldSP, puhInterDirSP
    1885 #endif
    1886       , numValidMergeCand
    1887       );
    1888 
    1889     rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours, vspFlag
    1890 #if H_3D_SPIVMP
    1891       , bSPIVMPFlag
    1892 #endif
    1893       , numValidMergeCand
    1894       );
    1895 
    1896 #else
    1897 #if FIX_TICKET_79
    1898     rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag, numValidMergeCand );
    1899 #else
    1900     rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand );
    1901 #endif
    1902 #endif
    1903 
    1904 
    1905 #endif
    1906 
    1907 #if H_3D_DDD
    1908     Int iDDDCand = rpcTempCU->getUseDDDCandIdx();
    1909     UChar ucDDDepth = rpcTempCU->getDDTmpDepth();
    1910     rpcTempCU->setUseDDD( false, 0, uhDepth );
    1911 #endif
     1271
    19121272
    19131273  for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual )
     
    19151275    for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
    19161276    {     
    1917 #if H_3D_IC
    1918         if( rpcTempCU->getSlice()->getApplyIC() && rpcTempCU->getSlice()->getIcSkipParseFlag() )
    1919         {
    1920           if( bICFlag && uiMergeCand == 0 )
    1921           {
    1922             continue;
    1923           }
    1924         }
    1925 #endif
    19261277        if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1))
    19271278        {
     
    19321283          rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag,     0, uhDepth );
    19331284          rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
    1934 #if H_3D_IC
    1935           rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth );
    1936 #endif
    1937 #if H_3D_ARP
    1938           rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
    1939 #endif
    19401285          rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level
    19411286          rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to LCU level
    1942 #if H_3D_VSP
    1943           rpcTempCU->setVSPFlagSubParts( vspFlag[uiMergeCand], 0, 0, uhDepth );
    1944 #if !FIX_TICKET_79
    1945           rpcTempCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeCand].m_acDvInfo, 0, 0, uhDepth );
    1946 #endif
    1947 #endif
    1948 #if H_3D_DDD
    1949           if( rpcTempCU->getSlice()->getIsDepth() && rpcTempCU->getSlice()->getViewIndex() != 0 && iDDDCand == uiMergeCand )
    1950           {
    1951               rpcTempCU->setUseDDD( true, 0, 0, uhDepth );
    1952               rpcTempCU->setDDDepthSubParts( ucDDDepth, 0, 0, uhDepth );
    1953           }
    1954           else
    1955           {
    1956               rpcTempCU->setUseDDD( false, 0, 0, uhDepth );
    1957           }
    1958 #endif
    1959 #if H_3D_SPIVMP
    1960           rpcTempCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeCand], 0, 0, uhDepth);
    1961           if (bSPIVMPFlag[uiMergeCand])
    1962           {
    1963             UInt uiSPAddr;
    1964             Int iWidth = rpcTempCU->getWidth(0);
    1965             Int iHeight = rpcTempCU->getHeight(0);
    1966             Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    1967             rpcTempCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    1968             for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    1969             {
    1970               rpcTempCU->getSPAbsPartIdx(0, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
    1971               rpcTempCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
    1972               rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(rpcTempCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
    1973               rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(rpcTempCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
    1974             }
    1975           }
    1976           else
    1977 #endif
    1978 #if H_3D_VSP
    1979           {
    1980           if ( vspFlag[uiMergeCand] )
    1981           {
    1982             UInt partAddr;
    1983             Int vspSize;
    1984             Int width, height;
    1985             rpcTempCU->getPartIndexAndSize( 0, partAddr, width, height );
    1986             if( uhInterDirNeighbours[ uiMergeCand ] & 0x01 )
    1987             {
    1988               rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_0, cMvFieldNeighbours[ 2*uiMergeCand + 0 ].getRefIdx(), vspSize );
    1989               rpcTempCU->setVSPFlag( partAddr, vspSize );
    1990             }
    1991             else
    1992             {
    1993               rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    1994             }
    1995             if( uhInterDirNeighbours[ uiMergeCand ] & 0x02 )
    1996             {
    1997               rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_1 , cMvFieldNeighbours[ 2*uiMergeCand + 1 ].getRefIdx(), vspSize );
    1998               rpcTempCU->setVSPFlag( partAddr, vspSize );
    1999             }
    2000             else
    2001             {
    2002               rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    2003             }
    2004             rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
    2005           }
    2006           else
    2007           {
    2008 #endif
    20091287            rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
    20101288            rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    20111289            rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    2012 #if H_3D_VSP
    2013           }
    2014         }
    2015 #endif
    20161290       // do MC
    20171291       m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
    20181292       // estimate residual and encode everything
    2019 #if H_3D_VSO //M2
    2020        if( m_pcRdCost->getUseRenModel() )
    2021        { //Reset
    2022          UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ();
    2023          UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ();
    2024          Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr ();
    2025          UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ();
    2026          m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2027        }
    2028 #endif
    20291293       m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU,
    20301294         m_ppcOrigYuv    [uhDepth],
     
    20431307
    20441308          rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth );
    2045 #if MTK_SINGLE_DEPTH_MODE_I0095
    2046           rpcTempCU->setSingleDepthFlagSubParts( false, 0, uhDepth );
    2047 #endif
    2048 #if H_3D_VSP // possible bug fix
    2049           if( rpcTempCU->getSkipFlag(0) )
    2050           {
    2051             rpcTempCU->setTrIdxSubParts(0, 0, uhDepth);
    2052           }
    2053 #endif
    2054 #if H_3D_INTER_SDC
    2055           TComDataCU *rpcTempCUPre = rpcTempCU;
    2056 #endif
    20571309          Int orgQP = rpcTempCU->getQP( 0 );
    20581310          xCheckDQP( rpcTempCU );
    20591311          xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
    2060 #if H_3D_INTER_SDC
    2061           if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() && !uiNoResidual )
    2062           {
    2063 #if FAST_SDC_OFFSET_DECISION_I0084
    2064             Double dOffsetCost[3] = {MAX_DOUBLE,MAX_DOUBLE,MAX_DOUBLE};
    2065             for( Int uiOffest = 1 ; uiOffest <= 5 ; uiOffest++ )
    2066 #else
    2067             for( Int uiOffest = -2 ; uiOffest <= 2 ; uiOffest++ )
    2068 #endif
    2069             {
    2070 #if FAST_SDC_OFFSET_DECISION_I0084
    2071               if( uiOffest > 3)
    2072               {
    2073                 if ( dOffsetCost[0] < (0.9*dOffsetCost[1]) && dOffsetCost[0] < (0.9*dOffsetCost[2]) )
    2074                 {
    2075                   continue;
    2076                 }
    2077                 if ( dOffsetCost[1] < dOffsetCost[0] && dOffsetCost[0] < dOffsetCost[2] &&  uiOffest == 5)
    2078                 {
    2079                   continue;
    2080                 }
    2081                 if ( dOffsetCost[0] < dOffsetCost[1] && dOffsetCost[2] < dOffsetCost[0] &&  uiOffest == 4)
    2082                 {
    2083                   continue;
    2084                 }
    2085               }
    2086 #endif
    2087               if( rpcTempCU != rpcTempCUPre )
    2088               {
    2089                 rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag  );
    2090                 rpcTempCU->copyPartFrom( rpcBestCU, 0, uhDepth );
    2091               }
    2092               rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
    2093 #if MTK_SINGLE_DEPTH_MODE_I0095
    2094               rpcTempCU->setSingleDepthFlagSubParts( false, 0, uhDepth );
    2095 #endif
    2096               rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth );
    2097               rpcTempCU->setCbfSubParts( 1, 1, 1, 0, uhDepth );
    2098 #if H_3D_VSO //M2
    2099               if( m_pcRdCost->getUseRenModel() )
    2100               { //Reset
    2101                 UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ();
    2102                 UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ();
    2103                 Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr ();
    2104                 UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ();
    2105                 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2106               }
    2107 #endif
    2108 #if FAST_SDC_OFFSET_DECISION_I0084
    2109               Int iSdcOffset = 0;
    2110               if(uiOffest % 2 == 0)
    2111               {
    2112                 iSdcOffset = uiOffest >> 1;
    2113               }
    2114               else
    2115               {
    2116                 iSdcOffset = -1 * (uiOffest >> 1);
    2117               }
    2118               m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU,
    2119                 m_ppcOrigYuv[uhDepth],
    2120                 ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth],
    2121                 m_ppcResiYuvTemp[uhDepth],
    2122                 m_ppcRecoYuvTemp[uhDepth],
    2123                 iSdcOffset,
    2124                 uhDepth );
    2125               if (uiOffest <= 3 )
    2126               {
    2127                 dOffsetCost [uiOffest -1] = rpcTempCU->getTotalCost();
    2128               }
    2129 #else
    2130               m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU,
    2131                 m_ppcOrigYuv[uhDepth],
    2132                 ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth],
    2133                 m_ppcResiYuvTemp[uhDepth],
    2134                 m_ppcRecoYuvTemp[uhDepth],
    2135                 uiOffest,
    2136                 uhDepth );
    2137 #endif
    2138 
    2139               xCheckDQP( rpcTempCU );
    2140               xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth );
    2141             }
    2142           }
    2143 #endif
    21441312          rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag );
    21451313
    21461314      if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
    21471315      {
    2148 #if H_3D_INTER_SDC
    2149         if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) )
    2150         {
    2151           bestIsSkip = !rpcBestCU->getSDCFlag( 0 ) && ( rpcBestCU->getQtRootCbf(0) == 0 );
    2152         }
    2153         else
    2154         {
    2155 #endif
    21561316        bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0;
    2157 #if H_3D_INTER_SDC
    2158         }
    2159 #endif
    21601317      }
    21611318    }
     
    21931350  }
    21941351 }
    2195 #if H_3D_SPIVMP
    2196  delete[] pcMvFieldSP;
    2197  delete[] puhInterDirSP;
    2198 #endif
    2199 #if H_3D_ARP
    2200  }
    2201 #endif
    22021352}
    22031353
    22041354
    22051355#if AMP_MRG
    2206 #if  H_3D_FAST_TEXTURE_ENCODING
    2207 Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bFMD, Bool bUseMRG)
    2208 #else
    22091356Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bUseMRG)
    2210 #endif
    22111357#else
    22121358Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize )
     
    22141360{
    22151361
    2216 #if H_3D
    2217   const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0);
    2218 #endif
    2219 #if  H_3D_FAST_TEXTURE_ENCODING
    2220   if(!(bFMD && (ePartSize == SIZE_2Nx2N)))  //have  motion estimation or merge check
    2221   {
    2222 #endif
    22231362  UChar uhDepth = rpcTempCU->getDepth( 0 );
    2224 #if H_3D_ARP
    2225   Int iLayerId    = rpcTempCU->getSlice()->getLayerId();
    2226   Bool bFirstTime = true;
    2227   Int nARPWMax    = rpcTempCU->getSlice()->getARPStepNum() - 1;
    2228 
    2229   if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N || !rpcTempCU->getDvInfo(0).bDV || rpcTempCU->getICFlag(0) )
    2230   {
    2231     nARPWMax = 0;
    2232   }
    2233 
    2234   for( Int nARPW = 0; nARPW <= nARPWMax; nARPW++ )
    2235   {
    2236     if( bFirstTime == false && rpcTempCU->getSlice()->getVPS()->getUseAdvRP( iLayerId ) )
    2237     {
    2238       rpcTempCU->initEstData( rpcTempCU->getDepth(0), rpcTempCU->getQP(0),bTransquantBypassFlag );     
    2239     }
    2240 #endif
    2241 #if H_3D_VSO // M3
    2242   if( m_pcRdCost->getUseRenModel() )
    2243   {
    2244     UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( );
    2245     UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( );
    2246     Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
    2247     UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
    2248     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2249   }
    2250 #endif
    22511363
    22521364  rpcTempCU->setDepthSubParts( uhDepth, 0 );
    22531365 
    22541366  rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
    2255 #if MTK_SINGLE_DEPTH_MODE_I0095
    2256   rpcTempCU->setSingleDepthFlagSubParts( false, 0, uhDepth );
    2257 #endif
    22581367  rpcTempCU->setPartSizeSubParts  ( ePartSize,  0, uhDepth );
    22591368  rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
    2260 #if H_3D_DDD
    2261   rpcTempCU->setUseDDD( false, 0, uhDepth );
    2262 #endif
    2263 
    2264 #if H_3D_ARP
    2265   rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
    2266 #endif
    2267 
    2268 #if H_3D_ARP
    2269   if( bFirstTime == false && nARPWMax )
    2270   {
    2271     rpcTempCU->copyPartFrom( m_ppcWeightedTempCU[uhDepth] , 0 , uhDepth );
    2272     rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
    2273 
    2274     m_pcPredSearch->motionCompensation( rpcTempCU , m_ppcPredYuvTemp[uhDepth] );
    2275   }
    2276   else
    2277   {
    2278     bFirstTime = false;
    2279 #endif
     1369
     1370
    22801371#if AMP_MRG
    22811372  rpcTempCU->setMergeAMP (true);
    2282 #if  H_3D_FAST_TEXTURE_ENCODING
    2283   m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bFMD, false, bUseMRG );
    2284 #else
    22851373  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], false, bUseMRG );
    2286 #endif
    22871374#else 
    22881375  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
    22891376#endif
    2290 #if H_3D_ARP
    2291    if( nARPWMax )
    2292    {
    2293      m_ppcWeightedTempCU[uhDepth]->copyPartFrom( rpcTempCU , 0 , uhDepth );
    2294    }
    2295   }
    2296 #endif
    22971377
    22981378#if AMP_MRG
    22991379  if ( !rpcTempCU->getMergeAMP() )
    23001380  {
    2301 #if H_3D_ARP
    2302     if( nARPWMax )
    2303     {
    2304       continue;
    2305     }
    2306     else
    2307 #endif
    23081381    return;
    23091382  }
    23101383#endif
    23111384
    2312 #if KWU_RC_MADPRED_E0227
    2313   if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth )
    2314   {
    2315     UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(),
    2316       m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(),
    2317       rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) );
    2318     m_temporalSAD = (Int)SAD;
    2319   }
    2320 #endif
    23211385  m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false );
    2322 #if H_3D_VSP // possible bug fix
    2323   if( rpcTempCU->getQtRootCbf(0)==0 )
    2324   {
    2325     rpcTempCU->setTrIdxSubParts(0, 0, uhDepth);
    2326   }
    2327 #endif
    2328 
    2329 #if H_3D_VSO // M4
    2330   if( m_pcRdCost->getUseLambdaScaleVSO() )
    2331     rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    2332   else
    2333 #endif
     1386
    23341387
    23351388  rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    2336 #if H_3D_INTER_SDC
    2337   TComDataCU *rpcTempCUPre = rpcTempCU;
    2338 #endif
    23391389  xCheckDQP( rpcTempCU );
    23401390  xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
    2341 #if H_3D_INTER_SDC
    2342   if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() && ePartSize == SIZE_2Nx2N)
    2343   {
    2344 #if FAST_SDC_OFFSET_DECISION_I0084
    2345     Double dOffsetCost[3] = {MAX_DOUBLE,MAX_DOUBLE,MAX_DOUBLE};
    2346     for( Int uiOffest = 1 ; uiOffest <= 5 ; uiOffest++ )
    2347 #else
    2348     for( Int uiOffest = -2 ; uiOffest <= 2 ; uiOffest++ )
    2349 #endif
    2350     {
    2351 #if FAST_SDC_OFFSET_DECISION_I0084
    2352       if( uiOffest > 3)
    2353       {
    2354         if ( dOffsetCost[0] < (0.9*dOffsetCost[1]) && dOffsetCost[0] < (0.9*dOffsetCost[2]) )
    2355         {
    2356           continue;
    2357         }
    2358         if ( dOffsetCost[1] < dOffsetCost[0] && dOffsetCost[0] < dOffsetCost[2] &&  uiOffest == 5)
    2359         {
    2360           continue;
    2361         }
    2362         if ( dOffsetCost[0] < dOffsetCost[1] && dOffsetCost[2] < dOffsetCost[0] &&  uiOffest == 4)
    2363         {
    2364           continue;
    2365         }
    2366       }
    2367 #endif
    2368       if( rpcTempCU != rpcTempCUPre )
    2369       {
    2370         Int orgQP = rpcBestCU->getQP( 0 );
    2371         rpcTempCU->initEstData( uhDepth, orgQP ,bTransquantBypassFlag );     
    2372         rpcTempCU->copyPartFrom( rpcBestCU, 0, uhDepth );
    2373       }
    2374       rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
    2375 #if MTK_SINGLE_DEPTH_MODE_I0095
    2376       rpcTempCU->setSingleDepthFlagSubParts( false, 0, uhDepth );
    2377 #endif
    2378       rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth );
    2379       rpcTempCU->setCbfSubParts( 1, 1, 1, 0, uhDepth );
    2380 #if H_3D_VSO // M3
    2381       if( m_pcRdCost->getUseRenModel() )
    2382       {
    2383         UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( );
    2384         UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( );
    2385         Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
    2386         UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
    2387         m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2388       }
    2389 #endif
    2390 
    2391 #if FAST_SDC_OFFSET_DECISION_I0084
    2392       Int iSdcOffset = 0;
    2393       if(uiOffest % 2 == 0)
    2394       {
    2395         iSdcOffset = uiOffest >> 1;
    2396       }
    2397       else
    2398       {
    2399         iSdcOffset = -1 * (uiOffest >> 1);
    2400       }
    2401       m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU,
    2402         m_ppcOrigYuv[uhDepth],
    2403         ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth],
    2404         m_ppcResiYuvTemp[uhDepth],
    2405         m_ppcRecoYuvTemp[uhDepth],
    2406         iSdcOffset,
    2407         uhDepth );
    2408       if (uiOffest <= 3 )
    2409       {
    2410         dOffsetCost [uiOffest -1] = rpcTempCU->getTotalCost();
    2411       }
    2412 #else
    2413       m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU,
    2414         m_ppcOrigYuv[uhDepth],
    2415         ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth],
    2416         m_ppcResiYuvTemp[uhDepth],
    2417         m_ppcRecoYuvTemp[uhDepth],
    2418         uiOffest,
    2419         uhDepth );
    2420 #endif
    2421 
    2422       xCheckDQP( rpcTempCU );
    2423       xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
    2424     }
    2425 
    2426   }
    2427 #endif
    2428 #if H_3D_ARP
    2429   }
    2430 #endif
    2431 #if  H_3D_FAST_TEXTURE_ENCODING
    2432   }
    2433 #endif
    2434 }
    2435 
    2436 #if H_3D_DBBP
    2437 Void TEncCu::xInvalidateOriginalSegments( TComYuv* pOrigYuv, TComYuv* pOrigYuvTemp, Bool* pMask, UInt uiValidSegment )
    2438 {
    2439   UInt  uiWidth     = pOrigYuv->getWidth ( );
    2440   UInt  uiHeight    = pOrigYuv->getHeight( );
    2441   Pel*  piSrc       = pOrigYuv->getLumaAddr( );
    2442   UInt  uiSrcStride = pOrigYuv->getStride();
    2443   Pel*  piDst       = pOrigYuvTemp->getLumaAddr( );
    2444   UInt  uiDstStride = pOrigYuvTemp->getStride();
    2445  
    2446   UInt  uiMaskStride= MAX_CU_SIZE;
    2447  
    2448   AOF( uiWidth == uiHeight );
    2449  
    2450   // backup pointer
    2451   Bool* pMaskStart = pMask;
    2452  
    2453   for (Int y=0; y<uiHeight; y++)
    2454   {
    2455     for (Int x=0; x<uiWidth; x++)
    2456     {
    2457       UChar ucSegment = (UChar)pMask[x];
    2458       AOF( ucSegment < 2 );
    2459      
    2460       piDst[x] = (ucSegment==uiValidSegment)?piSrc[x]:DBBP_INVALID_SHORT;
    2461     }
    2462    
    2463     piSrc  += uiSrcStride;
    2464     piDst  += uiDstStride;
    2465     pMask  += uiMaskStride;
    2466   }
    2467  
    2468   // now invalidate chroma
    2469   Pel*  piSrcU       = pOrigYuv->getCbAddr();
    2470   Pel*  piSrcV       = pOrigYuv->getCrAddr();
    2471   UInt  uiSrcStrideC = pOrigYuv->getCStride();
    2472   Pel*  piDstU       = pOrigYuvTemp->getCbAddr( );
    2473   Pel*  piDstV       = pOrigYuvTemp->getCrAddr( );
    2474   UInt  uiDstStrideC = pOrigYuvTemp->getCStride();
    2475   pMask = pMaskStart;
    2476  
    2477   for (Int y=0; y<uiHeight/2; y++)
    2478   {
    2479     for (Int x=0; x<uiWidth/2; x++)
    2480     {
    2481       UChar ucSegment = (UChar)pMask[x*2];
    2482       AOF( ucSegment < 2 );
    2483      
    2484       piDstU[x] = (ucSegment==uiValidSegment)?piSrcU[x]:DBBP_INVALID_SHORT;
    2485       piDstV[x] = (ucSegment==uiValidSegment)?piSrcV[x]:DBBP_INVALID_SHORT;
    2486     }
    2487    
    2488     piSrcU  += uiSrcStrideC;
    2489     piSrcV  += uiSrcStrideC;
    2490     piDstU  += uiDstStrideC;
    2491     piDstV  += uiDstStrideC;
    2492     pMask   += 2*uiMaskStride;
    2493   }
    2494 }
    2495 #if MTK_SINGLE_DEPTH_MODE_I0095
    2496 Void TEncCu::xCheckRDCostSingleDepth( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize )
     1391}
     1392
     1393
     1394Void TEncCu::xCheckRDCostIntra( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize )
    24971395{
    24981396  UInt uiDepth = rpcTempCU->getDepth( 0 );
    2499   if( !rpcBestCU->getSlice()->getIsDepth() || (eSize != SIZE_2Nx2N))
    2500   {
    2501     return;
    2502   }
    2503  
    2504 #if H_3D_VSO // M5
    2505   if( m_pcRdCost->getUseRenModel() )
    2506   {
    2507     UInt  uiWidth     = m_ppcOrigYuv[uiDepth]->getWidth   ();
    2508     UInt  uiHeight    = m_ppcOrigYuv[uiDepth]->getHeight  ();
    2509     Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getLumaAddr();
    2510     UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride  ();
    2511     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2512   }
    2513 #endif
     1397 
    25141398
    25151399  rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth );
    2516   rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
    2517   rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth );
    2518   rpcTempCU->setCUTransquantBypassSubParts( rpcTempCU->getCUTransquantBypass(0), 0, uiDepth );
    2519 
    2520   rpcTempCU->setTrIdxSubParts(0, 0, uiDepth);
    2521   rpcTempCU->setCbfSubParts(0, 1, 1, 0, uiDepth);
    2522   rpcTempCU->setSingleDepthFlagSubParts(true, 0, uiDepth);
    2523   rpcTempCU->setLumaIntraDirSubParts (DC_IDX, 0, uiDepth);
    2524 #if H_3D_DIM_SDC
    2525   rpcTempCU->setSDCFlagSubParts( false, 0, uiDepth);
    2526 #endif
    2527 
    2528   UInt uiPreCalcDistC;
    2529   m_pcPredSearch  ->estIntraPredSingleDepth      ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, false );
    2530 
    2531 
    2532   m_ppcRecoYuvTemp[uiDepth]->copyToPicLuma(rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU() );
    2533  
    2534  
    2535   m_pcEntropyCoder->resetBits();
    2536   if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
    2537   {
    2538     m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0,          true );
    2539   }
    2540   m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0,          true );
    2541   m_pcEntropyCoder->encodeSingleDepthMode( rpcTempCU, 0,          true );
    2542  
    2543 
    2544   m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
    2545  
    2546   rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
    2547   rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    2548 
    2549 
    2550 #if H_3D_VSO // M6
    2551   if( m_pcRdCost->getUseLambdaScaleVSO()) 
    2552     rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 
    2553   else
    2554 #endif
    2555   rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    2556  
    2557 
    2558   xCheckDQP( rpcTempCU );
    2559   xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth);
    2560 }
    2561 #endif
    2562 Void TEncCu::xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bUseMRG )
    2563 {
    2564   AOF( !rpcTempCU->getSlice()->getIsDepth() );
    2565  
    2566   UChar uhDepth = rpcTempCU->getDepth( 0 );
    2567  
    2568 #if H_3D_VSO
    2569   if( m_pcRdCost->getUseRenModel() )
    2570   {
    2571     UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( );
    2572     UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( );
    2573     Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
    2574     UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
    2575     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2576   }
    2577 #endif
    2578  
    2579   UInt uiWidth  = rpcTempCU->getWidth(0);
    2580   UInt uiHeight = rpcTempCU->getHeight(0);
    2581   AOF( uiWidth == uiHeight );
    2582  
    2583 #if SEC_DBBP_DISALLOW_8x8_I0078
    2584   if(uiWidth <= 8)
    2585   {
    2586     return;
    2587   }
    2588 #endif
    2589  
    2590   rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N,  0, uhDepth );
    2591  
    2592   // fetch virtual depth block
    2593   UInt uiDepthStride = 0;
    2594 #if LGE_FCO_I0116
    2595   Pel* pDepthPels = rpcTempCU->getVirtualDepthBlock(rpcTempCU->getZorderIdxInCU(), uiWidth, uiHeight, uiDepthStride);
    2596 #else
    2597   Pel* pDepthPels = rpcTempCU->getVirtualDepthBlock(0, uiWidth, uiHeight, uiDepthStride);
    2598 #endif
    2599   AOF( pDepthPels != NULL );
    2600   AOF( uiDepthStride != 0 );
    2601  
    2602   // derive partitioning from depth
    2603   PartSize eVirtualPartSize = m_pcPredSearch->getPartitionSizeFromDepth(pDepthPels, uiDepthStride, uiWidth);
    2604  
    2605   // derive segmentation mask from depth
    2606   Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE];
    2607   Bool bValidMask = m_pcPredSearch->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, uiWidth, uiHeight, pMask);
    2608  
    2609   if( !bValidMask )
    2610   {
    2611     return;
    2612   }
    2613  
    2614   // find optimal motion/disparity vector for each segment
    2615   DisInfo originalDvInfo = rpcTempCU->getDvInfo(0);
    2616   DBBPTmpData* pDBBPTmpData = rpcTempCU->getDBBPTmpData();
    2617   TComYuv* apPredYuv[2] = { m_ppcRecoYuvTemp[uhDepth], m_ppcPredYuvTemp[uhDepth] };
    2618  
    2619   // find optimal motion vector fields for both segments (as 2Nx2N)
    2620   rpcTempCU->setDepthSubParts( uhDepth, 0 );
    2621   rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N,  0, uhDepth );
    2622   rpcTempCU->setPredModeSubParts( MODE_INTER, 0, uhDepth );
    2623   for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
    2624   {
    2625     rpcTempCU->setDBBPFlagSubParts(true, 0, 0, uhDepth);
    2626     rpcTempCU->setDvInfoSubParts(originalDvInfo, 0, uhDepth);
    2627    
    2628     // invalidate all other segments in original YUV
    2629     xInvalidateOriginalSegments(m_ppcOrigYuv[uhDepth], m_ppcOrigYuvDBBP[uhDepth], pMask, uiSegment);
    2630    
    2631     // do motion estimation for this segment
    2632     m_pcRdCost->setUseMask(true);
    2633     rpcTempCU->getDBBPTmpData()->eVirtualPartSize = eVirtualPartSize;
    2634     rpcTempCU->getDBBPTmpData()->uiVirtualPartIndex = uiSegment;
    2635     m_pcPredSearch->predInterSearch( rpcTempCU, m_ppcOrigYuvDBBP[uhDepth], apPredYuv[uiSegment], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], false, false, bUseMRG );
    2636     m_pcRdCost->setUseMask(false);
    2637    
    2638     // extract motion parameters of full block for this segment
    2639     pDBBPTmpData->auhInterDir[uiSegment] = rpcTempCU->getInterDir(0);
    2640    
    2641     pDBBPTmpData->abMergeFlag[uiSegment] = rpcTempCU->getMergeFlag(0);
    2642     pDBBPTmpData->auhMergeIndex[uiSegment] = rpcTempCU->getMergeIndex(0);
    2643    
    2644     AOF( rpcTempCU->getSPIVMPFlag(0) == false );
    2645     AOF( rpcTempCU->getVSPFlag(0) == 0 );
    2646    
    2647     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    2648     {
    2649       RefPicList eRefList = (RefPicList)uiRefListIdx;
    2650      
    2651       pDBBPTmpData->acMvd[uiSegment][eRefList] = rpcTempCU->getCUMvField(eRefList)->getMvd(0);
    2652       pDBBPTmpData->aiMvpNum[uiSegment][eRefList] = rpcTempCU->getMVPNum(eRefList, 0);
    2653       pDBBPTmpData->aiMvpIdx[uiSegment][eRefList] = rpcTempCU->getMVPIdx(eRefList, 0);
    2654      
    2655       rpcTempCU->getMvField(rpcTempCU, 0, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]);
    2656     }
    2657   }
    2658  
    2659   // store final motion/disparity information in each PU using derived partitioning
    2660   rpcTempCU->setDepthSubParts( uhDepth, 0 );
    2661   rpcTempCU->setPartSizeSubParts  ( eVirtualPartSize,  0, uhDepth );
    2662   rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
    2663  
    2664   UInt uiPUOffset = ( g_auiPUOffset[UInt( eVirtualPartSize )] << ( ( rpcTempCU->getSlice()->getSPS()->getMaxCUDepth() - uhDepth ) << 1 ) ) >> 4;
    2665   for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
    2666   {
    2667     UInt uiPartAddr = uiSegment*uiPUOffset;
    2668    
    2669     rpcTempCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uhDepth);
    2670    
    2671     // now set stored information from 2Nx2N motion search to each partition
    2672     rpcTempCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uhDepth); // interprets depth relative to LCU level
    2673    
    2674     rpcTempCU->setMergeFlagSubParts(pDBBPTmpData->abMergeFlag[uiSegment], uiPartAddr, uiSegment, uhDepth);
    2675     rpcTempCU->setMergeIndexSubParts(pDBBPTmpData->auhMergeIndex[uiSegment], uiPartAddr, uiSegment, uhDepth);
    2676        
    2677     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    2678     {
    2679       RefPicList eRefList = (RefPicList)uiRefListIdx;
    2680      
    2681       rpcTempCU->getCUMvField( eRefList )->setAllMvd(pDBBPTmpData->acMvd[uiSegment][eRefList], eVirtualPartSize, uiPartAddr, 0, uiSegment);
    2682       rpcTempCU->setMVPNum(eRefList, uiPartAddr, pDBBPTmpData->aiMvpNum[uiSegment][eRefList]);
    2683       rpcTempCU->setMVPIdx(eRefList, uiPartAddr, pDBBPTmpData->aiMvpIdx[uiSegment][eRefList]);
    2684      
    2685       rpcTempCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], eVirtualPartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level
    2686     }
    2687   }
    2688  
    2689   // reconstruct final prediction signal by combining both segments
    2690 #if SHARP_DBBP_SIMPLE_FLTER_I0109
    2691   m_pcPredSearch->combineSegmentsWithMask(apPredYuv, m_ppcPredYuvTemp[uhDepth], pMask, uiWidth, uiHeight, 0, eVirtualPartSize);
    2692 #else
    2693   m_pcPredSearch->combineSegmentsWithMask(apPredYuv, m_ppcPredYuvTemp[uhDepth], pMask, uiWidth, uiHeight);
    2694 #endif
    2695  
    2696   m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false );
    2697  
    2698   xCheckDQP( rpcTempCU );
    2699   xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
    2700 }
    2701 #endif
    2702 
    2703 #if HHI_DMM4_ENC_I0066
    2704 Void TEncCu::xCheckRDCostIntra( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize, Bool bOnlyIVP )
    2705 #else
    2706 Void TEncCu::xCheckRDCostIntra( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize )
    2707 #endif
    2708 {
    2709   UInt uiDepth = rpcTempCU->getDepth( 0 );
    2710  
    2711 #if H_3D_VSO // M5
    2712   if( m_pcRdCost->getUseRenModel() )
    2713   {
    2714     UInt  uiWidth     = m_ppcOrigYuv[uiDepth]->getWidth   ();
    2715     UInt  uiHeight    = m_ppcOrigYuv[uiDepth]->getHeight  ();
    2716     Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getLumaAddr();
    2717     UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride  ();
    2718     m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    2719   }
    2720 #endif
    2721 
    2722   rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth );
    2723 #if MTK_SINGLE_DEPTH_MODE_I0095
    2724   rpcTempCU->setSingleDepthFlagSubParts( false, 0, uiDepth );
    2725 #endif
    27261400  rpcTempCU->setPartSizeSubParts( eSize, 0, uiDepth );
    27271401  rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth );
     
    27331407    m_pcPredSearch->preestChromaPredMode( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth] );
    27341408  }
    2735 #if HHI_DMM4_ENC_I0066
    2736   m_pcPredSearch  ->estIntraPredQT      ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, bSeparateLumaChroma, bOnlyIVP );
    2737 #else
    27381409  m_pcPredSearch  ->estIntraPredQT      ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, bSeparateLumaChroma );
    2739 #endif
    27401410  m_ppcRecoYuvTemp[uiDepth]->copyToPicLuma(rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU() );
    27411411 
    2742 #if H_3D_DIM_SDC
    2743   if( !rpcTempCU->getSDCFlag( 0 ) )
    2744 #endif
    27451412  m_pcPredSearch  ->estIntraPredChromaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC );
    27461413 
     
    27511418  }
    27521419  m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0,          true );
    2753 #if MTK_SINGLE_DEPTH_MODE_I0095
    2754   m_pcEntropyCoder->encodeSingleDepthMode( rpcTempCU, 0,          true );
    2755   if(!rpcTempCU->getSingleDepthFlag(0))
    2756   {
    2757 #endif
    27581420  m_pcEntropyCoder->encodePredMode( rpcTempCU, 0,          true );
    27591421  m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true );
    2760 #if H_3D_DIM_SDC
    2761   m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true );
    2762 #endif
    27631422  m_pcEntropyCoder->encodePredInfo( rpcTempCU, 0,          true );
    27641423  m_pcEntropyCoder->encodeIPCMInfo(rpcTempCU, 0, true );
     
    27681427  m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP );
    27691428  setdQPFlag( bCodeDQP );
    2770 #if MTK_SINGLE_DEPTH_MODE_I0095
    2771   }
    2772 #endif       
    27731429  m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
    27741430 
    27751431  rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
    27761432    rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    2777 #if H_3D_VSO // M6
    2778   if( m_pcRdCost->getUseLambdaScaleVSO()) 
    2779     rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 
    2780   else
    2781 #endif
    27821433  rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    27831434 
     
    27981449
    27991450  rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth );
    2800 #if MTK_SINGLE_DEPTH_MODE_I0095
    2801   rpcTempCU->setSingleDepthFlagSubParts( false, 0, uiDepth );
    2802 #endif
    28031451  rpcTempCU->setIPCMFlag(0, true);
    28041452  rpcTempCU->setIPCMFlagSubParts (true, 0, rpcTempCU->getDepth(0));
     
    28171465  }
    28181466  m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0,          true );
    2819 #if MTK_SINGLE_DEPTH_MODE_I0095
    2820   m_pcEntropyCoder->encodeSingleDepthMode( rpcTempCU, 0,          true );
    2821 #endif
    28221467  m_pcEntropyCoder->encodePredMode ( rpcTempCU, 0,          true );
    28231468  m_pcEntropyCoder->encodePartSize ( rpcTempCU, 0, uiDepth, true );
    2824 #if H_3D_DIM_SDC
    2825   m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true );
    2826 #endif
    28271469  m_pcEntropyCoder->encodeIPCMInfo ( rpcTempCU, 0, true );
    28281470
     
    28311473  rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
    28321474    rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    2833 #if H_3D_VSO // M44
    2834   if ( m_pcRdCost->getUseVSO() )
    2835     rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    2836   else
    2837 #endif
    28381475  rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    28391476
     
    28881525      pcCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits
    28891526        pcCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    2890 #if H_3D_VSO // M45
    2891       if ( m_pcRdCost->getUseVSO() )     
    2892         pcCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( pcCU->getTotalBits(), pcCU->getTotalDistortion() );     
    2893       else
    2894 #endif
    28951527      pcCU->getTotalCost() = m_pcRdCost->calcRdCost( pcCU->getTotalBits(), pcCU->getTotalDistortion() );
    28961528#endif
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncCu.h

    r1039 r1072  
    6969  TComDataCU**            m_ppcBestCU;      ///< Best CUs in each depth
    7070  TComDataCU**            m_ppcTempCU;      ///< Temporary CUs in each depth
    71 #if H_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 H_3D_DBBP
    85   TComYuv**               m_ppcOrigYuvDBBP;
    86 #endif
    8781 
    8882  //  Data : encoder control
     
    10599  TEncSbac*               m_pcRDGoOnSbacCoder;
    106100  TEncRateCtrl*           m_pcRateCtrl;
    107 #if KWU_RC_MADPRED_E0227
    108   UInt                    m_LCUPredictionSAD;
    109   Int                     m_addSADDepth;
    110   Int                     m_temporalSAD;
    111   Int                     m_spatialSAD;
    112 #endif
    113101public:
    114102  /// copy parameters from encoder class
     
    128116 
    129117  Void setBitCounter        ( TComBitCounter* pcBitCounter ) { m_pcBitCounter = pcBitCounter; }
    130 #if KWU_RC_MADPRED_E0227
    131   UInt getLCUPredictionSAD() { return m_LCUPredictionSAD; }
    132 #endif
    133118  Int   updateLCUDataISlice ( TComDataCU* pcCU, Int LCUIdx, Int width, Int height );
    134119protected:
     
    147132
    148133#if AMP_MRG
    149 #if  H_3D_FAST_TEXTURE_ENCODING
    150   Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize,  Bool bFMD, Bool bUseMRG = false  ) ;
    151 #else
    152134  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bUseMRG = false  );
    153 #endif
    154135#else
    155136  Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
    156137#endif
    157 #if H_3D_DBBP
    158   Void  xInvalidateOriginalSegments( TComYuv* pOrigYuv, TComYuv* pOrigYuvTemp, Bool* pMask, UInt uiValidSegment );
    159   Void  xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bUseMRG = false );
    160 #endif
    161 #if MTK_SINGLE_DEPTH_MODE_I0095
    162   Void  xCheckRDCostSingleDepth   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
    163 #endif
    164 #if HHI_DMM4_ENC_I0066
    165   Void  xCheckRDCostIntra   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bOnlyIVP );
    166 #else
    167138  Void  xCheckRDCostIntra   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
    168 #endif
    169139  Void  xCheckDQP           ( TComDataCU*  pcCU );
    170140 
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncEntropy.cpp

    r1066 r1072  
    7878}
    7979
    80 #if H_3D
    81 Void TEncEntropy::encodeSPS( TComSPS* pcSPS, Int viewIndex, Bool depthFlag )
    82 {
    83   m_pcEntropyCoderIf->codeSPS( pcSPS, viewIndex, depthFlag );
    84   return;
    85 }
    86 #else
    8780Void TEncEntropy::encodeSPS( TComSPS* pcSPS )
    8881{
     
    9083  return;
    9184}
    92 #endif
    9385
    9486Void TEncEntropy::encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
     
    119111  m_pcEntropyCoderIf->codeSkipFlag( pcCU, uiAbsPartIdx );
    120112}
    121 #if MTK_SINGLE_DEPTH_MODE_I0095
    122 Void TEncEntropy::encodeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    123 {
    124   if ( !pcCU->getSlice()->getIsDepth() )
    125   {
    126     return;
    127   }
    128   if(!pcCU->getSlice()->getApplySingleDepthMode())
    129   {
    130      return;
    131   }
    132  
    133   if( bRD )
    134   {
    135     uiAbsPartIdx = 0;
    136   }
    137   m_pcEntropyCoderIf->codeSingleDepthMode( pcCU, uiAbsPartIdx );
    138 }
    139 #endif
    140113/** encode merge flag
    141114 * \param pcCU
     
    166139}
    167140
    168 #if H_3D_IC
    169 Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    170 {
    171   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
    172   {
    173     return;
    174   }
    175 
    176   if( !pcCU->getSlice()->getApplyIC() )
    177   {
    178     return;
    179   }
    180 
    181   if( bRD )
    182   {
    183     uiAbsPartIdx = 0;
    184   }
    185   else
    186   {
    187 #if MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX
    188     Int ICEnableCandidate = pcCU->getSlice()->getICEnableCandidate(pcCU->getSlice()->getDepth());
    189     Int ICEnableNum = pcCU->getSlice()->getICEnableNum(pcCU->getSlice()->getDepth());
    190     ICEnableCandidate++;
    191     if(pcCU->getICFlag(uiAbsPartIdx))
    192     {
    193       ICEnableNum++;
    194     }
    195     pcCU->getSlice()->setICEnableCandidate(pcCU->getSlice()->getDepth(), ICEnableCandidate);
    196     pcCU->getSlice()->setICEnableNum(pcCU->getSlice()->getDepth(), ICEnableNum);
    197 #else
    198     g_aICEnableCANDIDATE[pcCU->getSlice()->getDepth()]++;
    199     if(pcCU->getICFlag(uiAbsPartIdx))
    200     {
    201       g_aICEnableNUM[pcCU->getSlice()->getDepth()]++;
    202     }
    203 #endif
    204   }
    205   if( pcCU->isICFlagRequired( uiAbsPartIdx ) )
    206   {
    207     m_pcEntropyCoderIf->codeICFlag( pcCU, uiAbsPartIdx );
    208   }
    209 }
    210 #endif
    211 
    212 #if H_3D_ARP
    213 Void TEncEntropy::encodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
    214 {
    215   if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) )
    216   {
    217     return;
    218   }
    219 
    220   if ( pcCU->getPartitionSize(uiAbsPartIdx)!=SIZE_2Nx2N )
    221   {
    222     assert(pcCU->getARPW (uiAbsPartIdx) == 0);
    223   }
    224   else
    225   {
    226     m_pcEntropyCoderIf->codeARPW( pcCU, uiAbsPartIdx );
    227   }
    228 }
    229 #endif
     141
    230142
    231143/** encode prediction mode
     
    273185  }
    274186 
    275 #if H_3D_DBBP
    276 #if! SEC_DBBP_EXPLICIT_SIG_I0077
    277   PartSize eVirtualPartSize = pcCU->getPartitionSize(uiAbsPartIdx);
    278   if( pcCU->getDBBPFlag(uiAbsPartIdx) )
    279   {
    280     AOF( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) );
    281    
    282     // temporarily change partition size for DBBP blocks
    283     pcCU->setPartSizeSubParts(RWTH_DBBP_PACK_MODE, uiAbsPartIdx, uiDepth);
    284   }
    285 #endif
    286 #endif
    287187 
    288188  m_pcEntropyCoderIf->codePartSize( pcCU, uiAbsPartIdx, uiDepth );
    289189 
    290 #if H_3D_DBBP
    291 #if SEC_DBBP_EXPLICIT_SIG_I0077
    292 #if SEC_DBBP_DISALLOW_8x8_I0078
    293   if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 )
    294 #else
    295   if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) )
    296 #endif
    297 #else
    298 #if SEC_DBBP_DISALLOW_8x8_I0078
    299   if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && pcCU->getWidth(uiAbsPartIdx) > 8 )
    300 #else
    301   if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) )
    302 #endif
    303 #endif
    304   {
    305     encodeDBBPFlag(pcCU, uiAbsPartIdx, bRD);
    306 #if !SEC_DBBP_EXPLICIT_SIG_I0077
    307     if( pcCU->getDBBPFlag(uiAbsPartIdx) )
    308     {
    309       // restore virtual partition size for DBBP blocks
    310       pcCU->setPartSizeSubParts(eVirtualPartSize, uiAbsPartIdx, uiDepth);
    311     }
    312 #endif
    313   }
    314 #endif
    315190}
    316191
     
    541416  {
    542417    encodeIntraDirModeLuma  ( pcCU, uiAbsPartIdx,true );
    543 #if H_3D_DIM_SDC
    544     if(!pcCU->getSDCFlag(uiAbsPartIdx))
    545 #endif
    546418    encodeIntraDirModeChroma( pcCU, uiAbsPartIdx, bRD );
    547419  }
     
    715587  UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
    716588  UInt uiChromaOffset = uiLumaOffset>>2;
    717 #if H_3D_DIM_SDC
    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, TEXT_LUMA) == 1 );
    723     assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
    724     assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
    725   }
    726 
    727   if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx ) )
    728   {
    729     assert( !pcCU->isSkipped( uiAbsPartIdx ) );
    730     assert( !pcCU->isIntra( uiAbsPartIdx) );
    731     assert( pcCU->getSlice()->getIsDepth() );
    732   }
    733 
    734   if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) )
    735   {
    736     Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
    737     UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
    738    
    739     if( !pcCU->getSDCFlag( uiAbsPartIdx ) )
    740     {
    741       for( Int iPart = 0; iPart < iPartNum; iPart++ )
    742       {
    743         if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE )
    744         {
    745           m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart );
    746         }
    747       }
    748     }
    749     else
    750     {
    751       m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx );
    752       return;
    753     }
    754   }
    755 #endif
    756589
    757590  if( pcCU->isIntra(uiAbsPartIdx) )
     
    812645}
    813646
    814 #if H_3D_INTER_SDC
    815 Void TEncEntropy::encodeDeltaDC  ( TComDataCU* pcCU, UInt absPartIdx )
    816 {
    817   m_pcEntropyCoderIf->codeDeltaDC( pcCU, absPartIdx );
    818 }
    819 
    820 Void TEncEntropy::encodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    821 {
    822   if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) ) ||
    823     ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getVpsDepthModesFlag( pcCU->getSlice()->getLayerIdInVps() ) ) )
    824   {
    825     return;
    826   }
    827 
    828   if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) )
    829   {
    830     return;
    831   }
    832 
    833   assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
    834 
    835   if( bRD )
    836   {
    837     uiAbsPartIdx = 0;
    838   }
    839 
    840   m_pcEntropyCoderIf->codeSDCFlag( pcCU, uiAbsPartIdx );
    841 }
    842 
    843 #endif
    844 #if H_3D_DBBP
    845 Void TEncEntropy::encodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    846 {
    847   if( bRD )
    848   {
    849     uiAbsPartIdx = 0;
    850   }
    851   m_pcEntropyCoderIf->codeDBBPFlag( pcCU, uiAbsPartIdx );
    852 }
    853 #endif
    854647//! \}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncEntropy.h

    r1039 r1072  
    6969
    7070  virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
    71 #if !H_3D
    7271  virtual Void  codeSPS                 ( TComSPS* pcSPS )                                      = 0;
    73 #else
    74   virtual Void  codeSPS                 ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag )       = 0;
    75 #endif
    7672  virtual Void  codePPS                 ( TComPPS* pcPPS )                                      = 0;
    7773  virtual Void  codeSliceHeader         ( TComSlice* pcSlice )                                  = 0;
     
    8682  virtual Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    8783  virtual Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    88 #if MTK_SINGLE_DEPTH_MODE_I0095
    89   virtual Void codeSingleDepthMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    90 #endif
    9184  virtual Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    9285  virtual Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    93 #if H_3D_ARP
    94   virtual Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    95 #endif
    96 #if H_3D_IC
    97   virtual Void codeICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    98 #endif
    99 #if H_3D_INTER_SDC
    100   virtual Void codeDeltaDC       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    101   virtual Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    102 #endif
    103 #if H_3D_DBBP
    104   virtual Void codeDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    105 #endif
    10686  virtual Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    10787 
     
    165145  Void encodeVPS               ( TComVPS* pcVPS);
    166146  // SPS
    167 #if H_3D
    168   Void encodeSPS               ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag );
    169 #else
    170147  Void encodeSPS               ( TComSPS* pcSPS );
    171 #endif
    172148  Void encodePPS               ( TComPPS* pcPPS );
    173149  Void encodeSplitFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
    174150  Void encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    175151  Void encodeSkipFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    176 #if MTK_SINGLE_DEPTH_MODE_I0095
    177   Void encodeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD=false );
    178 #endif
    179152  Void encodePUWise       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    180153  Void encodeInterDirPU   ( TComDataCU* pcSubCU, UInt uiAbsPartIdx  );
     
    184157  Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    185158  Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    186 #if H_3D_ARP
    187   Void encodeARPW         ( TComDataCU* pcCU, UInt uiAbspartIdx );
    188 #endif
    189 #if H_3D_IC
    190   Void encodeICFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    191 #endif
    192 #if H_3D_INTER_SDC
    193   Void encodeDeltaDC      ( TComDataCU* pcCU, UInt absPartIdx );
    194   Void encodeSDCFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    195 #endif
    196 #if H_3D_DBBP
    197   Void encodeDBBPFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    198 #endif
    199159  Void encodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    200160  Void encodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncGOP.cpp

    r1066 r1072  
    103103  m_viewId       = 0;
    104104  m_pocLastCoded = -1;
    105 #if H_3D
    106   m_viewIndex  =   0;
    107   m_isDepth = false;
    108 #endif
    109105#endif
    110106#if FIX1172
     
    155151  m_layerId              = pcTEncTop->getLayerId();
    156152  m_viewId               = pcTEncTop->getViewId();
    157 #if H_3D
    158   m_viewIndex            = pcTEncTop->getViewIndex();
    159   m_isDepth              = pcTEncTop->getIsDepth();
    160 #endif
    161 #endif
    162 #if MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX
    163   m_aICEnableCandidate           = pcTEncTop->getICEnableCandidate();
    164   m_aICEnableNum           = pcTEncTop->getICEnableNum();
    165 #endif
    166 #if KWU_FIX_URQ
    167   m_pcRateCtrl           = pcTEncTop->getRateCtrl();
    168153#endif
    169154}
     
    652637    pcPic  ->setLayerId     ( getLayerId()   );
    653638    pcPic  ->setViewId      ( getViewId()    );   
    654 #if !H_3D
    655639    pcSlice->setLayerId     ( getLayerId() );
    656640    pcSlice->setViewId      ( getViewId()  );   
    657641    pcSlice->setVPS         ( m_pcEncTop->getVPS() );
    658 #else
    659     pcPic  ->setViewIndex   ( getViewIndex() );
    660     pcPic  ->setIsDepth( getIsDepth() );
    661     pcSlice->setCamparaSlice( pcPic->getCodedScale(), pcPic->getCodedOffset() );   
    662 #endif
    663642#endif
    664643    //set default slice level flag to the same as SPS level flag
     
    937916    pcSlice->setRefPicList ( rcListPic );
    938917#endif
    939 #if MTK_SINGLE_DEPTH_MODE_I0095
    940     TEncTop* pcEncTop = (TEncTop*) m_pcCfg;
    941     bool enableSingleDepthMode=false;
    942     if(pcEncTop->getUseSingleDepthMode())
    943     {
    944       if(pcSlice->getIsDepth())
    945       {
    946         enableSingleDepthMode=true;
    947       }
    948     }
    949     pcSlice->setApplySingleDepthMode(enableSingleDepthMode);
    950 #endif   
    951 #if H_3D_ARP
    952     //GT: This seems to be broken when layerId in vps is not equal to layerId in nuh
    953     pcSlice->setARPStepNum(m_ivPicLists);
    954     if(pcSlice->getARPStepNum() > 1)
    955     {
    956       for(Int iLayerId = 0; iLayerId < getLayerId(); iLayerId ++ )
    957       {
    958         Int  iViewIdx =   pcSlice->getVPS()->getViewIndex(iLayerId);
    959         Bool bIsDepth = ( pcSlice->getVPS()->getDepthId  ( iLayerId ) == 1 );
    960         if( iViewIdx<getViewIndex() && !bIsDepth )
    961         {
    962           pcSlice->setBaseViewRefPicList( m_ivPicLists->getPicList( iLayerId ), iViewIdx );
    963         }
    964       }
    965     }
    966 #endif
    967 #if H_3D
    968     pcSlice->setIvPicLists( m_ivPicLists );         
    969 #if H_3D_IV_MERGE   
    970     assert( !m_pcEncTop->getIsDepth() || ( pcSlice->getTexturePic() != 0 ) );
    971 #endif   
    972 #endif
    973 #if MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX
    974     pcSlice->setICEnableCandidate( m_aICEnableCandidate );         
    975     pcSlice->setICEnableNum( m_aICEnableNum );         
    976 #endif
    977918    //  Slice info. refinement
    978919#if H_MV
     
    1025966
    1026967    pcSlice->setList1IdxToList0Idx();
    1027 #if H_3D_TMVP
    1028     if(pcSlice->getLayerId())
    1029       pcSlice->generateAlterRefforTMVP();
    1030 #endif
    1031968    if (m_pcEncTop->getTMVPModeId() == 2)
    1032969    {
     
    1059996#endif
    1060997
    1061 #if H_3D_VSO
    1062   // Should be moved to TEncTop !!!
    1063   Bool bUseVSO = m_pcEncTop->getUseVSO();
    1064  
    1065   TComRdCost* pcRdCost = m_pcEncTop->getRdCost();   
    1066 
    1067   pcRdCost->setUseVSO( bUseVSO );
    1068 
    1069   // SAIT_VSO_EST_A0033
    1070   pcRdCost->setUseEstimatedVSD( m_pcEncTop->getUseEstimatedVSD() );
    1071 
    1072   if ( bUseVSO )
    1073   {
    1074     Int iVSOMode = m_pcEncTop->getVSOMode();
    1075     pcRdCost->setVSOMode( iVSOMode  );
    1076     pcRdCost->setAllowNegDist( m_pcEncTop->getAllowNegDist() );
    1077 
    1078     // SAIT_VSO_EST_A0033
    1079 #if H_3D_FCO
    1080     Bool flagRec;
    1081     flagRec =  ((m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), false, pcSlice->getPOC(), true) == NULL) ? false: true);
    1082     pcRdCost->setVideoRecPicYuv( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), false, pcSlice->getPOC(), flagRec ) );
    1083     pcRdCost->setDepthPicYuv   ( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), true, pcSlice->getPOC(), false ) );
    1084 #else
    1085     pcRdCost->setVideoRecPicYuv( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), false , pcSlice->getPOC(), true ) );
    1086     pcRdCost->setDepthPicYuv   ( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), true  , pcSlice->getPOC(), false ) );
    1087 #endif
    1088 
    1089     // LGE_WVSO_A0119
    1090     Bool bUseWVSO  = m_pcEncTop->getUseWVSO();
    1091     pcRdCost->setUseWVSO( bUseWVSO );
    1092 
    1093   }
    1094 #endif
    1095998    /////////////////////////////////////////////////////////////////////////////////////////////////// Compress a slice
    1096999    //  Slice compression
     
    11411044      m_pcRateCtrl->initRCPic( frameLevel );
    11421045
    1143 #if KWU_RC_MADPRED_E0227
    1144       if(m_pcCfg->getLayerId() != 0)
    1145       {
    1146         m_pcRateCtrl->getRCPic()->setIVPic( m_pcEncTop->getEncTop()->getTEncTop(0)->getRateCtrl()->getRCPic() );
    1147       }
    1148 #endif
    11491046
    11501047      estimatedBits = m_pcRateCtrl->getRCPic()->getTargetBits();
     
    11821079      else    // normal case
    11831080      {
    1184 #if KWU_RC_MADPRED_E0227
    1185         if(m_pcRateCtrl->getLayerID() != 0)
    1186         {
    1187           list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
    1188           lambda  = m_pcRateCtrl->getRCPic()->estimatePicLambdaIV( listPreviousPicture, pcSlice->getPOC() );
    1189           sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
    1190         }
    1191         else
    1192         {
    1193 #endif
    11941081        list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
    11951082        lambda  = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->getSliceType());
    11961083        sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
    1197 #if KWU_RC_MADPRED_E0227
    1198         }
    1199 #endif
    12001084      }
    12011085
     
    13251209    m_storedStartCUAddrForEncodingSliceSegment.push_back(nextCUAddr);
    13261210    startCUAddrSliceSegmentIdx++;
    1327 #if H_3D_NBDV
    1328       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.
    1329       {
    1330         Int iColPoc = pcSlice->getRefPOC(RefPicList(1-pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
    1331         pcPic->setNumDdvCandPics(pcPic->getDisCandRefPictures(iColPoc));
    1332       }
    1333 #endif
    1334 #if H_3D
    1335       pcSlice->setDepthToDisparityLUTs();
    1336 
    1337 #endif
    1338 
    1339 #if H_3D_NBDV
    1340       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.
    1341       {
    1342         pcPic->checkTemporalIVRef();
    1343       }
    1344 
    1345       if(pcSlice->getIsDepth())
    1346       {
    1347         pcPic->checkTextureRef();
    1348       }
    1349 #endif
     1211
    13501212    while(nextCUAddr<uiRealEndAddress) // determine slice boundaries
    13511213    {
     
    14701332        pcSlice->getSPS()->getVuiParameters()->setHrdParametersPresentFlag( true );
    14711333      }
    1472 #if !H_3D
    14731334      m_pcEntropyCoder->encodeSPS(pcSlice->getSPS());
    1474 #else
    1475       m_pcEntropyCoder->encodeSPS(pcSlice->getSPS(), pcSlice->getViewIndex(), pcSlice->getIsDepth() );
    1476 #endif
    14771335      writeRBSPTrailingBits(nalu.m_Bitstream);
    14781336      accessUnit.push_back(new NALUnitEBSP(nalu));
     
    14831341#else
    14841342      nalu = NALUnit(NAL_UNIT_PPS);
    1485 #endif
    1486 #if PPS_FIX_DEPTH
    1487       if(!pcSlice->getIsDepth() || !pcSlice->getViewIndex() )
    1488       {
    14891343#endif
    14901344      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    14941348      actualTotalBits += UInt(accessUnit.back()->m_nalUnitData.str().size()) * 8;
    14951349     
    1496 #if PPS_FIX_DEPTH
    1497       }
    1498 #endif
    14991350      xCreateLeadingSEIMessages(accessUnit, pcSlice->getSPS());
    15001351
     
    20281879        }
    20291880      } // end iteration over slices
    2030 #if H_3D
    2031       pcPic->compressMotion(2);
    2032 #endif
    2033 #if !H_3D
    20341881      pcPic->compressMotion();
    2035 #endif
    20361882#if H_MV
    20371883      m_pocLastCoded = pcPic->getPOC();
     
    24522298}
    24532299#endif
    2454 #if H_3D_VSO
    2455 Void TEncGOP::preLoopFilterPicAll( TComPic* pcPic, Dist64& ruiDist, UInt64& ruiBits )
    2456 #else
    24572300Void TEncGOP::preLoopFilterPicAll( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits )
    2458 #endif
    24592301{
    24602302  TComSlice* pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx());
     
    25702412}
    25712413
    2572 #if H_3D_VSO
    2573 Dist64 TEncGOP::xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1)
    2574 #else
    25752414UInt64 TEncGOP::xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1)
    2576 #endif
    25772415{
    25782416  Int     x, y;
     
    25862424  Int   iHeight = pcPic0->getHeight();
    25872425 
    2588 #if H_3D_VSO
    2589   Dist64  uiTotalDiff = 0;
    2590 #else
    25912426  UInt64  uiTotalDiff = 0;
    2592 #endif
    25932427 
    25942428  for( y = 0; y < iHeight; y++ )
     
    27062540  }
    27072541 
    2708 #if H_3D_VSO
    2709 #if H_3D_VSO_SYNTH_DIST_OUT
    2710   if ( m_pcRdCost->getUseRenModel() )
    2711   {
    2712     unsigned int maxval = 255 * (1<<(g_uiBitDepth + g_uiBitIncrement -8));
    2713     Double fRefValueY = (double) maxval * maxval * iSize;
    2714     Double fRefValueC = fRefValueY / 4.0;
    2715     TRenModel*  pcRenModel = m_pcEncTop->getEncTop()->getRenModel();
    2716     Int64 iDistVSOY, iDistVSOU, iDistVSOV;
    2717     pcRenModel->getTotalSSE( iDistVSOY, iDistVSOU, iDistVSOV );
    2718     dYPSNR = ( iDistVSOY ? 10.0 * log10( fRefValueY / (Double) iDistVSOY ) : 99.99 );
    2719     dUPSNR = ( iDistVSOU ? 10.0 * log10( fRefValueC / (Double) iDistVSOU ) : 99.99 );
    2720     dVPSNR = ( iDistVSOV ? 10.0 * log10( fRefValueC / (Double) iDistVSOV ) : 99.99 );
    2721   }
    2722   else
    2723   {
    2724 #endif
    2725 #endif
    27262542    iHeight >>= 1;
    27272543  iWidth  >>= 1;
     
    27622578  dUPSNR            = ( uiSSDU ? 10.0 * log10( fRefValueC / (Double)uiSSDU ) : 99.99 );
    27632579  dVPSNR            = ( uiSSDV ? 10.0 * log10( fRefValueC / (Double)uiSSDV ) : 99.99 );
    2764 #if H_3D_VSO
    2765 #if H_3D_VSO_SYNTH_DIST_OUT
    2766 }
    2767 #endif
    2768 #endif
    27692580  /* calculate the size of the access unit, excluding:
    27702581   *  - any AnnexB contributions (start_code_prefix, zero_byte, etc.,)
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncGOP.h

    r1066 r1072  
    5757#include "TEncAnalyze.h"
    5858#include "TEncRateCtrl.h"
    59 #if KWU_RC_MADPRED_E0227
    60 #include "../App/TAppEncoder/TAppEncTop.h"
    61 #endif
    6259#include <vector>
    6360
     
    111108  Int                     m_layerId; 
    112109  Int                     m_viewId;
    113 #if H_3D
    114   Int                     m_viewIndex;
    115   Bool                    m_isDepth;
    116 #endif
    117 #endif
    118 #if MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX
    119   Int *m_aICEnableCandidate;
    120   Int *m_aICEnableNum;
    121110#endif
    122111  //--Adaptive Loop filter
     
    168157  Int       getLayerId       ()                 { return m_layerId;    } 
    169158  Int       getViewId        ()                 { return m_viewId;    }
    170 #if H_3D
    171   Int       getViewIndex     ()                 { return m_viewIndex;    }
    172   Bool      getIsDepth       ()                 { return m_isDepth; }
    173 #endif
    174159#endif
    175160
     
    181166  Void  printOutSummary      ( UInt uiNumAllPicCoded , bool isField);
    182167#endif
    183 #if H_3D_VSO
    184   Void  preLoopFilterPicAll  ( TComPic* pcPic, Dist64& ruiDist, UInt64& ruiBits );
    185 #else
    186168  Void  preLoopFilterPicAll  ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits );
    187 #endif
    188 
    189 #if KWU_RC_MADPRED_E0227
    190   TEncTop* getEncTop() { return m_pcEncTop; }
    191 #endif
     169
    192170
    193171  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
     
    206184  Void  xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime );
    207185
    208 #if H_3D_VSO
    209   Dist64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1);
    210 #else 
    211186  UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1);
    212 #endif
    213187
    214188  Double xCalculateRVM();
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncRateCtrl.cpp

    r872 r1072  
    480480
    481481  m_LCUs         = NULL;
    482 #if KWU_RC_MADPRED_E0227
    483   m_lastIVPicture = NULL;
    484 #endif
    485482
    486483  m_picActualHeaderBits = 0;
     
    489486  m_picLambda           = 0.0;
    490487
    491 #if KWU_RC_MADPRED_E0227
    492   m_IVtotalMAD            = 0.0;
    493 #endif
    494488}
    495489
     
    565559}
    566560
    567 #if KWU_RC_MADPRED_E0227
    568 Void TEncRCPic::addToPictureLsitIV( list<TEncRCPic*>& listPreviousPictures )
    569 {
    570   m_lastIVPicture = NULL;
    571   m_lastIVPicture = this;
    572 }
    573 
    574 Void TEncRCPic::setIVPic( TEncRCPic* BaseRCPic )
    575 {
    576   m_lastIVPicture = BaseRCPic;
    577 }
    578 #endif
    579 
    580 #if KWU_RC_MADPRED_E0227
    581 Void TEncRCPic::create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures, Int layerID )
    582 #else
     561
    583562Void TEncRCPic::create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures )
    584 #endif
    585563{
    586564  destroy();
     
    631609      m_LCUs[LCUIdx].m_numberOfPixel = currWidth * currHeight;
    632610
    633 #if KWU_RC_MADPRED_E0227
    634       m_LCUs[LCUIdx].m_CUWidth = currWidth;
    635       m_LCUs[LCUIdx].m_CUHeight = currHeight;
    636       m_LCUs[LCUIdx].m_IVMAD = -1.0;
    637 #endif
    638611    }
    639612  }
     
    644617
    645618
    646 #if KWU_RC_MADPRED_E0227
    647   m_LayerID = layerID;
    648   m_lastIVPicture = NULL;
    649   m_IVtotalMAD            = 0.0;
    650 #endif
    651 
    652 
    653 #if KWU_RC_MADPRED_E0227
    654   list<TEncRCPic*>::reverse_iterator it;
    655   if( m_LayerID != 0)
    656   {
    657     m_lastIVPicture = NULL;
    658     for ( it = listPreviousPictures.rbegin(); it != listPreviousPictures.rend(); it++ )
    659     {
    660       if ( (*it)->getLayerID() == 0 )
    661       {
    662         m_lastIVPicture = (*it);
    663         break;
    664       }
    665     }
    666   }
    667 
    668   m_lastPicture = NULL;
    669   for ( it = listPreviousPictures.rbegin(); it != listPreviousPictures.rend(); it++ )
    670   {
    671     if ( (*it)->getFrameLevel() == m_frameLevel )
    672     {
    673       m_lastPicture = (*it);
    674       break;
    675     }
    676   }
    677 #endif
     619
     620
    678621}
    679622
     
    823766
    824767
    825 #if KWU_RC_MADPRED_E0227
    826 Double TEncRCPic::estimatePicLambdaIV( list<TEncRCPic*>& listPreviousPictures, Int CurPOC )
    827 {
    828   Double alpha         = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha;
    829   Double beta          = m_encRCSeq->getPicPara( m_frameLevel ).m_beta;
    830   Double bpp       = (Double)m_targetBits/(Double)m_numberOfPixel;
    831   Double estLambda = alpha * pow( bpp, beta );
    832   Double lastLevelLambda = -1.0;
    833   Double lastPicLambda   = -1.0;
    834   Double lastValidLambda = -1.0;
    835   list<TEncRCPic*>::iterator it;
    836 
    837   if(listPreviousPictures.size() == 0 || CurPOC%8 == 0)
    838   {
    839     lastLevelLambda = m_lastIVPicture->getPicActualLambda();
    840     lastPicLambda     = m_lastIVPicture->getPicActualLambda();
    841   }
    842   else
    843   {
    844     for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ )
    845     {
    846       if ( (*it)->getFrameLevel() == m_frameLevel )
    847       {
    848         lastLevelLambda = (*it)->getPicActualLambda();
    849       }
    850       lastPicLambda     = (*it)->getPicActualLambda();
    851 
    852       if ( lastPicLambda > 0.0 )
    853       {
    854         lastValidLambda = lastPicLambda;
    855       }
    856     }
    857   }
    858 
    859   if ( lastLevelLambda > 0.0 )
    860   {
    861     lastLevelLambda = Clip3( 0.1, 10000.0, lastLevelLambda );
    862     estLambda = Clip3( lastLevelLambda * pow( 2.0, -3.0/3.0 ), lastLevelLambda * pow( 2.0, 3.0/3.0 ), estLambda );
    863   }
    864 
    865   if ( lastPicLambda > 0.0 )
    866   {
    867     lastPicLambda = Clip3( 0.1, 2000.0, lastPicLambda );
    868     estLambda = Clip3( lastPicLambda * pow( 2.0, -10.0/3.0 ), lastPicLambda * pow( 2.0, 10.0/3.0 ), estLambda );
    869   }
    870   else if ( lastValidLambda > 0.0 )
    871   {
    872     lastValidLambda = Clip3( 0.1, 2000.0, lastValidLambda );
    873     estLambda = Clip3( lastValidLambda * pow(2.0, -10.0/3.0), lastValidLambda * pow(2.0, 10.0/3.0), estLambda );
    874   }
    875   else
    876   {
    877     estLambda = Clip3( 0.1, 10000.0, estLambda );
    878   }
    879 
    880   if ( estLambda < 0.1 )
    881   {
    882     estLambda = 0.1;
    883   }
    884 
    885   m_estPicLambda = estLambda;
    886   return estLambda;
    887 }
    888 #endif
    889768
    890769
     
    935814
    936815
    937 #if KWU_RC_MADPRED_E0227
    938 Double TEncRCPic::getLCUTargetBppforInterView( list<TEncRCPic*>& listPreviousPictures, TComDataCU* pcCU, Double basePos, Double curPos, Double focalLen, Double znear, Double zfar, Int direction, Int* disparity )
    939 {
    940   Int   LCUIdx    = getLCUCoded();
    941   Double bpp      = -1.0;
    942   Int avgBits     = 0;
    943 #if !M0036_RC_IMPROVEMENT
    944   Double totalMAD = -1.0;
    945   Double MAD      = -1.0;
    946 #endif
    947 
    948   Double totalMAD = -1.0;
    949   Double MAD      = -1.0;
    950 
    951   Double IVMAD      = -1.0;
    952   Double SAD = 0.0;
    953   Int     x, y;
    954   Int Sum = 0;
    955 
    956   {
    957     Pel*  pOrg    = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
    958     Pel*  pRec    = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), 0);
    959     Pel*  pDep    = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
    960     Int   iStride = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getStride();
    961 
    962     Int   width  = m_LCUs[ LCUIdx ].m_CUWidth;
    963     Int   height = m_LCUs[ LCUIdx ].m_CUHeight;
    964 
    965     for( y = 0 ; y < pcCU->getSlice()->getSPS()->getMaxCUHeight() ; y+=8)
    966     {
    967       for( x = 0 ; x < pcCU->getSlice()->getSPS()->getMaxCUWidth() ; x+=8)
    968       {
    969         Sum += pDep[x];
    970       }
    971       pDep += iStride;
    972     }
    973 
    974     Double AvgDepth = (Double)Sum/((pcCU->getSlice()->getSPS()->getMaxCUHeight()/8)*(pcCU->getSlice()->getSPS()->getMaxCUWidth()/8));
    975 
    976     Double fL = focalLen * abs( basePos - curPos );
    977     Double z  = abs( 1.0 / znear - 1.0 / zfar ) * ((Double)(AvgDepth) / (( 1 << g_bitDepthY ) - 1) ) + abs(1.0 / zfar);
    978     *disparity = (Int)(direction*fL * z);
    979     Int shift = DISTORTION_PRECISION_ADJUSTMENT(g_bitDepthY-8);
    980 
    981     Int disp = *disparity;
    982     Int posX, posY;
    983     pcCU->getPosInPic(0, posX, posY);
    984     if((posX + *disparity) < 0 || (posX + *disparity + width) >= pcCU->getSlice()->getSPS()->getMaxCUWidth())
    985     {
    986       disp = 0;
    987     }
    988 
    989     for( y = 0; y < height; y++ )
    990     {
    991       for( x = 0; x < width; x++ )
    992       {
    993         SAD += abs( pOrg[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)]
    994                   - pRec[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)] )>>shift;
    995       }
    996       pOrg += iStride;
    997       pRec += iStride;
    998     }
    999     IVMAD = SAD / (Double)(height * width);
    1000     IVMAD = IVMAD * IVMAD;
    1001 
    1002     m_LCUs[ LCUIdx ].m_IVMAD = IVMAD;
    1003     if(m_lastPicture)
    1004     {
    1005       m_LCUs[ LCUIdx ].m_MAD = m_lastPicture->getLCU(LCUIdx).m_MAD;
    1006     }
    1007 
    1008     MAD = m_LCUs[ LCUIdx ].m_IVMAD;
    1009 
    1010     if(m_lastPicture)
    1011     {
    1012       totalMAD = m_lastPicture->getTotalMAD();      // get total MAD of temporal frame
    1013       for ( Int i=0; i<LCUIdx; i++ )
    1014       {
    1015         totalMAD -= m_lastPicture->getLCU(i).m_MAD;
    1016       }
    1017     }
    1018     else
    1019     {
    1020       totalMAD = m_lastIVPicture->getTotalMAD();      // get total MAD of inter-view frame
    1021       for ( Int i=0; i<LCUIdx; i++ )
    1022       {
    1023         totalMAD -= m_lastIVPicture->getLCU(i).m_MAD;
    1024       }
    1025     }
    1026 
    1027 
    1028     if ( totalMAD > 0.1 )
    1029     {
    1030       avgBits = Int( (m_bitsLeft * MAD) / totalMAD );
    1031     }
    1032     else
    1033     {
    1034       avgBits = Int( (m_bitsLeft) / m_LCULeft );
    1035     }
    1036   }
    1037 
    1038   if ( avgBits < 5 )
    1039   {
    1040     avgBits = 5;
    1041   }
    1042 
    1043   bpp = ( Double )avgBits/( Double )m_LCUs[ LCUIdx ].m_numberOfPixel;
    1044   m_LCUs[ LCUIdx ].m_targetBits = avgBits;
    1045 
    1046   return bpp;
    1047 }
    1048 #endif
    1049816
    1050817
     
    12571024  }
    12581025  m_picLambda           = averageLambda;
    1259 #if KWU_RC_MADPRED_E0227
    1260   m_totalMAD = 0;
    1261   for ( Int i=0; i<m_numberOfLCU; i++ )
    1262   {
    1263     m_totalMAD += m_LCUs[i].m_MAD;
    1264   }
    1265 #endif
    12661026
    12671027  Double alpha = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha;
     
    14391199}
    14401200
    1441 #if KWU_RC_MADPRED_E0227
    1442 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 )
    1443 #else
    14441201Void 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] )
    1445 #endif
    14461202{
    14471203  destroy();
     
    16301386  }
    16311387
    1632 #if KWU_RC_MADPRED_E0227
    1633   setLayerID(layerID);
    1634 #endif
    16351388
    16361389  delete[] bitsRatio;
     
    16411394{
    16421395  m_encRCPic = new TEncRCPic;
    1643 #if KWU_RC_MADPRED_E0227
    1644   m_encRCPic->create( m_encRCSeq, m_encRCGOP, frameLevel, m_listRCPictures, m_LayerID );
    1645 #else
    16461396  m_encRCPic->create( m_encRCSeq, m_encRCGOP, frameLevel, m_listRCPictures );
    1647 #endif
    16481397}
    16491398
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncRateCtrl.h

    r872 r1072  
    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();
     
    288268  Void setTotalIntraCost(Double cost)                     { m_totalCostIntra = cost; }
    289269  Void getLCUInitTargetBits();
    290 #if KWU_RC_MADPRED_E0227
    291   Double getTotalMAD()                                    { return m_totalMAD; }
    292   Void   setTotalMAD( Double MAD )                        { m_totalMAD = MAD; }
    293 
    294   Double getIVTotalMAD()                                    { return m_IVtotalMAD; }
    295   Void   setIVTotalMAD( Double MAD )                        { m_IVtotalMAD = MAD; }
    296 #endif
    297270
    298271  Int  getPicActualBits()                                 { return m_picActualBits; }
     
    304277  Void setPicEstLambda( Double lambda )                   { m_picLambda = lambda; }
    305278
    306 #if KWU_RC_MADPRED_E0227
    307   Int getLayerID()                                         { return m_LayerID; }
    308   Void setLayerID(Int layerid)                              { m_LayerID = layerid; }
    309 #endif
    310279private:
    311280  TEncRCSeq* m_encRCSeq;
     
    331300  Int m_picQP;                  // in integer form
    332301  Double m_picLambda;
    333 #if KWU_RC_MADPRED_E0227
    334   Double m_totalMAD;
    335   TEncRCPic* m_lastPicture;
    336   Int m_LayerID;
    337   TEncRCPic* m_lastIVPicture;
    338   Double m_IVtotalMAD;
    339 #endif
    340302};
    341303
     
    347309
    348310public:
    349 #if KWU_RC_MADPRED_E0227
    350   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 );
    351 #else
    352311  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] );
    353 #endif
    354312  Void destroy();
    355313  Void initRCPic( Int frameLevel );
     
    365323  list<TEncRCPic*>& getPicList() { return m_listRCPictures; }
    366324
    367 #if KWU_RC_MADPRED_E0227
    368   Int getLayerID()                { return m_LayerID; }
    369   Void setLayerID(Int layerid)     { m_LayerID = layerid; }
    370 #endif
    371325private:
    372326  TEncRCSeq* m_encRCSeq;
     
    375329  list<TEncRCPic*> m_listRCPictures;
    376330  Int        m_RCQP;
    377 #if KWU_RC_MADPRED_E0227
    378   Int m_LayerID;
     331};
     332
    379333#endif
    380 };
    381 
    382 #endif
    383 
    384 
     334
     335
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncSbac.cpp

    r1066 r1072  
    5858, m_cCUSplitFlagSCModel       ( 1,             1,               NUM_SPLIT_FLAG_CTX            , m_contextModels + m_numContextModels, m_numContextModels )
    5959, m_cCUSkipFlagSCModel        ( 1,             1,               NUM_SKIP_FLAG_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
    60 #if MTK_SINGLE_DEPTH_MODE_I0095
    61 , m_cCUSingleDepthFlagSCModel        ( 1,             1,               NUM_SINGLEDEPTH_FLAG_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
    62 , m_cSingleDepthValueSCModel         ( 1,             1,               NUM_SINGLE_DEPTH_VALUE_DATA_CTX      , m_contextModels + m_numContextModels, m_numContextModels)
    63 #endif
    6460, m_cCUMergeFlagExtSCModel    ( 1,             1,               NUM_MERGE_FLAG_EXT_CTX        , m_contextModels + m_numContextModels, m_numContextModels)
    6561, m_cCUMergeIdxExtSCModel     ( 1,             1,               NUM_MERGE_IDX_EXT_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
    66 #if H_3D_ARP
    67 , m_cCUPUARPWSCModel          ( 1,             1,               NUM_ARPW_CTX                  , m_contextModels + m_numContextModels, m_numContextModels)
    68 #endif
    69 #if H_3D_IC
    70 , m_cCUICFlagSCModel          ( 1,             1,               NUM_IC_FLAG_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
    71 #endif
    7262, m_cCUPartSizeSCModel        ( 1,             1,               NUM_PART_SIZE_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
    7363, m_cCUPredModeSCModel        ( 1,             1,               NUM_PRED_MODE_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
     
    9282, m_cTransformSkipSCModel     ( 1,             2,               NUM_TRANSFORMSKIP_FLAG_CTX    , m_contextModels + m_numContextModels, m_numContextModels)
    9383, m_CUTransquantBypassFlagSCModel( 1,          1,               NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels)
    94 #if H_3D_DIM
    95 , m_cDepthIntraModeSCModel    ( 1,             1,               NUM_DEPTH_INTRA_MODE_CTX      , m_contextModels + m_numContextModels, m_numContextModels)
    96 , m_cDdcFlagSCModel           ( 1,             1,               NUM_DDC_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    97 , m_cDdcDataSCModel           ( 1,             1,               NUM_DDC_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    98 , m_cAngleFlagSCModel         ( 1,             1,               NUM_ANGLE_FLAG_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
    99 #if H_3D_DIM_SDC
    100 , m_cSDCResidualFlagSCModel   ( 1,             1,               SDC_NUM_RESIDUAL_FLAG_CTX     , m_contextModels + m_numContextModels, m_numContextModels)
    101 , m_cSDCResidualSCModel       ( 1,             1,               SDC_NUM_RESIDUAL_CTX          , m_contextModels + m_numContextModels, m_numContextModels)
    102 #endif
    103 #endif
    104 #if H_3D_DIM_SDC
    105 , m_cSDCFlagSCModel                  ( 1,             1,  NUM_SDC_FLAG_CTX                 , m_contextModels + m_numContextModels, m_numContextModels)
    106 #endif
    107 #if H_3D_DBBP
    108 , m_cDBBPFlagSCModel             ( 1,             1,                 DBBP_NUM_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
    109 #endif
    11084{
    11185  assert( m_numContextModels <= MAX_NUM_CTX_MOD );
     
    134108 
    135109  m_cCUSkipFlagSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG );
    136 #if MTK_SINGLE_DEPTH_MODE_I0095
    137   m_cCUSingleDepthFlagSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SINGLEDEPTH_FLAG );
    138   m_cSingleDepthValueSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_SINGLE_DEPTH_VALUE_DATA );
    139 #endif
    140110  m_cCUMergeFlagExtSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT);
    141111  m_cCUMergeIdxExtSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT);
    142 #if H_3D_ARP
    143   m_cCUPUARPWSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_ARPW );
    144 #endif
    145 #if H_3D_IC
    146   m_cCUICFlagSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_IC_FLAG );
    147 #endif
    148112  m_cCUPartSizeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
    149113  m_cCUPredModeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );
     
    169133  m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );
    170134
    171 #if H_3D_DIM
    172   m_cDepthIntraModeSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE );
    173   m_cDdcFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG );
    174   m_cDdcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );
    175   m_cAngleFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG );
    176 #if H_3D_DIM_SDC
    177   m_cSDCResidualFlagSCModel.initBuffer   ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
    178   m_cSDCResidualSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL );
    179 #endif
    180 #endif
    181 #if H_3D_DIM_SDC
    182   m_cSDCFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
    183 #endif
    184 #if H_3D_DBBP
    185   m_cDBBPFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG );
    186 #endif
    187135  // new structure
    188136  m_uiLastQp = iQp;
     
    214162      curCost  = m_cCUSplitFlagSCModel.calcCost       ( curSliceType, qp, (UChar*)INIT_SPLIT_FLAG );
    215163      curCost += m_cCUSkipFlagSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_SKIP_FLAG );
    216 #if MTK_SINGLE_DEPTH_MODE_I0095
    217       curCost += m_cCUSingleDepthFlagSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_SINGLEDEPTH_FLAG );
    218       curCost += m_cSingleDepthValueSCModel.calcCost         ( curSliceType, qp, (UChar*)INIT_SINGLE_DEPTH_VALUE_DATA );
    219 #endif
    220164      curCost += m_cCUMergeFlagExtSCModel.calcCost    ( curSliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT);
    221165      curCost += m_cCUMergeIdxExtSCModel.calcCost     ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT);
    222 #if H_3D_ARP
    223       curCost += m_cCUPUARPWSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_ARPW );
    224 #endif
    225 #if H_3D_IC
    226       curCost += m_cCUICFlagSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_IC_FLAG );
    227 #endif
    228 #if H_3D_DIM_SDC
    229       curCost += m_cSDCFlagSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_SDC_FLAG );
    230 #endif
    231 #if H_3D_DBBP
    232       curCost += m_cDBBPFlagSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_DBBP_FLAG );
    233 #endif
    234166      curCost += m_cCUPartSizeSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_PART_SIZE );
    235167      curCost += m_cCUPredModeSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_PRED_MODE );
     
    254186      curCost += m_cTransformSkipSCModel.calcCost     ( curSliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
    255187      curCost += m_CUTransquantBypassFlagSCModel.calcCost( curSliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );
    256 #if H_3D_DIM
    257 #if SEPARATE_FLAG_I0085
    258     if( m_pcSlice->getVpsDepthModesFlag() || m_pcSlice->getIVPFlag() )
    259 #else
    260     if( m_pcSlice->getVpsDepthModesFlag() )
    261 #endif
    262     {
    263       curCost += m_cDepthIntraModeSCModel.calcCost    ( curSliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE );
    264       curCost += m_cDdcFlagSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_DDC_FLAG );
    265       curCost += m_cDdcDataSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_DDC_DATA );
    266       curCost += m_cAngleFlagSCModel.calcCost         ( curSliceType, qp, (UChar*)INIT_ANGLE_FLAG ); 
    267     }
    268 #endif
    269188      if (curCost < bestCost)
    270189      {
     
    291210 
    292211  m_cCUSkipFlagSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG );
    293 #if MTK_SINGLE_DEPTH_MODE_I0095
    294   m_cCUSingleDepthFlagSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SINGLEDEPTH_FLAG );
    295   m_cSingleDepthValueSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_SINGLE_DEPTH_VALUE_DATA );
    296 #endif 
    297212  m_cCUMergeFlagExtSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT);
    298213  m_cCUMergeIdxExtSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT);
    299 #if H_3D_ARP
    300   m_cCUPUARPWSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_ARPW );
    301 #endif
    302 #if H_3D_IC
    303   m_cCUICFlagSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_IC_FLAG );
    304 #endif
    305214  m_cCUPartSizeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
    306215  m_cCUPredModeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );
     
    325234  m_cTransformSkipSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
    326235  m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );
    327 #if H_3D_DIM
    328   m_cDepthIntraModeSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE );
    329   m_cDdcFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG );
    330   m_cDdcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );
    331   m_cAngleFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG );
    332 #if H_3D_DIM_SDC
    333   m_cSDCResidualFlagSCModel.initBuffer   ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
    334   m_cSDCResidualSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL );
    335 #endif
    336 #endif
    337 #if H_3D_DIM_SDC
    338   m_cSDCFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
    339 #endif
    340 #if H_3D_DBBP
    341   m_cDBBPFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG );
    342 #endif
    343236  m_pcBinIf->start();
    344237}
     
    350243}
    351244
    352 #if H_3D
    353 Void TEncSbac::codeSPS( TComSPS* pcSPS, Int viewIndex, Bool depthFlag )
    354 #else
    355245Void TEncSbac::codeSPS( TComSPS* pcSPS )
    356 #endif
    357246{
    358247  assert (0);
     
    454343  m_pcBinIf->encodeBinsEP( bins, numBins );
    455344}
    456 #if MTK_SINGLE_DEPTH_MODE_I0095
    457 Void TEncSbac::codeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx )
    458 {
    459   UInt uiSymbol = pcCU->getSingleDepthFlag(uiAbsPartIdx ) ? 1 : 0;
    460   m_pcBinIf->encodeBin( uiSymbol, m_cCUSingleDepthFlagSCModel.get( 0, 0, 0 ) );
    461   if(uiSymbol)
    462   {
    463     UInt uiUnaryIdx = (UInt) pcCU->getSingleDepthValue(uiAbsPartIdx);
    464     UInt uiNumCand = MTK_SINGLE_DEPTH_MODE_CANDIDATE_LIST_SIZE;
    465     if ( uiNumCand > 1 )
    466     {
    467       for( UInt ui = 0; ui < uiNumCand - 1; ++ui )
    468       {
    469         const UInt uiSymbol2 = ui == uiUnaryIdx ? 0 : 1;
    470         if ( ui==0 )
    471         {
    472           m_pcBinIf->encodeBin( uiSymbol2, m_cSingleDepthValueSCModel.get( 0, 0, 0 ) );
    473         }
    474         else
    475         {
    476           m_pcBinIf->encodeBinEP( uiSymbol2 );
    477         }
    478         if( uiSymbol2 == 0 )
    479         {
    480           break;
    481         }
    482       }
    483     }
    484   }
    485 }
    486 #endif
    487345/** Coding of coeff_abs_level_minus3
    488346 * \param uiSymbol value of coeff_abs_level_minus3
     
    513371}
    514372
    515 #if H_3D_DIM
    516 Void TEncSbac::xWriteExGolombLevel( UInt uiSymbol, ContextModel& rcSCModel  )
    517 {
    518   if( uiSymbol )
    519   {
    520     m_pcBinIf->encodeBin( 1, rcSCModel );
    521     UInt uiCount = 0;
    522     Bool bNoExGo = ( uiSymbol < 3 );
    523 
    524     while( --uiSymbol && ++uiCount < 3 )
    525     {
    526       m_pcBinIf->encodeBin( 1, rcSCModel );
    527     }
    528     if( bNoExGo )
    529     {
    530       m_pcBinIf->encodeBin( 0, rcSCModel );
    531     }
    532     else
    533     {
    534       xWriteEpExGolomb( uiSymbol, 0 );
    535     }
    536   }
    537   else
    538   {
    539     m_pcBinIf->encodeBin( 0, rcSCModel );
    540   }
    541 
    542   return;
    543 }
    544 
    545 Void TEncSbac::xCodeDimDeltaDC( Pel valDeltaDC, UInt uiNumSeg )
    546 {
    547   xWriteExGolombLevel( UInt( abs( valDeltaDC ) - ( uiNumSeg > 1 ? 0 : 1 ) ), m_cDdcDataSCModel.get(0, 0, 0) );
    548   if( valDeltaDC != 0 )
    549   {
    550     UInt uiSign = valDeltaDC > 0 ? 0 : 1;
    551     m_pcBinIf->encodeBinEP( uiSign );
    552   }
    553 }
    554 
    555 #if H_3D_DIM_DMM
    556 Void TEncSbac::xCodeDmm1WedgeIdx( UInt uiTabIdx, Int iNumBit )
    557 {
    558   for ( Int i = 0; i < iNumBit; i++ )
    559   {
    560     m_pcBinIf->encodeBinEP( ( uiTabIdx >> i ) & 1 );
    561   }
    562 }
    563 
    564 #endif
    565 
    566 #if !FIX_TICKET_76
    567 #if H_3D_DIM_SDC
    568 Void TEncSbac::xCodeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment )
    569 {
    570   assert( pcCU->getSlice()->getIsDepth() );
    571   assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
    572   assert( pcCU->getSDCFlag(uiAbsPartIdx) );
    573   assert( uiSegment < 2 );
    574  
    575   Pel segmentDCOffset = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
    576  
    577   UInt uiResidual = segmentDCOffset == 0 ? 0 : 1;
    578   UInt uiSign     = segmentDCOffset < 0 ? 1 : 0;
    579   UInt uiAbsIdx   = abs(segmentDCOffset);
    580 
    581 #if H_3D_DIM_DLT
    582   UInt uiMaxResidualBits = pcCU->getSlice()->getPPS()->getDLT()->getBitsPerDepthValue( pcCU->getSlice()->getLayerIdInVps() );
    583 #else
    584   UInt uiMaxResidualBits = g_bitDepthY;
    585 #endif
    586   assert( uiMaxResidualBits <= g_bitDepthY );
    587  
    588   // residual flag
    589   m_pcBinIf->encodeBin( uiResidual, m_cSDCResidualFlagSCModel.get( 0, 0, 0 ) );
    590 #if H_MV_ENC_DEC_TRAC
    591   DTRACE_CU("sdc_residual_flag[i]", uiResidual)
    592 #endif 
    593  
    594   if (uiResidual)
    595   {
    596     // encode sign bit of residual
    597     m_pcBinIf->encodeBinEP( uiSign );
    598 #if H_MV_ENC_DEC_TRAC
    599     DTRACE_CU("sdc_residual_sign_flag[i]", uiSign)
    600 #endif
    601 #if H_3D_DIM_DLT   
    602     UInt uiNumDepthValues = pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() );
    603 #else
    604     UInt uiNumDepthValues = ((1 << g_bitDepthY)-1);
    605 #endif
    606 
    607     assert(uiAbsIdx <= uiNumDepthValues);
    608    
    609     // encode residual magnitude
    610     uiAbsIdx -= 1;
    611 
    612 #if H_MV_ENC_DEC_TRAC
    613     DTRACE_CU("sdc_residual_abs_minus1[i]", uiAbsIdx)
    614 #endif
    615 
    616     // prefix part
    617     if ( uiAbsIdx == 0 )
    618     {
    619       m_pcBinIf->encodeBin( 0, m_cSDCResidualSCModel.get(0, 0, 0) );
    620     }
    621     else
    622     {
    623       UInt l = uiAbsIdx;
    624       UInt k = 0;
    625       UInt uiPrefixThreshold = ((uiNumDepthValues * 3) >> 2);
    626       while ( l > 0 && k < uiPrefixThreshold )
    627       {
    628         m_pcBinIf->encodeBin( 1, m_cSDCResidualSCModel.get(0, 0, 0) );
    629         l--;
    630         k++;
    631       }
    632       if ( uiAbsIdx < uiPrefixThreshold )
    633       {
    634         m_pcBinIf->encodeBin( 0, m_cSDCResidualSCModel.get(0, 0, 0) );
    635       }     
    636       else
    637       { // suffix part
    638         uiAbsIdx -= uiPrefixThreshold;
    639         UInt uiSuffixLength = numBitsForValue(uiNumDepthValues - uiPrefixThreshold);
    640         UInt uiBitInfo = 0;
    641         for ( Int i = 0; i < uiSuffixLength; i++)
    642         {
    643           uiBitInfo = ( uiAbsIdx & ( 1 << i ) ) >> i;
    644           m_pcBinIf->encodeBinEP( uiBitInfo);
    645         }
    646       }
    647     }
    648    
    649   }
    650 }
    651 #endif
    652 #endif
    653 #endif
    654373
    655374
     
    666385  this->m_cCUIntraPredSCModel      .copyFrom( &pSrc->m_cCUIntraPredSCModel       );
    667386}
    668 #if H_3D_DIM
    669 Void TEncSbac::loadIntraDepthMode( TEncSbac* pSrc)
    670 {
    671   m_pcBinIf->copyState( pSrc->m_pcBinIf );
    672 
    673   this->m_cDepthIntraModeSCModel .copyFrom( &pSrc->m_cDepthIntraModeSCModel );
    674   this->m_cDdcFlagSCModel        .copyFrom( &pSrc->m_cDdcFlagSCModel );
    675   this->m_cAngleFlagSCModel      .copyFrom( &pSrc->m_cAngleFlagSCModel );
    676 }
    677 #endif
    678387
    679388Void  TEncSbac::store( TEncSbac* pDest)
     
    716425{
    717426  PartSize eSize         = pcCU->getPartitionSize( uiAbsPartIdx );
    718 #if H_3D_QTLPC
    719 #if MTK_I0099_VPS_EX2
    720   TComVPS *vps           = pcCU->getPic()->getSlice(0)->getVPS();
    721   Bool    bLimQtPredFlag = vps->getLimQtPredFlag(pcCU->getPic()->getSlice(0)->getLayerId());
    722 #else
    723   TComSPS *sps           = pcCU->getPic()->getSlice(0)->getSPS();
    724 #endif
    725   TComPic *pcTexture     = pcCU->getSlice()->getTexturePic();
    726   Bool bDepthMapDetect   = (pcTexture != NULL);
    727   Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE);
    728  
    729   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);
    730 
    731   Bool depthDependent = false;
    732   UInt uiTexturePart = eSize;
    733 #if MTK_I0099_VPS_EX2
    734 #if LGE_FCO_I0116
    735   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && bLimQtPredFlag && pcTexture->getReconMark())
    736 #else
    737   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && bLimQtPredFlag )
    738 #endif
    739 #else
    740   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && sps->getUseQTL() && sps->getUsePC() )
    741 #endif
    742   {
    743     TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr());
    744     UInt uiCUIdx            = (pcCU->getZorderIdxInCU() == 0) ? uiAbsPartIdx : pcCU->getZorderIdxInCU();
    745     assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth);
    746     if(pcTextureCU->getDepth(uiCUIdx) == uiDepth )
    747     {
    748       depthDependent = true;
    749       uiTexturePart = pcTextureCU->getPartitionSize( uiCUIdx );
    750     }
    751     if (pcTextureCU->getDepth(uiCUIdx) == uiDepth && pcTextureCU->getPartitionSize( uiCUIdx ) == SIZE_2Nx2N)
    752     {
    753       assert( eSize == SIZE_2Nx2N );
    754       return;
    755     }
    756   }
    757 #endif
    758427  if ( pcCU->isIntra( uiAbsPartIdx ) )
    759428  {
     
    771440  DTRACE_CU("part_mode", eSize )
    772441#endif       
    773 #if H_3D_QTLPC
    774     if (depthDependent==false || uiTexturePart == SIZE_NxN|| uiTexturePart == SIZE_2Nx2N)
    775     {
    776 #endif
    777442  switch(eSize)
    778443  {
     
    841506    }
    842507  }
    843 #if H_3D_QTLPC
    844     }
    845     else if(uiTexturePart == SIZE_2NxN || uiTexturePart == SIZE_2NxnU || uiTexturePart == SIZE_2NxnD)
    846     {
    847       //assert(eSize!=SIZE_NxN);
    848       //assert(eSize!=SIZE_Nx2N);
    849       //assert(eSize==SIZE_2Nx2N || eSize==SIZE_2NxN || eSize==SIZE_2NxnU || eSize==SIZE_2NxnD);
    850       switch(eSize)
    851       {
    852       case SIZE_2Nx2N:
    853         {
    854           m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) );
    855           break;
    856         }
    857       case SIZE_2NxN:
    858         {
    859           m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
    860           if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
    861           {     
    862             m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 1) );
    863           }
    864           break;
    865         }
    866       case SIZE_2NxnU:
    867       case SIZE_2NxnD:
    868         {
    869           m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
    870           m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) );
    871           m_pcBinIf->encodeBinEP((eSize == SIZE_2NxnU? 0: 1));
    872           break;
    873         }
    874       default:
    875         {
    876           assert(0);
    877         }
    878       }
    879     }
    880     else if(uiTexturePart == SIZE_Nx2N|| uiTexturePart==SIZE_nLx2N || uiTexturePart==SIZE_nRx2N)
    881     {
    882       //assert(eSize!=SIZE_NxN);
    883       //assert(eSize!=SIZE_2NxN);
    884       //assert(eSize==SIZE_2Nx2N ||eSize==SIZE_Nx2N || eSize==SIZE_nLx2N || eSize==SIZE_nRx2N);
    885       switch(eSize)
    886       {
    887       case SIZE_2Nx2N:
    888         {
    889           m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) );
    890           break;
    891         }
    892       case SIZE_Nx2N:
    893         {
    894           m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
    895           if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
    896           {     
    897             m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 1) );
    898           }
    899           break;
    900         }
    901       case SIZE_nLx2N:
    902       case SIZE_nRx2N:
    903         {
    904           m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
    905           m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) );
    906           m_pcBinIf->encodeBinEP((eSize == SIZE_nLx2N? 0: 1));
    907           break;
    908         }
    909       default:
    910         {
    911           assert(0);
    912         }
    913       }
    914     }
    915     else
    916     {
    917       printf("uiTexturePart=%d",uiTexturePart);
    918       assert(0);
    919     }
    920 #endif
    921508}
    922509
     
    928515Void TEncSbac::codePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx )
    929516{
    930 #if H_3D_DIM_SDC
    931   if ( pcCU->getSlice()->isIntra() )
    932   {
    933     assert( pcCU->isIntra(uiAbsPartIdx) );
    934     return;
    935   }
    936 #endif
    937517 
    938518  // get context function is here
     
    1041621}
    1042622
    1043 #if H_3D_ARP
    1044 Void TEncSbac::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
    1045 {
    1046   Int  iW = (Int)pcCU->getARPW( uiAbsPartIdx );
    1047   Int  iMaxW = pcCU->getSlice()->getARPStepNum() - 1;
    1048   assert( iMaxW > 0);
    1049 
    1050   Int nOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx);
    1051   Int nBinNum = iW + ( iW != iMaxW );
    1052   m_pcBinIf->encodeBin( iW ? 1 : 0 , m_cCUPUARPWSCModel.get( 0, 0, 0 + nOffset ) );
    1053   if( nBinNum > 1 )
    1054   {
    1055      m_pcBinIf->encodeBin( ( iW == iMaxW ) ? 1 : 0, m_cCUPUARPWSCModel.get( 0, 0, 2 ) );
    1056   }
    1057 #if H_MV_ENC_DEC_TRAC
    1058   DTRACE_CU("iv_res_pred_weight_idx", iW);
    1059 #endif
    1060 }
    1061 #endif
    1062 
    1063 #if H_3D_IC
    1064 /** code Illumination Compensation flag
    1065  * \param pcCU
    1066  * \param uiAbsPartIdx
    1067  * \returns Void
    1068  */
    1069 Void TEncSbac::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
    1070 {
    1071   // get context function is here
    1072   UInt uiSymbol = pcCU->getICFlag( uiAbsPartIdx ) ? 1 : 0;
    1073   m_pcBinIf->encodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, 0 ) );
    1074 #if !H_MV_ENC_DEC_TRAC
    1075   DTRACE_CABAC_VL( g_nSymbolCounter++ );
    1076   DTRACE_CABAC_T( "\tICFlag" );
    1077   DTRACE_CABAC_T( "\tuiSymbol: ");
    1078   DTRACE_CABAC_V( uiSymbol );
    1079   DTRACE_CABAC_T( "\n");
    1080 #else
    1081   DTRACE_CU("ic_flag", uiSymbol );
    1082 #endif
    1083 }
    1084 #endif
     623
    1085624
    1086625
     
    1094633 
    1095634  assert( uiCtx < 3 );
    1096 #if H_3D_QTLPC
    1097   Bool bCodeSplitFlag    = true;
    1098 
    1099 #if MTK_I0099_VPS_EX2
    1100   TComVPS *vps           = pcCU->getPic()->getSlice(0)->getVPS();
    1101   Bool    bLimQtPredFlag = vps->getLimQtPredFlag(pcCU->getPic()->getSlice(0)->getLayerId());
    1102 #else
    1103   TComSPS *sps           = pcCU->getPic()->getSlice(0)->getSPS();
    1104 #endif
    1105   TComPic *pcTexture     = pcCU->getSlice()->getTexturePic();
    1106   Bool bDepthMapDetect   = (pcTexture != NULL);
    1107   Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE);
    1108 
    1109   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);
    1110 
    1111 #if MTK_I0099_VPS_EX2
    1112 #if LGE_FCO_I0116
    1113   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && bLimQtPredFlag && pcTexture->getReconMark() )
    1114 #else
    1115   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && bLimQtPredFlag  )
    1116 #endif
    1117 #else
    1118   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && sps->getUseQTL() && sps->getUsePC())
    1119 #endif
    1120   {
    1121     TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr());
    1122     UInt uiCUIdx            = (pcCU->getZorderIdxInCU() == 0) ? uiAbsPartIdx : pcCU->getZorderIdxInCU();
    1123     assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth);
    1124     bCodeSplitFlag          = (pcTextureCU->getDepth(uiCUIdx) > uiDepth);
    1125   }
    1126 
    1127   if(!bCodeSplitFlag)
    1128   {
    1129     assert(uiCurrSplitFlag == 0);
    1130     return;
    1131   }
    1132 #endif
    1133635  m_pcBinIf->encodeBin( uiCurrSplitFlag, m_cCUSplitFlagSCModel.get( 0, 0, uiCtx ) );
    1134636#if !H_MV_ENC_DEC_TRAC
     
    1166668  {
    1167669    dir[j] = pcCU->getLumaIntraDir( absPartIdx+partOffset*j );
    1168 #if H_3D_DIM
    1169 #if SEPARATE_FLAG_I0085
    1170     if( pcCU->getSlice()->getVpsDepthModesFlag() ||  pcCU->getSlice()->getIVPFlag() )
    1171 #else
    1172     if( pcCU->getSlice()->getVpsDepthModesFlag() )
    1173 #endif
    1174     {
    1175       codeIntraDepth( pcCU, absPartIdx+partOffset*j );
    1176     }
    1177     if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
    1178     {
    1179 #endif
    1180670      predNum[j] = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds[j]); 
    1181671      for(UInt i = 0; i < predNum[j]; i++)
     
    1190680      DTRACE_CU("prev_intra_luma_pred_flag", (predIdx[j] != -1)? 1 : 0);
    1191681#endif
    1192 #if H_3D_DIM
    1193     }
    1194 #endif
    1195682
    1196683  } 
    1197684  for (j=0;j<partNum;j++)
    1198685  {
    1199 #if H_3D_DIM
    1200     if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
    1201     {
    1202 #endif
    1203686    if(predIdx[j] != -1)
    1204687    {
     
    1235718#endif
    1236719    }
    1237 #if H_3D_DIM
    1238     }
    1239 #endif
    1240720  }
    1241721  return;
     
    1277757}
    1278758
    1279 #if H_3D_DIM
    1280 Void TEncSbac::codeIntraDepth( TComDataCU* pcCU, UInt absPartIdx )
    1281 {
    1282   codeIntraDepthMode( pcCU, absPartIdx );
    1283 
    1284   UInt dir     = pcCU->getLumaIntraDir( absPartIdx );
    1285   UInt dimType = getDimType( dir );
    1286 
    1287   switch( dimType )
    1288   {
    1289 #if H_3D_DIM_DMM
    1290   case( DMM1_IDX ):
    1291     {
    1292       xCodeDmm1WedgeIdx( pcCU->getDmmWedgeTabIdx( dimType, absPartIdx ), g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] );
    1293     } break;
    1294   case( DMM4_IDX ): break;
    1295 #endif
    1296   default: break;
    1297   }
    1298 }
    1299 
    1300 Void TEncSbac::codeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx )
    1301 {
    1302   UInt dir = pcCU->getLumaIntraDir( absPartIdx );
    1303 
    1304   if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed
    1305   {
    1306     m_pcBinIf->encodeBin( isDimMode( dir ) ? 0 : 1, m_cAngleFlagSCModel.get( 0, 0, 0 ) );
    1307   }
    1308   if( isDimMode( dir ) )
    1309   {
    1310     UInt uiCodeIdx = 0;
    1311 
    1312     switch( getDimType( dir ) )
    1313     {
    1314     case DMM1_IDX: uiCodeIdx = 0; break;
    1315     case DMM4_IDX: uiCodeIdx = 1; break;
    1316     default:                      break;
    1317     }
    1318     //mode coding
    1319 #if SEPARATE_FLAG_I0085
    1320     if( pcCU->getSlice()->getVpsDepthModesFlag() && pcCU->getSlice()->getIVPFlag())
    1321     {
    1322       m_pcBinIf->encodeBin( uiCodeIdx == 0 ? 0 : 1, m_cDepthIntraModeSCModel.get( 0, 0, 0 ) );
    1323     }
    1324 #else
    1325     m_pcBinIf->encodeBin( uiCodeIdx == 0 ? 0 : 1, m_cDepthIntraModeSCModel.get( 0, 0, 0 ) );
    1326 #endif
    1327   }
    1328 }
    1329 #endif
    1330759
    1331760
     
    23601789}
    23611790
    2362 #if H_3D_INTER_SDC
    2363 Void TEncSbac::codeDeltaDC( TComDataCU* pcCU, UInt absPartIdx )
    2364 {
    2365   if( !( pcCU->getSDCFlag( absPartIdx ) || ( pcCU->isIntra( absPartIdx ) && getDimType( pcCU->getLumaIntraDir( absPartIdx ) ) < DIM_NUM_TYPE ) ) )
    2366   {
    2367     assert( 0 );
    2368   }
    2369 
    2370 #if HS_DMM_SIGNALLING_I0120
    2371   UInt uiNumSegments = isDimMode( pcCU->getLumaIntraDir( absPartIdx ) ) ? 2 : 1;
    2372   UInt dimDeltaDC = 1;
    2373 #else
    2374   UInt uiNumSegments = 0;
    2375   UInt dimDeltaDC = 0;
    2376 #endif
    2377 
    2378 #if HS_DMM_SIGNALLING_I0120
    2379   if( pcCU->isIntra( absPartIdx ) && pcCU->getSDCFlag( absPartIdx ))
    2380   {
    2381 #else
    2382   if( pcCU->isIntra( absPartIdx ) )
    2383   {
    2384     UInt dir     = pcCU->getLumaIntraDir( absPartIdx );
    2385     uiNumSegments = isDimMode( dir ) ? 2 : 1;
    2386 
    2387     if( pcCU->getSDCFlag( absPartIdx ) )
    2388     {
    2389 #endif
    2390       if( uiNumSegments == 1 )
    2391       {
    2392         dimDeltaDC = pcCU->getSDCSegmentDCOffset( 0, absPartIdx ) ? 1 : 0;
    2393       }
    2394       else
    2395       {
    2396         dimDeltaDC = ( pcCU->getSDCSegmentDCOffset( 0, absPartIdx ) || pcCU->getSDCSegmentDCOffset( 1, absPartIdx ) ) ? 1 : 0;
    2397       }
    2398 #if !HS_DMM_SIGNALLING_I0120
    2399     }
    2400     else
    2401     {
    2402       dimDeltaDC = isDimDeltaDC( dir );
    2403     }
    2404 #endif
    2405     m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get( 0, 0, 0 ) );
    2406   }
    2407 #if !HS_DMM_SIGNALLING_I0120
    2408   else //all-zero inter SDC is not allowed
    2409   {
    2410     uiNumSegments = 1;
    2411     dimDeltaDC = 1;
    2412   }
    2413 #endif
    2414 
    2415   if( dimDeltaDC )
    2416   {
    2417     for( UInt segment = 0; segment < uiNumSegments; segment++ )
    2418     {
    2419       Pel deltaDC = 0;
    2420 
    2421       if( pcCU->isIntra( absPartIdx ) )
    2422       {
    2423         UInt dir     = pcCU->getLumaIntraDir( absPartIdx );
    2424         deltaDC = pcCU->getSDCFlag( absPartIdx ) ? pcCU->getSDCSegmentDCOffset( segment, absPartIdx ) : pcCU->getDimDeltaDC( getDimType( dir ), segment, absPartIdx );
    2425       }
    2426       else
    2427       {
    2428         deltaDC = pcCU->getSDCSegmentDCOffset( segment, absPartIdx );
    2429       }
    2430 
    2431       xCodeDimDeltaDC( deltaDC, uiNumSegments );
    2432     }
    2433   }
    2434 }
    2435 
    2436 Void TEncSbac::codeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
    2437 {
    2438   UInt uiSymbol = pcCU->getSDCFlag( uiAbsPartIdx ) ? 1 : 0;
    2439   UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx );
    2440 
    2441   m_pcBinIf->encodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) );
    2442 }
    2443 
    2444 #endif
    2445 
    2446 #if H_3D_DBBP
    2447 Void TEncSbac::codeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
    2448 {
    2449 #if SEC_DBBP_EXPLICIT_SIG_I0077
    2450   PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
    2451   AOF( ePartSize == SIZE_2NxN || ePartSize == SIZE_Nx2N );
    2452 #endif
    2453   AOF( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) );
    2454   AOF( !pcCU->getSlice()->getIsDepth() );
    2455  
    2456   UInt uiSymbol = pcCU->getDBBPFlag( uiAbsPartIdx ) ? 1 : 0;
    2457   m_pcBinIf->encodeBin( uiSymbol, m_cDBBPFlagSCModel.get( 0, 0, 0 ) );
    2458 }
    2459 #endif
     1791
    24601792
    24611793//! \}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncSbac.h

    r1039 r1072  
    8484  Void  load                   ( TEncSbac* pScr  );
    8585  Void  loadIntraDirModeLuma   ( TEncSbac* pScr  );
    86 #if H_3D_DIM
    87   Void  loadIntraDepthMode     ( TEncSbac* pScr  );
    88 #endif
    8986  Void  store                  ( TEncSbac* pDest );
    9087  Void  loadContexts           ( TEncSbac* pScr  );
     
    9491
    9592  Void  codeVPS                 ( TComVPS* pcVPS );
    96 #if !H_3D
    9793  Void  codeSPS                 ( TComSPS* pcSPS     );
    98 #else
    99   Void  codeSPS                 ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag );
    100 #endif
    10194  Void  codePPS                 ( TComPPS* pcPPS     );
    10295  Void  codeSliceHeader         ( TComSlice* pcSlice );
     
    124117  Void  xWriteEpExGolomb     ( UInt uiSymbol, UInt uiCount );
    125118  Void  xWriteCoefRemainExGolomb ( UInt symbol, UInt &rParam );
    126 #if H_3D_DIM
    127   Void  xWriteExGolombLevel  ( UInt uiSymbol, ContextModel& rcSCModel  );
    128   Void  xCodeDimDeltaDC      ( Pel valDeltaDC, UInt uiNumSeg );
    129 #if H_3D_DIM_DMM
    130   Void  xCodeDmm1WedgeIdx    ( UInt uiTabIdx, Int iNumBit );
    131 #endif
    132 #if !FIX_TICKET_76
    133 #if H_3D_DIM_SDC
    134   Void  xCodeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment );
    135 #endif
    136 #endif
    137 #endif
    138119 
    139120  Void  xCopyFrom            ( TEncSbac* pSrc );
     
    155136  Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx );
    156137  Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    157 #if MTK_SINGLE_DEPTH_MODE_I0095
    158   Void codeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx );
    159 #endif
    160138  Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    161139  Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    162 #if H_3D_ARP
    163   Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    164 #endif
    165 #if H_3D_IC
    166   Void codeICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    167 #endif
    168 #if H_3D_INTER_SDC
    169   Void codeDeltaDC       ( TComDataCU* pcCU, UInt absPartIdx );
    170   Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    171 #endif
    172 #if H_3D_DBBP
    173   Void codeDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    174 #endif
    175140  Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    176141  Void codeMVPIdx        ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
     
    188153  Void codeIntraDirChroma      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    189154
    190 #if H_3D_DIM
    191   Void codeIntraDepth          ( TComDataCU* pcCU, UInt absPartIdx );
    192   Void codeIntraDepthMode      ( TComDataCU* pcCU, UInt absPartIdx );
    193 #endif
    194155
    195156  Void codeInterDir            ( TComDataCU* pcCU, UInt uiAbsPartIdx );
     
    224185  ContextModel3DBuffer m_cCUSplitFlagSCModel;
    225186  ContextModel3DBuffer m_cCUSkipFlagSCModel;
    226 #if MTK_SINGLE_DEPTH_MODE_I0095
    227   ContextModel3DBuffer m_cCUSingleDepthFlagSCModel;
    228   ContextModel3DBuffer m_cSingleDepthValueSCModel;
    229 #endif
    230187  ContextModel3DBuffer m_cCUMergeFlagExtSCModel;
    231188  ContextModel3DBuffer m_cCUMergeIdxExtSCModel;
    232 #if H_3D_ARP
    233   ContextModel3DBuffer m_cCUPUARPWSCModel;
    234 #endif
    235 #if H_3D_IC
    236   ContextModel3DBuffer m_cCUICFlagSCModel;
    237 #endif
    238189  ContextModel3DBuffer m_cCUPartSizeSCModel;
    239190  ContextModel3DBuffer m_cCUPredModeSCModel;
     
    262213  ContextModel3DBuffer m_CUTransquantBypassFlagSCModel;
    263214
    264 #if H_3D_DIM
    265   ContextModel3DBuffer m_cDepthIntraModeSCModel;
    266   ContextModel3DBuffer m_cDdcFlagSCModel;
    267   ContextModel3DBuffer m_cDdcDataSCModel;
    268   ContextModel3DBuffer m_cAngleFlagSCModel;
    269 #if H_3D_DIM_SDC 
    270   ContextModel3DBuffer m_cSDCResidualFlagSCModel;
    271   ContextModel3DBuffer m_cSDCResidualSCModel;
    272 #endif
    273 #endif
    274 #if H_3D_DIM_SDC
    275   ContextModel3DBuffer m_cSDCFlagSCModel;
    276 #endif
    277 #if H_3D_DBBP
    278   ContextModel3DBuffer m_cDBBPFlagSCModel;
    279 #endif
    280215};
    281216
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncSearch.cpp

    r1066 r1072  
    4141#include "TEncSearch.h"
    4242#include <math.h>
    43 #if H_3D_INTER_SDC
    44 #include <memory.h>
    45 #endif
    4643
    4744//! \ingroup TLibEncoder
     
    318315 
    319316  piRefSrch = rcStruct.piRefY + iSearchY * rcStruct.iYStride + iSearchX;
    320 #if H_3D_IC
    321   m_cDistParam.bUseIC = pcPatternKey->getICFlag();
    322 #endif
    323 #if H_3D_INTER_SDC
    324   m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
    325 #endif
    326317  //-- jclee for using the SAD function pointer
    327318  m_pcRdCost->setDistParam( pcPatternKey, piRefSrch, rcStruct.iYStride,  m_cDistParam );
     
    750741
    751742    setDistParamComp(0);  // Y component
    752 #if H_3D_IC
    753     m_cDistParam.bUseIC = pcPatternKey->getICFlag();
    754 #endif
    755 #if H_3D_INTER_SDC
    756     m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
    757 #endif
    758743    m_cDistParam.pCur = piRefPos;
    759744    m_cDistParam.bitDepth = g_bitDepthY;
     
    915900        }
    916901        m_pcEntropyCoder->encodeSkipFlag( pcCU, 0, true );
    917 #if MTK_SINGLE_DEPTH_MODE_I0095
    918         m_pcEntropyCoder->encodeSingleDepthMode(pcCU, 0, true );
    919         if(!pcCU->getSingleDepthFlag(uiAbsPartIdx))
    920 #endif
    921902        m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
    922903      }
    923 #if MTK_SINGLE_DEPTH_MODE_I0095
    924       else
    925       {
    926         m_pcEntropyCoder->encodeSingleDepthMode(pcCU, 0, true );
    927       }
    928 #endif     
    929 #if MTK_SINGLE_DEPTH_MODE_I0095
    930       if(!pcCU->getSingleDepthFlag(uiAbsPartIdx))
    931       {
    932 #endif
    933904      m_pcEntropyCoder  ->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
    934905
    935 #if H_3D_DIM_SDC
    936       m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
    937 #endif
    938906      if (pcCU->isIntra(0) && pcCU->getPartitionSize(0) == SIZE_2Nx2N )
    939907      {
     
    945913        }
    946914      }
    947 #if MTK_SINGLE_DEPTH_MODE_I0095
    948     }
    949 #endif
    950     }
    951 #if MTK_SINGLE_DEPTH_MODE_I0095
    952       if(!pcCU->getSingleDepthFlag(uiAbsPartIdx))
    953       {
    954 #endif
     915    }
    955916    // luma prediction mode
    956917    if( pcCU->getPartitionSize(0) == SIZE_2Nx2N )
     
    959920      {
    960921        m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, 0 );
    961 #if H_3D_DIM_SDC
    962         if( pcCU->getSlice()->getIsDepth() && ( !pcCU->getSDCFlag( 0 ) ) && getDimType( pcCU->getLumaIntraDir( 0 ) ) < DIM_NUM_TYPE )
    963         {
    964           m_pcEntropyCoder->encodeDeltaDC( pcCU, 0 );
    965         }
    966 #endif
    967922      }
    968923    }
     
    976931        {
    977932          m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, uiPart * uiQNumParts );
    978 #if H_3D_DIM_SDC
    979           if( pcCU->getSlice()->getIsDepth() && ( !pcCU->getSDCFlag( uiPart * uiQNumParts ) ) && getDimType( pcCU->getLumaIntraDir( uiPart * uiQNumParts ) ) < DIM_NUM_TYPE )
    980           {
    981             m_pcEntropyCoder->encodeDeltaDC( pcCU, uiPart * uiQNumParts );
    982           }
    983 #endif
    984933        }
    985934      }
     
    987936      {
    988937        m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, uiAbsPartIdx );
    989 #if H_3D_DIM_SDC
    990         if( pcCU->getSlice()->getIsDepth() && ( !pcCU->getSDCFlag( uiAbsPartIdx ) ) && getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx ) ) < DIM_NUM_TYPE )
    991         {
    992           m_pcEntropyCoder->encodeDeltaDC( pcCU, uiAbsPartIdx );
    993       }
    994 #endif
    995     }
    996   }
    997 #if MTK_SINGLE_DEPTH_MODE_I0095
    998     }
    999 #endif
     938    }
     939  }
    1000940  }
    1001941  if( bChroma )
     
    10631003                                TComYuv*    pcPredYuv,
    10641004                                TComYuv*    pcResiYuv,
    1065 #if H_3D_VSO
    1066                                 Dist&       ruiDist,
    1067 #else
    10681005                                UInt&       ruiDist,
    1069 #endif
    10701006                                Int        default0Save1Load2
    1071 #if H_3D_DIM_ENC
    1072                                 , Bool       zeroResi
    1073 #endif
    10741007                                )
    10751008{
     
    11061039    pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
    11071040    //===== get prediction signal =====
    1108 #if H_3D_DIM
    1109     if( isDimMode( uiLumaPredMode ) )
    1110     {
    1111       predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, true );
    1112     }
    1113     else
    1114     {
    1115 #endif
    11161041    predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
    1117 #if H_3D_DIM
    1118     }
    1119 #endif
    11201042    // save prediction
    11211043    if(default0Save1Load2 == 1)
     
    11571079    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    11581080    {
    1159 #if H_3D_DIM_ENC
    1160       if( zeroResi )
    1161       {
    1162         memset( pResi, 0, sizeof( Pel ) * uiWidth );
    1163         pResi += uiStride;
    1164       }
    1165       else
    1166       {
    1167 #endif
    11681081        for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    11691082        {
     
    11731086        pResi += uiStride;
    11741087        pPred += uiStride;
    1175 #if H_3D_DIM_ENC
    1176       }
    1177 #endif
    11781088    }
    11791089  }
     
    12451155 
    12461156  //===== update distortion =====
    1247 #if H_3D_VSO // M39
    1248   if ( m_pcRdCost->getUseVSO() ) 
    1249       ruiDist += m_pcRdCost->getDistPartVSO  ( pcCU, uiAbsPartIdx, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, false ); 
    1250   else
    1251 #endif
    12521157  ruiDist += m_pcRdCost->getDistPart(g_bitDepthY, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight );
    12531158}
     
    13061211  {
    13071212    uiChromaPredMode          = pcCU->getLumaIntraDir( 0 );
    1308 #if H_3D_DIM
    1309     mapDepthModeToIntraDir( uiChromaPredMode );
    1310 #endif
    13111213  }
    13121214 
     
    14611363                                TComYuv*     pcPredYuv,
    14621364                                TComYuv*     pcResiYuv,
    1463 #if H_3D_VSO
    1464                                 Dist&        ruiDistY,
    1465 #else
    14661365                                UInt&        ruiDistY,
    1467 #endif
    14681366                                UInt&        ruiDistC,
    14691367#if HHI_RQT_INTRA_SPEEDUP
     
    14711369#endif
    14721370                                Double&      dRDCost
    1473 #if H_3D_DIM_ENC
    1474                                 , Bool        zeroResi
    1475 #endif                               
    14761371)
    14771372{
     
    15101405  }
    15111406#endif
    1512 #if H_3D_DIM
    1513   if( isDimMode( pcCU->getLumaIntraDir( uiAbsPartIdx ) ) )
    1514   {
    1515     bCheckSplit = false;
    1516   }
    1517 #endif
    15181407  Double  dSingleCost   = MAX_DOUBLE;
    1519 #if H_3D_VSO
    1520   Dist    uiSingleDistY = 0;
    1521 #else
    15221408  UInt    uiSingleDistY = 0;
    1523 #endif
    15241409  UInt    uiSingleDistC = 0;
    15251410  UInt    uiSingleCbfY  = 0;
     
    15431428      //----- store original entropy coding status -----
    15441429        m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] );
    1545 #if H_3D_VSO
    1546       Dist   singleDistYTmp     = 0;
    1547 #else
    15481430      UInt   singleDistYTmp     = 0;
    1549 #endif
    15501431      UInt   singleDistCTmp     = 0;
    15511432      UInt   singleCbfYTmp      = 0;
     
    15971478        {
    15981479          UInt uiSingleBits = xGetIntraBitsQT( pcCU, uiTrDepth, uiAbsPartIdx, true, !bLumaOnly, false );
    1599 #if H_3D_VSO // M NEW
    1600           if ( m_pcRdCost->getUseRenModel() )
    1601             singleCostTmp     = m_pcRdCost->calcRdCostVSO( uiSingleBits, singleDistYTmp + singleDistCTmp );
    1602           else
    1603 #endif
    16041480          singleCostTmp     = m_pcRdCost->calcRdCost( uiSingleBits, singleDistYTmp + singleDistCTmp );
    16051481        }
     
    16721548      //----- code luma block with given intra prediction mode and store Cbf-----
    16731549      dSingleCost   = 0.0;
    1674 #if H_3D_DIM_ENC
    1675       xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, uiSingleDistY, 0, zeroResi );
    1676 #else
    16771550      xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, uiSingleDistY );
    1678 #endif
    16791551      if( bCheckSplit )
    16801552      {
     
    17001572        uiSingleBits=uiSingleBits*4;
    17011573      }
    1702 #if H_3D_VSO // M40
    1703       if ( m_pcRdCost->getUseLambdaScaleVSO())     
    1704         dSingleCost = m_pcRdCost->calcRdCostVSO( uiSingleBits, uiSingleDistY + uiSingleDistC );     
    1705       else
    1706 #endif
    17071574      dSingleCost       = m_pcRdCost->calcRdCost( uiSingleBits, uiSingleDistY + uiSingleDistC );
    17081575    }
     
    17241591    //----- code splitted block -----
    17251592    Double  dSplitCost      = 0.0;
    1726 #if H_3D_VSO
    1727     Dist    uiSplitDistY    = 0;
    1728 #else
    17291593    UInt    uiSplitDistY    = 0;
    1730 #endif
    17311594    UInt    uiSplitDistC    = 0;
    17321595    UInt    uiQPartsDiv     = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
     
    17701633    //----- determine rate and r-d cost -----
    17711634    UInt uiSplitBits = xGetIntraBitsQT( pcCU, uiTrDepth, uiAbsPartIdx, true, !bLumaOnly, false );
    1772 #if H_3D_VSO // M41
    1773     if( m_pcRdCost->getUseLambdaScaleVSO() )   
    1774       dSplitCost = m_pcRdCost->calcRdCostVSO( uiSplitBits, uiSplitDistY + uiSplitDistC );   
    1775     else
    1776 #endif
    17771635    dSplitCost       = m_pcRdCost->calcRdCost( uiSplitBits, uiSplitDistY + uiSplitDistC );
    17781636   
     
    18431701    }
    18441702  }
    1845 #if H_3D_VSO // M42
    1846   if ( m_pcRdCost->getUseRenModel() && bCheckFull )
    1847   {
    1848     UInt  uiWidth     = pcCU->getWidth ( 0 ) >> uiTrDepth;
    1849     UInt  uiHeight    = pcCU->getHeight( 0 ) >> uiTrDepth;
    1850     UInt  uiQTLayer   = pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - uiLog2TrSize;
    1851     Pel*  piSrc       = m_pcQTTempTComYuv[ uiQTLayer ].getLumaAddr( uiAbsPartIdx );
    1852     UInt  uiSrcStride = m_pcQTTempTComYuv[ uiQTLayer ].getStride  ();
    1853 
    1854     m_pcRdCost->setRenModelData( pcCU, uiAbsPartIdx, piSrc, (Int) uiSrcStride, (Int) uiWidth, (Int) uiHeight );
    1855   }
    1856 #endif
    18571703  ruiDistY += uiSingleDistY;
    18581704  ruiDistC += uiSingleDistC;
    18591705  dRDCost  += dSingleCost;
    18601706}
    1861 #if MTK_SINGLE_DEPTH_MODE_I0095
    1862 Void TEncSearch::xIntraCodingSingleDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Int iTestDepthIdx, Pel *DepthNeighbor )
    1863 {
    1864   UInt    uiWidth           = pcCU     ->getWidth   ( 0 );
    1865   UInt    uiHeight          = pcCU     ->getHeight  ( 0 );
    1866   UInt    uiStride          = pcOrgYuv ->getStride  ();
    1867   Pel*    piOrg             = pcOrgYuv ->getLumaAddr( uiAbsPartIdx );
    1868   Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
    1869 
    1870   AOF( uiWidth == uiHeight );
    1871   AOF( uiAbsPartIdx == 0 );
    1872   pcCU->setSingleDepthValueSubParts((Pel)iTestDepthIdx,uiAbsPartIdx, 0, pcCU->getDepth(0)); 
    1873   //===== reconstruction =====
    1874 
    1875   for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    1876   {
    1877     for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    1878     {
    1879     piPred[ uiX ] = DepthNeighbor[iTestDepthIdx];
    1880     }
    1881     piPred     += uiStride;
    1882   }
    1883 
    1884   // clear UV
    1885   UInt  uiStrideC     = pcPredYuv->getCStride();
    1886   Pel   *pRecCb       = pcPredYuv->getCbAddr();
    1887   Pel   *pRecCr       = pcPredYuv->getCrAddr();
    1888 
    1889   for (Int y=0; y<uiHeight/2; y++)
    1890   {
    1891     for (Int x=0; x<uiWidth/2; x++)
    1892     {
    1893       pRecCb[x] = 1<<(g_bitDepthC-1);
    1894       pRecCr[x] = 1<<(g_bitDepthC-1);
    1895     }
    1896 
    1897     pRecCb += uiStrideC;
    1898     pRecCr += uiStrideC;
    1899   }
    1900 
    1901   piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
    1902   //===== determine distortion =====
    1903 #if H_3D_VSO
    1904   if ( m_pcRdCost->getUseVSO() )
    1905     ruiDist = m_pcRdCost->getDistPartVSO  ( pcCU, uiAbsPartIdx, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, false );
    1906   else
    1907 #endif
    1908     ruiDist = m_pcRdCost->getDistPart(g_bitDepthY, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight );
    1909 
    1910   //===== determine rate and r-d cost =====
    1911   m_pcEntropyCoder->resetBits();
    1912   m_pcEntropyCoder->encodeSingleDepthMode( pcCU, 0, true );
    1913   UInt uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    1914 
    1915 #if H_3D_VSO
    1916   if ( m_pcRdCost->getUseLambdaScaleVSO())
    1917     dRDCost = m_pcRdCost->calcRdCostVSO( uiBits, ruiDist );
    1918   else
    1919 #endif
    1920     dRDCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
    1921 }
    1922 #endif
    1923 #if H_3D_DIM_SDC
    1924 Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi  )
    1925 {
    1926   UInt    uiLumaPredMode    = pcCU     ->getLumaIntraDir( uiAbsPartIdx );
    1927   UInt    uiWidth           = pcCU     ->getWidth   ( 0 );
    1928   UInt    uiHeight          = pcCU     ->getHeight  ( 0 );
    1929   TComWedgelet* dmm4SegmentationOrg = new TComWedgelet( uiWidth, uiHeight );
    1930   UInt numParts = 1;
    1931   UInt sdcDepth = 0;
    1932   UInt uiStride;         
    1933   Pel* piOrg;         
    1934   Pel* piPred;         
    1935   Pel* piReco;       
    1936 
    1937   UInt uiZOrder;         
    1938   Pel* piRecIPred;       
    1939   UInt uiRecIPredStride;
    1940 
    1941   if ( ( uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) > 1 )
    1942   {
    1943     numParts = uiWidth * uiWidth >> ( 2 * pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() );
    1944     sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
    1945     uiWidth = uiHeight = ( 1 << pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() );
    1946   }
    1947 
    1948   for ( Int i = 0; i < numParts; i++ )
    1949   {
    1950     uiStride          = pcOrgYuv ->getStride  ();
    1951     piOrg             = pcOrgYuv ->getLumaAddr( uiAbsPartIdx );
    1952     piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
    1953     piReco            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
    1954 
    1955     uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
    1956     piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
    1957     uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
    1958 
    1959     AOF( uiWidth == uiHeight );
    1960 
    1961     //===== init availability pattern =====
    1962     Bool  bAboveAvail = false;
    1963     Bool  bLeftAvail  = false;
    1964     pcCU->getPattern()->initPattern   ( pcCU, sdcDepth, uiAbsPartIdx );
    1965     pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, sdcDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
    1966     TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
    1967     //===== get prediction signal =====
    1968     if( isDimMode( uiLumaPredMode ) )
    1969     {
    1970       UInt dimType   = getDimType  ( uiLumaPredMode );
    1971       UInt patternID = pcCU->getDmmWedgeTabIdx(dimType, uiAbsPartIdx);
    1972 #if SHARP_DMM1_I0110
    1973       UInt uiBaseWidth = pcCU->isDMM1UpscaleMode(uiWidth) ? pcCU->getDMM1BasePatternWidth(uiWidth) : uiWidth;
    1974       if ( patternID >= g_dmmWedgeLists[g_aucConvertToBit[uiBaseWidth]].size() && dimType == DMM1_IDX )
    1975 #else
    1976       if ( patternID >= g_dmmWedgeLists[g_aucConvertToBit[uiWidth]].size() && dimType == DMM1_IDX )
    1977 #endif
    1978       {
    1979 #if SHARP_DMM1_I0110
    1980         if (g_aucConvertToBit[uiBaseWidth] == 2) // Encoder method. Avoid DMM1 pattern list index exceeds the maximum DMM1 pattern number when SDC split is used.
    1981 #else
    1982         if (g_aucConvertToBit[uiWidth] == 2) // Encoder method. Avoid DMM1 pattern list index exceeds the maximum DMM1 pattern number when SDC split is used.
    1983 #endif
    1984         {                                   
    1985           patternID = 1349;  // Split 32x32 to 16x16. 1349: Maximum DMM1 pattern number when block size is 16x16
    1986         }
    1987         else
    1988         {
    1989           patternID = patternID >> 1;  // Other cases
    1990         }
    1991         pcCU->setDmmWedgeTabIdx(dimType, uiAbsPartIdx, patternID);
    1992       }
    1993       predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, true , dmm4Segmentation    );
    1994       Bool* dmm4PatternSplit = dmm4Segmentation->getPattern();
    1995       Bool* dmm4PatternOrg = dmm4SegmentationOrg->getPattern();
    1996       for( UInt k = 0; k < (uiWidth*uiHeight); k++ )
    1997       {
    1998         dmm4PatternOrg[k+(uiAbsPartIdx<<4)] = dmm4PatternSplit[k];
    1999       }
    2000     }
    2001     else
    2002     {
    2003       predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
    2004     }
    2005     if ( numParts > 1 )
    2006     {
    2007       for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    2008       {
    2009         for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    2010         {
    2011           piPred        [ uiX ] = ClipY( piPred[ uiX ] );
    2012           piRecIPred    [ uiX ] = piPred[ uiX ];
    2013         }
    2014         piPred     += uiStride;
    2015         piRecIPred += uiRecIPredStride;
    2016       }
    2017     }
    2018     uiAbsPartIdx += ( ( uiWidth * uiWidth ) >> 4 );
    2019     dmm4Segmentation->destroy(); delete dmm4Segmentation;
    2020   }
    2021   uiAbsPartIdx = 0;
    2022   uiStride          = pcOrgYuv ->getStride  ();
    2023   piOrg             = pcOrgYuv ->getLumaAddr( uiAbsPartIdx );
    2024   piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
    2025   piReco            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
    2026 
    2027   uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
    2028   piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
    2029   uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
    2030 
    2031   if (numParts > 1)
    2032   {
    2033     uiWidth = pcCU->getWidth( 0 );
    2034     uiHeight = pcCU->getHeight( 0 );
    2035   }
    2036   // number of segments depends on prediction mode
    2037   UInt uiNumSegments = 1;
    2038   Bool* pbMask = NULL;
    2039   UInt uiMaskStride = 0;
    2040 
    2041   if( getDimType( uiLumaPredMode ) == DMM1_IDX )
    2042   {
    2043     Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx);
    2044 
    2045 #if SHARP_DMM1_I0110
    2046     WedgeList* pacWedgeList  = pcCU->isDMM1UpscaleMode( uiWidth ) ? &g_dmmWedgeLists[(g_aucConvertToBit[pcCU->getDMM1BasePatternWidth(uiWidth)])] : &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
    2047 #else
    2048     WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
    2049 #endif
    2050     TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
    2051 
    2052     uiNumSegments = 2;
    2053 #if SHARP_DMM1_I0110
    2054     pbMask       = pcCU->isDMM1UpscaleMode( uiWidth ) ? pcWedgelet->getScaledPattern( uiWidth ) : pcWedgelet->getPattern();
    2055     uiMaskStride = pcCU->isDMM1UpscaleMode( uiWidth ) ? uiWidth : pcWedgelet->getStride();
    2056 #else
    2057     pbMask = pcWedgelet->getPattern();
    2058     uiMaskStride = pcWedgelet->getStride();
    2059 #endif
    2060   }
    2061   if( getDimType( uiLumaPredMode ) == DMM4_IDX )
    2062   {
    2063     uiNumSegments = 2;
    2064     pbMask       = dmm4SegmentationOrg->getPattern();
    2065     uiMaskStride = dmm4SegmentationOrg->getStride();
    2066   }
    2067 
    2068   // get DC prediction for each segment
    2069   Pel apDCPredValues[2];
    2070   if ( getDimType( uiLumaPredMode ) == DMM1_IDX || getDimType( uiLumaPredMode ) == DMM4_IDX )
    2071   {
    2072     apDCPredValues[0] = pcCU->getDmmPredictor( 0 );
    2073     apDCPredValues[1] = pcCU->getDmmPredictor( 1 );
    2074   }
    2075   else
    2076   {
    2077     analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode );
    2078   }
    2079 
    2080 
    2081   // get original DC for each segment
    2082   Pel apDCOrigValues[2];
    2083   analyzeSegmentsSDC(piOrg, uiStride, uiWidth, apDCOrigValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode, true );
    2084 
    2085   for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
    2086   {
    2087     // remap reconstructed value to valid depth values
    2088     Pel pDCRec = ( !bZeroResidual ) ? apDCOrigValues[uiSegment] : apDCPredValues[uiSegment];
    2089     // get residual (idx)
    2090 #if H_3D_DIM_DLT
    2091     Pel pResidualIdx = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pDCRec ) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
    2092 #else
    2093     Pel pResidualIdx = pDCRec - apDCPredValues[uiSegment];
    2094 #endif
    2095     if( !bZeroResidual )
    2096     {
    2097       Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
    2098       Int   pTestIdx    = pPredIdx + pResidualIdx + iSDCDeltaResi;
    2099       if( pTestIdx >= 0 && pTestIdx < pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) )
    2100       {
    2101         pResidualIdx += iSDCDeltaResi;
    2102       }
    2103     }
    2104     // save SDC DC offset
    2105     pcCU->setSDCSegmentDCOffset(pResidualIdx, uiSegment, uiAbsPartIdx);
    2106   }
    2107 
    2108   // reconstruct residual based on mask + DC residuals
    2109   Pel apDCResiValues[2];
    2110   for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
    2111   {
    2112 #if H_3D_DIM_DLT
    2113     Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
    2114     Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
    2115     Pel   pRecoValue  = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
    2116 
    2117     apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
    2118 #else
    2119     apDCResiValues[uiSegment]  = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
    2120 #endif
    2121   }
    2122 
    2123   //===== reconstruction =====
    2124   Bool* pMask     = pbMask;
    2125   Pel* pPred      = piPred;
    2126   Pel* pReco      = piReco;
    2127   Pel* pRecIPred  = piRecIPred;
    2128 
    2129   for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    2130   {
    2131     for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    2132     {
    2133       UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
    2134       assert( ucSegment < uiNumSegments );
    2135 
    2136       Pel pResiDC = apDCResiValues[ucSegment];
    2137 
    2138       pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResiDC );
    2139       pRecIPred[ uiX ] = pReco[ uiX ];
    2140     }
    2141     pPred     += uiStride;
    2142     pReco     += uiStride;
    2143     pRecIPred += uiRecIPredStride;
    2144     pMask     += uiMaskStride;
    2145   }
    2146 
    2147   // clear UV
    2148   UInt  uiStrideC     = pcPredYuv->getCStride();
    2149   Pel   *pRecCb       = pcPredYuv->getCbAddr();
    2150   Pel   *pRecCr       = pcPredYuv->getCrAddr();
    2151 
    2152   for (Int y=0; y<uiHeight/2; y++)
    2153   {
    2154     for (Int x=0; x<uiWidth/2; x++)
    2155     {
    2156       pRecCb[x] = 128;
    2157       pRecCr[x] = 128;
    2158     }
    2159 
    2160     pRecCb += uiStrideC;
    2161     pRecCr += uiStrideC;
    2162   }
    2163 
    2164   //===== determine distortion =====
    2165 #if H_3D_VSO
    2166   if ( m_pcRdCost->getUseVSO() )
    2167     ruiDist = m_pcRdCost->getDistPartVSO  ( pcCU, uiAbsPartIdx, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, false );
    2168   else
    2169 #endif
    2170     ruiDist = m_pcRdCost->getDistPart(g_bitDepthY, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight );
    2171 
    2172   //===== determine rate and r-d cost =====
    2173   m_pcEntropyCoder->resetBits();
    2174 
    2175   // encode reduced intra header
    2176   if( !pcCU->getSlice()->isIntra() )
    2177   {
    2178     if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
    2179     {
    2180       m_pcEntropyCoder->encodeCUTransquantBypassFlag( pcCU, 0, true );
    2181     }
    2182     m_pcEntropyCoder->encodeSkipFlag( pcCU, 0, true );
    2183     m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
    2184   }
    2185 
    2186   m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth( 0 ), true );
    2187   m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
    2188 
    2189   // encode pred direction + DC residual data
    2190   m_pcEntropyCoder->encodePredInfo( pcCU, 0, true );
    2191   Bool bDummy = false;
    2192   m_pcEntropyCoder->encodeCoeff( pcCU, 0, pcCU->getDepth( 0 ), uiWidth, uiHeight, bDummy );
    2193   UInt uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    2194 
    2195 #if H_3D_VSO
    2196   if ( m_pcRdCost->getUseLambdaScaleVSO())
    2197     dRDCost = m_pcRdCost->calcRdCostVSO( uiBits, ruiDist );
    2198   else
    2199 #endif
    2200     dRDCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
    2201   dmm4SegmentationOrg->destroy(); delete dmm4SegmentationOrg;
    2202 }
    2203 #endif
    22041707
    22051708Void
     
    28782381  pcCU->setChromIntraDirSubParts( uiBestMode, 0, pcCU->getDepth( 0 ) );
    28792382}
    2880 #if MTK_SINGLE_DEPTH_MODE_I0095
    2881 Void
    2882 TEncSearch::estIntraPredSingleDepth( TComDataCU* pcCU,
    2883                            TComYuv*    pcOrgYuv,
    2884                            TComYuv*    pcPredYuv,
    2885                            TComYuv*    pcResiYuv,
    2886                            TComYuv*    pcRecoYuv,
    2887                            UInt&       ruiDistC,
    2888                            Bool        bLumaOnly )
    2889 {
    2890   UInt    uiDepth        = pcCU->getDepth(0);
    2891   UInt    uiWidth        = pcCU->getWidth (0);
    2892   UInt    uiHeight       = pcCU->getHeight(0);
    2893 
    2894 
    2895   Pel* piOrg         = pcOrgYuv ->getLumaAddr( 0, uiWidth );
    2896   UInt uiStride      = pcPredYuv->getStride();
    2897 
    2898   Int index=0;
    2899   Pel testDepth;
    2900   Pel DepthNeighbours[5];
    2901   //construction of depth candidates
    2902   for( Int i = 0; (i < 5)  && (index<MTK_SINGLE_DEPTH_MODE_CANDIDATE_LIST_SIZE) ; i++ )
    2903   {
    2904     if(!pcCU->getNeighDepth (0, 0, &testDepth, i))
    2905     {
    2906       continue;
    2907     }
    2908     DepthNeighbours[index]=testDepth;
    2909     index++;
    2910     for(Int j=0;j<index-1;j++)
    2911     {
    2912       if( (DepthNeighbours[index-1]==DepthNeighbours[j]))
    2913       {
    2914         index--;
    2915         break;
    2916       }
    2917     }
    2918   }
    2919 
    2920   if(index==0)
    2921   {
    2922     DepthNeighbours[index]=1<<(g_bitDepthY-1);
    2923     index++;
    2924   }
    2925 
    2926   if(index==1)
    2927   {
    2928     DepthNeighbours[index]=ClipY(DepthNeighbours[0] + 1 );
    2929     index++;
    2930   }
    2931 
    2932 
    2933   Dist   uiDist = 0;
    2934   Double dCost   = 0.0;
    2935   Dist    uiBestDist = 0;
    2936   Double  dBestCost   = MAX_DOUBLE;
    2937   Pel     pBestSingleDepthValue = 0;
    2938 
    2939   for( Int testdepthidx = 0; testdepthidx < index ; testdepthidx++ )
    2940   {
    2941       // set context models
    2942       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    2943 
    2944       // determine residual for partition
    2945       uiDist = 0;
    2946       dCost   = 0.0;
    2947 #if H_3D_VSO // M36
    2948       if( m_pcRdCost->getUseRenModel() )
    2949       {
    2950         m_pcRdCost->setRenModelData( pcCU, 0, piOrg, uiStride, uiWidth, uiHeight );
    2951       }
    2952 #endif
    2953       xIntraCodingSingleDepth(pcCU, 0, pcOrgYuv, pcPredYuv, uiDist, dCost, testdepthidx, DepthNeighbours);
    2954       // check r-d cost
    2955       if( dCost < dBestCost )
    2956       {
    2957         uiBestDist = uiDist;
    2958         dBestCost   = dCost;
    2959         pBestSingleDepthValue = pcCU->getSingleDepthValue(0);
    2960         // copy reconstruction
    2961         pcPredYuv->copyPartToPartYuv(pcRecoYuv, 0, uiWidth, uiHeight);
    2962       }
    2963   } // depth index loop
    2964 
    2965 
    2966   pcCU->setSingleDepthValueSubParts((Pel)pBestSingleDepthValue,0, 0, uiDepth);
    2967   assert(pBestSingleDepthValue>=0);
    2968 
    2969   //===== reset context models =====
    2970   m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
    2971  
    2972   //===== set distortion (rate and r-d costs are determined later) =====
    2973   pcCU->getTotalDistortion() = uiBestDist;
    2974 }
    2975 
    2976 #endif
    29772383Void
    29782384TEncSearch::estIntraPredQT( TComDataCU* pcCU,
     
    29832389                            UInt&       ruiDistC,
    29842390                            Bool        bLumaOnly
    2985 #if HHI_DMM4_ENC_I0066
    2986                           , Bool        bOnlyIVP
    2987 #endif
    29882391                          )
    29892392{
     
    29952398  UInt    uiQNumParts    = pcCU->getTotalNumPart() >> 2;
    29962399  UInt    uiWidthBit     = pcCU->getIntraSizeIdx(0);
    2997 #if H_3D_VSO
    2998   Dist    uiOverallDistY = 0;
    2999 #else
    30002400  UInt    uiOverallDistY = 0;
    3001 #endif
    30022401  UInt    uiOverallDistC = 0;
    30032402  UInt    CandNum;
     
    30322431    Int numModesForFullRD = g_aucIntraModeNumFast[ uiWidthBit ];
    30332432   
    3034 #if HHI_DMM4_ENC_I0066
    3035     if( bOnlyIVP )
    3036     {
    3037       numModesForFullRD = 0;
    3038     }
    3039     else
    3040     {
    3041 #endif
    30422433    Bool doFastSearch = (numModesForFullRD != numModesAvailable);
    30432434    if (doFastSearch)
     
    30562447
    30572448        predIntraLumaAng( pcCU->getPattern(), uiMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
    3058 #if H_3D_VSO // M34
    3059         Dist uiSad;
    3060         if ( m_pcRdCost->getUseVSO() )
    3061         {
    3062           if ( m_pcRdCost->getUseEstimatedVSD() )
    3063           {         
    3064             uiSad = (Dist) ( m_pcRdCost->getDistPartVSD( pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, true ) );
    3065           }
    3066           else
    3067           {   
    3068             uiSad = m_pcRdCost->getDistPartVSO(pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, true );
    3069           }
    3070         }
    3071         else
    3072         {
    3073           uiSad = m_pcRdCost->calcHAD(g_bitDepthY, piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight );
    3074         }
    3075 #else       
    30762449        // use hadamard transform here
    30772450        UInt uiSad = m_pcRdCost->calcHAD(g_bitDepthY, piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight );
    3078 #endif
    30792451       
    30802452        UInt   iModeBits = xModeBitsIntra( pcCU, uiMode, uiPU, uiPartOffset, uiDepth, uiInitTrDepth );
    3081 #if H_3D_VSO // M35
    3082 #if H_3D_VSO_FIX // This fix should be enabled after verification
    3083         Double dLambda;
    3084         if ( m_pcRdCost->getUseLambdaScaleVSO() )
    3085         {
    3086           dLambda = m_pcRdCost->getUseRenModel() ? m_pcRdCost->getLambdaVSO() : m_pcRdCost->getSqrtLambdaVSO();
    3087         }
    3088         else       
    3089         {
    3090           dLambda = m_pcRdCost->getSqrtLambda();       
    3091         }
    3092 
    3093         Double cost      = (Double)uiSad + (Double)iModeBits * dLambda;
    3094 #else
    30952453        Double cost      = (Double)uiSad + (Double)iModeBits * m_pcRdCost->getSqrtLambda();
    3096 #endif
    3097 #else
    3098         Double cost      = (Double)uiSad + (Double)iModeBits * m_pcRdCost->getSqrtLambda();
    3099 #endif
    31002454       
    31012455        CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList );
     
    31352489      }
    31362490    }
    3137 #if HHI_DMM4_ENC_I0066
    3138     }
    3139 #endif
    3140 
    3141 #if H_3D_DIM
    3142     //===== determine set of depth intra modes to be tested =====
    3143     if( m_pcEncCfg->getIsDepth() && uiWidth >= DIM_MIN_SIZE && uiWidth <= DIM_MAX_SIZE && uiWidth == uiHeight )
    3144     {
    3145 #if HHI_DMM4_ENC_I0066
    3146 #if SEPARATE_FLAG_I0085
    3147       if( bOnlyIVP && m_pcEncCfg->getUseIVP() )
    3148 #else
    3149       if( bOnlyIVP )
    3150 #endif
    3151       {
    3152         TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
    3153         xPredContourFromTex( pcCU, uiPartOffset, uiWidth, uiHeight, dmm4Segmentation );
    3154 
    3155         Pel deltaDC1 = 0; Pel deltaDC2 = 0;
    3156         xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, dmm4Segmentation->getPattern(), dmm4Segmentation->getStride(), uiWidth, uiHeight, deltaDC1, deltaDC2 );
    3157         pcCU->setDimDeltaDC( DMM4_IDX, 0, uiPartOffset, deltaDC1 );
    3158         pcCU->setDimDeltaDC( DMM4_IDX, 1, uiPartOffset, deltaDC2 );
    3159 
    3160 #if HS_DMM_SIGNALLING_I0120
    3161         uiRdModeList[ numModesForFullRD++ ] = (DMM4_IDX+DIM_OFFSET);
    3162 #else
    3163         uiRdModeList[ numModesForFullRD++ ] = (2*DMM4_IDX  +DIM_OFFSET);
    3164         if( deltaDC1 != 0 || deltaDC2 != 0 )
    3165           uiRdModeList[ numModesForFullRD++ ] = (2*DMM4_IDX+1+DIM_OFFSET);
    3166 #endif
    3167         dmm4Segmentation->destroy(); delete dmm4Segmentation;
    3168       }
    3169       else
    3170       {
    3171 #endif
    3172 #if H_3D_FAST_DEPTH_INTRA
    3173       Int  threshold    = max(((pcCU->getQP(0))>>3)-1,3);
    3174       Int  varThreshold = (Int)( threshold * threshold - 8 );
    3175       UInt varCU      = m_pcRdCost->calcVAR(piOrg, uiStride, uiWidth,uiHeight,pcCU->getDepth(0));
    3176 #endif
    3177 
    3178 #if H_3D_DIM_DMM
    3179 #if SEPARATE_FLAG_I0085
    3180       if( ( m_pcEncCfg->getUseDMM() || m_pcEncCfg->getUseIVP() )
    3181 #else
    3182       if( m_pcEncCfg->getUseDMM()
    3183 #endif
    3184 #if H_3D_FAST_DEPTH_INTRA
    3185          && (uiRdModeList[0] != PLANAR_IDX || varCU >= varThreshold)
    3186 #endif
    3187         )
    3188       {
    3189 #if SEPARATE_FLAG_I0085
    3190         UInt uiStart, uiEnd;
    3191         if( m_pcEncCfg->getUseDMM() &&  m_pcEncCfg->getUseIVP() )
    3192         {
    3193           uiStart = 0;
    3194           uiEnd   = 2;
    3195         }
    3196         else if( m_pcEncCfg->getUseDMM() )
    3197         {
    3198           uiStart = 0;
    3199           uiEnd   = 1;
    3200         }
    3201         else if( m_pcEncCfg->getUseIVP() )
    3202         {
    3203           uiStart = 1;
    3204           uiEnd   = 2;
    3205         }
    3206         else
    3207         {
    3208           uiStart = 0;
    3209           uiEnd   = 0;
    3210         }
    3211         for( UInt dmmType = uiStart; dmmType < uiEnd; dmmType++ )
    3212 #else
    3213         for( UInt dmmType = 0; dmmType < DMM_NUM_TYPE; dmmType++ )
    3214 #endif
    3215         {
    3216 #if H_3D_FCO
    3217             TComPic* picTexture  = pcCU->getSlice()->getIvPic(false, pcCU->getSlice()->getViewIndex() );
    3218 #if LGE_FCO_I0116
    3219             if ( !picTexture->getReconMark() && (DMM4_IDX == dmmType ) )
    3220 #else
    3221             if ( !picTexture->getReconMark() && (DMM3_IDX == dmmType || DMM4_IDX == dmmType ) )
    3222 #endif
    3223             {
    3224                 continue;
    3225             }
    3226 #endif
    3227           UInt uiTabIdx = 0;
    3228           TComWedgelet* biSegmentation = NULL;
    3229           Pel deltaDC1 = 0; Pel deltaDC2 = 0;
    3230           switch( dmmType )
    3231           {
    3232           case( DMM1_IDX ):
    3233             {
    3234               xSearchDmm1Wedge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight, uiTabIdx );
    3235               pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dmmType,  uiPartOffset, uiDepth + uiInitTrDepth );
    3236 #if SHARP_DMM1_I0110
    3237               biSegmentation = pcCU->isDMM1UpscaleMode( uiWidth ) ?
    3238                   &(g_dmmWedgeLists[(g_aucConvertToBit[pcCU->getDMM1BasePatternWidth(uiWidth)])][uiTabIdx]) : &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]);
    3239 #else
    3240               biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]);
    3241 #endif
    3242             } break;
    3243 
    3244           case( DMM4_IDX ):
    3245             {
    3246               {
    3247                 biSegmentation = new TComWedgelet( uiWidth, uiHeight );
    3248                 xPredContourFromTex( pcCU, uiPartOffset, uiWidth, uiHeight, biSegmentation );
    3249               }
    3250             } break;
    3251           default: assert(0);
    3252           }
    3253 
    3254           if( biSegmentation )
    3255           {
    3256 #if SHARP_DMM1_I0110
    3257             if( dmmType == DMM1_IDX && pcCU->isDMM1UpscaleMode( uiWidth ) ){
    3258                 xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, biSegmentation->getScaledPattern(uiWidth), uiWidth, uiWidth, uiHeight, deltaDC1, deltaDC2 );
    3259             }
    3260             else
    3261             {
    3262                 xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, biSegmentation->getPattern(), biSegmentation->getStride(), uiWidth, uiHeight, deltaDC1, deltaDC2 );
    3263             }
    3264 #else
    3265             xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, biSegmentation->getPattern(), biSegmentation->getStride(), uiWidth, uiHeight, deltaDC1, deltaDC2 );
    3266 #endif
    3267             pcCU->setDimDeltaDC( dmmType, 0, uiPartOffset, deltaDC1 );
    3268             pcCU->setDimDeltaDC( dmmType, 1, uiPartOffset, deltaDC2 );
    3269 
    3270 #if HS_DMM_SIGNALLING_I0120
    3271             uiRdModeList[ numModesForFullRD++ ] = (dmmType  +DIM_OFFSET);
    3272 #else
    3273             uiRdModeList[ numModesForFullRD++ ] = (2*dmmType  +DIM_OFFSET);
    3274 #if HHI_DMM4_ENC_I0066
    3275             if( deltaDC1 != 0 || deltaDC2 != 0 )
    3276 #endif
    3277             uiRdModeList[ numModesForFullRD++ ] = (2*dmmType+1+DIM_OFFSET);
    3278 #endif
    3279 
    3280             if( DMM4_IDX == dmmType ) { biSegmentation->destroy(); delete biSegmentation; }
    3281           }
    3282         }
    3283       }
    3284 #if HHI_DMM4_ENC_I0066
    3285       }
    3286 #endif
    3287 #endif
    3288     }
    3289 #endif
     2491
    32902492    //===== check modes (using r-d costs) =====
    32912493#if HHI_RQT_INTRA_SPEEDUP_MOD
     
    32952497   
    32962498    UInt    uiBestPUMode  = 0;
    3297 #if SCU_HS_FAST_INTRA_SDC_I0123
    3298     UInt    uiBestPUModeConv  = 0;
    3299     UInt    uiSecondBestPUModeConv  = 0;
    3300     UInt    uiThirdBestPUModeConv  = 0;
    3301 #endif
    3302 
    3303 #if H_3D_VSO
    3304     Dist    uiBestPUDistY = 0;
    3305 #else
     2499
    33062500    UInt    uiBestPUDistY = 0;
    3307 #endif
    33082501    UInt    uiBestPUDistC = 0;
    33092502    Double  dBestPUCost   = MAX_DOUBLE;
    33102503
    3311 #if SCU_HS_FAST_INTRA_SDC_I0123
    3312     Double  dBestPUCostConv   = MAX_DOUBLE;
    3313     UInt varCU      = m_pcRdCost->calcVAR(piOrg, uiStride, uiWidth,uiHeight,pcCU->getDepth(0));
    3314     UInt rdSDC = m_pcEncCfg->getIsDepth() ? numModesForFullRD : 0;
    3315 #endif
    3316 
    3317 #if H_3D_DIM_SDC
    3318     Bool    bBestUseSDC   = false;
    3319     Pel     apBestDCOffsets[2] = {0,0};
    3320 #endif
    3321 #if SCU_HS_FAST_INTRA_SDC_I0123
    3322     for( UInt uiMode = 0; uiMode < numModesForFullRD + rdSDC; uiMode++ )
    3323 #else
     2504
    33242505    for( UInt uiMode = 0; uiMode < numModesForFullRD; uiMode++ )
    3325 #endif
    33262506    {
    33272507      // set luma prediction mode
    3328 #if !SCU_HS_FAST_INTRA_SDC_I0123
    33292508     UInt uiOrgMode = uiRdModeList[uiMode]; 
    3330 #endif
    33312509     
    3332 #if SCU_HS_FAST_INTRA_SDC_I0123
    3333       UInt uiOrgMode;
    3334       if (uiMode < numModesForFullRD)
    3335       {   
    3336          uiOrgMode = uiRdModeList[uiMode];
    3337       }
    3338       else
    3339       {
    3340            uiOrgMode = uiRdModeList[uiMode - numModesForFullRD];
    3341 
    3342            if (uiBestPUModeConv <= 1 )
    3343            {
    3344            if (uiOrgMode > 1 && varCU < 1) continue;         
    3345            }
    3346            else
    3347            {
    3348               if (uiOrgMode != uiBestPUModeConv && uiOrgMode != uiSecondBestPUModeConv && uiOrgMode != uiThirdBestPUModeConv
    3349                   && uiOrgMode > 1 && uiOrgMode < NUM_INTRA_MODE && varCU < 4)
    3350               continue;
    3351            }
    3352        }
    3353 #endif
    33542510
    33552511      pcCU->setLumaIntraDirSubParts ( uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
    33562512     
    3357 #if H_3D_DIM_SDC
    3358 #if SCU_HS_FAST_INTRA_SDC_I0123
    3359       Bool bTestSDC = ( m_pcEncCfg->getUseSDC() && pcCU->getSDCAvailable(uiPartOffset) && uiMode >= numModesForFullRD);
    3360 #else
    3361       Bool bTestSDC = ( m_pcEncCfg->getUseSDC() && pcCU->getSDCAvailable(uiPartOffset) );
    3362 #endif
    33632513     
    3364       for( UInt uiSDC=0; uiSDC<=(bTestSDC?1:0); uiSDC++ )
    3365       {
    3366 #if SCU_HS_FAST_INTRA_SDC_I0123
    3367         if (!uiSDC && uiMode >= numModesForFullRD) continue;
    3368 #endif
    3369         pcCU->setSDCFlagSubParts( (uiSDC != 0), uiPartOffset, uiDepth + uiInitTrDepth );
    3370 #if FAST_SDC_OFFSET_DECISION_I0084
    3371         Double dOffsetCost[3] = {MAX_DOUBLE,MAX_DOUBLE,MAX_DOUBLE};
    3372         for( Int iOffset = 1; iOffset <= 5; iOffset++ )
    3373 #else
    3374         for( Int iSDCDeltaResi = -2; iSDCDeltaResi <= 2; iSDCDeltaResi++ )
    3375 #endif
    3376         {
    3377 #if FAST_SDC_OFFSET_DECISION_I0084
    3378           Int iSDCDeltaResi = 0;
    3379           if(iOffset % 2 == 0)
    3380           {
    3381             iSDCDeltaResi = iOffset >> 1;
    3382           }
    3383           else
    3384           {
    3385             iSDCDeltaResi = -1 * (iOffset >> 1);
    3386           }
    3387 #endif
    3388           if( ( uiSDC == 0 ) && iSDCDeltaResi != 0 )
    3389           {
    3390             continue;
    3391           }
    3392 #if FAST_SDC_OFFSET_DECISION_I0084
    3393           if( iOffset > 3)
    3394           {
    3395             if ( dOffsetCost[0] < (0.9*dOffsetCost[1]) && dOffsetCost[0] < (0.9*dOffsetCost[2]) )
    3396             {
    3397               continue;
    3398             }
    3399             if ( dOffsetCost[1] < dOffsetCost[0] && dOffsetCost[0] < dOffsetCost[2] &&  iOffset == 5)
    3400             {
    3401               continue;
    3402             }
    3403             if ( dOffsetCost[0] < dOffsetCost[1] && dOffsetCost[2] < dOffsetCost[0] &&  iOffset == 4)
    3404             {
    3405               continue;
    3406             }
    3407           }
    3408 #endif
    3409 #endif
    34102514     
    3411 #if H_3D_DIM_ENC || H_3D_DIM_SDC
    3412       Bool bTestZeroResi = false;
    3413 #if H_3D_DIM_ENC
    3414       bTestZeroResi |= pcCU->getSlice()->getIsDepth() && !pcCU->getSlice()->isIRAP();
    3415 #endif
    3416 #if H_3D_DIM_SDC
    3417       bTestZeroResi |= pcCU->getSDCFlag(uiPartOffset);
    3418 #endif
    3419       if( uiSDC != 0 && iSDCDeltaResi != 0 )
    3420       {
    3421         bTestZeroResi = false;
    3422       }
    3423 #endif
    3424      
    3425 #if H_3D_DIM_ENC || H_3D_DIM_SDC     
    3426       for( UInt testZeroResi = 0; testZeroResi <= (bTestZeroResi ? 1 : 0) ; testZeroResi++ )
    3427       {
    3428 #endif
    34292515        // set context models
    34302516        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    34312517
    34322518        // determine residual for partition
    3433 #if H_3D_VSO
    3434         Dist   uiPUDistY = 0;
    3435 #else
    34362519        UInt   uiPUDistY = 0;
    3437 #endif
    34382520        UInt   uiPUDistC = 0;
    34392521        Double dPUCost   = 0.0;
    3440 #if H_3D_VSO // M36
    3441         if( m_pcRdCost->getUseRenModel() )
    3442         {
    3443           m_pcRdCost->setRenModelData( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight );
    3444         }
    3445 #endif
    3446 #if H_3D_DIM_SDC
    3447         if( pcCU->getSDCFlag(uiPartOffset) )
    3448         {
    3449           pcCU->setTrIdxSubParts(0, uiPartOffset, uiDepth + uiInitTrDepth);
    3450           pcCU->setCbfSubParts(1, 1, 1, uiPartOffset, uiDepth + uiInitTrDepth);
    3451 
    3452           // start encoding with SDC
    3453           xIntraCodingSDC(pcCU, uiPartOffset, pcOrgYuv, pcPredYuv, uiPUDistY, dPUCost, ( testZeroResi != 0 ), iSDCDeltaResi );
    3454 #if FAST_SDC_OFFSET_DECISION_I0084
    3455           if ( testZeroResi == 0 && iOffset <= 3 )
    3456           {
    3457             dOffsetCost [iOffset -1] = dPUCost;
    3458           }
    3459 #endif
    3460         }
    3461         else
    3462         {
    3463 #endif
    34642522#if HHI_RQT_INTRA_SPEEDUP
    3465 #if H_3D_DIM_ENC
    3466           xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost, (testZeroResi != 0) );
    3467 #if SCU_HS_FAST_INTRA_SDC_I0123   
    3468       if( dPUCost < dBestPUCostConv )
    3469       {
    3470         uiThirdBestPUModeConv = uiSecondBestPUModeConv;
    3471         uiSecondBestPUModeConv = uiBestPUModeConv;
    3472         uiBestPUModeConv  = uiOrgMode;
    3473         dBestPUCostConv   = dPUCost;
    3474       }
    3475 #endif
    3476 #else
    34772523          xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost );
    3478 #endif
    3479 #else
    3480 #if H_3D_DIM_ENC
    3481           xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost, (testZeroResi != 0) );
    34822524#else
    34832525          xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost );
    3484 #endif
    3485 #endif
    3486 #if H_3D_DIM_SDC
    3487         }
    34882526#endif
    34892527
     
    35002538          dBestPUCost   = dPUCost;
    35012539
    3502 #if H_3D_DIM_SDC
    3503           if( pcCU->getSDCFlag(uiPartOffset) )
    3504           {
    3505             bBestUseSDC = true;
    3506 
    3507             // copy reconstruction
    3508             pcPredYuv->copyPartToPartYuv(pcRecoYuv, uiPartOffset, uiWidth, uiHeight);
    3509 
    3510             // copy DC values
    3511             apBestDCOffsets[0] = pcCU->getSDCSegmentDCOffset(0, uiPartOffset);
    3512             apBestDCOffsets[1] = pcCU->getSDCSegmentDCOffset(1, uiPartOffset);
    3513           }
    3514           else
    3515           {
    3516             bBestUseSDC = false;
    3517 #endif
    35182540            xSetIntraResultQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcRecoYuv );
    35192541
     
    35262548            ::memcpy( m_puhQTTempTransformSkipFlag[1], pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
    35272549            ::memcpy( m_puhQTTempTransformSkipFlag[2], pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
    3528 #if H_3D_DIM_SDC
    3529           }
    3530 #endif
    35312550        }
    35322551#if HHI_RQT_INTRA_SPEEDUP_MOD
     
    35362555          dSecondBestPUCost = dPUCost;
    35372556        }
    3538 #endif
    3539 #if H_3D_DIM_ENC || H_3D_DIM_SDC
    3540       }
    3541         } // SDC residual loop
    3542 #endif
    3543 #if H_3D_DIM_SDC
    3544       } // SDC loop
    35452557#endif
    35462558    } // Mode loop
     
    35622574     
    35632575      pcCU->setLumaIntraDirSubParts ( uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
    3564 #if H_3D_DIM_SDC
    3565       pcCU->setSDCFlagSubParts(false, uiPartOffset, uiDepth + uiInitTrDepth);
    3566 #endif
    35672576     
    35682577      // set context models
     
    35702579     
    35712580      // determine residual for partition
    3572 #if H_3D_VSO
    3573       Dist   uiPUDistY = 0;
    3574 #else
    35752581      UInt   uiPUDistY = 0;
    3576 #endif
    35772582      UInt   uiPUDistC = 0;
    35782583      Double dPUCost   = 0.0;
    3579 #if H_3D_VSO // M37
    3580       // reset Model
    3581       if( m_pcRdCost->getUseRenModel() )
    3582       {
    3583         m_pcRdCost->setRenModelData( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight );
    3584       }
    3585 #endif
    35862584      xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, false, dPUCost );
    35872585     
     
    35932591        uiBestPUDistC = uiPUDistC;
    35942592        dBestPUCost   = dPUCost;
    3595 #if H_3D_DIM_SDC
    3596         bBestUseSDC   = false;
    3597 #endif
    35982593       
    35992594        xSetIntraResultQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcRecoYuv );
     
    36152610    uiOverallDistC += uiBestPUDistC;
    36162611   
    3617 #if H_3D_DIM_SDC
    3618     if( bBestUseSDC )
    3619     {
    3620       pcCU->setTrIdxSubParts(0, uiPartOffset, uiDepth + uiInitTrDepth);
    3621       pcCU->setCbfSubParts(1, 1, 1, uiPartOffset, uiDepth + uiInitTrDepth);
    3622      
    3623       //=== copy best DC segment values back to CU ====
    3624       pcCU->setSDCSegmentDCOffset(apBestDCOffsets[0], 0, uiPartOffset);
    3625       pcCU->setSDCSegmentDCOffset(apBestDCOffsets[1], 1, uiPartOffset);
    3626     }
    3627     else
    3628     {
    3629 #endif
    36302612        //--- update transform index and cbf ---
    36312613    UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth(0) + uiInitTrDepth ) << 1 );
     
    36372619    ::memcpy( pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, m_puhQTTempTransformSkipFlag[1], uiQPartNum * sizeof( UChar ) );
    36382620    ::memcpy( pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, m_puhQTTempTransformSkipFlag[2], uiQPartNum * sizeof( UChar ) );
    3639 #if H_3D_DIM_SDC
    3640     }
    3641 #endif
    36422621    //--- set reconstruction for next intra prediction blocks ---
    36432622    if( uiPU != uiNumPU - 1 )
     
    36672646        }
    36682647      }
    3669 #if H_3D_VSO // M38
    3670       // set model
    3671       if( m_pcRdCost->getUseRenModel() )
    3672       {
    3673         piSrc = pcRecoYuv->getLumaAddr( uiPartOffset );
    3674         m_pcRdCost->setRenModelData( pcCU, uiPartOffset, piSrc, uiSrcStride, uiCompWidth, uiCompHeight);
    3675       }
    3676 #endif
    36772648      if( !bLumaOnly && !bSkipChroma )
    36782649      {
     
    37072678    //=== update PU data ====
    37082679    pcCU->setLumaIntraDirSubParts     ( uiBestPUMode, uiPartOffset, uiDepth + uiInitTrDepth );
    3709 #if H_3D_DIM_SDC
    3710     pcCU->setSDCFlagSubParts          ( bBestUseSDC, uiPartOffset, uiDepth + uiInitTrDepth );
    3711 #endif
    37122680    pcCU->copyToPic                   ( uiDepth, uiPU, uiInitTrDepth );
    37132681  } // PU loop
     
    39592927  uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    39602928
    3961 #if H_3D_VSO // M43
    3962   if( m_pcRdCost->getUseLambdaScaleVSO() ) 
    3963     dCost =  m_pcRdCost->calcRdCostVSO( uiBits, uiDistortion ); 
    3964   else
    3965 #endif
    39662929  dCost = m_pcRdCost->calcRdCost( uiBits, uiDistortion );
    39672930
     
    39922955                            m_tmpYuvPred .getLumaAddr( uiAbsPartIdx ), m_tmpYuvPred .getStride(),
    39932956                            iWidth, iHeight, m_pcEncCfg->getUseHADME() );
    3994 #if H_3D_IC
    3995   cDistParam.bUseIC = false;
    3996 #endif
    3997 #if H_3D_INTER_SDC
    3998   cDistParam.bUseSDCMRSAD = false;
    3999 #endif
    40002957  ruiErr = cDistParam.DistFunc( &cDistParam );
    40012958}
     
    40152972 */
    40162973Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost, TComMvField* cMvFieldNeighbours, UChar* uhInterDirNeighbours
    4017 #if H_3D_VSP
    4018                                  , Int* vspFlag
    4019 #if !FIX_TICKET_79
    4020                                  , InheritedVSPDisInfo*  inheritedVSPDisInfo
    4021 #endif
    4022 #endif
    4023 #if H_3D_SPIVMP
    4024                                  , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    4025 #endif
    40262974                                 , Int& numValidMergeCand
    40272975                                 )
     
    40342982  UInt uiDepth = pcCU->getDepth( uiAbsPartIdx );
    40352983 
    4036 #if H_3D_DBBP
    4037   DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
    4038   if( pcCU->getDBBPFlag(0) )
    4039   {
    4040     AOF( uiAbsPartIdx == 0 );
    4041     AOF( iPUIdx == 0 );
    4042     AOF( pcCU->getPartitionSize(0) == SIZE_2Nx2N );
    4043     AOF( pDBBPTmpData->eVirtualPartSize != SIZE_NONE );
    4044    
    4045     // temporary change of partition size for candidate derivation
    4046     pcCU->setPartSizeSubParts( pDBBPTmpData->eVirtualPartSize, 0, pcCU->getDepth(0));
    4047     iPUIdx = pcCU->getDBBPTmpData()->uiVirtualPartIndex;
    4048    
    4049     // if this is handling the second segment, make sure that motion info of first segment is available
    4050     if( iPUIdx == 1 )
    4051     {
    4052       pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[0], 0, 0, pcCU->getDepth(0)); // interprets depth relative to LCU level
    4053      
    4054       for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    4055       {
    4056         RefPicList eRefList = (RefPicList)uiRefListIdx;
    4057        
    4058         pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[0][eRefList], pDBBPTmpData->eVirtualPartSize, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
    4059       }
    4060     }
    4061    
    4062     // update these values to virtual partition size
    4063     pcCU->getPartIndexAndSize( iPUIdx, uiAbsPartIdx, iWidth, iHeight );
    4064   }
    4065 #endif
    40662984 
    40672985  PartSize partSize = pcCU->getPartitionSize( 0 );
    4068 #if H_3D_DBBP
    4069   if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && partSize != SIZE_2Nx2N && pcCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(0) == false )
    4070 #else
    40712986  if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && partSize != SIZE_2Nx2N && pcCU->getWidth( 0 ) <= 8 )
    4072 #endif
    40732987  {
    40742988    pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
    40752989    if ( iPUIdx == 0 )
    40762990    {
    4077 #if H_3D
    4078       pcCU->initAvailableFlags();
    4079       pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand);
    4080       pcCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
    4081 #if H_3D_VSP && !FIX_TICKET_79
    4082                                         , inheritedVSPDisInfo
    4083 #endif
    4084 #if H_3D_SPIVMP
    4085         , pcMvFieldSP, puhInterDirSP
    4086 #endif
    4087         , numValidMergeCand
    4088         );
    4089 
    4090       pcCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours
    4091 #if H_3D_VSP
    4092         , vspFlag
    4093 #endif
    4094 #if H_3D_SPIVMP
    4095         , pbSPIVMPFlag
    4096 #endif
    4097                                         , numValidMergeCand
    4098         );
    4099 #else
    41002991      pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
    4101 #endif
    41022992    }
    41032993    pcCU->setPartSizeSubParts( partSize, 0, uiDepth );
     
    41052995  else
    41062996  {
    4107 #if H_3D
    4108     pcCU->initAvailableFlags();
    4109     pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand);
    4110     pcCU->xGetInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours
    4111 #if H_3D_VSP && !FIX_TICKET_79
    4112                                       , inheritedVSPDisInfo
    4113 #endif
    4114 #if H_3D_SPIVMP
    4115       , pcMvFieldSP, puhInterDirSP
    4116 #endif
    4117       , numValidMergeCand
    4118       );
    4119 
    4120     pcCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
    4121 #if H_3D_VSP
    4122       , vspFlag
    4123 #endif
    4124 #if H_3D_SPIVMP
    4125       , pbSPIVMPFlag
    4126 #endif
    4127                                       , numValidMergeCand
    4128       );
    4129 #else
    41302997    pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand
    41312998                                 );
    4132 #endif
    4133   }
    4134 #if H_3D_VSP && !FIX_TICKET_75
    4135   xRestrictBipredMergeCand( pcCU, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours,vspFlag, numValidMergeCand );
    4136 #else
     2999  }
    41373000  xRestrictBipredMergeCand( pcCU, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    4138 #endif
    4139 
    4140 #if H_3D_DBBP
    4141   if( pcCU->getDBBPFlag(0) )
    4142   {
    4143     // reset to 2Nx2N for actual motion search
    4144     iPUIdx = 0;
    4145     AOF( pcCU->getPartitionSize(0) == pDBBPTmpData->eVirtualPartSize );
    4146     pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, pcCU->getDepth(0));
    4147    
    4148     // restore values for 2Nx2N partition size
    4149     pcCU->getPartIndexAndSize( iPUIdx, uiAbsPartIdx, iWidth, iHeight );
    4150    
    4151     AOF( uiAbsPartIdx == 0 );
    4152     AOF( iWidth == iHeight );
    4153   }
    4154 #endif
     3001
    41553002
    41563003  ruiCost = MAX_UINT;
     
    41623009    PartSize ePartSize = pcCU->getPartitionSize( 0 );
    41633010
    4164 #if H_3D_VSP
    4165     pcCU->setVSPFlagSubParts( vspFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
    4166 #if !FIX_TICKET_79
    4167     pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeCand].m_acDvInfo, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
    4168 #endif
    4169 #endif
    4170 
    4171 #if H_3D_SPIVMP
    4172     pcCU->setSPIVMPFlagSubParts( pbSPIVMPFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ));
    4173     if (pbSPIVMPFlag[uiMergeCand])
    4174     {
    4175       UInt uiSPAddr;
    4176 
    4177       Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    4178 
    4179       pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    4180 
    4181       for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    4182       {
    4183         pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
    4184         pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
    4185         pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
    4186       }
    4187     }
    4188     else
    4189 #endif
    4190 #if H_3D_VSP
    4191 #if H_3D_DBBP
    4192       if ( vspFlag[uiMergeCand] && !pcCU->getDBBPFlag(0) )
    4193 #else
    4194       if ( vspFlag[uiMergeCand] )
    4195 #endif
    4196       {
    4197         UInt partAddr;
    4198         Int vspSize;
    4199         Int width, height;
    4200         pcCU->getPartIndexAndSize( iPUIdx, partAddr, width, height );
    4201 
    4202         if( uhInterDirNeighbours[ uiMergeCand ] & 0x01 )
    4203         {
    4204           pcCU->setMvFieldPUForVSP( pcCU, partAddr, width, height, REF_PIC_LIST_0, cMvFieldNeighbours[ 2*uiMergeCand + 0 ].getRefIdx(), vspSize );
    4205           pcCU->setVSPFlag( partAddr, vspSize );
    4206         }
    4207         else
    4208         {
    4209           pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    4210         }
    4211         if( uhInterDirNeighbours[ uiMergeCand ] & 0x02 )
    4212         {
    4213           pcCU->setMvFieldPUForVSP( pcCU, partAddr, width, height, REF_PIC_LIST_1, cMvFieldNeighbours[ 2*uiMergeCand + 1 ].getRefIdx(), vspSize );
    4214           pcCU->setVSPFlag( partAddr, vspSize );
    4215         }
    4216         else
    4217         {
    4218           pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    4219         }
    4220       }
    4221       else
    4222       {
    4223 #endif
     3011
    42243012        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    42253013        pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
    4226 #if H_3D_VSP
    4227       }
    4228 #endif
    4229 
    4230 #if H_3D_DDD
    4231       if( uiMergeCand == pcCU->getUseDDDCandIdx() )
    4232       {
    4233         pcCU->setUseDDD( true, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
    4234         pcCU->setDDDepthSubParts( pcCU->getDDTmpDepth(), uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
    4235       }
    4236       else
    4237       {
    4238         pcCU->setUseDDD( false, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
    4239       }
    4240 #endif
     3014
    42413015
    42423016      xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() );
     
    42663040 * \returns Void
    42673041 */
    4268 #if H_3D_VSP && !FIX_TICKET_75
    4269 Void TEncSearch::xRestrictBipredMergeCand( TComDataCU* pcCU, UInt puIdx, TComMvField* mvFieldNeighbours, UChar* interDirNeighbours, Int* vspFlag, Int numValidMergeCand )
    4270 #else
    42713042Void TEncSearch::xRestrictBipredMergeCand( TComDataCU* pcCU, UInt puIdx, TComMvField* mvFieldNeighbours, UChar* interDirNeighbours, Int numValidMergeCand )
    4272 #endif
    42733043{
    42743044  if ( pcCU->isBipredRestriction(puIdx) )
     
    42763046    for( UInt mergeCand = 0; mergeCand < numValidMergeCand; ++mergeCand )
    42773047    {
    4278 #if H_3D_VSP && !FIX_TICKET_75
    4279       if ( (interDirNeighbours[mergeCand] == 3) && (vspFlag[mergeCand] == false) )
    4280 #else
    42813048      if ( interDirNeighbours[mergeCand] == 3 )
    4282 #endif
    42833049      {
    42843050        interDirNeighbours[mergeCand] = 1;
     
    42993065 */
    43003066#if AMP_MRG
    4301 #if  H_3D_FAST_TEXTURE_ENCODING
    4302 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bFMD, Bool bUseRes, Bool bUseMRG )
    4303 #else
    43043067Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG )
    4305 #endif
    43063068#else
    43073069Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes )
     
    43663128#endif
    43673129
    4368 #if H_3D_IV_MERGE
    4369   TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    4370   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
    4371 #else
    43723130  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
    43733131  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    4374 #endif
    43753132  Int numValidMergeCand = 0 ;
    43763133
     
    44083165    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    44093166
    4410 #if H_3D_VSP
    4411     pcCU->setVSPFlagSubParts( 0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr) );
    4412 #endif
    44133167   
    44143168#if AMP_MRG
    44153169    Bool bTestNormalMC = true;
    4416 #if  H_3D_FAST_TEXTURE_ENCODING
    4417     if (bFMD||( bUseMRG && pcCU->getWidth( 0 ) > 8 && iNumPart == 2 ))
    4418 #else           
    44193170    if ( bUseMRG && pcCU->getWidth( 0 ) > 8 && iNumPart == 2 )
    4420 #endif
    44213171    {
    44223172      bTestNormalMC = false;
     
    48613611#endif
    48623612
    4863 #if H_3D_DBBP
    4864     // test merge mode for DBBP (2Nx2N)
    4865     if ( pcCU->getPartitionSize( uiPartAddr ) != SIZE_2Nx2N || pcCU->getDBBPFlag(0) )
    4866 #else
    48673613    if ( pcCU->getPartitionSize( uiPartAddr ) != SIZE_2Nx2N )
    4868 #endif
    48693614    {
    48703615      UInt uiMRGInterDir = 0;     
     
    48993644      // find Merge result
    49003645      UInt uiMRGCost = MAX_UINT;
    4901 #if H_3D_VSP
    4902       Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    4903       memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    4904 #if !FIX_TICKET_79
    4905       InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
    4906 #endif
    4907       UInt uiAbsPartIdx = 0;
    4908       Int iWidth = 0;
    4909       Int iHeight = 0;
    4910       pcCU->getPartIndexAndSize( iPartIdx, uiAbsPartIdx, iWidth, iHeight );
    4911       DisInfo OriginalDvInfo = pcCU->getDvInfo(uiAbsPartIdx);
    4912 #endif
    4913 #if H_3D_SPIVMP
    4914       Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
    4915       memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    4916       TComMvField*  pcMvFieldSP;
    4917       UChar* puhInterDirSP;
    4918       pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2];
    4919       puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()];
    4920 #endif
    49213646      xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, cMvFieldNeighbours, uhInterDirNeighbours
    4922 #if H_3D_VSP
    4923                       , vspFlag
    4924 #if !FIX_TICKET_79
    4925                       , inheritedVSPDisInfo
    4926 #endif
    4927 #endif
    4928 #if H_3D_SPIVMP
    4929                       , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
    4930 #endif
    49313647                      , numValidMergeCand
    49323648                      );
     
    49363652        pcCU->setMergeFlagSubParts ( true,          uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    49373653        pcCU->setMergeIndexSubParts( uiMRGIndex,    uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4938 #if H_3D_VSP
    4939         pcCU->setVSPFlagSubParts( vspFlag[uiMRGIndex], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4940 #if !FIX_TICKET_79
    4941         pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMRGIndex].m_acDvInfo, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4942 #endif
    4943 #endif
    4944 #if H_3D_DDD
    4945         if( uiMRGIndex == pcCU->getUseDDDCandIdx() )
    4946         {
    4947             assert( vspFlag[uiMRGIndex]     == 0 );
    4948             assert( bSPIVMPFlag[uiMRGIndex] == 0 );
    4949             pcCU->setUseDDD( true, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4950             pcCU->setDDDepthSubParts( pcCU->getDDTmpDepth(), uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4951         }
    4952         else
    4953         {
    4954             pcCU->setUseDDD( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    4955         }
    4956 #endif
    4957 #if H_3D_SPIVMP
    4958         pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMRGIndex], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 
    4959         if (bSPIVMPFlag[uiMRGIndex]!=0)
    4960         {
    4961           UInt uiSPAddr;
    4962           Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
    4963           pcCU->getSPPara(iRoiWidth, iRoiHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
    4964           for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
    4965           {
    4966             pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
    4967             pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
    4968             pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
    4969             pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
    4970           }
    4971           if ( pcCU->getInterDir(uiPartAddr) == 3 && pcCU->isBipredRestriction(iPartIdx) )
    4972           {
    4973             pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiPartAddr, 0, iPartIdx);
    4974             pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiPartAddr, 0, iPartIdx);
    4975             pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ));
    4976           }
    4977         }
    4978         else
    4979 #endif
    4980 #if H_3D_VSP
    4981 #if H_3D_DBBP
    4982         if ( vspFlag[uiMRGIndex] && !pcCU->getDBBPFlag(uiPartAddr) )
    4983 #else
    4984         if ( vspFlag[uiMRGIndex] )
    4985 #endif
    4986         {
    4987           UInt partAddrTemp;
    4988           Int vspSize;
    4989           Int width, height;
    4990           pcCU->getPartIndexAndSize( iPartIdx, partAddrTemp, width, height ); // true or pcCU->getTotalNumPart()==256
    4991           if( uiMRGInterDir & 0x01 )
    4992           {
    4993             pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_0, cMRGMvField[0].getRefIdx(), vspSize );
    4994             pcCU->setVSPFlag( partAddrTemp, vspSize );
    4995           }
    4996           else
    4997           {
    4998             pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
    4999           }
    5000           if( uiMRGInterDir & 0x02 )
    5001           {
    5002             pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_1, cMRGMvField[1].getRefIdx(), vspSize );
    5003             pcCU->setVSPFlag( partAddrTemp, vspSize );
    5004           }
    5005           else
    5006           {
    5007             pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    5008           }
    5009           pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    5010         }
    5011         else
    5012           {
    5013 #endif
    50143654          pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    50153655            pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
    50163656            pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    5017 #if H_3D
    5018           }
    5019 #endif
    50203657        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
    50213658        pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
     
    50283665      else
    50293666      {
    5030 #if H_3D_SPIVMP       
    5031         pcCU->setSPIVMPFlagSubParts(0, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    5032 #endif
    5033 #if H_3D_DDD
    5034         pcCU->setUseDDD( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    5035 #endif
    50363667        // set ME result
    50373668        pcCU->setMergeFlagSubParts( false,        uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    50383669        pcCU->setInterDirSubParts ( uiMEInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    5039 #if H_3D_VSP
    5040         pcCU->setVSPFlagSubParts ( 0,             uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    5041         pcCU->setDvInfoSubParts(OriginalDvInfo, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    5042 #endif
    50433670          pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMEMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
    50443671          pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMEMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    50453672        }
    5046 #if H_3D_SPIVMP
    5047       delete[] pcMvFieldSP;
    5048       delete[] puhInterDirSP;
    5049 #endif
    50503673    }
    50513674
     
    50823705  if (!bFilled)
    50833706  {
    5084 #if H_3D_DBBP
    5085     DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
    5086     if( pcCU->getDBBPFlag(0) )
    5087     {
    5088       AOF( uiPartAddr == 0 );
    5089       AOF( uiPartIdx == 0 );
    5090       AOF( pcCU->getPartitionSize(0) == SIZE_2Nx2N );
    5091       AOF( pDBBPTmpData->eVirtualPartSize != SIZE_NONE );
    5092       AOF( iRoiWidth == iRoiHeight );
    5093      
    5094       // temporary change of partition size for candidate derivation
    5095       pcCU->setPartSizeSubParts( pDBBPTmpData->eVirtualPartSize, 0, pcCU->getDepth(0));
    5096       uiPartIdx = pcCU->getDBBPTmpData()->uiVirtualPartIndex;
    5097      
    5098       // if this is handling the second segment, make sure that motion info of first segment is set to first segment
    5099       if( uiPartIdx == 1 )
    5100       {
    5101         pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[0], 0, 0, pcCU->getDepth(0)); // interprets depth relative to LCU level
    5102        
    5103         for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    5104         {
    5105           RefPicList eRefList = (RefPicList)uiRefListIdx;
    5106           pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[0][eRefList], pDBBPTmpData->eVirtualPartSize, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
    5107         }
    5108       }
    5109      
    5110       // update values to virtual partition size
    5111       pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    5112     }
    5113 #endif
    51143707   
    51153708    pcCU->fillMvpCand( uiPartIdx, uiPartAddr, eRefPicList, iRefIdx, pcAMVPInfo );
    51163709   
    5117 #if H_3D_DBBP
    5118     if( pcCU->getDBBPFlag(0) )
    5119     {
    5120       // restore 2Nx2N partitioning for motion estimation
    5121       uiPartIdx = 0;
    5122       AOF( pcCU->getPartitionSize(0) == pDBBPTmpData->eVirtualPartSize );
    5123       pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, pcCU->getDepth(0));
    5124      
    5125       // restore values for 2Nx2N partition size
    5126       pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    5127       AOF(uiPartAddr==0);
    5128     }
    5129 #endif
    51303710  }
    51313711 
     
    53473927  pcCU->clipMv( cMvCand );
    53483928
    5349 #if H_3D_IC
    5350   Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getViewIndex() != pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() );
    5351 #endif
    53523929
    53533930  // prediction pattern
     
    53593936  {
    53603937    xPredInterLumaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, false
    5361 #if H_3D_ARP
    5362       , false
    5363 #endif
    5364 #if H_3D_IC
    5365     , bICFlag
    5366 #endif
    53673938      );
    53683939  }
     
    54103981  pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    54113982 
    5412 #if H_3D_IC
    5413   Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getViewIndex() != pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->getViewIndex() );
    5414   pcPatternKey->setICFlag( bICFlag );
    5415 #endif
    5416 #if H_3D_INTER_SDC
    5417   if ( pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) )
    5418   {
    5419     pcPatternKey->setSDCMRSADFlag( true );
    5420   }
    5421   else
    5422   {
    5423     pcPatternKey->setSDCMRSADFlag( false );
    5424   }
    5425 #endif
    54263983
    54273984  if ( bBi )
     
    54574014 
    54584015  m_pcRdCost->setPredictor  ( *pcMvPred );
    5459 #if H_3D_IC
    5460   if( pcCU->getSlice()->getIsDepth() )
    5461     m_pcRdCost->setCostScale  ( 0 );
    5462   else
    5463 #endif
    54644016  m_pcRdCost->setCostScale  ( 2 );
    54654017
     
    54774029 
    54784030  m_pcRdCost->getMotionCost( 1, 0 );
    5479 #if H_3D_IC
    5480   if( ! pcCU->getSlice()->getIsDepth() )
    5481   {
    5482 #endif
    54834031  m_pcRdCost->setCostScale ( 1 );
    54844032 
     
    54914039  rcMv += (cMvHalf <<= 1);
    54924040  rcMv +=  cMvQter;
    5493 #if H_3D_IC
    5494   }
    5495 #endif
    54964041 
    54974042  UInt uiMvBits = m_pcRdCost->getBits( rcMv.getHor(), rcMv.getVer() );
    5498 #if H_3D_IC
    5499   if( pcCU->getSlice()->getIsDepth() )
    5500     ruiCost += m_pcRdCost->getCost( uiMvBits );
    5501 #endif
    55024043  ruiBits      += uiMvBits;
    55034044  ruiCost       = (UInt)( floor( fWeight * ( (Double)ruiCost - (Double)m_pcRdCost->getCost( uiMvBits ) ) ) + (Double)m_pcRdCost->getCost( ruiBits ) );
     
    55084049{
    55094050  Int  iMvShift = 2;
    5510 #if H_3D_IC
    5511   if( pcCU->getSlice()->getIsDepth() )
    5512     iMvShift = 0;
    5513 #endif
    55144051  TComMv cTmpMvPred = cMvPred;
    55154052  pcCU->clipMv( cTmpMvPred );
     
    55634100
    55644101      setDistParamComp(0);
    5565 #if H_3D_IC
    5566       m_cDistParam.bUseIC = pcPatternKey->getICFlag();
    5567 #endif
    5568 #if H_3D_INTER_SDC
    5569       m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
    5570 #endif
    55714102      m_cDistParam.bitDepth = g_bitDepthY;
    55724103      uiSad = m_cDistParam.DistFunc( &m_cDistParam );
     
    56194150  UInt uiSearchRange = m_iSearchRange;
    56204151  pcCU->clipMv( rcMv );
    5621 #if H_3D_IC
    5622   if( ! pcCU->getSlice()->getIsDepth() )
    5623 #endif
    56244152  rcMv >>= 2;
    56254153  // init TZSearchStruct
     
    56394167      TComMv cMv = m_acMvPredictors[index];
    56404168      pcCU->clipMv( cMv );
    5641 #if H_3D_IC
    5642       if( ! pcCU->getSlice()->getIsDepth() )
    5643 #endif
    56444169      cMv >>= 2;
    56454170      xTZSearchHelp( pcPatternKey, cStruct, cMv.getHor(), cMv.getVer(), 0, 0 );
     
    58474372  Bool      bHighPass    = pcCU->getSlice()->getDepth() ? true : false;
    58484373  UInt      uiBits       = 0, uiBitsBest = 0;
    5849 #if H_3D_VSO
    5850   Dist      uiDistortion = 0, uiDistortionBest = 0;
    5851 #else
    58524374  UInt      uiDistortion = 0, uiDistortionBest = 0;
    5853 #endif
    58544375 
    58554376  UInt      uiWidth      = pcCU->getWidth ( 0 );
     
    58654386    pcYuvPred->copyToPartYuv( rpcYuvRec, 0 );
    58664387
    5867 #if H_3D_VSO // M13
    5868     if ( m_pcRdCost->getUseVSO() )
    5869     {
    5870       uiDistortion = m_pcRdCost->getDistPartVSO( pcCU, 0, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight     , false );
    5871     }
    5872     else   
    5873     {
    5874 #endif
    58754388    uiDistortion = m_pcRdCost->getDistPart(g_bitDepthY, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight      )
    58764389    + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCbAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCbAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_U )
    58774390    + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_V );
    5878 #if H_3D_VSO // MIgnore
    5879     }
    5880 #endif
    58814391
    58824392      m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST]);
     
    58894399    m_pcEntropyCoder->encodeSkipFlag(pcCU, 0, true);
    58904400    m_pcEntropyCoder->encodeMergeIndex( pcCU, 0, true );
    5891 #if H_3D_ARP
    5892     m_pcEntropyCoder->encodeARPW( pcCU, 0 );
    5893 #endif
    5894 #if H_3D_IC
    5895     m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
    5896 #endif
    58974401    uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    58984402    pcCU->getTotalBits()       = uiBits;
    58994403    pcCU->getTotalDistortion() = uiDistortion;
    5900 #if H_3D_VSO //M 14
    5901     if ( m_pcRdCost->getUseLambdaScaleVSO() )   
    5902       pcCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( uiBits, uiDistortion );   
    5903     else
    5904 #endif   
    59054404    pcCU->getTotalCost() = m_pcRdCost->calcRdCost( uiBits, uiDistortion );
    59064405
     
    59104409    pcCU->setTrIdxSubParts( 0, 0, pcCU->getDepth(0) );
    59114410
    5912 #if H_3D_VSO // necessary? // M15
    5913     // set Model
    5914     if( !m_pcRdCost->getUseEstimatedVSD()&& m_pcRdCost->getUseRenModel() )
    5915     {
    5916       Pel*  piSrc       = rpcYuvRec->getLumaAddr();
    5917       UInt  uiSrcStride = rpcYuvRec->getStride();
    5918       m_pcRdCost->setRenModelData( pcCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    5919     }
    5920 #endif
    59214411
    59224412    return;
     
    59484438      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_CURR_BEST ] );
    59494439
    5950 #if H_3D_VSO // M16 // M18
    5951     Dist uiZeroDistortion = 0;
    5952     if ( m_pcRdCost->getUseVSO() )  // This creating and destroying need to be fixed.
    5953     {
    5954       m_cYuvRecTemp.create( pcYuvPred->getWidth(), pcYuvPred->getHeight()  );
    5955     }
    5956 
    5957     xEstimateResidualQT( pcCU, 0, 0, 0, pcYuvOrg, pcYuvPred, rpcYuvResi,  pcCU->getDepth(0), dCost, uiBits, uiDistortion, &uiZeroDistortion );
    5958    
    5959     if ( m_pcRdCost->getUseVSO() )
    5960     {
    5961       m_cYuvRecTemp.destroy();
    5962     }
    5963 #else
    59644440    UInt uiZeroDistortion = 0;
    59654441    xEstimateResidualQT( pcCU, 0, 0, 0, rpcYuvResi,  pcCU->getDepth(0), dCost, uiBits, uiDistortion, &uiZeroDistortion );
    5966 #endif
    59674442   
    59684443    m_pcEntropyCoder->resetBits();
     
    59704445    UInt zeroResiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    59714446
    5972 #if H_3D_VSO  // M19
    5973     Double dZeroCost;
    5974     if( m_pcRdCost->getUseLambdaScaleVSO() )   
    5975       dZeroCost = m_pcRdCost->calcRdCostVSO( 0, uiZeroDistortion );
    5976     else
    5977       dZeroCost = m_pcRdCost->calcRdCost( zeroResiBits, uiZeroDistortion );
    5978 #else
    59794447    Double dZeroCost = m_pcRdCost->calcRdCost( zeroResiBits, uiZeroDistortion );
    5980 #endif
    59814448    if(pcCU->isLosslessCoded( 0 ))
    59824449    { 
    59834450      dZeroCost = dCost + 1;
    59844451    }
    5985 #if H_3D_SPIVMP
    5986     if ( dZeroCost < dCost || pcCU->getQtRootCbf(0)==0)
    5987 #else
    59884452    if ( dZeroCost < dCost )
    5989 #endif
    59904453    {
    59914454      dCost        = dZeroCost;
     
    60164479    }
    60174480   
    6018 #if H_3D_VSO // M20
    6019     Double dExactCost;
    6020     if( m_pcRdCost->getUseLambdaScaleVSO() )   
    6021       dExactCost = m_pcRdCost->calcRdCostVSO( uiBits, uiDistortion );   
    6022     else
    6023       dExactCost = m_pcRdCost->calcRdCost   ( uiBits, uiDistortion );
    6024 #else   
    60254481    Double dExactCost = m_pcRdCost->calcRdCost( uiBits, uiDistortion );
    6026 #endif
    60274482    dCost = dExactCost;
    60284483   
     
    60634518        m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] );
    60644519      }
    6065 #if H_3D_VSO // M21
    6066     if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() )
    6067     {
    6068       Pel*  piSrc       = pcYuvOrg->getLumaAddr();
    6069       UInt  uiSrcStride = pcYuvOrg->getStride();
    6070       m_pcRdCost->setRenModelData( pcCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    6071     }
    6072 #endif
    60734520  }
    60744521  assert ( dCostBest != MAX_DOUBLE );
     
    60984545  rpcYuvRec->addClip ( pcYuvPred, rpcYuvResiBest, 0, uiWidth );
    60994546
    6100 #if H_3D_VSO  // M22 // GT: might be removed since VSO already provided clipped distortion
    6101   if ( m_pcRdCost->getUseVSO() )
    6102   {
    6103     uiDistortionBest = m_pcRdCost->getDistPartVSO  ( pcCU, 0, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight, false );
    6104   }
    6105   else
    6106   {
    6107 #endif
    61084547  // update with clipped distortion and cost (qp estimation loop uses unclipped values)
    61094548    uiDistortionBest = m_pcRdCost->getDistPart(g_bitDepthY, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight      )
    61104549    + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCbAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCbAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_U )
    61114550    + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_V );
    6112 #if H_3D_VSO // M23
    6113   }
    6114   if ( m_pcRdCost->getUseLambdaScaleVSO() )
    6115     dCostBest = m_pcRdCost->calcRdCostVSO( uiBitsBest, uiDistortionBest );
    6116   else
    6117 #endif
    61184551  dCostBest = m_pcRdCost->calcRdCost( uiBitsBest, uiDistortionBest );
    61194552 
     
    61284561 
    61294562  pcCU->setQPSubParts( qpBest, 0, pcCU->getDepth(0) );
    6130 #if H_3D_VSO // M24 // necessary??
    6131   if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() )
    6132   {
    6133     Pel*  piSrc       = rpcYuvRec->getLumaAddr();
    6134     UInt  uiSrcStride = rpcYuvRec->getStride();
    6135     m_pcRdCost->setRenModelData( pcCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    6136   }
    6137 #endif
    61384563}
    61394564
    6140 #if H_3D_INTER_SDC
    6141 Void TEncSearch::encodeResAndCalcRdInterSDCCU( TComDataCU* pcCU, TComYuv* pcOrg, TComYuv* pcPred, TComYuv* pcResi, TComYuv* pcRec, Int uiOffest, const UInt uiDepth )
    6142 {
    6143   if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( 0 ) )
    6144   {
    6145     return;
    6146   }
    6147   pcCU->setSDCFlagSubParts( true, 0, uiDepth );
    6148 
    6149   UInt  uiWidth   = pcCU->getWidth ( 0 );
    6150   UInt  uiHeight  = pcCU->getHeight( 0 );
    6151   UInt  uiSegSize = 0;
    6152 
    6153   Pel *pPred, *pOrg;
    6154   UInt uiPredStride = pcPred->getStride();
    6155   UInt uiOrgStride  = pcOrg->getStride();
    6156   UInt uiPelX, uiPelY;
    6157 
    6158   pPred = pcPred->getLumaAddr( 0 );
    6159   pOrg  = pcOrg->getLumaAddr( 0 );
    6160   Int pResDC = 0;
    6161 
    6162   //calculate dc value for prediction and original signal, and calculate residual and reconstruction
    6163   for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
    6164   {
    6165     for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
    6166     {
    6167       pResDC += (Int)( pOrg [uiPelX] - pPred[uiPelX] );
    6168       uiSegSize++;
    6169     }
    6170     pOrg  += uiOrgStride;
    6171     pPred += uiPredStride;
    6172   }
    6173 
    6174   Int iResiOffset = ( pResDC  > 0 ? ( uiSegSize >> 1 ) : -1*( uiSegSize >> 1 ) );
    6175   pResDC          = ( pResDC + iResiOffset ) / (Int) uiSegSize;
    6176 
    6177   pcCU->setSDCSegmentDCOffset( pResDC + uiOffest, 0, 0 );
    6178 
    6179 
    6180   Pel *pRec;
    6181   UInt uiRecStride  = pcRec->getStride();
    6182   pPred = pcPred->getLumaAddr( 0 );
    6183   pRec  = pcRec->getLumaAddr( 0 );
    6184 
    6185   for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
    6186   {
    6187     for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
    6188     {
    6189       pRec[ uiPelX ] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, pPred[uiPelX] + pcCU->getSDCSegmentDCOffset(0, 0) );
    6190     }
    6191     pPred     += uiPredStride;
    6192     pRec      += uiRecStride;
    6193   }
    6194 
    6195   // clear UV
    6196   UInt  uiStrideC     = pcRec->getCStride();
    6197   Pel   *pRecCb       = pcRec->getCbAddr();
    6198   Pel   *pRecCr       = pcRec->getCrAddr();
    6199 
    6200   for (Int y=0; y < uiHeight/2; y++)
    6201   {
    6202     for (Int x=0; x < uiWidth/2; x++)
    6203     {
    6204       pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
    6205       pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
    6206     }
    6207 
    6208     pRecCb += uiStrideC;
    6209     pRecCr += uiStrideC;
    6210   }
    6211 
    6212   Dist ruiDist;
    6213   Double rdCost;
    6214 #if H_3D_VSO // M13
    6215   if ( m_pcRdCost->getUseVSO() )
    6216   {
    6217     ruiDist = m_pcRdCost->getDistPartVSO( pcCU, 0, pcRec->getLumaAddr(), pcRec->getStride(),  pcOrg->getLumaAddr(), pcOrg->getStride(),  uiWidth,      uiHeight     , false );
    6218   }
    6219   else   
    6220   {
    6221 #endif
    6222     {
    6223       ruiDist = m_pcRdCost->getDistPart( g_bitDepthY, pcRec->getLumaAddr( 0 ), uiRecStride, pcOrg->getLumaAddr( 0 ), uiOrgStride, uiWidth, uiHeight );
    6224     }
    6225 #if H_3D_VSO
    6226   }
    6227 #endif
    6228 
    6229 #if H_3D_DIM_SDC
    6230   Bool bNonSkip = false;
    6231 #else
    6232   Bool bNonSkip = true;
    6233 #endif
    6234   bNonSkip |= ( pcCU->getSDCSegmentDCOffset( 0, 0 ) != 0 ) ? 1 : 0;
    6235   if( !bNonSkip )
    6236   {
    6237     pcCU->getTotalBits()       = MAX_INT;
    6238     pcCU->getTotalDistortion() = MAX_INT;
    6239     pcCU->getTotalCost()       = MAX_DOUBLE;
    6240   }
    6241   else
    6242   {
    6243     //----- determine rate and r-d cost -----
    6244     UInt uiBits = 0;
    6245     TComYuv *pDummy = NULL;
    6246     m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] );
    6247 
    6248     xAddSymbolBitsInter( pcCU, 0, 0, uiBits, pDummy, NULL, pDummy );
    6249 
    6250 #if H_3D_VSO //M 14
    6251     if ( m_pcRdCost->getUseLambdaScaleVSO() )   
    6252     {
    6253       rdCost = m_pcRdCost->calcRdCostVSO( uiBits, ruiDist );   
    6254     }
    6255     else
    6256 #endif
    6257     {
    6258       rdCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
    6259     }
    6260 
    6261     pcCU->getTotalBits()       = m_pcEntropyCoder->getNumberOfWrittenBits();
    6262     pcCU->getTotalDistortion() = ruiDist;
    6263     pcCU->getTotalCost()       = rdCost;
    6264 
    6265     m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] );
    6266   }
    6267 
    6268 #if H_3D_VSO // necessary? // M15
    6269   // set Model
    6270   if( !m_pcRdCost->getUseEstimatedVSD() && m_pcRdCost->getUseRenModel() )
    6271   {
    6272     Pel*  piSrc       = pcRec->getLumaAddr();
    6273     UInt  uiSrcStride = pcRec->getStride();
    6274     m_pcRdCost->setRenModelData( pcCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
    6275   }
    6276 #endif
    6277 }
    6278 #endif
    6279 
    6280 #if H_3D_VSO // M25
    6281 Void TEncSearch::xEstimateResidualQT( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx, UInt absTUPartIdx, TComYuv* pcOrg, TComYuv* pcPred, TComYuv* pcResi, const UInt uiDepth, Double &rdCost, UInt &ruiBits, Dist &ruiDist, Dist *puiZeroDist )
    6282 #else
     4565
    62834566Void TEncSearch::xEstimateResidualQT( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx, UInt absTUPartIdx, TComYuv* pcResi, const UInt uiDepth, Double &rdCost, UInt &ruiBits, UInt &ruiDist, UInt *puiZeroDist )
    6284 #endif
    62854567{
    62864568  const UInt uiTrMode = uiDepth - pcCU->getDepth( 0 );
     
    63194601  Double dSingleCost = MAX_DOUBLE;
    63204602  UInt uiSingleBits = 0;
    6321 #if H_3D_VSO
    6322   Dist uiSingleDist = 0;
    6323 #else
    63244603  UInt uiSingleDist = 0;
    6325 #endif
    63264604  UInt uiAbsSumY = 0, uiAbsSumU = 0, uiAbsSumV = 0;
    63274605  UInt uiBestTransformMode[3] = {0};
     
    64444722    ::memset( m_pTempPel, 0, sizeof( Pel ) * uiNumSamplesLuma ); // not necessary needed for inside of recursion (only at the beginning)
    64454723   
    6446 #if H_3D_VSO // M27
    6447     Dist uiDistY;
    6448     if ( m_pcRdCost->getUseVSO() )
    6449     {
    6450       if( m_pcRdCost->getUseEstimatedVSD() )
    6451       {
    6452         uiDistY = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPartIdx, m_pTempPel, 1<< uiLog2TrSize, pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize, false );
    6453       }
    6454       else
    6455       {     
    6456         uiDistY = m_pcRdCost->getDistPartVSO  ( pcCU, uiAbsPartIdx, pcPred->getLumaAddr( uiAbsPartIdx ), pcPred->getStride(), pcOrg->getLumaAddr( uiAbsPartIdx), pcOrg->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize, false ); // initialized with zero residual distortion
    6457       }
    6458     }
    6459     else
    6460     {
    6461       uiDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pTempPel, trWidth, pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth, trHeight ); // initialized with zero residual destortion
    6462     }
    6463 #else
    64644724    UInt uiDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pTempPel, trWidth, pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth, trHeight ); // initialized with zero residual destortion
    6465 #endif
    64664725
    64674726    if ( puiZeroDist )
     
    64794738      m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only
    64804739
    6481 #if H_3D_VSO // M28     
    6482       Dist uiNonzeroDistY;
    6483       if ( m_pcRdCost->getUseVSO() )
    6484       {
    6485         if ( m_pcRdCost->getUseEstimatedVSD() )
    6486         {         
    6487           uiNonzeroDistY = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPartIdx, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( uiAbsPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride(),  1<< uiLog2TrSize,    1<< uiLog2TrSize, false );
    6488         }
    6489         else
    6490         {       
    6491           m_cYuvRecTemp.addClipPartLuma( &m_pcQTTempTComYuv[uiQTTempAccessLayer], pcPred, uiAbsPartIdx, 1<< uiLog2TrSize  );
    6492           uiNonzeroDistY = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPartIdx, m_cYuvRecTemp.getLumaAddr(uiAbsPartIdx), m_cYuvRecTemp.getStride(),
    6493             pcOrg->getLumaAddr( uiAbsPartIdx ), pcOrg->getStride(), 1<< uiLog2TrSize,   1<< uiLog2TrSize, false );
    6494         }
    6495       }
    6496       else
    6497       {
    6498         uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),      pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth,trHeight );
    6499       }
    6500 #else     
    65014740      const UInt uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),
    65024741      pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth,trHeight );
    6503 #endif
    65044742      if (pcCU->isLosslessCoded(0))
    65054743      {
     
    65084746      else
    65094747      {
    6510 #if H_3D_VSO // M29
    6511         Double singleCostY;
    6512         if ( m_pcRdCost->getUseLambdaScaleVSO())
    6513           singleCostY = m_pcRdCost->calcRdCostVSO( uiSingleBitsY, uiNonzeroDistY );
    6514         else
    6515           singleCostY = m_pcRdCost->calcRdCost( uiSingleBitsY, uiNonzeroDistY );
    6516 #else
    65174748        const Double singleCostY = m_pcRdCost->calcRdCost( uiSingleBitsY, uiNonzeroDistY );
    6518 #endif
    65194749        m_pcEntropyCoder->resetBits();
    65204750        m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_LUMA,     uiTrMode );
    65214751        const UInt uiNullBitsY   = m_pcEntropyCoder->getNumberOfWrittenBits();
    6522 #if H_3D_VSO // M29
    6523         Double nullCostY;
    6524         if ( m_pcRdCost->getUseLambdaScaleVSO())
    6525           nullCostY   = m_pcRdCost->calcRdCostVSO( uiNullBitsY, uiDistY );
    6526         else
    6527           nullCostY   = m_pcRdCost->calcRdCost   ( uiNullBitsY, uiDistY );
    6528 #else
    65294752        const Double nullCostY   = m_pcRdCost->calcRdCost( uiNullBitsY, uiDistY );
    6530 #endif
    65314753        if( nullCostY < singleCostY ) 
    65324754        {   
     
    65534775      m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_LUMA, uiTrMode );
    65544776      const UInt uiNullBitsY = m_pcEntropyCoder->getNumberOfWrittenBits();
    6555 #if H_3D_VSO // M NEW01
    6556       if ( m_pcRdCost->getUseRenModel() )
    6557         minCostY = m_pcRdCost->calcRdCostVSO( uiNullBitsY, uiDistY );
    6558       else
    6559 #endif
    65604777      minCostY = m_pcRdCost->calcRdCost( uiNullBitsY, uiDistY );
    65614778    }
     
    67254942    if( checkTransformSkipY )
    67264943    {
    6727 #if H_3D_VSO
    6728       Dist uiNonzeroDistY;
    6729       UInt uiAbsSumTransformSkipY;
    6730 #else
    67314944      UInt uiNonzeroDistY, uiAbsSumTransformSkipY;
    6732 #endif
    67334945      Double dSingleCostY;
    67344946
     
    67854997        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType, true );
    67864998
    6787 #if H_3D_VSO // M NEW       
    6788         if ( m_pcRdCost->getUseVSO() )
    6789         {
    6790           if ( m_pcRdCost->getUseEstimatedVSD() )
    6791           {         
    6792             uiNonzeroDistY = m_pcRdCost->getDistPartVSD( pcCU,  uiAbsPartIdx, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( uiAbsPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride(),  1<< uiLog2TrSize,    1<< uiLog2TrSize, false );
    6793           }
    6794           else
    6795           {       
    6796             m_cYuvRecTemp.addClipPartLuma( &m_pcQTTempTComYuv[uiQTTempAccessLayer], pcPred, uiAbsPartIdx, 1<< uiLog2TrSize  );
    6797             uiNonzeroDistY = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPartIdx, m_cYuvRecTemp.getLumaAddr(uiAbsPartIdx), m_cYuvRecTemp.getStride(),
    6798               pcOrg->getLumaAddr( uiAbsPartIdx ), pcOrg->getStride(), 1<< uiLog2TrSize,   1<< uiLog2TrSize, false );
    6799           }
    6800         }
    6801         else
    6802 #endif
    68034999          uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),
    68045000          pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth, trHeight );
    68055001
    6806 #if H_3D_VSO
    6807         if ( m_pcRdCost->getUseRenModel() )
    6808           dSingleCostY = m_pcRdCost->calcRdCostVSO( uiTsSingleBitsY, uiNonzeroDistY );
    6809         else
    6810 #endif
    68115002        dSingleCostY = m_pcRdCost->calcRdCost( uiTsSingleBitsY, uiNonzeroDistY );
    68125003      }
     
    70155206
    70165207    uiSingleDist = uiDistY + uiDistU + uiDistV;
    7017 #if H_3D_VSO // M30
    7018     if ( m_pcRdCost->getUseLambdaScaleVSO())   
    7019       dSingleCost = m_pcRdCost->calcRdCostVSO( uiSingleBits, uiSingleDist );   
    7020     else
    7021 #endif
    70225208    dSingleCost = m_pcRdCost->calcRdCost( uiSingleBits, uiSingleDist );
    70235209  } 
     
    70315217      m_pcRDGoOnSbacCoder->load ( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    70325218    }
    7033 #if H_3D_VSO
    7034     Dist uiSubdivDist = 0;
    7035 #else
    70365219    UInt uiSubdivDist = 0;
    7037 #endif
    70385220    UInt uiSubdivBits = 0;
    70395221    Double dSubdivCost = 0.0;
     
    70435225    {
    70445226      UInt nsAddr = uiAbsPartIdx + ui * uiQPartNumSubdiv;
    7045 #if H_3D_VSO // M31
    7046       xEstimateResidualQT( pcCU, ui, uiAbsPartIdx + ui * uiQPartNumSubdiv, nsAddr, pcOrg, pcPred, pcResi, uiDepth + 1, dSubdivCost, uiSubdivBits, uiSubdivDist, bCheckFull ? NULL : puiZeroDist );
    7047 #else
    70485227      xEstimateResidualQT( pcCU, ui, uiAbsPartIdx + ui * uiQPartNumSubdiv, nsAddr, pcResi, uiDepth + 1, dSubdivCost, uiSubdivBits, uiSubdivDist, bCheckFull ? NULL : puiZeroDist );
    7049 #endif
    70505228    }
    70515229   
     
    70755253   
    70765254    uiSubdivBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    7077 #if H_3D_VSO // M32
    7078     if ( m_pcRdCost->getUseLambdaScaleVSO())
    7079       dSubdivCost  = m_pcRdCost->calcRdCostVSO( uiSubdivBits, uiSubdivDist );
    7080     else
    7081 #endif
    70825255    dSubdivCost  = m_pcRdCost->calcRdCost( uiSubdivBits, uiSubdivDist );
    70835256   
     
    71025275    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_TEST ] );
    71035276  }
    7104 #if H_3D_VSO // M33
    7105   if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() )
    7106   {
    7107     UInt  uiWidth     = 1<< uiLog2TrSize;
    7108     UInt  uiHeight    = 1<< uiLog2TrSize;
    7109     Pel*  piSrc;
    7110     UInt  uiSrcStride;
    7111     if ( uiAbsSumY )
    7112     {
    7113       UInt  uiQTLayer   = pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - uiLog2TrSize;
    7114       m_cYuvRecTemp.addClipPartLuma( &m_pcQTTempTComYuv[uiQTLayer], pcPred, uiAbsPartIdx, 1<< uiLog2TrSize  );
    7115       piSrc       = m_cYuvRecTemp.getLumaAddr( uiAbsPartIdx );
    7116       uiSrcStride = m_cYuvRecTemp.getStride  ();
    7117     }
    7118     else
    7119     {
    7120       piSrc       = pcPred->getLumaAddr( uiAbsPartIdx );
    7121       uiSrcStride = pcPred->getStride  ();
    7122     }
    7123     m_pcRdCost->setRenModelData( pcCU, uiAbsPartIdx, piSrc, (Int) uiSrcStride, (Int) uiWidth, (Int) uiHeight );
    7124   }
    7125 #endif
    71265277  rdCost += dSingleCost;
    71275278  ruiBits += uiSingleBits;
     
    73155466    // Reload only contexts required for coding intra mode information
    73165467    m_pcRDGoOnSbacCoder->loadIntraDirModeLuma( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    7317 #if H_3D_DIM
    7318     m_pcRDGoOnSbacCoder->loadIntraDepthMode( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
    7319 #endif
    73205468 
    73215469  pcCU->setLumaIntraDirSubParts ( uiMode, uiPartOffset, uiDepth + uiInitTrDepth );
     
    73725520    m_pcEntropyCoder->encodeSkipFlag(pcCU, 0, true);
    73735521    m_pcEntropyCoder->encodeMergeIndex(pcCU, 0, true);
    7374 #if H_3D_ARP
    7375     m_pcEntropyCoder->encodeARPW( pcCU, 0 );
    7376 #endif
    7377 #if H_3D_IC
    7378     m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
    7379 #endif
    73805522    ruiBits += m_pcEntropyCoder->getNumberOfWrittenBits();
    73815523  }
     
    73885530    }
    73895531    m_pcEntropyCoder->encodeSkipFlag ( pcCU, 0, true );
    7390 #if MTK_SINGLE_DEPTH_MODE_I0095
    7391     m_pcEntropyCoder->encodeSingleDepthMode ( pcCU, 0, true );
    7392 #endif
    73935532    m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
    73945533    m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
    7395 #if H_3D_DIM_SDC
    7396     m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
    7397 #endif
    73985534    m_pcEntropyCoder->encodePredInfo( pcCU, 0, true );
    7399 #if H_3D_ARP
    7400     m_pcEntropyCoder->encodeARPW( pcCU , 0 );
    7401 #endif
    7402 #if H_3D_IC
    7403     m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
    7404 #endif
    74055535    Bool bDummy = false;
    74065536    m_pcEntropyCoder->encodeCoeff   ( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0), bDummy );
     
    76515781}
    76525782
    7653 #if H_3D_DIM
    7654   // -------------------------------------------------------------------------------------------------------------------
    7655   // Depth intra search
    7656   // -------------------------------------------------------------------------------------------------------------------
    7657 Void TEncSearch::xCalcBiSegDCs( Pel* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& valDC1, Pel& valDC2 )
    7658 {
    7659   valDC1 = ( 1<<( g_bitDepthY - 1) );
    7660   valDC2 = ( 1<<( g_bitDepthY - 1) );
    7661 
    7662   UInt uiDC1 = 0;
    7663   UInt uiDC2 = 0;
    7664   UInt uiNumPixDC1 = 0, uiNumPixDC2 = 0;
    7665   if( srcStride == patternStride )
    7666   {
    7667     for( UInt k = 0; k < (patternStride * patternStride); k++ )
    7668     {
    7669       if( true == biSegPattern[k] )
    7670       {
    7671         uiDC2 += ptrSrc[k];
    7672         uiNumPixDC2++;
    7673       }
    7674       else
    7675       {
    7676         uiDC1 += ptrSrc[k];
    7677         uiNumPixDC1++;
    7678       }
    7679     }
    7680   }
    7681   else
    7682   {
    7683     Pel* piTemp = ptrSrc;
    7684     for( UInt uiY = 0; uiY < patternStride; uiY++ )
    7685     {
    7686       for( UInt uiX = 0; uiX < patternStride; uiX++ )
    7687       {
    7688         if( true == biSegPattern[uiX] )
    7689         {
    7690           uiDC2 += piTemp[uiX];
    7691           uiNumPixDC2++;
    7692         }
    7693         else
    7694         {
    7695           uiDC1 += piTemp[uiX];
    7696           uiNumPixDC1++;
    7697         }
    7698       }
    7699       piTemp       += srcStride;
    7700       biSegPattern += patternStride;
    7701     }
    7702   }
    7703 
    7704   if( uiNumPixDC1 > 0 ) { valDC1 = uiDC1 / uiNumPixDC1; }
    7705   if( uiNumPixDC2 > 0 ) { valDC2 = uiDC2 / uiNumPixDC2; }
    7706 }
    7707 
    7708 #if H_3D_DIM_DMM
    7709 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 )
    7710 {
    7711   assert( biSegPattern );
    7712   Pel origDC1 = 0; Pel origDC2 = 0;
    7713   xCalcBiSegDCs  ( piOrig,   uiStride, biSegPattern, patternStride, origDC1, origDC2 );
    7714   xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, origDC1, origDC2 );
    7715 
    7716   Int* piMask = pcCU->getPattern()->getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt ); // no filtering for DMM
    7717   Int  maskStride = 2*uiWidth + 1;
    7718   Int* ptrSrc = piMask+maskStride+1;
    7719   Pel  predDC1 = 0; Pel predDC2 = 0;
    7720   xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 );
    7721 
    7722   rDeltaDC1 = origDC1 - predDC1;
    7723   rDeltaDC2 = origDC2 - predDC2;
    7724 
    7725 #if H_3D_VSO
    7726   if( m_pcRdCost->getUseVSO() )
    7727   {
    7728     Pel fullDeltaDC1 = rDeltaDC1;
    7729     Pel fullDeltaDC2 = rDeltaDC2;
    7730 
    7731     Dist uiBestDist      = RDO_DIST_MAX;
    7732     UInt  uiBestQStepDC1 = 0;
    7733     UInt  uiBestQStepDC2 = 0;
    7734 
    7735     UInt uiDeltaDC1Max = abs(fullDeltaDC1);
    7736     UInt uiDeltaDC2Max = abs(fullDeltaDC2);
    7737 
    7738     //VSO Level delta DC check range extension
    7739     uiDeltaDC1Max += (uiDeltaDC1Max>>1);
    7740     uiDeltaDC2Max += (uiDeltaDC2Max>>1);
    7741 
    7742     // limit search range to [0, IBDI_MAX]
    7743     if( fullDeltaDC1 <  0 && uiDeltaDC1Max >                          abs(predDC1) ) { uiDeltaDC1Max =                          abs(predDC1); }
    7744     if( fullDeltaDC1 >= 0 && uiDeltaDC1Max > ((1 << g_bitDepthY)-1) - abs(predDC1) ) { uiDeltaDC1Max = ((1 << g_bitDepthY)-1) - abs(predDC1); }
    7745 
    7746     if( fullDeltaDC2 <  0 && uiDeltaDC2Max >                          abs(predDC2) ) { uiDeltaDC2Max =                          abs(predDC2); }
    7747     if( fullDeltaDC2 >= 0 && uiDeltaDC2Max > ((1 << g_bitDepthY)-1) - abs(predDC2) ) { uiDeltaDC2Max = ((1 << g_bitDepthY)-1) - abs(predDC2); }
    7748 
    7749     // init dist with original segment DCs
    7750     xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, origDC1, origDC2 );
    7751 
    7752     Dist uiOrgDist = RDO_DIST_MAX;
    7753     if( m_pcRdCost->getUseEstimatedVSD() )
    7754     {
    7755       uiOrgDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
    7756     }
    7757     else
    7758     {
    7759       uiOrgDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
    7760     }
    7761 
    7762     uiBestDist     = uiOrgDist;
    7763     uiBestQStepDC1 = abs(fullDeltaDC1);
    7764     uiBestQStepDC2 = abs(fullDeltaDC2);
    7765 
    7766     // coarse search with step size 4
    7767     for( UInt uiQStepDC1 = 0; uiQStepDC1 < uiDeltaDC1Max; uiQStepDC1 += 4 )
    7768     {
    7769       Pel testDC1 = ClipY( predDC1 + ((Int)(uiQStepDC1) * (( fullDeltaDC1 < 0 ) ? -1 : 1)) );
    7770       for( UInt uiQStepDC2 = 0; uiQStepDC2 < uiDeltaDC2Max; uiQStepDC2 += 4 )
    7771       {
    7772         Pel testDC2 = ClipY( predDC2 + ((Int)(uiQStepDC2) * (( fullDeltaDC2 < 0 ) ? -1 : 1)) );
    7773 
    7774         xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, testDC1, testDC2 );
    7775 
    7776         Dist uiAct4Dist = RDO_DIST_MAX;
    7777         if( m_pcRdCost->getUseEstimatedVSD() )
    7778         {
    7779           uiAct4Dist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
    7780         }
    7781         else
    7782         {
    7783           uiAct4Dist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
    7784         }
    7785 
    7786         if( uiAct4Dist < uiBestDist || uiBestDist == RDO_DIST_MAX )
    7787         {
    7788           uiBestDist     = uiAct4Dist;
    7789           uiBestQStepDC1 = uiQStepDC1;
    7790           uiBestQStepDC2 = uiQStepDC2;
    7791         }
    7792       }
    7793     }
    7794 
    7795     // refinement +-3
    7796     for( UInt uiQStepDC1 = (UInt)max(0, ((Int)uiBestQStepDC1-3)); uiQStepDC1 <= (uiBestQStepDC1+3); uiQStepDC1++ )
    7797     {
    7798       Pel testDC1 = ClipY( predDC1 + ((Int)(uiQStepDC1) * (( fullDeltaDC1 < 0 ) ? -1 : 1)) );
    7799       for( UInt uiQStepDC2 = (UInt)max(0, ((Int)uiBestQStepDC2-3)); uiQStepDC2 <= (uiBestQStepDC2+3); uiQStepDC2++ )
    7800       {
    7801         Pel testDC2 = ClipY( predDC2 + ((Int)(uiQStepDC2) * (( fullDeltaDC2 < 0 ) ? -1 : 1)) );
    7802 
    7803         xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, testDC1, testDC2 );
    7804 
    7805         Dist uiActDist = RDO_DIST_MAX;
    7806         if( m_pcRdCost->getUseEstimatedVSD() )
    7807         {
    7808           uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
    7809         }
    7810         else
    7811         {
    7812           uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
    7813         }
    7814 
    7815         if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX )
    7816         {
    7817           uiBestDist     = uiActDist;
    7818           uiBestQStepDC1 = uiQStepDC1;
    7819           uiBestQStepDC2 = uiQStepDC2;
    7820         }
    7821       }
    7822     }
    7823     rDeltaDC1 = (Int)(uiBestQStepDC1) * (Int)(( fullDeltaDC1 < 0 ) ? -1 : 1);
    7824     rDeltaDC2 = (Int)(uiBestQStepDC2) * (Int)(( fullDeltaDC2 < 0 ) ? -1 : 1);
    7825   }
    7826 #endif
    7827 
    7828 #if H_3D_DIM_DLT
    7829   rDeltaDC1 = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), ClipY(predDC1 + rDeltaDC1) ) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 );
    7830   rDeltaDC2 = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), ClipY(predDC2 + rDeltaDC2) ) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 );
    7831 #endif
    7832 }
    7833 
    7834 Void TEncSearch::xSearchDmm1Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx )
    7835 {
    7836   ruiTabIdx = 0;
    7837 
    7838   // local pred buffer
    7839   TComYuv cPredYuv;
    7840   cPredYuv.create( uiWidth, uiHeight );
    7841   cPredYuv.clear();
    7842 
    7843   UInt uiPredStride = cPredYuv.getStride();
    7844   Pel* piPred       = cPredYuv.getLumaAddr();
    7845 
    7846   Pel refDC1 = 0; Pel refDC2 = 0;
    7847 #if SHARP_DMM1_I0110
    7848   WedgeList*     pacWedgeList     = pcCU->isDMM1UpscaleMode( uiWidth ) ? &g_dmmWedgeLists[(g_aucConvertToBit[pcCU->getDMM1BasePatternWidth(uiWidth)])] : &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
    7849   WedgeNodeList* pacWedgeNodeList = pcCU->isDMM1UpscaleMode( uiWidth ) ? &g_dmmWedgeNodeLists[(g_aucConvertToBit[pcCU->getDMM1BasePatternWidth(uiWidth)])] : &g_dmmWedgeNodeLists[(g_aucConvertToBit[uiWidth])];
    7850 #else
    7851   WedgeList*     pacWedgeList     = &g_dmmWedgeLists    [(g_aucConvertToBit[uiWidth])];
    7852   WedgeNodeList* pacWedgeNodeList = &g_dmmWedgeNodeLists[(g_aucConvertToBit[uiWidth])];
    7853 #endif
    7854 
    7855   // coarse wedge search
    7856   Dist uiBestDist   = RDO_DIST_MAX;
    7857   UInt uiBestNodeId = 0;
    7858   for( UInt uiNodeId = 0; uiNodeId < pacWedgeNodeList->size(); uiNodeId++ )
    7859   {
    7860     TComWedgelet* pcWedgelet = &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx()));
    7861 #if SHARP_DMM1_I0110
    7862     Bool *pbPattern = pcCU->isDMM1UpscaleMode(uiWidth) ? pcWedgelet->getScaledPattern(uiWidth) : pcWedgelet->getPattern();
    7863     UInt uiStride   = pcCU->isDMM1UpscaleMode(uiWidth) ? uiWidth : pcWedgelet->getStride();
    7864     xCalcBiSegDCs  ( piRef,  uiRefStride,  pbPattern, uiStride, refDC1, refDC2 );
    7865     xAssignBiSegDCs( piPred, uiPredStride, pbPattern, uiStride, refDC1, refDC2 );
    7866 #else
    7867     xCalcBiSegDCs  ( piRef,  uiRefStride,  pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 );
    7868     xAssignBiSegDCs( piPred, uiPredStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 );
    7869 #endif
    7870 
    7871     Dist uiActDist = RDO_DIST_MAX;
    7872 #if H_3D_VSO
    7873     if( m_pcRdCost->getUseVSO() )
    7874     {
    7875       if( m_pcRdCost->getUseEstimatedVSD() )
    7876       {
    7877         uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false );
    7878       }
    7879       else
    7880       {
    7881         uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false );
    7882       }
    7883     }
    7884     else
    7885 #endif
    7886     {
    7887       uiActDist = m_pcRdCost->getDistPart( g_bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, TEXT_LUMA, DF_SAD );
    7888     }
    7889 
    7890     if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX )
    7891     {
    7892       uiBestDist   = uiActDist;
    7893       uiBestNodeId = uiNodeId;
    7894     }
    7895   }
    7896 
    7897   // refinement
    7898   Dist uiBestDistRef = uiBestDist;
    7899   UInt uiBestTabIdxRef  = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx();
    7900   for( UInt uiRefId = 0; uiRefId < DMM_NUM_WEDGE_REFINES; uiRefId++ )
    7901   {
    7902     if( pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ) != DMM_NO_WEDGEINDEX )
    7903     {
    7904       TComWedgelet* pcWedgelet = &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId )));
    7905 #if SHARP_DMM1_I0110
    7906       Bool *pbPattern = pcCU->isDMM1UpscaleMode(uiWidth) ? pcWedgelet->getScaledPattern(uiWidth) : pcWedgelet->getPattern();
    7907       UInt uiStride   = pcCU->isDMM1UpscaleMode(uiWidth) ? uiWidth : pcWedgelet->getStride();
    7908       xCalcBiSegDCs  ( piRef,  uiRefStride,  pbPattern, uiStride, refDC1, refDC2 );
    7909       xAssignBiSegDCs( piPred, uiPredStride, pbPattern, uiStride, refDC1, refDC2 );
    7910 #else
    7911       xCalcBiSegDCs  ( piRef,  uiRefStride,  pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 );
    7912       xAssignBiSegDCs( piPred, uiPredStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 );
    7913 #endif
    7914       Dist uiActDist = RDO_DIST_MAX;
    7915 #if H_3D_VSO
    7916       if( m_pcRdCost->getUseVSO() )
    7917       {
    7918         if( m_pcRdCost->getUseEstimatedVSD() ) //PM: use VSO instead of VSD here?
    7919         {
    7920           uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false );
    7921         }
    7922         else
    7923         {
    7924           uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false );
    7925         }
    7926       }
    7927       else
    7928 #endif
    7929       {
    7930         uiActDist = m_pcRdCost->getDistPart( g_bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, TEXT_LUMA, DF_SAD );
    7931       }
    7932 
    7933       if( uiActDist < uiBestDistRef || uiBestDistRef == RDO_DIST_MAX )
    7934       {
    7935         uiBestDistRef   = uiActDist;
    7936         uiBestTabIdxRef = pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId );
    7937       }
    7938     }
    7939   }
    7940 
    7941   ruiTabIdx = uiBestTabIdxRef;
    7942 
    7943   cPredYuv.destroy();
    7944   return;
    7945 }
    7946 
    7947 
    7948 #endif
    7949 
    7950 #endif
    79515783//! \}
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncSearch.h

    r1039 r1072  
    121121  Int             m_iMaxDeltaQP;
    122122
    123 #if H_3D_VSO // M17
    124   TComYuv         m_cYuvRecTemp;
    125 #endif
    126123  // AMVP cost computation
    127124  // UInt            m_auiMVPIdxCost[AMVP_MAX_NUM_CANDS+1][AMVP_MAX_NUM_CANDS];
     
    181178                                  UInt&       ruiDistC,
    182179                                  Bool        bLumaOnly
    183 #if HHI_DMM4_ENC_I0066
    184                                 , Bool        bOnlyIVP
    185 #endif
    186180                                );
    187181  Void  estIntraPredChromaQT    ( TComDataCU* pcCU,
     
    191185                                  TComYuv*    pcRecoYuv,
    192186                                  UInt        uiPreCalcDistC );
    193 #if MTK_SINGLE_DEPTH_MODE_I0095
    194   Void  estIntraPredSingleDepth  ( TComDataCU* pcCU,
    195                                   TComYuv*    pcOrgYuv,
    196                                   TComYuv*    pcPredYuv,
    197                                   TComYuv*    pcResiYuv,
    198                                   TComYuv*    pcRecoYuv,
    199                                   UInt&       ruiDistC,
    200                                   Bool        bLumaOnly );
    201 #endif   
    202187 
    203188  /// encoder estimation - inter prediction (non-skip)
     
    207192                                  TComYuv*&   rpcResiYuv,
    208193                                  TComYuv*&   rpcRecoYuv,
    209 #if H_3D_FAST_TEXTURE_ENCODING
    210                                   Bool        bFMD,
    211 #endif
    212194                                  Bool        bUseRes = false
    213195#if AMP_MRG
     
    224206                                  TComYuv*&   rpcYuvRec,
    225207                                  Bool        bSkipRes );
    226 #if H_3D_INTER_SDC
    227   Void encodeResAndCalcRdInterSDCCU( TComDataCU* pcCU,
    228     TComYuv* pcOrg,
    229     TComYuv* pcPred,
    230     TComYuv* pcResi,
    231     TComYuv* pcRec,
    232     Int      uiOffset,
    233     const UInt uiDepth );
    234 #endif
    235208  /// set ME search range
    236209  Void setAdaptiveSearchRange   ( Int iDir, Int iRefIdx, Int iSearchRange) { m_aaiAdaptSR[iDir][iRefIdx] = iSearchRange; }
     
    278251                                    TComYuv*     pcPredYuv,
    279252                                    TComYuv*     pcResiYuv,
    280 #if H_3D_VSO
    281                                     Dist&        ruiDist,
    282 #else
    283253                                    UInt&        ruiDist,
    284 #endif
    285254                                    Int         default0Save1Load2 = 0
    286 #if H_3D_DIM_ENC
    287                                   , Bool          zeroResi = false
    288 #endif
    289255                                    );
    290256  Void  xIntraCodingChromaBlk     ( TComDataCU*  pcCU,
     
    305271                                    TComYuv*     pcPredYuv,
    306272                                    TComYuv*     pcResiYuv,
    307 #if H_3D_VSO
    308                                     Dist&        ruiDistY,
    309 #else
    310273                                    UInt&        ruiDistY,
    311 #endif
    312274                                    UInt&        ruiDistC,
    313275#if HHI_RQT_INTRA_SPEEDUP
     
    315277#endif
    316278                                   Double&      dRDCost
    317 #if H_3D_DIM_ENC
    318                                    , Bool          zeroResi = false
    319 #endif
    320279                                   );
    321280 
     
    354313                                    UInt         uiAbsPartIdx,
    355314                                    UInt         stateU0V1Both2 );
    356 #if MTK_SINGLE_DEPTH_MODE_I0095
    357   Void xIntraCodingSingleDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Int iTestDepthIdx, Pel * DepthNeighbor );
    358 #endif
    359 #if H_3D_DIM
    360   // -------------------------------------------------------------------------------------------------------------------
    361   // Depth intra search
    362   // -------------------------------------------------------------------------------------------------------------------
    363   Void xCalcBiSegDCs              ( Pel* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& valDC1, Pel& valDC2 );
    364 #if H_3D_DIM_DMM
    365   Void xSearchDmmDeltaDCs         ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 );
    366   Void xSearchDmm1Wedge           ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx );
    367 #endif
    368 #if H_3D_DIM_SDC
    369   Void xIntraCodingSDC            ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi    );
    370 #endif
    371 #endif
    372315
    373316  // -------------------------------------------------------------------------------------------------------------------
     
    427370                                  , TComMvField* cMvFieldNeighbours, 
    428371                                    UChar* uhInterDirNeighbours
    429 #if H_3D_VSP
    430                                   , Int* vspFlag
    431 #if !FIX_TICKET_79
    432                                   , InheritedVSPDisInfo*  inheritedVSPDisInfo
    433 #endif
    434 #endif
    435 #if H_3D_SPIVMP
    436                                   , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
    437 #endif
    438372                                  , Int& numValidMergeCand
    439373                                   );
     
    443377                                    TComMvField*    mvFieldNeighbours,
    444378                                    UChar*          interDirNeighbours,
    445 #if H_3D_VSP && !FIX_TICKET_75
    446                                     Int* vspFlag,
    447 #endif
    448379                                    Int             numValidMergeCand );
    449380
     
    514445 
    515446  Void xEncodeResidualQT( TComDataCU* pcCU, UInt uiAbsPartIdx, const UInt uiDepth, Bool bSubdivAndCbf, TextType eType );
    516 #if H_3D_VSO // M26
    517   Void xEstimateResidualQT( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx, UInt absTUPartIdx,TComYuv* pcOrg, TComYuv* pcPred, TComYuv* pcResi, const UInt uiDepth, Double &rdCost, UInt &ruiBits, Dist &ruiDist, Dist *puiZeroDist );
    518 #else
    519447  Void xEstimateResidualQT( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx, UInt absTUPartIdx,TComYuv* pcResi, const UInt uiDepth, Double &rdCost, UInt &ruiBits, UInt &ruiDist, UInt *puiZeroDist );
    520 #endif
    521448  Void xSetResidualQTData( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx,UInt absTUPartIdx, TComYuv* pcResi, UInt uiDepth, Bool bSpatial );
    522449 
  • branches/HTM-12.1-MV-draft-1/source/Lib/TLibEncoder/TEncSlice.cpp

    r976 r1072  
    157157  m_pdRdPicQp         = (Double*)xMalloc( Double, m_pcCfg->getDeltaQpRD() * 2 + 1 );
    158158  m_piRdPicQp         = (Int*   )xMalloc( Int,    m_pcCfg->getDeltaQpRD() * 2 + 1 );
    159 #if KWU_RC_MADPRED_E0227
    160   if(m_pcCfg->getUseRateCtrl())
    161   {
    162     m_pcRateCtrl        = pcEncTop->getRateCtrl();
    163   }
    164   else
    165   {
    166     m_pcRateCtrl        = NULL;
    167   }
    168 #else
    169159  m_pcRateCtrl        = pcEncTop->getRateCtrl();
    170 #endif
    171160}
    172161
     
    204193  rpcSlice->setViewId      ( pVPS->getViewId      ( layerId ) );   
    205194  rpcSlice->setViewIndex   ( pVPS->getViewIndex   ( layerId ) );
    206 #if H_3D
    207   rpcSlice->setIsDepth     ( pVPS->getDepthId     ( layerId ) != 0 );   
    208 #endif
    209195#endif
    210196  rpcSlice->setSPS( pSPS );
     
    215201  rpcSlice->setPicOutputFlag( true );
    216202  rpcSlice->setPOC( pocCurr );
    217 #if H_3D_IC
    218   rpcSlice->setApplyIC( false );
    219 #endif
    220203  // depth computation based on GOP size
    221204  Int depth;
     
    437420  m_pcRdCost ->setLambda( dLambda );
    438421
    439 #if H_3D_VSO
    440   m_pcRdCost->setUseLambdaScaleVSO  ( (m_pcCfg->getUseVSO() ||  m_pcCfg->getForceLambdaScaleVSO()) && m_pcCfg->getIsDepth() );
    441   m_pcRdCost->setLambdaVSO          ( dLambda * m_pcCfg->getLambdaScaleVSO() );
    442 
    443   // Should be moved to TEncTop
    444  
    445   // SAIT_VSO_EST_A0033
    446   m_pcRdCost->setDisparityCoeff( m_pcCfg->getDispCoeff() );
    447 
    448   // LGE_WVSO_A0119
    449   if( m_pcCfg->getUseWVSO() && m_pcCfg->getIsDepth() )
    450   {
    451     m_pcRdCost->setDWeight  ( m_pcCfg->getDWeight()   );
    452     m_pcRdCost->setVSOWeight( m_pcCfg->getVSOWeight() );
    453     m_pcRdCost->setVSDWeight( m_pcCfg->getVSDWeight() );
    454   }
    455 
    456 #endif
    457422
    458423// for RDO
     
    607572  rpcSlice->setSliceSegmentMode     ( m_pcCfg->getSliceSegmentMode()     );
    608573  rpcSlice->setSliceSegmentArgument ( m_pcCfg->getSliceSegmentArgument() );
    609 #if H_3D_IV_MERGE
    610   if(rpcSlice->getIsDepth())
    611   {
    612     rpcSlice->setMaxNumMergeCand      ( m_pcCfg->getMaxNumMergeCand()   + ( ( rpcSlice->getVPS()->getMPIFlag( rpcSlice->getLayerIdInVps() ) || rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ) ? 1 : 0 ) );
    613   }
    614   else
    615   {
    616     rpcSlice->setMaxNumMergeCand      ( m_pcCfg->getMaxNumMergeCand()   + ( rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ? 1 : 0 ) );
    617   }
    618 #else
    619574  rpcSlice->setMaxNumMergeCand        ( m_pcCfg->getMaxNumMergeCand()        );
    620 #endif
    621575  xStoreWPparam( pPPS->getUseWP(), pPPS->getWPBiPred() );
    622576}
     
    766720   
    767721    Double dPicRdCost;
    768 #if H_3D_VSO
    769     Dist64 uiPicDist        = m_uiPicDist;
    770 #else
    771722    UInt64 uiPicDist        = m_uiPicDist;
    772 #endif
    773723    UInt64 uiALFBits        = 0;
    774724   
     
    777727    // compute RD cost and choose the best
    778728    dPicRdCost = m_pcRdCost->calcRdCost64( m_uiPicTotalBits + uiALFBits, uiPicDist, true, DF_SSE_FRAME);
    779 #if H_3D
    780     // Above calculation need to be fixed for VSO, including frameLambda value.
    781 #endif
    782729   
    783730    if ( dPicRdCost < dPicRdCostBest )
     
    925872  Int  iNumSubstreams = 1;
    926873  UInt uiTilesAcross  = 0;
    927 #if H_3D_IC
    928   if ( pcEncTop->getViewIndex() && pcEncTop->getUseIC() &&
    929        !( ( pcSlice->getSliceType() == P_SLICE && pcSlice->getPPS()->getUseWP() ) || ( pcSlice->getSliceType() == B_SLICE && pcSlice->getPPS()->getWPBiPred() ) )
    930      )
    931   {
    932     pcSlice ->xSetApplyIC(pcEncTop->getUseICLowLatencyEnc());
    933     if ( pcSlice->getApplyIC() )
    934     {
    935       pcSlice->setIcSkipParseFlag( pcSlice->getPOC() % m_pcCfg->getIntraPeriod() != 0 );<