1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file 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 | //! \ingroup TLibCommon |
---|
45 | //! \{ |
---|
46 | |
---|
47 | |
---|
48 | TComSlice::TComSlice() |
---|
49 | : m_iPPSId ( -1 ) |
---|
50 | #if H_MV |
---|
51 | , m_slicePicOrderCntLsb ( 0 ) |
---|
52 | #endif |
---|
53 | , m_iPOC ( 0 ) |
---|
54 | , m_iLastIDR ( 0 ) |
---|
55 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
56 | , m_eSliceType ( I_SLICE ) |
---|
57 | , m_iSliceQp ( 0 ) |
---|
58 | , m_dependentSliceSegmentFlag ( false ) |
---|
59 | #if ADAPTIVE_QP_SELECTION |
---|
60 | , m_iSliceQpBase ( 0 ) |
---|
61 | #endif |
---|
62 | , m_deblockingFilterDisable ( false ) |
---|
63 | , m_deblockingFilterOverrideFlag ( false ) |
---|
64 | , m_deblockingFilterBetaOffsetDiv2 ( 0 ) |
---|
65 | , m_deblockingFilterTcOffsetDiv2 ( 0 ) |
---|
66 | , m_bCheckLDC ( false ) |
---|
67 | , m_iSliceQpDelta ( 0 ) |
---|
68 | , m_iSliceQpDeltaCb ( 0 ) |
---|
69 | , m_iSliceQpDeltaCr ( 0 ) |
---|
70 | , m_iDepth ( 0 ) |
---|
71 | , m_bRefenced ( false ) |
---|
72 | , m_pcSPS ( NULL ) |
---|
73 | , m_pcPPS ( NULL ) |
---|
74 | , m_pcPic ( NULL ) |
---|
75 | , m_colFromL0Flag ( 1 ) |
---|
76 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
77 | , m_noOutputPriorPicsFlag ( false ) |
---|
78 | , m_noRaslOutputFlag ( false ) |
---|
79 | , m_handleCraAsBlaFlag ( false ) |
---|
80 | #endif |
---|
81 | , m_colRefIdx ( 0 ) |
---|
82 | , m_uiTLayer ( 0 ) |
---|
83 | , m_bTLayerSwitchingFlag ( false ) |
---|
84 | , m_sliceMode ( 0 ) |
---|
85 | , m_sliceArgument ( 0 ) |
---|
86 | , m_sliceCurStartCUAddr ( 0 ) |
---|
87 | , m_sliceCurEndCUAddr ( 0 ) |
---|
88 | , m_sliceIdx ( 0 ) |
---|
89 | , m_sliceSegmentMode ( 0 ) |
---|
90 | , m_sliceSegmentArgument ( 0 ) |
---|
91 | , m_sliceSegmentCurStartCUAddr ( 0 ) |
---|
92 | , m_sliceSegmentCurEndCUAddr ( 0 ) |
---|
93 | , m_nextSlice ( false ) |
---|
94 | , m_nextSliceSegment ( false ) |
---|
95 | , m_sliceBits ( 0 ) |
---|
96 | , m_sliceSegmentBits ( 0 ) |
---|
97 | , m_bFinalized ( false ) |
---|
98 | , m_uiTileOffstForMultES ( 0 ) |
---|
99 | , m_puiSubstreamSizes ( NULL ) |
---|
100 | , m_cabacInitFlag ( false ) |
---|
101 | , m_bLMvdL1Zero ( false ) |
---|
102 | , m_numEntryPointOffsets ( 0 ) |
---|
103 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
104 | , m_enableTMVPFlag ( true ) |
---|
105 | #if I0044_SLICE_TMVP |
---|
106 | , m_availableForTMVPRefFlag ( true ) |
---|
107 | #endif |
---|
108 | #if H_MV |
---|
109 | , m_refPicSetInterLayer0 ( NULL ) |
---|
110 | , m_refPicSetInterLayer1 ( NULL ) |
---|
111 | , m_layerId (0) |
---|
112 | , m_viewId (0) |
---|
113 | , m_viewIndex (0) |
---|
114 | #if !H_MV_HLS7_GEN |
---|
115 | , m_pocResetFlag (false) |
---|
116 | #endif |
---|
117 | #if H_MV |
---|
118 | , m_crossLayerBlaFlag (false) |
---|
119 | #endif |
---|
120 | , m_discardableFlag (false) |
---|
121 | , m_interLayerPredEnabledFlag (false) |
---|
122 | , m_numInterLayerRefPicsMinus1 (0) |
---|
123 | #if H_MV |
---|
124 | , m_sliceSegmentHeaderExtensionLength (0) |
---|
125 | , m_pocResetIdc (0) |
---|
126 | , m_pocResetPeriodId (0) |
---|
127 | , m_fullPocResetFlag (false) |
---|
128 | , m_pocLsbVal (0) |
---|
129 | , m_pocMsbValPresentFlag (false) |
---|
130 | , m_pocMsbVal (0) |
---|
131 | , m_pocMsbValRequiredFlag ( false ) |
---|
132 | #endif |
---|
133 | #endif |
---|
134 | { |
---|
135 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = 0; |
---|
136 | |
---|
137 | initEqualRef(); |
---|
138 | |
---|
139 | for (Int component = 0; component < 3; component++) |
---|
140 | { |
---|
141 | m_lambdas[component] = 0.0; |
---|
142 | } |
---|
143 | |
---|
144 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
145 | { |
---|
146 | m_list1IdxToList0Idx[idx] = -1; |
---|
147 | } |
---|
148 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
149 | { |
---|
150 | m_apcRefPicList [0][iNumCount] = NULL; |
---|
151 | m_apcRefPicList [1][iNumCount] = NULL; |
---|
152 | m_aiRefPOCList [0][iNumCount] = 0; |
---|
153 | m_aiRefPOCList [1][iNumCount] = 0; |
---|
154 | #if H_MV |
---|
155 | m_aiRefLayerIdList[0][iNumCount] = 0; |
---|
156 | m_aiRefLayerIdList[1][iNumCount] = 0; |
---|
157 | #endif |
---|
158 | } |
---|
159 | resetWpScaling(); |
---|
160 | initWpAcDcParam(); |
---|
161 | m_saoEnabledFlag = false; |
---|
162 | m_saoEnabledFlagChroma = false; |
---|
163 | #if H_MV |
---|
164 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
165 | { |
---|
166 | m_interLayerPredLayerIdc[ i ] = -1; |
---|
167 | } |
---|
168 | #endif |
---|
169 | } |
---|
170 | |
---|
171 | TComSlice::~TComSlice() |
---|
172 | { |
---|
173 | delete[] m_puiSubstreamSizes; |
---|
174 | m_puiSubstreamSizes = NULL; |
---|
175 | } |
---|
176 | |
---|
177 | |
---|
178 | Void TComSlice::initSlice() |
---|
179 | { |
---|
180 | m_aiNumRefIdx[0] = 0; |
---|
181 | m_aiNumRefIdx[1] = 0; |
---|
182 | |
---|
183 | m_colFromL0Flag = 1; |
---|
184 | |
---|
185 | m_colRefIdx = 0; |
---|
186 | initEqualRef(); |
---|
187 | m_bCheckLDC = false; |
---|
188 | m_iSliceQpDeltaCb = 0; |
---|
189 | m_iSliceQpDeltaCr = 0; |
---|
190 | |
---|
191 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
192 | |
---|
193 | m_bFinalized=false; |
---|
194 | |
---|
195 | m_tileByteLocation.clear(); |
---|
196 | m_cabacInitFlag = false; |
---|
197 | m_numEntryPointOffsets = 0; |
---|
198 | m_enableTMVPFlag = true; |
---|
199 | } |
---|
200 | |
---|
201 | Bool TComSlice::getRapPicFlag() |
---|
202 | { |
---|
203 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
204 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
205 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
206 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
207 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
208 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
209 | } |
---|
210 | |
---|
211 | /** |
---|
212 | - allocate table to contain substream sizes to be written to the slice header. |
---|
213 | . |
---|
214 | \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1. |
---|
215 | */ |
---|
216 | Void TComSlice::allocSubstreamSizes(UInt uiNumSubstreams) |
---|
217 | { |
---|
218 | delete[] m_puiSubstreamSizes; |
---|
219 | m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0]; |
---|
220 | } |
---|
221 | |
---|
222 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
223 | { |
---|
224 | TComPic* pcPicExtract; |
---|
225 | TComPic* pcPicInsert; |
---|
226 | |
---|
227 | TComList<TComPic*>::iterator iterPicExtract; |
---|
228 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
229 | TComList<TComPic*>::iterator iterPicInsert; |
---|
230 | |
---|
231 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
232 | { |
---|
233 | iterPicExtract = rcListPic.begin(); |
---|
234 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
235 | pcPicExtract = *(iterPicExtract); |
---|
236 | pcPicExtract->setCurrSliceIdx(0); |
---|
237 | |
---|
238 | iterPicInsert = rcListPic.begin(); |
---|
239 | while (iterPicInsert != iterPicExtract) |
---|
240 | { |
---|
241 | pcPicInsert = *(iterPicInsert); |
---|
242 | pcPicInsert->setCurrSliceIdx(0); |
---|
243 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
244 | { |
---|
245 | break; |
---|
246 | } |
---|
247 | |
---|
248 | iterPicInsert++; |
---|
249 | } |
---|
250 | |
---|
251 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
252 | |
---|
253 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
254 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
255 | rcListPic.erase (iterPicExtract); |
---|
256 | } |
---|
257 | } |
---|
258 | |
---|
259 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, |
---|
260 | Int poc) |
---|
261 | { |
---|
262 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
263 | TComPic* pcPic = *(iterPic); |
---|
264 | while ( iterPic != rcListPic.end() ) |
---|
265 | { |
---|
266 | if(pcPic->getPOC() == poc) |
---|
267 | { |
---|
268 | break; |
---|
269 | } |
---|
270 | iterPic++; |
---|
271 | pcPic = *(iterPic); |
---|
272 | } |
---|
273 | return pcPic; |
---|
274 | } |
---|
275 | |
---|
276 | |
---|
277 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
278 | { |
---|
279 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
280 | TComPic* pcPic = *(iterPic); |
---|
281 | TComPic* pcStPic = pcPic; |
---|
282 | |
---|
283 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
284 | if (!pocHasMsb) |
---|
285 | { |
---|
286 | poc = poc & (pocCycle - 1); |
---|
287 | } |
---|
288 | |
---|
289 | while ( iterPic != rcListPic.end() ) |
---|
290 | { |
---|
291 | pcPic = *(iterPic); |
---|
292 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
293 | { |
---|
294 | Int picPoc = pcPic->getPOC(); |
---|
295 | if (!pocHasMsb) |
---|
296 | { |
---|
297 | picPoc = picPoc & (pocCycle - 1); |
---|
298 | } |
---|
299 | |
---|
300 | if (poc == picPoc) |
---|
301 | { |
---|
302 | if(pcPic->getIsLongTerm()) |
---|
303 | { |
---|
304 | return pcPic; |
---|
305 | } |
---|
306 | else |
---|
307 | { |
---|
308 | pcStPic = pcPic; |
---|
309 | } |
---|
310 | break; |
---|
311 | } |
---|
312 | } |
---|
313 | |
---|
314 | iterPic++; |
---|
315 | } |
---|
316 | |
---|
317 | return pcStPic; |
---|
318 | } |
---|
319 | |
---|
320 | Void TComSlice::setRefPOCList () |
---|
321 | { |
---|
322 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
323 | { |
---|
324 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
325 | { |
---|
326 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
327 | #if H_MV |
---|
328 | m_aiRefLayerIdList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getLayerId(); |
---|
329 | #endif |
---|
330 | } |
---|
331 | } |
---|
332 | |
---|
333 | } |
---|
334 | |
---|
335 | Void TComSlice::setList1IdxToList0Idx() |
---|
336 | { |
---|
337 | Int idxL0, idxL1; |
---|
338 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
339 | { |
---|
340 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
341 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
342 | { |
---|
343 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
344 | { |
---|
345 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
346 | break; |
---|
347 | } |
---|
348 | } |
---|
349 | } |
---|
350 | } |
---|
351 | |
---|
352 | #if !H_MV |
---|
353 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) |
---|
354 | { |
---|
355 | if (!checkNumPocTotalCurr) |
---|
356 | { |
---|
357 | if (m_eSliceType == I_SLICE) |
---|
358 | { |
---|
359 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
360 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
361 | |
---|
362 | return; |
---|
363 | } |
---|
364 | |
---|
365 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
366 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
367 | } |
---|
368 | |
---|
369 | TComPic* pcRefPic= NULL; |
---|
370 | TComPic* RefPicSetStCurr0[16]; |
---|
371 | TComPic* RefPicSetStCurr1[16]; |
---|
372 | TComPic* RefPicSetLtCurr[16]; |
---|
373 | UInt NumPocStCurr0 = 0; |
---|
374 | UInt NumPocStCurr1 = 0; |
---|
375 | UInt NumPocLtCurr = 0; |
---|
376 | Int i; |
---|
377 | |
---|
378 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
379 | { |
---|
380 | if(m_pcRPS->getUsed(i)) |
---|
381 | { |
---|
382 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
383 | pcRefPic->setIsLongTerm(0); |
---|
384 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
385 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
386 | NumPocStCurr0++; |
---|
387 | pcRefPic->setCheckLTMSBPresent(false); |
---|
388 | } |
---|
389 | } |
---|
390 | |
---|
391 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
392 | { |
---|
393 | if(m_pcRPS->getUsed(i)) |
---|
394 | { |
---|
395 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
396 | pcRefPic->setIsLongTerm(0); |
---|
397 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
398 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
399 | NumPocStCurr1++; |
---|
400 | pcRefPic->setCheckLTMSBPresent(false); |
---|
401 | } |
---|
402 | } |
---|
403 | |
---|
404 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
405 | { |
---|
406 | if(m_pcRPS->getUsed(i)) |
---|
407 | { |
---|
408 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
409 | pcRefPic->setIsLongTerm(1); |
---|
410 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
411 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
412 | NumPocLtCurr++; |
---|
413 | } |
---|
414 | if(pcRefPic==NULL) |
---|
415 | { |
---|
416 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
417 | } |
---|
418 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
419 | } |
---|
420 | |
---|
421 | // ref_pic_list_init |
---|
422 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
423 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
424 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
425 | if (checkNumPocTotalCurr) |
---|
426 | { |
---|
427 | // 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: |
---|
428 | // - If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
429 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
430 | if (getRapPicFlag()) |
---|
431 | { |
---|
432 | assert(numPocTotalCurr == 0); |
---|
433 | } |
---|
434 | |
---|
435 | if (m_eSliceType == I_SLICE) |
---|
436 | { |
---|
437 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
438 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
439 | |
---|
440 | return; |
---|
441 | } |
---|
442 | |
---|
443 | assert(numPocTotalCurr > 0); |
---|
444 | |
---|
445 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
446 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
447 | } |
---|
448 | |
---|
449 | Int cIdx = 0; |
---|
450 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
451 | { |
---|
452 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
453 | } |
---|
454 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
455 | { |
---|
456 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
457 | } |
---|
458 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
459 | { |
---|
460 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
461 | } |
---|
462 | assert(cIdx == numPocTotalCurr); |
---|
463 | |
---|
464 | if (m_eSliceType==B_SLICE) |
---|
465 | { |
---|
466 | cIdx = 0; |
---|
467 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
468 | { |
---|
469 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
470 | } |
---|
471 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
472 | { |
---|
473 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
474 | } |
---|
475 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
476 | { |
---|
477 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
478 | } |
---|
479 | assert(cIdx == numPocTotalCurr); |
---|
480 | } |
---|
481 | |
---|
482 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
483 | |
---|
484 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[0]; rIdx ++) |
---|
485 | { |
---|
486 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPocTotalCurr; |
---|
487 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
488 | m_apcRefPicList[0][rIdx] = rpsCurrList0[ cIdx ]; |
---|
489 | m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
490 | } |
---|
491 | if ( m_eSliceType != B_SLICE ) |
---|
492 | { |
---|
493 | m_aiNumRefIdx[1] = 0; |
---|
494 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
495 | } |
---|
496 | else |
---|
497 | { |
---|
498 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[1]; rIdx ++) |
---|
499 | { |
---|
500 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPocTotalCurr; |
---|
501 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
502 | m_apcRefPicList[1][rIdx] = rpsCurrList1[ cIdx ]; |
---|
503 | m_bIsUsedAsLongTerm[1][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
504 | } |
---|
505 | } |
---|
506 | } |
---|
507 | |
---|
508 | #else |
---|
509 | Void TComSlice::getTempRefPicLists( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1, |
---|
510 | std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int& numPocTotalCurr, Bool checkNumPocTotalCurr ) |
---|
511 | { |
---|
512 | if (!checkNumPocTotalCurr) |
---|
513 | { |
---|
514 | if (m_eSliceType == I_SLICE) |
---|
515 | { |
---|
516 | return; |
---|
517 | } |
---|
518 | } |
---|
519 | |
---|
520 | TComPic* pcRefPic= NULL; |
---|
521 | TComPic* RefPicSetStCurr0[16]; |
---|
522 | TComPic* RefPicSetStCurr1[16]; |
---|
523 | TComPic* RefPicSetLtCurr[16]; |
---|
524 | UInt NumPocStCurr0 = 0; |
---|
525 | UInt NumPocStCurr1 = 0; |
---|
526 | UInt NumPocLtCurr = 0; |
---|
527 | Int i; |
---|
528 | |
---|
529 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
530 | { |
---|
531 | if(m_pcRPS->getUsed(i)) |
---|
532 | { |
---|
533 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
534 | pcRefPic->setIsLongTerm(0); |
---|
535 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
536 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
537 | NumPocStCurr0++; |
---|
538 | pcRefPic->setCheckLTMSBPresent(false); |
---|
539 | } |
---|
540 | } |
---|
541 | |
---|
542 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
543 | { |
---|
544 | if(m_pcRPS->getUsed(i)) |
---|
545 | { |
---|
546 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
547 | pcRefPic->setIsLongTerm(0); |
---|
548 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
549 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
550 | NumPocStCurr1++; |
---|
551 | pcRefPic->setCheckLTMSBPresent(false); |
---|
552 | } |
---|
553 | } |
---|
554 | |
---|
555 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
556 | { |
---|
557 | if(m_pcRPS->getUsed(i)) |
---|
558 | { |
---|
559 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
560 | pcRefPic->setIsLongTerm(1); |
---|
561 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
562 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
563 | NumPocLtCurr++; |
---|
564 | } |
---|
565 | if(pcRefPic==NULL) |
---|
566 | { |
---|
567 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
568 | } |
---|
569 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
570 | } |
---|
571 | |
---|
572 | Int numPocInterCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
573 | numPocTotalCurr = numPocInterCurr + getNumActiveRefLayerPics( ); |
---|
574 | assert( numPocTotalCurr == getNumRpsCurrTempList() ); |
---|
575 | |
---|
576 | if (checkNumPocTotalCurr) |
---|
577 | { |
---|
578 | // 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: |
---|
579 | // - 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. |
---|
580 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
581 | if ( getRapPicFlag() && m_layerId == 0 ) |
---|
582 | { |
---|
583 | assert(numPocTotalCurr == 0); |
---|
584 | } |
---|
585 | |
---|
586 | if (m_eSliceType == I_SLICE) |
---|
587 | { |
---|
588 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
589 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
590 | |
---|
591 | return; |
---|
592 | } |
---|
593 | |
---|
594 | assert(numPocTotalCurr > 0); |
---|
595 | |
---|
596 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
597 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
598 | } |
---|
599 | |
---|
600 | std::vector<TComPic*>* refPicSetInterLayer[2] = { &refPicSetInterLayer0, &refPicSetInterLayer1}; |
---|
601 | Int numPocInterLayer[2] = { getNumActiveRefLayerPics0( ), getNumActiveRefLayerPics1( ) }; |
---|
602 | |
---|
603 | TComPic** refPicSetStCurr [2] = { RefPicSetStCurr0, RefPicSetStCurr1 }; |
---|
604 | Int numPocStCurr[2] = { NumPocStCurr0, NumPocStCurr1 }; |
---|
605 | |
---|
606 | for (Int li = 0; li < ((m_eSliceType==B_SLICE) ? 2 : 1); li++) |
---|
607 | { |
---|
608 | rpsCurrList [li].resize(MAX_NUM_REF+1,NULL ); |
---|
609 | usedAsLongTerm[li].resize(MAX_NUM_REF+1,false); |
---|
610 | |
---|
611 | Int cIdx = 0; |
---|
612 | for ( i=0; i < numPocStCurr[li]; i++, cIdx++) |
---|
613 | { |
---|
614 | rpsCurrList[li][cIdx] = refPicSetStCurr[li][i]; |
---|
615 | usedAsLongTerm [li][cIdx] = false; |
---|
616 | } |
---|
617 | |
---|
618 | for ( i=0; i < numPocInterLayer[li]; i++, cIdx++) |
---|
619 | { |
---|
620 | rpsCurrList[li][cIdx] = (*refPicSetInterLayer[li])[i]; |
---|
621 | usedAsLongTerm [li][cIdx] = true; |
---|
622 | } |
---|
623 | |
---|
624 | for ( i=0; i < numPocStCurr[1-li]; i++, cIdx++) |
---|
625 | { |
---|
626 | rpsCurrList[li][cIdx] = refPicSetStCurr[1-li][i]; |
---|
627 | usedAsLongTerm [li][cIdx] = false; |
---|
628 | } |
---|
629 | |
---|
630 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
631 | { |
---|
632 | rpsCurrList[li][cIdx] = RefPicSetLtCurr[i]; |
---|
633 | usedAsLongTerm [li][cIdx] = true; |
---|
634 | } |
---|
635 | |
---|
636 | for ( i=0; i < numPocInterLayer[1-li]; i++, cIdx++) |
---|
637 | { |
---|
638 | assert( cIdx < MAX_NUM_REF ); |
---|
639 | rpsCurrList[li][cIdx] = (*refPicSetInterLayer[1-li])[i]; |
---|
640 | usedAsLongTerm [li][cIdx] = true; |
---|
641 | } |
---|
642 | |
---|
643 | assert(cIdx == numPocTotalCurr); |
---|
644 | } |
---|
645 | } |
---|
646 | |
---|
647 | Void TComSlice::setRefPicList( std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int numPocTotalCurr, Bool checkNumPocTotalCurr ) |
---|
648 | |
---|
649 | { |
---|
650 | if (!checkNumPocTotalCurr) |
---|
651 | { |
---|
652 | if (m_eSliceType == I_SLICE) |
---|
653 | { |
---|
654 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
655 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
656 | |
---|
657 | return; |
---|
658 | } |
---|
659 | } |
---|
660 | |
---|
661 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
662 | |
---|
663 | for (Int li = 0; li < 2; li++) |
---|
664 | { |
---|
665 | if ( m_eSliceType == P_SLICE && li == 1 ) |
---|
666 | { |
---|
667 | m_aiNumRefIdx[1] = 0; |
---|
668 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
669 | } |
---|
670 | else |
---|
671 | { |
---|
672 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[ li ] - 1 ); rIdx ++) |
---|
673 | { |
---|
674 | Bool listModified = m_RefPicListModification.getRefPicListModificationFlagL( li ); |
---|
675 | Int orgIdx = listModified ? m_RefPicListModification.getRefPicSetIdxL(li, rIdx) : (rIdx % numPocTotalCurr); |
---|
676 | |
---|
677 | assert( rpsCurrList[li][ orgIdx ] != NULL ); |
---|
678 | #if DISCARDABLE_PIC_RPS |
---|
679 | assert( rpsCurrList[li][ orgIdx ]->getSlice(0)->getDiscardableFlag() == 0 ); // Inter-layer RPS shall not contain picture with discardable_flag = 1. |
---|
680 | #endif |
---|
681 | m_apcRefPicList [li][rIdx] = rpsCurrList [li][ orgIdx ]; |
---|
682 | m_bIsUsedAsLongTerm[li][rIdx] = usedAsLongTerm [li][ orgIdx ] ; |
---|
683 | } |
---|
684 | } |
---|
685 | } |
---|
686 | } |
---|
687 | #endif |
---|
688 | Int TComSlice::getNumRpsCurrTempList() |
---|
689 | { |
---|
690 | Int numRpsCurrTempList = 0; |
---|
691 | |
---|
692 | if (m_eSliceType == I_SLICE) |
---|
693 | { |
---|
694 | return 0; |
---|
695 | } |
---|
696 | for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++) |
---|
697 | { |
---|
698 | if(m_pcRPS->getUsed(i)) |
---|
699 | { |
---|
700 | numRpsCurrTempList++; |
---|
701 | } |
---|
702 | } |
---|
703 | #if H_MV |
---|
704 | numRpsCurrTempList = numRpsCurrTempList + getNumActiveRefLayerPics(); |
---|
705 | #endif |
---|
706 | return numRpsCurrTempList; |
---|
707 | } |
---|
708 | |
---|
709 | Void TComSlice::initEqualRef() |
---|
710 | { |
---|
711 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
712 | { |
---|
713 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
714 | { |
---|
715 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
716 | { |
---|
717 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
718 | } |
---|
719 | } |
---|
720 | } |
---|
721 | } |
---|
722 | |
---|
723 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
724 | { |
---|
725 | Int i; |
---|
726 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
727 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1-curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
728 | TComSlice* preSlice; |
---|
729 | Int preColRefPOC; |
---|
730 | for(i=curSliceIdx-1; i>=0; i--) |
---|
731 | { |
---|
732 | preSlice = pic->getSlice(i); |
---|
733 | if(preSlice->getSliceType() != I_SLICE) |
---|
734 | { |
---|
735 | preColRefPOC = preSlice->getRefPOC( RefPicList(1-preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
736 | if(currColRefPOC != preColRefPOC) |
---|
737 | { |
---|
738 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
739 | exit(EXIT_FAILURE); |
---|
740 | } |
---|
741 | else |
---|
742 | { |
---|
743 | break; |
---|
744 | } |
---|
745 | } |
---|
746 | } |
---|
747 | } |
---|
748 | |
---|
749 | Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic) |
---|
750 | { |
---|
751 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
752 | { |
---|
753 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
754 | { |
---|
755 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
756 | } |
---|
757 | } |
---|
758 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
759 | { |
---|
760 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
761 | { |
---|
762 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
763 | { |
---|
764 | assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA); |
---|
765 | } |
---|
766 | else |
---|
767 | { |
---|
768 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
769 | } |
---|
770 | } |
---|
771 | } |
---|
772 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
773 | { |
---|
774 | pocCRA = getPOC(); |
---|
775 | associatedIRAPType = getNalUnitType(); |
---|
776 | } |
---|
777 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
778 | { |
---|
779 | pocCRA = getPOC(); |
---|
780 | associatedIRAPType = getNalUnitType(); |
---|
781 | } |
---|
782 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
783 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
784 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
785 | { |
---|
786 | pocCRA = getPOC(); |
---|
787 | associatedIRAPType = getNalUnitType(); |
---|
788 | } |
---|
789 | } |
---|
790 | |
---|
791 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
792 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
793 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
794 | * \param rcListPic reference to the reference picture list |
---|
795 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
796 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
797 | * are marked as "unused for reference" |
---|
798 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
799 | * Otherwise |
---|
800 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
801 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
802 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
803 | * the bRefreshPending flag to false. |
---|
804 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
805 | * reference of the current picture. |
---|
806 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
807 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
808 | */ |
---|
809 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
810 | { |
---|
811 | TComPic* rpcPic; |
---|
812 | #if !FIX1172 |
---|
813 | setAssociatedIRAPPOC(pocCRA); |
---|
814 | #endif |
---|
815 | Int pocCurr = getPOC(); |
---|
816 | |
---|
817 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
818 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
819 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
820 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
821 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
822 | { |
---|
823 | // mark all pictures as not used for reference |
---|
824 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
825 | while (iterPic != rcListPic.end()) |
---|
826 | { |
---|
827 | rpcPic = *(iterPic); |
---|
828 | rpcPic->setCurrSliceIdx(0); |
---|
829 | if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
830 | iterPic++; |
---|
831 | } |
---|
832 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
833 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
834 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
835 | { |
---|
836 | pocCRA = pocCurr; |
---|
837 | } |
---|
838 | #if EFFICIENT_FIELD_IRAP |
---|
839 | bRefreshPending = true; |
---|
840 | #endif |
---|
841 | } |
---|
842 | else // CRA or No DR |
---|
843 | { |
---|
844 | #if EFFICIENT_FIELD_IRAP |
---|
845 | if(getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
846 | { |
---|
847 | if (bRefreshPending==true && pocCurr > m_iLastIDR) // IDR reference marking pending |
---|
848 | { |
---|
849 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
850 | while (iterPic != rcListPic.end()) |
---|
851 | { |
---|
852 | rpcPic = *(iterPic); |
---|
853 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != m_iLastIDR) |
---|
854 | { |
---|
855 | rpcPic->getSlice(0)->setReferenced(false); |
---|
856 | } |
---|
857 | iterPic++; |
---|
858 | } |
---|
859 | bRefreshPending = false; |
---|
860 | } |
---|
861 | } |
---|
862 | else |
---|
863 | { |
---|
864 | #endif |
---|
865 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
866 | { |
---|
867 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
868 | while (iterPic != rcListPic.end()) |
---|
869 | { |
---|
870 | rpcPic = *(iterPic); |
---|
871 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
872 | { |
---|
873 | rpcPic->getSlice(0)->setReferenced(false); |
---|
874 | } |
---|
875 | iterPic++; |
---|
876 | } |
---|
877 | bRefreshPending = false; |
---|
878 | } |
---|
879 | #if EFFICIENT_FIELD_IRAP |
---|
880 | } |
---|
881 | #endif |
---|
882 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
883 | { |
---|
884 | bRefreshPending = true; |
---|
885 | pocCRA = pocCurr; |
---|
886 | } |
---|
887 | } |
---|
888 | } |
---|
889 | |
---|
890 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
891 | { |
---|
892 | assert( pSrc != NULL ); |
---|
893 | |
---|
894 | Int i, j, k; |
---|
895 | |
---|
896 | m_iPOC = pSrc->m_iPOC; |
---|
897 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
898 | #if H_MV |
---|
899 | m_layerId = pSrc->m_layerId; |
---|
900 | // GT: Copying of several other values might be be missing here, or is above not necessary? |
---|
901 | #endif |
---|
902 | m_eSliceType = pSrc->m_eSliceType; |
---|
903 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
904 | #if ADAPTIVE_QP_SELECTION |
---|
905 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
906 | #endif |
---|
907 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
908 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
909 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
910 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
911 | |
---|
912 | for (i = 0; i < 2; i++) |
---|
913 | { |
---|
914 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
915 | } |
---|
916 | |
---|
917 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
918 | { |
---|
919 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
920 | } |
---|
921 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
922 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
923 | m_iSliceQpDeltaCb = pSrc->m_iSliceQpDeltaCb; |
---|
924 | m_iSliceQpDeltaCr = pSrc->m_iSliceQpDeltaCr; |
---|
925 | for (i = 0; i < 2; i++) |
---|
926 | { |
---|
927 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
928 | { |
---|
929 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
930 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
931 | #if H_MV |
---|
932 | m_aiRefLayerIdList[i][j] = pSrc->m_aiRefLayerIdList[i][j]; |
---|
933 | #endif |
---|
934 | } |
---|
935 | } |
---|
936 | for (i = 0; i < 2; i++) |
---|
937 | { |
---|
938 | for (j = 0; j < MAX_NUM_REF + 1; j++) |
---|
939 | { |
---|
940 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
941 | } |
---|
942 | } |
---|
943 | m_iDepth = pSrc->m_iDepth; |
---|
944 | |
---|
945 | // referenced slice |
---|
946 | m_bRefenced = pSrc->m_bRefenced; |
---|
947 | |
---|
948 | // access channel |
---|
949 | #if H_MV |
---|
950 | m_pcVPS = pSrc->m_pcVPS; |
---|
951 | #endif |
---|
952 | m_pcSPS = pSrc->m_pcSPS; |
---|
953 | m_pcPPS = pSrc->m_pcPPS; |
---|
954 | m_pcRPS = pSrc->m_pcRPS; |
---|
955 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
956 | |
---|
957 | m_pcPic = pSrc->m_pcPic; |
---|
958 | |
---|
959 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
960 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
961 | setLambdas(pSrc->getLambdas()); |
---|
962 | for (i = 0; i < 2; i++) |
---|
963 | { |
---|
964 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
965 | { |
---|
966 | for (k =0; k < MAX_NUM_REF; k++) |
---|
967 | { |
---|
968 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
969 | } |
---|
970 | } |
---|
971 | } |
---|
972 | |
---|
973 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
974 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
975 | |
---|
976 | m_sliceMode = pSrc->m_sliceMode; |
---|
977 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
978 | m_sliceCurStartCUAddr = pSrc->m_sliceCurStartCUAddr; |
---|
979 | m_sliceCurEndCUAddr = pSrc->m_sliceCurEndCUAddr; |
---|
980 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
981 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
982 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
983 | m_sliceSegmentCurStartCUAddr = pSrc->m_sliceSegmentCurStartCUAddr; |
---|
984 | m_sliceSegmentCurEndCUAddr = pSrc->m_sliceSegmentCurEndCUAddr; |
---|
985 | m_nextSlice = pSrc->m_nextSlice; |
---|
986 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
987 | for ( Int e=0 ; e<2 ; e++ ) |
---|
988 | { |
---|
989 | for ( Int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
990 | { |
---|
991 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
992 | } |
---|
993 | } |
---|
994 | m_saoEnabledFlag = pSrc->m_saoEnabledFlag; |
---|
995 | m_saoEnabledFlagChroma = pSrc->m_saoEnabledFlagChroma; |
---|
996 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
997 | m_numEntryPointOffsets = pSrc->m_numEntryPointOffsets; |
---|
998 | |
---|
999 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
1000 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
1001 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
1002 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
1003 | |
---|
1004 | #if H_MV |
---|
1005 | // Additional slice header syntax elements |
---|
1006 | #if !H_MV_HLS7_GEN |
---|
1007 | m_pocResetFlag = pSrc->m_pocResetFlag; |
---|
1008 | #endif |
---|
1009 | m_discardableFlag = pSrc->m_discardableFlag; |
---|
1010 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
1011 | m_numInterLayerRefPicsMinus1 = pSrc->m_numInterLayerRefPicsMinus1; |
---|
1012 | |
---|
1013 | for (Int layer = 0; layer < MAX_NUM_LAYERS; layer++ ) |
---|
1014 | { |
---|
1015 | m_interLayerPredLayerIdc[ layer ] = pSrc->m_interLayerPredLayerIdc[ layer ]; |
---|
1016 | } |
---|
1017 | #endif |
---|
1018 | } |
---|
1019 | |
---|
1020 | Int TComSlice::m_prevTid0POC = 0; |
---|
1021 | |
---|
1022 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
1023 | * \param uiTLayer Temporal layer ID of the current slice |
---|
1024 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
1025 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
1026 | * temporal_layer_switching_point_flag is set accordingly. |
---|
1027 | */ |
---|
1028 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
1029 | { |
---|
1030 | m_uiTLayer = uiTLayer; |
---|
1031 | } |
---|
1032 | |
---|
1033 | /** Function for checking if this is a switching-point |
---|
1034 | */ |
---|
1035 | Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic ) |
---|
1036 | { |
---|
1037 | TComPic* rpcPic; |
---|
1038 | // loop through all pictures in the reference picture buffer |
---|
1039 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1040 | while ( iterPic != rcListPic.end()) |
---|
1041 | { |
---|
1042 | rpcPic = *(iterPic++); |
---|
1043 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
1044 | { |
---|
1045 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1046 | { |
---|
1047 | return false; |
---|
1048 | } |
---|
1049 | } |
---|
1050 | } |
---|
1051 | return true; |
---|
1052 | } |
---|
1053 | |
---|
1054 | /** Function for checking if this is a STSA candidate |
---|
1055 | */ |
---|
1056 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic ) |
---|
1057 | { |
---|
1058 | TComPic* rpcPic; |
---|
1059 | |
---|
1060 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1061 | while ( iterPic != rcListPic.end()) |
---|
1062 | { |
---|
1063 | rpcPic = *(iterPic++); |
---|
1064 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
1065 | { |
---|
1066 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1067 | { |
---|
1068 | return false; |
---|
1069 | } |
---|
1070 | } |
---|
1071 | } |
---|
1072 | return true; |
---|
1073 | } |
---|
1074 | |
---|
1075 | |
---|
1076 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) |
---|
1077 | { |
---|
1078 | TComPic* rpcPic; |
---|
1079 | |
---|
1080 | Int nalUnitType = this->getNalUnitType(); |
---|
1081 | |
---|
1082 | // When a picture is a leading picture, it shall be a RADL or RASL picture. |
---|
1083 | if(this->getAssociatedIRAPPOC() > this->getPOC()) |
---|
1084 | { |
---|
1085 | // Do not check IRAP pictures since they may get a POC lower than their associated IRAP |
---|
1086 | if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1087 | nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) |
---|
1088 | { |
---|
1089 | assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1090 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1091 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1092 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1093 | } |
---|
1094 | } |
---|
1095 | |
---|
1096 | // When a picture is a trailing picture, it shall not be a RADL or RASL picture. |
---|
1097 | if(this->getAssociatedIRAPPOC() < this->getPOC()) |
---|
1098 | { |
---|
1099 | assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && |
---|
1100 | nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && |
---|
1101 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && |
---|
1102 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1103 | } |
---|
1104 | |
---|
1105 | // No RASL pictures shall be present in the bitstream that are associated |
---|
1106 | // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. |
---|
1107 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1108 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1109 | { |
---|
1110 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && |
---|
1111 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); |
---|
1112 | } |
---|
1113 | |
---|
1114 | // No RASL pictures shall be present in the bitstream that are associated with |
---|
1115 | // an IDR picture. |
---|
1116 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1117 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1118 | { |
---|
1119 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && |
---|
1120 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
1121 | } |
---|
1122 | |
---|
1123 | // No RADL pictures shall be present in the bitstream that are associated with |
---|
1124 | // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated |
---|
1125 | // with an IDR picture having nal_unit_type equal to IDR_N_LP. |
---|
1126 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1127 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1128 | { |
---|
1129 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && |
---|
1130 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); |
---|
1131 | } |
---|
1132 | |
---|
1133 | // loop through all pictures in the reference picture buffer |
---|
1134 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1135 | while ( iterPic != rcListPic.end()) |
---|
1136 | { |
---|
1137 | rpcPic = *(iterPic++); |
---|
1138 | #if BUGFIX_INTRAPERIOD |
---|
1139 | if(!rpcPic->getReconMark()) |
---|
1140 | { |
---|
1141 | continue; |
---|
1142 | } |
---|
1143 | #endif |
---|
1144 | if (rpcPic->getPOC() == this->getPOC()) |
---|
1145 | { |
---|
1146 | continue; |
---|
1147 | } |
---|
1148 | |
---|
1149 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1150 | // in decoding order shall precede the IRAP picture in output order. |
---|
1151 | // (Note that any picture following in output order would be present in the DPB) |
---|
1152 | #if !SETTING_NO_OUT_PIC_PRIOR |
---|
1153 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
1154 | #else |
---|
1155 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1 && !this->getNoOutputPriorPicsFlag()) |
---|
1156 | #endif |
---|
1157 | { |
---|
1158 | if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1159 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1160 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1161 | nalUnitType == NAL_UNIT_CODED_SLICE_CRA || |
---|
1162 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1163 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
1164 | { |
---|
1165 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1166 | } |
---|
1167 | } |
---|
1168 | |
---|
1169 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1170 | // in decoding order shall precede any RADL picture associated with the IRAP |
---|
1171 | // picture in output order. |
---|
1172 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
1173 | { |
---|
1174 | if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1175 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) |
---|
1176 | { |
---|
1177 | // rpcPic precedes the IRAP in decoding order |
---|
1178 | if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1179 | { |
---|
1180 | // rpcPic must not be the IRAP picture |
---|
1181 | if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) |
---|
1182 | { |
---|
1183 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1184 | } |
---|
1185 | } |
---|
1186 | } |
---|
1187 | } |
---|
1188 | |
---|
1189 | // When a picture is a leading picture, it shall precede, in decoding order, |
---|
1190 | // all trailing pictures that are associated with the same IRAP picture. |
---|
1191 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1192 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1193 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1194 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1195 | { |
---|
1196 | if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) |
---|
1197 | { |
---|
1198 | // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB |
---|
1199 | // rpcPic would violate the constraint if it was a trailing picture |
---|
1200 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
1201 | } |
---|
1202 | } |
---|
1203 | |
---|
1204 | // Any RASL picture associated with a CRA or BLA picture shall precede any |
---|
1205 | // RADL picture associated with the CRA or BLA picture in output order |
---|
1206 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1207 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1208 | { |
---|
1209 | if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1210 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1211 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1212 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && |
---|
1213 | this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1214 | { |
---|
1215 | if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1216 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1217 | { |
---|
1218 | assert(rpcPic->getPOC() > this->getPOC()); |
---|
1219 | } |
---|
1220 | } |
---|
1221 | } |
---|
1222 | |
---|
1223 | // Any RASL picture associated with a CRA picture shall follow, in output |
---|
1224 | // order, any IRAP picture that precedes the CRA picture in decoding order. |
---|
1225 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1226 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1227 | { |
---|
1228 | if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
1229 | { |
---|
1230 | if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && |
---|
1231 | (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1232 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1233 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1234 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1235 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || |
---|
1236 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) |
---|
1237 | { |
---|
1238 | assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); |
---|
1239 | } |
---|
1240 | } |
---|
1241 | } |
---|
1242 | } |
---|
1243 | } |
---|
1244 | |
---|
1245 | |
---|
1246 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1247 | */ |
---|
1248 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
1249 | { |
---|
1250 | TComPic* rpcPic; |
---|
1251 | Int i, isReference; |
---|
1252 | |
---|
1253 | checkLeadingPictureRestrictions(rcListPic); |
---|
1254 | |
---|
1255 | // loop through all pictures in the reference picture buffer |
---|
1256 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1257 | while ( iterPic != rcListPic.end()) |
---|
1258 | { |
---|
1259 | rpcPic = *(iterPic++); |
---|
1260 | |
---|
1261 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
1262 | { |
---|
1263 | continue; |
---|
1264 | } |
---|
1265 | |
---|
1266 | isReference = 0; |
---|
1267 | // loop through all pictures in the Reference Picture Set |
---|
1268 | // to see if the picture should be kept as reference picture |
---|
1269 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
1270 | { |
---|
1271 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
1272 | { |
---|
1273 | isReference = 1; |
---|
1274 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1275 | rpcPic->setIsLongTerm(0); |
---|
1276 | } |
---|
1277 | } |
---|
1278 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1279 | { |
---|
1280 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1281 | { |
---|
1282 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
1283 | { |
---|
1284 | isReference = 1; |
---|
1285 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1286 | } |
---|
1287 | } |
---|
1288 | else |
---|
1289 | { |
---|
1290 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1291 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1292 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1293 | if(rpcPic->getIsLongTerm() && curPoc == refPoc) |
---|
1294 | { |
---|
1295 | isReference = 1; |
---|
1296 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1297 | } |
---|
1298 | } |
---|
1299 | |
---|
1300 | } |
---|
1301 | #if H_MV |
---|
1302 | if( isReference ) // Current picture is in the temporal RPS |
---|
1303 | { |
---|
1304 | assert( rpcPic->getSlice(0)->getDiscardableFlag() == 0 ); // Temporal RPS shall not contain picture with discardable_flag equal to 1 |
---|
1305 | } |
---|
1306 | #endif |
---|
1307 | // mark the picture as "unused for reference" if it is not in |
---|
1308 | // the Reference Picture Set |
---|
1309 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
1310 | { |
---|
1311 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
1312 | rpcPic->setUsedByCurr(0); |
---|
1313 | rpcPic->setIsLongTerm(0); |
---|
1314 | } |
---|
1315 | //check that pictures of higher temporal layers are not used |
---|
1316 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
1317 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
1318 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
1319 | { |
---|
1320 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
1321 | } |
---|
1322 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
1323 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
1324 | { |
---|
1325 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
1326 | } |
---|
1327 | } |
---|
1328 | } |
---|
1329 | |
---|
1330 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1331 | */ |
---|
1332 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1333 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1334 | #else |
---|
1335 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess) |
---|
1336 | #endif |
---|
1337 | { |
---|
1338 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1339 | Int atLeastOneUnabledByRecoveryPoint = 0; |
---|
1340 | Int atLeastOneFlushedByPreviousIDR = 0; |
---|
1341 | #endif |
---|
1342 | TComPic* rpcPic; |
---|
1343 | Int i, isAvailable; |
---|
1344 | Int atLeastOneLost = 0; |
---|
1345 | Int atLeastOneRemoved = 0; |
---|
1346 | Int iPocLost = 0; |
---|
1347 | |
---|
1348 | // loop through all long-term pictures in the Reference Picture Set |
---|
1349 | // to see if the picture should be kept as reference picture |
---|
1350 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1351 | { |
---|
1352 | isAvailable = 0; |
---|
1353 | // loop through all pictures in the reference picture buffer |
---|
1354 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1355 | while ( iterPic != rcListPic.end()) |
---|
1356 | { |
---|
1357 | rpcPic = *(iterPic++); |
---|
1358 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1359 | { |
---|
1360 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1361 | { |
---|
1362 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1363 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1364 | { |
---|
1365 | isAvailable = 0; |
---|
1366 | } |
---|
1367 | else |
---|
1368 | { |
---|
1369 | isAvailable = 1; |
---|
1370 | } |
---|
1371 | #else |
---|
1372 | isAvailable = 1; |
---|
1373 | #endif |
---|
1374 | } |
---|
1375 | } |
---|
1376 | else |
---|
1377 | { |
---|
1378 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1379 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1380 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1381 | if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) |
---|
1382 | { |
---|
1383 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1384 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1385 | { |
---|
1386 | isAvailable = 0; |
---|
1387 | } |
---|
1388 | else |
---|
1389 | { |
---|
1390 | isAvailable = 1; |
---|
1391 | } |
---|
1392 | #else |
---|
1393 | isAvailable = 1; |
---|
1394 | #endif |
---|
1395 | } |
---|
1396 | } |
---|
1397 | } |
---|
1398 | // if there was no such long-term check the short terms |
---|
1399 | if(!isAvailable) |
---|
1400 | { |
---|
1401 | iterPic = rcListPic.begin(); |
---|
1402 | while ( iterPic != rcListPic.end()) |
---|
1403 | { |
---|
1404 | rpcPic = *(iterPic++); |
---|
1405 | |
---|
1406 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1407 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
1408 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
1409 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
1410 | { |
---|
1411 | curPoc = curPoc & (pocCycle - 1); |
---|
1412 | refPoc = refPoc & (pocCycle - 1); |
---|
1413 | } |
---|
1414 | |
---|
1415 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
1416 | { |
---|
1417 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1418 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1419 | { |
---|
1420 | isAvailable = 0; |
---|
1421 | } |
---|
1422 | else |
---|
1423 | { |
---|
1424 | isAvailable = 1; |
---|
1425 | rpcPic->setIsLongTerm(1); |
---|
1426 | break; |
---|
1427 | } |
---|
1428 | #else |
---|
1429 | isAvailable = 1; |
---|
1430 | rpcPic->setIsLongTerm(1); |
---|
1431 | break; |
---|
1432 | #endif |
---|
1433 | } |
---|
1434 | } |
---|
1435 | } |
---|
1436 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1437 | // but not available as reference picture |
---|
1438 | if(isAvailable == 0) |
---|
1439 | { |
---|
1440 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1441 | { |
---|
1442 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1443 | { |
---|
1444 | if(printErrors) |
---|
1445 | { |
---|
1446 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1447 | } |
---|
1448 | atLeastOneRemoved = 1; |
---|
1449 | } |
---|
1450 | else |
---|
1451 | { |
---|
1452 | if(printErrors) |
---|
1453 | { |
---|
1454 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1455 | } |
---|
1456 | atLeastOneLost = 1; |
---|
1457 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1458 | } |
---|
1459 | } |
---|
1460 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1461 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1462 | { |
---|
1463 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1464 | } |
---|
1465 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1466 | { |
---|
1467 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1468 | } |
---|
1469 | #endif |
---|
1470 | } |
---|
1471 | } |
---|
1472 | // loop through all short-term pictures in the Reference Picture Set |
---|
1473 | // to see if the picture should be kept as reference picture |
---|
1474 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
1475 | { |
---|
1476 | isAvailable = 0; |
---|
1477 | // loop through all pictures in the reference picture buffer |
---|
1478 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1479 | while ( iterPic != rcListPic.end()) |
---|
1480 | { |
---|
1481 | rpcPic = *(iterPic++); |
---|
1482 | |
---|
1483 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1484 | { |
---|
1485 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1486 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1487 | { |
---|
1488 | isAvailable = 0; |
---|
1489 | } |
---|
1490 | else |
---|
1491 | { |
---|
1492 | isAvailable = 1; |
---|
1493 | } |
---|
1494 | #else |
---|
1495 | isAvailable = 1; |
---|
1496 | #endif |
---|
1497 | } |
---|
1498 | } |
---|
1499 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1500 | // but not available as reference picture |
---|
1501 | if(isAvailable == 0) |
---|
1502 | { |
---|
1503 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1504 | { |
---|
1505 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1506 | { |
---|
1507 | if(printErrors) |
---|
1508 | { |
---|
1509 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1510 | } |
---|
1511 | atLeastOneRemoved = 1; |
---|
1512 | } |
---|
1513 | else |
---|
1514 | { |
---|
1515 | if(printErrors) |
---|
1516 | { |
---|
1517 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1518 | } |
---|
1519 | atLeastOneLost = 1; |
---|
1520 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1521 | } |
---|
1522 | } |
---|
1523 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1524 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1525 | { |
---|
1526 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1527 | } |
---|
1528 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1529 | { |
---|
1530 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1531 | } |
---|
1532 | #endif |
---|
1533 | } |
---|
1534 | } |
---|
1535 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1536 | if(atLeastOneUnabledByRecoveryPoint || atLeastOneFlushedByPreviousIDR) |
---|
1537 | { |
---|
1538 | return -1; |
---|
1539 | } |
---|
1540 | #endif |
---|
1541 | if(atLeastOneLost) |
---|
1542 | { |
---|
1543 | return iPocLost+1; |
---|
1544 | } |
---|
1545 | if(atLeastOneRemoved) |
---|
1546 | { |
---|
1547 | return -2; |
---|
1548 | } |
---|
1549 | else |
---|
1550 | { |
---|
1551 | return 0; |
---|
1552 | } |
---|
1553 | } |
---|
1554 | |
---|
1555 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
1556 | */ |
---|
1557 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1558 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1559 | #else |
---|
1560 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP) |
---|
1561 | #endif |
---|
1562 | { |
---|
1563 | TComPic* rpcPic; |
---|
1564 | Int i, j; |
---|
1565 | Int k = 0; |
---|
1566 | Int nrOfNegativePictures = 0; |
---|
1567 | Int nrOfPositivePictures = 0; |
---|
1568 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
1569 | |
---|
1570 | // loop through all pictures in the Reference Picture Set |
---|
1571 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1572 | { |
---|
1573 | j = 0; |
---|
1574 | // loop through all pictures in the reference picture buffer |
---|
1575 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1576 | while ( iterPic != rcListPic.end()) |
---|
1577 | { |
---|
1578 | j++; |
---|
1579 | rpcPic = *(iterPic++); |
---|
1580 | |
---|
1581 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1582 | { |
---|
1583 | // This picture exists as a reference picture |
---|
1584 | // and should be added to the explicit Reference Picture Set |
---|
1585 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
1586 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); |
---|
1587 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1588 | pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) ); |
---|
1589 | #endif |
---|
1590 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
1591 | { |
---|
1592 | nrOfNegativePictures++; |
---|
1593 | } |
---|
1594 | else |
---|
1595 | { |
---|
1596 | nrOfPositivePictures++; |
---|
1597 | } |
---|
1598 | k++; |
---|
1599 | } |
---|
1600 | } |
---|
1601 | } |
---|
1602 | #if EFFICIENT_FIELD_IRAP |
---|
1603 | Bool useNewRPS = false; |
---|
1604 | // if current picture is complimentary field associated to IRAP, add the IRAP to its RPS. |
---|
1605 | if(m_pcPic->isField()) |
---|
1606 | { |
---|
1607 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1608 | while ( iterPic != rcListPic.end()) |
---|
1609 | { |
---|
1610 | rpcPic = *(iterPic++); |
---|
1611 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
1612 | { |
---|
1613 | pcRPS->setDeltaPOC(k, 1); |
---|
1614 | pcRPS->setUsed(k, true); |
---|
1615 | nrOfPositivePictures++; |
---|
1616 | k ++; |
---|
1617 | useNewRPS = true; |
---|
1618 | } |
---|
1619 | } |
---|
1620 | } |
---|
1621 | #endif |
---|
1622 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
1623 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
1624 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
1625 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
1626 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
1627 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
1628 | if (!pReferencePictureSet->getInterRPSPrediction() |
---|
1629 | #if EFFICIENT_FIELD_IRAP |
---|
1630 | || useNewRPS |
---|
1631 | #endif |
---|
1632 | ) |
---|
1633 | { |
---|
1634 | pcRPS->setInterRPSPrediction(false); |
---|
1635 | pcRPS->setNumRefIdc(0); |
---|
1636 | } |
---|
1637 | else |
---|
1638 | { |
---|
1639 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
1640 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
1641 | TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
1642 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
1643 | Int iNewIdc=0; |
---|
1644 | for(i=0; i<= iRefPics; i++) |
---|
1645 | { |
---|
1646 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
1647 | Int iRefIdc = 0; |
---|
1648 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
1649 | { |
---|
1650 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
1651 | { |
---|
1652 | if (pcRPS->getUsed(j)) |
---|
1653 | { |
---|
1654 | iRefIdc = 1; |
---|
1655 | } |
---|
1656 | else |
---|
1657 | { |
---|
1658 | iRefIdc = 2; |
---|
1659 | } |
---|
1660 | } |
---|
1661 | } |
---|
1662 | pcRPS->setRefIdc(i, iRefIdc); |
---|
1663 | iNewIdc++; |
---|
1664 | } |
---|
1665 | pcRPS->setInterRPSPrediction(true); |
---|
1666 | pcRPS->setNumRefIdc(iNewIdc); |
---|
1667 | pcRPS->setDeltaRPS(deltaRPS); |
---|
1668 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
1669 | } |
---|
1670 | |
---|
1671 | this->setRPS(pcRPS); |
---|
1672 | this->setRPSidx(-1); |
---|
1673 | } |
---|
1674 | |
---|
1675 | /** get AC and DC values for weighted pred |
---|
1676 | * \param *wp |
---|
1677 | * \returns Void |
---|
1678 | */ |
---|
1679 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
1680 | { |
---|
1681 | wp = m_weightACDCParam; |
---|
1682 | } |
---|
1683 | |
---|
1684 | /** init AC and DC values for weighted pred |
---|
1685 | * \returns Void |
---|
1686 | */ |
---|
1687 | Void TComSlice::initWpAcDcParam() |
---|
1688 | { |
---|
1689 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
1690 | { |
---|
1691 | m_weightACDCParam[iComp].iAC = 0; |
---|
1692 | m_weightACDCParam[iComp].iDC = 0; |
---|
1693 | } |
---|
1694 | } |
---|
1695 | |
---|
1696 | /** get WP tables for weighted pred |
---|
1697 | * \param RefPicList |
---|
1698 | * \param iRefIdx |
---|
1699 | * \param *&wpScalingParam |
---|
1700 | * \returns Void |
---|
1701 | */ |
---|
1702 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
1703 | { |
---|
1704 | wp = m_weightPredTable[e][iRefIdx]; |
---|
1705 | } |
---|
1706 | |
---|
1707 | /** reset Default WP tables settings : no weight. |
---|
1708 | * \param wpScalingParam |
---|
1709 | * \returns Void |
---|
1710 | */ |
---|
1711 | Void TComSlice::resetWpScaling() |
---|
1712 | { |
---|
1713 | for ( Int e=0 ; e<2 ; e++ ) |
---|
1714 | { |
---|
1715 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1716 | { |
---|
1717 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
1718 | { |
---|
1719 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1720 | pwp->bPresentFlag = false; |
---|
1721 | pwp->uiLog2WeightDenom = 0; |
---|
1722 | pwp->uiLog2WeightDenom = 0; |
---|
1723 | pwp->iWeight = 1; |
---|
1724 | pwp->iOffset = 0; |
---|
1725 | } |
---|
1726 | } |
---|
1727 | } |
---|
1728 | } |
---|
1729 | |
---|
1730 | /** init WP table |
---|
1731 | * \returns Void |
---|
1732 | */ |
---|
1733 | Void TComSlice::initWpScaling() |
---|
1734 | { |
---|
1735 | for ( Int e=0 ; e<2 ; e++ ) |
---|
1736 | { |
---|
1737 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1738 | { |
---|
1739 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
1740 | { |
---|
1741 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1742 | if ( !pwp->bPresentFlag ) |
---|
1743 | { |
---|
1744 | // Inferring values not present : |
---|
1745 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
1746 | pwp->iOffset = 0; |
---|
1747 | } |
---|
1748 | |
---|
1749 | pwp->w = pwp->iWeight; |
---|
1750 | Int bitDepth = yuv ? g_bitDepthC : g_bitDepthY; |
---|
1751 | pwp->o = pwp->iOffset << (bitDepth-8); |
---|
1752 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
1753 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
1754 | } |
---|
1755 | } |
---|
1756 | } |
---|
1757 | } |
---|
1758 | |
---|
1759 | // ------------------------------------------------------------------------------------------------ |
---|
1760 | // Video parameter set (VPS) |
---|
1761 | // ------------------------------------------------------------------------------------------------ |
---|
1762 | TComVPS::TComVPS() |
---|
1763 | : m_VPSId ( 0) |
---|
1764 | , m_uiMaxTLayers ( 1) |
---|
1765 | #if H_MV |
---|
1766 | , m_uiMaxLayersMinus1 ( 0) |
---|
1767 | #else |
---|
1768 | , m_uiMaxLayers ( 1) |
---|
1769 | #endif |
---|
1770 | , m_bTemporalIdNestingFlag (false) |
---|
1771 | , m_numHrdParameters ( 0) |
---|
1772 | #if H_MV |
---|
1773 | , m_maxLayerId ( 0) |
---|
1774 | #else |
---|
1775 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
1776 | #endif |
---|
1777 | , m_hrdParameters (NULL) |
---|
1778 | , m_hrdOpSetIdx (NULL) |
---|
1779 | , m_cprmsPresentFlag (NULL) |
---|
1780 | #if H_MV |
---|
1781 | , m_dpbSize (NULL) |
---|
1782 | , m_vpsVUI ( NULL ) |
---|
1783 | #endif |
---|
1784 | { |
---|
1785 | #if H_MV |
---|
1786 | m_vpsBaseLayerInternalFlag = true; |
---|
1787 | #if H_MV_HLS10_GEN_VSP_BASE_LAYER_AVAIL |
---|
1788 | m_vpsBaseLayerAvailableFlag = true; |
---|
1789 | #endif |
---|
1790 | #endif |
---|
1791 | |
---|
1792 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
1793 | { |
---|
1794 | m_numReorderPics[i] = 0; |
---|
1795 | m_uiMaxDecPicBuffering[i] = 1; |
---|
1796 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1797 | } |
---|
1798 | #if H_MV |
---|
1799 | for (Int lsIdx = 0; lsIdx < MAX_VPS_OP_SETS_PLUS1; lsIdx++ ) |
---|
1800 | { |
---|
1801 | for( Int layerId = 0; layerId < MAX_VPS_NUH_LAYER_ID_PLUS1; layerId++ ) |
---|
1802 | { |
---|
1803 | m_layerIdIncludedFlag[lsIdx][layerId] = (( lsIdx == 0 ) && ( layerId == 0 )) ; |
---|
1804 | } |
---|
1805 | } |
---|
1806 | m_vpsNumProfileTierLevelMinus1 = -1; |
---|
1807 | |
---|
1808 | m_numAddLayerSets = 0; |
---|
1809 | m_numAddOlss = 0; |
---|
1810 | m_defaultOutputLayerIdc = 0; |
---|
1811 | |
---|
1812 | for ( Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++) |
---|
1813 | { |
---|
1814 | m_layerSetIdxForOlsMinus1[i] = -1; |
---|
1815 | #if !H_MV_HLS10_PTL |
---|
1816 | m_profileLevelTierIdx[i] = 0; |
---|
1817 | #endif |
---|
1818 | for ( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++) |
---|
1819 | { |
---|
1820 | #if H_MV_HLS10_PTL |
---|
1821 | #if H_MV_HLS10_PTL_FIX |
---|
1822 | m_profileTierLevelIdx[i][j] = -1; |
---|
1823 | #else |
---|
1824 | m_profileTierLevelIdx[i][j] = false; |
---|
1825 | #endif |
---|
1826 | #endif |
---|
1827 | m_outputLayerFlag[i][j] = false; |
---|
1828 | } |
---|
1829 | m_altOutputLayerFlag[ i ] = false; |
---|
1830 | } |
---|
1831 | |
---|
1832 | m_repFormatIdxPresentFlag = false; |
---|
1833 | m_maxOneActiveRefLayerFlag = false; |
---|
1834 | m_directDepTypeLenMinus2 = 0; |
---|
1835 | |
---|
1836 | |
---|
1837 | m_vpsExtensionFlag = true; |
---|
1838 | m_vpsNonVuiExtensionLength = 0; |
---|
1839 | m_splittingFlag = false; |
---|
1840 | |
---|
1841 | for( Int i = 0; i < MAX_NUM_SCALABILITY_TYPES; i++ ) |
---|
1842 | { |
---|
1843 | m_scalabilityMaskFlag[i] = false; |
---|
1844 | m_dimensionIdLen [i] = -1; |
---|
1845 | } |
---|
1846 | |
---|
1847 | m_vpsNuhLayerIdPresentFlag = false; |
---|
1848 | |
---|
1849 | for( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++ ) |
---|
1850 | { |
---|
1851 | m_vpsProfilePresentFlag [i] = false; |
---|
1852 | m_layerSetIdxForOlsMinus1 [i] = 0; |
---|
1853 | for( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++ ) |
---|
1854 | { |
---|
1855 | m_outputLayerFlag[i][j] = false; |
---|
1856 | } |
---|
1857 | } |
---|
1858 | |
---|
1859 | for( Int i = 0; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
1860 | { |
---|
1861 | m_layerIdInVps[i] = (i == 0 ) ? 0 : -1; |
---|
1862 | } |
---|
1863 | |
---|
1864 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
1865 | { |
---|
1866 | m_layerIdInNuh [i] = ( i == 0 ) ? 0 : -1; |
---|
1867 | m_numDirectRefLayers[i] = 0; |
---|
1868 | m_vpsRepFormatIdx [i] = 0; |
---|
1869 | m_pocLsbNotPresentFlag[i] = 0; |
---|
1870 | m_repFormat [i] = NULL; |
---|
1871 | m_viewIdVal [i] = 0; |
---|
1872 | |
---|
1873 | |
---|
1874 | for( Int j = 0; j < MAX_NUM_LAYERS; j++ ) |
---|
1875 | { |
---|
1876 | m_directDependencyFlag[i][j] = false; |
---|
1877 | m_directDependencyType[i][j] = -1; |
---|
1878 | #if H_MV_HLS10_REF_PRED_LAYERS |
---|
1879 | m_dependencyFlag [i][j] = false; |
---|
1880 | m_idDirectRefLayer[i][j] = -1; |
---|
1881 | m_idPredictedLayer[i][j] = -1; |
---|
1882 | m_idRefLayer [i][j] = -1; |
---|
1883 | #else |
---|
1884 | m_refLayerId[i][j] = -1; |
---|
1885 | #endif |
---|
1886 | m_maxTidIlRefPicsPlus1[i][j] = 7; |
---|
1887 | } |
---|
1888 | |
---|
1889 | for( Int j = 0; j < MAX_NUM_SCALABILITY_TYPES; j++ ) |
---|
1890 | { |
---|
1891 | m_dimensionId[i][j] = 0; |
---|
1892 | } |
---|
1893 | } |
---|
1894 | m_vpsVUI = new TComVPSVUI; |
---|
1895 | m_dpbSize = new TComDpbSize; |
---|
1896 | |
---|
1897 | #endif |
---|
1898 | } |
---|
1899 | |
---|
1900 | TComVPS::~TComVPS() |
---|
1901 | { |
---|
1902 | if( m_hrdParameters != NULL ) delete[] m_hrdParameters; |
---|
1903 | if( m_hrdOpSetIdx != NULL ) delete[] m_hrdOpSetIdx; |
---|
1904 | if( m_cprmsPresentFlag != NULL ) delete[] m_cprmsPresentFlag; |
---|
1905 | #if H_MV |
---|
1906 | if ( m_vpsVUI != NULL ) delete m_vpsVUI; |
---|
1907 | if ( m_dpbSize != NULL ) delete m_dpbSize; |
---|
1908 | |
---|
1909 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
1910 | { |
---|
1911 | if (m_repFormat[ i ] != NULL ) delete m_repFormat[ i ]; |
---|
1912 | } |
---|
1913 | #endif |
---|
1914 | } |
---|
1915 | |
---|
1916 | #if H_MV |
---|
1917 | |
---|
1918 | Bool TComVPS::checkVPSExtensionSyntax() |
---|
1919 | { |
---|
1920 | for( Int layer = 1; layer <= getMaxLayersMinus1(); layer++ ) |
---|
1921 | { |
---|
1922 | // check layer_id_in_nuh constraint |
---|
1923 | assert( getLayerIdInNuh( layer ) > getLayerIdInNuh( layer -1 ) ); |
---|
1924 | } |
---|
1925 | |
---|
1926 | //The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
1927 | assert( getVpsNumRepFormatsMinus1() >= 0 ); |
---|
1928 | assert( getVpsNumRepFormatsMinus1() <= 255 ); |
---|
1929 | |
---|
1930 | #if H_MV_HLS10_ADD_LAYERSETS |
---|
1931 | // The value of num_add_layer_sets shall be in the range of 0 to 1023, inclusive. |
---|
1932 | assert( getNumAddLayerSets() >= 0 && getNumAddLayerSets() <= 1023 ); |
---|
1933 | #endif |
---|
1934 | return true; |
---|
1935 | } |
---|
1936 | |
---|
1937 | Int TComVPS::getNumScalabilityTypes() |
---|
1938 | { |
---|
1939 | return scalTypeToScalIdx( ScalabilityType(MAX_NUM_SCALABILITY_TYPES) ); |
---|
1940 | } |
---|
1941 | |
---|
1942 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) |
---|
1943 | { |
---|
1944 | assert( scalType >= 0 && scalType <= MAX_NUM_SCALABILITY_TYPES ); |
---|
1945 | assert( scalType == MAX_NUM_SCALABILITY_TYPES || getScalabilityMaskFlag( scalType ) ); |
---|
1946 | Int scalIdx = 0; |
---|
1947 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
1948 | { |
---|
1949 | scalIdx += ( getScalabilityMaskFlag( curScalType ) ? 1 : 0 ); |
---|
1950 | |
---|
1951 | } |
---|
1952 | |
---|
1953 | return scalIdx; |
---|
1954 | } |
---|
1955 | Void TComVPS::setScalabilityMaskFlag( UInt val ) |
---|
1956 | { |
---|
1957 | for ( Int scalType = 0; scalType < MAX_NUM_SCALABILITY_TYPES; scalType++ ) |
---|
1958 | { |
---|
1959 | setScalabilityMaskFlag( scalType, ( val & (1 << scalType ) ) != 0 ); |
---|
1960 | } |
---|
1961 | } |
---|
1962 | |
---|
1963 | Void TComVPS::setRefLayers() |
---|
1964 | { |
---|
1965 | |
---|
1966 | #if H_MV_HLS10_REF_PRED_LAYERS |
---|
1967 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
1968 | { |
---|
1969 | for( Int j = 0; j <= getMaxLayersMinus1(); j++ ) |
---|
1970 | { |
---|
1971 | m_dependencyFlag[ i ][ j ] = getDirectDependencyFlag( i , j ); |
---|
1972 | for( Int k = 0; k < i; k++ ) |
---|
1973 | { |
---|
1974 | if( getDirectDependencyFlag(i , k ) && m_dependencyFlag[k][j] ) |
---|
1975 | { |
---|
1976 | m_dependencyFlag[ i ][ j ] = true; |
---|
1977 | } |
---|
1978 | } |
---|
1979 | } |
---|
1980 | } |
---|
1981 | |
---|
1982 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
1983 | { |
---|
1984 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
1985 | Int d = 0; |
---|
1986 | Int r = 0; |
---|
1987 | Int p = 0; |
---|
1988 | for( Int j = 0; j <= getMaxLayersMinus1(); j++ ) |
---|
1989 | { |
---|
1990 | Int jNuhLid = getLayerIdInNuh( j ); |
---|
1991 | if( getDirectDependencyFlag( i , j ) ) |
---|
1992 | { |
---|
1993 | m_idDirectRefLayer[iNuhLId][d++] = jNuhLid; |
---|
1994 | } |
---|
1995 | if( getDependencyFlag( i , j ) ) |
---|
1996 | { |
---|
1997 | m_idRefLayer [iNuhLId][r++] = jNuhLid; |
---|
1998 | } |
---|
1999 | if( getDependencyFlag( j , i ) ) |
---|
2000 | { |
---|
2001 | m_idPredictedLayer[iNuhLId][p++] = jNuhLid; |
---|
2002 | } |
---|
2003 | } |
---|
2004 | m_numDirectRefLayers[ iNuhLId ] = d; |
---|
2005 | m_numRefLayers [ iNuhLId ] = r; |
---|
2006 | m_numPredictedLayers[ iNuhLId ] = p; |
---|
2007 | } |
---|
2008 | |
---|
2009 | Bool layerIdInListFlag[ 64 ]; |
---|
2010 | for( Int i = 0; i <= 63; i++ ) |
---|
2011 | { |
---|
2012 | layerIdInListFlag[ i ] = 0; |
---|
2013 | } |
---|
2014 | |
---|
2015 | Int k = 0; |
---|
2016 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2017 | { |
---|
2018 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2019 | if( getNumDirectRefLayers( iNuhLId ) == 0 ) |
---|
2020 | { |
---|
2021 | m_treePartitionLayerIdList[ k ][ 0 ] = iNuhLId; |
---|
2022 | Int h = 1; |
---|
2023 | for( Int j = 0; j < getNumPredictedLayers( iNuhLId ); j++ ) |
---|
2024 | { |
---|
2025 | Int predLId = getIdPredictedLayer( iNuhLId, j ); |
---|
2026 | if ( !layerIdInListFlag[ predLId ] ) |
---|
2027 | { |
---|
2028 | m_treePartitionLayerIdList[ k ][ h++ ] = predLId; |
---|
2029 | layerIdInListFlag[ predLId ] = 1; |
---|
2030 | } |
---|
2031 | } |
---|
2032 | m_numLayersInTreePartition[ k++ ] = h; |
---|
2033 | } |
---|
2034 | } |
---|
2035 | m_numIndependentLayers = k; |
---|
2036 | #else // H_MV_HLS10_GEN |
---|
2037 | |
---|
2038 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2039 | { |
---|
2040 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2041 | m_numDirectRefLayers[ iNuhLId ] = 0; |
---|
2042 | for( Int j = 0; j < i; j++ ) |
---|
2043 | { |
---|
2044 | if( getDirectDependencyFlag(i , j) ) |
---|
2045 | { |
---|
2046 | m_refLayerId[ iNuhLId ][m_numDirectRefLayers[ iNuhLId ]++ ] = getLayerIdInNuh( j ); |
---|
2047 | } |
---|
2048 | } |
---|
2049 | } |
---|
2050 | |
---|
2051 | for (Int i = 0 ; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
2052 | { |
---|
2053 | m_numRefLayers[i] = 0; |
---|
2054 | } |
---|
2055 | |
---|
2056 | for (Int currLayerId = 0; currLayerId <= 62; currLayerId++ ) |
---|
2057 | { |
---|
2058 | for (Int i = 0 ; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
2059 | { |
---|
2060 | m_recursiveRefLayerFlag[currLayerId][i] = 0; |
---|
2061 | } |
---|
2062 | } |
---|
2063 | |
---|
2064 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2065 | { |
---|
2066 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2067 | xSetRefLayerFlags( iNuhLId ); |
---|
2068 | for( Int j = 0; j < 63; j++ ) |
---|
2069 | { |
---|
2070 | m_numRefLayers[ iNuhLId ] += m_recursiveRefLayerFlag[ iNuhLId ][ j ]; |
---|
2071 | } |
---|
2072 | } |
---|
2073 | |
---|
2074 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) // Bug in spec "<" instead of "<=" |
---|
2075 | { |
---|
2076 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2077 | Int predIdx = 0; |
---|
2078 | for( Int j = iNuhLId + 1; j < 63; j++ ) |
---|
2079 | { |
---|
2080 | if( m_recursiveRefLayerFlag[ j ][ iNuhLId ] ) |
---|
2081 | { |
---|
2082 | m_predictedLayerId[ iNuhLId ][ predIdx++ ] = j; |
---|
2083 | } |
---|
2084 | } |
---|
2085 | m_numPredictedLayers[ iNuhLId ] = predIdx; |
---|
2086 | } |
---|
2087 | |
---|
2088 | Bool countedLayerIdxFlag[ MAX_NUM_LAYERS ]; |
---|
2089 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2090 | { |
---|
2091 | countedLayerIdxFlag[ i ] = 0; |
---|
2092 | } |
---|
2093 | for( Int i = 0, k = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2094 | { |
---|
2095 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2096 | if( m_numDirectRefLayers[ iNuhLId ] == 0 ) |
---|
2097 | { |
---|
2098 | m_treePartitionLayerIdList[ k ][ 0 ] = iNuhLId; |
---|
2099 | m_numLayersInTreePartition[ k ] = 1; |
---|
2100 | |
---|
2101 | for( Int j = 0; j < m_numPredictedLayers[ iNuhLId ]; j++ ) |
---|
2102 | { |
---|
2103 | if( !countedLayerIdxFlag[ getLayerIdInVps( m_predictedLayerId[ iNuhLId ][ j ] ) ] ) |
---|
2104 | { |
---|
2105 | m_treePartitionLayerIdList[ k ][ m_numLayersInTreePartition[ k ] ] = m_predictedLayerId[ iNuhLId ][ j ]; |
---|
2106 | m_numLayersInTreePartition[ k ]++; |
---|
2107 | countedLayerIdxFlag[ getLayerIdInVps( m_predictedLayerId[ iNuhLId ][ j ] ) ] = 1; |
---|
2108 | } |
---|
2109 | } |
---|
2110 | k++; |
---|
2111 | |
---|
2112 | m_numIndependentLayers = k; |
---|
2113 | } |
---|
2114 | } |
---|
2115 | #endif // H_MV_HLS10_GEN |
---|
2116 | } |
---|
2117 | |
---|
2118 | #if !H_MV_HLS10_REF_PRED_LAYERS |
---|
2119 | Int TComVPS::getRefLayerId( Int layerIdInNuh, Int idx ) |
---|
2120 | { |
---|
2121 | assert( idx >= 0 && idx < m_numDirectRefLayers[layerIdInNuh] ); |
---|
2122 | Int refLayerIdInNuh = m_refLayerId[ layerIdInNuh ][ idx ]; |
---|
2123 | assert ( refLayerIdInNuh >= 0 ); |
---|
2124 | return refLayerIdInNuh; |
---|
2125 | } |
---|
2126 | #endif |
---|
2127 | |
---|
2128 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) |
---|
2129 | { |
---|
2130 | return getScalabilityMaskFlag( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
2131 | } |
---|
2132 | |
---|
2133 | |
---|
2134 | |
---|
2135 | Int TComVPS::xGetDimBitOffset( Int j ) |
---|
2136 | { |
---|
2137 | Int dimBitOffset = 0; |
---|
2138 | if ( getSplittingFlag() && j == getNumScalabilityTypes() ) |
---|
2139 | { |
---|
2140 | dimBitOffset = 6; |
---|
2141 | } |
---|
2142 | else |
---|
2143 | { |
---|
2144 | for (Int dimIdx = 0; dimIdx <= j-1; dimIdx++) |
---|
2145 | { |
---|
2146 | dimBitOffset += getDimensionIdLen( dimIdx ); |
---|
2147 | } |
---|
2148 | } |
---|
2149 | return dimBitOffset; |
---|
2150 | } |
---|
2151 | |
---|
2152 | Int TComVPS::inferDimensionId( Int i, Int j ) |
---|
2153 | { |
---|
2154 | return ( ( getLayerIdInNuh( i ) & ( (1 << xGetDimBitOffset( j + 1 ) ) - 1) ) >> xGetDimBitOffset( j ) ); |
---|
2155 | } |
---|
2156 | |
---|
2157 | Int TComVPS::inferLastDimsionIdLenMinus1() |
---|
2158 | { |
---|
2159 | return ( 5 - xGetDimBitOffset( getNumScalabilityTypes() - 1 ) ); |
---|
2160 | } |
---|
2161 | |
---|
2162 | Int TComVPS::getNumLayersInIdList( Int lsIdx ) |
---|
2163 | { |
---|
2164 | assert( lsIdx >= 0 ); |
---|
2165 | #if H_MV_HLS10_ADD_LAYERSETS |
---|
2166 | assert( lsIdx <= getNumLayerSets() ); |
---|
2167 | #else |
---|
2168 | assert( lsIdx <= getVpsNumLayerSetsMinus1() ); |
---|
2169 | #endif |
---|
2170 | return (Int) m_layerSetLayerIdList[ lsIdx ].size(); |
---|
2171 | } |
---|
2172 | |
---|
2173 | Int TComVPS::getNumOutputLayerSets() |
---|
2174 | { |
---|
2175 | return getNumAddOlss() + getNumLayerSets(); |
---|
2176 | } |
---|
2177 | |
---|
2178 | Int TComVPS::getNumViews() |
---|
2179 | { |
---|
2180 | Int numViews = 1; |
---|
2181 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2182 | { |
---|
2183 | Int lId = getLayerIdInNuh( i ); |
---|
2184 | if ( i > 0 && ( getViewIndex( lId ) != getScalabilityId( i - 1, VIEW_ORDER_INDEX ) ) ) |
---|
2185 | { |
---|
2186 | numViews++; |
---|
2187 | } |
---|
2188 | } |
---|
2189 | |
---|
2190 | return numViews; |
---|
2191 | } |
---|
2192 | |
---|
2193 | #if !H_MV_HLS10_REF_PRED_LAYERS |
---|
2194 | Bool TComVPS::getInDirectDependencyFlag( Int depLayeridInVps, Int refLayeridInVps, Int depth /*= 0 */ ) |
---|
2195 | { |
---|
2196 | #if H_MV_HLS10_REF_PRED_LAYERS |
---|
2197 | // TBD: Remove getInDirectDependencyFlag entirely. |
---|
2198 | return getDependencyFlag( depLayeridInVps, refLayeridInVps ); |
---|
2199 | #else |
---|
2200 | assert( depth < 65 ); |
---|
2201 | Bool dependentFlag = getDirectDependencyFlag( depLayeridInVps, refLayeridInVps ); |
---|
2202 | |
---|
2203 | for( Int i = 0; i < depLayeridInVps && !dependentFlag; i++ ) |
---|
2204 | { |
---|
2205 | if ( getDirectDependencyFlag( depLayeridInVps, i ) ) |
---|
2206 | { |
---|
2207 | dependentFlag = getInDirectDependencyFlag( i, refLayeridInVps, depth++ ); |
---|
2208 | } |
---|
2209 | } |
---|
2210 | return dependentFlag; |
---|
2211 | #endif |
---|
2212 | } |
---|
2213 | #endif |
---|
2214 | |
---|
2215 | Void TComVPS::deriveLayerSetLayerIdList() |
---|
2216 | { |
---|
2217 | m_layerSetLayerIdList.resize( getVpsNumLayerSetsMinus1() + 1 ); |
---|
2218 | for (Int i = 0; i <= getVpsNumLayerSetsMinus1(); i++ ) |
---|
2219 | { |
---|
2220 | for( Int m = 0; m <= getVpsMaxLayerId(); m++ ) |
---|
2221 | { |
---|
2222 | if( getLayerIdIncludedFlag( i, m) ) |
---|
2223 | { |
---|
2224 | m_layerSetLayerIdList[ i ].push_back( m ); |
---|
2225 | } |
---|
2226 | } |
---|
2227 | } |
---|
2228 | } |
---|
2229 | |
---|
2230 | Void TComVPS::initTargetLayerIdLists() |
---|
2231 | { |
---|
2232 | m_targetDecLayerIdLists.resize( getNumOutputLayerSets() ); |
---|
2233 | m_targetOptLayerIdLists.resize( getNumOutputLayerSets() ); |
---|
2234 | } |
---|
2235 | |
---|
2236 | Void TComVPS::deriveTargetLayerIdList( Int i ) |
---|
2237 | { |
---|
2238 | Int lsIdx = olsIdxToLsIdx( i ); |
---|
2239 | |
---|
2240 | for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ ) |
---|
2241 | { |
---|
2242 | #if H_MV_HLS10_NESSECARY_LAYER |
---|
2243 | if ( getNecessaryLayerFlag( i , j )) |
---|
2244 | { |
---|
2245 | #endif |
---|
2246 | m_targetDecLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); |
---|
2247 | #if H_MV_HLS10_NESSECARY_LAYER |
---|
2248 | } |
---|
2249 | #endif |
---|
2250 | |
---|
2251 | if( getOutputLayerFlag( i, j )) |
---|
2252 | { |
---|
2253 | m_targetOptLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); |
---|
2254 | } |
---|
2255 | } |
---|
2256 | assert( getNumOutputLayersInOutputLayerSet( i ) > 0 ); |
---|
2257 | } |
---|
2258 | |
---|
2259 | Bool TComVPS::inferOutputLayerFlag( Int i, Int j ) |
---|
2260 | { |
---|
2261 | Bool outputLayerFlag; |
---|
2262 | switch ( getDefaultOutputLayerIdc( ) ) |
---|
2263 | { |
---|
2264 | case 0: |
---|
2265 | outputLayerFlag = true; |
---|
2266 | break; |
---|
2267 | case 1: |
---|
2268 | outputLayerFlag = ( j == m_layerSetLayerIdList[ olsIdxToLsIdx( i ) ].size() - 1 ); |
---|
2269 | break; |
---|
2270 | case 2: |
---|
2271 | if ( i == 0 && j == 0) |
---|
2272 | { |
---|
2273 | outputLayerFlag = true; // This is a software only fix for a bug in the spec. In spec outputLayerFlag is neither present nor inferred. |
---|
2274 | } |
---|
2275 | else |
---|
2276 | { |
---|
2277 | assert( 0 ); |
---|
2278 | } |
---|
2279 | break; |
---|
2280 | default: |
---|
2281 | assert( 0 ); |
---|
2282 | break; |
---|
2283 | } |
---|
2284 | return outputLayerFlag; |
---|
2285 | } |
---|
2286 | |
---|
2287 | Int TComVPS::getMaxSubLayersInLayerSetMinus1( Int i ) |
---|
2288 | { |
---|
2289 | Int maxSLMinus1 = 0; |
---|
2290 | for( Int k = 0; k < getNumLayersInIdList( i ); k++ ) |
---|
2291 | { |
---|
2292 | Int lId = m_layerSetLayerIdList[i][k]; |
---|
2293 | maxSLMinus1 = std::max( maxSLMinus1, getSubLayersVpsMaxMinus1( getLayerIdInVps( lId ) )); |
---|
2294 | } |
---|
2295 | return maxSLMinus1; |
---|
2296 | } |
---|
2297 | |
---|
2298 | #if !H_MV_HLS10_ADD_LAYERSETS |
---|
2299 | Void TComVPS::inferDbpSizeLayerSetZero( TComSPS* sps, Bool encoder ) |
---|
2300 | { |
---|
2301 | for( Int j = 0; j <= getMaxSubLayersInLayerSetMinus1( 0 ); j++ ) |
---|
2302 | { |
---|
2303 | Int maxDecPicBufferingMinus1 = sps->getMaxDecPicBuffering( j ) - 1; |
---|
2304 | Int numReorderPics = sps->getNumReorderPics ( j ); |
---|
2305 | Int maxLatencyIncreasePlus1 = sps->getMaxLatencyIncrease( j ); |
---|
2306 | |
---|
2307 | if ( encoder ) |
---|
2308 | { |
---|
2309 | assert( getDpbSize()->getMaxVpsDecPicBufferingMinus1(0, 0, j ) == maxDecPicBufferingMinus1 ); |
---|
2310 | assert( getDpbSize()->getMaxVpsNumReorderPics (0, j ) == numReorderPics ); |
---|
2311 | assert( getDpbSize()->getMaxVpsLatencyIncreasePlus1 (0, j ) == maxLatencyIncreasePlus1 ); |
---|
2312 | } |
---|
2313 | else |
---|
2314 | { |
---|
2315 | getDpbSize()->setMaxVpsDecPicBufferingMinus1(0, 0, j, maxDecPicBufferingMinus1 ); |
---|
2316 | getDpbSize()->setMaxVpsNumReorderPics (0, j, numReorderPics ); |
---|
2317 | getDpbSize()->setMaxVpsLatencyIncreasePlus1 (0, j, maxLatencyIncreasePlus1 ); |
---|
2318 | } |
---|
2319 | } |
---|
2320 | } |
---|
2321 | #endif |
---|
2322 | Bool TComVPS::getAltOutputLayerFlagVar( Int i ) |
---|
2323 | { |
---|
2324 | // Semantics variable not syntax element ! |
---|
2325 | |
---|
2326 | Bool altOptLayerFlag = false; |
---|
2327 | if ( i > 0 && getNumOutputLayersInOutputLayerSet( i ) == 1 && |
---|
2328 | getNumDirectRefLayers( getOlsHighestOutputLayerId( i ) ) > 0 ) |
---|
2329 | { |
---|
2330 | altOptLayerFlag = getAltOutputLayerFlag( i ); |
---|
2331 | } |
---|
2332 | return altOptLayerFlag; |
---|
2333 | } |
---|
2334 | |
---|
2335 | #if !H_MV_HLS10_MAXNUMPICS |
---|
2336 | Int TComVPS::getMaxNumPics( Int layerId ) |
---|
2337 | { |
---|
2338 | Int maxNumPics = MAX_INT; |
---|
2339 | for( Int olsIdx = 0; olsIdx < getNumOutputLayerSets(); olsIdx++) |
---|
2340 | { |
---|
2341 | Int lsIdx = olsIdxToLsIdx( olsIdx ); |
---|
2342 | for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ ) |
---|
2343 | { |
---|
2344 | if( getLayerSetLayerIdList(lsIdx, j ) == layerId ) |
---|
2345 | { |
---|
2346 | Int maxSL = getMaxSubLayersInLayerSetMinus1( lsIdx ); |
---|
2347 | maxNumPics = std::min( maxNumPics, getDpbSize()->getMaxVpsDecPicBufferingMinus1( olsIdx , j, maxSL ) ); |
---|
2348 | } |
---|
2349 | } |
---|
2350 | } |
---|
2351 | assert( maxNumPics != MAX_INT ); |
---|
2352 | return maxNumPics; |
---|
2353 | } |
---|
2354 | #endif |
---|
2355 | |
---|
2356 | #if !H_MV_HLS10_REF_PRED_LAYERS |
---|
2357 | Void TComVPS::xSetRefLayerFlags( Int currLayerId ) |
---|
2358 | { |
---|
2359 | for( Int j = 0; j < getNumDirectRefLayers( currLayerId ); j++ ) |
---|
2360 | { |
---|
2361 | Int refLayerId = m_refLayerId[ currLayerId ][ j ]; |
---|
2362 | m_recursiveRefLayerFlag[ currLayerId ][ refLayerId ] = 1; |
---|
2363 | for( Int k = 0; k < MAX_NUM_LAYER_IDS; k++ ) |
---|
2364 | { |
---|
2365 | m_recursiveRefLayerFlag[ currLayerId ][ k ] = m_recursiveRefLayerFlag[ currLayerId ][ k ] || m_recursiveRefLayerFlag[ refLayerId ][ k ]; |
---|
2366 | } |
---|
2367 | } |
---|
2368 | } |
---|
2369 | |
---|
2370 | #endif |
---|
2371 | |
---|
2372 | #if H_MV_HLS10_PTL_FIX |
---|
2373 | Int TComVPS::inferProfileTierLevelIdx(Int i, Int j) |
---|
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 | #endif |
---|
2393 | |
---|
2394 | #if H_MV_HLS10_ADD_LAYERSETS |
---|
2395 | Void TComVPS::deriveAddLayerSetLayerIdList(Int i) |
---|
2396 | { |
---|
2397 | assert( m_layerSetLayerIdList.size() == ( getVpsNumLayerSetsMinus1() + 1 + i ) ); |
---|
2398 | std::vector<Int> layerSetLayerIdList; |
---|
2399 | |
---|
2400 | for( Int treeIdx = 1; treeIdx < getNumIndependentLayers(); treeIdx++ ) |
---|
2401 | { |
---|
2402 | // The value of highest_layer_idx_plus1[ i ][ j ] shall be in the range of 0 to NumLayersInTreePartition[ j ], inclusive. |
---|
2403 | assert( getHighestLayerIdxPlus1( i, treeIdx ) >= 0 && getHighestLayerIdxPlus1( i, treeIdx ) <= getNumLayersInTreePartition( treeIdx ) ); |
---|
2404 | |
---|
2405 | for( Int layerCnt = 0; layerCnt < getHighestLayerIdxPlus1( i, treeIdx ); layerCnt++ ) |
---|
2406 | { |
---|
2407 | layerSetLayerIdList.push_back( getTreePartitionLayerIdList( treeIdx, layerCnt ) ); |
---|
2408 | } |
---|
2409 | } |
---|
2410 | m_layerSetLayerIdList.push_back( layerSetLayerIdList ); |
---|
2411 | |
---|
2412 | //It is a requirement of bitstream conformance that |
---|
2413 | //NumLayersInIdList[ vps_num_layer_sets_minus1 + 1 + i ] shall be greater than 0. |
---|
2414 | assert( getNumLayersInIdList( getVpsNumLayerSetsMinus1() + 1 + i ) > 0 ); |
---|
2415 | } |
---|
2416 | |
---|
2417 | #endif |
---|
2418 | |
---|
2419 | #if H_MV_HLS10_NESSECARY_LAYER |
---|
2420 | Void TComVPS::deriveNecessaryLayerFlags(Int olsIdx) |
---|
2421 | { |
---|
2422 | AOF( olsIdx >= 0 && olsIdx < getNumOutputLayerSets() ); |
---|
2423 | Int lsIdx = olsIdxToLsIdx( olsIdx ); |
---|
2424 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx) ; lsLayerIdx++ ) |
---|
2425 | { |
---|
2426 | m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ] = 0; |
---|
2427 | } |
---|
2428 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx ); lsLayerIdx++ ) |
---|
2429 | { |
---|
2430 | if( getOutputLayerFlag( olsIdx, lsLayerIdx )) |
---|
2431 | { |
---|
2432 | m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ] = 1; |
---|
2433 | Int currLayerId = getLayerSetLayerIdList( lsIdx, lsLayerIdx ); |
---|
2434 | for( Int rLsLayerIdx = 0; rLsLayerIdx < lsLayerIdx; rLsLayerIdx++ ) |
---|
2435 | { |
---|
2436 | Int refLayerId = getLayerSetLayerIdList( lsIdx, rLsLayerIdx ); |
---|
2437 | if( getDependencyFlag( getLayerIdInVps( currLayerId ), getLayerIdInVps( refLayerId ) ) ) |
---|
2438 | { |
---|
2439 | m_necessaryLayerFlag[ olsIdx ][ rLsLayerIdx ] = 1; |
---|
2440 | } |
---|
2441 | } |
---|
2442 | } |
---|
2443 | } |
---|
2444 | m_numNecessaryLayers[ olsIdx ] = 0; |
---|
2445 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx ); lsLayerIdx++ ) |
---|
2446 | { |
---|
2447 | m_numNecessaryLayers[ olsIdx ] += m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ]; |
---|
2448 | } |
---|
2449 | } |
---|
2450 | #endif |
---|
2451 | |
---|
2452 | #if H_MV_HLS10_ADD_LAYERSETS |
---|
2453 | Void TComVPS::printPTL() |
---|
2454 | { |
---|
2455 | std::vector<Int> idx; |
---|
2456 | std::vector<Int> num; |
---|
2457 | std::vector< std::vector<Int> > ptlInfo; |
---|
2458 | |
---|
2459 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "PTLI" << std::endl; |
---|
2460 | |
---|
2461 | for ( Int i = 0; i <= getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
2462 | { |
---|
2463 | std::vector<Int> curPtlInfo; |
---|
2464 | ProfileTierLevel* ptl = getPTL( i )->getGeneralPTL(); |
---|
2465 | curPtlInfo.push_back( (Int) ptl->getProfileIdc() ); |
---|
2466 | curPtlInfo.push_back( (Int) ptl->getTierFlag() ); |
---|
2467 | curPtlInfo.push_back( (Int) ptl->getLevelIdc() ); |
---|
2468 | curPtlInfo.push_back( (Int) ptl->getInbldFlag() ); |
---|
2469 | |
---|
2470 | idx.push_back ( i ); |
---|
2471 | num.push_back ( 4 ); |
---|
2472 | ptlInfo.push_back( curPtlInfo ); |
---|
2473 | } |
---|
2474 | |
---|
2475 | xPrintArray( "VpsProfileTierLevel", getVpsNumProfileTierLevelMinus1() + 1, idx, num, ptlInfo, false ); |
---|
2476 | |
---|
2477 | num.clear(); |
---|
2478 | idx.clear(); |
---|
2479 | for (Int i = 0; i < getNumOutputLayerSets(); i++) |
---|
2480 | { |
---|
2481 | num.push_back ( getNumLayersInIdList( olsIdxToLsIdx( i )) ); |
---|
2482 | idx.push_back( i ); |
---|
2483 | } |
---|
2484 | |
---|
2485 | xPrintArray( "profile_tier_level_idx", getNumOutputLayerSets(), idx, num, m_profileTierLevelIdx, true ); |
---|
2486 | std::cout << std::endl; |
---|
2487 | } |
---|
2488 | |
---|
2489 | Void TComVPS::printLayerDependencies() |
---|
2490 | { |
---|
2491 | vector<Int> fullArray; |
---|
2492 | vector<Int> range; |
---|
2493 | |
---|
2494 | |
---|
2495 | #if H_MV_HLS10_AUX |
---|
2496 | vector<Int> viewOrderIndex; |
---|
2497 | vector<Int> auxId; |
---|
2498 | vector<Int> dependencyId; |
---|
2499 | vector<Int> viewId; |
---|
2500 | #endif |
---|
2501 | for (Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2502 | { |
---|
2503 | fullArray.push_back( getMaxLayersMinus1() + 1 ); |
---|
2504 | range.push_back( i ); |
---|
2505 | #if H_MV_HLS10_AUX |
---|
2506 | viewOrderIndex.push_back( getViewIndex ( i ) ); |
---|
2507 | dependencyId .push_back( getDependencyId( i ) ); |
---|
2508 | auxId .push_back( getAuxId ( i ) ); |
---|
2509 | viewId .push_back( getViewId ( getLayerIdInNuh( i ) ) ); |
---|
2510 | #endif |
---|
2511 | } |
---|
2512 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Layer Dependencies" << std::endl; |
---|
2513 | xPrintArray( "direct_dependency_flag", getMaxLayersMinus1()+1, range, fullArray, m_directDependencyFlag, false ); |
---|
2514 | xPrintArray( "DependencyFlag", getMaxLayersMinus1()+1, range, fullArray, m_dependencyFlag, false ); |
---|
2515 | xPrintArray( "layer_id_in_nuh", getMaxLayersMinus1()+1, m_layerIdInNuh, true ); |
---|
2516 | xPrintArray( "IdPredictedLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numPredictedLayers, m_idPredictedLayer, true ); |
---|
2517 | xPrintArray( "IdRefLayer" , getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numRefLayers, m_idRefLayer, true ); |
---|
2518 | xPrintArray( "IdDirectRefLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numDirectRefLayers, m_idDirectRefLayer, true ); |
---|
2519 | std::cout << std::endl; |
---|
2520 | } |
---|
2521 | |
---|
2522 | #if H_MV_HLS10_AUX |
---|
2523 | Void TComVPS::printScalabilityId() |
---|
2524 | { |
---|
2525 | vector<Int> layerIdxInVps; |
---|
2526 | |
---|
2527 | |
---|
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 | viewOrderIndex.push_back( getViewIndex ( layerIdInNuh ) ); |
---|
2538 | dependencyId .push_back( getDependencyId( layerIdInNuh ) ); |
---|
2539 | auxId .push_back( getAuxId ( layerIdInNuh ) ); |
---|
2540 | viewId .push_back( getViewId ( layerIdInNuh ) ); |
---|
2541 | } |
---|
2542 | |
---|
2543 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Scalability Ids" << std::endl; |
---|
2544 | xPrintArray( "layerIdxInVps" , getMaxLayersMinus1()+1, layerIdxInVps, false ); |
---|
2545 | xPrintArray( "layer_id_in_nuh", getMaxLayersMinus1()+1, m_layerIdInNuh, false ); |
---|
2546 | |
---|
2547 | xPrintArray( "ViewOrderIndex", getMaxLayersMinus1()+1, viewOrderIndex, false ); |
---|
2548 | xPrintArray( "DependencyId" , getMaxLayersMinus1()+1, dependencyId , false ); |
---|
2549 | xPrintArray( "AuxId" , getMaxLayersMinus1()+1, auxId , false ); |
---|
2550 | xPrintArray( "ViewId" , getMaxLayersMinus1()+1, viewId , false ); |
---|
2551 | |
---|
2552 | std::cout << std::endl; |
---|
2553 | } |
---|
2554 | #endif |
---|
2555 | |
---|
2556 | Void TComVPS::printLayerSets() |
---|
2557 | { |
---|
2558 | vector<Int> fullArray; |
---|
2559 | vector<Int> numLayersInIdList; |
---|
2560 | vector<Int> rangeLayerSets; |
---|
2561 | |
---|
2562 | |
---|
2563 | for (Int i = 0; i < getNumLayerSets(); i++ ) |
---|
2564 | { |
---|
2565 | numLayersInIdList.push_back( getNumLayersInIdList( i ) ); |
---|
2566 | rangeLayerSets.push_back( i ); |
---|
2567 | } |
---|
2568 | |
---|
2569 | vector<Int> rangeOutputLayerSets; |
---|
2570 | vector<Int> numOutputLayersInOutputLayerSet; |
---|
2571 | vector<Int> numDecLayer; |
---|
2572 | vector<Int> numLayersInLayerSetForOutputLayerSet; |
---|
2573 | vector<Int> vOlsIdxToLsIdx; |
---|
2574 | for (Int i = 0; i < getNumOutputLayerSets(); i++ ) |
---|
2575 | { |
---|
2576 | vOlsIdxToLsIdx.push_back( olsIdxToLsIdx(i)); |
---|
2577 | numOutputLayersInOutputLayerSet.push_back( getNumOutputLayersInOutputLayerSet( i ) ); |
---|
2578 | numDecLayer.push_back( (Int) m_targetDecLayerIdLists[ i ].size() ); |
---|
2579 | rangeOutputLayerSets.push_back( i ); |
---|
2580 | numLayersInLayerSetForOutputLayerSet.push_back( getNumLayersInIdList( olsIdxToLsIdx( i ) ) ); |
---|
2581 | } |
---|
2582 | |
---|
2583 | vector<Int> rangeIndependentLayers; |
---|
2584 | for(Int i = 0; i < getNumIndependentLayers(); i++ ) |
---|
2585 | { |
---|
2586 | rangeIndependentLayers.push_back( i ); |
---|
2587 | } |
---|
2588 | |
---|
2589 | vector<Int> rangeAddLayerSets; |
---|
2590 | vector<Int> numHighestLayerIdxPlus1; |
---|
2591 | for(Int i = 0; i < getNumAddLayerSets(); i++ ) |
---|
2592 | { |
---|
2593 | rangeAddLayerSets.push_back( i ); |
---|
2594 | numHighestLayerIdxPlus1.push_back( getNumIndependentLayers() ); |
---|
2595 | } |
---|
2596 | |
---|
2597 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Layer Sets" << std::endl; |
---|
2598 | xPrintArray( "TreePartitionLayerIdList", getNumIndependentLayers(), rangeIndependentLayers, m_numLayersInTreePartition, m_treePartitionLayerIdList, true ); |
---|
2599 | xPrintArray( "highest_layer_idx_plus1", getNumAddLayerSets(), rangeAddLayerSets, numHighestLayerIdxPlus1, m_highestLayerIdxPlus1, true ); |
---|
2600 | xPrintArray( "LayerSetLayerIdList" , (Int) getNumLayerSets() , rangeLayerSets , numLayersInIdList, m_layerSetLayerIdList, true ); |
---|
2601 | xPrintArray( "OlsIdxToLsIdx", (Int) vOlsIdxToLsIdx.size(), vOlsIdxToLsIdx, true ); |
---|
2602 | xPrintArray( "OutputLayerFlag" , getNumOutputLayerSets(), rangeOutputLayerSets, numLayersInLayerSetForOutputLayerSet, m_outputLayerFlag, true ); |
---|
2603 | xPrintArray( "TargetOptLayerIdList", getNumOutputLayerSets(), rangeOutputLayerSets, numOutputLayersInOutputLayerSet, m_targetOptLayerIdLists, true ); |
---|
2604 | xPrintArray( "NecessaryLayerFlag" , getNumOutputLayerSets(), rangeOutputLayerSets, numLayersInLayerSetForOutputLayerSet, m_necessaryLayerFlag , true ); |
---|
2605 | xPrintArray( "TargetDecLayerIdList", getNumOutputLayerSets(), rangeOutputLayerSets, numDecLayer, m_targetDecLayerIdLists, true ); |
---|
2606 | std::cout << endl; |
---|
2607 | } |
---|
2608 | |
---|
2609 | #endif |
---|
2610 | |
---|
2611 | #endif // H_MV |
---|
2612 | |
---|
2613 | // ------------------------------------------------------------------------------------------------ |
---|
2614 | // Sequence parameter set (SPS) |
---|
2615 | // ------------------------------------------------------------------------------------------------ |
---|
2616 | |
---|
2617 | TComSPS::TComSPS() |
---|
2618 | : m_SPSId ( 0) |
---|
2619 | , m_VPSId ( 0) |
---|
2620 | , m_chromaFormatIdc (CHROMA_420) |
---|
2621 | , m_uiMaxTLayers ( 1) |
---|
2622 | // Structure |
---|
2623 | , m_picWidthInLumaSamples (352) |
---|
2624 | , m_picHeightInLumaSamples (288) |
---|
2625 | , m_log2MinCodingBlockSize ( 0) |
---|
2626 | , m_log2DiffMaxMinCodingBlockSize (0) |
---|
2627 | , m_uiMaxCUWidth ( 32) |
---|
2628 | , m_uiMaxCUHeight ( 32) |
---|
2629 | , m_uiMaxCUDepth ( 3) |
---|
2630 | , m_bLongTermRefsPresent (false) |
---|
2631 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
2632 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
2633 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
2634 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
2635 | // Tool list |
---|
2636 | , m_usePCM (false) |
---|
2637 | , m_pcmLog2MaxSize ( 5) |
---|
2638 | , m_uiPCMLog2MinSize ( 7) |
---|
2639 | , m_bitDepthY ( 8) |
---|
2640 | , m_bitDepthC ( 8) |
---|
2641 | , m_qpBDOffsetY ( 0) |
---|
2642 | , m_qpBDOffsetC ( 0) |
---|
2643 | , m_uiPCMBitDepthLuma ( 8) |
---|
2644 | , m_uiPCMBitDepthChroma ( 8) |
---|
2645 | , m_bPCMFilterDisableFlag (false) |
---|
2646 | , m_uiBitsForPOC ( 8) |
---|
2647 | , m_numLongTermRefPicSPS ( 0) |
---|
2648 | , m_uiMaxTrSize ( 32) |
---|
2649 | , m_bUseSAO (false) |
---|
2650 | , m_bTemporalIdNestingFlag (false) |
---|
2651 | , m_scalingListEnabledFlag (false) |
---|
2652 | , m_useStrongIntraSmoothing (false) |
---|
2653 | , m_vuiParametersPresentFlag (false) |
---|
2654 | , m_vuiParameters () |
---|
2655 | #if H_MV |
---|
2656 | , m_pcVPS ( NULL ) |
---|
2657 | , m_spsInferScalingListFlag ( false ) |
---|
2658 | , m_spsScalingListRefLayerId ( 0 ) |
---|
2659 | |
---|
2660 | , m_updateRepFormatFlag ( false ) |
---|
2661 | , m_spsRepFormatIdx ( 0 ) |
---|
2662 | , m_interViewMvVertConstraintFlag (false) |
---|
2663 | #endif |
---|
2664 | { |
---|
2665 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
2666 | { |
---|
2667 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2668 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2669 | m_numReorderPics[i] = 0; |
---|
2670 | } |
---|
2671 | m_scalingList = new TComScalingList; |
---|
2672 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
2673 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
2674 | #if H_MV |
---|
2675 | m_spsRangeExtensionsFlag = false; |
---|
2676 | m_spsMultilayerExtensionFlag = false; |
---|
2677 | m_spsExtension6bits = 0; |
---|
2678 | |
---|
2679 | #if !H_MV_HLS10_PPS |
---|
2680 | m_numScaledRefLayerOffsets = 0; |
---|
2681 | |
---|
2682 | for (Int i = 0; i < MAX_NUM_SCALED_REF_LAYERS; i++ ) |
---|
2683 | { |
---|
2684 | m_scaledRefLayerId [i] = -1; |
---|
2685 | } |
---|
2686 | |
---|
2687 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
2688 | { |
---|
2689 | m_scaledRefLayerLeftOffset [i] = 0; |
---|
2690 | m_scaledRefLayerTopOffset [i] = 0; |
---|
2691 | m_scaledRefLayerRiFghtOffset [i] = 0; |
---|
2692 | m_scaledRefLayerBottomOffset [i] = 0; |
---|
2693 | } |
---|
2694 | #endif |
---|
2695 | #endif |
---|
2696 | } |
---|
2697 | |
---|
2698 | TComSPS::~TComSPS() |
---|
2699 | { |
---|
2700 | delete m_scalingList; |
---|
2701 | m_RPSList.destroy(); |
---|
2702 | } |
---|
2703 | |
---|
2704 | Void TComSPS::createRPSList( Int numRPS ) |
---|
2705 | { |
---|
2706 | m_RPSList.destroy(); |
---|
2707 | m_RPSList.create(numRPS); |
---|
2708 | } |
---|
2709 | |
---|
2710 | Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
2711 | { |
---|
2712 | if( !getVuiParametersPresentFlag() ) |
---|
2713 | { |
---|
2714 | return; |
---|
2715 | } |
---|
2716 | |
---|
2717 | TComVUI *vui = getVuiParameters(); |
---|
2718 | TComHRD *hrd = vui->getHrdParameters(); |
---|
2719 | |
---|
2720 | TimingInfo *timingInfo = vui->getTimingInfo(); |
---|
2721 | timingInfo->setTimingInfoPresentFlag( true ); |
---|
2722 | switch( frameRate ) |
---|
2723 | { |
---|
2724 | case 24: |
---|
2725 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2726 | break; |
---|
2727 | case 25: |
---|
2728 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2729 | break; |
---|
2730 | case 30: |
---|
2731 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2732 | break; |
---|
2733 | case 50: |
---|
2734 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2735 | break; |
---|
2736 | case 60: |
---|
2737 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2738 | break; |
---|
2739 | default: |
---|
2740 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
---|
2741 | break; |
---|
2742 | } |
---|
2743 | |
---|
2744 | Bool rateCnt = ( bitRate > 0 ); |
---|
2745 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
2746 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
2747 | |
---|
2748 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
2749 | |
---|
2750 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
2751 | { |
---|
2752 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
2753 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
2754 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
2755 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
2756 | } |
---|
2757 | else |
---|
2758 | { |
---|
2759 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
2760 | } |
---|
2761 | |
---|
2762 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
2763 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
2764 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
2765 | |
---|
2766 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
2767 | if( randomAccess ) |
---|
2768 | { |
---|
2769 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
2770 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
2771 | } |
---|
2772 | else |
---|
2773 | { |
---|
2774 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
2775 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
2776 | } |
---|
2777 | |
---|
2778 | /* |
---|
2779 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
2780 | */ |
---|
2781 | Int i, j; |
---|
2782 | UInt birateValue, cpbSizeValue; |
---|
2783 | UInt ducpbSizeValue; |
---|
2784 | UInt duBitRateValue = 0; |
---|
2785 | |
---|
2786 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
2787 | { |
---|
2788 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
2789 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
2790 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
2791 | hrd->setCpbCntMinus1( i, 0 ); |
---|
2792 | |
---|
2793 | birateValue = bitRate; |
---|
2794 | cpbSizeValue = bitRate; // 1 second |
---|
2795 | ducpbSizeValue = bitRate/numDU; |
---|
2796 | duBitRateValue = bitRate; |
---|
2797 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
2798 | { |
---|
2799 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
2800 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
2801 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
2802 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
2803 | |
---|
2804 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
2805 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
2806 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
2807 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
2808 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
2809 | } |
---|
2810 | } |
---|
2811 | } |
---|
2812 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
2813 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
2814 | |
---|
2815 | TComPPS::TComPPS() |
---|
2816 | : m_PPSId (0) |
---|
2817 | , m_SPSId (0) |
---|
2818 | , m_picInitQPMinus26 (0) |
---|
2819 | , m_useDQP (false) |
---|
2820 | , m_bConstrainedIntraPred (false) |
---|
2821 | , m_bSliceChromaQpFlag (false) |
---|
2822 | , m_pcSPS (NULL) |
---|
2823 | , m_uiMaxCuDQPDepth (0) |
---|
2824 | , m_uiMinCuDQPSize (0) |
---|
2825 | , m_chromaCbQpOffset (0) |
---|
2826 | , m_chromaCrQpOffset (0) |
---|
2827 | , m_numRefIdxL0DefaultActive (1) |
---|
2828 | , m_numRefIdxL1DefaultActive (1) |
---|
2829 | , m_TransquantBypassEnableFlag (false) |
---|
2830 | , m_useTransformSkip (false) |
---|
2831 | , m_dependentSliceSegmentsEnabledFlag (false) |
---|
2832 | , m_tilesEnabledFlag (false) |
---|
2833 | , m_entropyCodingSyncEnabledFlag (false) |
---|
2834 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
2835 | , m_uniformSpacingFlag (0) |
---|
2836 | , m_iNumColumnsMinus1 (0) |
---|
2837 | , m_puiColumnWidth (NULL) |
---|
2838 | , m_iNumRowsMinus1 (0) |
---|
2839 | , m_puiRowHeight (NULL) |
---|
2840 | , m_iNumSubstreams (1) |
---|
2841 | , m_signHideFlag(0) |
---|
2842 | , m_cabacInitPresentFlag (false) |
---|
2843 | , m_encCABACTableIdx (I_SLICE) |
---|
2844 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
2845 | , m_loopFilterAcrossSlicesEnabledFlag (false) |
---|
2846 | , m_listsModificationPresentFlag( 0) |
---|
2847 | , m_numExtraSliceHeaderBits(0) |
---|
2848 | #if H_MV |
---|
2849 | , m_ppsInferScalingListFlag(false) |
---|
2850 | , m_ppsScalingListRefLayerId(0) |
---|
2851 | , m_pocResetInfoPresentFlag(false) |
---|
2852 | #endif |
---|
2853 | { |
---|
2854 | m_scalingList = new TComScalingList; |
---|
2855 | |
---|
2856 | #if H_MV |
---|
2857 | m_ppsRangeExtensionsFlag = false; |
---|
2858 | m_ppsMultilayerExtensionFlag = false; |
---|
2859 | m_ppsExtension6bits = 0; |
---|
2860 | #endif |
---|
2861 | } |
---|
2862 | |
---|
2863 | TComPPS::~TComPPS() |
---|
2864 | { |
---|
2865 | if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
2866 | { |
---|
2867 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
2868 | m_puiColumnWidth = NULL; |
---|
2869 | } |
---|
2870 | if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
2871 | { |
---|
2872 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
2873 | m_puiRowHeight = NULL; |
---|
2874 | } |
---|
2875 | delete m_scalingList; |
---|
2876 | } |
---|
2877 | |
---|
2878 | |
---|
2879 | #if H_MV |
---|
2880 | Void TComSPS::inferRepFormat( TComVPS* vps, Int layerIdCurr ) |
---|
2881 | { |
---|
2882 | #if H_MV_HLS10_MULTILAYERSPS |
---|
2883 | if ( getMultiLayerExtSpsFlag() ) |
---|
2884 | #else |
---|
2885 | if ( layerIdCurr > 0 ) |
---|
2886 | #endif |
---|
2887 | { |
---|
2888 | Int repFormatIdx = getUpdateRepFormatFlag() ? getSpsRepFormatIdx() : vps->getVpsRepFormatIdx( vps->getLayerIdInVps( layerIdCurr ) ) ; |
---|
2889 | TComRepFormat* repFormat = vps->getRepFormat( repFormatIdx ); |
---|
2890 | setChromaFormatIdc( repFormat->getChromaFormatVpsIdc() ); |
---|
2891 | //// ToDo: add when supported: |
---|
2892 | // setSeperateColourPlaneFlag( repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
2893 | |
---|
2894 | setPicWidthInLumaSamples ( repFormat->getPicWidthVpsInLumaSamples() ); |
---|
2895 | setPicHeightInLumaSamples( repFormat->getPicHeightVpsInLumaSamples() ); |
---|
2896 | |
---|
2897 | setBitDepthY ( repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
2898 | setQpBDOffsetY ( (Int) (6*( getBitDepthY() - 8 )) ); |
---|
2899 | |
---|
2900 | setBitDepthC ( repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
2901 | setQpBDOffsetC ( (Int) (6* ( getBitDepthC() -8 ) ) ); |
---|
2902 | #if H_MV_HLS10_GEN_VSP_CONF_WIN |
---|
2903 | Window &spsConf = getConformanceWindow(); |
---|
2904 | |
---|
2905 | // Scaled later |
---|
2906 | spsConf.setScaledFlag( false ); |
---|
2907 | spsConf.setWindowLeftOffset ( repFormat->getConfWinVpsLeftOffset() ); |
---|
2908 | spsConf.setWindowRightOffset ( repFormat->getConfWinVpsRightOffset() ); |
---|
2909 | spsConf.setWindowTopOffset ( repFormat->getConfWinVpsTopOffset() ); |
---|
2910 | spsConf.setWindowBottomOffset( repFormat->getConfWinVpsBottomOffset() ); |
---|
2911 | #endif |
---|
2912 | |
---|
2913 | #if H_MV_HLS10_MULTILAYERSPS |
---|
2914 | if ( getMultiLayerExtSpsFlag() && getUpdateRepFormatFlag() ) |
---|
2915 | #else |
---|
2916 | if ( getLayerId() > 0 && getUpdateRepFormatFlag() ) |
---|
2917 | #endif |
---|
2918 | { |
---|
2919 | assert( getChromaFormatIdc() <= repFormat->getChromaFormatVpsIdc() ); |
---|
2920 | //// ToDo: add when supported: |
---|
2921 | // assert( getSeperateColourPlaneFlag() <= repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
2922 | |
---|
2923 | assert( getPicWidthInLumaSamples() <= repFormat->getPicWidthVpsInLumaSamples() ); |
---|
2924 | assert( getPicHeightInLumaSamples() <= repFormat->getPicHeightVpsInLumaSamples() ); |
---|
2925 | |
---|
2926 | assert( getBitDepthY() <= repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
2927 | assert( getBitDepthC() <= repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
2928 | } |
---|
2929 | } |
---|
2930 | |
---|
2931 | // Set conformance window |
---|
2932 | Int scal = TComSPS::getWinUnitX( getChromaFormatIdc() ) ; |
---|
2933 | getConformanceWindow().scaleOffsets( scal ); |
---|
2934 | getVuiParameters()->getDefaultDisplayWindow().scaleOffsets( scal ); |
---|
2935 | } |
---|
2936 | |
---|
2937 | Void TComSPS::inferScalingList( TComSPS* spsSrc ) |
---|
2938 | { |
---|
2939 | if ( getSpsInferScalingListFlag() ) |
---|
2940 | { |
---|
2941 | assert( spsSrc != NULL ); |
---|
2942 | assert( !spsSrc->getSpsInferScalingListFlag() ); |
---|
2943 | getScalingList()->inferFrom( spsSrc->getScalingList() ); |
---|
2944 | } |
---|
2945 | } |
---|
2946 | |
---|
2947 | Void TComSPS::inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder ) |
---|
2948 | { |
---|
2949 | const std::vector<Int>& targetDecLayerIdList = vps->getTargetDecLayerIdList( vps->olsIdxToLsIdx( targetOptLayerSetIdx )); |
---|
2950 | |
---|
2951 | #if H_MV_HLS10_MULTILAYERSPS |
---|
2952 | if ( getMultiLayerExtSpsFlag() ) |
---|
2953 | #else |
---|
2954 | if (getLayerId() > 0 ) |
---|
2955 | #endif |
---|
2956 | { |
---|
2957 | Int layerIdx = 0; |
---|
2958 | while (layerIdx < (Int) targetDecLayerIdList.size() ) |
---|
2959 | { |
---|
2960 | if ( targetDecLayerIdList[layerIdx] == currLayerId ) |
---|
2961 | { |
---|
2962 | break; |
---|
2963 | } |
---|
2964 | layerIdx++; |
---|
2965 | } |
---|
2966 | |
---|
2967 | assert( layerIdx < (Int) targetDecLayerIdList.size() ); |
---|
2968 | |
---|
2969 | for (Int i = 0; i <= getSpsMaxSubLayersMinus1(); i++ ) |
---|
2970 | { |
---|
2971 | Int maxDecPicBufferingMinus1 = vps->getDpbSize()->getMaxVpsDecPicBufferingMinus1( targetOptLayerSetIdx, layerIdx, i ) ; |
---|
2972 | |
---|
2973 | #if H_MV_HLS10_MULTILAYERSPS |
---|
2974 | // This preliminary fix needs to be checked. |
---|
2975 | Int maxNumReorderPics = vps->getDpbSize()->getMaxVpsNumReorderPics( targetOptLayerSetIdx, i ); |
---|
2976 | Int maxLatencyIncreasePlus1 = vps->getDpbSize()->getMaxVpsLatencyIncreasePlus1( targetOptLayerSetIdx, i ); |
---|
2977 | #endif |
---|
2978 | if ( encoder ) |
---|
2979 | { |
---|
2980 | assert( getMaxDecPicBuffering( i ) - 1 == maxDecPicBufferingMinus1 ); |
---|
2981 | #if H_MV_HLS10_MULTILAYERSPS |
---|
2982 | // This preliminary fix needs to be checked. |
---|
2983 | assert( getNumReorderPics( i ) == maxNumReorderPics ); |
---|
2984 | assert( getMaxLatencyIncrease( i ) == maxLatencyIncreasePlus1 ); |
---|
2985 | #endif |
---|
2986 | |
---|
2987 | } |
---|
2988 | else |
---|
2989 | { |
---|
2990 | #if !H_MV_HLS10_MULTILAYERSPS |
---|
2991 | setMaxDecPicBuffering(i, maxDecPicBufferingMinus1 + 1 ); |
---|
2992 | #else |
---|
2993 | // This preliminary fix needs to be checked. |
---|
2994 | setMaxDecPicBuffering( maxDecPicBufferingMinus1 + 1 , i); |
---|
2995 | setNumReorderPics ( maxNumReorderPics, i ); |
---|
2996 | setMaxLatencyIncrease( maxLatencyIncreasePlus1 - 1 , i); |
---|
2997 | #endif |
---|
2998 | } |
---|
2999 | } |
---|
3000 | } |
---|
3001 | } |
---|
3002 | |
---|
3003 | Void TComSPS::checkRpsMaxNumPics( TComVPS* vps, Int currLayerId ) |
---|
3004 | { |
---|
3005 | #if !H_MV_HLS10_MAXNUMPICS |
---|
3006 | // In spec, when rps is in SPS, nuh_layer_id of SPS is used instead |
---|
3007 | // of nuh_layer_id of slice (currLayerId), this seems to be a bug. |
---|
3008 | #endif |
---|
3009 | for (Int i = 0; i < getRPSList()->getNumberOfReferencePictureSets(); i++ ) |
---|
3010 | { |
---|
3011 | TComReferencePictureSet* rps = getRPSList()->getReferencePictureSet( i ); |
---|
3012 | if ( !rps->getInterRPSPrediction() ) |
---|
3013 | { |
---|
3014 | #if H_MV_HLS10_MAXNUMPICS |
---|
3015 | rps->checkMaxNumPics( vps->getVpsExtensionFlag(), MAX_INT, getLayerId(), getMaxDecPicBuffering( getSpsMaxSubLayersMinus1() ) - 1 ); // INT_MAX to be replaced by DpbSize |
---|
3016 | #else |
---|
3017 | rps->checkMaxNumPics( vps->getVpsExtensionFlag(), vps->getMaxNumPics( currLayerId ), |
---|
3018 | getLayerId(), getMaxDecPicBuffering( getSpsMaxSubLayersMinus1() ) - 1 ); |
---|
3019 | #endif |
---|
3020 | } |
---|
3021 | } |
---|
3022 | } |
---|
3023 | |
---|
3024 | #if H_MV_HLS10_MULTILAYERSPS |
---|
3025 | Void TComSPS::inferSpsMaxSubLayersMinus1(Bool atPsActivation, TComVPS* vps) |
---|
3026 | { |
---|
3027 | assert( getLayerId() != 0 ); |
---|
3028 | if ( !atPsActivation ) |
---|
3029 | { |
---|
3030 | assert( vps == NULL ); |
---|
3031 | if (getSpsExtOrMaxSubLayersMinus1() != 7) |
---|
3032 | { |
---|
3033 | setSpsMaxSubLayersMinus1( getSpsExtOrMaxSubLayersMinus1() ); |
---|
3034 | } |
---|
3035 | } |
---|
3036 | else |
---|
3037 | { |
---|
3038 | assert( vps != NULL ); |
---|
3039 | if (getSpsExtOrMaxSubLayersMinus1() == 7) |
---|
3040 | { |
---|
3041 | setSpsMaxSubLayersMinus1( vps->getMaxSubLayersMinus1() ); |
---|
3042 | } |
---|
3043 | } |
---|
3044 | } |
---|
3045 | #endif |
---|
3046 | #endif |
---|
3047 | |
---|
3048 | TComReferencePictureSet::TComReferencePictureSet() |
---|
3049 | : m_numberOfPictures (0) |
---|
3050 | , m_numberOfNegativePictures (0) |
---|
3051 | , m_numberOfPositivePictures (0) |
---|
3052 | , m_numberOfLongtermPictures (0) |
---|
3053 | , m_interRPSPrediction (0) |
---|
3054 | , m_deltaRIdxMinus1 (0) |
---|
3055 | , m_deltaRPS (0) |
---|
3056 | , m_numRefIdc (0) |
---|
3057 | { |
---|
3058 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
3059 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
3060 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
3061 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
3062 | } |
---|
3063 | |
---|
3064 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
3065 | { |
---|
3066 | } |
---|
3067 | |
---|
3068 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
3069 | { |
---|
3070 | m_used[bufferNum] = used; |
---|
3071 | } |
---|
3072 | |
---|
3073 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
3074 | { |
---|
3075 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
3076 | } |
---|
3077 | |
---|
3078 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
3079 | { |
---|
3080 | m_numberOfPictures = numberOfPictures; |
---|
3081 | } |
---|
3082 | |
---|
3083 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
3084 | { |
---|
3085 | return m_used[bufferNum]; |
---|
3086 | } |
---|
3087 | |
---|
3088 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
3089 | { |
---|
3090 | return m_deltaPOC[bufferNum]; |
---|
3091 | } |
---|
3092 | |
---|
3093 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
3094 | { |
---|
3095 | return m_numberOfPictures; |
---|
3096 | } |
---|
3097 | |
---|
3098 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
3099 | { |
---|
3100 | return m_POC[bufferNum]; |
---|
3101 | } |
---|
3102 | |
---|
3103 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
3104 | { |
---|
3105 | m_POC[bufferNum] = POC; |
---|
3106 | } |
---|
3107 | |
---|
3108 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) |
---|
3109 | { |
---|
3110 | return m_bCheckLTMSB[bufferNum]; |
---|
3111 | } |
---|
3112 | |
---|
3113 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
3114 | { |
---|
3115 | m_bCheckLTMSB[bufferNum] = b; |
---|
3116 | } |
---|
3117 | |
---|
3118 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
3119 | * \param uiBufferNum |
---|
3120 | * \param iRefIdc |
---|
3121 | * \returns Void |
---|
3122 | */ |
---|
3123 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
3124 | { |
---|
3125 | m_refIdc[bufferNum] = refIdc; |
---|
3126 | } |
---|
3127 | |
---|
3128 | /** get the reference idc value at uiBufferNum |
---|
3129 | * \param uiBufferNum |
---|
3130 | * \returns Int |
---|
3131 | */ |
---|
3132 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
3133 | { |
---|
3134 | return m_refIdc[bufferNum]; |
---|
3135 | } |
---|
3136 | |
---|
3137 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
3138 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
3139 | * +ve values are in increasing order. |
---|
3140 | * \returns Void |
---|
3141 | */ |
---|
3142 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
3143 | { |
---|
3144 | // sort in increasing order (smallest first) |
---|
3145 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
3146 | { |
---|
3147 | Int deltaPOC = getDeltaPOC(j); |
---|
3148 | Bool used = getUsed(j); |
---|
3149 | for (Int k=j-1; k >= 0; k--) |
---|
3150 | { |
---|
3151 | Int temp = getDeltaPOC(k); |
---|
3152 | if (deltaPOC < temp) |
---|
3153 | { |
---|
3154 | setDeltaPOC(k+1, temp); |
---|
3155 | setUsed(k+1, getUsed(k)); |
---|
3156 | setDeltaPOC(k, deltaPOC); |
---|
3157 | setUsed(k, used); |
---|
3158 | } |
---|
3159 | } |
---|
3160 | } |
---|
3161 | // flip the negative values to largest first |
---|
3162 | Int numNegPics = getNumberOfNegativePictures(); |
---|
3163 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
3164 | { |
---|
3165 | Int deltaPOC = getDeltaPOC(j); |
---|
3166 | Bool used = getUsed(j); |
---|
3167 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
3168 | setUsed(j, getUsed(k)); |
---|
3169 | setDeltaPOC(k, deltaPOC); |
---|
3170 | setUsed(k, used); |
---|
3171 | } |
---|
3172 | } |
---|
3173 | |
---|
3174 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
3175 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
3176 | * \returns Void |
---|
3177 | */ |
---|
3178 | Void TComReferencePictureSet::printDeltaPOC() |
---|
3179 | { |
---|
3180 | printf("DeltaPOC = { "); |
---|
3181 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
3182 | { |
---|
3183 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
3184 | } |
---|
3185 | if (getInterRPSPrediction()) |
---|
3186 | { |
---|
3187 | printf("}, RefIdc = { "); |
---|
3188 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
3189 | { |
---|
3190 | printf("%d ", getRefIdc(j)); |
---|
3191 | } |
---|
3192 | } |
---|
3193 | printf("}\n"); |
---|
3194 | } |
---|
3195 | #if H_MV |
---|
3196 | Void TComReferencePictureSet::checkMaxNumPics( Bool vpsExtensionFlag, Int maxNumPics, Int nuhLayerId, Int spsMaxDecPicBufferingMinus1 ) |
---|
3197 | { |
---|
3198 | assert( getNumberOfPictures() >= 0 ); |
---|
3199 | if ( nuhLayerId == 0 ) |
---|
3200 | { |
---|
3201 | assert( getNumberOfPictures() <= spsMaxDecPicBufferingMinus1 ); |
---|
3202 | } |
---|
3203 | |
---|
3204 | if ( vpsExtensionFlag ) |
---|
3205 | { |
---|
3206 | assert( getNumberOfPictures() <= maxNumPics ); |
---|
3207 | } |
---|
3208 | } |
---|
3209 | #endif |
---|
3210 | |
---|
3211 | TComRPSList::TComRPSList() |
---|
3212 | :m_referencePictureSets (NULL) |
---|
3213 | { |
---|
3214 | } |
---|
3215 | |
---|
3216 | TComRPSList::~TComRPSList() |
---|
3217 | { |
---|
3218 | } |
---|
3219 | |
---|
3220 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
3221 | { |
---|
3222 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
3223 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
3224 | } |
---|
3225 | |
---|
3226 | Void TComRPSList::destroy() |
---|
3227 | { |
---|
3228 | if (m_referencePictureSets) |
---|
3229 | { |
---|
3230 | delete [] m_referencePictureSets; |
---|
3231 | } |
---|
3232 | m_numberOfReferencePictureSets = 0; |
---|
3233 | m_referencePictureSets = NULL; |
---|
3234 | } |
---|
3235 | |
---|
3236 | |
---|
3237 | |
---|
3238 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
3239 | { |
---|
3240 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
3241 | } |
---|
3242 | |
---|
3243 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
3244 | { |
---|
3245 | return m_numberOfReferencePictureSets; |
---|
3246 | } |
---|
3247 | |
---|
3248 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
3249 | { |
---|
3250 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
3251 | } |
---|
3252 | |
---|
3253 | TComRefPicListModification::TComRefPicListModification() |
---|
3254 | : m_bRefPicListModificationFlagL0 (false) |
---|
3255 | , m_bRefPicListModificationFlagL1 (false) |
---|
3256 | { |
---|
3257 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
3258 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
3259 | } |
---|
3260 | |
---|
3261 | TComRefPicListModification::~TComRefPicListModification() |
---|
3262 | { |
---|
3263 | } |
---|
3264 | |
---|
3265 | TComScalingList::TComScalingList() |
---|
3266 | { |
---|
3267 | init(); |
---|
3268 | } |
---|
3269 | TComScalingList::~TComScalingList() |
---|
3270 | { |
---|
3271 | destroy(); |
---|
3272 | } |
---|
3273 | |
---|
3274 | /** set default quantization matrix to array |
---|
3275 | */ |
---|
3276 | Void TComSlice::setDefaultScalingList() |
---|
3277 | { |
---|
3278 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3279 | { |
---|
3280 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
3281 | { |
---|
3282 | getScalingList()->processDefaultMatrix(sizeId, listId); |
---|
3283 | } |
---|
3284 | } |
---|
3285 | } |
---|
3286 | /** check if use default quantization matrix |
---|
3287 | * \returns true if use default quantization matrix in all size |
---|
3288 | */ |
---|
3289 | Bool TComSlice::checkDefaultScalingList() |
---|
3290 | { |
---|
3291 | UInt defaultCounter=0; |
---|
3292 | |
---|
3293 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3294 | { |
---|
3295 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
3296 | { |
---|
3297 | if( !memcmp(getScalingList()->getScalingListAddress(sizeId,listId), getScalingList()->getScalingListDefaultAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
3298 | && ((sizeId < SCALING_LIST_16x16) || (getScalingList()->getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
3299 | { |
---|
3300 | defaultCounter++; |
---|
3301 | } |
---|
3302 | } |
---|
3303 | } |
---|
3304 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32 |
---|
3305 | } |
---|
3306 | |
---|
3307 | #if H_MV |
---|
3308 | Void TComSlice::createInterLayerReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1 ) |
---|
3309 | { |
---|
3310 | refPicSetInterLayer0.clear(); |
---|
3311 | refPicSetInterLayer1.clear(); |
---|
3312 | |
---|
3313 | for( Int i = 0; i < getNumActiveRefLayerPics(); i++ ) |
---|
3314 | { |
---|
3315 | Int layerIdRef = getRefPicLayerId( i ); |
---|
3316 | TComPic* picRef = ivPicLists->getPic( layerIdRef, getPOC() ) ; |
---|
3317 | assert ( picRef != 0 ); // There shall be no entry equal to "no reference picture" in RefPicSetInterLayer0 or RefPicSetInterLayer1. |
---|
3318 | |
---|
3319 | picRef->getPicYuvRec()->extendPicBorder(); |
---|
3320 | picRef->setIsLongTerm( true ); |
---|
3321 | picRef->getSlice(0)->setReferenced( true ); |
---|
3322 | |
---|
3323 | Int viewIdCur = getVPS()->getViewId( getLayerId() ); |
---|
3324 | Int viewIdZero = getVPS()->getViewId( 0 ); |
---|
3325 | Int viewIdRef = getVPS()->getViewId( layerIdRef ); |
---|
3326 | |
---|
3327 | if ( ( viewIdCur <= viewIdZero && viewIdCur <= viewIdRef ) || ( viewIdCur >= viewIdZero && viewIdCur >= viewIdRef ) ) |
---|
3328 | { |
---|
3329 | refPicSetInterLayer0.push_back( picRef ); |
---|
3330 | } |
---|
3331 | else |
---|
3332 | { |
---|
3333 | refPicSetInterLayer1.push_back( picRef ); |
---|
3334 | } |
---|
3335 | // Consider to check here: |
---|
3336 | // "If the current picture is a RADL picture, there shall be no entry in the RefPicSetInterLayer0 and RefPicSetInterLayer1 that is a RASL picture. " |
---|
3337 | assert( picRef->getSlice(0)->getDiscardableFlag() == false ); // "There shall be no picture that has discardable_flag equal to 1 in RefPicSetInterLayer0 or RefPicSetInterLayer1". |
---|
3338 | } |
---|
3339 | } |
---|
3340 | |
---|
3341 | Void TComSlice::markIvRefPicsAsShortTerm( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 ) |
---|
3342 | { |
---|
3343 | // Mark as short-term |
---|
3344 | for ( Int i = 0; i < refPicSetInterLayer0.size(); i++ ) |
---|
3345 | { |
---|
3346 | refPicSetInterLayer0[i]->setIsLongTerm( false ); |
---|
3347 | } |
---|
3348 | |
---|
3349 | for ( Int i = 0; i < refPicSetInterLayer1.size(); i++ ) |
---|
3350 | { |
---|
3351 | refPicSetInterLayer1[i]->setIsLongTerm( false ); |
---|
3352 | } |
---|
3353 | |
---|
3354 | } |
---|
3355 | |
---|
3356 | Void TComSlice::printRefPicList() |
---|
3357 | { |
---|
3358 | for ( Int li = 0; li < 2; li++) |
---|
3359 | { |
---|
3360 | std::cout << std::endl << "RefPicListL" << li << ":" << std::endl; |
---|
3361 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[li]-1); rIdx ++) |
---|
3362 | { |
---|
3363 | if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( true ); |
---|
3364 | |
---|
3365 | m_apcRefPicList[li][rIdx]->print( false ); |
---|
3366 | } |
---|
3367 | } |
---|
3368 | } |
---|
3369 | |
---|
3370 | Void TComSlice::markCurrPic( TComPic* currPic ) |
---|
3371 | { |
---|
3372 | currPic->getSlice(0)->setReferenced( true ) ; |
---|
3373 | currPic->setIsLongTerm( false ); |
---|
3374 | |
---|
3375 | currPic->setReconMark( true ); |
---|
3376 | currPic->setPicOutputFlag( currPic->getSlice(0)->getPicOutputFlag() ); |
---|
3377 | } |
---|
3378 | |
---|
3379 | Void TComSlice::setRefPicSetInterLayer( std::vector<TComPic*>* refPicSetInterLayer0, std::vector<TComPic*>* refPicSetInterLayer1 ) |
---|
3380 | { |
---|
3381 | m_refPicSetInterLayer0 = refPicSetInterLayer0; |
---|
3382 | m_refPicSetInterLayer1 = refPicSetInterLayer1; |
---|
3383 | } |
---|
3384 | |
---|
3385 | TComPic* TComSlice::getPicFromRefPicSetInterLayer(Int setIdc, Int layerId ) |
---|
3386 | { |
---|
3387 | assert ( setIdc == 0 || setIdc == 1); |
---|
3388 | std::vector<TComPic*>* refPicSetInterLayer = ( setIdc == 0 ? m_refPicSetInterLayer0 : m_refPicSetInterLayer1); |
---|
3389 | assert( refPicSetInterLayer != 0 ); |
---|
3390 | |
---|
3391 | TComPic* pcPic = NULL; |
---|
3392 | for ( Int i = 0; i < (*refPicSetInterLayer).size(); i++ ) |
---|
3393 | { |
---|
3394 | if ((*refPicSetInterLayer)[ i ]->getLayerId() == layerId ) |
---|
3395 | { |
---|
3396 | pcPic = (*refPicSetInterLayer)[ i ]; |
---|
3397 | } |
---|
3398 | } |
---|
3399 | |
---|
3400 | assert(pcPic != NULL); |
---|
3401 | return pcPic; |
---|
3402 | } |
---|
3403 | |
---|
3404 | |
---|
3405 | Int TComSlice::getRefLayerPicFlag( Int i ) |
---|
3406 | { |
---|
3407 | TComVPS* vps = getVPS(); |
---|
3408 | #if H_MV_HLS10_REF_PRED_LAYERS |
---|
3409 | Int refLayerIdx = vps->getLayerIdInVps( vps->getIdDirectRefLayer( getLayerId(), i ) ); |
---|
3410 | #else |
---|
3411 | Int refLayerIdx = vps->getLayerIdInVps( vps->getRefLayerId( getLayerId(), i ) ); |
---|
3412 | #endif |
---|
3413 | |
---|
3414 | Bool refLayerPicFlag = ( vps->getSubLayersVpsMaxMinus1( refLayerIdx ) >= getTLayer() ) && ( getTLayer() == 0 ) && |
---|
3415 | ( vps->getMaxTidIlRefPicsPlus1( refLayerIdx, vps->getLayerIdInVps( getLayerId() )) > getTLayer() ); |
---|
3416 | |
---|
3417 | return refLayerPicFlag; |
---|
3418 | } |
---|
3419 | |
---|
3420 | Int TComSlice::getRefLayerPicIdc( Int j ) |
---|
3421 | { |
---|
3422 | Int refLayerPicIdc = -1; |
---|
3423 | Int curj = 0; |
---|
3424 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ ) |
---|
3425 | { |
---|
3426 | if( getRefLayerPicFlag( i ) ) |
---|
3427 | { |
---|
3428 | if ( curj == j ) |
---|
3429 | { |
---|
3430 | refLayerPicIdc = i; |
---|
3431 | break; |
---|
3432 | } |
---|
3433 | curj++; |
---|
3434 | } |
---|
3435 | } |
---|
3436 | |
---|
3437 | assert( curj == j ); |
---|
3438 | assert( refLayerPicIdc != -1 ); |
---|
3439 | return refLayerPicIdc; |
---|
3440 | } |
---|
3441 | |
---|
3442 | Int TComSlice::getNumRefLayerPics( ) |
---|
3443 | { |
---|
3444 | Int numRefLayerPics = 0; |
---|
3445 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ ) |
---|
3446 | { |
---|
3447 | numRefLayerPics += getRefLayerPicFlag( i ); |
---|
3448 | } |
---|
3449 | return numRefLayerPics; |
---|
3450 | } |
---|
3451 | |
---|
3452 | |
---|
3453 | |
---|
3454 | Int TComSlice::getNumActiveRefLayerPics() |
---|
3455 | { |
---|
3456 | Int numActiveRefLayerPics; |
---|
3457 | |
---|
3458 | if( getLayerId() == 0 || getNumRefLayerPics() == 0 ) |
---|
3459 | { |
---|
3460 | numActiveRefLayerPics = 0; |
---|
3461 | } |
---|
3462 | else if (getVPS()->getAllRefLayersActiveFlag() ) |
---|
3463 | { |
---|
3464 | numActiveRefLayerPics = getNumRefLayerPics(); |
---|
3465 | } |
---|
3466 | else if ( !getInterLayerPredEnabledFlag() ) |
---|
3467 | { |
---|
3468 | numActiveRefLayerPics = 0; |
---|
3469 | } |
---|
3470 | else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumDirectRefLayers( getLayerId() ) == 1 ) |
---|
3471 | { |
---|
3472 | numActiveRefLayerPics = 1; |
---|
3473 | } |
---|
3474 | else |
---|
3475 | { |
---|
3476 | numActiveRefLayerPics = getNumInterLayerRefPicsMinus1() + 1; |
---|
3477 | } |
---|
3478 | return numActiveRefLayerPics; |
---|
3479 | } |
---|
3480 | |
---|
3481 | Int TComSlice::getRefPicLayerId( Int i ) |
---|
3482 | { |
---|
3483 | #if H_MV_HLS10_REF_PRED_LAYERS |
---|
3484 | return getVPS()->getIdDirectRefLayer( getLayerId(), getInterLayerPredLayerIdc( i ) ); |
---|
3485 | #else |
---|
3486 | return getVPS()->getRefLayerId( getLayerId(), getInterLayerPredLayerIdc( i ) ); |
---|
3487 | #endif |
---|
3488 | } |
---|
3489 | |
---|
3490 | #endif |
---|
3491 | |
---|
3492 | |
---|
3493 | #if H_MV |
---|
3494 | Void TComSlice::checkCrossLayerBlaFlag() |
---|
3495 | { |
---|
3496 | // 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. |
---|
3497 | if ( getLayerId() != 0 || getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
3498 | { |
---|
3499 | assert( m_crossLayerBlaFlag == 0 ); |
---|
3500 | } |
---|
3501 | } |
---|
3502 | |
---|
3503 | Bool TComSlice::inferPocMsbValPresentFlag() |
---|
3504 | { |
---|
3505 | Bool pocMsbValPresentFlag; |
---|
3506 | if( getSliceSegmentHeaderExtensionLength() == 0 ) |
---|
3507 | { |
---|
3508 | pocMsbValPresentFlag = false; |
---|
3509 | } |
---|
3510 | else if ( getPocMsbValRequiredFlag() ) |
---|
3511 | { |
---|
3512 | pocMsbValPresentFlag = true; |
---|
3513 | } |
---|
3514 | else |
---|
3515 | { |
---|
3516 | pocMsbValPresentFlag = false; |
---|
3517 | } |
---|
3518 | |
---|
3519 | return pocMsbValPresentFlag; |
---|
3520 | } |
---|
3521 | |
---|
3522 | |
---|
3523 | #endif |
---|
3524 | |
---|
3525 | |
---|
3526 | /** get scaling matrix from RefMatrixID |
---|
3527 | * \param sizeId size index |
---|
3528 | * \param Index of input matrix |
---|
3529 | * \param Index of reference matrix |
---|
3530 | */ |
---|
3531 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
3532 | { |
---|
3533 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
3534 | } |
---|
3535 | |
---|
3536 | /** parse syntax infomation |
---|
3537 | * \param pchFile syntax infomation |
---|
3538 | * \returns false if successful |
---|
3539 | */ |
---|
3540 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
3541 | { |
---|
3542 | FILE *fp; |
---|
3543 | Char line[1024]; |
---|
3544 | UInt sizeIdc,listIdc; |
---|
3545 | UInt i,size = 0; |
---|
3546 | Int *src=0,data; |
---|
3547 | Char *ret; |
---|
3548 | UInt retval; |
---|
3549 | |
---|
3550 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
3551 | { |
---|
3552 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
3553 | return true; |
---|
3554 | } |
---|
3555 | |
---|
3556 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
3557 | { |
---|
3558 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
3559 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
3560 | { |
---|
3561 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
3562 | |
---|
3563 | fseek(fp,0,0); |
---|
3564 | do |
---|
3565 | { |
---|
3566 | ret = fgets(line, 1024, fp); |
---|
3567 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
3568 | { |
---|
3569 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
3570 | return true; |
---|
3571 | } |
---|
3572 | } |
---|
3573 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
3574 | for (i=0; i<size; i++) |
---|
3575 | { |
---|
3576 | retval = fscanf(fp, "%d,", &data); |
---|
3577 | if (retval!=1) |
---|
3578 | { |
---|
3579 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
3580 | return true; |
---|
3581 | } |
---|
3582 | src[i] = data; |
---|
3583 | } |
---|
3584 | //set DC value for default matrix check |
---|
3585 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
3586 | |
---|
3587 | if(sizeIdc > SCALING_LIST_8x8) |
---|
3588 | { |
---|
3589 | fseek(fp,0,0); |
---|
3590 | do |
---|
3591 | { |
---|
3592 | ret = fgets(line, 1024, fp); |
---|
3593 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
3594 | { |
---|
3595 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
3596 | return true; |
---|
3597 | } |
---|
3598 | } |
---|
3599 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
3600 | retval = fscanf(fp, "%d,", &data); |
---|
3601 | if (retval!=1) |
---|
3602 | { |
---|
3603 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
3604 | return true; |
---|
3605 | } |
---|
3606 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
3607 | setScalingListDC(sizeIdc,listIdc,data); |
---|
3608 | } |
---|
3609 | } |
---|
3610 | } |
---|
3611 | fclose(fp); |
---|
3612 | return false; |
---|
3613 | } |
---|
3614 | |
---|
3615 | #if H_MV |
---|
3616 | Void TComScalingList::inferFrom( TComScalingList* srcScLi ) |
---|
3617 | { |
---|
3618 | for(Int sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3619 | { |
---|
3620 | for(Int listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
3621 | { |
---|
3622 | setRefMatrixId (sizeId,listId, srcScLi->getRefMatrixId (sizeId,listId)); |
---|
3623 | setScalingListDC(sizeId,listId, srcScLi->getScalingListDC(sizeId,listId)); |
---|
3624 | ::memcpy(getScalingListAddress(sizeId, listId),srcScLi->getScalingListAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
3625 | } |
---|
3626 | } |
---|
3627 | } |
---|
3628 | #endif |
---|
3629 | /** initialization process of quantization matrix array |
---|
3630 | */ |
---|
3631 | Void TComScalingList::init() |
---|
3632 | { |
---|
3633 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3634 | { |
---|
3635 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
3636 | { |
---|
3637 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
3638 | } |
---|
3639 | } |
---|
3640 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
3641 | } |
---|
3642 | |
---|
3643 | /** destroy quantization matrix array |
---|
3644 | */ |
---|
3645 | Void TComScalingList::destroy() |
---|
3646 | { |
---|
3647 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3648 | { |
---|
3649 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
3650 | { |
---|
3651 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
3652 | } |
---|
3653 | } |
---|
3654 | } |
---|
3655 | |
---|
3656 | /** get default address of quantization matrix |
---|
3657 | * \param sizeId size index |
---|
3658 | * \param listId list index |
---|
3659 | * \returns pointer of quantization matrix |
---|
3660 | */ |
---|
3661 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
3662 | { |
---|
3663 | Int *src = 0; |
---|
3664 | switch(sizeId) |
---|
3665 | { |
---|
3666 | case SCALING_LIST_4x4: |
---|
3667 | src = g_quantTSDefault4x4; |
---|
3668 | break; |
---|
3669 | case SCALING_LIST_8x8: |
---|
3670 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
3671 | break; |
---|
3672 | case SCALING_LIST_16x16: |
---|
3673 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
3674 | break; |
---|
3675 | case SCALING_LIST_32x32: |
---|
3676 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
3677 | break; |
---|
3678 | default: |
---|
3679 | assert(0); |
---|
3680 | src = NULL; |
---|
3681 | break; |
---|
3682 | } |
---|
3683 | return src; |
---|
3684 | } |
---|
3685 | |
---|
3686 | /** process of default matrix |
---|
3687 | * \param sizeId size index |
---|
3688 | * \param Index of input matrix |
---|
3689 | */ |
---|
3690 | Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId) |
---|
3691 | { |
---|
3692 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
3693 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
3694 | } |
---|
3695 | |
---|
3696 | /** check DC value of matrix for default matrix signaling |
---|
3697 | */ |
---|
3698 | Void TComScalingList::checkDcOfMatrix() |
---|
3699 | { |
---|
3700 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3701 | { |
---|
3702 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
3703 | { |
---|
3704 | //check default matrix? |
---|
3705 | if(getScalingListDC(sizeId,listId) == 0) |
---|
3706 | { |
---|
3707 | processDefaultMatrix(sizeId, listId); |
---|
3708 | } |
---|
3709 | } |
---|
3710 | } |
---|
3711 | } |
---|
3712 | |
---|
3713 | ParameterSetManager::ParameterSetManager() |
---|
3714 | : m_vpsMap(MAX_NUM_VPS) |
---|
3715 | , m_spsMap(MAX_NUM_SPS) |
---|
3716 | , m_ppsMap(MAX_NUM_PPS) |
---|
3717 | , m_activeVPSId(-1) |
---|
3718 | #if !H_MV |
---|
3719 | , m_activeSPSId(-1) |
---|
3720 | , m_activePPSId(-1) |
---|
3721 | { |
---|
3722 | #else |
---|
3723 | { |
---|
3724 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
3725 | { |
---|
3726 | m_activeSPSId[ i ] = -1; |
---|
3727 | m_activePPSId[ i ] = -1; |
---|
3728 | } |
---|
3729 | #endif |
---|
3730 | } |
---|
3731 | |
---|
3732 | |
---|
3733 | ParameterSetManager::~ParameterSetManager() |
---|
3734 | { |
---|
3735 | } |
---|
3736 | |
---|
3737 | //! activate a SPS from a active parameter sets SEI message |
---|
3738 | //! \returns true, if activation is successful |
---|
3739 | #if H_MV |
---|
3740 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId, Int layerId ) |
---|
3741 | #else |
---|
3742 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
3743 | #endif |
---|
3744 | { |
---|
3745 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
3746 | if (sps) |
---|
3747 | { |
---|
3748 | Int vpsId = sps->getVPSId(); |
---|
3749 | if (m_vpsMap.getPS(vpsId)) |
---|
3750 | { |
---|
3751 | m_activeVPSId = vpsId; |
---|
3752 | #if H_MV |
---|
3753 | m_activeSPSId[ layerId ] = spsId; |
---|
3754 | #else |
---|
3755 | m_activeSPSId = spsId; |
---|
3756 | #endif |
---|
3757 | return true; |
---|
3758 | } |
---|
3759 | else |
---|
3760 | { |
---|
3761 | printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
3762 | } |
---|
3763 | } |
---|
3764 | else |
---|
3765 | { |
---|
3766 | printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
3767 | } |
---|
3768 | return false; |
---|
3769 | } |
---|
3770 | |
---|
3771 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
3772 | //! \returns true, if activation is successful |
---|
3773 | #if H_MV |
---|
3774 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP, Int layerId ) |
---|
3775 | #else |
---|
3776 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
3777 | #endif |
---|
3778 | { |
---|
3779 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
3780 | if (pps) |
---|
3781 | { |
---|
3782 | Int spsId = pps->getSPSId(); |
---|
3783 | #if H_MV |
---|
3784 | if (!isIRAP && (spsId != m_activeSPSId[ layerId ])) |
---|
3785 | #else |
---|
3786 | if (!isIRAP && (spsId != m_activeSPSId)) |
---|
3787 | #endif |
---|
3788 | { |
---|
3789 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IRAP."); |
---|
3790 | return false; |
---|
3791 | } |
---|
3792 | |
---|
3793 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
3794 | if (sps) |
---|
3795 | { |
---|
3796 | Int vpsId = sps->getVPSId(); |
---|
3797 | if (!isIRAP && (vpsId != m_activeVPSId)) |
---|
3798 | { |
---|
3799 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IRAP."); |
---|
3800 | return false; |
---|
3801 | } |
---|
3802 | if (m_vpsMap.getPS(vpsId)) |
---|
3803 | { |
---|
3804 | #if H_MV |
---|
3805 | m_activePPSId[ layerId ] = ppsId; |
---|
3806 | m_activeVPSId = vpsId; |
---|
3807 | m_activeSPSId[ layerId ] = spsId; |
---|
3808 | #else |
---|
3809 | m_activePPSId = ppsId; |
---|
3810 | m_activeVPSId = vpsId; |
---|
3811 | m_activeSPSId = spsId; |
---|
3812 | #endif |
---|
3813 | return true; |
---|
3814 | } |
---|
3815 | else |
---|
3816 | { |
---|
3817 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
3818 | } |
---|
3819 | } |
---|
3820 | else |
---|
3821 | { |
---|
3822 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
3823 | } |
---|
3824 | } |
---|
3825 | else |
---|
3826 | { |
---|
3827 | printf("Warning: tried to activate non-existing PPS."); |
---|
3828 | } |
---|
3829 | return false; |
---|
3830 | } |
---|
3831 | |
---|
3832 | ProfileTierLevel::ProfileTierLevel() |
---|
3833 | : m_profileSpace (0) |
---|
3834 | , m_tierFlag (false) |
---|
3835 | , m_profileIdc (0) |
---|
3836 | , m_levelIdc (0) |
---|
3837 | , m_progressiveSourceFlag (false) |
---|
3838 | , m_interlacedSourceFlag (false) |
---|
3839 | , m_nonPackedConstraintFlag(false) |
---|
3840 | , m_frameOnlyConstraintFlag(false) |
---|
3841 | #if H_MV_HLS10_PTL |
---|
3842 | , m_max12bitConstraintFlag ( false ) |
---|
3843 | , m_max10bitConstraintFlag ( false ) |
---|
3844 | , m_max8bitConstraintFlag ( false ) |
---|
3845 | , m_max422chromaConstraintFlag ( false ) |
---|
3846 | , m_max420chromaConstraintFlag ( false ) |
---|
3847 | , m_maxMonochromeConstraintFlag ( false ) |
---|
3848 | , m_intraConstraintFlag ( false ) |
---|
3849 | , m_onePictureOnlyConstraintFlag( false ) |
---|
3850 | , m_lowerBitRateConstraintFlag ( false ) |
---|
3851 | , m_inbldFlag ( false ) |
---|
3852 | #endif |
---|
3853 | { |
---|
3854 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
3855 | } |
---|
3856 | |
---|
3857 | #if H_MV_HLS10_PTL_INFER_FIX |
---|
3858 | Bool ProfileTierLevel::getV2ConstraintsPresentFlag() |
---|
3859 | { |
---|
3860 | return ( |
---|
3861 | getProfileIdc( ) == 4 || getProfileCompatibilityFlag( 4 ) || getProfileIdc( ) == 5 || getProfileCompatibilityFlag( 5 ) || |
---|
3862 | getProfileIdc( ) == 6 || getProfileCompatibilityFlag( 6 ) || getProfileIdc( ) == 7 || getProfileCompatibilityFlag( 7 ) |
---|
3863 | ); |
---|
3864 | } |
---|
3865 | |
---|
3866 | Bool ProfileTierLevel::getInbldPresentFlag() |
---|
3867 | { |
---|
3868 | return ( |
---|
3869 | ( getProfileIdc() >= 1 && getProfileIdc() <= 5 ) || getProfileCompatibilityFlag( 1 ) || getProfileCompatibilityFlag( 2 ) || |
---|
3870 | getProfileCompatibilityFlag( 3 ) || getProfileCompatibilityFlag( 4 ) || getProfileCompatibilityFlag( 5 ) |
---|
3871 | ); |
---|
3872 | } |
---|
3873 | |
---|
3874 | Void ProfileTierLevel::copyV2ConstraintFlags(ProfileTierLevel* ptlRef) |
---|
3875 | { |
---|
3876 | setMax12bitConstraintFlag ( ptlRef->getMax12bitConstraintFlag ( ) ); |
---|
3877 | setMax10bitConstraintFlag ( ptlRef->getMax10bitConstraintFlag ( ) ); |
---|
3878 | setMax8bitConstraintFlag ( ptlRef->getMax8bitConstraintFlag ( ) ); |
---|
3879 | setMax422chromaConstraintFlag ( ptlRef->getMax422chromaConstraintFlag ( ) ); |
---|
3880 | setMax420chromaConstraintFlag ( ptlRef->getMax420chromaConstraintFlag ( ) ); |
---|
3881 | setMaxMonochromeConstraintFlag ( ptlRef->getMaxMonochromeConstraintFlag ( ) ); |
---|
3882 | setIntraConstraintFlag ( ptlRef->getIntraConstraintFlag ( ) ); |
---|
3883 | setOnePictureOnlyConstraintFlag ( ptlRef->getOnePictureOnlyConstraintFlag ( ) ); |
---|
3884 | setLowerBitRateConstraintFlag ( ptlRef->getLowerBitRateConstraintFlag ( ) ); |
---|
3885 | } |
---|
3886 | |
---|
3887 | Void ProfileTierLevel::copyProfile(ProfileTierLevel* ptlRef) |
---|
3888 | { |
---|
3889 | setProfileSpace ( ptlRef->getProfileSpace ( ) ); |
---|
3890 | setTierFlag ( ptlRef->getTierFlag ( ) ); |
---|
3891 | setProfileIdc ( ptlRef->getProfileIdc ( ) ); |
---|
3892 | for (Int j = 0; j < 32; j++) |
---|
3893 | { |
---|
3894 | setProfileCompatibilityFlag(j, ptlRef->getProfileCompatibilityFlag ( j ) ); |
---|
3895 | } |
---|
3896 | setProgressiveSourceFlag ( ptlRef->getProgressiveSourceFlag ( ) ); |
---|
3897 | setInterlacedSourceFlag ( ptlRef->getInterlacedSourceFlag ( ) ); |
---|
3898 | setNonPackedConstraintFlag ( ptlRef->getNonPackedConstraintFlag ( ) ); |
---|
3899 | setFrameOnlyConstraintFlag ( ptlRef->getFrameOnlyConstraintFlag ( ) ); |
---|
3900 | copyV2ConstraintFlags ( ptlRef ); |
---|
3901 | } |
---|
3902 | |
---|
3903 | #endif |
---|
3904 | |
---|
3905 | TComPTL::TComPTL() |
---|
3906 | { |
---|
3907 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
3908 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
3909 | } |
---|
3910 | |
---|
3911 | #if H_MV |
---|
3912 | #if !H_MV_HLS10_PTL_INFER_FIX |
---|
3913 | Void TComPTL::copyLevelFrom( TComPTL* source ) |
---|
3914 | { |
---|
3915 | getGeneralPTL()->setLevelIdc( source->getGeneralPTL()->getLevelIdc() ); |
---|
3916 | for( Int subLayer = 0; subLayer < 6; subLayer++ ) |
---|
3917 | { |
---|
3918 | setSubLayerLevelPresentFlag( subLayer, source->getSubLayerLevelPresentFlag( subLayer ) ); |
---|
3919 | getSubLayerPTL( subLayer )->setLevelIdc( source->getSubLayerPTL( subLayer )->getLevelIdc() ); |
---|
3920 | } |
---|
3921 | } |
---|
3922 | #else |
---|
3923 | Void TComPTL::inferGeneralValues(Bool profilePresentFlag, Int k, TComPTL* refPTL) |
---|
3924 | { |
---|
3925 | ProfileTierLevel* refProfileTierLevel = NULL; |
---|
3926 | if ( k > 0 ) |
---|
3927 | { |
---|
3928 | assert( refPTL != NULL); |
---|
3929 | refProfileTierLevel = refPTL->getGeneralPTL(); |
---|
3930 | } |
---|
3931 | |
---|
3932 | ProfileTierLevel* curProfileTierLevel = getGeneralPTL( ); |
---|
3933 | |
---|
3934 | if( !profilePresentFlag ) |
---|
3935 | { |
---|
3936 | assert( k > 0 ); |
---|
3937 | assert( refProfileTierLevel != NULL ); |
---|
3938 | curProfileTierLevel->copyProfile( refProfileTierLevel); |
---|
3939 | } |
---|
3940 | else |
---|
3941 | { |
---|
3942 | if ( !curProfileTierLevel->getV2ConstraintsPresentFlag() ) |
---|
3943 | { |
---|
3944 | curProfileTierLevel->setMax12bitConstraintFlag ( false ); |
---|
3945 | curProfileTierLevel->setMax10bitConstraintFlag ( false ); |
---|
3946 | curProfileTierLevel->setMax8bitConstraintFlag ( false ); |
---|
3947 | curProfileTierLevel->setMax422chromaConstraintFlag ( false ); |
---|
3948 | curProfileTierLevel->setMax420chromaConstraintFlag ( false ); |
---|
3949 | curProfileTierLevel->setMaxMonochromeConstraintFlag ( false ); |
---|
3950 | curProfileTierLevel->setIntraConstraintFlag ( false ); |
---|
3951 | curProfileTierLevel->setOnePictureOnlyConstraintFlag ( false ); |
---|
3952 | curProfileTierLevel->setLowerBitRateConstraintFlag ( false ); |
---|
3953 | } |
---|
3954 | |
---|
3955 | if ( !curProfileTierLevel->getInbldPresentFlag() ) |
---|
3956 | { |
---|
3957 | curProfileTierLevel->setInbldFlag( false ); |
---|
3958 | } |
---|
3959 | } |
---|
3960 | } |
---|
3961 | |
---|
3962 | Void TComPTL::inferSubLayerValues(Int maxNumSubLayersMinus1, Int k, TComPTL* refPTL) |
---|
3963 | { |
---|
3964 | assert( k == 0 || refPTL != NULL ); |
---|
3965 | |
---|
3966 | for (Int i = maxNumSubLayersMinus1; i >= 0; i--) |
---|
3967 | { |
---|
3968 | ProfileTierLevel* refProfileTierLevel; |
---|
3969 | if ( k != 0 ) |
---|
3970 | { |
---|
3971 | refProfileTierLevel = refPTL->getSubLayerPTL( i ); |
---|
3972 | } |
---|
3973 | else |
---|
3974 | { |
---|
3975 | if ( i == maxNumSubLayersMinus1) |
---|
3976 | { |
---|
3977 | refProfileTierLevel = getGeneralPTL(); |
---|
3978 | } |
---|
3979 | else |
---|
3980 | { |
---|
3981 | refProfileTierLevel = getSubLayerPTL( i + 1 ); |
---|
3982 | } |
---|
3983 | } |
---|
3984 | |
---|
3985 | ProfileTierLevel* curProfileTierLevel = getSubLayerPTL( i ); |
---|
3986 | if( !getSubLayerLevelPresentFlag( i ) ) |
---|
3987 | { |
---|
3988 | curProfileTierLevel->setLevelIdc( refProfileTierLevel->getLevelIdc() ); |
---|
3989 | } |
---|
3990 | |
---|
3991 | if( !getSubLayerProfilePresentFlag( i ) ) |
---|
3992 | { |
---|
3993 | curProfileTierLevel->copyProfile( refProfileTierLevel); |
---|
3994 | } |
---|
3995 | else |
---|
3996 | { |
---|
3997 | if ( !curProfileTierLevel->getV2ConstraintsPresentFlag() ) |
---|
3998 | { |
---|
3999 | curProfileTierLevel->copyV2ConstraintFlags( refProfileTierLevel ); |
---|
4000 | } |
---|
4001 | |
---|
4002 | if ( !curProfileTierLevel->getInbldPresentFlag() ) |
---|
4003 | { |
---|
4004 | curProfileTierLevel->setInbldFlag( refProfileTierLevel->getInbldFlag() ); |
---|
4005 | } |
---|
4006 | } |
---|
4007 | } |
---|
4008 | } |
---|
4009 | |
---|
4010 | #endif |
---|
4011 | #endif |
---|
4012 | //! \} |
---|
4013 | |
---|
4014 | #if H_MV |
---|
4015 | TComVPSVUI::TComVPSVUI() |
---|
4016 | { |
---|
4017 | m_crossLayerIrapAlignedFlag = true; |
---|
4018 | m_allLayersIdrAlignedFlag = false; |
---|
4019 | m_bitRatePresentVpsFlag = false; |
---|
4020 | m_picRatePresentVpsFlag = false; |
---|
4021 | for ( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++) |
---|
4022 | { |
---|
4023 | for ( Int j = 0; j < MAX_TLAYER; j++) |
---|
4024 | { |
---|
4025 | m_bitRatePresentFlag [i][j] = false; |
---|
4026 | m_picRatePresentFlag [i][j] = false; |
---|
4027 | m_avgBitRate [i][j] = -1; |
---|
4028 | m_maxBitRate [i][j] = -1; |
---|
4029 | m_constantPicRateIdc [i][j] = -1; |
---|
4030 | m_avgPicRate [i][j] = -1; |
---|
4031 | } |
---|
4032 | } |
---|
4033 | |
---|
4034 | m_ilpRestrictedRefLayersFlag = false; |
---|
4035 | |
---|
4036 | for ( Int i = 0; i < MAX_NUM_LAYERS; i++) |
---|
4037 | { |
---|
4038 | for ( Int j = 0; j < MAX_NUM_LAYERS; j++) |
---|
4039 | { |
---|
4040 | m_tileBoundariesAlignedFlag [i][j] = false; |
---|
4041 | m_minSpatialSegmentOffsetPlus1[i][j] = 0; |
---|
4042 | m_ctuBasedOffsetEnabledFlag [i][j] = false; |
---|
4043 | m_minHorizontalCtuOffsetPlus1 [i][j] = -1; |
---|
4044 | } |
---|
4045 | m_baseLayerParameterSetCompatibilityFlag[i] = false; |
---|
4046 | } |
---|
4047 | for ( Int i = 0; i < MAX_NUM_VIDEO_SIGNAL_INFO; i++ ) |
---|
4048 | { |
---|
4049 | m_videoSignalInfo [i] = NULL; |
---|
4050 | } |
---|
4051 | |
---|
4052 | m_vpsVuiBspHrdPresentFlag = false; |
---|
4053 | #if H_MV_HLS10_VPS_VUI_BSP |
---|
4054 | m_vpsVuiBspHrdParameters = NULL; |
---|
4055 | #else |
---|
4056 | m_vpsVuiBspHrdParameters = new TComVpsVuiBspHrdParameters(); |
---|
4057 | #endif |
---|
4058 | } |
---|
4059 | |
---|
4060 | TComVPSVUI::~TComVPSVUI() |
---|
4061 | { |
---|
4062 | for ( Int i = 0; i < MAX_NUM_VIDEO_SIGNAL_INFO; i++ ) |
---|
4063 | { |
---|
4064 | if (m_videoSignalInfo[ i ] != NULL ) delete m_videoSignalInfo[ i ]; |
---|
4065 | m_videoSignalInfo [ i ] = NULL; |
---|
4066 | } |
---|
4067 | |
---|
4068 | if ( m_vpsVuiBspHrdParameters ) delete m_vpsVuiBspHrdParameters; |
---|
4069 | m_vpsVuiBspHrdParameters = NULL; |
---|
4070 | } |
---|
4071 | |
---|
4072 | Void TComVPSVUI::inferVpsVui( Bool encoderFlag ) |
---|
4073 | { |
---|
4074 | // inference of syntax elements that differ from default inference (as done in constructor), when VPS VUI is not present |
---|
4075 | if (!encoderFlag ) |
---|
4076 | { |
---|
4077 | setCrossLayerIrapAlignedFlag( false ); |
---|
4078 | } |
---|
4079 | else |
---|
4080 | { |
---|
4081 | assert( !getCrossLayerIrapAlignedFlag() ); |
---|
4082 | } |
---|
4083 | } |
---|
4084 | |
---|
4085 | Void TComRepFormat::inferChromaAndBitDepth( TComRepFormat* prevRepFormat, Bool encoderFlag ) |
---|
4086 | { |
---|
4087 | if ( !encoderFlag ) |
---|
4088 | { |
---|
4089 | setChromaAndBitDepthVpsPresentFlag( prevRepFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
4090 | setSeparateColourPlaneVpsFlag ( prevRepFormat->getSeparateColourPlaneVpsFlag () ); |
---|
4091 | setBitDepthVpsLumaMinus8 ( prevRepFormat->getBitDepthVpsLumaMinus8 () ); |
---|
4092 | setBitDepthVpsChromaMinus8 ( prevRepFormat->getBitDepthVpsChromaMinus8 () ); |
---|
4093 | } |
---|
4094 | else |
---|
4095 | { |
---|
4096 | assert( getChromaAndBitDepthVpsPresentFlag() == prevRepFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
4097 | assert( getSeparateColourPlaneVpsFlag () == prevRepFormat->getSeparateColourPlaneVpsFlag () ); |
---|
4098 | assert( getBitDepthVpsLumaMinus8 () == prevRepFormat->getBitDepthVpsLumaMinus8 () ); |
---|
4099 | assert( getBitDepthVpsChromaMinus8 () == prevRepFormat->getBitDepthVpsChromaMinus8 () ); |
---|
4100 | } |
---|
4101 | } |
---|
4102 | |
---|
4103 | #if !H_MV_HLS10_VPS_VUI_BSP |
---|
4104 | Void TComVpsVuiBspHrdParameters::checkLayerInBspFlag( TComVPS* vps, Int h ) |
---|
4105 | { |
---|
4106 | // It is a requirement of bitstream conformance that bitstream partition with index j shall not include |
---|
4107 | // direct or indirect reference layers of any layers in bitstream partition i for any values of i and j |
---|
4108 | // in the range of 0 to num_bitstream_partitions[ h ] ?1, inclusive, such that i is less than j. |
---|
4109 | |
---|
4110 | for ( Int partJ = 0; partJ < getNumBitstreamPartitions( h ); partJ++ ) |
---|
4111 | { |
---|
4112 | for ( Int partI = 0; partI < partJ; partI++ ) |
---|
4113 | { |
---|
4114 | for ( Int layerJ = 0; layerJ < vps->getMaxLayersMinus1(); layerJ++ ) |
---|
4115 | { |
---|
4116 | if ( m_layerInBspFlag[ h ][partJ][layerJ ] ) |
---|
4117 | { |
---|
4118 | for ( Int layerI = 0; layerI < vps->getMaxLayersMinus1(); layerI++ ) |
---|
4119 | { |
---|
4120 | if ( m_layerInBspFlag[ h ][partI][layerI] ) |
---|
4121 | { |
---|
4122 | assert( !vps->getInDirectDependencyFlag( layerI, layerJ ) ); |
---|
4123 | } |
---|
4124 | } |
---|
4125 | } |
---|
4126 | } |
---|
4127 | } |
---|
4128 | } |
---|
4129 | |
---|
4130 | // --------------- |
---|
4131 | // To be added: |
---|
4132 | // When vps_base_layer_internal_flag is equal to 0 and layer_in_bsp_flag[ h ][ i ][ 0 ] is equal to 1 for any value of h in the |
---|
4133 | // range of 1 to vps_num_layer_sets_minus1, inclusive, and any value of i in the range of 0 to num_bitstream_partitions[ h ] - 1, |
---|
4134 | // inclusive, the value of layer_in_bsp_flag[ h ][ i ][ j ] for at least one value of j in the range of 1 to |
---|
4135 | // NumLayersInIdList[ h ] - 1, inclusive, shall be equal to 1. |
---|
4136 | // --------------- |
---|
4137 | |
---|
4138 | |
---|
4139 | // When num_bitstream_partitions[ h ] is equal to 1 for any value of h in the range 1 to vps_num_layer_set_minus1, inclusive, |
---|
4140 | // the value of layer_in_bsp_flag[ h ][ 0 ][ j ] should be equal to 0 for at least one value of j in the range 0 to |
---|
4141 | // NumLayersInIdList[ h ] ? 1, inclusive. |
---|
4142 | |
---|
4143 | |
---|
4144 | if ( getNumBitstreamPartitions( h ) == 1 ) |
---|
4145 | { |
---|
4146 | Bool atLeastOneZero = false; |
---|
4147 | for ( Int j = 0; j <= vps->getNumLayersInIdList( h ) - 1; j++ ) |
---|
4148 | { |
---|
4149 | atLeastOneZero = atLeastOneZero || !getLayerInBspFlag( h, 0, j ); |
---|
4150 | } |
---|
4151 | assert( atLeastOneZero ); |
---|
4152 | } |
---|
4153 | |
---|
4154 | |
---|
4155 | // For any value of h in the range 1 to vps_num_layer_set_minus1, inclusive, the value of layer_in_bsp_flag[ h ][ i ][ j ] |
---|
4156 | // shall be equal to 1 for at most one value of i in the range of 0 to num_bitstream_partitions[ h ] ? 1, inclusive. |
---|
4157 | |
---|
4158 | for ( Int j = 0; j <= vps->getNumLayersInIdList( h ) - 1; j++ ) |
---|
4159 | { |
---|
4160 | Int numLayerInBsp = 0; |
---|
4161 | for ( Int i = 0; i <= getNumBitstreamPartitions( h ) - 1; i++ ) |
---|
4162 | { |
---|
4163 | numLayerInBsp += ( getLayerInBspFlag( h, i, j ) ? 1 : 0 ); |
---|
4164 | } |
---|
4165 | assert( numLayerInBsp <= 1 ); |
---|
4166 | } |
---|
4167 | |
---|
4168 | } |
---|
4169 | |
---|
4170 | Void TComVpsVuiBspHrdParameters::checkBspCombHrdAndShedIdx( TComVPS* vps, Int h, Int i, Int j ) |
---|
4171 | { |
---|
4172 | // bsp_comb_hrd_idx |
---|
4173 | assert( getBspCombSchedIdx(h, i, j ) >= 0 ); |
---|
4174 | assert( getBspCombSchedIdx(h, i, j ) <= getVpsNumBspHrdParametersMinus1() ); |
---|
4175 | |
---|
4176 | // bsp_comb_sched_idx |
---|
4177 | assert( getBspCombSchedIdx(h, i, j ) >= 0 ); |
---|
4178 | |
---|
4179 | //* This check needs to activated, when HighestTid is available here |
---|
4180 | // assert( getBspCombSchedIdx(h, i, j ) <= vps->getHrdParameters( getBspCombHrdIdx( h, i, j ) )->getCpbCntMinus1( highestTid ) ); |
---|
4181 | } |
---|
4182 | #endif |
---|
4183 | |
---|
4184 | #if H_MV_HLS10_VPS_VUI_BSP |
---|
4185 | |
---|
4186 | TComVpsVuiBspHrdParameters::~TComVpsVuiBspHrdParameters() |
---|
4187 | { |
---|
4188 | delete[] m_cprmsAddPresentFlag; |
---|
4189 | delete[] m_numSubLayerHrdMinus1; |
---|
4190 | delete[] m_hrdParameters; |
---|
4191 | |
---|
4192 | for (Int h = 0; h < m_numOls; h++) |
---|
4193 | { |
---|
4194 | if ( h > 0 ) |
---|
4195 | { |
---|
4196 | for (Int i = 0; i < getNumSignalledPartitioningSchemes(h)+1; i++) |
---|
4197 | { |
---|
4198 | for (Int t = 0; t < m_vps->getMaxSubLayersInLayerSetMinus1( m_vps->olsIdxToLsIdx(h) ) + 1; t++) |
---|
4199 | { |
---|
4200 | for ( Int j = 0; j <= getNumBspSchedulesMinus1(h,i,j);j++ ) |
---|
4201 | { |
---|
4202 | delete[] m_bspHrdIdx [h][i][t][j]; |
---|
4203 | delete[] m_bspSchedIdx[h][i][t][j]; |
---|
4204 | } |
---|
4205 | } |
---|
4206 | delete[] m_numBspSchedulesMinus1[h][i]; |
---|
4207 | } |
---|
4208 | } |
---|
4209 | |
---|
4210 | for (Int j = 0; j <= getNumSignalledPartitioningSchemes(h ) + 1; j++ ) |
---|
4211 | { |
---|
4212 | for (Int k = 0; k <= getNumPartitionsInSchemeMinus1(h,j); k++ ) |
---|
4213 | { |
---|
4214 | delete[] m_layerIncludedInPartitionFlag[h][j][k]; |
---|
4215 | } |
---|
4216 | } |
---|
4217 | delete[] m_numPartitionsInSchemeMinus1[h]; |
---|
4218 | } |
---|
4219 | delete[] m_numSignalledPartitioningSchemes; |
---|
4220 | } |
---|
4221 | |
---|
4222 | |
---|
4223 | Int TComVpsVuiBspHrdParameters::getBspHrdIdxLen(TComVPS* vps) |
---|
4224 | { |
---|
4225 | return gCeilLog2( vps->getNumHrdParameters() + getVpsNumAddHrdParams() ); |
---|
4226 | } |
---|
4227 | |
---|
4228 | Void TComVpsVuiBspHrdParameters::createAfterVpsNumAddHrdParams( TComVPS* vps ) |
---|
4229 | { |
---|
4230 | assert( vps == NULL ); |
---|
4231 | m_vps = vps; |
---|
4232 | m_offsetHrdParamIdx = vps->getNumHrdParameters(); |
---|
4233 | m_numHrdParam = vps->getNumHrdParameters() + getVpsNumAddHrdParams() - m_offsetHrdParamIdx; |
---|
4234 | m_numOls = vps->getNumOutputLayerSets(); |
---|
4235 | |
---|
4236 | m_cprmsAddPresentFlag = new Bool [ m_numHrdParam ]; |
---|
4237 | m_numSubLayerHrdMinus1 = new Int [ m_numHrdParam ]; |
---|
4238 | m_hrdParameters = new TComHRD [ m_numHrdParam ]; |
---|
4239 | |
---|
4240 | m_numSignalledPartitioningSchemes = new Int [ m_numOls ]; |
---|
4241 | m_numPartitionsInSchemeMinus1 = new Int* [ m_numOls ]; |
---|
4242 | m_numBspSchedulesMinus1 = new Int** [ m_numOls ]; |
---|
4243 | m_bspHrdIdx = new Int****[ m_numOls ]; |
---|
4244 | m_bspSchedIdx = new Int****[ m_numOls ]; |
---|
4245 | } |
---|
4246 | |
---|
4247 | Void TComVpsVuiBspHrdParameters::createAfterNumSignalledPartitioningSchemes( Int h ) |
---|
4248 | { |
---|
4249 | m_numPartitionsInSchemeMinus1 [h] = new Int [ getNumSignalledPartitioningSchemes(h) ]; |
---|
4250 | m_layerIncludedInPartitionFlag[h] = new Bool** [ getNumSignalledPartitioningSchemes(h) ]; |
---|
4251 | |
---|
4252 | m_numBspSchedulesMinus1[h] = new Int* [ getNumSignalledPartitioningSchemes(h) + 1 ]; |
---|
4253 | for (Int i = 0; i < getNumSignalledPartitioningSchemes(h) + 1; i++) |
---|
4254 | { |
---|
4255 | Int tMax = m_vps->getMaxSubLayersInLayerSetMinus1( m_vps->olsIdxToLsIdx(h) ) + 1; |
---|
4256 | m_numBspSchedulesMinus1[h][i] = new Int [ tMax ]; |
---|
4257 | m_bspHrdIdx [h][i] = new Int**[ tMax ]; |
---|
4258 | m_bspSchedIdx [h][i] = new Int**[ tMax ]; |
---|
4259 | } |
---|
4260 | } |
---|
4261 | |
---|
4262 | Void TComVpsVuiBspHrdParameters::createAfterNumPartitionsInSchemeMinus1( Int h, Int j ) |
---|
4263 | { |
---|
4264 | m_layerIncludedInPartitionFlag[h][j] = new Bool*[ getNumPartitionsInSchemeMinus1(h,j)]; |
---|
4265 | for( Int k = 0; k < getNumPartitionsInSchemeMinus1(h,j); k++ ) |
---|
4266 | { |
---|
4267 | m_layerIncludedInPartitionFlag[h][j][k] = new Bool[ m_vps->getNumLayersInIdList( m_vps->olsIdxToLsIdx(h))]; |
---|
4268 | } |
---|
4269 | } |
---|
4270 | |
---|
4271 | Void TComVpsVuiBspHrdParameters::createAfterNumBspSchedulesMinus1( Int h, Int i, Int t ) |
---|
4272 | { |
---|
4273 | m_bspSchedIdx[h][i][t] = new Int* [ getNumBspSchedulesMinus1( h, i, t ) + 1 ]; |
---|
4274 | m_bspHrdIdx [h][i][t] = new Int* [ getNumBspSchedulesMinus1( h, i, t ) + 1 ]; |
---|
4275 | for( Int j = 0; j < getNumBspSchedulesMinus1( h, i, t ) + 1; j++ ) |
---|
4276 | { |
---|
4277 | m_bspSchedIdx[h][i][t][j] = new Int[ getNumPartitionsInSchemeMinus1( h, i ) ]; |
---|
4278 | m_bspHrdIdx [h][i][t][j] = new Int[ getNumPartitionsInSchemeMinus1( h, i ) ]; |
---|
4279 | } |
---|
4280 | } |
---|
4281 | |
---|
4282 | #endif |
---|
4283 | |
---|
4284 | Void TComVUI::inferVideoSignalInfo( TComVPS* vps, Int layerIdCurr ) |
---|
4285 | { |
---|
4286 | if ( layerIdCurr == 0 || !vps->getVpsVuiPresentFlag() ) |
---|
4287 | { |
---|
4288 | return; |
---|
4289 | } |
---|
4290 | |
---|
4291 | TComVPSVUI* vpsVUI = vps->getVPSVUI(); |
---|
4292 | assert( vpsVUI != NULL ); |
---|
4293 | |
---|
4294 | TComVideoSignalInfo* videoSignalInfo = vpsVUI->getVideoSignalInfo( vpsVUI->getVpsVideoSignalInfoIdx( vps->getLayerIdInVps( layerIdCurr ) ) ); |
---|
4295 | assert( videoSignalInfo != NULL ); |
---|
4296 | |
---|
4297 | setVideoFormat ( videoSignalInfo->getVideoVpsFormat () ); |
---|
4298 | setVideoFullRangeFlag ( videoSignalInfo->getVideoFullRangeVpsFlag () ); |
---|
4299 | setColourPrimaries ( videoSignalInfo->getColourPrimariesVps () ); |
---|
4300 | setTransferCharacteristics( videoSignalInfo->getTransferCharacteristicsVps() ); |
---|
4301 | setMatrixCoefficients ( videoSignalInfo->getMatrixCoeffsVps () ); |
---|
4302 | } |
---|
4303 | |
---|
4304 | TComDpbSize::TComDpbSize() |
---|
4305 | { |
---|
4306 | for (Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++ ) |
---|
4307 | { |
---|
4308 | m_subLayerFlagInfoPresentFlag[i] = false; |
---|
4309 | |
---|
4310 | for (Int j = 0; j < MAX_TLAYER; j++ ) |
---|
4311 | { |
---|
4312 | m_subLayerDpbInfoPresentFlag [i][j] = ( j == 0) ; |
---|
4313 | m_maxVpsNumReorderPics [i][j] = 0; |
---|
4314 | m_maxVpsLatencyIncreasePlus1 [i][j] = 0; |
---|
4315 | |
---|
4316 | for (Int k = 0; k < MAX_NUM_LAYER_IDS; k++ ) |
---|
4317 | { |
---|
4318 | #if H_MV_HLS10_ADD_LAYERSETS |
---|
4319 | m_maxVpsDecPicBufferingMinus1[i][k][j] = MIN_INT; |
---|
4320 | #else |
---|
4321 | m_maxVpsDecPicBufferingMinus1[i][k][j] = 0; |
---|
4322 | #endif |
---|
4323 | } |
---|
4324 | } |
---|
4325 | } |
---|
4326 | } |
---|
4327 | |
---|
4328 | Void Window::scaleOffsets( Int scal ) |
---|
4329 | { |
---|
4330 | if (! m_scaledFlag ) |
---|
4331 | { |
---|
4332 | m_scaledFlag = true; |
---|
4333 | m_winLeftOffset *= scal; |
---|
4334 | m_winRightOffset *= scal; |
---|
4335 | m_winTopOffset *= scal; |
---|
4336 | m_winBottomOffset *= scal; |
---|
4337 | } |
---|
4338 | } |
---|
4339 | #endif |
---|
4340 | |
---|