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-2012, 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/TComAdaptiveLoopFilter.h" |
---|
41 | #include "TLibCommon/TComSampleAdaptiveOffset.h" |
---|
42 | |
---|
43 | //! \ingroup TLibEncoder |
---|
44 | //! \{ |
---|
45 | |
---|
46 | Void TEncEntropy::setEntropyCoder ( TEncEntropyIf* e, TComSlice* pcSlice ) |
---|
47 | { |
---|
48 | m_pcEntropyCoderIf = e; |
---|
49 | m_pcEntropyCoderIf->setSlice ( pcSlice ); |
---|
50 | } |
---|
51 | |
---|
52 | Void TEncEntropy::encodeSliceHeader ( TComSlice* pcSlice ) |
---|
53 | { |
---|
54 | if (pcSlice->getSPS()->getUseSAO()) |
---|
55 | { |
---|
56 | pcSlice->setSaoInterleavingFlag(pcSlice->getAPS()->getSaoInterleavingFlag()); |
---|
57 | pcSlice->setSaoEnabledFlag (pcSlice->getAPS()->getSaoParam()->bSaoFlag[0]); |
---|
58 | if (pcSlice->getAPS()->getSaoInterleavingFlag()) |
---|
59 | { |
---|
60 | pcSlice->setSaoEnabledFlagCb (pcSlice->getAPS()->getSaoParam()->bSaoFlag[1]); |
---|
61 | pcSlice->setSaoEnabledFlagCr (pcSlice->getAPS()->getSaoParam()->bSaoFlag[2]); |
---|
62 | } |
---|
63 | else |
---|
64 | { |
---|
65 | pcSlice->setSaoEnabledFlagCb (0); |
---|
66 | pcSlice->setSaoEnabledFlagCr (0); |
---|
67 | } |
---|
68 | } |
---|
69 | |
---|
70 | m_pcEntropyCoderIf->codeSliceHeader( pcSlice ); |
---|
71 | return; |
---|
72 | } |
---|
73 | |
---|
74 | Void TEncEntropy::encodeTilesWPPEntryPoint( TComSlice* pSlice ) |
---|
75 | { |
---|
76 | m_pcEntropyCoderIf->codeTilesWPPEntryPoint( pSlice ); |
---|
77 | } |
---|
78 | |
---|
79 | Void TEncEntropy::encodeTerminatingBit ( UInt uiIsLast ) |
---|
80 | { |
---|
81 | m_pcEntropyCoderIf->codeTerminatingBit( uiIsLast ); |
---|
82 | |
---|
83 | return; |
---|
84 | } |
---|
85 | |
---|
86 | Void TEncEntropy::encodeSliceFinish() |
---|
87 | { |
---|
88 | m_pcEntropyCoderIf->codeSliceFinish(); |
---|
89 | } |
---|
90 | |
---|
91 | Void TEncEntropy::encodeFlush() |
---|
92 | { |
---|
93 | m_pcEntropyCoderIf->codeFlush(); |
---|
94 | } |
---|
95 | Void TEncEntropy::encodeStart() |
---|
96 | { |
---|
97 | m_pcEntropyCoderIf->encodeStart(); |
---|
98 | } |
---|
99 | |
---|
100 | Void TEncEntropy::encodeSEI(const SEI& sei) |
---|
101 | { |
---|
102 | m_pcEntropyCoderIf->codeSEI(sei); |
---|
103 | return; |
---|
104 | } |
---|
105 | |
---|
106 | Void TEncEntropy::encodePPS( TComPPS* pcPPS ) |
---|
107 | { |
---|
108 | m_pcEntropyCoderIf->codePPS( pcPPS ); |
---|
109 | return; |
---|
110 | } |
---|
111 | |
---|
112 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
113 | Void TEncEntropy::encodeVPS( TComVPS* pcVPS ) |
---|
114 | { |
---|
115 | m_pcEntropyCoderIf->codeVPS( pcVPS ); |
---|
116 | return; |
---|
117 | } |
---|
118 | #endif |
---|
119 | |
---|
120 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
121 | Void codeVPS ( TComVPS* pcVPS ); |
---|
122 | #endif |
---|
123 | |
---|
124 | #if HHI_MPI || H3D_QTL |
---|
125 | Void TEncEntropy::encodeSPS( TComSPS* pcSPS, Bool bIsDepth ) |
---|
126 | { |
---|
127 | m_pcEntropyCoderIf->codeSPS( pcSPS, bIsDepth ); |
---|
128 | return; |
---|
129 | } |
---|
130 | #else |
---|
131 | Void TEncEntropy::encodeSPS( TComSPS* pcSPS ) |
---|
132 | { |
---|
133 | m_pcEntropyCoderIf->codeSPS( pcSPS ); |
---|
134 | return; |
---|
135 | } |
---|
136 | #endif |
---|
137 | |
---|
138 | Void TEncEntropy::encodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
139 | { |
---|
140 | if ( pcCU->getSlice()->isIntra() ) |
---|
141 | { |
---|
142 | return; |
---|
143 | } |
---|
144 | if( bRD ) |
---|
145 | { |
---|
146 | uiAbsPartIdx = 0; |
---|
147 | } |
---|
148 | if( !bRD ) |
---|
149 | { |
---|
150 | if( pcCU->getLastCUSucIPCMFlag() && pcCU->getIPCMFlag(uiAbsPartIdx) ) |
---|
151 | { |
---|
152 | return; |
---|
153 | } |
---|
154 | } |
---|
155 | m_pcEntropyCoderIf->codeSkipFlag( pcCU, uiAbsPartIdx ); |
---|
156 | } |
---|
157 | |
---|
158 | #if LGE_ILLUCOMP_B0045 |
---|
159 | Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD |
---|
160 | #if LGE_ILLUCOMP_DEPTH_C0046 |
---|
161 | , UInt uiDepth |
---|
162 | #endif |
---|
163 | ) |
---|
164 | { |
---|
165 | if (pcCU->isIntra(uiAbsPartIdx) || (pcCU->getSlice()->getViewId() == 0) |
---|
166 | #if !LGE_ILLUCOMP_DEPTH_C0046 |
---|
167 | || pcCU->getSlice()->getSPS()->isDepth() |
---|
168 | #endif |
---|
169 | ) |
---|
170 | { |
---|
171 | return; |
---|
172 | } |
---|
173 | |
---|
174 | if(!pcCU->getSlice()->getApplyIC()) |
---|
175 | return; |
---|
176 | |
---|
177 | if( bRD ) |
---|
178 | { |
---|
179 | uiAbsPartIdx = 0; |
---|
180 | } |
---|
181 | |
---|
182 | if(pcCU->isICFlagRequired(uiAbsPartIdx |
---|
183 | #if LGE_ILLUCOMP_DEPTH_C0046 |
---|
184 | , uiDepth //This modification is not needed after integrating JCT3V-C0137 |
---|
185 | #endif |
---|
186 | )) |
---|
187 | m_pcEntropyCoderIf->codeICFlag( pcCU, uiAbsPartIdx ); |
---|
188 | } |
---|
189 | #endif |
---|
190 | |
---|
191 | Void TEncEntropy::codeFiltCountBit(ALFParam* pAlfParam, Int64* ruiRate) |
---|
192 | { |
---|
193 | resetEntropy(); |
---|
194 | resetBits(); |
---|
195 | codeFilt(pAlfParam); |
---|
196 | *ruiRate = getNumberOfWrittenBits(); |
---|
197 | resetEntropy(); |
---|
198 | resetBits(); |
---|
199 | } |
---|
200 | |
---|
201 | Void TEncEntropy::codeAuxCountBit(ALFParam* pAlfParam, Int64* ruiRate) |
---|
202 | { |
---|
203 | resetEntropy(); |
---|
204 | resetBits(); |
---|
205 | codeAux(pAlfParam); |
---|
206 | *ruiRate = getNumberOfWrittenBits(); |
---|
207 | resetEntropy(); |
---|
208 | resetBits(); |
---|
209 | } |
---|
210 | |
---|
211 | Void TEncEntropy::codeAux(ALFParam* pAlfParam) |
---|
212 | { |
---|
213 | // m_pcEntropyCoderIf->codeAlfUvlc(pAlfParam->realfiltNo); |
---|
214 | |
---|
215 | Int noFilters = min(pAlfParam->filters_per_group-1, 2); |
---|
216 | m_pcEntropyCoderIf->codeAlfUvlc(noFilters); |
---|
217 | |
---|
218 | if(noFilters == 1) |
---|
219 | { |
---|
220 | m_pcEntropyCoderIf->codeAlfUvlc(pAlfParam->startSecondFilter); |
---|
221 | } |
---|
222 | else if (noFilters == 2) |
---|
223 | { |
---|
224 | Int numMergeFlags = 16; |
---|
225 | for (Int i=1; i<numMergeFlags; i++) |
---|
226 | { |
---|
227 | m_pcEntropyCoderIf->codeAlfFlag (pAlfParam->filterPattern[i]); |
---|
228 | } |
---|
229 | } |
---|
230 | } |
---|
231 | |
---|
232 | Int TEncEntropy::lengthGolomb(int coeffVal, int k) |
---|
233 | { |
---|
234 | int m = 2 << (k - 1); |
---|
235 | int q = coeffVal / m; |
---|
236 | if(coeffVal != 0) |
---|
237 | { |
---|
238 | return(q + 2 + k); |
---|
239 | } |
---|
240 | else |
---|
241 | { |
---|
242 | return(q + 1 + k); |
---|
243 | } |
---|
244 | } |
---|
245 | |
---|
246 | Int TEncEntropy::codeFilterCoeff(ALFParam* ALFp) |
---|
247 | { |
---|
248 | Int filters_per_group = ALFp->filters_per_group; |
---|
249 | int sqrFiltLength = ALFp->num_coeff; |
---|
250 | int i, k, kMin, kStart, minBits, ind, scanPos, maxScanVal, coeffVal, len = 0, |
---|
251 | *pDepthInt=NULL, kMinTab[MAX_SCAN_VAL], bitsCoeffScan[MAX_SCAN_VAL][MAX_EXP_GOLOMB], |
---|
252 | minKStart, minBitsKStart, bitsKStart; |
---|
253 | |
---|
254 | pDepthInt = pDepthIntTabShapes[ALFp->filter_shape]; |
---|
255 | maxScanVal = 0; |
---|
256 | int minScanVal = MIN_SCAN_POS_CROSS; |
---|
257 | |
---|
258 | for(i = 0; i < sqrFiltLength; i++) |
---|
259 | { |
---|
260 | maxScanVal = max(maxScanVal, pDepthInt[i]); |
---|
261 | } |
---|
262 | |
---|
263 | // vlc for all |
---|
264 | memset(bitsCoeffScan, 0, MAX_SCAN_VAL * MAX_EXP_GOLOMB * sizeof(int)); |
---|
265 | for(ind=0; ind<filters_per_group; ++ind) |
---|
266 | { |
---|
267 | for(i = 0; i < sqrFiltLength; i++) |
---|
268 | { |
---|
269 | scanPos=pDepthInt[i]-1; |
---|
270 | coeffVal=abs(ALFp->coeffmulti[ind][i]); |
---|
271 | for (k=1; k<15; k++) |
---|
272 | { |
---|
273 | bitsCoeffScan[scanPos][k]+=lengthGolomb(coeffVal, k); |
---|
274 | } |
---|
275 | } |
---|
276 | } |
---|
277 | |
---|
278 | minBitsKStart = 0; |
---|
279 | minKStart = -1; |
---|
280 | for(k = 1; k < 8; k++) |
---|
281 | { |
---|
282 | bitsKStart = 0; |
---|
283 | kStart = k; |
---|
284 | for(scanPos = minScanVal; scanPos < maxScanVal; scanPos++) |
---|
285 | { |
---|
286 | kMin = kStart; |
---|
287 | minBits = bitsCoeffScan[scanPos][kMin]; |
---|
288 | |
---|
289 | if(bitsCoeffScan[scanPos][kStart+1] < minBits) |
---|
290 | { |
---|
291 | kMin = kStart + 1; |
---|
292 | minBits = bitsCoeffScan[scanPos][kMin]; |
---|
293 | } |
---|
294 | kStart = kMin; |
---|
295 | bitsKStart += minBits; |
---|
296 | } |
---|
297 | if((bitsKStart < minBitsKStart) || (k == 1)) |
---|
298 | { |
---|
299 | minBitsKStart = bitsKStart; |
---|
300 | minKStart = k; |
---|
301 | } |
---|
302 | } |
---|
303 | |
---|
304 | kStart = minKStart; |
---|
305 | for(scanPos = minScanVal; scanPos < maxScanVal; scanPos++) |
---|
306 | { |
---|
307 | kMin = kStart; |
---|
308 | minBits = bitsCoeffScan[scanPos][kMin]; |
---|
309 | |
---|
310 | if(bitsCoeffScan[scanPos][kStart+1] < minBits) |
---|
311 | { |
---|
312 | kMin = kStart + 1; |
---|
313 | minBits = bitsCoeffScan[scanPos][kMin]; |
---|
314 | } |
---|
315 | |
---|
316 | kMinTab[scanPos] = kMin; |
---|
317 | kStart = kMin; |
---|
318 | } |
---|
319 | |
---|
320 | // Coding parameters |
---|
321 | ALFp->minKStart = minKStart; |
---|
322 | for(scanPos = minScanVal; scanPos < maxScanVal; scanPos++) |
---|
323 | { |
---|
324 | ALFp->kMinTab[scanPos] = kMinTab[scanPos]; |
---|
325 | } |
---|
326 | |
---|
327 | if (ALFp->filters_per_group == 1) |
---|
328 | { |
---|
329 | len += writeFilterCoeffs(sqrFiltLength, filters_per_group, pDepthInt, ALFp->coeffmulti, kTableTabShapes[ALF_CROSS9x7_SQUARE3x3]); |
---|
330 | } |
---|
331 | else |
---|
332 | { |
---|
333 | len += writeFilterCodingParams(minKStart, minScanVal, maxScanVal, kMinTab); |
---|
334 | |
---|
335 | // Filter coefficients |
---|
336 | len += writeFilterCoeffs(sqrFiltLength, filters_per_group, pDepthInt, ALFp->coeffmulti, kMinTab); |
---|
337 | } |
---|
338 | |
---|
339 | return len; |
---|
340 | } |
---|
341 | |
---|
342 | Int TEncEntropy::writeFilterCodingParams(int minKStart, int minScanVal, int maxScanVal, int kMinTab[]) |
---|
343 | { |
---|
344 | int scanPos; |
---|
345 | int golombIndexBit; |
---|
346 | int kMin; |
---|
347 | |
---|
348 | // Golomb parameters |
---|
349 | m_pcEntropyCoderIf->codeAlfUvlc(minKStart - 1); |
---|
350 | |
---|
351 | kMin = minKStart; |
---|
352 | for(scanPos = minScanVal; scanPos < maxScanVal; scanPos++) |
---|
353 | { |
---|
354 | golombIndexBit = (kMinTab[scanPos] != kMin)? 1: 0; |
---|
355 | |
---|
356 | assert(kMinTab[scanPos] <= kMin + 1); |
---|
357 | |
---|
358 | m_pcEntropyCoderIf->codeAlfFlag(golombIndexBit); |
---|
359 | kMin = kMinTab[scanPos]; |
---|
360 | } |
---|
361 | |
---|
362 | return 0; |
---|
363 | } |
---|
364 | |
---|
365 | Int TEncEntropy::writeFilterCoeffs(int sqrFiltLength, int filters_per_group, int pDepthInt[], |
---|
366 | int **FilterCoeff, int kMinTab[]) |
---|
367 | { |
---|
368 | int ind, scanPos, i; |
---|
369 | |
---|
370 | for(ind = 0; ind < filters_per_group; ++ind) |
---|
371 | { |
---|
372 | for(i = 0; i < sqrFiltLength; i++) |
---|
373 | { |
---|
374 | scanPos = pDepthInt[i] - 1; |
---|
375 | Int k = (filters_per_group == 1) ? kMinTab[i] : kMinTab[scanPos]; |
---|
376 | golombEncode(FilterCoeff[ind][i], k); |
---|
377 | } |
---|
378 | } |
---|
379 | return 0; |
---|
380 | } |
---|
381 | |
---|
382 | Int TEncEntropy::golombEncode(int coeff, int k) |
---|
383 | { |
---|
384 | int q, i; |
---|
385 | int symbol = abs(coeff); |
---|
386 | |
---|
387 | q = symbol >> k; |
---|
388 | |
---|
389 | for (i = 0; i < q; i++) |
---|
390 | { |
---|
391 | m_pcEntropyCoderIf->codeAlfFlag(1); |
---|
392 | } |
---|
393 | m_pcEntropyCoderIf->codeAlfFlag(0); |
---|
394 | // write one zero |
---|
395 | |
---|
396 | for(i = 0; i < k; i++) |
---|
397 | { |
---|
398 | m_pcEntropyCoderIf->codeAlfFlag(symbol & 0x01); |
---|
399 | symbol >>= 1; |
---|
400 | } |
---|
401 | |
---|
402 | if(coeff != 0) |
---|
403 | { |
---|
404 | int sign = (coeff > 0)? 1: 0; |
---|
405 | m_pcEntropyCoderIf->codeAlfFlag(sign); |
---|
406 | } |
---|
407 | return 0; |
---|
408 | } |
---|
409 | |
---|
410 | Void TEncEntropy::codeFilt(ALFParam* pAlfParam) |
---|
411 | { |
---|
412 | if(pAlfParam->filters_per_group > 1) |
---|
413 | { |
---|
414 | m_pcEntropyCoderIf->codeAlfFlag (pAlfParam->predMethod); |
---|
415 | } |
---|
416 | for(Int ind = 0; ind < pAlfParam->filters_per_group; ++ind) |
---|
417 | { |
---|
418 | m_pcEntropyCoderIf->codeAlfFlag (pAlfParam->nbSPred[ind]); |
---|
419 | } |
---|
420 | codeFilterCoeff (pAlfParam); |
---|
421 | } |
---|
422 | |
---|
423 | /** encode merge flag |
---|
424 | * \param pcCU |
---|
425 | * \param uiAbsPartIdx |
---|
426 | * \param uiPUIdx |
---|
427 | * \returns Void |
---|
428 | */ |
---|
429 | Void TEncEntropy::encodeMergeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx ) |
---|
430 | { |
---|
431 | // at least one merge candidate exists |
---|
432 | m_pcEntropyCoderIf->codeMergeFlag( pcCU, uiAbsPartIdx ); |
---|
433 | } |
---|
434 | |
---|
435 | /** encode merge index |
---|
436 | * \param pcCU |
---|
437 | * \param uiAbsPartIdx |
---|
438 | * \param uiPUIdx |
---|
439 | * \param bRD |
---|
440 | * \returns Void |
---|
441 | */ |
---|
442 | Void TEncEntropy::encodeMergeIndex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPUIdx, Bool bRD ) |
---|
443 | { |
---|
444 | if( bRD ) |
---|
445 | { |
---|
446 | uiAbsPartIdx = 0; |
---|
447 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
448 | } |
---|
449 | |
---|
450 | UInt uiNumCand = MRG_MAX_NUM_CANDS; |
---|
451 | if ( uiNumCand > 1 ) |
---|
452 | { |
---|
453 | m_pcEntropyCoderIf->codeMergeIndex( pcCU, uiAbsPartIdx ); |
---|
454 | } |
---|
455 | } |
---|
456 | |
---|
457 | |
---|
458 | /** parse the fixed length code (smaller than one max value) in ALF |
---|
459 | * \param run: coded value |
---|
460 | * \param rx: cur addr |
---|
461 | * \param numLCUInWidth: # of LCU in one LCU |
---|
462 | * \returns Void |
---|
463 | */ |
---|
464 | Void TEncEntropy::encodeAlfFixedLengthRun(UInt run, UInt rx, UInt numLCUInWidth) |
---|
465 | { |
---|
466 | assert(numLCUInWidth > rx); |
---|
467 | UInt maxValue = numLCUInWidth - rx - 1; |
---|
468 | m_pcEntropyCoderIf->codeAlfFixedLengthIdx(run, maxValue); |
---|
469 | } |
---|
470 | |
---|
471 | /** parse the fixed length code (smaller than one max value) in ALF |
---|
472 | * \param idx: coded value |
---|
473 | * \param numFilterSetsInBuffer: max value |
---|
474 | * \returns Void |
---|
475 | */ |
---|
476 | Void TEncEntropy::encodeAlfStoredFilterSetIdx(UInt idx, UInt numFilterSetsInBuffer) |
---|
477 | { |
---|
478 | assert(numFilterSetsInBuffer > 0); |
---|
479 | UInt maxValue = numFilterSetsInBuffer - 1; |
---|
480 | m_pcEntropyCoderIf->codeAlfFixedLengthIdx(idx, maxValue); |
---|
481 | } |
---|
482 | |
---|
483 | Void TEncEntropy::encodeAlfParam(AlfParamSet* pAlfParamSet, Bool bSentInAPS, Int firstLCUAddr, Bool alfAcrossSlice) |
---|
484 | { |
---|
485 | Bool isEnabled[NUM_ALF_COMPONENT]; |
---|
486 | Bool isUniParam[NUM_ALF_COMPONENT]; |
---|
487 | |
---|
488 | isEnabled[ALF_Y] = true; |
---|
489 | isEnabled[ALF_Cb]= pAlfParamSet->isEnabled[ALF_Cb]; |
---|
490 | isEnabled[ALF_Cr]= pAlfParamSet->isEnabled[ALF_Cr]; |
---|
491 | |
---|
492 | isUniParam[ALF_Y]= pAlfParamSet->isUniParam[ALF_Y]; |
---|
493 | isUniParam[ALF_Cb]= pAlfParamSet->isUniParam[ALF_Cb]; |
---|
494 | isUniParam[ALF_Cr]= pAlfParamSet->isUniParam[ALF_Cr]; |
---|
495 | |
---|
496 | |
---|
497 | //alf_cb_enable_flag |
---|
498 | m_pcEntropyCoderIf->codeAlfFlag(isEnabled[ALF_Cb]?1:0); |
---|
499 | //alf_cr_enable_flag |
---|
500 | m_pcEntropyCoderIf->codeAlfFlag(isEnabled[ALF_Cr]?1:0); |
---|
501 | |
---|
502 | for(Int compIdx = 0; compIdx< NUM_ALF_COMPONENT; compIdx++) |
---|
503 | { |
---|
504 | if(isEnabled[compIdx]) |
---|
505 | { |
---|
506 | //alf_one_{luma, cb, cr}_unit_per_slice_flag |
---|
507 | m_pcEntropyCoderIf->codeAlfFlag(isUniParam[compIdx]?1:0); |
---|
508 | } |
---|
509 | } |
---|
510 | if(bSentInAPS) |
---|
511 | { |
---|
512 | //alf_num_lcu_in_width_minus1 |
---|
513 | m_pcEntropyCoderIf->codeAlfUvlc(pAlfParamSet->numLCUInWidth-1); |
---|
514 | //alf_num_lcu_in_height_minus1 |
---|
515 | m_pcEntropyCoderIf->codeAlfUvlc(pAlfParamSet->numLCUInHeight-1); |
---|
516 | } |
---|
517 | else //sent in slice header |
---|
518 | { |
---|
519 | //alf_num_lcu_in_slice_minus1 |
---|
520 | m_pcEntropyCoderIf->codeAlfUvlc(pAlfParamSet->numLCU-1); |
---|
521 | } |
---|
522 | |
---|
523 | |
---|
524 | encodeAlfParamSet(pAlfParamSet, pAlfParamSet->numLCUInWidth, pAlfParamSet->numLCU, firstLCUAddr, alfAcrossSlice, 0, (Int)NUM_ALF_COMPONENT-1); |
---|
525 | |
---|
526 | } |
---|
527 | |
---|
528 | Bool TEncEntropy::getAlfRepeatRowFlag(Int compIdx, AlfParamSet* pAlfParamSet |
---|
529 | , Int lcuIdxInSlice, Int lcuPos |
---|
530 | , Int startlcuPosX, Int endlcuPosX |
---|
531 | , Int numLCUInWidth |
---|
532 | ) |
---|
533 | { |
---|
534 | assert(startlcuPosX == 0); //only the beginning of one LCU row needs to send repeat_row_flag |
---|
535 | |
---|
536 | Int len = endlcuPosX - startlcuPosX +1; |
---|
537 | Bool isRepeatRow = true; |
---|
538 | Int curPos; |
---|
539 | |
---|
540 | for(Int i= 0; i < len; i++) |
---|
541 | { |
---|
542 | curPos = lcuIdxInSlice +i; |
---|
543 | AlfUnitParam& alfUnitParam = pAlfParamSet->alfUnitParam[compIdx][curPos]; |
---|
544 | AlfUnitParam& alfUpUnitParam = pAlfParamSet->alfUnitParam[compIdx][curPos-numLCUInWidth]; |
---|
545 | |
---|
546 | if ( !(alfUnitParam == alfUpUnitParam) ) |
---|
547 | { |
---|
548 | isRepeatRow = false; |
---|
549 | break; |
---|
550 | } |
---|
551 | } |
---|
552 | |
---|
553 | return isRepeatRow; |
---|
554 | } |
---|
555 | |
---|
556 | |
---|
557 | Int TEncEntropy::getAlfRun(Int compIdx, AlfParamSet* pAlfParamSet |
---|
558 | , Int lcuIdxInSlice, Int lcuPos |
---|
559 | , Int startlcuPosX, Int endlcuPosX |
---|
560 | ) |
---|
561 | { |
---|
562 | Int alfRun = 0; |
---|
563 | Int len = endlcuPosX - startlcuPosX +1; |
---|
564 | AlfUnitParam& alfLeftUnitParam = pAlfParamSet->alfUnitParam[compIdx][lcuIdxInSlice]; |
---|
565 | |
---|
566 | |
---|
567 | |
---|
568 | for(Int i= 1; i < len; i++) |
---|
569 | { |
---|
570 | AlfUnitParam& alfUnitParam = pAlfParamSet->alfUnitParam[compIdx][lcuIdxInSlice+ i]; |
---|
571 | |
---|
572 | if (alfUnitParam == alfLeftUnitParam) |
---|
573 | { |
---|
574 | alfRun++; |
---|
575 | } |
---|
576 | else |
---|
577 | { |
---|
578 | break; |
---|
579 | } |
---|
580 | } |
---|
581 | |
---|
582 | return alfRun; |
---|
583 | |
---|
584 | } |
---|
585 | |
---|
586 | |
---|
587 | |
---|
588 | Void TEncEntropy::encodeAlfParamSet(AlfParamSet* pAlfParamSet, Int numLCUInWidth, Int numLCU, Int firstLCUAddr, Bool alfAcrossSlice, Int startCompIdx, Int endCompIdx) |
---|
589 | { |
---|
590 | Int endLCUY = (numLCU -1 + firstLCUAddr)/numLCUInWidth; |
---|
591 | Int endLCUX = (numLCU -1 + firstLCUAddr)%numLCUInWidth; |
---|
592 | |
---|
593 | static Bool isRepeatedRow [NUM_ALF_COMPONENT]; |
---|
594 | static Int numStoredFilters[NUM_ALF_COMPONENT]; |
---|
595 | static Int* run [NUM_ALF_COMPONENT]; |
---|
596 | |
---|
597 | for(Int compIdx =startCompIdx; compIdx <= endCompIdx; compIdx++) |
---|
598 | { |
---|
599 | isRepeatedRow[compIdx] = false; |
---|
600 | numStoredFilters[compIdx] = 0; |
---|
601 | |
---|
602 | run[compIdx] = new Int[numLCU+1]; |
---|
603 | run[compIdx][0] = -1; |
---|
604 | } |
---|
605 | |
---|
606 | Int ry, rx, addrUp, endrX, lcuPos; |
---|
607 | |
---|
608 | for(Int i=0; i< numLCU; i++) |
---|
609 | { |
---|
610 | lcuPos= firstLCUAddr+ i; |
---|
611 | rx = lcuPos% numLCUInWidth; |
---|
612 | ry = lcuPos/ numLCUInWidth; |
---|
613 | endrX = ( ry == endLCUY)?( endLCUX ):(numLCUInWidth-1); |
---|
614 | |
---|
615 | for(Int compIdx =startCompIdx; compIdx <= endCompIdx; compIdx++) |
---|
616 | { |
---|
617 | AlfUnitParam& alfUnitParam = pAlfParamSet->alfUnitParam[compIdx][i]; |
---|
618 | if(pAlfParamSet->isEnabled[compIdx]) |
---|
619 | { |
---|
620 | if(!pAlfParamSet->isUniParam[compIdx]) |
---|
621 | { |
---|
622 | addrUp = i-numLCUInWidth; |
---|
623 | if(rx ==0 && addrUp >=0) |
---|
624 | { |
---|
625 | isRepeatedRow[compIdx] = getAlfRepeatRowFlag(compIdx, pAlfParamSet, i, lcuPos, rx, endrX, numLCUInWidth); |
---|
626 | |
---|
627 | //alf_repeat_row_flag |
---|
628 | m_pcEntropyCoderIf->codeAlfFlag(isRepeatedRow[compIdx]?1:0); |
---|
629 | } |
---|
630 | |
---|
631 | if(isRepeatedRow[compIdx]) |
---|
632 | { |
---|
633 | assert(addrUp >=0); |
---|
634 | run[compIdx][i] = run[compIdx][addrUp]; |
---|
635 | } |
---|
636 | else |
---|
637 | { |
---|
638 | if(rx == 0 || run[compIdx][i] < 0) |
---|
639 | { |
---|
640 | run[compIdx][i] = getAlfRun(compIdx, pAlfParamSet, i, lcuPos, rx, endrX); |
---|
641 | |
---|
642 | if(addrUp < 0) |
---|
643 | { |
---|
644 | //alf_run_diff u(v) |
---|
645 | encodeAlfFixedLengthRun(run[compIdx][i], rx, numLCUInWidth); |
---|
646 | } |
---|
647 | else |
---|
648 | { |
---|
649 | //alf_run_diff s(v) |
---|
650 | m_pcEntropyCoderIf->codeAlfSvlc(run[compIdx][i]- run[compIdx][addrUp]); |
---|
651 | |
---|
652 | } |
---|
653 | |
---|
654 | if(ry > 0 && (addrUp >=0 || alfAcrossSlice)) |
---|
655 | { |
---|
656 | //alf_merge_up_flag |
---|
657 | m_pcEntropyCoderIf->codeAlfFlag( (alfUnitParam.mergeType == ALF_MERGE_UP)?1:0 ); |
---|
658 | } |
---|
659 | |
---|
660 | if(alfUnitParam.mergeType != ALF_MERGE_UP) |
---|
661 | { |
---|
662 | assert(alfUnitParam.mergeType == ALF_MERGE_DISABLED); |
---|
663 | |
---|
664 | //alf_lcu_enable_flag |
---|
665 | m_pcEntropyCoderIf->codeAlfFlag(alfUnitParam.isEnabled ? 1 : 0); |
---|
666 | |
---|
667 | if(alfUnitParam.isEnabled) |
---|
668 | { |
---|
669 | if(numStoredFilters[compIdx] > 0) |
---|
670 | { |
---|
671 | //alf_new_filter_set_flag |
---|
672 | m_pcEntropyCoderIf->codeAlfFlag(alfUnitParam.isNewFilt ? 1:0); |
---|
673 | |
---|
674 | if(!alfUnitParam.isNewFilt) |
---|
675 | { |
---|
676 | //alf_stored_filter_set_idx |
---|
677 | encodeAlfStoredFilterSetIdx(alfUnitParam.storedFiltIdx, numStoredFilters[compIdx]); |
---|
678 | |
---|
679 | } |
---|
680 | } |
---|
681 | else |
---|
682 | { |
---|
683 | assert(alfUnitParam.isNewFilt); |
---|
684 | } |
---|
685 | |
---|
686 | if(alfUnitParam.isNewFilt) |
---|
687 | { |
---|
688 | assert(alfUnitParam.alfFiltParam->alf_flag == 1); |
---|
689 | encodeAlfParam(alfUnitParam.alfFiltParam); |
---|
690 | numStoredFilters[compIdx]++; |
---|
691 | } |
---|
692 | } |
---|
693 | |
---|
694 | } |
---|
695 | } |
---|
696 | |
---|
697 | run[compIdx][i+1] = run[compIdx][i] -1; |
---|
698 | } |
---|
699 | |
---|
700 | } |
---|
701 | else // uni-param |
---|
702 | { |
---|
703 | if(i == 0) |
---|
704 | { |
---|
705 | //alf_lcu_enable_flag |
---|
706 | m_pcEntropyCoderIf->codeAlfFlag(alfUnitParam.isEnabled?1:0); |
---|
707 | if(alfUnitParam.isEnabled) |
---|
708 | { |
---|
709 | encodeAlfParam(alfUnitParam.alfFiltParam); |
---|
710 | } |
---|
711 | } |
---|
712 | } |
---|
713 | } // component enabled/disable |
---|
714 | } //comp |
---|
715 | |
---|
716 | } |
---|
717 | |
---|
718 | for(Int compIdx =startCompIdx; compIdx <= endCompIdx; compIdx++) |
---|
719 | { |
---|
720 | delete[] run[compIdx]; |
---|
721 | } |
---|
722 | |
---|
723 | } |
---|
724 | |
---|
725 | |
---|
726 | Void TEncEntropy::encodeAlfParam(ALFParam* pAlfParam) |
---|
727 | { |
---|
728 | const Int numCoeff = (Int)ALF_MAX_NUM_COEF; |
---|
729 | |
---|
730 | switch(pAlfParam->componentID) |
---|
731 | { |
---|
732 | case ALF_Cb: |
---|
733 | case ALF_Cr: |
---|
734 | { |
---|
735 | for(Int pos=0; pos< numCoeff; pos++) |
---|
736 | { |
---|
737 | m_pcEntropyCoderIf->codeAlfSvlc( pAlfParam->coeffmulti[0][pos]); |
---|
738 | |
---|
739 | } |
---|
740 | } |
---|
741 | break; |
---|
742 | case ALF_Y: |
---|
743 | { |
---|
744 | codeAux(pAlfParam); |
---|
745 | codeFilt(pAlfParam); |
---|
746 | } |
---|
747 | break; |
---|
748 | default: |
---|
749 | { |
---|
750 | printf("Not a legal component ID\n"); |
---|
751 | assert(0); |
---|
752 | exit(-1); |
---|
753 | } |
---|
754 | } |
---|
755 | } |
---|
756 | |
---|
757 | Void TEncEntropy::encodeAlfCtrlFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
758 | { |
---|
759 | if( bRD ) |
---|
760 | { |
---|
761 | uiAbsPartIdx = 0; |
---|
762 | } |
---|
763 | m_pcEntropyCoderIf->codeAlfCtrlFlag( pcCU, uiAbsPartIdx ); |
---|
764 | } |
---|
765 | |
---|
766 | |
---|
767 | /** Encode ALF CU control flag |
---|
768 | * \param uiFlag ALF CU control flag: 0 or 1 |
---|
769 | */ |
---|
770 | Void TEncEntropy::encodeAlfCtrlFlag(UInt uiFlag) |
---|
771 | { |
---|
772 | assert(uiFlag == 0 || uiFlag == 1); |
---|
773 | m_pcEntropyCoderIf->codeAlfCtrlFlag( uiFlag ); |
---|
774 | } |
---|
775 | |
---|
776 | |
---|
777 | /** Encode ALF CU control flag parameters |
---|
778 | * \param pAlfParam ALF parameters |
---|
779 | */ |
---|
780 | Void TEncEntropy::encodeAlfCtrlParam(AlfCUCtrlInfo& cAlfParam, Int iNumCUsInPic) |
---|
781 | { |
---|
782 | // region control parameters for luma |
---|
783 | m_pcEntropyCoderIf->codeAlfFlag(cAlfParam.cu_control_flag); |
---|
784 | |
---|
785 | if (cAlfParam.cu_control_flag == 0) |
---|
786 | { |
---|
787 | return; |
---|
788 | } |
---|
789 | |
---|
790 | m_pcEntropyCoderIf->codeAlfCtrlDepth(); |
---|
791 | |
---|
792 | Int iSymbol = ((Int)cAlfParam.num_alf_cu_flag - iNumCUsInPic); |
---|
793 | m_pcEntropyCoderIf->codeAlfSvlc(iSymbol); |
---|
794 | |
---|
795 | for(UInt i=0; i< cAlfParam.num_alf_cu_flag; i++) |
---|
796 | { |
---|
797 | m_pcEntropyCoderIf->codeAlfCtrlFlag( cAlfParam.alf_cu_flag[i] ); |
---|
798 | } |
---|
799 | } |
---|
800 | |
---|
801 | /** encode prediction mode |
---|
802 | * \param pcCU |
---|
803 | * \param uiAbsPartIdx |
---|
804 | * \param bRD |
---|
805 | * \returns Void |
---|
806 | */ |
---|
807 | Void TEncEntropy::encodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
808 | { |
---|
809 | if( bRD ) |
---|
810 | { |
---|
811 | uiAbsPartIdx = 0; |
---|
812 | } |
---|
813 | if( !bRD ) |
---|
814 | { |
---|
815 | if( pcCU->getLastCUSucIPCMFlag() && pcCU->getIPCMFlag(uiAbsPartIdx) ) |
---|
816 | { |
---|
817 | return; |
---|
818 | } |
---|
819 | } |
---|
820 | |
---|
821 | #if !RWTH_SDC_DLT_B0036 |
---|
822 | if ( pcCU->getSlice()->isIntra() ) |
---|
823 | { |
---|
824 | return; |
---|
825 | } |
---|
826 | #endif |
---|
827 | |
---|
828 | m_pcEntropyCoderIf->codePredMode( pcCU, uiAbsPartIdx ); |
---|
829 | |
---|
830 | #if RWTH_SDC_DLT_B0036 |
---|
831 | // if B-Slice, code SDC flag later |
---|
832 | if( !pcCU->getSlice()->isInterB() && pcCU->getSlice()->getSPS()->isDepth() && pcCU->isIntra(uiAbsPartIdx) ) |
---|
833 | { |
---|
834 | // encode SDC flag |
---|
835 | encodeSDCFlag(pcCU, uiAbsPartIdx, bRD); |
---|
836 | } |
---|
837 | #endif |
---|
838 | } |
---|
839 | |
---|
840 | // Split mode |
---|
841 | Void TEncEntropy::encodeSplitFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD ) |
---|
842 | { |
---|
843 | if( bRD ) |
---|
844 | { |
---|
845 | uiAbsPartIdx = 0; |
---|
846 | } |
---|
847 | if( !bRD ) |
---|
848 | { |
---|
849 | if( pcCU->getLastCUSucIPCMFlag() && pcCU->getIPCMFlag(uiAbsPartIdx) ) |
---|
850 | { |
---|
851 | return; |
---|
852 | } |
---|
853 | } |
---|
854 | |
---|
855 | m_pcEntropyCoderIf->codeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
856 | } |
---|
857 | |
---|
858 | /** encode partition size |
---|
859 | * \param pcCU |
---|
860 | * \param uiAbsPartIdx |
---|
861 | * \param uiDepth |
---|
862 | * \param bRD |
---|
863 | * \returns Void |
---|
864 | */ |
---|
865 | Void TEncEntropy::encodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD ) |
---|
866 | { |
---|
867 | if( bRD ) |
---|
868 | { |
---|
869 | uiAbsPartIdx = 0; |
---|
870 | } |
---|
871 | if( !bRD ) |
---|
872 | { |
---|
873 | if( pcCU->getLastCUSucIPCMFlag() && pcCU->getIPCMFlag(uiAbsPartIdx) ) |
---|
874 | { |
---|
875 | return; |
---|
876 | } |
---|
877 | } |
---|
878 | #if RWTH_SDC_DLT_B0036 |
---|
879 | if( !pcCU->getSlice()->isInterB() && pcCU->isIntra(uiAbsPartIdx) && pcCU->getSDCFlag(uiAbsPartIdx) ) |
---|
880 | { |
---|
881 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
882 | return; |
---|
883 | } |
---|
884 | #endif |
---|
885 | |
---|
886 | m_pcEntropyCoderIf->codePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
887 | |
---|
888 | #if RWTH_SDC_DLT_B0036 |
---|
889 | // code SDC flag now! |
---|
890 | if( pcCU->getSlice()->isInterB() && pcCU->isIntra(uiAbsPartIdx) && pcCU->getSlice()->getSPS()->isDepth() ) |
---|
891 | { |
---|
892 | // encode SDC flag |
---|
893 | encodeSDCFlag(pcCU, uiAbsPartIdx, bRD); |
---|
894 | |
---|
895 | if( pcCU->getSDCFlag(uiAbsPartIdx) ) |
---|
896 | { |
---|
897 | // part size is also known for SDC intra |
---|
898 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
899 | } |
---|
900 | } |
---|
901 | #endif |
---|
902 | } |
---|
903 | |
---|
904 | /** Encode I_PCM information. |
---|
905 | * \param pcCU pointer to CU |
---|
906 | * \param uiAbsPartIdx CU index |
---|
907 | * \param bRD flag indicating estimation or encoding |
---|
908 | * \returns Void |
---|
909 | */ |
---|
910 | Void TEncEntropy::encodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
911 | { |
---|
912 | if(!pcCU->getSlice()->getSPS()->getUsePCM() |
---|
913 | || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize()) |
---|
914 | || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize())) |
---|
915 | { |
---|
916 | return; |
---|
917 | } |
---|
918 | |
---|
919 | #if RWTH_SDC_DLT_B0036 |
---|
920 | if( pcCU->getSDCFlag(uiAbsPartIdx) ) |
---|
921 | { |
---|
922 | return; |
---|
923 | } |
---|
924 | #endif |
---|
925 | |
---|
926 | if( bRD ) |
---|
927 | { |
---|
928 | uiAbsPartIdx = 0; |
---|
929 | } |
---|
930 | |
---|
931 | Int numIPCM = 0; |
---|
932 | Bool firstIPCMFlag = false; |
---|
933 | |
---|
934 | if( pcCU->getIPCMFlag(uiAbsPartIdx) ) |
---|
935 | { |
---|
936 | numIPCM = 1; |
---|
937 | firstIPCMFlag = true; |
---|
938 | |
---|
939 | if( !bRD ) |
---|
940 | { |
---|
941 | numIPCM = pcCU->getNumSucIPCM(); |
---|
942 | firstIPCMFlag = !pcCU->getLastCUSucIPCMFlag(); |
---|
943 | } |
---|
944 | } |
---|
945 | m_pcEntropyCoderIf->codeIPCMInfo ( pcCU, uiAbsPartIdx, numIPCM, firstIPCMFlag); |
---|
946 | |
---|
947 | } |
---|
948 | |
---|
949 | Void TEncEntropy::xEncodeTransform( TComDataCU* pcCU,UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3, Bool& bCodeDQP ) |
---|
950 | { |
---|
951 | const UInt uiSubdiv = pcCU->getTransformIdx( uiAbsPartIdx ) + pcCU->getDepth( uiAbsPartIdx ) > uiDepth; |
---|
952 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; |
---|
953 | UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA , uiTrIdx ); |
---|
954 | UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
955 | UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
956 | |
---|
957 | if(uiTrIdx==0) |
---|
958 | { |
---|
959 | m_bakAbsPartIdxCU = uiAbsPartIdx; |
---|
960 | } |
---|
961 | if( uiLog2TrafoSize == 2 ) |
---|
962 | { |
---|
963 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
964 | if( ( uiAbsPartIdx % partNum ) == 0 ) |
---|
965 | { |
---|
966 | m_uiBakAbsPartIdx = uiAbsPartIdx; |
---|
967 | m_uiBakChromaOffset = offsetChroma; |
---|
968 | } |
---|
969 | else if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
970 | { |
---|
971 | cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
972 | cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
973 | } |
---|
974 | } |
---|
975 | {//CABAC |
---|
976 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) |
---|
977 | { |
---|
978 | assert( uiSubdiv ); |
---|
979 | } |
---|
980 | else if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && (pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N) && uiDepth == pcCU->getDepth(uiAbsPartIdx) && (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) ) |
---|
981 | { |
---|
982 | if ( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) |
---|
983 | { |
---|
984 | assert( uiSubdiv ); |
---|
985 | } |
---|
986 | else |
---|
987 | { |
---|
988 | assert(!uiSubdiv ); |
---|
989 | } |
---|
990 | } |
---|
991 | else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
992 | { |
---|
993 | assert( uiSubdiv ); |
---|
994 | } |
---|
995 | else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
996 | { |
---|
997 | assert( !uiSubdiv ); |
---|
998 | } |
---|
999 | else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) |
---|
1000 | { |
---|
1001 | assert( !uiSubdiv ); |
---|
1002 | } |
---|
1003 | else |
---|
1004 | { |
---|
1005 | assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ); |
---|
1006 | m_pcEntropyCoderIf->codeTransformSubdivFlag( uiSubdiv, uiDepth ); |
---|
1007 | } |
---|
1008 | } |
---|
1009 | |
---|
1010 | { |
---|
1011 | if( uiLog2TrafoSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
1012 | { |
---|
1013 | const UInt uiTrDepthCurr = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
1014 | const Bool bFirstCbfOfCU = uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() || uiTrDepthCurr == 0; |
---|
1015 | if( bFirstCbfOfCU || uiLog2TrafoSize > 2 ) |
---|
1016 | { |
---|
1017 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) ) |
---|
1018 | { |
---|
1019 | if ( uiInnerQuadIdx == 3 && uiUCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
1020 | { |
---|
1021 | uiUCbfFront3++; |
---|
1022 | } |
---|
1023 | else |
---|
1024 | { |
---|
1025 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ); |
---|
1026 | uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ); |
---|
1027 | } |
---|
1028 | } |
---|
1029 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) ) |
---|
1030 | { |
---|
1031 | if ( uiInnerQuadIdx == 3 && uiVCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
1032 | { |
---|
1033 | uiVCbfFront3++; |
---|
1034 | } |
---|
1035 | else |
---|
1036 | { |
---|
1037 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ); |
---|
1038 | uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ); |
---|
1039 | } |
---|
1040 | } |
---|
1041 | } |
---|
1042 | else if( uiLog2TrafoSize == 2 ) |
---|
1043 | { |
---|
1044 | assert( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) ); |
---|
1045 | assert( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) ); |
---|
1046 | |
---|
1047 | uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ); |
---|
1048 | uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ); |
---|
1049 | } |
---|
1050 | } |
---|
1051 | |
---|
1052 | if( uiSubdiv ) |
---|
1053 | { |
---|
1054 | UInt size; |
---|
1055 | width >>= 1; |
---|
1056 | height >>= 1; |
---|
1057 | size = width*height; |
---|
1058 | uiTrIdx++; |
---|
1059 | ++uiDepth; |
---|
1060 | const UInt partNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
1061 | |
---|
1062 | UInt uiCurrentCbfY = 0; |
---|
1063 | UInt uiCurrentCbfU = 0; |
---|
1064 | UInt uiCurrentCbfV = 0; |
---|
1065 | |
---|
1066 | UInt nsAddr = 0; |
---|
1067 | nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, 0, uiDepth - pcCU->getDepth( uiAbsPartIdx ) ); |
---|
1068 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, nsAddr, uiDepth, width, height, uiTrIdx, 0, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV, bCodeDQP ); |
---|
1069 | |
---|
1070 | uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); |
---|
1071 | nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, 1, uiDepth - pcCU->getDepth( uiAbsPartIdx ) ); |
---|
1072 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, nsAddr, uiDepth, width, height, uiTrIdx, 1, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV, bCodeDQP ); |
---|
1073 | |
---|
1074 | uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); |
---|
1075 | nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, 2, uiDepth - pcCU->getDepth( uiAbsPartIdx ) ); |
---|
1076 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, nsAddr, uiDepth, width, height, uiTrIdx, 2, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV, bCodeDQP ); |
---|
1077 | |
---|
1078 | uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); |
---|
1079 | nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, 3, uiDepth - pcCU->getDepth( uiAbsPartIdx ) ); |
---|
1080 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, nsAddr, uiDepth, width, height, uiTrIdx, 3, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV, bCodeDQP ); |
---|
1081 | |
---|
1082 | uiYCbfFront3 += uiCurrentCbfY; |
---|
1083 | uiUCbfFront3 += uiCurrentCbfU; |
---|
1084 | uiVCbfFront3 += uiCurrentCbfV; |
---|
1085 | } |
---|
1086 | else |
---|
1087 | { |
---|
1088 | { |
---|
1089 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
1090 | DTRACE_CABAC_T( "\tTrIdx: abspart=" ); |
---|
1091 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
1092 | DTRACE_CABAC_T( "\tdepth=" ); |
---|
1093 | DTRACE_CABAC_V( uiDepth ); |
---|
1094 | DTRACE_CABAC_T( "\ttrdepth=" ); |
---|
1095 | DTRACE_CABAC_V( pcCU->getTransformIdx( uiAbsPartIdx ) ); |
---|
1096 | DTRACE_CABAC_T( "\n" ); |
---|
1097 | } |
---|
1098 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
1099 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode ); |
---|
1100 | if(pcCU->getPredictionMode( uiAbsPartIdx ) == MODE_INTER && pcCU->useNonSquarePU( uiAbsPartIdx ) ) |
---|
1101 | { |
---|
1102 | pcCU->setNSQTIdxSubParts( uiLog2TrafoSize, uiAbsPartIdx, absTUPartIdx, uiLumaTrMode ); |
---|
1103 | } |
---|
1104 | if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) |
---|
1105 | { |
---|
1106 | assert( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, 0 ) ); |
---|
1107 | // printf( "saved one bin! " ); |
---|
1108 | } |
---|
1109 | else |
---|
1110 | { |
---|
1111 | const UInt uiLog2CUSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - pcCU->getDepth( uiAbsPartIdx ); |
---|
1112 | if ( pcCU->getPredictionMode( uiAbsPartIdx ) != MODE_INTRA && uiInnerQuadIdx == 3 && uiYCbfFront3 == 0 && uiUCbfFront3 == 0 && uiVCbfFront3 == 0 |
---|
1113 | && ( uiLog2CUSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() + 1 || uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) ) |
---|
1114 | { |
---|
1115 | uiYCbfFront3++; |
---|
1116 | } |
---|
1117 | else |
---|
1118 | { |
---|
1119 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode ); |
---|
1120 | uiYCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode ); |
---|
1121 | } |
---|
1122 | } |
---|
1123 | |
---|
1124 | if ( cbfY || cbfU || cbfV ) |
---|
1125 | { |
---|
1126 | // dQP: only for LCU once |
---|
1127 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
1128 | { |
---|
1129 | if ( bCodeDQP ) |
---|
1130 | { |
---|
1131 | encodeQP( pcCU, m_bakAbsPartIdxCU ); |
---|
1132 | bCodeDQP = false; |
---|
1133 | } |
---|
1134 | } |
---|
1135 | } |
---|
1136 | if( cbfY ) |
---|
1137 | { |
---|
1138 | Int trWidth = width; |
---|
1139 | Int trHeight = height; |
---|
1140 | pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight ); |
---|
1141 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); |
---|
1142 | } |
---|
1143 | if( uiLog2TrafoSize > 2 ) |
---|
1144 | { |
---|
1145 | Int trWidth = width >> 1; |
---|
1146 | Int trHeight = height >> 1; |
---|
1147 | pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight ); |
---|
1148 | if( cbfU ) |
---|
1149 | { |
---|
1150 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
1151 | } |
---|
1152 | if( cbfV ) |
---|
1153 | { |
---|
1154 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
1155 | } |
---|
1156 | } |
---|
1157 | else |
---|
1158 | { |
---|
1159 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
1160 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
1161 | { |
---|
1162 | Int trWidth = width; |
---|
1163 | Int trHeight = height; |
---|
1164 | pcCU->getNSQTSize( uiTrIdx - 1, uiAbsPartIdx, trWidth, trHeight ); |
---|
1165 | if( cbfU ) |
---|
1166 | { |
---|
1167 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
1168 | } |
---|
1169 | if( cbfV ) |
---|
1170 | { |
---|
1171 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
1172 | } |
---|
1173 | } |
---|
1174 | } |
---|
1175 | } |
---|
1176 | } |
---|
1177 | } |
---|
1178 | |
---|
1179 | |
---|
1180 | // Intra direction for Luma |
---|
1181 | Void TEncEntropy::encodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1182 | { |
---|
1183 | m_pcEntropyCoderIf->codeIntraDirLumaAng( pcCU, uiAbsPartIdx ); |
---|
1184 | } |
---|
1185 | |
---|
1186 | // Intra direction for Chroma |
---|
1187 | Void TEncEntropy::encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
1188 | { |
---|
1189 | if( bRD ) |
---|
1190 | { |
---|
1191 | uiAbsPartIdx = 0; |
---|
1192 | } |
---|
1193 | |
---|
1194 | m_pcEntropyCoderIf->codeIntraDirChroma( pcCU, uiAbsPartIdx ); |
---|
1195 | } |
---|
1196 | |
---|
1197 | Void TEncEntropy::encodePredInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
1198 | { |
---|
1199 | if( bRD ) |
---|
1200 | { |
---|
1201 | uiAbsPartIdx = 0; |
---|
1202 | } |
---|
1203 | |
---|
1204 | #if RWTH_SDC_DLT_B0036 |
---|
1205 | if( pcCU->getSDCFlag(uiAbsPartIdx) ) |
---|
1206 | { |
---|
1207 | encodeSDCPredMode(pcCU, uiAbsPartIdx, bRD); |
---|
1208 | return; |
---|
1209 | } |
---|
1210 | #endif |
---|
1211 | |
---|
1212 | PartSize eSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
1213 | |
---|
1214 | if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. |
---|
1215 | { |
---|
1216 | if( eSize == SIZE_NxN ) // if it is NxN size, encode 4 intra directions. |
---|
1217 | { |
---|
1218 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2; |
---|
1219 | // if it is NxN size, this size might be the smallest partition size. |
---|
1220 | encodeIntraDirModeLuma( pcCU, uiAbsPartIdx ); |
---|
1221 | encodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset ); |
---|
1222 | encodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset*2 ); |
---|
1223 | encodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset*3 ); |
---|
1224 | encodeIntraDirModeChroma( pcCU, uiAbsPartIdx, bRD ); |
---|
1225 | } |
---|
1226 | else // if it is not NxN size, encode 1 intra directions |
---|
1227 | { |
---|
1228 | encodeIntraDirModeLuma ( pcCU, uiAbsPartIdx ); |
---|
1229 | encodeIntraDirModeChroma( pcCU, uiAbsPartIdx, bRD ); |
---|
1230 | } |
---|
1231 | } |
---|
1232 | else // if it is Inter mode, encode motion vector and reference index |
---|
1233 | { |
---|
1234 | encodePUWise( pcCU, uiAbsPartIdx, bRD ); |
---|
1235 | } |
---|
1236 | } |
---|
1237 | |
---|
1238 | /** encode motion information for every PU block |
---|
1239 | * \param pcCU |
---|
1240 | * \param uiAbsPartIdx |
---|
1241 | * \param bRD |
---|
1242 | * \returns Void |
---|
1243 | */ |
---|
1244 | Void TEncEntropy::encodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
1245 | { |
---|
1246 | if ( bRD ) |
---|
1247 | { |
---|
1248 | uiAbsPartIdx = 0; |
---|
1249 | } |
---|
1250 | |
---|
1251 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
1252 | UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); |
---|
1253 | UInt uiDepth = pcCU->getDepth( uiAbsPartIdx ); |
---|
1254 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
1255 | |
---|
1256 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
---|
1257 | { |
---|
1258 | encodeMergeFlag( pcCU, uiSubPartIdx, uiPartIdx ); |
---|
1259 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
---|
1260 | { |
---|
1261 | encodeMergeIndex( pcCU, uiSubPartIdx, uiPartIdx ); |
---|
1262 | } |
---|
1263 | else |
---|
1264 | { |
---|
1265 | encodeInterDirPU( pcCU, uiSubPartIdx ); |
---|
1266 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
1267 | { |
---|
1268 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
1269 | { |
---|
1270 | encodeRefFrmIdxPU ( pcCU, uiSubPartIdx, RefPicList( uiRefListIdx ) ); |
---|
1271 | encodeMvdPU ( pcCU, uiSubPartIdx, RefPicList( uiRefListIdx ) ); |
---|
1272 | encodeMVPIdxPU ( pcCU, uiSubPartIdx, RefPicList( uiRefListIdx ) ); |
---|
1273 | } |
---|
1274 | } |
---|
1275 | } |
---|
1276 | } |
---|
1277 | |
---|
1278 | return; |
---|
1279 | } |
---|
1280 | |
---|
1281 | Void TEncEntropy::encodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1282 | { |
---|
1283 | if ( !pcCU->getSlice()->isInterB() ) |
---|
1284 | { |
---|
1285 | return; |
---|
1286 | } |
---|
1287 | |
---|
1288 | m_pcEntropyCoderIf->codeInterDir( pcCU, uiAbsPartIdx ); |
---|
1289 | return; |
---|
1290 | } |
---|
1291 | |
---|
1292 | /** encode reference frame index for a PU block |
---|
1293 | * \param pcCU |
---|
1294 | * \param uiAbsPartIdx |
---|
1295 | * \param eRefList |
---|
1296 | * \returns Void |
---|
1297 | */ |
---|
1298 | Void TEncEntropy::encodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
1299 | { |
---|
1300 | assert( !pcCU->isIntra( uiAbsPartIdx ) ); |
---|
1301 | |
---|
1302 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C)>0 && pcCU->getInterDir( uiAbsPartIdx ) != 3) |
---|
1303 | { |
---|
1304 | if ((eRefList== REF_PIC_LIST_1) || ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_C ) == 1 ) ) |
---|
1305 | { |
---|
1306 | return; |
---|
1307 | } |
---|
1308 | |
---|
1309 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
1310 | { |
---|
1311 | m_pcEntropyCoderIf->codeRefFrmIdx( pcCU, uiAbsPartIdx, RefPicList(pcCU->getInterDir( uiAbsPartIdx )-1) ); |
---|
1312 | } |
---|
1313 | |
---|
1314 | } |
---|
1315 | else |
---|
1316 | { |
---|
1317 | if ( ( pcCU->getSlice()->getNumRefIdx( eRefList ) == 1 ) ) |
---|
1318 | { |
---|
1319 | return; |
---|
1320 | } |
---|
1321 | |
---|
1322 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
1323 | { |
---|
1324 | m_pcEntropyCoderIf->codeRefFrmIdx( pcCU, uiAbsPartIdx, eRefList ); |
---|
1325 | } |
---|
1326 | } |
---|
1327 | |
---|
1328 | return; |
---|
1329 | } |
---|
1330 | |
---|
1331 | /** encode motion vector difference for a PU block |
---|
1332 | * \param pcCU |
---|
1333 | * \param uiAbsPartIdx |
---|
1334 | * \param eRefList |
---|
1335 | * \returns Void |
---|
1336 | */ |
---|
1337 | Void TEncEntropy::encodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
1338 | { |
---|
1339 | assert( !pcCU->isIntra( uiAbsPartIdx ) ); |
---|
1340 | |
---|
1341 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
1342 | { |
---|
1343 | m_pcEntropyCoderIf->codeMvd( pcCU, uiAbsPartIdx, eRefList ); |
---|
1344 | } |
---|
1345 | return; |
---|
1346 | } |
---|
1347 | |
---|
1348 | Void TEncEntropy::encodeMVPIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
1349 | { |
---|
1350 | if ( (pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList )) && (pcCU->getAMVPMode(uiAbsPartIdx) == AM_EXPL) ) |
---|
1351 | { |
---|
1352 | #if H3D_IVMP |
---|
1353 | const Int iNumCands = AMVP_MAX_NUM_CANDS + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); |
---|
1354 | m_pcEntropyCoderIf->codeMVPIdx( pcCU, uiAbsPartIdx, eRefList, iNumCands ); |
---|
1355 | #else |
---|
1356 | m_pcEntropyCoderIf->codeMVPIdx( pcCU, uiAbsPartIdx, eRefList ); |
---|
1357 | #endif |
---|
1358 | } |
---|
1359 | |
---|
1360 | return; |
---|
1361 | } |
---|
1362 | |
---|
1363 | Void TEncEntropy::encodeQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
1364 | { |
---|
1365 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, eType, uiTrDepth ); |
---|
1366 | } |
---|
1367 | |
---|
1368 | Void TEncEntropy::encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) |
---|
1369 | { |
---|
1370 | m_pcEntropyCoderIf->codeTransformSubdivFlag( uiSymbol, uiCtx ); |
---|
1371 | } |
---|
1372 | |
---|
1373 | Void TEncEntropy::encodeQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1374 | { |
---|
1375 | m_pcEntropyCoderIf->codeQtRootCbf( pcCU, uiAbsPartIdx ); |
---|
1376 | } |
---|
1377 | |
---|
1378 | // dQP |
---|
1379 | Void TEncEntropy::encodeQP( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
1380 | { |
---|
1381 | if( bRD ) |
---|
1382 | { |
---|
1383 | uiAbsPartIdx = 0; |
---|
1384 | } |
---|
1385 | |
---|
1386 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
1387 | { |
---|
1388 | m_pcEntropyCoderIf->codeDeltaQP( pcCU, uiAbsPartIdx ); |
---|
1389 | } |
---|
1390 | } |
---|
1391 | |
---|
1392 | |
---|
1393 | // texture |
---|
1394 | |
---|
1395 | /** encode coefficients |
---|
1396 | * \param pcCU |
---|
1397 | * \param uiAbsPartIdx |
---|
1398 | * \param uiDepth |
---|
1399 | * \param uiWidth |
---|
1400 | * \param uiHeight |
---|
1401 | */ |
---|
1402 | Void TEncEntropy::encodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ) |
---|
1403 | { |
---|
1404 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
1405 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
1406 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
1407 | |
---|
1408 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
1409 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode ); |
---|
1410 | |
---|
1411 | #if RWTH_SDC_DLT_B0036 |
---|
1412 | if( pcCU->getSDCFlag( uiAbsPartIdx ) ) |
---|
1413 | { |
---|
1414 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
1415 | assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); |
---|
1416 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); |
---|
1417 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); |
---|
1418 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); |
---|
1419 | |
---|
1420 | encodeSDCResidualData(pcCU, uiAbsPartIdx); |
---|
1421 | return; |
---|
1422 | } |
---|
1423 | #endif |
---|
1424 | |
---|
1425 | if( pcCU->isIntra(uiAbsPartIdx) ) |
---|
1426 | { |
---|
1427 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
1428 | DTRACE_CABAC_T( "\tdecodeTransformIdx()\tCUDepth=" ) |
---|
1429 | DTRACE_CABAC_V( uiDepth ) |
---|
1430 | DTRACE_CABAC_T( "\n" ) |
---|
1431 | } |
---|
1432 | else |
---|
1433 | { |
---|
1434 | { |
---|
1435 | #if HHI_MPI |
---|
1436 | if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N && |
---|
1437 | ( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth == pcCU->getTextureModeDepth( uiAbsPartIdx ) ) ) ) |
---|
1438 | #else |
---|
1439 | if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ) ) |
---|
1440 | #endif |
---|
1441 | { |
---|
1442 | m_pcEntropyCoderIf->codeQtRootCbf( pcCU, uiAbsPartIdx ); |
---|
1443 | } |
---|
1444 | if ( !pcCU->getQtRootCbf( uiAbsPartIdx ) ) |
---|
1445 | { |
---|
1446 | #if 1 // MW Bug Fix |
---|
1447 | pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth ); |
---|
1448 | pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
1449 | #endif |
---|
1450 | pcCU->setNSQTIdxSubParts( uiAbsPartIdx, uiDepth ); |
---|
1451 | return; |
---|
1452 | } |
---|
1453 | } |
---|
1454 | } |
---|
1455 | |
---|
1456 | #if FIX_MPI_B0065 |
---|
1457 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getMergeIndex( uiAbsPartIdx ) == 0 && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 ) |
---|
1458 | { |
---|
1459 | TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() ); |
---|
1460 | if( uiDepth == pcTextureCU->getDepth(uiAbsPartIdx)) |
---|
1461 | { |
---|
1462 | PartSize partSize = pcTextureCU->getPartitionSize(uiAbsPartIdx); |
---|
1463 | pcCU->setPartSizeSubParts( partSize, uiAbsPartIdx, uiDepth ); |
---|
1464 | } |
---|
1465 | else |
---|
1466 | { |
---|
1467 | pcCU->setPartSizeSubParts( SIZE_NxN, uiAbsPartIdx, uiDepth ); |
---|
1468 | } |
---|
1469 | } |
---|
1470 | #endif |
---|
1471 | |
---|
1472 | UInt temp = 0; |
---|
1473 | UInt temp1 = 0; |
---|
1474 | UInt temp2 = 0; |
---|
1475 | xEncodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, 0, temp, temp1, temp2, bCodeDQP ); |
---|
1476 | |
---|
1477 | #if FIX_MPI_B0065 |
---|
1478 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getMergeIndex( uiAbsPartIdx ) == 0 && pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N && pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 ) |
---|
1479 | { |
---|
1480 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
1481 | } |
---|
1482 | #endif |
---|
1483 | } |
---|
1484 | |
---|
1485 | Void TEncEntropy::encodeCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiTrWidth, UInt uiTrHeight, UInt uiDepth, TextType eType ) |
---|
1486 | { // This is for Transform unit processing. This may be used at mode selection stage for Inter. |
---|
1487 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, pcCoeff, uiAbsPartIdx, uiTrWidth, uiTrHeight, uiDepth, eType ); |
---|
1488 | } |
---|
1489 | |
---|
1490 | Void TEncEntropy::estimateBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) |
---|
1491 | { |
---|
1492 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : TEXT_CHROMA; |
---|
1493 | |
---|
1494 | m_pcEntropyCoderIf->estBit ( pcEstBitsSbac, width, height, eTType ); |
---|
1495 | } |
---|
1496 | |
---|
1497 | /** Encode SAO Offset |
---|
1498 | * \param saoLcuParam SAO LCU paramters |
---|
1499 | */ |
---|
1500 | Void TEncEntropy::encodeSaoOffset(SaoLcuParam* saoLcuParam) |
---|
1501 | { |
---|
1502 | UInt uiSymbol; |
---|
1503 | Int i; |
---|
1504 | |
---|
1505 | uiSymbol = saoLcuParam->typeIdx + 1; |
---|
1506 | m_pcEntropyCoderIf->codeSaoTypeIdx(uiSymbol); |
---|
1507 | if (uiSymbol) |
---|
1508 | { |
---|
1509 | if( saoLcuParam->typeIdx == SAO_BO ) |
---|
1510 | { |
---|
1511 | // Code Left Band Index |
---|
1512 | uiSymbol = (UInt) (saoLcuParam->bandPosition); |
---|
1513 | m_pcEntropyCoderIf->codeSaoUflc(uiSymbol); |
---|
1514 | for( i=0; i< saoLcuParam->length; i++) |
---|
1515 | { |
---|
1516 | m_pcEntropyCoderIf->codeSaoSvlc(saoLcuParam->offset[i]); |
---|
1517 | } |
---|
1518 | } |
---|
1519 | else |
---|
1520 | if( saoLcuParam->typeIdx < 4 ) |
---|
1521 | { |
---|
1522 | m_pcEntropyCoderIf->codeSaoUvlc( saoLcuParam->offset[0]); |
---|
1523 | m_pcEntropyCoderIf->codeSaoUvlc( saoLcuParam->offset[1]); |
---|
1524 | m_pcEntropyCoderIf->codeSaoUvlc(-saoLcuParam->offset[2]); |
---|
1525 | m_pcEntropyCoderIf->codeSaoUvlc(-saoLcuParam->offset[3]); |
---|
1526 | } |
---|
1527 | } |
---|
1528 | } |
---|
1529 | /** Encode SAO unit |
---|
1530 | * \param rx |
---|
1531 | * \param ry |
---|
1532 | * \param iCompIdx |
---|
1533 | * \param pSaoParam |
---|
1534 | * \param bRepeatedRow |
---|
1535 | */ |
---|
1536 | Void TEncEntropy::encodeSaoUnit(Int rx, Int ry, Int compIdx, SAOParam* saoParam, Int repeatedRow ) |
---|
1537 | { |
---|
1538 | int addr, addrLeft; |
---|
1539 | int numCuInWidth = saoParam->numCuInWidth; |
---|
1540 | SaoLcuParam* saoOneLcu; |
---|
1541 | Int runLeft; |
---|
1542 | |
---|
1543 | addr = rx + ry*numCuInWidth; |
---|
1544 | addrLeft = (addr%numCuInWidth == 0) ? -1 : addr - 1; |
---|
1545 | |
---|
1546 | if (!repeatedRow) |
---|
1547 | { |
---|
1548 | saoOneLcu = &(saoParam->saoLcuParam[compIdx][addr]); |
---|
1549 | runLeft = (addrLeft>=0 ) ? saoParam->saoLcuParam[compIdx][addrLeft].run : -1; |
---|
1550 | if (rx == 0 || runLeft==0) |
---|
1551 | { |
---|
1552 | if (ry == 0) |
---|
1553 | { |
---|
1554 | m_pcEntropyCoderIf->codeSaoRun(saoOneLcu->runDiff, numCuInWidth-rx-1); |
---|
1555 | saoOneLcu->mergeUpFlag = 0; |
---|
1556 | } |
---|
1557 | else |
---|
1558 | { |
---|
1559 | m_pcEntropyCoderIf->codeSaoSvlc(saoOneLcu->runDiff); |
---|
1560 | m_pcEntropyCoderIf->codeSaoFlag(saoOneLcu->mergeUpFlag); |
---|
1561 | } |
---|
1562 | if (!saoOneLcu->mergeUpFlag) |
---|
1563 | { |
---|
1564 | encodeSaoOffset(saoOneLcu); |
---|
1565 | } |
---|
1566 | } |
---|
1567 | } |
---|
1568 | } |
---|
1569 | |
---|
1570 | /** Encode SAO unit interleaving |
---|
1571 | * \param rx |
---|
1572 | * \param ry |
---|
1573 | * \param pSaoParam |
---|
1574 | * \param pcCU |
---|
1575 | * \param iCUAddrInSlice |
---|
1576 | * \param iCUAddrUpInSlice |
---|
1577 | * \param bLFCrossSliceBoundaryFlag |
---|
1578 | */ |
---|
1579 | Void TEncEntropy::encodeSaoUnitInterleaving(Int rx, Int ry, SAOParam* saoParam, TComDataCU* cu, Int cuAddrInSlice, Int cuAddrUpInSlice, Bool lfCrossSliceBoundaryFlag) |
---|
1580 | { |
---|
1581 | Int addr = cu->getAddr(); |
---|
1582 | for (Int compIdx=0; compIdx<3; compIdx++) |
---|
1583 | { |
---|
1584 | if (saoParam->bSaoFlag[compIdx]) |
---|
1585 | { |
---|
1586 | if (rx>0 && cuAddrInSlice!=0) |
---|
1587 | { |
---|
1588 | m_pcEntropyCoderIf->codeSaoMergeLeft(saoParam->saoLcuParam[compIdx][addr].mergeLeftFlag,compIdx); |
---|
1589 | } |
---|
1590 | else |
---|
1591 | { |
---|
1592 | saoParam->saoLcuParam[compIdx][addr].mergeLeftFlag = 0; |
---|
1593 | } |
---|
1594 | if (saoParam->saoLcuParam[compIdx][addr].mergeLeftFlag == 0) |
---|
1595 | { |
---|
1596 | if ( (ry > 0) && (cuAddrUpInSlice>0||lfCrossSliceBoundaryFlag)) |
---|
1597 | { |
---|
1598 | m_pcEntropyCoderIf->codeSaoMergeUp(saoParam->saoLcuParam[compIdx][addr].mergeUpFlag); |
---|
1599 | } |
---|
1600 | else |
---|
1601 | { |
---|
1602 | saoParam->saoLcuParam[compIdx][addr].mergeUpFlag = 0; |
---|
1603 | } |
---|
1604 | if (!saoParam->saoLcuParam[compIdx][addr].mergeUpFlag) |
---|
1605 | { |
---|
1606 | encodeSaoOffset(&(saoParam->saoLcuParam[compIdx][addr])); |
---|
1607 | } |
---|
1608 | } |
---|
1609 | } |
---|
1610 | } |
---|
1611 | } |
---|
1612 | |
---|
1613 | /** Encode SAO parameter |
---|
1614 | * \param pcAPS |
---|
1615 | */ |
---|
1616 | Void TEncEntropy::encodeSaoParam(TComAPS* aps) |
---|
1617 | { |
---|
1618 | SaoLcuParam* psSaoOneLcu; |
---|
1619 | int i,j,k, compIdx; |
---|
1620 | int numCuInWidth ; |
---|
1621 | int numCuInHeight ; |
---|
1622 | Bool repeatedRow[3]; |
---|
1623 | Int addr; |
---|
1624 | m_pcEntropyCoderIf->codeSaoFlag(aps->getSaoInterleavingFlag()); |
---|
1625 | if(!aps->getSaoInterleavingFlag()) |
---|
1626 | { |
---|
1627 | m_pcEntropyCoderIf->codeSaoFlag(aps->getSaoEnabled()); |
---|
1628 | if (aps->getSaoEnabled()) |
---|
1629 | { |
---|
1630 | SAOParam* pSaoParam = aps->getSaoParam(); |
---|
1631 | numCuInWidth = pSaoParam->numCuInWidth; |
---|
1632 | numCuInHeight = pSaoParam->numCuInHeight; |
---|
1633 | m_pcEntropyCoderIf->codeSaoFlag(pSaoParam->bSaoFlag[1]); |
---|
1634 | m_pcEntropyCoderIf->codeSaoFlag(pSaoParam->bSaoFlag[2]); |
---|
1635 | m_pcEntropyCoderIf->codeSaoUvlc(numCuInWidth-1); |
---|
1636 | m_pcEntropyCoderIf->codeSaoUvlc(numCuInHeight-1); |
---|
1637 | for (compIdx=0;compIdx<3;compIdx++) |
---|
1638 | { |
---|
1639 | if (pSaoParam->bSaoFlag[compIdx]) |
---|
1640 | { |
---|
1641 | m_pcEntropyCoderIf->codeSaoFlag(pSaoParam->oneUnitFlag[compIdx]); |
---|
1642 | if (pSaoParam->oneUnitFlag[compIdx]) |
---|
1643 | { |
---|
1644 | psSaoOneLcu = &(pSaoParam->saoLcuParam[compIdx][0]); |
---|
1645 | encodeSaoOffset(psSaoOneLcu); |
---|
1646 | } |
---|
1647 | } |
---|
1648 | } |
---|
1649 | |
---|
1650 | for (j=0;j<numCuInHeight;j++) |
---|
1651 | { |
---|
1652 | for (compIdx=0; compIdx<3; compIdx++) |
---|
1653 | { |
---|
1654 | repeatedRow[compIdx] = true; |
---|
1655 | for (k=0;k<numCuInWidth;k++) |
---|
1656 | { |
---|
1657 | addr = k + j*numCuInWidth; |
---|
1658 | psSaoOneLcu = &(pSaoParam->saoLcuParam[compIdx][addr]); |
---|
1659 | if (!psSaoOneLcu->mergeUpFlag || psSaoOneLcu->runDiff) |
---|
1660 | { |
---|
1661 | repeatedRow[compIdx] = false; |
---|
1662 | break; |
---|
1663 | } |
---|
1664 | } |
---|
1665 | } |
---|
1666 | for (i=0;i<numCuInWidth;i++) |
---|
1667 | { |
---|
1668 | for (compIdx=0; compIdx<3; compIdx++) |
---|
1669 | { |
---|
1670 | if (pSaoParam->bSaoFlag[compIdx] && !pSaoParam->oneUnitFlag[compIdx]) |
---|
1671 | { |
---|
1672 | if (j>0 && i==0) |
---|
1673 | { |
---|
1674 | m_pcEntropyCoderIf->codeSaoFlag(repeatedRow[compIdx]); |
---|
1675 | } |
---|
1676 | encodeSaoUnit (i,j, compIdx, pSaoParam, repeatedRow[compIdx]); |
---|
1677 | } |
---|
1678 | } |
---|
1679 | } |
---|
1680 | } |
---|
1681 | } |
---|
1682 | } |
---|
1683 | } |
---|
1684 | |
---|
1685 | Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ) |
---|
1686 | { |
---|
1687 | Int count = 0; |
---|
1688 | |
---|
1689 | for ( Int i = 0; i < uiSize; i++ ) |
---|
1690 | { |
---|
1691 | count += pcCoef[i] != 0; |
---|
1692 | } |
---|
1693 | |
---|
1694 | return count; |
---|
1695 | } |
---|
1696 | |
---|
1697 | /** encode quantization matrix |
---|
1698 | * \param scalingList quantization matrix information |
---|
1699 | */ |
---|
1700 | Void TEncEntropy::encodeScalingList( TComScalingList* scalingList ) |
---|
1701 | { |
---|
1702 | m_pcEntropyCoderIf->codeScalingList( scalingList ); |
---|
1703 | } |
---|
1704 | |
---|
1705 | Void TEncEntropy::encodeDFParams(TComAPS* pcAPS) |
---|
1706 | { |
---|
1707 | m_pcEntropyCoderIf->codeDFFlag(pcAPS->getLoopFilterDisable(), "loop_filter_disable"); |
---|
1708 | |
---|
1709 | if (!pcAPS->getLoopFilterDisable()) |
---|
1710 | { |
---|
1711 | m_pcEntropyCoderIf->codeDFSvlc(pcAPS->getLoopFilterBetaOffset(), "beta_offset_div2"); |
---|
1712 | m_pcEntropyCoderIf->codeDFSvlc(pcAPS->getLoopFilterTcOffset(), "tc_offset_div2"); |
---|
1713 | } |
---|
1714 | } |
---|
1715 | |
---|
1716 | #if RWTH_SDC_DLT_B0036 |
---|
1717 | Void TEncEntropy::encodeSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
1718 | { |
---|
1719 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
1720 | |
---|
1721 | if( bRD ) |
---|
1722 | uiAbsPartIdx = 0; |
---|
1723 | |
---|
1724 | m_pcEntropyCoderIf->codeSDCPredMode(pcCU, uiAbsPartIdx); |
---|
1725 | } |
---|
1726 | |
---|
1727 | Void TEncEntropy::encodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
1728 | { |
---|
1729 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
1730 | |
---|
1731 | if( bRD ) |
---|
1732 | uiAbsPartIdx = 0; |
---|
1733 | |
---|
1734 | m_pcEntropyCoderIf->codeSDCFlag(pcCU, uiAbsPartIdx); |
---|
1735 | } |
---|
1736 | |
---|
1737 | Void TEncEntropy::encodeSDCResidualData( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
1738 | { |
---|
1739 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
1740 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); |
---|
1741 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); |
---|
1742 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); |
---|
1743 | assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); |
---|
1744 | |
---|
1745 | if( bRD ) |
---|
1746 | uiAbsPartIdx = 0; |
---|
1747 | |
---|
1748 | // number of segments depends on prediction mode for INTRA |
---|
1749 | UInt uiNumSegments = 2; |
---|
1750 | UInt uiLumaPredMode = pcCU->getLumaIntraDir( uiAbsPartIdx ); |
---|
1751 | if( uiLumaPredMode == DC_IDX || uiLumaPredMode == PLANAR_IDX ) |
---|
1752 | uiNumSegments = 1; |
---|
1753 | |
---|
1754 | // encode residual data for each segment |
---|
1755 | for( UInt uiSeg = 0; uiSeg < uiNumSegments; uiSeg++ ) |
---|
1756 | m_pcEntropyCoderIf->codeSDCResidualData(pcCU, uiAbsPartIdx, uiSeg); |
---|
1757 | } |
---|
1758 | #endif |
---|
1759 | |
---|
1760 | //! \} |
---|