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