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 OL_QTLIMIT_PREDCODING_B0068 |
---|
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 | #if HHI_QTLPC_RAU_OFF_C0160 |
---|
718 | Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); |
---|
719 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTLPC()) |
---|
720 | #else |
---|
721 | if(bDepthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC()) |
---|
722 | #endif |
---|
723 | { |
---|
724 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
725 | assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); |
---|
726 | bParseSplitFlag = (pcTextureCU->getDepth(uiAbsPartIdx) > uiDepth); |
---|
727 | } |
---|
728 | |
---|
729 | if(bParseSplitFlag) |
---|
730 | { |
---|
731 | #endif |
---|
732 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) ); |
---|
733 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
734 | DTRACE_CABAC_T( "\tSplitFlag\n" ) |
---|
735 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
736 | } |
---|
737 | else |
---|
738 | uiSymbol = 0; |
---|
739 | #endif |
---|
740 | |
---|
741 | pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx ); |
---|
742 | |
---|
743 | return; |
---|
744 | } |
---|
745 | |
---|
746 | /** parse partition size |
---|
747 | * \param pcCU |
---|
748 | * \param uiAbsPartIdx |
---|
749 | * \param uiDepth |
---|
750 | * \returns Void |
---|
751 | */ |
---|
752 | Void TDecSbac::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
753 | { |
---|
754 | UInt uiSymbol, uiMode = 0; |
---|
755 | PartSize eMode; |
---|
756 | |
---|
757 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
758 | Bool bParsePartSize = true; |
---|
759 | TComSPS *sps = pcCU->getPic()->getSlice(0)->getSPS(); |
---|
760 | TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); |
---|
761 | Bool bDepthMapDetect = (pcTexture != NULL); |
---|
762 | Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); |
---|
763 | |
---|
764 | #if HHI_QTLPC_RAU_OFF_C0160 |
---|
765 | Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); |
---|
766 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTLPC()) |
---|
767 | #else |
---|
768 | if(bDepthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC()) |
---|
769 | #endif |
---|
770 | { |
---|
771 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
772 | assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); |
---|
773 | if (pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth && pcTextureCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN) |
---|
774 | { |
---|
775 | bParsePartSize = false; |
---|
776 | eMode = SIZE_2Nx2N; |
---|
777 | } |
---|
778 | } |
---|
779 | #endif |
---|
780 | |
---|
781 | if ( pcCU->isIntra( uiAbsPartIdx ) ) |
---|
782 | { |
---|
783 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
784 | if(bParsePartSize) |
---|
785 | { |
---|
786 | #endif |
---|
787 | uiSymbol = 1; |
---|
788 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
789 | { |
---|
790 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
791 | } |
---|
792 | eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; |
---|
793 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
794 | } |
---|
795 | #endif |
---|
796 | UInt uiTrLevel = 0; |
---|
797 | UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; |
---|
798 | UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; |
---|
799 | uiTrLevel = uiWidthInBit >= uiTrSizeInBit ? uiWidthInBit - uiTrSizeInBit : 0; |
---|
800 | if( eMode == SIZE_NxN ) |
---|
801 | { |
---|
802 | pcCU->setTrIdxSubParts( 1+uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
803 | } |
---|
804 | else |
---|
805 | { |
---|
806 | pcCU->setTrIdxSubParts( uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
807 | } |
---|
808 | } |
---|
809 | else |
---|
810 | { |
---|
811 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
812 | if(bParsePartSize) |
---|
813 | { |
---|
814 | #endif |
---|
815 | UInt uiMaxNumBits = 2; |
---|
816 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getSlice()->getSPS()->getDisInter4x4() && (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) ) |
---|
817 | { |
---|
818 | uiMaxNumBits ++; |
---|
819 | } |
---|
820 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
821 | { |
---|
822 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); |
---|
823 | if ( uiSymbol ) |
---|
824 | { |
---|
825 | break; |
---|
826 | } |
---|
827 | uiMode++; |
---|
828 | } |
---|
829 | eMode = (PartSize) uiMode; |
---|
830 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
831 | { |
---|
832 | if (eMode == SIZE_2NxN) |
---|
833 | { |
---|
834 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 )); |
---|
835 | if (uiSymbol == 0) |
---|
836 | { |
---|
837 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
838 | eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); |
---|
839 | } |
---|
840 | } |
---|
841 | else if (eMode == SIZE_Nx2N) |
---|
842 | { |
---|
843 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 )); |
---|
844 | if (uiSymbol == 0) |
---|
845 | { |
---|
846 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
847 | eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); |
---|
848 | } |
---|
849 | } |
---|
850 | } |
---|
851 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
852 | } |
---|
853 | #endif |
---|
854 | } |
---|
855 | pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth ); |
---|
856 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
857 | } |
---|
858 | |
---|
859 | /** parse prediction mode |
---|
860 | * \param pcCU |
---|
861 | * \param uiAbsPartIdx |
---|
862 | * \param uiDepth |
---|
863 | * \returns Void |
---|
864 | */ |
---|
865 | Void TDecSbac::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
866 | { |
---|
867 | if( pcCU->getSlice()->isIntra() ) |
---|
868 | { |
---|
869 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
870 | return; |
---|
871 | } |
---|
872 | |
---|
873 | UInt uiSymbol; |
---|
874 | Int iPredMode = MODE_INTER; |
---|
875 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) ); |
---|
876 | iPredMode += uiSymbol; |
---|
877 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
878 | } |
---|
879 | |
---|
880 | Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
881 | { |
---|
882 | UInt uiSymbol; |
---|
883 | Int intraPredMode; |
---|
884 | |
---|
885 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
886 | UInt uiFlag = 0; |
---|
887 | if( pcCU->getSlice()->getSPS()->getUseDMM() && (g_uiMaxCUWidth>>uiDepth) <= DMM_WEDGEMODEL_MAX_SIZE ) |
---|
888 | { |
---|
889 | m_pcTDecBinIf->decodeBin( uiFlag, m_cDmmFlagSCModel.get(0, 0, 0) ); |
---|
890 | } |
---|
891 | if( uiFlag ) |
---|
892 | { |
---|
893 | UInt uiDMMode; |
---|
894 | |
---|
895 | #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX |
---|
896 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode = uiSymbol; |
---|
897 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 1; |
---|
898 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
899 | { |
---|
900 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 2; |
---|
901 | } |
---|
902 | #else |
---|
903 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode = uiSymbol; |
---|
904 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
905 | { |
---|
906 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 1; |
---|
907 | } |
---|
908 | #endif |
---|
909 | intraPredMode = uiDMMode + NUM_INTRA_MODE; |
---|
910 | |
---|
911 | #if HHI_DMM_WEDGE_INTRA |
---|
912 | if( intraPredMode == DMM_WEDGE_FULL_IDX ) { xParseWedgeFullInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
913 | if( intraPredMode == DMM_WEDGE_FULL_D_IDX ) { xParseWedgeFullDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
914 | if( intraPredMode == DMM_WEDGE_PREDDIR_IDX ) { xParseWedgePredDirInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
915 | if( intraPredMode == DMM_WEDGE_PREDDIR_D_IDX ) { xParseWedgePredDirDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
916 | #endif |
---|
917 | #if HHI_DMM_PRED_TEX |
---|
918 | if( intraPredMode == DMM_WEDGE_PREDTEX_D_IDX ) { xParseWedgePredTexDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
919 | #if LGE_DMM3_SIMP_C0044 |
---|
920 | if( intraPredMode == DMM_WEDGE_PREDTEX_IDX ) { xParseWedgePredTexInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
921 | #endif |
---|
922 | if( intraPredMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xParseContourPredTexDeltaInfo( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
923 | #endif |
---|
924 | } |
---|
925 | else |
---|
926 | { |
---|
927 | #endif |
---|
928 | |
---|
929 | #if LGE_EDGE_INTRA_A0070 |
---|
930 | Bool bCodeEdgeIntra = false; |
---|
931 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
932 | { |
---|
933 | UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0); |
---|
934 | if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE ) |
---|
935 | bCodeEdgeIntra = true; |
---|
936 | } |
---|
937 | #endif |
---|
938 | |
---|
939 | Int uiPreds[3] = {-1, -1, -1}; |
---|
940 | Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); |
---|
941 | #if LGE_EDGE_INTRA_A0070 |
---|
942 | UInt uiCheckBit = 0; |
---|
943 | #endif |
---|
944 | |
---|
945 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); |
---|
946 | |
---|
947 | if ( uiSymbol ) |
---|
948 | { |
---|
949 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
950 | if (uiSymbol) |
---|
951 | { |
---|
952 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
953 | uiSymbol++; |
---|
954 | } |
---|
955 | intraPredMode = uiPreds[uiSymbol]; |
---|
956 | } |
---|
957 | else |
---|
958 | { |
---|
959 | intraPredMode = 0; |
---|
960 | |
---|
961 | |
---|
962 | m_pcTDecBinIf->decodeBinsEP( uiSymbol, 5 ); |
---|
963 | #if LGE_EDGE_INTRA_A0070 |
---|
964 | if (bCodeEdgeIntra) |
---|
965 | { |
---|
966 | if (uiSymbol==31) |
---|
967 | { |
---|
968 | m_pcTDecBinIf->decodeBinsEP(uiCheckBit,1); |
---|
969 | if (uiCheckBit) |
---|
970 | uiSymbol = EDGE_INTRA_IDX; |
---|
971 | } |
---|
972 | } |
---|
973 | #endif |
---|
974 | intraPredMode = uiSymbol; |
---|
975 | |
---|
976 | //postponed sorting of MPMs (only in remaining branch) |
---|
977 | if (uiPreds[0] > uiPreds[1]) |
---|
978 | { |
---|
979 | std::swap(uiPreds[0], uiPreds[1]); |
---|
980 | } |
---|
981 | if (uiPreds[0] > uiPreds[2]) |
---|
982 | { |
---|
983 | std::swap(uiPreds[0], uiPreds[2]); |
---|
984 | } |
---|
985 | if (uiPreds[1] > uiPreds[2]) |
---|
986 | { |
---|
987 | std::swap(uiPreds[1], uiPreds[2]); |
---|
988 | } |
---|
989 | #if LGE_EDGE_INTRA_A0070 |
---|
990 | if ( intraPredMode != EDGE_INTRA_IDX) |
---|
991 | { |
---|
992 | #endif |
---|
993 | for ( Int i = 0; i < uiPredNum; i++ ) |
---|
994 | { |
---|
995 | intraPredMode += ( intraPredMode >= uiPreds[i] ); |
---|
996 | } |
---|
997 | #if LGE_EDGE_INTRA_A0070 |
---|
998 | } |
---|
999 | #endif |
---|
1000 | } |
---|
1001 | |
---|
1002 | #if LGE_EDGE_INTRA_A0070 |
---|
1003 | if( intraPredMode == EDGE_INTRA_IDX ) |
---|
1004 | { |
---|
1005 | xParseEdgeIntraInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
1006 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
1007 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) ); |
---|
1008 | if( uiSymbol ) |
---|
1009 | { |
---|
1010 | intraPredMode = EDGE_INTRA_DELTA_IDX; |
---|
1011 | Int iDeltaDC0; |
---|
1012 | Int iDeltaDC1; |
---|
1013 | |
---|
1014 | xReadExGolombLevel( (UInt &) iDeltaDC0, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); |
---|
1015 | if( iDeltaDC0 != 0 ) |
---|
1016 | { |
---|
1017 | UInt uiSign; |
---|
1018 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1019 | if ( uiSign ) |
---|
1020 | { |
---|
1021 | iDeltaDC0 = -iDeltaDC0; |
---|
1022 | } |
---|
1023 | } |
---|
1024 | xReadExGolombLevel( (UInt &) iDeltaDC1, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); |
---|
1025 | if( iDeltaDC1 != 0 ) |
---|
1026 | { |
---|
1027 | UInt uiSign; |
---|
1028 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1029 | if ( uiSign ) |
---|
1030 | { |
---|
1031 | iDeltaDC1 = -iDeltaDC1; |
---|
1032 | } |
---|
1033 | } |
---|
1034 | |
---|
1035 | pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 ); |
---|
1036 | pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 ); |
---|
1037 | } |
---|
1038 | #endif |
---|
1039 | } |
---|
1040 | #endif |
---|
1041 | |
---|
1042 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1043 | } |
---|
1044 | #endif |
---|
1045 | |
---|
1046 | pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, uiAbsPartIdx, uiDepth ); |
---|
1047 | } |
---|
1048 | |
---|
1049 | Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1050 | { |
---|
1051 | UInt uiSymbol; |
---|
1052 | |
---|
1053 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) ); |
---|
1054 | |
---|
1055 | if( uiSymbol == 0 ) |
---|
1056 | { |
---|
1057 | uiSymbol = DM_CHROMA_IDX; |
---|
1058 | } |
---|
1059 | else |
---|
1060 | { |
---|
1061 | if( pcCU->getSlice()->getSPS()->getUseLMChroma() ) |
---|
1062 | { |
---|
1063 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 1 ) ); |
---|
1064 | } |
---|
1065 | else |
---|
1066 | { |
---|
1067 | uiSymbol = 1; |
---|
1068 | } |
---|
1069 | |
---|
1070 | if( uiSymbol == 0 ) |
---|
1071 | { |
---|
1072 | uiSymbol = LM_CHROMA_IDX; |
---|
1073 | } |
---|
1074 | else |
---|
1075 | { |
---|
1076 | UInt uiIPredMode; |
---|
1077 | m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 ); |
---|
1078 | UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; |
---|
1079 | pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); |
---|
1080 | uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; |
---|
1081 | } |
---|
1082 | } |
---|
1083 | pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); |
---|
1084 | return; |
---|
1085 | } |
---|
1086 | |
---|
1087 | Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1088 | { |
---|
1089 | UInt uiSymbol; |
---|
1090 | const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); |
---|
1091 | ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 ); |
---|
1092 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) ); |
---|
1093 | |
---|
1094 | if( uiSymbol ) |
---|
1095 | { |
---|
1096 | uiSymbol = 2; |
---|
1097 | } |
---|
1098 | |
---|
1099 | uiSymbol++; |
---|
1100 | ruiInterDir = uiSymbol; |
---|
1101 | return; |
---|
1102 | } |
---|
1103 | |
---|
1104 | Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
1105 | { |
---|
1106 | UInt uiSymbol; |
---|
1107 | |
---|
1108 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C ) > 0 && eRefList==REF_PIC_LIST_C) |
---|
1109 | { |
---|
1110 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
1111 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1112 | |
---|
1113 | if( uiSymbol ) |
---|
1114 | { |
---|
1115 | xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_C )-2 ); |
---|
1116 | uiSymbol++; |
---|
1117 | } |
---|
1118 | riRefFrmIdx = uiSymbol; |
---|
1119 | } |
---|
1120 | else |
---|
1121 | { |
---|
1122 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
1123 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1124 | |
---|
1125 | if( uiSymbol ) |
---|
1126 | { |
---|
1127 | xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( eRefList )-2 ); |
---|
1128 | uiSymbol++; |
---|
1129 | } |
---|
1130 | riRefFrmIdx = uiSymbol; |
---|
1131 | } |
---|
1132 | |
---|
1133 | return; |
---|
1134 | } |
---|
1135 | |
---|
1136 | Void TDecSbac::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
1137 | { |
---|
1138 | UInt uiSymbol; |
---|
1139 | UInt uiHorAbs; |
---|
1140 | UInt uiVerAbs; |
---|
1141 | UInt uiHorSign = 0; |
---|
1142 | UInt uiVerSign = 0; |
---|
1143 | ContextModel *pCtx = m_cCUMvdSCModel.get( 0 ); |
---|
1144 | |
---|
1145 | if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3) |
---|
1146 | { |
---|
1147 | uiHorAbs=0; |
---|
1148 | uiVerAbs=0; |
---|
1149 | } |
---|
1150 | else |
---|
1151 | { |
---|
1152 | |
---|
1153 | m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx ); |
---|
1154 | m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx ); |
---|
1155 | |
---|
1156 | const Bool bHorAbsGr0 = uiHorAbs != 0; |
---|
1157 | const Bool bVerAbsGr0 = uiVerAbs != 0; |
---|
1158 | pCtx++; |
---|
1159 | |
---|
1160 | if( bHorAbsGr0 ) |
---|
1161 | { |
---|
1162 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1163 | uiHorAbs += uiSymbol; |
---|
1164 | } |
---|
1165 | |
---|
1166 | if( bVerAbsGr0 ) |
---|
1167 | { |
---|
1168 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1169 | uiVerAbs += uiSymbol; |
---|
1170 | } |
---|
1171 | |
---|
1172 | if( bHorAbsGr0 ) |
---|
1173 | { |
---|
1174 | if( 2 == uiHorAbs ) |
---|
1175 | { |
---|
1176 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
1177 | uiHorAbs += uiSymbol; |
---|
1178 | } |
---|
1179 | |
---|
1180 | m_pcTDecBinIf->decodeBinEP( uiHorSign ); |
---|
1181 | } |
---|
1182 | |
---|
1183 | if( bVerAbsGr0 ) |
---|
1184 | { |
---|
1185 | if( 2 == uiVerAbs ) |
---|
1186 | { |
---|
1187 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
1188 | uiVerAbs += uiSymbol; |
---|
1189 | } |
---|
1190 | |
---|
1191 | m_pcTDecBinIf->decodeBinEP( uiVerSign ); |
---|
1192 | } |
---|
1193 | |
---|
1194 | } |
---|
1195 | |
---|
1196 | const TComMv cMv( uiHorSign ? -Int( uiHorAbs ): uiHorAbs, uiVerSign ? -Int( uiVerAbs ) : uiVerAbs ); |
---|
1197 | pcCU->getCUMvField( eRefList )->setAllMvd( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1198 | return; |
---|
1199 | } |
---|
1200 | |
---|
1201 | |
---|
1202 | Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) |
---|
1203 | { |
---|
1204 | m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) ); |
---|
1205 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1206 | DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) |
---|
1207 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1208 | DTRACE_CABAC_V( ruiSubdivFlag ) |
---|
1209 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1210 | DTRACE_CABAC_V( uiLog2TransformBlockSize ) |
---|
1211 | DTRACE_CABAC_T( "\n" ) |
---|
1212 | } |
---|
1213 | |
---|
1214 | Void TDecSbac::parseQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf ) |
---|
1215 | { |
---|
1216 | UInt uiSymbol; |
---|
1217 | const UInt uiCtx = 0; |
---|
1218 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) ); |
---|
1219 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1220 | DTRACE_CABAC_T( "\tparseQtRootCbf()" ) |
---|
1221 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1222 | DTRACE_CABAC_V( uiSymbol ) |
---|
1223 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1224 | DTRACE_CABAC_V( uiCtx ) |
---|
1225 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1226 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1227 | DTRACE_CABAC_T( "\n" ) |
---|
1228 | |
---|
1229 | uiQtRootCbf = uiSymbol; |
---|
1230 | } |
---|
1231 | |
---|
1232 | Void TDecSbac::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1233 | { |
---|
1234 | Int qp; |
---|
1235 | UInt uiDQp; |
---|
1236 | Int iDQp; |
---|
1237 | |
---|
1238 | m_pcTDecBinIf->decodeBin( uiDQp, m_cCUDeltaQpSCModel.get( 0, 0, 0 ) ); |
---|
1239 | |
---|
1240 | if ( uiDQp == 0 ) |
---|
1241 | { |
---|
1242 | qp = pcCU->getRefQP(uiAbsPartIdx); |
---|
1243 | } |
---|
1244 | else |
---|
1245 | { |
---|
1246 | UInt uiSign; |
---|
1247 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
1248 | m_pcTDecBinIf->decodeBinEP(uiSign); |
---|
1249 | |
---|
1250 | UInt uiMaxAbsDQpMinus1 = 24 + (qpBdOffsetY/2) + (uiSign); |
---|
1251 | UInt uiAbsDQpMinus1; |
---|
1252 | xReadUnaryMaxSymbol (uiAbsDQpMinus1, &m_cCUDeltaQpSCModel.get( 0, 0, 1 ), 1, uiMaxAbsDQpMinus1); |
---|
1253 | |
---|
1254 | iDQp = uiAbsDQpMinus1 + 1; |
---|
1255 | |
---|
1256 | if(uiSign) |
---|
1257 | { |
---|
1258 | iDQp = -iDQp; |
---|
1259 | } |
---|
1260 | |
---|
1261 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY; |
---|
1262 | } |
---|
1263 | |
---|
1264 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)))<<(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)) ; |
---|
1265 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
1266 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
1267 | } |
---|
1268 | |
---|
1269 | Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) |
---|
1270 | { |
---|
1271 | UInt uiSymbol; |
---|
1272 | const UInt uiCtx = pcCU->getCtxQtCbf( uiAbsPartIdx, eType, uiTrDepth ); |
---|
1273 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) ); |
---|
1274 | |
---|
1275 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1276 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
1277 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1278 | DTRACE_CABAC_V( uiSymbol ) |
---|
1279 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1280 | DTRACE_CABAC_V( uiCtx ) |
---|
1281 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1282 | DTRACE_CABAC_V( eType ) |
---|
1283 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1284 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1285 | DTRACE_CABAC_T( "\n" ) |
---|
1286 | |
---|
1287 | pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth ); |
---|
1288 | } |
---|
1289 | |
---|
1290 | /** Parse (X,Y) position of the last significant coefficient |
---|
1291 | * \param uiPosLastX reference to X component of last coefficient |
---|
1292 | * \param uiPosLastY reference to Y component of last coefficient |
---|
1293 | * \param width Block width |
---|
1294 | * \param height Block height |
---|
1295 | * \param eTType plane type / luminance or chrominance |
---|
1296 | * \param uiScanIdx scan type (zig-zag, hor, ver) |
---|
1297 | * |
---|
1298 | * This method decodes the X and Y component within a block of the last significant coefficient. |
---|
1299 | */ |
---|
1300 | Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx ) |
---|
1301 | { |
---|
1302 | UInt uiLast; |
---|
1303 | ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); |
---|
1304 | ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); |
---|
1305 | |
---|
1306 | // posX |
---|
1307 | Int widthCtx = eTType ? 4 : width; |
---|
1308 | const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ widthCtx ] * ( g_aucConvertToBit[ widthCtx ] + 3 ) ); |
---|
1309 | for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ ) |
---|
1310 | { |
---|
1311 | if ( eTType ) |
---|
1312 | { |
---|
1313 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + (uiPosLastX>>g_aucConvertToBit[ width ]) ) ); |
---|
1314 | } |
---|
1315 | else |
---|
1316 | { |
---|
1317 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + puiCtxIdxX[ uiPosLastX ] ) ); |
---|
1318 | } |
---|
1319 | if( !uiLast ) |
---|
1320 | { |
---|
1321 | break; |
---|
1322 | } |
---|
1323 | } |
---|
1324 | |
---|
1325 | // posY |
---|
1326 | Int heightCtx = eTType? 4 : height; |
---|
1327 | const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ heightCtx ] * ( g_aucConvertToBit[ heightCtx ] + 3 ) ); |
---|
1328 | for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ ) |
---|
1329 | { |
---|
1330 | if (eTType) |
---|
1331 | { |
---|
1332 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + (uiPosLastY>>g_aucConvertToBit[ height ]) ) ); |
---|
1333 | } |
---|
1334 | else |
---|
1335 | { |
---|
1336 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + puiCtxIdxY[ uiPosLastY ] ) ); |
---|
1337 | } |
---|
1338 | if( !uiLast ) |
---|
1339 | { |
---|
1340 | break; |
---|
1341 | } |
---|
1342 | } |
---|
1343 | if ( uiPosLastX > 3 ) |
---|
1344 | { |
---|
1345 | UInt uiTemp = 0; |
---|
1346 | UInt uiCount = ( uiPosLastX - 2 ) >> 1; |
---|
1347 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
1348 | { |
---|
1349 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
1350 | uiTemp += uiLast << i; |
---|
1351 | } |
---|
1352 | uiPosLastX = g_uiMinInGroup[ uiPosLastX ] + uiTemp; |
---|
1353 | } |
---|
1354 | if ( uiPosLastY > 3 ) |
---|
1355 | { |
---|
1356 | UInt uiTemp = 0; |
---|
1357 | UInt uiCount = ( uiPosLastY - 2 ) >> 1; |
---|
1358 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
1359 | { |
---|
1360 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
1361 | uiTemp += uiLast << i; |
---|
1362 | } |
---|
1363 | uiPosLastY = g_uiMinInGroup[ uiPosLastY ] + uiTemp; |
---|
1364 | } |
---|
1365 | |
---|
1366 | if( uiScanIdx == SCAN_VER ) |
---|
1367 | { |
---|
1368 | swap( uiPosLastX, uiPosLastY ); |
---|
1369 | } |
---|
1370 | } |
---|
1371 | |
---|
1372 | Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
1373 | { |
---|
1374 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1375 | DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) |
---|
1376 | DTRACE_CABAC_V( eTType ) |
---|
1377 | DTRACE_CABAC_T( "\twidth=" ) |
---|
1378 | DTRACE_CABAC_V( uiWidth ) |
---|
1379 | DTRACE_CABAC_T( "\theight=" ) |
---|
1380 | DTRACE_CABAC_V( uiHeight ) |
---|
1381 | DTRACE_CABAC_T( "\tdepth=" ) |
---|
1382 | DTRACE_CABAC_V( uiDepth ) |
---|
1383 | DTRACE_CABAC_T( "\tabspartidx=" ) |
---|
1384 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1385 | DTRACE_CABAC_T( "\ttoCU-X=" ) |
---|
1386 | DTRACE_CABAC_V( pcCU->getCUPelX() ) |
---|
1387 | DTRACE_CABAC_T( "\ttoCU-Y=" ) |
---|
1388 | DTRACE_CABAC_V( pcCU->getCUPelY() ) |
---|
1389 | DTRACE_CABAC_T( "\tCU-addr=" ) |
---|
1390 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
1391 | DTRACE_CABAC_T( "\tinCU-X=" ) |
---|
1392 | DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1393 | DTRACE_CABAC_T( "\tinCU-Y=" ) |
---|
1394 | DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1395 | DTRACE_CABAC_T( "\tpredmode=" ) |
---|
1396 | DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) |
---|
1397 | DTRACE_CABAC_T( "\n" ) |
---|
1398 | |
---|
1399 | if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) |
---|
1400 | { |
---|
1401 | uiWidth = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
1402 | uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
1403 | } |
---|
1404 | |
---|
1405 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); |
---|
1406 | |
---|
1407 | //----- parse significance map ----- |
---|
1408 | const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; |
---|
1409 | const UInt uiMaxNumCoeff = uiWidth * uiHeight; |
---|
1410 | const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; |
---|
1411 | UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); |
---|
1412 | int blockType = uiLog2BlockSize; |
---|
1413 | if (uiWidth != uiHeight) |
---|
1414 | { |
---|
1415 | uiScanIdx = SCAN_DIAG; |
---|
1416 | blockType = 4; |
---|
1417 | } |
---|
1418 | |
---|
1419 | //===== decode last significant ===== |
---|
1420 | UInt uiPosLastX, uiPosLastY; |
---|
1421 | parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, eTType, uiScanIdx ); |
---|
1422 | UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockSize); |
---|
1423 | pcCoef[ uiBlkPosLast ] = 1; |
---|
1424 | |
---|
1425 | //===== decode significance flags ===== |
---|
1426 | UInt uiScanPosLast = uiBlkPosLast; |
---|
1427 | if (uiScanIdx == SCAN_ZIGZAG) |
---|
1428 | { |
---|
1429 | // Map zigzag to diagonal scan |
---|
1430 | uiScanIdx = SCAN_DIAG; |
---|
1431 | } |
---|
1432 | const UInt * scan; |
---|
1433 | if (uiWidth == uiHeight) |
---|
1434 | { |
---|
1435 | scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ]; |
---|
1436 | } |
---|
1437 | else |
---|
1438 | { |
---|
1439 | scan = g_sigScanNSQT[ uiLog2BlockSize - 2 ]; |
---|
1440 | } |
---|
1441 | for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ ) |
---|
1442 | { |
---|
1443 | UInt uiBlkPos = scan[ uiScanPosLast ]; |
---|
1444 | if( uiBlkPosLast == uiBlkPos ) |
---|
1445 | { |
---|
1446 | break; |
---|
1447 | } |
---|
1448 | } |
---|
1449 | |
---|
1450 | ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, eTType ); |
---|
1451 | ContextModel * const baseCtx = (eTType==TEXT_LUMA) ? m_cCUSigSCModel.get( 0, 0 ) : m_cCUSigSCModel.get( 0, 0 ) + NUM_SIG_FLAG_CTX_LUMA; |
---|
1452 | |
---|
1453 | const Int iLastScanSet = uiScanPosLast >> LOG2_SCAN_SET_SIZE; |
---|
1454 | UInt uiNumOne = 0; |
---|
1455 | UInt uiGoRiceParam = 0; |
---|
1456 | |
---|
1457 | UInt const tsig = pcCU->getSlice()->getPPS()->getTSIG(); |
---|
1458 | #if LOSSLESS_CODING |
---|
1459 | Bool beValid; |
---|
1460 | if (pcCU->isLosslessCoded(uiAbsPartIdx)) |
---|
1461 | { |
---|
1462 | beValid = false; |
---|
1463 | } |
---|
1464 | else |
---|
1465 | { |
---|
1466 | beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
1467 | } |
---|
1468 | #else |
---|
1469 | Bool beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
1470 | #endif |
---|
1471 | UInt absSum = 0; |
---|
1472 | |
---|
1473 | UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ]; |
---|
1474 | ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); |
---|
1475 | const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1); |
---|
1476 | const UInt * scanCG; |
---|
1477 | if (uiWidth == uiHeight) |
---|
1478 | { |
---|
1479 | scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ]; |
---|
1480 | if( uiLog2BlockSize == 3 ) |
---|
1481 | { |
---|
1482 | scanCG = g_sigLastScan8x8[ uiScanIdx ]; |
---|
1483 | } |
---|
1484 | else if( uiLog2BlockSize == 5 ) |
---|
1485 | { |
---|
1486 | scanCG = g_sigLastScanCG32x32; |
---|
1487 | } |
---|
1488 | } |
---|
1489 | else |
---|
1490 | { |
---|
1491 | scanCG = g_sigCGScanNSQT[ uiLog2BlockSize - 2 ]; |
---|
1492 | } |
---|
1493 | Int iScanPosSig = (Int) uiScanPosLast; |
---|
1494 | for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- ) |
---|
1495 | { |
---|
1496 | Int iSubPos = iSubSet << LOG2_SCAN_SET_SIZE; |
---|
1497 | uiGoRiceParam = 0; |
---|
1498 | Int numNonZero = 0; |
---|
1499 | |
---|
1500 | Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE; |
---|
1501 | |
---|
1502 | Int pos[SCAN_SET_SIZE]; |
---|
1503 | if( iScanPosSig == (Int) uiScanPosLast ) |
---|
1504 | { |
---|
1505 | lastNZPosInCG = iScanPosSig; |
---|
1506 | firstNZPosInCG = iScanPosSig; |
---|
1507 | iScanPosSig--; |
---|
1508 | pos[ numNonZero ] = uiBlkPosLast; |
---|
1509 | numNonZero = 1; |
---|
1510 | } |
---|
1511 | |
---|
1512 | // decode significant_coeffgroup_flag |
---|
1513 | Int iCGBlkPos = scanCG[ iSubSet ]; |
---|
1514 | Int iCGPosY = iCGBlkPos / uiNumBlkSide; |
---|
1515 | Int iCGPosX = iCGBlkPos - (iCGPosY * uiNumBlkSide); |
---|
1516 | if( uiWidth == 8 && uiHeight == 8 && (uiScanIdx == SCAN_HOR || uiScanIdx == SCAN_VER) ) |
---|
1517 | { |
---|
1518 | iCGPosY = (uiScanIdx == SCAN_HOR ? iCGBlkPos : 0); |
---|
1519 | iCGPosX = (uiScanIdx == SCAN_VER ? iCGBlkPos : 0); |
---|
1520 | } |
---|
1521 | if( iSubSet == iLastScanSet || iSubSet == 0) |
---|
1522 | { |
---|
1523 | uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; |
---|
1524 | } |
---|
1525 | else |
---|
1526 | { |
---|
1527 | UInt uiSigCoeffGroup; |
---|
1528 | UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight ); |
---|
1529 | m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] ); |
---|
1530 | uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup; |
---|
1531 | } |
---|
1532 | |
---|
1533 | // decode significant_coeff_flag |
---|
1534 | UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig; |
---|
1535 | for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) |
---|
1536 | { |
---|
1537 | uiBlkPos = scan[ iScanPosSig ]; |
---|
1538 | uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
1539 | uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
1540 | uiSig = 0; |
---|
1541 | |
---|
1542 | if( uiSigCoeffGroupFlag[ iCGBlkPos ] ) |
---|
1543 | { |
---|
1544 | if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) |
---|
1545 | { |
---|
1546 | uiCtxSig = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType ); |
---|
1547 | m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] ); |
---|
1548 | } |
---|
1549 | else |
---|
1550 | { |
---|
1551 | uiSig = 1; |
---|
1552 | } |
---|
1553 | } |
---|
1554 | pcCoef[ uiBlkPos ] = uiSig; |
---|
1555 | if( uiSig ) |
---|
1556 | { |
---|
1557 | pos[ numNonZero ] = uiBlkPos; |
---|
1558 | numNonZero ++; |
---|
1559 | if( lastNZPosInCG == -1 ) |
---|
1560 | { |
---|
1561 | lastNZPosInCG = iScanPosSig; |
---|
1562 | } |
---|
1563 | firstNZPosInCG = iScanPosSig; |
---|
1564 | } |
---|
1565 | } |
---|
1566 | |
---|
1567 | |
---|
1568 | if( numNonZero ) |
---|
1569 | { |
---|
1570 | Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= (Int)tsig ); |
---|
1571 | absSum = 0; |
---|
1572 | |
---|
1573 | UInt c1 = 1; |
---|
1574 | UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0; |
---|
1575 | UInt uiBin; |
---|
1576 | |
---|
1577 | if( uiNumOne > 0 ) |
---|
1578 | { |
---|
1579 | uiCtxSet++; |
---|
1580 | } |
---|
1581 | |
---|
1582 | uiNumOne >>= 1; |
---|
1583 | ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet; |
---|
1584 | Int absCoeff[SCAN_SET_SIZE]; |
---|
1585 | |
---|
1586 | for ( Int i = 0; i < numNonZero; i++) absCoeff[i] = 1; |
---|
1587 | Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); |
---|
1588 | Int firstC2FlagIdx = -1; |
---|
1589 | |
---|
1590 | for( Int idx = 0; idx < numC1Flag; idx++ ) |
---|
1591 | { |
---|
1592 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] ); |
---|
1593 | if( uiBin == 1 ) |
---|
1594 | { |
---|
1595 | c1 = 0; |
---|
1596 | if (firstC2FlagIdx == -1) |
---|
1597 | { |
---|
1598 | firstC2FlagIdx = idx; |
---|
1599 | } |
---|
1600 | } |
---|
1601 | else if( (c1 < 3) && (c1 > 0) ) |
---|
1602 | { |
---|
1603 | c1++; |
---|
1604 | } |
---|
1605 | absCoeff[ idx ] = uiBin + 1; |
---|
1606 | } |
---|
1607 | |
---|
1608 | if (c1 == 0) |
---|
1609 | { |
---|
1610 | baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet; |
---|
1611 | if ( firstC2FlagIdx != -1) |
---|
1612 | { |
---|
1613 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] ); |
---|
1614 | absCoeff[ firstC2FlagIdx ] = uiBin + 2; |
---|
1615 | } |
---|
1616 | } |
---|
1617 | |
---|
1618 | UInt coeffSigns; |
---|
1619 | if ( signHidden && beValid ) |
---|
1620 | { |
---|
1621 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 ); |
---|
1622 | coeffSigns <<= 32 - (numNonZero-1); |
---|
1623 | } |
---|
1624 | else |
---|
1625 | { |
---|
1626 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero ); |
---|
1627 | coeffSigns <<= 32 - numNonZero; |
---|
1628 | } |
---|
1629 | |
---|
1630 | Int iFirstCoeff2 = 1; |
---|
1631 | if (c1 == 0 || numNonZero > C1FLAG_NUMBER) |
---|
1632 | { |
---|
1633 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
1634 | { |
---|
1635 | UInt baseLevel = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2) : 1; |
---|
1636 | |
---|
1637 | if( absCoeff[ idx ] == baseLevel) |
---|
1638 | { |
---|
1639 | UInt uiLevel; |
---|
1640 | xReadGoRiceExGolomb( uiLevel, uiGoRiceParam ); |
---|
1641 | absCoeff[ idx ] = uiLevel + baseLevel; |
---|
1642 | } |
---|
1643 | |
---|
1644 | if(absCoeff[ idx ] >= 2) |
---|
1645 | { |
---|
1646 | iFirstCoeff2 = 0; |
---|
1647 | uiNumOne++; |
---|
1648 | } |
---|
1649 | } |
---|
1650 | } |
---|
1651 | |
---|
1652 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
1653 | { |
---|
1654 | Int blkPos = pos[ idx ]; |
---|
1655 | // Signs applied later. |
---|
1656 | pcCoef[ blkPos ] = absCoeff[ idx ]; |
---|
1657 | absSum += absCoeff[ idx ]; |
---|
1658 | |
---|
1659 | if ( idx == numNonZero-1 && signHidden && beValid ) |
---|
1660 | { |
---|
1661 | // Infer sign of 1st element. |
---|
1662 | if (absSum&0x1) |
---|
1663 | pcCoef[ blkPos ] = -pcCoef[ blkPos ]; |
---|
1664 | } |
---|
1665 | else |
---|
1666 | { |
---|
1667 | Int sign = static_cast<Int>( coeffSigns ) >> 31; |
---|
1668 | pcCoef[ blkPos ] = ( pcCoef[ blkPos ] ^ sign ) - sign; |
---|
1669 | coeffSigns <<= 1; |
---|
1670 | } |
---|
1671 | } |
---|
1672 | } |
---|
1673 | else |
---|
1674 | { |
---|
1675 | uiNumOne >>= 1; |
---|
1676 | } |
---|
1677 | } |
---|
1678 | |
---|
1679 | return; |
---|
1680 | } |
---|
1681 | |
---|
1682 | |
---|
1683 | Void TDecSbac::parseSaoUvlc (UInt& ruiVal) |
---|
1684 | { |
---|
1685 | UInt uiCode; |
---|
1686 | Int i; |
---|
1687 | |
---|
1688 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoUvlcSCModel.get( 0, 0, 0 ) ); |
---|
1689 | if ( uiCode == 0 ) |
---|
1690 | { |
---|
1691 | ruiVal = 0; |
---|
1692 | return; |
---|
1693 | } |
---|
1694 | |
---|
1695 | i=1; |
---|
1696 | while (1) |
---|
1697 | { |
---|
1698 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoUvlcSCModel.get( 0, 0, 1 ) ); |
---|
1699 | if ( uiCode == 0 ) break; |
---|
1700 | i++; |
---|
1701 | } |
---|
1702 | |
---|
1703 | ruiVal = i; |
---|
1704 | } |
---|
1705 | |
---|
1706 | Void TDecSbac::parseSaoSvlc (Int& riVal) |
---|
1707 | { |
---|
1708 | UInt uiCode; |
---|
1709 | Int iSign; |
---|
1710 | Int i; |
---|
1711 | |
---|
1712 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 0 ) ); |
---|
1713 | |
---|
1714 | if ( uiCode == 0 ) |
---|
1715 | { |
---|
1716 | riVal = 0; |
---|
1717 | return; |
---|
1718 | } |
---|
1719 | |
---|
1720 | // read sign |
---|
1721 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 1 ) ); |
---|
1722 | |
---|
1723 | if ( uiCode == 0 ) |
---|
1724 | { |
---|
1725 | iSign = 1; |
---|
1726 | } |
---|
1727 | else |
---|
1728 | { |
---|
1729 | iSign = -1; |
---|
1730 | } |
---|
1731 | |
---|
1732 | // read magnitude |
---|
1733 | i=1; |
---|
1734 | while (1) |
---|
1735 | { |
---|
1736 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 2 ) ); |
---|
1737 | if ( uiCode == 0 ) break; |
---|
1738 | i++; |
---|
1739 | } |
---|
1740 | |
---|
1741 | riVal = i*iSign; |
---|
1742 | } |
---|
1743 | |
---|
1744 | Void TDecSbac::parseSaoUflc (UInt& riVal) |
---|
1745 | { |
---|
1746 | UInt uiSymbol; |
---|
1747 | riVal = 0; |
---|
1748 | for (Int i=0;i<5;i++) |
---|
1749 | { |
---|
1750 | m_pcTDecBinIf->decodeBinEP ( uiSymbol ); |
---|
1751 | if (uiSymbol) |
---|
1752 | { |
---|
1753 | riVal |= (1<<i); |
---|
1754 | } |
---|
1755 | } |
---|
1756 | } |
---|
1757 | Void TDecSbac::parseSaoMergeLeft (UInt& ruiVal, UInt uiCompIdx) |
---|
1758 | { |
---|
1759 | UInt uiCode; |
---|
1760 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeLeftSCModel.get( 0, 0, uiCompIdx ) ); |
---|
1761 | ruiVal = (Int)uiCode; |
---|
1762 | } |
---|
1763 | |
---|
1764 | Void TDecSbac::parseSaoMergeUp (UInt& ruiVal) |
---|
1765 | { |
---|
1766 | UInt uiCode; |
---|
1767 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeUpSCModel.get( 0, 0, 0 ) ); |
---|
1768 | ruiVal = (Int)uiCode; |
---|
1769 | } |
---|
1770 | Void TDecSbac::parseSaoTypeIdx (UInt& ruiVal) |
---|
1771 | { |
---|
1772 | UInt uiCode; |
---|
1773 | Int i; |
---|
1774 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); |
---|
1775 | if ( uiCode == 0 ) |
---|
1776 | { |
---|
1777 | ruiVal = 0; |
---|
1778 | return; |
---|
1779 | } |
---|
1780 | i=1; |
---|
1781 | while (1) |
---|
1782 | { |
---|
1783 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 1 ) ); |
---|
1784 | if ( uiCode == 0 ) break; |
---|
1785 | i++; |
---|
1786 | } |
---|
1787 | ruiVal = i; |
---|
1788 | } |
---|
1789 | |
---|
1790 | inline Void copySaoOneLcuParam(SaoLcuParam* psDst, SaoLcuParam* psSrc) |
---|
1791 | { |
---|
1792 | Int i; |
---|
1793 | psDst->partIdx = psSrc->partIdx; |
---|
1794 | psDst->typeIdx = psSrc->typeIdx; |
---|
1795 | if (psDst->typeIdx != -1) |
---|
1796 | { |
---|
1797 | if (psDst->typeIdx == SAO_BO) |
---|
1798 | { |
---|
1799 | psDst->bandPosition = psSrc->bandPosition ; |
---|
1800 | } |
---|
1801 | else |
---|
1802 | { |
---|
1803 | psDst->bandPosition = 0; |
---|
1804 | } |
---|
1805 | psDst->length = psSrc->length; |
---|
1806 | for (i=0;i<psDst->length;i++) |
---|
1807 | { |
---|
1808 | psDst->offset[i] = psSrc->offset[i]; |
---|
1809 | } |
---|
1810 | } |
---|
1811 | else |
---|
1812 | { |
---|
1813 | psDst->length = 0; |
---|
1814 | for (i=0;i<SAO_BO_LEN;i++) |
---|
1815 | { |
---|
1816 | psDst->offset[i] = 0; |
---|
1817 | } |
---|
1818 | } |
---|
1819 | } |
---|
1820 | Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam) |
---|
1821 | { |
---|
1822 | UInt uiSymbol; |
---|
1823 | Int iSymbol; |
---|
1824 | static Int iTypeLength[MAX_NUM_SAO_TYPE] = { |
---|
1825 | SAO_EO_LEN, |
---|
1826 | SAO_EO_LEN, |
---|
1827 | SAO_EO_LEN, |
---|
1828 | SAO_EO_LEN, |
---|
1829 | SAO_BO_LEN |
---|
1830 | }; |
---|
1831 | |
---|
1832 | parseSaoTypeIdx(uiSymbol); |
---|
1833 | psSaoLcuParam->typeIdx = (Int)uiSymbol - 1; |
---|
1834 | if (uiSymbol) |
---|
1835 | { |
---|
1836 | psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx]; |
---|
1837 | if( psSaoLcuParam->typeIdx == SAO_BO ) |
---|
1838 | { |
---|
1839 | // Parse Left Band Index |
---|
1840 | parseSaoUflc( uiSymbol ); |
---|
1841 | psSaoLcuParam->bandPosition = uiSymbol; |
---|
1842 | for(Int i=0; i< psSaoLcuParam->length; i++) |
---|
1843 | { |
---|
1844 | parseSaoSvlc(iSymbol); |
---|
1845 | psSaoLcuParam->offset[i] = iSymbol; |
---|
1846 | } |
---|
1847 | } |
---|
1848 | else if( psSaoLcuParam->typeIdx < 4 ) |
---|
1849 | { |
---|
1850 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[0] = uiSymbol; |
---|
1851 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[1] = uiSymbol; |
---|
1852 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[2] = -(Int)uiSymbol; |
---|
1853 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[3] = -(Int)uiSymbol; |
---|
1854 | } |
---|
1855 | } |
---|
1856 | else |
---|
1857 | { |
---|
1858 | psSaoLcuParam->length = 0; |
---|
1859 | } |
---|
1860 | } |
---|
1861 | |
---|
1862 | Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Bool bLFCrossSliceBoundaryFlag) |
---|
1863 | { |
---|
1864 | Int iAddr = pcCU->getAddr(); |
---|
1865 | UInt uiSymbol; |
---|
1866 | for (Int iCompIdx=0; iCompIdx<3; iCompIdx++) |
---|
1867 | { |
---|
1868 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; |
---|
1869 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; |
---|
1870 | pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition = 0; |
---|
1871 | pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; |
---|
1872 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0] = 0; |
---|
1873 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[1] = 0; |
---|
1874 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[2] = 0; |
---|
1875 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3] = 0; |
---|
1876 | |
---|
1877 | if (pSaoParam->bSaoFlag[iCompIdx]) |
---|
1878 | { |
---|
1879 | if (rx>0 && iCUAddrInSlice!=0) |
---|
1880 | { |
---|
1881 | parseSaoMergeLeft(uiSymbol,iCompIdx); pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = (Int)uiSymbol; |
---|
1882 | } |
---|
1883 | else |
---|
1884 | { |
---|
1885 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; |
---|
1886 | } |
---|
1887 | |
---|
1888 | if (pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag==0) |
---|
1889 | { |
---|
1890 | if ((ry > 0) && (iCUAddrUpInSlice>0||bLFCrossSliceBoundaryFlag)) |
---|
1891 | { |
---|
1892 | parseSaoMergeUp(uiSymbol); pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = uiSymbol; |
---|
1893 | } |
---|
1894 | else |
---|
1895 | { |
---|
1896 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; |
---|
1897 | } |
---|
1898 | if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag) |
---|
1899 | { |
---|
1900 | parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr])); |
---|
1901 | } |
---|
1902 | else |
---|
1903 | { |
---|
1904 | copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-pSaoParam->numCuInWidth]); |
---|
1905 | } |
---|
1906 | } |
---|
1907 | else |
---|
1908 | { |
---|
1909 | copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-1]); |
---|
1910 | } |
---|
1911 | } |
---|
1912 | else |
---|
1913 | { |
---|
1914 | pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; |
---|
1915 | pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition = 0; |
---|
1916 | } |
---|
1917 | } |
---|
1918 | } |
---|
1919 | |
---|
1920 | /** |
---|
1921 | - Initialize our contexts from the nominated source. |
---|
1922 | . |
---|
1923 | \param pSrc Contexts to be copied. |
---|
1924 | */ |
---|
1925 | Void TDecSbac::xCopyContextsFrom( TDecSbac* pSrc ) |
---|
1926 | { |
---|
1927 | memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0])); |
---|
1928 | } |
---|
1929 | |
---|
1930 | Void TDecSbac::xCopyFrom( TDecSbac* pSrc ) |
---|
1931 | { |
---|
1932 | m_pcTDecBinIf->copyState( pSrc->m_pcTDecBinIf ); |
---|
1933 | |
---|
1934 | m_uiLastQp = pSrc->m_uiLastQp; |
---|
1935 | xCopyContextsFrom( pSrc ); |
---|
1936 | |
---|
1937 | } |
---|
1938 | |
---|
1939 | Void TDecSbac::load ( TDecSbac* pScr ) |
---|
1940 | { |
---|
1941 | xCopyFrom(pScr); |
---|
1942 | } |
---|
1943 | |
---|
1944 | Void TDecSbac::loadContexts ( TDecSbac* pScr ) |
---|
1945 | { |
---|
1946 | xCopyContextsFrom(pScr); |
---|
1947 | } |
---|
1948 | |
---|
1949 | Void TDecSbac::decodeFlush ( ) |
---|
1950 | { |
---|
1951 | UInt uiBit; |
---|
1952 | m_pcTDecBinIf->decodeBinTrm(uiBit); |
---|
1953 | m_pcTDecBinIf->flush(); |
---|
1954 | |
---|
1955 | } |
---|
1956 | |
---|
1957 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA_A0070 && LGE_EDGE_INTRA_DELTA_DC) |
---|
1958 | Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel ) |
---|
1959 | { |
---|
1960 | UInt uiSymbol; |
---|
1961 | UInt uiCount = 0; |
---|
1962 | do |
---|
1963 | { |
---|
1964 | m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel ); |
---|
1965 | uiCount++; |
---|
1966 | } |
---|
1967 | while( uiSymbol && ( uiCount != 13 ) ); |
---|
1968 | |
---|
1969 | ruiSymbol = uiCount - 1; |
---|
1970 | |
---|
1971 | if( uiSymbol ) |
---|
1972 | { |
---|
1973 | xReadEpExGolomb( uiSymbol, 0 ); |
---|
1974 | ruiSymbol += uiSymbol + 1; |
---|
1975 | } |
---|
1976 | |
---|
1977 | return; |
---|
1978 | } |
---|
1979 | #endif |
---|
1980 | #if HHI_DMM_WEDGE_INTRA |
---|
1981 | Void TDecSbac::xParseWedgeFullInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1982 | { |
---|
1983 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
1984 | Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx]; |
---|
1985 | |
---|
1986 | UInt uiSymbol, uiTabIdx = 0; |
---|
1987 | for ( Int i = 0; i < iBits; i++ ) |
---|
1988 | { |
---|
1989 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 0) ); |
---|
1990 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
1991 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
1992 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
1993 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
1994 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
1995 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
1996 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
1997 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
1998 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
1999 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
2000 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
2001 | uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0; |
---|
2002 | uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0; |
---|
2003 | } |
---|
2004 | |
---|
2005 | pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
2006 | } |
---|
2007 | |
---|
2008 | Void TDecSbac::xParseWedgeFullDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2009 | { |
---|
2010 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
2011 | Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx]; |
---|
2012 | |
---|
2013 | UInt uiSymbol, uiTabIdx = 0; |
---|
2014 | for ( Int i = 0; i < iBits; i++ ) |
---|
2015 | { |
---|
2016 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 0) ); |
---|
2017 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
2018 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
2019 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
2020 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
2021 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
2022 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
2023 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
2024 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
2025 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
2026 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
2027 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
2028 | uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0; |
---|
2029 | uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0; |
---|
2030 | } |
---|
2031 | |
---|
2032 | pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
2033 | |
---|
2034 | UInt uiDC1, uiDC2; |
---|
2035 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2036 | Int iDC1 = uiDC1; |
---|
2037 | if ( uiDC1 ) |
---|
2038 | { |
---|
2039 | UInt uiSign; |
---|
2040 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2041 | if ( uiSign ) |
---|
2042 | { |
---|
2043 | iDC1 = -iDC1; |
---|
2044 | } |
---|
2045 | } |
---|
2046 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2047 | Int iDC2 = uiDC2; |
---|
2048 | if ( uiDC2 ) |
---|
2049 | { |
---|
2050 | UInt uiSign; |
---|
2051 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2052 | if ( uiSign ) |
---|
2053 | { |
---|
2054 | iDC2 = -iDC2; |
---|
2055 | } |
---|
2056 | } |
---|
2057 | |
---|
2058 | pcCU->setWedgeFullDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
2059 | pcCU->setWedgeFullDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
2060 | } |
---|
2061 | |
---|
2062 | Void TDecSbac::xParseWedgePredDirInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2063 | { |
---|
2064 | if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 ) |
---|
2065 | { |
---|
2066 | UInt uiDeltaEnd = 0; |
---|
2067 | m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cDmmDataSCModel.get(0, 0, 2) ); |
---|
2068 | |
---|
2069 | Int iDeltaEnd; |
---|
2070 | if( uiDeltaEnd != 0 ) |
---|
2071 | { |
---|
2072 | UInt uiAbsValMinus1; |
---|
2073 | UInt uiSymbol; |
---|
2074 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 = uiSymbol; |
---|
2075 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 |= uiSymbol << 1; |
---|
2076 | uiDeltaEnd = uiAbsValMinus1 + 1; |
---|
2077 | |
---|
2078 | iDeltaEnd = uiDeltaEnd; |
---|
2079 | UInt uiSign; |
---|
2080 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2081 | if( uiSign ) |
---|
2082 | { |
---|
2083 | iDeltaEnd = -iDeltaEnd; |
---|
2084 | } |
---|
2085 | } |
---|
2086 | else |
---|
2087 | { |
---|
2088 | iDeltaEnd = 0; |
---|
2089 | } |
---|
2090 | pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth ); |
---|
2091 | } |
---|
2092 | } |
---|
2093 | |
---|
2094 | Void TDecSbac::xParseWedgePredDirDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2095 | { |
---|
2096 | if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 ) |
---|
2097 | { |
---|
2098 | UInt uiDeltaEnd = 0; |
---|
2099 | m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cDmmDataSCModel.get(0, 0, 2) ); |
---|
2100 | |
---|
2101 | Int iDeltaEnd; |
---|
2102 | if( uiDeltaEnd != 0 ) |
---|
2103 | { |
---|
2104 | UInt uiAbsValMinus1; |
---|
2105 | UInt uiSymbol; |
---|
2106 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 = uiSymbol; |
---|
2107 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 |= uiSymbol << 1; |
---|
2108 | uiDeltaEnd = uiAbsValMinus1 + 1; |
---|
2109 | |
---|
2110 | iDeltaEnd = uiDeltaEnd; |
---|
2111 | UInt uiSign; |
---|
2112 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2113 | if( uiSign ) |
---|
2114 | { |
---|
2115 | iDeltaEnd = -iDeltaEnd; |
---|
2116 | } |
---|
2117 | } |
---|
2118 | else |
---|
2119 | { |
---|
2120 | iDeltaEnd = 0; |
---|
2121 | } |
---|
2122 | |
---|
2123 | pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth ); |
---|
2124 | } |
---|
2125 | |
---|
2126 | UInt uiDC1, uiDC2; |
---|
2127 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2128 | Int iDC1 = uiDC1; |
---|
2129 | if ( uiDC1 ) |
---|
2130 | { |
---|
2131 | UInt uiSign; |
---|
2132 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2133 | if ( uiSign ) |
---|
2134 | { |
---|
2135 | iDC1 = -iDC1; |
---|
2136 | } |
---|
2137 | } |
---|
2138 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2139 | Int iDC2 = uiDC2; |
---|
2140 | if ( uiDC2 ) |
---|
2141 | { |
---|
2142 | UInt uiSign; |
---|
2143 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2144 | if ( uiSign ) |
---|
2145 | { |
---|
2146 | iDC2 = -iDC2; |
---|
2147 | } |
---|
2148 | } |
---|
2149 | |
---|
2150 | pcCU->setWedgePredDirDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
2151 | pcCU->setWedgePredDirDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
2152 | } |
---|
2153 | #endif |
---|
2154 | #if HHI_DMM_PRED_TEX |
---|
2155 | #if LGE_DMM3_SIMP_C0044 |
---|
2156 | Void TDecSbac::xParseWedgePredTexInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2157 | { |
---|
2158 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
2159 | Int iBits = g_aucWedgeTexPredBitsListIdx[iIntraIdx]; |
---|
2160 | |
---|
2161 | UInt uiSymbol, uiTabIdx = 0; |
---|
2162 | for ( Int i = 0; i < iBits; i++ ) |
---|
2163 | { |
---|
2164 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 3) ); |
---|
2165 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
2166 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
2167 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
2168 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
2169 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
2170 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
2171 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
2172 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
2173 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
2174 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
2175 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
2176 | } |
---|
2177 | |
---|
2178 | pcCU->setWedgePredTexIntraTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
2179 | } |
---|
2180 | #endif |
---|
2181 | |
---|
2182 | Void TDecSbac::xParseWedgePredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2183 | { |
---|
2184 | #if LGE_DMM3_SIMP_C0044 |
---|
2185 | xParseWedgePredTexInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
2186 | #endif |
---|
2187 | UInt uiDC1, uiDC2; |
---|
2188 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2189 | Int iDC1 = uiDC1; |
---|
2190 | if ( uiDC1 ) |
---|
2191 | { |
---|
2192 | UInt uiSign; |
---|
2193 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2194 | if ( uiSign ) |
---|
2195 | { |
---|
2196 | iDC1 = -iDC1; |
---|
2197 | } |
---|
2198 | } |
---|
2199 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2200 | Int iDC2 = uiDC2; |
---|
2201 | if ( uiDC2 ) |
---|
2202 | { |
---|
2203 | UInt uiSign; |
---|
2204 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2205 | if ( uiSign ) |
---|
2206 | { |
---|
2207 | iDC2 = -iDC2; |
---|
2208 | } |
---|
2209 | } |
---|
2210 | |
---|
2211 | pcCU->setWedgePredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
2212 | pcCU->setWedgePredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
2213 | } |
---|
2214 | |
---|
2215 | Void TDecSbac::xParseContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2216 | { |
---|
2217 | UInt uiDC1, uiDC2; |
---|
2218 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2219 | Int iDC1 = uiDC1; |
---|
2220 | if ( uiDC1 ) |
---|
2221 | { |
---|
2222 | UInt uiSign; |
---|
2223 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2224 | if ( uiSign ) |
---|
2225 | { |
---|
2226 | iDC1 = -iDC1; |
---|
2227 | } |
---|
2228 | } |
---|
2229 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
2230 | Int iDC2 = uiDC2; |
---|
2231 | if ( uiDC2 ) |
---|
2232 | { |
---|
2233 | UInt uiSign; |
---|
2234 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2235 | if ( uiSign ) |
---|
2236 | { |
---|
2237 | iDC2 = -iDC2; |
---|
2238 | } |
---|
2239 | } |
---|
2240 | |
---|
2241 | pcCU->setContourPredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
2242 | pcCU->setContourPredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
2243 | } |
---|
2244 | #endif |
---|
2245 | |
---|
2246 | #if LGE_EDGE_INTRA_A0070 |
---|
2247 | Void TDecSbac::xParseEdgeIntraInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2248 | { |
---|
2249 | UInt uiSymbol = 0; |
---|
2250 | |
---|
2251 | // 1. Top(0) or Left(1) |
---|
2252 | UChar ucLeft; |
---|
2253 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
2254 | ucLeft = uiSymbol; |
---|
2255 | |
---|
2256 | // 2. Start position (lowest bit first) |
---|
2257 | UChar ucStart = 0; |
---|
2258 | for( UInt ui = 0; ui < 6 - uiDepth; ui++ ) |
---|
2259 | { |
---|
2260 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
2261 | ucStart |= (uiSymbol << ui); |
---|
2262 | } |
---|
2263 | |
---|
2264 | // 3. Number of edges |
---|
2265 | UChar ucMax = 0; |
---|
2266 | for( UInt ui = 0; ui < 7 - uiDepth; ui++ ) |
---|
2267 | { |
---|
2268 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
2269 | ucMax |= (uiSymbol << ui); |
---|
2270 | } |
---|
2271 | ucMax++; // +1 |
---|
2272 | |
---|
2273 | // 4. Edges |
---|
2274 | UChar* pucSymbolList = (UChar*) xMalloc( UChar, 256 * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 ); |
---|
2275 | UInt uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiAbsPartIdx ); |
---|
2276 | for( Int iPtr = 0; iPtr < ucMax; iPtr++ ) |
---|
2277 | { |
---|
2278 | UChar ucEdge = 0; |
---|
2279 | UInt uiReorderEdge = 0; |
---|
2280 | // Left-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 | // Right-friendly direction |
---|
2289 | // 0 ( 0deg) => 0 |
---|
2290 | // 1 ( -45deg) => 10 |
---|
2291 | // 2 ( 45deg) => 110 |
---|
2292 | // 3 ( -90deg) => 1110 |
---|
2293 | // 4 ( 90deg) => 11110 |
---|
2294 | // 5 (-135deg) => 111110 |
---|
2295 | // 6 ( 135deg) => 111111 |
---|
2296 | // refer to a paper "An efficient chain code with Huffman coding" |
---|
2297 | for( UInt ui = 0; ui < 6; ui++ ) |
---|
2298 | { |
---|
2299 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) ); |
---|
2300 | ucEdge <<= 1; |
---|
2301 | ucEdge |= uiSymbol; |
---|
2302 | if( uiSymbol == 0 ) |
---|
2303 | break; |
---|
2304 | } |
---|
2305 | |
---|
2306 | switch( ucEdge ) |
---|
2307 | { |
---|
2308 | case 0 : // "0" |
---|
2309 | uiReorderEdge = 0; |
---|
2310 | break; |
---|
2311 | case 2 : // "10" |
---|
2312 | uiReorderEdge = 1; |
---|
2313 | break; |
---|
2314 | case 6 : // "110" |
---|
2315 | uiReorderEdge = 2; |
---|
2316 | break; |
---|
2317 | case 14 : // "1110" |
---|
2318 | uiReorderEdge = 3; |
---|
2319 | break; |
---|
2320 | case 30 : // "11110" |
---|
2321 | uiReorderEdge = 4; |
---|
2322 | break; |
---|
2323 | case 62 : // "111110" |
---|
2324 | uiReorderEdge = 5; |
---|
2325 | break; |
---|
2326 | case 63 : // "111111" |
---|
2327 | uiReorderEdge = 6; |
---|
2328 | break; |
---|
2329 | default : |
---|
2330 | printf("parseIntraEdgeChain: error (unknown code %d)\n",ucEdge); |
---|
2331 | assert(false); |
---|
2332 | break; |
---|
2333 | } |
---|
2334 | pucSymbolList[iPtr] = uiReorderEdge; |
---|
2335 | } |
---|
2336 | ///////////////////// |
---|
2337 | // Edge Reconstruction |
---|
2338 | Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); |
---|
2339 | pcCU->reconPartition( uiAbsPartIdx, uiDepth, ucLeft == 1, ucStart, ucMax, pucSymbolList, pbRegion ); |
---|
2340 | xFree( pucSymbolList ); |
---|
2341 | } |
---|
2342 | #endif |
---|
2343 | |
---|
2344 | #if RWTH_SDC_DLT_B0036 |
---|
2345 | Void TDecSbac::parseSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2346 | { |
---|
2347 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
2348 | |
---|
2349 | UInt uiSymbol = 0; |
---|
2350 | UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx ); |
---|
2351 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) ); |
---|
2352 | |
---|
2353 | if( uiSymbol == 1 ) |
---|
2354 | { |
---|
2355 | pcCU->setPartSizeSubParts(SIZE_2Nx2N, uiAbsPartIdx, uiDepth); |
---|
2356 | |
---|
2357 | pcCU->setSDCFlagSubParts( true, uiAbsPartIdx, 0, uiDepth); |
---|
2358 | pcCU->setTrIdxSubParts(0, uiAbsPartIdx, uiDepth); |
---|
2359 | pcCU->setCbfSubParts(1, 1, 1, uiAbsPartIdx, uiDepth); |
---|
2360 | } |
---|
2361 | } |
---|
2362 | |
---|
2363 | Void TDecSbac::parseSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2364 | { |
---|
2365 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
2366 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
2367 | |
---|
2368 | assert( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
2369 | |
---|
2370 | UInt uiCtx = 0; |
---|
2371 | |
---|
2372 | UInt uiMPModeIdx = 0; |
---|
2373 | |
---|
2374 | for(Int i=0; i<RWTH_SDC_NUM_PRED_MODES-1; i++) |
---|
2375 | { |
---|
2376 | UInt uiIsMostProb = 0; |
---|
2377 | m_pcTDecBinIf->decodeBin( uiIsMostProb, m_cSDCPredModeSCModel.get( 0, i, uiCtx ) ); |
---|
2378 | |
---|
2379 | if ( uiIsMostProb == 1 ) |
---|
2380 | break; |
---|
2381 | |
---|
2382 | // else: get next most probable pred mode |
---|
2383 | uiMPModeIdx = (uiMPModeIdx+1)%RWTH_SDC_NUM_PRED_MODES; |
---|
2384 | } |
---|
2385 | |
---|
2386 | Int intraPredMode = g_auiSDCPredModes[uiMPModeIdx]; |
---|
2387 | |
---|
2388 | #if HHI_DMM_WEDGE_INTRA |
---|
2389 | if( intraPredMode == DMM_WEDGE_FULL_IDX ) { xParseWedgeFullInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
2390 | if( intraPredMode == DMM_WEDGE_PREDDIR_IDX ) { xParseWedgePredDirInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
2391 | #endif |
---|
2392 | |
---|
2393 | pcCU->setLumaIntraDirSubParts((UChar)intraPredMode, uiAbsPartIdx, uiDepth); |
---|
2394 | } |
---|
2395 | |
---|
2396 | Void TDecSbac::parseSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSegment ) |
---|
2397 | { |
---|
2398 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
2399 | assert( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
2400 | assert( uiSegment < 2 ); |
---|
2401 | |
---|
2402 | UInt uiResidual = 0; |
---|
2403 | UInt uiBit = 0; |
---|
2404 | UInt uiAbsIdx = 0; |
---|
2405 | UInt uiSign = 0; |
---|
2406 | Int iIdx = 0; |
---|
2407 | |
---|
2408 | UInt uiMaxResidualBits = GetBitsPerDepthValue(); |
---|
2409 | assert( uiMaxResidualBits <= g_uiBitDepth ); |
---|
2410 | |
---|
2411 | m_pcTDecBinIf->decodeBin(uiResidual, m_cSDCResidualFlagSCModel.get( 0, uiSegment, 0 ) ); |
---|
2412 | |
---|
2413 | if (uiResidual) |
---|
2414 | { |
---|
2415 | // decode residual sign bit |
---|
2416 | m_pcTDecBinIf->decodeBin(uiSign, m_cSDCResidualSignFlagSCModel.get( 0, uiSegment, 0 ) ); |
---|
2417 | |
---|
2418 | // decode residual magnitude |
---|
2419 | for (Int i=0; i<uiMaxResidualBits; i++) |
---|
2420 | { |
---|
2421 | m_pcTDecBinIf->decodeBin(uiBit, m_cSDCResidualSCModel.get( 0, uiSegment, i ) ); |
---|
2422 | uiAbsIdx |= uiBit << i; |
---|
2423 | } |
---|
2424 | |
---|
2425 | uiAbsIdx += 1; |
---|
2426 | iIdx =(Int)(uiSign ? -1 : 1)*uiAbsIdx; |
---|
2427 | } |
---|
2428 | |
---|
2429 | pcCU->setSDCSegmentDCOffset(iIdx, uiSegment, uiAbsPartIdx); |
---|
2430 | } |
---|
2431 | #endif |
---|
2432 | |
---|
2433 | //! \} |
---|