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