source: 3DVCSoftware/branches/HTM-14.1-update-dev0/source/Lib/TLibEncoder/TEncGOP.h @ 1218

Last change on this file since 1218 was 1200, checked in by tech, 10 years ago

Update to HM-16.5.
Starting point for further re-activation of 3D-tools.

Includes:

active:

  • MV-HEVC
  • 3D-HLS (apart from DLT)
  • VSO

inactive:

  • remaining 3D-HEVC tools.
  • Property svn:eol-style set to native
File size: 10.8 KB
RevLine 
[5]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
[1200]4 * granted under this license.
[5]5 *
[1200]6 * Copyright (c) 2010-2015, ITU/ISO/IEC
[5]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.
[56]17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
[5]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 */
[2]33
[56]34/** \file     TEncGOP.h
[2]35    \brief    GOP encoder class (header)
36*/
37
[56]38#ifndef __TENCGOP__
39#define __TENCGOP__
[2]40
[56]41#include <list>
42
[2]43#include <stdlib.h>
44
[56]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"
[2]51#include "TEncSlice.h"
52#include "TEncEntropy.h"
53#include "TEncCavlc.h"
54#include "TEncSbac.h"
[608]55#include "SEIwrite.h"
[1200]56#include "SEIEncoder.h"
[2]57
58#include "TEncAnalyze.h"
[608]59#include "TEncRateCtrl.h"
[655]60#if KWU_RC_MADPRED_E0227
61#include "../App/TAppEncoder/TAppEncTop.h"
62#endif
[2]63#include <vector>
64
[56]65//! \ingroup TLibEncoder
66//! \{
67
[2]68class TEncTop;
69
70// ====================================================================================================================
71// Class definition
72// ====================================================================================================================
73
[56]74class TEncGOP
[2]75{
[1200]76  class DUData
77  {
78  public:
79    DUData()
80    :accumBitsDU(0)
81    ,accumNalsDU(0) {};
82
83    Int accumBitsDU;
84    Int accumNalsDU;
85  };
86
[2]87private:
[1200]88
89  TEncAnalyze             m_gcAnalyzeAll;
90  TEncAnalyze             m_gcAnalyzeI;
91  TEncAnalyze             m_gcAnalyzeP;
92  TEncAnalyze             m_gcAnalyzeB;
93
94  TEncAnalyze             m_gcAnalyzeAll_in;
[2]95  //  Data
[56]96  Bool                    m_bLongtermTestPictureHasBeenCoded;
97  Bool                    m_bLongtermTestPictureHasBeenCoded2;
[1200]98  UInt                    m_numLongTermRefPicSPS;
99  UInt                    m_ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS];
100  Bool                    m_ltRefPicUsedByCurrPicFlag[MAX_NUM_LONG_TERM_REF_PICS];
[56]101  Int                     m_iLastIDR;
102  Int                     m_iGopSize;
103  Int                     m_iNumPicCoded;
104  Bool                    m_bFirst;
[964]105  Int                     m_iLastRecoveryPicPOC;
[1200]106
[2]107  //  Access channel
108  TEncTop*                m_pcEncTop;
109  TEncCfg*                m_pcCfg;
110  TEncSlice*              m_pcSliceEncoder;
111  TComList<TComPic*>*     m_pcListPic;
[1200]112
[2]113  TEncEntropy*            m_pcEntropyCoder;
114  TEncCavlc*              m_pcCavlcCoder;
115  TEncSbac*               m_pcSbacCoder;
116  TEncBinCABAC*           m_pcBinCABAC;
117  TComLoopFilter*         m_pcLoopFilter;
[608]118
119  SEIWriter               m_seiWriter;
[1200]120
121#if NH_MV
[608]122  TComPicLists*           m_ivPicLists;
[622]123  std::vector<TComPic*>   m_refPicSetInterLayer0; 
124  std::vector<TComPic*>   m_refPicSetInterLayer1; 
[608]125
126  Int                     m_pocLastCoded;
127  Int                     m_layerId; 
128  Int                     m_viewId;
[1200]129#if NH_3D
[608]130  Int                     m_viewIndex; 
131  Bool                    m_isDepth;
[5]132#endif
133#endif
[1084]134#if H_3D_IC
135  Int*                    m_aICEnableCandidate; 
136  Int*                    m_aICEnableNum; 
[1066]137#endif
[2]138  //--Adaptive Loop filter
139  TEncSampleAdaptiveOffset*  m_pcSAO;
[608]140  TEncRateCtrl*           m_pcRateCtrl;
[56]141  // indicate sequence first
142  Bool                    m_bSeqFirst;
[1200]143
[2]144  // clean decoding refresh
145  Bool                    m_bRefreshPending;
[56]146  Int                     m_pocCRA;
[872]147  NalUnitType             m_associatedIRAPType;
148  Int                     m_associatedIRAPPOC;
[2]149
150  std::vector<Int> m_vRVM_RP;
[608]151  UInt                    m_lastBPSEI;
152  UInt                    m_totalCoded;
153  Bool                    m_bufferingPeriodSEIPresentInAU;
[1200]154  SEIEncoder              m_seiEncoder;
155
[2]156public:
[56]157  TEncGOP();
158  virtual ~TEncGOP();
[1200]159
[608]160  Void  create      ();
[2]161  Void  destroy     ();
[1200]162
[2]163  Void  init        ( TEncTop* pcTEncTop );
[1200]164#if NH_MV
165  Void  initGOP     ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP); 
166  Void  compressPicInGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec,
167    std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE, Int iGOPid );
[608]168#else
[1200]169  Void  compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec,
170                      std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
[608]171#endif
[1200]172  Void  xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream* pcBitstreamRedirect);
[56]173
[1200]174#if NH_MV
[608]175  Int       getPocLastCoded  ()                 { return m_pocLastCoded; } 
176  Int       getLayerId       ()                 { return m_layerId;    } 
177  Int       getViewId        ()                 { return m_viewId;    }
[1200]178#if NH_3D
[608]179  Int       getViewIndex     ()                 { return m_viewIndex;    }
180  Bool      getIsDepth       ()                 { return m_isDepth; }
181#endif
182#endif
183
[56]184  Int   getGOPSize()          { return  m_iGopSize;  }
[1200]185
[2]186  TComList<TComPic*>*   getListPic()      { return m_pcListPic; }
[1200]187  Void  printOutSummary      ( UInt uiNumAllPicCoded, Bool isField, const Bool printMSEBasedSNR, const Bool printSequenceMSE, const BitDepths &bitDepths );
188#if NH_3D_VSO
189  Void  preLoopFilterPicAll  ( TComPic* pcPic, Dist64& ruiDist);
[608]190#else
[1200]191  Void  preLoopFilterPicAll  ( TComPic* pcPic, UInt64& ruiDist );
[608]192#endif
[655]193
194#if KWU_RC_MADPRED_E0227
195  TEncTop* getEncTop() { return m_pcEncTop; }
196#endif
197
[56]198  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
[872]199  NalUnitType getNalUnitType( Int pocCurr, Int lastIdr, Bool isField );
[608]200  Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& );
[1200]201
[2]202protected:
[608]203  TEncRateCtrl* getRateCtrl()       { return m_pcRateCtrl;  }
[2]204
[56]205protected:
[872]206
[1200]207  Void  xInitGOP          ( Int iPOCLast, Int iNumPicRcvd, Bool isField );
208  Void  xGetBuffer        ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField );
[655]209
[1200]210  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 );
211  Void  xCalculateAddPSNR          ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
212  Void  xCalculateInterlacedAddPSNR( TComPic* pcPicOrgFirstField, TComPic* pcPicOrgSecondField,
213                                     TComPicYuv* pcPicRecFirstField, TComPicYuv* pcPicRecSecondField,
214                                     const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
215#if NH_3D_VSO
216  Dist64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1, const BitDepths &bitDepths);
[608]217#else 
[1200]218  UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1, const BitDepths &bitDepths);
[608]219#endif
[2]220  Double xCalculateRVM();
221
[1200]222  Void xCreateIRAPLeadingSEIMessages (SEIMessages& seiMessages, const TComSPS *sps, const TComPPS *pps);
223  Void xCreatePerPictureSEIMessages (Int picInGOP, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, TComSlice *slice);
224  Void xCreatePictureTimingSEI  (Int IRAPGOPid, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, SEIMessages& duInfoSeiMessages, TComSlice *slice, Bool isField, std::deque<DUData> &duData);
225  Void xUpdateDuData(AccessUnit &testAU, std::deque<DUData> &duData);
226  Void xUpdateTimingSEI(SEIPictureTiming *pictureTimingSEI, std::deque<DUData> &duData, const TComSPS *sps);
227  Void xUpdateDuInfoSEI(SEIMessages &duInfoSeiMessages, SEIPictureTiming *pictureTimingSEI);
[608]228
[1200]229  Void xCreateScalableNestingSEI (SEIMessages& seiMessages, SEIMessages& nestedSeiMessages);
230  Void xWriteSEI (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps);
231  Void xWriteSEISeparately (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps);
232  Void xClearSEIs(SEIMessages& seiMessages, Bool deleteMessages);
233  Void xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, Bool testWrite);
234  Void xWriteLeadingSEIMessages  (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, std::deque<DUData> &duData);
235  Void xWriteTrailingSEIMessages (SEIMessages& seiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps);
236  Void xWriteDuSEIMessages       (SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, std::deque<DUData> &duData);
[608]237
[1200]238  Int xWriteVPS (AccessUnit &accessUnit, const TComVPS *vps);
239  Int xWriteSPS (AccessUnit &accessUnit, const TComSPS *sps);
240  Int xWritePPS (AccessUnit &accessUnit, const TComPPS *pps);
241  Int xWriteParameterSets (AccessUnit &accessUnit, TComSlice *slice);
242
243#if NH_MV
[622]244   Void  xSetRefPicListModificationsMv( std::vector<TComPic*> tempPicLists[2], TComSlice* pcSlice, UInt iGOPid );
[608]245#endif
[2]246
247
[1200]248  Void applyDeblockingFilterMetric( TComPic* pcPic, UInt uiNumSlices );
249};// END CLASS DEFINITION TEncGOP
[56]250
251//! \}
252
253#endif // __TENCGOP__
254
Note: See TracBrowser for help on using the repository browser.