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