1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TComSlice.cpp |
---|
35 | \brief slice header and SPS class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "CommonDef.h" |
---|
39 | #include "TComSlice.h" |
---|
40 | #include "TComPic.h" |
---|
41 | #include "TLibEncoder/TEncSbac.h" |
---|
42 | #include "TLibDecoder/TDecSbac.h" |
---|
43 | |
---|
44 | |
---|
45 | //! \ingroup TLibCommon |
---|
46 | //! \{ |
---|
47 | |
---|
48 | #if SVC_EXTENSION |
---|
49 | #include <numeric> |
---|
50 | ParameterSetMap<TComVPS> ParameterSetManager::m_vpsMap(MAX_NUM_VPS); |
---|
51 | ParameterSetMap<TComSPS> ParameterSetManager::m_spsMap(MAX_NUM_SPS); |
---|
52 | ParameterSetMap<TComPPS> ParameterSetManager::m_ppsMap(MAX_NUM_PPS); |
---|
53 | TComVPS ParameterSetManager::m_activeVPS; |
---|
54 | #endif |
---|
55 | |
---|
56 | TComSlice::TComSlice() |
---|
57 | : m_iPPSId ( -1 ) |
---|
58 | , m_PicOutputFlag ( true ) |
---|
59 | , m_iPOC ( 0 ) |
---|
60 | , m_iLastIDR ( 0 ) |
---|
61 | , m_iAssociatedIRAP ( 0 ) |
---|
62 | , m_iAssociatedIRAPType ( NAL_UNIT_INVALID ) |
---|
63 | , m_pcRPS ( 0 ) |
---|
64 | , m_LocalRPS ( ) |
---|
65 | , m_iBDidx ( 0 ) |
---|
66 | , m_RefPicListModification ( ) |
---|
67 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
68 | , m_eSliceType ( I_SLICE ) |
---|
69 | , m_iSliceQp ( 0 ) |
---|
70 | , m_dependentSliceSegmentFlag ( false ) |
---|
71 | #if ADAPTIVE_QP_SELECTION |
---|
72 | , m_iSliceQpBase ( 0 ) |
---|
73 | #endif |
---|
74 | , m_ChromaQpAdjEnabled ( false ) |
---|
75 | , m_deblockingFilterDisable ( false ) |
---|
76 | , m_deblockingFilterOverrideFlag ( false ) |
---|
77 | , m_deblockingFilterBetaOffsetDiv2( 0 ) |
---|
78 | , m_deblockingFilterTcOffsetDiv2 ( 0 ) |
---|
79 | , m_bCheckLDC ( false ) |
---|
80 | , m_iSliceQpDelta ( 0 ) |
---|
81 | , m_iDepth ( 0 ) |
---|
82 | , m_bRefenced ( false ) |
---|
83 | , m_pcVPS ( NULL ) |
---|
84 | , m_pcSPS ( NULL ) |
---|
85 | , m_pcPPS ( NULL ) |
---|
86 | , m_pcPic ( NULL ) |
---|
87 | #if ADAPTIVE_QP_SELECTION |
---|
88 | , m_pcTrQuant ( NULL ) |
---|
89 | #endif |
---|
90 | , m_colFromL0Flag ( true ) |
---|
91 | , m_noOutputPriorPicsFlag ( false ) |
---|
92 | , m_noRaslOutputFlag ( false ) |
---|
93 | , m_handleCraAsBlaFlag ( false ) |
---|
94 | , m_colRefIdx ( 0 ) |
---|
95 | , m_maxNumMergeCand ( 0 ) |
---|
96 | , m_uiTLayer ( 0 ) |
---|
97 | , m_bTLayerSwitchingFlag ( false ) |
---|
98 | , m_sliceMode ( NO_SLICES ) |
---|
99 | , m_sliceArgument ( 0 ) |
---|
100 | , m_sliceCurStartCtuTsAddr ( 0 ) |
---|
101 | , m_sliceCurEndCtuTsAddr ( 0 ) |
---|
102 | , m_sliceIdx ( 0 ) |
---|
103 | , m_sliceSegmentMode ( NO_SLICES ) |
---|
104 | , m_sliceSegmentArgument ( 0 ) |
---|
105 | , m_sliceSegmentCurStartCtuTsAddr ( 0 ) |
---|
106 | , m_sliceSegmentCurEndCtuTsAddr ( 0 ) |
---|
107 | , m_nextSlice ( false ) |
---|
108 | , m_nextSliceSegment ( false ) |
---|
109 | , m_sliceBits ( 0 ) |
---|
110 | , m_sliceSegmentBits ( 0 ) |
---|
111 | , m_bFinalized ( false ) |
---|
112 | , m_bTestWeightPred ( false ) |
---|
113 | , m_bTestWeightBiPred ( false ) |
---|
114 | , m_substreamSizes ( ) |
---|
115 | , m_cabacInitFlag ( false ) |
---|
116 | , m_bLMvdL1Zero ( false ) |
---|
117 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
118 | , m_LFCrossSliceBoundaryFlag ( false ) |
---|
119 | , m_enableTMVPFlag ( true ) |
---|
120 | , m_encCABACTableIdx (I_SLICE) |
---|
121 | #if SVC_EXTENSION |
---|
122 | , m_firstSliceInPic ( false ) |
---|
123 | , m_availableForTMVPRefFlag ( true ) |
---|
124 | , m_layerId ( 0 ) |
---|
125 | , m_bMFMEnabledFlag ( false ) |
---|
126 | , m_bDiscardableFlag ( false ) |
---|
127 | , m_bCrossLayerBLAFlag ( false ) |
---|
128 | , m_pocResetIdc ( 0 ) |
---|
129 | , m_pocResetPeriodId ( 0 ) |
---|
130 | , m_fullPocResetFlag ( false ) |
---|
131 | , m_pocLsbVal ( 0 ) |
---|
132 | , m_pocMsbVal ( 0 ) |
---|
133 | , m_pocMsbValRequiredFlag ( false ) |
---|
134 | , m_pocMsbValPresentFlag ( false ) |
---|
135 | , m_pocMsbValNeeded ( false ) |
---|
136 | , m_picOrderCntLsb (0) |
---|
137 | #endif //SVC_EXTENSION |
---|
138 | { |
---|
139 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
140 | { |
---|
141 | m_aiNumRefIdx[i] = 0; |
---|
142 | } |
---|
143 | |
---|
144 | #if SVC_EXTENSION |
---|
145 | memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) ); |
---|
146 | m_activeNumILRRefIdx = 0; |
---|
147 | m_interLayerPredEnabledFlag = 0; |
---|
148 | ::memset( m_interLayerPredLayerIdc, 0, sizeof(m_interLayerPredLayerIdc) ); |
---|
149 | #endif //SVC_EXTENSION |
---|
150 | |
---|
151 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
152 | { |
---|
153 | m_lambdas [component] = 0.0; |
---|
154 | m_iSliceChromaQpDelta[component] = 0; |
---|
155 | } |
---|
156 | |
---|
157 | initEqualRef(); |
---|
158 | |
---|
159 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
160 | { |
---|
161 | m_list1IdxToList0Idx[idx] = -1; |
---|
162 | } |
---|
163 | |
---|
164 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
165 | { |
---|
166 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
167 | { |
---|
168 | m_apcRefPicList [i][iNumCount] = NULL; |
---|
169 | m_aiRefPOCList [i][iNumCount] = 0; |
---|
170 | } |
---|
171 | } |
---|
172 | |
---|
173 | resetWpScaling(); |
---|
174 | initWpAcDcParam(); |
---|
175 | |
---|
176 | for(Int ch=0; ch < MAX_NUM_CHANNEL_TYPE; ch++) |
---|
177 | { |
---|
178 | m_saoEnabledFlag[ch] = false; |
---|
179 | } |
---|
180 | } |
---|
181 | |
---|
182 | TComSlice::~TComSlice() |
---|
183 | { |
---|
184 | } |
---|
185 | |
---|
186 | |
---|
187 | #if SVC_EXTENSION |
---|
188 | Void TComSlice::initSlice( UInt layerId ) |
---|
189 | #else |
---|
190 | Void TComSlice::initSlice() |
---|
191 | #endif |
---|
192 | { |
---|
193 | #if SVC_EXTENSION |
---|
194 | m_layerId = layerId; |
---|
195 | m_activeNumILRRefIdx = 0; |
---|
196 | m_interLayerPredEnabledFlag = 0; |
---|
197 | m_picOrderCntLsb = 0; |
---|
198 | m_pocResetIdc = 0; |
---|
199 | m_pocResetPeriodId = 0; |
---|
200 | m_fullPocResetFlag = false; |
---|
201 | m_pocLsbVal = 0; |
---|
202 | m_pocMsbVal = 0; |
---|
203 | m_pocMsbValRequiredFlag = false; |
---|
204 | m_pocMsbValPresentFlag = false; |
---|
205 | m_pocMsbValNeeded = false; |
---|
206 | m_pocResetDeltaPoc = 0; |
---|
207 | #endif |
---|
208 | |
---|
209 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
210 | { |
---|
211 | m_aiNumRefIdx[i] = 0; |
---|
212 | } |
---|
213 | m_colFromL0Flag = true; |
---|
214 | |
---|
215 | m_colRefIdx = 0; |
---|
216 | initEqualRef(); |
---|
217 | |
---|
218 | m_bCheckLDC = false; |
---|
219 | |
---|
220 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
221 | { |
---|
222 | m_iSliceChromaQpDelta[component] = 0; |
---|
223 | } |
---|
224 | |
---|
225 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
226 | |
---|
227 | m_bFinalized=false; |
---|
228 | |
---|
229 | m_substreamSizes.clear(); |
---|
230 | m_cabacInitFlag = false; |
---|
231 | m_enableTMVPFlag = true; |
---|
232 | } |
---|
233 | |
---|
234 | Bool TComSlice::getRapPicFlag() const |
---|
235 | { |
---|
236 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
237 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
238 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
239 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
240 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
241 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
242 | } |
---|
243 | |
---|
244 | |
---|
245 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
246 | { |
---|
247 | TComPic* pcPicExtract; |
---|
248 | TComPic* pcPicInsert; |
---|
249 | |
---|
250 | TComList<TComPic*>::iterator iterPicExtract; |
---|
251 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
252 | TComList<TComPic*>::iterator iterPicInsert; |
---|
253 | |
---|
254 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
255 | { |
---|
256 | iterPicExtract = rcListPic.begin(); |
---|
257 | for (Int j = 0; j < i; j++) |
---|
258 | { |
---|
259 | iterPicExtract++; |
---|
260 | } |
---|
261 | pcPicExtract = *(iterPicExtract); |
---|
262 | pcPicExtract->setCurrSliceIdx(0); |
---|
263 | |
---|
264 | iterPicInsert = rcListPic.begin(); |
---|
265 | while (iterPicInsert != iterPicExtract) |
---|
266 | { |
---|
267 | pcPicInsert = *(iterPicInsert); |
---|
268 | pcPicInsert->setCurrSliceIdx(0); |
---|
269 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
270 | { |
---|
271 | break; |
---|
272 | } |
---|
273 | |
---|
274 | iterPicInsert++; |
---|
275 | } |
---|
276 | |
---|
277 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
278 | |
---|
279 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
280 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
281 | rcListPic.erase (iterPicExtract); |
---|
282 | } |
---|
283 | } |
---|
284 | |
---|
285 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, Int poc) |
---|
286 | { |
---|
287 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
288 | TComPic* pcPic = *(iterPic); |
---|
289 | while ( iterPic != rcListPic.end() ) |
---|
290 | { |
---|
291 | #if SVC_EXTENSION |
---|
292 | if( pcPic->getPOC() == poc && pcPic->getSlice(0)->isReferenced() ) |
---|
293 | #else |
---|
294 | if(pcPic->getPOC() == poc) |
---|
295 | #endif |
---|
296 | { |
---|
297 | break; |
---|
298 | } |
---|
299 | iterPic++; |
---|
300 | #if SVC_EXTENSION |
---|
301 | // return NULL, if picture with requested POC is not in the list, otherwise iterator goes outside of the list |
---|
302 | if( iterPic == rcListPic.end() ) |
---|
303 | { |
---|
304 | return NULL; |
---|
305 | } |
---|
306 | #endif |
---|
307 | pcPic = *(iterPic); |
---|
308 | } |
---|
309 | #if SVC_EXTENSION |
---|
310 | assert( pcPic->getSlice(0)->isReferenced() ); |
---|
311 | #endif |
---|
312 | return pcPic; |
---|
313 | } |
---|
314 | |
---|
315 | |
---|
316 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
317 | { |
---|
318 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
319 | TComPic* pcPic = *(iterPic); |
---|
320 | TComPic* pcStPic = pcPic; |
---|
321 | |
---|
322 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
323 | if (!pocHasMsb) |
---|
324 | { |
---|
325 | poc = poc & (pocCycle - 1); |
---|
326 | } |
---|
327 | |
---|
328 | while ( iterPic != rcListPic.end() ) |
---|
329 | { |
---|
330 | pcPic = *(iterPic); |
---|
331 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
332 | { |
---|
333 | Int picPoc = pcPic->getPOC(); |
---|
334 | if (!pocHasMsb) |
---|
335 | { |
---|
336 | picPoc = picPoc & (pocCycle - 1); |
---|
337 | } |
---|
338 | |
---|
339 | if (poc == picPoc) |
---|
340 | { |
---|
341 | if(pcPic->getIsLongTerm()) |
---|
342 | { |
---|
343 | return pcPic; |
---|
344 | } |
---|
345 | else |
---|
346 | { |
---|
347 | pcStPic = pcPic; |
---|
348 | } |
---|
349 | break; |
---|
350 | } |
---|
351 | } |
---|
352 | |
---|
353 | iterPic++; |
---|
354 | } |
---|
355 | |
---|
356 | return pcStPic; |
---|
357 | } |
---|
358 | |
---|
359 | Void TComSlice::setRefPOCList () |
---|
360 | { |
---|
361 | for (Int iDir = 0; iDir < NUM_REF_PIC_LIST_01; iDir++) |
---|
362 | { |
---|
363 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
364 | { |
---|
365 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
366 | } |
---|
367 | } |
---|
368 | |
---|
369 | } |
---|
370 | |
---|
371 | Void TComSlice::setList1IdxToList0Idx() |
---|
372 | { |
---|
373 | Int idxL0, idxL1; |
---|
374 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
375 | { |
---|
376 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
377 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
378 | { |
---|
379 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
380 | { |
---|
381 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
382 | break; |
---|
383 | } |
---|
384 | } |
---|
385 | } |
---|
386 | } |
---|
387 | |
---|
388 | #if SVC_EXTENSION |
---|
389 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr, TComPic** ilpPic) |
---|
390 | #else |
---|
391 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) |
---|
392 | #endif |
---|
393 | { |
---|
394 | if (!checkNumPocTotalCurr) |
---|
395 | { |
---|
396 | if (m_eSliceType == I_SLICE) |
---|
397 | { |
---|
398 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
399 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
400 | |
---|
401 | return; |
---|
402 | } |
---|
403 | |
---|
404 | m_aiNumRefIdx[REF_PIC_LIST_0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
405 | m_aiNumRefIdx[REF_PIC_LIST_1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
406 | } |
---|
407 | |
---|
408 | TComPic* pcRefPic= NULL; |
---|
409 | static const UInt MAX_NUM_NEGATIVE_PICTURES=16; |
---|
410 | TComPic* RefPicSetStCurr0[MAX_NUM_NEGATIVE_PICTURES]; |
---|
411 | TComPic* RefPicSetStCurr1[MAX_NUM_NEGATIVE_PICTURES]; |
---|
412 | TComPic* RefPicSetLtCurr[MAX_NUM_NEGATIVE_PICTURES]; |
---|
413 | UInt NumPicStCurr0 = 0; |
---|
414 | UInt NumPicStCurr1 = 0; |
---|
415 | UInt NumPicLtCurr = 0; |
---|
416 | Int i; |
---|
417 | |
---|
418 | #if SVC_EXTENSION |
---|
419 | if( m_layerId == 0 || ( m_layerId > 0 && ( m_activeNumILRRefIdx == 0 || !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ) ) ) |
---|
420 | { |
---|
421 | #endif |
---|
422 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
423 | { |
---|
424 | if(m_pcRPS->getUsed(i)) |
---|
425 | { |
---|
426 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
427 | pcRefPic->setIsLongTerm(0); |
---|
428 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
429 | RefPicSetStCurr0[NumPicStCurr0] = pcRefPic; |
---|
430 | NumPicStCurr0++; |
---|
431 | pcRefPic->setCheckLTMSBPresent(false); |
---|
432 | } |
---|
433 | } |
---|
434 | |
---|
435 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
436 | { |
---|
437 | if(m_pcRPS->getUsed(i)) |
---|
438 | { |
---|
439 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
440 | pcRefPic->setIsLongTerm(0); |
---|
441 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
442 | RefPicSetStCurr1[NumPicStCurr1] = pcRefPic; |
---|
443 | NumPicStCurr1++; |
---|
444 | pcRefPic->setCheckLTMSBPresent(false); |
---|
445 | } |
---|
446 | } |
---|
447 | |
---|
448 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
449 | { |
---|
450 | if(m_pcRPS->getUsed(i)) |
---|
451 | { |
---|
452 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
453 | pcRefPic->setIsLongTerm(1); |
---|
454 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
455 | RefPicSetLtCurr[NumPicLtCurr] = pcRefPic; |
---|
456 | NumPicLtCurr++; |
---|
457 | } |
---|
458 | if(pcRefPic==NULL) |
---|
459 | { |
---|
460 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
461 | } |
---|
462 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
463 | } |
---|
464 | #if SVC_EXTENSION |
---|
465 | } |
---|
466 | #endif |
---|
467 | |
---|
468 | // ref_pic_list_init |
---|
469 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
470 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
471 | #if SVC_EXTENSION |
---|
472 | Int numInterLayerRPSPics = 0; |
---|
473 | if( m_layerId > 0 && m_activeNumILRRefIdx > 0 ) |
---|
474 | { |
---|
475 | for( i=0; i < m_pcVPS->getNumDirectRefLayers( m_layerId ); i++ ) |
---|
476 | { |
---|
477 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[i]->getSlice(0)->getLayerIdx(), getLayerIdx()); |
---|
478 | |
---|
479 | if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<= maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag() ) ) |
---|
480 | { |
---|
481 | numInterLayerRPSPics++; |
---|
482 | |
---|
483 | assert( ilpPic[i]->getSlice(0)->getDiscardableFlag() == 0 ); // Inter-layer RPS shall not contain picture with discardable_flag = 1. |
---|
484 | } |
---|
485 | } |
---|
486 | if (numInterLayerRPSPics < m_activeNumILRRefIdx) |
---|
487 | { |
---|
488 | m_activeNumILRRefIdx = numInterLayerRPSPics; |
---|
489 | } |
---|
490 | |
---|
491 | // max one resampling direct layer |
---|
492 | if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) ) |
---|
493 | { |
---|
494 | Int numResampler = 0; |
---|
495 | |
---|
496 | // motion resampling constraint |
---|
497 | Int numMotionResamplers = 0; |
---|
498 | Int refResamplingLayer[MAX_LAYERS]; |
---|
499 | memset( refResamplingLayer, 0, sizeof( refResamplingLayer ) ); |
---|
500 | |
---|
501 | for( i=0; i < m_activeNumILRRefIdx; i++ ) |
---|
502 | { |
---|
503 | UInt refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
504 | UInt refLayerId = m_pcVPS->getRefLayerId( m_layerId, refLayerIdc ); |
---|
505 | |
---|
506 | const Window &scalEL = getPPS()->getScaledRefLayerWindowForLayer(refLayerId); |
---|
507 | |
---|
508 | Int scalingOffset = ((scalEL.getWindowLeftOffset() == 0 ) && |
---|
509 | (scalEL.getWindowRightOffset() == 0 ) && |
---|
510 | (scalEL.getWindowTopOffset() == 0 ) && |
---|
511 | (scalEL.getWindowBottomOffset() == 0 ) |
---|
512 | ); |
---|
513 | |
---|
514 | Bool sameBitDepths = ( g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId] ) && ( g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId] ); |
---|
515 | |
---|
516 | // motion resampling constraint |
---|
517 | // Allow maximum of one motion resampling process for direct reference layers, and use motion inter-layer prediction from the same layer as texture inter-layer prediction |
---|
518 | if( !( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || !scalingOffset || !sameBitDepths |
---|
519 | #if CGS_3D_ASYMLUT |
---|
520 | || getPPS()->getCGSFlag() |
---|
521 | #endif |
---|
522 | ) // ratio 1x |
---|
523 | { |
---|
524 | UInt predType = m_pcVPS->getDirectDependencyType( m_layerId, refLayerId ) + 1; |
---|
525 | |
---|
526 | if( predType & 0x1 ) |
---|
527 | { |
---|
528 | numResampler++; |
---|
529 | refResamplingLayer[i] = refLayerIdc + 1; |
---|
530 | } |
---|
531 | |
---|
532 | if( predType & 0x2 ) |
---|
533 | { |
---|
534 | numMotionResamplers++; |
---|
535 | refResamplingLayer[i] -= refLayerIdc + 1; |
---|
536 | } |
---|
537 | } |
---|
538 | } |
---|
539 | |
---|
540 | // When both picture sample values and picture motion field resampling processes are invoked for decoding of a particular picture, they shall be applied to the same reference layer picture. |
---|
541 | if( m_activeNumILRRefIdx > 1 && numResampler > 0 ) |
---|
542 | { |
---|
543 | for( i=0; i < m_activeNumILRRefIdx; i++ ) |
---|
544 | { |
---|
545 | assert( refResamplingLayer[i] >= 0 && "Motion and sample inter-layer prediction shall be from the same layer" ); |
---|
546 | } |
---|
547 | } |
---|
548 | |
---|
549 | // Bitstream constraint for SHVC: The picture resampling process as specified in subclause G.8.1.4.1 shall not be invoked more than once for decoding of each particular picture. |
---|
550 | assert(numResampler <= 1); |
---|
551 | assert( numMotionResamplers <= 1 && "Up to 1 motion resampling is allowed" ); |
---|
552 | } |
---|
553 | } |
---|
554 | Int numPicTotalCurr = NumPicStCurr0 + NumPicStCurr1 + NumPicLtCurr + m_activeNumILRRefIdx; |
---|
555 | #else //SVC_EXTENSION |
---|
556 | Int numPicTotalCurr = NumPicStCurr0 + NumPicStCurr1 + NumPicLtCurr; |
---|
557 | #endif //SVC_EXTENSION |
---|
558 | |
---|
559 | if (checkNumPocTotalCurr) |
---|
560 | { |
---|
561 | // 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: |
---|
562 | #if SVC_EXTENSION // inter-layer prediction is allowed for BLA, CRA pictures of nuh_layer_id>0 |
---|
563 | // - If the current picture is a BLA or CRA picture with nuh_layer_id equal to 0, the value of NumPocTotalCurr shall be equal to 0. |
---|
564 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
565 | if (getRapPicFlag() && getLayerId()==0) |
---|
566 | #else |
---|
567 | // - If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
568 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
569 | if (getRapPicFlag()) |
---|
570 | #endif |
---|
571 | { |
---|
572 | assert(numPicTotalCurr == 0); |
---|
573 | } |
---|
574 | |
---|
575 | if (m_eSliceType == I_SLICE) |
---|
576 | { |
---|
577 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
578 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
579 | |
---|
580 | return; |
---|
581 | } |
---|
582 | |
---|
583 | assert(numPicTotalCurr > 0); |
---|
584 | // general tier and level limit: |
---|
585 | assert(numPicTotalCurr <= 8); |
---|
586 | |
---|
587 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
588 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
589 | } |
---|
590 | |
---|
591 | Int cIdx = 0; |
---|
592 | for ( i=0; i<NumPicStCurr0; i++, cIdx++) |
---|
593 | { |
---|
594 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
595 | } |
---|
596 | |
---|
597 | #if SVC_EXTENSION |
---|
598 | // initial reference picture list construction |
---|
599 | if( m_layerId > 0 ) |
---|
600 | { |
---|
601 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPicTotalCurr; cIdx ++, i ++) |
---|
602 | { |
---|
603 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
604 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx()); |
---|
605 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
606 | { |
---|
607 | rpsCurrList0[cIdx] = ilpPic[refLayerIdc]; |
---|
608 | } |
---|
609 | } |
---|
610 | } |
---|
611 | #endif //SVC_EXTENSION |
---|
612 | |
---|
613 | for ( i=0; i<NumPicStCurr1; i++, cIdx++) |
---|
614 | { |
---|
615 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
616 | } |
---|
617 | for ( i=0; i<NumPicLtCurr; i++, cIdx++) |
---|
618 | { |
---|
619 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
620 | } |
---|
621 | assert(cIdx == numPicTotalCurr); |
---|
622 | |
---|
623 | if (m_eSliceType==B_SLICE) |
---|
624 | { |
---|
625 | cIdx = 0; |
---|
626 | for ( i=0; i<NumPicStCurr1; i++, cIdx++) |
---|
627 | { |
---|
628 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
629 | } |
---|
630 | for ( i=0; i<NumPicStCurr0; i++, cIdx++) |
---|
631 | { |
---|
632 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
633 | } |
---|
634 | for ( i=0; i<NumPicLtCurr; i++, cIdx++) |
---|
635 | { |
---|
636 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
637 | } |
---|
638 | |
---|
639 | #if SVC_EXTENSION |
---|
640 | if( m_layerId > 0 ) |
---|
641 | { |
---|
642 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPicTotalCurr; cIdx ++, i ++) |
---|
643 | { |
---|
644 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
645 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1( ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx() ); |
---|
646 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
647 | { |
---|
648 | rpsCurrList1[cIdx] = ilpPic[refLayerIdc]; |
---|
649 | } |
---|
650 | } |
---|
651 | } |
---|
652 | #endif //SVC_EXTENSION |
---|
653 | |
---|
654 | assert(cIdx == numPicTotalCurr); |
---|
655 | } |
---|
656 | |
---|
657 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
658 | |
---|
659 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[REF_PIC_LIST_0]; rIdx ++) |
---|
660 | { |
---|
661 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPicTotalCurr; |
---|
662 | assert(cIdx >= 0 && cIdx < numPicTotalCurr); |
---|
663 | m_apcRefPicList[REF_PIC_LIST_0][rIdx] = rpsCurrList0[ cIdx ]; |
---|
664 | |
---|
665 | #if SVC_EXTENSION |
---|
666 | m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPicStCurr0 && cIdx < NumPicStCurr0 + m_activeNumILRRefIdx ) || ( cIdx >= NumPicStCurr0 + NumPicStCurr1 + m_activeNumILRRefIdx ); |
---|
667 | #else |
---|
668 | m_bIsUsedAsLongTerm[REF_PIC_LIST_0][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 ); |
---|
669 | #endif |
---|
670 | } |
---|
671 | if ( m_eSliceType != B_SLICE ) |
---|
672 | { |
---|
673 | m_aiNumRefIdx[REF_PIC_LIST_1] = 0; |
---|
674 | ::memset( m_apcRefPicList[REF_PIC_LIST_1], 0, sizeof(m_apcRefPicList[REF_PIC_LIST_1])); |
---|
675 | } |
---|
676 | else |
---|
677 | { |
---|
678 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[REF_PIC_LIST_1]; rIdx ++) |
---|
679 | { |
---|
680 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPicTotalCurr; |
---|
681 | assert(cIdx >= 0 && cIdx < numPicTotalCurr); |
---|
682 | m_apcRefPicList[REF_PIC_LIST_1][rIdx] = rpsCurrList1[ cIdx ]; |
---|
683 | m_bIsUsedAsLongTerm[REF_PIC_LIST_1][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 ); |
---|
684 | } |
---|
685 | } |
---|
686 | } |
---|
687 | |
---|
688 | Int TComSlice::getNumRpsCurrTempList() const |
---|
689 | { |
---|
690 | Int numRpsCurrTempList = 0; |
---|
691 | |
---|
692 | #if SVC_EXTENSION |
---|
693 | if( m_eSliceType == I_SLICE || ( m_layerId && |
---|
694 | (m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && |
---|
695 | (m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) ) |
---|
696 | #else |
---|
697 | if (m_eSliceType == I_SLICE) |
---|
698 | #endif |
---|
699 | { |
---|
700 | #if SVC_EXTENSION |
---|
701 | return m_activeNumILRRefIdx; |
---|
702 | #else |
---|
703 | return 0; |
---|
704 | #endif |
---|
705 | } |
---|
706 | for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++) |
---|
707 | { |
---|
708 | if(m_pcRPS->getUsed(i)) |
---|
709 | { |
---|
710 | numRpsCurrTempList++; |
---|
711 | } |
---|
712 | } |
---|
713 | #if SVC_EXTENSION |
---|
714 | if( m_layerId > 0 ) |
---|
715 | { |
---|
716 | numRpsCurrTempList += m_activeNumILRRefIdx; |
---|
717 | } |
---|
718 | #endif |
---|
719 | |
---|
720 | return numRpsCurrTempList; |
---|
721 | } |
---|
722 | |
---|
723 | Void TComSlice::initEqualRef() |
---|
724 | { |
---|
725 | for (Int iDir = 0; iDir < NUM_REF_PIC_LIST_01; iDir++) |
---|
726 | { |
---|
727 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
728 | { |
---|
729 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
730 | { |
---|
731 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
732 | } |
---|
733 | } |
---|
734 | } |
---|
735 | } |
---|
736 | |
---|
737 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
738 | { |
---|
739 | Int i; |
---|
740 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
741 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1 - curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
742 | TComSlice* preSlice; |
---|
743 | Int preColRefPOC; |
---|
744 | for(i=curSliceIdx-1; i>=0; i--) |
---|
745 | { |
---|
746 | preSlice = pic->getSlice(i); |
---|
747 | if(preSlice->getSliceType() != I_SLICE) |
---|
748 | { |
---|
749 | preColRefPOC = preSlice->getRefPOC( RefPicList(1 - preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
750 | if(currColRefPOC != preColRefPOC) |
---|
751 | { |
---|
752 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
753 | exit(EXIT_FAILURE); |
---|
754 | } |
---|
755 | else |
---|
756 | { |
---|
757 | break; |
---|
758 | } |
---|
759 | } |
---|
760 | } |
---|
761 | } |
---|
762 | |
---|
763 | Void TComSlice::checkCRA(const TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic) |
---|
764 | { |
---|
765 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
766 | { |
---|
767 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
768 | { |
---|
769 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
770 | } |
---|
771 | } |
---|
772 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
773 | { |
---|
774 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
775 | { |
---|
776 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
777 | { |
---|
778 | assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA); |
---|
779 | } |
---|
780 | else |
---|
781 | { |
---|
782 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
783 | } |
---|
784 | } |
---|
785 | } |
---|
786 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
787 | { |
---|
788 | pocCRA = getPOC(); |
---|
789 | associatedIRAPType = getNalUnitType(); |
---|
790 | } |
---|
791 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
792 | { |
---|
793 | pocCRA = getPOC(); |
---|
794 | associatedIRAPType = getNalUnitType(); |
---|
795 | } |
---|
796 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
797 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
798 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
799 | { |
---|
800 | pocCRA = getPOC(); |
---|
801 | associatedIRAPType = getNalUnitType(); |
---|
802 | } |
---|
803 | } |
---|
804 | |
---|
805 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
806 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
807 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
808 | * \param rcListPic reference to the reference picture list |
---|
809 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
810 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
811 | * are marked as "unused for reference" |
---|
812 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
813 | * Otherwise |
---|
814 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
815 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
816 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
817 | * the bRefreshPending flag to false. |
---|
818 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
819 | * reference of the current picture. |
---|
820 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
821 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
822 | */ |
---|
823 | #if NO_CLRAS_OUTPUT_FLAG |
---|
824 | Void TComSlice::decodingRefreshMarking( TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag, UInt smallestLayerId ) |
---|
825 | { |
---|
826 | if( !isIRAP() ) |
---|
827 | { |
---|
828 | return; |
---|
829 | } |
---|
830 | |
---|
831 | Int pocCurr = getPOC(); |
---|
832 | TComPic* rpcPic = NULL; |
---|
833 | |
---|
834 | // When the current picture is an IRAP picture with nuh_layer_id equal to 0 and NoClrasOutputFlag is equal to 1, |
---|
835 | // all reference pictures with any value of nuh_layer_id currently in the DPB (if any) are marked as "unused for reference". |
---|
836 | if (m_layerId == smallestLayerId && noClrasOutputFlag) |
---|
837 | { |
---|
838 | // mark all pictures for all layers as not used for reference |
---|
839 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
840 | while( iterPic != rcListPic.end() ) |
---|
841 | { |
---|
842 | rpcPic = *(iterPic); |
---|
843 | if( rpcPic->getPOC() != pocCurr ) |
---|
844 | { |
---|
845 | rpcPic->getSlice(0)->setReferenced(false); |
---|
846 | } |
---|
847 | iterPic++; |
---|
848 | } |
---|
849 | } |
---|
850 | |
---|
851 | // When the current picture is an IRAP picture with NoRaslOutputFlag equal to 1, |
---|
852 | // all reference pictures with nuh_layer_id equal to currPicLayerId currently in the DPB (if any) are marked as "unused for reference". |
---|
853 | if( m_noRaslOutputFlag ) |
---|
854 | { |
---|
855 | // mark all pictures of a current layer as not used for reference |
---|
856 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
857 | while( iterPic != rcListPic.end() ) |
---|
858 | { |
---|
859 | rpcPic = *(iterPic); |
---|
860 | if( rpcPic->getPOC() != pocCurr && rpcPic->getLayerId() == m_layerId ) |
---|
861 | { |
---|
862 | rpcPic->getSlice(0)->setReferenced(false); |
---|
863 | } |
---|
864 | iterPic++; |
---|
865 | } |
---|
866 | } |
---|
867 | } |
---|
868 | |
---|
869 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag) |
---|
870 | #else |
---|
871 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
872 | #endif |
---|
873 | { |
---|
874 | TComPic* rpcPic; |
---|
875 | Int pocCurr = getPOC(); |
---|
876 | |
---|
877 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
878 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
879 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
880 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
881 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
882 | { |
---|
883 | // mark all pictures as not used for reference |
---|
884 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
885 | while (iterPic != rcListPic.end()) |
---|
886 | { |
---|
887 | rpcPic = *(iterPic); |
---|
888 | rpcPic->setCurrSliceIdx(0); |
---|
889 | #if NO_CLRAS_OUTPUT_FLAG |
---|
890 | if( noClrasOutputFlag ) |
---|
891 | { |
---|
892 | rpcPic->getSlice(0)->setReferenced(false); // all layers // TODO. This does not mark all layers |
---|
893 | } |
---|
894 | else |
---|
895 | { |
---|
896 | if( rpcPic->getLayerId() == m_layerId ) |
---|
897 | { |
---|
898 | rpcPic->getSlice(0)->setReferenced(false); // only current layer |
---|
899 | } |
---|
900 | } |
---|
901 | #else |
---|
902 | if (rpcPic->getPOC() != pocCurr) |
---|
903 | { |
---|
904 | rpcPic->getSlice(0)->setReferenced(false); |
---|
905 | } |
---|
906 | #endif |
---|
907 | iterPic++; |
---|
908 | } |
---|
909 | |
---|
910 | #if SVC_EXTENSION |
---|
911 | m_pcPic->getSlice(0)->setReferenced(true); // Mark the current picture back as refererced. |
---|
912 | #endif |
---|
913 | |
---|
914 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
915 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
916 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
917 | { |
---|
918 | pocCRA = pocCurr; |
---|
919 | } |
---|
920 | #if EFFICIENT_FIELD_IRAP |
---|
921 | bRefreshPending = true; |
---|
922 | #endif |
---|
923 | } |
---|
924 | else // CRA or No DR |
---|
925 | { |
---|
926 | #if EFFICIENT_FIELD_IRAP |
---|
927 | if(getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
928 | { |
---|
929 | if (bRefreshPending==true && pocCurr > m_iLastIDR) // IDR reference marking pending |
---|
930 | { |
---|
931 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
932 | while (iterPic != rcListPic.end()) |
---|
933 | { |
---|
934 | rpcPic = *(iterPic); |
---|
935 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != m_iLastIDR) |
---|
936 | { |
---|
937 | rpcPic->getSlice(0)->setReferenced(false); |
---|
938 | } |
---|
939 | iterPic++; |
---|
940 | } |
---|
941 | bRefreshPending = false; |
---|
942 | } |
---|
943 | } |
---|
944 | else |
---|
945 | { |
---|
946 | #endif |
---|
947 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
948 | { |
---|
949 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
950 | while (iterPic != rcListPic.end()) |
---|
951 | { |
---|
952 | rpcPic = *(iterPic); |
---|
953 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
954 | { |
---|
955 | rpcPic->getSlice(0)->setReferenced(false); |
---|
956 | } |
---|
957 | iterPic++; |
---|
958 | } |
---|
959 | bRefreshPending = false; |
---|
960 | } |
---|
961 | #if EFFICIENT_FIELD_IRAP |
---|
962 | } |
---|
963 | #endif |
---|
964 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
965 | { |
---|
966 | bRefreshPending = true; |
---|
967 | pocCRA = pocCurr; |
---|
968 | } |
---|
969 | } |
---|
970 | } |
---|
971 | |
---|
972 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
973 | { |
---|
974 | assert( pSrc != NULL ); |
---|
975 | |
---|
976 | Int i, j, k; |
---|
977 | |
---|
978 | m_iPOC = pSrc->m_iPOC; |
---|
979 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
980 | m_eSliceType = pSrc->m_eSliceType; |
---|
981 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
982 | #if ADAPTIVE_QP_SELECTION |
---|
983 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
984 | #endif |
---|
985 | m_ChromaQpAdjEnabled = pSrc->m_ChromaQpAdjEnabled; |
---|
986 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
987 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
988 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
989 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
990 | |
---|
991 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
992 | { |
---|
993 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
994 | } |
---|
995 | |
---|
996 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
997 | { |
---|
998 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
999 | } |
---|
1000 | |
---|
1001 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
1002 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
1003 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
1004 | { |
---|
1005 | m_iSliceChromaQpDelta[component] = pSrc->m_iSliceChromaQpDelta[component]; |
---|
1006 | } |
---|
1007 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
1008 | { |
---|
1009 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1010 | { |
---|
1011 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
1012 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
1013 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
1014 | } |
---|
1015 | m_bIsUsedAsLongTerm[i][MAX_NUM_REF] = pSrc->m_bIsUsedAsLongTerm[i][MAX_NUM_REF]; |
---|
1016 | } |
---|
1017 | m_iDepth = pSrc->m_iDepth; |
---|
1018 | |
---|
1019 | // referenced slice |
---|
1020 | m_bRefenced = pSrc->m_bRefenced; |
---|
1021 | |
---|
1022 | // access channel |
---|
1023 | #if SVC_EXTENSION |
---|
1024 | m_pcVPS = pSrc->m_pcVPS; |
---|
1025 | m_layerId = pSrc->m_layerId; |
---|
1026 | m_activeNumILRRefIdx = pSrc->m_activeNumILRRefIdx; |
---|
1027 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
1028 | memcpy( m_interLayerPredLayerIdc, pSrc->m_interLayerPredLayerIdc, sizeof( m_interLayerPredLayerIdc ) ); |
---|
1029 | #endif |
---|
1030 | m_pcRPS = pSrc->m_pcRPS; |
---|
1031 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
1032 | |
---|
1033 | m_pcPic = pSrc->m_pcPic; |
---|
1034 | |
---|
1035 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
1036 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
1037 | |
---|
1038 | setLambdas(pSrc->getLambdas()); |
---|
1039 | |
---|
1040 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
1041 | { |
---|
1042 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1043 | { |
---|
1044 | for (k =0; k < MAX_NUM_REF; k++) |
---|
1045 | { |
---|
1046 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
1047 | } |
---|
1048 | } |
---|
1049 | } |
---|
1050 | |
---|
1051 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
1052 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
1053 | |
---|
1054 | m_sliceMode = pSrc->m_sliceMode; |
---|
1055 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
1056 | m_sliceCurStartCtuTsAddr = pSrc->m_sliceCurStartCtuTsAddr; |
---|
1057 | m_sliceCurEndCtuTsAddr = pSrc->m_sliceCurEndCtuTsAddr; |
---|
1058 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
1059 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
1060 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
1061 | m_sliceSegmentCurStartCtuTsAddr = pSrc->m_sliceSegmentCurStartCtuTsAddr; |
---|
1062 | m_sliceSegmentCurEndCtuTsAddr = pSrc->m_sliceSegmentCurEndCtuTsAddr; |
---|
1063 | m_nextSlice = pSrc->m_nextSlice; |
---|
1064 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
1065 | |
---|
1066 | for ( UInt e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
1067 | { |
---|
1068 | for ( UInt n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
1069 | { |
---|
1070 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(WPScalingParam)*MAX_NUM_COMPONENT ); |
---|
1071 | } |
---|
1072 | } |
---|
1073 | |
---|
1074 | for( UInt ch = 0 ; ch < MAX_NUM_CHANNEL_TYPE; ch++) |
---|
1075 | { |
---|
1076 | m_saoEnabledFlag[ch] = pSrc->m_saoEnabledFlag[ch]; |
---|
1077 | } |
---|
1078 | |
---|
1079 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
1080 | |
---|
1081 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
1082 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
1083 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
1084 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
1085 | m_encCABACTableIdx = pSrc->m_encCABACTableIdx; |
---|
1086 | } |
---|
1087 | |
---|
1088 | |
---|
1089 | Int TComSlice::m_prevTid0POC = 0; |
---|
1090 | |
---|
1091 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
1092 | * \param uiTLayer Temporal layer ID of the current slice |
---|
1093 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
1094 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
1095 | * temporal_layer_switching_point_flag is set accordingly. |
---|
1096 | */ |
---|
1097 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
1098 | { |
---|
1099 | m_uiTLayer = uiTLayer; |
---|
1100 | } |
---|
1101 | |
---|
1102 | /** Function for checking if this is a switching-point |
---|
1103 | */ |
---|
1104 | Bool TComSlice::isTemporalLayerSwitchingPoint(TComList<TComPic*>& rcListPic) |
---|
1105 | { |
---|
1106 | TComPic* rpcPic; |
---|
1107 | // loop through all pictures in the reference picture buffer |
---|
1108 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1109 | while ( iterPic != rcListPic.end()) |
---|
1110 | { |
---|
1111 | rpcPic = *(iterPic++); |
---|
1112 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
1113 | { |
---|
1114 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1115 | { |
---|
1116 | return false; |
---|
1117 | } |
---|
1118 | } |
---|
1119 | } |
---|
1120 | return true; |
---|
1121 | } |
---|
1122 | |
---|
1123 | /** Function for checking if this is a STSA candidate |
---|
1124 | */ |
---|
1125 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate(TComList<TComPic*>& rcListPic) |
---|
1126 | { |
---|
1127 | TComPic* rpcPic; |
---|
1128 | |
---|
1129 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1130 | while ( iterPic != rcListPic.end()) |
---|
1131 | { |
---|
1132 | rpcPic = *(iterPic++); |
---|
1133 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
1134 | { |
---|
1135 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1136 | { |
---|
1137 | return false; |
---|
1138 | } |
---|
1139 | } |
---|
1140 | } |
---|
1141 | return true; |
---|
1142 | } |
---|
1143 | |
---|
1144 | #if SVC_POC |
---|
1145 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic, Bool usePocBeforeReset) |
---|
1146 | #else |
---|
1147 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) |
---|
1148 | #endif |
---|
1149 | { |
---|
1150 | TComPic* rpcPic; |
---|
1151 | |
---|
1152 | Int nalUnitType = this->getNalUnitType(); |
---|
1153 | |
---|
1154 | // When a picture is a leading picture, it shall be a RADL or RASL picture. |
---|
1155 | if(this->getAssociatedIRAPPOC() > this->getPOC()) |
---|
1156 | { |
---|
1157 | // Do not check IRAP pictures since they may get a POC lower than their associated IRAP |
---|
1158 | if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1159 | nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) |
---|
1160 | { |
---|
1161 | assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1162 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1163 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1164 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1165 | } |
---|
1166 | } |
---|
1167 | |
---|
1168 | // When a picture is a trailing picture, it shall not be a RADL or RASL picture. |
---|
1169 | if(this->getAssociatedIRAPPOC() < this->getPOC()) |
---|
1170 | { |
---|
1171 | assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && |
---|
1172 | nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && |
---|
1173 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && |
---|
1174 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1175 | } |
---|
1176 | |
---|
1177 | // No RASL pictures shall be present in the bitstream that are associated |
---|
1178 | // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. |
---|
1179 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1180 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1181 | { |
---|
1182 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && |
---|
1183 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); |
---|
1184 | } |
---|
1185 | |
---|
1186 | // No RASL pictures shall be present in the bitstream that are associated with |
---|
1187 | // an IDR picture. |
---|
1188 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1189 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1190 | { |
---|
1191 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && |
---|
1192 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
1193 | } |
---|
1194 | |
---|
1195 | // No RADL pictures shall be present in the bitstream that are associated with |
---|
1196 | // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated |
---|
1197 | // with an IDR picture having nal_unit_type equal to IDR_N_LP. |
---|
1198 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1199 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1200 | { |
---|
1201 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && |
---|
1202 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); |
---|
1203 | } |
---|
1204 | |
---|
1205 | // loop through all pictures in the reference picture buffer |
---|
1206 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1207 | while ( iterPic != rcListPic.end()) |
---|
1208 | { |
---|
1209 | rpcPic = *(iterPic++); |
---|
1210 | #if BUGFIX_INTRAPERIOD |
---|
1211 | if(!rpcPic->getReconMark()) |
---|
1212 | { |
---|
1213 | continue; |
---|
1214 | } |
---|
1215 | #endif |
---|
1216 | if (rpcPic->getPOC() == this->getPOC()) |
---|
1217 | { |
---|
1218 | continue; |
---|
1219 | } |
---|
1220 | |
---|
1221 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1222 | // in decoding order shall precede the IRAP picture in output order. |
---|
1223 | // (Note that any picture following in output order would be present in the DPB) |
---|
1224 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1 && !this->getNoOutputPriorPicsFlag()) |
---|
1225 | { |
---|
1226 | if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1227 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1228 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1229 | nalUnitType == NAL_UNIT_CODED_SLICE_CRA || |
---|
1230 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1231 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
1232 | { |
---|
1233 | #if SVC_POC |
---|
1234 | if( usePocBeforeReset ) |
---|
1235 | { |
---|
1236 | assert(rpcPic->getSlice(0)->getPocValueBeforeReset() < this->getPocValueBeforeReset()); |
---|
1237 | } |
---|
1238 | else |
---|
1239 | { |
---|
1240 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1241 | } |
---|
1242 | #else |
---|
1243 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1244 | #endif |
---|
1245 | } |
---|
1246 | } |
---|
1247 | |
---|
1248 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1249 | // in decoding order shall precede any RADL picture associated with the IRAP |
---|
1250 | // picture in output order. |
---|
1251 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
1252 | { |
---|
1253 | if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1254 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) |
---|
1255 | { |
---|
1256 | // rpcPic precedes the IRAP in decoding order |
---|
1257 | if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1258 | { |
---|
1259 | // rpcPic must not be the IRAP picture |
---|
1260 | if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) |
---|
1261 | { |
---|
1262 | #if SVC_POC |
---|
1263 | if( usePocBeforeReset ) |
---|
1264 | { |
---|
1265 | assert(rpcPic->getSlice(0)->getPocValueBeforeReset() < this->getPocValueBeforeReset()); |
---|
1266 | } |
---|
1267 | else |
---|
1268 | { |
---|
1269 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1270 | } |
---|
1271 | #else |
---|
1272 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1273 | #endif |
---|
1274 | } |
---|
1275 | } |
---|
1276 | } |
---|
1277 | } |
---|
1278 | |
---|
1279 | // When a picture is a leading picture, it shall precede, in decoding order, |
---|
1280 | // all trailing pictures that are associated with the same IRAP picture. |
---|
1281 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1282 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1283 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1284 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1285 | { |
---|
1286 | if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) |
---|
1287 | { |
---|
1288 | // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB |
---|
1289 | // rpcPic would violate the constraint if it was a trailing picture |
---|
1290 | #if SVC_POC |
---|
1291 | if( usePocBeforeReset ) |
---|
1292 | { |
---|
1293 | assert(rpcPic->getPOC() <= this->getAssociatedIrapPocBeforeReset()); |
---|
1294 | } |
---|
1295 | else |
---|
1296 | { |
---|
1297 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
1298 | } |
---|
1299 | #else |
---|
1300 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
1301 | #endif |
---|
1302 | } |
---|
1303 | } |
---|
1304 | |
---|
1305 | // Any RASL picture associated with a CRA or BLA picture shall precede any |
---|
1306 | // RADL picture associated with the CRA or BLA picture in output order |
---|
1307 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1308 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1309 | { |
---|
1310 | if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1311 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1312 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1313 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && |
---|
1314 | this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1315 | { |
---|
1316 | if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1317 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1318 | { |
---|
1319 | assert(rpcPic->getPOC() > this->getPOC()); |
---|
1320 | } |
---|
1321 | } |
---|
1322 | } |
---|
1323 | |
---|
1324 | // Any RASL picture associated with a CRA picture shall follow, in output |
---|
1325 | // order, any IRAP picture that precedes the CRA picture in decoding order. |
---|
1326 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1327 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1328 | { |
---|
1329 | if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
1330 | { |
---|
1331 | if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && |
---|
1332 | (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1333 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1334 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1335 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1336 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || |
---|
1337 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) |
---|
1338 | { |
---|
1339 | assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); |
---|
1340 | } |
---|
1341 | } |
---|
1342 | } |
---|
1343 | } |
---|
1344 | } |
---|
1345 | |
---|
1346 | |
---|
1347 | |
---|
1348 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1349 | */ |
---|
1350 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet) |
---|
1351 | { |
---|
1352 | TComPic* rpcPic; |
---|
1353 | Int i, isReference; |
---|
1354 | |
---|
1355 | #if !ALIGNED_BUMPING |
---|
1356 | checkLeadingPictureRestrictions(rcListPic); |
---|
1357 | #endif |
---|
1358 | |
---|
1359 | // loop through all pictures in the reference picture buffer |
---|
1360 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1361 | while ( iterPic != rcListPic.end()) |
---|
1362 | { |
---|
1363 | rpcPic = *(iterPic++); |
---|
1364 | |
---|
1365 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
1366 | { |
---|
1367 | continue; |
---|
1368 | } |
---|
1369 | |
---|
1370 | isReference = 0; |
---|
1371 | // loop through all pictures in the Reference Picture Set |
---|
1372 | // to see if the picture should be kept as reference picture |
---|
1373 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
1374 | { |
---|
1375 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
1376 | { |
---|
1377 | isReference = 1; |
---|
1378 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1379 | rpcPic->setIsLongTerm(0); |
---|
1380 | } |
---|
1381 | } |
---|
1382 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1383 | { |
---|
1384 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1385 | { |
---|
1386 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
1387 | { |
---|
1388 | isReference = 1; |
---|
1389 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1390 | } |
---|
1391 | } |
---|
1392 | else |
---|
1393 | { |
---|
1394 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1395 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1396 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1397 | if(rpcPic->getIsLongTerm() && curPoc == refPoc) |
---|
1398 | { |
---|
1399 | isReference = 1; |
---|
1400 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1401 | } |
---|
1402 | } |
---|
1403 | |
---|
1404 | } |
---|
1405 | |
---|
1406 | #if SVC_EXTENSION |
---|
1407 | if( isReference ) // Current picture is in the temporal RPS |
---|
1408 | { |
---|
1409 | assert( rpcPic->getSlice(0)->getDiscardableFlag() == 0 ); // Temporal RPS shall not contain picture with discardable_flag equal to 1 |
---|
1410 | } |
---|
1411 | #endif |
---|
1412 | |
---|
1413 | // mark the picture as "unused for reference" if it is not in |
---|
1414 | // the Reference Picture Set |
---|
1415 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
1416 | { |
---|
1417 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
1418 | rpcPic->setUsedByCurr(0); |
---|
1419 | rpcPic->setIsLongTerm(0); |
---|
1420 | } |
---|
1421 | //check that pictures of higher temporal layers are not used |
---|
1422 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
1423 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
1424 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
1425 | { |
---|
1426 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
1427 | } |
---|
1428 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
1429 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
1430 | { |
---|
1431 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
1432 | } |
---|
1433 | } |
---|
1434 | } |
---|
1435 | |
---|
1436 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1437 | */ |
---|
1438 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1439 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1440 | #else |
---|
1441 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess) |
---|
1442 | #endif |
---|
1443 | { |
---|
1444 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1445 | Int atLeastOneUnabledByRecoveryPoint = 0; |
---|
1446 | Int atLeastOneFlushedByPreviousIDR = 0; |
---|
1447 | #endif |
---|
1448 | TComPic* rpcPic; |
---|
1449 | Int i, isAvailable; |
---|
1450 | Int atLeastOneLost = 0; |
---|
1451 | Int atLeastOneRemoved = 0; |
---|
1452 | Int iPocLost = 0; |
---|
1453 | |
---|
1454 | // loop through all long-term pictures in the Reference Picture Set |
---|
1455 | // to see if the picture should be kept as reference picture |
---|
1456 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1457 | { |
---|
1458 | isAvailable = 0; |
---|
1459 | // loop through all pictures in the reference picture buffer |
---|
1460 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1461 | while ( iterPic != rcListPic.end()) |
---|
1462 | { |
---|
1463 | rpcPic = *(iterPic++); |
---|
1464 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1465 | { |
---|
1466 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1467 | { |
---|
1468 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1469 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1470 | { |
---|
1471 | isAvailable = 0; |
---|
1472 | } |
---|
1473 | else |
---|
1474 | { |
---|
1475 | isAvailable = 1; |
---|
1476 | } |
---|
1477 | #else |
---|
1478 | isAvailable = 1; |
---|
1479 | #endif |
---|
1480 | } |
---|
1481 | } |
---|
1482 | else |
---|
1483 | { |
---|
1484 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1485 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1486 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1487 | if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) |
---|
1488 | { |
---|
1489 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1490 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1491 | { |
---|
1492 | isAvailable = 0; |
---|
1493 | } |
---|
1494 | else |
---|
1495 | { |
---|
1496 | isAvailable = 1; |
---|
1497 | } |
---|
1498 | #else |
---|
1499 | isAvailable = 1; |
---|
1500 | #endif |
---|
1501 | } |
---|
1502 | } |
---|
1503 | } |
---|
1504 | // if there was no such long-term check the short terms |
---|
1505 | if(!isAvailable) |
---|
1506 | { |
---|
1507 | iterPic = rcListPic.begin(); |
---|
1508 | while ( iterPic != rcListPic.end()) |
---|
1509 | { |
---|
1510 | rpcPic = *(iterPic++); |
---|
1511 | |
---|
1512 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1513 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
1514 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
1515 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
1516 | { |
---|
1517 | curPoc = curPoc & (pocCycle - 1); |
---|
1518 | refPoc = refPoc & (pocCycle - 1); |
---|
1519 | } |
---|
1520 | |
---|
1521 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
1522 | { |
---|
1523 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1524 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1525 | { |
---|
1526 | isAvailable = 0; |
---|
1527 | } |
---|
1528 | else |
---|
1529 | { |
---|
1530 | isAvailable = 1; |
---|
1531 | rpcPic->setIsLongTerm(1); |
---|
1532 | break; |
---|
1533 | } |
---|
1534 | #else |
---|
1535 | isAvailable = 1; |
---|
1536 | rpcPic->setIsLongTerm(1); |
---|
1537 | break; |
---|
1538 | #endif |
---|
1539 | } |
---|
1540 | } |
---|
1541 | } |
---|
1542 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1543 | // but not available as reference picture |
---|
1544 | if(isAvailable == 0) |
---|
1545 | { |
---|
1546 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1547 | { |
---|
1548 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1549 | { |
---|
1550 | if(printErrors) |
---|
1551 | { |
---|
1552 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1553 | } |
---|
1554 | atLeastOneRemoved = 1; |
---|
1555 | } |
---|
1556 | else |
---|
1557 | { |
---|
1558 | if(printErrors) |
---|
1559 | { |
---|
1560 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1561 | } |
---|
1562 | atLeastOneLost = 1; |
---|
1563 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1564 | } |
---|
1565 | } |
---|
1566 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1567 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1568 | { |
---|
1569 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1570 | } |
---|
1571 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1572 | { |
---|
1573 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1574 | } |
---|
1575 | #endif |
---|
1576 | } |
---|
1577 | } |
---|
1578 | // loop through all short-term pictures in the Reference Picture Set |
---|
1579 | // to see if the picture should be kept as reference picture |
---|
1580 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
1581 | { |
---|
1582 | isAvailable = 0; |
---|
1583 | // loop through all pictures in the reference picture buffer |
---|
1584 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1585 | while ( iterPic != rcListPic.end()) |
---|
1586 | { |
---|
1587 | rpcPic = *(iterPic++); |
---|
1588 | |
---|
1589 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1590 | { |
---|
1591 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1592 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1593 | { |
---|
1594 | isAvailable = 0; |
---|
1595 | } |
---|
1596 | else |
---|
1597 | { |
---|
1598 | isAvailable = 1; |
---|
1599 | } |
---|
1600 | #else |
---|
1601 | isAvailable = 1; |
---|
1602 | #endif |
---|
1603 | } |
---|
1604 | } |
---|
1605 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1606 | // but not available as reference picture |
---|
1607 | if(isAvailable == 0) |
---|
1608 | { |
---|
1609 | #if !UNAVAILABLE_PIC_BUGFIX |
---|
1610 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1611 | #endif |
---|
1612 | { |
---|
1613 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1614 | { |
---|
1615 | if(printErrors) |
---|
1616 | { |
---|
1617 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1618 | } |
---|
1619 | atLeastOneRemoved = 1; |
---|
1620 | } |
---|
1621 | else |
---|
1622 | { |
---|
1623 | if(printErrors) |
---|
1624 | { |
---|
1625 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1626 | } |
---|
1627 | atLeastOneLost = 1; |
---|
1628 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1629 | } |
---|
1630 | } |
---|
1631 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1632 | #if UNAVAILABLE_PIC_BUGFIX |
---|
1633 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1634 | #else |
---|
1635 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1636 | #endif |
---|
1637 | { |
---|
1638 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1639 | } |
---|
1640 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1641 | { |
---|
1642 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1643 | } |
---|
1644 | #endif |
---|
1645 | } |
---|
1646 | } |
---|
1647 | |
---|
1648 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1649 | if(atLeastOneUnabledByRecoveryPoint || atLeastOneFlushedByPreviousIDR) |
---|
1650 | { |
---|
1651 | return -1; |
---|
1652 | } |
---|
1653 | #endif |
---|
1654 | if(atLeastOneLost) |
---|
1655 | { |
---|
1656 | return iPocLost+1; |
---|
1657 | } |
---|
1658 | if(atLeastOneRemoved) |
---|
1659 | { |
---|
1660 | return -2; |
---|
1661 | } |
---|
1662 | else |
---|
1663 | { |
---|
1664 | return 0; |
---|
1665 | } |
---|
1666 | } |
---|
1667 | |
---|
1668 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
1669 | */ |
---|
1670 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1671 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1672 | #else |
---|
1673 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP) |
---|
1674 | #endif |
---|
1675 | { |
---|
1676 | TComPic* rpcPic; |
---|
1677 | Int i, j; |
---|
1678 | Int k = 0; |
---|
1679 | Int nrOfNegativePictures = 0; |
---|
1680 | Int nrOfPositivePictures = 0; |
---|
1681 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
1682 | #if EFFICIENT_FIELD_IRAP |
---|
1683 | Bool irapIsInRPS = false; |
---|
1684 | #endif |
---|
1685 | #if SVC_POC |
---|
1686 | Bool pocsAdjusted = false; |
---|
1687 | #endif |
---|
1688 | |
---|
1689 | // loop through all pictures in the Reference Picture Set |
---|
1690 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1691 | { |
---|
1692 | j = 0; |
---|
1693 | // loop through all pictures in the reference picture buffer |
---|
1694 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1695 | while ( iterPic != rcListPic.end()) |
---|
1696 | { |
---|
1697 | j++; |
---|
1698 | rpcPic = *(iterPic++); |
---|
1699 | |
---|
1700 | #if SVC_POC |
---|
1701 | // poc adjustement by poc reset needs to be taken into account here |
---|
1702 | Int deltaPOC = pReferencePictureSet->getDeltaPOC(i) - rpcPic->getPicSym()->getSlice(0)->getPocResetDeltaPoc(); |
---|
1703 | if (rpcPic->getPicSym()->getSlice(0)->getPocResetDeltaPoc() != 0) |
---|
1704 | { |
---|
1705 | pocsAdjusted = true; |
---|
1706 | } |
---|
1707 | |
---|
1708 | if (rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + deltaPOC && rpcPic->getSlice(0)->isReferenced()) |
---|
1709 | #else |
---|
1710 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1711 | #endif |
---|
1712 | { |
---|
1713 | // This picture exists as a reference picture |
---|
1714 | // and should be added to the explicit Reference Picture Set |
---|
1715 | #if SVC_POC |
---|
1716 | pcRPS->setDeltaPOC(k, deltaPOC); |
---|
1717 | #else |
---|
1718 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
1719 | #endif |
---|
1720 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); |
---|
1721 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1722 | #if SVC_POC |
---|
1723 | pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + deltaPOC < pocRandomAccess) ); |
---|
1724 | #else |
---|
1725 | pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) ); |
---|
1726 | #endif |
---|
1727 | #endif |
---|
1728 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
1729 | { |
---|
1730 | nrOfNegativePictures++; |
---|
1731 | } |
---|
1732 | else |
---|
1733 | { |
---|
1734 | #if EFFICIENT_FIELD_IRAP |
---|
1735 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
1736 | { |
---|
1737 | irapIsInRPS = true; |
---|
1738 | } |
---|
1739 | #endif |
---|
1740 | nrOfPositivePictures++; |
---|
1741 | } |
---|
1742 | k++; |
---|
1743 | } |
---|
1744 | } |
---|
1745 | } |
---|
1746 | |
---|
1747 | #if EFFICIENT_FIELD_IRAP |
---|
1748 | Bool useNewRPS = false; |
---|
1749 | // if current picture is complimentary field associated to IRAP, add the IRAP to its RPS. |
---|
1750 | if(m_pcPic->isField() && !irapIsInRPS) |
---|
1751 | { |
---|
1752 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1753 | while ( iterPic != rcListPic.end()) |
---|
1754 | { |
---|
1755 | rpcPic = *(iterPic++); |
---|
1756 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
1757 | { |
---|
1758 | pcRPS->setDeltaPOC(k, 1); |
---|
1759 | pcRPS->setUsed(k, true); |
---|
1760 | nrOfPositivePictures++; |
---|
1761 | k ++; |
---|
1762 | useNewRPS = true; |
---|
1763 | } |
---|
1764 | } |
---|
1765 | } |
---|
1766 | #endif |
---|
1767 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
1768 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
1769 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
1770 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
1771 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
1772 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
1773 | if (!pReferencePictureSet->getInterRPSPrediction() |
---|
1774 | #if EFFICIENT_FIELD_IRAP |
---|
1775 | || useNewRPS |
---|
1776 | #endif |
---|
1777 | #if SVC_POC |
---|
1778 | || pocsAdjusted // inter RPS prediction does not work if POCs have been adjusted |
---|
1779 | #endif |
---|
1780 | ) |
---|
1781 | { |
---|
1782 | pcRPS->setInterRPSPrediction(false); |
---|
1783 | pcRPS->setNumRefIdc(0); |
---|
1784 | } |
---|
1785 | else |
---|
1786 | { |
---|
1787 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
1788 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
1789 | const TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
1790 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
1791 | Int iNewIdc=0; |
---|
1792 | for(i=0; i<= iRefPics; i++) |
---|
1793 | { |
---|
1794 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
1795 | Int iRefIdc = 0; |
---|
1796 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
1797 | { |
---|
1798 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
1799 | { |
---|
1800 | if (pcRPS->getUsed(j)) |
---|
1801 | { |
---|
1802 | iRefIdc = 1; |
---|
1803 | } |
---|
1804 | else |
---|
1805 | { |
---|
1806 | iRefIdc = 2; |
---|
1807 | } |
---|
1808 | } |
---|
1809 | } |
---|
1810 | pcRPS->setRefIdc(i, iRefIdc); |
---|
1811 | iNewIdc++; |
---|
1812 | } |
---|
1813 | pcRPS->setInterRPSPrediction(true); |
---|
1814 | pcRPS->setNumRefIdc(iNewIdc); |
---|
1815 | pcRPS->setDeltaRPS(deltaRPS); |
---|
1816 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
1817 | } |
---|
1818 | |
---|
1819 | this->setRPS(pcRPS); |
---|
1820 | this->setRPSidx(-1); |
---|
1821 | } |
---|
1822 | |
---|
1823 | //! get AC and DC values for weighted pred |
---|
1824 | Void TComSlice::getWpAcDcParam(WPACDCParam *&wp) |
---|
1825 | { |
---|
1826 | wp = m_weightACDCParam; |
---|
1827 | } |
---|
1828 | |
---|
1829 | //! init AC and DC values for weighted pred |
---|
1830 | Void TComSlice::initWpAcDcParam() |
---|
1831 | { |
---|
1832 | for(Int iComp = 0; iComp < MAX_NUM_COMPONENT; iComp++ ) |
---|
1833 | { |
---|
1834 | m_weightACDCParam[iComp].iAC = 0; |
---|
1835 | m_weightACDCParam[iComp].iDC = 0; |
---|
1836 | } |
---|
1837 | } |
---|
1838 | |
---|
1839 | //! get tables for weighted prediction |
---|
1840 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, WPScalingParam *&wp ) |
---|
1841 | { |
---|
1842 | assert (e<NUM_REF_PIC_LIST_01); |
---|
1843 | wp = m_weightPredTable[e][iRefIdx]; |
---|
1844 | } |
---|
1845 | |
---|
1846 | //! reset Default WP tables settings : no weight. |
---|
1847 | Void TComSlice::resetWpScaling() |
---|
1848 | { |
---|
1849 | for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
1850 | { |
---|
1851 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1852 | { |
---|
1853 | for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) |
---|
1854 | { |
---|
1855 | WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1856 | pwp->bPresentFlag = false; |
---|
1857 | pwp->uiLog2WeightDenom = 0; |
---|
1858 | pwp->uiLog2WeightDenom = 0; |
---|
1859 | pwp->iWeight = 1; |
---|
1860 | pwp->iOffset = 0; |
---|
1861 | } |
---|
1862 | } |
---|
1863 | } |
---|
1864 | } |
---|
1865 | |
---|
1866 | //! init WP table |
---|
1867 | Void TComSlice::initWpScaling(const TComSPS *sps) |
---|
1868 | { |
---|
1869 | const Bool bUseHighPrecisionPredictionWeighting = sps->getUseHighPrecisionPredictionWeighting(); |
---|
1870 | for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
1871 | { |
---|
1872 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1873 | { |
---|
1874 | for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) |
---|
1875 | { |
---|
1876 | WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1877 | if ( !pwp->bPresentFlag ) |
---|
1878 | { |
---|
1879 | // Inferring values not present : |
---|
1880 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
1881 | pwp->iOffset = 0; |
---|
1882 | } |
---|
1883 | |
---|
1884 | const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (g_bitDepth[toChannelType(ComponentID(yuv))]-8)); |
---|
1885 | |
---|
1886 | pwp->w = pwp->iWeight; |
---|
1887 | pwp->o = pwp->iOffset * offsetScalingFactor; //NOTE: This value of the ".o" variable is never used - .o is set immediately before it gets used |
---|
1888 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
1889 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
1890 | } |
---|
1891 | } |
---|
1892 | } |
---|
1893 | } |
---|
1894 | |
---|
1895 | // ------------------------------------------------------------------------------------------------ |
---|
1896 | // Video parameter set (VPS) |
---|
1897 | // ------------------------------------------------------------------------------------------------ |
---|
1898 | #if SVC_EXTENSION |
---|
1899 | TComVPS::TComVPS() |
---|
1900 | : m_VPSId ( 0) |
---|
1901 | , m_uiMaxTLayers ( 1) |
---|
1902 | , m_uiMaxLayers ( 1) |
---|
1903 | , m_bTemporalIdNestingFlag (false) |
---|
1904 | , m_numHrdParameters ( 0) |
---|
1905 | , m_hrdParameters () |
---|
1906 | , m_hrdOpSetIdx () |
---|
1907 | , m_cprmsPresentFlag () |
---|
1908 | , m_baseLayerInternalFlag (true) |
---|
1909 | , m_baseLayerAvailableFlag (true) |
---|
1910 | , m_maxLayerId (0) |
---|
1911 | , m_numLayerSets (0) |
---|
1912 | , m_numOutputLayerSets (0) |
---|
1913 | , m_numProfileTierLevel (0) |
---|
1914 | , m_numAddOutputLayerSets (0) |
---|
1915 | , m_defaultTargetOutputLayerIdc(0) |
---|
1916 | , m_bitRatePresentVpsFlag (false) |
---|
1917 | , m_picRatePresentVpsFlag (false) |
---|
1918 | , m_repFormatIdxPresentFlag (false) |
---|
1919 | , m_vpsNumRepFormats (1) |
---|
1920 | , m_viewIdLen (0) |
---|
1921 | , m_vpsNonVuiExtLength (0) |
---|
1922 | , m_vpsPocLsbAlignedFlag(false) |
---|
1923 | { |
---|
1924 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
1925 | { |
---|
1926 | m_numReorderPics[i] = 0; |
---|
1927 | m_uiMaxDecPicBuffering[i] = 1; |
---|
1928 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1929 | } |
---|
1930 | |
---|
1931 | m_nonHEVCBaseLayerFlag = false; |
---|
1932 | m_splittingFlag = false; |
---|
1933 | m_nuhLayerIdPresentFlag = false; |
---|
1934 | ::memset(m_scalabilityMask, 0, sizeof(m_scalabilityMask)); |
---|
1935 | ::memset(m_dimensionIdLen, 0, sizeof(m_dimensionIdLen)); |
---|
1936 | ::memset(m_layerIdInNuh, 0, sizeof(m_layerIdInNuh)); |
---|
1937 | ::memset(m_dimensionId, 0, sizeof(m_dimensionId)); |
---|
1938 | |
---|
1939 | m_numScalabilityTypes = 0; |
---|
1940 | ::memset(m_layerIdxInVps, 0, sizeof(m_layerIdxInVps)); |
---|
1941 | ::memset(m_profilePresentFlag, 0, sizeof(m_profilePresentFlag)); |
---|
1942 | |
---|
1943 | ::memset(m_layerIdIncludedFlag, 0, sizeof(m_layerIdIncludedFlag)); |
---|
1944 | // Consider dynamic allocation for outputLayerSetIdx and outputLayerFlag |
---|
1945 | ::memset(m_outputLayerSetIdx, 0, sizeof(m_outputLayerSetIdx)); |
---|
1946 | ::memset(m_outputLayerFlag, 0, sizeof(m_outputLayerFlag)); |
---|
1947 | |
---|
1948 | ::memset(m_directDependencyFlag, 0, sizeof(m_directDependencyFlag)); |
---|
1949 | ::memset(m_numDirectRefLayers, 0, sizeof(m_numDirectRefLayers )); |
---|
1950 | ::memset(m_refLayerId, 0, sizeof(m_refLayerId )); |
---|
1951 | m_directDepTypeLen = 2; |
---|
1952 | ::memset(m_directDependencyType, 0, sizeof(m_directDependencyType)); |
---|
1953 | |
---|
1954 | m_maxOneActiveRefLayerFlag = true; |
---|
1955 | ::memset(m_pocLsbNotPresentFlag, 0, sizeof(m_pocLsbNotPresentFlag)); |
---|
1956 | m_crossLayerPictureTypeAlignFlag = true; |
---|
1957 | m_crossLayerIrapAlignFlag = true; |
---|
1958 | m_crossLayerAlignedIdrOnlyFlag = false; |
---|
1959 | m_maxTidRefPresentFlag = true; |
---|
1960 | for( Int i = 0; i < MAX_VPS_LAYER_IDX_PLUS1 - 1; i++) |
---|
1961 | { |
---|
1962 | for( Int j = 0; j < MAX_VPS_LAYER_IDX_PLUS1; j++) |
---|
1963 | { |
---|
1964 | m_maxTidIlRefPicsPlus1[i][j] = m_uiMaxTLayers + 1; |
---|
1965 | } |
---|
1966 | } |
---|
1967 | |
---|
1968 | m_tilesNotInUseFlag = true; |
---|
1969 | m_wppNotInUseFlag = true; |
---|
1970 | ::memset(m_tilesInUseFlag, 0, sizeof(m_tilesInUseFlag)); |
---|
1971 | ::memset(m_loopFilterNotAcrossTilesFlag, 0, sizeof(m_loopFilterNotAcrossTilesFlag)); |
---|
1972 | ::memset(m_tileBoundariesAlignedFlag, 0, sizeof(m_tileBoundariesAlignedFlag)); |
---|
1973 | ::memset(m_wppInUseFlag, 0, sizeof(m_wppInUseFlag)); |
---|
1974 | |
---|
1975 | m_ilpRestrictedRefLayersFlag = false; |
---|
1976 | ::memset(m_minSpatialSegmentOffsetPlus1, 0, sizeof(m_minSpatialSegmentOffsetPlus1)); |
---|
1977 | ::memset(m_ctuBasedOffsetEnabledFlag, 0, sizeof(m_ctuBasedOffsetEnabledFlag)); |
---|
1978 | ::memset(m_minHorizontalCtuOffsetPlus1, 0, sizeof(m_minHorizontalCtuOffsetPlus1)); |
---|
1979 | |
---|
1980 | m_vidSigPresentVpsFlag=true; |
---|
1981 | m_vpsVidSigInfo=1; |
---|
1982 | ::memset( m_vpsVidSigIdx, 0, sizeof(m_vpsVidSigIdx) ); |
---|
1983 | m_vpsVidSigIdx[0]=0; |
---|
1984 | for (Int i=0; i < 16; i++) |
---|
1985 | { |
---|
1986 | m_vpsVidFormat[i] = 5; |
---|
1987 | m_vpsFullRangeFlag[i] = false; |
---|
1988 | m_vpsColorPrimaries[i] = 2; |
---|
1989 | m_vpsTransChar[i] = 2; |
---|
1990 | m_vpsMatCoeff[i] = 2; |
---|
1991 | } |
---|
1992 | |
---|
1993 | ::memset( m_bitRatePresentFlag, 0, sizeof(m_bitRatePresentFlag) ); |
---|
1994 | ::memset( m_picRatePresentFlag, 0, sizeof(m_picRatePresentFlag) ); |
---|
1995 | ::memset( m_avgBitRate , 0, sizeof(m_avgBitRate) ); |
---|
1996 | ::memset( m_maxBitRate , 0, sizeof(m_maxBitRate) ); |
---|
1997 | ::memset( m_constPicRateIdc , 0, sizeof(m_constPicRateIdc) ); |
---|
1998 | ::memset( m_avgPicRate , 0, sizeof(m_avgPicRate) ); |
---|
1999 | ::memset( m_vpsRepFormatIdx , 0, sizeof(m_vpsRepFormatIdx) ); |
---|
2000 | ::memset( m_viewIdVal , 0, sizeof(m_viewIdVal)) ; |
---|
2001 | |
---|
2002 | for( Int i = 0; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
2003 | { |
---|
2004 | m_numberRefLayers[i] = 0; |
---|
2005 | for( Int j = 0; j < MAX_NUM_LAYER_IDS; j++ ) |
---|
2006 | { |
---|
2007 | m_recursiveRefLayerFlag[i][j] = 0; |
---|
2008 | } |
---|
2009 | } |
---|
2010 | |
---|
2011 | ::memset( m_subLayerFlagInfoPresentFlag, 0, sizeof(m_subLayerFlagInfoPresentFlag ) ); |
---|
2012 | ::memset( m_subLayerDpbInfoPresentFlag, 0, sizeof(m_subLayerDpbInfoPresentFlag ) ); |
---|
2013 | ::memset( m_maxVpsDecPicBufferingMinus1, 0, sizeof(m_maxVpsDecPicBufferingMinus1 ) ); |
---|
2014 | ::memset( m_maxVpsNumReorderPics, 0, sizeof(m_maxVpsNumReorderPics ) ); |
---|
2015 | ::memset( m_maxVpsLatencyIncreasePlus1, 0, sizeof(m_maxVpsLatencyIncreasePlus1 ) ); |
---|
2016 | ::memset( m_numSubDpbs , 0, sizeof(m_numSubDpbs) ); |
---|
2017 | ::memset( m_baseLayerPSCompatibilityFlag, 0, sizeof(m_baseLayerPSCompatibilityFlag) ); |
---|
2018 | } |
---|
2019 | #else |
---|
2020 | TComVPS::TComVPS() |
---|
2021 | : m_VPSId ( 0) |
---|
2022 | , m_uiMaxTLayers ( 1) |
---|
2023 | , m_uiMaxLayers ( 1) |
---|
2024 | , m_bTemporalIdNestingFlag (false) |
---|
2025 | , m_numHrdParameters ( 0) |
---|
2026 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
2027 | , m_hrdParameters () |
---|
2028 | , m_hrdOpSetIdx () |
---|
2029 | , m_cprmsPresentFlag () |
---|
2030 | { |
---|
2031 | |
---|
2032 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
2033 | { |
---|
2034 | m_numReorderPics[i] = 0; |
---|
2035 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2036 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2037 | } |
---|
2038 | } |
---|
2039 | #endif //SVC_EXTENSION |
---|
2040 | |
---|
2041 | TComVPS::~TComVPS() |
---|
2042 | { |
---|
2043 | } |
---|
2044 | |
---|
2045 | // ------------------------------------------------------------------------------------------------ |
---|
2046 | // Sequence parameter set (SPS) |
---|
2047 | // ------------------------------------------------------------------------------------------------ |
---|
2048 | |
---|
2049 | TComSPS::TComSPS() |
---|
2050 | : m_SPSId ( 0) |
---|
2051 | , m_VPSId ( 0) |
---|
2052 | , m_chromaFormatIdc (CHROMA_420) |
---|
2053 | , m_uiMaxTLayers ( 1) |
---|
2054 | // Structure |
---|
2055 | , m_picWidthInLumaSamples (352) |
---|
2056 | , m_picHeightInLumaSamples (288) |
---|
2057 | , m_log2MinCodingBlockSize ( 0) |
---|
2058 | , m_log2DiffMaxMinCodingBlockSize(0) |
---|
2059 | , m_uiMaxCUWidth ( 32) |
---|
2060 | , m_uiMaxCUHeight ( 32) |
---|
2061 | , m_uiMaxCUDepth ( 3) |
---|
2062 | , m_bLongTermRefsPresent (false) |
---|
2063 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
2064 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
2065 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
2066 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
2067 | // Tool list |
---|
2068 | , m_usePCM (false) |
---|
2069 | , m_pcmLog2MaxSize ( 5) |
---|
2070 | , m_uiPCMLog2MinSize ( 7) |
---|
2071 | , m_useExtendedPrecision (false) |
---|
2072 | , m_useHighPrecisionPredictionWeighting(false) |
---|
2073 | , m_useResidualRotation (false) |
---|
2074 | , m_useSingleSignificanceMapContext(false) |
---|
2075 | , m_useGolombRiceParameterAdaptation(false) |
---|
2076 | , m_alignCABACBeforeBypass (false) |
---|
2077 | , m_bPCMFilterDisableFlag (false) |
---|
2078 | , m_disableIntraReferenceSmoothing(false) |
---|
2079 | , m_uiBitsForPOC ( 8) |
---|
2080 | , m_numLongTermRefPicSPS ( 0) |
---|
2081 | , m_uiMaxTrSize ( 32) |
---|
2082 | , m_bUseSAO (false) |
---|
2083 | , m_bTemporalIdNestingFlag (false) |
---|
2084 | , m_scalingListEnabledFlag (false) |
---|
2085 | , m_useStrongIntraSmoothing (false) |
---|
2086 | , m_vuiParametersPresentFlag (false) |
---|
2087 | , m_vuiParameters () |
---|
2088 | #if SVC_EXTENSION |
---|
2089 | , m_layerId ( 0 ) |
---|
2090 | , m_extensionFlag ( false ) |
---|
2091 | , m_bV1CompatibleSPSFlag ( 0) |
---|
2092 | , m_updateRepFormatFlag (false) |
---|
2093 | , m_updateRepFormatIndex (0) |
---|
2094 | , m_inferScalingListFlag ( false ) |
---|
2095 | , m_scalingListRefLayerId ( 0 ) |
---|
2096 | #endif //SVC_EXTENSION |
---|
2097 | { |
---|
2098 | for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
2099 | { |
---|
2100 | m_uiBitDepth [ch] = 8; |
---|
2101 | m_uiPCMBitDepth[ch] = 8; |
---|
2102 | m_qpBDOffset [ch] = 0; |
---|
2103 | } |
---|
2104 | |
---|
2105 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
2106 | { |
---|
2107 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2108 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2109 | m_numReorderPics[i] = 0; |
---|
2110 | } |
---|
2111 | |
---|
2112 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
---|
2113 | { |
---|
2114 | m_useResidualDPCM[signallingModeIndex] = false; |
---|
2115 | } |
---|
2116 | |
---|
2117 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
2118 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
2119 | } |
---|
2120 | |
---|
2121 | TComSPS::~TComSPS() |
---|
2122 | { |
---|
2123 | m_RPSList.destroy(); |
---|
2124 | } |
---|
2125 | |
---|
2126 | Void TComSPS::createRPSList( Int numRPS ) |
---|
2127 | { |
---|
2128 | m_RPSList.destroy(); |
---|
2129 | m_RPSList.create(numRPS); |
---|
2130 | } |
---|
2131 | |
---|
2132 | Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
2133 | { |
---|
2134 | if( !getVuiParametersPresentFlag() ) |
---|
2135 | { |
---|
2136 | return; |
---|
2137 | } |
---|
2138 | |
---|
2139 | TComVUI *vui = getVuiParameters(); |
---|
2140 | TComHRD *hrd = vui->getHrdParameters(); |
---|
2141 | |
---|
2142 | TimingInfo *timingInfo = vui->getTimingInfo(); |
---|
2143 | #if SVC_EXTENSION |
---|
2144 | if( m_layerId > 0 ) |
---|
2145 | { |
---|
2146 | timingInfo->setTimingInfoPresentFlag( false ); |
---|
2147 | return; |
---|
2148 | } |
---|
2149 | #endif |
---|
2150 | |
---|
2151 | timingInfo->setTimingInfoPresentFlag( true ); |
---|
2152 | switch( frameRate ) |
---|
2153 | { |
---|
2154 | case 24: |
---|
2155 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2156 | break; |
---|
2157 | case 25: |
---|
2158 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2159 | break; |
---|
2160 | case 30: |
---|
2161 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2162 | break; |
---|
2163 | case 50: |
---|
2164 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2165 | break; |
---|
2166 | case 60: |
---|
2167 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2168 | break; |
---|
2169 | default: |
---|
2170 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
---|
2171 | break; |
---|
2172 | } |
---|
2173 | |
---|
2174 | Bool rateCnt = ( bitRate > 0 ); |
---|
2175 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
2176 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
2177 | |
---|
2178 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
2179 | |
---|
2180 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
2181 | { |
---|
2182 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
2183 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
2184 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
2185 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
2186 | } |
---|
2187 | else |
---|
2188 | { |
---|
2189 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
2190 | } |
---|
2191 | |
---|
2192 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
2193 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
2194 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
2195 | |
---|
2196 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
2197 | if( randomAccess ) |
---|
2198 | { |
---|
2199 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
2200 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
2201 | } |
---|
2202 | else |
---|
2203 | { |
---|
2204 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
2205 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
2206 | } |
---|
2207 | |
---|
2208 | /* |
---|
2209 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
2210 | */ |
---|
2211 | Int i, j; |
---|
2212 | UInt bitrateValue, cpbSizeValue; |
---|
2213 | UInt duCpbSizeValue; |
---|
2214 | UInt duBitRateValue = 0; |
---|
2215 | |
---|
2216 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
2217 | { |
---|
2218 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
2219 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
2220 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
2221 | hrd->setCpbCntMinus1( i, 0 ); |
---|
2222 | |
---|
2223 | bitrateValue = bitRate; |
---|
2224 | cpbSizeValue = bitRate; // 1 second |
---|
2225 | duCpbSizeValue = bitRate/numDU; |
---|
2226 | duBitRateValue = bitRate; |
---|
2227 | |
---|
2228 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
2229 | { |
---|
2230 | hrd->setBitRateValueMinus1( i, j, 0, ( bitrateValue - 1 ) ); |
---|
2231 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
2232 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( duCpbSizeValue - 1 ) ); |
---|
2233 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
2234 | |
---|
2235 | hrd->setBitRateValueMinus1( i, j, 1, ( bitrateValue - 1) ); |
---|
2236 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
2237 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( duCpbSizeValue - 1 ) ); |
---|
2238 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
2239 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
2240 | } |
---|
2241 | } |
---|
2242 | } |
---|
2243 | |
---|
2244 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
2245 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
2246 | |
---|
2247 | TComPPS::TComPPS() |
---|
2248 | : m_PPSId (0) |
---|
2249 | , m_SPSId (0) |
---|
2250 | , m_picInitQPMinus26 (0) |
---|
2251 | , m_useDQP (false) |
---|
2252 | , m_bConstrainedIntraPred (false) |
---|
2253 | , m_bSliceChromaQpFlag (false) |
---|
2254 | , m_uiMaxCuDQPDepth (0) |
---|
2255 | , m_MaxCuChromaQpAdjDepth (0) |
---|
2256 | , m_ChromaQpAdjTableSize (0) |
---|
2257 | , m_chromaCbQpOffset (0) |
---|
2258 | , m_chromaCrQpOffset (0) |
---|
2259 | , m_numRefIdxL0DefaultActive (1) |
---|
2260 | , m_numRefIdxL1DefaultActive (1) |
---|
2261 | , m_useCrossComponentPrediction (false) |
---|
2262 | , m_TransquantBypassEnableFlag (false) |
---|
2263 | , m_useTransformSkip (false) |
---|
2264 | , m_transformSkipLog2MaxSize (2) |
---|
2265 | , m_dependentSliceSegmentsEnabledFlag(false) |
---|
2266 | , m_tilesEnabledFlag (false) |
---|
2267 | , m_entropyCodingSyncEnabledFlag (false) |
---|
2268 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
2269 | , m_uniformSpacingFlag (false) |
---|
2270 | , m_numTileColumnsMinus1 (0) |
---|
2271 | , m_numTileRowsMinus1 (0) |
---|
2272 | , m_signHideFlag (false) |
---|
2273 | , m_cabacInitPresentFlag (false) |
---|
2274 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
2275 | , m_loopFilterAcrossSlicesEnabledFlag(false) |
---|
2276 | , m_listsModificationPresentFlag (0) |
---|
2277 | , m_numExtraSliceHeaderBits (0) |
---|
2278 | |
---|
2279 | #if SVC_EXTENSION |
---|
2280 | , m_extensionFlag(false) |
---|
2281 | , m_layerId(0) |
---|
2282 | , m_inferScalingListFlag ( false ) |
---|
2283 | , m_scalingListRefLayerId ( 0 ) |
---|
2284 | , m_pocResetInfoPresentFlag (false) |
---|
2285 | , m_numRefLayerLocationOffsets ( 0 ) |
---|
2286 | #if CGS_3D_ASYMLUT |
---|
2287 | , m_nCGSFlag(0) |
---|
2288 | , m_nCGSOutputBitDepthY(0) |
---|
2289 | , m_nCGSOutputBitDepthC(0) |
---|
2290 | #endif |
---|
2291 | #endif //SVC_EXTENSION |
---|
2292 | { |
---|
2293 | for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
2294 | { |
---|
2295 | m_saoOffsetBitShift[ch] = 0; |
---|
2296 | } |
---|
2297 | m_ChromaQpAdjTable[0].u.comp.CbOffset = 0; |
---|
2298 | m_ChromaQpAdjTable[0].u.comp.CrOffset = 0; |
---|
2299 | |
---|
2300 | #if SVC_EXTENSION |
---|
2301 | ::memset(m_scaledRefLayerOffsetPresentFlag, 0, sizeof(m_scaledRefLayerOffsetPresentFlag)); |
---|
2302 | ::memset(m_refRegionOffsetPresentFlag, 0, sizeof(m_refRegionOffsetPresentFlag)); |
---|
2303 | #endif //SVC_EXTENSION |
---|
2304 | } |
---|
2305 | |
---|
2306 | TComPPS::~TComPPS() |
---|
2307 | { |
---|
2308 | } |
---|
2309 | |
---|
2310 | TComReferencePictureSet::TComReferencePictureSet() |
---|
2311 | : m_numberOfPictures (0) |
---|
2312 | , m_numberOfNegativePictures (0) |
---|
2313 | , m_numberOfPositivePictures (0) |
---|
2314 | , m_numberOfLongtermPictures (0) |
---|
2315 | , m_interRPSPrediction (0) |
---|
2316 | , m_deltaRIdxMinus1 (0) |
---|
2317 | , m_deltaRPS (0) |
---|
2318 | , m_numRefIdc (0) |
---|
2319 | { |
---|
2320 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
2321 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
2322 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
2323 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
2324 | ::memset( m_bCheckLTMSB, 0, sizeof(m_bCheckLTMSB) ); |
---|
2325 | ::memset( m_pocLSBLT, 0, sizeof(m_pocLSBLT) ); |
---|
2326 | ::memset( m_deltaPOCMSBCycleLT, 0, sizeof(m_deltaPOCMSBCycleLT) ); |
---|
2327 | ::memset( m_deltaPocMSBPresentFlag, 0, sizeof(m_deltaPocMSBPresentFlag) ); |
---|
2328 | } |
---|
2329 | |
---|
2330 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
2331 | { |
---|
2332 | } |
---|
2333 | |
---|
2334 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
2335 | { |
---|
2336 | m_used[bufferNum] = used; |
---|
2337 | } |
---|
2338 | |
---|
2339 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
2340 | { |
---|
2341 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
2342 | } |
---|
2343 | |
---|
2344 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
2345 | { |
---|
2346 | m_numberOfPictures = numberOfPictures; |
---|
2347 | } |
---|
2348 | |
---|
2349 | Int TComReferencePictureSet::getUsed(Int bufferNum) const |
---|
2350 | { |
---|
2351 | return m_used[bufferNum]; |
---|
2352 | } |
---|
2353 | |
---|
2354 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) const |
---|
2355 | { |
---|
2356 | return m_deltaPOC[bufferNum]; |
---|
2357 | } |
---|
2358 | |
---|
2359 | Int TComReferencePictureSet::getNumberOfPictures() const |
---|
2360 | { |
---|
2361 | return m_numberOfPictures; |
---|
2362 | } |
---|
2363 | |
---|
2364 | Int TComReferencePictureSet::getPOC(Int bufferNum) const |
---|
2365 | { |
---|
2366 | return m_POC[bufferNum]; |
---|
2367 | } |
---|
2368 | |
---|
2369 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
2370 | { |
---|
2371 | m_POC[bufferNum] = POC; |
---|
2372 | } |
---|
2373 | |
---|
2374 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) const |
---|
2375 | { |
---|
2376 | return m_bCheckLTMSB[bufferNum]; |
---|
2377 | } |
---|
2378 | |
---|
2379 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
2380 | { |
---|
2381 | m_bCheckLTMSB[bufferNum] = b; |
---|
2382 | } |
---|
2383 | |
---|
2384 | //! set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
2385 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
2386 | { |
---|
2387 | m_refIdc[bufferNum] = refIdc; |
---|
2388 | } |
---|
2389 | |
---|
2390 | //! get the reference idc value at uiBufferNum |
---|
2391 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) const |
---|
2392 | { |
---|
2393 | return m_refIdc[bufferNum]; |
---|
2394 | } |
---|
2395 | |
---|
2396 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
2397 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
2398 | * +ve values are in increasing order. |
---|
2399 | * \returns Void |
---|
2400 | */ |
---|
2401 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
2402 | { |
---|
2403 | // sort in increasing order (smallest first) |
---|
2404 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
2405 | { |
---|
2406 | Int deltaPOC = getDeltaPOC(j); |
---|
2407 | Bool used = getUsed(j); |
---|
2408 | for (Int k=j-1; k >= 0; k--) |
---|
2409 | { |
---|
2410 | Int temp = getDeltaPOC(k); |
---|
2411 | if (deltaPOC < temp) |
---|
2412 | { |
---|
2413 | setDeltaPOC(k+1, temp); |
---|
2414 | setUsed(k+1, getUsed(k)); |
---|
2415 | setDeltaPOC(k, deltaPOC); |
---|
2416 | setUsed(k, used); |
---|
2417 | } |
---|
2418 | } |
---|
2419 | } |
---|
2420 | // flip the negative values to largest first |
---|
2421 | Int numNegPics = getNumberOfNegativePictures(); |
---|
2422 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
2423 | { |
---|
2424 | Int deltaPOC = getDeltaPOC(j); |
---|
2425 | Bool used = getUsed(j); |
---|
2426 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
2427 | setUsed(j, getUsed(k)); |
---|
2428 | setDeltaPOC(k, deltaPOC); |
---|
2429 | setUsed(k, used); |
---|
2430 | } |
---|
2431 | } |
---|
2432 | |
---|
2433 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
2434 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
2435 | * \returns Void |
---|
2436 | */ |
---|
2437 | Void TComReferencePictureSet::printDeltaPOC() const |
---|
2438 | { |
---|
2439 | printf("DeltaPOC = { "); |
---|
2440 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
2441 | { |
---|
2442 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
2443 | } |
---|
2444 | if (getInterRPSPrediction()) |
---|
2445 | { |
---|
2446 | printf("}, RefIdc = { "); |
---|
2447 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
2448 | { |
---|
2449 | printf("%d ", getRefIdc(j)); |
---|
2450 | } |
---|
2451 | } |
---|
2452 | printf("}\n"); |
---|
2453 | } |
---|
2454 | |
---|
2455 | TComRefPicListModification::TComRefPicListModification() |
---|
2456 | : m_refPicListModificationFlagL0 (false) |
---|
2457 | , m_refPicListModificationFlagL1 (false) |
---|
2458 | { |
---|
2459 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
2460 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
2461 | } |
---|
2462 | |
---|
2463 | TComRefPicListModification::~TComRefPicListModification() |
---|
2464 | { |
---|
2465 | } |
---|
2466 | |
---|
2467 | TComScalingList::TComScalingList() |
---|
2468 | { |
---|
2469 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2470 | { |
---|
2471 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
2472 | { |
---|
2473 | m_scalingListCoef[sizeId][listId].resize(min<Int>(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2474 | } |
---|
2475 | } |
---|
2476 | } |
---|
2477 | |
---|
2478 | /** set default quantization matrix to array |
---|
2479 | */ |
---|
2480 | Void TComScalingList::setDefaultScalingList() |
---|
2481 | { |
---|
2482 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2483 | { |
---|
2484 | for(UInt listId=0;listId<SCALING_LIST_NUM;listId++) |
---|
2485 | { |
---|
2486 | processDefaultMatrix(sizeId, listId); |
---|
2487 | } |
---|
2488 | } |
---|
2489 | } |
---|
2490 | /** check if use default quantization matrix |
---|
2491 | * \returns true if use default quantization matrix in all size |
---|
2492 | */ |
---|
2493 | Bool TComScalingList::checkDefaultScalingList() |
---|
2494 | { |
---|
2495 | UInt defaultCounter=0; |
---|
2496 | |
---|
2497 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2498 | { |
---|
2499 | for(UInt listId=0;listId<SCALING_LIST_NUM;listId++) |
---|
2500 | { |
---|
2501 | if( !memcmp(getScalingListAddress(sizeId,listId), getScalingListDefaultAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
2502 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
2503 | { |
---|
2504 | defaultCounter++; |
---|
2505 | } |
---|
2506 | } |
---|
2507 | } |
---|
2508 | |
---|
2509 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM )) ? false : true; |
---|
2510 | } |
---|
2511 | |
---|
2512 | /** get scaling matrix from RefMatrixID |
---|
2513 | * \param sizeId size index |
---|
2514 | * \param listId index of input matrix |
---|
2515 | * \param refListId index of reference matrix |
---|
2516 | */ |
---|
2517 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
2518 | { |
---|
2519 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2520 | } |
---|
2521 | |
---|
2522 | Void TComScalingList::checkPredMode(UInt sizeId, UInt listId) |
---|
2523 | { |
---|
2524 | Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. |
---|
2525 | |
---|
2526 | for(Int predListIdx = (Int)listId ; predListIdx >= 0; predListIdx-=predListStep) |
---|
2527 | { |
---|
2528 | if( !memcmp(getScalingListAddress(sizeId,listId),((listId == predListIdx) ? |
---|
2529 | getScalingListDefaultAddress(sizeId, predListIdx): getScalingListAddress(sizeId, predListIdx)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
2530 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value |
---|
2531 | { |
---|
2532 | setRefMatrixId(sizeId, listId, predListIdx); |
---|
2533 | setScalingListPredModeFlag(sizeId, listId, false); |
---|
2534 | return; |
---|
2535 | } |
---|
2536 | } |
---|
2537 | setScalingListPredModeFlag(sizeId, listId, true); |
---|
2538 | } |
---|
2539 | |
---|
2540 | static Void outputScalingListHelp(std::ostream &os) |
---|
2541 | { |
---|
2542 | os << "The scaling list file specifies all matrices and their DC values; none can be missing,\n" |
---|
2543 | "but their order is arbitrary.\n\n" |
---|
2544 | "The matrices are specified by:\n" |
---|
2545 | "<matrix name><unchecked data>\n" |
---|
2546 | " <value>,<value>,<value>,....\n\n" |
---|
2547 | " Line-feeds can be added arbitrarily between values, and the number of values needs to be\n" |
---|
2548 | " at least the number of entries for the matrix (superfluous entries are ignored).\n" |
---|
2549 | " The <unchecked data> is text on the same line as the matrix that is not checked\n" |
---|
2550 | " except to ensure that the matrix name token is unique. It is recommended that it is ' ='\n" |
---|
2551 | " The values in the matrices are the absolute values (0-255), not the delta values as\n" |
---|
2552 | " exchanged between the encoder and decoder\n\n" |
---|
2553 | "The DC values (for matrix sizes larger than 8x8) are specified by:\n" |
---|
2554 | "<matrix name>_DC<unchecked data>\n" |
---|
2555 | " <value>\n"; |
---|
2556 | |
---|
2557 | os << "The permitted matrix names are:\n"; |
---|
2558 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
2559 | { |
---|
2560 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
2561 | { |
---|
2562 | if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0)) |
---|
2563 | { |
---|
2564 | os << " " << MatrixType[sizeIdc][listIdc] << '\n'; |
---|
2565 | } |
---|
2566 | } |
---|
2567 | } |
---|
2568 | } |
---|
2569 | |
---|
2570 | Void TComScalingList::outputScalingLists(std::ostream &os) const |
---|
2571 | { |
---|
2572 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
2573 | { |
---|
2574 | const UInt size = min(8,4<<(sizeIdc)); |
---|
2575 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
2576 | { |
---|
2577 | if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0)) |
---|
2578 | { |
---|
2579 | const Int *src = getScalingListAddress(sizeIdc, listIdc); |
---|
2580 | os << (MatrixType[sizeIdc][listIdc]) << " =\n "; |
---|
2581 | for(UInt y=0; y<size; y++) |
---|
2582 | { |
---|
2583 | for(UInt x=0; x<size; x++, src++) |
---|
2584 | { |
---|
2585 | os << std::setw(3) << (*src) << ", "; |
---|
2586 | } |
---|
2587 | os << (y+1<size?"\n ":"\n"); |
---|
2588 | } |
---|
2589 | if(sizeIdc > SCALING_LIST_8x8) |
---|
2590 | { |
---|
2591 | os << MatrixType_DC[sizeIdc][listIdc] << " = \n " << std::setw(3) << getScalingListDC(sizeIdc, listIdc) << "\n"; |
---|
2592 | } |
---|
2593 | os << "\n"; |
---|
2594 | } |
---|
2595 | } |
---|
2596 | } |
---|
2597 | } |
---|
2598 | |
---|
2599 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
2600 | { |
---|
2601 | static const Int LINE_SIZE=1024; |
---|
2602 | FILE *fp = NULL; |
---|
2603 | Char line[LINE_SIZE]; |
---|
2604 | |
---|
2605 | if (pchFile == NULL) |
---|
2606 | { |
---|
2607 | fprintf(stderr, "Error: no scaling list file specified. Help on scaling lists being output\n"); |
---|
2608 | outputScalingListHelp(std::cout); |
---|
2609 | std::cout << "\n\nExample scaling list file using default values:\n\n"; |
---|
2610 | outputScalingLists(std::cout); |
---|
2611 | exit (1); |
---|
2612 | return true; |
---|
2613 | } |
---|
2614 | else if ((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
2615 | { |
---|
2616 | fprintf(stderr, "Error: cannot open scaling list file %s for reading\n",pchFile); |
---|
2617 | return true; |
---|
2618 | } |
---|
2619 | |
---|
2620 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
2621 | { |
---|
2622 | const UInt size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
2623 | |
---|
2624 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
2625 | { |
---|
2626 | Int * const src = getScalingListAddress(sizeIdc, listIdc); |
---|
2627 | |
---|
2628 | if ((sizeIdc==SCALING_LIST_32x32) && (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) // derive chroma32x32 from chroma16x16 |
---|
2629 | { |
---|
2630 | const Int *srcNextSmallerSize = getScalingListAddress(sizeIdc-1, listIdc); |
---|
2631 | for(UInt i=0; i<size; i++) |
---|
2632 | { |
---|
2633 | src[i] = srcNextSmallerSize[i]; |
---|
2634 | } |
---|
2635 | setScalingListDC(sizeIdc,listIdc,(sizeIdc > SCALING_LIST_8x8) ? getScalingListDC(sizeIdc-1, listIdc) : src[0]); |
---|
2636 | } |
---|
2637 | else |
---|
2638 | { |
---|
2639 | { |
---|
2640 | fseek(fp, 0, SEEK_SET); |
---|
2641 | Bool bFound=false; |
---|
2642 | while ((!feof(fp)) && (!bFound)) |
---|
2643 | { |
---|
2644 | Char *ret = fgets(line, LINE_SIZE, fp); |
---|
2645 | Char *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType[sizeIdc][listIdc]); |
---|
2646 | // This could be a match against the DC string as well, so verify it isn't |
---|
2647 | if (findNamePosition!= NULL && (MatrixType_DC[sizeIdc][listIdc]==NULL || strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL)) |
---|
2648 | { |
---|
2649 | bFound=true; |
---|
2650 | } |
---|
2651 | } |
---|
2652 | if (!bFound) |
---|
2653 | { |
---|
2654 | fprintf(stderr, "Error: cannot find Matrix %s from scaling list file %s\n", MatrixType[sizeIdc][listIdc], pchFile); |
---|
2655 | return true; |
---|
2656 | } |
---|
2657 | } |
---|
2658 | for (UInt i=0; i<size; i++) |
---|
2659 | { |
---|
2660 | Int data; |
---|
2661 | if (fscanf(fp, "%d,", &data)!=1) |
---|
2662 | { |
---|
2663 | fprintf(stderr, "Error: cannot read value #%d for Matrix %s from scaling list file %s at file position %ld\n", i, MatrixType[sizeIdc][listIdc], pchFile, ftell(fp)); |
---|
2664 | return true; |
---|
2665 | } |
---|
2666 | if (data<0 || data>255) |
---|
2667 | { |
---|
2668 | fprintf(stderr, "Error: QMatrix entry #%d of value %d for Matrix %s from scaling list file %s at file position %ld is out of range (0 to 255)\n", i, data, MatrixType[sizeIdc][listIdc], pchFile, ftell(fp)); |
---|
2669 | return true; |
---|
2670 | } |
---|
2671 | src[i] = data; |
---|
2672 | } |
---|
2673 | |
---|
2674 | //set DC value for default matrix check |
---|
2675 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
2676 | |
---|
2677 | if(sizeIdc > SCALING_LIST_8x8) |
---|
2678 | { |
---|
2679 | { |
---|
2680 | fseek(fp, 0, SEEK_SET); |
---|
2681 | Bool bFound=false; |
---|
2682 | while ((!feof(fp)) && (!bFound)) |
---|
2683 | { |
---|
2684 | Char *ret = fgets(line, LINE_SIZE, fp); |
---|
2685 | Char *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType_DC[sizeIdc][listIdc]); |
---|
2686 | if (findNamePosition!= NULL) |
---|
2687 | { |
---|
2688 | // This won't be a match against the non-DC string. |
---|
2689 | bFound=true; |
---|
2690 | } |
---|
2691 | } |
---|
2692 | if (!bFound) |
---|
2693 | { |
---|
2694 | fprintf(stderr, "Error: cannot find DC Matrix %s from scaling list file %s\n", MatrixType_DC[sizeIdc][listIdc], pchFile); |
---|
2695 | return true; |
---|
2696 | } |
---|
2697 | } |
---|
2698 | Int data; |
---|
2699 | if (fscanf(fp, "%d,", &data)!=1) |
---|
2700 | { |
---|
2701 | fprintf(stderr, "Error: cannot read DC %s from scaling list file %s at file position %ld\n", MatrixType_DC[sizeIdc][listIdc], pchFile, ftell(fp)); |
---|
2702 | return true; |
---|
2703 | } |
---|
2704 | if (data<0 || data>255) |
---|
2705 | { |
---|
2706 | fprintf(stderr, "Error: DC value %d for Matrix %s from scaling list file %s at file position %ld is out of range (0 to 255)\n", data, MatrixType[sizeIdc][listIdc], pchFile, ftell(fp)); |
---|
2707 | return true; |
---|
2708 | } |
---|
2709 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
2710 | setScalingListDC(sizeIdc,listIdc,data); |
---|
2711 | } |
---|
2712 | } |
---|
2713 | } |
---|
2714 | } |
---|
2715 | // std::cout << "\n\nRead scaling lists of:\n\n"; |
---|
2716 | // outputScalingLists(std::cout); |
---|
2717 | |
---|
2718 | fclose(fp); |
---|
2719 | return false; |
---|
2720 | } |
---|
2721 | |
---|
2722 | |
---|
2723 | /** get default address of quantization matrix |
---|
2724 | * \param sizeId size index |
---|
2725 | * \param listId list index |
---|
2726 | * \returns pointer of quantization matrix |
---|
2727 | */ |
---|
2728 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
2729 | { |
---|
2730 | Int *src = 0; |
---|
2731 | switch(sizeId) |
---|
2732 | { |
---|
2733 | case SCALING_LIST_4x4: |
---|
2734 | src = g_quantTSDefault4x4; |
---|
2735 | break; |
---|
2736 | case SCALING_LIST_8x8: |
---|
2737 | case SCALING_LIST_16x16: |
---|
2738 | case SCALING_LIST_32x32: |
---|
2739 | src = (listId < (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) ) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2740 | break; |
---|
2741 | default: |
---|
2742 | assert(0); |
---|
2743 | src = NULL; |
---|
2744 | break; |
---|
2745 | } |
---|
2746 | return src; |
---|
2747 | } |
---|
2748 | |
---|
2749 | /** process of default matrix |
---|
2750 | * \param sizeId size index |
---|
2751 | * \param listId index of input matrix |
---|
2752 | */ |
---|
2753 | Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId) |
---|
2754 | { |
---|
2755 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2756 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
2757 | } |
---|
2758 | |
---|
2759 | /** check DC value of matrix for default matrix signaling |
---|
2760 | */ |
---|
2761 | Void TComScalingList::checkDcOfMatrix() |
---|
2762 | { |
---|
2763 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2764 | { |
---|
2765 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
2766 | { |
---|
2767 | //check default matrix? |
---|
2768 | if(getScalingListDC(sizeId,listId) == 0) |
---|
2769 | { |
---|
2770 | processDefaultMatrix(sizeId, listId); |
---|
2771 | } |
---|
2772 | } |
---|
2773 | } |
---|
2774 | } |
---|
2775 | |
---|
2776 | ParameterSetManager::ParameterSetManager() |
---|
2777 | #if SVC_EXTENSION |
---|
2778 | : m_activeSPS() |
---|
2779 | #else |
---|
2780 | : m_vpsMap(MAX_NUM_VPS) |
---|
2781 | , m_spsMap(MAX_NUM_SPS) |
---|
2782 | , m_ppsMap(MAX_NUM_PPS) |
---|
2783 | , m_activeVPS() |
---|
2784 | , m_activeSPS() |
---|
2785 | #endif |
---|
2786 | { |
---|
2787 | #if !SVC_EXTENSION |
---|
2788 | m_activeVPS.setVPSId(-1); |
---|
2789 | #endif |
---|
2790 | m_activeSPS.setSPSId(-1); |
---|
2791 | } |
---|
2792 | |
---|
2793 | |
---|
2794 | ParameterSetManager::~ParameterSetManager() |
---|
2795 | { |
---|
2796 | } |
---|
2797 | |
---|
2798 | //! activate a SPS from a active parameter sets SEI message |
---|
2799 | //! \returns true, if activation is successful |
---|
2800 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
2801 | { |
---|
2802 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
2803 | if (sps) |
---|
2804 | { |
---|
2805 | Int vpsId = sps->getVPSId(); |
---|
2806 | TComVPS *vps = m_vpsMap.getPS(vpsId); |
---|
2807 | if (vps) |
---|
2808 | { |
---|
2809 | m_activeVPS = *(vps); |
---|
2810 | m_activeSPS = *(sps); |
---|
2811 | return true; |
---|
2812 | } |
---|
2813 | else |
---|
2814 | { |
---|
2815 | printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
2816 | } |
---|
2817 | } |
---|
2818 | else |
---|
2819 | { |
---|
2820 | printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
2821 | } |
---|
2822 | return false; |
---|
2823 | } |
---|
2824 | |
---|
2825 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
2826 | //! \returns true, if activation is successful |
---|
2827 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
2828 | { |
---|
2829 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
2830 | if (pps) |
---|
2831 | { |
---|
2832 | Int spsId = pps->getSPSId(); |
---|
2833 | if (!isIRAP && (spsId != m_activeSPS.getSPSId() )) |
---|
2834 | { |
---|
2835 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IDR."); |
---|
2836 | return false; |
---|
2837 | } |
---|
2838 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
2839 | if (sps) |
---|
2840 | { |
---|
2841 | Int vpsId = sps->getVPSId(); |
---|
2842 | if (!isIRAP && (vpsId != m_activeVPS.getVPSId() )) |
---|
2843 | { |
---|
2844 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IDR."); |
---|
2845 | return false; |
---|
2846 | } |
---|
2847 | TComVPS *vps =m_vpsMap.getPS(vpsId); |
---|
2848 | if (vps) |
---|
2849 | { |
---|
2850 | m_activeVPS = *(vps); |
---|
2851 | m_activeSPS = *(sps); |
---|
2852 | #if SVC_EXTENSION |
---|
2853 | m_activePPS = *(pps); |
---|
2854 | #endif |
---|
2855 | return true; |
---|
2856 | } |
---|
2857 | else |
---|
2858 | { |
---|
2859 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
2860 | } |
---|
2861 | } |
---|
2862 | else |
---|
2863 | { |
---|
2864 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
2865 | } |
---|
2866 | } |
---|
2867 | else |
---|
2868 | { |
---|
2869 | printf("Warning: tried to activate non-existing PPS."); |
---|
2870 | } |
---|
2871 | return false; |
---|
2872 | } |
---|
2873 | |
---|
2874 | ProfileTierLevel::ProfileTierLevel() |
---|
2875 | : m_profileSpace (0) |
---|
2876 | , m_tierFlag (Level::MAIN) |
---|
2877 | , m_profileIdc (Profile::NONE) |
---|
2878 | , m_levelIdc (Level::NONE) |
---|
2879 | , m_progressiveSourceFlag (false) |
---|
2880 | , m_interlacedSourceFlag (false) |
---|
2881 | , m_nonPackedConstraintFlag(false) |
---|
2882 | , m_frameOnlyConstraintFlag(false) |
---|
2883 | { |
---|
2884 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
2885 | } |
---|
2886 | |
---|
2887 | TComPTL::TComPTL() |
---|
2888 | { |
---|
2889 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
2890 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
2891 | } |
---|
2892 | |
---|
2893 | Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> *pNewData) |
---|
2894 | { |
---|
2895 | if (!bChanged) |
---|
2896 | { |
---|
2897 | if ((pOldData==0 && pOldData!=0) || (pOldData!=0 && pOldData==0)) |
---|
2898 | { |
---|
2899 | bChanged=true; |
---|
2900 | } |
---|
2901 | else if (pOldData!=0 && pOldData!=0) |
---|
2902 | { |
---|
2903 | // compare the two |
---|
2904 | if (pOldData->size() != pOldData->size()) |
---|
2905 | { |
---|
2906 | bChanged=true; |
---|
2907 | } |
---|
2908 | else |
---|
2909 | { |
---|
2910 | const UChar *pNewDataArray=&(*pNewData)[0]; |
---|
2911 | const UChar *pOldDataArray=&(*pOldData)[0]; |
---|
2912 | if (memcmp(pOldDataArray, pNewDataArray, pOldData->size())) |
---|
2913 | { |
---|
2914 | bChanged=true; |
---|
2915 | } |
---|
2916 | } |
---|
2917 | } |
---|
2918 | } |
---|
2919 | } |
---|
2920 | |
---|
2921 | #if SVC_EXTENSION |
---|
2922 | Void ProfileTierLevel::copyProfileInfo(ProfileTierLevel *ptl) |
---|
2923 | { |
---|
2924 | this->setProfileSpace ( ptl->getProfileSpace() ); |
---|
2925 | this->setTierFlag ( ptl->getTierFlag() ); |
---|
2926 | this->setProfileIdc ( ptl->getProfileIdc() ); |
---|
2927 | for(Int j = 0; j < 32; j++) |
---|
2928 | { |
---|
2929 | this->setProfileCompatibilityFlag(j, ptl->getProfileCompatibilityFlag(j)); |
---|
2930 | } |
---|
2931 | this->setProgressiveSourceFlag ( ptl->getProgressiveSourceFlag() ); |
---|
2932 | this->setInterlacedSourceFlag ( ptl->getInterlacedSourceFlag() ); |
---|
2933 | this->setNonPackedConstraintFlag( ptl->getNonPackedConstraintFlag()); |
---|
2934 | this->setFrameOnlyConstraintFlag( ptl->getFrameOnlyConstraintFlag()); |
---|
2935 | } |
---|
2936 | |
---|
2937 | const Window& TComPPS::getScaledRefLayerWindowForLayer(Int layerId) const |
---|
2938 | { |
---|
2939 | static const Window win; |
---|
2940 | |
---|
2941 | for( Int i = m_numRefLayerLocationOffsets-1; i >= 0; i-- ) |
---|
2942 | { |
---|
2943 | if( layerId == m_refLocationOffsetLayerId[i] ) |
---|
2944 | { |
---|
2945 | return m_scaledRefLayerWindow[i]; |
---|
2946 | } |
---|
2947 | } |
---|
2948 | |
---|
2949 | return win; |
---|
2950 | } |
---|
2951 | |
---|
2952 | const Window& TComPPS::getRefLayerWindowForLayer(Int layerId) const |
---|
2953 | { |
---|
2954 | static const Window win; |
---|
2955 | |
---|
2956 | for( Int i = m_numRefLayerLocationOffsets-1; i >= 0; i-- ) |
---|
2957 | { |
---|
2958 | if( layerId == m_refLocationOffsetLayerId[i] ) |
---|
2959 | { |
---|
2960 | return m_refLayerWindow[i]; |
---|
2961 | } |
---|
2962 | } |
---|
2963 | |
---|
2964 | return win; |
---|
2965 | } |
---|
2966 | |
---|
2967 | Bool TComPPS::hasZeroResamplingPhase(Int refLayerId) const |
---|
2968 | { |
---|
2969 | const ResamplingPhase &resamplingPhase = getResamplingPhase(refLayerId); |
---|
2970 | |
---|
2971 | return ( resamplingPhase.phaseHorLuma == 0 && resamplingPhase.phaseHorChroma == 0 && resamplingPhase.phaseVerLuma == 0 && resamplingPhase.phaseVerChroma == 0 ); |
---|
2972 | } |
---|
2973 | |
---|
2974 | const ResamplingPhase& TComPPS::getResamplingPhase(Int refLayerId) const |
---|
2975 | { |
---|
2976 | static const ResamplingPhase resamplingPhase; |
---|
2977 | |
---|
2978 | for( Int i = m_numRefLayerLocationOffsets-1; i >= 0; i-- ) |
---|
2979 | { |
---|
2980 | if( refLayerId == m_refLocationOffsetLayerId[i] ) |
---|
2981 | { |
---|
2982 | return m_resamplingPhase[i]; |
---|
2983 | } |
---|
2984 | } |
---|
2985 | |
---|
2986 | return resamplingPhase; |
---|
2987 | } |
---|
2988 | |
---|
2989 | Void TComVPS::deriveLayerIdListVariables() |
---|
2990 | { |
---|
2991 | // For layer 0 |
---|
2992 | m_numLayerInIdList.push_back(1); |
---|
2993 | m_layerSetLayerIdList.resize(m_vpsNumLayerSetsMinus1 + 1); |
---|
2994 | m_layerSetLayerIdList[0].push_back(0); |
---|
2995 | |
---|
2996 | // For other layers |
---|
2997 | for (Int i = 1; i <= m_vpsNumLayerSetsMinus1; i++) |
---|
2998 | { |
---|
2999 | for( Int m = 0; m <= m_maxLayerId; m++) |
---|
3000 | { |
---|
3001 | if( m_layerIdIncludedFlag[i][m] ) |
---|
3002 | { |
---|
3003 | m_layerSetLayerIdList[i].push_back(m); |
---|
3004 | } |
---|
3005 | } |
---|
3006 | m_numLayerInIdList.push_back((Int)m_layerSetLayerIdList[i].size()); |
---|
3007 | } |
---|
3008 | } |
---|
3009 | |
---|
3010 | Void TComVPS::deriveNumberOfSubDpbs() |
---|
3011 | { |
---|
3012 | // Derive number of sub-DPBs |
---|
3013 | // For layer set 0 |
---|
3014 | m_numSubDpbs[0] = 1; |
---|
3015 | // For other layer sets |
---|
3016 | for( Int i = 1; i < m_numLayerSets; i++) |
---|
3017 | { |
---|
3018 | m_numSubDpbs[i] = m_numLayerInIdList[i]; |
---|
3019 | } |
---|
3020 | } |
---|
3021 | |
---|
3022 | Void TComVPS::setTilesNotInUseFlag(Bool x) |
---|
3023 | { |
---|
3024 | m_tilesNotInUseFlag = x; |
---|
3025 | |
---|
3026 | if( m_tilesNotInUseFlag ) |
---|
3027 | { |
---|
3028 | for( Int i = 0; i < getMaxLayers(); i++ ) |
---|
3029 | { |
---|
3030 | m_tilesInUseFlag[i] = m_loopFilterNotAcrossTilesFlag[i] = m_tilesNotInUseFlag; |
---|
3031 | } |
---|
3032 | |
---|
3033 | for( Int i = 1; i < getMaxLayers(); i++ ) |
---|
3034 | { |
---|
3035 | for( Int j = 0; j < getNumDirectRefLayers(getLayerIdInNuh(i)); j++) |
---|
3036 | { |
---|
3037 | setTileBoundariesAlignedFlag(i, j, m_tilesNotInUseFlag); |
---|
3038 | } |
---|
3039 | } |
---|
3040 | } |
---|
3041 | } |
---|
3042 | |
---|
3043 | Void TComVPS::setWppNotInUseFlag(Bool x) |
---|
3044 | { |
---|
3045 | m_wppNotInUseFlag = x; |
---|
3046 | |
---|
3047 | if( m_wppNotInUseFlag ) |
---|
3048 | { |
---|
3049 | for( Int i = 0; i < getMaxLayers(); i++ ) |
---|
3050 | { |
---|
3051 | m_wppInUseFlag[i] = m_wppNotInUseFlag; |
---|
3052 | } |
---|
3053 | } |
---|
3054 | } |
---|
3055 | |
---|
3056 | Void TComVPS::setRefLayersFlags(Int currLayerId) |
---|
3057 | { |
---|
3058 | for (Int i = 0; i < m_numDirectRefLayers[currLayerId]; i++) |
---|
3059 | { |
---|
3060 | UInt refLayerId = getRefLayerId(currLayerId, i); |
---|
3061 | m_recursiveRefLayerFlag[currLayerId][refLayerId] = true; |
---|
3062 | for (Int k = 0; k < MAX_NUM_LAYER_IDS; k++) |
---|
3063 | { |
---|
3064 | m_recursiveRefLayerFlag[currLayerId][k] = m_recursiveRefLayerFlag[currLayerId][k] | m_recursiveRefLayerFlag[refLayerId][k]; |
---|
3065 | } |
---|
3066 | } |
---|
3067 | } |
---|
3068 | |
---|
3069 | Void TComVPS::setNumRefLayers() |
---|
3070 | { |
---|
3071 | memset( m_numberRefLayers, 0, sizeof( m_numberRefLayers ) ); |
---|
3072 | |
---|
3073 | for (Int i = 0; i < m_uiMaxLayers; i++) |
---|
3074 | { |
---|
3075 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
3076 | setRefLayersFlags(iNuhLId); |
---|
3077 | for (UInt j = 0; j < MAX_NUM_LAYER_IDS; j++) |
---|
3078 | { |
---|
3079 | m_numberRefLayers[iNuhLId] += (m_recursiveRefLayerFlag[iNuhLId][j] == true ? 1 : 0); |
---|
3080 | } |
---|
3081 | } |
---|
3082 | } |
---|
3083 | |
---|
3084 | Void TComVPS::setPredictedLayerIds() |
---|
3085 | { |
---|
3086 | for (UInt i = 0; i < m_uiMaxLayers - 1; i++) |
---|
3087 | { |
---|
3088 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
3089 | UInt predIdx = 0; |
---|
3090 | for (UInt j = iNuhLId + 1; j < MAX_NUM_LAYER_IDS; j++) |
---|
3091 | { |
---|
3092 | if( m_recursiveRefLayerFlag[j][iNuhLId] ) |
---|
3093 | { |
---|
3094 | m_predictedLayerId[iNuhLId][predIdx] = j; |
---|
3095 | predIdx++; |
---|
3096 | } |
---|
3097 | } |
---|
3098 | m_numPredictedLayers[iNuhLId] = predIdx; |
---|
3099 | } |
---|
3100 | m_numPredictedLayers[m_layerIdInNuh[m_uiMaxLayers-1]] = 0; |
---|
3101 | } |
---|
3102 | |
---|
3103 | Void TComVPS::setTreePartitionLayerIdList() |
---|
3104 | { |
---|
3105 | Bool countedLayerIdxFlag[MAX_NUM_LAYER_IDS]; |
---|
3106 | memset( countedLayerIdxFlag, 0, sizeof(countedLayerIdxFlag) ); |
---|
3107 | |
---|
3108 | Int numIndependentLayers = 0; |
---|
3109 | |
---|
3110 | for (UInt i = 0; i < m_uiMaxLayers; i++) |
---|
3111 | { |
---|
3112 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
3113 | if( m_numDirectRefLayers[iNuhLId] == 0 ) |
---|
3114 | { |
---|
3115 | m_treePartitionLayerIdList[numIndependentLayers][0] = iNuhLId; |
---|
3116 | m_numLayersInTreePartition[numIndependentLayers] = 1; |
---|
3117 | for( UInt j = 0; j < m_numPredictedLayers[iNuhLId]; j++ ) |
---|
3118 | { |
---|
3119 | if( !countedLayerIdxFlag[m_layerIdxInVps[iNuhLId]] ) |
---|
3120 | { |
---|
3121 | m_treePartitionLayerIdList[numIndependentLayers][m_numLayersInTreePartition[numIndependentLayers]] = m_predictedLayerId[iNuhLId][j]; |
---|
3122 | m_numLayersInTreePartition[numIndependentLayers] = m_numLayersInTreePartition[numIndependentLayers] + 1; |
---|
3123 | countedLayerIdxFlag[m_layerIdxInVps[m_predictedLayerId[iNuhLId][j]]] = true; |
---|
3124 | } |
---|
3125 | } |
---|
3126 | numIndependentLayers++; |
---|
3127 | } |
---|
3128 | } |
---|
3129 | |
---|
3130 | m_numIndependentLayers = numIndependentLayers; |
---|
3131 | } |
---|
3132 | |
---|
3133 | Void TComVPS::deriveLayerIdListVariablesForAddLayerSets() |
---|
3134 | { |
---|
3135 | m_layerSetLayerIdList.resize(m_vpsNumLayerSetsMinus1 + 1 + m_numAddLayerSets); |
---|
3136 | |
---|
3137 | for (UInt i = 0; i < m_numAddLayerSets; i++) |
---|
3138 | { |
---|
3139 | Int layerNum = 0; |
---|
3140 | Int lsIdx = m_vpsNumLayerSetsMinus1 + 1 + i; |
---|
3141 | for (Int treeIdx = 1; treeIdx < m_numIndependentLayers; treeIdx++) |
---|
3142 | { |
---|
3143 | for (Int layerCnt = 0; layerCnt < m_highestLayerIdxPlus1[i][treeIdx]; layerCnt++) |
---|
3144 | { |
---|
3145 | m_layerSetLayerIdList[lsIdx].push_back(m_treePartitionLayerIdList[treeIdx][layerCnt]); |
---|
3146 | layerNum++; |
---|
3147 | } |
---|
3148 | } |
---|
3149 | m_numLayerInIdList.push_back(layerNum); |
---|
3150 | } |
---|
3151 | } |
---|
3152 | |
---|
3153 | Int TComVPS::getNumViews() const |
---|
3154 | { |
---|
3155 | Int numViews = 1; |
---|
3156 | for( Int i = 0; i < m_uiMaxLayers; i++ ) |
---|
3157 | { |
---|
3158 | Int lId = m_layerIdInNuh[i]; |
---|
3159 | if( i > 0 && ( getViewIndex( lId ) != getScalabilityId( i - 1, VIEW_ORDER_INDEX ) ) ) |
---|
3160 | { |
---|
3161 | numViews++; |
---|
3162 | } |
---|
3163 | } |
---|
3164 | |
---|
3165 | return numViews; |
---|
3166 | } |
---|
3167 | |
---|
3168 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) const |
---|
3169 | { |
---|
3170 | return getScalabilityMask( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
3171 | } |
---|
3172 | |
---|
3173 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) const |
---|
3174 | { |
---|
3175 | assert( scalType >= 0 && scalType <= MAX_VPS_NUM_SCALABILITY_TYPES ); |
---|
3176 | assert( scalType == MAX_VPS_NUM_SCALABILITY_TYPES || getScalabilityMask( scalType ) ); |
---|
3177 | Int scalIdx = 0; |
---|
3178 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
3179 | { |
---|
3180 | scalIdx += ( getScalabilityMask( curScalType ) ? 1 : 0 ); |
---|
3181 | |
---|
3182 | } |
---|
3183 | |
---|
3184 | return scalIdx; |
---|
3185 | } |
---|
3186 | |
---|
3187 | Int TComVPS::getLayerIdcForOls( Int olsIdx, Int layerId ) const |
---|
3188 | { |
---|
3189 | Int layerIdc = -1; |
---|
3190 | UInt lsIdx = m_outputLayerSetIdx[olsIdx]; |
---|
3191 | |
---|
3192 | std::vector<Int>::const_iterator it = std::find( m_layerSetLayerIdList[lsIdx].begin(), m_layerSetLayerIdList[lsIdx].end(), layerId ); |
---|
3193 | |
---|
3194 | if( it != m_layerSetLayerIdList[lsIdx].end() ) |
---|
3195 | { |
---|
3196 | layerIdc = (Int)std::distance( m_layerSetLayerIdList[lsIdx].begin(), it ); |
---|
3197 | } |
---|
3198 | |
---|
3199 | assert( layerIdc >= 0 ); |
---|
3200 | |
---|
3201 | return layerIdc; |
---|
3202 | } |
---|
3203 | |
---|
3204 | Void TComVPS::determineSubDpbInfoFlags() |
---|
3205 | { |
---|
3206 | for(Int i = 1; i < getNumOutputLayerSets(); i++) |
---|
3207 | { |
---|
3208 | Int layerSetIdxForOutputLayerSet = getOutputLayerSetIdx( i ); |
---|
3209 | // For each output layer set, set the DPB size for each layer and the reorder/latency value the maximum for all layers |
---|
3210 | Bool checkFlagOuter = false; // Used to calculate sub_layer_flag_info_present_flag |
---|
3211 | Bool checkFlagInner[MAX_TLAYER]; // Used to calculate sub_layer_dpb_info_present_flag |
---|
3212 | |
---|
3213 | for(Int j = 0; j < getMaxTLayers(); j++) |
---|
3214 | { |
---|
3215 | // -------------------------------------------------------- |
---|
3216 | // To determine value of m_subLayerDpbInfoPresentFlag |
---|
3217 | // -------------------------------------------------------- |
---|
3218 | if( j == 0 ) // checkFlagInner[0] is always 1 |
---|
3219 | { |
---|
3220 | checkFlagInner[j] = true; // Always signal sub-layer DPB information for the first sub-layer |
---|
3221 | } |
---|
3222 | else |
---|
3223 | { |
---|
3224 | checkFlagInner[j] = false; // Initialize to be false. If the values of the current sub-layers matches with the earlier sub-layer, |
---|
3225 | // then will be continue to be false - i.e. the j-th sub-layer DPB info is not signaled |
---|
3226 | checkFlagInner[j] |= ( getMaxVpsNumReorderPics(i, j) != getMaxVpsNumReorderPics(i, j - 1) ); |
---|
3227 | |
---|
3228 | for(Int subDpbIdx = 0; subDpbIdx < getNumSubDpbs(layerSetIdxForOutputLayerSet) && !checkFlagInner[j]; subDpbIdx++) // If checkFlagInner[j] is true, break and signal the values |
---|
3229 | { |
---|
3230 | checkFlagInner[j] |= ( getMaxVpsDecPicBufferingMinus1(i, subDpbIdx, j - 1) != getMaxVpsDecPicBufferingMinus1(i, subDpbIdx, j) ); |
---|
3231 | } |
---|
3232 | } |
---|
3233 | // If checkFlagInner[j] = true, then some value needs to be signalled for the j-th sub-layer |
---|
3234 | setSubLayerDpbInfoPresentFlag( i, j, checkFlagInner[j] ); |
---|
3235 | } |
---|
3236 | |
---|
3237 | // -------------------------------------------------------- |
---|
3238 | // To determine value of m_subLayerFlagInfoPresentFlag |
---|
3239 | // -------------------------------------------------------- |
---|
3240 | |
---|
3241 | for(Int j = 1; j < getMaxTLayers(); j++) // Check if DPB info of any of non-zero sub-layers is signaled. If so set flag to one |
---|
3242 | { |
---|
3243 | if( getSubLayerDpbInfoPresentFlag(i, j) ) |
---|
3244 | { |
---|
3245 | checkFlagOuter = true; |
---|
3246 | break; |
---|
3247 | } |
---|
3248 | } |
---|
3249 | setSubLayerFlagInfoPresentFlag( i, checkFlagOuter ); |
---|
3250 | } |
---|
3251 | } |
---|
3252 | |
---|
3253 | #if O0164_MULTI_LAYER_HRD |
---|
3254 | Void TComVPS::setBspHrdParameters( UInt hrdIdx, UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
3255 | { |
---|
3256 | if( !getVpsVuiBspHrdPresentFlag() ) |
---|
3257 | { |
---|
3258 | return; |
---|
3259 | } |
---|
3260 | |
---|
3261 | TComHRD *hrd = getBspHrd(hrdIdx); |
---|
3262 | |
---|
3263 | Bool rateCnt = ( bitRate > 0 ); |
---|
3264 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
3265 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
3266 | |
---|
3267 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
3268 | |
---|
3269 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
3270 | { |
---|
3271 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
3272 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
3273 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
3274 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
3275 | } |
---|
3276 | else |
---|
3277 | { |
---|
3278 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
3279 | } |
---|
3280 | |
---|
3281 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
3282 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
3283 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
3284 | |
---|
3285 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
3286 | if( randomAccess ) |
---|
3287 | { |
---|
3288 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
3289 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
3290 | } |
---|
3291 | else |
---|
3292 | { |
---|
3293 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
3294 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
3295 | } |
---|
3296 | |
---|
3297 | /* |
---|
3298 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
3299 | */ |
---|
3300 | Int i, j; |
---|
3301 | UInt birateValue, cpbSizeValue; |
---|
3302 | UInt ducpbSizeValue; |
---|
3303 | UInt duBitRateValue = 0; |
---|
3304 | |
---|
3305 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
3306 | { |
---|
3307 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
3308 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
3309 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
3310 | hrd->setCpbCntMinus1( i, 0 ); |
---|
3311 | |
---|
3312 | birateValue = bitRate; |
---|
3313 | cpbSizeValue = bitRate; // 1 second |
---|
3314 | ducpbSizeValue = bitRate/numDU; |
---|
3315 | duBitRateValue = bitRate; |
---|
3316 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
3317 | { |
---|
3318 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
3319 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
3320 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
3321 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
3322 | |
---|
3323 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
3324 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
3325 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
3326 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
3327 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
3328 | } |
---|
3329 | } |
---|
3330 | } |
---|
3331 | #endif |
---|
3332 | |
---|
3333 | Void TComVPS::deriveNecessaryLayerFlag() |
---|
3334 | { |
---|
3335 | m_necessaryLayerFlag.empty(); |
---|
3336 | m_numNecessaryLayers.empty(); |
---|
3337 | // Assumed that output layer sets and variables RecursiveRefLayer are already derived |
---|
3338 | for( Int olsIdx = 0; olsIdx < m_numOutputLayerSets; olsIdx++) |
---|
3339 | { |
---|
3340 | deriveNecessaryLayerFlag(olsIdx); |
---|
3341 | } |
---|
3342 | } |
---|
3343 | |
---|
3344 | Void TComVPS::deriveNecessaryLayerFlag(const Int olsIdx) |
---|
3345 | { |
---|
3346 | Int lsIdx = m_outputLayerSetIdx[olsIdx]; |
---|
3347 | Int numLayersInLs = m_numLayerInIdList[lsIdx]; |
---|
3348 | assert( m_necessaryLayerFlag.size() == olsIdx ); // Function should be called in the correct order. |
---|
3349 | m_necessaryLayerFlag.push_back( std::vector<Bool>( numLayersInLs, false ) ); // Initialize to false |
---|
3350 | for( Int lsLayerIdx = 0; lsLayerIdx < numLayersInLs; lsLayerIdx++ ) |
---|
3351 | { |
---|
3352 | if( m_outputLayerFlag[olsIdx][lsLayerIdx] ) |
---|
3353 | { |
---|
3354 | m_necessaryLayerFlag[olsIdx][lsLayerIdx] = true; |
---|
3355 | Int currNuhLayerId = m_layerSetLayerIdList[lsIdx][lsLayerIdx]; |
---|
3356 | for( Int rLsLayerIdx = 0; rLsLayerIdx < lsLayerIdx; rLsLayerIdx++ ) |
---|
3357 | { |
---|
3358 | Int refNuhLayerId = m_layerSetLayerIdList[lsIdx][rLsLayerIdx]; |
---|
3359 | if( m_recursiveRefLayerFlag[currNuhLayerId][refNuhLayerId] ) |
---|
3360 | { |
---|
3361 | m_necessaryLayerFlag[olsIdx][rLsLayerIdx] = true; |
---|
3362 | } |
---|
3363 | } |
---|
3364 | } |
---|
3365 | } |
---|
3366 | m_numNecessaryLayers.push_back(std::accumulate(m_necessaryLayerFlag[olsIdx].begin(), m_necessaryLayerFlag[olsIdx].end(), 0)); |
---|
3367 | } |
---|
3368 | |
---|
3369 | Void TComVPS::checkNecessaryLayerFlagCondition() |
---|
3370 | { |
---|
3371 | /* It is a requirement of bitstream conformance that for each layer index layerIdx in the range of |
---|
3372 | ( vps_base_layer_internal_flag ? 0 : 1 ) to MaxLayersMinus1, inclusive, there shall be at least one OLS with index olsIdx such that |
---|
3373 | NecessaryLayerFlag[ olsIdx ][ lsLayerIdx ] is equal to 1 for the value of lsLayerIdx |
---|
3374 | for which LayerSetLayerIdList[ OlsIdxToLsIdx[ olsIdx ] ][ lsLayerIdx ] is equal to layer_id_in_nuh[ layerIdx ]. */ |
---|
3375 | for(Int layerIdx = m_baseLayerInternalFlag ? 0 : 1; layerIdx < m_uiMaxLayers; layerIdx++) |
---|
3376 | { |
---|
3377 | Bool layerFoundNecessaryLayerFlag = false; |
---|
3378 | for(Int olsIdx = 0; olsIdx < m_numOutputLayerSets; olsIdx++) |
---|
3379 | { |
---|
3380 | Int lsIdx = m_outputLayerSetIdx[olsIdx]; |
---|
3381 | Int currNuhLayerId = m_layerIdInNuh[layerIdx]; |
---|
3382 | std::vector<Int>::iterator iter = std::find( m_layerSetLayerIdList[lsIdx].begin(), m_layerSetLayerIdList[lsIdx].end(), currNuhLayerId ); |
---|
3383 | if( iter != m_layerSetLayerIdList[lsIdx].end() ) // Layer present in layer set |
---|
3384 | { |
---|
3385 | size_t positionLayer = iter - m_layerSetLayerIdList[lsIdx].begin(); |
---|
3386 | if( *(m_necessaryLayerFlag[olsIdx].begin() + positionLayer) == true ) |
---|
3387 | { |
---|
3388 | layerFoundNecessaryLayerFlag = true; |
---|
3389 | break; |
---|
3390 | } |
---|
3391 | } |
---|
3392 | } |
---|
3393 | assert( layerFoundNecessaryLayerFlag ); |
---|
3394 | } |
---|
3395 | } |
---|
3396 | |
---|
3397 | Int TComVPS::calculateLenOfSyntaxElement( const Int numVal ) const |
---|
3398 | { |
---|
3399 | Int numBits = 1; |
---|
3400 | while((1 << numBits) < numVal) |
---|
3401 | { |
---|
3402 | numBits++; |
---|
3403 | } |
---|
3404 | return numBits; |
---|
3405 | } |
---|
3406 | |
---|
3407 | Void TComVPS::calculateMaxSLInLayerSets() |
---|
3408 | { |
---|
3409 | for(Int lsIdx = 0; lsIdx < getNumLayerSets(); lsIdx++) |
---|
3410 | { |
---|
3411 | UInt maxSLMinus1 = 0; |
---|
3412 | for(Int k = 0; k < getNumLayersInIdList(lsIdx); k++ ) { |
---|
3413 | Int lId = getLayerSetLayerIdList(lsIdx, k); |
---|
3414 | maxSLMinus1 = std::max(maxSLMinus1, getMaxTSLayersMinus1(getLayerIdxInVps(lId))); |
---|
3415 | } |
---|
3416 | setMaxSLayersInLayerSetMinus1(lsIdx,maxSLMinus1); |
---|
3417 | } |
---|
3418 | } |
---|
3419 | |
---|
3420 | UInt TComSlice::getPicWidthInLumaSamples() |
---|
3421 | { |
---|
3422 | UInt retVal, layerId = getLayerId(); |
---|
3423 | |
---|
3424 | if ( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 ) |
---|
3425 | { |
---|
3426 | if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() ) |
---|
3427 | { |
---|
3428 | retVal = m_pcVPS->getVpsRepFormat(layerId)->getPicWidthVpsInLumaSamples(); |
---|
3429 | } |
---|
3430 | else |
---|
3431 | { |
---|
3432 | retVal = m_pcSPS->getPicWidthInLumaSamples(); |
---|
3433 | } |
---|
3434 | } |
---|
3435 | else |
---|
3436 | { |
---|
3437 | retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getPicWidthVpsInLumaSamples(); |
---|
3438 | } |
---|
3439 | |
---|
3440 | return retVal; |
---|
3441 | } |
---|
3442 | |
---|
3443 | UInt TComVPS::getPicWidthInLumaSamples( const TComSPS* sps, const UInt layerId ) const |
---|
3444 | { |
---|
3445 | UInt retVal; |
---|
3446 | |
---|
3447 | if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
3448 | { |
---|
3449 | if( layerId == 0 && m_nonHEVCBaseLayerFlag ) |
---|
3450 | { |
---|
3451 | retVal = m_vpsRepFormat[layerId].getPicWidthVpsInLumaSamples(); |
---|
3452 | } |
---|
3453 | else |
---|
3454 | { |
---|
3455 | retVal = sps->getPicWidthInLumaSamples(); |
---|
3456 | } |
---|
3457 | } |
---|
3458 | else |
---|
3459 | { |
---|
3460 | retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getPicWidthVpsInLumaSamples(); |
---|
3461 | } |
---|
3462 | |
---|
3463 | return retVal; |
---|
3464 | } |
---|
3465 | |
---|
3466 | UInt TComSlice::getPicHeightInLumaSamples() |
---|
3467 | { |
---|
3468 | UInt retVal, layerId = getLayerId(); |
---|
3469 | |
---|
3470 | if ( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 ) |
---|
3471 | { |
---|
3472 | if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() ) |
---|
3473 | { |
---|
3474 | retVal = m_pcVPS->getVpsRepFormat(layerId)->getPicHeightVpsInLumaSamples(); |
---|
3475 | } |
---|
3476 | else |
---|
3477 | { |
---|
3478 | retVal = m_pcSPS->getPicHeightInLumaSamples(); |
---|
3479 | } |
---|
3480 | } |
---|
3481 | else |
---|
3482 | { |
---|
3483 | retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getPicHeightVpsInLumaSamples(); |
---|
3484 | } |
---|
3485 | |
---|
3486 | return retVal; |
---|
3487 | } |
---|
3488 | |
---|
3489 | UInt TComVPS::getPicHeightInLumaSamples( const TComSPS* sps, const UInt layerId ) const |
---|
3490 | { |
---|
3491 | UInt retVal; |
---|
3492 | |
---|
3493 | if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
3494 | { |
---|
3495 | if( layerId == 0 && m_nonHEVCBaseLayerFlag ) |
---|
3496 | { |
---|
3497 | retVal = m_vpsRepFormat[layerId].getPicHeightVpsInLumaSamples(); |
---|
3498 | } |
---|
3499 | else |
---|
3500 | { |
---|
3501 | retVal = sps->getPicHeightInLumaSamples(); |
---|
3502 | } |
---|
3503 | } |
---|
3504 | else |
---|
3505 | { |
---|
3506 | retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getPicHeightVpsInLumaSamples(); |
---|
3507 | } |
---|
3508 | |
---|
3509 | return retVal; |
---|
3510 | } |
---|
3511 | |
---|
3512 | ChromaFormat TComSlice::getChromaFormatIdc() |
---|
3513 | { |
---|
3514 | ChromaFormat retVal; |
---|
3515 | UInt layerId = getLayerId(); |
---|
3516 | |
---|
3517 | if( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 ) |
---|
3518 | { |
---|
3519 | if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() ) |
---|
3520 | { |
---|
3521 | retVal = m_pcVPS->getVpsRepFormat(layerId)->getChromaFormatVpsIdc(); |
---|
3522 | } |
---|
3523 | else |
---|
3524 | { |
---|
3525 | retVal = m_pcSPS->getChromaFormatIdc(); |
---|
3526 | } |
---|
3527 | } |
---|
3528 | else |
---|
3529 | { |
---|
3530 | retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getChromaFormatVpsIdc(); |
---|
3531 | } |
---|
3532 | |
---|
3533 | return retVal; |
---|
3534 | } |
---|
3535 | |
---|
3536 | ChromaFormat TComVPS::getChromaFormatIdc( const TComSPS* sps, const UInt layerId ) const |
---|
3537 | { |
---|
3538 | ChromaFormat retVal; |
---|
3539 | |
---|
3540 | if( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
3541 | { |
---|
3542 | if( layerId == 0 && m_nonHEVCBaseLayerFlag ) |
---|
3543 | { |
---|
3544 | retVal = m_vpsRepFormat[layerId].getChromaFormatVpsIdc(); |
---|
3545 | } |
---|
3546 | else |
---|
3547 | { |
---|
3548 | retVal = sps->getChromaFormatIdc(); |
---|
3549 | } |
---|
3550 | } |
---|
3551 | else |
---|
3552 | { |
---|
3553 | retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getChromaFormatVpsIdc(); |
---|
3554 | } |
---|
3555 | |
---|
3556 | return retVal; |
---|
3557 | } |
---|
3558 | |
---|
3559 | UInt TComSlice::getBitDepthY() |
---|
3560 | { |
---|
3561 | UInt retVal, layerId = getLayerId(); |
---|
3562 | |
---|
3563 | if( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 ) |
---|
3564 | { |
---|
3565 | if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() ) |
---|
3566 | { |
---|
3567 | retVal = m_pcVPS->getVpsRepFormat(layerId)->getBitDepthVpsLuma(); |
---|
3568 | } |
---|
3569 | else |
---|
3570 | { |
---|
3571 | retVal = m_pcSPS->getBitDepth(CHANNEL_TYPE_LUMA); |
---|
3572 | } |
---|
3573 | } |
---|
3574 | else |
---|
3575 | { |
---|
3576 | retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getBitDepthVpsLuma(); |
---|
3577 | } |
---|
3578 | |
---|
3579 | return retVal; |
---|
3580 | } |
---|
3581 | |
---|
3582 | UInt TComVPS::getBitDepthY( const TComSPS* sps, const UInt layerId ) const |
---|
3583 | { |
---|
3584 | UInt retVal; |
---|
3585 | |
---|
3586 | if( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
3587 | { |
---|
3588 | if( layerId == 0 && m_nonHEVCBaseLayerFlag ) |
---|
3589 | { |
---|
3590 | retVal = m_vpsRepFormat[layerId].getBitDepthVpsLuma(); |
---|
3591 | } |
---|
3592 | else |
---|
3593 | { |
---|
3594 | retVal = sps->getBitDepth(CHANNEL_TYPE_LUMA); |
---|
3595 | } |
---|
3596 | } |
---|
3597 | else |
---|
3598 | { |
---|
3599 | retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getBitDepthVpsLuma(); |
---|
3600 | } |
---|
3601 | |
---|
3602 | return retVal; |
---|
3603 | } |
---|
3604 | |
---|
3605 | UInt TComSlice::getBitDepthC() |
---|
3606 | { |
---|
3607 | UInt retVal, layerId = getLayerId(); |
---|
3608 | |
---|
3609 | if( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 ) |
---|
3610 | { |
---|
3611 | if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() ) |
---|
3612 | { |
---|
3613 | retVal = m_pcVPS->getVpsRepFormat(layerId)->getBitDepthVpsChroma(); |
---|
3614 | } |
---|
3615 | else |
---|
3616 | { |
---|
3617 | retVal = m_pcSPS->getBitDepth(CHANNEL_TYPE_CHROMA); |
---|
3618 | } |
---|
3619 | } |
---|
3620 | else |
---|
3621 | { |
---|
3622 | retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getBitDepthVpsChroma(); |
---|
3623 | } |
---|
3624 | |
---|
3625 | return retVal; |
---|
3626 | } |
---|
3627 | |
---|
3628 | UInt TComVPS::getBitDepthC( const TComSPS* sps, const UInt layerId ) const |
---|
3629 | { |
---|
3630 | UInt retVal; |
---|
3631 | |
---|
3632 | if( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
3633 | { |
---|
3634 | if( layerId == 0 && m_nonHEVCBaseLayerFlag ) |
---|
3635 | { |
---|
3636 | retVal = m_vpsRepFormat[layerId].getBitDepthVpsChroma(); |
---|
3637 | } |
---|
3638 | else |
---|
3639 | { |
---|
3640 | retVal = sps->getBitDepth(CHANNEL_TYPE_CHROMA); |
---|
3641 | } |
---|
3642 | } |
---|
3643 | else |
---|
3644 | { |
---|
3645 | retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getBitDepthVpsChroma(); |
---|
3646 | } |
---|
3647 | |
---|
3648 | return retVal; |
---|
3649 | } |
---|
3650 | |
---|
3651 | Int TComSlice::getQpBDOffsetY() |
---|
3652 | { |
---|
3653 | return (getBitDepthY() - 8) * 6; |
---|
3654 | } |
---|
3655 | |
---|
3656 | Int TComSlice::getQpBDOffsetC() |
---|
3657 | { |
---|
3658 | return (getBitDepthC() - 8) * 6; |
---|
3659 | } |
---|
3660 | |
---|
3661 | const Window& TComSlice::getConformanceWindow() const |
---|
3662 | { |
---|
3663 | if ( m_layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 ) |
---|
3664 | { |
---|
3665 | if( m_layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() ) |
---|
3666 | { |
---|
3667 | return m_pcVPS->getVpsRepFormat(m_layerId)->getConformanceWindowVps(); |
---|
3668 | } |
---|
3669 | else |
---|
3670 | { |
---|
3671 | return m_pcSPS->getConformanceWindow(); |
---|
3672 | } |
---|
3673 | } |
---|
3674 | else |
---|
3675 | { |
---|
3676 | return m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(m_layerId)))->getConformanceWindowVps(); |
---|
3677 | } |
---|
3678 | } |
---|
3679 | |
---|
3680 | const Window& TComVPS::getConformanceWindow( const TComSPS* sps, const UInt layerId ) const |
---|
3681 | { |
---|
3682 | if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
3683 | { |
---|
3684 | if( layerId == 0 && m_nonHEVCBaseLayerFlag ) |
---|
3685 | { |
---|
3686 | return m_vpsRepFormat[layerId].getConformanceWindowVps(); |
---|
3687 | } |
---|
3688 | else |
---|
3689 | { |
---|
3690 | return sps->getConformanceWindow(); |
---|
3691 | } |
---|
3692 | } |
---|
3693 | else |
---|
3694 | { |
---|
3695 | return m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getConformanceWindowVps(); |
---|
3696 | } |
---|
3697 | } |
---|
3698 | |
---|
3699 | RepFormat::RepFormat() |
---|
3700 | #if AUXILIARY_PICTURES |
---|
3701 | : m_chromaFormatVpsIdc (CHROMA_420) |
---|
3702 | #else |
---|
3703 | : m_chromaFormatVpsIdc (0) |
---|
3704 | #endif |
---|
3705 | , m_separateColourPlaneVpsFlag (false) |
---|
3706 | , m_picWidthVpsInLumaSamples (0) |
---|
3707 | , m_picHeightVpsInLumaSamples (0) |
---|
3708 | , m_bitDepthVpsLuma (0) |
---|
3709 | , m_bitDepthVpsChroma (0) |
---|
3710 | {} |
---|
3711 | |
---|
3712 | Void TComPTL::copyProfileInfo(TComPTL *ptl) |
---|
3713 | { |
---|
3714 | // Copy all information related to general profile |
---|
3715 | this->getGeneralPTL()->copyProfileInfo(ptl->getGeneralPTL()); |
---|
3716 | } |
---|
3717 | |
---|
3718 | Bool TComSlice::setBaseColPic( TComList<TComPic*>& rcListPic, UInt refLayerIdc ) |
---|
3719 | { |
---|
3720 | if(m_layerId == 0) |
---|
3721 | { |
---|
3722 | memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) ); |
---|
3723 | return false; |
---|
3724 | } |
---|
3725 | |
---|
3726 | TComPic* pic = xGetRefPic( rcListPic, getPOC() ); |
---|
3727 | |
---|
3728 | if( pic ) |
---|
3729 | { |
---|
3730 | setBaseColPic(refLayerIdc, pic ); |
---|
3731 | } |
---|
3732 | else |
---|
3733 | { |
---|
3734 | return false; |
---|
3735 | } |
---|
3736 | |
---|
3737 | return true; |
---|
3738 | } |
---|
3739 | |
---|
3740 | TComPic* TComSlice::getBaseColPic( TComList<TComPic*>& rcListPic ) |
---|
3741 | { |
---|
3742 | return xGetRefPic( rcListPic, m_iPOC ); |
---|
3743 | } |
---|
3744 | |
---|
3745 | Void TComSlice::setILRPic(TComPic **pcIlpPic) |
---|
3746 | { |
---|
3747 | for( Int i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
3748 | { |
---|
3749 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
3750 | |
---|
3751 | if( pcIlpPic[refLayerIdc] ) |
---|
3752 | { |
---|
3753 | TComPic* pcRefPicBL = m_pcBaseColPic[refLayerIdc]; |
---|
3754 | |
---|
3755 | // copy scalability ratio, it is needed to get the correct location for the motion field of the corresponding reference layer block |
---|
3756 | pcIlpPic[refLayerIdc]->setSpatialEnhLayerFlag( refLayerIdc, m_pcPic->isSpatialEnhLayer(refLayerIdc) ); |
---|
3757 | |
---|
3758 | pcIlpPic[refLayerIdc]->copyUpsampledPictureYuv( m_pcPic->getFullPelBaseRec( refLayerIdc ), pcIlpPic[refLayerIdc]->getPicYuvRec() ); |
---|
3759 | pcIlpPic[refLayerIdc]->getSlice(0)->setBaseColPic( refLayerIdc, pcRefPicBL ); |
---|
3760 | |
---|
3761 | //set reference picture POC of each ILP reference |
---|
3762 | pcIlpPic[refLayerIdc]->getSlice(0)->setPOC( m_iPOC ); |
---|
3763 | |
---|
3764 | //set temporal Id |
---|
3765 | pcIlpPic[refLayerIdc]->getSlice(0)->setTLayer( m_uiTLayer ); |
---|
3766 | |
---|
3767 | //copy layer id from the reference layer |
---|
3768 | pcIlpPic[refLayerIdc]->setLayerId( pcRefPicBL->getLayerId() ); |
---|
3769 | pcIlpPic[refLayerIdc]->getSlice(0)->setLayerId(pcRefPicBL->getLayerId()); |
---|
3770 | |
---|
3771 | pcIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension( false ); |
---|
3772 | pcIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder(); |
---|
3773 | for (Int j=0; j<pcIlpPic[refLayerIdc]->getPicSym()->getNumberOfCtusInFrame(); j++) // set reference CU layerId |
---|
3774 | { |
---|
3775 | pcIlpPic[refLayerIdc]->getPicSym()->getCtu(j)->setLayerId( pcIlpPic[refLayerIdc]->getLayerId() ); |
---|
3776 | } |
---|
3777 | pcIlpPic[refLayerIdc]->setIsLongTerm(1); |
---|
3778 | |
---|
3779 | // assign PPS to ILRP to be used for reference location offsets |
---|
3780 | pcIlpPic[refLayerIdc]->getSlice(0)->setPPS( m_pcPic->getSlice(0)->getPPS() ); |
---|
3781 | |
---|
3782 | // assing VPS to ILRP to be used for deriving layerIdx |
---|
3783 | pcIlpPic[refLayerIdc]->getSlice(0)->setVPS( m_pcPic->getSlice(0)->getVPS() ); |
---|
3784 | |
---|
3785 | if( m_bMFMEnabledFlag && !(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) |
---|
3786 | { |
---|
3787 | //set reference picture POC of each ILP reference |
---|
3788 | assert( pcIlpPic[refLayerIdc]->getPOC() == pcRefPicBL->getPOC() ); |
---|
3789 | |
---|
3790 | //copy slice type from the reference layer |
---|
3791 | pcIlpPic[refLayerIdc]->getSlice(0)->setSliceType( pcRefPicBL->getSlice(0)->getSliceType() ); |
---|
3792 | |
---|
3793 | //copy "used for reference" |
---|
3794 | pcIlpPic[refLayerIdc]->getSlice(0)->setReferenced( pcRefPicBL->getSlice(0)->isReferenced() ); |
---|
3795 | |
---|
3796 | for( Int refList = 0; refList < 2; refList++ ) |
---|
3797 | { |
---|
3798 | RefPicList refPicList = RefPicList( refList ); |
---|
3799 | |
---|
3800 | //set reference POC of ILP |
---|
3801 | pcIlpPic[refLayerIdc]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList)); |
---|
3802 | assert(pcIlpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) >= 0); |
---|
3803 | assert(pcIlpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF); |
---|
3804 | |
---|
3805 | //initialize reference POC of ILP |
---|
3806 | for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++) |
---|
3807 | { |
---|
3808 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx); |
---|
3809 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx); |
---|
3810 | } |
---|
3811 | |
---|
3812 | for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++) |
---|
3813 | { |
---|
3814 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPOC(0, refPicList, refIdx); |
---|
3815 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPic(NULL, refPicList, refIdx); |
---|
3816 | } |
---|
3817 | |
---|
3818 | //copy reference pictures' marking from the reference layer |
---|
3819 | for(Int j = 0; j < MAX_NUM_REF + 1; j++) |
---|
3820 | { |
---|
3821 | pcIlpPic[refLayerIdc]->getSlice(0)->setIsUsedAsLongTerm(refList, j, pcRefPicBL->getSlice(0)->getIsUsedAsLongTerm(refList, j)); |
---|
3822 | } |
---|
3823 | } |
---|
3824 | |
---|
3825 | pcIlpPic[refLayerIdc]->copyUpsampledMvField( refLayerIdc, m_pcBaseColPic[refLayerIdc] ); |
---|
3826 | } |
---|
3827 | else |
---|
3828 | { |
---|
3829 | pcIlpPic[refLayerIdc]->initUpsampledMvField(); |
---|
3830 | } |
---|
3831 | |
---|
3832 | Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1( pcIlpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx() ); |
---|
3833 | assert( (Int)pcIlpPic[refLayerIdc]->getSlice(0)->getTLayer() < maxTidIlRefPicsPlus1 || ( !maxTidIlRefPicsPlus1 && pcIlpPic[refLayerIdc]->getSlice(0)->getRapPicFlag() ) ); |
---|
3834 | |
---|
3835 | } |
---|
3836 | } |
---|
3837 | } |
---|
3838 | |
---|
3839 | Int TComSlice::getReferenceLayerIdc( UInt refLayerId ) |
---|
3840 | { |
---|
3841 | for( Int i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
3842 | { |
---|
3843 | if( m_pcVPS->getRefLayerId(m_layerId, m_interLayerPredLayerIdc[i]) == refLayerId ) |
---|
3844 | { |
---|
3845 | return m_interLayerPredLayerIdc[i]; |
---|
3846 | } |
---|
3847 | } |
---|
3848 | |
---|
3849 | return -1; |
---|
3850 | } |
---|
3851 | |
---|
3852 | Bool TComSlice::getBlaPicFlag() |
---|
3853 | { |
---|
3854 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
3855 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
3856 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP; |
---|
3857 | } |
---|
3858 | |
---|
3859 | Bool TComSlice::getCraPicFlag() |
---|
3860 | { |
---|
3861 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
3862 | } |
---|
3863 | |
---|
3864 | Bool TComSlice::getRaslPicFlag() |
---|
3865 | { |
---|
3866 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R |
---|
3867 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N; |
---|
3868 | } |
---|
3869 | |
---|
3870 | Bool TComSlice::getRadlPicFlag() |
---|
3871 | { |
---|
3872 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R |
---|
3873 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N; |
---|
3874 | } |
---|
3875 | |
---|
3876 | Void TComSlice::decrementRefPocValues(Int const decrementValue) |
---|
3877 | { |
---|
3878 | for(Int listNum = 0; listNum < 2; listNum++) |
---|
3879 | { |
---|
3880 | RefPicList dpbPicSliceList = (listNum == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
3881 | for(Int listIdx = 0; listIdx < getNumRefIdx( dpbPicSliceList ); listIdx++) |
---|
3882 | { |
---|
3883 | setRefPOC( getRefPOC(dpbPicSliceList, listIdx) - decrementValue, |
---|
3884 | dpbPicSliceList, |
---|
3885 | listIdx |
---|
3886 | ); |
---|
3887 | } |
---|
3888 | } |
---|
3889 | } |
---|
3890 | |
---|
3891 | Int TComSlice::getCurrMsb( Int currLsb, Int prevLsb, Int prevMsb, Int maxLsbVal ) |
---|
3892 | { |
---|
3893 | if( prevLsb - currLsb >= (maxLsbVal >> 1) ) |
---|
3894 | { |
---|
3895 | return prevMsb + maxLsbVal; |
---|
3896 | } |
---|
3897 | else if( currLsb - prevLsb > (maxLsbVal >> 1) ) |
---|
3898 | { |
---|
3899 | return prevMsb - maxLsbVal; |
---|
3900 | } |
---|
3901 | else |
---|
3902 | { |
---|
3903 | return prevMsb; |
---|
3904 | } |
---|
3905 | } |
---|
3906 | |
---|
3907 | Void TComSlice::setRefPicListModificationSvc() |
---|
3908 | { |
---|
3909 | if( !m_pcPPS->getListsModificationPresentFlag()) |
---|
3910 | { |
---|
3911 | return; |
---|
3912 | } |
---|
3913 | |
---|
3914 | if(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) |
---|
3915 | { |
---|
3916 | return; |
---|
3917 | } |
---|
3918 | |
---|
3919 | TComRefPicListModification* refPicListModification = &m_RefPicListModification; |
---|
3920 | Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList(); // total number of ref pics in listTemp0 including inter-layer ref pics |
---|
3921 | #if SVC_EXTENSION |
---|
3922 | Int numberOfPocBeforeCurr = this->getNumNegativeRpsCurrTempList(); // number of negative temporal ref pics |
---|
3923 | #endif |
---|
3924 | |
---|
3925 | assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 0); |
---|
3926 | assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 0); |
---|
3927 | |
---|
3928 | //set L0 inter-layer reference picture modification |
---|
3929 | #if SVC_EXTENSION |
---|
3930 | Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true; |
---|
3931 | |
---|
3932 | if( m_activeNumILRRefIdx > 1 ) |
---|
3933 | { |
---|
3934 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] >= (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true; |
---|
3935 | } |
---|
3936 | #else |
---|
3937 | Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == numberOfRpsCurrTempList) ? false : true; |
---|
3938 | #endif |
---|
3939 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_0] > 1 ); |
---|
3940 | refPicListModification->setRefPicListModificationFlagL0(hasModification); |
---|
3941 | if(hasModification) |
---|
3942 | { |
---|
3943 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_0], numberOfRpsCurrTempList); i++) |
---|
3944 | { |
---|
3945 | refPicListModification->setRefPicSetIdxL0(i, i); |
---|
3946 | } |
---|
3947 | |
---|
3948 | if(m_aiNumRefIdx[REF_PIC_LIST_0] > numberOfRpsCurrTempList) |
---|
3949 | { |
---|
3950 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
3951 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_0]; i ++) |
---|
3952 | { |
---|
3953 | refPicListModification->setRefPicSetIdxL0(i, numberOfRpsCurrTempList - 1); |
---|
3954 | } |
---|
3955 | } |
---|
3956 | else |
---|
3957 | { |
---|
3958 | // number of ILRPs included into the reference picture list with the list modification |
---|
3959 | Int includeNumILRP = min( max(1, m_aiNumRefIdx[REF_PIC_LIST_0]-numberOfPocBeforeCurr), m_activeNumILRRefIdx); |
---|
3960 | |
---|
3961 | for(Int i = includeNumILRP; i > 0; i-- ) |
---|
3962 | { |
---|
3963 | #if SVC_EXTENSION |
---|
3964 | if( numberOfPocBeforeCurr >= m_aiNumRefIdx[REF_PIC_LIST_0] ) |
---|
3965 | { |
---|
3966 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i); |
---|
3967 | } |
---|
3968 | else |
---|
3969 | { |
---|
3970 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i); |
---|
3971 | for( Int j = numberOfPocBeforeCurr; j < (m_aiNumRefIdx[REF_PIC_LIST_0] - i); j++ ) |
---|
3972 | { |
---|
3973 | assert( j + includeNumILRP < numberOfRpsCurrTempList ); |
---|
3974 | refPicListModification->setRefPicSetIdxL0(j, j + includeNumILRP); |
---|
3975 | } |
---|
3976 | } |
---|
3977 | #else |
---|
3978 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i); |
---|
3979 | #endif |
---|
3980 | } |
---|
3981 | } |
---|
3982 | } |
---|
3983 | |
---|
3984 | //set L1 inter-layer reference picture modification |
---|
3985 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] >= numberOfRpsCurrTempList) ? false : true; |
---|
3986 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_1] > 1 ); |
---|
3987 | |
---|
3988 | refPicListModification->setRefPicListModificationFlagL1(hasModification); |
---|
3989 | if(hasModification) |
---|
3990 | { |
---|
3991 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_1], numberOfRpsCurrTempList); i++) |
---|
3992 | { |
---|
3993 | refPicListModification->setRefPicSetIdxL1(i, i); |
---|
3994 | } |
---|
3995 | if(m_aiNumRefIdx[REF_PIC_LIST_1] > numberOfRpsCurrTempList) |
---|
3996 | { |
---|
3997 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_1]; i ++) |
---|
3998 | { |
---|
3999 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
4000 | refPicListModification->setRefPicSetIdxL1(i, numberOfRpsCurrTempList - 1); |
---|
4001 | } |
---|
4002 | } |
---|
4003 | else |
---|
4004 | { |
---|
4005 | Int includeNumILRP = min(m_aiNumRefIdx[REF_PIC_LIST_1], m_activeNumILRRefIdx); |
---|
4006 | |
---|
4007 | for(Int i = includeNumILRP; i > 0; i-- ) |
---|
4008 | { |
---|
4009 | refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i); |
---|
4010 | } |
---|
4011 | } |
---|
4012 | } |
---|
4013 | return; |
---|
4014 | } |
---|
4015 | |
---|
4016 | Int TComSlice::getNumNegativeRpsCurrTempList() |
---|
4017 | { |
---|
4018 | if( m_eSliceType == I_SLICE ) |
---|
4019 | { |
---|
4020 | return 0; |
---|
4021 | } |
---|
4022 | |
---|
4023 | Int numPocBeforeCurr = 0; |
---|
4024 | |
---|
4025 | for( UInt i = 0; i < m_pcRPS->getNumberOfNegativePictures(); i++ ) |
---|
4026 | { |
---|
4027 | if( m_pcRPS->getUsed(i) ) |
---|
4028 | { |
---|
4029 | numPocBeforeCurr++; |
---|
4030 | } |
---|
4031 | } |
---|
4032 | |
---|
4033 | return numPocBeforeCurr; |
---|
4034 | } |
---|
4035 | #endif //SVC_EXTENSION |
---|
4036 | |
---|
4037 | //! \} |
---|