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-2012, 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 | #if RWTH_SDC_DLT_B0036 |
---|
41 | #define GetNumDepthValues() (pcCU->getSlice()->getSPS()->getNumDepthValues()) |
---|
42 | #define GetBitsPerDepthValue() (pcCU->getSlice()->getSPS()->getBitsPerDepthValue()) |
---|
43 | #endif |
---|
44 | |
---|
45 | //! \ingroup TLibDecoder |
---|
46 | //! \{ |
---|
47 | |
---|
48 | ////////////////////////////////////////////////////////////////////// |
---|
49 | // Construction/Destruction |
---|
50 | ////////////////////////////////////////////////////////////////////// |
---|
51 | |
---|
52 | TDecSbac::TDecSbac() |
---|
53 | // new structure here |
---|
54 | : m_pcBitstream ( 0 ) |
---|
55 | , m_pcTDecBinIf ( NULL ) |
---|
56 | , m_numContextModels ( 0 ) |
---|
57 | , m_cCUSplitFlagSCModel ( 1, 1, NUM_SPLIT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels ) |
---|
58 | , m_cCUSkipFlagSCModel ( 1, 1, NUM_SKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
59 | #if LGE_ILLUCOMP_B0045 |
---|
60 | , m_cCUICFlagSCModel ( 1, 1, NUM_IC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
61 | #endif |
---|
62 | , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
63 | , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
64 | #if H3D_IVRP |
---|
65 | , m_cResPredFlagSCModel ( 1, 1, NUM_RES_PRED_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
66 | #endif |
---|
67 | , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
68 | , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
69 | , m_cCUAlfCtrlFlagSCModel ( 1, 1, NUM_ALF_CTRL_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
70 | , m_cCUIntraPredSCModel ( 1, 1, NUM_ADI_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
71 | , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
72 | , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
73 | , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
74 | , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
75 | , m_cCUMvdSCModel ( 1, 1, NUM_MV_RES_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
76 | , m_cCUQtCbfSCModel ( 1, 2, NUM_QT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
77 | , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
78 | , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
79 | , m_cCUSigCoeffGroupSCModel ( 1, 2, NUM_SIG_CG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
80 | , m_cCUSigSCModel ( 1, 1, NUM_SIG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
81 | , m_cCuCtxLastX ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
82 | , m_cCuCtxLastY ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
83 | , m_cCUOneSCModel ( 1, 1, NUM_ONE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
84 | , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
85 | , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
86 | , m_cALFFlagSCModel ( 1, 1, NUM_ALF_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
87 | , m_cALFUvlcSCModel ( 1, 1, NUM_ALF_UVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
88 | , m_cALFSvlcSCModel ( 1, 1, NUM_ALF_SVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
89 | , m_cCUAMPSCModel ( 1, 1, NUM_CU_AMP_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
90 | , m_cSaoFlagSCModel ( 1, 1, NUM_SAO_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
91 | , m_cSaoUvlcSCModel ( 1, 1, NUM_SAO_UVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
92 | , m_cSaoSvlcSCModel ( 1, 1, NUM_SAO_SVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
93 | , m_cSaoMergeLeftSCModel ( 1, 1, NUM_SAO_MERGE_LEFT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
94 | , m_cSaoMergeUpSCModel ( 1, 1, NUM_SAO_MERGE_UP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
95 | , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
96 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
97 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
98 | , m_cDmmFlagSCModel ( 1, 1, NUM_DMM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
99 | , m_cDmmModeSCModel ( 1, 1, NUM_DMM_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
100 | #endif |
---|
101 | , m_cDmmDataSCModel ( 1, 1, NUM_DMM_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
102 | #endif |
---|
103 | #if LGE_EDGE_INTRA_A0070 |
---|
104 | , m_cEdgeIntraSCModel ( 1, 1, NUM_EDGE_INTRA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
105 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
106 | , m_cEdgeIntraDeltaDCSCModel ( 1, 1, NUM_EDGE_INTRA_DELTA_DC_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
107 | #endif |
---|
108 | #endif |
---|
109 | #if RWTH_SDC_DLT_B0036 |
---|
110 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
111 | , m_cSDCFlagSCModel ( 1, 1, SDC_NUM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
112 | #else |
---|
113 | , m_cDepthModeModel ( 1, 1, DEPTH_MODE_NUM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
114 | , m_cDmmDeltaFlagModel ( 1, 1, DMM_DELTA_NUM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
115 | #endif |
---|
116 | , m_cSDCResidualFlagSCModel ( 1, 2, SDC_NUM_RESIDUAL_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
117 | , m_cSDCResidualSignFlagSCModel ( 1, 2, SDC_NUM_SIGN_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
118 | , m_cSDCResidualSCModel ( 1, 2, SDC_NUM_RESIDUAL_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
119 | , m_cSDCPredModeSCModel ( 1, 3, SDC_NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
120 | #endif |
---|
121 | { |
---|
122 | assert( m_numContextModels <= MAX_NUM_CTX_MOD ); |
---|
123 | m_iSliceGranularity = 0; |
---|
124 | } |
---|
125 | |
---|
126 | TDecSbac::~TDecSbac() |
---|
127 | { |
---|
128 | } |
---|
129 | |
---|
130 | // ==================================================================================================================== |
---|
131 | // Public member functions |
---|
132 | // ==================================================================================================================== |
---|
133 | |
---|
134 | #if CABAC_INIT_FLAG |
---|
135 | Void TDecSbac::resetEntropy(TComSlice* pSlice) |
---|
136 | { |
---|
137 | SliceType sliceType = pSlice->getSliceType(); |
---|
138 | Int qp = pSlice->getSliceQp(); |
---|
139 | |
---|
140 | if (pSlice->getPPS()->getCabacInitPresentFlag() && pSlice->getCabacInitFlag()) |
---|
141 | { |
---|
142 | switch (sliceType) |
---|
143 | { |
---|
144 | case P_SLICE: // change initialization table to B_SLICE initialization |
---|
145 | sliceType = B_SLICE; |
---|
146 | break; |
---|
147 | case B_SLICE: // change initialization table to P_SLICE initialization |
---|
148 | sliceType = P_SLICE; |
---|
149 | break; |
---|
150 | default : // should not occur |
---|
151 | assert(0); |
---|
152 | } |
---|
153 | } |
---|
154 | |
---|
155 | #else |
---|
156 | Void TDecSbac::resetEntropywithQPandInitIDC (Int qp, Int iID) |
---|
157 | { |
---|
158 | SliceType sliceType = (SliceType)iID; |
---|
159 | #endif |
---|
160 | |
---|
161 | m_cCUSplitFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG ); |
---|
162 | m_cCUSkipFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SKIP_FLAG ); |
---|
163 | #if LGE_ILLUCOMP_B0045 |
---|
164 | m_cCUICFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_IC_FLAG ); |
---|
165 | #endif |
---|
166 | m_cCUMergeFlagExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
167 | m_cCUMergeIdxExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
168 | #if H3D_IVRP |
---|
169 | m_cResPredFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_RES_PRED_FLAG ); |
---|
170 | #endif |
---|
171 | m_cCUAlfCtrlFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ALF_CTRL_FLAG ); |
---|
172 | m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); |
---|
173 | m_cCUAMPSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CU_AMP_POS ); |
---|
174 | m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); |
---|
175 | m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
176 | m_cCUChromaPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
177 | m_cCUInterDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_DIR ); |
---|
178 | m_cCUMvdSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVD ); |
---|
179 | m_cCURefPicSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_REF_PIC ); |
---|
180 | m_cCUDeltaQpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DQP ); |
---|
181 | m_cCUQtCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_CBF ); |
---|
182 | m_cCUQtRootCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
183 | m_cCUSigCoeffGroupSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
184 | m_cCUSigSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_FLAG ); |
---|
185 | m_cCuCtxLastX.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
186 | m_cCuCtxLastY.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
187 | m_cCUOneSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ONE_FLAG ); |
---|
188 | m_cCUAbsSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ABS_FLAG ); |
---|
189 | m_cMVPIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVP_IDX ); |
---|
190 | m_cALFFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ALF_FLAG ); |
---|
191 | m_cALFUvlcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ALF_UVLC ); |
---|
192 | m_cALFSvlcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ALF_SVLC ); |
---|
193 | m_cSaoFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_FLAG ); |
---|
194 | m_cSaoUvlcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_UVLC ); |
---|
195 | m_cSaoSvlcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_SVLC ); |
---|
196 | m_cSaoMergeLeftSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG ); |
---|
197 | m_cSaoMergeUpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_UP_FLAG ); |
---|
198 | m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
199 | |
---|
200 | m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
201 | #if LGE_EDGE_INTRA_A0070 |
---|
202 | m_cEdgeIntraSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_EDGE_INTRA ); |
---|
203 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
204 | m_cEdgeIntraDeltaDCSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_EDGE_INTRA_DELTA_DC ); |
---|
205 | #endif |
---|
206 | #endif |
---|
207 | m_uiLastDQpNonZero = 0; |
---|
208 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
209 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
210 | m_cDmmFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM_FLAG ); |
---|
211 | m_cDmmModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM_MODE ); |
---|
212 | #endif |
---|
213 | m_cDmmDataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM_DATA ); |
---|
214 | #endif |
---|
215 | #if RWTH_SDC_DLT_B0036 |
---|
216 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
217 | m_cSDCFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_FLAG ); |
---|
218 | #else |
---|
219 | m_cDepthModeModel.initBuffer ( sliceType, qp, (UChar*)INIT_DEPTHMODE_FLAG ); |
---|
220 | m_cDmmDeltaFlagModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMMDELTA_FLAG ); |
---|
221 | #endif |
---|
222 | m_cSDCResidualFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); |
---|
223 | m_cSDCResidualSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL ); |
---|
224 | m_cSDCResidualSignFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_SIGN_FLAG ); |
---|
225 | m_cSDCPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_PRED_MODE ); |
---|
226 | #endif |
---|
227 | |
---|
228 | // new structure |
---|
229 | m_uiLastQp = qp; |
---|
230 | |
---|
231 | m_pcTDecBinIf->start(); |
---|
232 | } |
---|
233 | |
---|
234 | /** The function does the following: Read out terminate bit. Flush CABAC. Byte-align for next tile. |
---|
235 | * Intialize CABAC states. Start CABAC. |
---|
236 | */ |
---|
237 | Void TDecSbac::updateContextTables( SliceType eSliceType, Int iQp ) |
---|
238 | { |
---|
239 | UInt uiBit; |
---|
240 | m_pcTDecBinIf->decodeBinTrm(uiBit); |
---|
241 | m_pcTDecBinIf->finish(); |
---|
242 | #if !OL_FLUSH_ALIGN |
---|
243 | // Account for misaligned CABAC. |
---|
244 | Int iCABACReadAhead = m_pcTDecBinIf->getBitsReadAhead(); |
---|
245 | iCABACReadAhead--; |
---|
246 | Int iStreamBits = 8-m_pcBitstream->getNumBitsUntilByteAligned(); |
---|
247 | if (iCABACReadAhead >= iStreamBits) |
---|
248 | { |
---|
249 | // Misaligned CABAC has read into the 1st byte of the next tile. |
---|
250 | // Back up a byte prior to alignment. |
---|
251 | m_pcBitstream->backupByte(); |
---|
252 | } |
---|
253 | #endif |
---|
254 | m_pcBitstream->readOutTrailingBits(); |
---|
255 | m_cCUSplitFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG ); |
---|
256 | m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG ); |
---|
257 | #if LGE_ILLUCOMP_B0045 |
---|
258 | m_cCUICFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_IC_FLAG ); |
---|
259 | #endif |
---|
260 | m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
261 | m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
262 | #if H3D_IVRP |
---|
263 | m_cResPredFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_RES_PRED_FLAG ); |
---|
264 | #endif |
---|
265 | m_cCUAlfCtrlFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_CTRL_FLAG ); |
---|
266 | m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); |
---|
267 | m_cCUAMPSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS ); |
---|
268 | m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); |
---|
269 | m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
270 | m_cCUChromaPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
271 | m_cCUInterDirSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_DIR ); |
---|
272 | m_cCUMvdSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVD ); |
---|
273 | m_cCURefPicSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_REF_PIC ); |
---|
274 | m_cCUDeltaQpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DQP ); |
---|
275 | m_cCUQtCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_CBF ); |
---|
276 | m_cCUQtRootCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
277 | m_cCUSigCoeffGroupSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
278 | m_cCUSigSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_FLAG ); |
---|
279 | m_cCuCtxLastX.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
280 | m_cCuCtxLastY.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
281 | m_cCUOneSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ONE_FLAG ); |
---|
282 | m_cCUAbsSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG ); |
---|
283 | m_cMVPIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVP_IDX ); |
---|
284 | m_cALFFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_FLAG ); |
---|
285 | m_cALFUvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_UVLC ); |
---|
286 | m_cALFSvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_SVLC ); |
---|
287 | m_cSaoFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_FLAG ); |
---|
288 | m_cSaoUvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_UVLC ); |
---|
289 | m_cSaoSvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_SVLC ); |
---|
290 | m_cSaoMergeLeftSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG ); |
---|
291 | m_cSaoMergeUpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_UP_FLAG ); |
---|
292 | m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
293 | m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
294 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
295 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
296 | m_cDmmFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_FLAG ); |
---|
297 | m_cDmmModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_MODE ); |
---|
298 | #endif |
---|
299 | m_cDmmDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_DATA ); |
---|
300 | #endif |
---|
301 | #if RWTH_SDC_DLT_B0036 |
---|
302 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
303 | m_cSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG ); |
---|
304 | #else |
---|
305 | m_cDepthModeModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DEPTHMODE_FLAG ); |
---|
306 | m_cDmmDeltaFlagModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMMDELTA_FLAG ); |
---|
307 | #endif |
---|
308 | m_cSDCResidualFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); |
---|
309 | m_cSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL ); |
---|
310 | m_cSDCResidualSignFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_SIGN_FLAG ); |
---|
311 | m_cSDCPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_PRED_MODE ); |
---|
312 | #endif |
---|
313 | |
---|
314 | m_pcTDecBinIf->start(); |
---|
315 | } |
---|
316 | |
---|
317 | Void TDecSbac::readTileMarker( UInt& uiTileIdx, UInt uiBitsUsed ) |
---|
318 | { |
---|
319 | UInt uiSymbol; |
---|
320 | uiTileIdx = 0; |
---|
321 | for (Int iShift=uiBitsUsed-1; iShift>=0; iShift--) |
---|
322 | { |
---|
323 | m_pcTDecBinIf->decodeBinEP ( uiSymbol ); |
---|
324 | if (uiSymbol) |
---|
325 | { |
---|
326 | uiTileIdx |= (1<<iShift); |
---|
327 | } |
---|
328 | } |
---|
329 | } |
---|
330 | |
---|
331 | Void TDecSbac::parseTerminatingBit( UInt& ruiBit ) |
---|
332 | { |
---|
333 | m_pcTDecBinIf->decodeBinTrm( ruiBit ); |
---|
334 | } |
---|
335 | |
---|
336 | |
---|
337 | Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ) |
---|
338 | { |
---|
339 | if (uiMaxSymbol == 0) |
---|
340 | { |
---|
341 | ruiSymbol = 0; |
---|
342 | return; |
---|
343 | } |
---|
344 | |
---|
345 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
346 | |
---|
347 | if( ruiSymbol == 0 || uiMaxSymbol == 1 ) |
---|
348 | { |
---|
349 | return; |
---|
350 | } |
---|
351 | |
---|
352 | UInt uiSymbol = 0; |
---|
353 | UInt uiCont; |
---|
354 | |
---|
355 | do |
---|
356 | { |
---|
357 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
358 | uiSymbol++; |
---|
359 | } |
---|
360 | while( uiCont && ( uiSymbol < uiMaxSymbol - 1 ) ); |
---|
361 | |
---|
362 | if( uiCont && ( uiSymbol == uiMaxSymbol - 1 ) ) |
---|
363 | { |
---|
364 | uiSymbol++; |
---|
365 | } |
---|
366 | |
---|
367 | ruiSymbol = uiSymbol; |
---|
368 | } |
---|
369 | |
---|
370 | Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount ) |
---|
371 | { |
---|
372 | UInt uiSymbol = 0; |
---|
373 | UInt uiBit = 1; |
---|
374 | |
---|
375 | while( uiBit ) |
---|
376 | { |
---|
377 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
378 | uiSymbol += uiBit << uiCount++; |
---|
379 | } |
---|
380 | |
---|
381 | if ( --uiCount ) |
---|
382 | { |
---|
383 | UInt bins; |
---|
384 | m_pcTDecBinIf->decodeBinsEP( bins, uiCount ); |
---|
385 | uiSymbol += bins; |
---|
386 | } |
---|
387 | |
---|
388 | ruiSymbol = uiSymbol; |
---|
389 | } |
---|
390 | |
---|
391 | Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ) |
---|
392 | { |
---|
393 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
394 | |
---|
395 | if( !ruiSymbol ) |
---|
396 | { |
---|
397 | return; |
---|
398 | } |
---|
399 | |
---|
400 | UInt uiSymbol = 0; |
---|
401 | UInt uiCont; |
---|
402 | |
---|
403 | do |
---|
404 | { |
---|
405 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
406 | uiSymbol++; |
---|
407 | } |
---|
408 | while( uiCont ); |
---|
409 | |
---|
410 | ruiSymbol = uiSymbol; |
---|
411 | } |
---|
412 | |
---|
413 | /** Parsing of coeff_abs_level_minus3 |
---|
414 | * \param ruiSymbol reference to coeff_abs_level_minus3 |
---|
415 | * \param ruiGoRiceParam reference to Rice parameter |
---|
416 | * \returns Void |
---|
417 | */ |
---|
418 | Void TDecSbac::xReadGoRiceExGolomb( UInt &ruiSymbol, UInt &ruiGoRiceParam ) |
---|
419 | { |
---|
420 | Bool bExGolomb = false; |
---|
421 | UInt uiCodeWord = 0; |
---|
422 | UInt uiQuotient = 0; |
---|
423 | UInt uiRemainder = 0; |
---|
424 | UInt uiMaxVlc = g_auiGoRiceRange[ ruiGoRiceParam ]; |
---|
425 | UInt uiMaxPreLen = g_auiGoRicePrefixLen[ ruiGoRiceParam ]; |
---|
426 | |
---|
427 | do |
---|
428 | { |
---|
429 | uiQuotient++; |
---|
430 | m_pcTDecBinIf->decodeBinEP( uiCodeWord ); |
---|
431 | } |
---|
432 | while( uiCodeWord && uiQuotient < uiMaxPreLen ); |
---|
433 | |
---|
434 | uiCodeWord = 1 - uiCodeWord; |
---|
435 | uiQuotient -= uiCodeWord; |
---|
436 | |
---|
437 | if ( ruiGoRiceParam > 0 ) |
---|
438 | { |
---|
439 | m_pcTDecBinIf->decodeBinsEP( uiRemainder, ruiGoRiceParam ); |
---|
440 | } |
---|
441 | |
---|
442 | ruiSymbol = uiRemainder + ( uiQuotient << ruiGoRiceParam ); |
---|
443 | bExGolomb = ruiSymbol == ( uiMaxVlc + 1 ); |
---|
444 | |
---|
445 | if( bExGolomb ) |
---|
446 | { |
---|
447 | xReadEpExGolomb( uiCodeWord, 0 ); |
---|
448 | ruiSymbol += uiCodeWord; |
---|
449 | } |
---|
450 | |
---|
451 | ruiGoRiceParam = g_aauiGoRiceUpdate[ ruiGoRiceParam ][ min<UInt>( ruiSymbol, 23 ) ]; |
---|
452 | |
---|
453 | return; |
---|
454 | } |
---|
455 | |
---|
456 | |
---|
457 | /** Parse I_PCM information. |
---|
458 | * \param pcCU |
---|
459 | * \param uiAbsPartIdx |
---|
460 | * \param uiDepth |
---|
461 | * \returns Void |
---|
462 | * |
---|
463 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
464 | */ |
---|
465 | Void TDecSbac::parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
466 | { |
---|
467 | UInt uiSymbol; |
---|
468 | Int numSubseqIPCM = 0; |
---|
469 | Bool readPCMSampleFlag = false; |
---|
470 | |
---|
471 | if(pcCU->getNumSucIPCM() > 0) |
---|
472 | { |
---|
473 | readPCMSampleFlag = true; |
---|
474 | } |
---|
475 | else |
---|
476 | { |
---|
477 | m_pcTDecBinIf->decodeBinTrm(uiSymbol); |
---|
478 | |
---|
479 | if (uiSymbol) |
---|
480 | { |
---|
481 | readPCMSampleFlag = true; |
---|
482 | m_pcTDecBinIf->decodeNumSubseqIPCM(numSubseqIPCM); |
---|
483 | pcCU->setNumSucIPCM(numSubseqIPCM + 1); |
---|
484 | m_pcTDecBinIf->decodePCMAlignBits(); |
---|
485 | } |
---|
486 | } |
---|
487 | |
---|
488 | if (readPCMSampleFlag == true) |
---|
489 | { |
---|
490 | Bool bIpcmFlag = true; |
---|
491 | |
---|
492 | |
---|
493 | pcCU->setPartSizeSubParts ( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
494 | pcCU->setSizeSubParts ( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
495 | pcCU->setIPCMFlagSubParts ( bIpcmFlag, uiAbsPartIdx, uiDepth ); |
---|
496 | |
---|
497 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
498 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
499 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
500 | |
---|
501 | Pel* piPCMSample; |
---|
502 | UInt uiWidth; |
---|
503 | UInt uiHeight; |
---|
504 | UInt uiSampleBits; |
---|
505 | UInt uiX, uiY; |
---|
506 | |
---|
507 | piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; |
---|
508 | uiWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
509 | uiHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
510 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
511 | |
---|
512 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
513 | { |
---|
514 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
515 | { |
---|
516 | UInt uiSample; |
---|
517 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
518 | piPCMSample[uiX] = uiSample; |
---|
519 | } |
---|
520 | piPCMSample += uiWidth; |
---|
521 | } |
---|
522 | |
---|
523 | piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; |
---|
524 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
525 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
526 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
527 | |
---|
528 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
529 | { |
---|
530 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
531 | { |
---|
532 | UInt uiSample; |
---|
533 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
534 | piPCMSample[uiX] = uiSample; |
---|
535 | } |
---|
536 | piPCMSample += uiWidth; |
---|
537 | } |
---|
538 | |
---|
539 | piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; |
---|
540 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
541 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
542 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
543 | |
---|
544 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
545 | { |
---|
546 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
547 | { |
---|
548 | UInt uiSample; |
---|
549 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
550 | piPCMSample[uiX] = uiSample; |
---|
551 | } |
---|
552 | piPCMSample += uiWidth; |
---|
553 | } |
---|
554 | |
---|
555 | pcCU->setNumSucIPCM( pcCU->getNumSucIPCM() - 1); |
---|
556 | if(pcCU->getNumSucIPCM() == 0) |
---|
557 | { |
---|
558 | m_pcTDecBinIf->resetBac(); |
---|
559 | } |
---|
560 | } |
---|
561 | } |
---|
562 | |
---|
563 | /** parse skip flag |
---|
564 | * \param pcCU |
---|
565 | * \param uiAbsPartIdx |
---|
566 | * \param uiDepth |
---|
567 | * \returns Void |
---|
568 | */ |
---|
569 | Void TDecSbac::parseSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
570 | { |
---|
571 | if( pcCU->getSlice()->isIntra() ) |
---|
572 | { |
---|
573 | return; |
---|
574 | } |
---|
575 | |
---|
576 | UInt uiSymbol = 0; |
---|
577 | UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx ); |
---|
578 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) ); |
---|
579 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
580 | DTRACE_CABAC_T( "\tSkipFlag" ); |
---|
581 | DTRACE_CABAC_T( "\tuiCtxSkip: "); |
---|
582 | DTRACE_CABAC_V( uiCtxSkip ); |
---|
583 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
584 | DTRACE_CABAC_V( uiSymbol ); |
---|
585 | DTRACE_CABAC_T( "\n"); |
---|
586 | |
---|
587 | if( uiSymbol ) |
---|
588 | { |
---|
589 | pcCU->setPredModeSubParts( MODE_SKIP, uiAbsPartIdx, uiDepth ); |
---|
590 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
591 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
592 | pcCU->setMergeFlagSubParts( true , uiAbsPartIdx, 0, uiDepth ); |
---|
593 | } |
---|
594 | } |
---|
595 | |
---|
596 | #if LGE_ILLUCOMP_B0045 |
---|
597 | /** parse illumination compensation flag |
---|
598 | * \param pcCU |
---|
599 | * \param uiAbsPartIdx |
---|
600 | * \param uiDepth |
---|
601 | * \returns Void |
---|
602 | */ |
---|
603 | Void TDecSbac::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
604 | { |
---|
605 | UInt uiSymbol = 0; |
---|
606 | UInt uiCtxIC = pcCU->getCtxICFlag( uiAbsPartIdx ); |
---|
607 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, uiCtxIC ) ); |
---|
608 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
609 | DTRACE_CABAC_T( "\tICFlag" ); |
---|
610 | DTRACE_CABAC_T( "\tuiCtxIC: "); |
---|
611 | DTRACE_CABAC_V( uiCtxIC ); |
---|
612 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
613 | DTRACE_CABAC_V( uiSymbol ); |
---|
614 | DTRACE_CABAC_T( "\n"); |
---|
615 | |
---|
616 | pcCU->setICFlagSubParts( uiSymbol ? true : false , uiAbsPartIdx, 0, uiDepth ); |
---|
617 | } |
---|
618 | #endif |
---|
619 | |
---|
620 | |
---|
621 | /** parse merge flag |
---|
622 | * \param pcCU |
---|
623 | * \param uiAbsPartIdx |
---|
624 | * \param uiDepth |
---|
625 | * \param uiPUIdx |
---|
626 | * \returns Void |
---|
627 | */ |
---|
628 | Void TDecSbac::parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
629 | { |
---|
630 | UInt uiSymbol; |
---|
631 | m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) ); |
---|
632 | pcCU->setMergeFlagSubParts( uiSymbol ? true : false, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
633 | |
---|
634 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
635 | DTRACE_CABAC_T( "\tMergeFlag: " ); |
---|
636 | DTRACE_CABAC_V( uiSymbol ); |
---|
637 | DTRACE_CABAC_T( "\tAddress: " ); |
---|
638 | DTRACE_CABAC_V( pcCU->getAddr() ); |
---|
639 | DTRACE_CABAC_T( "\tuiAbsPartIdx: " ); |
---|
640 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
641 | DTRACE_CABAC_T( "\n" ); |
---|
642 | } |
---|
643 | |
---|
644 | Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
645 | { |
---|
646 | UInt uiNumCand = MRG_MAX_NUM_CANDS; |
---|
647 | UInt uiUnaryIdx = 0; |
---|
648 | uiNumCand = pcCU->getSlice()->getMaxNumMergeCand(); |
---|
649 | #if HHI_MPI |
---|
650 | const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE; |
---|
651 | const UInt uiMviMergePos = bMVIAvailable ? HHI_MPI_MERGE_POS : uiNumCand; |
---|
652 | #endif |
---|
653 | if ( uiNumCand > 1 ) |
---|
654 | { |
---|
655 | for( ; uiUnaryIdx < uiNumCand - 1; ++uiUnaryIdx ) |
---|
656 | { |
---|
657 | UInt uiSymbol = 0; |
---|
658 | if ( uiUnaryIdx==0 ) |
---|
659 | { |
---|
660 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) ); |
---|
661 | } |
---|
662 | else |
---|
663 | { |
---|
664 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
665 | } |
---|
666 | if( uiSymbol == 0 ) |
---|
667 | { |
---|
668 | break; |
---|
669 | } |
---|
670 | } |
---|
671 | } |
---|
672 | ruiMergeIndex = uiUnaryIdx; |
---|
673 | |
---|
674 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
675 | DTRACE_CABAC_T( "\tparseMergeIndex()" ) |
---|
676 | DTRACE_CABAC_T( "\tuiMRGIdx= " ) |
---|
677 | DTRACE_CABAC_V( ruiMergeIndex ) |
---|
678 | DTRACE_CABAC_T( "\n" ) |
---|
679 | #if HHI_MPI |
---|
680 | if( ruiMergeIndex > uiMviMergePos ) |
---|
681 | { |
---|
682 | assert( bMVIAvailable ); |
---|
683 | ruiMergeIndex--; |
---|
684 | } |
---|
685 | else if( ruiMergeIndex == uiMviMergePos ) |
---|
686 | { |
---|
687 | assert( bMVIAvailable ); |
---|
688 | pcCU->setTextureModeDepthSubParts( uiDepth, uiAbsPartIdx, uiDepth ); |
---|
689 | } |
---|
690 | #endif |
---|
691 | } |
---|
692 | |
---|
693 | #if H3D_IVRP |
---|
694 | Void |
---|
695 | TDecSbac::parseResPredFlag( TComDataCU* pcCU, Bool& rbResPredFlag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
696 | { |
---|
697 | UInt uiCtx = pcCU->getCtxResPredFlag( uiAbsPartIdx ); |
---|
698 | UInt uiSymbol = 0; |
---|
699 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cResPredFlagSCModel.get( 0, 0, uiCtx ) ); |
---|
700 | rbResPredFlag = ( uiSymbol != 0 ); |
---|
701 | } |
---|
702 | #endif |
---|
703 | |
---|
704 | #if H3D_IVMP |
---|
705 | Void TDecSbac::parseMVPIdx ( Int& riMVPIdx, Int iNumAMVPCands ) |
---|
706 | { |
---|
707 | UInt uiSymbol; |
---|
708 | xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, iNumAMVPCands-1); |
---|
709 | riMVPIdx = uiSymbol; |
---|
710 | } |
---|
711 | #else |
---|
712 | Void TDecSbac::parseMVPIdx ( Int& riMVPIdx ) |
---|
713 | { |
---|
714 | UInt uiSymbol; |
---|
715 | xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, AMVP_MAX_NUM_CANDS-1); |
---|
716 | riMVPIdx = uiSymbol; |
---|
717 | } |
---|
718 | #endif |
---|
719 | |
---|
720 | Void TDecSbac::parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
721 | { |
---|
722 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
723 | { |
---|
724 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
725 | return; |
---|
726 | } |
---|
727 | |
---|
728 | UInt uiSymbol; |
---|
729 | |
---|
730 | #if H3D_QTL |
---|
731 | Bool bParseSplitFlag = true; |
---|
732 | |
---|
733 | TComSPS *sps = pcCU->getPic()->getSlice(0)->getSPS(); |
---|
734 | TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); |
---|
735 | Bool bDepthMapDetect = (pcTexture != NULL); |
---|
736 | Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); |
---|
737 | |
---|
738 | Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); |
---|
739 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTLPC()) |
---|
740 | { |
---|
741 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
742 | assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); |
---|
743 | bParseSplitFlag = (pcTextureCU->getDepth(uiAbsPartIdx) > uiDepth); |
---|
744 | } |
---|
745 | |
---|
746 | if(bParseSplitFlag) |
---|
747 | { |
---|
748 | #endif |
---|
749 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) ); |
---|
750 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
751 | DTRACE_CABAC_T( "\tSplitFlag\n" ) |
---|
752 | #if H3D_QTL |
---|
753 | } |
---|
754 | else |
---|
755 | uiSymbol = 0; |
---|
756 | #endif |
---|
757 | |
---|
758 | pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx ); |
---|
759 | |
---|
760 | return; |
---|
761 | } |
---|
762 | |
---|
763 | /** parse partition size |
---|
764 | * \param pcCU |
---|
765 | * \param uiAbsPartIdx |
---|
766 | * \param uiDepth |
---|
767 | * \returns Void |
---|
768 | */ |
---|
769 | Void TDecSbac::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
770 | { |
---|
771 | UInt uiSymbol, uiMode = 0; |
---|
772 | PartSize eMode; |
---|
773 | |
---|
774 | #if H3D_QTL |
---|
775 | Bool bParsePartSize = true; |
---|
776 | TComSPS *sps = pcCU->getPic()->getSlice(0)->getSPS(); |
---|
777 | TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); |
---|
778 | Bool bDepthMapDetect = (pcTexture != NULL); |
---|
779 | Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); |
---|
780 | |
---|
781 | Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); |
---|
782 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTLPC()) |
---|
783 | { |
---|
784 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
785 | assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); |
---|
786 | if (pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth && pcTextureCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN) |
---|
787 | { |
---|
788 | bParsePartSize = false; |
---|
789 | eMode = SIZE_2Nx2N; |
---|
790 | } |
---|
791 | } |
---|
792 | #endif |
---|
793 | |
---|
794 | if ( pcCU->isIntra( uiAbsPartIdx ) ) |
---|
795 | { |
---|
796 | #if H3D_QTL |
---|
797 | if(bParsePartSize) |
---|
798 | { |
---|
799 | #endif |
---|
800 | uiSymbol = 1; |
---|
801 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
802 | { |
---|
803 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
804 | } |
---|
805 | eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; |
---|
806 | #if H3D_QTL |
---|
807 | } |
---|
808 | #endif |
---|
809 | UInt uiTrLevel = 0; |
---|
810 | UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; |
---|
811 | UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; |
---|
812 | uiTrLevel = uiWidthInBit >= uiTrSizeInBit ? uiWidthInBit - uiTrSizeInBit : 0; |
---|
813 | if( eMode == SIZE_NxN ) |
---|
814 | { |
---|
815 | pcCU->setTrIdxSubParts( 1+uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
816 | } |
---|
817 | else |
---|
818 | { |
---|
819 | pcCU->setTrIdxSubParts( uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
820 | } |
---|
821 | } |
---|
822 | else |
---|
823 | { |
---|
824 | #if H3D_QTL |
---|
825 | if(bParsePartSize) |
---|
826 | { |
---|
827 | #endif |
---|
828 | UInt uiMaxNumBits = 2; |
---|
829 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getSlice()->getSPS()->getDisInter4x4() && (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) ) |
---|
830 | { |
---|
831 | uiMaxNumBits ++; |
---|
832 | } |
---|
833 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
834 | { |
---|
835 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); |
---|
836 | if ( uiSymbol ) |
---|
837 | { |
---|
838 | break; |
---|
839 | } |
---|
840 | uiMode++; |
---|
841 | } |
---|
842 | eMode = (PartSize) uiMode; |
---|
843 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
844 | { |
---|
845 | if (eMode == SIZE_2NxN) |
---|
846 | { |
---|
847 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 )); |
---|
848 | if (uiSymbol == 0) |
---|
849 | { |
---|
850 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
851 | eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); |
---|
852 | } |
---|
853 | } |
---|
854 | else if (eMode == SIZE_Nx2N) |
---|
855 | { |
---|
856 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 )); |
---|
857 | if (uiSymbol == 0) |
---|
858 | { |
---|
859 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
860 | eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); |
---|
861 | } |
---|
862 | } |
---|
863 | } |
---|
864 | #if H3D_QTL |
---|
865 | } |
---|
866 | #endif |
---|
867 | } |
---|
868 | pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth ); |
---|
869 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
870 | } |
---|
871 | |
---|
872 | /** parse prediction mode |
---|
873 | * \param pcCU |
---|
874 | * \param uiAbsPartIdx |
---|
875 | * \param uiDepth |
---|
876 | * \returns Void |
---|
877 | */ |
---|
878 | Void TDecSbac::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
879 | { |
---|
880 | if( pcCU->getSlice()->isIntra() ) |
---|
881 | { |
---|
882 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
883 | return; |
---|
884 | } |
---|
885 | |
---|
886 | UInt uiSymbol; |
---|
887 | Int iPredMode = MODE_INTER; |
---|
888 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) ); |
---|
889 | iPredMode += uiSymbol; |
---|
890 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
891 | } |
---|
892 | #if PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
893 | Void TDecSbac::parseDepthIntraMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
894 | { |
---|
895 | UInt uiPuIdx = ( pcCU->getWidth(uiAbsPartIdx) == 64 )? 2 : ( ( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && pcCU->getWidth(uiAbsPartIdx) == 8 )? 0 : 1); |
---|
896 | UInt uiDir = 0; |
---|
897 | Bool bSDCFlag = 0; |
---|
898 | UInt uiSymbol = 1; |
---|
899 | UInt uiCode = 0 ; |
---|
900 | UInt uiBinNum = 0; |
---|
901 | UInt uiCtxDepthMode = 0; |
---|
902 | if ( uiPuIdx ==2 ) |
---|
903 | { |
---|
904 | while(uiBinNum<2 && uiSymbol) |
---|
905 | { |
---|
906 | uiCtxDepthMode = uiPuIdx*3 + uiBinNum; |
---|
907 | m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode)); |
---|
908 | uiCode = (uiCode<<1)+uiSymbol; |
---|
909 | uiBinNum++; |
---|
910 | } |
---|
911 | if (uiCode == 0) { uiDir = PLANAR_IDX; bSDCFlag = 1;} |
---|
912 | else if (uiCode == 2) { uiDir = 0; bSDCFlag = 0;} |
---|
913 | else if (uiCode == 3) { uiDir = DC_IDX; bSDCFlag = 1;} |
---|
914 | } |
---|
915 | else if ( uiPuIdx ==0 ) |
---|
916 | { |
---|
917 | while(uiBinNum<3 && uiSymbol) |
---|
918 | { |
---|
919 | uiCtxDepthMode = uiPuIdx*3 + ( uiBinNum >= 2? 2 : uiBinNum ); |
---|
920 | m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode)); |
---|
921 | uiCode = (uiCode<<1)+uiSymbol; |
---|
922 | uiBinNum++; |
---|
923 | } |
---|
924 | if (uiCode == 0) { uiDir = 0; bSDCFlag = 0;} |
---|
925 | else if (uiCode == 2) { uiDir = DMM_WEDGE_FULL_IDX; bSDCFlag = 0;} |
---|
926 | else if (uiCode == 6) { uiDir = DMM_WEDGE_PREDTEX_IDX; bSDCFlag = 0;} |
---|
927 | else if (uiCode == 7) { uiDir = EDGE_INTRA_IDX; bSDCFlag = 0;} |
---|
928 | } |
---|
929 | else |
---|
930 | { |
---|
931 | uiCtxDepthMode = uiPuIdx*3 ; |
---|
932 | m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode)); |
---|
933 | uiCode = (uiCode<<1)+uiSymbol; |
---|
934 | if (!uiSymbol) |
---|
935 | { |
---|
936 | uiCtxDepthMode = uiPuIdx*3 + 1; |
---|
937 | m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode)); |
---|
938 | uiCode = (uiCode<<1)+uiSymbol; |
---|
939 | if (uiSymbol) |
---|
940 | { |
---|
941 | uiCtxDepthMode = uiPuIdx*3 + 2; |
---|
942 | m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode)); |
---|
943 | uiCode = (uiCode<<1)+uiSymbol; |
---|
944 | } |
---|
945 | } |
---|
946 | else |
---|
947 | { |
---|
948 | uiCtxDepthMode = uiPuIdx*3 + 1; |
---|
949 | m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode)); |
---|
950 | uiCode = (uiCode<<1)+uiSymbol; |
---|
951 | if (!uiSymbol) |
---|
952 | { |
---|
953 | uiCtxDepthMode = uiPuIdx*3 + 2; |
---|
954 | m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode)); |
---|
955 | uiCode = (uiCode<<1)+uiSymbol; |
---|
956 | } |
---|
957 | else |
---|
958 | { |
---|
959 | uiBinNum = 0; |
---|
960 | while( uiSymbol && uiBinNum<3 ) |
---|
961 | { |
---|
962 | uiCtxDepthMode = uiPuIdx*3 + 2; |
---|
963 | m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode)); |
---|
964 | uiCode = (uiCode<<1)+uiSymbol; |
---|
965 | uiBinNum++; |
---|
966 | } |
---|
967 | } |
---|
968 | } |
---|
969 | if (uiCode == 0) { uiDir = PLANAR_IDX; bSDCFlag = 1;} |
---|
970 | else if (uiCode == 2) { uiDir = 5; bSDCFlag = 0;} |
---|
971 | else if (uiCode == 3) { uiDir = DMM_WEDGE_FULL_IDX; bSDCFlag = 1;} |
---|
972 | else if (uiCode == 4) { uiDir = DMM_WEDGE_FULL_IDX; bSDCFlag = 0;} |
---|
973 | else if (uiCode == 5) { uiDir = DMM_CONTOUR_PREDTEX_IDX; bSDCFlag = 0;} |
---|
974 | else if (uiCode == 6) { uiDir = DMM_WEDGE_PREDTEX_IDX; bSDCFlag = 0;} |
---|
975 | else if (uiCode == 14) { uiDir = DC_IDX; bSDCFlag = 1;} |
---|
976 | else if (uiCode == 31) { uiDir = DMM_WEDGE_PREDDIR_IDX; bSDCFlag = 0;} |
---|
977 | else if (uiCode == 30) { uiDir = EDGE_INTRA_IDX; bSDCFlag = 0;} |
---|
978 | } |
---|
979 | pcCU->setLumaIntraDirSubParts( (UChar)uiDir, uiAbsPartIdx, uiDepth ); |
---|
980 | pcCU->setSDCFlagSubParts(bSDCFlag, uiAbsPartIdx, 0, uiDepth); |
---|
981 | } |
---|
982 | Void TDecSbac::parseDepthModelingTable ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
983 | { |
---|
984 | parseDepthIntraMode(pcCU,uiAbsPartIdx,uiDepth); |
---|
985 | |
---|
986 | UInt uiDir = pcCU->getLumaIntraDir(uiAbsPartIdx); |
---|
987 | Bool bSdcFlag = pcCU->getSDCAvailable(uiAbsPartIdx) && pcCU->getSDCFlag(uiAbsPartIdx); |
---|
988 | Bool bDmmFlag = (uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX &&(!bSdcFlag))? 1:0; |
---|
989 | if (uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX)//DMM modes and SDC DMM1 |
---|
990 | { |
---|
991 | if( uiDir == DMM_WEDGE_FULL_IDX ) { xParseWedgeFullInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
992 | else if( uiDir == DMM_WEDGE_PREDTEX_IDX ) { xParseWedgePredTexInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
993 | else if( uiDir == DMM_WEDGE_PREDDIR_IDX ) { xParseWedgePredDirInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
994 | } |
---|
995 | else if(uiDir >= EDGE_INTRA_IDX)//CCM mode |
---|
996 | { |
---|
997 | xParseEdgeIntraInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
998 | } |
---|
999 | |
---|
1000 | UInt uiSymbol; |
---|
1001 | if (bDmmFlag) |
---|
1002 | { |
---|
1003 | if (bDmmFlag) |
---|
1004 | { |
---|
1005 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cDmmDeltaFlagModel.get(0, 0, 0) ); |
---|
1006 | uiDir += uiSymbol; |
---|
1007 | } |
---|
1008 | if (uiSymbol) |
---|
1009 | { |
---|
1010 | UInt uiDC; |
---|
1011 | Int iDC = 0,iDC1 = 0,iDC2 = 0; |
---|
1012 | for ( Int i = 0; i <2; i++ ) |
---|
1013 | { |
---|
1014 | xReadExGolombLevel( uiDC, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
1015 | iDC = uiDC; |
---|
1016 | if ( uiDC ) |
---|
1017 | { |
---|
1018 | UInt uiSign; |
---|
1019 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1020 | if ( uiSign ) |
---|
1021 | { |
---|
1022 | iDC = -iDC; |
---|
1023 | } |
---|
1024 | } |
---|
1025 | if ( i == 0 ) { iDC1 = iDC; } |
---|
1026 | else { iDC2 = iDC; } |
---|
1027 | } |
---|
1028 | |
---|
1029 | if( uiDir == DMM_WEDGE_FULL_D_IDX ) |
---|
1030 | { |
---|
1031 | pcCU->setWedgeFullDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
1032 | pcCU->setWedgeFullDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
1033 | } |
---|
1034 | else if( uiDir == DMM_WEDGE_PREDDIR_D_IDX ) |
---|
1035 | { |
---|
1036 | pcCU->setWedgePredDirDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
1037 | pcCU->setWedgePredDirDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
1038 | } |
---|
1039 | else if( uiDir == DMM_WEDGE_PREDTEX_D_IDX) |
---|
1040 | { |
---|
1041 | pcCU->setWedgePredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
1042 | pcCU->setWedgePredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
1043 | } |
---|
1044 | else if (uiDir== DMM_CONTOUR_PREDTEX_D_IDX ) |
---|
1045 | { |
---|
1046 | pcCU->setContourPredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
1047 | pcCU->setContourPredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
1048 | } |
---|
1049 | } |
---|
1050 | } |
---|
1051 | else if (uiDir >= EDGE_INTRA_IDX) |
---|
1052 | { |
---|
1053 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) ); |
---|
1054 | if( uiSymbol ) |
---|
1055 | { |
---|
1056 | uiDir = EDGE_INTRA_DELTA_IDX; |
---|
1057 | Int iDeltaDC = 0,iDeltaDC0 = 0,iDeltaDC1 = 0; |
---|
1058 | for (Int i = 0; i<2; i++) |
---|
1059 | { |
---|
1060 | xReadExGolombLevel( (UInt &) iDeltaDC, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); |
---|
1061 | if( iDeltaDC != 0 ) |
---|
1062 | { |
---|
1063 | UInt uiSign; |
---|
1064 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1065 | if ( uiSign ) |
---|
1066 | { |
---|
1067 | iDeltaDC = -iDeltaDC; |
---|
1068 | } |
---|
1069 | } |
---|
1070 | if ( i == 0 ) { iDeltaDC0 = iDeltaDC; } |
---|
1071 | else { iDeltaDC1 = iDeltaDC; } |
---|
1072 | } |
---|
1073 | |
---|
1074 | pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 ); |
---|
1075 | pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 ); |
---|
1076 | } |
---|
1077 | } |
---|
1078 | else if(bSdcFlag)//SDC mode |
---|
1079 | { |
---|
1080 | assert(pcCU->getPartitionSize(uiAbsPartIdx)!=SIZE_NxN); |
---|
1081 | pcCU->setTrIdxSubParts(0, uiAbsPartIdx, uiDepth); |
---|
1082 | pcCU->setCbfSubParts(1, 1, 1, uiAbsPartIdx, uiDepth); |
---|
1083 | |
---|
1084 | UInt uiNumSegments = ( uiDir == DC_IDX || uiDir == PLANAR_IDX )? 1 : 2; |
---|
1085 | for (int uiSeg=0; uiSeg<uiNumSegments; uiSeg++) |
---|
1086 | { |
---|
1087 | parseSDCResidualData(pcCU, uiAbsPartIdx, uiDepth, uiSeg); |
---|
1088 | } |
---|
1089 | } |
---|
1090 | |
---|
1091 | pcCU->setLumaIntraDirSubParts( (UChar)uiDir, uiAbsPartIdx, uiDepth ); |
---|
1092 | } |
---|
1093 | #endif |
---|
1094 | Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1095 | { |
---|
1096 | UInt uiSymbol; |
---|
1097 | Int intraPredMode; |
---|
1098 | #if PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
1099 | if (pcCU->getSlice()->getSPS()->isDepth()) |
---|
1100 | { |
---|
1101 | parseDepthModelingTable(pcCU, uiAbsPartIdx, uiDepth); |
---|
1102 | } |
---|
1103 | if (pcCU->getLumaIntraDir(uiAbsPartIdx)<NUM_INTRA_MODE && !pcCU->getSDCFlag(uiAbsPartIdx)) |
---|
1104 | { |
---|
1105 | #else |
---|
1106 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1107 | UInt uiFlag = 0; |
---|
1108 | if( pcCU->getSlice()->getSPS()->getUseDMM() && (g_uiMaxCUWidth>>uiDepth) <= DMM_WEDGEMODEL_MAX_SIZE ) |
---|
1109 | { |
---|
1110 | m_pcTDecBinIf->decodeBin( uiFlag, m_cDmmFlagSCModel.get(0, 0, 0) ); |
---|
1111 | } |
---|
1112 | if( uiFlag ) |
---|
1113 | { |
---|
1114 | UInt uiDMMode; |
---|
1115 | |
---|
1116 | #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX |
---|
1117 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode = uiSymbol; |
---|
1118 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 1; |
---|
1119 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
1120 | { |
---|
1121 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 2; |
---|
1122 | } |
---|
1123 | #else |
---|
1124 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode = uiSymbol; |
---|
1125 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
1126 | { |
---|
1127 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 1; |
---|
1128 | } |
---|
1129 | #endif |
---|
1130 | intraPredMode = uiDMMode + NUM_INTRA_MODE; |
---|
1131 | |
---|
1132 | #if HHI_DMM_WEDGE_INTRA |
---|
1133 | if( intraPredMode == DMM_WEDGE_FULL_IDX ) { xParseWedgeFullInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1134 | if( intraPredMode == DMM_WEDGE_FULL_D_IDX ) { xParseWedgeFullDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1135 | if( intraPredMode == DMM_WEDGE_PREDDIR_IDX ) { xParseWedgePredDirInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1136 | if( intraPredMode == DMM_WEDGE_PREDDIR_D_IDX ) { xParseWedgePredDirDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1137 | #endif |
---|
1138 | #if HHI_DMM_PRED_TEX |
---|
1139 | if( intraPredMode == DMM_WEDGE_PREDTEX_D_IDX ) { xParseWedgePredTexDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1140 | #if LGE_DMM3_SIMP_C0044 |
---|
1141 | if( intraPredMode == DMM_WEDGE_PREDTEX_IDX ) { xParseWedgePredTexInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1142 | #endif |
---|
1143 | if( intraPredMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xParseContourPredTexDeltaInfo( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1144 | #endif |
---|
1145 | } |
---|
1146 | else |
---|
1147 | { |
---|
1148 | #endif |
---|
1149 | |
---|
1150 | #if LGE_EDGE_INTRA_A0070 |
---|
1151 | Bool bCodeEdgeIntra = false; |
---|
1152 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
1153 | { |
---|
1154 | UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0); |
---|
1155 | if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE ) |
---|
1156 | bCodeEdgeIntra = true; |
---|
1157 | } |
---|
1158 | #endif |
---|
1159 | #endif |
---|
1160 | Int uiPreds[3] = {-1, -1, -1}; |
---|
1161 | Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); |
---|
1162 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
1163 | #if LGE_EDGE_INTRA_A0070 |
---|
1164 | UInt uiCheckBit = 0; |
---|
1165 | #endif |
---|
1166 | #endif |
---|
1167 | |
---|
1168 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); |
---|
1169 | |
---|
1170 | if ( uiSymbol ) |
---|
1171 | { |
---|
1172 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
1173 | if (uiSymbol) |
---|
1174 | { |
---|
1175 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
1176 | uiSymbol++; |
---|
1177 | } |
---|
1178 | intraPredMode = uiPreds[uiSymbol]; |
---|
1179 | } |
---|
1180 | else |
---|
1181 | { |
---|
1182 | intraPredMode = 0; |
---|
1183 | |
---|
1184 | |
---|
1185 | m_pcTDecBinIf->decodeBinsEP( uiSymbol, 5 ); |
---|
1186 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
1187 | #if LGE_EDGE_INTRA_A0070 |
---|
1188 | if (bCodeEdgeIntra) |
---|
1189 | { |
---|
1190 | if (uiSymbol==31) |
---|
1191 | { |
---|
1192 | m_pcTDecBinIf->decodeBinsEP(uiCheckBit,1); |
---|
1193 | if (uiCheckBit) |
---|
1194 | uiSymbol = EDGE_INTRA_IDX; |
---|
1195 | } |
---|
1196 | } |
---|
1197 | #endif |
---|
1198 | #endif |
---|
1199 | intraPredMode = uiSymbol; |
---|
1200 | |
---|
1201 | //postponed sorting of MPMs (only in remaining branch) |
---|
1202 | if (uiPreds[0] > uiPreds[1]) |
---|
1203 | { |
---|
1204 | std::swap(uiPreds[0], uiPreds[1]); |
---|
1205 | } |
---|
1206 | if (uiPreds[0] > uiPreds[2]) |
---|
1207 | { |
---|
1208 | std::swap(uiPreds[0], uiPreds[2]); |
---|
1209 | } |
---|
1210 | if (uiPreds[1] > uiPreds[2]) |
---|
1211 | { |
---|
1212 | std::swap(uiPreds[1], uiPreds[2]); |
---|
1213 | } |
---|
1214 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
1215 | #if LGE_EDGE_INTRA_A0070 |
---|
1216 | if ( intraPredMode != EDGE_INTRA_IDX) |
---|
1217 | { |
---|
1218 | #endif |
---|
1219 | #endif |
---|
1220 | for ( Int i = 0; i < uiPredNum; i++ ) |
---|
1221 | { |
---|
1222 | intraPredMode += ( intraPredMode >= uiPreds[i] ); |
---|
1223 | } |
---|
1224 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
1225 | #if LGE_EDGE_INTRA_A0070 |
---|
1226 | } |
---|
1227 | #endif |
---|
1228 | #endif |
---|
1229 | } |
---|
1230 | |
---|
1231 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
1232 | #if LGE_EDGE_INTRA_A0070 |
---|
1233 | if( intraPredMode == EDGE_INTRA_IDX ) |
---|
1234 | { |
---|
1235 | xParseEdgeIntraInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
1236 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
1237 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) ); |
---|
1238 | if( uiSymbol ) |
---|
1239 | { |
---|
1240 | intraPredMode = EDGE_INTRA_DELTA_IDX; |
---|
1241 | Int iDeltaDC0; |
---|
1242 | Int iDeltaDC1; |
---|
1243 | |
---|
1244 | xReadExGolombLevel( (UInt &) iDeltaDC0, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); |
---|
1245 | if( iDeltaDC0 != 0 ) |
---|
1246 | { |
---|
1247 | UInt uiSign; |
---|
1248 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1249 | if ( uiSign ) |
---|
1250 | { |
---|
1251 | iDeltaDC0 = -iDeltaDC0; |
---|
1252 | } |
---|
1253 | } |
---|
1254 | xReadExGolombLevel( (UInt &) iDeltaDC1, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); |
---|
1255 | if( iDeltaDC1 != 0 ) |
---|
1256 | { |
---|
1257 | UInt uiSign; |
---|
1258 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1259 | if ( uiSign ) |
---|
1260 | { |
---|
1261 | iDeltaDC1 = -iDeltaDC1; |
---|
1262 | } |
---|
1263 | } |
---|
1264 | |
---|
1265 | pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 ); |
---|
1266 | pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 ); |
---|
1267 | } |
---|
1268 | #endif |
---|
1269 | } |
---|
1270 | #endif |
---|
1271 | |
---|
1272 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1273 | } |
---|
1274 | #endif |
---|
1275 | pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, uiAbsPartIdx, uiDepth ); |
---|
1276 | #else |
---|
1277 | pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, uiAbsPartIdx, uiDepth ); |
---|
1278 | } |
---|
1279 | #endif |
---|
1280 | } |
---|
1281 | |
---|
1282 | Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1283 | { |
---|
1284 | UInt uiSymbol; |
---|
1285 | |
---|
1286 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) ); |
---|
1287 | |
---|
1288 | if( uiSymbol == 0 ) |
---|
1289 | { |
---|
1290 | uiSymbol = DM_CHROMA_IDX; |
---|
1291 | } |
---|
1292 | else |
---|
1293 | { |
---|
1294 | if( pcCU->getSlice()->getSPS()->getUseLMChroma() ) |
---|
1295 | { |
---|
1296 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 1 ) ); |
---|
1297 | } |
---|
1298 | else |
---|
1299 | { |
---|
1300 | uiSymbol = 1; |
---|
1301 | } |
---|
1302 | |
---|
1303 | if( uiSymbol == 0 ) |
---|
1304 | { |
---|
1305 | uiSymbol = LM_CHROMA_IDX; |
---|
1306 | } |
---|
1307 | else |
---|
1308 | { |
---|
1309 | UInt uiIPredMode; |
---|
1310 | m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 ); |
---|
1311 | UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; |
---|
1312 | pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); |
---|
1313 | uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; |
---|
1314 | } |
---|
1315 | } |
---|
1316 | pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); |
---|
1317 | return; |
---|
1318 | } |
---|
1319 | |
---|
1320 | Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1321 | { |
---|
1322 | UInt uiSymbol; |
---|
1323 | const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); |
---|
1324 | ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 ); |
---|
1325 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) ); |
---|
1326 | |
---|
1327 | if( uiSymbol ) |
---|
1328 | { |
---|
1329 | uiSymbol = 2; |
---|
1330 | } |
---|
1331 | |
---|
1332 | uiSymbol++; |
---|
1333 | ruiInterDir = uiSymbol; |
---|
1334 | return; |
---|
1335 | } |
---|
1336 | |
---|
1337 | Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
1338 | { |
---|
1339 | UInt uiSymbol; |
---|
1340 | |
---|
1341 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C ) > 0 && eRefList==REF_PIC_LIST_C) |
---|
1342 | { |
---|
1343 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
1344 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1345 | |
---|
1346 | if( uiSymbol ) |
---|
1347 | { |
---|
1348 | xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_C )-2 ); |
---|
1349 | uiSymbol++; |
---|
1350 | } |
---|
1351 | riRefFrmIdx = uiSymbol; |
---|
1352 | } |
---|
1353 | else |
---|
1354 | { |
---|
1355 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
1356 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1357 | |
---|
1358 | if( uiSymbol ) |
---|
1359 | { |
---|
1360 | xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( eRefList )-2 ); |
---|
1361 | uiSymbol++; |
---|
1362 | } |
---|
1363 | riRefFrmIdx = uiSymbol; |
---|
1364 | } |
---|
1365 | |
---|
1366 | return; |
---|
1367 | } |
---|
1368 | |
---|
1369 | Void TDecSbac::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
1370 | { |
---|
1371 | UInt uiSymbol; |
---|
1372 | UInt uiHorAbs; |
---|
1373 | UInt uiVerAbs; |
---|
1374 | UInt uiHorSign = 0; |
---|
1375 | UInt uiVerSign = 0; |
---|
1376 | ContextModel *pCtx = m_cCUMvdSCModel.get( 0 ); |
---|
1377 | |
---|
1378 | if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3) |
---|
1379 | { |
---|
1380 | uiHorAbs=0; |
---|
1381 | uiVerAbs=0; |
---|
1382 | } |
---|
1383 | else |
---|
1384 | { |
---|
1385 | |
---|
1386 | m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx ); |
---|
1387 | m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx ); |
---|
1388 | |
---|
1389 | const Bool bHorAbsGr0 = uiHorAbs != 0; |
---|
1390 | const Bool bVerAbsGr0 = uiVerAbs != 0; |
---|
1391 | pCtx++; |
---|
1392 | |
---|
1393 | if( bHorAbsGr0 ) |
---|
1394 | { |
---|
1395 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1396 | uiHorAbs += uiSymbol; |
---|
1397 | } |
---|
1398 | |
---|
1399 | if( bVerAbsGr0 ) |
---|
1400 | { |
---|
1401 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1402 | uiVerAbs += uiSymbol; |
---|
1403 | } |
---|
1404 | |
---|
1405 | if( bHorAbsGr0 ) |
---|
1406 | { |
---|
1407 | if( 2 == uiHorAbs ) |
---|
1408 | { |
---|
1409 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
1410 | uiHorAbs += uiSymbol; |
---|
1411 | } |
---|
1412 | |
---|
1413 | m_pcTDecBinIf->decodeBinEP( uiHorSign ); |
---|
1414 | } |
---|
1415 | |
---|
1416 | if( bVerAbsGr0 ) |
---|
1417 | { |
---|
1418 | if( 2 == uiVerAbs ) |
---|
1419 | { |
---|
1420 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
1421 | uiVerAbs += uiSymbol; |
---|
1422 | } |
---|
1423 | |
---|
1424 | m_pcTDecBinIf->decodeBinEP( uiVerSign ); |
---|
1425 | } |
---|
1426 | |
---|
1427 | } |
---|
1428 | |
---|
1429 | const TComMv cMv( uiHorSign ? -Int( uiHorAbs ): uiHorAbs, uiVerSign ? -Int( uiVerAbs ) : uiVerAbs ); |
---|
1430 | pcCU->getCUMvField( eRefList )->setAllMvd( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1431 | return; |
---|
1432 | } |
---|
1433 | |
---|
1434 | |
---|
1435 | Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) |
---|
1436 | { |
---|
1437 | m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) ); |
---|
1438 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1439 | DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) |
---|
1440 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1441 | DTRACE_CABAC_V( ruiSubdivFlag ) |
---|
1442 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1443 | DTRACE_CABAC_V( uiLog2TransformBlockSize ) |
---|
1444 | DTRACE_CABAC_T( "\n" ) |
---|
1445 | } |
---|
1446 | |
---|
1447 | Void TDecSbac::parseQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf ) |
---|
1448 | { |
---|
1449 | UInt uiSymbol; |
---|
1450 | const UInt uiCtx = 0; |
---|
1451 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) ); |
---|
1452 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1453 | DTRACE_CABAC_T( "\tparseQtRootCbf()" ) |
---|
1454 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1455 | DTRACE_CABAC_V( uiSymbol ) |
---|
1456 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1457 | DTRACE_CABAC_V( uiCtx ) |
---|
1458 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1459 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1460 | DTRACE_CABAC_T( "\n" ) |
---|
1461 | |
---|
1462 | uiQtRootCbf = uiSymbol; |
---|
1463 | } |
---|
1464 | |
---|
1465 | Void TDecSbac::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1466 | { |
---|
1467 | Int qp; |
---|
1468 | UInt uiDQp; |
---|
1469 | Int iDQp; |
---|
1470 | |
---|
1471 | m_pcTDecBinIf->decodeBin( uiDQp, m_cCUDeltaQpSCModel.get( 0, 0, 0 ) ); |
---|
1472 | |
---|
1473 | if ( uiDQp == 0 ) |
---|
1474 | { |
---|
1475 | qp = pcCU->getRefQP(uiAbsPartIdx); |
---|
1476 | } |
---|
1477 | else |
---|
1478 | { |
---|
1479 | UInt uiSign; |
---|
1480 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
1481 | m_pcTDecBinIf->decodeBinEP(uiSign); |
---|
1482 | |
---|
1483 | UInt uiMaxAbsDQpMinus1 = 24 + (qpBdOffsetY/2) + (uiSign); |
---|
1484 | UInt uiAbsDQpMinus1; |
---|
1485 | xReadUnaryMaxSymbol (uiAbsDQpMinus1, &m_cCUDeltaQpSCModel.get( 0, 0, 1 ), 1, uiMaxAbsDQpMinus1); |
---|
1486 | |
---|
1487 | iDQp = uiAbsDQpMinus1 + 1; |
---|
1488 | |
---|
1489 | if(uiSign) |
---|
1490 | { |
---|
1491 | iDQp = -iDQp; |
---|
1492 | } |
---|
1493 | |
---|
1494 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY; |
---|
1495 | } |
---|
1496 | |
---|
1497 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)))<<(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)) ; |
---|
1498 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
1499 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
1500 | } |
---|
1501 | |
---|
1502 | Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) |
---|
1503 | { |
---|
1504 | UInt uiSymbol; |
---|
1505 | const UInt uiCtx = pcCU->getCtxQtCbf( uiAbsPartIdx, eType, uiTrDepth ); |
---|
1506 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) ); |
---|
1507 | |
---|
1508 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1509 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
1510 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1511 | DTRACE_CABAC_V( uiSymbol ) |
---|
1512 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1513 | DTRACE_CABAC_V( uiCtx ) |
---|
1514 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1515 | DTRACE_CABAC_V( eType ) |
---|
1516 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1517 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1518 | DTRACE_CABAC_T( "\n" ) |
---|
1519 | |
---|
1520 | pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth ); |
---|
1521 | } |
---|
1522 | |
---|
1523 | /** Parse (X,Y) position of the last significant coefficient |
---|
1524 | * \param uiPosLastX reference to X component of last coefficient |
---|
1525 | * \param uiPosLastY reference to Y component of last coefficient |
---|
1526 | * \param width Block width |
---|
1527 | * \param height Block height |
---|
1528 | * \param eTType plane type / luminance or chrominance |
---|
1529 | * \param uiScanIdx scan type (zig-zag, hor, ver) |
---|
1530 | * |
---|
1531 | * This method decodes the X and Y component within a block of the last significant coefficient. |
---|
1532 | */ |
---|
1533 | Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx ) |
---|
1534 | { |
---|
1535 | UInt uiLast; |
---|
1536 | ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); |
---|
1537 | ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); |
---|
1538 | |
---|
1539 | // posX |
---|
1540 | Int widthCtx = eTType ? 4 : width; |
---|
1541 | const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ widthCtx ] * ( g_aucConvertToBit[ widthCtx ] + 3 ) ); |
---|
1542 | for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ ) |
---|
1543 | { |
---|
1544 | if ( eTType ) |
---|
1545 | { |
---|
1546 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + (uiPosLastX>>g_aucConvertToBit[ width ]) ) ); |
---|
1547 | } |
---|
1548 | else |
---|
1549 | { |
---|
1550 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + puiCtxIdxX[ uiPosLastX ] ) ); |
---|
1551 | } |
---|
1552 | if( !uiLast ) |
---|
1553 | { |
---|
1554 | break; |
---|
1555 | } |
---|
1556 | } |
---|
1557 | |
---|
1558 | // posY |
---|
1559 | Int heightCtx = eTType? 4 : height; |
---|
1560 | const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ heightCtx ] * ( g_aucConvertToBit[ heightCtx ] + 3 ) ); |
---|
1561 | for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ ) |
---|
1562 | { |
---|
1563 | if (eTType) |
---|
1564 | { |
---|
1565 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + (uiPosLastY>>g_aucConvertToBit[ height ]) ) ); |
---|
1566 | } |
---|
1567 | else |
---|
1568 | { |
---|
1569 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + puiCtxIdxY[ uiPosLastY ] ) ); |
---|
1570 | } |
---|
1571 | if( !uiLast ) |
---|
1572 | { |
---|
1573 | break; |
---|
1574 | } |
---|
1575 | } |
---|
1576 | if ( uiPosLastX > 3 ) |
---|
1577 | { |
---|
1578 | UInt uiTemp = 0; |
---|
1579 | UInt uiCount = ( uiPosLastX - 2 ) >> 1; |
---|
1580 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
1581 | { |
---|
1582 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
1583 | uiTemp += uiLast << i; |
---|
1584 | } |
---|
1585 | uiPosLastX = g_uiMinInGroup[ uiPosLastX ] + uiTemp; |
---|
1586 | } |
---|
1587 | if ( uiPosLastY > 3 ) |
---|
1588 | { |
---|
1589 | UInt uiTemp = 0; |
---|
1590 | UInt uiCount = ( uiPosLastY - 2 ) >> 1; |
---|
1591 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
1592 | { |
---|
1593 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
1594 | uiTemp += uiLast << i; |
---|
1595 | } |
---|
1596 | uiPosLastY = g_uiMinInGroup[ uiPosLastY ] + uiTemp; |
---|
1597 | } |
---|
1598 | |
---|
1599 | if( uiScanIdx == SCAN_VER ) |
---|
1600 | { |
---|
1601 | swap( uiPosLastX, uiPosLastY ); |
---|
1602 | } |
---|
1603 | } |
---|
1604 | |
---|
1605 | Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
1606 | { |
---|
1607 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1608 | DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) |
---|
1609 | DTRACE_CABAC_V( eTType ) |
---|
1610 | DTRACE_CABAC_T( "\twidth=" ) |
---|
1611 | DTRACE_CABAC_V( uiWidth ) |
---|
1612 | DTRACE_CABAC_T( "\theight=" ) |
---|
1613 | DTRACE_CABAC_V( uiHeight ) |
---|
1614 | DTRACE_CABAC_T( "\tdepth=" ) |
---|
1615 | DTRACE_CABAC_V( uiDepth ) |
---|
1616 | DTRACE_CABAC_T( "\tabspartidx=" ) |
---|
1617 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1618 | DTRACE_CABAC_T( "\ttoCU-X=" ) |
---|
1619 | DTRACE_CABAC_V( pcCU->getCUPelX() ) |
---|
1620 | DTRACE_CABAC_T( "\ttoCU-Y=" ) |
---|
1621 | DTRACE_CABAC_V( pcCU->getCUPelY() ) |
---|
1622 | DTRACE_CABAC_T( "\tCU-addr=" ) |
---|
1623 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
1624 | DTRACE_CABAC_T( "\tinCU-X=" ) |
---|
1625 | DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1626 | DTRACE_CABAC_T( "\tinCU-Y=" ) |
---|
1627 | DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1628 | DTRACE_CABAC_T( "\tpredmode=" ) |
---|
1629 | DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) |
---|
1630 | DTRACE_CABAC_T( "\n" ) |
---|
1631 | |
---|
1632 | if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) |
---|
1633 | { |
---|
1634 | uiWidth = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
1635 | uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
1636 | } |
---|
1637 | |
---|
1638 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); |
---|
1639 | |
---|
1640 | //----- parse significance map ----- |
---|
1641 | const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; |
---|
1642 | const UInt uiMaxNumCoeff = uiWidth * uiHeight; |
---|
1643 | const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; |
---|
1644 | UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); |
---|
1645 | int blockType = uiLog2BlockSize; |
---|
1646 | if (uiWidth != uiHeight) |
---|
1647 | { |
---|
1648 | uiScanIdx = SCAN_DIAG; |
---|
1649 | blockType = 4; |
---|
1650 | } |
---|
1651 | |
---|
1652 | //===== decode last significant ===== |
---|
1653 | UInt uiPosLastX, uiPosLastY; |
---|
1654 | parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, eTType, uiScanIdx ); |
---|
1655 | UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockSize); |
---|
1656 | pcCoef[ uiBlkPosLast ] = 1; |
---|
1657 | |
---|
1658 | //===== decode significance flags ===== |
---|
1659 | UInt uiScanPosLast = uiBlkPosLast; |
---|
1660 | if (uiScanIdx == SCAN_ZIGZAG) |
---|
1661 | { |
---|
1662 | // Map zigzag to diagonal scan |
---|
1663 | uiScanIdx = SCAN_DIAG; |
---|
1664 | } |
---|
1665 | const UInt * scan; |
---|
1666 | if (uiWidth == uiHeight) |
---|
1667 | { |
---|
1668 | scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ]; |
---|
1669 | } |
---|
1670 | else |
---|
1671 | { |
---|
1672 | scan = g_sigScanNSQT[ uiLog2BlockSize - 2 ]; |
---|
1673 | } |
---|
1674 | for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ ) |
---|
1675 | { |
---|
1676 | UInt uiBlkPos = scan[ uiScanPosLast ]; |
---|
1677 | if( uiBlkPosLast == uiBlkPos ) |
---|
1678 | { |
---|
1679 | break; |
---|
1680 | } |
---|
1681 | } |
---|
1682 | |
---|
1683 | ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, eTType ); |
---|
1684 | ContextModel * const baseCtx = (eTType==TEXT_LUMA) ? m_cCUSigSCModel.get( 0, 0 ) : m_cCUSigSCModel.get( 0, 0 ) + NUM_SIG_FLAG_CTX_LUMA; |
---|
1685 | |
---|
1686 | const Int iLastScanSet = uiScanPosLast >> LOG2_SCAN_SET_SIZE; |
---|
1687 | UInt uiNumOne = 0; |
---|
1688 | UInt uiGoRiceParam = 0; |
---|
1689 | |
---|
1690 | UInt const tsig = pcCU->getSlice()->getPPS()->getTSIG(); |
---|
1691 | #if LOSSLESS_CODING |
---|
1692 | Bool beValid; |
---|
1693 | if (pcCU->isLosslessCoded(uiAbsPartIdx)) |
---|
1694 | { |
---|
1695 | beValid = false; |
---|
1696 | } |
---|
1697 | else |
---|
1698 | { |
---|
1699 | beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
1700 | } |
---|
1701 | #else |
---|
1702 | Bool beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
1703 | #endif |
---|
1704 | UInt absSum = 0; |
---|
1705 | |
---|
1706 | UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ]; |
---|
1707 | ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); |
---|
1708 | const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1); |
---|
1709 | const UInt * scanCG; |
---|
1710 | if (uiWidth == uiHeight) |
---|
1711 | { |
---|
1712 | scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ]; |
---|
1713 | if( uiLog2BlockSize == 3 ) |
---|
1714 | { |
---|
1715 | scanCG = g_sigLastScan8x8[ uiScanIdx ]; |
---|
1716 | } |
---|
1717 | else if( uiLog2BlockSize == 5 ) |
---|
1718 | { |
---|
1719 | scanCG = g_sigLastScanCG32x32; |
---|
1720 | } |
---|
1721 | } |
---|
1722 | else |
---|
1723 | { |
---|
1724 | scanCG = g_sigCGScanNSQT[ uiLog2BlockSize - 2 ]; |
---|
1725 | } |
---|
1726 | Int iScanPosSig = (Int) uiScanPosLast; |
---|
1727 | for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- ) |
---|
1728 | { |
---|
1729 | Int iSubPos = iSubSet << LOG2_SCAN_SET_SIZE; |
---|
1730 | uiGoRiceParam = 0; |
---|
1731 | Int numNonZero = 0; |
---|
1732 | |
---|
1733 | Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE; |
---|
1734 | |
---|
1735 | Int pos[SCAN_SET_SIZE]; |
---|
1736 | if( iScanPosSig == (Int) uiScanPosLast ) |
---|
1737 | { |
---|
1738 | lastNZPosInCG = iScanPosSig; |
---|
1739 | firstNZPosInCG = iScanPosSig; |
---|
1740 | iScanPosSig--; |
---|
1741 | pos[ numNonZero ] = uiBlkPosLast; |
---|
1742 | numNonZero = 1; |
---|
1743 | } |
---|
1744 | |
---|
1745 | // decode significant_coeffgroup_flag |
---|
1746 | Int iCGBlkPos = scanCG[ iSubSet ]; |
---|
1747 | Int iCGPosY = iCGBlkPos / uiNumBlkSide; |
---|
1748 | Int iCGPosX = iCGBlkPos - (iCGPosY * uiNumBlkSide); |
---|
1749 | if( uiWidth == 8 && uiHeight == 8 && (uiScanIdx == SCAN_HOR || uiScanIdx == SCAN_VER) ) |
---|
1750 | { |
---|
1751 | iCGPosY = (uiScanIdx == SCAN_HOR ? iCGBlkPos : 0); |
---|
1752 | iCGPosX = (uiScanIdx == SCAN_VER ? iCGBlkPos : 0); |
---|
1753 | } |
---|
1754 | if( iSubSet == iLastScanSet || iSubSet == 0) |
---|
1755 | { |
---|
1756 | uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; |
---|
1757 | } |
---|
1758 | else |
---|
1759 | { |
---|
1760 | UInt uiSigCoeffGroup; |
---|
1761 | UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight ); |
---|
1762 | m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] ); |
---|
1763 | uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup; |
---|
1764 | } |
---|
1765 | |
---|
1766 | // decode significant_coeff_flag |
---|
1767 | UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig; |
---|
1768 | for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) |
---|
1769 | { |
---|
1770 | uiBlkPos = scan[ iScanPosSig ]; |
---|
1771 | uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
1772 | uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
1773 | uiSig = 0; |
---|
1774 | |
---|
1775 | if( uiSigCoeffGroupFlag[ iCGBlkPos ] ) |
---|
1776 | { |
---|
1777 | if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) |
---|
1778 | { |
---|
1779 | uiCtxSig = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType ); |
---|
1780 | m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] ); |
---|
1781 | } |
---|
1782 | else |
---|
1783 | { |
---|
1784 | uiSig = 1; |
---|
1785 | } |
---|
1786 | } |
---|
1787 | pcCoef[ uiBlkPos ] = uiSig; |
---|
1788 | if( uiSig ) |
---|
1789 | { |
---|
1790 | pos[ numNonZero ] = uiBlkPos; |
---|
1791 | numNonZero ++; |
---|
1792 | if( lastNZPosInCG == -1 ) |
---|
1793 | { |
---|
1794 | lastNZPosInCG = iScanPosSig; |
---|
1795 | } |
---|
1796 | firstNZPosInCG = iScanPosSig; |
---|
1797 | } |
---|
1798 | } |
---|
1799 | |
---|
1800 | |
---|
1801 | if( numNonZero ) |
---|
1802 | { |
---|
1803 | Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= (Int)tsig ); |
---|
1804 | absSum = 0; |
---|
1805 | |
---|
1806 | UInt c1 = 1; |
---|
1807 | UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0; |
---|
1808 | UInt uiBin; |
---|
1809 | |
---|
1810 | if( uiNumOne > 0 ) |
---|
1811 | { |
---|
1812 | uiCtxSet++; |
---|
1813 | } |
---|
1814 | |
---|
1815 | uiNumOne >>= 1; |
---|
1816 | ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet; |
---|
1817 | Int absCoeff[SCAN_SET_SIZE]; |
---|
1818 | |
---|
1819 | for ( Int i = 0; i < numNonZero; i++) absCoeff[i] = 1; |
---|
1820 | Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); |
---|
1821 | Int firstC2FlagIdx = -1; |
---|
1822 | |
---|
1823 | for( Int idx = 0; idx < numC1Flag; idx++ ) |
---|
1824 | { |
---|
1825 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] ); |
---|
1826 | if( uiBin == 1 ) |
---|
1827 | { |
---|
1828 | c1 = 0; |
---|
1829 | if (firstC2FlagIdx == -1) |
---|
1830 | { |
---|
1831 | firstC2FlagIdx = idx; |
---|
1832 | } |
---|
1833 | } |
---|
1834 | else if( (c1 < 3) && (c1 > 0) ) |
---|
1835 | { |
---|
1836 | c1++; |
---|
1837 | } |
---|
1838 | absCoeff[ idx ] = uiBin + 1; |
---|
1839 | } |
---|
1840 | |
---|
1841 | if (c1 == 0) |
---|
1842 | { |
---|
1843 | baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet; |
---|
1844 | if ( firstC2FlagIdx != -1) |
---|
1845 | { |
---|
1846 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] ); |
---|
1847 | absCoeff[ firstC2FlagIdx ] = uiBin + 2; |
---|
1848 | } |
---|
1849 | } |
---|
1850 | |
---|
1851 | UInt coeffSigns; |
---|
1852 | if ( signHidden && beValid ) |
---|
1853 | { |
---|
1854 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 ); |
---|
1855 | coeffSigns <<= 32 - (numNonZero-1); |
---|
1856 | } |
---|
1857 | else |
---|
1858 | { |
---|
1859 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero ); |
---|
1860 | coeffSigns <<= 32 - numNonZero; |
---|
1861 | } |
---|
1862 | |
---|
1863 | Int iFirstCoeff2 = 1; |
---|
1864 | if (c1 == 0 || numNonZero > C1FLAG_NUMBER) |
---|
1865 | { |
---|
1866 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
1867 | { |
---|
1868 | UInt baseLevel = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2) : 1; |
---|
1869 | |
---|
1870 | if( absCoeff[ idx ] == baseLevel) |
---|
1871 | { |
---|
1872 | UInt uiLevel; |
---|
1873 | xReadGoRiceExGolomb( uiLevel, uiGoRiceParam ); |
---|
1874 | absCoeff[ idx ] = uiLevel + baseLevel; |
---|
1875 | } |
---|
1876 | |
---|
1877 | if(absCoeff[ idx ] >= 2) |
---|
1878 | { |
---|
1879 | iFirstCoeff2 = 0; |
---|
1880 | uiNumOne++; |
---|
1881 | } |
---|
1882 | } |
---|
1883 | } |
---|
1884 | |
---|
1885 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
1886 | { |
---|
1887 | Int blkPos = pos[ idx ]; |
---|
1888 | // Signs applied later. |
---|
1889 | pcCoef[ blkPos ] = absCoeff[ idx ]; |
---|
1890 | absSum += absCoeff[ idx ]; |
---|
1891 | |
---|
1892 | if ( idx == numNonZero-1 && signHidden && beValid ) |
---|
1893 | { |
---|
1894 | // Infer sign of 1st element. |
---|
1895 | if (absSum&0x1) |
---|
1896 | pcCoef[ blkPos ] = -pcCoef[ blkPos ]; |
---|
1897 | } |
---|
1898 | else |
---|
1899 | { |
---|
1900 | Int sign = static_cast<Int>( coeffSigns ) >> 31; |
---|
1901 | pcCoef[ blkPos ] = ( pcCoef[ blkPos ] ^ sign ) - sign; |
---|
1902 | coeffSigns <<= 1; |
---|
1903 | } |
---|
1904 | } |
---|
1905 | } |
---|
1906 | else |
---|
1907 | { |
---|
1908 | uiNumOne >>= 1; |
---|
1909 | } |
---|
1910 | } |
---|
1911 | |
---|
1912 | return; |
---|
1913 | } |
---|
1914 | |
---|
1915 | |
---|
1916 | Void TDecSbac::parseSaoUvlc (UInt& ruiVal) |
---|
1917 | { |
---|
1918 | UInt uiCode; |
---|
1919 | Int i; |
---|
1920 | |
---|
1921 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoUvlcSCModel.get( 0, 0, 0 ) ); |
---|
1922 | if ( uiCode == 0 ) |
---|
1923 | { |
---|
1924 | ruiVal = 0; |
---|
1925 | return; |
---|
1926 | } |
---|
1927 | |
---|
1928 | i=1; |
---|
1929 | while (1) |
---|
1930 | { |
---|
1931 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoUvlcSCModel.get( 0, 0, 1 ) ); |
---|
1932 | if ( uiCode == 0 ) break; |
---|
1933 | i++; |
---|
1934 | } |
---|
1935 | |
---|
1936 | ruiVal = i; |
---|
1937 | } |
---|
1938 | |
---|
1939 | Void TDecSbac::parseSaoSvlc (Int& riVal) |
---|
1940 | { |
---|
1941 | UInt uiCode; |
---|
1942 | Int iSign; |
---|
1943 | Int i; |
---|
1944 | |
---|
1945 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 0 ) ); |
---|
1946 | |
---|
1947 | if ( uiCode == 0 ) |
---|
1948 | { |
---|
1949 | riVal = 0; |
---|
1950 | return; |
---|
1951 | } |
---|
1952 | |
---|
1953 | // read sign |
---|
1954 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 1 ) ); |
---|
1955 | |
---|
1956 | if ( uiCode == 0 ) |
---|
1957 | { |
---|
1958 | iSign = 1; |
---|
1959 | } |
---|
1960 | else |
---|
1961 | { |
---|
1962 | iSign = -1; |
---|
1963 | } |
---|
1964 | |
---|
1965 | // read magnitude |
---|
1966 | i=1; |
---|
1967 | while (1) |
---|
1968 | { |
---|
1969 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 2 ) ); |
---|
1970 | if ( uiCode == 0 ) break; |
---|
1971 | i++; |
---|
1972 | } |
---|
1973 | |
---|
1974 | riVal = i*iSign; |
---|
1975 | } |
---|
1976 | |
---|
1977 | Void TDecSbac::parseSaoUflc (UInt& riVal) |
---|
1978 | { |
---|
1979 | UInt uiSymbol; |
---|
1980 | riVal = 0; |
---|
1981 | for (Int i=0;i<5;i++) |
---|
1982 | { |
---|
1983 | m_pcTDecBinIf->decodeBinEP ( uiSymbol ); |
---|
1984 | if (uiSymbol) |
---|
1985 | { |
---|
1986 | riVal |= (1<<i); |
---|
1987 | } |
---|
1988 | } |
---|
1989 | } |
---|
1990 | Void TDecSbac::parseSaoMergeLeft (UInt& ruiVal, UInt uiCompIdx) |
---|
1991 | { |
---|
1992 | UInt uiCode; |
---|
1993 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeLeftSCModel.get( 0, 0, uiCompIdx ) ); |
---|
1994 | ruiVal = (Int)uiCode; |
---|
1995 | } |
---|
1996 | |
---|
1997 | Void TDecSbac::parseSaoMergeUp (UInt& ruiVal) |
---|
1998 | { |
---|
1999 | UInt uiCode; |
---|
2000 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeUpSCModel.get( 0, 0, 0 ) ); |
---|
2001 | ruiVal = (Int)uiCode; |
---|
2002 | } |
---|
2003 | Void TDecSbac::parseSaoTypeIdx (UInt& ruiVal) |
---|
2004 | { |
---|
2005 | UInt uiCode; |
---|
2006 | Int i; |
---|
2007 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); |
---|
2008 | if ( uiCode == 0 ) |
---|
2009 | { |
---|
2010 | ruiVal = 0; |
---|
2011 | return; |
---|
2012 | } |
---|
2013 | i=1; |
---|
2014 | while (1) |
---|
2015 | { |
---|
2016 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 1 ) ); |
---|
2017 | if ( uiCode == 0 ) break; |
---|
2018 | i++; |
---|
2019 | } |
---|
2020 | ruiVal = i; |
---|
2021 | } |
---|
2022 | |
---|
2023 | inline Void copySaoOneLcuParam(SaoLcuParam* psDst, SaoLcuParam* psSrc) |
---|
2024 | { |
---|
2025 | Int i; |
---|
2026 | psDst->partIdx = psSrc->partIdx; |
---|
2027 | psDst->typeIdx = psSrc->typeIdx; |
---|
2028 | if (psDst->typeIdx != -1) |
---|
2029 | { |
---|
2030 | if (psDst->typeIdx == SAO_BO) |
---|
2031 | { |
---|
2032 | psDst->bandPosition = psSrc->bandPosition ; |
---|
2033 | } |
---|
2034 | else |
---|
2035 | { |
---|
2036 | psDst->bandPosition = 0; |
---|
2037 | } |
---|
2038 | psDst->length = psSrc->length; |
---|
2039 | for (i=0;i<psDst->length;i++) |
---|
2040 | { |
---|
2041 | psDst->offset[i] = psSrc->offset[i]; |
---|
2042 | } |
---|
2043 | } |
---|
2044 | else |
---|
2045 | { |
---|
2046 | psDst->length = 0; |
---|
2047 | for (i=0;i<SAO_BO_LEN;i++) |
---|
2048 | { |
---|
2049 | psDst->offset[i] = 0; |
---|
2050 | } |
---|
2051 | } |
---|
2052 | } |
---|
2053 | Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam) |
---|
2054 | { |
---|
2055 | UInt uiSymbol; |
---|
2056 | Int iSymbol; |
---|
2057 | static Int iTypeLength[MAX_NUM_SAO_TYPE] = { |
---|
2058 | SAO_EO_LEN, |
---|
2059 | SAO_EO_LEN, |
---|
2060 | SAO_EO_LEN, |
---|
2061 | SAO_EO_LEN, |
---|
2062 | SAO_BO_LEN |
---|
2063 | }; |
---|
2064 | |
---|
2065 | parseSaoTypeIdx(uiSymbol); |
---|
2066 | psSaoLcuParam->typeIdx = (Int)uiSymbol - 1; |
---|
2067 | if (uiSymbol) |
---|
2068 | { |
---|
2069 | psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx]; |
---|
2070 | if( psSaoLcuParam->typeIdx == SAO_BO ) |
---|
2071 | { |
---|
2072 | // Parse Left Band Index |
---|
2073 | parseSaoUflc( uiSymbol ); |
---|
2074 | psSaoLcuParam->bandPosition = uiSymbol; |
---|
2075 | for(Int i=0; i< psSaoLcuParam->length; i++) |
---|
2076 | { |
---|
2077 | parseSaoSvlc(iSymbol); |
---|
2078 | psSaoLcuParam->offset[i] = iSymbol; |
---|
2079 | } |
---|
2080 | } |
---|
2081 | else if( psSaoLcuParam->typeIdx < 4 ) |
---|
2082 | { |
---|
2083 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[0] = uiSymbol; |
---|
2084 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[1] = uiSymbol; |
---|
2085 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[2] = -(Int)uiSymbol; |
---|
2086 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[3] = -(Int)uiSymbol; |
---|
2087 | } |
---|
2088 | } |
---|
2089 | else |
---|
2090 | { |
---|
2091 | psSaoLcuParam->length = 0; |
---|
2092 | } |
---|
2093 | } |
---|
2094 | |
---|
2095 | Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Bool bLFCrossSliceBoundaryFlag) |
---|
2096 | { |
---|
2097 | Int iAddr = pcCU->getAddr(); |
---|
2098 | UInt uiSymbol; |
---|
2099 | for (Int iCompIdx=0; iCompIdx<3; iCompIdx++) |
---|
2100 | { |
---|
2101 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; |
---|
2102 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; |
---|
2103 | pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition = 0; |
---|
2104 | pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; |
---|
2105 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0] = 0; |
---|
2106 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[1] = 0; |
---|
2107 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[2] = 0; |
---|
2108 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3] = 0; |
---|
2109 | |
---|
2110 | if (pSaoParam->bSaoFlag[iCompIdx]) |
---|
2111 | { |
---|
2112 | if (rx>0 && iCUAddrInSlice!=0) |
---|
2113 | { |
---|
2114 | parseSaoMergeLeft(uiSymbol,iCompIdx); pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = (Int)uiSymbol; |
---|
2115 | } |
---|
2116 | else |
---|
2117 | { |
---|
2118 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; |
---|
2119 | } |
---|
2120 | |
---|
2121 | if (pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag==0) |
---|
2122 | { |
---|
2123 | if ((ry > 0) && (iCUAddrUpInSlice>0||bLFCrossSliceBoundaryFlag)) |
---|
2124 | { |
---|
2125 | parseSaoMergeUp(uiSymbol); pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = uiSymbol; |
---|
2126 | } |
---|
2127 | else |
---|
2128 | { |
---|
2129 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; |
---|
2130 | } |
---|
2131 | if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag) |
---|
2132 | { |
---|
2133 | parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr])); |
---|
2134 | } |
---|
2135 | else |
---|
2136 | { |
---|
2137 | copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-pSaoParam->numCuInWidth]); |
---|
2138 | } |
---|
2139 | } |
---|
2140 | else |
---|
2141 | { |
---|
2142 | copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-1]); |
---|
2143 | } |
---|
2144 | } |
---|
2145 | else |
---|
2146 | { |
---|
2147 | pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; |
---|
2148 | pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition = 0; |
---|
2149 | } |
---|
2150 | } |
---|
2151 | } |
---|
2152 | |
---|
2153 | /** |
---|
2154 | - Initialize our contexts from the nominated source. |
---|
2155 | . |
---|
2156 | \param pSrc Contexts to be copied. |
---|
2157 | */ |
---|
2158 | Void TDecSbac::xCopyContextsFrom( TDecSbac* pSrc ) |
---|
2159 | { |
---|
2160 | memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0])); |
---|
2161 | } |
---|
2162 | |
---|
2163 | Void TDecSbac::xCopyFrom( TDecSbac* pSrc ) |
---|
2164 | { |
---|
2165 | m_pcTDecBinIf->copyState( pSrc->m_pcTDecBinIf ); |
---|
2166 | |
---|
2167 | m_uiLastQp = pSrc->m_uiLastQp; |
---|
2168 | xCopyContextsFrom( pSrc ); |
---|
2169 | |
---|
2170 | } |
---|
2171 | |
---|
2172 | Void TDecSbac::load ( TDecSbac* pScr ) |
---|
2173 | { |
---|
2174 | xCopyFrom(pScr); |
---|
2175 | } |
---|
2176 | |
---|
2177 | Void TDecSbac::loadContexts ( TDecSbac* pScr ) |
---|
2178 | { |
---|
2179 | xCopyContextsFrom(pScr); |
---|
2180 | } |
---|
2181 | |
---|
2182 | Void TDecSbac::decodeFlush ( ) |
---|
2183 | { |
---|
2184 | UInt uiBit; |
---|
2185 | m_pcTDecBinIf->decodeBinTrm(uiBit); |
---|
2186 | m_pcTDecBinIf->flush(); |
---|
2187 | |
---|
2188 | } |
---|
2189 | |
---|
2190 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA_A0070 && LGE_EDGE_INTRA_DELTA_DC) |
---|
2191 | Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel ) |
---|
2192 | { |
---|
2193 | UInt uiSymbol; |
---|
2194 | UInt uiCount = 0; |
---|
2195 | do |
---|
2196 | { |
---|
2197 | m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel ); |
---|
2198 | uiCount++; |
---|
2199 | } |
---|
2200 | while( uiSymbol && ( uiCount != 13 ) ); |
---|
2201 | |
---|
2202 | ruiSymbol = uiCount - 1; |
---|
2203 | |
---|
2204 | if( uiSymbol ) |
---|
2205 | { |
---|
2206 | xReadEpExGolomb( uiSymbol, 0 ); |
---|
2207 | ruiSymbol += uiSymbol + 1; |
---|
2208 | } |
---|
2209 | |
---|
2210 | return; |
---|
2211 | } |
---|
2212 | #endif |
---|
2213 | #if HHI_DMM_WEDGE_INTRA |
---|
2214 | Void TDecSbac::xParseWedgeFullInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2215 | { |
---|
2216 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
2217 | Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx]; |
---|
2218 | |
---|
2219 | UInt uiSymbol, uiTabIdx = 0; |
---|
2220 | for ( Int i = 0; i < iBits; i++ ) |
---|
2221 | { |
---|
2222 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 0) ); |
---|
2223 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
2224 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
2225 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
2226 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
2227 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
2228 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
2229 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
2230 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
2231 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
2232 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
2233 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
2234 | uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0; |
---|
2235 | uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0; |
---|
2236 | } |
---|
2237 | |
---|
2238 | pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
2239 | } |
---|
2240 | |
---|
2241 | Void TDecSbac::xParseWedgeFullDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2242 | { |
---|
2243 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
2244 | Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx]; |
---|
2245 | |
---|
2246 | UInt uiSymbol, uiTabIdx = 0; |
---|
2247 | for ( Int i = 0; i < iBits; i++ ) |
---|
2248 | { |
---|
2249 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 0) ); |
---|
2250 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
2251 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
2252 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
2253 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
2254 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
2255 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
2256 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
2257 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
2258 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
2259 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
2260 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
2261 | uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0; |
---|
2262 | uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0; |
---|
2263 | } |
---|
2264 | |
---|
2265 | pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
2266 | |
---|
2267 | UInt uiDC1, uiDC2; |
---|
2268 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2269 | Int iDC1 = uiDC1; |
---|
2270 | if ( uiDC1 ) |
---|
2271 | { |
---|
2272 | UInt uiSign; |
---|
2273 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2274 | if ( uiSign ) |
---|
2275 | { |
---|
2276 | iDC1 = -iDC1; |
---|
2277 | } |
---|
2278 | } |
---|
2279 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2280 | Int iDC2 = uiDC2; |
---|
2281 | if ( uiDC2 ) |
---|
2282 | { |
---|
2283 | UInt uiSign; |
---|
2284 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2285 | if ( uiSign ) |
---|
2286 | { |
---|
2287 | iDC2 = -iDC2; |
---|
2288 | } |
---|
2289 | } |
---|
2290 | |
---|
2291 | pcCU->setWedgeFullDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
2292 | pcCU->setWedgeFullDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
2293 | } |
---|
2294 | |
---|
2295 | Void TDecSbac::xParseWedgePredDirInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2296 | { |
---|
2297 | if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 ) |
---|
2298 | { |
---|
2299 | UInt uiDeltaEnd = 0; |
---|
2300 | m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cDmmDataSCModel.get(0, 0, 2) ); |
---|
2301 | |
---|
2302 | Int iDeltaEnd; |
---|
2303 | if( uiDeltaEnd != 0 ) |
---|
2304 | { |
---|
2305 | UInt uiAbsValMinus1; |
---|
2306 | UInt uiSymbol; |
---|
2307 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 = uiSymbol; |
---|
2308 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 |= uiSymbol << 1; |
---|
2309 | uiDeltaEnd = uiAbsValMinus1 + 1; |
---|
2310 | |
---|
2311 | iDeltaEnd = uiDeltaEnd; |
---|
2312 | UInt uiSign; |
---|
2313 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2314 | if( uiSign ) |
---|
2315 | { |
---|
2316 | iDeltaEnd = -iDeltaEnd; |
---|
2317 | } |
---|
2318 | } |
---|
2319 | else |
---|
2320 | { |
---|
2321 | iDeltaEnd = 0; |
---|
2322 | } |
---|
2323 | pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth ); |
---|
2324 | } |
---|
2325 | } |
---|
2326 | |
---|
2327 | Void TDecSbac::xParseWedgePredDirDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2328 | { |
---|
2329 | if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 ) |
---|
2330 | { |
---|
2331 | UInt uiDeltaEnd = 0; |
---|
2332 | m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cDmmDataSCModel.get(0, 0, 2) ); |
---|
2333 | |
---|
2334 | Int iDeltaEnd; |
---|
2335 | if( uiDeltaEnd != 0 ) |
---|
2336 | { |
---|
2337 | UInt uiAbsValMinus1; |
---|
2338 | UInt uiSymbol; |
---|
2339 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 = uiSymbol; |
---|
2340 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 |= uiSymbol << 1; |
---|
2341 | uiDeltaEnd = uiAbsValMinus1 + 1; |
---|
2342 | |
---|
2343 | iDeltaEnd = uiDeltaEnd; |
---|
2344 | UInt uiSign; |
---|
2345 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2346 | if( uiSign ) |
---|
2347 | { |
---|
2348 | iDeltaEnd = -iDeltaEnd; |
---|
2349 | } |
---|
2350 | } |
---|
2351 | else |
---|
2352 | { |
---|
2353 | iDeltaEnd = 0; |
---|
2354 | } |
---|
2355 | |
---|
2356 | pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth ); |
---|
2357 | } |
---|
2358 | |
---|
2359 | UInt uiDC1, uiDC2; |
---|
2360 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2361 | Int iDC1 = uiDC1; |
---|
2362 | if ( uiDC1 ) |
---|
2363 | { |
---|
2364 | UInt uiSign; |
---|
2365 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2366 | if ( uiSign ) |
---|
2367 | { |
---|
2368 | iDC1 = -iDC1; |
---|
2369 | } |
---|
2370 | } |
---|
2371 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2372 | Int iDC2 = uiDC2; |
---|
2373 | if ( uiDC2 ) |
---|
2374 | { |
---|
2375 | UInt uiSign; |
---|
2376 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2377 | if ( uiSign ) |
---|
2378 | { |
---|
2379 | iDC2 = -iDC2; |
---|
2380 | } |
---|
2381 | } |
---|
2382 | |
---|
2383 | pcCU->setWedgePredDirDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
2384 | pcCU->setWedgePredDirDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
2385 | } |
---|
2386 | #endif |
---|
2387 | #if HHI_DMM_PRED_TEX |
---|
2388 | #if LGE_DMM3_SIMP_C0044 |
---|
2389 | Void TDecSbac::xParseWedgePredTexInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2390 | { |
---|
2391 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
2392 | Int iBits = g_aucWedgeTexPredBitsListIdx[iIntraIdx]; |
---|
2393 | |
---|
2394 | UInt uiSymbol, uiTabIdx = 0; |
---|
2395 | for ( Int i = 0; i < iBits; i++ ) |
---|
2396 | { |
---|
2397 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 3) ); |
---|
2398 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
2399 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
2400 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
2401 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
2402 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
2403 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
2404 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
2405 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
2406 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
2407 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
2408 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
2409 | } |
---|
2410 | |
---|
2411 | pcCU->setWedgePredTexIntraTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
2412 | } |
---|
2413 | #endif |
---|
2414 | |
---|
2415 | Void TDecSbac::xParseWedgePredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2416 | { |
---|
2417 | #if LGE_DMM3_SIMP_C0044 |
---|
2418 | xParseWedgePredTexInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
2419 | #endif |
---|
2420 | UInt uiDC1, uiDC2; |
---|
2421 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2422 | Int iDC1 = uiDC1; |
---|
2423 | if ( uiDC1 ) |
---|
2424 | { |
---|
2425 | UInt uiSign; |
---|
2426 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2427 | if ( uiSign ) |
---|
2428 | { |
---|
2429 | iDC1 = -iDC1; |
---|
2430 | } |
---|
2431 | } |
---|
2432 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2433 | Int iDC2 = uiDC2; |
---|
2434 | if ( uiDC2 ) |
---|
2435 | { |
---|
2436 | UInt uiSign; |
---|
2437 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2438 | if ( uiSign ) |
---|
2439 | { |
---|
2440 | iDC2 = -iDC2; |
---|
2441 | } |
---|
2442 | } |
---|
2443 | |
---|
2444 | pcCU->setWedgePredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
2445 | pcCU->setWedgePredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
2446 | } |
---|
2447 | |
---|
2448 | Void TDecSbac::xParseContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2449 | { |
---|
2450 | UInt uiDC1, uiDC2; |
---|
2451 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2452 | Int iDC1 = uiDC1; |
---|
2453 | if ( uiDC1 ) |
---|
2454 | { |
---|
2455 | UInt uiSign; |
---|
2456 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2457 | if ( uiSign ) |
---|
2458 | { |
---|
2459 | iDC1 = -iDC1; |
---|
2460 | } |
---|
2461 | } |
---|
2462 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2463 | Int iDC2 = uiDC2; |
---|
2464 | if ( uiDC2 ) |
---|
2465 | { |
---|
2466 | UInt uiSign; |
---|
2467 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2468 | if ( uiSign ) |
---|
2469 | { |
---|
2470 | iDC2 = -iDC2; |
---|
2471 | } |
---|
2472 | } |
---|
2473 | |
---|
2474 | pcCU->setContourPredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
2475 | pcCU->setContourPredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
2476 | } |
---|
2477 | #endif |
---|
2478 | |
---|
2479 | #if LGE_EDGE_INTRA_A0070 |
---|
2480 | Void TDecSbac::xParseEdgeIntraInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2481 | { |
---|
2482 | UInt uiSymbol = 0; |
---|
2483 | |
---|
2484 | // 1. Top(0) or Left(1) |
---|
2485 | UChar ucLeft; |
---|
2486 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
2487 | ucLeft = uiSymbol; |
---|
2488 | |
---|
2489 | // 2. Start position (lowest bit first) |
---|
2490 | UChar ucStart = 0; |
---|
2491 | for( UInt ui = 0; ui < 6 - uiDepth; ui++ ) |
---|
2492 | { |
---|
2493 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
2494 | ucStart |= (uiSymbol << ui); |
---|
2495 | } |
---|
2496 | |
---|
2497 | // 3. Number of edges |
---|
2498 | UChar ucMax = 0; |
---|
2499 | for( UInt ui = 0; ui < 7 - uiDepth; ui++ ) |
---|
2500 | { |
---|
2501 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
2502 | ucMax |= (uiSymbol << ui); |
---|
2503 | } |
---|
2504 | ucMax++; // +1 |
---|
2505 | |
---|
2506 | // 4. Edges |
---|
2507 | UChar* pucSymbolList = (UChar*) xMalloc( UChar, 256 * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 ); |
---|
2508 | UInt uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiAbsPartIdx ); |
---|
2509 | for( Int iPtr = 0; iPtr < ucMax; iPtr++ ) |
---|
2510 | { |
---|
2511 | UChar ucEdge = 0; |
---|
2512 | UInt uiReorderEdge = 0; |
---|
2513 | // Left-friendly direction |
---|
2514 | // 0 ( 0deg) => 0 |
---|
2515 | // 1 ( 45deg) => 10 |
---|
2516 | // 2 ( -45deg) => 110 |
---|
2517 | // 3 ( 90deg) => 1110 |
---|
2518 | // 4 ( -90deg) => 11110 |
---|
2519 | // 5 ( 135deg) => 111110 |
---|
2520 | // 6 (-135deg) => 111111 |
---|
2521 | // Right-friendly direction |
---|
2522 | // 0 ( 0deg) => 0 |
---|
2523 | // 1 ( -45deg) => 10 |
---|
2524 | // 2 ( 45deg) => 110 |
---|
2525 | // 3 ( -90deg) => 1110 |
---|
2526 | // 4 ( 90deg) => 11110 |
---|
2527 | // 5 (-135deg) => 111110 |
---|
2528 | // 6 ( 135deg) => 111111 |
---|
2529 | // refer to a paper "An efficient chain code with Huffman coding" |
---|
2530 | for( UInt ui = 0; ui < 6; ui++ ) |
---|
2531 | { |
---|
2532 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) ); |
---|
2533 | ucEdge <<= 1; |
---|
2534 | ucEdge |= uiSymbol; |
---|
2535 | if( uiSymbol == 0 ) |
---|
2536 | break; |
---|
2537 | } |
---|
2538 | |
---|
2539 | switch( ucEdge ) |
---|
2540 | { |
---|
2541 | case 0 : // "0" |
---|
2542 | uiReorderEdge = 0; |
---|
2543 | break; |
---|
2544 | case 2 : // "10" |
---|
2545 | uiReorderEdge = 1; |
---|
2546 | break; |
---|
2547 | case 6 : // "110" |
---|
2548 | uiReorderEdge = 2; |
---|
2549 | break; |
---|
2550 | case 14 : // "1110" |
---|
2551 | uiReorderEdge = 3; |
---|
2552 | break; |
---|
2553 | case 30 : // "11110" |
---|
2554 | uiReorderEdge = 4; |
---|
2555 | break; |
---|
2556 | case 62 : // "111110" |
---|
2557 | uiReorderEdge = 5; |
---|
2558 | break; |
---|
2559 | case 63 : // "111111" |
---|
2560 | uiReorderEdge = 6; |
---|
2561 | break; |
---|
2562 | default : |
---|
2563 | printf("parseIntraEdgeChain: error (unknown code %d)\n",ucEdge); |
---|
2564 | assert(false); |
---|
2565 | break; |
---|
2566 | } |
---|
2567 | pucSymbolList[iPtr] = uiReorderEdge; |
---|
2568 | } |
---|
2569 | ///////////////////// |
---|
2570 | // Edge Reconstruction |
---|
2571 | Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); |
---|
2572 | pcCU->reconPartition( uiAbsPartIdx, uiDepth, ucLeft == 1, ucStart, ucMax, pucSymbolList, pbRegion ); |
---|
2573 | xFree( pucSymbolList ); |
---|
2574 | } |
---|
2575 | #endif |
---|
2576 | |
---|
2577 | #if RWTH_SDC_DLT_B0036 |
---|
2578 | #if !PKU_QC_DEPTH_INTRA_UNI_D0195 |
---|
2579 | Void TDecSbac::parseSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2580 | { |
---|
2581 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
2582 | |
---|
2583 | UInt uiSymbol = 0; |
---|
2584 | UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx ); |
---|
2585 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) ); |
---|
2586 | |
---|
2587 | if( uiSymbol == 1 ) |
---|
2588 | { |
---|
2589 | pcCU->setPartSizeSubParts(SIZE_2Nx2N, uiAbsPartIdx, uiDepth); |
---|
2590 | |
---|
2591 | pcCU->setSDCFlagSubParts( true, uiAbsPartIdx, 0, uiDepth); |
---|
2592 | pcCU->setTrIdxSubParts(0, uiAbsPartIdx, uiDepth); |
---|
2593 | pcCU->setCbfSubParts(1, 1, 1, uiAbsPartIdx, uiDepth); |
---|
2594 | } |
---|
2595 | } |
---|
2596 | |
---|
2597 | Void TDecSbac::parseSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2598 | { |
---|
2599 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
2600 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
2601 | |
---|
2602 | assert( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
2603 | |
---|
2604 | UInt uiCtx = 0; |
---|
2605 | |
---|
2606 | UInt uiMPModeIdx = 0; |
---|
2607 | |
---|
2608 | for(Int i=0; i<RWTH_SDC_NUM_PRED_MODES-1; i++) |
---|
2609 | { |
---|
2610 | UInt uiIsMostProb = 0; |
---|
2611 | #if INTEL_SDC64_D0193 |
---|
2612 | if( !(pcCU->getWidth(uiAbsPartIdx) == 64 && i == 1)) |
---|
2613 | #endif |
---|
2614 | m_pcTDecBinIf->decodeBin( uiIsMostProb, m_cSDCPredModeSCModel.get( 0, i, uiCtx ) ); |
---|
2615 | |
---|
2616 | if ( uiIsMostProb == 1 ) |
---|
2617 | break; |
---|
2618 | |
---|
2619 | // else: get next most probable pred mode |
---|
2620 | uiMPModeIdx = (uiMPModeIdx+1)%RWTH_SDC_NUM_PRED_MODES; |
---|
2621 | } |
---|
2622 | |
---|
2623 | Int intraPredMode = g_auiSDCPredModes[uiMPModeIdx]; |
---|
2624 | |
---|
2625 | #if HHI_DMM_WEDGE_INTRA |
---|
2626 | if( intraPredMode == DMM_WEDGE_FULL_IDX ) { xParseWedgeFullInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
2627 | if( intraPredMode == DMM_WEDGE_PREDDIR_IDX ) { xParseWedgePredDirInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
2628 | #endif |
---|
2629 | |
---|
2630 | pcCU->setLumaIntraDirSubParts((UChar)intraPredMode, uiAbsPartIdx, uiDepth); |
---|
2631 | } |
---|
2632 | #endif |
---|
2633 | |
---|
2634 | Void TDecSbac::parseSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSegment ) |
---|
2635 | { |
---|
2636 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
2637 | assert( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
2638 | assert( uiSegment < 2 ); |
---|
2639 | |
---|
2640 | UInt uiResidual = 0; |
---|
2641 | UInt uiBit = 0; |
---|
2642 | UInt uiAbsIdx = 0; |
---|
2643 | UInt uiSign = 0; |
---|
2644 | Int iIdx = 0; |
---|
2645 | |
---|
2646 | UInt uiMaxResidualBits = GetBitsPerDepthValue(); |
---|
2647 | assert( uiMaxResidualBits <= g_uiBitDepth ); |
---|
2648 | |
---|
2649 | m_pcTDecBinIf->decodeBin(uiResidual, m_cSDCResidualFlagSCModel.get( 0, uiSegment, 0 ) ); |
---|
2650 | |
---|
2651 | if (uiResidual) |
---|
2652 | { |
---|
2653 | // decode residual sign bit |
---|
2654 | m_pcTDecBinIf->decodeBin(uiSign, m_cSDCResidualSignFlagSCModel.get( 0, uiSegment, 0 ) ); |
---|
2655 | |
---|
2656 | // decode residual magnitude |
---|
2657 | for (Int i=0; i<uiMaxResidualBits; i++) |
---|
2658 | { |
---|
2659 | m_pcTDecBinIf->decodeBin(uiBit, m_cSDCResidualSCModel.get( 0, uiSegment, i ) ); |
---|
2660 | uiAbsIdx |= uiBit << i; |
---|
2661 | } |
---|
2662 | |
---|
2663 | uiAbsIdx += 1; |
---|
2664 | iIdx =(Int)(uiSign ? -1 : 1)*uiAbsIdx; |
---|
2665 | } |
---|
2666 | |
---|
2667 | pcCU->setSDCSegmentDCOffset(iIdx, uiSegment, uiAbsPartIdx); |
---|
2668 | } |
---|
2669 | #endif |
---|
2670 | |
---|
2671 | //! \} |
---|