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