[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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, 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 TEncCavlc.h |
---|
| 35 | \brief CAVLC encoder class (header) |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #ifndef __TENCCAVLC__ |
---|
| 39 | #define __TENCCAVLC__ |
---|
| 40 | |
---|
| 41 | #if _MSC_VER > 1000 |
---|
| 42 | #pragma once |
---|
| 43 | #endif // _MSC_VER > 1000 |
---|
| 44 | |
---|
[56] | 45 | #include "TLibCommon/CommonDef.h" |
---|
| 46 | #include "TLibCommon/TComBitStream.h" |
---|
[2] | 47 | #include "TEncEntropy.h" |
---|
[56] | 48 | #include "TLibCommon/TComRom.h" |
---|
[2] | 49 | |
---|
[56] | 50 | //! \ingroup TLibEncoder |
---|
| 51 | //! \{ |
---|
| 52 | |
---|
[2] | 53 | class TEncTop; |
---|
| 54 | |
---|
| 55 | // ==================================================================================================================== |
---|
| 56 | // Class definition |
---|
| 57 | // ==================================================================================================================== |
---|
| 58 | |
---|
| 59 | /// CAVLC encoder class |
---|
| 60 | class TEncCavlc : public TEncEntropyIf |
---|
| 61 | { |
---|
| 62 | public: |
---|
| 63 | TEncCavlc(); |
---|
| 64 | virtual ~TEncCavlc(); |
---|
| 65 | |
---|
| 66 | protected: |
---|
| 67 | TComBitIf* m_pcBitIf; |
---|
| 68 | TComSlice* m_pcSlice; |
---|
| 69 | UInt m_uiCoeffCost; |
---|
| 70 | Bool m_bAlfCtrl; |
---|
| 71 | UInt m_uiMaxAlfCtrlDepth; |
---|
[56] | 72 | Int m_iSliceGranularity; //!< slice granularity |
---|
[2] | 73 | |
---|
| 74 | Void xWriteCode ( UInt uiCode, UInt uiLength ); |
---|
| 75 | Void xWriteUvlc ( UInt uiCode ); |
---|
[56] | 76 | Void xWriteSvlc ( Int iCode ); |
---|
[2] | 77 | Void xWriteFlag ( UInt uiCode ); |
---|
[56] | 78 | #if ENC_DEC_TRACE |
---|
| 79 | Void xWriteCodeTr ( UInt value, UInt length, const Char *pSymbolName); |
---|
| 80 | Void xWriteUvlcTr ( UInt value, const Char *pSymbolName); |
---|
| 81 | Void xWriteSvlcTr ( Int value, const Char *pSymbolName); |
---|
| 82 | Void xWriteFlagTr ( UInt value, const Char *pSymbolName); |
---|
| 83 | #endif |
---|
| 84 | |
---|
| 85 | Void xWritePCMAlignZero (); |
---|
[2] | 86 | Void xWriteEpExGolomb ( UInt uiSymbol, UInt uiCount ); |
---|
| 87 | Void xWriteExGolombLevel ( UInt uiSymbol ); |
---|
| 88 | Void xWriteUnaryMaxSymbol ( UInt uiSymbol, UInt uiMaxSymbol ); |
---|
| 89 | |
---|
[56] | 90 | Void codeShortTermRefPicSet ( TComSPS* pcSPS, TComReferencePictureSet* pcRPS ); |
---|
[2] | 91 | |
---|
| 92 | UInt xConvertToUInt ( Int iValue ) { return ( iValue <= 0) ? -iValue<<1 : (iValue<<1)-1; } |
---|
| 93 | |
---|
| 94 | public: |
---|
| 95 | |
---|
| 96 | Void resetEntropy (); |
---|
[56] | 97 | #if CABAC_INIT_FLAG |
---|
| 98 | Void determineCabacInitIdx () {}; |
---|
| 99 | #endif |
---|
[2] | 100 | |
---|
| 101 | Void setBitstream ( TComBitIf* p ) { m_pcBitIf = p; } |
---|
| 102 | Void setSlice ( TComSlice* p ) { m_pcSlice = p; } |
---|
| 103 | Bool getAlfCtrl() {return m_bAlfCtrl;} |
---|
| 104 | UInt getMaxAlfCtrlDepth() {return m_uiMaxAlfCtrlDepth;} |
---|
| 105 | Void setAlfCtrl(Bool bAlfCtrl) {m_bAlfCtrl = bAlfCtrl;} |
---|
| 106 | Void setMaxAlfCtrlDepth(UInt uiMaxAlfCtrlDepth) {m_uiMaxAlfCtrlDepth = uiMaxAlfCtrlDepth;} |
---|
| 107 | Void resetBits () { m_pcBitIf->resetBits(); } |
---|
| 108 | Void resetCoeffCost () { m_uiCoeffCost = 0; } |
---|
| 109 | UInt getNumberOfWrittenBits() { return m_pcBitIf->getNumberOfWrittenBits(); } |
---|
| 110 | UInt getCoeffCost () { return m_uiCoeffCost; } |
---|
| 111 | |
---|
[210] | 112 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
[77] | 113 | Void codeVPS ( TComVPS* pcVPS ); |
---|
| 114 | #endif |
---|
| 115 | |
---|
[332] | 116 | #if HHI_MPI || H3D_QTL |
---|
[56] | 117 | Void codeSPS ( TComSPS* pcSPS, Bool bIsDepth ); |
---|
[42] | 118 | #else |
---|
[56] | 119 | Void codeSPS ( TComSPS* pcSPS ); |
---|
[42] | 120 | #endif |
---|
[2] | 121 | Void codePPS ( TComPPS* pcPPS ); |
---|
| 122 | void codeSEI(const SEI&); |
---|
| 123 | Void codeSliceHeader ( TComSlice* pcSlice ); |
---|
[56] | 124 | |
---|
| 125 | Void codeTileMarkerFlag(TComSlice* pcSlice); |
---|
| 126 | |
---|
| 127 | Void codeTilesWPPEntryPoint( TComSlice* pSlice ); |
---|
[2] | 128 | Void codeTerminatingBit ( UInt uilsLast ); |
---|
| 129 | Void codeSliceFinish (); |
---|
[56] | 130 | Void codeFlush () {} |
---|
| 131 | Void encodeStart () {} |
---|
[2] | 132 | |
---|
[296] | 133 | #if H3D_IVMP |
---|
[56] | 134 | Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ); |
---|
| 135 | #else |
---|
[2] | 136 | Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ); |
---|
[56] | 137 | #endif |
---|
[2] | 138 | Void codeAlfFlag ( UInt uiCode ); |
---|
| 139 | Void codeAlfUvlc ( UInt uiCode ); |
---|
| 140 | Void codeAlfSvlc ( Int iCode ); |
---|
| 141 | Void codeAlfCtrlDepth(); |
---|
[56] | 142 | Void codeAPSAlflag(UInt uiCode); |
---|
| 143 | Void codeAlfFixedLengthIdx( UInt idx, UInt numFilterSetsInBuffer); |
---|
[443] | 144 | #if LGE_SAO_MIGRATION_D0091 |
---|
| 145 | Void codeSAOSign ( UInt code ) { printf("Not supported\n"); assert (0); } |
---|
| 146 | Void codeSaoMaxUvlc ( UInt code, UInt maxSymbol ){printf("Not supported\n"); assert (0);} |
---|
| 147 | Void codeSaoMerge ( UInt uiCode ){printf("Not supported\n"); assert (0);} |
---|
| 148 | Void codeSaoTypeIdx ( UInt uiCode ){printf("Not supported\n"); assert (0);} |
---|
| 149 | Void codeSaoUflc ( UInt uiLength, UInt uiCode ){ assert(uiCode < 32); printf("Not supported\n"); assert (0);} |
---|
| 150 | #else |
---|
[56] | 151 | Void codeSaoFlag ( UInt uiCode ); |
---|
| 152 | Void codeSaoUvlc ( UInt uiCode ); |
---|
| 153 | Void codeSaoSvlc ( Int iCode ); |
---|
| 154 | Void codeSaoRun ( UInt uiCode, UInt maxValue ); |
---|
| 155 | Void codeSaoMergeLeft ( UInt uiCode, UInt compIdx ){;} |
---|
| 156 | Void codeSaoMergeUp ( UInt uiCode ){;} |
---|
| 157 | Void codeSaoTypeIdx ( UInt uiCode ){ xWriteUvlc(uiCode );} |
---|
| 158 | Void codeSaoUflc ( UInt uiCode ){ assert(uiCode < 32); xWriteCode(uiCode, 5);} |
---|
[443] | 159 | #endif |
---|
[56] | 160 | |
---|
[2] | 161 | Void codeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
[189] | 162 | #if LGE_ILLUCOMP_B0045 |
---|
| 163 | Void codeICFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 164 | #endif |
---|
[2] | 165 | Void codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 166 | Void codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
[296] | 167 | #if H3D_IVRP |
---|
[2] | 168 | Void codeResPredFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
[5] | 169 | #endif |
---|
[443] | 170 | #if QC_ARP_D0177 |
---|
| 171 | virtual Void codeARPW ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 172 | #endif |
---|
[2] | 173 | Void codeAlfCtrlFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
[56] | 174 | |
---|
| 175 | Void codeApsExtensionFlag (); |
---|
| 176 | |
---|
| 177 | /// set slice granularity |
---|
| 178 | Void setSliceGranularity(Int iSliceGranularity) {m_iSliceGranularity = iSliceGranularity;} |
---|
| 179 | |
---|
| 180 | ///get slice granularity |
---|
| 181 | Int getSliceGranularity() {return m_iSliceGranularity; } |
---|
| 182 | |
---|
[2] | 183 | Void codeAlfCtrlFlag ( UInt uiSymbol ); |
---|
| 184 | Void codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode ); |
---|
| 185 | Void codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 186 | |
---|
| 187 | Void codePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 188 | Void codePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 189 | |
---|
[56] | 190 | Void codeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag); |
---|
| 191 | |
---|
[2] | 192 | Void codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ); |
---|
| 193 | Void codeQtCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ); |
---|
| 194 | Void codeQtRootCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 195 | |
---|
[443] | 196 | Void codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx |
---|
| 197 | #if PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
| 198 | , Bool bSdcRD = false |
---|
| 199 | #endif |
---|
| 200 | ); |
---|
[2] | 201 | |
---|
| 202 | Void codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 203 | Void codeInterDir ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 204 | Void codeRefFrmIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ); |
---|
| 205 | Void codeMvd ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ); |
---|
| 206 | |
---|
| 207 | Void codeDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 208 | |
---|
[56] | 209 | Void codeCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ); |
---|
[2] | 210 | |
---|
[56] | 211 | Void estBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType); |
---|
[2] | 212 | |
---|
[56] | 213 | Void xCodePredWeightTable ( TComSlice* pcSlice ); |
---|
| 214 | Void updateContextTables ( SliceType eSliceType, Int iQp, Bool bExecuteFinish=true ) { return; } |
---|
| 215 | Void updateContextTables ( SliceType eSliceType, Int iQp ) { return; } |
---|
| 216 | Void writeTileMarker ( UInt uiTileIdx, UInt uiBitsUsed ); |
---|
| 217 | |
---|
| 218 | Void codeAPSInitInfo(TComAPS* pcAPS); //!< code APS flags before encoding SAO and ALF parameters |
---|
| 219 | Void codeFinish(Bool bEnd) { /*do nothing*/} |
---|
| 220 | Void codeScalingList ( TComScalingList* scalingList ); |
---|
| 221 | Void xCodeScalingList ( TComScalingList* scalingList, UInt sizeId, UInt listId); |
---|
| 222 | Void codeDFFlag ( UInt uiCode, const Char *pSymbolName ); |
---|
| 223 | Void codeDFSvlc ( Int iCode, const Char *pSymbolName ); |
---|
[189] | 224 | |
---|
| 225 | #if RWTH_SDC_DLT_B0036 |
---|
[443] | 226 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
[189] | 227 | Void codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
[443] | 228 | #endif |
---|
[189] | 229 | Void codeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ); |
---|
[443] | 230 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
[189] | 231 | Void codeSDCPredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ); |
---|
| 232 | #endif |
---|
[443] | 233 | #endif |
---|
[56] | 234 | |
---|
[2] | 235 | }; |
---|
| 236 | |
---|
[56] | 237 | //! \} |
---|
| 238 | |
---|
[2] | 239 | #endif // !defined(AFX_TENCCAVLC_H__EE8A0B30_945B_4169_B290_24D3AD52296F__INCLUDED_) |
---|
| 240 | |
---|