source: 3DVCSoftware/branches/HTM-DEV-0.2-dev/source/Lib/TLibEncoder/TEncTop.h @ 438

Last change on this file since 438 was 438, checked in by tech, 12 years ago

Integrated 3D encoder control, camera parameters, renderer and MV fixes.

  • Property svn:eol-style set to native
File size: 11.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-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
67
68/// encoder class
69class TEncTop : public TEncCfg
70{
71private:
72  // picture
73  Int                     m_iPOCLast;                     ///< time index (POC)
74  Int                     m_iNumPicRcvd;                  ///< number of received pictures
75  UInt                    m_uiNumAllPicCoded;             ///< number of coded pictures
76  TComList<TComPic*>      m_cListPic;                     ///< dynamic list of pictures
77 
78#if H_MV
79  TComPicLists*           m_ivPicLists;                   ///< access to picture lists of other layers
80#endif
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  TEncEntropy             m_cEntropyCoder;                ///< entropy encoder
90  TEncCavlc               m_cCavlcCoder;                  ///< CAVLC encoder
91  TEncSbac                m_cSbacCoder;                   ///< SBAC encoder
92  TEncBinCABAC            m_cBinCoderCABAC;               ///< bin coder CABAC
93  TEncSbac*               m_pcSbacCoders;                 ///< SBAC encoders (to encode substreams )
94  TEncBinCABAC*           m_pcBinCoderCABACs;             ///< bin coders CABAC (one per substream)
95 
96  // processing unit
97  TEncGOP                 m_cGOPEncoder;                  ///< GOP encoder
98  TEncSlice               m_cSliceEncoder;                ///< slice encoder
99  TEncCu                  m_cCuEncoder;                   ///< CU encoder
100  // SPS
101  TComSPS                 m_cSPS;                         ///< SPS
102  TComPPS                 m_cPPS;                         ///< PPS
103  // RD cost computation
104  TComBitCounter          m_cBitCounter;                  ///< bit counter for RD optimization
105  TComRdCost              m_cRdCost;                      ///< RD cost computation class
106  TEncSbac***             m_pppcRDSbacCoder;              ///< temporal storage for RD computation
107  TEncSbac                m_cRDGoOnSbacCoder;             ///< going on SBAC model for RD stage
108#if FAST_BIT_EST
109  TEncBinCABACCounter***  m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
110  TEncBinCABACCounter     m_cRDGoOnBinCoderCABAC;         ///< going on bin coder CABAC for RD stage
111#else
112  TEncBinCABAC***         m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
113  TEncBinCABAC            m_cRDGoOnBinCoderCABAC;         ///< going on bin coder CABAC for RD stage
114#endif
115  Int                     m_iNumSubstreams;                ///< # of top-level elements allocated.
116  TComBitCounter*         m_pcBitCounters;                 ///< bit counters for RD optimization per substream
117  TComRdCost*             m_pcRdCosts;                     ///< RD cost computation class per substream
118  TEncSbac****            m_ppppcRDSbacCoders;             ///< temporal storage for RD computation per substream
119  TEncSbac*               m_pcRDGoOnSbacCoders;            ///< going on SBAC model for RD stage per substream
120  TEncBinCABAC****        m_ppppcBinCodersCABAC;           ///< temporal CABAC state storage for RD computation per substream
121  TEncBinCABAC*           m_pcRDGoOnBinCodersCABAC;        ///< going on bin coder CABAC for RD stage per substream
122
123  // quality control
124  TEncPreanalyzer         m_cPreanalyzer;                 ///< image characteristics analyzer for TM5-step3-like adaptive QP
125
126  TComScalingList         m_scalingList;                 ///< quantization matrix information
127  TEncRateCtrl            m_cRateCtrl;                    ///< Rate control class
128 
129#if H_MV
130  TEncAnalyze             m_cAnalyzeAll;
131  TEncAnalyze             m_cAnalyzeI;
132  TEncAnalyze             m_cAnalyzeP;
133  TEncAnalyze             m_cAnalyzeB; 
134#endif
135
136protected:
137  Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
138  Void  xInitSPS          ();                             ///< initialize SPS from encoder options
139  Void  xInitPPS          ();                             ///< initialize PPS from encoder options
140 
141  Void  xInitPPSforTiles  ();
142  Void  xInitRPS          ();                             ///< initialize PPS from encoder options
143
144public:
145  TEncTop();
146  virtual ~TEncTop();
147 
148  Void      create          ();
149  Void      destroy         ();
150
151  Void      init            ();
152
153#if H_MV 
154  TComPicLists* getIvPicLists() { return m_ivPicLists; }
155#endif
156
157  Void      deletePicBuffer ();
158
159  Void      createWPPCoders(Int iNumSubstreams);
160 
161#if H_MV
162  Void      initNewPic(TComPicYuv* pcPicYuvOrg);
163#endif
164
165  // -------------------------------------------------------------------------------------------------------------------
166  // member access functions
167  // -------------------------------------------------------------------------------------------------------------------
168 
169  TComList<TComPic*>*     getListPic            () { return  &m_cListPic;             }
170  TEncSearch*             getPredSearch         () { return  &m_cSearch;              }
171 
172  TComTrQuant*            getTrQuant            () { return  &m_cTrQuant;             }
173  TComLoopFilter*         getLoopFilter         () { return  &m_cLoopFilter;          }
174  TEncSampleAdaptiveOffset* getSAO              () { return  &m_cEncSAO;              }
175  TEncGOP*                getGOPEncoder         () { return  &m_cGOPEncoder;          }
176  TEncSlice*              getSliceEncoder       () { return  &m_cSliceEncoder;        }
177  TEncCu*                 getCuEncoder          () { return  &m_cCuEncoder;           }
178  TEncEntropy*            getEntropyCoder       () { return  &m_cEntropyCoder;        }
179  TEncCavlc*              getCavlcCoder         () { return  &m_cCavlcCoder;          }
180  TEncSbac*               getSbacCoder          () { return  &m_cSbacCoder;           }
181  TEncBinCABAC*           getBinCABAC           () { return  &m_cBinCoderCABAC;       }
182  TEncSbac*               getSbacCoders     () { return  m_pcSbacCoders;      }
183  TEncBinCABAC*           getBinCABACs          () { return  m_pcBinCoderCABACs;      }
184 
185  TComBitCounter*         getBitCounter         () { return  &m_cBitCounter;          }
186  TComRdCost*             getRdCost             () { return  &m_cRdCost;              }
187  TEncSbac***             getRDSbacCoder        () { return  m_pppcRDSbacCoder;       }
188  TEncSbac*               getRDGoOnSbacCoder    () { return  &m_cRDGoOnSbacCoder;     }
189  TComBitCounter*         getBitCounters        () { return  m_pcBitCounters;         }
190  TComRdCost*             getRdCosts            () { return  m_pcRdCosts;             }
191  TEncSbac****            getRDSbacCoders       () { return  m_ppppcRDSbacCoders;     }
192  TEncSbac*               getRDGoOnSbacCoders   () { return  m_pcRDGoOnSbacCoders;   }
193  TEncRateCtrl*           getRateCtrl           () { return &m_cRateCtrl;             }
194  TComSPS*                getSPS                () { return  &m_cSPS;                 }
195  TComPPS*                getPPS                () { return  &m_cPPS;                 }
196  Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid );
197  TComScalingList*        getScalingList        () { return  &m_scalingList;         }
198
199#if H_MV
200  TEncAnalyze*            getAnalyzeAll         () { return &m_cAnalyzeAll; }
201  TEncAnalyze*            getAnalyzeI           () { return &m_cAnalyzeI;   }
202  TEncAnalyze*            getAnalyzeP           () { return &m_cAnalyzeP;   }
203  TEncAnalyze*            getAnalyzeB           () { return &m_cAnalyzeB;   }
204
205  Int                     getNumAllPicCoded     () { return m_uiNumAllPicCoded; }
206 
207  Int                     getFrameId            (Int iGOPid);
208 
209  TComPic*                getPic                ( Int poc );
210  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
211#endif
212
213
214  // -------------------------------------------------------------------------------------------------------------------
215  // encoder function
216  // -------------------------------------------------------------------------------------------------------------------
217
218  /// encode several number of pictures until end-of-sequence
219  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
220              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded
221#if H_MV
222              , Int gopId
223#endif       
224              ); 
225
226#if H_MV
227  void printSummary      ( Int numAllPicCoded ); 
228#else
229  void printSummary() { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded); }
230#endif
231
232};
233
234//! \}
235
236#endif // __TENCTOP__
Note: See TracBrowser for help on using the repository browser.