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