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

Last change on this file since 582 was 2, checked in by seregin, 12 years ago

Initial import by Vadim Seregin <vseregin@…>

File size: 7.5 KB
Line 
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-2012, 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 "TEncAdaptiveLoopFilter.h"
51#include "TEncSampleAdaptiveOffset.h"
52#include "TEncSlice.h"
53#include "TEncEntropy.h"
54#include "TEncCavlc.h"
55#include "TEncSbac.h"
56#include "SEIwrite.h"
57
58#include "TEncAnalyze.h"
59#include "TEncRateCtrl.h"
60#include <vector>
61
62//! \ingroup TLibEncoder
63//! \{
64
65class TEncTop;
66
67// ====================================================================================================================
68// Class definition
69// ====================================================================================================================
70
71/// GOP encoder class
72class TEncGOP
73{
74private:
75  //  Data
76  Bool                    m_bLongtermTestPictureHasBeenCoded;
77  Bool                    m_bLongtermTestPictureHasBeenCoded2;
78#if LTRP_IN_SPS
79  UInt            m_numLongTermRefPicSPS;
80  UInt            m_ltRefPicPocLsbSps[33];
81  Bool            m_ltRefPicUsedByCurrPicFlag[33];
82#endif
83  Int                     m_iLastIDR;
84  Int                     m_iGopSize;
85  Int                     m_iNumPicCoded;
86  Bool                    m_bFirst;
87 
88#if SVC_EXTENSION
89  UInt                    m_layerId;     
90#endif
91
92  //  Access channel
93  TEncTop*                m_pcEncTop;
94  TEncCfg*                m_pcCfg;
95  TEncSlice*              m_pcSliceEncoder;
96  TComList<TComPic*>*     m_pcListPic;
97
98#if SVC_EXTENSION
99  TEncTop**               m_ppcTEncTop;
100#if SVC_UPSAMPLING
101  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
102#endif 
103#endif
104 
105  TEncEntropy*            m_pcEntropyCoder;
106  TEncCavlc*              m_pcCavlcCoder;
107  TEncSbac*               m_pcSbacCoder;
108  TEncBinCABAC*           m_pcBinCABAC;
109  TComLoopFilter*         m_pcLoopFilter;
110
111  SEIWriter               m_seiWriter;
112 
113#if !REMOVE_ALF
114  // Adaptive Loop filter
115  TEncAdaptiveLoopFilter* m_pcAdaptiveLoopFilter;
116#endif
117  //--Adaptive Loop filter
118  TEncSampleAdaptiveOffset*  m_pcSAO;
119  TComBitCounter*         m_pcBitCounter;
120  TEncRateCtrl*           m_pcRateCtrl;
121  // indicate sequence first
122  Bool                    m_bSeqFirst;
123 
124  // clean decoding refresh
125  Bool                    m_bRefreshPending;
126  Int                     m_pocCRA;
127  std::vector<Int>        m_storedStartCUAddrForEncodingSlice;
128  std::vector<Int>        m_storedStartCUAddrForEncodingDependentSlice;
129
130  std::vector<Int> m_vRVM_RP;
131#if BUFFERING_PERIOD_AND_TIMING_SEI
132  UInt                    m_lastBPSEI;
133  UInt                    m_totalCoded;
134  UInt                    m_cpbRemovalDelay;
135#endif
136public:
137  TEncGOP();
138  virtual ~TEncGOP();
139 
140#if SVC_EXTENSION
141  Void  create      ( Int iWidth, Int iHeight, UInt iMaxCUWidth, UInt iMaxCUHeight, UInt layerId );
142#else
143  Void  create      ( Int iWidth, Int iHeight, UInt iMaxCUWidth, UInt iMaxCUHeight );
144#endif
145  Void  destroy     ();
146 
147  Void  init        ( TEncTop* pcTEncTop );
148#if SVC_EXTENSION
149  Void  compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );
150#else
151  Void  compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );
152#endif
153  Void xWriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice);
154
155 
156  Int   getGOPSize()          { return  m_iGopSize;  }
157 
158  TComList<TComPic*>*   getListPic()      { return m_pcListPic; }
159 
160  Void  printOutSummary      ( UInt uiNumAllPicCoded );
161  Void  preLoopFilterPicAll  ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits );
162 
163  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
164  NalUnitType getNalUnitType( UInt uiPOCCurr );
165#if !REMOVE_APS
166  Void freeAPS     (TComAPS* pAPS, TComSPS* pSPS);
167  Void allocAPS    (TComAPS* pAPS, TComSPS* pSPS);
168#endif
169  Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& );
170protected:
171#if !REMOVE_APS
172  Void encodeAPS   (TComAPS* pcAPS, TComOutputBitstream& APSbs, TComSlice* pcSlice);            //!< encode APS syntax elements
173  Void assignNewAPS(TComAPS& cAPS, Int apsID, std::vector<TComAPS>& vAPS, TComSlice* pcSlice);  //!< Assign APS object into APS container
174#endif
175  TEncRateCtrl* getRateCtrl()       { return m_pcRateCtrl;  }
176
177protected:
178  Void  xInitGOP          ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut );
179  Void  xGetBuffer        ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, UInt uiPOCCurr );
180 
181  Void  xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime );
182 
183  UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1);
184
185  Double xCalculateRVM();
186};// END CLASS DEFINITION TEncGOP
187
188// ====================================================================================================================
189// Enumeration
190// ====================================================================================================================
191enum PROCESSING_STATE
192{
193  EXECUTE_INLOOPFILTER,
194  ENCODE_APS,
195  ENCODE_SLICE
196};
197
198enum SCALING_LIST_PARAMETER
199{
200  SCALING_LIST_OFF,
201  SCALING_LIST_DEFAULT,
202  SCALING_LIST_FILE_READ
203};
204
205//! \}
206
207#endif // __TENCGOP__
208
Note: See TracBrowser for help on using the repository browser.