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-2015, 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 TEncEntropy.cpp |
---|
35 | \brief entropy encoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TEncEntropy.h" |
---|
39 | #include "TLibCommon/TypeDef.h" |
---|
40 | #include "TLibCommon/TComSampleAdaptiveOffset.h" |
---|
41 | |
---|
42 | //! \ingroup TLibEncoder |
---|
43 | //! \{ |
---|
44 | |
---|
45 | Void TEncEntropy::setEntropyCoder ( TEncEntropyIf* e, TComSlice* pcSlice ) |
---|
46 | { |
---|
47 | m_pcEntropyCoderIf = e; |
---|
48 | m_pcEntropyCoderIf->setSlice ( pcSlice ); |
---|
49 | } |
---|
50 | |
---|
51 | Void TEncEntropy::encodeSliceHeader ( TComSlice* pcSlice ) |
---|
52 | { |
---|
53 | m_pcEntropyCoderIf->codeSliceHeader( pcSlice ); |
---|
54 | return; |
---|
55 | } |
---|
56 | |
---|
57 | Void TEncEntropy::encodeTilesWPPEntryPoint( TComSlice* pSlice ) |
---|
58 | { |
---|
59 | m_pcEntropyCoderIf->codeTilesWPPEntryPoint( pSlice ); |
---|
60 | } |
---|
61 | |
---|
62 | Void TEncEntropy::encodeTerminatingBit ( UInt uiIsLast ) |
---|
63 | { |
---|
64 | m_pcEntropyCoderIf->codeTerminatingBit( uiIsLast ); |
---|
65 | |
---|
66 | return; |
---|
67 | } |
---|
68 | |
---|
69 | Void TEncEntropy::encodeSliceFinish() |
---|
70 | { |
---|
71 | m_pcEntropyCoderIf->codeSliceFinish(); |
---|
72 | } |
---|
73 | |
---|
74 | Void TEncEntropy::encodePPS( TComPPS* pcPPS ) |
---|
75 | { |
---|
76 | m_pcEntropyCoderIf->codePPS( pcPPS ); |
---|
77 | return; |
---|
78 | } |
---|
79 | |
---|
80 | Void TEncEntropy::encodeSPS( TComSPS* pcSPS ) |
---|
81 | { |
---|
82 | m_pcEntropyCoderIf->codeSPS( pcSPS ); |
---|
83 | return; |
---|
84 | } |
---|
85 | |
---|
86 | Void TEncEntropy::encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
87 | { |
---|
88 | if( bRD ) |
---|
89 | { |
---|
90 | uiAbsPartIdx = 0; |
---|
91 | } |
---|
92 | m_pcEntropyCoderIf->codeCUTransquantBypassFlag( pcCU, uiAbsPartIdx ); |
---|
93 | } |
---|
94 | |
---|
95 | Void TEncEntropy::encodeVPS( TComVPS* pcVPS ) |
---|
96 | { |
---|
97 | m_pcEntropyCoderIf->codeVPS( pcVPS ); |
---|
98 | return; |
---|
99 | } |
---|
100 | |
---|
101 | Void TEncEntropy::encodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
102 | { |
---|
103 | if ( pcCU->getSlice()->isIntra() ) |
---|
104 | { |
---|
105 | return; |
---|
106 | } |
---|
107 | if( bRD ) |
---|
108 | { |
---|
109 | uiAbsPartIdx = 0; |
---|
110 | } |
---|
111 | m_pcEntropyCoderIf->codeSkipFlag( pcCU, uiAbsPartIdx ); |
---|
112 | } |
---|
113 | |
---|
114 | #if SEC_DEPTH_INTRA_SKIP_MODE_K0033 |
---|
115 | Void TEncEntropy::encodeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
116 | { |
---|
117 | if ( !pcCU->getSlice()->getIsDepth() ) |
---|
118 | { |
---|
119 | return; |
---|
120 | } |
---|
121 | if( bRD ) |
---|
122 | { |
---|
123 | uiAbsPartIdx = 0; |
---|
124 | } |
---|
125 | m_pcEntropyCoderIf->codeDIS( pcCU, uiAbsPartIdx ); |
---|
126 | } |
---|
127 | #else |
---|
128 | #if H_3D_SINGLE_DEPTH |
---|
129 | Void TEncEntropy::encodeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
130 | { |
---|
131 | if(!pcCU->getSlice()->getIntraSingleFlag() ) |
---|
132 | { |
---|
133 | return; |
---|
134 | } |
---|
135 | if( bRD ) |
---|
136 | { |
---|
137 | uiAbsPartIdx = 0; |
---|
138 | } |
---|
139 | m_pcEntropyCoderIf->codeSingleDepthMode( pcCU, uiAbsPartIdx ); |
---|
140 | } |
---|
141 | #endif |
---|
142 | #endif |
---|
143 | |
---|
144 | /** encode merge flag |
---|
145 | * \param pcCU |
---|
146 | * \param uiAbsPartIdx |
---|
147 | * \returns Void |
---|
148 | */ |
---|
149 | Void TEncEntropy::encodeMergeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
150 | { |
---|
151 | // at least one merge candidate exists |
---|
152 | m_pcEntropyCoderIf->codeMergeFlag( pcCU, uiAbsPartIdx ); |
---|
153 | } |
---|
154 | |
---|
155 | /** encode merge index |
---|
156 | * \param pcCU |
---|
157 | * \param uiAbsPartIdx |
---|
158 | * \param uiPUIdx |
---|
159 | * \param bRD |
---|
160 | * \returns Void |
---|
161 | */ |
---|
162 | Void TEncEntropy::encodeMergeIndex( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
163 | { |
---|
164 | if( bRD ) |
---|
165 | { |
---|
166 | uiAbsPartIdx = 0; |
---|
167 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
168 | } |
---|
169 | m_pcEntropyCoderIf->codeMergeIndex( pcCU, uiAbsPartIdx ); |
---|
170 | } |
---|
171 | |
---|
172 | #if H_3D_IC |
---|
173 | Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
174 | { |
---|
175 | if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 ) |
---|
176 | { |
---|
177 | return; |
---|
178 | } |
---|
179 | |
---|
180 | if( !pcCU->getSlice()->getApplyIC() ) |
---|
181 | { |
---|
182 | return; |
---|
183 | } |
---|
184 | |
---|
185 | if( bRD ) |
---|
186 | { |
---|
187 | uiAbsPartIdx = 0; |
---|
188 | } |
---|
189 | else |
---|
190 | { |
---|
191 | Int ICEnableCandidate = pcCU->getSlice()->getICEnableCandidate(pcCU->getSlice()->getDepth()); |
---|
192 | Int ICEnableNum = pcCU->getSlice()->getICEnableNum(pcCU->getSlice()->getDepth()); |
---|
193 | ICEnableCandidate++; |
---|
194 | if(pcCU->getICFlag(uiAbsPartIdx)) |
---|
195 | { |
---|
196 | ICEnableNum++; |
---|
197 | } |
---|
198 | pcCU->getSlice()->setICEnableCandidate(pcCU->getSlice()->getDepth(), ICEnableCandidate); |
---|
199 | pcCU->getSlice()->setICEnableNum(pcCU->getSlice()->getDepth(), ICEnableNum); |
---|
200 | } |
---|
201 | if( pcCU->isICFlagRequired( uiAbsPartIdx ) ) |
---|
202 | { |
---|
203 | m_pcEntropyCoderIf->codeICFlag( pcCU, uiAbsPartIdx ); |
---|
204 | } |
---|
205 | } |
---|
206 | #endif |
---|
207 | |
---|
208 | #if H_3D_ARP |
---|
209 | Void TEncEntropy::encodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
210 | { |
---|
211 | if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) ) |
---|
212 | { |
---|
213 | return; |
---|
214 | } |
---|
215 | |
---|
216 | if ( pcCU->getPartitionSize(uiAbsPartIdx)!=SIZE_2Nx2N ) |
---|
217 | { |
---|
218 | assert(pcCU->getARPW (uiAbsPartIdx) == 0); |
---|
219 | } |
---|
220 | else |
---|
221 | { |
---|
222 | m_pcEntropyCoderIf->codeARPW( pcCU, uiAbsPartIdx ); |
---|
223 | } |
---|
224 | } |
---|
225 | #endif |
---|
226 | |
---|
227 | /** encode prediction mode |
---|
228 | * \param pcCU |
---|
229 | * \param uiAbsPartIdx |
---|
230 | * \param bRD |
---|
231 | * \returns Void |
---|
232 | */ |
---|
233 | Void TEncEntropy::encodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
234 | { |
---|
235 | if( bRD ) |
---|
236 | { |
---|
237 | uiAbsPartIdx = 0; |
---|
238 | } |
---|
239 | if ( pcCU->getSlice()->isIntra() ) |
---|
240 | { |
---|
241 | return; |
---|
242 | } |
---|
243 | |
---|
244 | m_pcEntropyCoderIf->codePredMode( pcCU, uiAbsPartIdx ); |
---|
245 | } |
---|
246 | |
---|
247 | // Split mode |
---|
248 | Void TEncEntropy::encodeSplitFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD ) |
---|
249 | { |
---|
250 | if( bRD ) |
---|
251 | { |
---|
252 | uiAbsPartIdx = 0; |
---|
253 | } |
---|
254 | m_pcEntropyCoderIf->codeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
255 | } |
---|
256 | |
---|
257 | /** encode partition size |
---|
258 | * \param pcCU |
---|
259 | * \param uiAbsPartIdx |
---|
260 | * \param uiDepth |
---|
261 | * \param bRD |
---|
262 | * \returns Void |
---|
263 | */ |
---|
264 | Void TEncEntropy::encodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD ) |
---|
265 | { |
---|
266 | if( bRD ) |
---|
267 | { |
---|
268 | uiAbsPartIdx = 0; |
---|
269 | } |
---|
270 | |
---|
271 | m_pcEntropyCoderIf->codePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
272 | |
---|
273 | #if !HHI_MOVE_SYN_K0052 |
---|
274 | #if H_3D_DBBP |
---|
275 | if( pcCU->getSlice()->getDepthBasedBlkPartFlag() && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 && pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() ) |
---|
276 | { |
---|
277 | encodeDBBPFlag(pcCU, uiAbsPartIdx, bRD); |
---|
278 | } |
---|
279 | #endif |
---|
280 | #endif |
---|
281 | } |
---|
282 | |
---|
283 | /** Encode I_PCM information. |
---|
284 | * \param pcCU pointer to CU |
---|
285 | * \param uiAbsPartIdx CU index |
---|
286 | * \param bRD flag indicating estimation or encoding |
---|
287 | * \returns Void |
---|
288 | */ |
---|
289 | Void TEncEntropy::encodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
290 | { |
---|
291 | if(!pcCU->getSlice()->getSPS()->getUsePCM() |
---|
292 | || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize()) |
---|
293 | || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize())) |
---|
294 | { |
---|
295 | return; |
---|
296 | } |
---|
297 | |
---|
298 | if( bRD ) |
---|
299 | { |
---|
300 | uiAbsPartIdx = 0; |
---|
301 | } |
---|
302 | |
---|
303 | m_pcEntropyCoderIf->codeIPCMInfo ( pcCU, uiAbsPartIdx ); |
---|
304 | } |
---|
305 | |
---|
306 | #if H_3D_DISABLE_CHROMA |
---|
307 | Void TEncEntropy::xEncodeTransform( TComDataCU* pcCU,UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Bool rd ) |
---|
308 | #else |
---|
309 | Void TEncEntropy::xEncodeTransform( TComDataCU* pcCU,UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP ) |
---|
310 | #endif |
---|
311 | { |
---|
312 | |
---|
313 | #if H_MV_ENC_DEC_TRAC |
---|
314 | #if ENC_DEC_TRACE |
---|
315 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
316 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
317 | |
---|
318 | DTRACE_TU_S("=========== transform_tree ===========\n") |
---|
319 | DTRACE_TU("x0", uiLPelX) |
---|
320 | DTRACE_TU("x1", uiTPelY) |
---|
321 | DTRACE_TU("log2TrafoSize", g_uiMaxCUWidth>>uiDepth) |
---|
322 | DTRACE_TU("trafoDepth" , uiDepth) |
---|
323 | #endif |
---|
324 | #endif |
---|
325 | |
---|
326 | const UInt uiSubdiv = pcCU->getTransformIdx( uiAbsPartIdx ) + pcCU->getDepth( uiAbsPartIdx ) > uiDepth; |
---|
327 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; |
---|
328 | UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA , uiTrIdx ); |
---|
329 | UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
330 | UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
331 | #if H_3D_DISABLE_CHROMA |
---|
332 | if( !rd && pcCU->getSlice()->getSPS()->getChromaFormatIdc() == 0 ) |
---|
333 | { |
---|
334 | cbfU = 0; |
---|
335 | cbfV = 0; |
---|
336 | } |
---|
337 | #endif |
---|
338 | if(uiTrIdx==0) |
---|
339 | { |
---|
340 | m_bakAbsPartIdxCU = uiAbsPartIdx; |
---|
341 | } |
---|
342 | if( uiLog2TrafoSize == 2 ) |
---|
343 | { |
---|
344 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
345 | if( ( uiAbsPartIdx % partNum ) == 0 ) |
---|
346 | { |
---|
347 | m_uiBakAbsPartIdx = uiAbsPartIdx; |
---|
348 | m_uiBakChromaOffset = offsetChroma; |
---|
349 | } |
---|
350 | else if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
351 | { |
---|
352 | cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
353 | cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
354 | #if H_3D_DISABLE_CHROMA |
---|
355 | if( !rd && pcCU->getSlice()->getSPS()->getChromaFormatIdc() == 0 ) |
---|
356 | { |
---|
357 | cbfU = 0; |
---|
358 | cbfV = 0; |
---|
359 | } |
---|
360 | #endif |
---|
361 | } |
---|
362 | } |
---|
363 | |
---|
364 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) |
---|
365 | { |
---|
366 | assert( uiSubdiv ); |
---|
367 | } |
---|
368 | else if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && (pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N) && uiDepth == pcCU->getDepth(uiAbsPartIdx) && (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) ) |
---|
369 | { |
---|
370 | if ( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) |
---|
371 | { |
---|
372 | assert( uiSubdiv ); |
---|
373 | } |
---|
374 | else |
---|
375 | { |
---|
376 | assert(!uiSubdiv ); |
---|
377 | } |
---|
378 | } |
---|
379 | else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
380 | { |
---|
381 | assert( uiSubdiv ); |
---|
382 | } |
---|
383 | else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
384 | { |
---|
385 | assert( !uiSubdiv ); |
---|
386 | } |
---|
387 | else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) |
---|
388 | { |
---|
389 | assert( !uiSubdiv ); |
---|
390 | } |
---|
391 | else |
---|
392 | { |
---|
393 | assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ); |
---|
394 | m_pcEntropyCoderIf->codeTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize ); |
---|
395 | } |
---|
396 | |
---|
397 | const UInt uiTrDepthCurr = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
398 | const Bool bFirstCbfOfCU = uiTrDepthCurr == 0; |
---|
399 | if( bFirstCbfOfCU || uiLog2TrafoSize > 2 ) |
---|
400 | { |
---|
401 | #if H_3D_DISABLE_CHROMA |
---|
402 | if (pcCU->getSlice()->getSPS()->getChromaFormatIdc() != 0 || rd) |
---|
403 | { |
---|
404 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) ) |
---|
405 | { |
---|
406 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ); |
---|
407 | } |
---|
408 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) ) |
---|
409 | { |
---|
410 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ); |
---|
411 | } |
---|
412 | } |
---|
413 | #else |
---|
414 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) ) |
---|
415 | { |
---|
416 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ); |
---|
417 | } |
---|
418 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) ) |
---|
419 | { |
---|
420 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ); |
---|
421 | } |
---|
422 | #endif |
---|
423 | } |
---|
424 | else if( uiLog2TrafoSize == 2 ) |
---|
425 | { |
---|
426 | #if H_3D_DISABLE_CHROMA |
---|
427 | if ( rd && pcCU->getSlice()->getSPS()->getChromaFormatIdc() != 0 ) |
---|
428 | { |
---|
429 | assert( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) ); |
---|
430 | assert( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) ); |
---|
431 | } |
---|
432 | #else |
---|
433 | assert( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) ); |
---|
434 | assert( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) ); |
---|
435 | #endif |
---|
436 | } |
---|
437 | |
---|
438 | if( uiSubdiv ) |
---|
439 | { |
---|
440 | UInt size; |
---|
441 | width >>= 1; |
---|
442 | height >>= 1; |
---|
443 | size = width*height; |
---|
444 | uiTrIdx++; |
---|
445 | ++uiDepth; |
---|
446 | const UInt partNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
447 | |
---|
448 | #if H_3D_DISABLE_CHROMA |
---|
449 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, rd ); |
---|
450 | |
---|
451 | uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); |
---|
452 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ,rd ); |
---|
453 | |
---|
454 | uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); |
---|
455 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, rd ); |
---|
456 | |
---|
457 | uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); |
---|
458 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, rd ); |
---|
459 | #else |
---|
460 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); |
---|
461 | |
---|
462 | uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); |
---|
463 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); |
---|
464 | |
---|
465 | uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); |
---|
466 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); |
---|
467 | |
---|
468 | uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); |
---|
469 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); |
---|
470 | #endif |
---|
471 | } |
---|
472 | else |
---|
473 | { |
---|
474 | #if !H_MV_ENC_DEC_TRAC |
---|
475 | { |
---|
476 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
477 | DTRACE_CABAC_T( "\tTrIdx: abspart=" ); |
---|
478 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
479 | DTRACE_CABAC_T( "\tdepth=" ); |
---|
480 | DTRACE_CABAC_V( uiDepth ); |
---|
481 | DTRACE_CABAC_T( "\ttrdepth=" ); |
---|
482 | DTRACE_CABAC_V( pcCU->getTransformIdx( uiAbsPartIdx ) ); |
---|
483 | DTRACE_CABAC_T( "\n" ); |
---|
484 | } |
---|
485 | #endif |
---|
486 | |
---|
487 | #if H_3D_DISABLE_CHROMA |
---|
488 | Bool notcbfUV = !rd && pcCU->getSlice()->getSPS()->getChromaFormatIdc() == 0 ? 1 : ( !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) ; |
---|
489 | if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && |
---|
490 | uiDepth == pcCU->getDepth( uiAbsPartIdx ) && notcbfUV ) |
---|
491 | #else |
---|
492 | if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) |
---|
493 | #endif |
---|
494 | { |
---|
495 | assert( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, 0 ) ); |
---|
496 | // printf( "saved one bin! " ); |
---|
497 | } |
---|
498 | else |
---|
499 | { |
---|
500 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, pcCU->getTransformIdx( uiAbsPartIdx ) ); |
---|
501 | } |
---|
502 | |
---|
503 | |
---|
504 | if ( cbfY || cbfU || cbfV ) |
---|
505 | { |
---|
506 | // dQP: only for LCU once |
---|
507 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
508 | { |
---|
509 | if ( bCodeDQP ) |
---|
510 | { |
---|
511 | encodeQP( pcCU, m_bakAbsPartIdxCU ); |
---|
512 | bCodeDQP = false; |
---|
513 | } |
---|
514 | } |
---|
515 | } |
---|
516 | if( cbfY ) |
---|
517 | { |
---|
518 | Int trWidth = width; |
---|
519 | Int trHeight = height; |
---|
520 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); |
---|
521 | } |
---|
522 | if( uiLog2TrafoSize > 2 ) |
---|
523 | { |
---|
524 | Int trWidth = width >> 1; |
---|
525 | Int trHeight = height >> 1; |
---|
526 | if( cbfU ) |
---|
527 | { |
---|
528 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
529 | } |
---|
530 | if( cbfV ) |
---|
531 | { |
---|
532 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
533 | } |
---|
534 | } |
---|
535 | else |
---|
536 | { |
---|
537 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
538 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
539 | { |
---|
540 | Int trWidth = width; |
---|
541 | Int trHeight = height; |
---|
542 | if( cbfU ) |
---|
543 | { |
---|
544 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
545 | } |
---|
546 | if( cbfV ) |
---|
547 | { |
---|
548 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
549 | } |
---|
550 | } |
---|
551 | } |
---|
552 | } |
---|
553 | } |
---|
554 | |
---|
555 | // Intra direction for Luma |
---|
556 | Void TEncEntropy::encodeIntraDirModeLuma ( TComDataCU* pcCU, UInt absPartIdx, Bool isMultiplePU ) |
---|
557 | { |
---|
558 | m_pcEntropyCoderIf->codeIntraDirLumaAng( pcCU, absPartIdx , isMultiplePU); |
---|
559 | } |
---|
560 | |
---|
561 | // Intra direction for Chroma |
---|
562 | Void TEncEntropy::encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
563 | { |
---|
564 | if( bRD ) |
---|
565 | { |
---|
566 | uiAbsPartIdx = 0; |
---|
567 | } |
---|
568 | |
---|
569 | m_pcEntropyCoderIf->codeIntraDirChroma( pcCU, uiAbsPartIdx ); |
---|
570 | } |
---|
571 | |
---|
572 | Void TEncEntropy::encodePredInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
573 | { |
---|
574 | if( bRD ) |
---|
575 | { |
---|
576 | uiAbsPartIdx = 0; |
---|
577 | } |
---|
578 | if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. |
---|
579 | { |
---|
580 | encodeIntraDirModeLuma ( pcCU, uiAbsPartIdx,true ); |
---|
581 | #if H_3D_DIM_SDC |
---|
582 | #if H_3D_DISABLE_CHROMA |
---|
583 | if(!pcCU->getSDCFlag(uiAbsPartIdx) && ( pcCU->getSlice()->getSPS()->getChromaFormatIdc() != 0 || bRD ) ) |
---|
584 | #else |
---|
585 | if(!pcCU->getSDCFlag(uiAbsPartIdx)) |
---|
586 | #endif |
---|
587 | #endif |
---|
588 | encodeIntraDirModeChroma( pcCU, uiAbsPartIdx, bRD ); |
---|
589 | } |
---|
590 | else // if it is Inter mode, encode motion vector and reference index |
---|
591 | { |
---|
592 | encodePUWise( pcCU, uiAbsPartIdx, bRD ); |
---|
593 | } |
---|
594 | } |
---|
595 | |
---|
596 | /** encode motion information for every PU block |
---|
597 | * \param pcCU |
---|
598 | * \param uiAbsPartIdx |
---|
599 | * \param bRD |
---|
600 | * \returns Void |
---|
601 | */ |
---|
602 | Void TEncEntropy::encodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
603 | { |
---|
604 | if ( bRD ) |
---|
605 | { |
---|
606 | uiAbsPartIdx = 0; |
---|
607 | } |
---|
608 | |
---|
609 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
610 | UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); |
---|
611 | UInt uiDepth = pcCU->getDepth( uiAbsPartIdx ); |
---|
612 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
613 | |
---|
614 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
---|
615 | { |
---|
616 | #if H_MV_ENC_DEC_TRAC |
---|
617 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
---|
618 | //Todo: |
---|
619 | //DTRACE_PU("x0", uiLPelX) |
---|
620 | //DTRACE_PU("x1", uiTPelY) |
---|
621 | #endif |
---|
622 | encodeMergeFlag( pcCU, uiSubPartIdx ); |
---|
623 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
---|
624 | { |
---|
625 | encodeMergeIndex( pcCU, uiSubPartIdx ); |
---|
626 | } |
---|
627 | else |
---|
628 | { |
---|
629 | encodeInterDirPU( pcCU, uiSubPartIdx ); |
---|
630 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
631 | { |
---|
632 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
633 | { |
---|
634 | encodeRefFrmIdxPU ( pcCU, uiSubPartIdx, RefPicList( uiRefListIdx ) ); |
---|
635 | encodeMvdPU ( pcCU, uiSubPartIdx, RefPicList( uiRefListIdx ) ); |
---|
636 | encodeMVPIdxPU ( pcCU, uiSubPartIdx, RefPicList( uiRefListIdx ) ); |
---|
637 | } |
---|
638 | } |
---|
639 | } |
---|
640 | } |
---|
641 | |
---|
642 | return; |
---|
643 | } |
---|
644 | |
---|
645 | Void TEncEntropy::encodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
646 | { |
---|
647 | if ( !pcCU->getSlice()->isInterB() ) |
---|
648 | { |
---|
649 | return; |
---|
650 | } |
---|
651 | |
---|
652 | m_pcEntropyCoderIf->codeInterDir( pcCU, uiAbsPartIdx ); |
---|
653 | return; |
---|
654 | } |
---|
655 | |
---|
656 | /** encode reference frame index for a PU block |
---|
657 | * \param pcCU |
---|
658 | * \param uiAbsPartIdx |
---|
659 | * \param eRefList |
---|
660 | * \returns Void |
---|
661 | */ |
---|
662 | Void TEncEntropy::encodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
663 | { |
---|
664 | assert( !pcCU->isIntra( uiAbsPartIdx ) ); |
---|
665 | { |
---|
666 | if ( ( pcCU->getSlice()->getNumRefIdx( eRefList ) == 1 ) ) |
---|
667 | { |
---|
668 | return; |
---|
669 | } |
---|
670 | |
---|
671 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
672 | { |
---|
673 | m_pcEntropyCoderIf->codeRefFrmIdx( pcCU, uiAbsPartIdx, eRefList ); |
---|
674 | } |
---|
675 | } |
---|
676 | |
---|
677 | return; |
---|
678 | } |
---|
679 | |
---|
680 | /** encode motion vector difference for a PU block |
---|
681 | * \param pcCU |
---|
682 | * \param uiAbsPartIdx |
---|
683 | * \param eRefList |
---|
684 | * \returns Void |
---|
685 | */ |
---|
686 | Void TEncEntropy::encodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
687 | { |
---|
688 | assert( !pcCU->isIntra( uiAbsPartIdx ) ); |
---|
689 | |
---|
690 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
691 | { |
---|
692 | m_pcEntropyCoderIf->codeMvd( pcCU, uiAbsPartIdx, eRefList ); |
---|
693 | } |
---|
694 | return; |
---|
695 | } |
---|
696 | |
---|
697 | Void TEncEntropy::encodeMVPIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
698 | { |
---|
699 | if ( (pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList )) ) |
---|
700 | { |
---|
701 | m_pcEntropyCoderIf->codeMVPIdx( pcCU, uiAbsPartIdx, eRefList ); |
---|
702 | } |
---|
703 | |
---|
704 | return; |
---|
705 | } |
---|
706 | |
---|
707 | Void TEncEntropy::encodeQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
708 | { |
---|
709 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, eType, uiTrDepth ); |
---|
710 | } |
---|
711 | |
---|
712 | Void TEncEntropy::encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) |
---|
713 | { |
---|
714 | m_pcEntropyCoderIf->codeTransformSubdivFlag( uiSymbol, uiCtx ); |
---|
715 | } |
---|
716 | |
---|
717 | Void TEncEntropy::encodeQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
718 | { |
---|
719 | m_pcEntropyCoderIf->codeQtRootCbf( pcCU, uiAbsPartIdx ); |
---|
720 | } |
---|
721 | |
---|
722 | Void TEncEntropy::encodeQtCbfZero( TComDataCU* pcCU, TextType eType, UInt uiTrDepth ) |
---|
723 | { |
---|
724 | m_pcEntropyCoderIf->codeQtCbfZero( pcCU, eType, uiTrDepth ); |
---|
725 | } |
---|
726 | Void TEncEntropy::encodeQtRootCbfZero( TComDataCU* pcCU ) |
---|
727 | { |
---|
728 | m_pcEntropyCoderIf->codeQtRootCbfZero( pcCU ); |
---|
729 | } |
---|
730 | |
---|
731 | // dQP |
---|
732 | Void TEncEntropy::encodeQP( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
733 | { |
---|
734 | if( bRD ) |
---|
735 | { |
---|
736 | uiAbsPartIdx = 0; |
---|
737 | } |
---|
738 | |
---|
739 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
740 | { |
---|
741 | m_pcEntropyCoderIf->codeDeltaQP( pcCU, uiAbsPartIdx ); |
---|
742 | } |
---|
743 | } |
---|
744 | |
---|
745 | |
---|
746 | // texture |
---|
747 | /** encode coefficients |
---|
748 | * \param pcCU |
---|
749 | * \param uiAbsPartIdx |
---|
750 | * \param uiDepth |
---|
751 | * \param uiWidth |
---|
752 | * \param uiHeight |
---|
753 | */ |
---|
754 | #if H_3D_DISABLE_CHROMA |
---|
755 | Void TEncEntropy::encodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP, Bool rd ) |
---|
756 | #else |
---|
757 | Void TEncEntropy::encodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ) |
---|
758 | #endif |
---|
759 | { |
---|
760 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
761 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
762 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
763 | #if H_3D_DIM_SDC |
---|
764 | if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx ) ) |
---|
765 | { |
---|
766 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
767 | assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); |
---|
768 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); |
---|
769 | #if H_3D_DISABLE_CHROMA |
---|
770 | if (!pcCU->getSlice()->getIsDepth() ) |
---|
771 | { |
---|
772 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); |
---|
773 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); |
---|
774 | } |
---|
775 | #else |
---|
776 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); |
---|
777 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); |
---|
778 | #endif |
---|
779 | } |
---|
780 | |
---|
781 | |
---|
782 | if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx ) ) |
---|
783 | { |
---|
784 | assert( !pcCU->isSkipped( uiAbsPartIdx ) ); |
---|
785 | assert( !pcCU->isIntra( uiAbsPartIdx) ); |
---|
786 | assert( pcCU->getSlice()->getIsDepth() ); |
---|
787 | } |
---|
788 | |
---|
789 | if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) ) |
---|
790 | { |
---|
791 | Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1; |
---|
792 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2; |
---|
793 | |
---|
794 | if( !pcCU->getSDCFlag( uiAbsPartIdx ) ) |
---|
795 | { |
---|
796 | for( Int iPart = 0; iPart < iPartNum; iPart++ ) |
---|
797 | { |
---|
798 | if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) |
---|
799 | { |
---|
800 | m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart ); |
---|
801 | } |
---|
802 | } |
---|
803 | } |
---|
804 | else |
---|
805 | { |
---|
806 | m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx ); |
---|
807 | return; |
---|
808 | } |
---|
809 | } |
---|
810 | #endif |
---|
811 | |
---|
812 | if( pcCU->isIntra(uiAbsPartIdx) ) |
---|
813 | { |
---|
814 | #if !H_MV |
---|
815 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
816 | DTRACE_CABAC_T( "\tdecodeTransformIdx()\tCUDepth=" ) |
---|
817 | DTRACE_CABAC_V( uiDepth ) |
---|
818 | DTRACE_CABAC_T( "\n" ) |
---|
819 | #endif |
---|
820 | } |
---|
821 | else |
---|
822 | { |
---|
823 | if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ) ) |
---|
824 | { |
---|
825 | m_pcEntropyCoderIf->codeQtRootCbf( pcCU, uiAbsPartIdx ); |
---|
826 | } |
---|
827 | if ( !pcCU->getQtRootCbf( uiAbsPartIdx ) ) |
---|
828 | { |
---|
829 | return; |
---|
830 | } |
---|
831 | } |
---|
832 | |
---|
833 | #if H_3D_DISABLE_CHROMA |
---|
834 | xEncodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP, rd); |
---|
835 | #else |
---|
836 | xEncodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP); |
---|
837 | #endif |
---|
838 | } |
---|
839 | |
---|
840 | Void TEncEntropy::encodeCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiTrWidth, UInt uiTrHeight, UInt uiDepth, TextType eType ) |
---|
841 | { |
---|
842 | // This is for Transform unit processing. This may be used at mode selection stage for Inter. |
---|
843 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, pcCoeff, uiAbsPartIdx, uiTrWidth, uiTrHeight, uiDepth, eType ); |
---|
844 | } |
---|
845 | |
---|
846 | Void TEncEntropy::estimateBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) |
---|
847 | { |
---|
848 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : TEXT_CHROMA; |
---|
849 | |
---|
850 | m_pcEntropyCoderIf->estBit ( pcEstBitsSbac, width, height, eTType ); |
---|
851 | } |
---|
852 | |
---|
853 | Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ) |
---|
854 | { |
---|
855 | Int count = 0; |
---|
856 | |
---|
857 | for ( Int i = 0; i < uiSize; i++ ) |
---|
858 | { |
---|
859 | count += pcCoef[i] != 0; |
---|
860 | } |
---|
861 | |
---|
862 | return count; |
---|
863 | } |
---|
864 | |
---|
865 | /** encode quantization matrix |
---|
866 | * \param scalingList quantization matrix information |
---|
867 | */ |
---|
868 | Void TEncEntropy::encodeScalingList( TComScalingList* scalingList ) |
---|
869 | { |
---|
870 | m_pcEntropyCoderIf->codeScalingList( scalingList ); |
---|
871 | } |
---|
872 | |
---|
873 | #if H_3D_INTER_SDC |
---|
874 | Void TEncEntropy::encodeDeltaDC ( TComDataCU* pcCU, UInt absPartIdx ) |
---|
875 | { |
---|
876 | m_pcEntropyCoderIf->codeDeltaDC( pcCU, absPartIdx ); |
---|
877 | } |
---|
878 | |
---|
879 | Void TEncEntropy::encodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
880 | { |
---|
881 | if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getInterSdcFlag() ) || |
---|
882 | ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getIntraSdcWedgeFlag() ) ) |
---|
883 | { |
---|
884 | return; |
---|
885 | } |
---|
886 | |
---|
887 | if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) ) |
---|
888 | { |
---|
889 | return; |
---|
890 | } |
---|
891 | |
---|
892 | assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) ); |
---|
893 | |
---|
894 | if( bRD ) |
---|
895 | { |
---|
896 | uiAbsPartIdx = 0; |
---|
897 | } |
---|
898 | |
---|
899 | m_pcEntropyCoderIf->codeSDCFlag( pcCU, uiAbsPartIdx ); |
---|
900 | } |
---|
901 | |
---|
902 | #endif |
---|
903 | #if H_3D_DBBP |
---|
904 | Void TEncEntropy::encodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
905 | { |
---|
906 | #if HHI_MOVE_SYN_K0052 |
---|
907 | if( pcCU->getSlice()->getDepthBasedBlkPartFlag() && |
---|
908 | ( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || |
---|
909 | pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && |
---|
910 | pcCU->getWidth(uiAbsPartIdx) > 8 && |
---|
911 | pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() ) |
---|
912 | { |
---|
913 | #endif |
---|
914 | if( bRD ) |
---|
915 | { |
---|
916 | uiAbsPartIdx = 0; |
---|
917 | } |
---|
918 | m_pcEntropyCoderIf->codeDBBPFlag( pcCU, uiAbsPartIdx ); |
---|
919 | #if HHI_MOVE_SYN_K0052 |
---|
920 | } |
---|
921 | #endif |
---|
922 | } |
---|
923 | #endif |
---|
924 | //! \} |
---|