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