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

Last change on this file since 794 was 776, checked in by sony, 11 years ago

JCTVC-P0050: Knee Function Information (MACRO: P0050_KNEE_FUNCTION_SEI)
ohji.nakagami@…

  • Property svn:eol-style set to native
File size: 10.4 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
4 * granted under this license. 
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"
[677]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
73/// GOP encoder class
74class TEncGOP
75{
76private:
77  //  Data
78  Bool                    m_bLongtermTestPictureHasBeenCoded;
79  Bool                    m_bLongtermTestPictureHasBeenCoded2;
80  UInt            m_numLongTermRefPicSPS;
81  UInt            m_ltRefPicPocLsbSps[33];
82  Bool            m_ltRefPicUsedByCurrPicFlag[33];
83  Int                     m_iLastIDR;
84  Int                     m_iGopSize;
85  Int                     m_iNumPicCoded;
86  Bool                    m_bFirst;
[652]87#if ALLOW_RECOVERY_POINT_AS_RAP
88  Int                     m_iLastRecoveryPicPOC;
89#endif
[313]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;
102
103  SEIWriter               m_seiWriter;
104 
105  //--Adaptive Loop filter
106  TEncSampleAdaptiveOffset*  m_pcSAO;
107  TComBitCounter*         m_pcBitCounter;
108  TEncRateCtrl*           m_pcRateCtrl;
109  // indicate sequence first
110  Bool                    m_bSeqFirst;
111 
112  // clean decoding refresh
113  Bool                    m_bRefreshPending;
114  Int                     m_pocCRA;
115  std::vector<Int>        m_storedStartCUAddrForEncodingSlice;
116  std::vector<Int>        m_storedStartCUAddrForEncodingSliceSegment;
[595]117#if FIX1172
118  NalUnitType             m_associatedIRAPType;
119  Int                     m_associatedIRAPPOC;
120#endif
[313]121
122  std::vector<Int> m_vRVM_RP;
123  UInt                    m_lastBPSEI;
124  UInt                    m_totalCoded;
125  UInt                    m_cpbRemovalDelay;
126  UInt                    m_tl0Idx;
127  UInt                    m_rapIdx;
128  Bool                    m_activeParameterSetSEIPresentInAU;
129  Bool                    m_bufferingPeriodSEIPresentInAU;
130  Bool                    m_pictureTimingSEIPresentInAU;
131  Bool                    m_nestedBufferingPeriodSEIPresentInAU;
132  Bool                    m_nestedPictureTimingSEIPresentInAU;
[595]133
134#if SVC_EXTENSION
135  UInt                    m_layerId;     
136  TEncTop**               m_ppcTEncTop;
137  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
[677]138#if Q0048_CGS_3D_ASYMLUT
139  TEnc3DAsymLUT           m_Enc3DAsymLUTPicUpdate;
140  TEnc3DAsymLUT           m_Enc3DAsymLUTPPS;
141  TComPicYuv*             m_pColorMappedPic;
142
143  Int m_iTap;
144  const Int (*m_phase_filter)[13];
145  const Int (*m_phase_filter_luma)[13];
146  const Int (*m_phase_filter_chroma)[13];
147  Int m_iM, m_iN;
148  static const Int m_phase_filter_0_t0[4][13];
149  static const Int m_phase_filter_0_t1[4][13];
150  static const Int m_phase_filter_0_t1_chroma[4][13];
151  static const Int m_phase_filter_1[8][13];
152  Int   **m_temp;
[595]153#endif
[677]154#endif
[595]155 
[313]156public:
157  TEncGOP();
158  virtual ~TEncGOP();
159 
160#if SVC_EXTENSION
161  Void  create      ( UInt layerId );
162#else
163  Void  create      ();
164#endif
165  Void  destroy     ();
166 
167  Void  init        ( TEncTop* pcTEncTop );
168#if SVC_EXTENSION
[442]169  Void  compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff );
[313]170#else
[442]171  Void  compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff );
[313]172#endif
173  Void  xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect);
174
175 
176  Int   getGOPSize()          { return  m_iGopSize;  }
177 
178  TComList<TComPic*>*   getListPic()      { return m_pcListPic; }
179 
[442]180#if !SVC_EXTENSION
181  Void  printOutSummary      ( UInt uiNumAllPicCoded, Bool isField);
182#endif
[313]183  Void  preLoopFilterPicAll  ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits );
184 
185  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
[595]186  NalUnitType getNalUnitType( Int pocCurr, Int lastIdr, Bool isField );
[313]187  Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& );
188protected:
189  TEncRateCtrl* getRateCtrl()       { return m_pcRateCtrl;  }
190
191protected:
[442]192 
193  Void xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField );
[313]194  Void  xInitGOP          ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut );
[442]195  Void  xGetBuffer        ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField );
[313]196 
197  Void  xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime );
[442]198  Void  xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime );
[313]199 
200  UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1);
201
202  Double xCalculateRVM();
203
204  SEIActiveParameterSets* xCreateSEIActiveParameterSets (TComSPS *sps);
205  SEIFramePacking*        xCreateSEIFramePacking();
206  SEIDisplayOrientation*  xCreateSEIDisplayOrientation();
207
208  SEIToneMappingInfo*     xCreateSEIToneMappingInfo();
[776]209#if P0050_KNEE_FUNCTION_SEI
210  SEIKneeFunctionInfo*    xCreateSEIKneeFunctionInfo();
211#endif
[694]212#if Q0074_SEI_COLOR_MAPPING
213  SEIColorMappingInfo*    xCreateSEIColorMappingInfo( Char* file );
214#endif
[313]215
216  Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps);
217  Int xGetFirstSeiLocation (AccessUnit &accessUnit);
218  Void xResetNonNestedSEIPresentFlags()
219  {
220    m_activeParameterSetSEIPresentInAU = false;
221    m_bufferingPeriodSEIPresentInAU    = false;
222    m_pictureTimingSEIPresentInAU      = false;
223  }
224  Void xResetNestedSEIPresentFlags()
225  {
226    m_nestedBufferingPeriodSEIPresentInAU    = false;
227    m_nestedPictureTimingSEIPresentInAU      = false;
228  }
[595]229  Void dblMetric( TComPic* pcPic, UInt uiNumSlices );
230
231#if SVC_EXTENSION
232#if LAYERS_NOT_PRESENT_SEI
233  SEILayersNotPresent*    xCreateSEILayersNotPresent ();
234#endif
[442]235#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
236  Void xBuildTileSetsMap(TComPicSym* picSym);
[595]237  SEIInterLayerConstrainedTileSets* xCreateSEIInterLayerConstrainedTileSets();
[442]238#endif
[644]239#if O0164_MULTI_LAYER_HRD
240  SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice);
241#endif
[677]242#if Q0048_CGS_3D_ASYMLUT
243  Void xDetermin3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS );
244  Void downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest);
245  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 );
246  inline Short  xClip( Short x , Int bitdepth );
247  Void initDs(Int iWidth, Int iHeight, Int iType);
248  Void filterImg(
249    Pel           *src,
250    Int           iSrcStride,
251    Pel           *dst,
252    Int           iDstStride,
253    Int           height1, 
254    Int           width1, 
255    Int           shift,
256    Int           plane);
257
258  Int get_mem2DintWithPad(Int ***array2D, Int dim0, Int dim1, Int iPadY, Int iPadX);
259  Void free_mem2DintWithPad(Int **array2D, Int iPadY, Int iPadX);
260#endif
[595]261#endif //SVC_EXTENSION
[313]262};// END CLASS DEFINITION TEncGOP
263
264// ====================================================================================================================
265// Enumeration
266// ====================================================================================================================
267enum PROCESSING_STATE
268{
269  EXECUTE_INLOOPFILTER,
270  ENCODE_SLICE
271};
272
273enum SCALING_LIST_PARAMETER
274{
275  SCALING_LIST_OFF,
276  SCALING_LIST_DEFAULT,
277  SCALING_LIST_FILE_READ
278};
279
280//! \}
281
282#endif // __TENCGOP__
283
Note: See TracBrowser for help on using the repository browser.