[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 |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2011, 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 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 | */ |
---|
[2] | 33 | |
---|
[5] | 34 | |
---|
[2] | 35 | /** \file TEncTop.h |
---|
| 36 | \brief encoder class (header) |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | #ifndef __TENCTOP__ |
---|
| 40 | #define __TENCTOP__ |
---|
| 41 | |
---|
| 42 | // Include files |
---|
| 43 | #include "../TLibCommon/TComList.h" |
---|
| 44 | #include "../TLibCommon/TComPrediction.h" |
---|
| 45 | #include "../TLibCommon/TComTrQuant.h" |
---|
| 46 | #include "../TLibCommon/TComBitStream.h" |
---|
| 47 | #include "../TLibCommon/TComDepthMapGenerator.h" |
---|
| 48 | #include "../TLibCommon/TComResidualGenerator.h" |
---|
| 49 | |
---|
| 50 | #include "../TLibVideoIO/TVideoIOYuv.h" |
---|
| 51 | #include "../TLibVideoIO/TVideoIOBits.h" |
---|
| 52 | |
---|
| 53 | #include "TEncCfg.h" |
---|
| 54 | #include "TEncGOP.h" |
---|
| 55 | #include "TEncSlice.h" |
---|
| 56 | #include "TEncEntropy.h" |
---|
| 57 | #include "TEncCavlc.h" |
---|
| 58 | #include "TEncSbac.h" |
---|
| 59 | #include "TEncSearch.h" |
---|
| 60 | #include "TEncAdaptiveLoopFilter.h" |
---|
| 61 | |
---|
| 62 | #include "TEncSeqStructure.h" |
---|
| 63 | #include <map> |
---|
| 64 | #include "TEncAnalyze.h" |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | // ==================================================================================================================== |
---|
| 68 | // Class definition |
---|
| 69 | // ==================================================================================================================== |
---|
| 70 | |
---|
| 71 | class TAppEncTop ; |
---|
| 72 | |
---|
| 73 | /// encoder class |
---|
| 74 | class TEncTop : public TEncCfg |
---|
| 75 | { |
---|
| 76 | private: |
---|
| 77 | // picture |
---|
| 78 | Int m_iPOCLast; ///< time index (POC) |
---|
| 79 | Int m_iNumPicRcvd; ///< number of received pictures |
---|
| 80 | UInt m_uiNumAllPicCoded; ///< number of coded pictures |
---|
| 81 | TComList<TComPic*> m_cListPic; ///< dynamic list of pictures |
---|
| 82 | |
---|
| 83 | Bool m_bSeqFirst ; |
---|
| 84 | TEncSeqStructure::Iterator m_cSeqIter; |
---|
| 85 | std::map<Int, TComPic*> m_acInputPicMap; |
---|
| 86 | std::map<PicOrderCnt, TComPicYuv*> m_acOutputPicMap; |
---|
| 87 | |
---|
| 88 | // encoder search |
---|
| 89 | TEncSearch m_cSearch; ///< encoder search class |
---|
| 90 | TEncEntropy* m_pcEntropyCoder; ///< entropy encoder |
---|
| 91 | TEncCavlc* m_pcCavlcCoder; ///< CAVLC encoder |
---|
| 92 | // coding tool |
---|
| 93 | TComTrQuant m_cTrQuant; ///< transform & quantization class |
---|
| 94 | TComLoopFilter m_cLoopFilter; ///< deblocking filter class |
---|
| 95 | #if MTK_SAO |
---|
| 96 | TEncSampleAdaptiveOffset m_cEncSAO; ///< sample adaptive offset class |
---|
| 97 | #endif |
---|
| 98 | TEncAdaptiveLoopFilter m_cAdaptiveLoopFilter; ///< adaptive loop filter class |
---|
| 99 | TEncEntropy m_cEntropyCoder; ///< entropy encoder |
---|
| 100 | TEncCavlc m_cCavlcCoder; ///< CAVLC encoder |
---|
| 101 | TEncSbac m_cSbacCoder; ///< SBAC encoder |
---|
| 102 | TEncBinCABAC m_cBinCoderCABAC; ///< bin coder CABAC |
---|
| 103 | |
---|
| 104 | // processing unit |
---|
| 105 | TEncPic m_cPicEncoder; ///< Pic encoder |
---|
| 106 | TEncSlice m_cSliceEncoder; ///< slice encoder |
---|
| 107 | TEncCu m_cCuEncoder; ///< CU encoder |
---|
[5] | 108 | #if DEPTH_MAP_GENERATION |
---|
[2] | 109 | TComDepthMapGenerator m_cDepthMapGenerator; ///< depth map generator |
---|
[5] | 110 | #endif |
---|
| 111 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 112 | TComResidualGenerator m_cResidualGenerator; ///< generator for residual pictures |
---|
[5] | 113 | #endif |
---|
[2] | 114 | |
---|
| 115 | // SPS |
---|
| 116 | TComSPS m_cSPS; ///< SPS |
---|
| 117 | TComPPS m_cPPS; ///< PPS |
---|
| 118 | |
---|
| 119 | // RD cost computation |
---|
| 120 | TComBitCounter m_cBitCounter; ///< bit counter for RD optimization |
---|
| 121 | TComRdCost m_cRdCost; ///< RD cost computation class |
---|
| 122 | TEncSbac*** m_pppcRDSbacCoder; ///< temporal storage for RD computation |
---|
| 123 | TEncSbac m_cRDGoOnSbacCoder; ///< going on SBAC model for RD stage |
---|
| 124 | TEncBinCABAC*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation |
---|
| 125 | TEncBinCABAC m_cRDGoOnBinCoderCABAC; ///< going on bin coder CABAC for RD stage |
---|
| 126 | |
---|
| 127 | std::vector<TEncTop*>* m_pacTEncTopList; |
---|
| 128 | TAppEncTop* m_pcTAppEncTop; // SB better: design a new MVTop encoder class, instead of mixing lib and app |
---|
| 129 | |
---|
| 130 | bool m_bPicWaitingForCoding; |
---|
| 131 | |
---|
| 132 | PicOrderCnt m_iFrameNumInCodingOrder; |
---|
| 133 | |
---|
| 134 | protected: |
---|
| 135 | Void xGetNewPicBuffer ( TComPic*& rpcPic ); ///< get picture buffer which will be processed |
---|
| 136 | Void xInitSPS (); ///< initialize SPS from encoder options |
---|
| 137 | #if CONSTRAINED_INTRA_PRED |
---|
| 138 | Void xInitPPS (); ///< initialize PPS from encoder options |
---|
| 139 | #endif |
---|
| 140 | Void xSetPicProperties( TComPic* pcPic ) ; |
---|
| 141 | Void xSetRefPics( TComPic* pcPic, RefPicList eRefPicList ); |
---|
| 142 | Void xCheckSliceType(TComPic* pcPic); |
---|
| 143 | |
---|
| 144 | public: |
---|
| 145 | TEncTop(); |
---|
| 146 | virtual ~TEncTop(); |
---|
| 147 | |
---|
| 148 | Void create (); |
---|
| 149 | Void destroy (); |
---|
| 150 | Void init ( TAppEncTop* pcTAppEncTop ); |
---|
| 151 | Void deletePicBuffer (); |
---|
| 152 | |
---|
| 153 | Void deleteExtraPicBuffers ( Int iPoc ); |
---|
| 154 | #if AMVP_BUFFERCOMPRESS |
---|
| 155 | Void compressMotion ( Int iPoc ); |
---|
| 156 | #endif |
---|
| 157 | |
---|
| 158 | UInt getNextFrameId () { return (UInt)m_cSeqIter.getPoc(); } |
---|
| 159 | Bool currentPocWillBeCoded () { return ( m_acInputPicMap.find( (Int)m_cSeqIter.getPoc() ) != m_acInputPicMap.end() ); } |
---|
| 160 | |
---|
| 161 | TComList<TComPic*> getCodedPictureStore(){ return m_cListPic;} |
---|
| 162 | |
---|
| 163 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 164 | // member access functions |
---|
| 165 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 166 | |
---|
| 167 | TComList<TComPic*>* getListPic () { return &m_cListPic; } |
---|
| 168 | TEncSearch* getPredSearch () { return &m_cSearch; } |
---|
| 169 | |
---|
| 170 | TComTrQuant* getTrQuant () { return &m_cTrQuant; } |
---|
| 171 | TComLoopFilter* getLoopFilter () { return &m_cLoopFilter; } |
---|
| 172 | TEncAdaptiveLoopFilter* getAdaptiveLoopFilter () { return &m_cAdaptiveLoopFilter; } |
---|
| 173 | #if MTK_SAO |
---|
| 174 | TEncSampleAdaptiveOffset* getSAO () { return &m_cEncSAO; } |
---|
| 175 | #endif |
---|
| 176 | TEncPic* getPicEncoder () { return &m_cPicEncoder; } |
---|
| 177 | TEncSlice* getSliceEncoder () { return &m_cSliceEncoder; } |
---|
| 178 | TEncCu* getCuEncoder () { return &m_cCuEncoder; } |
---|
| 179 | TEncEntropy* getEntropyCoder () { return &m_cEntropyCoder; } |
---|
| 180 | TEncCavlc* getCavlcCoder () { return &m_cCavlcCoder; } |
---|
| 181 | TEncSbac* getSbacCoder () { return &m_cSbacCoder; } |
---|
| 182 | TEncBinCABAC* getBinCABAC () { return &m_cBinCoderCABAC; } |
---|
| 183 | |
---|
| 184 | TComBitCounter* getBitCounter () { return &m_cBitCounter; } |
---|
| 185 | TComRdCost* getRdCost () { return &m_cRdCost; } |
---|
| 186 | TEncSbac*** getRDSbacCoder () { return m_pppcRDSbacCoder; } |
---|
| 187 | TEncSbac* getRDGoOnSbacCoder () { return &m_cRDGoOnSbacCoder; } |
---|
[5] | 188 | #if DEPTH_MAP_GENERATION |
---|
[2] | 189 | TComDepthMapGenerator* getDepthMapGenerator () { return &m_cDepthMapGenerator; } |
---|
[5] | 190 | #endif |
---|
| 191 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 192 | TComResidualGenerator* getResidualGenerator () { return &m_cResidualGenerator; } |
---|
[5] | 193 | #endif |
---|
[2] | 194 | |
---|
| 195 | TComSPS* getSPS () { return &m_cSPS; } |
---|
| 196 | TComPPS* getPPS () { return &m_cPPS; } |
---|
| 197 | |
---|
| 198 | Void setTEncTopList ( std::vector<TEncTop*>* pacTEncTopList ); |
---|
| 199 | TAppEncTop* getEncTop () { return m_pcTAppEncTop; } |
---|
| 200 | |
---|
| 201 | Int getNumAllPicCoded () { return m_uiNumAllPicCoded; } |
---|
| 202 | |
---|
| 203 | Void printOutSummary ( UInt uiNumAllPicCoded ); |
---|
| 204 | |
---|
| 205 | TEncAnalyze m_cAnalyzeAll; |
---|
| 206 | TEncAnalyze m_cAnalyzeI; |
---|
| 207 | TEncAnalyze m_cAnalyzeP; |
---|
| 208 | TEncAnalyze m_cAnalyzeB; |
---|
| 209 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 210 | // encoder function |
---|
| 211 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 212 | |
---|
| 213 | /// encode several number of pictures until end-of-sequence |
---|
| 214 | |
---|
| 215 | |
---|
| 216 | //GT PRE LOAD ENC BUFFER |
---|
| 217 | Void encode ( bool bEos, std::map<PicOrderCnt, TComPicYuv*>& rcMapPicYuvRecOut, TComBitstream* pcBitstreamOut, Bool& bNewPicNeeded ); |
---|
| 218 | Void receivePic( bool bEos, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvRec, TComPicYuv* pcOrgPdmDepth = 0 ); |
---|
| 219 | }; |
---|
| 220 | |
---|
| 221 | #endif // __TENCTOP__ |
---|
| 222 | |
---|