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