source: SHVCSoftware/branches/SHM-1.1-dev/source/Lib/TLibEncoder/TEncTop.h @ 505

Last change on this file since 505 was 38, checked in by seregin, 12 years ago

AVC_SYNTAX: initial porting of the AVC metadata file reading

File size: 12.6 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     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 "TEncAdaptiveLoopFilter.h"
57#include "TEncSampleAdaptiveOffset.h"
58#include "TEncPreanalyzer.h"
59#include "TEncRateCtrl.h"
60//! \ingroup TLibEncoder
61//! \{
62
63// ====================================================================================================================
64// Class definition
65// ====================================================================================================================
66
67/// encoder class
68class TEncTop : public TEncCfg
69{
70private:
71  // picture
72  Int                     m_iPOCLast;                     ///< time index (POC)
73  Int                     m_iNumPicRcvd;                  ///< number of received pictures
74  UInt                    m_uiNumAllPicCoded;             ///< number of coded pictures
75  TComList<TComPic*>      m_cListPic;                     ///< dynamic list of pictures
76#if SVC_EXTENSION
77  static Int              m_iSPSIdCnt;                    ///< next Id number for SPS   
78  static Int              m_iPPSIdCnt;                    ///< next Id number for PPS   
79#if AVC_SYNTAX
80  fstream*                m_pBLSyntaxFile;
81#endif
82#endif
83 
84  // encoder search
85  TEncSearch              m_cSearch;                      ///< encoder search class
86  TEncEntropy*            m_pcEntropyCoder;                     ///< entropy encoder
87  TEncCavlc*              m_pcCavlcCoder;                       ///< CAVLC encoder 
88  // coding tool
89  TComTrQuant             m_cTrQuant;                     ///< transform & quantization class
90  TComLoopFilter          m_cLoopFilter;                  ///< deblocking filter class
91  TEncSampleAdaptiveOffset m_cEncSAO;                     ///< sample adaptive offset class
92#if !REMOVE_ALF
93  TEncAdaptiveLoopFilter  m_cAdaptiveLoopFilter;          ///< adaptive loop filter class
94#endif
95  TEncEntropy             m_cEntropyCoder;                ///< entropy encoder
96  TEncCavlc               m_cCavlcCoder;                  ///< CAVLC encoder
97  TEncSbac                m_cSbacCoder;                   ///< SBAC encoder
98  TEncBinCABAC            m_cBinCoderCABAC;               ///< bin coder CABAC
99  TEncSbac*               m_pcSbacCoders;                 ///< SBAC encoders (to encode substreams )
100  TEncBinCABAC*           m_pcBinCoderCABACs;             ///< bin coders CABAC (one per substream)
101 
102  // processing unit
103  TEncGOP                 m_cGOPEncoder;                  ///< GOP encoder
104  TEncSlice               m_cSliceEncoder;                ///< slice encoder
105  TEncCu                  m_cCuEncoder;                   ///< CU encoder
106  // SPS
107  TComSPS                 m_cSPS;                         ///< SPS
108  TComPPS                 m_cPPS;                         ///< PPS
109#if !REMOVE_APS
110  std::vector<TComAPS>    m_vAPS;  //!< APS container
111#endif
112  // RD cost computation
113  TComBitCounter          m_cBitCounter;                  ///< bit counter for RD optimization
114  TComRdCost              m_cRdCost;                      ///< RD cost computation class
115  TEncSbac***             m_pppcRDSbacCoder;              ///< temporal storage for RD computation
116  TEncSbac                m_cRDGoOnSbacCoder;             ///< going on SBAC model for RD stage
117#if FAST_BIT_EST
118  TEncBinCABACCounter***  m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
119  TEncBinCABACCounter     m_cRDGoOnBinCoderCABAC;         ///< going on bin coder CABAC for RD stage
120#else
121  TEncBinCABAC***         m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
122  TEncBinCABAC            m_cRDGoOnBinCoderCABAC;         ///< going on bin coder CABAC for RD stage
123#endif
124  Int                     m_iNumSubstreams;                ///< # of top-level elements allocated.
125  TComBitCounter*         m_pcBitCounters;                 ///< bit counters for RD optimization per substream
126  TComRdCost*             m_pcRdCosts;                     ///< RD cost computation class per substream
127  TEncSbac****            m_ppppcRDSbacCoders;             ///< temporal storage for RD computation per substream
128  TEncSbac*               m_pcRDGoOnSbacCoders;            ///< going on SBAC model for RD stage per substream
129  TEncBinCABAC****        m_ppppcBinCodersCABAC;           ///< temporal CABAC state storage for RD computation per substream
130  TEncBinCABAC*           m_pcRDGoOnBinCodersCABAC;        ///< going on bin coder CABAC for RD stage per substream
131
132  // quality control
133  TEncPreanalyzer         m_cPreanalyzer;                 ///< image characteristics analyzer for TM5-step3-like adaptive QP
134
135  TComScalingList         m_scalingList;                 ///< quantization matrix information
136  TEncRateCtrl            m_cRateCtrl;                    ///< Rate control class
137 
138#if SVC_EXTENSION
139  TEncTop**               m_ppcTEncTop;
140  TEncTop*                getLayerEnc(UInt layer)   { return m_ppcTEncTop[layer]; }
141#endif
142#if REF_IDX_FRAMEWORK
143  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
144#endif
145#if REF_IDX_MFM
146  Bool                    m_bMFMEnabledFlag;
147#endif
148protected:
149  Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
150  Void  xInitSPS          ();                             ///< initialize SPS from encoder options
151  Void  xInitPPS          ();                             ///< initialize PPS from encoder options
152 
153  Void  xInitPPSforTiles  ();
154  Void  xInitRPS          ();                             ///< initialize PPS from encoder options
155#if REF_IDX_FRAMEWORK
156  Void xInitILRP();
157#endif
158public:
159  TEncTop();
160  virtual ~TEncTop();
161 
162  Void      create          ();
163  Void      destroy         ();
164  Void      init            ();
165  Void      deletePicBuffer ();
166
167  Void      createWPPCoders(Int iNumSubstreams);
168 
169  // -------------------------------------------------------------------------------------------------------------------
170  // member access functions
171  // -------------------------------------------------------------------------------------------------------------------
172 
173  TComList<TComPic*>*     getListPic            () { return  &m_cListPic;             }
174  TEncSearch*             getPredSearch         () { return  &m_cSearch;              }
175 
176  TComTrQuant*            getTrQuant            () { return  &m_cTrQuant;             }
177  TComLoopFilter*         getLoopFilter         () { return  &m_cLoopFilter;          }
178#if !REMOVE_ALF
179  TEncAdaptiveLoopFilter* getAdaptiveLoopFilter () { return  &m_cAdaptiveLoopFilter;  }
180#endif
181  TEncSampleAdaptiveOffset* getSAO              () { return  &m_cEncSAO;              }
182  TEncGOP*                getGOPEncoder         () { return  &m_cGOPEncoder;          }
183  TEncSlice*              getSliceEncoder       () { return  &m_cSliceEncoder;        }
184  TEncCu*                 getCuEncoder          () { return  &m_cCuEncoder;           }
185  TEncEntropy*            getEntropyCoder       () { return  &m_cEntropyCoder;        }
186  TEncCavlc*              getCavlcCoder         () { return  &m_cCavlcCoder;          }
187  TEncSbac*               getSbacCoder          () { return  &m_cSbacCoder;           }
188  TEncBinCABAC*           getBinCABAC           () { return  &m_cBinCoderCABAC;       }
189  TEncSbac*               getSbacCoders     () { return  m_pcSbacCoders;      }
190  TEncBinCABAC*           getBinCABACs          () { return  m_pcBinCoderCABACs;      }
191 
192  TComBitCounter*         getBitCounter         () { return  &m_cBitCounter;          }
193  TComRdCost*             getRdCost             () { return  &m_cRdCost;              }
194  TEncSbac***             getRDSbacCoder        () { return  m_pppcRDSbacCoder;       }
195  TEncSbac*               getRDGoOnSbacCoder    () { return  &m_cRDGoOnSbacCoder;     }
196  TComBitCounter*         getBitCounters        () { return  m_pcBitCounters;         }
197  TComRdCost*             getRdCosts            () { return  m_pcRdCosts;             }
198  TEncSbac****            getRDSbacCoders       () { return  m_ppppcRDSbacCoders;     }
199  TEncSbac*               getRDGoOnSbacCoders   () { return  m_pcRDGoOnSbacCoders;   }
200  TEncRateCtrl*           getRateCtrl           () { return &m_cRateCtrl;             }
201  TComSPS*                getSPS                () { return  &m_cSPS;                 }
202  TComPPS*                getPPS                () { return  &m_cPPS;                 }
203#if !REMOVE_APS
204  std::vector<TComAPS>&   getAPS                () { return m_vAPS; }
205#endif
206#if SVC_EXTENSION 
207  Void                    setLayerEnc(TEncTop** p) {m_ppcTEncTop = p;}
208  TEncTop**               getLayerEnc()            {return m_ppcTEncTop;}
209#endif
210  Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid,TComList<TComPic*>& listPic );
211  TComScalingList*        getScalingList        () { return  &m_scalingList;         }
212#if SVC_EXTENSION
213  Int                     getPOCLast            () { return m_iPOCLast;               }
214  Int                     getNumPicRcvd         () { return m_iNumPicRcvd;            }
215  Void                    setNumPicRcvd         ( Int num ) { m_iNumPicRcvd = num;      }
216#endif
217
218  // -------------------------------------------------------------------------------------------------------------------
219  // encoder function
220  // -------------------------------------------------------------------------------------------------------------------
221
222  /// encode several number of pictures until end-of-sequence
223#if SVC_EXTENSION
224  Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
225              std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP  );
226
227  Void encodePrep( bool bEos, TComPicYuv* pcPicYuvOrg );
228#if AVC_SYNTAX
229  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
230  fstream*  getBLSyntaxFile() { return m_pBLSyntaxFile; }
231#endif
232#else
233  Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
234              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 
235#endif
236#if REF_IDX_FRAMEWORK
237  TComPic** getIlpList() { return m_cIlpPic; }
238  Void setILRPic(TComPic *pcPic);
239#endif
240#if REF_IDX_MFM
241  Void setMFMEnabledFlag       (Bool flag)   {m_bMFMEnabledFlag = flag;}
242  Bool getMFMEnabledFlag()                   {return m_bMFMEnabledFlag;}   
243#endif
244
245};
246
247//! \}
248
249#endif // __TENCTOP__
Note: See TracBrowser for help on using the repository browser.