source: SHVCSoftware/branches/SHM-upgrade/source/Lib/TLibEncoder/TEncEntropy.h @ 1439

Last change on this file since 1439 was 916, checked in by seregin, 10 years ago

initial porting

  • Property svn:eol-style set to native
File size: 11.0 KB
RevLine 
[313]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
[916]4 * granted under this license.
[313]5 *
[595]6 * Copyright (c) 2010-2014, ITU/ISO/IEC
[313]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.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
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 */
33
34/** \file     TEncEntropy.h
35    \brief    entropy encoder class (header)
36*/
37
38#ifndef __TENCENTROPY__
39#define __TENCENTROPY__
40
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"
[916]48#include "TLibCommon/TComChromaFormat.h"
[313]49
50class TEncSbac;
51class TEncCavlc;
52class SEI;
[713]53#if Q0048_CGS_3D_ASYMLUT
54class TEnc3DAsymLUT;
55#endif
[313]56
57// ====================================================================================================================
58// Class definition
59// ====================================================================================================================
60
61/// entropy encoder pure class
62class TEncEntropyIf
63{
64public:
65  virtual Void  resetEntropy          ()                = 0;
66  virtual Void  determineCabacInitIdx ()                = 0;
67  virtual Void  setBitstream          ( TComBitIf* p )  = 0;
68  virtual Void  setSlice              ( TComSlice* p )  = 0;
69  virtual Void  resetBits             ()                = 0;
70  virtual UInt  getNumberOfWrittenBits()                = 0;
71
72  virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
73  virtual Void  codeSPS                 ( TComSPS* pcSPS )                                      = 0;
[713]74  virtual Void  codePPS                 ( TComPPS* pcPPS
75#if Q0048_CGS_3D_ASYMLUT
76    , TEnc3DAsymLUT * pc3DAsymLUT
77#endif
78    )                                      = 0;
[313]79  virtual Void  codeSliceHeader         ( TComSlice* pcSlice )                                  = 0;
80
81  virtual Void  codeTilesWPPEntryPoint  ( TComSlice* pSlice )     = 0;
82  virtual Void  codeTerminatingBit      ( UInt uilsLast )                                       = 0;
83  virtual Void  codeSliceFinish         ()                                                      = 0;
84  virtual Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0;
85  virtual Void codeScalingList   ( TComScalingList* scalingList )      = 0;
[916]86
87#if POC_RESET_IDC_SIGNALLING
88  virtual Void codeSliceHeaderExtn     ( TComSlice* pSlice, Int shBitsWrittenTillNow )     = 0;
89#endif
90
[313]91public:
92  virtual Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
93  virtual Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
94  virtual Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
95  virtual Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
96  virtual Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
[345]97
[313]98  virtual Void codePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
99  virtual Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[916]100
[313]101  virtual Void codeIPCMInfo      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
102
103  virtual Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) = 0;
[916]104  virtual Void codeQtCbf         ( TComTU &rTu, const ComponentID compID, const Bool lowestLevel ) = 0;
[313]105  virtual Void codeQtRootCbf     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[916]106  virtual Void codeQtCbfZero     ( TComTU &rTu, const ChannelType chType ) = 0;
[313]107  virtual Void codeQtRootCbfZero ( TComDataCU* pcCU ) = 0;
108  virtual Void codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool isMultiplePU ) = 0;
[916]109
[313]110  virtual Void codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
111  virtual Void codeInterDir      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
112  virtual Void codeRefFrmIdx     ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList )      = 0;
113  virtual Void codeMvd           ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList )      = 0;
[916]114
115  virtual Void codeCrossComponentPrediction( TComTU &rTu, ComponentID compID ) = 0;
116
[313]117  virtual Void codeDeltaQP       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[916]118  virtual Void codeChromaQpAdjustment( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
119  virtual Void codeCoeffNxN      ( TComTU &rTu, TCoeff* pcCoef, const ComponentID compID ) = 0;
120  virtual Void codeTransformSkipFlags ( TComTU &rTu, ComponentID component ) = 0;
[644]121#if SVC_EXTENSION
[916]122  virtual Void codeSAOBlkParam   (SAOBlkParam& saoBlkParam, UInt* saoMaxOffsetQVal, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false)    =0;
[644]123#else
[916]124  virtual Void codeSAOBlkParam   (SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false)    =0;
[644]125#endif
[916]126  virtual Void estBit               (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType) = 0;
[313]127
128  virtual Void codeDFFlag (UInt uiCode, const Char *pSymbolName) = 0;
129  virtual Void codeDFSvlc (Int iCode, const Char *pSymbolName)   = 0;
130
[916]131  virtual Void codeExplicitRdpcmMode ( TComTU &rTu, const ComponentID compID ) = 0;
132
[313]133  virtual ~TEncEntropyIf() {}
134};
135
136/// entropy encoder class
137class TEncEntropy
138{
139public:
140  Void    setEntropyCoder           ( TEncEntropyIf* e, TComSlice* pcSlice );
141  Void    setBitstream              ( TComBitIf* p )          { m_pcEntropyCoderIf->setBitstream(p);  }
142  Void    resetBits                 ()                        { m_pcEntropyCoderIf->resetBits();      }
143  UInt    getNumberOfWrittenBits    ()                        { return m_pcEntropyCoderIf->getNumberOfWrittenBits(); }
144  Void    resetEntropy              ()                        { m_pcEntropyCoderIf->resetEntropy();  }
145  Void    determineCabacInitIdx     ()                        { m_pcEntropyCoderIf->determineCabacInitIdx(); }
[916]146
[313]147  Void    encodeSliceHeader         ( TComSlice* pcSlice );
148  Void    encodeTilesWPPEntryPoint( TComSlice* pSlice );
149  Void    encodeTerminatingBit      ( UInt uiIsLast );
150  Void    encodeSliceFinish         ();
151  TEncEntropyIf*      m_pcEntropyCoderIf;
[916]152
153#if POC_RESET_IDC_SIGNALLING
154  Void    encodeSliceHeaderExtn( TComSlice* pSlice, Int shBitsWrittenTillNow );
155#endif
[313]156public:
157  Void encodeVPS               ( TComVPS* pcVPS);
158  // SPS
159  Void encodeSPS               ( TComSPS* pcSPS );
[713]160  Void encodePPS               ( TComPPS* pcPPS
161#if Q0048_CGS_3D_ASYMLUT
162    , TEnc3DAsymLUT * pc3DAsymLUT
163#endif
164    );
[313]165  Void encodeSplitFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
166  Void encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
167  Void encodeSkipFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
[916]168  Void encodePUWise       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
[313]169  Void encodeInterDirPU   ( TComDataCU* pcSubCU, UInt uiAbsPartIdx  );
170  Void encodeRefFrmIdxPU  ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
171  Void encodeMvdPU        ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
172  Void encodeMVPIdxPU     ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
173  Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
174  Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
175  Void encodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
176  Void encodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
177  Void encodeIPCMInfo          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
[916]178  Void encodePredInfo          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
[313]179  Void encodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt absPartIdx, Bool isMultiplePU = false );
[916]180
181  Void encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx );
182
[313]183  Void encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx );
[916]184  Void encodeQtCbf             ( TComTU &rTu, const ComponentID compID, const Bool lowestLevel );
185
186  Void encodeQtCbfZero         ( TComTU &rTu, const ChannelType chType );
[313]187  Void encodeQtRootCbfZero     ( TComDataCU* pcCU );
188  Void encodeQtRootCbf         ( TComDataCU* pcCU, UInt uiAbsPartIdx );
189  Void encodeQP                ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
[916]190  Void encodeChromaQpAdjustment ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
[313]191
192  Void encodeScalingList       ( TComScalingList* scalingList );
193
[916]194  Void encodeCrossComponentPrediction( TComTU &rTu, ComponentID compID );
195
[313]196private:
[916]197  Void xEncodeTransform        ( Bool& bCodeDQP, Bool& codeChromaQpAdj, TComTU &rTu );
198
[313]199public:
[916]200  Void encodeCoeff             ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool& bCodeDQP, Bool& codeChromaQpAdj );
201
202  Void encodeCoeffNxN         ( TComTU &rTu, TCoeff* pcCoef, const ComponentID compID );
203
204  Void estimateBit             ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType );
[644]205#if SVC_EXTENSION
206  Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, UInt* saoMaxOffsetQVal, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, saoMaxOffsetQVal, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);}
207#else
[540]208  Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);}
[644]209#endif
[313]210  static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize );
211
212};// END CLASS DEFINITION TEncEntropy
213
214//! \}
215
216#endif // __TENCENTROPY__
217
Note: See TracBrowser for help on using the repository browser.