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_pcRPS ( 0 ) |
---|
59 | , m_LocalRPS ( ) |
---|
60 | , m_iBDidx ( 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 H_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 H_3D |
---|
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 H_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 H_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_pcRPS->getNumberOfNegativePictures(); i++) |
---|
468 | { |
---|
469 | if(m_pcRPS->getUsed(i)) |
---|
470 | { |
---|
471 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->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_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
481 | { |
---|
482 | if(m_pcRPS->getUsed(i)) |
---|
483 | { |
---|
484 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->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_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
494 | { |
---|
495 | if(m_pcRPS->getUsed(i)) |
---|
496 | { |
---|
497 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->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_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
506 | } |
---|
507 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->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_pcRPS->getNumberOfNegativePictures(); i++) |
---|
623 | { |
---|
624 | if(m_pcRPS->getUsed(i)) |
---|
625 | { |
---|
626 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->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_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
639 | { |
---|
640 | if(m_pcRPS->getUsed(i)) |
---|
641 | { |
---|
642 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->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_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
655 | { |
---|
656 | if(m_pcRPS->getUsed(i)) |
---|
657 | { |
---|
658 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->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_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
670 | } |
---|
671 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->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_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++) |
---|
801 | { |
---|
802 | if(m_pcRPS->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 H_3D |
---|
827 | #if H_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_pcRPS = pSrc->m_pcRPS; |
---|
1100 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
1101 | |
---|
1102 | m_pcPic = pSrc->m_pcPic; |
---|
1103 | |
---|
1104 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
1105 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
1106 | |
---|
1107 | setLambdas(pSrc->getLambdas()); |
---|
1108 | |
---|
1109 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
1110 | { |
---|
1111 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1112 | { |
---|
1113 | for (k =0; k < MAX_NUM_REF; k++) |
---|
1114 | { |
---|
1115 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
1116 | } |
---|
1117 | } |
---|
1118 | } |
---|
1119 | |
---|
1120 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
1121 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
1122 | |
---|
1123 | m_sliceMode = pSrc->m_sliceMode; |
---|
1124 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
1125 | m_sliceCurStartCtuTsAddr = pSrc->m_sliceCurStartCtuTsAddr; |
---|
1126 | m_sliceCurEndCtuTsAddr = pSrc->m_sliceCurEndCtuTsAddr; |
---|
1127 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
1128 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
1129 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
1130 | m_sliceSegmentCurStartCtuTsAddr = pSrc->m_sliceSegmentCurStartCtuTsAddr; |
---|
1131 | m_sliceSegmentCurEndCtuTsAddr = pSrc->m_sliceSegmentCurEndCtuTsAddr; |
---|
1132 | m_nextSlice = pSrc->m_nextSlice; |
---|
1133 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
1134 | |
---|
1135 | for ( UInt e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
1136 | { |
---|
1137 | for ( UInt n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
1138 | { |
---|
1139 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(WPScalingParam)*MAX_NUM_COMPONENT ); |
---|
1140 | } |
---|
1141 | } |
---|
1142 | |
---|
1143 | for( UInt ch = 0 ; ch < MAX_NUM_CHANNEL_TYPE; ch++) |
---|
1144 | { |
---|
1145 | m_saoEnabledFlag[ch] = pSrc->m_saoEnabledFlag[ch]; |
---|
1146 | } |
---|
1147 | |
---|
1148 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
1149 | |
---|
1150 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
1151 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
1152 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
1153 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
1154 | m_encCABACTableIdx = pSrc->m_encCABACTableIdx; |
---|
1155 | |
---|
1156 | #if NH_MV |
---|
1157 | // Additional slice header syntax elements |
---|
1158 | #if !H_MV_HLS7_GEN |
---|
1159 | m_pocResetFlag = pSrc->m_pocResetFlag; |
---|
1160 | #endif |
---|
1161 | m_discardableFlag = pSrc->m_discardableFlag; |
---|
1162 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
1163 | m_numInterLayerRefPicsMinus1 = pSrc->m_numInterLayerRefPicsMinus1; |
---|
1164 | |
---|
1165 | for (Int layer = 0; layer < MAX_NUM_LAYERS; layer++ ) |
---|
1166 | { |
---|
1167 | m_interLayerPredLayerIdc[ layer ] = pSrc->m_interLayerPredLayerIdc[ layer ]; |
---|
1168 | } |
---|
1169 | #endif |
---|
1170 | #if H_3D |
---|
1171 | m_bApplyDIS = pSrc->m_bApplyDIS; |
---|
1172 | #endif |
---|
1173 | #if H_3D_IC |
---|
1174 | m_bApplyIC = pSrc->m_bApplyIC; |
---|
1175 | m_icSkipParseFlag = pSrc->m_icSkipParseFlag; |
---|
1176 | #endif |
---|
1177 | |
---|
1178 | } |
---|
1179 | |
---|
1180 | |
---|
1181 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
1182 | * \param uiTLayer Temporal layer ID of the current slice |
---|
1183 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
1184 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
1185 | * temporal_layer_switching_point_flag is set accordingly. |
---|
1186 | */ |
---|
1187 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
1188 | { |
---|
1189 | m_uiTLayer = uiTLayer; |
---|
1190 | } |
---|
1191 | |
---|
1192 | /** Function for checking if this is a switching-point |
---|
1193 | */ |
---|
1194 | Bool TComSlice::isTemporalLayerSwitchingPoint(TComList<TComPic*>& rcListPic) |
---|
1195 | { |
---|
1196 | TComPic* rpcPic; |
---|
1197 | // loop through all pictures in the reference picture buffer |
---|
1198 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1199 | while ( iterPic != rcListPic.end()) |
---|
1200 | { |
---|
1201 | rpcPic = *(iterPic++); |
---|
1202 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
1203 | { |
---|
1204 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1205 | { |
---|
1206 | return false; |
---|
1207 | } |
---|
1208 | } |
---|
1209 | } |
---|
1210 | return true; |
---|
1211 | } |
---|
1212 | |
---|
1213 | /** Function for checking if this is a STSA candidate |
---|
1214 | */ |
---|
1215 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate(TComList<TComPic*>& rcListPic) |
---|
1216 | { |
---|
1217 | TComPic* rpcPic; |
---|
1218 | |
---|
1219 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1220 | while ( iterPic != rcListPic.end()) |
---|
1221 | { |
---|
1222 | rpcPic = *(iterPic++); |
---|
1223 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
1224 | { |
---|
1225 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1226 | { |
---|
1227 | return false; |
---|
1228 | } |
---|
1229 | } |
---|
1230 | } |
---|
1231 | return true; |
---|
1232 | } |
---|
1233 | |
---|
1234 | |
---|
1235 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) |
---|
1236 | { |
---|
1237 | TComPic* rpcPic; |
---|
1238 | |
---|
1239 | Int nalUnitType = this->getNalUnitType(); |
---|
1240 | |
---|
1241 | // When a picture is a leading picture, it shall be a RADL or RASL picture. |
---|
1242 | if(this->getAssociatedIRAPPOC() > this->getPOC()) |
---|
1243 | { |
---|
1244 | // Do not check IRAP pictures since they may get a POC lower than their associated IRAP |
---|
1245 | if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1246 | nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) |
---|
1247 | { |
---|
1248 | assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1249 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1250 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1251 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1252 | } |
---|
1253 | } |
---|
1254 | |
---|
1255 | // When a picture is a trailing picture, it shall not be a RADL or RASL picture. |
---|
1256 | if(this->getAssociatedIRAPPOC() < this->getPOC()) |
---|
1257 | { |
---|
1258 | assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && |
---|
1259 | nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && |
---|
1260 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && |
---|
1261 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1262 | } |
---|
1263 | |
---|
1264 | // No RASL pictures shall be present in the bitstream that are associated |
---|
1265 | // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. |
---|
1266 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1267 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1268 | { |
---|
1269 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && |
---|
1270 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); |
---|
1271 | } |
---|
1272 | |
---|
1273 | // No RASL pictures shall be present in the bitstream that are associated with |
---|
1274 | // an IDR picture. |
---|
1275 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1276 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1277 | { |
---|
1278 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && |
---|
1279 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
1280 | } |
---|
1281 | |
---|
1282 | // No RADL pictures shall be present in the bitstream that are associated with |
---|
1283 | // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated |
---|
1284 | // with an IDR picture having nal_unit_type equal to IDR_N_LP. |
---|
1285 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1286 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1287 | { |
---|
1288 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && |
---|
1289 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); |
---|
1290 | } |
---|
1291 | |
---|
1292 | // loop through all pictures in the reference picture buffer |
---|
1293 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1294 | while ( iterPic != rcListPic.end()) |
---|
1295 | { |
---|
1296 | rpcPic = *(iterPic++); |
---|
1297 | if(!rpcPic->getReconMark()) |
---|
1298 | { |
---|
1299 | continue; |
---|
1300 | } |
---|
1301 | if (rpcPic->getPOC() == this->getPOC()) |
---|
1302 | { |
---|
1303 | continue; |
---|
1304 | } |
---|
1305 | |
---|
1306 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1307 | // in decoding order shall precede the IRAP picture in output order. |
---|
1308 | // (Note that any picture following in output order would be present in the DPB) |
---|
1309 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1 && !this->getNoOutputPriorPicsFlag()) |
---|
1310 | { |
---|
1311 | if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1312 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1313 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1314 | nalUnitType == NAL_UNIT_CODED_SLICE_CRA || |
---|
1315 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1316 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
1317 | { |
---|
1318 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1319 | } |
---|
1320 | } |
---|
1321 | |
---|
1322 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1323 | // in decoding order shall precede any RADL picture associated with the IRAP |
---|
1324 | // picture in output order. |
---|
1325 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
1326 | { |
---|
1327 | if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1328 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) |
---|
1329 | { |
---|
1330 | // rpcPic precedes the IRAP in decoding order |
---|
1331 | if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1332 | { |
---|
1333 | // rpcPic must not be the IRAP picture |
---|
1334 | if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) |
---|
1335 | { |
---|
1336 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1337 | } |
---|
1338 | } |
---|
1339 | } |
---|
1340 | } |
---|
1341 | |
---|
1342 | // When a picture is a leading picture, it shall precede, in decoding order, |
---|
1343 | // all trailing pictures that are associated with the same IRAP picture. |
---|
1344 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1345 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1346 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1347 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1348 | { |
---|
1349 | if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) |
---|
1350 | { |
---|
1351 | // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB |
---|
1352 | // rpcPic would violate the constraint if it was a trailing picture |
---|
1353 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
1354 | } |
---|
1355 | } |
---|
1356 | |
---|
1357 | // Any RASL picture associated with a CRA or BLA picture shall precede any |
---|
1358 | // RADL picture associated with the CRA or BLA picture in output order |
---|
1359 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1360 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1361 | { |
---|
1362 | if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1363 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1364 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1365 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && |
---|
1366 | this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1367 | { |
---|
1368 | if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1369 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1370 | { |
---|
1371 | assert(rpcPic->getPOC() > this->getPOC()); |
---|
1372 | } |
---|
1373 | } |
---|
1374 | } |
---|
1375 | |
---|
1376 | // Any RASL picture associated with a CRA picture shall follow, in output |
---|
1377 | // order, any IRAP picture that precedes the CRA picture in decoding order. |
---|
1378 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1379 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1380 | { |
---|
1381 | if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
1382 | { |
---|
1383 | if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && |
---|
1384 | (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1385 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1386 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1387 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1388 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || |
---|
1389 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) |
---|
1390 | { |
---|
1391 | assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); |
---|
1392 | } |
---|
1393 | } |
---|
1394 | } |
---|
1395 | } |
---|
1396 | } |
---|
1397 | |
---|
1398 | |
---|
1399 | |
---|
1400 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1401 | */ |
---|
1402 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet) |
---|
1403 | { |
---|
1404 | TComPic* rpcPic; |
---|
1405 | Int i, isReference; |
---|
1406 | |
---|
1407 | checkLeadingPictureRestrictions(rcListPic); |
---|
1408 | |
---|
1409 | // loop through all pictures in the reference picture buffer |
---|
1410 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1411 | while ( iterPic != rcListPic.end()) |
---|
1412 | { |
---|
1413 | rpcPic = *(iterPic++); |
---|
1414 | |
---|
1415 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
1416 | { |
---|
1417 | continue; |
---|
1418 | } |
---|
1419 | |
---|
1420 | isReference = 0; |
---|
1421 | // loop through all pictures in the Reference Picture Set |
---|
1422 | // to see if the picture should be kept as reference picture |
---|
1423 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
1424 | { |
---|
1425 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
1426 | { |
---|
1427 | isReference = 1; |
---|
1428 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1429 | rpcPic->setIsLongTerm(0); |
---|
1430 | } |
---|
1431 | } |
---|
1432 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1433 | { |
---|
1434 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1435 | { |
---|
1436 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
1437 | { |
---|
1438 | isReference = 1; |
---|
1439 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1440 | } |
---|
1441 | } |
---|
1442 | else |
---|
1443 | { |
---|
1444 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1445 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1446 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1447 | if(rpcPic->getIsLongTerm() && curPoc == refPoc) |
---|
1448 | { |
---|
1449 | isReference = 1; |
---|
1450 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1451 | } |
---|
1452 | } |
---|
1453 | |
---|
1454 | } |
---|
1455 | #if NH_MV |
---|
1456 | if( isReference ) // Current picture is in the temporal RPS |
---|
1457 | { |
---|
1458 | assert( rpcPic->getSlice(0)->getDiscardableFlag() == 0 ); // Temporal RPS shall not contain picture with discardable_flag equal to 1 |
---|
1459 | } |
---|
1460 | #endif |
---|
1461 | // mark the picture as "unused for reference" if it is not in |
---|
1462 | // the Reference Picture Set |
---|
1463 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
1464 | { |
---|
1465 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
1466 | rpcPic->setUsedByCurr(0); |
---|
1467 | rpcPic->setIsLongTerm(0); |
---|
1468 | } |
---|
1469 | //check that pictures of higher temporal layers are not used |
---|
1470 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
1471 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
1472 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
1473 | { |
---|
1474 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
1475 | } |
---|
1476 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
1477 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
1478 | { |
---|
1479 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
1480 | } |
---|
1481 | } |
---|
1482 | } |
---|
1483 | |
---|
1484 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1485 | */ |
---|
1486 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1487 | { |
---|
1488 | Int atLeastOneUnabledByRecoveryPoint = 0; |
---|
1489 | Int atLeastOneFlushedByPreviousIDR = 0; |
---|
1490 | TComPic* rpcPic; |
---|
1491 | Int i, isAvailable; |
---|
1492 | Int atLeastOneLost = 0; |
---|
1493 | Int atLeastOneRemoved = 0; |
---|
1494 | Int iPocLost = 0; |
---|
1495 | |
---|
1496 | // loop through all long-term pictures in the Reference Picture Set |
---|
1497 | // to see if the picture should be kept as reference picture |
---|
1498 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1499 | { |
---|
1500 | isAvailable = 0; |
---|
1501 | // loop through all pictures in the reference picture buffer |
---|
1502 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1503 | while ( iterPic != rcListPic.end()) |
---|
1504 | { |
---|
1505 | rpcPic = *(iterPic++); |
---|
1506 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1507 | { |
---|
1508 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1509 | { |
---|
1510 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1511 | { |
---|
1512 | isAvailable = 0; |
---|
1513 | } |
---|
1514 | else |
---|
1515 | { |
---|
1516 | isAvailable = 1; |
---|
1517 | } |
---|
1518 | } |
---|
1519 | } |
---|
1520 | else |
---|
1521 | { |
---|
1522 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1523 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1524 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1525 | if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) |
---|
1526 | { |
---|
1527 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1528 | { |
---|
1529 | isAvailable = 0; |
---|
1530 | } |
---|
1531 | else |
---|
1532 | { |
---|
1533 | isAvailable = 1; |
---|
1534 | } |
---|
1535 | } |
---|
1536 | } |
---|
1537 | } |
---|
1538 | // if there was no such long-term check the short terms |
---|
1539 | if(!isAvailable) |
---|
1540 | { |
---|
1541 | iterPic = rcListPic.begin(); |
---|
1542 | while ( iterPic != rcListPic.end()) |
---|
1543 | { |
---|
1544 | rpcPic = *(iterPic++); |
---|
1545 | |
---|
1546 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1547 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
1548 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
1549 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
1550 | { |
---|
1551 | curPoc = curPoc & (pocCycle - 1); |
---|
1552 | refPoc = refPoc & (pocCycle - 1); |
---|
1553 | } |
---|
1554 | |
---|
1555 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
1556 | { |
---|
1557 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1558 | { |
---|
1559 | isAvailable = 0; |
---|
1560 | } |
---|
1561 | else |
---|
1562 | { |
---|
1563 | isAvailable = 1; |
---|
1564 | rpcPic->setIsLongTerm(1); |
---|
1565 | break; |
---|
1566 | } |
---|
1567 | } |
---|
1568 | } |
---|
1569 | } |
---|
1570 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1571 | // but not available as reference picture |
---|
1572 | if(isAvailable == 0) |
---|
1573 | { |
---|
1574 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1575 | { |
---|
1576 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1577 | { |
---|
1578 | if(printErrors) |
---|
1579 | { |
---|
1580 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1581 | } |
---|
1582 | atLeastOneRemoved = 1; |
---|
1583 | } |
---|
1584 | else |
---|
1585 | { |
---|
1586 | if(printErrors) |
---|
1587 | { |
---|
1588 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1589 | } |
---|
1590 | atLeastOneLost = 1; |
---|
1591 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1592 | } |
---|
1593 | } |
---|
1594 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1595 | { |
---|
1596 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1597 | } |
---|
1598 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1599 | { |
---|
1600 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1601 | } |
---|
1602 | } |
---|
1603 | } |
---|
1604 | // loop through all short-term pictures in the Reference Picture Set |
---|
1605 | // to see if the picture should be kept as reference picture |
---|
1606 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
1607 | { |
---|
1608 | isAvailable = 0; |
---|
1609 | // loop through all pictures in the reference picture buffer |
---|
1610 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1611 | while ( iterPic != rcListPic.end()) |
---|
1612 | { |
---|
1613 | rpcPic = *(iterPic++); |
---|
1614 | |
---|
1615 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1616 | { |
---|
1617 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1618 | { |
---|
1619 | isAvailable = 0; |
---|
1620 | } |
---|
1621 | else |
---|
1622 | { |
---|
1623 | isAvailable = 1; |
---|
1624 | } |
---|
1625 | } |
---|
1626 | } |
---|
1627 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1628 | // but not available as reference picture |
---|
1629 | if(isAvailable == 0) |
---|
1630 | { |
---|
1631 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1632 | { |
---|
1633 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1634 | { |
---|
1635 | if(printErrors) |
---|
1636 | { |
---|
1637 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1638 | } |
---|
1639 | atLeastOneRemoved = 1; |
---|
1640 | } |
---|
1641 | else |
---|
1642 | { |
---|
1643 | if(printErrors) |
---|
1644 | { |
---|
1645 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1646 | } |
---|
1647 | atLeastOneLost = 1; |
---|
1648 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1649 | } |
---|
1650 | } |
---|
1651 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1652 | { |
---|
1653 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1654 | } |
---|
1655 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1656 | { |
---|
1657 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1658 | } |
---|
1659 | } |
---|
1660 | } |
---|
1661 | |
---|
1662 | if(atLeastOneUnabledByRecoveryPoint || atLeastOneFlushedByPreviousIDR) |
---|
1663 | { |
---|
1664 | return -1; |
---|
1665 | } |
---|
1666 | if(atLeastOneLost) |
---|
1667 | { |
---|
1668 | return iPocLost+1; |
---|
1669 | } |
---|
1670 | if(atLeastOneRemoved) |
---|
1671 | { |
---|
1672 | return -2; |
---|
1673 | } |
---|
1674 | else |
---|
1675 | { |
---|
1676 | return 0; |
---|
1677 | } |
---|
1678 | } |
---|
1679 | |
---|
1680 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
1681 | */ |
---|
1682 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint, const Bool bEfficientFieldIRAPEnabled) |
---|
1683 | { |
---|
1684 | TComPic* rpcPic; |
---|
1685 | Int i, j; |
---|
1686 | Int k = 0; |
---|
1687 | Int nrOfNegativePictures = 0; |
---|
1688 | Int nrOfPositivePictures = 0; |
---|
1689 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
1690 | Bool irapIsInRPS = false; // Used when bEfficientFieldIRAPEnabled==true |
---|
1691 | |
---|
1692 | // loop through all pictures in the Reference Picture Set |
---|
1693 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1694 | { |
---|
1695 | j = 0; |
---|
1696 | // loop through all pictures in the reference picture buffer |
---|
1697 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1698 | while ( iterPic != rcListPic.end()) |
---|
1699 | { |
---|
1700 | j++; |
---|
1701 | rpcPic = *(iterPic++); |
---|
1702 | |
---|
1703 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1704 | { |
---|
1705 | // This picture exists as a reference picture |
---|
1706 | // and should be added to the explicit Reference Picture Set |
---|
1707 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
1708 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); |
---|
1709 | if (bEfficientFieldIRAPEnabled) |
---|
1710 | { |
---|
1711 | pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) ); |
---|
1712 | } |
---|
1713 | |
---|
1714 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
1715 | { |
---|
1716 | nrOfNegativePictures++; |
---|
1717 | } |
---|
1718 | else |
---|
1719 | { |
---|
1720 | if(bEfficientFieldIRAPEnabled && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
1721 | { |
---|
1722 | irapIsInRPS = true; |
---|
1723 | } |
---|
1724 | nrOfPositivePictures++; |
---|
1725 | } |
---|
1726 | k++; |
---|
1727 | } |
---|
1728 | } |
---|
1729 | } |
---|
1730 | |
---|
1731 | Bool useNewRPS = false; |
---|
1732 | // if current picture is complimentary field associated to IRAP, add the IRAP to its RPS. |
---|
1733 | if(bEfficientFieldIRAPEnabled && m_pcPic->isField() && !irapIsInRPS) |
---|
1734 | { |
---|
1735 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1736 | while ( iterPic != rcListPic.end()) |
---|
1737 | { |
---|
1738 | rpcPic = *(iterPic++); |
---|
1739 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
1740 | { |
---|
1741 | pcRPS->setDeltaPOC(k, 1); |
---|
1742 | pcRPS->setUsed(k, true); |
---|
1743 | nrOfPositivePictures++; |
---|
1744 | k ++; |
---|
1745 | useNewRPS = true; |
---|
1746 | } |
---|
1747 | } |
---|
1748 | } |
---|
1749 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
1750 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
1751 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
1752 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
1753 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
1754 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
1755 | if (!pReferencePictureSet->getInterRPSPrediction() || useNewRPS ) |
---|
1756 | { |
---|
1757 | pcRPS->setInterRPSPrediction(false); |
---|
1758 | pcRPS->setNumRefIdc(0); |
---|
1759 | } |
---|
1760 | else |
---|
1761 | { |
---|
1762 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
1763 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
1764 | const TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
1765 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
1766 | Int iNewIdc=0; |
---|
1767 | for(i=0; i<= iRefPics; i++) |
---|
1768 | { |
---|
1769 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
1770 | Int iRefIdc = 0; |
---|
1771 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
1772 | { |
---|
1773 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
1774 | { |
---|
1775 | if (pcRPS->getUsed(j)) |
---|
1776 | { |
---|
1777 | iRefIdc = 1; |
---|
1778 | } |
---|
1779 | else |
---|
1780 | { |
---|
1781 | iRefIdc = 2; |
---|
1782 | } |
---|
1783 | } |
---|
1784 | } |
---|
1785 | pcRPS->setRefIdc(i, iRefIdc); |
---|
1786 | iNewIdc++; |
---|
1787 | } |
---|
1788 | pcRPS->setInterRPSPrediction(true); |
---|
1789 | pcRPS->setNumRefIdc(iNewIdc); |
---|
1790 | pcRPS->setDeltaRPS(deltaRPS); |
---|
1791 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
1792 | } |
---|
1793 | |
---|
1794 | this->setRPS(pcRPS); |
---|
1795 | this->setRPSidx(-1); |
---|
1796 | } |
---|
1797 | |
---|
1798 | //! get AC and DC values for weighted pred |
---|
1799 | Void TComSlice::getWpAcDcParam(WPACDCParam *&wp) |
---|
1800 | { |
---|
1801 | wp = m_weightACDCParam; |
---|
1802 | } |
---|
1803 | |
---|
1804 | //! init AC and DC values for weighted pred |
---|
1805 | Void TComSlice::initWpAcDcParam() |
---|
1806 | { |
---|
1807 | for(Int iComp = 0; iComp < MAX_NUM_COMPONENT; iComp++ ) |
---|
1808 | { |
---|
1809 | m_weightACDCParam[iComp].iAC = 0; |
---|
1810 | m_weightACDCParam[iComp].iDC = 0; |
---|
1811 | } |
---|
1812 | } |
---|
1813 | |
---|
1814 | //! get tables for weighted prediction |
---|
1815 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, WPScalingParam *&wp ) |
---|
1816 | { |
---|
1817 | assert (e<NUM_REF_PIC_LIST_01); |
---|
1818 | wp = m_weightPredTable[e][iRefIdx]; |
---|
1819 | } |
---|
1820 | |
---|
1821 | //! reset Default WP tables settings : no weight. |
---|
1822 | Void TComSlice::resetWpScaling() |
---|
1823 | { |
---|
1824 | for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
1825 | { |
---|
1826 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1827 | { |
---|
1828 | for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) |
---|
1829 | { |
---|
1830 | WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1831 | pwp->bPresentFlag = false; |
---|
1832 | pwp->uiLog2WeightDenom = 0; |
---|
1833 | pwp->uiLog2WeightDenom = 0; |
---|
1834 | pwp->iWeight = 1; |
---|
1835 | pwp->iOffset = 0; |
---|
1836 | } |
---|
1837 | } |
---|
1838 | } |
---|
1839 | } |
---|
1840 | |
---|
1841 | //! init WP table |
---|
1842 | Void TComSlice::initWpScaling(const TComSPS *sps) |
---|
1843 | { |
---|
1844 | const Bool bUseHighPrecisionPredictionWeighting = sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag(); |
---|
1845 | for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
1846 | { |
---|
1847 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1848 | { |
---|
1849 | for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) |
---|
1850 | { |
---|
1851 | WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1852 | if ( !pwp->bPresentFlag ) |
---|
1853 | { |
---|
1854 | // Inferring values not present : |
---|
1855 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
1856 | pwp->iOffset = 0; |
---|
1857 | } |
---|
1858 | |
---|
1859 | const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (sps->getBitDepth(toChannelType(ComponentID(yuv)))-8)); |
---|
1860 | |
---|
1861 | pwp->w = pwp->iWeight; |
---|
1862 | pwp->o = pwp->iOffset * offsetScalingFactor; //NOTE: This value of the ".o" variable is never used - .o is set immediately before it gets used |
---|
1863 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
1864 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
1865 | } |
---|
1866 | } |
---|
1867 | } |
---|
1868 | } |
---|
1869 | |
---|
1870 | // ------------------------------------------------------------------------------------------------ |
---|
1871 | // Video parameter set (VPS) |
---|
1872 | // ------------------------------------------------------------------------------------------------ |
---|
1873 | TComVPS::TComVPS() |
---|
1874 | : m_VPSId ( 0) |
---|
1875 | , m_uiMaxTLayers ( 1) |
---|
1876 | #if NH_MV |
---|
1877 | , m_uiMaxLayersMinus1 ( 0) |
---|
1878 | #else |
---|
1879 | , m_uiMaxLayers ( 1) |
---|
1880 | #endif |
---|
1881 | , m_bTemporalIdNestingFlag (false) |
---|
1882 | , m_numHrdParameters ( 0) |
---|
1883 | #if NH_MV |
---|
1884 | , m_maxLayerId ( 0) |
---|
1885 | #else |
---|
1886 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
1887 | #endif |
---|
1888 | , m_hrdParameters () |
---|
1889 | , m_hrdOpSetIdx () |
---|
1890 | , m_cprmsPresentFlag () |
---|
1891 | { |
---|
1892 | #if NH_MV |
---|
1893 | m_vpsBaseLayerInternalFlag = true; |
---|
1894 | m_vpsBaseLayerAvailableFlag = true; |
---|
1895 | |
---|
1896 | m_numViews = 0; |
---|
1897 | |
---|
1898 | #endif |
---|
1899 | |
---|
1900 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
1901 | { |
---|
1902 | m_numReorderPics[i] = 0; |
---|
1903 | m_uiMaxDecPicBuffering[i] = 1; |
---|
1904 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1905 | } |
---|
1906 | #if NH_MV |
---|
1907 | for (Int lsIdx = 0; lsIdx < MAX_VPS_OP_SETS_PLUS1; lsIdx++ ) |
---|
1908 | { |
---|
1909 | for( Int layerId = 0; layerId < MAX_VPS_NUH_LAYER_ID_PLUS1; layerId++ ) |
---|
1910 | { |
---|
1911 | m_layerIdIncludedFlag[lsIdx][layerId] = (( lsIdx == 0 ) && ( layerId == 0 )) ; |
---|
1912 | } |
---|
1913 | } |
---|
1914 | m_vpsNumProfileTierLevelMinus1 = -1; |
---|
1915 | |
---|
1916 | m_numAddLayerSets = 0; |
---|
1917 | m_numAddOlss = 0; |
---|
1918 | m_defaultOutputLayerIdc = 0; |
---|
1919 | |
---|
1920 | for ( Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++) |
---|
1921 | { |
---|
1922 | m_layerSetIdxForOlsMinus1[i] = -1; |
---|
1923 | for ( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++) |
---|
1924 | { |
---|
1925 | m_profileTierLevelIdx[i][j] = -1; |
---|
1926 | m_outputLayerFlag[i][j] = false; |
---|
1927 | } |
---|
1928 | m_altOutputLayerFlag[ i ] = false; |
---|
1929 | } |
---|
1930 | |
---|
1931 | m_repFormatIdxPresentFlag = false; |
---|
1932 | m_maxOneActiveRefLayerFlag = false; |
---|
1933 | m_vpsPocLsbAlignedFlag = false; |
---|
1934 | m_directDepTypeLenMinus2 = 0; |
---|
1935 | |
---|
1936 | |
---|
1937 | m_vpsExtensionFlag = true; |
---|
1938 | m_vpsNonVuiExtensionLength = 0; |
---|
1939 | m_splittingFlag = false; |
---|
1940 | |
---|
1941 | |
---|
1942 | for( Int i = 0; i < MAX_NUM_SCALABILITY_TYPES; i++ ) |
---|
1943 | { |
---|
1944 | m_scalabilityMaskFlag[i] = false; |
---|
1945 | m_dimensionIdLen [i] = -1; |
---|
1946 | } |
---|
1947 | |
---|
1948 | m_vpsNuhLayerIdPresentFlag = false; |
---|
1949 | |
---|
1950 | for( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++ ) |
---|
1951 | { |
---|
1952 | m_vpsProfilePresentFlag [i] = false; |
---|
1953 | m_layerSetIdxForOlsMinus1 [i] = 0; |
---|
1954 | for( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++ ) |
---|
1955 | { |
---|
1956 | m_outputLayerFlag[i][j] = false; |
---|
1957 | } |
---|
1958 | } |
---|
1959 | |
---|
1960 | for( Int i = 0; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
1961 | { |
---|
1962 | m_layerIdInVps[i] = (i == 0 ) ? 0 : -1; |
---|
1963 | } |
---|
1964 | |
---|
1965 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
1966 | { |
---|
1967 | m_layerIdInNuh [i] = ( i == 0 ) ? 0 : -1; |
---|
1968 | m_numDirectRefLayers[i] = 0; |
---|
1969 | #if NH_3D |
---|
1970 | m_numRefListLayers[i] = 0; |
---|
1971 | #endif |
---|
1972 | m_vpsRepFormatIdx [i] = 0; |
---|
1973 | m_pocLsbNotPresentFlag[i] = 0; |
---|
1974 | m_viewIdVal [i] = 0; |
---|
1975 | |
---|
1976 | #if NH_3D |
---|
1977 | m_viewIndex [i] = -1; |
---|
1978 | #endif |
---|
1979 | |
---|
1980 | for( Int j = 0; j < MAX_NUM_LAYERS; j++ ) |
---|
1981 | { |
---|
1982 | m_directDependencyFlag[i][j] = false; |
---|
1983 | m_directDependencyType[i][j] = -1; |
---|
1984 | m_dependencyFlag [i][j] = false; |
---|
1985 | m_idDirectRefLayer[i][j] = -1; |
---|
1986 | #if NH_3D |
---|
1987 | m_idRefListLayer[i][j] = -1; |
---|
1988 | #endif |
---|
1989 | m_idPredictedLayer[i][j] = -1; |
---|
1990 | m_idRefLayer [i][j] = -1; |
---|
1991 | m_maxTidIlRefPicsPlus1[i][j] = 7; |
---|
1992 | } |
---|
1993 | |
---|
1994 | for( Int j = 0; j < MAX_NUM_SCALABILITY_TYPES; j++ ) |
---|
1995 | { |
---|
1996 | m_dimensionId[i][j] = 0; |
---|
1997 | } |
---|
1998 | #if H_3D_ARP |
---|
1999 | #endif |
---|
2000 | } |
---|
2001 | #endif |
---|
2002 | } |
---|
2003 | |
---|
2004 | TComVPS::~TComVPS() |
---|
2005 | { |
---|
2006 | } |
---|
2007 | |
---|
2008 | #if NH_MV |
---|
2009 | |
---|
2010 | Bool TComVPS::checkVPSExtensionSyntax() |
---|
2011 | { |
---|
2012 | for( Int layer = 1; layer <= getMaxLayersMinus1(); layer++ ) |
---|
2013 | { |
---|
2014 | // check layer_id_in_nuh constraint |
---|
2015 | assert( getLayerIdInNuh( layer ) > getLayerIdInNuh( layer -1 ) ); |
---|
2016 | } |
---|
2017 | |
---|
2018 | //The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
2019 | assert( getVpsNumRepFormatsMinus1() >= 0 ); |
---|
2020 | assert( getVpsNumRepFormatsMinus1() <= 255 ); |
---|
2021 | |
---|
2022 | // The value of num_add_layer_sets shall be in the range of 0 to 1023, inclusive. |
---|
2023 | assert( getNumAddLayerSets() >= 0 && getNumAddLayerSets() <= 1023 ); |
---|
2024 | return true; |
---|
2025 | } |
---|
2026 | |
---|
2027 | Int TComVPS::getNumScalabilityTypes() const |
---|
2028 | { |
---|
2029 | return scalTypeToScalIdx( ScalabilityType(MAX_NUM_SCALABILITY_TYPES) ); |
---|
2030 | } |
---|
2031 | |
---|
2032 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) const |
---|
2033 | { |
---|
2034 | assert( scalType >= 0 && scalType <= MAX_NUM_SCALABILITY_TYPES ); |
---|
2035 | assert( scalType == MAX_NUM_SCALABILITY_TYPES || getScalabilityMaskFlag( scalType ) ); |
---|
2036 | Int scalIdx = 0; |
---|
2037 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
2038 | { |
---|
2039 | scalIdx += ( getScalabilityMaskFlag( curScalType ) ? 1 : 0 ); |
---|
2040 | |
---|
2041 | } |
---|
2042 | |
---|
2043 | return scalIdx; |
---|
2044 | } |
---|
2045 | Void TComVPS::setScalabilityMaskFlag( UInt val ) |
---|
2046 | { |
---|
2047 | for ( Int scalType = 0; scalType < MAX_NUM_SCALABILITY_TYPES; scalType++ ) |
---|
2048 | { |
---|
2049 | setScalabilityMaskFlag( scalType, ( val & (1 << scalType ) ) != 0 ); |
---|
2050 | } |
---|
2051 | } |
---|
2052 | |
---|
2053 | Void TComVPS::setRefLayers() |
---|
2054 | { |
---|
2055 | |
---|
2056 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2057 | { |
---|
2058 | for( Int j = 0; j <= getMaxLayersMinus1(); j++ ) |
---|
2059 | { |
---|
2060 | m_dependencyFlag[ i ][ j ] = getDirectDependencyFlag( i , j ); |
---|
2061 | for( Int k = 0; k < i; k++ ) |
---|
2062 | { |
---|
2063 | if( getDirectDependencyFlag(i , k ) && m_dependencyFlag[k][j] ) |
---|
2064 | { |
---|
2065 | m_dependencyFlag[ i ][ j ] = true; |
---|
2066 | } |
---|
2067 | } |
---|
2068 | } |
---|
2069 | } |
---|
2070 | |
---|
2071 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2072 | { |
---|
2073 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2074 | Int d = 0; |
---|
2075 | #if NH_3D |
---|
2076 | Int l = 0; |
---|
2077 | #endif |
---|
2078 | Int r = 0; |
---|
2079 | Int p = 0; |
---|
2080 | |
---|
2081 | for( Int j = 0; j <= getMaxLayersMinus1(); j++ ) |
---|
2082 | { |
---|
2083 | Int jNuhLid = getLayerIdInNuh( j ); |
---|
2084 | if( getDirectDependencyFlag( i , j ) ) |
---|
2085 | { |
---|
2086 | m_idDirectRefLayer[iNuhLId][d++] = jNuhLid; |
---|
2087 | } |
---|
2088 | #if NH_3D |
---|
2089 | if( getDirectDependencyFlag( i , j ) && ( getDepthId( iNuhLId ) == getDepthId( jNuhLid ) )) |
---|
2090 | { |
---|
2091 | m_idRefListLayer [iNuhLId][l++] = jNuhLid; |
---|
2092 | } |
---|
2093 | #endif |
---|
2094 | |
---|
2095 | if( getDependencyFlag( i , j ) ) |
---|
2096 | { |
---|
2097 | m_idRefLayer [iNuhLId][r++] = jNuhLid; |
---|
2098 | } |
---|
2099 | if( getDependencyFlag( j , i ) ) |
---|
2100 | { |
---|
2101 | m_idPredictedLayer[iNuhLId][p++] = jNuhLid; |
---|
2102 | } |
---|
2103 | } |
---|
2104 | m_numDirectRefLayers[ iNuhLId ] = d; |
---|
2105 | #if NH_3D |
---|
2106 | m_numRefListLayers[ iNuhLId ] = l; |
---|
2107 | #endif |
---|
2108 | |
---|
2109 | m_numRefLayers [ iNuhLId ] = r; |
---|
2110 | m_numPredictedLayers[ iNuhLId ] = p; |
---|
2111 | } |
---|
2112 | |
---|
2113 | Bool layerIdInListFlag[ 64 ]; |
---|
2114 | for( Int i = 0; i <= 63; i++ ) |
---|
2115 | { |
---|
2116 | layerIdInListFlag[ i ] = 0; |
---|
2117 | } |
---|
2118 | |
---|
2119 | Int k = 0; |
---|
2120 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2121 | { |
---|
2122 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2123 | if( getNumDirectRefLayers( iNuhLId ) == 0 ) |
---|
2124 | { |
---|
2125 | m_treePartitionLayerIdList[ k ][ 0 ] = iNuhLId; |
---|
2126 | Int h = 1; |
---|
2127 | for( Int j = 0; j < getNumPredictedLayers( iNuhLId ); j++ ) |
---|
2128 | { |
---|
2129 | Int predLId = getIdPredictedLayer( iNuhLId, j ); |
---|
2130 | if ( !layerIdInListFlag[ predLId ] ) |
---|
2131 | { |
---|
2132 | m_treePartitionLayerIdList[ k ][ h++ ] = predLId; |
---|
2133 | layerIdInListFlag[ predLId ] = 1; |
---|
2134 | } |
---|
2135 | } |
---|
2136 | m_numLayersInTreePartition[ k++ ] = h; |
---|
2137 | } |
---|
2138 | } |
---|
2139 | m_numIndependentLayers = k; |
---|
2140 | } |
---|
2141 | |
---|
2142 | |
---|
2143 | Void TComVPS::initNumViews( ) |
---|
2144 | { |
---|
2145 | m_numViews = 1; |
---|
2146 | #if NH_3D |
---|
2147 | AOF( m_viewOIdxList.size() == 0 ); |
---|
2148 | m_viewOIdxList.push_back( 0 ); |
---|
2149 | #endif |
---|
2150 | |
---|
2151 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2152 | { |
---|
2153 | Int lId = getLayerIdInNuh( i ); |
---|
2154 | if( i > 0 ) |
---|
2155 | { |
---|
2156 | Bool newViewFlag = true; |
---|
2157 | for( Int j = 0; j < i; j++ ) |
---|
2158 | { |
---|
2159 | if( getViewOrderIdx( lId ) == getViewOrderIdx( getLayerIdInNuh( j ) ) ) |
---|
2160 | { |
---|
2161 | newViewFlag = false; |
---|
2162 | } |
---|
2163 | } |
---|
2164 | if( newViewFlag ) |
---|
2165 | { |
---|
2166 | m_numViews++; |
---|
2167 | #if NH_3D |
---|
2168 | m_viewOIdxList.push_back( getViewOrderIdx( lId ) ); |
---|
2169 | #endif |
---|
2170 | } |
---|
2171 | } |
---|
2172 | } |
---|
2173 | } |
---|
2174 | |
---|
2175 | |
---|
2176 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) const |
---|
2177 | { |
---|
2178 | return getScalabilityMaskFlag( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
2179 | } |
---|
2180 | |
---|
2181 | #if NH_3D |
---|
2182 | Int TComVPS::getLayerIdInNuh( Int viewIndex, Bool depthFlag ) const |
---|
2183 | { |
---|
2184 | Int foundLayerIdinNuh = -1; |
---|
2185 | |
---|
2186 | for (Int layerIdInVps = 0 ; layerIdInVps <= getMaxLayersMinus1(); layerIdInVps++ ) |
---|
2187 | { |
---|
2188 | Int layerIdInNuh = getLayerIdInNuh( layerIdInVps ); |
---|
2189 | if( ( getViewIndex( layerIdInNuh ) == viewIndex ) && ( getDepthId( layerIdInNuh ) == ( depthFlag ? 1 : 0 ) ) ) |
---|
2190 | { |
---|
2191 | foundLayerIdinNuh = layerIdInNuh; |
---|
2192 | break; |
---|
2193 | } |
---|
2194 | } |
---|
2195 | return foundLayerIdinNuh; |
---|
2196 | } |
---|
2197 | |
---|
2198 | Void TComVPS::createCamPars(Int iNumViews) |
---|
2199 | { |
---|
2200 | m_numCp .resize( iNumViews ); |
---|
2201 | m_cpRefVoi .resize( iNumViews ); |
---|
2202 | m_cpInSliceSegmentHeaderFlag.resize( iNumViews ); |
---|
2203 | m_cpPresentFlag .resize( iNumViews ); |
---|
2204 | m_aaaiCodedScale .resize( iNumViews ); |
---|
2205 | m_aaaiCodedOffset .resize( iNumViews ); |
---|
2206 | |
---|
2207 | for ( Int i = 0; i < iNumViews ; i++ ) |
---|
2208 | { |
---|
2209 | m_numCp [i] = 0; |
---|
2210 | m_cpRefVoi [i].resize( iNumViews ); |
---|
2211 | m_cpInSliceSegmentHeaderFlag[i] = false; |
---|
2212 | m_aaaiCodedScale [i].resize( 2 ); |
---|
2213 | m_aaaiCodedOffset [i].resize( 2 ); |
---|
2214 | m_cpPresentFlag [i].resize( iNumViews ); |
---|
2215 | |
---|
2216 | for ( Int j = 0; j < iNumViews; j++) |
---|
2217 | { |
---|
2218 | m_cpRefVoi [i][j] = 0; |
---|
2219 | m_cpPresentFlag [i][j] = false; |
---|
2220 | } |
---|
2221 | |
---|
2222 | for ( Int j = 0; j < 2; j++ ) |
---|
2223 | { |
---|
2224 | m_aaaiCodedScale [i][j].resize( MAX_NUM_LAYERS ); |
---|
2225 | m_aaaiCodedOffset [i][j].resize( MAX_NUM_LAYERS ); |
---|
2226 | |
---|
2227 | for ( Int k = 0; k < MAX_NUM_LAYERS; k++ ) |
---|
2228 | { |
---|
2229 | m_aaaiCodedScale [i][j][k] = 0; |
---|
2230 | m_aaaiCodedOffset[i][j][k] = 0; |
---|
2231 | } |
---|
2232 | } |
---|
2233 | } |
---|
2234 | } |
---|
2235 | #endif // H_3D |
---|
2236 | |
---|
2237 | |
---|
2238 | Int TComVPS::xGetDimBitOffset( Int j ) const |
---|
2239 | { |
---|
2240 | Int dimBitOffset = 0; |
---|
2241 | if ( getSplittingFlag() && j == getNumScalabilityTypes() ) |
---|
2242 | { |
---|
2243 | dimBitOffset = 6; |
---|
2244 | } |
---|
2245 | else |
---|
2246 | { |
---|
2247 | for (Int dimIdx = 0; dimIdx <= j-1; dimIdx++) |
---|
2248 | { |
---|
2249 | dimBitOffset += getDimensionIdLen( dimIdx ); |
---|
2250 | } |
---|
2251 | } |
---|
2252 | return dimBitOffset; |
---|
2253 | } |
---|
2254 | |
---|
2255 | Int TComVPS::inferDimensionId( Int i, Int j ) const |
---|
2256 | { |
---|
2257 | return ( ( getLayerIdInNuh( i ) & ( (1 << xGetDimBitOffset( j + 1 ) ) - 1) ) >> xGetDimBitOffset( j ) ); |
---|
2258 | } |
---|
2259 | |
---|
2260 | Int TComVPS::inferLastDimsionIdLenMinus1() const |
---|
2261 | { |
---|
2262 | return ( 5 - xGetDimBitOffset( getNumScalabilityTypes() - 1 ) ); |
---|
2263 | } |
---|
2264 | |
---|
2265 | Int TComVPS::getNumLayersInIdList( Int lsIdx ) const |
---|
2266 | { |
---|
2267 | assert( lsIdx >= 0 ); |
---|
2268 | assert( lsIdx <= getNumLayerSets() ); |
---|
2269 | return (Int) m_layerSetLayerIdList[ lsIdx ].size(); |
---|
2270 | } |
---|
2271 | |
---|
2272 | Int TComVPS::getNumOutputLayerSets() const |
---|
2273 | { |
---|
2274 | return getNumAddOlss() + getNumLayerSets(); |
---|
2275 | } |
---|
2276 | |
---|
2277 | |
---|
2278 | |
---|
2279 | Void TComVPS::deriveLayerSetLayerIdList() |
---|
2280 | { |
---|
2281 | m_layerSetLayerIdList.resize( getVpsNumLayerSetsMinus1() + 1 ); |
---|
2282 | for (Int i = 0; i <= getVpsNumLayerSetsMinus1(); i++ ) |
---|
2283 | { |
---|
2284 | for( Int m = 0; m <= getVpsMaxLayerId(); m++ ) |
---|
2285 | { |
---|
2286 | if( getLayerIdIncludedFlag( i, m) ) |
---|
2287 | { |
---|
2288 | m_layerSetLayerIdList[ i ].push_back( m ); |
---|
2289 | } |
---|
2290 | } |
---|
2291 | } |
---|
2292 | } |
---|
2293 | |
---|
2294 | Void TComVPS::initTargetLayerIdLists() |
---|
2295 | { |
---|
2296 | m_targetDecLayerIdLists.resize( getNumOutputLayerSets() ); |
---|
2297 | m_targetOptLayerIdLists.resize( getNumOutputLayerSets() ); |
---|
2298 | } |
---|
2299 | |
---|
2300 | Void TComVPS::deriveTargetLayerIdList( Int i ) |
---|
2301 | { |
---|
2302 | Int lsIdx = olsIdxToLsIdx( i ); |
---|
2303 | |
---|
2304 | for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ ) |
---|
2305 | { |
---|
2306 | if ( getNecessaryLayerFlag( i , j )) |
---|
2307 | { |
---|
2308 | m_targetDecLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); |
---|
2309 | } |
---|
2310 | |
---|
2311 | if( getOutputLayerFlag( i, j )) |
---|
2312 | { |
---|
2313 | m_targetOptLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); |
---|
2314 | } |
---|
2315 | } |
---|
2316 | assert( getNumOutputLayersInOutputLayerSet( i ) > 0 ); |
---|
2317 | } |
---|
2318 | |
---|
2319 | Bool TComVPS::inferOutputLayerFlag( Int i, Int j ) const |
---|
2320 | { |
---|
2321 | Bool outputLayerFlag; |
---|
2322 | switch ( getDefaultOutputLayerIdc( ) ) |
---|
2323 | { |
---|
2324 | case 0: |
---|
2325 | outputLayerFlag = true; |
---|
2326 | break; |
---|
2327 | case 1: |
---|
2328 | outputLayerFlag = ( j == m_layerSetLayerIdList[ olsIdxToLsIdx( i ) ].size() - 1 ); |
---|
2329 | break; |
---|
2330 | case 2: |
---|
2331 | if ( i == 0 && j == 0) |
---|
2332 | { |
---|
2333 | outputLayerFlag = true; // This is a software only fix for a bug in the spec. In spec outputLayerFlag is neither present nor inferred. |
---|
2334 | } |
---|
2335 | else |
---|
2336 | { |
---|
2337 | assert( 0 ); |
---|
2338 | } |
---|
2339 | break; |
---|
2340 | default: |
---|
2341 | assert( 0 ); |
---|
2342 | break; |
---|
2343 | } |
---|
2344 | return outputLayerFlag; |
---|
2345 | } |
---|
2346 | |
---|
2347 | Int TComVPS::getMaxSubLayersInLayerSetMinus1( Int i ) const |
---|
2348 | { |
---|
2349 | Int maxSLMinus1 = 0; |
---|
2350 | for( Int k = 0; k < getNumLayersInIdList( i ); k++ ) |
---|
2351 | { |
---|
2352 | Int lId = m_layerSetLayerIdList[i][k]; |
---|
2353 | maxSLMinus1 = std::max( maxSLMinus1, getSubLayersVpsMaxMinus1( getLayerIdInVps( lId ) )); |
---|
2354 | } |
---|
2355 | return maxSLMinus1; |
---|
2356 | } |
---|
2357 | |
---|
2358 | Bool TComVPS::getAltOutputLayerFlagVar( Int i ) const |
---|
2359 | { |
---|
2360 | // Semantics variable not syntax element ! |
---|
2361 | |
---|
2362 | Bool altOptLayerFlag = false; |
---|
2363 | if ( i > 0 && getNumOutputLayersInOutputLayerSet( i ) == 1 && |
---|
2364 | getNumDirectRefLayers( getOlsHighestOutputLayerId( i ) ) > 0 ) |
---|
2365 | { |
---|
2366 | altOptLayerFlag = getAltOutputLayerFlag( i ); |
---|
2367 | } |
---|
2368 | return altOptLayerFlag; |
---|
2369 | } |
---|
2370 | |
---|
2371 | |
---|
2372 | |
---|
2373 | Int TComVPS::inferProfileTierLevelIdx(Int i, Int j) const |
---|
2374 | { |
---|
2375 | Bool inferZero = ( i == 0 && j == 0 && getVpsBaseLayerInternalFlag() ); |
---|
2376 | Bool inferGreaterZero = getNecessaryLayerFlag(i,j) && ( getVpsNumProfileTierLevelMinus1() == 0 ); |
---|
2377 | assert( inferZero || inferGreaterZero ); |
---|
2378 | |
---|
2379 | Bool ptlIdx = 0; // inference for greaterZero |
---|
2380 | if ( inferZero ) |
---|
2381 | { |
---|
2382 | ptlIdx = getMaxLayersMinus1() > 0 ? 1 : 0; |
---|
2383 | if ( inferGreaterZero ) |
---|
2384 | { |
---|
2385 | assert( ptlIdx == 0 ); |
---|
2386 | // This should never happen since : |
---|
2387 | // 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. |
---|
2388 | } |
---|
2389 | } |
---|
2390 | return ptlIdx; |
---|
2391 | } |
---|
2392 | |
---|
2393 | Void TComVPS::deriveAddLayerSetLayerIdList(Int i) |
---|
2394 | { |
---|
2395 | assert( m_layerSetLayerIdList.size() == ( getVpsNumLayerSetsMinus1() + 1 + i ) ); |
---|
2396 | std::vector<Int> layerSetLayerIdList; |
---|
2397 | |
---|
2398 | for( Int treeIdx = 1; treeIdx < getNumIndependentLayers(); treeIdx++ ) |
---|
2399 | { |
---|
2400 | // The value of highest_layer_idx_plus1[ i ][ j ] shall be in the range of 0 to NumLayersInTreePartition[ j ], inclusive. |
---|
2401 | assert( getHighestLayerIdxPlus1( i, treeIdx ) >= 0 && getHighestLayerIdxPlus1( i, treeIdx ) <= getNumLayersInTreePartition( treeIdx ) ); |
---|
2402 | |
---|
2403 | for( Int layerCnt = 0; layerCnt < getHighestLayerIdxPlus1( i, treeIdx ); layerCnt++ ) |
---|
2404 | { |
---|
2405 | layerSetLayerIdList.push_back( getTreePartitionLayerIdList( treeIdx, layerCnt ) ); |
---|
2406 | } |
---|
2407 | } |
---|
2408 | m_layerSetLayerIdList.push_back( layerSetLayerIdList ); |
---|
2409 | |
---|
2410 | //It is a requirement of bitstream conformance that |
---|
2411 | //NumLayersInIdList[ vps_num_layer_sets_minus1 + 1 + i ] shall be greater than 0. |
---|
2412 | assert( getNumLayersInIdList( getVpsNumLayerSetsMinus1() + 1 + i ) > 0 ); |
---|
2413 | } |
---|
2414 | |
---|
2415 | |
---|
2416 | Void TComVPS::deriveNecessaryLayerFlags(Int olsIdx) |
---|
2417 | { |
---|
2418 | AOF( olsIdx >= 0 && olsIdx < getNumOutputLayerSets() ); |
---|
2419 | Int lsIdx = olsIdxToLsIdx( olsIdx ); |
---|
2420 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx) ; lsLayerIdx++ ) |
---|
2421 | { |
---|
2422 | m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ] = 0; |
---|
2423 | } |
---|
2424 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx ); lsLayerIdx++ ) |
---|
2425 | { |
---|
2426 | if( getOutputLayerFlag( olsIdx, lsLayerIdx )) |
---|
2427 | { |
---|
2428 | m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ] = 1; |
---|
2429 | Int currLayerId = getLayerSetLayerIdList( lsIdx, lsLayerIdx ); |
---|
2430 | for( Int rLsLayerIdx = 0; rLsLayerIdx < lsLayerIdx; rLsLayerIdx++ ) |
---|
2431 | { |
---|
2432 | Int refLayerId = getLayerSetLayerIdList( lsIdx, rLsLayerIdx ); |
---|
2433 | if( getDependencyFlag( getLayerIdInVps( currLayerId ), getLayerIdInVps( refLayerId ) ) ) |
---|
2434 | { |
---|
2435 | m_necessaryLayerFlag[ olsIdx ][ rLsLayerIdx ] = 1; |
---|
2436 | } |
---|
2437 | } |
---|
2438 | } |
---|
2439 | } |
---|
2440 | m_numNecessaryLayers[ olsIdx ] = 0; |
---|
2441 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx ); lsLayerIdx++ ) |
---|
2442 | { |
---|
2443 | m_numNecessaryLayers[ olsIdx ] += m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ]; |
---|
2444 | } |
---|
2445 | } |
---|
2446 | |
---|
2447 | Void TComVPS::printPTL() const |
---|
2448 | { |
---|
2449 | std::vector<Int> idx; |
---|
2450 | std::vector<Int> num; |
---|
2451 | IntAry2d ptlInfo; |
---|
2452 | |
---|
2453 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "PTLI" << std::endl; |
---|
2454 | |
---|
2455 | for ( Int i = 0; i <= getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
2456 | { |
---|
2457 | std::vector<Int> curPtlInfo; |
---|
2458 | const ProfileTierLevel* ptl = getPTL( i )->getGeneralPTL(); |
---|
2459 | curPtlInfo.push_back( (Int) ptl->getProfileIdc() ); |
---|
2460 | curPtlInfo.push_back( (Int) ptl->getTierFlag() ); |
---|
2461 | curPtlInfo.push_back( (Int) ptl->getLevelIdc() ); |
---|
2462 | curPtlInfo.push_back( (Int) ptl->getInbldFlag() ); |
---|
2463 | |
---|
2464 | idx.push_back ( i ); |
---|
2465 | num.push_back ( 4 ); |
---|
2466 | ptlInfo.push_back( curPtlInfo ); |
---|
2467 | } |
---|
2468 | |
---|
2469 | xPrintArray( "VpsProfileTierLevel", getVpsNumProfileTierLevelMinus1() + 1, idx, num, ptlInfo, false ); |
---|
2470 | |
---|
2471 | num.clear(); |
---|
2472 | idx.clear(); |
---|
2473 | for (Int i = 0; i < getNumOutputLayerSets(); i++) |
---|
2474 | { |
---|
2475 | num.push_back ( getNumLayersInIdList( olsIdxToLsIdx( i )) ); |
---|
2476 | idx.push_back( i ); |
---|
2477 | } |
---|
2478 | |
---|
2479 | xPrintArray( "profile_tier_level_idx", getNumOutputLayerSets(), idx, num, m_profileTierLevelIdx, true ); |
---|
2480 | std::cout << std::endl; |
---|
2481 | } |
---|
2482 | |
---|
2483 | Void TComVPS::printLayerDependencies() const |
---|
2484 | { |
---|
2485 | vector<Int> fullArray; |
---|
2486 | vector<Int> range; |
---|
2487 | |
---|
2488 | #if NH_3D |
---|
2489 | vector<Int> depthId; |
---|
2490 | #endif |
---|
2491 | |
---|
2492 | vector<Int> viewOrderIndex; |
---|
2493 | vector<Int> auxId; |
---|
2494 | vector<Int> dependencyId; |
---|
2495 | vector<Int> viewId; |
---|
2496 | for (Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2497 | { |
---|
2498 | fullArray.push_back( getMaxLayersMinus1() + 1 ); |
---|
2499 | range.push_back( i ); |
---|
2500 | viewOrderIndex.push_back( getViewIndex ( i ) ); |
---|
2501 | dependencyId .push_back( getDependencyId( i ) ); |
---|
2502 | auxId .push_back( getAuxId ( i ) ); |
---|
2503 | viewId .push_back( getViewId ( getLayerIdInNuh( i ) ) ); |
---|
2504 | #if H_3D |
---|
2505 | depthId.push_back( getDepthId( i ) ); |
---|
2506 | #endif |
---|
2507 | } |
---|
2508 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Layer Dependencies" << std::endl; |
---|
2509 | xPrintArray( "direct_dependency_flag", getMaxLayersMinus1()+1, range, fullArray, m_directDependencyFlag, false ); |
---|
2510 | xPrintArray( "DependencyFlag", getMaxLayersMinus1()+1, range, fullArray, m_dependencyFlag, false ); |
---|
2511 | xPrintArray( "layer_id_in_nuh", getMaxLayersMinus1()+1, m_layerIdInNuh, true ); |
---|
2512 | xPrintArray( "IdPredictedLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numPredictedLayers, m_idPredictedLayer, true ); |
---|
2513 | xPrintArray( "IdRefLayer" , getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numRefLayers, m_idRefLayer, true ); |
---|
2514 | xPrintArray( "IdDirectRefLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numDirectRefLayers, m_idDirectRefLayer, true ); |
---|
2515 | #if NH_3D |
---|
2516 | xPrintArray( "IdRefListLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numRefListLayers, m_idRefListLayer, true ); |
---|
2517 | #endif |
---|
2518 | |
---|
2519 | std::cout << std::endl; |
---|
2520 | } |
---|
2521 | |
---|
2522 | Void TComVPS::printScalabilityId() const |
---|
2523 | { |
---|
2524 | vector<Int> layerIdxInVps; |
---|
2525 | |
---|
2526 | |
---|
2527 | vector<Int> depthId; |
---|
2528 | vector<Int> viewOrderIndex; |
---|
2529 | vector<Int> auxId; |
---|
2530 | vector<Int> dependencyId; |
---|
2531 | vector<Int> viewId; |
---|
2532 | |
---|
2533 | for (Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2534 | { |
---|
2535 | Int layerIdInNuh = getLayerIdInNuh( i ); |
---|
2536 | layerIdxInVps .push_back( i ); |
---|
2537 | depthId .push_back( getDepthId ( layerIdInNuh ) ); |
---|
2538 | viewOrderIndex.push_back( getViewIndex ( layerIdInNuh ) ); |
---|
2539 | dependencyId .push_back( getDependencyId( layerIdInNuh ) ); |
---|
2540 | auxId .push_back( getAuxId ( layerIdInNuh ) ); |
---|
2541 | viewId .push_back( getViewId ( layerIdInNuh ) ); |
---|
2542 | |
---|
2543 | } |
---|
2544 | |
---|
2545 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Scalability Ids" << std::endl; |
---|
2546 | xPrintArray( "layerIdxInVps" , getMaxLayersMinus1()+1, layerIdxInVps, false ); |
---|
2547 | xPrintArray( "layer_id_in_nuh", getMaxLayersMinus1()+1, m_layerIdInNuh, false ); |
---|
2548 | |
---|
2549 | xPrintArray( "DepthLayerFlag", getMaxLayersMinus1()+1, depthId , false ); |
---|
2550 | xPrintArray( "ViewOrderIdx" , getMaxLayersMinus1()+1, viewOrderIndex, false ); |
---|
2551 | xPrintArray( "DependencyId" , getMaxLayersMinus1()+1, dependencyId , false ); |
---|
2552 | xPrintArray( "AuxId" , getMaxLayersMinus1()+1, auxId , false ); |
---|
2553 | xPrintArray( "ViewIdVal" , getMaxLayersMinus1()+1, viewId , false ); |
---|
2554 | |
---|
2555 | std::cout << std::endl; |
---|
2556 | } |
---|
2557 | |
---|
2558 | Void TComVPS::printLayerSets() const |
---|
2559 | { |
---|
2560 | vector<Int> fullArray; |
---|
2561 | vector<Int> numLayersInIdList; |
---|
2562 | vector<Int> rangeLayerSets; |
---|
2563 | |
---|
2564 | |
---|
2565 | for (Int i = 0; i < getNumLayerSets(); i++ ) |
---|
2566 | { |
---|
2567 | numLayersInIdList.push_back( getNumLayersInIdList( i ) ); |
---|
2568 | rangeLayerSets.push_back( i ); |
---|
2569 | } |
---|
2570 | |
---|
2571 | vector<Int> rangeOutputLayerSets; |
---|
2572 | vector<Int> numOutputLayersInOutputLayerSet; |
---|
2573 | vector<Int> numDecLayer; |
---|
2574 | vector<Int> numLayersInLayerSetForOutputLayerSet; |
---|
2575 | vector<Int> vOlsIdxToLsIdx; |
---|
2576 | for (Int i = 0; i < getNumOutputLayerSets(); i++ ) |
---|
2577 | { |
---|
2578 | vOlsIdxToLsIdx.push_back( olsIdxToLsIdx(i)); |
---|
2579 | numOutputLayersInOutputLayerSet.push_back( getNumOutputLayersInOutputLayerSet( i ) ); |
---|
2580 | numDecLayer.push_back( (Int) m_targetDecLayerIdLists[ i ].size() ); |
---|
2581 | rangeOutputLayerSets.push_back( i ); |
---|
2582 | numLayersInLayerSetForOutputLayerSet.push_back( getNumLayersInIdList( olsIdxToLsIdx( i ) ) ); |
---|
2583 | } |
---|
2584 | |
---|
2585 | vector<Int> rangeIndependentLayers; |
---|
2586 | for(Int i = 0; i < getNumIndependentLayers(); i++ ) |
---|
2587 | { |
---|
2588 | rangeIndependentLayers.push_back( i ); |
---|
2589 | } |
---|
2590 | |
---|
2591 | vector<Int> rangeAddLayerSets; |
---|
2592 | vector<Int> numHighestLayerIdxPlus1; |
---|
2593 | for(Int i = 0; i < getNumAddLayerSets(); i++ ) |
---|
2594 | { |
---|
2595 | rangeAddLayerSets.push_back( i ); |
---|
2596 | numHighestLayerIdxPlus1.push_back( getNumIndependentLayers() ); |
---|
2597 | } |
---|
2598 | |
---|
2599 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Layer Sets" << std::endl; |
---|
2600 | xPrintArray( "TreePartitionLayerIdList", getNumIndependentLayers(), rangeIndependentLayers, m_numLayersInTreePartition, m_treePartitionLayerIdList, true ); |
---|
2601 | xPrintArray( "highest_layer_idx_plus1", getNumAddLayerSets(), rangeAddLayerSets, numHighestLayerIdxPlus1, m_highestLayerIdxPlus1, true ); |
---|
2602 | xPrintArray( "LayerSetLayerIdList" , (Int) getNumLayerSets() , rangeLayerSets , numLayersInIdList, m_layerSetLayerIdList, true ); |
---|
2603 | xPrintArray( "OlsIdxToLsIdx", (Int) vOlsIdxToLsIdx.size(), vOlsIdxToLsIdx, true ); |
---|
2604 | xPrintArray( "OutputLayerFlag" , getNumOutputLayerSets(), rangeOutputLayerSets, numLayersInLayerSetForOutputLayerSet, m_outputLayerFlag, true ); |
---|
2605 | xPrintArray( "TargetOptLayerIdList", getNumOutputLayerSets(), rangeOutputLayerSets, numOutputLayersInOutputLayerSet, m_targetOptLayerIdLists, true ); |
---|
2606 | xPrintArray( "NecessaryLayerFlag" , getNumOutputLayerSets(), rangeOutputLayerSets, numLayersInLayerSetForOutputLayerSet, m_necessaryLayerFlag , true ); |
---|
2607 | xPrintArray( "TargetDecLayerIdList", getNumOutputLayerSets(), rangeOutputLayerSets, numDecLayer, m_targetDecLayerIdLists, true ); |
---|
2608 | std::cout << endl; |
---|
2609 | } |
---|
2610 | |
---|
2611 | #if NH_3D |
---|
2612 | Void TComVPS::initViewCompLayer() |
---|
2613 | { |
---|
2614 | assert( m_viewCompLayerId.size() == 0 && m_viewCompLayerPresentFlag.size() == 0 ); |
---|
2615 | for( Int i = 0; i < getNumViews(); i++ ) |
---|
2616 | { |
---|
2617 | m_viewCompLayerId .push_back( std::vector<Int>(0) ); |
---|
2618 | m_viewCompLayerPresentFlag.push_back( std::vector<Bool>(0) ); |
---|
2619 | |
---|
2620 | for( Int depFlag = 0; depFlag <= 1; depFlag++ ) |
---|
2621 | { |
---|
2622 | Int iViewOIdx = getViewOIdxList( i ); |
---|
2623 | Int layerId = -1; |
---|
2624 | for( Int j = 0; j <= getMaxLayersMinus1(); j++ ) |
---|
2625 | { |
---|
2626 | Int jNuhLId = getLayerIdInNuh( j ); |
---|
2627 | if( getVpsDepthFlag( jNuhLId ) == ( (Bool) depFlag ) && getViewOrderIdx( jNuhLId ) == iViewOIdx |
---|
2628 | && getDependencyId( jNuhLId ) == 0 && getAuxId( jNuhLId ) == 0 ) |
---|
2629 | { |
---|
2630 | layerId = jNuhLId; |
---|
2631 | } |
---|
2632 | } |
---|
2633 | m_viewCompLayerPresentFlag[ i ].push_back( layerId != -1 ); |
---|
2634 | m_viewCompLayerId [ i ].push_back( layerId ); |
---|
2635 | } |
---|
2636 | } |
---|
2637 | } |
---|
2638 | |
---|
2639 | Int TComVPS::getVoiInVps(Int viewOIdx) const |
---|
2640 | { |
---|
2641 | for ( Int i = 0; i < m_viewOIdxList.size(); i++ ) |
---|
2642 | { |
---|
2643 | if ( m_viewOIdxList[ i ] == viewOIdx ) |
---|
2644 | { |
---|
2645 | return i; |
---|
2646 | } |
---|
2647 | } |
---|
2648 | assert( 0 ); |
---|
2649 | return -1; |
---|
2650 | } |
---|
2651 | |
---|
2652 | Void TComVPS::deriveCpPresentFlag() |
---|
2653 | { |
---|
2654 | for( Int nInVps = 0; nInVps < getNumViews(); nInVps++ ) |
---|
2655 | { |
---|
2656 | for( Int mInVps = 0; mInVps < getNumViews(); mInVps++ ) |
---|
2657 | { |
---|
2658 | m_cpPresentFlag[nInVps][mInVps] = 0; |
---|
2659 | } |
---|
2660 | } |
---|
2661 | |
---|
2662 | for( Int n = 1; n < getNumViews(); n++ ) |
---|
2663 | { |
---|
2664 | Int iInVps = getVoiInVps( getViewOIdxList( n ) ); |
---|
2665 | for( Int m = 0; m < getNumCp( iInVps ); m++ ) |
---|
2666 | { |
---|
2667 | m_cpPresentFlag[ iInVps ][ getVoiInVps( getCpRefVoi( iInVps, m ) ) ] = 1; |
---|
2668 | } |
---|
2669 | } |
---|
2670 | } |
---|
2671 | #endif |
---|
2672 | |
---|
2673 | #endif // NH_MV |
---|
2674 | |
---|
2675 | // ------------------------------------------------------------------------------------------------ |
---|
2676 | // Sequence parameter set (SPS) |
---|
2677 | // ------------------------------------------------------------------------------------------------ |
---|
2678 | |
---|
2679 | TComSPSRExt::TComSPSRExt() |
---|
2680 | : m_transformSkipRotationEnabledFlag (false) |
---|
2681 | , m_transformSkipContextEnabledFlag (false) |
---|
2682 | // m_rdpcmEnabledFlag initialized below |
---|
2683 | , m_extendedPrecisionProcessingFlag (false) |
---|
2684 | , m_intraSmoothingDisabledFlag (false) |
---|
2685 | , m_highPrecisionOffsetsEnabledFlag (false) |
---|
2686 | , m_persistentRiceAdaptationEnabledFlag(false) |
---|
2687 | , m_cabacBypassAlignmentEnabledFlag (false) |
---|
2688 | { |
---|
2689 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
---|
2690 | { |
---|
2691 | m_rdpcmEnabledFlag[signallingModeIndex] = false; |
---|
2692 | } |
---|
2693 | } |
---|
2694 | |
---|
2695 | TComSPS::TComSPS() |
---|
2696 | : m_SPSId ( 0) |
---|
2697 | , m_VPSId ( 0) |
---|
2698 | , m_chromaFormatIdc (CHROMA_420) |
---|
2699 | , m_uiMaxTLayers ( 1) |
---|
2700 | // Structure |
---|
2701 | , m_picWidthInLumaSamples (352) |
---|
2702 | , m_picHeightInLumaSamples (288) |
---|
2703 | , m_log2MinCodingBlockSize ( 0) |
---|
2704 | , m_log2DiffMaxMinCodingBlockSize(0) |
---|
2705 | , m_uiMaxCUWidth ( 32) |
---|
2706 | , m_uiMaxCUHeight ( 32) |
---|
2707 | , m_uiMaxTotalCUDepth ( 3) |
---|
2708 | , m_bLongTermRefsPresent (false) |
---|
2709 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
2710 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
2711 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
2712 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
2713 | // Tool list |
---|
2714 | , m_usePCM (false) |
---|
2715 | , m_pcmLog2MaxSize ( 5) |
---|
2716 | , m_uiPCMLog2MinSize ( 7) |
---|
2717 | , m_bPCMFilterDisableFlag (false) |
---|
2718 | , m_uiBitsForPOC ( 8) |
---|
2719 | , m_numLongTermRefPicSPS ( 0) |
---|
2720 | , m_uiMaxTrSize ( 32) |
---|
2721 | , m_bUseSAO (false) |
---|
2722 | , m_bTemporalIdNestingFlag (false) |
---|
2723 | , m_scalingListEnabledFlag (false) |
---|
2724 | , m_useStrongIntraSmoothing (false) |
---|
2725 | , m_vuiParametersPresentFlag (false) |
---|
2726 | , m_vuiParameters () |
---|
2727 | #if NH_MV |
---|
2728 | , m_pcVPS ( NULL ) |
---|
2729 | , m_spsInferScalingListFlag ( false ) |
---|
2730 | , m_spsScalingListRefLayerId ( 0 ) |
---|
2731 | |
---|
2732 | , m_updateRepFormatFlag ( false ) |
---|
2733 | , m_spsRepFormatIdx ( 0 ) |
---|
2734 | , m_interViewMvVertConstraintFlag (false) |
---|
2735 | #endif |
---|
2736 | |
---|
2737 | { |
---|
2738 | for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
2739 | { |
---|
2740 | m_bitDepths.recon[ch] = 8; |
---|
2741 | #if O0043_BEST_EFFORT_DECODING |
---|
2742 | m_bitDepths.stream[ch] = 8; |
---|
2743 | #endif |
---|
2744 | m_pcmBitDepths[ch] = 8; |
---|
2745 | m_qpBDOffset [ch] = 0; |
---|
2746 | } |
---|
2747 | |
---|
2748 | |
---|
2749 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
2750 | { |
---|
2751 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2752 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2753 | m_numReorderPics[i] = 0; |
---|
2754 | } |
---|
2755 | |
---|
2756 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
2757 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
2758 | #if NH_MV |
---|
2759 | m_spsRangeExtensionsFlag = false; |
---|
2760 | m_spsMultilayerExtensionFlag = false; |
---|
2761 | m_spsExtension5bits = 0; |
---|
2762 | m_sps3dExtensionFlag = false; |
---|
2763 | |
---|
2764 | #endif |
---|
2765 | |
---|
2766 | } |
---|
2767 | |
---|
2768 | TComSPS::~TComSPS() |
---|
2769 | { |
---|
2770 | m_RPSList.destroy(); |
---|
2771 | } |
---|
2772 | |
---|
2773 | Void TComSPS::createRPSList( Int numRPS ) |
---|
2774 | { |
---|
2775 | m_RPSList.destroy(); |
---|
2776 | m_RPSList.create(numRPS); |
---|
2777 | } |
---|
2778 | |
---|
2779 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
2780 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
2781 | |
---|
2782 | TComPPSRExt::TComPPSRExt() |
---|
2783 | : m_log2MaxTransformSkipBlockSize (2) |
---|
2784 | , m_crossComponentPredictionEnabledFlag(false) |
---|
2785 | , m_diffCuChromaQpOffsetDepth (0) |
---|
2786 | , m_chromaQpOffsetListLen (0) |
---|
2787 | // m_ChromaQpAdjTableIncludingNullEntry initialized below |
---|
2788 | // m_log2SaoOffsetScale initialized below |
---|
2789 | { |
---|
2790 | 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. |
---|
2791 | m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CrOffset = 0; |
---|
2792 | for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
2793 | { |
---|
2794 | m_log2SaoOffsetScale[ch] = 0; |
---|
2795 | } |
---|
2796 | } |
---|
2797 | |
---|
2798 | TComPPS::TComPPS() |
---|
2799 | : m_PPSId (0) |
---|
2800 | , m_SPSId (0) |
---|
2801 | , m_picInitQPMinus26 (0) |
---|
2802 | , m_useDQP (false) |
---|
2803 | , m_bConstrainedIntraPred (false) |
---|
2804 | , m_bSliceChromaQpFlag (false) |
---|
2805 | , m_uiMaxCuDQPDepth (0) |
---|
2806 | , m_chromaCbQpOffset (0) |
---|
2807 | , m_chromaCrQpOffset (0) |
---|
2808 | , m_numRefIdxL0DefaultActive (1) |
---|
2809 | , m_numRefIdxL1DefaultActive (1) |
---|
2810 | , m_TransquantBypassEnableFlag (false) |
---|
2811 | , m_useTransformSkip (false) |
---|
2812 | , m_dependentSliceSegmentsEnabledFlag(false) |
---|
2813 | , m_tilesEnabledFlag (false) |
---|
2814 | , m_entropyCodingSyncEnabledFlag (false) |
---|
2815 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
2816 | , m_uniformSpacingFlag (false) |
---|
2817 | , m_numTileColumnsMinus1 (0) |
---|
2818 | , m_numTileRowsMinus1 (0) |
---|
2819 | , m_signHideFlag (false) |
---|
2820 | , m_cabacInitPresentFlag (false) |
---|
2821 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
2822 | , m_loopFilterAcrossSlicesEnabledFlag(false) |
---|
2823 | , m_listsModificationPresentFlag (0) |
---|
2824 | , m_numExtraSliceHeaderBits (0) |
---|
2825 | #if NH_MV |
---|
2826 | , m_ppsInferScalingListFlag (false) |
---|
2827 | , m_ppsScalingListRefLayerId (0) |
---|
2828 | , m_pocResetInfoPresentFlag (false) |
---|
2829 | #if H_3D |
---|
2830 | , m_pcDLT(NULL) |
---|
2831 | #endif |
---|
2832 | #endif |
---|
2833 | |
---|
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 H_3D |
---|
2849 | TComDLT::TComDLT() |
---|
2850 | : m_bDltPresentFlag(false) |
---|
2851 | , m_iNumDepthViews(0) |
---|
2852 | , m_uiDepthViewBitDepth(8) |
---|
2853 | { |
---|
2854 | m_uiDepthViewBitDepth = g_bitDepthY; |
---|
2855 | |
---|
2856 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
2857 | { |
---|
2858 | m_bUseDLTFlag [i] = false; |
---|
2859 | m_bInterViewDltPredEnableFlag [i] = false; |
---|
2860 | |
---|
2861 | // allocate some memory and initialize with default mapping |
---|
2862 | m_iNumDepthmapValues[i] = ((1 << m_uiDepthViewBitDepth)-1)+1; |
---|
2863 | m_iDepthValue2Idx[i] = (Int*) xMalloc(Int, m_iNumDepthmapValues[i]); |
---|
2864 | m_iIdx2DepthValue[i] = (Int*) xMalloc(Int, m_iNumDepthmapValues[i]); |
---|
2865 | |
---|
2866 | //default mapping |
---|
2867 | for (Int d=0; d<m_iNumDepthmapValues[i]; d++) |
---|
2868 | { |
---|
2869 | m_iDepthValue2Idx[i][d] = d; |
---|
2870 | m_iIdx2DepthValue[i][d] = d; |
---|
2871 | } |
---|
2872 | } |
---|
2873 | } |
---|
2874 | |
---|
2875 | TComDLT::~TComDLT() |
---|
2876 | { |
---|
2877 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
2878 | { |
---|
2879 | if ( m_iDepthValue2Idx[i] != NULL ) |
---|
2880 | { |
---|
2881 | xFree( m_iDepthValue2Idx[i] ); |
---|
2882 | m_iDepthValue2Idx[i] = NULL; |
---|
2883 | } |
---|
2884 | |
---|
2885 | if ( m_iIdx2DepthValue[i] != NULL ) |
---|
2886 | { |
---|
2887 | xFree( m_iIdx2DepthValue[i] ); |
---|
2888 | m_iIdx2DepthValue[i] = NULL; |
---|
2889 | } |
---|
2890 | } |
---|
2891 | } |
---|
2892 | |
---|
2893 | Void TComDLT::setDepthLUTs(Int layerIdInVps, Int* idxToDepthValueTable, Int iNumDepthValues) |
---|
2894 | { |
---|
2895 | if( idxToDepthValueTable == NULL || iNumDepthValues == 0 ) // default mapping only |
---|
2896 | return; |
---|
2897 | |
---|
2898 | // copy idx2DepthValue to internal array |
---|
2899 | memcpy(m_iIdx2DepthValue[layerIdInVps], idxToDepthValueTable, iNumDepthValues*sizeof(UInt)); |
---|
2900 | |
---|
2901 | UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1); |
---|
2902 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
2903 | { |
---|
2904 | Int iIdxDown = 0; |
---|
2905 | Int iIdxUp = iNumDepthValues-1; |
---|
2906 | Bool bFound = false; |
---|
2907 | |
---|
2908 | // iterate over indices to find lower closest depth |
---|
2909 | Int i = 1; |
---|
2910 | while(!bFound && i<iNumDepthValues) |
---|
2911 | { |
---|
2912 | if( m_iIdx2DepthValue[layerIdInVps][i] > p ) |
---|
2913 | { |
---|
2914 | iIdxDown = i-1; |
---|
2915 | bFound = true; |
---|
2916 | } |
---|
2917 | |
---|
2918 | i++; |
---|
2919 | } |
---|
2920 | iIdxUp = bFound ? iIdxDown + 1 : iNumDepthValues-1; |
---|
2921 | |
---|
2922 | // assign closer depth value/idx |
---|
2923 | if( abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxDown]) < abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxUp]) ) |
---|
2924 | { |
---|
2925 | m_iDepthValue2Idx[layerIdInVps][p] = iIdxDown; |
---|
2926 | } |
---|
2927 | else |
---|
2928 | { |
---|
2929 | m_iDepthValue2Idx[layerIdInVps][p] = iIdxUp; |
---|
2930 | } |
---|
2931 | |
---|
2932 | } |
---|
2933 | |
---|
2934 | // update DLT variables |
---|
2935 | m_iNumDepthmapValues[layerIdInVps] = iNumDepthValues; |
---|
2936 | } |
---|
2937 | |
---|
2938 | Void TComDLT::getDeltaDLT( Int layerIdInVps, Int* piDLTInRef, UInt uiDLTInRefNum, Int* piDeltaDLTOut, UInt *puiDeltaDLTOutNum ) |
---|
2939 | { |
---|
2940 | Bool abBM0[ 256 ]; |
---|
2941 | Bool abBM1[ 256 ]; |
---|
2942 | |
---|
2943 | memset( abBM0, 0, sizeof( abBM0 )); |
---|
2944 | memset( abBM1, 0, sizeof( abBM1 )); |
---|
2945 | |
---|
2946 | // convert reference DLT to bit string |
---|
2947 | for( Int i = 0; i < uiDLTInRefNum; i++ ) |
---|
2948 | { |
---|
2949 | abBM0[ piDLTInRef[ i ] ] = true; |
---|
2950 | } |
---|
2951 | // convert internal DLT to bit string |
---|
2952 | for( Int i = 0; i < m_iNumDepthmapValues[ layerIdInVps ]; i++ ) |
---|
2953 | { |
---|
2954 | abBM1[ m_iIdx2DepthValue[ layerIdInVps ][ i ] ] = true; |
---|
2955 | } |
---|
2956 | |
---|
2957 | *puiDeltaDLTOutNum = 0; |
---|
2958 | for( Int i = 0; i < 256; i++ ) |
---|
2959 | { |
---|
2960 | if( abBM0[ i ] ^ abBM1[ i ] ) |
---|
2961 | { |
---|
2962 | piDeltaDLTOut[ *puiDeltaDLTOutNum ] = i; |
---|
2963 | *puiDeltaDLTOutNum = *puiDeltaDLTOutNum + 1; |
---|
2964 | } |
---|
2965 | } |
---|
2966 | } |
---|
2967 | |
---|
2968 | Void TComDLT::setDeltaDLT( Int layerIdInVps, Int* piDLTInRef, UInt uiDLTInRefNum, Int* piDeltaDLTIn, UInt uiDeltaDLTInNum ) |
---|
2969 | { |
---|
2970 | Bool abBM0[ 256 ]; |
---|
2971 | Bool abBM1[ 256 ]; |
---|
2972 | |
---|
2973 | memset( abBM0, 0, sizeof( abBM0 )); |
---|
2974 | memset( abBM1, 0, sizeof( abBM1 )); |
---|
2975 | |
---|
2976 | // convert reference DLT to bit string |
---|
2977 | for( Int i = 0; i < uiDLTInRefNum; i++ ) |
---|
2978 | { |
---|
2979 | abBM0[ piDLTInRef[ i ] ] = true; |
---|
2980 | } |
---|
2981 | // convert delta DLT to bit string |
---|
2982 | for( Int i = 0; i < uiDeltaDLTInNum; i++ ) |
---|
2983 | { |
---|
2984 | abBM1[ piDeltaDLTIn[ i ] ] = true; |
---|
2985 | } |
---|
2986 | |
---|
2987 | Int aiIdx2DepthValue[256]; |
---|
2988 | UInt uiNumDepthValues = 0; |
---|
2989 | memset( aiIdx2DepthValue, 0, sizeof( aiIdx2DepthValue )); |
---|
2990 | |
---|
2991 | for( Int i = 0; i < 256; i++ ) |
---|
2992 | { |
---|
2993 | if( abBM0[ i ] ^ abBM1[ i ] ) |
---|
2994 | { |
---|
2995 | aiIdx2DepthValue[ uiNumDepthValues++ ] = i; |
---|
2996 | } |
---|
2997 | } |
---|
2998 | |
---|
2999 | // update internal tables |
---|
3000 | setDepthLUTs(layerIdInVps, aiIdx2DepthValue, uiNumDepthValues); |
---|
3001 | } |
---|
3002 | |
---|
3003 | #endif |
---|
3004 | |
---|
3005 | #if NH_MV |
---|
3006 | Void TComSPS::inferRepFormat( TComVPS* vps, Int layerIdCurr, Bool encoder ) |
---|
3007 | { |
---|
3008 | if ( getMultiLayerExtSpsFlag() ) |
---|
3009 | { |
---|
3010 | Int repFormatIdx = getUpdateRepFormatFlag() ? getSpsRepFormatIdx() : vps->getVpsRepFormatIdx( vps->getLayerIdInVps( layerIdCurr ) ) ; |
---|
3011 | const TComRepFormat* repFormat = vps->getRepFormat( repFormatIdx ); |
---|
3012 | |
---|
3013 | if ( encoder ) |
---|
3014 | { |
---|
3015 | assert( getChromaFormatIdc() == (ChromaFormat) repFormat->getChromaFormatVpsIdc() ); |
---|
3016 | //// ToDo: add when supported: |
---|
3017 | // assert( getSeperateColourPlaneFlag( repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
3018 | |
---|
3019 | assert( getPicWidthInLumaSamples() == repFormat->getPicWidthVpsInLumaSamples() ); |
---|
3020 | assert( getPicHeightInLumaSamples() == repFormat->getPicHeightVpsInLumaSamples() ); |
---|
3021 | |
---|
3022 | assert( getBitDepth ( CHANNEL_TYPE_LUMA ) == repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
3023 | assert( getQpBDOffset ( CHANNEL_TYPE_LUMA ) == (Int) (6*( getBitDepth( CHANNEL_TYPE_LUMA ) - 8 )) ); |
---|
3024 | |
---|
3025 | assert( getBitDepth ( CHANNEL_TYPE_CHROMA ) == repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
3026 | assert( getQpBDOffset ( CHANNEL_TYPE_CHROMA ) == (Int) (6* ( getBitDepth( CHANNEL_TYPE_CHROMA ) -8 ) ) ); |
---|
3027 | } |
---|
3028 | else |
---|
3029 | { |
---|
3030 | setChromaFormatIdc( (ChromaFormat) repFormat->getChromaFormatVpsIdc() ); |
---|
3031 | //// ToDo: add when supported: |
---|
3032 | // setSeperateColourPlaneFlag( repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
3033 | |
---|
3034 | setPicWidthInLumaSamples ( repFormat->getPicWidthVpsInLumaSamples() ); |
---|
3035 | setPicHeightInLumaSamples( repFormat->getPicHeightVpsInLumaSamples() ); |
---|
3036 | |
---|
3037 | setBitDepth ( CHANNEL_TYPE_LUMA, repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
3038 | setQpBDOffset ( CHANNEL_TYPE_LUMA, (Int) (6*( getBitDepth( CHANNEL_TYPE_LUMA ) - 8 )) ); |
---|
3039 | |
---|
3040 | setBitDepth ( CHANNEL_TYPE_CHROMA, repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
3041 | setQpBDOffset ( CHANNEL_TYPE_CHROMA, (Int) (6* ( getBitDepth( CHANNEL_TYPE_CHROMA ) -8 ) ) ); |
---|
3042 | Window &spsConf = getConformanceWindow(); |
---|
3043 | |
---|
3044 | // Scaled later |
---|
3045 | spsConf.setScaledFlag( false ); |
---|
3046 | spsConf.setWindowLeftOffset ( repFormat->getConfWinVpsLeftOffset() ); |
---|
3047 | spsConf.setWindowRightOffset ( repFormat->getConfWinVpsRightOffset() ); |
---|
3048 | spsConf.setWindowTopOffset ( repFormat->getConfWinVpsTopOffset() ); |
---|
3049 | spsConf.setWindowBottomOffset( repFormat->getConfWinVpsBottomOffset() ); |
---|
3050 | } |
---|
3051 | |
---|
3052 | if ( getMultiLayerExtSpsFlag() && getUpdateRepFormatFlag() ) |
---|
3053 | { |
---|
3054 | assert( getChromaFormatIdc() <= repFormat->getChromaFormatVpsIdc() ); |
---|
3055 | //// ToDo: add when supported: |
---|
3056 | // assert( getSeperateColourPlaneFlag() <= repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
3057 | |
---|
3058 | assert( getPicWidthInLumaSamples() <= repFormat->getPicWidthVpsInLumaSamples() ); |
---|
3059 | assert( getPicHeightInLumaSamples() <= repFormat->getPicHeightVpsInLumaSamples() ); |
---|
3060 | |
---|
3061 | assert( getBitDepth( CHANNEL_TYPE_LUMA ) <= repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
3062 | assert( getBitDepth( CHANNEL_TYPE_CHROMA ) <= repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
3063 | } |
---|
3064 | } |
---|
3065 | |
---|
3066 | // Set conformance window |
---|
3067 | Int scal = TComSPS::getWinUnitX( getChromaFormatIdc() ) ; |
---|
3068 | getConformanceWindow().scaleOffsets( scal ); |
---|
3069 | getVuiParameters()->getDefaultDisplayWindow().scaleOffsets( scal ); |
---|
3070 | |
---|
3071 | if (encoder && getMultiLayerExtSpsFlag() ) |
---|
3072 | { |
---|
3073 | Int repFormatIdx = getUpdateRepFormatFlag() ? getSpsRepFormatIdx() : vps->getVpsRepFormatIdx( vps->getLayerIdInVps( layerIdCurr ) ) ; |
---|
3074 | const TComRepFormat* repFormat = vps->getRepFormat( repFormatIdx ); |
---|
3075 | |
---|
3076 | Window &spsConf = getConformanceWindow(); |
---|
3077 | assert( spsConf.getWindowLeftOffset () == repFormat->getConfWinVpsLeftOffset() ); |
---|
3078 | assert( spsConf.getWindowRightOffset () == repFormat->getConfWinVpsRightOffset() ); |
---|
3079 | assert( spsConf.getWindowTopOffset () == repFormat->getConfWinVpsTopOffset() ); |
---|
3080 | assert( spsConf.getWindowBottomOffset() == repFormat->getConfWinVpsBottomOffset() ); |
---|
3081 | } |
---|
3082 | } |
---|
3083 | |
---|
3084 | Void TComSPS::inferScalingList( const TComSPS* spsSrc ) |
---|
3085 | { |
---|
3086 | if ( getSpsInferScalingListFlag() ) |
---|
3087 | { |
---|
3088 | assert( spsSrc != NULL ); |
---|
3089 | assert( !spsSrc->getSpsInferScalingListFlag() ); |
---|
3090 | getScalingList().inferFrom( (spsSrc->getScalingList()) ); |
---|
3091 | } |
---|
3092 | } |
---|
3093 | |
---|
3094 | Void TComSPS::inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder ) |
---|
3095 | { |
---|
3096 | const std::vector<Int>& targetDecLayerIdList = vps->getTargetDecLayerIdList( vps->olsIdxToLsIdx( targetOptLayerSetIdx )); |
---|
3097 | |
---|
3098 | if ( getMultiLayerExtSpsFlag() ) |
---|
3099 | { |
---|
3100 | Int layerIdx = 0; |
---|
3101 | while (layerIdx < (Int) targetDecLayerIdList.size() ) |
---|
3102 | { |
---|
3103 | if ( targetDecLayerIdList[layerIdx] == currLayerId ) |
---|
3104 | { |
---|
3105 | break; |
---|
3106 | } |
---|
3107 | layerIdx++; |
---|
3108 | } |
---|
3109 | |
---|
3110 | assert( layerIdx < (Int) targetDecLayerIdList.size() ); |
---|
3111 | |
---|
3112 | for (Int i = 0; i <= getSpsMaxSubLayersMinus1(); i++ ) |
---|
3113 | { |
---|
3114 | Int maxDecPicBufferingMinus1 = vps->getDpbSize()->getMaxVpsDecPicBufferingMinus1( targetOptLayerSetIdx, layerIdx, i ) ; |
---|
3115 | |
---|
3116 | // This preliminary fix needs to be checked. |
---|
3117 | Int maxNumReorderPics = vps->getDpbSize()->getMaxVpsNumReorderPics( targetOptLayerSetIdx, i ); |
---|
3118 | Int maxLatencyIncreasePlus1 = vps->getDpbSize()->getMaxVpsLatencyIncreasePlus1( targetOptLayerSetIdx, i ); |
---|
3119 | if ( encoder ) |
---|
3120 | { |
---|
3121 | assert( getMaxDecPicBuffering( i ) - 1 == maxDecPicBufferingMinus1 ); |
---|
3122 | // This preliminary fix needs to be checked. |
---|
3123 | assert( getNumReorderPics( i ) == maxNumReorderPics ); |
---|
3124 | assert( getMaxLatencyIncrease( i ) == maxLatencyIncreasePlus1 ); |
---|
3125 | |
---|
3126 | } |
---|
3127 | else |
---|
3128 | { |
---|
3129 | // This preliminary fix needs to be checked. |
---|
3130 | setMaxDecPicBuffering( maxDecPicBufferingMinus1 + 1 , i); |
---|
3131 | setNumReorderPics ( maxNumReorderPics, i ); |
---|
3132 | setMaxLatencyIncrease( maxLatencyIncreasePlus1 - 1 , i); |
---|
3133 | } |
---|
3134 | } |
---|
3135 | } |
---|
3136 | } |
---|
3137 | |
---|
3138 | Void TComSPS::checkRpsMaxNumPics( const TComVPS* vps, Int currLayerId ) const |
---|
3139 | { |
---|
3140 | for (Int i = 0; i < getRPSList()->getNumberOfReferencePictureSets(); i++ ) |
---|
3141 | { |
---|
3142 | const TComReferencePictureSet* rps = getRPSList()->getReferencePictureSet( i ); |
---|
3143 | if ( !rps->getInterRPSPrediction() ) |
---|
3144 | { |
---|
3145 | rps->checkMaxNumPics( vps->getVpsExtensionFlag(), MAX_INT, getLayerId(), getMaxDecPicBuffering( getSpsMaxSubLayersMinus1() ) - 1 ); // INT_MAX to be replaced by DpbSize |
---|
3146 | } |
---|
3147 | } |
---|
3148 | } |
---|
3149 | |
---|
3150 | Void TComSPS::inferSpsMaxSubLayersMinus1(Bool atPsActivation, TComVPS* vps) |
---|
3151 | { |
---|
3152 | assert( getLayerId() != 0 ); |
---|
3153 | if ( !atPsActivation ) |
---|
3154 | { |
---|
3155 | assert( vps == NULL ); |
---|
3156 | if (getSpsExtOrMaxSubLayersMinus1() != 7) |
---|
3157 | { |
---|
3158 | setSpsMaxSubLayersMinus1( getSpsExtOrMaxSubLayersMinus1() ); |
---|
3159 | } |
---|
3160 | } |
---|
3161 | else |
---|
3162 | { |
---|
3163 | assert( vps != NULL ); |
---|
3164 | if (getSpsExtOrMaxSubLayersMinus1() == 7) |
---|
3165 | { |
---|
3166 | setSpsMaxSubLayersMinus1( vps->getMaxSubLayersMinus1() ); |
---|
3167 | } |
---|
3168 | } |
---|
3169 | } |
---|
3170 | #endif |
---|
3171 | |
---|
3172 | |
---|
3173 | TComReferencePictureSet::TComReferencePictureSet() |
---|
3174 | : m_numberOfPictures (0) |
---|
3175 | , m_numberOfNegativePictures (0) |
---|
3176 | , m_numberOfPositivePictures (0) |
---|
3177 | , m_numberOfLongtermPictures (0) |
---|
3178 | , m_interRPSPrediction (0) |
---|
3179 | , m_deltaRIdxMinus1 (0) |
---|
3180 | , m_deltaRPS (0) |
---|
3181 | , m_numRefIdc (0) |
---|
3182 | { |
---|
3183 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
3184 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
3185 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
3186 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
3187 | ::memset( m_bCheckLTMSB, 0, sizeof(m_bCheckLTMSB) ); |
---|
3188 | ::memset( m_pocLSBLT, 0, sizeof(m_pocLSBLT) ); |
---|
3189 | ::memset( m_deltaPOCMSBCycleLT, 0, sizeof(m_deltaPOCMSBCycleLT) ); |
---|
3190 | ::memset( m_deltaPocMSBPresentFlag, 0, sizeof(m_deltaPocMSBPresentFlag) ); |
---|
3191 | } |
---|
3192 | |
---|
3193 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
3194 | { |
---|
3195 | } |
---|
3196 | |
---|
3197 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
3198 | { |
---|
3199 | m_used[bufferNum] = used; |
---|
3200 | } |
---|
3201 | |
---|
3202 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
3203 | { |
---|
3204 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
3205 | } |
---|
3206 | |
---|
3207 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
3208 | { |
---|
3209 | m_numberOfPictures = numberOfPictures; |
---|
3210 | } |
---|
3211 | |
---|
3212 | Int TComReferencePictureSet::getUsed(Int bufferNum) const |
---|
3213 | { |
---|
3214 | return m_used[bufferNum]; |
---|
3215 | } |
---|
3216 | |
---|
3217 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) const |
---|
3218 | { |
---|
3219 | return m_deltaPOC[bufferNum]; |
---|
3220 | } |
---|
3221 | |
---|
3222 | Int TComReferencePictureSet::getNumberOfPictures() const |
---|
3223 | { |
---|
3224 | return m_numberOfPictures; |
---|
3225 | } |
---|
3226 | |
---|
3227 | Int TComReferencePictureSet::getPOC(Int bufferNum) const |
---|
3228 | { |
---|
3229 | return m_POC[bufferNum]; |
---|
3230 | } |
---|
3231 | |
---|
3232 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
3233 | { |
---|
3234 | m_POC[bufferNum] = POC; |
---|
3235 | } |
---|
3236 | |
---|
3237 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) const |
---|
3238 | { |
---|
3239 | return m_bCheckLTMSB[bufferNum]; |
---|
3240 | } |
---|
3241 | |
---|
3242 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
3243 | { |
---|
3244 | m_bCheckLTMSB[bufferNum] = b; |
---|
3245 | } |
---|
3246 | |
---|
3247 | //! set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
3248 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
3249 | { |
---|
3250 | m_refIdc[bufferNum] = refIdc; |
---|
3251 | } |
---|
3252 | |
---|
3253 | //! get the reference idc value at uiBufferNum |
---|
3254 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) const |
---|
3255 | { |
---|
3256 | return m_refIdc[bufferNum]; |
---|
3257 | } |
---|
3258 | |
---|
3259 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
3260 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
3261 | * +ve values are in increasing order. |
---|
3262 | * \returns Void |
---|
3263 | */ |
---|
3264 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
3265 | { |
---|
3266 | // sort in increasing order (smallest first) |
---|
3267 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
3268 | { |
---|
3269 | Int deltaPOC = getDeltaPOC(j); |
---|
3270 | Bool used = getUsed(j); |
---|
3271 | for (Int k=j-1; k >= 0; k--) |
---|
3272 | { |
---|
3273 | Int temp = getDeltaPOC(k); |
---|
3274 | if (deltaPOC < temp) |
---|
3275 | { |
---|
3276 | setDeltaPOC(k+1, temp); |
---|
3277 | setUsed(k+1, getUsed(k)); |
---|
3278 | setDeltaPOC(k, deltaPOC); |
---|
3279 | setUsed(k, used); |
---|
3280 | } |
---|
3281 | } |
---|
3282 | } |
---|
3283 | // flip the negative values to largest first |
---|
3284 | Int numNegPics = getNumberOfNegativePictures(); |
---|
3285 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
3286 | { |
---|
3287 | Int deltaPOC = getDeltaPOC(j); |
---|
3288 | Bool used = getUsed(j); |
---|
3289 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
3290 | setUsed(j, getUsed(k)); |
---|
3291 | setDeltaPOC(k, deltaPOC); |
---|
3292 | setUsed(k, used); |
---|
3293 | } |
---|
3294 | } |
---|
3295 | |
---|
3296 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
3297 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
3298 | * \returns Void |
---|
3299 | */ |
---|
3300 | Void TComReferencePictureSet::printDeltaPOC() const |
---|
3301 | { |
---|
3302 | printf("DeltaPOC = { "); |
---|
3303 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
3304 | { |
---|
3305 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
3306 | } |
---|
3307 | if (getInterRPSPrediction()) |
---|
3308 | { |
---|
3309 | printf("}, RefIdc = { "); |
---|
3310 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
3311 | { |
---|
3312 | printf("%d ", getRefIdc(j)); |
---|
3313 | } |
---|
3314 | } |
---|
3315 | printf("}\n"); |
---|
3316 | } |
---|
3317 | |
---|
3318 | #if NH_MV |
---|
3319 | Void TComReferencePictureSet::checkMaxNumPics( Bool vpsExtensionFlag, Int maxNumPics, Int nuhLayerId, Int spsMaxDecPicBufferingMinus1 ) const |
---|
3320 | { |
---|
3321 | assert( getNumberOfPictures() >= 0 ); |
---|
3322 | if ( nuhLayerId == 0 ) |
---|
3323 | { |
---|
3324 | assert( getNumberOfPictures() <= spsMaxDecPicBufferingMinus1 ); |
---|
3325 | } |
---|
3326 | |
---|
3327 | if ( vpsExtensionFlag ) |
---|
3328 | { |
---|
3329 | assert( getNumberOfPictures() <= maxNumPics ); |
---|
3330 | } |
---|
3331 | } |
---|
3332 | #endif |
---|
3333 | |
---|
3334 | |
---|
3335 | |
---|
3336 | |
---|
3337 | TComRefPicListModification::TComRefPicListModification() |
---|
3338 | : m_refPicListModificationFlagL0 (false) |
---|
3339 | , m_refPicListModificationFlagL1 (false) |
---|
3340 | { |
---|
3341 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
3342 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
3343 | } |
---|
3344 | |
---|
3345 | TComRefPicListModification::~TComRefPicListModification() |
---|
3346 | { |
---|
3347 | } |
---|
3348 | |
---|
3349 | TComScalingList::TComScalingList() |
---|
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 | m_scalingListCoef[sizeId][listId].resize(min<Int>(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
3356 | } |
---|
3357 | } |
---|
3358 | } |
---|
3359 | |
---|
3360 | /** set default quantization matrix to array |
---|
3361 | */ |
---|
3362 | Void TComScalingList::setDefaultScalingList() |
---|
3363 | { |
---|
3364 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3365 | { |
---|
3366 | for(UInt listId=0;listId<SCALING_LIST_NUM;listId++) |
---|
3367 | { |
---|
3368 | processDefaultMatrix(sizeId, listId); |
---|
3369 | } |
---|
3370 | } |
---|
3371 | } |
---|
3372 | /** check if use default quantization matrix |
---|
3373 | * \returns true if use default quantization matrix in all size |
---|
3374 | */ |
---|
3375 | Bool TComScalingList::checkDefaultScalingList() |
---|
3376 | { |
---|
3377 | UInt defaultCounter=0; |
---|
3378 | |
---|
3379 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3380 | { |
---|
3381 | for(UInt listId=0;listId<SCALING_LIST_NUM;listId++) |
---|
3382 | { |
---|
3383 | if( !memcmp(getScalingListAddress(sizeId,listId), getScalingListDefaultAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
3384 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
3385 | { |
---|
3386 | defaultCounter++; |
---|
3387 | } |
---|
3388 | } |
---|
3389 | } |
---|
3390 | |
---|
3391 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM )) ? false : true; |
---|
3392 | } |
---|
3393 | |
---|
3394 | #if NH_MV |
---|
3395 | Void TComSlice::createInterLayerReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1 ) |
---|
3396 | { |
---|
3397 | refPicSetInterLayer0.clear(); |
---|
3398 | refPicSetInterLayer1.clear(); |
---|
3399 | |
---|
3400 | for( Int i = 0; i < getNumActiveRefLayerPics(); i++ ) |
---|
3401 | { |
---|
3402 | Int layerIdRef = getRefPicLayerId( i ); |
---|
3403 | TComPic* picRef = ivPicLists->getPic( layerIdRef, getPOC() ) ; |
---|
3404 | assert ( picRef != 0 ); // There shall be no entry equal to "no reference picture" in RefPicSetInterLayer0 or RefPicSetInterLayer1. |
---|
3405 | |
---|
3406 | picRef->getPicYuvRec()->extendPicBorder(); |
---|
3407 | picRef->setIsLongTerm( true ); |
---|
3408 | picRef->getSlice(0)->setReferenced( true ); |
---|
3409 | |
---|
3410 | Int viewIdCur = getVPS()->getViewId( getLayerId() ); |
---|
3411 | Int viewIdZero = getVPS()->getViewId( 0 ); |
---|
3412 | Int viewIdRef = getVPS()->getViewId( layerIdRef ); |
---|
3413 | |
---|
3414 | if ( ( viewIdCur <= viewIdZero && viewIdCur <= viewIdRef ) || ( viewIdCur >= viewIdZero && viewIdCur >= viewIdRef ) ) |
---|
3415 | { |
---|
3416 | refPicSetInterLayer0.push_back( picRef ); |
---|
3417 | } |
---|
3418 | else |
---|
3419 | { |
---|
3420 | refPicSetInterLayer1.push_back( picRef ); |
---|
3421 | } |
---|
3422 | // Consider to check here: |
---|
3423 | // "If the current picture is a RADL picture, there shall be no entry in the RefPicSetInterLayer0 and RefPicSetInterLayer1 that is a RASL picture. " |
---|
3424 | assert( picRef->getSlice(0)->getDiscardableFlag() == false ); // "There shall be no picture that has discardable_flag equal to 1 in RefPicSetInterLayer0 or RefPicSetInterLayer1". |
---|
3425 | } |
---|
3426 | } |
---|
3427 | |
---|
3428 | Void TComSlice::markIvRefPicsAsShortTerm( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 ) |
---|
3429 | { |
---|
3430 | // Mark as short-term |
---|
3431 | for ( Int i = 0; i < refPicSetInterLayer0.size(); i++ ) |
---|
3432 | { |
---|
3433 | refPicSetInterLayer0[i]->setIsLongTerm( false ); |
---|
3434 | } |
---|
3435 | |
---|
3436 | for ( Int i = 0; i < refPicSetInterLayer1.size(); i++ ) |
---|
3437 | { |
---|
3438 | refPicSetInterLayer1[i]->setIsLongTerm( false ); |
---|
3439 | } |
---|
3440 | |
---|
3441 | } |
---|
3442 | |
---|
3443 | Void TComSlice::printRefPicList() |
---|
3444 | { |
---|
3445 | for ( Int li = 0; li < 2; li++) |
---|
3446 | { |
---|
3447 | std::cout << std::endl << "RefPicListL" << li << ":" << std::endl; |
---|
3448 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[li]-1); rIdx ++) |
---|
3449 | { |
---|
3450 | if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( true ); |
---|
3451 | |
---|
3452 | m_apcRefPicList[li][rIdx]->print( false ); |
---|
3453 | } |
---|
3454 | } |
---|
3455 | } |
---|
3456 | |
---|
3457 | Void TComSlice::markCurrPic( TComPic* currPic ) |
---|
3458 | { |
---|
3459 | currPic->getSlice(0)->setReferenced( true ) ; |
---|
3460 | currPic->setIsLongTerm( false ); |
---|
3461 | |
---|
3462 | currPic->setReconMark( true ); |
---|
3463 | currPic->setPicOutputFlag( currPic->getSlice(0)->getPicOutputFlag() ); |
---|
3464 | } |
---|
3465 | |
---|
3466 | Void TComSlice::setRefPicSetInterLayer( std::vector<TComPic*>* refPicSetInterLayer0, std::vector<TComPic*>* refPicSetInterLayer1 ) |
---|
3467 | { |
---|
3468 | m_refPicSetInterLayer0 = refPicSetInterLayer0; |
---|
3469 | m_refPicSetInterLayer1 = refPicSetInterLayer1; |
---|
3470 | } |
---|
3471 | |
---|
3472 | TComPic* TComSlice::getPicFromRefPicSetInterLayer(Int setIdc, Int layerId ) const |
---|
3473 | { |
---|
3474 | assert ( setIdc == 0 || setIdc == 1); |
---|
3475 | std::vector<TComPic*>* refPicSetInterLayer = ( setIdc == 0 ? m_refPicSetInterLayer0 : m_refPicSetInterLayer1); |
---|
3476 | assert( refPicSetInterLayer != 0 ); |
---|
3477 | |
---|
3478 | TComPic* pcPic = NULL; |
---|
3479 | for ( Int i = 0; i < (*refPicSetInterLayer).size(); i++ ) |
---|
3480 | { |
---|
3481 | if ((*refPicSetInterLayer)[ i ]->getLayerId() == layerId ) |
---|
3482 | { |
---|
3483 | pcPic = (*refPicSetInterLayer)[ i ]; |
---|
3484 | } |
---|
3485 | } |
---|
3486 | |
---|
3487 | assert(pcPic != NULL); |
---|
3488 | return pcPic; |
---|
3489 | } |
---|
3490 | |
---|
3491 | |
---|
3492 | Int TComSlice::getRefLayerPicFlag( Int i ) const |
---|
3493 | { |
---|
3494 | const TComVPS* vps = getVPS(); |
---|
3495 | #if NH_3D |
---|
3496 | Int refLayerIdx = vps->getLayerIdInVps( vps->getIdRefListLayer( getLayerId(), i ) ); |
---|
3497 | #else |
---|
3498 | Int refLayerIdx = vps->getLayerIdInVps( vps->getIdDirectRefLayer( getLayerId(), i ) ); |
---|
3499 | #endif |
---|
3500 | |
---|
3501 | Bool refLayerPicFlag = ( vps->getSubLayersVpsMaxMinus1( refLayerIdx ) >= getTLayer() && ( getTLayer() == 0 || |
---|
3502 | vps->getMaxTidIlRefPicsPlus1( refLayerIdx, vps->getLayerIdInVps( getLayerId() )) > getTLayer() )); |
---|
3503 | return refLayerPicFlag; |
---|
3504 | } |
---|
3505 | |
---|
3506 | Int TComSlice::getRefLayerPicIdc( Int j ) const |
---|
3507 | { |
---|
3508 | Int refLayerPicIdc = -1; |
---|
3509 | Int curj = 0; |
---|
3510 | #if NH_3D |
---|
3511 | for( Int i = 0; i < getVPS()->getNumRefListLayers( getLayerId()) ; i++ ) |
---|
3512 | #else |
---|
3513 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ ) |
---|
3514 | #endif |
---|
3515 | { |
---|
3516 | if( getRefLayerPicFlag( i ) ) |
---|
3517 | { |
---|
3518 | if ( curj == j ) |
---|
3519 | { |
---|
3520 | refLayerPicIdc = i; |
---|
3521 | break; |
---|
3522 | } |
---|
3523 | curj++; |
---|
3524 | } |
---|
3525 | } |
---|
3526 | |
---|
3527 | assert( curj == j ); |
---|
3528 | assert( refLayerPicIdc != -1 ); |
---|
3529 | return refLayerPicIdc; |
---|
3530 | } |
---|
3531 | |
---|
3532 | Int TComSlice::getNumRefLayerPics( ) const |
---|
3533 | { |
---|
3534 | Int numRefLayerPics = 0; |
---|
3535 | #if NH_3D |
---|
3536 | for( Int i = 0; i < getVPS()->getNumRefListLayers( getLayerId()) ; i++ ) |
---|
3537 | #else |
---|
3538 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ ) |
---|
3539 | #endif |
---|
3540 | { |
---|
3541 | numRefLayerPics += getRefLayerPicFlag( i ); |
---|
3542 | } |
---|
3543 | return numRefLayerPics; |
---|
3544 | } |
---|
3545 | |
---|
3546 | |
---|
3547 | |
---|
3548 | Int TComSlice::getNumActiveRefLayerPics() const |
---|
3549 | { |
---|
3550 | Int numActiveRefLayerPics; |
---|
3551 | |
---|
3552 | if( getLayerId() == 0 || getNumRefLayerPics() == 0 ) |
---|
3553 | { |
---|
3554 | numActiveRefLayerPics = 0; |
---|
3555 | } |
---|
3556 | else if (getVPS()->getAllRefLayersActiveFlag() ) |
---|
3557 | { |
---|
3558 | numActiveRefLayerPics = getNumRefLayerPics(); |
---|
3559 | } |
---|
3560 | else if ( !getInterLayerPredEnabledFlag() ) |
---|
3561 | { |
---|
3562 | numActiveRefLayerPics = 0; |
---|
3563 | } |
---|
3564 | #if NH_3D |
---|
3565 | else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumRefListLayers( getLayerId() ) == 1 ) |
---|
3566 | #else |
---|
3567 | else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumDirectRefLayers( getLayerId() ) == 1 ) |
---|
3568 | #endif |
---|
3569 | { |
---|
3570 | numActiveRefLayerPics = 1; |
---|
3571 | } |
---|
3572 | else |
---|
3573 | { |
---|
3574 | numActiveRefLayerPics = getNumInterLayerRefPicsMinus1() + 1; |
---|
3575 | } |
---|
3576 | return numActiveRefLayerPics; |
---|
3577 | } |
---|
3578 | |
---|
3579 | Int TComSlice::getRefPicLayerId( Int i ) const |
---|
3580 | { |
---|
3581 | #if NH_3D |
---|
3582 | return getVPS()->getIdRefListLayer( getLayerId(), getInterLayerPredLayerIdc( i ) ); |
---|
3583 | #else |
---|
3584 | return getVPS()->getIdDirectRefLayer( getLayerId(), getInterLayerPredLayerIdc( i ) ); |
---|
3585 | #endif |
---|
3586 | } |
---|
3587 | #if NH_3D_NBDV |
---|
3588 | Void TComSlice::setDefaultRefView() |
---|
3589 | { |
---|
3590 | setDefaultRefViewIdx(-1); |
---|
3591 | setDefaultRefViewIdxAvailableFlag(false); |
---|
3592 | |
---|
3593 | Int valid = 0; |
---|
3594 | Int DefaultRefViewIdx = -1; |
---|
3595 | |
---|
3596 | for(UInt curViewIdx = 0; curViewIdx < getViewIndex() && valid == 0; curViewIdx++) |
---|
3597 | { |
---|
3598 | for(Int iRefListId = 0; (iRefListId < (isInterB() ? 2 : 1)) && !isIntra() && valid == 0; iRefListId++) |
---|
3599 | { |
---|
3600 | RefPicList eRefPicList = RefPicList(iRefListId); |
---|
3601 | Int iNumRefPics = getNumRefIdx(eRefPicList); |
---|
3602 | |
---|
3603 | for(Int i = 0; i < iNumRefPics; i++) |
---|
3604 | { |
---|
3605 | if(getPOC() == getRefPic(eRefPicList, i)->getPOC() && curViewIdx == getRefPic(eRefPicList, i)->getViewIndex()) |
---|
3606 | { |
---|
3607 | valid = 1; |
---|
3608 | DefaultRefViewIdx = curViewIdx; |
---|
3609 | break; |
---|
3610 | } |
---|
3611 | } |
---|
3612 | } |
---|
3613 | } |
---|
3614 | |
---|
3615 | if(valid) |
---|
3616 | { |
---|
3617 | setDefaultRefViewIdx(DefaultRefViewIdx); |
---|
3618 | setDefaultRefViewIdxAvailableFlag(true); |
---|
3619 | } |
---|
3620 | } |
---|
3621 | #endif |
---|
3622 | |
---|
3623 | #if H_3D_ARP |
---|
3624 | Void TComSlice::setARPStepNum( TComPicLists*ivPicLists ) |
---|
3625 | { |
---|
3626 | Bool tempRefPicInListsFlag = false; |
---|
3627 | if( !getIvResPredFlag() || this->isIRAP()) |
---|
3628 | { |
---|
3629 | m_nARPStepNum = 0; |
---|
3630 | } |
---|
3631 | else |
---|
3632 | { |
---|
3633 | setFirstTRefIdx (REF_PIC_LIST_0, -1); |
---|
3634 | setFirstTRefIdx (REF_PIC_LIST_1, -1); |
---|
3635 | for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ ) |
---|
3636 | { |
---|
3637 | Int diffPOC=MAX_INT; |
---|
3638 | Int idx=-1; |
---|
3639 | for(Int i = 0; i < getNumRefIdx(RefPicList(refListIdx)); i++ ) |
---|
3640 | { |
---|
3641 | if ( getRefPic(RefPicList(refListIdx), i)->getPOC() != getPOC() ) |
---|
3642 | { |
---|
3643 | if( abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC()) < diffPOC) |
---|
3644 | { |
---|
3645 | diffPOC=abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC()); |
---|
3646 | idx=i; |
---|
3647 | } |
---|
3648 | } |
---|
3649 | if(idx>=0) |
---|
3650 | { |
---|
3651 | setFirstTRefIdx (RefPicList(refListIdx), idx); |
---|
3652 | } |
---|
3653 | } |
---|
3654 | } |
---|
3655 | tempRefPicInListsFlag = (getFirstTRefIdx(REF_PIC_LIST_0) >= 0 || getFirstTRefIdx(REF_PIC_LIST_1) >= 0) && getDefaultRefViewIdxAvailableFlag(); |
---|
3656 | m_nARPStepNum = tempRefPicInListsFlag ? H_3D_ARP_WFNR : 0; |
---|
3657 | } |
---|
3658 | |
---|
3659 | if (tempRefPicInListsFlag) |
---|
3660 | { |
---|
3661 | for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ ) |
---|
3662 | { |
---|
3663 | RefPicList eRefPicList = RefPicList( refListIdx ); |
---|
3664 | Int prevPOC = getRefPic(eRefPicList, getFirstTRefIdx(eRefPicList) )->getPOC(); |
---|
3665 | for( Int i = 0; i < getNumActiveRefLayerPics(); i++ ) |
---|
3666 | { |
---|
3667 | Int layerIdInNuh = getRefPicLayerId( i ); |
---|
3668 | |
---|
3669 | TComPic* picV = getIvPic( getIsDepth(), getVPS()->getViewIndex( layerIdInNuh ) ); |
---|
3670 | assert( picV != NULL ); |
---|
3671 | IntAry1d pocsInCurrRPSsPicV = picV->getSlice(0)->getPocsInCurrRPSs(); |
---|
3672 | Bool refRpRefAvailFlag = false; |
---|
3673 | for (Int idx = 0; idx < pocsInCurrRPSsPicV.size(); idx++) |
---|
3674 | { |
---|
3675 | if ( pocsInCurrRPSsPicV[idx] == prevPOC ) |
---|
3676 | { |
---|
3677 | refRpRefAvailFlag = true; |
---|
3678 | break; |
---|
3679 | } |
---|
3680 | } |
---|
3681 | |
---|
3682 | if (getFirstTRefIdx(eRefPicList) >= 0 && refRpRefAvailFlag ) |
---|
3683 | { |
---|
3684 | m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = true; |
---|
3685 | } |
---|
3686 | else |
---|
3687 | { |
---|
3688 | m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = false; |
---|
3689 | } |
---|
3690 | } |
---|
3691 | } |
---|
3692 | } |
---|
3693 | } |
---|
3694 | #endif |
---|
3695 | |
---|
3696 | #if H_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 << g_bitDepthY ); |
---|
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(); |
---|
3792 | Int iHeight = pcCurrPicYuv->getHeight(); |
---|
3793 | |
---|
3794 | Pel* pCurrY = pcCurrPicYuv ->getLumaAddr(); |
---|
3795 | Pel* pRefOrgY = pcRefPicYuvOrg ->getLumaAddr(); |
---|
3796 | Int iCurrStride = pcCurrPicYuv->getStride(); |
---|
3797 | Int iRefStride = pcRefPicYuvOrg->getStride(); |
---|
3798 | |
---|
3799 | for ( Int y = 0; y < iHeight; y++ ) |
---|
3800 | { |
---|
3801 | for ( Int x = 0; x < iWidth; x++ ) |
---|
3802 | { |
---|
3803 | aiCurrHist[pCurrY[x]]++; |
---|
3804 | aiRefOrgHist[pRefOrgY[x]]++; |
---|
3805 | } |
---|
3806 | pCurrY += iCurrStride; |
---|
3807 | pRefOrgY += iRefStride; |
---|
3808 | } |
---|
3809 | |
---|
3810 | // Histogram SAD |
---|
3811 | Int iSumOrgSAD = 0; |
---|
3812 | for ( Int i = 0; i < iMaxPelValue; i++ ) |
---|
3813 | { |
---|
3814 | iSumOrgSAD += abs( aiCurrHist[i] - aiRefOrgHist[i] ); |
---|
3815 | } |
---|
3816 | |
---|
3817 | // Setting |
---|
3818 | Double dThresholdOrgSAD = getIsDepth() ? 0.1 : 0.05; |
---|
3819 | |
---|
3820 | if ( iSumOrgSAD > Int( dThresholdOrgSAD * iWidth * iHeight ) ) |
---|
3821 | { |
---|
3822 | m_bApplyIC = true; |
---|
3823 | } |
---|
3824 | else |
---|
3825 | { |
---|
3826 | m_bApplyIC = false; |
---|
3827 | } |
---|
3828 | |
---|
3829 | xFree( aiCurrHist ); |
---|
3830 | xFree( aiRefOrgHist ); |
---|
3831 | } |
---|
3832 | }//if(bUseLowLatencyICEnc) |
---|
3833 | } |
---|
3834 | #endif |
---|
3835 | #if NH_3D |
---|
3836 | Void TComSlice::setIvPicLists( TComPicLists* m_ivPicLists ) |
---|
3837 | { |
---|
3838 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
3839 | { |
---|
3840 | for ( Int depthId = 0; depthId < 2; depthId++ ) |
---|
3841 | { |
---|
3842 | m_ivPicsCurrPoc[ depthId ][ i ] = ( i <= m_viewIndex ) ? m_ivPicLists->getPic( i, ( depthId == 1) , getPOC() ) : NULL; |
---|
3843 | } |
---|
3844 | } |
---|
3845 | } |
---|
3846 | Void TComSlice::setDepthToDisparityLUTs() |
---|
3847 | { |
---|
3848 | Bool setupLUT = false; |
---|
3849 | |
---|
3850 | setupLUT = setupLUT || getViewSynthesisPredFlag( ); |
---|
3851 | |
---|
3852 | #if NH_3D_NBDV_REF |
---|
3853 | setupLUT = setupLUT || getDepthRefinementFlag( ); |
---|
3854 | #endif |
---|
3855 | |
---|
3856 | #if H_3D_IV_MERGE |
---|
3857 | setupLUT = setupLUT || ( getIvMvPredFlag() && getIsDepth() ); |
---|
3858 | #endif |
---|
3859 | |
---|
3860 | Int bitDepthY = getSPS()->getBitDepth(CHANNEL_TYPE_LUMA); |
---|
3861 | |
---|
3862 | if( !setupLUT ) |
---|
3863 | { |
---|
3864 | return; |
---|
3865 | } |
---|
3866 | |
---|
3867 | m_numViews = getVPS()->getNumViews(); |
---|
3868 | /// GT: Allocation should be moved to a better place later; |
---|
3869 | if ( m_depthToDisparityB == NULL ) |
---|
3870 | { |
---|
3871 | m_depthToDisparityB = new Int*[ m_numViews ]; |
---|
3872 | for ( Int i = 0; i < getVPS()->getNumViews(); i++ ) |
---|
3873 | { |
---|
3874 | m_depthToDisparityB[ i ] = new Int[ Int(1 << bitDepthY) ]; |
---|
3875 | } |
---|
3876 | } |
---|
3877 | |
---|
3878 | |
---|
3879 | if ( m_depthToDisparityF == NULL ) |
---|
3880 | { |
---|
3881 | m_depthToDisparityF = new Int*[ m_numViews ]; |
---|
3882 | for ( Int i = 0; i < m_numViews; i++ ) |
---|
3883 | { |
---|
3884 | m_depthToDisparityF[ i ] = new Int[ Int(1 << bitDepthY) ]; |
---|
3885 | } |
---|
3886 | } |
---|
3887 | |
---|
3888 | assert( m_depthToDisparityB != NULL ); |
---|
3889 | assert( m_depthToDisparityF != NULL ); |
---|
3890 | |
---|
3891 | const TComVPS* vps = getVPS(); |
---|
3892 | |
---|
3893 | Int log2Div = bitDepthY - 1 + vps->getCpPrecision(); |
---|
3894 | Int voiInVps = vps->getVoiInVps( getViewIndex() ); |
---|
3895 | Bool camParaSH = vps->getCpInSliceSegmentHeaderFlag( voiInVps ); |
---|
3896 | |
---|
3897 | const IntAry1d codScale = camParaSH ? m_aaiCodedScale [ 0 ] : vps->getCodedScale ( voiInVps ); |
---|
3898 | const IntAry1d codOffset = camParaSH ? m_aaiCodedOffset[ 0 ] : vps->getCodedOffset ( voiInVps ); |
---|
3899 | const IntAry1d invCodScale = camParaSH ? m_aaiCodedScale [ 1 ] : vps->getInvCodedScale ( voiInVps ); |
---|
3900 | const IntAry1d invCodOffset = camParaSH ? m_aaiCodedOffset[ 1 ] : vps->getInvCodedOffset( voiInVps ); |
---|
3901 | |
---|
3902 | |
---|
3903 | for (Int i = 0; i < voiInVps; i++) |
---|
3904 | { |
---|
3905 | Int iInVoi = vps->getVoiInVps( i ); |
---|
3906 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
3907 | if ( g_traceCameraParameters ) |
---|
3908 | { |
---|
3909 | std::cout << std::endl << "Cp: " << codScale [ iInVoi ] << " " << codOffset[ iInVoi ] << " " |
---|
3910 | << invCodScale[ iInVoi ] << " " << invCodOffset[ iInVoi ] << " " << log2Div; |
---|
3911 | } |
---|
3912 | #endif |
---|
3913 | for ( Int d = 0; d <= ( ( 1 << bitDepthY ) - 1 ); d++ ) |
---|
3914 | { |
---|
3915 | Int offset = ( codOffset [ iInVoi ] << bitDepthY ) + ( ( 1 << log2Div ) >> 1 ); |
---|
3916 | m_depthToDisparityB[ iInVoi ][ d ] = ( codScale [ iInVoi ] * d + offset ) >> log2Div; |
---|
3917 | |
---|
3918 | Int invOffset = ( invCodOffset[ iInVoi ] << bitDepthY ) + ( ( 1 << log2Div ) >> 1 ); |
---|
3919 | m_depthToDisparityF[ iInVoi ][ d ] = ( invCodScale[ iInVoi ] * d + invOffset ) >> log2Div; |
---|
3920 | } |
---|
3921 | } |
---|
3922 | } |
---|
3923 | #endif |
---|
3924 | #endif |
---|
3925 | |
---|
3926 | |
---|
3927 | #if NH_MV |
---|
3928 | Void TComSlice::checkCrossLayerBlaFlag() const |
---|
3929 | { |
---|
3930 | // 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. |
---|
3931 | if ( getLayerId() != 0 || getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
3932 | { |
---|
3933 | assert( m_crossLayerBlaFlag == 0 ); |
---|
3934 | } |
---|
3935 | } |
---|
3936 | |
---|
3937 | Bool TComSlice::inferPocMsbValPresentFlag() |
---|
3938 | { |
---|
3939 | Bool pocMsbValPresentFlag; |
---|
3940 | if( getSliceSegmentHeaderExtensionLength() == 0 ) |
---|
3941 | { |
---|
3942 | pocMsbValPresentFlag = false; |
---|
3943 | } |
---|
3944 | else if ( getPocMsbValRequiredFlag() ) |
---|
3945 | { |
---|
3946 | pocMsbValPresentFlag = true; |
---|
3947 | } |
---|
3948 | else |
---|
3949 | { |
---|
3950 | pocMsbValPresentFlag = false; |
---|
3951 | } |
---|
3952 | |
---|
3953 | return pocMsbValPresentFlag; |
---|
3954 | } |
---|
3955 | |
---|
3956 | |
---|
3957 | #endif |
---|
3958 | |
---|
3959 | |
---|
3960 | #if NH_3D |
---|
3961 | Void TComSlice::init3dToolParameters() |
---|
3962 | { |
---|
3963 | Bool depthFlag = getIsDepth(); |
---|
3964 | |
---|
3965 | Bool nRLLG0 = ( getVPS()->getNumRefListLayers( getLayerId() ) > 0 ); |
---|
3966 | |
---|
3967 | const TComSps3dExtension* sps3dExt = getSPS()->getSps3dExtension(); |
---|
3968 | |
---|
3969 | m_ivMvPredFlag = sps3dExt->getIvMvPredFlag ( depthFlag ) && nRLLG0 ; |
---|
3970 | m_ivMvScalingFlag = sps3dExt->getIvMvScalingFlag ( depthFlag ) ; |
---|
3971 | m_ivResPredFlag = sps3dExt->getIvResPredFlag ( depthFlag ) && nRLLG0 ; |
---|
3972 | m_depthRefinementFlag = sps3dExt->getDepthRefinementFlag ( depthFlag ) && getInCompPredFlag() && m_cpAvailableFlag; |
---|
3973 | m_viewSynthesisPredFlag = sps3dExt->getViewSynthesisPredFlag( depthFlag ) && nRLLG0 && getInCompPredFlag() && m_cpAvailableFlag; |
---|
3974 | m_depthBasedBlkPartFlag = sps3dExt->getDepthBasedBlkPartFlag( depthFlag ) && getInCompPredFlag(); |
---|
3975 | m_mpiFlag = sps3dExt->getMpiFlag ( depthFlag ) && getInCompPredFlag(); |
---|
3976 | m_intraContourFlag = sps3dExt->getIntraContourFlag ( depthFlag ) && getInCompPredFlag(); |
---|
3977 | m_intraSdcWedgeFlag = sps3dExt->getIntraSdcWedgeFlag ( depthFlag ) ; |
---|
3978 | m_qtPredFlag = sps3dExt->getQtPredFlag ( depthFlag ) && getInCompPredFlag(); |
---|
3979 | m_interSdcFlag = sps3dExt->getInterSdcFlag ( depthFlag ) ; |
---|
3980 | m_depthIntraSkipFlag = sps3dExt->getDepthIntraSkipFlag ( depthFlag ) ; |
---|
3981 | |
---|
3982 | m_subPbSize = 1 << ( sps3dExt->getLog2SubPbSizeMinus3 ( depthFlag ) + 3 ); |
---|
3983 | m_mpiSubPbSize = 1 << ( sps3dExt->getLog2MpiSubPbSizeMinus3( depthFlag ) + 3 ); |
---|
3984 | |
---|
3985 | |
---|
3986 | #if H_3D_OUTPUT_ACTIVE_TOOLS |
---|
3987 | std::cout << "Layer: :" << getLayerId() << std::endl; |
---|
3988 | std::cout << "DepthFlag: :" << getIsDepth() << std::endl; |
---|
3989 | std::cout << "ViewOrderIdx: :" << getViewIndex() << std::endl; |
---|
3990 | std::cout << "InterCmpPredAvailableFlag:" << getInCmpPredAvailFlag() << std::endl; |
---|
3991 | std::cout << "InterCompPredFlag :" << getInCompPredFlag() << std::endl; |
---|
3992 | |
---|
3993 | std::cout << "ivMvPredFlag :" << m_ivMvPredFlag << std::endl; |
---|
3994 | std::cout << "ivMvScalingFlag :" << m_ivMvScalingFlag << std::endl; |
---|
3995 | std::cout << "ivResPredFlag :" << m_ivResPredFlag << std::endl; |
---|
3996 | std::cout << "depthRefinementFlag :" << m_depthRefinementFlag << std::endl; |
---|
3997 | std::cout << "viewSynthesisPredFlag :" << m_viewSynthesisPredFlag << std::endl; |
---|
3998 | std::cout << "depthBasedBlkPartFlag :" << m_depthBasedBlkPartFlag << std::endl; |
---|
3999 | std::cout << "mpiFlag :" << m_mpiFlag << std::endl; |
---|
4000 | std::cout << "intraContourFlag :" << m_intraContourFlag << std::endl; |
---|
4001 | std::cout << "intraSdcWedgeFlag :" << m_intraSdcWedgeFlag << std::endl; |
---|
4002 | std::cout << "qtPredFlag :" << m_qtPredFlag << std::endl; |
---|
4003 | std::cout << "interSdcFlag :" << m_interSdcFlag << std::endl; |
---|
4004 | std::cout << "depthIntraSkipFlag :" << m_depthIntraSkipFlag << std::endl; |
---|
4005 | std::cout << "subPbSize :" << m_subPbSize << std::endl; |
---|
4006 | std::cout << "mpiSubPbSize :" << m_mpiSubPbSize << std::endl; |
---|
4007 | #endif |
---|
4008 | } |
---|
4009 | |
---|
4010 | Void TComSlice::deriveInCmpPredAndCpAvailFlag( ) |
---|
4011 | { |
---|
4012 | Int numCurCmpLIds = getIsDepth() ? 1 : getNumActiveRefLayerPics(); |
---|
4013 | std::vector<Int> curCmpLIds; |
---|
4014 | if ( getIsDepth() ) |
---|
4015 | { |
---|
4016 | curCmpLIds.push_back( getLayerId() ); |
---|
4017 | } |
---|
4018 | else |
---|
4019 | { |
---|
4020 | for (Int i = 0; i < numCurCmpLIds; i++) |
---|
4021 | { |
---|
4022 | curCmpLIds.push_back( getRefPicLayerId( i ) ); |
---|
4023 | } |
---|
4024 | } |
---|
4025 | |
---|
4026 | m_cpAvailableFlag = true; |
---|
4027 | m_inCmpRefViewIdcs.clear(); |
---|
4028 | Bool allRefCmpLayersAvailFlag = true; |
---|
4029 | |
---|
4030 | for( Int i = 0; i <= numCurCmpLIds - 1; i++ ) |
---|
4031 | { |
---|
4032 | m_inCmpRefViewIdcs.push_back( getVPS()->getViewOrderIdx( curCmpLIds[ i ] )); |
---|
4033 | if( !getVPS()->getCpPresentFlag( getVPS()->getVoiInVps( getViewIndex() ), getVPS()->getVoiInVps( m_inCmpRefViewIdcs[ i ] ) ) ) |
---|
4034 | { |
---|
4035 | m_cpAvailableFlag = false; |
---|
4036 | } |
---|
4037 | Bool refCmpCurLIdAvailFlag = false; |
---|
4038 | if( getVPS()->getViewCompLayerPresentFlag( m_inCmpRefViewIdcs[ i ], !getIsDepth() ) ) |
---|
4039 | { |
---|
4040 | Int j = getVPS()->getLayerIdInVps( getVPS()->getViewCompLayerId( m_inCmpRefViewIdcs[ i ], !getIsDepth() ) ); |
---|
4041 | if ( getVPS()->getDirectDependencyFlag( getVPS()->getLayerIdInVps( getLayerId() ) , j ) && |
---|
4042 | getVPS()->getSubLayersVpsMaxMinus1( j ) >= getTemporalId() && |
---|
4043 | ( getTemporalId() == 0 || getVPS()->getMaxTidIlRefPicsPlus1( j , getVPS()->getLayerIdInVps( getLayerId() ) ) > getTemporalId() ) |
---|
4044 | ) |
---|
4045 | { |
---|
4046 | refCmpCurLIdAvailFlag = true; |
---|
4047 | } |
---|
4048 | } |
---|
4049 | if( !refCmpCurLIdAvailFlag ) |
---|
4050 | { |
---|
4051 | allRefCmpLayersAvailFlag = false; |
---|
4052 | } |
---|
4053 | } |
---|
4054 | |
---|
4055 | if( !allRefCmpLayersAvailFlag ) |
---|
4056 | { |
---|
4057 | m_inCmpPredAvailFlag = false; |
---|
4058 | } |
---|
4059 | else |
---|
4060 | { |
---|
4061 | const TComSps3dExtension* sps3dExt = getSPS()->getSps3dExtension(); |
---|
4062 | if( !getIsDepth() ) |
---|
4063 | { |
---|
4064 | m_inCmpPredAvailFlag = sps3dExt->getViewSynthesisPredFlag( getIsDepth() ) || |
---|
4065 | sps3dExt->getDepthBasedBlkPartFlag( getIsDepth() ) || |
---|
4066 | sps3dExt->getDepthRefinementFlag ( getIsDepth() ); |
---|
4067 | } |
---|
4068 | else |
---|
4069 | { |
---|
4070 | m_inCmpPredAvailFlag = sps3dExt->getIntraContourFlag( getIsDepth() ) || |
---|
4071 | sps3dExt->getQtPredFlag( getIsDepth() ) || |
---|
4072 | sps3dExt->getMpiFlag( getIsDepth() ); |
---|
4073 | } |
---|
4074 | } |
---|
4075 | } |
---|
4076 | |
---|
4077 | Void TComSlice::checkInCompPredRefLayers() |
---|
4078 | { |
---|
4079 | if ( getInCompPredFlag() ) |
---|
4080 | { |
---|
4081 | for (Int i = 0; i < getNumCurCmpLIds(); i++ ) |
---|
4082 | { |
---|
4083 | assert( getIvPic(!getIsDepth(), getInCmpRefViewIdcs( i ) ) != NULL ); |
---|
4084 | // It is a requirement of bitstream conformance that there |
---|
4085 | // is a picture in the DPB with PicOrderCntVal equal to the PicOrderCntVal of the current picture, |
---|
4086 | // and a nuh_layer_id value equal to ViewCompLayerId[ inCmpRefViewIdcs[ i ] ][ !DepthFlag ]. |
---|
4087 | } |
---|
4088 | } |
---|
4089 | } |
---|
4090 | |
---|
4091 | #endif |
---|
4092 | |
---|
4093 | /** get scaling matrix from RefMatrixID |
---|
4094 | * \param sizeId size index |
---|
4095 | * \param listId index of input matrix |
---|
4096 | * \param refListId index of reference matrix |
---|
4097 | */ |
---|
4098 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
4099 | { |
---|
4100 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
4101 | } |
---|
4102 | |
---|
4103 | Void TComScalingList::checkPredMode(UInt sizeId, UInt listId) |
---|
4104 | { |
---|
4105 | Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. |
---|
4106 | |
---|
4107 | for(Int predListIdx = (Int)listId ; predListIdx >= 0; predListIdx-=predListStep) |
---|
4108 | { |
---|
4109 | if( !memcmp(getScalingListAddress(sizeId,listId),((listId == predListIdx) ? |
---|
4110 | getScalingListDefaultAddress(sizeId, predListIdx): getScalingListAddress(sizeId, predListIdx)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
4111 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value |
---|
4112 | { |
---|
4113 | setRefMatrixId(sizeId, listId, predListIdx); |
---|
4114 | setScalingListPredModeFlag(sizeId, listId, false); |
---|
4115 | return; |
---|
4116 | } |
---|
4117 | } |
---|
4118 | setScalingListPredModeFlag(sizeId, listId, true); |
---|
4119 | } |
---|
4120 | |
---|
4121 | static Void outputScalingListHelp(std::ostream &os) |
---|
4122 | { |
---|
4123 | os << "The scaling list file specifies all matrices and their DC values; none can be missing,\n" |
---|
4124 | "but their order is arbitrary.\n\n" |
---|
4125 | "The matrices are specified by:\n" |
---|
4126 | "<matrix name><unchecked data>\n" |
---|
4127 | " <value>,<value>,<value>,....\n\n" |
---|
4128 | " Line-feeds can be added arbitrarily between values, and the number of values needs to be\n" |
---|
4129 | " at least the number of entries for the matrix (superfluous entries are ignored).\n" |
---|
4130 | " The <unchecked data> is text on the same line as the matrix that is not checked\n" |
---|
4131 | " except to ensure that the matrix name token is unique. It is recommended that it is ' ='\n" |
---|
4132 | " The values in the matrices are the absolute values (0-255), not the delta values as\n" |
---|
4133 | " exchanged between the encoder and decoder\n\n" |
---|
4134 | "The DC values (for matrix sizes larger than 8x8) are specified by:\n" |
---|
4135 | "<matrix name>_DC<unchecked data>\n" |
---|
4136 | " <value>\n"; |
---|
4137 | |
---|
4138 | os << "The permitted matrix names are:\n"; |
---|
4139 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
4140 | { |
---|
4141 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
4142 | { |
---|
4143 | if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0)) |
---|
4144 | { |
---|
4145 | os << " " << MatrixType[sizeIdc][listIdc] << '\n'; |
---|
4146 | } |
---|
4147 | } |
---|
4148 | } |
---|
4149 | } |
---|
4150 | |
---|
4151 | Void TComScalingList::outputScalingLists(std::ostream &os) const |
---|
4152 | { |
---|
4153 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
4154 | { |
---|
4155 | const UInt size = min(8,4<<(sizeIdc)); |
---|
4156 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
4157 | { |
---|
4158 | if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0)) |
---|
4159 | { |
---|
4160 | const Int *src = getScalingListAddress(sizeIdc, listIdc); |
---|
4161 | os << (MatrixType[sizeIdc][listIdc]) << " =\n "; |
---|
4162 | for(UInt y=0; y<size; y++) |
---|
4163 | { |
---|
4164 | for(UInt x=0; x<size; x++, src++) |
---|
4165 | { |
---|
4166 | os << std::setw(3) << (*src) << ", "; |
---|
4167 | } |
---|
4168 | os << (y+1<size?"\n ":"\n"); |
---|
4169 | } |
---|
4170 | if(sizeIdc > SCALING_LIST_8x8) |
---|
4171 | { |
---|
4172 | os << MatrixType_DC[sizeIdc][listIdc] << " = \n " << std::setw(3) << getScalingListDC(sizeIdc, listIdc) << "\n"; |
---|
4173 | } |
---|
4174 | os << "\n"; |
---|
4175 | } |
---|
4176 | } |
---|
4177 | } |
---|
4178 | } |
---|
4179 | |
---|
4180 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
4181 | { |
---|
4182 | static const Int LINE_SIZE=1024; |
---|
4183 | FILE *fp = NULL; |
---|
4184 | Char line[LINE_SIZE]; |
---|
4185 | |
---|
4186 | if (pchFile == NULL) |
---|
4187 | { |
---|
4188 | fprintf(stderr, "Error: no scaling list file specified. Help on scaling lists being output\n"); |
---|
4189 | outputScalingListHelp(std::cout); |
---|
4190 | std::cout << "\n\nExample scaling list file using default values:\n\n"; |
---|
4191 | outputScalingLists(std::cout); |
---|
4192 | exit (1); |
---|
4193 | return true; |
---|
4194 | } |
---|
4195 | else if ((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
4196 | { |
---|
4197 | fprintf(stderr, "Error: cannot open scaling list file %s for reading\n",pchFile); |
---|
4198 | return true; |
---|
4199 | } |
---|
4200 | |
---|
4201 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
4202 | { |
---|
4203 | const UInt size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
4204 | |
---|
4205 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
4206 | { |
---|
4207 | Int * const src = getScalingListAddress(sizeIdc, listIdc); |
---|
4208 | |
---|
4209 | if ((sizeIdc==SCALING_LIST_32x32) && (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) // derive chroma32x32 from chroma16x16 |
---|
4210 | { |
---|
4211 | const Int *srcNextSmallerSize = getScalingListAddress(sizeIdc-1, listIdc); |
---|
4212 | for(UInt i=0; i<size; i++) |
---|
4213 | { |
---|
4214 | src[i] = srcNextSmallerSize[i]; |
---|
4215 | } |
---|
4216 | setScalingListDC(sizeIdc,listIdc,(sizeIdc > SCALING_LIST_8x8) ? getScalingListDC(sizeIdc-1, listIdc) : src[0]); |
---|
4217 | } |
---|
4218 | else |
---|
4219 | { |
---|
4220 | { |
---|
4221 | fseek(fp, 0, SEEK_SET); |
---|
4222 | Bool bFound=false; |
---|
4223 | while ((!feof(fp)) && (!bFound)) |
---|
4224 | { |
---|
4225 | Char *ret = fgets(line, LINE_SIZE, fp); |
---|
4226 | Char *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType[sizeIdc][listIdc]); |
---|
4227 | // This could be a match against the DC string as well, so verify it isn't |
---|
4228 | if (findNamePosition!= NULL && (MatrixType_DC[sizeIdc][listIdc]==NULL || strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL)) |
---|
4229 | { |
---|
4230 | bFound=true; |
---|
4231 | } |
---|
4232 | } |
---|
4233 | if (!bFound) |
---|
4234 | { |
---|
4235 | fprintf(stderr, "Error: cannot find Matrix %s from scaling list file %s\n", MatrixType[sizeIdc][listIdc], pchFile); |
---|
4236 | return true; |
---|
4237 | } |
---|
4238 | } |
---|
4239 | for (UInt i=0; i<size; i++) |
---|
4240 | { |
---|
4241 | Int data; |
---|
4242 | if (fscanf(fp, "%d,", &data)!=1) |
---|
4243 | { |
---|
4244 | 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)); |
---|
4245 | return true; |
---|
4246 | } |
---|
4247 | if (data<0 || data>255) |
---|
4248 | { |
---|
4249 | 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)); |
---|
4250 | return true; |
---|
4251 | } |
---|
4252 | src[i] = data; |
---|
4253 | } |
---|
4254 | |
---|
4255 | //set DC value for default matrix check |
---|
4256 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
4257 | |
---|
4258 | if(sizeIdc > SCALING_LIST_8x8) |
---|
4259 | { |
---|
4260 | { |
---|
4261 | fseek(fp, 0, SEEK_SET); |
---|
4262 | Bool bFound=false; |
---|
4263 | while ((!feof(fp)) && (!bFound)) |
---|
4264 | { |
---|
4265 | Char *ret = fgets(line, LINE_SIZE, fp); |
---|
4266 | Char *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType_DC[sizeIdc][listIdc]); |
---|
4267 | if (findNamePosition!= NULL) |
---|
4268 | { |
---|
4269 | // This won't be a match against the non-DC string. |
---|
4270 | bFound=true; |
---|
4271 | } |
---|
4272 | } |
---|
4273 | if (!bFound) |
---|
4274 | { |
---|
4275 | fprintf(stderr, "Error: cannot find DC Matrix %s from scaling list file %s\n", MatrixType_DC[sizeIdc][listIdc], pchFile); |
---|
4276 | return true; |
---|
4277 | } |
---|
4278 | } |
---|
4279 | Int data; |
---|
4280 | if (fscanf(fp, "%d,", &data)!=1) |
---|
4281 | { |
---|
4282 | fprintf(stderr, "Error: cannot read DC %s from scaling list file %s at file position %ld\n", MatrixType_DC[sizeIdc][listIdc], pchFile, ftell(fp)); |
---|
4283 | return true; |
---|
4284 | } |
---|
4285 | if (data<0 || data>255) |
---|
4286 | { |
---|
4287 | 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)); |
---|
4288 | return true; |
---|
4289 | } |
---|
4290 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
4291 | setScalingListDC(sizeIdc,listIdc,data); |
---|
4292 | } |
---|
4293 | } |
---|
4294 | } |
---|
4295 | } |
---|
4296 | // std::cout << "\n\nRead scaling lists of:\n\n"; |
---|
4297 | // outputScalingLists(std::cout); |
---|
4298 | |
---|
4299 | fclose(fp); |
---|
4300 | return false; |
---|
4301 | } |
---|
4302 | |
---|
4303 | #if NH_MV |
---|
4304 | Void TComScalingList::inferFrom( const TComScalingList& srcScLi ) |
---|
4305 | { |
---|
4306 | for(Int sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
4307 | { |
---|
4308 | for(Int listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
4309 | { |
---|
4310 | setRefMatrixId (sizeId,listId, srcScLi.getRefMatrixId (sizeId,listId)); |
---|
4311 | setScalingListDC(sizeId,listId, srcScLi.getScalingListDC(sizeId,listId)); |
---|
4312 | ::memcpy(getScalingListAddress(sizeId, listId),srcScLi.getScalingListAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
4313 | } |
---|
4314 | } |
---|
4315 | } |
---|
4316 | #endif |
---|
4317 | |
---|
4318 | |
---|
4319 | /** get default address of quantization matrix |
---|
4320 | * \param sizeId size index |
---|
4321 | * \param listId list index |
---|
4322 | * \returns pointer of quantization matrix |
---|
4323 | */ |
---|
4324 | const Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
4325 | { |
---|
4326 | const Int *src = 0; |
---|
4327 | switch(sizeId) |
---|
4328 | { |
---|
4329 | case SCALING_LIST_4x4: |
---|
4330 | src = g_quantTSDefault4x4; |
---|
4331 | break; |
---|
4332 | case SCALING_LIST_8x8: |
---|
4333 | case SCALING_LIST_16x16: |
---|
4334 | case SCALING_LIST_32x32: |
---|
4335 | src = (listId < (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) ) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
4336 | break; |
---|
4337 | default: |
---|
4338 | assert(0); |
---|
4339 | src = NULL; |
---|
4340 | break; |
---|
4341 | } |
---|
4342 | return src; |
---|
4343 | } |
---|
4344 | |
---|
4345 | /** process of default matrix |
---|
4346 | * \param sizeId size index |
---|
4347 | * \param listId index of input matrix |
---|
4348 | */ |
---|
4349 | Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId) |
---|
4350 | { |
---|
4351 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
4352 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
4353 | } |
---|
4354 | |
---|
4355 | /** check DC value of matrix for default matrix signaling |
---|
4356 | */ |
---|
4357 | Void TComScalingList::checkDcOfMatrix() |
---|
4358 | { |
---|
4359 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
4360 | { |
---|
4361 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
4362 | { |
---|
4363 | //check default matrix? |
---|
4364 | if(getScalingListDC(sizeId,listId) == 0) |
---|
4365 | { |
---|
4366 | processDefaultMatrix(sizeId, listId); |
---|
4367 | } |
---|
4368 | } |
---|
4369 | } |
---|
4370 | } |
---|
4371 | |
---|
4372 | ParameterSetManager::ParameterSetManager() |
---|
4373 | : m_vpsMap(MAX_NUM_VPS) |
---|
4374 | , m_spsMap(MAX_NUM_SPS) |
---|
4375 | , m_ppsMap(MAX_NUM_PPS) |
---|
4376 | , m_activeVPSId(-1) |
---|
4377 | #if !NH_MV |
---|
4378 | , m_activeSPSId(-1) |
---|
4379 | #endif |
---|
4380 | { |
---|
4381 | #if NH_MV |
---|
4382 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
4383 | { |
---|
4384 | m_activeSPSId[i] = -1; |
---|
4385 | } |
---|
4386 | #endif |
---|
4387 | } |
---|
4388 | |
---|
4389 | |
---|
4390 | ParameterSetManager::~ParameterSetManager() |
---|
4391 | { |
---|
4392 | } |
---|
4393 | |
---|
4394 | //! activate a SPS from a active parameter sets SEI message |
---|
4395 | //! \returns true, if activation is successful |
---|
4396 | #if NH_MV |
---|
4397 | //Bool ParameterSetManager::activateSPSWithSEI(Int spsId, Int layerId ) |
---|
4398 | #else |
---|
4399 | //Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
4400 | #endif |
---|
4401 | //{ |
---|
4402 | //TComSPS *sps = m_spsMap.getPS(spsId); |
---|
4403 | // if (sps) |
---|
4404 | // { |
---|
4405 | // Int vpsId = sps->getVPSId(); |
---|
4406 | // TComVPS *vps = m_vpsMap.getPS(vpsId); |
---|
4407 | // if (vps) |
---|
4408 | // { |
---|
4409 | #if NH_MV |
---|
4410 | // m_activeVPS = *(vps); |
---|
4411 | // m_activeSPS[ layerId ] = *(sps); |
---|
4412 | #else |
---|
4413 | // m_activeVPS = *(vps); |
---|
4414 | // m_activeSPS = *(sps); |
---|
4415 | #endif |
---|
4416 | // return true; |
---|
4417 | // } |
---|
4418 | // else |
---|
4419 | // { |
---|
4420 | // printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
4421 | // } |
---|
4422 | // } |
---|
4423 | // else |
---|
4424 | // { |
---|
4425 | // printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
4426 | // } |
---|
4427 | // return false; |
---|
4428 | //} |
---|
4429 | |
---|
4430 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
4431 | //! \returns true, if activation is successful |
---|
4432 | #if NH_MV |
---|
4433 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP, Int layerId ) |
---|
4434 | #else |
---|
4435 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
4436 | #endif |
---|
4437 | { |
---|
4438 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
4439 | if (pps) |
---|
4440 | { |
---|
4441 | Int spsId = pps->getSPSId(); |
---|
4442 | #if NH_MV |
---|
4443 | if (!isIRAP && (spsId != m_activeSPSId[ layerId ] )) |
---|
4444 | #else |
---|
4445 | if (!isIRAP && (spsId != m_activeSPSId )) |
---|
4446 | #endif |
---|
4447 | { |
---|
4448 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IDR."); |
---|
4449 | } |
---|
4450 | else |
---|
4451 | { |
---|
4452 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
4453 | if (sps) |
---|
4454 | { |
---|
4455 | Int vpsId = sps->getVPSId(); |
---|
4456 | if (!isIRAP && (vpsId != m_activeVPSId )) |
---|
4457 | { |
---|
4458 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IDR."); |
---|
4459 | } |
---|
4460 | else |
---|
4461 | { |
---|
4462 | TComVPS *vps =m_vpsMap.getPS(vpsId); |
---|
4463 | if (vps) |
---|
4464 | { |
---|
4465 | m_activeVPSId = vpsId; |
---|
4466 | #if NH_MV |
---|
4467 | m_activeSPSId[layerId] = spsId; |
---|
4468 | #else |
---|
4469 | m_activeSPSId = spsId; |
---|
4470 | #endif |
---|
4471 | return true; |
---|
4472 | } |
---|
4473 | else |
---|
4474 | { |
---|
4475 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
4476 | } |
---|
4477 | } |
---|
4478 | } |
---|
4479 | else |
---|
4480 | { |
---|
4481 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
4482 | } |
---|
4483 | } |
---|
4484 | } |
---|
4485 | else |
---|
4486 | { |
---|
4487 | printf("Warning: tried to activate non-existing PPS."); |
---|
4488 | } |
---|
4489 | |
---|
4490 | // Failed to activate if reach here. |
---|
4491 | #if NH_MV |
---|
4492 | m_activeSPSId[layerId]=-1; |
---|
4493 | #else |
---|
4494 | m_activeSPSId=-1; |
---|
4495 | #endif |
---|
4496 | m_activeVPSId=-1; |
---|
4497 | |
---|
4498 | return false; |
---|
4499 | } |
---|
4500 | |
---|
4501 | ProfileTierLevel::ProfileTierLevel() |
---|
4502 | : m_profileSpace (0) |
---|
4503 | , m_tierFlag (Level::MAIN) |
---|
4504 | , m_profileIdc (Profile::NONE) |
---|
4505 | , m_levelIdc (Level::NONE) |
---|
4506 | , m_progressiveSourceFlag (false) |
---|
4507 | , m_interlacedSourceFlag (false) |
---|
4508 | , m_nonPackedConstraintFlag(false) |
---|
4509 | , m_frameOnlyConstraintFlag(false) |
---|
4510 | #if NH_MV |
---|
4511 | , m_intraConstraintFlag ( false ) |
---|
4512 | , m_onePictureOnlyConstraintFlag( false ) |
---|
4513 | , m_lowerBitRateConstraintFlag ( false ) |
---|
4514 | , m_max12bitConstraintFlag ( false ) |
---|
4515 | , m_max10bitConstraintFlag ( false ) |
---|
4516 | , m_max8bitConstraintFlag ( false ) |
---|
4517 | , m_max422chromaConstraintFlag ( false ) |
---|
4518 | , m_max420chromaConstraintFlag ( false ) |
---|
4519 | , m_maxMonochromeConstraintFlag ( false ) |
---|
4520 | , m_inbldFlag ( false ) |
---|
4521 | #endif |
---|
4522 | { |
---|
4523 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
4524 | } |
---|
4525 | |
---|
4526 | #if NH_MV |
---|
4527 | Bool ProfileTierLevel::getV2ConstraintsPresentFlag() const |
---|
4528 | { |
---|
4529 | return ( |
---|
4530 | getProfileIdc( ) == 4 || getProfileCompatibilityFlag( 4 ) || getProfileIdc( ) == 5 || getProfileCompatibilityFlag( 5 ) || |
---|
4531 | getProfileIdc( ) == 6 || getProfileCompatibilityFlag( 6 ) || getProfileIdc( ) == 7 || getProfileCompatibilityFlag( 7 ) |
---|
4532 | ); |
---|
4533 | } |
---|
4534 | |
---|
4535 | Bool ProfileTierLevel::getInbldPresentFlag() const |
---|
4536 | { |
---|
4537 | return ( |
---|
4538 | ( getProfileIdc() >= 1 && getProfileIdc() <= 5 ) || getProfileCompatibilityFlag( 1 ) || getProfileCompatibilityFlag( 2 ) || |
---|
4539 | getProfileCompatibilityFlag( 3 ) || getProfileCompatibilityFlag( 4 ) || getProfileCompatibilityFlag( 5 ) |
---|
4540 | ); |
---|
4541 | } |
---|
4542 | |
---|
4543 | Void ProfileTierLevel::copyV2ConstraintFlags(ProfileTierLevel* ptlRef) |
---|
4544 | { |
---|
4545 | setMax12bitConstraintFlag ( ptlRef->getMax12bitConstraintFlag ( ) ); |
---|
4546 | setMax10bitConstraintFlag ( ptlRef->getMax10bitConstraintFlag ( ) ); |
---|
4547 | setMax8bitConstraintFlag ( ptlRef->getMax8bitConstraintFlag ( ) ); |
---|
4548 | setMax422chromaConstraintFlag ( ptlRef->getMax422chromaConstraintFlag ( ) ); |
---|
4549 | setMax420chromaConstraintFlag ( ptlRef->getMax420chromaConstraintFlag ( ) ); |
---|
4550 | setMaxMonochromeConstraintFlag ( ptlRef->getMaxMonochromeConstraintFlag ( ) ); |
---|
4551 | setIntraConstraintFlag ( ptlRef->getIntraConstraintFlag ( ) ); |
---|
4552 | setOnePictureOnlyConstraintFlag ( ptlRef->getOnePictureOnlyConstraintFlag ( ) ); |
---|
4553 | setLowerBitRateConstraintFlag ( ptlRef->getLowerBitRateConstraintFlag ( ) ); |
---|
4554 | } |
---|
4555 | |
---|
4556 | Void ProfileTierLevel::copyProfile(ProfileTierLevel* ptlRef) |
---|
4557 | { |
---|
4558 | setProfileSpace ( ptlRef->getProfileSpace ( ) ); |
---|
4559 | setTierFlag ( ptlRef->getTierFlag ( ) ); |
---|
4560 | setProfileIdc ( ptlRef->getProfileIdc ( ) ); |
---|
4561 | for (Int j = 0; j < 32; j++) |
---|
4562 | { |
---|
4563 | setProfileCompatibilityFlag(j, ptlRef->getProfileCompatibilityFlag ( j ) ); |
---|
4564 | } |
---|
4565 | setProgressiveSourceFlag ( ptlRef->getProgressiveSourceFlag ( ) ); |
---|
4566 | setInterlacedSourceFlag ( ptlRef->getInterlacedSourceFlag ( ) ); |
---|
4567 | setNonPackedConstraintFlag ( ptlRef->getNonPackedConstraintFlag ( ) ); |
---|
4568 | setFrameOnlyConstraintFlag ( ptlRef->getFrameOnlyConstraintFlag ( ) ); |
---|
4569 | copyV2ConstraintFlags ( ptlRef ); |
---|
4570 | } |
---|
4571 | #endif |
---|
4572 | |
---|
4573 | TComPTL::TComPTL() |
---|
4574 | { |
---|
4575 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
4576 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
4577 | } |
---|
4578 | |
---|
4579 | Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> &newData) |
---|
4580 | { |
---|
4581 | if (!bChanged) |
---|
4582 | { |
---|
4583 | if ((pOldData==0 && pOldData!=0) || (pOldData!=0 && pOldData==0)) |
---|
4584 | { |
---|
4585 | bChanged=true; |
---|
4586 | } |
---|
4587 | else if (pOldData!=0 && pOldData!=0) |
---|
4588 | { |
---|
4589 | // compare the two |
---|
4590 | if (pOldData->size() != pOldData->size()) |
---|
4591 | { |
---|
4592 | bChanged=true; |
---|
4593 | } |
---|
4594 | else |
---|
4595 | { |
---|
4596 | const UChar *pNewDataArray=&(newData)[0]; |
---|
4597 | const UChar *pOldDataArray=&(*pOldData)[0]; |
---|
4598 | if (memcmp(pOldDataArray, pNewDataArray, pOldData->size())) |
---|
4599 | { |
---|
4600 | bChanged=true; |
---|
4601 | } |
---|
4602 | } |
---|
4603 | } |
---|
4604 | } |
---|
4605 | } |
---|
4606 | #if NH_MV |
---|
4607 | Void TComPTL::inferGeneralValues(Bool profilePresentFlag, Int k, TComPTL* refPTL) |
---|
4608 | { |
---|
4609 | ProfileTierLevel* refProfileTierLevel = NULL; |
---|
4610 | if ( k > 0 ) |
---|
4611 | { |
---|
4612 | assert( refPTL != NULL); |
---|
4613 | refProfileTierLevel = refPTL->getGeneralPTL(); |
---|
4614 | } |
---|
4615 | |
---|
4616 | ProfileTierLevel* curProfileTierLevel = getGeneralPTL( ); |
---|
4617 | |
---|
4618 | if( !profilePresentFlag ) |
---|
4619 | { |
---|
4620 | assert( k > 0 ); |
---|
4621 | assert( refProfileTierLevel != NULL ); |
---|
4622 | curProfileTierLevel->copyProfile( refProfileTierLevel); |
---|
4623 | } |
---|
4624 | else |
---|
4625 | { |
---|
4626 | if ( !curProfileTierLevel->getV2ConstraintsPresentFlag() ) |
---|
4627 | { |
---|
4628 | curProfileTierLevel->setMax12bitConstraintFlag ( false ); |
---|
4629 | curProfileTierLevel->setMax10bitConstraintFlag ( false ); |
---|
4630 | curProfileTierLevel->setMax8bitConstraintFlag ( false ); |
---|
4631 | curProfileTierLevel->setMax422chromaConstraintFlag ( false ); |
---|
4632 | curProfileTierLevel->setMax420chromaConstraintFlag ( false ); |
---|
4633 | curProfileTierLevel->setMaxMonochromeConstraintFlag ( false ); |
---|
4634 | curProfileTierLevel->setIntraConstraintFlag ( false ); |
---|
4635 | curProfileTierLevel->setOnePictureOnlyConstraintFlag ( false ); |
---|
4636 | curProfileTierLevel->setLowerBitRateConstraintFlag ( false ); |
---|
4637 | } |
---|
4638 | |
---|
4639 | if ( !curProfileTierLevel->getInbldPresentFlag() ) |
---|
4640 | { |
---|
4641 | curProfileTierLevel->setInbldFlag( false ); |
---|
4642 | } |
---|
4643 | } |
---|
4644 | } |
---|
4645 | |
---|
4646 | Void TComPTL::inferSubLayerValues(Int maxNumSubLayersMinus1, Int k, TComPTL* refPTL) |
---|
4647 | { |
---|
4648 | assert( k == 0 || refPTL != NULL ); |
---|
4649 | |
---|
4650 | for (Int i = maxNumSubLayersMinus1; i >= 0; i--) |
---|
4651 | { |
---|
4652 | ProfileTierLevel* refProfileTierLevel; |
---|
4653 | if ( k != 0 ) |
---|
4654 | { |
---|
4655 | refProfileTierLevel = refPTL->getSubLayerPTL( i ); |
---|
4656 | } |
---|
4657 | else |
---|
4658 | { |
---|
4659 | if ( i == maxNumSubLayersMinus1) |
---|
4660 | { |
---|
4661 | refProfileTierLevel = getGeneralPTL(); |
---|
4662 | } |
---|
4663 | else |
---|
4664 | { |
---|
4665 | refProfileTierLevel = getSubLayerPTL( i + 1 ); |
---|
4666 | } |
---|
4667 | } |
---|
4668 | |
---|
4669 | ProfileTierLevel* curProfileTierLevel = getSubLayerPTL( i ); |
---|
4670 | if( !getSubLayerLevelPresentFlag( i ) ) |
---|
4671 | { |
---|
4672 | curProfileTierLevel->setLevelIdc( refProfileTierLevel->getLevelIdc() ); |
---|
4673 | } |
---|
4674 | |
---|
4675 | if( !getSubLayerProfilePresentFlag( i ) ) |
---|
4676 | { |
---|
4677 | curProfileTierLevel->copyProfile( refProfileTierLevel); |
---|
4678 | } |
---|
4679 | else |
---|
4680 | { |
---|
4681 | if ( !curProfileTierLevel->getV2ConstraintsPresentFlag() ) |
---|
4682 | { |
---|
4683 | curProfileTierLevel->copyV2ConstraintFlags( refProfileTierLevel ); |
---|
4684 | } |
---|
4685 | |
---|
4686 | if ( !curProfileTierLevel->getInbldPresentFlag() ) |
---|
4687 | { |
---|
4688 | curProfileTierLevel->setInbldFlag( refProfileTierLevel->getInbldFlag() ); |
---|
4689 | } |
---|
4690 | } |
---|
4691 | } |
---|
4692 | } |
---|
4693 | |
---|
4694 | #endif |
---|
4695 | |
---|
4696 | //! \} |
---|
4697 | |
---|
4698 | #if NH_MV |
---|
4699 | Void TComVPSVUI::init( Int numLayerSets, Int maxNumSubLayers, Int maxNumLayers ) |
---|
4700 | { |
---|
4701 | m_crossLayerIrapAlignedFlag = true; |
---|
4702 | m_allLayersIdrAlignedFlag = false; |
---|
4703 | m_bitRatePresentVpsFlag = false; |
---|
4704 | m_picRatePresentVpsFlag = false; |
---|
4705 | |
---|
4706 | m_bitRatePresentFlag .resize(numLayerSets); |
---|
4707 | m_picRatePresentFlag .resize(numLayerSets); |
---|
4708 | m_avgBitRate .resize(numLayerSets); |
---|
4709 | m_maxBitRate .resize(numLayerSets); |
---|
4710 | m_constantPicRateIdc .resize(numLayerSets); |
---|
4711 | m_avgPicRate .resize(numLayerSets); |
---|
4712 | |
---|
4713 | for ( Int i = 0; i < numLayerSets; i++) |
---|
4714 | { |
---|
4715 | m_bitRatePresentFlag [i].resize( maxNumSubLayers); |
---|
4716 | m_picRatePresentFlag [i].resize( maxNumSubLayers); |
---|
4717 | m_avgBitRate [i].resize( maxNumSubLayers); |
---|
4718 | m_maxBitRate [i].resize( maxNumSubLayers); |
---|
4719 | m_constantPicRateIdc [i].resize( maxNumSubLayers); |
---|
4720 | m_avgPicRate [i].resize( maxNumSubLayers); |
---|
4721 | for ( Int j = 0; j < maxNumSubLayers; j++) |
---|
4722 | { |
---|
4723 | m_bitRatePresentFlag [i][j] = false; |
---|
4724 | m_picRatePresentFlag [i][j] = false; |
---|
4725 | m_avgBitRate [i][j] = -1; |
---|
4726 | m_maxBitRate [i][j] = -1; |
---|
4727 | m_constantPicRateIdc [i][j] = -1; |
---|
4728 | m_avgPicRate [i][j] = -1; |
---|
4729 | } |
---|
4730 | } |
---|
4731 | |
---|
4732 | m_ilpRestrictedRefLayersFlag = false; |
---|
4733 | |
---|
4734 | m_tileBoundariesAlignedFlag .resize( maxNumLayers ); |
---|
4735 | m_minSpatialSegmentOffsetPlus1 .resize( maxNumLayers ); |
---|
4736 | m_ctuBasedOffsetEnabledFlag .resize( maxNumLayers ); |
---|
4737 | m_minHorizontalCtuOffsetPlus1 .resize( maxNumLayers ); |
---|
4738 | m_baseLayerParameterSetCompatibilityFlag.resize( maxNumLayers ); |
---|
4739 | |
---|
4740 | for ( Int i = 0; i < maxNumLayers; i++) |
---|
4741 | { |
---|
4742 | m_tileBoundariesAlignedFlag [i].resize( maxNumLayers ); |
---|
4743 | m_minSpatialSegmentOffsetPlus1[i].resize( maxNumLayers ); |
---|
4744 | m_ctuBasedOffsetEnabledFlag [i].resize( maxNumLayers ); |
---|
4745 | m_minHorizontalCtuOffsetPlus1 [i].resize( maxNumLayers ); |
---|
4746 | for ( Int j = 0; j < maxNumLayers; j++) |
---|
4747 | { |
---|
4748 | m_tileBoundariesAlignedFlag [i][j] = false; |
---|
4749 | m_minSpatialSegmentOffsetPlus1[i][j] = 0; |
---|
4750 | m_ctuBasedOffsetEnabledFlag [i][j] = false; |
---|
4751 | m_minHorizontalCtuOffsetPlus1 [i][j] = -1; |
---|
4752 | } |
---|
4753 | m_baseLayerParameterSetCompatibilityFlag[i] = false; |
---|
4754 | } |
---|
4755 | m_vpsVuiBspHrdPresentFlag = false; |
---|
4756 | } |
---|
4757 | |
---|
4758 | Void TComRepFormat::inferChromaAndBitDepth( const TComRepFormat* prevRepFormat ) |
---|
4759 | { |
---|
4760 | setChromaAndBitDepthVpsPresentFlag( prevRepFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
4761 | setSeparateColourPlaneVpsFlag ( prevRepFormat->getSeparateColourPlaneVpsFlag () ); |
---|
4762 | setBitDepthVpsLumaMinus8 ( prevRepFormat->getBitDepthVpsLumaMinus8 () ); |
---|
4763 | setBitDepthVpsChromaMinus8 ( prevRepFormat->getBitDepthVpsChromaMinus8 () ); |
---|
4764 | } |
---|
4765 | |
---|
4766 | Void TComRepFormat::checkInferChromaAndBitDepth( const TComRepFormat* prevRepFormat ) const |
---|
4767 | { |
---|
4768 | assert( getChromaAndBitDepthVpsPresentFlag() == prevRepFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
4769 | assert( getSeparateColourPlaneVpsFlag () == prevRepFormat->getSeparateColourPlaneVpsFlag () ); |
---|
4770 | assert( getBitDepthVpsLumaMinus8 () == prevRepFormat->getBitDepthVpsLumaMinus8 () ); |
---|
4771 | assert( getBitDepthVpsChromaMinus8 () == prevRepFormat->getBitDepthVpsChromaMinus8 () ); |
---|
4772 | } |
---|
4773 | |
---|
4774 | Int TComVpsVuiBspHrdParameters::getBspHrdIdxLen( const TComVPS* vps) const |
---|
4775 | { |
---|
4776 | return gCeilLog2( vps->getNumHrdParameters() + getVpsNumAddHrdParams() ); |
---|
4777 | } |
---|
4778 | |
---|
4779 | Void TComVpsVuiBspHrdParameters::createAfterVpsNumAddHrdParams( const TComVPS* vps ) |
---|
4780 | { |
---|
4781 | m_offsetHrdParamIdx = vps->getNumHrdParameters(); |
---|
4782 | m_numHrdParam = vps->getNumHrdParameters() + getVpsNumAddHrdParams() - m_offsetHrdParamIdx; |
---|
4783 | m_numOls = vps->getNumOutputLayerSets(); |
---|
4784 | |
---|
4785 | m_cprmsAddPresentFlag .resize( m_numHrdParam ); |
---|
4786 | m_numSubLayerHrdMinus1.resize( m_numHrdParam ); |
---|
4787 | m_hrdParameters .resize( m_numHrdParam ); |
---|
4788 | |
---|
4789 | m_numSignalledPartitioningSchemes .resize( m_numOls ); |
---|
4790 | m_numPartitionsInSchemeMinus1 .resize( m_numOls ); |
---|
4791 | m_numBspSchedulesMinus1 .resize( m_numOls ); |
---|
4792 | m_bspHrdIdx .resize( m_numOls ); |
---|
4793 | m_bspSchedIdx .resize( m_numOls ); |
---|
4794 | } |
---|
4795 | |
---|
4796 | Void TComVpsVuiBspHrdParameters::createAfterNumSignalledPartitioningSchemes( const TComVPS* vps, Int h ) |
---|
4797 | { |
---|
4798 | m_numPartitionsInSchemeMinus1 [h].resize( getNumSignalledPartitioningSchemes(h) ); |
---|
4799 | m_layerIncludedInPartitionFlag[h].resize( getNumSignalledPartitioningSchemes(h) ); |
---|
4800 | |
---|
4801 | m_numBspSchedulesMinus1 [h].resize( getNumSignalledPartitioningSchemes(h) + 1 ); |
---|
4802 | for (Int i = 0; i < getNumSignalledPartitioningSchemes(h) + 1; i++) |
---|
4803 | { |
---|
4804 | Int tMax = vps->getMaxSubLayersInLayerSetMinus1( m_vps->olsIdxToLsIdx(h) ) + 1; |
---|
4805 | m_numBspSchedulesMinus1[h][i].resize( tMax ); |
---|
4806 | m_bspHrdIdx [h][i].resize( tMax ); |
---|
4807 | m_bspSchedIdx [h][i].resize( tMax ); |
---|
4808 | } |
---|
4809 | } |
---|
4810 | |
---|
4811 | Void TComVpsVuiBspHrdParameters::createAfterNumPartitionsInSchemeMinus1( const TComVPS* vps, Int h, Int j ) |
---|
4812 | { |
---|
4813 | m_layerIncludedInPartitionFlag[h][j].resize( getNumPartitionsInSchemeMinus1(h,j)); |
---|
4814 | for( Int k = 0; k < getNumPartitionsInSchemeMinus1(h,j); k++ ) |
---|
4815 | { |
---|
4816 | m_layerIncludedInPartitionFlag[h][j][k].resize( m_vps->getNumLayersInIdList( vps->olsIdxToLsIdx(h))); |
---|
4817 | } |
---|
4818 | } |
---|
4819 | |
---|
4820 | Void TComVpsVuiBspHrdParameters::createAfterNumBspSchedulesMinus1( const TComVPS* vps, Int h, Int i, Int t ) |
---|
4821 | { |
---|
4822 | m_bspSchedIdx[h][i][t].resize( getNumBspSchedulesMinus1( h, i, t ) + 1 ); |
---|
4823 | m_bspHrdIdx [h][i][t].resize( getNumBspSchedulesMinus1( h, i, t ) + 1 ); |
---|
4824 | for( Int j = 0; j < getNumBspSchedulesMinus1( h, i, t ) + 1; j++ ) |
---|
4825 | { |
---|
4826 | m_bspSchedIdx[h][i][t][j].resize( getNumPartitionsInSchemeMinus1( h, i ) ); |
---|
4827 | m_bspHrdIdx [h][i][t][j].resize( getNumPartitionsInSchemeMinus1( h, i ) ); |
---|
4828 | } |
---|
4829 | } |
---|
4830 | |
---|
4831 | |
---|
4832 | Void TComVUI::inferVideoSignalInfo( const TComVPS* vps, Int layerIdCurr ) |
---|
4833 | { |
---|
4834 | if ( layerIdCurr == 0 || !vps->getVpsVuiPresentFlag() ) |
---|
4835 | { |
---|
4836 | return; |
---|
4837 | } |
---|
4838 | |
---|
4839 | const TComVPSVUI* vpsVui = vps->getVPSVUI(); |
---|
4840 | assert( vpsVui != NULL ); |
---|
4841 | |
---|
4842 | const TComVideoSignalInfo* videoSignalInfo = vpsVui->getVideoSignalInfo( vpsVui->getVpsVideoSignalInfoIdx( vps->getLayerIdInVps( layerIdCurr ) ) ); |
---|
4843 | assert( videoSignalInfo != NULL ); |
---|
4844 | |
---|
4845 | setVideoFormat ( videoSignalInfo->getVideoVpsFormat () ); |
---|
4846 | setVideoFullRangeFlag ( videoSignalInfo->getVideoFullRangeVpsFlag () ); |
---|
4847 | setColourPrimaries ( videoSignalInfo->getColourPrimariesVps () ); |
---|
4848 | setTransferCharacteristics( videoSignalInfo->getTransferCharacteristicsVps() ); |
---|
4849 | setMatrixCoefficients ( videoSignalInfo->getMatrixCoeffsVps () ); |
---|
4850 | } |
---|
4851 | |
---|
4852 | Void TComDpbSize::init( Int numOutputLayerSets, Int maxNumLayerIds, Int maxNumSubLayers ) |
---|
4853 | { |
---|
4854 | m_subLayerFlagInfoPresentFlag.resize( numOutputLayerSets ); |
---|
4855 | m_subLayerDpbInfoPresentFlag .resize( numOutputLayerSets ); |
---|
4856 | m_maxVpsDecPicBufferingMinus1.resize( numOutputLayerSets ); |
---|
4857 | m_maxVpsNumReorderPics .resize( numOutputLayerSets ); |
---|
4858 | m_maxVpsLatencyIncreasePlus1 .resize( numOutputLayerSets ); |
---|
4859 | |
---|
4860 | for (Int i = 0; i < numOutputLayerSets; i++ ) |
---|
4861 | { |
---|
4862 | m_subLayerFlagInfoPresentFlag[i] = false; |
---|
4863 | |
---|
4864 | m_subLayerDpbInfoPresentFlag [i].resize( maxNumSubLayers ); |
---|
4865 | m_maxVpsDecPicBufferingMinus1[i].resize( maxNumLayerIds ); |
---|
4866 | m_maxVpsNumReorderPics [i].resize( maxNumSubLayers ); |
---|
4867 | m_maxVpsLatencyIncreasePlus1 [i].resize( maxNumSubLayers ); |
---|
4868 | |
---|
4869 | for (Int j = 0; j < maxNumSubLayers; j++ ) |
---|
4870 | { |
---|
4871 | m_subLayerDpbInfoPresentFlag [i][j] = ( j == 0) ; |
---|
4872 | m_maxVpsNumReorderPics [i][j] = 0; |
---|
4873 | m_maxVpsLatencyIncreasePlus1 [i][j] = 0; |
---|
4874 | } |
---|
4875 | |
---|
4876 | for (Int k = 0; k < maxNumLayerIds; k++ ) |
---|
4877 | { |
---|
4878 | m_maxVpsDecPicBufferingMinus1[i][k].resize( maxNumSubLayers ); |
---|
4879 | for (Int j = 0; j < maxNumSubLayers; j++ ) |
---|
4880 | { |
---|
4881 | m_maxVpsDecPicBufferingMinus1[i][k][j] = MIN_INT; |
---|
4882 | } |
---|
4883 | } |
---|
4884 | } |
---|
4885 | } |
---|
4886 | |
---|
4887 | Void Window::scaleOffsets( Int scal ) |
---|
4888 | { |
---|
4889 | if (! m_scaledFlag ) |
---|
4890 | { |
---|
4891 | m_scaledFlag = true; |
---|
4892 | m_winLeftOffset *= scal; |
---|
4893 | m_winRightOffset *= scal; |
---|
4894 | m_winTopOffset *= scal; |
---|
4895 | m_winBottomOffset *= scal; |
---|
4896 | } |
---|
4897 | } |
---|
4898 | #endif |
---|