Mercurial > hg > forks > libbpg
comparison jctvc/TLibEncoder/TEncSlice.h @ 0:772086c29cc7
Initial import.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 16 Nov 2016 11:16:33 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:772086c29cc7 |
---|---|
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-2014, 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 | |
53 class TEncTop; | |
54 class TEncGOP; | |
55 | |
56 // ==================================================================================================================== | |
57 // Class definition | |
58 // ==================================================================================================================== | |
59 | |
60 /// slice encoder class | |
61 class TEncSlice | |
62 : public WeightPredAnalysis | |
63 { | |
64 private: | |
65 // encoder configuration | |
66 TEncCfg* m_pcCfg; ///< encoder configuration class | |
67 | |
68 // pictures | |
69 TComList<TComPic*>* m_pcListPic; ///< list of pictures | |
70 TComPicYuv* m_apcPicYuvPred; ///< prediction picture buffer | |
71 TComPicYuv* m_apcPicYuvResi; ///< residual picture buffer | |
72 | |
73 // processing units | |
74 TEncGOP* m_pcGOPEncoder; ///< GOP encoder | |
75 TEncCu* m_pcCuEncoder; ///< CU encoder | |
76 | |
77 // encoder search | |
78 TEncSearch* m_pcPredSearch; ///< encoder search class | |
79 | |
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 | |
85 | |
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 | |
91 UInt64 m_uiPicDist; ///< total distortion for the picture | |
92 Double m_dPicRdCost; ///< picture-level RD cost | |
93 Double* m_pdRdPicLambda; ///< array of lambda candidates | |
94 Double* m_pdRdPicQp; ///< array of picture QP candidates (double-type for lambda) | |
95 Int* m_piRdPicQp; ///< array of picture QP candidates (Int-type) | |
96 TEncRateCtrl* m_pcRateCtrl; ///< Rate control manager | |
97 UInt m_uiSliceIdx; | |
98 TEncSbac m_lastSliceSegmentEndContextState; ///< context storage for state at the end of the previous slice-segment (used for dependent slices only). | |
99 TEncSbac m_entropyCodingSyncContextState; ///< context storate for state of contexts at the wavefront/WPP/entropy-coding-sync second CTU of tile-row | |
100 | |
101 Void setUpLambda(TComSlice* slice, const Double dLambda, Int iQP); | |
102 Void calculateBoundingCtuTsAddrForSlice(UInt &startCtuTSAddrSlice, UInt &boundingCtuTSAddrSlice, Bool &haveReachedTileBoundary, TComPic* pcPic, const Bool encodingSlice, const Int sliceMode, const Int sliceArgument, const UInt uiSliceCurEndCtuTSAddr); | |
103 | |
104 public: | |
105 TEncSlice(); | |
106 virtual ~TEncSlice(); | |
107 | |
108 Void create ( Int iWidth, Int iHeight, ChromaFormat chromaFormat, UInt iMaxCUWidth, UInt iMaxCUHeight, UChar uhTotalDepth ); | |
109 Void destroy (); | |
110 Void init ( TEncTop* pcEncTop ); | |
111 | |
112 /// preparation of slice encoding (reference marking, QP and lambda) | |
113 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, | |
114 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, Bool isField ); | |
115 Void resetQP ( TComPic* pic, Int sliceQP, Double lambda ); | |
116 // compress and encode slice | |
117 Void precompressSlice ( TComPic* pcPic ); ///< precompress slice for multi-loop opt. | |
118 Void compressSlice ( TComPic* pcPic ); ///< analysis stage of slice | |
119 Void calCostSliceI ( TComPic* pcPic ); | |
120 Void encodeSlice ( TComPic* pcPic, TComOutputBitstream* pcSubstreams, UInt &numBinsCoded ); | |
121 | |
122 // misc. functions | |
123 Void setSearchRange ( TComSlice* pcSlice ); ///< set ME range adaptively | |
124 | |
125 TEncCu* getCUEncoder() { return m_pcCuEncoder; } ///< CU encoder | |
126 Void xDetermineStartAndBoundingCtuTsAddr ( UInt& startCtuTsAddr, UInt& boundingCtuTsAddr, TComPic* pcPic, const Bool encodingSlice ); | |
127 UInt getSliceIdx() { return m_uiSliceIdx; } | |
128 Void setSliceIdx(UInt i) { m_uiSliceIdx = i; } | |
129 | |
130 private: | |
131 Double xGetQPValueAccordingToLambda ( Double lambda ); | |
132 }; | |
133 | |
134 //! \} | |
135 | |
136 #endif // __TENCSLICE__ |