source: 3DVCSoftware/branches/0.2-poznan-univ/source/Lib/TLibEncoder/TEncEntropy.h

Last change on this file was 5, checked in by hhi, 13 years ago

Clean version with cfg-files

  • Property svn:eol-style set to native
File size: 12.5 KB
Line 
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
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2011, ISO/IEC
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 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
35
36/** \file     TEncEntropy.h
37    \brief    entropy encoder class (header)
38*/
39
40#ifndef __TENCENTROPY__
41#define __TENCENTROPY__
42
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"
49class TEncSbac;
50class TEncCavlc;
51class SEI;
52
53// ====================================================================================================================
54// Class definition
55// ====================================================================================================================
56
57/// entropy encoder pure class
58class TEncEntropyIf
59{
60public:
61  virtual Bool getAlfCtrl()                = 0;
62  virtual UInt getMaxAlfCtrlDepth()                = 0;
63  virtual Void setAlfCtrl(Bool bAlfCtrl)                = 0;
64  virtual Void setMaxAlfCtrlDepth(UInt uiMaxAlfCtrlDepth)                = 0;
65 
66  virtual Void  resetEntropy          ()                = 0;
67  virtual Void  setBitstream          ( TComBitIf* p )  = 0;
68  virtual Void  setSlice              ( TComSlice* p )  = 0;
69  virtual Void  resetBits             ()                = 0;
70  virtual Void  resetCoeffCost        ()                = 0;
71  virtual UInt  getNumberOfWrittenBits()                = 0;
72  virtual UInt  getCoeffCost          ()                = 0;
73 
74  virtual Void  codeNALUnitHeader       ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, Bool bOutputFlag = true ) = 0;
75
76  virtual Void  codeSPS                 ( TComSPS* pcSPS )                                      = 0;
77  virtual Void  codePPS                 ( TComPPS* pcPPS )                                      = 0;
78  virtual void codeSEI(const SEI&) = 0;
79  virtual Void  codeSliceHeader         ( TComSlice* pcSlice )                                  = 0;
80  virtual Void  codeTerminatingBit      ( UInt uilsLast )                                       = 0;
81  virtual Void  codeSliceFinish         ()                                                      = 0;
82 
83  virtual Void codeAlfCtrlDepth() = 0;
84  virtual Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0;
85 
86  virtual Void codeViewIdx( Int iViewIdx ) = 0;
87
88public:
89  virtual Void codeAlfCtrlFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
90 
91  virtual Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
92  virtual Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
93  virtual Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
94#if HHI_INTER_VIEW_RESIDUAL_PRED
95  virtual Void codeResPredFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
96#endif
97  virtual Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
98 
99  virtual Void codePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
100  virtual Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
101 
102  virtual Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) = 0;
103  virtual Void codeQtCbf         ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) = 0;
104  virtual Void codeQtRootCbf     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
105  virtual Void codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
106 
107  virtual Void codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
108  virtual Void codeInterDir      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
109  virtual Void codeRefFrmIdx     ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList )      = 0;
110  virtual Void codeMvd           ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList )      = 0;
111  virtual Void codeDeltaQP       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
112  virtual Void codeCbf           ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) = 0;
113  virtual Void codeBlockCbf      ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiQPartNum, Bool bRD = false) = 0;
114#if CAVLC_RQT_CBP
115  virtual Void codeCbfTrdiv      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
116  virtual UInt xGetFlagPattern   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
117#endif
118  virtual Void codeCoeffNxN      ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType, Bool bRD = false ) = 0;
119 
120  virtual Void codeAlfFlag          ( UInt uiCode ) = 0;
121  virtual Void codeAlfUvlc          ( UInt uiCode ) = 0;
122  virtual Void codeAlfSvlc          ( Int   iCode ) = 0;
123#if TSB_ALF_HEADER
124  virtual Void codeAlfFlagNum       ( UInt uiCode, UInt minValue ) = 0;
125  virtual Void codeAlfCtrlFlag      ( UInt uiSymbol ) = 0;
126#endif
127#if MTK_SAO
128  virtual Void codeAoFlag          ( UInt uiCode ) = 0;
129  virtual Void codeAoUvlc          ( UInt uiCode ) = 0;
130  virtual Void codeAoSvlc          ( Int   iCode ) = 0;
131#endif
132  virtual Void estBit               (estBitsSbacStruct* pcEstBitsSbac, UInt uiCTXIdx, TextType eTType) = 0;
133 
134  virtual ~TEncEntropyIf() {}
135};
136
137/// entropy encoder class
138class TEncEntropy
139{
140public:
141  Void    setEntropyCoder           ( TEncEntropyIf* e, TComSlice* pcSlice );
142  Void    setBitstream              ( TComBitIf* p )          { m_pcEntropyCoderIf->setBitstream(p);  }
143  Void    resetBits                 ()                        { m_pcEntropyCoderIf->resetBits();      }
144  Void    resetCoeffCost            ()                        { m_pcEntropyCoderIf->resetCoeffCost(); }
145  UInt    getNumberOfWrittenBits    ()                        { return m_pcEntropyCoderIf->getNumberOfWrittenBits(); }
146  UInt    getCoeffCost              ()                        { return  m_pcEntropyCoderIf->getCoeffCost(); }
147  Void    resetEntropy              ()                        { m_pcEntropyCoderIf->resetEntropy();  }
148 
149  Void    encodeSliceHeader         ( TComSlice* pcSlice );
150  Void    encodeTerminatingBit      ( UInt uiIsLast );
151  Void    encodeSliceFinish         ();
152 
153  Void encodeAlfParam(ALFParam* pAlfParam);
154  Void encodeMVPIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Bool bRD = false );
155 
156  Void encodeViewIdx(Int iViewIdx );
157
158  TEncEntropyIf*      m_pcEntropyCoderIf;
159 
160public:
161  // SPS
162  Void encodeSPS               ( TComSPS* pcSPS );
163  Void encodePPS               ( TComPPS* pcPPS );
164  void encodeSEI(const SEI&);
165  Bool getAlfCtrl() {return m_pcEntropyCoderIf->getAlfCtrl();}
166  UInt getMaxAlfCtrlDepth() {return m_pcEntropyCoderIf->getMaxAlfCtrlDepth();}
167  Void setAlfCtrl(Bool bAlfCtrl) {m_pcEntropyCoderIf->setAlfCtrl(bAlfCtrl);}
168  Void setMaxAlfCtrlDepth(UInt uiMaxAlfCtrlDepth) {m_pcEntropyCoderIf->setMaxAlfCtrlDepth(uiMaxAlfCtrlDepth);}
169 
170  Void encodeSplitFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
171  Void encodeSkipFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
172  Void encodePUWise       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
173  Void encodeInterDirPU   ( TComDataCU* pcSubCU, UInt uiAbsPartIdx  );
174  Void encodeRefFrmIdxPU  ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
175  Void encodeMvdPU        ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
176  Void encodeMVPIdxPU     ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
177  Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx );
178#if HHI_MRG_SKIP
179  Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD = false );
180#else
181  Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx );
182#endif
183#if HHI_INTER_VIEW_RESIDUAL_PRED
184  Void encodeResPredFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD = false );
185#endif
186  Void encodeAlfCtrlFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
187#if TSB_ALF_HEADER
188  Void encodeAlfCtrlParam      ( ALFParam *pAlfParam );
189#endif
190  Void encodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
191  Void encodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
192 
193  Void encodePredInfo          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
194  Void encodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
195 
196  Void encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
197  Void encodeInterDir          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
198  Void encodeRefFrmIdx         ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Bool bRD = false );
199  Void encodeMvd               ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Bool bRD = false );
200 
201  Void encodeTransformIdx      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
202  Void encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx );
203  Void encodeQtCbf             ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth );
204  Void encodeQtRootCbf         ( TComDataCU* pcCU, UInt uiAbsPartIdx );
205  Void encodeQP                ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
206 
207private:
208  Void xEncodeTransformSubdiv  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 );
209  Void xEncodeCoeff            ( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, TextType eType, Bool bRD = false );
210public:
211  Void encodeCoeff             ( TComDataCU* pcCU                 , UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight );
212  Void encodeCoeff             ( TComDataCU* pcCU, TCoeff* pCoeff , UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiMaxTrMode, UInt uiTrMode, TextType eType, Bool bRD = false );
213 
214  Void encodeCoeffNxN         ( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiTrWidth, UInt uiTrHeight, UInt uiDepth, TextType eType, Bool bRD = false );
215 
216  Void estimateBit             ( estBitsSbacStruct* pcEstBitsSbac, UInt uiWidth, TextType eTType);
217 
218  // ALF-related
219  Void codeAuxCountBit(ALFParam* pAlfParam, Int64* ruiRate);
220  Void codeFiltCountBit(ALFParam* pAlfParam, Int64* ruiRate);
221  Void codeAux (ALFParam* pAlfParam);
222  Void codeFilt (ALFParam* pAlfParam);
223  Int codeFilterCoeff(ALFParam* ALFp);
224  Int writeFilterCodingParams(int minKStart, int maxScanVal, int kMinTab[]);
225  Int writeFilterCoeffs(int sqrFiltLength, int filters_per_group, int pDepthInt[], 
226                        int **FilterCoeff, int kMinTab[]);
227  Int golombEncode(int coeff, int k);
228  Int lengthGolomb(int coeffVal, int k);
229#if MTK_SAO
230  Void    encodeQAOOnePart(SAOParam* pQaoParam, Int part_idx);
231  Void    encodeQuadTreeSplitFlag(SAOParam* pQaoParam, Int part_idx);
232  Void    encodeSaoParam(SAOParam* pQaoParam) ;
233#endif
234
235};// END CLASS DEFINITION TEncEntropy
236
237
238#endif // __TENCENTROPY__
239
Note: See TracBrowser for help on using the repository browser.