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 | #if SVC_EXTENSION |
---|
48 | ParameterSetMap<TComVPS> ParameterSetManager::m_vpsMap(MAX_NUM_VPS); |
---|
49 | Int ParameterSetManager::m_activeVPSId = -1; |
---|
50 | #endif |
---|
51 | |
---|
52 | TComSlice::TComSlice() |
---|
53 | : m_iPPSId ( -1 ) |
---|
54 | , m_iPOC ( 0 ) |
---|
55 | , m_iLastIDR ( 0 ) |
---|
56 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
57 | , m_eSliceType ( I_SLICE ) |
---|
58 | , m_iSliceQp ( 0 ) |
---|
59 | , m_dependentSliceSegmentFlag ( false ) |
---|
60 | #if ADAPTIVE_QP_SELECTION |
---|
61 | , m_iSliceQpBase ( 0 ) |
---|
62 | #endif |
---|
63 | , m_deblockingFilterDisable ( false ) |
---|
64 | , m_deblockingFilterOverrideFlag ( false ) |
---|
65 | , m_deblockingFilterBetaOffsetDiv2 ( 0 ) |
---|
66 | , m_deblockingFilterTcOffsetDiv2 ( 0 ) |
---|
67 | , m_bCheckLDC ( false ) |
---|
68 | , m_iSliceQpDelta ( 0 ) |
---|
69 | , m_iSliceQpDeltaCb ( 0 ) |
---|
70 | , m_iSliceQpDeltaCr ( 0 ) |
---|
71 | , m_iDepth ( 0 ) |
---|
72 | , m_bRefenced ( false ) |
---|
73 | , m_pcSPS ( NULL ) |
---|
74 | , m_pcPPS ( NULL ) |
---|
75 | , m_pcPic ( NULL ) |
---|
76 | , m_colFromL0Flag ( 1 ) |
---|
77 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
78 | , m_noOutputPriorPicsFlag ( false ) |
---|
79 | , m_noRaslOutputFlag ( false ) |
---|
80 | , m_handleCraAsBlaFlag ( false ) |
---|
81 | #endif |
---|
82 | , m_colRefIdx ( 0 ) |
---|
83 | , m_uiTLayer ( 0 ) |
---|
84 | , m_bTLayerSwitchingFlag ( false ) |
---|
85 | , m_sliceMode ( 0 ) |
---|
86 | , m_sliceArgument ( 0 ) |
---|
87 | , m_sliceCurStartCUAddr ( 0 ) |
---|
88 | , m_sliceCurEndCUAddr ( 0 ) |
---|
89 | , m_sliceIdx ( 0 ) |
---|
90 | , m_sliceSegmentMode ( 0 ) |
---|
91 | , m_sliceSegmentArgument ( 0 ) |
---|
92 | , m_sliceSegmentCurStartCUAddr ( 0 ) |
---|
93 | , m_sliceSegmentCurEndCUAddr ( 0 ) |
---|
94 | , m_nextSlice ( false ) |
---|
95 | , m_nextSliceSegment ( false ) |
---|
96 | , m_sliceBits ( 0 ) |
---|
97 | , m_sliceSegmentBits ( 0 ) |
---|
98 | , m_bFinalized ( false ) |
---|
99 | , m_uiTileOffstForMultES ( 0 ) |
---|
100 | , m_puiSubstreamSizes ( NULL ) |
---|
101 | , m_cabacInitFlag ( false ) |
---|
102 | , m_bLMvdL1Zero ( false ) |
---|
103 | , m_numEntryPointOffsets ( 0 ) |
---|
104 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
105 | , m_enableTMVPFlag ( true ) |
---|
106 | #if SVC_EXTENSION |
---|
107 | , m_layerId ( 0 ) |
---|
108 | #if REF_IDX_MFM |
---|
109 | , m_bMFMEnabledFlag ( false ) |
---|
110 | #endif |
---|
111 | #if POC_RESET_FLAG |
---|
112 | , m_bPocResetFlag ( false ) |
---|
113 | #endif |
---|
114 | , m_bDiscardableFlag ( false ) |
---|
115 | #if O0149_CROSS_LAYER_BLA_FLAG |
---|
116 | , m_bCrossLayerBLAFlag ( false ) |
---|
117 | #endif |
---|
118 | #if POC_RESET_IDC_SIGNALLING |
---|
119 | , m_pocResetIdc ( 0 ) |
---|
120 | , m_pocResetPeriodId ( 0 ) |
---|
121 | , m_fullPocResetFlag ( false ) |
---|
122 | , m_pocLsbVal ( 0 ) |
---|
123 | , m_pocMsbVal ( 0 ) |
---|
124 | , m_pocMsbValRequiredFlag ( false ) |
---|
125 | , m_pocMsbValPresentFlag ( false ) |
---|
126 | #endif |
---|
127 | #endif //SVC_EXTENSION |
---|
128 | { |
---|
129 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = 0; |
---|
130 | |
---|
131 | #if SVC_EXTENSION |
---|
132 | memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) ); |
---|
133 | m_activeNumILRRefIdx = 0; |
---|
134 | m_interLayerPredEnabledFlag = 0; |
---|
135 | ::memset( m_interLayerPredLayerIdc, 0, sizeof(m_interLayerPredLayerIdc) ); |
---|
136 | #if P0312_VERT_PHASE_ADJ |
---|
137 | ::memset( m_vertPhasePositionFlag, 0, sizeof(m_vertPhasePositionFlag) ); |
---|
138 | #endif |
---|
139 | #endif //SVC_EXTENSION |
---|
140 | |
---|
141 | initEqualRef(); |
---|
142 | |
---|
143 | for (Int component = 0; component < 3; component++) |
---|
144 | { |
---|
145 | m_lambdas[component] = 0.0; |
---|
146 | } |
---|
147 | |
---|
148 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
149 | { |
---|
150 | m_list1IdxToList0Idx[idx] = -1; |
---|
151 | } |
---|
152 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
153 | { |
---|
154 | m_apcRefPicList [0][iNumCount] = NULL; |
---|
155 | m_apcRefPicList [1][iNumCount] = NULL; |
---|
156 | m_aiRefPOCList [0][iNumCount] = 0; |
---|
157 | m_aiRefPOCList [1][iNumCount] = 0; |
---|
158 | } |
---|
159 | resetWpScaling(); |
---|
160 | initWpAcDcParam(); |
---|
161 | m_saoEnabledFlag = false; |
---|
162 | m_saoEnabledFlagChroma = false; |
---|
163 | } |
---|
164 | |
---|
165 | TComSlice::~TComSlice() |
---|
166 | { |
---|
167 | delete[] m_puiSubstreamSizes; |
---|
168 | m_puiSubstreamSizes = NULL; |
---|
169 | } |
---|
170 | |
---|
171 | |
---|
172 | #if SVC_EXTENSION |
---|
173 | Void TComSlice::initSlice( UInt layerId ) |
---|
174 | #else |
---|
175 | Void TComSlice::initSlice() |
---|
176 | #endif |
---|
177 | { |
---|
178 | #if SVC_EXTENSION |
---|
179 | m_layerId = layerId; |
---|
180 | m_activeNumILRRefIdx = 0; |
---|
181 | m_interLayerPredEnabledFlag = 0; |
---|
182 | #endif |
---|
183 | m_aiNumRefIdx[0] = 0; |
---|
184 | m_aiNumRefIdx[1] = 0; |
---|
185 | |
---|
186 | m_colFromL0Flag = 1; |
---|
187 | |
---|
188 | m_colRefIdx = 0; |
---|
189 | initEqualRef(); |
---|
190 | m_bCheckLDC = false; |
---|
191 | m_iSliceQpDeltaCb = 0; |
---|
192 | m_iSliceQpDeltaCr = 0; |
---|
193 | |
---|
194 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
195 | |
---|
196 | m_bFinalized=false; |
---|
197 | |
---|
198 | m_tileByteLocation.clear(); |
---|
199 | m_cabacInitFlag = false; |
---|
200 | m_numEntryPointOffsets = 0; |
---|
201 | m_enableTMVPFlag = true; |
---|
202 | } |
---|
203 | |
---|
204 | Bool TComSlice::getRapPicFlag() |
---|
205 | { |
---|
206 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
207 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
208 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
209 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
210 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
211 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
212 | } |
---|
213 | #if NO_OUTPUT_OF_PRIOR_PICS |
---|
214 | Bool TComSlice::getBlaPicFlag () |
---|
215 | { |
---|
216 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
217 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
218 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP; |
---|
219 | } |
---|
220 | Bool TComSlice::getCraPicFlag () |
---|
221 | { |
---|
222 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
223 | } |
---|
224 | #endif |
---|
225 | |
---|
226 | /** |
---|
227 | - allocate table to contain substream sizes to be written to the slice header. |
---|
228 | . |
---|
229 | \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1. |
---|
230 | */ |
---|
231 | Void TComSlice::allocSubstreamSizes(UInt uiNumSubstreams) |
---|
232 | { |
---|
233 | delete[] m_puiSubstreamSizes; |
---|
234 | m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0]; |
---|
235 | } |
---|
236 | |
---|
237 | Void TComSlice::sortPicList(TComList<TComPic*>& rcListPic) |
---|
238 | { |
---|
239 | TComPic* pcPicExtract; |
---|
240 | TComPic* pcPicInsert; |
---|
241 | |
---|
242 | TComList<TComPic*>::iterator iterPicExtract; |
---|
243 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
244 | TComList<TComPic*>::iterator iterPicInsert; |
---|
245 | |
---|
246 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
247 | { |
---|
248 | iterPicExtract = rcListPic.begin(); |
---|
249 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
250 | pcPicExtract = *(iterPicExtract); |
---|
251 | pcPicExtract->setCurrSliceIdx(0); |
---|
252 | |
---|
253 | iterPicInsert = rcListPic.begin(); |
---|
254 | while (iterPicInsert != iterPicExtract) |
---|
255 | { |
---|
256 | pcPicInsert = *(iterPicInsert); |
---|
257 | pcPicInsert->setCurrSliceIdx(0); |
---|
258 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
259 | { |
---|
260 | break; |
---|
261 | } |
---|
262 | |
---|
263 | iterPicInsert++; |
---|
264 | } |
---|
265 | |
---|
266 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
267 | |
---|
268 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
269 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
270 | rcListPic.erase (iterPicExtract); |
---|
271 | } |
---|
272 | } |
---|
273 | |
---|
274 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, |
---|
275 | Int poc) |
---|
276 | { |
---|
277 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
278 | TComPic* pcPic = *(iterPic); |
---|
279 | while ( iterPic != rcListPic.end() ) |
---|
280 | { |
---|
281 | if(pcPic->getPOC() == poc) |
---|
282 | { |
---|
283 | break; |
---|
284 | } |
---|
285 | iterPic++; |
---|
286 | #if SVC_EXTENSION |
---|
287 | // return NULL, if picture with requested POC is not in the list, otherwise iterator goes outside of the list |
---|
288 | if( iterPic == rcListPic.end() ) |
---|
289 | { |
---|
290 | return NULL; |
---|
291 | } |
---|
292 | #endif |
---|
293 | pcPic = *(iterPic); |
---|
294 | } |
---|
295 | #if POC_RESET_FLAG |
---|
296 | assert( pcPic->getSlice(0)->isReferenced() ); |
---|
297 | #endif |
---|
298 | return pcPic; |
---|
299 | } |
---|
300 | |
---|
301 | |
---|
302 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
303 | { |
---|
304 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
305 | TComPic* pcPic = *(iterPic); |
---|
306 | TComPic* pcStPic = pcPic; |
---|
307 | |
---|
308 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
309 | if (!pocHasMsb) |
---|
310 | { |
---|
311 | poc = poc & (pocCycle - 1); |
---|
312 | } |
---|
313 | |
---|
314 | while ( iterPic != rcListPic.end() ) |
---|
315 | { |
---|
316 | pcPic = *(iterPic); |
---|
317 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
318 | { |
---|
319 | Int picPoc = pcPic->getPOC(); |
---|
320 | if (!pocHasMsb) |
---|
321 | { |
---|
322 | picPoc = picPoc & (pocCycle - 1); |
---|
323 | } |
---|
324 | |
---|
325 | #if POC_RESET_RPS |
---|
326 | if( ((!pocHasMsb) && ((poc & (pocCycle-1)) == picPoc)) || ( pocHasMsb && (poc == picPoc)) ) |
---|
327 | #else |
---|
328 | if (poc == picPoc) |
---|
329 | #endif |
---|
330 | { |
---|
331 | if (pcPic->getIsLongTerm()) |
---|
332 | { |
---|
333 | return pcPic; |
---|
334 | } |
---|
335 | else |
---|
336 | { |
---|
337 | pcStPic = pcPic; |
---|
338 | } |
---|
339 | break; |
---|
340 | } |
---|
341 | } |
---|
342 | |
---|
343 | iterPic++; |
---|
344 | } |
---|
345 | |
---|
346 | return pcStPic; |
---|
347 | } |
---|
348 | |
---|
349 | Void TComSlice::setRefPOCList() |
---|
350 | { |
---|
351 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
352 | { |
---|
353 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
354 | { |
---|
355 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
356 | } |
---|
357 | } |
---|
358 | |
---|
359 | } |
---|
360 | |
---|
361 | Void TComSlice::setList1IdxToList0Idx() |
---|
362 | { |
---|
363 | Int idxL0, idxL1; |
---|
364 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
365 | { |
---|
366 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
367 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
368 | { |
---|
369 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
370 | { |
---|
371 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
372 | break; |
---|
373 | } |
---|
374 | } |
---|
375 | } |
---|
376 | } |
---|
377 | |
---|
378 | #if SVC_EXTENSION |
---|
379 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr, TComPic** ilpPic) |
---|
380 | #else |
---|
381 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) |
---|
382 | #endif |
---|
383 | { |
---|
384 | if (!checkNumPocTotalCurr) |
---|
385 | { |
---|
386 | if (m_eSliceType == I_SLICE) |
---|
387 | { |
---|
388 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
389 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
390 | |
---|
391 | return; |
---|
392 | } |
---|
393 | |
---|
394 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
395 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
396 | } |
---|
397 | |
---|
398 | TComPic* pcRefPic= NULL; |
---|
399 | TComPic* RefPicSetStCurr0[16]; |
---|
400 | TComPic* RefPicSetStCurr1[16]; |
---|
401 | TComPic* RefPicSetLtCurr[16]; |
---|
402 | UInt NumPocStCurr0 = 0; |
---|
403 | UInt NumPocStCurr1 = 0; |
---|
404 | UInt NumPocLtCurr = 0; |
---|
405 | Int i; |
---|
406 | |
---|
407 | #if SVC_EXTENSION |
---|
408 | if( m_layerId == 0 || ( m_layerId > 0 && ( m_activeNumILRRefIdx == 0 || !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ) ) ) |
---|
409 | { |
---|
410 | #endif |
---|
411 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
412 | { |
---|
413 | if(m_pcRPS->getUsed(i)) |
---|
414 | { |
---|
415 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
416 | pcRefPic->setIsLongTerm(0); |
---|
417 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
418 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
419 | NumPocStCurr0++; |
---|
420 | pcRefPic->setCheckLTMSBPresent(false); |
---|
421 | } |
---|
422 | } |
---|
423 | |
---|
424 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
425 | { |
---|
426 | if(m_pcRPS->getUsed(i)) |
---|
427 | { |
---|
428 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
429 | pcRefPic->setIsLongTerm(0); |
---|
430 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
431 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
432 | NumPocStCurr1++; |
---|
433 | pcRefPic->setCheckLTMSBPresent(false); |
---|
434 | } |
---|
435 | } |
---|
436 | |
---|
437 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
438 | { |
---|
439 | if(m_pcRPS->getUsed(i)) |
---|
440 | { |
---|
441 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
442 | pcRefPic->setIsLongTerm(1); |
---|
443 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
444 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
445 | NumPocLtCurr++; |
---|
446 | } |
---|
447 | if(pcRefPic==NULL) |
---|
448 | { |
---|
449 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
450 | } |
---|
451 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
452 | } |
---|
453 | #if SVC_EXTENSION |
---|
454 | } |
---|
455 | #endif |
---|
456 | |
---|
457 | #if SVC_EXTENSION |
---|
458 | for( i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
459 | { |
---|
460 | UInt refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
461 | //inter-layer reference picture |
---|
462 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
463 | Int maxTidIlRefPicsPlus1 = ( m_layerId > 0 && m_activeNumILRRefIdx > 0)? m_pcVPS->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId(),m_layerId) : 0; |
---|
464 | #else |
---|
465 | Int maxTidIlRefPicsPlus1 = ( m_layerId > 0 && m_activeNumILRRefIdx > 0)? m_pcVPS->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()) : 0; |
---|
466 | #endif |
---|
467 | if( m_layerId > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<= maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) ) |
---|
468 | { |
---|
469 | #if REF_IDX_MFM |
---|
470 | if(!(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) && getMFMEnabledFlag()) |
---|
471 | { |
---|
472 | ilpPic[refLayerIdc]->copyUpsampledMvField( refLayerIdc, m_pcBaseColPic[refLayerIdc] ); |
---|
473 | } |
---|
474 | else |
---|
475 | { |
---|
476 | ilpPic[refLayerIdc]->initUpsampledMvField(); |
---|
477 | } |
---|
478 | #endif |
---|
479 | ilpPic[refLayerIdc]->setIsLongTerm(1); |
---|
480 | } |
---|
481 | } |
---|
482 | #endif |
---|
483 | // ref_pic_list_init |
---|
484 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
485 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
486 | #if SVC_EXTENSION |
---|
487 | Int numInterLayerRPSPics = 0; |
---|
488 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
489 | if( m_layerId > 0 && m_activeNumILRRefIdx > 0 ) |
---|
490 | #else |
---|
491 | if( m_layerId > 0 ) |
---|
492 | #endif |
---|
493 | { |
---|
494 | for( i=0; i < m_pcVPS->getNumDirectRefLayers( m_layerId ); i++ ) |
---|
495 | { |
---|
496 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
497 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[i]->getSlice(0)->getLayerId(),m_layerId); |
---|
498 | #else |
---|
499 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[i]->getSlice(0)->getLayerId()); |
---|
500 | #endif |
---|
501 | if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<= maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag() ) ) |
---|
502 | { |
---|
503 | numInterLayerRPSPics++; |
---|
504 | #if DISCARDABLE_PIC_RPS |
---|
505 | assert( ilpPic[i]->getSlice(0)->getDiscardableFlag() == 0 ); // Inter-layer RPS shall not contain picture with discardable_flag = 1. |
---|
506 | #endif |
---|
507 | } |
---|
508 | } |
---|
509 | if (numInterLayerRPSPics < m_activeNumILRRefIdx) |
---|
510 | { |
---|
511 | m_activeNumILRRefIdx = numInterLayerRPSPics; |
---|
512 | } |
---|
513 | #if MAX_ONE_RESAMPLING_DIRECT_LAYERS |
---|
514 | #if SCALABILITY_MASK_E0104 |
---|
515 | if( m_pcVPS->getScalabilityMask(2) ) |
---|
516 | #else |
---|
517 | if( m_pcVPS->getScalabilityMask(1) ) |
---|
518 | #endif |
---|
519 | { |
---|
520 | Int numResampler = 0; |
---|
521 | #if MOTION_RESAMPLING_CONSTRAINT |
---|
522 | Int numMotionResamplers = 0; |
---|
523 | Int refResamplingLayer[MAX_LAYERS]; |
---|
524 | memset( refResamplingLayer, 0, sizeof( refResamplingLayer ) ); |
---|
525 | #endif |
---|
526 | #if !RESAMPLING_CONSTRAINT_BUG_FIX |
---|
527 | const Window &scalEL = getSPS()->getScaledRefLayerWindow(m_interLayerPredLayerIdc[i]); |
---|
528 | Int scalingOffset = ((scalEL.getWindowLeftOffset() == 0 ) && |
---|
529 | (scalEL.getWindowRightOffset() == 0 ) && |
---|
530 | (scalEL.getWindowTopOffset() == 0 ) && |
---|
531 | (scalEL.getWindowBottomOffset() == 0 ) |
---|
532 | ); |
---|
533 | #endif |
---|
534 | |
---|
535 | for( i=0; i < m_activeNumILRRefIdx; i++ ) |
---|
536 | { |
---|
537 | UInt refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
538 | UInt refLayerId = m_pcVPS->getRefLayerId( m_layerId, refLayerIdc ); |
---|
539 | #if RESAMPLING_CONSTRAINT_BUG_FIX |
---|
540 | #if O0098_SCALED_REF_LAYER_ID |
---|
541 | const Window &scalEL = getSPS()->getScaledRefLayerWindowForLayer(refLayerId); |
---|
542 | #else |
---|
543 | const Window &scalEL = getSPS()->getScaledRefLayerWindow(m_interLayerPredLayerIdc[i]); |
---|
544 | #endif |
---|
545 | Int scalingOffset = ((scalEL.getWindowLeftOffset() == 0 ) && |
---|
546 | (scalEL.getWindowRightOffset() == 0 ) && |
---|
547 | (scalEL.getWindowTopOffset() == 0 ) && |
---|
548 | (scalEL.getWindowBottomOffset() == 0 ) |
---|
549 | ); |
---|
550 | #endif |
---|
551 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
552 | Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] ); |
---|
553 | |
---|
554 | if( !( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || !scalingOffset || !sameBitDepths |
---|
555 | #if Q0048_CGS_3D_ASYMLUT |
---|
556 | || getPPS()->getCGSFlag() |
---|
557 | #endif |
---|
558 | ) // ratio 1x |
---|
559 | #else |
---|
560 | if(!( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || (!scalingOffset)) // ratio 1x |
---|
561 | #endif |
---|
562 | { |
---|
563 | #if MOTION_RESAMPLING_CONSTRAINT |
---|
564 | UInt predType = m_pcVPS->getDirectDependencyType( m_layerId, refLayerId ) + 1; |
---|
565 | |
---|
566 | if( predType & 0x1 ) |
---|
567 | { |
---|
568 | numResampler++; |
---|
569 | refResamplingLayer[i] = refLayerIdc + 1; |
---|
570 | } |
---|
571 | |
---|
572 | if( predType & 0x2 ) |
---|
573 | { |
---|
574 | numMotionResamplers++; |
---|
575 | refResamplingLayer[i] -= refLayerIdc + 1; |
---|
576 | } |
---|
577 | #else |
---|
578 | numResampler++; |
---|
579 | #endif |
---|
580 | } |
---|
581 | } |
---|
582 | |
---|
583 | // When both picture sample values and picture motion field resampling processes are invoked for decoding of a particular picture, they shall be applied to the same reference layer picture. |
---|
584 | if( m_activeNumILRRefIdx > 1 && numResampler > 0 ) |
---|
585 | { |
---|
586 | for( i=0; i < m_activeNumILRRefIdx; i++ ) |
---|
587 | { |
---|
588 | assert( refResamplingLayer[i] >= 0 && "Motion and sample inter-layer prediction shall be from the same layer" ); |
---|
589 | } |
---|
590 | } |
---|
591 | |
---|
592 | // Bitstream constraint for SHVC: The picture resampling process as specified in subclause G.8.1.4.1 shall not be invoked more than once for decoding of each particular picture. |
---|
593 | assert(numResampler <= 1); |
---|
594 | #if MOTION_RESAMPLING_CONSTRAINT |
---|
595 | assert( numMotionResamplers <= 1 && "Up to 1 motion resampling is allowed" ); |
---|
596 | #endif |
---|
597 | } |
---|
598 | #endif |
---|
599 | } |
---|
600 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_activeNumILRRefIdx; |
---|
601 | #else //SVC_EXTENSION |
---|
602 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
603 | #endif //SVC_EXTENSION |
---|
604 | |
---|
605 | if (checkNumPocTotalCurr) |
---|
606 | { |
---|
607 | // 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: |
---|
608 | #if SVC_EXTENSION // inter-layer prediction is allowed for BLA, CRA pictures of nuh_layer_id>0 |
---|
609 | // - If the current picture is a BLA or CRA picture with nuh_layer_id equal to 0, the value of NumPocTotalCurr shall be equal to 0. |
---|
610 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
611 | if (getRapPicFlag() && getLayerId()==0) |
---|
612 | #else |
---|
613 | // - If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
614 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
615 | if (getRapPicFlag()) |
---|
616 | #endif |
---|
617 | { |
---|
618 | assert(numPocTotalCurr == 0); |
---|
619 | } |
---|
620 | |
---|
621 | if (m_eSliceType == I_SLICE) |
---|
622 | { |
---|
623 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
624 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
625 | |
---|
626 | return; |
---|
627 | } |
---|
628 | |
---|
629 | assert(numPocTotalCurr > 0); |
---|
630 | |
---|
631 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
632 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
633 | } |
---|
634 | |
---|
635 | Int cIdx = 0; |
---|
636 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
637 | { |
---|
638 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
639 | } |
---|
640 | #if SVC_EXTENSION |
---|
641 | #if RPL_INIT_N0316_N0082 |
---|
642 | if( m_layerId > 0 ) |
---|
643 | { |
---|
644 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
645 | { |
---|
646 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
647 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
648 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId(),m_layerId); |
---|
649 | #else |
---|
650 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()); |
---|
651 | #endif |
---|
652 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
653 | { |
---|
654 | rpsCurrList0[cIdx] = ilpPic[refLayerIdc]; |
---|
655 | } |
---|
656 | } |
---|
657 | } |
---|
658 | #endif |
---|
659 | #endif //SVC_EXTENSION |
---|
660 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
661 | { |
---|
662 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
663 | } |
---|
664 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
665 | { |
---|
666 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
667 | } |
---|
668 | #if !RPL_INIT_N0316_N0082 |
---|
669 | #if SVC_EXTENSION |
---|
670 | if( m_layerId > 0 ) |
---|
671 | { |
---|
672 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
673 | { |
---|
674 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
675 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
676 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId(),m_layerId); |
---|
677 | #else |
---|
678 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()); |
---|
679 | #endif |
---|
680 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
681 | { |
---|
682 | rpsCurrList0[cIdx] = ilpPic[refLayerIdc]; |
---|
683 | } |
---|
684 | } |
---|
685 | } |
---|
686 | #endif |
---|
687 | #endif |
---|
688 | assert(cIdx == numPocTotalCurr); |
---|
689 | |
---|
690 | if (m_eSliceType==B_SLICE) |
---|
691 | { |
---|
692 | cIdx = 0; |
---|
693 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
694 | { |
---|
695 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
696 | } |
---|
697 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
698 | { |
---|
699 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
700 | } |
---|
701 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
702 | { |
---|
703 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
704 | } |
---|
705 | |
---|
706 | #if SVC_EXTENSION |
---|
707 | if( m_layerId > 0 ) |
---|
708 | { |
---|
709 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
710 | { |
---|
711 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
712 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
713 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId(),m_layerId); |
---|
714 | #else |
---|
715 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()); |
---|
716 | #endif |
---|
717 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
718 | { |
---|
719 | rpsCurrList1[cIdx] = ilpPic[refLayerIdc]; |
---|
720 | } |
---|
721 | } |
---|
722 | } |
---|
723 | #endif //SVC_EXTENSION |
---|
724 | |
---|
725 | assert(cIdx == numPocTotalCurr); |
---|
726 | } |
---|
727 | |
---|
728 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
729 | |
---|
730 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[0]; rIdx ++) |
---|
731 | { |
---|
732 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPocTotalCurr; |
---|
733 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
734 | m_apcRefPicList[0][rIdx] = rpsCurrList0[ cIdx ]; |
---|
735 | #if RPL_INIT_N0316_N0082 |
---|
736 | m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 && cIdx < NumPocStCurr0 + m_activeNumILRRefIdx ) || ( cIdx >= NumPocStCurr0 + NumPocStCurr1 + m_activeNumILRRefIdx ); |
---|
737 | #else |
---|
738 | m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
739 | #endif |
---|
740 | } |
---|
741 | if ( m_eSliceType != B_SLICE ) |
---|
742 | { |
---|
743 | m_aiNumRefIdx[1] = 0; |
---|
744 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
745 | } |
---|
746 | else |
---|
747 | { |
---|
748 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[1]; rIdx ++) |
---|
749 | { |
---|
750 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPocTotalCurr; |
---|
751 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
752 | m_apcRefPicList[1][rIdx] = rpsCurrList1[ cIdx ]; |
---|
753 | m_bIsUsedAsLongTerm[1][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
754 | } |
---|
755 | } |
---|
756 | } |
---|
757 | |
---|
758 | #if SVC_EXTENSION |
---|
759 | Void TComSlice::setRefPicListModificationSvc() |
---|
760 | { |
---|
761 | if( !m_pcPPS->getListsModificationPresentFlag()) |
---|
762 | { |
---|
763 | return; |
---|
764 | } |
---|
765 | |
---|
766 | if(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) |
---|
767 | { |
---|
768 | return; |
---|
769 | } |
---|
770 | |
---|
771 | TComRefPicListModification* refPicListModification = &m_RefPicListModification; |
---|
772 | Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList(); // total number of ref pics in listTemp0 including inter-layer ref pics |
---|
773 | #if RPL_INIT_N0316_N0082 |
---|
774 | Int numberOfPocBeforeCurr = this->getNumNegativeRpsCurrTempList(); // number of negative temporal ref pics |
---|
775 | #endif |
---|
776 | |
---|
777 | assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 0); |
---|
778 | assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 0); |
---|
779 | |
---|
780 | //set L0 inter-layer reference picture modification |
---|
781 | #if RPL_INIT_N0316_N0082 |
---|
782 | Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true; |
---|
783 | |
---|
784 | if( m_activeNumILRRefIdx > 1 ) |
---|
785 | { |
---|
786 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] >= (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true; |
---|
787 | } |
---|
788 | #else |
---|
789 | Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == numberOfRpsCurrTempList) ? false : true; |
---|
790 | #endif |
---|
791 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_0] > 1 ); |
---|
792 | refPicListModification->setRefPicListModificationFlagL0(hasModification); |
---|
793 | if(hasModification) |
---|
794 | { |
---|
795 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_0], numberOfRpsCurrTempList); i++) |
---|
796 | { |
---|
797 | refPicListModification->setRefPicSetIdxL0(i, i); |
---|
798 | } |
---|
799 | |
---|
800 | if(m_aiNumRefIdx[REF_PIC_LIST_0] > numberOfRpsCurrTempList) |
---|
801 | { |
---|
802 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
803 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_0]; i ++) |
---|
804 | { |
---|
805 | refPicListModification->setRefPicSetIdxL0(i, numberOfRpsCurrTempList - 1); |
---|
806 | } |
---|
807 | } |
---|
808 | else |
---|
809 | { |
---|
810 | // number of ILRPs included into the reference picture list with the list modification |
---|
811 | Int includeNumILRP = min( max(1, m_aiNumRefIdx[REF_PIC_LIST_0]-numberOfPocBeforeCurr), m_activeNumILRRefIdx); |
---|
812 | |
---|
813 | for(Int i = includeNumILRP; i > 0; i-- ) |
---|
814 | { |
---|
815 | #if RPL_INIT_N0316_N0082 |
---|
816 | if((numberOfPocBeforeCurr) >= m_aiNumRefIdx[REF_PIC_LIST_0]) |
---|
817 | { |
---|
818 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i); |
---|
819 | } |
---|
820 | else |
---|
821 | { |
---|
822 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i); |
---|
823 | for (Int j = numberOfPocBeforeCurr; j < (m_aiNumRefIdx[REF_PIC_LIST_0] - i); j++) |
---|
824 | { |
---|
825 | assert( j + includeNumILRP < numberOfRpsCurrTempList ); |
---|
826 | refPicListModification->setRefPicSetIdxL0(j, j + includeNumILRP); |
---|
827 | } |
---|
828 | } |
---|
829 | #else |
---|
830 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i); |
---|
831 | #endif |
---|
832 | } |
---|
833 | } |
---|
834 | } |
---|
835 | |
---|
836 | //set L1 inter-layer reference picture modification |
---|
837 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] >= numberOfRpsCurrTempList) ? false : true; |
---|
838 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_1] > 1 ); |
---|
839 | |
---|
840 | refPicListModification->setRefPicListModificationFlagL1(hasModification); |
---|
841 | if(hasModification) |
---|
842 | { |
---|
843 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_1], numberOfRpsCurrTempList); i++) |
---|
844 | { |
---|
845 | refPicListModification->setRefPicSetIdxL1(i, i); |
---|
846 | } |
---|
847 | if(m_aiNumRefIdx[REF_PIC_LIST_1] > numberOfRpsCurrTempList) |
---|
848 | { |
---|
849 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_1]; i ++) |
---|
850 | { |
---|
851 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
852 | refPicListModification->setRefPicSetIdxL1(i, numberOfRpsCurrTempList - 1); |
---|
853 | } |
---|
854 | } |
---|
855 | else |
---|
856 | { |
---|
857 | Int includeNumILRP = min(m_aiNumRefIdx[REF_PIC_LIST_1], m_activeNumILRRefIdx); |
---|
858 | |
---|
859 | for(Int i = includeNumILRP; i > 0; i-- ) |
---|
860 | { |
---|
861 | refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i); |
---|
862 | } |
---|
863 | } |
---|
864 | } |
---|
865 | return; |
---|
866 | } |
---|
867 | #endif |
---|
868 | #if RPL_INIT_N0316_N0082 |
---|
869 | Int TComSlice::getNumNegativeRpsCurrTempList() |
---|
870 | { |
---|
871 | if( m_eSliceType == I_SLICE ) |
---|
872 | { |
---|
873 | return 0; |
---|
874 | } |
---|
875 | |
---|
876 | Int numPocBeforeCurr = 0; |
---|
877 | for( UInt i = 0; i < m_pcRPS->getNumberOfNegativePictures(); i++ ) |
---|
878 | { |
---|
879 | if(m_pcRPS->getUsed(i)) |
---|
880 | { |
---|
881 | numPocBeforeCurr++; |
---|
882 | } |
---|
883 | } |
---|
884 | |
---|
885 | return numPocBeforeCurr; |
---|
886 | } |
---|
887 | #endif |
---|
888 | Int TComSlice::getNumRpsCurrTempList() |
---|
889 | { |
---|
890 | Int numRpsCurrTempList = 0; |
---|
891 | |
---|
892 | #if SVC_EXTENSION |
---|
893 | if( m_eSliceType == I_SLICE || ( m_layerId && |
---|
894 | (m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && |
---|
895 | (m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) ) |
---|
896 | #else |
---|
897 | if (m_eSliceType == I_SLICE) |
---|
898 | #endif |
---|
899 | { |
---|
900 | #if SVC_EXTENSION |
---|
901 | return m_activeNumILRRefIdx; |
---|
902 | #else |
---|
903 | return 0; |
---|
904 | #endif |
---|
905 | } |
---|
906 | for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++) |
---|
907 | { |
---|
908 | if(m_pcRPS->getUsed(i)) |
---|
909 | { |
---|
910 | numRpsCurrTempList++; |
---|
911 | } |
---|
912 | } |
---|
913 | #if SVC_EXTENSION |
---|
914 | if( m_layerId > 0 ) |
---|
915 | { |
---|
916 | numRpsCurrTempList += m_activeNumILRRefIdx; |
---|
917 | } |
---|
918 | #endif |
---|
919 | |
---|
920 | return numRpsCurrTempList; |
---|
921 | } |
---|
922 | |
---|
923 | Void TComSlice::initEqualRef() |
---|
924 | { |
---|
925 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
926 | { |
---|
927 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
928 | { |
---|
929 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
930 | { |
---|
931 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
932 | } |
---|
933 | } |
---|
934 | } |
---|
935 | } |
---|
936 | |
---|
937 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
938 | { |
---|
939 | Int i; |
---|
940 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
941 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1-curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
942 | TComSlice* preSlice; |
---|
943 | Int preColRefPOC; |
---|
944 | for(i=curSliceIdx-1; i>=0; i--) |
---|
945 | { |
---|
946 | preSlice = pic->getSlice(i); |
---|
947 | if(preSlice->getSliceType() != I_SLICE) |
---|
948 | { |
---|
949 | preColRefPOC = preSlice->getRefPOC( RefPicList(1-preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
950 | if(currColRefPOC != preColRefPOC) |
---|
951 | { |
---|
952 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
953 | exit(EXIT_FAILURE); |
---|
954 | } |
---|
955 | else |
---|
956 | { |
---|
957 | break; |
---|
958 | } |
---|
959 | } |
---|
960 | } |
---|
961 | } |
---|
962 | |
---|
963 | Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic) |
---|
964 | { |
---|
965 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
966 | { |
---|
967 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
968 | { |
---|
969 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
970 | } |
---|
971 | } |
---|
972 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
973 | { |
---|
974 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
975 | { |
---|
976 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
977 | { |
---|
978 | assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA); |
---|
979 | } |
---|
980 | else |
---|
981 | { |
---|
982 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
983 | } |
---|
984 | } |
---|
985 | } |
---|
986 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
987 | { |
---|
988 | pocCRA = getPOC(); |
---|
989 | associatedIRAPType = getNalUnitType(); |
---|
990 | } |
---|
991 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
992 | { |
---|
993 | pocCRA = getPOC(); |
---|
994 | associatedIRAPType = getNalUnitType(); |
---|
995 | } |
---|
996 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
997 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
998 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
999 | { |
---|
1000 | pocCRA = getPOC(); |
---|
1001 | associatedIRAPType = getNalUnitType(); |
---|
1002 | } |
---|
1003 | } |
---|
1004 | |
---|
1005 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
1006 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
1007 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
1008 | * \param rcListPic reference to the reference picture list |
---|
1009 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
1010 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
1011 | * are marked as "unused for reference" |
---|
1012 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
1013 | * Otherwise |
---|
1014 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
1015 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
1016 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
1017 | * the bRefreshPending flag to false. |
---|
1018 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
1019 | * reference of the current picture. |
---|
1020 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
1021 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
1022 | */ |
---|
1023 | #if NO_CLRAS_OUTPUT_FLAG |
---|
1024 | Void TComSlice::decodingRefreshMarking( TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag ) |
---|
1025 | { |
---|
1026 | if( !isIRAP() ) |
---|
1027 | { |
---|
1028 | return; |
---|
1029 | } |
---|
1030 | |
---|
1031 | Int pocCurr = getPOC(); |
---|
1032 | TComPic* rpcPic = NULL; |
---|
1033 | |
---|
1034 | // When the current picture is an IRAP picture with nuh_layer_id equal to 0 and NoClrasOutputFlag is equal to 1, |
---|
1035 | // all reference pictures with any value of nuh_layer_id currently in the DPB (if any) are marked as "unused for reference". |
---|
1036 | if( m_layerId == 0 && noClrasOutputFlag ) |
---|
1037 | { |
---|
1038 | // mark all pictures for all layers as not used for reference |
---|
1039 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1040 | while( iterPic != rcListPic.end() ) |
---|
1041 | { |
---|
1042 | rpcPic = *(iterPic); |
---|
1043 | if( rpcPic->getPOC() != pocCurr ) |
---|
1044 | { |
---|
1045 | rpcPic->getSlice(0)->setReferenced(false); |
---|
1046 | } |
---|
1047 | iterPic++; |
---|
1048 | } |
---|
1049 | } |
---|
1050 | |
---|
1051 | // When the current picture is an IRAP picture with NoRaslOutputFlag equal to 1, |
---|
1052 | // all reference pictures with nuh_layer_id equal to currPicLayerId currently in the DPB (if any) are marked as "unused for reference". |
---|
1053 | if( m_noRaslOutputFlag ) |
---|
1054 | { |
---|
1055 | // mark all pictures of a current layer as not used for reference |
---|
1056 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1057 | while( iterPic != rcListPic.end() ) |
---|
1058 | { |
---|
1059 | rpcPic = *(iterPic); |
---|
1060 | if( rpcPic->getPOC() != pocCurr && rpcPic->getLayerId() == m_layerId ) |
---|
1061 | { |
---|
1062 | rpcPic->getSlice(0)->setReferenced(false); |
---|
1063 | } |
---|
1064 | iterPic++; |
---|
1065 | } |
---|
1066 | } |
---|
1067 | } |
---|
1068 | |
---|
1069 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag) |
---|
1070 | #else |
---|
1071 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
1072 | #endif |
---|
1073 | { |
---|
1074 | TComPic* rpcPic; |
---|
1075 | #if !FIX1172 |
---|
1076 | setAssociatedIRAPPOC(pocCRA); |
---|
1077 | #endif |
---|
1078 | Int pocCurr = getPOC(); |
---|
1079 | |
---|
1080 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1081 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1082 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
1083 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
1084 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
1085 | { |
---|
1086 | // mark all pictures as not used for reference |
---|
1087 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1088 | while (iterPic != rcListPic.end()) |
---|
1089 | { |
---|
1090 | rpcPic = *(iterPic); |
---|
1091 | rpcPic->setCurrSliceIdx(0); |
---|
1092 | #if NO_CLRAS_OUTPUT_FLAG |
---|
1093 | if (noClrasOutputFlag) |
---|
1094 | { |
---|
1095 | if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false); // all layers |
---|
1096 | } |
---|
1097 | else |
---|
1098 | { |
---|
1099 | if (rpcPic->getPOC() != pocCurr && rpcPic->getLayerId() == m_layerId) rpcPic->getSlice(0)->setReferenced(false); // only current layer |
---|
1100 | } |
---|
1101 | #else |
---|
1102 | if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
1103 | #endif |
---|
1104 | iterPic++; |
---|
1105 | } |
---|
1106 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1107 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1108 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1109 | { |
---|
1110 | pocCRA = pocCurr; |
---|
1111 | } |
---|
1112 | #if EFFICIENT_FIELD_IRAP |
---|
1113 | bRefreshPending = true; |
---|
1114 | #endif |
---|
1115 | } |
---|
1116 | else // CRA or No DR |
---|
1117 | { |
---|
1118 | #if EFFICIENT_FIELD_IRAP |
---|
1119 | if(getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
1120 | { |
---|
1121 | if (bRefreshPending==true && pocCurr > m_iLastIDR) // IDR reference marking pending |
---|
1122 | { |
---|
1123 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1124 | while (iterPic != rcListPic.end()) |
---|
1125 | { |
---|
1126 | rpcPic = *(iterPic); |
---|
1127 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != m_iLastIDR) |
---|
1128 | { |
---|
1129 | rpcPic->getSlice(0)->setReferenced(false); |
---|
1130 | } |
---|
1131 | iterPic++; |
---|
1132 | } |
---|
1133 | bRefreshPending = false; |
---|
1134 | } |
---|
1135 | } |
---|
1136 | else |
---|
1137 | { |
---|
1138 | #endif |
---|
1139 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
1140 | { |
---|
1141 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1142 | while (iterPic != rcListPic.end()) |
---|
1143 | { |
---|
1144 | rpcPic = *(iterPic); |
---|
1145 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
1146 | { |
---|
1147 | rpcPic->getSlice(0)->setReferenced(false); |
---|
1148 | } |
---|
1149 | iterPic++; |
---|
1150 | } |
---|
1151 | bRefreshPending = false; |
---|
1152 | } |
---|
1153 | #if EFFICIENT_FIELD_IRAP |
---|
1154 | } |
---|
1155 | #endif |
---|
1156 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
1157 | { |
---|
1158 | bRefreshPending = true; |
---|
1159 | pocCRA = pocCurr; |
---|
1160 | } |
---|
1161 | } |
---|
1162 | } |
---|
1163 | |
---|
1164 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
1165 | { |
---|
1166 | assert( pSrc != NULL ); |
---|
1167 | |
---|
1168 | Int i, j, k; |
---|
1169 | |
---|
1170 | m_iPOC = pSrc->m_iPOC; |
---|
1171 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
1172 | m_eSliceType = pSrc->m_eSliceType; |
---|
1173 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
1174 | #if ADAPTIVE_QP_SELECTION |
---|
1175 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
1176 | #endif |
---|
1177 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
1178 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
1179 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
1180 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
1181 | |
---|
1182 | for (i = 0; i < 2; i++) |
---|
1183 | { |
---|
1184 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
1185 | } |
---|
1186 | |
---|
1187 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
1188 | { |
---|
1189 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
1190 | } |
---|
1191 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
1192 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
1193 | m_iSliceQpDeltaCb = pSrc->m_iSliceQpDeltaCb; |
---|
1194 | m_iSliceQpDeltaCr = pSrc->m_iSliceQpDeltaCr; |
---|
1195 | for (i = 0; i < 2; i++) |
---|
1196 | { |
---|
1197 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1198 | { |
---|
1199 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
1200 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
1201 | } |
---|
1202 | } |
---|
1203 | for (i = 0; i < 2; i++) |
---|
1204 | { |
---|
1205 | for (j = 0; j < MAX_NUM_REF + 1; j++) |
---|
1206 | { |
---|
1207 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
1208 | } |
---|
1209 | } |
---|
1210 | m_iDepth = pSrc->m_iDepth; |
---|
1211 | |
---|
1212 | // referenced slice |
---|
1213 | m_bRefenced = pSrc->m_bRefenced; |
---|
1214 | |
---|
1215 | // access channel |
---|
1216 | #if SVC_EXTENSION |
---|
1217 | m_pcVPS = pSrc->m_pcVPS; |
---|
1218 | m_layerId = pSrc->m_layerId; |
---|
1219 | m_activeNumILRRefIdx = pSrc->m_activeNumILRRefIdx; |
---|
1220 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
1221 | memcpy( m_interLayerPredLayerIdc, pSrc->m_interLayerPredLayerIdc, sizeof( m_interLayerPredLayerIdc ) ); |
---|
1222 | #if P0312_VERT_PHASE_ADJ |
---|
1223 | memcpy( m_vertPhasePositionFlag, pSrc->m_vertPhasePositionFlag, sizeof( m_vertPhasePositionFlag ) ); |
---|
1224 | #endif |
---|
1225 | #endif |
---|
1226 | m_pcSPS = pSrc->m_pcSPS; |
---|
1227 | m_pcPPS = pSrc->m_pcPPS; |
---|
1228 | m_pcRPS = pSrc->m_pcRPS; |
---|
1229 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
1230 | |
---|
1231 | m_pcPic = pSrc->m_pcPic; |
---|
1232 | |
---|
1233 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
1234 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
1235 | setLambdas(pSrc->getLambdas()); |
---|
1236 | for (i = 0; i < 2; i++) |
---|
1237 | { |
---|
1238 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1239 | { |
---|
1240 | for (k =0; k < MAX_NUM_REF; k++) |
---|
1241 | { |
---|
1242 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
1243 | } |
---|
1244 | } |
---|
1245 | } |
---|
1246 | |
---|
1247 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
1248 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
1249 | |
---|
1250 | m_sliceMode = pSrc->m_sliceMode; |
---|
1251 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
1252 | m_sliceCurStartCUAddr = pSrc->m_sliceCurStartCUAddr; |
---|
1253 | m_sliceCurEndCUAddr = pSrc->m_sliceCurEndCUAddr; |
---|
1254 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
1255 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
1256 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
1257 | m_sliceSegmentCurStartCUAddr = pSrc->m_sliceSegmentCurStartCUAddr; |
---|
1258 | m_sliceSegmentCurEndCUAddr = pSrc->m_sliceSegmentCurEndCUAddr; |
---|
1259 | m_nextSlice = pSrc->m_nextSlice; |
---|
1260 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
1261 | for ( Int e=0 ; e<2 ; e++ ) |
---|
1262 | { |
---|
1263 | for ( Int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
1264 | { |
---|
1265 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
1266 | } |
---|
1267 | } |
---|
1268 | m_saoEnabledFlag = pSrc->m_saoEnabledFlag; |
---|
1269 | m_saoEnabledFlagChroma = pSrc->m_saoEnabledFlagChroma; |
---|
1270 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
1271 | m_numEntryPointOffsets = pSrc->m_numEntryPointOffsets; |
---|
1272 | |
---|
1273 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
1274 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
1275 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
1276 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
1277 | } |
---|
1278 | |
---|
1279 | Int TComSlice::m_prevTid0POC = 0; |
---|
1280 | |
---|
1281 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
1282 | * \param uiTLayer Temporal layer ID of the current slice |
---|
1283 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
1284 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
1285 | * temporal_layer_switching_point_flag is set accordingly. |
---|
1286 | */ |
---|
1287 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
1288 | { |
---|
1289 | m_uiTLayer = uiTLayer; |
---|
1290 | } |
---|
1291 | |
---|
1292 | /** Function for checking if this is a switching-point |
---|
1293 | */ |
---|
1294 | Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic ) |
---|
1295 | { |
---|
1296 | TComPic* rpcPic; |
---|
1297 | // loop through all pictures in the reference picture buffer |
---|
1298 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1299 | while ( iterPic != rcListPic.end()) |
---|
1300 | { |
---|
1301 | rpcPic = *(iterPic++); |
---|
1302 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
1303 | { |
---|
1304 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1305 | { |
---|
1306 | return false; |
---|
1307 | } |
---|
1308 | } |
---|
1309 | } |
---|
1310 | return true; |
---|
1311 | } |
---|
1312 | |
---|
1313 | /** Function for checking if this is a STSA candidate |
---|
1314 | */ |
---|
1315 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic ) |
---|
1316 | { |
---|
1317 | TComPic* rpcPic; |
---|
1318 | |
---|
1319 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1320 | while ( iterPic != rcListPic.end()) |
---|
1321 | { |
---|
1322 | rpcPic = *(iterPic++); |
---|
1323 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
1324 | { |
---|
1325 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1326 | { |
---|
1327 | return false; |
---|
1328 | } |
---|
1329 | } |
---|
1330 | } |
---|
1331 | return true; |
---|
1332 | } |
---|
1333 | |
---|
1334 | |
---|
1335 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) |
---|
1336 | { |
---|
1337 | TComPic* rpcPic; |
---|
1338 | |
---|
1339 | Int nalUnitType = this->getNalUnitType(); |
---|
1340 | |
---|
1341 | // When a picture is a leading picture, it shall be a RADL or RASL picture. |
---|
1342 | if(this->getAssociatedIRAPPOC() > this->getPOC()) |
---|
1343 | { |
---|
1344 | // Do not check IRAP pictures since they may get a POC lower than their associated IRAP |
---|
1345 | if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1346 | nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) |
---|
1347 | { |
---|
1348 | assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1349 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1350 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1351 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1352 | } |
---|
1353 | } |
---|
1354 | |
---|
1355 | // When a picture is a trailing picture, it shall not be a RADL or RASL picture. |
---|
1356 | if(this->getAssociatedIRAPPOC() < this->getPOC()) |
---|
1357 | { |
---|
1358 | assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && |
---|
1359 | nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && |
---|
1360 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && |
---|
1361 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1362 | } |
---|
1363 | |
---|
1364 | // No RASL pictures shall be present in the bitstream that are associated |
---|
1365 | // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. |
---|
1366 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1367 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1368 | { |
---|
1369 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && |
---|
1370 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); |
---|
1371 | } |
---|
1372 | |
---|
1373 | // No RASL pictures shall be present in the bitstream that are associated with |
---|
1374 | // an IDR picture. |
---|
1375 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1376 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1377 | { |
---|
1378 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && |
---|
1379 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
1380 | } |
---|
1381 | |
---|
1382 | // No RADL pictures shall be present in the bitstream that are associated with |
---|
1383 | // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated |
---|
1384 | // with an IDR picture having nal_unit_type equal to IDR_N_LP. |
---|
1385 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1386 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1387 | { |
---|
1388 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && |
---|
1389 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); |
---|
1390 | } |
---|
1391 | |
---|
1392 | // loop through all pictures in the reference picture buffer |
---|
1393 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1394 | while ( iterPic != rcListPic.end()) |
---|
1395 | { |
---|
1396 | rpcPic = *(iterPic++); |
---|
1397 | #if BUGFIX_INTRAPERIOD |
---|
1398 | if(!rpcPic->getReconMark()) |
---|
1399 | { |
---|
1400 | continue; |
---|
1401 | } |
---|
1402 | #endif |
---|
1403 | if (rpcPic->getPOC() == this->getPOC()) |
---|
1404 | { |
---|
1405 | continue; |
---|
1406 | } |
---|
1407 | |
---|
1408 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1409 | // in decoding order shall precede the IRAP picture in output order. |
---|
1410 | // (Note that any picture following in output order would be present in the DPB) |
---|
1411 | #if !SETTING_NO_OUT_PIC_PRIOR |
---|
1412 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
1413 | #else |
---|
1414 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1 && !this->getNoOutputPriorPicsFlag()) |
---|
1415 | #endif |
---|
1416 | { |
---|
1417 | if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1418 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1419 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1420 | nalUnitType == NAL_UNIT_CODED_SLICE_CRA || |
---|
1421 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1422 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
1423 | { |
---|
1424 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1425 | } |
---|
1426 | } |
---|
1427 | |
---|
1428 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1429 | // in decoding order shall precede any RADL picture associated with the IRAP |
---|
1430 | // picture in output order. |
---|
1431 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
1432 | { |
---|
1433 | if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1434 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) |
---|
1435 | { |
---|
1436 | // rpcPic precedes the IRAP in decoding order |
---|
1437 | if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1438 | { |
---|
1439 | // rpcPic must not be the IRAP picture |
---|
1440 | if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) |
---|
1441 | { |
---|
1442 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1443 | } |
---|
1444 | } |
---|
1445 | } |
---|
1446 | } |
---|
1447 | |
---|
1448 | // When a picture is a leading picture, it shall precede, in decoding order, |
---|
1449 | // all trailing pictures that are associated with the same IRAP picture. |
---|
1450 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1451 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1452 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1453 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1454 | { |
---|
1455 | if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) |
---|
1456 | { |
---|
1457 | // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB |
---|
1458 | // rpcPic would violate the constraint if it was a trailing picture |
---|
1459 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
1460 | } |
---|
1461 | } |
---|
1462 | |
---|
1463 | // Any RASL picture associated with a CRA or BLA picture shall precede any |
---|
1464 | // RADL picture associated with the CRA or BLA picture in output order |
---|
1465 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1466 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1467 | { |
---|
1468 | if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1469 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1470 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1471 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && |
---|
1472 | this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1473 | { |
---|
1474 | if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1475 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1476 | { |
---|
1477 | assert(rpcPic->getPOC() > this->getPOC()); |
---|
1478 | } |
---|
1479 | } |
---|
1480 | } |
---|
1481 | |
---|
1482 | // Any RASL picture associated with a CRA picture shall follow, in output |
---|
1483 | // order, any IRAP picture that precedes the CRA picture in decoding order. |
---|
1484 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1485 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1486 | { |
---|
1487 | if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
1488 | { |
---|
1489 | if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && |
---|
1490 | (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1491 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1492 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1493 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1494 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || |
---|
1495 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) |
---|
1496 | { |
---|
1497 | assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); |
---|
1498 | } |
---|
1499 | } |
---|
1500 | } |
---|
1501 | } |
---|
1502 | } |
---|
1503 | |
---|
1504 | |
---|
1505 | |
---|
1506 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1507 | */ |
---|
1508 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
1509 | { |
---|
1510 | TComPic* rpcPic; |
---|
1511 | Int i, isReference; |
---|
1512 | |
---|
1513 | #if !ALIGNED_BUMPING |
---|
1514 | checkLeadingPictureRestrictions(rcListPic); |
---|
1515 | #endif |
---|
1516 | |
---|
1517 | // loop through all pictures in the reference picture buffer |
---|
1518 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1519 | while ( iterPic != rcListPic.end()) |
---|
1520 | { |
---|
1521 | rpcPic = *(iterPic++); |
---|
1522 | |
---|
1523 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
1524 | { |
---|
1525 | continue; |
---|
1526 | } |
---|
1527 | |
---|
1528 | isReference = 0; |
---|
1529 | // loop through all pictures in the Reference Picture Set |
---|
1530 | // to see if the picture should be kept as reference picture |
---|
1531 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
1532 | { |
---|
1533 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
1534 | { |
---|
1535 | isReference = 1; |
---|
1536 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1537 | rpcPic->setIsLongTerm(0); |
---|
1538 | } |
---|
1539 | } |
---|
1540 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1541 | { |
---|
1542 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1543 | { |
---|
1544 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
1545 | { |
---|
1546 | isReference = 1; |
---|
1547 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1548 | } |
---|
1549 | } |
---|
1550 | else |
---|
1551 | { |
---|
1552 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1553 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1554 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1555 | if(rpcPic->getIsLongTerm() && curPoc == refPoc) |
---|
1556 | { |
---|
1557 | isReference = 1; |
---|
1558 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1559 | } |
---|
1560 | } |
---|
1561 | |
---|
1562 | } |
---|
1563 | #if DISCARDABLE_PIC_RPS |
---|
1564 | if( isReference ) // Current picture is in the temporal RPS |
---|
1565 | { |
---|
1566 | assert( rpcPic->getSlice(0)->getDiscardableFlag() == 0 ); // Temporal RPS shall not contain picture with discardable_flag equal to 1 |
---|
1567 | } |
---|
1568 | #endif |
---|
1569 | // mark the picture as "unused for reference" if it is not in |
---|
1570 | // the Reference Picture Set |
---|
1571 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
1572 | { |
---|
1573 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
1574 | rpcPic->setUsedByCurr(0); |
---|
1575 | rpcPic->setIsLongTerm(0); |
---|
1576 | } |
---|
1577 | //check that pictures of higher temporal layers are not used |
---|
1578 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
1579 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
1580 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
1581 | { |
---|
1582 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
1583 | } |
---|
1584 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
1585 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
1586 | { |
---|
1587 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
1588 | } |
---|
1589 | } |
---|
1590 | } |
---|
1591 | |
---|
1592 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1593 | */ |
---|
1594 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1595 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1596 | #else |
---|
1597 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess) |
---|
1598 | #endif |
---|
1599 | { |
---|
1600 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1601 | Int atLeastOneUnabledByRecoveryPoint = 0; |
---|
1602 | Int atLeastOneFlushedByPreviousIDR = 0; |
---|
1603 | #endif |
---|
1604 | TComPic* rpcPic; |
---|
1605 | Int i, isAvailable; |
---|
1606 | Int atLeastOneLost = 0; |
---|
1607 | Int atLeastOneRemoved = 0; |
---|
1608 | Int iPocLost = 0; |
---|
1609 | |
---|
1610 | // loop through all long-term pictures in the Reference Picture Set |
---|
1611 | // to see if the picture should be kept as reference picture |
---|
1612 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1613 | { |
---|
1614 | isAvailable = 0; |
---|
1615 | // loop through all pictures in the reference picture buffer |
---|
1616 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1617 | while ( iterPic != rcListPic.end()) |
---|
1618 | { |
---|
1619 | rpcPic = *(iterPic++); |
---|
1620 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1621 | { |
---|
1622 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1623 | { |
---|
1624 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1625 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1626 | { |
---|
1627 | isAvailable = 0; |
---|
1628 | } |
---|
1629 | else |
---|
1630 | { |
---|
1631 | isAvailable = 1; |
---|
1632 | } |
---|
1633 | #else |
---|
1634 | isAvailable = 1; |
---|
1635 | #endif |
---|
1636 | } |
---|
1637 | } |
---|
1638 | else |
---|
1639 | { |
---|
1640 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1641 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1642 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1643 | if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) |
---|
1644 | { |
---|
1645 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1646 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1647 | { |
---|
1648 | isAvailable = 0; |
---|
1649 | } |
---|
1650 | else |
---|
1651 | { |
---|
1652 | isAvailable = 1; |
---|
1653 | } |
---|
1654 | #else |
---|
1655 | isAvailable = 1; |
---|
1656 | #endif |
---|
1657 | } |
---|
1658 | } |
---|
1659 | } |
---|
1660 | // if there was no such long-term check the short terms |
---|
1661 | if(!isAvailable) |
---|
1662 | { |
---|
1663 | iterPic = rcListPic.begin(); |
---|
1664 | while ( iterPic != rcListPic.end()) |
---|
1665 | { |
---|
1666 | rpcPic = *(iterPic++); |
---|
1667 | |
---|
1668 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1669 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
1670 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
1671 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
1672 | { |
---|
1673 | curPoc = curPoc & (pocCycle - 1); |
---|
1674 | refPoc = refPoc & (pocCycle - 1); |
---|
1675 | } |
---|
1676 | |
---|
1677 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
1678 | { |
---|
1679 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1680 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1681 | { |
---|
1682 | isAvailable = 0; |
---|
1683 | } |
---|
1684 | else |
---|
1685 | { |
---|
1686 | isAvailable = 1; |
---|
1687 | rpcPic->setIsLongTerm(1); |
---|
1688 | break; |
---|
1689 | } |
---|
1690 | #else |
---|
1691 | isAvailable = 1; |
---|
1692 | rpcPic->setIsLongTerm(1); |
---|
1693 | break; |
---|
1694 | #endif |
---|
1695 | } |
---|
1696 | } |
---|
1697 | } |
---|
1698 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1699 | // but not available as reference picture |
---|
1700 | if(isAvailable == 0) |
---|
1701 | { |
---|
1702 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1703 | { |
---|
1704 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1705 | { |
---|
1706 | if(printErrors) |
---|
1707 | { |
---|
1708 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1709 | } |
---|
1710 | atLeastOneRemoved = 1; |
---|
1711 | } |
---|
1712 | else |
---|
1713 | { |
---|
1714 | if(printErrors) |
---|
1715 | { |
---|
1716 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1717 | } |
---|
1718 | atLeastOneLost = 1; |
---|
1719 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1720 | } |
---|
1721 | } |
---|
1722 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1723 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1724 | { |
---|
1725 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1726 | } |
---|
1727 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1728 | { |
---|
1729 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1730 | } |
---|
1731 | #endif |
---|
1732 | } |
---|
1733 | } |
---|
1734 | // loop through all short-term pictures in the Reference Picture Set |
---|
1735 | // to see if the picture should be kept as reference picture |
---|
1736 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
1737 | { |
---|
1738 | isAvailable = 0; |
---|
1739 | // loop through all pictures in the reference picture buffer |
---|
1740 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1741 | while ( iterPic != rcListPic.end()) |
---|
1742 | { |
---|
1743 | rpcPic = *(iterPic++); |
---|
1744 | |
---|
1745 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1746 | { |
---|
1747 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1748 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1749 | { |
---|
1750 | isAvailable = 0; |
---|
1751 | } |
---|
1752 | else |
---|
1753 | { |
---|
1754 | isAvailable = 1; |
---|
1755 | } |
---|
1756 | #else |
---|
1757 | isAvailable = 1; |
---|
1758 | #endif |
---|
1759 | } |
---|
1760 | } |
---|
1761 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1762 | // but not available as reference picture |
---|
1763 | if(isAvailable == 0) |
---|
1764 | { |
---|
1765 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1766 | { |
---|
1767 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1768 | { |
---|
1769 | if(printErrors) |
---|
1770 | { |
---|
1771 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1772 | } |
---|
1773 | atLeastOneRemoved = 1; |
---|
1774 | } |
---|
1775 | else |
---|
1776 | { |
---|
1777 | if(printErrors) |
---|
1778 | { |
---|
1779 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1780 | } |
---|
1781 | atLeastOneLost = 1; |
---|
1782 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1783 | } |
---|
1784 | } |
---|
1785 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1786 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1787 | { |
---|
1788 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1789 | } |
---|
1790 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1791 | { |
---|
1792 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1793 | } |
---|
1794 | #endif |
---|
1795 | } |
---|
1796 | } |
---|
1797 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1798 | if(atLeastOneUnabledByRecoveryPoint || atLeastOneFlushedByPreviousIDR) |
---|
1799 | { |
---|
1800 | return -1; |
---|
1801 | } |
---|
1802 | #endif |
---|
1803 | if(atLeastOneLost) |
---|
1804 | { |
---|
1805 | return iPocLost+1; |
---|
1806 | } |
---|
1807 | if(atLeastOneRemoved) |
---|
1808 | { |
---|
1809 | return -2; |
---|
1810 | } |
---|
1811 | else |
---|
1812 | { |
---|
1813 | return 0; |
---|
1814 | } |
---|
1815 | } |
---|
1816 | |
---|
1817 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
1818 | */ |
---|
1819 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1820 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1821 | #else |
---|
1822 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP) |
---|
1823 | #endif |
---|
1824 | { |
---|
1825 | TComPic* rpcPic; |
---|
1826 | Int i, j; |
---|
1827 | Int k = 0; |
---|
1828 | Int nrOfNegativePictures = 0; |
---|
1829 | Int nrOfPositivePictures = 0; |
---|
1830 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
1831 | |
---|
1832 | // loop through all pictures in the Reference Picture Set |
---|
1833 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1834 | { |
---|
1835 | j = 0; |
---|
1836 | // loop through all pictures in the reference picture buffer |
---|
1837 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1838 | while ( iterPic != rcListPic.end()) |
---|
1839 | { |
---|
1840 | j++; |
---|
1841 | rpcPic = *(iterPic++); |
---|
1842 | |
---|
1843 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1844 | { |
---|
1845 | // This picture exists as a reference picture |
---|
1846 | // and should be added to the explicit Reference Picture Set |
---|
1847 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
1848 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); |
---|
1849 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1850 | pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) ); |
---|
1851 | #endif |
---|
1852 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
1853 | { |
---|
1854 | nrOfNegativePictures++; |
---|
1855 | } |
---|
1856 | else |
---|
1857 | { |
---|
1858 | nrOfPositivePictures++; |
---|
1859 | } |
---|
1860 | k++; |
---|
1861 | } |
---|
1862 | } |
---|
1863 | } |
---|
1864 | #if EFFICIENT_FIELD_IRAP |
---|
1865 | Bool useNewRPS = false; |
---|
1866 | // if current picture is complimentary field associated to IRAP, add the IRAP to its RPS. |
---|
1867 | if(m_pcPic->isField()) |
---|
1868 | { |
---|
1869 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1870 | while ( iterPic != rcListPic.end()) |
---|
1871 | { |
---|
1872 | rpcPic = *(iterPic++); |
---|
1873 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
1874 | { |
---|
1875 | pcRPS->setDeltaPOC(k, 1); |
---|
1876 | pcRPS->setUsed(k, true); |
---|
1877 | nrOfPositivePictures++; |
---|
1878 | k ++; |
---|
1879 | useNewRPS = true; |
---|
1880 | } |
---|
1881 | } |
---|
1882 | } |
---|
1883 | #endif |
---|
1884 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
1885 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
1886 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
1887 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
1888 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
1889 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
1890 | if (!pReferencePictureSet->getInterRPSPrediction() |
---|
1891 | #if EFFICIENT_FIELD_IRAP |
---|
1892 | || useNewRPS |
---|
1893 | #endif |
---|
1894 | ) |
---|
1895 | { |
---|
1896 | pcRPS->setInterRPSPrediction(false); |
---|
1897 | pcRPS->setNumRefIdc(0); |
---|
1898 | } |
---|
1899 | else |
---|
1900 | { |
---|
1901 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
1902 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
1903 | TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
1904 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
1905 | Int iNewIdc=0; |
---|
1906 | for(i=0; i<= iRefPics; i++) |
---|
1907 | { |
---|
1908 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
1909 | Int iRefIdc = 0; |
---|
1910 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
1911 | { |
---|
1912 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
1913 | { |
---|
1914 | if (pcRPS->getUsed(j)) |
---|
1915 | { |
---|
1916 | iRefIdc = 1; |
---|
1917 | } |
---|
1918 | else |
---|
1919 | { |
---|
1920 | iRefIdc = 2; |
---|
1921 | } |
---|
1922 | } |
---|
1923 | } |
---|
1924 | pcRPS->setRefIdc(i, iRefIdc); |
---|
1925 | iNewIdc++; |
---|
1926 | } |
---|
1927 | pcRPS->setInterRPSPrediction(true); |
---|
1928 | pcRPS->setNumRefIdc(iNewIdc); |
---|
1929 | pcRPS->setDeltaRPS(deltaRPS); |
---|
1930 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
1931 | } |
---|
1932 | |
---|
1933 | this->setRPS(pcRPS); |
---|
1934 | this->setRPSidx(-1); |
---|
1935 | } |
---|
1936 | |
---|
1937 | /** get AC and DC values for weighted pred |
---|
1938 | * \param *wp |
---|
1939 | * \returns Void |
---|
1940 | */ |
---|
1941 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
1942 | { |
---|
1943 | wp = m_weightACDCParam; |
---|
1944 | } |
---|
1945 | |
---|
1946 | /** init AC and DC values for weighted pred |
---|
1947 | * \returns Void |
---|
1948 | */ |
---|
1949 | Void TComSlice::initWpAcDcParam() |
---|
1950 | { |
---|
1951 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
1952 | { |
---|
1953 | m_weightACDCParam[iComp].iAC = 0; |
---|
1954 | m_weightACDCParam[iComp].iDC = 0; |
---|
1955 | } |
---|
1956 | } |
---|
1957 | |
---|
1958 | /** get WP tables for weighted pred |
---|
1959 | * \param RefPicList |
---|
1960 | * \param iRefIdx |
---|
1961 | * \param *&wpScalingParam |
---|
1962 | * \returns Void |
---|
1963 | */ |
---|
1964 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
1965 | { |
---|
1966 | wp = m_weightPredTable[e][iRefIdx]; |
---|
1967 | } |
---|
1968 | |
---|
1969 | /** reset Default WP tables settings : no weight. |
---|
1970 | * \param wpScalingParam |
---|
1971 | * \returns Void |
---|
1972 | */ |
---|
1973 | Void TComSlice::resetWpScaling() |
---|
1974 | { |
---|
1975 | for ( Int e=0 ; e<2 ; e++ ) |
---|
1976 | { |
---|
1977 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1978 | { |
---|
1979 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
1980 | { |
---|
1981 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1982 | pwp->bPresentFlag = false; |
---|
1983 | pwp->uiLog2WeightDenom = 0; |
---|
1984 | pwp->uiLog2WeightDenom = 0; |
---|
1985 | pwp->iWeight = 1; |
---|
1986 | pwp->iOffset = 0; |
---|
1987 | } |
---|
1988 | } |
---|
1989 | } |
---|
1990 | } |
---|
1991 | |
---|
1992 | /** init WP table |
---|
1993 | * \returns Void |
---|
1994 | */ |
---|
1995 | Void TComSlice::initWpScaling() |
---|
1996 | { |
---|
1997 | for ( Int e=0 ; e<2 ; e++ ) |
---|
1998 | { |
---|
1999 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
2000 | { |
---|
2001 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
2002 | { |
---|
2003 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
2004 | if ( !pwp->bPresentFlag ) |
---|
2005 | { |
---|
2006 | // Inferring values not present : |
---|
2007 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
2008 | pwp->iOffset = 0; |
---|
2009 | } |
---|
2010 | |
---|
2011 | pwp->w = pwp->iWeight; |
---|
2012 | Int bitDepth = yuv ? g_bitDepthC : g_bitDepthY; |
---|
2013 | pwp->o = pwp->iOffset << (bitDepth-8); |
---|
2014 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
2015 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
2016 | } |
---|
2017 | } |
---|
2018 | } |
---|
2019 | } |
---|
2020 | |
---|
2021 | #if REPN_FORMAT_IN_VPS |
---|
2022 | UInt TComSlice::getPicWidthInLumaSamples() |
---|
2023 | { |
---|
2024 | TComSPS *sps = getSPS(); |
---|
2025 | TComVPS *vps = getVPS(); |
---|
2026 | UInt retVal, layerId = getLayerId(); |
---|
2027 | #if O0096_REP_FORMAT_INDEX |
---|
2028 | if ( layerId == 0 ) |
---|
2029 | { |
---|
2030 | if( vps->getAvcBaseLayerFlag() ) |
---|
2031 | { |
---|
2032 | retVal = vps->getVpsRepFormat(layerId)->getPicWidthVpsInLumaSamples(); |
---|
2033 | } |
---|
2034 | else |
---|
2035 | { |
---|
2036 | retVal = sps->getPicWidthInLumaSamples(); |
---|
2037 | } |
---|
2038 | } |
---|
2039 | else |
---|
2040 | { |
---|
2041 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getPicWidthVpsInLumaSamples(); |
---|
2042 | } |
---|
2043 | #else |
---|
2044 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
2045 | { |
---|
2046 | retVal = sps->getPicWidthInLumaSamples(); |
---|
2047 | } |
---|
2048 | else |
---|
2049 | { |
---|
2050 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getPicWidthVpsInLumaSamples(); |
---|
2051 | } |
---|
2052 | #endif |
---|
2053 | return retVal; |
---|
2054 | } |
---|
2055 | UInt TComSlice::getPicHeightInLumaSamples() |
---|
2056 | { |
---|
2057 | TComSPS *sps = getSPS(); |
---|
2058 | TComVPS *vps = getVPS(); |
---|
2059 | UInt retVal, layerId = getLayerId(); |
---|
2060 | #if O0096_REP_FORMAT_INDEX |
---|
2061 | if( layerId == 0 ) |
---|
2062 | { |
---|
2063 | if( vps->getAvcBaseLayerFlag() ) |
---|
2064 | { |
---|
2065 | retVal = vps->getVpsRepFormat(layerId)->getPicHeightVpsInLumaSamples(); |
---|
2066 | } |
---|
2067 | else |
---|
2068 | { |
---|
2069 | retVal = sps->getPicHeightInLumaSamples(); |
---|
2070 | } |
---|
2071 | } |
---|
2072 | else |
---|
2073 | { |
---|
2074 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getPicHeightVpsInLumaSamples(); |
---|
2075 | } |
---|
2076 | #else |
---|
2077 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
2078 | { |
---|
2079 | retVal = sps->getPicHeightInLumaSamples(); |
---|
2080 | } |
---|
2081 | else |
---|
2082 | { |
---|
2083 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getPicHeightVpsInLumaSamples(); |
---|
2084 | } |
---|
2085 | #endif |
---|
2086 | return retVal; |
---|
2087 | } |
---|
2088 | #if AUXILIARY_PICTURES |
---|
2089 | ChromaFormat TComSlice::getChromaFormatIdc() |
---|
2090 | #else |
---|
2091 | UInt TComSlice::getChromaFormatIdc() |
---|
2092 | #endif |
---|
2093 | { |
---|
2094 | TComSPS *sps = getSPS(); |
---|
2095 | TComVPS *vps = getVPS(); |
---|
2096 | #if AUXILIARY_PICTURES |
---|
2097 | ChromaFormat retVal; |
---|
2098 | UInt layerId = getLayerId(); |
---|
2099 | #else |
---|
2100 | UInt retVal, layerId = getLayerId(); |
---|
2101 | #endif |
---|
2102 | #if O0096_REP_FORMAT_INDEX |
---|
2103 | if( layerId == 0 ) |
---|
2104 | { |
---|
2105 | if( vps->getAvcBaseLayerFlag() ) |
---|
2106 | { |
---|
2107 | retVal = vps->getVpsRepFormat(layerId)->getChromaFormatVpsIdc(); |
---|
2108 | } |
---|
2109 | else |
---|
2110 | { |
---|
2111 | retVal = sps->getChromaFormatIdc(); |
---|
2112 | } |
---|
2113 | } |
---|
2114 | else |
---|
2115 | { |
---|
2116 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getChromaFormatVpsIdc(); |
---|
2117 | } |
---|
2118 | #else |
---|
2119 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
2120 | { |
---|
2121 | retVal = sps->getChromaFormatIdc(); |
---|
2122 | } |
---|
2123 | else |
---|
2124 | { |
---|
2125 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getChromaFormatVpsIdc(); |
---|
2126 | } |
---|
2127 | #endif |
---|
2128 | return retVal; |
---|
2129 | } |
---|
2130 | UInt TComSlice::getBitDepthY() |
---|
2131 | { |
---|
2132 | TComSPS *sps = getSPS(); |
---|
2133 | TComVPS *vps = getVPS(); |
---|
2134 | UInt retVal, layerId = getLayerId(); |
---|
2135 | #if O0096_REP_FORMAT_INDEX |
---|
2136 | if( layerId == 0 ) |
---|
2137 | { |
---|
2138 | retVal = sps->getBitDepthY(); |
---|
2139 | } |
---|
2140 | else |
---|
2141 | { |
---|
2142 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getBitDepthVpsLuma(); |
---|
2143 | } |
---|
2144 | #else |
---|
2145 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
2146 | { |
---|
2147 | retVal = sps->getBitDepthY(); |
---|
2148 | } |
---|
2149 | else |
---|
2150 | { |
---|
2151 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsLuma(); |
---|
2152 | } |
---|
2153 | #endif |
---|
2154 | return retVal; |
---|
2155 | } |
---|
2156 | UInt TComSlice::getBitDepthC() |
---|
2157 | { |
---|
2158 | TComSPS *sps = getSPS(); |
---|
2159 | TComVPS *vps = getVPS(); |
---|
2160 | UInt retVal, layerId = getLayerId(); |
---|
2161 | #if O0096_REP_FORMAT_INDEX |
---|
2162 | if( layerId == 0 ) |
---|
2163 | { |
---|
2164 | retVal = sps->getBitDepthC(); |
---|
2165 | } |
---|
2166 | else |
---|
2167 | { |
---|
2168 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getBitDepthVpsChroma(); |
---|
2169 | } |
---|
2170 | #else |
---|
2171 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
2172 | { |
---|
2173 | retVal = sps->getBitDepthC(); |
---|
2174 | } |
---|
2175 | else |
---|
2176 | { |
---|
2177 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsChroma(); |
---|
2178 | } |
---|
2179 | #endif |
---|
2180 | return retVal; |
---|
2181 | } |
---|
2182 | Int TComSlice::getQpBDOffsetY() |
---|
2183 | { |
---|
2184 | return (getBitDepthY() - 8) * 6; |
---|
2185 | } |
---|
2186 | Int TComSlice::getQpBDOffsetC() |
---|
2187 | { |
---|
2188 | return (getBitDepthC() - 8) * 6; |
---|
2189 | } |
---|
2190 | |
---|
2191 | RepFormat::RepFormat() |
---|
2192 | #if AUXILIARY_PICTURES |
---|
2193 | : m_chromaFormatVpsIdc (CHROMA_420) |
---|
2194 | #else |
---|
2195 | : m_chromaFormatVpsIdc (0) |
---|
2196 | #endif |
---|
2197 | , m_separateColourPlaneVpsFlag (false) |
---|
2198 | , m_picWidthVpsInLumaSamples (0) |
---|
2199 | , m_picHeightVpsInLumaSamples (0) |
---|
2200 | , m_bitDepthVpsLuma (0) |
---|
2201 | , m_bitDepthVpsChroma (0) |
---|
2202 | {} |
---|
2203 | #if RESOLUTION_BASED_DPB |
---|
2204 | Void RepFormat::init() |
---|
2205 | { |
---|
2206 | m_chromaFormatVpsIdc = CHROMA_420; |
---|
2207 | m_separateColourPlaneVpsFlag = false; |
---|
2208 | m_picWidthVpsInLumaSamples = 0; |
---|
2209 | m_picHeightVpsInLumaSamples = 0; |
---|
2210 | m_bitDepthVpsLuma = 0; |
---|
2211 | m_bitDepthVpsChroma = 0; |
---|
2212 | } |
---|
2213 | #endif |
---|
2214 | #endif |
---|
2215 | |
---|
2216 | // ------------------------------------------------------------------------------------------------ |
---|
2217 | // Video parameter set (VPS) |
---|
2218 | // ------------------------------------------------------------------------------------------------ |
---|
2219 | #if SVC_EXTENSION |
---|
2220 | TComVPS::TComVPS() |
---|
2221 | : m_VPSId ( 0) |
---|
2222 | , m_uiMaxTLayers ( 1) |
---|
2223 | , m_uiMaxLayers ( 1) |
---|
2224 | , m_bTemporalIdNestingFlag (false) |
---|
2225 | , m_numHrdParameters ( 0) |
---|
2226 | , m_hrdParameters (NULL) |
---|
2227 | , m_hrdOpSetIdx (NULL) |
---|
2228 | , m_cprmsPresentFlag (NULL) |
---|
2229 | , m_maxLayerId (0) |
---|
2230 | , m_numLayerSets (0) |
---|
2231 | #if VPS_EXTN_OP_LAYER_SETS |
---|
2232 | , m_numOutputLayerSets (0) |
---|
2233 | #endif |
---|
2234 | , m_numProfileTierLevel (0) |
---|
2235 | #if !VPS_EXTN_UEV_CODING |
---|
2236 | , m_moreOutputLayerSetsThanDefaultFlag (false) |
---|
2237 | #endif |
---|
2238 | , m_numAddOutputLayerSets (0) |
---|
2239 | #if P0295_DEFAULT_OUT_LAYER_IDC |
---|
2240 | , m_defaultTargetOutputLayerIdc (0) |
---|
2241 | #else |
---|
2242 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
2243 | , m_defaultOneTargetOutputLayerIdc (0) |
---|
2244 | #else |
---|
2245 | , m_defaultOneTargetOutputLayerFlag (false) |
---|
2246 | #endif |
---|
2247 | #endif |
---|
2248 | , m_bitRatePresentVpsFlag (false) |
---|
2249 | , m_picRatePresentVpsFlag (false) |
---|
2250 | #if REPN_FORMAT_IN_VPS |
---|
2251 | #if Q0195_REP_FORMAT_CLEANUP |
---|
2252 | , m_repFormatIdxPresentFlag (false) |
---|
2253 | #else |
---|
2254 | , m_repFormatIdxPresentFlag (true) |
---|
2255 | #endif |
---|
2256 | , m_vpsNumRepFormats (1) |
---|
2257 | #endif |
---|
2258 | #if VIEW_ID_RELATED_SIGNALING |
---|
2259 | #if O0109_VIEW_ID_LEN |
---|
2260 | , m_viewIdLen (0) |
---|
2261 | #else |
---|
2262 | , m_viewIdLenMinus1 (0) |
---|
2263 | #endif |
---|
2264 | #endif |
---|
2265 | #if !P0307_REMOVE_VPS_VUI_OFFSET |
---|
2266 | #if VPS_VUI_OFFSET |
---|
2267 | , m_vpsVuiOffset (0) |
---|
2268 | #endif |
---|
2269 | #endif |
---|
2270 | #if P0307_VPS_NON_VUI_EXTENSION |
---|
2271 | , m_vpsNonVuiExtLength (0) |
---|
2272 | #endif |
---|
2273 | { |
---|
2274 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
2275 | { |
---|
2276 | m_numReorderPics[i] = 0; |
---|
2277 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2278 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2279 | } |
---|
2280 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
2281 | m_avcBaseLayerFlag = false; |
---|
2282 | m_splittingFlag = false; |
---|
2283 | ::memset(m_scalabilityMask, 0, sizeof(m_scalabilityMask)); |
---|
2284 | ::memset(m_dimensionIdLen, 0, sizeof(m_dimensionIdLen)); |
---|
2285 | m_nuhLayerIdPresentFlag = false; |
---|
2286 | ::memset(m_layerIdInNuh, 0, sizeof(m_layerIdInNuh)); |
---|
2287 | ::memset(m_dimensionId, 0, sizeof(m_dimensionId)); |
---|
2288 | |
---|
2289 | m_numScalabilityTypes = 0; |
---|
2290 | ::memset(m_layerIdInVps, 0, sizeof(m_layerIdInVps)); |
---|
2291 | #endif |
---|
2292 | #if VPS_EXTN_PROFILE_INFO |
---|
2293 | ::memset(m_profilePresentFlag, 0, sizeof(m_profilePresentFlag)); |
---|
2294 | #if !P0048_REMOVE_PROFILE_REF |
---|
2295 | ::memset(m_profileLayerSetRef, 0, sizeof(m_profileLayerSetRef)); |
---|
2296 | #endif |
---|
2297 | #endif |
---|
2298 | #if VPS_EXTN_OP_LAYER_SETS |
---|
2299 | ::memset(m_layerIdIncludedFlag, 0, sizeof(m_layerIdIncludedFlag)); |
---|
2300 | // Consider dynamic allocation for outputLayerSetIdx and outputLayerFlag |
---|
2301 | ::memset(m_outputLayerSetIdx, 0, sizeof(m_outputLayerSetIdx)); |
---|
2302 | ::memset(m_outputLayerFlag, 0, sizeof(m_outputLayerFlag)); |
---|
2303 | #endif |
---|
2304 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
2305 | ::memset(m_directDependencyFlag, 0, sizeof(m_directDependencyFlag)); |
---|
2306 | ::memset(m_numDirectRefLayers, 0, sizeof(m_numDirectRefLayers )); |
---|
2307 | ::memset(m_refLayerId, 0, sizeof(m_refLayerId )); |
---|
2308 | m_directDepTypeLen = 2; |
---|
2309 | ::memset(m_directDependencyType, 0, sizeof(m_directDependencyType)); |
---|
2310 | #endif |
---|
2311 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
2312 | ::memset(m_layerSetLayerIdList, 0, sizeof(m_layerSetLayerIdList)); |
---|
2313 | ::memset(m_numLayerInIdList, 0, sizeof(m_numLayerInIdList )); |
---|
2314 | #endif |
---|
2315 | ::memset(m_profileLevelTierIdx, 0, sizeof(m_profileLevelTierIdx)); |
---|
2316 | m_maxOneActiveRefLayerFlag = true; |
---|
2317 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
2318 | ::memset(m_pocLsbNotPresentFlag, 0, sizeof(m_pocLsbNotPresentFlag)); |
---|
2319 | #endif |
---|
2320 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
2321 | m_crossLayerPictureTypeAlignFlag = true; |
---|
2322 | #endif |
---|
2323 | m_crossLayerIrapAlignFlag = true; |
---|
2324 | #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG |
---|
2325 | m_crossLayerAlignedIdrOnlyFlag = false; |
---|
2326 | #endif |
---|
2327 | m_maxTidRefPresentFlag = true; |
---|
2328 | for( Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++) |
---|
2329 | { |
---|
2330 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
2331 | for( Int j = 0; j < MAX_VPS_LAYER_ID_PLUS1; j++) |
---|
2332 | { |
---|
2333 | m_maxTidIlRefPicsPlus1[i][j] = m_uiMaxTLayers + 1; |
---|
2334 | } |
---|
2335 | #else |
---|
2336 | m_maxTidIlRefPicsPlus1[i] = m_uiMaxTLayers + 1; |
---|
2337 | #endif |
---|
2338 | } |
---|
2339 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
2340 | m_tilesNotInUseFlag = true; |
---|
2341 | ::memset(m_tilesInUseFlag, 0, sizeof(m_tilesInUseFlag)); |
---|
2342 | ::memset(m_loopFilterNotAcrossTilesFlag, 0, sizeof(m_loopFilterNotAcrossTilesFlag)); |
---|
2343 | #endif |
---|
2344 | #if TILE_BOUNDARY_ALIGNED_FLAG |
---|
2345 | ::memset(m_tileBoundariesAlignedFlag, 0, sizeof(m_tileBoundariesAlignedFlag)); |
---|
2346 | #endif |
---|
2347 | #if VPS_VUI_WPP_NOT_IN_USE__FLAG |
---|
2348 | m_wppNotInUseFlag = true; |
---|
2349 | ::memset(m_wppInUseFlag, 0, sizeof(m_wppInUseFlag)); |
---|
2350 | #endif |
---|
2351 | #if N0160_VUI_EXT_ILP_REF |
---|
2352 | m_ilpRestrictedRefLayersFlag = false; |
---|
2353 | ::memset(m_minSpatialSegmentOffsetPlus1, 0, sizeof(m_minSpatialSegmentOffsetPlus1)); |
---|
2354 | ::memset(m_ctuBasedOffsetEnabledFlag, 0, sizeof(m_ctuBasedOffsetEnabledFlag)); |
---|
2355 | ::memset(m_minHorizontalCtuOffsetPlus1, 0, sizeof(m_minHorizontalCtuOffsetPlus1)); |
---|
2356 | #endif |
---|
2357 | #if VPS_VUI_VIDEO_SIGNAL |
---|
2358 | m_vidSigPresentVpsFlag=true; |
---|
2359 | m_vpsVidSigInfo=1; |
---|
2360 | ::memset( m_vpsVidSigIdx, 0, sizeof(m_vpsVidSigIdx) ); |
---|
2361 | m_vpsVidSigIdx[0]=0; |
---|
2362 | for (Int i=0; i < 16; i++) |
---|
2363 | { |
---|
2364 | m_vpsVidFormat[i] = 5; |
---|
2365 | m_vpsFullRangeFlag[i] = false; |
---|
2366 | m_vpsColorPrimaries[i] = 2; |
---|
2367 | m_vpsTransChar[i] = 2; |
---|
2368 | m_vpsMatCoeff[i] = 2; |
---|
2369 | } |
---|
2370 | #endif |
---|
2371 | ::memset(m_bitRatePresentFlag, 0, sizeof(m_bitRatePresentFlag)); |
---|
2372 | ::memset(m_picRatePresentFlag, 0, sizeof(m_picRatePresentFlag)); |
---|
2373 | ::memset(m_avgBitRate , 0, sizeof(m_avgBitRate) ); |
---|
2374 | ::memset(m_maxBitRate , 0, sizeof(m_maxBitRate) ); |
---|
2375 | ::memset(m_constPicRateIdc , 0, sizeof(m_constPicRateIdc) ); |
---|
2376 | ::memset(m_avgPicRate , 0, sizeof(m_avgPicRate) ); |
---|
2377 | #if REPN_FORMAT_IN_VPS |
---|
2378 | ::memset( m_vpsRepFormatIdx, 0, sizeof(m_vpsRepFormatIdx) ); |
---|
2379 | #endif |
---|
2380 | #if VIEW_ID_RELATED_SIGNALING |
---|
2381 | ::memset(m_viewIdVal, 0, sizeof(m_viewIdVal)); |
---|
2382 | #endif |
---|
2383 | #if O0092_0094_DEPENDENCY_CONSTRAINT |
---|
2384 | for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) |
---|
2385 | { |
---|
2386 | m_numberRefLayers[i] = 0; |
---|
2387 | for (Int j = 0; j < MAX_NUM_LAYER_IDS; j++) |
---|
2388 | { |
---|
2389 | m_recursiveRefLayerFlag[i][j] = 0; |
---|
2390 | } |
---|
2391 | } |
---|
2392 | #endif |
---|
2393 | #if VPS_DPB_SIZE_TABLE |
---|
2394 | ::memset( m_subLayerFlagInfoPresentFlag, 0, sizeof(m_subLayerFlagInfoPresentFlag ) ); |
---|
2395 | ::memset( m_subLayerDpbInfoPresentFlag, 0, sizeof(m_subLayerDpbInfoPresentFlag ) ); |
---|
2396 | ::memset( m_maxVpsDecPicBufferingMinus1, 0, sizeof(m_maxVpsDecPicBufferingMinus1 ) ); |
---|
2397 | #if RESOLUTION_BASED_DPB |
---|
2398 | ::memset( m_maxVpsLayerDecPicBuffMinus1, 0, sizeof(m_maxVpsLayerDecPicBuffMinus1 ) ); |
---|
2399 | #endif |
---|
2400 | ::memset( m_maxVpsNumReorderPics, 0, sizeof(m_maxVpsNumReorderPics ) ); |
---|
2401 | ::memset( m_maxVpsLatencyIncreasePlus1, 0, sizeof(m_maxVpsLatencyIncreasePlus1 ) ); |
---|
2402 | ::memset( m_numSubDpbs , 0, sizeof(m_numSubDpbs) ); |
---|
2403 | #endif |
---|
2404 | } |
---|
2405 | #else |
---|
2406 | TComVPS::TComVPS() |
---|
2407 | : m_VPSId ( 0) |
---|
2408 | , m_uiMaxTLayers ( 1) |
---|
2409 | , m_uiMaxLayers ( 1) |
---|
2410 | , m_bTemporalIdNestingFlag (false) |
---|
2411 | , m_numHrdParameters ( 0) |
---|
2412 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
2413 | , m_hrdParameters (NULL) |
---|
2414 | , m_hrdOpSetIdx (NULL) |
---|
2415 | , m_cprmsPresentFlag (NULL) |
---|
2416 | { |
---|
2417 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
2418 | { |
---|
2419 | m_numReorderPics[i] = 0; |
---|
2420 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2421 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2422 | } |
---|
2423 | } |
---|
2424 | #endif //SVC_EXTENSION |
---|
2425 | |
---|
2426 | TComVPS::~TComVPS() |
---|
2427 | { |
---|
2428 | if( m_hrdParameters != NULL ) delete[] m_hrdParameters; |
---|
2429 | if( m_hrdOpSetIdx != NULL ) delete[] m_hrdOpSetIdx; |
---|
2430 | if( m_cprmsPresentFlag != NULL ) delete[] m_cprmsPresentFlag; |
---|
2431 | } |
---|
2432 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
2433 | Void TComVPS::deriveLayerIdListVariables() |
---|
2434 | { |
---|
2435 | // For layer 0 |
---|
2436 | m_numLayerInIdList[0] = 1; |
---|
2437 | m_layerSetLayerIdList[0][0] = 0; |
---|
2438 | |
---|
2439 | // For other layers |
---|
2440 | Int i, m, n; |
---|
2441 | for( i = 1; i < m_numLayerSets; i++ ) |
---|
2442 | { |
---|
2443 | n = 0; |
---|
2444 | for( m = 0; m <= m_maxLayerId; m++) |
---|
2445 | { |
---|
2446 | if( m_layerIdIncludedFlag[i][m] ) |
---|
2447 | { |
---|
2448 | m_layerSetLayerIdList[i][n++] = m; |
---|
2449 | } |
---|
2450 | } |
---|
2451 | m_numLayerInIdList[i] = n; |
---|
2452 | } |
---|
2453 | } |
---|
2454 | #endif |
---|
2455 | #if !RESOLUTION_BASED_DPB |
---|
2456 | #if VPS_DPB_SIZE_TABLE |
---|
2457 | Void TComVPS::deriveNumberOfSubDpbs() |
---|
2458 | { |
---|
2459 | // Derive number of sub-DPBs |
---|
2460 | #if CHANGE_NUMSUBDPB_IDX |
---|
2461 | // For layer set 0 |
---|
2462 | setNumSubDpbs(0, 1); |
---|
2463 | // For other layer sets |
---|
2464 | for( Int i = 1; i < getNumLayerSets(); i++) |
---|
2465 | { |
---|
2466 | setNumSubDpbs( i, getNumLayersInIdList( i ) ); |
---|
2467 | } |
---|
2468 | #else |
---|
2469 | // For output layer set 0 |
---|
2470 | setNumSubDpbs(0, 1); |
---|
2471 | // For other output layer sets |
---|
2472 | for( Int i = 1; i < getNumOutputLayerSets(); i++) |
---|
2473 | { |
---|
2474 | setNumSubDpbs( i, getNumLayersInIdList( getOutputLayerSetIdx(i)) ); |
---|
2475 | } |
---|
2476 | #endif |
---|
2477 | } |
---|
2478 | #endif |
---|
2479 | #endif |
---|
2480 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
2481 | Void TComVPS::setTilesNotInUseFlag(Bool x) |
---|
2482 | { |
---|
2483 | m_tilesNotInUseFlag = x; |
---|
2484 | if (m_tilesNotInUseFlag) |
---|
2485 | { |
---|
2486 | for (int i = 0; i < getMaxLayers(); i++) |
---|
2487 | { |
---|
2488 | m_tilesInUseFlag[i] = m_loopFilterNotAcrossTilesFlag[i] = m_tilesNotInUseFlag; |
---|
2489 | } |
---|
2490 | } |
---|
2491 | #if TILE_BOUNDARY_ALIGNED_FLAG |
---|
2492 | if (m_tilesNotInUseFlag) |
---|
2493 | { |
---|
2494 | for (int i = 1; i < getMaxLayers(); i++) |
---|
2495 | { |
---|
2496 | for(int j = 0; j < getNumDirectRefLayers(getLayerIdInNuh(i)); j++) |
---|
2497 | { |
---|
2498 | setTileBoundariesAlignedFlag(i, j, m_tilesNotInUseFlag); |
---|
2499 | } |
---|
2500 | } |
---|
2501 | } |
---|
2502 | #endif |
---|
2503 | } |
---|
2504 | #endif |
---|
2505 | #if VPS_VUI_WPP_NOT_IN_USE__FLAG |
---|
2506 | Void TComVPS::setWppNotInUseFlag(Bool x) |
---|
2507 | { |
---|
2508 | m_wppNotInUseFlag = x; |
---|
2509 | if (m_wppNotInUseFlag) |
---|
2510 | { |
---|
2511 | for (int i = 0; i < getMaxLayers(); i++) |
---|
2512 | { |
---|
2513 | m_wppInUseFlag[i] = m_wppNotInUseFlag; |
---|
2514 | } |
---|
2515 | } |
---|
2516 | } |
---|
2517 | #endif |
---|
2518 | #if O0092_0094_DEPENDENCY_CONSTRAINT |
---|
2519 | Void TComVPS::setRefLayersFlags(Int currLayerId) |
---|
2520 | { |
---|
2521 | for (Int i = 0; i < m_numDirectRefLayers[currLayerId]; i++) |
---|
2522 | { |
---|
2523 | UInt refLayerId = getRefLayerId(currLayerId, i); |
---|
2524 | m_recursiveRefLayerFlag[currLayerId][refLayerId] = true; |
---|
2525 | for (Int k = 0; k < MAX_NUM_LAYER_IDS; k++) |
---|
2526 | { |
---|
2527 | m_recursiveRefLayerFlag[currLayerId][k] = m_recursiveRefLayerFlag[currLayerId][k] | m_recursiveRefLayerFlag[refLayerId][k]; |
---|
2528 | } |
---|
2529 | } |
---|
2530 | } |
---|
2531 | |
---|
2532 | Void TComVPS::setNumRefLayers() |
---|
2533 | { |
---|
2534 | memset( m_numberRefLayers, 0, sizeof( m_numberRefLayers ) ); |
---|
2535 | |
---|
2536 | for (Int i = 0; i < m_uiMaxLayers; i++) |
---|
2537 | { |
---|
2538 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
2539 | setRefLayersFlags(iNuhLId); |
---|
2540 | for (UInt j = 0; j < MAX_NUM_LAYER_IDS; j++) |
---|
2541 | { |
---|
2542 | m_numberRefLayers[iNuhLId] += (m_recursiveRefLayerFlag[iNuhLId][j] == true ? 1 : 0); |
---|
2543 | } |
---|
2544 | } |
---|
2545 | } |
---|
2546 | #endif |
---|
2547 | |
---|
2548 | #if Q0078_ADD_LAYER_SETS |
---|
2549 | Void TComVPS::setPredictedLayerIds() |
---|
2550 | { |
---|
2551 | for (UInt i = 0; i < getMaxLayers() - 1; i++) |
---|
2552 | { |
---|
2553 | UInt iNuhLId = getLayerIdInNuh(i); |
---|
2554 | UInt predIdx = 0; |
---|
2555 | for (UInt j = iNuhLId + 1; j < 63; j++) |
---|
2556 | { |
---|
2557 | if (getRecursiveRefLayerFlag(j, iNuhLId)) |
---|
2558 | { |
---|
2559 | setPredictedLayerId(i, predIdx, j); |
---|
2560 | predIdx++; |
---|
2561 | } |
---|
2562 | } |
---|
2563 | setNumPredictedLayers(iNuhLId, predIdx); |
---|
2564 | } |
---|
2565 | } |
---|
2566 | |
---|
2567 | Void TComVPS::setTreePartitionLayerIdList() |
---|
2568 | { |
---|
2569 | Bool countedLayerIdxFlag[MAX_NUM_LAYER_IDS]; |
---|
2570 | |
---|
2571 | for (UInt i = 0; i <= getMaxLayers() - 1; i++) |
---|
2572 | { |
---|
2573 | countedLayerIdxFlag[i] = false; |
---|
2574 | } |
---|
2575 | |
---|
2576 | Int numIndependentLayers = 0; |
---|
2577 | |
---|
2578 | for (UInt i = 0; i <= getMaxLayers() - 1; i++) |
---|
2579 | { |
---|
2580 | UInt iNuhLId = getLayerIdInNuh(i); |
---|
2581 | if (getNumDirectRefLayers(iNuhLId) == 0) |
---|
2582 | { |
---|
2583 | setTreePartitionLayerId(numIndependentLayers, 0, iNuhLId); |
---|
2584 | setNumLayersInTreePartition(numIndependentLayers, 1); |
---|
2585 | for (UInt j = 0; j < getNumPredictedLayers(iNuhLId); j++) |
---|
2586 | { |
---|
2587 | if (!countedLayerIdxFlag[getLayerIdInVps(iNuhLId)]) |
---|
2588 | { |
---|
2589 | setTreePartitionLayerId(numIndependentLayers, getNumLayersInTreePartition(numIndependentLayers), getPredictedLayerId(iNuhLId, j)); |
---|
2590 | setNumLayersInTreePartition(numIndependentLayers, getNumLayersInTreePartition(numIndependentLayers) + 1); |
---|
2591 | countedLayerIdxFlag[getLayerIdInVps(getPredictedLayerId(iNuhLId, j))] = true; |
---|
2592 | } |
---|
2593 | } |
---|
2594 | numIndependentLayers++; |
---|
2595 | } |
---|
2596 | } |
---|
2597 | |
---|
2598 | setNumIndependentLayers(numIndependentLayers); |
---|
2599 | } |
---|
2600 | #endif |
---|
2601 | |
---|
2602 | #if VIEW_ID_RELATED_SIGNALING |
---|
2603 | Int TComVPS::getNumViews() |
---|
2604 | { |
---|
2605 | Int numViews = 1; |
---|
2606 | for( Int i = 0; i <= getMaxLayers() - 1; i++ ) |
---|
2607 | { |
---|
2608 | Int lId = getLayerIdInNuh( i ); |
---|
2609 | if ( i > 0 && ( getViewIndex( lId ) != getScalabilityId( i - 1, VIEW_ORDER_INDEX ) ) ) |
---|
2610 | { |
---|
2611 | numViews++; |
---|
2612 | } |
---|
2613 | } |
---|
2614 | |
---|
2615 | return numViews; |
---|
2616 | } |
---|
2617 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) |
---|
2618 | { |
---|
2619 | return getScalabilityMask( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
2620 | } |
---|
2621 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) |
---|
2622 | { |
---|
2623 | assert( scalType >= 0 && scalType <= MAX_VPS_NUM_SCALABILITY_TYPES ); |
---|
2624 | assert( scalType == MAX_VPS_NUM_SCALABILITY_TYPES || getScalabilityMask( scalType ) ); |
---|
2625 | Int scalIdx = 0; |
---|
2626 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
2627 | { |
---|
2628 | scalIdx += ( getScalabilityMask( curScalType ) ? 1 : 0 ); |
---|
2629 | |
---|
2630 | } |
---|
2631 | |
---|
2632 | return scalIdx; |
---|
2633 | } |
---|
2634 | #endif |
---|
2635 | #if VPS_DPB_SIZE_TABLE |
---|
2636 | Void TComVPS::determineSubDpbInfoFlags() |
---|
2637 | { |
---|
2638 | for(Int i = 1; i < getNumOutputLayerSets(); i++) |
---|
2639 | { |
---|
2640 | Int layerSetIdxForOutputLayerSet = getOutputLayerSetIdx( i ); |
---|
2641 | // For each output layer set, set the DPB size for each layer and the reorder/latency value the maximum for all layers |
---|
2642 | Bool checkFlagOuter = false; // Used to calculate sub_layer_flag_info_present_flag |
---|
2643 | Bool checkFlagInner[MAX_TLAYER]; // Used to calculate sub_layer_dpb_info_present_flag |
---|
2644 | |
---|
2645 | for(Int j = 0; j < getMaxTLayers(); j++) |
---|
2646 | { |
---|
2647 | // -------------------------------------------------------- |
---|
2648 | // To determine value of m_subLayerDpbInfoPresentFlag |
---|
2649 | // -------------------------------------------------------- |
---|
2650 | if( j == 0 ) // checkFlagInner[0] is always 1 |
---|
2651 | { |
---|
2652 | checkFlagInner[j] = true; // Always signal sub-layer DPB information for the first sub-layer |
---|
2653 | } |
---|
2654 | else |
---|
2655 | { |
---|
2656 | checkFlagInner[j] = false; // Initialize to be false. If the values of the current sub-layers matches with the earlier sub-layer, |
---|
2657 | // then will be continue to be false - i.e. the j-th sub-layer DPB info is not signaled |
---|
2658 | checkFlagInner[j] |= ( getMaxVpsNumReorderPics(i, j) != getMaxVpsNumReorderPics(i, j - 1) ); |
---|
2659 | #if CHANGE_NUMSUBDPB_IDX |
---|
2660 | for(Int subDpbIdx = 0; subDpbIdx < getNumSubDpbs(layerSetIdxForOutputLayerSet) && !checkFlagInner[j]; subDpbIdx++) // If checkFlagInner[j] is true, break and signal the values |
---|
2661 | #else |
---|
2662 | for(Int k = 0; k < getNumSubDpbs(i) && !checkFlagInner[j]; k++) // If checkFlagInner[j] is true, break and signal the values |
---|
2663 | #endif |
---|
2664 | { |
---|
2665 | checkFlagInner[j] |= ( getMaxVpsDecPicBufferingMinus1(i, subDpbIdx, j - 1) != getMaxVpsDecPicBufferingMinus1(i, subDpbIdx, j) ); |
---|
2666 | } |
---|
2667 | #if RESOLUTION_BASED_DPB |
---|
2668 | for(Int layerIdx = 0; layerIdx < this->getNumLayersInIdList(layerSetIdxForOutputLayerSet) && !checkFlagInner[j]; layerIdx++) // If checkFlagInner[j] is true, break and signal the values |
---|
2669 | { |
---|
2670 | checkFlagInner[j] |= ( getMaxVpsLayerDecPicBuffMinus1(i, layerIdx, j - 1) != getMaxVpsLayerDecPicBuffMinus1(i, layerIdx, j) ); |
---|
2671 | } |
---|
2672 | #endif |
---|
2673 | } |
---|
2674 | // If checkFlagInner[j] = true, then some value needs to be signalled for the j-th sub-layer |
---|
2675 | setSubLayerDpbInfoPresentFlag( i, j, checkFlagInner[j] ); |
---|
2676 | } |
---|
2677 | |
---|
2678 | // -------------------------------------------------------- |
---|
2679 | // To determine value of m_subLayerFlagInfoPresentFlag |
---|
2680 | // -------------------------------------------------------- |
---|
2681 | |
---|
2682 | for(Int j = 1; j < getMaxTLayers(); j++) // Check if DPB info of any of non-zero sub-layers is signaled. If so set flag to one |
---|
2683 | { |
---|
2684 | if( getSubLayerDpbInfoPresentFlag(i, j) ) |
---|
2685 | { |
---|
2686 | checkFlagOuter = true; |
---|
2687 | break; |
---|
2688 | } |
---|
2689 | } |
---|
2690 | setSubLayerFlagInfoPresentFlag( i, checkFlagOuter ); |
---|
2691 | } |
---|
2692 | } |
---|
2693 | #endif |
---|
2694 | #if RESOLUTION_BASED_DPB |
---|
2695 | Void TComVPS::assignSubDpbIndices() |
---|
2696 | { |
---|
2697 | RepFormat layerRepFormat [MAX_LAYERS]; |
---|
2698 | RepFormat subDpbRepFormat [MAX_LAYERS]; |
---|
2699 | |
---|
2700 | for(Int lsIdx = 0; lsIdx < this->getNumLayerSets(); lsIdx++) |
---|
2701 | { |
---|
2702 | for(Int j = 0; j < MAX_LAYERS; j++) |
---|
2703 | { |
---|
2704 | layerRepFormat [j].init(); |
---|
2705 | subDpbRepFormat[j].init(); |
---|
2706 | } |
---|
2707 | |
---|
2708 | // Assign resolution, bit-depth, colour format for each layer in the layer set |
---|
2709 | for(Int i = 0; i < this->getNumLayersInIdList( lsIdx ); i++) |
---|
2710 | { |
---|
2711 | Int layerIdxInVps = this->getLayerIdInVps( this->getLayerSetLayerIdList(lsIdx, i) ); |
---|
2712 | Int repFormatIdx = this->getVpsRepFormatIdx( layerIdxInVps ); |
---|
2713 | RepFormat* repFormat = this->getVpsRepFormat( repFormatIdx ); |
---|
2714 | |
---|
2715 | // Assign the rep_format() to the layer |
---|
2716 | layerRepFormat[i] = *repFormat; |
---|
2717 | } |
---|
2718 | |
---|
2719 | // ---------------------------------------- |
---|
2720 | // Sub-DPB assignment |
---|
2721 | // ---------------------------------------- |
---|
2722 | // For the base layer |
---|
2723 | m_subDpbAssigned[lsIdx][0] = 0; |
---|
2724 | subDpbRepFormat[0] = layerRepFormat[0]; |
---|
2725 | |
---|
2726 | // Sub-DPB counter |
---|
2727 | Int subDpbCtr = 1; |
---|
2728 | |
---|
2729 | for(Int i = 1; i < this->getNumLayersInIdList( lsIdx ); i++) |
---|
2730 | { |
---|
2731 | Bool newSubDpbFlag = true; |
---|
2732 | for(Int j = 0; (j < subDpbCtr) && (newSubDpbFlag); j++) |
---|
2733 | { |
---|
2734 | if( RepFormat::checkSameSubDpb( layerRepFormat[i], subDpbRepFormat[j] ) ) |
---|
2735 | { |
---|
2736 | // Belong to i-th sub-DPB |
---|
2737 | m_subDpbAssigned[lsIdx][i] = j; |
---|
2738 | newSubDpbFlag = false; |
---|
2739 | } |
---|
2740 | } |
---|
2741 | if( newSubDpbFlag ) |
---|
2742 | { |
---|
2743 | // New sub-DPB |
---|
2744 | subDpbRepFormat[subDpbCtr] = layerRepFormat[i]; |
---|
2745 | m_subDpbAssigned[lsIdx][i] = subDpbCtr; |
---|
2746 | subDpbCtr++; // Increment # subDpbs |
---|
2747 | } |
---|
2748 | } |
---|
2749 | m_numSubDpbs[lsIdx] = subDpbCtr; |
---|
2750 | } |
---|
2751 | } |
---|
2752 | Int TComVPS::findLayerIdxInLayerSet ( Int lsIdx, Int nuhLayerId ) |
---|
2753 | { |
---|
2754 | for(Int i = 0; i < this->getNumLayersInIdList(lsIdx); i++) |
---|
2755 | { |
---|
2756 | if( this->getLayerSetLayerIdList( lsIdx, i) == nuhLayerId ) |
---|
2757 | { |
---|
2758 | return i; |
---|
2759 | } |
---|
2760 | } |
---|
2761 | return -1; // Layer not found |
---|
2762 | } |
---|
2763 | #endif |
---|
2764 | #if O0164_MULTI_LAYER_HRD |
---|
2765 | Void TComVPS::setBspHrdParameters( UInt hrdIdx, UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
2766 | { |
---|
2767 | if( !getVpsVuiBspHrdPresentFlag() ) |
---|
2768 | { |
---|
2769 | return; |
---|
2770 | } |
---|
2771 | |
---|
2772 | TComHRD *hrd = getBspHrd(hrdIdx); |
---|
2773 | |
---|
2774 | Bool rateCnt = ( bitRate > 0 ); |
---|
2775 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
2776 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
2777 | |
---|
2778 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
2779 | |
---|
2780 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
2781 | { |
---|
2782 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
2783 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
2784 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
2785 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
2786 | } |
---|
2787 | else |
---|
2788 | { |
---|
2789 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
2790 | } |
---|
2791 | |
---|
2792 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
2793 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
2794 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
2795 | |
---|
2796 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
2797 | if( randomAccess ) |
---|
2798 | { |
---|
2799 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
2800 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
2801 | } |
---|
2802 | else |
---|
2803 | { |
---|
2804 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
2805 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
2806 | } |
---|
2807 | |
---|
2808 | /* |
---|
2809 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
2810 | */ |
---|
2811 | Int i, j; |
---|
2812 | UInt birateValue, cpbSizeValue; |
---|
2813 | UInt ducpbSizeValue; |
---|
2814 | UInt duBitRateValue = 0; |
---|
2815 | |
---|
2816 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
2817 | { |
---|
2818 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
2819 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
2820 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
2821 | hrd->setCpbCntMinus1( i, 0 ); |
---|
2822 | |
---|
2823 | birateValue = bitRate; |
---|
2824 | cpbSizeValue = bitRate; // 1 second |
---|
2825 | ducpbSizeValue = bitRate/numDU; |
---|
2826 | duBitRateValue = bitRate; |
---|
2827 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
2828 | { |
---|
2829 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
2830 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
2831 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
2832 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
2833 | |
---|
2834 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
2835 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
2836 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
2837 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
2838 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
2839 | } |
---|
2840 | } |
---|
2841 | } |
---|
2842 | #endif |
---|
2843 | #if RESOLUTION_BASED_DPB |
---|
2844 | // RepFormat Assignment operator |
---|
2845 | RepFormat& RepFormat::operator= (const RepFormat &other) |
---|
2846 | { |
---|
2847 | if( this != &other) |
---|
2848 | { |
---|
2849 | m_chromaAndBitDepthVpsPresentFlag = other.m_chromaAndBitDepthVpsPresentFlag; |
---|
2850 | m_chromaFormatVpsIdc = other.m_chromaFormatVpsIdc; |
---|
2851 | m_separateColourPlaneVpsFlag = other.m_separateColourPlaneVpsFlag; |
---|
2852 | m_picWidthVpsInLumaSamples = other.m_picWidthVpsInLumaSamples; |
---|
2853 | m_picHeightVpsInLumaSamples = other.m_picHeightVpsInLumaSamples; |
---|
2854 | m_bitDepthVpsLuma = other.m_bitDepthVpsLuma; |
---|
2855 | m_bitDepthVpsChroma = other.m_bitDepthVpsChroma; |
---|
2856 | } |
---|
2857 | return *this; |
---|
2858 | } |
---|
2859 | |
---|
2860 | // Check whether x and y share the same resolution, chroma format and bit-depth. |
---|
2861 | Bool RepFormat::checkSameSubDpb(const RepFormat &x, const RepFormat &y) |
---|
2862 | { |
---|
2863 | return ( (x.m_chromaFormatVpsIdc == y.m_chromaFormatVpsIdc) |
---|
2864 | && (x.m_picWidthVpsInLumaSamples == y.m_picWidthVpsInLumaSamples) |
---|
2865 | && (x.m_picHeightVpsInLumaSamples == y.m_picHeightVpsInLumaSamples) |
---|
2866 | && (x.m_bitDepthVpsLuma == y.m_bitDepthVpsLuma) |
---|
2867 | && (x.m_bitDepthVpsChroma == y.m_bitDepthVpsChroma) |
---|
2868 | ); |
---|
2869 | } |
---|
2870 | #endif |
---|
2871 | // ------------------------------------------------------------------------------------------------ |
---|
2872 | // Sequence parameter set (SPS) |
---|
2873 | // ------------------------------------------------------------------------------------------------ |
---|
2874 | |
---|
2875 | TComSPS::TComSPS() |
---|
2876 | : m_SPSId ( 0) |
---|
2877 | , m_VPSId ( 0) |
---|
2878 | , m_chromaFormatIdc (CHROMA_420) |
---|
2879 | , m_uiMaxTLayers ( 1) |
---|
2880 | // Structure |
---|
2881 | , m_picWidthInLumaSamples (352) |
---|
2882 | , m_picHeightInLumaSamples (288) |
---|
2883 | , m_log2MinCodingBlockSize ( 0) |
---|
2884 | , m_log2DiffMaxMinCodingBlockSize (0) |
---|
2885 | , m_uiMaxCUWidth ( 32) |
---|
2886 | , m_uiMaxCUHeight ( 32) |
---|
2887 | , m_uiMaxCUDepth ( 3) |
---|
2888 | , m_bLongTermRefsPresent (false) |
---|
2889 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
2890 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
2891 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
2892 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
2893 | // Tool list |
---|
2894 | , m_usePCM (false) |
---|
2895 | , m_pcmLog2MaxSize ( 5) |
---|
2896 | , m_uiPCMLog2MinSize ( 7) |
---|
2897 | , m_bitDepthY ( 8) |
---|
2898 | , m_bitDepthC ( 8) |
---|
2899 | , m_qpBDOffsetY ( 0) |
---|
2900 | , m_qpBDOffsetC ( 0) |
---|
2901 | , m_uiPCMBitDepthLuma ( 8) |
---|
2902 | , m_uiPCMBitDepthChroma ( 8) |
---|
2903 | , m_bPCMFilterDisableFlag (false) |
---|
2904 | , m_uiBitsForPOC ( 8) |
---|
2905 | , m_numLongTermRefPicSPS ( 0) |
---|
2906 | , m_uiMaxTrSize ( 32) |
---|
2907 | , m_bUseSAO (false) |
---|
2908 | , m_bTemporalIdNestingFlag (false) |
---|
2909 | , m_scalingListEnabledFlag (false) |
---|
2910 | , m_useStrongIntraSmoothing (false) |
---|
2911 | , m_vuiParametersPresentFlag (false) |
---|
2912 | , m_vuiParameters () |
---|
2913 | #if SVC_EXTENSION |
---|
2914 | , m_layerId ( 0 ) |
---|
2915 | , m_numScaledRefLayerOffsets ( 0 ) |
---|
2916 | #if REPN_FORMAT_IN_VPS |
---|
2917 | , m_updateRepFormatFlag (false) |
---|
2918 | #if O0096_REP_FORMAT_INDEX |
---|
2919 | , m_updateRepFormatIndex (0) |
---|
2920 | #endif |
---|
2921 | #endif |
---|
2922 | #if SCALINGLIST_INFERRING |
---|
2923 | , m_inferScalingListFlag ( false ) |
---|
2924 | , m_scalingListRefLayerId ( 0 ) |
---|
2925 | #endif |
---|
2926 | #endif //SVC_EXTENSION |
---|
2927 | { |
---|
2928 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
2929 | { |
---|
2930 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2931 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2932 | m_numReorderPics[i] = 0; |
---|
2933 | } |
---|
2934 | m_scalingList = new TComScalingList; |
---|
2935 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
2936 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
2937 | |
---|
2938 | #if P0312_VERT_PHASE_ADJ |
---|
2939 | ::memset(m_vertPhasePositionEnableFlag, 0, sizeof(m_vertPhasePositionEnableFlag)); |
---|
2940 | #endif |
---|
2941 | } |
---|
2942 | |
---|
2943 | TComSPS::~TComSPS() |
---|
2944 | { |
---|
2945 | #if SCALINGLIST_INFERRING |
---|
2946 | if( !m_inferScalingListFlag ) |
---|
2947 | #endif |
---|
2948 | delete m_scalingList; |
---|
2949 | m_RPSList.destroy(); |
---|
2950 | } |
---|
2951 | |
---|
2952 | Void TComSPS::createRPSList( Int numRPS ) |
---|
2953 | { |
---|
2954 | m_RPSList.destroy(); |
---|
2955 | m_RPSList.create(numRPS); |
---|
2956 | } |
---|
2957 | |
---|
2958 | Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
2959 | { |
---|
2960 | if( !getVuiParametersPresentFlag() ) |
---|
2961 | { |
---|
2962 | return; |
---|
2963 | } |
---|
2964 | |
---|
2965 | TComVUI *vui = getVuiParameters(); |
---|
2966 | TComHRD *hrd = vui->getHrdParameters(); |
---|
2967 | |
---|
2968 | TimingInfo *timingInfo = vui->getTimingInfo(); |
---|
2969 | #if SVC_EXTENSION |
---|
2970 | if( m_layerId > 0 ) |
---|
2971 | { |
---|
2972 | timingInfo->setTimingInfoPresentFlag( false ); |
---|
2973 | return; |
---|
2974 | } |
---|
2975 | #endif |
---|
2976 | |
---|
2977 | timingInfo->setTimingInfoPresentFlag( true ); |
---|
2978 | switch( frameRate ) |
---|
2979 | { |
---|
2980 | case 24: |
---|
2981 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2982 | break; |
---|
2983 | case 25: |
---|
2984 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2985 | break; |
---|
2986 | case 30: |
---|
2987 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2988 | break; |
---|
2989 | case 50: |
---|
2990 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2991 | break; |
---|
2992 | case 60: |
---|
2993 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
---|
2994 | break; |
---|
2995 | default: |
---|
2996 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
---|
2997 | break; |
---|
2998 | } |
---|
2999 | |
---|
3000 | Bool rateCnt = ( bitRate > 0 ); |
---|
3001 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
3002 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
3003 | |
---|
3004 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
3005 | |
---|
3006 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
3007 | { |
---|
3008 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
3009 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
3010 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
3011 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
3012 | } |
---|
3013 | else |
---|
3014 | { |
---|
3015 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
3016 | } |
---|
3017 | |
---|
3018 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
3019 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
3020 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
3021 | |
---|
3022 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
3023 | if( randomAccess ) |
---|
3024 | { |
---|
3025 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
3026 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
3027 | } |
---|
3028 | else |
---|
3029 | { |
---|
3030 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
3031 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
3032 | } |
---|
3033 | |
---|
3034 | /* |
---|
3035 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
3036 | */ |
---|
3037 | Int i, j; |
---|
3038 | UInt birateValue, cpbSizeValue; |
---|
3039 | UInt ducpbSizeValue; |
---|
3040 | UInt duBitRateValue = 0; |
---|
3041 | |
---|
3042 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
3043 | { |
---|
3044 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
3045 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
3046 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
3047 | hrd->setCpbCntMinus1( i, 0 ); |
---|
3048 | |
---|
3049 | birateValue = bitRate; |
---|
3050 | cpbSizeValue = bitRate; // 1 second |
---|
3051 | ducpbSizeValue = bitRate/numDU; |
---|
3052 | duBitRateValue = bitRate; |
---|
3053 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
3054 | { |
---|
3055 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
3056 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
3057 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
3058 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
3059 | |
---|
3060 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
3061 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
3062 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
3063 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
3064 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
3065 | } |
---|
3066 | } |
---|
3067 | } |
---|
3068 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
3069 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
3070 | |
---|
3071 | #if O0098_SCALED_REF_LAYER_ID |
---|
3072 | Window& TComSPS::getScaledRefLayerWindowForLayer(Int layerId) |
---|
3073 | { |
---|
3074 | static Window win; |
---|
3075 | |
---|
3076 | for (Int i = 0; i < m_numScaledRefLayerOffsets; i++) |
---|
3077 | { |
---|
3078 | if (layerId == m_scaledRefLayerId[i]) |
---|
3079 | { |
---|
3080 | return m_scaledRefLayerWindow[i]; |
---|
3081 | } |
---|
3082 | } |
---|
3083 | |
---|
3084 | win.resetWindow(); // scaled reference layer offsets are inferred to be zero when not present |
---|
3085 | return win; |
---|
3086 | } |
---|
3087 | #endif |
---|
3088 | |
---|
3089 | TComPPS::TComPPS() |
---|
3090 | : m_PPSId (0) |
---|
3091 | , m_SPSId (0) |
---|
3092 | , m_picInitQPMinus26 (0) |
---|
3093 | , m_useDQP (false) |
---|
3094 | , m_bConstrainedIntraPred (false) |
---|
3095 | , m_bSliceChromaQpFlag (false) |
---|
3096 | , m_pcSPS (NULL) |
---|
3097 | , m_uiMaxCuDQPDepth (0) |
---|
3098 | , m_uiMinCuDQPSize (0) |
---|
3099 | , m_chromaCbQpOffset (0) |
---|
3100 | , m_chromaCrQpOffset (0) |
---|
3101 | , m_numRefIdxL0DefaultActive (1) |
---|
3102 | , m_numRefIdxL1DefaultActive (1) |
---|
3103 | , m_TransquantBypassEnableFlag (false) |
---|
3104 | , m_useTransformSkip (false) |
---|
3105 | , m_dependentSliceSegmentsEnabledFlag (false) |
---|
3106 | , m_tilesEnabledFlag (false) |
---|
3107 | , m_entropyCodingSyncEnabledFlag (false) |
---|
3108 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
3109 | , m_uniformSpacingFlag (0) |
---|
3110 | , m_iNumColumnsMinus1 (0) |
---|
3111 | , m_puiColumnWidth (NULL) |
---|
3112 | , m_iNumRowsMinus1 (0) |
---|
3113 | , m_puiRowHeight (NULL) |
---|
3114 | , m_iNumSubstreams (1) |
---|
3115 | , m_signHideFlag(0) |
---|
3116 | , m_cabacInitPresentFlag (false) |
---|
3117 | , m_encCABACTableIdx (I_SLICE) |
---|
3118 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
3119 | , m_loopFilterAcrossSlicesEnabledFlag (false) |
---|
3120 | , m_listsModificationPresentFlag( 0) |
---|
3121 | , m_numExtraSliceHeaderBits(0) |
---|
3122 | #if SVC_EXTENSION |
---|
3123 | , m_extensionFlag(false) |
---|
3124 | #if SCALINGLIST_INFERRING |
---|
3125 | , m_layerId(0) |
---|
3126 | , m_inferScalingListFlag ( false ) |
---|
3127 | , m_scalingListRefLayerId ( 0 ) |
---|
3128 | #endif |
---|
3129 | #if POC_RESET_IDC |
---|
3130 | , m_pocResetInfoPresentFlag (false) |
---|
3131 | #endif |
---|
3132 | #if Q0048_CGS_3D_ASYMLUT |
---|
3133 | , m_nCGSFlag(0) |
---|
3134 | , m_nCGSOutputBitDepthY(0) |
---|
3135 | , m_nCGSOutputBitDepthC(0) |
---|
3136 | #endif |
---|
3137 | #endif //SVC_EXTENSION |
---|
3138 | { |
---|
3139 | m_scalingList = new TComScalingList; |
---|
3140 | } |
---|
3141 | |
---|
3142 | TComPPS::~TComPPS() |
---|
3143 | { |
---|
3144 | if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
3145 | { |
---|
3146 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
3147 | m_puiColumnWidth = NULL; |
---|
3148 | } |
---|
3149 | if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
3150 | { |
---|
3151 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
3152 | m_puiRowHeight = NULL; |
---|
3153 | } |
---|
3154 | |
---|
3155 | #if SCALINGLIST_INFERRING |
---|
3156 | if( !m_inferScalingListFlag ) |
---|
3157 | #endif |
---|
3158 | delete m_scalingList; |
---|
3159 | } |
---|
3160 | |
---|
3161 | TComReferencePictureSet::TComReferencePictureSet() |
---|
3162 | : m_numberOfPictures (0) |
---|
3163 | , m_numberOfNegativePictures (0) |
---|
3164 | , m_numberOfPositivePictures (0) |
---|
3165 | , m_numberOfLongtermPictures (0) |
---|
3166 | , m_interRPSPrediction (0) |
---|
3167 | , m_deltaRIdxMinus1 (0) |
---|
3168 | , m_deltaRPS (0) |
---|
3169 | , m_numRefIdc (0) |
---|
3170 | { |
---|
3171 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
3172 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
3173 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
3174 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
3175 | } |
---|
3176 | |
---|
3177 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
3178 | { |
---|
3179 | } |
---|
3180 | |
---|
3181 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
3182 | { |
---|
3183 | m_used[bufferNum] = used; |
---|
3184 | } |
---|
3185 | |
---|
3186 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
3187 | { |
---|
3188 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
3189 | } |
---|
3190 | |
---|
3191 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
3192 | { |
---|
3193 | m_numberOfPictures = numberOfPictures; |
---|
3194 | } |
---|
3195 | |
---|
3196 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
3197 | { |
---|
3198 | return m_used[bufferNum]; |
---|
3199 | } |
---|
3200 | |
---|
3201 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
3202 | { |
---|
3203 | return m_deltaPOC[bufferNum]; |
---|
3204 | } |
---|
3205 | |
---|
3206 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
3207 | { |
---|
3208 | return m_numberOfPictures; |
---|
3209 | } |
---|
3210 | |
---|
3211 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
3212 | { |
---|
3213 | return m_POC[bufferNum]; |
---|
3214 | } |
---|
3215 | |
---|
3216 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
3217 | { |
---|
3218 | m_POC[bufferNum] = POC; |
---|
3219 | } |
---|
3220 | |
---|
3221 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) |
---|
3222 | { |
---|
3223 | return m_bCheckLTMSB[bufferNum]; |
---|
3224 | } |
---|
3225 | |
---|
3226 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
3227 | { |
---|
3228 | m_bCheckLTMSB[bufferNum] = b; |
---|
3229 | } |
---|
3230 | |
---|
3231 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
3232 | * \param uiBufferNum |
---|
3233 | * \param iRefIdc |
---|
3234 | * \returns Void |
---|
3235 | */ |
---|
3236 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
3237 | { |
---|
3238 | m_refIdc[bufferNum] = refIdc; |
---|
3239 | } |
---|
3240 | |
---|
3241 | /** get the reference idc value at uiBufferNum |
---|
3242 | * \param uiBufferNum |
---|
3243 | * \returns Int |
---|
3244 | */ |
---|
3245 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
3246 | { |
---|
3247 | return m_refIdc[bufferNum]; |
---|
3248 | } |
---|
3249 | |
---|
3250 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
3251 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
3252 | * +ve values are in increasing order. |
---|
3253 | * \returns Void |
---|
3254 | */ |
---|
3255 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
3256 | { |
---|
3257 | // sort in increasing order (smallest first) |
---|
3258 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
3259 | { |
---|
3260 | Int deltaPOC = getDeltaPOC(j); |
---|
3261 | Bool used = getUsed(j); |
---|
3262 | for (Int k=j-1; k >= 0; k--) |
---|
3263 | { |
---|
3264 | Int temp = getDeltaPOC(k); |
---|
3265 | if (deltaPOC < temp) |
---|
3266 | { |
---|
3267 | setDeltaPOC(k+1, temp); |
---|
3268 | setUsed(k+1, getUsed(k)); |
---|
3269 | setDeltaPOC(k, deltaPOC); |
---|
3270 | setUsed(k, used); |
---|
3271 | } |
---|
3272 | } |
---|
3273 | } |
---|
3274 | // flip the negative values to largest first |
---|
3275 | Int numNegPics = getNumberOfNegativePictures(); |
---|
3276 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
3277 | { |
---|
3278 | Int deltaPOC = getDeltaPOC(j); |
---|
3279 | Bool used = getUsed(j); |
---|
3280 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
3281 | setUsed(j, getUsed(k)); |
---|
3282 | setDeltaPOC(k, deltaPOC); |
---|
3283 | setUsed(k, used); |
---|
3284 | } |
---|
3285 | } |
---|
3286 | |
---|
3287 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
3288 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
3289 | * \returns Void |
---|
3290 | */ |
---|
3291 | Void TComReferencePictureSet::printDeltaPOC() |
---|
3292 | { |
---|
3293 | printf("DeltaPOC = { "); |
---|
3294 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
3295 | { |
---|
3296 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
3297 | } |
---|
3298 | if (getInterRPSPrediction()) |
---|
3299 | { |
---|
3300 | printf("}, RefIdc = { "); |
---|
3301 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
3302 | { |
---|
3303 | printf("%d ", getRefIdc(j)); |
---|
3304 | } |
---|
3305 | } |
---|
3306 | printf("}\n"); |
---|
3307 | } |
---|
3308 | |
---|
3309 | TComRPSList::TComRPSList() |
---|
3310 | :m_referencePictureSets (NULL) |
---|
3311 | { |
---|
3312 | } |
---|
3313 | |
---|
3314 | TComRPSList::~TComRPSList() |
---|
3315 | { |
---|
3316 | } |
---|
3317 | |
---|
3318 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
3319 | { |
---|
3320 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
3321 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
3322 | } |
---|
3323 | |
---|
3324 | Void TComRPSList::destroy() |
---|
3325 | { |
---|
3326 | if (m_referencePictureSets) |
---|
3327 | { |
---|
3328 | delete [] m_referencePictureSets; |
---|
3329 | } |
---|
3330 | m_numberOfReferencePictureSets = 0; |
---|
3331 | m_referencePictureSets = NULL; |
---|
3332 | } |
---|
3333 | |
---|
3334 | |
---|
3335 | |
---|
3336 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
3337 | { |
---|
3338 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
3339 | } |
---|
3340 | |
---|
3341 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
3342 | { |
---|
3343 | return m_numberOfReferencePictureSets; |
---|
3344 | } |
---|
3345 | |
---|
3346 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
3347 | { |
---|
3348 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
3349 | } |
---|
3350 | |
---|
3351 | TComRefPicListModification::TComRefPicListModification() |
---|
3352 | : m_bRefPicListModificationFlagL0 (false) |
---|
3353 | , m_bRefPicListModificationFlagL1 (false) |
---|
3354 | { |
---|
3355 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
3356 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
3357 | } |
---|
3358 | |
---|
3359 | TComRefPicListModification::~TComRefPicListModification() |
---|
3360 | { |
---|
3361 | } |
---|
3362 | |
---|
3363 | TComScalingList::TComScalingList() |
---|
3364 | { |
---|
3365 | init(); |
---|
3366 | } |
---|
3367 | |
---|
3368 | TComScalingList::~TComScalingList() |
---|
3369 | { |
---|
3370 | destroy(); |
---|
3371 | } |
---|
3372 | |
---|
3373 | /** set default quantization matrix to array |
---|
3374 | */ |
---|
3375 | Void TComSlice::setDefaultScalingList() |
---|
3376 | { |
---|
3377 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3378 | { |
---|
3379 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
3380 | { |
---|
3381 | getScalingList()->processDefaultMatrix(sizeId, listId); |
---|
3382 | } |
---|
3383 | } |
---|
3384 | } |
---|
3385 | /** check if use default quantization matrix |
---|
3386 | * \returns true if use default quantization matrix in all size |
---|
3387 | */ |
---|
3388 | Bool TComSlice::checkDefaultScalingList() |
---|
3389 | { |
---|
3390 | UInt defaultCounter=0; |
---|
3391 | |
---|
3392 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3393 | { |
---|
3394 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
3395 | { |
---|
3396 | 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 |
---|
3397 | && ((sizeId < SCALING_LIST_16x16) || (getScalingList()->getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
3398 | { |
---|
3399 | defaultCounter++; |
---|
3400 | } |
---|
3401 | } |
---|
3402 | } |
---|
3403 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32 |
---|
3404 | } |
---|
3405 | |
---|
3406 | /** get scaling matrix from RefMatrixID |
---|
3407 | * \param sizeId size index |
---|
3408 | * \param Index of input matrix |
---|
3409 | * \param Index of reference matrix |
---|
3410 | */ |
---|
3411 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
3412 | { |
---|
3413 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
3414 | } |
---|
3415 | |
---|
3416 | /** parse syntax infomation |
---|
3417 | * \param pchFile syntax infomation |
---|
3418 | * \returns false if successful |
---|
3419 | */ |
---|
3420 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
3421 | { |
---|
3422 | FILE *fp; |
---|
3423 | Char line[1024]; |
---|
3424 | UInt sizeIdc,listIdc; |
---|
3425 | UInt i,size = 0; |
---|
3426 | Int *src=0,data; |
---|
3427 | Char *ret; |
---|
3428 | UInt retval; |
---|
3429 | |
---|
3430 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
3431 | { |
---|
3432 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
3433 | return true; |
---|
3434 | } |
---|
3435 | |
---|
3436 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
3437 | { |
---|
3438 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
3439 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
3440 | { |
---|
3441 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
3442 | |
---|
3443 | fseek(fp,0,0); |
---|
3444 | do |
---|
3445 | { |
---|
3446 | ret = fgets(line, 1024, fp); |
---|
3447 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
3448 | { |
---|
3449 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
3450 | return true; |
---|
3451 | } |
---|
3452 | } |
---|
3453 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
3454 | for (i=0; i<size; i++) |
---|
3455 | { |
---|
3456 | retval = fscanf(fp, "%d,", &data); |
---|
3457 | if (retval!=1) |
---|
3458 | { |
---|
3459 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
3460 | return true; |
---|
3461 | } |
---|
3462 | src[i] = data; |
---|
3463 | } |
---|
3464 | //set DC value for default matrix check |
---|
3465 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
3466 | |
---|
3467 | if(sizeIdc > SCALING_LIST_8x8) |
---|
3468 | { |
---|
3469 | fseek(fp,0,0); |
---|
3470 | do |
---|
3471 | { |
---|
3472 | ret = fgets(line, 1024, fp); |
---|
3473 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
3474 | { |
---|
3475 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
3476 | return true; |
---|
3477 | } |
---|
3478 | } |
---|
3479 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
3480 | retval = fscanf(fp, "%d,", &data); |
---|
3481 | if (retval!=1) |
---|
3482 | { |
---|
3483 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
3484 | return true; |
---|
3485 | } |
---|
3486 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
3487 | setScalingListDC(sizeIdc,listIdc,data); |
---|
3488 | } |
---|
3489 | } |
---|
3490 | } |
---|
3491 | fclose(fp); |
---|
3492 | return false; |
---|
3493 | } |
---|
3494 | |
---|
3495 | /** initialization process of quantization matrix array |
---|
3496 | */ |
---|
3497 | Void TComScalingList::init() |
---|
3498 | { |
---|
3499 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3500 | { |
---|
3501 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
3502 | { |
---|
3503 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
3504 | } |
---|
3505 | } |
---|
3506 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
3507 | } |
---|
3508 | |
---|
3509 | /** destroy quantization matrix array |
---|
3510 | */ |
---|
3511 | Void TComScalingList::destroy() |
---|
3512 | { |
---|
3513 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3514 | { |
---|
3515 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
3516 | { |
---|
3517 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
3518 | } |
---|
3519 | } |
---|
3520 | } |
---|
3521 | |
---|
3522 | /** get default address of quantization matrix |
---|
3523 | * \param sizeId size index |
---|
3524 | * \param listId list index |
---|
3525 | * \returns pointer of quantization matrix |
---|
3526 | */ |
---|
3527 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
3528 | { |
---|
3529 | Int *src = 0; |
---|
3530 | switch(sizeId) |
---|
3531 | { |
---|
3532 | case SCALING_LIST_4x4: |
---|
3533 | src = g_quantTSDefault4x4; |
---|
3534 | break; |
---|
3535 | case SCALING_LIST_8x8: |
---|
3536 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
3537 | break; |
---|
3538 | case SCALING_LIST_16x16: |
---|
3539 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
3540 | break; |
---|
3541 | case SCALING_LIST_32x32: |
---|
3542 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
3543 | break; |
---|
3544 | default: |
---|
3545 | assert(0); |
---|
3546 | src = NULL; |
---|
3547 | break; |
---|
3548 | } |
---|
3549 | return src; |
---|
3550 | } |
---|
3551 | |
---|
3552 | /** process of default matrix |
---|
3553 | * \param sizeId size index |
---|
3554 | * \param Index of input matrix |
---|
3555 | */ |
---|
3556 | Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId) |
---|
3557 | { |
---|
3558 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
3559 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
3560 | } |
---|
3561 | |
---|
3562 | /** check DC value of matrix for default matrix signaling |
---|
3563 | */ |
---|
3564 | Void TComScalingList::checkDcOfMatrix() |
---|
3565 | { |
---|
3566 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3567 | { |
---|
3568 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
3569 | { |
---|
3570 | //check default matrix? |
---|
3571 | if(getScalingListDC(sizeId,listId) == 0) |
---|
3572 | { |
---|
3573 | processDefaultMatrix(sizeId, listId); |
---|
3574 | } |
---|
3575 | } |
---|
3576 | } |
---|
3577 | } |
---|
3578 | |
---|
3579 | ParameterSetManager::ParameterSetManager() |
---|
3580 | #if SVC_EXTENSION |
---|
3581 | : m_spsMap(MAX_NUM_SPS) |
---|
3582 | , m_ppsMap(MAX_NUM_PPS) |
---|
3583 | , m_activeSPSId(-1) |
---|
3584 | , m_activePPSId(-1) |
---|
3585 | #else |
---|
3586 | : m_vpsMap(MAX_NUM_VPS) |
---|
3587 | , m_spsMap(MAX_NUM_SPS) |
---|
3588 | , m_ppsMap(MAX_NUM_PPS) |
---|
3589 | , m_activeVPSId(-1) |
---|
3590 | , m_activeSPSId(-1) |
---|
3591 | , m_activePPSId(-1) |
---|
3592 | #endif |
---|
3593 | { |
---|
3594 | } |
---|
3595 | |
---|
3596 | |
---|
3597 | ParameterSetManager::~ParameterSetManager() |
---|
3598 | { |
---|
3599 | } |
---|
3600 | |
---|
3601 | //! activate a SPS from a active parameter sets SEI message |
---|
3602 | //! \returns true, if activation is successful |
---|
3603 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
3604 | { |
---|
3605 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
3606 | if (sps) |
---|
3607 | { |
---|
3608 | Int vpsId = sps->getVPSId(); |
---|
3609 | if (m_vpsMap.getPS(vpsId)) |
---|
3610 | { |
---|
3611 | m_activeVPSId = vpsId; |
---|
3612 | m_activeSPSId = spsId; |
---|
3613 | return true; |
---|
3614 | } |
---|
3615 | else |
---|
3616 | { |
---|
3617 | printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
3618 | } |
---|
3619 | } |
---|
3620 | else |
---|
3621 | { |
---|
3622 | printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
3623 | } |
---|
3624 | return false; |
---|
3625 | } |
---|
3626 | |
---|
3627 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
3628 | //! \returns true, if activation is successful |
---|
3629 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
3630 | { |
---|
3631 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
3632 | if (pps) |
---|
3633 | { |
---|
3634 | Int spsId = pps->getSPSId(); |
---|
3635 | if (!isIRAP && (spsId != m_activeSPSId)) |
---|
3636 | { |
---|
3637 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IRAP."); |
---|
3638 | return false; |
---|
3639 | } |
---|
3640 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
3641 | if (sps) |
---|
3642 | { |
---|
3643 | Int vpsId = sps->getVPSId(); |
---|
3644 | if (!isIRAP && (vpsId != m_activeVPSId)) |
---|
3645 | { |
---|
3646 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IRAP."); |
---|
3647 | return false; |
---|
3648 | } |
---|
3649 | if (m_vpsMap.getPS(vpsId)) |
---|
3650 | { |
---|
3651 | m_activePPSId = ppsId; |
---|
3652 | m_activeVPSId = vpsId; |
---|
3653 | m_activeSPSId = spsId; |
---|
3654 | |
---|
3655 | return true; |
---|
3656 | } |
---|
3657 | else |
---|
3658 | { |
---|
3659 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
3660 | } |
---|
3661 | } |
---|
3662 | else |
---|
3663 | { |
---|
3664 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
3665 | } |
---|
3666 | } |
---|
3667 | else |
---|
3668 | { |
---|
3669 | printf("Warning: tried to activate non-existing PPS."); |
---|
3670 | } |
---|
3671 | return false; |
---|
3672 | } |
---|
3673 | |
---|
3674 | ProfileTierLevel::ProfileTierLevel() |
---|
3675 | : m_profileSpace (0) |
---|
3676 | , m_tierFlag (false) |
---|
3677 | , m_profileIdc (0) |
---|
3678 | , m_levelIdc (0) |
---|
3679 | , m_progressiveSourceFlag (false) |
---|
3680 | , m_interlacedSourceFlag (false) |
---|
3681 | , m_nonPackedConstraintFlag(false) |
---|
3682 | , m_frameOnlyConstraintFlag(false) |
---|
3683 | { |
---|
3684 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
3685 | } |
---|
3686 | #if VPS_EXTN_PROFILE_INFO |
---|
3687 | Void ProfileTierLevel::copyProfileInfo(ProfileTierLevel *ptl) |
---|
3688 | { |
---|
3689 | this->setProfileSpace ( ptl->getProfileSpace() ); |
---|
3690 | this->setTierFlag ( ptl->getTierFlag() ); |
---|
3691 | this->setProfileIdc ( ptl->getProfileIdc() ); |
---|
3692 | for(Int j = 0; j < 32; j++) |
---|
3693 | { |
---|
3694 | this->setProfileCompatibilityFlag(j, ptl->getProfileCompatibilityFlag(j)); |
---|
3695 | } |
---|
3696 | this->setProgressiveSourceFlag ( ptl->getProgressiveSourceFlag() ); |
---|
3697 | this->setInterlacedSourceFlag ( ptl->getInterlacedSourceFlag() ); |
---|
3698 | this->setNonPackedConstraintFlag( ptl->getNonPackedConstraintFlag()); |
---|
3699 | this->setFrameOnlyConstraintFlag( ptl->getFrameOnlyConstraintFlag()); |
---|
3700 | } |
---|
3701 | #endif |
---|
3702 | |
---|
3703 | TComPTL::TComPTL() |
---|
3704 | { |
---|
3705 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
3706 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
3707 | } |
---|
3708 | #if VPS_EXTN_PROFILE_INFO |
---|
3709 | Void TComPTL::copyProfileInfo(TComPTL *ptl) |
---|
3710 | { |
---|
3711 | // Copy all information related to general profile |
---|
3712 | this->getGeneralPTL()->copyProfileInfo(ptl->getGeneralPTL()); |
---|
3713 | } |
---|
3714 | #endif |
---|
3715 | |
---|
3716 | #if SVC_EXTENSION |
---|
3717 | #if AVC_SYNTAX |
---|
3718 | Void TComSlice::initBaseLayerRPL( TComSlice *pcSlice ) |
---|
3719 | { |
---|
3720 | // Assumed that RPL of the base layer is same to the EL, otherwise this information should be also dumped and read from the metadata file |
---|
3721 | setPOC( pcSlice->getPOC() ); |
---|
3722 | if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) |
---|
3723 | { |
---|
3724 | setSliceType( I_SLICE ); |
---|
3725 | } |
---|
3726 | else |
---|
3727 | { |
---|
3728 | setSliceType( pcSlice->getSliceType() ); |
---|
3729 | } |
---|
3730 | |
---|
3731 | if( this->isIntra() ) |
---|
3732 | { |
---|
3733 | return; |
---|
3734 | } |
---|
3735 | |
---|
3736 | //initialize reference POC of BL |
---|
3737 | for( Int iRefPicList = 0; iRefPicList < 2; iRefPicList++ ) |
---|
3738 | { |
---|
3739 | RefPicList eRefPicList = RefPicList( iRefPicList ); |
---|
3740 | |
---|
3741 | assert( pcSlice->getNumRefIdx( eRefPicList) >= 0 ); |
---|
3742 | setNumRefIdx( eRefPicList, pcSlice->getNumRefIdx( eRefPicList ) - 1 ); |
---|
3743 | assert( getNumRefIdx( eRefPicList) <= MAX_NUM_REF); |
---|
3744 | |
---|
3745 | for(Int refIdx = 0; refIdx < getNumRefIdx( eRefPicList ); refIdx++) |
---|
3746 | { |
---|
3747 | setRefPOC( pcSlice->getRefPic( eRefPicList, refIdx )->getPOC(), eRefPicList, refIdx ); |
---|
3748 | setRefPic( pcSlice->getRefPic( eRefPicList, refIdx ), eRefPicList, refIdx ); |
---|
3749 | /* |
---|
3750 | // should be set if the base layer has its own instance of the reference picture lists, currently EL RPL is reused. |
---|
3751 | getRefPic( eRefPicList, refIdx )->setLayerId( 0 ); |
---|
3752 | getRefPic( eRefPicList, refIdx )->setIsLongTerm( pcSlice->getRefPic( eRefPicList, refIdx )->getIsLongTerm() ); |
---|
3753 | */ |
---|
3754 | |
---|
3755 | } |
---|
3756 | } |
---|
3757 | return; |
---|
3758 | } |
---|
3759 | #endif |
---|
3760 | |
---|
3761 | Bool TComSlice::setBaseColPic( TComList<TComPic*>& rcListPic, UInt refLayerIdc ) |
---|
3762 | { |
---|
3763 | if(m_layerId == 0) |
---|
3764 | { |
---|
3765 | memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) ); |
---|
3766 | return false; |
---|
3767 | } |
---|
3768 | #if POC_RESET_FLAG |
---|
3769 | TComPic* pic = xGetRefPic( rcListPic, m_bPocResetFlag ? 0 : m_iPOC ); |
---|
3770 | |
---|
3771 | if( pic ) |
---|
3772 | { |
---|
3773 | setBaseColPic(refLayerIdc, pic ); |
---|
3774 | } |
---|
3775 | else |
---|
3776 | { |
---|
3777 | return false; |
---|
3778 | } |
---|
3779 | |
---|
3780 | return true; |
---|
3781 | #else |
---|
3782 | setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC())); |
---|
3783 | #endif |
---|
3784 | } |
---|
3785 | |
---|
3786 | #if MFM_ENCCONSTRAINT |
---|
3787 | TComPic* TComSlice::getBaseColPic( TComList<TComPic*>& rcListPic ) |
---|
3788 | { |
---|
3789 | #if POC_RESET_FLAG |
---|
3790 | return xGetRefPic( rcListPic, m_bPocResetFlag ? 0 : m_iPOC ); |
---|
3791 | #else |
---|
3792 | return xGetRefPic( rcListPic, m_iPOC ); |
---|
3793 | #endif |
---|
3794 | } |
---|
3795 | #endif |
---|
3796 | |
---|
3797 | #if REF_IDX_MFM |
---|
3798 | Void TComSlice::setRefPOCListILP( TComPic** ilpPic, TComPic** pcRefPicRL ) |
---|
3799 | { |
---|
3800 | for( UInt i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
3801 | { |
---|
3802 | UInt refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
3803 | |
---|
3804 | TComPic* pcRefPicBL = pcRefPicRL[refLayerIdc]; |
---|
3805 | |
---|
3806 | //set reference picture POC of each ILP reference |
---|
3807 | Int thePoc = ilpPic[refLayerIdc]->getPOC(); |
---|
3808 | assert(thePoc == pcRefPicBL->getPOC()); |
---|
3809 | |
---|
3810 | ilpPic[refLayerIdc]->getSlice(0)->setBaseColPic( refLayerIdc, pcRefPicBL ); |
---|
3811 | |
---|
3812 | //copy layer id from the reference layer |
---|
3813 | ilpPic[refLayerIdc]->setLayerId( pcRefPicBL->getLayerId() ); |
---|
3814 | |
---|
3815 | //copy slice type from the reference layer |
---|
3816 | ilpPic[refLayerIdc]->getSlice(0)->setSliceType( pcRefPicBL->getSlice(0)->getSliceType() ); |
---|
3817 | |
---|
3818 | //copy "used for reference" |
---|
3819 | ilpPic[refLayerIdc]->getSlice(0)->setReferenced( pcRefPicBL->getSlice(0)->isReferenced() ); |
---|
3820 | |
---|
3821 | for( Int refList = 0; refList < 2; refList++ ) |
---|
3822 | { |
---|
3823 | RefPicList refPicList = RefPicList( refList ); |
---|
3824 | |
---|
3825 | //set reference POC of ILP |
---|
3826 | ilpPic[refLayerIdc]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList)); |
---|
3827 | assert(ilpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) >= 0); |
---|
3828 | assert(ilpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF); |
---|
3829 | |
---|
3830 | //initialize reference POC of ILP |
---|
3831 | for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++) |
---|
3832 | { |
---|
3833 | ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx); |
---|
3834 | ilpPic[refLayerIdc]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx); |
---|
3835 | } |
---|
3836 | |
---|
3837 | for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++) |
---|
3838 | { |
---|
3839 | ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(0, refPicList, refIdx); |
---|
3840 | ilpPic[refLayerIdc]->getSlice(0)->setRefPic(NULL, refPicList, refIdx); |
---|
3841 | } |
---|
3842 | |
---|
3843 | //copy reference pictures' marking from the reference layer |
---|
3844 | for(Int j = 0; j < MAX_NUM_REF + 1; j++) |
---|
3845 | { |
---|
3846 | ilpPic[refLayerIdc]->getSlice(0)->setIsUsedAsLongTerm(refList, j, pcRefPicBL->getSlice(0)->getIsUsedAsLongTerm(refList, j)); |
---|
3847 | } |
---|
3848 | } |
---|
3849 | } |
---|
3850 | return; |
---|
3851 | } |
---|
3852 | #endif |
---|
3853 | |
---|
3854 | Void TComSlice::setILRPic(TComPic **pcIlpPic) |
---|
3855 | { |
---|
3856 | for( Int i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
3857 | { |
---|
3858 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
3859 | |
---|
3860 | if( pcIlpPic[refLayerIdc] ) |
---|
3861 | { |
---|
3862 | pcIlpPic[refLayerIdc]->copyUpsampledPictureYuv( m_pcPic->getFullPelBaseRec( refLayerIdc ), pcIlpPic[refLayerIdc]->getPicYuvRec() ); |
---|
3863 | pcIlpPic[refLayerIdc]->getSlice(0)->setPOC( m_iPOC ); |
---|
3864 | pcIlpPic[refLayerIdc]->setLayerId( m_pcBaseColPic[refLayerIdc]->getLayerId() ); //set reference layerId |
---|
3865 | pcIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension( false ); |
---|
3866 | pcIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder(); |
---|
3867 | for (Int j=0; j<pcIlpPic[refLayerIdc]->getPicSym()->getNumberOfCUsInFrame(); j++) // set reference CU layerId |
---|
3868 | { |
---|
3869 | pcIlpPic[refLayerIdc]->getPicSym()->getCU(j)->setLayerId( pcIlpPic[refLayerIdc]->getLayerId() ); |
---|
3870 | } |
---|
3871 | } |
---|
3872 | } |
---|
3873 | } |
---|
3874 | |
---|
3875 | #endif //SVC_EXTENSION |
---|
3876 | |
---|
3877 | //! \} |
---|