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