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