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