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-2013, 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 H_3D_ARP |
---|
57 | , m_cCUPUARPWSCModel ( 1, 1, NUM_ARPW_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
58 | #endif |
---|
59 | #if H_3D_IC |
---|
60 | , m_cCUICFlagSCModel ( 1, 1, NUM_IC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
61 | #endif |
---|
62 | , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
63 | , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
64 | , m_cCUIntraPredSCModel ( 1, 1, NUM_ADI_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
65 | , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
66 | , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
67 | , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
68 | , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
69 | , m_cCUMvdSCModel ( 1, 1, NUM_MV_RES_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
70 | , m_cCUQtCbfSCModel ( 1, 2, NUM_QT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
71 | , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
72 | , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
73 | , m_cCUSigCoeffGroupSCModel ( 1, 2, NUM_SIG_CG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
74 | , m_cCUSigSCModel ( 1, 1, NUM_SIG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
75 | , m_cCuCtxLastX ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
76 | , m_cCuCtxLastY ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
77 | , m_cCUOneSCModel ( 1, 1, NUM_ONE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
78 | , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
79 | , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
80 | , m_cCUAMPSCModel ( 1, 1, NUM_CU_AMP_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
81 | , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
82 | , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
83 | , m_cTransformSkipSCModel ( 1, 2, NUM_TRANSFORMSKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
84 | , m_CUTransquantBypassFlagSCModel( 1, 1, NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels) |
---|
85 | #if H_3D_DIM |
---|
86 | , m_cDepthIntraModeSCModel ( 1, 1, NUM_DEPTH_INTRA_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
87 | , m_cDdcFlagSCModel ( 1, 1, NUM_DDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
88 | , m_cDdcDataSCModel ( 1, 1, NUM_DDC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
89 | #if QC_GENERIC_SDC_G0122 |
---|
90 | , m_cAngleFlagSCModel ( 1, 1, NUM_ANGLE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
91 | , m_cIntraSdcFlagSCModel ( 1, 1, NUM_INTRASDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
92 | #endif |
---|
93 | #if H_3D_DIM_DMM |
---|
94 | , m_cDmm1DataSCModel ( 1, 1, NUM_DMM1_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
95 | #endif |
---|
96 | #if H_3D_DIM_SDC |
---|
97 | , m_cSDCResidualFlagSCModel ( 1, 1, SDC_NUM_RESIDUAL_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
98 | , m_cSDCResidualSCModel ( 1, 1, SDC_NUM_RESIDUAL_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
99 | #endif |
---|
100 | #endif |
---|
101 | #if H_3D_INTER_SDC |
---|
102 | , m_cInterSDCFlagSCModel ( 1, 1, NUM_INTER_SDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
103 | , m_cInterSDCResidualSCModel ( 1, 1, NUM_INTER_SDC_RESIDUAL_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
104 | , m_cInterSDCResidualSignFlagSCModel ( 1, 1, NUM_INTER_SDC_SIGN_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
105 | #endif |
---|
106 | { |
---|
107 | assert( m_numContextModels <= MAX_NUM_CTX_MOD ); |
---|
108 | } |
---|
109 | |
---|
110 | TDecSbac::~TDecSbac() |
---|
111 | { |
---|
112 | } |
---|
113 | |
---|
114 | // ==================================================================================================================== |
---|
115 | // Public member functions |
---|
116 | // ==================================================================================================================== |
---|
117 | |
---|
118 | Void TDecSbac::resetEntropy(TComSlice* pSlice) |
---|
119 | { |
---|
120 | SliceType sliceType = pSlice->getSliceType(); |
---|
121 | Int qp = pSlice->getSliceQp(); |
---|
122 | |
---|
123 | if (pSlice->getPPS()->getCabacInitPresentFlag() && pSlice->getCabacInitFlag()) |
---|
124 | { |
---|
125 | switch (sliceType) |
---|
126 | { |
---|
127 | case P_SLICE: // change initialization table to B_SLICE initialization |
---|
128 | sliceType = B_SLICE; |
---|
129 | break; |
---|
130 | case B_SLICE: // change initialization table to P_SLICE initialization |
---|
131 | sliceType = P_SLICE; |
---|
132 | break; |
---|
133 | default : // should not occur |
---|
134 | assert(0); |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | m_cCUSplitFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG ); |
---|
139 | m_cCUSkipFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SKIP_FLAG ); |
---|
140 | m_cCUMergeFlagExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
141 | m_cCUMergeIdxExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
142 | #if H_3D_ARP |
---|
143 | m_cCUPUARPWSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ARPW ); |
---|
144 | #endif |
---|
145 | #if H_3D_IC |
---|
146 | m_cCUICFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_IC_FLAG ); |
---|
147 | #endif |
---|
148 | m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); |
---|
149 | m_cCUAMPSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CU_AMP_POS ); |
---|
150 | m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); |
---|
151 | m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
152 | m_cCUChromaPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
153 | m_cCUInterDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_DIR ); |
---|
154 | m_cCUMvdSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVD ); |
---|
155 | m_cCURefPicSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_REF_PIC ); |
---|
156 | m_cCUDeltaQpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DQP ); |
---|
157 | m_cCUQtCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_CBF ); |
---|
158 | m_cCUQtRootCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
159 | m_cCUSigCoeffGroupSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
160 | m_cCUSigSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_FLAG ); |
---|
161 | m_cCuCtxLastX.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
162 | m_cCuCtxLastY.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
163 | m_cCUOneSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ONE_FLAG ); |
---|
164 | m_cCUAbsSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ABS_FLAG ); |
---|
165 | m_cMVPIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVP_IDX ); |
---|
166 | m_cSaoMergeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG ); |
---|
167 | m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
168 | |
---|
169 | m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
170 | m_cTransformSkipSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); |
---|
171 | m_CUTransquantBypassFlagSCModel.initBuffer( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); |
---|
172 | #if H_3D_DIM |
---|
173 | m_cDepthIntraModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE ); |
---|
174 | m_cDdcFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DDC_FLAG ); |
---|
175 | m_cDdcDataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DDC_DATA ); |
---|
176 | #if QC_GENERIC_SDC_G0122 |
---|
177 | m_cAngleFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ANGLE_FLAG ); |
---|
178 | m_cIntraSdcFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRASDC_FLAG ); |
---|
179 | #endif |
---|
180 | #if H_3D_DIM_DMM |
---|
181 | m_cDmm1DataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM1_DATA ); |
---|
182 | #endif |
---|
183 | #if H_3D_DIM_SDC |
---|
184 | m_cSDCResidualFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); |
---|
185 | m_cSDCResidualSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL ); |
---|
186 | #endif |
---|
187 | #endif |
---|
188 | #if H_3D_INTER_SDC |
---|
189 | m_cInterSDCFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_SDC_FLAG ); |
---|
190 | m_cInterSDCResidualSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_SDC_RESIDUAL ); |
---|
191 | m_cInterSDCResidualSignFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_SDC_SIGN_FLAG ); |
---|
192 | #endif |
---|
193 | m_uiLastDQpNonZero = 0; |
---|
194 | |
---|
195 | // new structure |
---|
196 | m_uiLastQp = qp; |
---|
197 | |
---|
198 | m_pcTDecBinIf->start(); |
---|
199 | } |
---|
200 | |
---|
201 | /** The function does the following: Read out terminate bit. Flush CABAC. Byte-align for next tile. |
---|
202 | * Intialize CABAC states. Start CABAC. |
---|
203 | */ |
---|
204 | Void TDecSbac::updateContextTables( SliceType eSliceType, Int iQp ) |
---|
205 | { |
---|
206 | UInt uiBit; |
---|
207 | m_pcTDecBinIf->decodeBinTrm(uiBit); |
---|
208 | assert(uiBit); // end_of_sub_stream_one_bit must be equal to 1 |
---|
209 | m_pcTDecBinIf->finish(); |
---|
210 | m_pcBitstream->readOutTrailingBits(); |
---|
211 | m_cCUSplitFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG ); |
---|
212 | m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG ); |
---|
213 | m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
214 | m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
215 | #if H_3D_ARP |
---|
216 | m_cCUPUARPWSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ARPW ); |
---|
217 | #endif |
---|
218 | #if H_3D_IC |
---|
219 | m_cCUICFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_IC_FLAG ); |
---|
220 | #endif |
---|
221 | m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); |
---|
222 | m_cCUAMPSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS ); |
---|
223 | m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); |
---|
224 | m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
225 | m_cCUChromaPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
226 | m_cCUInterDirSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_DIR ); |
---|
227 | m_cCUMvdSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVD ); |
---|
228 | m_cCURefPicSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_REF_PIC ); |
---|
229 | m_cCUDeltaQpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DQP ); |
---|
230 | m_cCUQtCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_CBF ); |
---|
231 | m_cCUQtRootCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
232 | m_cCUSigCoeffGroupSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
233 | m_cCUSigSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_FLAG ); |
---|
234 | m_cCuCtxLastX.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
235 | m_cCuCtxLastY.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
236 | m_cCUOneSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ONE_FLAG ); |
---|
237 | m_cCUAbsSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG ); |
---|
238 | m_cMVPIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVP_IDX ); |
---|
239 | m_cSaoMergeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG ); |
---|
240 | m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
241 | m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
242 | m_cTransformSkipSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); |
---|
243 | m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); |
---|
244 | |
---|
245 | #if H_3D_DIM |
---|
246 | m_cDepthIntraModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE ); |
---|
247 | m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG ); |
---|
248 | m_cDdcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_DATA ); |
---|
249 | #if QC_GENERIC_SDC_G0122 |
---|
250 | m_cAngleFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG ); |
---|
251 | m_cIntraSdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRASDC_FLAG ); |
---|
252 | #endif |
---|
253 | #if H_3D_DIM_DMM |
---|
254 | m_cDmm1DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA ); |
---|
255 | #endif |
---|
256 | #if H_3D_DIM_SDC |
---|
257 | m_cSDCResidualFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); |
---|
258 | m_cSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL ); |
---|
259 | #endif |
---|
260 | #endif |
---|
261 | #if H_3D_INTER_SDC |
---|
262 | m_cInterSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_FLAG ); |
---|
263 | m_cInterSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_RESIDUAL ); |
---|
264 | m_cInterSDCResidualSignFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_SIGN_FLAG ); |
---|
265 | #endif |
---|
266 | m_pcTDecBinIf->start(); |
---|
267 | } |
---|
268 | |
---|
269 | Void TDecSbac::parseTerminatingBit( UInt& ruiBit ) |
---|
270 | { |
---|
271 | m_pcTDecBinIf->decodeBinTrm( ruiBit ); |
---|
272 | if ( ruiBit ) |
---|
273 | { |
---|
274 | m_pcTDecBinIf->finish(); |
---|
275 | } |
---|
276 | } |
---|
277 | |
---|
278 | |
---|
279 | Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ) |
---|
280 | { |
---|
281 | if (uiMaxSymbol == 0) |
---|
282 | { |
---|
283 | ruiSymbol = 0; |
---|
284 | return; |
---|
285 | } |
---|
286 | |
---|
287 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
288 | |
---|
289 | if( ruiSymbol == 0 || uiMaxSymbol == 1 ) |
---|
290 | { |
---|
291 | return; |
---|
292 | } |
---|
293 | |
---|
294 | UInt uiSymbol = 0; |
---|
295 | UInt uiCont; |
---|
296 | |
---|
297 | do |
---|
298 | { |
---|
299 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
300 | uiSymbol++; |
---|
301 | } |
---|
302 | while( uiCont && ( uiSymbol < uiMaxSymbol - 1 ) ); |
---|
303 | |
---|
304 | if( uiCont && ( uiSymbol == uiMaxSymbol - 1 ) ) |
---|
305 | { |
---|
306 | uiSymbol++; |
---|
307 | } |
---|
308 | |
---|
309 | ruiSymbol = uiSymbol; |
---|
310 | } |
---|
311 | |
---|
312 | Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount ) |
---|
313 | { |
---|
314 | UInt uiSymbol = 0; |
---|
315 | UInt uiBit = 1; |
---|
316 | |
---|
317 | while( uiBit ) |
---|
318 | { |
---|
319 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
320 | uiSymbol += uiBit << uiCount++; |
---|
321 | } |
---|
322 | |
---|
323 | if ( --uiCount ) |
---|
324 | { |
---|
325 | UInt bins; |
---|
326 | m_pcTDecBinIf->decodeBinsEP( bins, uiCount ); |
---|
327 | uiSymbol += bins; |
---|
328 | } |
---|
329 | |
---|
330 | ruiSymbol = uiSymbol; |
---|
331 | } |
---|
332 | |
---|
333 | Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ) |
---|
334 | { |
---|
335 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
336 | |
---|
337 | if( !ruiSymbol ) |
---|
338 | { |
---|
339 | return; |
---|
340 | } |
---|
341 | |
---|
342 | UInt uiSymbol = 0; |
---|
343 | UInt uiCont; |
---|
344 | |
---|
345 | do |
---|
346 | { |
---|
347 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
348 | uiSymbol++; |
---|
349 | } |
---|
350 | while( uiCont ); |
---|
351 | |
---|
352 | ruiSymbol = uiSymbol; |
---|
353 | } |
---|
354 | |
---|
355 | |
---|
356 | /** Parsing of coeff_abs_level_remaing |
---|
357 | * \param ruiSymbol reference to coeff_abs_level_remaing |
---|
358 | * \param ruiParam reference to parameter |
---|
359 | * \returns Void |
---|
360 | */ |
---|
361 | Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam ) |
---|
362 | { |
---|
363 | |
---|
364 | UInt prefix = 0; |
---|
365 | UInt codeWord = 0; |
---|
366 | do |
---|
367 | { |
---|
368 | prefix++; |
---|
369 | m_pcTDecBinIf->decodeBinEP( codeWord ); |
---|
370 | } |
---|
371 | while( codeWord); |
---|
372 | codeWord = 1 - codeWord; |
---|
373 | prefix -= codeWord; |
---|
374 | codeWord=0; |
---|
375 | if (prefix < COEF_REMAIN_BIN_REDUCTION ) |
---|
376 | { |
---|
377 | m_pcTDecBinIf->decodeBinsEP(codeWord,rParam); |
---|
378 | rSymbol = (prefix<<rParam) + codeWord; |
---|
379 | } |
---|
380 | else |
---|
381 | { |
---|
382 | m_pcTDecBinIf->decodeBinsEP(codeWord,prefix-COEF_REMAIN_BIN_REDUCTION+rParam); |
---|
383 | rSymbol = (((1<<(prefix-COEF_REMAIN_BIN_REDUCTION))+COEF_REMAIN_BIN_REDUCTION-1)<<rParam)+codeWord; |
---|
384 | } |
---|
385 | } |
---|
386 | |
---|
387 | #if H_3D_DIM |
---|
388 | Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel ) |
---|
389 | { |
---|
390 | UInt uiSymbol; |
---|
391 | UInt uiCount = 0; |
---|
392 | do |
---|
393 | { |
---|
394 | m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel ); |
---|
395 | uiCount++; |
---|
396 | } |
---|
397 | while( uiSymbol && ( uiCount != 13 ) ); |
---|
398 | |
---|
399 | ruiSymbol = uiCount - 1; |
---|
400 | |
---|
401 | if( uiSymbol ) |
---|
402 | { |
---|
403 | xReadEpExGolomb( uiSymbol, 0 ); |
---|
404 | ruiSymbol += uiSymbol + 1; |
---|
405 | } |
---|
406 | |
---|
407 | return; |
---|
408 | } |
---|
409 | |
---|
410 | Void TDecSbac::xParseDimDeltaDC( Pel& rValDeltaDC, UInt uiNumSeg ) |
---|
411 | { |
---|
412 | UInt absValDeltaDC = 0; |
---|
413 | xReadExGolombLevel( absValDeltaDC, m_cDdcDataSCModel.get(0, 0, 0) ); |
---|
414 | rValDeltaDC = (Pel)absValDeltaDC + ( uiNumSeg > 1 ? 0 : 1 ); |
---|
415 | |
---|
416 | if( rValDeltaDC != 0 ) |
---|
417 | { |
---|
418 | UInt uiSign; |
---|
419 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
420 | if ( uiSign ) |
---|
421 | { |
---|
422 | rValDeltaDC = -rValDeltaDC; |
---|
423 | } |
---|
424 | } |
---|
425 | } |
---|
426 | |
---|
427 | |
---|
428 | #if H_3D_DIM_DMM |
---|
429 | Void TDecSbac::xParseDmm1WedgeIdx( UInt& ruiTabIdx, Int iNumBit ) |
---|
430 | { |
---|
431 | UInt uiSymbol, uiIdx = 0; |
---|
432 | for( Int i = 0; i < iNumBit; i++ ) |
---|
433 | { |
---|
434 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm1DataSCModel.get(0, 0, 0) ); |
---|
435 | uiIdx += uiSymbol << i; |
---|
436 | } |
---|
437 | ruiTabIdx = uiIdx; |
---|
438 | } |
---|
439 | #endif |
---|
440 | |
---|
441 | #if H_3D_DIM_SDC |
---|
442 | Void TDecSbac::xParseSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSegment ) |
---|
443 | { |
---|
444 | assert( pcCU->getSlice()->getIsDepth() ); |
---|
445 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
446 | assert( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
447 | assert( uiSegment < 2 ); |
---|
448 | |
---|
449 | UInt uiResidual = 0; |
---|
450 | UInt uiBit = 0; |
---|
451 | UInt uiAbsIdx = 0; |
---|
452 | UInt uiSign = 0; |
---|
453 | Int iIdx = 0; |
---|
454 | |
---|
455 | #if H_3D_DIM_DLT |
---|
456 | UInt uiMaxResidualBits = pcCU->getSlice()->getPPS()->getDLT()->getBitsPerDepthValue( pcCU->getSlice()->getLayerIdInVps() ); |
---|
457 | #else |
---|
458 | UInt uiMaxResidualBits = g_bitDepthY; |
---|
459 | #endif |
---|
460 | assert( uiMaxResidualBits <= g_bitDepthY ); |
---|
461 | |
---|
462 | m_pcTDecBinIf->decodeBin(uiResidual, m_cSDCResidualFlagSCModel.get( 0, 0, 0 ) ); |
---|
463 | |
---|
464 | #if H_MV_ENC_DEC_TRAC |
---|
465 | DTRACE_CU("sdc_residual_flag[i]", uiResidual) |
---|
466 | #endif |
---|
467 | |
---|
468 | if (uiResidual) |
---|
469 | { |
---|
470 | // decode residual sign bit |
---|
471 | m_pcTDecBinIf->decodeBinEP(uiSign); |
---|
472 | #if H_MV_ENC_DEC_TRAC |
---|
473 | DTRACE_CU("sdc_residual_sign_flag[i]", uiSign) |
---|
474 | #endif |
---|
475 | |
---|
476 | // decode residual magnitude |
---|
477 | // prefix part |
---|
478 | UInt uiCount = 0; |
---|
479 | #if H_3D_DIM_DLT |
---|
480 | UInt uiNumDepthValues = pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ); |
---|
481 | #else |
---|
482 | UInt uiNumDepthValues = ((1 << g_bitDepthY)-1); |
---|
483 | #endif |
---|
484 | UInt uiPrefixThreshold = ((uiNumDepthValues * 3) >> 2); |
---|
485 | for ( UInt ui = 0; ui < uiPrefixThreshold; ui++) |
---|
486 | { |
---|
487 | m_pcTDecBinIf->decodeBin( uiBit, m_cSDCResidualSCModel.get(0, 0, 0) ); |
---|
488 | if ( uiBit == 0 ) |
---|
489 | break; |
---|
490 | else |
---|
491 | uiCount++; |
---|
492 | } |
---|
493 | // suffix part |
---|
494 | if ( uiCount == uiPrefixThreshold ) |
---|
495 | { |
---|
496 | for ( UInt ui = 0; ui < numBitsForValue(uiNumDepthValues - uiPrefixThreshold); ui++ ) |
---|
497 | { |
---|
498 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
499 | uiAbsIdx |= uiBit << ui; |
---|
500 | } |
---|
501 | uiAbsIdx += uiCount; |
---|
502 | } |
---|
503 | else |
---|
504 | { |
---|
505 | uiAbsIdx = uiCount; |
---|
506 | } |
---|
507 | |
---|
508 | #if H_MV_ENC_DEC_TRAC |
---|
509 | DTRACE_CU("sdc_residual_abs_minus1[i]", uiAbsIdx) |
---|
510 | #endif |
---|
511 | |
---|
512 | uiAbsIdx += 1; |
---|
513 | iIdx =(Int)(uiSign ? -1 : 1)*uiAbsIdx; |
---|
514 | } |
---|
515 | |
---|
516 | pcCU->setSDCSegmentDCOffset(iIdx, uiSegment, uiAbsPartIdx); |
---|
517 | } |
---|
518 | #endif |
---|
519 | #endif |
---|
520 | |
---|
521 | /** Parse I_PCM information. |
---|
522 | * \param pcCU |
---|
523 | * \param uiAbsPartIdx |
---|
524 | * \param uiDepth |
---|
525 | * \returns Void |
---|
526 | * |
---|
527 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
528 | */ |
---|
529 | Void TDecSbac::parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
530 | { |
---|
531 | UInt uiSymbol; |
---|
532 | |
---|
533 | m_pcTDecBinIf->decodeBinTrm(uiSymbol); |
---|
534 | |
---|
535 | #if H_MV_ENC_DEC_TRAC |
---|
536 | DTRACE_CU("pcm_flag", uiSymbol) |
---|
537 | #endif |
---|
538 | if (uiSymbol) |
---|
539 | { |
---|
540 | Bool bIpcmFlag = true; |
---|
541 | |
---|
542 | pcCU->setPartSizeSubParts ( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
543 | pcCU->setSizeSubParts ( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
544 | pcCU->setTrIdxSubParts ( 0, uiAbsPartIdx, uiDepth ); |
---|
545 | pcCU->setIPCMFlagSubParts ( bIpcmFlag, uiAbsPartIdx, uiDepth ); |
---|
546 | |
---|
547 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
548 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
549 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
550 | |
---|
551 | Pel* piPCMSample; |
---|
552 | UInt uiWidth; |
---|
553 | UInt uiHeight; |
---|
554 | UInt uiSampleBits; |
---|
555 | UInt uiX, uiY; |
---|
556 | |
---|
557 | piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; |
---|
558 | uiWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
559 | uiHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
560 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
561 | |
---|
562 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
563 | { |
---|
564 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
565 | { |
---|
566 | UInt uiSample; |
---|
567 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
568 | piPCMSample[uiX] = uiSample; |
---|
569 | } |
---|
570 | piPCMSample += uiWidth; |
---|
571 | } |
---|
572 | |
---|
573 | piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; |
---|
574 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
575 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
576 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
577 | |
---|
578 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
579 | { |
---|
580 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
581 | { |
---|
582 | UInt uiSample; |
---|
583 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
584 | piPCMSample[uiX] = uiSample; |
---|
585 | } |
---|
586 | piPCMSample += uiWidth; |
---|
587 | } |
---|
588 | |
---|
589 | piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; |
---|
590 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
591 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
592 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
593 | |
---|
594 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
595 | { |
---|
596 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
597 | { |
---|
598 | UInt uiSample; |
---|
599 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
600 | piPCMSample[uiX] = uiSample; |
---|
601 | } |
---|
602 | piPCMSample += uiWidth; |
---|
603 | } |
---|
604 | |
---|
605 | m_pcTDecBinIf->start(); |
---|
606 | } |
---|
607 | } |
---|
608 | |
---|
609 | Void TDecSbac::parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
610 | { |
---|
611 | UInt uiSymbol; |
---|
612 | m_pcTDecBinIf->decodeBin( uiSymbol, m_CUTransquantBypassFlagSCModel.get( 0, 0, 0 ) ); |
---|
613 | #if H_MV_ENC_DEC_TRAC |
---|
614 | DTRACE_CU("cu_transquant_bypass_flag", uiSymbol); |
---|
615 | #endif |
---|
616 | pcCU->setCUTransquantBypassSubParts(uiSymbol ? true : false, uiAbsPartIdx, uiDepth); |
---|
617 | } |
---|
618 | |
---|
619 | /** parse skip flag |
---|
620 | * \param pcCU |
---|
621 | * \param uiAbsPartIdx |
---|
622 | * \param uiDepth |
---|
623 | * \returns Void |
---|
624 | */ |
---|
625 | Void TDecSbac::parseSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
626 | { |
---|
627 | if( pcCU->getSlice()->isIntra() ) |
---|
628 | { |
---|
629 | return; |
---|
630 | } |
---|
631 | |
---|
632 | UInt uiSymbol = 0; |
---|
633 | UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx ); |
---|
634 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) ); |
---|
635 | #if !H_MV_ENC_DEC_TRAC |
---|
636 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
637 | DTRACE_CABAC_T( "\tSkipFlag" ); |
---|
638 | DTRACE_CABAC_T( "\tuiCtxSkip: "); |
---|
639 | DTRACE_CABAC_V( uiCtxSkip ); |
---|
640 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
641 | DTRACE_CABAC_V( uiSymbol ); |
---|
642 | DTRACE_CABAC_T( "\n"); |
---|
643 | #endif |
---|
644 | |
---|
645 | if( uiSymbol ) |
---|
646 | { |
---|
647 | pcCU->setSkipFlagSubParts( true, uiAbsPartIdx, uiDepth ); |
---|
648 | pcCU->setPredModeSubParts( MODE_INTER, uiAbsPartIdx, uiDepth ); |
---|
649 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
650 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
651 | pcCU->setMergeFlagSubParts( true , uiAbsPartIdx, 0, uiDepth ); |
---|
652 | } |
---|
653 | #if H_MV_ENC_DEC_TRAC |
---|
654 | DTRACE_CU("cu_skip_flag", uiSymbol); |
---|
655 | #endif |
---|
656 | } |
---|
657 | |
---|
658 | /** parse merge flag |
---|
659 | * \param pcCU |
---|
660 | * \param uiAbsPartIdx |
---|
661 | * \param uiDepth |
---|
662 | * \param uiPUIdx |
---|
663 | * \returns Void |
---|
664 | */ |
---|
665 | Void TDecSbac::parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
666 | { |
---|
667 | UInt uiSymbol; |
---|
668 | m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) ); |
---|
669 | #if H_MV_ENC_DEC_TRAC |
---|
670 | DTRACE_PU("merge_flag", uiSymbol) |
---|
671 | #endif |
---|
672 | pcCU->setMergeFlagSubParts( uiSymbol ? true : false, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
673 | |
---|
674 | #if !H_MV_ENC_DEC_TRAC |
---|
675 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
676 | DTRACE_CABAC_T( "\tMergeFlag: " ); |
---|
677 | DTRACE_CABAC_V( uiSymbol ); |
---|
678 | DTRACE_CABAC_T( "\tAddress: " ); |
---|
679 | DTRACE_CABAC_V( pcCU->getAddr() ); |
---|
680 | DTRACE_CABAC_T( "\tuiAbsPartIdx: " ); |
---|
681 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
682 | DTRACE_CABAC_T( "\n" ); |
---|
683 | #endif |
---|
684 | } |
---|
685 | |
---|
686 | Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex ) |
---|
687 | { |
---|
688 | UInt uiUnaryIdx = 0; |
---|
689 | UInt uiNumCand = pcCU->getSlice()->getMaxNumMergeCand(); |
---|
690 | if ( uiNumCand > 1 ) |
---|
691 | { |
---|
692 | for( ; uiUnaryIdx < uiNumCand - 1; ++uiUnaryIdx ) |
---|
693 | { |
---|
694 | UInt uiSymbol = 0; |
---|
695 | if ( uiUnaryIdx==0 ) |
---|
696 | { |
---|
697 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) ); |
---|
698 | } |
---|
699 | else |
---|
700 | { |
---|
701 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
702 | } |
---|
703 | if( uiSymbol == 0 ) |
---|
704 | { |
---|
705 | break; |
---|
706 | } |
---|
707 | } |
---|
708 | #if H_MV_ENC_DEC_TRAC |
---|
709 | DTRACE_PU("merge_idx", uiUnaryIdx) |
---|
710 | #endif |
---|
711 | } |
---|
712 | ruiMergeIndex = uiUnaryIdx; |
---|
713 | |
---|
714 | #if !H_MV_ENC_DEC_TRAC |
---|
715 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
716 | DTRACE_CABAC_T( "\tparseMergeIndex()" ) |
---|
717 | DTRACE_CABAC_T( "\tuiMRGIdx= " ) |
---|
718 | DTRACE_CABAC_V( ruiMergeIndex ) |
---|
719 | DTRACE_CABAC_T( "\n" ) |
---|
720 | #endif |
---|
721 | } |
---|
722 | |
---|
723 | Void TDecSbac::parseMVPIdx ( Int& riMVPIdx ) |
---|
724 | { |
---|
725 | UInt uiSymbol; |
---|
726 | xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, AMVP_MAX_NUM_CANDS-1); |
---|
727 | riMVPIdx = uiSymbol; |
---|
728 | } |
---|
729 | |
---|
730 | Void TDecSbac::parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
731 | { |
---|
732 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
733 | { |
---|
734 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
735 | return; |
---|
736 | } |
---|
737 | |
---|
738 | UInt uiSymbol; |
---|
739 | #if H_3D_QTLPC |
---|
740 | Bool bParseSplitFlag = true; |
---|
741 | |
---|
742 | TComSPS *sps = pcCU->getPic()->getSlice(0)->getSPS(); |
---|
743 | TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); |
---|
744 | Bool bDepthMapDetect = (pcTexture != NULL); |
---|
745 | Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); |
---|
746 | |
---|
747 | Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); |
---|
748 | |
---|
749 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL() && sps->getUsePC()) |
---|
750 | { |
---|
751 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
752 | assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); |
---|
753 | bParseSplitFlag = (pcTextureCU->getDepth(uiAbsPartIdx) > uiDepth); |
---|
754 | } |
---|
755 | |
---|
756 | if(bParseSplitFlag) |
---|
757 | { |
---|
758 | #endif |
---|
759 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) ); |
---|
760 | #if H_MV_ENC_DEC_TRAC |
---|
761 | DTRACE_CU("split_cu_flag", uiSymbol); |
---|
762 | #else |
---|
763 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
764 | DTRACE_CABAC_T( "\tSplitFlag\n" ) |
---|
765 | #endif |
---|
766 | #if H_3D_QTLPC |
---|
767 | } |
---|
768 | else |
---|
769 | { |
---|
770 | uiSymbol = 0; |
---|
771 | } |
---|
772 | #endif |
---|
773 | pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx ); |
---|
774 | |
---|
775 | return; |
---|
776 | } |
---|
777 | |
---|
778 | /** parse partition size |
---|
779 | * \param pcCU |
---|
780 | * \param uiAbsPartIdx |
---|
781 | * \param uiDepth |
---|
782 | * \returns Void |
---|
783 | */ |
---|
784 | Void TDecSbac::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
785 | { |
---|
786 | UInt uiSymbol, uiMode = 0; |
---|
787 | PartSize eMode; |
---|
788 | |
---|
789 | #if H_3D_QTLPC |
---|
790 | Bool bParsePartSize = true; |
---|
791 | TComSPS *sps = pcCU->getPic()->getSlice(0)->getSPS(); |
---|
792 | TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); |
---|
793 | Bool bDepthMapDetect = (pcTexture != NULL); |
---|
794 | Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); |
---|
795 | |
---|
796 | Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); |
---|
797 | |
---|
798 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL() && sps->getUsePC()) |
---|
799 | { |
---|
800 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
801 | assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); |
---|
802 | if (pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth && pcTextureCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN) |
---|
803 | { |
---|
804 | bParsePartSize = false; |
---|
805 | eMode = SIZE_2Nx2N; |
---|
806 | } |
---|
807 | } |
---|
808 | #endif |
---|
809 | |
---|
810 | |
---|
811 | if ( pcCU->isIntra( uiAbsPartIdx ) ) |
---|
812 | { |
---|
813 | #if H_3D_QTLPC |
---|
814 | if(bParsePartSize) |
---|
815 | { |
---|
816 | #endif |
---|
817 | uiSymbol = 1; |
---|
818 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
819 | { |
---|
820 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
821 | #if H_MV_ENC_DEC_TRAC |
---|
822 | DTRACE_CU("part_mode", uiSymbol) |
---|
823 | #endif |
---|
824 | } |
---|
825 | eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; |
---|
826 | #if H_3D_QTLPC |
---|
827 | } |
---|
828 | #endif |
---|
829 | UInt uiTrLevel = 0; |
---|
830 | UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; |
---|
831 | UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; |
---|
832 | uiTrLevel = uiWidthInBit >= uiTrSizeInBit ? uiWidthInBit - uiTrSizeInBit : 0; |
---|
833 | if( eMode == SIZE_NxN ) |
---|
834 | { |
---|
835 | pcCU->setTrIdxSubParts( 1+uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
836 | } |
---|
837 | else |
---|
838 | { |
---|
839 | pcCU->setTrIdxSubParts( uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
840 | } |
---|
841 | } |
---|
842 | else |
---|
843 | { |
---|
844 | #if H_3D_QTLPC |
---|
845 | if(bParsePartSize) |
---|
846 | { |
---|
847 | #endif |
---|
848 | UInt uiMaxNumBits = 2; |
---|
849 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) ) |
---|
850 | { |
---|
851 | uiMaxNumBits ++; |
---|
852 | } |
---|
853 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
854 | { |
---|
855 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); |
---|
856 | if ( uiSymbol ) |
---|
857 | { |
---|
858 | break; |
---|
859 | } |
---|
860 | uiMode++; |
---|
861 | } |
---|
862 | eMode = (PartSize) uiMode; |
---|
863 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
864 | { |
---|
865 | if (eMode == SIZE_2NxN) |
---|
866 | { |
---|
867 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 )); |
---|
868 | if (uiSymbol == 0) |
---|
869 | { |
---|
870 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
871 | eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); |
---|
872 | } |
---|
873 | } |
---|
874 | else if (eMode == SIZE_Nx2N) |
---|
875 | { |
---|
876 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 )); |
---|
877 | if (uiSymbol == 0) |
---|
878 | { |
---|
879 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
880 | eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); |
---|
881 | } |
---|
882 | } |
---|
883 | } |
---|
884 | #if H_MV_ENC_DEC_TRAC |
---|
885 | DTRACE_CU("part_mode", eMode ) |
---|
886 | #endif |
---|
887 | #if H_3D_QTLPC |
---|
888 | } |
---|
889 | #endif |
---|
890 | } |
---|
891 | pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth ); |
---|
892 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
893 | } |
---|
894 | |
---|
895 | /** parse prediction mode |
---|
896 | * \param pcCU |
---|
897 | * \param uiAbsPartIdx |
---|
898 | * \param uiDepth |
---|
899 | * \returns Void |
---|
900 | */ |
---|
901 | Void TDecSbac::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
902 | { |
---|
903 | if( pcCU->getSlice()->isIntra() ) |
---|
904 | { |
---|
905 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
906 | return; |
---|
907 | } |
---|
908 | |
---|
909 | UInt uiSymbol; |
---|
910 | Int iPredMode = MODE_INTER; |
---|
911 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) ); |
---|
912 | iPredMode += uiSymbol; |
---|
913 | #if H_MV_ENC_DEC_TRAC |
---|
914 | DTRACE_CU("pred_mode_flag", uiSymbol) |
---|
915 | #endif |
---|
916 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
917 | } |
---|
918 | |
---|
919 | Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
920 | { |
---|
921 | PartSize mode = pcCU->getPartitionSize( absPartIdx ); |
---|
922 | UInt partNum = mode==SIZE_NxN?4:1; |
---|
923 | UInt partOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(absPartIdx) << 1 ) ) >> 2; |
---|
924 | UInt mpmPred[4],symbol; |
---|
925 | Int j,intraPredMode; |
---|
926 | if (mode==SIZE_NxN) |
---|
927 | { |
---|
928 | depth++; |
---|
929 | } |
---|
930 | for (j=0;j<partNum;j++) |
---|
931 | { |
---|
932 | #if H_3D_DIM |
---|
933 | if( pcCU->getSlice()->getVpsDepthModesFlag() ) |
---|
934 | { |
---|
935 | parseIntraDepth( pcCU, absPartIdx+partOffset*j, depth ); |
---|
936 | } |
---|
937 | if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) |
---|
938 | #if H_3D_DIM_SDC |
---|
939 | #if QC_GENERIC_SDC_G0122 |
---|
940 | if( 1 ) |
---|
941 | #else |
---|
942 | if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) ) |
---|
943 | #endif |
---|
944 | #endif |
---|
945 | { |
---|
946 | #endif |
---|
947 | m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); |
---|
948 | mpmPred[j] = symbol; |
---|
949 | #if H_MV_ENC_DEC_TRAC |
---|
950 | DTRACE_CU("prev_intra_luma_pred_flag", symbol) |
---|
951 | #endif |
---|
952 | #if H_3D_DIM |
---|
953 | } |
---|
954 | #endif |
---|
955 | } |
---|
956 | for (j=0;j<partNum;j++) |
---|
957 | { |
---|
958 | #if H_3D_DIM |
---|
959 | if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) |
---|
960 | #if H_3D_DIM_SDC |
---|
961 | #if QC_GENERIC_SDC_G0122 |
---|
962 | if( 1 ) |
---|
963 | #else |
---|
964 | if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) ) |
---|
965 | #endif |
---|
966 | #endif |
---|
967 | { |
---|
968 | #endif |
---|
969 | Int preds[3] = {-1, -1, -1}; |
---|
970 | Int predNum = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds); |
---|
971 | if (mpmPred[j]) |
---|
972 | { |
---|
973 | m_pcTDecBinIf->decodeBinEP( symbol ); |
---|
974 | if (symbol) |
---|
975 | { |
---|
976 | m_pcTDecBinIf->decodeBinEP( symbol ); |
---|
977 | symbol++; |
---|
978 | } |
---|
979 | #if H_MV_ENC_DEC_TRAC |
---|
980 | DTRACE_CU("mpm_idx", symbol) |
---|
981 | #endif |
---|
982 | intraPredMode = preds[symbol]; |
---|
983 | } |
---|
984 | else |
---|
985 | { |
---|
986 | m_pcTDecBinIf->decodeBinsEP( symbol, 5 ); |
---|
987 | intraPredMode = symbol; |
---|
988 | #if H_MV_ENC_DEC_TRAC |
---|
989 | DTRACE_CU("rem_intra_luma_pred_mode", symbol) |
---|
990 | #endif |
---|
991 | //postponed sorting of MPMs (only in remaining branch) |
---|
992 | if (preds[0] > preds[1]) |
---|
993 | { |
---|
994 | std::swap(preds[0], preds[1]); |
---|
995 | } |
---|
996 | if (preds[0] > preds[2]) |
---|
997 | { |
---|
998 | std::swap(preds[0], preds[2]); |
---|
999 | } |
---|
1000 | if (preds[1] > preds[2]) |
---|
1001 | { |
---|
1002 | std::swap(preds[1], preds[2]); |
---|
1003 | } |
---|
1004 | for ( Int i = 0; i < predNum; i++ ) |
---|
1005 | { |
---|
1006 | intraPredMode += ( intraPredMode >= preds[i] ); |
---|
1007 | } |
---|
1008 | } |
---|
1009 | pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, absPartIdx+partOffset*j, depth ); |
---|
1010 | #if H_3D_DIM |
---|
1011 | } |
---|
1012 | #endif |
---|
1013 | } |
---|
1014 | } |
---|
1015 | |
---|
1016 | Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1017 | { |
---|
1018 | UInt uiSymbol; |
---|
1019 | |
---|
1020 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) ); |
---|
1021 | |
---|
1022 | if( uiSymbol == 0 ) |
---|
1023 | { |
---|
1024 | #if H_MV_ENC_DEC_TRAC |
---|
1025 | DTRACE_CU("intra_chroma_pred_mode", uiSymbol ) |
---|
1026 | #endif |
---|
1027 | uiSymbol = DM_CHROMA_IDX; |
---|
1028 | } |
---|
1029 | else |
---|
1030 | { |
---|
1031 | { |
---|
1032 | UInt uiIPredMode; |
---|
1033 | m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 ); |
---|
1034 | #if H_MV_ENC_DEC_TRAC |
---|
1035 | DTRACE_CU("intra_chroma_pred_mode", uiIPredMode ) |
---|
1036 | #endif |
---|
1037 | UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; |
---|
1038 | pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); |
---|
1039 | uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; |
---|
1040 | } |
---|
1041 | } |
---|
1042 | pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); |
---|
1043 | return; |
---|
1044 | } |
---|
1045 | |
---|
1046 | #if H_3D_DIM |
---|
1047 | Void TDecSbac::parseIntraDepth( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
1048 | { |
---|
1049 | parseIntraDepthMode( pcCU, absPartIdx, depth ); |
---|
1050 | |
---|
1051 | UInt dir = pcCU->getLumaIntraDir( absPartIdx ); |
---|
1052 | UInt dimType = getDimType( dir ); |
---|
1053 | |
---|
1054 | switch( dimType ) |
---|
1055 | { |
---|
1056 | #if H_3D_DIM_DMM |
---|
1057 | case( DMM1_IDX ): |
---|
1058 | { |
---|
1059 | UInt uiTabIdx = 0; |
---|
1060 | xParseDmm1WedgeIdx( uiTabIdx, g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); |
---|
1061 | pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, absPartIdx, depth ); |
---|
1062 | } break; |
---|
1063 | case( DMM4_IDX ): break; |
---|
1064 | #endif |
---|
1065 | default: break; |
---|
1066 | } |
---|
1067 | |
---|
1068 | if( dimType < DIM_NUM_TYPE || pcCU->getSDCFlag( absPartIdx ) ) |
---|
1069 | { |
---|
1070 | UInt symbol; |
---|
1071 | #if QC_GENERIC_SDC_G0122 |
---|
1072 | UInt uiNumSegments = isDimMode( dir ) ? 2 : 1; |
---|
1073 | #else |
---|
1074 | UInt uiNumSegments = ( dir == PLANAR_IDX ) ? 1 : 2; |
---|
1075 | #endif |
---|
1076 | |
---|
1077 | if( pcCU->getSDCFlag( absPartIdx ) ) |
---|
1078 | { |
---|
1079 | assert(pcCU->getPartitionSize(absPartIdx)==SIZE_2Nx2N); |
---|
1080 | pcCU->setTrIdxSubParts(0, absPartIdx, depth); |
---|
1081 | pcCU->setCbfSubParts(1, 1, 1, absPartIdx, depth); |
---|
1082 | } |
---|
1083 | |
---|
1084 | m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get(0, 0, uiNumSegments-1) ); |
---|
1085 | |
---|
1086 | if( symbol ) |
---|
1087 | { |
---|
1088 | if( !pcCU->getSDCFlag( absPartIdx ) ) |
---|
1089 | { |
---|
1090 | dir += symbol; |
---|
1091 | } |
---|
1092 | } |
---|
1093 | for( UInt segment = 0; segment < uiNumSegments; segment++ ) |
---|
1094 | { |
---|
1095 | Pel valDeltaDC = 0; |
---|
1096 | if( symbol ) |
---|
1097 | { |
---|
1098 | xParseDimDeltaDC( valDeltaDC, uiNumSegments ); |
---|
1099 | } |
---|
1100 | |
---|
1101 | if( pcCU->getSDCFlag( absPartIdx ) ) |
---|
1102 | { |
---|
1103 | pcCU->setSDCSegmentDCOffset( valDeltaDC, segment, absPartIdx ); |
---|
1104 | } |
---|
1105 | else |
---|
1106 | { |
---|
1107 | pcCU->setDimDeltaDC( dimType, segment, absPartIdx, valDeltaDC ); |
---|
1108 | } |
---|
1109 | } |
---|
1110 | } |
---|
1111 | |
---|
1112 | pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth ); |
---|
1113 | } |
---|
1114 | |
---|
1115 | #if QC_GENERIC_SDC_G0122 |
---|
1116 | Void TDecSbac::parseIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
1117 | { |
---|
1118 | UInt uiSymbol, uiIsDimMode; |
---|
1119 | |
---|
1120 | if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed |
---|
1121 | { |
---|
1122 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cAngleFlagSCModel.get( 0, 0, pcCU->getCtxAngleFlag( absPartIdx ) ) ); |
---|
1123 | } |
---|
1124 | else |
---|
1125 | { |
---|
1126 | uiSymbol = 1; |
---|
1127 | } |
---|
1128 | uiIsDimMode = uiSymbol ? 0 : 1; |
---|
1129 | pcCU->setLumaIntraDirSubParts( 0, absPartIdx, depth ); |
---|
1130 | |
---|
1131 | if( pcCU->getPartitionSize( absPartIdx ) == SIZE_2Nx2N ) //SDC is allowed only in this case |
---|
1132 | { |
---|
1133 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraSdcFlagSCModel.get( 0, 0, pcCU->getCtxSDCFlag( absPartIdx ) ) ); |
---|
1134 | } |
---|
1135 | else |
---|
1136 | { |
---|
1137 | uiSymbol = 0; |
---|
1138 | } |
---|
1139 | |
---|
1140 | pcCU->setSDCFlagSubParts( uiSymbol, absPartIdx, depth ); |
---|
1141 | |
---|
1142 | //decode DMM index |
---|
1143 | if( uiIsDimMode ) |
---|
1144 | { |
---|
1145 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDepthIntraModeSCModel.get( 0, 0, 0 ) ); |
---|
1146 | if( !uiSymbol ) |
---|
1147 | { |
---|
1148 | pcCU->setLumaIntraDirSubParts( ( 2 * DMM1_IDX + DIM_OFFSET ), absPartIdx, depth ); |
---|
1149 | } |
---|
1150 | else |
---|
1151 | { |
---|
1152 | pcCU->setLumaIntraDirSubParts( ( 2 * DMM4_IDX + DIM_OFFSET ), absPartIdx, depth ); |
---|
1153 | } |
---|
1154 | } |
---|
1155 | } |
---|
1156 | #else |
---|
1157 | Void TDecSbac::parseIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
1158 | { |
---|
1159 | UInt puIdx = (pcCU->getWidth(absPartIdx) == 64) ? 2 : ( (pcCU->getPartitionSize(absPartIdx) == SIZE_NxN && pcCU->getWidth(absPartIdx) == 8) ? 0 : 1 ); |
---|
1160 | UInt dir = 0; |
---|
1161 | Bool sdcFlag = 0; |
---|
1162 | UInt symbol = 1; |
---|
1163 | UInt modeCode = 0 ; |
---|
1164 | UInt binNum = 0; |
---|
1165 | UInt ctxDepthMode = 0; |
---|
1166 | |
---|
1167 | if( puIdx == 2 ) |
---|
1168 | { |
---|
1169 | { |
---|
1170 | ctxDepthMode = puIdx*3 + binNum; |
---|
1171 | m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); |
---|
1172 | modeCode = (modeCode<<1) + symbol; |
---|
1173 | binNum++; |
---|
1174 | } |
---|
1175 | if( modeCode == 0 ) { dir = PLANAR_IDX; sdcFlag = 1;} |
---|
1176 | else if( modeCode == 1 ) { dir = 0; sdcFlag = 0;} |
---|
1177 | } |
---|
1178 | else if( puIdx == 0 ) |
---|
1179 | { |
---|
1180 | while( binNum < 1 && symbol ) |
---|
1181 | { |
---|
1182 | ctxDepthMode = puIdx*3 + ((binNum >= 2) ? 2 : binNum); |
---|
1183 | m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); |
---|
1184 | modeCode = (modeCode<<1) + symbol; |
---|
1185 | binNum++; |
---|
1186 | } |
---|
1187 | if( modeCode == 0 ) |
---|
1188 | { |
---|
1189 | dir = 0; |
---|
1190 | sdcFlag = 0; |
---|
1191 | } |
---|
1192 | else if ( modeCode == 1 ) |
---|
1193 | { |
---|
1194 | dir = (2*DMM1_IDX+DIM_OFFSET); |
---|
1195 | sdcFlag = 0; |
---|
1196 | } |
---|
1197 | } |
---|
1198 | else |
---|
1199 | { |
---|
1200 | while( binNum < 4 && symbol ) |
---|
1201 | { |
---|
1202 | ctxDepthMode = puIdx*3 + ((binNum >= 2) ? 2 : binNum); |
---|
1203 | m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); |
---|
1204 | modeCode = (modeCode<<1) + symbol; |
---|
1205 | binNum++; |
---|
1206 | } |
---|
1207 | if ( modeCode == 0 ) { dir = PLANAR_IDX; sdcFlag = 1;} |
---|
1208 | else if ( modeCode == 2 ) { dir = 5; sdcFlag = 0;} |
---|
1209 | else if ( modeCode == 6 ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 1;} |
---|
1210 | else if ( modeCode == 14 ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;} |
---|
1211 | else if ( modeCode == 15 ) { dir = (2*DMM4_IDX+DIM_OFFSET); sdcFlag = 0;} |
---|
1212 | |
---|
1213 | } |
---|
1214 | pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth ); |
---|
1215 | #if H_3D_DIM_SDC |
---|
1216 | pcCU->setSDCFlagSubParts( sdcFlag, absPartIdx, depth ); |
---|
1217 | #endif |
---|
1218 | } |
---|
1219 | #endif |
---|
1220 | #endif |
---|
1221 | |
---|
1222 | Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ) |
---|
1223 | { |
---|
1224 | UInt uiSymbol; |
---|
1225 | const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); |
---|
1226 | ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 ); |
---|
1227 | uiSymbol = 0; |
---|
1228 | if (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N || pcCU->getHeight(uiAbsPartIdx) != 8 ) |
---|
1229 | { |
---|
1230 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) ); |
---|
1231 | } |
---|
1232 | |
---|
1233 | if( uiSymbol ) |
---|
1234 | { |
---|
1235 | uiSymbol = 2; |
---|
1236 | } |
---|
1237 | else |
---|
1238 | { |
---|
1239 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + 4 ) ); |
---|
1240 | assert(uiSymbol == 0 || uiSymbol == 1); |
---|
1241 | } |
---|
1242 | |
---|
1243 | uiSymbol++; |
---|
1244 | ruiInterDir = uiSymbol; |
---|
1245 | #if H_MV_ENC_DEC_TRAC |
---|
1246 | DTRACE_PU("inter_pred_idc", ruiInterDir - 1 ) |
---|
1247 | #endif |
---|
1248 | |
---|
1249 | return; |
---|
1250 | } |
---|
1251 | |
---|
1252 | Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList ) |
---|
1253 | { |
---|
1254 | UInt uiSymbol; |
---|
1255 | { |
---|
1256 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
1257 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1258 | |
---|
1259 | if( uiSymbol ) |
---|
1260 | { |
---|
1261 | UInt uiRefNum = pcCU->getSlice()->getNumRefIdx( eRefList ) - 2; |
---|
1262 | pCtx++; |
---|
1263 | UInt ui; |
---|
1264 | for( ui = 0; ui < uiRefNum; ++ui ) |
---|
1265 | { |
---|
1266 | if( ui == 0 ) |
---|
1267 | { |
---|
1268 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1269 | } |
---|
1270 | else |
---|
1271 | { |
---|
1272 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
1273 | } |
---|
1274 | if( uiSymbol == 0 ) |
---|
1275 | { |
---|
1276 | break; |
---|
1277 | } |
---|
1278 | } |
---|
1279 | uiSymbol = ui + 1; |
---|
1280 | } |
---|
1281 | riRefFrmIdx = uiSymbol; |
---|
1282 | } |
---|
1283 | |
---|
1284 | #if H_MV_ENC_DEC_TRAC |
---|
1285 | #if ENC_DEC_TRACE |
---|
1286 | if ( eRefList == REF_PIC_LIST_0 ) |
---|
1287 | { |
---|
1288 | DTRACE_PU("ref_idx_l0", uiSymbol) |
---|
1289 | } |
---|
1290 | else |
---|
1291 | { |
---|
1292 | DTRACE_PU("ref_idx_l1", uiSymbol) |
---|
1293 | } |
---|
1294 | #endif |
---|
1295 | #endif |
---|
1296 | return; |
---|
1297 | } |
---|
1298 | |
---|
1299 | Void TDecSbac::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
1300 | { |
---|
1301 | UInt uiSymbol; |
---|
1302 | UInt uiHorAbs; |
---|
1303 | UInt uiVerAbs; |
---|
1304 | UInt uiHorSign = 0; |
---|
1305 | UInt uiVerSign = 0; |
---|
1306 | ContextModel *pCtx = m_cCUMvdSCModel.get( 0 ); |
---|
1307 | |
---|
1308 | if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3) |
---|
1309 | { |
---|
1310 | uiHorAbs=0; |
---|
1311 | uiVerAbs=0; |
---|
1312 | } |
---|
1313 | else |
---|
1314 | { |
---|
1315 | m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx ); |
---|
1316 | m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx ); |
---|
1317 | |
---|
1318 | const Bool bHorAbsGr0 = uiHorAbs != 0; |
---|
1319 | const Bool bVerAbsGr0 = uiVerAbs != 0; |
---|
1320 | pCtx++; |
---|
1321 | |
---|
1322 | if( bHorAbsGr0 ) |
---|
1323 | { |
---|
1324 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1325 | uiHorAbs += uiSymbol; |
---|
1326 | } |
---|
1327 | |
---|
1328 | if( bVerAbsGr0 ) |
---|
1329 | { |
---|
1330 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
1331 | uiVerAbs += uiSymbol; |
---|
1332 | } |
---|
1333 | |
---|
1334 | if( bHorAbsGr0 ) |
---|
1335 | { |
---|
1336 | if( 2 == uiHorAbs ) |
---|
1337 | { |
---|
1338 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
1339 | uiHorAbs += uiSymbol; |
---|
1340 | } |
---|
1341 | |
---|
1342 | m_pcTDecBinIf->decodeBinEP( uiHorSign ); |
---|
1343 | } |
---|
1344 | |
---|
1345 | if( bVerAbsGr0 ) |
---|
1346 | { |
---|
1347 | if( 2 == uiVerAbs ) |
---|
1348 | { |
---|
1349 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
1350 | uiVerAbs += uiSymbol; |
---|
1351 | } |
---|
1352 | |
---|
1353 | m_pcTDecBinIf->decodeBinEP( uiVerSign ); |
---|
1354 | } |
---|
1355 | |
---|
1356 | } |
---|
1357 | |
---|
1358 | const TComMv cMv( uiHorSign ? -Int( uiHorAbs ): uiHorAbs, uiVerSign ? -Int( uiVerAbs ) : uiVerAbs ); |
---|
1359 | pcCU->getCUMvField( eRefList )->setAllMvd( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1360 | return; |
---|
1361 | } |
---|
1362 | |
---|
1363 | |
---|
1364 | Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) |
---|
1365 | { |
---|
1366 | m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) ); |
---|
1367 | #if !H_MV_ENC_DEC_TRAC |
---|
1368 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1369 | DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) |
---|
1370 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1371 | DTRACE_CABAC_V( ruiSubdivFlag ) |
---|
1372 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1373 | DTRACE_CABAC_V( uiLog2TransformBlockSize ) |
---|
1374 | DTRACE_CABAC_T( "\n" ) |
---|
1375 | #endif |
---|
1376 | } |
---|
1377 | |
---|
1378 | Void TDecSbac::parseQtRootCbf( UInt uiAbsPartIdx, UInt& uiQtRootCbf ) |
---|
1379 | { |
---|
1380 | UInt uiSymbol; |
---|
1381 | const UInt uiCtx = 0; |
---|
1382 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) ); |
---|
1383 | #if !H_MV_ENC_DEC_TRAC |
---|
1384 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1385 | DTRACE_CABAC_T( "\tparseQtRootCbf()" ) |
---|
1386 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1387 | DTRACE_CABAC_V( uiSymbol ) |
---|
1388 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1389 | DTRACE_CABAC_V( uiCtx ) |
---|
1390 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1391 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1392 | DTRACE_CABAC_T( "\n" ) |
---|
1393 | #else |
---|
1394 | DTRACE_CU( "rqt_root_cbf", uiSymbol ) |
---|
1395 | #endif |
---|
1396 | |
---|
1397 | uiQtRootCbf = uiSymbol; |
---|
1398 | } |
---|
1399 | |
---|
1400 | Void TDecSbac::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1401 | { |
---|
1402 | Int qp; |
---|
1403 | UInt uiDQp; |
---|
1404 | Int iDQp; |
---|
1405 | |
---|
1406 | UInt uiSymbol; |
---|
1407 | |
---|
1408 | xReadUnaryMaxSymbol (uiDQp, &m_cCUDeltaQpSCModel.get( 0, 0, 0 ), 1, CU_DQP_TU_CMAX); |
---|
1409 | |
---|
1410 | if( uiDQp >= CU_DQP_TU_CMAX) |
---|
1411 | { |
---|
1412 | xReadEpExGolomb( uiSymbol, CU_DQP_EG_k ); |
---|
1413 | uiDQp+=uiSymbol; |
---|
1414 | } |
---|
1415 | |
---|
1416 | if ( uiDQp > 0 ) |
---|
1417 | { |
---|
1418 | UInt uiSign; |
---|
1419 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
1420 | m_pcTDecBinIf->decodeBinEP(uiSign); |
---|
1421 | iDQp = uiDQp; |
---|
1422 | if(uiSign) |
---|
1423 | { |
---|
1424 | iDQp = -iDQp; |
---|
1425 | } |
---|
1426 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY; |
---|
1427 | } |
---|
1428 | else |
---|
1429 | { |
---|
1430 | qp = pcCU->getRefQP(uiAbsPartIdx); |
---|
1431 | } |
---|
1432 | pcCU->setQPSubParts(qp, uiAbsPartIdx, uiDepth); |
---|
1433 | pcCU->setCodedQP(qp); |
---|
1434 | } |
---|
1435 | |
---|
1436 | Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) |
---|
1437 | { |
---|
1438 | UInt uiSymbol; |
---|
1439 | const UInt uiCtx = pcCU->getCtxQtCbf( eType, uiTrDepth ); |
---|
1440 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) ); |
---|
1441 | #if !H_MV_ENC_DEC_TRAC |
---|
1442 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1443 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
1444 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1445 | DTRACE_CABAC_V( uiSymbol ) |
---|
1446 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1447 | DTRACE_CABAC_V( uiCtx ) |
---|
1448 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1449 | DTRACE_CABAC_V( eType ) |
---|
1450 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1451 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1452 | DTRACE_CABAC_T( "\n" ) |
---|
1453 | #endif |
---|
1454 | |
---|
1455 | pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth ); |
---|
1456 | } |
---|
1457 | |
---|
1458 | void TDecSbac::parseTransformSkipFlags (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType) |
---|
1459 | { |
---|
1460 | if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) |
---|
1461 | { |
---|
1462 | return; |
---|
1463 | } |
---|
1464 | if(width != 4 || height != 4) |
---|
1465 | { |
---|
1466 | return; |
---|
1467 | } |
---|
1468 | |
---|
1469 | UInt useTransformSkip; |
---|
1470 | m_pcTDecBinIf->decodeBin( useTransformSkip , m_cTransformSkipSCModel.get( 0, eTType? TEXT_CHROMA: TEXT_LUMA, 0 ) ); |
---|
1471 | if(eTType!= TEXT_LUMA) |
---|
1472 | { |
---|
1473 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - uiDepth; |
---|
1474 | if(uiLog2TrafoSize == 2) |
---|
1475 | { |
---|
1476 | uiDepth --; |
---|
1477 | } |
---|
1478 | } |
---|
1479 | #if !H_MV_ENC_DEC_TRAC |
---|
1480 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1481 | DTRACE_CABAC_T("\tparseTransformSkip()"); |
---|
1482 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1483 | DTRACE_CABAC_V( useTransformSkip ) |
---|
1484 | DTRACE_CABAC_T( "\tAddr=" ) |
---|
1485 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
1486 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1487 | DTRACE_CABAC_V( eTType ) |
---|
1488 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1489 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1490 | DTRACE_CABAC_T( "\n" ) |
---|
1491 | #endif |
---|
1492 | |
---|
1493 | pcCU->setTransformSkipSubParts( useTransformSkip, eTType, uiAbsPartIdx, uiDepth); |
---|
1494 | } |
---|
1495 | |
---|
1496 | /** Parse (X,Y) position of the last significant coefficient |
---|
1497 | * \param uiPosLastX reference to X component of last coefficient |
---|
1498 | * \param uiPosLastY reference to Y component of last coefficient |
---|
1499 | * \param width Block width |
---|
1500 | * \param height Block height |
---|
1501 | * \param eTType plane type / luminance or chrominance |
---|
1502 | * \param uiScanIdx scan type (zig-zag, hor, ver) |
---|
1503 | * |
---|
1504 | * This method decodes the X and Y component within a block of the last significant coefficient. |
---|
1505 | */ |
---|
1506 | Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx ) |
---|
1507 | { |
---|
1508 | UInt uiLast; |
---|
1509 | ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); |
---|
1510 | ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); |
---|
1511 | |
---|
1512 | Int blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY; |
---|
1513 | blkSizeOffsetX = eTType ? 0: (g_aucConvertToBit[ width ] *3 + ((g_aucConvertToBit[ width ] +1)>>2)); |
---|
1514 | blkSizeOffsetY = eTType ? 0: (g_aucConvertToBit[ height ]*3 + ((g_aucConvertToBit[ height ]+1)>>2)); |
---|
1515 | shiftX= eTType ? g_aucConvertToBit[ width ] :((g_aucConvertToBit[ width ]+3)>>2); |
---|
1516 | shiftY= eTType ? g_aucConvertToBit[ height ] :((g_aucConvertToBit[ height ]+3)>>2); |
---|
1517 | // posX |
---|
1518 | for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ ) |
---|
1519 | { |
---|
1520 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + blkSizeOffsetX + (uiPosLastX >>shiftX) ) ); |
---|
1521 | if( !uiLast ) |
---|
1522 | { |
---|
1523 | break; |
---|
1524 | } |
---|
1525 | } |
---|
1526 | |
---|
1527 | // posY |
---|
1528 | for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ ) |
---|
1529 | { |
---|
1530 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + blkSizeOffsetY + (uiPosLastY >>shiftY)) ); |
---|
1531 | if( !uiLast ) |
---|
1532 | { |
---|
1533 | break; |
---|
1534 | } |
---|
1535 | } |
---|
1536 | if ( uiPosLastX > 3 ) |
---|
1537 | { |
---|
1538 | UInt uiTemp = 0; |
---|
1539 | UInt uiCount = ( uiPosLastX - 2 ) >> 1; |
---|
1540 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
1541 | { |
---|
1542 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
1543 | uiTemp += uiLast << i; |
---|
1544 | } |
---|
1545 | uiPosLastX = g_uiMinInGroup[ uiPosLastX ] + uiTemp; |
---|
1546 | } |
---|
1547 | if ( uiPosLastY > 3 ) |
---|
1548 | { |
---|
1549 | UInt uiTemp = 0; |
---|
1550 | UInt uiCount = ( uiPosLastY - 2 ) >> 1; |
---|
1551 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
1552 | { |
---|
1553 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
1554 | uiTemp += uiLast << i; |
---|
1555 | } |
---|
1556 | uiPosLastY = g_uiMinInGroup[ uiPosLastY ] + uiTemp; |
---|
1557 | } |
---|
1558 | |
---|
1559 | if( uiScanIdx == SCAN_VER ) |
---|
1560 | { |
---|
1561 | swap( uiPosLastX, uiPosLastY ); |
---|
1562 | } |
---|
1563 | } |
---|
1564 | |
---|
1565 | Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
1566 | { |
---|
1567 | #if !H_MV_ENC_DEC_TRAC |
---|
1568 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1569 | DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) |
---|
1570 | DTRACE_CABAC_V( eTType ) |
---|
1571 | DTRACE_CABAC_T( "\twidth=" ) |
---|
1572 | DTRACE_CABAC_V( uiWidth ) |
---|
1573 | DTRACE_CABAC_T( "\theight=" ) |
---|
1574 | DTRACE_CABAC_V( uiHeight ) |
---|
1575 | DTRACE_CABAC_T( "\tdepth=" ) |
---|
1576 | DTRACE_CABAC_V( uiDepth ) |
---|
1577 | DTRACE_CABAC_T( "\tabspartidx=" ) |
---|
1578 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1579 | DTRACE_CABAC_T( "\ttoCU-X=" ) |
---|
1580 | DTRACE_CABAC_V( pcCU->getCUPelX() ) |
---|
1581 | DTRACE_CABAC_T( "\ttoCU-Y=" ) |
---|
1582 | DTRACE_CABAC_V( pcCU->getCUPelY() ) |
---|
1583 | DTRACE_CABAC_T( "\tCU-addr=" ) |
---|
1584 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
1585 | DTRACE_CABAC_T( "\tinCU-X=" ) |
---|
1586 | DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1587 | DTRACE_CABAC_T( "\tinCU-Y=" ) |
---|
1588 | DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1589 | DTRACE_CABAC_T( "\tpredmode=" ) |
---|
1590 | DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) |
---|
1591 | DTRACE_CABAC_T( "\n" ) |
---|
1592 | #endif |
---|
1593 | |
---|
1594 | if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) |
---|
1595 | { |
---|
1596 | uiWidth = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
1597 | uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
1598 | } |
---|
1599 | if(pcCU->getSlice()->getPPS()->getUseTransformSkip()) |
---|
1600 | { |
---|
1601 | parseTransformSkipFlags( pcCU, uiAbsPartIdx, uiWidth, uiHeight, uiDepth, eTType); |
---|
1602 | } |
---|
1603 | |
---|
1604 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); |
---|
1605 | |
---|
1606 | //----- parse significance map ----- |
---|
1607 | const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; |
---|
1608 | const UInt uiMaxNumCoeff = uiWidth * uiHeight; |
---|
1609 | const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; |
---|
1610 | UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); |
---|
1611 | |
---|
1612 | //===== decode last significant ===== |
---|
1613 | UInt uiPosLastX, uiPosLastY; |
---|
1614 | parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, eTType, uiScanIdx ); |
---|
1615 | UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockSize); |
---|
1616 | pcCoef[ uiBlkPosLast ] = 1; |
---|
1617 | |
---|
1618 | //===== decode significance flags ===== |
---|
1619 | UInt uiScanPosLast; |
---|
1620 | const UInt *scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ]; |
---|
1621 | for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ ) |
---|
1622 | { |
---|
1623 | UInt uiBlkPos = scan[ uiScanPosLast ]; |
---|
1624 | if( uiBlkPosLast == uiBlkPos ) |
---|
1625 | { |
---|
1626 | break; |
---|
1627 | } |
---|
1628 | } |
---|
1629 | |
---|
1630 | ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, eTType ); |
---|
1631 | ContextModel * const baseCtx = (eTType==TEXT_LUMA) ? m_cCUSigSCModel.get( 0, 0 ) : m_cCUSigSCModel.get( 0, 0 ) + NUM_SIG_FLAG_CTX_LUMA; |
---|
1632 | |
---|
1633 | const Int iLastScanSet = uiScanPosLast >> LOG2_SCAN_SET_SIZE; |
---|
1634 | UInt c1 = 1; |
---|
1635 | UInt uiGoRiceParam = 0; |
---|
1636 | |
---|
1637 | Bool beValid; |
---|
1638 | if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) |
---|
1639 | { |
---|
1640 | beValid = false; |
---|
1641 | } |
---|
1642 | else |
---|
1643 | { |
---|
1644 | beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
1645 | } |
---|
1646 | UInt absSum = 0; |
---|
1647 | |
---|
1648 | UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ]; |
---|
1649 | ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); |
---|
1650 | const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1); |
---|
1651 | const UInt * scanCG; |
---|
1652 | { |
---|
1653 | scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ]; |
---|
1654 | if( uiLog2BlockSize == 3 ) |
---|
1655 | { |
---|
1656 | scanCG = g_sigLastScan8x8[ uiScanIdx ]; |
---|
1657 | } |
---|
1658 | else if( uiLog2BlockSize == 5 ) |
---|
1659 | { |
---|
1660 | scanCG = g_sigLastScanCG32x32; |
---|
1661 | } |
---|
1662 | } |
---|
1663 | Int iScanPosSig = (Int) uiScanPosLast; |
---|
1664 | for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- ) |
---|
1665 | { |
---|
1666 | Int iSubPos = iSubSet << LOG2_SCAN_SET_SIZE; |
---|
1667 | uiGoRiceParam = 0; |
---|
1668 | Int numNonZero = 0; |
---|
1669 | |
---|
1670 | Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE; |
---|
1671 | |
---|
1672 | Int pos[SCAN_SET_SIZE]; |
---|
1673 | if( iScanPosSig == (Int) uiScanPosLast ) |
---|
1674 | { |
---|
1675 | lastNZPosInCG = iScanPosSig; |
---|
1676 | firstNZPosInCG = iScanPosSig; |
---|
1677 | iScanPosSig--; |
---|
1678 | pos[ numNonZero ] = uiBlkPosLast; |
---|
1679 | numNonZero = 1; |
---|
1680 | } |
---|
1681 | |
---|
1682 | // decode significant_coeffgroup_flag |
---|
1683 | Int iCGBlkPos = scanCG[ iSubSet ]; |
---|
1684 | Int iCGPosY = iCGBlkPos / uiNumBlkSide; |
---|
1685 | Int iCGPosX = iCGBlkPos - (iCGPosY * uiNumBlkSide); |
---|
1686 | if( iSubSet == iLastScanSet || iSubSet == 0) |
---|
1687 | { |
---|
1688 | uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; |
---|
1689 | } |
---|
1690 | else |
---|
1691 | { |
---|
1692 | UInt uiSigCoeffGroup; |
---|
1693 | UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); |
---|
1694 | m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] ); |
---|
1695 | uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup; |
---|
1696 | } |
---|
1697 | |
---|
1698 | // decode significant_coeff_flag |
---|
1699 | Int patternSigCtx = TComTrQuant::calcPatternSigCtx( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); |
---|
1700 | UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig; |
---|
1701 | for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) |
---|
1702 | { |
---|
1703 | uiBlkPos = scan[ iScanPosSig ]; |
---|
1704 | uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
1705 | uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
1706 | uiSig = 0; |
---|
1707 | |
---|
1708 | if( uiSigCoeffGroupFlag[ iCGBlkPos ] ) |
---|
1709 | { |
---|
1710 | if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) |
---|
1711 | { |
---|
1712 | uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, uiLog2BlockSize, eTType ); |
---|
1713 | m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] ); |
---|
1714 | } |
---|
1715 | else |
---|
1716 | { |
---|
1717 | uiSig = 1; |
---|
1718 | } |
---|
1719 | } |
---|
1720 | pcCoef[ uiBlkPos ] = uiSig; |
---|
1721 | if( uiSig ) |
---|
1722 | { |
---|
1723 | pos[ numNonZero ] = uiBlkPos; |
---|
1724 | numNonZero ++; |
---|
1725 | if( lastNZPosInCG == -1 ) |
---|
1726 | { |
---|
1727 | lastNZPosInCG = iScanPosSig; |
---|
1728 | } |
---|
1729 | firstNZPosInCG = iScanPosSig; |
---|
1730 | } |
---|
1731 | } |
---|
1732 | |
---|
1733 | if( numNonZero ) |
---|
1734 | { |
---|
1735 | Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= SBH_THRESHOLD ); |
---|
1736 | absSum = 0; |
---|
1737 | UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0; |
---|
1738 | UInt uiBin; |
---|
1739 | if( c1 == 0 ) |
---|
1740 | { |
---|
1741 | uiCtxSet++; |
---|
1742 | } |
---|
1743 | c1 = 1; |
---|
1744 | ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet; |
---|
1745 | Int absCoeff[SCAN_SET_SIZE]; |
---|
1746 | |
---|
1747 | for ( Int i = 0; i < numNonZero; i++) absCoeff[i] = 1; |
---|
1748 | Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); |
---|
1749 | Int firstC2FlagIdx = -1; |
---|
1750 | |
---|
1751 | for( Int idx = 0; idx < numC1Flag; idx++ ) |
---|
1752 | { |
---|
1753 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] ); |
---|
1754 | if( uiBin == 1 ) |
---|
1755 | { |
---|
1756 | c1 = 0; |
---|
1757 | if (firstC2FlagIdx == -1) |
---|
1758 | { |
---|
1759 | firstC2FlagIdx = idx; |
---|
1760 | } |
---|
1761 | } |
---|
1762 | else if( (c1 < 3) && (c1 > 0) ) |
---|
1763 | { |
---|
1764 | c1++; |
---|
1765 | } |
---|
1766 | absCoeff[ idx ] = uiBin + 1; |
---|
1767 | } |
---|
1768 | |
---|
1769 | if (c1 == 0) |
---|
1770 | { |
---|
1771 | baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet; |
---|
1772 | if ( firstC2FlagIdx != -1) |
---|
1773 | { |
---|
1774 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] ); |
---|
1775 | absCoeff[ firstC2FlagIdx ] = uiBin + 2; |
---|
1776 | } |
---|
1777 | } |
---|
1778 | |
---|
1779 | UInt coeffSigns; |
---|
1780 | if ( signHidden && beValid ) |
---|
1781 | { |
---|
1782 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 ); |
---|
1783 | coeffSigns <<= 32 - (numNonZero-1); |
---|
1784 | } |
---|
1785 | else |
---|
1786 | { |
---|
1787 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero ); |
---|
1788 | coeffSigns <<= 32 - numNonZero; |
---|
1789 | } |
---|
1790 | |
---|
1791 | Int iFirstCoeff2 = 1; |
---|
1792 | if (c1 == 0 || numNonZero > C1FLAG_NUMBER) |
---|
1793 | { |
---|
1794 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
1795 | { |
---|
1796 | UInt baseLevel = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2) : 1; |
---|
1797 | |
---|
1798 | if( absCoeff[ idx ] == baseLevel) |
---|
1799 | { |
---|
1800 | UInt uiLevel; |
---|
1801 | xReadCoefRemainExGolomb( uiLevel, uiGoRiceParam ); |
---|
1802 | absCoeff[ idx ] = uiLevel + baseLevel; |
---|
1803 | if(absCoeff[idx]>3*(1<<uiGoRiceParam)) |
---|
1804 | { |
---|
1805 | uiGoRiceParam = min<UInt>(uiGoRiceParam+ 1, 4); |
---|
1806 | } |
---|
1807 | } |
---|
1808 | |
---|
1809 | if(absCoeff[ idx ] >= 2) |
---|
1810 | { |
---|
1811 | iFirstCoeff2 = 0; |
---|
1812 | } |
---|
1813 | } |
---|
1814 | } |
---|
1815 | |
---|
1816 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
1817 | { |
---|
1818 | Int blkPos = pos[ idx ]; |
---|
1819 | // Signs applied later. |
---|
1820 | pcCoef[ blkPos ] = absCoeff[ idx ]; |
---|
1821 | absSum += absCoeff[ idx ]; |
---|
1822 | |
---|
1823 | if ( idx == numNonZero-1 && signHidden && beValid ) |
---|
1824 | { |
---|
1825 | // Infer sign of 1st element. |
---|
1826 | if (absSum&0x1) |
---|
1827 | { |
---|
1828 | pcCoef[ blkPos ] = -pcCoef[ blkPos ]; |
---|
1829 | } |
---|
1830 | } |
---|
1831 | else |
---|
1832 | { |
---|
1833 | Int sign = static_cast<Int>( coeffSigns ) >> 31; |
---|
1834 | pcCoef[ blkPos ] = ( pcCoef[ blkPos ] ^ sign ) - sign; |
---|
1835 | coeffSigns <<= 1; |
---|
1836 | } |
---|
1837 | } |
---|
1838 | } |
---|
1839 | } |
---|
1840 | |
---|
1841 | return; |
---|
1842 | } |
---|
1843 | |
---|
1844 | |
---|
1845 | Void TDecSbac::parseSaoMaxUvlc ( UInt& val, UInt maxSymbol ) |
---|
1846 | { |
---|
1847 | if (maxSymbol == 0) |
---|
1848 | { |
---|
1849 | val = 0; |
---|
1850 | return; |
---|
1851 | } |
---|
1852 | |
---|
1853 | UInt code; |
---|
1854 | Int i; |
---|
1855 | m_pcTDecBinIf->decodeBinEP( code ); |
---|
1856 | if ( code == 0 ) |
---|
1857 | { |
---|
1858 | val = 0; |
---|
1859 | return; |
---|
1860 | } |
---|
1861 | |
---|
1862 | i=1; |
---|
1863 | while (1) |
---|
1864 | { |
---|
1865 | m_pcTDecBinIf->decodeBinEP( code ); |
---|
1866 | if ( code == 0 ) |
---|
1867 | { |
---|
1868 | break; |
---|
1869 | } |
---|
1870 | i++; |
---|
1871 | if (i == maxSymbol) |
---|
1872 | { |
---|
1873 | break; |
---|
1874 | } |
---|
1875 | } |
---|
1876 | |
---|
1877 | val = i; |
---|
1878 | } |
---|
1879 | Void TDecSbac::parseSaoUflc (UInt uiLength, UInt& riVal) |
---|
1880 | { |
---|
1881 | m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength ); |
---|
1882 | } |
---|
1883 | Void TDecSbac::parseSaoMerge (UInt& ruiVal) |
---|
1884 | { |
---|
1885 | UInt uiCode; |
---|
1886 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) ); |
---|
1887 | ruiVal = (Int)uiCode; |
---|
1888 | } |
---|
1889 | Void TDecSbac::parseSaoTypeIdx (UInt& ruiVal) |
---|
1890 | { |
---|
1891 | UInt uiCode; |
---|
1892 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); |
---|
1893 | if (uiCode == 0) |
---|
1894 | { |
---|
1895 | ruiVal = 0; |
---|
1896 | } |
---|
1897 | else |
---|
1898 | { |
---|
1899 | m_pcTDecBinIf->decodeBinEP( uiCode ); |
---|
1900 | if (uiCode == 0) |
---|
1901 | { |
---|
1902 | ruiVal = 5; |
---|
1903 | } |
---|
1904 | else |
---|
1905 | { |
---|
1906 | ruiVal = 1; |
---|
1907 | } |
---|
1908 | } |
---|
1909 | } |
---|
1910 | |
---|
1911 | inline Void copySaoOneLcuParam(SaoLcuParam* psDst, SaoLcuParam* psSrc) |
---|
1912 | { |
---|
1913 | Int i; |
---|
1914 | psDst->partIdx = psSrc->partIdx; |
---|
1915 | psDst->typeIdx = psSrc->typeIdx; |
---|
1916 | if (psDst->typeIdx != -1) |
---|
1917 | { |
---|
1918 | psDst->subTypeIdx = psSrc->subTypeIdx ; |
---|
1919 | psDst->length = psSrc->length; |
---|
1920 | for (i=0;i<psDst->length;i++) |
---|
1921 | { |
---|
1922 | psDst->offset[i] = psSrc->offset[i]; |
---|
1923 | } |
---|
1924 | } |
---|
1925 | else |
---|
1926 | { |
---|
1927 | psDst->length = 0; |
---|
1928 | for (i=0;i<SAO_BO_LEN;i++) |
---|
1929 | { |
---|
1930 | psDst->offset[i] = 0; |
---|
1931 | } |
---|
1932 | } |
---|
1933 | } |
---|
1934 | |
---|
1935 | Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam, UInt compIdx) |
---|
1936 | { |
---|
1937 | UInt uiSymbol; |
---|
1938 | static Int iTypeLength[MAX_NUM_SAO_TYPE] = |
---|
1939 | { |
---|
1940 | SAO_EO_LEN, |
---|
1941 | SAO_EO_LEN, |
---|
1942 | SAO_EO_LEN, |
---|
1943 | SAO_EO_LEN, |
---|
1944 | SAO_BO_LEN |
---|
1945 | }; |
---|
1946 | |
---|
1947 | if (compIdx==2) |
---|
1948 | { |
---|
1949 | uiSymbol = (UInt)( psSaoLcuParam->typeIdx + 1); |
---|
1950 | } |
---|
1951 | else |
---|
1952 | { |
---|
1953 | parseSaoTypeIdx(uiSymbol); |
---|
1954 | } |
---|
1955 | psSaoLcuParam->typeIdx = (Int)uiSymbol - 1; |
---|
1956 | if (uiSymbol) |
---|
1957 | { |
---|
1958 | psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx]; |
---|
1959 | |
---|
1960 | Int bitDepth = compIdx ? g_bitDepthC : g_bitDepthY; |
---|
1961 | Int offsetTh = 1 << min(bitDepth - 5,5); |
---|
1962 | |
---|
1963 | if( psSaoLcuParam->typeIdx == SAO_BO ) |
---|
1964 | { |
---|
1965 | for(Int i=0; i< psSaoLcuParam->length; i++) |
---|
1966 | { |
---|
1967 | parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); |
---|
1968 | psSaoLcuParam->offset[i] = uiSymbol; |
---|
1969 | } |
---|
1970 | for(Int i=0; i< psSaoLcuParam->length; i++) |
---|
1971 | { |
---|
1972 | if (psSaoLcuParam->offset[i] != 0) |
---|
1973 | { |
---|
1974 | m_pcTDecBinIf->decodeBinEP ( uiSymbol); |
---|
1975 | if (uiSymbol) |
---|
1976 | { |
---|
1977 | psSaoLcuParam->offset[i] = -psSaoLcuParam->offset[i] ; |
---|
1978 | } |
---|
1979 | } |
---|
1980 | } |
---|
1981 | parseSaoUflc(5, uiSymbol ); |
---|
1982 | psSaoLcuParam->subTypeIdx = uiSymbol; |
---|
1983 | } |
---|
1984 | else if( psSaoLcuParam->typeIdx < 4 ) |
---|
1985 | { |
---|
1986 | parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[0] = uiSymbol; |
---|
1987 | parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[1] = uiSymbol; |
---|
1988 | parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[2] = -(Int)uiSymbol; |
---|
1989 | parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[3] = -(Int)uiSymbol; |
---|
1990 | if (compIdx != 2) |
---|
1991 | { |
---|
1992 | parseSaoUflc(2, uiSymbol ); |
---|
1993 | psSaoLcuParam->subTypeIdx = uiSymbol; |
---|
1994 | psSaoLcuParam->typeIdx += psSaoLcuParam->subTypeIdx; |
---|
1995 | } |
---|
1996 | } |
---|
1997 | } |
---|
1998 | else |
---|
1999 | { |
---|
2000 | psSaoLcuParam->length = 0; |
---|
2001 | } |
---|
2002 | } |
---|
2003 | |
---|
2004 | Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp) |
---|
2005 | { |
---|
2006 | Int iAddr = pcCU->getAddr(); |
---|
2007 | UInt uiSymbol; |
---|
2008 | for (Int iCompIdx=0; iCompIdx<3; iCompIdx++) |
---|
2009 | { |
---|
2010 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; |
---|
2011 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; |
---|
2012 | pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0; |
---|
2013 | pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; |
---|
2014 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0] = 0; |
---|
2015 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[1] = 0; |
---|
2016 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[2] = 0; |
---|
2017 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3] = 0; |
---|
2018 | |
---|
2019 | } |
---|
2020 | if (pSaoParam->bSaoFlag[0] || pSaoParam->bSaoFlag[1] ) |
---|
2021 | { |
---|
2022 | if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft) |
---|
2023 | { |
---|
2024 | parseSaoMerge(uiSymbol); |
---|
2025 | pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag = (Bool)uiSymbol; |
---|
2026 | } |
---|
2027 | if (pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag==0) |
---|
2028 | { |
---|
2029 | if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp) |
---|
2030 | { |
---|
2031 | parseSaoMerge(uiSymbol); |
---|
2032 | pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag = (Bool)uiSymbol; |
---|
2033 | } |
---|
2034 | } |
---|
2035 | } |
---|
2036 | |
---|
2037 | for (Int iCompIdx=0; iCompIdx<3; iCompIdx++) |
---|
2038 | { |
---|
2039 | if ((iCompIdx == 0 && pSaoParam->bSaoFlag[0]) || (iCompIdx > 0 && pSaoParam->bSaoFlag[1]) ) |
---|
2040 | { |
---|
2041 | if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft) |
---|
2042 | { |
---|
2043 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag; |
---|
2044 | } |
---|
2045 | else |
---|
2046 | { |
---|
2047 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; |
---|
2048 | } |
---|
2049 | |
---|
2050 | if (pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag==0) |
---|
2051 | { |
---|
2052 | if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp) |
---|
2053 | { |
---|
2054 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag; |
---|
2055 | } |
---|
2056 | else |
---|
2057 | { |
---|
2058 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; |
---|
2059 | } |
---|
2060 | if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag) |
---|
2061 | { |
---|
2062 | pSaoParam->saoLcuParam[2][iAddr].typeIdx = pSaoParam->saoLcuParam[1][iAddr].typeIdx; |
---|
2063 | parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr]), iCompIdx); |
---|
2064 | } |
---|
2065 | else |
---|
2066 | { |
---|
2067 | copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-pSaoParam->numCuInWidth]); |
---|
2068 | } |
---|
2069 | } |
---|
2070 | else |
---|
2071 | { |
---|
2072 | copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-1]); |
---|
2073 | } |
---|
2074 | } |
---|
2075 | else |
---|
2076 | { |
---|
2077 | pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; |
---|
2078 | pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0; |
---|
2079 | } |
---|
2080 | } |
---|
2081 | } |
---|
2082 | |
---|
2083 | /** |
---|
2084 | - Initialize our contexts from the nominated source. |
---|
2085 | . |
---|
2086 | \param pSrc Contexts to be copied. |
---|
2087 | */ |
---|
2088 | Void TDecSbac::xCopyContextsFrom( TDecSbac* pSrc ) |
---|
2089 | { |
---|
2090 | memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0])); |
---|
2091 | } |
---|
2092 | |
---|
2093 | Void TDecSbac::xCopyFrom( TDecSbac* pSrc ) |
---|
2094 | { |
---|
2095 | m_pcTDecBinIf->copyState( pSrc->m_pcTDecBinIf ); |
---|
2096 | |
---|
2097 | m_uiLastQp = pSrc->m_uiLastQp; |
---|
2098 | xCopyContextsFrom( pSrc ); |
---|
2099 | |
---|
2100 | } |
---|
2101 | |
---|
2102 | Void TDecSbac::load ( TDecSbac* pScr ) |
---|
2103 | { |
---|
2104 | xCopyFrom(pScr); |
---|
2105 | } |
---|
2106 | |
---|
2107 | Void TDecSbac::loadContexts ( TDecSbac* pScr ) |
---|
2108 | { |
---|
2109 | xCopyContextsFrom(pScr); |
---|
2110 | } |
---|
2111 | |
---|
2112 | #if H_3D_ARP |
---|
2113 | Void TDecSbac::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2114 | { |
---|
2115 | UInt uiMaxW = pcCU->getSlice()->getARPStepNum() - 1; |
---|
2116 | UInt uiW = 0; |
---|
2117 | UInt uiOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx); |
---|
2118 | UInt uiCode = 0; |
---|
2119 | |
---|
2120 | assert ( uiMaxW > 0 ); |
---|
2121 | |
---|
2122 | m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 0 + uiOffset ) ); |
---|
2123 | |
---|
2124 | uiW = uiCode; |
---|
2125 | if( 1 == uiW ) |
---|
2126 | { |
---|
2127 | m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 3 ) ); |
---|
2128 | uiW += ( 1 == uiCode ? 1 : 0 ); |
---|
2129 | } |
---|
2130 | #if H_MV_ENC_DEC_TRAC |
---|
2131 | DTRACE_CU("iv_res_pred_weight_idx", uiW ) |
---|
2132 | #endif |
---|
2133 | pcCU->setARPWSubParts( ( UChar )( uiW ) , uiAbsPartIdx, uiDepth ); |
---|
2134 | } |
---|
2135 | #endif |
---|
2136 | |
---|
2137 | #if H_3D_IC |
---|
2138 | /** parse illumination compensation flag |
---|
2139 | * \param pcCU |
---|
2140 | * \param uiAbsPartIdx |
---|
2141 | * \param uiDepth |
---|
2142 | * \returns Void |
---|
2143 | */ |
---|
2144 | Void TDecSbac::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2145 | { |
---|
2146 | UInt uiSymbol = 0; |
---|
2147 | UInt uiCtxIC = pcCU->getCtxICFlag( uiAbsPartIdx ); |
---|
2148 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, uiCtxIC ) ); |
---|
2149 | #if !H_MV_ENC_DEC_TRAC |
---|
2150 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
2151 | DTRACE_CABAC_T( "\tICFlag" ); |
---|
2152 | DTRACE_CABAC_T( "\tuiCtxIC: "); |
---|
2153 | DTRACE_CABAC_V( uiCtxIC ); |
---|
2154 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
2155 | DTRACE_CABAC_V( uiSymbol ); |
---|
2156 | DTRACE_CABAC_T( "\n"); |
---|
2157 | #else |
---|
2158 | DTRACE_CU("ic_flag", uiSymbol) |
---|
2159 | #endif |
---|
2160 | |
---|
2161 | pcCU->setICFlagSubParts( uiSymbol ? true : false , uiAbsPartIdx, 0, uiDepth ); |
---|
2162 | } |
---|
2163 | #endif |
---|
2164 | |
---|
2165 | #if H_3D_INTER_SDC |
---|
2166 | Void TDecSbac::parseInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2167 | { |
---|
2168 | UInt uiSymbol = 0; |
---|
2169 | UInt uiCtxInterSDCFlag = pcCU->getCtxInterSDCFlag( uiAbsPartIdx ); |
---|
2170 | |
---|
2171 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cInterSDCFlagSCModel.get( 0, 0, uiCtxInterSDCFlag ) ); |
---|
2172 | |
---|
2173 | if( uiSymbol ) |
---|
2174 | { |
---|
2175 | pcCU->setInterSDCFlagSubParts( true, uiAbsPartIdx, 0, uiDepth ); |
---|
2176 | pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth ); |
---|
2177 | pcCU->setCbfSubParts( 1, 1, 1, uiAbsPartIdx, uiDepth ); |
---|
2178 | } |
---|
2179 | else |
---|
2180 | { |
---|
2181 | pcCU->setInterSDCFlagSubParts( false, uiAbsPartIdx, 0, uiDepth); |
---|
2182 | } |
---|
2183 | } |
---|
2184 | |
---|
2185 | Void TDecSbac::parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSegment ) |
---|
2186 | { |
---|
2187 | UInt uiAbsIdx = 0; |
---|
2188 | UInt uiSign = 0; |
---|
2189 | Int iIdx = 0; |
---|
2190 | |
---|
2191 | xReadExGolombLevel( uiAbsIdx, m_cInterSDCResidualSCModel.get( 0, 0, 0 ) ); |
---|
2192 | |
---|
2193 | uiAbsIdx++; |
---|
2194 | m_pcTDecBinIf->decodeBin( uiSign, m_cInterSDCResidualSignFlagSCModel.get( 0, 0, 0 ) ); |
---|
2195 | iIdx = (Int)( uiSign ? -1 : 1 ) * uiAbsIdx; |
---|
2196 | |
---|
2197 | pcCU->setInterSDCSegmentDCOffset( iIdx, uiSegment, uiAbsPartIdx ); |
---|
2198 | } |
---|
2199 | #endif |
---|
2200 | |
---|
2201 | //! \} |
---|