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