[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 | * |
---|
[872] | 6 | * Copyright (c) 2010-2014, 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" |
---|
[2] | 56 | |
---|
| 57 | #include "TEncAnalyze.h" |
---|
[608] | 58 | #include "TEncRateCtrl.h" |
---|
[655] | 59 | #if KWU_RC_MADPRED_E0227 |
---|
| 60 | #include "../App/TAppEncoder/TAppEncTop.h" |
---|
| 61 | #endif |
---|
[2] | 62 | #include <vector> |
---|
| 63 | |
---|
[56] | 64 | //! \ingroup TLibEncoder |
---|
| 65 | //! \{ |
---|
| 66 | |
---|
[2] | 67 | class TEncTop; |
---|
| 68 | |
---|
| 69 | // ==================================================================================================================== |
---|
| 70 | // Class definition |
---|
| 71 | // ==================================================================================================================== |
---|
| 72 | |
---|
| 73 | /// GOP encoder class |
---|
[56] | 74 | class TEncGOP |
---|
[2] | 75 | { |
---|
| 76 | private: |
---|
| 77 | // Data |
---|
[56] | 78 | Bool m_bLongtermTestPictureHasBeenCoded; |
---|
| 79 | Bool m_bLongtermTestPictureHasBeenCoded2; |
---|
[608] | 80 | UInt m_numLongTermRefPicSPS; |
---|
| 81 | UInt m_ltRefPicPocLsbSps[33]; |
---|
| 82 | Bool m_ltRefPicUsedByCurrPicFlag[33]; |
---|
[56] | 83 | Int m_iLastIDR; |
---|
| 84 | Int m_iGopSize; |
---|
| 85 | Int m_iNumPicCoded; |
---|
| 86 | Bool m_bFirst; |
---|
[964] | 87 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
| 88 | Int m_iLastRecoveryPicPOC; |
---|
| 89 | #endif |
---|
[2] | 90 | |
---|
| 91 | // Access channel |
---|
| 92 | TEncTop* m_pcEncTop; |
---|
| 93 | TEncCfg* m_pcCfg; |
---|
| 94 | TEncSlice* m_pcSliceEncoder; |
---|
| 95 | TComList<TComPic*>* m_pcListPic; |
---|
| 96 | |
---|
| 97 | TEncEntropy* m_pcEntropyCoder; |
---|
| 98 | TEncCavlc* m_pcCavlcCoder; |
---|
| 99 | TEncSbac* m_pcSbacCoder; |
---|
| 100 | TEncBinCABAC* m_pcBinCABAC; |
---|
| 101 | TComLoopFilter* m_pcLoopFilter; |
---|
[608] | 102 | |
---|
| 103 | SEIWriter m_seiWriter; |
---|
[56] | 104 | |
---|
[608] | 105 | #if H_MV |
---|
| 106 | TComPicLists* m_ivPicLists; |
---|
[622] | 107 | std::vector<TComPic*> m_refPicSetInterLayer0; |
---|
| 108 | std::vector<TComPic*> m_refPicSetInterLayer1; |
---|
[608] | 109 | |
---|
| 110 | Int m_pocLastCoded; |
---|
| 111 | Int m_layerId; |
---|
| 112 | Int m_viewId; |
---|
| 113 | #if H_3D |
---|
| 114 | Int m_viewIndex; |
---|
| 115 | Bool m_isDepth; |
---|
[5] | 116 | #endif |
---|
| 117 | #endif |
---|
[1084] | 118 | #if H_3D_IC |
---|
| 119 | Int* m_aICEnableCandidate; |
---|
| 120 | Int* m_aICEnableNum; |
---|
[1066] | 121 | #endif |
---|
[2] | 122 | //--Adaptive Loop filter |
---|
| 123 | TEncSampleAdaptiveOffset* m_pcSAO; |
---|
| 124 | TComBitCounter* m_pcBitCounter; |
---|
[608] | 125 | TEncRateCtrl* m_pcRateCtrl; |
---|
[56] | 126 | // indicate sequence first |
---|
| 127 | Bool m_bSeqFirst; |
---|
[2] | 128 | |
---|
| 129 | // clean decoding refresh |
---|
| 130 | Bool m_bRefreshPending; |
---|
[56] | 131 | Int m_pocCRA; |
---|
[608] | 132 | std::vector<Int> m_storedStartCUAddrForEncodingSlice; |
---|
| 133 | std::vector<Int> m_storedStartCUAddrForEncodingSliceSegment; |
---|
[872] | 134 | #if FIX1172 |
---|
| 135 | NalUnitType m_associatedIRAPType; |
---|
| 136 | Int m_associatedIRAPPOC; |
---|
| 137 | #endif |
---|
[2] | 138 | |
---|
| 139 | std::vector<Int> m_vRVM_RP; |
---|
[608] | 140 | UInt m_lastBPSEI; |
---|
| 141 | UInt m_totalCoded; |
---|
| 142 | UInt m_cpbRemovalDelay; |
---|
| 143 | UInt m_tl0Idx; |
---|
| 144 | UInt m_rapIdx; |
---|
| 145 | Bool m_activeParameterSetSEIPresentInAU; |
---|
| 146 | Bool m_bufferingPeriodSEIPresentInAU; |
---|
| 147 | Bool m_pictureTimingSEIPresentInAU; |
---|
| 148 | Bool m_nestedBufferingPeriodSEIPresentInAU; |
---|
| 149 | Bool m_nestedPictureTimingSEIPresentInAU; |
---|
[2] | 150 | public: |
---|
[56] | 151 | TEncGOP(); |
---|
| 152 | virtual ~TEncGOP(); |
---|
[2] | 153 | |
---|
[608] | 154 | Void create (); |
---|
[2] | 155 | Void destroy (); |
---|
| 156 | |
---|
| 157 | Void init ( TEncTop* pcTEncTop ); |
---|
[608] | 158 | #if H_MV |
---|
[56] | 159 | Void initGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP); |
---|
[655] | 160 | Void compressPicInGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid, Bool isField, Bool isTff ); |
---|
[608] | 161 | #else |
---|
[655] | 162 | Void compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); |
---|
[608] | 163 | #endif |
---|
| 164 | Void xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect); |
---|
[56] | 165 | |
---|
[608] | 166 | #if H_MV |
---|
| 167 | Int getPocLastCoded () { return m_pocLastCoded; } |
---|
| 168 | Int getLayerId () { return m_layerId; } |
---|
| 169 | Int getViewId () { return m_viewId; } |
---|
| 170 | #if H_3D |
---|
| 171 | Int getViewIndex () { return m_viewIndex; } |
---|
| 172 | Bool getIsDepth () { return m_isDepth; } |
---|
| 173 | #endif |
---|
| 174 | #endif |
---|
| 175 | |
---|
[56] | 176 | Int getGOPSize() { return m_iGopSize; } |
---|
| 177 | |
---|
[2] | 178 | TComList<TComPic*>* getListPic() { return m_pcListPic; } |
---|
[608] | 179 | |
---|
| 180 | #if !H_MV |
---|
[655] | 181 | Void printOutSummary ( UInt uiNumAllPicCoded , bool isField); |
---|
[608] | 182 | #endif |
---|
| 183 | #if H_3D_VSO |
---|
| 184 | Void preLoopFilterPicAll ( TComPic* pcPic, Dist64& ruiDist, UInt64& ruiBits ); |
---|
| 185 | #else |
---|
[2] | 186 | Void preLoopFilterPicAll ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits ); |
---|
[608] | 187 | #endif |
---|
[655] | 188 | |
---|
| 189 | #if KWU_RC_MADPRED_E0227 |
---|
| 190 | TEncTop* getEncTop() { return m_pcEncTop; } |
---|
| 191 | #endif |
---|
| 192 | |
---|
[56] | 193 | TEncSlice* getSliceEncoder() { return m_pcSliceEncoder; } |
---|
[872] | 194 | NalUnitType getNalUnitType( Int pocCurr, Int lastIdr, Bool isField ); |
---|
[608] | 195 | Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& ); |
---|
[2] | 196 | protected: |
---|
[608] | 197 | TEncRateCtrl* getRateCtrl() { return m_pcRateCtrl; } |
---|
[2] | 198 | |
---|
[56] | 199 | protected: |
---|
[872] | 200 | |
---|
[655] | 201 | Void xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, bool isField ); |
---|
| 202 | Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, bool isField ); |
---|
[2] | 203 | |
---|
[56] | 204 | Void xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime ); |
---|
[655] | 205 | Void xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ); |
---|
| 206 | |
---|
[608] | 207 | #if H_3D_VSO |
---|
| 208 | Dist64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1); |
---|
| 209 | #else |
---|
[2] | 210 | UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1); |
---|
[608] | 211 | #endif |
---|
[2] | 212 | |
---|
| 213 | Double xCalculateRVM(); |
---|
| 214 | |
---|
[608] | 215 | SEIActiveParameterSets* xCreateSEIActiveParameterSets (TComSPS *sps); |
---|
| 216 | SEIFramePacking* xCreateSEIFramePacking(); |
---|
| 217 | SEIDisplayOrientation* xCreateSEIDisplayOrientation(); |
---|
| 218 | |
---|
| 219 | SEIToneMappingInfo* xCreateSEIToneMappingInfo(); |
---|
[884] | 220 | #if H_MV |
---|
[872] | 221 | SEISubBitstreamProperty *xCreateSEISubBitstreamProperty( TComSPS *sps); |
---|
| 222 | #endif |
---|
[608] | 223 | |
---|
| 224 | Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps); |
---|
| 225 | Int xGetFirstSeiLocation (AccessUnit &accessUnit); |
---|
| 226 | Void xResetNonNestedSEIPresentFlags() |
---|
| 227 | { |
---|
| 228 | m_activeParameterSetSEIPresentInAU = false; |
---|
| 229 | m_bufferingPeriodSEIPresentInAU = false; |
---|
| 230 | m_pictureTimingSEIPresentInAU = false; |
---|
| 231 | } |
---|
| 232 | Void xResetNestedSEIPresentFlags() |
---|
| 233 | { |
---|
| 234 | m_nestedBufferingPeriodSEIPresentInAU = false; |
---|
| 235 | m_nestedPictureTimingSEIPresentInAU = false; |
---|
| 236 | } |
---|
| 237 | #if H_MV |
---|
[622] | 238 | Void xSetRefPicListModificationsMv( std::vector<TComPic*> tempPicLists[2], TComSlice* pcSlice, UInt iGOPid ); |
---|
[608] | 239 | #endif |
---|
| 240 | Void dblMetric( TComPic* pcPic, UInt uiNumSlices ); |
---|
[56] | 241 | };// END CLASS DEFINITION TEncGOP |
---|
[2] | 242 | |
---|
[56] | 243 | // ==================================================================================================================== |
---|
| 244 | // Enumeration |
---|
| 245 | // ==================================================================================================================== |
---|
| 246 | enum PROCESSING_STATE |
---|
| 247 | { |
---|
| 248 | EXECUTE_INLOOPFILTER, |
---|
| 249 | ENCODE_SLICE |
---|
| 250 | }; |
---|
[2] | 251 | |
---|
[56] | 252 | enum SCALING_LIST_PARAMETER |
---|
| 253 | { |
---|
| 254 | SCALING_LIST_OFF, |
---|
| 255 | SCALING_LIST_DEFAULT, |
---|
| 256 | SCALING_LIST_FILE_READ |
---|
| 257 | }; |
---|
| 258 | |
---|
| 259 | //! \} |
---|
| 260 | |
---|
| 261 | #endif // __TENCGOP__ |
---|
| 262 | |
---|