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