source: SHVCSoftware/branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h @ 1353

Last change on this file since 1353 was 1336, checked in by seregin, 9 years ago

port rev 4414

  • Property svn:eol-style set to native
File size: 14.3 KB
RevLine 
[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
[1029]4 * granted under this license.
[313]5 *
[1259]6 * Copyright (c) 2010-2015, ITU/ISO/IEC
[313]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"
[1273]56#include "SEIEncoder.h"
[1212]57#if CGS_3D_ASYMLUT
[713]58#include "TEnc3DAsymLUT.h"
59#endif
[313]60
61#include "TEncAnalyze.h"
62#include "TEncRateCtrl.h"
63#include <vector>
64
65//! \ingroup TLibEncoder
66//! \{
67
68class TEncTop;
69
70// ====================================================================================================================
71// Class definition
72// ====================================================================================================================
73
74class TEncGOP
75{
[1273]76  class DUData
77  {
78  public:
79    DUData()
80    :accumBitsDU(0)
81    ,accumNalsDU(0) {};
82
83    Int accumBitsDU;
84    Int accumNalsDU;
85  };
86
[313]87private:
[1292]88
89  TEncAnalyze             m_gcAnalyzeAll;
90  TEncAnalyze             m_gcAnalyzeI;
91  TEncAnalyze             m_gcAnalyzeP;
92  TEncAnalyze             m_gcAnalyzeB;
93
94  TEncAnalyze             m_gcAnalyzeAll_in;
[313]95  //  Data
96  Bool                    m_bLongtermTestPictureHasBeenCoded;
97  Bool                    m_bLongtermTestPictureHasBeenCoded2;
[1029]98  UInt                    m_numLongTermRefPicSPS;
99  UInt                    m_ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS];
100  Bool                    m_ltRefPicUsedByCurrPicFlag[MAX_NUM_LONG_TERM_REF_PICS];
[313]101  Int                     m_iLastIDR;
102  Int                     m_iGopSize;
103  Int                     m_iNumPicCoded;
104  Bool                    m_bFirst;
[713]105  Int                     m_iLastRecoveryPicPOC;
[1029]106
[313]107  //  Access channel
108  TEncTop*                m_pcEncTop;
109  TEncCfg*                m_pcCfg;
110  TEncSlice*              m_pcSliceEncoder;
111  TComList<TComPic*>*     m_pcListPic;
[1029]112
[313]113  TEncEntropy*            m_pcEntropyCoder;
114  TEncCavlc*              m_pcCavlcCoder;
115  TEncSbac*               m_pcSbacCoder;
116  TEncBinCABAC*           m_pcBinCABAC;
117  TComLoopFilter*         m_pcLoopFilter;
118
119  SEIWriter               m_seiWriter;
[1029]120
[313]121  //--Adaptive Loop filter
122  TEncSampleAdaptiveOffset*  m_pcSAO;
123  TEncRateCtrl*           m_pcRateCtrl;
124  // indicate sequence first
125  Bool                    m_bSeqFirst;
[1029]126
[313]127  // clean decoding refresh
128  Bool                    m_bRefreshPending;
129  Int                     m_pocCRA;
[595]130  NalUnitType             m_associatedIRAPType;
131  Int                     m_associatedIRAPPOC;
[313]132
133  std::vector<Int> m_vRVM_RP;
134  UInt                    m_lastBPSEI;
135  UInt                    m_totalCoded;
136  Bool                    m_bufferingPeriodSEIPresentInAU;
[1273]137  SEIEncoder              m_seiEncoder;
[595]138
[1273]139#if Q0074_COLOUR_REMAPPING_SEI
140  TComSEIColourRemappingInfo m_seiColourRemappingInfo; 
141#endif
[1209]142#if SVC_EXTENSION
[1029]143  Int                     m_pocCraWithoutReset;
144  Int                     m_associatedIrapPocBeforeReset;
[595]145  UInt                    m_layerId;     
146  TEncTop**               m_ppcTEncTop;
147  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
[1212]148#if CGS_3D_ASYMLUT
[713]149  TEnc3DAsymLUT           m_Enc3DAsymLUTPicUpdate;
150  TEnc3DAsymLUT           m_Enc3DAsymLUTPPS;
151  TComPicYuv*             m_pColorMappedPic;
152
153  Int m_iTap;
154  const Int (*m_phase_filter)[13];
155  const Int (*m_phase_filter_luma)[13];
156  const Int (*m_phase_filter_chroma)[13];
157  Int m_iM, m_iN;
158  static const Int m_phase_filter_0_t0[4][13];
159  static const Int m_phase_filter_0_t1[4][13];
160  static const Int m_phase_filter_0_t1_chroma[4][13];
161  static const Int m_phase_filter_1[8][13];
162  Int   **m_temp;
[595]163#endif
[815]164  Int   m_lastPocPeriodId;
[978]165  Bool  m_noRaslOutputFlag;
166  Bool  m_prevPicHasEos;
[1277]167  static Bool m_signalledVPS;
[815]168#endif
[595]169 
[313]170public:
171  TEncGOP();
172  virtual ~TEncGOP();
173 
174#if SVC_EXTENSION
175  Void  create      ( UInt layerId );
176#else
177  Void  create      ();
178#endif
179  Void  destroy     ();
[1029]180
[313]181  Void  init        ( TEncTop* pcTEncTop );
[1029]182#if SVC_EXTENSION 
183  Void  compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec,
184                      std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
[313]185#else
[1029]186  Void  compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec,
187                      std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
[313]188#endif
[1029]189  Void  xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream* pcBitstreamRedirect);
[313]190
[1029]191
[313]192  Int   getGOPSize()          { return  m_iGopSize;  }
[1029]193
[313]194  TComList<TComPic*>*   getListPic()      { return m_pcListPic; }
[1307]195
[1289]196  Void  printOutSummary      ( UInt uiNumAllPicCoded, Bool isField, const Bool printMSEBasedSNR, const Bool printSequenceMSE, const BitDepths &bitDepths );
[1029]197  Void  preLoopFilterPicAll  ( TComPic* pcPic, UInt64& ruiDist );
198
[313]199  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
[595]200  NalUnitType getNalUnitType( Int pocCurr, Int lastIdr, Bool isField );
[313]201  Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& );
[1029]202
[1209]203#if SVC_EXTENSION
[1029]204  Void  determinePocResetIdc( Int const pocCurr, TComSlice *const slice);
[1292]205  Int   getIntraRefreshInterval()   { return m_pcCfg->getIntraPeriod(); }
206  Int   getIntraRefreshType()       { return m_pcCfg->getDecodingRefreshType(); } 
207  Int   getLastPocPeriodId()        { return m_lastPocPeriodId; }
208  Void  setLastPocPeriodId(Int x)   { m_lastPocPeriodId = x;    }
[1029]209  Void  updatePocValuesOfPics( Int const pocCurr, TComSlice *const slice);
[1292]210
211  TEncAnalyze* getAnalyzeAll()      { return &m_gcAnalyzeAll;  }
212  TEncAnalyze* getAnalyzeI()        { return &m_gcAnalyzeI;    }
213  TEncAnalyze* getAnalyzeP()        { return &m_gcAnalyzeP;    }
214  TEncAnalyze* getAnalyzeB()        { return &m_gcAnalyzeB;    }
215  TEncAnalyze* getAnalyzeAllin()    { return &m_gcAnalyzeAll_in; }
216  Double       calculateRVM()       { return xCalculateRVM();    }
[1029]217#endif
218
[313]219protected:
220  TEncRateCtrl* getRateCtrl()       { return m_pcRateCtrl;  }
221
222protected:
[1029]223
[1307]224  Void  xInitGOP          ( Int iPOCLast, Int iNumPicRcvd, Bool isField );
[1029]225  Void  xGetBuffer        ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField );
226
[1291]227  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 );
[1029]228  Void  xCalculateAddPSNR          ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
229  Void  xCalculateInterlacedAddPSNR( TComPic* pcPicOrgFirstField, TComPic* pcPicOrgSecondField,
230                                     TComPicYuv* pcPicRecFirstField, TComPicYuv* pcPicRecSecondField,
[1307]231                                     const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
[1029]232
[1287]233  UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1, const BitDepths &bitDepths);
[313]234
235  Double xCalculateRVM();
236
[1273]237  Void xCreateIRAPLeadingSEIMessages (SEIMessages& seiMessages, const TComSPS *sps, const TComPPS *pps);
238  Void xCreatePerPictureSEIMessages (Int picInGOP, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, TComSlice *slice);
[1307]239  Void xCreatePictureTimingSEI  (Int IRAPGOPid, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, SEIMessages& duInfoSeiMessages, TComSlice *slice, Bool isField, std::deque<DUData> &duData);
[1273]240  Void xUpdateDuData(AccessUnit &testAU, std::deque<DUData> &duData);
241  Void xUpdateTimingSEI(SEIPictureTiming *pictureTimingSEI, std::deque<DUData> &duData, const TComSPS *sps);
242  Void xUpdateDuInfoSEI(SEIMessages &duInfoSeiMessages, SEIPictureTiming *pictureTimingSEI);
[313]243
[1273]244  Void xCreateScalableNestingSEI (SEIMessages& seiMessages, SEIMessages& nestedSeiMessages);
245#if O0164_MULTI_LAYER_HRD
246  Void xWriteSEI (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
247  Void xWriteSEISeparately (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
248#else
249  Void xWriteSEI (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps);
250  Void xWriteSEISeparately (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps);
251#endif
252  Void xClearSEIs(SEIMessages& seiMessages, Bool deleteMessages);
253#if O0164_MULTI_LAYER_HRD
254  Void xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComVPS *vps, const TComSPS *sps, Bool testWrite, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
255  Void xWriteLeadingSEIMessages  (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComVPS *vps, const TComSPS *sps, std::deque<DUData> &duData, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
256  Void xWriteTrailingSEIMessages (SEIMessages& seiMessages, AccessUnit &accessUnit, Int temporalId, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
257  Void xWriteDuSEIMessages       (SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComVPS *sps, const TComSPS *vps, std::deque<DUData> &duData, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
258#else
259  Void xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, Bool testWrite);
260  Void xWriteLeadingSEIMessages  (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, std::deque<DUData> &duData);
261  Void xWriteTrailingSEIMessages (SEIMessages& seiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps);
262  Void xWriteDuSEIMessages       (SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, std::deque<DUData> &duData);
263#endif
264
265  Int xWriteVPS (AccessUnit &accessUnit, const TComVPS *vps);
266  Int xWriteSPS (AccessUnit &accessUnit, const TComSPS *sps);
267  Int xWritePPS (AccessUnit &accessUnit, const TComPPS *pps);
268  Int xWriteParameterSets (AccessUnit &accessUnit, TComSlice *slice);
269
[1235]270  Void applyDeblockingFilterMetric( TComPic* pcPic, UInt uiNumSlices );
[595]271
[1029]272#if Q0074_COLOUR_REMAPPING_SEI
[1273]273  TComSEIColourRemappingInfo* xGetSEIColourRemappingInfo()  { return &m_seiColourRemappingInfo; }
274  Void  setCRISEIFile( Char* pch )       { m_seiColourRemappingInfo.m_colourRemapSEIFile = pch; }
[1089]275
276  Void freeColourCRI();
277  Int  readingCRIparameters();
278  Void xCheckParameter();
[1029]279#endif
[595]280#if SVC_EXTENSION
[442]281#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
282  Void xBuildTileSetsMap(TComPicSym* picSym);
283#endif
[1212]284#if CGS_3D_ASYMLUT
[713]285  Void xDetermin3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS );
[1287]286  Void downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest, BitDepths& bitDepth);
[713]287  Void downScaleComponent2x2( const Pel* pSrc, Pel* pDest, const Int iSrcStride, const Int iDestStride, const Int iSrcWidth, const Int iSrcHeight, const Int inputBitDepth, const Int outputBitDepth );
[1235]288  inline Short xClip( Short x , Int bitdepth );
[713]289  Void initDs(Int iWidth, Int iHeight, Int iType);
[1287]290  Void filterImg( Pel *src, Int iSrcStride, Pel *dst, Int iDstStride, Int height1, Int width1, BitDepths& bitDepth, Int plane );
[713]291
292  Int get_mem2DintWithPad(Int ***array2D, Int dim0, Int dim1, Int iPadY, Int iPadX);
293  Void free_mem2DintWithPad(Int **array2D, Int iPadY, Int iPadX);
294#endif
[978]295  Void xCheckLayerReset(TComSlice *slice);
296  Void xSetNoRaslOutputFlag(TComSlice *slice);
297  Void xSetLayerInitializedFlag(TComSlice *slice);
[595]298#endif //SVC_EXTENSION
[313]299};// END CLASS DEFINITION TEncGOP
300
301//! \}
302
303#endif // __TENCGOP__
304
Note: See TracBrowser for help on using the repository browser.