source: 3DVCSoftware/branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncEntropy.h @ 1288

Last change on this file since 1288 was 1279, checked in by tech, 10 years ago

Merged 14.1-update-dev2@1277.

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