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_refPicSetInterLayer0 ( NULL ) |
---|
107 | , m_refPicSetInterLayer1 ( NULL ) |
---|
108 | , m_layerId (0) |
---|
109 | , m_viewId (0) |
---|
110 | , m_viewIndex (0) |
---|
111 | #if H_3D |
---|
112 | , m_isDepth (false) |
---|
113 | #endif |
---|
114 | #if !H_MV_HLS7_GEN |
---|
115 | , m_pocResetFlag (false) |
---|
116 | #endif |
---|
117 | #if H_MV |
---|
118 | , m_crossLayerBlaFlag (false) |
---|
119 | #endif |
---|
120 | , m_discardableFlag (false) |
---|
121 | , m_interLayerPredEnabledFlag (false) |
---|
122 | , m_numInterLayerRefPicsMinus1 (0) |
---|
123 | #if H_MV |
---|
124 | , m_sliceSegmentHeaderExtensionLength (0) |
---|
125 | , m_pocResetIdc (0) |
---|
126 | , m_pocResetPeriodId (0) |
---|
127 | , m_fullPocResetFlag (false) |
---|
128 | , m_pocLsbVal (0) |
---|
129 | , m_pocMsbValPresentFlag (false) |
---|
130 | , m_pocMsbVal (0) |
---|
131 | , m_pocMsbValRequiredFlag ( false ) |
---|
132 | #endif |
---|
133 | #if H_3D_IC |
---|
134 | , m_bApplyIC ( false ) |
---|
135 | , m_icSkipParseFlag ( false ) |
---|
136 | #endif |
---|
137 | #if H_3D |
---|
138 | , m_depthToDisparityB ( NULL ) |
---|
139 | , m_depthToDisparityF ( NULL ) |
---|
140 | #endif |
---|
141 | #if MTK_SINGLE_DEPTH_MODE_I0095 |
---|
142 | , m_bApplySingleDepthMode (false) |
---|
143 | #endif |
---|
144 | #endif |
---|
145 | { |
---|
146 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = 0; |
---|
147 | |
---|
148 | initEqualRef(); |
---|
149 | |
---|
150 | for (Int component = 0; component < 3; component++) |
---|
151 | { |
---|
152 | m_lambdas[component] = 0.0; |
---|
153 | } |
---|
154 | |
---|
155 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
156 | { |
---|
157 | m_list1IdxToList0Idx[idx] = -1; |
---|
158 | } |
---|
159 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
160 | { |
---|
161 | m_apcRefPicList [0][iNumCount] = NULL; |
---|
162 | m_apcRefPicList [1][iNumCount] = NULL; |
---|
163 | m_aiRefPOCList [0][iNumCount] = 0; |
---|
164 | m_aiRefPOCList [1][iNumCount] = 0; |
---|
165 | #if H_MV |
---|
166 | m_aiRefLayerIdList[0][iNumCount] = 0; |
---|
167 | m_aiRefLayerIdList[1][iNumCount] = 0; |
---|
168 | #endif |
---|
169 | } |
---|
170 | resetWpScaling(); |
---|
171 | initWpAcDcParam(); |
---|
172 | m_saoEnabledFlag = false; |
---|
173 | m_saoEnabledFlagChroma = false; |
---|
174 | #if H_MV |
---|
175 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
176 | { |
---|
177 | m_interLayerPredLayerIdc[ i ] = -1; |
---|
178 | } |
---|
179 | #endif |
---|
180 | } |
---|
181 | |
---|
182 | TComSlice::~TComSlice() |
---|
183 | { |
---|
184 | delete[] m_puiSubstreamSizes; |
---|
185 | m_puiSubstreamSizes = NULL; |
---|
186 | #if H_3D |
---|
187 | for( UInt i = 0; i < getViewIndex(); i++ ) |
---|
188 | { |
---|
189 | if ( m_depthToDisparityB && m_depthToDisparityB[ i ] ) |
---|
190 | { |
---|
191 | delete[] m_depthToDisparityB [ i ]; |
---|
192 | } |
---|
193 | |
---|
194 | if ( m_depthToDisparityF && m_depthToDisparityF[ i ] ) |
---|
195 | { |
---|
196 | delete[] m_depthToDisparityF [ i ]; |
---|
197 | } |
---|
198 | } |
---|
199 | |
---|
200 | if ( m_depthToDisparityF ) |
---|
201 | { |
---|
202 | delete[] m_depthToDisparityF; |
---|
203 | } |
---|
204 | |
---|
205 | m_depthToDisparityF = NULL; |
---|
206 | |
---|
207 | if ( m_depthToDisparityB ) |
---|
208 | delete[] m_depthToDisparityB; |
---|
209 | |
---|
210 | m_depthToDisparityB = NULL; |
---|
211 | #endif |
---|
212 | } |
---|
213 | |
---|
214 | |
---|
215 | Void TComSlice::initSlice() |
---|
216 | { |
---|
217 | m_aiNumRefIdx[0] = 0; |
---|
218 | m_aiNumRefIdx[1] = 0; |
---|
219 | |
---|
220 | m_colFromL0Flag = 1; |
---|
221 | |
---|
222 | m_colRefIdx = 0; |
---|
223 | initEqualRef(); |
---|
224 | m_bCheckLDC = false; |
---|
225 | m_iSliceQpDeltaCb = 0; |
---|
226 | m_iSliceQpDeltaCr = 0; |
---|
227 | |
---|
228 | #if H_3D_IV_MERGE |
---|
229 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS_MEM; |
---|
230 | #else |
---|
231 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
232 | #endif |
---|
233 | |
---|
234 | m_bFinalized=false; |
---|
235 | |
---|
236 | m_tileByteLocation.clear(); |
---|
237 | m_cabacInitFlag = false; |
---|
238 | m_numEntryPointOffsets = 0; |
---|
239 | m_enableTMVPFlag = true; |
---|
240 | #if H_3D_TMVP |
---|
241 | m_aiAlterRefIdx[0] = -1; |
---|
242 | m_aiAlterRefIdx[1] = -1; |
---|
243 | #endif |
---|
244 | } |
---|
245 | |
---|
246 | Bool TComSlice::getRapPicFlag() |
---|
247 | { |
---|
248 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
249 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
250 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
251 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
252 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
253 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
254 | } |
---|
255 | |
---|
256 | /** |
---|
257 | - allocate table to contain substream sizes to be written to the slice header. |
---|
258 | . |
---|
259 | \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1. |
---|
260 | */ |
---|
261 | Void TComSlice::allocSubstreamSizes(UInt uiNumSubstreams) |
---|
262 | { |
---|
263 | delete[] m_puiSubstreamSizes; |
---|
264 | m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0]; |
---|
265 | } |
---|
266 | |
---|
267 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
268 | { |
---|
269 | TComPic* pcPicExtract; |
---|
270 | TComPic* pcPicInsert; |
---|
271 | |
---|
272 | TComList<TComPic*>::iterator iterPicExtract; |
---|
273 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
274 | TComList<TComPic*>::iterator iterPicInsert; |
---|
275 | |
---|
276 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
277 | { |
---|
278 | iterPicExtract = rcListPic.begin(); |
---|
279 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
280 | pcPicExtract = *(iterPicExtract); |
---|
281 | pcPicExtract->setCurrSliceIdx(0); |
---|
282 | |
---|
283 | iterPicInsert = rcListPic.begin(); |
---|
284 | while (iterPicInsert != iterPicExtract) |
---|
285 | { |
---|
286 | pcPicInsert = *(iterPicInsert); |
---|
287 | pcPicInsert->setCurrSliceIdx(0); |
---|
288 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
289 | { |
---|
290 | break; |
---|
291 | } |
---|
292 | |
---|
293 | iterPicInsert++; |
---|
294 | } |
---|
295 | |
---|
296 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
297 | |
---|
298 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
299 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
300 | rcListPic.erase (iterPicExtract); |
---|
301 | } |
---|
302 | } |
---|
303 | |
---|
304 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, |
---|
305 | Int poc) |
---|
306 | { |
---|
307 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
308 | TComPic* pcPic = *(iterPic); |
---|
309 | while ( iterPic != rcListPic.end() ) |
---|
310 | { |
---|
311 | if(pcPic->getPOC() == poc) |
---|
312 | { |
---|
313 | break; |
---|
314 | } |
---|
315 | iterPic++; |
---|
316 | pcPic = *(iterPic); |
---|
317 | } |
---|
318 | return pcPic; |
---|
319 | } |
---|
320 | |
---|
321 | |
---|
322 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
323 | { |
---|
324 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
325 | TComPic* pcPic = *(iterPic); |
---|
326 | TComPic* pcStPic = pcPic; |
---|
327 | |
---|
328 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
329 | if (!pocHasMsb) |
---|
330 | { |
---|
331 | poc = poc & (pocCycle - 1); |
---|
332 | } |
---|
333 | |
---|
334 | while ( iterPic != rcListPic.end() ) |
---|
335 | { |
---|
336 | pcPic = *(iterPic); |
---|
337 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
338 | { |
---|
339 | Int picPoc = pcPic->getPOC(); |
---|
340 | if (!pocHasMsb) |
---|
341 | { |
---|
342 | picPoc = picPoc & (pocCycle - 1); |
---|
343 | } |
---|
344 | |
---|
345 | if (poc == picPoc) |
---|
346 | { |
---|
347 | if(pcPic->getIsLongTerm()) |
---|
348 | { |
---|
349 | return pcPic; |
---|
350 | } |
---|
351 | else |
---|
352 | { |
---|
353 | pcStPic = pcPic; |
---|
354 | } |
---|
355 | break; |
---|
356 | } |
---|
357 | } |
---|
358 | |
---|
359 | iterPic++; |
---|
360 | } |
---|
361 | |
---|
362 | return pcStPic; |
---|
363 | } |
---|
364 | |
---|
365 | Void TComSlice::setRefPOCList () |
---|
366 | { |
---|
367 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
368 | { |
---|
369 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
370 | { |
---|
371 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
372 | #if H_MV |
---|
373 | m_aiRefLayerIdList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getLayerId(); |
---|
374 | #endif |
---|
375 | } |
---|
376 | } |
---|
377 | |
---|
378 | } |
---|
379 | |
---|
380 | Void TComSlice::setList1IdxToList0Idx() |
---|
381 | { |
---|
382 | Int idxL0, idxL1; |
---|
383 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
384 | { |
---|
385 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
386 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
387 | { |
---|
388 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
389 | { |
---|
390 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
391 | break; |
---|
392 | } |
---|
393 | } |
---|
394 | } |
---|
395 | } |
---|
396 | |
---|
397 | #if !H_MV |
---|
398 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) |
---|
399 | { |
---|
400 | if (!checkNumPocTotalCurr) |
---|
401 | { |
---|
402 | if (m_eSliceType == I_SLICE) |
---|
403 | { |
---|
404 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
405 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
406 | |
---|
407 | return; |
---|
408 | } |
---|
409 | |
---|
410 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
411 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
412 | } |
---|
413 | |
---|
414 | TComPic* pcRefPic= NULL; |
---|
415 | TComPic* RefPicSetStCurr0[16]; |
---|
416 | TComPic* RefPicSetStCurr1[16]; |
---|
417 | TComPic* RefPicSetLtCurr[16]; |
---|
418 | UInt NumPocStCurr0 = 0; |
---|
419 | UInt NumPocStCurr1 = 0; |
---|
420 | UInt NumPocLtCurr = 0; |
---|
421 | Int i; |
---|
422 | |
---|
423 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
424 | { |
---|
425 | if(m_pcRPS->getUsed(i)) |
---|
426 | { |
---|
427 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
428 | pcRefPic->setIsLongTerm(0); |
---|
429 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
430 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
431 | NumPocStCurr0++; |
---|
432 | pcRefPic->setCheckLTMSBPresent(false); |
---|
433 | } |
---|
434 | } |
---|
435 | |
---|
436 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
437 | { |
---|
438 | if(m_pcRPS->getUsed(i)) |
---|
439 | { |
---|
440 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
441 | pcRefPic->setIsLongTerm(0); |
---|
442 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
443 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
444 | NumPocStCurr1++; |
---|
445 | pcRefPic->setCheckLTMSBPresent(false); |
---|
446 | } |
---|
447 | } |
---|
448 | |
---|
449 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
450 | { |
---|
451 | if(m_pcRPS->getUsed(i)) |
---|
452 | { |
---|
453 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
454 | pcRefPic->setIsLongTerm(1); |
---|
455 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
456 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
457 | NumPocLtCurr++; |
---|
458 | } |
---|
459 | if(pcRefPic==NULL) |
---|
460 | { |
---|
461 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
462 | } |
---|
463 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
464 | } |
---|
465 | |
---|
466 | // ref_pic_list_init |
---|
467 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
468 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
469 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
470 | if (checkNumPocTotalCurr) |
---|
471 | { |
---|
472 | // 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: |
---|
473 | // - If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
474 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
475 | if (getRapPicFlag()) |
---|
476 | { |
---|
477 | assert(numPocTotalCurr == 0); |
---|
478 | } |
---|
479 | |
---|
480 | if (m_eSliceType == I_SLICE) |
---|
481 | { |
---|
482 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
483 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
484 | |
---|
485 | return; |
---|
486 | } |
---|
487 | |
---|
488 | assert(numPocTotalCurr > 0); |
---|
489 | |
---|
490 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
491 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
492 | } |
---|
493 | |
---|
494 | Int cIdx = 0; |
---|
495 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
496 | { |
---|
497 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
498 | } |
---|
499 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
500 | { |
---|
501 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
502 | } |
---|
503 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
504 | { |
---|
505 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
506 | } |
---|
507 | assert(cIdx == numPocTotalCurr); |
---|
508 | |
---|
509 | if (m_eSliceType==B_SLICE) |
---|
510 | { |
---|
511 | cIdx = 0; |
---|
512 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
513 | { |
---|
514 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
515 | } |
---|
516 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
517 | { |
---|
518 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
519 | } |
---|
520 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
521 | { |
---|
522 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
523 | } |
---|
524 | assert(cIdx == numPocTotalCurr); |
---|
525 | } |
---|
526 | |
---|
527 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
528 | |
---|
529 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[0]; rIdx ++) |
---|
530 | { |
---|
531 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPocTotalCurr; |
---|
532 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
533 | m_apcRefPicList[0][rIdx] = rpsCurrList0[ cIdx ]; |
---|
534 | m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
535 | } |
---|
536 | if ( m_eSliceType != B_SLICE ) |
---|
537 | { |
---|
538 | m_aiNumRefIdx[1] = 0; |
---|
539 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
540 | } |
---|
541 | else |
---|
542 | { |
---|
543 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[1]; rIdx ++) |
---|
544 | { |
---|
545 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPocTotalCurr; |
---|
546 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
547 | m_apcRefPicList[1][rIdx] = rpsCurrList1[ cIdx ]; |
---|
548 | m_bIsUsedAsLongTerm[1][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
549 | } |
---|
550 | } |
---|
551 | } |
---|
552 | |
---|
553 | #else |
---|
554 | Void TComSlice::getTempRefPicLists( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1, |
---|
555 | std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int& numPocTotalCurr, Bool checkNumPocTotalCurr ) |
---|
556 | { |
---|
557 | if (!checkNumPocTotalCurr) |
---|
558 | { |
---|
559 | if (m_eSliceType == I_SLICE) |
---|
560 | { |
---|
561 | return; |
---|
562 | } |
---|
563 | } |
---|
564 | |
---|
565 | TComPic* pcRefPic= NULL; |
---|
566 | TComPic* RefPicSetStCurr0[16]; |
---|
567 | TComPic* RefPicSetStCurr1[16]; |
---|
568 | TComPic* RefPicSetLtCurr[16]; |
---|
569 | UInt NumPocStCurr0 = 0; |
---|
570 | UInt NumPocStCurr1 = 0; |
---|
571 | UInt NumPocLtCurr = 0; |
---|
572 | Int i; |
---|
573 | |
---|
574 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
575 | { |
---|
576 | if(m_pcRPS->getUsed(i)) |
---|
577 | { |
---|
578 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
579 | pcRefPic->setIsLongTerm(0); |
---|
580 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
581 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
582 | NumPocStCurr0++; |
---|
583 | pcRefPic->setCheckLTMSBPresent(false); |
---|
584 | } |
---|
585 | } |
---|
586 | |
---|
587 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
588 | { |
---|
589 | if(m_pcRPS->getUsed(i)) |
---|
590 | { |
---|
591 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
592 | pcRefPic->setIsLongTerm(0); |
---|
593 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
594 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
595 | NumPocStCurr1++; |
---|
596 | pcRefPic->setCheckLTMSBPresent(false); |
---|
597 | } |
---|
598 | } |
---|
599 | |
---|
600 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
601 | { |
---|
602 | if(m_pcRPS->getUsed(i)) |
---|
603 | { |
---|
604 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
605 | pcRefPic->setIsLongTerm(1); |
---|
606 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
607 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
608 | NumPocLtCurr++; |
---|
609 | } |
---|
610 | if(pcRefPic==NULL) |
---|
611 | { |
---|
612 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
613 | } |
---|
614 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
615 | } |
---|
616 | |
---|
617 | Int numPocInterCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
618 | numPocTotalCurr = numPocInterCurr + getNumActiveRefLayerPics( ); |
---|
619 | assert( numPocTotalCurr == getNumRpsCurrTempList() ); |
---|
620 | |
---|
621 | if (checkNumPocTotalCurr) |
---|
622 | { |
---|
623 | // 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: |
---|
624 | // - 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. |
---|
625 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
626 | if ( getRapPicFlag() && m_layerId == 0 ) |
---|
627 | { |
---|
628 | assert(numPocTotalCurr == 0); |
---|
629 | } |
---|
630 | |
---|
631 | if (m_eSliceType == I_SLICE) |
---|
632 | { |
---|
633 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
634 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
635 | |
---|
636 | return; |
---|
637 | } |
---|
638 | |
---|
639 | assert(numPocTotalCurr > 0); |
---|
640 | |
---|
641 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
642 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
643 | } |
---|
644 | |
---|
645 | std::vector<TComPic*>* refPicSetInterLayer[2] = { &refPicSetInterLayer0, &refPicSetInterLayer1}; |
---|
646 | Int numPocInterLayer[2] = { getNumActiveRefLayerPics0( ), getNumActiveRefLayerPics1( ) }; |
---|
647 | |
---|
648 | TComPic** refPicSetStCurr [2] = { RefPicSetStCurr0, RefPicSetStCurr1 }; |
---|
649 | #if FIX_WARNING |
---|
650 | Int numPocStCurr[2] = { (Int)NumPocStCurr0, (Int)NumPocStCurr1 }; |
---|
651 | #else |
---|
652 | Int numPocStCurr[2] = { NumPocStCurr0, NumPocStCurr1 }; |
---|
653 | #endif |
---|
654 | |
---|
655 | for (Int li = 0; li < ((m_eSliceType==B_SLICE) ? 2 : 1); li++) |
---|
656 | { |
---|
657 | rpsCurrList [li].resize(MAX_NUM_REF+1,NULL ); |
---|
658 | usedAsLongTerm[li].resize(MAX_NUM_REF+1,false); |
---|
659 | |
---|
660 | Int cIdx = 0; |
---|
661 | for ( i=0; i < numPocStCurr[li]; i++, cIdx++) |
---|
662 | { |
---|
663 | rpsCurrList[li][cIdx] = refPicSetStCurr[li][i]; |
---|
664 | usedAsLongTerm [li][cIdx] = false; |
---|
665 | } |
---|
666 | |
---|
667 | for ( i=0; i < numPocInterLayer[li]; i++, cIdx++) |
---|
668 | { |
---|
669 | rpsCurrList[li][cIdx] = (*refPicSetInterLayer[li])[i]; |
---|
670 | usedAsLongTerm [li][cIdx] = true; |
---|
671 | } |
---|
672 | |
---|
673 | for ( i=0; i < numPocStCurr[1-li]; i++, cIdx++) |
---|
674 | { |
---|
675 | rpsCurrList[li][cIdx] = refPicSetStCurr[1-li][i]; |
---|
676 | usedAsLongTerm [li][cIdx] = false; |
---|
677 | } |
---|
678 | |
---|
679 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
680 | { |
---|
681 | rpsCurrList[li][cIdx] = RefPicSetLtCurr[i]; |
---|
682 | usedAsLongTerm [li][cIdx] = true; |
---|
683 | } |
---|
684 | |
---|
685 | for ( i=0; i < numPocInterLayer[1-li]; i++, cIdx++) |
---|
686 | { |
---|
687 | assert( cIdx < MAX_NUM_REF ); |
---|
688 | rpsCurrList[li][cIdx] = (*refPicSetInterLayer[1-li])[i]; |
---|
689 | usedAsLongTerm [li][cIdx] = true; |
---|
690 | } |
---|
691 | |
---|
692 | assert(cIdx == numPocTotalCurr); |
---|
693 | } |
---|
694 | } |
---|
695 | |
---|
696 | Void TComSlice::setRefPicList( std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int numPocTotalCurr, Bool checkNumPocTotalCurr ) |
---|
697 | |
---|
698 | { |
---|
699 | if (!checkNumPocTotalCurr) |
---|
700 | { |
---|
701 | if (m_eSliceType == I_SLICE) |
---|
702 | { |
---|
703 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
704 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
705 | |
---|
706 | return; |
---|
707 | } |
---|
708 | } |
---|
709 | |
---|
710 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
711 | |
---|
712 | for (Int li = 0; li < 2; li++) |
---|
713 | { |
---|
714 | if ( m_eSliceType == P_SLICE && li == 1 ) |
---|
715 | { |
---|
716 | m_aiNumRefIdx[1] = 0; |
---|
717 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
718 | } |
---|
719 | else |
---|
720 | { |
---|
721 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[ li ] - 1 ); rIdx ++) |
---|
722 | { |
---|
723 | Bool listModified = m_RefPicListModification.getRefPicListModificationFlagL( li ); |
---|
724 | Int orgIdx = listModified ? m_RefPicListModification.getRefPicSetIdxL(li, rIdx) : (rIdx % numPocTotalCurr); |
---|
725 | |
---|
726 | assert( rpsCurrList[li][ orgIdx ] != NULL ); |
---|
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 MTK_SINGLE_DEPTH_MODE_I0095 |
---|
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 | #endif |
---|
1878 | |
---|
1879 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
1880 | { |
---|
1881 | m_numReorderPics[i] = 0; |
---|
1882 | m_uiMaxDecPicBuffering[i] = 1; |
---|
1883 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1884 | } |
---|
1885 | #if H_MV |
---|
1886 | for (Int lsIdx = 0; lsIdx < MAX_VPS_OP_SETS_PLUS1; lsIdx++ ) |
---|
1887 | { |
---|
1888 | for( Int layerId = 0; layerId < MAX_VPS_NUH_LAYER_ID_PLUS1; layerId++ ) |
---|
1889 | { |
---|
1890 | m_layerIdIncludedFlag[lsIdx][layerId] = (( lsIdx == 0 ) && ( layerId == 0 )) ; |
---|
1891 | } |
---|
1892 | } |
---|
1893 | m_vpsNumProfileTierLevelMinus1 = -1; |
---|
1894 | |
---|
1895 | m_numAddLayerSets = 0; |
---|
1896 | m_numAddOlss = 0; |
---|
1897 | m_defaultOutputLayerIdc = 0; |
---|
1898 | |
---|
1899 | for ( Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++) |
---|
1900 | { |
---|
1901 | m_layerSetIdxForOlsMinus1[i] = -1; |
---|
1902 | m_profileLevelTierIdx[i] = 0; |
---|
1903 | for ( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++) |
---|
1904 | { |
---|
1905 | m_outputLayerFlag[i][j] = false; |
---|
1906 | } |
---|
1907 | m_altOutputLayerFlag[ i ] = false; |
---|
1908 | } |
---|
1909 | |
---|
1910 | m_repFormatIdxPresentFlag = false; |
---|
1911 | m_maxOneActiveRefLayerFlag = false; |
---|
1912 | m_directDepTypeLenMinus2 = 0; |
---|
1913 | |
---|
1914 | |
---|
1915 | m_vpsExtensionFlag = true; |
---|
1916 | m_vpsNonVuiExtensionLength = 0; |
---|
1917 | m_splittingFlag = false; |
---|
1918 | |
---|
1919 | for( Int i = 0; i < MAX_NUM_SCALABILITY_TYPES; i++ ) |
---|
1920 | { |
---|
1921 | m_scalabilityMaskFlag[i] = false; |
---|
1922 | m_dimensionIdLen [i] = -1; |
---|
1923 | } |
---|
1924 | |
---|
1925 | m_vpsNuhLayerIdPresentFlag = false; |
---|
1926 | |
---|
1927 | for( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++ ) |
---|
1928 | { |
---|
1929 | m_vpsProfilePresentFlag [i] = false; |
---|
1930 | m_layerSetIdxForOlsMinus1 [i] = 0; |
---|
1931 | for( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++ ) |
---|
1932 | { |
---|
1933 | m_outputLayerFlag[i][j] = false; |
---|
1934 | } |
---|
1935 | } |
---|
1936 | |
---|
1937 | for( Int i = 0; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
1938 | { |
---|
1939 | m_layerIdInVps[i] = (i == 0 ) ? 0 : -1; |
---|
1940 | } |
---|
1941 | |
---|
1942 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
1943 | { |
---|
1944 | m_layerIdInNuh [i] = ( i == 0 ) ? 0 : -1; |
---|
1945 | m_numDirectRefLayers[i] = 0; |
---|
1946 | m_vpsRepFormatIdx [i] = 0; |
---|
1947 | m_pocLsbNotPresentFlag[i] = 0; |
---|
1948 | m_repFormat [i] = NULL; |
---|
1949 | m_viewIdVal [i] = 0; |
---|
1950 | |
---|
1951 | #if H_3D |
---|
1952 | m_viewIndex [i] = -1; |
---|
1953 | m_vpsDepthModesFlag [i] = false; |
---|
1954 | #if SEPARATE_FLAG_I0085 |
---|
1955 | m_bIVPFlag [i] = false; |
---|
1956 | #endif |
---|
1957 | m_ivMvScalingFlag = true; |
---|
1958 | #endif |
---|
1959 | |
---|
1960 | for( Int j = 0; j < MAX_NUM_LAYERS; j++ ) |
---|
1961 | { |
---|
1962 | m_directDependencyFlag[i][j] = false; |
---|
1963 | m_directDependencyType[i][j] = -1; |
---|
1964 | m_refLayerId[i][j] = -1; |
---|
1965 | m_maxTidIlRefPicsPlus1[i][j] = 7; |
---|
1966 | } |
---|
1967 | |
---|
1968 | for( Int j = 0; j < MAX_NUM_SCALABILITY_TYPES; j++ ) |
---|
1969 | { |
---|
1970 | m_dimensionId[i][j] = 0; |
---|
1971 | } |
---|
1972 | #if H_3D_ARP |
---|
1973 | m_uiUseAdvResPred[i] = 0; |
---|
1974 | m_uiARPStepNum[i] = 1; |
---|
1975 | #endif |
---|
1976 | } |
---|
1977 | m_vpsVUI = new TComVPSVUI; |
---|
1978 | m_dpbSize = new TComDpbSize; |
---|
1979 | |
---|
1980 | #if H_3D |
---|
1981 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
1982 | { |
---|
1983 | #if H_3D_IV_MERGE |
---|
1984 | m_ivMvPredFlag [ i ] = false; |
---|
1985 | #if H_3D_SPIVMP |
---|
1986 | m_iSubPULog2Size [ i ] = 0; |
---|
1987 | #endif |
---|
1988 | #endif |
---|
1989 | #if H_3D_VSP |
---|
1990 | m_viewSynthesisPredFlag[ i ] = false; |
---|
1991 | #endif |
---|
1992 | #if H_3D_NBDV_REF |
---|
1993 | m_depthRefinementFlag [ i ] = false; |
---|
1994 | #endif |
---|
1995 | #if H_3D_INTER_SDC |
---|
1996 | m_bInterSDCFlag [ i ] = false; |
---|
1997 | #endif |
---|
1998 | #if SEPARATE_FLAG_I0085 |
---|
1999 | m_bIVPFlag [ i ] = false; |
---|
2000 | #endif |
---|
2001 | #if H_3D_DBBP |
---|
2002 | m_dbbpFlag [ i ] = false; |
---|
2003 | #endif |
---|
2004 | #if H_3D_IV_MERGE |
---|
2005 | m_bMPIFlag [ i ] = false; |
---|
2006 | #endif |
---|
2007 | } |
---|
2008 | #endif |
---|
2009 | #endif |
---|
2010 | } |
---|
2011 | |
---|
2012 | TComVPS::~TComVPS() |
---|
2013 | { |
---|
2014 | if( m_hrdParameters != NULL ) delete[] m_hrdParameters; |
---|
2015 | if( m_hrdOpSetIdx != NULL ) delete[] m_hrdOpSetIdx; |
---|
2016 | if( m_cprmsPresentFlag != NULL ) delete[] m_cprmsPresentFlag; |
---|
2017 | #if H_MV |
---|
2018 | if ( m_vpsVUI != NULL ) delete m_vpsVUI; |
---|
2019 | if ( m_dpbSize != NULL ) delete m_dpbSize; |
---|
2020 | |
---|
2021 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
2022 | { |
---|
2023 | if (m_repFormat[ i ] != NULL ) delete m_repFormat[ i ]; |
---|
2024 | } |
---|
2025 | #endif |
---|
2026 | #if H_3D |
---|
2027 | deleteCamPars(); |
---|
2028 | #endif |
---|
2029 | } |
---|
2030 | |
---|
2031 | #if H_MV |
---|
2032 | |
---|
2033 | Bool TComVPS::checkVPSExtensionSyntax() |
---|
2034 | { |
---|
2035 | for( Int layer = 1; layer <= getMaxLayersMinus1(); layer++ ) |
---|
2036 | { |
---|
2037 | // check layer_id_in_nuh constraint |
---|
2038 | assert( getLayerIdInNuh( layer ) > getLayerIdInNuh( layer -1 ) ); |
---|
2039 | } |
---|
2040 | |
---|
2041 | //The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
2042 | assert( getVpsNumRepFormatsMinus1() >= 0 ); |
---|
2043 | assert( getVpsNumRepFormatsMinus1() <= 255 ); |
---|
2044 | |
---|
2045 | return true; |
---|
2046 | } |
---|
2047 | |
---|
2048 | Int TComVPS::getNumScalabilityTypes() |
---|
2049 | { |
---|
2050 | return scalTypeToScalIdx( ScalabilityType(MAX_NUM_SCALABILITY_TYPES) ); |
---|
2051 | } |
---|
2052 | |
---|
2053 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) |
---|
2054 | { |
---|
2055 | assert( scalType >= 0 && scalType <= MAX_NUM_SCALABILITY_TYPES ); |
---|
2056 | assert( scalType == MAX_NUM_SCALABILITY_TYPES || getScalabilityMaskFlag( scalType ) ); |
---|
2057 | Int scalIdx = 0; |
---|
2058 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
2059 | { |
---|
2060 | scalIdx += ( getScalabilityMaskFlag( curScalType ) ? 1 : 0 ); |
---|
2061 | |
---|
2062 | } |
---|
2063 | |
---|
2064 | return scalIdx; |
---|
2065 | } |
---|
2066 | Void TComVPS::setScalabilityMaskFlag( UInt val ) |
---|
2067 | { |
---|
2068 | for ( Int scalType = 0; scalType < MAX_NUM_SCALABILITY_TYPES; scalType++ ) |
---|
2069 | { |
---|
2070 | setScalabilityMaskFlag( scalType, ( val & (1 << scalType ) ) != 0 ); |
---|
2071 | } |
---|
2072 | } |
---|
2073 | |
---|
2074 | Void TComVPS::setRefLayers() |
---|
2075 | { |
---|
2076 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2077 | { |
---|
2078 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2079 | m_numDirectRefLayers[ iNuhLId ] = 0; |
---|
2080 | for( Int j = 0; j < i; j++ ) |
---|
2081 | { |
---|
2082 | if( getDirectDependencyFlag(i , j) ) |
---|
2083 | { |
---|
2084 | m_refLayerId[ iNuhLId ][m_numDirectRefLayers[ iNuhLId ]++ ] = getLayerIdInNuh( j ); |
---|
2085 | } |
---|
2086 | } |
---|
2087 | } |
---|
2088 | |
---|
2089 | for (Int i = 0 ; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
2090 | { |
---|
2091 | m_numRefLayers[i] = 0; |
---|
2092 | } |
---|
2093 | |
---|
2094 | for (Int currLayerId = 0; currLayerId <= 62; currLayerId++ ) |
---|
2095 | { |
---|
2096 | for (Int i = 0 ; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
2097 | { |
---|
2098 | m_recursiveRefLayerFlag[currLayerId][i] = 0; |
---|
2099 | } |
---|
2100 | } |
---|
2101 | |
---|
2102 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2103 | { |
---|
2104 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2105 | xSetRefLayerFlags( iNuhLId ); |
---|
2106 | for( Int j = 0; j < 63; j++ ) |
---|
2107 | { |
---|
2108 | m_numRefLayers[ iNuhLId ] += m_recursiveRefLayerFlag[ iNuhLId ][ j ]; |
---|
2109 | } |
---|
2110 | } |
---|
2111 | |
---|
2112 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) // Bug in spec "<" instead of "<=" |
---|
2113 | { |
---|
2114 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2115 | Int predIdx = 0; |
---|
2116 | for( Int j = iNuhLId + 1; j < 63; j++ ) |
---|
2117 | { |
---|
2118 | if( m_recursiveRefLayerFlag[ j ][ iNuhLId ] ) |
---|
2119 | { |
---|
2120 | m_predictedLayerId[ iNuhLId ][ predIdx++ ] = j; |
---|
2121 | } |
---|
2122 | } |
---|
2123 | m_numPredictedLayers[ iNuhLId ] = predIdx; |
---|
2124 | } |
---|
2125 | |
---|
2126 | Bool countedLayerIdxFlag[ MAX_NUM_LAYERS ]; |
---|
2127 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2128 | { |
---|
2129 | countedLayerIdxFlag[ i ] = 0; |
---|
2130 | } |
---|
2131 | |
---|
2132 | for( Int i = 0, k = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2133 | { |
---|
2134 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
2135 | if( m_numDirectRefLayers[ iNuhLId ] == 0 ) |
---|
2136 | { |
---|
2137 | m_treePartitionLayerIdList[ k ][ 0 ] = iNuhLId; |
---|
2138 | m_numLayersInTreePartition[ k ] = 1; |
---|
2139 | for( Int j = 0; j < m_numPredictedLayers[ iNuhLId ]; j++ ) |
---|
2140 | { |
---|
2141 | if( !countedLayerIdxFlag[ getLayerIdInVps( m_predictedLayerId[ iNuhLId ][ j ] ) ] ) |
---|
2142 | { |
---|
2143 | m_treePartitionLayerIdList[ k ][ m_numLayersInTreePartition[ k ] ] = m_predictedLayerId[ iNuhLId ][ j ]; |
---|
2144 | m_numLayersInTreePartition[ k ]++; |
---|
2145 | countedLayerIdxFlag[ getLayerIdInVps( m_predictedLayerId[ iNuhLId ][ j ] ) ] = 1; |
---|
2146 | } |
---|
2147 | } |
---|
2148 | k++; |
---|
2149 | } |
---|
2150 | m_numIndependentLayers = k; |
---|
2151 | } |
---|
2152 | } |
---|
2153 | |
---|
2154 | Int TComVPS::getRefLayerId( Int layerIdInNuh, Int idx ) |
---|
2155 | { |
---|
2156 | assert( idx >= 0 && idx < m_numDirectRefLayers[layerIdInNuh] ); |
---|
2157 | Int refLayerIdInNuh = m_refLayerId[ layerIdInNuh ][ idx ]; |
---|
2158 | assert ( refLayerIdInNuh >= 0 ); |
---|
2159 | return refLayerIdInNuh; |
---|
2160 | } |
---|
2161 | |
---|
2162 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) |
---|
2163 | { |
---|
2164 | return getScalabilityMaskFlag( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
2165 | } |
---|
2166 | |
---|
2167 | #if H_3D |
---|
2168 | Int TComVPS::getLayerIdInNuh( Int viewIndex, Bool depthFlag ) |
---|
2169 | { |
---|
2170 | Int foundLayerIdinNuh = -1; |
---|
2171 | |
---|
2172 | for (Int layerIdInVps = 0 ; layerIdInVps <= getMaxLayersMinus1(); layerIdInVps++ ) |
---|
2173 | { |
---|
2174 | Int layerIdInNuh = getLayerIdInNuh( layerIdInVps ); |
---|
2175 | if( ( getViewIndex( layerIdInNuh ) == viewIndex ) && ( getDepthId( layerIdInNuh ) == ( depthFlag ? 1 : 0 ) ) ) |
---|
2176 | { |
---|
2177 | foundLayerIdinNuh = layerIdInNuh; |
---|
2178 | break; |
---|
2179 | } |
---|
2180 | } |
---|
2181 | #if !BUG_FIX_TK65 |
---|
2182 | assert( foundLayerIdinNuh != -1 ); |
---|
2183 | #endif |
---|
2184 | return foundLayerIdinNuh; |
---|
2185 | } |
---|
2186 | |
---|
2187 | Void TComVPS::createCamPars(Int iNumViews) |
---|
2188 | { |
---|
2189 | Int i = 0, j = 0; |
---|
2190 | |
---|
2191 | m_bCamParPresent = new Bool[ iNumViews ]; |
---|
2192 | m_bCamParInSliceHeader = new Bool[ iNumViews ]; |
---|
2193 | |
---|
2194 | m_aaaiCodedScale = new Int**[ iNumViews ]; |
---|
2195 | m_aaaiCodedOffset = new Int**[ iNumViews ]; |
---|
2196 | for ( i = 0; i < iNumViews ; i++ ) |
---|
2197 | { |
---|
2198 | m_bCamParInSliceHeader[i] = false; |
---|
2199 | m_aaaiCodedScale[i] = new Int*[ 2 ]; |
---|
2200 | m_aaaiCodedOffset[i] = new Int*[ 2 ]; |
---|
2201 | for ( j = 0; j < 2; j++ ) |
---|
2202 | { |
---|
2203 | m_aaaiCodedScale[i][j] = new Int[ MAX_NUM_LAYERS ]; |
---|
2204 | m_aaaiCodedOffset[i][j] = new Int[ MAX_NUM_LAYERS ]; |
---|
2205 | for ( Int k = 0; k < MAX_NUM_LAYERS; k++ ) |
---|
2206 | { |
---|
2207 | m_aaaiCodedScale[i][j][k] = 0; |
---|
2208 | m_aaaiCodedOffset[i][j][k] = 0; |
---|
2209 | } |
---|
2210 | } |
---|
2211 | } |
---|
2212 | } |
---|
2213 | |
---|
2214 | Void TComVPS::deleteCamPars() |
---|
2215 | { |
---|
2216 | Int iNumViews = getNumViews(); |
---|
2217 | Int i = 0, j = 0; |
---|
2218 | |
---|
2219 | if ( m_bCamParPresent != NULL ) |
---|
2220 | { |
---|
2221 | delete [] m_bCamParPresent; |
---|
2222 | } |
---|
2223 | if ( m_bCamParInSliceHeader != NULL ) |
---|
2224 | { |
---|
2225 | delete [] m_bCamParInSliceHeader; |
---|
2226 | } |
---|
2227 | |
---|
2228 | if ( m_aaaiCodedScale != NULL ) |
---|
2229 | { |
---|
2230 | for ( i = 0; i < iNumViews ; i++ ) |
---|
2231 | { |
---|
2232 | for ( j = 0; j < 2; j++ ) |
---|
2233 | { |
---|
2234 | delete [] m_aaaiCodedScale[i][j]; |
---|
2235 | } |
---|
2236 | delete [] m_aaaiCodedScale[i]; |
---|
2237 | } |
---|
2238 | delete [] m_aaaiCodedScale; |
---|
2239 | } |
---|
2240 | |
---|
2241 | if ( m_aaaiCodedOffset != NULL ) |
---|
2242 | { |
---|
2243 | for ( i = 0; i < iNumViews ; i++ ) |
---|
2244 | { |
---|
2245 | for ( j = 0; j < 2; j++ ) |
---|
2246 | { |
---|
2247 | delete [] m_aaaiCodedOffset[i][j]; |
---|
2248 | } |
---|
2249 | delete [] m_aaaiCodedOffset[i]; |
---|
2250 | } |
---|
2251 | delete [] m_aaaiCodedOffset; |
---|
2252 | } |
---|
2253 | } |
---|
2254 | |
---|
2255 | |
---|
2256 | Void |
---|
2257 | TComVPS::initCamParaVPS( UInt uiViewIndex, Bool bCamParPresent, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset ) |
---|
2258 | { |
---|
2259 | AOT( uiViewIndex != 0 && !bCamParSlice && ( aaiScale == 0 || aaiOffset == 0 ) ); |
---|
2260 | |
---|
2261 | m_uiCamParPrecision = ( ( uiViewIndex != 0 )? uiCamParPrecision : 0 ); |
---|
2262 | m_bCamParPresent[ uiViewIndex ] = (( uiViewIndex != 0 )? bCamParPresent : false ); |
---|
2263 | m_bCamParInSliceHeader[ uiViewIndex ] = ( (uiViewIndex != 0)? bCamParSlice : false ); |
---|
2264 | |
---|
2265 | if( !m_bCamParInSliceHeader[ uiViewIndex ] ) |
---|
2266 | { |
---|
2267 | for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < uiViewIndex; uiBaseViewIndex++ ) |
---|
2268 | { |
---|
2269 | m_aaaiCodedScale [ uiViewIndex ][ 0 ][ uiBaseViewIndex ] = aaiScale [ uiBaseViewIndex ][ uiViewIndex ]; |
---|
2270 | m_aaaiCodedScale [ uiViewIndex ][ 1 ][ uiBaseViewIndex ] = aaiScale [ uiViewIndex ][ uiBaseViewIndex ]; |
---|
2271 | m_aaaiCodedOffset[ uiViewIndex ][ 0 ][ uiBaseViewIndex ] = aaiOffset[ uiBaseViewIndex ][ uiViewIndex ]; |
---|
2272 | m_aaaiCodedOffset[ uiViewIndex ][ 1 ][ uiBaseViewIndex ] = aaiOffset[ uiViewIndex ][ uiBaseViewIndex ]; |
---|
2273 | } |
---|
2274 | } |
---|
2275 | } |
---|
2276 | |
---|
2277 | #endif // H_3D |
---|
2278 | |
---|
2279 | |
---|
2280 | Int TComVPS::xGetDimBitOffset( Int j ) |
---|
2281 | { |
---|
2282 | Int dimBitOffset = 0; |
---|
2283 | if ( getSplittingFlag() && j == getNumScalabilityTypes() ) |
---|
2284 | { |
---|
2285 | dimBitOffset = 6; |
---|
2286 | } |
---|
2287 | else |
---|
2288 | { |
---|
2289 | for (Int dimIdx = 0; dimIdx <= j-1; dimIdx++) |
---|
2290 | { |
---|
2291 | dimBitOffset += getDimensionIdLen( dimIdx ); |
---|
2292 | } |
---|
2293 | } |
---|
2294 | return dimBitOffset; |
---|
2295 | } |
---|
2296 | |
---|
2297 | Int TComVPS::inferDimensionId( Int i, Int j ) |
---|
2298 | { |
---|
2299 | return ( ( getLayerIdInNuh( i ) & ( (1 << xGetDimBitOffset( j + 1 ) ) - 1) ) >> xGetDimBitOffset( j ) ); |
---|
2300 | } |
---|
2301 | |
---|
2302 | Int TComVPS::inferLastDimsionIdLenMinus1() |
---|
2303 | { |
---|
2304 | return ( 5 - xGetDimBitOffset( getNumScalabilityTypes() - 1 ) ); |
---|
2305 | } |
---|
2306 | |
---|
2307 | Int TComVPS::getNumLayersInIdList( Int lsIdx ) |
---|
2308 | { |
---|
2309 | assert( lsIdx >= 0 ); |
---|
2310 | assert( lsIdx <= getVpsNumLayerSetsMinus1() ); |
---|
2311 | return (Int) m_layerSetLayerIdList[ lsIdx ].size(); |
---|
2312 | } |
---|
2313 | |
---|
2314 | Int TComVPS::getNumOutputLayerSets() |
---|
2315 | { |
---|
2316 | return getNumAddOlss() + getNumLayerSets(); |
---|
2317 | } |
---|
2318 | |
---|
2319 | Int TComVPS::getNumViews() |
---|
2320 | { |
---|
2321 | Int numViews = 1; |
---|
2322 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
2323 | { |
---|
2324 | Int lId = getLayerIdInNuh( i ); |
---|
2325 | if ( i > 0 && ( getViewIndex( lId ) != getScalabilityId( i - 1, VIEW_ORDER_INDEX ) ) ) |
---|
2326 | { |
---|
2327 | numViews++; |
---|
2328 | } |
---|
2329 | } |
---|
2330 | |
---|
2331 | return numViews; |
---|
2332 | } |
---|
2333 | |
---|
2334 | Bool TComVPS::getInDirectDependencyFlag( Int depLayeridInVps, Int refLayeridInVps, Int depth /*= 0 */ ) |
---|
2335 | { |
---|
2336 | assert( depth < 65 ); |
---|
2337 | Bool dependentFlag = getDirectDependencyFlag( depLayeridInVps, refLayeridInVps ); |
---|
2338 | |
---|
2339 | for( Int i = 0; i < depLayeridInVps && !dependentFlag; i++ ) |
---|
2340 | { |
---|
2341 | if ( getDirectDependencyFlag( depLayeridInVps, i ) ) |
---|
2342 | { |
---|
2343 | dependentFlag = getInDirectDependencyFlag( i, refLayeridInVps, depth++ ); |
---|
2344 | } |
---|
2345 | } |
---|
2346 | return dependentFlag; |
---|
2347 | } |
---|
2348 | |
---|
2349 | Void TComVPS::deriveLayerSetLayerIdList() |
---|
2350 | { |
---|
2351 | m_layerSetLayerIdList.resize( getVpsNumLayerSetsMinus1() + 1 ); |
---|
2352 | for (Int i = 0; i <= getVpsNumLayerSetsMinus1(); i++ ) |
---|
2353 | { |
---|
2354 | for( Int m = 0; m <= getVpsMaxLayerId(); m++ ) |
---|
2355 | { |
---|
2356 | if( getLayerIdIncludedFlag( i, m) ) |
---|
2357 | { |
---|
2358 | m_layerSetLayerIdList[ i ].push_back( m ); |
---|
2359 | } |
---|
2360 | } |
---|
2361 | } |
---|
2362 | } |
---|
2363 | |
---|
2364 | Void TComVPS::initTargetLayerIdLists() |
---|
2365 | { |
---|
2366 | m_targetDecLayerIdLists.resize( getNumOutputLayerSets() ); |
---|
2367 | m_targetOptLayerIdLists.resize( getNumOutputLayerSets() ); |
---|
2368 | } |
---|
2369 | |
---|
2370 | Void TComVPS::deriveTargetLayerIdList( Int i ) |
---|
2371 | { |
---|
2372 | Int lsIdx = olsIdxToLsIdx( i ); |
---|
2373 | |
---|
2374 | for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ ) |
---|
2375 | { |
---|
2376 | m_targetDecLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); |
---|
2377 | if( getOutputLayerFlag( i, j )) |
---|
2378 | { |
---|
2379 | m_targetOptLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); |
---|
2380 | } |
---|
2381 | } |
---|
2382 | assert( getNumOutputLayersInOutputLayerSet( i ) > 0 ); |
---|
2383 | } |
---|
2384 | |
---|
2385 | Bool TComVPS::inferOutputLayerFlag( Int i, Int j ) |
---|
2386 | { |
---|
2387 | Bool outputLayerFlag; |
---|
2388 | switch ( getDefaultOutputLayerIdc( ) ) |
---|
2389 | { |
---|
2390 | case 0: |
---|
2391 | outputLayerFlag = true; |
---|
2392 | break; |
---|
2393 | case 1: |
---|
2394 | outputLayerFlag = ( j == m_layerSetLayerIdList[ olsIdxToLsIdx( i ) ].size() - 1 ); |
---|
2395 | break; |
---|
2396 | case 2: |
---|
2397 | if ( i == 0 && j == 0) |
---|
2398 | { |
---|
2399 | outputLayerFlag = true; // This is a software only fix for a bug in the spec. In spec outputLayerFlag is neither present nor inferred. |
---|
2400 | } |
---|
2401 | else |
---|
2402 | { |
---|
2403 | assert( 0 ); |
---|
2404 | } |
---|
2405 | break; |
---|
2406 | default: |
---|
2407 | assert( 0 ); |
---|
2408 | break; |
---|
2409 | } |
---|
2410 | return outputLayerFlag; |
---|
2411 | } |
---|
2412 | |
---|
2413 | Int TComVPS::getMaxSubLayersInLayerSetMinus1( Int i ) |
---|
2414 | { |
---|
2415 | Int maxSLMinus1 = 0; |
---|
2416 | for( Int k = 0; k < getNumLayersInIdList( i ); k++ ) |
---|
2417 | { |
---|
2418 | Int lId = m_layerSetLayerIdList[i][k]; |
---|
2419 | maxSLMinus1 = std::max( maxSLMinus1, getSubLayersVpsMaxMinus1( getLayerIdInVps( lId ) )); |
---|
2420 | } |
---|
2421 | return maxSLMinus1; |
---|
2422 | } |
---|
2423 | |
---|
2424 | Void TComVPS::inferDbpSizeLayerSetZero( TComSPS* sps, Bool encoder ) |
---|
2425 | { |
---|
2426 | for( Int j = 0; j <= getMaxSubLayersInLayerSetMinus1( 0 ); j++ ) |
---|
2427 | { |
---|
2428 | Int maxDecPicBufferingMinus1 = sps->getMaxDecPicBuffering( j ) - 1; |
---|
2429 | Int numReorderPics = sps->getNumReorderPics ( j ); |
---|
2430 | Int maxLatencyIncreasePlus1 = sps->getMaxLatencyIncrease( j ); |
---|
2431 | |
---|
2432 | if ( encoder ) |
---|
2433 | { |
---|
2434 | assert( getDpbSize()->getMaxVpsDecPicBufferingMinus1(0, 0, j ) == maxDecPicBufferingMinus1 ); |
---|
2435 | assert( getDpbSize()->getMaxVpsNumReorderPics (0, j ) == numReorderPics ); |
---|
2436 | assert( getDpbSize()->getMaxVpsLatencyIncreasePlus1 (0, j ) == maxLatencyIncreasePlus1 ); |
---|
2437 | } |
---|
2438 | else |
---|
2439 | { |
---|
2440 | getDpbSize()->setMaxVpsDecPicBufferingMinus1(0, 0, j, maxDecPicBufferingMinus1 ); |
---|
2441 | getDpbSize()->setMaxVpsNumReorderPics (0, j, numReorderPics ); |
---|
2442 | getDpbSize()->setMaxVpsLatencyIncreasePlus1 (0, j, maxLatencyIncreasePlus1 ); |
---|
2443 | } |
---|
2444 | } |
---|
2445 | } |
---|
2446 | |
---|
2447 | Bool TComVPS::getAltOutputLayerFlagVar( Int i ) |
---|
2448 | { |
---|
2449 | // Semantics variable not syntax element ! |
---|
2450 | |
---|
2451 | Bool altOptLayerFlag = false; |
---|
2452 | if ( i > 0 && getNumOutputLayersInOutputLayerSet( i ) == 1 && |
---|
2453 | getNumDirectRefLayers( getOlsHighestOutputLayerId( i ) ) > 0 ) |
---|
2454 | { |
---|
2455 | altOptLayerFlag = getAltOutputLayerFlag( i ); |
---|
2456 | } |
---|
2457 | return altOptLayerFlag; |
---|
2458 | } |
---|
2459 | |
---|
2460 | Int TComVPS::getMaxNumPics( Int layerId ) |
---|
2461 | { |
---|
2462 | Int maxNumPics = MAX_INT; |
---|
2463 | for( Int olsIdx = 0; olsIdx < getNumOutputLayerSets(); olsIdx++) |
---|
2464 | { |
---|
2465 | Int lsIdx = olsIdxToLsIdx( olsIdx ); |
---|
2466 | for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ ) |
---|
2467 | { |
---|
2468 | if( getLayerSetLayerIdList(lsIdx, j ) == layerId ) |
---|
2469 | { |
---|
2470 | Int maxSL = getMaxSubLayersInLayerSetMinus1( lsIdx ); |
---|
2471 | maxNumPics = std::min( maxNumPics, getDpbSize()->getMaxVpsDecPicBufferingMinus1( olsIdx , j, maxSL ) ); |
---|
2472 | } |
---|
2473 | } |
---|
2474 | } |
---|
2475 | assert( maxNumPics != MAX_INT ); |
---|
2476 | return maxNumPics; |
---|
2477 | } |
---|
2478 | |
---|
2479 | Void TComVPS::xSetRefLayerFlags( Int currLayerId ) |
---|
2480 | { |
---|
2481 | for( Int j = 0; j < getNumDirectRefLayers( currLayerId ); j++ ) |
---|
2482 | { |
---|
2483 | Int refLayerId = m_refLayerId[ currLayerId ][ j ]; |
---|
2484 | m_recursiveRefLayerFlag[ currLayerId ][ refLayerId ] = 1; |
---|
2485 | for( Int k = 0; k < MAX_NUM_LAYER_IDS; k++ ) |
---|
2486 | { |
---|
2487 | m_recursiveRefLayerFlag[ currLayerId ][ k ] = m_recursiveRefLayerFlag[ currLayerId ][ k ] || m_recursiveRefLayerFlag[ refLayerId ][ k ]; |
---|
2488 | } |
---|
2489 | } |
---|
2490 | } |
---|
2491 | |
---|
2492 | #endif // H_MV |
---|
2493 | |
---|
2494 | // ------------------------------------------------------------------------------------------------ |
---|
2495 | // Sequence parameter set (SPS) |
---|
2496 | // ------------------------------------------------------------------------------------------------ |
---|
2497 | |
---|
2498 | TComSPS::TComSPS() |
---|
2499 | : m_SPSId ( 0) |
---|
2500 | , m_VPSId ( 0) |
---|
2501 | , m_chromaFormatIdc (CHROMA_420) |
---|
2502 | , m_uiMaxTLayers ( 1) |
---|
2503 | // Structure |
---|
2504 | , m_picWidthInLumaSamples (352) |
---|
2505 | , m_picHeightInLumaSamples (288) |
---|
2506 | , m_log2MinCodingBlockSize ( 0) |
---|
2507 | , m_log2DiffMaxMinCodingBlockSize (0) |
---|
2508 | , m_uiMaxCUWidth ( 32) |
---|
2509 | , m_uiMaxCUHeight ( 32) |
---|
2510 | , m_uiMaxCUDepth ( 3) |
---|
2511 | , m_bLongTermRefsPresent (false) |
---|
2512 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
2513 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
2514 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
2515 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
2516 | // Tool list |
---|
2517 | , m_usePCM (false) |
---|
2518 | , m_pcmLog2MaxSize ( 5) |
---|
2519 | , m_uiPCMLog2MinSize ( 7) |
---|
2520 | #if H_3D_QTLPC |
---|
2521 | , m_bUseQTL (false) |
---|
2522 | , m_bUsePC (false) |
---|
2523 | #endif |
---|
2524 | , m_bitDepthY ( 8) |
---|
2525 | , m_bitDepthC ( 8) |
---|
2526 | , m_qpBDOffsetY ( 0) |
---|
2527 | , m_qpBDOffsetC ( 0) |
---|
2528 | , m_uiPCMBitDepthLuma ( 8) |
---|
2529 | , m_uiPCMBitDepthChroma ( 8) |
---|
2530 | , m_bPCMFilterDisableFlag (false) |
---|
2531 | , m_uiBitsForPOC ( 8) |
---|
2532 | , m_numLongTermRefPicSPS ( 0) |
---|
2533 | , m_uiMaxTrSize ( 32) |
---|
2534 | , m_bUseSAO (false) |
---|
2535 | , m_bTemporalIdNestingFlag (false) |
---|
2536 | , m_scalingListEnabledFlag (false) |
---|
2537 | , m_useStrongIntraSmoothing (false) |
---|
2538 | , m_vuiParametersPresentFlag (false) |
---|
2539 | , m_vuiParameters () |
---|
2540 | #if H_MV |
---|
2541 | , m_pcVPS ( NULL ) |
---|
2542 | , m_spsInferScalingListFlag ( false ) |
---|
2543 | , m_spsScalingListRefLayerId ( 0 ) |
---|
2544 | |
---|
2545 | , m_updateRepFormatFlag ( false ) |
---|
2546 | , m_spsRepFormatIdx ( 0 ) |
---|
2547 | , m_interViewMvVertConstraintFlag (false) |
---|
2548 | #endif |
---|
2549 | #if H_3D |
---|
2550 | , m_bCamParInSliceHeader (false) |
---|
2551 | #endif |
---|
2552 | { |
---|
2553 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
2554 | { |
---|
2555 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2556 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2557 | m_numReorderPics[i] = 0; |
---|
2558 | } |
---|
2559 | m_scalingList = new TComScalingList; |
---|
2560 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
2561 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
2562 | #if H_MV |
---|
2563 | m_spsRangeExtensionsFlag = false; |
---|
2564 | m_spsMultilayerExtensionFlag = false; |
---|
2565 | #if H_3D |
---|
2566 | m_spsExtension5bits = 0; |
---|
2567 | m_sps3dExtensionFlag = false; |
---|
2568 | #else |
---|
2569 | m_spsExtension6bits = 0; |
---|
2570 | #endif |
---|
2571 | |
---|
2572 | m_numScaledRefLayerOffsets = 0; |
---|
2573 | |
---|
2574 | for (Int i = 0; i < MAX_NUM_SCALED_REF_LAYERS; i++ ) |
---|
2575 | { |
---|
2576 | m_scaledRefLayerId [i] = -1; |
---|
2577 | } |
---|
2578 | |
---|
2579 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
2580 | { |
---|
2581 | m_scaledRefLayerLeftOffset [i] = 0; |
---|
2582 | m_scaledRefLayerTopOffset [i] = 0; |
---|
2583 | m_scaledRefLayerRightOffset [i] = 0; |
---|
2584 | m_scaledRefLayerBottomOffset [i] = 0; |
---|
2585 | } |
---|
2586 | #endif |
---|
2587 | } |
---|
2588 | |
---|
2589 | TComSPS::~TComSPS() |
---|
2590 | { |
---|
2591 | delete m_scalingList; |
---|
2592 | m_RPSList.destroy(); |
---|
2593 | } |
---|
2594 | |
---|
2595 | Void TComSPS::createRPSList( Int numRPS ) |
---|
2596 | { |
---|
2597 | m_RPSList.destroy(); |
---|
2598 | m_RPSList.create(numRPS); |
---|
2599 | } |
---|
2600 | |
---|
2601 | Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
2602 | { |
---|
2603 | if( !getVuiParametersPresentFlag() ) |
---|
2604 | { |
---|
2605 | return; |
---|
2606 | } |
---|
2607 | |
---|
2608 | TComVUI *vui = getVuiParameters(); |
---|
2609 | TComHRD *hrd = vui->getHrdParameters(); |
---|
2610 | |
---|
2611 | TimingInfo *timingInfo = vui->getTimingInfo(); |
---|
2612 | timingInfo->setTimingInfoPresentFlag( true ); |
---|
2613 | switch( frameRate ) |
---|
2614 | { |
---|
2615 | case 24: |
---|
2616 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2617 | break; |
---|
2618 | case 25: |
---|
2619 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2620 | break; |
---|
2621 | case 30: |
---|
2622 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2623 | break; |
---|
2624 | case 50: |
---|
2625 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2626 | break; |
---|
2627 | case 60: |
---|
2628 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2629 | break; |
---|
2630 | default: |
---|
2631 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
---|
2632 | break; |
---|
2633 | } |
---|
2634 | |
---|
2635 | Bool rateCnt = ( bitRate > 0 ); |
---|
2636 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
2637 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
2638 | |
---|
2639 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
2640 | |
---|
2641 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
2642 | { |
---|
2643 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
2644 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
2645 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
2646 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
2647 | } |
---|
2648 | else |
---|
2649 | { |
---|
2650 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
2651 | } |
---|
2652 | |
---|
2653 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
2654 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
2655 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
2656 | |
---|
2657 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
2658 | if( randomAccess ) |
---|
2659 | { |
---|
2660 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
2661 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
2662 | } |
---|
2663 | else |
---|
2664 | { |
---|
2665 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
2666 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
2667 | } |
---|
2668 | |
---|
2669 | /* |
---|
2670 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
2671 | */ |
---|
2672 | Int i, j; |
---|
2673 | UInt birateValue, cpbSizeValue; |
---|
2674 | UInt ducpbSizeValue; |
---|
2675 | UInt duBitRateValue = 0; |
---|
2676 | |
---|
2677 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
2678 | { |
---|
2679 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
2680 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
2681 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
2682 | hrd->setCpbCntMinus1( i, 0 ); |
---|
2683 | |
---|
2684 | birateValue = bitRate; |
---|
2685 | cpbSizeValue = bitRate; // 1 second |
---|
2686 | ducpbSizeValue = bitRate/numDU; |
---|
2687 | duBitRateValue = bitRate; |
---|
2688 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
2689 | { |
---|
2690 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
2691 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
2692 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
2693 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
2694 | |
---|
2695 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
2696 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
2697 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
2698 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
2699 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
2700 | } |
---|
2701 | } |
---|
2702 | } |
---|
2703 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
2704 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
2705 | |
---|
2706 | TComPPS::TComPPS() |
---|
2707 | : m_PPSId (0) |
---|
2708 | , m_SPSId (0) |
---|
2709 | , m_picInitQPMinus26 (0) |
---|
2710 | , m_useDQP (false) |
---|
2711 | , m_bConstrainedIntraPred (false) |
---|
2712 | , m_bSliceChromaQpFlag (false) |
---|
2713 | , m_pcSPS (NULL) |
---|
2714 | , m_uiMaxCuDQPDepth (0) |
---|
2715 | , m_uiMinCuDQPSize (0) |
---|
2716 | , m_chromaCbQpOffset (0) |
---|
2717 | , m_chromaCrQpOffset (0) |
---|
2718 | , m_numRefIdxL0DefaultActive (1) |
---|
2719 | , m_numRefIdxL1DefaultActive (1) |
---|
2720 | , m_TransquantBypassEnableFlag (false) |
---|
2721 | , m_useTransformSkip (false) |
---|
2722 | , m_dependentSliceSegmentsEnabledFlag (false) |
---|
2723 | , m_tilesEnabledFlag (false) |
---|
2724 | , m_entropyCodingSyncEnabledFlag (false) |
---|
2725 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
2726 | , m_uniformSpacingFlag (0) |
---|
2727 | , m_iNumColumnsMinus1 (0) |
---|
2728 | , m_puiColumnWidth (NULL) |
---|
2729 | , m_iNumRowsMinus1 (0) |
---|
2730 | , m_puiRowHeight (NULL) |
---|
2731 | , m_iNumSubstreams (1) |
---|
2732 | , m_signHideFlag(0) |
---|
2733 | , m_cabacInitPresentFlag (false) |
---|
2734 | , m_encCABACTableIdx (I_SLICE) |
---|
2735 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
2736 | , m_loopFilterAcrossSlicesEnabledFlag (false) |
---|
2737 | , m_listsModificationPresentFlag( 0) |
---|
2738 | , m_numExtraSliceHeaderBits(0) |
---|
2739 | #if H_MV |
---|
2740 | , m_ppsInferScalingListFlag(false) |
---|
2741 | , m_ppsScalingListRefLayerId(0) |
---|
2742 | , m_pocResetInfoPresentFlag(false) |
---|
2743 | #if H_3D |
---|
2744 | , m_pcDLT(NULL) |
---|
2745 | #endif |
---|
2746 | #endif |
---|
2747 | { |
---|
2748 | m_scalingList = new TComScalingList; |
---|
2749 | |
---|
2750 | #if H_MV |
---|
2751 | m_ppsRangeExtensionsFlag = false; |
---|
2752 | m_ppsMultilayerExtensionFlag = false; |
---|
2753 | #if !H_3D |
---|
2754 | m_ppsExtension6bits = 0; |
---|
2755 | #else |
---|
2756 | m_pps3dExtensionFlag = false; |
---|
2757 | m_ppsExtension5bits = 0; |
---|
2758 | #endif |
---|
2759 | #endif |
---|
2760 | } |
---|
2761 | |
---|
2762 | TComPPS::~TComPPS() |
---|
2763 | { |
---|
2764 | if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
2765 | { |
---|
2766 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
2767 | m_puiColumnWidth = NULL; |
---|
2768 | } |
---|
2769 | if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
2770 | { |
---|
2771 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
2772 | m_puiRowHeight = NULL; |
---|
2773 | } |
---|
2774 | delete m_scalingList; |
---|
2775 | } |
---|
2776 | |
---|
2777 | #if H_3D |
---|
2778 | TComDLT::TComDLT() |
---|
2779 | : m_bDltPresentFlag(false) |
---|
2780 | , m_iNumDepthViews(0) |
---|
2781 | , m_uiDepthViewBitDepth(8) |
---|
2782 | { |
---|
2783 | m_uiDepthViewBitDepth = g_bitDepthY; |
---|
2784 | |
---|
2785 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
2786 | { |
---|
2787 | m_bUseDLTFlag [i] = false; |
---|
2788 | m_bInterViewDltPredEnableFlag [i] = false; |
---|
2789 | |
---|
2790 | // allocate some memory and initialize with default mapping |
---|
2791 | m_iNumDepthmapValues[i] = ((1 << m_uiDepthViewBitDepth)-1)+1; |
---|
2792 | m_iBitsPerDepthValue[i] = numBitsForValue(m_iNumDepthmapValues[i]); |
---|
2793 | |
---|
2794 | m_iDepthValue2Idx[i] = (Int*) xMalloc(Int, m_iNumDepthmapValues[i]); |
---|
2795 | m_iIdx2DepthValue[i] = (Int*) xMalloc(Int, m_iNumDepthmapValues[i]); |
---|
2796 | |
---|
2797 | //default mapping |
---|
2798 | for (Int d=0; d<m_iNumDepthmapValues[i]; d++) |
---|
2799 | { |
---|
2800 | m_iDepthValue2Idx[i][d] = d; |
---|
2801 | m_iIdx2DepthValue[i][d] = d; |
---|
2802 | } |
---|
2803 | } |
---|
2804 | } |
---|
2805 | |
---|
2806 | TComDLT::~TComDLT() |
---|
2807 | { |
---|
2808 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
2809 | { |
---|
2810 | if ( m_iDepthValue2Idx[i] != NULL ) |
---|
2811 | { |
---|
2812 | xFree( m_iDepthValue2Idx[i] ); |
---|
2813 | m_iDepthValue2Idx[i] = NULL; |
---|
2814 | } |
---|
2815 | |
---|
2816 | if ( m_iIdx2DepthValue[i] != NULL ) |
---|
2817 | { |
---|
2818 | xFree( m_iIdx2DepthValue[i] ); |
---|
2819 | m_iIdx2DepthValue[i] = NULL; |
---|
2820 | } |
---|
2821 | } |
---|
2822 | } |
---|
2823 | |
---|
2824 | Void TComDLT::setDepthLUTs(Int layerIdInVps, Int* idxToDepthValueTable, Int iNumDepthValues) |
---|
2825 | { |
---|
2826 | if( idxToDepthValueTable == NULL || iNumDepthValues == 0 ) // default mapping only |
---|
2827 | return; |
---|
2828 | |
---|
2829 | // copy idx2DepthValue to internal array |
---|
2830 | memcpy(m_iIdx2DepthValue[layerIdInVps], idxToDepthValueTable, iNumDepthValues*sizeof(UInt)); |
---|
2831 | |
---|
2832 | UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1); |
---|
2833 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
2834 | { |
---|
2835 | Int iIdxDown = 0; |
---|
2836 | Int iIdxUp = iNumDepthValues-1; |
---|
2837 | Bool bFound = false; |
---|
2838 | |
---|
2839 | // iterate over indices to find lower closest depth |
---|
2840 | Int i = 1; |
---|
2841 | while(!bFound && i<iNumDepthValues) |
---|
2842 | { |
---|
2843 | if( m_iIdx2DepthValue[layerIdInVps][i] > p ) |
---|
2844 | { |
---|
2845 | iIdxDown = i-1; |
---|
2846 | bFound = true; |
---|
2847 | } |
---|
2848 | |
---|
2849 | i++; |
---|
2850 | } |
---|
2851 | // iterate over indices to find upper closest depth |
---|
2852 | i = iNumDepthValues-2; |
---|
2853 | bFound = false; |
---|
2854 | while(!bFound && i>=0) |
---|
2855 | { |
---|
2856 | if( m_iIdx2DepthValue[layerIdInVps][i] < p ) |
---|
2857 | { |
---|
2858 | iIdxUp = i+1; |
---|
2859 | bFound = true; |
---|
2860 | } |
---|
2861 | |
---|
2862 | i--; |
---|
2863 | } |
---|
2864 | |
---|
2865 | // assert monotony |
---|
2866 | assert(iIdxDown<=iIdxUp); |
---|
2867 | |
---|
2868 | // assign closer depth value/idx |
---|
2869 | if( abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxDown]) < abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxUp]) ) |
---|
2870 | { |
---|
2871 | m_iDepthValue2Idx[layerIdInVps][p] = iIdxDown; |
---|
2872 | } |
---|
2873 | else |
---|
2874 | { |
---|
2875 | m_iDepthValue2Idx[layerIdInVps][p] = iIdxUp; |
---|
2876 | } |
---|
2877 | |
---|
2878 | } |
---|
2879 | |
---|
2880 | // update DLT variables |
---|
2881 | m_iNumDepthmapValues[layerIdInVps] = iNumDepthValues; |
---|
2882 | m_iBitsPerDepthValue[layerIdInVps] = numBitsForValue(m_iNumDepthmapValues[layerIdInVps]); |
---|
2883 | } |
---|
2884 | |
---|
2885 | #if H_3D_DELTA_DLT |
---|
2886 | Void TComDLT::getDeltaDLT( Int layerIdInVps, Int* piDLTInRef, UInt uiDLTInRefNum, Int* piDeltaDLTOut, UInt *puiDeltaDLTOutNum ) |
---|
2887 | { |
---|
2888 | Bool abBM0[ 256 ]; |
---|
2889 | Bool abBM1[ 256 ]; |
---|
2890 | |
---|
2891 | memset( abBM0, 0, sizeof( abBM0 )); |
---|
2892 | memset( abBM1, 0, sizeof( abBM1 )); |
---|
2893 | |
---|
2894 | // convert reference DLT to bit string |
---|
2895 | for( Int i = 0; i < uiDLTInRefNum; i++ ) |
---|
2896 | { |
---|
2897 | abBM0[ piDLTInRef[ i ] ] = true; |
---|
2898 | } |
---|
2899 | // convert internal DLT to bit string |
---|
2900 | for( Int i = 0; i < m_iNumDepthmapValues[ layerIdInVps ]; i++ ) |
---|
2901 | { |
---|
2902 | abBM1[ m_iIdx2DepthValue[ layerIdInVps ][ i ] ] = true; |
---|
2903 | } |
---|
2904 | |
---|
2905 | *puiDeltaDLTOutNum = 0; |
---|
2906 | for( Int i = 0; i < 256; i++ ) |
---|
2907 | { |
---|
2908 | if( abBM0[ i ] ^ abBM1[ i ] ) |
---|
2909 | { |
---|
2910 | piDeltaDLTOut[ *puiDeltaDLTOutNum ] = i; |
---|
2911 | *puiDeltaDLTOutNum = *puiDeltaDLTOutNum + 1; |
---|
2912 | } |
---|
2913 | } |
---|
2914 | } |
---|
2915 | |
---|
2916 | Void TComDLT::setDeltaDLT( Int layerIdInVps, Int* piDLTInRef, UInt uiDLTInRefNum, Int* piDeltaDLTIn, UInt uiDeltaDLTInNum ) |
---|
2917 | { |
---|
2918 | Bool abBM0[ 256 ]; |
---|
2919 | Bool abBM1[ 256 ]; |
---|
2920 | |
---|
2921 | memset( abBM0, 0, sizeof( abBM0 )); |
---|
2922 | memset( abBM1, 0, sizeof( abBM1 )); |
---|
2923 | |
---|
2924 | // convert reference DLT to bit string |
---|
2925 | for( Int i = 0; i < uiDLTInRefNum; i++ ) |
---|
2926 | { |
---|
2927 | abBM0[ piDLTInRef[ i ] ] = true; |
---|
2928 | } |
---|
2929 | // convert delta DLT to bit string |
---|
2930 | for( Int i = 0; i < uiDeltaDLTInNum; i++ ) |
---|
2931 | { |
---|
2932 | abBM1[ piDeltaDLTIn[ i ] ] = true; |
---|
2933 | } |
---|
2934 | |
---|
2935 | Int aiIdx2DepthValue[256]; |
---|
2936 | UInt uiNumDepthValues = 0; |
---|
2937 | memset( aiIdx2DepthValue, 0, sizeof( aiIdx2DepthValue )); |
---|
2938 | |
---|
2939 | for( Int i = 0; i < 256; i++ ) |
---|
2940 | { |
---|
2941 | if( abBM0[ i ] ^ abBM1[ i ] ) |
---|
2942 | { |
---|
2943 | aiIdx2DepthValue[ uiNumDepthValues++ ] = i; |
---|
2944 | } |
---|
2945 | } |
---|
2946 | |
---|
2947 | // update internal tables |
---|
2948 | setDepthLUTs(layerIdInVps, aiIdx2DepthValue, uiNumDepthValues); |
---|
2949 | } |
---|
2950 | #endif |
---|
2951 | |
---|
2952 | #endif |
---|
2953 | |
---|
2954 | #if H_MV |
---|
2955 | Void TComSPS::inferRepFormat( TComVPS* vps, Int layerIdCurr ) |
---|
2956 | { |
---|
2957 | if ( layerIdCurr > 0 ) |
---|
2958 | { |
---|
2959 | Int repFormatIdx = getUpdateRepFormatFlag() ? getSpsRepFormatIdx() : vps->getVpsRepFormatIdx( vps->getLayerIdInVps( layerIdCurr ) ) ; |
---|
2960 | TComRepFormat* repFormat = vps->getRepFormat( repFormatIdx ); |
---|
2961 | setChromaFormatIdc( repFormat->getChromaFormatVpsIdc() ); |
---|
2962 | //// ToDo: add when supported: |
---|
2963 | // setSeperateColourPlaneFlag( repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
2964 | |
---|
2965 | setPicWidthInLumaSamples ( repFormat->getPicWidthVpsInLumaSamples() ); |
---|
2966 | setPicHeightInLumaSamples( repFormat->getPicHeightVpsInLumaSamples() ); |
---|
2967 | |
---|
2968 | setBitDepthY ( repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
2969 | setQpBDOffsetY ( (Int) (6*( getBitDepthY() - 8 )) ); |
---|
2970 | |
---|
2971 | setBitDepthC ( repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
2972 | setQpBDOffsetC ( (Int) (6* ( getBitDepthC() -8 ) ) ); |
---|
2973 | if ( getLayerId() > 0 && getUpdateRepFormatFlag() ) |
---|
2974 | { |
---|
2975 | assert( getChromaFormatIdc() <= repFormat->getChromaFormatVpsIdc() ); |
---|
2976 | //// ToDo: add when supported: |
---|
2977 | // assert( getSeperateColourPlaneFlag() <= repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
2978 | |
---|
2979 | assert( getPicWidthInLumaSamples() <= repFormat->getPicWidthVpsInLumaSamples() ); |
---|
2980 | assert( getPicHeightInLumaSamples() <= repFormat->getPicHeightVpsInLumaSamples() ); |
---|
2981 | |
---|
2982 | assert( getBitDepthY() <= repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
2983 | assert( getBitDepthC() <= repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
2984 | } |
---|
2985 | } |
---|
2986 | |
---|
2987 | // Set conformance window |
---|
2988 | Int scal = TComSPS::getWinUnitX( getChromaFormatIdc() ) ; |
---|
2989 | getConformanceWindow().scaleOffsets( scal ); |
---|
2990 | getVuiParameters()->getDefaultDisplayWindow().scaleOffsets( scal ); |
---|
2991 | } |
---|
2992 | |
---|
2993 | Void TComSPS::inferScalingList( TComSPS* spsSrc ) |
---|
2994 | { |
---|
2995 | if ( getSpsInferScalingListFlag() ) |
---|
2996 | { |
---|
2997 | assert( spsSrc != NULL ); |
---|
2998 | assert( !spsSrc->getSpsInferScalingListFlag() ); |
---|
2999 | getScalingList()->inferFrom( spsSrc->getScalingList() ); |
---|
3000 | } |
---|
3001 | } |
---|
3002 | |
---|
3003 | Void TComSPS::inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder ) |
---|
3004 | { |
---|
3005 | const std::vector<Int>& targetDecLayerIdList = vps->getTargetDecLayerIdList( vps->olsIdxToLsIdx( targetOptLayerSetIdx )); |
---|
3006 | |
---|
3007 | if (getLayerId() > 0 ) |
---|
3008 | { |
---|
3009 | Int layerIdx = 0; |
---|
3010 | while (layerIdx < (Int) targetDecLayerIdList.size() ) |
---|
3011 | { |
---|
3012 | if ( targetDecLayerIdList[layerIdx] == currLayerId ) |
---|
3013 | { |
---|
3014 | break; |
---|
3015 | } |
---|
3016 | layerIdx++; |
---|
3017 | } |
---|
3018 | |
---|
3019 | assert( layerIdx < (Int) targetDecLayerIdList.size() ); |
---|
3020 | |
---|
3021 | for (Int i = 0; i <= getSpsMaxSubLayersMinus1(); i++ ) |
---|
3022 | { |
---|
3023 | Int maxDecPicBufferingMinus1 = vps->getDpbSize()->getMaxVpsDecPicBufferingMinus1( targetOptLayerSetIdx, layerIdx, i ) ; |
---|
3024 | |
---|
3025 | if ( encoder ) |
---|
3026 | { |
---|
3027 | assert( getMaxDecPicBuffering( i ) - 1 == maxDecPicBufferingMinus1 ); |
---|
3028 | } |
---|
3029 | else |
---|
3030 | { |
---|
3031 | setMaxDecPicBuffering(i, maxDecPicBufferingMinus1 + 1 ); |
---|
3032 | } |
---|
3033 | } |
---|
3034 | } |
---|
3035 | } |
---|
3036 | |
---|
3037 | Void TComSPS::checkRpsMaxNumPics( TComVPS* vps, Int currLayerId ) |
---|
3038 | { |
---|
3039 | // In spec, when rps is in SPS, nuh_layer_id of SPS is used instead |
---|
3040 | // of nuh_layer_id of slice (currLayerId), this seems to be a bug. |
---|
3041 | |
---|
3042 | for (Int i = 0; i < getRPSList()->getNumberOfReferencePictureSets(); i++ ) |
---|
3043 | { |
---|
3044 | TComReferencePictureSet* rps = getRPSList()->getReferencePictureSet( i ); |
---|
3045 | if ( !rps->getInterRPSPrediction() ) |
---|
3046 | { |
---|
3047 | rps->checkMaxNumPics( vps->getVpsExtensionFlag(), vps->getMaxNumPics( currLayerId ), |
---|
3048 | getLayerId(), getMaxDecPicBuffering( getSpsMaxSubLayersMinus1() ) - 1 ); |
---|
3049 | } |
---|
3050 | } |
---|
3051 | } |
---|
3052 | |
---|
3053 | #endif |
---|
3054 | |
---|
3055 | TComReferencePictureSet::TComReferencePictureSet() |
---|
3056 | : m_numberOfPictures (0) |
---|
3057 | , m_numberOfNegativePictures (0) |
---|
3058 | , m_numberOfPositivePictures (0) |
---|
3059 | , m_numberOfLongtermPictures (0) |
---|
3060 | , m_interRPSPrediction (0) |
---|
3061 | , m_deltaRIdxMinus1 (0) |
---|
3062 | , m_deltaRPS (0) |
---|
3063 | , m_numRefIdc (0) |
---|
3064 | { |
---|
3065 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
3066 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
3067 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
3068 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
3069 | } |
---|
3070 | |
---|
3071 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
3072 | { |
---|
3073 | } |
---|
3074 | |
---|
3075 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
3076 | { |
---|
3077 | m_used[bufferNum] = used; |
---|
3078 | } |
---|
3079 | |
---|
3080 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
3081 | { |
---|
3082 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
3083 | } |
---|
3084 | |
---|
3085 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
3086 | { |
---|
3087 | m_numberOfPictures = numberOfPictures; |
---|
3088 | } |
---|
3089 | |
---|
3090 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
3091 | { |
---|
3092 | return m_used[bufferNum]; |
---|
3093 | } |
---|
3094 | |
---|
3095 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
3096 | { |
---|
3097 | return m_deltaPOC[bufferNum]; |
---|
3098 | } |
---|
3099 | |
---|
3100 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
3101 | { |
---|
3102 | return m_numberOfPictures; |
---|
3103 | } |
---|
3104 | |
---|
3105 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
3106 | { |
---|
3107 | return m_POC[bufferNum]; |
---|
3108 | } |
---|
3109 | |
---|
3110 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
3111 | { |
---|
3112 | m_POC[bufferNum] = POC; |
---|
3113 | } |
---|
3114 | |
---|
3115 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) |
---|
3116 | { |
---|
3117 | return m_bCheckLTMSB[bufferNum]; |
---|
3118 | } |
---|
3119 | |
---|
3120 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
3121 | { |
---|
3122 | m_bCheckLTMSB[bufferNum] = b; |
---|
3123 | } |
---|
3124 | |
---|
3125 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
3126 | * \param uiBufferNum |
---|
3127 | * \param iRefIdc |
---|
3128 | * \returns Void |
---|
3129 | */ |
---|
3130 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
3131 | { |
---|
3132 | m_refIdc[bufferNum] = refIdc; |
---|
3133 | } |
---|
3134 | |
---|
3135 | /** get the reference idc value at uiBufferNum |
---|
3136 | * \param uiBufferNum |
---|
3137 | * \returns Int |
---|
3138 | */ |
---|
3139 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
3140 | { |
---|
3141 | return m_refIdc[bufferNum]; |
---|
3142 | } |
---|
3143 | |
---|
3144 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
3145 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
3146 | * +ve values are in increasing order. |
---|
3147 | * \returns Void |
---|
3148 | */ |
---|
3149 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
3150 | { |
---|
3151 | // sort in increasing order (smallest first) |
---|
3152 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
3153 | { |
---|
3154 | Int deltaPOC = getDeltaPOC(j); |
---|
3155 | Bool used = getUsed(j); |
---|
3156 | for (Int k=j-1; k >= 0; k--) |
---|
3157 | { |
---|
3158 | Int temp = getDeltaPOC(k); |
---|
3159 | if (deltaPOC < temp) |
---|
3160 | { |
---|
3161 | setDeltaPOC(k+1, temp); |
---|
3162 | setUsed(k+1, getUsed(k)); |
---|
3163 | setDeltaPOC(k, deltaPOC); |
---|
3164 | setUsed(k, used); |
---|
3165 | } |
---|
3166 | } |
---|
3167 | } |
---|
3168 | // flip the negative values to largest first |
---|
3169 | Int numNegPics = getNumberOfNegativePictures(); |
---|
3170 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
3171 | { |
---|
3172 | Int deltaPOC = getDeltaPOC(j); |
---|
3173 | Bool used = getUsed(j); |
---|
3174 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
3175 | setUsed(j, getUsed(k)); |
---|
3176 | setDeltaPOC(k, deltaPOC); |
---|
3177 | setUsed(k, used); |
---|
3178 | } |
---|
3179 | } |
---|
3180 | |
---|
3181 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
3182 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
3183 | * \returns Void |
---|
3184 | */ |
---|
3185 | Void TComReferencePictureSet::printDeltaPOC() |
---|
3186 | { |
---|
3187 | printf("DeltaPOC = { "); |
---|
3188 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
3189 | { |
---|
3190 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
3191 | } |
---|
3192 | if (getInterRPSPrediction()) |
---|
3193 | { |
---|
3194 | printf("}, RefIdc = { "); |
---|
3195 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
3196 | { |
---|
3197 | printf("%d ", getRefIdc(j)); |
---|
3198 | } |
---|
3199 | } |
---|
3200 | printf("}\n"); |
---|
3201 | } |
---|
3202 | #if H_MV |
---|
3203 | Void TComReferencePictureSet::checkMaxNumPics( Bool vpsExtensionFlag, Int maxNumPics, Int nuhLayerId, Int spsMaxDecPicBufferingMinus1 ) |
---|
3204 | { |
---|
3205 | assert( getNumberOfPictures() >= 0 ); |
---|
3206 | if ( nuhLayerId == 0 ) |
---|
3207 | { |
---|
3208 | assert( getNumberOfPictures() <= spsMaxDecPicBufferingMinus1 ); |
---|
3209 | } |
---|
3210 | |
---|
3211 | if ( vpsExtensionFlag ) |
---|
3212 | { |
---|
3213 | assert( getNumberOfPictures() <= maxNumPics ); |
---|
3214 | } |
---|
3215 | } |
---|
3216 | #endif |
---|
3217 | |
---|
3218 | TComRPSList::TComRPSList() |
---|
3219 | :m_referencePictureSets (NULL) |
---|
3220 | { |
---|
3221 | } |
---|
3222 | |
---|
3223 | TComRPSList::~TComRPSList() |
---|
3224 | { |
---|
3225 | } |
---|
3226 | |
---|
3227 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
3228 | { |
---|
3229 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
3230 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
3231 | } |
---|
3232 | |
---|
3233 | Void TComRPSList::destroy() |
---|
3234 | { |
---|
3235 | if (m_referencePictureSets) |
---|
3236 | { |
---|
3237 | delete [] m_referencePictureSets; |
---|
3238 | } |
---|
3239 | m_numberOfReferencePictureSets = 0; |
---|
3240 | m_referencePictureSets = NULL; |
---|
3241 | } |
---|
3242 | |
---|
3243 | |
---|
3244 | |
---|
3245 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
3246 | { |
---|
3247 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
3248 | } |
---|
3249 | |
---|
3250 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
3251 | { |
---|
3252 | return m_numberOfReferencePictureSets; |
---|
3253 | } |
---|
3254 | |
---|
3255 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
3256 | { |
---|
3257 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
3258 | } |
---|
3259 | |
---|
3260 | TComRefPicListModification::TComRefPicListModification() |
---|
3261 | : m_bRefPicListModificationFlagL0 (false) |
---|
3262 | , m_bRefPicListModificationFlagL1 (false) |
---|
3263 | { |
---|
3264 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
3265 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
3266 | } |
---|
3267 | |
---|
3268 | TComRefPicListModification::~TComRefPicListModification() |
---|
3269 | { |
---|
3270 | } |
---|
3271 | |
---|
3272 | TComScalingList::TComScalingList() |
---|
3273 | { |
---|
3274 | init(); |
---|
3275 | } |
---|
3276 | TComScalingList::~TComScalingList() |
---|
3277 | { |
---|
3278 | destroy(); |
---|
3279 | } |
---|
3280 | |
---|
3281 | /** set default quantization matrix to array |
---|
3282 | */ |
---|
3283 | Void TComSlice::setDefaultScalingList() |
---|
3284 | { |
---|
3285 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3286 | { |
---|
3287 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
3288 | { |
---|
3289 | getScalingList()->processDefaultMatrix(sizeId, listId); |
---|
3290 | } |
---|
3291 | } |
---|
3292 | } |
---|
3293 | /** check if use default quantization matrix |
---|
3294 | * \returns true if use default quantization matrix in all size |
---|
3295 | */ |
---|
3296 | Bool TComSlice::checkDefaultScalingList() |
---|
3297 | { |
---|
3298 | UInt defaultCounter=0; |
---|
3299 | |
---|
3300 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3301 | { |
---|
3302 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
3303 | { |
---|
3304 | 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 |
---|
3305 | && ((sizeId < SCALING_LIST_16x16) || (getScalingList()->getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
3306 | { |
---|
3307 | defaultCounter++; |
---|
3308 | } |
---|
3309 | } |
---|
3310 | } |
---|
3311 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32 |
---|
3312 | } |
---|
3313 | |
---|
3314 | #if H_MV |
---|
3315 | Void TComSlice::createInterLayerReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1 ) |
---|
3316 | { |
---|
3317 | refPicSetInterLayer0.clear(); |
---|
3318 | refPicSetInterLayer1.clear(); |
---|
3319 | |
---|
3320 | for( Int i = 0; i < getNumActiveRefLayerPics(); i++ ) |
---|
3321 | { |
---|
3322 | Int layerIdRef = getRefPicLayerId( i ); |
---|
3323 | TComPic* picRef = ivPicLists->getPic( layerIdRef, getPOC() ) ; |
---|
3324 | assert ( picRef != 0 ); // There shall be no entry equal to "no reference picture" in RefPicSetInterLayer0 or RefPicSetInterLayer1. |
---|
3325 | |
---|
3326 | picRef->getPicYuvRec()->extendPicBorder(); |
---|
3327 | picRef->setIsLongTerm( true ); |
---|
3328 | picRef->getSlice(0)->setReferenced( true ); |
---|
3329 | |
---|
3330 | Int viewIdCur = getVPS()->getViewId( getLayerId() ); |
---|
3331 | Int viewIdZero = getVPS()->getViewId( 0 ); |
---|
3332 | Int viewIdRef = getVPS()->getViewId( layerIdRef ); |
---|
3333 | |
---|
3334 | if ( ( viewIdCur <= viewIdZero && viewIdCur <= viewIdRef ) || ( viewIdCur >= viewIdZero && viewIdCur >= viewIdRef ) ) |
---|
3335 | { |
---|
3336 | refPicSetInterLayer0.push_back( picRef ); |
---|
3337 | } |
---|
3338 | else |
---|
3339 | { |
---|
3340 | refPicSetInterLayer1.push_back( picRef ); |
---|
3341 | } |
---|
3342 | // Consider to check here: |
---|
3343 | // "If the current picture is a RADL picture, there shall be no entry in the RefPicSetInterLayer0 and RefPicSetInterLayer1 that is a RASL picture. " |
---|
3344 | assert( picRef->getSlice(0)->getDiscardableFlag() == false ); // "There shall be no picture that has discardable_flag equal to 1 in RefPicSetInterLayer0 or RefPicSetInterLayer1". |
---|
3345 | } |
---|
3346 | } |
---|
3347 | |
---|
3348 | Void TComSlice::markIvRefPicsAsShortTerm( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 ) |
---|
3349 | { |
---|
3350 | // Mark as short-term |
---|
3351 | for ( Int i = 0; i < refPicSetInterLayer0.size(); i++ ) |
---|
3352 | { |
---|
3353 | refPicSetInterLayer0[i]->setIsLongTerm( false ); |
---|
3354 | } |
---|
3355 | |
---|
3356 | for ( Int i = 0; i < refPicSetInterLayer1.size(); i++ ) |
---|
3357 | { |
---|
3358 | refPicSetInterLayer1[i]->setIsLongTerm( false ); |
---|
3359 | } |
---|
3360 | |
---|
3361 | } |
---|
3362 | |
---|
3363 | Void TComSlice::printRefPicList() |
---|
3364 | { |
---|
3365 | for ( Int li = 0; li < 2; li++) |
---|
3366 | { |
---|
3367 | std::cout << std::endl << "RefPicListL" << li << ":" << std::endl; |
---|
3368 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[li]-1); rIdx ++) |
---|
3369 | { |
---|
3370 | if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( true ); |
---|
3371 | |
---|
3372 | m_apcRefPicList[li][rIdx]->print( false ); |
---|
3373 | } |
---|
3374 | } |
---|
3375 | } |
---|
3376 | |
---|
3377 | Void TComSlice::markCurrPic( TComPic* currPic ) |
---|
3378 | { |
---|
3379 | currPic->getSlice(0)->setReferenced( true ) ; |
---|
3380 | currPic->setIsLongTerm( false ); |
---|
3381 | |
---|
3382 | currPic->setReconMark( true ); |
---|
3383 | currPic->setPicOutputFlag( currPic->getSlice(0)->getPicOutputFlag() ); |
---|
3384 | } |
---|
3385 | |
---|
3386 | Void TComSlice::setRefPicSetInterLayer( std::vector<TComPic*>* refPicSetInterLayer0, std::vector<TComPic*>* refPicSetInterLayer1 ) |
---|
3387 | { |
---|
3388 | m_refPicSetInterLayer0 = refPicSetInterLayer0; |
---|
3389 | m_refPicSetInterLayer1 = refPicSetInterLayer1; |
---|
3390 | } |
---|
3391 | |
---|
3392 | TComPic* TComSlice::getPicFromRefPicSetInterLayer(Int setIdc, Int layerId ) |
---|
3393 | { |
---|
3394 | assert ( setIdc == 0 || setIdc == 1); |
---|
3395 | std::vector<TComPic*>* refPicSetInterLayer = ( setIdc == 0 ? m_refPicSetInterLayer0 : m_refPicSetInterLayer1); |
---|
3396 | assert( refPicSetInterLayer != 0 ); |
---|
3397 | |
---|
3398 | TComPic* pcPic = NULL; |
---|
3399 | for ( Int i = 0; i < (*refPicSetInterLayer).size(); i++ ) |
---|
3400 | { |
---|
3401 | if ((*refPicSetInterLayer)[ i ]->getLayerId() == layerId ) |
---|
3402 | { |
---|
3403 | pcPic = (*refPicSetInterLayer)[ i ]; |
---|
3404 | } |
---|
3405 | } |
---|
3406 | |
---|
3407 | assert(pcPic != NULL); |
---|
3408 | return pcPic; |
---|
3409 | } |
---|
3410 | |
---|
3411 | |
---|
3412 | Int TComSlice::getRefLayerPicFlag( Int i ) |
---|
3413 | { |
---|
3414 | TComVPS* vps = getVPS(); |
---|
3415 | Int refLayerIdx = vps->getLayerIdInVps( vps->getRefLayerId( getLayerId(), i ) ); |
---|
3416 | |
---|
3417 | Bool refLayerPicFlag = ( vps->getSubLayersVpsMaxMinus1( refLayerIdx ) >= getTLayer() ) && ( getTLayer() == 0 ) && |
---|
3418 | ( vps->getMaxTidIlRefPicsPlus1( refLayerIdx, vps->getLayerIdInVps( getLayerId() )) > getTLayer() ); |
---|
3419 | |
---|
3420 | return refLayerPicFlag; |
---|
3421 | } |
---|
3422 | |
---|
3423 | Int TComSlice::getRefLayerPicIdc( Int j ) |
---|
3424 | { |
---|
3425 | Int refLayerPicIdc = -1; |
---|
3426 | Int curj = 0; |
---|
3427 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ ) |
---|
3428 | { |
---|
3429 | if( getRefLayerPicFlag( i ) ) |
---|
3430 | { |
---|
3431 | if ( curj == j ) |
---|
3432 | { |
---|
3433 | refLayerPicIdc = i; |
---|
3434 | break; |
---|
3435 | } |
---|
3436 | curj++; |
---|
3437 | } |
---|
3438 | } |
---|
3439 | |
---|
3440 | assert( curj == j ); |
---|
3441 | assert( refLayerPicIdc != -1 ); |
---|
3442 | return refLayerPicIdc; |
---|
3443 | } |
---|
3444 | |
---|
3445 | Int TComSlice::getNumRefLayerPics( ) |
---|
3446 | { |
---|
3447 | Int numRefLayerPics = 0; |
---|
3448 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ ) |
---|
3449 | { |
---|
3450 | numRefLayerPics += getRefLayerPicFlag( i ); |
---|
3451 | } |
---|
3452 | return numRefLayerPics; |
---|
3453 | } |
---|
3454 | |
---|
3455 | |
---|
3456 | |
---|
3457 | Int TComSlice::getNumActiveRefLayerPics() |
---|
3458 | { |
---|
3459 | Int numActiveRefLayerPics; |
---|
3460 | |
---|
3461 | if( getLayerId() == 0 || getNumRefLayerPics() == 0 ) |
---|
3462 | { |
---|
3463 | numActiveRefLayerPics = 0; |
---|
3464 | } |
---|
3465 | else if (getVPS()->getAllRefLayersActiveFlag() ) |
---|
3466 | { |
---|
3467 | numActiveRefLayerPics = getNumRefLayerPics(); |
---|
3468 | } |
---|
3469 | else if ( !getInterLayerPredEnabledFlag() ) |
---|
3470 | { |
---|
3471 | numActiveRefLayerPics = 0; |
---|
3472 | } |
---|
3473 | else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumDirectRefLayers( getLayerId() ) == 1 ) |
---|
3474 | { |
---|
3475 | numActiveRefLayerPics = 1; |
---|
3476 | } |
---|
3477 | else |
---|
3478 | { |
---|
3479 | numActiveRefLayerPics = getNumInterLayerRefPicsMinus1() + 1; |
---|
3480 | } |
---|
3481 | return numActiveRefLayerPics; |
---|
3482 | } |
---|
3483 | |
---|
3484 | Int TComSlice::getRefPicLayerId( Int i ) |
---|
3485 | { |
---|
3486 | return getVPS()->getRefLayerId( getLayerId(), getInterLayerPredLayerIdc( i ) ); |
---|
3487 | } |
---|
3488 | |
---|
3489 | #if H_3D_ARP |
---|
3490 | Void TComSlice::setARPStepNum( TComPicLists*ivPicLists ) |
---|
3491 | { |
---|
3492 | Bool tempRefPicInListsFlag = false; |
---|
3493 | if(!getVPS()->getUseAdvRP(getLayerId()) || this->isIRAP()) |
---|
3494 | { |
---|
3495 | m_nARPStepNum = 0; |
---|
3496 | } |
---|
3497 | else |
---|
3498 | { |
---|
3499 | setFirstTRefIdx (REF_PIC_LIST_0, -1); |
---|
3500 | setFirstTRefIdx (REF_PIC_LIST_1, -1); |
---|
3501 | for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ ) |
---|
3502 | { |
---|
3503 | Int diffPOC=MAX_INT; |
---|
3504 | Int idx=-1; |
---|
3505 | for(Int i = 0; i < getNumRefIdx(RefPicList(refListIdx)); i++ ) |
---|
3506 | { |
---|
3507 | if ( getRefPic(RefPicList(refListIdx), i)->getPOC() != getPOC() ) |
---|
3508 | { |
---|
3509 | if( abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC()) < diffPOC) |
---|
3510 | { |
---|
3511 | diffPOC=abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC()); |
---|
3512 | idx=i; |
---|
3513 | } |
---|
3514 | } |
---|
3515 | if(idx>=0) |
---|
3516 | { |
---|
3517 | setFirstTRefIdx (RefPicList(refListIdx), idx); |
---|
3518 | } |
---|
3519 | } |
---|
3520 | } |
---|
3521 | tempRefPicInListsFlag = getFirstTRefIdx(REF_PIC_LIST_0) >= 0 || getFirstTRefIdx(REF_PIC_LIST_1) >= 0; |
---|
3522 | m_nARPStepNum = tempRefPicInListsFlag ? getVPS()->getARPStepNum(getLayerId()) : 0; |
---|
3523 | } |
---|
3524 | |
---|
3525 | if (tempRefPicInListsFlag) |
---|
3526 | { |
---|
3527 | for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ ) |
---|
3528 | { |
---|
3529 | RefPicList eRefPicList = RefPicList( refListIdx ); |
---|
3530 | Int prevPOC = getRefPic(eRefPicList, getFirstTRefIdx(eRefPicList) )->getPOC(); |
---|
3531 | for( Int i = 0; i < getNumActiveRefLayerPics(); i++ ) |
---|
3532 | { |
---|
3533 | Int layerIdInNuh = getRefPicLayerId( i ); |
---|
3534 | Int viewIdx = getVPS()->getViewId( layerIdInNuh ); |
---|
3535 | TComPic*pcPicPrev = ivPicLists->getPic(viewIdx, 0, prevPOC); |
---|
3536 | if (getFirstTRefIdx(eRefPicList) >= 0 && pcPicPrev && pcPicPrev->getSlice( 0 )->isReferenced()) |
---|
3537 | { |
---|
3538 | m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = true; |
---|
3539 | } |
---|
3540 | else |
---|
3541 | { |
---|
3542 | m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = false; |
---|
3543 | } |
---|
3544 | } |
---|
3545 | } |
---|
3546 | } |
---|
3547 | } |
---|
3548 | #endif |
---|
3549 | #if H_3D_IC |
---|
3550 | Void TComSlice::xSetApplyIC(Bool bUseLowLatencyICEnc) |
---|
3551 | { |
---|
3552 | if(bUseLowLatencyICEnc) |
---|
3553 | { |
---|
3554 | Bool existInterViewRef=false; |
---|
3555 | TComPic* pcCurrPic = getPic(); |
---|
3556 | TComPic* pcRefPic = NULL; |
---|
3557 | for ( Int i = 0; (i < getNumRefIdx( REF_PIC_LIST_0 )) && !existInterViewRef; i++ ) |
---|
3558 | { |
---|
3559 | pcRefPic = getRefPic( REF_PIC_LIST_0, i ); |
---|
3560 | if ( pcRefPic != NULL ) |
---|
3561 | { |
---|
3562 | if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() ) |
---|
3563 | { |
---|
3564 | existInterViewRef = true; |
---|
3565 | } |
---|
3566 | } |
---|
3567 | } |
---|
3568 | |
---|
3569 | for ( Int i = 0; (i < getNumRefIdx( REF_PIC_LIST_1 )) && !existInterViewRef; i++ ) |
---|
3570 | { |
---|
3571 | pcRefPic = getRefPic( REF_PIC_LIST_1, i ); |
---|
3572 | if ( pcRefPic != NULL ) |
---|
3573 | { |
---|
3574 | if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() ) |
---|
3575 | { |
---|
3576 | existInterViewRef = true; |
---|
3577 | } |
---|
3578 | } |
---|
3579 | } |
---|
3580 | |
---|
3581 | if(!existInterViewRef) |
---|
3582 | { |
---|
3583 | m_bApplyIC = false; |
---|
3584 | } |
---|
3585 | else |
---|
3586 | { |
---|
3587 | Int curLayer=getDepth(); |
---|
3588 | if( curLayer>9) curLayer=9; // Max layer is 10 |
---|
3589 | |
---|
3590 | m_bApplyIC = true; |
---|
3591 | Int refLayer = curLayer-1; |
---|
3592 | if( (refLayer>=0) && (g_aICEnableCANDIDATE[refLayer]>0) ) |
---|
3593 | { |
---|
3594 | Double ratio=Double(g_aICEnableNUM[refLayer])/Double(g_aICEnableCANDIDATE[refLayer]); |
---|
3595 | |
---|
3596 | if( ratio > IC_LOW_LATENCY_ENCODING_THRESHOLD) |
---|
3597 | { |
---|
3598 | m_bApplyIC=true; |
---|
3599 | } |
---|
3600 | else |
---|
3601 | { |
---|
3602 | m_bApplyIC=false; |
---|
3603 | } |
---|
3604 | } |
---|
3605 | g_aICEnableNUM[curLayer]=0; |
---|
3606 | g_aICEnableCANDIDATE[curLayer]=0; |
---|
3607 | g_lastlayer=getDepth(); |
---|
3608 | } |
---|
3609 | } |
---|
3610 | else |
---|
3611 | { |
---|
3612 | Int iMaxPelValue = ( 1 << g_bitDepthY ); |
---|
3613 | Int *aiRefOrgHist; |
---|
3614 | Int *aiCurrHist; |
---|
3615 | aiRefOrgHist = (Int *) xMalloc( Int,iMaxPelValue ); |
---|
3616 | aiCurrHist = (Int *) xMalloc( Int,iMaxPelValue ); |
---|
3617 | memset( aiRefOrgHist, 0, iMaxPelValue*sizeof(Int) ); |
---|
3618 | memset( aiCurrHist, 0, iMaxPelValue*sizeof(Int) ); |
---|
3619 | // Reference Idx Number |
---|
3620 | Int iNumRefIdx = getNumRefIdx( REF_PIC_LIST_0 ); |
---|
3621 | TComPic* pcCurrPic = NULL; |
---|
3622 | TComPic* pcRefPic = NULL; |
---|
3623 | TComPicYuv* pcCurrPicYuv = NULL; |
---|
3624 | TComPicYuv* pcRefPicYuvOrg = NULL; |
---|
3625 | pcCurrPic = getPic(); |
---|
3626 | pcCurrPicYuv = pcCurrPic->getPicYuvOrg(); |
---|
3627 | Int iWidth = pcCurrPicYuv->getWidth(); |
---|
3628 | Int iHeight = pcCurrPicYuv->getHeight(); |
---|
3629 | |
---|
3630 | |
---|
3631 | // Get InterView Reference picture |
---|
3632 | // !!!!! Assume only one Interview Reference Picture in L0 |
---|
3633 | for ( Int i = 0; i < iNumRefIdx; i++ ) |
---|
3634 | { |
---|
3635 | pcRefPic = getRefPic( REF_PIC_LIST_0, i ); |
---|
3636 | if ( pcRefPic != NULL ) |
---|
3637 | { |
---|
3638 | if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() ) |
---|
3639 | { |
---|
3640 | pcRefPicYuvOrg = pcRefPic->getPicYuvOrg(); |
---|
3641 | } |
---|
3642 | } |
---|
3643 | } |
---|
3644 | |
---|
3645 | if ( pcRefPicYuvOrg != NULL ) |
---|
3646 | { |
---|
3647 | Pel* pCurrY = pcCurrPicYuv ->getLumaAddr(); |
---|
3648 | Pel* pRefOrgY = pcRefPicYuvOrg ->getLumaAddr(); |
---|
3649 | Int iCurrStride = pcCurrPicYuv->getStride(); |
---|
3650 | Int iRefStride = pcRefPicYuvOrg->getStride(); |
---|
3651 | Int iSumOrgSAD = 0; |
---|
3652 | Double dThresholdOrgSAD = getIsDepth() ? 0.1 : 0.05; |
---|
3653 | |
---|
3654 | // Histogram building - luminance |
---|
3655 | for ( Int y = 0; y < iHeight; y++ ) |
---|
3656 | { |
---|
3657 | for ( Int x = 0; x < iWidth; x++ ) |
---|
3658 | { |
---|
3659 | aiCurrHist[pCurrY[x]]++; |
---|
3660 | aiRefOrgHist[pRefOrgY[x]]++; |
---|
3661 | } |
---|
3662 | pCurrY += iCurrStride; |
---|
3663 | pRefOrgY += iRefStride; |
---|
3664 | } |
---|
3665 | // Histogram SAD |
---|
3666 | for ( Int i = 0; i < iMaxPelValue; i++ ) |
---|
3667 | { |
---|
3668 | iSumOrgSAD += abs( aiCurrHist[i] - aiRefOrgHist[i] ); |
---|
3669 | } |
---|
3670 | // Setting |
---|
3671 | if ( iSumOrgSAD > Int( dThresholdOrgSAD * iWidth * iHeight ) ) |
---|
3672 | { |
---|
3673 | m_bApplyIC = true; |
---|
3674 | } |
---|
3675 | else |
---|
3676 | { |
---|
3677 | m_bApplyIC = false; |
---|
3678 | } |
---|
3679 | } |
---|
3680 | |
---|
3681 | xFree( aiCurrHist ); |
---|
3682 | xFree( aiRefOrgHist ); |
---|
3683 | aiCurrHist = NULL; |
---|
3684 | aiRefOrgHist = NULL; |
---|
3685 | }//if(bUseLowLatencyICEnc) |
---|
3686 | } |
---|
3687 | #endif |
---|
3688 | #if H_3D |
---|
3689 | Void TComSlice::setIvPicLists( TComPicLists* m_ivPicLists ) |
---|
3690 | { |
---|
3691 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
3692 | { |
---|
3693 | for ( Int depthId = 0; depthId < 2; depthId++ ) |
---|
3694 | { |
---|
3695 | m_ivPicsCurrPoc[ depthId ][ i ] = ( i <= m_viewIndex ) ? m_ivPicLists->getPic( i, ( depthId == 1) , getPOC() ) : NULL; |
---|
3696 | } |
---|
3697 | } |
---|
3698 | } |
---|
3699 | Void TComSlice::setDepthToDisparityLUTs() |
---|
3700 | { |
---|
3701 | Bool setupLUT = false; |
---|
3702 | Int layerIdInVPS = getVPS()->getLayerIdInNuh( m_layerId ); |
---|
3703 | |
---|
3704 | #if H_3D_VSP |
---|
3705 | setupLUT = setupLUT || getVPS()->getViewSynthesisPredFlag( layerIdInVPS); |
---|
3706 | #endif |
---|
3707 | |
---|
3708 | #if H_3D_NBDV_REF |
---|
3709 | setupLUT = setupLUT || getVPS()->getDepthRefinementFlag( layerIdInVPS ); |
---|
3710 | #endif |
---|
3711 | |
---|
3712 | #if H_3D_IV_MERGE |
---|
3713 | setupLUT = setupLUT || ( getVPS()->getIvMvPredFlag(layerIdInVPS ) && getIsDepth() ); |
---|
3714 | #endif |
---|
3715 | |
---|
3716 | #if H_3D_DDD |
---|
3717 | if( getIsDepth() && getViewIndex() > 0 ) |
---|
3718 | { |
---|
3719 | TComSlice *pcTextSlice = getTexturePic()->getSlice( 0 ); |
---|
3720 | memcpy( m_aiDDDInvScale, pcTextSlice->m_aiDDDInvScale, sizeof( Int ) * getViewIndex() ); |
---|
3721 | memcpy( m_aiDDDInvOffset, pcTextSlice->m_aiDDDInvOffset, sizeof( Int ) * getViewIndex() ); |
---|
3722 | memcpy( m_aiDDDShift, pcTextSlice->m_aiDDDShift, sizeof( Int ) * getViewIndex() ); |
---|
3723 | } |
---|
3724 | #endif |
---|
3725 | |
---|
3726 | if( !setupLUT ) |
---|
3727 | return; |
---|
3728 | |
---|
3729 | /// GT: Allocation should be moved to a better place later; |
---|
3730 | if ( m_depthToDisparityB == NULL ) |
---|
3731 | { |
---|
3732 | m_depthToDisparityB = new Int*[ getViewIndex() ]; |
---|
3733 | for ( Int i = 0; i < getViewIndex(); i++ ) |
---|
3734 | { |
---|
3735 | m_depthToDisparityB[ i ] = new Int[ Int(1 << g_bitDepthY) ]; |
---|
3736 | } |
---|
3737 | } |
---|
3738 | |
---|
3739 | if ( m_depthToDisparityF == NULL ) |
---|
3740 | { |
---|
3741 | m_depthToDisparityF= new Int*[ getViewIndex() ]; |
---|
3742 | for ( Int i = 0; i < getViewIndex(); i++ ) |
---|
3743 | { |
---|
3744 | m_depthToDisparityF[ i ] = new Int[ Int(1 << g_bitDepthY) ]; |
---|
3745 | } |
---|
3746 | } |
---|
3747 | |
---|
3748 | assert( m_depthToDisparityB != NULL ); |
---|
3749 | assert( m_depthToDisparityF != NULL ); |
---|
3750 | |
---|
3751 | TComVPS* vps = getVPS(); |
---|
3752 | |
---|
3753 | Int log2Div = g_bitDepthY - 1 + vps->getCamParPrecision(); |
---|
3754 | Int viewIndex = getViewIndex(); |
---|
3755 | |
---|
3756 | Bool camParaSH = vps->hasCamParInSliceHeader( viewIndex ); |
---|
3757 | |
---|
3758 | Int* codScale = camParaSH ? m_aaiCodedScale [ 0 ] : vps->getCodedScale ( viewIndex ); |
---|
3759 | Int* codOffset = camParaSH ? m_aaiCodedOffset[ 0 ] : vps->getCodedOffset ( viewIndex ); |
---|
3760 | Int* invCodScale = camParaSH ? m_aaiCodedScale [ 1 ] : vps->getInvCodedScale ( viewIndex ); |
---|
3761 | Int* invCodOffset = camParaSH ? m_aaiCodedOffset[ 1 ] : vps->getInvCodedOffset( viewIndex ); |
---|
3762 | |
---|
3763 | for (Int i = 0; i <= ( getViewIndex() - 1); i++) |
---|
3764 | { |
---|
3765 | for ( Int d = 0; d <= ( ( 1 << g_bitDepthY ) - 1 ); d++ ) |
---|
3766 | { |
---|
3767 | Int offset = ( codOffset [ i ] << g_bitDepthY ) + ( ( 1 << log2Div ) >> 1 ); |
---|
3768 | m_depthToDisparityB[ i ][ d ] = ( codScale [ i ] * d + offset ) >> log2Div; |
---|
3769 | |
---|
3770 | Int invOffset = ( invCodOffset[ i ] << g_bitDepthY ) + ( ( 1 << log2Div ) >> 1 ); |
---|
3771 | m_depthToDisparityF[ i ][ d ] = ( invCodScale[ i ] * d + invOffset ) >> log2Div; |
---|
3772 | } |
---|
3773 | |
---|
3774 | #if H_3D_DDD |
---|
3775 | initializeDDDPara( vps->getCamParPrecision(), codScale[ i ], codOffset[ i ], i ); |
---|
3776 | #endif |
---|
3777 | } |
---|
3778 | } |
---|
3779 | #endif |
---|
3780 | #endif |
---|
3781 | |
---|
3782 | #if H_3D_DDD |
---|
3783 | Void TComSlice::initializeDDDPara( UInt uiCamParsCodedPrecision, Int iCodedScale,Int iCodedOffset, Int iBaseViewIdx ) |
---|
3784 | { |
---|
3785 | UInt uiViewId = getViewIndex(); |
---|
3786 | |
---|
3787 | if( uiViewId == 0 ) |
---|
3788 | { |
---|
3789 | m_aiDDDInvScale[ iBaseViewIdx ] = m_aiDDDInvOffset[ iBaseViewIdx ] = m_aiDDDShift[ iBaseViewIdx ] = 0; |
---|
3790 | return; |
---|
3791 | } |
---|
3792 | |
---|
3793 | |
---|
3794 | Int iSign = iCodedScale >= 0 ? 1 : -1; |
---|
3795 | iCodedScale = abs( iCodedScale ); |
---|
3796 | |
---|
3797 | Int iBitWidth = 0; |
---|
3798 | |
---|
3799 | const Int iInvPres = 9; |
---|
3800 | |
---|
3801 | while( ((( 1 << iBitWidth ) << 1 ) <= iCodedScale ) ) |
---|
3802 | { |
---|
3803 | iBitWidth ++; |
---|
3804 | } |
---|
3805 | iBitWidth += iInvPres; |
---|
3806 | Int iTargetValue = 1 << iBitWidth; |
---|
3807 | |
---|
3808 | Int iMinError = MAX_INT; |
---|
3809 | Int iBestD = 1 << ( iInvPres - 1 ); |
---|
3810 | for( Int d = 1 << ( iInvPres - 1 ); d < ( 1 << iInvPres ); d++ ) |
---|
3811 | { |
---|
3812 | Int iError = abs( iCodedScale * d - iTargetValue ); |
---|
3813 | if( iError < iMinError ) |
---|
3814 | { |
---|
3815 | iMinError = iError; |
---|
3816 | iBestD = d; |
---|
3817 | } |
---|
3818 | if( iMinError == 0 ) |
---|
3819 | { |
---|
3820 | break; |
---|
3821 | } |
---|
3822 | } |
---|
3823 | Int iRoundingDir = 0; |
---|
3824 | if( iCodedScale * iBestD > iTargetValue ) |
---|
3825 | { |
---|
3826 | iRoundingDir = -1; |
---|
3827 | } |
---|
3828 | else if( iCodedScale * iBestD < iTargetValue ) |
---|
3829 | { |
---|
3830 | iRoundingDir = 1; |
---|
3831 | } |
---|
3832 | Int iCamPres = uiCamParsCodedPrecision - 1; |
---|
3833 | m_aiDDDInvScale [ iBaseViewIdx ] = ( iBestD << ( iCamPres + g_bitDepthY )) * iSign; |
---|
3834 | m_aiDDDInvOffset[ iBaseViewIdx ] = -iSign * iBestD * ( iCodedOffset << g_bitDepthY ); |
---|
3835 | m_aiDDDShift [ iBaseViewIdx ] = iBitWidth; |
---|
3836 | m_aiDDDInvOffset[ iBaseViewIdx ] += 1 << ( m_aiDDDShift[ iBaseViewIdx ] - 1 ); |
---|
3837 | m_aiDDDInvOffset[ iBaseViewIdx ] += ( 1 << ( m_aiDDDShift[ iBaseViewIdx ] - 4 ) ) * iRoundingDir; |
---|
3838 | |
---|
3839 | return; |
---|
3840 | } |
---|
3841 | |
---|
3842 | |
---|
3843 | #endif |
---|
3844 | |
---|
3845 | #if H_MV |
---|
3846 | Void TComSlice::checkCrossLayerBlaFlag() |
---|
3847 | { |
---|
3848 | // 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. |
---|
3849 | if ( getLayerId() != 0 || getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
3850 | { |
---|
3851 | assert( m_crossLayerBlaFlag == 0 ); |
---|
3852 | } |
---|
3853 | } |
---|
3854 | |
---|
3855 | Bool TComSlice::inferPocMsbValPresentFlag() |
---|
3856 | { |
---|
3857 | Bool pocMsbValPresentFlag; |
---|
3858 | if( getSliceSegmentHeaderExtensionLength() == 0 ) |
---|
3859 | { |
---|
3860 | pocMsbValPresentFlag = false; |
---|
3861 | } |
---|
3862 | else if ( getPocMsbValRequiredFlag() ) |
---|
3863 | { |
---|
3864 | pocMsbValPresentFlag = true; |
---|
3865 | } |
---|
3866 | else |
---|
3867 | { |
---|
3868 | pocMsbValPresentFlag = false; |
---|
3869 | } |
---|
3870 | |
---|
3871 | return pocMsbValPresentFlag; |
---|
3872 | } |
---|
3873 | |
---|
3874 | |
---|
3875 | #endif |
---|
3876 | |
---|
3877 | #if H_3D_DBBP |
---|
3878 | Int TComSlice::getDepthFromDV( Int iDV, Int iBaseViewIdx ) |
---|
3879 | { |
---|
3880 | return ClipY(( iDV * m_aiDDDInvScale[ iBaseViewIdx ] + m_aiDDDInvOffset[ iBaseViewIdx ] ) >> m_aiDDDShift[ iBaseViewIdx ]); |
---|
3881 | } |
---|
3882 | #endif |
---|
3883 | |
---|
3884 | /** get scaling matrix from RefMatrixID |
---|
3885 | * \param sizeId size index |
---|
3886 | * \param Index of input matrix |
---|
3887 | * \param Index of reference matrix |
---|
3888 | */ |
---|
3889 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
3890 | { |
---|
3891 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
3892 | } |
---|
3893 | |
---|
3894 | /** parse syntax infomation |
---|
3895 | * \param pchFile syntax infomation |
---|
3896 | * \returns false if successful |
---|
3897 | */ |
---|
3898 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
3899 | { |
---|
3900 | FILE *fp; |
---|
3901 | Char line[1024]; |
---|
3902 | UInt sizeIdc,listIdc; |
---|
3903 | UInt i,size = 0; |
---|
3904 | Int *src=0,data; |
---|
3905 | Char *ret; |
---|
3906 | UInt retval; |
---|
3907 | |
---|
3908 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
3909 | { |
---|
3910 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
3911 | return true; |
---|
3912 | } |
---|
3913 | |
---|
3914 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
3915 | { |
---|
3916 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
3917 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
3918 | { |
---|
3919 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
3920 | |
---|
3921 | fseek(fp,0,0); |
---|
3922 | do |
---|
3923 | { |
---|
3924 | ret = fgets(line, 1024, fp); |
---|
3925 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
3926 | { |
---|
3927 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
3928 | return true; |
---|
3929 | } |
---|
3930 | } |
---|
3931 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
3932 | for (i=0; i<size; i++) |
---|
3933 | { |
---|
3934 | retval = fscanf(fp, "%d,", &data); |
---|
3935 | if (retval!=1) |
---|
3936 | { |
---|
3937 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
3938 | return true; |
---|
3939 | } |
---|
3940 | src[i] = data; |
---|
3941 | } |
---|
3942 | //set DC value for default matrix check |
---|
3943 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
3944 | |
---|
3945 | if(sizeIdc > SCALING_LIST_8x8) |
---|
3946 | { |
---|
3947 | fseek(fp,0,0); |
---|
3948 | do |
---|
3949 | { |
---|
3950 | ret = fgets(line, 1024, fp); |
---|
3951 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
3952 | { |
---|
3953 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
3954 | return true; |
---|
3955 | } |
---|
3956 | } |
---|
3957 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
3958 | retval = fscanf(fp, "%d,", &data); |
---|
3959 | if (retval!=1) |
---|
3960 | { |
---|
3961 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
3962 | return true; |
---|
3963 | } |
---|
3964 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
3965 | setScalingListDC(sizeIdc,listIdc,data); |
---|
3966 | } |
---|
3967 | } |
---|
3968 | } |
---|
3969 | fclose(fp); |
---|
3970 | return false; |
---|
3971 | } |
---|
3972 | |
---|
3973 | #if H_MV |
---|
3974 | Void TComScalingList::inferFrom( TComScalingList* srcScLi ) |
---|
3975 | { |
---|
3976 | for(Int sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3977 | { |
---|
3978 | for(Int listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
3979 | { |
---|
3980 | setRefMatrixId (sizeId,listId, srcScLi->getRefMatrixId (sizeId,listId)); |
---|
3981 | setScalingListDC(sizeId,listId, srcScLi->getScalingListDC(sizeId,listId)); |
---|
3982 | ::memcpy(getScalingListAddress(sizeId, listId),srcScLi->getScalingListAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
3983 | } |
---|
3984 | } |
---|
3985 | } |
---|
3986 | #endif |
---|
3987 | /** initialization process of quantization matrix array |
---|
3988 | */ |
---|
3989 | Void TComScalingList::init() |
---|
3990 | { |
---|
3991 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3992 | { |
---|
3993 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
3994 | { |
---|
3995 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
3996 | } |
---|
3997 | } |
---|
3998 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
3999 | } |
---|
4000 | |
---|
4001 | /** destroy quantization matrix array |
---|
4002 | */ |
---|
4003 | Void TComScalingList::destroy() |
---|
4004 | { |
---|
4005 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
4006 | { |
---|
4007 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
4008 | { |
---|
4009 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
4010 | } |
---|
4011 | } |
---|
4012 | } |
---|
4013 | |
---|
4014 | /** get default address of quantization matrix |
---|
4015 | * \param sizeId size index |
---|
4016 | * \param listId list index |
---|
4017 | * \returns pointer of quantization matrix |
---|
4018 | */ |
---|
4019 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
4020 | { |
---|
4021 | Int *src = 0; |
---|
4022 | switch(sizeId) |
---|
4023 | { |
---|
4024 | case SCALING_LIST_4x4: |
---|
4025 | src = g_quantTSDefault4x4; |
---|
4026 | break; |
---|
4027 | case SCALING_LIST_8x8: |
---|
4028 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
4029 | break; |
---|
4030 | case SCALING_LIST_16x16: |
---|
4031 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
4032 | break; |
---|
4033 | case SCALING_LIST_32x32: |
---|
4034 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
4035 | break; |
---|
4036 | default: |
---|
4037 | assert(0); |
---|
4038 | src = NULL; |
---|
4039 | break; |
---|
4040 | } |
---|
4041 | return src; |
---|
4042 | } |
---|
4043 | |
---|
4044 | /** process of default matrix |
---|
4045 | * \param sizeId size index |
---|
4046 | * \param Index of input matrix |
---|
4047 | */ |
---|
4048 | Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId) |
---|
4049 | { |
---|
4050 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
4051 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
4052 | } |
---|
4053 | |
---|
4054 | /** check DC value of matrix for default matrix signaling |
---|
4055 | */ |
---|
4056 | Void TComScalingList::checkDcOfMatrix() |
---|
4057 | { |
---|
4058 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
4059 | { |
---|
4060 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
4061 | { |
---|
4062 | //check default matrix? |
---|
4063 | if(getScalingListDC(sizeId,listId) == 0) |
---|
4064 | { |
---|
4065 | processDefaultMatrix(sizeId, listId); |
---|
4066 | } |
---|
4067 | } |
---|
4068 | } |
---|
4069 | } |
---|
4070 | |
---|
4071 | ParameterSetManager::ParameterSetManager() |
---|
4072 | : m_vpsMap(MAX_NUM_VPS) |
---|
4073 | , m_spsMap(MAX_NUM_SPS) |
---|
4074 | , m_ppsMap(MAX_NUM_PPS) |
---|
4075 | , m_activeVPSId(-1) |
---|
4076 | #if !H_MV |
---|
4077 | , m_activeSPSId(-1) |
---|
4078 | , m_activePPSId(-1) |
---|
4079 | { |
---|
4080 | #else |
---|
4081 | { |
---|
4082 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
4083 | { |
---|
4084 | m_activeSPSId[ i ] = -1; |
---|
4085 | m_activePPSId[ i ] = -1; |
---|
4086 | } |
---|
4087 | #endif |
---|
4088 | } |
---|
4089 | |
---|
4090 | |
---|
4091 | ParameterSetManager::~ParameterSetManager() |
---|
4092 | { |
---|
4093 | } |
---|
4094 | |
---|
4095 | //! activate a SPS from a active parameter sets SEI message |
---|
4096 | //! \returns true, if activation is successful |
---|
4097 | #if H_MV |
---|
4098 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId, Int layerId ) |
---|
4099 | #else |
---|
4100 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
4101 | #endif |
---|
4102 | { |
---|
4103 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
4104 | if (sps) |
---|
4105 | { |
---|
4106 | Int vpsId = sps->getVPSId(); |
---|
4107 | if (m_vpsMap.getPS(vpsId)) |
---|
4108 | { |
---|
4109 | m_activeVPSId = vpsId; |
---|
4110 | #if H_MV |
---|
4111 | m_activeSPSId[ layerId ] = spsId; |
---|
4112 | #else |
---|
4113 | m_activeSPSId = spsId; |
---|
4114 | #endif |
---|
4115 | return true; |
---|
4116 | } |
---|
4117 | else |
---|
4118 | { |
---|
4119 | printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
4120 | } |
---|
4121 | } |
---|
4122 | else |
---|
4123 | { |
---|
4124 | printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
4125 | } |
---|
4126 | return false; |
---|
4127 | } |
---|
4128 | |
---|
4129 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
4130 | //! \returns true, if activation is successful |
---|
4131 | #if H_MV |
---|
4132 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP, Int layerId ) |
---|
4133 | #else |
---|
4134 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
4135 | #endif |
---|
4136 | { |
---|
4137 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
4138 | if (pps) |
---|
4139 | { |
---|
4140 | Int spsId = pps->getSPSId(); |
---|
4141 | #if H_MV |
---|
4142 | if (!isIRAP && (spsId != m_activeSPSId[ layerId ])) |
---|
4143 | #else |
---|
4144 | if (!isIRAP && (spsId != m_activeSPSId)) |
---|
4145 | #endif |
---|
4146 | { |
---|
4147 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IRAP."); |
---|
4148 | return false; |
---|
4149 | } |
---|
4150 | |
---|
4151 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
4152 | if (sps) |
---|
4153 | { |
---|
4154 | Int vpsId = sps->getVPSId(); |
---|
4155 | if (!isIRAP && (vpsId != m_activeVPSId)) |
---|
4156 | { |
---|
4157 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IRAP."); |
---|
4158 | return false; |
---|
4159 | } |
---|
4160 | if (m_vpsMap.getPS(vpsId)) |
---|
4161 | { |
---|
4162 | #if H_MV |
---|
4163 | m_activePPSId[ layerId ] = ppsId; |
---|
4164 | m_activeVPSId = vpsId; |
---|
4165 | m_activeSPSId[ layerId ] = spsId; |
---|
4166 | #else |
---|
4167 | m_activePPSId = ppsId; |
---|
4168 | m_activeVPSId = vpsId; |
---|
4169 | m_activeSPSId = spsId; |
---|
4170 | #endif |
---|
4171 | return true; |
---|
4172 | } |
---|
4173 | else |
---|
4174 | { |
---|
4175 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
4176 | } |
---|
4177 | } |
---|
4178 | else |
---|
4179 | { |
---|
4180 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
4181 | } |
---|
4182 | } |
---|
4183 | else |
---|
4184 | { |
---|
4185 | printf("Warning: tried to activate non-existing PPS."); |
---|
4186 | } |
---|
4187 | return false; |
---|
4188 | } |
---|
4189 | |
---|
4190 | ProfileTierLevel::ProfileTierLevel() |
---|
4191 | : m_profileSpace (0) |
---|
4192 | , m_tierFlag (false) |
---|
4193 | , m_profileIdc (0) |
---|
4194 | , m_levelIdc (0) |
---|
4195 | , m_progressiveSourceFlag (false) |
---|
4196 | , m_interlacedSourceFlag (false) |
---|
4197 | , m_nonPackedConstraintFlag(false) |
---|
4198 | , m_frameOnlyConstraintFlag(false) |
---|
4199 | { |
---|
4200 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
4201 | } |
---|
4202 | |
---|
4203 | TComPTL::TComPTL() |
---|
4204 | { |
---|
4205 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
4206 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
4207 | } |
---|
4208 | |
---|
4209 | #if H_MV |
---|
4210 | Void TComPTL::copyLevelFrom( TComPTL* source ) |
---|
4211 | { |
---|
4212 | getGeneralPTL()->setLevelIdc( source->getGeneralPTL()->getLevelIdc() ); |
---|
4213 | for( Int subLayer = 0; subLayer < 6; subLayer++ ) |
---|
4214 | { |
---|
4215 | setSubLayerLevelPresentFlag( subLayer, source->getSubLayerLevelPresentFlag( subLayer ) ); |
---|
4216 | getSubLayerPTL( subLayer )->setLevelIdc( source->getSubLayerPTL( subLayer )->getLevelIdc() ); |
---|
4217 | } |
---|
4218 | } |
---|
4219 | #endif |
---|
4220 | //! \} |
---|
4221 | |
---|
4222 | #if H_MV |
---|
4223 | TComVPSVUI::TComVPSVUI() |
---|
4224 | { |
---|
4225 | m_crossLayerIrapAlignedFlag = true; |
---|
4226 | m_allLayersIdrAlignedFlag = false; |
---|
4227 | m_bitRatePresentVpsFlag = false; |
---|
4228 | m_picRatePresentVpsFlag = false; |
---|
4229 | for ( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++) |
---|
4230 | { |
---|
4231 | for ( Int j = 0; j < MAX_TLAYER; j++) |
---|
4232 | { |
---|
4233 | m_bitRatePresentFlag [i][j] = false; |
---|
4234 | m_picRatePresentFlag [i][j] = false; |
---|
4235 | m_avgBitRate [i][j] = -1; |
---|
4236 | m_maxBitRate [i][j] = -1; |
---|
4237 | m_constantPicRateIdc [i][j] = -1; |
---|
4238 | m_avgPicRate [i][j] = -1; |
---|
4239 | } |
---|
4240 | } |
---|
4241 | |
---|
4242 | m_ilpRestrictedRefLayersFlag = false; |
---|
4243 | |
---|
4244 | for ( Int i = 0; i < MAX_NUM_LAYERS; i++) |
---|
4245 | { |
---|
4246 | for ( Int j = 0; j < MAX_NUM_LAYERS; j++) |
---|
4247 | { |
---|
4248 | m_tileBoundariesAlignedFlag [i][j] = false; |
---|
4249 | m_minSpatialSegmentOffsetPlus1[i][j] = 0; |
---|
4250 | m_ctuBasedOffsetEnabledFlag [i][j] = false; |
---|
4251 | m_minHorizontalCtuOffsetPlus1 [i][j] = -1; |
---|
4252 | } |
---|
4253 | m_baseLayerParameterSetCompatibilityFlag[i] = false; |
---|
4254 | } |
---|
4255 | for ( Int i = 0; i < MAX_NUM_VIDEO_SIGNAL_INFO; i++ ) |
---|
4256 | { |
---|
4257 | m_videoSignalInfo [i] = NULL; |
---|
4258 | } |
---|
4259 | |
---|
4260 | m_vpsVuiBspHrdPresentFlag = false; |
---|
4261 | m_vpsVuiBspHrdParameters = new TComVpsVuiBspHrdParameters(); |
---|
4262 | } |
---|
4263 | |
---|
4264 | TComVPSVUI::~TComVPSVUI() |
---|
4265 | { |
---|
4266 | for ( Int i = 0; i < MAX_NUM_VIDEO_SIGNAL_INFO; i++ ) |
---|
4267 | { |
---|
4268 | if (m_videoSignalInfo[ i ] != NULL ) delete m_videoSignalInfo[ i ]; |
---|
4269 | m_videoSignalInfo [ i ] = NULL; |
---|
4270 | } |
---|
4271 | |
---|
4272 | if ( m_vpsVuiBspHrdParameters ) delete m_vpsVuiBspHrdParameters; |
---|
4273 | m_vpsVuiBspHrdParameters = NULL; |
---|
4274 | } |
---|
4275 | |
---|
4276 | Void TComVPSVUI::inferVpsVui( Bool encoderFlag ) |
---|
4277 | { |
---|
4278 | // inference of syntax elements that differ from default inference (as done in constructor), when VPS VUI is not present |
---|
4279 | if (!encoderFlag ) |
---|
4280 | { |
---|
4281 | setCrossLayerIrapAlignedFlag( false ); |
---|
4282 | } |
---|
4283 | else |
---|
4284 | { |
---|
4285 | assert( !getCrossLayerIrapAlignedFlag() ); |
---|
4286 | } |
---|
4287 | } |
---|
4288 | |
---|
4289 | Void TComRepFormat::inferChromaAndBitDepth( TComRepFormat* prevRepFormat, Bool encoderFlag ) |
---|
4290 | { |
---|
4291 | if ( !encoderFlag ) |
---|
4292 | { |
---|
4293 | setChromaAndBitDepthVpsPresentFlag( prevRepFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
4294 | setSeparateColourPlaneVpsFlag ( prevRepFormat->getSeparateColourPlaneVpsFlag () ); |
---|
4295 | setBitDepthVpsLumaMinus8 ( prevRepFormat->getBitDepthVpsLumaMinus8 () ); |
---|
4296 | setBitDepthVpsChromaMinus8 ( prevRepFormat->getBitDepthVpsChromaMinus8 () ); |
---|
4297 | } |
---|
4298 | else |
---|
4299 | { |
---|
4300 | assert( getChromaAndBitDepthVpsPresentFlag() == prevRepFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
4301 | assert( getSeparateColourPlaneVpsFlag () == prevRepFormat->getSeparateColourPlaneVpsFlag () ); |
---|
4302 | assert( getBitDepthVpsLumaMinus8 () == prevRepFormat->getBitDepthVpsLumaMinus8 () ); |
---|
4303 | assert( getBitDepthVpsChromaMinus8 () == prevRepFormat->getBitDepthVpsChromaMinus8 () ); |
---|
4304 | } |
---|
4305 | } |
---|
4306 | |
---|
4307 | Void TComVpsVuiBspHrdParameters::checkLayerInBspFlag( TComVPS* vps, Int h ) |
---|
4308 | { |
---|
4309 | // It is a requirement of bitstream conformance that bitstream partition with index j shall not include |
---|
4310 | // direct or indirect reference layers of any layers in bitstream partition i for any values of i and j |
---|
4311 | // in the range of 0 to num_bitstream_partitions[ h ] ?1, inclusive, such that i is less than j. |
---|
4312 | |
---|
4313 | for ( Int partJ = 0; partJ < getNumBitstreamPartitions( h ); partJ++ ) |
---|
4314 | { |
---|
4315 | for ( Int partI = 0; partI < partJ; partI++ ) |
---|
4316 | { |
---|
4317 | for ( Int layerJ = 0; layerJ < vps->getMaxLayersMinus1(); layerJ++ ) |
---|
4318 | { |
---|
4319 | if ( m_layerInBspFlag[ h ][partJ][layerJ ] ) |
---|
4320 | { |
---|
4321 | for ( Int layerI = 0; layerI < vps->getMaxLayersMinus1(); layerI++ ) |
---|
4322 | { |
---|
4323 | if ( m_layerInBspFlag[ h ][partI][layerI] ) |
---|
4324 | { |
---|
4325 | assert( !vps->getInDirectDependencyFlag( layerI, layerJ ) ); |
---|
4326 | } |
---|
4327 | } |
---|
4328 | } |
---|
4329 | } |
---|
4330 | } |
---|
4331 | } |
---|
4332 | |
---|
4333 | // --------------- |
---|
4334 | // To be added: |
---|
4335 | // When vps_base_layer_internal_flag is equal to 0 and layer_in_bsp_flag[ h ][ i ][ 0 ] is equal to 1 for any value of h in the |
---|
4336 | // range of 1 to vps_num_layer_sets_minus1, inclusive, and any value of i in the range of 0 to num_bitstream_partitions[ h ] - 1, |
---|
4337 | // inclusive, the value of layer_in_bsp_flag[ h ][ i ][ j ] for at least one value of j in the range of 1 to |
---|
4338 | // NumLayersInIdList[ h ] - 1, inclusive, shall be equal to 1. |
---|
4339 | // --------------- |
---|
4340 | |
---|
4341 | |
---|
4342 | // When num_bitstream_partitions[ h ] is equal to 1 for any value of h in the range 1 to vps_num_layer_set_minus1, inclusive, |
---|
4343 | // the value of layer_in_bsp_flag[ h ][ 0 ][ j ] should be equal to 0 for at least one value of j in the range 0 to |
---|
4344 | // NumLayersInIdList[ h ] − 1, inclusive. |
---|
4345 | |
---|
4346 | |
---|
4347 | if ( getNumBitstreamPartitions( h ) == 1 ) |
---|
4348 | { |
---|
4349 | Bool atLeastOneZero = false; |
---|
4350 | for ( Int j = 0; j <= vps->getNumLayersInIdList( h ) - 1; j++ ) |
---|
4351 | { |
---|
4352 | atLeastOneZero = atLeastOneZero || !getLayerInBspFlag( h, 0, j ); |
---|
4353 | } |
---|
4354 | assert( atLeastOneZero ); |
---|
4355 | } |
---|
4356 | |
---|
4357 | |
---|
4358 | // For any value of h in the range 1 to vps_num_layer_set_minus1, inclusive, the value of layer_in_bsp_flag[ h ][ i ][ j ] |
---|
4359 | // shall be equal to 1 for at most one value of i in the range of 0 to num_bitstream_partitions[ h ] − 1, inclusive. |
---|
4360 | |
---|
4361 | for ( Int j = 0; j <= vps->getNumLayersInIdList( h ) - 1; j++ ) |
---|
4362 | { |
---|
4363 | Int numLayerInBsp = 0; |
---|
4364 | for ( Int i = 0; i <= getNumBitstreamPartitions( h ) - 1; i++ ) |
---|
4365 | { |
---|
4366 | numLayerInBsp += ( getLayerInBspFlag( h, i, j ) ? 1 : 0 ); |
---|
4367 | } |
---|
4368 | assert( numLayerInBsp <= 1 ); |
---|
4369 | } |
---|
4370 | |
---|
4371 | } |
---|
4372 | |
---|
4373 | Void TComVpsVuiBspHrdParameters::checkBspCombHrdAndShedIdx( TComVPS* vps, Int h, Int i, Int j ) |
---|
4374 | { |
---|
4375 | // bsp_comb_hrd_idx |
---|
4376 | assert( getBspCombSchedIdx(h, i, j ) >= 0 ); |
---|
4377 | assert( getBspCombSchedIdx(h, i, j ) <= getVpsNumBspHrdParametersMinus1() ); |
---|
4378 | |
---|
4379 | // bsp_comb_sched_idx |
---|
4380 | assert( getBspCombSchedIdx(h, i, j ) >= 0 ); |
---|
4381 | |
---|
4382 | //* This check needs to activated, when HighestTid is available here |
---|
4383 | // assert( getBspCombSchedIdx(h, i, j ) <= vps->getHrdParameters( getBspCombHrdIdx( h, i, j ) )->getCpbCntMinus1( highestTid ) ); |
---|
4384 | } |
---|
4385 | |
---|
4386 | Void TComVUI::inferVideoSignalInfo( TComVPS* vps, Int layerIdCurr ) |
---|
4387 | { |
---|
4388 | if ( layerIdCurr == 0 || !vps->getVpsVuiPresentFlag() ) |
---|
4389 | { |
---|
4390 | return; |
---|
4391 | } |
---|
4392 | |
---|
4393 | TComVPSVUI* vpsVUI = vps->getVPSVUI(); |
---|
4394 | assert( vpsVUI != NULL ); |
---|
4395 | |
---|
4396 | TComVideoSignalInfo* videoSignalInfo = vpsVUI->getVideoSignalInfo( vpsVUI->getVpsVideoSignalInfoIdx( vps->getLayerIdInVps( layerIdCurr ) ) ); |
---|
4397 | assert( videoSignalInfo != NULL ); |
---|
4398 | |
---|
4399 | setVideoFormat ( videoSignalInfo->getVideoVpsFormat () ); |
---|
4400 | setVideoFullRangeFlag ( videoSignalInfo->getVideoFullRangeVpsFlag () ); |
---|
4401 | setColourPrimaries ( videoSignalInfo->getColourPrimariesVps () ); |
---|
4402 | setTransferCharacteristics( videoSignalInfo->getTransferCharacteristicsVps() ); |
---|
4403 | setMatrixCoefficients ( videoSignalInfo->getMatrixCoeffsVps () ); |
---|
4404 | } |
---|
4405 | |
---|
4406 | TComDpbSize::TComDpbSize() |
---|
4407 | { |
---|
4408 | for (Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++ ) |
---|
4409 | { |
---|
4410 | m_subLayerFlagInfoPresentFlag[i] = false; |
---|
4411 | |
---|
4412 | for (Int j = 0; j < MAX_TLAYER; j++ ) |
---|
4413 | { |
---|
4414 | m_subLayerDpbInfoPresentFlag [i][j] = ( j == 0) ; |
---|
4415 | m_maxVpsNumReorderPics [i][j] = 0; |
---|
4416 | m_maxVpsLatencyIncreasePlus1 [i][j] = 0; |
---|
4417 | |
---|
4418 | for (Int k = 0; k < MAX_NUM_LAYER_IDS; k++ ) |
---|
4419 | { |
---|
4420 | m_maxVpsDecPicBufferingMinus1[i][k][j] = 0; |
---|
4421 | } |
---|
4422 | } |
---|
4423 | } |
---|
4424 | } |
---|
4425 | |
---|
4426 | Void Window::scaleOffsets( Int scal ) |
---|
4427 | { |
---|
4428 | if (! m_scaledFlag ) |
---|
4429 | { |
---|
4430 | m_scaledFlag = true; |
---|
4431 | m_winLeftOffset *= scal; |
---|
4432 | m_winRightOffset *= scal; |
---|
4433 | m_winTopOffset *= scal; |
---|
4434 | m_winBottomOffset *= scal; |
---|
4435 | } |
---|
4436 | } |
---|
4437 | #endif |
---|
4438 | |
---|