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