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-2014, 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 TEncSbac.cpp |
---|
35 | \brief SBAC encoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TEncTop.h" |
---|
39 | #include "TEncSbac.h" |
---|
40 | |
---|
41 | #include <map> |
---|
42 | #include <algorithm> |
---|
43 | |
---|
44 | //! \ingroup TLibEncoder |
---|
45 | //! \{ |
---|
46 | |
---|
47 | // ==================================================================================================================== |
---|
48 | // Constructor / destructor / create / destroy |
---|
49 | // ==================================================================================================================== |
---|
50 | |
---|
51 | TEncSbac::TEncSbac() |
---|
52 | // new structure here |
---|
53 | : m_pcBitIf ( NULL ) |
---|
54 | , m_pcSlice ( NULL ) |
---|
55 | , m_pcBinIf ( NULL ) |
---|
56 | , m_uiCoeffCost ( 0 ) |
---|
57 | , m_numContextModels ( 0 ) |
---|
58 | , m_cCUSplitFlagSCModel ( 1, 1, NUM_SPLIT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels ) |
---|
59 | , m_cCUSkipFlagSCModel ( 1, 1, NUM_SKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
60 | #if H_3D_SINGLE_DEPTH |
---|
61 | , m_cCUSingleDepthFlagSCModel ( 1, 1, NUM_SINGLEDEPTH_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
62 | , m_cSingleDepthValueSCModel ( 1, 1, NUM_SINGLE_DEPTH_VALUE_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
63 | #endif |
---|
64 | , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
65 | , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
66 | #if H_3D_ARP |
---|
67 | , m_cCUPUARPWSCModel ( 1, 1, NUM_ARPW_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
68 | #endif |
---|
69 | #if H_3D_IC |
---|
70 | , m_cCUICFlagSCModel ( 1, 1, NUM_IC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
71 | #endif |
---|
72 | , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
73 | , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
74 | , m_cCUIntraPredSCModel ( 1, 1, NUM_ADI_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
75 | , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
76 | , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
77 | , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
78 | , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
79 | , m_cCUMvdSCModel ( 1, 1, NUM_MV_RES_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
80 | , m_cCUQtCbfSCModel ( 1, 2, NUM_QT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
81 | , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
82 | , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
83 | , m_cCUSigCoeffGroupSCModel ( 1, 2, NUM_SIG_CG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
84 | , m_cCUSigSCModel ( 1, 1, NUM_SIG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
85 | , m_cCuCtxLastX ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
86 | , m_cCuCtxLastY ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
87 | , m_cCUOneSCModel ( 1, 1, NUM_ONE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
88 | , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
89 | , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
90 | , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
91 | , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
92 | , m_cTransformSkipSCModel ( 1, 2, NUM_TRANSFORMSKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
93 | , m_CUTransquantBypassFlagSCModel( 1, 1, NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels) |
---|
94 | #if H_3D_DIM |
---|
95 | , m_cDepthIntraModeSCModel ( 1, 1, NUM_DEPTH_INTRA_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
96 | , m_cDdcFlagSCModel ( 1, 1, NUM_DDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
97 | , m_cDdcDataSCModel ( 1, 1, NUM_DDC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
98 | , m_cAngleFlagSCModel ( 1, 1, NUM_ANGLE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
99 | #if H_3D_DIM_SDC |
---|
100 | , m_cSDCResidualFlagSCModel ( 1, 1, SDC_NUM_RESIDUAL_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
101 | , m_cSDCResidualSCModel ( 1, 1, SDC_NUM_RESIDUAL_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
102 | #endif |
---|
103 | #endif |
---|
104 | #if H_3D_DIM_SDC |
---|
105 | , m_cSDCFlagSCModel ( 1, 1, NUM_SDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
106 | #endif |
---|
107 | #if H_3D_DBBP |
---|
108 | , m_cDBBPFlagSCModel ( 1, 1, DBBP_NUM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
109 | #endif |
---|
110 | { |
---|
111 | assert( m_numContextModels <= MAX_NUM_CTX_MOD ); |
---|
112 | } |
---|
113 | |
---|
114 | TEncSbac::~TEncSbac() |
---|
115 | { |
---|
116 | } |
---|
117 | |
---|
118 | // ==================================================================================================================== |
---|
119 | // Public member functions |
---|
120 | // ==================================================================================================================== |
---|
121 | |
---|
122 | Void TEncSbac::resetEntropy () |
---|
123 | { |
---|
124 | Int iQp = m_pcSlice->getSliceQp(); |
---|
125 | SliceType eSliceType = m_pcSlice->getSliceType(); |
---|
126 | |
---|
127 | Int encCABACTableIdx = m_pcSlice->getPPS()->getEncCABACTableIdx(); |
---|
128 | if (!m_pcSlice->isIntra() && (encCABACTableIdx==B_SLICE || encCABACTableIdx==P_SLICE) && m_pcSlice->getPPS()->getCabacInitPresentFlag()) |
---|
129 | { |
---|
130 | eSliceType = (SliceType) encCABACTableIdx; |
---|
131 | } |
---|
132 | |
---|
133 | m_cCUSplitFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG ); |
---|
134 | |
---|
135 | m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG ); |
---|
136 | #if H_3D_SINGLE_DEPTH |
---|
137 | m_cCUSingleDepthFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SINGLEDEPTH_FLAG ); |
---|
138 | m_cSingleDepthValueSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SINGLE_DEPTH_VALUE_DATA ); |
---|
139 | #endif |
---|
140 | m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT); |
---|
141 | m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT); |
---|
142 | #if H_3D_ARP |
---|
143 | m_cCUPUARPWSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ARPW ); |
---|
144 | #endif |
---|
145 | #if H_3D_IC |
---|
146 | m_cCUICFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_IC_FLAG ); |
---|
147 | #endif |
---|
148 | m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); |
---|
149 | m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); |
---|
150 | m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
151 | m_cCUChromaPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
152 | m_cCUInterDirSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_DIR ); |
---|
153 | m_cCUMvdSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVD ); |
---|
154 | m_cCURefPicSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_REF_PIC ); |
---|
155 | m_cCUDeltaQpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DQP ); |
---|
156 | m_cCUQtCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_CBF ); |
---|
157 | m_cCUQtRootCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
158 | m_cCUSigCoeffGroupSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
159 | m_cCUSigSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_FLAG ); |
---|
160 | m_cCuCtxLastX.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
161 | m_cCuCtxLastY.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
162 | m_cCUOneSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ONE_FLAG ); |
---|
163 | m_cCUAbsSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG ); |
---|
164 | m_cMVPIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVP_IDX ); |
---|
165 | m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
166 | m_cSaoMergeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG ); |
---|
167 | m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
168 | m_cTransformSkipSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); |
---|
169 | m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); |
---|
170 | |
---|
171 | #if H_3D_DIM |
---|
172 | m_cDepthIntraModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE ); |
---|
173 | m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG ); |
---|
174 | m_cDdcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_DATA ); |
---|
175 | m_cAngleFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG ); |
---|
176 | #if H_3D_DIM_SDC |
---|
177 | m_cSDCResidualFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); |
---|
178 | m_cSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL ); |
---|
179 | #endif |
---|
180 | #endif |
---|
181 | #if H_3D_DIM_SDC |
---|
182 | m_cSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG ); |
---|
183 | #endif |
---|
184 | #if H_3D_DBBP |
---|
185 | m_cDBBPFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG ); |
---|
186 | #endif |
---|
187 | // new structure |
---|
188 | m_uiLastQp = iQp; |
---|
189 | |
---|
190 | m_pcBinIf->start(); |
---|
191 | |
---|
192 | return; |
---|
193 | } |
---|
194 | |
---|
195 | /** The function does the following: |
---|
196 | * If current slice type is P/B then it determines the distance of initialisation type 1 and 2 from the current CABAC states and |
---|
197 | * stores the index of the closest table. This index is used for the next P/B slice when cabac_init_present_flag is true. |
---|
198 | */ |
---|
199 | Void TEncSbac::determineCabacInitIdx() |
---|
200 | { |
---|
201 | Int qp = m_pcSlice->getSliceQp(); |
---|
202 | |
---|
203 | if (!m_pcSlice->isIntra()) |
---|
204 | { |
---|
205 | SliceType aSliceTypeChoices[] = {B_SLICE, P_SLICE}; |
---|
206 | |
---|
207 | UInt bestCost = MAX_UINT; |
---|
208 | SliceType bestSliceType = aSliceTypeChoices[0]; |
---|
209 | for (UInt idx=0; idx<2; idx++) |
---|
210 | { |
---|
211 | UInt curCost = 0; |
---|
212 | SliceType curSliceType = aSliceTypeChoices[idx]; |
---|
213 | |
---|
214 | curCost = m_cCUSplitFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SPLIT_FLAG ); |
---|
215 | curCost += m_cCUSkipFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SKIP_FLAG ); |
---|
216 | #if H_3D_SINGLE_DEPTH |
---|
217 | curCost += m_cCUSingleDepthFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SINGLEDEPTH_FLAG ); |
---|
218 | curCost += m_cSingleDepthValueSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SINGLE_DEPTH_VALUE_DATA ); |
---|
219 | #endif |
---|
220 | curCost += m_cCUMergeFlagExtSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT); |
---|
221 | curCost += m_cCUMergeIdxExtSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT); |
---|
222 | #if H_3D_ARP |
---|
223 | curCost += m_cCUPUARPWSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_ARPW ); |
---|
224 | #endif |
---|
225 | #if H_3D_IC |
---|
226 | curCost += m_cCUICFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_IC_FLAG ); |
---|
227 | #endif |
---|
228 | #if H_3D_DIM_SDC |
---|
229 | curCost += m_cSDCFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SDC_FLAG ); |
---|
230 | #endif |
---|
231 | #if H_3D_DBBP |
---|
232 | curCost += m_cDBBPFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DBBP_FLAG ); |
---|
233 | #endif |
---|
234 | curCost += m_cCUPartSizeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_PART_SIZE ); |
---|
235 | curCost += m_cCUPredModeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_PRED_MODE ); |
---|
236 | curCost += m_cCUIntraPredSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
237 | curCost += m_cCUChromaPredSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
238 | curCost += m_cCUInterDirSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_INTER_DIR ); |
---|
239 | curCost += m_cCUMvdSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_MVD ); |
---|
240 | curCost += m_cCURefPicSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_REF_PIC ); |
---|
241 | curCost += m_cCUDeltaQpSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DQP ); |
---|
242 | curCost += m_cCUQtCbfSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_QT_CBF ); |
---|
243 | curCost += m_cCUQtRootCbfSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
244 | curCost += m_cCUSigCoeffGroupSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
245 | curCost += m_cCUSigSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SIG_FLAG ); |
---|
246 | curCost += m_cCuCtxLastX.calcCost ( curSliceType, qp, (UChar*)INIT_LAST ); |
---|
247 | curCost += m_cCuCtxLastY.calcCost ( curSliceType, qp, (UChar*)INIT_LAST ); |
---|
248 | curCost += m_cCUOneSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_ONE_FLAG ); |
---|
249 | curCost += m_cCUAbsSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_ABS_FLAG ); |
---|
250 | curCost += m_cMVPIdxSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_MVP_IDX ); |
---|
251 | curCost += m_cCUTransSubdivFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
252 | curCost += m_cSaoMergeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG ); |
---|
253 | curCost += m_cSaoTypeIdxSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
254 | curCost += m_cTransformSkipSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); |
---|
255 | curCost += m_CUTransquantBypassFlagSCModel.calcCost( curSliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); |
---|
256 | #if H_3D_DIM |
---|
257 | if( m_pcSlice->getIntraSdcWedgeFlag() || m_pcSlice->getIntraContourFlag() ) |
---|
258 | { |
---|
259 | curCost += m_cDepthIntraModeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE ); |
---|
260 | curCost += m_cDdcFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DDC_FLAG ); |
---|
261 | curCost += m_cDdcDataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DDC_DATA ); |
---|
262 | curCost += m_cAngleFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_ANGLE_FLAG ); |
---|
263 | } |
---|
264 | #endif |
---|
265 | if (curCost < bestCost) |
---|
266 | { |
---|
267 | bestSliceType = curSliceType; |
---|
268 | bestCost = curCost; |
---|
269 | } |
---|
270 | } |
---|
271 | m_pcSlice->getPPS()->setEncCABACTableIdx( bestSliceType ); |
---|
272 | } |
---|
273 | else |
---|
274 | { |
---|
275 | m_pcSlice->getPPS()->setEncCABACTableIdx( I_SLICE ); |
---|
276 | } |
---|
277 | } |
---|
278 | |
---|
279 | |
---|
280 | /** The function does the followng: Write out terminate bit. Flush CABAC. Intialize CABAC states. Start CABAC. |
---|
281 | */ |
---|
282 | Void TEncSbac::updateContextTables( SliceType eSliceType, Int iQp, Bool bExecuteFinish ) |
---|
283 | { |
---|
284 | m_pcBinIf->encodeBinTrm(1); |
---|
285 | if (bExecuteFinish) m_pcBinIf->finish(); |
---|
286 | m_cCUSplitFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG ); |
---|
287 | |
---|
288 | m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG ); |
---|
289 | #if H_3D_SINGLE_DEPTH |
---|
290 | m_cCUSingleDepthFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SINGLEDEPTH_FLAG ); |
---|
291 | m_cSingleDepthValueSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SINGLE_DEPTH_VALUE_DATA ); |
---|
292 | #endif |
---|
293 | m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT); |
---|
294 | m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT); |
---|
295 | #if H_3D_ARP |
---|
296 | m_cCUPUARPWSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ARPW ); |
---|
297 | #endif |
---|
298 | #if H_3D_IC |
---|
299 | m_cCUICFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_IC_FLAG ); |
---|
300 | #endif |
---|
301 | m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); |
---|
302 | m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); |
---|
303 | m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
304 | m_cCUChromaPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
305 | m_cCUInterDirSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_DIR ); |
---|
306 | m_cCUMvdSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVD ); |
---|
307 | m_cCURefPicSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_REF_PIC ); |
---|
308 | m_cCUDeltaQpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DQP ); |
---|
309 | m_cCUQtCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_CBF ); |
---|
310 | m_cCUQtRootCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
311 | m_cCUSigCoeffGroupSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
312 | m_cCUSigSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_FLAG ); |
---|
313 | m_cCuCtxLastX.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
314 | m_cCuCtxLastY.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
315 | m_cCUOneSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ONE_FLAG ); |
---|
316 | m_cCUAbsSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG ); |
---|
317 | m_cMVPIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVP_IDX ); |
---|
318 | m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
319 | m_cSaoMergeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG ); |
---|
320 | m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
321 | m_cTransformSkipSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); |
---|
322 | m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); |
---|
323 | #if H_3D_DIM |
---|
324 | m_cDepthIntraModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE ); |
---|
325 | m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG ); |
---|
326 | m_cDdcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_DATA ); |
---|
327 | m_cAngleFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG ); |
---|
328 | #if H_3D_DIM_SDC |
---|
329 | m_cSDCResidualFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); |
---|
330 | m_cSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL ); |
---|
331 | #endif |
---|
332 | #endif |
---|
333 | #if H_3D_DIM_SDC |
---|
334 | m_cSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG ); |
---|
335 | #endif |
---|
336 | #if H_3D_DBBP |
---|
337 | m_cDBBPFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG ); |
---|
338 | #endif |
---|
339 | m_pcBinIf->start(); |
---|
340 | } |
---|
341 | |
---|
342 | Void TEncSbac::codeVPS( TComVPS* pcVPS ) |
---|
343 | { |
---|
344 | assert (0); |
---|
345 | return; |
---|
346 | } |
---|
347 | |
---|
348 | Void TEncSbac::codeSPS( TComSPS* pcSPS ) |
---|
349 | { |
---|
350 | assert (0); |
---|
351 | return; |
---|
352 | } |
---|
353 | |
---|
354 | Void TEncSbac::codePPS( TComPPS* pcPPS ) |
---|
355 | { |
---|
356 | assert (0); |
---|
357 | return; |
---|
358 | } |
---|
359 | |
---|
360 | Void TEncSbac::codeSliceHeader( TComSlice* pcSlice ) |
---|
361 | { |
---|
362 | assert (0); |
---|
363 | return; |
---|
364 | } |
---|
365 | |
---|
366 | Void TEncSbac::codeTilesWPPEntryPoint( TComSlice* pSlice ) |
---|
367 | { |
---|
368 | assert (0); |
---|
369 | return; |
---|
370 | } |
---|
371 | |
---|
372 | Void TEncSbac::codeTerminatingBit( UInt uilsLast ) |
---|
373 | { |
---|
374 | m_pcBinIf->encodeBinTrm( uilsLast ); |
---|
375 | } |
---|
376 | |
---|
377 | Void TEncSbac::codeSliceFinish() |
---|
378 | { |
---|
379 | m_pcBinIf->finish(); |
---|
380 | } |
---|
381 | |
---|
382 | Void TEncSbac::xWriteUnarySymbol( UInt uiSymbol, ContextModel* pcSCModel, Int iOffset ) |
---|
383 | { |
---|
384 | m_pcBinIf->encodeBin( uiSymbol ? 1 : 0, pcSCModel[0] ); |
---|
385 | |
---|
386 | if( 0 == uiSymbol) |
---|
387 | { |
---|
388 | return; |
---|
389 | } |
---|
390 | |
---|
391 | while( uiSymbol-- ) |
---|
392 | { |
---|
393 | m_pcBinIf->encodeBin( uiSymbol ? 1 : 0, pcSCModel[ iOffset ] ); |
---|
394 | } |
---|
395 | |
---|
396 | return; |
---|
397 | } |
---|
398 | |
---|
399 | Void TEncSbac::xWriteUnaryMaxSymbol( UInt uiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ) |
---|
400 | { |
---|
401 | if (uiMaxSymbol == 0) |
---|
402 | { |
---|
403 | return; |
---|
404 | } |
---|
405 | |
---|
406 | m_pcBinIf->encodeBin( uiSymbol ? 1 : 0, pcSCModel[ 0 ] ); |
---|
407 | |
---|
408 | if ( uiSymbol == 0 ) |
---|
409 | { |
---|
410 | return; |
---|
411 | } |
---|
412 | |
---|
413 | Bool bCodeLast = ( uiMaxSymbol > uiSymbol ); |
---|
414 | |
---|
415 | while( --uiSymbol ) |
---|
416 | { |
---|
417 | m_pcBinIf->encodeBin( 1, pcSCModel[ iOffset ] ); |
---|
418 | } |
---|
419 | if( bCodeLast ) |
---|
420 | { |
---|
421 | m_pcBinIf->encodeBin( 0, pcSCModel[ iOffset ] ); |
---|
422 | } |
---|
423 | |
---|
424 | return; |
---|
425 | } |
---|
426 | |
---|
427 | Void TEncSbac::xWriteEpExGolomb( UInt uiSymbol, UInt uiCount ) |
---|
428 | { |
---|
429 | UInt bins = 0; |
---|
430 | Int numBins = 0; |
---|
431 | |
---|
432 | while( uiSymbol >= (UInt)(1<<uiCount) ) |
---|
433 | { |
---|
434 | bins = 2 * bins + 1; |
---|
435 | numBins++; |
---|
436 | uiSymbol -= 1 << uiCount; |
---|
437 | uiCount ++; |
---|
438 | } |
---|
439 | bins = 2 * bins + 0; |
---|
440 | numBins++; |
---|
441 | |
---|
442 | bins = (bins << uiCount) | uiSymbol; |
---|
443 | numBins += uiCount; |
---|
444 | |
---|
445 | assert( numBins <= 32 ); |
---|
446 | m_pcBinIf->encodeBinsEP( bins, numBins ); |
---|
447 | } |
---|
448 | #if H_3D_SINGLE_DEPTH |
---|
449 | Void TEncSbac::codeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
450 | { |
---|
451 | UInt uiSymbol = pcCU->getSingleDepthFlag(uiAbsPartIdx ) ? 1 : 0; |
---|
452 | m_pcBinIf->encodeBin( uiSymbol, m_cCUSingleDepthFlagSCModel.get( 0, 0, 0 ) ); |
---|
453 | if(uiSymbol) |
---|
454 | { |
---|
455 | UInt uiUnaryIdx = (UInt) pcCU->getSingleDepthValue(uiAbsPartIdx); |
---|
456 | UInt uiNumCand = SINGLE_DEPTH_MODE_CAND_LIST_SIZE; |
---|
457 | if ( uiNumCand > 1 ) |
---|
458 | { |
---|
459 | for( UInt ui = 0; ui < uiNumCand - 1; ++ui ) |
---|
460 | { |
---|
461 | const UInt uiSymbol2 = ui == uiUnaryIdx ? 0 : 1; |
---|
462 | if ( ui==0 ) |
---|
463 | { |
---|
464 | m_pcBinIf->encodeBin( uiSymbol2, m_cSingleDepthValueSCModel.get( 0, 0, 0 ) ); |
---|
465 | } |
---|
466 | else |
---|
467 | { |
---|
468 | m_pcBinIf->encodeBinEP( uiSymbol2 ); |
---|
469 | } |
---|
470 | if( uiSymbol2 == 0 ) |
---|
471 | { |
---|
472 | break; |
---|
473 | } |
---|
474 | } |
---|
475 | } |
---|
476 | } |
---|
477 | } |
---|
478 | #endif |
---|
479 | /** Coding of coeff_abs_level_minus3 |
---|
480 | * \param uiSymbol value of coeff_abs_level_minus3 |
---|
481 | * \param ruiGoRiceParam reference to Rice parameter |
---|
482 | * \returns Void |
---|
483 | */ |
---|
484 | Void TEncSbac::xWriteCoefRemainExGolomb ( UInt symbol, UInt &rParam ) |
---|
485 | { |
---|
486 | Int codeNumber = (Int)symbol; |
---|
487 | UInt length; |
---|
488 | if (codeNumber < (COEF_REMAIN_BIN_REDUCTION << rParam)) |
---|
489 | { |
---|
490 | length = codeNumber>>rParam; |
---|
491 | m_pcBinIf->encodeBinsEP( (1<<(length+1))-2 , length+1); |
---|
492 | m_pcBinIf->encodeBinsEP((codeNumber%(1<<rParam)),rParam); |
---|
493 | } |
---|
494 | else |
---|
495 | { |
---|
496 | length = rParam; |
---|
497 | codeNumber = codeNumber - ( COEF_REMAIN_BIN_REDUCTION << rParam); |
---|
498 | while (codeNumber >= (1<<length)) |
---|
499 | { |
---|
500 | codeNumber -= (1<<(length++)); |
---|
501 | } |
---|
502 | m_pcBinIf->encodeBinsEP((1<<(COEF_REMAIN_BIN_REDUCTION+length+1-rParam))-2,COEF_REMAIN_BIN_REDUCTION+length+1-rParam); |
---|
503 | m_pcBinIf->encodeBinsEP(codeNumber,length); |
---|
504 | } |
---|
505 | } |
---|
506 | |
---|
507 | #if H_3D_DIM |
---|
508 | Void TEncSbac::xWriteExGolombLevel( UInt uiSymbol, ContextModel& rcSCModel ) |
---|
509 | { |
---|
510 | if( uiSymbol ) |
---|
511 | { |
---|
512 | m_pcBinIf->encodeBin( 1, rcSCModel ); |
---|
513 | UInt uiCount = 0; |
---|
514 | Bool bNoExGo = ( uiSymbol < 3 ); |
---|
515 | |
---|
516 | while( --uiSymbol && ++uiCount < 3 ) |
---|
517 | { |
---|
518 | m_pcBinIf->encodeBin( 1, rcSCModel ); |
---|
519 | } |
---|
520 | if( bNoExGo ) |
---|
521 | { |
---|
522 | m_pcBinIf->encodeBin( 0, rcSCModel ); |
---|
523 | } |
---|
524 | else |
---|
525 | { |
---|
526 | xWriteEpExGolomb( uiSymbol, 0 ); |
---|
527 | } |
---|
528 | } |
---|
529 | else |
---|
530 | { |
---|
531 | m_pcBinIf->encodeBin( 0, rcSCModel ); |
---|
532 | } |
---|
533 | |
---|
534 | return; |
---|
535 | } |
---|
536 | |
---|
537 | Void TEncSbac::xCodeDimDeltaDC( Pel valDeltaDC, UInt uiNumSeg ) |
---|
538 | { |
---|
539 | xWriteExGolombLevel( UInt( abs( valDeltaDC ) - ( uiNumSeg > 1 ? 0 : 1 ) ), m_cDdcDataSCModel.get(0, 0, 0) ); |
---|
540 | if( valDeltaDC != 0 ) |
---|
541 | { |
---|
542 | UInt uiSign = valDeltaDC > 0 ? 0 : 1; |
---|
543 | m_pcBinIf->encodeBinEP( uiSign ); |
---|
544 | } |
---|
545 | } |
---|
546 | |
---|
547 | #if H_3D_DIM_DMM |
---|
548 | Void TEncSbac::xCodeDmm1WedgeIdx( UInt uiTabIdx, Int iNumBit ) |
---|
549 | { |
---|
550 | for ( Int i = 0; i < iNumBit; i++ ) |
---|
551 | { |
---|
552 | m_pcBinIf->encodeBinEP( ( uiTabIdx >> i ) & 1 ); |
---|
553 | } |
---|
554 | } |
---|
555 | |
---|
556 | #endif |
---|
557 | #endif |
---|
558 | |
---|
559 | |
---|
560 | // SBAC RD |
---|
561 | Void TEncSbac::load ( TEncSbac* pSrc) |
---|
562 | { |
---|
563 | this->xCopyFrom(pSrc); |
---|
564 | } |
---|
565 | |
---|
566 | Void TEncSbac::loadIntraDirModeLuma( TEncSbac* pSrc) |
---|
567 | { |
---|
568 | m_pcBinIf->copyState( pSrc->m_pcBinIf ); |
---|
569 | |
---|
570 | this->m_cCUIntraPredSCModel .copyFrom( &pSrc->m_cCUIntraPredSCModel ); |
---|
571 | } |
---|
572 | #if H_3D_DIM |
---|
573 | Void TEncSbac::loadIntraDepthMode( TEncSbac* pSrc) |
---|
574 | { |
---|
575 | m_pcBinIf->copyState( pSrc->m_pcBinIf ); |
---|
576 | |
---|
577 | this->m_cDepthIntraModeSCModel .copyFrom( &pSrc->m_cDepthIntraModeSCModel ); |
---|
578 | this->m_cDdcFlagSCModel .copyFrom( &pSrc->m_cDdcFlagSCModel ); |
---|
579 | this->m_cAngleFlagSCModel .copyFrom( &pSrc->m_cAngleFlagSCModel ); |
---|
580 | } |
---|
581 | #endif |
---|
582 | |
---|
583 | Void TEncSbac::store( TEncSbac* pDest) |
---|
584 | { |
---|
585 | pDest->xCopyFrom( this ); |
---|
586 | } |
---|
587 | |
---|
588 | |
---|
589 | Void TEncSbac::xCopyFrom( TEncSbac* pSrc ) |
---|
590 | { |
---|
591 | m_pcBinIf->copyState( pSrc->m_pcBinIf ); |
---|
592 | |
---|
593 | this->m_uiCoeffCost = pSrc->m_uiCoeffCost; |
---|
594 | this->m_uiLastQp = pSrc->m_uiLastQp; |
---|
595 | |
---|
596 | memcpy( m_contextModels, pSrc->m_contextModels, m_numContextModels * sizeof( ContextModel ) ); |
---|
597 | } |
---|
598 | |
---|
599 | Void TEncSbac::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
600 | { |
---|
601 | Int iSymbol = pcCU->getMVPIdx(eRefList, uiAbsPartIdx); |
---|
602 | Int iNum = AMVP_MAX_NUM_CANDS; |
---|
603 | |
---|
604 | xWriteUnaryMaxSymbol(iSymbol, m_cMVPIdxSCModel.get(0), 1, iNum-1); |
---|
605 | #if H_MV_ENC_DEC_TRAC |
---|
606 | #if ENC_DEC_TRACE |
---|
607 | if ( eRefList == REF_PIC_LIST_0 ) |
---|
608 | { |
---|
609 | DTRACE_PU("mvp_l0_flag", iSymbol) |
---|
610 | } |
---|
611 | else |
---|
612 | { |
---|
613 | DTRACE_PU("mvp_l1_flag", iSymbol) |
---|
614 | } |
---|
615 | #endif |
---|
616 | #endif |
---|
617 | } |
---|
618 | |
---|
619 | Void TEncSbac::codePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
620 | { |
---|
621 | PartSize eSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
622 | #if H_3D_QTLPC |
---|
623 | Bool bLimQtPredFlag = pcCU->getPic()->getSlice(0)->getQtPredFlag(); |
---|
624 | TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); |
---|
625 | Bool bDepthMapDetect = (pcTexture != NULL); |
---|
626 | Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); |
---|
627 | |
---|
628 | 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); |
---|
629 | |
---|
630 | Bool depthDependent = false; |
---|
631 | UInt uiTexturePart = eSize; |
---|
632 | |
---|
633 | #if H_3D_FCO |
---|
634 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && bLimQtPredFlag && pcTexture->getReconMark()) |
---|
635 | #else |
---|
636 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && bLimQtPredFlag ) |
---|
637 | #endif |
---|
638 | { |
---|
639 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
640 | UInt uiCUIdx = (pcCU->getZorderIdxInCU() == 0) ? uiAbsPartIdx : pcCU->getZorderIdxInCU(); |
---|
641 | assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth); |
---|
642 | if(pcTextureCU->getDepth(uiCUIdx) == uiDepth ) |
---|
643 | { |
---|
644 | depthDependent = true; |
---|
645 | uiTexturePart = pcTextureCU->getPartitionSize( uiCUIdx ); |
---|
646 | } |
---|
647 | if (pcTextureCU->getDepth(uiCUIdx) == uiDepth && pcTextureCU->getPartitionSize( uiCUIdx ) == SIZE_2Nx2N) |
---|
648 | { |
---|
649 | assert( eSize == SIZE_2Nx2N ); |
---|
650 | return; |
---|
651 | } |
---|
652 | } |
---|
653 | #endif |
---|
654 | if ( pcCU->isIntra( uiAbsPartIdx ) ) |
---|
655 | { |
---|
656 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
657 | { |
---|
658 | m_pcBinIf->encodeBin( eSize == SIZE_2Nx2N? 1 : 0, m_cCUPartSizeSCModel.get( 0, 0, 0 ) ); |
---|
659 | #if H_MV_ENC_DEC_TRAC |
---|
660 | DTRACE_CU("part_mode", eSize == SIZE_2Nx2N? 1 : 0) |
---|
661 | #endif |
---|
662 | } |
---|
663 | return; |
---|
664 | } |
---|
665 | |
---|
666 | #if H_MV_ENC_DEC_TRAC |
---|
667 | DTRACE_CU("part_mode", eSize ) |
---|
668 | #endif |
---|
669 | #if H_3D_QTLPC |
---|
670 | if (depthDependent==false || uiTexturePart == SIZE_NxN|| uiTexturePart == SIZE_2Nx2N) |
---|
671 | { |
---|
672 | #endif |
---|
673 | switch(eSize) |
---|
674 | { |
---|
675 | case SIZE_2Nx2N: |
---|
676 | { |
---|
677 | m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
678 | break; |
---|
679 | } |
---|
680 | case SIZE_2NxN: |
---|
681 | case SIZE_2NxnU: |
---|
682 | case SIZE_2NxnD: |
---|
683 | { |
---|
684 | m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
685 | m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 1) ); |
---|
686 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
687 | { |
---|
688 | if (eSize == SIZE_2NxN) |
---|
689 | { |
---|
690 | m_pcBinIf->encodeBin(1, m_cCUPartSizeSCModel.get( 0, 0, 3 )); |
---|
691 | } |
---|
692 | else |
---|
693 | { |
---|
694 | m_pcBinIf->encodeBin(0, m_cCUPartSizeSCModel.get( 0, 0, 3 )); |
---|
695 | m_pcBinIf->encodeBinEP((eSize == SIZE_2NxnU? 0: 1)); |
---|
696 | } |
---|
697 | } |
---|
698 | break; |
---|
699 | } |
---|
700 | case SIZE_Nx2N: |
---|
701 | case SIZE_nLx2N: |
---|
702 | case SIZE_nRx2N: |
---|
703 | { |
---|
704 | m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
705 | m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) ); |
---|
706 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getWidth(uiAbsPartIdx) == 8 && pcCU->getHeight(uiAbsPartIdx) == 8 ) ) |
---|
707 | { |
---|
708 | m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 2) ); |
---|
709 | } |
---|
710 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
711 | { |
---|
712 | if (eSize == SIZE_Nx2N) |
---|
713 | { |
---|
714 | m_pcBinIf->encodeBin(1, m_cCUPartSizeSCModel.get( 0, 0, 3 )); |
---|
715 | } |
---|
716 | else |
---|
717 | { |
---|
718 | m_pcBinIf->encodeBin(0, m_cCUPartSizeSCModel.get( 0, 0, 3 )); |
---|
719 | m_pcBinIf->encodeBinEP((eSize == SIZE_nLx2N? 0: 1)); |
---|
720 | } |
---|
721 | } |
---|
722 | break; |
---|
723 | } |
---|
724 | case SIZE_NxN: |
---|
725 | { |
---|
726 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getWidth(uiAbsPartIdx) == 8 && pcCU->getHeight(uiAbsPartIdx) == 8 ) ) |
---|
727 | { |
---|
728 | m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
729 | m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) ); |
---|
730 | m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 2) ); |
---|
731 | } |
---|
732 | break; |
---|
733 | } |
---|
734 | default: |
---|
735 | { |
---|
736 | assert(0); |
---|
737 | } |
---|
738 | } |
---|
739 | #if H_3D_QTLPC |
---|
740 | } |
---|
741 | else if(uiTexturePart == SIZE_2NxN || uiTexturePart == SIZE_2NxnU || uiTexturePart == SIZE_2NxnD) |
---|
742 | { |
---|
743 | //assert(eSize!=SIZE_NxN); |
---|
744 | //assert(eSize!=SIZE_Nx2N); |
---|
745 | //assert(eSize==SIZE_2Nx2N || eSize==SIZE_2NxN || eSize==SIZE_2NxnU || eSize==SIZE_2NxnD); |
---|
746 | switch(eSize) |
---|
747 | { |
---|
748 | case SIZE_2Nx2N: |
---|
749 | { |
---|
750 | m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
751 | break; |
---|
752 | } |
---|
753 | case SIZE_2NxN: |
---|
754 | { |
---|
755 | m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
756 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
757 | { |
---|
758 | m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 1) ); |
---|
759 | } |
---|
760 | break; |
---|
761 | } |
---|
762 | case SIZE_2NxnU: |
---|
763 | case SIZE_2NxnD: |
---|
764 | { |
---|
765 | m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
766 | m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) ); |
---|
767 | m_pcBinIf->encodeBinEP((eSize == SIZE_2NxnU? 0: 1)); |
---|
768 | break; |
---|
769 | } |
---|
770 | default: |
---|
771 | { |
---|
772 | assert(0); |
---|
773 | } |
---|
774 | } |
---|
775 | } |
---|
776 | else if(uiTexturePart == SIZE_Nx2N|| uiTexturePart==SIZE_nLx2N || uiTexturePart==SIZE_nRx2N) |
---|
777 | { |
---|
778 | //assert(eSize!=SIZE_NxN); |
---|
779 | //assert(eSize!=SIZE_2NxN); |
---|
780 | //assert(eSize==SIZE_2Nx2N ||eSize==SIZE_Nx2N || eSize==SIZE_nLx2N || eSize==SIZE_nRx2N); |
---|
781 | switch(eSize) |
---|
782 | { |
---|
783 | case SIZE_2Nx2N: |
---|
784 | { |
---|
785 | m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
786 | break; |
---|
787 | } |
---|
788 | case SIZE_Nx2N: |
---|
789 | { |
---|
790 | m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
791 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
792 | { |
---|
793 | m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 1) ); |
---|
794 | } |
---|
795 | break; |
---|
796 | } |
---|
797 | case SIZE_nLx2N: |
---|
798 | case SIZE_nRx2N: |
---|
799 | { |
---|
800 | m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
801 | m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) ); |
---|
802 | m_pcBinIf->encodeBinEP((eSize == SIZE_nLx2N? 0: 1)); |
---|
803 | break; |
---|
804 | } |
---|
805 | default: |
---|
806 | { |
---|
807 | assert(0); |
---|
808 | } |
---|
809 | } |
---|
810 | } |
---|
811 | else |
---|
812 | { |
---|
813 | printf("uiTexturePart=%d",uiTexturePart); |
---|
814 | assert(0); |
---|
815 | } |
---|
816 | #endif |
---|
817 | } |
---|
818 | |
---|
819 | /** code prediction mode |
---|
820 | * \param pcCU |
---|
821 | * \param uiAbsPartIdx |
---|
822 | * \returns Void |
---|
823 | */ |
---|
824 | Void TEncSbac::codePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
825 | { |
---|
826 | #if H_3D_DIM_SDC |
---|
827 | if ( pcCU->getSlice()->isIntra() ) |
---|
828 | { |
---|
829 | assert( pcCU->isIntra(uiAbsPartIdx) ); |
---|
830 | return; |
---|
831 | } |
---|
832 | #endif |
---|
833 | |
---|
834 | // get context function is here |
---|
835 | Int iPredMode = pcCU->getPredictionMode( uiAbsPartIdx ); |
---|
836 | m_pcBinIf->encodeBin( iPredMode == MODE_INTER ? 0 : 1, m_cCUPredModeSCModel.get( 0, 0, 0 ) ); |
---|
837 | #if H_MV_ENC_DEC_TRAC |
---|
838 | DTRACE_CU("pred_mode_flag", iPredMode == MODE_INTER ? 0 : 1); |
---|
839 | #endif |
---|
840 | } |
---|
841 | |
---|
842 | Void TEncSbac::codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
843 | { |
---|
844 | UInt uiSymbol = pcCU->getCUTransquantBypass(uiAbsPartIdx); |
---|
845 | m_pcBinIf->encodeBin( uiSymbol, m_CUTransquantBypassFlagSCModel.get( 0, 0, 0 ) ); |
---|
846 | #if H_MV_ENC_DEC_TRAC |
---|
847 | DTRACE_CU("cu_transquant_bypass_flag", uiSymbol); |
---|
848 | #endif |
---|
849 | } |
---|
850 | |
---|
851 | /** code skip flag |
---|
852 | * \param pcCU |
---|
853 | * \param uiAbsPartIdx |
---|
854 | * \returns Void |
---|
855 | */ |
---|
856 | Void TEncSbac::codeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
857 | { |
---|
858 | // get context function is here |
---|
859 | UInt uiSymbol = pcCU->isSkipped( uiAbsPartIdx ) ? 1 : 0; |
---|
860 | UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx ) ; |
---|
861 | m_pcBinIf->encodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) ); |
---|
862 | #if !H_MV_ENC_DEC_TRAC |
---|
863 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
864 | DTRACE_CABAC_T( "\tSkipFlag" ); |
---|
865 | DTRACE_CABAC_T( "\tuiCtxSkip: "); |
---|
866 | DTRACE_CABAC_V( uiCtxSkip ); |
---|
867 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
868 | DTRACE_CABAC_V( uiSymbol ); |
---|
869 | DTRACE_CABAC_T( "\n"); |
---|
870 | #else |
---|
871 | DTRACE_CU("cu_skip_flag", uiSymbol); |
---|
872 | #endif |
---|
873 | } |
---|
874 | |
---|
875 | /** code merge flag |
---|
876 | * \param pcCU |
---|
877 | * \param uiAbsPartIdx |
---|
878 | * \returns Void |
---|
879 | */ |
---|
880 | Void TEncSbac::codeMergeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
881 | { |
---|
882 | const UInt uiSymbol = pcCU->getMergeFlag( uiAbsPartIdx ) ? 1 : 0; |
---|
883 | m_pcBinIf->encodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) ); |
---|
884 | |
---|
885 | #if H_MV_ENC_DEC_TRAC |
---|
886 | DTRACE_PU("merge_flag", uiSymbol); |
---|
887 | #else |
---|
888 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
889 | DTRACE_CABAC_T( "\tMergeFlag: " ); |
---|
890 | DTRACE_CABAC_V( uiSymbol ); |
---|
891 | DTRACE_CABAC_T( "\tAddress: " ); |
---|
892 | DTRACE_CABAC_V( pcCU->getAddr() ); |
---|
893 | DTRACE_CABAC_T( "\tuiAbsPartIdx: " ); |
---|
894 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
895 | DTRACE_CABAC_T( "\n" ); |
---|
896 | #endif |
---|
897 | } |
---|
898 | |
---|
899 | /** code merge index |
---|
900 | * \param pcCU |
---|
901 | * \param uiAbsPartIdx |
---|
902 | * \returns Void |
---|
903 | */ |
---|
904 | Void TEncSbac::codeMergeIndex( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
905 | { |
---|
906 | UInt uiUnaryIdx = pcCU->getMergeIndex( uiAbsPartIdx ); |
---|
907 | UInt uiNumCand = pcCU->getSlice()->getMaxNumMergeCand(); |
---|
908 | if ( uiNumCand > 1 ) |
---|
909 | { |
---|
910 | for( UInt ui = 0; ui < uiNumCand - 1; ++ui ) |
---|
911 | { |
---|
912 | const UInt uiSymbol = ui == uiUnaryIdx ? 0 : 1; |
---|
913 | if ( ui==0 ) |
---|
914 | { |
---|
915 | m_pcBinIf->encodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) ); |
---|
916 | } |
---|
917 | else |
---|
918 | { |
---|
919 | m_pcBinIf->encodeBinEP( uiSymbol ); |
---|
920 | } |
---|
921 | if( uiSymbol == 0 ) |
---|
922 | { |
---|
923 | break; |
---|
924 | } |
---|
925 | } |
---|
926 | #if H_MV_ENC_DEC_TRAC |
---|
927 | DTRACE_PU("merge_idx", uiUnaryIdx); |
---|
928 | #endif |
---|
929 | } |
---|
930 | #if !H_MV_ENC_DEC_TRAC |
---|
931 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
932 | DTRACE_CABAC_T( "\tparseMergeIndex()" ); |
---|
933 | DTRACE_CABAC_T( "\tuiMRGIdx= " ); |
---|
934 | DTRACE_CABAC_V( pcCU->getMergeIndex( uiAbsPartIdx ) ); |
---|
935 | DTRACE_CABAC_T( "\n" ); |
---|
936 | #endif |
---|
937 | } |
---|
938 | |
---|
939 | #if H_3D_ARP |
---|
940 | Void TEncSbac::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
941 | { |
---|
942 | Int iW = (Int)pcCU->getARPW( uiAbsPartIdx ); |
---|
943 | Int iMaxW = pcCU->getSlice()->getARPStepNum() - 1; |
---|
944 | assert( iMaxW > 0); |
---|
945 | |
---|
946 | Int nOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx); |
---|
947 | Int nBinNum = iW + ( iW != iMaxW ); |
---|
948 | m_pcBinIf->encodeBin( iW ? 1 : 0 , m_cCUPUARPWSCModel.get( 0, 0, 0 + nOffset ) ); |
---|
949 | if( nBinNum > 1 ) |
---|
950 | { |
---|
951 | m_pcBinIf->encodeBin( ( iW == iMaxW ) ? 1 : 0, m_cCUPUARPWSCModel.get( 0, 0, 2 ) ); |
---|
952 | } |
---|
953 | #if H_MV_ENC_DEC_TRAC |
---|
954 | DTRACE_CU("iv_res_pred_weight_idx", iW); |
---|
955 | #endif |
---|
956 | } |
---|
957 | #endif |
---|
958 | |
---|
959 | #if H_3D_IC |
---|
960 | /** code Illumination Compensation flag |
---|
961 | * \param pcCU |
---|
962 | * \param uiAbsPartIdx |
---|
963 | * \returns Void |
---|
964 | */ |
---|
965 | Void TEncSbac::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
966 | { |
---|
967 | // get context function is here |
---|
968 | UInt uiSymbol = pcCU->getICFlag( uiAbsPartIdx ) ? 1 : 0; |
---|
969 | m_pcBinIf->encodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, 0 ) ); |
---|
970 | #if !H_MV_ENC_DEC_TRAC |
---|
971 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
972 | DTRACE_CABAC_T( "\tICFlag" ); |
---|
973 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
974 | DTRACE_CABAC_V( uiSymbol ); |
---|
975 | DTRACE_CABAC_T( "\n"); |
---|
976 | #else |
---|
977 | DTRACE_CU("ic_flag", uiSymbol ); |
---|
978 | #endif |
---|
979 | } |
---|
980 | #endif |
---|
981 | |
---|
982 | |
---|
983 | Void TEncSbac::codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
984 | { |
---|
985 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
986 | return; |
---|
987 | |
---|
988 | UInt uiCtx = pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ); |
---|
989 | UInt uiCurrSplitFlag = ( pcCU->getDepth( uiAbsPartIdx ) > uiDepth ) ? 1 : 0; |
---|
990 | |
---|
991 | assert( uiCtx < 3 ); |
---|
992 | #if H_3D_QTLPC |
---|
993 | Bool bCodeSplitFlag = true; |
---|
994 | |
---|
995 | |
---|
996 | Bool bLimQtPredFlag = pcCU->getPic()->getSlice(0)->getQtPredFlag(); |
---|
997 | TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); |
---|
998 | Bool bDepthMapDetect = (pcTexture != NULL); |
---|
999 | Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); |
---|
1000 | |
---|
1001 | 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); |
---|
1002 | |
---|
1003 | #if H_3D_FCO |
---|
1004 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && bLimQtPredFlag && pcTexture->getReconMark() ) |
---|
1005 | #else |
---|
1006 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && bLimQtPredFlag ) |
---|
1007 | #endif |
---|
1008 | { |
---|
1009 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
1010 | UInt uiCUIdx = (pcCU->getZorderIdxInCU() == 0) ? uiAbsPartIdx : pcCU->getZorderIdxInCU(); |
---|
1011 | assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth); |
---|
1012 | bCodeSplitFlag = (pcTextureCU->getDepth(uiCUIdx) > uiDepth); |
---|
1013 | } |
---|
1014 | |
---|
1015 | if(!bCodeSplitFlag) |
---|
1016 | { |
---|
1017 | assert(uiCurrSplitFlag == 0); |
---|
1018 | return; |
---|
1019 | } |
---|
1020 | #endif |
---|
1021 | m_pcBinIf->encodeBin( uiCurrSplitFlag, m_cCUSplitFlagSCModel.get( 0, 0, uiCtx ) ); |
---|
1022 | #if !H_MV_ENC_DEC_TRAC |
---|
1023 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1024 | DTRACE_CABAC_T( "\tSplitFlag\n" ) |
---|
1025 | #else |
---|
1026 | DTRACE_CU("split_cu_flag", uiCurrSplitFlag ); |
---|
1027 | #endif |
---|
1028 | return; |
---|
1029 | } |
---|
1030 | |
---|
1031 | Void TEncSbac::codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) |
---|
1032 | { |
---|
1033 | m_pcBinIf->encodeBin( uiSymbol, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiCtx ) ); |
---|
1034 | #if !H_MV_ENC_DEC_TRAC |
---|
1035 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1036 | DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) |
---|
1037 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1038 | DTRACE_CABAC_V( uiSymbol ) |
---|
1039 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1040 | DTRACE_CABAC_V( uiCtx ) |
---|
1041 | DTRACE_CABAC_T( "\n" ) |
---|
1042 | #endif |
---|
1043 | } |
---|
1044 | |
---|
1045 | Void TEncSbac::codeIntraDirLumaAng( TComDataCU* pcCU, UInt absPartIdx, Bool isMultiple) |
---|
1046 | { |
---|
1047 | UInt dir[4],j; |
---|
1048 | Int preds[4][3] = {{-1, -1, -1},{-1, -1, -1},{-1, -1, -1},{-1, -1, -1}}; |
---|
1049 | Int predNum[4], predIdx[4] ={ -1,-1,-1,-1}; |
---|
1050 | PartSize mode = pcCU->getPartitionSize( absPartIdx ); |
---|
1051 | UInt partNum = isMultiple?(mode==SIZE_NxN?4:1):1; |
---|
1052 | UInt partOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(absPartIdx) << 1 ) ) >> 2; |
---|
1053 | for (j=0;j<partNum;j++) |
---|
1054 | { |
---|
1055 | dir[j] = pcCU->getLumaIntraDir( absPartIdx+partOffset*j ); |
---|
1056 | #if H_3D_DIM |
---|
1057 | if( pcCU->getSlice()->getIntraSdcWedgeFlag() || pcCU->getSlice()->getIntraContourFlag() ) |
---|
1058 | { |
---|
1059 | codeIntraDepth( pcCU, absPartIdx+partOffset*j ); |
---|
1060 | } |
---|
1061 | if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) |
---|
1062 | { |
---|
1063 | #endif |
---|
1064 | predNum[j] = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds[j]); |
---|
1065 | for(UInt i = 0; i < predNum[j]; i++) |
---|
1066 | { |
---|
1067 | if(dir[j] == preds[j][i]) |
---|
1068 | { |
---|
1069 | predIdx[j] = i; |
---|
1070 | } |
---|
1071 | } |
---|
1072 | m_pcBinIf->encodeBin((predIdx[j] != -1)? 1 : 0, m_cCUIntraPredSCModel.get( 0, 0, 0 ) ); |
---|
1073 | #if H_MV_ENC_DEC_TRAC |
---|
1074 | DTRACE_CU("prev_intra_luma_pred_flag", (predIdx[j] != -1)? 1 : 0); |
---|
1075 | #endif |
---|
1076 | #if H_3D_DIM |
---|
1077 | } |
---|
1078 | #endif |
---|
1079 | |
---|
1080 | } |
---|
1081 | for (j=0;j<partNum;j++) |
---|
1082 | { |
---|
1083 | #if H_3D_DIM |
---|
1084 | if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) |
---|
1085 | { |
---|
1086 | #endif |
---|
1087 | if(predIdx[j] != -1) |
---|
1088 | { |
---|
1089 | m_pcBinIf->encodeBinEP( predIdx[j] ? 1 : 0 ); |
---|
1090 | if (predIdx[j]) |
---|
1091 | { |
---|
1092 | m_pcBinIf->encodeBinEP( predIdx[j]-1 ); |
---|
1093 | } |
---|
1094 | #if H_MV_ENC_DEC_TRAC |
---|
1095 | DTRACE_CU("mpm_idx", predIdx[j] ); |
---|
1096 | #endif |
---|
1097 | } |
---|
1098 | else |
---|
1099 | { |
---|
1100 | if (preds[j][0] > preds[j][1]) |
---|
1101 | { |
---|
1102 | std::swap(preds[j][0], preds[j][1]); |
---|
1103 | } |
---|
1104 | if (preds[j][0] > preds[j][2]) |
---|
1105 | { |
---|
1106 | std::swap(preds[j][0], preds[j][2]); |
---|
1107 | } |
---|
1108 | if (preds[j][1] > preds[j][2]) |
---|
1109 | { |
---|
1110 | std::swap(preds[j][1], preds[j][2]); |
---|
1111 | } |
---|
1112 | for(Int i = (predNum[j] - 1); i >= 0; i--) |
---|
1113 | { |
---|
1114 | dir[j] = dir[j] > preds[j][i] ? dir[j] - 1 : dir[j]; |
---|
1115 | } |
---|
1116 | m_pcBinIf->encodeBinsEP( dir[j], 5 ); |
---|
1117 | #if H_MV_ENC_DEC_TRAC |
---|
1118 | DTRACE_CU("rem_intra_luma_pred_mode", dir[j] ); |
---|
1119 | #endif |
---|
1120 | } |
---|
1121 | #if H_3D_DIM |
---|
1122 | } |
---|
1123 | #endif |
---|
1124 | } |
---|
1125 | return; |
---|
1126 | } |
---|
1127 | |
---|
1128 | Void TEncSbac::codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1129 | { |
---|
1130 | UInt uiIntraDirChroma = pcCU->getChromaIntraDir( uiAbsPartIdx ); |
---|
1131 | |
---|
1132 | if( uiIntraDirChroma == DM_CHROMA_IDX ) |
---|
1133 | { |
---|
1134 | m_pcBinIf->encodeBin( 0, m_cCUChromaPredSCModel.get( 0, 0, 0 ) ); |
---|
1135 | #if H_MV_ENC_DEC_TRAC |
---|
1136 | DTRACE_CU("intra_chroma_pred_mode", 0 ); |
---|
1137 | #endif |
---|
1138 | } |
---|
1139 | else |
---|
1140 | { |
---|
1141 | UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; |
---|
1142 | pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); |
---|
1143 | |
---|
1144 | for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) |
---|
1145 | { |
---|
1146 | if( uiIntraDirChroma == uiAllowedChromaDir[i] ) |
---|
1147 | { |
---|
1148 | uiIntraDirChroma = i; |
---|
1149 | break; |
---|
1150 | } |
---|
1151 | } |
---|
1152 | m_pcBinIf->encodeBin( 1, m_cCUChromaPredSCModel.get( 0, 0, 0 ) ); |
---|
1153 | |
---|
1154 | m_pcBinIf->encodeBinsEP( uiIntraDirChroma, 2 ); |
---|
1155 | #if H_MV_ENC_DEC_TRAC |
---|
1156 | DTRACE_CU("intra_chroma_pred_mode", uiIntraDirChroma ); |
---|
1157 | #endif |
---|
1158 | |
---|
1159 | } |
---|
1160 | return; |
---|
1161 | } |
---|
1162 | |
---|
1163 | #if H_3D_DIM |
---|
1164 | Void TEncSbac::codeIntraDepth( TComDataCU* pcCU, UInt absPartIdx ) |
---|
1165 | { |
---|
1166 | codeIntraDepthMode( pcCU, absPartIdx ); |
---|
1167 | |
---|
1168 | UInt dir = pcCU->getLumaIntraDir( absPartIdx ); |
---|
1169 | UInt dimType = getDimType( dir ); |
---|
1170 | |
---|
1171 | switch( dimType ) |
---|
1172 | { |
---|
1173 | #if H_3D_DIM_DMM |
---|
1174 | case( DMM1_IDX ): |
---|
1175 | { |
---|
1176 | xCodeDmm1WedgeIdx( pcCU->getDmmWedgeTabIdx( dimType, absPartIdx ), g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); |
---|
1177 | } break; |
---|
1178 | case( DMM4_IDX ): break; |
---|
1179 | #endif |
---|
1180 | default: break; |
---|
1181 | } |
---|
1182 | } |
---|
1183 | |
---|
1184 | Void TEncSbac::codeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx ) |
---|
1185 | { |
---|
1186 | UInt dir = pcCU->getLumaIntraDir( absPartIdx ); |
---|
1187 | |
---|
1188 | if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed |
---|
1189 | { |
---|
1190 | m_pcBinIf->encodeBin( isDimMode( dir ) ? 0 : 1, m_cAngleFlagSCModel.get( 0, 0, 0 ) ); |
---|
1191 | } |
---|
1192 | if( isDimMode( dir ) ) |
---|
1193 | { |
---|
1194 | UInt uiCodeIdx = 0; |
---|
1195 | |
---|
1196 | switch( getDimType( dir ) ) |
---|
1197 | { |
---|
1198 | case DMM1_IDX: uiCodeIdx = 0; break; |
---|
1199 | case DMM4_IDX: uiCodeIdx = 1; break; |
---|
1200 | default: break; |
---|
1201 | } |
---|
1202 | //mode coding |
---|
1203 | if( pcCU->getSlice()->getIntraSdcWedgeFlag() && pcCU->getSlice()->getIntraContourFlag()) |
---|
1204 | { |
---|
1205 | m_pcBinIf->encodeBin( uiCodeIdx == 0 ? 0 : 1, m_cDepthIntraModeSCModel.get( 0, 0, 0 ) ); |
---|
1206 | } |
---|
1207 | } |
---|
1208 | } |
---|
1209 | #endif |
---|
1210 | |
---|
1211 | |
---|
1212 | Void TEncSbac::codeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1213 | { |
---|
1214 | const UInt uiInterDir = pcCU->getInterDir( uiAbsPartIdx ) - 1; |
---|
1215 | const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); |
---|
1216 | ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 ); |
---|
1217 | if (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N || pcCU->getHeight(uiAbsPartIdx) != 8 ) |
---|
1218 | { |
---|
1219 | m_pcBinIf->encodeBin( uiInterDir == 2 ? 1 : 0, *( pCtx + uiCtx ) ); |
---|
1220 | } |
---|
1221 | if (uiInterDir < 2) |
---|
1222 | { |
---|
1223 | m_pcBinIf->encodeBin( uiInterDir, *( pCtx + 4 ) ); |
---|
1224 | } |
---|
1225 | #if H_MV_ENC_DEC_TRAC |
---|
1226 | DTRACE_PU("inter_pred_idc", uiInterDir ); |
---|
1227 | #endif |
---|
1228 | |
---|
1229 | return; |
---|
1230 | } |
---|
1231 | |
---|
1232 | Void TEncSbac::codeRefFrmIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
1233 | { |
---|
1234 | { |
---|
1235 | Int iRefFrame = pcCU->getCUMvField( eRefList )->getRefIdx( uiAbsPartIdx ); |
---|
1236 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
1237 | m_pcBinIf->encodeBin( ( iRefFrame == 0 ? 0 : 1 ), *pCtx ); |
---|
1238 | |
---|
1239 | if( iRefFrame > 0 ) |
---|
1240 | { |
---|
1241 | UInt uiRefNum = pcCU->getSlice()->getNumRefIdx( eRefList ) - 2; |
---|
1242 | pCtx++; |
---|
1243 | iRefFrame--; |
---|
1244 | for( UInt ui = 0; ui < uiRefNum; ++ui ) |
---|
1245 | { |
---|
1246 | const UInt uiSymbol = ui == iRefFrame ? 0 : 1; |
---|
1247 | if( ui == 0 ) |
---|
1248 | { |
---|
1249 | m_pcBinIf->encodeBin( uiSymbol, *pCtx ); |
---|
1250 | } |
---|
1251 | else |
---|
1252 | { |
---|
1253 | m_pcBinIf->encodeBinEP( uiSymbol ); |
---|
1254 | } |
---|
1255 | if( uiSymbol == 0 ) |
---|
1256 | { |
---|
1257 | break; |
---|
1258 | } |
---|
1259 | } |
---|
1260 | } |
---|
1261 | #if H_MV_ENC_DEC_TRAC |
---|
1262 | #if ENC_DEC_TRACE |
---|
1263 | iRefFrame = pcCU->getCUMvField( eRefList )->getRefIdx( uiAbsPartIdx ); |
---|
1264 | if ( eRefList == REF_PIC_LIST_0 ) |
---|
1265 | { |
---|
1266 | DTRACE_PU("ref_idx_l0", iRefFrame) |
---|
1267 | } |
---|
1268 | else |
---|
1269 | { |
---|
1270 | DTRACE_PU("ref_idx_l1", iRefFrame) |
---|
1271 | } |
---|
1272 | #endif |
---|
1273 | #endif |
---|
1274 | } |
---|
1275 | return; |
---|
1276 | } |
---|
1277 | |
---|
1278 | Void TEncSbac::codeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
1279 | { |
---|
1280 | if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3) |
---|
1281 | { |
---|
1282 | return; |
---|
1283 | } |
---|
1284 | |
---|
1285 | const TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefList ); |
---|
1286 | const Int iHor = pcCUMvField->getMvd( uiAbsPartIdx ).getHor(); |
---|
1287 | const Int iVer = pcCUMvField->getMvd( uiAbsPartIdx ).getVer(); |
---|
1288 | ContextModel* pCtx = m_cCUMvdSCModel.get( 0 ); |
---|
1289 | |
---|
1290 | m_pcBinIf->encodeBin( iHor != 0 ? 1 : 0, *pCtx ); |
---|
1291 | m_pcBinIf->encodeBin( iVer != 0 ? 1 : 0, *pCtx ); |
---|
1292 | |
---|
1293 | const Bool bHorAbsGr0 = iHor != 0; |
---|
1294 | const Bool bVerAbsGr0 = iVer != 0; |
---|
1295 | const UInt uiHorAbs = 0 > iHor ? -iHor : iHor; |
---|
1296 | const UInt uiVerAbs = 0 > iVer ? -iVer : iVer; |
---|
1297 | pCtx++; |
---|
1298 | |
---|
1299 | if( bHorAbsGr0 ) |
---|
1300 | { |
---|
1301 | m_pcBinIf->encodeBin( uiHorAbs > 1 ? 1 : 0, *pCtx ); |
---|
1302 | } |
---|
1303 | |
---|
1304 | if( bVerAbsGr0 ) |
---|
1305 | { |
---|
1306 | m_pcBinIf->encodeBin( uiVerAbs > 1 ? 1 : 0, *pCtx ); |
---|
1307 | } |
---|
1308 | |
---|
1309 | if( bHorAbsGr0 ) |
---|
1310 | { |
---|
1311 | if( uiHorAbs > 1 ) |
---|
1312 | { |
---|
1313 | xWriteEpExGolomb( uiHorAbs-2, 1 ); |
---|
1314 | } |
---|
1315 | |
---|
1316 | m_pcBinIf->encodeBinEP( 0 > iHor ? 1 : 0 ); |
---|
1317 | } |
---|
1318 | |
---|
1319 | if( bVerAbsGr0 ) |
---|
1320 | { |
---|
1321 | if( uiVerAbs > 1 ) |
---|
1322 | { |
---|
1323 | xWriteEpExGolomb( uiVerAbs-2, 1 ); |
---|
1324 | } |
---|
1325 | |
---|
1326 | m_pcBinIf->encodeBinEP( 0 > iVer ? 1 : 0 ); |
---|
1327 | } |
---|
1328 | |
---|
1329 | return; |
---|
1330 | } |
---|
1331 | |
---|
1332 | Void TEncSbac::codeDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1333 | { |
---|
1334 | Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); |
---|
1335 | |
---|
1336 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
1337 | iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); |
---|
1338 | |
---|
1339 | UInt uiAbsDQp = (UInt)((iDQp > 0)? iDQp : (-iDQp)); |
---|
1340 | UInt TUValue = min((Int)uiAbsDQp, CU_DQP_TU_CMAX); |
---|
1341 | xWriteUnaryMaxSymbol( TUValue, &m_cCUDeltaQpSCModel.get( 0, 0, 0 ), 1, CU_DQP_TU_CMAX); |
---|
1342 | if( uiAbsDQp >= CU_DQP_TU_CMAX ) |
---|
1343 | { |
---|
1344 | xWriteEpExGolomb( uiAbsDQp - CU_DQP_TU_CMAX, CU_DQP_EG_k ); |
---|
1345 | } |
---|
1346 | |
---|
1347 | if ( uiAbsDQp > 0) |
---|
1348 | { |
---|
1349 | UInt uiSign = (iDQp > 0 ? 0 : 1); |
---|
1350 | m_pcBinIf->encodeBinEP(uiSign); |
---|
1351 | } |
---|
1352 | |
---|
1353 | return; |
---|
1354 | } |
---|
1355 | |
---|
1356 | Void TEncSbac::codeQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
1357 | { |
---|
1358 | UInt uiCbf = pcCU->getCbf ( uiAbsPartIdx, eType, uiTrDepth ); |
---|
1359 | UInt uiCtx = pcCU->getCtxQtCbf( eType, uiTrDepth ); |
---|
1360 | m_pcBinIf->encodeBin( uiCbf , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA : eType, uiCtx ) ); |
---|
1361 | #if !H_MV_ENC_DEC_TRAC |
---|
1362 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1363 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
1364 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1365 | DTRACE_CABAC_V( uiCbf ) |
---|
1366 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1367 | DTRACE_CABAC_V( uiCtx ) |
---|
1368 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1369 | DTRACE_CABAC_V( eType ) |
---|
1370 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1371 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1372 | DTRACE_CABAC_T( "\n" ) |
---|
1373 | #endif |
---|
1374 | } |
---|
1375 | |
---|
1376 | void TEncSbac::codeTransformSkipFlags (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, TextType eTType ) |
---|
1377 | { |
---|
1378 | if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) |
---|
1379 | { |
---|
1380 | return; |
---|
1381 | } |
---|
1382 | if(width != 4 || height != 4) |
---|
1383 | { |
---|
1384 | return; |
---|
1385 | } |
---|
1386 | |
---|
1387 | UInt useTransformSkip = pcCU->getTransformSkip( uiAbsPartIdx,eTType); |
---|
1388 | m_pcBinIf->encodeBin( useTransformSkip, m_cTransformSkipSCModel.get( 0, eTType? TEXT_CHROMA: TEXT_LUMA, 0 ) ); |
---|
1389 | #if !H_MV_ENC_DEC_TRAC |
---|
1390 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1391 | DTRACE_CABAC_T("\tparseTransformSkip()"); |
---|
1392 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1393 | DTRACE_CABAC_V( useTransformSkip ) |
---|
1394 | DTRACE_CABAC_T( "\tAddr=" ) |
---|
1395 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
1396 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1397 | DTRACE_CABAC_V( eTType ) |
---|
1398 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1399 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1400 | DTRACE_CABAC_T( "\n" ) |
---|
1401 | #endif |
---|
1402 | } |
---|
1403 | |
---|
1404 | /** Code I_PCM information. |
---|
1405 | * \param pcCU pointer to CU |
---|
1406 | * \param uiAbsPartIdx CU index |
---|
1407 | * \returns Void |
---|
1408 | */ |
---|
1409 | Void TEncSbac::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1410 | { |
---|
1411 | UInt uiIPCM = (pcCU->getIPCMFlag(uiAbsPartIdx) == true)? 1 : 0; |
---|
1412 | |
---|
1413 | Bool writePCMSampleFlag = pcCU->getIPCMFlag(uiAbsPartIdx); |
---|
1414 | |
---|
1415 | m_pcBinIf->encodeBinTrm (uiIPCM); |
---|
1416 | #if H_MV_ENC_DEC_TRAC |
---|
1417 | DTRACE_CU("pcm_flag", uiIPCM) |
---|
1418 | #endif |
---|
1419 | if (writePCMSampleFlag) |
---|
1420 | { |
---|
1421 | m_pcBinIf->encodePCMAlignBits(); |
---|
1422 | |
---|
1423 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
1424 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
1425 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
1426 | Pel* piPCMSample; |
---|
1427 | UInt uiWidth; |
---|
1428 | UInt uiHeight; |
---|
1429 | UInt uiSampleBits; |
---|
1430 | UInt uiX, uiY; |
---|
1431 | |
---|
1432 | piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; |
---|
1433 | uiWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
1434 | uiHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
1435 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
1436 | |
---|
1437 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
1438 | { |
---|
1439 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
1440 | { |
---|
1441 | UInt uiSample = piPCMSample[uiX]; |
---|
1442 | |
---|
1443 | m_pcBinIf->xWritePCMCode(uiSample, uiSampleBits); |
---|
1444 | } |
---|
1445 | piPCMSample += uiWidth; |
---|
1446 | } |
---|
1447 | |
---|
1448 | piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; |
---|
1449 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
1450 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
1451 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
1452 | |
---|
1453 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
1454 | { |
---|
1455 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
1456 | { |
---|
1457 | UInt uiSample = piPCMSample[uiX]; |
---|
1458 | |
---|
1459 | m_pcBinIf->xWritePCMCode(uiSample, uiSampleBits); |
---|
1460 | } |
---|
1461 | piPCMSample += uiWidth; |
---|
1462 | } |
---|
1463 | |
---|
1464 | piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; |
---|
1465 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
1466 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
1467 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
1468 | |
---|
1469 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
1470 | { |
---|
1471 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
1472 | { |
---|
1473 | UInt uiSample = piPCMSample[uiX]; |
---|
1474 | |
---|
1475 | m_pcBinIf->xWritePCMCode(uiSample, uiSampleBits); |
---|
1476 | } |
---|
1477 | piPCMSample += uiWidth; |
---|
1478 | } |
---|
1479 | m_pcBinIf->resetBac(); |
---|
1480 | } |
---|
1481 | } |
---|
1482 | |
---|
1483 | Void TEncSbac::codeQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1484 | { |
---|
1485 | UInt uiCbf = pcCU->getQtRootCbf( uiAbsPartIdx ); |
---|
1486 | UInt uiCtx = 0; |
---|
1487 | m_pcBinIf->encodeBin( uiCbf , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) ); |
---|
1488 | #if !H_MV_ENC_DEC_TRAC |
---|
1489 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1490 | DTRACE_CABAC_T( "\tparseQtRootCbf()" ) |
---|
1491 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1492 | DTRACE_CABAC_V( uiCbf ) |
---|
1493 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1494 | DTRACE_CABAC_V( uiCtx ) |
---|
1495 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1496 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1497 | DTRACE_CABAC_T( "\n" ) |
---|
1498 | #else |
---|
1499 | DTRACE_CU( "rqt_root_cbf", uiCbf ) |
---|
1500 | #endif |
---|
1501 | } |
---|
1502 | |
---|
1503 | Void TEncSbac::codeQtCbfZero( TComDataCU* pcCU, TextType eType, UInt uiTrDepth ) |
---|
1504 | { |
---|
1505 | // this function is only used to estimate the bits when cbf is 0 |
---|
1506 | // and will never be called when writing the bistream. do not need to write log |
---|
1507 | UInt uiCbf = 0; |
---|
1508 | UInt uiCtx = pcCU->getCtxQtCbf( eType, uiTrDepth ); |
---|
1509 | m_pcBinIf->encodeBin( uiCbf , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA : eType, uiCtx ) ); |
---|
1510 | } |
---|
1511 | |
---|
1512 | Void TEncSbac::codeQtRootCbfZero( TComDataCU* pcCU ) |
---|
1513 | { |
---|
1514 | // this function is only used to estimate the bits when cbf is 0 |
---|
1515 | // and will never be called when writing the bistream. do not need to write log |
---|
1516 | UInt uiCbf = 0; |
---|
1517 | UInt uiCtx = 0; |
---|
1518 | m_pcBinIf->encodeBin( uiCbf , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) ); |
---|
1519 | } |
---|
1520 | |
---|
1521 | /** Encode (X,Y) position of the last significant coefficient |
---|
1522 | * \param uiPosX X component of last coefficient |
---|
1523 | * \param uiPosY Y component of last coefficient |
---|
1524 | * \param width Block width |
---|
1525 | * \param height Block height |
---|
1526 | * \param eTType plane type / luminance or chrominance |
---|
1527 | * \param uiScanIdx scan type (zig-zag, hor, ver) |
---|
1528 | * This method encodes the X and Y component within a block of the last significant coefficient. |
---|
1529 | */ |
---|
1530 | Void TEncSbac::codeLastSignificantXY( UInt uiPosX, UInt uiPosY, Int width, Int height, TextType eTType, UInt uiScanIdx ) |
---|
1531 | { |
---|
1532 | // swap |
---|
1533 | if( uiScanIdx == SCAN_VER ) |
---|
1534 | { |
---|
1535 | swap( uiPosX, uiPosY ); |
---|
1536 | } |
---|
1537 | |
---|
1538 | UInt uiCtxLast; |
---|
1539 | ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); |
---|
1540 | ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); |
---|
1541 | UInt uiGroupIdxX = g_uiGroupIdx[ uiPosX ]; |
---|
1542 | UInt uiGroupIdxY = g_uiGroupIdx[ uiPosY ]; |
---|
1543 | |
---|
1544 | |
---|
1545 | Int blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY; |
---|
1546 | blkSizeOffsetX = eTType ? 0: (g_aucConvertToBit[ width ] *3 + ((g_aucConvertToBit[ width ] +1)>>2)); |
---|
1547 | blkSizeOffsetY = eTType ? 0: (g_aucConvertToBit[ height ]*3 + ((g_aucConvertToBit[ height ]+1)>>2)); |
---|
1548 | shiftX= eTType ? g_aucConvertToBit[ width ] :((g_aucConvertToBit[ width ]+3)>>2); |
---|
1549 | shiftY= eTType ? g_aucConvertToBit[ height ] :((g_aucConvertToBit[ height ]+3)>>2); |
---|
1550 | // posX |
---|
1551 | for( uiCtxLast = 0; uiCtxLast < uiGroupIdxX; uiCtxLast++ ) |
---|
1552 | { |
---|
1553 | m_pcBinIf->encodeBin( 1, *( pCtxX + blkSizeOffsetX + (uiCtxLast >>shiftX) ) ); |
---|
1554 | } |
---|
1555 | if( uiGroupIdxX < g_uiGroupIdx[ width - 1 ]) |
---|
1556 | { |
---|
1557 | m_pcBinIf->encodeBin( 0, *( pCtxX + blkSizeOffsetX + (uiCtxLast >>shiftX) ) ); |
---|
1558 | } |
---|
1559 | |
---|
1560 | // posY |
---|
1561 | for( uiCtxLast = 0; uiCtxLast < uiGroupIdxY; uiCtxLast++ ) |
---|
1562 | { |
---|
1563 | m_pcBinIf->encodeBin( 1, *( pCtxY + blkSizeOffsetY + (uiCtxLast >>shiftY) ) ); |
---|
1564 | } |
---|
1565 | if( uiGroupIdxY < g_uiGroupIdx[ height - 1 ]) |
---|
1566 | { |
---|
1567 | m_pcBinIf->encodeBin( 0, *( pCtxY + blkSizeOffsetY + (uiCtxLast >>shiftY) ) ); |
---|
1568 | } |
---|
1569 | if ( uiGroupIdxX > 3 ) |
---|
1570 | { |
---|
1571 | UInt uiCount = ( uiGroupIdxX - 2 ) >> 1; |
---|
1572 | uiPosX = uiPosX - g_uiMinInGroup[ uiGroupIdxX ]; |
---|
1573 | for (Int i = uiCount - 1 ; i >= 0; i-- ) |
---|
1574 | { |
---|
1575 | m_pcBinIf->encodeBinEP( ( uiPosX >> i ) & 1 ); |
---|
1576 | } |
---|
1577 | } |
---|
1578 | if ( uiGroupIdxY > 3 ) |
---|
1579 | { |
---|
1580 | UInt uiCount = ( uiGroupIdxY - 2 ) >> 1; |
---|
1581 | uiPosY = uiPosY - g_uiMinInGroup[ uiGroupIdxY ]; |
---|
1582 | for ( Int i = uiCount - 1 ; i >= 0; i-- ) |
---|
1583 | { |
---|
1584 | m_pcBinIf->encodeBinEP( ( uiPosY >> i ) & 1 ); |
---|
1585 | } |
---|
1586 | } |
---|
1587 | } |
---|
1588 | |
---|
1589 | Void TEncSbac::codeCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
1590 | { |
---|
1591 | #if !H_MV_ENC_DEC_TRAC |
---|
1592 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1593 | DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) |
---|
1594 | DTRACE_CABAC_V( eTType ) |
---|
1595 | DTRACE_CABAC_T( "\twidth=" ) |
---|
1596 | DTRACE_CABAC_V( uiWidth ) |
---|
1597 | DTRACE_CABAC_T( "\theight=" ) |
---|
1598 | DTRACE_CABAC_V( uiHeight ) |
---|
1599 | DTRACE_CABAC_T( "\tdepth=" ) |
---|
1600 | DTRACE_CABAC_V( uiDepth ) |
---|
1601 | DTRACE_CABAC_T( "\tabspartidx=" ) |
---|
1602 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1603 | DTRACE_CABAC_T( "\ttoCU-X=" ) |
---|
1604 | DTRACE_CABAC_V( pcCU->getCUPelX() ) |
---|
1605 | DTRACE_CABAC_T( "\ttoCU-Y=" ) |
---|
1606 | DTRACE_CABAC_V( pcCU->getCUPelY() ) |
---|
1607 | DTRACE_CABAC_T( "\tCU-addr=" ) |
---|
1608 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
1609 | DTRACE_CABAC_T( "\tinCU-X=" ) |
---|
1610 | DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1611 | DTRACE_CABAC_T( "\tinCU-Y=" ) |
---|
1612 | DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1613 | DTRACE_CABAC_T( "\tpredmode=" ) |
---|
1614 | DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) |
---|
1615 | DTRACE_CABAC_T( "\n" ) |
---|
1616 | #endif |
---|
1617 | if( uiWidth > m_pcSlice->getSPS()->getMaxTrSize() ) |
---|
1618 | { |
---|
1619 | uiWidth = m_pcSlice->getSPS()->getMaxTrSize(); |
---|
1620 | uiHeight = m_pcSlice->getSPS()->getMaxTrSize(); |
---|
1621 | } |
---|
1622 | |
---|
1623 | UInt uiNumSig = 0; |
---|
1624 | |
---|
1625 | // compute number of significant coefficients |
---|
1626 | uiNumSig = TEncEntropy::countNonZeroCoeffs(pcCoef, uiWidth * uiHeight); |
---|
1627 | |
---|
1628 | if ( uiNumSig == 0 ) |
---|
1629 | return; |
---|
1630 | if(pcCU->getSlice()->getPPS()->getUseTransformSkip()) |
---|
1631 | { |
---|
1632 | codeTransformSkipFlags( pcCU,uiAbsPartIdx, uiWidth, uiHeight, eTType ); |
---|
1633 | } |
---|
1634 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); |
---|
1635 | |
---|
1636 | //----- encode significance map ----- |
---|
1637 | const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; |
---|
1638 | UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); |
---|
1639 | const UInt *scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize - 1 ]; |
---|
1640 | |
---|
1641 | Bool beValid; |
---|
1642 | if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) |
---|
1643 | { |
---|
1644 | beValid = false; |
---|
1645 | } |
---|
1646 | else |
---|
1647 | { |
---|
1648 | beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
1649 | } |
---|
1650 | |
---|
1651 | // Find position of last coefficient |
---|
1652 | Int scanPosLast = -1; |
---|
1653 | Int posLast; |
---|
1654 | |
---|
1655 | const UInt * scanCG; |
---|
1656 | { |
---|
1657 | scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ]; |
---|
1658 | if( uiLog2BlockSize == 3 ) |
---|
1659 | { |
---|
1660 | scanCG = g_sigLastScan8x8[ uiScanIdx ]; |
---|
1661 | } |
---|
1662 | else if( uiLog2BlockSize == 5 ) |
---|
1663 | { |
---|
1664 | scanCG = g_sigLastScanCG32x32; |
---|
1665 | } |
---|
1666 | } |
---|
1667 | UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ]; |
---|
1668 | static const UInt uiShift = MLS_CG_SIZE >> 1; |
---|
1669 | const UInt uiNumBlkSide = uiWidth >> uiShift; |
---|
1670 | |
---|
1671 | ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); |
---|
1672 | |
---|
1673 | do |
---|
1674 | { |
---|
1675 | posLast = scan[ ++scanPosLast ]; |
---|
1676 | |
---|
1677 | // get L1 sig map |
---|
1678 | UInt uiPosY = posLast >> uiLog2BlockSize; |
---|
1679 | UInt uiPosX = posLast - ( uiPosY << uiLog2BlockSize ); |
---|
1680 | UInt uiBlkIdx = uiNumBlkSide * (uiPosY >> uiShift) + (uiPosX >> uiShift); |
---|
1681 | if( pcCoef[ posLast ] ) |
---|
1682 | { |
---|
1683 | uiSigCoeffGroupFlag[ uiBlkIdx ] = 1; |
---|
1684 | } |
---|
1685 | |
---|
1686 | uiNumSig -= ( pcCoef[ posLast ] != 0 ); |
---|
1687 | } |
---|
1688 | while ( uiNumSig > 0 ); |
---|
1689 | |
---|
1690 | // Code position of last coefficient |
---|
1691 | Int posLastY = posLast >> uiLog2BlockSize; |
---|
1692 | Int posLastX = posLast - ( posLastY << uiLog2BlockSize ); |
---|
1693 | codeLastSignificantXY(posLastX, posLastY, uiWidth, uiHeight, eTType, uiScanIdx); |
---|
1694 | |
---|
1695 | //===== code significance flag ===== |
---|
1696 | ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, eTType ); |
---|
1697 | ContextModel * const baseCtx = (eTType==TEXT_LUMA) ? m_cCUSigSCModel.get( 0, 0 ) : m_cCUSigSCModel.get( 0, 0 ) + NUM_SIG_FLAG_CTX_LUMA; |
---|
1698 | |
---|
1699 | |
---|
1700 | const Int iLastScanSet = scanPosLast >> LOG2_SCAN_SET_SIZE; |
---|
1701 | UInt c1 = 1; |
---|
1702 | UInt uiGoRiceParam = 0; |
---|
1703 | Int iScanPosSig = scanPosLast; |
---|
1704 | |
---|
1705 | for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- ) |
---|
1706 | { |
---|
1707 | Int numNonZero = 0; |
---|
1708 | Int iSubPos = iSubSet << LOG2_SCAN_SET_SIZE; |
---|
1709 | uiGoRiceParam = 0; |
---|
1710 | Int absCoeff[16]; |
---|
1711 | UInt coeffSigns = 0; |
---|
1712 | |
---|
1713 | Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE; |
---|
1714 | |
---|
1715 | if( iScanPosSig == scanPosLast ) |
---|
1716 | { |
---|
1717 | absCoeff[ 0 ] = abs( pcCoef[ posLast ] ); |
---|
1718 | coeffSigns = ( pcCoef[ posLast ] < 0 ); |
---|
1719 | numNonZero = 1; |
---|
1720 | lastNZPosInCG = iScanPosSig; |
---|
1721 | firstNZPosInCG = iScanPosSig; |
---|
1722 | iScanPosSig--; |
---|
1723 | } |
---|
1724 | |
---|
1725 | // encode significant_coeffgroup_flag |
---|
1726 | Int iCGBlkPos = scanCG[ iSubSet ]; |
---|
1727 | Int iCGPosY = iCGBlkPos / uiNumBlkSide; |
---|
1728 | Int iCGPosX = iCGBlkPos - (iCGPosY * uiNumBlkSide); |
---|
1729 | if( iSubSet == iLastScanSet || iSubSet == 0) |
---|
1730 | { |
---|
1731 | uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; |
---|
1732 | } |
---|
1733 | else |
---|
1734 | { |
---|
1735 | UInt uiSigCoeffGroup = (uiSigCoeffGroupFlag[ iCGBlkPos ] != 0); |
---|
1736 | UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); |
---|
1737 | m_pcBinIf->encodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] ); |
---|
1738 | } |
---|
1739 | |
---|
1740 | // encode significant_coeff_flag |
---|
1741 | if( uiSigCoeffGroupFlag[ iCGBlkPos ] ) |
---|
1742 | { |
---|
1743 | Int patternSigCtx = TComTrQuant::calcPatternSigCtx( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); |
---|
1744 | UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig; |
---|
1745 | for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) |
---|
1746 | { |
---|
1747 | uiBlkPos = scan[ iScanPosSig ]; |
---|
1748 | uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
1749 | uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
1750 | uiSig = (pcCoef[ uiBlkPos ] != 0); |
---|
1751 | if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) |
---|
1752 | { |
---|
1753 | uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, uiLog2BlockSize, eTType ); |
---|
1754 | m_pcBinIf->encodeBin( uiSig, baseCtx[ uiCtxSig ] ); |
---|
1755 | } |
---|
1756 | if( uiSig ) |
---|
1757 | { |
---|
1758 | absCoeff[ numNonZero ] = abs( pcCoef[ uiBlkPos ] ); |
---|
1759 | coeffSigns = 2 * coeffSigns + ( pcCoef[ uiBlkPos ] < 0 ); |
---|
1760 | numNonZero++; |
---|
1761 | if( lastNZPosInCG == -1 ) |
---|
1762 | { |
---|
1763 | lastNZPosInCG = iScanPosSig; |
---|
1764 | } |
---|
1765 | firstNZPosInCG = iScanPosSig; |
---|
1766 | } |
---|
1767 | } |
---|
1768 | } |
---|
1769 | else |
---|
1770 | { |
---|
1771 | iScanPosSig = iSubPos - 1; |
---|
1772 | } |
---|
1773 | |
---|
1774 | if( numNonZero > 0 ) |
---|
1775 | { |
---|
1776 | Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= SBH_THRESHOLD ); |
---|
1777 | UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0; |
---|
1778 | |
---|
1779 | if( c1 == 0 ) |
---|
1780 | { |
---|
1781 | uiCtxSet++; |
---|
1782 | } |
---|
1783 | c1 = 1; |
---|
1784 | ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet; |
---|
1785 | |
---|
1786 | Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); |
---|
1787 | Int firstC2FlagIdx = -1; |
---|
1788 | for( Int idx = 0; idx < numC1Flag; idx++ ) |
---|
1789 | { |
---|
1790 | UInt uiSymbol = absCoeff[ idx ] > 1; |
---|
1791 | m_pcBinIf->encodeBin( uiSymbol, baseCtxMod[c1] ); |
---|
1792 | if( uiSymbol ) |
---|
1793 | { |
---|
1794 | c1 = 0; |
---|
1795 | |
---|
1796 | if (firstC2FlagIdx == -1) |
---|
1797 | { |
---|
1798 | firstC2FlagIdx = idx; |
---|
1799 | } |
---|
1800 | } |
---|
1801 | else if( (c1 < 3) && (c1 > 0) ) |
---|
1802 | { |
---|
1803 | c1++; |
---|
1804 | } |
---|
1805 | } |
---|
1806 | |
---|
1807 | if (c1 == 0) |
---|
1808 | { |
---|
1809 | |
---|
1810 | baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet; |
---|
1811 | if ( firstC2FlagIdx != -1) |
---|
1812 | { |
---|
1813 | UInt symbol = absCoeff[ firstC2FlagIdx ] > 2; |
---|
1814 | m_pcBinIf->encodeBin( symbol, baseCtxMod[0] ); |
---|
1815 | } |
---|
1816 | } |
---|
1817 | |
---|
1818 | if( beValid && signHidden ) |
---|
1819 | { |
---|
1820 | m_pcBinIf->encodeBinsEP( (coeffSigns >> 1), numNonZero-1 ); |
---|
1821 | } |
---|
1822 | else |
---|
1823 | { |
---|
1824 | m_pcBinIf->encodeBinsEP( coeffSigns, numNonZero ); |
---|
1825 | } |
---|
1826 | |
---|
1827 | Int iFirstCoeff2 = 1; |
---|
1828 | if (c1 == 0 || numNonZero > C1FLAG_NUMBER) |
---|
1829 | { |
---|
1830 | for ( Int idx = 0; idx < numNonZero; idx++ ) |
---|
1831 | { |
---|
1832 | UInt baseLevel = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2 ) : 1; |
---|
1833 | |
---|
1834 | if( absCoeff[ idx ] >= baseLevel) |
---|
1835 | { |
---|
1836 | xWriteCoefRemainExGolomb( absCoeff[ idx ] - baseLevel, uiGoRiceParam ); |
---|
1837 | if(absCoeff[idx] > 3*(1<<uiGoRiceParam)) |
---|
1838 | { |
---|
1839 | uiGoRiceParam = min<UInt>(uiGoRiceParam+ 1, 4); |
---|
1840 | } |
---|
1841 | } |
---|
1842 | if(absCoeff[ idx ] >= 2) |
---|
1843 | { |
---|
1844 | iFirstCoeff2 = 0; |
---|
1845 | } |
---|
1846 | } |
---|
1847 | } |
---|
1848 | } |
---|
1849 | } |
---|
1850 | |
---|
1851 | return; |
---|
1852 | } |
---|
1853 | |
---|
1854 | /** code SAO offset sign |
---|
1855 | * \param code sign value |
---|
1856 | */ |
---|
1857 | Void TEncSbac::codeSAOSign( UInt code ) |
---|
1858 | { |
---|
1859 | m_pcBinIf->encodeBinEP( code ); |
---|
1860 | } |
---|
1861 | |
---|
1862 | Void TEncSbac::codeSaoMaxUvlc ( UInt code, UInt maxSymbol ) |
---|
1863 | { |
---|
1864 | if (maxSymbol == 0) |
---|
1865 | { |
---|
1866 | return; |
---|
1867 | } |
---|
1868 | |
---|
1869 | Int i; |
---|
1870 | Bool bCodeLast = ( maxSymbol > code ); |
---|
1871 | |
---|
1872 | if ( code == 0 ) |
---|
1873 | { |
---|
1874 | m_pcBinIf->encodeBinEP( 0 ); |
---|
1875 | } |
---|
1876 | else |
---|
1877 | { |
---|
1878 | m_pcBinIf->encodeBinEP( 1 ); |
---|
1879 | for ( i=0; i<code-1; i++ ) |
---|
1880 | { |
---|
1881 | m_pcBinIf->encodeBinEP( 1 ); |
---|
1882 | } |
---|
1883 | if( bCodeLast ) |
---|
1884 | { |
---|
1885 | m_pcBinIf->encodeBinEP( 0 ); |
---|
1886 | } |
---|
1887 | } |
---|
1888 | } |
---|
1889 | |
---|
1890 | |
---|
1891 | /** Code SAO EO class or BO band position |
---|
1892 | * \param uiLength |
---|
1893 | * \param uiCode |
---|
1894 | */ |
---|
1895 | Void TEncSbac::codeSaoUflc ( UInt uiLength, UInt uiCode ) |
---|
1896 | { |
---|
1897 | m_pcBinIf->encodeBinsEP ( uiCode, uiLength ); |
---|
1898 | } |
---|
1899 | /** Code SAO merge flags |
---|
1900 | * \param uiCode |
---|
1901 | * \param uiCompIdx |
---|
1902 | */ |
---|
1903 | Void TEncSbac::codeSaoMerge ( UInt uiCode ) |
---|
1904 | { |
---|
1905 | if (uiCode == 0) |
---|
1906 | { |
---|
1907 | m_pcBinIf->encodeBin(0, m_cSaoMergeSCModel.get( 0, 0, 0 )); |
---|
1908 | } |
---|
1909 | else |
---|
1910 | { |
---|
1911 | m_pcBinIf->encodeBin(1, m_cSaoMergeSCModel.get( 0, 0, 0 )); |
---|
1912 | } |
---|
1913 | } |
---|
1914 | /** Code SAO type index |
---|
1915 | * \param uiCode |
---|
1916 | */ |
---|
1917 | Void TEncSbac::codeSaoTypeIdx ( UInt uiCode) |
---|
1918 | { |
---|
1919 | if (uiCode == 0) |
---|
1920 | { |
---|
1921 | m_pcBinIf->encodeBin( 0, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); |
---|
1922 | } |
---|
1923 | else |
---|
1924 | { |
---|
1925 | m_pcBinIf->encodeBin( 1, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); |
---|
1926 | m_pcBinIf->encodeBinEP( uiCode == 1 ? 0 : 1 ); |
---|
1927 | } |
---|
1928 | } |
---|
1929 | /*! |
---|
1930 | **************************************************************************** |
---|
1931 | * \brief |
---|
1932 | * estimate bit cost for CBP, significant map and significant coefficients |
---|
1933 | **************************************************************************** |
---|
1934 | */ |
---|
1935 | Void TEncSbac::estBit( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType ) |
---|
1936 | { |
---|
1937 | estCBFBit( pcEstBitsSbac ); |
---|
1938 | |
---|
1939 | estSignificantCoeffGroupMapBit( pcEstBitsSbac, eTType ); |
---|
1940 | |
---|
1941 | // encode significance map |
---|
1942 | estSignificantMapBit( pcEstBitsSbac, width, height, eTType ); |
---|
1943 | |
---|
1944 | // encode significant coefficients |
---|
1945 | estSignificantCoefficientsBit( pcEstBitsSbac, eTType ); |
---|
1946 | } |
---|
1947 | |
---|
1948 | /*! |
---|
1949 | **************************************************************************** |
---|
1950 | * \brief |
---|
1951 | * estimate bit cost for each CBP bit |
---|
1952 | **************************************************************************** |
---|
1953 | */ |
---|
1954 | Void TEncSbac::estCBFBit( estBitsSbacStruct* pcEstBitsSbac ) |
---|
1955 | { |
---|
1956 | ContextModel *pCtx = m_cCUQtCbfSCModel.get( 0 ); |
---|
1957 | |
---|
1958 | for( UInt uiCtxInc = 0; uiCtxInc < 3*NUM_QT_CBF_CTX; uiCtxInc++ ) |
---|
1959 | { |
---|
1960 | pcEstBitsSbac->blockCbpBits[ uiCtxInc ][ 0 ] = pCtx[ uiCtxInc ].getEntropyBits( 0 ); |
---|
1961 | pcEstBitsSbac->blockCbpBits[ uiCtxInc ][ 1 ] = pCtx[ uiCtxInc ].getEntropyBits( 1 ); |
---|
1962 | } |
---|
1963 | |
---|
1964 | pCtx = m_cCUQtRootCbfSCModel.get( 0 ); |
---|
1965 | |
---|
1966 | for( UInt uiCtxInc = 0; uiCtxInc < 4; uiCtxInc++ ) |
---|
1967 | { |
---|
1968 | pcEstBitsSbac->blockRootCbpBits[ uiCtxInc ][ 0 ] = pCtx[ uiCtxInc ].getEntropyBits( 0 ); |
---|
1969 | pcEstBitsSbac->blockRootCbpBits[ uiCtxInc ][ 1 ] = pCtx[ uiCtxInc ].getEntropyBits( 1 ); |
---|
1970 | } |
---|
1971 | } |
---|
1972 | |
---|
1973 | |
---|
1974 | /*! |
---|
1975 | **************************************************************************** |
---|
1976 | * \brief |
---|
1977 | * estimate SAMBAC bit cost for significant coefficient group map |
---|
1978 | **************************************************************************** |
---|
1979 | */ |
---|
1980 | Void TEncSbac::estSignificantCoeffGroupMapBit( estBitsSbacStruct* pcEstBitsSbac, TextType eTType ) |
---|
1981 | { |
---|
1982 | Int firstCtx = 0, numCtx = NUM_SIG_CG_FLAG_CTX; |
---|
1983 | |
---|
1984 | for ( Int ctxIdx = firstCtx; ctxIdx < firstCtx + numCtx; ctxIdx++ ) |
---|
1985 | { |
---|
1986 | for( UInt uiBin = 0; uiBin < 2; uiBin++ ) |
---|
1987 | { |
---|
1988 | pcEstBitsSbac->significantCoeffGroupBits[ ctxIdx ][ uiBin ] = m_cCUSigCoeffGroupSCModel.get( 0, eTType, ctxIdx ).getEntropyBits( uiBin ); |
---|
1989 | } |
---|
1990 | } |
---|
1991 | } |
---|
1992 | |
---|
1993 | |
---|
1994 | /*! |
---|
1995 | **************************************************************************** |
---|
1996 | * \brief |
---|
1997 | * estimate SAMBAC bit cost for significant coefficient map |
---|
1998 | **************************************************************************** |
---|
1999 | */ |
---|
2000 | Void TEncSbac::estSignificantMapBit( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType ) |
---|
2001 | { |
---|
2002 | Int firstCtx = 1, numCtx = 8; |
---|
2003 | if (max(width, height) >= 16) |
---|
2004 | { |
---|
2005 | firstCtx = (eTType == TEXT_LUMA) ? 21 : 12; |
---|
2006 | numCtx = (eTType == TEXT_LUMA) ? 6 : 3; |
---|
2007 | } |
---|
2008 | else if (width == 8) |
---|
2009 | { |
---|
2010 | firstCtx = 9; |
---|
2011 | numCtx = (eTType == TEXT_LUMA) ? 12 : 3; |
---|
2012 | } |
---|
2013 | |
---|
2014 | if (eTType == TEXT_LUMA ) |
---|
2015 | { |
---|
2016 | for( UInt bin = 0; bin < 2; bin++ ) |
---|
2017 | { |
---|
2018 | pcEstBitsSbac->significantBits[ 0 ][ bin ] = m_cCUSigSCModel.get( 0, 0, 0 ).getEntropyBits( bin ); |
---|
2019 | } |
---|
2020 | |
---|
2021 | for ( Int ctxIdx = firstCtx; ctxIdx < firstCtx + numCtx; ctxIdx++ ) |
---|
2022 | { |
---|
2023 | for( UInt uiBin = 0; uiBin < 2; uiBin++ ) |
---|
2024 | { |
---|
2025 | pcEstBitsSbac->significantBits[ ctxIdx ][ uiBin ] = m_cCUSigSCModel.get( 0, 0, ctxIdx ).getEntropyBits( uiBin ); |
---|
2026 | } |
---|
2027 | } |
---|
2028 | } |
---|
2029 | else |
---|
2030 | { |
---|
2031 | for( UInt bin = 0; bin < 2; bin++ ) |
---|
2032 | { |
---|
2033 | pcEstBitsSbac->significantBits[ 0 ][ bin ] = m_cCUSigSCModel.get( 0, 0, NUM_SIG_FLAG_CTX_LUMA + 0 ).getEntropyBits( bin ); |
---|
2034 | } |
---|
2035 | for ( Int ctxIdx = firstCtx; ctxIdx < firstCtx + numCtx; ctxIdx++ ) |
---|
2036 | { |
---|
2037 | for( UInt uiBin = 0; uiBin < 2; uiBin++ ) |
---|
2038 | { |
---|
2039 | pcEstBitsSbac->significantBits[ ctxIdx ][ uiBin ] = m_cCUSigSCModel.get( 0, 0, NUM_SIG_FLAG_CTX_LUMA + ctxIdx ).getEntropyBits( uiBin ); |
---|
2040 | } |
---|
2041 | } |
---|
2042 | } |
---|
2043 | Int iBitsX = 0, iBitsY = 0; |
---|
2044 | Int blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY; |
---|
2045 | |
---|
2046 | blkSizeOffsetX = eTType ? 0: (g_aucConvertToBit[ width ] *3 + ((g_aucConvertToBit[ width ] +1)>>2)); |
---|
2047 | blkSizeOffsetY = eTType ? 0: (g_aucConvertToBit[ height ]*3 + ((g_aucConvertToBit[ height ]+1)>>2)); |
---|
2048 | shiftX = eTType ? g_aucConvertToBit[ width ] :((g_aucConvertToBit[ width ]+3)>>2); |
---|
2049 | shiftY = eTType ? g_aucConvertToBit[ height ] :((g_aucConvertToBit[ height ]+3)>>2); |
---|
2050 | |
---|
2051 | Int ctx; |
---|
2052 | ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); |
---|
2053 | for (ctx = 0; ctx < g_uiGroupIdx[ width - 1 ]; ctx++) |
---|
2054 | { |
---|
2055 | Int ctxOffset = blkSizeOffsetX + (ctx >>shiftX); |
---|
2056 | pcEstBitsSbac->lastXBits[ ctx ] = iBitsX + pCtxX[ ctxOffset ].getEntropyBits( 0 ); |
---|
2057 | iBitsX += pCtxX[ ctxOffset ].getEntropyBits( 1 ); |
---|
2058 | } |
---|
2059 | pcEstBitsSbac->lastXBits[ctx] = iBitsX; |
---|
2060 | ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); |
---|
2061 | for (ctx = 0; ctx < g_uiGroupIdx[ height - 1 ]; ctx++) |
---|
2062 | { |
---|
2063 | Int ctxOffset = blkSizeOffsetY + (ctx >>shiftY); |
---|
2064 | pcEstBitsSbac->lastYBits[ ctx ] = iBitsY + pCtxY[ ctxOffset ].getEntropyBits( 0 ); |
---|
2065 | iBitsY += pCtxY[ ctxOffset ].getEntropyBits( 1 ); |
---|
2066 | } |
---|
2067 | pcEstBitsSbac->lastYBits[ctx] = iBitsY; |
---|
2068 | } |
---|
2069 | |
---|
2070 | /*! |
---|
2071 | **************************************************************************** |
---|
2072 | * \brief |
---|
2073 | * estimate bit cost of significant coefficient |
---|
2074 | **************************************************************************** |
---|
2075 | */ |
---|
2076 | Void TEncSbac::estSignificantCoefficientsBit( estBitsSbacStruct* pcEstBitsSbac, TextType eTType ) |
---|
2077 | { |
---|
2078 | if (eTType==TEXT_LUMA) |
---|
2079 | { |
---|
2080 | ContextModel *ctxOne = m_cCUOneSCModel.get(0, 0); |
---|
2081 | ContextModel *ctxAbs = m_cCUAbsSCModel.get(0, 0); |
---|
2082 | |
---|
2083 | for (Int ctxIdx = 0; ctxIdx < NUM_ONE_FLAG_CTX_LUMA; ctxIdx++) |
---|
2084 | { |
---|
2085 | pcEstBitsSbac->m_greaterOneBits[ ctxIdx ][ 0 ] = ctxOne[ ctxIdx ].getEntropyBits( 0 ); |
---|
2086 | pcEstBitsSbac->m_greaterOneBits[ ctxIdx ][ 1 ] = ctxOne[ ctxIdx ].getEntropyBits( 1 ); |
---|
2087 | } |
---|
2088 | |
---|
2089 | for (Int ctxIdx = 0; ctxIdx < NUM_ABS_FLAG_CTX_LUMA; ctxIdx++) |
---|
2090 | { |
---|
2091 | pcEstBitsSbac->m_levelAbsBits[ ctxIdx ][ 0 ] = ctxAbs[ ctxIdx ].getEntropyBits( 0 ); |
---|
2092 | pcEstBitsSbac->m_levelAbsBits[ ctxIdx ][ 1 ] = ctxAbs[ ctxIdx ].getEntropyBits( 1 ); |
---|
2093 | } |
---|
2094 | } |
---|
2095 | else |
---|
2096 | { |
---|
2097 | ContextModel *ctxOne = m_cCUOneSCModel.get(0, 0) + NUM_ONE_FLAG_CTX_LUMA; |
---|
2098 | ContextModel *ctxAbs = m_cCUAbsSCModel.get(0, 0) + NUM_ABS_FLAG_CTX_LUMA; |
---|
2099 | |
---|
2100 | for (Int ctxIdx = 0; ctxIdx < NUM_ONE_FLAG_CTX_CHROMA; ctxIdx++) |
---|
2101 | { |
---|
2102 | pcEstBitsSbac->m_greaterOneBits[ ctxIdx ][ 0 ] = ctxOne[ ctxIdx ].getEntropyBits( 0 ); |
---|
2103 | pcEstBitsSbac->m_greaterOneBits[ ctxIdx ][ 1 ] = ctxOne[ ctxIdx ].getEntropyBits( 1 ); |
---|
2104 | } |
---|
2105 | |
---|
2106 | for (Int ctxIdx = 0; ctxIdx < NUM_ABS_FLAG_CTX_CHROMA; ctxIdx++) |
---|
2107 | { |
---|
2108 | pcEstBitsSbac->m_levelAbsBits[ ctxIdx ][ 0 ] = ctxAbs[ ctxIdx ].getEntropyBits( 0 ); |
---|
2109 | pcEstBitsSbac->m_levelAbsBits[ ctxIdx ][ 1 ] = ctxAbs[ ctxIdx ].getEntropyBits( 1 ); |
---|
2110 | } |
---|
2111 | } |
---|
2112 | } |
---|
2113 | |
---|
2114 | /** |
---|
2115 | - Initialize our context information from the nominated source. |
---|
2116 | . |
---|
2117 | \param pSrc From where to copy context information. |
---|
2118 | */ |
---|
2119 | Void TEncSbac::xCopyContextsFrom( TEncSbac* pSrc ) |
---|
2120 | { |
---|
2121 | memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0])); |
---|
2122 | } |
---|
2123 | |
---|
2124 | Void TEncSbac::loadContexts ( TEncSbac* pScr) |
---|
2125 | { |
---|
2126 | this->xCopyContextsFrom(pScr); |
---|
2127 | } |
---|
2128 | |
---|
2129 | Void TEncSbac::codeSAOOffsetParam(Int compIdx, SAOOffset& ctbParam, Bool sliceEnabled) |
---|
2130 | { |
---|
2131 | UInt uiSymbol; |
---|
2132 | if(!sliceEnabled) |
---|
2133 | { |
---|
2134 | assert(ctbParam.modeIdc == SAO_MODE_OFF); |
---|
2135 | return; |
---|
2136 | } |
---|
2137 | |
---|
2138 | //type |
---|
2139 | if(compIdx == SAO_Y || compIdx == SAO_Cb) |
---|
2140 | { |
---|
2141 | //sao_type_idx_luma or sao_type_idx_chroma |
---|
2142 | if(ctbParam.modeIdc == SAO_MODE_OFF) |
---|
2143 | { |
---|
2144 | uiSymbol =0; |
---|
2145 | } |
---|
2146 | else if(ctbParam.typeIdc == SAO_TYPE_BO) //BO |
---|
2147 | { |
---|
2148 | uiSymbol = 1; |
---|
2149 | } |
---|
2150 | else |
---|
2151 | { |
---|
2152 | assert(ctbParam.typeIdc < SAO_TYPE_START_BO); //EO |
---|
2153 | uiSymbol = 2; |
---|
2154 | } |
---|
2155 | codeSaoTypeIdx(uiSymbol); |
---|
2156 | } |
---|
2157 | |
---|
2158 | if(ctbParam.modeIdc == SAO_MODE_NEW) |
---|
2159 | { |
---|
2160 | Int numClasses = (ctbParam.typeIdc == SAO_TYPE_BO)?4:NUM_SAO_EO_CLASSES; |
---|
2161 | Int offset[4]; |
---|
2162 | Int k=0; |
---|
2163 | for(Int i=0; i< numClasses; i++) |
---|
2164 | { |
---|
2165 | if(ctbParam.typeIdc != SAO_TYPE_BO && i == SAO_CLASS_EO_PLAIN) |
---|
2166 | { |
---|
2167 | continue; |
---|
2168 | } |
---|
2169 | Int classIdx = (ctbParam.typeIdc == SAO_TYPE_BO)?( (ctbParam.typeAuxInfo+i)% NUM_SAO_BO_CLASSES ):i; |
---|
2170 | offset[k] = ctbParam.offset[classIdx]; |
---|
2171 | k++; |
---|
2172 | } |
---|
2173 | |
---|
2174 | for(Int i=0; i< 4; i++) |
---|
2175 | { |
---|
2176 | codeSaoMaxUvlc((offset[i]<0)?(-offset[i]):(offset[i]), g_saoMaxOffsetQVal[compIdx] ); //sao_offset_abs |
---|
2177 | } |
---|
2178 | |
---|
2179 | |
---|
2180 | if(ctbParam.typeIdc == SAO_TYPE_BO) |
---|
2181 | { |
---|
2182 | for(Int i=0; i< 4; i++) |
---|
2183 | { |
---|
2184 | if(offset[i] != 0) |
---|
2185 | { |
---|
2186 | codeSAOSign((offset[i]< 0)?1:0); |
---|
2187 | } |
---|
2188 | } |
---|
2189 | |
---|
2190 | codeSaoUflc(NUM_SAO_BO_CLASSES_LOG2, ctbParam.typeAuxInfo ); //sao_band_position |
---|
2191 | } |
---|
2192 | else //EO |
---|
2193 | { |
---|
2194 | if(compIdx == SAO_Y || compIdx == SAO_Cb) |
---|
2195 | { |
---|
2196 | assert(ctbParam.typeIdc - SAO_TYPE_START_EO >=0); |
---|
2197 | codeSaoUflc(NUM_SAO_EO_TYPES_LOG2, ctbParam.typeIdc - SAO_TYPE_START_EO ); //sao_eo_class_luma or sao_eo_class_chroma |
---|
2198 | } |
---|
2199 | } |
---|
2200 | |
---|
2201 | } |
---|
2202 | } |
---|
2203 | |
---|
2204 | |
---|
2205 | Void TEncSbac::codeSAOBlkParam(SAOBlkParam& saoBlkParam |
---|
2206 | , Bool* sliceEnabled |
---|
2207 | , Bool leftMergeAvail |
---|
2208 | , Bool aboveMergeAvail |
---|
2209 | , Bool onlyEstMergeInfo // = false |
---|
2210 | ) |
---|
2211 | { |
---|
2212 | |
---|
2213 | Bool isLeftMerge = false; |
---|
2214 | Bool isAboveMerge= false; |
---|
2215 | |
---|
2216 | if(leftMergeAvail) |
---|
2217 | { |
---|
2218 | isLeftMerge = ((saoBlkParam[SAO_Y].modeIdc == SAO_MODE_MERGE) && (saoBlkParam[SAO_Y].typeIdc == SAO_MERGE_LEFT)); |
---|
2219 | codeSaoMerge( isLeftMerge?1:0 ); //sao_merge_left_flag |
---|
2220 | } |
---|
2221 | |
---|
2222 | if( aboveMergeAvail && !isLeftMerge) |
---|
2223 | { |
---|
2224 | isAboveMerge = ((saoBlkParam[SAO_Y].modeIdc == SAO_MODE_MERGE) && (saoBlkParam[SAO_Y].typeIdc == SAO_MERGE_ABOVE)); |
---|
2225 | codeSaoMerge( isAboveMerge?1:0 ); //sao_merge_left_flag |
---|
2226 | } |
---|
2227 | |
---|
2228 | if(onlyEstMergeInfo) |
---|
2229 | { |
---|
2230 | return; //only for RDO |
---|
2231 | } |
---|
2232 | |
---|
2233 | if(!isLeftMerge && !isAboveMerge) //not merge mode |
---|
2234 | { |
---|
2235 | for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) |
---|
2236 | { |
---|
2237 | codeSAOOffsetParam(compIdx, saoBlkParam[compIdx], sliceEnabled[compIdx]); |
---|
2238 | } |
---|
2239 | } |
---|
2240 | } |
---|
2241 | |
---|
2242 | #if H_3D_INTER_SDC |
---|
2243 | Void TEncSbac::codeDeltaDC( TComDataCU* pcCU, UInt absPartIdx ) |
---|
2244 | { |
---|
2245 | if( !( pcCU->getSDCFlag( absPartIdx ) || ( pcCU->isIntra( absPartIdx ) && getDimType( pcCU->getLumaIntraDir( absPartIdx ) ) < DIM_NUM_TYPE ) ) ) |
---|
2246 | { |
---|
2247 | assert( 0 ); |
---|
2248 | } |
---|
2249 | |
---|
2250 | UInt uiNumSegments = isDimMode( pcCU->getLumaIntraDir( absPartIdx ) ) ? 2 : 1; |
---|
2251 | UInt dimDeltaDC = 1; |
---|
2252 | |
---|
2253 | if( pcCU->isIntra( absPartIdx ) && pcCU->getSDCFlag( absPartIdx )) |
---|
2254 | { |
---|
2255 | if( uiNumSegments == 1 ) |
---|
2256 | { |
---|
2257 | dimDeltaDC = pcCU->getSDCSegmentDCOffset( 0, absPartIdx ) ? 1 : 0; |
---|
2258 | } |
---|
2259 | else |
---|
2260 | { |
---|
2261 | dimDeltaDC = ( pcCU->getSDCSegmentDCOffset( 0, absPartIdx ) || pcCU->getSDCSegmentDCOffset( 1, absPartIdx ) ) ? 1 : 0; |
---|
2262 | } |
---|
2263 | m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get( 0, 0, 0 ) ); |
---|
2264 | } |
---|
2265 | |
---|
2266 | if( dimDeltaDC ) |
---|
2267 | { |
---|
2268 | for( UInt segment = 0; segment < uiNumSegments; segment++ ) |
---|
2269 | { |
---|
2270 | Pel deltaDC = 0; |
---|
2271 | |
---|
2272 | if( pcCU->isIntra( absPartIdx ) ) |
---|
2273 | { |
---|
2274 | UInt dir = pcCU->getLumaIntraDir( absPartIdx ); |
---|
2275 | deltaDC = pcCU->getSDCFlag( absPartIdx ) ? pcCU->getSDCSegmentDCOffset( segment, absPartIdx ) : pcCU->getDimDeltaDC( getDimType( dir ), segment, absPartIdx ); |
---|
2276 | } |
---|
2277 | else |
---|
2278 | { |
---|
2279 | deltaDC = pcCU->getSDCSegmentDCOffset( segment, absPartIdx ); |
---|
2280 | } |
---|
2281 | |
---|
2282 | xCodeDimDeltaDC( deltaDC, uiNumSegments ); |
---|
2283 | } |
---|
2284 | } |
---|
2285 | } |
---|
2286 | |
---|
2287 | Void TEncSbac::codeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
2288 | { |
---|
2289 | UInt uiSymbol = pcCU->getSDCFlag( uiAbsPartIdx ) ? 1 : 0; |
---|
2290 | UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx ); |
---|
2291 | |
---|
2292 | m_pcBinIf->encodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) ); |
---|
2293 | } |
---|
2294 | |
---|
2295 | #endif |
---|
2296 | |
---|
2297 | #if H_3D_DBBP |
---|
2298 | Void TEncSbac::codeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
2299 | { |
---|
2300 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
2301 | AOF( ePartSize == SIZE_2NxN || ePartSize == SIZE_Nx2N ); |
---|
2302 | AOF( pcCU->getSlice()->getDepthBasedBlkPartFlag() ); |
---|
2303 | AOF( !pcCU->getSlice()->getIsDepth() ); |
---|
2304 | |
---|
2305 | UInt uiSymbol = pcCU->getDBBPFlag( uiAbsPartIdx ) ? 1 : 0; |
---|
2306 | m_pcBinIf->encodeBin( uiSymbol, m_cDBBPFlagSCModel.get( 0, 0, 0 ) ); |
---|
2307 | } |
---|
2308 | #endif |
---|
2309 | |
---|
2310 | //! \} |
---|