[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 |
---|
[1313] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1313] | 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" |
---|
[1313] | 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 | |
---|
| 67 | /// encoder class |
---|
| 68 | class TEncTop : public TEncCfg |
---|
| 69 | { |
---|
| 70 | private: |
---|
| 71 | // picture |
---|
| 72 | Int m_iPOCLast; ///< time index (POC) |
---|
| 73 | Int m_iNumPicRcvd; ///< number of received pictures |
---|
| 74 | UInt m_uiNumAllPicCoded; ///< number of coded pictures |
---|
[1321] | 75 | #if !NH_MV |
---|
[2] | 76 | TComList<TComPic*> m_cListPic; ///< dynamic list of pictures |
---|
[1321] | 77 | #endif |
---|
[1313] | 78 | |
---|
| 79 | #if NH_MV |
---|
[608] | 80 | TComPicLists* m_ivPicLists; ///< access to picture lists of other layers |
---|
| 81 | #endif |
---|
[2] | 82 | // encoder search |
---|
| 83 | TEncSearch m_cSearch; ///< encoder search class |
---|
[872] | 84 | //TEncEntropy* m_pcEntropyCoder; ///< entropy encoder |
---|
[1313] | 85 | TEncCavlc* m_pcCavlcCoder; ///< CAVLC encoder |
---|
[2] | 86 | // coding tool |
---|
| 87 | TComTrQuant m_cTrQuant; ///< transform & quantization class |
---|
| 88 | TComLoopFilter m_cLoopFilter; ///< deblocking filter class |
---|
[56] | 89 | TEncSampleAdaptiveOffset m_cEncSAO; ///< sample adaptive offset class |
---|
[2] | 90 | TEncEntropy m_cEntropyCoder; ///< entropy encoder |
---|
| 91 | TEncCavlc m_cCavlcCoder; ///< CAVLC encoder |
---|
| 92 | TEncSbac m_cSbacCoder; ///< SBAC encoder |
---|
| 93 | TEncBinCABAC m_cBinCoderCABAC; ///< bin coder CABAC |
---|
[1313] | 94 | |
---|
[2] | 95 | // processing unit |
---|
[56] | 96 | TEncGOP m_cGOPEncoder; ///< GOP encoder |
---|
[2] | 97 | TEncSlice m_cSliceEncoder; ///< slice encoder |
---|
| 98 | TEncCu m_cCuEncoder; ///< CU encoder |
---|
| 99 | // SPS |
---|
[1313] | 100 | TComSPS m_cSPS; ///< SPS. This is the base value. This is copied to TComPicSym |
---|
| 101 | TComPPS m_cPPS; ///< PPS. This is the base value. This is copied to TComPicSym |
---|
[2] | 102 | // RD cost computation |
---|
| 103 | TComRdCost m_cRdCost; ///< RD cost computation class |
---|
| 104 | TEncSbac*** m_pppcRDSbacCoder; ///< temporal storage for RD computation |
---|
| 105 | TEncSbac m_cRDGoOnSbacCoder; ///< going on SBAC model for RD stage |
---|
[56] | 106 | #if FAST_BIT_EST |
---|
| 107 | TEncBinCABACCounter*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation |
---|
| 108 | TEncBinCABACCounter m_cRDGoOnBinCoderCABAC; ///< going on bin coder CABAC for RD stage |
---|
| 109 | #else |
---|
[2] | 110 | TEncBinCABAC*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation |
---|
| 111 | TEncBinCABAC m_cRDGoOnBinCoderCABAC; ///< going on bin coder CABAC for RD stage |
---|
[56] | 112 | #endif |
---|
[2] | 113 | |
---|
[56] | 114 | // quality control |
---|
| 115 | TEncPreanalyzer m_cPreanalyzer; ///< image characteristics analyzer for TM5-step3-like adaptive QP |
---|
| 116 | |
---|
[608] | 117 | TEncRateCtrl m_cRateCtrl; ///< Rate control class |
---|
[655] | 118 | |
---|
[1313] | 119 | #if NH_MV |
---|
[56] | 120 | TEncAnalyze m_cAnalyzeAll; |
---|
| 121 | TEncAnalyze m_cAnalyzeI; |
---|
| 122 | TEncAnalyze m_cAnalyzeP; |
---|
[1313] | 123 | TEncAnalyze m_cAnalyzeB; |
---|
| 124 | TEncAnalyze m_cAnalyzeAll_in; |
---|
[608] | 125 | #endif |
---|
[2] | 126 | protected: |
---|
| 127 | Void xGetNewPicBuffer ( TComPic*& rpcPic ); ///< get picture buffer which will be processed |
---|
[1313] | 128 | Void xInitVPS (); ///< initialize VPS from encoder options |
---|
[2] | 129 | Void xInitSPS (); ///< initialize SPS from encoder options |
---|
| 130 | Void xInitPPS (); ///< initialize PPS from encoder options |
---|
[1313] | 131 | Void xInitScalingLists(); ///< initialize scaling lists |
---|
| 132 | Void xInitHrdParameters(); ///< initialize HRD parameters |
---|
| 133 | |
---|
[56] | 134 | Void xInitPPSforTiles (); |
---|
[655] | 135 | Void xInitRPS (Bool isFieldCoding); ///< initialize PPS from encoder options |
---|
[2] | 136 | |
---|
| 137 | public: |
---|
| 138 | TEncTop(); |
---|
| 139 | virtual ~TEncTop(); |
---|
[1313] | 140 | |
---|
[2] | 141 | Void create (); |
---|
| 142 | Void destroy (); |
---|
[655] | 143 | Void init (Bool isFieldCoding); |
---|
[1313] | 144 | #if NH_MV |
---|
[608] | 145 | TComPicLists* getIvPicLists() { return m_ivPicLists; } |
---|
| 146 | #endif |
---|
[2] | 147 | Void deletePicBuffer (); |
---|
[1313] | 148 | #if NH_MV |
---|
[608] | 149 | Void initNewPic(TComPicYuv* pcPicYuvOrg); |
---|
| 150 | #endif |
---|
[2] | 151 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 152 | // member access functions |
---|
| 153 | // ------------------------------------------------------------------------------------------------------------------- |
---|
[1313] | 154 | |
---|
[1321] | 155 | #if NH_MV |
---|
| 156 | TComList<TComPic*>* getListPic () { return m_ivPicLists->getSubDpb( getLayerId(), false); } |
---|
| 157 | #else |
---|
[2] | 158 | TComList<TComPic*>* getListPic () { return &m_cListPic; } |
---|
[1321] | 159 | #endif |
---|
[2] | 160 | TEncSearch* getPredSearch () { return &m_cSearch; } |
---|
[1313] | 161 | |
---|
[2] | 162 | TComTrQuant* getTrQuant () { return &m_cTrQuant; } |
---|
| 163 | TComLoopFilter* getLoopFilter () { return &m_cLoopFilter; } |
---|
[56] | 164 | TEncSampleAdaptiveOffset* getSAO () { return &m_cEncSAO; } |
---|
| 165 | TEncGOP* getGOPEncoder () { return &m_cGOPEncoder; } |
---|
[2] | 166 | TEncSlice* getSliceEncoder () { return &m_cSliceEncoder; } |
---|
| 167 | TEncCu* getCuEncoder () { return &m_cCuEncoder; } |
---|
| 168 | TEncEntropy* getEntropyCoder () { return &m_cEntropyCoder; } |
---|
| 169 | TEncCavlc* getCavlcCoder () { return &m_cCavlcCoder; } |
---|
| 170 | TEncSbac* getSbacCoder () { return &m_cSbacCoder; } |
---|
| 171 | TEncBinCABAC* getBinCABAC () { return &m_cBinCoderCABAC; } |
---|
[1313] | 172 | |
---|
[2] | 173 | TComRdCost* getRdCost () { return &m_cRdCost; } |
---|
| 174 | TEncSbac*** getRDSbacCoder () { return m_pppcRDSbacCoder; } |
---|
| 175 | TEncSbac* getRDGoOnSbacCoder () { return &m_cRDGoOnSbacCoder; } |
---|
[608] | 176 | TEncRateCtrl* getRateCtrl () { return &m_cRateCtrl; } |
---|
| 177 | Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid ); |
---|
[1313] | 178 | Int getReferencePictureSetIdxForSOP(Int POCCurr, Int GOPid ); |
---|
| 179 | #if NH_MV |
---|
[56] | 180 | TEncAnalyze* getAnalyzeAll () { return &m_cAnalyzeAll; } |
---|
| 181 | TEncAnalyze* getAnalyzeI () { return &m_cAnalyzeI; } |
---|
| 182 | TEncAnalyze* getAnalyzeP () { return &m_cAnalyzeP; } |
---|
| 183 | TEncAnalyze* getAnalyzeB () { return &m_cAnalyzeB; } |
---|
[1313] | 184 | Int getNumAllPicCoded () { return m_uiNumAllPicCoded; } |
---|
| 185 | Int getFrameId (Int iGOPid); |
---|
[608] | 186 | TComPic* getPic ( Int poc ); |
---|
| 187 | Void setIvPicLists ( TComPicLists* picLists) { m_ivPicLists = picLists; } |
---|
[5] | 188 | #endif |
---|
[2] | 189 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 190 | // encoder function |
---|
| 191 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 192 | |
---|
| 193 | /// encode several number of pictures until end-of-sequence |
---|
[1313] | 194 | #if NH_MV |
---|
| 195 | Void encode( Bool bEos, |
---|
| 196 | TComPicYuv* pcPicYuvOrg, |
---|
| 197 | TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, // used for SNR calculations. Picture in original colour space. |
---|
| 198 | TComList<TComPicYuv*>& rcListPicYuvRecOut, |
---|
| 199 | std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId ); |
---|
[655] | 200 | |
---|
[1313] | 201 | /// encode several number of pictures until end-of-sequence |
---|
| 202 | Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, |
---|
| 203 | TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, // used for SNR calculations. Picture in original colour space. |
---|
| 204 | TComList<TComPicYuv*>& rcListPicYuvRecOut, |
---|
| 205 | std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff, Int gopId); |
---|
[608] | 206 | #else |
---|
[1313] | 207 | Void encode( Bool bEos, |
---|
| 208 | TComPicYuv* pcPicYuvOrg, |
---|
| 209 | TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, // used for SNR calculations. Picture in original colour space. |
---|
| 210 | TComList<TComPicYuv*>& rcListPicYuvRecOut, |
---|
| 211 | std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); |
---|
[655] | 212 | |
---|
[1313] | 213 | /// encode several number of pictures until end-of-sequence |
---|
| 214 | Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, |
---|
| 215 | TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, // used for SNR calculations. Picture in original colour space. |
---|
| 216 | TComList<TComPicYuv*>& rcListPicYuvRecOut, |
---|
| 217 | std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff); |
---|
[608] | 218 | #endif |
---|
[1313] | 219 | Void printSummary(Bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField, m_printMSEBasedSequencePSNR, m_printSequenceMSE, m_cSPS.getBitDepths()); } |
---|
[608] | 220 | |
---|
[56] | 221 | }; |
---|
[2] | 222 | |
---|
[56] | 223 | //! \} |
---|
[2] | 224 | |
---|
| 225 | #endif // __TENCTOP__ |
---|
[1313] | 226 | |
---|