source: SHVCSoftware/branches/SHM-upgrade/source/Lib/TLibEncoder/TEncGOP.h @ 996

Last change on this file since 996 was 979, checked in by seregin, 10 years ago

port implementation of JCTVC-R0071 - IRAP and EOS cross-layer impacts (rev 978)

  • Property svn:eol-style set to native
File size: 11.6 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
[916]4 * granted under this license.
[313]5 *
[595]6 * Copyright (c) 2010-2014, 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"
[713]56#if Q0048_CGS_3D_ASYMLUT
57#include "TEnc3DAsymLUT.h"
58#endif
[313]59
60#include "TEncAnalyze.h"
61#include "TEncRateCtrl.h"
62#include <vector>
63
64//! \ingroup TLibEncoder
65//! \{
66
67class TEncTop;
68
69// ====================================================================================================================
70// Class definition
71// ====================================================================================================================
72
73class TEncGOP
74{
75private:
76  //  Data
77  Bool                    m_bLongtermTestPictureHasBeenCoded;
78  Bool                    m_bLongtermTestPictureHasBeenCoded2;
[916]79  UInt                    m_numLongTermRefPicSPS;
80  UInt                    m_ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS];
81  Bool                    m_ltRefPicUsedByCurrPicFlag[MAX_NUM_LONG_TERM_REF_PICS];
[313]82  Int                     m_iLastIDR;
83  Int                     m_iGopSize;
84  Int                     m_iNumPicCoded;
85  Bool                    m_bFirst;
[713]86#if ALLOW_RECOVERY_POINT_AS_RAP
87  Int                     m_iLastRecoveryPicPOC;
88#endif
[916]89
[313]90  //  Access channel
91  TEncTop*                m_pcEncTop;
92  TEncCfg*                m_pcCfg;
93  TEncSlice*              m_pcSliceEncoder;
94  TComList<TComPic*>*     m_pcListPic;
[916]95
[313]96  TEncEntropy*            m_pcEntropyCoder;
97  TEncCavlc*              m_pcCavlcCoder;
98  TEncSbac*               m_pcSbacCoder;
99  TEncBinCABAC*           m_pcBinCABAC;
100  TComLoopFilter*         m_pcLoopFilter;
101
102  SEIWriter               m_seiWriter;
[916]103
[313]104  //--Adaptive Loop filter
105  TEncSampleAdaptiveOffset*  m_pcSAO;
106  TEncRateCtrl*           m_pcRateCtrl;
107  // indicate sequence first
108  Bool                    m_bSeqFirst;
[916]109
[313]110  // clean decoding refresh
111  Bool                    m_bRefreshPending;
112  Int                     m_pocCRA;
[595]113  NalUnitType             m_associatedIRAPType;
114  Int                     m_associatedIRAPPOC;
[313]115
116  std::vector<Int> m_vRVM_RP;
117  UInt                    m_lastBPSEI;
118  UInt                    m_totalCoded;
119  UInt                    m_cpbRemovalDelay;
120  UInt                    m_tl0Idx;
121  UInt                    m_rapIdx;
122  Bool                    m_activeParameterSetSEIPresentInAU;
123  Bool                    m_bufferingPeriodSEIPresentInAU;
124  Bool                    m_pictureTimingSEIPresentInAU;
125  Bool                    m_nestedBufferingPeriodSEIPresentInAU;
126  Bool                    m_nestedPictureTimingSEIPresentInAU;
[595]127
[916]128#if POC_RESET_IDC_ENCODER
129  Int                     m_pocCraWithoutReset;
130  Int                     m_associatedIrapPocBeforeReset;
131#endif
[595]132#if SVC_EXTENSION
133  UInt                    m_layerId;     
134  TEncTop**               m_ppcTEncTop;
135  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
[713]136#if Q0048_CGS_3D_ASYMLUT
137  TEnc3DAsymLUT           m_Enc3DAsymLUTPicUpdate;
138  TEnc3DAsymLUT           m_Enc3DAsymLUTPPS;
139  TComPicYuv*             m_pColorMappedPic;
140
141  Int m_iTap;
142  const Int (*m_phase_filter)[13];
143  const Int (*m_phase_filter_luma)[13];
144  const Int (*m_phase_filter_chroma)[13];
145  Int m_iM, m_iN;
146  static const Int m_phase_filter_0_t0[4][13];
147  static const Int m_phase_filter_0_t1[4][13];
148  static const Int m_phase_filter_0_t1_chroma[4][13];
149  static const Int m_phase_filter_1[8][13];
150  Int   **m_temp;
[595]151#endif
[815]152#if POC_RESET_IDC_ENCODER
153  Int   m_lastPocPeriodId;
[713]154#endif
[979]155#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
156  Bool  m_noRaslOutputFlag;
157  Bool  m_prevPicHasEos;
[815]158#endif
[979]159#endif
[595]160 
[313]161public:
162  TEncGOP();
163  virtual ~TEncGOP();
164 
165#if SVC_EXTENSION
166  Void  create      ( UInt layerId );
167#else
168  Void  create      ();
169#endif
170  Void  destroy     ();
[916]171
[313]172  Void  init        ( TEncTop* pcTEncTop );
[916]173#if SVC_EXTENSION 
174  Void  compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec,
175                      std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
[313]176#else
[916]177  Void  compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec,
178                      std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
[313]179#endif
[916]180  Void  xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream* pcBitstreamRedirect);
[313]181
[916]182
[313]183  Int   getGOPSize()          { return  m_iGopSize;  }
[916]184
[313]185  TComList<TComPic*>*   getListPic()      { return m_pcListPic; }
186 
[442]187#if !SVC_EXTENSION
[916]188  Void  printOutSummary      ( UInt uiNumAllPicCoded, Bool isField, const Bool printMSEBasedSNR, const Bool printSequenceMSE );
[442]189#endif
[916]190  Void  preLoopFilterPicAll  ( TComPic* pcPic, UInt64& ruiDist );
191
[313]192  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
[595]193  NalUnitType getNalUnitType( Int pocCurr, Int lastIdr, Bool isField );
[313]194  Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& );
[916]195
196#if POC_RESET_IDC_ENCODER
197  Void  determinePocResetIdc( Int const pocCurr, TComSlice *const slice);
198  Int   getIntraRefreshInterval()  { return m_pcCfg->getIntraPeriod(); }
199  Int   getIntraRefreshType()      { return m_pcCfg->getDecodingRefreshType(); } 
200  Int   getLastPocPeriodId()      { return m_lastPocPeriodId; }
201  Void  setLastPocPeriodId(Int x) { m_lastPocPeriodId = x;    }
202  Void  updatePocValuesOfPics( Int const pocCurr, TComSlice *const slice);
203#endif
204
[313]205protected:
206  TEncRateCtrl* getRateCtrl()       { return m_pcRateCtrl;  }
207
208protected:
[916]209
210  Void  xInitGOP          ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField );
211  Void  xGetBuffer        ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField );
212
213  Void  xCalculateAddPSNR          ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
214  Void  xCalculateInterlacedAddPSNR( TComPic* pcPicOrgFirstField, TComPic* pcPicOrgSecondField,
215                                     TComPicYuv* pcPicRecFirstField, TComPicYuv* pcPicRecSecondField,
216                                     const AccessUnit& accessUnit, Double dEncTime, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
217
[313]218  UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1);
219
220  Double xCalculateRVM();
221
[916]222  SEIActiveParameterSets*           xCreateSEIActiveParameterSets (TComSPS *sps);
223  SEIFramePacking*                  xCreateSEIFramePacking();
224  SEISegmentedRectFramePacking*     xCreateSEISegmentedRectFramePacking();
225  SEIDisplayOrientation*            xCreateSEIDisplayOrientation();
226  SEIToneMappingInfo*               xCreateSEIToneMappingInfo();
227  SEITempMotionConstrainedTileSets* xCreateSEITempMotionConstrainedTileSets ();
228  SEIKneeFunctionInfo*              xCreateSEIKneeFunctionInfo();
229  SEIChromaSamplingFilterHint*      xCreateSEIChromaSamplingFilterHint(Bool bChromaLocInfoPresent, Int iHorFilterIndex, Int iVerFilterIdc);
[313]230
231  Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps);
232  Int xGetFirstSeiLocation (AccessUnit &accessUnit);
233  Void xResetNonNestedSEIPresentFlags()
234  {
235    m_activeParameterSetSEIPresentInAU = false;
236    m_bufferingPeriodSEIPresentInAU    = false;
237    m_pictureTimingSEIPresentInAU      = false;
238  }
239  Void xResetNestedSEIPresentFlags()
240  {
241    m_nestedBufferingPeriodSEIPresentInAU    = false;
242    m_nestedPictureTimingSEIPresentInAU      = false;
243  }
[595]244  Void dblMetric( TComPic* pcPic, UInt uiNumSlices );
245
[916]246#if Q0074_COLOUR_REMAPPING_SEI
247  SEIColourRemappingInfo* xCreateSEIColourRemappingInfo();
248#endif
[595]249#if SVC_EXTENSION
250#if LAYERS_NOT_PRESENT_SEI
251  SEILayersNotPresent*    xCreateSEILayersNotPresent ();
252#endif
[442]253#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
254  Void xBuildTileSetsMap(TComPicSym* picSym);
[595]255  SEIInterLayerConstrainedTileSets* xCreateSEIInterLayerConstrainedTileSets();
[442]256#endif
[644]257#if O0164_MULTI_LAYER_HRD
[894]258#if VPS_VUI_BSP_HRD_PARAMS
[896]259  SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice, Int olsIdx, Int partitioningSchemeIdx, Int bspIdx);
[894]260#else
[644]261  SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice);
262#endif
[894]263#endif
[912]264#if Q0096_OVERLAY_SEI
265  SEIOverlayInfo* xCreateSEIOverlayInfo();
266#endif
[713]267#if Q0048_CGS_3D_ASYMLUT
268  Void xDetermin3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS );
269  Void downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest);
270  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 );
271  inline Short  xClip( Short x , Int bitdepth );
272  Void initDs(Int iWidth, Int iHeight, Int iType);
273  Void filterImg(
274    Pel           *src,
275    Int           iSrcStride,
276    Pel           *dst,
277    Int           iDstStride,
278    Int           height1, 
279    Int           width1, 
280    Int           shift,
281    Int           plane);
282
283  Int get_mem2DintWithPad(Int ***array2D, Int dim0, Int dim1, Int iPadY, Int iPadX);
284  Void free_mem2DintWithPad(Int **array2D, Int iPadY, Int iPadX);
285#endif
[979]286#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
287  Void xCheckLayerReset(TComSlice *slice);
288  Void xSetNoRaslOutputFlag(TComSlice *slice);
289  Void xSetLayerInitializedFlag(TComSlice *slice);
290#endif
[595]291#endif //SVC_EXTENSION
[313]292};// END CLASS DEFINITION TEncGOP
293
294//! \}
295
296#endif // __TENCGOP__
297
Note: See TracBrowser for help on using the repository browser.