source: 3DVCSoftware/trunk/source/Lib/TLibEncoder/TEncEntropy.h @ 46

Last change on this file since 46 was 42, checked in by tech, 13 years ago

Nokia (Flexible Coding Order)
Ericsson ( High Level Syntax )
changes

  • Property svn:eol-style set to native
File size: 12.7 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
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 */
[2]33
34
[5]35
[2]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 
[42]74#if BITSTREAM_EXTRACTION
75  virtual Void  codeNALUnitHeader       ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, UInt uiLayerId = 0 ) = 0;
76#else
[2]77  virtual Void  codeNALUnitHeader       ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, Bool bOutputFlag = true ) = 0;
[42]78#endif
[2]79
80  virtual Void  codeSPS                 ( TComSPS* pcSPS )                                      = 0;
81  virtual Void  codePPS                 ( TComPPS* pcPPS )                                      = 0;
82  virtual void codeSEI(const SEI&) = 0;
83  virtual Void  codeSliceHeader         ( TComSlice* pcSlice )                                  = 0;
84  virtual Void  codeTerminatingBit      ( UInt uilsLast )                                       = 0;
85  virtual Void  codeSliceFinish         ()                                                      = 0;
86 
87  virtual Void codeAlfCtrlDepth() = 0;
88  virtual Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) = 0;
89 
90  virtual Void codeViewIdx( Int iViewIdx ) = 0;
91
92public:
93  virtual Void codeAlfCtrlFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
94 
95  virtual Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
96  virtual Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
97  virtual Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[5]98#if HHI_INTER_VIEW_RESIDUAL_PRED
[2]99  virtual Void codeResPredFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
[5]100#endif
[2]101  virtual Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
102 
103  virtual Void codePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
104  virtual Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
105 
106  virtual Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) = 0;
107  virtual Void codeQtCbf         ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) = 0;
108  virtual Void codeQtRootCbf     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
109  virtual Void codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
110 
111  virtual Void codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
112  virtual Void codeInterDir      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
113  virtual Void codeRefFrmIdx     ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList )      = 0;
114  virtual Void codeMvd           ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList )      = 0;
115  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;
123 
124  virtual Void codeAlfFlag          ( UInt uiCode ) = 0;
125  virtual Void codeAlfUvlc          ( UInt uiCode ) = 0;
126  virtual Void codeAlfSvlc          ( Int   iCode ) = 0;
127#if TSB_ALF_HEADER
128  virtual Void codeAlfFlagNum       ( UInt uiCode, UInt minValue ) = 0;
129  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 
138  virtual ~TEncEntropyIf() {}
139};
140
141/// entropy encoder class
142class TEncEntropy
143{
144public:
145  Void    setEntropyCoder           ( TEncEntropyIf* e, TComSlice* pcSlice );
146  Void    setBitstream              ( TComBitIf* p )          { m_pcEntropyCoderIf->setBitstream(p);  }
147  Void    resetBits                 ()                        { m_pcEntropyCoderIf->resetBits();      }
148  Void    resetCoeffCost            ()                        { m_pcEntropyCoderIf->resetCoeffCost(); }
149  UInt    getNumberOfWrittenBits    ()                        { return m_pcEntropyCoderIf->getNumberOfWrittenBits(); }
150  UInt    getCoeffCost              ()                        { return  m_pcEntropyCoderIf->getCoeffCost(); }
151  Void    resetEntropy              ()                        { m_pcEntropyCoderIf->resetEntropy();  }
152 
153  Void    encodeSliceHeader         ( TComSlice* pcSlice );
154  Void    encodeTerminatingBit      ( UInt uiIsLast );
155  Void    encodeSliceFinish         ();
156 
157  Void encodeAlfParam(ALFParam* pAlfParam);
158  Void encodeMVPIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Bool bRD = false );
159 
160  Void encodeViewIdx(Int iViewIdx );
161
162  TEncEntropyIf*      m_pcEntropyCoderIf;
163 
164public:
165  // SPS
166  Void encodeSPS               ( TComSPS* pcSPS );
167  Void encodePPS               ( TComPPS* pcPPS );
168  void encodeSEI(const SEI&);
169  Bool getAlfCtrl() {return m_pcEntropyCoderIf->getAlfCtrl();}
170  UInt getMaxAlfCtrlDepth() {return m_pcEntropyCoderIf->getMaxAlfCtrlDepth();}
171  Void setAlfCtrl(Bool bAlfCtrl) {m_pcEntropyCoderIf->setAlfCtrl(bAlfCtrl);}
172  Void setMaxAlfCtrlDepth(UInt uiMaxAlfCtrlDepth) {m_pcEntropyCoderIf->setMaxAlfCtrlDepth(uiMaxAlfCtrlDepth);}
173 
174  Void encodeSplitFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
175  Void encodeSkipFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
176  Void encodePUWise       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
177  Void encodeInterDirPU   ( TComDataCU* pcSubCU, UInt uiAbsPartIdx  );
178  Void encodeRefFrmIdxPU  ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
179  Void encodeMvdPU        ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
180  Void encodeMVPIdxPU     ( TComDataCU* pcSubCU, UInt uiAbsPartIdx, RefPicList eRefList );
181  Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx );
182#if HHI_MRG_SKIP
183  Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD = false );
184#else
185  Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx );
186#endif
[5]187#if HHI_INTER_VIEW_RESIDUAL_PRED
[2]188  Void encodeResPredFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD = false );
[5]189#endif
[2]190  Void encodeAlfCtrlFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
191#if TSB_ALF_HEADER
192  Void encodeAlfCtrlParam      ( ALFParam *pAlfParam );
193#endif
194  Void encodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
195  Void encodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
196 
197  Void encodePredInfo          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
198  Void encodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
199 
200  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 
205  Void encodeTransformIdx      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
206  Void encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx );
207  Void encodeQtCbf             ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth );
208  Void encodeQtRootCbf         ( TComDataCU* pcCU, UInt uiAbsPartIdx );
209  Void encodeQP                ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
210 
211private:
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 );
214public:
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);
221 
222  // ALF-related
223  Void codeAuxCountBit(ALFParam* pAlfParam, Int64* ruiRate);
224  Void codeFiltCountBit(ALFParam* pAlfParam, Int64* ruiRate);
225  Void codeAux (ALFParam* pAlfParam);
226  Void codeFilt (ALFParam* pAlfParam);
227  Int codeFilterCoeff(ALFParam* ALFp);
228  Int writeFilterCodingParams(int minKStart, int maxScanVal, int kMinTab[]);
229  Int writeFilterCoeffs(int sqrFiltLength, int filters_per_group, int pDepthInt[], 
230                        int **FilterCoeff, int kMinTab[]);
231  Int golombEncode(int coeff, int k);
232  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
238
239};// END CLASS DEFINITION TEncEntropy
240
241
242#endif // __TENCENTROPY__
243
Note: See TracBrowser for help on using the repository browser.