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