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