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