source: SHVCSoftware/trunk/source/Lib/TLibEncoder/TEncTop.h @ 548

Last change on this file since 548 was 540, checked in by seregin, 11 years ago

merge SHM-4.1-dev branch

  • Property svn:eol-style set to native
File size: 14.8 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 *
6 * Copyright (c) 2010-2013, 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     TEncTop.h
35    \brief    encoder class (header)
36*/
37
38#ifndef __TENCTOP__
39#define __TENCTOP__
40
41// Include files
42#include "TLibCommon/TComList.h"
43#include "TLibCommon/TComPrediction.h"
44#include "TLibCommon/TComTrQuant.h"
45#include "TLibCommon/AccessUnit.h"
46
47#include "TLibVideoIO/TVideoIOYuv.h"
48
49#include "TEncCfg.h"
50#include "TEncGOP.h"
51#include "TEncSlice.h"
52#include "TEncEntropy.h"
53#include "TEncCavlc.h"
54#include "TEncSbac.h"
55#include "TEncSearch.h"
56#include "TEncSampleAdaptiveOffset.h"
57#include "TEncPreanalyzer.h"
58#include "TEncRateCtrl.h"
59//! \ingroup TLibEncoder
60//! \{
61
62// ====================================================================================================================
63// Class definition
64// ====================================================================================================================
65
66/// encoder class
67class TEncTop : public TEncCfg
68{
69private:
70  // picture
71  Int                     m_iPOCLast;                     ///< time index (POC)
72  Int                     m_iNumPicRcvd;                  ///< number of received pictures
73  UInt                    m_uiNumAllPicCoded;             ///< number of coded pictures
74  TComList<TComPic*>      m_cListPic;                     ///< dynamic list of pictures
75#if SVC_EXTENSION
76  static Int              m_iSPSIdCnt;                    ///< next Id number for SPS   
77  static Int              m_iPPSIdCnt;                    ///< next Id number for PPS   
78#if AVC_SYNTAX
79  fstream*                m_pBLSyntaxFile;
80#endif
81#endif
82 
83  // encoder search
84  TEncSearch              m_cSearch;                      ///< encoder search class
[540]85  //TEncEntropy*            m_pcEntropyCoder;                     ///< entropy encoder
[313]86  TEncCavlc*              m_pcCavlcCoder;                       ///< CAVLC encoder 
87  // coding tool
88  TComTrQuant             m_cTrQuant;                     ///< transform & quantization class
89  TComLoopFilter          m_cLoopFilter;                  ///< deblocking filter class
90  TEncSampleAdaptiveOffset m_cEncSAO;                     ///< sample adaptive offset class
91  TEncEntropy             m_cEntropyCoder;                ///< entropy encoder
92  TEncCavlc               m_cCavlcCoder;                  ///< CAVLC encoder
93  TEncSbac                m_cSbacCoder;                   ///< SBAC encoder
94  TEncBinCABAC            m_cBinCoderCABAC;               ///< bin coder CABAC
95  TEncSbac*               m_pcSbacCoders;                 ///< SBAC encoders (to encode substreams )
96  TEncBinCABAC*           m_pcBinCoderCABACs;             ///< bin coders CABAC (one per substream)
97 
98  // processing unit
99  TEncGOP                 m_cGOPEncoder;                  ///< GOP encoder
100  TEncSlice               m_cSliceEncoder;                ///< slice encoder
101  TEncCu                  m_cCuEncoder;                   ///< CU encoder
102  // SPS
103  TComSPS                 m_cSPS;                         ///< SPS
104  TComPPS                 m_cPPS;                         ///< PPS
105  // RD cost computation
106  TComBitCounter          m_cBitCounter;                  ///< bit counter for RD optimization
107  TComRdCost              m_cRdCost;                      ///< RD cost computation class
108  TEncSbac***             m_pppcRDSbacCoder;              ///< temporal storage for RD computation
109  TEncSbac                m_cRDGoOnSbacCoder;             ///< going on SBAC model for RD stage
110#if FAST_BIT_EST
111  TEncBinCABACCounter***  m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
112  TEncBinCABACCounter     m_cRDGoOnBinCoderCABAC;         ///< going on bin coder CABAC for RD stage
113#else
114  TEncBinCABAC***         m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
115  TEncBinCABAC            m_cRDGoOnBinCoderCABAC;         ///< going on bin coder CABAC for RD stage
116#endif
117  Int                     m_iNumSubstreams;                ///< # of top-level elements allocated.
118  TComBitCounter*         m_pcBitCounters;                 ///< bit counters for RD optimization per substream
119  TComRdCost*             m_pcRdCosts;                     ///< RD cost computation class per substream
120  TEncSbac****            m_ppppcRDSbacCoders;             ///< temporal storage for RD computation per substream
121  TEncSbac*               m_pcRDGoOnSbacCoders;            ///< going on SBAC model for RD stage per substream
122  TEncBinCABAC****        m_ppppcBinCodersCABAC;           ///< temporal CABAC state storage for RD computation per substream
123  TEncBinCABAC*           m_pcRDGoOnBinCodersCABAC;        ///< going on bin coder CABAC for RD stage per substream
124
125  // quality control
126  TEncPreanalyzer         m_cPreanalyzer;                 ///< image characteristics analyzer for TM5-step3-like adaptive QP
127
128  TComScalingList         m_scalingList;                 ///< quantization matrix information
129  TEncRateCtrl            m_cRateCtrl;                    ///< Rate control class
130 
131#if SVC_EXTENSION
[442]132
[313]133  TEncTop**               m_ppcTEncTop;
134  TEncTop*                getLayerEnc(UInt layer)   { return m_ppcTEncTop[layer]; }
135  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
136#if REF_IDX_MFM
137  Bool                    m_bMFMEnabledFlag;
138#endif
139#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
140  Int                     m_ilSampleOnlyPred;
141#endif
142  UInt                    m_numScaledRefLayerOffsets;
[540]143#if O0098_SCALED_REF_LAYER_ID
144  UInt                    m_scaledRefLayerId[MAX_LAYERS];
145#endif
[313]146  Window                  m_scaledRefLayerWindow[MAX_LAYERS];
[442]147#if POC_RESET_FLAG
148  Int                     m_pocAdjustmentValue;
149#endif
[540]150#if NO_CLRAS_OUTPUT_FLAG
151  Bool                    m_noClrasOutputFlag;
152  Bool                    m_layerInitializedFlag;
153  Bool                    m_firstPicInLayerDecodedFlag;
154  Bool                    m_noOutputOfPriorPicsFlags;
155#endif
[494]156#endif //SVC_EXTENSION
[313]157protected:
158  Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
159  Void  xInitSPS          ();                             ///< initialize SPS from encoder options
160  Void  xInitPPS          ();                             ///< initialize PPS from encoder options
161 
162  Void  xInitPPSforTiles  ();
[442]163  Void  xInitRPS          (Bool isFieldCoding);           ///< initialize PPS from encoder options
164#if SVC_EXTENSION
[313]165  Void xInitILRP();
166#endif
167public:
168  TEncTop();
169  virtual ~TEncTop();
170 
171  Void      create          ();
172  Void      destroy         ();
[442]173  Void      init            (Bool isFieldCoding);
[313]174  Void      deletePicBuffer ();
175
176  Void      createWPPCoders(Int iNumSubstreams);
177 
178  // -------------------------------------------------------------------------------------------------------------------
179  // member access functions
180  // -------------------------------------------------------------------------------------------------------------------
181 
182  TComList<TComPic*>*     getListPic            () { return  &m_cListPic;             }
183  TEncSearch*             getPredSearch         () { return  &m_cSearch;              }
184 
185  TComTrQuant*            getTrQuant            () { return  &m_cTrQuant;             }
186  TComLoopFilter*         getLoopFilter         () { return  &m_cLoopFilter;          }
187  TEncSampleAdaptiveOffset* getSAO              () { return  &m_cEncSAO;              }
188  TEncGOP*                getGOPEncoder         () { return  &m_cGOPEncoder;          }
189  TEncSlice*              getSliceEncoder       () { return  &m_cSliceEncoder;        }
190  TEncCu*                 getCuEncoder          () { return  &m_cCuEncoder;           }
191  TEncEntropy*            getEntropyCoder       () { return  &m_cEntropyCoder;        }
192  TEncCavlc*              getCavlcCoder         () { return  &m_cCavlcCoder;          }
193  TEncSbac*               getSbacCoder          () { return  &m_cSbacCoder;           }
194  TEncBinCABAC*           getBinCABAC           () { return  &m_cBinCoderCABAC;       }
195  TEncSbac*               getSbacCoders     () { return  m_pcSbacCoders;      }
196  TEncBinCABAC*           getBinCABACs          () { return  m_pcBinCoderCABACs;      }
197 
198  TComBitCounter*         getBitCounter         () { return  &m_cBitCounter;          }
199  TComRdCost*             getRdCost             () { return  &m_cRdCost;              }
200  TEncSbac***             getRDSbacCoder        () { return  m_pppcRDSbacCoder;       }
201  TEncSbac*               getRDGoOnSbacCoder    () { return  &m_cRDGoOnSbacCoder;     }
202  TComBitCounter*         getBitCounters        () { return  m_pcBitCounters;         }
203  TComRdCost*             getRdCosts            () { return  m_pcRdCosts;             }
204  TEncSbac****            getRDSbacCoders       () { return  m_ppppcRDSbacCoders;     }
205  TEncSbac*               getRDGoOnSbacCoders   () { return  m_pcRDGoOnSbacCoders;   }
206  TEncRateCtrl*           getRateCtrl           () { return &m_cRateCtrl;             }
207  TComSPS*                getSPS                () { return  &m_cSPS;                 }
208  TComPPS*                getPPS                () { return  &m_cPPS;                 }
209  Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid );
210  Int getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid );
211  TComScalingList*        getScalingList        () { return  &m_scalingList;         }
212#if SVC_EXTENSION
213  Void                    setLayerEnc(TEncTop** p) {m_ppcTEncTop = p;}
214  TEncTop**               getLayerEnc()            {return m_ppcTEncTop;}
215  Int                     getPOCLast            () { return m_iPOCLast;               }
216  Int                     getNumPicRcvd         () { return m_iNumPicRcvd;            }
217  Void                    setNumPicRcvd         ( Int num ) { m_iNumPicRcvd = num;      }
218  Void                    setNumScaledRefLayerOffsets(Int x) { m_numScaledRefLayerOffsets = x; }
219  UInt                    getNumScaledRefLayerOffsets() { return m_numScaledRefLayerOffsets; }
[540]220#if O0098_SCALED_REF_LAYER_ID
221  Void                    setScaledRefLayerId(Int x, UInt id) { m_scaledRefLayerId[x] = id;   }
222  UInt                    getScaledRefLayerId(Int x)          { return m_scaledRefLayerId[x]; }
223  Window&  getScaledRefLayerWindowForLayer(Int layerId);
224#endif
[313]225  Window&  getScaledRefLayerWindow(Int x)            { return m_scaledRefLayerWindow[x]; }
[494]226#endif //SVC_EXTENSION
[313]227
228  // -------------------------------------------------------------------------------------------------------------------
229  // encoder function
230  // -------------------------------------------------------------------------------------------------------------------
231
232  /// encode several number of pictures until end-of-sequence
233#if SVC_EXTENSION
234  TComPic** getIlpList() { return m_cIlpPic; }
235#if REF_IDX_MFM
236  Void      setMFMEnabledFlag       (Bool flag)   {m_bMFMEnabledFlag = flag;}
237  Bool      getMFMEnabledFlag()                   {return m_bMFMEnabledFlag;}   
238#endif
239#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
240  Void      setIlSampleOnlyPred( Int i )          { m_ilSampleOnlyPred = i;    }
241  Int       getIlSampleOnlyPred()                 { return m_ilSampleOnlyPred; }
242#endif
243#if AVC_SYNTAX
244  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
245  fstream*  getBLSyntaxFile() { return m_pBLSyntaxFile; }
246#endif
[442]247  Void      encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP );
[313]248  Void      encodePrep( TComPicYuv* pcPicYuvOrg );
[442]249  Void      encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP, Bool isTff );
250  Void      encodePrep( TComPicYuv* pcPicYuvOrg, Bool isTff );
[313]251#if VPS_EXTN_DIRECT_REF_LAYERS
252  TEncTop*  getRefLayerEnc(UInt refLayerIdc);
253#endif
[442]254#if POC_RESET_FLAG
255  Int  getPocAdjustmentValue()      { return m_pocAdjustmentValue;}
256  Void setPocAdjustmentValue(Int x) { m_pocAdjustmentValue = x;   }
257#endif
[540]258#if NO_CLRAS_OUTPUT_FLAG
259  Int  getNoClrasOutputFlag()                { return m_noClrasOutputFlag;}
260  Void setNoClrasOutputFlag(Bool x)          { m_noClrasOutputFlag = x;   }
261  Int  getLayerInitializedFlag()             { return m_layerInitializedFlag;}
262  Void setLayerInitializedFlag(Bool x)       { m_layerInitializedFlag = x;   }
263  Int  getFirstPicInLayerDecodedFlag()       { return m_firstPicInLayerDecodedFlag;}
264  Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x;   }
265  Int  getNoOutputOfPriorPicsFlags()         { return m_noOutputOfPriorPicsFlags;}
266  Void setNoOutputOfPriorPicsFlags(Bool x)   { m_noOutputOfPriorPicsFlags = x;   }
267#endif
[442]268#else //SVC_EXTENSION
[313]269  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
[442]270              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded );
[313]271
[442]272  /// encode several number of pictures until end-of-sequence
273  Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
274              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff);
275
276  Void printSummary(Bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField); }
277#endif //#if SVC_EXTENSION
[313]278};
279
280//! \}
281
282#endif // __TENCTOP__
Note: See TracBrowser for help on using the repository browser.