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