[313] | 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 |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
| 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. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 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 | */ |
---|
| 33 | |
---|
| 34 | /** \file TEncGOP.h |
---|
| 35 | \brief GOP encoder class (header) |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #ifndef __TENCGOP__ |
---|
| 39 | #define __TENCGOP__ |
---|
| 40 | |
---|
| 41 | #include <list> |
---|
| 42 | |
---|
| 43 | #include <stdlib.h> |
---|
| 44 | |
---|
| 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" |
---|
| 51 | #include "TEncSlice.h" |
---|
| 52 | #include "TEncEntropy.h" |
---|
| 53 | #include "TEncCavlc.h" |
---|
| 54 | #include "TEncSbac.h" |
---|
| 55 | #include "SEIwrite.h" |
---|
| 56 | |
---|
| 57 | #include "TEncAnalyze.h" |
---|
| 58 | #include "TEncRateCtrl.h" |
---|
| 59 | #include <vector> |
---|
| 60 | |
---|
| 61 | //! \ingroup TLibEncoder |
---|
| 62 | //! \{ |
---|
| 63 | |
---|
| 64 | class TEncTop; |
---|
| 65 | |
---|
| 66 | // ==================================================================================================================== |
---|
| 67 | // Class definition |
---|
| 68 | // ==================================================================================================================== |
---|
| 69 | |
---|
| 70 | /// GOP encoder class |
---|
| 71 | class TEncGOP |
---|
| 72 | { |
---|
| 73 | private: |
---|
| 74 | // Data |
---|
| 75 | Bool m_bLongtermTestPictureHasBeenCoded; |
---|
| 76 | Bool m_bLongtermTestPictureHasBeenCoded2; |
---|
| 77 | UInt m_numLongTermRefPicSPS; |
---|
| 78 | UInt m_ltRefPicPocLsbSps[33]; |
---|
| 79 | Bool m_ltRefPicUsedByCurrPicFlag[33]; |
---|
| 80 | Int m_iLastIDR; |
---|
| 81 | Int m_iGopSize; |
---|
| 82 | Int m_iNumPicCoded; |
---|
| 83 | Bool m_bFirst; |
---|
| 84 | |
---|
| 85 | #if SVC_EXTENSION |
---|
| 86 | UInt m_layerId; |
---|
| 87 | #endif |
---|
| 88 | |
---|
| 89 | // Access channel |
---|
| 90 | TEncTop* m_pcEncTop; |
---|
| 91 | TEncCfg* m_pcCfg; |
---|
| 92 | TEncSlice* m_pcSliceEncoder; |
---|
| 93 | TComList<TComPic*>* m_pcListPic; |
---|
| 94 | |
---|
| 95 | #if SVC_EXTENSION |
---|
| 96 | TEncTop** m_ppcTEncTop; |
---|
| 97 | #if SVC_UPSAMPLING |
---|
| 98 | TEncSearch* m_pcPredSearch; ///< encoder search class |
---|
| 99 | #endif |
---|
| 100 | #endif |
---|
| 101 | |
---|
| 102 | TEncEntropy* m_pcEntropyCoder; |
---|
| 103 | TEncCavlc* m_pcCavlcCoder; |
---|
| 104 | TEncSbac* m_pcSbacCoder; |
---|
| 105 | TEncBinCABAC* m_pcBinCABAC; |
---|
| 106 | TComLoopFilter* m_pcLoopFilter; |
---|
| 107 | |
---|
| 108 | SEIWriter m_seiWriter; |
---|
| 109 | |
---|
| 110 | //--Adaptive Loop filter |
---|
| 111 | TEncSampleAdaptiveOffset* m_pcSAO; |
---|
| 112 | TComBitCounter* m_pcBitCounter; |
---|
| 113 | TEncRateCtrl* m_pcRateCtrl; |
---|
| 114 | // indicate sequence first |
---|
| 115 | Bool m_bSeqFirst; |
---|
| 116 | |
---|
| 117 | // clean decoding refresh |
---|
| 118 | Bool m_bRefreshPending; |
---|
| 119 | Int m_pocCRA; |
---|
| 120 | std::vector<Int> m_storedStartCUAddrForEncodingSlice; |
---|
| 121 | std::vector<Int> m_storedStartCUAddrForEncodingSliceSegment; |
---|
| 122 | |
---|
| 123 | std::vector<Int> m_vRVM_RP; |
---|
| 124 | UInt m_lastBPSEI; |
---|
| 125 | UInt m_totalCoded; |
---|
| 126 | UInt m_cpbRemovalDelay; |
---|
| 127 | UInt m_tl0Idx; |
---|
| 128 | UInt m_rapIdx; |
---|
| 129 | Bool m_activeParameterSetSEIPresentInAU; |
---|
| 130 | Bool m_bufferingPeriodSEIPresentInAU; |
---|
| 131 | Bool m_pictureTimingSEIPresentInAU; |
---|
| 132 | Bool m_nestedBufferingPeriodSEIPresentInAU; |
---|
| 133 | Bool m_nestedPictureTimingSEIPresentInAU; |
---|
| 134 | public: |
---|
| 135 | TEncGOP(); |
---|
| 136 | virtual ~TEncGOP(); |
---|
| 137 | |
---|
| 138 | #if SVC_EXTENSION |
---|
| 139 | Void create ( UInt layerId ); |
---|
| 140 | #else |
---|
| 141 | Void create (); |
---|
| 142 | #endif |
---|
| 143 | Void destroy (); |
---|
| 144 | |
---|
| 145 | Void init ( TEncTop* pcTEncTop ); |
---|
| 146 | #if SVC_EXTENSION |
---|
| 147 | Void compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP ); |
---|
| 148 | #else |
---|
| 149 | Void compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP ); |
---|
| 150 | #endif |
---|
| 151 | Void xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect); |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | Int getGOPSize() { return m_iGopSize; } |
---|
| 155 | |
---|
| 156 | TComList<TComPic*>* getListPic() { return m_pcListPic; } |
---|
| 157 | |
---|
| 158 | Void printOutSummary ( UInt uiNumAllPicCoded ); |
---|
| 159 | Void preLoopFilterPicAll ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits ); |
---|
| 160 | |
---|
| 161 | TEncSlice* getSliceEncoder() { return m_pcSliceEncoder; } |
---|
| 162 | NalUnitType getNalUnitType( Int pocCurr, Int lastIdr ); |
---|
| 163 | Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& ); |
---|
| 164 | protected: |
---|
| 165 | TEncRateCtrl* getRateCtrl() { return m_pcRateCtrl; } |
---|
| 166 | |
---|
| 167 | protected: |
---|
| 168 | Void xInitGOP ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ); |
---|
| 169 | Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr ); |
---|
| 170 | |
---|
| 171 | Void xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime ); |
---|
| 172 | |
---|
| 173 | UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1); |
---|
| 174 | |
---|
| 175 | Double xCalculateRVM(); |
---|
| 176 | |
---|
| 177 | SEIActiveParameterSets* xCreateSEIActiveParameterSets (TComSPS *sps); |
---|
| 178 | #if M0043_LAYERS_PRESENT_SEI |
---|
| 179 | SEILayersPresent* xCreateSEILayersPresent (); |
---|
| 180 | #endif |
---|
| 181 | SEIFramePacking* xCreateSEIFramePacking(); |
---|
| 182 | SEIDisplayOrientation* xCreateSEIDisplayOrientation(); |
---|
| 183 | |
---|
| 184 | SEIToneMappingInfo* xCreateSEIToneMappingInfo(); |
---|
| 185 | |
---|
| 186 | Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps); |
---|
| 187 | Int xGetFirstSeiLocation (AccessUnit &accessUnit); |
---|
| 188 | Void xResetNonNestedSEIPresentFlags() |
---|
| 189 | { |
---|
| 190 | m_activeParameterSetSEIPresentInAU = false; |
---|
| 191 | m_bufferingPeriodSEIPresentInAU = false; |
---|
| 192 | m_pictureTimingSEIPresentInAU = false; |
---|
| 193 | } |
---|
| 194 | Void xResetNestedSEIPresentFlags() |
---|
| 195 | { |
---|
| 196 | m_nestedBufferingPeriodSEIPresentInAU = false; |
---|
| 197 | m_nestedPictureTimingSEIPresentInAU = false; |
---|
| 198 | } |
---|
| 199 | Void dblMetric( TComPic* pcPic, UInt uiNumSlices ); |
---|
[345] | 200 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
[313] | 201 | TComPic* getMotionPredIlp(TComSlice* pcSlice); |
---|
| 202 | #endif |
---|
| 203 | };// END CLASS DEFINITION TEncGOP |
---|
| 204 | |
---|
| 205 | // ==================================================================================================================== |
---|
| 206 | // Enumeration |
---|
| 207 | // ==================================================================================================================== |
---|
| 208 | enum PROCESSING_STATE |
---|
| 209 | { |
---|
| 210 | EXECUTE_INLOOPFILTER, |
---|
| 211 | ENCODE_SLICE |
---|
| 212 | }; |
---|
| 213 | |
---|
| 214 | enum SCALING_LIST_PARAMETER |
---|
| 215 | { |
---|
| 216 | SCALING_LIST_OFF, |
---|
| 217 | SCALING_LIST_DEFAULT, |
---|
| 218 | SCALING_LIST_FILE_READ |
---|
| 219 | }; |
---|
| 220 | |
---|
| 221 | //! \} |
---|
| 222 | |
---|
| 223 | #endif // __TENCGOP__ |
---|
| 224 | |
---|