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