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 TDecSbac.cpp |
---|
35 | \brief Context-adaptive entropy decoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TDecSbac.h" |
---|
39 | |
---|
40 | //! \ingroup TLibDecoder |
---|
41 | //! \{ |
---|
42 | |
---|
43 | ////////////////////////////////////////////////////////////////////// |
---|
44 | // Construction/Destruction |
---|
45 | ////////////////////////////////////////////////////////////////////// |
---|
46 | |
---|
47 | TDecSbac::TDecSbac() |
---|
48 | // new structure here |
---|
49 | : m_pcBitstream ( 0 ) |
---|
50 | , m_pcTDecBinIf ( NULL ) |
---|
51 | , m_numContextModels ( 0 ) |
---|
52 | , m_cCUSplitFlagSCModel ( 1, 1, NUM_SPLIT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels ) |
---|
53 | , m_cCUSkipFlagSCModel ( 1, 1, NUM_SKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
54 | , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
55 | , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
56 | #if H_3D_ARP |
---|
57 | , m_cCUPUARPWSCModel ( 1, 1, NUM_ARPW_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
58 | #endif |
---|
59 | #if H_3D_IC |
---|
60 | , m_cCUICFlagSCModel ( 1, 1, NUM_IC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
61 | #endif |
---|
62 | , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
63 | , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
64 | , m_cCUIntraPredSCModel ( 1, 1, NUM_ADI_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
65 | , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
66 | , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
67 | , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
68 | , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
69 | , m_cCUMvdSCModel ( 1, 1, NUM_MV_RES_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
70 | , m_cCUQtCbfSCModel ( 1, 2, NUM_QT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
71 | , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
72 | , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
73 | , m_cCUSigCoeffGroupSCModel ( 1, 2, NUM_SIG_CG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
74 | , m_cCUSigSCModel ( 1, 1, NUM_SIG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
75 | , m_cCuCtxLastX ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
76 | , m_cCuCtxLastY ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
77 | , m_cCUOneSCModel ( 1, 1, NUM_ONE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
78 | , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
79 | , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
80 | , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
81 | , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
82 | , m_cTransformSkipSCModel ( 1, 2, NUM_TRANSFORMSKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
83 | , m_CUTransquantBypassFlagSCModel( 1, 1, NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels) |
---|
84 | #if H_3D_DIM |
---|
85 | , m_cDepthIntraModeSCModel ( 1, 1, NUM_DEPTH_INTRA_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
86 | , m_cDdcFlagSCModel ( 1, 1, NUM_DDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
87 | , m_cDdcDataSCModel ( 1, 1, NUM_DDC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
88 | , m_cAngleFlagSCModel ( 1, 1, NUM_ANGLE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
89 | #if H_3D_DIM_DMM && !MTK_DMM_SIMP_CODE_H0092 |
---|
90 | , m_cDmm1DataSCModel ( 1, 1, NUM_DMM1_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
91 | #endif |
---|
92 | #if H_3D_DIM_SDC |
---|
93 | , m_cSDCResidualFlagSCModel ( 1, 1, SDC_NUM_RESIDUAL_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
94 | , m_cSDCResidualSCModel ( 1, 1, SDC_NUM_RESIDUAL_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
95 | #endif |
---|
96 | #endif |
---|
97 | #if H_3D_DIM_SDC |
---|
98 | , m_cSDCFlagSCModel ( 1, 1, NUM_SDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
99 | #endif |
---|
100 | #if H_3D_DBBP |
---|
101 | , m_cDBBPFlagSCModel ( 1, 1, DBBP_NUM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
102 | #endif |
---|
103 | { |
---|
104 | assert( m_numContextModels <= MAX_NUM_CTX_MOD ); |
---|
105 | } |
---|
106 | |
---|
107 | TDecSbac::~TDecSbac() |
---|
108 | { |
---|
109 | } |
---|
110 | |
---|
111 | // ==================================================================================================================== |
---|
112 | // Public member functions |
---|
113 | // ==================================================================================================================== |
---|
114 | |
---|
115 | Void TDecSbac::resetEntropy(TComSlice* pSlice) |
---|
116 | { |
---|
117 | SliceType sliceType = pSlice->getSliceType(); |
---|
118 | Int qp = pSlice->getSliceQp(); |
---|
119 | |
---|
120 | if (pSlice->getPPS()->getCabacInitPresentFlag() && pSlice->getCabacInitFlag()) |
---|
121 | { |
---|
122 | switch (sliceType) |
---|
123 | { |
---|
124 | case P_SLICE: // change initialization table to B_SLICE initialization |
---|
125 | sliceType = B_SLICE; |
---|
126 | break; |
---|
127 | case B_SLICE: // change initialization table to P_SLICE initialization |
---|
128 | sliceType = P_SLICE; |
---|
129 | break; |
---|
130 | default : // should not occur |
---|
131 | assert(0); |
---|
132 | } |
---|
133 | } |
---|
134 | |
---|
135 | m_cCUSplitFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG ); |
---|
136 | m_cCUSkipFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SKIP_FLAG ); |
---|
137 | m_cCUMergeFlagExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
138 | m_cCUMergeIdxExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
139 | #if H_3D_ARP |
---|
140 | m_cCUPUARPWSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ARPW ); |
---|
141 | #endif |
---|
142 | #if H_3D_IC |
---|
143 | m_cCUICFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_IC_FLAG ); |
---|
144 | #endif |
---|
145 | m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); |
---|
146 | m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); |
---|
147 | m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
148 | m_cCUChromaPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
149 | m_cCUInterDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_DIR ); |
---|
150 | m_cCUMvdSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVD ); |
---|
151 | m_cCURefPicSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_REF_PIC ); |
---|
152 | m_cCUDeltaQpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DQP ); |
---|
153 | m_cCUQtCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_CBF ); |
---|
154 | m_cCUQtRootCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
155 | m_cCUSigCoeffGroupSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
156 | m_cCUSigSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_FLAG ); |
---|
157 | m_cCuCtxLastX.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
158 | m_cCuCtxLastY.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
159 | m_cCUOneSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ONE_FLAG ); |
---|
160 | m_cCUAbsSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ABS_FLAG ); |
---|
161 | m_cMVPIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVP_IDX ); |
---|
162 | m_cSaoMergeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG ); |
---|
163 | m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
164 | |
---|
165 | m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
166 | m_cTransformSkipSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); |
---|
167 | m_CUTransquantBypassFlagSCModel.initBuffer( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); |
---|
168 | #if H_3D_DIM |
---|
169 | m_cDepthIntraModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE ); |
---|
170 | m_cDdcFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DDC_FLAG ); |
---|
171 | m_cDdcDataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DDC_DATA ); |
---|
172 | m_cAngleFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ANGLE_FLAG ); |
---|
173 | #if H_3D_DIM_DMM && !MTK_DMM_SIMP_CODE_H0092 |
---|
174 | m_cDmm1DataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM1_DATA ); |
---|
175 | #endif |
---|
176 | #if H_3D_DIM_SDC |
---|
177 | m_cSDCResidualFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); |
---|
178 | m_cSDCResidualSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL ); |
---|
179 | #endif |
---|
180 | #endif |
---|
181 | #if H_3D_DIM_SDC |
---|
182 | m_cSDCFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_FLAG ); |
---|
183 | #endif |
---|
184 | #if H_3D_DBBP |
---|
185 | m_cDBBPFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DBBP_FLAG ); |
---|
186 | #endif |
---|
187 | m_uiLastDQpNonZero = 0; |
---|
188 | |
---|
189 | // new structure |
---|
190 | m_uiLastQp = qp; |
---|
191 | |
---|
192 | m_pcTDecBinIf->start(); |
---|
193 | } |
---|
194 | |
---|
195 | /** The function does the following: Read out terminate bit. Flush CABAC. Byte-align for next tile. |
---|
196 | * Intialize CABAC states. Start CABAC. |
---|
197 | */ |
---|
198 | Void TDecSbac::updateContextTables( SliceType eSliceType, Int iQp ) |
---|
199 | { |
---|
200 | UInt uiBit; |
---|
201 | m_pcTDecBinIf->decodeBinTrm(uiBit); |
---|
202 | assert(uiBit); // end_of_sub_stream_one_bit must be equal to 1 |
---|
203 | m_pcTDecBinIf->finish(); |
---|
204 | m_pcBitstream->readOutTrailingBits(); |
---|
205 | m_cCUSplitFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG ); |
---|
206 | m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG ); |
---|
207 | m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
208 | m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
209 | #if H_3D_ARP |
---|
210 | m_cCUPUARPWSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ARPW ); |
---|
211 | #endif |
---|
212 | #if H_3D_IC |
---|
213 | m_cCUICFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_IC_FLAG ); |
---|
214 | #endif |
---|
215 | m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); |
---|
216 | m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); |
---|
217 | m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
218 | m_cCUChromaPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
219 | m_cCUInterDirSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_DIR ); |
---|
220 | m_cCUMvdSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVD ); |
---|
221 | m_cCURefPicSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_REF_PIC ); |
---|
222 | m_cCUDeltaQpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DQP ); |
---|
223 | m_cCUQtCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_CBF ); |
---|
224 | m_cCUQtRootCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
225 | m_cCUSigCoeffGroupSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
226 | m_cCUSigSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_FLAG ); |
---|
227 | m_cCuCtxLastX.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
228 | m_cCuCtxLastY.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
229 | m_cCUOneSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ONE_FLAG ); |
---|
230 | m_cCUAbsSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG ); |
---|
231 | m_cMVPIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVP_IDX ); |
---|
232 | m_cSaoMergeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG ); |
---|
233 | m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
234 | m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
235 | m_cTransformSkipSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); |
---|
236 | m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); |
---|
237 | |
---|
238 | #if H_3D_DIM |
---|
239 | m_cDepthIntraModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE ); |
---|
240 | m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG ); |
---|
241 | m_cDdcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_DATA ); |
---|
242 | m_cAngleFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG ); |
---|
243 | #if H_3D_DIM_DMM && !MTK_DMM_SIMP_CODE_H0092 |
---|
244 | m_cDmm1DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA ); |
---|
245 | #endif |
---|
246 | #if H_3D_DIM_SDC |
---|
247 | m_cSDCResidualFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); |
---|
248 | m_cSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL ); |
---|
249 | #endif |
---|
250 | #endif |
---|
251 | #if H_3D_DIM_SDC |
---|
252 | m_cSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG ); |
---|
253 | #endif |
---|
254 | #if H_3D_DBBP |
---|
255 | m_cDBBPFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG ); |
---|
256 | #endif |
---|
257 | m_pcTDecBinIf->start(); |
---|
258 | } |
---|
259 | |
---|
260 | Void TDecSbac::parseTerminatingBit( UInt& ruiBit ) |
---|
261 | { |
---|
262 | m_pcTDecBinIf->decodeBinTrm( ruiBit ); |
---|
263 | if ( ruiBit ) |
---|
264 | { |
---|
265 | m_pcTDecBinIf->finish(); |
---|
266 | } |
---|
267 | } |
---|
268 | |
---|
269 | |
---|
270 | Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ) |
---|
271 | { |
---|
272 | if (uiMaxSymbol == 0) |
---|
273 | { |
---|
274 | ruiSymbol = 0; |
---|
275 | return; |
---|
276 | } |
---|
277 | |
---|
278 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
279 | |
---|
280 | if( ruiSymbol == 0 || uiMaxSymbol == 1 ) |
---|
281 | { |
---|
282 | return; |
---|
283 | } |
---|
284 | |
---|
285 | UInt uiSymbol = 0; |
---|
286 | UInt uiCont; |
---|
287 | |
---|
288 | do |
---|
289 | { |
---|
290 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
291 | uiSymbol++; |
---|
292 | } |
---|
293 | while( uiCont && ( uiSymbol < uiMaxSymbol - 1 ) ); |
---|
294 | |
---|
295 | if( uiCont && ( uiSymbol == uiMaxSymbol - 1 ) ) |
---|
296 | { |
---|
297 | uiSymbol++; |
---|
298 | } |
---|
299 | |
---|
300 | ruiSymbol = uiSymbol; |
---|
301 | } |
---|
302 | |
---|
303 | Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount ) |
---|
304 | { |
---|
305 | UInt uiSymbol = 0; |
---|
306 | UInt uiBit = 1; |
---|
307 | |
---|
308 | while( uiBit ) |
---|
309 | { |
---|
310 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
311 | uiSymbol += uiBit << uiCount++; |
---|
312 | } |
---|
313 | |
---|
314 | if ( --uiCount ) |
---|
315 | { |
---|
316 | UInt bins; |
---|
317 | m_pcTDecBinIf->decodeBinsEP( bins, uiCount ); |
---|
318 | uiSymbol += bins; |
---|
319 | } |
---|
320 | |
---|
321 | ruiSymbol = uiSymbol; |
---|
322 | } |
---|
323 | |
---|
324 | Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ) |
---|
325 | { |
---|
326 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
327 | |
---|
328 | if( !ruiSymbol ) |
---|
329 | { |
---|
330 | return; |
---|
331 | } |
---|
332 | |
---|
333 | UInt uiSymbol = 0; |
---|
334 | UInt uiCont; |
---|
335 | |
---|
336 | do |
---|
337 | { |
---|
338 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
339 | uiSymbol++; |
---|
340 | } |
---|
341 | while( uiCont ); |
---|
342 | |
---|
343 | ruiSymbol = uiSymbol; |
---|
344 | } |
---|
345 | |
---|
346 | |
---|
347 | /** Parsing of coeff_abs_level_remaing |
---|
348 | * \param ruiSymbol reference to coeff_abs_level_remaing |
---|
349 | * \param ruiParam reference to parameter |
---|
350 | * \returns Void |
---|
351 | */ |
---|
352 | Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam ) |
---|
353 | { |
---|
354 | |
---|
355 | UInt prefix = 0; |
---|
356 | UInt codeWord = 0; |
---|
357 | do |
---|
358 | { |
---|
359 | prefix++; |
---|
360 | m_pcTDecBinIf->decodeBinEP( codeWord ); |
---|
361 | } |
---|
362 | while( codeWord); |
---|
363 | codeWord = 1 - codeWord; |
---|
364 | prefix -= codeWord; |
---|
365 | codeWord=0; |
---|
366 | if (prefix < COEF_REMAIN_BIN_REDUCTION ) |
---|
367 | { |
---|
368 | m_pcTDecBinIf->decodeBinsEP(codeWord,rParam); |
---|
369 | rSymbol = (prefix<<rParam) + codeWord; |
---|
370 | } |
---|
371 | else |
---|
372 | { |
---|
373 | m_pcTDecBinIf->decodeBinsEP(codeWord,prefix-COEF_REMAIN_BIN_REDUCTION+rParam); |
---|
374 | rSymbol = (((1<<(prefix-COEF_REMAIN_BIN_REDUCTION))+COEF_REMAIN_BIN_REDUCTION-1)<<rParam)+codeWord; |
---|
375 | } |
---|
376 | } |
---|
377 | |
---|
378 | #if H_3D_DIM |
---|
379 | Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel ) |
---|
380 | { |
---|
381 | UInt uiSymbol; |
---|
382 | UInt uiCount = 0; |
---|
383 | do |
---|
384 | { |
---|
385 | m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel ); |
---|
386 | uiCount++; |
---|
387 | } |
---|
388 | #if QC_SIMP_DELTADC_CODING_H0131 |
---|
389 | while( uiSymbol && ( uiCount != 3 ) ); |
---|
390 | #else |
---|
391 | while( uiSymbol && ( uiCount != 13 ) ); |
---|
392 | #endif |
---|
393 | ruiSymbol = uiCount - 1; |
---|
394 | |
---|
395 | if( uiSymbol ) |
---|
396 | { |
---|
397 | xReadEpExGolomb( uiSymbol, 0 ); |
---|
398 | ruiSymbol += uiSymbol + 1; |
---|
399 | } |
---|
400 | |
---|
401 | return; |
---|
402 | } |
---|
403 | |
---|
404 | Void TDecSbac::xParseDimDeltaDC( Pel& rValDeltaDC, UInt uiNumSeg ) |
---|
405 | { |
---|
406 | UInt absValDeltaDC = 0; |
---|
407 | xReadExGolombLevel( absValDeltaDC, m_cDdcDataSCModel.get(0, 0, 0) ); |
---|
408 | rValDeltaDC = (Pel)absValDeltaDC + ( uiNumSeg > 1 ? 0 : 1 ); |
---|
409 | |
---|
410 | if( rValDeltaDC != 0 ) |
---|
411 | { |
---|
412 | UInt uiSign; |
---|
413 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
414 | if ( uiSign ) |
---|
415 | { |
---|
416 | rValDeltaDC = -rValDeltaDC; |
---|
417 | } |
---|
418 | } |
---|
419 | } |
---|
420 | |
---|
421 | |
---|
422 | #if H_3D_DIM_DMM |
---|
423 | Void TDecSbac::xParseDmm1WedgeIdx( UInt& ruiTabIdx, Int iNumBit ) |
---|
424 | { |
---|
425 | UInt uiSymbol, uiIdx = 0; |
---|
426 | for( Int i = 0; i < iNumBit; i++ ) |
---|
427 | { |
---|
428 | #if MTK_DMM_SIMP_CODE_H0092 |
---|
429 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
430 | #else |
---|
431 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm1DataSCModel.get(0, 0, 0) ); |
---|
432 | #endif |
---|
433 | uiIdx += uiSymbol << i; |
---|
434 | } |
---|
435 | ruiTabIdx = uiIdx; |
---|
436 | } |
---|
437 | #endif |
---|
438 | |
---|
439 | #if H_3D_DIM_SDC |
---|
440 | Void TDecSbac::xParseSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSegment ) |
---|
441 | { |
---|
442 | assert( pcCU->getSlice()->getIsDepth() ); |
---|
443 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
444 | assert( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
445 | assert( uiSegment < 2 ); |
---|
446 | |
---|
447 | UInt uiResidual = 0; |
---|
448 | UInt uiBit = 0; |
---|
449 | UInt uiAbsIdx = 0; |
---|
450 | UInt uiSign = 0; |
---|
451 | Int iIdx = 0; |
---|
452 | |
---|
453 | #if H_3D_DIM_DLT |
---|
454 | UInt uiMaxResidualBits = pcCU->getSlice()->getPPS()->getDLT()->getBitsPerDepthValue( pcCU->getSlice()->getLayerIdInVps() ); |
---|
455 | #else |
---|
456 | UInt uiMaxResidualBits = g_bitDepthY; |
---|
457 | #endif |
---|
458 | assert( uiMaxResidualBits <= g_bitDepthY ); |
---|
459 | |
---|
460 | m_pcTDecBinIf->decodeBin(uiResidual, m_cSDCResidualFlagSCModel.get( 0, 0, 0 ) ); |
---|
461 | |
---|
462 | #if H_MV_ENC_DEC_TRAC |
---|
463 | DTRACE_CU("sdc_residual_flag[i]", uiResidual) |
---|
464 | #endif |
---|
465 | |
---|
466 | if (uiResidual) |
---|
467 | { |
---|
468 | // decode residual sign bit |
---|
469 | m_pcTDecBinIf->decodeBinEP(uiSign); |
---|
470 | #if H_MV_ENC_DEC_TRAC |
---|
471 | DTRACE_CU("sdc_residual_sign_flag[i]", uiSign) |
---|
472 | #endif |
---|
473 | |
---|
474 | // decode residual magnitude |
---|
475 | // prefix part |
---|
476 | UInt uiCount = 0; |
---|
477 | #if H_3D_DIM_DLT |
---|
478 | UInt uiNumDepthValues = pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ); |
---|
479 | #else |
---|
480 | UInt uiNumDepthValues = ((1 << g_bitDepthY)-1); |
---|
481 | #endif |
---|
482 | UInt uiPrefixThreshold = ((uiNumDepthValues * 3) >> 2); |
---|
483 | for ( UInt ui = 0; ui < uiPrefixThreshold; ui++) |
---|
484 | { |
---|
485 | m_pcTDecBinIf->decodeBin( uiBit, m_cSDCResidualSCModel.get(0, 0, 0) ); |
---|
486 | if ( uiBit == 0 ) |
---|
487 | break; |
---|
488 | else |
---|
489 | uiCount++; |
---|
490 | } |
---|
491 | // suffix part |
---|
492 | if ( uiCount == uiPrefixThreshold ) |
---|
493 | { |
---|
494 | for ( UInt ui = 0; ui < numBitsForValue(uiNumDepthValues - uiPrefixThreshold); ui++ ) |
---|
495 | { |
---|
496 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
497 | uiAbsIdx |= uiBit << ui; |
---|
498 | } |
---|
499 | uiAbsIdx += uiCount; |
---|
500 | } |
---|
501 | else |
---|
502 | { |
---|
503 | uiAbsIdx = uiCount; |
---|
504 | } |
---|
505 | |
---|
506 | #if H_MV_ENC_DEC_TRAC |
---|
507 | DTRACE_CU("sdc_residual_abs_minus1[i]", uiAbsIdx) |
---|
508 | #endif |
---|
509 | |
---|
510 | uiAbsIdx += 1; |
---|
511 | iIdx =(Int)(uiSign ? -1 : 1)*uiAbsIdx; |
---|
512 | } |
---|
513 | |
---|
514 | pcCU->setSDCSegmentDCOffset(iIdx, uiSegment, uiAbsPartIdx); |
---|
515 | } |
---|
516 | #endif |
---|
517 | #endif |
---|
518 | |
---|
519 | /** Parse I_PCM information. |
---|
520 | * \param pcCU |
---|
521 | * \param uiAbsPartIdx |
---|
522 | * \param uiDepth |
---|
523 | * \returns Void |
---|
524 | * |
---|
525 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
526 | */ |
---|
527 | Void TDecSbac::parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
528 | { |
---|
529 | UInt uiSymbol; |
---|
530 | |
---|
531 | m_pcTDecBinIf->decodeBinTrm(uiSymbol); |
---|
532 | |
---|
533 | #if H_MV_ENC_DEC_TRAC |
---|
534 | DTRACE_CU("pcm_flag", uiSymbol) |
---|
535 | #endif |
---|
536 | if (uiSymbol) |
---|
537 | { |
---|
538 | Bool bIpcmFlag = true; |
---|
539 | |
---|
540 | pcCU->setPartSizeSubParts ( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
541 | pcCU->setSizeSubParts ( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
542 | pcCU->setTrIdxSubParts ( 0, uiAbsPartIdx, uiDepth ); |
---|
543 | pcCU->setIPCMFlagSubParts ( bIpcmFlag, uiAbsPartIdx, uiDepth ); |
---|
544 | |
---|
545 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
546 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
547 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
548 | |
---|
549 | Pel* piPCMSample; |
---|
550 | UInt uiWidth; |
---|
551 | UInt uiHeight; |
---|
552 | UInt uiSampleBits; |
---|
553 | UInt uiX, uiY; |
---|
554 | |
---|
555 | piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; |
---|
556 | uiWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
557 | uiHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
558 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
559 | |
---|
560 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
561 | { |
---|
562 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
563 | { |
---|
564 | UInt uiSample; |
---|
565 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
566 | piPCMSample[uiX] = uiSample; |
---|
567 | } |
---|
568 | piPCMSample += uiWidth; |
---|
569 | } |
---|
570 | |
---|
571 | piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; |
---|
572 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
573 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
574 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
575 | |
---|
576 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
577 | { |
---|
578 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
579 | { |
---|
580 | UInt uiSample; |
---|
581 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
582 | piPCMSample[uiX] = uiSample; |
---|
583 | } |
---|
584 | piPCMSample += uiWidth; |
---|
585 | } |
---|
586 | |
---|
587 | piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; |
---|
588 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
589 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
590 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
591 | |
---|
592 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
593 | { |
---|
594 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
595 | { |
---|
596 | UInt uiSample; |
---|
597 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
598 | piPCMSample[uiX] = uiSample; |
---|
599 | } |
---|
600 | piPCMSample += uiWidth; |
---|
601 | } |
---|
602 | |
---|
603 | m_pcTDecBinIf->start(); |
---|
604 | } |
---|
605 | } |
---|
606 | |
---|
607 | Void TDecSbac::parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
608 | { |
---|
609 | UInt uiSymbol; |
---|
610 | m_pcTDecBinIf->decodeBin( uiSymbol, m_CUTransquantBypassFlagSCModel.get( 0, 0, 0 ) ); |
---|
611 | #if H_MV_ENC_DEC_TRAC |
---|
612 | DTRACE_CU("cu_transquant_bypass_flag", uiSymbol); |
---|
613 | #endif |
---|
614 | pcCU->setCUTransquantBypassSubParts(uiSymbol ? true : false, uiAbsPartIdx, uiDepth); |
---|
615 | } |
---|
616 | |
---|
617 | /** parse skip flag |
---|
618 | * \param pcCU |
---|
619 | * \param uiAbsPartIdx |
---|
620 | * \param uiDepth |
---|
621 | * \returns Void |
---|
622 | */ |
---|
623 | Void TDecSbac::parseSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
624 | { |
---|
625 | if( pcCU->getSlice()->isIntra() ) |
---|
626 | { |
---|
627 | return; |
---|
628 | } |
---|
629 | |
---|
630 | UInt uiSymbol = 0; |
---|
631 | UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx ); |
---|
632 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) ); |
---|
633 | #if !H_MV_ENC_DEC_TRAC |
---|
634 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
635 | DTRACE_CABAC_T( "\tSkipFlag" ); |
---|
636 | DTRACE_CABAC_T( "\tuiCtxSkip: "); |
---|
637 | DTRACE_CABAC_V( uiCtxSkip ); |
---|
638 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
639 | DTRACE_CABAC_V( uiSymbol ); |
---|
640 | DTRACE_CABAC_T( "\n"); |
---|
641 | #endif |
---|
642 | |
---|
643 | if( uiSymbol ) |
---|
644 | { |
---|
645 | pcCU->setSkipFlagSubParts( true, uiAbsPartIdx, uiDepth ); |
---|
646 | pcCU->setPredModeSubParts( MODE_INTER, uiAbsPartIdx, uiDepth ); |
---|
647 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
648 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
649 | pcCU->setMergeFlagSubParts( true , uiAbsPartIdx, 0, uiDepth ); |
---|
650 | } |
---|
651 | #if H_MV_ENC_DEC_TRAC |
---|
652 | DTRACE_CU("cu_skip_flag", uiSymbol); |
---|
653 | #endif |
---|
654 | } |
---|
655 | |
---|
656 | /** parse merge flag |
---|
657 | * \param pcCU |
---|
658 | * \param uiAbsPartIdx |
---|
659 | * \param uiDepth |
---|
660 | * \param uiPUIdx |
---|
661 | * \returns Void |
---|
662 | */ |
---|
663 | Void TDecSbac::parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
664 | { |
---|
665 | UInt uiSymbol; |
---|
666 | m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) ); |
---|
667 | #if H_MV_ENC_DEC_TRAC |
---|
668 | DTRACE_PU("merge_flag", uiSymbol) |
---|
669 | #endif |
---|
670 | pcCU->setMergeFlagSubParts( uiSymbol ? true : false, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
671 | |
---|
672 | #if !H_MV_ENC_DEC_TRAC |
---|
673 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
674 | DTRACE_CABAC_T( "\tMergeFlag: " ); |
---|
675 | DTRACE_CABAC_V( uiSymbol ); |
---|
676 | DTRACE_CABAC_T( "\tAddress: " ); |
---|
677 | DTRACE_CABAC_V( pcCU->getAddr() ); |
---|
678 | DTRACE_CABAC_T( "\tuiAbsPartIdx: " ); |
---|
679 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
680 | DTRACE_CABAC_T( "\n" ); |
---|
681 | #endif |
---|
682 | } |
---|
683 | |
---|
684 | Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex ) |
---|
685 | { |
---|
686 | UInt uiUnaryIdx = 0; |
---|
687 | UInt uiNumCand = pcCU->getSlice()->getMaxNumMergeCand(); |
---|
688 | if ( uiNumCand > 1 ) |
---|
689 | { |
---|
690 | for( ; uiUnaryIdx < uiNumCand - 1; ++uiUnaryIdx ) |
---|
691 | { |
---|
692 | UInt uiSymbol = 0; |
---|
693 | if ( uiUnaryIdx==0 ) |
---|
694 | { |
---|
695 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) ); |
---|
696 | } |
---|
697 | else |
---|
698 | { |
---|
699 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
700 | } |
---|
701 | if( uiSymbol == 0 ) |
---|
702 | { |
---|
703 | break; |
---|
704 | } |
---|
705 | } |
---|
706 | #if H_MV_ENC_DEC_TRAC |
---|
707 | DTRACE_PU("merge_idx", uiUnaryIdx) |
---|
708 | #endif |
---|
709 | } |
---|
710 | ruiMergeIndex = uiUnaryIdx; |
---|
711 | |
---|
712 | #if !H_MV_ENC_DEC_TRAC |
---|
713 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
714 | DTRACE_CABAC_T( "\tparseMergeIndex()" ) |
---|
715 | DTRACE_CABAC_T( "\tuiMRGIdx= " ) |
---|
716 | DTRACE_CABAC_V( ruiMergeIndex ) |
---|
717 | DTRACE_CABAC_T( "\n" ) |
---|
718 | #endif |
---|
719 | } |
---|
720 | |
---|
721 | Void TDecSbac::parseMVPIdx ( Int& riMVPIdx ) |
---|
722 | { |
---|
723 | UInt uiSymbol; |
---|
724 | xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, AMVP_MAX_NUM_CANDS-1); |
---|
725 | riMVPIdx = uiSymbol; |
---|
726 | } |
---|
727 | |
---|
728 | Void TDecSbac::parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
729 | { |
---|
730 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
731 | { |
---|
732 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
733 | return; |
---|
734 | } |
---|
735 | |
---|
736 | UInt uiSymbol; |
---|
737 | #if H_3D_QTLPC |
---|
738 | Bool bParseSplitFlag = true; |
---|
739 | |
---|
740 | TComSPS *sps = pcCU->getPic()->getSlice(0)->getSPS(); |
---|
741 | TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); |
---|
742 | Bool bDepthMapDetect = (pcTexture != NULL); |
---|
743 | Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); |
---|
744 | |
---|
745 | Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); |
---|
746 | |
---|
747 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL() && sps->getUsePC()) |
---|
748 | { |
---|
749 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
750 | assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); |
---|
751 | bParseSplitFlag = (pcTextureCU->getDepth(uiAbsPartIdx) > uiDepth); |
---|
752 | } |
---|
753 | |
---|
754 | if(bParseSplitFlag) |
---|
755 | { |
---|
756 | #endif |
---|
757 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) ); |
---|
758 | #if H_MV_ENC_DEC_TRAC |
---|
759 | DTRACE_CU("split_cu_flag", uiSymbol); |
---|
760 | #else |
---|
761 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
762 | DTRACE_CABAC_T( "\tSplitFlag\n" ) |
---|
763 | #endif |
---|
764 | #if H_3D_QTLPC |
---|
765 | } |
---|
766 | else |
---|
767 | { |
---|
768 | uiSymbol = 0; |
---|
769 | } |
---|
770 | #endif |
---|
771 | pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx ); |
---|
772 | |
---|
773 | return; |
---|
774 | } |
---|
775 | |
---|
776 | /** parse partition size |
---|
777 | * \param pcCU |
---|
778 | * \param uiAbsPartIdx |
---|
779 | * \param uiDepth |
---|
780 | * \returns Void |
---|
781 | */ |
---|
782 | Void TDecSbac::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
783 | { |
---|
784 | UInt uiSymbol, uiMode = 0; |
---|
785 | PartSize eMode; |
---|
786 | |
---|
787 | #if H_3D_QTLPC |
---|
788 | Bool bParsePartSize = true; |
---|
789 | TComSPS *sps = pcCU->getPic()->getSlice(0)->getSPS(); |
---|
790 | TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); |
---|
791 | Bool bDepthMapDetect = (pcTexture != NULL); |
---|
792 | Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); |
---|
793 | |
---|
794 | Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); |
---|
795 | |
---|
796 | Bool depthDependent = false; |
---|
797 | UInt uiTexturePart = uiMode; |
---|
798 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL() && sps->getUsePC()) |
---|
799 | { |
---|
800 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
801 | assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); |
---|
802 | if(pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth ) |
---|
803 | { |
---|
804 | depthDependent = true; |
---|
805 | uiTexturePart = pcTextureCU->getPartitionSize( uiAbsPartIdx ); |
---|
806 | } |
---|
807 | if (pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth && pcTextureCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N) |
---|
808 | { |
---|
809 | bParsePartSize = false; |
---|
810 | eMode = SIZE_2Nx2N; |
---|
811 | } |
---|
812 | } |
---|
813 | #endif |
---|
814 | |
---|
815 | |
---|
816 | if ( pcCU->isIntra( uiAbsPartIdx ) ) |
---|
817 | { |
---|
818 | #if H_3D_QTLPC |
---|
819 | if(bParsePartSize) |
---|
820 | { |
---|
821 | #endif |
---|
822 | uiSymbol = 1; |
---|
823 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
824 | { |
---|
825 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
826 | #if H_MV_ENC_DEC_TRAC |
---|
827 | DTRACE_CU("part_mode", uiSymbol) |
---|
828 | #endif |
---|
829 | } |
---|
830 | eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; |
---|
831 | #if H_3D_QTLPC |
---|
832 | } |
---|
833 | #endif |
---|
834 | UInt uiTrLevel = 0; |
---|
835 | UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; |
---|
836 | UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; |
---|
837 | uiTrLevel = uiWidthInBit >= uiTrSizeInBit ? uiWidthInBit - uiTrSizeInBit : 0; |
---|
838 | if( eMode == SIZE_NxN ) |
---|
839 | { |
---|
840 | pcCU->setTrIdxSubParts( 1+uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
841 | } |
---|
842 | else |
---|
843 | { |
---|
844 | pcCU->setTrIdxSubParts( uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
845 | } |
---|
846 | } |
---|
847 | else |
---|
848 | { |
---|
849 | #if H_3D_QTLPC |
---|
850 | if(bParsePartSize) |
---|
851 | { |
---|
852 | if (depthDependent==false || uiTexturePart == SIZE_NxN|| uiTexturePart == SIZE_2Nx2N) |
---|
853 | { |
---|
854 | #endif |
---|
855 | UInt uiMaxNumBits = 2; |
---|
856 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) ) |
---|
857 | { |
---|
858 | uiMaxNumBits ++; |
---|
859 | } |
---|
860 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
861 | { |
---|
862 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); |
---|
863 | if ( uiSymbol ) |
---|
864 | { |
---|
865 | break; |
---|
866 | } |
---|
867 | uiMode++; |
---|
868 | } |
---|
869 | eMode = (PartSize) uiMode; |
---|
870 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
871 | { |
---|
872 | if (eMode == SIZE_2NxN) |
---|
873 | { |
---|
874 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 )); |
---|
875 | if (uiSymbol == 0) |
---|
876 | { |
---|
877 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
878 | eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); |
---|
879 | } |
---|
880 | } |
---|
881 | else if (eMode == SIZE_Nx2N) |
---|
882 | { |
---|
883 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 )); |
---|
884 | if (uiSymbol == 0) |
---|
885 | { |
---|
886 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
887 | eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); |
---|
888 | } |
---|
889 | } |
---|
890 | } |
---|
891 | #if H_3D_QTLPC |
---|
892 | } |
---|
893 | else if(uiTexturePart == SIZE_2NxN || uiTexturePart == SIZE_2NxnU || uiTexturePart == SIZE_2NxnD) |
---|
894 | { |
---|
895 | UInt uiMaxNumBits = 1; |
---|
896 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
897 | { |
---|
898 | uiMaxNumBits ++; |
---|
899 | } |
---|
900 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
901 | { |
---|
902 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); |
---|
903 | if ( uiSymbol ) |
---|
904 | { |
---|
905 | break; |
---|
906 | } |
---|
907 | uiMode++; |
---|
908 | } |
---|
909 | eMode = (PartSize) uiMode; |
---|
910 | if(uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==1 ) |
---|
911 | { |
---|
912 | eMode = SIZE_2NxN; |
---|
913 | } |
---|
914 | else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth )==0 && uiSymbol==0) |
---|
915 | { |
---|
916 | eMode = SIZE_2NxN; |
---|
917 | } |
---|
918 | else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==0) |
---|
919 | { |
---|
920 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
921 | eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); |
---|
922 | } |
---|
923 | } |
---|
924 | else if(uiTexturePart == SIZE_Nx2N|| uiTexturePart==SIZE_nLx2N || uiTexturePart==SIZE_nRx2N) |
---|
925 | { |
---|
926 | UInt uiMaxNumBits = 1; |
---|
927 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
928 | { |
---|
929 | uiMaxNumBits ++; |
---|
930 | } |
---|
931 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
932 | { |
---|
933 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); |
---|
934 | if ( uiSymbol ) |
---|
935 | { |
---|
936 | break; |
---|
937 | } |
---|
938 | uiMode++; |
---|
939 | } |
---|
940 | eMode = (PartSize) uiMode; |
---|
941 | if(uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==1 ) |
---|
942 | { |
---|
943 | eMode = SIZE_Nx2N; |
---|
944 | } |
---|
945 | else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth )==0 && uiSymbol==0) |
---|
946 | { |
---|
947 | eMode = SIZE_Nx2N; |
---|
948 | } |
---|
949 | else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==0) |
---|
950 | { |
---|
951 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
952 | eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); |
---|
953 | } |
---|
954 | } |
---|
955 | else |
---|
956 | { |
---|
957 | assert(0); |
---|
958 | } |
---|
959 | #endif |
---|
960 | #if H_MV_ENC_DEC_TRAC |
---|
961 | DTRACE_CU("part_mode", eMode ) |
---|
962 | #endif |
---|
963 | #if H_3D_QTLPC |
---|
964 | } |
---|
965 | #endif |
---|
966 | } |
---|
967 | pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth ); |
---|
968 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
969 | } |
---|
970 | |
---|
971 | /** parse prediction mode |
---|
972 | * \param pcCU |
---|
973 | * \param uiAbsPartIdx |
---|
974 | * \param uiDepth |
---|
975 | * \returns Void |
---|
976 | */ |
---|
977 | Void TDecSbac::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
978 | { |
---|
979 | if( pcCU->getSlice()->isIntra() ) |
---|
980 | { |
---|
981 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
982 | return; |
---|
983 | } |
---|
984 | |
---|
985 | UInt uiSymbol; |
---|
986 | Int iPredMode = MODE_INTER; |
---|
987 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) ); |
---|
988 | iPredMode += uiSymbol; |
---|
989 | #if H_MV_ENC_DEC_TRAC |
---|
990 | DTRACE_CU("pred_mode_flag", uiSymbol) |
---|
991 | #endif |
---|
992 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
993 | } |
---|
994 | |
---|
995 | Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
996 | { |
---|
997 | PartSize mode = pcCU->getPartitionSize( absPartIdx ); |
---|
998 | UInt partNum = mode==SIZE_NxN?4:1; |
---|
999 | UInt partOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(absPartIdx) << 1 ) ) >> 2; |
---|
1000 | UInt mpmPred[4],symbol; |
---|
1001 | Int j,intraPredMode; |
---|
1002 | if (mode==SIZE_NxN) |
---|
1003 | { |
---|
1004 | depth++; |
---|
1005 | } |
---|
1006 | for (j=0;j<partNum;j++) |
---|
1007 | { |
---|
1008 | #if H_3D_DIM |
---|
1009 | if( pcCU->getSlice()->getVpsDepthModesFlag() ) |
---|
1010 | { |
---|
1011 | parseIntraDepth( pcCU, absPartIdx+partOffset*j, depth ); |
---|
1012 | } |
---|
1013 | if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) |
---|
1014 | { |
---|
1015 | #endif |
---|
1016 | m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); |
---|
1017 | mpmPred[j] = symbol; |
---|
1018 | #if H_MV_ENC_DEC_TRAC |
---|
1019 | DTRACE_CU("prev_intra_luma_pred_flag", symbol) |
---|
1020 | #endif |
---|
1021 | #if H_3D_DIM |
---|
1022 | } |
---|
1023 | #endif |
---|
1024 | } |
---|
1025 | for (j=0;j<partNum;j++) |
---|
1026 | { |
---|
1027 | #if H_3D_DIM |
---|
1028 | if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) |
---|
1029 | { |
---|
1030 | #endif |
---|
1031 | Int preds[3] = {-1, -1, -1}; |
---|
1032 | Int predNum = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds); |
---|
1033 | if (mpmPred[j]) |
---|
1034 | { |
---|
1035 | m_pcTDecBinIf->decodeBinEP( symbol ); |
---|
1036 | if (symbol) |
---|
1037 | { |
---|
1038 | m_pcTDecBinIf->decodeBinEP( symbol ); |
---|
1039 | symbol++; |
---|
1040 | } |
---|
1041 | #if H_MV_ENC_DEC_TRAC |
---|
1042 | DTRACE_CU("mpm_idx", symbol) |
---|
1043 | #endif |
---|
1044 | intraPredMode = preds[symbol]; |
---|
1045 | } |
---|
1046 | else |
---|
1047 | { |
---|
1048 | m_pcTDecBinIf->decodeBinsEP( symbol, 5 ); |
---|
1049 | intraPredMode = symbol; |
---|
1050 | #if H_MV_ENC_DEC_TRAC |
---|
1051 | DTRACE_CU("rem_intra_luma_pred_mode", symbol) |
---|
1052 | #endif |
---|
1053 | //postponed sorting of MPMs (only in remaining branch) |
---|
1054 | if (preds[0] > preds[1]) |
---|
1055 | { |
---|
1056 | std::swap(preds[0], preds[1]); |
---|
1057 | } |
---|
1058 | if (preds[0] > preds[2]) |
---|
1059 | { |
---|
1060 | std::swap(preds[0], preds[2]); |
---|
1061 | } |
---|
1062 | if (preds[1] > preds[2]) |
---|
1063 | { |
---|
1064 | std::swap(preds[1], preds[2]); |
---|
1065 | } |
---|
1066 | for ( Int i = 0; i < predNum; i++ ) |
---|
1067 | { |
---|
1068 | intraPredMode += ( intraPredMode >= preds[i] ); |
---|
1069 | } |
---|
1070 | } |
---|
1071 | pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, absPartIdx+partOffset*j, depth ); |
---|
1072 | #if H_3D_DIM |
---|
1073 | } |
---|
1074 | #endif |
---|
1075 | } |
---|
1076 | } |
---|
1077 | |
---|
1078 | Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1079 | { |
---|
1080 | UInt uiSymbol; |
---|
1081 | |
---|
1082 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) ); |
---|
1083 | |
---|
1084 | if( uiSymbol == 0 ) |
---|
1085 | { |
---|
1086 | #if H_MV_ENC_DEC_TRAC |
---|
1087 | DTRACE_CU("intra_chroma_pred_mode", uiSymbol ) |
---|
1088 | #endif |
---|
1089 | uiSymbol = DM_CHROMA_IDX; |
---|
1090 | } |
---|
1091 | else |
---|
1092 | { |
---|
1093 | { |
---|
1094 | UInt uiIPredMode; |
---|
1095 | m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 ); |
---|
1096 | #if H_MV_ENC_DEC_TRAC |
---|
1097 | DTRACE_CU("intra_chroma_pred_mode", uiIPredMode ) |
---|
1098 | #endif |
---|
1099 | UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; |
---|
1100 | pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); |
---|
1101 | uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; |
---|
1102 | } |
---|
1103 | } |
---|
1104 | pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); |
---|
1105 | return; |
---|
1106 | } |
---|
1107 | |
---|
1108 | #if H_3D_DIM |
---|
1109 | Void TDecSbac::parseIntraDepth( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
1110 | { |
---|
1111 | parseIntraDepthMode( pcCU, absPartIdx, depth ); |
---|
1112 | |
---|
1113 | UInt dir = pcCU->getLumaIntraDir( absPartIdx ); |
---|
1114 | UInt dimType = getDimType( dir ); |
---|
1115 | |
---|
1116 | switch( dimType ) |
---|
1117 | { |
---|
1118 | #if H_3D_DIM_DMM |
---|
1119 | case( DMM1_IDX ): |
---|
1120 | { |
---|
1121 | UInt uiTabIdx = 0; |
---|
1122 | xParseDmm1WedgeIdx( uiTabIdx, g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); |
---|
1123 | pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, absPartIdx, depth ); |
---|
1124 | } break; |
---|
1125 | case( DMM4_IDX ): break; |
---|
1126 | #endif |
---|
1127 | default: break; |
---|
1128 | } |
---|
1129 | |
---|
1130 | pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth ); |
---|
1131 | } |
---|
1132 | |
---|
1133 | Void TDecSbac::parseIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
1134 | { |
---|
1135 | UInt uiSymbol, uiIsDimMode; |
---|
1136 | |
---|
1137 | if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed |
---|
1138 | { |
---|
1139 | #if LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135 |
---|
1140 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cAngleFlagSCModel.get( 0, 0, 0 ) ); |
---|
1141 | #else |
---|
1142 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cAngleFlagSCModel.get( 0, 0, pcCU->getCtxAngleFlag( absPartIdx ) ) ); |
---|
1143 | #endif |
---|
1144 | } |
---|
1145 | else |
---|
1146 | { |
---|
1147 | uiSymbol = 1; |
---|
1148 | } |
---|
1149 | uiIsDimMode = uiSymbol ? 0 : 1; |
---|
1150 | pcCU->setLumaIntraDirSubParts( 0, absPartIdx, depth ); |
---|
1151 | |
---|
1152 | //decode DMM index |
---|
1153 | if( uiIsDimMode ) |
---|
1154 | { |
---|
1155 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDepthIntraModeSCModel.get( 0, 0, 0 ) ); |
---|
1156 | if( !uiSymbol ) |
---|
1157 | { |
---|
1158 | pcCU->setLumaIntraDirSubParts( ( 2 * DMM1_IDX + DIM_OFFSET ), absPartIdx, depth ); |
---|
1159 | } |
---|
1160 | else |
---|
1161 | { |
---|
1162 | pcCU->setLumaIntraDirSubParts( ( 2 * DMM4_IDX + DIM_OFFSET ), absPartIdx, depth ); |
---|
1163 | } |
---|
1164 | } |
---|
1165 | } |
---|
1166 | #endif |
---|
1167 | |
---|
1168 | Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ) |
---|
1169 | { |
---|
1170 | UInt uiSymbol; |
---|
1171 | const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); |
---|
1172 | ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 ); |
---|
1173 | uiSymbol = 0; |
---|
1174 | if (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N || pcCU->getHeight(uiAbsPartIdx) != 8 ) |
---|
1175 | { |
---|
1176 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) ); |
---|
1177 | } |
---|
1178 | |
---|
1179 | if( uiSymbol ) |
---|
1180 | { |
---|
1181 | uiSymbol = 2; |
---|
1182 | } |
---|
1183 | else |
---|
1184 | { |
---|
1185 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + 4 ) ); |
---|
1186 | assert(uiSymbol == 0 || uiSymbol == 1); |
---|
1187 | } |
---|
1188 | |
---|
1189 | uiSymbol++; |
---|
1190 | ruiInterDir = uiSymbol; |
---|
1191 | #if H_MV_ENC_DEC_TRAC |
---|
1192 | DTRACE_PU("inter_pred_idc", ruiInterDir - 1 ) |
---|
1193 | #endif |
---|
1194 | |
---|
1195 | return; |
---|
1196 | } |
---|
1197 | |
---|
1198 | Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList ) |
---|
1199 | { |
---|
1200 | UInt uiSymbol; |
---|
1201 | { |
---|
1202 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
1203 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1204 | |
---|
1205 | if( uiSymbol ) |
---|
1206 | { |
---|
1207 | UInt uiRefNum = pcCU->getSlice()->getNumRefIdx( eRefList ) - 2; |
---|
1208 | pCtx++; |
---|
1209 | UInt ui; |
---|
1210 | for( ui = 0; ui < uiRefNum; ++ui ) |
---|
1211 | { |
---|
1212 | if( ui == 0 ) |
---|
1213 | { |
---|
1214 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1215 | } |
---|
1216 | else |
---|
1217 | { |
---|
1218 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
1219 | } |
---|
1220 | if( uiSymbol == 0 ) |
---|
1221 | { |
---|
1222 | break; |
---|
1223 | } |
---|
1224 | } |
---|
1225 | uiSymbol = ui + 1; |
---|
1226 | } |
---|
1227 | riRefFrmIdx = uiSymbol; |
---|
1228 | } |
---|
1229 | |
---|
1230 | #if H_MV_ENC_DEC_TRAC |
---|
1231 | #if ENC_DEC_TRACE |
---|
1232 | if ( eRefList == REF_PIC_LIST_0 ) |
---|
1233 | { |
---|
1234 | DTRACE_PU("ref_idx_l0", uiSymbol) |
---|
1235 | } |
---|
1236 | else |
---|
1237 | { |
---|
1238 | DTRACE_PU("ref_idx_l1", uiSymbol) |
---|
1239 | } |
---|
1240 | #endif |
---|
1241 | #endif |
---|
1242 | return; |
---|
1243 | } |
---|
1244 | |
---|
1245 | Void TDecSbac::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
1246 | { |
---|
1247 | UInt uiSymbol; |
---|
1248 | UInt uiHorAbs; |
---|
1249 | UInt uiVerAbs; |
---|
1250 | UInt uiHorSign = 0; |
---|
1251 | UInt uiVerSign = 0; |
---|
1252 | ContextModel *pCtx = m_cCUMvdSCModel.get( 0 ); |
---|
1253 | |
---|
1254 | if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3) |
---|
1255 | { |
---|
1256 | uiHorAbs=0; |
---|
1257 | uiVerAbs=0; |
---|
1258 | } |
---|
1259 | else |
---|
1260 | { |
---|
1261 | m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx ); |
---|
1262 | m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx ); |
---|
1263 | |
---|
1264 | const Bool bHorAbsGr0 = uiHorAbs != 0; |
---|
1265 | const Bool bVerAbsGr0 = uiVerAbs != 0; |
---|
1266 | pCtx++; |
---|
1267 | |
---|
1268 | if( bHorAbsGr0 ) |
---|
1269 | { |
---|
1270 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1271 | uiHorAbs += uiSymbol; |
---|
1272 | } |
---|
1273 | |
---|
1274 | if( bVerAbsGr0 ) |
---|
1275 | { |
---|
1276 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1277 | uiVerAbs += uiSymbol; |
---|
1278 | } |
---|
1279 | |
---|
1280 | if( bHorAbsGr0 ) |
---|
1281 | { |
---|
1282 | if( 2 == uiHorAbs ) |
---|
1283 | { |
---|
1284 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
1285 | uiHorAbs += uiSymbol; |
---|
1286 | } |
---|
1287 | |
---|
1288 | m_pcTDecBinIf->decodeBinEP( uiHorSign ); |
---|
1289 | } |
---|
1290 | |
---|
1291 | if( bVerAbsGr0 ) |
---|
1292 | { |
---|
1293 | if( 2 == uiVerAbs ) |
---|
1294 | { |
---|
1295 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
1296 | uiVerAbs += uiSymbol; |
---|
1297 | } |
---|
1298 | |
---|
1299 | m_pcTDecBinIf->decodeBinEP( uiVerSign ); |
---|
1300 | } |
---|
1301 | |
---|
1302 | } |
---|
1303 | |
---|
1304 | const TComMv cMv( uiHorSign ? -Int( uiHorAbs ): uiHorAbs, uiVerSign ? -Int( uiVerAbs ) : uiVerAbs ); |
---|
1305 | pcCU->getCUMvField( eRefList )->setAllMvd( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1306 | return; |
---|
1307 | } |
---|
1308 | |
---|
1309 | |
---|
1310 | Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) |
---|
1311 | { |
---|
1312 | m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) ); |
---|
1313 | #if !H_MV_ENC_DEC_TRAC |
---|
1314 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1315 | DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) |
---|
1316 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1317 | DTRACE_CABAC_V( ruiSubdivFlag ) |
---|
1318 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1319 | DTRACE_CABAC_V( uiLog2TransformBlockSize ) |
---|
1320 | DTRACE_CABAC_T( "\n" ) |
---|
1321 | #endif |
---|
1322 | } |
---|
1323 | |
---|
1324 | Void TDecSbac::parseQtRootCbf( UInt uiAbsPartIdx, UInt& uiQtRootCbf ) |
---|
1325 | { |
---|
1326 | UInt uiSymbol; |
---|
1327 | const UInt uiCtx = 0; |
---|
1328 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) ); |
---|
1329 | #if !H_MV_ENC_DEC_TRAC |
---|
1330 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1331 | DTRACE_CABAC_T( "\tparseQtRootCbf()" ) |
---|
1332 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1333 | DTRACE_CABAC_V( uiSymbol ) |
---|
1334 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1335 | DTRACE_CABAC_V( uiCtx ) |
---|
1336 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1337 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1338 | DTRACE_CABAC_T( "\n" ) |
---|
1339 | #else |
---|
1340 | DTRACE_CU( "rqt_root_cbf", uiSymbol ) |
---|
1341 | #endif |
---|
1342 | |
---|
1343 | uiQtRootCbf = uiSymbol; |
---|
1344 | } |
---|
1345 | |
---|
1346 | Void TDecSbac::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1347 | { |
---|
1348 | Int qp; |
---|
1349 | UInt uiDQp; |
---|
1350 | Int iDQp; |
---|
1351 | |
---|
1352 | UInt uiSymbol; |
---|
1353 | |
---|
1354 | xReadUnaryMaxSymbol (uiDQp, &m_cCUDeltaQpSCModel.get( 0, 0, 0 ), 1, CU_DQP_TU_CMAX); |
---|
1355 | |
---|
1356 | if( uiDQp >= CU_DQP_TU_CMAX) |
---|
1357 | { |
---|
1358 | xReadEpExGolomb( uiSymbol, CU_DQP_EG_k ); |
---|
1359 | uiDQp+=uiSymbol; |
---|
1360 | } |
---|
1361 | |
---|
1362 | if ( uiDQp > 0 ) |
---|
1363 | { |
---|
1364 | UInt uiSign; |
---|
1365 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
1366 | m_pcTDecBinIf->decodeBinEP(uiSign); |
---|
1367 | iDQp = uiDQp; |
---|
1368 | if(uiSign) |
---|
1369 | { |
---|
1370 | iDQp = -iDQp; |
---|
1371 | } |
---|
1372 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY; |
---|
1373 | } |
---|
1374 | else |
---|
1375 | { |
---|
1376 | qp = pcCU->getRefQP(uiAbsPartIdx); |
---|
1377 | } |
---|
1378 | pcCU->setQPSubParts(qp, uiAbsPartIdx, uiDepth); |
---|
1379 | pcCU->setCodedQP(qp); |
---|
1380 | } |
---|
1381 | |
---|
1382 | Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) |
---|
1383 | { |
---|
1384 | UInt uiSymbol; |
---|
1385 | const UInt uiCtx = pcCU->getCtxQtCbf( eType, uiTrDepth ); |
---|
1386 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) ); |
---|
1387 | #if !H_MV_ENC_DEC_TRAC |
---|
1388 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1389 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
1390 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1391 | DTRACE_CABAC_V( uiSymbol ) |
---|
1392 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1393 | DTRACE_CABAC_V( uiCtx ) |
---|
1394 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1395 | DTRACE_CABAC_V( eType ) |
---|
1396 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1397 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1398 | DTRACE_CABAC_T( "\n" ) |
---|
1399 | #endif |
---|
1400 | |
---|
1401 | pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth ); |
---|
1402 | } |
---|
1403 | |
---|
1404 | void TDecSbac::parseTransformSkipFlags (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType) |
---|
1405 | { |
---|
1406 | if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) |
---|
1407 | { |
---|
1408 | return; |
---|
1409 | } |
---|
1410 | if(width != 4 || height != 4) |
---|
1411 | { |
---|
1412 | return; |
---|
1413 | } |
---|
1414 | |
---|
1415 | UInt useTransformSkip; |
---|
1416 | m_pcTDecBinIf->decodeBin( useTransformSkip , m_cTransformSkipSCModel.get( 0, eTType? TEXT_CHROMA: TEXT_LUMA, 0 ) ); |
---|
1417 | if(eTType!= TEXT_LUMA) |
---|
1418 | { |
---|
1419 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - uiDepth; |
---|
1420 | if(uiLog2TrafoSize == 2) |
---|
1421 | { |
---|
1422 | uiDepth --; |
---|
1423 | } |
---|
1424 | } |
---|
1425 | #if !H_MV_ENC_DEC_TRAC |
---|
1426 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1427 | DTRACE_CABAC_T("\tparseTransformSkip()"); |
---|
1428 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1429 | DTRACE_CABAC_V( useTransformSkip ) |
---|
1430 | DTRACE_CABAC_T( "\tAddr=" ) |
---|
1431 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
1432 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1433 | DTRACE_CABAC_V( eTType ) |
---|
1434 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1435 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1436 | DTRACE_CABAC_T( "\n" ) |
---|
1437 | #endif |
---|
1438 | |
---|
1439 | pcCU->setTransformSkipSubParts( useTransformSkip, eTType, uiAbsPartIdx, uiDepth); |
---|
1440 | } |
---|
1441 | |
---|
1442 | /** Parse (X,Y) position of the last significant coefficient |
---|
1443 | * \param uiPosLastX reference to X component of last coefficient |
---|
1444 | * \param uiPosLastY reference to Y component of last coefficient |
---|
1445 | * \param width Block width |
---|
1446 | * \param height Block height |
---|
1447 | * \param eTType plane type / luminance or chrominance |
---|
1448 | * \param uiScanIdx scan type (zig-zag, hor, ver) |
---|
1449 | * |
---|
1450 | * This method decodes the X and Y component within a block of the last significant coefficient. |
---|
1451 | */ |
---|
1452 | Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx ) |
---|
1453 | { |
---|
1454 | UInt uiLast; |
---|
1455 | ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); |
---|
1456 | ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); |
---|
1457 | |
---|
1458 | Int blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY; |
---|
1459 | blkSizeOffsetX = eTType ? 0: (g_aucConvertToBit[ width ] *3 + ((g_aucConvertToBit[ width ] +1)>>2)); |
---|
1460 | blkSizeOffsetY = eTType ? 0: (g_aucConvertToBit[ height ]*3 + ((g_aucConvertToBit[ height ]+1)>>2)); |
---|
1461 | shiftX= eTType ? g_aucConvertToBit[ width ] :((g_aucConvertToBit[ width ]+3)>>2); |
---|
1462 | shiftY= eTType ? g_aucConvertToBit[ height ] :((g_aucConvertToBit[ height ]+3)>>2); |
---|
1463 | // posX |
---|
1464 | for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ ) |
---|
1465 | { |
---|
1466 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + blkSizeOffsetX + (uiPosLastX >>shiftX) ) ); |
---|
1467 | if( !uiLast ) |
---|
1468 | { |
---|
1469 | break; |
---|
1470 | } |
---|
1471 | } |
---|
1472 | |
---|
1473 | // posY |
---|
1474 | for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ ) |
---|
1475 | { |
---|
1476 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + blkSizeOffsetY + (uiPosLastY >>shiftY)) ); |
---|
1477 | if( !uiLast ) |
---|
1478 | { |
---|
1479 | break; |
---|
1480 | } |
---|
1481 | } |
---|
1482 | if ( uiPosLastX > 3 ) |
---|
1483 | { |
---|
1484 | UInt uiTemp = 0; |
---|
1485 | UInt uiCount = ( uiPosLastX - 2 ) >> 1; |
---|
1486 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
1487 | { |
---|
1488 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
1489 | uiTemp += uiLast << i; |
---|
1490 | } |
---|
1491 | uiPosLastX = g_uiMinInGroup[ uiPosLastX ] + uiTemp; |
---|
1492 | } |
---|
1493 | if ( uiPosLastY > 3 ) |
---|
1494 | { |
---|
1495 | UInt uiTemp = 0; |
---|
1496 | UInt uiCount = ( uiPosLastY - 2 ) >> 1; |
---|
1497 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
1498 | { |
---|
1499 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
1500 | uiTemp += uiLast << i; |
---|
1501 | } |
---|
1502 | uiPosLastY = g_uiMinInGroup[ uiPosLastY ] + uiTemp; |
---|
1503 | } |
---|
1504 | |
---|
1505 | if( uiScanIdx == SCAN_VER ) |
---|
1506 | { |
---|
1507 | swap( uiPosLastX, uiPosLastY ); |
---|
1508 | } |
---|
1509 | } |
---|
1510 | |
---|
1511 | Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
1512 | { |
---|
1513 | #if !H_MV_ENC_DEC_TRAC |
---|
1514 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1515 | DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) |
---|
1516 | DTRACE_CABAC_V( eTType ) |
---|
1517 | DTRACE_CABAC_T( "\twidth=" ) |
---|
1518 | DTRACE_CABAC_V( uiWidth ) |
---|
1519 | DTRACE_CABAC_T( "\theight=" ) |
---|
1520 | DTRACE_CABAC_V( uiHeight ) |
---|
1521 | DTRACE_CABAC_T( "\tdepth=" ) |
---|
1522 | DTRACE_CABAC_V( uiDepth ) |
---|
1523 | DTRACE_CABAC_T( "\tabspartidx=" ) |
---|
1524 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1525 | DTRACE_CABAC_T( "\ttoCU-X=" ) |
---|
1526 | DTRACE_CABAC_V( pcCU->getCUPelX() ) |
---|
1527 | DTRACE_CABAC_T( "\ttoCU-Y=" ) |
---|
1528 | DTRACE_CABAC_V( pcCU->getCUPelY() ) |
---|
1529 | DTRACE_CABAC_T( "\tCU-addr=" ) |
---|
1530 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
1531 | DTRACE_CABAC_T( "\tinCU-X=" ) |
---|
1532 | DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1533 | DTRACE_CABAC_T( "\tinCU-Y=" ) |
---|
1534 | DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1535 | DTRACE_CABAC_T( "\tpredmode=" ) |
---|
1536 | DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) |
---|
1537 | DTRACE_CABAC_T( "\n" ) |
---|
1538 | #endif |
---|
1539 | |
---|
1540 | if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) |
---|
1541 | { |
---|
1542 | uiWidth = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
1543 | uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
1544 | } |
---|
1545 | if(pcCU->getSlice()->getPPS()->getUseTransformSkip()) |
---|
1546 | { |
---|
1547 | parseTransformSkipFlags( pcCU, uiAbsPartIdx, uiWidth, uiHeight, uiDepth, eTType); |
---|
1548 | } |
---|
1549 | |
---|
1550 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); |
---|
1551 | |
---|
1552 | //----- parse significance map ----- |
---|
1553 | const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; |
---|
1554 | const UInt uiMaxNumCoeff = uiWidth * uiHeight; |
---|
1555 | const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; |
---|
1556 | UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); |
---|
1557 | |
---|
1558 | //===== decode last significant ===== |
---|
1559 | UInt uiPosLastX, uiPosLastY; |
---|
1560 | parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, eTType, uiScanIdx ); |
---|
1561 | UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockSize); |
---|
1562 | pcCoef[ uiBlkPosLast ] = 1; |
---|
1563 | |
---|
1564 | //===== decode significance flags ===== |
---|
1565 | UInt uiScanPosLast; |
---|
1566 | const UInt *scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ]; |
---|
1567 | for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ ) |
---|
1568 | { |
---|
1569 | UInt uiBlkPos = scan[ uiScanPosLast ]; |
---|
1570 | if( uiBlkPosLast == uiBlkPos ) |
---|
1571 | { |
---|
1572 | break; |
---|
1573 | } |
---|
1574 | } |
---|
1575 | |
---|
1576 | ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, eTType ); |
---|
1577 | ContextModel * const baseCtx = (eTType==TEXT_LUMA) ? m_cCUSigSCModel.get( 0, 0 ) : m_cCUSigSCModel.get( 0, 0 ) + NUM_SIG_FLAG_CTX_LUMA; |
---|
1578 | |
---|
1579 | const Int iLastScanSet = uiScanPosLast >> LOG2_SCAN_SET_SIZE; |
---|
1580 | UInt c1 = 1; |
---|
1581 | UInt uiGoRiceParam = 0; |
---|
1582 | |
---|
1583 | Bool beValid; |
---|
1584 | if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) |
---|
1585 | { |
---|
1586 | beValid = false; |
---|
1587 | } |
---|
1588 | else |
---|
1589 | { |
---|
1590 | beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
1591 | } |
---|
1592 | UInt absSum = 0; |
---|
1593 | |
---|
1594 | UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ]; |
---|
1595 | ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); |
---|
1596 | const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1); |
---|
1597 | const UInt * scanCG; |
---|
1598 | { |
---|
1599 | scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ]; |
---|
1600 | if( uiLog2BlockSize == 3 ) |
---|
1601 | { |
---|
1602 | scanCG = g_sigLastScan8x8[ uiScanIdx ]; |
---|
1603 | } |
---|
1604 | else if( uiLog2BlockSize == 5 ) |
---|
1605 | { |
---|
1606 | scanCG = g_sigLastScanCG32x32; |
---|
1607 | } |
---|
1608 | } |
---|
1609 | Int iScanPosSig = (Int) uiScanPosLast; |
---|
1610 | for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- ) |
---|
1611 | { |
---|
1612 | Int iSubPos = iSubSet << LOG2_SCAN_SET_SIZE; |
---|
1613 | uiGoRiceParam = 0; |
---|
1614 | Int numNonZero = 0; |
---|
1615 | |
---|
1616 | Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE; |
---|
1617 | |
---|
1618 | Int pos[SCAN_SET_SIZE]; |
---|
1619 | if( iScanPosSig == (Int) uiScanPosLast ) |
---|
1620 | { |
---|
1621 | lastNZPosInCG = iScanPosSig; |
---|
1622 | firstNZPosInCG = iScanPosSig; |
---|
1623 | iScanPosSig--; |
---|
1624 | pos[ numNonZero ] = uiBlkPosLast; |
---|
1625 | numNonZero = 1; |
---|
1626 | } |
---|
1627 | |
---|
1628 | // decode significant_coeffgroup_flag |
---|
1629 | Int iCGBlkPos = scanCG[ iSubSet ]; |
---|
1630 | Int iCGPosY = iCGBlkPos / uiNumBlkSide; |
---|
1631 | Int iCGPosX = iCGBlkPos - (iCGPosY * uiNumBlkSide); |
---|
1632 | if( iSubSet == iLastScanSet || iSubSet == 0) |
---|
1633 | { |
---|
1634 | uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; |
---|
1635 | } |
---|
1636 | else |
---|
1637 | { |
---|
1638 | UInt uiSigCoeffGroup; |
---|
1639 | UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); |
---|
1640 | m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] ); |
---|
1641 | uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup; |
---|
1642 | } |
---|
1643 | |
---|
1644 | // decode significant_coeff_flag |
---|
1645 | Int patternSigCtx = TComTrQuant::calcPatternSigCtx( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); |
---|
1646 | UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig; |
---|
1647 | for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) |
---|
1648 | { |
---|
1649 | uiBlkPos = scan[ iScanPosSig ]; |
---|
1650 | uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
1651 | uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
1652 | uiSig = 0; |
---|
1653 | |
---|
1654 | if( uiSigCoeffGroupFlag[ iCGBlkPos ] ) |
---|
1655 | { |
---|
1656 | if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) |
---|
1657 | { |
---|
1658 | uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, uiLog2BlockSize, eTType ); |
---|
1659 | m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] ); |
---|
1660 | } |
---|
1661 | else |
---|
1662 | { |
---|
1663 | uiSig = 1; |
---|
1664 | } |
---|
1665 | } |
---|
1666 | pcCoef[ uiBlkPos ] = uiSig; |
---|
1667 | if( uiSig ) |
---|
1668 | { |
---|
1669 | pos[ numNonZero ] = uiBlkPos; |
---|
1670 | numNonZero ++; |
---|
1671 | if( lastNZPosInCG == -1 ) |
---|
1672 | { |
---|
1673 | lastNZPosInCG = iScanPosSig; |
---|
1674 | } |
---|
1675 | firstNZPosInCG = iScanPosSig; |
---|
1676 | } |
---|
1677 | } |
---|
1678 | |
---|
1679 | if( numNonZero ) |
---|
1680 | { |
---|
1681 | Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= SBH_THRESHOLD ); |
---|
1682 | absSum = 0; |
---|
1683 | UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0; |
---|
1684 | UInt uiBin; |
---|
1685 | if( c1 == 0 ) |
---|
1686 | { |
---|
1687 | uiCtxSet++; |
---|
1688 | } |
---|
1689 | c1 = 1; |
---|
1690 | ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet; |
---|
1691 | Int absCoeff[SCAN_SET_SIZE]; |
---|
1692 | |
---|
1693 | for ( Int i = 0; i < numNonZero; i++) absCoeff[i] = 1; |
---|
1694 | Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); |
---|
1695 | Int firstC2FlagIdx = -1; |
---|
1696 | |
---|
1697 | for( Int idx = 0; idx < numC1Flag; idx++ ) |
---|
1698 | { |
---|
1699 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] ); |
---|
1700 | if( uiBin == 1 ) |
---|
1701 | { |
---|
1702 | c1 = 0; |
---|
1703 | if (firstC2FlagIdx == -1) |
---|
1704 | { |
---|
1705 | firstC2FlagIdx = idx; |
---|
1706 | } |
---|
1707 | } |
---|
1708 | else if( (c1 < 3) && (c1 > 0) ) |
---|
1709 | { |
---|
1710 | c1++; |
---|
1711 | } |
---|
1712 | absCoeff[ idx ] = uiBin + 1; |
---|
1713 | } |
---|
1714 | |
---|
1715 | if (c1 == 0) |
---|
1716 | { |
---|
1717 | baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet; |
---|
1718 | if ( firstC2FlagIdx != -1) |
---|
1719 | { |
---|
1720 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] ); |
---|
1721 | absCoeff[ firstC2FlagIdx ] = uiBin + 2; |
---|
1722 | } |
---|
1723 | } |
---|
1724 | |
---|
1725 | UInt coeffSigns; |
---|
1726 | if ( signHidden && beValid ) |
---|
1727 | { |
---|
1728 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 ); |
---|
1729 | coeffSigns <<= 32 - (numNonZero-1); |
---|
1730 | } |
---|
1731 | else |
---|
1732 | { |
---|
1733 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero ); |
---|
1734 | coeffSigns <<= 32 - numNonZero; |
---|
1735 | } |
---|
1736 | |
---|
1737 | Int iFirstCoeff2 = 1; |
---|
1738 | if (c1 == 0 || numNonZero > C1FLAG_NUMBER) |
---|
1739 | { |
---|
1740 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
1741 | { |
---|
1742 | UInt baseLevel = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2) : 1; |
---|
1743 | |
---|
1744 | if( absCoeff[ idx ] == baseLevel) |
---|
1745 | { |
---|
1746 | UInt uiLevel; |
---|
1747 | xReadCoefRemainExGolomb( uiLevel, uiGoRiceParam ); |
---|
1748 | absCoeff[ idx ] = uiLevel + baseLevel; |
---|
1749 | if(absCoeff[idx]>3*(1<<uiGoRiceParam)) |
---|
1750 | { |
---|
1751 | uiGoRiceParam = min<UInt>(uiGoRiceParam+ 1, 4); |
---|
1752 | } |
---|
1753 | } |
---|
1754 | |
---|
1755 | if(absCoeff[ idx ] >= 2) |
---|
1756 | { |
---|
1757 | iFirstCoeff2 = 0; |
---|
1758 | } |
---|
1759 | } |
---|
1760 | } |
---|
1761 | |
---|
1762 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
1763 | { |
---|
1764 | Int blkPos = pos[ idx ]; |
---|
1765 | // Signs applied later. |
---|
1766 | pcCoef[ blkPos ] = absCoeff[ idx ]; |
---|
1767 | absSum += absCoeff[ idx ]; |
---|
1768 | |
---|
1769 | if ( idx == numNonZero-1 && signHidden && beValid ) |
---|
1770 | { |
---|
1771 | // Infer sign of 1st element. |
---|
1772 | if (absSum&0x1) |
---|
1773 | { |
---|
1774 | pcCoef[ blkPos ] = -pcCoef[ blkPos ]; |
---|
1775 | } |
---|
1776 | } |
---|
1777 | else |
---|
1778 | { |
---|
1779 | Int sign = static_cast<Int>( coeffSigns ) >> 31; |
---|
1780 | pcCoef[ blkPos ] = ( pcCoef[ blkPos ] ^ sign ) - sign; |
---|
1781 | coeffSigns <<= 1; |
---|
1782 | } |
---|
1783 | } |
---|
1784 | } |
---|
1785 | } |
---|
1786 | |
---|
1787 | return; |
---|
1788 | } |
---|
1789 | |
---|
1790 | |
---|
1791 | Void TDecSbac::parseSaoMaxUvlc ( UInt& val, UInt maxSymbol ) |
---|
1792 | { |
---|
1793 | if (maxSymbol == 0) |
---|
1794 | { |
---|
1795 | val = 0; |
---|
1796 | return; |
---|
1797 | } |
---|
1798 | |
---|
1799 | UInt code; |
---|
1800 | Int i; |
---|
1801 | m_pcTDecBinIf->decodeBinEP( code ); |
---|
1802 | if ( code == 0 ) |
---|
1803 | { |
---|
1804 | val = 0; |
---|
1805 | return; |
---|
1806 | } |
---|
1807 | |
---|
1808 | i=1; |
---|
1809 | while (1) |
---|
1810 | { |
---|
1811 | m_pcTDecBinIf->decodeBinEP( code ); |
---|
1812 | if ( code == 0 ) |
---|
1813 | { |
---|
1814 | break; |
---|
1815 | } |
---|
1816 | i++; |
---|
1817 | if (i == maxSymbol) |
---|
1818 | { |
---|
1819 | break; |
---|
1820 | } |
---|
1821 | } |
---|
1822 | |
---|
1823 | val = i; |
---|
1824 | } |
---|
1825 | Void TDecSbac::parseSaoUflc (UInt uiLength, UInt& riVal) |
---|
1826 | { |
---|
1827 | m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength ); |
---|
1828 | } |
---|
1829 | Void TDecSbac::parseSaoMerge (UInt& ruiVal) |
---|
1830 | { |
---|
1831 | UInt uiCode; |
---|
1832 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) ); |
---|
1833 | ruiVal = (Int)uiCode; |
---|
1834 | } |
---|
1835 | Void TDecSbac::parseSaoTypeIdx (UInt& ruiVal) |
---|
1836 | { |
---|
1837 | UInt uiCode; |
---|
1838 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); |
---|
1839 | if (uiCode == 0) |
---|
1840 | { |
---|
1841 | ruiVal = 0; |
---|
1842 | } |
---|
1843 | else |
---|
1844 | { |
---|
1845 | m_pcTDecBinIf->decodeBinEP( uiCode ); |
---|
1846 | if (uiCode == 0) |
---|
1847 | { |
---|
1848 | ruiVal = 1; |
---|
1849 | } |
---|
1850 | else |
---|
1851 | { |
---|
1852 | ruiVal = 2; |
---|
1853 | } |
---|
1854 | } |
---|
1855 | } |
---|
1856 | |
---|
1857 | Void TDecSbac::parseSaoSign(UInt& val) |
---|
1858 | { |
---|
1859 | m_pcTDecBinIf->decodeBinEP ( val ); |
---|
1860 | } |
---|
1861 | |
---|
1862 | Void TDecSbac::parseSAOBlkParam (SAOBlkParam& saoBlkParam |
---|
1863 | , Bool* sliceEnabled |
---|
1864 | , Bool leftMergeAvail |
---|
1865 | , Bool aboveMergeAvail |
---|
1866 | ) |
---|
1867 | { |
---|
1868 | UInt uiSymbol; |
---|
1869 | |
---|
1870 | Bool isLeftMerge = false; |
---|
1871 | Bool isAboveMerge= false; |
---|
1872 | |
---|
1873 | if(leftMergeAvail) |
---|
1874 | { |
---|
1875 | parseSaoMerge(uiSymbol); //sao_merge_left_flag |
---|
1876 | isLeftMerge = (uiSymbol?true:false); |
---|
1877 | } |
---|
1878 | |
---|
1879 | if( aboveMergeAvail && !isLeftMerge) |
---|
1880 | { |
---|
1881 | parseSaoMerge(uiSymbol); //sao_merge_up_flag |
---|
1882 | isAboveMerge = (uiSymbol?true:false); |
---|
1883 | } |
---|
1884 | |
---|
1885 | if(isLeftMerge || isAboveMerge) //merge mode |
---|
1886 | { |
---|
1887 | saoBlkParam[SAO_Y].modeIdc = saoBlkParam[SAO_Cb].modeIdc = saoBlkParam[SAO_Cr].modeIdc = SAO_MODE_MERGE; |
---|
1888 | saoBlkParam[SAO_Y].typeIdc = saoBlkParam[SAO_Cb].typeIdc = saoBlkParam[SAO_Cr].typeIdc = (isLeftMerge)?SAO_MERGE_LEFT:SAO_MERGE_ABOVE; |
---|
1889 | } |
---|
1890 | else //new or off mode |
---|
1891 | { |
---|
1892 | for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) |
---|
1893 | { |
---|
1894 | SAOOffset& ctbParam = saoBlkParam[compIdx]; |
---|
1895 | |
---|
1896 | if(!sliceEnabled[compIdx]) |
---|
1897 | { |
---|
1898 | //off |
---|
1899 | ctbParam.modeIdc = SAO_MODE_OFF; |
---|
1900 | continue; |
---|
1901 | } |
---|
1902 | |
---|
1903 | //type |
---|
1904 | if(compIdx == SAO_Y || compIdx == SAO_Cb) |
---|
1905 | { |
---|
1906 | parseSaoTypeIdx(uiSymbol); //sao_type_idx_luma or sao_type_idx_chroma |
---|
1907 | |
---|
1908 | assert(uiSymbol ==0 || uiSymbol ==1 || uiSymbol ==2); |
---|
1909 | |
---|
1910 | if(uiSymbol ==0) //OFF |
---|
1911 | { |
---|
1912 | ctbParam.modeIdc = SAO_MODE_OFF; |
---|
1913 | } |
---|
1914 | else if(uiSymbol == 1) //BO |
---|
1915 | { |
---|
1916 | ctbParam.modeIdc = SAO_MODE_NEW; |
---|
1917 | ctbParam.typeIdc = SAO_TYPE_START_BO; |
---|
1918 | } |
---|
1919 | else //2, EO |
---|
1920 | { |
---|
1921 | ctbParam.modeIdc = SAO_MODE_NEW; |
---|
1922 | ctbParam.typeIdc = SAO_TYPE_START_EO; |
---|
1923 | } |
---|
1924 | |
---|
1925 | } |
---|
1926 | else //Cr, follow Cb SAO type |
---|
1927 | { |
---|
1928 | ctbParam.modeIdc = saoBlkParam[SAO_Cb].modeIdc; |
---|
1929 | ctbParam.typeIdc = saoBlkParam[SAO_Cb].typeIdc; |
---|
1930 | } |
---|
1931 | |
---|
1932 | if(ctbParam.modeIdc == SAO_MODE_NEW) |
---|
1933 | { |
---|
1934 | Int offset[4]; |
---|
1935 | for(Int i=0; i< 4; i++) |
---|
1936 | { |
---|
1937 | parseSaoMaxUvlc(uiSymbol, g_saoMaxOffsetQVal[compIdx] ); //sao_offset_abs |
---|
1938 | offset[i] = (Int)uiSymbol; |
---|
1939 | } |
---|
1940 | |
---|
1941 | if(ctbParam.typeIdc == SAO_TYPE_START_BO) |
---|
1942 | { |
---|
1943 | for(Int i=0; i< 4; i++) |
---|
1944 | { |
---|
1945 | if(offset[i] != 0) |
---|
1946 | { |
---|
1947 | parseSaoSign(uiSymbol); //sao_offset_sign |
---|
1948 | if(uiSymbol) |
---|
1949 | { |
---|
1950 | offset[i] = -offset[i]; |
---|
1951 | } |
---|
1952 | } |
---|
1953 | } |
---|
1954 | parseSaoUflc(NUM_SAO_BO_CLASSES_LOG2, uiSymbol ); //sao_band_position |
---|
1955 | ctbParam.typeAuxInfo = uiSymbol; |
---|
1956 | |
---|
1957 | for(Int i=0; i<4; i++) |
---|
1958 | { |
---|
1959 | ctbParam.offset[(ctbParam.typeAuxInfo+i)%MAX_NUM_SAO_CLASSES] = offset[i]; |
---|
1960 | } |
---|
1961 | |
---|
1962 | } |
---|
1963 | else //EO |
---|
1964 | { |
---|
1965 | ctbParam.typeAuxInfo = 0; |
---|
1966 | |
---|
1967 | if(compIdx == SAO_Y || compIdx == SAO_Cb) |
---|
1968 | { |
---|
1969 | parseSaoUflc(NUM_SAO_EO_TYPES_LOG2, uiSymbol ); //sao_eo_class_luma or sao_eo_class_chroma |
---|
1970 | ctbParam.typeIdc += uiSymbol; |
---|
1971 | } |
---|
1972 | else |
---|
1973 | { |
---|
1974 | ctbParam.typeIdc = saoBlkParam[SAO_Cb].typeIdc; |
---|
1975 | } |
---|
1976 | ctbParam.offset[SAO_CLASS_EO_FULL_VALLEY] = offset[0]; |
---|
1977 | ctbParam.offset[SAO_CLASS_EO_HALF_VALLEY] = offset[1]; |
---|
1978 | ctbParam.offset[SAO_CLASS_EO_PLAIN ] = 0; |
---|
1979 | ctbParam.offset[SAO_CLASS_EO_HALF_PEAK ] = -offset[2]; |
---|
1980 | ctbParam.offset[SAO_CLASS_EO_FULL_PEAK ] = -offset[3]; |
---|
1981 | } |
---|
1982 | } |
---|
1983 | } |
---|
1984 | } |
---|
1985 | } |
---|
1986 | |
---|
1987 | /** |
---|
1988 | - Initialize our contexts from the nominated source. |
---|
1989 | . |
---|
1990 | \param pSrc Contexts to be copied. |
---|
1991 | */ |
---|
1992 | Void TDecSbac::xCopyContextsFrom( TDecSbac* pSrc ) |
---|
1993 | { |
---|
1994 | memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0])); |
---|
1995 | } |
---|
1996 | |
---|
1997 | Void TDecSbac::xCopyFrom( TDecSbac* pSrc ) |
---|
1998 | { |
---|
1999 | m_pcTDecBinIf->copyState( pSrc->m_pcTDecBinIf ); |
---|
2000 | |
---|
2001 | m_uiLastQp = pSrc->m_uiLastQp; |
---|
2002 | xCopyContextsFrom( pSrc ); |
---|
2003 | |
---|
2004 | } |
---|
2005 | |
---|
2006 | Void TDecSbac::load ( TDecSbac* pScr ) |
---|
2007 | { |
---|
2008 | xCopyFrom(pScr); |
---|
2009 | } |
---|
2010 | |
---|
2011 | Void TDecSbac::loadContexts ( TDecSbac* pScr ) |
---|
2012 | { |
---|
2013 | xCopyContextsFrom(pScr); |
---|
2014 | } |
---|
2015 | |
---|
2016 | #if H_3D_ARP |
---|
2017 | Void TDecSbac::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2018 | { |
---|
2019 | UInt uiMaxW = pcCU->getSlice()->getARPStepNum() - 1; |
---|
2020 | UInt uiW = 0; |
---|
2021 | UInt uiOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx); |
---|
2022 | UInt uiCode = 0; |
---|
2023 | |
---|
2024 | assert ( uiMaxW > 0 ); |
---|
2025 | |
---|
2026 | m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 0 + uiOffset ) ); |
---|
2027 | |
---|
2028 | uiW = uiCode; |
---|
2029 | if( 1 == uiW ) |
---|
2030 | { |
---|
2031 | m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 2 ) ); |
---|
2032 | uiW += ( 1 == uiCode ? 1 : 0 ); |
---|
2033 | } |
---|
2034 | #if H_MV_ENC_DEC_TRAC |
---|
2035 | DTRACE_CU("iv_res_pred_weight_idx", uiW ) |
---|
2036 | #endif |
---|
2037 | pcCU->setARPWSubParts( ( UChar )( uiW ) , uiAbsPartIdx, uiDepth ); |
---|
2038 | } |
---|
2039 | #endif |
---|
2040 | |
---|
2041 | #if H_3D_IC |
---|
2042 | /** parse illumination compensation flag |
---|
2043 | * \param pcCU |
---|
2044 | * \param uiAbsPartIdx |
---|
2045 | * \param uiDepth |
---|
2046 | * \returns Void |
---|
2047 | */ |
---|
2048 | Void TDecSbac::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2049 | { |
---|
2050 | UInt uiSymbol = 0; |
---|
2051 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, 0 ) ); |
---|
2052 | #if !H_MV_ENC_DEC_TRAC |
---|
2053 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
2054 | DTRACE_CABAC_T( "\tICFlag" ); |
---|
2055 | DTRACE_CABAC_T( "\tuiCtxIC: "); |
---|
2056 | DTRACE_CABAC_V( uiCtxIC ); |
---|
2057 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
2058 | DTRACE_CABAC_V( uiSymbol ); |
---|
2059 | DTRACE_CABAC_T( "\n"); |
---|
2060 | #else |
---|
2061 | DTRACE_CU("ic_flag", uiSymbol) |
---|
2062 | #endif |
---|
2063 | |
---|
2064 | pcCU->setICFlagSubParts( uiSymbol ? true : false , uiAbsPartIdx, 0, uiDepth ); |
---|
2065 | } |
---|
2066 | #endif |
---|
2067 | |
---|
2068 | #if H_3D_INTER_SDC |
---|
2069 | Void TDecSbac::parseDeltaDC( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
2070 | { |
---|
2071 | if( ! ( pcCU->getSDCFlag( absPartIdx ) || ( pcCU->isIntra( absPartIdx ) && getDimType( pcCU->getLumaIntraDir( absPartIdx ) ) < DIM_NUM_TYPE ) ) ) |
---|
2072 | { |
---|
2073 | assert( 0 ); |
---|
2074 | } |
---|
2075 | |
---|
2076 | UInt symbol = 0; |
---|
2077 | UInt uiNumSegments = 0; |
---|
2078 | |
---|
2079 | if( pcCU->isIntra( absPartIdx ) ) |
---|
2080 | { |
---|
2081 | UInt dir = pcCU->getLumaIntraDir( absPartIdx ); |
---|
2082 | uiNumSegments = isDimMode( dir ) ? 2 : 1; |
---|
2083 | #if MTK_DELTA_DC_FLAG_ONE_CONTEXT_H0084_H0100_H0113 |
---|
2084 | m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get( 0, 0, 0 ) ); |
---|
2085 | #else |
---|
2086 | m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get( 0, 0, uiNumSegments-1 ) ); |
---|
2087 | #endif |
---|
2088 | if( pcCU->getSDCFlag( absPartIdx ) ) |
---|
2089 | { |
---|
2090 | assert( pcCU->getPartitionSize( absPartIdx ) == SIZE_2Nx2N ); |
---|
2091 | pcCU->setTrIdxSubParts( 0, absPartIdx, depth ); |
---|
2092 | pcCU->setCbfSubParts( 1, 1, 1, absPartIdx, depth ); |
---|
2093 | } |
---|
2094 | else |
---|
2095 | { |
---|
2096 | pcCU->setLumaIntraDirSubParts( dir + symbol, absPartIdx, depth ); |
---|
2097 | } |
---|
2098 | } |
---|
2099 | else |
---|
2100 | { |
---|
2101 | uiNumSegments = 1; |
---|
2102 | symbol = 1; |
---|
2103 | } |
---|
2104 | |
---|
2105 | |
---|
2106 | for( UInt segment = 0; segment < uiNumSegments; segment++ ) |
---|
2107 | { |
---|
2108 | Pel valDeltaDC = 0; |
---|
2109 | if( symbol ) |
---|
2110 | { |
---|
2111 | xParseDimDeltaDC( valDeltaDC, uiNumSegments ); |
---|
2112 | } |
---|
2113 | |
---|
2114 | if( pcCU->isIntra( absPartIdx ) ) |
---|
2115 | { |
---|
2116 | UInt dir = pcCU->getLumaIntraDir( absPartIdx ); |
---|
2117 | |
---|
2118 | if( pcCU->getSDCFlag( absPartIdx ) ) |
---|
2119 | { |
---|
2120 | pcCU->setSDCSegmentDCOffset( valDeltaDC, segment, absPartIdx ); |
---|
2121 | } |
---|
2122 | else |
---|
2123 | { |
---|
2124 | pcCU->setDimDeltaDC( getDimType( dir ), segment, absPartIdx, valDeltaDC ); |
---|
2125 | } |
---|
2126 | } |
---|
2127 | else |
---|
2128 | { |
---|
2129 | pcCU->setSDCSegmentDCOffset( valDeltaDC, segment, absPartIdx ); |
---|
2130 | } |
---|
2131 | } |
---|
2132 | } |
---|
2133 | |
---|
2134 | Void TDecSbac::parseSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2135 | { |
---|
2136 | UInt uiSymbol = 0; |
---|
2137 | UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx ); |
---|
2138 | |
---|
2139 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) ); |
---|
2140 | |
---|
2141 | if( uiSymbol ) |
---|
2142 | { |
---|
2143 | pcCU->setSDCFlagSubParts( true, uiAbsPartIdx, uiDepth ); |
---|
2144 | pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth ); |
---|
2145 | pcCU->setCbfSubParts( 1, 1, 1, uiAbsPartIdx, uiDepth ); |
---|
2146 | } |
---|
2147 | else |
---|
2148 | { |
---|
2149 | pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth ); |
---|
2150 | } |
---|
2151 | } |
---|
2152 | |
---|
2153 | #endif |
---|
2154 | |
---|
2155 | #if H_3D_DBBP |
---|
2156 | Void TDecSbac::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2157 | { |
---|
2158 | #if !MTK_DBBP_SIGNALING_H0094 |
---|
2159 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
2160 | #endif |
---|
2161 | AOF( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) ); |
---|
2162 | AOF( !pcCU->getSlice()->getIsDepth() ); |
---|
2163 | #if !MTK_DBBP_SIGNALING_H0094 |
---|
2164 | AOF( ePartSize == RWTH_DBBP_PACK_MODE ); |
---|
2165 | #endif |
---|
2166 | |
---|
2167 | UInt uiSymbol = 0; |
---|
2168 | |
---|
2169 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDBBPFlagSCModel.get( 0, 0, 0 ) ); |
---|
2170 | |
---|
2171 | if( uiSymbol ) |
---|
2172 | { |
---|
2173 | pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx, 0, uiDepth); |
---|
2174 | #if MTK_DIS_SPBIP8X4_H0205 |
---|
2175 | UInt uiCurrPartNumQ = (pcCU->getPic()->getNumPartInCU() >> (2 * uiDepth)) >> 2; |
---|
2176 | pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx + 2*uiCurrPartNumQ, 1, uiDepth); |
---|
2177 | #endif |
---|
2178 | } |
---|
2179 | } |
---|
2180 | #endif |
---|
2181 | |
---|
2182 | |
---|
2183 | |
---|
2184 | //! \} |
---|