Changeset 56 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/TEncEntropy.h


Ignore:
Timestamp:
11 May 2012, 21:20:17 (12 years ago)
Author:
hschwarz
Message:

updated trunk (move to HM6.1)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibEncoder/TEncEntropy.h

    r42 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    3232 */
    3333
    34 
    35 
    3634/** \file     TEncEntropy.h
    3735    \brief    entropy encoder class (header)
     
    4139#define __TENCENTROPY__
    4240
    43 #include "../TLibCommon/TComSlice.h"
    44 #include "../TLibCommon/TComDataCU.h"
    45 #include "../TLibCommon/TComBitStream.h"
    46 #include "../TLibCommon/ContextModel.h"
    47 #include "../TLibCommon/TComPic.h"
    48 #include "../TLibCommon/TComTrQuant.h"
     41#include "TLibCommon/TComSlice.h"
     42#include "TLibCommon/TComDataCU.h"
     43#include "TLibCommon/TComBitStream.h"
     44#include "TLibCommon/ContextModel.h"
     45#include "TLibCommon/TComPic.h"
     46#include "TLibCommon/TComTrQuant.h"
     47#include "TLibCommon/TComAdaptiveLoopFilter.h"
     48#include "TLibCommon/TComSampleAdaptiveOffset.h"
     49
    4950class TEncSbac;
    5051class TEncCavlc;
     
    6566 
    6667  virtual Void  resetEntropy          ()                = 0;
     68#if CABAC_INIT_FLAG
     69  virtual Void  determineCabacInitIdx ()                = 0;
     70#endif
    6771  virtual Void  setBitstream          ( TComBitIf* p )  = 0;
    6872  virtual Void  setSlice              ( TComSlice* p )  = 0;
     
    7175  virtual UInt  getNumberOfWrittenBits()                = 0;
    7276  virtual UInt  getCoeffCost          ()                = 0;
    73  
    74 #if BITSTREAM_EXTRACTION
    75   virtual Void  codeNALUnitHeader       ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, UInt uiLayerId = 0 ) = 0;
    76 #else
    77   virtual Void  codeNALUnitHeader       ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, Bool bOutputFlag = true ) = 0;
    78 #endif
    79 
     77
     78#if HHI_MPI
     79  virtual Void  codeSPS                 ( TComSPS* pcSPS, Bool bIsDepth )                       = 0;
     80#else
    8081  virtual Void  codeSPS                 ( TComSPS* pcSPS )                                      = 0;
     82#endif
    8183  virtual Void  codePPS                 ( TComPPS* pcPPS )                                      = 0;
    8284  virtual void codeSEI(const SEI&) = 0;
    8385  virtual Void  codeSliceHeader         ( TComSlice* pcSlice )                                  = 0;
     86  virtual Void codeTileMarkerFlag      ( TComSlice* pcSlice )                                  = 0;
     87
     88#if TILES_WPP_ENTRY_POINT_SIGNALLING
     89  virtual Void  codeTilesWPPEntryPoint  ( TComSlice* pSlice )     = 0;
     90#else
     91  virtual Void  codeSliceHeaderSubstreamTable( TComSlice* pcSlice )                             = 0;
     92#endif
    8493  virtual Void  codeTerminatingBit      ( UInt uilsLast )                                       = 0;
    8594  virtual Void  codeSliceFinish         ()                                                      = 0;
     95#if OL_FLUSH
     96  virtual Void  codeFlush               ()                                                      = 0;
     97  virtual Void  encodeStart             ()                                                      = 0;
     98#endif
    8699 
    87100  virtual Void codeAlfCtrlDepth() = 0;
     101#if HHI_INTER_VIEW_MOTION_PRED
     102  virtual Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ) = 0;
     103#else
    88104  virtual Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0;
    89  
    90   virtual Void codeViewIdx( Int iViewIdx ) = 0;
    91 
     105#endif
     106  virtual Void codeScalingList   ( TComScalingList* scalingList )      = 0;
     107 
    92108public:
    93109  virtual Void codeAlfCtrlFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
     110  virtual Void codeApsExtensionFlag () = 0;
    94111 
    95112  virtual Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
     
    104121  virtual Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    105122 
     123#if BURST_IPCM
     124  virtual Void codeIPCMInfo      ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag) = 0;
     125#else
     126  virtual Void codeIPCMInfo      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
     127#endif
     128
    106129  virtual Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) = 0;
    107130  virtual Void codeQtCbf         ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) = 0;
     
    114137  virtual Void codeMvd           ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList )      = 0;
    115138  virtual Void codeDeltaQP       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
    116   virtual Void codeCbf           ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) = 0;
    117   virtual Void codeBlockCbf      ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiQPartNum, Bool bRD = false) = 0;
    118 #if CAVLC_RQT_CBP
    119   virtual Void codeCbfTrdiv      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    120   virtual UInt xGetFlagPattern   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    121 #endif
    122   virtual Void codeCoeffNxN      ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType, Bool bRD = false ) = 0;
     139  virtual Void codeCoeffNxN      ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) = 0;
    123140 
    124141  virtual Void codeAlfFlag          ( UInt uiCode ) = 0;
    125142  virtual Void codeAlfUvlc          ( UInt uiCode ) = 0;
    126143  virtual Void codeAlfSvlc          ( Int   iCode ) = 0;
    127 #if TSB_ALF_HEADER
    128   virtual Void codeAlfFlagNum       ( UInt uiCode, UInt minValue ) = 0;
     144#if LCU_SYNTAX_ALF
     145  virtual Void codeAlfFixedLengthIdx( UInt idx, UInt numFilterSetsInBuffer) = 0;
     146  virtual Void codeAPSAlflag(UInt uiCode) = 0;
     147#endif
     148  /// set slice granularity
     149  virtual Void setSliceGranularity(Int iSliceGranularity) = 0;
     150
     151  /// get slice granularity
     152  virtual Int  getSliceGranularity()                      = 0;
     153
    129154  virtual Void codeAlfCtrlFlag      ( UInt uiSymbol ) = 0;
    130 #endif
    131 #if MTK_SAO
    132   virtual Void codeAoFlag          ( UInt uiCode ) = 0;
    133   virtual Void codeAoUvlc          ( UInt uiCode ) = 0;
    134   virtual Void codeAoSvlc          ( Int   iCode ) = 0;
    135 #endif
    136   virtual Void estBit               (estBitsSbacStruct* pcEstBitsSbac, UInt uiCTXIdx, TextType eTType) = 0;
    137  
     155  virtual Void codeSaoFlag          ( UInt uiCode ) = 0;
     156  virtual Void codeSaoUvlc          ( UInt uiCode ) = 0;
     157  virtual Void codeSaoSvlc          ( Int   iCode ) = 0;
     158#if SAO_UNIT_INTERLEAVING
     159  virtual Void codeSaoRun          ( UInt   uiCode, UInt uiMaxValue  ) = 0;
     160  virtual Void codeSaoMergeLeft    ( UInt   uiCode, UInt uiCompIdx  ) = 0;
     161  virtual Void codeSaoMergeUp      ( UInt   uiCode) = 0;
     162  virtual Void codeSaoTypeIdx      ( UInt   uiCode) = 0;
     163  virtual Void codeSaoUflc         ( UInt   uiCode) = 0;
     164#endif
     165  virtual Void estBit               (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) = 0;
     166 
     167  virtual Void updateContextTables ( SliceType eSliceType, Int iQp, Bool bExecuteFinish )   = 0;
     168  virtual Void updateContextTables ( SliceType eSliceType, Int iQp )   = 0;
     169  virtual Void writeTileMarker             ( UInt uiTileIdx, UInt uiBitsUsed ) = 0;
     170
     171  virtual Void codeAPSInitInfo  (TComAPS* pcAPS)= 0;
     172  virtual Void codeFinish       (Bool bEnd)= 0;
     173
     174  virtual Void codeDFFlag (UInt uiCode, const Char *pSymbolName) = 0;
     175  virtual Void codeDFSvlc (Int iCode, const Char *pSymbolName)   = 0;
     176
    138177  virtual ~TEncEntropyIf() {}
     178
    139179};
    140180
     
    142182class TEncEntropy
    143183{
     184private:
     185  UInt    m_uiBakAbsPartIdx;
     186  UInt    m_uiBakChromaOffset;
     187#if UNIFIED_TRANSFORM_TREE
     188  UInt    m_bakAbsPartIdxCU;
     189#endif
     190
    144191public:
    145192  Void    setEntropyCoder           ( TEncEntropyIf* e, TComSlice* pcSlice );
     
    150197  UInt    getCoeffCost              ()                        { return  m_pcEntropyCoderIf->getCoeffCost(); }
    151198  Void    resetEntropy              ()                        { m_pcEntropyCoderIf->resetEntropy();  }
     199#if CABAC_INIT_FLAG
     200  Void    determineCabacInitIdx     ()                        { m_pcEntropyCoderIf->determineCabacInitIdx(); }
     201#endif
    152202 
    153203  Void    encodeSliceHeader         ( TComSlice* pcSlice );
     204  Void    encodeTileMarkerFlag       (TComSlice* pcSlice) {m_pcEntropyCoderIf->codeTileMarkerFlag(pcSlice);}
     205#if TILES_WPP_ENTRY_POINT_SIGNALLING
     206  Void    encodeTilesWPPEntryPoint( TComSlice* pSlice );
     207#else
     208  Void    encodeSliceHeaderSubstreamTable( TComSlice* pcSlice );
     209#endif
    154210  Void    encodeTerminatingBit      ( UInt uiIsLast );
    155211  Void    encodeSliceFinish         ();
    156  
     212#if OL_FLUSH
     213  Void    encodeFlush               ();
     214  Void    encodeStart               ();
     215#endif
     216#if LCU_SYNTAX_ALF
     217  Void encodeAlfFlag(UInt code) {m_pcEntropyCoderIf->codeAlfFlag(code);}
     218  Void encodeAlfStoredFilterSetIdx(UInt idx, UInt numFilterSetsInBuffer);
     219  Void encodeAlfFixedLengthRun(UInt run, UInt rx, UInt numLCUInWidth);
     220  Void encodeAlfParam(AlfParamSet* pAlfParamSet, Bool bSentInAPS = true, Int firstLCUAddr = 0, Bool alfAcrossSlice= true);
     221  Void encodeAlfParamSet(AlfParamSet* pAlfParamSet, Int numLCUInWidth, Int numLCU, Int firstLCUAddr, Bool alfAcrossSlice, Int startCompIdx, Int endCompIdx);
     222  Bool getAlfRepeatRowFlag(Int compIdx, AlfParamSet* pAlfParamSet, Int lcuIdx, Int lcuPos, Int startlcuPosX, Int endlcuPosX, Int numLCUInWidth);
     223  Int  getAlfRun(Int compIdx, AlfParamSet* pAlfParamSet, Int lcuIdxInSlice, Int lcuPos, Int startlcuPosX, Int endlcuPosX);
     224  Void encodeAPSAlfFlag(UInt code) {m_pcEntropyCoderIf->codeAPSAlflag(code);}
     225#endif 
    157226  Void encodeAlfParam(ALFParam* pAlfParam);
    158   Void encodeMVPIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Bool bRD = false );
    159  
    160   Void encodeViewIdx(Int iViewIdx );
    161 
     227 
    162228  TEncEntropyIf*      m_pcEntropyCoderIf;
    163229 
    164230public:
    165231  // SPS
     232#if HHI_MPI
     233  Void encodeSPS               ( TComSPS* pcSPS, Bool bIsDepth );
     234#else
    166235  Void encodeSPS               ( TComSPS* pcSPS );
     236#endif
    167237  Void encodePPS               ( TComPPS* pcPPS );
    168238  void encodeSEI(const SEI&);
     
    180250  Void encodeMVPIdxPU     ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
    181251  Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx );
    182 #if HHI_MRG_SKIP
    183252  Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD = false );
    184 #else
    185   Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx );
    186 #endif
    187253#if HHI_INTER_VIEW_RESIDUAL_PRED
    188254  Void encodeResPredFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD = false );
    189255#endif
    190256  Void encodeAlfCtrlFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    191 #if TSB_ALF_HEADER
    192   Void encodeAlfCtrlParam      ( ALFParam *pAlfParam );
    193 #endif
     257
     258  /// set slice granularity
     259  Void setSliceGranularity (Int iSliceGranularity) {m_pcEntropyCoderIf->setSliceGranularity(iSliceGranularity);}
     260
     261  /// encode ALF CU control flag
     262  Void encodeAlfCtrlFlag(UInt uiFlag);
     263 
     264  Void encodeApsExtensionFlag() {m_pcEntropyCoderIf->codeApsExtensionFlag();};
     265
     266  Void encodeAlfCtrlParam(AlfCUCtrlInfo& cAlfParam, Int iNumCUsInPic);
     267
    194268  Void encodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    195269  Void encodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
    196  
     270  Void encodeIPCMInfo          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    197271  Void encodePredInfo          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    198272  Void encodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    199273 
    200274  Void encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    201   Void encodeInterDir          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    202   Void encodeRefFrmIdx         ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Bool bRD = false );
    203   Void encodeMvd               ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Bool bRD = false );
    204  
     275 
     276#if !UNIFIED_TRANSFORM_TREE
    205277  Void encodeTransformIdx      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
     278#endif
    206279  Void encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx );
    207280  Void encodeQtCbf             ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth );
    208281  Void encodeQtRootCbf         ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    209282  Void encodeQP                ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    210  
     283  Void updateContextTables     ( SliceType eSliceType, Int iQp, Bool bExecuteFinish )   { m_pcEntropyCoderIf->updateContextTables( eSliceType, iQp, bExecuteFinish );     }
     284  Void updateContextTables     ( SliceType eSliceType, Int iQp )                        { m_pcEntropyCoderIf->updateContextTables( eSliceType, iQp, true );               }
     285  Void writeTileMarker              ( UInt uiTileIdx, UInt uiBitsUsed ) { m_pcEntropyCoderIf->writeTileMarker( uiTileIdx, uiBitsUsed ); }
     286 
     287  Void encodeAPSInitInfo          (TComAPS* pcAPS) {m_pcEntropyCoderIf->codeAPSInitInfo(pcAPS);}
     288  Void encodeFinish               (Bool bEnd) {m_pcEntropyCoderIf->codeFinish(bEnd);}
     289  Void encodeScalingList       ( TComScalingList* scalingList );
     290  Void encodeDFParams          (TComAPS* pcAPS);
     291
    211292private:
    212   Void xEncodeTransformSubdiv  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 );
    213   Void xEncodeCoeff            ( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, TextType eType, Bool bRD = false );
    214 public:
    215   Void encodeCoeff             ( TComDataCU* pcCU                 , UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight );
    216   Void encodeCoeff             ( TComDataCU* pcCU, TCoeff* pCoeff , UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiMaxTrMode, UInt uiTrMode, TextType eType, Bool bRD = false );
    217  
    218   Void encodeCoeffNxN         ( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiTrWidth, UInt uiTrHeight, UInt uiDepth, TextType eType, Bool bRD = false );
    219  
    220   Void estimateBit             ( estBitsSbacStruct* pcEstBitsSbac, UInt uiWidth, TextType eTType);
     293#if UNIFIED_TRANSFORM_TREE
     294  Void xEncodeTransform        ( TComDataCU* pcCU,UInt offsetLumaOffset, UInt offsetChroma, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3, Bool& bCodeDQP );
     295#else
     296  Void xEncodeTransformSubdiv  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 );
     297  Void xEncodeCoeff            ( TComDataCU* pcCU, UInt uiLumaOffset, UInt uiChromaOffset, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, Bool& bCodeDQP );
     298#endif // !UNIFIED_TRANSFORM_TREE
     299public:
     300  Void encodeCoeff             ( TComDataCU* pcCU,                 UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP );
     301 
     302  Void encodeCoeffNxN         ( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiTrWidth, UInt uiTrHeight, UInt uiDepth, TextType eType );
     303 
     304  Void estimateBit             ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType);
    221305 
    222306  // ALF-related
     
    226310  Void codeFilt (ALFParam* pAlfParam);
    227311  Int codeFilterCoeff(ALFParam* ALFp);
    228   Int writeFilterCodingParams(int minKStart, int maxScanVal, int kMinTab[]);
     312  Int writeFilterCodingParams(int minKStart, int minScanVal, int maxScanVal, int kMinTab[]);
     313
    229314  Int writeFilterCoeffs(int sqrFiltLength, int filters_per_group, int pDepthInt[],
    230315                        int **FilterCoeff, int kMinTab[]);
    231316  Int golombEncode(int coeff, int k);
    232317  Int lengthGolomb(int coeffVal, int k);
    233 #if MTK_SAO
    234   Void    encodeQAOOnePart(SAOParam* pQaoParam, Int part_idx);
    235   Void    encodeQuadTreeSplitFlag(SAOParam* pQaoParam, Int part_idx);
    236   Void    encodeSaoParam(SAOParam* pQaoParam) ;
    237 #endif
     318#if SAO_UNIT_INTERLEAVING
     319  Void    encodeSaoUnit(Int rx, Int ry, Int compIdx, SAOParam* saoParam, Int repeatedRow);
     320  Void    encodeSaoOffset(SaoLcuParam* saoLcuParam);
     321  Void    encodeSaoUnitInterleaving(Int rx, Int ry, SAOParam* saoParam, TComDataCU* cu, Int cuAddrInSlice, Int cuAddrUpInSlice, Bool lfCrossSliceBoundaryFlag);
     322  Void    encodeSaoParam         (TComAPS*  aps);
     323#else
     324  Void    encodeSaoOnePart       (SAOParam* pSaoParam, Int iPartIdx, Int iYCbCr);
     325  Void    encodeQuadTreeSplitFlag(SAOParam* pSaoParam, Int iPartIdx, Int iYCbCr);
     326  Void    encodeSaoParam         (SAOParam* pSaoParam);
     327#endif
     328
     329  static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize );
    238330
    239331};// END CLASS DEFINITION TEncEntropy
    240332
     333//! \}
    241334
    242335#endif // __TENCENTROPY__
Note: See TracChangeset for help on using the changeset viewer.