source: 3DVCSoftware/branches/HTM-16.2-dev/source/App/TAppEncoder/TAppEncTop.h @ 1412

Last change on this file since 1412 was 1412, checked in by tech, 7 years ago
  • Update HM-16.18
  • Cleanups
  • Encoder Extension

-- Representation formats
-- Parameter set sharing
-- GOP configuration

  • Property svn:eol-style set to native
File size: 9.9 KB
RevLine 
[5]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
[1313]4 * granted under this license.
[5]5 *
[1412]6 * Copyright (c) 2010-2017, ITU/ISO/IEC
[5]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.
[56]17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
[5]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 */
[2]33
34/** \file     TAppEncTop.h
35    \brief    Encoder application class (header)
36*/
37
38#ifndef __TAPPENCTOP__
39#define __TAPPENCTOP__
40
[56]41#include <list>
42#include <ostream>
43
44#include "TLibEncoder/TEncTop.h"
45#include "TLibVideoIO/TVideoIOYuv.h"
46#include "TLibCommon/AccessUnit.h"
[2]47#include "TAppEncCfg.h"
[1386]48#if NH_3D_VSO
[2]49#include "../../Lib/TLibRenderer/TRenTop.h"
[56]50#endif
[2]51
[655]52#if KWU_RC_MADPRED_E0227
53class TEncTop;
54#endif
[56]55//! \ingroup TAppEncoder
56//! \{
57
[2]58// ====================================================================================================================
59// Class definition
60// ====================================================================================================================
61
62/// encoder application class
63class TAppEncTop : public TAppEncCfg
64{
65private:
66  // class interface
[1313]67#if NH_MV
[608]68  std::vector<TEncTop*>      m_acTEncTopList ;              ///< encoder class per layer
[100]69  std::vector<TVideoIOYuv*>  m_acTVideoIOYuvInputFileList;  ///< input YUV file
70  std::vector<TVideoIOYuv*>  m_acTVideoIOYuvReconFileList;  ///< output reconstruction file
[608]71 
[1313]72  std::vector<TComList<TComPicYuv*>*>  m_cListPicYuvRec;         ///< list of reconstruction YUV files
[2]73
[608]74  std::vector<Int>           m_frameRcvd;                   ///< number of received frames
[1412]75  TComPicLists               m_ivPicLists;                  ///< picture buffers of encoder instances
[2]76
[1412]77  ParameterSetMap<TComSPS>   m_spsMap;
78  ParameterSetMap<TComPPS>   m_ppsMap;
79 
80  IntAry1d                   m_parameterSetId; 
81  BoolAry1d                  m_sendParameterSets;
82
83
[1313]84#if NH_MV
[964]85  TComVPS*                   m_vps;                         ///< vps
86#else
[608]87  TComVPS                    m_vps;                         ///< vps
[964]88#endif
[608]89#else
90  TEncTop                    m_cTEncTop;                    ///< encoder class
91  TVideoIOYuv                m_cTVideoIOYuvInputFile;       ///< input YUV file
92  TVideoIOYuv                m_cTVideoIOYuvReconFile;       ///< output reconstruction file
[1313]93
[608]94  TComList<TComPicYuv*>      m_cListPicYuvRec;              ///< list of reconstruction YUV files
[1313]95
[608]96  Int                        m_iFrameRcvd;                  ///< number of received frames
[77]97#endif
[56]98
[1313]99#if NH_3D
[1124]100  TComSps3dExtension         m_sps3dExtension;              ///< Currently all layers share the same sps 3D Extension 
[758]101#endif
102
[608]103  UInt m_essentialBytes;
104  UInt m_totalBytes;
[1313]105#if NH_3D_VSO
[2]106  TRenTop                     m_cRendererTop; 
[5]107  TRenModel                   m_cRendererModel;   
[2]108#endif
109protected:
110  // initialization
111  Void  xCreateLib        ();                               ///< create files & encoder class
112  Void  xInitLibCfg       ();                               ///< initialize internal variables
[655]113  Void  xInitLib          (Bool isFieldCoding);             ///< initialize encoder class
[2]114  Void  xDestroyLib       ();                               ///< destroy encoder class
[1313]115
[2]116  /// obtain required buffers
[1313]117#if NH_MV
[608]118  Void  xGetBuffer(TComPicYuv*& rpcPicYuvRec, UInt layer);
119#else
120  Void xGetBuffer(TComPicYuv*& rpcPicYuvRec);
121#endif
122
[2]123  /// delete allocated buffers
124  Void  xDeleteBuffer     ();
[1313]125
[2]126  // file I/O
[1313]127#if NH_MV
[608]128  Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId); ///< write bitstream to file
129#else
130  Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits); ///< write bitstream to file
131#endif
[1313]132  Void rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& stats);
133  Void printRateSummary();
134  Void printChromaFormat();
[100]135
[1313]136#if NH_MV
137  Void xSetTimingInfo             ( TComVPS& vps );
138  Void xSetHrdParameters          ( TComVPS& vps );
[608]139  Void xSetLayerIds               ( TComVPS& vps ); 
140  Void xSetDimensionIdAndLength   ( TComVPS& vps );
141  Void xSetDependencies           ( TComVPS& vps );
142  Void xSetLayerSets              ( TComVPS& vps );
143  Void xSetProfileTierLevel       ( TComVPS& vps );
[1066]144
[1313]145  Void xSetProfileTierLevel       ( TComVPS& vps, Int profileTierLevelIdx, Int subLayer,                             
146                                    Profile::Name profile, Level::Name level, Level::Tier tier, 
147                                    Bool progressiveSourceFlag, Bool interlacedSourceFlag, 
148                                    Bool nonPackedConstraintFlag, Bool frameOnlyConstraintFlag, 
149                                    Bool inbldFlag );
[622]150  Void xSetRepFormat              ( TComVPS& vps );
[738]151  Void xSetDpbSize                ( TComVPS& vps );
[622]152  Void xSetVPSVUI                 ( TComVPS& vps );
[1313]153#if NH_3D
[1179]154  Void xSetCamPara                ( TComVPS& vps );
155#endif
[1412]156
157  Void xDeriveParameterSetIds( TComVPS& vps )
158  {
159
160    m_parameterSetId  .clear();
161    m_sendParameterSets.clear();
162
163    m_parameterSetId  .resize( m_numberOfLayers, -1 );
164    m_sendParameterSets.resize( m_numberOfLayers, false );
165    if ( !m_shareParameterSets )
166    {
167      AOT( m_numberOfLayers > 16 ); 
168      for (Int curVpsLayerId = 0; curVpsLayerId < m_numberOfLayers; curVpsLayerId++ )
169      {
170        m_parameterSetId   [curVpsLayerId] = curVpsLayerId; 
171        m_sendParameterSets[curVpsLayerId] = true         ; 
172      }
173    }
174    else
175    {
176      // The spec requires e.g.:
177      // - It is a requirement of bitstream conformance that, when present, the value of chroma_format_idc shall be less than or equal to chroma_format_vps_idc
178      //   of the vps_rep_format_idx[ j ]-th rep_format( ) syntax structure in the active VPS, where j is equal to LayerIdxInVps[ layerIdCurr ]. 
179
180      // Consequently, a depth layer with chorma format 4:0:0 cannot refer to a base layer SPS with chroma format 4:2:0
181
182      // Furthermore, it is required that
183      // - the SPS RBSP shall have nuh_layer_id equal to 0, nuhLayerId, or IdRefLayer[ nuhLayerId ][ i ] with any value of i in the range of 0 to NumRefLayers[ nuhLayerId ] - 1, inclusive.
184
185      // Because of these requirements and when parameter set sharing is enabled, HTM sends the parameter sets for a current layer in its smallest reference layer having the same representation format.
186
187
188      Int curPsId = 0; 
189
190      // Loop all layers
191      for (Int curVpsLayerId = 0; curVpsLayerId < m_numberOfLayers; curVpsLayerId++ )
192      {
193        // Get smallest reference layer with same rep format idx
194        Int curNuhLayerId = vps.getLayerIdInNuh(curVpsLayerId);
195        Int smallestRefNuhLIdSameRepFmt   = curNuhLayerId;
196
197        Int curRepFormatIdx = m_layerIdxInVpsToRepFormatIdx[ curVpsLayerId ];
198
199        for (Int j = 0; j < vps.getNumRefLayers( curNuhLayerId ); j++ )
200        {
201          Int refNuhLayerId = vps.getIdRefLayer( curNuhLayerId, j );
202          Int refVpsLayerId = vps.getLayerIdInVps( refNuhLayerId ); 
203
204          if ( smallestRefNuhLIdSameRepFmt > refNuhLayerId &&  m_layerIdxInVpsToRepFormatIdx[refVpsLayerId] == curRepFormatIdx  )
205          {
206            smallestRefNuhLIdSameRepFmt = refNuhLayerId; 
207          }
208        }
209
210        Int smallestRefVpsLIdSameRepFmt =   vps.getLayerIdInVps(  smallestRefNuhLIdSameRepFmt ); 
211
212        if (smallestRefVpsLIdSameRepFmt == curVpsLayerId )
213        {
214          m_sendParameterSets[ curVpsLayerId ] = true;         
215          m_parameterSetId   [ curVpsLayerId ] = curPsId;
216          curPsId++;
217          AOT( curPsId > 15 ); 
218        }
219        else
220        {
221          AOT( m_parameterSetId   [ smallestRefVpsLIdSameRepFmt  ] == -1 );
222          m_parameterSetId   [ curVpsLayerId ] = m_parameterSetId   [ smallestRefVpsLIdSameRepFmt  ];
223        }
224
225       
226      }
227    }
228  }
229
[608]230  Int  xGetMax( std::vector<Int>& vec);
[1066]231  Bool xLayerIdInTargetEncLayerIdList( Int nuhLayerId );
[56]232#endif
[1412]233#if NH_3D
[1313]234  Void xDeriveDltArray( TComVPS& vps, TComDLT* dlt );
235  Void xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt);
[758]236#endif
[1313]237
[608]238public:
239  TAppEncTop();
240  virtual ~TAppEncTop();
[1313]241
[608]242  Void        encode      ();                               ///< main encoding function
[1313]243#if NH_MV
[608]244  TEncTop*    getTEncTop( UInt layer ) { return  m_acTEncTopList[layer]; }  ///< return pointer to encoder class for specific layer
[443]245#else
[608]246  TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
[1412]247 
[296]248#endif
[1412]249private:
250
[2]251};// END CLASS DEFINITION TAppEncTop
252
[56]253//! \}
254
[2]255#endif // __TAPPENCTOP__
256
Note: See TracBrowser for help on using the repository browser.