source: 3DVCSoftware/branches/0.3-nokia/source/Lib/TLibEncoder/TEncSbac.h @ 36

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

Clean version with cfg-files

  • Property svn:eol-style set to native
File size: 11.3 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     TEncSbac.h
37    \brief    Context-adaptive entropy encoder class (header)
38*/
39
40#ifndef __TENCSBAC__
41#define __TENCSBAC__
42
43#if _MSC_VER > 1000
44#pragma once
45#endif // _MSC_VER > 1000
46
47#include "../TLibCommon/TComBitStream.h"
48#include "../TLibCommon/ContextTables.h"
49#include "../TLibCommon/ContextModel.h"
50#include "../TLibCommon/ContextModel3DBuffer.h"
51#include "TEncEntropy.h"
52#include "TEncBinCoder.h"
53#include "TEncBinCoderCABAC.h"
54
55class TEncTop;
56
57// ====================================================================================================================
58// Class definition
59// ====================================================================================================================
60
61/// SBAC encoder class
62class TEncSbac : public TEncEntropyIf
63{
64public:
65  TEncSbac();
66  virtual ~TEncSbac();
67 
68  Void  init                   ( TEncBinIf* p )  { m_pcBinIf = p; }
69  Void  uninit                 ()                { m_pcBinIf = 0; }
70 
71  //  Virtual list
72  Void  resetEntropy           ();
73  Void  setBitstream           ( TComBitIf* p )  { m_pcBitIf = p; m_pcBinIf->init( p ); }
74  Void  setSlice               ( TComSlice* p )  { m_pcSlice = p;                       }
75 
76  Bool  getAlfCtrl             ()                         { return m_bAlfCtrl;          }
77  UInt  getMaxAlfCtrlDepth     ()                         { return m_uiMaxAlfCtrlDepth; }
78  Void  setAlfCtrl             ( Bool bAlfCtrl          ) { m_bAlfCtrl          = bAlfCtrl;          }
79  Void  setMaxAlfCtrlDepth     ( UInt uiMaxAlfCtrlDepth ) { m_uiMaxAlfCtrlDepth = uiMaxAlfCtrlDepth; }
80 
81  // SBAC RD
82  Void  resetCoeffCost         ()                { m_uiCoeffCost = 0;  }
83  UInt  getCoeffCost           ()                { return  m_uiCoeffCost;  }
84 
85  Void  load                   ( TEncSbac* pScr  );
86  Void  store                  ( TEncSbac* pDest );
87  Void  resetBits              ()                { m_pcBinIf->resetBits(); m_pcBitIf->resetBits(); }
88  UInt  getNumberOfWrittenBits ()                { return m_pcBinIf->getNumWrittenBits(); }
89  //--SBAC RD
90 
91  Void  codeNALUnitHeader       ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, Bool bOutputFlag = true );
92
93  Void  codeSPS                 ( TComSPS* pcSPS     );
94  Void  codePPS                 ( TComPPS* pcPPS     );
95  void codeSEI(const SEI&);
96  Void  codeSliceHeader         ( TComSlice* pcSlice );
97  Void  codeTerminatingBit      ( UInt uilsLast      );
98  Void  codeSliceFinish         ();
99 
100  Void  codeAlfFlag       ( UInt uiCode );
101  Void  codeAlfUvlc       ( UInt uiCode );
102  Void  codeAlfSvlc       ( Int  uiCode );
103  Void  codeAlfCtrlDepth  ();
104#if TSB_ALF_HEADER
105  Void codeAlfFlagNum        ( UInt uiCode, UInt minValue );
106  Void codeAlfCtrlFlag       ( UInt uiSymbol );
107#endif
108#if MTK_SAO
109  Void  codeAoFlag       ( UInt uiCode );
110  Void  codeAoUvlc       ( UInt uiCode );
111  Void  codeAoSvlc       ( Int  uiCode );
112#endif
113
114private:
115  Void  xWriteUnarySymbol    ( UInt uiSymbol, ContextModel* pcSCModel, Int iOffset );
116  Void  xWriteUnaryMaxSymbol ( UInt uiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol );
117  Void  xWriteEpExGolomb     ( UInt uiSymbol, UInt uiCount );
118#if E253
119  Void  xWriteGoRiceExGolomb ( UInt uiSymbol, UInt &ruiGoRiceParam );
120#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
121  Void  xWriteExGolombLevel  ( UInt uiSymbol, ContextModel& rcSCModel  );
122#endif
123#else
124  Void  xWriteExGolombLevel  ( UInt uiSymbol, ContextModel& rcSCModel  );
125#endif
126  Void  xWriteTerminatingBit ( UInt uiBit );
127 
128  Void  xCheckCoeff( TCoeff* pcCoef, UInt uiSize, UInt uiDepth, UInt& uiNumofCoeff, UInt& uiPart );
129
130#if MVD_CTX
131  Void  xWriteMvd            ( Int iMvd, UInt uiAbsSumL, UInt uiAbsSumA, UInt uiCtx );
132#else
133  Void  xWriteMvd            ( Int iMvd, UInt uiAbsSum, UInt uiCtx );
134#endif
135  Void  xWriteExGolombMvd    ( UInt uiSymbol, ContextModel* pcSCModel, UInt uiMaxBin );
136  Void  xCopyFrom            ( TEncSbac* pSrc );
137 
138#if HHI_DMM_WEDGE_INTRA
139  Void  xCodeWedgeFullInfo   ( TComDataCU* pcCU, UInt uiAbsPartIdx );
140  Void  xCodeWedgeFullDeltaInfo     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
141
142  Void  xCodeWedgePredDirInfo       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
143  Void  xCodeWedgePredDirDeltaInfo  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
144#endif
145#if HHI_DMM_PRED_TEX
146  Void  xCodeWedgePredTexDeltaInfo  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
147  Void  xCodeContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx );
148#endif
149 
150protected:
151  TComBitIf*    m_pcBitIf;
152  TComSlice*    m_pcSlice;
153  TEncBinIf*    m_pcBinIf;
154  Bool          m_bAlfCtrl;
155 
156  //SBAC RD
157  UInt          m_uiCoeffCost;
158 
159  // Adaptive loop filter
160  UInt          m_uiMaxAlfCtrlDepth;
161  //--Adaptive loop filter
162
163public:
164  Void codeAlfCtrlFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx );
165  Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
166  Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
167  Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
168#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
169  Void codeMergeIndexMV  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
170#endif
171#if HHI_INTER_VIEW_RESIDUAL_PRED
172  Void codeResPredFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx );
173#endif
174  Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
175  Void codeMVPIdx        ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
176 
177  Void codePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
178  Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
179 
180  Void codeTransformSubdivFlag ( UInt uiSymbol, UInt uiCtx );
181  Void codeQtCbf               ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth );
182  Void codeQtRootCbf           ( TComDataCU* pcCU, UInt uiAbsPartIdx );
183 
184  Void codeIntraDirLumaAng     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
185 
186  Void codeIntraDirChroma      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
187  Void codeInterDir            ( TComDataCU* pcCU, UInt uiAbsPartIdx );
188  Void codeRefFrmIdx           ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
189  Void codeMvd                 ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
190 
191  Void codeViewIdx                       (Int iViewIdx);
192
193  Void codeDeltaQP             ( TComDataCU* pcCU, UInt uiAbsPartIdx );
194  Void codeCbf                 ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) {}
195  Void codeBlockCbf            ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiQPartNum, Bool bRD = false ) {}
196 
197#if CAVLC_RQT_CBP
198  Void codeCbfTrdiv      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) {}
199  UInt xGetFlagPattern   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) { return 0; }
200#endif
201#if PCP_SIGMAP_SIMPLE_LAST
202  __inline Void codeLastSignificantXY ( UInt uiPosX, UInt uiPosY, const UInt uiWidth, const TextType eTType, const UInt uiCTXIdx, const UInt uiScanIdx );
203#endif
204  Void codeCoeffNxN            ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType, Bool bRD = false );
205 
206  // -------------------------------------------------------------------------------------------------------------------
207  // for RD-optimizatioon
208  // -------------------------------------------------------------------------------------------------------------------
209 
210  Void estBit                        ( estBitsSbacStruct* pcEstBitsSbac, UInt uiCTXIdx, TextType eTType );
211  Void estCBFBit                     ( estBitsSbacStruct* pcEstBitsSbac, UInt uiCTXIdx, TextType eTType );
212  Void estSignificantMapBit          ( estBitsSbacStruct* pcEstBitsSbac, UInt uiCTXIdx, TextType eTType );
213  Void estSignificantCoefficientsBit ( estBitsSbacStruct* pcEstBitsSbac, UInt uiCTXIdx, TextType eTType );
214 
215  __inline Int  biari_no_bits        ( Short symbol, ContextModel& rcSCModel );
216 
217  TEncBinIf* getEncBinIf()  { return m_pcBinIf; }
218private:
219  UInt                 m_uiLastQp;
220  ContextModel3DBuffer m_cCUSplitFlagSCModel;
221  ContextModel3DBuffer m_cCUSkipFlagSCModel;
222  ContextModel3DBuffer m_cCUMergeFlagExtSCModel;
223  ContextModel3DBuffer m_cCUMergeIdxExtSCModel;
224  ContextModel3DBuffer m_cCUMVMergeIdxExtSCModel;
225  ContextModel3DBuffer m_cResPredFlagSCModel;
226  ContextModel3DBuffer m_cCUPartSizeSCModel;
227  ContextModel3DBuffer m_cCUPredModeSCModel;
228  ContextModel3DBuffer m_cCUAlfCtrlFlagSCModel;
229  ContextModel3DBuffer m_cCUIntraPredSCModel;
230#if ADD_PLANAR_MODE
231  ContextModel3DBuffer m_cPlanarFlagSCModel;
232#endif
233  ContextModel3DBuffer m_cCUChromaPredSCModel;
234  ContextModel3DBuffer m_cCUDeltaQpSCModel;
235  ContextModel3DBuffer m_cCUInterDirSCModel;
236  ContextModel3DBuffer m_cCURefPicSCModel;
237  ContextModel3DBuffer m_cCUMvdSCModel;
238  ContextModel3DBuffer m_cCUQtCbfSCModel;
239  ContextModel3DBuffer m_cCUTransSubdivFlagSCModel;
240  ContextModel3DBuffer m_cCUQtRootCbfSCModel;
241 
242  ContextModel3DBuffer m_cCUSigSCModel;
243#if PCP_SIGMAP_SIMPLE_LAST
244  ContextModel3DBuffer m_cCuCtxLastX;
245  ContextModel3DBuffer m_cCuCtxLastY;
246#else
247  ContextModel3DBuffer m_cCULastSCModel;
248#endif
249  ContextModel3DBuffer m_cCUOneSCModel;
250  ContextModel3DBuffer m_cCUAbsSCModel;
251 
252  ContextModel3DBuffer m_cMVPIdxSCModel;
253 
254  ContextModel3DBuffer m_cALFFlagSCModel;
255  ContextModel3DBuffer m_cALFUvlcSCModel;
256  ContextModel3DBuffer m_cALFSvlcSCModel;
257#if MTK_SAO
258  ContextModel3DBuffer m_cAOFlagSCModel;
259  ContextModel3DBuffer m_cAOUvlcSCModel;
260  ContextModel3DBuffer m_cAOSvlcSCModel;
261#endif
262  ContextModel3DBuffer m_cViewIdxSCModel;
263#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
264  ContextModel3DBuffer m_cIntraDMMSCModel;
265  ContextModel3DBuffer m_cIntraWedgeSCModel;
266#endif
267};
268
269#endif // !defined(AFX_TENCSBAC_H__DDA7CDC4_EDE3_4015_9D32_2156249C82AA__INCLUDED_)
Note: See TracBrowser for help on using the repository browser.