1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TComSlice.cpp |
---|
35 | \brief slice header and SPS class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "CommonDef.h" |
---|
39 | #include "TComSlice.h" |
---|
40 | #include "TComPic.h" |
---|
41 | #include "TLibEncoder/TEncSbac.h" |
---|
42 | #include "TLibDecoder/TDecSbac.h" |
---|
43 | |
---|
44 | |
---|
45 | //! \ingroup TLibCommon |
---|
46 | //! \{ |
---|
47 | |
---|
48 | #if SVC_EXTENSION |
---|
49 | #include <numeric> |
---|
50 | ParameterSetMap<TComVPS> ParameterSetManager::m_vpsMap(MAX_NUM_VPS); |
---|
51 | ParameterSetMap<TComSPS> ParameterSetManager::m_spsMap(MAX_NUM_SPS); |
---|
52 | ParameterSetMap<TComPPS> ParameterSetManager::m_ppsMap(MAX_NUM_PPS); |
---|
53 | TComVPS ParameterSetManager::m_activeVPS; |
---|
54 | #endif |
---|
55 | |
---|
56 | TComSlice::TComSlice() |
---|
57 | : m_iPPSId ( -1 ) |
---|
58 | , m_PicOutputFlag ( true ) |
---|
59 | , m_iPOC ( 0 ) |
---|
60 | , m_iLastIDR ( 0 ) |
---|
61 | , m_iAssociatedIRAP ( 0 ) |
---|
62 | , m_iAssociatedIRAPType ( NAL_UNIT_INVALID ) |
---|
63 | , m_pcRPS ( 0 ) |
---|
64 | , m_LocalRPS ( ) |
---|
65 | , m_iBDidx ( 0 ) |
---|
66 | , m_RefPicListModification ( ) |
---|
67 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
68 | , m_eSliceType ( I_SLICE ) |
---|
69 | , m_iSliceQp ( 0 ) |
---|
70 | , m_dependentSliceSegmentFlag ( false ) |
---|
71 | #if ADAPTIVE_QP_SELECTION |
---|
72 | , m_iSliceQpBase ( 0 ) |
---|
73 | #endif |
---|
74 | , m_ChromaQpAdjEnabled ( false ) |
---|
75 | , m_deblockingFilterDisable ( false ) |
---|
76 | , m_deblockingFilterOverrideFlag ( false ) |
---|
77 | , m_deblockingFilterBetaOffsetDiv2( 0 ) |
---|
78 | , m_deblockingFilterTcOffsetDiv2 ( 0 ) |
---|
79 | , m_bCheckLDC ( false ) |
---|
80 | , m_iSliceQpDelta ( 0 ) |
---|
81 | , m_iDepth ( 0 ) |
---|
82 | , m_bRefenced ( false ) |
---|
83 | , m_pcVPS ( NULL ) |
---|
84 | , m_pcSPS ( NULL ) |
---|
85 | , m_pcPPS ( NULL ) |
---|
86 | , m_pcPic ( NULL ) |
---|
87 | , 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) |
---|
867 | #else |
---|
868 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
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 EFFICIENT_FIELD_IRAP |
---|
918 | bRefreshPending = true; |
---|
919 | #endif |
---|
920 | } |
---|
921 | else // CRA or No DR |
---|
922 | { |
---|
923 | #if EFFICIENT_FIELD_IRAP |
---|
924 | if(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 | #endif |
---|
944 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
945 | { |
---|
946 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
947 | while (iterPic != rcListPic.end()) |
---|
948 | { |
---|
949 | rpcPic = *(iterPic); |
---|
950 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
951 | { |
---|
952 | rpcPic->getSlice(0)->setReferenced(false); |
---|
953 | } |
---|
954 | iterPic++; |
---|
955 | } |
---|
956 | bRefreshPending = false; |
---|
957 | } |
---|
958 | #if EFFICIENT_FIELD_IRAP |
---|
959 | } |
---|
960 | #endif |
---|
961 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
962 | { |
---|
963 | bRefreshPending = true; |
---|
964 | pocCRA = pocCurr; |
---|
965 | } |
---|
966 | } |
---|
967 | } |
---|
968 | |
---|
969 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
970 | { |
---|
971 | assert( pSrc != NULL ); |
---|
972 | |
---|
973 | Int i, j, k; |
---|
974 | |
---|
975 | m_iPOC = pSrc->m_iPOC; |
---|
976 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
977 | m_eSliceType = pSrc->m_eSliceType; |
---|
978 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
979 | #if ADAPTIVE_QP_SELECTION |
---|
980 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
981 | #endif |
---|
982 | m_ChromaQpAdjEnabled = pSrc->m_ChromaQpAdjEnabled; |
---|
983 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
984 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
985 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
986 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
987 | |
---|
988 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
989 | { |
---|
990 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
991 | } |
---|
992 | |
---|
993 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
994 | { |
---|
995 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
996 | } |
---|
997 | |
---|
998 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
999 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
1000 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
1001 | { |
---|
1002 | m_iSliceChromaQpDelta[component] = pSrc->m_iSliceChromaQpDelta[component]; |
---|
1003 | } |
---|
1004 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
1005 | { |
---|
1006 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1007 | { |
---|
1008 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
1009 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
1010 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
1011 | } |
---|
1012 | m_bIsUsedAsLongTerm[i][MAX_NUM_REF] = pSrc->m_bIsUsedAsLongTerm[i][MAX_NUM_REF]; |
---|
1013 | } |
---|
1014 | m_iDepth = pSrc->m_iDepth; |
---|
1015 | |
---|
1016 | // referenced slice |
---|
1017 | m_bRefenced = pSrc->m_bRefenced; |
---|
1018 | |
---|
1019 | // access channel |
---|
1020 | #if SVC_EXTENSION |
---|
1021 | m_pcVPS = pSrc->m_pcVPS; |
---|
1022 | m_layerId = pSrc->m_layerId; |
---|
1023 | m_activeNumILRRefIdx = pSrc->m_activeNumILRRefIdx; |
---|
1024 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
1025 | memcpy( m_interLayerPredLayerIdc, pSrc->m_interLayerPredLayerIdc, sizeof( m_interLayerPredLayerIdc ) ); |
---|
1026 | #endif |
---|
1027 | m_pcRPS = pSrc->m_pcRPS; |
---|
1028 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
1029 | |
---|
1030 | m_pcPic = pSrc->m_pcPic; |
---|
1031 | |
---|
1032 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
1033 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
1034 | |
---|
1035 | setLambdas(pSrc->getLambdas()); |
---|
1036 | |
---|
1037 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
1038 | { |
---|
1039 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1040 | { |
---|
1041 | for (k =0; k < MAX_NUM_REF; k++) |
---|
1042 | { |
---|
1043 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
1044 | } |
---|
1045 | } |
---|
1046 | } |
---|
1047 | |
---|
1048 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
1049 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
1050 | |
---|
1051 | m_sliceMode = pSrc->m_sliceMode; |
---|
1052 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
1053 | m_sliceCurStartCtuTsAddr = pSrc->m_sliceCurStartCtuTsAddr; |
---|
1054 | m_sliceCurEndCtuTsAddr = pSrc->m_sliceCurEndCtuTsAddr; |
---|
1055 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
1056 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
1057 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
1058 | m_sliceSegmentCurStartCtuTsAddr = pSrc->m_sliceSegmentCurStartCtuTsAddr; |
---|
1059 | m_sliceSegmentCurEndCtuTsAddr = pSrc->m_sliceSegmentCurEndCtuTsAddr; |
---|
1060 | m_nextSlice = pSrc->m_nextSlice; |
---|
1061 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
1062 | |
---|
1063 | for ( UInt e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
1064 | { |
---|
1065 | for ( UInt n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
1066 | { |
---|
1067 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(WPScalingParam)*MAX_NUM_COMPONENT ); |
---|
1068 | } |
---|
1069 | } |
---|
1070 | |
---|
1071 | for( UInt ch = 0 ; ch < MAX_NUM_CHANNEL_TYPE; ch++) |
---|
1072 | { |
---|
1073 | m_saoEnabledFlag[ch] = pSrc->m_saoEnabledFlag[ch]; |
---|
1074 | } |
---|
1075 | |
---|
1076 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
1077 | |
---|
1078 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
1079 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
1080 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
1081 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
1082 | m_encCABACTableIdx = pSrc->m_encCABACTableIdx; |
---|
1083 | } |
---|
1084 | |
---|
1085 | |
---|
1086 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
1087 | * \param uiTLayer Temporal layer ID of the current slice |
---|
1088 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
1089 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
1090 | * temporal_layer_switching_point_flag is set accordingly. |
---|
1091 | */ |
---|
1092 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
1093 | { |
---|
1094 | m_uiTLayer = uiTLayer; |
---|
1095 | } |
---|
1096 | |
---|
1097 | /** Function for checking if this is a switching-point |
---|
1098 | */ |
---|
1099 | Bool TComSlice::isTemporalLayerSwitchingPoint(TComList<TComPic*>& rcListPic) |
---|
1100 | { |
---|
1101 | TComPic* rpcPic; |
---|
1102 | // loop through all pictures in the reference picture buffer |
---|
1103 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1104 | while ( iterPic != rcListPic.end()) |
---|
1105 | { |
---|
1106 | rpcPic = *(iterPic++); |
---|
1107 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
1108 | { |
---|
1109 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1110 | { |
---|
1111 | return false; |
---|
1112 | } |
---|
1113 | } |
---|
1114 | } |
---|
1115 | return true; |
---|
1116 | } |
---|
1117 | |
---|
1118 | /** Function for checking if this is a STSA candidate |
---|
1119 | */ |
---|
1120 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate(TComList<TComPic*>& rcListPic) |
---|
1121 | { |
---|
1122 | TComPic* rpcPic; |
---|
1123 | |
---|
1124 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1125 | while ( iterPic != rcListPic.end()) |
---|
1126 | { |
---|
1127 | rpcPic = *(iterPic++); |
---|
1128 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
1129 | { |
---|
1130 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1131 | { |
---|
1132 | return false; |
---|
1133 | } |
---|
1134 | } |
---|
1135 | } |
---|
1136 | return true; |
---|
1137 | } |
---|
1138 | |
---|
1139 | #if SVC_POC |
---|
1140 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic, Bool usePocBeforeReset) |
---|
1141 | #else |
---|
1142 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) |
---|
1143 | #endif |
---|
1144 | { |
---|
1145 | TComPic* rpcPic; |
---|
1146 | |
---|
1147 | Int nalUnitType = this->getNalUnitType(); |
---|
1148 | |
---|
1149 | // When a picture is a leading picture, it shall be a RADL or RASL picture. |
---|
1150 | if(this->getAssociatedIRAPPOC() > this->getPOC()) |
---|
1151 | { |
---|
1152 | // Do not check IRAP pictures since they may get a POC lower than their associated IRAP |
---|
1153 | if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1154 | nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) |
---|
1155 | { |
---|
1156 | assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1157 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1158 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1159 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1160 | } |
---|
1161 | } |
---|
1162 | |
---|
1163 | // When a picture is a trailing picture, it shall not be a RADL or RASL picture. |
---|
1164 | if(this->getAssociatedIRAPPOC() < this->getPOC()) |
---|
1165 | { |
---|
1166 | assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && |
---|
1167 | nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && |
---|
1168 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && |
---|
1169 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1170 | } |
---|
1171 | |
---|
1172 | // No RASL pictures shall be present in the bitstream that are associated |
---|
1173 | // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. |
---|
1174 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1175 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1176 | { |
---|
1177 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && |
---|
1178 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); |
---|
1179 | } |
---|
1180 | |
---|
1181 | // No RASL pictures shall be present in the bitstream that are associated with |
---|
1182 | // an IDR picture. |
---|
1183 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1184 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1185 | { |
---|
1186 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && |
---|
1187 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
1188 | } |
---|
1189 | |
---|
1190 | // No RADL pictures shall be present in the bitstream that are associated with |
---|
1191 | // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated |
---|
1192 | // with an IDR picture having nal_unit_type equal to IDR_N_LP. |
---|
1193 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1194 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1195 | { |
---|
1196 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && |
---|
1197 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); |
---|
1198 | } |
---|
1199 | |
---|
1200 | // loop through all pictures in the reference picture buffer |
---|
1201 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1202 | while ( iterPic != rcListPic.end()) |
---|
1203 | { |
---|
1204 | rpcPic = *(iterPic++); |
---|
1205 | #if BUGFIX_INTRAPERIOD |
---|
1206 | if(!rpcPic->getReconMark()) |
---|
1207 | { |
---|
1208 | continue; |
---|
1209 | } |
---|
1210 | #endif |
---|
1211 | if (rpcPic->getPOC() == this->getPOC()) |
---|
1212 | { |
---|
1213 | continue; |
---|
1214 | } |
---|
1215 | |
---|
1216 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1217 | // in decoding order shall precede the IRAP picture in output order. |
---|
1218 | // (Note that any picture following in output order would be present in the DPB) |
---|
1219 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1 && !this->getNoOutputPriorPicsFlag()) |
---|
1220 | { |
---|
1221 | if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1222 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1223 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1224 | nalUnitType == NAL_UNIT_CODED_SLICE_CRA || |
---|
1225 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1226 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
1227 | { |
---|
1228 | #if SVC_POC |
---|
1229 | if( usePocBeforeReset ) |
---|
1230 | { |
---|
1231 | assert(rpcPic->getSlice(0)->getPocValueBeforeReset() < this->getPocValueBeforeReset()); |
---|
1232 | } |
---|
1233 | else |
---|
1234 | { |
---|
1235 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1236 | } |
---|
1237 | #else |
---|
1238 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1239 | #endif |
---|
1240 | } |
---|
1241 | } |
---|
1242 | |
---|
1243 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1244 | // in decoding order shall precede any RADL picture associated with the IRAP |
---|
1245 | // picture in output order. |
---|
1246 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
1247 | { |
---|
1248 | if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1249 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) |
---|
1250 | { |
---|
1251 | // rpcPic precedes the IRAP in decoding order |
---|
1252 | if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1253 | { |
---|
1254 | // rpcPic must not be the IRAP picture |
---|
1255 | if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) |
---|
1256 | { |
---|
1257 | #if SVC_POC |
---|
1258 | if( usePocBeforeReset ) |
---|
1259 | { |
---|
1260 | assert(rpcPic->getSlice(0)->getPocValueBeforeReset() < this->getPocValueBeforeReset()); |
---|
1261 | } |
---|
1262 | else |
---|
1263 | { |
---|
1264 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1265 | } |
---|
1266 | #else |
---|
1267 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1268 | #endif |
---|
1269 | } |
---|
1270 | } |
---|
1271 | } |
---|
1272 | } |
---|
1273 | |
---|
1274 | // When a picture is a leading picture, it shall precede, in decoding order, |
---|
1275 | // all trailing pictures that are associated with the same IRAP picture. |
---|
1276 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1277 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1278 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1279 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1280 | { |
---|
1281 | if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) |
---|
1282 | { |
---|
1283 | // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB |
---|
1284 | // rpcPic would violate the constraint if it was a trailing picture |
---|
1285 | #if SVC_POC |
---|
1286 | if( usePocBeforeReset ) |
---|
1287 | { |
---|
1288 | assert(rpcPic->getPOC() <= this->getAssociatedIrapPocBeforeReset()); |
---|
1289 | } |
---|
1290 | else |
---|
1291 | { |
---|
1292 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
1293 | } |
---|
1294 | #else |
---|
1295 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
1296 | #endif |
---|
1297 | } |
---|
1298 | } |
---|
1299 | |
---|
1300 | // Any RASL picture associated with a CRA or BLA picture shall precede any |
---|
1301 | // RADL picture associated with the CRA or BLA picture in output order |
---|
1302 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1303 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1304 | { |
---|
1305 | if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1306 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1307 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1308 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && |
---|
1309 | this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1310 | { |
---|
1311 | if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1312 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1313 | { |
---|
1314 | assert(rpcPic->getPOC() > this->getPOC()); |
---|
1315 | } |
---|
1316 | } |
---|
1317 | } |
---|
1318 | |
---|
1319 | // Any RASL picture associated with a CRA picture shall follow, in output |
---|
1320 | // order, any IRAP picture that precedes the CRA picture in decoding order. |
---|
1321 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1322 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1323 | { |
---|
1324 | if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
1325 | { |
---|
1326 | if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && |
---|
1327 | (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1328 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1329 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1330 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1331 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || |
---|
1332 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) |
---|
1333 | { |
---|
1334 | assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); |
---|
1335 | } |
---|
1336 | } |
---|
1337 | } |
---|
1338 | } |
---|
1339 | } |
---|
1340 | |
---|
1341 | |
---|
1342 | |
---|
1343 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1344 | */ |
---|
1345 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet) |
---|
1346 | { |
---|
1347 | TComPic* rpcPic; |
---|
1348 | Int i, isReference; |
---|
1349 | |
---|
1350 | #if !ALIGNED_BUMPING |
---|
1351 | checkLeadingPictureRestrictions(rcListPic); |
---|
1352 | #endif |
---|
1353 | |
---|
1354 | // loop through all pictures in the reference picture buffer |
---|
1355 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1356 | while ( iterPic != rcListPic.end()) |
---|
1357 | { |
---|
1358 | rpcPic = *(iterPic++); |
---|
1359 | |
---|
1360 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
1361 | { |
---|
1362 | continue; |
---|
1363 | } |
---|
1364 | |
---|
1365 | isReference = 0; |
---|
1366 | // loop through all pictures in the Reference Picture Set |
---|
1367 | // to see if the picture should be kept as reference picture |
---|
1368 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
1369 | { |
---|
1370 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
1371 | { |
---|
1372 | isReference = 1; |
---|
1373 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1374 | rpcPic->setIsLongTerm(0); |
---|
1375 | } |
---|
1376 | } |
---|
1377 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1378 | { |
---|
1379 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1380 | { |
---|
1381 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
1382 | { |
---|
1383 | isReference = 1; |
---|
1384 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1385 | } |
---|
1386 | } |
---|
1387 | else |
---|
1388 | { |
---|
1389 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1390 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1391 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1392 | if(rpcPic->getIsLongTerm() && curPoc == refPoc) |
---|
1393 | { |
---|
1394 | isReference = 1; |
---|
1395 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1396 | } |
---|
1397 | } |
---|
1398 | |
---|
1399 | } |
---|
1400 | |
---|
1401 | #if SVC_EXTENSION |
---|
1402 | if( isReference ) // Current picture is in the temporal RPS |
---|
1403 | { |
---|
1404 | assert( rpcPic->getSlice(0)->getDiscardableFlag() == 0 ); // Temporal RPS shall not contain picture with discardable_flag equal to 1 |
---|
1405 | } |
---|
1406 | #endif |
---|
1407 | |
---|
1408 | // mark the picture as "unused for reference" if it is not in |
---|
1409 | // the Reference Picture Set |
---|
1410 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
1411 | { |
---|
1412 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
1413 | rpcPic->setUsedByCurr(0); |
---|
1414 | rpcPic->setIsLongTerm(0); |
---|
1415 | } |
---|
1416 | //check that pictures of higher temporal layers are not used |
---|
1417 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
1418 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
1419 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
1420 | { |
---|
1421 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
1422 | } |
---|
1423 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
1424 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
1425 | { |
---|
1426 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
1427 | } |
---|
1428 | } |
---|
1429 | } |
---|
1430 | |
---|
1431 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1432 | */ |
---|
1433 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1434 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1435 | #else |
---|
1436 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess) |
---|
1437 | #endif |
---|
1438 | { |
---|
1439 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1440 | Int atLeastOneUnabledByRecoveryPoint = 0; |
---|
1441 | Int atLeastOneFlushedByPreviousIDR = 0; |
---|
1442 | #endif |
---|
1443 | TComPic* rpcPic; |
---|
1444 | Int i, isAvailable; |
---|
1445 | Int atLeastOneLost = 0; |
---|
1446 | Int atLeastOneRemoved = 0; |
---|
1447 | Int iPocLost = 0; |
---|
1448 | |
---|
1449 | // loop through all long-term pictures in the Reference Picture Set |
---|
1450 | // to see if the picture should be kept as reference picture |
---|
1451 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1452 | { |
---|
1453 | isAvailable = 0; |
---|
1454 | // loop through all pictures in the reference picture buffer |
---|
1455 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1456 | while ( iterPic != rcListPic.end()) |
---|
1457 | { |
---|
1458 | rpcPic = *(iterPic++); |
---|
1459 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1460 | { |
---|
1461 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1462 | { |
---|
1463 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1464 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1465 | { |
---|
1466 | isAvailable = 0; |
---|
1467 | } |
---|
1468 | else |
---|
1469 | { |
---|
1470 | isAvailable = 1; |
---|
1471 | } |
---|
1472 | #else |
---|
1473 | isAvailable = 1; |
---|
1474 | #endif |
---|
1475 | } |
---|
1476 | } |
---|
1477 | else |
---|
1478 | { |
---|
1479 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1480 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1481 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1482 | if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) |
---|
1483 | { |
---|
1484 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1485 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1486 | { |
---|
1487 | isAvailable = 0; |
---|
1488 | } |
---|
1489 | else |
---|
1490 | { |
---|
1491 | isAvailable = 1; |
---|
1492 | } |
---|
1493 | #else |
---|
1494 | isAvailable = 1; |
---|
1495 | #endif |
---|
1496 | } |
---|
1497 | } |
---|
1498 | } |
---|
1499 | // if there was no such long-term check the short terms |
---|
1500 | if(!isAvailable) |
---|
1501 | { |
---|
1502 | iterPic = rcListPic.begin(); |
---|
1503 | while ( iterPic != rcListPic.end()) |
---|
1504 | { |
---|
1505 | rpcPic = *(iterPic++); |
---|
1506 | |
---|
1507 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1508 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
1509 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
1510 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
1511 | { |
---|
1512 | curPoc = curPoc & (pocCycle - 1); |
---|
1513 | refPoc = refPoc & (pocCycle - 1); |
---|
1514 | } |
---|
1515 | |
---|
1516 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
1517 | { |
---|
1518 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1519 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1520 | { |
---|
1521 | isAvailable = 0; |
---|
1522 | } |
---|
1523 | else |
---|
1524 | { |
---|
1525 | isAvailable = 1; |
---|
1526 | rpcPic->setIsLongTerm(1); |
---|
1527 | break; |
---|
1528 | } |
---|
1529 | #else |
---|
1530 | isAvailable = 1; |
---|
1531 | rpcPic->setIsLongTerm(1); |
---|
1532 | break; |
---|
1533 | #endif |
---|
1534 | } |
---|
1535 | } |
---|
1536 | } |
---|
1537 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1538 | // but not available as reference picture |
---|
1539 | if(isAvailable == 0) |
---|
1540 | { |
---|
1541 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1542 | { |
---|
1543 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1544 | { |
---|
1545 | if(printErrors) |
---|
1546 | { |
---|
1547 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1548 | } |
---|
1549 | atLeastOneRemoved = 1; |
---|
1550 | } |
---|
1551 | else |
---|
1552 | { |
---|
1553 | if(printErrors) |
---|
1554 | { |
---|
1555 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1556 | } |
---|
1557 | atLeastOneLost = 1; |
---|
1558 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1559 | } |
---|
1560 | } |
---|
1561 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1562 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1563 | { |
---|
1564 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1565 | } |
---|
1566 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1567 | { |
---|
1568 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1569 | } |
---|
1570 | #endif |
---|
1571 | } |
---|
1572 | } |
---|
1573 | // loop through all short-term pictures in the Reference Picture Set |
---|
1574 | // to see if the picture should be kept as reference picture |
---|
1575 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
1576 | { |
---|
1577 | isAvailable = 0; |
---|
1578 | // loop through all pictures in the reference picture buffer |
---|
1579 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1580 | while ( iterPic != rcListPic.end()) |
---|
1581 | { |
---|
1582 | rpcPic = *(iterPic++); |
---|
1583 | |
---|
1584 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1585 | { |
---|
1586 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1587 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1588 | { |
---|
1589 | isAvailable = 0; |
---|
1590 | } |
---|
1591 | else |
---|
1592 | { |
---|
1593 | isAvailable = 1; |
---|
1594 | } |
---|
1595 | #else |
---|
1596 | isAvailable = 1; |
---|
1597 | #endif |
---|
1598 | } |
---|
1599 | } |
---|
1600 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1601 | // but not available as reference picture |
---|
1602 | if(isAvailable == 0) |
---|
1603 | { |
---|
1604 | #if !UNAVAILABLE_PIC_BUGFIX |
---|
1605 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1606 | #endif |
---|
1607 | { |
---|
1608 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1609 | { |
---|
1610 | if(printErrors) |
---|
1611 | { |
---|
1612 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1613 | } |
---|
1614 | atLeastOneRemoved = 1; |
---|
1615 | } |
---|
1616 | else |
---|
1617 | { |
---|
1618 | if(printErrors) |
---|
1619 | { |
---|
1620 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1621 | } |
---|
1622 | atLeastOneLost = 1; |
---|
1623 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1624 | } |
---|
1625 | } |
---|
1626 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1627 | #if UNAVAILABLE_PIC_BUGFIX |
---|
1628 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1629 | #else |
---|
1630 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1631 | #endif |
---|
1632 | { |
---|
1633 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1634 | } |
---|
1635 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1636 | { |
---|
1637 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1638 | } |
---|
1639 | #endif |
---|
1640 | } |
---|
1641 | } |
---|
1642 | |
---|
1643 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1644 | if(atLeastOneUnabledByRecoveryPoint || atLeastOneFlushedByPreviousIDR) |
---|
1645 | { |
---|
1646 | return -1; |
---|
1647 | } |
---|
1648 | #endif |
---|
1649 | if(atLeastOneLost) |
---|
1650 | { |
---|
1651 | return iPocLost+1; |
---|
1652 | } |
---|
1653 | if(atLeastOneRemoved) |
---|
1654 | { |
---|
1655 | return -2; |
---|
1656 | } |
---|
1657 | else |
---|
1658 | { |
---|
1659 | return 0; |
---|
1660 | } |
---|
1661 | } |
---|
1662 | |
---|
1663 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
1664 | */ |
---|
1665 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1666 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1667 | #else |
---|
1668 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP) |
---|
1669 | #endif |
---|
1670 | { |
---|
1671 | TComPic* rpcPic; |
---|
1672 | Int i, j; |
---|
1673 | Int k = 0; |
---|
1674 | Int nrOfNegativePictures = 0; |
---|
1675 | Int nrOfPositivePictures = 0; |
---|
1676 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
1677 | #if EFFICIENT_FIELD_IRAP |
---|
1678 | Bool irapIsInRPS = false; |
---|
1679 | #endif |
---|
1680 | #if SVC_POC |
---|
1681 | Bool pocsAdjusted = false; |
---|
1682 | #endif |
---|
1683 | |
---|
1684 | // loop through all pictures in the Reference Picture Set |
---|
1685 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1686 | { |
---|
1687 | j = 0; |
---|
1688 | // loop through all pictures in the reference picture buffer |
---|
1689 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1690 | while ( iterPic != rcListPic.end()) |
---|
1691 | { |
---|
1692 | j++; |
---|
1693 | rpcPic = *(iterPic++); |
---|
1694 | |
---|
1695 | #if SVC_POC |
---|
1696 | // poc adjustement by poc reset needs to be taken into account here |
---|
1697 | Int deltaPOC = pReferencePictureSet->getDeltaPOC(i) - rpcPic->getPicSym()->getSlice(0)->getPocResetDeltaPoc(); |
---|
1698 | if (rpcPic->getPicSym()->getSlice(0)->getPocResetDeltaPoc() != 0) |
---|
1699 | { |
---|
1700 | pocsAdjusted = true; |
---|
1701 | } |
---|
1702 | |
---|
1703 | if (rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + deltaPOC && rpcPic->getSlice(0)->isReferenced()) |
---|
1704 | #else |
---|
1705 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1706 | #endif |
---|
1707 | { |
---|
1708 | // This picture exists as a reference picture |
---|
1709 | // and should be added to the explicit Reference Picture Set |
---|
1710 | #if SVC_POC |
---|
1711 | pcRPS->setDeltaPOC(k, deltaPOC); |
---|
1712 | #else |
---|
1713 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
1714 | #endif |
---|
1715 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); |
---|
1716 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1717 | #if SVC_POC |
---|
1718 | pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + deltaPOC < pocRandomAccess) ); |
---|
1719 | #else |
---|
1720 | pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) ); |
---|
1721 | #endif |
---|
1722 | #endif |
---|
1723 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
1724 | { |
---|
1725 | nrOfNegativePictures++; |
---|
1726 | } |
---|
1727 | else |
---|
1728 | { |
---|
1729 | #if EFFICIENT_FIELD_IRAP |
---|
1730 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
1731 | { |
---|
1732 | irapIsInRPS = true; |
---|
1733 | } |
---|
1734 | #endif |
---|
1735 | nrOfPositivePictures++; |
---|
1736 | } |
---|
1737 | k++; |
---|
1738 | } |
---|
1739 | } |
---|
1740 | } |
---|
1741 | |
---|
1742 | #if EFFICIENT_FIELD_IRAP |
---|
1743 | Bool useNewRPS = false; |
---|
1744 | // if current picture is complimentary field associated to IRAP, add the IRAP to its RPS. |
---|
1745 | if(m_pcPic->isField() && !irapIsInRPS) |
---|
1746 | { |
---|
1747 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1748 | while ( iterPic != rcListPic.end()) |
---|
1749 | { |
---|
1750 | rpcPic = *(iterPic++); |
---|
1751 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
1752 | { |
---|
1753 | pcRPS->setDeltaPOC(k, 1); |
---|
1754 | pcRPS->setUsed(k, true); |
---|
1755 | nrOfPositivePictures++; |
---|
1756 | k ++; |
---|
1757 | useNewRPS = true; |
---|
1758 | } |
---|
1759 | } |
---|
1760 | } |
---|
1761 | #endif |
---|
1762 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
1763 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
1764 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
1765 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
1766 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
1767 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
1768 | if (!pReferencePictureSet->getInterRPSPrediction() |
---|
1769 | #if EFFICIENT_FIELD_IRAP |
---|
1770 | || useNewRPS |
---|
1771 | #endif |
---|
1772 | #if SVC_POC |
---|
1773 | || pocsAdjusted // inter RPS prediction does not work if POCs have been adjusted |
---|
1774 | #endif |
---|
1775 | ) |
---|
1776 | { |
---|
1777 | pcRPS->setInterRPSPrediction(false); |
---|
1778 | pcRPS->setNumRefIdc(0); |
---|
1779 | } |
---|
1780 | else |
---|
1781 | { |
---|
1782 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
1783 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
1784 | const TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
1785 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
1786 | Int iNewIdc=0; |
---|
1787 | for(i=0; i<= iRefPics; i++) |
---|
1788 | { |
---|
1789 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
1790 | Int iRefIdc = 0; |
---|
1791 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
1792 | { |
---|
1793 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
1794 | { |
---|
1795 | if (pcRPS->getUsed(j)) |
---|
1796 | { |
---|
1797 | iRefIdc = 1; |
---|
1798 | } |
---|
1799 | else |
---|
1800 | { |
---|
1801 | iRefIdc = 2; |
---|
1802 | } |
---|
1803 | } |
---|
1804 | } |
---|
1805 | pcRPS->setRefIdc(i, iRefIdc); |
---|
1806 | iNewIdc++; |
---|
1807 | } |
---|
1808 | pcRPS->setInterRPSPrediction(true); |
---|
1809 | pcRPS->setNumRefIdc(iNewIdc); |
---|
1810 | pcRPS->setDeltaRPS(deltaRPS); |
---|
1811 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
1812 | } |
---|
1813 | |
---|
1814 | this->setRPS(pcRPS); |
---|
1815 | this->setRPSidx(-1); |
---|
1816 | } |
---|
1817 | |
---|
1818 | //! init AC and DC values for weighted pred |
---|
1819 | Void TComSlice::initWpAcDcParam() |
---|
1820 | { |
---|
1821 | for(Int iComp = 0; iComp < MAX_NUM_COMPONENT; iComp++ ) |
---|
1822 | { |
---|
1823 | m_weightACDCParam[iComp].iAC = 0; |
---|
1824 | m_weightACDCParam[iComp].iDC = 0; |
---|
1825 | } |
---|
1826 | } |
---|
1827 | |
---|
1828 | //! get tables for weighted prediction |
---|
1829 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, WPScalingParam *&wp ) |
---|
1830 | { |
---|
1831 | assert (e<NUM_REF_PIC_LIST_01); |
---|
1832 | wp = m_weightPredTable[e][iRefIdx]; |
---|
1833 | } |
---|
1834 | |
---|
1835 | //! reset Default WP tables settings : no weight. |
---|
1836 | Void TComSlice::resetWpScaling() |
---|
1837 | { |
---|
1838 | for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
1839 | { |
---|
1840 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1841 | { |
---|
1842 | for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) |
---|
1843 | { |
---|
1844 | WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1845 | pwp->bPresentFlag = false; |
---|
1846 | pwp->uiLog2WeightDenom = 0; |
---|
1847 | pwp->uiLog2WeightDenom = 0; |
---|
1848 | pwp->iWeight = 1; |
---|
1849 | pwp->iOffset = 0; |
---|
1850 | } |
---|
1851 | } |
---|
1852 | } |
---|
1853 | } |
---|
1854 | |
---|
1855 | //! init WP table |
---|
1856 | Void TComSlice::initWpScaling(const TComSPS *sps) |
---|
1857 | { |
---|
1858 | const Bool bUseHighPrecisionPredictionWeighting = sps->getUseHighPrecisionPredictionWeighting(); |
---|
1859 | for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
1860 | { |
---|
1861 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1862 | { |
---|
1863 | for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) |
---|
1864 | { |
---|
1865 | WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1866 | if ( !pwp->bPresentFlag ) |
---|
1867 | { |
---|
1868 | // Inferring values not present : |
---|
1869 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
1870 | pwp->iOffset = 0; |
---|
1871 | } |
---|
1872 | |
---|
1873 | #if SVC_EXTENSION |
---|
1874 | const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (getBitDepth(toChannelType(ComponentID(yuv)))-8)); |
---|
1875 | #else |
---|
1876 | const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (sps->getBitDepth(toChannelType(ComponentID(yuv)))-8)); |
---|
1877 | #endif |
---|
1878 | |
---|
1879 | pwp->w = pwp->iWeight; |
---|
1880 | pwp->o = pwp->iOffset * offsetScalingFactor; //NOTE: This value of the ".o" variable is never used - .o is set immediately before it gets used |
---|
1881 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
1882 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
1883 | } |
---|
1884 | } |
---|
1885 | } |
---|
1886 | } |
---|
1887 | |
---|
1888 | // ------------------------------------------------------------------------------------------------ |
---|
1889 | // Video parameter set (VPS) |
---|
1890 | // ------------------------------------------------------------------------------------------------ |
---|
1891 | #if SVC_EXTENSION |
---|
1892 | TComVPS::TComVPS() |
---|
1893 | : m_VPSId ( 0) |
---|
1894 | , m_uiMaxTLayers ( 1) |
---|
1895 | , m_uiMaxLayers ( 1) |
---|
1896 | , m_bTemporalIdNestingFlag (false) |
---|
1897 | , m_numHrdParameters ( 0) |
---|
1898 | , m_hrdParameters () |
---|
1899 | , m_hrdOpSetIdx () |
---|
1900 | , m_cprmsPresentFlag () |
---|
1901 | , m_baseLayerInternalFlag (true) |
---|
1902 | , m_baseLayerAvailableFlag (true) |
---|
1903 | , m_maxLayerId (0) |
---|
1904 | , m_numLayerSets (0) |
---|
1905 | , m_numOutputLayerSets (0) |
---|
1906 | , m_numProfileTierLevel (0) |
---|
1907 | , m_numAddOutputLayerSets (0) |
---|
1908 | , m_defaultTargetOutputLayerIdc(0) |
---|
1909 | , m_bitRatePresentVpsFlag (false) |
---|
1910 | , m_picRatePresentVpsFlag (false) |
---|
1911 | , m_repFormatIdxPresentFlag (false) |
---|
1912 | , m_vpsNumRepFormats (1) |
---|
1913 | , m_viewIdLen (0) |
---|
1914 | , m_vpsNonVuiExtLength (0) |
---|
1915 | , m_vpsPocLsbAlignedFlag(false) |
---|
1916 | { |
---|
1917 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
1918 | { |
---|
1919 | m_numReorderPics[i] = 0; |
---|
1920 | m_uiMaxDecPicBuffering[i] = 1; |
---|
1921 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1922 | } |
---|
1923 | |
---|
1924 | m_nonHEVCBaseLayerFlag = false; |
---|
1925 | m_splittingFlag = false; |
---|
1926 | m_nuhLayerIdPresentFlag = false; |
---|
1927 | ::memset(m_scalabilityMask, 0, sizeof(m_scalabilityMask)); |
---|
1928 | ::memset(m_dimensionIdLen, 0, sizeof(m_dimensionIdLen)); |
---|
1929 | ::memset(m_layerIdInNuh, 0, sizeof(m_layerIdInNuh)); |
---|
1930 | ::memset(m_dimensionId, 0, sizeof(m_dimensionId)); |
---|
1931 | |
---|
1932 | m_numScalabilityTypes = 0; |
---|
1933 | ::memset(m_layerIdxInVps, 0, sizeof(m_layerIdxInVps)); |
---|
1934 | ::memset(m_profilePresentFlag, 0, sizeof(m_profilePresentFlag)); |
---|
1935 | |
---|
1936 | ::memset(m_layerIdIncludedFlag, 0, sizeof(m_layerIdIncludedFlag)); |
---|
1937 | // Consider dynamic allocation for outputLayerSetIdx and outputLayerFlag |
---|
1938 | ::memset(m_outputLayerSetIdx, 0, sizeof(m_outputLayerSetIdx)); |
---|
1939 | ::memset(m_outputLayerFlag, 0, sizeof(m_outputLayerFlag)); |
---|
1940 | |
---|
1941 | ::memset(m_directDependencyFlag, 0, sizeof(m_directDependencyFlag)); |
---|
1942 | ::memset(m_numDirectRefLayers, 0, sizeof(m_numDirectRefLayers )); |
---|
1943 | ::memset(m_refLayerId, 0, sizeof(m_refLayerId )); |
---|
1944 | m_directDepTypeLen = 2; |
---|
1945 | ::memset(m_directDependencyType, 0, sizeof(m_directDependencyType)); |
---|
1946 | |
---|
1947 | m_maxOneActiveRefLayerFlag = true; |
---|
1948 | ::memset(m_pocLsbNotPresentFlag, 0, sizeof(m_pocLsbNotPresentFlag)); |
---|
1949 | m_crossLayerPictureTypeAlignFlag = true; |
---|
1950 | m_crossLayerIrapAlignFlag = true; |
---|
1951 | m_crossLayerAlignedIdrOnlyFlag = false; |
---|
1952 | m_maxTidRefPresentFlag = true; |
---|
1953 | for( Int i = 0; i < MAX_VPS_LAYER_IDX_PLUS1 - 1; i++) |
---|
1954 | { |
---|
1955 | for( Int j = 0; j < MAX_VPS_LAYER_IDX_PLUS1; j++) |
---|
1956 | { |
---|
1957 | m_maxTidIlRefPicsPlus1[i][j] = m_uiMaxTLayers + 1; |
---|
1958 | } |
---|
1959 | } |
---|
1960 | |
---|
1961 | m_tilesNotInUseFlag = true; |
---|
1962 | m_wppNotInUseFlag = true; |
---|
1963 | ::memset(m_tilesInUseFlag, 0, sizeof(m_tilesInUseFlag)); |
---|
1964 | ::memset(m_loopFilterNotAcrossTilesFlag, 0, sizeof(m_loopFilterNotAcrossTilesFlag)); |
---|
1965 | ::memset(m_tileBoundariesAlignedFlag, 0, sizeof(m_tileBoundariesAlignedFlag)); |
---|
1966 | ::memset(m_wppInUseFlag, 0, sizeof(m_wppInUseFlag)); |
---|
1967 | |
---|
1968 | m_ilpRestrictedRefLayersFlag = false; |
---|
1969 | ::memset(m_minSpatialSegmentOffsetPlus1, 0, sizeof(m_minSpatialSegmentOffsetPlus1)); |
---|
1970 | ::memset(m_ctuBasedOffsetEnabledFlag, 0, sizeof(m_ctuBasedOffsetEnabledFlag)); |
---|
1971 | ::memset(m_minHorizontalCtuOffsetPlus1, 0, sizeof(m_minHorizontalCtuOffsetPlus1)); |
---|
1972 | |
---|
1973 | m_vidSigPresentVpsFlag=true; |
---|
1974 | m_vpsVidSigInfo=1; |
---|
1975 | ::memset( m_vpsVidSigIdx, 0, sizeof(m_vpsVidSigIdx) ); |
---|
1976 | m_vpsVidSigIdx[0]=0; |
---|
1977 | for (Int i=0; i < 16; i++) |
---|
1978 | { |
---|
1979 | m_vpsVidFormat[i] = 5; |
---|
1980 | m_vpsFullRangeFlag[i] = false; |
---|
1981 | m_vpsColorPrimaries[i] = 2; |
---|
1982 | m_vpsTransChar[i] = 2; |
---|
1983 | m_vpsMatCoeff[i] = 2; |
---|
1984 | } |
---|
1985 | |
---|
1986 | ::memset( m_bitRatePresentFlag, 0, sizeof(m_bitRatePresentFlag) ); |
---|
1987 | ::memset( m_picRatePresentFlag, 0, sizeof(m_picRatePresentFlag) ); |
---|
1988 | ::memset( m_avgBitRate , 0, sizeof(m_avgBitRate) ); |
---|
1989 | ::memset( m_maxBitRate , 0, sizeof(m_maxBitRate) ); |
---|
1990 | ::memset( m_constPicRateIdc , 0, sizeof(m_constPicRateIdc) ); |
---|
1991 | ::memset( m_avgPicRate , 0, sizeof(m_avgPicRate) ); |
---|
1992 | ::memset( m_vpsRepFormatIdx , 0, sizeof(m_vpsRepFormatIdx) ); |
---|
1993 | ::memset( m_viewIdVal , 0, sizeof(m_viewIdVal)) ; |
---|
1994 | |
---|
1995 | for( Int i = 0; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
1996 | { |
---|
1997 | m_numberRefLayers[i] = 0; |
---|
1998 | for( Int j = 0; j < MAX_NUM_LAYER_IDS; j++ ) |
---|
1999 | { |
---|
2000 | m_recursiveRefLayerFlag[i][j] = 0; |
---|
2001 | } |
---|
2002 | } |
---|
2003 | |
---|
2004 | ::memset( m_subLayerFlagInfoPresentFlag, 0, sizeof(m_subLayerFlagInfoPresentFlag ) ); |
---|
2005 | ::memset( m_subLayerDpbInfoPresentFlag, 0, sizeof(m_subLayerDpbInfoPresentFlag ) ); |
---|
2006 | ::memset( m_maxVpsDecPicBufferingMinus1, 0, sizeof(m_maxVpsDecPicBufferingMinus1 ) ); |
---|
2007 | ::memset( m_maxVpsNumReorderPics, 0, sizeof(m_maxVpsNumReorderPics ) ); |
---|
2008 | ::memset( m_maxVpsLatencyIncreasePlus1, 0, sizeof(m_maxVpsLatencyIncreasePlus1 ) ); |
---|
2009 | ::memset( m_numSubDpbs , 0, sizeof(m_numSubDpbs) ); |
---|
2010 | ::memset( m_baseLayerPSCompatibilityFlag, 0, sizeof(m_baseLayerPSCompatibilityFlag) ); |
---|
2011 | } |
---|
2012 | #else |
---|
2013 | TComVPS::TComVPS() |
---|
2014 | : m_VPSId ( 0) |
---|
2015 | , m_uiMaxTLayers ( 1) |
---|
2016 | , m_uiMaxLayers ( 1) |
---|
2017 | , m_bTemporalIdNestingFlag (false) |
---|
2018 | , m_numHrdParameters ( 0) |
---|
2019 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
2020 | , m_hrdParameters () |
---|
2021 | , m_hrdOpSetIdx () |
---|
2022 | , m_cprmsPresentFlag () |
---|
2023 | { |
---|
2024 | |
---|
2025 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
2026 | { |
---|
2027 | m_numReorderPics[i] = 0; |
---|
2028 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2029 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2030 | } |
---|
2031 | } |
---|
2032 | #endif //SVC_EXTENSION |
---|
2033 | |
---|
2034 | TComVPS::~TComVPS() |
---|
2035 | { |
---|
2036 | } |
---|
2037 | |
---|
2038 | // ------------------------------------------------------------------------------------------------ |
---|
2039 | // Sequence parameter set (SPS) |
---|
2040 | // ------------------------------------------------------------------------------------------------ |
---|
2041 | |
---|
2042 | TComSPS::TComSPS() |
---|
2043 | : m_SPSId ( 0) |
---|
2044 | , m_VPSId ( 0) |
---|
2045 | , m_chromaFormatIdc (CHROMA_420) |
---|
2046 | , m_uiMaxTLayers ( 1) |
---|
2047 | // Structure |
---|
2048 | , m_picWidthInLumaSamples (352) |
---|
2049 | , m_picHeightInLumaSamples (288) |
---|
2050 | , m_log2MinCodingBlockSize ( 0) |
---|
2051 | , m_log2DiffMaxMinCodingBlockSize(0) |
---|
2052 | , m_uiMaxCUWidth ( 32) |
---|
2053 | , m_uiMaxCUHeight ( 32) |
---|
2054 | , m_uiMaxTotalCUDepth ( 3) |
---|
2055 | , m_bLongTermRefsPresent (false) |
---|
2056 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
2057 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
2058 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
2059 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
2060 | // Tool list |
---|
2061 | , m_usePCM (false) |
---|
2062 | , m_pcmLog2MaxSize ( 5) |
---|
2063 | , m_uiPCMLog2MinSize ( 7) |
---|
2064 | , m_useExtendedPrecision (false) |
---|
2065 | , m_useHighPrecisionPredictionWeighting(false) |
---|
2066 | , m_useResidualRotation (false) |
---|
2067 | , m_useSingleSignificanceMapContext(false) |
---|
2068 | , m_useGolombRiceParameterAdaptation(false) |
---|
2069 | , m_alignCABACBeforeBypass (false) |
---|
2070 | , m_bPCMFilterDisableFlag (false) |
---|
2071 | , m_disableIntraReferenceSmoothing(false) |
---|
2072 | , m_uiBitsForPOC ( 8) |
---|
2073 | , m_numLongTermRefPicSPS ( 0) |
---|
2074 | , m_uiMaxTrSize ( 32) |
---|
2075 | , m_bUseSAO (false) |
---|
2076 | , m_bTemporalIdNestingFlag (false) |
---|
2077 | , m_scalingListEnabledFlag (false) |
---|
2078 | , m_useStrongIntraSmoothing (false) |
---|
2079 | , m_vuiParametersPresentFlag (false) |
---|
2080 | , m_vuiParameters () |
---|
2081 | #if SVC_EXTENSION |
---|
2082 | , m_layerId ( 0 ) |
---|
2083 | , m_extensionFlag ( false ) |
---|
2084 | , m_bV1CompatibleSPSFlag ( 0) |
---|
2085 | , m_updateRepFormatFlag (false) |
---|
2086 | , m_updateRepFormatIndex (0) |
---|
2087 | , m_inferScalingListFlag ( false ) |
---|
2088 | , m_scalingListRefLayerId ( 0 ) |
---|
2089 | #endif //SVC_EXTENSION |
---|
2090 | { |
---|
2091 | for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
2092 | { |
---|
2093 | m_bitDepths.recon[ch] = 8; |
---|
2094 | #if O0043_BEST_EFFORT_DECODING |
---|
2095 | m_bitDepths.stream[ch] = 8; |
---|
2096 | #endif |
---|
2097 | m_pcmBitDepths[ch] = 8; |
---|
2098 | m_qpBDOffset [ch] = 0; |
---|
2099 | } |
---|
2100 | |
---|
2101 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
2102 | { |
---|
2103 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2104 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2105 | m_numReorderPics[i] = 0; |
---|
2106 | } |
---|
2107 | |
---|
2108 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
---|
2109 | { |
---|
2110 | m_useResidualDPCM[signallingModeIndex] = false; |
---|
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 | TComPPS::TComPPS() |
---|
2247 | : m_PPSId (0) |
---|
2248 | , m_SPSId (0) |
---|
2249 | , m_picInitQPMinus26 (0) |
---|
2250 | , m_useDQP (false) |
---|
2251 | , m_bConstrainedIntraPred (false) |
---|
2252 | , m_bSliceChromaQpFlag (false) |
---|
2253 | , m_uiMaxCuDQPDepth (0) |
---|
2254 | , m_MaxCuChromaQpAdjDepth (0) |
---|
2255 | , m_ChromaQpAdjTableSize (0) |
---|
2256 | , m_chromaCbQpOffset (0) |
---|
2257 | , m_chromaCrQpOffset (0) |
---|
2258 | , m_numRefIdxL0DefaultActive (1) |
---|
2259 | , m_numRefIdxL1DefaultActive (1) |
---|
2260 | , m_useCrossComponentPrediction (false) |
---|
2261 | , m_TransquantBypassEnableFlag (false) |
---|
2262 | , m_useTransformSkip (false) |
---|
2263 | , m_transformSkipLog2MaxSize (2) |
---|
2264 | , m_dependentSliceSegmentsEnabledFlag(false) |
---|
2265 | , m_tilesEnabledFlag (false) |
---|
2266 | , m_entropyCodingSyncEnabledFlag (false) |
---|
2267 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
2268 | , m_uniformSpacingFlag (false) |
---|
2269 | , m_numTileColumnsMinus1 (0) |
---|
2270 | , m_numTileRowsMinus1 (0) |
---|
2271 | , m_signHideFlag (false) |
---|
2272 | , m_cabacInitPresentFlag (false) |
---|
2273 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
2274 | , m_loopFilterAcrossSlicesEnabledFlag(false) |
---|
2275 | , m_listsModificationPresentFlag (0) |
---|
2276 | , m_numExtraSliceHeaderBits (0) |
---|
2277 | |
---|
2278 | #if SVC_EXTENSION |
---|
2279 | , m_extensionFlag(false) |
---|
2280 | , m_layerId(0) |
---|
2281 | , m_inferScalingListFlag ( false ) |
---|
2282 | , m_scalingListRefLayerId ( 0 ) |
---|
2283 | , m_pocResetInfoPresentFlag (false) |
---|
2284 | , m_numRefLayerLocationOffsets ( 0 ) |
---|
2285 | #if CGS_3D_ASYMLUT |
---|
2286 | , m_nCGSFlag(0) |
---|
2287 | , m_nCGSOutputBitDepthY(0) |
---|
2288 | , m_nCGSOutputBitDepthC(0) |
---|
2289 | #endif |
---|
2290 | #endif //SVC_EXTENSION |
---|
2291 | { |
---|
2292 | for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
2293 | { |
---|
2294 | m_saoOffsetBitShift[ch] = 0; |
---|
2295 | } |
---|
2296 | 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. |
---|
2297 | m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CrOffset = 0; |
---|
2298 | |
---|
2299 | #if SVC_EXTENSION |
---|
2300 | ::memset(m_scaledRefLayerOffsetPresentFlag, 0, sizeof(m_scaledRefLayerOffsetPresentFlag)); |
---|
2301 | ::memset(m_refRegionOffsetPresentFlag, 0, sizeof(m_refRegionOffsetPresentFlag)); |
---|
2302 | #endif //SVC_EXTENSION |
---|
2303 | } |
---|
2304 | |
---|
2305 | TComPPS::~TComPPS() |
---|
2306 | { |
---|
2307 | } |
---|
2308 | |
---|
2309 | TComReferencePictureSet::TComReferencePictureSet() |
---|
2310 | : m_numberOfPictures (0) |
---|
2311 | , m_numberOfNegativePictures (0) |
---|
2312 | , m_numberOfPositivePictures (0) |
---|
2313 | , m_numberOfLongtermPictures (0) |
---|
2314 | , m_interRPSPrediction (0) |
---|
2315 | , m_deltaRIdxMinus1 (0) |
---|
2316 | , m_deltaRPS (0) |
---|
2317 | , m_numRefIdc (0) |
---|
2318 | { |
---|
2319 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
2320 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
2321 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
2322 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
2323 | ::memset( m_bCheckLTMSB, 0, sizeof(m_bCheckLTMSB) ); |
---|
2324 | ::memset( m_pocLSBLT, 0, sizeof(m_pocLSBLT) ); |
---|
2325 | ::memset( m_deltaPOCMSBCycleLT, 0, sizeof(m_deltaPOCMSBCycleLT) ); |
---|
2326 | ::memset( m_deltaPocMSBPresentFlag, 0, sizeof(m_deltaPocMSBPresentFlag) ); |
---|
2327 | } |
---|
2328 | |
---|
2329 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
2330 | { |
---|
2331 | } |
---|
2332 | |
---|
2333 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
2334 | { |
---|
2335 | m_used[bufferNum] = used; |
---|
2336 | } |
---|
2337 | |
---|
2338 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
2339 | { |
---|
2340 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
2341 | } |
---|
2342 | |
---|
2343 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
2344 | { |
---|
2345 | m_numberOfPictures = numberOfPictures; |
---|
2346 | } |
---|
2347 | |
---|
2348 | Int TComReferencePictureSet::getUsed(Int bufferNum) const |
---|
2349 | { |
---|
2350 | return m_used[bufferNum]; |
---|
2351 | } |
---|
2352 | |
---|
2353 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) const |
---|
2354 | { |
---|
2355 | return m_deltaPOC[bufferNum]; |
---|
2356 | } |
---|
2357 | |
---|
2358 | Int TComReferencePictureSet::getNumberOfPictures() const |
---|
2359 | { |
---|
2360 | return m_numberOfPictures; |
---|
2361 | } |
---|
2362 | |
---|
2363 | Int TComReferencePictureSet::getPOC(Int bufferNum) const |
---|
2364 | { |
---|
2365 | return m_POC[bufferNum]; |
---|
2366 | } |
---|
2367 | |
---|
2368 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
2369 | { |
---|
2370 | m_POC[bufferNum] = POC; |
---|
2371 | } |
---|
2372 | |
---|
2373 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) const |
---|
2374 | { |
---|
2375 | return m_bCheckLTMSB[bufferNum]; |
---|
2376 | } |
---|
2377 | |
---|
2378 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
2379 | { |
---|
2380 | m_bCheckLTMSB[bufferNum] = b; |
---|
2381 | } |
---|
2382 | |
---|
2383 | //! set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
2384 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
2385 | { |
---|
2386 | m_refIdc[bufferNum] = refIdc; |
---|
2387 | } |
---|
2388 | |
---|
2389 | //! get the reference idc value at uiBufferNum |
---|
2390 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) const |
---|
2391 | { |
---|
2392 | return m_refIdc[bufferNum]; |
---|
2393 | } |
---|
2394 | |
---|
2395 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
2396 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
2397 | * +ve values are in increasing order. |
---|
2398 | * \returns Void |
---|
2399 | */ |
---|
2400 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
2401 | { |
---|
2402 | // sort in increasing order (smallest first) |
---|
2403 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
2404 | { |
---|
2405 | Int deltaPOC = getDeltaPOC(j); |
---|
2406 | Bool used = getUsed(j); |
---|
2407 | for (Int k=j-1; k >= 0; k--) |
---|
2408 | { |
---|
2409 | Int temp = getDeltaPOC(k); |
---|
2410 | if (deltaPOC < temp) |
---|
2411 | { |
---|
2412 | setDeltaPOC(k+1, temp); |
---|
2413 | setUsed(k+1, getUsed(k)); |
---|
2414 | setDeltaPOC(k, deltaPOC); |
---|
2415 | setUsed(k, used); |
---|
2416 | } |
---|
2417 | } |
---|
2418 | } |
---|
2419 | // flip the negative values to largest first |
---|
2420 | Int numNegPics = getNumberOfNegativePictures(); |
---|
2421 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
2422 | { |
---|
2423 | Int deltaPOC = getDeltaPOC(j); |
---|
2424 | Bool used = getUsed(j); |
---|
2425 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
2426 | setUsed(j, getUsed(k)); |
---|
2427 | setDeltaPOC(k, deltaPOC); |
---|
2428 | setUsed(k, used); |
---|
2429 | } |
---|
2430 | } |
---|
2431 | |
---|
2432 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
2433 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
2434 | * \returns Void |
---|
2435 | */ |
---|
2436 | Void TComReferencePictureSet::printDeltaPOC() const |
---|
2437 | { |
---|
2438 | printf("DeltaPOC = { "); |
---|
2439 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
2440 | { |
---|
2441 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
2442 | } |
---|
2443 | if (getInterRPSPrediction()) |
---|
2444 | { |
---|
2445 | printf("}, RefIdc = { "); |
---|
2446 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
2447 | { |
---|
2448 | printf("%d ", getRefIdc(j)); |
---|
2449 | } |
---|
2450 | } |
---|
2451 | printf("}\n"); |
---|
2452 | } |
---|
2453 | |
---|
2454 | TComRefPicListModification::TComRefPicListModification() |
---|
2455 | : m_refPicListModificationFlagL0 (false) |
---|
2456 | , m_refPicListModificationFlagL1 (false) |
---|
2457 | { |
---|
2458 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
2459 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
2460 | } |
---|
2461 | |
---|
2462 | TComRefPicListModification::~TComRefPicListModification() |
---|
2463 | { |
---|
2464 | } |
---|
2465 | |
---|
2466 | TComScalingList::TComScalingList() |
---|
2467 | { |
---|
2468 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2469 | { |
---|
2470 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
2471 | { |
---|
2472 | m_scalingListCoef[sizeId][listId].resize(min<Int>(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2473 | } |
---|
2474 | } |
---|
2475 | } |
---|
2476 | |
---|
2477 | /** set default quantization matrix to array |
---|
2478 | */ |
---|
2479 | Void TComScalingList::setDefaultScalingList() |
---|
2480 | { |
---|
2481 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2482 | { |
---|
2483 | for(UInt listId=0;listId<SCALING_LIST_NUM;listId++) |
---|
2484 | { |
---|
2485 | processDefaultMatrix(sizeId, listId); |
---|
2486 | } |
---|
2487 | } |
---|
2488 | } |
---|
2489 | /** check if use default quantization matrix |
---|
2490 | * \returns true if use default quantization matrix in all size |
---|
2491 | */ |
---|
2492 | Bool TComScalingList::checkDefaultScalingList() |
---|
2493 | { |
---|
2494 | UInt defaultCounter=0; |
---|
2495 | |
---|
2496 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2497 | { |
---|
2498 | for(UInt listId=0;listId<SCALING_LIST_NUM;listId++) |
---|
2499 | { |
---|
2500 | if( !memcmp(getScalingListAddress(sizeId,listId), getScalingListDefaultAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
2501 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
2502 | { |
---|
2503 | defaultCounter++; |
---|
2504 | } |
---|
2505 | } |
---|
2506 | } |
---|
2507 | |
---|
2508 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM )) ? false : true; |
---|
2509 | } |
---|
2510 | |
---|
2511 | /** get scaling matrix from RefMatrixID |
---|
2512 | * \param sizeId size index |
---|
2513 | * \param listId index of input matrix |
---|
2514 | * \param refListId index of reference matrix |
---|
2515 | */ |
---|
2516 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
2517 | { |
---|
2518 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2519 | } |
---|
2520 | |
---|
2521 | Void TComScalingList::checkPredMode(UInt sizeId, UInt listId) |
---|
2522 | { |
---|
2523 | Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. |
---|
2524 | |
---|
2525 | for(Int predListIdx = (Int)listId ; predListIdx >= 0; predListIdx-=predListStep) |
---|
2526 | { |
---|
2527 | if( !memcmp(getScalingListAddress(sizeId,listId),((listId == predListIdx) ? |
---|
2528 | getScalingListDefaultAddress(sizeId, predListIdx): getScalingListAddress(sizeId, predListIdx)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
2529 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value |
---|
2530 | { |
---|
2531 | setRefMatrixId(sizeId, listId, predListIdx); |
---|
2532 | setScalingListPredModeFlag(sizeId, listId, false); |
---|
2533 | return; |
---|
2534 | } |
---|
2535 | } |
---|
2536 | setScalingListPredModeFlag(sizeId, listId, true); |
---|
2537 | } |
---|
2538 | |
---|
2539 | static Void outputScalingListHelp(std::ostream &os) |
---|
2540 | { |
---|
2541 | os << "The scaling list file specifies all matrices and their DC values; none can be missing,\n" |
---|
2542 | "but their order is arbitrary.\n\n" |
---|
2543 | "The matrices are specified by:\n" |
---|
2544 | "<matrix name><unchecked data>\n" |
---|
2545 | " <value>,<value>,<value>,....\n\n" |
---|
2546 | " Line-feeds can be added arbitrarily between values, and the number of values needs to be\n" |
---|
2547 | " at least the number of entries for the matrix (superfluous entries are ignored).\n" |
---|
2548 | " The <unchecked data> is text on the same line as the matrix that is not checked\n" |
---|
2549 | " except to ensure that the matrix name token is unique. It is recommended that it is ' ='\n" |
---|
2550 | " The values in the matrices are the absolute values (0-255), not the delta values as\n" |
---|
2551 | " exchanged between the encoder and decoder\n\n" |
---|
2552 | "The DC values (for matrix sizes larger than 8x8) are specified by:\n" |
---|
2553 | "<matrix name>_DC<unchecked data>\n" |
---|
2554 | " <value>\n"; |
---|
2555 | |
---|
2556 | os << "The permitted matrix names are:\n"; |
---|
2557 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
2558 | { |
---|
2559 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
2560 | { |
---|
2561 | if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0)) |
---|
2562 | { |
---|
2563 | os << " " << MatrixType[sizeIdc][listIdc] << '\n'; |
---|
2564 | } |
---|
2565 | } |
---|
2566 | } |
---|
2567 | } |
---|
2568 | |
---|
2569 | Void TComScalingList::outputScalingLists(std::ostream &os) const |
---|
2570 | { |
---|
2571 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
2572 | { |
---|
2573 | const UInt size = min(8,4<<(sizeIdc)); |
---|
2574 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
2575 | { |
---|
2576 | if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0)) |
---|
2577 | { |
---|
2578 | const Int *src = getScalingListAddress(sizeIdc, listIdc); |
---|
2579 | os << (MatrixType[sizeIdc][listIdc]) << " =\n "; |
---|
2580 | for(UInt y=0; y<size; y++) |
---|
2581 | { |
---|
2582 | for(UInt x=0; x<size; x++, src++) |
---|
2583 | { |
---|
2584 | os << std::setw(3) << (*src) << ", "; |
---|
2585 | } |
---|
2586 | os << (y+1<size?"\n ":"\n"); |
---|
2587 | } |
---|
2588 | if(sizeIdc > SCALING_LIST_8x8) |
---|
2589 | { |
---|
2590 | os << MatrixType_DC[sizeIdc][listIdc] << " = \n " << std::setw(3) << getScalingListDC(sizeIdc, listIdc) << "\n"; |
---|
2591 | } |
---|
2592 | os << "\n"; |
---|
2593 | } |
---|
2594 | } |
---|
2595 | } |
---|
2596 | } |
---|
2597 | |
---|
2598 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
2599 | { |
---|
2600 | static const Int LINE_SIZE=1024; |
---|
2601 | FILE *fp = NULL; |
---|
2602 | Char line[LINE_SIZE]; |
---|
2603 | |
---|
2604 | if (pchFile == NULL) |
---|
2605 | { |
---|
2606 | fprintf(stderr, "Error: no scaling list file specified. Help on scaling lists being output\n"); |
---|
2607 | outputScalingListHelp(std::cout); |
---|
2608 | std::cout << "\n\nExample scaling list file using default values:\n\n"; |
---|
2609 | outputScalingLists(std::cout); |
---|
2610 | exit (1); |
---|
2611 | return true; |
---|
2612 | } |
---|
2613 | else if ((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
2614 | { |
---|
2615 | fprintf(stderr, "Error: cannot open scaling list file %s for reading\n",pchFile); |
---|
2616 | return true; |
---|
2617 | } |
---|
2618 | |
---|
2619 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
2620 | { |
---|
2621 | const UInt size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
2622 | |
---|
2623 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
2624 | { |
---|
2625 | Int * const src = getScalingListAddress(sizeIdc, listIdc); |
---|
2626 | |
---|
2627 | if ((sizeIdc==SCALING_LIST_32x32) && (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) // derive chroma32x32 from chroma16x16 |
---|
2628 | { |
---|
2629 | const Int *srcNextSmallerSize = getScalingListAddress(sizeIdc-1, listIdc); |
---|
2630 | for(UInt i=0; i<size; i++) |
---|
2631 | { |
---|
2632 | src[i] = srcNextSmallerSize[i]; |
---|
2633 | } |
---|
2634 | setScalingListDC(sizeIdc,listIdc,(sizeIdc > SCALING_LIST_8x8) ? getScalingListDC(sizeIdc-1, listIdc) : src[0]); |
---|
2635 | } |
---|
2636 | else |
---|
2637 | { |
---|
2638 | { |
---|
2639 | fseek(fp, 0, SEEK_SET); |
---|
2640 | Bool bFound=false; |
---|
2641 | while ((!feof(fp)) && (!bFound)) |
---|
2642 | { |
---|
2643 | Char *ret = fgets(line, LINE_SIZE, fp); |
---|
2644 | Char *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType[sizeIdc][listIdc]); |
---|
2645 | // This could be a match against the DC string as well, so verify it isn't |
---|
2646 | if (findNamePosition!= NULL && (MatrixType_DC[sizeIdc][listIdc]==NULL || strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL)) |
---|
2647 | { |
---|
2648 | bFound=true; |
---|
2649 | } |
---|
2650 | } |
---|
2651 | if (!bFound) |
---|
2652 | { |
---|
2653 | fprintf(stderr, "Error: cannot find Matrix %s from scaling list file %s\n", MatrixType[sizeIdc][listIdc], pchFile); |
---|
2654 | return true; |
---|
2655 | } |
---|
2656 | } |
---|
2657 | for (UInt i=0; i<size; i++) |
---|
2658 | { |
---|
2659 | Int data; |
---|
2660 | if (fscanf(fp, "%d,", &data)!=1) |
---|
2661 | { |
---|
2662 | 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)); |
---|
2663 | return true; |
---|
2664 | } |
---|
2665 | if (data<0 || data>255) |
---|
2666 | { |
---|
2667 | 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)); |
---|
2668 | return true; |
---|
2669 | } |
---|
2670 | src[i] = data; |
---|
2671 | } |
---|
2672 | |
---|
2673 | //set DC value for default matrix check |
---|
2674 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
2675 | |
---|
2676 | if(sizeIdc > SCALING_LIST_8x8) |
---|
2677 | { |
---|
2678 | { |
---|
2679 | fseek(fp, 0, SEEK_SET); |
---|
2680 | Bool bFound=false; |
---|
2681 | while ((!feof(fp)) && (!bFound)) |
---|
2682 | { |
---|
2683 | Char *ret = fgets(line, LINE_SIZE, fp); |
---|
2684 | Char *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType_DC[sizeIdc][listIdc]); |
---|
2685 | if (findNamePosition!= NULL) |
---|
2686 | { |
---|
2687 | // This won't be a match against the non-DC string. |
---|
2688 | bFound=true; |
---|
2689 | } |
---|
2690 | } |
---|
2691 | if (!bFound) |
---|
2692 | { |
---|
2693 | fprintf(stderr, "Error: cannot find DC Matrix %s from scaling list file %s\n", MatrixType_DC[sizeIdc][listIdc], pchFile); |
---|
2694 | return true; |
---|
2695 | } |
---|
2696 | } |
---|
2697 | Int data; |
---|
2698 | if (fscanf(fp, "%d,", &data)!=1) |
---|
2699 | { |
---|
2700 | fprintf(stderr, "Error: cannot read DC %s from scaling list file %s at file position %ld\n", MatrixType_DC[sizeIdc][listIdc], pchFile, ftell(fp)); |
---|
2701 | return true; |
---|
2702 | } |
---|
2703 | if (data<0 || data>255) |
---|
2704 | { |
---|
2705 | 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)); |
---|
2706 | return true; |
---|
2707 | } |
---|
2708 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
2709 | setScalingListDC(sizeIdc,listIdc,data); |
---|
2710 | } |
---|
2711 | } |
---|
2712 | } |
---|
2713 | } |
---|
2714 | // std::cout << "\n\nRead scaling lists of:\n\n"; |
---|
2715 | // outputScalingLists(std::cout); |
---|
2716 | |
---|
2717 | fclose(fp); |
---|
2718 | return false; |
---|
2719 | } |
---|
2720 | |
---|
2721 | |
---|
2722 | /** get default address of quantization matrix |
---|
2723 | * \param sizeId size index |
---|
2724 | * \param listId list index |
---|
2725 | * \returns pointer of quantization matrix |
---|
2726 | */ |
---|
2727 | const Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
2728 | { |
---|
2729 | const Int *src = 0; |
---|
2730 | switch(sizeId) |
---|
2731 | { |
---|
2732 | case SCALING_LIST_4x4: |
---|
2733 | src = g_quantTSDefault4x4; |
---|
2734 | break; |
---|
2735 | case SCALING_LIST_8x8: |
---|
2736 | case SCALING_LIST_16x16: |
---|
2737 | case SCALING_LIST_32x32: |
---|
2738 | src = (listId < (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) ) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2739 | break; |
---|
2740 | default: |
---|
2741 | assert(0); |
---|
2742 | src = NULL; |
---|
2743 | break; |
---|
2744 | } |
---|
2745 | return src; |
---|
2746 | } |
---|
2747 | |
---|
2748 | /** process of default matrix |
---|
2749 | * \param sizeId size index |
---|
2750 | * \param listId index of input matrix |
---|
2751 | */ |
---|
2752 | Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId) |
---|
2753 | { |
---|
2754 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2755 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
2756 | } |
---|
2757 | |
---|
2758 | /** check DC value of matrix for default matrix signaling |
---|
2759 | */ |
---|
2760 | Void TComScalingList::checkDcOfMatrix() |
---|
2761 | { |
---|
2762 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2763 | { |
---|
2764 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
2765 | { |
---|
2766 | //check default matrix? |
---|
2767 | if(getScalingListDC(sizeId,listId) == 0) |
---|
2768 | { |
---|
2769 | processDefaultMatrix(sizeId, listId); |
---|
2770 | } |
---|
2771 | } |
---|
2772 | } |
---|
2773 | } |
---|
2774 | |
---|
2775 | ParameterSetManager::ParameterSetManager() |
---|
2776 | #if SVC_EXTENSION |
---|
2777 | : m_activeSPS() |
---|
2778 | #else |
---|
2779 | : m_vpsMap(MAX_NUM_VPS) |
---|
2780 | , m_spsMap(MAX_NUM_SPS) |
---|
2781 | , m_ppsMap(MAX_NUM_PPS) |
---|
2782 | , m_activeVPS() |
---|
2783 | , m_activeSPS() |
---|
2784 | #endif |
---|
2785 | { |
---|
2786 | #if !SVC_EXTENSION |
---|
2787 | m_activeVPS.setVPSId(-1); |
---|
2788 | #endif |
---|
2789 | m_activeSPS.setSPSId(-1); |
---|
2790 | } |
---|
2791 | |
---|
2792 | |
---|
2793 | ParameterSetManager::~ParameterSetManager() |
---|
2794 | { |
---|
2795 | } |
---|
2796 | |
---|
2797 | //! activate a SPS from a active parameter sets SEI message |
---|
2798 | //! \returns true, if activation is successful |
---|
2799 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
2800 | { |
---|
2801 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
2802 | if (sps) |
---|
2803 | { |
---|
2804 | Int vpsId = sps->getVPSId(); |
---|
2805 | TComVPS *vps = m_vpsMap.getPS(vpsId); |
---|
2806 | if (vps) |
---|
2807 | { |
---|
2808 | m_activeVPS = *(vps); |
---|
2809 | m_activeSPS = *(sps); |
---|
2810 | return true; |
---|
2811 | } |
---|
2812 | else |
---|
2813 | { |
---|
2814 | printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
2815 | } |
---|
2816 | } |
---|
2817 | else |
---|
2818 | { |
---|
2819 | printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
2820 | } |
---|
2821 | return false; |
---|
2822 | } |
---|
2823 | |
---|
2824 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
2825 | //! \returns true, if activation is successful |
---|
2826 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
2827 | { |
---|
2828 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
2829 | if (pps) |
---|
2830 | { |
---|
2831 | Int spsId = pps->getSPSId(); |
---|
2832 | if (!isIRAP && (spsId != m_activeSPS.getSPSId() )) |
---|
2833 | { |
---|
2834 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IDR."); |
---|
2835 | return false; |
---|
2836 | } |
---|
2837 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
2838 | if (sps) |
---|
2839 | { |
---|
2840 | Int vpsId = sps->getVPSId(); |
---|
2841 | if (!isIRAP && (vpsId != m_activeVPS.getVPSId() )) |
---|
2842 | { |
---|
2843 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IDR."); |
---|
2844 | return false; |
---|
2845 | } |
---|
2846 | TComVPS *vps =m_vpsMap.getPS(vpsId); |
---|
2847 | if (vps) |
---|
2848 | { |
---|
2849 | m_activeVPS = *(vps); |
---|
2850 | m_activeSPS = *(sps); |
---|
2851 | #if SVC_EXTENSION |
---|
2852 | m_activePPS = *(pps); |
---|
2853 | #endif |
---|
2854 | return true; |
---|
2855 | } |
---|
2856 | else |
---|
2857 | { |
---|
2858 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
2859 | } |
---|
2860 | } |
---|
2861 | else |
---|
2862 | { |
---|
2863 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
2864 | } |
---|
2865 | } |
---|
2866 | else |
---|
2867 | { |
---|
2868 | printf("Warning: tried to activate non-existing PPS."); |
---|
2869 | } |
---|
2870 | return false; |
---|
2871 | } |
---|
2872 | |
---|
2873 | ProfileTierLevel::ProfileTierLevel() |
---|
2874 | : m_profileSpace (0) |
---|
2875 | , m_tierFlag (Level::MAIN) |
---|
2876 | , m_profileIdc (Profile::NONE) |
---|
2877 | , m_levelIdc (Level::NONE) |
---|
2878 | , m_progressiveSourceFlag (false) |
---|
2879 | , m_interlacedSourceFlag (false) |
---|
2880 | , m_nonPackedConstraintFlag(false) |
---|
2881 | , m_frameOnlyConstraintFlag(false) |
---|
2882 | { |
---|
2883 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
2884 | } |
---|
2885 | |
---|
2886 | TComPTL::TComPTL() |
---|
2887 | { |
---|
2888 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
2889 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
2890 | } |
---|
2891 | |
---|
2892 | Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> *pNewData) |
---|
2893 | { |
---|
2894 | if (!bChanged) |
---|
2895 | { |
---|
2896 | if ((pOldData==0 && pOldData!=0) || (pOldData!=0 && pOldData==0)) |
---|
2897 | { |
---|
2898 | bChanged=true; |
---|
2899 | } |
---|
2900 | else if (pOldData!=0 && pOldData!=0) |
---|
2901 | { |
---|
2902 | // compare the two |
---|
2903 | if (pOldData->size() != pOldData->size()) |
---|
2904 | { |
---|
2905 | bChanged=true; |
---|
2906 | } |
---|
2907 | else |
---|
2908 | { |
---|
2909 | const UChar *pNewDataArray=&(*pNewData)[0]; |
---|
2910 | const UChar *pOldDataArray=&(*pOldData)[0]; |
---|
2911 | if (memcmp(pOldDataArray, pNewDataArray, pOldData->size())) |
---|
2912 | { |
---|
2913 | bChanged=true; |
---|
2914 | } |
---|
2915 | } |
---|
2916 | } |
---|
2917 | } |
---|
2918 | } |
---|
2919 | |
---|
2920 | #if SVC_EXTENSION |
---|
2921 | Void ProfileTierLevel::copyProfileInfo(ProfileTierLevel *ptl) |
---|
2922 | { |
---|
2923 | this->setProfileSpace ( ptl->getProfileSpace() ); |
---|
2924 | this->setTierFlag ( ptl->getTierFlag() ); |
---|
2925 | this->setProfileIdc ( ptl->getProfileIdc() ); |
---|
2926 | for(Int j = 0; j < 32; j++) |
---|
2927 | { |
---|
2928 | this->setProfileCompatibilityFlag(j, ptl->getProfileCompatibilityFlag(j)); |
---|
2929 | } |
---|
2930 | this->setProgressiveSourceFlag ( ptl->getProgressiveSourceFlag() ); |
---|
2931 | this->setInterlacedSourceFlag ( ptl->getInterlacedSourceFlag() ); |
---|
2932 | this->setNonPackedConstraintFlag( ptl->getNonPackedConstraintFlag()); |
---|
2933 | this->setFrameOnlyConstraintFlag( ptl->getFrameOnlyConstraintFlag()); |
---|
2934 | } |
---|
2935 | |
---|
2936 | const Window& TComPPS::getScaledRefLayerWindowForLayer(Int layerId) const |
---|
2937 | { |
---|
2938 | static const Window win; |
---|
2939 | |
---|
2940 | for( Int i = m_numRefLayerLocationOffsets-1; i >= 0; i-- ) |
---|
2941 | { |
---|
2942 | if( layerId == m_refLocationOffsetLayerId[i] ) |
---|
2943 | { |
---|
2944 | return m_scaledRefLayerWindow[i]; |
---|
2945 | } |
---|
2946 | } |
---|
2947 | |
---|
2948 | return win; |
---|
2949 | } |
---|
2950 | |
---|
2951 | const Window& TComPPS::getRefLayerWindowForLayer(Int layerId) const |
---|
2952 | { |
---|
2953 | static const Window win; |
---|
2954 | |
---|
2955 | for( Int i = m_numRefLayerLocationOffsets-1; i >= 0; i-- ) |
---|
2956 | { |
---|
2957 | if( layerId == m_refLocationOffsetLayerId[i] ) |
---|
2958 | { |
---|
2959 | return m_refLayerWindow[i]; |
---|
2960 | } |
---|
2961 | } |
---|
2962 | |
---|
2963 | return win; |
---|
2964 | } |
---|
2965 | |
---|
2966 | Bool TComPPS::hasZeroResamplingPhase(Int refLayerId) const |
---|
2967 | { |
---|
2968 | const ResamplingPhase &resamplingPhase = getResamplingPhase(refLayerId); |
---|
2969 | |
---|
2970 | return ( resamplingPhase.phaseHorLuma == 0 && resamplingPhase.phaseHorChroma == 0 && resamplingPhase.phaseVerLuma == 0 && resamplingPhase.phaseVerChroma == 0 ); |
---|
2971 | } |
---|
2972 | |
---|
2973 | const ResamplingPhase& TComPPS::getResamplingPhase(Int refLayerId) const |
---|
2974 | { |
---|
2975 | static const ResamplingPhase resamplingPhase; |
---|
2976 | |
---|
2977 | for( Int i = m_numRefLayerLocationOffsets-1; i >= 0; i-- ) |
---|
2978 | { |
---|
2979 | if( refLayerId == m_refLocationOffsetLayerId[i] ) |
---|
2980 | { |
---|
2981 | return m_resamplingPhase[i]; |
---|
2982 | } |
---|
2983 | } |
---|
2984 | |
---|
2985 | return resamplingPhase; |
---|
2986 | } |
---|
2987 | |
---|
2988 | Void TComVPS::deriveLayerIdListVariables() |
---|
2989 | { |
---|
2990 | // For layer 0 |
---|
2991 | m_numLayerInIdList.push_back(1); |
---|
2992 | m_layerSetLayerIdList.resize(m_vpsNumLayerSetsMinus1 + 1); |
---|
2993 | m_layerSetLayerIdList[0].push_back(0); |
---|
2994 | |
---|
2995 | // For other layers |
---|
2996 | for (Int i = 1; i <= m_vpsNumLayerSetsMinus1; i++) |
---|
2997 | { |
---|
2998 | for( Int m = 0; m <= m_maxLayerId; m++) |
---|
2999 | { |
---|
3000 | if( m_layerIdIncludedFlag[i][m] ) |
---|
3001 | { |
---|
3002 | m_layerSetLayerIdList[i].push_back(m); |
---|
3003 | } |
---|
3004 | } |
---|
3005 | m_numLayerInIdList.push_back((Int)m_layerSetLayerIdList[i].size()); |
---|
3006 | } |
---|
3007 | } |
---|
3008 | |
---|
3009 | Void TComVPS::deriveNumberOfSubDpbs() |
---|
3010 | { |
---|
3011 | // Derive number of sub-DPBs |
---|
3012 | // For layer set 0 |
---|
3013 | m_numSubDpbs[0] = 1; |
---|
3014 | // For other layer sets |
---|
3015 | for( Int i = 1; i < m_numLayerSets; i++) |
---|
3016 | { |
---|
3017 | m_numSubDpbs[i] = m_numLayerInIdList[i]; |
---|
3018 | } |
---|
3019 | } |
---|
3020 | |
---|
3021 | Void TComVPS::setTilesNotInUseFlag(Bool x) |
---|
3022 | { |
---|
3023 | m_tilesNotInUseFlag = x; |
---|
3024 | |
---|
3025 | if( m_tilesNotInUseFlag ) |
---|
3026 | { |
---|
3027 | for( Int i = 0; i < getMaxLayers(); i++ ) |
---|
3028 | { |
---|
3029 | m_tilesInUseFlag[i] = m_loopFilterNotAcrossTilesFlag[i] = m_tilesNotInUseFlag; |
---|
3030 | } |
---|
3031 | |
---|
3032 | for( Int i = 1; i < getMaxLayers(); i++ ) |
---|
3033 | { |
---|
3034 | for( Int j = 0; j < getNumDirectRefLayers(getLayerIdInNuh(i)); j++) |
---|
3035 | { |
---|
3036 | setTileBoundariesAlignedFlag(i, j, m_tilesNotInUseFlag); |
---|
3037 | } |
---|
3038 | } |
---|
3039 | } |
---|
3040 | } |
---|
3041 | |
---|
3042 | Void TComVPS::setWppNotInUseFlag(Bool x) |
---|
3043 | { |
---|
3044 | m_wppNotInUseFlag = x; |
---|
3045 | |
---|
3046 | if( m_wppNotInUseFlag ) |
---|
3047 | { |
---|
3048 | for( Int i = 0; i < getMaxLayers(); i++ ) |
---|
3049 | { |
---|
3050 | m_wppInUseFlag[i] = m_wppNotInUseFlag; |
---|
3051 | } |
---|
3052 | } |
---|
3053 | } |
---|
3054 | |
---|
3055 | Void TComVPS::setRefLayersFlags(Int currLayerId) |
---|
3056 | { |
---|
3057 | for (Int i = 0; i < m_numDirectRefLayers[currLayerId]; i++) |
---|
3058 | { |
---|
3059 | UInt refLayerId = getRefLayerId(currLayerId, i); |
---|
3060 | m_recursiveRefLayerFlag[currLayerId][refLayerId] = true; |
---|
3061 | for (Int k = 0; k < MAX_NUM_LAYER_IDS; k++) |
---|
3062 | { |
---|
3063 | m_recursiveRefLayerFlag[currLayerId][k] = m_recursiveRefLayerFlag[currLayerId][k] | m_recursiveRefLayerFlag[refLayerId][k]; |
---|
3064 | } |
---|
3065 | } |
---|
3066 | } |
---|
3067 | |
---|
3068 | Void TComVPS::setNumRefLayers() |
---|
3069 | { |
---|
3070 | memset( m_numberRefLayers, 0, sizeof( m_numberRefLayers ) ); |
---|
3071 | |
---|
3072 | for (Int i = 0; i < m_uiMaxLayers; i++) |
---|
3073 | { |
---|
3074 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
3075 | setRefLayersFlags(iNuhLId); |
---|
3076 | for (UInt j = 0; j < MAX_NUM_LAYER_IDS; j++) |
---|
3077 | { |
---|
3078 | m_numberRefLayers[iNuhLId] += (m_recursiveRefLayerFlag[iNuhLId][j] == true ? 1 : 0); |
---|
3079 | } |
---|
3080 | } |
---|
3081 | } |
---|
3082 | |
---|
3083 | Void TComVPS::setPredictedLayerIds() |
---|
3084 | { |
---|
3085 | for (UInt i = 0; i < m_uiMaxLayers - 1; i++) |
---|
3086 | { |
---|
3087 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
3088 | UInt predIdx = 0; |
---|
3089 | for (UInt j = iNuhLId + 1; j < MAX_NUM_LAYER_IDS; j++) |
---|
3090 | { |
---|
3091 | if( m_recursiveRefLayerFlag[j][iNuhLId] ) |
---|
3092 | { |
---|
3093 | m_predictedLayerId[iNuhLId][predIdx] = j; |
---|
3094 | predIdx++; |
---|
3095 | } |
---|
3096 | } |
---|
3097 | m_numPredictedLayers[iNuhLId] = predIdx; |
---|
3098 | } |
---|
3099 | m_numPredictedLayers[m_layerIdInNuh[m_uiMaxLayers-1]] = 0; |
---|
3100 | } |
---|
3101 | |
---|
3102 | Void TComVPS::setTreePartitionLayerIdList() |
---|
3103 | { |
---|
3104 | Bool countedLayerIdxFlag[MAX_NUM_LAYER_IDS]; |
---|
3105 | memset( countedLayerIdxFlag, 0, sizeof(countedLayerIdxFlag) ); |
---|
3106 | |
---|
3107 | Int numIndependentLayers = 0; |
---|
3108 | |
---|
3109 | for (UInt i = 0; i < m_uiMaxLayers; i++) |
---|
3110 | { |
---|
3111 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
3112 | if( m_numDirectRefLayers[iNuhLId] == 0 ) |
---|
3113 | { |
---|
3114 | m_treePartitionLayerIdList[numIndependentLayers][0] = iNuhLId; |
---|
3115 | m_numLayersInTreePartition[numIndependentLayers] = 1; |
---|
3116 | for( UInt j = 0; j < m_numPredictedLayers[iNuhLId]; j++ ) |
---|
3117 | { |
---|
3118 | if( !countedLayerIdxFlag[m_layerIdxInVps[iNuhLId]] ) |
---|
3119 | { |
---|
3120 | m_treePartitionLayerIdList[numIndependentLayers][m_numLayersInTreePartition[numIndependentLayers]] = m_predictedLayerId[iNuhLId][j]; |
---|
3121 | m_numLayersInTreePartition[numIndependentLayers] = m_numLayersInTreePartition[numIndependentLayers] + 1; |
---|
3122 | countedLayerIdxFlag[m_layerIdxInVps[m_predictedLayerId[iNuhLId][j]]] = true; |
---|
3123 | } |
---|
3124 | } |
---|
3125 | numIndependentLayers++; |
---|
3126 | } |
---|
3127 | } |
---|
3128 | |
---|
3129 | m_numIndependentLayers = numIndependentLayers; |
---|
3130 | } |
---|
3131 | |
---|
3132 | Void TComVPS::deriveLayerIdListVariablesForAddLayerSets() |
---|
3133 | { |
---|
3134 | m_layerSetLayerIdList.resize(m_vpsNumLayerSetsMinus1 + 1 + m_numAddLayerSets); |
---|
3135 | |
---|
3136 | for (UInt i = 0; i < m_numAddLayerSets; i++) |
---|
3137 | { |
---|
3138 | Int layerNum = 0; |
---|
3139 | Int lsIdx = m_vpsNumLayerSetsMinus1 + 1 + i; |
---|
3140 | for (Int treeIdx = 1; treeIdx < m_numIndependentLayers; treeIdx++) |
---|
3141 | { |
---|
3142 | for (Int layerCnt = 0; layerCnt < m_highestLayerIdxPlus1[i][treeIdx]; layerCnt++) |
---|
3143 | { |
---|
3144 | m_layerSetLayerIdList[lsIdx].push_back(m_treePartitionLayerIdList[treeIdx][layerCnt]); |
---|
3145 | layerNum++; |
---|
3146 | } |
---|
3147 | } |
---|
3148 | m_numLayerInIdList.push_back(layerNum); |
---|
3149 | } |
---|
3150 | } |
---|
3151 | |
---|
3152 | Int TComVPS::getNumViews() const |
---|
3153 | { |
---|
3154 | Int numViews = 1; |
---|
3155 | for( Int i = 0; i < m_uiMaxLayers; i++ ) |
---|
3156 | { |
---|
3157 | Int lId = m_layerIdInNuh[i]; |
---|
3158 | if( i > 0 && ( getViewIndex( lId ) != getScalabilityId( i - 1, VIEW_ORDER_INDEX ) ) ) |
---|
3159 | { |
---|
3160 | numViews++; |
---|
3161 | } |
---|
3162 | } |
---|
3163 | |
---|
3164 | return numViews; |
---|
3165 | } |
---|
3166 | |
---|
3167 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) const |
---|
3168 | { |
---|
3169 | return getScalabilityMask( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
3170 | } |
---|
3171 | |
---|
3172 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) const |
---|
3173 | { |
---|
3174 | assert( scalType >= 0 && scalType <= MAX_VPS_NUM_SCALABILITY_TYPES ); |
---|
3175 | assert( scalType == MAX_VPS_NUM_SCALABILITY_TYPES || getScalabilityMask( scalType ) ); |
---|
3176 | Int scalIdx = 0; |
---|
3177 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
3178 | { |
---|
3179 | scalIdx += ( getScalabilityMask( curScalType ) ? 1 : 0 ); |
---|
3180 | |
---|
3181 | } |
---|
3182 | |
---|
3183 | return scalIdx; |
---|
3184 | } |
---|
3185 | |
---|
3186 | Int TComVPS::getLayerIdcForOls( Int olsIdx, Int layerId ) const |
---|
3187 | { |
---|
3188 | Int layerIdc = -1; |
---|
3189 | UInt lsIdx = m_outputLayerSetIdx[olsIdx]; |
---|
3190 | |
---|
3191 | std::vector<Int>::const_iterator it = std::find( m_layerSetLayerIdList[lsIdx].begin(), m_layerSetLayerIdList[lsIdx].end(), layerId ); |
---|
3192 | |
---|
3193 | if( it != m_layerSetLayerIdList[lsIdx].end() ) |
---|
3194 | { |
---|
3195 | layerIdc = (Int)std::distance( m_layerSetLayerIdList[lsIdx].begin(), it ); |
---|
3196 | } |
---|
3197 | |
---|
3198 | assert( layerIdc >= 0 ); |
---|
3199 | |
---|
3200 | return layerIdc; |
---|
3201 | } |
---|
3202 | |
---|
3203 | Void TComVPS::determineSubDpbInfoFlags() |
---|
3204 | { |
---|
3205 | for(Int i = 1; i < getNumOutputLayerSets(); i++) |
---|
3206 | { |
---|
3207 | Int layerSetIdxForOutputLayerSet = getOutputLayerSetIdx( i ); |
---|
3208 | // For each output layer set, set the DPB size for each layer and the reorder/latency value the maximum for all layers |
---|
3209 | Bool checkFlagOuter = false; // Used to calculate sub_layer_flag_info_present_flag |
---|
3210 | Bool checkFlagInner[MAX_TLAYER]; // Used to calculate sub_layer_dpb_info_present_flag |
---|
3211 | |
---|
3212 | for(Int j = 0; j < getMaxTLayers(); j++) |
---|
3213 | { |
---|
3214 | // -------------------------------------------------------- |
---|
3215 | // To determine value of m_subLayerDpbInfoPresentFlag |
---|
3216 | // -------------------------------------------------------- |
---|
3217 | if( j == 0 ) // checkFlagInner[0] is always 1 |
---|
3218 | { |
---|
3219 | checkFlagInner[j] = true; // Always signal sub-layer DPB information for the first sub-layer |
---|
3220 | } |
---|
3221 | else |
---|
3222 | { |
---|
3223 | checkFlagInner[j] = false; // Initialize to be false. If the values of the current sub-layers matches with the earlier sub-layer, |
---|
3224 | // then will be continue to be false - i.e. the j-th sub-layer DPB info is not signaled |
---|
3225 | checkFlagInner[j] |= ( getMaxVpsNumReorderPics(i, j) != getMaxVpsNumReorderPics(i, j - 1) ); |
---|
3226 | |
---|
3227 | for(Int subDpbIdx = 0; subDpbIdx < getNumSubDpbs(layerSetIdxForOutputLayerSet) && !checkFlagInner[j]; subDpbIdx++) // If checkFlagInner[j] is true, break and signal the values |
---|
3228 | { |
---|
3229 | checkFlagInner[j] |= ( getMaxVpsDecPicBufferingMinus1(i, subDpbIdx, j - 1) != getMaxVpsDecPicBufferingMinus1(i, subDpbIdx, j) ); |
---|
3230 | } |
---|
3231 | } |
---|
3232 | // If checkFlagInner[j] = true, then some value needs to be signalled for the j-th sub-layer |
---|
3233 | setSubLayerDpbInfoPresentFlag( i, j, checkFlagInner[j] ); |
---|
3234 | } |
---|
3235 | |
---|
3236 | // -------------------------------------------------------- |
---|
3237 | // To determine value of m_subLayerFlagInfoPresentFlag |
---|
3238 | // -------------------------------------------------------- |
---|
3239 | |
---|
3240 | 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 |
---|
3241 | { |
---|
3242 | if( getSubLayerDpbInfoPresentFlag(i, j) ) |
---|
3243 | { |
---|
3244 | checkFlagOuter = true; |
---|
3245 | break; |
---|
3246 | } |
---|
3247 | } |
---|
3248 | setSubLayerFlagInfoPresentFlag( i, checkFlagOuter ); |
---|
3249 | } |
---|
3250 | } |
---|
3251 | |
---|
3252 | #if O0164_MULTI_LAYER_HRD |
---|
3253 | Void TComVPS::setBspHrdParameters( UInt hrdIdx, UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
3254 | { |
---|
3255 | if( !getVpsVuiBspHrdPresentFlag() ) |
---|
3256 | { |
---|
3257 | return; |
---|
3258 | } |
---|
3259 | |
---|
3260 | TComHRD *hrd = getBspHrd(hrdIdx); |
---|
3261 | |
---|
3262 | Bool rateCnt = ( bitRate > 0 ); |
---|
3263 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
3264 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
3265 | |
---|
3266 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
3267 | |
---|
3268 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
3269 | { |
---|
3270 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
3271 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
3272 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
3273 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
3274 | } |
---|
3275 | else |
---|
3276 | { |
---|
3277 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
3278 | } |
---|
3279 | |
---|
3280 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
3281 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
3282 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
3283 | |
---|
3284 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
3285 | if( randomAccess ) |
---|
3286 | { |
---|
3287 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
3288 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
3289 | } |
---|
3290 | else |
---|
3291 | { |
---|
3292 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
3293 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
3294 | } |
---|
3295 | |
---|
3296 | /* |
---|
3297 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
3298 | */ |
---|
3299 | Int i, j; |
---|
3300 | UInt birateValue, cpbSizeValue; |
---|
3301 | UInt ducpbSizeValue; |
---|
3302 | UInt duBitRateValue = 0; |
---|
3303 | |
---|
3304 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
3305 | { |
---|
3306 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
3307 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
3308 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
3309 | hrd->setCpbCntMinus1( i, 0 ); |
---|
3310 | |
---|
3311 | birateValue = bitRate; |
---|
3312 | cpbSizeValue = bitRate; // 1 second |
---|
3313 | ducpbSizeValue = bitRate/numDU; |
---|
3314 | duBitRateValue = bitRate; |
---|
3315 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
3316 | { |
---|
3317 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
3318 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
3319 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
3320 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
3321 | |
---|
3322 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
3323 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
3324 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
3325 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
3326 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
3327 | } |
---|
3328 | } |
---|
3329 | } |
---|
3330 | #endif |
---|
3331 | |
---|
3332 | Void TComVPS::deriveNecessaryLayerFlag() |
---|
3333 | { |
---|
3334 | m_necessaryLayerFlag.empty(); |
---|
3335 | m_numNecessaryLayers.empty(); |
---|
3336 | // Assumed that output layer sets and variables RecursiveRefLayer are already derived |
---|
3337 | for( Int olsIdx = 0; olsIdx < m_numOutputLayerSets; olsIdx++) |
---|
3338 | { |
---|
3339 | deriveNecessaryLayerFlag(olsIdx); |
---|
3340 | } |
---|
3341 | } |
---|
3342 | |
---|
3343 | Void TComVPS::deriveNecessaryLayerFlag(const Int olsIdx) |
---|
3344 | { |
---|
3345 | Int lsIdx = m_outputLayerSetIdx[olsIdx]; |
---|
3346 | Int numLayersInLs = m_numLayerInIdList[lsIdx]; |
---|
3347 | assert( m_necessaryLayerFlag.size() == olsIdx ); // Function should be called in the correct order. |
---|
3348 | m_necessaryLayerFlag.push_back( std::vector<Bool>( numLayersInLs, false ) ); // Initialize to false |
---|
3349 | for( Int lsLayerIdx = 0; lsLayerIdx < numLayersInLs; lsLayerIdx++ ) |
---|
3350 | { |
---|
3351 | if( m_outputLayerFlag[olsIdx][lsLayerIdx] ) |
---|
3352 | { |
---|
3353 | m_necessaryLayerFlag[olsIdx][lsLayerIdx] = true; |
---|
3354 | Int currNuhLayerId = m_layerSetLayerIdList[lsIdx][lsLayerIdx]; |
---|
3355 | for( Int rLsLayerIdx = 0; rLsLayerIdx < lsLayerIdx; rLsLayerIdx++ ) |
---|
3356 | { |
---|
3357 | Int refNuhLayerId = m_layerSetLayerIdList[lsIdx][rLsLayerIdx]; |
---|
3358 | if( m_recursiveRefLayerFlag[currNuhLayerId][refNuhLayerId] ) |
---|
3359 | { |
---|
3360 | m_necessaryLayerFlag[olsIdx][rLsLayerIdx] = true; |
---|
3361 | } |
---|
3362 | } |
---|
3363 | } |
---|
3364 | } |
---|
3365 | m_numNecessaryLayers.push_back(std::accumulate(m_necessaryLayerFlag[olsIdx].begin(), m_necessaryLayerFlag[olsIdx].end(), 0)); |
---|
3366 | } |
---|
3367 | |
---|
3368 | Void TComVPS::checkNecessaryLayerFlagCondition() |
---|
3369 | { |
---|
3370 | /* It is a requirement of bitstream conformance that for each layer index layerIdx in the range of |
---|
3371 | ( vps_base_layer_internal_flag ? 0 : 1 ) to MaxLayersMinus1, inclusive, there shall be at least one OLS with index olsIdx such that |
---|
3372 | NecessaryLayerFlag[ olsIdx ][ lsLayerIdx ] is equal to 1 for the value of lsLayerIdx |
---|
3373 | for which LayerSetLayerIdList[ OlsIdxToLsIdx[ olsIdx ] ][ lsLayerIdx ] is equal to layer_id_in_nuh[ layerIdx ]. */ |
---|
3374 | for(Int layerIdx = m_baseLayerInternalFlag ? 0 : 1; layerIdx < m_uiMaxLayers; layerIdx++) |
---|
3375 | { |
---|
3376 | Bool layerFoundNecessaryLayerFlag = false; |
---|
3377 | for(Int olsIdx = 0; olsIdx < m_numOutputLayerSets; olsIdx++) |
---|
3378 | { |
---|
3379 | Int lsIdx = m_outputLayerSetIdx[olsIdx]; |
---|
3380 | Int currNuhLayerId = m_layerIdInNuh[layerIdx]; |
---|
3381 | std::vector<Int>::iterator iter = std::find( m_layerSetLayerIdList[lsIdx].begin(), m_layerSetLayerIdList[lsIdx].end(), currNuhLayerId ); |
---|
3382 | if( iter != m_layerSetLayerIdList[lsIdx].end() ) // Layer present in layer set |
---|
3383 | { |
---|
3384 | size_t positionLayer = iter - m_layerSetLayerIdList[lsIdx].begin(); |
---|
3385 | if( *(m_necessaryLayerFlag[olsIdx].begin() + positionLayer) == true ) |
---|
3386 | { |
---|
3387 | layerFoundNecessaryLayerFlag = true; |
---|
3388 | break; |
---|
3389 | } |
---|
3390 | } |
---|
3391 | } |
---|
3392 | assert( layerFoundNecessaryLayerFlag ); |
---|
3393 | } |
---|
3394 | } |
---|
3395 | |
---|
3396 | Int TComVPS::calculateLenOfSyntaxElement( const Int numVal ) const |
---|
3397 | { |
---|
3398 | Int numBits = 1; |
---|
3399 | while((1 << numBits) < numVal) |
---|
3400 | { |
---|
3401 | numBits++; |
---|
3402 | } |
---|
3403 | return numBits; |
---|
3404 | } |
---|
3405 | |
---|
3406 | Void TComVPS::calculateMaxSLInLayerSets() |
---|
3407 | { |
---|
3408 | for(Int lsIdx = 0; lsIdx < getNumLayerSets(); lsIdx++) |
---|
3409 | { |
---|
3410 | UInt maxSLMinus1 = 0; |
---|
3411 | for(Int k = 0; k < getNumLayersInIdList(lsIdx); k++ ) { |
---|
3412 | Int lId = getLayerSetLayerIdList(lsIdx, k); |
---|
3413 | maxSLMinus1 = std::max(maxSLMinus1, getMaxTSLayersMinus1(getLayerIdxInVps(lId))); |
---|
3414 | } |
---|
3415 | setMaxSLayersInLayerSetMinus1(lsIdx,maxSLMinus1); |
---|
3416 | } |
---|
3417 | } |
---|
3418 | |
---|
3419 | UInt TComSlice::getPicWidthInLumaSamples() |
---|
3420 | { |
---|
3421 | UInt retVal, layerId = getLayerId(); |
---|
3422 | |
---|
3423 | if ( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 ) |
---|
3424 | { |
---|
3425 | if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() ) |
---|
3426 | { |
---|
3427 | retVal = m_pcVPS->getVpsRepFormat(layerId)->getPicWidthVpsInLumaSamples(); |
---|
3428 | } |
---|
3429 | else |
---|
3430 | { |
---|
3431 | retVal = m_pcSPS->getPicWidthInLumaSamples(); |
---|
3432 | } |
---|
3433 | } |
---|
3434 | else |
---|
3435 | { |
---|
3436 | retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getPicWidthVpsInLumaSamples(); |
---|
3437 | } |
---|
3438 | |
---|
3439 | return retVal; |
---|
3440 | } |
---|
3441 | |
---|
3442 | UInt TComVPS::getPicWidthInLumaSamples( const TComSPS* sps, const UInt layerId ) const |
---|
3443 | { |
---|
3444 | UInt retVal; |
---|
3445 | |
---|
3446 | if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
3447 | { |
---|
3448 | if( layerId == 0 && m_nonHEVCBaseLayerFlag ) |
---|
3449 | { |
---|
3450 | retVal = m_vpsRepFormat[layerId].getPicWidthVpsInLumaSamples(); |
---|
3451 | } |
---|
3452 | else |
---|
3453 | { |
---|
3454 | retVal = sps->getPicWidthInLumaSamples(); |
---|
3455 | } |
---|
3456 | } |
---|
3457 | else |
---|
3458 | { |
---|
3459 | retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getPicWidthVpsInLumaSamples(); |
---|
3460 | } |
---|
3461 | |
---|
3462 | return retVal; |
---|
3463 | } |
---|
3464 | |
---|
3465 | UInt TComSlice::getPicHeightInLumaSamples() |
---|
3466 | { |
---|
3467 | UInt retVal, layerId = getLayerId(); |
---|
3468 | |
---|
3469 | if ( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 ) |
---|
3470 | { |
---|
3471 | if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() ) |
---|
3472 | { |
---|
3473 | retVal = m_pcVPS->getVpsRepFormat(layerId)->getPicHeightVpsInLumaSamples(); |
---|
3474 | } |
---|
3475 | else |
---|
3476 | { |
---|
3477 | retVal = m_pcSPS->getPicHeightInLumaSamples(); |
---|
3478 | } |
---|
3479 | } |
---|
3480 | else |
---|
3481 | { |
---|
3482 | retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getPicHeightVpsInLumaSamples(); |
---|
3483 | } |
---|
3484 | |
---|
3485 | return retVal; |
---|
3486 | } |
---|
3487 | |
---|
3488 | UInt TComVPS::getPicHeightInLumaSamples( const TComSPS* sps, const UInt layerId ) const |
---|
3489 | { |
---|
3490 | UInt retVal; |
---|
3491 | |
---|
3492 | if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
3493 | { |
---|
3494 | if( layerId == 0 && m_nonHEVCBaseLayerFlag ) |
---|
3495 | { |
---|
3496 | retVal = m_vpsRepFormat[layerId].getPicHeightVpsInLumaSamples(); |
---|
3497 | } |
---|
3498 | else |
---|
3499 | { |
---|
3500 | retVal = sps->getPicHeightInLumaSamples(); |
---|
3501 | } |
---|
3502 | } |
---|
3503 | else |
---|
3504 | { |
---|
3505 | retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getPicHeightVpsInLumaSamples(); |
---|
3506 | } |
---|
3507 | |
---|
3508 | return retVal; |
---|
3509 | } |
---|
3510 | |
---|
3511 | ChromaFormat TComSlice::getChromaFormatIdc() |
---|
3512 | { |
---|
3513 | ChromaFormat retVal; |
---|
3514 | UInt layerId = getLayerId(); |
---|
3515 | |
---|
3516 | if( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 ) |
---|
3517 | { |
---|
3518 | if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() ) |
---|
3519 | { |
---|
3520 | retVal = m_pcVPS->getVpsRepFormat(layerId)->getChromaFormatVpsIdc(); |
---|
3521 | } |
---|
3522 | else |
---|
3523 | { |
---|
3524 | retVal = m_pcSPS->getChromaFormatIdc(); |
---|
3525 | } |
---|
3526 | } |
---|
3527 | else |
---|
3528 | { |
---|
3529 | retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getChromaFormatVpsIdc(); |
---|
3530 | } |
---|
3531 | |
---|
3532 | return retVal; |
---|
3533 | } |
---|
3534 | |
---|
3535 | ChromaFormat TComVPS::getChromaFormatIdc( const TComSPS* sps, const UInt layerId ) const |
---|
3536 | { |
---|
3537 | ChromaFormat retVal; |
---|
3538 | |
---|
3539 | if( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
3540 | { |
---|
3541 | if( layerId == 0 && m_nonHEVCBaseLayerFlag ) |
---|
3542 | { |
---|
3543 | retVal = m_vpsRepFormat[layerId].getChromaFormatVpsIdc(); |
---|
3544 | } |
---|
3545 | else |
---|
3546 | { |
---|
3547 | retVal = sps->getChromaFormatIdc(); |
---|
3548 | } |
---|
3549 | } |
---|
3550 | else |
---|
3551 | { |
---|
3552 | retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getChromaFormatVpsIdc(); |
---|
3553 | } |
---|
3554 | |
---|
3555 | return retVal; |
---|
3556 | } |
---|
3557 | |
---|
3558 | BitDepths& TComSlice::getBitDepths() |
---|
3559 | { |
---|
3560 | static BitDepths bitDepths; |
---|
3561 | |
---|
3562 | bitDepths.recon[CHANNEL_TYPE_LUMA] = getBitDepth(CHANNEL_TYPE_LUMA); |
---|
3563 | bitDepths.recon[CHANNEL_TYPE_CHROMA] = getBitDepth(CHANNEL_TYPE_CHROMA); |
---|
3564 | |
---|
3565 | return bitDepths; |
---|
3566 | } |
---|
3567 | |
---|
3568 | UInt TComSlice::getBitDepth(ChannelType type) const |
---|
3569 | { |
---|
3570 | UInt retVal, layerId = getLayerId(); |
---|
3571 | |
---|
3572 | if( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 ) |
---|
3573 | { |
---|
3574 | if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() ) |
---|
3575 | { |
---|
3576 | retVal = m_pcVPS->getVpsRepFormat(layerId)->getBitDepthVps(type); |
---|
3577 | } |
---|
3578 | else |
---|
3579 | { |
---|
3580 | retVal = m_pcSPS->getBitDepth(type); |
---|
3581 | } |
---|
3582 | } |
---|
3583 | else |
---|
3584 | { |
---|
3585 | retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getBitDepthVps(type); |
---|
3586 | } |
---|
3587 | |
---|
3588 | return retVal; |
---|
3589 | } |
---|
3590 | |
---|
3591 | UInt TComVPS::getBitDepth( ChannelType type, const TComSPS* sps, const UInt layerId ) const |
---|
3592 | { |
---|
3593 | UInt retVal; |
---|
3594 | |
---|
3595 | if( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
3596 | { |
---|
3597 | if( layerId == 0 && m_nonHEVCBaseLayerFlag ) |
---|
3598 | { |
---|
3599 | retVal = m_vpsRepFormat[layerId].getBitDepthVps(type); |
---|
3600 | } |
---|
3601 | else |
---|
3602 | { |
---|
3603 | retVal = sps->getBitDepth(type); |
---|
3604 | } |
---|
3605 | } |
---|
3606 | else |
---|
3607 | { |
---|
3608 | retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getBitDepthVps(type); |
---|
3609 | } |
---|
3610 | |
---|
3611 | return retVal; |
---|
3612 | } |
---|
3613 | |
---|
3614 | const BitDepths& TComVPS::getBitDepths( const TComSPS* sps, const UInt layerId ) const |
---|
3615 | { |
---|
3616 | static const BitDepths bitDepths( getBitDepth(CHANNEL_TYPE_LUMA, sps, layerId), getBitDepth(CHANNEL_TYPE_CHROMA, sps, layerId) ); |
---|
3617 | return bitDepths; |
---|
3618 | } |
---|
3619 | |
---|
3620 | const Window& TComSlice::getConformanceWindow() const |
---|
3621 | { |
---|
3622 | if ( m_layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 ) |
---|
3623 | { |
---|
3624 | if( m_layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() ) |
---|
3625 | { |
---|
3626 | return m_pcVPS->getVpsRepFormat(m_layerId)->getConformanceWindowVps(); |
---|
3627 | } |
---|
3628 | else |
---|
3629 | { |
---|
3630 | return m_pcSPS->getConformanceWindow(); |
---|
3631 | } |
---|
3632 | } |
---|
3633 | else |
---|
3634 | { |
---|
3635 | return m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(m_layerId)))->getConformanceWindowVps(); |
---|
3636 | } |
---|
3637 | } |
---|
3638 | |
---|
3639 | const Window& TComVPS::getConformanceWindow( const TComSPS* sps, const UInt layerId ) const |
---|
3640 | { |
---|
3641 | if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
3642 | { |
---|
3643 | if( layerId == 0 && m_nonHEVCBaseLayerFlag ) |
---|
3644 | { |
---|
3645 | return m_vpsRepFormat[layerId].getConformanceWindowVps(); |
---|
3646 | } |
---|
3647 | else |
---|
3648 | { |
---|
3649 | return sps->getConformanceWindow(); |
---|
3650 | } |
---|
3651 | } |
---|
3652 | else |
---|
3653 | { |
---|
3654 | return m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getConformanceWindowVps(); |
---|
3655 | } |
---|
3656 | } |
---|
3657 | |
---|
3658 | RepFormat::RepFormat() |
---|
3659 | #if AUXILIARY_PICTURES |
---|
3660 | : m_chromaFormatVpsIdc (CHROMA_420) |
---|
3661 | #else |
---|
3662 | : m_chromaFormatVpsIdc (0) |
---|
3663 | #endif |
---|
3664 | , m_separateColourPlaneVpsFlag (false) |
---|
3665 | , m_picWidthVpsInLumaSamples (0) |
---|
3666 | , m_picHeightVpsInLumaSamples (0) |
---|
3667 | , m_bitDepthVpsLuma (0) |
---|
3668 | , m_bitDepthVpsChroma (0) |
---|
3669 | {} |
---|
3670 | |
---|
3671 | Void TComPTL::copyProfileInfo(TComPTL *ptl) |
---|
3672 | { |
---|
3673 | // Copy all information related to general profile |
---|
3674 | this->getGeneralPTL()->copyProfileInfo(ptl->getGeneralPTL()); |
---|
3675 | } |
---|
3676 | |
---|
3677 | Bool TComSlice::setBaseColPic( TComList<TComPic*>& rcListPic, UInt refLayerIdc ) |
---|
3678 | { |
---|
3679 | if(m_layerId == 0) |
---|
3680 | { |
---|
3681 | memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) ); |
---|
3682 | return false; |
---|
3683 | } |
---|
3684 | |
---|
3685 | TComPic* pic = xGetRefPic( rcListPic, getPOC() ); |
---|
3686 | |
---|
3687 | if( pic ) |
---|
3688 | { |
---|
3689 | setBaseColPic(refLayerIdc, pic ); |
---|
3690 | } |
---|
3691 | else |
---|
3692 | { |
---|
3693 | return false; |
---|
3694 | } |
---|
3695 | |
---|
3696 | return true; |
---|
3697 | } |
---|
3698 | |
---|
3699 | TComPic* TComSlice::getBaseColPic( TComList<TComPic*>& rcListPic ) |
---|
3700 | { |
---|
3701 | return xGetRefPic( rcListPic, m_iPOC ); |
---|
3702 | } |
---|
3703 | |
---|
3704 | Void TComSlice::setILRPic(TComPic **pcIlpPic) |
---|
3705 | { |
---|
3706 | for( Int i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
3707 | { |
---|
3708 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
3709 | |
---|
3710 | if( pcIlpPic[refLayerIdc] ) |
---|
3711 | { |
---|
3712 | TComPic* pcRefPicBL = m_pcBaseColPic[refLayerIdc]; |
---|
3713 | |
---|
3714 | // copy scalability ratio, it is needed to get the correct location for the motion field of the corresponding reference layer block |
---|
3715 | pcIlpPic[refLayerIdc]->setSpatialEnhLayerFlag( refLayerIdc, m_pcPic->isSpatialEnhLayer(refLayerIdc) ); |
---|
3716 | |
---|
3717 | pcIlpPic[refLayerIdc]->copyUpsampledPictureYuv( m_pcPic->getFullPelBaseRec( refLayerIdc ), pcIlpPic[refLayerIdc]->getPicYuvRec() ); |
---|
3718 | pcIlpPic[refLayerIdc]->getSlice(0)->setBaseColPic( refLayerIdc, pcRefPicBL ); |
---|
3719 | |
---|
3720 | //set reference picture POC of each ILP reference |
---|
3721 | pcIlpPic[refLayerIdc]->getSlice(0)->setPOC( m_iPOC ); |
---|
3722 | |
---|
3723 | //set temporal Id |
---|
3724 | pcIlpPic[refLayerIdc]->getSlice(0)->setTLayer( m_uiTLayer ); |
---|
3725 | |
---|
3726 | //copy layer id from the reference layer |
---|
3727 | pcIlpPic[refLayerIdc]->setLayerId( pcRefPicBL->getLayerId() ); |
---|
3728 | pcIlpPic[refLayerIdc]->getSlice(0)->setLayerId(pcRefPicBL->getLayerId()); |
---|
3729 | |
---|
3730 | pcIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension( false ); |
---|
3731 | pcIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder(); |
---|
3732 | for (Int j=0; j<pcIlpPic[refLayerIdc]->getPicSym()->getNumberOfCtusInFrame(); j++) // set reference CU layerId |
---|
3733 | { |
---|
3734 | pcIlpPic[refLayerIdc]->getPicSym()->getCtu(j)->setLayerId( pcIlpPic[refLayerIdc]->getLayerId() ); |
---|
3735 | } |
---|
3736 | pcIlpPic[refLayerIdc]->setIsLongTerm(1); |
---|
3737 | |
---|
3738 | // assign PPS to ILRP to be used for reference location offsets |
---|
3739 | pcIlpPic[refLayerIdc]->getSlice(0)->setPPS( m_pcPic->getSlice(0)->getPPS() ); |
---|
3740 | |
---|
3741 | // assign SPS to ILRP to be used for obtaining bit depth |
---|
3742 | pcIlpPic[refLayerIdc]->getSlice(0)->setSPS( m_pcPic->getSlice(0)->getSPS() ); |
---|
3743 | |
---|
3744 | // assing VPS to ILRP to be used for deriving layerIdx |
---|
3745 | pcIlpPic[refLayerIdc]->getSlice(0)->setVPS( m_pcPic->getSlice(0)->getVPS() ); |
---|
3746 | |
---|
3747 | if( m_bMFMEnabledFlag && !(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) |
---|
3748 | { |
---|
3749 | //set reference picture POC of each ILP reference |
---|
3750 | assert( pcIlpPic[refLayerIdc]->getPOC() == pcRefPicBL->getPOC() ); |
---|
3751 | |
---|
3752 | //copy slice type from the reference layer |
---|
3753 | pcIlpPic[refLayerIdc]->getSlice(0)->setSliceType( pcRefPicBL->getSlice(0)->getSliceType() ); |
---|
3754 | |
---|
3755 | //copy "used for reference" |
---|
3756 | pcIlpPic[refLayerIdc]->getSlice(0)->setReferenced( pcRefPicBL->getSlice(0)->isReferenced() ); |
---|
3757 | |
---|
3758 | for( Int refList = 0; refList < 2; refList++ ) |
---|
3759 | { |
---|
3760 | RefPicList refPicList = RefPicList( refList ); |
---|
3761 | |
---|
3762 | //set reference POC of ILP |
---|
3763 | pcIlpPic[refLayerIdc]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList)); |
---|
3764 | assert(pcIlpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) >= 0); |
---|
3765 | assert(pcIlpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF); |
---|
3766 | |
---|
3767 | //initialize reference POC of ILP |
---|
3768 | for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++) |
---|
3769 | { |
---|
3770 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx); |
---|
3771 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx); |
---|
3772 | } |
---|
3773 | |
---|
3774 | for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++) |
---|
3775 | { |
---|
3776 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPOC(0, refPicList, refIdx); |
---|
3777 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPic(NULL, refPicList, refIdx); |
---|
3778 | } |
---|
3779 | |
---|
3780 | //copy reference pictures' marking from the reference layer |
---|
3781 | for(Int j = 0; j < MAX_NUM_REF + 1; j++) |
---|
3782 | { |
---|
3783 | pcIlpPic[refLayerIdc]->getSlice(0)->setIsUsedAsLongTerm(refList, j, pcRefPicBL->getSlice(0)->getIsUsedAsLongTerm(refList, j)); |
---|
3784 | } |
---|
3785 | } |
---|
3786 | |
---|
3787 | pcIlpPic[refLayerIdc]->copyUpsampledMvField(refLayerIdc); |
---|
3788 | } |
---|
3789 | else |
---|
3790 | { |
---|
3791 | pcIlpPic[refLayerIdc]->initUpsampledMvField(); |
---|
3792 | } |
---|
3793 | |
---|
3794 | Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1( pcIlpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx() ); |
---|
3795 | assert( (Int)pcIlpPic[refLayerIdc]->getSlice(0)->getTLayer() < maxTidIlRefPicsPlus1 || ( !maxTidIlRefPicsPlus1 && pcIlpPic[refLayerIdc]->getSlice(0)->getRapPicFlag() ) ); |
---|
3796 | |
---|
3797 | } |
---|
3798 | } |
---|
3799 | } |
---|
3800 | |
---|
3801 | Int TComSlice::getReferenceLayerIdc( UInt refLayerId ) |
---|
3802 | { |
---|
3803 | for( Int i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
3804 | { |
---|
3805 | if( m_pcVPS->getRefLayerId(m_layerId, m_interLayerPredLayerIdc[i]) == refLayerId ) |
---|
3806 | { |
---|
3807 | return m_interLayerPredLayerIdc[i]; |
---|
3808 | } |
---|
3809 | } |
---|
3810 | |
---|
3811 | return -1; |
---|
3812 | } |
---|
3813 | |
---|
3814 | Bool TComSlice::getBlaPicFlag() |
---|
3815 | { |
---|
3816 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
3817 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
3818 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP; |
---|
3819 | } |
---|
3820 | |
---|
3821 | Bool TComSlice::getCraPicFlag() |
---|
3822 | { |
---|
3823 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
3824 | } |
---|
3825 | |
---|
3826 | Bool TComSlice::getRaslPicFlag() |
---|
3827 | { |
---|
3828 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R |
---|
3829 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N; |
---|
3830 | } |
---|
3831 | |
---|
3832 | Bool TComSlice::getRadlPicFlag() |
---|
3833 | { |
---|
3834 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R |
---|
3835 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N; |
---|
3836 | } |
---|
3837 | |
---|
3838 | Void TComSlice::decrementRefPocValues(Int const decrementValue) |
---|
3839 | { |
---|
3840 | for(Int listNum = 0; listNum < 2; listNum++) |
---|
3841 | { |
---|
3842 | RefPicList dpbPicSliceList = (listNum == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
3843 | for(Int listIdx = 0; listIdx < getNumRefIdx( dpbPicSliceList ); listIdx++) |
---|
3844 | { |
---|
3845 | setRefPOC( getRefPOC(dpbPicSliceList, listIdx) - decrementValue, |
---|
3846 | dpbPicSliceList, |
---|
3847 | listIdx |
---|
3848 | ); |
---|
3849 | } |
---|
3850 | } |
---|
3851 | } |
---|
3852 | |
---|
3853 | Int TComSlice::getCurrMsb( Int currLsb, Int prevLsb, Int prevMsb, Int maxLsbVal ) |
---|
3854 | { |
---|
3855 | if( prevLsb - currLsb >= (maxLsbVal >> 1) ) |
---|
3856 | { |
---|
3857 | return prevMsb + maxLsbVal; |
---|
3858 | } |
---|
3859 | else if( currLsb - prevLsb > (maxLsbVal >> 1) ) |
---|
3860 | { |
---|
3861 | return prevMsb - maxLsbVal; |
---|
3862 | } |
---|
3863 | else |
---|
3864 | { |
---|
3865 | return prevMsb; |
---|
3866 | } |
---|
3867 | } |
---|
3868 | |
---|
3869 | Void TComSlice::setRefPicListModificationSvc() |
---|
3870 | { |
---|
3871 | if( !m_pcPPS->getListsModificationPresentFlag()) |
---|
3872 | { |
---|
3873 | return; |
---|
3874 | } |
---|
3875 | |
---|
3876 | if(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) |
---|
3877 | { |
---|
3878 | return; |
---|
3879 | } |
---|
3880 | |
---|
3881 | TComRefPicListModification* refPicListModification = &m_RefPicListModification; |
---|
3882 | Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList(); // total number of ref pics in listTemp0 including inter-layer ref pics |
---|
3883 | #if SVC_EXTENSION |
---|
3884 | Int numberOfPocBeforeCurr = this->getNumNegativeRpsCurrTempList(); // number of negative temporal ref pics |
---|
3885 | #endif |
---|
3886 | |
---|
3887 | assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 0); |
---|
3888 | assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 0); |
---|
3889 | |
---|
3890 | //set L0 inter-layer reference picture modification |
---|
3891 | #if SVC_EXTENSION |
---|
3892 | Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true; |
---|
3893 | |
---|
3894 | if( m_activeNumILRRefIdx > 1 ) |
---|
3895 | { |
---|
3896 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] >= (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true; |
---|
3897 | } |
---|
3898 | #else |
---|
3899 | Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == numberOfRpsCurrTempList) ? false : true; |
---|
3900 | #endif |
---|
3901 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_0] > 1 ); |
---|
3902 | refPicListModification->setRefPicListModificationFlagL0(hasModification); |
---|
3903 | if(hasModification) |
---|
3904 | { |
---|
3905 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_0], numberOfRpsCurrTempList); i++) |
---|
3906 | { |
---|
3907 | refPicListModification->setRefPicSetIdxL0(i, i); |
---|
3908 | } |
---|
3909 | |
---|
3910 | if(m_aiNumRefIdx[REF_PIC_LIST_0] > numberOfRpsCurrTempList) |
---|
3911 | { |
---|
3912 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
3913 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_0]; i ++) |
---|
3914 | { |
---|
3915 | refPicListModification->setRefPicSetIdxL0(i, numberOfRpsCurrTempList - 1); |
---|
3916 | } |
---|
3917 | } |
---|
3918 | else |
---|
3919 | { |
---|
3920 | // number of ILRPs included into the reference picture list with the list modification |
---|
3921 | Int includeNumILRP = min( max(1, m_aiNumRefIdx[REF_PIC_LIST_0]-numberOfPocBeforeCurr), m_activeNumILRRefIdx); |
---|
3922 | |
---|
3923 | for(Int i = includeNumILRP; i > 0; i-- ) |
---|
3924 | { |
---|
3925 | #if SVC_EXTENSION |
---|
3926 | if( numberOfPocBeforeCurr >= m_aiNumRefIdx[REF_PIC_LIST_0] ) |
---|
3927 | { |
---|
3928 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i); |
---|
3929 | } |
---|
3930 | else |
---|
3931 | { |
---|
3932 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i); |
---|
3933 | for( Int j = numberOfPocBeforeCurr; j < (m_aiNumRefIdx[REF_PIC_LIST_0] - i); j++ ) |
---|
3934 | { |
---|
3935 | assert( j + includeNumILRP < numberOfRpsCurrTempList ); |
---|
3936 | refPicListModification->setRefPicSetIdxL0(j, j + includeNumILRP); |
---|
3937 | } |
---|
3938 | } |
---|
3939 | #else |
---|
3940 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i); |
---|
3941 | #endif |
---|
3942 | } |
---|
3943 | } |
---|
3944 | } |
---|
3945 | |
---|
3946 | //set L1 inter-layer reference picture modification |
---|
3947 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] >= numberOfRpsCurrTempList) ? false : true; |
---|
3948 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_1] > 1 ); |
---|
3949 | |
---|
3950 | refPicListModification->setRefPicListModificationFlagL1(hasModification); |
---|
3951 | if(hasModification) |
---|
3952 | { |
---|
3953 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_1], numberOfRpsCurrTempList); i++) |
---|
3954 | { |
---|
3955 | refPicListModification->setRefPicSetIdxL1(i, i); |
---|
3956 | } |
---|
3957 | if(m_aiNumRefIdx[REF_PIC_LIST_1] > numberOfRpsCurrTempList) |
---|
3958 | { |
---|
3959 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_1]; i ++) |
---|
3960 | { |
---|
3961 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
3962 | refPicListModification->setRefPicSetIdxL1(i, numberOfRpsCurrTempList - 1); |
---|
3963 | } |
---|
3964 | } |
---|
3965 | else |
---|
3966 | { |
---|
3967 | Int includeNumILRP = min(m_aiNumRefIdx[REF_PIC_LIST_1], m_activeNumILRRefIdx); |
---|
3968 | |
---|
3969 | for(Int i = includeNumILRP; i > 0; i-- ) |
---|
3970 | { |
---|
3971 | refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i); |
---|
3972 | } |
---|
3973 | } |
---|
3974 | } |
---|
3975 | return; |
---|
3976 | } |
---|
3977 | |
---|
3978 | Int TComSlice::getNumNegativeRpsCurrTempList() |
---|
3979 | { |
---|
3980 | if( m_eSliceType == I_SLICE ) |
---|
3981 | { |
---|
3982 | return 0; |
---|
3983 | } |
---|
3984 | |
---|
3985 | Int numPocBeforeCurr = 0; |
---|
3986 | |
---|
3987 | for( UInt i = 0; i < m_pcRPS->getNumberOfNegativePictures(); i++ ) |
---|
3988 | { |
---|
3989 | if( m_pcRPS->getUsed(i) ) |
---|
3990 | { |
---|
3991 | numPocBeforeCurr++; |
---|
3992 | } |
---|
3993 | } |
---|
3994 | |
---|
3995 | return numPocBeforeCurr; |
---|
3996 | } |
---|
3997 | #endif //SVC_EXTENSION |
---|
3998 | |
---|
3999 | //! \} |
---|