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