source: SHVCSoftware/trunk/source/Lib/TLibEncoder/TEncSlice.h @ 501

Last change on this file since 501 was 494, checked in by seregin, 11 years ago

reintegrate branch SHM-4.0-dev

  • Property svn:eol-style set to native
File size: 7.9 KB
RevLine 
[313]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     TEncSlice.h
35    \brief    slice encoder class (header)
36*/
37
38#ifndef __TENCSLICE__
39#define __TENCSLICE__
40
41// Include files
42#include "TLibCommon/CommonDef.h"
43#include "TLibCommon/TComList.h"
44#include "TLibCommon/TComPic.h"
45#include "TLibCommon/TComPicYuv.h"
46#include "TEncCu.h"
47#include "WeightPredAnalysis.h"
48#include "TEncRateCtrl.h"
49
50//! \ingroup TLibEncoder
51//! \{
52
53class TEncTop;
54class TEncGOP;
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
67 
68#if SVC_EXTENSION
69  TEncTop**               m_ppcTEncTop;
70#endif 
71
72  // pictures
73  TComList<TComPic*>*     m_pcListPic;                          ///< list of pictures
74  TComPicYuv*             m_apcPicYuvPred;                      ///< prediction picture buffer
75  TComPicYuv*             m_apcPicYuvResi;                      ///< residual picture buffer
76 
77  // processing units
78  TEncGOP*                m_pcGOPEncoder;                       ///< GOP encoder
79  TEncCu*                 m_pcCuEncoder;                        ///< CU encoder
80 
81  // encoder search
82  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
83 
84  // coding tools
85  TEncEntropy*            m_pcEntropyCoder;                     ///< entropy encoder
86  TEncCavlc*              m_pcCavlcCoder;                       ///< CAVLC encoder
87  TEncSbac*               m_pcSbacCoder;                        ///< SBAC encoder
88  TEncBinCABAC*           m_pcBinCABAC;                         ///< Bin encoder CABAC
89  TComTrQuant*            m_pcTrQuant;                          ///< transform & quantization
90 
91  // RD optimization
92  TComBitCounter*         m_pcBitCounter;                       ///< bit counter
93  TComRdCost*             m_pcRdCost;                           ///< RD cost computation
94  TEncSbac***             m_pppcRDSbacCoder;                    ///< storage for SBAC-based RD optimization
95  TEncSbac*               m_pcRDGoOnSbacCoder;                  ///< go-on SBAC encoder
96  UInt64                  m_uiPicTotalBits;                     ///< total bits for the picture
97  UInt64                  m_uiPicDist;                          ///< total distortion for the picture
98  Double                  m_dPicRdCost;                         ///< picture-level RD cost
99  Double*                 m_pdRdPicLambda;                      ///< array of lambda candidates
100  Double*                 m_pdRdPicQp;                          ///< array of picture QP candidates (double-type for lambda)
101  Int*                    m_piRdPicQp;                          ///< array of picture QP candidates (Int-type)
102  TEncBinCABAC*           m_pcBufferBinCoderCABACs;       ///< line of bin coder CABAC
103  TEncSbac*               m_pcBufferSbacCoders;                 ///< line to store temporary contexts
104  TEncBinCABAC*           m_pcBufferLowLatBinCoderCABACs;       ///< dependent tiles: line of bin coder CABAC
105  TEncSbac*               m_pcBufferLowLatSbacCoders;           ///< dependent tiles: line to store temporary contexts
106  TEncRateCtrl*           m_pcRateCtrl;                         ///< Rate control manager
107  UInt                    m_uiSliceIdx;
108  std::vector<TEncSbac*> CTXMem;
109public:
110  TEncSlice();
111  virtual ~TEncSlice();
112 
[494]113#if AUXILIARY_PICTURES
114  Void    create              ( Int iWidth, Int iHeight, ChromaFormat chromaFormat, UInt iMaxCUWidth, UInt iMaxCUHeight, UChar uhTotalDepth );
115#else
[313]116  Void    create              ( Int iWidth, Int iHeight, UInt iMaxCUWidth, UInt iMaxCUHeight, UChar uhTotalDepth );
[494]117#endif
[313]118  Void    destroy             ();
119  Void    init                ( TEncTop* pcEncTop );
120 
121  /// preparation of slice encoding (reference marking, QP and lambda)
122#if SVC_EXTENSION
123  Void    initEncSlice        ( TComPic*  pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd,
[442]124                                Int iGOPid,   TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps, Bool isField );
[494]125#if O0194_WEIGHTED_PREDICTION_CGS
126  Void    estimateILWpParam   ( TComSlice* pcSlice );
127#endif
[313]128#else
129  Void    initEncSlice        ( TComPic*  pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd,
[442]130                                Int iGOPid,   TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, Bool isField );
[313]131#endif
132
133#if RATE_CONTROL_LAMBDA_DOMAIN
134  Void    resetQP             ( TComPic* pic, Int sliceQP, Double lambda );
135#else
136  Void    xLamdaRecalculation ( Int changeQP, Int idGOP, Int depth, SliceType eSliceType, TComSPS* pcSPS, TComSlice* pcSlice);
137#endif
138  // compress and encode slice
139  Void    precompressSlice    ( TComPic*& rpcPic                                );      ///< precompress slice for multi-loop opt.
140  Void    compressSlice       ( TComPic*& rpcPic                                );      ///< analysis stage of slice
141#if RATE_CONTROL_INTRA
142  Void    calCostSliceI       ( TComPic*& rpcPic );
143#endif
144  Void    encodeSlice         ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams  );
145 
146  // misc. functions
147  Void    setSearchRange      ( TComSlice* pcSlice  );                                  ///< set ME range adaptively
148  UInt64  getTotalBits        ()  { return m_uiPicTotalBits; }
149 
150  TEncCu*        getCUEncoder() { return m_pcCuEncoder; }                        ///< CU encoder
151  Void    xDetermineStartAndBoundingCUAddr  ( UInt& uiStartCUAddr, UInt& uiBoundingCUAddr, TComPic*& rpcPic, Bool bEncodeSlice );
152  UInt    getSliceIdx()         { return m_uiSliceIdx;                    }
153  Void    setSliceIdx(UInt i)   { m_uiSliceIdx = i;                       }
154  Void      initCtxMem( UInt i );
155  Void      setCtxMem( TEncSbac* sb, Int b )   { CTXMem[b] = sb; }
156
157private:
158  Double  xGetQPValueAccordingToLambda ( Double lambda );
159
160#if JCTVC_M0259_LAMBDAREFINEMENT
161private:
162  Double  xCalEnhLambdaFactor( Double deltaQP , Double beta );
163#endif
164};
165
166//! \}
167
168#endif // __TENCSLICE__
Note: See TracBrowser for help on using the repository browser.