source: 3DVCSoftware/branches/HTM-13.1-dev1-Samsung/source/Lib/TLibEncoder/TEncEntropy.h

Last change on this file was 1145, checked in by samsung-htm, 10 years ago

Integration of K0033: Depth intra skip (DIS) mode

  • Property svn:eol-style set to native
File size: 12.3 KB
RevLine 
[5]1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
[56]4 * granted under this license. 
[5]5 *
[872]6* Copyright (c) 2010-2014, ITU/ISO/IEC
[5]7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
[56]17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
[5]18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
[2]33
34/** \file     TEncEntropy.h
35    \brief    entropy encoder class (header)
36*/
37
38#ifndef __TENCENTROPY__
39#define __TENCENTROPY__
40
[56]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/TComSampleAdaptiveOffset.h"
48
[2]49class TEncSbac;
50class TEncCavlc;
51class SEI;
52
53// ====================================================================================================================
54// Class definition
55// ====================================================================================================================
56
57/// entropy encoder pure class
58class TEncEntropyIf
59{
60public:
61  virtual Void  resetEntropy          ()                = 0;
[56]62  virtual Void  determineCabacInitIdx ()                = 0;
[2]63  virtual Void  setBitstream          ( TComBitIf* p )  = 0;
64  virtual Void  setSlice              ( TComSlice* p )  = 0;
65  virtual Void  resetBits             ()                = 0;
66  virtual Void  resetCoeffCost        ()                = 0;
67  virtual UInt  getNumberOfWrittenBits()                = 0;
68  virtual UInt  getCoeffCost          ()                = 0;
[56]69
[100]70  virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
[1124]71  virtual Void  codeSPS                 ( TComSPS* pcSPS )                                      = 0;
[2]72  virtual Void  codePPS                 ( TComPPS* pcPPS )                                      = 0;
73  virtual Void  codeSliceHeader         ( TComSlice* pcSlice )                                  = 0;
[56]74
75  virtual Void  codeTilesWPPEntryPoint  ( TComSlice* pSlice )     = 0;
[2]76  virtual Void  codeTerminatingBit      ( UInt uilsLast )                                       = 0;
77  virtual Void  codeSliceFinish         ()                                                      = 0;
78  virtual Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0;
[56]79  virtual Void codeScalingList   ( TComScalingList* scalingList )      = 0;
[2]80 
81public:
[608]82  virtual Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[2]83  virtual Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[1145]84#if SEC_DEPTH_INTRA_SKIP_MODE_K0033
85  virtual Void codeDIS          ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
86#else
[1084]87#if H_3D_SINGLE_DEPTH
[1039]88  virtual Void codeSingleDepthMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
89#endif
[1145]90#endif
[2]91  virtual Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
92  virtual Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[608]93#if H_3D_ARP
94  virtual Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[5]95#endif
[608]96#if H_3D_IC
97  virtual Void codeICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[443]98#endif
[655]99#if H_3D_INTER_SDC
[833]100  virtual Void codeDeltaDC       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
101  virtual Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[608]102#endif
[833]103#if H_3D_DBBP
104  virtual Void codeDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
105#endif
[2]106  virtual Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
107 
108  virtual Void codePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
109  virtual Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
110 
[608]111  virtual Void codeIPCMInfo      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[56]112
[2]113  virtual Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) = 0;
114  virtual Void codeQtCbf         ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) = 0;
115  virtual Void codeQtRootCbf     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[608]116  virtual Void codeQtCbfZero     ( TComDataCU* pcCU, TextType eType, UInt uiTrDepth ) = 0;
117  virtual Void codeQtRootCbfZero ( TComDataCU* pcCU ) = 0;
118  virtual Void codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool isMultiplePU ) = 0;
[2]119 
120  virtual Void codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
121  virtual Void codeInterDir      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
122  virtual Void codeRefFrmIdx     ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList )      = 0;
123  virtual Void codeMvd           ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList )      = 0;
124  virtual Void codeDeltaQP       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[56]125  virtual Void codeCoeffNxN      ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) = 0;
[608]126  virtual Void codeTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, TextType eTType ) = 0;
[872]127  virtual Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false)    =0;
[56]128  virtual Void estBit               (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) = 0;
[2]129 
[56]130  virtual Void updateContextTables ( SliceType eSliceType, Int iQp, Bool bExecuteFinish )   = 0;
131  virtual Void updateContextTables ( SliceType eSliceType, Int iQp )   = 0;
132
133  virtual Void codeDFFlag (UInt uiCode, const Char *pSymbolName) = 0;
134  virtual Void codeDFSvlc (Int iCode, const Char *pSymbolName)   = 0;
135
[2]136  virtual ~TEncEntropyIf() {}
[56]137
[2]138};
139
140/// entropy encoder class
141class TEncEntropy
142{
[56]143private:
144  UInt    m_uiBakAbsPartIdx;
145  UInt    m_uiBakChromaOffset;
146  UInt    m_bakAbsPartIdxCU;
147
[2]148public:
149  Void    setEntropyCoder           ( TEncEntropyIf* e, TComSlice* pcSlice );
150  Void    setBitstream              ( TComBitIf* p )          { m_pcEntropyCoderIf->setBitstream(p);  }
151  Void    resetBits                 ()                        { m_pcEntropyCoderIf->resetBits();      }
152  Void    resetCoeffCost            ()                        { m_pcEntropyCoderIf->resetCoeffCost(); }
153  UInt    getNumberOfWrittenBits    ()                        { return m_pcEntropyCoderIf->getNumberOfWrittenBits(); }
154  UInt    getCoeffCost              ()                        { return  m_pcEntropyCoderIf->getCoeffCost(); }
155  Void    resetEntropy              ()                        { m_pcEntropyCoderIf->resetEntropy();  }
[56]156  Void    determineCabacInitIdx     ()                        { m_pcEntropyCoderIf->determineCabacInitIdx(); }
[2]157 
158  Void    encodeSliceHeader         ( TComSlice* pcSlice );
[56]159  Void    encodeTilesWPPEntryPoint( TComSlice* pSlice );
[2]160  Void    encodeTerminatingBit      ( UInt uiIsLast );
161  Void    encodeSliceFinish         ();
162  TEncEntropyIf*      m_pcEntropyCoderIf;
163 
164public:
[100]165  Void encodeVPS               ( TComVPS* pcVPS);
[2]166  // SPS
[1124]167  Void encodeSPS               ( TComSPS* pcSPS );
[2]168  Void encodePPS               ( TComPPS* pcPPS );
169  Void encodeSplitFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
[608]170  Void encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
[2]171  Void encodeSkipFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
[1145]172#if SEC_DEPTH_INTRA_SKIP_MODE_K0033
173  Void encodeDIS               ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD=false );
174#else
[1084]175#if H_3D_SINGLE_DEPTH
[1039]176  Void encodeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD=false );
177#endif
[1145]178#endif
[2]179  Void encodePUWise       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
180  Void encodeInterDirPU   ( TComDataCU* pcSubCU, UInt uiAbsPartIdx  );
181  Void encodeRefFrmIdxPU  ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
182  Void encodeMvdPU        ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
183  Void encodeMVPIdxPU     ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
[608]184  Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
185  Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
186#if H_3D_ARP
187  Void encodeARPW         ( TComDataCU* pcCU, UInt uiAbspartIdx );
[443]188#endif
[608]189#if H_3D_IC
190  Void encodeICFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
191#endif
[655]192#if H_3D_INTER_SDC
[833]193  Void encodeDeltaDC      ( TComDataCU* pcCU, UInt absPartIdx );
194  Void encodeSDCFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
[608]195#endif
[833]196#if H_3D_DBBP
197  Void encodeDBBPFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
198#endif
[2]199  Void encodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
200  Void encodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
[56]201  Void encodeIPCMInfo          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
[608]202  Void encodePredInfo          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
203  Void encodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt absPartIdx, Bool isMultiplePU = false );
[2]204 
205  Void encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
206 
207  Void encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx );
208  Void encodeQtCbf             ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth );
[608]209  Void encodeQtCbfZero         ( TComDataCU* pcCU, TextType eType, UInt uiTrDepth );
210  Void encodeQtRootCbfZero     ( TComDataCU* pcCU );
[2]211  Void encodeQtRootCbf         ( TComDataCU* pcCU, UInt uiAbsPartIdx );
212  Void encodeQP                ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
[56]213  Void updateContextTables     ( SliceType eSliceType, Int iQp, Bool bExecuteFinish )   { m_pcEntropyCoderIf->updateContextTables( eSliceType, iQp, bExecuteFinish );     }
214  Void updateContextTables     ( SliceType eSliceType, Int iQp )                        { m_pcEntropyCoderIf->updateContextTables( eSliceType, iQp, true );               }
[608]215
[56]216  Void encodeScalingList       ( TComScalingList* scalingList );
217
[2]218private:
[608]219  Void xEncodeTransform        ( TComDataCU* pcCU,UInt offsetLumaOffset, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP );
[2]220public:
[56]221  Void encodeCoeff             ( TComDataCU* pcCU,                 UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP );
[2]222 
[56]223  Void encodeCoeffNxN         ( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiTrWidth, UInt uiTrHeight, UInt uiDepth, TextType eType );
[2]224 
[56]225  Void estimateBit             ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType);
[872]226  Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);}
[56]227  static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize );
228
[2]229};// END CLASS DEFINITION TEncEntropy
230
[56]231//! \}
[2]232
233#endif // __TENCENTROPY__
234
Note: See TracBrowser for help on using the repository browser.