[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 TEncTop.h |
---|
| 35 | \brief encoder class (header) |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #ifndef __TENCTOP__ |
---|
| 39 | #define __TENCTOP__ |
---|
| 40 | |
---|
| 41 | // Include files |
---|
[56] | 42 | #include "TLibCommon/TComList.h" |
---|
| 43 | #include "TLibCommon/TComPrediction.h" |
---|
| 44 | #include "TLibCommon/TComTrQuant.h" |
---|
[1200] | 45 | #include "TLibCommon/TComLoopFilter.h" |
---|
[56] | 46 | #include "TLibCommon/AccessUnit.h" |
---|
[2] | 47 | |
---|
[56] | 48 | #include "TLibVideoIO/TVideoIOYuv.h" |
---|
[2] | 49 | |
---|
| 50 | #include "TEncCfg.h" |
---|
| 51 | #include "TEncGOP.h" |
---|
| 52 | #include "TEncSlice.h" |
---|
| 53 | #include "TEncEntropy.h" |
---|
| 54 | #include "TEncCavlc.h" |
---|
| 55 | #include "TEncSbac.h" |
---|
| 56 | #include "TEncSearch.h" |
---|
[56] | 57 | #include "TEncSampleAdaptiveOffset.h" |
---|
| 58 | #include "TEncPreanalyzer.h" |
---|
[608] | 59 | #include "TEncRateCtrl.h" |
---|
[56] | 60 | //! \ingroup TLibEncoder |
---|
| 61 | //! \{ |
---|
[2] | 62 | |
---|
| 63 | // ==================================================================================================================== |
---|
| 64 | // Class definition |
---|
| 65 | // ==================================================================================================================== |
---|
| 66 | |
---|
[655] | 67 | #if KWU_RC_MADPRED_E0227 |
---|
| 68 | class TAppEncTop; |
---|
| 69 | #endif |
---|
[2] | 70 | /// encoder class |
---|
| 71 | class TEncTop : public TEncCfg |
---|
| 72 | { |
---|
| 73 | private: |
---|
| 74 | // picture |
---|
| 75 | Int m_iPOCLast; ///< time index (POC) |
---|
| 76 | Int m_iNumPicRcvd; ///< number of received pictures |
---|
| 77 | UInt m_uiNumAllPicCoded; ///< number of coded pictures |
---|
| 78 | TComList<TComPic*> m_cListPic; ///< dynamic list of pictures |
---|
[1200] | 79 | |
---|
| 80 | #if NH_MV |
---|
[608] | 81 | TComPicLists* m_ivPicLists; ///< access to picture lists of other layers |
---|
| 82 | #endif |
---|
[1225] | 83 | #if NH_3D_IC |
---|
[1066] | 84 | Int *m_aICEnableCandidate; |
---|
| 85 | Int *m_aICEnableNum; |
---|
| 86 | #endif |
---|
[2] | 87 | // encoder search |
---|
| 88 | TEncSearch m_cSearch; ///< encoder search class |
---|
[872] | 89 | //TEncEntropy* m_pcEntropyCoder; ///< entropy encoder |
---|
[1200] | 90 | TEncCavlc* m_pcCavlcCoder; ///< CAVLC encoder |
---|
[2] | 91 | // coding tool |
---|
| 92 | TComTrQuant m_cTrQuant; ///< transform & quantization class |
---|
| 93 | TComLoopFilter m_cLoopFilter; ///< deblocking filter class |
---|
[56] | 94 | TEncSampleAdaptiveOffset m_cEncSAO; ///< sample adaptive offset class |
---|
[2] | 95 | TEncEntropy m_cEntropyCoder; ///< entropy encoder |
---|
| 96 | TEncCavlc m_cCavlcCoder; ///< CAVLC encoder |
---|
| 97 | TEncSbac m_cSbacCoder; ///< SBAC encoder |
---|
| 98 | TEncBinCABAC m_cBinCoderCABAC; ///< bin coder CABAC |
---|
[1200] | 99 | |
---|
[2] | 100 | // processing unit |
---|
[56] | 101 | TEncGOP m_cGOPEncoder; ///< GOP encoder |
---|
[2] | 102 | TEncSlice m_cSliceEncoder; ///< slice encoder |
---|
| 103 | TEncCu m_cCuEncoder; ///< CU encoder |
---|
| 104 | // SPS |
---|
[1200] | 105 | TComSPS m_cSPS; ///< SPS. This is the base value. This is copied to TComPicSym |
---|
| 106 | TComPPS m_cPPS; ///< PPS. This is the base value. This is copied to TComPicSym |
---|
[2] | 107 | // RD cost computation |
---|
| 108 | TComRdCost m_cRdCost; ///< RD cost computation class |
---|
| 109 | TEncSbac*** m_pppcRDSbacCoder; ///< temporal storage for RD computation |
---|
| 110 | TEncSbac m_cRDGoOnSbacCoder; ///< going on SBAC model for RD stage |
---|
[56] | 111 | #if FAST_BIT_EST |
---|
| 112 | TEncBinCABACCounter*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation |
---|
| 113 | TEncBinCABACCounter m_cRDGoOnBinCoderCABAC; ///< going on bin coder CABAC for RD stage |
---|
| 114 | #else |
---|
[2] | 115 | TEncBinCABAC*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation |
---|
| 116 | TEncBinCABAC m_cRDGoOnBinCoderCABAC; ///< going on bin coder CABAC for RD stage |
---|
[56] | 117 | #endif |
---|
[2] | 118 | |
---|
[56] | 119 | // quality control |
---|
| 120 | TEncPreanalyzer m_cPreanalyzer; ///< image characteristics analyzer for TM5-step3-like adaptive QP |
---|
| 121 | |
---|
[608] | 122 | TEncRateCtrl m_cRateCtrl; ///< Rate control class |
---|
[655] | 123 | |
---|
| 124 | #if KWU_RC_MADPRED_E0227 |
---|
| 125 | TAppEncTop* m_pcTAppEncTop; |
---|
| 126 | TAppComCamPara* m_cCamParam; |
---|
| 127 | #endif |
---|
[1200] | 128 | #if NH_MV |
---|
[56] | 129 | TEncAnalyze m_cAnalyzeAll; |
---|
| 130 | TEncAnalyze m_cAnalyzeI; |
---|
| 131 | TEncAnalyze m_cAnalyzeP; |
---|
[1200] | 132 | TEncAnalyze m_cAnalyzeB; |
---|
| 133 | TEncAnalyze m_cAnalyzeAll_in; |
---|
[608] | 134 | #endif |
---|
[2] | 135 | protected: |
---|
| 136 | Void xGetNewPicBuffer ( TComPic*& rpcPic ); ///< get picture buffer which will be processed |
---|
[1200] | 137 | Void xInitVPS (); ///< initialize VPS from encoder options |
---|
[2] | 138 | Void xInitSPS (); ///< initialize SPS from encoder options |
---|
| 139 | Void xInitPPS (); ///< initialize PPS from encoder options |
---|
[1200] | 140 | Void xInitScalingLists(); ///< initialize scaling lists |
---|
| 141 | Void xInitHrdParameters(); ///< initialize HRD parameters |
---|
| 142 | |
---|
[56] | 143 | Void xInitPPSforTiles (); |
---|
[655] | 144 | Void xInitRPS (Bool isFieldCoding); ///< initialize PPS from encoder options |
---|
[2] | 145 | |
---|
| 146 | public: |
---|
| 147 | TEncTop(); |
---|
| 148 | virtual ~TEncTop(); |
---|
[1200] | 149 | |
---|
[2] | 150 | Void create (); |
---|
| 151 | Void destroy (); |
---|
[655] | 152 | #if KWU_RC_MADPRED_E0227 |
---|
| 153 | Void init ( TAppEncTop* pcTAppEncTop, Bool isFieldCoding ); |
---|
| 154 | #else |
---|
| 155 | Void init (Bool isFieldCoding); |
---|
| 156 | #endif |
---|
[1200] | 157 | #if NH_MV |
---|
[608] | 158 | TComPicLists* getIvPicLists() { return m_ivPicLists; } |
---|
| 159 | #endif |
---|
[1225] | 160 | #if NH_3D_IC |
---|
[1084] | 161 | Int* getICEnableCandidate() { return m_aICEnableCandidate; } |
---|
| 162 | Int* getICEnableNum() { return m_aICEnableNum; } |
---|
[1066] | 163 | #endif |
---|
[2] | 164 | Void deletePicBuffer (); |
---|
[1200] | 165 | #if NH_MV |
---|
[608] | 166 | Void initNewPic(TComPicYuv* pcPicYuvOrg); |
---|
| 167 | #endif |
---|
[2] | 168 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 169 | // member access functions |
---|
| 170 | // ------------------------------------------------------------------------------------------------------------------- |
---|
[1200] | 171 | |
---|
[2] | 172 | TComList<TComPic*>* getListPic () { return &m_cListPic; } |
---|
| 173 | TEncSearch* getPredSearch () { return &m_cSearch; } |
---|
[1200] | 174 | |
---|
[2] | 175 | TComTrQuant* getTrQuant () { return &m_cTrQuant; } |
---|
| 176 | TComLoopFilter* getLoopFilter () { return &m_cLoopFilter; } |
---|
[56] | 177 | TEncSampleAdaptiveOffset* getSAO () { return &m_cEncSAO; } |
---|
| 178 | TEncGOP* getGOPEncoder () { return &m_cGOPEncoder; } |
---|
[2] | 179 | TEncSlice* getSliceEncoder () { return &m_cSliceEncoder; } |
---|
| 180 | TEncCu* getCuEncoder () { return &m_cCuEncoder; } |
---|
| 181 | TEncEntropy* getEntropyCoder () { return &m_cEntropyCoder; } |
---|
| 182 | TEncCavlc* getCavlcCoder () { return &m_cCavlcCoder; } |
---|
| 183 | TEncSbac* getSbacCoder () { return &m_cSbacCoder; } |
---|
| 184 | TEncBinCABAC* getBinCABAC () { return &m_cBinCoderCABAC; } |
---|
[1200] | 185 | |
---|
[2] | 186 | TComRdCost* getRdCost () { return &m_cRdCost; } |
---|
| 187 | TEncSbac*** getRDSbacCoder () { return m_pppcRDSbacCoder; } |
---|
| 188 | TEncSbac* getRDGoOnSbacCoder () { return &m_cRDGoOnSbacCoder; } |
---|
[608] | 189 | TEncRateCtrl* getRateCtrl () { return &m_cRateCtrl; } |
---|
[655] | 190 | #if KWU_RC_MADPRED_E0227 |
---|
| 191 | TAppEncTop* getEncTop () { return m_pcTAppEncTop; } |
---|
| 192 | TAppComCamPara* getCamParam() { return m_cCamParam;} |
---|
| 193 | Void setCamParam(TAppComCamPara * pCamparam) { m_cCamParam = pCamparam;} |
---|
| 194 | #endif |
---|
[608] | 195 | Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid ); |
---|
[1200] | 196 | Int getReferencePictureSetIdxForSOP(Int POCCurr, Int GOPid ); |
---|
| 197 | #if NH_MV |
---|
[56] | 198 | TEncAnalyze* getAnalyzeAll () { return &m_cAnalyzeAll; } |
---|
| 199 | TEncAnalyze* getAnalyzeI () { return &m_cAnalyzeI; } |
---|
| 200 | TEncAnalyze* getAnalyzeP () { return &m_cAnalyzeP; } |
---|
| 201 | TEncAnalyze* getAnalyzeB () { return &m_cAnalyzeB; } |
---|
[1200] | 202 | Int getNumAllPicCoded () { return m_uiNumAllPicCoded; } |
---|
| 203 | Int getFrameId (Int iGOPid); |
---|
[608] | 204 | TComPic* getPic ( Int poc ); |
---|
| 205 | Void setIvPicLists ( TComPicLists* picLists) { m_ivPicLists = picLists; } |
---|
[5] | 206 | #endif |
---|
[1200] | 207 | #if NH_3D |
---|
[1124] | 208 | Void setSps3dExtension ( TComSps3dExtension sps3dExtension ) { m_cSPS.setSps3dExtension( sps3dExtension ); }; |
---|
| 209 | #endif |
---|
[1225] | 210 | #if NH_3D_IC |
---|
[1066] | 211 | Void setICEnableCandidate ( Int* ICEnableCandidate) { m_aICEnableCandidate = ICEnableCandidate; } |
---|
| 212 | Void setICEnableNum ( Int* ICEnableNum) { m_aICEnableNum = ICEnableNum; } |
---|
| 213 | #endif |
---|
[2] | 214 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 215 | // encoder function |
---|
| 216 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 217 | |
---|
| 218 | /// encode several number of pictures until end-of-sequence |
---|
[1200] | 219 | #if NH_MV |
---|
| 220 | Void encode( Bool bEos, |
---|
| 221 | TComPicYuv* pcPicYuvOrg, |
---|
| 222 | TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, // used for SNR calculations. Picture in original colour space. |
---|
| 223 | TComList<TComPicYuv*>& rcListPicYuvRecOut, |
---|
| 224 | std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId ); |
---|
[655] | 225 | |
---|
[1200] | 226 | /// encode several number of pictures until end-of-sequence |
---|
| 227 | Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, |
---|
| 228 | TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, // used for SNR calculations. Picture in original colour space. |
---|
| 229 | TComList<TComPicYuv*>& rcListPicYuvRecOut, |
---|
| 230 | std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff, Int gopId); |
---|
[608] | 231 | #else |
---|
[1200] | 232 | Void encode( Bool bEos, |
---|
| 233 | TComPicYuv* pcPicYuvOrg, |
---|
| 234 | TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, // used for SNR calculations. Picture in original colour space. |
---|
| 235 | TComList<TComPicYuv*>& rcListPicYuvRecOut, |
---|
| 236 | std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); |
---|
[655] | 237 | |
---|
[1200] | 238 | /// encode several number of pictures until end-of-sequence |
---|
| 239 | Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, |
---|
| 240 | TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, // used for SNR calculations. Picture in original colour space. |
---|
| 241 | TComList<TComPicYuv*>& rcListPicYuvRecOut, |
---|
| 242 | std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff); |
---|
[608] | 243 | #endif |
---|
[1200] | 244 | Void printSummary(Bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField, m_printMSEBasedSequencePSNR, m_printSequenceMSE, m_cSPS.getBitDepths()); } |
---|
[608] | 245 | |
---|
[1200] | 246 | #if NH_3D_VSO |
---|
| 247 | Void setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset, Int maxCuHeight ); |
---|
[608] | 248 | #endif |
---|
[56] | 249 | }; |
---|
[2] | 250 | |
---|
[56] | 251 | //! \} |
---|
[2] | 252 | |
---|
| 253 | #endif // __TENCTOP__ |
---|
[1200] | 254 | |
---|