source: SHVCSoftware/branches/0.1.1-bugfix/source/Lib/TLibDecoder/TDecSbac.h @ 444

Last change on this file since 444 was 2, checked in by seregin, 12 years ago

Initial import by Vadim Seregin <vseregin@…>

File size: 9.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-2012, ITU/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 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     TDecSbac.h
35    \brief    SBAC decoder class (header)
36*/
37
38#ifndef __TDECSBAC__
39#define __TDECSBAC__
40
41
42#if _MSC_VER > 1000
43#pragma once
44#endif // _MSC_VER > 1000
45
46
47#include "TDecEntropy.h"
48#include "TDecBinCoder.h"
49#include "TLibCommon/ContextTables.h"
50#include "TLibCommon/ContextModel.h"
51#include "TLibCommon/ContextModel3DBuffer.h"
52
53//! \ingroup TLibDecoder
54//! \{
55
56// ====================================================================================================================
57// Class definition
58// ====================================================================================================================
59
60class SEImessages;
61
62/// SBAC decoder class
63class TDecSbac : public TDecEntropyIf
64{
65public:
66  TDecSbac();
67  virtual ~TDecSbac();
68 
69  Void  init                      ( TDecBinIf* p )    { m_pcTDecBinIf = p; }
70  Void  uninit                    (              )    { m_pcTDecBinIf = 0; }
71 
72  Void load                          ( TDecSbac* pScr );
73  Void loadContexts                  ( TDecSbac* pScr );
74  Void xCopyFrom           ( TDecSbac* pSrc );
75  Void xCopyContextsFrom       ( TDecSbac* pSrc );
76  Void decodeFlush();
77
78  Void  resetEntropy (TComSlice* pSlice );
79  Void  setBitstream              ( TComInputBitstream* p  ) { m_pcBitstream = p; m_pcTDecBinIf->init( p ); }
80  Void  parseVPS                  ( TComVPS* pcVPS )  {}
81  Void  parseSPS                  ( TComSPS* pcSPS         ) {}
82  Void  parsePPS                  ( TComPPS* pcPPS         ) {}
83#if !REMOVE_APS
84  Void  parseAPS                  ( TComAPS* pAPS          ) {}
85#endif
86
87  Void  parseSliceHeader          ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) {}
88  Void  parseTerminatingBit       ( UInt& ruiBit );
89  Void  parseMVPIdx               ( Int& riMVPIdx          );
90  Void  parseSaoMaxUvlc           ( UInt& val, UInt maxSymbol );
91#if SAO_MERGE_ONE_CTX
92  Void  parseSaoMerge         ( UInt&  ruiVal   );
93#else
94  Void  parseSaoMergeLeft         ( UInt&  ruiVal, UInt uiCompIdx   );
95  Void  parseSaoMergeUp           ( UInt&  ruiVal  );
96#endif
97  Void  parseSaoTypeIdx           ( UInt&  ruiVal  );
98#if SAO_TYPE_CODING
99  Void  parseSaoUflc              ( UInt uiLength, UInt& ruiVal     );
100#else
101  Void  parseSaoUflc              ( UInt& ruiVal           );
102#endif
103  Void  parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp);
104#if SAO_TYPE_SHARING
105  Void  parseSaoOffset            (SaoLcuParam* psSaoLcuParam, UInt compIdx);
106#else
107  Void  parseSaoOffset            (SaoLcuParam* psSaoLcuParam);
108#endif
109private:
110  Void  xReadUnarySymbol    ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset );
111  Void  xReadUnaryMaxSymbol ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol );
112  Void  xReadEpExGolomb     ( UInt& ruiSymbol, UInt uiCount );
113  Void  xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam );
114private:
115  TComInputBitstream* m_pcBitstream;
116  TDecBinIf*        m_pcTDecBinIf;
117 
118#if !REMOVE_FGS
119  Int           m_iSliceGranularity; //!< slice granularity
120#endif
121 
122public:
123#if !REMOVE_ALF
124  Void parseAlfCtrlFlag   (Int compIdx, UInt& code);
125#endif
126#if !REMOVE_FGS
127  /// set slice granularity
128  Void setSliceGranularity(Int iSliceGranularity)  {m_iSliceGranularity = iSliceGranularity;}
129
130  /// get slice granularity
131  Int  getSliceGranularity()                       {return m_iSliceGranularity;             }
132#endif
133 
134  Void parseSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
135  Void parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
136  Void parseSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
137  Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
138  Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth );
139  Void parsePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
140  Void parsePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
141 
142  Void parseIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
143 
144  Void parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
145 
146  Void parseInterDir      ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth );
147  Void parseRefFrmIdx     ( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList );
148  Void parseMvd           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList );
149 
150  Void parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize );
151  Void parseQtCbf         ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth );
152  Void parseQtRootCbf     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf );
153 
154  Void parseDeltaQP       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
155 
156  Void parseIPCMInfo      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth);
157
158  Void parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx );
159  Void parseCoeffNxN      ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType );
160  Void parseTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType);
161
162  Void updateContextTables( SliceType eSliceType, Int iQp );
163
164  Void  parseScalingList ( TComScalingList* scalingList ) {}
165
166#if INTRA_BL
167  Void parseIntraBLFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
168#endif
169private:
170  UInt m_uiLastDQpNonZero;
171  UInt m_uiLastQp;
172 
173  ContextModel         m_contextModels[MAX_NUM_CTX_MOD];
174  Int                  m_numContextModels;
175  ContextModel3DBuffer m_cCUSplitFlagSCModel;
176  ContextModel3DBuffer m_cCUSkipFlagSCModel;
177  ContextModel3DBuffer m_cCUMergeFlagExtSCModel;
178  ContextModel3DBuffer m_cCUMergeIdxExtSCModel;
179  ContextModel3DBuffer m_cCUPartSizeSCModel;
180  ContextModel3DBuffer m_cCUPredModeSCModel;
181  ContextModel3DBuffer m_cCUAlfCtrlFlagSCModel;
182  ContextModel3DBuffer m_cCUIntraPredSCModel;
183  ContextModel3DBuffer m_cCUChromaPredSCModel;
184  ContextModel3DBuffer m_cCUDeltaQpSCModel;
185  ContextModel3DBuffer m_cCUInterDirSCModel;
186  ContextModel3DBuffer m_cCURefPicSCModel;
187  ContextModel3DBuffer m_cCUMvdSCModel;
188  ContextModel3DBuffer m_cCUQtCbfSCModel;
189  ContextModel3DBuffer m_cCUTransSubdivFlagSCModel;
190  ContextModel3DBuffer m_cCUQtRootCbfSCModel;
191 
192  ContextModel3DBuffer m_cCUSigCoeffGroupSCModel;
193  ContextModel3DBuffer m_cCUSigSCModel;
194  ContextModel3DBuffer m_cCuCtxLastX;
195  ContextModel3DBuffer m_cCuCtxLastY;
196  ContextModel3DBuffer m_cCUOneSCModel;
197  ContextModel3DBuffer m_cCUAbsSCModel;
198 
199  ContextModel3DBuffer m_cMVPIdxSCModel;
200 
201  ContextModel3DBuffer m_cALFFlagSCModel;
202  ContextModel3DBuffer m_cALFUvlcSCModel;
203  ContextModel3DBuffer m_cALFSvlcSCModel;
204  ContextModel3DBuffer m_cCUAMPSCModel;
205#if !SAO_ABS_BY_PASS
206  ContextModel3DBuffer m_cSaoUvlcSCModel;
207#endif
208#if SAO_MERGE_ONE_CTX
209  ContextModel3DBuffer m_cSaoMergeSCModel;
210#else
211  ContextModel3DBuffer m_cSaoMergeLeftSCModel;
212  ContextModel3DBuffer m_cSaoMergeUpSCModel;
213#endif
214#if INTRA_BL
215  ContextModel3DBuffer m_cIntraBLPredFlagSCModel;
216#endif
217  ContextModel3DBuffer m_cSaoTypeIdxSCModel;
218  ContextModel3DBuffer m_cTransformSkipSCModel;
219  ContextModel3DBuffer m_CUTransquantBypassFlagSCModel;
220};
221
222//! \}
223
224#endif // !defined(AFX_TDECSBAC_H__CFCAAA19_8110_47F4_9A16_810C4B5499D5__INCLUDED_)
Note: See TracBrowser for help on using the repository browser.