source: 3DVCSoftware/trunk/source/Lib/TLibEncoder/TEncSlice.h @ 1417

Last change on this file since 1417 was 1413, checked in by tech, 6 years ago

Merged HTM-16.2-dev@1412

  • Property svn:eol-style set to native
File size: 7.7 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 *
[1413]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     TEncSlice.h
35    \brief    slice encoder class (header)
36*/
37
38#ifndef __TENCSLICE__
39#define __TENCSLICE__
40
41// Include files
[56]42#include "TLibCommon/CommonDef.h"
43#include "TLibCommon/TComList.h"
44#include "TLibCommon/TComPic.h"
45#include "TLibCommon/TComPicYuv.h"
[2]46#include "TEncCu.h"
47#include "WeightPredAnalysis.h"
[608]48#include "TEncRateCtrl.h"
[2]49
[56]50//! \ingroup TLibEncoder
51//! \{
52
[2]53class TEncTop;
[56]54class TEncGOP;
[2]55
56// ====================================================================================================================
57// Class definition
58// ====================================================================================================================
59
60/// slice encoder class
61class TEncSlice
62  : public WeightPredAnalysis
63{
64private:
65  // encoder configuration
66  TEncCfg*                m_pcCfg;                              ///< encoder configuration class
[1313]67
[2]68  // pictures
69  TComList<TComPic*>*     m_pcListPic;                          ///< list of pictures
[1405]70  TComPicYuv              m_picYuvPred;                         ///< prediction picture buffer
71  TComPicYuv              m_picYuvResi;                         ///< residual picture buffer
[1313]72
[2]73  // processing units
[56]74  TEncGOP*                m_pcGOPEncoder;                       ///< GOP encoder
[2]75  TEncCu*                 m_pcCuEncoder;                        ///< CU encoder
[1313]76
[2]77  // encoder search
78  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
[1313]79
[2]80  // coding tools
81  TEncEntropy*            m_pcEntropyCoder;                     ///< entropy encoder
82  TEncSbac*               m_pcSbacCoder;                        ///< SBAC encoder
83  TEncBinCABAC*           m_pcBinCABAC;                         ///< Bin encoder CABAC
84  TComTrQuant*            m_pcTrQuant;                          ///< transform & quantization
[1313]85
[2]86  // RD optimization
87  TComRdCost*             m_pcRdCost;                           ///< RD cost computation
88  TEncSbac***             m_pppcRDSbacCoder;                    ///< storage for SBAC-based RD optimization
89  TEncSbac*               m_pcRDGoOnSbacCoder;                  ///< go-on SBAC encoder
90  UInt64                  m_uiPicTotalBits;                     ///< total bits for the picture
[1313]91#if NH_3D_VSO
[608]92  Dist64                  m_uiPicDist;                          ///< total distortion for the picture
93#else
[2]94  UInt64                  m_uiPicDist;                          ///< total distortion for the picture
[1413]95#endif 
96 Double                  m_dPicRdCost;                         ///< picture-level RD cost
[1405]97  std::vector<Double>     m_vdRdPicLambda;                      ///< array of lambda candidates
98  std::vector<Double>     m_vdRdPicQp;                          ///< array of picture QP candidates (double-type for lambda)
99  std::vector<Int>        m_viRdPicQp;                          ///< array of picture QP candidates (Int-type)
[608]100  TEncRateCtrl*           m_pcRateCtrl;                         ///< Rate control manager
[2]101  UInt                    m_uiSliceIdx;
[1313]102  TEncSbac                m_lastSliceSegmentEndContextState;    ///< context storage for state at the end of the previous slice-segment (used for dependent slices only).
103  TEncSbac                m_entropyCodingSyncContextState;      ///< context storate for state of contexts at the wavefront/WPP/entropy-coding-sync second CTU of tile-row
104  SliceType               m_encCABACTableIdx;
[1413]105  Int                     m_gopID;
106#if NH_MV
107  SliceType               m_eSliceTypeBaseView;
108#endif
[1313]109
[1413]110  Double   calculateLambda( const TComSlice* pSlice, const Int GOPid, const Int depth, const Double refQP, const Double dQP, Int &iQP );
[1313]111  Void     setUpLambda(TComSlice* slice, const Double dLambda, Int iQP);
112  Void     calculateBoundingCtuTsAddrForSlice(UInt &startCtuTSAddrSlice, UInt &boundingCtuTSAddrSlice, Bool &haveReachedTileBoundary, TComPic* pcPic, const Int sliceMode, const Int sliceArgument);
113
[2]114public:
115  TEncSlice();
116  virtual ~TEncSlice();
[1313]117
118  Void    create              ( Int iWidth, Int iHeight, ChromaFormat chromaFormat, UInt iMaxCUWidth, UInt iMaxCUHeight, UChar uhTotalDepth );
[2]119  Void    destroy             ();
120  Void    init                ( TEncTop* pcEncTop );
[1313]121
[2]122  /// preparation of slice encoding (reference marking, QP and lambda)
[1313]123#if NH_MV
124  Void    initEncSlice        ( TComPic* pcPic, Int pocLast, Int pocCurr, 
125                                Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, Int layerId, bool isField  ); 
[622]126#else
[1386]127  Void    initEncSlice        ( TComPic*  pcPic, const Int pocLast, const Int pocCurr,
128                                const Int iGOPid,   TComSlice*& rpcSlice, const Bool isField );
[622]129#endif
[1413]130
[608]131  Void    resetQP             ( TComPic* pic, Int sliceQP, Double lambda );
[1413]132  Void    setGopID( Int iGopID )      { m_gopID = iGopID; }
133  Int     getGopID() const            { return m_gopID;   }
134  Void    updateLambda(TComSlice* pSlice, Double dQP);
135
[2]136  // compress and encode slice
[1313]137  Void    precompressSlice    ( TComPic* pcPic                                     );      ///< precompress slice for multi-loop slice-level QP opt.
138  Void    compressSlice       ( TComPic* pcPic, const Bool bCompressEntireSlice, const Bool bFastDeltaQP );      ///< analysis stage of slice
139  Void    calCostSliceI       ( TComPic* pcPic );
140  Void    encodeSlice         ( TComPic* pcPic, TComOutputBitstream* pcSubstreams, UInt &numBinsCoded );
141
[2]142  // misc. functions
143  Void    setSearchRange      ( TComSlice* pcSlice  );                                  ///< set ME range adaptively
[1313]144
[2]145  TEncCu*        getCUEncoder() { return m_pcCuEncoder; }                        ///< CU encoder
[1313]146  Void    xDetermineStartAndBoundingCtuTsAddr  ( UInt& startCtuTsAddr, UInt& boundingCtuTsAddr, TComPic* pcPic );
[2]147  UInt    getSliceIdx()         { return m_uiSliceIdx;                    }
148  Void    setSliceIdx(UInt i)   { m_uiSliceIdx = i;                       }
[833]149
[1313]150  SliceType getEncCABACTableIdx() const           { return m_encCABACTableIdx;        }
151
[608]152private:
153  Double  xGetQPValueAccordingToLambda ( Double lambda );
[2]154};
155
[56]156//! \}
[2]157
158#endif // __TENCSLICE__
Note: See TracBrowser for help on using the repository browser.