[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 | |
---|
[56] | 34 | /** \file TEncGOP.h |
---|
[2] | 35 | \brief GOP encoder class (header) |
---|
| 36 | */ |
---|
| 37 | |
---|
[56] | 38 | #ifndef __TENCGOP__ |
---|
| 39 | #define __TENCGOP__ |
---|
[2] | 40 | |
---|
[56] | 41 | #include <list> |
---|
| 42 | |
---|
[2] | 43 | #include <stdlib.h> |
---|
| 44 | |
---|
[56] | 45 | #include "TLibCommon/TComList.h" |
---|
| 46 | #include "TLibCommon/TComPic.h" |
---|
| 47 | #include "TLibCommon/TComBitCounter.h" |
---|
| 48 | #include "TLibCommon/TComLoopFilter.h" |
---|
| 49 | #include "TLibCommon/AccessUnit.h" |
---|
| 50 | #include "TEncSampleAdaptiveOffset.h" |
---|
[2] | 51 | #include "TEncSlice.h" |
---|
| 52 | #include "TEncEntropy.h" |
---|
| 53 | #include "TEncCavlc.h" |
---|
| 54 | #include "TEncSbac.h" |
---|
[608] | 55 | #include "SEIwrite.h" |
---|
[1313] | 56 | #include "SEIEncoder.h" |
---|
[2] | 57 | |
---|
| 58 | #include "TEncAnalyze.h" |
---|
[608] | 59 | #include "TEncRateCtrl.h" |
---|
[2] | 60 | #include <vector> |
---|
| 61 | |
---|
[56] | 62 | //! \ingroup TLibEncoder |
---|
| 63 | //! \{ |
---|
| 64 | |
---|
[2] | 65 | class TEncTop; |
---|
| 66 | |
---|
| 67 | // ==================================================================================================================== |
---|
| 68 | // Class definition |
---|
| 69 | // ==================================================================================================================== |
---|
| 70 | |
---|
[56] | 71 | class TEncGOP |
---|
[2] | 72 | { |
---|
[1313] | 73 | class DUData |
---|
| 74 | { |
---|
| 75 | public: |
---|
| 76 | DUData() |
---|
| 77 | :accumBitsDU(0) |
---|
| 78 | ,accumNalsDU(0) {}; |
---|
| 79 | |
---|
| 80 | Int accumBitsDU; |
---|
| 81 | Int accumNalsDU; |
---|
| 82 | }; |
---|
| 83 | |
---|
[2] | 84 | private: |
---|
[1313] | 85 | |
---|
| 86 | TEncAnalyze m_gcAnalyzeAll; |
---|
| 87 | TEncAnalyze m_gcAnalyzeI; |
---|
| 88 | TEncAnalyze m_gcAnalyzeP; |
---|
| 89 | TEncAnalyze m_gcAnalyzeB; |
---|
| 90 | |
---|
| 91 | TEncAnalyze m_gcAnalyzeAll_in; |
---|
[2] | 92 | // Data |
---|
[56] | 93 | Bool m_bLongtermTestPictureHasBeenCoded; |
---|
| 94 | Bool m_bLongtermTestPictureHasBeenCoded2; |
---|
[1313] | 95 | UInt m_numLongTermRefPicSPS; |
---|
| 96 | UInt m_ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS]; |
---|
| 97 | Bool m_ltRefPicUsedByCurrPicFlag[MAX_NUM_LONG_TERM_REF_PICS]; |
---|
[56] | 98 | Int m_iLastIDR; |
---|
| 99 | Int m_iGopSize; |
---|
| 100 | Int m_iNumPicCoded; |
---|
| 101 | Bool m_bFirst; |
---|
[964] | 102 | Int m_iLastRecoveryPicPOC; |
---|
[1313] | 103 | |
---|
[2] | 104 | // Access channel |
---|
| 105 | TEncTop* m_pcEncTop; |
---|
| 106 | TEncCfg* m_pcCfg; |
---|
| 107 | TEncSlice* m_pcSliceEncoder; |
---|
| 108 | TComList<TComPic*>* m_pcListPic; |
---|
[1313] | 109 | |
---|
[2] | 110 | TEncEntropy* m_pcEntropyCoder; |
---|
| 111 | TEncCavlc* m_pcCavlcCoder; |
---|
| 112 | TEncSbac* m_pcSbacCoder; |
---|
| 113 | TEncBinCABAC* m_pcBinCABAC; |
---|
| 114 | TComLoopFilter* m_pcLoopFilter; |
---|
[608] | 115 | |
---|
| 116 | SEIWriter m_seiWriter; |
---|
[1313] | 117 | |
---|
| 118 | #if NH_MV |
---|
[608] | 119 | TComPicLists* m_ivPicLists; |
---|
[622] | 120 | std::vector<TComPic*> m_refPicSetInterLayer0; |
---|
| 121 | std::vector<TComPic*> m_refPicSetInterLayer1; |
---|
[608] | 122 | |
---|
| 123 | Int m_pocLastCoded; |
---|
| 124 | Int m_layerId; |
---|
| 125 | Int m_viewId; |
---|
[5] | 126 | #endif |
---|
[2] | 127 | //--Adaptive Loop filter |
---|
| 128 | TEncSampleAdaptiveOffset* m_pcSAO; |
---|
[608] | 129 | TEncRateCtrl* m_pcRateCtrl; |
---|
[56] | 130 | // indicate sequence first |
---|
| 131 | Bool m_bSeqFirst; |
---|
[1313] | 132 | |
---|
[2] | 133 | // clean decoding refresh |
---|
| 134 | Bool m_bRefreshPending; |
---|
[56] | 135 | Int m_pocCRA; |
---|
[872] | 136 | NalUnitType m_associatedIRAPType; |
---|
| 137 | Int m_associatedIRAPPOC; |
---|
[2] | 138 | |
---|
| 139 | std::vector<Int> m_vRVM_RP; |
---|
[608] | 140 | UInt m_lastBPSEI; |
---|
| 141 | UInt m_totalCoded; |
---|
| 142 | Bool m_bufferingPeriodSEIPresentInAU; |
---|
[1313] | 143 | SEIEncoder m_seiEncoder; |
---|
| 144 | |
---|
[2] | 145 | public: |
---|
[56] | 146 | TEncGOP(); |
---|
| 147 | virtual ~TEncGOP(); |
---|
[1313] | 148 | |
---|
[608] | 149 | Void create (); |
---|
[2] | 150 | Void destroy (); |
---|
[1313] | 151 | |
---|
[2] | 152 | Void init ( TEncTop* pcTEncTop ); |
---|
[1313] | 153 | #if NH_MV |
---|
| 154 | Void initGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP); |
---|
| 155 | Void compressPicInGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, |
---|
| 156 | std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE, Int iGOPid ); |
---|
[608] | 157 | #else |
---|
[1313] | 158 | Void compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, |
---|
| 159 | std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE ); |
---|
[608] | 160 | #endif |
---|
[1313] | 161 | Void xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream* pcBitstreamRedirect); |
---|
[56] | 162 | |
---|
[1313] | 163 | #if NH_MV |
---|
[608] | 164 | Int getPocLastCoded () { return m_pocLastCoded; } |
---|
| 165 | Int getLayerId () { return m_layerId; } |
---|
| 166 | Int getViewId () { return m_viewId; } |
---|
| 167 | #endif |
---|
| 168 | |
---|
[56] | 169 | Int getGOPSize() { return m_iGopSize; } |
---|
[1313] | 170 | |
---|
[2] | 171 | TComList<TComPic*>* getListPic() { return m_pcListPic; } |
---|
[1313] | 172 | Void printOutSummary ( UInt uiNumAllPicCoded, Bool isField, const Bool printMSEBasedSNR, const Bool printSequenceMSE, const BitDepths &bitDepths ); |
---|
| 173 | Void preLoopFilterPicAll ( TComPic* pcPic, UInt64& ruiDist ); |
---|
[655] | 174 | |
---|
| 175 | |
---|
[56] | 176 | TEncSlice* getSliceEncoder() { return m_pcSliceEncoder; } |
---|
[872] | 177 | NalUnitType getNalUnitType( Int pocCurr, Int lastIdr, Bool isField ); |
---|
[608] | 178 | Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& ); |
---|
[1313] | 179 | |
---|
[2] | 180 | protected: |
---|
[608] | 181 | TEncRateCtrl* getRateCtrl() { return m_pcRateCtrl; } |
---|
[2] | 182 | |
---|
[56] | 183 | protected: |
---|
[872] | 184 | |
---|
[1313] | 185 | Void xInitGOP ( Int iPOCLast, Int iNumPicRcvd, Bool isField ); |
---|
| 186 | Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField ); |
---|
[655] | 187 | |
---|
[1313] | 188 | Void xCalculateAddPSNRs ( const Bool isField, const Bool isFieldTopFieldFirst, const Int iGOPid, TComPic* pcPic, const AccessUnit&accessUnit, TComList<TComPic*> &rcListPic, Double dEncTime, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE ); |
---|
| 189 | Void xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE ); |
---|
| 190 | Void xCalculateInterlacedAddPSNR( TComPic* pcPicOrgFirstField, TComPic* pcPicOrgSecondField, |
---|
| 191 | TComPicYuv* pcPicRecFirstField, TComPicYuv* pcPicRecSecondField, |
---|
| 192 | const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE ); |
---|
| 193 | UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1, const BitDepths &bitDepths); |
---|
[2] | 194 | Double xCalculateRVM(); |
---|
| 195 | |
---|
[1313] | 196 | Void xCreateIRAPLeadingSEIMessages (SEIMessages& seiMessages, const TComSPS *sps, const TComPPS *pps); |
---|
| 197 | Void xCreatePerPictureSEIMessages (Int picInGOP, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, TComSlice *slice); |
---|
| 198 | Void xCreatePictureTimingSEI (Int IRAPGOPid, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, SEIMessages& duInfoSeiMessages, TComSlice *slice, Bool isField, std::deque<DUData> &duData); |
---|
| 199 | Void xUpdateDuData(AccessUnit &testAU, std::deque<DUData> &duData); |
---|
| 200 | Void xUpdateTimingSEI(SEIPictureTiming *pictureTimingSEI, std::deque<DUData> &duData, const TComSPS *sps); |
---|
| 201 | Void xUpdateDuInfoSEI(SEIMessages &duInfoSeiMessages, SEIPictureTiming *pictureTimingSEI); |
---|
[608] | 202 | |
---|
[1313] | 203 | Void xCreateScalableNestingSEI (SEIMessages& seiMessages, SEIMessages& nestedSeiMessages); |
---|
| 204 | Void xWriteSEI (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps); |
---|
| 205 | Void xWriteSEISeparately (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps); |
---|
| 206 | Void xClearSEIs(SEIMessages& seiMessages, Bool deleteMessages); |
---|
| 207 | Void xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, Bool testWrite); |
---|
| 208 | Void xWriteLeadingSEIMessages (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, std::deque<DUData> &duData); |
---|
| 209 | Void xWriteTrailingSEIMessages (SEIMessages& seiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps); |
---|
| 210 | Void xWriteDuSEIMessages (SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, std::deque<DUData> &duData); |
---|
[608] | 211 | |
---|
[1313] | 212 | Int xWriteVPS (AccessUnit &accessUnit, const TComVPS *vps); |
---|
| 213 | Int xWriteSPS (AccessUnit &accessUnit, const TComSPS *sps); |
---|
| 214 | Int xWritePPS (AccessUnit &accessUnit, const TComPPS *pps); |
---|
| 215 | Int xWriteParameterSets (AccessUnit &accessUnit, TComSlice *slice); |
---|
| 216 | |
---|
| 217 | #if NH_MV |
---|
[622] | 218 | Void xSetRefPicListModificationsMv( std::vector<TComPic*> tempPicLists[2], TComSlice* pcSlice, UInt iGOPid ); |
---|
[608] | 219 | #endif |
---|
[2] | 220 | |
---|
| 221 | |
---|
[1313] | 222 | Void applyDeblockingFilterMetric( TComPic* pcPic, UInt uiNumSlices ); |
---|
| 223 | };// END CLASS DEFINITION TEncGOP |
---|
[56] | 224 | |
---|
| 225 | //! \} |
---|
| 226 | |
---|
| 227 | #endif // __TENCGOP__ |
---|
| 228 | |
---|