source: SHVCSoftware/branches/SHM-1.0-dev/source/Lib/TLibEncoder/TEncTop.h @ 569

Last change on this file since 569 was 25, checked in by qualcomm, 12 years ago

L0336: motion field mapping of inter-layer reference picture from Qualcomm, cjianle@…

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