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 TComSlice.cpp |
---|
35 | \brief slice header and SPS class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "CommonDef.h" |
---|
39 | #include "TComSlice.h" |
---|
40 | #include "TComPic.h" |
---|
41 | #include "TLibEncoder/TEncSbac.h" |
---|
42 | #include "TLibDecoder/TDecSbac.h" |
---|
43 | |
---|
44 | |
---|
45 | //! \ingroup TLibCommon |
---|
46 | //! \{ |
---|
47 | |
---|
48 | TComSlice::TComSlice() |
---|
49 | : m_iPPSId ( -1 ) |
---|
50 | , m_PicOutputFlag ( true ) |
---|
51 | #if NH_MV |
---|
52 | , m_slicePicOrderCntLsb ( 0 ) |
---|
53 | #endif |
---|
54 | , m_iPOC ( 0 ) |
---|
55 | , m_iLastIDR ( 0 ) |
---|
56 | , m_iAssociatedIRAP ( 0 ) |
---|
57 | , m_iAssociatedIRAPType ( NAL_UNIT_INVALID ) |
---|
58 | , m_pRPS ( 0 ) |
---|
59 | , m_localRPS ( ) |
---|
60 | , m_rpsIdx ( 0 ) |
---|
61 | , m_RefPicListModification ( ) |
---|
62 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
63 | , m_eSliceType ( I_SLICE ) |
---|
64 | , m_iSliceQp ( 0 ) |
---|
65 | , m_dependentSliceSegmentFlag ( false ) |
---|
66 | #if ADAPTIVE_QP_SELECTION |
---|
67 | , m_iSliceQpBase ( 0 ) |
---|
68 | #endif |
---|
69 | , m_ChromaQpAdjEnabled ( false ) |
---|
70 | , m_deblockingFilterDisable ( false ) |
---|
71 | , m_deblockingFilterOverrideFlag ( false ) |
---|
72 | , m_deblockingFilterBetaOffsetDiv2( 0 ) |
---|
73 | , m_deblockingFilterTcOffsetDiv2 ( 0 ) |
---|
74 | , m_bCheckLDC ( false ) |
---|
75 | , m_iSliceQpDelta ( 0 ) |
---|
76 | , m_iDepth ( 0 ) |
---|
77 | , m_bRefenced ( false ) |
---|
78 | , m_pcVPS ( NULL ) |
---|
79 | , m_pcSPS ( NULL ) |
---|
80 | , m_pcPPS ( NULL ) |
---|
81 | , m_pcPic ( NULL ) |
---|
82 | , m_colFromL0Flag ( true ) |
---|
83 | , m_noOutputPriorPicsFlag ( false ) |
---|
84 | , m_noRaslOutputFlag ( false ) |
---|
85 | , m_handleCraAsBlaFlag ( false ) |
---|
86 | , m_colRefIdx ( 0 ) |
---|
87 | , m_maxNumMergeCand ( 0 ) |
---|
88 | , m_uiTLayer ( 0 ) |
---|
89 | , m_bTLayerSwitchingFlag ( false ) |
---|
90 | , m_sliceMode ( NO_SLICES ) |
---|
91 | , m_sliceArgument ( 0 ) |
---|
92 | , m_sliceCurStartCtuTsAddr ( 0 ) |
---|
93 | , m_sliceCurEndCtuTsAddr ( 0 ) |
---|
94 | , m_sliceIdx ( 0 ) |
---|
95 | , m_sliceSegmentMode ( NO_SLICES ) |
---|
96 | , m_sliceSegmentArgument ( 0 ) |
---|
97 | , m_sliceSegmentCurStartCtuTsAddr ( 0 ) |
---|
98 | , m_sliceSegmentCurEndCtuTsAddr ( 0 ) |
---|
99 | , m_nextSlice ( false ) |
---|
100 | , m_nextSliceSegment ( false ) |
---|
101 | , m_sliceBits ( 0 ) |
---|
102 | , m_sliceSegmentBits ( 0 ) |
---|
103 | , m_bFinalized ( false ) |
---|
104 | , m_bTestWeightPred ( false ) |
---|
105 | , m_bTestWeightBiPred ( false ) |
---|
106 | , m_substreamSizes ( ) |
---|
107 | , m_cabacInitFlag ( false ) |
---|
108 | , m_bLMvdL1Zero ( false ) |
---|
109 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
110 | , m_LFCrossSliceBoundaryFlag ( false ) |
---|
111 | , m_enableTMVPFlag ( true ) |
---|
112 | , m_encCABACTableIdx (I_SLICE) |
---|
113 | #if NH_MV |
---|
114 | , m_availableForTMVPRefFlag ( true ) |
---|
115 | , m_refPicSetInterLayer0 ( NULL ) |
---|
116 | , m_refPicSetInterLayer1 ( NULL ) |
---|
117 | , m_layerId (0) |
---|
118 | , m_viewId (0) |
---|
119 | , m_viewIndex (0) |
---|
120 | #if NH_3D |
---|
121 | , m_isDepth (false) |
---|
122 | #endif |
---|
123 | #if !H_MV_HLS7_GEN |
---|
124 | , m_pocResetFlag (false) |
---|
125 | #endif |
---|
126 | #if NH_MV |
---|
127 | , m_crossLayerBlaFlag (false) |
---|
128 | #endif |
---|
129 | , m_discardableFlag (false) |
---|
130 | , m_interLayerPredEnabledFlag (false) |
---|
131 | , m_numInterLayerRefPicsMinus1 (0) |
---|
132 | #if NH_MV |
---|
133 | , m_sliceSegmentHeaderExtensionLength (0) |
---|
134 | , m_pocResetIdc (0) |
---|
135 | , m_pocResetPeriodId (0) |
---|
136 | , m_fullPocResetFlag (false) |
---|
137 | , m_pocLsbVal (0) |
---|
138 | , m_pocMsbValPresentFlag (false) |
---|
139 | , m_pocMsbVal (0) |
---|
140 | , m_pocMsbValRequiredFlag (false) |
---|
141 | #endif |
---|
142 | #if NH_3D_IC |
---|
143 | , m_bApplyIC (false) |
---|
144 | , m_icSkipParseFlag (false) |
---|
145 | #endif |
---|
146 | #if NH_3D |
---|
147 | , m_inCmpPredFlag (false) |
---|
148 | , m_numViews (0) |
---|
149 | , m_depthToDisparityB (NULL) |
---|
150 | , m_depthToDisparityF (NULL) |
---|
151 | #endif |
---|
152 | #if NH_3D_DIS |
---|
153 | , m_bApplyDIS (false) |
---|
154 | #endif |
---|
155 | #endif |
---|
156 | { |
---|
157 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
158 | { |
---|
159 | m_aiNumRefIdx[i] = 0; |
---|
160 | } |
---|
161 | |
---|
162 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
163 | { |
---|
164 | m_lambdas [component] = 0.0; |
---|
165 | m_iSliceChromaQpDelta[component] = 0; |
---|
166 | } |
---|
167 | |
---|
168 | initEqualRef(); |
---|
169 | |
---|
170 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
171 | { |
---|
172 | m_list1IdxToList0Idx[idx] = -1; |
---|
173 | } |
---|
174 | |
---|
175 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
176 | { |
---|
177 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
178 | { |
---|
179 | m_apcRefPicList [i][iNumCount] = NULL; |
---|
180 | m_aiRefPOCList [i][iNumCount] = 0; |
---|
181 | } |
---|
182 | #if NH_MV |
---|
183 | m_aiRefLayerIdList[0][iNumCount] = 0; |
---|
184 | m_aiRefLayerIdList[1][iNumCount] = 0; |
---|
185 | #endif |
---|
186 | } |
---|
187 | |
---|
188 | resetWpScaling(); |
---|
189 | initWpAcDcParam(); |
---|
190 | |
---|
191 | for(Int ch=0; ch < MAX_NUM_CHANNEL_TYPE; ch++) |
---|
192 | { |
---|
193 | m_saoEnabledFlag[ch] = false; |
---|
194 | } |
---|
195 | #if NH_MV |
---|
196 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
197 | { |
---|
198 | m_interLayerPredLayerIdc[ i ] = -1; |
---|
199 | } |
---|
200 | #endif |
---|
201 | #if NH_3D |
---|
202 | m_iDefaultRefViewIdx = -1; |
---|
203 | m_bDefaultRefViewIdxAvailableFlag = false; |
---|
204 | m_ivMvPredFlag = false; |
---|
205 | m_ivMvScalingFlag = false; |
---|
206 | m_ivResPredFlag = false; |
---|
207 | m_depthRefinementFlag = false; |
---|
208 | m_viewSynthesisPredFlag = false; |
---|
209 | m_depthBasedBlkPartFlag = false; |
---|
210 | m_mpiFlag = false; |
---|
211 | m_intraContourFlag = false; |
---|
212 | m_intraSdcWedgeFlag = false; |
---|
213 | m_qtPredFlag = false; |
---|
214 | m_interSdcFlag = false; |
---|
215 | m_depthIntraSkipFlag = false; |
---|
216 | m_subPbSize = 1 << 6; |
---|
217 | m_mpiSubPbSize = 1 << 6; |
---|
218 | |
---|
219 | m_aaiCodedOffset.resize(2); |
---|
220 | m_aaiCodedScale .resize(2); |
---|
221 | for (Int i = 0; i < 2; i++) |
---|
222 | { |
---|
223 | m_aaiCodedOffset[i].resize(MAX_NUM_LAYERS); |
---|
224 | m_aaiCodedScale [i].resize(MAX_NUM_LAYERS); |
---|
225 | } |
---|
226 | |
---|
227 | #endif |
---|
228 | |
---|
229 | } |
---|
230 | |
---|
231 | TComSlice::~TComSlice() |
---|
232 | { |
---|
233 | #if NH_3D |
---|
234 | for( UInt i = 0; i < m_numViews; i++ ) |
---|
235 | { |
---|
236 | if ( m_depthToDisparityB && m_depthToDisparityB[ i ] ) |
---|
237 | { |
---|
238 | delete[] m_depthToDisparityB [ i ]; |
---|
239 | } |
---|
240 | |
---|
241 | if ( m_depthToDisparityF && m_depthToDisparityF[ i ] ) |
---|
242 | { |
---|
243 | delete[] m_depthToDisparityF [ i ]; |
---|
244 | } |
---|
245 | } |
---|
246 | |
---|
247 | if ( m_depthToDisparityF ) |
---|
248 | { |
---|
249 | delete[] m_depthToDisparityF; |
---|
250 | } |
---|
251 | |
---|
252 | m_depthToDisparityF = NULL; |
---|
253 | |
---|
254 | if ( m_depthToDisparityB ) |
---|
255 | delete[] m_depthToDisparityB; |
---|
256 | |
---|
257 | m_depthToDisparityB = NULL; |
---|
258 | #endif |
---|
259 | |
---|
260 | } |
---|
261 | |
---|
262 | |
---|
263 | Void TComSlice::initSlice() |
---|
264 | { |
---|
265 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
266 | { |
---|
267 | m_aiNumRefIdx[i] = 0; |
---|
268 | } |
---|
269 | m_colFromL0Flag = true; |
---|
270 | |
---|
271 | m_colRefIdx = 0; |
---|
272 | initEqualRef(); |
---|
273 | |
---|
274 | m_bCheckLDC = false; |
---|
275 | |
---|
276 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
277 | { |
---|
278 | m_iSliceChromaQpDelta[component] = 0; |
---|
279 | } |
---|
280 | #if NH_3D_IV_MERGE |
---|
281 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS_MEM; |
---|
282 | #else |
---|
283 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
284 | #endif |
---|
285 | |
---|
286 | m_bFinalized=false; |
---|
287 | |
---|
288 | m_substreamSizes.clear(); |
---|
289 | m_cabacInitFlag = false; |
---|
290 | m_enableTMVPFlag = true; |
---|
291 | #if NH_3D_TMVP |
---|
292 | m_aiAlterRefIdx[0] = -1; |
---|
293 | m_aiAlterRefIdx[1] = -1; |
---|
294 | #endif |
---|
295 | } |
---|
296 | |
---|
297 | Bool TComSlice::getRapPicFlag() const |
---|
298 | { |
---|
299 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
300 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
301 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
302 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
303 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
304 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
305 | } |
---|
306 | |
---|
307 | |
---|
308 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
309 | { |
---|
310 | TComPic* pcPicExtract; |
---|
311 | TComPic* pcPicInsert; |
---|
312 | |
---|
313 | TComList<TComPic*>::iterator iterPicExtract; |
---|
314 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
315 | TComList<TComPic*>::iterator iterPicInsert; |
---|
316 | |
---|
317 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
318 | { |
---|
319 | iterPicExtract = rcListPic.begin(); |
---|
320 | for (Int j = 0; j < i; j++) |
---|
321 | { |
---|
322 | iterPicExtract++; |
---|
323 | } |
---|
324 | pcPicExtract = *(iterPicExtract); |
---|
325 | pcPicExtract->setCurrSliceIdx(0); |
---|
326 | |
---|
327 | iterPicInsert = rcListPic.begin(); |
---|
328 | while (iterPicInsert != iterPicExtract) |
---|
329 | { |
---|
330 | pcPicInsert = *(iterPicInsert); |
---|
331 | pcPicInsert->setCurrSliceIdx(0); |
---|
332 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
333 | { |
---|
334 | break; |
---|
335 | } |
---|
336 | |
---|
337 | iterPicInsert++; |
---|
338 | } |
---|
339 | |
---|
340 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
341 | |
---|
342 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
343 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
344 | rcListPic.erase (iterPicExtract); |
---|
345 | } |
---|
346 | } |
---|
347 | |
---|
348 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, Int poc) |
---|
349 | { |
---|
350 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
351 | TComPic* pcPic = *(iterPic); |
---|
352 | while ( iterPic != rcListPic.end() ) |
---|
353 | { |
---|
354 | if(pcPic->getPOC() == poc) |
---|
355 | { |
---|
356 | break; |
---|
357 | } |
---|
358 | iterPic++; |
---|
359 | pcPic = *(iterPic); |
---|
360 | } |
---|
361 | return pcPic; |
---|
362 | } |
---|
363 | |
---|
364 | |
---|
365 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
366 | { |
---|
367 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
368 | TComPic* pcPic = *(iterPic); |
---|
369 | TComPic* pcStPic = pcPic; |
---|
370 | |
---|
371 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
372 | if (!pocHasMsb) |
---|
373 | { |
---|
374 | poc = poc & (pocCycle - 1); |
---|
375 | } |
---|
376 | |
---|
377 | while ( iterPic != rcListPic.end() ) |
---|
378 | { |
---|
379 | pcPic = *(iterPic); |
---|
380 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
381 | { |
---|
382 | Int picPoc = pcPic->getPOC(); |
---|
383 | if (!pocHasMsb) |
---|
384 | { |
---|
385 | picPoc = picPoc & (pocCycle - 1); |
---|
386 | } |
---|
387 | |
---|
388 | if (poc == picPoc) |
---|
389 | { |
---|
390 | if(pcPic->getIsLongTerm()) |
---|
391 | { |
---|
392 | return pcPic; |
---|
393 | } |
---|
394 | else |
---|
395 | { |
---|
396 | pcStPic = pcPic; |
---|
397 | } |
---|
398 | break; |
---|
399 | } |
---|
400 | } |
---|
401 | |
---|
402 | iterPic++; |
---|
403 | } |
---|
404 | |
---|
405 | return pcStPic; |
---|
406 | } |
---|
407 | |
---|
408 | Void TComSlice::setRefPOCList () |
---|
409 | { |
---|
410 | for (Int iDir = 0; iDir < NUM_REF_PIC_LIST_01; iDir++) |
---|
411 | { |
---|
412 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
413 | { |
---|
414 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
415 | #if NH_MV |
---|
416 | m_aiRefLayerIdList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getLayerId(); |
---|
417 | #endif |
---|
418 | } |
---|
419 | } |
---|
420 | |
---|
421 | } |
---|
422 | |
---|
423 | Void TComSlice::setList1IdxToList0Idx() |
---|
424 | { |
---|
425 | Int idxL0, idxL1; |
---|
426 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
427 | { |
---|
428 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
429 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
430 | { |
---|
431 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
432 | { |
---|
433 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
434 | break; |
---|
435 | } |
---|
436 | } |
---|
437 | } |
---|
438 | } |
---|
439 | |
---|
440 | #if !NH_MV |
---|
441 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) |
---|
442 | { |
---|
443 | if (!checkNumPocTotalCurr) |
---|
444 | { |
---|
445 | if (m_eSliceType == I_SLICE) |
---|
446 | { |
---|
447 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
448 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
449 | |
---|
450 | return; |
---|
451 | } |
---|
452 | |
---|
453 | m_aiNumRefIdx[REF_PIC_LIST_0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
454 | m_aiNumRefIdx[REF_PIC_LIST_1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
455 | } |
---|
456 | |
---|
457 | TComPic* pcRefPic= NULL; |
---|
458 | static const UInt MAX_NUM_NEGATIVE_PICTURES=16; |
---|
459 | TComPic* RefPicSetStCurr0[MAX_NUM_NEGATIVE_PICTURES]; |
---|
460 | TComPic* RefPicSetStCurr1[MAX_NUM_NEGATIVE_PICTURES]; |
---|
461 | TComPic* RefPicSetLtCurr[MAX_NUM_NEGATIVE_PICTURES]; |
---|
462 | UInt NumPicStCurr0 = 0; |
---|
463 | UInt NumPicStCurr1 = 0; |
---|
464 | UInt NumPicLtCurr = 0; |
---|
465 | Int i; |
---|
466 | |
---|
467 | for(i=0; i < m_pRPS->getNumberOfNegativePictures(); i++) |
---|
468 | { |
---|
469 | if(m_pRPS->getUsed(i)) |
---|
470 | { |
---|
471 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pRPS->getDeltaPOC(i)); |
---|
472 | pcRefPic->setIsLongTerm(0); |
---|
473 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
474 | RefPicSetStCurr0[NumPicStCurr0] = pcRefPic; |
---|
475 | NumPicStCurr0++; |
---|
476 | pcRefPic->setCheckLTMSBPresent(false); |
---|
477 | } |
---|
478 | } |
---|
479 | |
---|
480 | for(; i < m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures(); i++) |
---|
481 | { |
---|
482 | if(m_pRPS->getUsed(i)) |
---|
483 | { |
---|
484 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pRPS->getDeltaPOC(i)); |
---|
485 | pcRefPic->setIsLongTerm(0); |
---|
486 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
487 | RefPicSetStCurr1[NumPicStCurr1] = pcRefPic; |
---|
488 | NumPicStCurr1++; |
---|
489 | pcRefPic->setCheckLTMSBPresent(false); |
---|
490 | } |
---|
491 | } |
---|
492 | |
---|
493 | for(i = m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures()+m_pRPS->getNumberOfLongtermPictures()-1; i > m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
494 | { |
---|
495 | if(m_pRPS->getUsed(i)) |
---|
496 | { |
---|
497 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pRPS->getPOC(i), m_pRPS->getCheckLTMSBPresent(i)); |
---|
498 | pcRefPic->setIsLongTerm(1); |
---|
499 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
500 | RefPicSetLtCurr[NumPicLtCurr] = pcRefPic; |
---|
501 | NumPicLtCurr++; |
---|
502 | } |
---|
503 | if(pcRefPic==NULL) |
---|
504 | { |
---|
505 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pRPS->getPOC(i), m_pRPS->getCheckLTMSBPresent(i)); |
---|
506 | } |
---|
507 | pcRefPic->setCheckLTMSBPresent(m_pRPS->getCheckLTMSBPresent(i)); |
---|
508 | } |
---|
509 | |
---|
510 | // ref_pic_list_init |
---|
511 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
512 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
513 | Int numPicTotalCurr = NumPicStCurr0 + NumPicStCurr1 + NumPicLtCurr; |
---|
514 | |
---|
515 | if (checkNumPocTotalCurr) |
---|
516 | { |
---|
517 | // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr: |
---|
518 | // - If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
519 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
520 | if (getRapPicFlag()) |
---|
521 | { |
---|
522 | assert(numPicTotalCurr == 0); |
---|
523 | } |
---|
524 | |
---|
525 | if (m_eSliceType == I_SLICE) |
---|
526 | { |
---|
527 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
528 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
529 | |
---|
530 | return; |
---|
531 | } |
---|
532 | |
---|
533 | assert(numPicTotalCurr > 0); |
---|
534 | // general tier and level limit: |
---|
535 | assert(numPicTotalCurr <= 8); |
---|
536 | |
---|
537 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
538 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
539 | } |
---|
540 | |
---|
541 | Int cIdx = 0; |
---|
542 | for ( i=0; i<NumPicStCurr0; i++, cIdx++) |
---|
543 | { |
---|
544 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
545 | } |
---|
546 | for ( i=0; i<NumPicStCurr1; i++, cIdx++) |
---|
547 | { |
---|
548 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
549 | } |
---|
550 | for ( i=0; i<NumPicLtCurr; i++, cIdx++) |
---|
551 | { |
---|
552 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
553 | } |
---|
554 | assert(cIdx == numPicTotalCurr); |
---|
555 | |
---|
556 | if (m_eSliceType==B_SLICE) |
---|
557 | { |
---|
558 | cIdx = 0; |
---|
559 | for ( i=0; i<NumPicStCurr1; i++, cIdx++) |
---|
560 | { |
---|
561 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
562 | } |
---|
563 | for ( i=0; i<NumPicStCurr0; i++, cIdx++) |
---|
564 | { |
---|
565 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
566 | } |
---|
567 | for ( i=0; i<NumPicLtCurr; i++, cIdx++) |
---|
568 | { |
---|
569 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
570 | } |
---|
571 | assert(cIdx == numPicTotalCurr); |
---|
572 | } |
---|
573 | |
---|
574 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
575 | |
---|
576 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[REF_PIC_LIST_0]; rIdx ++) |
---|
577 | { |
---|
578 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPicTotalCurr; |
---|
579 | assert(cIdx >= 0 && cIdx < numPicTotalCurr); |
---|
580 | m_apcRefPicList[REF_PIC_LIST_0][rIdx] = rpsCurrList0[ cIdx ]; |
---|
581 | m_bIsUsedAsLongTerm[REF_PIC_LIST_0][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 ); |
---|
582 | } |
---|
583 | if ( m_eSliceType != B_SLICE ) |
---|
584 | { |
---|
585 | m_aiNumRefIdx[REF_PIC_LIST_1] = 0; |
---|
586 | ::memset( m_apcRefPicList[REF_PIC_LIST_1], 0, sizeof(m_apcRefPicList[REF_PIC_LIST_1])); |
---|
587 | } |
---|
588 | else |
---|
589 | { |
---|
590 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[REF_PIC_LIST_1]; rIdx ++) |
---|
591 | { |
---|
592 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPicTotalCurr; |
---|
593 | assert(cIdx >= 0 && cIdx < numPicTotalCurr); |
---|
594 | m_apcRefPicList[REF_PIC_LIST_1][rIdx] = rpsCurrList1[ cIdx ]; |
---|
595 | m_bIsUsedAsLongTerm[REF_PIC_LIST_1][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 ); |
---|
596 | } |
---|
597 | } |
---|
598 | } |
---|
599 | #else |
---|
600 | Void TComSlice::getTempRefPicLists( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1, |
---|
601 | std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int& numPocTotalCurr, Bool checkNumPocTotalCurr ) |
---|
602 | { |
---|
603 | if (!checkNumPocTotalCurr) |
---|
604 | { |
---|
605 | if (m_eSliceType == I_SLICE) |
---|
606 | { |
---|
607 | return; |
---|
608 | } |
---|
609 | } |
---|
610 | |
---|
611 | TComPic* pcRefPic= NULL; |
---|
612 | TComPic* RefPicSetStCurr0[16]; |
---|
613 | TComPic* RefPicSetStCurr1[16]; |
---|
614 | TComPic* RefPicSetLtCurr[16]; |
---|
615 | UInt NumPocStCurr0 = 0; |
---|
616 | UInt NumPocStCurr1 = 0; |
---|
617 | UInt NumPocLtCurr = 0; |
---|
618 | Int i; |
---|
619 | #if NH_3D |
---|
620 | m_pocsInCurrRPSs.clear(); |
---|
621 | #endif |
---|
622 | for(i=0; i < m_pRPS->getNumberOfNegativePictures(); i++) |
---|
623 | { |
---|
624 | if(m_pRPS->getUsed(i)) |
---|
625 | { |
---|
626 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pRPS->getDeltaPOC(i)); |
---|
627 | pcRefPic->setIsLongTerm(0); |
---|
628 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
629 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
630 | NumPocStCurr0++; |
---|
631 | pcRefPic->setCheckLTMSBPresent(false); |
---|
632 | #if NH_3D |
---|
633 | m_pocsInCurrRPSs.push_back( pcRefPic->getPOC() ); |
---|
634 | #endif |
---|
635 | } |
---|
636 | } |
---|
637 | |
---|
638 | for(; i < m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures(); i++) |
---|
639 | { |
---|
640 | if(m_pRPS->getUsed(i)) |
---|
641 | { |
---|
642 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pRPS->getDeltaPOC(i)); |
---|
643 | pcRefPic->setIsLongTerm(0); |
---|
644 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
645 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
646 | NumPocStCurr1++; |
---|
647 | pcRefPic->setCheckLTMSBPresent(false); |
---|
648 | #if NH_3D |
---|
649 | m_pocsInCurrRPSs.push_back( pcRefPic->getPOC() ); |
---|
650 | #endif |
---|
651 | } |
---|
652 | } |
---|
653 | |
---|
654 | for(i = m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures()+m_pRPS->getNumberOfLongtermPictures()-1; i > m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
655 | { |
---|
656 | if(m_pRPS->getUsed(i)) |
---|
657 | { |
---|
658 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pRPS->getPOC(i), m_pRPS->getCheckLTMSBPresent(i)); |
---|
659 | pcRefPic->setIsLongTerm(1); |
---|
660 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
661 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
662 | NumPocLtCurr++; |
---|
663 | #if NH_3D |
---|
664 | m_pocsInCurrRPSs.push_back( pcRefPic->getPOC() ); |
---|
665 | #endif |
---|
666 | } |
---|
667 | if(pcRefPic==NULL) |
---|
668 | { |
---|
669 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pRPS->getPOC(i), m_pRPS->getCheckLTMSBPresent(i)); |
---|
670 | } |
---|
671 | pcRefPic->setCheckLTMSBPresent(m_pRPS->getCheckLTMSBPresent(i)); |
---|
672 | } |
---|
673 | |
---|
674 | Int numPocInterCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
675 | #if NH_3D |
---|
676 | assert( numPocInterCurr == (Int) m_pocsInCurrRPSs.size() ); |
---|
677 | #endif |
---|
678 | numPocTotalCurr = numPocInterCurr + getNumActiveRefLayerPics( ); |
---|
679 | assert( numPocTotalCurr == getNumRpsCurrTempList() ); |
---|
680 | |
---|
681 | if (checkNumPocTotalCurr) |
---|
682 | { |
---|
683 | // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr: |
---|
684 | // - If nuh_layer_id is equal to 0 and the current picture is a BLA picture or a CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
685 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
686 | if ( getRapPicFlag() && m_layerId == 0 ) |
---|
687 | { |
---|
688 | assert(numPocTotalCurr == 0); |
---|
689 | } |
---|
690 | |
---|
691 | if (m_eSliceType == I_SLICE) |
---|
692 | { |
---|
693 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
694 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
695 | |
---|
696 | return; |
---|
697 | } |
---|
698 | |
---|
699 | assert(numPocTotalCurr > 0); |
---|
700 | |
---|
701 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
702 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
703 | } |
---|
704 | |
---|
705 | std::vector<TComPic*>* refPicSetInterLayer[2] = { &refPicSetInterLayer0, &refPicSetInterLayer1}; |
---|
706 | Int numPocInterLayer[2] = { getNumActiveRefLayerPics0( ), getNumActiveRefLayerPics1( ) }; |
---|
707 | |
---|
708 | TComPic** refPicSetStCurr [2] = { RefPicSetStCurr0, RefPicSetStCurr1 }; |
---|
709 | Int numPocStCurr[2] = { (Int)NumPocStCurr0, (Int)NumPocStCurr1 }; |
---|
710 | |
---|
711 | for (Int li = 0; li < ((m_eSliceType==B_SLICE) ? 2 : 1); li++) |
---|
712 | { |
---|
713 | rpsCurrList [li].resize(MAX_NUM_REF+1,NULL ); |
---|
714 | usedAsLongTerm[li].resize(MAX_NUM_REF+1,false); |
---|
715 | |
---|
716 | Int cIdx = 0; |
---|
717 | for ( i=0; i < numPocStCurr[li]; i++, cIdx++) |
---|
718 | { |
---|
719 | rpsCurrList[li][cIdx] = refPicSetStCurr[li][i]; |
---|
720 | usedAsLongTerm [li][cIdx] = false; |
---|
721 | } |
---|
722 | |
---|
723 | for ( i=0; i < numPocInterLayer[li]; i++, cIdx++) |
---|
724 | { |
---|
725 | rpsCurrList[li][cIdx] = (*refPicSetInterLayer[li])[i]; |
---|
726 | usedAsLongTerm [li][cIdx] = true; |
---|
727 | } |
---|
728 | |
---|
729 | for ( i=0; i < numPocStCurr[1-li]; i++, cIdx++) |
---|
730 | { |
---|
731 | rpsCurrList[li][cIdx] = refPicSetStCurr[1-li][i]; |
---|
732 | usedAsLongTerm [li][cIdx] = false; |
---|
733 | } |
---|
734 | |
---|
735 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
736 | { |
---|
737 | rpsCurrList[li][cIdx] = RefPicSetLtCurr[i]; |
---|
738 | usedAsLongTerm [li][cIdx] = true; |
---|
739 | } |
---|
740 | |
---|
741 | for ( i=0; i < numPocInterLayer[1-li]; i++, cIdx++) |
---|
742 | { |
---|
743 | assert( cIdx < MAX_NUM_REF ); |
---|
744 | rpsCurrList[li][cIdx] = (*refPicSetInterLayer[1-li])[i]; |
---|
745 | usedAsLongTerm [li][cIdx] = true; |
---|
746 | } |
---|
747 | |
---|
748 | assert(cIdx == numPocTotalCurr); |
---|
749 | } |
---|
750 | } |
---|
751 | |
---|
752 | Void TComSlice::setRefPicList( std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int numPocTotalCurr, Bool checkNumPocTotalCurr ) |
---|
753 | |
---|
754 | { |
---|
755 | if (!checkNumPocTotalCurr) |
---|
756 | { |
---|
757 | if (m_eSliceType == I_SLICE) |
---|
758 | { |
---|
759 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
760 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
761 | |
---|
762 | return; |
---|
763 | } |
---|
764 | } |
---|
765 | |
---|
766 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
767 | |
---|
768 | for (Int li = 0; li < 2; li++) |
---|
769 | { |
---|
770 | if ( m_eSliceType == P_SLICE && li == 1 ) |
---|
771 | { |
---|
772 | m_aiNumRefIdx[1] = 0; |
---|
773 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
774 | } |
---|
775 | else |
---|
776 | { |
---|
777 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[ li ] - 1 ); rIdx ++) |
---|
778 | { |
---|
779 | Bool listModified = m_RefPicListModification.getRefPicListModificationFlagL( li ); |
---|
780 | Int orgIdx = listModified ? m_RefPicListModification.getRefPicSetIdxL(li, rIdx) : (rIdx % numPocTotalCurr); |
---|
781 | |
---|
782 | assert( rpsCurrList[li][ orgIdx ] != NULL ); |
---|
783 | assert( rpsCurrList[li][ orgIdx ]->getSlice(0)->getDiscardableFlag() == 0 ); // Inter-layer RPS shall not contain picture with discardable_flag = 1. |
---|
784 | m_apcRefPicList [li][rIdx] = rpsCurrList [li][ orgIdx ]; |
---|
785 | m_bIsUsedAsLongTerm[li][rIdx] = usedAsLongTerm [li][ orgIdx ] ; |
---|
786 | } |
---|
787 | } |
---|
788 | } |
---|
789 | } |
---|
790 | #endif |
---|
791 | |
---|
792 | Int TComSlice::getNumRpsCurrTempList() const |
---|
793 | { |
---|
794 | Int numRpsCurrTempList = 0; |
---|
795 | |
---|
796 | if (m_eSliceType == I_SLICE) |
---|
797 | { |
---|
798 | return 0; |
---|
799 | } |
---|
800 | for(UInt i=0; i < m_pRPS->getNumberOfNegativePictures()+ m_pRPS->getNumberOfPositivePictures() + m_pRPS->getNumberOfLongtermPictures(); i++) |
---|
801 | { |
---|
802 | if(m_pRPS->getUsed(i)) |
---|
803 | { |
---|
804 | numRpsCurrTempList++; |
---|
805 | } |
---|
806 | } |
---|
807 | #if NH_MV |
---|
808 | numRpsCurrTempList = numRpsCurrTempList + getNumActiveRefLayerPics(); |
---|
809 | #endif |
---|
810 | return numRpsCurrTempList; |
---|
811 | } |
---|
812 | |
---|
813 | Void TComSlice::initEqualRef() |
---|
814 | { |
---|
815 | for (Int iDir = 0; iDir < NUM_REF_PIC_LIST_01; iDir++) |
---|
816 | { |
---|
817 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
818 | { |
---|
819 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
820 | { |
---|
821 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
822 | } |
---|
823 | } |
---|
824 | } |
---|
825 | } |
---|
826 | #if NH_3D |
---|
827 | #if NH_3D_TMVP |
---|
828 | Void TComSlice::generateAlterRefforTMVP() |
---|
829 | { |
---|
830 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
831 | { |
---|
832 | if ( this->getNumRefIdx( RefPicList( uiRefListIdx ) ) == 0) |
---|
833 | { |
---|
834 | continue; |
---|
835 | } |
---|
836 | Bool bZeroIdxLtFlag = this->getRefPic(RefPicList(uiRefListIdx), 0)->getIsLongTerm(); |
---|
837 | for(Int i = 1; i < this->getNumRefIdx(RefPicList(uiRefListIdx)); i++ ) |
---|
838 | { |
---|
839 | if ( ( bZeroIdxLtFlag && !this->getRefPic(RefPicList(uiRefListIdx), i)->getIsLongTerm() ) || |
---|
840 | (!bZeroIdxLtFlag && this->getRefPic(RefPicList(uiRefListIdx), i)->getIsLongTerm() ) ) |
---|
841 | { |
---|
842 | this->setAlterRefIdx(RefPicList(uiRefListIdx),i); |
---|
843 | break; |
---|
844 | } |
---|
845 | } |
---|
846 | } |
---|
847 | } |
---|
848 | #endif |
---|
849 | #endif |
---|
850 | |
---|
851 | #if NH_3D |
---|
852 | Void TComSlice::setCamparaSlice( Int** aaiScale, Int** aaiOffset ) |
---|
853 | { |
---|
854 | Int voiInVps = m_pcVPS->getVoiInVps(getViewIndex() ); |
---|
855 | if( m_pcVPS->getNumCp( voiInVps ) > 0 ) |
---|
856 | { |
---|
857 | if( m_pcVPS->getCpInSliceSegmentHeaderFlag( voiInVps ) ) |
---|
858 | { |
---|
859 | for( Int m = 0; m < m_pcVPS->getNumCp( voiInVps ); m++ ) |
---|
860 | { |
---|
861 | Int j = m_pcVPS->getCpRefVoi( voiInVps, m ); |
---|
862 | Int jInVps = m_pcVPS->getVoiInVps( j ); |
---|
863 | |
---|
864 | setCpScale ( jInVps , aaiScale [ jInVps ][ voiInVps ]); |
---|
865 | setCpInvScale( jInVps , aaiScale [ voiInVps ][ jInVps ]); |
---|
866 | setCpOff ( jInVps , aaiOffset[ jInVps ][ voiInVps ]); |
---|
867 | setCpInvOff ( jInVps , aaiOffset[ voiInVps ][ jInVps ]); |
---|
868 | } |
---|
869 | } |
---|
870 | } |
---|
871 | } |
---|
872 | #endif |
---|
873 | |
---|
874 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
875 | { |
---|
876 | Int i; |
---|
877 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
878 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1 - curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
879 | TComSlice* preSlice; |
---|
880 | Int preColRefPOC; |
---|
881 | for(i=curSliceIdx-1; i>=0; i--) |
---|
882 | { |
---|
883 | preSlice = pic->getSlice(i); |
---|
884 | if(preSlice->getSliceType() != I_SLICE) |
---|
885 | { |
---|
886 | preColRefPOC = preSlice->getRefPOC( RefPicList(1 - preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
887 | if(currColRefPOC != preColRefPOC) |
---|
888 | { |
---|
889 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
890 | exit(EXIT_FAILURE); |
---|
891 | } |
---|
892 | else |
---|
893 | { |
---|
894 | break; |
---|
895 | } |
---|
896 | } |
---|
897 | } |
---|
898 | } |
---|
899 | |
---|
900 | Void TComSlice::checkCRA(const TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic) |
---|
901 | { |
---|
902 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
903 | { |
---|
904 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
905 | { |
---|
906 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
907 | } |
---|
908 | } |
---|
909 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
910 | { |
---|
911 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
912 | { |
---|
913 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
914 | { |
---|
915 | assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA); |
---|
916 | } |
---|
917 | else |
---|
918 | { |
---|
919 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
920 | } |
---|
921 | } |
---|
922 | } |
---|
923 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
924 | { |
---|
925 | pocCRA = getPOC(); |
---|
926 | associatedIRAPType = getNalUnitType(); |
---|
927 | } |
---|
928 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
929 | { |
---|
930 | pocCRA = getPOC(); |
---|
931 | associatedIRAPType = getNalUnitType(); |
---|
932 | } |
---|
933 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
934 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
935 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
936 | { |
---|
937 | pocCRA = getPOC(); |
---|
938 | associatedIRAPType = getNalUnitType(); |
---|
939 | } |
---|
940 | } |
---|
941 | |
---|
942 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
943 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
944 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
945 | * \param rcListPic reference to the reference picture list |
---|
946 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
947 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
948 | * are marked as "unused for reference" |
---|
949 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
950 | * Otherwise |
---|
951 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
952 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
953 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
954 | * the bRefreshPending flag to false. |
---|
955 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
956 | * reference of the current picture. |
---|
957 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
958 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
959 | */ |
---|
960 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, const bool bEfficientFieldIRAPEnabled) |
---|
961 | { |
---|
962 | TComPic* rpcPic; |
---|
963 | Int pocCurr = getPOC(); |
---|
964 | |
---|
965 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
966 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
967 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
968 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
969 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
970 | { |
---|
971 | // mark all pictures as not used for reference |
---|
972 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
973 | while (iterPic != rcListPic.end()) |
---|
974 | { |
---|
975 | rpcPic = *(iterPic); |
---|
976 | rpcPic->setCurrSliceIdx(0); |
---|
977 | if (rpcPic->getPOC() != pocCurr) |
---|
978 | { |
---|
979 | rpcPic->getSlice(0)->setReferenced(false); |
---|
980 | } |
---|
981 | iterPic++; |
---|
982 | } |
---|
983 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
984 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
985 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
986 | { |
---|
987 | pocCRA = pocCurr; |
---|
988 | } |
---|
989 | if (bEfficientFieldIRAPEnabled) |
---|
990 | { |
---|
991 | bRefreshPending = true; |
---|
992 | } |
---|
993 | } |
---|
994 | else // CRA or No DR |
---|
995 | { |
---|
996 | if(bEfficientFieldIRAPEnabled && (getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
997 | { |
---|
998 | if (bRefreshPending==true && pocCurr > m_iLastIDR) // IDR reference marking pending |
---|
999 | { |
---|
1000 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1001 | while (iterPic != rcListPic.end()) |
---|
1002 | { |
---|
1003 | rpcPic = *(iterPic); |
---|
1004 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != m_iLastIDR) |
---|
1005 | { |
---|
1006 | rpcPic->getSlice(0)->setReferenced(false); |
---|
1007 | } |
---|
1008 | iterPic++; |
---|
1009 | } |
---|
1010 | bRefreshPending = false; |
---|
1011 | } |
---|
1012 | } |
---|
1013 | else |
---|
1014 | { |
---|
1015 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
1016 | { |
---|
1017 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1018 | while (iterPic != rcListPic.end()) |
---|
1019 | { |
---|
1020 | rpcPic = *(iterPic); |
---|
1021 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
1022 | { |
---|
1023 | rpcPic->getSlice(0)->setReferenced(false); |
---|
1024 | } |
---|
1025 | iterPic++; |
---|
1026 | } |
---|
1027 | bRefreshPending = false; |
---|
1028 | } |
---|
1029 | } |
---|
1030 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
1031 | { |
---|
1032 | bRefreshPending = true; |
---|
1033 | pocCRA = pocCurr; |
---|
1034 | } |
---|
1035 | } |
---|
1036 | } |
---|
1037 | |
---|
1038 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
1039 | { |
---|
1040 | assert( pSrc != NULL ); |
---|
1041 | |
---|
1042 | Int i, j, k; |
---|
1043 | |
---|
1044 | m_iPOC = pSrc->m_iPOC; |
---|
1045 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
1046 | #if NH_MV |
---|
1047 | m_layerId = pSrc->m_layerId; |
---|
1048 | // GT: Copying of several other values might be be missing here, or is above not necessary? |
---|
1049 | #endif |
---|
1050 | m_eSliceType = pSrc->m_eSliceType; |
---|
1051 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
1052 | #if ADAPTIVE_QP_SELECTION |
---|
1053 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
1054 | #endif |
---|
1055 | m_ChromaQpAdjEnabled = pSrc->m_ChromaQpAdjEnabled; |
---|
1056 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
1057 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
1058 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
1059 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
1060 | |
---|
1061 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
1062 | { |
---|
1063 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
1064 | } |
---|
1065 | |
---|
1066 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
1067 | { |
---|
1068 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
1069 | } |
---|
1070 | |
---|
1071 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
1072 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
1073 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
1074 | { |
---|
1075 | m_iSliceChromaQpDelta[component] = pSrc->m_iSliceChromaQpDelta[component]; |
---|
1076 | } |
---|
1077 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
1078 | { |
---|
1079 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1080 | { |
---|
1081 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
1082 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
1083 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
1084 | #if NH_MV |
---|
1085 | m_aiRefLayerIdList[i][j] = pSrc->m_aiRefLayerIdList[i][j]; |
---|
1086 | #endif |
---|
1087 | } |
---|
1088 | m_bIsUsedAsLongTerm[i][MAX_NUM_REF] = pSrc->m_bIsUsedAsLongTerm[i][MAX_NUM_REF]; |
---|
1089 | } |
---|
1090 | m_iDepth = pSrc->m_iDepth; |
---|
1091 | |
---|
1092 | // referenced slice |
---|
1093 | m_bRefenced = pSrc->m_bRefenced; |
---|
1094 | |
---|
1095 | // access channel |
---|
1096 | #if NH_MV |
---|
1097 | m_pcVPS = pSrc->m_pcVPS; |
---|
1098 | #endif |
---|
1099 | m_pRPS = pSrc->m_pRPS; m_iLastIDR = pSrc->m_iLastIDR; |
---|
1100 | |
---|
1101 | m_pcPic = pSrc->m_pcPic; |
---|
1102 | |
---|
1103 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
1104 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
1105 | |
---|
1106 | setLambdas(pSrc->getLambdas()); |
---|
1107 | |
---|
1108 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
1109 | { |
---|
1110 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1111 | { |
---|
1112 | for (k =0; k < MAX_NUM_REF; k++) |
---|
1113 | { |
---|
1114 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
1115 | } |
---|
1116 | } |
---|
1117 | } |
---|
1118 | |
---|
1119 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
1120 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
1121 | |
---|
1122 | m_sliceMode = pSrc->m_sliceMode; |
---|
1123 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
1124 | m_sliceCurStartCtuTsAddr = pSrc->m_sliceCurStartCtuTsAddr; |
---|
1125 | m_sliceCurEndCtuTsAddr = pSrc->m_sliceCurEndCtuTsAddr; |
---|
1126 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
1127 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
1128 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
1129 | m_sliceSegmentCurStartCtuTsAddr = pSrc->m_sliceSegmentCurStartCtuTsAddr; |
---|
1130 | m_sliceSegmentCurEndCtuTsAddr = pSrc->m_sliceSegmentCurEndCtuTsAddr; |
---|
1131 | m_nextSlice = pSrc->m_nextSlice; |
---|
1132 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
1133 | |
---|
1134 | for ( UInt e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
1135 | { |
---|
1136 | for ( UInt n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
1137 | { |
---|
1138 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(WPScalingParam)*MAX_NUM_COMPONENT ); |
---|
1139 | } |
---|
1140 | } |
---|
1141 | |
---|
1142 | for( UInt ch = 0 ; ch < MAX_NUM_CHANNEL_TYPE; ch++) |
---|
1143 | { |
---|
1144 | m_saoEnabledFlag[ch] = pSrc->m_saoEnabledFlag[ch]; |
---|
1145 | } |
---|
1146 | |
---|
1147 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
1148 | |
---|
1149 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
1150 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
1151 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
1152 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
1153 | m_encCABACTableIdx = pSrc->m_encCABACTableIdx; |
---|
1154 | |
---|
1155 | #if NH_MV |
---|
1156 | // Additional slice header syntax elements |
---|
1157 | #if !H_MV_HLS7_GEN |
---|
1158 | m_pocResetFlag = pSrc->m_pocResetFlag; |
---|
1159 | #endif |
---|
1160 | m_discardableFlag = pSrc->m_discardableFlag; |
---|
1161 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
1162 | m_numInterLayerRefPicsMinus1 = pSrc->m_numInterLayerRefPicsMinus1; |
---|
1163 | |
---|
1164 | for (Int layer = 0; layer < MAX_NUM_LAYERS; layer++ ) |
---|
1165 | { |
---|
1166 | m_interLayerPredLayerIdc[ layer ] = pSrc->m_interLayerPredLayerIdc[ layer ]; |
---|
1167 | } |
---|
1168 | #endif |
---|
1169 | #if NH_3D_DIS |
---|
1170 | m_bApplyDIS = pSrc->m_bApplyDIS; |
---|
1171 | #endif |
---|
1172 | #if NH_3D_IC |
---|
1173 | m_bApplyIC = pSrc->m_bApplyIC; |
---|
1174 | m_icSkipParseFlag = pSrc->m_icSkipParseFlag; |
---|
1175 | #endif |
---|
1176 | |
---|
1177 | } |
---|
1178 | |
---|
1179 | |
---|
1180 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
1181 | * \param uiTLayer Temporal layer ID of the current slice |
---|
1182 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
1183 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
1184 | * temporal_layer_switching_point_flag is set accordingly. |
---|
1185 | */ |
---|
1186 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
1187 | { |
---|
1188 | m_uiTLayer = uiTLayer; |
---|
1189 | } |
---|
1190 | |
---|
1191 | /** Function for checking if this is a switching-point |
---|
1192 | */ |
---|
1193 | Bool TComSlice::isTemporalLayerSwitchingPoint(TComList<TComPic*>& rcListPic) |
---|
1194 | { |
---|
1195 | TComPic* rpcPic; |
---|
1196 | // loop through all pictures in the reference picture buffer |
---|
1197 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1198 | while ( iterPic != rcListPic.end()) |
---|
1199 | { |
---|
1200 | rpcPic = *(iterPic++); |
---|
1201 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
1202 | { |
---|
1203 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1204 | { |
---|
1205 | return false; |
---|
1206 | } |
---|
1207 | } |
---|
1208 | } |
---|
1209 | return true; |
---|
1210 | } |
---|
1211 | |
---|
1212 | /** Function for checking if this is a STSA candidate |
---|
1213 | */ |
---|
1214 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate(TComList<TComPic*>& rcListPic) |
---|
1215 | { |
---|
1216 | TComPic* rpcPic; |
---|
1217 | |
---|
1218 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1219 | while ( iterPic != rcListPic.end()) |
---|
1220 | { |
---|
1221 | rpcPic = *(iterPic++); |
---|
1222 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
1223 | { |
---|
1224 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1225 | { |
---|
1226 | return false; |
---|
1227 | } |
---|
1228 | } |
---|
1229 | } |
---|
1230 | return true; |
---|
1231 | } |
---|
1232 | |
---|
1233 | |
---|
1234 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) |
---|
1235 | { |
---|
1236 | TComPic* rpcPic; |
---|
1237 | |
---|
1238 | Int nalUnitType = this->getNalUnitType(); |
---|
1239 | |
---|
1240 | // When a picture is a leading picture, it shall be a RADL or RASL picture. |
---|
1241 | if(this->getAssociatedIRAPPOC() > this->getPOC()) |
---|
1242 | { |
---|
1243 | // Do not check IRAP pictures since they may get a POC lower than their associated IRAP |
---|
1244 | if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1245 | nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) |
---|
1246 | { |
---|
1247 | assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1248 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1249 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1250 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1251 | } |
---|
1252 | } |
---|
1253 | |
---|
1254 | // When a picture is a trailing picture, it shall not be a RADL or RASL picture. |
---|
1255 | if(this->getAssociatedIRAPPOC() < this->getPOC()) |
---|
1256 | { |
---|
1257 | assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && |
---|
1258 | nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && |
---|
1259 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && |
---|
1260 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1261 | } |
---|
1262 | |
---|
1263 | // No RASL pictures shall be present in the bitstream that are associated |
---|
1264 | // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. |
---|
1265 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1266 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1267 | { |
---|
1268 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && |
---|
1269 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); |
---|
1270 | } |
---|
1271 | |
---|
1272 | // No RASL pictures shall be present in the bitstream that are associated with |
---|
1273 | // an IDR picture. |
---|
1274 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1275 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1276 | { |
---|
1277 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && |
---|
1278 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
1279 | } |
---|
1280 | |
---|
1281 | // No RADL pictures shall be present in the bitstream that are associated with |
---|
1282 | // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated |
---|
1283 | // with an IDR picture having nal_unit_type equal to IDR_N_LP. |
---|
1284 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1285 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1286 | { |
---|
1287 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && |
---|
1288 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); |
---|
1289 | } |
---|
1290 | |
---|
1291 | // loop through all pictures in the reference picture buffer |
---|
1292 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1293 | while ( iterPic != rcListPic.end()) |
---|
1294 | { |
---|
1295 | rpcPic = *(iterPic++); |
---|
1296 | if(!rpcPic->getReconMark()) |
---|
1297 | { |
---|
1298 | continue; |
---|
1299 | } |
---|
1300 | if (rpcPic->getPOC() == this->getPOC()) |
---|
1301 | { |
---|
1302 | continue; |
---|
1303 | } |
---|
1304 | |
---|
1305 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1306 | // in decoding order shall precede the IRAP picture in output order. |
---|
1307 | // (Note that any picture following in output order would be present in the DPB) |
---|
1308 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1 && !this->getNoOutputPriorPicsFlag()) |
---|
1309 | { |
---|
1310 | if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1311 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1312 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1313 | nalUnitType == NAL_UNIT_CODED_SLICE_CRA || |
---|
1314 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1315 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
1316 | { |
---|
1317 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1318 | } |
---|
1319 | } |
---|
1320 | |
---|
1321 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1322 | // in decoding order shall precede any RADL picture associated with the IRAP |
---|
1323 | // picture in output order. |
---|
1324 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
1325 | { |
---|
1326 | if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1327 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) |
---|
1328 | { |
---|
1329 | // rpcPic precedes the IRAP in decoding order |
---|
1330 | if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1331 | { |
---|
1332 | // rpcPic must not be the IRAP picture |
---|
1333 | if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) |
---|
1334 | { |
---|
1335 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1336 | } |
---|
1337 | } |
---|
1338 | } |
---|
1339 | } |
---|
1340 | |
---|
1341 | // When a picture is a leading picture, it shall precede, in decoding order, |
---|
1342 | // all trailing pictures that are associated with the same IRAP picture. |
---|
1343 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1344 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1345 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1346 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1347 | { |
---|
1348 | if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) |
---|
1349 | { |
---|
1350 | // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB |
---|
1351 | // rpcPic would violate the constraint if it was a trailing picture |
---|
1352 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
1353 | } |
---|
1354 | } |
---|
1355 | |
---|
1356 | // Any RASL picture associated with a CRA or BLA picture shall precede any |
---|
1357 | // RADL picture associated with the CRA or BLA picture in output order |
---|
1358 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1359 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1360 | { |
---|
1361 | if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1362 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1363 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1364 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && |
---|
1365 | this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1366 | { |
---|
1367 | if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1368 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1369 | { |
---|
1370 | assert(rpcPic->getPOC() > this->getPOC()); |
---|
1371 | } |
---|
1372 | } |
---|
1373 | } |
---|
1374 | |
---|
1375 | // Any RASL picture associated with a CRA picture shall follow, in output |
---|
1376 | // order, any IRAP picture that precedes the CRA picture in decoding order. |
---|
1377 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1378 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1379 | { |
---|
1380 | if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
1381 | { |
---|
1382 | if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && |
---|
1383 | (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1384 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1385 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1386 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1387 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || |
---|
1388 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) |
---|
1389 | { |
---|
1390 | assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); |
---|
1391 | } |
---|
1392 | } |
---|
1393 | } |
---|
1394 | } |
---|
1395 | } |
---|
1396 | |
---|
1397 | |
---|
1398 | |
---|
1399 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1400 | */ |
---|
1401 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet) |
---|
1402 | { |
---|
1403 | TComPic* rpcPic; |
---|
1404 | Int i, isReference; |
---|
1405 | |
---|
1406 | checkLeadingPictureRestrictions(rcListPic); |
---|
1407 | |
---|
1408 | // loop through all pictures in the reference picture buffer |
---|
1409 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1410 | while ( iterPic != rcListPic.end()) |
---|
1411 | { |
---|
1412 | rpcPic = *(iterPic++); |
---|
1413 | |
---|
1414 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
1415 | { |
---|
1416 | continue; |
---|
1417 | } |
---|
1418 | |
---|
1419 | isReference = 0; |
---|
1420 | // loop through all pictures in the Reference Picture Set |
---|
1421 | // to see if the picture should be kept as reference picture |
---|
1422 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
1423 | { |
---|
1424 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
1425 | { |
---|
1426 | isReference = 1; |
---|
1427 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1428 | rpcPic->setIsLongTerm(0); |
---|
1429 | } |
---|
1430 | } |
---|
1431 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1432 | { |
---|
1433 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1434 | { |
---|
1435 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
1436 | { |
---|
1437 | isReference = 1; |
---|
1438 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1439 | } |
---|
1440 | } |
---|
1441 | else |
---|
1442 | { |
---|
1443 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1444 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1445 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1446 | if(rpcPic->getIsLongTerm() && curPoc == refPoc) |
---|
1447 | { |
---|
1448 | isReference = 1; |
---|
1449 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1450 | } |
---|
1451 | } |
---|
1452 | |
---|
1453 | } |
---|
1454 | #if NH_MV |
---|
1455 | if( isReference ) // Current picture is in the temporal RPS |
---|
1456 | { |
---|
1457 | assert( rpcPic->getSlice(0)->getDiscardableFlag() == 0 ); // Temporal RPS shall not contain picture with discardable_flag equal to 1 |
---|
1458 | } |
---|
1459 | #endif |
---|
1460 | // mark the picture as "unused for reference" if it is not in |
---|
1461 | // the Reference Picture Set |
---|
1462 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
1463 | { |
---|
1464 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
1465 | rpcPic->setUsedByCurr(0); |
---|
1466 | rpcPic->setIsLongTerm(0); |
---|
1467 | } |
---|
1468 | //check that pictures of higher temporal layers are not used |
---|
1469 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
1470 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
1471 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
1472 | { |
---|
1473 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
1474 | } |
---|
1475 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
1476 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
1477 | { |
---|
1478 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
1479 | } |
---|
1480 | } |
---|
1481 | } |
---|
1482 | |
---|
1483 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1484 | */ |
---|
1485 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1486 | { |
---|
1487 | Int atLeastOneUnabledByRecoveryPoint = 0; |
---|
1488 | Int atLeastOneFlushedByPreviousIDR = 0; |
---|
1489 | TComPic* rpcPic; |
---|
1490 | Int i, isAvailable; |
---|
1491 | Int atLeastOneLost = 0; |
---|
1492 | Int atLeastOneRemoved = 0; |
---|
1493 | Int iPocLost = 0; |
---|
1494 | |
---|
1495 | // loop through all long-term pictures in the Reference Picture Set |
---|
1496 | // to see if the picture should be kept as reference picture |
---|
1497 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1498 | { |
---|
1499 | isAvailable = 0; |
---|
1500 | // loop through all pictures in the reference picture buffer |
---|
1501 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1502 | while ( iterPic != rcListPic.end()) |
---|
1503 | { |
---|
1504 | rpcPic = *(iterPic++); |
---|
1505 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1506 | { |
---|
1507 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1508 | { |
---|
1509 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1510 | { |
---|
1511 | isAvailable = 0; |
---|
1512 | } |
---|
1513 | else |
---|
1514 | { |
---|
1515 | isAvailable = 1; |
---|
1516 | } |
---|
1517 | } |
---|
1518 | } |
---|
1519 | else |
---|
1520 | { |
---|
1521 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1522 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1523 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1524 | if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) |
---|
1525 | { |
---|
1526 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1527 | { |
---|
1528 | isAvailable = 0; |
---|
1529 | } |
---|
1530 | else |
---|
1531 | { |
---|
1532 | isAvailable = 1; |
---|
1533 | } |
---|
1534 | } |
---|
1535 | } |
---|
1536 | } |
---|
1537 | // if there was no such long-term check the short terms |
---|
1538 | if(!isAvailable) |
---|
1539 | { |
---|
1540 | iterPic = rcListPic.begin(); |
---|
1541 | while ( iterPic != rcListPic.end()) |
---|
1542 | { |
---|
1543 | rpcPic = *(iterPic++); |
---|
1544 | |
---|
1545 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1546 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
1547 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
1548 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
1549 | { |
---|
1550 | curPoc = curPoc & (pocCycle - 1); |
---|
1551 | refPoc = refPoc & (pocCycle - 1); |
---|
1552 | } |
---|
1553 | |
---|
1554 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
1555 | { |
---|
1556 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1557 | { |
---|
1558 | isAvailable = 0; |
---|
1559 | } |
---|
1560 | else |
---|
1561 | { |
---|
1562 | isAvailable = 1; |
---|
1563 | rpcPic->setIsLongTerm(1); |
---|
1564 | break; |
---|
1565 | } |
---|
1566 | } |
---|
1567 | } |
---|
1568 | } |
---|
1569 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1570 | // but not available as reference picture |
---|
1571 | if(isAvailable == 0) |
---|
1572 | { |
---|
1573 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1574 | { |
---|
1575 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1576 | { |
---|
1577 | if(printErrors) |
---|
1578 | { |
---|
1579 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1580 | } |
---|
1581 | atLeastOneRemoved = 1; |
---|
1582 | } |
---|
1583 | else |
---|
1584 | { |
---|
1585 | if(printErrors) |
---|
1586 | { |
---|
1587 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1588 | } |
---|
1589 | atLeastOneLost = 1; |
---|
1590 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1591 | } |
---|
1592 | } |
---|
1593 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1594 | { |
---|
1595 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1596 | } |
---|
1597 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1598 | { |
---|
1599 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1600 | } |
---|
1601 | } |
---|
1602 | } |
---|
1603 | // loop through all short-term pictures in the Reference Picture Set |
---|
1604 | // to see if the picture should be kept as reference picture |
---|
1605 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
1606 | { |
---|
1607 | isAvailable = 0; |
---|
1608 | // loop through all pictures in the reference picture buffer |
---|
1609 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1610 | while ( iterPic != rcListPic.end()) |
---|
1611 | { |
---|
1612 | rpcPic = *(iterPic++); |
---|
1613 | |
---|
1614 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1615 | { |
---|
1616 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1617 | { |
---|
1618 | isAvailable = 0; |
---|
1619 | } |
---|
1620 | else |
---|
1621 | { |
---|
1622 | isAvailable = 1; |
---|
1623 | } |
---|
1624 | } |
---|
1625 | } |
---|
1626 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1627 | // but not available as reference picture |
---|
1628 | if(isAvailable == 0) |
---|
1629 | { |
---|
1630 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1631 | { |
---|
1632 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1633 | { |
---|
1634 | if(printErrors) |
---|
1635 | { |
---|
1636 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1637 | } |
---|
1638 | atLeastOneRemoved = 1; |
---|
1639 | } |
---|
1640 | else |
---|
1641 | { |
---|
1642 | if(printErrors) |
---|
1643 | { |
---|
1644 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1645 | } |
---|
1646 | atLeastOneLost = 1; |
---|
1647 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1648 | } |
---|
1649 | } |
---|
1650 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1651 | { |
---|
1652 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1653 | } |
---|
1654 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1655 | { |
---|
1656 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1657 | } |
---|
1658 | } |
---|
1659 | } |
---|
1660 | |
---|
1661 | if(atLeastOneUnabledByRecoveryPoint || atLeastOneFlushedByPreviousIDR) |
---|
1662 | { |
---|
1663 | return -1; |
---|
1664 | } |
---|
1665 | if(atLeastOneLost) |
---|
1666 | { |
---|
1667 | return iPocLost+1; |
---|
1668 | } |
---|
1669 | if(atLeastOneRemoved) |
---|
1670 | { |
---|
1671 | return -2; |
---|
1672 | } |
---|
1673 | else |
---|
1674 | { |
---|
1675 | return 0; |
---|
1676 | } |
---|
1677 | } |
---|
1678 | |
---|
1679 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
1680 | */ |
---|
1681 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint, const Bool bEfficientFieldIRAPEnabled) |
---|
1682 | { |
---|
1683 | TComPic* rpcPic; |
---|
1684 | Int i, j; |
---|
1685 | Int k = 0; |
---|
1686 | Int nrOfNegativePictures = 0; |
---|
1687 | Int nrOfPositivePictures = 0; |
---|
1688 | TComReferencePictureSet* pLocalRPS = this->getLocalRPS(); |
---|
1689 | (*pLocalRPS)=TComReferencePictureSet(); |
---|
1690 | |
---|
1691 | Bool irapIsInRPS = false; // Used when bEfficientFieldIRAPEnabled==true |
---|
1692 | |
---|
1693 | // loop through all pictures in the Reference Picture Set |
---|
1694 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1695 | { |
---|
1696 | j = 0; |
---|
1697 | // loop through all pictures in the reference picture buffer |
---|
1698 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1699 | while ( iterPic != rcListPic.end()) |
---|
1700 | { |
---|
1701 | j++; |
---|
1702 | rpcPic = *(iterPic++); |
---|
1703 | |
---|
1704 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1705 | { |
---|
1706 | // This picture exists as a reference picture |
---|
1707 | // and should be added to the explicit Reference Picture Set |
---|
1708 | pLocalRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
1709 | pLocalRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); |
---|
1710 | if (bEfficientFieldIRAPEnabled) |
---|
1711 | { |
---|
1712 | pLocalRPS->setUsed(k, pLocalRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) ); |
---|
1713 | } |
---|
1714 | |
---|
1715 | if(pLocalRPS->getDeltaPOC(k) < 0) |
---|
1716 | { |
---|
1717 | nrOfNegativePictures++; |
---|
1718 | } |
---|
1719 | else |
---|
1720 | { |
---|
1721 | if(bEfficientFieldIRAPEnabled && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
1722 | { |
---|
1723 | irapIsInRPS = true; |
---|
1724 | } |
---|
1725 | nrOfPositivePictures++; |
---|
1726 | } |
---|
1727 | k++; |
---|
1728 | } |
---|
1729 | } |
---|
1730 | } |
---|
1731 | |
---|
1732 | Bool useNewRPS = false; |
---|
1733 | // if current picture is complimentary field associated to IRAP, add the IRAP to its RPS. |
---|
1734 | if(bEfficientFieldIRAPEnabled && m_pcPic->isField() && !irapIsInRPS) |
---|
1735 | { |
---|
1736 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1737 | while ( iterPic != rcListPic.end()) |
---|
1738 | { |
---|
1739 | rpcPic = *(iterPic++); |
---|
1740 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
1741 | { |
---|
1742 | pLocalRPS->setDeltaPOC(k, 1); |
---|
1743 | pLocalRPS->setUsed(k, true); |
---|
1744 | nrOfPositivePictures++; |
---|
1745 | k ++; |
---|
1746 | useNewRPS = true; |
---|
1747 | } |
---|
1748 | } |
---|
1749 | } |
---|
1750 | pLocalRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
1751 | pLocalRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
1752 | pLocalRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
1753 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
1754 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
1755 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
1756 | if (!pReferencePictureSet->getInterRPSPrediction() || useNewRPS ) |
---|
1757 | { |
---|
1758 | pLocalRPS->setInterRPSPrediction(false); |
---|
1759 | pLocalRPS->setNumRefIdc(0); |
---|
1760 | } |
---|
1761 | else |
---|
1762 | { |
---|
1763 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
1764 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
1765 | const TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
1766 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
1767 | Int iNewIdc=0; |
---|
1768 | for(i=0; i<= iRefPics; i++) |
---|
1769 | { |
---|
1770 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
1771 | Int iRefIdc = 0; |
---|
1772 | for (j=0; j < pLocalRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
1773 | { |
---|
1774 | if ( (deltaPOC + deltaRPS) == pLocalRPS->getDeltaPOC(j)) |
---|
1775 | { |
---|
1776 | if (pLocalRPS->getUsed(j)) |
---|
1777 | { |
---|
1778 | iRefIdc = 1; |
---|
1779 | } |
---|
1780 | else |
---|
1781 | { |
---|
1782 | iRefIdc = 2; |
---|
1783 | } |
---|
1784 | } |
---|
1785 | } |
---|
1786 | pLocalRPS->setRefIdc(i, iRefIdc); |
---|
1787 | iNewIdc++; |
---|
1788 | } |
---|
1789 | pLocalRPS->setInterRPSPrediction(true); |
---|
1790 | pLocalRPS->setNumRefIdc(iNewIdc); |
---|
1791 | pLocalRPS->setDeltaRPS(deltaRPS); |
---|
1792 | pLocalRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
1793 | } |
---|
1794 | |
---|
1795 | this->setRPS(pLocalRPS); |
---|
1796 | this->setRPSidx(-1); |
---|
1797 | } |
---|
1798 | |
---|
1799 | //! get AC and DC values for weighted pred |
---|
1800 | Void TComSlice::getWpAcDcParam(WPACDCParam *&wp) |
---|
1801 | { |
---|
1802 | wp = m_weightACDCParam; |
---|
1803 | } |
---|
1804 | |
---|
1805 | //! init AC and DC values for weighted pred |
---|
1806 | Void TComSlice::initWpAcDcParam() |
---|
1807 | { |
---|
1808 | for(Int iComp = 0; iComp < MAX_NUM_COMPONENT; iComp++ ) |
---|
1809 | { |
---|
1810 | m_weightACDCParam[iComp].iAC = 0; |
---|
1811 | m_weightACDCParam[iComp].iDC = 0; |
---|
1812 | } |
---|
1813 | } |
---|
1814 | |
---|
1815 | //! get tables for weighted prediction |
---|
1816 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, WPScalingParam *&wp ) |
---|
1817 | { |
---|
1818 | assert (e<NUM_REF_PIC_LIST_01); |
---|
1819 | wp = m_weightPredTable[e][iRefIdx]; |
---|
1820 | } |
---|
1821 | |
---|
1822 | //! reset Default WP tables settings : no weight. |
---|
1823 | Void TComSlice::resetWpScaling() |
---|
1824 | { |
---|
1825 | for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
1826 | { |
---|
1827 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1828 | { |
---|
1829 | for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) |
---|
1830 | { |
---|
1831 | WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1832 | pwp->bPresentFlag = false; |
---|
1833 | pwp->uiLog2WeightDenom = 0; |
---|
1834 | pwp->uiLog2WeightDenom = 0; |
---|
1835 | pwp->iWeight = 1; |
---|
1836 | pwp->iOffset = 0; |
---|
1837 | } |
---|
1838 | } |
---|
1839 | } |
---|
1840 | } |
---|
1841 | |
---|
1842 | //! init WP table |
---|
1843 | Void TComSlice::initWpScaling(const TComSPS *sps) |
---|
1844 | { |
---|
1845 | const Bool bUseHighPrecisionPredictionWeighting = sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag(); |
---|
1846 | for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
1847 | { |
---|
1848 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1849 | { |
---|
1850 | for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) |
---|
1851 | { |
---|
1852 | WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1853 | if ( !pwp->bPresentFlag ) |
---|
1854 | { |
---|
1855 | // Inferring values not present : |
---|
1856 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
1857 | pwp->iOffset = 0; |
---|
1858 | } |
---|
1859 | |
---|
1860 | const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (sps->getBitDepth(toChannelType(ComponentID(yuv)))-8)); |
---|
1861 | |
---|
1862 | pwp->w = pwp->iWeight; |
---|
1863 | pwp->o = pwp->iOffset * offsetScalingFactor; //NOTE: This value of the ".o" variable is never used - .o is set immediately before it gets used |
---|
1864 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
1865 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
1866 | } |
---|
1867 | } |
---|
1868 | } |
---|
1869 | } |
---|
1870 | |
---|
1871 | // ------------------------------------------------------------------------------------------------ |
---|
1872 | // Video parameter set (VPS) |
---|
1873 | // ------------------------------------------------------------------------------------------------ |
---|
1874 | TComVPS::TComVPS() |
---|
1875 | : m_VPSId ( 0) |
---|
1876 | , m_uiMaxTLayers ( 1) |
---|
1877 | #if NH_MV |
---|
1878 | , m_uiMaxLayersMinus1 ( 0) |
---|
1879 | #else |
---|
1880 | , m_uiMaxLayers ( 1) |
---|
1881 | #endif |
---|
1882 | , m_bTemporalIdNestingFlag (false) |
---|
1883 | , m_numHrdParameters ( 0) |
---|
1884 | #if NH_MV |
---|
1885 | , m_maxLayerId ( 0) |
---|
1886 | #else |
---|
1887 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
1888 | #endif |
---|
1889 | , m_hrdParameters () |
---|
1890 | , m_hrdOpSetIdx () |
---|
1891 | , m_cprmsPresentFlag () |
---|
1892 | { |
---|
1893 | #if NH_MV |
---|
1894 | m_vpsBaseLayerInternalFlag = true; |
---|
1895 | m_vpsBaseLayerAvailableFlag = true; |
---|
1896 | |
---|
1897 | m_numViews = 0; |
---|
1898 | |
---|
1899 | #endif |
---|
1900 | |
---|
1901 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
1902 | { |
---|
1903 | m_numReorderPics[i] = 0; |
---|
1904 | m_uiMaxDecPicBuffering[i] = 1; |
---|
1905 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1906 | } |
---|
1907 | #if NH_MV |
---|
1908 | for (Int lsIdx = 0; lsIdx < MAX_VPS_OP_SETS_PLUS1; lsIdx++ ) |
---|
1909 | { |
---|
1910 | for( Int layerId = 0; layerId < MAX_VPS_NUH_LAYER_ID_PLUS1; layerId++ ) |
---|
1911 | { |
---|
1912 | m_layerIdIncludedFlag[lsIdx][layerId] = (( lsIdx == 0 ) && ( layerId == 0 )) ; |
---|
1913 | } |
---|
1914 | } |
---|
1915 | m_vpsNumProfileTierLevelMinus1 = -1; |
---|
1916 | |
---|
1917 | m_numAddLayerSets = 0; |
---|
1918 | m_numAddOlss = 0; |
---|
1919 | m_defaultOutputLayerIdc = 0; |
---|
1920 | |
---|
1921 | for ( Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++) |
---|
1922 | { |
---|
1923 | m_layerSetIdxForOlsMinus1[i] = -1; |
---|
1924 | for ( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++) |
---|
1925 | { |
---|
1926 | m_profileTierLevelIdx[i][j] = -1; |
---|
1927 | m_outputLayerFlag[i][j] = false; |
---|
1928 | } |
---|
1929 | m_altOutputLayerFlag[ i ] = false; |
---|
1930 | } |
---|
1931 | |
---|
1932 | m_repFormatIdxPresentFlag = false; |
---|
1933 | m_maxOneActiveRefLayerFlag = false; |
---|
1934 | m_vpsPocLsbAlignedFlag = false; |
---|
1935 | m_directDepTypeLenMinus2 = 0; |
---|
1936 | |
---|
1937 | |
---|
1938 | m_vpsExtensionFlag = true; |
---|
1939 | m_vpsNonVuiExtensionLength = 0; |
---|
1940 | m_splittingFlag = false; |
---|
1941 | |
---|
1942 | |
---|
1943 | for( Int i = 0; i < MAX_NUM_SCALABILITY_TYPES; i++ ) |
---|
1944 | { |
---|
1945 | m_scalabilityMaskFlag[i] = false; |
---|
1946 | m_dimensionIdLen [i] = -1; |
---|
1947 | } |
---|
1948 | |
---|
1949 | m_vpsNuhLayerIdPresentFlag = false; |
---|
1950 | |
---|
1951 | for( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++ ) |
---|
1952 | { |
---|
1953 | m_vpsProfilePresentFlag [i] = false; |
---|
1954 | m_layerSetIdxForOlsMinus1 [i] = 0; |
---|
1955 | for( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++ ) |
---|
1956 | { |
---|
1957 | m_outputLayerFlag[i][j] = false; |
---|
1958 | } |
---|
1959 | } |
---|
1960 | |
---|
1961 | for( Int i = 0; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
1962 | { |
---|
1963 | m_layerIdInVps[i] = (i == 0 ) ? 0 : -1; |
---|
1964 | } |
---|
1965 | |
---|
1966 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
1967 | { |
---|
1968 | m_layerIdInNuh [i] = ( i == 0 ) ? 0 : -1; |
---|
1969 | m_numDirectRefLayers[i] = 0; |
---|
1970 | #if NH_3D |
---|
1971 | m_numRefListLayers[i] = 0; |
---|
1972 | #endif |
---|
1973 | m_vpsRepFormatIdx [i] = 0; |
---|
1974 | m_pocLsbNotPresentFlag[i] = 0; |
---|
1975 | m_viewIdVal [i] = 0; |
---|
1976 | |
---|
1977 | #if NH_3D |
---|
1978 | m_viewIndex [i] = -1; |
---|
1979 | #endif |
---|
1980 | |
---|
1981 | for( Int j = 0; j < MAX_NUM_LAYERS; j++ ) |
---|
1982 | { |
---|
1983 | m_directDependencyFlag[i][j] = false; |
---|
1984 | m_directDependencyType[i][j] = -1; |
---|
1985 | m_dependencyFlag [i][j] = false; |
---|
1986 | m_idDirectRefLayer[i][j] = -1; |
---|
1987 | #if NH_3D |
---|
1988 | m_idRefListLayer[i][j] = -1; |
---|
1989 | #endif |
---|
1990 | m_idPredictedLayer[i][j] = -1; |
---|
1991 | m_idRefLayer [i][j] = -1; |
---|
1992 | m_maxTidIlRefPicsPlus1[i][j] = 7; |
---|
1993 | } |
---|
1994 | |
---|
1995 | for( Int j = 0; j < MAX_NUM_SCALABILITY_TYPES; j++ ) |
---|
1996 | { |
---|
1997 | m_dimensionId[i][j] = 0; |
---|
1998 | } |
---|
1999 | #if NH_3D_ARP |
---|
2000 | #endif |
---|
2001 | } |
---|
2002 | #endif |
---|
2003 | } |
---|
2004 | |
---|
2005 | TComVPS::~TComVPS() |
---|
2006 | { |
---|
2007 | } |
---|
2008 | |
---|
2009 | #if NH_MV |
---|
2010 | |
---|
2011 | Bool TComVPS::checkVPSExtensionSyntax() |
---|
2012 | { |
---|
2013 | for( Int layer = 1; layer <= getMaxLayersMinus1(); layer++ ) |
---|
2014 | { |
---|
2015 | // check layer_id_in_nuh constraint |
---|
2016 | assert( getLayerIdInNuh( layer ) > getLayerIdInNuh( layer -1 ) ); |
---|
2017 | } |
---|
2018 | |
---|
2019 | //The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
2020 | assert( getVpsNumRepFormatsMinus1() >= 0 ); |
---|
2021 | assert( getVpsNumRepFormatsMinus1() <= 255 ); |
---|
2022 | |
---|
2023 | // The value of num_add_layer_sets shall be in the range of 0 to 1023, inclusive. |
---|
2024 | assert( getNumAddLayerSets() >= 0 && getNumAddLayerSets() <= 1023 ); |
---|
2025 | return true; |
---|
2026 | } |
---|
2027 | |
---|
2028 | Int TComVPS::getNumScalabilityTypes() const |
---|
2029 | { |
---|
2030 | return scalTypeToScalIdx( ScalabilityType(MAX_NUM_SCALABILITY_TYPES) ); |
---|
2031 | } |
---|
2032 | |
---|
2033 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) const |
---|
2034 | { |
---|
2035 | assert( (Int)scalType >= 0 && (Int)scalType <= MAX_NUM_SCALABILITY_TYPES ); |
---|
2036 | assert( (Int)scalType == MAX_NUM_SCALABILITY_TYPES || getScalabilityMaskFlag( scalType ) ); |
---|
2037 | Int scalIdx = 0; |
---|
2038 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
2039 | { |
---|
2040 | scalIdx += ( getScalabilityMaskFlag( curScalType ) ? 1 : 0 ); |
---|
2041 | |
---|
2042 | } |
---|
2043 | |
---|
2044 | return scalIdx; |
---|
2045 | } |
---|
2046 | Void TComVPS::setScalabilityMaskFlag( UInt val ) |
---|
2047 | { |
---|
2048 | for ( Int scalType = 0; scalType < MAX_NUM_SCALABILITY_TYPES; scalType++ ) |
---|
2049 | { |
---|
2050 | setScalabilityMaskFlag( scalType, ( val & (1 << scalType ) ) != 0 ); |
---|
2051 | } |
---|
2052 | } |
---|
2053 | |
---|
2054 | Void TComVPS::setRefLayers() |
---|
2055 | { |
---|
2056 | |
---|
2057 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2058 | { |
---|
2059 | for( Int j = 0; j <= getMaxLayersMinus1(); j++ ) |
---|
2060 | { |
---|
2061 | m_dependencyFlag[ i ][ j ] = getDirectDependencyFlag( i , j ); |
---|
2062 | for( Int k = 0; k < i; k++ ) |
---|
2063 | { |
---|
2064 | if( getDirectDependencyFlag(i , k ) && m_dependencyFlag[k][j] ) |
---|
2065 | { |
---|
2066 | m_dependencyFlag[ i ][ j ] = true; |
---|
2067 | } |
---|
2068 | } |
---|
2069 | } |
---|
2070 | } |
---|
2071 | |
---|
2072 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2073 | { |
---|
2074 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2075 | Int d = 0; |
---|
2076 | #if NH_3D |
---|
2077 | Int l = 0; |
---|
2078 | #endif |
---|
2079 | Int r = 0; |
---|
2080 | Int p = 0; |
---|
2081 | |
---|
2082 | for( Int j = 0; j <= getMaxLayersMinus1(); j++ ) |
---|
2083 | { |
---|
2084 | Int jNuhLid = getLayerIdInNuh( j ); |
---|
2085 | if( getDirectDependencyFlag( i , j ) ) |
---|
2086 | { |
---|
2087 | m_idDirectRefLayer[iNuhLId][d++] = jNuhLid; |
---|
2088 | } |
---|
2089 | #if NH_3D |
---|
2090 | if( getDirectDependencyFlag( i , j ) && ( getDepthId( iNuhLId ) == getDepthId( jNuhLid ) )) |
---|
2091 | { |
---|
2092 | m_idRefListLayer [iNuhLId][l++] = jNuhLid; |
---|
2093 | } |
---|
2094 | #endif |
---|
2095 | |
---|
2096 | if( getDependencyFlag( i , j ) ) |
---|
2097 | { |
---|
2098 | m_idRefLayer [iNuhLId][r++] = jNuhLid; |
---|
2099 | } |
---|
2100 | if( getDependencyFlag( j , i ) ) |
---|
2101 | { |
---|
2102 | m_idPredictedLayer[iNuhLId][p++] = jNuhLid; |
---|
2103 | } |
---|
2104 | } |
---|
2105 | m_numDirectRefLayers[ iNuhLId ] = d; |
---|
2106 | #if NH_3D |
---|
2107 | m_numRefListLayers[ iNuhLId ] = l; |
---|
2108 | #endif |
---|
2109 | |
---|
2110 | m_numRefLayers [ iNuhLId ] = r; |
---|
2111 | m_numPredictedLayers[ iNuhLId ] = p; |
---|
2112 | } |
---|
2113 | |
---|
2114 | Bool layerIdInListFlag[ 64 ]; |
---|
2115 | for( Int i = 0; i <= 63; i++ ) |
---|
2116 | { |
---|
2117 | layerIdInListFlag[ i ] = 0; |
---|
2118 | } |
---|
2119 | |
---|
2120 | Int k = 0; |
---|
2121 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2122 | { |
---|
2123 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2124 | if( getNumDirectRefLayers( iNuhLId ) == 0 ) |
---|
2125 | { |
---|
2126 | m_treePartitionLayerIdList[ k ][ 0 ] = iNuhLId; |
---|
2127 | Int h = 1; |
---|
2128 | for( Int j = 0; j < getNumPredictedLayers( iNuhLId ); j++ ) |
---|
2129 | { |
---|
2130 | Int predLId = getIdPredictedLayer( iNuhLId, j ); |
---|
2131 | if ( !layerIdInListFlag[ predLId ] ) |
---|
2132 | { |
---|
2133 | m_treePartitionLayerIdList[ k ][ h++ ] = predLId; |
---|
2134 | layerIdInListFlag[ predLId ] = 1; |
---|
2135 | } |
---|
2136 | } |
---|
2137 | m_numLayersInTreePartition[ k++ ] = h; |
---|
2138 | } |
---|
2139 | } |
---|
2140 | m_numIndependentLayers = k; |
---|
2141 | } |
---|
2142 | |
---|
2143 | |
---|
2144 | Void TComVPS::initNumViews( ) |
---|
2145 | { |
---|
2146 | m_numViews = 1; |
---|
2147 | #if NH_3D |
---|
2148 | AOF( m_viewOIdxList.size() == 0 ); |
---|
2149 | m_viewOIdxList.push_back( 0 ); |
---|
2150 | #endif |
---|
2151 | |
---|
2152 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2153 | { |
---|
2154 | Int lId = getLayerIdInNuh( i ); |
---|
2155 | if( i > 0 ) |
---|
2156 | { |
---|
2157 | Bool newViewFlag = true; |
---|
2158 | for( Int j = 0; j < i; j++ ) |
---|
2159 | { |
---|
2160 | if( getViewOrderIdx( lId ) == getViewOrderIdx( getLayerIdInNuh( j ) ) ) |
---|
2161 | { |
---|
2162 | newViewFlag = false; |
---|
2163 | } |
---|
2164 | } |
---|
2165 | if( newViewFlag ) |
---|
2166 | { |
---|
2167 | m_numViews++; |
---|
2168 | #if NH_3D |
---|
2169 | m_viewOIdxList.push_back( getViewOrderIdx( lId ) ); |
---|
2170 | #endif |
---|
2171 | } |
---|
2172 | } |
---|
2173 | } |
---|
2174 | } |
---|
2175 | |
---|
2176 | |
---|
2177 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) const |
---|
2178 | { |
---|
2179 | return getScalabilityMaskFlag( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
2180 | } |
---|
2181 | |
---|
2182 | #if NH_3D |
---|
2183 | Int TComVPS::getLayerIdInNuh( Int viewIndex, Bool depthFlag ) const |
---|
2184 | { |
---|
2185 | Int foundLayerIdinNuh = -1; |
---|
2186 | |
---|
2187 | for (Int layerIdInVps = 0 ; layerIdInVps <= getMaxLayersMinus1(); layerIdInVps++ ) |
---|
2188 | { |
---|
2189 | Int layerIdInNuh = getLayerIdInNuh( layerIdInVps ); |
---|
2190 | if( ( getViewIndex( layerIdInNuh ) == viewIndex ) && ( getDepthId( layerIdInNuh ) == ( depthFlag ? 1 : 0 ) ) ) |
---|
2191 | { |
---|
2192 | foundLayerIdinNuh = layerIdInNuh; |
---|
2193 | break; |
---|
2194 | } |
---|
2195 | } |
---|
2196 | return foundLayerIdinNuh; |
---|
2197 | } |
---|
2198 | |
---|
2199 | Void TComVPS::createCamPars(Int iNumViews) |
---|
2200 | { |
---|
2201 | m_numCp .resize( iNumViews ); |
---|
2202 | m_cpRefVoi .resize( iNumViews ); |
---|
2203 | m_cpInSliceSegmentHeaderFlag.resize( iNumViews ); |
---|
2204 | m_cpPresentFlag .resize( iNumViews ); |
---|
2205 | m_aaaiCodedScale .resize( iNumViews ); |
---|
2206 | m_aaaiCodedOffset .resize( iNumViews ); |
---|
2207 | |
---|
2208 | for ( Int i = 0; i < iNumViews ; i++ ) |
---|
2209 | { |
---|
2210 | m_numCp [i] = 0; |
---|
2211 | m_cpRefVoi [i].resize( iNumViews ); |
---|
2212 | m_cpInSliceSegmentHeaderFlag[i] = false; |
---|
2213 | m_aaaiCodedScale [i].resize( 2 ); |
---|
2214 | m_aaaiCodedOffset [i].resize( 2 ); |
---|
2215 | m_cpPresentFlag [i].resize( iNumViews ); |
---|
2216 | |
---|
2217 | for ( Int j = 0; j < iNumViews; j++) |
---|
2218 | { |
---|
2219 | m_cpRefVoi [i][j] = 0; |
---|
2220 | m_cpPresentFlag [i][j] = false; |
---|
2221 | } |
---|
2222 | |
---|
2223 | for ( Int j = 0; j < 2; j++ ) |
---|
2224 | { |
---|
2225 | m_aaaiCodedScale [i][j].resize( MAX_NUM_LAYERS ); |
---|
2226 | m_aaaiCodedOffset [i][j].resize( MAX_NUM_LAYERS ); |
---|
2227 | |
---|
2228 | for ( Int k = 0; k < MAX_NUM_LAYERS; k++ ) |
---|
2229 | { |
---|
2230 | m_aaaiCodedScale [i][j][k] = 0; |
---|
2231 | m_aaaiCodedOffset[i][j][k] = 0; |
---|
2232 | } |
---|
2233 | } |
---|
2234 | } |
---|
2235 | } |
---|
2236 | #endif // NH_3D |
---|
2237 | |
---|
2238 | |
---|
2239 | Int TComVPS::xGetDimBitOffset( Int j ) const |
---|
2240 | { |
---|
2241 | Int dimBitOffset = 0; |
---|
2242 | if ( getSplittingFlag() && j == getNumScalabilityTypes() ) |
---|
2243 | { |
---|
2244 | dimBitOffset = 6; |
---|
2245 | } |
---|
2246 | else |
---|
2247 | { |
---|
2248 | for (Int dimIdx = 0; dimIdx <= j-1; dimIdx++) |
---|
2249 | { |
---|
2250 | dimBitOffset += getDimensionIdLen( dimIdx ); |
---|
2251 | } |
---|
2252 | } |
---|
2253 | return dimBitOffset; |
---|
2254 | } |
---|
2255 | |
---|
2256 | Int TComVPS::inferDimensionId( Int i, Int j ) const |
---|
2257 | { |
---|
2258 | return ( ( getLayerIdInNuh( i ) & ( (1 << xGetDimBitOffset( j + 1 ) ) - 1) ) >> xGetDimBitOffset( j ) ); |
---|
2259 | } |
---|
2260 | |
---|
2261 | Int TComVPS::inferLastDimsionIdLenMinus1() const |
---|
2262 | { |
---|
2263 | return ( 5 - xGetDimBitOffset( getNumScalabilityTypes() - 1 ) ); |
---|
2264 | } |
---|
2265 | |
---|
2266 | Int TComVPS::getNumLayersInIdList( Int lsIdx ) const |
---|
2267 | { |
---|
2268 | assert( lsIdx >= 0 ); |
---|
2269 | assert( lsIdx <= getNumLayerSets() ); |
---|
2270 | return (Int) m_layerSetLayerIdList[ lsIdx ].size(); |
---|
2271 | } |
---|
2272 | |
---|
2273 | Int TComVPS::getNumOutputLayerSets() const |
---|
2274 | { |
---|
2275 | return getNumAddOlss() + getNumLayerSets(); |
---|
2276 | } |
---|
2277 | |
---|
2278 | |
---|
2279 | |
---|
2280 | Void TComVPS::deriveLayerSetLayerIdList() |
---|
2281 | { |
---|
2282 | m_layerSetLayerIdList.resize( getVpsNumLayerSetsMinus1() + 1 ); |
---|
2283 | for (Int i = 0; i <= getVpsNumLayerSetsMinus1(); i++ ) |
---|
2284 | { |
---|
2285 | for( Int m = 0; m <= getVpsMaxLayerId(); m++ ) |
---|
2286 | { |
---|
2287 | if( getLayerIdIncludedFlag( i, m) ) |
---|
2288 | { |
---|
2289 | m_layerSetLayerIdList[ i ].push_back( m ); |
---|
2290 | } |
---|
2291 | } |
---|
2292 | } |
---|
2293 | } |
---|
2294 | |
---|
2295 | Void TComVPS::initTargetLayerIdLists() |
---|
2296 | { |
---|
2297 | m_targetDecLayerIdLists.resize( getNumOutputLayerSets() ); |
---|
2298 | m_targetOptLayerIdLists.resize( getNumOutputLayerSets() ); |
---|
2299 | } |
---|
2300 | |
---|
2301 | Void TComVPS::deriveTargetLayerIdList( Int i ) |
---|
2302 | { |
---|
2303 | Int lsIdx = olsIdxToLsIdx( i ); |
---|
2304 | |
---|
2305 | for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ ) |
---|
2306 | { |
---|
2307 | if ( getNecessaryLayerFlag( i , j )) |
---|
2308 | { |
---|
2309 | m_targetDecLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); |
---|
2310 | } |
---|
2311 | |
---|
2312 | if( getOutputLayerFlag( i, j )) |
---|
2313 | { |
---|
2314 | m_targetOptLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); |
---|
2315 | } |
---|
2316 | } |
---|
2317 | assert( getNumOutputLayersInOutputLayerSet( i ) > 0 ); |
---|
2318 | } |
---|
2319 | |
---|
2320 | Bool TComVPS::inferOutputLayerFlag( Int i, Int j ) const |
---|
2321 | { |
---|
2322 | Bool outputLayerFlag; |
---|
2323 | switch ( getDefaultOutputLayerIdc( ) ) |
---|
2324 | { |
---|
2325 | case 0: |
---|
2326 | outputLayerFlag = true; |
---|
2327 | break; |
---|
2328 | case 1: |
---|
2329 | outputLayerFlag = ( j == m_layerSetLayerIdList[ olsIdxToLsIdx( i ) ].size() - 1 ); |
---|
2330 | break; |
---|
2331 | case 2: |
---|
2332 | if ( i == 0 && j == 0) |
---|
2333 | { |
---|
2334 | outputLayerFlag = true; // This is a software only fix for a bug in the spec. In spec outputLayerFlag is neither present nor inferred. |
---|
2335 | } |
---|
2336 | else |
---|
2337 | { |
---|
2338 | assert( 0 ); |
---|
2339 | } |
---|
2340 | break; |
---|
2341 | default: |
---|
2342 | assert( 0 ); |
---|
2343 | break; |
---|
2344 | } |
---|
2345 | return outputLayerFlag; |
---|
2346 | } |
---|
2347 | |
---|
2348 | Int TComVPS::getMaxSubLayersInLayerSetMinus1( Int i ) const |
---|
2349 | { |
---|
2350 | Int maxSLMinus1 = 0; |
---|
2351 | for( Int k = 0; k < getNumLayersInIdList( i ); k++ ) |
---|
2352 | { |
---|
2353 | Int lId = m_layerSetLayerIdList[i][k]; |
---|
2354 | maxSLMinus1 = std::max( maxSLMinus1, getSubLayersVpsMaxMinus1( getLayerIdInVps( lId ) )); |
---|
2355 | } |
---|
2356 | return maxSLMinus1; |
---|
2357 | } |
---|
2358 | |
---|
2359 | Bool TComVPS::getAltOutputLayerFlagVar( Int i ) const |
---|
2360 | { |
---|
2361 | // Semantics variable not syntax element ! |
---|
2362 | |
---|
2363 | Bool altOptLayerFlag = false; |
---|
2364 | if ( i > 0 && getNumOutputLayersInOutputLayerSet( i ) == 1 && |
---|
2365 | getNumDirectRefLayers( getOlsHighestOutputLayerId( i ) ) > 0 ) |
---|
2366 | { |
---|
2367 | altOptLayerFlag = getAltOutputLayerFlag( i ); |
---|
2368 | } |
---|
2369 | return altOptLayerFlag; |
---|
2370 | } |
---|
2371 | |
---|
2372 | |
---|
2373 | |
---|
2374 | Int TComVPS::inferProfileTierLevelIdx(Int i, Int j) const |
---|
2375 | { |
---|
2376 | Bool inferZero = ( i == 0 && j == 0 && getVpsBaseLayerInternalFlag() ); |
---|
2377 | Bool inferGreaterZero = getNecessaryLayerFlag(i,j) && ( getVpsNumProfileTierLevelMinus1() == 0 ); |
---|
2378 | assert( inferZero || inferGreaterZero ); |
---|
2379 | |
---|
2380 | Bool ptlIdx = 0; // inference for greaterZero |
---|
2381 | if ( inferZero ) |
---|
2382 | { |
---|
2383 | ptlIdx = getMaxLayersMinus1() > 0 ? 1 : 0; |
---|
2384 | if ( inferGreaterZero ) |
---|
2385 | { |
---|
2386 | assert( ptlIdx == 0 ); |
---|
2387 | // This should never happen since : |
---|
2388 | // When vps_max_layers_minus1 is greater than 0, the value of vps_num_profile_tier_level_minus1 shall be greater than or equal to 1. |
---|
2389 | } |
---|
2390 | } |
---|
2391 | return ptlIdx; |
---|
2392 | } |
---|
2393 | |
---|
2394 | Void TComVPS::deriveAddLayerSetLayerIdList(Int i) |
---|
2395 | { |
---|
2396 | assert( m_layerSetLayerIdList.size() == ( getVpsNumLayerSetsMinus1() + 1 + i ) ); |
---|
2397 | std::vector<Int> layerSetLayerIdList; |
---|
2398 | |
---|
2399 | for( Int treeIdx = 1; treeIdx < getNumIndependentLayers(); treeIdx++ ) |
---|
2400 | { |
---|
2401 | // The value of highest_layer_idx_plus1[ i ][ j ] shall be in the range of 0 to NumLayersInTreePartition[ j ], inclusive. |
---|
2402 | assert( getHighestLayerIdxPlus1( i, treeIdx ) >= 0 && getHighestLayerIdxPlus1( i, treeIdx ) <= getNumLayersInTreePartition( treeIdx ) ); |
---|
2403 | |
---|
2404 | for( Int layerCnt = 0; layerCnt < getHighestLayerIdxPlus1( i, treeIdx ); layerCnt++ ) |
---|
2405 | { |
---|
2406 | layerSetLayerIdList.push_back( getTreePartitionLayerIdList( treeIdx, layerCnt ) ); |
---|
2407 | } |
---|
2408 | } |
---|
2409 | m_layerSetLayerIdList.push_back( layerSetLayerIdList ); |
---|
2410 | |
---|
2411 | //It is a requirement of bitstream conformance that |
---|
2412 | //NumLayersInIdList[ vps_num_layer_sets_minus1 + 1 + i ] shall be greater than 0. |
---|
2413 | assert( getNumLayersInIdList( getVpsNumLayerSetsMinus1() + 1 + i ) > 0 ); |
---|
2414 | } |
---|
2415 | |
---|
2416 | |
---|
2417 | Void TComVPS::deriveNecessaryLayerFlags(Int olsIdx) |
---|
2418 | { |
---|
2419 | AOF( olsIdx >= 0 && olsIdx < getNumOutputLayerSets() ); |
---|
2420 | Int lsIdx = olsIdxToLsIdx( olsIdx ); |
---|
2421 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx) ; lsLayerIdx++ ) |
---|
2422 | { |
---|
2423 | m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ] = 0; |
---|
2424 | } |
---|
2425 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx ); lsLayerIdx++ ) |
---|
2426 | { |
---|
2427 | if( getOutputLayerFlag( olsIdx, lsLayerIdx )) |
---|
2428 | { |
---|
2429 | m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ] = 1; |
---|
2430 | Int currLayerId = getLayerSetLayerIdList( lsIdx, lsLayerIdx ); |
---|
2431 | for( Int rLsLayerIdx = 0; rLsLayerIdx < lsLayerIdx; rLsLayerIdx++ ) |
---|
2432 | { |
---|
2433 | Int refLayerId = getLayerSetLayerIdList( lsIdx, rLsLayerIdx ); |
---|
2434 | if( getDependencyFlag( getLayerIdInVps( currLayerId ), getLayerIdInVps( refLayerId ) ) ) |
---|
2435 | { |
---|
2436 | m_necessaryLayerFlag[ olsIdx ][ rLsLayerIdx ] = 1; |
---|
2437 | } |
---|
2438 | } |
---|
2439 | } |
---|
2440 | } |
---|
2441 | m_numNecessaryLayers[ olsIdx ] = 0; |
---|
2442 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx ); lsLayerIdx++ ) |
---|
2443 | { |
---|
2444 | m_numNecessaryLayers[ olsIdx ] += m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ]; |
---|
2445 | } |
---|
2446 | } |
---|
2447 | |
---|
2448 | Void TComVPS::printPTL() const |
---|
2449 | { |
---|
2450 | std::vector<Int> idx; |
---|
2451 | std::vector<Int> num; |
---|
2452 | IntAry2d ptlInfo; |
---|
2453 | |
---|
2454 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "PTLI" << std::endl; |
---|
2455 | |
---|
2456 | for ( Int i = 0; i <= getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
2457 | { |
---|
2458 | std::vector<Int> curPtlInfo; |
---|
2459 | const ProfileTierLevel* ptl = getPTL( i )->getGeneralPTL(); |
---|
2460 | curPtlInfo.push_back( (Int) ptl->getProfileIdc() ); |
---|
2461 | curPtlInfo.push_back( (Int) ptl->getTierFlag() ); |
---|
2462 | curPtlInfo.push_back( (Int) ptl->getLevelIdc() ); |
---|
2463 | curPtlInfo.push_back( (Int) ptl->getInbldFlag() ); |
---|
2464 | |
---|
2465 | idx.push_back ( i ); |
---|
2466 | num.push_back ( 4 ); |
---|
2467 | ptlInfo.push_back( curPtlInfo ); |
---|
2468 | } |
---|
2469 | |
---|
2470 | xPrintArray( "VpsProfileTierLevel", getVpsNumProfileTierLevelMinus1() + 1, idx, num, ptlInfo, false ); |
---|
2471 | |
---|
2472 | num.clear(); |
---|
2473 | idx.clear(); |
---|
2474 | for (Int i = 0; i < getNumOutputLayerSets(); i++) |
---|
2475 | { |
---|
2476 | num.push_back ( getNumLayersInIdList( olsIdxToLsIdx( i )) ); |
---|
2477 | idx.push_back( i ); |
---|
2478 | } |
---|
2479 | |
---|
2480 | xPrintArray( "profile_tier_level_idx", getNumOutputLayerSets(), idx, num, m_profileTierLevelIdx, true ); |
---|
2481 | std::cout << std::endl; |
---|
2482 | } |
---|
2483 | |
---|
2484 | Void TComVPS::printLayerDependencies() const |
---|
2485 | { |
---|
2486 | vector<Int> fullArray; |
---|
2487 | vector<Int> range; |
---|
2488 | |
---|
2489 | #if NH_3D |
---|
2490 | vector<Int> depthId; |
---|
2491 | #endif |
---|
2492 | |
---|
2493 | vector<Int> viewOrderIndex; |
---|
2494 | vector<Int> auxId; |
---|
2495 | vector<Int> dependencyId; |
---|
2496 | vector<Int> viewId; |
---|
2497 | for (Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2498 | { |
---|
2499 | fullArray.push_back( getMaxLayersMinus1() + 1 ); |
---|
2500 | range.push_back( i ); |
---|
2501 | viewOrderIndex.push_back( getViewIndex ( i ) ); |
---|
2502 | dependencyId .push_back( getDependencyId( i ) ); |
---|
2503 | auxId .push_back( getAuxId ( i ) ); |
---|
2504 | viewId .push_back( getViewId ( getLayerIdInNuh( i ) ) ); |
---|
2505 | #if NH_3D |
---|
2506 | depthId.push_back( getDepthId( i ) ); |
---|
2507 | #endif |
---|
2508 | } |
---|
2509 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Layer Dependencies" << std::endl; |
---|
2510 | xPrintArray( "direct_dependency_flag", getMaxLayersMinus1()+1, range, fullArray, m_directDependencyFlag, false ); |
---|
2511 | xPrintArray( "DependencyFlag", getMaxLayersMinus1()+1, range, fullArray, m_dependencyFlag, false ); |
---|
2512 | xPrintArray( "layer_id_in_nuh", getMaxLayersMinus1()+1, m_layerIdInNuh, true ); |
---|
2513 | xPrintArray( "IdPredictedLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numPredictedLayers, m_idPredictedLayer, true ); |
---|
2514 | xPrintArray( "IdRefLayer" , getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numRefLayers, m_idRefLayer, true ); |
---|
2515 | xPrintArray( "IdDirectRefLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numDirectRefLayers, m_idDirectRefLayer, true ); |
---|
2516 | #if NH_3D |
---|
2517 | xPrintArray( "IdRefListLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numRefListLayers, m_idRefListLayer, true ); |
---|
2518 | #endif |
---|
2519 | |
---|
2520 | std::cout << std::endl; |
---|
2521 | } |
---|
2522 | |
---|
2523 | Void TComVPS::printScalabilityId() const |
---|
2524 | { |
---|
2525 | vector<Int> layerIdxInVps; |
---|
2526 | |
---|
2527 | |
---|
2528 | vector<Int> depthId; |
---|
2529 | vector<Int> viewOrderIndex; |
---|
2530 | vector<Int> auxId; |
---|
2531 | vector<Int> dependencyId; |
---|
2532 | vector<Int> viewId; |
---|
2533 | |
---|
2534 | for (Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2535 | { |
---|
2536 | Int layerIdInNuh = getLayerIdInNuh( i ); |
---|
2537 | layerIdxInVps .push_back( i ); |
---|
2538 | depthId .push_back( getDepthId ( layerIdInNuh ) ); |
---|
2539 | viewOrderIndex.push_back( getViewIndex ( layerIdInNuh ) ); |
---|
2540 | dependencyId .push_back( getDependencyId( layerIdInNuh ) ); |
---|
2541 | auxId .push_back( getAuxId ( layerIdInNuh ) ); |
---|
2542 | viewId .push_back( getViewId ( layerIdInNuh ) ); |
---|
2543 | |
---|
2544 | } |
---|
2545 | |
---|
2546 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Scalability Ids" << std::endl; |
---|
2547 | xPrintArray( "layerIdxInVps" , getMaxLayersMinus1()+1, layerIdxInVps, false ); |
---|
2548 | xPrintArray( "layer_id_in_nuh", getMaxLayersMinus1()+1, m_layerIdInNuh, false ); |
---|
2549 | |
---|
2550 | xPrintArray( "DepthLayerFlag", getMaxLayersMinus1()+1, depthId , false ); |
---|
2551 | xPrintArray( "ViewOrderIdx" , getMaxLayersMinus1()+1, viewOrderIndex, false ); |
---|
2552 | xPrintArray( "DependencyId" , getMaxLayersMinus1()+1, dependencyId , false ); |
---|
2553 | xPrintArray( "AuxId" , getMaxLayersMinus1()+1, auxId , false ); |
---|
2554 | xPrintArray( "ViewIdVal" , getMaxLayersMinus1()+1, viewId , false ); |
---|
2555 | |
---|
2556 | std::cout << std::endl; |
---|
2557 | } |
---|
2558 | |
---|
2559 | Void TComVPS::printLayerSets() const |
---|
2560 | { |
---|
2561 | vector<Int> fullArray; |
---|
2562 | vector<Int> numLayersInIdList; |
---|
2563 | vector<Int> rangeLayerSets; |
---|
2564 | |
---|
2565 | |
---|
2566 | for (Int i = 0; i < getNumLayerSets(); i++ ) |
---|
2567 | { |
---|
2568 | numLayersInIdList.push_back( getNumLayersInIdList( i ) ); |
---|
2569 | rangeLayerSets.push_back( i ); |
---|
2570 | } |
---|
2571 | |
---|
2572 | vector<Int> rangeOutputLayerSets; |
---|
2573 | vector<Int> numOutputLayersInOutputLayerSet; |
---|
2574 | vector<Int> numDecLayer; |
---|
2575 | vector<Int> numLayersInLayerSetForOutputLayerSet; |
---|
2576 | vector<Int> vOlsIdxToLsIdx; |
---|
2577 | for (Int i = 0; i < getNumOutputLayerSets(); i++ ) |
---|
2578 | { |
---|
2579 | vOlsIdxToLsIdx.push_back( olsIdxToLsIdx(i)); |
---|
2580 | numOutputLayersInOutputLayerSet.push_back( getNumOutputLayersInOutputLayerSet( i ) ); |
---|
2581 | numDecLayer.push_back( (Int) m_targetDecLayerIdLists[ i ].size() ); |
---|
2582 | rangeOutputLayerSets.push_back( i ); |
---|
2583 | numLayersInLayerSetForOutputLayerSet.push_back( getNumLayersInIdList( olsIdxToLsIdx( i ) ) ); |
---|
2584 | } |
---|
2585 | |
---|
2586 | vector<Int> rangeIndependentLayers; |
---|
2587 | for(Int i = 0; i < getNumIndependentLayers(); i++ ) |
---|
2588 | { |
---|
2589 | rangeIndependentLayers.push_back( i ); |
---|
2590 | } |
---|
2591 | |
---|
2592 | vector<Int> rangeAddLayerSets; |
---|
2593 | vector<Int> numHighestLayerIdxPlus1; |
---|
2594 | for(Int i = 0; i < getNumAddLayerSets(); i++ ) |
---|
2595 | { |
---|
2596 | rangeAddLayerSets.push_back( i ); |
---|
2597 | numHighestLayerIdxPlus1.push_back( getNumIndependentLayers() ); |
---|
2598 | } |
---|
2599 | |
---|
2600 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Layer Sets" << std::endl; |
---|
2601 | xPrintArray( "TreePartitionLayerIdList", getNumIndependentLayers(), rangeIndependentLayers, m_numLayersInTreePartition, m_treePartitionLayerIdList, true ); |
---|
2602 | xPrintArray( "highest_layer_idx_plus1", getNumAddLayerSets(), rangeAddLayerSets, numHighestLayerIdxPlus1, m_highestLayerIdxPlus1, true ); |
---|
2603 | xPrintArray( "LayerSetLayerIdList" , (Int) getNumLayerSets() , rangeLayerSets , numLayersInIdList, m_layerSetLayerIdList, true ); |
---|
2604 | xPrintArray( "OlsIdxToLsIdx", (Int) vOlsIdxToLsIdx.size(), vOlsIdxToLsIdx, true ); |
---|
2605 | xPrintArray( "OutputLayerFlag" , getNumOutputLayerSets(), rangeOutputLayerSets, numLayersInLayerSetForOutputLayerSet, m_outputLayerFlag, true ); |
---|
2606 | xPrintArray( "TargetOptLayerIdList", getNumOutputLayerSets(), rangeOutputLayerSets, numOutputLayersInOutputLayerSet, m_targetOptLayerIdLists, true ); |
---|
2607 | xPrintArray( "NecessaryLayerFlag" , getNumOutputLayerSets(), rangeOutputLayerSets, numLayersInLayerSetForOutputLayerSet, m_necessaryLayerFlag , true ); |
---|
2608 | xPrintArray( "TargetDecLayerIdList", getNumOutputLayerSets(), rangeOutputLayerSets, numDecLayer, m_targetDecLayerIdLists, true ); |
---|
2609 | std::cout << endl; |
---|
2610 | } |
---|
2611 | |
---|
2612 | #if NH_3D |
---|
2613 | Void TComVPS::initViewCompLayer() |
---|
2614 | { |
---|
2615 | assert( m_viewCompLayerId.size() == 0 && m_viewCompLayerPresentFlag.size() == 0 ); |
---|
2616 | for( Int i = 0; i < getNumViews(); i++ ) |
---|
2617 | { |
---|
2618 | m_viewCompLayerId .push_back( std::vector<Int>(0) ); |
---|
2619 | m_viewCompLayerPresentFlag.push_back( std::vector<Bool>(0) ); |
---|
2620 | |
---|
2621 | for( Int depFlag = 0; depFlag <= 1; depFlag++ ) |
---|
2622 | { |
---|
2623 | Int iViewOIdx = getViewOIdxList( i ); |
---|
2624 | Int layerId = -1; |
---|
2625 | for( Int j = 0; j <= getMaxLayersMinus1(); j++ ) |
---|
2626 | { |
---|
2627 | Int jNuhLId = getLayerIdInNuh( j ); |
---|
2628 | if( getVpsDepthFlag( jNuhLId ) == ( (Bool) depFlag ) && getViewOrderIdx( jNuhLId ) == iViewOIdx |
---|
2629 | && getDependencyId( jNuhLId ) == 0 && getAuxId( jNuhLId ) == 0 ) |
---|
2630 | { |
---|
2631 | layerId = jNuhLId; |
---|
2632 | } |
---|
2633 | } |
---|
2634 | m_viewCompLayerPresentFlag[ i ].push_back( layerId != -1 ); |
---|
2635 | m_viewCompLayerId [ i ].push_back( layerId ); |
---|
2636 | } |
---|
2637 | } |
---|
2638 | } |
---|
2639 | |
---|
2640 | Int TComVPS::getVoiInVps(Int viewOIdx) const |
---|
2641 | { |
---|
2642 | for ( Int i = 0; i < m_viewOIdxList.size(); i++ ) |
---|
2643 | { |
---|
2644 | if ( m_viewOIdxList[ i ] == viewOIdx ) |
---|
2645 | { |
---|
2646 | return i; |
---|
2647 | } |
---|
2648 | } |
---|
2649 | assert( 0 ); |
---|
2650 | return -1; |
---|
2651 | } |
---|
2652 | |
---|
2653 | Void TComVPS::deriveCpPresentFlag() |
---|
2654 | { |
---|
2655 | for( Int nInVps = 0; nInVps < getNumViews(); nInVps++ ) |
---|
2656 | { |
---|
2657 | for( Int mInVps = 0; mInVps < getNumViews(); mInVps++ ) |
---|
2658 | { |
---|
2659 | m_cpPresentFlag[nInVps][mInVps] = 0; |
---|
2660 | } |
---|
2661 | } |
---|
2662 | |
---|
2663 | for( Int n = 1; n < getNumViews(); n++ ) |
---|
2664 | { |
---|
2665 | Int iInVps = getVoiInVps( getViewOIdxList( n ) ); |
---|
2666 | for( Int m = 0; m < getNumCp( iInVps ); m++ ) |
---|
2667 | { |
---|
2668 | m_cpPresentFlag[ iInVps ][ getVoiInVps( getCpRefVoi( iInVps, m ) ) ] = 1; |
---|
2669 | } |
---|
2670 | } |
---|
2671 | } |
---|
2672 | #endif |
---|
2673 | |
---|
2674 | #endif // NH_MV |
---|
2675 | |
---|
2676 | // ------------------------------------------------------------------------------------------------ |
---|
2677 | // Sequence parameter set (SPS) |
---|
2678 | // ------------------------------------------------------------------------------------------------ |
---|
2679 | |
---|
2680 | TComSPSRExt::TComSPSRExt() |
---|
2681 | : m_transformSkipRotationEnabledFlag (false) |
---|
2682 | , m_transformSkipContextEnabledFlag (false) |
---|
2683 | // m_rdpcmEnabledFlag initialized below |
---|
2684 | , m_extendedPrecisionProcessingFlag (false) |
---|
2685 | , m_intraSmoothingDisabledFlag (false) |
---|
2686 | , m_highPrecisionOffsetsEnabledFlag (false) |
---|
2687 | , m_persistentRiceAdaptationEnabledFlag(false) |
---|
2688 | , m_cabacBypassAlignmentEnabledFlag (false) |
---|
2689 | { |
---|
2690 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
---|
2691 | { |
---|
2692 | m_rdpcmEnabledFlag[signallingModeIndex] = false; |
---|
2693 | } |
---|
2694 | } |
---|
2695 | |
---|
2696 | TComSPS::TComSPS() |
---|
2697 | : m_SPSId ( 0) |
---|
2698 | , m_VPSId ( 0) |
---|
2699 | , m_chromaFormatIdc (CHROMA_420) |
---|
2700 | , m_uiMaxTLayers ( 1) |
---|
2701 | // Structure |
---|
2702 | , m_picWidthInLumaSamples (352) |
---|
2703 | , m_picHeightInLumaSamples (288) |
---|
2704 | , m_log2MinCodingBlockSize ( 0) |
---|
2705 | , m_log2DiffMaxMinCodingBlockSize(0) |
---|
2706 | , m_uiMaxCUWidth ( 32) |
---|
2707 | , m_uiMaxCUHeight ( 32) |
---|
2708 | , m_uiMaxTotalCUDepth ( 3) |
---|
2709 | , m_bLongTermRefsPresent (false) |
---|
2710 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
2711 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
2712 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
2713 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
2714 | // Tool list |
---|
2715 | , m_usePCM (false) |
---|
2716 | , m_pcmLog2MaxSize ( 5) |
---|
2717 | , m_uiPCMLog2MinSize ( 7) |
---|
2718 | , m_bPCMFilterDisableFlag (false) |
---|
2719 | , m_uiBitsForPOC ( 8) |
---|
2720 | , m_numLongTermRefPicSPS ( 0) |
---|
2721 | , m_uiMaxTrSize ( 32) |
---|
2722 | , m_bUseSAO (false) |
---|
2723 | , m_bTemporalIdNestingFlag (false) |
---|
2724 | , m_scalingListEnabledFlag (false) |
---|
2725 | , m_useStrongIntraSmoothing (false) |
---|
2726 | , m_vuiParametersPresentFlag (false) |
---|
2727 | , m_vuiParameters () |
---|
2728 | #if NH_MV |
---|
2729 | , m_pcVPS ( NULL ) |
---|
2730 | , m_spsInferScalingListFlag ( false ) |
---|
2731 | , m_spsScalingListRefLayerId ( 0 ) |
---|
2732 | |
---|
2733 | , m_updateRepFormatFlag ( false ) |
---|
2734 | , m_spsRepFormatIdx ( 0 ) |
---|
2735 | , m_interViewMvVertConstraintFlag (false) |
---|
2736 | #endif |
---|
2737 | |
---|
2738 | { |
---|
2739 | for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
2740 | { |
---|
2741 | m_bitDepths.recon[ch] = 8; |
---|
2742 | #if O0043_BEST_EFFORT_DECODING |
---|
2743 | m_bitDepths.stream[ch] = 8; |
---|
2744 | #endif |
---|
2745 | m_pcmBitDepths[ch] = 8; |
---|
2746 | m_qpBDOffset [ch] = 0; |
---|
2747 | } |
---|
2748 | |
---|
2749 | |
---|
2750 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
2751 | { |
---|
2752 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2753 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2754 | m_numReorderPics[i] = 0; |
---|
2755 | } |
---|
2756 | |
---|
2757 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
2758 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
2759 | #if NH_MV |
---|
2760 | m_spsRangeExtensionsFlag = false; |
---|
2761 | m_spsMultilayerExtensionFlag = false; |
---|
2762 | m_spsExtension5bits = 0; |
---|
2763 | m_sps3dExtensionFlag = false; |
---|
2764 | |
---|
2765 | #endif |
---|
2766 | |
---|
2767 | } |
---|
2768 | |
---|
2769 | TComSPS::~TComSPS() |
---|
2770 | { |
---|
2771 | m_RPSList.destroy(); |
---|
2772 | } |
---|
2773 | |
---|
2774 | Void TComSPS::createRPSList( Int numRPS ) |
---|
2775 | { |
---|
2776 | m_RPSList.destroy(); |
---|
2777 | m_RPSList.create(numRPS); |
---|
2778 | } |
---|
2779 | |
---|
2780 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
2781 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
2782 | |
---|
2783 | TComPPSRExt::TComPPSRExt() |
---|
2784 | : m_log2MaxTransformSkipBlockSize (2) |
---|
2785 | , m_crossComponentPredictionEnabledFlag(false) |
---|
2786 | , m_diffCuChromaQpOffsetDepth (0) |
---|
2787 | , m_chromaQpOffsetListLen (0) |
---|
2788 | // m_ChromaQpAdjTableIncludingNullEntry initialized below |
---|
2789 | // m_log2SaoOffsetScale initialized below |
---|
2790 | { |
---|
2791 | m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CbOffset = 0; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0. This is initialised here and never subsequently changed. |
---|
2792 | m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CrOffset = 0; |
---|
2793 | for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
2794 | { |
---|
2795 | m_log2SaoOffsetScale[ch] = 0; |
---|
2796 | } |
---|
2797 | } |
---|
2798 | |
---|
2799 | TComPPS::TComPPS() |
---|
2800 | : m_PPSId (0) |
---|
2801 | , m_SPSId (0) |
---|
2802 | , m_picInitQPMinus26 (0) |
---|
2803 | , m_useDQP (false) |
---|
2804 | , m_bConstrainedIntraPred (false) |
---|
2805 | , m_bSliceChromaQpFlag (false) |
---|
2806 | , m_uiMaxCuDQPDepth (0) |
---|
2807 | , m_chromaCbQpOffset (0) |
---|
2808 | , m_chromaCrQpOffset (0) |
---|
2809 | , m_numRefIdxL0DefaultActive (1) |
---|
2810 | , m_numRefIdxL1DefaultActive (1) |
---|
2811 | , m_TransquantBypassEnableFlag (false) |
---|
2812 | , m_useTransformSkip (false) |
---|
2813 | , m_dependentSliceSegmentsEnabledFlag(false) |
---|
2814 | , m_tilesEnabledFlag (false) |
---|
2815 | , m_entropyCodingSyncEnabledFlag (false) |
---|
2816 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
2817 | , m_uniformSpacingFlag (false) |
---|
2818 | , m_numTileColumnsMinus1 (0) |
---|
2819 | , m_numTileRowsMinus1 (0) |
---|
2820 | , m_signHideFlag (false) |
---|
2821 | , m_cabacInitPresentFlag (false) |
---|
2822 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
2823 | , m_loopFilterAcrossSlicesEnabledFlag(false) |
---|
2824 | , m_listsModificationPresentFlag (0) |
---|
2825 | , m_numExtraSliceHeaderBits (0) |
---|
2826 | #if NH_MV |
---|
2827 | , m_ppsInferScalingListFlag (false) |
---|
2828 | , m_ppsScalingListRefLayerId (0) |
---|
2829 | , m_pocResetInfoPresentFlag (false) |
---|
2830 | #endif |
---|
2831 | #if NH_3D_DLT |
---|
2832 | , m_cDLT () |
---|
2833 | #endif |
---|
2834 | { |
---|
2835 | #if NH_MV |
---|
2836 | m_ppsRangeExtensionsFlag = false; |
---|
2837 | m_ppsMultilayerExtensionFlag = false; |
---|
2838 | m_pps3dExtensionFlag = false; |
---|
2839 | m_ppsExtension5bits = 0; |
---|
2840 | #endif |
---|
2841 | |
---|
2842 | } |
---|
2843 | |
---|
2844 | TComPPS::~TComPPS() |
---|
2845 | { |
---|
2846 | } |
---|
2847 | |
---|
2848 | #if NH_3D_DLT |
---|
2849 | TComDLT::TComDLT() |
---|
2850 | : m_bDltPresentFlag(false) |
---|
2851 | , m_iNumDepthViews(0) |
---|
2852 | , m_uiDepthViewBitDepth(8) |
---|
2853 | { |
---|
2854 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
2855 | { |
---|
2856 | m_bUseDLTFlag [i] = false; |
---|
2857 | m_bInterViewDltPredEnableFlag [i] = false; |
---|
2858 | m_bDltBitMapRepFlag [i] = false; |
---|
2859 | |
---|
2860 | // allocate some memory and initialize with default mapping |
---|
2861 | m_iNumDepthmapValues[i] = ((1 << m_uiDepthViewBitDepth)-1)+1; |
---|
2862 | m_iDepthValue2Idx[i] = std::vector<Int>(m_iNumDepthmapValues[i]); |
---|
2863 | m_iIdx2DepthValue[i] = std::vector<Int>(m_iNumDepthmapValues[i]); |
---|
2864 | |
---|
2865 | m_iDepthIdxToLayerId[i] = i; |
---|
2866 | |
---|
2867 | //default mapping |
---|
2868 | for (Int d=0; d<m_iNumDepthmapValues[i]; d++) |
---|
2869 | { |
---|
2870 | m_iDepthValue2Idx[i][d] = d; |
---|
2871 | m_iIdx2DepthValue[i][d] = d; |
---|
2872 | } |
---|
2873 | } |
---|
2874 | } |
---|
2875 | |
---|
2876 | TComDLT::~TComDLT() |
---|
2877 | { |
---|
2878 | |
---|
2879 | } |
---|
2880 | |
---|
2881 | Void TComDLT::setDepthLUTs(Int layerIdInVps, std::vector<Int> idxToDepthValueTable, Int iNumDepthValues) |
---|
2882 | { |
---|
2883 | if( iNumDepthValues == 0 ) // default mapping only |
---|
2884 | return; |
---|
2885 | |
---|
2886 | // copy idx2DepthValue to internal array |
---|
2887 | m_iIdx2DepthValue[layerIdInVps] = idxToDepthValueTable; |
---|
2888 | |
---|
2889 | UInt uiMaxDepthValue = ((1 << m_uiDepthViewBitDepth)-1); |
---|
2890 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
2891 | { |
---|
2892 | Int iIdxDown = 0; |
---|
2893 | Int iIdxUp = iNumDepthValues-1; |
---|
2894 | Bool bFound = false; |
---|
2895 | |
---|
2896 | // iterate over indices to find lower closest depth |
---|
2897 | Int i = 1; |
---|
2898 | while(!bFound && i<iNumDepthValues) |
---|
2899 | { |
---|
2900 | if( m_iIdx2DepthValue[layerIdInVps][i] > p ) |
---|
2901 | { |
---|
2902 | iIdxDown = i-1; |
---|
2903 | bFound = true; |
---|
2904 | } |
---|
2905 | |
---|
2906 | i++; |
---|
2907 | } |
---|
2908 | iIdxUp = bFound ? iIdxDown + 1 : iNumDepthValues-1; |
---|
2909 | |
---|
2910 | // assign closer depth value/idx |
---|
2911 | if( abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxDown]) < abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxUp]) ) |
---|
2912 | { |
---|
2913 | m_iDepthValue2Idx[layerIdInVps][p] = iIdxDown; |
---|
2914 | } |
---|
2915 | else |
---|
2916 | { |
---|
2917 | m_iDepthValue2Idx[layerIdInVps][p] = iIdxUp; |
---|
2918 | } |
---|
2919 | |
---|
2920 | } |
---|
2921 | |
---|
2922 | // update DLT variables |
---|
2923 | m_iNumDepthmapValues[layerIdInVps] = iNumDepthValues; |
---|
2924 | } |
---|
2925 | |
---|
2926 | Void TComDLT::getDeltaDLT( Int layerIdInVps, std::vector<Int> piDLTInRef, UInt uiDLTInRefNum, std::vector<Int>& riDeltaDLTOut, UInt&ruiDeltaDLTOutNum ) const |
---|
2927 | { |
---|
2928 | Bool abBM0[ 256 ]; |
---|
2929 | Bool abBM1[ 256 ]; |
---|
2930 | |
---|
2931 | memset( abBM0, 0, sizeof( abBM0 )); |
---|
2932 | memset( abBM1, 0, sizeof( abBM1 )); |
---|
2933 | |
---|
2934 | // convert reference DLT to bit string |
---|
2935 | for( Int i = 0; i < uiDLTInRefNum; i++ ) |
---|
2936 | { |
---|
2937 | abBM0[ piDLTInRef[ i ] ] = true; |
---|
2938 | } |
---|
2939 | // convert internal DLT to bit string |
---|
2940 | for( Int i = 0; i < m_iNumDepthmapValues[ layerIdInVps ]; i++ ) |
---|
2941 | { |
---|
2942 | abBM1[ m_iIdx2DepthValue[ layerIdInVps ][ i ] ] = true; |
---|
2943 | } |
---|
2944 | |
---|
2945 | ruiDeltaDLTOutNum = 0; |
---|
2946 | for( Int i = 0; i < 256; i++ ) |
---|
2947 | { |
---|
2948 | if( abBM0[ i ] ^ abBM1[ i ] ) |
---|
2949 | { |
---|
2950 | riDeltaDLTOut[ ruiDeltaDLTOutNum++ ] = i; |
---|
2951 | } |
---|
2952 | } |
---|
2953 | } |
---|
2954 | |
---|
2955 | Void TComDLT::setDeltaDLT( Int layerIdInVps, std::vector<Int> piDLTInRef, UInt uiDLTInRefNum, std::vector<Int> piDeltaDLTIn, UInt uiDeltaDLTInNum ) |
---|
2956 | { |
---|
2957 | Bool abBM0[ 256 ]; |
---|
2958 | Bool abBM1[ 256 ]; |
---|
2959 | |
---|
2960 | memset( abBM0, 0, sizeof( abBM0 )); |
---|
2961 | memset( abBM1, 0, sizeof( abBM1 )); |
---|
2962 | |
---|
2963 | // convert reference DLT to bit string |
---|
2964 | for( Int i = 0; i < uiDLTInRefNum; i++ ) |
---|
2965 | { |
---|
2966 | abBM0[ piDLTInRef[ i ] ] = true; |
---|
2967 | } |
---|
2968 | // convert delta DLT to bit string |
---|
2969 | for( Int i = 0; i < uiDeltaDLTInNum; i++ ) |
---|
2970 | { |
---|
2971 | abBM1[ piDeltaDLTIn[ i ] ] = true; |
---|
2972 | } |
---|
2973 | |
---|
2974 | std::vector<Int> aiIdx2DepthValue(256, 0); |
---|
2975 | UInt uiNumDepthValues = 0; |
---|
2976 | std::fill(aiIdx2DepthValue.begin(), aiIdx2DepthValue.end(), 0); |
---|
2977 | |
---|
2978 | for( Int i = 0; i < 256; i++ ) |
---|
2979 | { |
---|
2980 | if( abBM0[ i ] ^ abBM1[ i ] ) |
---|
2981 | { |
---|
2982 | aiIdx2DepthValue[ uiNumDepthValues++ ] = i; |
---|
2983 | } |
---|
2984 | } |
---|
2985 | |
---|
2986 | // update internal tables |
---|
2987 | setDepthLUTs(layerIdInVps, aiIdx2DepthValue, uiNumDepthValues); |
---|
2988 | } |
---|
2989 | |
---|
2990 | #endif |
---|
2991 | |
---|
2992 | #if NH_MV |
---|
2993 | Void TComSPS::inferRepFormat( TComVPS* vps, Int layerIdCurr, Bool encoder ) |
---|
2994 | { |
---|
2995 | if ( getMultiLayerExtSpsFlag() ) |
---|
2996 | { |
---|
2997 | Int repFormatIdx = getUpdateRepFormatFlag() ? getSpsRepFormatIdx() : vps->getVpsRepFormatIdx( vps->getLayerIdInVps( layerIdCurr ) ) ; |
---|
2998 | const TComRepFormat* repFormat = vps->getRepFormat( repFormatIdx ); |
---|
2999 | |
---|
3000 | if ( encoder ) |
---|
3001 | { |
---|
3002 | assert( getChromaFormatIdc() == (ChromaFormat) repFormat->getChromaFormatVpsIdc() ); |
---|
3003 | //// ToDo: add when supported: |
---|
3004 | // assert( getSeperateColourPlaneFlag( repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
3005 | |
---|
3006 | assert( getPicWidthInLumaSamples() == repFormat->getPicWidthVpsInLumaSamples() ); |
---|
3007 | assert( getPicHeightInLumaSamples() == repFormat->getPicHeightVpsInLumaSamples() ); |
---|
3008 | |
---|
3009 | assert( getBitDepth ( CHANNEL_TYPE_LUMA ) == repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
3010 | assert( getQpBDOffset ( CHANNEL_TYPE_LUMA ) == (Int) (6*( getBitDepth( CHANNEL_TYPE_LUMA ) - 8 )) ); |
---|
3011 | |
---|
3012 | assert( getBitDepth ( CHANNEL_TYPE_CHROMA ) == repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
3013 | assert( getQpBDOffset ( CHANNEL_TYPE_CHROMA ) == (Int) (6* ( getBitDepth( CHANNEL_TYPE_CHROMA ) -8 ) ) ); |
---|
3014 | } |
---|
3015 | else |
---|
3016 | { |
---|
3017 | setChromaFormatIdc( (ChromaFormat) repFormat->getChromaFormatVpsIdc() ); |
---|
3018 | //// ToDo: add when supported: |
---|
3019 | // setSeperateColourPlaneFlag( repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
3020 | |
---|
3021 | setPicWidthInLumaSamples ( repFormat->getPicWidthVpsInLumaSamples() ); |
---|
3022 | setPicHeightInLumaSamples( repFormat->getPicHeightVpsInLumaSamples() ); |
---|
3023 | |
---|
3024 | setBitDepth ( CHANNEL_TYPE_LUMA, repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
3025 | setQpBDOffset ( CHANNEL_TYPE_LUMA, (Int) (6*( getBitDepth( CHANNEL_TYPE_LUMA ) - 8 )) ); |
---|
3026 | |
---|
3027 | setBitDepth ( CHANNEL_TYPE_CHROMA, repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
3028 | setQpBDOffset ( CHANNEL_TYPE_CHROMA, (Int) (6* ( getBitDepth( CHANNEL_TYPE_CHROMA ) -8 ) ) ); |
---|
3029 | Window &spsConf = getConformanceWindow(); |
---|
3030 | |
---|
3031 | // Scaled later |
---|
3032 | spsConf.setScaledFlag( false ); |
---|
3033 | spsConf.setWindowLeftOffset ( repFormat->getConfWinVpsLeftOffset() ); |
---|
3034 | spsConf.setWindowRightOffset ( repFormat->getConfWinVpsRightOffset() ); |
---|
3035 | spsConf.setWindowTopOffset ( repFormat->getConfWinVpsTopOffset() ); |
---|
3036 | spsConf.setWindowBottomOffset( repFormat->getConfWinVpsBottomOffset() ); |
---|
3037 | } |
---|
3038 | |
---|
3039 | if ( getMultiLayerExtSpsFlag() && getUpdateRepFormatFlag() ) |
---|
3040 | { |
---|
3041 | assert( getChromaFormatIdc() <= repFormat->getChromaFormatVpsIdc() ); |
---|
3042 | //// ToDo: add when supported: |
---|
3043 | // assert( getSeperateColourPlaneFlag() <= repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
3044 | |
---|
3045 | assert( getPicWidthInLumaSamples() <= repFormat->getPicWidthVpsInLumaSamples() ); |
---|
3046 | assert( getPicHeightInLumaSamples() <= repFormat->getPicHeightVpsInLumaSamples() ); |
---|
3047 | |
---|
3048 | assert( getBitDepth( CHANNEL_TYPE_LUMA ) <= repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
3049 | assert( getBitDepth( CHANNEL_TYPE_CHROMA ) <= repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
3050 | } |
---|
3051 | } |
---|
3052 | |
---|
3053 | // Set conformance window |
---|
3054 | Int scal = TComSPS::getWinUnitX( getChromaFormatIdc() ) ; |
---|
3055 | getConformanceWindow().scaleOffsets( scal ); |
---|
3056 | getVuiParameters()->getDefaultDisplayWindow().scaleOffsets( scal ); |
---|
3057 | |
---|
3058 | if (encoder && getMultiLayerExtSpsFlag() ) |
---|
3059 | { |
---|
3060 | Int repFormatIdx = getUpdateRepFormatFlag() ? getSpsRepFormatIdx() : vps->getVpsRepFormatIdx( vps->getLayerIdInVps( layerIdCurr ) ) ; |
---|
3061 | const TComRepFormat* repFormat = vps->getRepFormat( repFormatIdx ); |
---|
3062 | |
---|
3063 | Window &spsConf = getConformanceWindow(); |
---|
3064 | assert( spsConf.getWindowLeftOffset () == repFormat->getConfWinVpsLeftOffset() ); |
---|
3065 | assert( spsConf.getWindowRightOffset () == repFormat->getConfWinVpsRightOffset() ); |
---|
3066 | assert( spsConf.getWindowTopOffset () == repFormat->getConfWinVpsTopOffset() ); |
---|
3067 | assert( spsConf.getWindowBottomOffset() == repFormat->getConfWinVpsBottomOffset() ); |
---|
3068 | } |
---|
3069 | } |
---|
3070 | |
---|
3071 | Void TComSPS::inferScalingList( const TComSPS* spsSrc ) |
---|
3072 | { |
---|
3073 | if ( getSpsInferScalingListFlag() ) |
---|
3074 | { |
---|
3075 | assert( spsSrc != NULL ); |
---|
3076 | assert( !spsSrc->getSpsInferScalingListFlag() ); |
---|
3077 | getScalingList().inferFrom( (spsSrc->getScalingList()) ); |
---|
3078 | } |
---|
3079 | } |
---|
3080 | |
---|
3081 | Void TComSPS::inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder ) |
---|
3082 | { |
---|
3083 | const std::vector<Int>& targetDecLayerIdList = vps->getTargetDecLayerIdList( vps->olsIdxToLsIdx( targetOptLayerSetIdx )); |
---|
3084 | |
---|
3085 | if ( getMultiLayerExtSpsFlag() ) |
---|
3086 | { |
---|
3087 | Int layerIdx = 0; |
---|
3088 | while (layerIdx < (Int) targetDecLayerIdList.size() ) |
---|
3089 | { |
---|
3090 | if ( targetDecLayerIdList[layerIdx] == currLayerId ) |
---|
3091 | { |
---|
3092 | break; |
---|
3093 | } |
---|
3094 | layerIdx++; |
---|
3095 | } |
---|
3096 | |
---|
3097 | assert( layerIdx < (Int) targetDecLayerIdList.size() ); |
---|
3098 | |
---|
3099 | for (Int i = 0; i <= getSpsMaxSubLayersMinus1(); i++ ) |
---|
3100 | { |
---|
3101 | Int maxDecPicBufferingMinus1 = vps->getDpbSize()->getMaxVpsDecPicBufferingMinus1( targetOptLayerSetIdx, layerIdx, i ) ; |
---|
3102 | |
---|
3103 | // This preliminary fix needs to be checked. |
---|
3104 | Int maxNumReorderPics = vps->getDpbSize()->getMaxVpsNumReorderPics( targetOptLayerSetIdx, i ); |
---|
3105 | Int maxLatencyIncreasePlus1 = vps->getDpbSize()->getMaxVpsLatencyIncreasePlus1( targetOptLayerSetIdx, i ); |
---|
3106 | if ( encoder ) |
---|
3107 | { |
---|
3108 | assert( getMaxDecPicBuffering( i ) - 1 == maxDecPicBufferingMinus1 ); |
---|
3109 | // This preliminary fix needs to be checked. |
---|
3110 | assert( getNumReorderPics( i ) == maxNumReorderPics ); |
---|
3111 | assert( getMaxLatencyIncrease( i ) == maxLatencyIncreasePlus1 ); |
---|
3112 | |
---|
3113 | } |
---|
3114 | else |
---|
3115 | { |
---|
3116 | // This preliminary fix needs to be checked. |
---|
3117 | setMaxDecPicBuffering( maxDecPicBufferingMinus1 + 1 , i); |
---|
3118 | setNumReorderPics ( maxNumReorderPics, i ); |
---|
3119 | setMaxLatencyIncrease( maxLatencyIncreasePlus1 - 1 , i); |
---|
3120 | } |
---|
3121 | } |
---|
3122 | } |
---|
3123 | } |
---|
3124 | |
---|
3125 | Void TComSPS::checkRpsMaxNumPics( const TComVPS* vps, Int currLayerId ) const |
---|
3126 | { |
---|
3127 | for (Int i = 0; i < getRPSList()->getNumberOfReferencePictureSets(); i++ ) |
---|
3128 | { |
---|
3129 | const TComReferencePictureSet* rps = getRPSList()->getReferencePictureSet( i ); |
---|
3130 | if ( !rps->getInterRPSPrediction() ) |
---|
3131 | { |
---|
3132 | rps->checkMaxNumPics( vps->getVpsExtensionFlag(), MAX_INT, getLayerId(), getMaxDecPicBuffering( getSpsMaxSubLayersMinus1() ) - 1 ); // INT_MAX to be replaced by DpbSize |
---|
3133 | } |
---|
3134 | } |
---|
3135 | } |
---|
3136 | |
---|
3137 | Void TComSPS::inferSpsMaxSubLayersMinus1(Bool atPsActivation, TComVPS* vps) |
---|
3138 | { |
---|
3139 | assert( getLayerId() != 0 ); |
---|
3140 | if ( !atPsActivation ) |
---|
3141 | { |
---|
3142 | assert( vps == NULL ); |
---|
3143 | if (getSpsExtOrMaxSubLayersMinus1() != 7) |
---|
3144 | { |
---|
3145 | setSpsMaxSubLayersMinus1( getSpsExtOrMaxSubLayersMinus1() ); |
---|
3146 | } |
---|
3147 | } |
---|
3148 | else |
---|
3149 | { |
---|
3150 | assert( vps != NULL ); |
---|
3151 | if (getSpsExtOrMaxSubLayersMinus1() == 7) |
---|
3152 | { |
---|
3153 | setSpsMaxSubLayersMinus1( vps->getMaxSubLayersMinus1() ); |
---|
3154 | } |
---|
3155 | } |
---|
3156 | } |
---|
3157 | #endif |
---|
3158 | |
---|
3159 | |
---|
3160 | TComReferencePictureSet::TComReferencePictureSet() |
---|
3161 | : m_numberOfPictures (0) |
---|
3162 | , m_numberOfNegativePictures (0) |
---|
3163 | , m_numberOfPositivePictures (0) |
---|
3164 | , m_numberOfLongtermPictures (0) |
---|
3165 | , m_interRPSPrediction (0) |
---|
3166 | , m_deltaRIdxMinus1 (0) |
---|
3167 | , m_deltaRPS (0) |
---|
3168 | , m_numRefIdc (0) |
---|
3169 | { |
---|
3170 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
3171 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
3172 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
3173 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
3174 | ::memset( m_bCheckLTMSB, 0, sizeof(m_bCheckLTMSB) ); |
---|
3175 | ::memset( m_pocLSBLT, 0, sizeof(m_pocLSBLT) ); |
---|
3176 | ::memset( m_deltaPOCMSBCycleLT, 0, sizeof(m_deltaPOCMSBCycleLT) ); |
---|
3177 | ::memset( m_deltaPocMSBPresentFlag, 0, sizeof(m_deltaPocMSBPresentFlag) ); |
---|
3178 | } |
---|
3179 | |
---|
3180 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
3181 | { |
---|
3182 | } |
---|
3183 | |
---|
3184 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
3185 | { |
---|
3186 | m_used[bufferNum] = used; |
---|
3187 | } |
---|
3188 | |
---|
3189 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
3190 | { |
---|
3191 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
3192 | } |
---|
3193 | |
---|
3194 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
3195 | { |
---|
3196 | m_numberOfPictures = numberOfPictures; |
---|
3197 | } |
---|
3198 | |
---|
3199 | Int TComReferencePictureSet::getUsed(Int bufferNum) const |
---|
3200 | { |
---|
3201 | return m_used[bufferNum]; |
---|
3202 | } |
---|
3203 | |
---|
3204 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) const |
---|
3205 | { |
---|
3206 | return m_deltaPOC[bufferNum]; |
---|
3207 | } |
---|
3208 | |
---|
3209 | Int TComReferencePictureSet::getNumberOfPictures() const |
---|
3210 | { |
---|
3211 | return m_numberOfPictures; |
---|
3212 | } |
---|
3213 | |
---|
3214 | Int TComReferencePictureSet::getPOC(Int bufferNum) const |
---|
3215 | { |
---|
3216 | return m_POC[bufferNum]; |
---|
3217 | } |
---|
3218 | |
---|
3219 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
3220 | { |
---|
3221 | m_POC[bufferNum] = POC; |
---|
3222 | } |
---|
3223 | |
---|
3224 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) const |
---|
3225 | { |
---|
3226 | return m_bCheckLTMSB[bufferNum]; |
---|
3227 | } |
---|
3228 | |
---|
3229 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
3230 | { |
---|
3231 | m_bCheckLTMSB[bufferNum] = b; |
---|
3232 | } |
---|
3233 | |
---|
3234 | //! set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
3235 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
3236 | { |
---|
3237 | m_refIdc[bufferNum] = refIdc; |
---|
3238 | } |
---|
3239 | |
---|
3240 | //! get the reference idc value at uiBufferNum |
---|
3241 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) const |
---|
3242 | { |
---|
3243 | return m_refIdc[bufferNum]; |
---|
3244 | } |
---|
3245 | |
---|
3246 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
3247 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
3248 | * +ve values are in increasing order. |
---|
3249 | * \returns Void |
---|
3250 | */ |
---|
3251 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
3252 | { |
---|
3253 | // sort in increasing order (smallest first) |
---|
3254 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
3255 | { |
---|
3256 | Int deltaPOC = getDeltaPOC(j); |
---|
3257 | Bool used = getUsed(j); |
---|
3258 | for (Int k=j-1; k >= 0; k--) |
---|
3259 | { |
---|
3260 | Int temp = getDeltaPOC(k); |
---|
3261 | if (deltaPOC < temp) |
---|
3262 | { |
---|
3263 | setDeltaPOC(k+1, temp); |
---|
3264 | setUsed(k+1, getUsed(k)); |
---|
3265 | setDeltaPOC(k, deltaPOC); |
---|
3266 | setUsed(k, used); |
---|
3267 | } |
---|
3268 | } |
---|
3269 | } |
---|
3270 | // flip the negative values to largest first |
---|
3271 | Int numNegPics = getNumberOfNegativePictures(); |
---|
3272 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
3273 | { |
---|
3274 | Int deltaPOC = getDeltaPOC(j); |
---|
3275 | Bool used = getUsed(j); |
---|
3276 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
3277 | setUsed(j, getUsed(k)); |
---|
3278 | setDeltaPOC(k, deltaPOC); |
---|
3279 | setUsed(k, used); |
---|
3280 | } |
---|
3281 | } |
---|
3282 | |
---|
3283 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
3284 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
3285 | * \returns Void |
---|
3286 | */ |
---|
3287 | Void TComReferencePictureSet::printDeltaPOC() const |
---|
3288 | { |
---|
3289 | printf("DeltaPOC = { "); |
---|
3290 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
3291 | { |
---|
3292 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
3293 | } |
---|
3294 | if (getInterRPSPrediction()) |
---|
3295 | { |
---|
3296 | printf("}, RefIdc = { "); |
---|
3297 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
3298 | { |
---|
3299 | printf("%d ", getRefIdc(j)); |
---|
3300 | } |
---|
3301 | } |
---|
3302 | printf("}\n"); |
---|
3303 | } |
---|
3304 | |
---|
3305 | #if NH_MV |
---|
3306 | Void TComReferencePictureSet::checkMaxNumPics( Bool vpsExtensionFlag, Int maxNumPics, Int nuhLayerId, Int spsMaxDecPicBufferingMinus1 ) const |
---|
3307 | { |
---|
3308 | assert( getNumberOfPictures() >= 0 ); |
---|
3309 | if ( nuhLayerId == 0 ) |
---|
3310 | { |
---|
3311 | assert( getNumberOfPictures() <= spsMaxDecPicBufferingMinus1 ); |
---|
3312 | } |
---|
3313 | |
---|
3314 | if ( vpsExtensionFlag ) |
---|
3315 | { |
---|
3316 | assert( getNumberOfPictures() <= maxNumPics ); |
---|
3317 | } |
---|
3318 | } |
---|
3319 | #endif |
---|
3320 | |
---|
3321 | |
---|
3322 | |
---|
3323 | |
---|
3324 | TComRefPicListModification::TComRefPicListModification() |
---|
3325 | : m_refPicListModificationFlagL0 (false) |
---|
3326 | , m_refPicListModificationFlagL1 (false) |
---|
3327 | { |
---|
3328 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
3329 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
3330 | } |
---|
3331 | |
---|
3332 | TComRefPicListModification::~TComRefPicListModification() |
---|
3333 | { |
---|
3334 | } |
---|
3335 | |
---|
3336 | TComScalingList::TComScalingList() |
---|
3337 | { |
---|
3338 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3339 | { |
---|
3340 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
3341 | { |
---|
3342 | m_scalingListCoef[sizeId][listId].resize(min<Int>(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
3343 | } |
---|
3344 | } |
---|
3345 | } |
---|
3346 | |
---|
3347 | /** set default quantization matrix to array |
---|
3348 | */ |
---|
3349 | Void TComScalingList::setDefaultScalingList() |
---|
3350 | { |
---|
3351 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3352 | { |
---|
3353 | for(UInt listId=0;listId<SCALING_LIST_NUM;listId++) |
---|
3354 | { |
---|
3355 | processDefaultMatrix(sizeId, listId); |
---|
3356 | } |
---|
3357 | } |
---|
3358 | } |
---|
3359 | /** check if use default quantization matrix |
---|
3360 | * \returns true if use default quantization matrix in all size |
---|
3361 | */ |
---|
3362 | Bool TComScalingList::checkDefaultScalingList() |
---|
3363 | { |
---|
3364 | UInt defaultCounter=0; |
---|
3365 | |
---|
3366 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3367 | { |
---|
3368 | for(UInt listId=0;listId<SCALING_LIST_NUM;listId++) |
---|
3369 | { |
---|
3370 | if( !memcmp(getScalingListAddress(sizeId,listId), getScalingListDefaultAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
3371 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
3372 | { |
---|
3373 | defaultCounter++; |
---|
3374 | } |
---|
3375 | } |
---|
3376 | } |
---|
3377 | |
---|
3378 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM )) ? false : true; |
---|
3379 | } |
---|
3380 | |
---|
3381 | #if NH_MV |
---|
3382 | Void TComSlice::createInterLayerReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1 ) |
---|
3383 | { |
---|
3384 | refPicSetInterLayer0.clear(); |
---|
3385 | refPicSetInterLayer1.clear(); |
---|
3386 | |
---|
3387 | for( Int i = 0; i < getNumActiveRefLayerPics(); i++ ) |
---|
3388 | { |
---|
3389 | Int layerIdRef = getRefPicLayerId( i ); |
---|
3390 | TComPic* picRef = ivPicLists->getPic( layerIdRef, getPOC() ) ; |
---|
3391 | assert ( picRef != 0 ); // There shall be no entry equal to "no reference picture" in RefPicSetInterLayer0 or RefPicSetInterLayer1. |
---|
3392 | |
---|
3393 | picRef->getPicYuvRec()->extendPicBorder(); |
---|
3394 | picRef->setIsLongTerm( true ); |
---|
3395 | picRef->getSlice(0)->setReferenced( true ); |
---|
3396 | |
---|
3397 | Int viewIdCur = getVPS()->getViewId( getLayerId() ); |
---|
3398 | Int viewIdZero = getVPS()->getViewId( 0 ); |
---|
3399 | Int viewIdRef = getVPS()->getViewId( layerIdRef ); |
---|
3400 | |
---|
3401 | if ( ( viewIdCur <= viewIdZero && viewIdCur <= viewIdRef ) || ( viewIdCur >= viewIdZero && viewIdCur >= viewIdRef ) ) |
---|
3402 | { |
---|
3403 | refPicSetInterLayer0.push_back( picRef ); |
---|
3404 | } |
---|
3405 | else |
---|
3406 | { |
---|
3407 | refPicSetInterLayer1.push_back( picRef ); |
---|
3408 | } |
---|
3409 | // Consider to check here: |
---|
3410 | // "If the current picture is a RADL picture, there shall be no entry in the RefPicSetInterLayer0 and RefPicSetInterLayer1 that is a RASL picture. " |
---|
3411 | assert( picRef->getSlice(0)->getDiscardableFlag() == false ); // "There shall be no picture that has discardable_flag equal to 1 in RefPicSetInterLayer0 or RefPicSetInterLayer1". |
---|
3412 | } |
---|
3413 | } |
---|
3414 | |
---|
3415 | Void TComSlice::markIvRefPicsAsShortTerm( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 ) |
---|
3416 | { |
---|
3417 | // Mark as short-term |
---|
3418 | for ( Int i = 0; i < refPicSetInterLayer0.size(); i++ ) |
---|
3419 | { |
---|
3420 | refPicSetInterLayer0[i]->setIsLongTerm( false ); |
---|
3421 | } |
---|
3422 | |
---|
3423 | for ( Int i = 0; i < refPicSetInterLayer1.size(); i++ ) |
---|
3424 | { |
---|
3425 | refPicSetInterLayer1[i]->setIsLongTerm( false ); |
---|
3426 | } |
---|
3427 | |
---|
3428 | } |
---|
3429 | |
---|
3430 | Void TComSlice::printRefPicList() |
---|
3431 | { |
---|
3432 | for ( Int li = 0; li < 2; li++) |
---|
3433 | { |
---|
3434 | std::cout << std::endl << "RefPicListL" << li << ":" << std::endl; |
---|
3435 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[li]-1); rIdx ++) |
---|
3436 | { |
---|
3437 | if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( true ); |
---|
3438 | |
---|
3439 | m_apcRefPicList[li][rIdx]->print( false ); |
---|
3440 | } |
---|
3441 | } |
---|
3442 | } |
---|
3443 | |
---|
3444 | Void TComSlice::markCurrPic( TComPic* currPic ) |
---|
3445 | { |
---|
3446 | currPic->getSlice(0)->setReferenced( true ) ; |
---|
3447 | currPic->setIsLongTerm( false ); |
---|
3448 | |
---|
3449 | currPic->setReconMark( true ); |
---|
3450 | currPic->setPicOutputFlag( currPic->getSlice(0)->getPicOutputFlag() ); |
---|
3451 | } |
---|
3452 | |
---|
3453 | Void TComSlice::setRefPicSetInterLayer( std::vector<TComPic*>* refPicSetInterLayer0, std::vector<TComPic*>* refPicSetInterLayer1 ) |
---|
3454 | { |
---|
3455 | m_refPicSetInterLayer0 = refPicSetInterLayer0; |
---|
3456 | m_refPicSetInterLayer1 = refPicSetInterLayer1; |
---|
3457 | } |
---|
3458 | |
---|
3459 | TComPic* TComSlice::getPicFromRefPicSetInterLayer(Int setIdc, Int layerId ) const |
---|
3460 | { |
---|
3461 | assert ( setIdc == 0 || setIdc == 1); |
---|
3462 | std::vector<TComPic*>* refPicSetInterLayer = ( setIdc == 0 ? m_refPicSetInterLayer0 : m_refPicSetInterLayer1); |
---|
3463 | assert( refPicSetInterLayer != 0 ); |
---|
3464 | |
---|
3465 | TComPic* pcPic = NULL; |
---|
3466 | for ( Int i = 0; i < (*refPicSetInterLayer).size(); i++ ) |
---|
3467 | { |
---|
3468 | if ((*refPicSetInterLayer)[ i ]->getLayerId() == layerId ) |
---|
3469 | { |
---|
3470 | pcPic = (*refPicSetInterLayer)[ i ]; |
---|
3471 | } |
---|
3472 | } |
---|
3473 | |
---|
3474 | assert(pcPic != NULL); |
---|
3475 | return pcPic; |
---|
3476 | } |
---|
3477 | |
---|
3478 | |
---|
3479 | Int TComSlice::getRefLayerPicFlag( Int i ) const |
---|
3480 | { |
---|
3481 | const TComVPS* vps = getVPS(); |
---|
3482 | #if NH_3D |
---|
3483 | Int refLayerIdx = vps->getLayerIdInVps( vps->getIdRefListLayer( getLayerId(), i ) ); |
---|
3484 | #else |
---|
3485 | Int refLayerIdx = vps->getLayerIdInVps( vps->getIdDirectRefLayer( getLayerId(), i ) ); |
---|
3486 | #endif |
---|
3487 | |
---|
3488 | Bool refLayerPicFlag = ( vps->getSubLayersVpsMaxMinus1( refLayerIdx ) >= getTLayer() && ( getTLayer() == 0 || |
---|
3489 | vps->getMaxTidIlRefPicsPlus1( refLayerIdx, vps->getLayerIdInVps( getLayerId() )) > getTLayer() )); |
---|
3490 | return refLayerPicFlag; |
---|
3491 | } |
---|
3492 | |
---|
3493 | Int TComSlice::getRefLayerPicIdc( Int j ) const |
---|
3494 | { |
---|
3495 | Int refLayerPicIdc = -1; |
---|
3496 | Int curj = 0; |
---|
3497 | #if NH_3D |
---|
3498 | for( Int i = 0; i < getVPS()->getNumRefListLayers( getLayerId()) ; i++ ) |
---|
3499 | #else |
---|
3500 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ ) |
---|
3501 | #endif |
---|
3502 | { |
---|
3503 | if( getRefLayerPicFlag( i ) ) |
---|
3504 | { |
---|
3505 | if ( curj == j ) |
---|
3506 | { |
---|
3507 | refLayerPicIdc = i; |
---|
3508 | break; |
---|
3509 | } |
---|
3510 | curj++; |
---|
3511 | } |
---|
3512 | } |
---|
3513 | |
---|
3514 | assert( curj == j ); |
---|
3515 | assert( refLayerPicIdc != -1 ); |
---|
3516 | return refLayerPicIdc; |
---|
3517 | } |
---|
3518 | |
---|
3519 | Int TComSlice::getNumRefLayerPics( ) const |
---|
3520 | { |
---|
3521 | Int numRefLayerPics = 0; |
---|
3522 | #if NH_3D |
---|
3523 | for( Int i = 0; i < getVPS()->getNumRefListLayers( getLayerId()) ; i++ ) |
---|
3524 | #else |
---|
3525 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ ) |
---|
3526 | #endif |
---|
3527 | { |
---|
3528 | numRefLayerPics += getRefLayerPicFlag( i ); |
---|
3529 | } |
---|
3530 | return numRefLayerPics; |
---|
3531 | } |
---|
3532 | |
---|
3533 | |
---|
3534 | |
---|
3535 | Int TComSlice::getNumActiveRefLayerPics() const |
---|
3536 | { |
---|
3537 | Int numActiveRefLayerPics; |
---|
3538 | |
---|
3539 | if( getLayerId() == 0 || getNumRefLayerPics() == 0 ) |
---|
3540 | { |
---|
3541 | numActiveRefLayerPics = 0; |
---|
3542 | } |
---|
3543 | else if (getVPS()->getAllRefLayersActiveFlag() ) |
---|
3544 | { |
---|
3545 | numActiveRefLayerPics = getNumRefLayerPics(); |
---|
3546 | } |
---|
3547 | else if ( !getInterLayerPredEnabledFlag() ) |
---|
3548 | { |
---|
3549 | numActiveRefLayerPics = 0; |
---|
3550 | } |
---|
3551 | #if NH_3D |
---|
3552 | else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumRefListLayers( getLayerId() ) == 1 ) |
---|
3553 | #else |
---|
3554 | else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumDirectRefLayers( getLayerId() ) == 1 ) |
---|
3555 | #endif |
---|
3556 | { |
---|
3557 | numActiveRefLayerPics = 1; |
---|
3558 | } |
---|
3559 | else |
---|
3560 | { |
---|
3561 | numActiveRefLayerPics = getNumInterLayerRefPicsMinus1() + 1; |
---|
3562 | } |
---|
3563 | return numActiveRefLayerPics; |
---|
3564 | } |
---|
3565 | |
---|
3566 | Int TComSlice::getRefPicLayerId( Int i ) const |
---|
3567 | { |
---|
3568 | #if NH_3D |
---|
3569 | return getVPS()->getIdRefListLayer( getLayerId(), getInterLayerPredLayerIdc( i ) ); |
---|
3570 | #else |
---|
3571 | return getVPS()->getIdDirectRefLayer( getLayerId(), getInterLayerPredLayerIdc( i ) ); |
---|
3572 | #endif |
---|
3573 | } |
---|
3574 | #if NH_3D_NBDV |
---|
3575 | Void TComSlice::setDefaultRefView() |
---|
3576 | { |
---|
3577 | setDefaultRefViewIdx(-1); |
---|
3578 | setDefaultRefViewIdxAvailableFlag(false); |
---|
3579 | |
---|
3580 | Int valid = 0; |
---|
3581 | Int DefaultRefViewIdx = -1; |
---|
3582 | |
---|
3583 | for(UInt curViewIdx = 0; curViewIdx < getViewIndex() && valid == 0; curViewIdx++) |
---|
3584 | { |
---|
3585 | for(Int iRefListId = 0; (iRefListId < (isInterB() ? 2 : 1)) && !isIntra() && valid == 0; iRefListId++) |
---|
3586 | { |
---|
3587 | RefPicList eRefPicList = RefPicList(iRefListId); |
---|
3588 | Int iNumRefPics = getNumRefIdx(eRefPicList); |
---|
3589 | |
---|
3590 | for(Int i = 0; i < iNumRefPics; i++) |
---|
3591 | { |
---|
3592 | if(getPOC() == getRefPic(eRefPicList, i)->getPOC() && curViewIdx == getRefPic(eRefPicList, i)->getViewIndex()) |
---|
3593 | { |
---|
3594 | valid = 1; |
---|
3595 | DefaultRefViewIdx = curViewIdx; |
---|
3596 | break; |
---|
3597 | } |
---|
3598 | } |
---|
3599 | } |
---|
3600 | } |
---|
3601 | |
---|
3602 | if(valid) |
---|
3603 | { |
---|
3604 | setDefaultRefViewIdx(DefaultRefViewIdx); |
---|
3605 | setDefaultRefViewIdxAvailableFlag(true); |
---|
3606 | } |
---|
3607 | } |
---|
3608 | #endif |
---|
3609 | |
---|
3610 | #if NH_3D_ARP |
---|
3611 | Void TComSlice::setARPStepNum( TComPicLists*ivPicLists ) |
---|
3612 | { |
---|
3613 | Bool tempRefPicInListsFlag = false; |
---|
3614 | if( !getIvResPredFlag() || this->isIRAP()) |
---|
3615 | { |
---|
3616 | m_nARPStepNum = 0; |
---|
3617 | } |
---|
3618 | else |
---|
3619 | { |
---|
3620 | setFirstTRefIdx (REF_PIC_LIST_0, -1); |
---|
3621 | setFirstTRefIdx (REF_PIC_LIST_1, -1); |
---|
3622 | for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ ) |
---|
3623 | { |
---|
3624 | Int diffPOC=MAX_INT; |
---|
3625 | Int idx=-1; |
---|
3626 | for(Int i = 0; i < getNumRefIdx(RefPicList(refListIdx)); i++ ) |
---|
3627 | { |
---|
3628 | if ( getRefPic(RefPicList(refListIdx), i)->getPOC() != getPOC() ) |
---|
3629 | { |
---|
3630 | if( abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC()) < diffPOC) |
---|
3631 | { |
---|
3632 | diffPOC=abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC()); |
---|
3633 | idx=i; |
---|
3634 | } |
---|
3635 | } |
---|
3636 | if(idx>=0) |
---|
3637 | { |
---|
3638 | setFirstTRefIdx (RefPicList(refListIdx), idx); |
---|
3639 | } |
---|
3640 | } |
---|
3641 | } |
---|
3642 | tempRefPicInListsFlag = (getFirstTRefIdx(REF_PIC_LIST_0) >= 0 || getFirstTRefIdx(REF_PIC_LIST_1) >= 0) && getDefaultRefViewIdxAvailableFlag(); |
---|
3643 | m_nARPStepNum = tempRefPicInListsFlag ? H_3D_ARP_WFNR : 0; |
---|
3644 | } |
---|
3645 | |
---|
3646 | if (tempRefPicInListsFlag) |
---|
3647 | { |
---|
3648 | for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ ) |
---|
3649 | { |
---|
3650 | RefPicList eRefPicList = RefPicList( refListIdx ); |
---|
3651 | Int prevPOC = getRefPic(eRefPicList, getFirstTRefIdx(eRefPicList) )->getPOC(); |
---|
3652 | for( Int i = 0; i < getNumActiveRefLayerPics(); i++ ) |
---|
3653 | { |
---|
3654 | Int layerIdInNuh = getRefPicLayerId( i ); |
---|
3655 | |
---|
3656 | TComPic* picV = getIvPic( getIsDepth(), getVPS()->getViewIndex( layerIdInNuh ) ); |
---|
3657 | assert( picV != NULL ); |
---|
3658 | IntAry1d pocsInCurrRPSsPicV = picV->getSlice(0)->getPocsInCurrRPSs(); |
---|
3659 | Bool refRpRefAvailFlag = false; |
---|
3660 | for (Int idx = 0; idx < pocsInCurrRPSsPicV.size(); idx++) |
---|
3661 | { |
---|
3662 | if ( pocsInCurrRPSsPicV[idx] == prevPOC ) |
---|
3663 | { |
---|
3664 | refRpRefAvailFlag = true; |
---|
3665 | break; |
---|
3666 | } |
---|
3667 | } |
---|
3668 | |
---|
3669 | if (getFirstTRefIdx(eRefPicList) >= 0 && refRpRefAvailFlag ) |
---|
3670 | { |
---|
3671 | m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = true; |
---|
3672 | } |
---|
3673 | else |
---|
3674 | { |
---|
3675 | m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = false; |
---|
3676 | } |
---|
3677 | } |
---|
3678 | } |
---|
3679 | } |
---|
3680 | if( m_nARPStepNum > 1) |
---|
3681 | { |
---|
3682 | for(Int i = 0; i < getNumActiveRefLayerPics(); i ++ ) |
---|
3683 | { |
---|
3684 | Int iLayerId = getRefPicLayerId( i ); |
---|
3685 | Int iViewIdx = getVPS()->getViewIndex(iLayerId); |
---|
3686 | Bool bIsDepth = ( getVPS()->getDepthId ( iLayerId ) == 1 ); |
---|
3687 | if( iViewIdx<getViewIndex() && !bIsDepth ) |
---|
3688 | { |
---|
3689 | setBaseViewRefPicList( ivPicLists->getPicList( iLayerId ), iViewIdx ); |
---|
3690 | } |
---|
3691 | } |
---|
3692 | } |
---|
3693 | } |
---|
3694 | #endif |
---|
3695 | |
---|
3696 | #if NH_3D_IC |
---|
3697 | // This is an encoder only function and should be moved to TEncSlice or TEncSearch!! |
---|
3698 | Void TComSlice::xSetApplyIC(Bool bUseLowLatencyICEnc) |
---|
3699 | { |
---|
3700 | if(bUseLowLatencyICEnc) |
---|
3701 | { |
---|
3702 | Bool existInterViewRef=false; |
---|
3703 | TComPic* pcCurrPic = getPic(); |
---|
3704 | TComPic* pcRefPic = NULL; |
---|
3705 | for ( Int i = 0; (i < getNumRefIdx( REF_PIC_LIST_0 )) && !existInterViewRef; i++ ) |
---|
3706 | { |
---|
3707 | pcRefPic = getRefPic( REF_PIC_LIST_0, i ); |
---|
3708 | if ( pcRefPic != NULL ) |
---|
3709 | { |
---|
3710 | if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() ) |
---|
3711 | { |
---|
3712 | existInterViewRef = true; |
---|
3713 | } |
---|
3714 | } |
---|
3715 | } |
---|
3716 | |
---|
3717 | for ( Int i = 0; (i < getNumRefIdx( REF_PIC_LIST_1 )) && !existInterViewRef; i++ ) |
---|
3718 | { |
---|
3719 | pcRefPic = getRefPic( REF_PIC_LIST_1, i ); |
---|
3720 | if ( pcRefPic != NULL ) |
---|
3721 | { |
---|
3722 | if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() ) |
---|
3723 | { |
---|
3724 | existInterViewRef = true; |
---|
3725 | } |
---|
3726 | } |
---|
3727 | } |
---|
3728 | |
---|
3729 | if(!existInterViewRef) |
---|
3730 | { |
---|
3731 | m_bApplyIC = false; |
---|
3732 | } |
---|
3733 | else |
---|
3734 | { |
---|
3735 | Int curLayer=getDepth(); |
---|
3736 | if( curLayer>9) curLayer=9; // Max layer is 10 |
---|
3737 | |
---|
3738 | m_bApplyIC = true; |
---|
3739 | Int refLayer = curLayer-1; |
---|
3740 | |
---|
3741 | Int ICEnableCandidate = getICEnableCandidate(refLayer); |
---|
3742 | Int ICEnableNum = getICEnableNum(refLayer); |
---|
3743 | if( (refLayer>=0) && (ICEnableCandidate>0) ) |
---|
3744 | { |
---|
3745 | Double ratio=Double(ICEnableNum/Double(ICEnableCandidate)); |
---|
3746 | |
---|
3747 | if( ratio > IC_LOW_LATENCY_ENCODING_THRESHOLD) |
---|
3748 | { |
---|
3749 | m_bApplyIC=true; |
---|
3750 | } |
---|
3751 | else |
---|
3752 | { |
---|
3753 | m_bApplyIC=false; |
---|
3754 | } |
---|
3755 | } |
---|
3756 | setICEnableCandidate(curLayer, 0); |
---|
3757 | setICEnableNum(curLayer, 0); |
---|
3758 | } |
---|
3759 | } |
---|
3760 | else |
---|
3761 | { |
---|
3762 | TComPic* pcCurrPic = getPic(); |
---|
3763 | TComPicYuv* pcCurrPicYuv = pcCurrPic->getPicYuvOrg(); |
---|
3764 | |
---|
3765 | // Get InterView Reference picture |
---|
3766 | // !!!!! Assume only one Interview Reference Picture in L0 |
---|
3767 | // GT: Is this assumption correct? |
---|
3768 | |
---|
3769 | TComPicYuv* pcRefPicYuvOrg = NULL; |
---|
3770 | for ( Int i = 0; i < getNumRefIdx( REF_PIC_LIST_0 ); i++ ) |
---|
3771 | { |
---|
3772 | TComPic* pcRefPic = getRefPic( REF_PIC_LIST_0, i ); |
---|
3773 | if ( pcRefPic != NULL ) |
---|
3774 | { |
---|
3775 | if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() ) |
---|
3776 | { |
---|
3777 | pcRefPicYuvOrg = pcRefPic->getPicYuvOrg(); |
---|
3778 | } |
---|
3779 | } |
---|
3780 | } |
---|
3781 | |
---|
3782 | if ( pcRefPicYuvOrg != NULL ) |
---|
3783 | { |
---|
3784 | // Histogram building - luminance |
---|
3785 | Int iMaxPelValue = ( 1 << getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) ); |
---|
3786 | Int *aiRefOrgHist = (Int *) xMalloc( Int,iMaxPelValue ); |
---|
3787 | Int *aiCurrHist = (Int *) xMalloc( Int,iMaxPelValue ); |
---|
3788 | memset( aiRefOrgHist, 0, iMaxPelValue*sizeof(Int) ); |
---|
3789 | memset( aiCurrHist, 0, iMaxPelValue*sizeof(Int) ); |
---|
3790 | |
---|
3791 | Int iWidth = pcCurrPicYuv->getWidth(COMPONENT_Y); |
---|
3792 | Int iHeight = pcCurrPicYuv->getHeight(COMPONENT_Y); |
---|
3793 | Pel* pCurrY = pcCurrPicYuv->getAddr(COMPONENT_Y); |
---|
3794 | Pel* pRefOrgY = pcRefPicYuvOrg->getAddr(COMPONENT_Y); |
---|
3795 | Int iCurrStride = pcCurrPicYuv->getStride(COMPONENT_Y); |
---|
3796 | Int iRefStride = pcRefPicYuvOrg->getStride(COMPONENT_Y); |
---|
3797 | for ( Int y = 0; y < iHeight; y++ ) |
---|
3798 | { |
---|
3799 | for ( Int x = 0; x < iWidth; x++ ) |
---|
3800 | { |
---|
3801 | aiCurrHist[pCurrY[x]]++; |
---|
3802 | aiRefOrgHist[pRefOrgY[x]]++; |
---|
3803 | } |
---|
3804 | pCurrY += iCurrStride; |
---|
3805 | pRefOrgY += iRefStride; |
---|
3806 | } |
---|
3807 | |
---|
3808 | // Histogram SAD |
---|
3809 | Int iSumOrgSAD = 0; |
---|
3810 | for ( Int i = 0; i < iMaxPelValue; i++ ) |
---|
3811 | { |
---|
3812 | iSumOrgSAD += abs( aiCurrHist[i] - aiRefOrgHist[i] ); |
---|
3813 | } |
---|
3814 | |
---|
3815 | // Setting |
---|
3816 | Double dThresholdOrgSAD = getIsDepth() ? 0.1 : 0.05; |
---|
3817 | |
---|
3818 | if ( iSumOrgSAD > Int( dThresholdOrgSAD * iWidth * iHeight ) ) |
---|
3819 | { |
---|
3820 | m_bApplyIC = true; |
---|
3821 | } |
---|
3822 | else |
---|
3823 | { |
---|
3824 | m_bApplyIC = false; |
---|
3825 | } |
---|
3826 | |
---|
3827 | xFree( aiCurrHist ); |
---|
3828 | xFree( aiRefOrgHist ); |
---|
3829 | } |
---|
3830 | }//if(bUseLowLatencyICEnc) |
---|
3831 | } |
---|
3832 | #endif |
---|
3833 | #if NH_3D |
---|
3834 | Void TComSlice::setIvPicLists( TComPicLists* m_ivPicLists ) |
---|
3835 | { |
---|
3836 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
3837 | { |
---|
3838 | for ( Int depthId = 0; depthId < 2; depthId++ ) |
---|
3839 | { |
---|
3840 | m_ivPicsCurrPoc[ depthId ][ i ] = ( i <= m_viewIndex ) ? m_ivPicLists->getPic( i, ( depthId == 1) , getPOC() ) : NULL; |
---|
3841 | } |
---|
3842 | } |
---|
3843 | } |
---|
3844 | Void TComSlice::setDepthToDisparityLUTs() |
---|
3845 | { |
---|
3846 | Bool setupLUT = false; |
---|
3847 | |
---|
3848 | setupLUT = setupLUT || getViewSynthesisPredFlag( ); |
---|
3849 | |
---|
3850 | #if NH_3D_NBDV_REF |
---|
3851 | setupLUT = setupLUT || getDepthRefinementFlag( ); |
---|
3852 | #endif |
---|
3853 | |
---|
3854 | #if NH_3D_IV_MERGE |
---|
3855 | setupLUT = setupLUT || ( getIvMvPredFlag() && getIsDepth() ); |
---|
3856 | #endif |
---|
3857 | |
---|
3858 | Int bitDepthY = getSPS()->getBitDepth(CHANNEL_TYPE_LUMA); |
---|
3859 | |
---|
3860 | if( !setupLUT ) |
---|
3861 | { |
---|
3862 | return; |
---|
3863 | } |
---|
3864 | |
---|
3865 | m_numViews = getVPS()->getNumViews(); |
---|
3866 | /// GT: Allocation should be moved to a better place later; |
---|
3867 | if ( m_depthToDisparityB == NULL ) |
---|
3868 | { |
---|
3869 | m_depthToDisparityB = new Int*[ m_numViews ]; |
---|
3870 | for ( Int i = 0; i < getVPS()->getNumViews(); i++ ) |
---|
3871 | { |
---|
3872 | m_depthToDisparityB[ i ] = new Int[ Int(1 << bitDepthY) ]; |
---|
3873 | } |
---|
3874 | } |
---|
3875 | |
---|
3876 | |
---|
3877 | if ( m_depthToDisparityF == NULL ) |
---|
3878 | { |
---|
3879 | m_depthToDisparityF = new Int*[ m_numViews ]; |
---|
3880 | for ( Int i = 0; i < m_numViews; i++ ) |
---|
3881 | { |
---|
3882 | m_depthToDisparityF[ i ] = new Int[ Int(1 << bitDepthY) ]; |
---|
3883 | } |
---|
3884 | } |
---|
3885 | |
---|
3886 | assert( m_depthToDisparityB != NULL ); |
---|
3887 | assert( m_depthToDisparityF != NULL ); |
---|
3888 | |
---|
3889 | const TComVPS* vps = getVPS(); |
---|
3890 | |
---|
3891 | Int log2Div = bitDepthY - 1 + vps->getCpPrecision(); |
---|
3892 | Int voiInVps = vps->getVoiInVps( getViewIndex() ); |
---|
3893 | Bool camParaSH = vps->getCpInSliceSegmentHeaderFlag( voiInVps ); |
---|
3894 | |
---|
3895 | const IntAry1d codScale = camParaSH ? m_aaiCodedScale [ 0 ] : vps->getCodedScale ( voiInVps ); |
---|
3896 | const IntAry1d codOffset = camParaSH ? m_aaiCodedOffset[ 0 ] : vps->getCodedOffset ( voiInVps ); |
---|
3897 | const IntAry1d invCodScale = camParaSH ? m_aaiCodedScale [ 1 ] : vps->getInvCodedScale ( voiInVps ); |
---|
3898 | const IntAry1d invCodOffset = camParaSH ? m_aaiCodedOffset[ 1 ] : vps->getInvCodedOffset( voiInVps ); |
---|
3899 | |
---|
3900 | |
---|
3901 | for (Int i = 0; i < voiInVps; i++) |
---|
3902 | { |
---|
3903 | Int iInVoi = vps->getVoiInVps( i ); |
---|
3904 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
3905 | if ( g_traceCameraParameters ) |
---|
3906 | { |
---|
3907 | std::cout << "Cp: " << codScale [ iInVoi ] << " " << codOffset[ iInVoi ] << " " |
---|
3908 | << invCodScale[ iInVoi ] << " " << invCodOffset[ iInVoi ] << " " << log2Div << std::endl ; |
---|
3909 | } |
---|
3910 | #endif |
---|
3911 | for ( Int d = 0; d <= ( ( 1 << bitDepthY ) - 1 ); d++ ) |
---|
3912 | { |
---|
3913 | Int offset = ( codOffset [ iInVoi ] << bitDepthY ) + ( ( 1 << log2Div ) >> 1 ); |
---|
3914 | m_depthToDisparityB[ iInVoi ][ d ] = ( codScale [ iInVoi ] * d + offset ) >> log2Div; |
---|
3915 | |
---|
3916 | Int invOffset = ( invCodOffset[ iInVoi ] << bitDepthY ) + ( ( 1 << log2Div ) >> 1 ); |
---|
3917 | m_depthToDisparityF[ iInVoi ][ d ] = ( invCodScale[ iInVoi ] * d + invOffset ) >> log2Div; |
---|
3918 | } |
---|
3919 | } |
---|
3920 | } |
---|
3921 | #endif |
---|
3922 | #endif |
---|
3923 | |
---|
3924 | |
---|
3925 | #if NH_MV |
---|
3926 | Void TComSlice::checkCrossLayerBlaFlag() const |
---|
3927 | { |
---|
3928 | // cross_layer_bla_flag shall be equal to 0 for pictures with nal_unit_type not equal to IDR_W_RADL or IDR_N_LP or with nuh_layer_id not equal to 0. |
---|
3929 | if ( getLayerId() != 0 || getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
3930 | { |
---|
3931 | assert( m_crossLayerBlaFlag == 0 ); |
---|
3932 | } |
---|
3933 | } |
---|
3934 | |
---|
3935 | Bool TComSlice::inferPocMsbValPresentFlag() |
---|
3936 | { |
---|
3937 | Bool pocMsbValPresentFlag; |
---|
3938 | if( getSliceSegmentHeaderExtensionLength() == 0 ) |
---|
3939 | { |
---|
3940 | pocMsbValPresentFlag = false; |
---|
3941 | } |
---|
3942 | else if ( getPocMsbValRequiredFlag() ) |
---|
3943 | { |
---|
3944 | pocMsbValPresentFlag = true; |
---|
3945 | } |
---|
3946 | else |
---|
3947 | { |
---|
3948 | pocMsbValPresentFlag = false; |
---|
3949 | } |
---|
3950 | |
---|
3951 | return pocMsbValPresentFlag; |
---|
3952 | } |
---|
3953 | |
---|
3954 | |
---|
3955 | #endif |
---|
3956 | |
---|
3957 | |
---|
3958 | #if NH_3D |
---|
3959 | Void TComSlice::init3dToolParameters() |
---|
3960 | { |
---|
3961 | Bool depthFlag = getIsDepth(); |
---|
3962 | |
---|
3963 | Bool nRLLG0 = ( getVPS()->getNumRefListLayers( getLayerId() ) > 0 ); |
---|
3964 | |
---|
3965 | const TComSps3dExtension* sps3dExt = getSPS()->getSps3dExtension(); |
---|
3966 | |
---|
3967 | m_ivMvPredFlag = sps3dExt->getIvMvPredFlag ( depthFlag ) && nRLLG0 ; |
---|
3968 | m_ivMvScalingFlag = sps3dExt->getIvMvScalingFlag ( depthFlag ) ; |
---|
3969 | m_ivResPredFlag = sps3dExt->getIvResPredFlag ( depthFlag ) && nRLLG0 ; |
---|
3970 | m_depthRefinementFlag = sps3dExt->getDepthRefinementFlag ( depthFlag ) && getInCompPredFlag() && m_cpAvailableFlag; |
---|
3971 | m_viewSynthesisPredFlag = sps3dExt->getViewSynthesisPredFlag( depthFlag ) && nRLLG0 && getInCompPredFlag() && m_cpAvailableFlag; |
---|
3972 | m_depthBasedBlkPartFlag = sps3dExt->getDepthBasedBlkPartFlag( depthFlag ) && getInCompPredFlag(); |
---|
3973 | m_mpiFlag = sps3dExt->getMpiFlag ( depthFlag ) && getInCompPredFlag(); |
---|
3974 | m_intraContourFlag = sps3dExt->getIntraContourFlag ( depthFlag ) && getInCompPredFlag(); |
---|
3975 | m_intraSdcWedgeFlag = sps3dExt->getIntraSdcWedgeFlag ( depthFlag ) ; |
---|
3976 | m_qtPredFlag = sps3dExt->getQtPredFlag ( depthFlag ) && getInCompPredFlag(); |
---|
3977 | m_interSdcFlag = sps3dExt->getInterSdcFlag ( depthFlag ) ; |
---|
3978 | m_depthIntraSkipFlag = sps3dExt->getDepthIntraSkipFlag ( depthFlag ) ; |
---|
3979 | |
---|
3980 | m_subPbSize = 1 << ( sps3dExt->getLog2SubPbSizeMinus3 ( depthFlag ) + 3 ); |
---|
3981 | m_mpiSubPbSize = 1 << ( sps3dExt->getLog2MpiSubPbSizeMinus3( depthFlag ) + 3 ); |
---|
3982 | |
---|
3983 | |
---|
3984 | #if H_3D_OUTPUT_ACTIVE_TOOLS |
---|
3985 | std::cout << "Layer: :" << getLayerId() << std::endl; |
---|
3986 | std::cout << "DepthFlag: :" << getIsDepth() << std::endl; |
---|
3987 | std::cout << "ViewOrderIdx: :" << getViewIndex() << std::endl; |
---|
3988 | std::cout << "InterCmpPredAvailableFlag:" << getInCmpPredAvailFlag() << std::endl; |
---|
3989 | std::cout << "InterCompPredFlag :" << getInCompPredFlag() << std::endl; |
---|
3990 | |
---|
3991 | std::cout << "ivMvPredFlag :" << m_ivMvPredFlag << std::endl; |
---|
3992 | std::cout << "ivMvScalingFlag :" << m_ivMvScalingFlag << std::endl; |
---|
3993 | std::cout << "ivResPredFlag :" << m_ivResPredFlag << std::endl; |
---|
3994 | std::cout << "depthRefinementFlag :" << m_depthRefinementFlag << std::endl; |
---|
3995 | std::cout << "viewSynthesisPredFlag :" << m_viewSynthesisPredFlag << std::endl; |
---|
3996 | std::cout << "depthBasedBlkPartFlag :" << m_depthBasedBlkPartFlag << std::endl; |
---|
3997 | std::cout << "mpiFlag :" << m_mpiFlag << std::endl; |
---|
3998 | std::cout << "intraContourFlag :" << m_intraContourFlag << std::endl; |
---|
3999 | std::cout << "intraSdcWedgeFlag :" << m_intraSdcWedgeFlag << std::endl; |
---|
4000 | std::cout << "qtPredFlag :" << m_qtPredFlag << std::endl; |
---|
4001 | std::cout << "interSdcFlag :" << m_interSdcFlag << std::endl; |
---|
4002 | std::cout << "depthIntraSkipFlag :" << m_depthIntraSkipFlag << std::endl; |
---|
4003 | std::cout << "subPbSize :" << m_subPbSize << std::endl; |
---|
4004 | std::cout << "mpiSubPbSize :" << m_mpiSubPbSize << std::endl; |
---|
4005 | #endif |
---|
4006 | } |
---|
4007 | |
---|
4008 | Void TComSlice::deriveInCmpPredAndCpAvailFlag( ) |
---|
4009 | { |
---|
4010 | Int numCurCmpLIds = getIsDepth() ? 1 : getNumActiveRefLayerPics(); |
---|
4011 | std::vector<Int> curCmpLIds; |
---|
4012 | if ( getIsDepth() ) |
---|
4013 | { |
---|
4014 | curCmpLIds.push_back( getLayerId() ); |
---|
4015 | } |
---|
4016 | else |
---|
4017 | { |
---|
4018 | for (Int i = 0; i < numCurCmpLIds; i++) |
---|
4019 | { |
---|
4020 | curCmpLIds.push_back( getRefPicLayerId( i ) ); |
---|
4021 | } |
---|
4022 | } |
---|
4023 | |
---|
4024 | m_cpAvailableFlag = true; |
---|
4025 | m_inCmpRefViewIdcs.clear(); |
---|
4026 | Bool allRefCmpLayersAvailFlag = true; |
---|
4027 | |
---|
4028 | for( Int i = 0; i <= numCurCmpLIds - 1; i++ ) |
---|
4029 | { |
---|
4030 | m_inCmpRefViewIdcs.push_back( getVPS()->getViewOrderIdx( curCmpLIds[ i ] )); |
---|
4031 | if( !getVPS()->getCpPresentFlag( getVPS()->getVoiInVps( getViewIndex() ), getVPS()->getVoiInVps( m_inCmpRefViewIdcs[ i ] ) ) ) |
---|
4032 | { |
---|
4033 | m_cpAvailableFlag = false; |
---|
4034 | } |
---|
4035 | Bool refCmpCurLIdAvailFlag = false; |
---|
4036 | if( getVPS()->getViewCompLayerPresentFlag( m_inCmpRefViewIdcs[ i ], !getIsDepth() ) ) |
---|
4037 | { |
---|
4038 | Int j = getVPS()->getLayerIdInVps( getVPS()->getViewCompLayerId( m_inCmpRefViewIdcs[ i ], !getIsDepth() ) ); |
---|
4039 | if ( getVPS()->getDirectDependencyFlag( getVPS()->getLayerIdInVps( getLayerId() ) , j ) && |
---|
4040 | getVPS()->getSubLayersVpsMaxMinus1( j ) >= getTemporalId() && |
---|
4041 | ( getTemporalId() == 0 || getVPS()->getMaxTidIlRefPicsPlus1( j , getVPS()->getLayerIdInVps( getLayerId() ) ) > getTemporalId() ) |
---|
4042 | ) |
---|
4043 | { |
---|
4044 | refCmpCurLIdAvailFlag = true; |
---|
4045 | } |
---|
4046 | } |
---|
4047 | if( !refCmpCurLIdAvailFlag ) |
---|
4048 | { |
---|
4049 | allRefCmpLayersAvailFlag = false; |
---|
4050 | } |
---|
4051 | } |
---|
4052 | |
---|
4053 | if( !allRefCmpLayersAvailFlag ) |
---|
4054 | { |
---|
4055 | m_inCmpPredAvailFlag = false; |
---|
4056 | } |
---|
4057 | else |
---|
4058 | { |
---|
4059 | const TComSps3dExtension* sps3dExt = getSPS()->getSps3dExtension(); |
---|
4060 | if( !getIsDepth() ) |
---|
4061 | { |
---|
4062 | m_inCmpPredAvailFlag = sps3dExt->getViewSynthesisPredFlag( getIsDepth() ) || |
---|
4063 | sps3dExt->getDepthBasedBlkPartFlag( getIsDepth() ) || |
---|
4064 | sps3dExt->getDepthRefinementFlag ( getIsDepth() ); |
---|
4065 | } |
---|
4066 | else |
---|
4067 | { |
---|
4068 | m_inCmpPredAvailFlag = sps3dExt->getIntraContourFlag( getIsDepth() ) || |
---|
4069 | sps3dExt->getQtPredFlag( getIsDepth() ) || |
---|
4070 | sps3dExt->getMpiFlag( getIsDepth() ); |
---|
4071 | } |
---|
4072 | } |
---|
4073 | } |
---|
4074 | |
---|
4075 | Void TComSlice::checkInCompPredRefLayers() |
---|
4076 | { |
---|
4077 | if ( getInCompPredFlag() ) |
---|
4078 | { |
---|
4079 | for (Int i = 0; i < getNumCurCmpLIds(); i++ ) |
---|
4080 | { |
---|
4081 | assert( getIvPic(!getIsDepth(), getInCmpRefViewIdcs( i ) ) != NULL ); |
---|
4082 | // It is a requirement of bitstream conformance that there |
---|
4083 | // is a picture in the DPB with PicOrderCntVal equal to the PicOrderCntVal of the current picture, |
---|
4084 | // and a nuh_layer_id value equal to ViewCompLayerId[ inCmpRefViewIdcs[ i ] ][ !DepthFlag ]. |
---|
4085 | } |
---|
4086 | } |
---|
4087 | } |
---|
4088 | |
---|
4089 | #endif |
---|
4090 | |
---|
4091 | /** get scaling matrix from RefMatrixID |
---|
4092 | * \param sizeId size index |
---|
4093 | * \param listId index of input matrix |
---|
4094 | * \param refListId index of reference matrix |
---|
4095 | */ |
---|
4096 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
4097 | { |
---|
4098 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
4099 | } |
---|
4100 | |
---|
4101 | Void TComScalingList::checkPredMode(UInt sizeId, UInt listId) |
---|
4102 | { |
---|
4103 | Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. |
---|
4104 | |
---|
4105 | for(Int predListIdx = (Int)listId ; predListIdx >= 0; predListIdx-=predListStep) |
---|
4106 | { |
---|
4107 | if( !memcmp(getScalingListAddress(sizeId,listId),((listId == predListIdx) ? |
---|
4108 | getScalingListDefaultAddress(sizeId, predListIdx): getScalingListAddress(sizeId, predListIdx)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
4109 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value |
---|
4110 | { |
---|
4111 | setRefMatrixId(sizeId, listId, predListIdx); |
---|
4112 | setScalingListPredModeFlag(sizeId, listId, false); |
---|
4113 | return; |
---|
4114 | } |
---|
4115 | } |
---|
4116 | setScalingListPredModeFlag(sizeId, listId, true); |
---|
4117 | } |
---|
4118 | |
---|
4119 | static Void outputScalingListHelp(std::ostream &os) |
---|
4120 | { |
---|
4121 | os << "The scaling list file specifies all matrices and their DC values; none can be missing,\n" |
---|
4122 | "but their order is arbitrary.\n\n" |
---|
4123 | "The matrices are specified by:\n" |
---|
4124 | "<matrix name><unchecked data>\n" |
---|
4125 | " <value>,<value>,<value>,....\n\n" |
---|
4126 | " Line-feeds can be added arbitrarily between values, and the number of values needs to be\n" |
---|
4127 | " at least the number of entries for the matrix (superfluous entries are ignored).\n" |
---|
4128 | " The <unchecked data> is text on the same line as the matrix that is not checked\n" |
---|
4129 | " except to ensure that the matrix name token is unique. It is recommended that it is ' ='\n" |
---|
4130 | " The values in the matrices are the absolute values (0-255), not the delta values as\n" |
---|
4131 | " exchanged between the encoder and decoder\n\n" |
---|
4132 | "The DC values (for matrix sizes larger than 8x8) are specified by:\n" |
---|
4133 | "<matrix name>_DC<unchecked data>\n" |
---|
4134 | " <value>\n"; |
---|
4135 | |
---|
4136 | os << "The permitted matrix names are:\n"; |
---|
4137 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
4138 | { |
---|
4139 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
4140 | { |
---|
4141 | if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0)) |
---|
4142 | { |
---|
4143 | os << " " << MatrixType[sizeIdc][listIdc] << '\n'; |
---|
4144 | } |
---|
4145 | } |
---|
4146 | } |
---|
4147 | } |
---|
4148 | |
---|
4149 | Void TComScalingList::outputScalingLists(std::ostream &os) const |
---|
4150 | { |
---|
4151 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
4152 | { |
---|
4153 | const UInt size = min(8,4<<(sizeIdc)); |
---|
4154 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
4155 | { |
---|
4156 | if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0)) |
---|
4157 | { |
---|
4158 | const Int *src = getScalingListAddress(sizeIdc, listIdc); |
---|
4159 | os << (MatrixType[sizeIdc][listIdc]) << " =\n "; |
---|
4160 | for(UInt y=0; y<size; y++) |
---|
4161 | { |
---|
4162 | for(UInt x=0; x<size; x++, src++) |
---|
4163 | { |
---|
4164 | os << std::setw(3) << (*src) << ", "; |
---|
4165 | } |
---|
4166 | os << (y+1<size?"\n ":"\n"); |
---|
4167 | } |
---|
4168 | if(sizeIdc > SCALING_LIST_8x8) |
---|
4169 | { |
---|
4170 | os << MatrixType_DC[sizeIdc][listIdc] << " = \n " << std::setw(3) << getScalingListDC(sizeIdc, listIdc) << "\n"; |
---|
4171 | } |
---|
4172 | os << "\n"; |
---|
4173 | } |
---|
4174 | } |
---|
4175 | } |
---|
4176 | } |
---|
4177 | |
---|
4178 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
4179 | { |
---|
4180 | static const Int LINE_SIZE=1024; |
---|
4181 | FILE *fp = NULL; |
---|
4182 | Char line[LINE_SIZE]; |
---|
4183 | |
---|
4184 | if (pchFile == NULL) |
---|
4185 | { |
---|
4186 | fprintf(stderr, "Error: no scaling list file specified. Help on scaling lists being output\n"); |
---|
4187 | outputScalingListHelp(std::cout); |
---|
4188 | std::cout << "\n\nExample scaling list file using default values:\n\n"; |
---|
4189 | outputScalingLists(std::cout); |
---|
4190 | exit (1); |
---|
4191 | return true; |
---|
4192 | } |
---|
4193 | else if ((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
4194 | { |
---|
4195 | fprintf(stderr, "Error: cannot open scaling list file %s for reading\n",pchFile); |
---|
4196 | return true; |
---|
4197 | } |
---|
4198 | |
---|
4199 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
4200 | { |
---|
4201 | const UInt size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
4202 | |
---|
4203 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
4204 | { |
---|
4205 | Int * const src = getScalingListAddress(sizeIdc, listIdc); |
---|
4206 | |
---|
4207 | if ((sizeIdc==SCALING_LIST_32x32) && (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) // derive chroma32x32 from chroma16x16 |
---|
4208 | { |
---|
4209 | const Int *srcNextSmallerSize = getScalingListAddress(sizeIdc-1, listIdc); |
---|
4210 | for(UInt i=0; i<size; i++) |
---|
4211 | { |
---|
4212 | src[i] = srcNextSmallerSize[i]; |
---|
4213 | } |
---|
4214 | setScalingListDC(sizeIdc,listIdc,(sizeIdc > SCALING_LIST_8x8) ? getScalingListDC(sizeIdc-1, listIdc) : src[0]); |
---|
4215 | } |
---|
4216 | else |
---|
4217 | { |
---|
4218 | { |
---|
4219 | fseek(fp, 0, SEEK_SET); |
---|
4220 | Bool bFound=false; |
---|
4221 | while ((!feof(fp)) && (!bFound)) |
---|
4222 | { |
---|
4223 | Char *ret = fgets(line, LINE_SIZE, fp); |
---|
4224 | Char *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType[sizeIdc][listIdc]); |
---|
4225 | // This could be a match against the DC string as well, so verify it isn't |
---|
4226 | if (findNamePosition!= NULL && (MatrixType_DC[sizeIdc][listIdc]==NULL || strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL)) |
---|
4227 | { |
---|
4228 | bFound=true; |
---|
4229 | } |
---|
4230 | } |
---|
4231 | if (!bFound) |
---|
4232 | { |
---|
4233 | fprintf(stderr, "Error: cannot find Matrix %s from scaling list file %s\n", MatrixType[sizeIdc][listIdc], pchFile); |
---|
4234 | return true; |
---|
4235 | } |
---|
4236 | } |
---|
4237 | for (UInt i=0; i<size; i++) |
---|
4238 | { |
---|
4239 | Int data; |
---|
4240 | if (fscanf(fp, "%d,", &data)!=1) |
---|
4241 | { |
---|
4242 | fprintf(stderr, "Error: cannot read value #%d for Matrix %s from scaling list file %s at file position %ld\n", i, MatrixType[sizeIdc][listIdc], pchFile, ftell(fp)); |
---|
4243 | return true; |
---|
4244 | } |
---|
4245 | if (data<0 || data>255) |
---|
4246 | { |
---|
4247 | fprintf(stderr, "Error: QMatrix entry #%d of value %d for Matrix %s from scaling list file %s at file position %ld is out of range (0 to 255)\n", i, data, MatrixType[sizeIdc][listIdc], pchFile, ftell(fp)); |
---|
4248 | return true; |
---|
4249 | } |
---|
4250 | src[i] = data; |
---|
4251 | } |
---|
4252 | |
---|
4253 | //set DC value for default matrix check |
---|
4254 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
4255 | |
---|
4256 | if(sizeIdc > SCALING_LIST_8x8) |
---|
4257 | { |
---|
4258 | { |
---|
4259 | fseek(fp, 0, SEEK_SET); |
---|
4260 | Bool bFound=false; |
---|
4261 | while ((!feof(fp)) && (!bFound)) |
---|
4262 | { |
---|
4263 | Char *ret = fgets(line, LINE_SIZE, fp); |
---|
4264 | Char *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType_DC[sizeIdc][listIdc]); |
---|
4265 | if (findNamePosition!= NULL) |
---|
4266 | { |
---|
4267 | // This won't be a match against the non-DC string. |
---|
4268 | bFound=true; |
---|
4269 | } |
---|
4270 | } |
---|
4271 | if (!bFound) |
---|
4272 | { |
---|
4273 | fprintf(stderr, "Error: cannot find DC Matrix %s from scaling list file %s\n", MatrixType_DC[sizeIdc][listIdc], pchFile); |
---|
4274 | return true; |
---|
4275 | } |
---|
4276 | } |
---|
4277 | Int data; |
---|
4278 | if (fscanf(fp, "%d,", &data)!=1) |
---|
4279 | { |
---|
4280 | fprintf(stderr, "Error: cannot read DC %s from scaling list file %s at file position %ld\n", MatrixType_DC[sizeIdc][listIdc], pchFile, ftell(fp)); |
---|
4281 | return true; |
---|
4282 | } |
---|
4283 | if (data<0 || data>255) |
---|
4284 | { |
---|
4285 | fprintf(stderr, "Error: DC value %d for Matrix %s from scaling list file %s at file position %ld is out of range (0 to 255)\n", data, MatrixType[sizeIdc][listIdc], pchFile, ftell(fp)); |
---|
4286 | return true; |
---|
4287 | } |
---|
4288 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
4289 | setScalingListDC(sizeIdc,listIdc,data); |
---|
4290 | } |
---|
4291 | } |
---|
4292 | } |
---|
4293 | } |
---|
4294 | // std::cout << "\n\nRead scaling lists of:\n\n"; |
---|
4295 | // outputScalingLists(std::cout); |
---|
4296 | |
---|
4297 | fclose(fp); |
---|
4298 | return false; |
---|
4299 | } |
---|
4300 | |
---|
4301 | #if NH_MV |
---|
4302 | Void TComScalingList::inferFrom( const TComScalingList& srcScLi ) |
---|
4303 | { |
---|
4304 | for(Int sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
4305 | { |
---|
4306 | for(Int listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
4307 | { |
---|
4308 | setRefMatrixId (sizeId,listId, srcScLi.getRefMatrixId (sizeId,listId)); |
---|
4309 | setScalingListDC(sizeId,listId, srcScLi.getScalingListDC(sizeId,listId)); |
---|
4310 | ::memcpy(getScalingListAddress(sizeId, listId),srcScLi.getScalingListAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
4311 | } |
---|
4312 | } |
---|
4313 | } |
---|
4314 | #endif |
---|
4315 | |
---|
4316 | |
---|
4317 | /** get default address of quantization matrix |
---|
4318 | * \param sizeId size index |
---|
4319 | * \param listId list index |
---|
4320 | * \returns pointer of quantization matrix |
---|
4321 | */ |
---|
4322 | const Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
4323 | { |
---|
4324 | const Int *src = 0; |
---|
4325 | switch(sizeId) |
---|
4326 | { |
---|
4327 | case SCALING_LIST_4x4: |
---|
4328 | src = g_quantTSDefault4x4; |
---|
4329 | break; |
---|
4330 | case SCALING_LIST_8x8: |
---|
4331 | case SCALING_LIST_16x16: |
---|
4332 | case SCALING_LIST_32x32: |
---|
4333 | src = (listId < (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) ) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
4334 | break; |
---|
4335 | default: |
---|
4336 | assert(0); |
---|
4337 | src = NULL; |
---|
4338 | break; |
---|
4339 | } |
---|
4340 | return src; |
---|
4341 | } |
---|
4342 | |
---|
4343 | /** process of default matrix |
---|
4344 | * \param sizeId size index |
---|
4345 | * \param listId index of input matrix |
---|
4346 | */ |
---|
4347 | Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId) |
---|
4348 | { |
---|
4349 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
4350 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
4351 | } |
---|
4352 | |
---|
4353 | /** check DC value of matrix for default matrix signaling |
---|
4354 | */ |
---|
4355 | Void TComScalingList::checkDcOfMatrix() |
---|
4356 | { |
---|
4357 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
4358 | { |
---|
4359 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
4360 | { |
---|
4361 | //check default matrix? |
---|
4362 | if(getScalingListDC(sizeId,listId) == 0) |
---|
4363 | { |
---|
4364 | processDefaultMatrix(sizeId, listId); |
---|
4365 | } |
---|
4366 | } |
---|
4367 | } |
---|
4368 | } |
---|
4369 | |
---|
4370 | ParameterSetManager::ParameterSetManager() |
---|
4371 | : m_vpsMap(MAX_NUM_VPS) |
---|
4372 | , m_spsMap(MAX_NUM_SPS) |
---|
4373 | , m_ppsMap(MAX_NUM_PPS) |
---|
4374 | , m_activeVPSId(-1) |
---|
4375 | #if !NH_MV |
---|
4376 | , m_activeSPSId(-1) |
---|
4377 | #endif |
---|
4378 | { |
---|
4379 | #if NH_MV |
---|
4380 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
4381 | { |
---|
4382 | m_activeSPSId[i] = -1; |
---|
4383 | } |
---|
4384 | #endif |
---|
4385 | } |
---|
4386 | |
---|
4387 | |
---|
4388 | ParameterSetManager::~ParameterSetManager() |
---|
4389 | { |
---|
4390 | } |
---|
4391 | |
---|
4392 | //! activate a SPS from a active parameter sets SEI message |
---|
4393 | //! \returns true, if activation is successful |
---|
4394 | #if NH_MV |
---|
4395 | //Bool ParameterSetManager::activateSPSWithSEI(Int spsId, Int layerId ) |
---|
4396 | #else |
---|
4397 | //Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
4398 | #endif |
---|
4399 | //{ |
---|
4400 | //TComSPS *sps = m_spsMap.getPS(spsId); |
---|
4401 | // if (sps) |
---|
4402 | // { |
---|
4403 | // Int vpsId = sps->getVPSId(); |
---|
4404 | // TComVPS *vps = m_vpsMap.getPS(vpsId); |
---|
4405 | // if (vps) |
---|
4406 | // { |
---|
4407 | #if NH_MV |
---|
4408 | // m_activeVPS = *(vps); |
---|
4409 | // m_activeSPS[ layerId ] = *(sps); |
---|
4410 | #else |
---|
4411 | // m_activeVPS = *(vps); |
---|
4412 | // m_activeSPS = *(sps); |
---|
4413 | #endif |
---|
4414 | // return true; |
---|
4415 | // } |
---|
4416 | // else |
---|
4417 | // { |
---|
4418 | // printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
4419 | // } |
---|
4420 | // } |
---|
4421 | // else |
---|
4422 | // { |
---|
4423 | // printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
4424 | // } |
---|
4425 | // return false; |
---|
4426 | //} |
---|
4427 | |
---|
4428 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
4429 | //! \returns true, if activation is successful |
---|
4430 | #if NH_MV |
---|
4431 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP, Int layerId ) |
---|
4432 | #else |
---|
4433 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
4434 | #endif |
---|
4435 | { |
---|
4436 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
4437 | if (pps) |
---|
4438 | { |
---|
4439 | Int spsId = pps->getSPSId(); |
---|
4440 | #if NH_MV |
---|
4441 | if (!isIRAP && (spsId != m_activeSPSId[ layerId ] )) |
---|
4442 | #else |
---|
4443 | if (!isIRAP && (spsId != m_activeSPSId )) |
---|
4444 | #endif |
---|
4445 | { |
---|
4446 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IDR."); |
---|
4447 | } |
---|
4448 | else |
---|
4449 | { |
---|
4450 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
4451 | if (sps) |
---|
4452 | { |
---|
4453 | Int vpsId = sps->getVPSId(); |
---|
4454 | if (!isIRAP && (vpsId != m_activeVPSId )) |
---|
4455 | { |
---|
4456 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IDR."); |
---|
4457 | } |
---|
4458 | else |
---|
4459 | { |
---|
4460 | TComVPS *vps =m_vpsMap.getPS(vpsId); |
---|
4461 | if (vps) |
---|
4462 | { |
---|
4463 | m_activeVPSId = vpsId; |
---|
4464 | #if NH_MV |
---|
4465 | m_activeSPSId[layerId] = spsId; |
---|
4466 | #else |
---|
4467 | m_activeSPSId = spsId; |
---|
4468 | #endif |
---|
4469 | return true; |
---|
4470 | } |
---|
4471 | else |
---|
4472 | { |
---|
4473 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
4474 | } |
---|
4475 | } |
---|
4476 | } |
---|
4477 | else |
---|
4478 | { |
---|
4479 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
4480 | } |
---|
4481 | } |
---|
4482 | } |
---|
4483 | else |
---|
4484 | { |
---|
4485 | printf("Warning: tried to activate non-existing PPS."); |
---|
4486 | } |
---|
4487 | |
---|
4488 | // Failed to activate if reach here. |
---|
4489 | #if NH_MV |
---|
4490 | m_activeSPSId[layerId]=-1; |
---|
4491 | #else |
---|
4492 | m_activeSPSId=-1; |
---|
4493 | #endif |
---|
4494 | m_activeVPSId=-1; |
---|
4495 | |
---|
4496 | return false; |
---|
4497 | } |
---|
4498 | |
---|
4499 | ProfileTierLevel::ProfileTierLevel() |
---|
4500 | : m_profileSpace (0) |
---|
4501 | , m_tierFlag (Level::MAIN) |
---|
4502 | , m_profileIdc (Profile::NONE) |
---|
4503 | , m_levelIdc (Level::NONE) |
---|
4504 | , m_progressiveSourceFlag (false) |
---|
4505 | , m_interlacedSourceFlag (false) |
---|
4506 | , m_nonPackedConstraintFlag(false) |
---|
4507 | , m_frameOnlyConstraintFlag(false) |
---|
4508 | #if NH_MV |
---|
4509 | , m_intraConstraintFlag ( false ) |
---|
4510 | , m_onePictureOnlyConstraintFlag( false ) |
---|
4511 | , m_lowerBitRateConstraintFlag ( false ) |
---|
4512 | , m_max12bitConstraintFlag ( false ) |
---|
4513 | , m_max10bitConstraintFlag ( false ) |
---|
4514 | , m_max8bitConstraintFlag ( false ) |
---|
4515 | , m_max422chromaConstraintFlag ( false ) |
---|
4516 | , m_max420chromaConstraintFlag ( false ) |
---|
4517 | , m_maxMonochromeConstraintFlag ( false ) |
---|
4518 | , m_inbldFlag ( false ) |
---|
4519 | #endif |
---|
4520 | { |
---|
4521 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
4522 | } |
---|
4523 | |
---|
4524 | #if NH_MV |
---|
4525 | Bool ProfileTierLevel::getV2ConstraintsPresentFlag() const |
---|
4526 | { |
---|
4527 | return ( |
---|
4528 | getProfileIdc( ) == 4 || getProfileCompatibilityFlag( 4 ) || getProfileIdc( ) == 5 || getProfileCompatibilityFlag( 5 ) || |
---|
4529 | getProfileIdc( ) == 6 || getProfileCompatibilityFlag( 6 ) || getProfileIdc( ) == 7 || getProfileCompatibilityFlag( 7 ) |
---|
4530 | ); |
---|
4531 | } |
---|
4532 | |
---|
4533 | Bool ProfileTierLevel::getInbldPresentFlag() const |
---|
4534 | { |
---|
4535 | return ( |
---|
4536 | ( getProfileIdc() >= 1 && getProfileIdc() <= 5 ) || getProfileCompatibilityFlag( 1 ) || getProfileCompatibilityFlag( 2 ) || |
---|
4537 | getProfileCompatibilityFlag( 3 ) || getProfileCompatibilityFlag( 4 ) || getProfileCompatibilityFlag( 5 ) |
---|
4538 | ); |
---|
4539 | } |
---|
4540 | |
---|
4541 | Void ProfileTierLevel::copyV2ConstraintFlags(ProfileTierLevel* ptlRef) |
---|
4542 | { |
---|
4543 | setMax12bitConstraintFlag ( ptlRef->getMax12bitConstraintFlag ( ) ); |
---|
4544 | setMax10bitConstraintFlag ( ptlRef->getMax10bitConstraintFlag ( ) ); |
---|
4545 | setMax8bitConstraintFlag ( ptlRef->getMax8bitConstraintFlag ( ) ); |
---|
4546 | setMax422chromaConstraintFlag ( ptlRef->getMax422chromaConstraintFlag ( ) ); |
---|
4547 | setMax420chromaConstraintFlag ( ptlRef->getMax420chromaConstraintFlag ( ) ); |
---|
4548 | setMaxMonochromeConstraintFlag ( ptlRef->getMaxMonochromeConstraintFlag ( ) ); |
---|
4549 | setIntraConstraintFlag ( ptlRef->getIntraConstraintFlag ( ) ); |
---|
4550 | setOnePictureOnlyConstraintFlag ( ptlRef->getOnePictureOnlyConstraintFlag ( ) ); |
---|
4551 | setLowerBitRateConstraintFlag ( ptlRef->getLowerBitRateConstraintFlag ( ) ); |
---|
4552 | } |
---|
4553 | |
---|
4554 | Void ProfileTierLevel::copyProfile(ProfileTierLevel* ptlRef) |
---|
4555 | { |
---|
4556 | setProfileSpace ( ptlRef->getProfileSpace ( ) ); |
---|
4557 | setTierFlag ( ptlRef->getTierFlag ( ) ); |
---|
4558 | setProfileIdc ( ptlRef->getProfileIdc ( ) ); |
---|
4559 | for (Int j = 0; j < 32; j++) |
---|
4560 | { |
---|
4561 | setProfileCompatibilityFlag(j, ptlRef->getProfileCompatibilityFlag ( j ) ); |
---|
4562 | } |
---|
4563 | setProgressiveSourceFlag ( ptlRef->getProgressiveSourceFlag ( ) ); |
---|
4564 | setInterlacedSourceFlag ( ptlRef->getInterlacedSourceFlag ( ) ); |
---|
4565 | setNonPackedConstraintFlag ( ptlRef->getNonPackedConstraintFlag ( ) ); |
---|
4566 | setFrameOnlyConstraintFlag ( ptlRef->getFrameOnlyConstraintFlag ( ) ); |
---|
4567 | copyV2ConstraintFlags ( ptlRef ); |
---|
4568 | } |
---|
4569 | #endif |
---|
4570 | |
---|
4571 | TComPTL::TComPTL() |
---|
4572 | { |
---|
4573 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
4574 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
4575 | } |
---|
4576 | |
---|
4577 | Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> &newData) |
---|
4578 | { |
---|
4579 | if (!bChanged) |
---|
4580 | { |
---|
4581 | if ((pOldData==0 && pOldData!=0) || (pOldData!=0 && pOldData==0)) |
---|
4582 | { |
---|
4583 | bChanged=true; |
---|
4584 | } |
---|
4585 | else if (pOldData!=0 && pOldData!=0) |
---|
4586 | { |
---|
4587 | // compare the two |
---|
4588 | if (pOldData->size() != pOldData->size()) |
---|
4589 | { |
---|
4590 | bChanged=true; |
---|
4591 | } |
---|
4592 | else |
---|
4593 | { |
---|
4594 | const UChar *pNewDataArray=&(newData)[0]; |
---|
4595 | const UChar *pOldDataArray=&(*pOldData)[0]; |
---|
4596 | if (memcmp(pOldDataArray, pNewDataArray, pOldData->size())) |
---|
4597 | { |
---|
4598 | bChanged=true; |
---|
4599 | } |
---|
4600 | } |
---|
4601 | } |
---|
4602 | } |
---|
4603 | } |
---|
4604 | #if NH_MV |
---|
4605 | Void TComPTL::inferGeneralValues(Bool profilePresentFlag, Int k, TComPTL* refPTL) |
---|
4606 | { |
---|
4607 | ProfileTierLevel* refProfileTierLevel = NULL; |
---|
4608 | if ( k > 0 ) |
---|
4609 | { |
---|
4610 | assert( refPTL != NULL); |
---|
4611 | refProfileTierLevel = refPTL->getGeneralPTL(); |
---|
4612 | } |
---|
4613 | |
---|
4614 | ProfileTierLevel* curProfileTierLevel = getGeneralPTL( ); |
---|
4615 | |
---|
4616 | if( !profilePresentFlag ) |
---|
4617 | { |
---|
4618 | assert( k > 0 ); |
---|
4619 | assert( refProfileTierLevel != NULL ); |
---|
4620 | curProfileTierLevel->copyProfile( refProfileTierLevel); |
---|
4621 | } |
---|
4622 | else |
---|
4623 | { |
---|
4624 | if ( !curProfileTierLevel->getV2ConstraintsPresentFlag() ) |
---|
4625 | { |
---|
4626 | curProfileTierLevel->setMax12bitConstraintFlag ( false ); |
---|
4627 | curProfileTierLevel->setMax10bitConstraintFlag ( false ); |
---|
4628 | curProfileTierLevel->setMax8bitConstraintFlag ( false ); |
---|
4629 | curProfileTierLevel->setMax422chromaConstraintFlag ( false ); |
---|
4630 | curProfileTierLevel->setMax420chromaConstraintFlag ( false ); |
---|
4631 | curProfileTierLevel->setMaxMonochromeConstraintFlag ( false ); |
---|
4632 | curProfileTierLevel->setIntraConstraintFlag ( false ); |
---|
4633 | curProfileTierLevel->setOnePictureOnlyConstraintFlag ( false ); |
---|
4634 | curProfileTierLevel->setLowerBitRateConstraintFlag ( false ); |
---|
4635 | } |
---|
4636 | |
---|
4637 | if ( !curProfileTierLevel->getInbldPresentFlag() ) |
---|
4638 | { |
---|
4639 | curProfileTierLevel->setInbldFlag( false ); |
---|
4640 | } |
---|
4641 | } |
---|
4642 | } |
---|
4643 | |
---|
4644 | Void TComPTL::inferSubLayerValues(Int maxNumSubLayersMinus1, Int k, TComPTL* refPTL) |
---|
4645 | { |
---|
4646 | assert( k == 0 || refPTL != NULL ); |
---|
4647 | |
---|
4648 | for (Int i = maxNumSubLayersMinus1; i >= 0; i--) |
---|
4649 | { |
---|
4650 | ProfileTierLevel* refProfileTierLevel; |
---|
4651 | if ( k != 0 ) |
---|
4652 | { |
---|
4653 | refProfileTierLevel = refPTL->getSubLayerPTL( i ); |
---|
4654 | } |
---|
4655 | else |
---|
4656 | { |
---|
4657 | if ( i == maxNumSubLayersMinus1) |
---|
4658 | { |
---|
4659 | refProfileTierLevel = getGeneralPTL(); |
---|
4660 | } |
---|
4661 | else |
---|
4662 | { |
---|
4663 | refProfileTierLevel = getSubLayerPTL( i + 1 ); |
---|
4664 | } |
---|
4665 | } |
---|
4666 | |
---|
4667 | ProfileTierLevel* curProfileTierLevel = getSubLayerPTL( i ); |
---|
4668 | if( !getSubLayerLevelPresentFlag( i ) ) |
---|
4669 | { |
---|
4670 | curProfileTierLevel->setLevelIdc( refProfileTierLevel->getLevelIdc() ); |
---|
4671 | } |
---|
4672 | |
---|
4673 | if( !getSubLayerProfilePresentFlag( i ) ) |
---|
4674 | { |
---|
4675 | curProfileTierLevel->copyProfile( refProfileTierLevel); |
---|
4676 | } |
---|
4677 | else |
---|
4678 | { |
---|
4679 | if ( !curProfileTierLevel->getV2ConstraintsPresentFlag() ) |
---|
4680 | { |
---|
4681 | curProfileTierLevel->copyV2ConstraintFlags( refProfileTierLevel ); |
---|
4682 | } |
---|
4683 | |
---|
4684 | if ( !curProfileTierLevel->getInbldPresentFlag() ) |
---|
4685 | { |
---|
4686 | curProfileTierLevel->setInbldFlag( refProfileTierLevel->getInbldFlag() ); |
---|
4687 | } |
---|
4688 | } |
---|
4689 | } |
---|
4690 | } |
---|
4691 | |
---|
4692 | #endif |
---|
4693 | |
---|
4694 | //! \} |
---|
4695 | |
---|
4696 | #if NH_MV |
---|
4697 | Void TComVPSVUI::init( Int numLayerSets, Int maxNumSubLayers, Int maxNumLayers ) |
---|
4698 | { |
---|
4699 | m_crossLayerIrapAlignedFlag = true; |
---|
4700 | m_allLayersIdrAlignedFlag = false; |
---|
4701 | m_bitRatePresentVpsFlag = false; |
---|
4702 | m_picRatePresentVpsFlag = false; |
---|
4703 | |
---|
4704 | m_bitRatePresentFlag .resize(numLayerSets); |
---|
4705 | m_picRatePresentFlag .resize(numLayerSets); |
---|
4706 | m_avgBitRate .resize(numLayerSets); |
---|
4707 | m_maxBitRate .resize(numLayerSets); |
---|
4708 | m_constantPicRateIdc .resize(numLayerSets); |
---|
4709 | m_avgPicRate .resize(numLayerSets); |
---|
4710 | |
---|
4711 | for ( Int i = 0; i < numLayerSets; i++) |
---|
4712 | { |
---|
4713 | m_bitRatePresentFlag [i].resize( maxNumSubLayers); |
---|
4714 | m_picRatePresentFlag [i].resize( maxNumSubLayers); |
---|
4715 | m_avgBitRate [i].resize( maxNumSubLayers); |
---|
4716 | m_maxBitRate [i].resize( maxNumSubLayers); |
---|
4717 | m_constantPicRateIdc [i].resize( maxNumSubLayers); |
---|
4718 | m_avgPicRate [i].resize( maxNumSubLayers); |
---|
4719 | for ( Int j = 0; j < maxNumSubLayers; j++) |
---|
4720 | { |
---|
4721 | m_bitRatePresentFlag [i][j] = false; |
---|
4722 | m_picRatePresentFlag [i][j] = false; |
---|
4723 | m_avgBitRate [i][j] = -1; |
---|
4724 | m_maxBitRate [i][j] = -1; |
---|
4725 | m_constantPicRateIdc [i][j] = -1; |
---|
4726 | m_avgPicRate [i][j] = -1; |
---|
4727 | } |
---|
4728 | } |
---|
4729 | |
---|
4730 | m_ilpRestrictedRefLayersFlag = false; |
---|
4731 | |
---|
4732 | m_tileBoundariesAlignedFlag .resize( maxNumLayers ); |
---|
4733 | m_minSpatialSegmentOffsetPlus1 .resize( maxNumLayers ); |
---|
4734 | m_ctuBasedOffsetEnabledFlag .resize( maxNumLayers ); |
---|
4735 | m_minHorizontalCtuOffsetPlus1 .resize( maxNumLayers ); |
---|
4736 | m_baseLayerParameterSetCompatibilityFlag.resize( maxNumLayers ); |
---|
4737 | |
---|
4738 | for ( Int i = 0; i < maxNumLayers; i++) |
---|
4739 | { |
---|
4740 | m_tileBoundariesAlignedFlag [i].resize( maxNumLayers ); |
---|
4741 | m_minSpatialSegmentOffsetPlus1[i].resize( maxNumLayers ); |
---|
4742 | m_ctuBasedOffsetEnabledFlag [i].resize( maxNumLayers ); |
---|
4743 | m_minHorizontalCtuOffsetPlus1 [i].resize( maxNumLayers ); |
---|
4744 | for ( Int j = 0; j < maxNumLayers; j++) |
---|
4745 | { |
---|
4746 | m_tileBoundariesAlignedFlag [i][j] = false; |
---|
4747 | m_minSpatialSegmentOffsetPlus1[i][j] = 0; |
---|
4748 | m_ctuBasedOffsetEnabledFlag [i][j] = false; |
---|
4749 | m_minHorizontalCtuOffsetPlus1 [i][j] = -1; |
---|
4750 | } |
---|
4751 | m_baseLayerParameterSetCompatibilityFlag[i] = false; |
---|
4752 | } |
---|
4753 | m_vpsVuiBspHrdPresentFlag = false; |
---|
4754 | } |
---|
4755 | |
---|
4756 | Void TComRepFormat::inferChromaAndBitDepth( const TComRepFormat* prevRepFormat ) |
---|
4757 | { |
---|
4758 | setChromaAndBitDepthVpsPresentFlag( prevRepFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
4759 | setSeparateColourPlaneVpsFlag ( prevRepFormat->getSeparateColourPlaneVpsFlag () ); |
---|
4760 | setBitDepthVpsLumaMinus8 ( prevRepFormat->getBitDepthVpsLumaMinus8 () ); |
---|
4761 | setBitDepthVpsChromaMinus8 ( prevRepFormat->getBitDepthVpsChromaMinus8 () ); |
---|
4762 | } |
---|
4763 | |
---|
4764 | Void TComRepFormat::checkInferChromaAndBitDepth( const TComRepFormat* prevRepFormat ) const |
---|
4765 | { |
---|
4766 | assert( getChromaAndBitDepthVpsPresentFlag() == prevRepFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
4767 | assert( getSeparateColourPlaneVpsFlag () == prevRepFormat->getSeparateColourPlaneVpsFlag () ); |
---|
4768 | assert( getBitDepthVpsLumaMinus8 () == prevRepFormat->getBitDepthVpsLumaMinus8 () ); |
---|
4769 | assert( getBitDepthVpsChromaMinus8 () == prevRepFormat->getBitDepthVpsChromaMinus8 () ); |
---|
4770 | } |
---|
4771 | |
---|
4772 | Int TComVpsVuiBspHrdParameters::getBspHrdIdxLen( const TComVPS* vps) const |
---|
4773 | { |
---|
4774 | return gCeilLog2( vps->getNumHrdParameters() + getVpsNumAddHrdParams() ); |
---|
4775 | } |
---|
4776 | |
---|
4777 | Void TComVpsVuiBspHrdParameters::createAfterVpsNumAddHrdParams( const TComVPS* vps ) |
---|
4778 | { |
---|
4779 | m_offsetHrdParamIdx = vps->getNumHrdParameters(); |
---|
4780 | m_numHrdParam = vps->getNumHrdParameters() + getVpsNumAddHrdParams() - m_offsetHrdParamIdx; |
---|
4781 | m_numOls = vps->getNumOutputLayerSets(); |
---|
4782 | |
---|
4783 | m_cprmsAddPresentFlag .resize( m_numHrdParam ); |
---|
4784 | m_numSubLayerHrdMinus1.resize( m_numHrdParam ); |
---|
4785 | m_hrdParameters .resize( m_numHrdParam ); |
---|
4786 | |
---|
4787 | m_numSignalledPartitioningSchemes .resize( m_numOls ); |
---|
4788 | m_numPartitionsInSchemeMinus1 .resize( m_numOls ); |
---|
4789 | m_numBspSchedulesMinus1 .resize( m_numOls ); |
---|
4790 | m_bspHrdIdx .resize( m_numOls ); |
---|
4791 | m_bspSchedIdx .resize( m_numOls ); |
---|
4792 | } |
---|
4793 | |
---|
4794 | Void TComVpsVuiBspHrdParameters::createAfterNumSignalledPartitioningSchemes( const TComVPS* vps, Int h ) |
---|
4795 | { |
---|
4796 | m_numPartitionsInSchemeMinus1 [h].resize( getNumSignalledPartitioningSchemes(h) ); |
---|
4797 | m_layerIncludedInPartitionFlag[h].resize( getNumSignalledPartitioningSchemes(h) ); |
---|
4798 | |
---|
4799 | m_numBspSchedulesMinus1 [h].resize( getNumSignalledPartitioningSchemes(h) + 1 ); |
---|
4800 | for (Int i = 0; i < getNumSignalledPartitioningSchemes(h) + 1; i++) |
---|
4801 | { |
---|
4802 | Int tMax = vps->getMaxSubLayersInLayerSetMinus1( m_vps->olsIdxToLsIdx(h) ) + 1; |
---|
4803 | m_numBspSchedulesMinus1[h][i].resize( tMax ); |
---|
4804 | m_bspHrdIdx [h][i].resize( tMax ); |
---|
4805 | m_bspSchedIdx [h][i].resize( tMax ); |
---|
4806 | } |
---|
4807 | } |
---|
4808 | |
---|
4809 | Void TComVpsVuiBspHrdParameters::createAfterNumPartitionsInSchemeMinus1( const TComVPS* vps, Int h, Int j ) |
---|
4810 | { |
---|
4811 | m_layerIncludedInPartitionFlag[h][j].resize( getNumPartitionsInSchemeMinus1(h,j)); |
---|
4812 | for( Int k = 0; k < getNumPartitionsInSchemeMinus1(h,j); k++ ) |
---|
4813 | { |
---|
4814 | m_layerIncludedInPartitionFlag[h][j][k].resize( m_vps->getNumLayersInIdList( vps->olsIdxToLsIdx(h))); |
---|
4815 | } |
---|
4816 | } |
---|
4817 | |
---|
4818 | Void TComVpsVuiBspHrdParameters::createAfterNumBspSchedulesMinus1( const TComVPS* vps, Int h, Int i, Int t ) |
---|
4819 | { |
---|
4820 | m_bspSchedIdx[h][i][t].resize( getNumBspSchedulesMinus1( h, i, t ) + 1 ); |
---|
4821 | m_bspHrdIdx [h][i][t].resize( getNumBspSchedulesMinus1( h, i, t ) + 1 ); |
---|
4822 | for( Int j = 0; j < getNumBspSchedulesMinus1( h, i, t ) + 1; j++ ) |
---|
4823 | { |
---|
4824 | m_bspSchedIdx[h][i][t][j].resize( getNumPartitionsInSchemeMinus1( h, i ) ); |
---|
4825 | m_bspHrdIdx [h][i][t][j].resize( getNumPartitionsInSchemeMinus1( h, i ) ); |
---|
4826 | } |
---|
4827 | } |
---|
4828 | |
---|
4829 | |
---|
4830 | Void TComVUI::inferVideoSignalInfo( const TComVPS* vps, Int layerIdCurr ) |
---|
4831 | { |
---|
4832 | if ( layerIdCurr == 0 || !vps->getVpsVuiPresentFlag() ) |
---|
4833 | { |
---|
4834 | return; |
---|
4835 | } |
---|
4836 | |
---|
4837 | const TComVPSVUI* vpsVui = vps->getVPSVUI(); |
---|
4838 | assert( vpsVui != NULL ); |
---|
4839 | |
---|
4840 | const TComVideoSignalInfo* videoSignalInfo = vpsVui->getVideoSignalInfo( vpsVui->getVpsVideoSignalInfoIdx( vps->getLayerIdInVps( layerIdCurr ) ) ); |
---|
4841 | assert( videoSignalInfo != NULL ); |
---|
4842 | |
---|
4843 | setVideoFormat ( videoSignalInfo->getVideoVpsFormat () ); |
---|
4844 | setVideoFullRangeFlag ( videoSignalInfo->getVideoFullRangeVpsFlag () ); |
---|
4845 | setColourPrimaries ( videoSignalInfo->getColourPrimariesVps () ); |
---|
4846 | setTransferCharacteristics( videoSignalInfo->getTransferCharacteristicsVps() ); |
---|
4847 | setMatrixCoefficients ( videoSignalInfo->getMatrixCoeffsVps () ); |
---|
4848 | } |
---|
4849 | |
---|
4850 | Void TComDpbSize::init( Int numOutputLayerSets, Int maxNumLayerIds, Int maxNumSubLayers ) |
---|
4851 | { |
---|
4852 | m_subLayerFlagInfoPresentFlag.resize( numOutputLayerSets ); |
---|
4853 | m_subLayerDpbInfoPresentFlag .resize( numOutputLayerSets ); |
---|
4854 | m_maxVpsDecPicBufferingMinus1.resize( numOutputLayerSets ); |
---|
4855 | m_maxVpsNumReorderPics .resize( numOutputLayerSets ); |
---|
4856 | m_maxVpsLatencyIncreasePlus1 .resize( numOutputLayerSets ); |
---|
4857 | |
---|
4858 | for (Int i = 0; i < numOutputLayerSets; i++ ) |
---|
4859 | { |
---|
4860 | m_subLayerFlagInfoPresentFlag[i] = false; |
---|
4861 | |
---|
4862 | m_subLayerDpbInfoPresentFlag [i].resize( maxNumSubLayers ); |
---|
4863 | m_maxVpsDecPicBufferingMinus1[i].resize( maxNumLayerIds ); |
---|
4864 | m_maxVpsNumReorderPics [i].resize( maxNumSubLayers ); |
---|
4865 | m_maxVpsLatencyIncreasePlus1 [i].resize( maxNumSubLayers ); |
---|
4866 | |
---|
4867 | for (Int j = 0; j < maxNumSubLayers; j++ ) |
---|
4868 | { |
---|
4869 | m_subLayerDpbInfoPresentFlag [i][j] = ( j == 0) ; |
---|
4870 | m_maxVpsNumReorderPics [i][j] = 0; |
---|
4871 | m_maxVpsLatencyIncreasePlus1 [i][j] = 0; |
---|
4872 | } |
---|
4873 | |
---|
4874 | for (Int k = 0; k < maxNumLayerIds; k++ ) |
---|
4875 | { |
---|
4876 | m_maxVpsDecPicBufferingMinus1[i][k].resize( maxNumSubLayers ); |
---|
4877 | for (Int j = 0; j < maxNumSubLayers; j++ ) |
---|
4878 | { |
---|
4879 | m_maxVpsDecPicBufferingMinus1[i][k][j] = MIN_INT; |
---|
4880 | } |
---|
4881 | } |
---|
4882 | } |
---|
4883 | } |
---|
4884 | |
---|
4885 | Void Window::scaleOffsets( Int scal ) |
---|
4886 | { |
---|
4887 | if (! m_scaledFlag ) |
---|
4888 | { |
---|
4889 | m_scaledFlag = true; |
---|
4890 | m_winLeftOffset *= scal; |
---|
4891 | m_winRightOffset *= scal; |
---|
4892 | m_winTopOffset *= scal; |
---|
4893 | m_winBottomOffset *= scal; |
---|
4894 | } |
---|
4895 | } |
---|
4896 | #endif |
---|