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-2015, 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 | #include "TLibCommon/TComTU.h" |
---|
40 | #include "TLibCommon/TComTrQuant.h" |
---|
41 | |
---|
42 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
43 | #include "TLibCommon/TComCodingStatistics.h" |
---|
44 | // |
---|
45 | #define RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(a) , a |
---|
46 | #else |
---|
47 | #define RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(a) |
---|
48 | #endif |
---|
49 | |
---|
50 | //! \ingroup TLibDecoder |
---|
51 | //! \{ |
---|
52 | |
---|
53 | #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST |
---|
54 | #include "../TLibCommon/Debug.h" |
---|
55 | #endif |
---|
56 | |
---|
57 | |
---|
58 | ////////////////////////////////////////////////////////////////////// |
---|
59 | // Construction/Destruction |
---|
60 | ////////////////////////////////////////////////////////////////////// |
---|
61 | |
---|
62 | TDecSbac::TDecSbac() |
---|
63 | // new structure here |
---|
64 | : m_pcBitstream ( 0 ) |
---|
65 | , m_pcTDecBinIf ( NULL ) |
---|
66 | , m_numContextModels ( 0 ) |
---|
67 | , m_cCUSplitFlagSCModel ( 1, 1, NUM_SPLIT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
68 | , m_cCUSkipFlagSCModel ( 1, 1, NUM_SKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
69 | , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
70 | , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
71 | , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
72 | , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
73 | , m_cCUIntraPredSCModel ( 1, 1, NUM_ADI_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
74 | , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
75 | , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
76 | , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
77 | , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
78 | , m_cCUMvdSCModel ( 1, 1, NUM_MV_RES_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
79 | , m_cCUQtCbfSCModel ( 1, NUM_QT_CBF_CTX_SETS, NUM_QT_CBF_CTX_PER_SET , m_contextModels + m_numContextModels, m_numContextModels) |
---|
80 | , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
81 | , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
82 | , m_cCUSigCoeffGroupSCModel ( 1, 2, NUM_SIG_CG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
83 | , m_cCUSigSCModel ( 1, 1, NUM_SIG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
84 | , m_cCuCtxLastX ( 1, NUM_CTX_LAST_FLAG_SETS, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
85 | , m_cCuCtxLastY ( 1, NUM_CTX_LAST_FLAG_SETS, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
86 | , m_cCUOneSCModel ( 1, 1, NUM_ONE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
87 | , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
88 | , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
89 | , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
90 | , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
91 | , m_cTransformSkipSCModel ( 1, MAX_NUM_CHANNEL_TYPE, NUM_TRANSFORMSKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
92 | , m_CUTransquantBypassFlagSCModel ( 1, 1, NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
93 | , m_explicitRdpcmFlagSCModel ( 1, MAX_NUM_CHANNEL_TYPE, NUM_EXPLICIT_RDPCM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
94 | , m_explicitRdpcmDirSCModel ( 1, MAX_NUM_CHANNEL_TYPE, NUM_EXPLICIT_RDPCM_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
95 | , m_cCrossComponentPredictionSCModel ( 1, 1, NUM_CROSS_COMPONENT_PREDICTION_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
96 | , m_ChromaQpAdjFlagSCModel ( 1, 1, NUM_CHROMA_QP_ADJ_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
97 | , m_ChromaQpAdjIdcSCModel ( 1, 1, NUM_CHROMA_QP_ADJ_IDC_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
98 | { |
---|
99 | assert( m_numContextModels <= MAX_NUM_CTX_MOD ); |
---|
100 | } |
---|
101 | |
---|
102 | TDecSbac::~TDecSbac() |
---|
103 | { |
---|
104 | } |
---|
105 | |
---|
106 | // ==================================================================================================================== |
---|
107 | // Public member functions |
---|
108 | // ==================================================================================================================== |
---|
109 | |
---|
110 | Void TDecSbac::resetEntropy(TComSlice* pSlice) |
---|
111 | { |
---|
112 | SliceType sliceType = pSlice->getSliceType(); |
---|
113 | Int qp = pSlice->getSliceQp(); |
---|
114 | |
---|
115 | if (pSlice->getPPS()->getCabacInitPresentFlag() && pSlice->getCabacInitFlag()) |
---|
116 | { |
---|
117 | switch (sliceType) |
---|
118 | { |
---|
119 | case P_SLICE: // change initialization table to B_SLICE initialization |
---|
120 | sliceType = B_SLICE; |
---|
121 | break; |
---|
122 | case B_SLICE: // change initialization table to P_SLICE initialization |
---|
123 | sliceType = P_SLICE; |
---|
124 | break; |
---|
125 | default : // should not occur |
---|
126 | assert(0); |
---|
127 | break; |
---|
128 | } |
---|
129 | } |
---|
130 | |
---|
131 | m_cCUSplitFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG ); |
---|
132 | m_cCUSkipFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SKIP_FLAG ); |
---|
133 | m_cCUMergeFlagExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
134 | m_cCUMergeIdxExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
135 | m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); |
---|
136 | m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); |
---|
137 | m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
138 | m_cCUChromaPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
139 | m_cCUInterDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_DIR ); |
---|
140 | m_cCUMvdSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVD ); |
---|
141 | m_cCURefPicSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_REF_PIC ); |
---|
142 | m_cCUDeltaQpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DQP ); |
---|
143 | m_cCUQtCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_CBF ); |
---|
144 | m_cCUQtRootCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
145 | m_cCUSigCoeffGroupSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
146 | m_cCUSigSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_FLAG ); |
---|
147 | m_cCuCtxLastX.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
148 | m_cCuCtxLastY.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
149 | m_cCUOneSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ONE_FLAG ); |
---|
150 | m_cCUAbsSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ABS_FLAG ); |
---|
151 | m_cMVPIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVP_IDX ); |
---|
152 | m_cSaoMergeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG ); |
---|
153 | m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
154 | m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
155 | m_cTransformSkipSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); |
---|
156 | m_CUTransquantBypassFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); |
---|
157 | m_explicitRdpcmFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_EXPLICIT_RDPCM_FLAG); |
---|
158 | m_explicitRdpcmDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_EXPLICIT_RDPCM_DIR); |
---|
159 | m_cCrossComponentPredictionSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CROSS_COMPONENT_PREDICTION ); |
---|
160 | m_ChromaQpAdjFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_QP_ADJ_FLAG ); |
---|
161 | m_ChromaQpAdjIdcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_QP_ADJ_IDC ); |
---|
162 | |
---|
163 | for (UInt statisticIndex = 0; statisticIndex < RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS ; statisticIndex++) |
---|
164 | { |
---|
165 | m_golombRiceAdaptationStatistics[statisticIndex] = 0; |
---|
166 | } |
---|
167 | |
---|
168 | m_pcTDecBinIf->start(); |
---|
169 | } |
---|
170 | |
---|
171 | Void TDecSbac::parseTerminatingBit( UInt& ruiBit ) |
---|
172 | { |
---|
173 | m_pcTDecBinIf->decodeBinTrm( ruiBit ); |
---|
174 | if ( ruiBit == 1 ) |
---|
175 | { |
---|
176 | m_pcTDecBinIf->finish(); |
---|
177 | |
---|
178 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
179 | TComCodingStatistics::IncrementStatisticEP(STATS__TRAILING_BITS, m_pcBitstream->readOutTrailingBits(),0); |
---|
180 | #else |
---|
181 | m_pcBitstream->readOutTrailingBits(); |
---|
182 | #endif |
---|
183 | } |
---|
184 | } |
---|
185 | |
---|
186 | Void TDecSbac::parseRemainingBytes( Bool noTrailingBytesExpected ) |
---|
187 | { |
---|
188 | if (noTrailingBytesExpected) |
---|
189 | { |
---|
190 | const UInt numberOfRemainingSubstreamBytes=m_pcBitstream->getNumBitsLeft(); |
---|
191 | assert (numberOfRemainingSubstreamBytes == 0); |
---|
192 | } |
---|
193 | else |
---|
194 | { |
---|
195 | while (m_pcBitstream->getNumBitsLeft()) |
---|
196 | { |
---|
197 | UInt trailingNullByte=m_pcBitstream->readByte(); |
---|
198 | if (trailingNullByte!=0) |
---|
199 | { |
---|
200 | printf("Trailing byte should be 0, but has value %02x\n", trailingNullByte); |
---|
201 | assert(trailingNullByte==0); |
---|
202 | } |
---|
203 | } |
---|
204 | } |
---|
205 | } |
---|
206 | |
---|
207 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
208 | Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol, const class TComCodingStatisticsClassType &whichStat ) |
---|
209 | #else |
---|
210 | Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ) |
---|
211 | #endif |
---|
212 | { |
---|
213 | if (uiMaxSymbol == 0) |
---|
214 | { |
---|
215 | ruiSymbol = 0; |
---|
216 | return; |
---|
217 | } |
---|
218 | |
---|
219 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); |
---|
220 | |
---|
221 | if( ruiSymbol == 0 || uiMaxSymbol == 1 ) |
---|
222 | { |
---|
223 | return; |
---|
224 | } |
---|
225 | |
---|
226 | UInt uiSymbol = 0; |
---|
227 | UInt uiCont; |
---|
228 | |
---|
229 | do |
---|
230 | { |
---|
231 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); |
---|
232 | uiSymbol++; |
---|
233 | } while( uiCont && ( uiSymbol < uiMaxSymbol - 1 ) ); |
---|
234 | |
---|
235 | if( uiCont && ( uiSymbol == uiMaxSymbol - 1 ) ) |
---|
236 | { |
---|
237 | uiSymbol++; |
---|
238 | } |
---|
239 | |
---|
240 | ruiSymbol = uiSymbol; |
---|
241 | } |
---|
242 | |
---|
243 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
244 | Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount, const class TComCodingStatisticsClassType &whichStat ) |
---|
245 | #else |
---|
246 | Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount ) |
---|
247 | #endif |
---|
248 | { |
---|
249 | UInt uiSymbol = 0; |
---|
250 | UInt uiBit = 1; |
---|
251 | |
---|
252 | while( uiBit ) |
---|
253 | { |
---|
254 | m_pcTDecBinIf->decodeBinEP( uiBit RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); |
---|
255 | uiSymbol += uiBit << uiCount++; |
---|
256 | } |
---|
257 | |
---|
258 | if ( --uiCount ) |
---|
259 | { |
---|
260 | UInt bins; |
---|
261 | m_pcTDecBinIf->decodeBinsEP( bins, uiCount RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); |
---|
262 | uiSymbol += bins; |
---|
263 | } |
---|
264 | |
---|
265 | ruiSymbol = uiSymbol; |
---|
266 | } |
---|
267 | |
---|
268 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
269 | Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, const class TComCodingStatisticsClassType &whichStat ) |
---|
270 | #else |
---|
271 | Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ) |
---|
272 | #endif |
---|
273 | { |
---|
274 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); |
---|
275 | |
---|
276 | if( !ruiSymbol ) |
---|
277 | { |
---|
278 | return; |
---|
279 | } |
---|
280 | |
---|
281 | UInt uiSymbol = 0; |
---|
282 | UInt uiCont; |
---|
283 | |
---|
284 | do |
---|
285 | { |
---|
286 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); |
---|
287 | uiSymbol++; |
---|
288 | } while( uiCont ); |
---|
289 | |
---|
290 | ruiSymbol = uiSymbol; |
---|
291 | } |
---|
292 | |
---|
293 | |
---|
294 | /** Parsing of coeff_abs_level_remaing |
---|
295 | * \param rSymbol reference to coeff_abs_level_remaing |
---|
296 | * \param rParam reference to parameter |
---|
297 | * \param useLimitedPrefixLength |
---|
298 | * \param channelType |
---|
299 | */ |
---|
300 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
301 | Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam, const Bool useLimitedPrefixLength, const ChannelType channelType, const class TComCodingStatisticsClassType &whichStat ) |
---|
302 | #else |
---|
303 | Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam, const Bool useLimitedPrefixLength, const ChannelType channelType ) |
---|
304 | #endif |
---|
305 | { |
---|
306 | UInt prefix = 0; |
---|
307 | UInt codeWord = 0; |
---|
308 | |
---|
309 | if (useLimitedPrefixLength) |
---|
310 | { |
---|
311 | const UInt longestPossiblePrefix = (32 - (COEF_REMAIN_BIN_REDUCTION + g_maxTrDynamicRange[channelType])) + COEF_REMAIN_BIN_REDUCTION; |
---|
312 | |
---|
313 | do |
---|
314 | { |
---|
315 | prefix++; |
---|
316 | m_pcTDecBinIf->decodeBinEP( codeWord RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); |
---|
317 | } while((codeWord != 0) && (prefix < longestPossiblePrefix)); |
---|
318 | } |
---|
319 | else |
---|
320 | { |
---|
321 | do |
---|
322 | { |
---|
323 | prefix++; |
---|
324 | m_pcTDecBinIf->decodeBinEP( codeWord RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); |
---|
325 | } while( codeWord); |
---|
326 | } |
---|
327 | |
---|
328 | codeWord = 1 - codeWord; |
---|
329 | prefix -= codeWord; |
---|
330 | codeWord=0; |
---|
331 | |
---|
332 | if (prefix < COEF_REMAIN_BIN_REDUCTION ) |
---|
333 | { |
---|
334 | m_pcTDecBinIf->decodeBinsEP(codeWord,rParam RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); |
---|
335 | rSymbol = (prefix<<rParam) + codeWord; |
---|
336 | } |
---|
337 | else if (useLimitedPrefixLength) |
---|
338 | { |
---|
339 | const UInt maximumPrefixLength = (32 - (COEF_REMAIN_BIN_REDUCTION + g_maxTrDynamicRange[channelType])); |
---|
340 | |
---|
341 | const UInt prefixLength = prefix - COEF_REMAIN_BIN_REDUCTION; |
---|
342 | const UInt suffixLength = (prefixLength == maximumPrefixLength) ? (g_maxTrDynamicRange[channelType] - rParam) : prefixLength; |
---|
343 | |
---|
344 | m_pcTDecBinIf->decodeBinsEP(codeWord, (suffixLength + rParam) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); |
---|
345 | |
---|
346 | rSymbol = codeWord + ((((1 << prefixLength) - 1) + COEF_REMAIN_BIN_REDUCTION) << rParam); |
---|
347 | } |
---|
348 | else |
---|
349 | { |
---|
350 | m_pcTDecBinIf->decodeBinsEP(codeWord,prefix-COEF_REMAIN_BIN_REDUCTION+rParam RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); |
---|
351 | rSymbol = (((1<<(prefix-COEF_REMAIN_BIN_REDUCTION))+COEF_REMAIN_BIN_REDUCTION-1)<<rParam)+codeWord; |
---|
352 | } |
---|
353 | } |
---|
354 | |
---|
355 | |
---|
356 | /** Parse I_PCM information. |
---|
357 | * \param pcCU |
---|
358 | * \param uiAbsPartIdx |
---|
359 | * \param uiDepth |
---|
360 | * \returns Void |
---|
361 | * |
---|
362 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
363 | */ |
---|
364 | Void TDecSbac::parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
365 | { |
---|
366 | UInt uiSymbol; |
---|
367 | |
---|
368 | m_pcTDecBinIf->decodeBinTrm(uiSymbol); |
---|
369 | |
---|
370 | if (uiSymbol == 1) |
---|
371 | { |
---|
372 | Bool bIpcmFlag = true; |
---|
373 | |
---|
374 | pcCU->setPartSizeSubParts ( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
375 | pcCU->setSizeSubParts ( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
376 | pcCU->setTrIdxSubParts ( 0, uiAbsPartIdx, uiDepth ); |
---|
377 | pcCU->setIPCMFlagSubParts ( bIpcmFlag, uiAbsPartIdx, uiDepth ); |
---|
378 | |
---|
379 | const UInt minCoeffSizeY = pcCU->getPic()->getMinCUWidth() * pcCU->getPic()->getMinCUHeight(); |
---|
380 | const UInt offsetY = minCoeffSizeY * uiAbsPartIdx; |
---|
381 | for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
382 | { |
---|
383 | const ComponentID compID = ComponentID(ch); |
---|
384 | const UInt offset = offsetY >> (pcCU->getPic()->getComponentScaleX(compID) + pcCU->getPic()->getComponentScaleY(compID)); |
---|
385 | Pel * pPCMSample = pcCU->getPCMSample(compID) + offset; |
---|
386 | const UInt width = pcCU->getWidth (uiAbsPartIdx) >> pcCU->getPic()->getComponentScaleX(compID); |
---|
387 | const UInt height = pcCU->getHeight(uiAbsPartIdx) >> pcCU->getPic()->getComponentScaleY(compID); |
---|
388 | const UInt sampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID)); |
---|
389 | for (UInt y=0; y<height; y++) |
---|
390 | { |
---|
391 | for (UInt x=0; x<width; x++) |
---|
392 | { |
---|
393 | UInt sample; |
---|
394 | m_pcTDecBinIf->xReadPCMCode(sampleBits, sample); |
---|
395 | pPCMSample[x] = sample; |
---|
396 | } |
---|
397 | pPCMSample += width; |
---|
398 | } |
---|
399 | } |
---|
400 | |
---|
401 | m_pcTDecBinIf->start(); |
---|
402 | } |
---|
403 | } |
---|
404 | |
---|
405 | Void TDecSbac::parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
406 | { |
---|
407 | UInt uiSymbol; |
---|
408 | m_pcTDecBinIf->decodeBin( uiSymbol, m_CUTransquantBypassFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__TQ_BYPASS_FLAG) ); |
---|
409 | pcCU->setCUTransquantBypassSubParts(uiSymbol ? true : false, uiAbsPartIdx, uiDepth); |
---|
410 | } |
---|
411 | |
---|
412 | /** parse skip flag |
---|
413 | * \param pcCU |
---|
414 | * \param uiAbsPartIdx |
---|
415 | * \param uiDepth |
---|
416 | * \returns Void |
---|
417 | */ |
---|
418 | Void TDecSbac::parseSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
419 | { |
---|
420 | if( pcCU->getSlice()->isIntra() ) |
---|
421 | { |
---|
422 | return; |
---|
423 | } |
---|
424 | |
---|
425 | UInt uiSymbol = 0; |
---|
426 | UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx ); |
---|
427 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SKIP_FLAG) ); |
---|
428 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
429 | DTRACE_CABAC_T( "\tSkipFlag" ); |
---|
430 | DTRACE_CABAC_T( "\tuiCtxSkip: "); |
---|
431 | DTRACE_CABAC_V( uiCtxSkip ); |
---|
432 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
433 | DTRACE_CABAC_V( uiSymbol ); |
---|
434 | DTRACE_CABAC_T( "\n"); |
---|
435 | |
---|
436 | if( uiSymbol ) |
---|
437 | { |
---|
438 | pcCU->setSkipFlagSubParts( true, uiAbsPartIdx, uiDepth ); |
---|
439 | pcCU->setPredModeSubParts( MODE_INTER, uiAbsPartIdx, uiDepth ); |
---|
440 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
441 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
442 | pcCU->setMergeFlagSubParts( true , uiAbsPartIdx, 0, uiDepth ); |
---|
443 | } |
---|
444 | } |
---|
445 | |
---|
446 | |
---|
447 | /** parse merge flag |
---|
448 | * \param pcCU |
---|
449 | * \param uiAbsPartIdx |
---|
450 | * \param uiDepth |
---|
451 | * \param uiPUIdx |
---|
452 | * \returns Void |
---|
453 | */ |
---|
454 | Void TDecSbac::parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
455 | { |
---|
456 | UInt uiSymbol; |
---|
457 | m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MERGE_FLAG) ); |
---|
458 | pcCU->setMergeFlagSubParts( uiSymbol ? true : false, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
459 | |
---|
460 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
461 | DTRACE_CABAC_T( "\tMergeFlag: " ); |
---|
462 | DTRACE_CABAC_V( uiSymbol ); |
---|
463 | DTRACE_CABAC_T( "\tAddress: " ); |
---|
464 | DTRACE_CABAC_V( pcCU->getCtuRsAddr() ); |
---|
465 | DTRACE_CABAC_T( "\tuiAbsPartIdx: " ); |
---|
466 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
467 | DTRACE_CABAC_T( "\n" ); |
---|
468 | } |
---|
469 | |
---|
470 | Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex ) |
---|
471 | { |
---|
472 | UInt uiUnaryIdx = 0; |
---|
473 | UInt uiNumCand = pcCU->getSlice()->getMaxNumMergeCand(); |
---|
474 | if ( uiNumCand > 1 ) |
---|
475 | { |
---|
476 | for( ; uiUnaryIdx < uiNumCand - 1; ++uiUnaryIdx ) |
---|
477 | { |
---|
478 | UInt uiSymbol = 0; |
---|
479 | if ( uiUnaryIdx==0 ) |
---|
480 | { |
---|
481 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MERGE_INDEX) ); |
---|
482 | } |
---|
483 | else |
---|
484 | { |
---|
485 | m_pcTDecBinIf->decodeBinEP( uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MERGE_INDEX) ); |
---|
486 | } |
---|
487 | if( uiSymbol == 0 ) |
---|
488 | { |
---|
489 | break; |
---|
490 | } |
---|
491 | } |
---|
492 | } |
---|
493 | ruiMergeIndex = uiUnaryIdx; |
---|
494 | |
---|
495 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
496 | DTRACE_CABAC_T( "\tparseMergeIndex()" ) |
---|
497 | DTRACE_CABAC_T( "\tuiMRGIdx= " ) |
---|
498 | DTRACE_CABAC_V( ruiMergeIndex ) |
---|
499 | DTRACE_CABAC_T( "\n" ) |
---|
500 | } |
---|
501 | |
---|
502 | Void TDecSbac::parseMVPIdx ( Int& riMVPIdx ) |
---|
503 | { |
---|
504 | UInt uiSymbol; |
---|
505 | xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, AMVP_MAX_NUM_CANDS-1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVP_IDX) ); |
---|
506 | riMVPIdx = uiSymbol; |
---|
507 | } |
---|
508 | |
---|
509 | Void TDecSbac::parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
510 | { |
---|
511 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
512 | { |
---|
513 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
514 | return; |
---|
515 | } |
---|
516 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
517 | const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__SPLIT_FLAG, g_aucConvertToBit[g_uiMaxCUWidth>>uiDepth]+2); |
---|
518 | #endif |
---|
519 | |
---|
520 | UInt uiSymbol; |
---|
521 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
522 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
523 | DTRACE_CABAC_T( "\tSplitFlag\n" ) |
---|
524 | pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx ); |
---|
525 | |
---|
526 | return; |
---|
527 | } |
---|
528 | |
---|
529 | /** parse partition size |
---|
530 | * \param pcCU |
---|
531 | * \param uiAbsPartIdx |
---|
532 | * \param uiDepth |
---|
533 | * \returns Void |
---|
534 | */ |
---|
535 | Void TDecSbac::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
536 | { |
---|
537 | UInt uiSymbol, uiMode = 0; |
---|
538 | PartSize eMode; |
---|
539 | |
---|
540 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
541 | const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__PART_SIZE, g_aucConvertToBit[g_uiMaxCUWidth>>uiDepth]+2); |
---|
542 | #endif |
---|
543 | |
---|
544 | if ( pcCU->isIntra( uiAbsPartIdx ) ) |
---|
545 | { |
---|
546 | uiSymbol = 1; |
---|
547 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
548 | { |
---|
549 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
550 | } |
---|
551 | eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; |
---|
552 | UInt uiTrLevel = 0; |
---|
553 | UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; |
---|
554 | UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; |
---|
555 | uiTrLevel = uiWidthInBit >= uiTrSizeInBit ? uiWidthInBit - uiTrSizeInBit : 0; |
---|
556 | if( eMode == SIZE_NxN ) |
---|
557 | { |
---|
558 | pcCU->setTrIdxSubParts( 1+uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
559 | } |
---|
560 | else |
---|
561 | { |
---|
562 | pcCU->setTrIdxSubParts( uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
563 | } |
---|
564 | } |
---|
565 | else |
---|
566 | { |
---|
567 | UInt uiMaxNumBits = 2; |
---|
568 | |
---|
569 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) ) |
---|
570 | { |
---|
571 | uiMaxNumBits ++; |
---|
572 | } |
---|
573 | |
---|
574 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
575 | { |
---|
576 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
577 | if ( uiSymbol ) |
---|
578 | { |
---|
579 | break; |
---|
580 | } |
---|
581 | uiMode++; |
---|
582 | } |
---|
583 | eMode = (PartSize) uiMode; |
---|
584 | if ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < g_uiMaxCUDepth-g_uiAddCUDepth ) |
---|
585 | { |
---|
586 | if (eMode == SIZE_2NxN) |
---|
587 | { |
---|
588 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype)); |
---|
589 | if (uiSymbol == 0) |
---|
590 | { |
---|
591 | m_pcTDecBinIf->decodeBinEP(uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
592 | eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); |
---|
593 | } |
---|
594 | } |
---|
595 | else if (eMode == SIZE_Nx2N) |
---|
596 | { |
---|
597 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
598 | if (uiSymbol == 0) |
---|
599 | { |
---|
600 | m_pcTDecBinIf->decodeBinEP(uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
601 | eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); |
---|
602 | } |
---|
603 | } |
---|
604 | } |
---|
605 | } |
---|
606 | pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth ); |
---|
607 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
608 | } |
---|
609 | |
---|
610 | |
---|
611 | /** parse prediction mode |
---|
612 | * \param pcCU |
---|
613 | * \param uiAbsPartIdx |
---|
614 | * \param uiDepth |
---|
615 | * \returns Void |
---|
616 | */ |
---|
617 | Void TDecSbac::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
618 | { |
---|
619 | if( pcCU->getSlice()->isIntra() ) |
---|
620 | { |
---|
621 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
622 | return; |
---|
623 | } |
---|
624 | |
---|
625 | UInt uiSymbol; |
---|
626 | Int iPredMode = MODE_INTER; |
---|
627 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__PRED_MODE) ); |
---|
628 | iPredMode += uiSymbol; |
---|
629 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
630 | } |
---|
631 | |
---|
632 | |
---|
633 | Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
634 | { |
---|
635 | PartSize mode = pcCU->getPartitionSize( absPartIdx ); |
---|
636 | UInt partNum = mode==SIZE_NxN?4:1; |
---|
637 | UInt partOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth(absPartIdx) << 1 ) ) >> 2; |
---|
638 | UInt mpmPred[4],symbol; |
---|
639 | Int j,intraPredMode; |
---|
640 | if (mode==SIZE_NxN) |
---|
641 | { |
---|
642 | depth++; |
---|
643 | } |
---|
644 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
645 | const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__INTRA_DIR_ANG, g_aucConvertToBit[g_uiMaxCUWidth>>depth]+2, CHANNEL_TYPE_LUMA); |
---|
646 | #endif |
---|
647 | for (j=0;j<partNum;j++) |
---|
648 | { |
---|
649 | m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
650 | mpmPred[j] = symbol; |
---|
651 | } |
---|
652 | for (j=0;j<partNum;j++) |
---|
653 | { |
---|
654 | Int preds[NUM_MOST_PROBABLE_MODES] = {-1, -1, -1}; |
---|
655 | pcCU->getIntraDirPredictor(absPartIdx+partOffset*j, preds, COMPONENT_Y); |
---|
656 | if (mpmPred[j]) |
---|
657 | { |
---|
658 | m_pcTDecBinIf->decodeBinEP( symbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
659 | if (symbol) |
---|
660 | { |
---|
661 | m_pcTDecBinIf->decodeBinEP( symbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
662 | symbol++; |
---|
663 | } |
---|
664 | intraPredMode = preds[symbol]; |
---|
665 | } |
---|
666 | else |
---|
667 | { |
---|
668 | m_pcTDecBinIf->decodeBinsEP( symbol, 5 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
669 | intraPredMode = symbol; |
---|
670 | |
---|
671 | //postponed sorting of MPMs (only in remaining branch) |
---|
672 | if (preds[0] > preds[1]) |
---|
673 | { |
---|
674 | std::swap(preds[0], preds[1]); |
---|
675 | } |
---|
676 | if (preds[0] > preds[2]) |
---|
677 | { |
---|
678 | std::swap(preds[0], preds[2]); |
---|
679 | } |
---|
680 | if (preds[1] > preds[2]) |
---|
681 | { |
---|
682 | std::swap(preds[1], preds[2]); |
---|
683 | } |
---|
684 | for ( UInt i = 0; i < NUM_MOST_PROBABLE_MODES; i++ ) |
---|
685 | { |
---|
686 | intraPredMode += ( intraPredMode >= preds[i] ); |
---|
687 | } |
---|
688 | } |
---|
689 | pcCU->setIntraDirSubParts(CHANNEL_TYPE_LUMA, (UChar)intraPredMode, absPartIdx+partOffset*j, depth ); |
---|
690 | } |
---|
691 | } |
---|
692 | |
---|
693 | |
---|
694 | Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
695 | { |
---|
696 | UInt uiSymbol; |
---|
697 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
698 | const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__INTRA_DIR_ANG, g_aucConvertToBit[g_uiMaxCUWidth>>uiDepth]+2, CHANNEL_TYPE_CHROMA); |
---|
699 | #endif |
---|
700 | |
---|
701 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
702 | if( uiSymbol == 0 ) |
---|
703 | { |
---|
704 | uiSymbol = DM_CHROMA_IDX; |
---|
705 | } |
---|
706 | else |
---|
707 | { |
---|
708 | UInt uiIPredMode; |
---|
709 | m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
710 | UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; |
---|
711 | pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); |
---|
712 | uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; |
---|
713 | } |
---|
714 | |
---|
715 | pcCU->setIntraDirSubParts( CHANNEL_TYPE_CHROMA, uiSymbol, uiAbsPartIdx, uiDepth ); |
---|
716 | } |
---|
717 | |
---|
718 | |
---|
719 | Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ) |
---|
720 | { |
---|
721 | UInt uiSymbol; |
---|
722 | const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); |
---|
723 | ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 ); |
---|
724 | |
---|
725 | uiSymbol = 0; |
---|
726 | if (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N || pcCU->getHeight(uiAbsPartIdx) != 8 ) |
---|
727 | { |
---|
728 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__INTER_DIR) ); |
---|
729 | } |
---|
730 | |
---|
731 | if( uiSymbol ) |
---|
732 | { |
---|
733 | uiSymbol = 2; |
---|
734 | } |
---|
735 | else |
---|
736 | { |
---|
737 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + 4 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__INTER_DIR) ); |
---|
738 | assert(uiSymbol == 0 || uiSymbol == 1); |
---|
739 | } |
---|
740 | |
---|
741 | uiSymbol++; |
---|
742 | ruiInterDir = uiSymbol; |
---|
743 | return; |
---|
744 | } |
---|
745 | |
---|
746 | Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList ) |
---|
747 | { |
---|
748 | UInt uiSymbol; |
---|
749 | |
---|
750 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
751 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__REF_FRM_IDX) ); |
---|
752 | |
---|
753 | if( uiSymbol ) |
---|
754 | { |
---|
755 | UInt uiRefNum = pcCU->getSlice()->getNumRefIdx( eRefList ) - 2; |
---|
756 | pCtx++; |
---|
757 | UInt ui; |
---|
758 | for( ui = 0; ui < uiRefNum; ++ui ) |
---|
759 | { |
---|
760 | if( ui == 0 ) |
---|
761 | { |
---|
762 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__REF_FRM_IDX) ); |
---|
763 | } |
---|
764 | else |
---|
765 | { |
---|
766 | m_pcTDecBinIf->decodeBinEP( uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__REF_FRM_IDX) ); |
---|
767 | } |
---|
768 | if( uiSymbol == 0 ) |
---|
769 | { |
---|
770 | break; |
---|
771 | } |
---|
772 | } |
---|
773 | uiSymbol = ui + 1; |
---|
774 | } |
---|
775 | riRefFrmIdx = uiSymbol; |
---|
776 | |
---|
777 | return; |
---|
778 | } |
---|
779 | |
---|
780 | Void TDecSbac::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
781 | { |
---|
782 | UInt uiSymbol; |
---|
783 | UInt uiHorAbs; |
---|
784 | UInt uiVerAbs; |
---|
785 | UInt uiHorSign = 0; |
---|
786 | UInt uiVerSign = 0; |
---|
787 | ContextModel *pCtx = m_cCUMvdSCModel.get( 0 ); |
---|
788 | |
---|
789 | if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3) |
---|
790 | { |
---|
791 | uiHorAbs=0; |
---|
792 | uiVerAbs=0; |
---|
793 | } |
---|
794 | else |
---|
795 | { |
---|
796 | m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD) ); |
---|
797 | m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD) ); |
---|
798 | |
---|
799 | const Bool bHorAbsGr0 = uiHorAbs != 0; |
---|
800 | const Bool bVerAbsGr0 = uiVerAbs != 0; |
---|
801 | pCtx++; |
---|
802 | |
---|
803 | if( bHorAbsGr0 ) |
---|
804 | { |
---|
805 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD) ); |
---|
806 | uiHorAbs += uiSymbol; |
---|
807 | } |
---|
808 | |
---|
809 | if( bVerAbsGr0 ) |
---|
810 | { |
---|
811 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD) ); |
---|
812 | uiVerAbs += uiSymbol; |
---|
813 | } |
---|
814 | |
---|
815 | if( bHorAbsGr0 ) |
---|
816 | { |
---|
817 | if( 2 == uiHorAbs ) |
---|
818 | { |
---|
819 | xReadEpExGolomb( uiSymbol, 1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD_EP) ); |
---|
820 | uiHorAbs += uiSymbol; |
---|
821 | } |
---|
822 | |
---|
823 | m_pcTDecBinIf->decodeBinEP( uiHorSign RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD_EP) ); |
---|
824 | } |
---|
825 | |
---|
826 | if( bVerAbsGr0 ) |
---|
827 | { |
---|
828 | if( 2 == uiVerAbs ) |
---|
829 | { |
---|
830 | xReadEpExGolomb( uiSymbol, 1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD_EP) ); |
---|
831 | uiVerAbs += uiSymbol; |
---|
832 | } |
---|
833 | |
---|
834 | m_pcTDecBinIf->decodeBinEP( uiVerSign RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD_EP) ); |
---|
835 | } |
---|
836 | |
---|
837 | } |
---|
838 | |
---|
839 | const TComMv cMv( uiHorSign ? -Int( uiHorAbs ): uiHorAbs, uiVerSign ? -Int( uiVerAbs ) : uiVerAbs ); |
---|
840 | pcCU->getCUMvField( eRefList )->setAllMvd( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
841 | return; |
---|
842 | } |
---|
843 | |
---|
844 | Void TDecSbac::parseCrossComponentPrediction( TComTU &rTu, ComponentID compID ) |
---|
845 | { |
---|
846 | TComDataCU *pcCU = rTu.getCU(); |
---|
847 | |
---|
848 | if( isLuma(compID) || !pcCU->getSlice()->getPPS()->getUseCrossComponentPrediction() ) |
---|
849 | { |
---|
850 | return; |
---|
851 | } |
---|
852 | |
---|
853 | const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
---|
854 | |
---|
855 | if (!pcCU->isIntra(uiAbsPartIdx) || (pcCU->getIntraDir( CHANNEL_TYPE_CHROMA, uiAbsPartIdx ) == DM_CHROMA_IDX)) |
---|
856 | { |
---|
857 | Char alpha = 0; |
---|
858 | UInt symbol = 0; |
---|
859 | |
---|
860 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
861 | DTRACE_CABAC_T("\tparseCrossComponentPrediction()") |
---|
862 | DTRACE_CABAC_T( "\tAddr=" ) |
---|
863 | DTRACE_CABAC_V( compID ) |
---|
864 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
865 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
866 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
867 | TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__CROSS_COMPONENT_PREDICTION, (g_aucConvertToBit[rTu.getRect(compID).width] + 2), compID); |
---|
868 | #endif |
---|
869 | ContextModel *pCtx = m_cCrossComponentPredictionSCModel.get(0, 0) + ((compID == COMPONENT_Cr) ? (NUM_CROSS_COMPONENT_PREDICTION_CTX >> 1) : 0); |
---|
870 | m_pcTDecBinIf->decodeBin( symbol, pCtx[0] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
871 | |
---|
872 | if(symbol != 0) |
---|
873 | { |
---|
874 | // Cross-component prediction alpha is non-zero. |
---|
875 | UInt sign = 0; |
---|
876 | m_pcTDecBinIf->decodeBin( symbol, pCtx[1] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
877 | |
---|
878 | if (symbol != 0) |
---|
879 | { |
---|
880 | // alpha is 2 (symbol=1), 4(symbol=2) or 8(symbol=3). |
---|
881 | // Read up to two more bits |
---|
882 | xReadUnaryMaxSymbol( symbol, (pCtx + 2), 1, 2 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
883 | symbol += 1; |
---|
884 | } |
---|
885 | m_pcTDecBinIf->decodeBin( sign, pCtx[4] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
886 | |
---|
887 | alpha = (sign != 0) ? -(1 << symbol) : (1 << symbol); |
---|
888 | } |
---|
889 | DTRACE_CABAC_T( "\tAlpha=" ) |
---|
890 | DTRACE_CABAC_V( alpha ) |
---|
891 | DTRACE_CABAC_T( "\n" ) |
---|
892 | |
---|
893 | pcCU->setCrossComponentPredictionAlphaPartRange( alpha, compID, uiAbsPartIdx, rTu.GetAbsPartIdxNumParts( compID ) ); |
---|
894 | } |
---|
895 | } |
---|
896 | |
---|
897 | Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) |
---|
898 | { |
---|
899 | m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) |
---|
900 | RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(TComCodingStatisticsClassType(STATS__CABAC_BITS__TRANSFORM_SUBDIV_FLAG, 5-uiLog2TransformBlockSize)) |
---|
901 | ); |
---|
902 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
903 | DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) |
---|
904 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
905 | DTRACE_CABAC_V( ruiSubdivFlag ) |
---|
906 | DTRACE_CABAC_T( "\tctx=" ) |
---|
907 | DTRACE_CABAC_V( uiLog2TransformBlockSize ) |
---|
908 | DTRACE_CABAC_T( "\n" ) |
---|
909 | } |
---|
910 | |
---|
911 | Void TDecSbac::parseQtRootCbf( UInt uiAbsPartIdx, UInt& uiQtRootCbf ) |
---|
912 | { |
---|
913 | UInt uiSymbol; |
---|
914 | const UInt uiCtx = 0; |
---|
915 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__QT_ROOT_CBF) ); |
---|
916 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
917 | DTRACE_CABAC_T( "\tparseQtRootCbf()" ) |
---|
918 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
919 | DTRACE_CABAC_V( uiSymbol ) |
---|
920 | DTRACE_CABAC_T( "\tctx=" ) |
---|
921 | DTRACE_CABAC_V( uiCtx ) |
---|
922 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
923 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
924 | DTRACE_CABAC_T( "\n" ) |
---|
925 | |
---|
926 | uiQtRootCbf = uiSymbol; |
---|
927 | } |
---|
928 | |
---|
929 | Void TDecSbac::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
930 | { |
---|
931 | Int qp; |
---|
932 | UInt uiDQp; |
---|
933 | Int iDQp; |
---|
934 | |
---|
935 | UInt uiSymbol; |
---|
936 | |
---|
937 | xReadUnaryMaxSymbol (uiDQp, &m_cCUDeltaQpSCModel.get( 0, 0, 0 ), 1, CU_DQP_TU_CMAX RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTA_QP_EP) ); |
---|
938 | |
---|
939 | if( uiDQp >= CU_DQP_TU_CMAX) |
---|
940 | { |
---|
941 | xReadEpExGolomb( uiSymbol, CU_DQP_EG_k RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTA_QP_EP)); |
---|
942 | uiDQp+=uiSymbol; |
---|
943 | } |
---|
944 | |
---|
945 | if ( uiDQp > 0 ) |
---|
946 | { |
---|
947 | UInt uiSign; |
---|
948 | #if SVC_EXTENSION |
---|
949 | Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); |
---|
950 | #else |
---|
951 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); |
---|
952 | #endif |
---|
953 | m_pcTDecBinIf->decodeBinEP(uiSign RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTA_QP_EP)); |
---|
954 | iDQp = uiDQp; |
---|
955 | if(uiSign) |
---|
956 | { |
---|
957 | iDQp = -iDQp; |
---|
958 | } |
---|
959 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY; |
---|
960 | } |
---|
961 | else |
---|
962 | { |
---|
963 | qp = pcCU->getRefQP(uiAbsPartIdx); |
---|
964 | } |
---|
965 | |
---|
966 | pcCU->setQPSubParts(qp, uiAbsPartIdx, uiDepth); |
---|
967 | pcCU->setCodedQP(qp); |
---|
968 | } |
---|
969 | |
---|
970 | /** parse chroma qp adjustment, converting to the internal table representation. |
---|
971 | * \returns Void |
---|
972 | */ |
---|
973 | Void TDecSbac::parseChromaQpAdjustment( TComDataCU* cu, UInt absPartIdx, UInt depth ) |
---|
974 | { |
---|
975 | UInt symbol; |
---|
976 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
977 | const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__CHROMA_QP_ADJUSTMENT, g_aucConvertToBit[g_uiMaxCUWidth>>depth]+2, CHANNEL_TYPE_CHROMA); |
---|
978 | #endif |
---|
979 | |
---|
980 | Int tableSize = cu->getSlice()->getPPS()->getChromaQpAdjTableSize(); |
---|
981 | |
---|
982 | /* cu_chroma_qp_adjustment_flag */ |
---|
983 | m_pcTDecBinIf->decodeBin( symbol, m_ChromaQpAdjFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
984 | |
---|
985 | if (symbol && tableSize > 1) |
---|
986 | { |
---|
987 | /* cu_chroma_qp_adjustment_idc */ |
---|
988 | xReadUnaryMaxSymbol( symbol, &m_ChromaQpAdjIdcSCModel.get( 0, 0, 0 ), 0, tableSize - 1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
989 | symbol++; |
---|
990 | } |
---|
991 | /* NB, symbol = 0 if outer flag is not set, |
---|
992 | * 1 if outer flag is set and there is no inner flag |
---|
993 | * 1+ otherwise */ |
---|
994 | cu->setChromaQpAdjSubParts( symbol, absPartIdx, depth ); |
---|
995 | cu->setCodedChromaQpAdj(symbol); |
---|
996 | } |
---|
997 | |
---|
998 | Void TDecSbac::parseQtCbf( TComTU &rTu, const ComponentID compID, const Bool lowestLevel ) |
---|
999 | { |
---|
1000 | TComDataCU* pcCU = rTu.getCU(); |
---|
1001 | |
---|
1002 | const UInt absPartIdx = rTu.GetAbsPartIdxTU(compID); |
---|
1003 | const UInt TUDepth = rTu.GetTransformDepthRel(); |
---|
1004 | const UInt uiCtx = pcCU->getCtxQtCbf( rTu, toChannelType(compID) ); |
---|
1005 | const UInt contextSet = toChannelType(compID); |
---|
1006 | |
---|
1007 | const UInt width = rTu.getRect(compID).width; |
---|
1008 | const UInt height = rTu.getRect(compID).height; |
---|
1009 | const Bool canQuadSplit = (width >= (MIN_TU_SIZE * 2)) && (height >= (MIN_TU_SIZE * 2)); |
---|
1010 | const UInt coveredPartIdxes = rTu.GetAbsPartIdxNumParts(compID); |
---|
1011 | |
---|
1012 | // Since the CBF for chroma is coded at the highest level possible, if sub-TUs are |
---|
1013 | // to be coded for a 4x8 chroma TU, their CBFs must be coded at the highest 4x8 level |
---|
1014 | // (i.e. where luma TUs are 8x8 rather than 4x4) |
---|
1015 | // ___ ___ |
---|
1016 | // | | | <- 4 x (8x8 luma + 4x8 4:2:2 chroma) |
---|
1017 | // |___|___| each quadrant has its own chroma CBF |
---|
1018 | // | | | _ _ _ _ |
---|
1019 | // |___|___| | |
---|
1020 | // <--16---> V |
---|
1021 | // _ _ |
---|
1022 | // |_|_| <- 4 x 4x4 luma + 1 x 4x8 4:2:2 chroma |
---|
1023 | // |_|_| no chroma CBF is coded - instead the parent CBF is inherited |
---|
1024 | // <-8-> if sub-TUs are present, their CBFs had to be coded at the parent level |
---|
1025 | |
---|
1026 | const UInt lowestTUDepth = TUDepth + ((!lowestLevel && !canQuadSplit) ? 1 : 0); //unsplittable TUs inherit their parent's CBF |
---|
1027 | UInt lowestTUCBF = 0; |
---|
1028 | |
---|
1029 | if ((width != height) && (lowestLevel || !canQuadSplit)) //if sub-TUs are present |
---|
1030 | { |
---|
1031 | const UInt subTUDepth = lowestTUDepth + 1; |
---|
1032 | const UInt partIdxesPerSubTU = rTu.GetAbsPartIdxNumParts(compID) >> 1; |
---|
1033 | |
---|
1034 | UInt combinedSubTUCBF = 0; |
---|
1035 | |
---|
1036 | for (UInt subTU = 0; subTU < 2; subTU++) |
---|
1037 | { |
---|
1038 | UInt uiCbf = MAX_UINT; |
---|
1039 | m_pcTDecBinIf->decodeBin(uiCbf, m_cCUQtCbfSCModel.get(0, contextSet, uiCtx) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(TComCodingStatisticsClassType(STATS__CABAC_BITS__QT_CBF, g_aucConvertToBit[rTu.getRect(compID).width]+2, compID))); |
---|
1040 | |
---|
1041 | const UInt subTUAbsPartIdx = absPartIdx + (subTU * partIdxesPerSubTU); |
---|
1042 | pcCU->setCbfPartRange((uiCbf << subTUDepth), compID, subTUAbsPartIdx, partIdxesPerSubTU); |
---|
1043 | combinedSubTUCBF |= uiCbf; |
---|
1044 | |
---|
1045 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1046 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
1047 | DTRACE_CABAC_T( "\tsub-TU=" ) |
---|
1048 | DTRACE_CABAC_V( subTU ) |
---|
1049 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1050 | DTRACE_CABAC_V( uiCbf ) |
---|
1051 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1052 | DTRACE_CABAC_V( uiCtx ) |
---|
1053 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1054 | DTRACE_CABAC_V( compID ) |
---|
1055 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1056 | DTRACE_CABAC_V( subTUAbsPartIdx ) |
---|
1057 | DTRACE_CABAC_T( "\n" ) |
---|
1058 | } |
---|
1059 | |
---|
1060 | //propagate the sub-TU CBF up to the lowest TU level |
---|
1061 | if (combinedSubTUCBF != 0) |
---|
1062 | { |
---|
1063 | pcCU->bitwiseOrCbfPartRange((combinedSubTUCBF << lowestTUDepth), compID, absPartIdx, coveredPartIdxes); |
---|
1064 | lowestTUCBF = combinedSubTUCBF; |
---|
1065 | } |
---|
1066 | } |
---|
1067 | else |
---|
1068 | { |
---|
1069 | UInt uiCbf = MAX_UINT; |
---|
1070 | m_pcTDecBinIf->decodeBin(uiCbf, m_cCUQtCbfSCModel.get(0, contextSet, uiCtx) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(TComCodingStatisticsClassType(STATS__CABAC_BITS__QT_CBF, g_aucConvertToBit[rTu.getRect(compID).width]+2, compID))); |
---|
1071 | |
---|
1072 | pcCU->setCbfSubParts((uiCbf << lowestTUDepth), compID, absPartIdx, rTu.GetTransformDepthTotalAdj(compID)); |
---|
1073 | |
---|
1074 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1075 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
1076 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1077 | DTRACE_CABAC_V( uiCbf ) |
---|
1078 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1079 | DTRACE_CABAC_V( uiCtx ) |
---|
1080 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1081 | DTRACE_CABAC_V( compID ) |
---|
1082 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1083 | DTRACE_CABAC_V( rTu.GetAbsPartIdxTU(compID) ) |
---|
1084 | DTRACE_CABAC_T( "\n" ) |
---|
1085 | |
---|
1086 | lowestTUCBF = uiCbf; |
---|
1087 | } |
---|
1088 | |
---|
1089 | //propagate the lowest level CBF up to the current level |
---|
1090 | if (lowestTUCBF != 0) |
---|
1091 | { |
---|
1092 | for (UInt depth = TUDepth; depth < lowestTUDepth; depth++) |
---|
1093 | { |
---|
1094 | pcCU->bitwiseOrCbfPartRange((lowestTUCBF << depth), compID, absPartIdx, coveredPartIdxes); |
---|
1095 | } |
---|
1096 | } |
---|
1097 | } |
---|
1098 | |
---|
1099 | |
---|
1100 | Void TDecSbac::parseTransformSkipFlags (TComTU &rTu, ComponentID component) |
---|
1101 | { |
---|
1102 | TComDataCU* pcCU=rTu.getCU(); |
---|
1103 | UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(component); |
---|
1104 | |
---|
1105 | if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) |
---|
1106 | { |
---|
1107 | return; |
---|
1108 | } |
---|
1109 | |
---|
1110 | if (!TUCompRectHasAssociatedTransformSkipFlag(rTu.getRect(component), pcCU->getSlice()->getPPS()->getTransformSkipLog2MaxSize())) |
---|
1111 | { |
---|
1112 | return; |
---|
1113 | } |
---|
1114 | |
---|
1115 | UInt useTransformSkip; |
---|
1116 | |
---|
1117 | m_pcTDecBinIf->decodeBin( useTransformSkip , m_cTransformSkipSCModel.get( 0, toChannelType(component), 0 ) |
---|
1118 | RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(TComCodingStatisticsClassType(STATS__CABAC_BITS__TRANSFORM_SKIP_FLAGS, component)) |
---|
1119 | ); |
---|
1120 | |
---|
1121 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1122 | DTRACE_CABAC_T("\tparseTransformSkip()"); |
---|
1123 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1124 | DTRACE_CABAC_V( useTransformSkip ) |
---|
1125 | DTRACE_CABAC_T( "\tAddr=" ) |
---|
1126 | DTRACE_CABAC_V( pcCU->getCtuRsAddr() ) |
---|
1127 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1128 | DTRACE_CABAC_V( component ) |
---|
1129 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1130 | DTRACE_CABAC_V( rTu.GetAbsPartIdxTU() ) |
---|
1131 | DTRACE_CABAC_T( "\n" ) |
---|
1132 | |
---|
1133 | pcCU->setTransformSkipPartRange( useTransformSkip, component, uiAbsPartIdx, rTu.GetAbsPartIdxNumParts(component)); |
---|
1134 | } |
---|
1135 | |
---|
1136 | |
---|
1137 | /** Parse (X,Y) position of the last significant coefficient |
---|
1138 | * \param uiPosLastX reference to X component of last coefficient |
---|
1139 | * \param uiPosLastY reference to Y component of last coefficient |
---|
1140 | * \param width Block width |
---|
1141 | * \param height Block height |
---|
1142 | * \param component chroma compinent ID |
---|
1143 | * \param uiScanIdx scan type (zig-zag, hor, ver) |
---|
1144 | * |
---|
1145 | * This method decodes the X and Y component within a block of the last significant coefficient. |
---|
1146 | */ |
---|
1147 | Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, ComponentID component, UInt uiScanIdx ) |
---|
1148 | { |
---|
1149 | UInt uiLast; |
---|
1150 | |
---|
1151 | ContextModel *pCtxX = m_cCuCtxLastX.get( 0, toChannelType(component) ); |
---|
1152 | ContextModel *pCtxY = m_cCuCtxLastY.get( 0, toChannelType(component) ); |
---|
1153 | |
---|
1154 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
1155 | TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__LAST_SIG_X_Y, g_aucConvertToBit[width]+2, component); |
---|
1156 | #endif |
---|
1157 | |
---|
1158 | |
---|
1159 | if ( uiScanIdx == SCAN_VER ) |
---|
1160 | { |
---|
1161 | swap( width, height ); |
---|
1162 | } |
---|
1163 | |
---|
1164 | Int blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY; |
---|
1165 | getLastSignificantContextParameters(component, width, height, blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY); |
---|
1166 | |
---|
1167 | //------------------ |
---|
1168 | |
---|
1169 | // posX |
---|
1170 | |
---|
1171 | for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ ) |
---|
1172 | { |
---|
1173 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + blkSizeOffsetX + (uiPosLastX >>shiftX) ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
1174 | |
---|
1175 | if( !uiLast ) |
---|
1176 | { |
---|
1177 | break; |
---|
1178 | } |
---|
1179 | } |
---|
1180 | |
---|
1181 | // posY |
---|
1182 | |
---|
1183 | for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ ) |
---|
1184 | { |
---|
1185 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + blkSizeOffsetY + (uiPosLastY >>shiftY)) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
1186 | |
---|
1187 | if( !uiLast ) |
---|
1188 | { |
---|
1189 | break; |
---|
1190 | } |
---|
1191 | } |
---|
1192 | |
---|
1193 | // EP-coded part |
---|
1194 | |
---|
1195 | if ( uiPosLastX > 3 ) |
---|
1196 | { |
---|
1197 | UInt uiTemp = 0; |
---|
1198 | UInt uiCount = ( uiPosLastX - 2 ) >> 1; |
---|
1199 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
1200 | { |
---|
1201 | m_pcTDecBinIf->decodeBinEP( uiLast RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
1202 | uiTemp += uiLast << i; |
---|
1203 | } |
---|
1204 | uiPosLastX = g_uiMinInGroup[ uiPosLastX ] + uiTemp; |
---|
1205 | } |
---|
1206 | if ( uiPosLastY > 3 ) |
---|
1207 | { |
---|
1208 | UInt uiTemp = 0; |
---|
1209 | UInt uiCount = ( uiPosLastY - 2 ) >> 1; |
---|
1210 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
1211 | { |
---|
1212 | m_pcTDecBinIf->decodeBinEP( uiLast RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); |
---|
1213 | uiTemp += uiLast << i; |
---|
1214 | } |
---|
1215 | uiPosLastY = g_uiMinInGroup[ uiPosLastY ] + uiTemp; |
---|
1216 | } |
---|
1217 | |
---|
1218 | if( uiScanIdx == SCAN_VER ) |
---|
1219 | { |
---|
1220 | swap( uiPosLastX, uiPosLastY ); |
---|
1221 | } |
---|
1222 | } |
---|
1223 | |
---|
1224 | Void TDecSbac::parseCoeffNxN( TComTU &rTu, ComponentID compID ) |
---|
1225 | { |
---|
1226 | TComDataCU* pcCU=rTu.getCU(); |
---|
1227 | const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(compID); |
---|
1228 | const TComRectangle &rRect=rTu.getRect(compID); |
---|
1229 | const UInt uiWidth=rRect.width; |
---|
1230 | const UInt uiHeight=rRect.height; |
---|
1231 | TCoeff* pcCoef=(pcCU->getCoeff(compID)+rTu.getCoefficientOffset(compID)); |
---|
1232 | |
---|
1233 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1234 | DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) |
---|
1235 | DTRACE_CABAC_V( compID ) |
---|
1236 | DTRACE_CABAC_T( "\twidth=" ) |
---|
1237 | DTRACE_CABAC_V( uiWidth ) |
---|
1238 | DTRACE_CABAC_T( "\theight=" ) |
---|
1239 | DTRACE_CABAC_V( uiHeight ) |
---|
1240 | DTRACE_CABAC_T( "\tdepth=" ) |
---|
1241 | // DTRACE_CABAC_V( rTu.GetTransformDepthTotalAdj(compID) ) |
---|
1242 | DTRACE_CABAC_V( rTu.GetTransformDepthTotal() ) |
---|
1243 | DTRACE_CABAC_T( "\tabspartidx=" ) |
---|
1244 | // DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1245 | DTRACE_CABAC_V( rTu.GetAbsPartIdxTU(compID) ) |
---|
1246 | DTRACE_CABAC_T( "\ttoCU-X=" ) |
---|
1247 | DTRACE_CABAC_V( pcCU->getCUPelX() ) |
---|
1248 | DTRACE_CABAC_T( "\ttoCU-Y=" ) |
---|
1249 | DTRACE_CABAC_V( pcCU->getCUPelY() ) |
---|
1250 | DTRACE_CABAC_T( "\tCU-addr=" ) |
---|
1251 | DTRACE_CABAC_V( pcCU->getCtuRsAddr() ) |
---|
1252 | DTRACE_CABAC_T( "\tinCU-X=" ) |
---|
1253 | // DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1254 | DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[rTu.GetAbsPartIdxTU(compID)] ] ) |
---|
1255 | DTRACE_CABAC_T( "\tinCU-Y=" ) |
---|
1256 | // DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1257 | DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[rTu.GetAbsPartIdxTU(compID)] ] ) |
---|
1258 | DTRACE_CABAC_T( "\tpredmode=" ) |
---|
1259 | DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) |
---|
1260 | DTRACE_CABAC_T( "\n" ) |
---|
1261 | |
---|
1262 | //-------------------------------------------------------------------------------------------------- |
---|
1263 | |
---|
1264 | if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) |
---|
1265 | { |
---|
1266 | std::cerr << "ERROR: parseCoeffNxN was passed a TU with dimensions larger than the maximum allowed size" << std::endl; |
---|
1267 | assert(false); |
---|
1268 | exit(1); |
---|
1269 | } |
---|
1270 | |
---|
1271 | //-------------------------------------------------------------------------------------------------- |
---|
1272 | |
---|
1273 | //set parameters |
---|
1274 | |
---|
1275 | const ChannelType chType = toChannelType(compID); |
---|
1276 | const UInt uiLog2BlockWidth = g_aucConvertToBit[ uiWidth ] + 2; |
---|
1277 | const UInt uiLog2BlockHeight = g_aucConvertToBit[ uiHeight ] + 2; |
---|
1278 | const UInt uiMaxNumCoeff = uiWidth * uiHeight; |
---|
1279 | const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; |
---|
1280 | |
---|
1281 | const ChannelType channelType = toChannelType(compID); |
---|
1282 | const Bool extendedPrecision = pcCU->getSlice()->getSPS()->getUseExtendedPrecision(); |
---|
1283 | |
---|
1284 | const Bool alignCABACBeforeBypass = pcCU->getSlice()->getSPS()->getAlignCABACBeforeBypass(); |
---|
1285 | |
---|
1286 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
1287 | TComCodingStatisticsClassType ctype_group(STATS__CABAC_BITS__SIG_COEFF_GROUP_FLAG, uiLog2BlockWidth, compID); |
---|
1288 | TComCodingStatisticsClassType ctype_map(STATS__CABAC_BITS__SIG_COEFF_MAP_FLAG, uiLog2BlockWidth, compID); |
---|
1289 | TComCodingStatisticsClassType ctype_gt1(STATS__CABAC_BITS__GT1_FLAG, uiLog2BlockWidth, compID); |
---|
1290 | TComCodingStatisticsClassType ctype_gt2(STATS__CABAC_BITS__GT2_FLAG, uiLog2BlockWidth, compID); |
---|
1291 | #endif |
---|
1292 | |
---|
1293 | Bool beValid; |
---|
1294 | if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) |
---|
1295 | { |
---|
1296 | beValid = false; |
---|
1297 | if((!pcCU->isIntra(uiAbsPartIdx)) && pcCU->isRDPCMEnabled(uiAbsPartIdx)) |
---|
1298 | { |
---|
1299 | parseExplicitRdpcmMode(rTu, compID); |
---|
1300 | } |
---|
1301 | } |
---|
1302 | else |
---|
1303 | { |
---|
1304 | beValid = pcCU->getSlice()->getPPS()->getSignHideFlag(); |
---|
1305 | } |
---|
1306 | |
---|
1307 | UInt absSum = 0; |
---|
1308 | |
---|
1309 | //-------------------------------------------------------------------------------------------------- |
---|
1310 | |
---|
1311 | if(pcCU->getSlice()->getPPS()->getUseTransformSkip()) |
---|
1312 | { |
---|
1313 | parseTransformSkipFlags(rTu, compID); |
---|
1314 | // This TU has coefficients and is transform skipped. Check whether is inter coded and if yes decode the explicit RDPCM mode |
---|
1315 | if(pcCU->getTransformSkip(uiAbsPartIdx, compID) && (!pcCU->isIntra(uiAbsPartIdx)) && pcCU->isRDPCMEnabled(uiAbsPartIdx) ) |
---|
1316 | { |
---|
1317 | parseExplicitRdpcmMode(rTu, compID); |
---|
1318 | if(pcCU->getExplicitRdpcmMode(compID, uiAbsPartIdx) != RDPCM_OFF) |
---|
1319 | { |
---|
1320 | // Sign data hiding is avoided for horizontal and vertical RDPCM modes |
---|
1321 | beValid = false; |
---|
1322 | } |
---|
1323 | } |
---|
1324 | } |
---|
1325 | |
---|
1326 | Int uiIntraMode = -1; |
---|
1327 | const Bool bIsLuma = isLuma(compID); |
---|
1328 | Int isIntra = pcCU->isIntra(uiAbsPartIdx) ? 1 : 0; |
---|
1329 | if ( isIntra && pcCU->isRDPCMEnabled(uiAbsPartIdx) ) |
---|
1330 | { |
---|
1331 | uiIntraMode = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx ); |
---|
1332 | uiIntraMode = (uiIntraMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, rTu.GetChromaFormat())) : uiIntraMode; |
---|
1333 | uiIntraMode = ((rTu.GetChromaFormat() == CHROMA_422) && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiIntraMode] : uiIntraMode; |
---|
1334 | |
---|
1335 | Bool transformSkip = pcCU->getTransformSkip( uiAbsPartIdx,compID); |
---|
1336 | Bool rdpcm_lossy = ( transformSkip /*&& isIntra*/ && ( (uiIntraMode == HOR_IDX) || (uiIntraMode == VER_IDX) ) ); |
---|
1337 | if ( rdpcm_lossy ) |
---|
1338 | { |
---|
1339 | beValid = false; |
---|
1340 | } |
---|
1341 | } |
---|
1342 | |
---|
1343 | //-------------------------------------------------------------------------------------------------- |
---|
1344 | |
---|
1345 | const Bool bUseGolombRiceParameterAdaptation = pcCU->getSlice()->getSPS()->getUseGolombRiceParameterAdaptation(); |
---|
1346 | UInt ¤tGolombRiceStatistic = m_golombRiceAdaptationStatistics[rTu.getGolombRiceStatisticsIndex(compID)]; |
---|
1347 | |
---|
1348 | //select scans |
---|
1349 | TUEntropyCodingParameters codingParameters; |
---|
1350 | getTUEntropyCodingParameters(codingParameters, rTu, compID); |
---|
1351 | |
---|
1352 | //===== decode last significant ===== |
---|
1353 | UInt uiPosLastX, uiPosLastY; |
---|
1354 | parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, compID, codingParameters.scanType ); |
---|
1355 | UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockWidth); |
---|
1356 | pcCoef[ uiBlkPosLast ] = 1; |
---|
1357 | |
---|
1358 | //===== decode significance flags ===== |
---|
1359 | UInt uiScanPosLast; |
---|
1360 | for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ ) |
---|
1361 | { |
---|
1362 | UInt uiBlkPos = codingParameters.scan[ uiScanPosLast ]; |
---|
1363 | if( uiBlkPosLast == uiBlkPos ) |
---|
1364 | { |
---|
1365 | break; |
---|
1366 | } |
---|
1367 | } |
---|
1368 | |
---|
1369 | ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, isChroma(chType) ); |
---|
1370 | ContextModel * const baseCtx = m_cCUSigSCModel.get( 0, 0 ) + getSignificanceMapContextOffset(compID); |
---|
1371 | |
---|
1372 | const Int iLastScanSet = uiScanPosLast >> MLS_CG_SIZE; |
---|
1373 | UInt c1 = 1; |
---|
1374 | UInt uiGoRiceParam = 0; |
---|
1375 | |
---|
1376 | |
---|
1377 | UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ]; |
---|
1378 | memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); |
---|
1379 | |
---|
1380 | Int iScanPosSig = (Int) uiScanPosLast; |
---|
1381 | for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- ) |
---|
1382 | { |
---|
1383 | Int iSubPos = iSubSet << MLS_CG_SIZE; |
---|
1384 | uiGoRiceParam = currentGolombRiceStatistic / RExt__GOLOMB_RICE_INCREMENT_DIVISOR; |
---|
1385 | Bool updateGolombRiceStatistics = bUseGolombRiceParameterAdaptation; //leave the statistics at 0 when not using the adaptation system |
---|
1386 | Int numNonZero = 0; |
---|
1387 | |
---|
1388 | Int lastNZPosInCG = -1; |
---|
1389 | Int firstNZPosInCG = 1 << MLS_CG_SIZE; |
---|
1390 | |
---|
1391 | Bool escapeDataPresentInGroup = false; |
---|
1392 | |
---|
1393 | Int pos[1 << MLS_CG_SIZE]; |
---|
1394 | |
---|
1395 | if( iScanPosSig == (Int) uiScanPosLast ) |
---|
1396 | { |
---|
1397 | lastNZPosInCG = iScanPosSig; |
---|
1398 | firstNZPosInCG = iScanPosSig; |
---|
1399 | iScanPosSig--; |
---|
1400 | pos[ numNonZero ] = uiBlkPosLast; |
---|
1401 | numNonZero = 1; |
---|
1402 | } |
---|
1403 | |
---|
1404 | // decode significant_coeffgroup_flag |
---|
1405 | Int iCGBlkPos = codingParameters.scanCG[ iSubSet ]; |
---|
1406 | Int iCGPosY = iCGBlkPos / codingParameters.widthInGroups; |
---|
1407 | Int iCGPosX = iCGBlkPos - (iCGPosY * codingParameters.widthInGroups); |
---|
1408 | |
---|
1409 | if( iSubSet == iLastScanSet || iSubSet == 0) |
---|
1410 | { |
---|
1411 | uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; |
---|
1412 | } |
---|
1413 | else |
---|
1414 | { |
---|
1415 | UInt uiSigCoeffGroup; |
---|
1416 | UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, codingParameters.widthInGroups, codingParameters.heightInGroups ); |
---|
1417 | m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_group) ); |
---|
1418 | uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup; |
---|
1419 | } |
---|
1420 | |
---|
1421 | // decode significant_coeff_flag |
---|
1422 | const Int patternSigCtx = TComTrQuant::calcPatternSigCtx(uiSigCoeffGroupFlag, iCGPosX, iCGPosY, codingParameters.widthInGroups, codingParameters.heightInGroups); |
---|
1423 | |
---|
1424 | UInt uiBlkPos, uiSig, uiCtxSig; |
---|
1425 | for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) |
---|
1426 | { |
---|
1427 | uiBlkPos = codingParameters.scan[ iScanPosSig ]; |
---|
1428 | uiSig = 0; |
---|
1429 | |
---|
1430 | if( uiSigCoeffGroupFlag[ iCGBlkPos ] ) |
---|
1431 | { |
---|
1432 | if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) |
---|
1433 | { |
---|
1434 | uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, codingParameters, iScanPosSig, uiLog2BlockWidth, uiLog2BlockHeight, chType ); |
---|
1435 | m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_map) ); |
---|
1436 | } |
---|
1437 | else |
---|
1438 | { |
---|
1439 | uiSig = 1; |
---|
1440 | } |
---|
1441 | } |
---|
1442 | pcCoef[ uiBlkPos ] = uiSig; |
---|
1443 | if( uiSig ) |
---|
1444 | { |
---|
1445 | pos[ numNonZero ] = uiBlkPos; |
---|
1446 | numNonZero ++; |
---|
1447 | if( lastNZPosInCG == -1 ) |
---|
1448 | { |
---|
1449 | lastNZPosInCG = iScanPosSig; |
---|
1450 | } |
---|
1451 | firstNZPosInCG = iScanPosSig; |
---|
1452 | } |
---|
1453 | } |
---|
1454 | |
---|
1455 | if( numNonZero > 0 ) |
---|
1456 | { |
---|
1457 | Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= SBH_THRESHOLD ); |
---|
1458 | |
---|
1459 | absSum = 0; |
---|
1460 | |
---|
1461 | const UInt uiCtxSet = getContextSetIndex(compID, iSubSet, (c1 == 0)); |
---|
1462 | c1 = 1; |
---|
1463 | UInt uiBin; |
---|
1464 | |
---|
1465 | ContextModel *baseCtxMod = m_cCUOneSCModel.get( 0, 0 ) + (NUM_ONE_FLAG_CTX_PER_SET * uiCtxSet); |
---|
1466 | |
---|
1467 | Int absCoeff[1 << MLS_CG_SIZE]; |
---|
1468 | |
---|
1469 | for ( Int i = 0; i < numNonZero; i++) |
---|
1470 | { |
---|
1471 | absCoeff[i] = 1; |
---|
1472 | } |
---|
1473 | Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); |
---|
1474 | Int firstC2FlagIdx = -1; |
---|
1475 | |
---|
1476 | for( Int idx = 0; idx < numC1Flag; idx++ ) |
---|
1477 | { |
---|
1478 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_gt1) ); |
---|
1479 | if( uiBin == 1 ) |
---|
1480 | { |
---|
1481 | c1 = 0; |
---|
1482 | if (firstC2FlagIdx == -1) |
---|
1483 | { |
---|
1484 | firstC2FlagIdx = idx; |
---|
1485 | } |
---|
1486 | else //if a greater-than-one has been encountered already this group |
---|
1487 | { |
---|
1488 | escapeDataPresentInGroup = true; |
---|
1489 | } |
---|
1490 | } |
---|
1491 | else if( (c1 < 3) && (c1 > 0) ) |
---|
1492 | { |
---|
1493 | c1++; |
---|
1494 | } |
---|
1495 | absCoeff[ idx ] = uiBin + 1; |
---|
1496 | } |
---|
1497 | |
---|
1498 | if (c1 == 0) |
---|
1499 | { |
---|
1500 | baseCtxMod = m_cCUAbsSCModel.get( 0, 0 ) + (NUM_ABS_FLAG_CTX_PER_SET * uiCtxSet); |
---|
1501 | if ( firstC2FlagIdx != -1) |
---|
1502 | { |
---|
1503 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_gt2) ); |
---|
1504 | absCoeff[ firstC2FlagIdx ] = uiBin + 2; |
---|
1505 | if (uiBin != 0) |
---|
1506 | { |
---|
1507 | escapeDataPresentInGroup = true; |
---|
1508 | } |
---|
1509 | } |
---|
1510 | } |
---|
1511 | |
---|
1512 | escapeDataPresentInGroup = escapeDataPresentInGroup || (numNonZero > C1FLAG_NUMBER); |
---|
1513 | |
---|
1514 | const Bool alignGroup = escapeDataPresentInGroup && alignCABACBeforeBypass; |
---|
1515 | |
---|
1516 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
1517 | TComCodingStatisticsClassType ctype_signs((alignGroup ? STATS__CABAC_BITS__ALIGNED_SIGN_BIT : STATS__CABAC_BITS__SIGN_BIT ), uiLog2BlockWidth, compID); |
---|
1518 | TComCodingStatisticsClassType ctype_escs ((alignGroup ? STATS__CABAC_BITS__ALIGNED_ESCAPE_BITS : STATS__CABAC_BITS__ESCAPE_BITS), uiLog2BlockWidth, compID); |
---|
1519 | #endif |
---|
1520 | |
---|
1521 | if (alignGroup) |
---|
1522 | { |
---|
1523 | m_pcTDecBinIf->align(); |
---|
1524 | } |
---|
1525 | |
---|
1526 | UInt coeffSigns; |
---|
1527 | if ( signHidden && beValid ) |
---|
1528 | { |
---|
1529 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_signs) ); |
---|
1530 | coeffSigns <<= 32 - (numNonZero-1); |
---|
1531 | } |
---|
1532 | else |
---|
1533 | { |
---|
1534 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_signs) ); |
---|
1535 | coeffSigns <<= 32 - numNonZero; |
---|
1536 | } |
---|
1537 | |
---|
1538 | Int iFirstCoeff2 = 1; |
---|
1539 | if (escapeDataPresentInGroup) |
---|
1540 | { |
---|
1541 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
1542 | { |
---|
1543 | UInt baseLevel = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2) : 1; |
---|
1544 | |
---|
1545 | if( absCoeff[ idx ] == baseLevel) |
---|
1546 | { |
---|
1547 | UInt uiLevel; |
---|
1548 | xReadCoefRemainExGolomb( uiLevel, uiGoRiceParam, extendedPrecision, channelType RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_escs) ); |
---|
1549 | |
---|
1550 | absCoeff[ idx ] = uiLevel + baseLevel; |
---|
1551 | |
---|
1552 | if (absCoeff[idx] > (3 << uiGoRiceParam)) |
---|
1553 | { |
---|
1554 | uiGoRiceParam = bUseGolombRiceParameterAdaptation ? (uiGoRiceParam + 1) : (std::min<UInt>((uiGoRiceParam + 1), 4)); |
---|
1555 | } |
---|
1556 | |
---|
1557 | if (updateGolombRiceStatistics) |
---|
1558 | { |
---|
1559 | const UInt initialGolombRiceParameter = currentGolombRiceStatistic / RExt__GOLOMB_RICE_INCREMENT_DIVISOR; |
---|
1560 | |
---|
1561 | if (uiLevel >= (3 << initialGolombRiceParameter)) |
---|
1562 | { |
---|
1563 | currentGolombRiceStatistic++; |
---|
1564 | } |
---|
1565 | else if (((uiLevel * 2) < (1 << initialGolombRiceParameter)) && (currentGolombRiceStatistic > 0)) |
---|
1566 | { |
---|
1567 | currentGolombRiceStatistic--; |
---|
1568 | } |
---|
1569 | |
---|
1570 | updateGolombRiceStatistics = false; |
---|
1571 | } |
---|
1572 | } |
---|
1573 | |
---|
1574 | if(absCoeff[ idx ] >= 2) |
---|
1575 | { |
---|
1576 | iFirstCoeff2 = 0; |
---|
1577 | } |
---|
1578 | } |
---|
1579 | } |
---|
1580 | |
---|
1581 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
1582 | { |
---|
1583 | Int blkPos = pos[ idx ]; |
---|
1584 | // Signs applied later. |
---|
1585 | pcCoef[ blkPos ] = absCoeff[ idx ]; |
---|
1586 | absSum += absCoeff[ idx ]; |
---|
1587 | |
---|
1588 | if ( idx == numNonZero-1 && signHidden && beValid ) |
---|
1589 | { |
---|
1590 | // Infer sign of 1st element. |
---|
1591 | if (absSum&0x1) |
---|
1592 | { |
---|
1593 | pcCoef[ blkPos ] = -pcCoef[ blkPos ]; |
---|
1594 | } |
---|
1595 | } |
---|
1596 | else |
---|
1597 | { |
---|
1598 | Int sign = static_cast<Int>( coeffSigns ) >> 31; |
---|
1599 | pcCoef[ blkPos ] = ( pcCoef[ blkPos ] ^ sign ) - sign; |
---|
1600 | coeffSigns <<= 1; |
---|
1601 | } |
---|
1602 | } |
---|
1603 | } |
---|
1604 | } |
---|
1605 | |
---|
1606 | #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST |
---|
1607 | printSBACCoeffData(uiPosLastX, uiPosLastY, uiWidth, uiHeight, compID, uiAbsPartIdx, codingParameters.scanType, pcCoef); |
---|
1608 | #endif |
---|
1609 | |
---|
1610 | return; |
---|
1611 | } |
---|
1612 | |
---|
1613 | Void TDecSbac::parseSaoMaxUvlc ( UInt& val, UInt maxSymbol ) |
---|
1614 | { |
---|
1615 | if (maxSymbol == 0) |
---|
1616 | { |
---|
1617 | val = 0; |
---|
1618 | return; |
---|
1619 | } |
---|
1620 | |
---|
1621 | UInt code; |
---|
1622 | Int i; |
---|
1623 | m_pcTDecBinIf->decodeBinEP( code RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); |
---|
1624 | if ( code == 0 ) |
---|
1625 | { |
---|
1626 | val = 0; |
---|
1627 | return; |
---|
1628 | } |
---|
1629 | |
---|
1630 | i=1; |
---|
1631 | while (1) |
---|
1632 | { |
---|
1633 | m_pcTDecBinIf->decodeBinEP( code RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); |
---|
1634 | if ( code == 0 ) |
---|
1635 | { |
---|
1636 | break; |
---|
1637 | } |
---|
1638 | i++; |
---|
1639 | if (i == maxSymbol) |
---|
1640 | { |
---|
1641 | break; |
---|
1642 | } |
---|
1643 | } |
---|
1644 | |
---|
1645 | val = i; |
---|
1646 | } |
---|
1647 | |
---|
1648 | Void TDecSbac::parseSaoUflc (UInt uiLength, UInt& riVal) |
---|
1649 | { |
---|
1650 | m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); |
---|
1651 | } |
---|
1652 | |
---|
1653 | Void TDecSbac::parseSaoMerge (UInt& ruiVal) |
---|
1654 | { |
---|
1655 | UInt uiCode; |
---|
1656 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); |
---|
1657 | ruiVal = (Int)uiCode; |
---|
1658 | } |
---|
1659 | |
---|
1660 | Void TDecSbac::parseSaoTypeIdx (UInt& ruiVal) |
---|
1661 | { |
---|
1662 | UInt uiCode; |
---|
1663 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); |
---|
1664 | if (uiCode == 0) |
---|
1665 | { |
---|
1666 | ruiVal = 0; |
---|
1667 | } |
---|
1668 | else |
---|
1669 | { |
---|
1670 | m_pcTDecBinIf->decodeBinEP( uiCode RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); |
---|
1671 | if (uiCode == 0) |
---|
1672 | { |
---|
1673 | ruiVal = 1; |
---|
1674 | } |
---|
1675 | else |
---|
1676 | { |
---|
1677 | ruiVal = 2; |
---|
1678 | } |
---|
1679 | } |
---|
1680 | } |
---|
1681 | |
---|
1682 | Void TDecSbac::parseSaoSign(UInt& val) |
---|
1683 | { |
---|
1684 | m_pcTDecBinIf->decodeBinEP ( val RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); |
---|
1685 | } |
---|
1686 | |
---|
1687 | Void TDecSbac::parseSAOBlkParam (SAOBlkParam& saoBlkParam |
---|
1688 | #if SVC_EXTENSION |
---|
1689 | , UInt* saoMaxOffsetQVal |
---|
1690 | #endif |
---|
1691 | , Bool* sliceEnabled |
---|
1692 | , Bool leftMergeAvail |
---|
1693 | , Bool aboveMergeAvail |
---|
1694 | ) |
---|
1695 | { |
---|
1696 | UInt uiSymbol; |
---|
1697 | |
---|
1698 | Bool isLeftMerge = false; |
---|
1699 | Bool isAboveMerge= false; |
---|
1700 | |
---|
1701 | if(leftMergeAvail) |
---|
1702 | { |
---|
1703 | parseSaoMerge(uiSymbol); //sao_merge_left_flag |
---|
1704 | isLeftMerge = (uiSymbol?true:false); |
---|
1705 | } |
---|
1706 | |
---|
1707 | if( aboveMergeAvail && !isLeftMerge) |
---|
1708 | { |
---|
1709 | parseSaoMerge(uiSymbol); //sao_merge_up_flag |
---|
1710 | isAboveMerge = (uiSymbol?true:false); |
---|
1711 | } |
---|
1712 | |
---|
1713 | if(isLeftMerge || isAboveMerge) //merge mode |
---|
1714 | { |
---|
1715 | for (UInt componentIndex = 0; componentIndex < MAX_NUM_COMPONENT; componentIndex++) |
---|
1716 | { |
---|
1717 | saoBlkParam[componentIndex].modeIdc = (sliceEnabled[componentIndex]) ? SAO_MODE_MERGE : SAO_MODE_OFF; |
---|
1718 | saoBlkParam[componentIndex].typeIdc = (isLeftMerge)?SAO_MERGE_LEFT:SAO_MERGE_ABOVE; |
---|
1719 | } |
---|
1720 | } |
---|
1721 | else //new or off mode |
---|
1722 | { |
---|
1723 | for(Int compId=COMPONENT_Y; compId < MAX_NUM_COMPONENT; compId++) |
---|
1724 | { |
---|
1725 | const ComponentID compIdx=ComponentID(compId); |
---|
1726 | const ComponentID firstCompOfChType = getFirstComponentOfChannel(toChannelType(compIdx)); |
---|
1727 | SAOOffset& ctbParam = saoBlkParam[compIdx]; |
---|
1728 | |
---|
1729 | if(!sliceEnabled[compIdx]) |
---|
1730 | { |
---|
1731 | //off |
---|
1732 | ctbParam.modeIdc = SAO_MODE_OFF; |
---|
1733 | continue; |
---|
1734 | } |
---|
1735 | |
---|
1736 | //type |
---|
1737 | if(compIdx == firstCompOfChType) |
---|
1738 | { |
---|
1739 | parseSaoTypeIdx(uiSymbol); //sao_type_idx_luma or sao_type_idx_chroma |
---|
1740 | |
---|
1741 | assert(uiSymbol ==0 || uiSymbol ==1 || uiSymbol ==2); |
---|
1742 | |
---|
1743 | if(uiSymbol ==0) //OFF |
---|
1744 | { |
---|
1745 | ctbParam.modeIdc = SAO_MODE_OFF; |
---|
1746 | } |
---|
1747 | else if(uiSymbol == 1) //BO |
---|
1748 | { |
---|
1749 | ctbParam.modeIdc = SAO_MODE_NEW; |
---|
1750 | ctbParam.typeIdc = SAO_TYPE_START_BO; |
---|
1751 | } |
---|
1752 | else //2, EO |
---|
1753 | { |
---|
1754 | ctbParam.modeIdc = SAO_MODE_NEW; |
---|
1755 | ctbParam.typeIdc = SAO_TYPE_START_EO; |
---|
1756 | } |
---|
1757 | |
---|
1758 | } |
---|
1759 | else //Cr, follow Cb SAO type |
---|
1760 | { |
---|
1761 | ctbParam.modeIdc = saoBlkParam[COMPONENT_Cb].modeIdc; |
---|
1762 | ctbParam.typeIdc = saoBlkParam[COMPONENT_Cb].typeIdc; |
---|
1763 | } |
---|
1764 | |
---|
1765 | if(ctbParam.modeIdc == SAO_MODE_NEW) |
---|
1766 | { |
---|
1767 | #if O0043_BEST_EFFORT_DECODING |
---|
1768 | Int bitDepthOrig = g_bitDepthInStream[toChannelType(compIdx)]; |
---|
1769 | Int forceBitDepthAdjust = bitDepthOrig - g_bitDepth[toChannelType(compIdx)]; |
---|
1770 | #endif |
---|
1771 | Int offset[4]; |
---|
1772 | for(Int i=0; i< 4; i++) |
---|
1773 | { |
---|
1774 | #if SVC_EXTENSION |
---|
1775 | parseSaoMaxUvlc(uiSymbol, saoMaxOffsetQVal[compIdx] ); //sao_offset_abs |
---|
1776 | #else |
---|
1777 | #if O0043_BEST_EFFORT_DECODING |
---|
1778 | Int saoMaxOffsetQVal = (1<<(min(bitDepthOrig, MAX_SAO_TRUNCATED_BITDEPTH)-5))-1; |
---|
1779 | parseSaoMaxUvlc(uiSymbol, saoMaxOffsetQVal); //sao_offset_abs |
---|
1780 | #else |
---|
1781 | parseSaoMaxUvlc(uiSymbol, g_saoMaxOffsetQVal[compIdx] ); //sao_offset_abs |
---|
1782 | #endif |
---|
1783 | #endif |
---|
1784 | offset[i] = (Int)uiSymbol; |
---|
1785 | } |
---|
1786 | |
---|
1787 | if(ctbParam.typeIdc == SAO_TYPE_START_BO) |
---|
1788 | { |
---|
1789 | for(Int i=0; i< 4; i++) |
---|
1790 | { |
---|
1791 | if(offset[i] != 0) |
---|
1792 | { |
---|
1793 | parseSaoSign(uiSymbol); //sao_offset_sign |
---|
1794 | if(uiSymbol) |
---|
1795 | { |
---|
1796 | #if O0043_BEST_EFFORT_DECODING |
---|
1797 | offset[i] >>= forceBitDepthAdjust; |
---|
1798 | #endif |
---|
1799 | offset[i] = -offset[i]; |
---|
1800 | } |
---|
1801 | } |
---|
1802 | } |
---|
1803 | parseSaoUflc(NUM_SAO_BO_CLASSES_LOG2, uiSymbol ); //sao_band_position |
---|
1804 | ctbParam.typeAuxInfo = uiSymbol; |
---|
1805 | |
---|
1806 | for(Int i=0; i<4; i++) |
---|
1807 | { |
---|
1808 | ctbParam.offset[(ctbParam.typeAuxInfo+i)%MAX_NUM_SAO_CLASSES] = offset[i]; |
---|
1809 | } |
---|
1810 | |
---|
1811 | } |
---|
1812 | else //EO |
---|
1813 | { |
---|
1814 | ctbParam.typeAuxInfo = 0; |
---|
1815 | |
---|
1816 | if(firstCompOfChType == compIdx) |
---|
1817 | { |
---|
1818 | parseSaoUflc(NUM_SAO_EO_TYPES_LOG2, uiSymbol ); //sao_eo_class_luma or sao_eo_class_chroma |
---|
1819 | ctbParam.typeIdc += uiSymbol; |
---|
1820 | } |
---|
1821 | else |
---|
1822 | { |
---|
1823 | ctbParam.typeIdc = saoBlkParam[firstCompOfChType].typeIdc; |
---|
1824 | } |
---|
1825 | ctbParam.offset[SAO_CLASS_EO_FULL_VALLEY] = offset[0]; |
---|
1826 | ctbParam.offset[SAO_CLASS_EO_HALF_VALLEY] = offset[1]; |
---|
1827 | ctbParam.offset[SAO_CLASS_EO_PLAIN ] = 0; |
---|
1828 | ctbParam.offset[SAO_CLASS_EO_HALF_PEAK ] = -offset[2]; |
---|
1829 | ctbParam.offset[SAO_CLASS_EO_FULL_PEAK ] = -offset[3]; |
---|
1830 | } |
---|
1831 | } |
---|
1832 | } |
---|
1833 | } |
---|
1834 | } |
---|
1835 | |
---|
1836 | /** |
---|
1837 | - Initialize our contexts from the nominated source. |
---|
1838 | . |
---|
1839 | \param pSrc Contexts to be copied. |
---|
1840 | */ |
---|
1841 | Void TDecSbac::xCopyContextsFrom( const TDecSbac* pSrc ) |
---|
1842 | { |
---|
1843 | memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0])); |
---|
1844 | memcpy(m_golombRiceAdaptationStatistics, pSrc->m_golombRiceAdaptationStatistics, (sizeof(UInt) * RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS)); |
---|
1845 | } |
---|
1846 | |
---|
1847 | Void TDecSbac::xCopyFrom( const TDecSbac* pSrc ) |
---|
1848 | { |
---|
1849 | m_pcTDecBinIf->copyState( pSrc->m_pcTDecBinIf ); |
---|
1850 | xCopyContextsFrom( pSrc ); |
---|
1851 | } |
---|
1852 | |
---|
1853 | Void TDecSbac::load ( const TDecSbac* pSrc ) |
---|
1854 | { |
---|
1855 | xCopyFrom(pSrc); |
---|
1856 | } |
---|
1857 | |
---|
1858 | Void TDecSbac::loadContexts ( const TDecSbac* pSrc ) |
---|
1859 | { |
---|
1860 | xCopyContextsFrom(pSrc); |
---|
1861 | } |
---|
1862 | |
---|
1863 | /** Performs CABAC decoding of the explicit RDPCM mode |
---|
1864 | * \param rTu current TU data structure |
---|
1865 | * \param compID component identifier |
---|
1866 | */ |
---|
1867 | Void TDecSbac::parseExplicitRdpcmMode( TComTU &rTu, ComponentID compID ) |
---|
1868 | { |
---|
1869 | TComDataCU* cu = rTu.getCU(); |
---|
1870 | const UInt absPartIdx=rTu.GetAbsPartIdxTU(compID); |
---|
1871 | const TComRectangle &rect = rTu.getRect(compID); |
---|
1872 | const UInt tuHeight = g_aucConvertToBit[rect.height]; |
---|
1873 | const UInt tuWidth = g_aucConvertToBit[rect.width]; |
---|
1874 | UInt code = 0; |
---|
1875 | |
---|
1876 | assert(tuHeight == tuWidth); |
---|
1877 | |
---|
1878 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
1879 | const TComCodingStatisticsClassType ctype(STATS__EXPLICIT_RDPCM_BITS, g_aucConvertToBit[g_uiMaxCUWidth>>rTu.GetTransformDepthTotal()]+2); |
---|
1880 | #endif |
---|
1881 | |
---|
1882 | m_pcTDecBinIf->decodeBin(code, m_explicitRdpcmFlagSCModel.get (0, toChannelType(compID), 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype)); |
---|
1883 | |
---|
1884 | if(code == 0) |
---|
1885 | { |
---|
1886 | cu->setExplicitRdpcmModePartRange( RDPCM_OFF, compID, absPartIdx, rTu.GetAbsPartIdxNumParts(compID)); |
---|
1887 | } |
---|
1888 | else |
---|
1889 | { |
---|
1890 | m_pcTDecBinIf->decodeBin(code, m_explicitRdpcmDirSCModel.get (0, toChannelType(compID), 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype)); |
---|
1891 | if(code == 0) |
---|
1892 | { |
---|
1893 | cu->setExplicitRdpcmModePartRange( RDPCM_HOR, compID, absPartIdx, rTu.GetAbsPartIdxNumParts(compID)); |
---|
1894 | } |
---|
1895 | else |
---|
1896 | { |
---|
1897 | cu->setExplicitRdpcmModePartRange( RDPCM_VER, compID, absPartIdx, rTu.GetAbsPartIdxNumParts(compID)); |
---|
1898 | } |
---|
1899 | } |
---|
1900 | } |
---|
1901 | |
---|
1902 | |
---|
1903 | //! \} |
---|