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