Changeset 1360 in 3DVCSoftware for branches/HTM-15.2-dev/source/Lib/TLibCommon


Ignore:
Timestamp:
28 Oct 2015, 17:46:00 (9 years ago)
Author:
tech
Message:

Update to HM-16.7.

Location:
branches/HTM-15.2-dev/source/Lib/TLibCommon
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/CommonDef.h

    r1357 r1360  
    4242#include <iostream>
    4343#include <assert.h>
     44#include <limits>
    4445
    4546#if _MSC_VER > 1000
     
    7576#define HM_VERSION        "16.6"                ///<
    7677#else
    77 #define NV_VERSION        "16.6"                 ///< Current software version
     78#define NV_VERSION        "16.7"                 ///< Current software version
    7879#endif
    7980// ====================================================================================================================
     
    141142
    142143static const Int AMVP_MAX_NUM_CANDS =                               2; ///< AMVP: advanced motion vector prediction - max number of final candidates
    143 static const Int AMVP_MAX_NUM_CANDS_MEM =                           3; ///< AMVP: advanced motion vector prediction - max number of candidates
    144144static const Int AMVP_DECIMATION_FACTOR =                           4;
    145145static const Int MRG_MAX_NUM_CANDS =                                5; ///< MERGE
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/Debug.cpp

    r1321 r1360  
    4949#if DEBUG_STRING
    5050// these strings are used to reorder the debug output so that the encoder and decoder match.
    51 const Char *debug_reorder_data_inter_token[MAX_NUM_COMPONENT+1]
     51const TChar *debug_reorder_data_inter_token[MAX_NUM_COMPONENT+1]
    5252 = {"Start of channel 0 inter debug\n", "Start of channel 1 inter debug\n", "Start of channel 2 inter debug\n", "End of inter residual debug\n"} ;
    53 const Char *partSizeToString[NUMBER_OF_PART_SIZES]={"2Nx2N(0)", "2NxN(1)", "Nx2N(2)", "NxN(3)", "2Nx(N/2+3N/2)(4)", "2Nx(3N/2+N/2)(5)", "(N/2+3N/2)x2N(6)", "(3N/2+N/2)x2N(7)"};
     53const TChar *partSizeToString[NUMBER_OF_PART_SIZES]={"2Nx2N(0)", "2NxN(1)", "Nx2N(2)", "NxN(3)", "2Nx(N/2+3N/2)(4)", "2Nx(3N/2+N/2)(5)", "(N/2+3N/2)x2N(6)", "(3N/2+N/2)x2N(7)"};
    5454#endif
    5555
     
    179179  PRINT_CONSTANT(O0043_BEST_EFFORT_DECODING,                                        settingNameWidth, settingValueWidth);
    180180
     181  PRINT_CONSTANT(ME_ENABLE_ROUNDING_OF_MVS,                                         settingNameWidth, settingValueWidth);
     182  PRINT_CONSTANT(U0040_MODIFIED_WEIGHTEDPREDICTION_WITH_BIPRED_AND_CLIPPING,        settingNameWidth, settingValueWidth);
     183
    181184  //------------------------------------------------
    182185
     
    418421
    419422
    420 Void printBlockToStream( std::ostream &ss, const Char *pLinePrefix, TComYuv &src, const UInt numSubBlocksAcross, const UInt numSubBlocksUp, const UInt defWidth )
     423Void printBlockToStream( std::ostream &ss, const TChar *pLinePrefix, TComYuv &src, const UInt numSubBlocksAcross, const UInt numSubBlocksUp, const UInt defWidth )
    421424{
    422425  const UInt numValidComp=src.getNumberValidComponents();
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/Debug.h

    r1313 r1360  
    4747#include <TLibCommon/CommonDef.h>
    4848#if DEBUG_STRING
    49 extern const Char *debug_reorder_data_inter_token[MAX_NUM_COMPONENT+1];
    50 extern const Char *partSizeToString[NUMBER_OF_PART_SIZES];
     49extern const TChar *debug_reorder_data_inter_token[MAX_NUM_COMPONENT+1];
     50extern const TChar *partSizeToString[NUMBER_OF_PART_SIZES];
    5151#endif
    5252
     
    149149UInt getZScanIndex(const UInt x, const UInt y);
    150150
    151 //template specialisation for Char types to get it to render as a number
     151//template specialisation for SChar/UChar types to get it to render as a number
    152152template <typename ValueType> inline Void writeValueToStream       (const ValueType &value, std::ostream &stream, const UInt outputWidth) { stream << std::setw(outputWidth) <<      value;  }
    153 template <>                   inline Void writeValueToStream<Char >(const Char      &value, std::ostream &stream, const UInt outputWidth) { stream << std::setw(outputWidth) <<  Int(value); }
     153template <>                   inline Void writeValueToStream<SChar>(const SChar     &value, std::ostream &stream, const UInt outputWidth) { stream << std::setw(outputWidth) <<  Int(value); }
    154154template <>                   inline Void writeValueToStream<UChar>(const UChar     &value, std::ostream &stream, const UInt outputWidth) { stream << std::setw(outputWidth) << UInt(value); }
    155155
     
    231231
    232232template <typename T>
    233 Void printBlockToStream( std::ostream &ss, const Char *pLinePrefix, const T * blkSrc, const UInt width, const UInt height, const UInt stride, const UInt subBlockWidth=0, const UInt subBlockHeight=0, const UInt defWidth=3 )
     233Void printBlockToStream( std::ostream &ss, const TChar *pLinePrefix, const T * blkSrc, const UInt width, const UInt height, const UInt stride, const UInt subBlockWidth=0, const UInt subBlockHeight=0, const UInt defWidth=3 )
    234234{
    235235  for (UInt y=0; y<height; y++)
     
    255255
    256256class TComYuv;
    257 Void printBlockToStream( std::ostream &ss, const Char *pLinePrefix, TComYuv &src, const UInt numSubBlocksAcross=1, const UInt numSubBlocksUp=1, const UInt defWidth=3 );
     257Void printBlockToStream( std::ostream &ss, const TChar *pLinePrefix, TComYuv &src, const UInt numSubBlocksAcross=1, const UInt numSubBlocksUp=1, const UInt defWidth=3 );
    258258
    259259// ---------------------------------------------------------------------------------------------- //
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/SEI.cpp

    r1356 r1360  
    118118
    119119// Static member
    120 const Char *SEI::getSEIMessageString(SEI::PayloadType payloadType)
     120const TChar *SEI::getSEIMessageString(SEI::PayloadType payloadType)
    121121{
    122122  switch (payloadType)
     
    151151    case SEI::SEGM_RECT_FRAME_PACKING:              return "Segmented rectangular frame packing arrangement";
    152152    case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS:    return "Temporal motion constrained tile sets";
    153     case SEI::CHROMA_SAMPLING_FILTER_HINT:          return "Chroma sampling filter hint";
     153    case SEI::CHROMA_RESAMPLING_FILTER_HINT:        return "Chroma sampling filter hint";
     154    case SEI::COLOUR_REMAPPING_INFO:                return "Colour remapping info";
     155
    154156#if NH_MV
    155     case SEI::COLOUR_REMAPPING_INFO:                     return "Colour remapping information";
    156157    case SEI::DEINTERLACED_FIELD_IDENTIFICATION:         return "Deinterlaced field identification";
    157158    case SEI::LAYERS_NOT_PRESENT:                        return "Layers not present";
     
    266267}
    267268
    268 Void SEI::setupFromCfgFile( const Char* cfgFile )
     269Void SEI::setupFromCfgFile( const TChar* cfgFile )
    269270{
    270271  assert( false );
     
    304305}
    305306
    306 Void SEI::xCheckCfgRange( Bool& wrongConfig, Int val, Int minVal, Int maxVal, const Char* seName )
     307Void SEI::xCheckCfgRange( Bool& wrongConfig, Int val, Int minVal, Int maxVal, const TChar* seName )
    307308{
    308309  if ( val < minVal || val > maxVal  )
     
    329330}
    330331
    331 Void SEI::xCheckCfg( Bool& wrongConfig, Bool cond, const Char* errStr )
     332Void SEI::xCheckCfg( Bool& wrongConfig, Bool cond, const TChar* errStr )
    332333{
    333334  if ( !cond  )
     
    341342
    342343#if NH_MV_LAYERS_NOT_PRESENT_SEI
    343 Void SEILayersNotPresent::setupFromCfgFile(const Char* cfgFile)
     344Void SEILayersNotPresent::setupFromCfgFile(const TChar* cfgFile)
    344345{
    345346  // Set default values
     
    401402
    402403
    403 Void SEIInterLayerConstrainedTileSets::setupFromCfgFile(const Char* cfgFile)
     404Void SEIInterLayerConstrainedTileSets::setupFromCfgFile(const TChar* cfgFile)
    404405{
    405406  // Set default values
     
    483484};
    484485
    485 Void SEIBspNesting::setupFromCfgFile(const Char* cfgFile)
     486Void SEIBspNesting::setupFromCfgFile(const TChar* cfgFile)
    486487{
    487488  // Set default values
     
    556557};
    557558
    558 Void SEIBspInitialArrivalTime::setupFromCfgFile(const Char* cfgFile)
     559Void SEIBspInitialArrivalTime::setupFromCfgFile(const TChar* cfgFile)
    559560{
    560561  // Set default values
     
    605606#endif
    606607
    607 Void SEISubBitstreamProperty::setupFromCfgFile(const Char* cfgFile)
     608Void SEISubBitstreamProperty::setupFromCfgFile(const TChar* cfgFile)
    608609{
    609610  // Set default values
     
    681682}
    682683
    683 Void SEIAlphaChannelInfo::setupFromCfgFile(const Char* cfgFile)
     684Void SEIAlphaChannelInfo::setupFromCfgFile(const TChar* cfgFile)
    684685{
    685686  // Set default values
     
    744745{ };
    745746
    746 Void SEIOverlayInfo::setupFromCfgFile(const Char* cfgFile)
     747Void SEIOverlayInfo::setupFromCfgFile(const TChar* cfgFile)
    747748{
    748749  // Set default values
     
    828829
    829830
    830 Void SEITemporalMvPredictionConstraints::setupFromCfgFile(const Char* cfgFile)
     831Void SEITemporalMvPredictionConstraints::setupFromCfgFile(const TChar* cfgFile)
    831832{
    832833  // Set default values
     
    870871
    871872#if NH_MV_SEI_TBD
    872 Void SEIFrameFieldInfo::setupFromCfgFile(const Char* cfgFile)
     873Void SEIFrameFieldInfo::setupFromCfgFile(const TChar* cfgFile)
    873874{
    874875  // Set default values
     
    922923#endif
    923924
    924 Void SEIThreeDimensionalReferenceDisplaysInfo::setupFromCfgFile(const Char* cfgFile)
     925Void SEIThreeDimensionalReferenceDisplaysInfo::setupFromCfgFile(const TChar* cfgFile)
    925926{
    926927  // Set default values
     
    10251026};
    10261027
    1027 Void SEIDepthRepresentationInfo::setupFromCfgFile(const Char* cfgFile)
     1028Void SEIDepthRepresentationInfo::setupFromCfgFile(const TChar* cfgFile)
    10281029{
    10291030  // Set default values
     
    11971198#endif
    11981199
    1199 Void SEIMultiviewSceneInfo::setupFromCfgFile(const Char* cfgFile)
     1200Void SEIMultiviewSceneInfo::setupFromCfgFile(const TChar* cfgFile)
    12001201{
    12011202  // Set default values
     
    12431244};
    12441245
    1245 Void SEIMultiviewAcquisitionInfo::setupFromCfgFile(const Char* cfgFile)
     1246Void SEIMultiviewAcquisitionInfo::setupFromCfgFile(const TChar* cfgFile)
    12461247{
    12471248  // Set default values
     
    14051406}
    14061407
    1407 Void SEIMultiviewViewPosition::setupFromCfgFile(const Char* cfgFile)
     1408Void SEIMultiviewViewPosition::setupFromCfgFile(const TChar* cfgFile)
    14081409{
    14091410  // Set default values
     
    14561457
    14571458#if NH_3D
    1458 Void SEIAlternativeDepthInfo::setupFromCfgFile(const Char* cfgFile)
     1459Void SEIAlternativeDepthInfo::setupFromCfgFile(const TChar* cfgFile)
    14591460{
    14601461  // Set default values
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/SEI.h

    r1356 r1360  
    9494    SEGM_RECT_FRAME_PACKING              = 138,
    9595    TEMP_MOTION_CONSTRAINED_TILE_SETS    = 139,
    96     CHROMA_SAMPLING_FILTER_HINT          = 140,
    97     KNEE_FUNCTION_INFO                   = 141
     96    CHROMA_RESAMPLING_FILTER_HINT        = 140,
     97    KNEE_FUNCTION_INFO                   = 141,
     98    COLOUR_REMAPPING_INFO                = 142,
    9899#if NH_MV_SEI
    99     ,COLOUR_REMAPPING_INFO                    = 142,
    100100    DEINTERLACED_FIELD_IDENTIFICATION         = 143,
    101101    LAYERS_NOT_PRESENT                        = 160,
     
    120120  };
    121121
     122#if NH_MV
    122123  SEI();
     124#else
     125  SEI() {}
     126#endif
     127
    123128
    124129  virtual ~SEI() {}
     130
     131  static const TChar *getSEIMessageString(SEI::PayloadType payloadType);
     132
     133  virtual PayloadType payloadType() const = 0;
     134
     135#if NH_MV_SEI
    125136  virtual SEI*       getCopy( ) const;
    126   static const Char *getSEIMessageString(SEI::PayloadType payloadType );
    127   virtual PayloadType payloadType() const = 0;
    128 
    129 #if NH_MV_SEI
    130137  static SEI*        getNewSEIMessage         ( SEI::PayloadType payloadType );
    131138  Bool               insertSei                ( Int curLayerId, Int curPoc, Int curTid, Int curNaluType ) const;
     
    133140
    134141  virtual Void       setupFromSlice           ( const TComSlice* slice );
    135   virtual Void       setupFromCfgFile         ( const Char* cfgFile );
     142  virtual Void       setupFromCfgFile         ( const TChar*  cfgFile );
    136143  virtual Bool       checkCfg                 ( const TComSlice* slice   );
    137144
    138145  Void               xPrintCfgErrorIntro();
    139   Void               xCheckCfgRange           ( Bool& wrongConfig, Int val, Int minVal, Int maxVal, const Char* seName );
    140   Void               xCheckCfg                ( Bool& wrongConfig, Bool cond, const Char* errStr );
     146  Void               xCheckCfgRange           ( Bool& wrongConfig, Int val, Int minVal, Int maxVal, const TChar* seName );
     147  Void               xCheckCfg                ( Bool& wrongConfig, Bool cond, const TChar* errStr );
    141148  Void               xAddGeneralOpts          ( po::Options &opts, IntAry1d defAppLayerIds, IntAry1d defAppPocs, IntAry1d defAppTids, IntAry1d defAppVclNaluTypes,
    142149                                                Int defSeiNaluId, Int defPositionInSeiNalu, Bool defModifyByEncoder );
     
    186193  virtual ~SEIDecodedPictureHash() {}
    187194
    188   enum Method
    189   {
    190     MD5,
    191     CRC,
    192     CHECKSUM,
    193     RESERVED,
    194   } method;
     195  HashType method;
    195196
    196197  TComPictureHash m_pictureHash;
     
    482483};
    483484
    484 class SEIChromaSamplingFilterHint : public SEI
    485 {
    486 public:
    487   PayloadType payloadType() const {return CHROMA_SAMPLING_FILTER_HINT;}
    488   SEIChromaSamplingFilterHint() {}
    489   virtual ~SEIChromaSamplingFilterHint() {
    490     if(m_verChromaFilterIdc == 1)
     485class SEIColourRemappingInfo : public SEI
     486{
     487public:
     488
     489  struct CRIlut
     490  {
     491    Int codedValue;
     492    Int targetValue;
     493    bool operator < (const CRIlut& a) const
    491494    {
    492       for(Int i = 0; i < m_numVerticalFilters; i ++)
     495      return codedValue < a.codedValue;
     496    }
     497  };
     498
     499  PayloadType payloadType() const { return COLOUR_REMAPPING_INFO; }
     500  SEIColourRemappingInfo() {}
     501  ~SEIColourRemappingInfo() {}
     502
     503  Void copyFrom( const SEIColourRemappingInfo &seiCriInput)
    493504      {
    494         free(m_verFilterCoeff[i]);
    495       }
    496       free(m_verFilterCoeff);
    497       free(m_verTapLengthMinus1);
    498     }
    499     if(m_horChromaFilterIdc == 1)
    500     {
    501       for(Int i = 0; i < m_numHorizontalFilters; i ++)
    502       {
    503         free(m_horFilterCoeff[i]);
    504       }
    505       free(m_horFilterCoeff);
    506       free(m_horTapLengthMinus1);
    507     }
     505    (*this) = seiCriInput;
    508506  }
     507
     508  UInt                m_colourRemapId;
     509  Bool                m_colourRemapCancelFlag;
     510  Bool                m_colourRemapPersistenceFlag;
     511  Bool                m_colourRemapVideoSignalInfoPresentFlag;
     512  Bool                m_colourRemapFullRangeFlag;
     513  Int                 m_colourRemapPrimaries;
     514  Int                 m_colourRemapTransferFunction;
     515  Int                 m_colourRemapMatrixCoefficients;
     516  Int                 m_colourRemapInputBitDepth;
     517  Int                 m_colourRemapBitDepth;
     518  Int                 m_preLutNumValMinus1[3];
     519  std::vector<CRIlut> m_preLut[3];
     520  Bool                m_colourRemapMatrixPresentFlag;
     521  Int                 m_log2MatrixDenom;
     522  Int                 m_colourRemapCoeffs[3][3];
     523  Int                 m_postLutNumValMinus1[3];
     524  std::vector<CRIlut> m_postLut[3];
     525};
     526
     527class SEIChromaResamplingFilterHint : public SEI
     528{
     529public:
     530  PayloadType payloadType() const {return CHROMA_RESAMPLING_FILTER_HINT;}
     531  SEIChromaResamplingFilterHint() {}
     532  virtual ~SEIChromaResamplingFilterHint() {}
    509533
    510534  Int   m_verChromaFilterIdc;
    511535  Int   m_horChromaFilterIdc;
    512   Bool  m_verFilteringProcessFlag;
     536  Bool                           m_verFilteringFieldProcessingFlag;
    513537  Int   m_targetFormatIdc;
    514538  Bool  m_perfectReconstructionFlag;
    515   Int   m_numVerticalFilters;
    516   Int*  m_verTapLengthMinus1;
    517   Int** m_verFilterCoeff;
    518   Int   m_numHorizontalFilters;
    519   Int*  m_horTapLengthMinus1;
    520   Int** m_horFilterCoeff;
     539  std::vector<std::vector<Int> > m_verFilterCoeff;
     540  std::vector<std::vector<Int> > m_horFilterCoeff;
    521541};
    522542
     
    669689  SEI* getCopy( ) const { return new SEILayersNotPresent(*this); };
    670690
    671   Void setupFromCfgFile( const Char*      cfgFile );
     691  Void setupFromCfgFile( const TChar*     cfgFile );
    672692  Bool checkCfg        ( const TComSlice* slice   );
    673693
     
    691711  SEI* getCopy( ) const { return new SEIInterLayerConstrainedTileSets(*this); };
    692712
    693   Void setupFromCfgFile( const Char*      cfgFile );
     713  Void setupFromCfgFile( const TChar*     cfgFile );
    694714  Bool checkCfg        ( const TComSlice* slice   );
    695715
     
    733753  SEI* getCopy( ) const { return new SEIBspNesting(*this); };
    734754
    735   Void setupFromCfgFile( const Char*      cfgFile );
     755  Void setupFromCfgFile( const TChar*      cfgFile );
    736756  Void setupFromSlice  ( const TComSlice* slice   );
    737757  Bool checkCfg        ( const TComSlice* slice   );
     
    752772  SEI* getCopy( ) const { return new SEIBspInitialArrivalTime(*this); };
    753773
    754   Void setupFromCfgFile( const Char*      cfgFile );
     774  Void setupFromCfgFile( const TChar*      cfgFile );
    755775  Void setupFromSlice  ( const TComSlice* slice   );
    756776  Bool checkCfg        ( const TComSlice* slice   );
     
    769789  SEI* getCopy( ) const { return new SEISubBitstreamProperty(*this); };
    770790
    771   Void setupFromCfgFile( const Char*      cfgFile );
     791  Void setupFromCfgFile( const TChar*     cfgFile );
    772792  Bool checkCfg        ( const TComSlice* slice   );
    773793  Void resizeArrays    ( );
     
    790810  SEI* getCopy( ) const { return new SEIAlphaChannelInfo(*this); };
    791811
    792   Void setupFromCfgFile( const Char*      cfgFile );
     812  Void setupFromCfgFile( const TChar*     cfgFile );
    793813  Bool checkCfg        ( const TComSlice* slice   );
    794814
     
    811831  SEI* getCopy( ) const { return new SEIOverlayInfo(*this); };
    812832
    813   Void setupFromCfgFile( const Char*      cfgFile );
     833  Void setupFromCfgFile( const TChar*     cfgFile );
    814834  Bool checkCfg        ( const TComSlice* slice   );
    815835
     
    848868  SEI* getCopy( ) const { return new SEITemporalMvPredictionConstraints(*this); };
    849869
    850   Void setupFromCfgFile( const Char*      cfgFile );
     870  Void setupFromCfgFile( const TChar*     cfgFile );
    851871  Bool checkCfg        ( const TComSlice* slice   );
    852872
     
    864884  SEI* getCopy( ) const { return new SEIFrameFieldInfo(*this); };
    865885
    866   Void setupFromCfgFile( const Char*      cfgFile );
     886  Void setupFromCfgFile( const TChar*     cfgFile );
    867887  Void setupFromSlice  ( const TComSlice* slice   );
    868888  Bool checkCfg        ( const TComSlice* slice   );
     
    882902  SEI* getCopy( ) const { return new SEIThreeDimensionalReferenceDisplaysInfo(*this); };
    883903
    884   Void setupFromCfgFile( const Char*      cfgFile );
     904  Void setupFromCfgFile( const TChar*     cfgFile );
    885905  Bool checkCfg        ( const TComSlice* slice   );
    886906
     
    936956        SEI* getCopy( ) const { return new SEIDepthRepresentationInfo(*this); };
    937957
    938         Void setupFromCfgFile( const Char*      cfgFile );
     958        Void setupFromCfgFile( const TChar*     cfgFile );
    939959        Void setupFromSlice  ( const TComSlice* slice   );
    940960        Bool checkCfg        ( const TComSlice* slice   );
     
    10031023  SEI* getCopy( ) const { return new SEIMultiviewSceneInfo(*this); };
    10041024
    1005   Void setupFromCfgFile( const Char*      cfgFile );
     1025  Void setupFromCfgFile( const TChar*     cfgFile );
    10061026  Bool checkCfg        ( const TComSlice* slice   );
    10071027
     
    10191039  SEI* getCopy( ) const { return new SEIMultiviewAcquisitionInfo(*this); };
    10201040
    1021   Void setupFromCfgFile( const Char*      cfgFile );
     1041  Void setupFromCfgFile( const TChar*     cfgFile );
    10221042  Bool checkCfg        ( const TComSlice* slice   );
    10231043
     
    11311151  SEI* getCopy( ) const { return new SEIMultiviewViewPosition(*this); };
    11321152
    1133   Void setupFromCfgFile( const Char*      cfgFile );
     1153  Void setupFromCfgFile( const TChar*     cfgFile );
    11341154  Void setupFromSlice  ( const TComSlice* slice   );
    11351155  Bool checkCfg        ( const TComSlice* slice   );
     
    11481168  SEI* getCopy( ) const { return new SEIAlternativeDepthInfo(*this); };
    11491169
    1150   Void setupFromCfgFile( const Char*      cfgFile );
     1170  Void setupFromCfgFile( const TChar*     cfgFile );
    11511171  Bool checkCfg        ( const TComSlice* slice   );
    11521172
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComBitStream.cpp

    r1321 r1360  
    9393}
    9494
    95 Char* TComOutputBitstream::getByteStream() const
    96 {
    97   return (Char*) &m_fifo.front();
     95UChar* TComOutputBitstream::getByteStream() const
     96{
     97  return (UChar*) &m_fifo.front();
    9898}
    9999
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComBitStream.h

    r1313 r1360  
    115115   * bytestream are stored in ascending addresses.
    116116   */
    117   Char* getByteStream() const;
     117  UChar* getByteStream() const;
    118118
    119119  /**
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComCodingStatistics.h

    r1321 r1360  
    120120};
    121121
    122 static inline const Char* getName(TComCodingStatisticsType name)
     122static inline const TChar* getName(TComCodingStatisticsType name)
    123123{
    124   static const Char *statNames[]=
     124  static const TChar *statNames[]=
    125125  {
    126126    "NAL_UNIT_TOTAL_BODY", // This is a special case and is not included in the total sums.
     
    189189#endif
    190190  };
    191   assert(STATS__NUM_STATS == sizeof(statNames)/sizeof(Char *) && name < STATS__NUM_STATS);
     191  assert(STATS__NUM_STATS == sizeof(statNames)/sizeof(TChar *) && name < STATS__NUM_STATS);
    192192  return statNames[name];
    193193}
     
    229229  }
    230230
    231   static const Char *GetSubClassString(const UInt subClass)
     231  static const TChar *GetSubClassString(const UInt subClass)
    232232  {
    233233    assert (subClass<CODING_STATS_NUM_SUBCLASSES);
    234     static const Char *strings[1+MAX_NUM_COMPONENT+MAX_NUM_CHANNEL_TYPE]={"-", "Y", "Cb", "Cr", "Luma", "Chroma"};
     234    static const TChar *strings[1+MAX_NUM_COMPONENT+MAX_NUM_CHANNEL_TYPE]={"-", "Y", "Cb", "Cr", "Luma", "Chroma"};
    235235    return strings[subClass/CODING_STATS_NUM_WIDTHS];
    236236  }
     
    289289    { }
    290290
    291     static Void OutputLine(const Char *pName, const Char sep, UInt width, const Char *pSubClassStr, const SStat &sCABAC, const SStat &sEP)
     291    static Void OutputLine(const TChar *pName, const TChar sep, UInt width, const TChar *pSubClassStr, const SStat &sCABAC, const SStat &sEP)
    292292    {
    293293      if (width==0)
     
    302302      }
    303303    }
    304     static Void OutputLine(const Char *pName, const Char sep, const Char *pWidthString, const Char *pSubClassStr, const SStat &sCABAC, const SStat &sEP)
     304    static Void OutputLine(const TChar *pName, const TChar sep, const TChar *pWidthString, const TChar *pSubClassStr, const SStat &sCABAC, const SStat &sEP)
    305305    {
    306306      printf("%c%-45s%c  %6s %6s %12lld %12lld %12lld %12lld %12lld %12lld %12lld (%12lld)%c\n",
     
    308308              sCABAC.count, sCABAC.sum, sCABAC.bits, sEP.count, sEP.sum, sEP.bits, sCABAC.bits+sEP.bits, (sCABAC.bits+sEP.bits)/8, sep=='~'?']':' ');
    309309    }
    310     static Void OutputLine(const Char *pName, const Char sep, const Char *pWidthString, const Char *pSubClassStr,  const SStat &sEP)
     310    static Void OutputLine(const TChar *pName, const TChar sep, const TChar *pWidthString, const TChar *pSubClassStr,  const SStat &sEP)
    311311    {
    312312      printf("%c%-45s%c  %6s %6s %12s %12s %12s %12lld %12lld %12lld %12lld (%12lld)%c\n",
     
    315315    }
    316316
    317     static Void OutputDashedLine(const Char *pText)
     317    static Void OutputDashedLine(const TChar *pText)
    318318    {
    319319      printf("--%s",pText);
     
    360360        SStat cabacSubTotal, epSubTotal;
    361361        Bool bHadClassifiedEntry=false;
    362         const Char *pName=getName(TComCodingStatisticsType(i));
     362        const TChar *pName=getName(TComCodingStatisticsType(i));
    363363
    364364        for(UInt c=0; c<CODING_STATS_NUM_SUBCLASSES; c++)
     
    488488    static SStat &GetStatisticEP(const std::string &str) { return GetSingletonInstance().data.mappings_ep[str]; }
    489489
    490     static SStat &GetStatisticEP(const Char *pKey) {return GetStatisticEP(std::string(pKey)); }
     490    static SStat &GetStatisticEP(const TChar *pKey) {return GetStatisticEP(std::string(pKey)); }
    491491
    492492    static Void IncrementStatisticEP(const TComCodingStatisticsClassType &stat, const Int numBits, const Int value)
     
    506506    }
    507507
    508     static Void IncrementStatisticEP(const Char *pKey, const Int numBits, const Int value)
     508    static Void IncrementStatisticEP(const TChar *pKey, const Int numBits, const Int value)
    509509    {
    510510      SStat &s=GetStatisticEP(pKey);
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComDataCU.cpp

    r1356 r1360  
    160160  if ( !bDecSubCu )
    161161  {
    162     m_phQP               = (Char*     )xMalloc(Char,     uiNumPartition);
     162    m_phQP               = (SChar*    )xMalloc(SChar,    uiNumPartition);
    163163    m_puhDepth           = (UChar*    )xMalloc(UChar,    uiNumPartition);
    164164    m_puhWidth           = (UChar*    )xMalloc(UChar,    uiNumPartition);
     
    171171    m_ucDISType          = (UChar*)xMalloc(UChar, uiNumPartition);
    172172#endif
    173     m_pePartSize         = new Char[ uiNumPartition ];
     173    m_pePartSize         = new SChar[ uiNumPartition ];
    174174    memset( m_pePartSize, NUMBER_OF_PART_SIZES,uiNumPartition * sizeof( *m_pePartSize ) );
    175     m_pePredMode         = new Char[ uiNumPartition ];
     175    m_pePredMode         = new SChar[ uiNumPartition ];
    176176    m_CUTransquantBypass = new Bool[ uiNumPartition ];
    177177
     
    179179    m_puhMergeIndex      = (UChar* )xMalloc(UChar,  uiNumPartition);
    180180#if NH_3D_VSP
    181     m_piVSPFlag          = (Char*  )xMalloc(Char,  uiNumPartition);
     181    m_piVSPFlag          = (SChar* )xMalloc(SChar, uiNumPartition);
    182182#endif
    183183#if NH_3D_SPIVMP
     
    196196    {
    197197      const RefPicList rpl=RefPicList(i);
    198       m_apiMVPIdx[rpl]       = new Char[ uiNumPartition ];
    199       m_apiMVPNum[rpl]       = new Char[ uiNumPartition ];
    200       memset( m_apiMVPIdx[rpl], -1,uiNumPartition * sizeof( Char ) );
     198      m_apiMVPIdx[rpl]       = new SChar[ uiNumPartition ];
     199      m_apiMVPNum[rpl]       = new SChar[ uiNumPartition ];
     200      memset( m_apiMVPIdx[rpl], -1,uiNumPartition * sizeof( SChar ) );
    201201    }
    202202
     
    212212      const UInt totalSize   = (uiWidth * uiHeight) >> chromaShift;
    213213
    214       m_crossComponentPredictionAlpha[compID] = (Char*  )xMalloc(Char,   uiNumPartition);
     214      m_crossComponentPredictionAlpha[compID] = (SChar* )xMalloc(SChar,  uiNumPartition);
    215215      m_puhTransformSkip[compID]              = (UChar* )xMalloc(UChar,  uiNumPartition);
    216216      m_explicitRdpcmMode[compID]             = (UChar* )xMalloc(UChar,  uiNumPartition);
     
    524524}
    525525
    526 Bool TComDataCU::isLastSubCUOfCtu(const UInt absPartIdx)
     526Bool TComDataCU::isLastSubCUOfCtu(const UInt absPartIdx) const
    527527{
    528528  const TComSPS &sps=*(getSlice()->getSPS());
     
    844844  Int iSizeInUchar = sizeof( UChar  ) * m_uiNumPartition;
    845845  Int iSizeInBool  = sizeof( Bool   ) * m_uiNumPartition;
    846   Int sizeInChar = sizeof( Char  ) * m_uiNumPartition;
     846  Int sizeInChar = sizeof( SChar  ) * m_uiNumPartition;
    847847
    848848  memset( m_phQP,              qp,  sizeInChar );
     
    850850  memset( m_puhMergeIndex,      0, iSizeInUchar );
    851851#if NH_3D_VSP
    852   memset( m_piVSPFlag,          0, sizeof( Char ) * m_uiNumPartition );
     852  memset( m_piVSPFlag,          0, sizeof( SChar ) * m_uiNumPartition );
    853853#endif
    854854#if NH_3D_SPIVMP
     
    12191219  Int iSizeInBool   = sizeof( Bool  ) * uiNumPartition;
    12201220
    1221   Int sizeInChar  = sizeof( Char ) * uiNumPartition;
     1221  Int sizeInChar  = sizeof( SChar ) * uiNumPartition;
    12221222  memcpy( m_skipFlag   + uiOffset, pcCU->getSkipFlag(),       sizeof( *m_skipFlag )   * uiNumPartition );
    12231223#if NH_3D_DIS
     
    12331233  memcpy( m_puhMergeIndex       + uiOffset, pcCU->getMergeIndex(),        iSizeInUchar );
    12341234#if NH_3D_VSP
    1235   memcpy( m_piVSPFlag           + uiOffset, pcCU->getVSPFlag(),           sizeof( Char ) * uiNumPartition );
     1235  memcpy( m_piVSPFlag           + uiOffset, pcCU->getVSPFlag(),           sizeof( SChar ) * uiNumPartition );
    12361236  memcpy( m_pDvInfo             + uiOffset, pcCU->getDvInfo(),            sizeof( *m_pDvInfo ) * uiNumPartition );
    12371237#endif
     
    13351335  Int iSizeInUchar  = sizeof( UChar ) * m_uiNumPartition;
    13361336  Int iSizeInBool   = sizeof( Bool  ) * m_uiNumPartition;
    1337   Int sizeInChar  = sizeof( Char ) * m_uiNumPartition;
     1337  Int sizeInChar  = sizeof( SChar ) * m_uiNumPartition;
    13381338
    13391339  memcpy( pCtu->getSkipFlag() + m_absZIdxInCtu, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition );
     
    13551355  memcpy( pCtu->getMergeIndex()        + m_absZIdxInCtu, m_puhMergeIndex,       iSizeInUchar );
    13561356#if NH_3D_VSP
    1357   memcpy( pCtu->getVSPFlag()           + m_absZIdxInCtu, m_piVSPFlag,           sizeof( Char ) * m_uiNumPartition );
     1357  memcpy( pCtu->getVSPFlag()           + m_absZIdxInCtu, m_piVSPFlag,           sizeof( SChar ) * m_uiNumPartition );
    13581358#endif
    13591359#if NH_3D_DBBP
     
    14471447// --------------------------------------------------------------------------------------------------------------------
    14481448
    1449 TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx,
     1449const TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx,
    14501450                                   UInt uiCurrPartUnitIdx,
    14511451                                   Bool bEnforceSliceRestriction,
    1452                                    Bool bEnforceTileRestriction )
     1452                                         Bool bEnforceTileRestriction ) const
    14531453{
    14541454  UInt uiAbsPartIdx       = g_auiZscanToRaster[uiCurrPartUnitIdx];
     
    14791479
    14801480
    1481 TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx,
     1481const TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx,
    14821482                                    UInt uiCurrPartUnitIdx,
    14831483                                    Bool bEnforceSliceRestriction,
    14841484                                    Bool planarAtCtuBoundary,
    1485                                     Bool bEnforceTileRestriction )
     1485                                          Bool bEnforceTileRestriction ) const
    14861486{
    14871487  UInt uiAbsPartIdx       = g_auiZscanToRaster[uiCurrPartUnitIdx];
     
    15171517}
    15181518
    1519 TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction )
     1519const TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) const
    15201520{
    15211521  UInt uiAbsPartIdx       = g_auiZscanToRaster[uiCurrPartUnitIdx];
     
    15641564}
    15651565
    1566 TComDataCU* TComDataCU::getPUBelowLeft(UInt& uiBLPartUnitIdx,  UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction)
     1566const TComDataCU* TComDataCU::getPUBelowLeft(UInt& uiBLPartUnitIdx,  UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) const
    15671567{
    15681568  UInt uiAbsPartIdxLB     = g_auiZscanToRaster[uiCurrPartUnitIdx];
     
    16081608}
    16091609
    1610 TComDataCU* TComDataCU::getPUAboveRight(UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction)
     1610const TComDataCU* TComDataCU::getPUAboveRight(UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) const
    16111611{
    16121612  UInt uiAbsPartIdxRT     = g_auiZscanToRaster[uiCurrPartUnitIdx];
     
    16681668*\returns TComDataCU*   point of TComDataCU of left QpMinCu
    16691669*/
    1670 TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInCtu )
     1670const TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInCtu ) const
    16711671{
    16721672  const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth();
     
    16951695*\returns TComDataCU*   point of TComDataCU of above QpMinCu
    16961696*/
    1697 TComDataCU* TComDataCU::getQpMinCuAbove( UInt& uiAPartUnitIdx, UInt uiCurrAbsIdxInCtu )
     1697const TComDataCU* TComDataCU::getQpMinCuAbove( UInt& uiAPartUnitIdx, UInt uiCurrAbsIdxInCtu ) const
    16981698{
    16991699  const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth();
     
    17211721/** Get reference QP from left QpMinCu or latest coded QP
    17221722*\param   uiCurrAbsIdxInCtu
    1723 *\returns Char   reference QP value
     1723*\returns SChar   reference QP value
    17241724*/
    1725 Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInCtu )
     1725SChar TComDataCU::getRefQP( UInt uiCurrAbsIdxInCtu ) const
    17261726{
    17271727  UInt lPartIdx = MAX_UINT;
    17281728  UInt aPartIdx = MAX_UINT;
    1729   TComDataCU* cULeft  = getQpMinCuLeft ( lPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu );
    1730   TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu );
     1729  const TComDataCU* cULeft  = getQpMinCuLeft ( lPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu );
     1730  const TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu );
    17311731  return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + 1) >> 1);
    17321732}
    17331733
    1734 Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx )
     1734Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) const
    17351735{
    17361736  Int iLastValidPartIdx = iAbsPartIdx-1;
     
    17441744}
    17451745
    1746 Char TComDataCU::getLastCodedQP( UInt uiAbsPartIdx )
     1746SChar TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) const
    17471747{
    17481748  UInt uiQUPartIdxMask = ~((1<<((getSlice()->getSPS()->getMaxTotalCUDepth() - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1);
     
    17841784 * \returns true if the CU is coded in lossless coding mode; false if otherwise
    17851785 */
    1786 Bool TComDataCU::isLosslessCoded(UInt absPartIdx)
     1786Bool TComDataCU::isLosslessCoded(UInt absPartIdx) const
    17871787{
    17881788  return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx));
     
    17961796*\param   [out] uiModeList pointer to chroma intra modes array
    17971797*/
    1798 Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt uiModeList[NUM_CHROMA_MODE] )
     1798Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt uiModeList[NUM_CHROMA_MODE] ) const
    17991799{
    18001800  uiModeList[0] = PLANAR_IDX;
     
    18241824*\returns Number of MPM
    18251825*/
    1826 Void TComDataCU::getIntraDirPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode  )
    1827 {
    1828   TComDataCU* pcCULeft, *pcCUAbove;
     1826Void TComDataCU::getIntraDirPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode ) const
     1827{
    18291828  UInt        LeftPartIdx  = MAX_UINT;
    18301829  UInt        AbovePartIdx = MAX_UINT;
     
    18361835  const ChromaFormat chForm = getPic()->getChromaFormat();
    18371836  // Get intra direction of left PU
    1838   pcCULeft = getPULeft( LeftPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
     1837  const TComDataCU *pcCULeft = getPULeft( LeftPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
    18391838
    18401839  if (isChroma(compID))
     
    18481847
    18491848  // Get intra direction of above PU
    1850   pcCUAbove = getPUAbove( AbovePartIdx, m_absZIdxInCtu + uiAbsPartIdx, true, true );
     1849  const TComDataCU *pcCUAbove = getPUAbove( AbovePartIdx, m_absZIdxInCtu + uiAbsPartIdx, true, true );
    18511850
    18521851  if (isChroma(compID))
     
    19171916}
    19181917
    1919 UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth )
    1920 {
    1921   TComDataCU* pcTempCU;
     1918UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) const
     1919{
     1920  const TComDataCU* pcTempCU;
    19221921  UInt        uiTempPartIdx;
    19231922  UInt        uiCtx;
     
    19331932}
    19341933
    1935 UInt TComDataCU::getCtxQtCbf( TComTU &rTu, const ChannelType chType )
     1934UInt TComDataCU::getCtxQtCbf( TComTU &rTu, const ChannelType chType ) const
    19361935{
    19371936  const UInt transformDepth = rTu.GetTransformDepthRel();
     
    19481947}
    19491948
    1950 UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx )
     1949UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) const
    19511950{
    19521951  UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2;
     
    19751974}
    19761975
    1977 UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx )
    1978 {
    1979   TComDataCU* pcTempCU;
     1976UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) const
     1977{
     1978  const TComDataCU* pcTempCU;
    19801979  UInt        uiTempPartIdx;
    19811980  UInt        uiCtx = 0;
     
    19941993UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx )
    19951994{
    1996   TComDataCU* pcTempCU;
     1995  const TComDataCU* pcTempCU;
    19971996  UInt        uiTempPartIdx;
    19981997  UInt        uiCtx = 0;
    1999  
     1998
    20001999  pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
    20012000  uiCtx    = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0;
    2002     return uiCtx;
     2001  return uiCtx;
    20032002}
    20042003#endif
     
    20862085
    20872086
    2088 UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx )
     2087UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) const
    20892088{
    20902089  return getDepth( uiAbsPartIdx );
     
    20922091
    20932092
    2094 UChar TComDataCU::getQtRootCbf( UInt uiIdx )
     2093UChar TComDataCU::getQtRootCbf( UInt uiIdx ) const
    20952094{
    20962095  const UInt numberValidComponents = getPic()->getNumberValidComponents();
     
    21482147}
    21492148
    2150 Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth)
     2149Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) const
    21512150{
    21522151  UInt uiPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1);
     
    23762375
    23772376#if NH_3D_VSP
    2378 Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    2379 {
    2380   setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
     2377Void TComDataCU::setVSPFlagSubParts( SChar iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     2378{
     2379  setSubPart<SChar>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
    23812380}
    23822381template<typename T>
     
    25232522Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    25242523{
    2525   setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx );
     2524  setSubPart<SChar>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx );
    25262525}
    25272526
    25282527Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    25292528{
    2530   setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx );
     2529  setSubPart<SChar>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx );
    25312530}
    25322531
     
    25612560}
    25622561
    2563 Void TComDataCU::setCrossComponentPredictionAlphaPartRange( Char alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes )
    2564 {
    2565   memset((m_crossComponentPredictionAlpha[compID] + uiAbsPartIdx), alphaValue, (sizeof(Char) * uiCoveredPartIdxes));
     2562Void TComDataCU::setCrossComponentPredictionAlphaPartRange( SChar alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes )
     2563{
     2564  memset((m_crossComponentPredictionAlpha[compID] + uiAbsPartIdx), alphaValue, (sizeof(SChar) * uiCoveredPartIdxes));
    25662565}
    25672566
     
    25792578}
    25802579
    2581 UChar TComDataCU::getNumPartitions(const UInt uiAbsPartIdx)
     2580UChar TComDataCU::getNumPartitions(const UInt uiAbsPartIdx) const
    25822581{
    25832582  UChar iNumPart = 0;
     
    26012600// This is for use by a leaf/sub CU object only, with no additional AbsPartIdx
    26022601#if NH_3D_IC || NH_3D_VSP
    2603 Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU)
     2602Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU) const
    26042603{
    26052604  UInt uiNumPartition  = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition;
     
    26452644#else
    26462645
    2647 Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight )
     2646Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight )  const
    26482647{
    26492648  switch ( m_pePartSize[0] )
     
    26862685#endif
    26872686
    2688 
    2689 Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField )
     2687// static member function
     2688Void TComDataCU::getMvField ( const TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField )
    26902689{
    26912690  if ( pcCU == NULL )  // OUT OF BOUNDARY
     
    26962695  }
    26972696
    2698   TComCUMvField*  pcCUMvField = pcCU->getCUMvField( eRefPicList );
     2697  const TComCUMvField*  pcCUMvField = pcCU->getCUMvField( eRefPicList );
    26992698  rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) );
    27002699}
    27012700
    2702 Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT )
     2701Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const
    27032702{
    27042703  ruiPartIdxLT = m_absZIdxInCtu + uiAbsPartIdx;
     
    27492748}
    27502749
    2751 Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB )
     2750Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) const
    27522751{
    27532752  UInt uiPUHeight = 0;
     
    27962795}
    27972796
    2798 Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT )
     2797Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const
    27992798{
    28002799  ruiPartIdxLT = m_absZIdxInCtu;
     
    28362835}
    28372836
    2838 Void TComDataCU::deriveLeftBottomIdx( UInt  uiPartIdx,      UInt&      ruiPartIdxLB )
     2837Void TComDataCU::deriveLeftBottomIdx( UInt  uiPartIdx,      UInt&      ruiPartIdxLB ) const
    28392838{
    28402839  ruiPartIdxLB      = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth()];
     
    28762875 * \param [out] ruiPartIdxRB  partition index of neighbouring bottom right block
    28772876 */
    2878 Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt &ruiPartIdxRB )
     2877Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt &ruiPartIdxRB ) const
    28792878{
    28802879  ruiPartIdxRB      = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth() +  m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1];
     
    29122911}
    29132912
    2914 Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx )
     2913Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, const TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) const
    29152914{
    29162915  if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) )
     
    33063305  //left
    33073306  UInt uiLeftPartIdx = 0;
    3308   TComDataCU* pcCULeft = 0;
     3307  const TComDataCU* pcCULeft = 0;
    33093308  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); 
    33103309
     
    37833782
    37843783//! Construct a list of merging candidates
     3784#if NH_3D
    37853785Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
     3786#else
     3787Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) const
     3788#endif
    37863789{
    37873790  UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx;
     
    38113814  //left
    38123815  UInt uiLeftPartIdx = 0;
    3813   TComDataCU* pcCULeft = 0;
    3814   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
     3816  const TComDataCU *pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
    38153817
    38163818  Bool isAvailableA1 = pcCULeft &&
     
    38283830    puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
    38293831    // get Mv from Left
    3830     pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     3832    TComDataCU::getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    38313833    if ( getSlice()->isInterB() )
    38323834    {
    3833       pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     3835      TComDataCU::getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    38343836    }
    38353837    if ( mrgCandIdx == iCount )
     
    38473849  // above
    38483850  UInt uiAbovePartIdx = 0;
    3849   TComDataCU* pcCUAbove = 0;
    3850   pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
     3851  const TComDataCU *pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
    38513852
    38523853  Bool isAvailableB1 = pcCUAbove &&
     
    38643865    puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
    38653866    // get Mv from Left
    3866     pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     3867    TComDataCU::getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    38673868    if ( getSlice()->isInterB() )
    38683869    {
    3869       pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     3870      TComDataCU::getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    38703871    }
    38713872    if ( mrgCandIdx == iCount )
     
    38833884  // above right
    38843885  UInt uiAboveRightPartIdx = 0;
    3885   TComDataCU* pcCUAboveRight = 0;
    3886   pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
     3886  const TComDataCU *pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
    38873887
    38883888  Bool isAvailableB0 = pcCUAboveRight &&
     
    38993899    puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
    39003900    // get Mv from Left
    3901     pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     3901    TComDataCU::getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    39023902    if ( getSlice()->isInterB() )
    39033903    {
    3904       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     3904      TComDataCU::getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    39053905    }
    39063906    if ( mrgCandIdx == iCount )
     
    39183918  //left bottom
    39193919  UInt uiLeftBottomPartIdx = 0;
    3920   TComDataCU* pcCULeftBottom = 0;
    3921   pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
     3920  const TComDataCU *pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
    39223921
    39233922  Bool isAvailableA0 = pcCULeftBottom &&
     
    39343933    puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
    39353934    // get Mv from Left
    3936     pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     3935    TComDataCU::getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    39373936    if ( getSlice()->isInterB() )
    39383937    {
    3939       pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     3938      TComDataCU::getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    39403939    }
    39413940    if ( mrgCandIdx == iCount )
     
    39553954  {
    39563955    UInt uiAboveLeftPartIdx = 0;
    3957     TComDataCU* pcCUAboveLeft = 0;
    3958     pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
     3956    const TComDataCU *pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
    39593957
    39603958    Bool isAvailableB2 = pcCUAboveLeft &&
     
    39723970      puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
    39733971      // get Mv from Left
    3974       pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     3972      TComDataCU::getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    39753973      if ( getSlice()->isInterB() )
    39763974      {
    3977         pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     3975        TComDataCU::getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    39783976      }
    39793977      if ( mrgCandIdx == iCount )
     
    41664164 * \param xP, yP   location of the upper-left corner pixel of the current PU
    41674165 */
    4168 Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP)
     4166Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) const
    41694167{
    41704168
     
    41864184 * \param nPSW, nPSH    size of the current PU
    41874185 */
    4188 Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH)
     4186Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) const
    41894187{
    41904188  UInt col = m_uiCUPelX;
     
    42474245}
    42484246
    4249 /** Constructs a list of candidates for AMVP
     4247/** Constructs a list of candidates for AMVP (See specification, section "Derivation process for motion vector predictor candidates")
    42504248 * \param uiPartIdx
    42514249 * \param uiPartAddr
     
    42544252 * \param pInfo
    42554253 */
    4256 Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo )
    4257 {
    4258   TComMv cMvPred;
    4259   Bool bAddedSmvp = false;
    4260 
     4254Void TComDataCU::fillMvpCand ( const UInt partIdx, const UInt partAddr, const RefPicList eRefPicList, const Int refIdx, AMVPInfo* pInfo ) const
     4255{
    42614256  pInfo->iN = 0;
    4262   if (iRefIdx < 0)
     4257  if (refIdx < 0)
    42634258  {
    42644259    return;
     
    42664261
    42674262  //-- Get Spatial MV
    4268   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    4269   const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
    4270   const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
    4271   Bool bAdded = false;
    4272 
    4273   deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT );
    4274   deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB );
    4275 
    4276   TComDataCU* tmpCU = NULL;
    4277   UInt idx;
    4278   tmpCU = getPUBelowLeft(idx, uiPartIdxLB);
    4279   bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx));
    4280 
    4281   if (!bAddedSmvp)
    4282   {
    4283     tmpCU = getPULeft(idx, uiPartIdxLB);
    4284     bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx));
     4263  UInt partIdxLT, partIdxRT, partIdxLB;
     4264  deriveLeftRightTopIdx( partIdx, partIdxLT, partIdxRT );
     4265  deriveLeftBottomIdx( partIdx, partIdxLB );
     4266
     4267  Bool isScaledFlagLX = false; /// variable name from specification; true when the PUs below left or left are available (availableA0 || availableA1).
     4268  {
     4269    UInt idx;
     4270    const TComDataCU* tmpCU = getPUBelowLeft(idx, partIdxLB);
     4271    isScaledFlagLX = (tmpCU != NULL) && (tmpCU->isInter(idx));
     4272    if (!isScaledFlagLX)
     4273    {
     4274      tmpCU = getPULeft(idx, partIdxLB);
     4275      isScaledFlagLX = (tmpCU != NULL) && (tmpCU->isInter(idx));
     4276    }
    42854277  }
    42864278
    42874279  // Left predictor search
    4288   bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT);
    4289   if (!bAdded)
    4290   {
    4291     bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT );
    4292   }
    4293 
    4294   if(!bAdded)
    4295   {
    4296     bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT);
     4280  if (isScaledFlagLX)
     4281  {
     4282    Bool bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLB, MD_BELOW_LEFT);
    42974283    if (!bAdded)
    42984284    {
    4299       xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT );
     4285      bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLB, MD_LEFT );
     4286      if(!bAdded)
     4287      {
     4288        bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLB, MD_BELOW_LEFT);
     4289        if (!bAdded)
     4290        {
     4291          xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLB, MD_LEFT );
     4292        }
     4293      }
    43004294    }
    43014295  }
    43024296
    43034297  // Above predictor search
    4304   bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT);
    4305 
    4306   if (!bAdded)
    4307   {
    4308     bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE);
    4309   }
    4310 
    4311   if(!bAdded)
    4312   {
    4313     xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
    4314   }
    4315 
    4316   if(!bAddedSmvp)
    4317   {
    4318     bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT);
     4298  {
     4299    Bool bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE_RIGHT);
    43194300    if (!bAdded)
    43204301    {
    4321       bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE);
    4322     }
    4323 
    4324     if(!bAdded)
    4325     {
    4326       xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
     4302      bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE);
     4303      if(!bAdded)
     4304      {
     4305        xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLT, MD_ABOVE_LEFT);
     4306      }
     4307    }
     4308  }
     4309
     4310  if(!isScaledFlagLX)
     4311  {
     4312    Bool bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE_RIGHT);
     4313    if (!bAdded)
     4314    {
     4315      bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE);
     4316      if(!bAdded)
     4317      {
     4318        xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLT, MD_ABOVE_LEFT);
     4319      }
    43274320    }
    43284321  }
     
    43364329  }
    43374330
    4338   if ( getSlice()->getEnableTMVPFlag() )
     4331  if (pInfo->iN < AMVP_MAX_NUM_CANDS && getSlice()->getEnableTMVPFlag() )
    43394332  {
    43404333    // Get Temporal Motion Predictor
    4341     Int iRefIdx_Col = iRefIdx;
     4334    const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
     4335    const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
     4336#if NH_3D_TMVP
     4337    Int refIdx_Col = refIdx;
     4338#else
     4339    const Int refIdx_Col = refIdx;
     4340#endif
    43424341    TComMv cColMv;
    4343     UInt uiPartIdxRB;
    4344     UInt uiAbsPartIdx;
    4345     UInt uiAbsPartAddr;
    4346 
    4347     deriveRightBottomIdx( uiPartIdx, uiPartIdxRB );
    4348     uiAbsPartAddr = m_absZIdxInCtu + uiPartAddr;
     4342    UInt partIdxRB;
     4343    UInt absPartIdx;
     4344
     4345    deriveRightBottomIdx( partIdx, partIdxRB );
     4346    UInt absPartAddr = m_absZIdxInCtu + partAddr;
    43494347
    43504348    //----  co-located RightBottom Temporal Predictor (H) ---//
    4351     uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB];
     4349    absPartIdx = g_auiZscanToRaster[partIdxRB];
    43524350    Int ctuRsAddr = -1;
    4353     if (  ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () )  // image boundary check
    4354        && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
    4355     {
    4356       if ( ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) &&  // is not at the last column of CTU
    4357            ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) )  // is not at the last row    of CTU
    4358       {
    4359         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth + 1 ];
     4351    if (  ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[absPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () )  // image boundary check
     4352      && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[absPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
     4353    {
     4354      if ( ( absPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) &&  // is not at the last column of CTU
     4355        ( absPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) )  // is not at the last row    of CTU
     4356      {
     4357        absPartAddr = g_auiRasterToZscan[ absPartIdx + numPartInCtuWidth + 1 ];
    43604358        ctuRsAddr = getCtuRsAddr();
    43614359      }
    4362       else if ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 )  // is not at the last column of CTU But is last row of CTU
    4363       {
    4364         uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ];
    4365       }
    4366       else if ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU
    4367       {
    4368         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ];
     4360      else if ( absPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 )  // is not at the last column of CTU But is last row of CTU
     4361      {
     4362        absPartAddr = g_auiRasterToZscan[ (absPartIdx + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ];
     4363      }
     4364      else if ( absPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU
     4365      {
     4366        absPartAddr = g_auiRasterToZscan[ absPartIdx + 1 ];
    43694367        ctuRsAddr = getCtuRsAddr() + 1;
    43704368      }
    43714369      else //is the right bottom corner of CTU
    43724370      {
    4373         uiAbsPartAddr = 0;
    4374       }
    4375     }
    4376     if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx_Col
     4371        absPartAddr = 0;
     4372      }
     4373    }
     4374    if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, absPartAddr, cColMv, refIdx_Col
    43774375#if NH_3D_TMVP
    4378          , 0
    4379 #endif
    4380  ) )
     4376      , 0
     4377#endif
     4378      ) )
    43814379    {
    43824380      pInfo->m_acMvCand[pInfo->iN++] = cColMv;
     
    43854383    {
    43864384      UInt uiPartIdxCenter;
    4387       xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter );
    4388       if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter,  cColMv, iRefIdx_Col
     4385      xDeriveCenterIdx( partIdx, uiPartIdxCenter );
     4386      if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter,  cColMv, refIdx_Col
    43894387#if NH_3D_TMVP
    4390          , 0
    4391 #endif
    4392 ))
     4388        , 0
     4389#endif
     4390        ))
    43934391      {
    43944392        pInfo->m_acMvCand[pInfo->iN++] = cColMv;
     
    43964394    }
    43974395    //----  co-located RightBottom Temporal Predictor  ---//
    4398   }
    4399 
    4400   if (pInfo->iN > AMVP_MAX_NUM_CANDS)
    4401   {
    4402     pInfo->iN = AMVP_MAX_NUM_CANDS;
    44034396  }
    44044397
     
    44124405
    44134406
    4414 Bool TComDataCU::isBipredRestriction(UInt puIdx)
     4407Bool TComDataCU::isBipredRestriction(UInt puIdx) const
    44154408{
    44164409  Int width = 0;
     
    44344427
    44354428
    4436 Void TComDataCU::clipMv    (TComMv&  rcMv)
     4429Void TComDataCU::clipMv    (TComMv&  rcMv) const
    44374430{
    44384431  const TComSPS &sps=*(m_pcSlice->getSPS());
     
    44704463#endif
    44714464
    4472 UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx)
     4465UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) const
    44734466{
    44744467  UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 );
     
    45074500 * \returns true if the current the block is skipped
    45084501 */
    4509 Bool TComDataCU::isSkipped( UInt uiPartIdx )
     4502Bool TComDataCU::isSkipped( UInt uiPartIdx ) const
    45104503{
    45114504  return ( getSkipFlag( uiPartIdx ) );
     
    45164509// ====================================================================================================================
    45174510
    4518 Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir )
    4519 {
    4520   TComDataCU* pcTmpCU = NULL;
    4521   UInt uiIdx;
     4511Bool TComDataCU::xAddMVPCandUnscaled( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const
     4512{
     4513  const TComDataCU* neibCU = NULL;
     4514  UInt neibPUPartIdx;
    45224515  switch( eDir )
    45234516  {
    45244517    case MD_LEFT:
    45254518    {
    4526       pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx);
     4519      neibCU = getPULeft(neibPUPartIdx, uiPartUnitIdx);
    45274520      break;
    45284521    }
    45294522    case MD_ABOVE:
    45304523    {
    4531       pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx);
     4524      neibCU = getPUAbove(neibPUPartIdx, uiPartUnitIdx);
    45324525      break;
    45334526    }
    45344527    case MD_ABOVE_RIGHT:
    45354528    {
    4536       pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx);
     4529      neibCU = getPUAboveRight(neibPUPartIdx, uiPartUnitIdx);
    45374530      break;
    45384531    }
    45394532    case MD_BELOW_LEFT:
    45404533    {
    4541       pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx);
     4534      neibCU = getPUBelowLeft(neibPUPartIdx, uiPartUnitIdx);
    45424535      break;
    45434536    }
    45444537    case MD_ABOVE_LEFT:
    45454538    {
    4546       pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx);
     4539      neibCU = getPUAboveLeft(neibPUPartIdx, uiPartUnitIdx);
    45474540      break;
    45484541    }
     
    45534546  }
    45544547
    4555   if ( pcTmpCU == NULL )
     4548  if ( neibCU == NULL )
    45564549  {
    45574550    return false;
    45584551  }
    45594552
    4560   if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ))
    4561   {
    4562     TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
    4563 
    4564     pInfo->m_acMvCand[ pInfo->iN++] = cMvPred;
    4565     return true;
    4566   }
    4567 
    4568   RefPicList eRefPicList2nd = REF_PIC_LIST_0;
    4569   if(       eRefPicList == REF_PIC_LIST_0 )
    4570   {
    4571     eRefPicList2nd = REF_PIC_LIST_1;
    4572   }
    4573   else if ( eRefPicList == REF_PIC_LIST_1)
    4574   {
    4575     eRefPicList2nd = REF_PIC_LIST_0;
    4576   }
    4577 
    4578 
    4579   Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC();
    4580   Int iNeibRefPOC;
    4581 
    4582 
    4583   if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 )
    4584   {
    4585     iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) );
    4586     if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List//
    4587     {
    4588       TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
    4589       pInfo->m_acMvCand[ pInfo->iN++] = cMvPred;
     4553  const Int        currRefPOC     = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC();
     4554  const RefPicList eRefPicList2nd = (eRefPicList == REF_PIC_LIST_0) ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
     4555
     4556  for(Int predictorSource=0; predictorSource<2; predictorSource++) // examine the indicated reference picture list, then if not available, examine the other list.
     4557  {
     4558    const RefPicList eRefPicListIndex = (predictorSource==0) ? eRefPicList : eRefPicList2nd;
     4559    const Int        neibRefIdx       = neibCU->getCUMvField(eRefPicListIndex)->getRefIdx(neibPUPartIdx);
     4560
     4561    if ( neibRefIdx >= 0 && currRefPOC == neibCU->getSlice()->getRefPOC( eRefPicListIndex, neibRefIdx ))
     4562    {
     4563      info.m_acMvCand[info.iN++] = neibCU->getCUMvField(eRefPicListIndex)->getMv(neibPUPartIdx);
    45904564      return true;
    45914565    }
     
    46024576 * \returns Bool
    46034577 */
    4604 Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir )
    4605 {
    4606   TComDataCU* pcTmpCU = NULL;
    4607   UInt uiIdx;
     4578Bool TComDataCU::xAddMVPCandWithScaling( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const
     4579{
     4580  const TComDataCU* neibCU = NULL;
     4581  UInt neibPUPartIdx;
    46084582  switch( eDir )
    46094583  {
    46104584  case MD_LEFT:
    46114585    {
    4612       pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx);
     4586      neibCU = getPULeft(neibPUPartIdx, uiPartUnitIdx);
    46134587      break;
    46144588    }
    46154589  case MD_ABOVE:
    46164590    {
    4617       pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx);
     4591      neibCU = getPUAbove(neibPUPartIdx, uiPartUnitIdx);
    46184592      break;
    46194593    }
    46204594  case MD_ABOVE_RIGHT:
    46214595    {
    4622       pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx);
     4596      neibCU = getPUAboveRight(neibPUPartIdx, uiPartUnitIdx);
    46234597      break;
    46244598    }
    46254599  case MD_BELOW_LEFT:
    46264600    {
    4627       pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx);
     4601      neibCU = getPUBelowLeft(neibPUPartIdx, uiPartUnitIdx);
    46284602      break;
    46294603    }
    46304604  case MD_ABOVE_LEFT:
    46314605    {
    4632       pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx);
     4606      neibCU = getPUAboveLeft(neibPUPartIdx, uiPartUnitIdx);
    46334607      break;
    46344608    }
     
    46394613  }
    46404614
    4641   if ( pcTmpCU == NULL )
     4615  if ( neibCU == NULL )
    46424616  {
    46434617    return false;
    46444618  }
    46454619
    4646   RefPicList eRefPicList2nd = REF_PIC_LIST_0;
    4647   if(       eRefPicList == REF_PIC_LIST_0 )
    4648   {
    4649     eRefPicList2nd = REF_PIC_LIST_1;
    4650   }
    4651   else if ( eRefPicList == REF_PIC_LIST_1)
    4652   {
    4653     eRefPicList2nd = REF_PIC_LIST_0;
    4654   }
    4655 
    4656   Int iCurrPOC = m_pcSlice->getPOC();
    4657   Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC();
    4658   Int iNeibPOC = iCurrPOC;
    4659   Int iNeibRefPOC;
    4660   Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm();
    4661   Bool bIsNeibRefLongTerm = false;
    4662 
    4663   //---------------  V1 (END) ------------------//
    4664   if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0)
    4665   {
    4666     iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) );
    4667     TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
    4668     TComMv rcMv;
    4669 
    4670     bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm();
    4671     if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm )
    4672     {
    4673       if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm )
    4674       {
    4675         rcMv = cMvPred;
    4676       }
    4677       else
    4678       {
    4679         Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC );
    4680         if ( iScale == 4096 )
     4620  const RefPicList eRefPicList2nd = (eRefPicList == REF_PIC_LIST_0) ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
     4621
     4622  const Int  currPOC            = m_pcSlice->getPOC();
     4623  const Int  currRefPOC         = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC();
     4624  const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm();
     4625  const Int  neibPOC            = currPOC;
     4626
     4627  for(Int predictorSource=0; predictorSource<2; predictorSource++) // examine the indicated reference picture list, then if not available, examine the other list.
     4628  {
     4629    const RefPicList eRefPicListIndex = (predictorSource==0) ? eRefPicList : eRefPicList2nd;
     4630    const Int        neibRefIdx       = neibCU->getCUMvField(eRefPicListIndex)->getRefIdx(neibPUPartIdx);
     4631    if( neibRefIdx >= 0)
     4632    {
     4633      const Bool bIsNeibRefLongTerm = neibCU->getSlice()->getRefPic( eRefPicListIndex, neibRefIdx )->getIsLongTerm();
     4634
     4635      if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm )
     4636      {
     4637        const TComMv &cMvPred = neibCU->getCUMvField(eRefPicListIndex)->getMv(neibPUPartIdx);
     4638        TComMv rcMv;
     4639        if ( bIsCurrRefLongTerm /* || bIsNeibRefLongTerm*/ )
    46814640        {
    46824641          rcMv = cMvPred;
     
    46844643        else
    46854644        {
    4686           rcMv = cMvPred.scaleMv( iScale );
     4645          const Int neibRefPOC = neibCU->getSlice()->getRefPOC( eRefPicListIndex, neibRefIdx );
     4646          const Int scale      = xGetDistScaleFactor( currPOC, currRefPOC, neibPOC, neibRefPOC );
     4647          if ( scale == 4096 )
     4648          {
     4649            rcMv = cMvPred;
     4650          }
     4651          else
     4652          {
     4653            rcMv = cMvPred.scaleMv( scale );
     4654          }
    46874655        }
    4688       }
    4689 
    4690       pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
    4691       return true;
    4692     }
    4693   }
    4694   //---------------------- V2(END) --------------------//
    4695   if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0)
    4696   {
    4697     iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) );
    4698     TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
    4699     TComMv rcMv;
    4700 
    4701     bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm();
    4702     if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm )
    4703     {
    4704       if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm )
    4705       {
    4706         rcMv = cMvPred;
    4707       }
    4708       else
    4709       {
    4710         Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC );
    4711         if ( iScale == 4096 )
    4712         {
    4713           rcMv = cMvPred;
    4714         }
    4715         else
    4716         {
    4717           rcMv = cMvPred.scaleMv( iScale );
    4718         }
    4719       }
    4720 
    4721       pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
    4722       return true;
    4723     }
    4724   }
    4725   //---------------------- V3(END) --------------------//
     4656
     4657        info.m_acMvCand[info.iN++] = rcMv;
     4658        return true;
     4659      }
     4660    }
     4661  }
    47264662  return false;
    47274663}
    47284664
    4729 Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int ctuRsAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx
    47304665#if NH_3D_TMVP
    4731   , Bool bMRG
    4732 #endif
    4733 )
    4734 {
    4735   UInt uiAbsPartAddr = uiPartUnitIdx;
    4736 
    4737   RefPicList  eColRefPicList;
    4738   Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale;
    4739   TComMv cColMv;
     4666Bool TComDataCU::xGetColMVP( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, Int& refIdx, Bool bMRG  ) const
     4667#else
     4668Bool TComDataCU::xGetColMVP( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, const Int refIdx ) const
     4669#endif
     4670{
     4671  const UInt absPartAddr = partUnitIdx;
    47404672
    47414673  // use coldir.
    4742   TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx());
    4743   TComDataCU *pColCtu = pColPic->getCtu( ctuRsAddr );
    4744   if(pColCtu->getPic()==0||pColCtu->getPartitionSize(uiPartUnitIdx)==NUMBER_OF_PART_SIZES)
     4674  const TComPic    * const pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx());
     4675  const TComDataCU * const pColCtu = pColPic->getCtu( ctuRsAddr );
     4676  if(pColCtu->getPic()==0 || pColCtu->getPartitionSize(partUnitIdx)==NUMBER_OF_PART_SIZES)
    47454677  {
    47464678    return false;
    47474679  }
    4748   iCurrPOC = m_pcSlice->getPOC();
    4749   iColPOC = pColCtu->getSlice()->getPOC();
    4750 
    4751   if (!pColCtu->isInter(uiAbsPartAddr))
     4680
     4681  if (!pColCtu->isInter(absPartAddr))
    47524682  {
    47534683    return false;
    47544684  }
    47554685
    4756   eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag());
    4757 
    4758   Int iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr);
     4686  RefPicList eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag());
     4687  Int iColRefIdx            = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr);
    47594688
    47604689  if (iColRefIdx < 0 )
    47614690  {
    47624691    eColRefPicList = RefPicList(1 - eColRefPicList);
    4763     iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr);
     4692    iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr);
    47644693
    47654694    if (iColRefIdx < 0 )
     
    47694698  }
    47704699
    4771   // Scale the vector.
    4772   iColRefPOC = pColCtu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx);
    4773   cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr);
    4774 
    4775   iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC();
    4776 
    4777   Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm();
    4778   Bool bIsColRefLongTerm = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx);
     4700#if NH_3D_TMVP
     4701  Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();
     4702#else
     4703  const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();
     4704#endif
     4705  const Bool bIsColRefLongTerm  = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx);
    47794706
    47804707  if ( bIsCurrRefLongTerm != bIsColRefLongTerm )
     
    47844711    if(bMRG && iAlterRefIdx > 0)
    47854712    {
    4786       riRefIdx = iAlterRefIdx;
    4787       bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm();
    4788       iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC();
     4713      refIdx = iAlterRefIdx;
     4714      bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();
    47894715      assert(bIsCurrRefLongTerm == bIsColRefLongTerm);
    47904716    }
     
    47924718    {
    47934719#endif
    4794     return false;
     4720      return false;
    47954721#if NH_3D_TMVP
    47964722    }
    47974723#endif
    47984724  }
    4799 
     4725  // Scale the vector.
     4726  const TComMv &cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(absPartAddr);
     4727
     4728#if NH_3D_TMVP
    48004729  if ( bIsCurrRefLongTerm || bIsColRefLongTerm )
     4730#else
     4731  if ( bIsCurrRefLongTerm /*|| bIsColRefLongTerm*/ )
     4732#endif
    48014733  {
    48024734#if NH_3D_TMVP
    4803     Int iCurrViewId    = m_pcSlice->getViewId ();
    4804     Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewId ();
    4805     Int iColViewId     = pColCtu->getSlice()->getViewId();
    4806     Int iColRefViewId  = pColCtu->getSlice()->getRefPic( eColRefPicList, pColCtu->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewId();
    4807     iScale = 4096;
     4735    const Int iCurrViewId    = m_pcSlice->getViewId ();
     4736    const Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, refIdx)->getViewId ();
     4737    const Int iColViewId     = pColCtu->getSlice()->getViewId();
     4738    const Int iColRefViewId  = pColCtu->getSlice()->getRefPic( eColRefPicList, pColCtu->getCUMvField(eColRefPicList)->getRefIdx(absPartAddr))->getViewId();
     4739    Int scale = 4096;
    48084740    if ( iCurrRefViewId != iCurrViewId && iColViewId != iColRefViewId )
    48094741    {
    4810       iScale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId );
    4811     }
    4812     if ( bMRG && iScale != 4096 && m_pcSlice->getIvMvScalingFlag( ) )
    4813     {
    4814       rcMv = cColMv.scaleMv( iScale );
     4742      scale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId );
     4743    }
     4744    if ( bMRG && scale != 4096 && m_pcSlice->getIvMvScalingFlag( ) )
     4745    {
     4746      rcMv = cColMv.scaleMv( scale );
    48154747    }
    48164748    else
    48174749    {
    48184750#endif
    4819     rcMv = cColMv;
     4751      rcMv = cColMv;
    48204752#if NH_3D_TMVP
    48214753    }
     
    48244756  else
    48254757  {
    4826     iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC);
    4827     if ( iScale == 4096 )
     4758    const Int currPOC    = m_pcSlice->getPOC();
     4759    const Int colPOC     = pColCtu->getSlice()->getPOC();
     4760    const Int colRefPOC  = pColCtu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx);
     4761    const Int currRefPOC = m_pcSlice->getRefPic(eRefPicList, refIdx)->getPOC();
     4762    const Int scale      = xGetDistScaleFactor(currPOC, currRefPOC, colPOC, colRefPOC);
     4763    if ( scale == 4096 )
    48284764    {
    48294765      rcMv = cColMv;
     
    48314767    else
    48324768    {
    4833       rcMv = cColMv.scaleMv( iScale );
     4769      rcMv = cColMv.scaleMv( scale );
    48344770    }
    48354771  }
     
    48384774}
    48394775
     4776// Static member
    48404777Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC)
    48414778{
     
    48574794}
    48584795
    4859 Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter )
     4796Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) const
    48604797{
    48614798  UInt uiPartAddr;
     
    50014938 
    50024939  UInt uiMidPart, uiPartNeighbor; 
    5003   TComDataCU* pcCUNeighbor;
     4940  const TComDataCU* pcCUNeighbor;
    50044941  Bool bDepAvail = false;
    50054942  Pel *pDepth  = this->getPic()->getPicYuvRec()->getAddr(COMPONENT_Y);
     
    51615098  UInt uiIdx = 0;
    51625099  Bool        bCheckMcpDv = false;   
    5163   TComDataCU* pcTmpCU     = NULL;
     5100  const TComDataCU* pcTmpCU     = NULL;
    51645101
    51655102  //// ******* Get disparity from left block ******* /////
     
    53075244
    53085245
    5309 Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos
     5246Bool TComDataCU::xCheckSpatialNBDV( const TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos
    53105247#if NH_3D_NBDV_REF
    53115248, Bool bDepthRefine
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComDataCU.h

    r1321 r1360  
    112112  UChar*         m_ucDISType;
    113113#endif
    114   Char*          m_pePartSize;         ///< array of partition sizes
    115   Char*          m_pePredMode;         ///< array of prediction modes
    116   Char*          m_crossComponentPredictionAlpha[MAX_NUM_COMPONENT]; ///< array of cross-component prediction alpha values
     114  SChar*          m_pePartSize;         ///< array of partition sizes
     115  SChar*        m_pePredMode;                           ///< array of prediction modes
     116  SChar*        m_crossComponentPredictionAlpha[MAX_NUM_COMPONENT]; ///< array of cross-component prediction alpha values
    117117  Bool*          m_CUTransquantBypass;   ///< array of cu_transquant_bypass flags
    118   Char*          m_phQP;               ///< array of QP values
     118  SChar*        m_phQP;                                 ///< array of QP values
    119119  UChar*         m_ChromaQpAdj;        ///< array of chroma QP adjustments (indexed). when value = 0, cu_chroma_qp_offset_flag=0; when value>0, indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=value-1
    120120  UInt           m_codedChromaQpAdj;
     
    125125  TCoeff*        m_pcTrCoeff[MAX_NUM_COMPONENT];       ///< array of transform coefficient buffers (0->Y, 1->Cb, 2->Cr)
    126126#if ADAPTIVE_QP_SELECTION
    127   TCoeff*        m_pcArlCoeff[MAX_NUM_COMPONENT];  // ARL coefficient buffer (0->Y, 1->Cb, 2->Cr)
     127  TCoeff*       m_pcArlCoeff[MAX_NUM_COMPONENT];        ///< ARL coefficient buffer (0->Y, 1->Cb, 2->Cr)
    128128  Bool           m_ArlCoeffIsAliasedAllocation;  ///< ARL coefficient buffer is an alias of the global buffer and must not be free()'d
    129129#endif
     
    154154  Bool          m_bIsMergeAMP;
    155155#endif
    156   UChar*        m_puhIntraDir[MAX_NUM_CHANNEL_TYPE]; // 0-> Luma, 1-> Chroma
     156  UChar*        m_puhIntraDir[MAX_NUM_CHANNEL_TYPE];
    157157  UChar*        m_puhInterDir;        ///< array of inter directions
    158   Char*         m_apiMVPIdx[NUM_REF_PIC_LIST_01];       ///< array of motion vector predictor candidates
    159   Char*         m_apiMVPNum[NUM_REF_PIC_LIST_01];       ///< array of number of possible motion vectors predictors
     158  SChar*        m_apiMVPIdx[NUM_REF_PIC_LIST_01];       ///< array of motion vector predictor candidates
     159  SChar*        m_apiMVPNum[NUM_REF_PIC_LIST_01];       ///< array of number of possible motion vectors predictors
    160160  Bool*         m_pbIPCMFlag;         ///< array of intra_pcm flags
    161161#if NH_3D_NBDV
     
    163163#endif
    164164#if NH_3D_VSP
    165   Char*         m_piVSPFlag;          ///< array of VSP flags to indicate whehter a block uses VSP or not  ///< 0: non-VSP; 1: VSP
     165  SChar*        m_piVSPFlag;          ///< array of VSP flags to indicate whehter a block uses VSP or not  ///< 0: non-VSP; 1: VSP
    166166#endif
    167167#if NH_3D_SPIVMP
     
    208208  UInt          m_uiTotalBits;        ///< sum of partition bits
    209209  UInt          m_uiTotalBins;        ///< sum of partition bins
    210   Char          m_codedQP;
     210  SChar         m_codedQP;
    211211#if NH_3D_MLC
    212212  DisInfo         m_cDefaultDisInfo;    ///< Default disparity information for initializing
     
    219219protected:
    220220
    221   /// add possible motion vector predictor candidates
    222   Bool          xAddMVPCand           ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
    223   Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
     221  /// adds a single possible motion vector predictor candidate
     222  Bool          xAddMVPCandUnscaled           ( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const;
     223  Bool          xAddMVPCandWithScaling        ( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const;
     224
    224225#if NH_3D_VSP
    225226  Bool          xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount);
     
    229230#endif
    230231
    231   Void          deriveRightBottomIdx        ( UInt uiPartIdx, UInt& ruiPartIdxRB );
    232   Bool          xGetColMVP( RefPicList eRefPicList, Int ctuRsAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx
     232  Void          deriveRightBottomIdx          ( UInt uiPartIdx, UInt& ruiPartIdxRB ) const;
     233
    233234#if NH_3D_TMVP
    234   ,  Bool bMRG = true
    235 #endif
    236  );
    237 
     235  Bool          xGetColMVP                    ( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, Int& refIdx, Bool bMRG = true  ) const;
     236#else
     237  Bool          xGetColMVP                    ( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, const Int refIdx ) const;
     238#endif
    238239
    239240  /// compute scaling factor from POC difference
     241
    240242#if !NH_3D_ARP
    241   Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
    242 #endif
    243 
    244   Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter );
     243  static Int    xGetDistScaleFactor           ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
     244#endif
     245  Void          xDeriveCenterIdx              ( UInt uiPartIdx, UInt& ruiPartIdxCenter ) const;
    245246
    246247#if NH_3D_VSP
     
    249250
    250251public:
     252
     253#if NH_3D_ARP
     254  static Int    xGetDistScaleFactor           ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
     255#endif
     256
    251257  TComDataCU();
    252258  virtual ~TComDataCU();
     
    255261  // create / destroy / initialize / copy
    256262  // -------------------------------------------------------------------------------------------------------------------
    257 #if NH_3D_ARP
    258   /// compute scaling factor from POC difference
    259   Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
    260 #endif
    261263  Void          create                ( ChromaFormat chromaFormatIDC, UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize
    262264#if ADAPTIVE_QP_SELECTION
     
    315317  // -------------------------------------------------------------------------------------------------------------------
    316318
    317   Char*         getPartitionSize      ()                        { return m_pePartSize;        }
    318   PartSize      getPartitionSize      ( UInt uiIdx )            { return static_cast<PartSize>( m_pePartSize[uiIdx] ); }
     319  SChar*        getPartitionSize              ( )                                                          { return m_pePartSize;                       }
     320  PartSize      getPartitionSize              ( UInt uiIdx ) const                                         { return static_cast<PartSize>( m_pePartSize[uiIdx] ); }
    319321  Void          setPartitionSize      ( UInt uiIdx, PartSize uh){ m_pePartSize[uiIdx] = uh;   }
    320322  Void          setPartSizeSubParts   ( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth );
     
    326328 
    327329  Bool*         getSkipFlag            ()                        { return m_skipFlag;          }
    328   Bool          getSkipFlag            (UInt idx)                { return m_skipFlag[idx];     }
     330  Bool          getSkipFlag                   ( UInt idx ) const                                           { return m_skipFlag[idx];                    }
    329331  Void          setSkipFlag           ( UInt idx, Bool skip)     { m_skipFlag[idx] = skip;   }
    330332  Void          setSkipFlagSubParts   ( Bool skip, UInt absPartIdx, UInt depth );
     
    340342  Void         setDISTypeSubParts    ( UChar ucDISType, UInt uiAbsPartIdx, UInt uiDepth );
    341343#endif
    342   Char*         getPredictionMode     ()                        { return m_pePredMode;        }
    343   PredMode      getPredictionMode     ( UInt uiIdx )            { return static_cast<PredMode>( m_pePredMode[uiIdx] ); }
     344  SChar*        getPredictionMode             ( )                                                          { return m_pePredMode;                       }
     345  PredMode      getPredictionMode             ( UInt uiIdx ) const                                         { return static_cast<PredMode>( m_pePredMode[uiIdx] ); }
    344346  Void          setPredictionMode     ( UInt uiIdx, PredMode uh){ m_pePredMode[uiIdx] = uh;   }
    345347  Void          setPredModeSubParts   ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth );
    346348
    347349#if NH_3D_DBBP
    348   Bool*         getDBBPFlag           ()                        { return m_pbDBBPFlag;               }
    349   Bool          getDBBPFlag           ( UInt uiIdx )            { return m_pbDBBPFlag[uiIdx];        }
     350  Bool*         getDBBPFlag           ()                        const { return m_pbDBBPFlag;               }
     351  Bool          getDBBPFlag           ( UInt uiIdx )            const { return m_pbDBBPFlag[uiIdx];        }
    350352  Void          setDBBPFlag           ( UInt uiIdx, Bool b )    { m_pbDBBPFlag[uiIdx] = b;           }
    351353  Void          setDBBPFlagSubParts   ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
     
    353355#endif
    354356
    355   Char*         getCrossComponentPredictionAlpha( ComponentID compID )             { return m_crossComponentPredictionAlpha[compID];         }
    356   Char          getCrossComponentPredictionAlpha( UInt uiIdx, ComponentID compID ) { return m_crossComponentPredictionAlpha[compID][uiIdx]; }
     357  SChar*        getCrossComponentPredictionAlpha( ComponentID compID )                                     { return m_crossComponentPredictionAlpha[compID];        }
     358  SChar         getCrossComponentPredictionAlpha( UInt uiIdx, ComponentID compID )                         { return m_crossComponentPredictionAlpha[compID][uiIdx]; }
    357359
    358360  Bool*         getCUTransquantBypass ()                        { return m_CUTransquantBypass;        }
    359   Bool          getCUTransquantBypass( UInt uiIdx )             { return m_CUTransquantBypass[uiIdx]; }
     361  Bool          getCUTransquantBypass         ( UInt uiIdx ) const                                         { return m_CUTransquantBypass[uiIdx];        }
    360362
    361363  UChar*        getWidth              ()                        { return m_puhWidth;          }
    362   UChar         getWidth              ( UInt uiIdx )            { return m_puhWidth[uiIdx];   }
     364  UChar         getWidth                      ( UInt uiIdx ) const                                         { return m_puhWidth[uiIdx];                  }
    363365  Void          setWidth              ( UInt uiIdx, UChar  uh ) { m_puhWidth[uiIdx] = uh;     }
    364366
    365367  UChar*        getHeight             ()                        { return m_puhHeight;         }
    366   UChar         getHeight             ( UInt uiIdx )            { return m_puhHeight[uiIdx];  }
     368  UChar         getHeight                     ( UInt uiIdx ) const                                         { return m_puhHeight[uiIdx];                 }
    367369  Void          setHeight             ( UInt uiIdx, UChar  uh ) { m_puhHeight[uiIdx] = uh;    }
    368370
    369371  Void          setSizeSubParts       ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth );
    370372
    371   Char*         getQP                 ()                        { return m_phQP;              }
    372   Char          getQP                 ( UInt uiIdx ) const      { return m_phQP[uiIdx];       }
    373   Void          setQP                 ( UInt uiIdx, Char value ){ m_phQP[uiIdx] =  value;     }
     373  SChar*        getQP                         ( )                                                          { return m_phQP;                             }
     374  SChar         getQP                         ( UInt uiIdx ) const                                         { return m_phQP[uiIdx];                      }
     375  Void          setQP                         ( UInt uiIdx, SChar value )                                  { m_phQP[uiIdx] =  value;                    }
    374376  Void          setQPSubParts         ( Int qp,   UInt uiAbsPartIdx, UInt uiDepth );
    375   Int           getLastValidPartIdx   ( Int iAbsPartIdx );
    376   Char          getLastCodedQP        ( UInt uiAbsPartIdx );
     377  Int           getLastValidPartIdx           ( Int iAbsPartIdx ) const;
     378  SChar         getLastCodedQP                ( UInt uiAbsPartIdx ) const;
    377379  Void          setQPSubCUs           ( Int qp, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf );
    378   Void          setCodedQP            ( Char qp )               { m_codedQP = qp;             }
    379   Char          getCodedQP            ()                        { return m_codedQP;           }
     380  Void          setCodedQP                    ( SChar qp )                                                 { m_codedQP = qp;                            }
     381  SChar         getCodedQP                    ( ) const                                                    { return m_codedQP;                          }
    380382
    381383  UChar*        getChromaQpAdj        ()                        { return m_ChromaQpAdj;       } ///< array of chroma QP adjustments (indexed). when value = 0, cu_chroma_qp_offset_flag=0; when value>0, indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=value-1
     
    383385  Void          setChromaQpAdj        (Int idx, UChar val)      { m_ChromaQpAdj[idx] = val;   } ///< When val = 0,   cu_chroma_qp_offset_flag=0; when val>0,   indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=val-1
    384386  Void          setChromaQpAdjSubParts( UChar val, Int absPartIdx, Int depth );
    385   Void          setCodedChromaQpAdj   ( Char qp )               { m_codedChromaQpAdj = qp;    }
    386   Char          getCodedChromaQpAdj   ()                        { return m_codedChromaQpAdj;  }
    387 
    388   Bool          isLosslessCoded       ( UInt absPartIdx );
     387  Void          setCodedChromaQpAdj           ( SChar qp )                                                 { m_codedChromaQpAdj = qp;                   }
     388  SChar         getCodedChromaQpAdj           ( ) const                                                    { return m_codedChromaQpAdj;                 }
     389
     390  Bool          isLosslessCoded               ( UInt absPartIdx ) const;
    389391
    390392  UChar*        getTransformIdx       ()                        { return m_puhTrIdx;          }
    391   UChar         getTransformIdx       ( UInt uiIdx )            { return m_puhTrIdx[uiIdx];   }
     393  UChar         getTransformIdx               ( UInt uiIdx ) const                                         { return m_puhTrIdx[uiIdx];                  }
    392394  Void          setTrIdxSubParts      ( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth );
    393395
    394396  UChar*        getTransformSkip      ( ComponentID compID )    { return m_puhTransformSkip[compID];}
    395   UChar         getTransformSkip      ( UInt uiIdx, ComponentID compID)    { return m_puhTransformSkip[compID][uiIdx];}
     397  UChar         getTransformSkip              ( UInt uiIdx, ComponentID compID ) const                     { return m_puhTransformSkip[compID][uiIdx];  }
    396398  Void          setTransformSkipSubParts  ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth);
    397399  Void          setTransformSkipSubParts  ( const UInt useTransformSkip[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth );
    398400
    399401  UChar*        getExplicitRdpcmMode      ( ComponentID component ) { return m_explicitRdpcmMode[component]; }
    400   UChar         getExplicitRdpcmMode      ( ComponentID component, UInt partIdx ) {return m_explicitRdpcmMode[component][partIdx]; }
     402  UChar         getExplicitRdpcmMode          ( ComponentID component, UInt partIdx ) const                { return m_explicitRdpcmMode[component][partIdx]; }
    401403  Void          setExplicitRdpcmModePartRange ( UInt rdpcmMode, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );
    402404
    403   Bool          isRDPCMEnabled         ( UInt uiAbsPartIdx )  { return getSlice()->getSPS()->getSpsRangeExtension().getRdpcmEnabledFlag(isIntra(uiAbsPartIdx) ? RDPCM_SIGNAL_IMPLICIT : RDPCM_SIGNAL_EXPLICIT); }
    404 
    405   Void          setCrossComponentPredictionAlphaPartRange    ( Char alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );
     405  Bool          isRDPCMEnabled                ( UInt uiAbsPartIdx ) const                                  { return getSlice()->getSPS()->getSpsRangeExtension().getRdpcmEnabledFlag(isIntra(uiAbsPartIdx) ? RDPCM_SIGNAL_IMPLICIT : RDPCM_SIGNAL_EXPLICIT); }
     406
     407  Void          setCrossComponentPredictionAlphaPartRange ( SChar alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );
    406408  Void          setTransformSkipPartRange                    ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );
    407409
    408   UInt          getQuadtreeTULog2MinSizeInCU( UInt uiIdx );
     410  UInt          getQuadtreeTULog2MinSizeInCU  ( UInt uiIdx ) const;
    409411
    410412  TComCUMvField* getCUMvField         ( RefPicList e )          { return  &m_acCUMvField[e];  }
     413  const TComCUMvField* getCUMvField           ( RefPicList e ) const                                       { return &m_acCUMvField[e];                  }
    411414
    412415  TCoeff*       getCoeff              (ComponentID component)   { return m_pcTrCoeff[component]; }
     
    417420  Pel*          getPCMSample          ( ComponentID component ) { return m_pcIPCMSample[component]; }
    418421
    419   UChar         getCbf    ( UInt uiIdx, ComponentID eType )                  { return m_puhCbf[eType][uiIdx];  }
     422  UChar         getCbf                        ( UInt uiIdx, ComponentID eType ) const                      { return m_puhCbf[eType][uiIdx];             }
    420423  UChar*        getCbf    ( ComponentID eType )                              { return m_puhCbf[eType];         }
    421   UChar         getCbf    ( UInt uiIdx, ComponentID eType, UInt uiTrDepth )  { return ( ( getCbf( uiIdx, eType ) >> uiTrDepth ) & 0x1 ); }
     424  UChar         getCbf                        ( UInt uiIdx, ComponentID eType, UInt uiTrDepth ) const      { return ( ( getCbf( uiIdx, eType ) >> uiTrDepth ) & 0x1 ); }
    422425  Void          setCbf    ( UInt uiIdx, ComponentID eType, UChar uh )        { m_puhCbf[eType][uiIdx] = uh;    }
    423426  Void          clearCbf  ( UInt uiIdx, ComponentID eType, UInt uiNumParts );
    424   UChar         getQtRootCbf          ( UInt uiIdx );
     427  UChar         getQtRootCbf                  ( UInt uiIdx ) const;
    425428
    426429  Void          setCbfSubParts        ( const UInt uiCbf[MAX_NUM_COMPONENT],  UInt uiAbsPartIdx, UInt uiDepth           );
     
    436439
    437440  Bool*         getMergeFlag          ()                        { return m_pbMergeFlag;               }
    438   Bool          getMergeFlag          ( UInt uiIdx )            { return m_pbMergeFlag[uiIdx];        }
     441  Bool          getMergeFlag                  ( UInt uiIdx ) const                                         { return m_pbMergeFlag[uiIdx];               }
    439442  Void          setMergeFlag          ( UInt uiIdx, Bool b )    { m_pbMergeFlag[uiIdx] = b;           }
    440443  Void          setMergeFlagSubParts  ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    441444
    442445  UChar*        getMergeIndex         ()                        { return m_puhMergeIndex;                         }
    443   UChar         getMergeIndex         ( UInt uiIdx )            { return m_puhMergeIndex[uiIdx];                  }
     446  UChar         getMergeIndex                 ( UInt uiIdx ) const                                         { return m_puhMergeIndex[uiIdx];             }
    444447  Void          setMergeIndex         ( UInt uiIdx, UInt uiMergeIndex ) { m_puhMergeIndex[uiIdx] = uiMergeIndex;  }
    445448  Void          setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
     
    453456#if AMP_MRG
    454457  Void          setMergeAMP( Bool b )      { m_bIsMergeAMP = b; }
    455   Bool          getMergeAMP( )             { return m_bIsMergeAMP; }
     458  Bool          getMergeAMP                   ( ) const                                                    { return m_bIsMergeAMP;                      }
    456459#endif
    457460
     
    465468
    466469  UChar*        getInterDir           ()                        { return m_puhInterDir;               }
    467   UChar         getInterDir           ( UInt uiIdx )            { return m_puhInterDir[uiIdx];        }
     470  UChar         getInterDir                   ( UInt uiIdx ) const                                         { return m_puhInterDir[uiIdx];               }
    468471  Void          setInterDir           ( UInt uiIdx, UChar  uh ) { m_puhInterDir[uiIdx] = uh;          }
    469472  Void          setInterDirSubParts   ( UInt uiDir,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    470473  Bool*         getIPCMFlag           ()                        { return m_pbIPCMFlag;               }
    471   Bool          getIPCMFlag           (UInt uiIdx )             { return m_pbIPCMFlag[uiIdx];        }
     474  Bool          getIPCMFlag                   ( UInt uiIdx ) const                                         { return m_pbIPCMFlag[uiIdx];                }
    472475  Void          setIPCMFlag           (UInt uiIdx, Bool b )     { m_pbIPCMFlag[uiIdx] = b;           }
    473476  Void          setIPCMFlagSubParts   (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth);
     
    482485#if NH_3D_NBDV
    483486  Void          xDeriveRightBottomNbIdx(Int &uiLCUIdxRBNb, Int &uiPartIdxRBNb );
    484   Bool          xCheckSpatialNBDV (TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paMvpDvInfo,
     487  Bool          xCheckSpatialNBDV (const TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paMvpDvInfo,
    485488                                   UInt uiMvpDvPos
    486489#if NH_3D_NBDV_REF
     
    525528#endif
    526529#if NH_3D_ARP
    527   UChar*        getARPW            ()                        { return m_puhARPW;               }
    528   UChar         getARPW            ( UInt uiIdx )            { return m_puhARPW[uiIdx];        }
     530  UChar*        getARPW            ()              const          { return m_puhARPW;               }
     531  UChar         getARPW            ( UInt uiIdx )  const          { return m_puhARPW[uiIdx];        }
    529532  Void          setARPW            ( UInt uiIdx, UChar w )   { m_puhARPW[uiIdx] = w;           }
    530533  Void          setARPWSubParts    ( UChar w, UInt uiAbsPartIdx, UInt uiDepth );
     
    536539  Void          setICFlagSubParts  ( Bool bICFlag,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    537540  Bool          isICFlagRequired   ( UInt uiAbsPartIdx );
    538   Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false);
     541  Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false) const;
    539542#elif NH_3D_VSP
    540   Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false);
     543  Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false) const;
    541544#else
    542545  // -------------------------------------------------------------------------------------------------------------------
     
    544547  // -------------------------------------------------------------------------------------------------------------------
    545548
    546   Void          getPartIndexAndSize   ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ); // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx
    547 #endif
    548   UChar         getNumPartitions      ( const UInt uiAbsPartIdx = 0 );
    549   Bool          isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth);
     549  Void          getPartIndexAndSize           ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) const; // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx
     550#endif
     551  UChar         getNumPartitions              ( const UInt uiAbsPartIdx = 0 ) const;
     552  Bool          isFirstAbsZorderIdxInDepth    ( UInt uiAbsPartIdx, UInt uiDepth ) const;
    550553
    551554#if NH_3D_DMM
     
    575578  // -------------------------------------------------------------------------------------------------------------------
    576579
    577   Void          getMvField            ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField );
    578 
    579   Void          fillMvpCand           ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo );
    580   Bool          isDiffMER             ( Int xN, Int yN, Int xP, Int yP);
    581   Void          getPartPosition       ( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH);
     580  static Void   getMvField                    ( const TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField );
     581
     582  Void          fillMvpCand                   ( const UInt uiPartIdx, const UInt uiPartAddr, const RefPicList eRefPicList, const Int iRefIdx, AMVPInfo* pInfo ) const;
     583  Bool          isDiffMER                     ( Int xN, Int yN, Int xP, Int yP ) const;
     584  Void          getPartPosition               ( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH ) const;
    582585
    583586  Void          setMVPIdx             ( RefPicList eRefPicList, UInt uiIdx, Int iMVPIdx)  { m_apiMVPIdx[eRefPicList][uiIdx] = iMVPIdx;  }
    584   Int           getMVPIdx             ( RefPicList eRefPicList, UInt uiIdx)               { return m_apiMVPIdx[eRefPicList][uiIdx];     }
    585   Char*         getMVPIdx             ( RefPicList eRefPicList )                          { return m_apiMVPIdx[eRefPicList];            }
     587  Int           getMVPIdx                     ( RefPicList eRefPicList, UInt uiIdx) const                  { return m_apiMVPIdx[eRefPicList][uiIdx];    }
     588  SChar*        getMVPIdx                     ( RefPicList eRefPicList )                                   { return m_apiMVPIdx[eRefPicList];           }
    586589
    587590  Void          setMVPNum             ( RefPicList eRefPicList, UInt uiIdx, Int iMVPNum ) { m_apiMVPNum[eRefPicList][uiIdx] = iMVPNum;  }
    588   Int           getMVPNum             ( RefPicList eRefPicList, UInt uiIdx )              { return m_apiMVPNum[eRefPicList][uiIdx];     }
    589   Char*         getMVPNum             ( RefPicList eRefPicList )                          { return m_apiMVPNum[eRefPicList];            }
     591  Int           getMVPNum                     ( RefPicList eRefPicList, UInt uiIdx ) const                 { return m_apiMVPNum[eRefPicList][uiIdx];    }
     592  SChar*        getMVPNum                     ( RefPicList eRefPicList )                                   { return m_apiMVPNum[eRefPicList];           }
    590593
    591594  Void          setMVPIdxSubParts     ( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    592595  Void          setMVPNumSubParts     ( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    593596
    594   Void          clipMv                ( TComMv&     rcMv     );
     597  Void          clipMv                        ( TComMv&     rcMv     ) const;
     598
    595599#if NH_MV
    596600  Void          checkMvVertRest (TComMv&  rcMv,  RefPicList eRefPicList, int iRefIdx );
    597601#endif
    598   Void          getMvPredLeft         ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldA.getMv(); }
    599   Void          getMvPredAbove        ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldB.getMv(); }
    600   Void          getMvPredAboveRight   ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldC.getMv(); }
     602  Void          getMvPredLeft                 ( TComMv&     rcMvPred ) const                               { rcMvPred = m_cMvFieldA.getMv();            }
     603  Void          getMvPredAbove                ( TComMv&     rcMvPred ) const                               { rcMvPred = m_cMvFieldB.getMv();            }
     604  Void          getMvPredAboveRight           ( TComMv&     rcMvPred ) const                               { rcMvPred = m_cMvFieldC.getMv();            }
    601605#if NH_3D
    602606  Void          compressMV            ( Int scale );
     
    618622  Bool          CUIsFromSameSliceAndTile    ( const TComDataCU *pCU /* Can be NULL */) const;
    619623  Bool          CUIsFromSameSliceTileAndWavefrontRow( const TComDataCU *pCU /* Can be NULL */) const;
    620   Bool          isLastSubCUOfCtu(const UInt absPartIdx);
    621 
    622 
    623   TComDataCU*   getPULeft                   ( UInt& uiLPartUnitIdx,
     624  Bool          isLastSubCUOfCtu              ( const UInt absPartIdx ) const;
     625
     626
     627  const TComDataCU*   getPULeft               ( UInt& uiLPartUnitIdx,
    624628                                              UInt uiCurrPartUnitIdx,
    625629                                              Bool bEnforceSliceRestriction=true,
    626                                               Bool bEnforceTileRestriction=true );
    627   TComDataCU*   getPUAbove                  ( UInt&  uiAPartUnitIdx,
     630                                                Bool  bEnforceTileRestriction=true ) const;
     631
     632  const TComDataCU*   getPUAbove              ( UInt& uiAPartUnitIdx,
    628633                                              UInt uiCurrPartUnitIdx,
    629634                                              Bool bEnforceSliceRestriction=true,
    630635                                              Bool planarAtCTUBoundary = false,
    631                                               Bool bEnforceTileRestriction=true );
    632   TComDataCU*   getPUAboveLeft              ( UInt&  uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );
    633 
    634   TComDataCU*   getQpMinCuLeft              ( UInt&  uiLPartUnitIdx , UInt uiCurrAbsIdxInCtu );
    635   TComDataCU*   getQpMinCuAbove             ( UInt&  uiAPartUnitIdx , UInt uiCurrAbsIdxInCtu );
    636   Char          getRefQP                    ( UInt   uiCurrAbsIdxInCtu                       );
     636                                                Bool  bEnforceTileRestriction=true ) const;
     637
     638  const TComDataCU*   getPUAboveLeft          ( UInt&  uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true ) const;
     639
     640  const TComDataCU*   getQpMinCuLeft          ( UInt&  uiLPartUnitIdx,  UInt uiCurrAbsIdxInCtu ) const;
     641  const TComDataCU*   getQpMinCuAbove         ( UInt&  uiAPartUnitIdx,  UInt uiCurrAbsIdxInCtu ) const;
    637642
    638643  /// returns CU and part index of the PU above the top row of the current uiCurrPartUnitIdx of the CU, at a horizontal offset (to the right) of uiPartUnitOffset (in parts)
    639   TComDataCU*   getPUAboveRight             ( UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true );
     644  const TComDataCU*   getPUAboveRight         ( UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true ) const;
    640645  /// returns CU and part index of the PU left of the lefthand column of the current uiCurrPartUnitIdx of the CU, at a vertical offset (below) of uiPartUnitOffset (in parts)
    641   TComDataCU*   getPUBelowLeft              ( UInt&  uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true );
    642 
    643   Void          deriveLeftRightTopIdx       ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
    644   Void          deriveLeftBottomIdx         ( UInt uiPartIdx, UInt& ruiPartIdxLB );
    645 
    646   Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );
     646  const TComDataCU*   getPUBelowLeft          ( UInt&  uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true ) const;
     647
     648  SChar         getRefQP                      ( UInt uiCurrAbsIdxInCtu ) const;
     649
     650  Void          deriveLeftRightTopIdx         ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const;
     651  Void          deriveLeftBottomIdx           ( UInt uiPartIdx, UInt& ruiPartIdxLB ) const;
     652
    647653#if NH_3D
    648654  Bool          hasEqualMotion              ( Int dirA, const TComMvField* mvFieldA,  Int dirB, const TComMvField* mvFieldB  );
    649655#endif
     656  Bool          hasEqualMotion                ( UInt uiAbsPartIdx, const TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) const;
     657
    650658#if NH_3D_MLC
    651659  Bool          getAvailableFlagA1() { return m_bAvailableFlagA1;   }
     
    670678  , Int& numValidMergeCand, Int mrgCandIdx = -1 );
    671679#endif
     680#if NH_3D
    672681  Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 );
     682#else
     683  Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 ) const;
     684#endif
    673685
    674686#if NH_3D_VSP
    675687#if NH_3D_SPIVMP
    676   Bool*         getSPIVMPFlag        ()                        { return m_pbSPIVMPFlag;          }
    677   Bool          getSPIVMPFlag        ( UInt uiIdx )            { return m_pbSPIVMPFlag[uiIdx];   }
     688  Bool*         getSPIVMPFlag        ()                        const { return m_pbSPIVMPFlag;          }
     689  Bool          getSPIVMPFlag        ( UInt uiIdx )            const { return m_pbSPIVMPFlag[uiIdx];   }
    678690  Void          setSPIVMPFlag        ( UInt uiIdx, Bool n )     { m_pbSPIVMPFlag[uiIdx] = n;      }
    679691  Void          setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    680692#endif
    681693
    682   Char*         getVSPFlag        ()                        { return m_piVSPFlag;          }
    683   Char          getVSPFlag        ( UInt uiIdx )            { return m_piVSPFlag[uiIdx];   }
     694  SChar*        getVSPFlag        ()                        const { return m_piVSPFlag;          }
     695  SChar         getVSPFlag        ( UInt uiIdx )            const { return m_piVSPFlag[uiIdx];   }
    684696  Void          setVSPFlag        ( UInt uiIdx, Int n )     { m_piVSPFlag[uiIdx] = n;      }
    685   Void          setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
     697  Void          setVSPFlagSubParts( SChar iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    686698  Void          setMvFieldPUForVSP    ( TComDataCU* cu, UInt partAddr, Int width, Int height, RefPicList refPicList, Int refIdx, Int &vspSize );
    687699#endif
    688   Void          deriveLeftRightTopIdxGeneral  ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
    689   Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );
    690 
     700  Void          deriveLeftRightTopIdxGeneral  ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const;
     701  Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) const;
    691702  // -------------------------------------------------------------------------------------------------------------------
    692703  // member functions for modes
     
    695706  Bool          isIntra            ( UInt uiPartIdx )  const { return m_pePredMode[ uiPartIdx ] == MODE_INTRA;                                              }
    696707  Bool          isInter            ( UInt uiPartIdx )  const { return m_pePredMode[ uiPartIdx ] == MODE_INTER;                                              }
    697   Bool          isSkipped          ( UInt uiPartIdx );                                                    ///< returns true, if the partiton is skipped
    698   Bool          isBipredRestriction( UInt puIdx );
     708  Bool          isSkipped                     ( UInt uiPartIdx ) const; ///< returns true, if the partiton is skipped
     709  Bool          isBipredRestriction           ( UInt puIdx     ) const;
    699710
    700711  // -------------------------------------------------------------------------------------------------------------------
     
    702713  // -------------------------------------------------------------------------------------------------------------------
    703714
    704   UInt          getIntraSizeIdx                 ( UInt uiAbsPartIdx                                       );
    705 
    706   Void          getAllowedChromaDir             ( UInt uiAbsPartIdx, UInt* uiModeList );
    707   Void          getIntraDirPredictor            ( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode = NULL );
     715  UInt          getIntraSizeIdx               ( UInt uiAbsPartIdx ) const;
     716
     717  Void          getAllowedChromaDir           ( UInt uiAbsPartIdx, UInt* uiModeList ) const;
     718  Void          getIntraDirPredictor          ( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode = NULL ) const;
    708719
    709720  // -------------------------------------------------------------------------------------------------------------------
     
    711722  // -------------------------------------------------------------------------------------------------------------------
    712723
    713   UInt          getCtxSplitFlag                 ( UInt   uiAbsPartIdx, UInt uiDepth                   );
    714   UInt          getCtxQtCbf                     ( TComTU &rTu, const ChannelType chType );
    715 
    716   UInt          getCtxSkipFlag                  ( UInt   uiAbsPartIdx                                 );
    717   UInt          getCtxInterDir                  ( UInt   uiAbsPartIdx                                 );
     724  UInt          getCtxSplitFlag               ( UInt   uiAbsPartIdx, UInt uiDepth     ) const;
     725  UInt          getCtxQtCbf                   ( TComTU &rTu, const ChannelType chType ) const;
     726
     727  UInt          getCtxSkipFlag                ( UInt   uiAbsPartIdx ) const;
     728  UInt          getCtxInterDir                ( UInt   uiAbsPartIdx ) const;
    718729#if NH_3D_ARP
    719730  UInt          getCTXARPWFlag                  ( UInt   uiAbsPartIdx                                 );
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComLoopFilter.cpp

    r1313 r1360  
    365365  UInt uiY           = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsZorderIdx ] ];
    366366
    367   TComDataCU* pcTempCU;
    368367  UInt        uiTempPartIdx;
    369368
     
    380379  if ( m_stLFCUParam.bLeftEdge )
    381380  {
    382     pcTempCU = pcCU->getPULeft( uiTempPartIdx, uiAbsZorderIdx, !pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), !m_bLFCrossTileBoundary);
     381    const TComDataCU* pcTempCU = pcCU->getPULeft( uiTempPartIdx, uiAbsZorderIdx, !pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), !m_bLFCrossTileBoundary);
    383382
    384383    if ( pcTempCU != NULL )
     
    402401  if ( m_stLFCUParam.bTopEdge )
    403402  {
    404     pcTempCU = pcCU->getPUAbove( uiTempPartIdx, uiAbsZorderIdx, !pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), false, !m_bLFCrossTileBoundary);
     403    const TComDataCU* pcTempCU = pcCU->getPUAbove( uiTempPartIdx, uiAbsZorderIdx, !pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), false, !m_bLFCrossTileBoundary);
    405404
    406405    if ( pcTempCU != NULL )
     
    425424
    426425  UInt uiPartP;
    427   TComDataCU* pcCUP;
     426  const TComDataCU* pcCUP;
    428427  UInt uiBs = 0;
    429428
     
    459458      {
    460459        Int iRefIdx;
    461         TComPic *piRefP0, *piRefP1, *piRefQ0, *piRefQ1;
    462460        iRefIdx = pcCUP->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartP);
    463         piRefP0 = (iRefIdx < 0) ? NULL : pcCUP->getSlice()->getRefPic(REF_PIC_LIST_0, iRefIdx);
     461        const TComPic *piRefP0 = (iRefIdx < 0) ? NULL : pcCUP->getSlice()->getRefPic(REF_PIC_LIST_0, iRefIdx);
    464462        iRefIdx = pcCUP->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartP);
    465         piRefP1 = (iRefIdx < 0) ? NULL : pcCUP->getSlice()->getRefPic(REF_PIC_LIST_1, iRefIdx);
     463        const TComPic *piRefP1 = (iRefIdx < 0) ? NULL : pcCUP->getSlice()->getRefPic(REF_PIC_LIST_1, iRefIdx);
    466464        iRefIdx = pcCUQ->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartQ);
    467         piRefQ0 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx);
     465        const TComPic *piRefQ0 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx);
    468466        iRefIdx = pcCUQ->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartQ);
    469         piRefQ1 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx);
     467        const TComPic *piRefQ1 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx);
    470468
    471469        TComMv pcMvP0 = pcCUP->getCUMvField(REF_PIC_LIST_0)->getMv(uiPartP);
     
    530528      {
    531529        Int iRefIdx;
    532         TComPic *piRefP0, *piRefQ0;
    533530        iRefIdx = pcCUP->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartP);
    534         piRefP0 = (iRefIdx < 0) ? NULL : pcCUP->getSlice()->getRefPic(REF_PIC_LIST_0, iRefIdx);
     531        const TComPic *piRefP0 = (iRefIdx < 0) ? NULL : pcCUP->getSlice()->getRefPic(REF_PIC_LIST_0, iRefIdx);
    535532        iRefIdx = pcCUQ->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartQ);
    536         piRefQ0 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx);
     533        const TComPic *piRefQ0 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx);
    537534        TComMv pcMvP0 = pcCUP->getCUMvField(REF_PIC_LIST_0)->getMv(uiPartP);
    538535        TComMv pcMvQ0 = pcCUQ->getCUMvField(REF_PIC_LIST_0)->getMv(uiPartQ);
     
    583580  UInt  uiPartPIdx = 0;
    584581  UInt  uiPartQIdx = 0;
    585   TComDataCU* pcCUP = pcCU;
     582  const TComDataCU* pcCUP = pcCU;
    586583  TComDataCU* pcCUQ = pcCU;
    587584  Int  betaOffsetDiv2 = pcCUQ->getSlice()->getDeblockingFilterBetaOffsetDiv2();
     
    758755      UInt  uiPartQIdx = uiBsAbsIdx;
    759756      // Derive neighboring PU index
    760       TComDataCU* pcCUP;
     757      const TComDataCU* pcCUP;
    761758      UInt  uiPartPIdx;
    762759
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComMotionInfo.cpp

    r1321 r1360  
    6666  m_pcMv     = new TComMv[ uiNumPartition ];
    6767  m_pcMvd    = new TComMv[ uiNumPartition ];
    68   m_piRefIdx = new Char [ uiNumPartition ];
     68  m_piRefIdx = new SChar [ uiNumPartition ];
    6969
    7070  m_uiNumPartition = uiNumPartition;
     
    321321Void TComCUMvField::setAllRefIdx ( Int iRefIdx, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx )
    322322{
    323   setAll(m_piRefIdx, static_cast<Char>(iRefIdx), eCUMode, iPartAddr, uiDepth, iPartIdx);
     323  setAll(m_piRefIdx, static_cast<SChar>(iRefIdx), eCUMode, iPartAddr, uiDepth, iPartIdx);
    324324}
    325325
     
    358358 * \param scale      Factor by which to subsample motion information
    359359 */
    360 Void TComCUMvField::compress(Char* pePredMode, Int scale)
     360Void TComCUMvField::compress(SChar* pePredMode, Int scale)
    361361{
    362362  Int N = scale * scale;
     
    381381
    382382#if NH_MV
    383 Void TComCUMvField::print(Char* pePredMode)
     383Void TComCUMvField::print(SChar* pePredMode)
    384384{
    385385  for ( Int uiPartIdx = 0; uiPartIdx < m_uiNumPartition; uiPartIdx += 1 )
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComMotionInfo.h

    r1321 r1360  
    5757typedef struct _AMVPInfo
    5858{
    59   TComMv m_acMvCand[ AMVP_MAX_NUM_CANDS_MEM ];  ///< array of motion vector predictor candidates
     59  TComMv m_acMvCand[ AMVP_MAX_NUM_CANDS ];  ///< array of motion vector predictor candidates
    6060  Int    iN;                                ///< number of motion vector predictor candidates
    6161} AMVPInfo;
     
    122122  TComMv*   m_pcMv;
    123123  TComMv*   m_pcMvd;
    124   Char*     m_piRefIdx;
     124  SChar*    m_piRefIdx;
    125125  UInt      m_uiNumPartition;
    126126  AMVPInfo  m_cAMVPInfo;
     
    188188  }
    189189 
    190   Void compress(Char* pePredMode, Int scale);
     190  Void compress(SChar* pePredMode, Int scale);
    191191#if NH_MV
    192   Void print   (Char* pePredMode);
     192  Void print   (SChar* pePredMode);
    193193#endif
    194194};
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComMv.h

    r1313 r1360  
    145145  }
    146146
     147#if NH_3D || !ME_ENABLE_ROUNDING_OF_MVS
    147148  const TComMv& operator>>= (const Int i)
    148149  {
     
    151152    return  *this;
    152153  }
     154#endif
     155
     156#if ME_ENABLE_ROUNDING_OF_MVS
     157  //! shift right with rounding
     158  Void divideByPowerOf2 (const Int i)
     159  {
     160    Int offset = (i == 0) ? 0 : 1 << (i - 1);
     161    m_iHor += offset;
     162    m_iVer += offset;
     163
     164    m_iHor >>= i;
     165    m_iVer >>= i;
     166  }
     167#endif
    153168
    154169  const TComMv& operator<<= (const Int i)
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComPattern.cpp

    r1313 r1360  
    6666
    6767/// constrained intra prediction
    68 Bool  isAboveLeftAvailable  ( TComDataCU* pcCU, UInt uiPartIdxLT );
    69 Int   isAboveAvailable      ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
    70 Int   isLeftAvailable       ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
    71 Int   isAboveRightAvailable ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
    72 Int   isBelowLeftAvailable  ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
     68Bool  isAboveLeftAvailable  ( const TComDataCU* pcCU, UInt uiPartIdxLT );
     69Int   isAboveAvailable      ( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
     70Int   isLeftAvailable       ( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
     71Int   isAboveRightAvailable ( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
     72Int   isBelowLeftAvailable  ( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
    7373
    7474
     
    566566}
    567567
    568 Bool isAboveLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT )
     568Bool isAboveLeftAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT )
    569569{
    570570  Bool bAboveLeftFlag;
    571571  UInt uiPartAboveLeft;
    572   TComDataCU* pcCUAboveLeft = pcCU->getPUAboveLeft( uiPartAboveLeft, uiPartIdxLT );
     572  const TComDataCU* pcCUAboveLeft = pcCU->getPUAboveLeft( uiPartAboveLeft, uiPartIdxLT );
    573573  if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
    574574  {
     
    582582}
    583583
    584 Int isAboveAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
     584Int isAboveAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
    585585{
    586586  const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
     
    593593  {
    594594    UInt uiPartAbove;
    595     TComDataCU* pcCUAbove = pcCU->getPUAbove( uiPartAbove, g_auiRasterToZscan[uiRasterPart] );
     595    const TComDataCU* pcCUAbove = pcCU->getPUAbove( uiPartAbove, g_auiRasterToZscan[uiRasterPart] );
    596596    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
    597597    {
     
    623623}
    624624
    625 Int isLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
     625Int isLeftAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
    626626{
    627627  const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
     
    634634  {
    635635    UInt uiPartLeft;
    636     TComDataCU* pcCULeft = pcCU->getPULeft( uiPartLeft, g_auiRasterToZscan[uiRasterPart] );
     636    const TComDataCU* pcCULeft = pcCU->getPULeft( uiPartLeft, g_auiRasterToZscan[uiRasterPart] );
    637637    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
    638638    {
     
    665665}
    666666
    667 Int isAboveRightAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
     667Int isAboveRightAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
    668668{
    669669  const UInt uiNumUnitsInPU = g_auiZscanToRaster[uiPartIdxRT] - g_auiZscanToRaster[uiPartIdxLT] + 1;
     
    674674  {
    675675    UInt uiPartAboveRight;
    676     TComDataCU* pcCUAboveRight = pcCU->getPUAboveRight( uiPartAboveRight, uiPartIdxRT, uiOffset );
     676    const TComDataCU* pcCUAboveRight = pcCU->getPUAboveRight( uiPartAboveRight, uiPartIdxRT, uiOffset );
    677677    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
    678678    {
     
    705705}
    706706
    707 Int isBelowLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
     707Int isBelowLeftAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
    708708{
    709709  const UInt uiNumUnitsInPU = (g_auiZscanToRaster[uiPartIdxLB] - g_auiZscanToRaster[uiPartIdxLT]) / pcCU->getPic()->getNumPartInCtuWidth() + 1;
     
    714714  {
    715715    UInt uiPartBelowLeft;
    716     TComDataCU* pcCUBelowLeft = pcCU->getPUBelowLeft( uiPartBelowLeft, uiPartIdxLB, uiOffset );
     716    const TComDataCU* pcCUBelowLeft = pcCU->getPUBelowLeft( uiPartBelowLeft, uiPartIdxLB, uiOffset );
    717717    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
    718718    {
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComPattern.h

    r1313 r1360  
    6969    return  m_piROIOrigin;
    7070  }
     71  __inline const Pel*  getROIOrigin() const
     72  {
     73    return  m_piROIOrigin;
     74  }
    7175
    7276  /// set parameters from Pel buffer for accessing neighbouring pixels
     
    9397  // ROI & pattern information, (ROI = &pattern[AboveOffset][LeftOffset])
    9498  Pel*  getROIY()                 { return m_cPatternY.getROIOrigin();    }
    95   Int   getROIYWidth()            { return m_cPatternY.m_iROIWidth;       }
    96   Int   getROIYHeight()           { return m_cPatternY.m_iROIHeight;      }
    97   Int   getPatternLStride()       { return m_cPatternY.m_iPatternStride;  }
    98   Int   getBitDepthY()            { return m_cPatternY.m_bitDepth; }
     99  const Pel*  getROIY() const     { return m_cPatternY.getROIOrigin();    }
     100  Int   getROIYWidth() const      { return m_cPatternY.m_iROIWidth;       }
     101  Int   getROIYHeight() const     { return m_cPatternY.m_iROIHeight;      }
     102  Int   getPatternLStride() const { return m_cPatternY.m_iPatternStride;  }
     103  Int   getBitDepthY() const      { return m_cPatternY.m_bitDepth;        }
    99104
    100105#if NH_3D_IC
    101   Bool  getICFlag()               { return m_bICFlag; }
     106  Bool  getICFlag()               const { return m_bICFlag; }
    102107  Void  setICFlag( Bool bICFlag ) { m_bICFlag = bICFlag; }
    103108#endif
    104109#if NH_3D_SDC_INTER
    105   Bool  getSDCMRSADFlag()         { return m_bSDCMRSADFlag; }
     110  Bool  getSDCMRSADFlag()         const { return m_bSDCMRSADFlag; }
    106111  Void  setSDCMRSADFlag( Bool bSDCMRSADFlag )    { m_bSDCMRSADFlag = bSDCMRSADFlag; }
    107112#endif
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComPic.h

    r1321 r1360  
    189189
    190190  TComPicSym*   getPicSym()           { return  &m_picSym;    }
     191  const TComPicSym* getPicSym() const { return  &m_picSym;    }
    191192  TComSlice*    getSlice(Int i)       { return  m_picSym.getSlice(i);  }
    192193  Int           getPOC() const        { return  m_picSym.getSlice(m_uiCurrSliceIdx)->getPOC();  }
     
    247248#if NH_MV
    248249   Void          setLayerId            ( Int layerId )    { m_layerId      = layerId; }
    249    Int           getLayerId            ()                 { return m_layerId;    }
     250   Int           getLayerId            () const           { return m_layerId;    }
    250251   
    251252   Void          setViewId             ( Int viewId )     { m_viewId = viewId;   }
    252    Int           getViewId             ()                 { return m_viewId;     }
     253   Int           getViewId             () const           { return m_viewId;     }
    253254
    254255   Void          setPicOutputFlag(Bool b)                 { m_bPicOutputFlag = b;      }
    255    Bool          getPicOutputFlag()                       { return m_bPicOutputFlag ;  }
     256   Bool          getPicOutputFlag() const                 { return m_bPicOutputFlag ;  }
    256257
    257258   Bool          getPocResetPeriodId();
     
    312313#if NH_3D
    313314   Void          setViewIndex          ( Int viewIndex )  { m_viewIndex = viewIndex;   }
    314    Int           getViewIndex          ()                 { return m_viewIndex;     }
     315   Int           getViewIndex          () const           { return m_viewIndex;     }
    315316
    316317   Void          setIsDepth            ( Bool isDepth )   { m_isDepth = isDepth; }
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComPicSym.cpp

    r1313 r1360  
    140140  clearSliceBuffer();
    141141
     142  if (m_pictureCtuArray)
     143  {
    142144  for (Int i = 0; i < m_numCtusInFrame; i++)
    143145  {
     146      if (m_pictureCtuArray[i])
     147      {
    144148    m_pictureCtuArray[i]->destroy();
    145149    delete m_pictureCtuArray[i];
    146150    m_pictureCtuArray[i] = NULL;
    147151  }
     152    }
    148153  delete [] m_pictureCtuArray;
    149154  m_pictureCtuArray = NULL;
     155  }
    150156
    151157  delete [] m_ctuTsToRsAddrMap;
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComPicYuv.cpp

    r1313 r1360  
    7979
    8080
    81 Void TComPicYuv::create ( const Int iPicWidth,                ///< picture width
    82                           const Int iPicHeight,               ///< picture height
     81Void TComPicYuv::createWithoutCUInfo ( const Int picWidth,                 ///< picture width
     82                                       const Int picHeight,                ///< picture height
     83                                       const ChromaFormat chromaFormatIDC, ///< chroma format
     84                                       const Bool bUseMargin,              ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image.
     85                                       const UInt maxCUWidth,              ///< used for margin only
     86                                       const UInt maxCUHeight)             ///< used for margin only
     87
     88{
     89  m_picWidth          = picWidth;
     90  m_picHeight         = picHeight;
     91
     92#if NH_3D_IV_MERGE
     93// Check if m_iBaseUnitWidth and m_iBaseUnitHeight need to be derived here
     94#endif
     95
     96  m_chromaFormatIDC   = chromaFormatIDC;
     97  m_marginX          = (bUseMargin?maxCUWidth:0) + 16;   // for 16-byte alignment
     98  m_marginY          = (bUseMargin?maxCUHeight:0) + 16;  // margin for 8-tap filter and infinite padding
     99  m_bIsBorderExtended = false;
     100
     101  // assign the picture arrays and set up the ptr to the top left of the original picture
     102  for(UInt comp=0; comp<getNumberValidComponents(); comp++)
     103  {
     104    const ComponentID ch=ComponentID(comp);
     105    m_apiPicBuf[comp] = (Pel*)xMalloc( Pel, getStride(ch) * getTotalHeight(ch));
     106    m_piPicOrg[comp]  = m_apiPicBuf[comp] + (m_marginY >> getComponentScaleY(ch)) * getStride(ch) + (m_marginX >> getComponentScaleX(ch));
     107  }
     108  // initialize pointers for unused components to NULL
     109  for(UInt comp=getNumberValidComponents();comp<MAX_NUM_COMPONENT; comp++)
     110    {
     111    }
     112
     113  for(Int chan=0; chan<MAX_NUM_CHANNEL_TYPE; chan++)
     114    {
     115    m_ctuOffsetInBuffer[chan]   = NULL;
     116    m_subCuOffsetInBuffer[chan] = NULL;
     117    }
     118  }
     119
     120
     121
     122Void TComPicYuv::create ( const Int picWidth,                 ///< picture width
     123                          const Int picHeight,                ///< picture height
    83124                          const ChromaFormat chromaFormatIDC, ///< chroma format
    84                           const UInt uiMaxCUWidth,            ///< used for generating offsets to CUs. Can use iPicWidth if no offsets are required
    85                           const UInt uiMaxCUHeight,           ///< used for generating offsets to CUs. Can use iPicHeight if no offsets are required
    86                           const UInt uiMaxCUDepth,            ///< used for generating offsets to CUs. Can use 0 if no offsets are required
     125                          const UInt maxCUWidth,              ///< used for generating offsets to CUs.
     126                          const UInt maxCUHeight,             ///< used for generating offsets to CUs.
     127                          const UInt maxCUDepth,              ///< used for generating offsets to CUs.
    87128                          const Bool bUseMargin)              ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image.
    88129
    89130{
    90   m_iPicWidth         = iPicWidth;
    91   m_iPicHeight        = iPicHeight;
     131  createWithoutCUInfo(picWidth, picHeight, chromaFormatIDC, bUseMargin, maxCUWidth, maxCUHeight);
    92132
    93133#if NH_3D_IV_MERGE
    94   m_iCuWidth        = uiMaxCUWidth;
    95   m_iCuHeight       = uiMaxCUHeight;
    96 
    97   m_iNumCuInWidth   = m_iPicWidth / m_iCuWidth;
    98   m_iNumCuInWidth  += ( m_iPicWidth % m_iCuWidth ) ? 1 : 0;
    99 
    100   m_iBaseUnitWidth  = uiMaxCUWidth  >> uiMaxCUDepth;
    101   m_iBaseUnitHeight = uiMaxCUHeight >> uiMaxCUDepth;
    102 #endif
    103 
    104   m_chromaFormatIDC   = chromaFormatIDC;
    105   m_iMarginX          = (bUseMargin?uiMaxCUWidth:0) + 16;   // for 16-byte alignment
    106   m_iMarginY          = (bUseMargin?uiMaxCUHeight:0) + 16;  // margin for 8-tap filter and infinite padding
    107   m_bIsBorderExtended = false;
    108 
    109   // assign the picture arrays and set up the ptr to the top left of the original picture
    110   {
    111     Int chan=0;
    112     for(; chan<getNumberValidComponents(); chan++)
    113     {
    114       const ComponentID ch=ComponentID(chan);
    115       m_apiPicBuf[chan] = (Pel*)xMalloc( Pel, getStride(ch)       * getTotalHeight(ch));
    116       m_piPicOrg[chan]  = m_apiPicBuf[chan] + (m_iMarginY >> getComponentScaleY(ch))   * getStride(ch)       + (m_iMarginX >> getComponentScaleX(ch));
    117     }
    118     for(;chan<MAX_NUM_COMPONENT; chan++)
    119     {
    120       m_apiPicBuf[chan] = NULL;
    121       m_piPicOrg[chan]  = NULL;
    122     }
    123   }
    124 
    125 
    126   const Int numCuInWidth  = m_iPicWidth  / uiMaxCUWidth  + (m_iPicWidth  % uiMaxCUWidth  != 0);
    127   const Int numCuInHeight = m_iPicHeight / uiMaxCUHeight + (m_iPicHeight % uiMaxCUHeight != 0);
    128   for(Int chan=0; chan<2; chan++)
    129   {
    130     const ComponentID ch=ComponentID(chan);
    131     const Int ctuHeight=uiMaxCUHeight>>getComponentScaleY(ch);
    132     const Int ctuWidth=uiMaxCUWidth>>getComponentScaleX(ch);
     134  m_iBaseUnitWidth  = maxCUWidth  >> maxCUDepth;
     135  m_iBaseUnitHeight = maxCUHeight >> maxCUDepth;
     136#endif
     137
     138
     139  const Int numCuInWidth  = m_picWidth  / maxCUWidth  + (m_picWidth  % maxCUWidth  != 0);
     140  const Int numCuInHeight = m_picHeight / maxCUHeight + (m_picHeight % maxCUHeight != 0);
     141  for(Int chan=0; chan<MAX_NUM_CHANNEL_TYPE; chan++)
     142  {
     143    const ChannelType ch= ChannelType(chan);
     144    const Int ctuHeight = maxCUHeight>>getChannelTypeScaleY(ch);
     145    const Int ctuWidth  = maxCUWidth>>getChannelTypeScaleX(ch);
    133146    const Int stride = getStride(ch);
    134147
     
    143156    }
    144157
    145     m_subCuOffsetInBuffer[chan] = new Int[(size_t)1 << (2 * uiMaxCUDepth)];
    146 
    147     const Int numSubBlockPartitions=(1<<uiMaxCUDepth);
    148     const Int minSubBlockHeight    =(ctuHeight >> uiMaxCUDepth);
    149     const Int minSubBlockWidth     =(ctuWidth  >> uiMaxCUDepth);
     158    m_subCuOffsetInBuffer[chan] = new Int[(size_t)1 << (2 * maxCUDepth)];
     159
     160    const Int numSubBlockPartitions=(1<<maxCUDepth);
     161    const Int minSubBlockHeight    =(ctuHeight >> maxCUDepth);
     162    const Int minSubBlockWidth     =(ctuWidth  >> maxCUDepth);
    150163
    151164    for (Int buRow = 0; buRow < numSubBlockPartitions; buRow++)
     
    153166      for (Int buCol = 0; buCol < numSubBlockPartitions; buCol++)
    154167      {
    155         m_subCuOffsetInBuffer[chan][(buRow << uiMaxCUDepth) + buCol] = stride  * buRow * minSubBlockHeight + buCol * minSubBlockWidth;
    156       }
    157     }
    158   }
    159   return;
     168        m_subCuOffsetInBuffer[chan][(buRow << maxCUDepth) + buCol] = stride  * buRow * minSubBlockHeight + buCol * minSubBlockWidth;
     169      }
     170    }
     171  }
    160172}
    161173
     
    164176Void TComPicYuv::destroy()
    165177{
    166   for(Int chan=0; chan<MAX_NUM_COMPONENT; chan++)
    167   {
    168     m_piPicOrg[chan] = NULL;
    169 
    170     if( m_apiPicBuf[chan] )
    171     {
    172       xFree( m_apiPicBuf[chan] );
    173       m_apiPicBuf[chan] = NULL;
     178  for(Int comp=0; comp<MAX_NUM_COMPONENT; comp++)
     179  {
     180    m_piPicOrg[comp] = NULL;
     181
     182    if( m_apiPicBuf[comp] )
     183    {
     184      xFree( m_apiPicBuf[comp] );
     185      m_apiPicBuf[comp] = NULL;
    174186    }
    175187  }
     
    194206Void  TComPicYuv::copyToPic (TComPicYuv*  pcPicYuvDst) const
    195207{
    196   assert( m_iPicWidth  == pcPicYuvDst->getWidth(COMPONENT_Y)  );
    197   assert( m_iPicHeight == pcPicYuvDst->getHeight(COMPONENT_Y) );
    198208  assert( m_chromaFormatIDC == pcPicYuvDst->getChromaFormat() );
    199209
    200   for(Int chan=0; chan<getNumberValidComponents(); chan++)
    201   {
    202     const ComponentID ch=ComponentID(chan);
    203     ::memcpy ( pcPicYuvDst->getBuf(ch), m_apiPicBuf[ch], sizeof (Pel) * getStride(ch) * getTotalHeight(ch));
    204   }
    205   return;
     210  for(Int comp=0; comp<getNumberValidComponents(); comp++)
     211  {
     212    const ComponentID compId=ComponentID(comp);
     213    const Int width     = getWidth(compId);
     214    const Int height    = getHeight(compId);
     215    const Int strideSrc = getStride(compId);
     216    assert(pcPicYuvDst->getWidth(compId) == width);
     217    assert(pcPicYuvDst->getHeight(compId) == height);
     218    if (strideSrc==pcPicYuvDst->getStride(compId))
     219  {
     220      ::memcpy ( pcPicYuvDst->getBuf(compId), getBuf(compId), sizeof(Pel)*strideSrc*getTotalHeight(compId));
     221    }
     222    else
     223    {
     224      const Pel *pSrc       = getAddr(compId);
     225            Pel *pDest      = pcPicYuvDst->getAddr(compId);
     226      const UInt strideDest = pcPicYuvDst->getStride(compId);
     227
     228      for(Int y=0; y<height; y++, pSrc+=strideSrc, pDest+=strideDest)
     229      {
     230        ::memcpy(pDest, pSrc, width*sizeof(Pel));
     231      }
     232    }
     233  }
    206234}
    207235
     
    214242  }
    215243
    216   for(Int chan=0; chan<getNumberValidComponents(); chan++)
    217   {
    218     const ComponentID ch=ComponentID(chan);
    219     Pel *piTxt=getAddr(ch); // piTxt = point to (0,0) of image within bigger picture.
    220     const Int iStride=getStride(ch);
    221     const Int iWidth=getWidth(ch);
    222     const Int iHeight=getHeight(ch);
    223     const Int iMarginX=getMarginX(ch);
    224     const Int iMarginY=getMarginY(ch);
     244  for(Int comp=0; comp<getNumberValidComponents(); comp++)
     245  {
     246    const ComponentID compId=ComponentID(comp);
     247    Pel *piTxt=getAddr(compId); // piTxt = point to (0,0) of image within bigger picture.
     248    const Int stride=getStride(compId);
     249    const Int width=getWidth(compId);
     250    const Int height=getHeight(compId);
     251    const Int marginX=getMarginX(compId);
     252    const Int marginY=getMarginY(compId);
    225253
    226254    Pel*  pi = piTxt;
    227255    // do left and right margins
    228     for (Int y = 0; y < iHeight; y++)
    229     {
    230       for (Int x = 0; x < iMarginX; x++ )
    231       {
    232         pi[ -iMarginX + x ] = pi[0];
    233         pi[    iWidth + x ] = pi[iWidth-1];
    234       }
    235       pi += iStride;
     256    for (Int y = 0; y < height; y++)
     257    {
     258      for (Int x = 0; x < marginX; x++ )
     259      {
     260        pi[ -marginX + x ] = pi[0];
     261        pi[    width + x ] = pi[width-1];
     262      }
     263      pi += stride;
    236264    }
    237265
    238266    // pi is now the (0,height) (bottom left of image within bigger picture
    239     pi -= (iStride + iMarginX);
     267    pi -= (stride + marginX);
    240268    // pi is now the (-marginX, height-1)
    241     for (Int y = 0; y < iMarginY; y++ )
    242     {
    243       ::memcpy( pi + (y+1)*iStride, pi, sizeof(Pel)*(iWidth + (iMarginX<<1)) );
     269    for (Int y = 0; y < marginY; y++ )
     270    {
     271      ::memcpy( pi + (y+1)*stride, pi, sizeof(Pel)*(width + (marginX<<1)) );
    244272    }
    245273
    246274    // pi is still (-marginX, height-1)
    247     pi -= ((iHeight-1) * iStride);
     275    pi -= ((height-1) * stride);
    248276    // pi is now (-marginX, 0)
    249     for (Int y = 0; y < iMarginY; y++ )
    250     {
    251       ::memcpy( pi - (y+1)*iStride, pi, sizeof(Pel)*(iWidth + (iMarginX<<1)) );
     277    for (Int y = 0; y < marginY; y++ )
     278    {
     279      ::memcpy( pi - (y+1)*stride, pi, sizeof(Pel)*(width + (marginX<<1)) );
    252280    }
    253281  }
     
    259287
    260288// NOTE: This function is never called, but may be useful for developers.
    261 Void TComPicYuv::dump (const Char* pFileName, const BitDepths &bitDepths, Bool bAdd) const
    262 {
    263   FILE* pFile;
    264   if (!bAdd)
    265   {
    266     pFile = fopen (pFileName, "wb");
    267   }
    268   else
    269   {
    270     pFile = fopen (pFileName, "ab");
    271   }
    272 
    273 
    274   for(Int chan = 0; chan < getNumberValidComponents(); chan++)
    275   {
    276     const ComponentID  ch     = ComponentID(chan);
    277     const Int          shift  = bitDepths.recon[toChannelType(ch)] - 8;
    278     const Int          offset = (shift>0)?(1<<(shift-1)):0;
    279     const Pel         *pi     = getAddr(ch);
    280     const Int          stride = getStride(ch);
    281     const Int          height = getHeight(ch);
    282     const Int          width  = getWidth(ch);
    283 
     289Void TComPicYuv::dump (const std::string &fileName, const BitDepths &bitDepths, const Bool bAppend, const Bool bForceTo8Bit) const
     290{
     291  FILE *pFile = fopen (fileName.c_str(), bAppend?"ab":"wb");
     292
     293  Bool is16bit=false;
     294  for(Int comp = 0; comp < getNumberValidComponents() && !bForceTo8Bit; comp++)
     295  {
     296    if (bitDepths.recon[toChannelType(ComponentID(comp))]>8)
     297  {
     298      is16bit=true;
     299    }
     300  }
     301
     302  for(Int comp = 0; comp < getNumberValidComponents(); comp++)
     303  {
     304    const ComponentID  compId = ComponentID(comp);
     305    const Pel         *pi     = getAddr(compId);
     306    const Int          stride = getStride(compId);
     307    const Int          height = getHeight(compId);
     308    const Int          width  = getWidth(compId);
     309
     310    if (is16bit)
     311    {
    284312    for (Int y = 0; y < height; y++ )
    285313    {
    286314      for (Int x = 0; x < width; x++ )
    287315      {
    288         UChar uc = (UChar)Clip3<Pel>(0, 255, (pi[x]+offset)>>shift);
     316          UChar uc = (UChar)((pi[x]>>0) & 0xff);
    289317        fwrite( &uc, sizeof(UChar), 1, pFile );
     318          uc = (UChar)((pi[x]>>8) & 0xff);
     319          fwrite( &uc, sizeof(UChar), 1, pFile );
    290320      }
    291321      pi += stride;
     322    }
     323  }
     324    else
     325    {
     326      const Int shift  = bitDepths.recon[toChannelType(compId)] - 8;
     327      const Int offset = (shift>0)?(1<<(shift-1)):0;
     328      for (Int y = 0; y < height; y++ )
     329      {
     330        for (Int x = 0; x < width; x++ )
     331        {
     332          UChar uc = (UChar)Clip3<Pel>(0, 255, (pi[x]+offset)>>shift);
     333          fwrite( &uc, sizeof(UChar), 1, pFile );
     334        }
     335        pi += stride;
     336      }
    292337    }
    293338  }
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComPicYuv.h

    r1321 r1360  
    6969  // ------------------------------------------------------------------------------------------------
    7070
    71   Int   m_iPicWidth;                                ///< Width of picture in pixels
    72   Int   m_iPicHeight;                               ///< Height of picture in pixels
     71  Int   m_picWidth;                                 ///< Width of picture in pixels
     72  Int   m_picHeight;                                ///< Height of picture in pixels
    7373  ChromaFormat m_chromaFormatIDC;                   ///< Chroma Format
    7474
     
    7676  Int*  m_subCuOffsetInBuffer[MAX_NUM_CHANNEL_TYPE];///< Gives an offset in the buffer for a given sub-CU (and channel), relative to start of CTU
    7777
    78   Int   m_iMarginX;                                 ///< margin of Luma channel (chroma's may be smaller, depending on ratio)
    79   Int   m_iMarginY;                                 ///< margin of Luma channel (chroma's may be smaller, depending on ratio)
     78  Int   m_marginX;                                  ///< margin of Luma channel (chroma's may be smaller, depending on ratio)
     79  Int   m_marginY;                                  ///< margin of Luma channel (chroma's may be smaller, depending on ratio)
    8080
    8181  Bool  m_bIsBorderExtended;
     
    100100  // ------------------------------------------------------------------------------------------------
    101101
    102   Void          create            (const Int iPicWidth,
    103                                    const Int iPicHeight,
     102  Void          create            (const Int picWidth,
     103                                   const Int picHeight,
    104104                                   const ChromaFormat chromaFormatIDC,
    105                                    const UInt uiMaxCUWidth,  ///< used for generating offsets to CUs. Can use iPicWidth if no offsets are required
    106                                    const UInt uiMaxCUHeight, ///< used for generating offsets to CUs. Can use iPicHeight if no offsets are required
    107                                    const UInt uiMaxCUDepth,  ///< used for generating offsets to CUs. Can use 0 if no offsets are required
     105                                   const UInt maxCUWidth,  ///< used for generating offsets to CUs.
     106                                   const UInt maxCUHeight, ///< used for generating offsets to CUs.
     107                                   const UInt maxCUDepth,  ///< used for generating offsets to CUs.
    108108                                   const Bool bUseMargin);   ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image.
     109
     110  Void          createWithoutCUInfo(const Int picWidth,
     111                                    const Int picHeight,
     112                                    const ChromaFormat chromaFormatIDC,
     113                                    const Bool bUseMargin=false, ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image.
     114                                    const UInt maxCUWidth=0,   ///< used for margin only
     115                                    const UInt maxCUHeight=0); ///< used for margin only
    109116
    110117  Void          destroy           ();
     
    118125  // ------------------------------------------------------------------------------------------------
    119126
    120   Int           getWidth          (const ComponentID id) const { return  m_iPicWidth >> getComponentScaleX(id);   }
    121   Int           getHeight         (const ComponentID id) const { return  m_iPicHeight >> getComponentScaleY(id);  }
     127  Int           getWidth          (const ComponentID id) const { return  m_picWidth >> getComponentScaleX(id);   }
     128  Int           getHeight         (const ComponentID id) const { return  m_picHeight >> getComponentScaleY(id);  }
    122129  ChromaFormat  getChromaFormat   ()                     const { return m_chromaFormatIDC; }
    123130  UInt          getNumberValidComponents() const { return ::getNumberValidComponents(m_chromaFormatIDC); }
    124131
    125   Int           getStride         (const ComponentID id) const { return ((m_iPicWidth     ) + (m_iMarginX  <<1)) >> getComponentScaleX(id); }
    126   Int           getTotalHeight    (const ComponentID id) const { return ((m_iPicHeight    ) + (m_iMarginY  <<1)) >> getComponentScaleY(id); }
    127 
    128   Int           getMarginX        (const ComponentID id) const { return m_iMarginX >> getComponentScaleX(id);  }
    129   Int           getMarginY        (const ComponentID id) const { return m_iMarginY >> getComponentScaleY(id);  }
     132  Int           getStride         (const ComponentID id) const { return ((m_picWidth     ) + (m_marginX  <<1)) >> getComponentScaleX(id); }
     133private:
     134  Int           getStride         (const ChannelType id) const { return ((m_picWidth     ) + (m_marginX  <<1)) >> getChannelTypeScaleX(id); }
     135public:
     136  Int           getTotalHeight    (const ComponentID id) const { return ((m_picHeight    ) + (m_marginY  <<1)) >> getComponentScaleY(id); }
     137
     138  Int           getMarginX        (const ComponentID id) const { return m_marginX >> getComponentScaleX(id);  }
     139  Int           getMarginY        (const ComponentID id) const { return m_marginY >> getComponentScaleY(id);  }
    130140
    131141  // ------------------------------------------------------------------------------------------------
     
    135145  //  Access starting position of picture buffer with margin
    136146  Pel*          getBuf            (const ComponentID ch)       { return  m_apiPicBuf[ch];   }
     147  const Pel*    getBuf            (const ComponentID ch) const { return  m_apiPicBuf[ch];   }
    137148
    138149  //  Access starting position of original picture
     
    151162  UInt          getComponentScaleY(const ComponentID id) const { return ::getComponentScaleY(id, m_chromaFormatIDC); }
    152163
     164  UInt          getChannelTypeScaleX(const ChannelType id) const { return ::getChannelTypeScaleX(id, m_chromaFormatIDC); }
     165  UInt          getChannelTypeScaleY(const ChannelType id) const { return ::getChannelTypeScaleY(id, m_chromaFormatIDC); }
     166
    153167  // ------------------------------------------------------------------------------------------------
    154168  //  Miscellaneous
     
    162176
    163177  //  Dump picture
    164   Void          dump              (const Char* pFileName, const BitDepths &bitDepths, Bool bAdd = false) const ;
     178  Void          dump              (const std::string &fileName, const BitDepths &bitDepths, const Bool bAppend=false, const Bool bForceTo8Bit=false) const ;
    165179
    166180  // Set border extension flag
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComPicYuvMD5.cpp

    r1313 r1360  
    209209std::string hashToString(const TComPictureHash &digest, Int numChar)
    210210{
    211   static const Char* hex = "0123456789abcdef";
     211  static const TChar* hex = "0123456789abcdef";
    212212  std::string result;
    213213
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComPrediction.cpp

    r1321 r1360  
    11391139  Int         iHeight;
    11401140  UInt        uiPartAddr;
     1141  const TComSlice *pSlice    = pcCU->getSlice();
     1142  const SliceType  sliceType = pSlice->getSliceType();
     1143  const TComPPS   &pps       = *(pSlice->getPPS());
    11411144
    11421145  if ( iPartIdx >= 0 )
     
    11471150    {
    11481151#endif
    1149       if ( eRefPicList != REF_PIC_LIST_X )
    1150       {
    1151         if( pcCU->getSlice()->getPPS()->getUseWP())
    1152         {
    1153           xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
    1154         }
    1155         else
    1156         {
    1157           xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1158         }
    1159         if ( pcCU->getSlice()->getPPS()->getUseWP() )
    1160         {
    1161           xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1162         }
     1152     if ( eRefPicList != REF_PIC_LIST_X )
     1153     {
     1154      if( (sliceType == P_SLICE && pps.getUseWP()) || (sliceType == B_SLICE && pps.getWPBiPred()))
     1155      {
     1156        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
     1157        xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    11631158      }
    11641159      else
    11651160      {
     1161        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
     1162      }
     1163     }
     1164     else
     1165     {
    11661166#if NH_3D_SPIVMP
    11671167        if ( pcCU->getSPIVMPFlag(uiPartAddr)!=0) 
     
    12351235    if ( eRefPicList != REF_PIC_LIST_X )
    12361236    {
    1237       if( pcCU->getSlice()->getPPS()->getUseWP())
     1237      if( (sliceType == P_SLICE && pps.getUseWP()) || (sliceType == B_SLICE && pps.getWPBiPred()))
    12381238      {
    12391239        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
     1240        xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    12401241      }
    12411242      else
    12421243      {
    12431244        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1244       }
    1245       if ( pcCU->getSlice()->getPPS()->getUseWP() )
    1246       {
    1247         xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    12481245      }
    12491246    }
     
    14491446      Int iCurrPOC    = pcCU->getSlice()->getPOC();
    14501447      Int iColRefPOC  = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx );
    1451     Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, arpRefIdx );
    1452       Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC);
     1448      Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, arpRefIdx );
     1449      Int iScale      = pcCU->xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC);
    14531450      if ( iScale != 4096 )
    14541451      {
    14551452        cMv = cMv.scaleMv( iScale );
    14561453      }
    1457     iRefIdx = arpRefIdx;
    1458   }
     1454      iRefIdx = arpRefIdx;
     1455    }
    14591456
    14601457  pcCU->clipMv(cMv);
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComRdCost.cpp

    r1321 r1360  
    6464// Calculate RD functions
    6565#if NH_3D_VSO
    66 Double TComRdCost::calcRdCost( UInt uiBits, Dist uiDistortion, Bool bFlag, DFunc eDFunc )
     66Double TComRdCost::calcRdCost( Double numBits, Dist intDistortion, DFunc eDFunc )
     67{
     68  Double distortion = (Double) intDistortion;
    6769#else
    68 Double TComRdCost::calcRdCost( UInt uiBits, Distortion uiDistortion, Bool bFlag, DFunc eDFunc )
    69 #endif
    70 {
    71   Double dRdCost = 0.0;
    72   Double dLambda = 0.0;
     70Double TComRdCost::calcRdCost( Double numBits, Double distortion, DFunc eDFunc )
     71{
     72#endif
     73 
     74  Double lambda = 1.0;
    7375
    7476  switch ( eDFunc )
     
    7880      break;
    7981    case DF_SAD:
    80 #if RExt__HIGH_BIT_DEPTH_SUPPORT
     82      lambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
     83      break;
     84    case DF_DEFAULT:
     85      lambda = m_dLambda;
     86      break;
     87    case DF_SSE_FRAME:
     88      lambda = m_dFrameLambda;
     89      break;
     90    default:
     91      assert (0);
     92      break;
     93  }
     94
     95#if NH_MV
     96  // D_PRINT_INDENT( g_traceRDCost,  "Dist: " + n2s(distortion) + " Bits: " + n2s(numBits) + " RD Cost: " + n2s(dRdCost));
     97   D_PRINT_INDENT( g_traceRDCost,  "Dist: " + n2s(distortion) + " Bits: " + n2s(numBits) );
     98#endif
     99
     100  if (eDFunc == DF_SAD)
     101  {
     102    if (m_costMode != COST_STANDARD_LOSSY)
     103    {
     104      return ((distortion * 65536.0) / lambda) + numBits; // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     105    }
     106    else
     107    {
     108      return distortion + (((numBits * lambda) ) / 65536.0);
     109    }
     110  }
     111  else
     112  {
     113    if (m_costMode != COST_STANDARD_LOSSY)
     114    {
     115      return (distortion / lambda) + numBits; // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     116    }
     117    else
     118    {
     119      return distortion + (numBits * lambda);
     120    }
     121  }
     122}
     123
     124#if NH_3D_VSO
     125Double TComRdCost::calcRdCost64( UInt64 uiBits, Dist64 uiDistortion, Bool bFlag, DFunc eDFunc )
     126#else
     127Double TComRdCost::calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag, DFunc eDFunc )
     128#endif
     129{
     130  Double dRdCost = 0.0;
     131  Double dLambda = 0.0;
     132
     133  switch ( eDFunc )
     134  {
     135    case DF_SSE:
     136      assert(0);
     137      break;
     138    case DF_SAD:
    81139      dLambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
    82 #else
    83       dLambda = (Double)m_uiLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
    84 #endif
    85140      break;
    86141    case DF_DEFAULT:
     
    104159    else
    105160    {
    106       dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda));
     161      dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda));
    107162    }
    108163  }
     
    133188  }
    134189
    135 #if NH_MV
    136   D_PRINT_INDENT( g_traceRDCost,  "Dist: " + n2s(uiDistortion) + " Bits: " + n2s(uiBits) + " RD Cost: " + n2s(dRdCost));
    137 #endif
    138   return dRdCost;
    139 }
    140 
    141 #if NH_3D_VSO
    142 Double TComRdCost::calcRdCost64( UInt64 uiBits, Dist64 uiDistortion, Bool bFlag, DFunc eDFunc )
    143 #else
    144 Double TComRdCost::calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag, DFunc eDFunc )
    145 #endif
    146 {
    147   Double dRdCost = 0.0;
    148   Double dLambda = 0.0;
    149 
    150   switch ( eDFunc )
    151   {
    152     case DF_SSE:
    153       assert(0);
    154       break;
    155     case DF_SAD:
    156 #if RExt__HIGH_BIT_DEPTH_SUPPORT
    157       dLambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
    158 #else
    159       dLambda = (Double)m_uiLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
    160 #endif
    161       break;
    162     case DF_DEFAULT:
    163       dLambda =         m_dLambda;
    164       break;
    165     case DF_SSE_FRAME:
    166       dLambda =         m_dFrameLambda;
    167       break;
    168     default:
    169       assert (0);
    170       break;
    171   }
    172 
    173   if (bFlag) //NOTE: this "bFlag" is never true
    174   {
    175     // Intra8x8, Intra4x4 Block only...
    176     if (m_costMode != COST_STANDARD_LOSSY)
    177     {
    178       dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
    179     }
    180     else
    181     {
    182       dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda));
    183     }
    184   }
    185   else
    186   {
    187     if (eDFunc == DF_SAD)
    188     {
    189       if (m_costMode != COST_STANDARD_LOSSY)
    190       {
    191         dRdCost = ((Double(uiDistortion) * 65536) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
    192       }
    193       else
    194       {
    195         dRdCost = floor(Double(uiDistortion) + (floor((Double(uiBits) * dLambda) + 0.5) / 65536.0));
    196       }
    197     }
    198     else
    199     {
    200       if (m_costMode != COST_STANDARD_LOSSY)
    201       {
    202         dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
    203       }
    204       else
    205       {
    206         dRdCost = floor(Double(uiDistortion) + (Double(uiBits) * dLambda) + 0.5);
    207       }
    208     }
    209   }
    210 
    211190  return dRdCost;
    212191}
     
    216195  m_dLambda           = dLambda;
    217196  m_sqrtLambda        = sqrt(m_dLambda);
    218 #if RExt__HIGH_BIT_DEPTH_SUPPORT
    219197  m_dLambdaMotionSAD[0] = 65536.0 * m_sqrtLambda;
    220198  m_dLambdaMotionSSE[0] = 65536.0 * m_dLambda;
     
    226204  m_dLambdaMotionSAD[1] = 65536.0 * sqrt(dLambda);
    227205  m_dLambdaMotionSSE[1] = 65536.0 * dLambda;
    228 #else
    229   m_uiLambdaMotionSAD[0] = (UInt)floor(65536.0 * m_sqrtLambda);
    230   m_uiLambdaMotionSSE[0] = (UInt)floor(65536.0 * m_dLambda   );
    231 #if FULL_NBIT
    232   dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12) / 3.0));
    233 #else
    234   dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (bitDepths.recon[CHANNEL_TYPE_LUMA] - 8)) / 3.0));
    235 #endif
    236   m_uiLambdaMotionSAD[1] = (UInt)floor(65536.0 * sqrt(dLambda));
    237   m_uiLambdaMotionSSE[1] = (UInt)floor(65536.0 * dLambda   );
    238 #endif
    239206}
    240207
     
    298265  m_costMode                   = COST_STANDARD_LOSSY;
    299266
    300 #if RExt__HIGH_BIT_DEPTH_SUPPORT
    301   m_dCost                      = 0;
    302 #else
    303   m_uiCost                     = 0;
    304 #endif
     267  m_motionLambda               = 0;
    305268  m_iCostScale                 = 0;
    306269
     
    370333  // initialize
    371334  rcDistParam.iSubShift  = 0;
     335  rcDistParam.m_maximumDistortionForEarlyExit = std::numeric_limits<Distortion>::max();
    372336}
    373337
    374338// Setting the Distortion Parameter for Inter (ME)
    375 Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, DistParam& rcDistParam )
     339Void TComRdCost::setDistParam( const TComPattern* const pcPatternKey, const Pel* piRefY, Int iRefStride, DistParam& rcDistParam )
    376340{
    377341  // set Original & Curr Pointer / Stride
     
    386350  rcDistParam.iRows    = pcPatternKey->getROIYHeight();
    387351  rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
     352  rcDistParam.m_maximumDistortionForEarlyExit = std::numeric_limits<Distortion>::max();
    388353
    389354  if (rcDistParam.iCols == 12)
     
    411376
    412377// Setting the Distortion Parameter for Inter (subpel ME with step)
    413 Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME )
     378Void TComRdCost::setDistParam( const TComPattern* const pcPatternKey, const Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME )
    414379{
    415380  // set Original & Curr Pointer / Stride
     
    427392  rcDistParam.iRows    = pcPatternKey->getROIYHeight();
    428393
     394  rcDistParam.m_maximumDistortionForEarlyExit = std::numeric_limits<Distortion>::max();
     395
    429396  // set distortion function
    430397  if ( !bHADME )
     
    459426}
    460427
    461 Void TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard )
     428Void TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, const Pel* p1, Int iStride1, const Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard )
    462429{
    463430  rcDP.pOrg       = p1;
     
    471438  rcDP.bitDepth   = bitDepth;
    472439  rcDP.DistFunc   = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ];
     440  rcDP.m_maximumDistortionForEarlyExit = std::numeric_limits<Distortion>::max();
    473441#if NH_3D_DBBP
    474442  if( m_bUseMask )
     
    479447}
    480448
    481 Distortion TComRdCost::calcHAD( Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight )
     449Distortion TComRdCost::calcHAD( Int bitDepth, const Pel* pi0, Int iStride0, const Pel* pi1, Int iStride1, Int iWidth, Int iHeight )
    482450{
    483451  Distortion uiSum = 0;
     
    550518
    551519
    552 Distortion TComRdCost::getDistPart( Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, const ComponentID compID, DFunc eDFunc )
     520Distortion TComRdCost::getDistPart( Int bitDepth, const Pel* piCur, Int iCurStride,  const Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, const ComponentID compID, DFunc eDFunc )
    553521{
    554522  DistParam cDtParam;
     
    663631UInt TComRdCost::xGetMaskedSSE( DistParam* pcDtParam )
    664632{
    665   Pel* piOrg   = pcDtParam->pOrg;
    666   Pel* piCur   = pcDtParam->pCur;
     633  const Pel* piOrg   = pcDtParam->pOrg;
     634  const Pel* piCur   = pcDtParam->pCur;
    667635  Int  iRows   = pcDtParam->iRows;
    668636  Int  iCols   = pcDtParam->iCols;
     
    701669#endif
    702670 
    703   Pel* piOrg   = pcDtParam->pOrg;
    704   Pel* piCur   = pcDtParam->pCur;
     671  const Pel* piOrg   = pcDtParam->pOrg;
     672  const Pel* piCur   = pcDtParam->pCur;
    705673  Int  iRows   = pcDtParam->iRows;
    706674  Int  iCols   = pcDtParam->iCols;
     
    729697UInt TComRdCost::xGetMaskedVSD( DistParam* pcDtParam )
    730698{
    731   Pel* piOrg    = pcDtParam->pOrg;
    732   Pel* piCur    = pcDtParam->pCur;
    733   Pel* piVirRec = pcDtParam->pVirRec;
    734   Pel* piVirOrg = pcDtParam->pVirOrg;
     699  const Pel* piOrg    = pcDtParam->pOrg;
     700  const Pel* piCur    = pcDtParam->pCur;
     701  const Pel* piVirRec = pcDtParam->pVirRec;
     702  const Pel* piVirOrg = pcDtParam->pVirOrg;
    735703  Int  iRows    = pcDtParam->iRows;
    736704  Int  iCols    = pcDtParam->iCols;
     
    786754  const Pel* piOrg   = pcDtParam->pOrg;
    787755  const Pel* piCur   = pcDtParam->pCur;
    788   Int  iRows   = pcDtParam->iRows;
    789   Int  iCols   = pcDtParam->iCols;
    790   Int  iStrideCur = pcDtParam->iStrideCur;
    791   Int  iStrideOrg = pcDtParam->iStrideOrg;
     756  const Int  iCols           = pcDtParam->iCols;
     757  const Int  iStrideCur      = pcDtParam->iStrideCur;
     758  const Int  iStrideOrg      = pcDtParam->iStrideOrg;
     759  const UInt distortionShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth - 8);
    792760
    793761  Distortion uiSum = 0;
    794762
    795   for( ; iRows != 0; iRows-- )
     763  for(Int iRows = pcDtParam->iRows ; iRows != 0; iRows-- )
    796764  {
    797765    for (Int n = 0; n < iCols; n++ )
     
    799767      uiSum += abs( piOrg[n] - piCur[n] );
    800768    }
    801     piOrg += iStrideOrg;
    802     piCur += iStrideCur;
    803   }
    804 
    805   return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     769    if (pcDtParam->m_maximumDistortionForEarlyExit < ( uiSum >> distortionShift ))
     770    {
     771      return ( uiSum >> distortionShift );
     772    }
     773    piOrg += iStrideOrg;
     774    piCur += iStrideCur;
     775  }
     776
     777  return ( uiSum >> distortionShift );
    806778}
    807779
     
    14031375    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    14041376  }
    1405   Pel* piOrg   = pcDtParam->pOrg;
    1406   Pel* piCur   = pcDtParam->pCur;
     1377  const Pel* piOrg   = pcDtParam->pOrg;
     1378  const Pel* piCur   = pcDtParam->pCur;
    14071379  Int  iRows   = pcDtParam->iRows;
    14081380  Int  iCols   = pcDtParam->iCols;
     
    14511423    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    14521424  }
    1453   Pel* piOrg   = pcDtParam->pOrg;
    1454   Pel* piCur   = pcDtParam->pCur;
     1425  const Pel* piOrg   = pcDtParam->pOrg;
     1426  const Pel* piCur   = pcDtParam->pCur;
    14551427  Int  iRows   = pcDtParam->iRows;
    14561428  Int  iSubShift  = pcDtParam->iSubShift;
     
    15081480    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    15091481  }
    1510   Pel* piOrg      = pcDtParam->pOrg;
    1511   Pel* piCur      = pcDtParam->pCur;
     1482  const Pel* piOrg      = pcDtParam->pOrg;
     1483  const Pel* piCur      = pcDtParam->pCur;
    15121484  Int  iRows      = pcDtParam->iRows;
    15131485  Int  iSubShift  = pcDtParam->iSubShift;
     
    15771549    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    15781550  }
    1579   Pel* piOrg   = pcDtParam->pOrg;
    1580   Pel* piCur   = pcDtParam->pCur;
     1551  const Pel* piOrg   = pcDtParam->pOrg;
     1552  const Pel* piCur   = pcDtParam->pCur;
    15811553  Int  iRows   = pcDtParam->iRows;
    15821554  Int  iSubShift  = pcDtParam->iSubShift;
     
    16701642    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    16711643  }
    1672   Pel* piOrg   = pcDtParam->pOrg;
    1673   Pel* piCur   = pcDtParam->pCur;
     1644  const Pel* piOrg   = pcDtParam->pOrg;
     1645  const Pel* piCur   = pcDtParam->pCur;
    16741646  Int  iRows   = pcDtParam->iRows;
    16751647  Int  iSubShift  = pcDtParam->iSubShift;
     
    17481720UInt TComRdCost::xGetSAD16Nic( DistParam* pcDtParam )
    17491721{
    1750   Pel* piOrg   = pcDtParam->pOrg;
    1751   Pel* piCur   = pcDtParam->pCur;
     1722  const Pel* piOrg   = pcDtParam->pOrg;
     1723  const Pel* piCur   = pcDtParam->pCur;
    17521724  Int  iRows   = pcDtParam->iRows;
    17531725  Int  iCols   = pcDtParam->iCols;
     
    18451817    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    18461818  }
    1847   Pel* piOrg   = pcDtParam->pOrg;
    1848   Pel* piCur   = pcDtParam->pCur;
     1819  const Pel* piOrg   = pcDtParam->pOrg;
     1820  const Pel* piCur   = pcDtParam->pCur;
    18491821  Int  iRows   = pcDtParam->iRows;
    18501822  Int  iSubShift  = pcDtParam->iSubShift;
     
    19871959    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    19881960  }
    1989   Pel* piOrg   = pcDtParam->pOrg;
    1990   Pel* piCur   = pcDtParam->pCur;
     1961  const Pel* piOrg   = pcDtParam->pOrg;
     1962  const Pel* piCur   = pcDtParam->pCur;
    19911963  Int  iRows   = pcDtParam->iRows;
    19921964  Int  iSubShift  = pcDtParam->iSubShift;
     
    21042076    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    21052077  }
    2106   Pel* piOrg   = pcDtParam->pOrg;
    2107   Pel* piCur   = pcDtParam->pCur;
     2078  const Pel* piOrg   = pcDtParam->pOrg;
     2079  const Pel* piCur   = pcDtParam->pCur;
    21082080  Int  iRows   = pcDtParam->iRows;
    21092081  Int  iSubShift  = pcDtParam->iSubShift;
     
    23432315  }
    23442316
    2345   Pel* piOrg   = pcDtParam->pOrg;
    2346   Pel* piCur   = pcDtParam->pCur;
     2317  const Pel* piOrg   = pcDtParam->pOrg;
     2318  const Pel* piCur   = pcDtParam->pCur;
    23472319  Int  iRows   = pcDtParam->iRows;
    23482320  Int  iSubShift  = pcDtParam->iSubShift;
     
    28792851#if NH_3D_VSO
    28802852//SAIT_VSO_EST_A0033
    2881 UInt TComRdCost::getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride,  Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y )
     2853UInt TComRdCost::getVSDEstimate( Int dDM, const Pel* pOrg, Int iOrgStride, const Pel* pVirRec, const Pel* pVirOrg, Int iVirStride, Int x, Int y )
    28822854{
    28832855  // change to use bit depth from DistParam struct
     
    28942866UInt TComRdCost::xGetVSD( DistParam* pcDtParam )
    28952867{
    2896   Pel* piOrg    = pcDtParam->pOrg;
    2897   Pel* piCur    = pcDtParam->pCur;
    2898   Pel* piVirRec = pcDtParam->pVirRec;
    2899   Pel* piVirOrg = pcDtParam->pVirOrg;
     2868  const Pel* piOrg    = pcDtParam->pOrg;
     2869  const Pel* piCur    = pcDtParam->pCur;
     2870  const Pel* piVirRec = pcDtParam->pVirRec;
     2871  const Pel* piVirOrg = pcDtParam->pVirOrg;
    29002872  Int  iRows    = pcDtParam->iRows;
    29012873  Int  iCols    = pcDtParam->iCols;
     
    29252897UInt TComRdCost::xGetVSD4( DistParam* pcDtParam )
    29262898{
    2927   Pel* piOrg   = pcDtParam->pOrg;
    2928   Pel* piCur   = pcDtParam->pCur;
    2929   Pel* piVirRec = pcDtParam->pVirRec;
    2930   Pel* piVirOrg = pcDtParam->pVirOrg;
     2899  const Pel* piOrg   = pcDtParam->pOrg;
     2900  const Pel* piCur   = pcDtParam->pCur;
     2901  const Pel* piVirRec = pcDtParam->pVirRec;
     2902  const Pel* piVirOrg = pcDtParam->pVirOrg;
    29312903  Int  iRows   = pcDtParam->iRows;
    29322904  Int  iStrideOrg = pcDtParam->iStrideOrg;
     
    29552927UInt TComRdCost::xGetVSD8( DistParam* pcDtParam )
    29562928{
    2957   Pel* piOrg   = pcDtParam->pOrg;
    2958   Pel* piCur   = pcDtParam->pCur;
    2959   Pel* piVirRec = pcDtParam->pVirRec;
    2960   Pel* piVirOrg = pcDtParam->pVirOrg;
     2929  const Pel* piOrg   = pcDtParam->pOrg;
     2930  const Pel* piCur   = pcDtParam->pCur;
     2931  const Pel* piVirRec = pcDtParam->pVirRec;
     2932  const Pel* piVirOrg = pcDtParam->pVirOrg;
    29612933  Int  iRows   = pcDtParam->iRows;
    29622934  Int  iStrideOrg = pcDtParam->iStrideOrg;
     
    29852957UInt TComRdCost::xGetVSD16( DistParam* pcDtParam )
    29862958{
    2987   Pel* piOrg   = pcDtParam->pOrg;
    2988   Pel* piCur   = pcDtParam->pCur;
    2989   Pel* piVirRec = pcDtParam->pVirRec;
    2990   Pel* piVirOrg = pcDtParam->pVirOrg;
     2959  const Pel* piOrg   = pcDtParam->pOrg;
     2960  const Pel* piCur   = pcDtParam->pCur;
     2961  const Pel* piVirRec = pcDtParam->pVirRec;
     2962  const Pel* piVirOrg = pcDtParam->pVirOrg;
    29912963  Int  iRows   = pcDtParam->iRows;
    29922964  Int  iStrideOrg = pcDtParam->iStrideOrg;
     
    30152987UInt TComRdCost::xGetVSD16N( DistParam* pcDtParam )
    30162988{
    3017   Pel* piOrg   = pcDtParam->pOrg;
    3018   Pel* piCur   = pcDtParam->pCur;
    3019   Pel* piVirRec = pcDtParam->pVirRec;
    3020   Pel* piVirOrg = pcDtParam->pVirOrg;
     2989  const Pel* piOrg   = pcDtParam->pOrg;
     2990  const Pel* piCur   = pcDtParam->pCur;
     2991  const Pel* piVirRec = pcDtParam->pVirRec;
     2992  const Pel* piVirOrg = pcDtParam->pVirOrg;
    30212993  Int  iRows   = pcDtParam->iRows;
    30222994  Int  iCols   = pcDtParam->iCols;
     
    30493021UInt TComRdCost::xGetVSD32( DistParam* pcDtParam )
    30503022{
    3051   Pel* piOrg   = pcDtParam->pOrg;
    3052   Pel* piCur   = pcDtParam->pCur;
    3053   Pel* piVirRec = pcDtParam->pVirRec;
    3054   Pel* piVirOrg = pcDtParam->pVirOrg;
     3023  const Pel* piOrg   = pcDtParam->pOrg;
     3024  const Pel* piCur   = pcDtParam->pCur;
     3025  const Pel* piVirRec = pcDtParam->pVirRec;
     3026  const Pel* piVirOrg = pcDtParam->pVirOrg;
    30553027  Int  iRows   = pcDtParam->iRows;
    30563028  Int  iStrideOrg = pcDtParam->iStrideOrg;
     
    30793051UInt TComRdCost::xGetVSD64( DistParam* pcDtParam )
    30803052{
    3081   Pel* piOrg      = pcDtParam->pOrg;
    3082   Pel* piCur      = pcDtParam->pCur;
    3083   Pel* piVirRec   = pcDtParam->pVirRec;
    3084   Pel* piVirOrg   = pcDtParam->pVirOrg;
     3053  const Pel* piOrg      = pcDtParam->pOrg;
     3054  const Pel* piCur      = pcDtParam->pCur;
     3055  const Pel* piVirRec   = pcDtParam->pVirRec;
     3056  const Pel* piVirOrg   = pcDtParam->pVirOrg;
    30853057  Int  iRows      = pcDtParam->iRows;
    30863058  Int  iStrideOrg = pcDtParam->iStrideOrg;
     
    31133085// --------------------------------------------------------------------------------------------------------------------
    31143086
    3115 Distortion TComRdCost::xCalcHADs2x2( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
     3087Distortion TComRdCost::xCalcHADs2x2( const Pel *piOrg, const Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    31163088{
    31173089  Distortion satd = 0;
     
    31353107}
    31363108
    3137 Distortion TComRdCost::xCalcHADs4x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
     3109Distortion TComRdCost::xCalcHADs4x4( const Pel *piOrg, const Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    31383110{
    31393111  Int k;
     
    32313203}
    32323204
    3233 Distortion TComRdCost::xCalcHADs8x8( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
     3205Distortion TComRdCost::xCalcHADs8x8( const Pel *piOrg, const Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    32343206{
    32353207  Int k, i, j, jj;
     
    33483320#endif
    33493321
    3350   Pel* piOrg   = pcDtParam->pOrg;
    3351   Pel* piCur   = pcDtParam->pCur;
    3352   Int  iRows   = pcDtParam->iRows;
    3353   Int  iCols   = pcDtParam->iCols;
    3354   Int  iStrideCur = pcDtParam->iStrideCur;
    3355   Int  iStrideOrg = pcDtParam->iStrideOrg;
    3356   Int  iStep  = pcDtParam->iStep;
     3322  const Pel* piOrg      = pcDtParam->pOrg;
     3323  const Pel* piCur      = pcDtParam->pCur;
     3324  const Int  iRows      = pcDtParam->iRows;
     3325  const Int  iCols      = pcDtParam->iCols;
     3326  const Int  iStrideCur = pcDtParam->iStrideCur;
     3327  const Int  iStrideOrg = pcDtParam->iStrideOrg;
     3328  const Int  iStep      = pcDtParam->iStep;
    33573329
    33583330  Int  x, y;
     
    34183390    return TComRdCostWeightPrediction::xGetHADsw( pcDtParam );
    34193391  }
    3420   Pel* piOrg   = pcDtParam->pOrg;
    3421   Pel* piCur   = pcDtParam->pCur;
     3392  const Pel* piOrg   = pcDtParam->pOrg;
     3393  const Pel* piCur   = pcDtParam->pCur;
     3394 
    34223395  Int  iRows   = pcDtParam->iRows;
    34233396  Int  iCols   = pcDtParam->iCols;
     
    34493422  iDeltaC = (iOrigAvg - iCurAvg)/iRows/iCols;
    34503423
     3424  const Int orgMaxSize = MAX_CU_SIZE*MAX_CU_SIZE;
     3425  assert( iRows * iCols <= orgMaxSize );
     3426 
     3427  Pel orgMinusDeltaDc[ orgMaxSize ];
     3428  Pel* tempOrgMinusDeltaDc = orgMinusDeltaDc;
     3429 
    34513430  for ( y=0; y<iRows; y++ )
    34523431  {
    34533432    for ( x=0; x<iCols; x++ )
    34543433    {       
    3455       piOrg[x] -= iDeltaC;
    3456     }
    3457     piOrg += iStrideOrg;
    3458   }
     3434      tempOrgMinusDeltaDc[x] = (piOrg[x] - iDeltaC);
     3435    }
     3436    piOrg               += iStrideOrg;
     3437    tempOrgMinusDeltaDc += iStrideOrg;
     3438  }
     3439
     3440  tempOrgMinusDeltaDc = orgMinusDeltaDc;
    34593441
    34603442  piOrg   = pcDtParam->pOrg;
     
    34723454      for ( x=0; x<iCols; x+= 8 )
    34733455      {
    3474         uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
     3456        uiSum += xCalcHADs8x8( &tempOrgMinusDeltaDc[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    34753457      }
    3476       piOrg += iOffsetOrg;
    3477       piCur += iOffsetCur;
     3458      tempOrgMinusDeltaDc += iOffsetOrg;
     3459      piCur               += iOffsetCur;
    34783460    }
    34793461  }
     
    34873469      for ( x=0; x<iCols; x+= 16 )
    34883470      {
    3489         uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
     3471        uiSum += xCalcHADs16x4( &tempOrgMinusDeltaDc[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    34903472      }
    3491       piOrg += iOffsetOrg;
    3492       piCur += iOffsetCur;
     3473      tempOrgMinusDeltaDc += iOffsetOrg;
     3474      piCur               += iOffsetCur;
    34933475    }
    34943476  }
     
    35013483      for ( x=0; x<iCols; x+= 4 )
    35023484      {
    3503         uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
     3485        uiSum += xCalcHADs4x16( &tempOrgMinusDeltaDc[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    35043486      }
    3505       piOrg += iOffsetOrg;
    3506       piCur += iOffsetCur;
     3487      tempOrgMinusDeltaDc += iOffsetOrg;
     3488      piCur               += iOffsetCur;
    35073489    }
    35083490  }
     
    35173499      for ( x=0; x<iCols; x+= 4 )
    35183500      {
    3519         uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
     3501        uiSum += xCalcHADs4x4( &tempOrgMinusDeltaDc[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    35203502      }
    3521       piOrg += iOffsetOrg;
    3522       piCur += iOffsetCur;
     3503      tempOrgMinusDeltaDc += iOffsetOrg;
     3504      piCur               += iOffsetCur;
    35233505    }
    35243506  }
     
    35313513      for ( x=0; x<iCols; x+=2 )
    35323514      {
    3533         uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
     3515        uiSum += xCalcHADs2x2( &tempOrgMinusDeltaDc[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    35343516      }
    3535       piOrg += iOffsetOrg;
    3536       piCur += iOffsetCur;
     3517      tempOrgMinusDeltaDc += iOffsetOrg;
     3518      piCur               += iOffsetCur;
    35373519    }
    35383520  }
     
    35403522  {
    35413523    assert(false);
    3542   }
    3543 
    3544   piOrg   = pcDtParam->pOrg;
    3545 
    3546   for ( y=0; y<iRows; y++ )
    3547   {
    3548     for ( x=0; x<iCols; x++ )
    3549     {       
    3550       piOrg[x] += iDeltaC;
    3551     }
    3552     piOrg += iStrideOrg;
    35533524  }
    35543525
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComRdCost.h

    r1313 r1360  
    8181{
    8282public:
    83   Pel*  pOrg;
    84   Pel*  pCur;
     83  const Pel*            pOrg;
     84  const Pel*            pCur;
    8585  Int   iStrideOrg;
    8686  Int   iStrideCur;
     
    104104
    105105  Bool            bApplyWeight;     // whether weighted prediction is used or not
    106   WPScalingParam  *wpCur;           // weighted prediction scaling parameters for current ref
     106  Bool                  bIsBiPred;
     107
     108  const WPScalingParam *wpCur;           // weighted prediction scaling parameters for current ref
    107109  ComponentID     compIdx;
     110  Distortion            m_maximumDistortionForEarlyExit; /// During cost calculations, if distortion exceeds this value, cost calculations may early-terminate.
    108111
    109112  // (vertical) subsampling shift (for reducing complexity)
     
    112115
    113116  DistParam()
    114   {
    115     pOrg = NULL;
    116     pCur = NULL;
    117     iStrideOrg = 0;
    118     iStrideCur = 0;
    119     iRows = 0;
    120     iCols = 0;
    121     iStep = 1;
    122     DistFunc = NULL;
    123     iSubShift = 0;
    124     bitDepth = 0;
    125 #if NH_3D_VSO
    126     // SAIT_VSO_EST_A0033
    127     pVirRec = NULL;
    128     pVirOrg = NULL;
    129     iStrideVir = 0;
    130 #endif
    131 #if NH_3D_SDC_INTER
    132     bUseSDCMRSAD = false;
    133 #endif
    134   }
     117   : pOrg(NULL),
     118     pCur(NULL),
     119     iStrideOrg(0),
     120     iStrideCur(0),
     121     iRows(0),
     122     iCols(0),
     123     iStep(1),
     124     DistFunc(NULL),
     125     bitDepth(0),
     126     bApplyWeight(false),
     127     bIsBiPred(false),
     128     wpCur(NULL),
     129     compIdx(MAX_NUM_COMPONENT),
     130     m_maximumDistortionForEarlyExit(std::numeric_limits<Distortion>::max()),
     131     iSubShift(0)
     132  { }
    135133};
    136134
     
    146144  Double                  m_dLambda;
    147145  Double                  m_sqrtLambda;
    148 #if RExt__HIGH_BIT_DEPTH_SUPPORT
    149146  Double                  m_dLambdaMotionSAD[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/];
    150147  Double                  m_dLambdaMotionSSE[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/];
    151 #else
    152   UInt                    m_uiLambdaMotionSAD[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/];
    153   UInt                    m_uiLambdaMotionSSE[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/];
    154 #endif
    155148  Double                  m_dFrameLambda;
    156149#if NH_3D_VSO
     
    161154  // for motion cost
    162155  TComMv                  m_mvPredictor;
    163 #if RExt__HIGH_BIT_DEPTH_SUPPORT
    164   Double                  m_dCost;
    165 #else
    166   UInt                    m_uiCost;
    167 #endif
     156  Double                  m_motionLambda;
    168157  Int                     m_iCostScale;
    169158#if NH_3D_DBBP
     
    175164  virtual ~TComRdCost();
    176165#if NH_3D_VSO
    177   Double  calcRdCost  ( UInt   uiBits, Dist  uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    178   Double  calcRdCost64( UInt64 uiBits, Dist64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
     166  Double  calcRdCost64( UInt64 uiBits , Dist64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
     167  Double  calcRdCost( Double numBits, Dist intDistortion, DFunc eDFunc = DF_DEFAULT );
    179168#else
    180   Double  calcRdCost  ( UInt   uiBits, Distortion uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    181   Double  calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    182 #endif
     169  Double calcRdCost( Double numBits, Double distortion, DFunc eDFunc = DF_DEFAULT );
     170#endif
     171
    183172
    184173  Void    setDistortionWeight  ( const ComponentID compID, const Double distortionWeight ) { m_distortionWeight[compID] = distortionWeight; }
     
    202191
    203192  Void    setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam );
    204   Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride,            DistParam& rcDistParam );
    205   Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false );
    206   Void    setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false );
     193  Void    setDistParam( const TComPattern* const pcPatternKey, const Pel* piRefY, Int iRefStride,            DistParam& rcDistParam );
     194  Void    setDistParam( const TComPattern* const pcPatternKey, const Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false );
     195  Void    setDistParam( DistParam& rcDP, Int bitDepth, const Pel* p1, Int iStride1, const Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false );
    207196
    208197#if NH_3D_DBBP
     
    210199#endif
    211200
    212   Distortion calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight );
     201  Distortion calcHAD(Int bitDepth, const Pel* pi0, Int iStride0, const Pel* pi1, Int iStride1, Int iWidth, Int iHeight );
    213202
    214203#if NH_3D_ENC_DEPTH
     
    218207  // for motion cost
    219208  static UInt    xGetExpGolombNumberOfBits( Int iVal );
    220 #if RExt__HIGH_BIT_DEPTH_SUPPORT
    221   Void    getMotionCost( Bool bSad, Int iAdd, Bool bIsTransquantBypass ) { m_dCost = (bSad ? m_dLambdaMotionSAD[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING) ?1:0] + iAdd : m_dLambdaMotionSSE[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING)?1:0] + iAdd); }
    222 #else
    223   Void    getMotionCost( Bool bSad, Int iAdd, Bool bIsTransquantBypass ) { m_uiCost = (bSad ? m_uiLambdaMotionSAD[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING) ?1:0] + iAdd : m_uiLambdaMotionSSE[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING)?1:0] + iAdd); }
    224 #endif
     209  Void    selectMotionLambda( Bool bSad, Int iAdd, Bool bIsTransquantBypass ) { m_motionLambda = (bSad ? m_dLambdaMotionSAD[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING) ?1:0] + iAdd : m_dLambdaMotionSSE[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING)?1:0] + iAdd); }
    225210  Void    setPredictor( TComMv& rcMv )
    226211  {
     
    228213  }
    229214  Void    setCostScale( Int iCostScale )    { m_iCostScale = iCostScale; }
    230   __inline Distortion getCost( Int x, Int y )
     215  Distortion getCost( UInt b )                 { return Distortion(( m_motionLambda * b ) / 65536.0); }
     216  Distortion getCostOfVectorWithPredictor( const Int x, const Int y )
    231217  {
    232 #if RExt__HIGH_BIT_DEPTH_SUPPORT
    233     return Distortion((m_dCost * getBits(x, y)) / 65536.0);
    234 #else
    235     return m_uiCost * getBits(x, y) >> 16;
    236 #endif
     218    return Distortion((m_motionLambda * getBitsOfVectorWithPredictor(x, y)) / 65536.0);
    237219  }
    238 #if RExt__HIGH_BIT_DEPTH_SUPPORT
    239   Distortion getCost( UInt b )                 { return Distortion(( m_dCost * b ) / 65536.0); }
    240 #else
    241   Distortion getCost( UInt b )                 { return ( m_uiCost * b ) >> 16; }
    242 #endif
    243   UInt    getBits( Int x, Int y )
     220  UInt getBitsOfVectorWithPredictor( const Int x, const Int y )
    244221  {
    245222    return xGetExpGolombNumberOfBits((x << m_iCostScale) - m_mvPredictor.getHor())
     
    299276
    300277  static Distortion xGetHADs          ( DistParam* pcDtParam );
    301   static Distortion xCalcHADs2x2      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    302   static Distortion xCalcHADs4x4      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    303   static Distortion xCalcHADs8x8      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
     278  static Distortion xCalcHADs2x2      ( const Pel *piOrg, const Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
     279  static Distortion xCalcHADs4x4      ( const Pel *piOrg, const Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
     280  static Distortion xCalcHADs8x8      ( const Pel *piOrg, const Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    304281#if NH_3D_DBBP
    305282  static UInt xGetMaskedSSE     ( DistParam* pcDtParam );
     
    311288public:
    312289
    313   Distortion   getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, const ComponentID compID, DFunc eDFunc = DF_SSE );
     290  Distortion   getDistPart(Int bitDepth, const Pel* piCur, Int iCurStride, const Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, const ComponentID compID, DFunc eDFunc = DF_SSE );
    314291
    315292#if KWU_RC_MADPRED_E0227
     
    320297  // SAIT_VSO_EST_A0033
    321298  UInt        getDistPartVSD( TComDataCU* pcCu, UInt uiPartOffset, Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHad, DFunc eDFunc = DF_VSD);
    322   static UInt getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride,  Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y );
     299  static UInt getVSDEstimate( Int dDM, const Pel* pOrg, Int iOrgStride,  const Pel* pVirRec, const Pel* pVirOrg, Int iVirStride, Int x, Int y );
    323300
    324301private:
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComRdCostWeightPrediction.cpp

    r1313 r1360  
    7070  const Int             shift      = wpCur.shift;
    7171  const Int             round      = wpCur.round;
     72  const Int        distortionShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    7273
    7374  Distortion uiSum = 0;
    7475
     76#if !U0040_MODIFIED_WEIGHTEDPREDICTION_WITH_BIPRED_AND_CLIPPING
    7577  for(Int iRows = pcDtParam->iRows; iRows != 0; iRows-- )
    7678  {
     
    8082
    8183      uiSum += abs( piOrg[n] - pred );
     84    }
     85    if (pcDtParam->m_maximumDistortionForEarlyExit <  ( uiSum >> distortionShift))
     86    {
     87      return uiSum >> distortionShift;
    8288    }
    8389    piOrg += iStrideOrg;
     
    8692
    8793  pcDtParam->compIdx = MAX_NUM_COMPONENT;  // reset for DEBUG (assert test)
    88 
    89   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     94#else
     95  // Default weight
     96  if (w0 == 1 << shift)
     97  {
     98    // no offset
     99    if (offset == 0)
     100    {
     101      for(Int iRows = pcDtParam->iRows; iRows != 0; iRows-- )
     102      {
     103        for (Int n = 0; n < iCols; n++ )
     104        {
     105          uiSum += abs( piOrg[n] - piCur[n] );
     106        }
     107        if (pcDtParam->m_maximumDistortionForEarlyExit <  ( uiSum >> distortionShift))
     108        {
     109          return uiSum >> distortionShift;
     110        }
     111        piOrg += iStrideOrg;
     112        piCur += iStrideCur;
     113      }
     114    }
     115    else
     116    {
     117      // Lets not clip for the bipredictive case since clipping should be done after
     118      // combining both elements. Unfortunately the code uses the suboptimal "subtraction"
     119      // method, which is faster but introduces the clipping issue (therefore Bipred is suboptimal).
     120      if (pcDtParam->bIsBiPred)
     121      {
     122        for(Int iRows = pcDtParam->iRows; iRows != 0; iRows-- )
     123        {
     124          for (Int n = 0; n < iCols; n++ )
     125          {
     126            uiSum += abs( piOrg[n] - (piCur[n] + offset) );
     127          }
     128          if (pcDtParam->m_maximumDistortionForEarlyExit <  ( uiSum >> distortionShift))
     129          {
     130            return uiSum >> distortionShift;
     131          }
     132
     133          piOrg += iStrideOrg;
     134          piCur += iStrideCur;
     135        }
     136      }
     137      else
     138      {
     139        const Pel iMaxValue = (Pel) ((1 << pcDtParam->bitDepth) - 1);
     140        for(Int iRows = pcDtParam->iRows; iRows != 0; iRows-- )
     141        {
     142          for (Int n = 0; n < iCols; n++ )
     143          {
     144            const Pel pred = Clip3((Pel) 0, iMaxValue, (Pel) (piCur[n] + offset)) ;
     145
     146            uiSum += abs( piOrg[n] - pred );
     147          }
     148          if (pcDtParam->m_maximumDistortionForEarlyExit <  ( uiSum >> distortionShift))
     149          {
     150            return uiSum >> distortionShift;
     151          }
     152          piOrg += iStrideOrg;
     153          piCur += iStrideCur;
     154        }
     155      }
     156    }
     157  }
     158  else
     159  {
     160    // Lets not clip for the bipredictive case since clipping should be done after
     161    // combining both elements. Unfortunately the code uses the suboptimal "subtraction"
     162    // method, which is faster but introduces the clipping issue (therefore Bipred is suboptimal).
     163    if (pcDtParam->bIsBiPred)
     164    {
     165      for(Int iRows = pcDtParam->iRows; iRows != 0; iRows-- )
     166      {
     167        for (Int n = 0; n < iCols; n++ )
     168        {
     169          const Pel pred = ( (w0*piCur[n] + round) >> shift ) + offset ;
     170          uiSum += abs( piOrg[n] - pred );
     171        }
     172        if (pcDtParam->m_maximumDistortionForEarlyExit <  ( uiSum >> distortionShift))
     173        {
     174          return uiSum >> distortionShift;
     175        }
     176
     177        piOrg += iStrideOrg;
     178        piCur += iStrideCur;
     179      }
     180    }
     181    else
     182    {
     183      const Pel iMaxValue = (Pel) ((1 << pcDtParam->bitDepth) - 1);
     184
     185      if (offset == 0)
     186      {
     187        for(Int iRows = pcDtParam->iRows; iRows != 0; iRows-- )
     188        {
     189          for (Int n = 0; n < iCols; n++ )
     190          {
     191            const Pel pred = Clip3((Pel) 0, iMaxValue, (Pel) (( (w0*piCur[n] + round) >> shift ))) ;
     192
     193            uiSum += abs( piOrg[n] - pred );
     194          }
     195          if (pcDtParam->m_maximumDistortionForEarlyExit <  ( uiSum >> distortionShift))
     196          {
     197            return uiSum >> distortionShift;
     198          }
     199          piOrg += iStrideOrg;
     200          piCur += iStrideCur;
     201        }
     202      }
     203      else
     204      {
     205        for(Int iRows = pcDtParam->iRows; iRows != 0; iRows-- )
     206        {
     207          for (Int n = 0; n < iCols; n++ )
     208          {
     209            const Pel pred = Clip3((Pel) 0, iMaxValue, (Pel) (( (w0*piCur[n] + round) >> shift ) + offset)) ;
     210
     211            uiSum += abs( piOrg[n] - pred );
     212          }
     213          if (pcDtParam->m_maximumDistortionForEarlyExit <  ( uiSum >> distortionShift))
     214          {
     215            return uiSum >> distortionShift;
     216          }
     217          piOrg += iStrideOrg;
     218          piCur += iStrideCur;
     219        }
     220      }
     221    }
     222  }
     223  //pcDtParam->compIdx = MAX_NUM_COMPONENT;  // reset for DEBUG (assert test)
     224#endif
     225
     226  return uiSum >> distortionShift;
    90227}
    91228
     
    119256  Distortion sum = 0;
    120257
     258#if !U0040_MODIFIED_WEIGHTEDPREDICTION_WITH_BIPRED_AND_CLIPPING
    121259  for(Int iRows = pcDtParam->iRows ; iRows != 0; iRows-- )
    122260  {
     
    132270
    133271  pcDtParam->compIdx = MAX_NUM_COMPONENT; // reset for DEBUG (assert test)
     272#else
     273  if (pcDtParam->bIsBiPred)
     274  {
     275    for(Int iRows = pcDtParam->iRows ; iRows != 0; iRows-- )
     276    {
     277      for (Int n = 0; n < iCols; n++ )
     278      {
     279        const Pel pred     = ( (w0*piCur[n] + round) >> shift ) + offset ;
     280        const Pel residual = piOrg[n] - pred;
     281        sum += ( Distortion(residual) * Distortion(residual) ) >> distortionShift;
     282      }
     283      piOrg += iStrideOrg;
     284      piCur += iStrideCur;
     285    }
     286  }
     287  else
     288  {
     289    const Pel iMaxValue = (Pel) ((1 << pcDtParam->bitDepth) - 1);
     290
     291    for(Int iRows = pcDtParam->iRows ; iRows != 0; iRows-- )
     292    {
     293      for (Int n = 0; n < iCols; n++ )
     294      {
     295        const Pel pred     = Clip3((Pel) 0, iMaxValue, (Pel) (( (w0*piCur[n] + round) >> shift ) + offset)) ;
     296        const Pel residual = piOrg[n] - pred;
     297        sum += ( Distortion(residual) * Distortion(residual) ) >> distortionShift;
     298      }
     299      piOrg += iStrideOrg;
     300      piCur += iStrideCur;
     301    }
     302  }
     303
     304  //pcDtParam->compIdx = MAX_NUM_COMPONENT; // reset for DEBUG (assert test)
     305#endif
    134306
    135307  return sum;
     
    416588  const ComponentID compIdx    = pcDtParam->compIdx;
    417589  assert(compIdx<MAX_NUM_COMPONENT);
    418   const WPScalingParam  wpCur    = pcDtParam->wpCur[compIdx];
     590  const WPScalingParam &wpCur  = pcDtParam->wpCur[compIdx];
    419591
    420592  Distortion uiSum = 0;
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComRom.cpp

    r1321 r1360  
    4747//! \ingroup TLibCommon
    4848//! \{
    49 const Char* nalUnitTypeToString(NalUnitType type)
     49const TChar* nalUnitTypeToString(NalUnitType type)
    5050{
    5151  switch (type)
     
    532532// Misc.
    533533// ====================================================================================================================
    534 Char  g_aucConvertToBit  [ MAX_CU_SIZE+1 ];
     534SChar  g_aucConvertToBit  [ MAX_CU_SIZE+1 ];
    535535#if ENC_DEC_TRACE
    536536FILE*  g_hTrace = NULL; // Set to NULL to open up a file. Set to stdout to use the current output
    537537const Bool g_bEncDecTraceEnable  = true;
    538538const Bool g_bEncDecTraceDisable = false;
    539 Bool   g_HLSTraceEnable = false;
     539Bool   g_HLSTraceEnable = true;
    540540Bool   g_bJustDoIt = false;
    541541UInt64 g_nSymbolCounter = 0;
     
    582582const UInt g_uiMinInGroup[ LAST_SIGNIFICANT_GROUPS ] = {0,1,2,3,4,6,8,12,16,24};
    583583const UInt g_uiGroupIdx[ MAX_TU_SIZE ]   = {0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9};
    584 const Char *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] =
     584const TChar *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] =
    585585{
    586586  {
     
    617617  },
    618618};
    619 const Char *MatrixType_DC[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] =
     619const TChar *MatrixType_DC[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] =
    620620{
    621621  {
     
    673673#if H_MV_ENC_DEC_TRAC
    674674#if ENC_DEC_TRACE
    675 Void tracePSHeader( const Char* psName, Int layerId )
     675Void tracePSHeader( const TChar* psName, Int layerId )
    676676
    677677  if ( !g_disableHLSTrace  )
     
    727727  } 
    728728}
    729 Void writeToTraceFile( const Char* symbolName, Int val, Bool doIt )
     729Void writeToTraceFile( const TChar* symbolName, Int val, Bool doIt )
    730730{
    731731  if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt  )
     
    749749  return g_nSymbolCounter;
    750750}
    751 Void writeToTraceFile( const Char* symbolName, Bool doIt )
     751Void writeToTraceFile( const TChar* symbolName, Bool doIt )
    752752{
    753753  if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt  )
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComRom.h

    r1321 r1360  
    149149// Misc.
    150150// ====================================================================================================================
    151 extern       Char   g_aucConvertToBit  [ MAX_CU_SIZE+1 ];   // from width to log2(width)-2
     151extern       SChar   g_aucConvertToBit  [ MAX_CU_SIZE+1 ];   // from width to log2(width)-2
    152152#if NH_MV
    153153// Change later
     
    206206#define D_PRINT_INC_INDENT( b, str ) prinStrIncIndent( b, str );
    207207#define D_PRINT_INDENT( b, str )     printStrIndent   ( b, str);
    208  Void           tracePSHeader   ( const Char* psName, Int layerId );
    209  Void           writeToTraceFile( const Char* symbolName, Int val, Bool doIt );
    210  Void           writeToTraceFile( const Char* symbolName, Bool doIt );
     208 Void           tracePSHeader   ( const TChar* psName, Int layerId );
     209 Void           writeToTraceFile( const TChar* symbolName, Int val, Bool doIt );
     210 Void           writeToTraceFile( const TChar* symbolName, Bool doIt );
    211211 UInt64         incSymbolCounter();         
    212212 Void           stopAtPos       ( Int poc, Int layerId, Int cuPelX, Int cuPelY, Int cuWidth, Int cuHeight );           
     
    243243#endif
    244244#endif
    245 const Char* nalUnitTypeToString(NalUnitType type);
    246 extern const Char *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM];
    247 extern const Char *MatrixType_DC[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM];
     245const TChar* nalUnitTypeToString(NalUnitType type);
     246
     247extern const TChar *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM];
     248extern const TChar *MatrixType_DC[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM];
    248249extern const Int g_quantTSDefault4x4[4*4];
    249250extern const Int g_quantIntraDefault8x8[8*8];
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp

    r1313 r1360  
    324324      m_signLineBuf1 = NULL;
    325325    }
    326     m_signLineBuf1 = new Char[m_lineBufWidth+1];
     326    m_signLineBuf1 = new SChar[m_lineBufWidth+1];
    327327
    328328    if (m_signLineBuf2)
     
    331331      m_signLineBuf2 = NULL;
    332332    }
    333     m_signLineBuf2 = new Char[m_lineBufWidth+1];
     333    m_signLineBuf2 = new SChar[m_lineBufWidth+1];
    334334  }
    335335
     
    338338  Int x,y, startX, startY, endX, endY, edgeType;
    339339  Int firstLineStartX, firstLineEndX, lastLineStartX, lastLineEndX;
    340   Char signLeft, signRight, signDown;
     340  SChar signLeft, signRight, signDown;
    341341
    342342  Pel* srcLine = srcBlk;
     
    352352      for (y=0; y< height; y++)
    353353      {
    354         signLeft = (Char)sgn(srcLine[startX] - srcLine[startX-1]);
     354        signLeft = (SChar)sgn(srcLine[startX] - srcLine[startX-1]);
    355355        for (x=startX; x< endX; x++)
    356356        {
    357           signRight = (Char)sgn(srcLine[x] - srcLine[x+1]);
     357          signRight = (SChar)sgn(srcLine[x] - srcLine[x+1]);
    358358          edgeType =  signRight + signLeft;
    359359          signLeft  = -signRight;
     
    370370    {
    371371      offset += 2;
    372       Char *signUpLine = m_signLineBuf1;
     372      SChar *signUpLine = m_signLineBuf1;
    373373
    374374      startY = isAboveAvail ? 0 : 1;
     
    383383      for (x=0; x< width; x++)
    384384      {
    385         signUpLine[x] = (Char)sgn(srcLine[x] - srcLineAbove[x]);
     385        signUpLine[x] = (SChar)sgn(srcLine[x] - srcLineAbove[x]);
    386386      }
    387387
     
    393393        for (x=0; x< width; x++)
    394394        {
    395           signDown  = (Char)sgn(srcLine[x] - srcLineBelow[x]);
     395          signDown  = (SChar)sgn(srcLine[x] - srcLineBelow[x]);
    396396          edgeType = signDown + signUpLine[x];
    397397          signUpLine[x]= -signDown;
     
    408408    {
    409409      offset += 2;
    410       Char *signUpLine, *signDownLine, *signTmpLine;
     410      SChar *signUpLine, *signDownLine, *signTmpLine;
    411411
    412412      signUpLine  = m_signLineBuf1;
     
    420420      for (x=startX; x< endX+1; x++)
    421421      {
    422         signUpLine[x] = (Char)sgn(srcLineBelow[x] - srcLine[x- 1]);
     422        signUpLine[x] = (SChar)sgn(srcLineBelow[x] - srcLine[x- 1]);
    423423      }
    424424
     
    444444        for (x=startX; x<endX; x++)
    445445        {
    446           signDown =  (Char)sgn(srcLine[x] - srcLineBelow[x+ 1]);
     446          signDown =  (SChar)sgn(srcLine[x] - srcLineBelow[x+ 1]);
    447447          edgeType =  signDown + signUpLine[x];
    448448          resLine[x] = Clip3<Int>(0, maxSampleValueIncl, srcLine[x] + offset[edgeType]);
     
    450450          signDownLine[x+1] = -signDown;
    451451        }
    452         signDownLine[startX] = (Char)sgn(srcLineBelow[startX] - srcLine[startX-1]);
     452        signDownLine[startX] = (SChar)sgn(srcLineBelow[startX] - srcLine[startX-1]);
    453453
    454454        signTmpLine  = signUpLine;
     
    475475    {
    476476      offset += 2;
    477       Char *signUpLine = m_signLineBuf1+1;
     477      SChar *signUpLine = m_signLineBuf1+1;
    478478
    479479      startX = isLeftAvail ? 0 : 1;
     
    484484      for (x=startX-1; x< endX; x++)
    485485      {
    486         signUpLine[x] = (Char)sgn(srcLineBelow[x] - srcLine[x+1]);
     486        signUpLine[x] = (SChar)sgn(srcLineBelow[x] - srcLine[x+1]);
    487487      }
    488488
     
    507507        for(x= startX; x< endX; x++)
    508508        {
    509           signDown =  (Char)sgn(srcLine[x] - srcLineBelow[x-1]);
     509          signDown =  (SChar)sgn(srcLine[x] - srcLineBelow[x-1]);
    510510          edgeType =  signDown + signUpLine[x];
    511511          resLine[x] = Clip3<Int>(0, maxSampleValueIncl, srcLine[x] + offset[edgeType]);
    512512          signUpLine[x-1] = -signDown;
    513513        }
    514         signUpLine[endX-1] = (Char)sgn(srcLineBelow[endX-1] - srcLine[endX]);
     514        signUpLine[endX-1] = (SChar)sgn(srcLineBelow[endX-1] - srcLine[endX]);
    515515        srcLine  += srcStride;
    516516        resLine += resStride;
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h

    r1313 r1360  
    9696
    9797  Int m_lineBufWidth;
    98   Char* m_signLineBuf1;
    99   Char* m_signLineBuf2;
     98  SChar* m_signLineBuf1;
     99  SChar* m_signLineBuf2;
    100100  ChromaFormat m_chromaFormatIDC;
    101101private:
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComSlice.cpp

    r1321 r1360  
    452452Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr )
    453453{
    454   if (!checkNumPocTotalCurr)
    455   {
    456454    if (m_eSliceType == I_SLICE)
    457455    {
     
    459457      ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
    460458
     459    if (!checkNumPocTotalCurr)
     460    {
    461461      return;
    462462    }
    463 
    464     m_aiNumRefIdx[REF_PIC_LIST_0] = getNumRefIdx(REF_PIC_LIST_0);
    465     m_aiNumRefIdx[REF_PIC_LIST_1] = getNumRefIdx(REF_PIC_LIST_1);
    466463  }
    467464
     
    536533    if (m_eSliceType == I_SLICE)
    537534    {
    538       ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
    539       ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
    540 
    541535      return;
    542536    }
     
    545539    // general tier and level limit:
    546540    assert(numPicTotalCurr <= 8);
    547 
    548     m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
    549     m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
    550541  }
    551542
     
    27672758    m_uiSpsMaxLatencyIncreasePlus1[i] = 0;
    27682759#else
    2769     m_uiMaxLatencyIncrease[i] = 0;
     2760    m_uiMaxLatencyIncreasePlus1[i] = 0;
    27702761#endif
    27712762    m_uiMaxDecPicBuffering[i] = 1;
     
    45454536}
    45464537
    4547 Bool TComScalingList::xParseScalingList(Char* pchFile)
     4538Bool TComScalingList::xParseScalingList(const std::string &fileName)
    45484539{
    45494540  static const Int LINE_SIZE=1024;
    45504541  FILE *fp = NULL;
    4551   Char line[LINE_SIZE];
    4552 
    4553   if (pchFile == NULL)
     4542  TChar line[LINE_SIZE];
     4543
     4544  if (fileName.empty())
    45544545  {
    45554546    fprintf(stderr, "Error: no scaling list file specified. Help on scaling lists being output\n");
     
    45604551    return true;
    45614552  }
    4562   else if ((fp = fopen(pchFile,"r")) == (FILE*)NULL)
    4563   {
    4564     fprintf(stderr, "Error: cannot open scaling list file %s for reading\n",pchFile);
     4553  else if ((fp = fopen(fileName.c_str(),"r")) == (FILE*)NULL)
     4554  {
     4555    fprintf(stderr, "Error: cannot open scaling list file %s for reading\n", fileName.c_str());
    45654556    return true;
    45664557  }
     
    45904581          while ((!feof(fp)) && (!bFound))
    45914582          {
    4592             Char *ret = fgets(line, LINE_SIZE, fp);
    4593             Char *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType[sizeIdc][listIdc]);
     4583            TChar *ret = fgets(line, LINE_SIZE, fp);
     4584            TChar *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType[sizeIdc][listIdc]);
    45944585            // This could be a match against the DC string as well, so verify it isn't
    45954586            if (findNamePosition!= NULL && (MatrixType_DC[sizeIdc][listIdc]==NULL || strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL))
     
    46004591          if (!bFound)
    46014592          {
    4602             fprintf(stderr, "Error: cannot find Matrix %s from scaling list file %s\n", MatrixType[sizeIdc][listIdc], pchFile);
     4593            fprintf(stderr, "Error: cannot find Matrix %s from scaling list file %s\n", MatrixType[sizeIdc][listIdc], fileName.c_str());
    46034594            return true;
    46044595          }
     
    46094600          if (fscanf(fp, "%d,", &data)!=1)
    46104601          {
    4611             fprintf(stderr, "Error: cannot read value #%d for Matrix %s from scaling list file %s at file position %ld\n", i, MatrixType[sizeIdc][listIdc], pchFile, ftell(fp));
     4602            fprintf(stderr, "Error: cannot read value #%d for Matrix %s from scaling list file %s at file position %ld\n", i, MatrixType[sizeIdc][listIdc], fileName.c_str(), ftell(fp));
    46124603            return true;
    46134604          }
    46144605          if (data<0 || data>255)
    46154606          {
    4616             fprintf(stderr, "Error: QMatrix entry #%d of value %d for Matrix %s from scaling list file %s at file position %ld is out of range (0 to 255)\n", i, data, MatrixType[sizeIdc][listIdc], pchFile, ftell(fp));
     4607            fprintf(stderr, "Error: QMatrix entry #%d of value %d for Matrix %s from scaling list file %s at file position %ld is out of range (0 to 255)\n", i, data, MatrixType[sizeIdc][listIdc], fileName.c_str(), ftell(fp));
    46174608            return true;
    46184609          }
     
    46304621            while ((!feof(fp)) && (!bFound))
    46314622            {
    4632               Char *ret = fgets(line, LINE_SIZE, fp);
    4633               Char *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType_DC[sizeIdc][listIdc]);
     4623              TChar *ret = fgets(line, LINE_SIZE, fp);
     4624              TChar *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType_DC[sizeIdc][listIdc]);
    46344625              if (findNamePosition!= NULL)
    46354626              {
     
    46404631            if (!bFound)
    46414632            {
    4642               fprintf(stderr, "Error: cannot find DC Matrix %s from scaling list file %s\n", MatrixType_DC[sizeIdc][listIdc], pchFile);
     4633              fprintf(stderr, "Error: cannot find DC Matrix %s from scaling list file %s\n", MatrixType_DC[sizeIdc][listIdc], fileName.c_str());
    46434634              return true;
    46444635            }
     
    46474638          if (fscanf(fp, "%d,", &data)!=1)
    46484639          {
    4649             fprintf(stderr, "Error: cannot read DC %s from scaling list file %s at file position %ld\n", MatrixType_DC[sizeIdc][listIdc], pchFile, ftell(fp));
     4640            fprintf(stderr, "Error: cannot read DC %s from scaling list file %s at file position %ld\n", MatrixType_DC[sizeIdc][listIdc], fileName.c_str(), ftell(fp));
    46504641            return true;
    46514642          }
    46524643          if (data<0 || data>255)
    46534644          {
    4654             fprintf(stderr, "Error: DC value %d for Matrix %s from scaling list file %s at file position %ld is out of range (0 to 255)\n", data, MatrixType[sizeIdc][listIdc], pchFile, ftell(fp));
     4645            fprintf(stderr, "Error: DC value %d for Matrix %s from scaling list file %s at file position %ld is out of range (0 to 255)\n", data, MatrixType[sizeIdc][listIdc], fileName.c_str(), ftell(fp));
    46554646            return true;
    46564647          }
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComSlice.h

    r1321 r1360  
    292292  Void       checkDcOfMatrix();
    293293  Void       processRefMatrix(UInt sizeId, UInt listId , UInt refListId );
    294   Bool       xParseScalingList(Char* pchFile);
     294  Bool       xParseScalingList(const std::string &fileName);
    295295#if NH_MV
    296296  Void       inferFrom                      ( const TComScalingList& srcScLi );
     
    14261426#endif
    14271427
    1428   template <typename T, typename S, typename U> Void xPrintArray( const Char* name, Int numElemDim1, U idx, S numElemDim2, T vec, Bool printNumber, Bool printIdx = true ) const
     1428  template <typename T, typename S, typename U> Void xPrintArray( const TChar* name, Int numElemDim1, U idx, S numElemDim2, T vec, Bool printNumber, Bool printIdx = true ) const
    14291429  {
    14301430    std::cout << std::endl;
     
    19551955#if NH_MV
    19561956  UInt             m_uiSpsMaxLatencyIncreasePlus1[MAX_TLAYER]; 
    1957   // Calling a member m_uiMaxLatencyIncrease although it is m_uiMaxLatencyIncreasePlus1 is really bad style. 
    19581957#else
    1959   UInt             m_uiMaxLatencyIncrease[MAX_TLAYER];  // Really max latency increase plus 1 (value 0 expresses no limit)
     1958  UInt             m_uiMaxLatencyIncreasePlus1[MAX_TLAYER];
    19601959#endif
    19611960
     
    21352134  Bool                   getScalingListPresentFlag() const                                               { return m_scalingListPresentFlag;                                     }
    21362135  Void                   setScalingListPresentFlag( Bool b )                                             { m_scalingListPresentFlag  = b;                                       }
    2137   Void                   setScalingList( TComScalingList *scalingList);
    21382136  TComScalingList&       getScalingList()                                                                { return m_scalingList;                                                }
    21392137  const TComScalingList& getScalingList() const                                                          { return m_scalingList;                                                }
     
    21462144  Int                    getSpsMaxLatencyPictures( Int i )  const                                       { return ( getSpsMaxNumReorderPics(i) + getSpsMaxLatencyIncreasePlus1(i)-1); }
    21472145#else
    2148   UInt                   getMaxLatencyIncrease(UInt tlayer) const                                        { return m_uiMaxLatencyIncrease[tlayer];                               }
    2149   Void                   setMaxLatencyIncrease( UInt ui , UInt tlayer)                                   { m_uiMaxLatencyIncrease[tlayer] = ui;                                 }
     2146  UInt                   getMaxLatencyIncreasePlus1(UInt tlayer) const                                   { return m_uiMaxLatencyIncreasePlus1[tlayer];                          }
     2147  Void                   setMaxLatencyIncreasePlus1( UInt ui , UInt tlayer)                              { m_uiMaxLatencyIncreasePlus1[tlayer] = ui;                            }
    21502148#endif
    21512149
     
    21662164  const TComSPSRExt&     getSpsRangeExtension() const                                                    { return m_spsRangeExtension;                                          }
    21672165  TComSPSRExt&           getSpsRangeExtension()                                                          { return m_spsRangeExtension;                                          }
    2168 
    2169   // Sequence parameter set range extension syntax
    2170   // WAS: getUseResidualRotation and setUseResidualRotation
    2171   // Now getSpsRangeExtension().getTransformSkipRotationEnabledFlag and getSpsRangeExtension().setTransformSkipRotationEnabledFlag
    2172 
    2173   // WAS: getUseSingleSignificanceMapContext and setUseSingleSignificanceMapContext
    2174   // Now: getSpsRangeExtension().getTransformSkipContextEnabledFlag and getSpsRangeExtension().setTransformSkipContextEnabledFlag
    2175 
    2176   // WAS: getUseResidualDPCM and setUseResidualDPCM
    2177   // Now: getSpsRangeExtension().getRdpcmEnabledFlag and getSpsRangeExtension().setRdpcmEnabledFlag and
    2178 
    2179   // WAS: getUseExtendedPrecision and setUseExtendedPrecision
    2180   // Now: getSpsRangeExtension().getExtendedPrecisionProcessingFlag and getSpsRangeExtension().setExtendedPrecisionProcessingFlag
    2181 
    2182   // WAS: getDisableIntraReferenceSmoothing and setDisableIntraReferenceSmoothing
    2183   // Now: getSpsRangeExtension().getIntraSmoothingDisabledFlag and getSpsRangeExtension().setIntraSmoothingDisabledFlag
    2184 
    2185   // WAS: getUseHighPrecisionPredictionWeighting and setUseHighPrecisionPredictionWeighting
    2186   // Now: getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag and getSpsRangeExtension().setHighPrecisionOffsetsEnabledFlag
    2187 
    2188   // WAS: getUseGolombRiceParameterAdaptation and setUseGolombRiceParameterAdaptation
    2189   // Now: getSpsRangeExtension().getPersistentRiceAdaptationEnabledFlag and getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag
    2190 
    2191   // WAS: getAlignCABACBeforeBypass and setAlignCABACBeforeBypass
    2192   // Now: getSpsRangeExtension().getCabacBypassAlignmentEnabledFlag and getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag
    2193 
    21942166
    21952167#if NH_MV
     
    22992271  Void    setListEntryL0( Int i, Int  val )                      { m_RefPicSetIdxL0[i] = val;                                          }
    23002272  Void    setListEntryL1( Int i, Int  val )                      { m_RefPicSetIdxL1[i] = val;                                          }
    2301 
    2302 
    2303 #endif
     2273#endif
     2274
    23042275};
     2276
    23052277
    23062278/// PPS RExt class
     
    25572529  TComPPSRExt&           getPpsRangeExtension()                                           { return m_ppsRangeExtension;                   }
    25582530
    2559   // WAS: getTransformSkipLog2MaxSize and setTransformSkipLog2MaxSize
    2560   // Now: getPpsRangeExtension().getLog2MaxTransformSkipBlockSize and getPpsRangeExtension().setLog2MaxTransformSkipBlockSize
    2561 
    2562   // WAS: getUseCrossComponentPrediction and setUseCrossComponentPrediction
    2563   // Now: getPpsRangeExtension().getCrossComponentPredictionEnabledFlag and getPpsRangeExtension().setCrossComponentPredictionEnabledFlag
    2564 
    2565   // WAS: clearChromaQpAdjTable
    2566   // Now: getPpsRangeExtension().clearChromaQpOffsetList
    2567 
    2568   // WAS: getMaxCuChromaQpAdjDepth and setMaxCuChromaQpAdjDepth
    2569   // Now: getPpsRangeExtension().getDiffCuChromaQpOffsetDepth and getPpsRangeExtension().setDiffCuChromaQpOffsetDepth
    2570 
    2571   // WAS: getChromaQpAdjTableSize
    2572   // Now: getPpsRangeExtension().getChromaQpOffsetListLen
    2573 
    2574   // WAS: getChromaQpAdjTableAt and setChromaQpAdjTableAt
    2575   // Now: getPpsRangeExtension().getChromaQpOffsetListEntry and getPpsRangeExtension().setChromaQpOffsetListEntry
    2576 
    2577   // WAS: getSaoOffsetBitShift and setSaoOffsetBitShift
    2578   // Now: getPpsRangeExtension().getLog2SaoOffsetScale and getPpsRangeExtension().setLog2SaoOffsetScale
    2579 
    25802531#if NH_MV
    25812532  Void    setLayerId( Int  val )                                                     { m_layerId = val;                                           }
     
    28762827  Int                         getPOC() const                                         { return m_iPOC;                                                }
    28772828  Int                         getSliceQp() const                                     { return m_iSliceQp;                                            }
     2829  Bool                        getUseWeightedPrediction() const                       { return( (m_eSliceType==P_SLICE && testWeightPred()) || (m_eSliceType==B_SLICE && testWeightBiPred()) ); }
    28782830  Bool                        getDependentSliceSegmentFlag() const                   { return m_dependentSliceSegmentFlag;                           }
    28792831  Void                        setDependentSliceSegmentFlag(Bool val)                 { m_dependentSliceSegmentFlag = val;                            }
     
    28922844  TComPic*                    getPic()                                               { return m_pcPic;                                               }
    28932845  TComPic*                    getRefPic( RefPicList e, Int iRefIdx)                  { return m_apcRefPicList[e][iRefIdx];                           }
    2894   Int                         getRefPOC( RefPicList e, Int iRefIdx)                  { return m_aiRefPOCList[e][iRefIdx];                            }
     2846  const TComPic*              getRefPic( RefPicList e, Int iRefIdx) const            { return m_apcRefPicList[e][iRefIdx];                           }
     2847  Int                         getRefPOC( RefPicList e, Int iRefIdx) const            { return m_aiRefPOCList[e][iRefIdx];                            }
    28952848#if NH_3D
    28962849  Bool                        getInCmpPredAvailFlag( )                 const         { return m_inCmpPredAvailFlag;                                  }
     
    31803133
    31813134  Void                        setEnableTMVPFlag( Bool   b )                          { m_enableTMVPFlag = b;                                         }
    3182   Bool                        getEnableTMVPFlag()                                    { return m_enableTMVPFlag;                                      }
     3135  Bool                        getEnableTMVPFlag() const                              { return m_enableTMVPFlag;                                      }
    31833136
    31843137  Void                        setEncCABACTableIdx( SliceType idx )                   { m_encCABACTableIdx = idx;                                     }
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TComWeightPrediction.cpp

    r1313 r1360  
    5555}
    5656
     57static inline Pel noWeightUnidir( Pel P0, Int round, Int shift, Int offset, Int clipBD)
     58{
     59  return ClipBD( ( ((P0 + IF_INTERNAL_OFFS) + round) >> shift ) + offset, clipBD );
     60}
     61
     62static inline Pel noWeightOffsetUnidir( Pel P0, Int round, Int shift, Int clipBD)
     63{
     64  return ClipBD( ( ((P0 + IF_INTERNAL_OFFS) + round) >> shift ), clipBD );
     65}
     66
     67
    5768// ====================================================================================================================
    5869// Class definition
     
    154165    const Int  shiftNum    = std::max<Int>(2, (IF_INTERNAL_PREC - clipBD));
    155166    const Int  shift       = wp0[compID].shift + shiftNum;
    156     const Int  round       = (shift > 0) ? (1<<(shift-1)) : 0;
    157167    const UInt iSrc0Stride = pcYuvSrc0->getStride(compID);
    158168    const UInt iDstStride  = pcYuvDst->getStride(compID);
     
    162172    const Int  iWidth      = uiWidth>>csx;
    163173
     174    if (w0 != 1 << wp0[compID].shift)
     175    {
     176      const Int  round       = (shift > 0) ? (1<<(shift-1)) : 0;
    164177    for (Int y = iHeight-1; y >= 0; y-- )
    165178    {
     
    178191      pSrc0 += iSrc0Stride;
    179192      pDst  += iDstStride;
     193    }
     194  }
     195    else
     196    {
     197      const Int  round       = (shiftNum > 0) ? (1<<(shiftNum-1)) : 0;
     198      if (offset == 0)
     199      {
     200        for (Int y = iHeight-1; y >= 0; y-- )
     201        {
     202          Int x = iWidth-1;
     203          for ( ; x >= 3; )
     204          {
     205            pDst[x] = noWeightOffsetUnidir(pSrc0[x], round, shiftNum, clipBD); x--;
     206            pDst[x] = noWeightOffsetUnidir(pSrc0[x], round, shiftNum, clipBD); x--;
     207            pDst[x] = noWeightOffsetUnidir(pSrc0[x], round, shiftNum, clipBD); x--;
     208            pDst[x] = noWeightOffsetUnidir(pSrc0[x], round, shiftNum, clipBD); x--;
     209          }
     210          for( ; x >= 0; x--)
     211          {
     212            pDst[x] = noWeightOffsetUnidir(pSrc0[x], round, shiftNum, clipBD);
     213          }
     214          pSrc0 += iSrc0Stride;
     215          pDst  += iDstStride;
     216        }
     217      }
     218      else
     219      {
     220        for (Int y = iHeight-1; y >= 0; y-- )
     221        {
     222          Int x = iWidth-1;
     223          for ( ; x >= 3; )
     224          {
     225            pDst[x] = noWeightUnidir(pSrc0[x], round, shiftNum, offset, clipBD); x--;
     226            pDst[x] = noWeightUnidir(pSrc0[x], round, shiftNum, offset, clipBD); x--;
     227            pDst[x] = noWeightUnidir(pSrc0[x], round, shiftNum, offset, clipBD); x--;
     228            pDst[x] = noWeightUnidir(pSrc0[x], round, shiftNum, offset, clipBD); x--;
     229          }
     230          for( ; x >= 0; x--)
     231          {
     232            pDst[x] = noWeightUnidir(pSrc0[x], round, shiftNum, offset, clipBD);
     233          }
     234          pSrc0 += iSrc0Stride;
     235          pDst  += iDstStride;
     236        }
     237      }
    180238    }
    181239  }
     
    197255        TComSlice *const pcSlice  = pcCU->getSlice();
    198256  const Bool             wpBiPred = pcCU->getSlice()->getPPS()->getWPBiPred();
    199   const Bool             bBiDir   = (iRefIdx0>=0 && iRefIdx1>=0);
    200   const Bool             bUniDir  = !bBiDir;
    201 
    202   if ( bUniDir || wpBiPred )
     257  const Bool             bBiPred  = (iRefIdx0>=0 && iRefIdx1>=0);
     258  const Bool             bUniPred = !bBiPred;
     259
     260  if ( bUniPred || wpBiPred )
    203261  { // explicit --------------------
    204262    if ( iRefIdx0 >= 0 )
     
    228286  const Bool bUseHighPrecisionPredictionWeighting = pcSlice->getSPS()->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag();
    229287
    230   if ( bBiDir )
    231   { // Bi-Dir case
     288  if ( bBiPred )
     289  { // Bi-predictive case
    232290    for ( Int yuv=0 ; yuv<numValidComponent ; yuv++ )
    233291    {
     
    248306  }
    249307  else
    250   {  // Unidir
     308  {  // UniPred
    251309    WPScalingParam *const pwp = (iRefIdx0>=0) ? wp0 : wp1 ;
    252310
  • branches/HTM-15.2-dev/source/Lib/TLibCommon/TypeDef.h

    r1356 r1360  
    3232 */
    3333/** \file     TypeDef.h
    34     \brief    Define basic types, new types and enumerations
     34    \brief    Define macros, basic types, new types and enumerations
    3535*/
    3636#ifndef __TYPEDEF__
     
    373373#define DECODER_CHECK_SUBSTREAM_AND_SLICE_TRAILING_BYTES  1 ///< TODO: integrate this macro into a broader conformance checking system.
    374374#define T0196_SELECTIVE_RDOQ                              1 ///< selective RDOQ
     375#define U0040_MODIFIED_WEIGHTEDPREDICTION_WITH_BIPRED_AND_CLIPPING 1
     376
    375377// ====================================================================================================================
    376378// Tool Switches
     
    389391#define MATRIX_MULT                                       0 ///< Brute force matrix multiplication instead of partial butterfly
    390392#define O0043_BEST_EFFORT_DECODING                        0 ///< 0 (default) = disable code related to best effort decoding, 1 = enable code relating to best effort decoding [ decode-side only ].
     393
     394#define ME_ENABLE_ROUNDING_OF_MVS                         1 ///< 0 (default) = disables rounding of motion vectors when right shifted,  1 = enables rounding
     395
    391396#define RDOQ_CHROMA_LAMBDA                                1 ///< F386: weighting of chroma for RDOQ
    392397// This can be enabled by the makefile
     
    394399#define RExt__HIGH_BIT_DEPTH_SUPPORT                                           0 ///< 0 (default) use data type definitions for 8-10 bit video, 1 = use larger data types to allow for up to 16-bit video (originally developed as part of N0188)
    395400#endif
     401
     402#define U0132_TARGET_BITS_SATURATION                      1 ///< Rate control with target bits saturation method
     403
    396404// ====================================================================================================================
    397405// Derived macros
     
    443451typedef       void                Void;
    444452typedef       bool                Bool;
    445 #ifdef __arm__
    446 typedef       signed char         Char;
    447 #else
    448 typedef       char                Char;
    449 #endif
    450 typedef       unsigned char       UChar;
     453
     454typedef       char                TChar; // Used for text/characters
     455typedef       signed char         SChar; // Signed 8-bit values
     456typedef       unsigned char       UChar; // Unsigned 8-bit values
    451457typedef       short               Short;
    452458typedef       unsigned short      UShort;
     
    577583  NUMBER_INPUT_COLOUR_SPACE_CONVERSIONS = 4
    578584};
     585
     586enum MATRIX_COEFFICIENTS // Table E.5 (Matrix coefficients)
     587{
     588  MATRIX_COEFFICIENTS_RGB                           = 0,
     589  MATRIX_COEFFICIENTS_BT709                         = 1,
     590  MATRIX_COEFFICIENTS_UNSPECIFIED                   = 2,
     591  MATRIX_COEFFICIENTS_RESERVED_BY_ITUISOIEC         = 3,
     592  MATRIX_COEFFICIENTS_USFCCT47                      = 4,
     593  MATRIX_COEFFICIENTS_BT601_625                     = 5,
     594  MATRIX_COEFFICIENTS_BT601_525                     = 6,
     595  MATRIX_COEFFICIENTS_SMPTE240                      = 7,
     596  MATRIX_COEFFICIENTS_YCGCO                         = 8,
     597  MATRIX_COEFFICIENTS_BT2020_NON_CONSTANT_LUMINANCE = 9,
     598  MATRIX_COEFFICIENTS_BT2020_CONSTANT_LUMINANCE     = 10,
     599};
     600
    579601enum DeblockEdgeDir
    580602{
     
    713735enum MESearchMethod
    714736{
    715   FULL_SEARCH                = 0,     ///< Full search
    716   DIAMOND                    = 1,     ///< Fast search
    717   SELECTIVE                  = 2      ///< Selective search
     737  MESEARCH_FULL              = 0,
     738  MESEARCH_DIAMOND           = 1,
     739  MESEARCH_SELECTIVE         = 2,
     740  MESEARCH_DIAMOND_ENHANCED  = 3,
     741  MESEARCH_NUMBER_OF_METHODS = 4
    718742};
    719743/// coefficient scanning type used in ACS
     
    760784  FIXED_NUMBER_OF_BYTES  = 2,          ///< Limit maximum number of bytes in a slice / slice segment
    761785  FIXED_NUMBER_OF_TILES  = 3,          ///< slices / slice segments span an integer number of tiles
    762 };
     786  NUMBER_OF_SLICE_CONSTRAINT_MODES = 4
     787};
     788
     789// For use with decoded picture hash SEI messages, generated by encoder.
     790enum HashType
     791{
     792  HASHTYPE_MD5             = 0,
     793  HASHTYPE_CRC             = 1,
     794  HASHTYPE_CHECKSUM        = 2,
     795  HASHTYPE_NONE            = 3,
     796  NUMBER_OF_HASHTYPES      = 4
     797};
     798
    763799enum SAOMode //mode
    764800{
     
    861897  COST_MIXED_LOSSLESS_LOSSY_CODING = 3
    862898};
     899
     900enum WeightedPredictionMethod
     901{
     902  WP_PER_PICTURE_WITH_SIMPLE_DC_COMBINED_COMPONENT                          =0,
     903  WP_PER_PICTURE_WITH_SIMPLE_DC_PER_COMPONENT                               =1,
     904  WP_PER_PICTURE_WITH_HISTOGRAM_AND_PER_COMPONENT                           =2,
     905  WP_PER_PICTURE_WITH_HISTOGRAM_AND_PER_COMPONENT_AND_CLIPPING              =3,
     906  WP_PER_PICTURE_WITH_HISTOGRAM_AND_PER_COMPONENT_AND_CLIPPING_AND_EXTENSION=4
     907};
     908
     909enum FastInterSearchMode
     910{
     911  FASTINTERSEARCH_DISABLED = 0,
     912  FASTINTERSEARCH_MODE1    = 1, // TODO: assign better names to these.
     913  FASTINTERSEARCH_MODE2    = 2,
     914  FASTINTERSEARCH_MODE3    = 3
     915};
     916
    863917enum SPSExtensionFlagIndex
    864918{
Note: See TracChangeset for help on using the changeset viewer.