source: 3DVCSoftware/trunk/source/Lib/TLibEncoder/TEncTop.h

Last change on this file was 1413, checked in by tech, 6 years ago

Merged HTM-16.2-dev@1412

  • Property svn:eol-style set to native
File size: 13.7 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
[1313]4 * granted under this license.
[5]5 *
[1413]6 * Copyright (c) 2010-2017, 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
34/** \file     TEncTop.h
35    \brief    encoder class (header)
36*/
37
38#ifndef __TENCTOP__
39#define __TENCTOP__
40
41// Include files
[56]42#include "TLibCommon/TComList.h"
43#include "TLibCommon/TComPrediction.h"
44#include "TLibCommon/TComTrQuant.h"
[1313]45#include "TLibCommon/TComLoopFilter.h"
[56]46#include "TLibCommon/AccessUnit.h"
[2]47
[56]48#include "TLibVideoIO/TVideoIOYuv.h"
[2]49
50#include "TEncCfg.h"
51#include "TEncGOP.h"
52#include "TEncSlice.h"
53#include "TEncEntropy.h"
54#include "TEncCavlc.h"
55#include "TEncSbac.h"
56#include "TEncSearch.h"
[56]57#include "TEncSampleAdaptiveOffset.h"
58#include "TEncPreanalyzer.h"
[608]59#include "TEncRateCtrl.h"
[56]60//! \ingroup TLibEncoder
61//! \{
[2]62
63// ====================================================================================================================
64// Class definition
65// ====================================================================================================================
66
[655]67#if KWU_RC_MADPRED_E0227
68class TAppEncTop;
69#endif
[2]70/// encoder class
71class TEncTop : public TEncCfg
72{
73private:
74  // picture
75  Int                     m_iPOCLast;                     ///< time index (POC)
76  Int                     m_iNumPicRcvd;                  ///< number of received pictures
77  UInt                    m_uiNumAllPicCoded;             ///< number of coded pictures
[1321]78#if !NH_MV
[2]79  TComList<TComPic*>      m_cListPic;                     ///< dynamic list of pictures
[1321]80#endif
[1313]81
82#if NH_MV
[608]83  TComPicLists*           m_ivPicLists;                   ///< access to picture lists of other layers
84#endif
[1413]85#if NH_3D
[1066]86  Int *m_aICEnableCandidate;
87  Int *m_aICEnableNum;
88#endif
[2]89  // encoder search
90  TEncSearch              m_cSearch;                      ///< encoder search class
[872]91  //TEncEntropy*            m_pcEntropyCoder;                     ///< entropy encoder
[1313]92  TEncCavlc*              m_pcCavlcCoder;                       ///< CAVLC encoder
[2]93  // coding tool
94  TComTrQuant             m_cTrQuant;                     ///< transform & quantization class
95  TComLoopFilter          m_cLoopFilter;                  ///< deblocking filter class
[56]96  TEncSampleAdaptiveOffset m_cEncSAO;                     ///< sample adaptive offset class
[2]97  TEncEntropy             m_cEntropyCoder;                ///< entropy encoder
98  TEncCavlc               m_cCavlcCoder;                  ///< CAVLC encoder
99  TEncSbac                m_cSbacCoder;                   ///< SBAC encoder
100  TEncBinCABAC            m_cBinCoderCABAC;               ///< bin coder CABAC
[1313]101
[2]102  // processing unit
[56]103  TEncGOP                 m_cGOPEncoder;                  ///< GOP encoder
[2]104  TEncSlice               m_cSliceEncoder;                ///< slice encoder
105  TEncCu                  m_cCuEncoder;                   ///< CU encoder
[1413]106
107#if NH_3D 
108  TComSps3dExtension     m_sps3dExtension;
109#endif
110
[2]111  // SPS
[1413]112#if NH_MV
113  ParameterSetMap<TComSPS>& m_spsMap;                      ///< SPS. This is the base value. This is copied to TComPicSym
114  ParameterSetMap<TComPPS>& m_ppsMap;                      ///< PPS. This is the base value. This is copied to TComPicSym
115#else
116  ParameterSetMap<TComSPS> m_spsMap;                      ///< SPS. This is the base value. This is copied to TComPicSym
117  ParameterSetMap<TComPPS> m_ppsMap;                      ///< PPS. This is the base value. This is copied to TComPicSym
118#endif
[2]119  // RD cost computation
120  TComRdCost              m_cRdCost;                      ///< RD cost computation class
121  TEncSbac***             m_pppcRDSbacCoder;              ///< temporal storage for RD computation
122  TEncSbac                m_cRDGoOnSbacCoder;             ///< going on SBAC model for RD stage
[56]123#if FAST_BIT_EST
124  TEncBinCABACCounter***  m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
125  TEncBinCABACCounter     m_cRDGoOnBinCoderCABAC;         ///< going on bin coder CABAC for RD stage
126#else
[2]127  TEncBinCABAC***         m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
128  TEncBinCABAC            m_cRDGoOnBinCoderCABAC;         ///< going on bin coder CABAC for RD stage
[56]129#endif
[2]130
[56]131  // quality control
132  TEncPreanalyzer         m_cPreanalyzer;                 ///< image characteristics analyzer for TM5-step3-like adaptive QP
133
[608]134  TEncRateCtrl            m_cRateCtrl;                    ///< Rate control class
[655]135
136#if KWU_RC_MADPRED_E0227
137  TAppEncTop*             m_pcTAppEncTop;
138  TAppComCamPara*         m_cCamParam;
139#endif
[1313]140#if NH_MV
[56]141  TEncAnalyze             m_cAnalyzeAll;
142  TEncAnalyze             m_cAnalyzeI;
143  TEncAnalyze             m_cAnalyzeP;
[1313]144  TEncAnalyze             m_cAnalyzeB;
145  TEncAnalyze             m_cAnalyzeAll_in;
[608]146#endif
[1413]147 
[2]148protected:
[1413]149  Void  xGetNewPicBuffer  ( TComPic*& rpcPic, Int ppsId ); ///< get picture buffer which will be processed. If ppsId<0, then the ppsMap will be queried for the first match.
150  Void  xInitVPS          (TComVPS &vps, const TComSPS &sps); ///< initialize VPS from encoder options
151  Void  xInitSPS          (TComSPS &sps);                 ///< initialize SPS from encoder options
152  Void  xInitPPS          (TComPPS &pps, const TComSPS &sps) const; ///< initialize PPS from encoder options
153  Void  xInitScalingLists (TComSPS &sps, TComPPS &pps);   ///< initialize scaling lists
154  Void  xInitHrdParameters(TComSPS &sps);                 ///< initialize HRD parameters
[1313]155
[1413]156#if NH_MV 
157  Int   xGetPsIdAndPsLayerId      ( ); 
[2]158
[1413]159  Void  xInitPPSforTiles  (TComPPS &pps) const ;
160#else
161  Void  xInitPPSforTiles  (TComPPS &pps);
162#endif
163  Void  xInitRPS          (TComSPS &sps, Bool isFieldCoding);           ///< initialize PPS from encoder options
164
[2]165public:
[1413]166#if NH_MV
167  TEncTop( ParameterSetMap<TComSPS>& spsMap, ParameterSetMap<TComPPS>& ppsMap );
168#else
[2]169  TEncTop();
[1413]170#endif
[2]171  virtual ~TEncTop();
[1313]172
[2]173  Void      create          ();
174  Void      destroy         ();
[655]175#if KWU_RC_MADPRED_E0227
176  Void      init            ( TAppEncTop* pcTAppEncTop, Bool isFieldCoding );
177#else
178  Void      init            (Bool isFieldCoding);
179#endif
[1313]180#if NH_MV 
[608]181  TComPicLists* getIvPicLists() { return m_ivPicLists; }
182#endif
[1413]183#if NH_3D
[1084]184  Int*      getICEnableCandidate() { return m_aICEnableCandidate; }
185  Int*      getICEnableNum() { return m_aICEnableNum; }
[1066]186#endif
[2]187  Void      deletePicBuffer ();
[1313]188#if NH_MV
[608]189  Void      initNewPic(TComPicYuv* pcPicYuvOrg);
190#endif
[2]191  // -------------------------------------------------------------------------------------------------------------------
192  // member access functions
193  // -------------------------------------------------------------------------------------------------------------------
[1313]194
[1321]195#if NH_MV
196  TComList<TComPic*>*     getListPic            () { return  m_ivPicLists->getSubDpb( getLayerId(), false);             }
197#else
[2]198  TComList<TComPic*>*     getListPic            () { return  &m_cListPic;             }
[1321]199#endif
[2]200  TEncSearch*             getPredSearch         () { return  &m_cSearch;              }
[1313]201
[2]202  TComTrQuant*            getTrQuant            () { return  &m_cTrQuant;             }
203  TComLoopFilter*         getLoopFilter         () { return  &m_cLoopFilter;          }
[56]204  TEncSampleAdaptiveOffset* getSAO              () { return  &m_cEncSAO;              }
205  TEncGOP*                getGOPEncoder         () { return  &m_cGOPEncoder;          }
[2]206  TEncSlice*              getSliceEncoder       () { return  &m_cSliceEncoder;        }
207  TEncCu*                 getCuEncoder          () { return  &m_cCuEncoder;           }
208  TEncEntropy*            getEntropyCoder       () { return  &m_cEntropyCoder;        }
209  TEncCavlc*              getCavlcCoder         () { return  &m_cCavlcCoder;          }
210  TEncSbac*               getSbacCoder          () { return  &m_cSbacCoder;           }
211  TEncBinCABAC*           getBinCABAC           () { return  &m_cBinCoderCABAC;       }
[1313]212
[2]213  TComRdCost*             getRdCost             () { return  &m_cRdCost;              }
214  TEncSbac***             getRDSbacCoder        () { return  m_pppcRDSbacCoder;       }
215  TEncSbac*               getRDGoOnSbacCoder    () { return  &m_cRDGoOnSbacCoder;     }
[608]216  TEncRateCtrl*           getRateCtrl           () { return &m_cRateCtrl;             }
[655]217#if KWU_RC_MADPRED_E0227
218  TAppEncTop*             getEncTop             () { return m_pcTAppEncTop; }
219  TAppComCamPara*         getCamParam()                 { return m_cCamParam;}
220  Void                    setCamParam(TAppComCamPara * pCamparam)                 { m_cCamParam = pCamparam;}
221#endif
[608]222  Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid );
[1313]223  Int getReferencePictureSetIdxForSOP(Int POCCurr, Int GOPid );
224#if NH_MV
[56]225  TEncAnalyze*            getAnalyzeAll         () { return &m_cAnalyzeAll; }
226  TEncAnalyze*            getAnalyzeI           () { return &m_cAnalyzeI;   }
227  TEncAnalyze*            getAnalyzeP           () { return &m_cAnalyzeP;   }
228  TEncAnalyze*            getAnalyzeB           () { return &m_cAnalyzeB;   }
[1313]229  Int                     getNumAllPicCoded     () { return m_uiNumAllPicCoded; } 
230  Int                     getFrameId            (Int iGOPid); 
[608]231  TComPic*                getPic                ( Int poc );
232  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
[5]233#endif
[1313]234#if NH_3D
[1413]235  Void                    setSps3dExtension     ( TComSps3dExtension sps3dExtension ) { m_sps3dExtension = sps3dExtension;  };
[1066]236  Void                    setICEnableCandidate         ( Int* ICEnableCandidate) { m_aICEnableCandidate = ICEnableCandidate; }
237  Void                    setICEnableNum         ( Int* ICEnableNum) { m_aICEnableNum = ICEnableNum; }
238#endif
[1413]239
240#if JCTVC_Y0038_PARAMS
241#if NH_MV
242  Void                   setParamSetChanged(Int iD, Bool isPps );
243#else
244  Void                   setParamSetChanged(Int spsId, Int ppsId);
245#endif
246#endif
247  Bool                   PPSNeedsWriting(Int ppsId);
248  Bool                   SPSNeedsWriting(Int spsId);
249
[2]250  // -------------------------------------------------------------------------------------------------------------------
251  // encoder function
252  // -------------------------------------------------------------------------------------------------------------------
253
254  /// encode several number of pictures until end-of-sequence
[1313]255#if NH_MV
256  Void encode( Bool bEos,
257    TComPicYuv* pcPicYuvOrg,
258    TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, // used for SNR calculations. Picture in original colour space.
259    TComList<TComPicYuv*>& rcListPicYuvRecOut,
260    std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId );
[655]261
[1313]262  /// encode several number of pictures until end-of-sequence
263  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg,
264    TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, // used for SNR calculations. Picture in original colour space.
265    TComList<TComPicYuv*>& rcListPicYuvRecOut,
266    std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff, Int gopId);
[608]267#else
[1313]268  Void encode( Bool bEos,
269               TComPicYuv* pcPicYuvOrg,
270               TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, // used for SNR calculations. Picture in original colour space.
271               TComList<TComPicYuv*>& rcListPicYuvRecOut,
272               std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded );
[655]273
[1313]274  /// encode several number of pictures until end-of-sequence
275  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg,
276               TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, // used for SNR calculations. Picture in original colour space.
277               TComList<TComPicYuv*>& rcListPicYuvRecOut,
278               std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff);
[608]279#endif
[1413]280#if JVET_F0064_MSSSIM
281  Void printSummary(Bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField, m_printMSEBasedSequencePSNR, m_printSequenceMSE, m_printMSSSIM, m_spsMap.getFirstPS()->getBitDepths()); }
282#else
283  Void printSummary(Bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField, m_printMSEBasedSequencePSNR, m_printSequenceMSE, m_spsMap.getFirstPS()->getBitDepths()); }
284#endif
[608]285
[1313]286#if NH_3D_VSO
287   Void setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset, Int maxCuHeight ); 
[608]288#endif
[56]289};
[2]290
[56]291//! \}
[2]292
293#endif // __TENCTOP__
[1313]294
Note: See TracBrowser for help on using the repository browser.