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