[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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, 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" |
---|
| 45 | #include "TLibCommon/AccessUnit.h" |
---|
| 46 | #include "TLibCommon/TComDepthMapGenerator.h" |
---|
[2] | 47 | #include "../TLibCommon/TComResidualGenerator.h" |
---|
| 48 | |
---|
[56] | 49 | #include "TLibVideoIO/TVideoIOYuv.h" |
---|
[2] | 50 | |
---|
| 51 | #include "TEncCfg.h" |
---|
| 52 | #include "TEncGOP.h" |
---|
| 53 | #include "TEncSlice.h" |
---|
| 54 | #include "TEncEntropy.h" |
---|
| 55 | #include "TEncCavlc.h" |
---|
| 56 | #include "TEncSbac.h" |
---|
| 57 | #include "TEncSearch.h" |
---|
| 58 | #include "TEncAdaptiveLoopFilter.h" |
---|
[56] | 59 | #include "TEncSampleAdaptiveOffset.h" |
---|
| 60 | #include "TEncPreanalyzer.h" |
---|
[2] | 61 | |
---|
[56] | 62 | //! \ingroup TLibEncoder |
---|
| 63 | //! \{ |
---|
[2] | 64 | |
---|
| 65 | // ==================================================================================================================== |
---|
| 66 | // Class definition |
---|
| 67 | // ==================================================================================================================== |
---|
| 68 | |
---|
[56] | 69 | class TAppEncTop; |
---|
[2] | 70 | |
---|
| 71 | /// encoder class |
---|
| 72 | class TEncTop : public TEncCfg |
---|
| 73 | { |
---|
| 74 | private: |
---|
| 75 | // picture |
---|
| 76 | Int m_iPOCLast; ///< time index (POC) |
---|
| 77 | Int m_iNumPicRcvd; ///< number of received pictures |
---|
| 78 | UInt m_uiNumAllPicCoded; ///< number of coded pictures |
---|
| 79 | TComList<TComPic*> m_cListPic; ///< dynamic list of pictures |
---|
[56] | 80 | |
---|
[2] | 81 | // encoder search |
---|
| 82 | TEncSearch m_cSearch; ///< encoder search class |
---|
[56] | 83 | TEncEntropy* m_pcEntropyCoder; ///< entropy encoder |
---|
| 84 | TEncCavlc* m_pcCavlcCoder; ///< CAVLC encoder |
---|
[2] | 85 | // coding tool |
---|
| 86 | TComTrQuant m_cTrQuant; ///< transform & quantization class |
---|
| 87 | TComLoopFilter m_cLoopFilter; ///< deblocking filter class |
---|
[56] | 88 | TEncSampleAdaptiveOffset m_cEncSAO; ///< sample adaptive offset class |
---|
[2] | 89 | TEncAdaptiveLoopFilter m_cAdaptiveLoopFilter; ///< adaptive loop filter class |
---|
| 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 |
---|
[56] | 94 | TEncSbac* m_pcSbacCoders; ///< SBAC encoders (to encode substreams ) |
---|
| 95 | TEncBinCABAC* m_pcBinCoderCABACs; ///< bin coders CABAC (one per substream) |
---|
| 96 | |
---|
[2] | 97 | // processing unit |
---|
[56] | 98 | TEncGOP m_cGOPEncoder; ///< GOP encoder |
---|
[2] | 99 | TEncSlice m_cSliceEncoder; ///< slice encoder |
---|
| 100 | TEncCu m_cCuEncoder; ///< CU encoder |
---|
[56] | 101 | |
---|
[5] | 102 | #if DEPTH_MAP_GENERATION |
---|
[2] | 103 | TComDepthMapGenerator m_cDepthMapGenerator; ///< depth map generator |
---|
[5] | 104 | #endif |
---|
| 105 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 106 | TComResidualGenerator m_cResidualGenerator; ///< generator for residual pictures |
---|
[5] | 107 | #endif |
---|
[2] | 108 | // SPS |
---|
| 109 | TComSPS m_cSPS; ///< SPS |
---|
| 110 | TComPPS m_cPPS; ///< PPS |
---|
[56] | 111 | std::vector<TComAPS> m_vAPS; //!< APS container |
---|
| 112 | TComRPSList m_RPSList; ///< RPS |
---|
| 113 | |
---|
[2] | 114 | // RD cost computation |
---|
| 115 | TComBitCounter m_cBitCounter; ///< bit counter for RD optimization |
---|
| 116 | TComRdCost m_cRdCost; ///< RD cost computation class |
---|
| 117 | TEncSbac*** m_pppcRDSbacCoder; ///< temporal storage for RD computation |
---|
| 118 | TEncSbac m_cRDGoOnSbacCoder; ///< going on SBAC model for RD stage |
---|
[56] | 119 | #if FAST_BIT_EST |
---|
| 120 | TEncBinCABACCounter*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation |
---|
| 121 | TEncBinCABACCounter m_cRDGoOnBinCoderCABAC; ///< going on bin coder CABAC for RD stage |
---|
| 122 | #else |
---|
[2] | 123 | TEncBinCABAC*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation |
---|
| 124 | TEncBinCABAC m_cRDGoOnBinCoderCABAC; ///< going on bin coder CABAC for RD stage |
---|
[56] | 125 | #endif |
---|
| 126 | Int m_iNumSubstreams; ///< # of top-level elements allocated. |
---|
| 127 | TComBitCounter* m_pcBitCounters; ///< bit counters for RD optimization per substream |
---|
| 128 | TComRdCost* m_pcRdCosts; ///< RD cost computation class per substream |
---|
| 129 | TEncSbac**** m_ppppcRDSbacCoders; ///< temporal storage for RD computation per substream |
---|
| 130 | TEncSbac* m_pcRDGoOnSbacCoders; ///< going on SBAC model for RD stage per substream |
---|
| 131 | TEncBinCABAC**** m_ppppcBinCodersCABAC; ///< temporal CABAC state storage for RD computation per substream |
---|
| 132 | TEncBinCABAC* m_pcRDGoOnBinCodersCABAC; ///< going on bin coder CABAC for RD stage per substream |
---|
[2] | 133 | |
---|
[56] | 134 | // quality control |
---|
| 135 | TEncPreanalyzer m_cPreanalyzer; ///< image characteristics analyzer for TM5-step3-like adaptive QP |
---|
| 136 | |
---|
| 137 | TComScalingList m_scalingList; ///< quantization matrix information |
---|
| 138 | |
---|
[2] | 139 | std::vector<TEncTop*>* m_pacTEncTopList; |
---|
[56] | 140 | TAppEncTop* m_pcTAppEncTop; |
---|
[2] | 141 | |
---|
[56] | 142 | TEncAnalyze m_cAnalyzeAll; |
---|
| 143 | TEncAnalyze m_cAnalyzeI; |
---|
| 144 | TEncAnalyze m_cAnalyzeP; |
---|
| 145 | TEncAnalyze m_cAnalyzeB; |
---|
[2] | 146 | |
---|
[166] | 147 | #if VSP_N |
---|
| 148 | TComPic* m_pcPicVSP; ///< view synthesis prediction buffer for current POC to be coded |
---|
| 149 | TComPic* m_pcPicAvail; |
---|
[213] | 150 | Bool m_bIsFirstInView; |
---|
[166] | 151 | #endif |
---|
| 152 | |
---|
[2] | 153 | protected: |
---|
| 154 | Void xGetNewPicBuffer ( TComPic*& rpcPic ); ///< get picture buffer which will be processed |
---|
| 155 | Void xInitSPS (); ///< initialize SPS from encoder options |
---|
| 156 | Void xInitPPS (); ///< initialize PPS from encoder options |
---|
[56] | 157 | |
---|
| 158 | Void xInitPPSforTiles (); |
---|
| 159 | Void xInitRPS (); ///< initialize PPS from encoder options |
---|
| 160 | Void xInitSPSforInterViewRefs(); |
---|
[2] | 161 | |
---|
| 162 | public: |
---|
| 163 | TEncTop(); |
---|
| 164 | virtual ~TEncTop(); |
---|
[56] | 165 | |
---|
[2] | 166 | Void create (); |
---|
| 167 | Void destroy (); |
---|
| 168 | Void init ( TAppEncTop* pcTAppEncTop ); |
---|
| 169 | Void deletePicBuffer (); |
---|
| 170 | |
---|
[56] | 171 | UInt getFrameId (Int iGOPid) { |
---|
| 172 | if(m_iPOCLast == 0) |
---|
| 173 | { |
---|
| 174 | return(0 ); |
---|
| 175 | } |
---|
| 176 | else |
---|
| 177 | { |
---|
| 178 | return m_iPOCLast -m_iNumPicRcvd+ getGOPEntry(iGOPid).m_POC ; |
---|
| 179 | } |
---|
| 180 | } |
---|
| 181 | #if HHI_INTERVIEW_SKIP || HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 182 | Void deleteExtraPicBuffers ( Int iPoc ); |
---|
| 183 | #endif |
---|
| 184 | |
---|
[56] | 185 | Void compressMotion ( Int iPoc ); |
---|
[2] | 186 | |
---|
[56] | 187 | Void initNewPic(TComPicYuv* pcPicYuvOrg, TComPicYuv* pcOrgPdmDepth = 0); |
---|
[2] | 188 | |
---|
[56] | 189 | Void createWPPCoders(Int iNumSubstreams); |
---|
| 190 | |
---|
[2] | 191 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 192 | // member access functions |
---|
| 193 | // ------------------------------------------------------------------------------------------------------------------- |
---|
[56] | 194 | |
---|
[2] | 195 | TComList<TComPic*>* getListPic () { return &m_cListPic; } |
---|
| 196 | TEncSearch* getPredSearch () { return &m_cSearch; } |
---|
[56] | 197 | |
---|
[2] | 198 | TComTrQuant* getTrQuant () { return &m_cTrQuant; } |
---|
| 199 | TComLoopFilter* getLoopFilter () { return &m_cLoopFilter; } |
---|
| 200 | TEncAdaptiveLoopFilter* getAdaptiveLoopFilter () { return &m_cAdaptiveLoopFilter; } |
---|
[56] | 201 | TEncSampleAdaptiveOffset* getSAO () { return &m_cEncSAO; } |
---|
| 202 | TEncGOP* getGOPEncoder () { return &m_cGOPEncoder; } |
---|
[2] | 203 | TEncSlice* getSliceEncoder () { return &m_cSliceEncoder; } |
---|
| 204 | TEncCu* getCuEncoder () { return &m_cCuEncoder; } |
---|
| 205 | TEncEntropy* getEntropyCoder () { return &m_cEntropyCoder; } |
---|
| 206 | TEncCavlc* getCavlcCoder () { return &m_cCavlcCoder; } |
---|
| 207 | TEncSbac* getSbacCoder () { return &m_cSbacCoder; } |
---|
| 208 | TEncBinCABAC* getBinCABAC () { return &m_cBinCoderCABAC; } |
---|
[56] | 209 | TEncSbac* getSbacCoders () { return m_pcSbacCoders; } |
---|
| 210 | TEncBinCABAC* getBinCABACs () { return m_pcBinCoderCABACs; } |
---|
| 211 | |
---|
[2] | 212 | TComBitCounter* getBitCounter () { return &m_cBitCounter; } |
---|
| 213 | TComRdCost* getRdCost () { return &m_cRdCost; } |
---|
| 214 | TEncSbac*** getRDSbacCoder () { return m_pppcRDSbacCoder; } |
---|
| 215 | TEncSbac* getRDGoOnSbacCoder () { return &m_cRDGoOnSbacCoder; } |
---|
[56] | 216 | TComBitCounter* getBitCounters () { return m_pcBitCounters; } |
---|
| 217 | TComRdCost* getRdCosts () { return m_pcRdCosts; } |
---|
| 218 | TEncSbac**** getRDSbacCoders () { return m_ppppcRDSbacCoders; } |
---|
| 219 | TEncSbac* getRDGoOnSbacCoders () { return m_pcRDGoOnSbacCoders; } |
---|
| 220 | |
---|
| 221 | Void setTEncTopList ( std::vector<TEncTop*>* pacTEncTopList ); |
---|
| 222 | TAppEncTop* getEncTop () { return m_pcTAppEncTop; } |
---|
| 223 | Int getNumAllPicCoded () { return m_uiNumAllPicCoded; } |
---|
| 224 | Void printOutSummary ( UInt uiNumAllPicCoded ); |
---|
| 225 | |
---|
| 226 | TComSPS* getSPS () { return &m_cSPS; } |
---|
| 227 | TComPPS* getPPS () { return &m_cPPS; } |
---|
| 228 | std::vector<TComAPS>& getAPS () { return m_vAPS; } |
---|
| 229 | TComRPSList* getRPSList () { return &m_RPSList; } |
---|
| 230 | |
---|
| 231 | Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid,TComList<TComPic*>& listPic ); |
---|
| 232 | TComScalingList* getScalingList () { return &m_scalingList; } |
---|
| 233 | |
---|
| 234 | TEncAnalyze* getAnalyzeAll () { return &m_cAnalyzeAll; } |
---|
| 235 | TEncAnalyze* getAnalyzeI () { return &m_cAnalyzeI; } |
---|
| 236 | TEncAnalyze* getAnalyzeP () { return &m_cAnalyzeP; } |
---|
| 237 | TEncAnalyze* getAnalyzeB () { return &m_cAnalyzeB; } |
---|
| 238 | |
---|
[5] | 239 | #if DEPTH_MAP_GENERATION |
---|
[2] | 240 | TComDepthMapGenerator* getDepthMapGenerator () { return &m_cDepthMapGenerator; } |
---|
[5] | 241 | #endif |
---|
| 242 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 243 | TComResidualGenerator* getResidualGenerator () { return &m_cResidualGenerator; } |
---|
[5] | 244 | #endif |
---|
[166] | 245 | #if VSP_N |
---|
| 246 | TComPic* getVSPBuf () { return m_pcPicVSP; } |
---|
| 247 | TComPic* getVSPAvailBuf () { return m_pcPicAvail; } |
---|
[213] | 248 | Void setIsFirstInView ( Bool b ) { m_bIsFirstInView = b; } |
---|
| 249 | Bool getIsFirstInView () { return m_bIsFirstInView; } |
---|
[166] | 250 | #endif |
---|
[2] | 251 | |
---|
| 252 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 253 | // encoder function |
---|
| 254 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 255 | |
---|
| 256 | /// encode several number of pictures until end-of-sequence |
---|
[56] | 257 | Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, |
---|
| 258 | std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId ); |
---|
| 259 | }; |
---|
[2] | 260 | |
---|
[56] | 261 | //! \} |
---|
[2] | 262 | |
---|
| 263 | #endif // __TENCTOP__ |
---|