source: 3DVCSoftware/branches/HTM-DEV-0.3-dev2a/source/Lib/TLibEncoder/TEncTop.h @ 465

Last change on this file since 465 was 465, checked in by tech, 11 years ago

Fixed some minor memory leaks.

  • Property svn:eol-style set to native
File size: 12.2 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-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#if H_3D_ARP
67class TAppEncTop;
68#endif
69
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
78  TComList<TComPic*>      m_cListPic;                     ///< dynamic list of pictures
79 
80#if H_MV
81  TComPicLists*           m_ivPicLists;                   ///< access to picture lists of other layers
82#endif
83  // encoder search
84  TEncSearch              m_cSearch;                      ///< encoder search class
85  TEncEntropy*            m_pcEntropyCoder;                     ///< entropy encoder
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 H_3D_ARP
132  TAppEncTop*             m_pcTAppEncTop;
133#endif
134
135#if H_MV
136  TEncAnalyze             m_cAnalyzeAll;
137  TEncAnalyze             m_cAnalyzeI;
138  TEncAnalyze             m_cAnalyzeP;
139  TEncAnalyze             m_cAnalyzeB; 
140#endif
141protected:
142  Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
143  Void  xInitSPS          ();                             ///< initialize SPS from encoder options
144  Void  xInitPPS          ();                             ///< initialize PPS from encoder options
145 
146  Void  xInitPPSforTiles  ();
147  Void  xInitRPS          ();                             ///< initialize PPS from encoder options
148
149public:
150  TEncTop();
151  virtual ~TEncTop();
152 
153  Void      create          ();
154  Void      destroy         ();
155  Void      init            ();
156#if H_MV 
157  TComPicLists* getIvPicLists() { return m_ivPicLists; }
158#endif
159  Void      deletePicBuffer ();
160
161  Void      createWPPCoders(Int iNumSubstreams);
162 
163#if H_MV
164  Void      initNewPic(TComPicYuv* pcPicYuvOrg);
165#endif
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  TEncSampleAdaptiveOffset* getSAO              () { return  &m_cEncSAO;              }
176  TEncGOP*                getGOPEncoder         () { return  &m_cGOPEncoder;          }
177  TEncSlice*              getSliceEncoder       () { return  &m_cSliceEncoder;        }
178  TEncCu*                 getCuEncoder          () { return  &m_cCuEncoder;           }
179  TEncEntropy*            getEntropyCoder       () { return  &m_cEntropyCoder;        }
180  TEncCavlc*              getCavlcCoder         () { return  &m_cCavlcCoder;          }
181  TEncSbac*               getSbacCoder          () { return  &m_cSbacCoder;           }
182  TEncBinCABAC*           getBinCABAC           () { return  &m_cBinCoderCABAC;       }
183  TEncSbac*               getSbacCoders     () { return  m_pcSbacCoders;      }
184  TEncBinCABAC*           getBinCABACs          () { return  m_pcBinCoderCABACs;      }
185 
186  TComBitCounter*         getBitCounter         () { return  &m_cBitCounter;          }
187  TComRdCost*             getRdCost             () { return  &m_cRdCost;              }
188  TEncSbac***             getRDSbacCoder        () { return  m_pppcRDSbacCoder;       }
189  TEncSbac*               getRDGoOnSbacCoder    () { return  &m_cRDGoOnSbacCoder;     }
190  TComBitCounter*         getBitCounters        () { return  m_pcBitCounters;         }
191  TComRdCost*             getRdCosts            () { return  m_pcRdCosts;             }
192  TEncSbac****            getRDSbacCoders       () { return  m_ppppcRDSbacCoders;     }
193  TEncSbac*               getRDGoOnSbacCoders   () { return  m_pcRDGoOnSbacCoders;   }
194  TEncRateCtrl*           getRateCtrl           () { return &m_cRateCtrl;             }
195  TComSPS*                getSPS                () { return  &m_cSPS;                 }
196  TComPPS*                getPPS                () { return  &m_cPPS;                 }
197  Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid );
198#if L0208_SOP_DESCRIPTION_SEI
199  Int getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid );
200#endif
201  TComScalingList*        getScalingList        () { return  &m_scalingList;         }
202#if H_MV
203  TEncAnalyze*            getAnalyzeAll         () { return &m_cAnalyzeAll; }
204  TEncAnalyze*            getAnalyzeI           () { return &m_cAnalyzeI;   }
205  TEncAnalyze*            getAnalyzeP           () { return &m_cAnalyzeP;   }
206  TEncAnalyze*            getAnalyzeB           () { return &m_cAnalyzeB;   }
207
208  Int                     getNumAllPicCoded     () { return m_uiNumAllPicCoded; }
209 
210  Int                     getFrameId            (Int iGOPid);
211 
212  TComPic*                getPic                ( Int poc );
213  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
214#endif
215#if H_3D_ARP
216  //GT (IVREFS): m_tAppDecTop is not needed any more. Reference pictures can be obtained from m_ivPicLists. Should be fixed later.
217  Void            setTAppEncTop( TAppEncTop* pcTAppEncTop ) { m_pcTAppEncTop = pcTAppEncTop; }
218  TAppEncTop*     getTAppEncTop()                           { return  m_pcTAppEncTop; }
219#endif
220  // -------------------------------------------------------------------------------------------------------------------
221  // encoder function
222  // -------------------------------------------------------------------------------------------------------------------
223
224  /// encode several number of pictures until end-of-sequence
225#if H_MV
226  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded  , Int gopId  ); 
227#else
228  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
229              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 
230#endif
231
232#if H_MV
233  Void printSummary      ( Int numAllPicCoded ); 
234#else
235  void printSummary() { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded); } 
236#endif
237
238#if H_3D
239   Void setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset );
240#endif
241};
242
243//! \}
244
245#endif // __TENCTOP__
Note: See TracBrowser for help on using the repository browser.