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