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