[324] | 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-2013, 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 TEncTop.h |
---|
| 35 | \brief encoder class (header) |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #ifndef __TENCTOP__ |
---|
| 39 | #define __TENCTOP__ |
---|
| 40 | |
---|
| 41 | // Include files |
---|
| 42 | #include "TLibCommon/TComList.h" |
---|
| 43 | #include "TLibCommon/TComPrediction.h" |
---|
| 44 | #include "TLibCommon/TComTrQuant.h" |
---|
| 45 | #include "TLibCommon/AccessUnit.h" |
---|
| 46 | |
---|
| 47 | #include "TLibVideoIO/TVideoIOYuv.h" |
---|
| 48 | |
---|
| 49 | #include "TEncCfg.h" |
---|
| 50 | #include "TEncGOP.h" |
---|
| 51 | #include "TEncSlice.h" |
---|
| 52 | #include "TEncEntropy.h" |
---|
| 53 | #include "TEncCavlc.h" |
---|
| 54 | #include "TEncSbac.h" |
---|
| 55 | #include "TEncSearch.h" |
---|
| 56 | #include "TEncSampleAdaptiveOffset.h" |
---|
| 57 | #include "TEncPreanalyzer.h" |
---|
| 58 | #include "TEncRateCtrl.h" |
---|
| 59 | //! \ingroup TLibEncoder |
---|
| 60 | //! \{ |
---|
| 61 | |
---|
| 62 | // ==================================================================================================================== |
---|
| 63 | // Class definition |
---|
| 64 | // ==================================================================================================================== |
---|
| 65 | |
---|
| 66 | /// encoder class |
---|
| 67 | class TEncTop : public TEncCfg |
---|
| 68 | { |
---|
| 69 | private: |
---|
| 70 | // picture |
---|
| 71 | Int m_iPOCLast; ///< time index (POC) |
---|
| 72 | Int m_iNumPicRcvd; ///< number of received pictures |
---|
| 73 | UInt m_uiNumAllPicCoded; ///< number of coded pictures |
---|
| 74 | TComList<TComPic*> m_cListPic; ///< dynamic list of pictures |
---|
| 75 | |
---|
[368] | 76 | #if H_MV |
---|
| 77 | TComPicLists* m_ivPicLists; ///< access to picture lists of other layers |
---|
| 78 | #endif |
---|
[324] | 79 | // encoder search |
---|
| 80 | TEncSearch m_cSearch; ///< encoder search class |
---|
| 81 | TEncEntropy* m_pcEntropyCoder; ///< entropy encoder |
---|
| 82 | TEncCavlc* m_pcCavlcCoder; ///< CAVLC encoder |
---|
| 83 | // coding tool |
---|
| 84 | TComTrQuant m_cTrQuant; ///< transform & quantization class |
---|
| 85 | TComLoopFilter m_cLoopFilter; ///< deblocking filter class |
---|
| 86 | TEncSampleAdaptiveOffset m_cEncSAO; ///< sample adaptive offset class |
---|
| 87 | TEncEntropy m_cEntropyCoder; ///< entropy encoder |
---|
| 88 | TEncCavlc m_cCavlcCoder; ///< CAVLC encoder |
---|
| 89 | TEncSbac m_cSbacCoder; ///< SBAC encoder |
---|
| 90 | TEncBinCABAC m_cBinCoderCABAC; ///< bin coder CABAC |
---|
| 91 | TEncSbac* m_pcSbacCoders; ///< SBAC encoders (to encode substreams ) |
---|
| 92 | TEncBinCABAC* m_pcBinCoderCABACs; ///< bin coders CABAC (one per substream) |
---|
| 93 | |
---|
| 94 | // processing unit |
---|
| 95 | TEncGOP m_cGOPEncoder; ///< GOP encoder |
---|
| 96 | TEncSlice m_cSliceEncoder; ///< slice encoder |
---|
| 97 | TEncCu m_cCuEncoder; ///< CU encoder |
---|
| 98 | // SPS |
---|
| 99 | TComSPS m_cSPS; ///< SPS |
---|
| 100 | TComPPS m_cPPS; ///< PPS |
---|
| 101 | // RD cost computation |
---|
| 102 | TComBitCounter m_cBitCounter; ///< bit counter for RD optimization |
---|
| 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 |
---|
| 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 |
---|
| 110 | TEncBinCABAC*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation |
---|
| 111 | TEncBinCABAC m_cRDGoOnBinCoderCABAC; ///< going on bin coder CABAC for RD stage |
---|
| 112 | #endif |
---|
| 113 | Int m_iNumSubstreams; ///< # of top-level elements allocated. |
---|
| 114 | TComBitCounter* m_pcBitCounters; ///< bit counters for RD optimization per substream |
---|
| 115 | TComRdCost* m_pcRdCosts; ///< RD cost computation class per substream |
---|
| 116 | TEncSbac**** m_ppppcRDSbacCoders; ///< temporal storage for RD computation per substream |
---|
| 117 | TEncSbac* m_pcRDGoOnSbacCoders; ///< going on SBAC model for RD stage per substream |
---|
| 118 | TEncBinCABAC**** m_ppppcBinCodersCABAC; ///< temporal CABAC state storage for RD computation per substream |
---|
| 119 | TEncBinCABAC* m_pcRDGoOnBinCodersCABAC; ///< going on bin coder CABAC for RD stage per substream |
---|
| 120 | |
---|
| 121 | // quality control |
---|
| 122 | TEncPreanalyzer m_cPreanalyzer; ///< image characteristics analyzer for TM5-step3-like adaptive QP |
---|
| 123 | |
---|
| 124 | TComScalingList m_scalingList; ///< quantization matrix information |
---|
| 125 | TEncRateCtrl m_cRateCtrl; ///< Rate control class |
---|
| 126 | |
---|
[368] | 127 | #if H_MV |
---|
| 128 | TEncAnalyze m_cAnalyzeAll; |
---|
| 129 | TEncAnalyze m_cAnalyzeI; |
---|
| 130 | TEncAnalyze m_cAnalyzeP; |
---|
| 131 | TEncAnalyze m_cAnalyzeB; |
---|
| 132 | #endif |
---|
[324] | 133 | protected: |
---|
| 134 | Void xGetNewPicBuffer ( TComPic*& rpcPic ); ///< get picture buffer which will be processed |
---|
| 135 | Void xInitSPS (); ///< initialize SPS from encoder options |
---|
| 136 | Void xInitPPS (); ///< initialize PPS from encoder options |
---|
| 137 | |
---|
| 138 | Void xInitPPSforTiles (); |
---|
| 139 | Void xInitRPS (); ///< initialize PPS from encoder options |
---|
| 140 | |
---|
| 141 | public: |
---|
| 142 | TEncTop(); |
---|
| 143 | virtual ~TEncTop(); |
---|
| 144 | |
---|
| 145 | Void create (); |
---|
| 146 | Void destroy (); |
---|
| 147 | Void init (); |
---|
[368] | 148 | #if H_MV |
---|
| 149 | TComPicLists* getIvPicLists() { return m_ivPicLists; } |
---|
| 150 | #endif |
---|
[324] | 151 | Void deletePicBuffer (); |
---|
| 152 | |
---|
| 153 | Void createWPPCoders(Int iNumSubstreams); |
---|
| 154 | |
---|
[368] | 155 | #if H_MV |
---|
| 156 | Void initNewPic(TComPicYuv* pcPicYuvOrg); |
---|
| 157 | #endif |
---|
[324] | 158 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 159 | // member access functions |
---|
| 160 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 161 | |
---|
| 162 | TComList<TComPic*>* getListPic () { return &m_cListPic; } |
---|
| 163 | TEncSearch* getPredSearch () { return &m_cSearch; } |
---|
| 164 | |
---|
| 165 | TComTrQuant* getTrQuant () { return &m_cTrQuant; } |
---|
| 166 | TComLoopFilter* getLoopFilter () { return &m_cLoopFilter; } |
---|
| 167 | TEncSampleAdaptiveOffset* getSAO () { return &m_cEncSAO; } |
---|
| 168 | TEncGOP* getGOPEncoder () { return &m_cGOPEncoder; } |
---|
| 169 | TEncSlice* getSliceEncoder () { return &m_cSliceEncoder; } |
---|
| 170 | TEncCu* getCuEncoder () { return &m_cCuEncoder; } |
---|
| 171 | TEncEntropy* getEntropyCoder () { return &m_cEntropyCoder; } |
---|
| 172 | TEncCavlc* getCavlcCoder () { return &m_cCavlcCoder; } |
---|
| 173 | TEncSbac* getSbacCoder () { return &m_cSbacCoder; } |
---|
| 174 | TEncBinCABAC* getBinCABAC () { return &m_cBinCoderCABAC; } |
---|
| 175 | TEncSbac* getSbacCoders () { return m_pcSbacCoders; } |
---|
| 176 | TEncBinCABAC* getBinCABACs () { return m_pcBinCoderCABACs; } |
---|
| 177 | |
---|
| 178 | TComBitCounter* getBitCounter () { return &m_cBitCounter; } |
---|
| 179 | TComRdCost* getRdCost () { return &m_cRdCost; } |
---|
| 180 | TEncSbac*** getRDSbacCoder () { return m_pppcRDSbacCoder; } |
---|
| 181 | TEncSbac* getRDGoOnSbacCoder () { return &m_cRDGoOnSbacCoder; } |
---|
| 182 | TComBitCounter* getBitCounters () { return m_pcBitCounters; } |
---|
| 183 | TComRdCost* getRdCosts () { return m_pcRdCosts; } |
---|
| 184 | TEncSbac**** getRDSbacCoders () { return m_ppppcRDSbacCoders; } |
---|
| 185 | TEncSbac* getRDGoOnSbacCoders () { return m_pcRDGoOnSbacCoders; } |
---|
| 186 | TEncRateCtrl* getRateCtrl () { return &m_cRateCtrl; } |
---|
| 187 | TComSPS* getSPS () { return &m_cSPS; } |
---|
| 188 | TComPPS* getPPS () { return &m_cPPS; } |
---|
| 189 | Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid ); |
---|
[362] | 190 | #if L0208_SOP_DESCRIPTION_SEI |
---|
| 191 | Int getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid ); |
---|
| 192 | #endif |
---|
[324] | 193 | TComScalingList* getScalingList () { return &m_scalingList; } |
---|
[368] | 194 | #if H_MV |
---|
| 195 | TEncAnalyze* getAnalyzeAll () { return &m_cAnalyzeAll; } |
---|
| 196 | TEncAnalyze* getAnalyzeI () { return &m_cAnalyzeI; } |
---|
| 197 | TEncAnalyze* getAnalyzeP () { return &m_cAnalyzeP; } |
---|
| 198 | TEncAnalyze* getAnalyzeB () { return &m_cAnalyzeB; } |
---|
| 199 | |
---|
| 200 | Int getNumAllPicCoded () { return m_uiNumAllPicCoded; } |
---|
| 201 | |
---|
| 202 | Int getFrameId (Int iGOPid); |
---|
| 203 | |
---|
| 204 | TComPic* getPic ( Int poc ); |
---|
| 205 | Void setIvPicLists ( TComPicLists* picLists) { m_ivPicLists = picLists; } |
---|
| 206 | #endif |
---|
[324] | 207 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 208 | // encoder function |
---|
| 209 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 210 | |
---|
| 211 | /// encode several number of pictures until end-of-sequence |
---|
[368] | 212 | #if H_MV |
---|
| 213 | Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded , Int gopId ); |
---|
| 214 | #else |
---|
[324] | 215 | Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, |
---|
[362] | 216 | std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); |
---|
[368] | 217 | #endif |
---|
[324] | 218 | |
---|
[368] | 219 | #if H_MV |
---|
| 220 | Void printSummary ( Int numAllPicCoded ); |
---|
| 221 | #else |
---|
[324] | 222 | void printSummary() { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded); } |
---|
[368] | 223 | #endif |
---|
[324] | 224 | }; |
---|
| 225 | |
---|
| 226 | //! \} |
---|
| 227 | |
---|
| 228 | #endif // __TENCTOP__ |
---|