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 | //! \ingroup TLibCommon |
---|
45 | //! \{ |
---|
46 | |
---|
47 | |
---|
48 | TComSlice::TComSlice() |
---|
49 | : m_iPPSId ( -1 ) |
---|
50 | #if H_MV |
---|
51 | , m_slicePicOrderCntLsb ( 0 ) |
---|
52 | #endif |
---|
53 | , m_iPOC ( 0 ) |
---|
54 | , m_iLastIDR ( 0 ) |
---|
55 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
56 | , m_eSliceType ( I_SLICE ) |
---|
57 | , m_iSliceQp ( 0 ) |
---|
58 | , m_dependentSliceSegmentFlag ( false ) |
---|
59 | #if ADAPTIVE_QP_SELECTION |
---|
60 | , m_iSliceQpBase ( 0 ) |
---|
61 | #endif |
---|
62 | , m_deblockingFilterDisable ( false ) |
---|
63 | , m_deblockingFilterOverrideFlag ( false ) |
---|
64 | , m_deblockingFilterBetaOffsetDiv2 ( 0 ) |
---|
65 | , m_deblockingFilterTcOffsetDiv2 ( 0 ) |
---|
66 | , m_bCheckLDC ( false ) |
---|
67 | , m_iSliceQpDelta ( 0 ) |
---|
68 | , m_iSliceQpDeltaCb ( 0 ) |
---|
69 | , m_iSliceQpDeltaCr ( 0 ) |
---|
70 | , m_iDepth ( 0 ) |
---|
71 | , m_bRefenced ( false ) |
---|
72 | , m_pcSPS ( NULL ) |
---|
73 | , m_pcPPS ( NULL ) |
---|
74 | , m_pcPic ( NULL ) |
---|
75 | , m_colFromL0Flag ( 1 ) |
---|
76 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
77 | , m_noOutputPriorPicsFlag ( false ) |
---|
78 | , m_noRaslOutputFlag ( false ) |
---|
79 | , m_handleCraAsBlaFlag ( false ) |
---|
80 | #endif |
---|
81 | , m_colRefIdx ( 0 ) |
---|
82 | , m_uiTLayer ( 0 ) |
---|
83 | , m_bTLayerSwitchingFlag ( false ) |
---|
84 | , m_sliceMode ( 0 ) |
---|
85 | , m_sliceArgument ( 0 ) |
---|
86 | , m_sliceCurStartCUAddr ( 0 ) |
---|
87 | , m_sliceCurEndCUAddr ( 0 ) |
---|
88 | , m_sliceIdx ( 0 ) |
---|
89 | , m_sliceSegmentMode ( 0 ) |
---|
90 | , m_sliceSegmentArgument ( 0 ) |
---|
91 | , m_sliceSegmentCurStartCUAddr ( 0 ) |
---|
92 | , m_sliceSegmentCurEndCUAddr ( 0 ) |
---|
93 | , m_nextSlice ( false ) |
---|
94 | , m_nextSliceSegment ( false ) |
---|
95 | , m_sliceBits ( 0 ) |
---|
96 | , m_sliceSegmentBits ( 0 ) |
---|
97 | , m_bFinalized ( false ) |
---|
98 | , m_uiTileOffstForMultES ( 0 ) |
---|
99 | , m_puiSubstreamSizes ( NULL ) |
---|
100 | , m_cabacInitFlag ( false ) |
---|
101 | , m_bLMvdL1Zero ( false ) |
---|
102 | , m_numEntryPointOffsets ( 0 ) |
---|
103 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
104 | , m_enableTMVPFlag ( true ) |
---|
105 | #if I0044_SLICE_TMVP |
---|
106 | , m_availableForTMVPRefFlag ( true ) |
---|
107 | #endif |
---|
108 | #if H_MV |
---|
109 | , m_refPicSetInterLayer0 ( NULL ) |
---|
110 | , m_refPicSetInterLayer1 ( NULL ) |
---|
111 | , m_layerId (0) |
---|
112 | , m_viewId (0) |
---|
113 | , m_viewIndex (0) |
---|
114 | #if H_3D |
---|
115 | , m_isDepth (false) |
---|
116 | #endif |
---|
117 | #if !H_MV_HLS7_GEN |
---|
118 | , m_pocResetFlag (false) |
---|
119 | #endif |
---|
120 | #if H_MV |
---|
121 | , m_crossLayerBlaFlag (false) |
---|
122 | #endif |
---|
123 | , m_discardableFlag (false) |
---|
124 | , m_interLayerPredEnabledFlag (false) |
---|
125 | , m_numInterLayerRefPicsMinus1 (0) |
---|
126 | #if H_MV |
---|
127 | , m_sliceSegmentHeaderExtensionLength (0) |
---|
128 | , m_pocResetIdc (0) |
---|
129 | , m_pocResetPeriodId (0) |
---|
130 | , m_fullPocResetFlag (false) |
---|
131 | , m_pocLsbVal (0) |
---|
132 | , m_pocMsbValPresentFlag (false) |
---|
133 | , m_pocMsbVal (0) |
---|
134 | , m_pocMsbValRequiredFlag ( false ) |
---|
135 | #endif |
---|
136 | #if H_3D_IC |
---|
137 | , m_bApplyIC ( false ) |
---|
138 | , m_icSkipParseFlag ( false ) |
---|
139 | #endif |
---|
140 | #if H_3D |
---|
141 | , m_depthToDisparityB ( NULL ) |
---|
142 | , m_depthToDisparityF ( NULL ) |
---|
143 | #endif |
---|
144 | #if MTK_SINGLE_DEPTH_MODE_I0095 |
---|
145 | , m_bApplySingleDepthMode (false) |
---|
146 | #endif |
---|
147 | #endif |
---|
148 | { |
---|
149 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = 0; |
---|
150 | |
---|
151 | initEqualRef(); |
---|
152 | |
---|
153 | for (Int component = 0; component < 3; component++) |
---|
154 | { |
---|
155 | m_lambdas[component] = 0.0; |
---|
156 | } |
---|
157 | |
---|
158 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
159 | { |
---|
160 | m_list1IdxToList0Idx[idx] = -1; |
---|
161 | } |
---|
162 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
163 | { |
---|
164 | m_apcRefPicList [0][iNumCount] = NULL; |
---|
165 | m_apcRefPicList [1][iNumCount] = NULL; |
---|
166 | m_aiRefPOCList [0][iNumCount] = 0; |
---|
167 | m_aiRefPOCList [1][iNumCount] = 0; |
---|
168 | #if H_MV |
---|
169 | m_aiRefLayerIdList[0][iNumCount] = 0; |
---|
170 | m_aiRefLayerIdList[1][iNumCount] = 0; |
---|
171 | #endif |
---|
172 | } |
---|
173 | resetWpScaling(); |
---|
174 | initWpAcDcParam(); |
---|
175 | m_saoEnabledFlag = false; |
---|
176 | m_saoEnabledFlagChroma = false; |
---|
177 | #if H_MV |
---|
178 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
179 | { |
---|
180 | m_interLayerPredLayerIdc[ i ] = -1; |
---|
181 | } |
---|
182 | #endif |
---|
183 | } |
---|
184 | |
---|
185 | TComSlice::~TComSlice() |
---|
186 | { |
---|
187 | delete[] m_puiSubstreamSizes; |
---|
188 | m_puiSubstreamSizes = NULL; |
---|
189 | #if H_3D |
---|
190 | for( UInt i = 0; i < getViewIndex(); i++ ) |
---|
191 | { |
---|
192 | if ( m_depthToDisparityB && m_depthToDisparityB[ i ] ) |
---|
193 | { |
---|
194 | delete[] m_depthToDisparityB [ i ]; |
---|
195 | } |
---|
196 | |
---|
197 | if ( m_depthToDisparityF && m_depthToDisparityF[ i ] ) |
---|
198 | { |
---|
199 | delete[] m_depthToDisparityF [ i ]; |
---|
200 | } |
---|
201 | } |
---|
202 | |
---|
203 | if ( m_depthToDisparityF ) |
---|
204 | { |
---|
205 | delete[] m_depthToDisparityF; |
---|
206 | } |
---|
207 | |
---|
208 | m_depthToDisparityF = NULL; |
---|
209 | |
---|
210 | if ( m_depthToDisparityB ) |
---|
211 | delete[] m_depthToDisparityB; |
---|
212 | |
---|
213 | m_depthToDisparityB = NULL; |
---|
214 | #endif |
---|
215 | } |
---|
216 | |
---|
217 | |
---|
218 | Void TComSlice::initSlice() |
---|
219 | { |
---|
220 | m_aiNumRefIdx[0] = 0; |
---|
221 | m_aiNumRefIdx[1] = 0; |
---|
222 | |
---|
223 | m_colFromL0Flag = 1; |
---|
224 | |
---|
225 | m_colRefIdx = 0; |
---|
226 | initEqualRef(); |
---|
227 | m_bCheckLDC = false; |
---|
228 | m_iSliceQpDeltaCb = 0; |
---|
229 | m_iSliceQpDeltaCr = 0; |
---|
230 | |
---|
231 | #if H_3D_IV_MERGE |
---|
232 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS_MEM; |
---|
233 | #else |
---|
234 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
235 | #endif |
---|
236 | |
---|
237 | m_bFinalized=false; |
---|
238 | |
---|
239 | m_tileByteLocation.clear(); |
---|
240 | m_cabacInitFlag = false; |
---|
241 | m_numEntryPointOffsets = 0; |
---|
242 | m_enableTMVPFlag = true; |
---|
243 | #if H_3D_TMVP |
---|
244 | m_aiAlterRefIdx[0] = -1; |
---|
245 | m_aiAlterRefIdx[1] = -1; |
---|
246 | #endif |
---|
247 | } |
---|
248 | |
---|
249 | Bool TComSlice::getRapPicFlag() |
---|
250 | { |
---|
251 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
252 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
253 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
254 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
255 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
256 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
257 | } |
---|
258 | |
---|
259 | /** |
---|
260 | - allocate table to contain substream sizes to be written to the slice header. |
---|
261 | . |
---|
262 | \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1. |
---|
263 | */ |
---|
264 | Void TComSlice::allocSubstreamSizes(UInt uiNumSubstreams) |
---|
265 | { |
---|
266 | delete[] m_puiSubstreamSizes; |
---|
267 | m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0]; |
---|
268 | } |
---|
269 | |
---|
270 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
271 | { |
---|
272 | TComPic* pcPicExtract; |
---|
273 | TComPic* pcPicInsert; |
---|
274 | |
---|
275 | TComList<TComPic*>::iterator iterPicExtract; |
---|
276 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
277 | TComList<TComPic*>::iterator iterPicInsert; |
---|
278 | |
---|
279 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
280 | { |
---|
281 | iterPicExtract = rcListPic.begin(); |
---|
282 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
283 | pcPicExtract = *(iterPicExtract); |
---|
284 | pcPicExtract->setCurrSliceIdx(0); |
---|
285 | |
---|
286 | iterPicInsert = rcListPic.begin(); |
---|
287 | while (iterPicInsert != iterPicExtract) |
---|
288 | { |
---|
289 | pcPicInsert = *(iterPicInsert); |
---|
290 | pcPicInsert->setCurrSliceIdx(0); |
---|
291 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
292 | { |
---|
293 | break; |
---|
294 | } |
---|
295 | |
---|
296 | iterPicInsert++; |
---|
297 | } |
---|
298 | |
---|
299 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
300 | |
---|
301 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
302 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
303 | rcListPic.erase (iterPicExtract); |
---|
304 | } |
---|
305 | } |
---|
306 | |
---|
307 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, |
---|
308 | Int poc) |
---|
309 | { |
---|
310 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
311 | TComPic* pcPic = *(iterPic); |
---|
312 | while ( iterPic != rcListPic.end() ) |
---|
313 | { |
---|
314 | if(pcPic->getPOC() == poc) |
---|
315 | { |
---|
316 | break; |
---|
317 | } |
---|
318 | iterPic++; |
---|
319 | pcPic = *(iterPic); |
---|
320 | } |
---|
321 | return pcPic; |
---|
322 | } |
---|
323 | |
---|
324 | |
---|
325 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
326 | { |
---|
327 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
328 | TComPic* pcPic = *(iterPic); |
---|
329 | TComPic* pcStPic = pcPic; |
---|
330 | |
---|
331 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
332 | if (!pocHasMsb) |
---|
333 | { |
---|
334 | poc = poc & (pocCycle - 1); |
---|
335 | } |
---|
336 | |
---|
337 | while ( iterPic != rcListPic.end() ) |
---|
338 | { |
---|
339 | pcPic = *(iterPic); |
---|
340 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
341 | { |
---|
342 | Int picPoc = pcPic->getPOC(); |
---|
343 | if (!pocHasMsb) |
---|
344 | { |
---|
345 | picPoc = picPoc & (pocCycle - 1); |
---|
346 | } |
---|
347 | |
---|
348 | if (poc == picPoc) |
---|
349 | { |
---|
350 | if(pcPic->getIsLongTerm()) |
---|
351 | { |
---|
352 | return pcPic; |
---|
353 | } |
---|
354 | else |
---|
355 | { |
---|
356 | pcStPic = pcPic; |
---|
357 | } |
---|
358 | break; |
---|
359 | } |
---|
360 | } |
---|
361 | |
---|
362 | iterPic++; |
---|
363 | } |
---|
364 | |
---|
365 | return pcStPic; |
---|
366 | } |
---|
367 | |
---|
368 | Void TComSlice::setRefPOCList () |
---|
369 | { |
---|
370 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
371 | { |
---|
372 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
373 | { |
---|
374 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
375 | #if H_MV |
---|
376 | m_aiRefLayerIdList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getLayerId(); |
---|
377 | #endif |
---|
378 | } |
---|
379 | } |
---|
380 | |
---|
381 | } |
---|
382 | |
---|
383 | Void TComSlice::setList1IdxToList0Idx() |
---|
384 | { |
---|
385 | Int idxL0, idxL1; |
---|
386 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
387 | { |
---|
388 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
389 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
390 | { |
---|
391 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
392 | { |
---|
393 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
394 | break; |
---|
395 | } |
---|
396 | } |
---|
397 | } |
---|
398 | } |
---|
399 | |
---|
400 | #if !H_MV |
---|
401 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) |
---|
402 | { |
---|
403 | if (!checkNumPocTotalCurr) |
---|
404 | { |
---|
405 | if (m_eSliceType == I_SLICE) |
---|
406 | { |
---|
407 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
408 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
409 | |
---|
410 | return; |
---|
411 | } |
---|
412 | |
---|
413 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
414 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
415 | } |
---|
416 | |
---|
417 | TComPic* pcRefPic= NULL; |
---|
418 | TComPic* RefPicSetStCurr0[16]; |
---|
419 | TComPic* RefPicSetStCurr1[16]; |
---|
420 | TComPic* RefPicSetLtCurr[16]; |
---|
421 | UInt NumPocStCurr0 = 0; |
---|
422 | UInt NumPocStCurr1 = 0; |
---|
423 | UInt NumPocLtCurr = 0; |
---|
424 | Int i; |
---|
425 | |
---|
426 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
427 | { |
---|
428 | if(m_pcRPS->getUsed(i)) |
---|
429 | { |
---|
430 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
431 | pcRefPic->setIsLongTerm(0); |
---|
432 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
433 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
434 | NumPocStCurr0++; |
---|
435 | pcRefPic->setCheckLTMSBPresent(false); |
---|
436 | } |
---|
437 | } |
---|
438 | |
---|
439 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
440 | { |
---|
441 | if(m_pcRPS->getUsed(i)) |
---|
442 | { |
---|
443 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
444 | pcRefPic->setIsLongTerm(0); |
---|
445 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
446 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
447 | NumPocStCurr1++; |
---|
448 | pcRefPic->setCheckLTMSBPresent(false); |
---|
449 | } |
---|
450 | } |
---|
451 | |
---|
452 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
453 | { |
---|
454 | if(m_pcRPS->getUsed(i)) |
---|
455 | { |
---|
456 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
457 | pcRefPic->setIsLongTerm(1); |
---|
458 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
459 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
460 | NumPocLtCurr++; |
---|
461 | } |
---|
462 | if(pcRefPic==NULL) |
---|
463 | { |
---|
464 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
465 | } |
---|
466 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
467 | } |
---|
468 | |
---|
469 | // ref_pic_list_init |
---|
470 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
471 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
472 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
473 | if (checkNumPocTotalCurr) |
---|
474 | { |
---|
475 | // 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: |
---|
476 | // - If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
477 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
478 | if (getRapPicFlag()) |
---|
479 | { |
---|
480 | assert(numPocTotalCurr == 0); |
---|
481 | } |
---|
482 | |
---|
483 | if (m_eSliceType == I_SLICE) |
---|
484 | { |
---|
485 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
486 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
487 | |
---|
488 | return; |
---|
489 | } |
---|
490 | |
---|
491 | assert(numPocTotalCurr > 0); |
---|
492 | |
---|
493 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
494 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
495 | } |
---|
496 | |
---|
497 | Int cIdx = 0; |
---|
498 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
499 | { |
---|
500 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
501 | } |
---|
502 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
503 | { |
---|
504 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
505 | } |
---|
506 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
507 | { |
---|
508 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
509 | } |
---|
510 | assert(cIdx == numPocTotalCurr); |
---|
511 | |
---|
512 | if (m_eSliceType==B_SLICE) |
---|
513 | { |
---|
514 | cIdx = 0; |
---|
515 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
516 | { |
---|
517 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
518 | } |
---|
519 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
520 | { |
---|
521 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
522 | } |
---|
523 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
524 | { |
---|
525 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
526 | } |
---|
527 | assert(cIdx == numPocTotalCurr); |
---|
528 | } |
---|
529 | |
---|
530 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
531 | |
---|
532 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[0]; rIdx ++) |
---|
533 | { |
---|
534 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPocTotalCurr; |
---|
535 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
536 | m_apcRefPicList[0][rIdx] = rpsCurrList0[ cIdx ]; |
---|
537 | m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
538 | } |
---|
539 | if ( m_eSliceType != B_SLICE ) |
---|
540 | { |
---|
541 | m_aiNumRefIdx[1] = 0; |
---|
542 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
543 | } |
---|
544 | else |
---|
545 | { |
---|
546 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[1]; rIdx ++) |
---|
547 | { |
---|
548 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPocTotalCurr; |
---|
549 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
550 | m_apcRefPicList[1][rIdx] = rpsCurrList1[ cIdx ]; |
---|
551 | m_bIsUsedAsLongTerm[1][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
552 | } |
---|
553 | } |
---|
554 | } |
---|
555 | |
---|
556 | #else |
---|
557 | Void TComSlice::getTempRefPicLists( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1, |
---|
558 | std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int& numPocTotalCurr, Bool checkNumPocTotalCurr ) |
---|
559 | { |
---|
560 | if (!checkNumPocTotalCurr) |
---|
561 | { |
---|
562 | if (m_eSliceType == I_SLICE) |
---|
563 | { |
---|
564 | return; |
---|
565 | } |
---|
566 | } |
---|
567 | |
---|
568 | TComPic* pcRefPic= NULL; |
---|
569 | TComPic* RefPicSetStCurr0[16]; |
---|
570 | TComPic* RefPicSetStCurr1[16]; |
---|
571 | TComPic* RefPicSetLtCurr[16]; |
---|
572 | UInt NumPocStCurr0 = 0; |
---|
573 | UInt NumPocStCurr1 = 0; |
---|
574 | UInt NumPocLtCurr = 0; |
---|
575 | Int i; |
---|
576 | |
---|
577 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
578 | { |
---|
579 | if(m_pcRPS->getUsed(i)) |
---|
580 | { |
---|
581 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
582 | pcRefPic->setIsLongTerm(0); |
---|
583 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
584 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
585 | NumPocStCurr0++; |
---|
586 | pcRefPic->setCheckLTMSBPresent(false); |
---|
587 | } |
---|
588 | } |
---|
589 | |
---|
590 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
591 | { |
---|
592 | if(m_pcRPS->getUsed(i)) |
---|
593 | { |
---|
594 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
595 | pcRefPic->setIsLongTerm(0); |
---|
596 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
597 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
598 | NumPocStCurr1++; |
---|
599 | pcRefPic->setCheckLTMSBPresent(false); |
---|
600 | } |
---|
601 | } |
---|
602 | |
---|
603 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
604 | { |
---|
605 | if(m_pcRPS->getUsed(i)) |
---|
606 | { |
---|
607 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
608 | pcRefPic->setIsLongTerm(1); |
---|
609 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
610 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
611 | NumPocLtCurr++; |
---|
612 | } |
---|
613 | if(pcRefPic==NULL) |
---|
614 | { |
---|
615 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
616 | } |
---|
617 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
618 | } |
---|
619 | |
---|
620 | Int numPocInterCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
621 | numPocTotalCurr = numPocInterCurr + getNumActiveRefLayerPics( ); |
---|
622 | assert( numPocTotalCurr == getNumRpsCurrTempList() ); |
---|
623 | |
---|
624 | if (checkNumPocTotalCurr) |
---|
625 | { |
---|
626 | // 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: |
---|
627 | // - If nuh_layer_id is equal to 0 and the current picture is a BLA picture or a CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
628 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
629 | if ( getRapPicFlag() && m_layerId == 0 ) |
---|
630 | { |
---|
631 | assert(numPocTotalCurr == 0); |
---|
632 | } |
---|
633 | |
---|
634 | if (m_eSliceType == I_SLICE) |
---|
635 | { |
---|
636 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
637 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
638 | |
---|
639 | return; |
---|
640 | } |
---|
641 | |
---|
642 | assert(numPocTotalCurr > 0); |
---|
643 | |
---|
644 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
645 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
646 | } |
---|
647 | |
---|
648 | std::vector<TComPic*>* refPicSetInterLayer[2] = { &refPicSetInterLayer0, &refPicSetInterLayer1}; |
---|
649 | Int numPocInterLayer[2] = { getNumActiveRefLayerPics0( ), getNumActiveRefLayerPics1( ) }; |
---|
650 | |
---|
651 | TComPic** refPicSetStCurr [2] = { RefPicSetStCurr0, RefPicSetStCurr1 }; |
---|
652 | #if FIX_WARNING |
---|
653 | Int numPocStCurr[2] = { (Int)NumPocStCurr0, (Int)NumPocStCurr1 }; |
---|
654 | #else |
---|
655 | Int numPocStCurr[2] = { NumPocStCurr0, NumPocStCurr1 }; |
---|
656 | #endif |
---|
657 | |
---|
658 | for (Int li = 0; li < ((m_eSliceType==B_SLICE) ? 2 : 1); li++) |
---|
659 | { |
---|
660 | rpsCurrList [li].resize(MAX_NUM_REF+1,NULL ); |
---|
661 | usedAsLongTerm[li].resize(MAX_NUM_REF+1,false); |
---|
662 | |
---|
663 | Int cIdx = 0; |
---|
664 | for ( i=0; i < numPocStCurr[li]; i++, cIdx++) |
---|
665 | { |
---|
666 | rpsCurrList[li][cIdx] = refPicSetStCurr[li][i]; |
---|
667 | usedAsLongTerm [li][cIdx] = false; |
---|
668 | } |
---|
669 | |
---|
670 | for ( i=0; i < numPocInterLayer[li]; i++, cIdx++) |
---|
671 | { |
---|
672 | rpsCurrList[li][cIdx] = (*refPicSetInterLayer[li])[i]; |
---|
673 | usedAsLongTerm [li][cIdx] = true; |
---|
674 | } |
---|
675 | |
---|
676 | for ( i=0; i < numPocStCurr[1-li]; i++, cIdx++) |
---|
677 | { |
---|
678 | rpsCurrList[li][cIdx] = refPicSetStCurr[1-li][i]; |
---|
679 | usedAsLongTerm [li][cIdx] = false; |
---|
680 | } |
---|
681 | |
---|
682 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
683 | { |
---|
684 | rpsCurrList[li][cIdx] = RefPicSetLtCurr[i]; |
---|
685 | usedAsLongTerm [li][cIdx] = true; |
---|
686 | } |
---|
687 | |
---|
688 | for ( i=0; i < numPocInterLayer[1-li]; i++, cIdx++) |
---|
689 | { |
---|
690 | assert( cIdx < MAX_NUM_REF ); |
---|
691 | rpsCurrList[li][cIdx] = (*refPicSetInterLayer[1-li])[i]; |
---|
692 | usedAsLongTerm [li][cIdx] = true; |
---|
693 | } |
---|
694 | |
---|
695 | assert(cIdx == numPocTotalCurr); |
---|
696 | } |
---|
697 | } |
---|
698 | |
---|
699 | Void TComSlice::setRefPicList( std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int numPocTotalCurr, Bool checkNumPocTotalCurr ) |
---|
700 | |
---|
701 | { |
---|
702 | if (!checkNumPocTotalCurr) |
---|
703 | { |
---|
704 | if (m_eSliceType == I_SLICE) |
---|
705 | { |
---|
706 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
707 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
708 | |
---|
709 | return; |
---|
710 | } |
---|
711 | } |
---|
712 | |
---|
713 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
714 | |
---|
715 | for (Int li = 0; li < 2; li++) |
---|
716 | { |
---|
717 | if ( m_eSliceType == P_SLICE && li == 1 ) |
---|
718 | { |
---|
719 | m_aiNumRefIdx[1] = 0; |
---|
720 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
721 | } |
---|
722 | else |
---|
723 | { |
---|
724 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[ li ] - 1 ); rIdx ++) |
---|
725 | { |
---|
726 | Bool listModified = m_RefPicListModification.getRefPicListModificationFlagL( li ); |
---|
727 | Int orgIdx = listModified ? m_RefPicListModification.getRefPicSetIdxL(li, rIdx) : (rIdx % numPocTotalCurr); |
---|
728 | |
---|
729 | assert( rpsCurrList[li][ orgIdx ] != NULL ); |
---|
730 | #if DISCARDABLE_PIC_RPS |
---|
731 | assert( rpsCurrList[li][ orgIdx ]->getSlice(0)->getDiscardableFlag() == 0 ); // Inter-layer RPS shall not contain picture with discardable_flag = 1. |
---|
732 | #endif |
---|
733 | m_apcRefPicList [li][rIdx] = rpsCurrList [li][ orgIdx ]; |
---|
734 | m_bIsUsedAsLongTerm[li][rIdx] = usedAsLongTerm [li][ orgIdx ] ; |
---|
735 | } |
---|
736 | } |
---|
737 | } |
---|
738 | } |
---|
739 | #endif |
---|
740 | Int TComSlice::getNumRpsCurrTempList() |
---|
741 | { |
---|
742 | Int numRpsCurrTempList = 0; |
---|
743 | |
---|
744 | if (m_eSliceType == I_SLICE) |
---|
745 | { |
---|
746 | return 0; |
---|
747 | } |
---|
748 | for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++) |
---|
749 | { |
---|
750 | if(m_pcRPS->getUsed(i)) |
---|
751 | { |
---|
752 | numRpsCurrTempList++; |
---|
753 | } |
---|
754 | } |
---|
755 | #if H_MV |
---|
756 | numRpsCurrTempList = numRpsCurrTempList + getNumActiveRefLayerPics(); |
---|
757 | #endif |
---|
758 | return numRpsCurrTempList; |
---|
759 | } |
---|
760 | |
---|
761 | Void TComSlice::initEqualRef() |
---|
762 | { |
---|
763 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
764 | { |
---|
765 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
766 | { |
---|
767 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
768 | { |
---|
769 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
770 | } |
---|
771 | } |
---|
772 | } |
---|
773 | } |
---|
774 | #if H_3D |
---|
775 | #if H_3D_TMVP |
---|
776 | Void TComSlice::generateAlterRefforTMVP() |
---|
777 | { |
---|
778 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
779 | { |
---|
780 | if ( this->getNumRefIdx( RefPicList( uiRefListIdx ) ) == 0) |
---|
781 | { |
---|
782 | continue; |
---|
783 | } |
---|
784 | Bool bZeroIdxLtFlag = this->getRefPic(RefPicList(uiRefListIdx), 0)->getIsLongTerm(); |
---|
785 | for(Int i = 1; i < this->getNumRefIdx(RefPicList(uiRefListIdx)); i++ ) |
---|
786 | { |
---|
787 | if ( ( bZeroIdxLtFlag && !this->getRefPic(RefPicList(uiRefListIdx), i)->getIsLongTerm() ) || |
---|
788 | (!bZeroIdxLtFlag && this->getRefPic(RefPicList(uiRefListIdx), i)->getIsLongTerm() ) ) |
---|
789 | { |
---|
790 | this->setAlterRefIdx(RefPicList(uiRefListIdx),i); |
---|
791 | break; |
---|
792 | } |
---|
793 | } |
---|
794 | } |
---|
795 | } |
---|
796 | #endif |
---|
797 | Void TComSlice::setCamparaSlice( Int** aaiScale, Int** aaiOffset ) |
---|
798 | { |
---|
799 | if( m_pcVPS->hasCamParInSliceHeader( m_viewIndex ) ) |
---|
800 | { |
---|
801 | for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < m_viewIndex; uiBaseViewIndex++ ) |
---|
802 | { |
---|
803 | m_aaiCodedScale [ 0 ][ uiBaseViewIndex ] = aaiScale [ uiBaseViewIndex ][ m_viewIndex ]; |
---|
804 | m_aaiCodedScale [ 1 ][ uiBaseViewIndex ] = aaiScale [ m_viewIndex ][ uiBaseViewIndex ]; |
---|
805 | m_aaiCodedOffset[ 0 ][ uiBaseViewIndex ] = aaiOffset[ uiBaseViewIndex ][ m_viewIndex ]; |
---|
806 | m_aaiCodedOffset[ 1 ][ uiBaseViewIndex ] = aaiOffset[ m_viewIndex ][ uiBaseViewIndex ]; |
---|
807 | } |
---|
808 | } |
---|
809 | } |
---|
810 | #endif |
---|
811 | |
---|
812 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
813 | { |
---|
814 | Int i; |
---|
815 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
816 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1-curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
817 | TComSlice* preSlice; |
---|
818 | Int preColRefPOC; |
---|
819 | for(i=curSliceIdx-1; i>=0; i--) |
---|
820 | { |
---|
821 | preSlice = pic->getSlice(i); |
---|
822 | if(preSlice->getSliceType() != I_SLICE) |
---|
823 | { |
---|
824 | preColRefPOC = preSlice->getRefPOC( RefPicList(1-preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
825 | if(currColRefPOC != preColRefPOC) |
---|
826 | { |
---|
827 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
828 | exit(EXIT_FAILURE); |
---|
829 | } |
---|
830 | else |
---|
831 | { |
---|
832 | break; |
---|
833 | } |
---|
834 | } |
---|
835 | } |
---|
836 | } |
---|
837 | |
---|
838 | Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic) |
---|
839 | { |
---|
840 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
841 | { |
---|
842 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
843 | { |
---|
844 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
845 | } |
---|
846 | } |
---|
847 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
848 | { |
---|
849 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
850 | { |
---|
851 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
852 | { |
---|
853 | assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA); |
---|
854 | } |
---|
855 | else |
---|
856 | { |
---|
857 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
858 | } |
---|
859 | } |
---|
860 | } |
---|
861 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
862 | { |
---|
863 | pocCRA = getPOC(); |
---|
864 | associatedIRAPType = getNalUnitType(); |
---|
865 | } |
---|
866 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
867 | { |
---|
868 | pocCRA = getPOC(); |
---|
869 | associatedIRAPType = getNalUnitType(); |
---|
870 | } |
---|
871 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
872 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
873 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
874 | { |
---|
875 | pocCRA = getPOC(); |
---|
876 | associatedIRAPType = getNalUnitType(); |
---|
877 | } |
---|
878 | } |
---|
879 | |
---|
880 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
881 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
882 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
883 | * \param rcListPic reference to the reference picture list |
---|
884 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
885 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
886 | * are marked as "unused for reference" |
---|
887 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
888 | * Otherwise |
---|
889 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
890 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
891 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
892 | * the bRefreshPending flag to false. |
---|
893 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
894 | * reference of the current picture. |
---|
895 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
896 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
897 | */ |
---|
898 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
899 | { |
---|
900 | TComPic* rpcPic; |
---|
901 | #if !FIX1172 |
---|
902 | setAssociatedIRAPPOC(pocCRA); |
---|
903 | #endif |
---|
904 | Int pocCurr = getPOC(); |
---|
905 | |
---|
906 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
907 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
908 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
909 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
910 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
911 | { |
---|
912 | // mark all pictures as not used for reference |
---|
913 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
914 | while (iterPic != rcListPic.end()) |
---|
915 | { |
---|
916 | rpcPic = *(iterPic); |
---|
917 | rpcPic->setCurrSliceIdx(0); |
---|
918 | if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
919 | iterPic++; |
---|
920 | } |
---|
921 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
922 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
923 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
924 | { |
---|
925 | pocCRA = pocCurr; |
---|
926 | } |
---|
927 | #if EFFICIENT_FIELD_IRAP |
---|
928 | bRefreshPending = true; |
---|
929 | #endif |
---|
930 | } |
---|
931 | else // CRA or No DR |
---|
932 | { |
---|
933 | #if EFFICIENT_FIELD_IRAP |
---|
934 | if(getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
935 | { |
---|
936 | if (bRefreshPending==true && pocCurr > m_iLastIDR) // IDR reference marking pending |
---|
937 | { |
---|
938 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
939 | while (iterPic != rcListPic.end()) |
---|
940 | { |
---|
941 | rpcPic = *(iterPic); |
---|
942 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != m_iLastIDR) |
---|
943 | { |
---|
944 | rpcPic->getSlice(0)->setReferenced(false); |
---|
945 | } |
---|
946 | iterPic++; |
---|
947 | } |
---|
948 | bRefreshPending = false; |
---|
949 | } |
---|
950 | } |
---|
951 | else |
---|
952 | { |
---|
953 | #endif |
---|
954 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
955 | { |
---|
956 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
957 | while (iterPic != rcListPic.end()) |
---|
958 | { |
---|
959 | rpcPic = *(iterPic); |
---|
960 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
961 | { |
---|
962 | rpcPic->getSlice(0)->setReferenced(false); |
---|
963 | } |
---|
964 | iterPic++; |
---|
965 | } |
---|
966 | bRefreshPending = false; |
---|
967 | } |
---|
968 | #if EFFICIENT_FIELD_IRAP |
---|
969 | } |
---|
970 | #endif |
---|
971 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
972 | { |
---|
973 | bRefreshPending = true; |
---|
974 | pocCRA = pocCurr; |
---|
975 | } |
---|
976 | } |
---|
977 | } |
---|
978 | |
---|
979 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
980 | { |
---|
981 | assert( pSrc != NULL ); |
---|
982 | |
---|
983 | Int i, j, k; |
---|
984 | |
---|
985 | m_iPOC = pSrc->m_iPOC; |
---|
986 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
987 | #if H_MV |
---|
988 | m_layerId = pSrc->m_layerId; |
---|
989 | // GT: Copying of several other values might be be missing here, or is above not necessary? |
---|
990 | #endif |
---|
991 | m_eSliceType = pSrc->m_eSliceType; |
---|
992 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
993 | #if ADAPTIVE_QP_SELECTION |
---|
994 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
995 | #endif |
---|
996 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
997 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
998 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
999 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
1000 | |
---|
1001 | for (i = 0; i < 2; i++) |
---|
1002 | { |
---|
1003 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
1004 | } |
---|
1005 | |
---|
1006 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
1007 | { |
---|
1008 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
1009 | } |
---|
1010 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
1011 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
1012 | m_iSliceQpDeltaCb = pSrc->m_iSliceQpDeltaCb; |
---|
1013 | m_iSliceQpDeltaCr = pSrc->m_iSliceQpDeltaCr; |
---|
1014 | for (i = 0; i < 2; i++) |
---|
1015 | { |
---|
1016 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1017 | { |
---|
1018 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
1019 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
1020 | #if H_MV |
---|
1021 | m_aiRefLayerIdList[i][j] = pSrc->m_aiRefLayerIdList[i][j]; |
---|
1022 | #endif |
---|
1023 | } |
---|
1024 | } |
---|
1025 | for (i = 0; i < 2; i++) |
---|
1026 | { |
---|
1027 | for (j = 0; j < MAX_NUM_REF + 1; j++) |
---|
1028 | { |
---|
1029 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
1030 | } |
---|
1031 | } |
---|
1032 | m_iDepth = pSrc->m_iDepth; |
---|
1033 | |
---|
1034 | // referenced slice |
---|
1035 | m_bRefenced = pSrc->m_bRefenced; |
---|
1036 | |
---|
1037 | // access channel |
---|
1038 | #if H_MV |
---|
1039 | m_pcVPS = pSrc->m_pcVPS; |
---|
1040 | #endif |
---|
1041 | m_pcSPS = pSrc->m_pcSPS; |
---|
1042 | m_pcPPS = pSrc->m_pcPPS; |
---|
1043 | m_pcRPS = pSrc->m_pcRPS; |
---|
1044 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
1045 | |
---|
1046 | m_pcPic = pSrc->m_pcPic; |
---|
1047 | |
---|
1048 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
1049 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
1050 | setLambdas(pSrc->getLambdas()); |
---|
1051 | for (i = 0; i < 2; i++) |
---|
1052 | { |
---|
1053 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1054 | { |
---|
1055 | for (k =0; k < MAX_NUM_REF; k++) |
---|
1056 | { |
---|
1057 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
1058 | } |
---|
1059 | } |
---|
1060 | } |
---|
1061 | |
---|
1062 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
1063 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
1064 | |
---|
1065 | m_sliceMode = pSrc->m_sliceMode; |
---|
1066 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
1067 | m_sliceCurStartCUAddr = pSrc->m_sliceCurStartCUAddr; |
---|
1068 | m_sliceCurEndCUAddr = pSrc->m_sliceCurEndCUAddr; |
---|
1069 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
1070 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
1071 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
1072 | m_sliceSegmentCurStartCUAddr = pSrc->m_sliceSegmentCurStartCUAddr; |
---|
1073 | m_sliceSegmentCurEndCUAddr = pSrc->m_sliceSegmentCurEndCUAddr; |
---|
1074 | m_nextSlice = pSrc->m_nextSlice; |
---|
1075 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
1076 | for ( Int e=0 ; e<2 ; e++ ) |
---|
1077 | { |
---|
1078 | for ( Int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
1079 | { |
---|
1080 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
1081 | } |
---|
1082 | } |
---|
1083 | m_saoEnabledFlag = pSrc->m_saoEnabledFlag; |
---|
1084 | m_saoEnabledFlagChroma = pSrc->m_saoEnabledFlagChroma; |
---|
1085 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
1086 | m_numEntryPointOffsets = pSrc->m_numEntryPointOffsets; |
---|
1087 | |
---|
1088 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
1089 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
1090 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
1091 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
1092 | |
---|
1093 | #if H_MV |
---|
1094 | // Additional slice header syntax elements |
---|
1095 | #if !H_MV_HLS7_GEN |
---|
1096 | m_pocResetFlag = pSrc->m_pocResetFlag; |
---|
1097 | #endif |
---|
1098 | m_discardableFlag = pSrc->m_discardableFlag; |
---|
1099 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
1100 | m_numInterLayerRefPicsMinus1 = pSrc->m_numInterLayerRefPicsMinus1; |
---|
1101 | |
---|
1102 | for (Int layer = 0; layer < MAX_NUM_LAYERS; layer++ ) |
---|
1103 | { |
---|
1104 | m_interLayerPredLayerIdc[ layer ] = pSrc->m_interLayerPredLayerIdc[ layer ]; |
---|
1105 | } |
---|
1106 | #endif |
---|
1107 | #if MTK_SINGLE_DEPTH_MODE_I0095 |
---|
1108 | m_bApplySingleDepthMode = pSrc->m_bApplySingleDepthMode; |
---|
1109 | #endif |
---|
1110 | #if H_3D_IC |
---|
1111 | m_bApplyIC = pSrc->m_bApplyIC; |
---|
1112 | m_icSkipParseFlag = pSrc->m_icSkipParseFlag; |
---|
1113 | #endif |
---|
1114 | } |
---|
1115 | |
---|
1116 | Int TComSlice::m_prevTid0POC = 0; |
---|
1117 | |
---|
1118 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
1119 | * \param uiTLayer Temporal layer ID of the current slice |
---|
1120 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
1121 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
1122 | * temporal_layer_switching_point_flag is set accordingly. |
---|
1123 | */ |
---|
1124 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
1125 | { |
---|
1126 | m_uiTLayer = uiTLayer; |
---|
1127 | } |
---|
1128 | |
---|
1129 | /** Function for checking if this is a switching-point |
---|
1130 | */ |
---|
1131 | Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic ) |
---|
1132 | { |
---|
1133 | TComPic* rpcPic; |
---|
1134 | // loop through all pictures in the reference picture buffer |
---|
1135 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1136 | while ( iterPic != rcListPic.end()) |
---|
1137 | { |
---|
1138 | rpcPic = *(iterPic++); |
---|
1139 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
1140 | { |
---|
1141 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1142 | { |
---|
1143 | return false; |
---|
1144 | } |
---|
1145 | } |
---|
1146 | } |
---|
1147 | return true; |
---|
1148 | } |
---|
1149 | |
---|
1150 | /** Function for checking if this is a STSA candidate |
---|
1151 | */ |
---|
1152 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic ) |
---|
1153 | { |
---|
1154 | TComPic* rpcPic; |
---|
1155 | |
---|
1156 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1157 | while ( iterPic != rcListPic.end()) |
---|
1158 | { |
---|
1159 | rpcPic = *(iterPic++); |
---|
1160 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
1161 | { |
---|
1162 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1163 | { |
---|
1164 | return false; |
---|
1165 | } |
---|
1166 | } |
---|
1167 | } |
---|
1168 | return true; |
---|
1169 | } |
---|
1170 | |
---|
1171 | |
---|
1172 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) |
---|
1173 | { |
---|
1174 | TComPic* rpcPic; |
---|
1175 | |
---|
1176 | Int nalUnitType = this->getNalUnitType(); |
---|
1177 | |
---|
1178 | // When a picture is a leading picture, it shall be a RADL or RASL picture. |
---|
1179 | if(this->getAssociatedIRAPPOC() > this->getPOC()) |
---|
1180 | { |
---|
1181 | // Do not check IRAP pictures since they may get a POC lower than their associated IRAP |
---|
1182 | if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1183 | nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) |
---|
1184 | { |
---|
1185 | assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1186 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1187 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1188 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1189 | } |
---|
1190 | } |
---|
1191 | |
---|
1192 | // When a picture is a trailing picture, it shall not be a RADL or RASL picture. |
---|
1193 | if(this->getAssociatedIRAPPOC() < this->getPOC()) |
---|
1194 | { |
---|
1195 | assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && |
---|
1196 | nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && |
---|
1197 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && |
---|
1198 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1199 | } |
---|
1200 | |
---|
1201 | // No RASL pictures shall be present in the bitstream that are associated |
---|
1202 | // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. |
---|
1203 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1204 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1205 | { |
---|
1206 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && |
---|
1207 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); |
---|
1208 | } |
---|
1209 | |
---|
1210 | // No RASL pictures shall be present in the bitstream that are associated with |
---|
1211 | // an IDR picture. |
---|
1212 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1213 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1214 | { |
---|
1215 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && |
---|
1216 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
1217 | } |
---|
1218 | |
---|
1219 | // No RADL pictures shall be present in the bitstream that are associated with |
---|
1220 | // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated |
---|
1221 | // with an IDR picture having nal_unit_type equal to IDR_N_LP. |
---|
1222 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1223 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1224 | { |
---|
1225 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && |
---|
1226 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); |
---|
1227 | } |
---|
1228 | |
---|
1229 | // loop through all pictures in the reference picture buffer |
---|
1230 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1231 | while ( iterPic != rcListPic.end()) |
---|
1232 | { |
---|
1233 | rpcPic = *(iterPic++); |
---|
1234 | #if BUGFIX_INTRAPERIOD |
---|
1235 | if(!rpcPic->getReconMark()) |
---|
1236 | { |
---|
1237 | continue; |
---|
1238 | } |
---|
1239 | #endif |
---|
1240 | if (rpcPic->getPOC() == this->getPOC()) |
---|
1241 | { |
---|
1242 | continue; |
---|
1243 | } |
---|
1244 | |
---|
1245 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1246 | // in decoding order shall precede the IRAP picture in output order. |
---|
1247 | // (Note that any picture following in output order would be present in the DPB) |
---|
1248 | #if !SETTING_NO_OUT_PIC_PRIOR |
---|
1249 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
1250 | #else |
---|
1251 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1 && !this->getNoOutputPriorPicsFlag()) |
---|
1252 | #endif |
---|
1253 | { |
---|
1254 | if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1255 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1256 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1257 | nalUnitType == NAL_UNIT_CODED_SLICE_CRA || |
---|
1258 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1259 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
1260 | { |
---|
1261 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1262 | } |
---|
1263 | } |
---|
1264 | |
---|
1265 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1266 | // in decoding order shall precede any RADL picture associated with the IRAP |
---|
1267 | // picture in output order. |
---|
1268 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
1269 | { |
---|
1270 | if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1271 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) |
---|
1272 | { |
---|
1273 | // rpcPic precedes the IRAP in decoding order |
---|
1274 | if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1275 | { |
---|
1276 | // rpcPic must not be the IRAP picture |
---|
1277 | if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) |
---|
1278 | { |
---|
1279 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1280 | } |
---|
1281 | } |
---|
1282 | } |
---|
1283 | } |
---|
1284 | |
---|
1285 | // When a picture is a leading picture, it shall precede, in decoding order, |
---|
1286 | // all trailing pictures that are associated with the same IRAP picture. |
---|
1287 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1288 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1289 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1290 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1291 | { |
---|
1292 | if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) |
---|
1293 | { |
---|
1294 | // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB |
---|
1295 | // rpcPic would violate the constraint if it was a trailing picture |
---|
1296 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
1297 | } |
---|
1298 | } |
---|
1299 | |
---|
1300 | // Any RASL picture associated with a CRA or BLA picture shall precede any |
---|
1301 | // RADL picture associated with the CRA or BLA picture in output order |
---|
1302 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1303 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1304 | { |
---|
1305 | if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1306 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1307 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1308 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && |
---|
1309 | this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1310 | { |
---|
1311 | if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1312 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1313 | { |
---|
1314 | assert(rpcPic->getPOC() > this->getPOC()); |
---|
1315 | } |
---|
1316 | } |
---|
1317 | } |
---|
1318 | |
---|
1319 | // Any RASL picture associated with a CRA picture shall follow, in output |
---|
1320 | // order, any IRAP picture that precedes the CRA picture in decoding order. |
---|
1321 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1322 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1323 | { |
---|
1324 | if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
1325 | { |
---|
1326 | if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && |
---|
1327 | (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1328 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1329 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1330 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1331 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || |
---|
1332 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) |
---|
1333 | { |
---|
1334 | assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); |
---|
1335 | } |
---|
1336 | } |
---|
1337 | } |
---|
1338 | } |
---|
1339 | } |
---|
1340 | |
---|
1341 | |
---|
1342 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1343 | */ |
---|
1344 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
1345 | { |
---|
1346 | TComPic* rpcPic; |
---|
1347 | Int i, isReference; |
---|
1348 | |
---|
1349 | checkLeadingPictureRestrictions(rcListPic); |
---|
1350 | |
---|
1351 | // loop through all pictures in the reference picture buffer |
---|
1352 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1353 | while ( iterPic != rcListPic.end()) |
---|
1354 | { |
---|
1355 | rpcPic = *(iterPic++); |
---|
1356 | |
---|
1357 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
1358 | { |
---|
1359 | continue; |
---|
1360 | } |
---|
1361 | |
---|
1362 | isReference = 0; |
---|
1363 | // loop through all pictures in the Reference Picture Set |
---|
1364 | // to see if the picture should be kept as reference picture |
---|
1365 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
1366 | { |
---|
1367 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
1368 | { |
---|
1369 | isReference = 1; |
---|
1370 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1371 | rpcPic->setIsLongTerm(0); |
---|
1372 | } |
---|
1373 | } |
---|
1374 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1375 | { |
---|
1376 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1377 | { |
---|
1378 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
1379 | { |
---|
1380 | isReference = 1; |
---|
1381 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1382 | } |
---|
1383 | } |
---|
1384 | else |
---|
1385 | { |
---|
1386 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1387 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1388 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1389 | if(rpcPic->getIsLongTerm() && curPoc == refPoc) |
---|
1390 | { |
---|
1391 | isReference = 1; |
---|
1392 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1393 | } |
---|
1394 | } |
---|
1395 | |
---|
1396 | } |
---|
1397 | #if H_MV |
---|
1398 | if( isReference ) // Current picture is in the temporal RPS |
---|
1399 | { |
---|
1400 | assert( rpcPic->getSlice(0)->getDiscardableFlag() == 0 ); // Temporal RPS shall not contain picture with discardable_flag equal to 1 |
---|
1401 | } |
---|
1402 | #endif |
---|
1403 | // mark the picture as "unused for reference" if it is not in |
---|
1404 | // the Reference Picture Set |
---|
1405 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
1406 | { |
---|
1407 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
1408 | rpcPic->setUsedByCurr(0); |
---|
1409 | rpcPic->setIsLongTerm(0); |
---|
1410 | } |
---|
1411 | //check that pictures of higher temporal layers are not used |
---|
1412 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
1413 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
1414 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
1415 | { |
---|
1416 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
1417 | } |
---|
1418 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
1419 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
1420 | { |
---|
1421 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
1422 | } |
---|
1423 | } |
---|
1424 | } |
---|
1425 | |
---|
1426 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1427 | */ |
---|
1428 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1429 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1430 | #else |
---|
1431 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess) |
---|
1432 | #endif |
---|
1433 | { |
---|
1434 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1435 | Int atLeastOneUnabledByRecoveryPoint = 0; |
---|
1436 | Int atLeastOneFlushedByPreviousIDR = 0; |
---|
1437 | #endif |
---|
1438 | TComPic* rpcPic; |
---|
1439 | Int i, isAvailable; |
---|
1440 | Int atLeastOneLost = 0; |
---|
1441 | Int atLeastOneRemoved = 0; |
---|
1442 | Int iPocLost = 0; |
---|
1443 | |
---|
1444 | // loop through all long-term pictures in the Reference Picture Set |
---|
1445 | // to see if the picture should be kept as reference picture |
---|
1446 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1447 | { |
---|
1448 | isAvailable = 0; |
---|
1449 | // loop through all pictures in the reference picture buffer |
---|
1450 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1451 | while ( iterPic != rcListPic.end()) |
---|
1452 | { |
---|
1453 | rpcPic = *(iterPic++); |
---|
1454 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1455 | { |
---|
1456 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1457 | { |
---|
1458 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1459 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1460 | { |
---|
1461 | isAvailable = 0; |
---|
1462 | } |
---|
1463 | else |
---|
1464 | { |
---|
1465 | isAvailable = 1; |
---|
1466 | } |
---|
1467 | #else |
---|
1468 | isAvailable = 1; |
---|
1469 | #endif |
---|
1470 | } |
---|
1471 | } |
---|
1472 | else |
---|
1473 | { |
---|
1474 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1475 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1476 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1477 | if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) |
---|
1478 | { |
---|
1479 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1480 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1481 | { |
---|
1482 | isAvailable = 0; |
---|
1483 | } |
---|
1484 | else |
---|
1485 | { |
---|
1486 | isAvailable = 1; |
---|
1487 | } |
---|
1488 | #else |
---|
1489 | isAvailable = 1; |
---|
1490 | #endif |
---|
1491 | } |
---|
1492 | } |
---|
1493 | } |
---|
1494 | // if there was no such long-term check the short terms |
---|
1495 | if(!isAvailable) |
---|
1496 | { |
---|
1497 | iterPic = rcListPic.begin(); |
---|
1498 | while ( iterPic != rcListPic.end()) |
---|
1499 | { |
---|
1500 | rpcPic = *(iterPic++); |
---|
1501 | |
---|
1502 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1503 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
1504 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
1505 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
1506 | { |
---|
1507 | curPoc = curPoc & (pocCycle - 1); |
---|
1508 | refPoc = refPoc & (pocCycle - 1); |
---|
1509 | } |
---|
1510 | |
---|
1511 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
1512 | { |
---|
1513 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1514 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1515 | { |
---|
1516 | isAvailable = 0; |
---|
1517 | } |
---|
1518 | else |
---|
1519 | { |
---|
1520 | isAvailable = 1; |
---|
1521 | rpcPic->setIsLongTerm(1); |
---|
1522 | break; |
---|
1523 | } |
---|
1524 | #else |
---|
1525 | isAvailable = 1; |
---|
1526 | rpcPic->setIsLongTerm(1); |
---|
1527 | break; |
---|
1528 | #endif |
---|
1529 | } |
---|
1530 | } |
---|
1531 | } |
---|
1532 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1533 | // but not available as reference picture |
---|
1534 | if(isAvailable == 0) |
---|
1535 | { |
---|
1536 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1537 | { |
---|
1538 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1539 | { |
---|
1540 | if(printErrors) |
---|
1541 | { |
---|
1542 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1543 | } |
---|
1544 | atLeastOneRemoved = 1; |
---|
1545 | } |
---|
1546 | else |
---|
1547 | { |
---|
1548 | if(printErrors) |
---|
1549 | { |
---|
1550 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1551 | } |
---|
1552 | atLeastOneLost = 1; |
---|
1553 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1554 | } |
---|
1555 | } |
---|
1556 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1557 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1558 | { |
---|
1559 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1560 | } |
---|
1561 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1562 | { |
---|
1563 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1564 | } |
---|
1565 | #endif |
---|
1566 | } |
---|
1567 | } |
---|
1568 | // loop through all short-term pictures in the Reference Picture Set |
---|
1569 | // to see if the picture should be kept as reference picture |
---|
1570 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
1571 | { |
---|
1572 | isAvailable = 0; |
---|
1573 | // loop through all pictures in the reference picture buffer |
---|
1574 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1575 | while ( iterPic != rcListPic.end()) |
---|
1576 | { |
---|
1577 | rpcPic = *(iterPic++); |
---|
1578 | |
---|
1579 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1580 | { |
---|
1581 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1582 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1583 | { |
---|
1584 | isAvailable = 0; |
---|
1585 | } |
---|
1586 | else |
---|
1587 | { |
---|
1588 | isAvailable = 1; |
---|
1589 | } |
---|
1590 | #else |
---|
1591 | isAvailable = 1; |
---|
1592 | #endif |
---|
1593 | } |
---|
1594 | } |
---|
1595 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1596 | // but not available as reference picture |
---|
1597 | if(isAvailable == 0) |
---|
1598 | { |
---|
1599 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1600 | { |
---|
1601 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1602 | { |
---|
1603 | if(printErrors) |
---|
1604 | { |
---|
1605 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1606 | } |
---|
1607 | atLeastOneRemoved = 1; |
---|
1608 | } |
---|
1609 | else |
---|
1610 | { |
---|
1611 | if(printErrors) |
---|
1612 | { |
---|
1613 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1614 | } |
---|
1615 | atLeastOneLost = 1; |
---|
1616 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1617 | } |
---|
1618 | } |
---|
1619 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1620 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1621 | { |
---|
1622 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1623 | } |
---|
1624 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1625 | { |
---|
1626 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1627 | } |
---|
1628 | #endif |
---|
1629 | } |
---|
1630 | } |
---|
1631 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1632 | if(atLeastOneUnabledByRecoveryPoint || atLeastOneFlushedByPreviousIDR) |
---|
1633 | { |
---|
1634 | return -1; |
---|
1635 | } |
---|
1636 | #endif |
---|
1637 | if(atLeastOneLost) |
---|
1638 | { |
---|
1639 | return iPocLost+1; |
---|
1640 | } |
---|
1641 | if(atLeastOneRemoved) |
---|
1642 | { |
---|
1643 | return -2; |
---|
1644 | } |
---|
1645 | else |
---|
1646 | { |
---|
1647 | return 0; |
---|
1648 | } |
---|
1649 | } |
---|
1650 | |
---|
1651 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
1652 | */ |
---|
1653 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1654 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1655 | #else |
---|
1656 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP) |
---|
1657 | #endif |
---|
1658 | { |
---|
1659 | TComPic* rpcPic; |
---|
1660 | Int i, j; |
---|
1661 | Int k = 0; |
---|
1662 | Int nrOfNegativePictures = 0; |
---|
1663 | Int nrOfPositivePictures = 0; |
---|
1664 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
1665 | |
---|
1666 | // loop through all pictures in the Reference Picture Set |
---|
1667 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1668 | { |
---|
1669 | j = 0; |
---|
1670 | // loop through all pictures in the reference picture buffer |
---|
1671 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1672 | while ( iterPic != rcListPic.end()) |
---|
1673 | { |
---|
1674 | j++; |
---|
1675 | rpcPic = *(iterPic++); |
---|
1676 | |
---|
1677 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1678 | { |
---|
1679 | // This picture exists as a reference picture |
---|
1680 | // and should be added to the explicit Reference Picture Set |
---|
1681 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
1682 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); |
---|
1683 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1684 | pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) ); |
---|
1685 | #endif |
---|
1686 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
1687 | { |
---|
1688 | nrOfNegativePictures++; |
---|
1689 | } |
---|
1690 | else |
---|
1691 | { |
---|
1692 | nrOfPositivePictures++; |
---|
1693 | } |
---|
1694 | k++; |
---|
1695 | } |
---|
1696 | } |
---|
1697 | } |
---|
1698 | #if EFFICIENT_FIELD_IRAP |
---|
1699 | Bool useNewRPS = false; |
---|
1700 | // if current picture is complimentary field associated to IRAP, add the IRAP to its RPS. |
---|
1701 | if(m_pcPic->isField()) |
---|
1702 | { |
---|
1703 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1704 | while ( iterPic != rcListPic.end()) |
---|
1705 | { |
---|
1706 | rpcPic = *(iterPic++); |
---|
1707 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
1708 | { |
---|
1709 | pcRPS->setDeltaPOC(k, 1); |
---|
1710 | pcRPS->setUsed(k, true); |
---|
1711 | nrOfPositivePictures++; |
---|
1712 | k ++; |
---|
1713 | useNewRPS = true; |
---|
1714 | } |
---|
1715 | } |
---|
1716 | } |
---|
1717 | #endif |
---|
1718 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
1719 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
1720 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
1721 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
1722 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
1723 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
1724 | if (!pReferencePictureSet->getInterRPSPrediction() |
---|
1725 | #if EFFICIENT_FIELD_IRAP |
---|
1726 | || useNewRPS |
---|
1727 | #endif |
---|
1728 | ) |
---|
1729 | { |
---|
1730 | pcRPS->setInterRPSPrediction(false); |
---|
1731 | pcRPS->setNumRefIdc(0); |
---|
1732 | } |
---|
1733 | else |
---|
1734 | { |
---|
1735 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
1736 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
1737 | TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
1738 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
1739 | Int iNewIdc=0; |
---|
1740 | for(i=0; i<= iRefPics; i++) |
---|
1741 | { |
---|
1742 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
1743 | Int iRefIdc = 0; |
---|
1744 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
1745 | { |
---|
1746 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
1747 | { |
---|
1748 | if (pcRPS->getUsed(j)) |
---|
1749 | { |
---|
1750 | iRefIdc = 1; |
---|
1751 | } |
---|
1752 | else |
---|
1753 | { |
---|
1754 | iRefIdc = 2; |
---|
1755 | } |
---|
1756 | } |
---|
1757 | } |
---|
1758 | pcRPS->setRefIdc(i, iRefIdc); |
---|
1759 | iNewIdc++; |
---|
1760 | } |
---|
1761 | pcRPS->setInterRPSPrediction(true); |
---|
1762 | pcRPS->setNumRefIdc(iNewIdc); |
---|
1763 | pcRPS->setDeltaRPS(deltaRPS); |
---|
1764 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
1765 | } |
---|
1766 | |
---|
1767 | this->setRPS(pcRPS); |
---|
1768 | this->setRPSidx(-1); |
---|
1769 | } |
---|
1770 | |
---|
1771 | /** get AC and DC values for weighted pred |
---|
1772 | * \param *wp |
---|
1773 | * \returns Void |
---|
1774 | */ |
---|
1775 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
1776 | { |
---|
1777 | wp = m_weightACDCParam; |
---|
1778 | } |
---|
1779 | |
---|
1780 | /** init AC and DC values for weighted pred |
---|
1781 | * \returns Void |
---|
1782 | */ |
---|
1783 | Void TComSlice::initWpAcDcParam() |
---|
1784 | { |
---|
1785 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
1786 | { |
---|
1787 | m_weightACDCParam[iComp].iAC = 0; |
---|
1788 | m_weightACDCParam[iComp].iDC = 0; |
---|
1789 | } |
---|
1790 | } |
---|
1791 | |
---|
1792 | /** get WP tables for weighted pred |
---|
1793 | * \param RefPicList |
---|
1794 | * \param iRefIdx |
---|
1795 | * \param *&wpScalingParam |
---|
1796 | * \returns Void |
---|
1797 | */ |
---|
1798 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
1799 | { |
---|
1800 | wp = m_weightPredTable[e][iRefIdx]; |
---|
1801 | } |
---|
1802 | |
---|
1803 | /** reset Default WP tables settings : no weight. |
---|
1804 | * \param wpScalingParam |
---|
1805 | * \returns Void |
---|
1806 | */ |
---|
1807 | Void TComSlice::resetWpScaling() |
---|
1808 | { |
---|
1809 | for ( Int e=0 ; e<2 ; e++ ) |
---|
1810 | { |
---|
1811 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1812 | { |
---|
1813 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
1814 | { |
---|
1815 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1816 | pwp->bPresentFlag = false; |
---|
1817 | pwp->uiLog2WeightDenom = 0; |
---|
1818 | pwp->uiLog2WeightDenom = 0; |
---|
1819 | pwp->iWeight = 1; |
---|
1820 | pwp->iOffset = 0; |
---|
1821 | } |
---|
1822 | } |
---|
1823 | } |
---|
1824 | } |
---|
1825 | |
---|
1826 | /** init WP table |
---|
1827 | * \returns Void |
---|
1828 | */ |
---|
1829 | Void TComSlice::initWpScaling() |
---|
1830 | { |
---|
1831 | for ( Int e=0 ; e<2 ; e++ ) |
---|
1832 | { |
---|
1833 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1834 | { |
---|
1835 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
1836 | { |
---|
1837 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1838 | if ( !pwp->bPresentFlag ) |
---|
1839 | { |
---|
1840 | // Inferring values not present : |
---|
1841 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
1842 | pwp->iOffset = 0; |
---|
1843 | } |
---|
1844 | |
---|
1845 | pwp->w = pwp->iWeight; |
---|
1846 | Int bitDepth = yuv ? g_bitDepthC : g_bitDepthY; |
---|
1847 | pwp->o = pwp->iOffset << (bitDepth-8); |
---|
1848 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
1849 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
1850 | } |
---|
1851 | } |
---|
1852 | } |
---|
1853 | } |
---|
1854 | |
---|
1855 | // ------------------------------------------------------------------------------------------------ |
---|
1856 | // Video parameter set (VPS) |
---|
1857 | // ------------------------------------------------------------------------------------------------ |
---|
1858 | TComVPS::TComVPS() |
---|
1859 | : m_VPSId ( 0) |
---|
1860 | , m_uiMaxTLayers ( 1) |
---|
1861 | #if H_MV |
---|
1862 | , m_uiMaxLayersMinus1 ( 0) |
---|
1863 | #else |
---|
1864 | , m_uiMaxLayers ( 1) |
---|
1865 | #endif |
---|
1866 | , m_bTemporalIdNestingFlag (false) |
---|
1867 | , m_numHrdParameters ( 0) |
---|
1868 | #if H_MV |
---|
1869 | , m_maxLayerId ( 0) |
---|
1870 | #else |
---|
1871 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
1872 | #endif |
---|
1873 | , m_hrdParameters (NULL) |
---|
1874 | , m_hrdOpSetIdx (NULL) |
---|
1875 | , m_cprmsPresentFlag (NULL) |
---|
1876 | #if H_MV |
---|
1877 | , m_dpbSize (NULL) |
---|
1878 | , m_vpsVUI ( NULL ) |
---|
1879 | #endif |
---|
1880 | { |
---|
1881 | #if H_MV |
---|
1882 | m_vpsBaseLayerInternalFlag = true; |
---|
1883 | #if H_MV_HLS10_GEN_VSP_BASE_LAYER_AVAIL |
---|
1884 | m_vpsBaseLayerAvailableFlag = true; |
---|
1885 | #endif |
---|
1886 | #endif |
---|
1887 | |
---|
1888 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
1889 | { |
---|
1890 | m_numReorderPics[i] = 0; |
---|
1891 | m_uiMaxDecPicBuffering[i] = 1; |
---|
1892 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1893 | } |
---|
1894 | #if H_MV |
---|
1895 | for (Int lsIdx = 0; lsIdx < MAX_VPS_OP_SETS_PLUS1; lsIdx++ ) |
---|
1896 | { |
---|
1897 | for( Int layerId = 0; layerId < MAX_VPS_NUH_LAYER_ID_PLUS1; layerId++ ) |
---|
1898 | { |
---|
1899 | m_layerIdIncludedFlag[lsIdx][layerId] = (( lsIdx == 0 ) && ( layerId == 0 )) ; |
---|
1900 | } |
---|
1901 | } |
---|
1902 | m_vpsNumProfileTierLevelMinus1 = -1; |
---|
1903 | |
---|
1904 | m_numAddLayerSets = 0; |
---|
1905 | m_numAddOlss = 0; |
---|
1906 | m_defaultOutputLayerIdc = 0; |
---|
1907 | |
---|
1908 | for ( Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++) |
---|
1909 | { |
---|
1910 | m_layerSetIdxForOlsMinus1[i] = -1; |
---|
1911 | #if !H_MV_HLS10_PTL |
---|
1912 | m_profileLevelTierIdx[i] = 0; |
---|
1913 | #endif |
---|
1914 | for ( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++) |
---|
1915 | { |
---|
1916 | #if H_MV_HLS10_PTL |
---|
1917 | #if H_MV_HLS10_PTL_FIX |
---|
1918 | m_profileTierLevelIdx[i][j] = -1; |
---|
1919 | #else |
---|
1920 | m_profileTierLevelIdx[i][j] = false; |
---|
1921 | #endif |
---|
1922 | #endif |
---|
1923 | m_outputLayerFlag[i][j] = false; |
---|
1924 | } |
---|
1925 | m_altOutputLayerFlag[ i ] = false; |
---|
1926 | } |
---|
1927 | |
---|
1928 | m_repFormatIdxPresentFlag = false; |
---|
1929 | m_maxOneActiveRefLayerFlag = false; |
---|
1930 | m_directDepTypeLenMinus2 = 0; |
---|
1931 | |
---|
1932 | |
---|
1933 | m_vpsExtensionFlag = true; |
---|
1934 | m_vpsNonVuiExtensionLength = 0; |
---|
1935 | m_splittingFlag = false; |
---|
1936 | |
---|
1937 | for( Int i = 0; i < MAX_NUM_SCALABILITY_TYPES; i++ ) |
---|
1938 | { |
---|
1939 | m_scalabilityMaskFlag[i] = false; |
---|
1940 | m_dimensionIdLen [i] = -1; |
---|
1941 | } |
---|
1942 | |
---|
1943 | m_vpsNuhLayerIdPresentFlag = false; |
---|
1944 | |
---|
1945 | for( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++ ) |
---|
1946 | { |
---|
1947 | m_vpsProfilePresentFlag [i] = false; |
---|
1948 | m_layerSetIdxForOlsMinus1 [i] = 0; |
---|
1949 | for( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++ ) |
---|
1950 | { |
---|
1951 | m_outputLayerFlag[i][j] = false; |
---|
1952 | } |
---|
1953 | } |
---|
1954 | |
---|
1955 | for( Int i = 0; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
1956 | { |
---|
1957 | m_layerIdInVps[i] = (i == 0 ) ? 0 : -1; |
---|
1958 | } |
---|
1959 | |
---|
1960 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
1961 | { |
---|
1962 | m_layerIdInNuh [i] = ( i == 0 ) ? 0 : -1; |
---|
1963 | m_numDirectRefLayers[i] = 0; |
---|
1964 | m_vpsRepFormatIdx [i] = 0; |
---|
1965 | m_pocLsbNotPresentFlag[i] = 0; |
---|
1966 | m_repFormat [i] = NULL; |
---|
1967 | m_viewIdVal [i] = 0; |
---|
1968 | |
---|
1969 | #if H_3D |
---|
1970 | m_viewIndex [i] = -1; |
---|
1971 | m_vpsDepthModesFlag [i] = false; |
---|
1972 | #if SEC_HLS_CLEANUP_I0100 |
---|
1973 | m_ivMvScalingFlag[i] = true; |
---|
1974 | #else |
---|
1975 | m_ivMvScalingFlag = true; |
---|
1976 | #endif |
---|
1977 | #if SEPARATE_FLAG_I0085 |
---|
1978 | m_bIVPFlag [i] = false; |
---|
1979 | #endif |
---|
1980 | #endif |
---|
1981 | |
---|
1982 | for( Int j = 0; j < MAX_NUM_LAYERS; j++ ) |
---|
1983 | { |
---|
1984 | m_directDependencyFlag[i][j] = false; |
---|
1985 | m_directDependencyType[i][j] = -1; |
---|
1986 | #if H_MV_HLS10_REF_PRED_LAYERS |
---|
1987 | m_dependencyFlag [i][j] = false; |
---|
1988 | m_idDirectRefLayer[i][j] = -1; |
---|
1989 | m_idPredictedLayer[i][j] = -1; |
---|
1990 | m_idRefLayer [i][j] = -1; |
---|
1991 | #else |
---|
1992 | m_refLayerId[i][j] = -1; |
---|
1993 | #endif |
---|
1994 | m_maxTidIlRefPicsPlus1[i][j] = 7; |
---|
1995 | } |
---|
1996 | |
---|
1997 | for( Int j = 0; j < MAX_NUM_SCALABILITY_TYPES; j++ ) |
---|
1998 | { |
---|
1999 | m_dimensionId[i][j] = 0; |
---|
2000 | } |
---|
2001 | #if H_3D_ARP |
---|
2002 | m_uiUseAdvResPred[i] = 0; |
---|
2003 | m_uiARPStepNum[i] = 1; |
---|
2004 | #endif |
---|
2005 | } |
---|
2006 | m_vpsVUI = new TComVPSVUI; |
---|
2007 | m_dpbSize = new TComDpbSize; |
---|
2008 | |
---|
2009 | #if H_3D |
---|
2010 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
2011 | { |
---|
2012 | #if H_3D_IV_MERGE |
---|
2013 | m_ivMvPredFlag [ i ] = false; |
---|
2014 | #if H_3D_SPIVMP |
---|
2015 | m_iSubPULog2Size [ i ] = 0; |
---|
2016 | #endif |
---|
2017 | #endif |
---|
2018 | #if MTK_I0099_VPS_EX2 |
---|
2019 | m_bLimQtPredFlag [ i ] = false; |
---|
2020 | #endif |
---|
2021 | #if H_3D_VSP |
---|
2022 | m_viewSynthesisPredFlag[ i ] = false; |
---|
2023 | #endif |
---|
2024 | #if H_3D_NBDV_REF |
---|
2025 | m_depthRefinementFlag [ i ] = false; |
---|
2026 | #endif |
---|
2027 | #if H_3D_INTER_SDC |
---|
2028 | m_bInterSDCFlag [ i ] = false; |
---|
2029 | #endif |
---|
2030 | #if SEPARATE_FLAG_I0085 |
---|
2031 | m_bIVPFlag [ i ] = false; |
---|
2032 | #endif |
---|
2033 | #if H_3D_DBBP |
---|
2034 | m_dbbpFlag [ i ] = false; |
---|
2035 | #endif |
---|
2036 | #if H_3D_IV_MERGE |
---|
2037 | m_bMPIFlag [ i ] = false; |
---|
2038 | #endif |
---|
2039 | } |
---|
2040 | #endif |
---|
2041 | #endif |
---|
2042 | } |
---|
2043 | |
---|
2044 | TComVPS::~TComVPS() |
---|
2045 | { |
---|
2046 | if( m_hrdParameters != NULL ) delete[] m_hrdParameters; |
---|
2047 | if( m_hrdOpSetIdx != NULL ) delete[] m_hrdOpSetIdx; |
---|
2048 | if( m_cprmsPresentFlag != NULL ) delete[] m_cprmsPresentFlag; |
---|
2049 | #if H_MV |
---|
2050 | if ( m_vpsVUI != NULL ) delete m_vpsVUI; |
---|
2051 | if ( m_dpbSize != NULL ) delete m_dpbSize; |
---|
2052 | |
---|
2053 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
2054 | { |
---|
2055 | if (m_repFormat[ i ] != NULL ) delete m_repFormat[ i ]; |
---|
2056 | } |
---|
2057 | #endif |
---|
2058 | #if H_3D |
---|
2059 | deleteCamPars(); |
---|
2060 | #endif |
---|
2061 | } |
---|
2062 | |
---|
2063 | #if H_MV |
---|
2064 | |
---|
2065 | Bool TComVPS::checkVPSExtensionSyntax() |
---|
2066 | { |
---|
2067 | for( Int layer = 1; layer <= getMaxLayersMinus1(); layer++ ) |
---|
2068 | { |
---|
2069 | // check layer_id_in_nuh constraint |
---|
2070 | assert( getLayerIdInNuh( layer ) > getLayerIdInNuh( layer -1 ) ); |
---|
2071 | } |
---|
2072 | |
---|
2073 | //The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
2074 | assert( getVpsNumRepFormatsMinus1() >= 0 ); |
---|
2075 | assert( getVpsNumRepFormatsMinus1() <= 255 ); |
---|
2076 | |
---|
2077 | #if H_MV_HLS10_ADD_LAYERSETS |
---|
2078 | // The value of num_add_layer_sets shall be in the range of 0 to 1023, inclusive. |
---|
2079 | assert( getNumAddLayerSets() >= 0 && getNumAddLayerSets() <= 1023 ); |
---|
2080 | #endif |
---|
2081 | return true; |
---|
2082 | } |
---|
2083 | |
---|
2084 | Int TComVPS::getNumScalabilityTypes() |
---|
2085 | { |
---|
2086 | return scalTypeToScalIdx( ScalabilityType(MAX_NUM_SCALABILITY_TYPES) ); |
---|
2087 | } |
---|
2088 | |
---|
2089 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) |
---|
2090 | { |
---|
2091 | assert( scalType >= 0 && scalType <= MAX_NUM_SCALABILITY_TYPES ); |
---|
2092 | assert( scalType == MAX_NUM_SCALABILITY_TYPES || getScalabilityMaskFlag( scalType ) ); |
---|
2093 | Int scalIdx = 0; |
---|
2094 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
2095 | { |
---|
2096 | scalIdx += ( getScalabilityMaskFlag( curScalType ) ? 1 : 0 ); |
---|
2097 | |
---|
2098 | } |
---|
2099 | |
---|
2100 | return scalIdx; |
---|
2101 | } |
---|
2102 | Void TComVPS::setScalabilityMaskFlag( UInt val ) |
---|
2103 | { |
---|
2104 | for ( Int scalType = 0; scalType < MAX_NUM_SCALABILITY_TYPES; scalType++ ) |
---|
2105 | { |
---|
2106 | setScalabilityMaskFlag( scalType, ( val & (1 << scalType ) ) != 0 ); |
---|
2107 | } |
---|
2108 | } |
---|
2109 | |
---|
2110 | Void TComVPS::setRefLayers() |
---|
2111 | { |
---|
2112 | |
---|
2113 | #if H_MV_HLS10_REF_PRED_LAYERS |
---|
2114 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2115 | { |
---|
2116 | for( Int j = 0; j <= getMaxLayersMinus1(); j++ ) |
---|
2117 | { |
---|
2118 | m_dependencyFlag[ i ][ j ] = getDirectDependencyFlag( i , j ); |
---|
2119 | for( Int k = 0; k < i; k++ ) |
---|
2120 | { |
---|
2121 | if( getDirectDependencyFlag(i , k ) && m_dependencyFlag[k][j] ) |
---|
2122 | { |
---|
2123 | m_dependencyFlag[ i ][ j ] = true; |
---|
2124 | } |
---|
2125 | } |
---|
2126 | } |
---|
2127 | } |
---|
2128 | |
---|
2129 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2130 | { |
---|
2131 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2132 | Int d = 0; |
---|
2133 | Int r = 0; |
---|
2134 | Int p = 0; |
---|
2135 | for( Int j = 0; j <= getMaxLayersMinus1(); j++ ) |
---|
2136 | { |
---|
2137 | Int jNuhLid = getLayerIdInNuh( j ); |
---|
2138 | if( getDirectDependencyFlag( i , j ) ) |
---|
2139 | { |
---|
2140 | m_idDirectRefLayer[iNuhLId][d++] = jNuhLid; |
---|
2141 | } |
---|
2142 | if( getDependencyFlag( i , j ) ) |
---|
2143 | { |
---|
2144 | m_idRefLayer [iNuhLId][r++] = jNuhLid; |
---|
2145 | } |
---|
2146 | if( getDependencyFlag( j , i ) ) |
---|
2147 | { |
---|
2148 | m_idPredictedLayer[iNuhLId][p++] = jNuhLid; |
---|
2149 | } |
---|
2150 | } |
---|
2151 | m_numDirectRefLayers[ iNuhLId ] = d; |
---|
2152 | m_numRefLayers [ iNuhLId ] = r; |
---|
2153 | m_numPredictedLayers[ iNuhLId ] = p; |
---|
2154 | } |
---|
2155 | |
---|
2156 | Bool layerIdInListFlag[ 64 ]; |
---|
2157 | for( Int i = 0; i <= 63; i++ ) |
---|
2158 | { |
---|
2159 | layerIdInListFlag[ i ] = 0; |
---|
2160 | } |
---|
2161 | |
---|
2162 | Int k = 0; |
---|
2163 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2164 | { |
---|
2165 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2166 | if( getNumDirectRefLayers( iNuhLId ) == 0 ) |
---|
2167 | { |
---|
2168 | m_treePartitionLayerIdList[ k ][ 0 ] = iNuhLId; |
---|
2169 | Int h = 1; |
---|
2170 | for( Int j = 0; j < getNumPredictedLayers( iNuhLId ); j++ ) |
---|
2171 | { |
---|
2172 | Int predLId = getIdPredictedLayer( iNuhLId, j ); |
---|
2173 | if ( !layerIdInListFlag[ predLId ] ) |
---|
2174 | { |
---|
2175 | m_treePartitionLayerIdList[ k ][ h++ ] = predLId; |
---|
2176 | layerIdInListFlag[ predLId ] = 1; |
---|
2177 | } |
---|
2178 | } |
---|
2179 | m_numLayersInTreePartition[ k++ ] = h; |
---|
2180 | } |
---|
2181 | } |
---|
2182 | m_numIndependentLayers = k; |
---|
2183 | #else // H_MV_HLS10_GEN |
---|
2184 | |
---|
2185 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2186 | { |
---|
2187 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2188 | m_numDirectRefLayers[ iNuhLId ] = 0; |
---|
2189 | for( Int j = 0; j < i; j++ ) |
---|
2190 | { |
---|
2191 | if( getDirectDependencyFlag(i , j) ) |
---|
2192 | { |
---|
2193 | m_refLayerId[ iNuhLId ][m_numDirectRefLayers[ iNuhLId ]++ ] = getLayerIdInNuh( j ); |
---|
2194 | } |
---|
2195 | } |
---|
2196 | } |
---|
2197 | |
---|
2198 | for (Int i = 0 ; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
2199 | { |
---|
2200 | m_numRefLayers[i] = 0; |
---|
2201 | } |
---|
2202 | |
---|
2203 | for (Int currLayerId = 0; currLayerId <= 62; currLayerId++ ) |
---|
2204 | { |
---|
2205 | for (Int i = 0 ; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
2206 | { |
---|
2207 | m_recursiveRefLayerFlag[currLayerId][i] = 0; |
---|
2208 | } |
---|
2209 | } |
---|
2210 | |
---|
2211 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2212 | { |
---|
2213 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2214 | xSetRefLayerFlags( iNuhLId ); |
---|
2215 | for( Int j = 0; j < 63; j++ ) |
---|
2216 | { |
---|
2217 | m_numRefLayers[ iNuhLId ] += m_recursiveRefLayerFlag[ iNuhLId ][ j ]; |
---|
2218 | } |
---|
2219 | } |
---|
2220 | |
---|
2221 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) // Bug in spec "<" instead of "<=" |
---|
2222 | { |
---|
2223 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2224 | Int predIdx = 0; |
---|
2225 | for( Int j = iNuhLId + 1; j < 63; j++ ) |
---|
2226 | { |
---|
2227 | if( m_recursiveRefLayerFlag[ j ][ iNuhLId ] ) |
---|
2228 | { |
---|
2229 | m_predictedLayerId[ iNuhLId ][ predIdx++ ] = j; |
---|
2230 | } |
---|
2231 | } |
---|
2232 | m_numPredictedLayers[ iNuhLId ] = predIdx; |
---|
2233 | } |
---|
2234 | |
---|
2235 | Bool countedLayerIdxFlag[ MAX_NUM_LAYERS ]; |
---|
2236 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2237 | { |
---|
2238 | countedLayerIdxFlag[ i ] = 0; |
---|
2239 | } |
---|
2240 | for( Int i = 0, k = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2241 | { |
---|
2242 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2243 | if( m_numDirectRefLayers[ iNuhLId ] == 0 ) |
---|
2244 | { |
---|
2245 | m_treePartitionLayerIdList[ k ][ 0 ] = iNuhLId; |
---|
2246 | m_numLayersInTreePartition[ k ] = 1; |
---|
2247 | |
---|
2248 | for( Int j = 0; j < m_numPredictedLayers[ iNuhLId ]; j++ ) |
---|
2249 | { |
---|
2250 | if( !countedLayerIdxFlag[ getLayerIdInVps( m_predictedLayerId[ iNuhLId ][ j ] ) ] ) |
---|
2251 | { |
---|
2252 | m_treePartitionLayerIdList[ k ][ m_numLayersInTreePartition[ k ] ] = m_predictedLayerId[ iNuhLId ][ j ]; |
---|
2253 | m_numLayersInTreePartition[ k ]++; |
---|
2254 | countedLayerIdxFlag[ getLayerIdInVps( m_predictedLayerId[ iNuhLId ][ j ] ) ] = 1; |
---|
2255 | } |
---|
2256 | } |
---|
2257 | k++; |
---|
2258 | |
---|
2259 | m_numIndependentLayers = k; |
---|
2260 | } |
---|
2261 | } |
---|
2262 | #endif // H_MV_HLS10_GEN |
---|
2263 | } |
---|
2264 | |
---|
2265 | #if !H_MV_HLS10_REF_PRED_LAYERS |
---|
2266 | Int TComVPS::getRefLayerId( Int layerIdInNuh, Int idx ) |
---|
2267 | { |
---|
2268 | assert( idx >= 0 && idx < m_numDirectRefLayers[layerIdInNuh] ); |
---|
2269 | Int refLayerIdInNuh = m_refLayerId[ layerIdInNuh ][ idx ]; |
---|
2270 | assert ( refLayerIdInNuh >= 0 ); |
---|
2271 | return refLayerIdInNuh; |
---|
2272 | } |
---|
2273 | #endif |
---|
2274 | |
---|
2275 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) |
---|
2276 | { |
---|
2277 | return getScalabilityMaskFlag( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
2278 | } |
---|
2279 | |
---|
2280 | #if H_3D |
---|
2281 | Int TComVPS::getLayerIdInNuh( Int viewIndex, Bool depthFlag ) |
---|
2282 | { |
---|
2283 | Int foundLayerIdinNuh = -1; |
---|
2284 | |
---|
2285 | for (Int layerIdInVps = 0 ; layerIdInVps <= getMaxLayersMinus1(); layerIdInVps++ ) |
---|
2286 | { |
---|
2287 | Int layerIdInNuh = getLayerIdInNuh( layerIdInVps ); |
---|
2288 | if( ( getViewIndex( layerIdInNuh ) == viewIndex ) && ( getDepthId( layerIdInNuh ) == ( depthFlag ? 1 : 0 ) ) ) |
---|
2289 | { |
---|
2290 | foundLayerIdinNuh = layerIdInNuh; |
---|
2291 | break; |
---|
2292 | } |
---|
2293 | } |
---|
2294 | #if !BUG_FIX_TK65 |
---|
2295 | assert( foundLayerIdinNuh != -1 ); |
---|
2296 | #endif |
---|
2297 | return foundLayerIdinNuh; |
---|
2298 | } |
---|
2299 | |
---|
2300 | Void TComVPS::createCamPars(Int iNumViews) |
---|
2301 | { |
---|
2302 | Int i = 0, j = 0; |
---|
2303 | |
---|
2304 | m_bCamParPresent = new Bool[ iNumViews ]; |
---|
2305 | m_bCamParInSliceHeader = new Bool[ iNumViews ]; |
---|
2306 | |
---|
2307 | m_aaaiCodedScale = new Int**[ iNumViews ]; |
---|
2308 | m_aaaiCodedOffset = new Int**[ iNumViews ]; |
---|
2309 | for ( i = 0; i < iNumViews ; i++ ) |
---|
2310 | { |
---|
2311 | #if H_3D_FIX_UNINIT |
---|
2312 | m_bCamParPresent[i] = false; |
---|
2313 | #endif |
---|
2314 | m_bCamParInSliceHeader[i] = false; |
---|
2315 | m_aaaiCodedScale[i] = new Int*[ 2 ]; |
---|
2316 | m_aaaiCodedOffset[i] = new Int*[ 2 ]; |
---|
2317 | for ( j = 0; j < 2; j++ ) |
---|
2318 | { |
---|
2319 | m_aaaiCodedScale[i][j] = new Int[ MAX_NUM_LAYERS ]; |
---|
2320 | m_aaaiCodedOffset[i][j] = new Int[ MAX_NUM_LAYERS ]; |
---|
2321 | for ( Int k = 0; k < MAX_NUM_LAYERS; k++ ) |
---|
2322 | { |
---|
2323 | m_aaaiCodedScale[i][j][k] = 0; |
---|
2324 | m_aaaiCodedOffset[i][j][k] = 0; |
---|
2325 | } |
---|
2326 | } |
---|
2327 | } |
---|
2328 | } |
---|
2329 | |
---|
2330 | Void TComVPS::deleteCamPars() |
---|
2331 | { |
---|
2332 | Int iNumViews = getNumViews(); |
---|
2333 | Int i = 0, j = 0; |
---|
2334 | |
---|
2335 | if ( m_bCamParPresent != NULL ) |
---|
2336 | { |
---|
2337 | delete [] m_bCamParPresent; |
---|
2338 | } |
---|
2339 | if ( m_bCamParInSliceHeader != NULL ) |
---|
2340 | { |
---|
2341 | delete [] m_bCamParInSliceHeader; |
---|
2342 | } |
---|
2343 | |
---|
2344 | if ( m_aaaiCodedScale != NULL ) |
---|
2345 | { |
---|
2346 | for ( i = 0; i < iNumViews ; i++ ) |
---|
2347 | { |
---|
2348 | for ( j = 0; j < 2; j++ ) |
---|
2349 | { |
---|
2350 | delete [] m_aaaiCodedScale[i][j]; |
---|
2351 | } |
---|
2352 | delete [] m_aaaiCodedScale[i]; |
---|
2353 | } |
---|
2354 | delete [] m_aaaiCodedScale; |
---|
2355 | } |
---|
2356 | |
---|
2357 | if ( m_aaaiCodedOffset != NULL ) |
---|
2358 | { |
---|
2359 | for ( i = 0; i < iNumViews ; i++ ) |
---|
2360 | { |
---|
2361 | for ( j = 0; j < 2; j++ ) |
---|
2362 | { |
---|
2363 | delete [] m_aaaiCodedOffset[i][j]; |
---|
2364 | } |
---|
2365 | delete [] m_aaaiCodedOffset[i]; |
---|
2366 | } |
---|
2367 | delete [] m_aaaiCodedOffset; |
---|
2368 | } |
---|
2369 | } |
---|
2370 | |
---|
2371 | |
---|
2372 | Void |
---|
2373 | TComVPS::initCamParaVPS( UInt uiViewIndex, Bool bCamParPresent, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset ) |
---|
2374 | { |
---|
2375 | AOT( uiViewIndex != 0 && !bCamParSlice && ( aaiScale == 0 || aaiOffset == 0 ) ); |
---|
2376 | |
---|
2377 | m_uiCamParPrecision = ( ( uiViewIndex != 0 )? uiCamParPrecision : 0 ); |
---|
2378 | m_bCamParPresent[ uiViewIndex ] = (( uiViewIndex != 0 )? bCamParPresent : false ); |
---|
2379 | m_bCamParInSliceHeader[ uiViewIndex ] = ( (uiViewIndex != 0)? bCamParSlice : false ); |
---|
2380 | |
---|
2381 | if( !m_bCamParInSliceHeader[ uiViewIndex ] ) |
---|
2382 | { |
---|
2383 | for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < uiViewIndex; uiBaseViewIndex++ ) |
---|
2384 | { |
---|
2385 | m_aaaiCodedScale [ uiViewIndex ][ 0 ][ uiBaseViewIndex ] = aaiScale [ uiBaseViewIndex ][ uiViewIndex ]; |
---|
2386 | m_aaaiCodedScale [ uiViewIndex ][ 1 ][ uiBaseViewIndex ] = aaiScale [ uiViewIndex ][ uiBaseViewIndex ]; |
---|
2387 | m_aaaiCodedOffset[ uiViewIndex ][ 0 ][ uiBaseViewIndex ] = aaiOffset[ uiBaseViewIndex ][ uiViewIndex ]; |
---|
2388 | m_aaaiCodedOffset[ uiViewIndex ][ 1 ][ uiBaseViewIndex ] = aaiOffset[ uiViewIndex ][ uiBaseViewIndex ]; |
---|
2389 | } |
---|
2390 | } |
---|
2391 | } |
---|
2392 | |
---|
2393 | #endif // H_3D |
---|
2394 | |
---|
2395 | |
---|
2396 | Int TComVPS::xGetDimBitOffset( Int j ) |
---|
2397 | { |
---|
2398 | Int dimBitOffset = 0; |
---|
2399 | if ( getSplittingFlag() && j == getNumScalabilityTypes() ) |
---|
2400 | { |
---|
2401 | dimBitOffset = 6; |
---|
2402 | } |
---|
2403 | else |
---|
2404 | { |
---|
2405 | for (Int dimIdx = 0; dimIdx <= j-1; dimIdx++) |
---|
2406 | { |
---|
2407 | dimBitOffset += getDimensionIdLen( dimIdx ); |
---|
2408 | } |
---|
2409 | } |
---|
2410 | return dimBitOffset; |
---|
2411 | } |
---|
2412 | |
---|
2413 | Int TComVPS::inferDimensionId( Int i, Int j ) |
---|
2414 | { |
---|
2415 | return ( ( getLayerIdInNuh( i ) & ( (1 << xGetDimBitOffset( j + 1 ) ) - 1) ) >> xGetDimBitOffset( j ) ); |
---|
2416 | } |
---|
2417 | |
---|
2418 | Int TComVPS::inferLastDimsionIdLenMinus1() |
---|
2419 | { |
---|
2420 | return ( 5 - xGetDimBitOffset( getNumScalabilityTypes() - 1 ) ); |
---|
2421 | } |
---|
2422 | |
---|
2423 | Int TComVPS::getNumLayersInIdList( Int lsIdx ) |
---|
2424 | { |
---|
2425 | assert( lsIdx >= 0 ); |
---|
2426 | #if H_MV_HLS10_ADD_LAYERSETS |
---|
2427 | assert( lsIdx <= getNumLayerSets() ); |
---|
2428 | #else |
---|
2429 | assert( lsIdx <= getVpsNumLayerSetsMinus1() ); |
---|
2430 | #endif |
---|
2431 | return (Int) m_layerSetLayerIdList[ lsIdx ].size(); |
---|
2432 | } |
---|
2433 | |
---|
2434 | Int TComVPS::getNumOutputLayerSets() |
---|
2435 | { |
---|
2436 | return getNumAddOlss() + getNumLayerSets(); |
---|
2437 | } |
---|
2438 | |
---|
2439 | Int TComVPS::getNumViews() |
---|
2440 | { |
---|
2441 | Int numViews = 1; |
---|
2442 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2443 | { |
---|
2444 | Int lId = getLayerIdInNuh( i ); |
---|
2445 | if ( i > 0 && ( getViewIndex( lId ) != getScalabilityId( i - 1, VIEW_ORDER_INDEX ) ) ) |
---|
2446 | { |
---|
2447 | numViews++; |
---|
2448 | } |
---|
2449 | } |
---|
2450 | |
---|
2451 | return numViews; |
---|
2452 | } |
---|
2453 | |
---|
2454 | #if !H_MV_HLS10_REF_PRED_LAYERS |
---|
2455 | Bool TComVPS::getInDirectDependencyFlag( Int depLayeridInVps, Int refLayeridInVps, Int depth /*= 0 */ ) |
---|
2456 | { |
---|
2457 | #if H_MV_HLS10_REF_PRED_LAYERS |
---|
2458 | // TBD: Remove getInDirectDependencyFlag entirely. |
---|
2459 | return getDependencyFlag( depLayeridInVps, refLayeridInVps ); |
---|
2460 | #else |
---|
2461 | assert( depth < 65 ); |
---|
2462 | Bool dependentFlag = getDirectDependencyFlag( depLayeridInVps, refLayeridInVps ); |
---|
2463 | |
---|
2464 | for( Int i = 0; i < depLayeridInVps && !dependentFlag; i++ ) |
---|
2465 | { |
---|
2466 | if ( getDirectDependencyFlag( depLayeridInVps, i ) ) |
---|
2467 | { |
---|
2468 | dependentFlag = getInDirectDependencyFlag( i, refLayeridInVps, depth++ ); |
---|
2469 | } |
---|
2470 | } |
---|
2471 | return dependentFlag; |
---|
2472 | #endif |
---|
2473 | } |
---|
2474 | #endif |
---|
2475 | |
---|
2476 | Void TComVPS::deriveLayerSetLayerIdList() |
---|
2477 | { |
---|
2478 | m_layerSetLayerIdList.resize( getVpsNumLayerSetsMinus1() + 1 ); |
---|
2479 | for (Int i = 0; i <= getVpsNumLayerSetsMinus1(); i++ ) |
---|
2480 | { |
---|
2481 | for( Int m = 0; m <= getVpsMaxLayerId(); m++ ) |
---|
2482 | { |
---|
2483 | if( getLayerIdIncludedFlag( i, m) ) |
---|
2484 | { |
---|
2485 | m_layerSetLayerIdList[ i ].push_back( m ); |
---|
2486 | } |
---|
2487 | } |
---|
2488 | } |
---|
2489 | } |
---|
2490 | |
---|
2491 | Void TComVPS::initTargetLayerIdLists() |
---|
2492 | { |
---|
2493 | m_targetDecLayerIdLists.resize( getNumOutputLayerSets() ); |
---|
2494 | m_targetOptLayerIdLists.resize( getNumOutputLayerSets() ); |
---|
2495 | } |
---|
2496 | |
---|
2497 | Void TComVPS::deriveTargetLayerIdList( Int i ) |
---|
2498 | { |
---|
2499 | Int lsIdx = olsIdxToLsIdx( i ); |
---|
2500 | |
---|
2501 | for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ ) |
---|
2502 | { |
---|
2503 | #if H_MV_HLS10_NESSECARY_LAYER |
---|
2504 | if ( getNecessaryLayerFlag( i , j )) |
---|
2505 | { |
---|
2506 | #endif |
---|
2507 | m_targetDecLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); |
---|
2508 | #if H_MV_HLS10_NESSECARY_LAYER |
---|
2509 | } |
---|
2510 | #endif |
---|
2511 | |
---|
2512 | if( getOutputLayerFlag( i, j )) |
---|
2513 | { |
---|
2514 | m_targetOptLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); |
---|
2515 | } |
---|
2516 | } |
---|
2517 | assert( getNumOutputLayersInOutputLayerSet( i ) > 0 ); |
---|
2518 | } |
---|
2519 | |
---|
2520 | Bool TComVPS::inferOutputLayerFlag( Int i, Int j ) |
---|
2521 | { |
---|
2522 | Bool outputLayerFlag; |
---|
2523 | switch ( getDefaultOutputLayerIdc( ) ) |
---|
2524 | { |
---|
2525 | case 0: |
---|
2526 | outputLayerFlag = true; |
---|
2527 | break; |
---|
2528 | case 1: |
---|
2529 | outputLayerFlag = ( j == m_layerSetLayerIdList[ olsIdxToLsIdx( i ) ].size() - 1 ); |
---|
2530 | break; |
---|
2531 | case 2: |
---|
2532 | if ( i == 0 && j == 0) |
---|
2533 | { |
---|
2534 | outputLayerFlag = true; // This is a software only fix for a bug in the spec. In spec outputLayerFlag is neither present nor inferred. |
---|
2535 | } |
---|
2536 | else |
---|
2537 | { |
---|
2538 | assert( 0 ); |
---|
2539 | } |
---|
2540 | break; |
---|
2541 | default: |
---|
2542 | assert( 0 ); |
---|
2543 | break; |
---|
2544 | } |
---|
2545 | return outputLayerFlag; |
---|
2546 | } |
---|
2547 | |
---|
2548 | Int TComVPS::getMaxSubLayersInLayerSetMinus1( Int i ) |
---|
2549 | { |
---|
2550 | Int maxSLMinus1 = 0; |
---|
2551 | for( Int k = 0; k < getNumLayersInIdList( i ); k++ ) |
---|
2552 | { |
---|
2553 | Int lId = m_layerSetLayerIdList[i][k]; |
---|
2554 | maxSLMinus1 = std::max( maxSLMinus1, getSubLayersVpsMaxMinus1( getLayerIdInVps( lId ) )); |
---|
2555 | } |
---|
2556 | return maxSLMinus1; |
---|
2557 | } |
---|
2558 | |
---|
2559 | #if !H_MV_HLS10_ADD_LAYERSETS |
---|
2560 | Void TComVPS::inferDbpSizeLayerSetZero( TComSPS* sps, Bool encoder ) |
---|
2561 | { |
---|
2562 | for( Int j = 0; j <= getMaxSubLayersInLayerSetMinus1( 0 ); j++ ) |
---|
2563 | { |
---|
2564 | Int maxDecPicBufferingMinus1 = sps->getMaxDecPicBuffering( j ) - 1; |
---|
2565 | Int numReorderPics = sps->getNumReorderPics ( j ); |
---|
2566 | Int maxLatencyIncreasePlus1 = sps->getMaxLatencyIncrease( j ); |
---|
2567 | |
---|
2568 | if ( encoder ) |
---|
2569 | { |
---|
2570 | assert( getDpbSize()->getMaxVpsDecPicBufferingMinus1(0, 0, j ) == maxDecPicBufferingMinus1 ); |
---|
2571 | assert( getDpbSize()->getMaxVpsNumReorderPics (0, j ) == numReorderPics ); |
---|
2572 | assert( getDpbSize()->getMaxVpsLatencyIncreasePlus1 (0, j ) == maxLatencyIncreasePlus1 ); |
---|
2573 | } |
---|
2574 | else |
---|
2575 | { |
---|
2576 | getDpbSize()->setMaxVpsDecPicBufferingMinus1(0, 0, j, maxDecPicBufferingMinus1 ); |
---|
2577 | getDpbSize()->setMaxVpsNumReorderPics (0, j, numReorderPics ); |
---|
2578 | getDpbSize()->setMaxVpsLatencyIncreasePlus1 (0, j, maxLatencyIncreasePlus1 ); |
---|
2579 | } |
---|
2580 | } |
---|
2581 | } |
---|
2582 | #endif |
---|
2583 | Bool TComVPS::getAltOutputLayerFlagVar( Int i ) |
---|
2584 | { |
---|
2585 | // Semantics variable not syntax element ! |
---|
2586 | |
---|
2587 | Bool altOptLayerFlag = false; |
---|
2588 | if ( i > 0 && getNumOutputLayersInOutputLayerSet( i ) == 1 && |
---|
2589 | getNumDirectRefLayers( getOlsHighestOutputLayerId( i ) ) > 0 ) |
---|
2590 | { |
---|
2591 | altOptLayerFlag = getAltOutputLayerFlag( i ); |
---|
2592 | } |
---|
2593 | return altOptLayerFlag; |
---|
2594 | } |
---|
2595 | |
---|
2596 | #if !H_MV_HLS10_MAXNUMPICS |
---|
2597 | Int TComVPS::getMaxNumPics( Int layerId ) |
---|
2598 | { |
---|
2599 | Int maxNumPics = MAX_INT; |
---|
2600 | for( Int olsIdx = 0; olsIdx < getNumOutputLayerSets(); olsIdx++) |
---|
2601 | { |
---|
2602 | Int lsIdx = olsIdxToLsIdx( olsIdx ); |
---|
2603 | for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ ) |
---|
2604 | { |
---|
2605 | if( getLayerSetLayerIdList(lsIdx, j ) == layerId ) |
---|
2606 | { |
---|
2607 | Int maxSL = getMaxSubLayersInLayerSetMinus1( lsIdx ); |
---|
2608 | maxNumPics = std::min( maxNumPics, getDpbSize()->getMaxVpsDecPicBufferingMinus1( olsIdx , j, maxSL ) ); |
---|
2609 | } |
---|
2610 | } |
---|
2611 | } |
---|
2612 | assert( maxNumPics != MAX_INT ); |
---|
2613 | return maxNumPics; |
---|
2614 | } |
---|
2615 | #endif |
---|
2616 | |
---|
2617 | #if !H_MV_HLS10_REF_PRED_LAYERS |
---|
2618 | Void TComVPS::xSetRefLayerFlags( Int currLayerId ) |
---|
2619 | { |
---|
2620 | for( Int j = 0; j < getNumDirectRefLayers( currLayerId ); j++ ) |
---|
2621 | { |
---|
2622 | Int refLayerId = m_refLayerId[ currLayerId ][ j ]; |
---|
2623 | m_recursiveRefLayerFlag[ currLayerId ][ refLayerId ] = 1; |
---|
2624 | for( Int k = 0; k < MAX_NUM_LAYER_IDS; k++ ) |
---|
2625 | { |
---|
2626 | m_recursiveRefLayerFlag[ currLayerId ][ k ] = m_recursiveRefLayerFlag[ currLayerId ][ k ] || m_recursiveRefLayerFlag[ refLayerId ][ k ]; |
---|
2627 | } |
---|
2628 | } |
---|
2629 | } |
---|
2630 | |
---|
2631 | #endif |
---|
2632 | |
---|
2633 | #if H_MV_HLS10_PTL_FIX |
---|
2634 | Int TComVPS::inferProfileTierLevelIdx(Int i, Int j) |
---|
2635 | { |
---|
2636 | Bool inferZero = ( i == 0 && j == 0 && getVpsBaseLayerInternalFlag() ); |
---|
2637 | Bool inferGreaterZero = getNecessaryLayerFlag(i,j) && ( getVpsNumProfileTierLevelMinus1() == 0 ); |
---|
2638 | assert( inferZero || inferGreaterZero ); |
---|
2639 | |
---|
2640 | Bool ptlIdx = 0; // inference for greaterZero |
---|
2641 | if ( inferZero ) |
---|
2642 | { |
---|
2643 | ptlIdx = getMaxLayersMinus1() > 0 ? 1 : 0; |
---|
2644 | if ( inferGreaterZero ) |
---|
2645 | { |
---|
2646 | assert( ptlIdx == 0 ); |
---|
2647 | // This should never happen since : |
---|
2648 | // When vps_max_layers_minus1 is greater than 0, the value of vps_num_profile_tier_level_minus1 shall be greater than or equal to 1. |
---|
2649 | } |
---|
2650 | } |
---|
2651 | return ptlIdx; |
---|
2652 | } |
---|
2653 | #endif |
---|
2654 | |
---|
2655 | #if H_MV_HLS10_ADD_LAYERSETS |
---|
2656 | Void TComVPS::deriveAddLayerSetLayerIdList(Int i) |
---|
2657 | { |
---|
2658 | assert( m_layerSetLayerIdList.size() == ( getVpsNumLayerSetsMinus1() + 1 + i ) ); |
---|
2659 | std::vector<Int> layerSetLayerIdList; |
---|
2660 | |
---|
2661 | for( Int treeIdx = 1; treeIdx < getNumIndependentLayers(); treeIdx++ ) |
---|
2662 | { |
---|
2663 | // The value of highest_layer_idx_plus1[ i ][ j ] shall be in the range of 0 to NumLayersInTreePartition[ j ], inclusive. |
---|
2664 | assert( getHighestLayerIdxPlus1( i, treeIdx ) >= 0 && getHighestLayerIdxPlus1( i, treeIdx ) <= getNumLayersInTreePartition( treeIdx ) ); |
---|
2665 | |
---|
2666 | for( Int layerCnt = 0; layerCnt < getHighestLayerIdxPlus1( i, treeIdx ); layerCnt++ ) |
---|
2667 | { |
---|
2668 | layerSetLayerIdList.push_back( getTreePartitionLayerIdList( treeIdx, layerCnt ) ); |
---|
2669 | } |
---|
2670 | } |
---|
2671 | m_layerSetLayerIdList.push_back( layerSetLayerIdList ); |
---|
2672 | |
---|
2673 | //It is a requirement of bitstream conformance that |
---|
2674 | //NumLayersInIdList[ vps_num_layer_sets_minus1 + 1 + i ] shall be greater than 0. |
---|
2675 | assert( getNumLayersInIdList( getVpsNumLayerSetsMinus1() + 1 + i ) > 0 ); |
---|
2676 | } |
---|
2677 | |
---|
2678 | #endif |
---|
2679 | |
---|
2680 | #if H_MV_HLS10_NESSECARY_LAYER |
---|
2681 | Void TComVPS::deriveNecessaryLayerFlags(Int olsIdx) |
---|
2682 | { |
---|
2683 | AOF( olsIdx >= 0 && olsIdx < getNumOutputLayerSets() ); |
---|
2684 | Int lsIdx = olsIdxToLsIdx( olsIdx ); |
---|
2685 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx) ; lsLayerIdx++ ) |
---|
2686 | { |
---|
2687 | m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ] = 0; |
---|
2688 | } |
---|
2689 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx ); lsLayerIdx++ ) |
---|
2690 | { |
---|
2691 | if( getOutputLayerFlag( olsIdx, lsLayerIdx )) |
---|
2692 | { |
---|
2693 | m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ] = 1; |
---|
2694 | Int currLayerId = getLayerSetLayerIdList( lsIdx, lsLayerIdx ); |
---|
2695 | for( Int rLsLayerIdx = 0; rLsLayerIdx < lsLayerIdx; rLsLayerIdx++ ) |
---|
2696 | { |
---|
2697 | Int refLayerId = getLayerSetLayerIdList( lsIdx, rLsLayerIdx ); |
---|
2698 | if( getDependencyFlag( getLayerIdInVps( currLayerId ), getLayerIdInVps( refLayerId ) ) ) |
---|
2699 | { |
---|
2700 | m_necessaryLayerFlag[ olsIdx ][ rLsLayerIdx ] = 1; |
---|
2701 | } |
---|
2702 | } |
---|
2703 | } |
---|
2704 | } |
---|
2705 | m_numNecessaryLayers[ olsIdx ] = 0; |
---|
2706 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx ); lsLayerIdx++ ) |
---|
2707 | { |
---|
2708 | m_numNecessaryLayers[ olsIdx ] += m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ]; |
---|
2709 | } |
---|
2710 | } |
---|
2711 | #endif |
---|
2712 | |
---|
2713 | #if H_MV_HLS10_ADD_LAYERSETS |
---|
2714 | Void TComVPS::printPTL() |
---|
2715 | { |
---|
2716 | std::vector<Int> idx; |
---|
2717 | std::vector<Int> num; |
---|
2718 | std::vector< std::vector<Int> > ptlInfo; |
---|
2719 | |
---|
2720 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "PTLI" << std::endl; |
---|
2721 | |
---|
2722 | for ( Int i = 0; i <= getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
2723 | { |
---|
2724 | std::vector<Int> curPtlInfo; |
---|
2725 | ProfileTierLevel* ptl = getPTL( i )->getGeneralPTL(); |
---|
2726 | curPtlInfo.push_back( (Int) ptl->getProfileIdc() ); |
---|
2727 | curPtlInfo.push_back( (Int) ptl->getTierFlag() ); |
---|
2728 | curPtlInfo.push_back( (Int) ptl->getLevelIdc() ); |
---|
2729 | curPtlInfo.push_back( (Int) ptl->getInbldFlag() ); |
---|
2730 | |
---|
2731 | idx.push_back ( i ); |
---|
2732 | num.push_back ( 4 ); |
---|
2733 | ptlInfo.push_back( curPtlInfo ); |
---|
2734 | } |
---|
2735 | |
---|
2736 | xPrintArray( "VpsProfileTierLevel", getVpsNumProfileTierLevelMinus1() + 1, idx, num, ptlInfo, false ); |
---|
2737 | |
---|
2738 | num.clear(); |
---|
2739 | idx.clear(); |
---|
2740 | for (Int i = 0; i < getNumOutputLayerSets(); i++) |
---|
2741 | { |
---|
2742 | num.push_back ( getNumLayersInIdList( olsIdxToLsIdx( i )) ); |
---|
2743 | idx.push_back( i ); |
---|
2744 | } |
---|
2745 | |
---|
2746 | xPrintArray( "profile_tier_level_idx", getNumOutputLayerSets(), idx, num, m_profileTierLevelIdx, true ); |
---|
2747 | std::cout << std::endl; |
---|
2748 | } |
---|
2749 | |
---|
2750 | Void TComVPS::printLayerDependencies() |
---|
2751 | { |
---|
2752 | vector<Int> fullArray; |
---|
2753 | vector<Int> range; |
---|
2754 | |
---|
2755 | #if H_3D |
---|
2756 | vector<Int> depthId; |
---|
2757 | #endif |
---|
2758 | |
---|
2759 | #if H_MV_HLS10_AUX |
---|
2760 | vector<Int> viewOrderIndex; |
---|
2761 | vector<Int> auxId; |
---|
2762 | vector<Int> dependencyId; |
---|
2763 | vector<Int> viewId; |
---|
2764 | #endif |
---|
2765 | for (Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2766 | { |
---|
2767 | fullArray.push_back( getMaxLayersMinus1() + 1 ); |
---|
2768 | range.push_back( i ); |
---|
2769 | #if H_MV_HLS10_AUX |
---|
2770 | viewOrderIndex.push_back( getViewIndex ( i ) ); |
---|
2771 | dependencyId .push_back( getDependencyId( i ) ); |
---|
2772 | auxId .push_back( getAuxId ( i ) ); |
---|
2773 | viewId .push_back( getViewId ( getLayerIdInNuh( i ) ) ); |
---|
2774 | #if H_3D |
---|
2775 | depthId.push_back( getDepthId( i ) ); |
---|
2776 | #endif |
---|
2777 | #endif |
---|
2778 | } |
---|
2779 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Layer Dependencies" << std::endl; |
---|
2780 | xPrintArray( "direct_dependency_flag", getMaxLayersMinus1()+1, range, fullArray, m_directDependencyFlag, false ); |
---|
2781 | xPrintArray( "DependencyFlag", getMaxLayersMinus1()+1, range, fullArray, m_dependencyFlag, false ); |
---|
2782 | xPrintArray( "layer_id_in_nuh", getMaxLayersMinus1()+1, m_layerIdInNuh, true ); |
---|
2783 | xPrintArray( "IdPredictedLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numPredictedLayers, m_idPredictedLayer, true ); |
---|
2784 | xPrintArray( "IdRefLayer" , getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numRefLayers, m_idRefLayer, true ); |
---|
2785 | xPrintArray( "IdDirectRefLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numDirectRefLayers, m_idDirectRefLayer, true ); |
---|
2786 | std::cout << std::endl; |
---|
2787 | } |
---|
2788 | |
---|
2789 | #if H_MV_HLS10_AUX |
---|
2790 | Void TComVPS::printScalabilityId() |
---|
2791 | { |
---|
2792 | vector<Int> layerIdxInVps; |
---|
2793 | |
---|
2794 | #if H_3D |
---|
2795 | vector<Int> depthId; |
---|
2796 | #endif |
---|
2797 | |
---|
2798 | vector<Int> viewOrderIndex; |
---|
2799 | vector<Int> auxId; |
---|
2800 | vector<Int> dependencyId; |
---|
2801 | vector<Int> viewId; |
---|
2802 | |
---|
2803 | for (Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2804 | { |
---|
2805 | Int layerIdInNuh = getLayerIdInNuh( i ); |
---|
2806 | layerIdxInVps .push_back( i ); |
---|
2807 | viewOrderIndex.push_back( getViewIndex ( layerIdInNuh ) ); |
---|
2808 | dependencyId .push_back( getDependencyId( layerIdInNuh ) ); |
---|
2809 | auxId .push_back( getAuxId ( layerIdInNuh ) ); |
---|
2810 | viewId .push_back( getViewId ( layerIdInNuh ) ); |
---|
2811 | #if H_3D |
---|
2812 | depthId .push_back( getDepthId ( layerIdInNuh ) ); |
---|
2813 | #endif |
---|
2814 | } |
---|
2815 | |
---|
2816 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Scalability Ids" << std::endl; |
---|
2817 | xPrintArray( "layerIdxInVps" , getMaxLayersMinus1()+1, layerIdxInVps, false ); |
---|
2818 | xPrintArray( "layer_id_in_nuh", getMaxLayersMinus1()+1, m_layerIdInNuh, false ); |
---|
2819 | |
---|
2820 | xPrintArray( "ViewOrderIndex", getMaxLayersMinus1()+1, viewOrderIndex, false ); |
---|
2821 | xPrintArray( "DependencyId" , getMaxLayersMinus1()+1, dependencyId , false ); |
---|
2822 | xPrintArray( "AuxId" , getMaxLayersMinus1()+1, auxId , false ); |
---|
2823 | xPrintArray( "ViewId" , getMaxLayersMinus1()+1, viewId , false ); |
---|
2824 | |
---|
2825 | std::cout << std::endl; |
---|
2826 | } |
---|
2827 | #endif |
---|
2828 | |
---|
2829 | Void TComVPS::printLayerSets() |
---|
2830 | { |
---|
2831 | vector<Int> fullArray; |
---|
2832 | vector<Int> numLayersInIdList; |
---|
2833 | vector<Int> rangeLayerSets; |
---|
2834 | |
---|
2835 | |
---|
2836 | for (Int i = 0; i < getNumLayerSets(); i++ ) |
---|
2837 | { |
---|
2838 | numLayersInIdList.push_back( getNumLayersInIdList( i ) ); |
---|
2839 | rangeLayerSets.push_back( i ); |
---|
2840 | } |
---|
2841 | |
---|
2842 | vector<Int> rangeOutputLayerSets; |
---|
2843 | vector<Int> numOutputLayersInOutputLayerSet; |
---|
2844 | vector<Int> numDecLayer; |
---|
2845 | vector<Int> numLayersInLayerSetForOutputLayerSet; |
---|
2846 | vector<Int> vOlsIdxToLsIdx; |
---|
2847 | for (Int i = 0; i < getNumOutputLayerSets(); i++ ) |
---|
2848 | { |
---|
2849 | vOlsIdxToLsIdx.push_back( olsIdxToLsIdx(i)); |
---|
2850 | numOutputLayersInOutputLayerSet.push_back( getNumOutputLayersInOutputLayerSet( i ) ); |
---|
2851 | numDecLayer.push_back( (Int) m_targetDecLayerIdLists[ i ].size() ); |
---|
2852 | rangeOutputLayerSets.push_back( i ); |
---|
2853 | numLayersInLayerSetForOutputLayerSet.push_back( getNumLayersInIdList( olsIdxToLsIdx( i ) ) ); |
---|
2854 | } |
---|
2855 | |
---|
2856 | vector<Int> rangeIndependentLayers; |
---|
2857 | for(Int i = 0; i < getNumIndependentLayers(); i++ ) |
---|
2858 | { |
---|
2859 | rangeIndependentLayers.push_back( i ); |
---|
2860 | } |
---|
2861 | |
---|
2862 | vector<Int> rangeAddLayerSets; |
---|
2863 | vector<Int> numHighestLayerIdxPlus1; |
---|
2864 | for(Int i = 0; i < getNumAddLayerSets(); i++ ) |
---|
2865 | { |
---|
2866 | rangeAddLayerSets.push_back( i ); |
---|
2867 | numHighestLayerIdxPlus1.push_back( getNumIndependentLayers() ); |
---|
2868 | } |
---|
2869 | |
---|
2870 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Layer Sets" << std::endl; |
---|
2871 | xPrintArray( "TreePartitionLayerIdList", getNumIndependentLayers(), rangeIndependentLayers, m_numLayersInTreePartition, m_treePartitionLayerIdList, true ); |
---|
2872 | xPrintArray( "highest_layer_idx_plus1", getNumAddLayerSets(), rangeAddLayerSets, numHighestLayerIdxPlus1, m_highestLayerIdxPlus1, true ); |
---|
2873 | xPrintArray( "LayerSetLayerIdList" , (Int) getNumLayerSets() , rangeLayerSets , numLayersInIdList, m_layerSetLayerIdList, true ); |
---|
2874 | xPrintArray( "OlsIdxToLsIdx", (Int) vOlsIdxToLsIdx.size(), vOlsIdxToLsIdx, true ); |
---|
2875 | xPrintArray( "OutputLayerFlag" , getNumOutputLayerSets(), rangeOutputLayerSets, numLayersInLayerSetForOutputLayerSet, m_outputLayerFlag, true ); |
---|
2876 | xPrintArray( "TargetOptLayerIdList", getNumOutputLayerSets(), rangeOutputLayerSets, numOutputLayersInOutputLayerSet, m_targetOptLayerIdLists, true ); |
---|
2877 | xPrintArray( "NecessaryLayerFlag" , getNumOutputLayerSets(), rangeOutputLayerSets, numLayersInLayerSetForOutputLayerSet, m_necessaryLayerFlag , true ); |
---|
2878 | xPrintArray( "TargetDecLayerIdList", getNumOutputLayerSets(), rangeOutputLayerSets, numDecLayer, m_targetDecLayerIdLists, true ); |
---|
2879 | std::cout << endl; |
---|
2880 | } |
---|
2881 | |
---|
2882 | #endif |
---|
2883 | |
---|
2884 | #endif // H_MV |
---|
2885 | |
---|
2886 | // ------------------------------------------------------------------------------------------------ |
---|
2887 | // Sequence parameter set (SPS) |
---|
2888 | // ------------------------------------------------------------------------------------------------ |
---|
2889 | |
---|
2890 | TComSPS::TComSPS() |
---|
2891 | : m_SPSId ( 0) |
---|
2892 | , m_VPSId ( 0) |
---|
2893 | , m_chromaFormatIdc (CHROMA_420) |
---|
2894 | , m_uiMaxTLayers ( 1) |
---|
2895 | // Structure |
---|
2896 | , m_picWidthInLumaSamples (352) |
---|
2897 | , m_picHeightInLumaSamples (288) |
---|
2898 | , m_log2MinCodingBlockSize ( 0) |
---|
2899 | , m_log2DiffMaxMinCodingBlockSize (0) |
---|
2900 | , m_uiMaxCUWidth ( 32) |
---|
2901 | , m_uiMaxCUHeight ( 32) |
---|
2902 | , m_uiMaxCUDepth ( 3) |
---|
2903 | , m_bLongTermRefsPresent (false) |
---|
2904 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
2905 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
2906 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
2907 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
2908 | // Tool list |
---|
2909 | , m_usePCM (false) |
---|
2910 | , m_pcmLog2MaxSize ( 5) |
---|
2911 | , m_uiPCMLog2MinSize ( 7) |
---|
2912 | #if !MTK_I0099_VPS_EX2 |
---|
2913 | #if H_3D_QTLPC |
---|
2914 | , m_bUseQTL (false) |
---|
2915 | , m_bUsePC (false) |
---|
2916 | #endif |
---|
2917 | #endif |
---|
2918 | , m_bitDepthY ( 8) |
---|
2919 | , m_bitDepthC ( 8) |
---|
2920 | , m_qpBDOffsetY ( 0) |
---|
2921 | , m_qpBDOffsetC ( 0) |
---|
2922 | , m_uiPCMBitDepthLuma ( 8) |
---|
2923 | , m_uiPCMBitDepthChroma ( 8) |
---|
2924 | , m_bPCMFilterDisableFlag (false) |
---|
2925 | , m_uiBitsForPOC ( 8) |
---|
2926 | , m_numLongTermRefPicSPS ( 0) |
---|
2927 | , m_uiMaxTrSize ( 32) |
---|
2928 | , m_bUseSAO (false) |
---|
2929 | , m_bTemporalIdNestingFlag (false) |
---|
2930 | , m_scalingListEnabledFlag (false) |
---|
2931 | , m_useStrongIntraSmoothing (false) |
---|
2932 | , m_vuiParametersPresentFlag (false) |
---|
2933 | , m_vuiParameters () |
---|
2934 | #if H_MV |
---|
2935 | , m_pcVPS ( NULL ) |
---|
2936 | , m_spsInferScalingListFlag ( false ) |
---|
2937 | , m_spsScalingListRefLayerId ( 0 ) |
---|
2938 | |
---|
2939 | , m_updateRepFormatFlag ( false ) |
---|
2940 | , m_spsRepFormatIdx ( 0 ) |
---|
2941 | , m_interViewMvVertConstraintFlag (false) |
---|
2942 | #endif |
---|
2943 | #if H_3D |
---|
2944 | , m_bCamParInSliceHeader (false) |
---|
2945 | #endif |
---|
2946 | { |
---|
2947 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
2948 | { |
---|
2949 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2950 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2951 | m_numReorderPics[i] = 0; |
---|
2952 | } |
---|
2953 | m_scalingList = new TComScalingList; |
---|
2954 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
2955 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
2956 | #if H_MV |
---|
2957 | m_spsRangeExtensionsFlag = false; |
---|
2958 | m_spsMultilayerExtensionFlag = false; |
---|
2959 | #if H_3D |
---|
2960 | m_spsExtension5bits = 0; |
---|
2961 | m_sps3dExtensionFlag = false; |
---|
2962 | #else |
---|
2963 | m_spsExtension6bits = 0; |
---|
2964 | #endif |
---|
2965 | |
---|
2966 | #if !H_MV_HLS10_PPS |
---|
2967 | m_numScaledRefLayerOffsets = 0; |
---|
2968 | |
---|
2969 | for (Int i = 0; i < MAX_NUM_SCALED_REF_LAYERS; i++ ) |
---|
2970 | { |
---|
2971 | m_scaledRefLayerId [i] = -1; |
---|
2972 | } |
---|
2973 | |
---|
2974 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
2975 | { |
---|
2976 | m_scaledRefLayerLeftOffset [i] = 0; |
---|
2977 | m_scaledRefLayerTopOffset [i] = 0; |
---|
2978 | m_scaledRefLayerRiFghtOffset [i] = 0; |
---|
2979 | m_scaledRefLayerBottomOffset [i] = 0; |
---|
2980 | } |
---|
2981 | #endif |
---|
2982 | #endif |
---|
2983 | } |
---|
2984 | |
---|
2985 | TComSPS::~TComSPS() |
---|
2986 | { |
---|
2987 | delete m_scalingList; |
---|
2988 | m_RPSList.destroy(); |
---|
2989 | } |
---|
2990 | |
---|
2991 | Void TComSPS::createRPSList( Int numRPS ) |
---|
2992 | { |
---|
2993 | m_RPSList.destroy(); |
---|
2994 | m_RPSList.create(numRPS); |
---|
2995 | } |
---|
2996 | |
---|
2997 | Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
2998 | { |
---|
2999 | if( !getVuiParametersPresentFlag() ) |
---|
3000 | { |
---|
3001 | return; |
---|
3002 | } |
---|
3003 | |
---|
3004 | TComVUI *vui = getVuiParameters(); |
---|
3005 | TComHRD *hrd = vui->getHrdParameters(); |
---|
3006 | |
---|
3007 | TimingInfo *timingInfo = vui->getTimingInfo(); |
---|
3008 | timingInfo->setTimingInfoPresentFlag( true ); |
---|
3009 | switch( frameRate ) |
---|
3010 | { |
---|
3011 | case 24: |
---|
3012 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
3013 | break; |
---|
3014 | case 25: |
---|
3015 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
3016 | break; |
---|
3017 | case 30: |
---|
3018 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
---|
3019 | break; |
---|
3020 | case 50: |
---|
3021 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
3022 | break; |
---|
3023 | case 60: |
---|
3024 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
---|
3025 | break; |
---|
3026 | default: |
---|
3027 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
---|
3028 | break; |
---|
3029 | } |
---|
3030 | |
---|
3031 | Bool rateCnt = ( bitRate > 0 ); |
---|
3032 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
3033 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
3034 | |
---|
3035 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
3036 | |
---|
3037 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
3038 | { |
---|
3039 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
3040 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
3041 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
3042 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
3043 | } |
---|
3044 | else |
---|
3045 | { |
---|
3046 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
3047 | } |
---|
3048 | |
---|
3049 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
3050 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
3051 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
3052 | |
---|
3053 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
3054 | if( randomAccess ) |
---|
3055 | { |
---|
3056 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
3057 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
3058 | } |
---|
3059 | else |
---|
3060 | { |
---|
3061 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
3062 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
3063 | } |
---|
3064 | |
---|
3065 | /* |
---|
3066 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
3067 | */ |
---|
3068 | Int i, j; |
---|
3069 | UInt birateValue, cpbSizeValue; |
---|
3070 | UInt ducpbSizeValue; |
---|
3071 | UInt duBitRateValue = 0; |
---|
3072 | |
---|
3073 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
3074 | { |
---|
3075 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
3076 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
3077 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
3078 | hrd->setCpbCntMinus1( i, 0 ); |
---|
3079 | |
---|
3080 | birateValue = bitRate; |
---|
3081 | cpbSizeValue = bitRate; // 1 second |
---|
3082 | ducpbSizeValue = bitRate/numDU; |
---|
3083 | duBitRateValue = bitRate; |
---|
3084 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
3085 | { |
---|
3086 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
3087 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
3088 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
3089 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
3090 | |
---|
3091 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
3092 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
3093 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
3094 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
3095 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
3096 | } |
---|
3097 | } |
---|
3098 | } |
---|
3099 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
3100 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
3101 | |
---|
3102 | TComPPS::TComPPS() |
---|
3103 | : m_PPSId (0) |
---|
3104 | , m_SPSId (0) |
---|
3105 | , m_picInitQPMinus26 (0) |
---|
3106 | , m_useDQP (false) |
---|
3107 | , m_bConstrainedIntraPred (false) |
---|
3108 | , m_bSliceChromaQpFlag (false) |
---|
3109 | , m_pcSPS (NULL) |
---|
3110 | , m_uiMaxCuDQPDepth (0) |
---|
3111 | , m_uiMinCuDQPSize (0) |
---|
3112 | , m_chromaCbQpOffset (0) |
---|
3113 | , m_chromaCrQpOffset (0) |
---|
3114 | , m_numRefIdxL0DefaultActive (1) |
---|
3115 | , m_numRefIdxL1DefaultActive (1) |
---|
3116 | , m_TransquantBypassEnableFlag (false) |
---|
3117 | , m_useTransformSkip (false) |
---|
3118 | , m_dependentSliceSegmentsEnabledFlag (false) |
---|
3119 | , m_tilesEnabledFlag (false) |
---|
3120 | , m_entropyCodingSyncEnabledFlag (false) |
---|
3121 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
3122 | , m_uniformSpacingFlag (0) |
---|
3123 | , m_iNumColumnsMinus1 (0) |
---|
3124 | , m_puiColumnWidth (NULL) |
---|
3125 | , m_iNumRowsMinus1 (0) |
---|
3126 | , m_puiRowHeight (NULL) |
---|
3127 | , m_iNumSubstreams (1) |
---|
3128 | , m_signHideFlag(0) |
---|
3129 | , m_cabacInitPresentFlag (false) |
---|
3130 | , m_encCABACTableIdx (I_SLICE) |
---|
3131 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
3132 | , m_loopFilterAcrossSlicesEnabledFlag (false) |
---|
3133 | , m_listsModificationPresentFlag( 0) |
---|
3134 | , m_numExtraSliceHeaderBits(0) |
---|
3135 | #if H_MV |
---|
3136 | , m_ppsInferScalingListFlag(false) |
---|
3137 | , m_ppsScalingListRefLayerId(0) |
---|
3138 | , m_pocResetInfoPresentFlag(false) |
---|
3139 | #if H_3D |
---|
3140 | , m_pcDLT(NULL) |
---|
3141 | #endif |
---|
3142 | #endif |
---|
3143 | { |
---|
3144 | m_scalingList = new TComScalingList; |
---|
3145 | |
---|
3146 | #if H_MV |
---|
3147 | m_ppsRangeExtensionsFlag = false; |
---|
3148 | m_ppsMultilayerExtensionFlag = false; |
---|
3149 | #if !H_3D |
---|
3150 | m_ppsExtension6bits = 0; |
---|
3151 | #else |
---|
3152 | m_pps3dExtensionFlag = false; |
---|
3153 | m_ppsExtension5bits = 0; |
---|
3154 | #endif |
---|
3155 | #endif |
---|
3156 | } |
---|
3157 | |
---|
3158 | TComPPS::~TComPPS() |
---|
3159 | { |
---|
3160 | if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
3161 | { |
---|
3162 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
3163 | m_puiColumnWidth = NULL; |
---|
3164 | } |
---|
3165 | if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
3166 | { |
---|
3167 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
3168 | m_puiRowHeight = NULL; |
---|
3169 | } |
---|
3170 | delete m_scalingList; |
---|
3171 | } |
---|
3172 | |
---|
3173 | #if H_3D |
---|
3174 | TComDLT::TComDLT() |
---|
3175 | : m_bDltPresentFlag(false) |
---|
3176 | , m_iNumDepthViews(0) |
---|
3177 | , m_uiDepthViewBitDepth(8) |
---|
3178 | { |
---|
3179 | m_uiDepthViewBitDepth = g_bitDepthY; |
---|
3180 | |
---|
3181 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
3182 | { |
---|
3183 | m_bUseDLTFlag [i] = false; |
---|
3184 | m_bInterViewDltPredEnableFlag [i] = false; |
---|
3185 | |
---|
3186 | // allocate some memory and initialize with default mapping |
---|
3187 | m_iNumDepthmapValues[i] = ((1 << m_uiDepthViewBitDepth)-1)+1; |
---|
3188 | #if !FIX_TICKET_77 |
---|
3189 | m_iBitsPerDepthValue[i] = numBitsForValue(m_iNumDepthmapValues[i]); |
---|
3190 | #endif |
---|
3191 | m_iDepthValue2Idx[i] = (Int*) xMalloc(Int, m_iNumDepthmapValues[i]); |
---|
3192 | m_iIdx2DepthValue[i] = (Int*) xMalloc(Int, m_iNumDepthmapValues[i]); |
---|
3193 | |
---|
3194 | //default mapping |
---|
3195 | for (Int d=0; d<m_iNumDepthmapValues[i]; d++) |
---|
3196 | { |
---|
3197 | m_iDepthValue2Idx[i][d] = d; |
---|
3198 | m_iIdx2DepthValue[i][d] = d; |
---|
3199 | } |
---|
3200 | } |
---|
3201 | } |
---|
3202 | |
---|
3203 | TComDLT::~TComDLT() |
---|
3204 | { |
---|
3205 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
3206 | { |
---|
3207 | if ( m_iDepthValue2Idx[i] != NULL ) |
---|
3208 | { |
---|
3209 | xFree( m_iDepthValue2Idx[i] ); |
---|
3210 | m_iDepthValue2Idx[i] = NULL; |
---|
3211 | } |
---|
3212 | |
---|
3213 | if ( m_iIdx2DepthValue[i] != NULL ) |
---|
3214 | { |
---|
3215 | xFree( m_iIdx2DepthValue[i] ); |
---|
3216 | m_iIdx2DepthValue[i] = NULL; |
---|
3217 | } |
---|
3218 | } |
---|
3219 | } |
---|
3220 | |
---|
3221 | Void TComDLT::setDepthLUTs(Int layerIdInVps, Int* idxToDepthValueTable, Int iNumDepthValues) |
---|
3222 | { |
---|
3223 | if( idxToDepthValueTable == NULL || iNumDepthValues == 0 ) // default mapping only |
---|
3224 | return; |
---|
3225 | |
---|
3226 | // copy idx2DepthValue to internal array |
---|
3227 | memcpy(m_iIdx2DepthValue[layerIdInVps], idxToDepthValueTable, iNumDepthValues*sizeof(UInt)); |
---|
3228 | |
---|
3229 | UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1); |
---|
3230 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
3231 | { |
---|
3232 | Int iIdxDown = 0; |
---|
3233 | Int iIdxUp = iNumDepthValues-1; |
---|
3234 | Bool bFound = false; |
---|
3235 | |
---|
3236 | // iterate over indices to find lower closest depth |
---|
3237 | Int i = 1; |
---|
3238 | while(!bFound && i<iNumDepthValues) |
---|
3239 | { |
---|
3240 | if( m_iIdx2DepthValue[layerIdInVps][i] > p ) |
---|
3241 | { |
---|
3242 | iIdxDown = i-1; |
---|
3243 | bFound = true; |
---|
3244 | } |
---|
3245 | |
---|
3246 | i++; |
---|
3247 | } |
---|
3248 | // iterate over indices to find upper closest depth |
---|
3249 | i = iNumDepthValues-2; |
---|
3250 | bFound = false; |
---|
3251 | while(!bFound && i>=0) |
---|
3252 | { |
---|
3253 | if( m_iIdx2DepthValue[layerIdInVps][i] < p ) |
---|
3254 | { |
---|
3255 | iIdxUp = i+1; |
---|
3256 | bFound = true; |
---|
3257 | } |
---|
3258 | |
---|
3259 | i--; |
---|
3260 | } |
---|
3261 | |
---|
3262 | // assert monotony |
---|
3263 | assert(iIdxDown<=iIdxUp); |
---|
3264 | |
---|
3265 | // assign closer depth value/idx |
---|
3266 | if( abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxDown]) < abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxUp]) ) |
---|
3267 | { |
---|
3268 | m_iDepthValue2Idx[layerIdInVps][p] = iIdxDown; |
---|
3269 | } |
---|
3270 | else |
---|
3271 | { |
---|
3272 | m_iDepthValue2Idx[layerIdInVps][p] = iIdxUp; |
---|
3273 | } |
---|
3274 | |
---|
3275 | } |
---|
3276 | |
---|
3277 | // update DLT variables |
---|
3278 | m_iNumDepthmapValues[layerIdInVps] = iNumDepthValues; |
---|
3279 | #if !FIX_TICKET_77 |
---|
3280 | m_iBitsPerDepthValue[layerIdInVps] = numBitsForValue(m_iNumDepthmapValues[layerIdInVps]); |
---|
3281 | #endif |
---|
3282 | } |
---|
3283 | |
---|
3284 | #if H_3D_DELTA_DLT |
---|
3285 | Void TComDLT::getDeltaDLT( Int layerIdInVps, Int* piDLTInRef, UInt uiDLTInRefNum, Int* piDeltaDLTOut, UInt *puiDeltaDLTOutNum ) |
---|
3286 | { |
---|
3287 | Bool abBM0[ 256 ]; |
---|
3288 | Bool abBM1[ 256 ]; |
---|
3289 | |
---|
3290 | memset( abBM0, 0, sizeof( abBM0 )); |
---|
3291 | memset( abBM1, 0, sizeof( abBM1 )); |
---|
3292 | |
---|
3293 | // convert reference DLT to bit string |
---|
3294 | for( Int i = 0; i < uiDLTInRefNum; i++ ) |
---|
3295 | { |
---|
3296 | abBM0[ piDLTInRef[ i ] ] = true; |
---|
3297 | } |
---|
3298 | // convert internal DLT to bit string |
---|
3299 | for( Int i = 0; i < m_iNumDepthmapValues[ layerIdInVps ]; i++ ) |
---|
3300 | { |
---|
3301 | abBM1[ m_iIdx2DepthValue[ layerIdInVps ][ i ] ] = true; |
---|
3302 | } |
---|
3303 | |
---|
3304 | *puiDeltaDLTOutNum = 0; |
---|
3305 | for( Int i = 0; i < 256; i++ ) |
---|
3306 | { |
---|
3307 | if( abBM0[ i ] ^ abBM1[ i ] ) |
---|
3308 | { |
---|
3309 | piDeltaDLTOut[ *puiDeltaDLTOutNum ] = i; |
---|
3310 | *puiDeltaDLTOutNum = *puiDeltaDLTOutNum + 1; |
---|
3311 | } |
---|
3312 | } |
---|
3313 | } |
---|
3314 | |
---|
3315 | Void TComDLT::setDeltaDLT( Int layerIdInVps, Int* piDLTInRef, UInt uiDLTInRefNum, Int* piDeltaDLTIn, UInt uiDeltaDLTInNum ) |
---|
3316 | { |
---|
3317 | Bool abBM0[ 256 ]; |
---|
3318 | Bool abBM1[ 256 ]; |
---|
3319 | |
---|
3320 | memset( abBM0, 0, sizeof( abBM0 )); |
---|
3321 | memset( abBM1, 0, sizeof( abBM1 )); |
---|
3322 | |
---|
3323 | // convert reference DLT to bit string |
---|
3324 | for( Int i = 0; i < uiDLTInRefNum; i++ ) |
---|
3325 | { |
---|
3326 | abBM0[ piDLTInRef[ i ] ] = true; |
---|
3327 | } |
---|
3328 | // convert delta DLT to bit string |
---|
3329 | for( Int i = 0; i < uiDeltaDLTInNum; i++ ) |
---|
3330 | { |
---|
3331 | abBM1[ piDeltaDLTIn[ i ] ] = true; |
---|
3332 | } |
---|
3333 | |
---|
3334 | Int aiIdx2DepthValue[256]; |
---|
3335 | UInt uiNumDepthValues = 0; |
---|
3336 | memset( aiIdx2DepthValue, 0, sizeof( aiIdx2DepthValue )); |
---|
3337 | |
---|
3338 | for( Int i = 0; i < 256; i++ ) |
---|
3339 | { |
---|
3340 | if( abBM0[ i ] ^ abBM1[ i ] ) |
---|
3341 | { |
---|
3342 | aiIdx2DepthValue[ uiNumDepthValues++ ] = i; |
---|
3343 | } |
---|
3344 | } |
---|
3345 | |
---|
3346 | // update internal tables |
---|
3347 | setDepthLUTs(layerIdInVps, aiIdx2DepthValue, uiNumDepthValues); |
---|
3348 | } |
---|
3349 | #endif |
---|
3350 | |
---|
3351 | #endif |
---|
3352 | |
---|
3353 | #if H_MV |
---|
3354 | Void TComSPS::inferRepFormat( TComVPS* vps, Int layerIdCurr ) |
---|
3355 | { |
---|
3356 | #if H_MV_HLS10_MULTILAYERSPS |
---|
3357 | if ( getMultiLayerExtSpsFlag() ) |
---|
3358 | #else |
---|
3359 | if ( layerIdCurr > 0 ) |
---|
3360 | #endif |
---|
3361 | { |
---|
3362 | Int repFormatIdx = getUpdateRepFormatFlag() ? getSpsRepFormatIdx() : vps->getVpsRepFormatIdx( vps->getLayerIdInVps( layerIdCurr ) ) ; |
---|
3363 | TComRepFormat* repFormat = vps->getRepFormat( repFormatIdx ); |
---|
3364 | setChromaFormatIdc( repFormat->getChromaFormatVpsIdc() ); |
---|
3365 | //// ToDo: add when supported: |
---|
3366 | // setSeperateColourPlaneFlag( repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
3367 | |
---|
3368 | setPicWidthInLumaSamples ( repFormat->getPicWidthVpsInLumaSamples() ); |
---|
3369 | setPicHeightInLumaSamples( repFormat->getPicHeightVpsInLumaSamples() ); |
---|
3370 | |
---|
3371 | setBitDepthY ( repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
3372 | setQpBDOffsetY ( (Int) (6*( getBitDepthY() - 8 )) ); |
---|
3373 | |
---|
3374 | setBitDepthC ( repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
3375 | setQpBDOffsetC ( (Int) (6* ( getBitDepthC() -8 ) ) ); |
---|
3376 | #if H_MV_HLS10_GEN_VSP_CONF_WIN |
---|
3377 | Window &spsConf = getConformanceWindow(); |
---|
3378 | |
---|
3379 | // Scaled later |
---|
3380 | spsConf.setScaledFlag( false ); |
---|
3381 | spsConf.setWindowLeftOffset ( repFormat->getConfWinVpsLeftOffset() ); |
---|
3382 | spsConf.setWindowRightOffset ( repFormat->getConfWinVpsRightOffset() ); |
---|
3383 | spsConf.setWindowTopOffset ( repFormat->getConfWinVpsTopOffset() ); |
---|
3384 | spsConf.setWindowBottomOffset( repFormat->getConfWinVpsBottomOffset() ); |
---|
3385 | #endif |
---|
3386 | |
---|
3387 | #if H_MV_HLS10_MULTILAYERSPS |
---|
3388 | if ( getMultiLayerExtSpsFlag() && getUpdateRepFormatFlag() ) |
---|
3389 | #else |
---|
3390 | if ( getLayerId() > 0 && getUpdateRepFormatFlag() ) |
---|
3391 | #endif |
---|
3392 | { |
---|
3393 | assert( getChromaFormatIdc() <= repFormat->getChromaFormatVpsIdc() ); |
---|
3394 | //// ToDo: add when supported: |
---|
3395 | // assert( getSeperateColourPlaneFlag() <= repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
3396 | |
---|
3397 | assert( getPicWidthInLumaSamples() <= repFormat->getPicWidthVpsInLumaSamples() ); |
---|
3398 | assert( getPicHeightInLumaSamples() <= repFormat->getPicHeightVpsInLumaSamples() ); |
---|
3399 | |
---|
3400 | assert( getBitDepthY() <= repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
3401 | assert( getBitDepthC() <= repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
3402 | } |
---|
3403 | } |
---|
3404 | |
---|
3405 | // Set conformance window |
---|
3406 | Int scal = TComSPS::getWinUnitX( getChromaFormatIdc() ) ; |
---|
3407 | getConformanceWindow().scaleOffsets( scal ); |
---|
3408 | getVuiParameters()->getDefaultDisplayWindow().scaleOffsets( scal ); |
---|
3409 | } |
---|
3410 | |
---|
3411 | Void TComSPS::inferScalingList( TComSPS* spsSrc ) |
---|
3412 | { |
---|
3413 | if ( getSpsInferScalingListFlag() ) |
---|
3414 | { |
---|
3415 | assert( spsSrc != NULL ); |
---|
3416 | assert( !spsSrc->getSpsInferScalingListFlag() ); |
---|
3417 | getScalingList()->inferFrom( spsSrc->getScalingList() ); |
---|
3418 | } |
---|
3419 | } |
---|
3420 | |
---|
3421 | Void TComSPS::inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder ) |
---|
3422 | { |
---|
3423 | const std::vector<Int>& targetDecLayerIdList = vps->getTargetDecLayerIdList( vps->olsIdxToLsIdx( targetOptLayerSetIdx )); |
---|
3424 | |
---|
3425 | #if H_MV_HLS10_MULTILAYERSPS |
---|
3426 | if ( getMultiLayerExtSpsFlag() ) |
---|
3427 | #else |
---|
3428 | if (getLayerId() > 0 ) |
---|
3429 | #endif |
---|
3430 | { |
---|
3431 | Int layerIdx = 0; |
---|
3432 | while (layerIdx < (Int) targetDecLayerIdList.size() ) |
---|
3433 | { |
---|
3434 | if ( targetDecLayerIdList[layerIdx] == currLayerId ) |
---|
3435 | { |
---|
3436 | break; |
---|
3437 | } |
---|
3438 | layerIdx++; |
---|
3439 | } |
---|
3440 | |
---|
3441 | assert( layerIdx < (Int) targetDecLayerIdList.size() ); |
---|
3442 | |
---|
3443 | for (Int i = 0; i <= getSpsMaxSubLayersMinus1(); i++ ) |
---|
3444 | { |
---|
3445 | Int maxDecPicBufferingMinus1 = vps->getDpbSize()->getMaxVpsDecPicBufferingMinus1( targetOptLayerSetIdx, layerIdx, i ) ; |
---|
3446 | |
---|
3447 | #if H_MV_HLS10_MULTILAYERSPS |
---|
3448 | // This preliminary fix needs to be checked. |
---|
3449 | Int maxNumReorderPics = vps->getDpbSize()->getMaxVpsNumReorderPics( targetOptLayerSetIdx, i ); |
---|
3450 | Int maxLatencyIncreasePlus1 = vps->getDpbSize()->getMaxVpsLatencyIncreasePlus1( targetOptLayerSetIdx, i ); |
---|
3451 | #endif |
---|
3452 | if ( encoder ) |
---|
3453 | { |
---|
3454 | assert( getMaxDecPicBuffering( i ) - 1 == maxDecPicBufferingMinus1 ); |
---|
3455 | #if H_MV_HLS10_MULTILAYERSPS |
---|
3456 | // This preliminary fix needs to be checked. |
---|
3457 | assert( getNumReorderPics( i ) == maxNumReorderPics ); |
---|
3458 | assert( getMaxLatencyIncrease( i ) == maxLatencyIncreasePlus1 ); |
---|
3459 | #endif |
---|
3460 | |
---|
3461 | } |
---|
3462 | else |
---|
3463 | { |
---|
3464 | #if !H_MV_HLS10_MULTILAYERSPS |
---|
3465 | setMaxDecPicBuffering(i, maxDecPicBufferingMinus1 + 1 ); |
---|
3466 | #else |
---|
3467 | // This preliminary fix needs to be checked. |
---|
3468 | setMaxDecPicBuffering( maxDecPicBufferingMinus1 + 1 , i); |
---|
3469 | setNumReorderPics ( maxNumReorderPics, i ); |
---|
3470 | setMaxLatencyIncrease( maxLatencyIncreasePlus1 - 1 , i); |
---|
3471 | #endif |
---|
3472 | } |
---|
3473 | } |
---|
3474 | } |
---|
3475 | } |
---|
3476 | |
---|
3477 | Void TComSPS::checkRpsMaxNumPics( TComVPS* vps, Int currLayerId ) |
---|
3478 | { |
---|
3479 | #if !H_MV_HLS10_MAXNUMPICS |
---|
3480 | // In spec, when rps is in SPS, nuh_layer_id of SPS is used instead |
---|
3481 | // of nuh_layer_id of slice (currLayerId), this seems to be a bug. |
---|
3482 | #endif |
---|
3483 | for (Int i = 0; i < getRPSList()->getNumberOfReferencePictureSets(); i++ ) |
---|
3484 | { |
---|
3485 | TComReferencePictureSet* rps = getRPSList()->getReferencePictureSet( i ); |
---|
3486 | if ( !rps->getInterRPSPrediction() ) |
---|
3487 | { |
---|
3488 | #if H_MV_HLS10_MAXNUMPICS |
---|
3489 | rps->checkMaxNumPics( vps->getVpsExtensionFlag(), MAX_INT, getLayerId(), getMaxDecPicBuffering( getSpsMaxSubLayersMinus1() ) - 1 ); // INT_MAX to be replaced by DpbSize |
---|
3490 | #else |
---|
3491 | rps->checkMaxNumPics( vps->getVpsExtensionFlag(), vps->getMaxNumPics( currLayerId ), |
---|
3492 | getLayerId(), getMaxDecPicBuffering( getSpsMaxSubLayersMinus1() ) - 1 ); |
---|
3493 | #endif |
---|
3494 | } |
---|
3495 | } |
---|
3496 | } |
---|
3497 | |
---|
3498 | #if H_MV_HLS10_MULTILAYERSPS |
---|
3499 | Void TComSPS::inferSpsMaxSubLayersMinus1(Bool atPsActivation, TComVPS* vps) |
---|
3500 | { |
---|
3501 | assert( getLayerId() != 0 ); |
---|
3502 | if ( !atPsActivation ) |
---|
3503 | { |
---|
3504 | assert( vps == NULL ); |
---|
3505 | if (getSpsExtOrMaxSubLayersMinus1() != 7) |
---|
3506 | { |
---|
3507 | setSpsMaxSubLayersMinus1( getSpsExtOrMaxSubLayersMinus1() ); |
---|
3508 | } |
---|
3509 | } |
---|
3510 | else |
---|
3511 | { |
---|
3512 | assert( vps != NULL ); |
---|
3513 | if (getSpsExtOrMaxSubLayersMinus1() == 7) |
---|
3514 | { |
---|
3515 | setSpsMaxSubLayersMinus1( vps->getMaxSubLayersMinus1() ); |
---|
3516 | } |
---|
3517 | } |
---|
3518 | } |
---|
3519 | #endif |
---|
3520 | #endif |
---|
3521 | |
---|
3522 | TComReferencePictureSet::TComReferencePictureSet() |
---|
3523 | : m_numberOfPictures (0) |
---|
3524 | , m_numberOfNegativePictures (0) |
---|
3525 | , m_numberOfPositivePictures (0) |
---|
3526 | , m_numberOfLongtermPictures (0) |
---|
3527 | , m_interRPSPrediction (0) |
---|
3528 | , m_deltaRIdxMinus1 (0) |
---|
3529 | , m_deltaRPS (0) |
---|
3530 | , m_numRefIdc (0) |
---|
3531 | { |
---|
3532 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
3533 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
3534 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
3535 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
3536 | } |
---|
3537 | |
---|
3538 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
3539 | { |
---|
3540 | } |
---|
3541 | |
---|
3542 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
3543 | { |
---|
3544 | m_used[bufferNum] = used; |
---|
3545 | } |
---|
3546 | |
---|
3547 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
3548 | { |
---|
3549 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
3550 | } |
---|
3551 | |
---|
3552 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
3553 | { |
---|
3554 | m_numberOfPictures = numberOfPictures; |
---|
3555 | } |
---|
3556 | |
---|
3557 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
3558 | { |
---|
3559 | return m_used[bufferNum]; |
---|
3560 | } |
---|
3561 | |
---|
3562 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
3563 | { |
---|
3564 | return m_deltaPOC[bufferNum]; |
---|
3565 | } |
---|
3566 | |
---|
3567 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
3568 | { |
---|
3569 | return m_numberOfPictures; |
---|
3570 | } |
---|
3571 | |
---|
3572 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
3573 | { |
---|
3574 | return m_POC[bufferNum]; |
---|
3575 | } |
---|
3576 | |
---|
3577 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
3578 | { |
---|
3579 | m_POC[bufferNum] = POC; |
---|
3580 | } |
---|
3581 | |
---|
3582 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) |
---|
3583 | { |
---|
3584 | return m_bCheckLTMSB[bufferNum]; |
---|
3585 | } |
---|
3586 | |
---|
3587 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
3588 | { |
---|
3589 | m_bCheckLTMSB[bufferNum] = b; |
---|
3590 | } |
---|
3591 | |
---|
3592 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
3593 | * \param uiBufferNum |
---|
3594 | * \param iRefIdc |
---|
3595 | * \returns Void |
---|
3596 | */ |
---|
3597 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
3598 | { |
---|
3599 | m_refIdc[bufferNum] = refIdc; |
---|
3600 | } |
---|
3601 | |
---|
3602 | /** get the reference idc value at uiBufferNum |
---|
3603 | * \param uiBufferNum |
---|
3604 | * \returns Int |
---|
3605 | */ |
---|
3606 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
3607 | { |
---|
3608 | return m_refIdc[bufferNum]; |
---|
3609 | } |
---|
3610 | |
---|
3611 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
3612 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
3613 | * +ve values are in increasing order. |
---|
3614 | * \returns Void |
---|
3615 | */ |
---|
3616 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
3617 | { |
---|
3618 | // sort in increasing order (smallest first) |
---|
3619 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
3620 | { |
---|
3621 | Int deltaPOC = getDeltaPOC(j); |
---|
3622 | Bool used = getUsed(j); |
---|
3623 | for (Int k=j-1; k >= 0; k--) |
---|
3624 | { |
---|
3625 | Int temp = getDeltaPOC(k); |
---|
3626 | if (deltaPOC < temp) |
---|
3627 | { |
---|
3628 | setDeltaPOC(k+1, temp); |
---|
3629 | setUsed(k+1, getUsed(k)); |
---|
3630 | setDeltaPOC(k, deltaPOC); |
---|
3631 | setUsed(k, used); |
---|
3632 | } |
---|
3633 | } |
---|
3634 | } |
---|
3635 | // flip the negative values to largest first |
---|
3636 | Int numNegPics = getNumberOfNegativePictures(); |
---|
3637 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
3638 | { |
---|
3639 | Int deltaPOC = getDeltaPOC(j); |
---|
3640 | Bool used = getUsed(j); |
---|
3641 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
3642 | setUsed(j, getUsed(k)); |
---|
3643 | setDeltaPOC(k, deltaPOC); |
---|
3644 | setUsed(k, used); |
---|
3645 | } |
---|
3646 | } |
---|
3647 | |
---|
3648 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
3649 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
3650 | * \returns Void |
---|
3651 | */ |
---|
3652 | Void TComReferencePictureSet::printDeltaPOC() |
---|
3653 | { |
---|
3654 | printf("DeltaPOC = { "); |
---|
3655 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
3656 | { |
---|
3657 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
3658 | } |
---|
3659 | if (getInterRPSPrediction()) |
---|
3660 | { |
---|
3661 | printf("}, RefIdc = { "); |
---|
3662 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
3663 | { |
---|
3664 | printf("%d ", getRefIdc(j)); |
---|
3665 | } |
---|
3666 | } |
---|
3667 | printf("}\n"); |
---|
3668 | } |
---|
3669 | #if H_MV |
---|
3670 | Void TComReferencePictureSet::checkMaxNumPics( Bool vpsExtensionFlag, Int maxNumPics, Int nuhLayerId, Int spsMaxDecPicBufferingMinus1 ) |
---|
3671 | { |
---|
3672 | assert( getNumberOfPictures() >= 0 ); |
---|
3673 | if ( nuhLayerId == 0 ) |
---|
3674 | { |
---|
3675 | assert( getNumberOfPictures() <= spsMaxDecPicBufferingMinus1 ); |
---|
3676 | } |
---|
3677 | |
---|
3678 | if ( vpsExtensionFlag ) |
---|
3679 | { |
---|
3680 | assert( getNumberOfPictures() <= maxNumPics ); |
---|
3681 | } |
---|
3682 | } |
---|
3683 | #endif |
---|
3684 | |
---|
3685 | TComRPSList::TComRPSList() |
---|
3686 | :m_referencePictureSets (NULL) |
---|
3687 | { |
---|
3688 | } |
---|
3689 | |
---|
3690 | TComRPSList::~TComRPSList() |
---|
3691 | { |
---|
3692 | } |
---|
3693 | |
---|
3694 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
3695 | { |
---|
3696 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
3697 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
3698 | } |
---|
3699 | |
---|
3700 | Void TComRPSList::destroy() |
---|
3701 | { |
---|
3702 | if (m_referencePictureSets) |
---|
3703 | { |
---|
3704 | delete [] m_referencePictureSets; |
---|
3705 | } |
---|
3706 | m_numberOfReferencePictureSets = 0; |
---|
3707 | m_referencePictureSets = NULL; |
---|
3708 | } |
---|
3709 | |
---|
3710 | |
---|
3711 | |
---|
3712 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
3713 | { |
---|
3714 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
3715 | } |
---|
3716 | |
---|
3717 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
3718 | { |
---|
3719 | return m_numberOfReferencePictureSets; |
---|
3720 | } |
---|
3721 | |
---|
3722 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
3723 | { |
---|
3724 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
3725 | } |
---|
3726 | |
---|
3727 | TComRefPicListModification::TComRefPicListModification() |
---|
3728 | : m_bRefPicListModificationFlagL0 (false) |
---|
3729 | , m_bRefPicListModificationFlagL1 (false) |
---|
3730 | { |
---|
3731 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
3732 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
3733 | } |
---|
3734 | |
---|
3735 | TComRefPicListModification::~TComRefPicListModification() |
---|
3736 | { |
---|
3737 | } |
---|
3738 | |
---|
3739 | TComScalingList::TComScalingList() |
---|
3740 | { |
---|
3741 | init(); |
---|
3742 | } |
---|
3743 | TComScalingList::~TComScalingList() |
---|
3744 | { |
---|
3745 | destroy(); |
---|
3746 | } |
---|
3747 | |
---|
3748 | /** set default quantization matrix to array |
---|
3749 | */ |
---|
3750 | Void TComSlice::setDefaultScalingList() |
---|
3751 | { |
---|
3752 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3753 | { |
---|
3754 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
3755 | { |
---|
3756 | getScalingList()->processDefaultMatrix(sizeId, listId); |
---|
3757 | } |
---|
3758 | } |
---|
3759 | } |
---|
3760 | /** check if use default quantization matrix |
---|
3761 | * \returns true if use default quantization matrix in all size |
---|
3762 | */ |
---|
3763 | Bool TComSlice::checkDefaultScalingList() |
---|
3764 | { |
---|
3765 | UInt defaultCounter=0; |
---|
3766 | |
---|
3767 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3768 | { |
---|
3769 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
3770 | { |
---|
3771 | 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 |
---|
3772 | && ((sizeId < SCALING_LIST_16x16) || (getScalingList()->getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
3773 | { |
---|
3774 | defaultCounter++; |
---|
3775 | } |
---|
3776 | } |
---|
3777 | } |
---|
3778 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32 |
---|
3779 | } |
---|
3780 | |
---|
3781 | #if H_MV |
---|
3782 | Void TComSlice::createInterLayerReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1 ) |
---|
3783 | { |
---|
3784 | refPicSetInterLayer0.clear(); |
---|
3785 | refPicSetInterLayer1.clear(); |
---|
3786 | |
---|
3787 | for( Int i = 0; i < getNumActiveRefLayerPics(); i++ ) |
---|
3788 | { |
---|
3789 | Int layerIdRef = getRefPicLayerId( i ); |
---|
3790 | TComPic* picRef = ivPicLists->getPic( layerIdRef, getPOC() ) ; |
---|
3791 | assert ( picRef != 0 ); // There shall be no entry equal to "no reference picture" in RefPicSetInterLayer0 or RefPicSetInterLayer1. |
---|
3792 | |
---|
3793 | picRef->getPicYuvRec()->extendPicBorder(); |
---|
3794 | picRef->setIsLongTerm( true ); |
---|
3795 | picRef->getSlice(0)->setReferenced( true ); |
---|
3796 | |
---|
3797 | Int viewIdCur = getVPS()->getViewId( getLayerId() ); |
---|
3798 | Int viewIdZero = getVPS()->getViewId( 0 ); |
---|
3799 | Int viewIdRef = getVPS()->getViewId( layerIdRef ); |
---|
3800 | |
---|
3801 | if ( ( viewIdCur <= viewIdZero && viewIdCur <= viewIdRef ) || ( viewIdCur >= viewIdZero && viewIdCur >= viewIdRef ) ) |
---|
3802 | { |
---|
3803 | refPicSetInterLayer0.push_back( picRef ); |
---|
3804 | } |
---|
3805 | else |
---|
3806 | { |
---|
3807 | refPicSetInterLayer1.push_back( picRef ); |
---|
3808 | } |
---|
3809 | // Consider to check here: |
---|
3810 | // "If the current picture is a RADL picture, there shall be no entry in the RefPicSetInterLayer0 and RefPicSetInterLayer1 that is a RASL picture. " |
---|
3811 | assert( picRef->getSlice(0)->getDiscardableFlag() == false ); // "There shall be no picture that has discardable_flag equal to 1 in RefPicSetInterLayer0 or RefPicSetInterLayer1". |
---|
3812 | } |
---|
3813 | } |
---|
3814 | |
---|
3815 | Void TComSlice::markIvRefPicsAsShortTerm( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 ) |
---|
3816 | { |
---|
3817 | // Mark as short-term |
---|
3818 | for ( Int i = 0; i < refPicSetInterLayer0.size(); i++ ) |
---|
3819 | { |
---|
3820 | refPicSetInterLayer0[i]->setIsLongTerm( false ); |
---|
3821 | } |
---|
3822 | |
---|
3823 | for ( Int i = 0; i < refPicSetInterLayer1.size(); i++ ) |
---|
3824 | { |
---|
3825 | refPicSetInterLayer1[i]->setIsLongTerm( false ); |
---|
3826 | } |
---|
3827 | |
---|
3828 | } |
---|
3829 | |
---|
3830 | Void TComSlice::printRefPicList() |
---|
3831 | { |
---|
3832 | for ( Int li = 0; li < 2; li++) |
---|
3833 | { |
---|
3834 | std::cout << std::endl << "RefPicListL" << li << ":" << std::endl; |
---|
3835 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[li]-1); rIdx ++) |
---|
3836 | { |
---|
3837 | if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( true ); |
---|
3838 | |
---|
3839 | m_apcRefPicList[li][rIdx]->print( false ); |
---|
3840 | } |
---|
3841 | } |
---|
3842 | } |
---|
3843 | |
---|
3844 | Void TComSlice::markCurrPic( TComPic* currPic ) |
---|
3845 | { |
---|
3846 | currPic->getSlice(0)->setReferenced( true ) ; |
---|
3847 | currPic->setIsLongTerm( false ); |
---|
3848 | |
---|
3849 | currPic->setReconMark( true ); |
---|
3850 | currPic->setPicOutputFlag( currPic->getSlice(0)->getPicOutputFlag() ); |
---|
3851 | } |
---|
3852 | |
---|
3853 | Void TComSlice::setRefPicSetInterLayer( std::vector<TComPic*>* refPicSetInterLayer0, std::vector<TComPic*>* refPicSetInterLayer1 ) |
---|
3854 | { |
---|
3855 | m_refPicSetInterLayer0 = refPicSetInterLayer0; |
---|
3856 | m_refPicSetInterLayer1 = refPicSetInterLayer1; |
---|
3857 | } |
---|
3858 | |
---|
3859 | TComPic* TComSlice::getPicFromRefPicSetInterLayer(Int setIdc, Int layerId ) |
---|
3860 | { |
---|
3861 | assert ( setIdc == 0 || setIdc == 1); |
---|
3862 | std::vector<TComPic*>* refPicSetInterLayer = ( setIdc == 0 ? m_refPicSetInterLayer0 : m_refPicSetInterLayer1); |
---|
3863 | assert( refPicSetInterLayer != 0 ); |
---|
3864 | |
---|
3865 | TComPic* pcPic = NULL; |
---|
3866 | for ( Int i = 0; i < (*refPicSetInterLayer).size(); i++ ) |
---|
3867 | { |
---|
3868 | if ((*refPicSetInterLayer)[ i ]->getLayerId() == layerId ) |
---|
3869 | { |
---|
3870 | pcPic = (*refPicSetInterLayer)[ i ]; |
---|
3871 | } |
---|
3872 | } |
---|
3873 | |
---|
3874 | assert(pcPic != NULL); |
---|
3875 | return pcPic; |
---|
3876 | } |
---|
3877 | |
---|
3878 | |
---|
3879 | Int TComSlice::getRefLayerPicFlag( Int i ) |
---|
3880 | { |
---|
3881 | TComVPS* vps = getVPS(); |
---|
3882 | #if H_MV_HLS10_REF_PRED_LAYERS |
---|
3883 | Int refLayerIdx = vps->getLayerIdInVps( vps->getIdDirectRefLayer( getLayerId(), i ) ); |
---|
3884 | #else |
---|
3885 | Int refLayerIdx = vps->getLayerIdInVps( vps->getRefLayerId( getLayerId(), i ) ); |
---|
3886 | #endif |
---|
3887 | |
---|
3888 | Bool refLayerPicFlag = ( vps->getSubLayersVpsMaxMinus1( refLayerIdx ) >= getTLayer() ) && ( getTLayer() == 0 ) && |
---|
3889 | ( vps->getMaxTidIlRefPicsPlus1( refLayerIdx, vps->getLayerIdInVps( getLayerId() )) > getTLayer() ); |
---|
3890 | |
---|
3891 | return refLayerPicFlag; |
---|
3892 | } |
---|
3893 | |
---|
3894 | Int TComSlice::getRefLayerPicIdc( Int j ) |
---|
3895 | { |
---|
3896 | Int refLayerPicIdc = -1; |
---|
3897 | Int curj = 0; |
---|
3898 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ ) |
---|
3899 | { |
---|
3900 | if( getRefLayerPicFlag( i ) ) |
---|
3901 | { |
---|
3902 | if ( curj == j ) |
---|
3903 | { |
---|
3904 | refLayerPicIdc = i; |
---|
3905 | break; |
---|
3906 | } |
---|
3907 | curj++; |
---|
3908 | } |
---|
3909 | } |
---|
3910 | |
---|
3911 | assert( curj == j ); |
---|
3912 | assert( refLayerPicIdc != -1 ); |
---|
3913 | return refLayerPicIdc; |
---|
3914 | } |
---|
3915 | |
---|
3916 | Int TComSlice::getNumRefLayerPics( ) |
---|
3917 | { |
---|
3918 | Int numRefLayerPics = 0; |
---|
3919 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ ) |
---|
3920 | { |
---|
3921 | numRefLayerPics += getRefLayerPicFlag( i ); |
---|
3922 | } |
---|
3923 | return numRefLayerPics; |
---|
3924 | } |
---|
3925 | |
---|
3926 | |
---|
3927 | |
---|
3928 | Int TComSlice::getNumActiveRefLayerPics() |
---|
3929 | { |
---|
3930 | Int numActiveRefLayerPics; |
---|
3931 | |
---|
3932 | if( getLayerId() == 0 || getNumRefLayerPics() == 0 ) |
---|
3933 | { |
---|
3934 | numActiveRefLayerPics = 0; |
---|
3935 | } |
---|
3936 | else if (getVPS()->getAllRefLayersActiveFlag() ) |
---|
3937 | { |
---|
3938 | numActiveRefLayerPics = getNumRefLayerPics(); |
---|
3939 | } |
---|
3940 | else if ( !getInterLayerPredEnabledFlag() ) |
---|
3941 | { |
---|
3942 | numActiveRefLayerPics = 0; |
---|
3943 | } |
---|
3944 | else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumDirectRefLayers( getLayerId() ) == 1 ) |
---|
3945 | { |
---|
3946 | numActiveRefLayerPics = 1; |
---|
3947 | } |
---|
3948 | else |
---|
3949 | { |
---|
3950 | numActiveRefLayerPics = getNumInterLayerRefPicsMinus1() + 1; |
---|
3951 | } |
---|
3952 | return numActiveRefLayerPics; |
---|
3953 | } |
---|
3954 | |
---|
3955 | Int TComSlice::getRefPicLayerId( Int i ) |
---|
3956 | { |
---|
3957 | #if H_MV_HLS10_REF_PRED_LAYERS |
---|
3958 | return getVPS()->getIdDirectRefLayer( getLayerId(), getInterLayerPredLayerIdc( i ) ); |
---|
3959 | #else |
---|
3960 | return getVPS()->getRefLayerId( getLayerId(), getInterLayerPredLayerIdc( i ) ); |
---|
3961 | #endif |
---|
3962 | } |
---|
3963 | |
---|
3964 | #if H_3D_ARP |
---|
3965 | Void TComSlice::setARPStepNum( TComPicLists*ivPicLists ) |
---|
3966 | { |
---|
3967 | Bool tempRefPicInListsFlag = false; |
---|
3968 | if(!getVPS()->getUseAdvRP(getLayerId()) || this->isIRAP()) |
---|
3969 | { |
---|
3970 | m_nARPStepNum = 0; |
---|
3971 | } |
---|
3972 | else |
---|
3973 | { |
---|
3974 | setFirstTRefIdx (REF_PIC_LIST_0, -1); |
---|
3975 | setFirstTRefIdx (REF_PIC_LIST_1, -1); |
---|
3976 | for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ ) |
---|
3977 | { |
---|
3978 | Int diffPOC=MAX_INT; |
---|
3979 | Int idx=-1; |
---|
3980 | for(Int i = 0; i < getNumRefIdx(RefPicList(refListIdx)); i++ ) |
---|
3981 | { |
---|
3982 | if ( getRefPic(RefPicList(refListIdx), i)->getPOC() != getPOC() ) |
---|
3983 | { |
---|
3984 | if( abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC()) < diffPOC) |
---|
3985 | { |
---|
3986 | diffPOC=abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC()); |
---|
3987 | idx=i; |
---|
3988 | } |
---|
3989 | } |
---|
3990 | if(idx>=0) |
---|
3991 | { |
---|
3992 | setFirstTRefIdx (RefPicList(refListIdx), idx); |
---|
3993 | } |
---|
3994 | } |
---|
3995 | } |
---|
3996 | tempRefPicInListsFlag = getFirstTRefIdx(REF_PIC_LIST_0) >= 0 || getFirstTRefIdx(REF_PIC_LIST_1) >= 0; |
---|
3997 | m_nARPStepNum = tempRefPicInListsFlag ? getVPS()->getARPStepNum(getLayerId()) : 0; |
---|
3998 | } |
---|
3999 | |
---|
4000 | if (tempRefPicInListsFlag) |
---|
4001 | { |
---|
4002 | for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ ) |
---|
4003 | { |
---|
4004 | RefPicList eRefPicList = RefPicList( refListIdx ); |
---|
4005 | Int prevPOC = getRefPic(eRefPicList, getFirstTRefIdx(eRefPicList) )->getPOC(); |
---|
4006 | for( Int i = 0; i < getNumActiveRefLayerPics(); i++ ) |
---|
4007 | { |
---|
4008 | Int layerIdInNuh = getRefPicLayerId( i ); |
---|
4009 | Int viewIdx = getVPS()->getViewId( layerIdInNuh ); |
---|
4010 | TComPic*pcPicPrev = ivPicLists->getPic(viewIdx, 0, prevPOC); |
---|
4011 | if (getFirstTRefIdx(eRefPicList) >= 0 && pcPicPrev && pcPicPrev->getSlice( 0 )->isReferenced()) |
---|
4012 | { |
---|
4013 | m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = true; |
---|
4014 | } |
---|
4015 | else |
---|
4016 | { |
---|
4017 | m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = false; |
---|
4018 | } |
---|
4019 | } |
---|
4020 | } |
---|
4021 | } |
---|
4022 | } |
---|
4023 | #endif |
---|
4024 | #if H_3D_IC |
---|
4025 | Void TComSlice::xSetApplyIC(Bool bUseLowLatencyICEnc) |
---|
4026 | { |
---|
4027 | if(bUseLowLatencyICEnc) |
---|
4028 | { |
---|
4029 | Bool existInterViewRef=false; |
---|
4030 | TComPic* pcCurrPic = getPic(); |
---|
4031 | TComPic* pcRefPic = NULL; |
---|
4032 | for ( Int i = 0; (i < getNumRefIdx( REF_PIC_LIST_0 )) && !existInterViewRef; i++ ) |
---|
4033 | { |
---|
4034 | pcRefPic = getRefPic( REF_PIC_LIST_0, i ); |
---|
4035 | if ( pcRefPic != NULL ) |
---|
4036 | { |
---|
4037 | if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() ) |
---|
4038 | { |
---|
4039 | existInterViewRef = true; |
---|
4040 | } |
---|
4041 | } |
---|
4042 | } |
---|
4043 | |
---|
4044 | for ( Int i = 0; (i < getNumRefIdx( REF_PIC_LIST_1 )) && !existInterViewRef; i++ ) |
---|
4045 | { |
---|
4046 | pcRefPic = getRefPic( REF_PIC_LIST_1, i ); |
---|
4047 | if ( pcRefPic != NULL ) |
---|
4048 | { |
---|
4049 | if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() ) |
---|
4050 | { |
---|
4051 | existInterViewRef = true; |
---|
4052 | } |
---|
4053 | } |
---|
4054 | } |
---|
4055 | |
---|
4056 | if(!existInterViewRef) |
---|
4057 | { |
---|
4058 | m_bApplyIC = false; |
---|
4059 | } |
---|
4060 | else |
---|
4061 | { |
---|
4062 | Int curLayer=getDepth(); |
---|
4063 | if( curLayer>9) curLayer=9; // Max layer is 10 |
---|
4064 | |
---|
4065 | m_bApplyIC = true; |
---|
4066 | Int refLayer = curLayer-1; |
---|
4067 | #if MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX |
---|
4068 | Int ICEnableCandidate = getICEnableCandidate(refLayer); |
---|
4069 | Int ICEnableNum = getICEnableNum(refLayer); |
---|
4070 | if( (refLayer>=0) && (ICEnableCandidate>0) ) |
---|
4071 | { |
---|
4072 | Double ratio=Double(ICEnableNum/Double(ICEnableCandidate)); |
---|
4073 | |
---|
4074 | if( ratio > IC_LOW_LATENCY_ENCODING_THRESHOLD) |
---|
4075 | { |
---|
4076 | m_bApplyIC=true; |
---|
4077 | } |
---|
4078 | else |
---|
4079 | { |
---|
4080 | m_bApplyIC=false; |
---|
4081 | } |
---|
4082 | } |
---|
4083 | setICEnableCandidate(curLayer, 0); |
---|
4084 | setICEnableNum(curLayer, 0); |
---|
4085 | #else |
---|
4086 | if( (refLayer>=0) && (g_aICEnableCANDIDATE[refLayer]>0) ) |
---|
4087 | { |
---|
4088 | Double ratio=Double(g_aICEnableNUM[refLayer])/Double(g_aICEnableCANDIDATE[refLayer]); |
---|
4089 | |
---|
4090 | if( ratio > IC_LOW_LATENCY_ENCODING_THRESHOLD) |
---|
4091 | { |
---|
4092 | m_bApplyIC=true; |
---|
4093 | } |
---|
4094 | else |
---|
4095 | { |
---|
4096 | m_bApplyIC=false; |
---|
4097 | } |
---|
4098 | } |
---|
4099 | g_aICEnableNUM[curLayer]=0; |
---|
4100 | g_aICEnableCANDIDATE[curLayer]=0; |
---|
4101 | g_lastlayer=getDepth(); |
---|
4102 | #endif |
---|
4103 | } |
---|
4104 | } |
---|
4105 | else |
---|
4106 | { |
---|
4107 | Int iMaxPelValue = ( 1 << g_bitDepthY ); |
---|
4108 | Int *aiRefOrgHist; |
---|
4109 | Int *aiCurrHist; |
---|
4110 | aiRefOrgHist = (Int *) xMalloc( Int,iMaxPelValue ); |
---|
4111 | aiCurrHist = (Int *) xMalloc( Int,iMaxPelValue ); |
---|
4112 | memset( aiRefOrgHist, 0, iMaxPelValue*sizeof(Int) ); |
---|
4113 | memset( aiCurrHist, 0, iMaxPelValue*sizeof(Int) ); |
---|
4114 | // Reference Idx Number |
---|
4115 | Int iNumRefIdx = getNumRefIdx( REF_PIC_LIST_0 ); |
---|
4116 | TComPic* pcCurrPic = NULL; |
---|
4117 | TComPic* pcRefPic = NULL; |
---|
4118 | TComPicYuv* pcCurrPicYuv = NULL; |
---|
4119 | TComPicYuv* pcRefPicYuvOrg = NULL; |
---|
4120 | pcCurrPic = getPic(); |
---|
4121 | pcCurrPicYuv = pcCurrPic->getPicYuvOrg(); |
---|
4122 | Int iWidth = pcCurrPicYuv->getWidth(); |
---|
4123 | Int iHeight = pcCurrPicYuv->getHeight(); |
---|
4124 | |
---|
4125 | |
---|
4126 | // Get InterView Reference picture |
---|
4127 | // !!!!! Assume only one Interview Reference Picture in L0 |
---|
4128 | for ( Int i = 0; i < iNumRefIdx; i++ ) |
---|
4129 | { |
---|
4130 | pcRefPic = getRefPic( REF_PIC_LIST_0, i ); |
---|
4131 | if ( pcRefPic != NULL ) |
---|
4132 | { |
---|
4133 | if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() ) |
---|
4134 | { |
---|
4135 | pcRefPicYuvOrg = pcRefPic->getPicYuvOrg(); |
---|
4136 | } |
---|
4137 | } |
---|
4138 | } |
---|
4139 | |
---|
4140 | if ( pcRefPicYuvOrg != NULL ) |
---|
4141 | { |
---|
4142 | Pel* pCurrY = pcCurrPicYuv ->getLumaAddr(); |
---|
4143 | Pel* pRefOrgY = pcRefPicYuvOrg ->getLumaAddr(); |
---|
4144 | Int iCurrStride = pcCurrPicYuv->getStride(); |
---|
4145 | Int iRefStride = pcRefPicYuvOrg->getStride(); |
---|
4146 | Int iSumOrgSAD = 0; |
---|
4147 | Double dThresholdOrgSAD = getIsDepth() ? 0.1 : 0.05; |
---|
4148 | |
---|
4149 | // Histogram building - luminance |
---|
4150 | for ( Int y = 0; y < iHeight; y++ ) |
---|
4151 | { |
---|
4152 | for ( Int x = 0; x < iWidth; x++ ) |
---|
4153 | { |
---|
4154 | aiCurrHist[pCurrY[x]]++; |
---|
4155 | aiRefOrgHist[pRefOrgY[x]]++; |
---|
4156 | } |
---|
4157 | pCurrY += iCurrStride; |
---|
4158 | pRefOrgY += iRefStride; |
---|
4159 | } |
---|
4160 | // Histogram SAD |
---|
4161 | for ( Int i = 0; i < iMaxPelValue; i++ ) |
---|
4162 | { |
---|
4163 | iSumOrgSAD += abs( aiCurrHist[i] - aiRefOrgHist[i] ); |
---|
4164 | } |
---|
4165 | // Setting |
---|
4166 | if ( iSumOrgSAD > Int( dThresholdOrgSAD * iWidth * iHeight ) ) |
---|
4167 | { |
---|
4168 | m_bApplyIC = true; |
---|
4169 | } |
---|
4170 | else |
---|
4171 | { |
---|
4172 | m_bApplyIC = false; |
---|
4173 | } |
---|
4174 | } |
---|
4175 | |
---|
4176 | xFree( aiCurrHist ); |
---|
4177 | xFree( aiRefOrgHist ); |
---|
4178 | aiCurrHist = NULL; |
---|
4179 | aiRefOrgHist = NULL; |
---|
4180 | }//if(bUseLowLatencyICEnc) |
---|
4181 | } |
---|
4182 | #endif |
---|
4183 | #if H_3D |
---|
4184 | Void TComSlice::setIvPicLists( TComPicLists* m_ivPicLists ) |
---|
4185 | { |
---|
4186 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
4187 | { |
---|
4188 | for ( Int depthId = 0; depthId < 2; depthId++ ) |
---|
4189 | { |
---|
4190 | m_ivPicsCurrPoc[ depthId ][ i ] = ( i <= m_viewIndex ) ? m_ivPicLists->getPic( i, ( depthId == 1) , getPOC() ) : NULL; |
---|
4191 | } |
---|
4192 | } |
---|
4193 | } |
---|
4194 | Void TComSlice::setDepthToDisparityLUTs() |
---|
4195 | { |
---|
4196 | Bool setupLUT = false; |
---|
4197 | Int layerIdInVPS = getVPS()->getLayerIdInNuh( m_layerId ); |
---|
4198 | |
---|
4199 | #if H_3D_VSP |
---|
4200 | setupLUT = setupLUT || getVPS()->getViewSynthesisPredFlag( layerIdInVPS); |
---|
4201 | #endif |
---|
4202 | |
---|
4203 | #if H_3D_NBDV_REF |
---|
4204 | setupLUT = setupLUT || getVPS()->getDepthRefinementFlag( layerIdInVPS ); |
---|
4205 | #endif |
---|
4206 | |
---|
4207 | #if H_3D_IV_MERGE |
---|
4208 | setupLUT = setupLUT || ( getVPS()->getIvMvPredFlag(layerIdInVPS ) && getIsDepth() ); |
---|
4209 | #endif |
---|
4210 | |
---|
4211 | #if H_3D_DDD |
---|
4212 | #if LGE_FCO_I0116 |
---|
4213 | if( getIsDepth() && getViewIndex() > 0 && getVPS()->getMPIFlag(layerIdInVPS)) |
---|
4214 | #else |
---|
4215 | if( getIsDepth() && getViewIndex() > 0 ) |
---|
4216 | #endif |
---|
4217 | { |
---|
4218 | TComSlice *pcTextSlice = getTexturePic()->getSlice( 0 ); |
---|
4219 | memcpy( m_aiDDDInvScale, pcTextSlice->m_aiDDDInvScale, sizeof( Int ) * getViewIndex() ); |
---|
4220 | memcpy( m_aiDDDInvOffset, pcTextSlice->m_aiDDDInvOffset, sizeof( Int ) * getViewIndex() ); |
---|
4221 | memcpy( m_aiDDDShift, pcTextSlice->m_aiDDDShift, sizeof( Int ) * getViewIndex() ); |
---|
4222 | } |
---|
4223 | #endif |
---|
4224 | |
---|
4225 | if( !setupLUT ) |
---|
4226 | return; |
---|
4227 | |
---|
4228 | /// GT: Allocation should be moved to a better place later; |
---|
4229 | if ( m_depthToDisparityB == NULL ) |
---|
4230 | { |
---|
4231 | m_depthToDisparityB = new Int*[ getViewIndex() ]; |
---|
4232 | for ( Int i = 0; i < getViewIndex(); i++ ) |
---|
4233 | { |
---|
4234 | m_depthToDisparityB[ i ] = new Int[ Int(1 << g_bitDepthY) ]; |
---|
4235 | } |
---|
4236 | } |
---|
4237 | |
---|
4238 | if ( m_depthToDisparityF == NULL ) |
---|
4239 | { |
---|
4240 | m_depthToDisparityF= new Int*[ getViewIndex() ]; |
---|
4241 | for ( Int i = 0; i < getViewIndex(); i++ ) |
---|
4242 | { |
---|
4243 | m_depthToDisparityF[ i ] = new Int[ Int(1 << g_bitDepthY) ]; |
---|
4244 | } |
---|
4245 | } |
---|
4246 | |
---|
4247 | assert( m_depthToDisparityB != NULL ); |
---|
4248 | assert( m_depthToDisparityF != NULL ); |
---|
4249 | |
---|
4250 | TComVPS* vps = getVPS(); |
---|
4251 | |
---|
4252 | Int log2Div = g_bitDepthY - 1 + vps->getCamParPrecision(); |
---|
4253 | Int viewIndex = getViewIndex(); |
---|
4254 | |
---|
4255 | Bool camParaSH = vps->hasCamParInSliceHeader( viewIndex ); |
---|
4256 | |
---|
4257 | Int* codScale = camParaSH ? m_aaiCodedScale [ 0 ] : vps->getCodedScale ( viewIndex ); |
---|
4258 | Int* codOffset = camParaSH ? m_aaiCodedOffset[ 0 ] : vps->getCodedOffset ( viewIndex ); |
---|
4259 | Int* invCodScale = camParaSH ? m_aaiCodedScale [ 1 ] : vps->getInvCodedScale ( viewIndex ); |
---|
4260 | Int* invCodOffset = camParaSH ? m_aaiCodedOffset[ 1 ] : vps->getInvCodedOffset( viewIndex ); |
---|
4261 | |
---|
4262 | for (Int i = 0; i <= ( getViewIndex() - 1); i++) |
---|
4263 | { |
---|
4264 | for ( Int d = 0; d <= ( ( 1 << g_bitDepthY ) - 1 ); d++ ) |
---|
4265 | { |
---|
4266 | Int offset = ( codOffset [ i ] << g_bitDepthY ) + ( ( 1 << log2Div ) >> 1 ); |
---|
4267 | m_depthToDisparityB[ i ][ d ] = ( codScale [ i ] * d + offset ) >> log2Div; |
---|
4268 | |
---|
4269 | Int invOffset = ( invCodOffset[ i ] << g_bitDepthY ) + ( ( 1 << log2Div ) >> 1 ); |
---|
4270 | m_depthToDisparityF[ i ][ d ] = ( invCodScale[ i ] * d + invOffset ) >> log2Div; |
---|
4271 | } |
---|
4272 | |
---|
4273 | #if H_3D_DDD |
---|
4274 | initializeDDDPara( vps->getCamParPrecision(), codScale[ i ], codOffset[ i ], i ); |
---|
4275 | #endif |
---|
4276 | } |
---|
4277 | } |
---|
4278 | #endif |
---|
4279 | #endif |
---|
4280 | |
---|
4281 | #if H_3D_DDD |
---|
4282 | Void TComSlice::initializeDDDPara( UInt uiCamParsCodedPrecision, Int iCodedScale,Int iCodedOffset, Int iBaseViewIdx ) |
---|
4283 | { |
---|
4284 | UInt uiViewId = getViewIndex(); |
---|
4285 | |
---|
4286 | if( uiViewId == 0 ) |
---|
4287 | { |
---|
4288 | m_aiDDDInvScale[ iBaseViewIdx ] = m_aiDDDInvOffset[ iBaseViewIdx ] = m_aiDDDShift[ iBaseViewIdx ] = 0; |
---|
4289 | return; |
---|
4290 | } |
---|
4291 | |
---|
4292 | |
---|
4293 | Int iSign = iCodedScale >= 0 ? 1 : -1; |
---|
4294 | iCodedScale = abs( iCodedScale ); |
---|
4295 | |
---|
4296 | Int iBitWidth = 0; |
---|
4297 | |
---|
4298 | const Int iInvPres = 9; |
---|
4299 | |
---|
4300 | while( ((( 1 << iBitWidth ) << 1 ) <= iCodedScale ) ) |
---|
4301 | { |
---|
4302 | iBitWidth ++; |
---|
4303 | } |
---|
4304 | iBitWidth += iInvPres; |
---|
4305 | Int iTargetValue = 1 << iBitWidth; |
---|
4306 | |
---|
4307 | Int iMinError = MAX_INT; |
---|
4308 | Int iBestD = 1 << ( iInvPres - 1 ); |
---|
4309 | for( Int d = 1 << ( iInvPres - 1 ); d < ( 1 << iInvPres ); d++ ) |
---|
4310 | { |
---|
4311 | Int iError = abs( iCodedScale * d - iTargetValue ); |
---|
4312 | if( iError < iMinError ) |
---|
4313 | { |
---|
4314 | iMinError = iError; |
---|
4315 | iBestD = d; |
---|
4316 | } |
---|
4317 | if( iMinError == 0 ) |
---|
4318 | { |
---|
4319 | break; |
---|
4320 | } |
---|
4321 | } |
---|
4322 | Int iRoundingDir = 0; |
---|
4323 | if( iCodedScale * iBestD > iTargetValue ) |
---|
4324 | { |
---|
4325 | iRoundingDir = -1; |
---|
4326 | } |
---|
4327 | else if( iCodedScale * iBestD < iTargetValue ) |
---|
4328 | { |
---|
4329 | iRoundingDir = 1; |
---|
4330 | } |
---|
4331 | Int iCamPres = uiCamParsCodedPrecision - 1; |
---|
4332 | m_aiDDDInvScale [ iBaseViewIdx ] = ( iBestD << ( iCamPres + g_bitDepthY )) * iSign; |
---|
4333 | m_aiDDDInvOffset[ iBaseViewIdx ] = -iSign * iBestD * ( iCodedOffset << g_bitDepthY ); |
---|
4334 | m_aiDDDShift [ iBaseViewIdx ] = iBitWidth; |
---|
4335 | m_aiDDDInvOffset[ iBaseViewIdx ] += 1 << ( m_aiDDDShift[ iBaseViewIdx ] - 1 ); |
---|
4336 | m_aiDDDInvOffset[ iBaseViewIdx ] += ( 1 << ( m_aiDDDShift[ iBaseViewIdx ] - 4 ) ) * iRoundingDir; |
---|
4337 | |
---|
4338 | return; |
---|
4339 | } |
---|
4340 | |
---|
4341 | |
---|
4342 | #endif |
---|
4343 | |
---|
4344 | #if H_MV |
---|
4345 | Void TComSlice::checkCrossLayerBlaFlag() |
---|
4346 | { |
---|
4347 | // cross_layer_bla_flag shall be equal to 0 for pictures with nal_unit_type not equal to IDR_W_RADL or IDR_N_LP or with nuh_layer_id not equal to 0. |
---|
4348 | if ( getLayerId() != 0 || getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
4349 | { |
---|
4350 | assert( m_crossLayerBlaFlag == 0 ); |
---|
4351 | } |
---|
4352 | } |
---|
4353 | |
---|
4354 | Bool TComSlice::inferPocMsbValPresentFlag() |
---|
4355 | { |
---|
4356 | Bool pocMsbValPresentFlag; |
---|
4357 | if( getSliceSegmentHeaderExtensionLength() == 0 ) |
---|
4358 | { |
---|
4359 | pocMsbValPresentFlag = false; |
---|
4360 | } |
---|
4361 | else if ( getPocMsbValRequiredFlag() ) |
---|
4362 | { |
---|
4363 | pocMsbValPresentFlag = true; |
---|
4364 | } |
---|
4365 | else |
---|
4366 | { |
---|
4367 | pocMsbValPresentFlag = false; |
---|
4368 | } |
---|
4369 | |
---|
4370 | return pocMsbValPresentFlag; |
---|
4371 | } |
---|
4372 | |
---|
4373 | |
---|
4374 | #endif |
---|
4375 | |
---|
4376 | #if H_3D_DBBP |
---|
4377 | Int TComSlice::getDepthFromDV( Int iDV, Int iBaseViewIdx ) |
---|
4378 | { |
---|
4379 | return ClipY(( iDV * m_aiDDDInvScale[ iBaseViewIdx ] + m_aiDDDInvOffset[ iBaseViewIdx ] ) >> m_aiDDDShift[ iBaseViewIdx ]); |
---|
4380 | } |
---|
4381 | #endif |
---|
4382 | |
---|
4383 | /** get scaling matrix from RefMatrixID |
---|
4384 | * \param sizeId size index |
---|
4385 | * \param Index of input matrix |
---|
4386 | * \param Index of reference matrix |
---|
4387 | */ |
---|
4388 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
4389 | { |
---|
4390 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
4391 | } |
---|
4392 | |
---|
4393 | /** parse syntax infomation |
---|
4394 | * \param pchFile syntax infomation |
---|
4395 | * \returns false if successful |
---|
4396 | */ |
---|
4397 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
4398 | { |
---|
4399 | FILE *fp; |
---|
4400 | Char line[1024]; |
---|
4401 | UInt sizeIdc,listIdc; |
---|
4402 | UInt i,size = 0; |
---|
4403 | Int *src=0,data; |
---|
4404 | Char *ret; |
---|
4405 | UInt retval; |
---|
4406 | |
---|
4407 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
4408 | { |
---|
4409 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
4410 | return true; |
---|
4411 | } |
---|
4412 | |
---|
4413 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
4414 | { |
---|
4415 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
4416 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
4417 | { |
---|
4418 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
4419 | |
---|
4420 | fseek(fp,0,0); |
---|
4421 | do |
---|
4422 | { |
---|
4423 | ret = fgets(line, 1024, fp); |
---|
4424 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
4425 | { |
---|
4426 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
4427 | return true; |
---|
4428 | } |
---|
4429 | } |
---|
4430 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
4431 | for (i=0; i<size; i++) |
---|
4432 | { |
---|
4433 | retval = fscanf(fp, "%d,", &data); |
---|
4434 | if (retval!=1) |
---|
4435 | { |
---|
4436 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
4437 | return true; |
---|
4438 | } |
---|
4439 | src[i] = data; |
---|
4440 | } |
---|
4441 | //set DC value for default matrix check |
---|
4442 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
4443 | |
---|
4444 | if(sizeIdc > SCALING_LIST_8x8) |
---|
4445 | { |
---|
4446 | fseek(fp,0,0); |
---|
4447 | do |
---|
4448 | { |
---|
4449 | ret = fgets(line, 1024, fp); |
---|
4450 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
4451 | { |
---|
4452 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
4453 | return true; |
---|
4454 | } |
---|
4455 | } |
---|
4456 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
4457 | retval = fscanf(fp, "%d,", &data); |
---|
4458 | if (retval!=1) |
---|
4459 | { |
---|
4460 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
4461 | return true; |
---|
4462 | } |
---|
4463 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
4464 | setScalingListDC(sizeIdc,listIdc,data); |
---|
4465 | } |
---|
4466 | } |
---|
4467 | } |
---|
4468 | fclose(fp); |
---|
4469 | return false; |
---|
4470 | } |
---|
4471 | |
---|
4472 | #if H_MV |
---|
4473 | Void TComScalingList::inferFrom( TComScalingList* srcScLi ) |
---|
4474 | { |
---|
4475 | for(Int sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
4476 | { |
---|
4477 | for(Int listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
4478 | { |
---|
4479 | setRefMatrixId (sizeId,listId, srcScLi->getRefMatrixId (sizeId,listId)); |
---|
4480 | setScalingListDC(sizeId,listId, srcScLi->getScalingListDC(sizeId,listId)); |
---|
4481 | ::memcpy(getScalingListAddress(sizeId, listId),srcScLi->getScalingListAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
4482 | } |
---|
4483 | } |
---|
4484 | } |
---|
4485 | #endif |
---|
4486 | /** initialization process of quantization matrix array |
---|
4487 | */ |
---|
4488 | Void TComScalingList::init() |
---|
4489 | { |
---|
4490 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
4491 | { |
---|
4492 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
4493 | { |
---|
4494 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
4495 | } |
---|
4496 | } |
---|
4497 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
4498 | } |
---|
4499 | |
---|
4500 | /** destroy quantization matrix array |
---|
4501 | */ |
---|
4502 | Void TComScalingList::destroy() |
---|
4503 | { |
---|
4504 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
4505 | { |
---|
4506 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
4507 | { |
---|
4508 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
4509 | } |
---|
4510 | } |
---|
4511 | } |
---|
4512 | |
---|
4513 | /** get default address of quantization matrix |
---|
4514 | * \param sizeId size index |
---|
4515 | * \param listId list index |
---|
4516 | * \returns pointer of quantization matrix |
---|
4517 | */ |
---|
4518 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
4519 | { |
---|
4520 | Int *src = 0; |
---|
4521 | switch(sizeId) |
---|
4522 | { |
---|
4523 | case SCALING_LIST_4x4: |
---|
4524 | src = g_quantTSDefault4x4; |
---|
4525 | break; |
---|
4526 | case SCALING_LIST_8x8: |
---|
4527 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
4528 | break; |
---|
4529 | case SCALING_LIST_16x16: |
---|
4530 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
4531 | break; |
---|
4532 | case SCALING_LIST_32x32: |
---|
4533 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
4534 | break; |
---|
4535 | default: |
---|
4536 | assert(0); |
---|
4537 | src = NULL; |
---|
4538 | break; |
---|
4539 | } |
---|
4540 | return src; |
---|
4541 | } |
---|
4542 | |
---|
4543 | /** process of default matrix |
---|
4544 | * \param sizeId size index |
---|
4545 | * \param Index of input matrix |
---|
4546 | */ |
---|
4547 | Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId) |
---|
4548 | { |
---|
4549 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
4550 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
4551 | } |
---|
4552 | |
---|
4553 | /** check DC value of matrix for default matrix signaling |
---|
4554 | */ |
---|
4555 | Void TComScalingList::checkDcOfMatrix() |
---|
4556 | { |
---|
4557 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
4558 | { |
---|
4559 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
4560 | { |
---|
4561 | //check default matrix? |
---|
4562 | if(getScalingListDC(sizeId,listId) == 0) |
---|
4563 | { |
---|
4564 | processDefaultMatrix(sizeId, listId); |
---|
4565 | } |
---|
4566 | } |
---|
4567 | } |
---|
4568 | } |
---|
4569 | |
---|
4570 | ParameterSetManager::ParameterSetManager() |
---|
4571 | : m_vpsMap(MAX_NUM_VPS) |
---|
4572 | , m_spsMap(MAX_NUM_SPS) |
---|
4573 | , m_ppsMap(MAX_NUM_PPS) |
---|
4574 | , m_activeVPSId(-1) |
---|
4575 | #if !H_MV |
---|
4576 | , m_activeSPSId(-1) |
---|
4577 | , m_activePPSId(-1) |
---|
4578 | { |
---|
4579 | #else |
---|
4580 | { |
---|
4581 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
4582 | { |
---|
4583 | m_activeSPSId[ i ] = -1; |
---|
4584 | m_activePPSId[ i ] = -1; |
---|
4585 | } |
---|
4586 | #endif |
---|
4587 | } |
---|
4588 | |
---|
4589 | |
---|
4590 | ParameterSetManager::~ParameterSetManager() |
---|
4591 | { |
---|
4592 | } |
---|
4593 | |
---|
4594 | //! activate a SPS from a active parameter sets SEI message |
---|
4595 | //! \returns true, if activation is successful |
---|
4596 | #if H_MV |
---|
4597 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId, Int layerId ) |
---|
4598 | #else |
---|
4599 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
4600 | #endif |
---|
4601 | { |
---|
4602 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
4603 | if (sps) |
---|
4604 | { |
---|
4605 | Int vpsId = sps->getVPSId(); |
---|
4606 | if (m_vpsMap.getPS(vpsId)) |
---|
4607 | { |
---|
4608 | m_activeVPSId = vpsId; |
---|
4609 | #if H_MV |
---|
4610 | m_activeSPSId[ layerId ] = spsId; |
---|
4611 | #else |
---|
4612 | m_activeSPSId = spsId; |
---|
4613 | #endif |
---|
4614 | return true; |
---|
4615 | } |
---|
4616 | else |
---|
4617 | { |
---|
4618 | printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
4619 | } |
---|
4620 | } |
---|
4621 | else |
---|
4622 | { |
---|
4623 | printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
4624 | } |
---|
4625 | return false; |
---|
4626 | } |
---|
4627 | |
---|
4628 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
4629 | //! \returns true, if activation is successful |
---|
4630 | #if H_MV |
---|
4631 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP, Int layerId ) |
---|
4632 | #else |
---|
4633 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
4634 | #endif |
---|
4635 | { |
---|
4636 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
4637 | if (pps) |
---|
4638 | { |
---|
4639 | Int spsId = pps->getSPSId(); |
---|
4640 | #if H_MV |
---|
4641 | if (!isIRAP && (spsId != m_activeSPSId[ layerId ])) |
---|
4642 | #else |
---|
4643 | if (!isIRAP && (spsId != m_activeSPSId)) |
---|
4644 | #endif |
---|
4645 | { |
---|
4646 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IRAP."); |
---|
4647 | return false; |
---|
4648 | } |
---|
4649 | |
---|
4650 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
4651 | if (sps) |
---|
4652 | { |
---|
4653 | Int vpsId = sps->getVPSId(); |
---|
4654 | if (!isIRAP && (vpsId != m_activeVPSId)) |
---|
4655 | { |
---|
4656 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IRAP."); |
---|
4657 | return false; |
---|
4658 | } |
---|
4659 | if (m_vpsMap.getPS(vpsId)) |
---|
4660 | { |
---|
4661 | #if H_MV |
---|
4662 | m_activePPSId[ layerId ] = ppsId; |
---|
4663 | m_activeVPSId = vpsId; |
---|
4664 | m_activeSPSId[ layerId ] = spsId; |
---|
4665 | #else |
---|
4666 | m_activePPSId = ppsId; |
---|
4667 | m_activeVPSId = vpsId; |
---|
4668 | m_activeSPSId = spsId; |
---|
4669 | #endif |
---|
4670 | return true; |
---|
4671 | } |
---|
4672 | else |
---|
4673 | { |
---|
4674 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
4675 | } |
---|
4676 | } |
---|
4677 | else |
---|
4678 | { |
---|
4679 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
4680 | } |
---|
4681 | } |
---|
4682 | else |
---|
4683 | { |
---|
4684 | printf("Warning: tried to activate non-existing PPS."); |
---|
4685 | } |
---|
4686 | return false; |
---|
4687 | } |
---|
4688 | |
---|
4689 | ProfileTierLevel::ProfileTierLevel() |
---|
4690 | : m_profileSpace (0) |
---|
4691 | , m_tierFlag (false) |
---|
4692 | , m_profileIdc (0) |
---|
4693 | , m_levelIdc (0) |
---|
4694 | , m_progressiveSourceFlag (false) |
---|
4695 | , m_interlacedSourceFlag (false) |
---|
4696 | , m_nonPackedConstraintFlag(false) |
---|
4697 | , m_frameOnlyConstraintFlag(false) |
---|
4698 | #if H_MV_HLS10_PTL |
---|
4699 | , m_max12bitConstraintFlag ( false ) |
---|
4700 | , m_max10bitConstraintFlag ( false ) |
---|
4701 | , m_max8bitConstraintFlag ( false ) |
---|
4702 | , m_max422chromaConstraintFlag ( false ) |
---|
4703 | , m_max420chromaConstraintFlag ( false ) |
---|
4704 | , m_maxMonochromeConstraintFlag ( false ) |
---|
4705 | , m_intraConstraintFlag ( false ) |
---|
4706 | , m_onePictureOnlyConstraintFlag( false ) |
---|
4707 | , m_lowerBitRateConstraintFlag ( false ) |
---|
4708 | , m_inbldFlag ( false ) |
---|
4709 | #endif |
---|
4710 | { |
---|
4711 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
4712 | } |
---|
4713 | |
---|
4714 | #if H_MV_HLS10_PTL_INFER_FIX |
---|
4715 | Bool ProfileTierLevel::getV2ConstraintsPresentFlag() |
---|
4716 | { |
---|
4717 | return ( |
---|
4718 | getProfileIdc( ) == 4 || getProfileCompatibilityFlag( 4 ) || getProfileIdc( ) == 5 || getProfileCompatibilityFlag( 5 ) || |
---|
4719 | getProfileIdc( ) == 6 || getProfileCompatibilityFlag( 6 ) || getProfileIdc( ) == 7 || getProfileCompatibilityFlag( 7 ) |
---|
4720 | ); |
---|
4721 | } |
---|
4722 | |
---|
4723 | Bool ProfileTierLevel::getInbldPresentFlag() |
---|
4724 | { |
---|
4725 | return ( |
---|
4726 | ( getProfileIdc() >= 1 && getProfileIdc() <= 5 ) || getProfileCompatibilityFlag( 1 ) || getProfileCompatibilityFlag( 2 ) || |
---|
4727 | getProfileCompatibilityFlag( 3 ) || getProfileCompatibilityFlag( 4 ) || getProfileCompatibilityFlag( 5 ) |
---|
4728 | ); |
---|
4729 | } |
---|
4730 | |
---|
4731 | Void ProfileTierLevel::copyV2ConstraintFlags(ProfileTierLevel* ptlRef) |
---|
4732 | { |
---|
4733 | setMax12bitConstraintFlag ( ptlRef->getMax12bitConstraintFlag ( ) ); |
---|
4734 | setMax10bitConstraintFlag ( ptlRef->getMax10bitConstraintFlag ( ) ); |
---|
4735 | setMax8bitConstraintFlag ( ptlRef->getMax8bitConstraintFlag ( ) ); |
---|
4736 | setMax422chromaConstraintFlag ( ptlRef->getMax422chromaConstraintFlag ( ) ); |
---|
4737 | setMax420chromaConstraintFlag ( ptlRef->getMax420chromaConstraintFlag ( ) ); |
---|
4738 | setMaxMonochromeConstraintFlag ( ptlRef->getMaxMonochromeConstraintFlag ( ) ); |
---|
4739 | setIntraConstraintFlag ( ptlRef->getIntraConstraintFlag ( ) ); |
---|
4740 | setOnePictureOnlyConstraintFlag ( ptlRef->getOnePictureOnlyConstraintFlag ( ) ); |
---|
4741 | setLowerBitRateConstraintFlag ( ptlRef->getLowerBitRateConstraintFlag ( ) ); |
---|
4742 | } |
---|
4743 | |
---|
4744 | Void ProfileTierLevel::copyProfile(ProfileTierLevel* ptlRef) |
---|
4745 | { |
---|
4746 | setProfileSpace ( ptlRef->getProfileSpace ( ) ); |
---|
4747 | setTierFlag ( ptlRef->getTierFlag ( ) ); |
---|
4748 | setProfileIdc ( ptlRef->getProfileIdc ( ) ); |
---|
4749 | for (Int j = 0; j < 32; j++) |
---|
4750 | { |
---|
4751 | setProfileCompatibilityFlag(j, ptlRef->getProfileCompatibilityFlag ( j ) ); |
---|
4752 | } |
---|
4753 | setProgressiveSourceFlag ( ptlRef->getProgressiveSourceFlag ( ) ); |
---|
4754 | setInterlacedSourceFlag ( ptlRef->getInterlacedSourceFlag ( ) ); |
---|
4755 | setNonPackedConstraintFlag ( ptlRef->getNonPackedConstraintFlag ( ) ); |
---|
4756 | setFrameOnlyConstraintFlag ( ptlRef->getFrameOnlyConstraintFlag ( ) ); |
---|
4757 | copyV2ConstraintFlags ( ptlRef ); |
---|
4758 | } |
---|
4759 | |
---|
4760 | #endif |
---|
4761 | |
---|
4762 | TComPTL::TComPTL() |
---|
4763 | { |
---|
4764 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
4765 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
4766 | } |
---|
4767 | |
---|
4768 | #if H_MV |
---|
4769 | #if !H_MV_HLS10_PTL_INFER_FIX |
---|
4770 | Void TComPTL::copyLevelFrom( TComPTL* source ) |
---|
4771 | { |
---|
4772 | getGeneralPTL()->setLevelIdc( source->getGeneralPTL()->getLevelIdc() ); |
---|
4773 | for( Int subLayer = 0; subLayer < 6; subLayer++ ) |
---|
4774 | { |
---|
4775 | setSubLayerLevelPresentFlag( subLayer, source->getSubLayerLevelPresentFlag( subLayer ) ); |
---|
4776 | getSubLayerPTL( subLayer )->setLevelIdc( source->getSubLayerPTL( subLayer )->getLevelIdc() ); |
---|
4777 | } |
---|
4778 | } |
---|
4779 | #else |
---|
4780 | Void TComPTL::inferGeneralValues(Bool profilePresentFlag, Int k, TComPTL* refPTL) |
---|
4781 | { |
---|
4782 | ProfileTierLevel* refProfileTierLevel = NULL; |
---|
4783 | if ( k > 0 ) |
---|
4784 | { |
---|
4785 | assert( refPTL != NULL); |
---|
4786 | refProfileTierLevel = refPTL->getGeneralPTL(); |
---|
4787 | } |
---|
4788 | |
---|
4789 | ProfileTierLevel* curProfileTierLevel = getGeneralPTL( ); |
---|
4790 | |
---|
4791 | if( !profilePresentFlag ) |
---|
4792 | { |
---|
4793 | assert( k > 0 ); |
---|
4794 | assert( refProfileTierLevel != NULL ); |
---|
4795 | curProfileTierLevel->copyProfile( refProfileTierLevel); |
---|
4796 | } |
---|
4797 | else |
---|
4798 | { |
---|
4799 | if ( !curProfileTierLevel->getV2ConstraintsPresentFlag() ) |
---|
4800 | { |
---|
4801 | curProfileTierLevel->setMax12bitConstraintFlag ( false ); |
---|
4802 | curProfileTierLevel->setMax10bitConstraintFlag ( false ); |
---|
4803 | curProfileTierLevel->setMax8bitConstraintFlag ( false ); |
---|
4804 | curProfileTierLevel->setMax422chromaConstraintFlag ( false ); |
---|
4805 | curProfileTierLevel->setMax420chromaConstraintFlag ( false ); |
---|
4806 | curProfileTierLevel->setMaxMonochromeConstraintFlag ( false ); |
---|
4807 | curProfileTierLevel->setIntraConstraintFlag ( false ); |
---|
4808 | curProfileTierLevel->setOnePictureOnlyConstraintFlag ( false ); |
---|
4809 | curProfileTierLevel->setLowerBitRateConstraintFlag ( false ); |
---|
4810 | } |
---|
4811 | |
---|
4812 | if ( !curProfileTierLevel->getInbldPresentFlag() ) |
---|
4813 | { |
---|
4814 | curProfileTierLevel->setInbldFlag( false ); |
---|
4815 | } |
---|
4816 | } |
---|
4817 | } |
---|
4818 | |
---|
4819 | Void TComPTL::inferSubLayerValues(Int maxNumSubLayersMinus1, Int k, TComPTL* refPTL) |
---|
4820 | { |
---|
4821 | assert( k == 0 || refPTL != NULL ); |
---|
4822 | |
---|
4823 | for (Int i = maxNumSubLayersMinus1; i >= 0; i--) |
---|
4824 | { |
---|
4825 | ProfileTierLevel* refProfileTierLevel; |
---|
4826 | if ( k != 0 ) |
---|
4827 | { |
---|
4828 | refProfileTierLevel = refPTL->getSubLayerPTL( i ); |
---|
4829 | } |
---|
4830 | else |
---|
4831 | { |
---|
4832 | if ( i == maxNumSubLayersMinus1) |
---|
4833 | { |
---|
4834 | refProfileTierLevel = getGeneralPTL(); |
---|
4835 | } |
---|
4836 | else |
---|
4837 | { |
---|
4838 | refProfileTierLevel = getSubLayerPTL( i + 1 ); |
---|
4839 | } |
---|
4840 | } |
---|
4841 | |
---|
4842 | ProfileTierLevel* curProfileTierLevel = getSubLayerPTL( i ); |
---|
4843 | if( !getSubLayerLevelPresentFlag( i ) ) |
---|
4844 | { |
---|
4845 | curProfileTierLevel->setLevelIdc( refProfileTierLevel->getLevelIdc() ); |
---|
4846 | } |
---|
4847 | |
---|
4848 | if( !getSubLayerProfilePresentFlag( i ) ) |
---|
4849 | { |
---|
4850 | curProfileTierLevel->copyProfile( refProfileTierLevel); |
---|
4851 | } |
---|
4852 | else |
---|
4853 | { |
---|
4854 | if ( !curProfileTierLevel->getV2ConstraintsPresentFlag() ) |
---|
4855 | { |
---|
4856 | curProfileTierLevel->copyV2ConstraintFlags( refProfileTierLevel ); |
---|
4857 | } |
---|
4858 | |
---|
4859 | if ( !curProfileTierLevel->getInbldPresentFlag() ) |
---|
4860 | { |
---|
4861 | curProfileTierLevel->setInbldFlag( refProfileTierLevel->getInbldFlag() ); |
---|
4862 | } |
---|
4863 | } |
---|
4864 | } |
---|
4865 | } |
---|
4866 | |
---|
4867 | #endif |
---|
4868 | #endif |
---|
4869 | //! \} |
---|
4870 | |
---|
4871 | #if H_MV |
---|
4872 | TComVPSVUI::TComVPSVUI() |
---|
4873 | { |
---|
4874 | m_crossLayerIrapAlignedFlag = true; |
---|
4875 | m_allLayersIdrAlignedFlag = false; |
---|
4876 | m_bitRatePresentVpsFlag = false; |
---|
4877 | m_picRatePresentVpsFlag = false; |
---|
4878 | for ( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++) |
---|
4879 | { |
---|
4880 | for ( Int j = 0; j < MAX_TLAYER; j++) |
---|
4881 | { |
---|
4882 | m_bitRatePresentFlag [i][j] = false; |
---|
4883 | m_picRatePresentFlag [i][j] = false; |
---|
4884 | m_avgBitRate [i][j] = -1; |
---|
4885 | m_maxBitRate [i][j] = -1; |
---|
4886 | m_constantPicRateIdc [i][j] = -1; |
---|
4887 | m_avgPicRate [i][j] = -1; |
---|
4888 | } |
---|
4889 | } |
---|
4890 | |
---|
4891 | m_ilpRestrictedRefLayersFlag = false; |
---|
4892 | |
---|
4893 | for ( Int i = 0; i < MAX_NUM_LAYERS; i++) |
---|
4894 | { |
---|
4895 | for ( Int j = 0; j < MAX_NUM_LAYERS; j++) |
---|
4896 | { |
---|
4897 | m_tileBoundariesAlignedFlag [i][j] = false; |
---|
4898 | m_minSpatialSegmentOffsetPlus1[i][j] = 0; |
---|
4899 | m_ctuBasedOffsetEnabledFlag [i][j] = false; |
---|
4900 | m_minHorizontalCtuOffsetPlus1 [i][j] = -1; |
---|
4901 | } |
---|
4902 | m_baseLayerParameterSetCompatibilityFlag[i] = false; |
---|
4903 | } |
---|
4904 | for ( Int i = 0; i < MAX_NUM_VIDEO_SIGNAL_INFO; i++ ) |
---|
4905 | { |
---|
4906 | m_videoSignalInfo [i] = NULL; |
---|
4907 | } |
---|
4908 | |
---|
4909 | m_vpsVuiBspHrdPresentFlag = false; |
---|
4910 | #if H_MV_HLS10_VPS_VUI_BSP |
---|
4911 | m_vpsVuiBspHrdParameters = NULL; |
---|
4912 | #else |
---|
4913 | m_vpsVuiBspHrdParameters = new TComVpsVuiBspHrdParameters(); |
---|
4914 | #endif |
---|
4915 | } |
---|
4916 | |
---|
4917 | TComVPSVUI::~TComVPSVUI() |
---|
4918 | { |
---|
4919 | for ( Int i = 0; i < MAX_NUM_VIDEO_SIGNAL_INFO; i++ ) |
---|
4920 | { |
---|
4921 | if (m_videoSignalInfo[ i ] != NULL ) delete m_videoSignalInfo[ i ]; |
---|
4922 | m_videoSignalInfo [ i ] = NULL; |
---|
4923 | } |
---|
4924 | |
---|
4925 | if ( m_vpsVuiBspHrdParameters ) delete m_vpsVuiBspHrdParameters; |
---|
4926 | m_vpsVuiBspHrdParameters = NULL; |
---|
4927 | } |
---|
4928 | |
---|
4929 | Void TComVPSVUI::inferVpsVui( Bool encoderFlag ) |
---|
4930 | { |
---|
4931 | // inference of syntax elements that differ from default inference (as done in constructor), when VPS VUI is not present |
---|
4932 | if (!encoderFlag ) |
---|
4933 | { |
---|
4934 | setCrossLayerIrapAlignedFlag( false ); |
---|
4935 | } |
---|
4936 | else |
---|
4937 | { |
---|
4938 | assert( !getCrossLayerIrapAlignedFlag() ); |
---|
4939 | } |
---|
4940 | } |
---|
4941 | |
---|
4942 | Void TComRepFormat::inferChromaAndBitDepth( TComRepFormat* prevRepFormat, Bool encoderFlag ) |
---|
4943 | { |
---|
4944 | if ( !encoderFlag ) |
---|
4945 | { |
---|
4946 | setChromaAndBitDepthVpsPresentFlag( prevRepFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
4947 | setSeparateColourPlaneVpsFlag ( prevRepFormat->getSeparateColourPlaneVpsFlag () ); |
---|
4948 | setBitDepthVpsLumaMinus8 ( prevRepFormat->getBitDepthVpsLumaMinus8 () ); |
---|
4949 | setBitDepthVpsChromaMinus8 ( prevRepFormat->getBitDepthVpsChromaMinus8 () ); |
---|
4950 | } |
---|
4951 | else |
---|
4952 | { |
---|
4953 | assert( getChromaAndBitDepthVpsPresentFlag() == prevRepFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
4954 | assert( getSeparateColourPlaneVpsFlag () == prevRepFormat->getSeparateColourPlaneVpsFlag () ); |
---|
4955 | assert( getBitDepthVpsLumaMinus8 () == prevRepFormat->getBitDepthVpsLumaMinus8 () ); |
---|
4956 | assert( getBitDepthVpsChromaMinus8 () == prevRepFormat->getBitDepthVpsChromaMinus8 () ); |
---|
4957 | } |
---|
4958 | } |
---|
4959 | |
---|
4960 | #if !H_MV_HLS10_VPS_VUI_BSP |
---|
4961 | Void TComVpsVuiBspHrdParameters::checkLayerInBspFlag( TComVPS* vps, Int h ) |
---|
4962 | { |
---|
4963 | // It is a requirement of bitstream conformance that bitstream partition with index j shall not include |
---|
4964 | // direct or indirect reference layers of any layers in bitstream partition i for any values of i and j |
---|
4965 | // in the range of 0 to num_bitstream_partitions[ h ] ?1, inclusive, such that i is less than j. |
---|
4966 | |
---|
4967 | for ( Int partJ = 0; partJ < getNumBitstreamPartitions( h ); partJ++ ) |
---|
4968 | { |
---|
4969 | for ( Int partI = 0; partI < partJ; partI++ ) |
---|
4970 | { |
---|
4971 | for ( Int layerJ = 0; layerJ < vps->getMaxLayersMinus1(); layerJ++ ) |
---|
4972 | { |
---|
4973 | if ( m_layerInBspFlag[ h ][partJ][layerJ ] ) |
---|
4974 | { |
---|
4975 | for ( Int layerI = 0; layerI < vps->getMaxLayersMinus1(); layerI++ ) |
---|
4976 | { |
---|
4977 | if ( m_layerInBspFlag[ h ][partI][layerI] ) |
---|
4978 | { |
---|
4979 | assert( !vps->getInDirectDependencyFlag( layerI, layerJ ) ); |
---|
4980 | } |
---|
4981 | } |
---|
4982 | } |
---|
4983 | } |
---|
4984 | } |
---|
4985 | } |
---|
4986 | |
---|
4987 | // --------------- |
---|
4988 | // To be added: |
---|
4989 | // When vps_base_layer_internal_flag is equal to 0 and layer_in_bsp_flag[ h ][ i ][ 0 ] is equal to 1 for any value of h in the |
---|
4990 | // range of 1 to vps_num_layer_sets_minus1, inclusive, and any value of i in the range of 0 to num_bitstream_partitions[ h ] - 1, |
---|
4991 | // inclusive, the value of layer_in_bsp_flag[ h ][ i ][ j ] for at least one value of j in the range of 1 to |
---|
4992 | // NumLayersInIdList[ h ] - 1, inclusive, shall be equal to 1. |
---|
4993 | // --------------- |
---|
4994 | |
---|
4995 | |
---|
4996 | // When num_bitstream_partitions[ h ] is equal to 1 for any value of h in the range 1 to vps_num_layer_set_minus1, inclusive, |
---|
4997 | // the value of layer_in_bsp_flag[ h ][ 0 ][ j ] should be equal to 0 for at least one value of j in the range 0 to |
---|
4998 | // NumLayersInIdList[ h ] ? 1, inclusive. |
---|
4999 | |
---|
5000 | |
---|
5001 | if ( getNumBitstreamPartitions( h ) == 1 ) |
---|
5002 | { |
---|
5003 | Bool atLeastOneZero = false; |
---|
5004 | for ( Int j = 0; j <= vps->getNumLayersInIdList( h ) - 1; j++ ) |
---|
5005 | { |
---|
5006 | atLeastOneZero = atLeastOneZero || !getLayerInBspFlag( h, 0, j ); |
---|
5007 | } |
---|
5008 | assert( atLeastOneZero ); |
---|
5009 | } |
---|
5010 | |
---|
5011 | |
---|
5012 | // For any value of h in the range 1 to vps_num_layer_set_minus1, inclusive, the value of layer_in_bsp_flag[ h ][ i ][ j ] |
---|
5013 | // shall be equal to 1 for at most one value of i in the range of 0 to num_bitstream_partitions[ h ] ? 1, inclusive. |
---|
5014 | |
---|
5015 | for ( Int j = 0; j <= vps->getNumLayersInIdList( h ) - 1; j++ ) |
---|
5016 | { |
---|
5017 | Int numLayerInBsp = 0; |
---|
5018 | for ( Int i = 0; i <= getNumBitstreamPartitions( h ) - 1; i++ ) |
---|
5019 | { |
---|
5020 | numLayerInBsp += ( getLayerInBspFlag( h, i, j ) ? 1 : 0 ); |
---|
5021 | } |
---|
5022 | assert( numLayerInBsp <= 1 ); |
---|
5023 | } |
---|
5024 | |
---|
5025 | } |
---|
5026 | |
---|
5027 | Void TComVpsVuiBspHrdParameters::checkBspCombHrdAndShedIdx( TComVPS* vps, Int h, Int i, Int j ) |
---|
5028 | { |
---|
5029 | // bsp_comb_hrd_idx |
---|
5030 | assert( getBspCombSchedIdx(h, i, j ) >= 0 ); |
---|
5031 | assert( getBspCombSchedIdx(h, i, j ) <= getVpsNumBspHrdParametersMinus1() ); |
---|
5032 | |
---|
5033 | // bsp_comb_sched_idx |
---|
5034 | assert( getBspCombSchedIdx(h, i, j ) >= 0 ); |
---|
5035 | |
---|
5036 | //* This check needs to activated, when HighestTid is available here |
---|
5037 | // assert( getBspCombSchedIdx(h, i, j ) <= vps->getHrdParameters( getBspCombHrdIdx( h, i, j ) )->getCpbCntMinus1( highestTid ) ); |
---|
5038 | } |
---|
5039 | #endif |
---|
5040 | |
---|
5041 | #if H_MV_HLS10_VPS_VUI_BSP |
---|
5042 | |
---|
5043 | TComVpsVuiBspHrdParameters::~TComVpsVuiBspHrdParameters() |
---|
5044 | { |
---|
5045 | delete[] m_cprmsAddPresentFlag; |
---|
5046 | delete[] m_numSubLayerHrdMinus1; |
---|
5047 | delete[] m_hrdParameters; |
---|
5048 | |
---|
5049 | for (Int h = 0; h < m_numOls; h++) |
---|
5050 | { |
---|
5051 | if ( h > 0 ) |
---|
5052 | { |
---|
5053 | for (Int i = 0; i < getNumSignalledPartitioningSchemes(h)+1; i++) |
---|
5054 | { |
---|
5055 | for (Int t = 0; t < m_vps->getMaxSubLayersInLayerSetMinus1( m_vps->olsIdxToLsIdx(h) ) + 1; t++) |
---|
5056 | { |
---|
5057 | for ( Int j = 0; j <= getNumBspSchedulesMinus1(h,i,j);j++ ) |
---|
5058 | { |
---|
5059 | delete[] m_bspHrdIdx [h][i][t][j]; |
---|
5060 | delete[] m_bspSchedIdx[h][i][t][j]; |
---|
5061 | } |
---|
5062 | } |
---|
5063 | delete[] m_numBspSchedulesMinus1[h][i]; |
---|
5064 | } |
---|
5065 | } |
---|
5066 | |
---|
5067 | for (Int j = 0; j <= getNumSignalledPartitioningSchemes(h ) + 1; j++ ) |
---|
5068 | { |
---|
5069 | for (Int k = 0; k <= getNumPartitionsInSchemeMinus1(h,j); k++ ) |
---|
5070 | { |
---|
5071 | delete[] m_layerIncludedInPartitionFlag[h][j][k]; |
---|
5072 | } |
---|
5073 | } |
---|
5074 | delete[] m_numPartitionsInSchemeMinus1[h]; |
---|
5075 | } |
---|
5076 | delete[] m_numSignalledPartitioningSchemes; |
---|
5077 | } |
---|
5078 | |
---|
5079 | |
---|
5080 | Int TComVpsVuiBspHrdParameters::getBspHrdIdxLen(TComVPS* vps) |
---|
5081 | { |
---|
5082 | return gCeilLog2( vps->getNumHrdParameters() + getVpsNumAddHrdParams() ); |
---|
5083 | } |
---|
5084 | |
---|
5085 | Void TComVpsVuiBspHrdParameters::createAfterVpsNumAddHrdParams( TComVPS* vps ) |
---|
5086 | { |
---|
5087 | assert( vps == NULL ); |
---|
5088 | m_vps = vps; |
---|
5089 | m_offsetHrdParamIdx = vps->getNumHrdParameters(); |
---|
5090 | m_numHrdParam = vps->getNumHrdParameters() + getVpsNumAddHrdParams() - m_offsetHrdParamIdx; |
---|
5091 | m_numOls = vps->getNumOutputLayerSets(); |
---|
5092 | |
---|
5093 | m_cprmsAddPresentFlag = new Bool [ m_numHrdParam ]; |
---|
5094 | m_numSubLayerHrdMinus1 = new Int [ m_numHrdParam ]; |
---|
5095 | m_hrdParameters = new TComHRD [ m_numHrdParam ]; |
---|
5096 | |
---|
5097 | m_numSignalledPartitioningSchemes = new Int [ m_numOls ]; |
---|
5098 | m_numPartitionsInSchemeMinus1 = new Int* [ m_numOls ]; |
---|
5099 | m_numBspSchedulesMinus1 = new Int** [ m_numOls ]; |
---|
5100 | m_bspHrdIdx = new Int****[ m_numOls ]; |
---|
5101 | m_bspSchedIdx = new Int****[ m_numOls ]; |
---|
5102 | } |
---|
5103 | |
---|
5104 | Void TComVpsVuiBspHrdParameters::createAfterNumSignalledPartitioningSchemes( Int h ) |
---|
5105 | { |
---|
5106 | m_numPartitionsInSchemeMinus1 [h] = new Int [ getNumSignalledPartitioningSchemes(h) ]; |
---|
5107 | m_layerIncludedInPartitionFlag[h] = new Bool** [ getNumSignalledPartitioningSchemes(h) ]; |
---|
5108 | |
---|
5109 | m_numBspSchedulesMinus1[h] = new Int* [ getNumSignalledPartitioningSchemes(h) + 1 ]; |
---|
5110 | for (Int i = 0; i < getNumSignalledPartitioningSchemes(h) + 1; i++) |
---|
5111 | { |
---|
5112 | Int tMax = m_vps->getMaxSubLayersInLayerSetMinus1( m_vps->olsIdxToLsIdx(h) ) + 1; |
---|
5113 | m_numBspSchedulesMinus1[h][i] = new Int [ tMax ]; |
---|
5114 | m_bspHrdIdx [h][i] = new Int**[ tMax ]; |
---|
5115 | m_bspSchedIdx [h][i] = new Int**[ tMax ]; |
---|
5116 | } |
---|
5117 | } |
---|
5118 | |
---|
5119 | Void TComVpsVuiBspHrdParameters::createAfterNumPartitionsInSchemeMinus1( Int h, Int j ) |
---|
5120 | { |
---|
5121 | m_layerIncludedInPartitionFlag[h][j] = new Bool*[ getNumPartitionsInSchemeMinus1(h,j)]; |
---|
5122 | for( Int k = 0; k < getNumPartitionsInSchemeMinus1(h,j); k++ ) |
---|
5123 | { |
---|
5124 | m_layerIncludedInPartitionFlag[h][j][k] = new Bool[ m_vps->getNumLayersInIdList( m_vps->olsIdxToLsIdx(h))]; |
---|
5125 | } |
---|
5126 | } |
---|
5127 | |
---|
5128 | Void TComVpsVuiBspHrdParameters::createAfterNumBspSchedulesMinus1( Int h, Int i, Int t ) |
---|
5129 | { |
---|
5130 | m_bspSchedIdx[h][i][t] = new Int* [ getNumBspSchedulesMinus1( h, i, t ) + 1 ]; |
---|
5131 | m_bspHrdIdx [h][i][t] = new Int* [ getNumBspSchedulesMinus1( h, i, t ) + 1 ]; |
---|
5132 | for( Int j = 0; j < getNumBspSchedulesMinus1( h, i, t ) + 1; j++ ) |
---|
5133 | { |
---|
5134 | m_bspSchedIdx[h][i][t][j] = new Int[ getNumPartitionsInSchemeMinus1( h, i ) ]; |
---|
5135 | m_bspHrdIdx [h][i][t][j] = new Int[ getNumPartitionsInSchemeMinus1( h, i ) ]; |
---|
5136 | } |
---|
5137 | } |
---|
5138 | |
---|
5139 | #endif |
---|
5140 | |
---|
5141 | Void TComVUI::inferVideoSignalInfo( TComVPS* vps, Int layerIdCurr ) |
---|
5142 | { |
---|
5143 | if ( layerIdCurr == 0 || !vps->getVpsVuiPresentFlag() ) |
---|
5144 | { |
---|
5145 | return; |
---|
5146 | } |
---|
5147 | |
---|
5148 | TComVPSVUI* vpsVUI = vps->getVPSVUI(); |
---|
5149 | assert( vpsVUI != NULL ); |
---|
5150 | |
---|
5151 | TComVideoSignalInfo* videoSignalInfo = vpsVUI->getVideoSignalInfo( vpsVUI->getVpsVideoSignalInfoIdx( vps->getLayerIdInVps( layerIdCurr ) ) ); |
---|
5152 | assert( videoSignalInfo != NULL ); |
---|
5153 | |
---|
5154 | setVideoFormat ( videoSignalInfo->getVideoVpsFormat () ); |
---|
5155 | setVideoFullRangeFlag ( videoSignalInfo->getVideoFullRangeVpsFlag () ); |
---|
5156 | setColourPrimaries ( videoSignalInfo->getColourPrimariesVps () ); |
---|
5157 | setTransferCharacteristics( videoSignalInfo->getTransferCharacteristicsVps() ); |
---|
5158 | setMatrixCoefficients ( videoSignalInfo->getMatrixCoeffsVps () ); |
---|
5159 | } |
---|
5160 | |
---|
5161 | TComDpbSize::TComDpbSize() |
---|
5162 | { |
---|
5163 | for (Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++ ) |
---|
5164 | { |
---|
5165 | m_subLayerFlagInfoPresentFlag[i] = false; |
---|
5166 | |
---|
5167 | for (Int j = 0; j < MAX_TLAYER; j++ ) |
---|
5168 | { |
---|
5169 | m_subLayerDpbInfoPresentFlag [i][j] = ( j == 0) ; |
---|
5170 | m_maxVpsNumReorderPics [i][j] = 0; |
---|
5171 | m_maxVpsLatencyIncreasePlus1 [i][j] = 0; |
---|
5172 | |
---|
5173 | for (Int k = 0; k < MAX_NUM_LAYER_IDS; k++ ) |
---|
5174 | { |
---|
5175 | #if H_MV_HLS10_ADD_LAYERSETS |
---|
5176 | m_maxVpsDecPicBufferingMinus1[i][k][j] = MIN_INT; |
---|
5177 | #else |
---|
5178 | m_maxVpsDecPicBufferingMinus1[i][k][j] = 0; |
---|
5179 | #endif |
---|
5180 | } |
---|
5181 | } |
---|
5182 | } |
---|
5183 | } |
---|
5184 | |
---|
5185 | Void Window::scaleOffsets( Int scal ) |
---|
5186 | { |
---|
5187 | if (! m_scaledFlag ) |
---|
5188 | { |
---|
5189 | m_scaledFlag = true; |
---|
5190 | m_winLeftOffset *= scal; |
---|
5191 | m_winRightOffset *= scal; |
---|
5192 | m_winTopOffset *= scal; |
---|
5193 | m_winBottomOffset *= scal; |
---|
5194 | } |
---|
5195 | } |
---|
5196 | #endif |
---|
5197 | |
---|