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