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