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-2013, 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 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
68 | , m_bRefPicListModificationFlagLC ( false ) |
---|
69 | , m_bRefPicListCombinationFlag ( false ) |
---|
70 | #endif |
---|
71 | , m_bCheckLDC ( false ) |
---|
72 | , m_iSliceQpDelta ( 0 ) |
---|
73 | , m_iSliceQpDeltaCb ( 0 ) |
---|
74 | , m_iSliceQpDeltaCr ( 0 ) |
---|
75 | , m_iDepth ( 0 ) |
---|
76 | , m_bRefenced ( false ) |
---|
77 | , m_pcSPS ( NULL ) |
---|
78 | , m_pcPPS ( NULL ) |
---|
79 | , m_pcPic ( NULL ) |
---|
80 | , m_colFromL0Flag ( 1 ) |
---|
81 | , m_colRefIdx ( 0 ) |
---|
82 | #if SAO_CHROMA_LAMBDA |
---|
83 | , m_dLambdaLuma( 0.0 ) |
---|
84 | , m_dLambdaChroma( 0.0 ) |
---|
85 | #else |
---|
86 | , m_dLambda ( 0.0 ) |
---|
87 | #endif |
---|
88 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
89 | , m_bNoBackPredFlag ( false ) |
---|
90 | #endif |
---|
91 | , m_uiTLayer ( 0 ) |
---|
92 | #if SVC_EXTENSION |
---|
93 | , m_layerId ( 0 ) |
---|
94 | , m_pcBaseColPic ( NULL ) |
---|
95 | #endif |
---|
96 | , m_bTLayerSwitchingFlag ( false ) |
---|
97 | , m_sliceMode ( 0 ) |
---|
98 | , m_sliceArgument ( 0 ) |
---|
99 | , m_sliceCurStartCUAddr ( 0 ) |
---|
100 | , m_sliceCurEndCUAddr ( 0 ) |
---|
101 | , m_sliceIdx ( 0 ) |
---|
102 | , m_sliceSegmentMode ( 0 ) |
---|
103 | , m_sliceSegmentArgument ( 0 ) |
---|
104 | , m_sliceSegmentCurStartCUAddr ( 0 ) |
---|
105 | , m_sliceSegmentCurEndCUAddr ( 0 ) |
---|
106 | , m_nextSlice ( false ) |
---|
107 | , m_nextSliceSegment ( false ) |
---|
108 | , m_sliceBits ( 0 ) |
---|
109 | , m_sliceSegmentBits ( 0 ) |
---|
110 | , m_bFinalized ( false ) |
---|
111 | , m_uiTileOffstForMultES ( 0 ) |
---|
112 | , m_puiSubstreamSizes ( NULL ) |
---|
113 | , m_cabacInitFlag ( false ) |
---|
114 | , m_bLMvdL1Zero ( false ) |
---|
115 | , m_numEntryPointOffsets ( 0 ) |
---|
116 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
117 | , m_enableTMVPFlag ( true ) |
---|
118 | { |
---|
119 | #if L0034_COMBINED_LIST_CLEANUP |
---|
120 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = 0; |
---|
121 | #else |
---|
122 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = m_aiNumRefIdx[2] = 0; |
---|
123 | #endif |
---|
124 | |
---|
125 | #if REF_IDX_FRAMEWORK |
---|
126 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
127 | m_activeNumILRRefIdx = 0; |
---|
128 | m_interLayerPredEnabledFlag = 0; |
---|
129 | ::memset( m_interLayerPredLayerIdc, 0, sizeof(m_interLayerPredLayerIdc) ); |
---|
130 | #else |
---|
131 | m_numILRRefIdx = 0; |
---|
132 | #endif |
---|
133 | #endif |
---|
134 | |
---|
135 | initEqualRef(); |
---|
136 | |
---|
137 | #if L0034_COMBINED_LIST_CLEANUP |
---|
138 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
139 | { |
---|
140 | m_list1IdxToList0Idx[idx] = -1; |
---|
141 | } |
---|
142 | #else |
---|
143 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++) |
---|
144 | { |
---|
145 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1; |
---|
146 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1; |
---|
147 | m_eListIdFromIdxOfLC[iNumCount]=0; |
---|
148 | m_iRefIdxFromIdxOfLC[iNumCount]=0; |
---|
149 | m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1; |
---|
150 | m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1; |
---|
151 | } |
---|
152 | #endif |
---|
153 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
154 | { |
---|
155 | m_apcRefPicList [0][iNumCount] = NULL; |
---|
156 | m_apcRefPicList [1][iNumCount] = NULL; |
---|
157 | m_aiRefPOCList [0][iNumCount] = 0; |
---|
158 | m_aiRefPOCList [1][iNumCount] = 0; |
---|
159 | } |
---|
160 | resetWpScaling(); |
---|
161 | initWpAcDcParam(); |
---|
162 | m_saoEnabledFlag = 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 | #endif |
---|
181 | m_aiNumRefIdx[0] = 0; |
---|
182 | m_aiNumRefIdx[1] = 0; |
---|
183 | #if REF_IDX_FRAMEWORK |
---|
184 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
185 | m_activeNumILRRefIdx = 0; |
---|
186 | m_interLayerPredEnabledFlag = 0; |
---|
187 | #else |
---|
188 | m_numILRRefIdx = 0; |
---|
189 | #endif |
---|
190 | |
---|
191 | #endif |
---|
192 | m_colFromL0Flag = 1; |
---|
193 | |
---|
194 | m_colRefIdx = 0; |
---|
195 | initEqualRef(); |
---|
196 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
197 | m_bNoBackPredFlag = false; |
---|
198 | m_bRefPicListCombinationFlag = false; |
---|
199 | m_bRefPicListModificationFlagLC = false; |
---|
200 | #endif |
---|
201 | m_bCheckLDC = false; |
---|
202 | m_iSliceQpDeltaCb = 0; |
---|
203 | m_iSliceQpDeltaCr = 0; |
---|
204 | |
---|
205 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
206 | m_aiNumRefIdx[REF_PIC_LIST_C] = 0; |
---|
207 | #endif |
---|
208 | |
---|
209 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
210 | |
---|
211 | m_bFinalized=false; |
---|
212 | |
---|
213 | m_tileByteLocation.clear(); |
---|
214 | m_cabacInitFlag = false; |
---|
215 | m_numEntryPointOffsets = 0; |
---|
216 | m_enableTMVPFlag = true; |
---|
217 | } |
---|
218 | |
---|
219 | Bool TComSlice::getRapPicFlag() |
---|
220 | { |
---|
221 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
222 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
223 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
224 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
225 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
226 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
227 | } |
---|
228 | |
---|
229 | /** |
---|
230 | - allocate table to contain substream sizes to be written to the slice header. |
---|
231 | . |
---|
232 | \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1. |
---|
233 | */ |
---|
234 | Void TComSlice::allocSubstreamSizes(UInt uiNumSubstreams) |
---|
235 | { |
---|
236 | delete[] m_puiSubstreamSizes; |
---|
237 | m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0]; |
---|
238 | } |
---|
239 | |
---|
240 | Void TComSlice::sortPicList(TComList<TComPic*>& rcListPic) |
---|
241 | { |
---|
242 | TComPic* pcPicExtract; |
---|
243 | TComPic* pcPicInsert; |
---|
244 | |
---|
245 | TComList<TComPic*>::iterator iterPicExtract; |
---|
246 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
247 | TComList<TComPic*>::iterator iterPicInsert; |
---|
248 | |
---|
249 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
250 | { |
---|
251 | iterPicExtract = rcListPic.begin(); |
---|
252 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
253 | pcPicExtract = *(iterPicExtract); |
---|
254 | pcPicExtract->setCurrSliceIdx(0); |
---|
255 | |
---|
256 | iterPicInsert = rcListPic.begin(); |
---|
257 | while (iterPicInsert != iterPicExtract) |
---|
258 | { |
---|
259 | pcPicInsert = *(iterPicInsert); |
---|
260 | pcPicInsert->setCurrSliceIdx(0); |
---|
261 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
262 | { |
---|
263 | break; |
---|
264 | } |
---|
265 | |
---|
266 | iterPicInsert++; |
---|
267 | } |
---|
268 | |
---|
269 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
270 | |
---|
271 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
272 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
273 | rcListPic.erase (iterPicExtract); |
---|
274 | } |
---|
275 | } |
---|
276 | |
---|
277 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, |
---|
278 | Int poc) |
---|
279 | { |
---|
280 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
281 | TComPic* pcPic = *(iterPic); |
---|
282 | while ( iterPic != rcListPic.end() ) |
---|
283 | { |
---|
284 | if(pcPic->getPOC() == poc) |
---|
285 | { |
---|
286 | break; |
---|
287 | } |
---|
288 | iterPic++; |
---|
289 | pcPic = *(iterPic); |
---|
290 | } |
---|
291 | return pcPic; |
---|
292 | } |
---|
293 | |
---|
294 | |
---|
295 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
296 | { |
---|
297 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
298 | TComPic* pcPic = *(iterPic); |
---|
299 | TComPic* pcStPic = pcPic; |
---|
300 | |
---|
301 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
302 | if (!pocHasMsb) |
---|
303 | { |
---|
304 | poc = poc % pocCycle; |
---|
305 | } |
---|
306 | |
---|
307 | while ( iterPic != rcListPic.end() ) |
---|
308 | { |
---|
309 | pcPic = *(iterPic); |
---|
310 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
311 | { |
---|
312 | Int picPoc = pcPic->getPOC(); |
---|
313 | if (!pocHasMsb) |
---|
314 | { |
---|
315 | picPoc = picPoc % pocCycle; |
---|
316 | } |
---|
317 | |
---|
318 | if (poc == picPoc) |
---|
319 | { |
---|
320 | if (pcPic->getIsLongTerm()) |
---|
321 | { |
---|
322 | return pcPic; |
---|
323 | } |
---|
324 | else |
---|
325 | { |
---|
326 | pcStPic = pcPic; |
---|
327 | } |
---|
328 | break; |
---|
329 | } |
---|
330 | } |
---|
331 | |
---|
332 | iterPic++; |
---|
333 | } |
---|
334 | |
---|
335 | return pcStPic; |
---|
336 | } |
---|
337 | |
---|
338 | Void TComSlice::setRefPOCList() |
---|
339 | { |
---|
340 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
341 | { |
---|
342 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
343 | { |
---|
344 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
345 | } |
---|
346 | } |
---|
347 | |
---|
348 | } |
---|
349 | |
---|
350 | #if L0034_COMBINED_LIST_CLEANUP |
---|
351 | Void TComSlice::setList1IdxToList0Idx() |
---|
352 | { |
---|
353 | Int idxL0, idxL1; |
---|
354 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
355 | { |
---|
356 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
357 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
358 | { |
---|
359 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
360 | { |
---|
361 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
362 | break; |
---|
363 | } |
---|
364 | } |
---|
365 | } |
---|
366 | } |
---|
367 | #else |
---|
368 | Void TComSlice::generateCombinedList() |
---|
369 | { |
---|
370 | if(m_aiNumRefIdx[REF_PIC_LIST_C] > 0) |
---|
371 | { |
---|
372 | m_aiNumRefIdx[REF_PIC_LIST_C]=0; |
---|
373 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++) |
---|
374 | { |
---|
375 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1; |
---|
376 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1; |
---|
377 | m_eListIdFromIdxOfLC[iNumCount]=0; |
---|
378 | m_iRefIdxFromIdxOfLC[iNumCount]=0; |
---|
379 | m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1; |
---|
380 | m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1; |
---|
381 | } |
---|
382 | |
---|
383 | for (Int iNumRefIdx = 0; iNumRefIdx < MAX_NUM_REF; iNumRefIdx++) |
---|
384 | { |
---|
385 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_0]) |
---|
386 | { |
---|
387 | Bool bTempRefIdxInL2 = true; |
---|
388 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
389 | { |
---|
390 | if ( m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) |
---|
391 | { |
---|
392 | m_iRefIdxOfL1FromRefIdxOfL0[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
393 | m_iRefIdxOfL0FromRefIdxOfL1[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
394 | bTempRefIdxInL2 = false; |
---|
395 | break; |
---|
396 | } |
---|
397 | } |
---|
398 | |
---|
399 | if(bTempRefIdxInL2 == true) |
---|
400 | { |
---|
401 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_0; |
---|
402 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
403 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
404 | } |
---|
405 | } |
---|
406 | |
---|
407 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_1]) |
---|
408 | { |
---|
409 | Bool bTempRefIdxInL2 = true; |
---|
410 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
411 | { |
---|
412 | if ( m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) |
---|
413 | { |
---|
414 | m_iRefIdxOfL0FromRefIdxOfL1[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
415 | m_iRefIdxOfL1FromRefIdxOfL0[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
416 | bTempRefIdxInL2 = false; |
---|
417 | break; |
---|
418 | } |
---|
419 | } |
---|
420 | if(bTempRefIdxInL2 == true) |
---|
421 | { |
---|
422 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_1; |
---|
423 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
424 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
425 | } |
---|
426 | } |
---|
427 | } |
---|
428 | } |
---|
429 | } |
---|
430 | #endif |
---|
431 | |
---|
432 | #if FIX1071 |
---|
433 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr, TComPic** ilpPic) |
---|
434 | #else |
---|
435 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic ) |
---|
436 | #endif |
---|
437 | { |
---|
438 | #if FIX1071 |
---|
439 | if (!checkNumPocTotalCurr) |
---|
440 | #endif |
---|
441 | { |
---|
442 | if( m_eSliceType == I_SLICE ) |
---|
443 | { |
---|
444 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
445 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
446 | return; |
---|
447 | } |
---|
448 | |
---|
449 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
450 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
451 | } |
---|
452 | |
---|
453 | TComPic* pcRefPic= NULL; |
---|
454 | TComPic* RefPicSetStCurr0[16]; |
---|
455 | TComPic* RefPicSetStCurr1[16]; |
---|
456 | TComPic* RefPicSetLtCurr[16]; |
---|
457 | UInt NumPocStCurr0 = 0; |
---|
458 | UInt NumPocStCurr1 = 0; |
---|
459 | UInt NumPocLtCurr = 0; |
---|
460 | Int i; |
---|
461 | |
---|
462 | #if REF_IDX_FRAMEWORK |
---|
463 | #if ZERO_NUM_DIRECT_LAYERS |
---|
464 | if( m_layerId == 0 || ( m_layerId > 0 && ( m_activeNumILRRefIdx == 0 || !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ) ) ) |
---|
465 | #else |
---|
466 | if ((getLayerId() == 0) || |
---|
467 | ((getSPS()->getLayerId()) && !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && |
---|
468 | (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ) |
---|
469 | ) |
---|
470 | #endif |
---|
471 | { |
---|
472 | #endif |
---|
473 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
474 | { |
---|
475 | if(m_pcRPS->getUsed(i)) |
---|
476 | { |
---|
477 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
478 | pcRefPic->setIsLongTerm(0); |
---|
479 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
480 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
481 | NumPocStCurr0++; |
---|
482 | pcRefPic->setCheckLTMSBPresent(false); |
---|
483 | } |
---|
484 | } |
---|
485 | |
---|
486 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
487 | { |
---|
488 | if(m_pcRPS->getUsed(i)) |
---|
489 | { |
---|
490 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
491 | pcRefPic->setIsLongTerm(0); |
---|
492 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
493 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
494 | NumPocStCurr1++; |
---|
495 | pcRefPic->setCheckLTMSBPresent(false); |
---|
496 | } |
---|
497 | } |
---|
498 | |
---|
499 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
500 | { |
---|
501 | if(m_pcRPS->getUsed(i)) |
---|
502 | { |
---|
503 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
504 | pcRefPic->setIsLongTerm(1); |
---|
505 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
506 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
507 | NumPocLtCurr++; |
---|
508 | } |
---|
509 | if(pcRefPic==NULL) |
---|
510 | { |
---|
511 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
512 | } |
---|
513 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
514 | } |
---|
515 | #if REF_IDX_FRAMEWORK |
---|
516 | } |
---|
517 | #endif |
---|
518 | |
---|
519 | #if REF_IDX_FRAMEWORK |
---|
520 | //inter-layer reference picture |
---|
521 | #if REF_IDX_MFM |
---|
522 | |
---|
523 | #if ILR_RESTR |
---|
524 | Int maxSubLayerForILPPlus1 = (getLayerId() > 0 && m_activeNumILRRefIdx > 0)? getVPS()->getMaxSublayerForIlpPlus1(ilpPic[0]->getSlice(0)->getLayerId()) : 0; |
---|
525 | #if ZERO_NUM_DIRECT_LAYERS |
---|
526 | if( getLayerId() > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[0]->getSlice(0)->getTLayer())<= maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[0]->getSlice(0)->getRapPicFlag()) ) ) |
---|
527 | #else |
---|
528 | if( getLayerId() && ( ( (Int)(ilpPic[0]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[0]->getSlice(0)->getRapPicFlag()) ) ) |
---|
529 | #endif |
---|
530 | |
---|
531 | #else |
---|
532 | #if ZERO_NUM_DIRECT_LAYERS |
---|
533 | if( m_layerId > 0 && m_activeNumILRRefIdx > 0 ) |
---|
534 | #else |
---|
535 | if (getLayerId()) |
---|
536 | #endif |
---|
537 | #endif |
---|
538 | { |
---|
539 | if(!(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && getSPS()->getMFMEnabledFlag()) |
---|
540 | { |
---|
541 | ilpPic[0]->copyUpsampledMvField(getBaseColPic()); |
---|
542 | } |
---|
543 | else |
---|
544 | { |
---|
545 | ilpPic[0]->initUpsampledMvField(); |
---|
546 | } |
---|
547 | #endif |
---|
548 | ilpPic[0]->setIsLongTerm(1); |
---|
549 | } |
---|
550 | #endif |
---|
551 | // ref_pic_list_init |
---|
552 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
553 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
554 | #if REF_IDX_FRAMEWORK |
---|
555 | #if ILR_RESTR |
---|
556 | Int numInterLayerRPSPics = 0; |
---|
557 | if (getLayerId()>0) |
---|
558 | { |
---|
559 | for (i=0; i < getVPS()->getNumDirectRefLayers(getLayerId()); i++) |
---|
560 | { |
---|
561 | maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId()); |
---|
562 | if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<= maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag() ) ) |
---|
563 | { |
---|
564 | numInterLayerRPSPics++; |
---|
565 | } |
---|
566 | } |
---|
567 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
568 | if (numInterLayerRPSPics < m_activeNumILRRefIdx) |
---|
569 | { |
---|
570 | m_activeNumILRRefIdx = numInterLayerRPSPics; |
---|
571 | } |
---|
572 | #if MAX_ONE_RESAMPLING_DIRECT_LAYERS |
---|
573 | if(getVPS()->getScalabilityMask(1)) |
---|
574 | { |
---|
575 | Int numResampler = 0; |
---|
576 | const Window &scalEL = getSPS()->getScaledRefLayerWindow(); |
---|
577 | Int scalingOffset = ((scalEL.getWindowLeftOffset() == 0 ) && |
---|
578 | (scalEL.getWindowRightOffset() == 0 ) && |
---|
579 | (scalEL.getWindowTopOffset() == 0 ) && |
---|
580 | (scalEL.getWindowBottomOffset() == 0 ) |
---|
581 | ); |
---|
582 | |
---|
583 | Int widthEL = getPic()->getPicYuvRec()->getWidth(); |
---|
584 | Int heightEL = getPic()->getPicYuvRec()->getHeight(); |
---|
585 | for (i=0; i < m_activeNumILRRefIdx; i++) |
---|
586 | { |
---|
587 | Int widthBL = ilpPic[getInterLayerPredLayerIdc(i)]->getSlice(0)->getBaseColPic()->getPicYuvRec()->getWidth(); |
---|
588 | Int heightBL = ilpPic[getInterLayerPredLayerIdc(i)]->getSlice(0)->getBaseColPic()->getPicYuvRec()->getHeight(); |
---|
589 | |
---|
590 | if(!(widthEL == widthBL && heightEL == heightBL && (scalingOffset))) |
---|
591 | { |
---|
592 | numResampler++; |
---|
593 | } |
---|
594 | } |
---|
595 | |
---|
596 | //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. |
---|
597 | assert(numResampler <= 1); |
---|
598 | } |
---|
599 | #endif |
---|
600 | #else |
---|
601 | if (numInterLayerRPSPics < m_numILRRefIdx) |
---|
602 | { |
---|
603 | m_numILRRefIdx = numInterLayerRPSPics; |
---|
604 | } |
---|
605 | #endif |
---|
606 | } |
---|
607 | #endif |
---|
608 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
609 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_activeNumILRRefIdx; |
---|
610 | #else |
---|
611 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_numILRRefIdx; |
---|
612 | #endif |
---|
613 | #else |
---|
614 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
615 | #endif |
---|
616 | #if FIX1071 |
---|
617 | if (checkNumPocTotalCurr) |
---|
618 | { |
---|
619 | // 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: |
---|
620 | #if ILP_RAP // inter-layer prediction is allowed for BLA, CRA pictures of nuh_layer_id>0 |
---|
621 | // – 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. |
---|
622 | // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
623 | if (getRapPicFlag() && getLayerId()==0) |
---|
624 | #else |
---|
625 | // – If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
626 | // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
627 | if (getRapPicFlag()) |
---|
628 | #endif |
---|
629 | { |
---|
630 | assert(numPocTotalCurr == 0); |
---|
631 | } |
---|
632 | |
---|
633 | if (m_eSliceType == I_SLICE) |
---|
634 | { |
---|
635 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
636 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
637 | |
---|
638 | return; |
---|
639 | } |
---|
640 | |
---|
641 | assert(numPocTotalCurr != 0); |
---|
642 | |
---|
643 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
644 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
645 | } |
---|
646 | #endif |
---|
647 | |
---|
648 | Int cIdx = 0; |
---|
649 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
650 | { |
---|
651 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
652 | } |
---|
653 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
654 | { |
---|
655 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
656 | } |
---|
657 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
658 | { |
---|
659 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
660 | } |
---|
661 | #if REF_IDX_FRAMEWORK |
---|
662 | if(getLayerId()) |
---|
663 | { |
---|
664 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
665 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
666 | #else |
---|
667 | for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
668 | #endif |
---|
669 | { |
---|
670 | #if ILR_RESTR |
---|
671 | maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId()); |
---|
672 | if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag()) ) |
---|
673 | #endif |
---|
674 | rpsCurrList0[cIdx] = ilpPic[i]; |
---|
675 | } |
---|
676 | } |
---|
677 | #endif |
---|
678 | if (m_eSliceType==B_SLICE) |
---|
679 | { |
---|
680 | cIdx = 0; |
---|
681 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
682 | { |
---|
683 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
684 | } |
---|
685 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
686 | { |
---|
687 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
688 | } |
---|
689 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
690 | { |
---|
691 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
692 | } |
---|
693 | #if REF_IDX_FRAMEWORK |
---|
694 | if(getLayerId()) |
---|
695 | { |
---|
696 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
697 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
698 | #else |
---|
699 | for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
700 | #endif |
---|
701 | { |
---|
702 | #if ILR_RESTR |
---|
703 | maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId()); |
---|
704 | if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag()) ) |
---|
705 | #endif |
---|
706 | rpsCurrList1[cIdx] = ilpPic[i]; |
---|
707 | } |
---|
708 | } |
---|
709 | #endif |
---|
710 | } |
---|
711 | |
---|
712 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
713 | |
---|
714 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[0]-1); rIdx ++) |
---|
715 | { |
---|
716 | m_apcRefPicList[0][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? rpsCurrList0[ m_RefPicListModification.getRefPicSetIdxL0(rIdx) ] : rpsCurrList0[rIdx % numPocTotalCurr]; |
---|
717 | m_bIsUsedAsLongTerm[0][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? (m_RefPicListModification.getRefPicSetIdxL0(rIdx) >= (NumPocStCurr0 + NumPocStCurr1)) |
---|
718 | : ((rIdx % numPocTotalCurr) >= (NumPocStCurr0 + NumPocStCurr1)); |
---|
719 | } |
---|
720 | if ( m_eSliceType == P_SLICE ) |
---|
721 | { |
---|
722 | m_aiNumRefIdx[1] = 0; |
---|
723 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
724 | } |
---|
725 | else |
---|
726 | { |
---|
727 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[1]-1); rIdx ++) |
---|
728 | { |
---|
729 | m_apcRefPicList[1][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? rpsCurrList1[ m_RefPicListModification.getRefPicSetIdxL1(rIdx) ] : rpsCurrList1[rIdx % numPocTotalCurr]; |
---|
730 | m_bIsUsedAsLongTerm[1][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? |
---|
731 | (m_RefPicListModification.getRefPicSetIdxL1(rIdx) >= (NumPocStCurr0 + NumPocStCurr1)): ((rIdx % numPocTotalCurr) >= (NumPocStCurr0 + NumPocStCurr1)); |
---|
732 | } |
---|
733 | } |
---|
734 | } |
---|
735 | |
---|
736 | #if REF_IDX_FRAMEWORK |
---|
737 | Void TComSlice::setRefPicListModificationSvc() |
---|
738 | { |
---|
739 | if( !this->getPPS()->getListsModificationPresentFlag()) |
---|
740 | { |
---|
741 | return; |
---|
742 | } |
---|
743 | |
---|
744 | if(this->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && this->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) |
---|
745 | { |
---|
746 | return; |
---|
747 | } |
---|
748 | |
---|
749 | TComRefPicListModification* refPicListModification = this->getRefPicListModification(); |
---|
750 | Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList(); // total number of ref pics in listTemp0 including inter-layer ref pics |
---|
751 | |
---|
752 | assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 1); |
---|
753 | assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 1); |
---|
754 | |
---|
755 | //set L0 inter-layer reference picture modification |
---|
756 | Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == numberOfRpsCurrTempList) ? false : true; |
---|
757 | refPicListModification->setRefPicListModificationFlagL0(hasModification); |
---|
758 | if(hasModification) |
---|
759 | { |
---|
760 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_0], numberOfRpsCurrTempList); i++) |
---|
761 | { |
---|
762 | refPicListModification->setRefPicSetIdxL0(i, i); |
---|
763 | } |
---|
764 | if(m_aiNumRefIdx[REF_PIC_LIST_0] > numberOfRpsCurrTempList) |
---|
765 | { |
---|
766 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
767 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_0]; i ++) |
---|
768 | { |
---|
769 | refPicListModification->setRefPicSetIdxL0(i, numberOfRpsCurrTempList - 1); |
---|
770 | } |
---|
771 | } |
---|
772 | else |
---|
773 | { |
---|
774 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
775 | for(Int i = m_activeNumILRRefIdx; i > 0; i-- ) |
---|
776 | #else |
---|
777 | for(Int i = m_numILRRefIdx; i > 0; i-- ) |
---|
778 | #endif |
---|
779 | { |
---|
780 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i); |
---|
781 | } |
---|
782 | } |
---|
783 | } |
---|
784 | |
---|
785 | //set L1 inter-layer reference picture modification |
---|
786 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] == numberOfRpsCurrTempList) ? false : true; |
---|
787 | refPicListModification->setRefPicListModificationFlagL1(hasModification); |
---|
788 | if(hasModification) |
---|
789 | { |
---|
790 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_1], numberOfRpsCurrTempList); i++) |
---|
791 | { |
---|
792 | refPicListModification->setRefPicSetIdxL1(i, i); |
---|
793 | } |
---|
794 | if(m_aiNumRefIdx[REF_PIC_LIST_1] > numberOfRpsCurrTempList) |
---|
795 | { |
---|
796 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_1]; i ++) |
---|
797 | { |
---|
798 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
799 | refPicListModification->setRefPicSetIdxL1(i, numberOfRpsCurrTempList - 1); |
---|
800 | } |
---|
801 | } |
---|
802 | else |
---|
803 | { |
---|
804 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
805 | for(Int i = m_activeNumILRRefIdx; i > 0; i-- ) |
---|
806 | #else |
---|
807 | for(Int i = m_numILRRefIdx; i > 0; i-- ) |
---|
808 | #endif |
---|
809 | { |
---|
810 | refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i); |
---|
811 | } |
---|
812 | } |
---|
813 | } |
---|
814 | return; |
---|
815 | } |
---|
816 | #endif |
---|
817 | |
---|
818 | Int TComSlice::getNumRpsCurrTempList() |
---|
819 | { |
---|
820 | Int numRpsCurrTempList = 0; |
---|
821 | |
---|
822 | #if REF_IDX_FRAMEWORK |
---|
823 | if( m_eSliceType == I_SLICE || ( getSPS()->getLayerId() && |
---|
824 | (getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && |
---|
825 | (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) ) ) |
---|
826 | #else |
---|
827 | if (m_eSliceType == I_SLICE) |
---|
828 | #endif |
---|
829 | { |
---|
830 | #if REF_IDX_FRAMEWORK |
---|
831 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
832 | return m_activeNumILRRefIdx; |
---|
833 | #else |
---|
834 | return getNumILRRefIdx(); |
---|
835 | #endif |
---|
836 | #else |
---|
837 | return 0; |
---|
838 | #endif |
---|
839 | } |
---|
840 | for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++) |
---|
841 | { |
---|
842 | if(m_pcRPS->getUsed(i)) |
---|
843 | { |
---|
844 | numRpsCurrTempList++; |
---|
845 | } |
---|
846 | } |
---|
847 | #if REF_IDX_FRAMEWORK |
---|
848 | if(getLayerId()) |
---|
849 | { |
---|
850 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
851 | numRpsCurrTempList += m_activeNumILRRefIdx; |
---|
852 | #else |
---|
853 | numRpsCurrTempList += getNumILRRefIdx(); |
---|
854 | #endif |
---|
855 | } |
---|
856 | #endif |
---|
857 | |
---|
858 | return numRpsCurrTempList; |
---|
859 | } |
---|
860 | |
---|
861 | Void TComSlice::initEqualRef() |
---|
862 | { |
---|
863 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
864 | { |
---|
865 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
866 | { |
---|
867 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
868 | { |
---|
869 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
870 | } |
---|
871 | } |
---|
872 | } |
---|
873 | } |
---|
874 | |
---|
875 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
876 | { |
---|
877 | Int i; |
---|
878 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
879 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1-curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
880 | TComSlice* preSlice; |
---|
881 | Int preColRefPOC; |
---|
882 | for(i=curSliceIdx-1; i>=0; i--) |
---|
883 | { |
---|
884 | preSlice = pic->getSlice(i); |
---|
885 | if(preSlice->getSliceType() != I_SLICE) |
---|
886 | { |
---|
887 | preColRefPOC = preSlice->getRefPOC( RefPicList(1-preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
888 | if(currColRefPOC != preColRefPOC) |
---|
889 | { |
---|
890 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
891 | exit(EXIT_FAILURE); |
---|
892 | } |
---|
893 | else |
---|
894 | { |
---|
895 | break; |
---|
896 | } |
---|
897 | } |
---|
898 | } |
---|
899 | } |
---|
900 | |
---|
901 | Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic) |
---|
902 | { |
---|
903 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
904 | { |
---|
905 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
906 | { |
---|
907 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
908 | } |
---|
909 | } |
---|
910 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
911 | { |
---|
912 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
913 | { |
---|
914 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
915 | { |
---|
916 | assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA); |
---|
917 | } |
---|
918 | else |
---|
919 | { |
---|
920 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
921 | } |
---|
922 | } |
---|
923 | } |
---|
924 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
925 | { |
---|
926 | pocCRA = getPOC(); |
---|
927 | prevRAPisBLA = false; |
---|
928 | } |
---|
929 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
930 | { |
---|
931 | pocCRA = getPOC(); |
---|
932 | prevRAPisBLA = false; |
---|
933 | } |
---|
934 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
935 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
936 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
937 | { |
---|
938 | pocCRA = getPOC(); |
---|
939 | prevRAPisBLA = true; |
---|
940 | } |
---|
941 | } |
---|
942 | |
---|
943 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
944 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
945 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
946 | * \param rcListPic reference to the reference picture list |
---|
947 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
948 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
949 | * are marked as "unused for reference" |
---|
950 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
951 | * Otherwise |
---|
952 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
953 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
954 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
955 | * the bRefreshPending flag to false. |
---|
956 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
957 | * reference of the current picture. |
---|
958 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
959 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
960 | */ |
---|
961 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
962 | { |
---|
963 | TComPic* rpcPic; |
---|
964 | Int pocCurr = getPOC(); |
---|
965 | |
---|
966 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
967 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
968 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
969 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
970 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
971 | { |
---|
972 | // mark all pictures as not used for reference |
---|
973 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
974 | while (iterPic != rcListPic.end()) |
---|
975 | { |
---|
976 | rpcPic = *(iterPic); |
---|
977 | rpcPic->setCurrSliceIdx(0); |
---|
978 | if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
979 | iterPic++; |
---|
980 | } |
---|
981 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
982 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
983 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
984 | { |
---|
985 | pocCRA = pocCurr; |
---|
986 | } |
---|
987 | } |
---|
988 | else // CRA or No DR |
---|
989 | { |
---|
990 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
991 | { |
---|
992 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
993 | while (iterPic != rcListPic.end()) |
---|
994 | { |
---|
995 | rpcPic = *(iterPic); |
---|
996 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
997 | { |
---|
998 | rpcPic->getSlice(0)->setReferenced(false); |
---|
999 | } |
---|
1000 | iterPic++; |
---|
1001 | } |
---|
1002 | bRefreshPending = false; |
---|
1003 | } |
---|
1004 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
1005 | { |
---|
1006 | bRefreshPending = true; |
---|
1007 | pocCRA = pocCurr; |
---|
1008 | } |
---|
1009 | } |
---|
1010 | } |
---|
1011 | |
---|
1012 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
1013 | { |
---|
1014 | assert( pSrc != NULL ); |
---|
1015 | |
---|
1016 | Int i, j, k; |
---|
1017 | |
---|
1018 | m_iPOC = pSrc->m_iPOC; |
---|
1019 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
1020 | m_eSliceType = pSrc->m_eSliceType; |
---|
1021 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
1022 | #if ADAPTIVE_QP_SELECTION |
---|
1023 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
1024 | #endif |
---|
1025 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
1026 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
1027 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
1028 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
1029 | |
---|
1030 | #if L0034_COMBINED_LIST_CLEANUP |
---|
1031 | for (i = 0; i < 2; i++) |
---|
1032 | #else |
---|
1033 | for (i = 0; i < 3; i++) |
---|
1034 | #endif |
---|
1035 | { |
---|
1036 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
1037 | } |
---|
1038 | |
---|
1039 | #if L0034_COMBINED_LIST_CLEANUP |
---|
1040 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
1041 | { |
---|
1042 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
1043 | } |
---|
1044 | #else |
---|
1045 | for (i = 0; i < 2; i++) |
---|
1046 | { |
---|
1047 | for (j = 0; j < MAX_NUM_REF_LC; j++) |
---|
1048 | { |
---|
1049 | m_iRefIdxOfLC[i][j] = pSrc->m_iRefIdxOfLC[i][j]; |
---|
1050 | } |
---|
1051 | } |
---|
1052 | for (i = 0; i < MAX_NUM_REF_LC; i++) |
---|
1053 | { |
---|
1054 | m_eListIdFromIdxOfLC[i] = pSrc->m_eListIdFromIdxOfLC[i]; |
---|
1055 | m_iRefIdxFromIdxOfLC[i] = pSrc->m_iRefIdxFromIdxOfLC[i]; |
---|
1056 | m_iRefIdxOfL1FromRefIdxOfL0[i] = pSrc->m_iRefIdxOfL1FromRefIdxOfL0[i]; |
---|
1057 | m_iRefIdxOfL0FromRefIdxOfL1[i] = pSrc->m_iRefIdxOfL0FromRefIdxOfL1[i]; |
---|
1058 | } |
---|
1059 | m_bRefPicListModificationFlagLC = pSrc->m_bRefPicListModificationFlagLC; |
---|
1060 | m_bRefPicListCombinationFlag = pSrc->m_bRefPicListCombinationFlag; |
---|
1061 | #endif |
---|
1062 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
1063 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
1064 | m_iSliceQpDeltaCb = pSrc->m_iSliceQpDeltaCb; |
---|
1065 | m_iSliceQpDeltaCr = pSrc->m_iSliceQpDeltaCr; |
---|
1066 | for (i = 0; i < 2; i++) |
---|
1067 | { |
---|
1068 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1069 | { |
---|
1070 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
1071 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
1072 | } |
---|
1073 | } |
---|
1074 | for (i = 0; i < 2; i++) |
---|
1075 | { |
---|
1076 | for (j = 0; j < MAX_NUM_REF + 1; j++) |
---|
1077 | { |
---|
1078 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
1079 | } |
---|
1080 | } |
---|
1081 | m_iDepth = pSrc->m_iDepth; |
---|
1082 | |
---|
1083 | // referenced slice |
---|
1084 | m_bRefenced = pSrc->m_bRefenced; |
---|
1085 | |
---|
1086 | // access channel |
---|
1087 | #if SVC_EXTENSION |
---|
1088 | m_pcVPS = pSrc->m_pcVPS; |
---|
1089 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
1090 | m_activeNumILRRefIdx = pSrc->m_activeNumILRRefIdx; |
---|
1091 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
1092 | m_numInterLayerRefPics = pSrc->m_numInterLayerRefPics; |
---|
1093 | memcpy( m_interLayerPredLayerIdc, pSrc->m_interLayerPredLayerIdc, sizeof( m_interLayerPredLayerIdc ) ); |
---|
1094 | #elif REF_IDX_FRAMEWORK |
---|
1095 | m_numILRRefIdx = pSrc->m_numILRRefIdx; |
---|
1096 | #endif |
---|
1097 | #endif |
---|
1098 | m_pcSPS = pSrc->m_pcSPS; |
---|
1099 | m_pcPPS = pSrc->m_pcPPS; |
---|
1100 | m_pcRPS = pSrc->m_pcRPS; |
---|
1101 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
1102 | |
---|
1103 | m_pcPic = pSrc->m_pcPic; |
---|
1104 | |
---|
1105 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
1106 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
1107 | #if SAO_CHROMA_LAMBDA |
---|
1108 | m_dLambdaLuma = pSrc->m_dLambdaLuma; |
---|
1109 | m_dLambdaChroma = pSrc->m_dLambdaChroma; |
---|
1110 | #else |
---|
1111 | m_dLambda = pSrc->m_dLambda; |
---|
1112 | #endif |
---|
1113 | for (i = 0; i < 2; i++) |
---|
1114 | { |
---|
1115 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1116 | { |
---|
1117 | for (k =0; k < MAX_NUM_REF; k++) |
---|
1118 | { |
---|
1119 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
1120 | } |
---|
1121 | } |
---|
1122 | } |
---|
1123 | |
---|
1124 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
1125 | m_bNoBackPredFlag = pSrc->m_bNoBackPredFlag; |
---|
1126 | #endif |
---|
1127 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
1128 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
1129 | |
---|
1130 | m_sliceMode = pSrc->m_sliceMode; |
---|
1131 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
1132 | m_sliceCurStartCUAddr = pSrc->m_sliceCurStartCUAddr; |
---|
1133 | m_sliceCurEndCUAddr = pSrc->m_sliceCurEndCUAddr; |
---|
1134 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
1135 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
1136 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
1137 | m_sliceSegmentCurStartCUAddr = pSrc->m_sliceSegmentCurStartCUAddr; |
---|
1138 | m_sliceSegmentCurEndCUAddr = pSrc->m_sliceSegmentCurEndCUAddr; |
---|
1139 | m_nextSlice = pSrc->m_nextSlice; |
---|
1140 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
1141 | for ( Int e=0 ; e<2 ; e++ ) |
---|
1142 | { |
---|
1143 | for ( Int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
1144 | { |
---|
1145 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
1146 | } |
---|
1147 | } |
---|
1148 | m_saoEnabledFlag = pSrc->m_saoEnabledFlag; |
---|
1149 | m_saoEnabledFlagChroma = pSrc->m_saoEnabledFlagChroma; |
---|
1150 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
1151 | m_numEntryPointOffsets = pSrc->m_numEntryPointOffsets; |
---|
1152 | |
---|
1153 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
1154 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
1155 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
1156 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
1157 | } |
---|
1158 | |
---|
1159 | Int TComSlice::m_prevPOC = 0; |
---|
1160 | |
---|
1161 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
1162 | * \param uiTLayer Temporal layer ID of the current slice |
---|
1163 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
1164 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
1165 | * temporal_layer_switching_point_flag is set accordingly. |
---|
1166 | */ |
---|
1167 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
1168 | { |
---|
1169 | m_uiTLayer = uiTLayer; |
---|
1170 | } |
---|
1171 | |
---|
1172 | /** Function for checking if this is a switching-point |
---|
1173 | */ |
---|
1174 | Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic ) |
---|
1175 | { |
---|
1176 | TComPic* rpcPic; |
---|
1177 | // loop through all pictures in the reference picture buffer |
---|
1178 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1179 | while ( iterPic != rcListPic.end()) |
---|
1180 | { |
---|
1181 | rpcPic = *(iterPic++); |
---|
1182 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
1183 | { |
---|
1184 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1185 | { |
---|
1186 | return false; |
---|
1187 | } |
---|
1188 | } |
---|
1189 | } |
---|
1190 | return true; |
---|
1191 | } |
---|
1192 | |
---|
1193 | /** Function for checking if this is a STSA candidate |
---|
1194 | */ |
---|
1195 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic ) |
---|
1196 | { |
---|
1197 | TComPic* rpcPic; |
---|
1198 | |
---|
1199 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1200 | while ( iterPic != rcListPic.end()) |
---|
1201 | { |
---|
1202 | rpcPic = *(iterPic++); |
---|
1203 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
1204 | { |
---|
1205 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1206 | { |
---|
1207 | return false; |
---|
1208 | } |
---|
1209 | } |
---|
1210 | } |
---|
1211 | return true; |
---|
1212 | } |
---|
1213 | |
---|
1214 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1215 | */ |
---|
1216 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
1217 | { |
---|
1218 | TComPic* rpcPic; |
---|
1219 | Int i, isReference; |
---|
1220 | |
---|
1221 | // loop through all pictures in the reference picture buffer |
---|
1222 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1223 | while ( iterPic != rcListPic.end()) |
---|
1224 | { |
---|
1225 | rpcPic = *(iterPic++); |
---|
1226 | |
---|
1227 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
1228 | { |
---|
1229 | continue; |
---|
1230 | } |
---|
1231 | |
---|
1232 | isReference = 0; |
---|
1233 | // loop through all pictures in the Reference Picture Set |
---|
1234 | // to see if the picture should be kept as reference picture |
---|
1235 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
1236 | { |
---|
1237 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
1238 | { |
---|
1239 | isReference = 1; |
---|
1240 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1241 | rpcPic->setIsLongTerm(0); |
---|
1242 | } |
---|
1243 | } |
---|
1244 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1245 | { |
---|
1246 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1247 | { |
---|
1248 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
1249 | { |
---|
1250 | isReference = 1; |
---|
1251 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1252 | } |
---|
1253 | } |
---|
1254 | else |
---|
1255 | { |
---|
1256 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) |
---|
1257 | { |
---|
1258 | isReference = 1; |
---|
1259 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1260 | } |
---|
1261 | } |
---|
1262 | |
---|
1263 | } |
---|
1264 | // mark the picture as "unused for reference" if it is not in |
---|
1265 | // the Reference Picture Set |
---|
1266 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
1267 | { |
---|
1268 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
1269 | rpcPic->setUsedByCurr(0); |
---|
1270 | rpcPic->setIsLongTerm(0); |
---|
1271 | } |
---|
1272 | //check that pictures of higher temporal layers are not used |
---|
1273 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
1274 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
1275 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
1276 | { |
---|
1277 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
1278 | } |
---|
1279 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
1280 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
1281 | { |
---|
1282 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
1283 | } |
---|
1284 | } |
---|
1285 | } |
---|
1286 | |
---|
1287 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1288 | */ |
---|
1289 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess) |
---|
1290 | { |
---|
1291 | TComPic* rpcPic; |
---|
1292 | Int i, isAvailable; |
---|
1293 | Int atLeastOneLost = 0; |
---|
1294 | Int atLeastOneRemoved = 0; |
---|
1295 | Int iPocLost = 0; |
---|
1296 | |
---|
1297 | // loop through all long-term pictures in the Reference Picture Set |
---|
1298 | // to see if the picture should be kept as reference picture |
---|
1299 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1300 | { |
---|
1301 | isAvailable = 0; |
---|
1302 | // loop through all pictures in the reference picture buffer |
---|
1303 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1304 | while ( iterPic != rcListPic.end()) |
---|
1305 | { |
---|
1306 | rpcPic = *(iterPic++); |
---|
1307 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1308 | { |
---|
1309 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1310 | { |
---|
1311 | isAvailable = 1; |
---|
1312 | } |
---|
1313 | } |
---|
1314 | else |
---|
1315 | { |
---|
1316 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()) && rpcPic->getSlice(0)->isReferenced()) |
---|
1317 | { |
---|
1318 | isAvailable = 1; |
---|
1319 | } |
---|
1320 | } |
---|
1321 | } |
---|
1322 | // if there was no such long-term check the short terms |
---|
1323 | if(!isAvailable) |
---|
1324 | { |
---|
1325 | iterPic = rcListPic.begin(); |
---|
1326 | while ( iterPic != rcListPic.end()) |
---|
1327 | { |
---|
1328 | rpcPic = *(iterPic++); |
---|
1329 | |
---|
1330 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1331 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
1332 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
1333 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
1334 | { |
---|
1335 | curPoc = curPoc % pocCycle; |
---|
1336 | refPoc = refPoc % pocCycle; |
---|
1337 | } |
---|
1338 | |
---|
1339 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
1340 | { |
---|
1341 | isAvailable = 1; |
---|
1342 | rpcPic->setIsLongTerm(1); |
---|
1343 | break; |
---|
1344 | } |
---|
1345 | } |
---|
1346 | } |
---|
1347 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1348 | // but not available as reference picture |
---|
1349 | if(isAvailable == 0) |
---|
1350 | { |
---|
1351 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1352 | { |
---|
1353 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1354 | { |
---|
1355 | if(printErrors) |
---|
1356 | { |
---|
1357 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1358 | } |
---|
1359 | atLeastOneRemoved = 1; |
---|
1360 | } |
---|
1361 | else |
---|
1362 | { |
---|
1363 | if(printErrors) |
---|
1364 | { |
---|
1365 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1366 | } |
---|
1367 | atLeastOneLost = 1; |
---|
1368 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1369 | } |
---|
1370 | } |
---|
1371 | } |
---|
1372 | } |
---|
1373 | // loop through all short-term pictures in the Reference Picture Set |
---|
1374 | // to see if the picture should be kept as reference picture |
---|
1375 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
1376 | { |
---|
1377 | isAvailable = 0; |
---|
1378 | // loop through all pictures in the reference picture buffer |
---|
1379 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1380 | while ( iterPic != rcListPic.end()) |
---|
1381 | { |
---|
1382 | rpcPic = *(iterPic++); |
---|
1383 | |
---|
1384 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1385 | { |
---|
1386 | isAvailable = 1; |
---|
1387 | } |
---|
1388 | } |
---|
1389 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1390 | // but not available as reference picture |
---|
1391 | if(isAvailable == 0) |
---|
1392 | { |
---|
1393 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1394 | { |
---|
1395 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1396 | { |
---|
1397 | if(printErrors) |
---|
1398 | { |
---|
1399 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1400 | } |
---|
1401 | atLeastOneRemoved = 1; |
---|
1402 | } |
---|
1403 | else |
---|
1404 | { |
---|
1405 | if(printErrors) |
---|
1406 | { |
---|
1407 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1408 | } |
---|
1409 | atLeastOneLost = 1; |
---|
1410 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1411 | } |
---|
1412 | } |
---|
1413 | } |
---|
1414 | } |
---|
1415 | if(atLeastOneLost) |
---|
1416 | { |
---|
1417 | return iPocLost+1; |
---|
1418 | } |
---|
1419 | if(atLeastOneRemoved) |
---|
1420 | { |
---|
1421 | return -2; |
---|
1422 | } |
---|
1423 | else |
---|
1424 | { |
---|
1425 | return 0; |
---|
1426 | } |
---|
1427 | } |
---|
1428 | |
---|
1429 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
1430 | */ |
---|
1431 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
1432 | { |
---|
1433 | TComPic* rpcPic; |
---|
1434 | Int i, j; |
---|
1435 | Int k = 0; |
---|
1436 | Int nrOfNegativePictures = 0; |
---|
1437 | Int nrOfPositivePictures = 0; |
---|
1438 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
1439 | |
---|
1440 | // loop through all pictures in the Reference Picture Set |
---|
1441 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1442 | { |
---|
1443 | j = 0; |
---|
1444 | // loop through all pictures in the reference picture buffer |
---|
1445 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1446 | while ( iterPic != rcListPic.end()) |
---|
1447 | { |
---|
1448 | j++; |
---|
1449 | rpcPic = *(iterPic++); |
---|
1450 | |
---|
1451 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1452 | { |
---|
1453 | // This picture exists as a reference picture |
---|
1454 | // and should be added to the explicit Reference Picture Set |
---|
1455 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
1456 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i)); |
---|
1457 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
1458 | { |
---|
1459 | nrOfNegativePictures++; |
---|
1460 | } |
---|
1461 | else |
---|
1462 | { |
---|
1463 | nrOfPositivePictures++; |
---|
1464 | } |
---|
1465 | k++; |
---|
1466 | } |
---|
1467 | } |
---|
1468 | } |
---|
1469 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
1470 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
1471 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
1472 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
1473 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
1474 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
1475 | if (!pReferencePictureSet->getInterRPSPrediction()) |
---|
1476 | { |
---|
1477 | pcRPS->setInterRPSPrediction(false); |
---|
1478 | pcRPS->setNumRefIdc(0); |
---|
1479 | } |
---|
1480 | else |
---|
1481 | { |
---|
1482 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
1483 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
1484 | TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
1485 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
1486 | Int iNewIdc=0; |
---|
1487 | for(i=0; i<= iRefPics; i++) |
---|
1488 | { |
---|
1489 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
1490 | Int iRefIdc = 0; |
---|
1491 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
1492 | { |
---|
1493 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
1494 | { |
---|
1495 | if (pcRPS->getUsed(j)) |
---|
1496 | { |
---|
1497 | iRefIdc = 1; |
---|
1498 | } |
---|
1499 | else |
---|
1500 | { |
---|
1501 | iRefIdc = 2; |
---|
1502 | } |
---|
1503 | } |
---|
1504 | } |
---|
1505 | pcRPS->setRefIdc(i, iRefIdc); |
---|
1506 | iNewIdc++; |
---|
1507 | } |
---|
1508 | pcRPS->setInterRPSPrediction(true); |
---|
1509 | pcRPS->setNumRefIdc(iNewIdc); |
---|
1510 | pcRPS->setDeltaRPS(deltaRPS); |
---|
1511 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
1512 | } |
---|
1513 | |
---|
1514 | this->setRPS(pcRPS); |
---|
1515 | this->setRPSidx(-1); |
---|
1516 | } |
---|
1517 | |
---|
1518 | /** get AC and DC values for weighted pred |
---|
1519 | * \param *wp |
---|
1520 | * \returns Void |
---|
1521 | */ |
---|
1522 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
1523 | { |
---|
1524 | wp = m_weightACDCParam; |
---|
1525 | } |
---|
1526 | |
---|
1527 | /** init AC and DC values for weighted pred |
---|
1528 | * \returns Void |
---|
1529 | */ |
---|
1530 | Void TComSlice::initWpAcDcParam() |
---|
1531 | { |
---|
1532 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
1533 | { |
---|
1534 | m_weightACDCParam[iComp].iAC = 0; |
---|
1535 | m_weightACDCParam[iComp].iDC = 0; |
---|
1536 | } |
---|
1537 | } |
---|
1538 | |
---|
1539 | /** get WP tables for weighted pred |
---|
1540 | * \param RefPicList |
---|
1541 | * \param iRefIdx |
---|
1542 | * \param *&wpScalingParam |
---|
1543 | * \returns Void |
---|
1544 | */ |
---|
1545 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
1546 | { |
---|
1547 | wp = m_weightPredTable[e][iRefIdx]; |
---|
1548 | } |
---|
1549 | |
---|
1550 | /** reset Default WP tables settings : no weight. |
---|
1551 | * \param wpScalingParam |
---|
1552 | * \returns Void |
---|
1553 | */ |
---|
1554 | Void TComSlice::resetWpScaling() |
---|
1555 | { |
---|
1556 | for ( Int e=0 ; e<2 ; e++ ) |
---|
1557 | { |
---|
1558 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1559 | { |
---|
1560 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
1561 | { |
---|
1562 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1563 | pwp->bPresentFlag = false; |
---|
1564 | pwp->uiLog2WeightDenom = 0; |
---|
1565 | pwp->uiLog2WeightDenom = 0; |
---|
1566 | pwp->iWeight = 1; |
---|
1567 | pwp->iOffset = 0; |
---|
1568 | } |
---|
1569 | } |
---|
1570 | } |
---|
1571 | } |
---|
1572 | |
---|
1573 | /** init WP table |
---|
1574 | * \returns Void |
---|
1575 | */ |
---|
1576 | Void TComSlice::initWpScaling() |
---|
1577 | { |
---|
1578 | for ( Int e=0 ; e<2 ; e++ ) |
---|
1579 | { |
---|
1580 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1581 | { |
---|
1582 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
1583 | { |
---|
1584 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
1585 | if ( !pwp->bPresentFlag ) |
---|
1586 | { |
---|
1587 | // Inferring values not present : |
---|
1588 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
1589 | pwp->iOffset = 0; |
---|
1590 | } |
---|
1591 | |
---|
1592 | pwp->w = pwp->iWeight; |
---|
1593 | Int bitDepth = yuv ? g_bitDepthC : g_bitDepthY; |
---|
1594 | pwp->o = pwp->iOffset << (bitDepth-8); |
---|
1595 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
1596 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
1597 | } |
---|
1598 | } |
---|
1599 | } |
---|
1600 | } |
---|
1601 | |
---|
1602 | // ------------------------------------------------------------------------------------------------ |
---|
1603 | // Video parameter set (VPS) |
---|
1604 | // ------------------------------------------------------------------------------------------------ |
---|
1605 | TComVPS::TComVPS() |
---|
1606 | : m_VPSId ( 0) |
---|
1607 | , m_uiMaxTLayers ( 1) |
---|
1608 | , m_uiMaxLayers ( 1) |
---|
1609 | , m_bTemporalIdNestingFlag (false) |
---|
1610 | , m_numHrdParameters ( 0) |
---|
1611 | #if !VPS_RENAME |
---|
1612 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
1613 | #endif |
---|
1614 | , m_hrdParameters (NULL) |
---|
1615 | , m_hrdOpSetIdx (NULL) |
---|
1616 | , m_cprmsPresentFlag (NULL) |
---|
1617 | #if VPS_RENAME |
---|
1618 | , m_maxLayerId (0) |
---|
1619 | , m_numLayerSets (0) |
---|
1620 | #endif |
---|
1621 | #if VPS_EXTN_OP_LAYER_SETS |
---|
1622 | , m_numOutputLayerSets (0) |
---|
1623 | #endif |
---|
1624 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
1625 | , m_numProfileTierLevel (0) |
---|
1626 | , m_moreOutputLayerSetsThanDefaultFlag (false) |
---|
1627 | , m_numAddOutputLayerSets (0) |
---|
1628 | , m_defaultOneTargetOutputLayerFlag (false) |
---|
1629 | #endif |
---|
1630 | { |
---|
1631 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
1632 | { |
---|
1633 | m_numReorderPics[i] = 0; |
---|
1634 | #if L0323_DPB |
---|
1635 | m_uiMaxDecPicBuffering[i] = 1; |
---|
1636 | #else |
---|
1637 | m_uiMaxDecPicBuffering[i] = 0; |
---|
1638 | #endif |
---|
1639 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1640 | } |
---|
1641 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
1642 | m_avcBaseLayerFlag = false; |
---|
1643 | m_splittingFlag = false; |
---|
1644 | ::memset(m_scalabilityMask, 0, sizeof(m_scalabilityMask)); |
---|
1645 | ::memset(m_dimensionIdLen, 0, sizeof(m_dimensionIdLen)); |
---|
1646 | m_nuhLayerIdPresentFlag = false; |
---|
1647 | ::memset(m_layerIdInNuh, 0, sizeof(m_layerIdInNuh)); |
---|
1648 | ::memset(m_dimensionId, 0, sizeof(m_dimensionId)); |
---|
1649 | |
---|
1650 | m_numScalabilityTypes = 0; |
---|
1651 | ::memset(m_layerIdInVps, 0, sizeof(m_layerIdInVps)); |
---|
1652 | #endif |
---|
1653 | #if VPS_EXTN_PROFILE_INFO |
---|
1654 | ::memset(m_profilePresentFlag, 0, sizeof(m_profilePresentFlag)); |
---|
1655 | ::memset(m_profileLayerSetRef, 0, sizeof(m_profileLayerSetRef)); |
---|
1656 | #endif |
---|
1657 | #if VPS_EXTN_OP_LAYER_SETS |
---|
1658 | ::memset(m_layerIdIncludedFlag, 0, sizeof(m_layerIdIncludedFlag)); |
---|
1659 | // Consider dynamic allocation for outputLayerSetIdx and outputLayerFlag |
---|
1660 | ::memset(m_outputLayerSetIdx, 0, sizeof(m_outputLayerSetIdx)); |
---|
1661 | ::memset(m_outputLayerFlag, 0, sizeof(m_outputLayerFlag)); |
---|
1662 | #endif |
---|
1663 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1664 | ::memset(m_directDependencyFlag, 0, sizeof(m_directDependencyFlag)); |
---|
1665 | ::memset(m_numDirectRefLayers, 0, sizeof(m_numDirectRefLayers )); |
---|
1666 | ::memset(m_refLayerId, 0, sizeof(m_refLayerId )); |
---|
1667 | #endif |
---|
1668 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
1669 | ::memset(m_layerSetLayerIdList, 0, sizeof(m_layerSetLayerIdList)); |
---|
1670 | ::memset(m_numLayerInIdList, 0, sizeof(m_numLayerInIdList )); |
---|
1671 | #endif |
---|
1672 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
1673 | ::memset(m_profileLevelTierIdx, 0, sizeof(m_profileLevelTierIdx)); |
---|
1674 | #endif |
---|
1675 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
1676 | m_maxOneActiveRefLayerFlag = true; |
---|
1677 | #endif |
---|
1678 | #if JCTVC_M0203_INTERLAYER_PRED_IDC |
---|
1679 | for( Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++) |
---|
1680 | { |
---|
1681 | m_maxSublayerForIlpPlus1[i] = m_uiMaxTLayers + 1; |
---|
1682 | } |
---|
1683 | #endif |
---|
1684 | } |
---|
1685 | |
---|
1686 | TComVPS::~TComVPS() |
---|
1687 | { |
---|
1688 | if( m_hrdParameters != NULL ) delete[] m_hrdParameters; |
---|
1689 | if( m_hrdOpSetIdx != NULL ) delete[] m_hrdOpSetIdx; |
---|
1690 | if( m_cprmsPresentFlag != NULL ) delete[] m_cprmsPresentFlag; |
---|
1691 | } |
---|
1692 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
1693 | Void TComVPS::deriveLayerIdListVariables() |
---|
1694 | { |
---|
1695 | // For layer 0 |
---|
1696 | setNumLayersInIdList(0, 1); |
---|
1697 | setLayerSetLayerIdList(0, 0, 0); |
---|
1698 | |
---|
1699 | // For other layers |
---|
1700 | Int i, m, n; |
---|
1701 | for( i = 1; i <= getNumLayerSets() - 1; i++ ) |
---|
1702 | { |
---|
1703 | n = 0; |
---|
1704 | for( m = 0; m <= this->getMaxLayerId(); m++) |
---|
1705 | { |
---|
1706 | if(this->getLayerIdIncludedFlag(i, m)) |
---|
1707 | { |
---|
1708 | setLayerSetLayerIdList(i, n, m); |
---|
1709 | n++; |
---|
1710 | } |
---|
1711 | } |
---|
1712 | setNumLayersInIdList(i, n); |
---|
1713 | } |
---|
1714 | } |
---|
1715 | #endif |
---|
1716 | // ------------------------------------------------------------------------------------------------ |
---|
1717 | // Sequence parameter set (SPS) |
---|
1718 | // ------------------------------------------------------------------------------------------------ |
---|
1719 | |
---|
1720 | TComSPS::TComSPS() |
---|
1721 | : m_SPSId ( 0) |
---|
1722 | , m_VPSId ( 0) |
---|
1723 | , m_chromaFormatIdc (CHROMA_420) |
---|
1724 | , m_uiMaxTLayers ( 1) |
---|
1725 | // Structure |
---|
1726 | , m_picWidthInLumaSamples (352) |
---|
1727 | , m_picHeightInLumaSamples (288) |
---|
1728 | , m_log2MinCodingBlockSize ( 0) |
---|
1729 | , m_log2DiffMaxMinCodingBlockSize (0) |
---|
1730 | , m_uiMaxCUWidth ( 32) |
---|
1731 | , m_uiMaxCUHeight ( 32) |
---|
1732 | , m_uiMaxCUDepth ( 3) |
---|
1733 | , m_bLongTermRefsPresent (false) |
---|
1734 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
1735 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
1736 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
1737 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
1738 | // Tool list |
---|
1739 | , m_usePCM (false) |
---|
1740 | , m_pcmLog2MaxSize ( 5) |
---|
1741 | , m_uiPCMLog2MinSize ( 7) |
---|
1742 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
1743 | , m_bUseLComb (false) |
---|
1744 | #endif |
---|
1745 | , m_bitDepthY ( 8) |
---|
1746 | , m_bitDepthC ( 8) |
---|
1747 | , m_qpBDOffsetY ( 0) |
---|
1748 | , m_qpBDOffsetC ( 0) |
---|
1749 | , m_useLossless (false) |
---|
1750 | , m_uiPCMBitDepthLuma ( 8) |
---|
1751 | , m_uiPCMBitDepthChroma ( 8) |
---|
1752 | , m_bPCMFilterDisableFlag (false) |
---|
1753 | , m_uiBitsForPOC ( 8) |
---|
1754 | , m_numLongTermRefPicSPS ( 0) |
---|
1755 | , m_uiMaxTrSize ( 32) |
---|
1756 | , m_bUseSAO (false) |
---|
1757 | , m_bTemporalIdNestingFlag (false) |
---|
1758 | , m_scalingListEnabledFlag (false) |
---|
1759 | , m_useStrongIntraSmoothing (false) |
---|
1760 | , m_vuiParametersPresentFlag (false) |
---|
1761 | , m_vuiParameters () |
---|
1762 | #if SVC_EXTENSION |
---|
1763 | , m_layerId(0) |
---|
1764 | #endif |
---|
1765 | { |
---|
1766 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
1767 | { |
---|
1768 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1769 | #if L0323_DPB |
---|
1770 | m_uiMaxDecPicBuffering[i] = 1; |
---|
1771 | #else |
---|
1772 | m_uiMaxDecPicBuffering[i] = 0; |
---|
1773 | #endif |
---|
1774 | m_numReorderPics[i] = 0; |
---|
1775 | } |
---|
1776 | m_scalingList = new TComScalingList; |
---|
1777 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
1778 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
1779 | } |
---|
1780 | |
---|
1781 | TComSPS::~TComSPS() |
---|
1782 | { |
---|
1783 | delete m_scalingList; |
---|
1784 | m_RPSList.destroy(); |
---|
1785 | } |
---|
1786 | |
---|
1787 | Void TComSPS::createRPSList( Int numRPS ) |
---|
1788 | { |
---|
1789 | m_RPSList.destroy(); |
---|
1790 | m_RPSList.create(numRPS); |
---|
1791 | } |
---|
1792 | |
---|
1793 | Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
1794 | { |
---|
1795 | if( !getVuiParametersPresentFlag() ) |
---|
1796 | { |
---|
1797 | return; |
---|
1798 | } |
---|
1799 | |
---|
1800 | TComVUI *vui = getVuiParameters(); |
---|
1801 | TComHRD *hrd = vui->getHrdParameters(); |
---|
1802 | |
---|
1803 | #if L0043_TIMING_INFO |
---|
1804 | TimingInfo *timingInfo = vui->getTimingInfo(); |
---|
1805 | timingInfo->setTimingInfoPresentFlag( true ); |
---|
1806 | switch( frameRate ) |
---|
1807 | { |
---|
1808 | case 24: |
---|
1809 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
1810 | break; |
---|
1811 | case 25: |
---|
1812 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
1813 | break; |
---|
1814 | case 30: |
---|
1815 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
---|
1816 | break; |
---|
1817 | case 50: |
---|
1818 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
1819 | break; |
---|
1820 | case 60: |
---|
1821 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
---|
1822 | break; |
---|
1823 | default: |
---|
1824 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
---|
1825 | break; |
---|
1826 | } |
---|
1827 | #else |
---|
1828 | hrd->setTimingInfoPresentFlag( true ); |
---|
1829 | switch( frameRate ) |
---|
1830 | { |
---|
1831 | case 24: |
---|
1832 | hrd->setNumUnitsInTick( 1125000 ); hrd->setTimeScale ( 27000000 ); |
---|
1833 | break; |
---|
1834 | case 25: |
---|
1835 | hrd->setNumUnitsInTick( 1080000 ); hrd->setTimeScale ( 27000000 ); |
---|
1836 | break; |
---|
1837 | case 30: |
---|
1838 | hrd->setNumUnitsInTick( 900900 ); hrd->setTimeScale ( 27000000 ); |
---|
1839 | break; |
---|
1840 | case 50: |
---|
1841 | hrd->setNumUnitsInTick( 540000 ); hrd->setTimeScale ( 27000000 ); |
---|
1842 | break; |
---|
1843 | case 60: |
---|
1844 | hrd->setNumUnitsInTick( 450450 ); hrd->setTimeScale ( 27000000 ); |
---|
1845 | break; |
---|
1846 | default: |
---|
1847 | hrd->setNumUnitsInTick( 1001 ); hrd->setTimeScale ( 60000 ); |
---|
1848 | break; |
---|
1849 | } |
---|
1850 | #endif |
---|
1851 | |
---|
1852 | Bool rateCnt = ( bitRate > 0 ); |
---|
1853 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
1854 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
1855 | |
---|
1856 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
1857 | |
---|
1858 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1859 | { |
---|
1860 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
1861 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
1862 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
1863 | #if L0044_DU_DPB_OUTPUT_DELAY_HRD |
---|
1864 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
1865 | #endif |
---|
1866 | } |
---|
1867 | else |
---|
1868 | { |
---|
1869 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
1870 | } |
---|
1871 | |
---|
1872 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
1873 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
1874 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
1875 | |
---|
1876 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
1877 | if( randomAccess ) |
---|
1878 | { |
---|
1879 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
1880 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
1881 | } |
---|
1882 | else |
---|
1883 | { |
---|
1884 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
1885 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
1886 | } |
---|
1887 | |
---|
1888 | /* |
---|
1889 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
1890 | */ |
---|
1891 | Int i, j; |
---|
1892 | UInt birateValue, cpbSizeValue; |
---|
1893 | UInt ducpbSizeValue; |
---|
1894 | #if L0363_DU_BIT_RATE |
---|
1895 | UInt duBitRateValue = 0; |
---|
1896 | #endif |
---|
1897 | |
---|
1898 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
1899 | { |
---|
1900 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
1901 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
1902 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
1903 | hrd->setCpbCntMinus1( i, 0 ); |
---|
1904 | |
---|
1905 | birateValue = bitRate; |
---|
1906 | cpbSizeValue = bitRate; // 1 second |
---|
1907 | ducpbSizeValue = bitRate/numDU; |
---|
1908 | #if L0363_DU_BIT_RATE |
---|
1909 | duBitRateValue = bitRate; |
---|
1910 | #endif |
---|
1911 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
1912 | { |
---|
1913 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
1914 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
1915 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
1916 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
1917 | |
---|
1918 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
1919 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
1920 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
1921 | #if L0363_DU_BIT_RATE |
---|
1922 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
1923 | #endif |
---|
1924 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
1925 | } |
---|
1926 | } |
---|
1927 | } |
---|
1928 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
1929 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
1930 | |
---|
1931 | TComPPS::TComPPS() |
---|
1932 | : m_PPSId (0) |
---|
1933 | , m_SPSId (0) |
---|
1934 | , m_picInitQPMinus26 (0) |
---|
1935 | , m_useDQP (false) |
---|
1936 | , m_bConstrainedIntraPred (false) |
---|
1937 | , m_bSliceChromaQpFlag (false) |
---|
1938 | , m_pcSPS (NULL) |
---|
1939 | , m_uiMaxCuDQPDepth (0) |
---|
1940 | , m_uiMinCuDQPSize (0) |
---|
1941 | , m_chromaCbQpOffset (0) |
---|
1942 | , m_chromaCrQpOffset (0) |
---|
1943 | , m_numRefIdxL0DefaultActive (1) |
---|
1944 | , m_numRefIdxL1DefaultActive (1) |
---|
1945 | , m_TransquantBypassEnableFlag (false) |
---|
1946 | , m_useTransformSkip (false) |
---|
1947 | , m_dependentSliceSegmentsEnabledFlag (false) |
---|
1948 | , m_tilesEnabledFlag (false) |
---|
1949 | , m_entropyCodingSyncEnabledFlag (false) |
---|
1950 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
1951 | , m_uniformSpacingFlag (0) |
---|
1952 | , m_iNumColumnsMinus1 (0) |
---|
1953 | , m_puiColumnWidth (NULL) |
---|
1954 | , m_iNumRowsMinus1 (0) |
---|
1955 | , m_puiRowHeight (NULL) |
---|
1956 | , m_iNumSubstreams (1) |
---|
1957 | , m_signHideFlag(0) |
---|
1958 | , m_cabacInitPresentFlag (false) |
---|
1959 | , m_encCABACTableIdx (I_SLICE) |
---|
1960 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
1961 | , m_loopFilterAcrossSlicesEnabledFlag (false) |
---|
1962 | , m_listsModificationPresentFlag( 0) |
---|
1963 | , m_numExtraSliceHeaderBits(0) |
---|
1964 | { |
---|
1965 | m_scalingList = new TComScalingList; |
---|
1966 | } |
---|
1967 | |
---|
1968 | TComPPS::~TComPPS() |
---|
1969 | { |
---|
1970 | if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
1971 | { |
---|
1972 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
1973 | m_puiColumnWidth = NULL; |
---|
1974 | } |
---|
1975 | if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
1976 | { |
---|
1977 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
1978 | m_puiRowHeight = NULL; |
---|
1979 | } |
---|
1980 | delete m_scalingList; |
---|
1981 | } |
---|
1982 | |
---|
1983 | TComReferencePictureSet::TComReferencePictureSet() |
---|
1984 | : m_numberOfPictures (0) |
---|
1985 | , m_numberOfNegativePictures (0) |
---|
1986 | , m_numberOfPositivePictures (0) |
---|
1987 | , m_numberOfLongtermPictures (0) |
---|
1988 | , m_interRPSPrediction (0) |
---|
1989 | , m_deltaRIdxMinus1 (0) |
---|
1990 | , m_deltaRPS (0) |
---|
1991 | , m_numRefIdc (0) |
---|
1992 | { |
---|
1993 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
1994 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
1995 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
1996 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
1997 | } |
---|
1998 | |
---|
1999 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
2000 | { |
---|
2001 | } |
---|
2002 | |
---|
2003 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
2004 | { |
---|
2005 | m_used[bufferNum] = used; |
---|
2006 | } |
---|
2007 | |
---|
2008 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
2009 | { |
---|
2010 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
2011 | } |
---|
2012 | |
---|
2013 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
2014 | { |
---|
2015 | m_numberOfPictures = numberOfPictures; |
---|
2016 | } |
---|
2017 | |
---|
2018 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
2019 | { |
---|
2020 | return m_used[bufferNum]; |
---|
2021 | } |
---|
2022 | |
---|
2023 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
2024 | { |
---|
2025 | return m_deltaPOC[bufferNum]; |
---|
2026 | } |
---|
2027 | |
---|
2028 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
2029 | { |
---|
2030 | return m_numberOfPictures; |
---|
2031 | } |
---|
2032 | |
---|
2033 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
2034 | { |
---|
2035 | return m_POC[bufferNum]; |
---|
2036 | } |
---|
2037 | |
---|
2038 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
2039 | { |
---|
2040 | m_POC[bufferNum] = POC; |
---|
2041 | } |
---|
2042 | |
---|
2043 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) |
---|
2044 | { |
---|
2045 | return m_bCheckLTMSB[bufferNum]; |
---|
2046 | } |
---|
2047 | |
---|
2048 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
2049 | { |
---|
2050 | m_bCheckLTMSB[bufferNum] = b; |
---|
2051 | } |
---|
2052 | |
---|
2053 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
2054 | * \param uiBufferNum |
---|
2055 | * \param iRefIdc |
---|
2056 | * \returns Void |
---|
2057 | */ |
---|
2058 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
2059 | { |
---|
2060 | m_refIdc[bufferNum] = refIdc; |
---|
2061 | } |
---|
2062 | |
---|
2063 | /** get the reference idc value at uiBufferNum |
---|
2064 | * \param uiBufferNum |
---|
2065 | * \returns Int |
---|
2066 | */ |
---|
2067 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
2068 | { |
---|
2069 | return m_refIdc[bufferNum]; |
---|
2070 | } |
---|
2071 | |
---|
2072 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
2073 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
2074 | * +ve values are in increasing order. |
---|
2075 | * \returns Void |
---|
2076 | */ |
---|
2077 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
2078 | { |
---|
2079 | // sort in increasing order (smallest first) |
---|
2080 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
2081 | { |
---|
2082 | Int deltaPOC = getDeltaPOC(j); |
---|
2083 | Bool used = getUsed(j); |
---|
2084 | for (Int k=j-1; k >= 0; k--) |
---|
2085 | { |
---|
2086 | Int temp = getDeltaPOC(k); |
---|
2087 | if (deltaPOC < temp) |
---|
2088 | { |
---|
2089 | setDeltaPOC(k+1, temp); |
---|
2090 | setUsed(k+1, getUsed(k)); |
---|
2091 | setDeltaPOC(k, deltaPOC); |
---|
2092 | setUsed(k, used); |
---|
2093 | } |
---|
2094 | } |
---|
2095 | } |
---|
2096 | // flip the negative values to largest first |
---|
2097 | Int numNegPics = getNumberOfNegativePictures(); |
---|
2098 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
2099 | { |
---|
2100 | Int deltaPOC = getDeltaPOC(j); |
---|
2101 | Bool used = getUsed(j); |
---|
2102 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
2103 | setUsed(j, getUsed(k)); |
---|
2104 | setDeltaPOC(k, deltaPOC); |
---|
2105 | setUsed(k, used); |
---|
2106 | } |
---|
2107 | } |
---|
2108 | |
---|
2109 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
2110 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
2111 | * \returns Void |
---|
2112 | */ |
---|
2113 | Void TComReferencePictureSet::printDeltaPOC() |
---|
2114 | { |
---|
2115 | printf("DeltaPOC = { "); |
---|
2116 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
2117 | { |
---|
2118 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
2119 | } |
---|
2120 | if (getInterRPSPrediction()) |
---|
2121 | { |
---|
2122 | printf("}, RefIdc = { "); |
---|
2123 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
2124 | { |
---|
2125 | printf("%d ", getRefIdc(j)); |
---|
2126 | } |
---|
2127 | } |
---|
2128 | printf("}\n"); |
---|
2129 | } |
---|
2130 | |
---|
2131 | TComRPSList::TComRPSList() |
---|
2132 | :m_referencePictureSets (NULL) |
---|
2133 | { |
---|
2134 | } |
---|
2135 | |
---|
2136 | TComRPSList::~TComRPSList() |
---|
2137 | { |
---|
2138 | } |
---|
2139 | |
---|
2140 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
2141 | { |
---|
2142 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
2143 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
2144 | } |
---|
2145 | |
---|
2146 | Void TComRPSList::destroy() |
---|
2147 | { |
---|
2148 | if (m_referencePictureSets) |
---|
2149 | { |
---|
2150 | delete [] m_referencePictureSets; |
---|
2151 | } |
---|
2152 | m_numberOfReferencePictureSets = 0; |
---|
2153 | m_referencePictureSets = NULL; |
---|
2154 | } |
---|
2155 | |
---|
2156 | |
---|
2157 | |
---|
2158 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
2159 | { |
---|
2160 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
2161 | } |
---|
2162 | |
---|
2163 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
2164 | { |
---|
2165 | return m_numberOfReferencePictureSets; |
---|
2166 | } |
---|
2167 | |
---|
2168 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
2169 | { |
---|
2170 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
2171 | } |
---|
2172 | |
---|
2173 | TComRefPicListModification::TComRefPicListModification() |
---|
2174 | : m_bRefPicListModificationFlagL0 (false) |
---|
2175 | , m_bRefPicListModificationFlagL1 (false) |
---|
2176 | { |
---|
2177 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
2178 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
2179 | } |
---|
2180 | |
---|
2181 | TComRefPicListModification::~TComRefPicListModification() |
---|
2182 | { |
---|
2183 | } |
---|
2184 | |
---|
2185 | TComScalingList::TComScalingList() |
---|
2186 | { |
---|
2187 | m_useTransformSkip = false; |
---|
2188 | init(); |
---|
2189 | } |
---|
2190 | TComScalingList::~TComScalingList() |
---|
2191 | { |
---|
2192 | destroy(); |
---|
2193 | } |
---|
2194 | |
---|
2195 | /** set default quantization matrix to array |
---|
2196 | */ |
---|
2197 | Void TComSlice::setDefaultScalingList() |
---|
2198 | { |
---|
2199 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2200 | { |
---|
2201 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
2202 | { |
---|
2203 | getScalingList()->processDefaultMarix(sizeId, listId); |
---|
2204 | } |
---|
2205 | } |
---|
2206 | } |
---|
2207 | /** check if use default quantization matrix |
---|
2208 | * \returns true if use default quantization matrix in all size |
---|
2209 | */ |
---|
2210 | Bool TComSlice::checkDefaultScalingList() |
---|
2211 | { |
---|
2212 | UInt defaultCounter=0; |
---|
2213 | |
---|
2214 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2215 | { |
---|
2216 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
2217 | { |
---|
2218 | 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 |
---|
2219 | && ((sizeId < SCALING_LIST_16x16) || (getScalingList()->getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
2220 | { |
---|
2221 | defaultCounter++; |
---|
2222 | } |
---|
2223 | } |
---|
2224 | } |
---|
2225 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32 |
---|
2226 | } |
---|
2227 | |
---|
2228 | /** get scaling matrix from RefMatrixID |
---|
2229 | * \param sizeId size index |
---|
2230 | * \param Index of input matrix |
---|
2231 | * \param Index of reference matrix |
---|
2232 | */ |
---|
2233 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
2234 | { |
---|
2235 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2236 | } |
---|
2237 | |
---|
2238 | /** parse syntax infomation |
---|
2239 | * \param pchFile syntax infomation |
---|
2240 | * \returns false if successful |
---|
2241 | */ |
---|
2242 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
2243 | { |
---|
2244 | FILE *fp; |
---|
2245 | Char line[1024]; |
---|
2246 | UInt sizeIdc,listIdc; |
---|
2247 | UInt i,size = 0; |
---|
2248 | Int *src=0,data; |
---|
2249 | Char *ret; |
---|
2250 | UInt retval; |
---|
2251 | |
---|
2252 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
2253 | { |
---|
2254 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
2255 | return true; |
---|
2256 | } |
---|
2257 | |
---|
2258 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
2259 | { |
---|
2260 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
2261 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
2262 | { |
---|
2263 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
2264 | |
---|
2265 | fseek(fp,0,0); |
---|
2266 | do |
---|
2267 | { |
---|
2268 | ret = fgets(line, 1024, fp); |
---|
2269 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
2270 | { |
---|
2271 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2272 | return true; |
---|
2273 | } |
---|
2274 | } |
---|
2275 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
2276 | for (i=0; i<size; i++) |
---|
2277 | { |
---|
2278 | retval = fscanf(fp, "%d,", &data); |
---|
2279 | if (retval!=1) |
---|
2280 | { |
---|
2281 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2282 | return true; |
---|
2283 | } |
---|
2284 | src[i] = data; |
---|
2285 | } |
---|
2286 | //set DC value for default matrix check |
---|
2287 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
2288 | |
---|
2289 | if(sizeIdc > SCALING_LIST_8x8) |
---|
2290 | { |
---|
2291 | fseek(fp,0,0); |
---|
2292 | do |
---|
2293 | { |
---|
2294 | ret = fgets(line, 1024, fp); |
---|
2295 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
2296 | { |
---|
2297 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
2298 | return true; |
---|
2299 | } |
---|
2300 | } |
---|
2301 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
2302 | retval = fscanf(fp, "%d,", &data); |
---|
2303 | if (retval!=1) |
---|
2304 | { |
---|
2305 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2306 | return true; |
---|
2307 | } |
---|
2308 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
2309 | setScalingListDC(sizeIdc,listIdc,data); |
---|
2310 | } |
---|
2311 | } |
---|
2312 | } |
---|
2313 | fclose(fp); |
---|
2314 | return false; |
---|
2315 | } |
---|
2316 | |
---|
2317 | /** initialization process of quantization matrix array |
---|
2318 | */ |
---|
2319 | Void TComScalingList::init() |
---|
2320 | { |
---|
2321 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2322 | { |
---|
2323 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2324 | { |
---|
2325 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
2326 | } |
---|
2327 | } |
---|
2328 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
2329 | } |
---|
2330 | |
---|
2331 | /** destroy quantization matrix array |
---|
2332 | */ |
---|
2333 | Void TComScalingList::destroy() |
---|
2334 | { |
---|
2335 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2336 | { |
---|
2337 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2338 | { |
---|
2339 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
2340 | } |
---|
2341 | } |
---|
2342 | } |
---|
2343 | |
---|
2344 | /** get default address of quantization matrix |
---|
2345 | * \param sizeId size index |
---|
2346 | * \param listId list index |
---|
2347 | * \returns pointer of quantization matrix |
---|
2348 | */ |
---|
2349 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
2350 | { |
---|
2351 | Int *src = 0; |
---|
2352 | switch(sizeId) |
---|
2353 | { |
---|
2354 | case SCALING_LIST_4x4: |
---|
2355 | src = g_quantTSDefault4x4; |
---|
2356 | break; |
---|
2357 | case SCALING_LIST_8x8: |
---|
2358 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2359 | break; |
---|
2360 | case SCALING_LIST_16x16: |
---|
2361 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2362 | break; |
---|
2363 | case SCALING_LIST_32x32: |
---|
2364 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2365 | break; |
---|
2366 | default: |
---|
2367 | assert(0); |
---|
2368 | src = NULL; |
---|
2369 | break; |
---|
2370 | } |
---|
2371 | return src; |
---|
2372 | } |
---|
2373 | |
---|
2374 | /** process of default matrix |
---|
2375 | * \param sizeId size index |
---|
2376 | * \param Index of input matrix |
---|
2377 | */ |
---|
2378 | Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId) |
---|
2379 | { |
---|
2380 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2381 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
2382 | } |
---|
2383 | |
---|
2384 | /** check DC value of matrix for default matrix signaling |
---|
2385 | */ |
---|
2386 | Void TComScalingList::checkDcOfMatrix() |
---|
2387 | { |
---|
2388 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2389 | { |
---|
2390 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2391 | { |
---|
2392 | //check default matrix? |
---|
2393 | if(getScalingListDC(sizeId,listId) == 0) |
---|
2394 | { |
---|
2395 | processDefaultMarix(sizeId, listId); |
---|
2396 | } |
---|
2397 | } |
---|
2398 | } |
---|
2399 | } |
---|
2400 | |
---|
2401 | ParameterSetManager::ParameterSetManager() |
---|
2402 | #if SVC_EXTENSION |
---|
2403 | : m_spsMap(MAX_NUM_SPS) |
---|
2404 | , m_ppsMap(MAX_NUM_PPS) |
---|
2405 | , m_activeSPSId(-1) |
---|
2406 | , m_activePPSId(-1) |
---|
2407 | #else |
---|
2408 | : m_vpsMap(MAX_NUM_VPS) |
---|
2409 | , m_spsMap(MAX_NUM_SPS) |
---|
2410 | , m_ppsMap(MAX_NUM_PPS) |
---|
2411 | , m_activeVPSId(-1) |
---|
2412 | , m_activeSPSId(-1) |
---|
2413 | , m_activePPSId(-1) |
---|
2414 | #endif |
---|
2415 | { |
---|
2416 | } |
---|
2417 | |
---|
2418 | |
---|
2419 | ParameterSetManager::~ParameterSetManager() |
---|
2420 | { |
---|
2421 | } |
---|
2422 | |
---|
2423 | //! activate a SPS from a active parameter sets SEI message |
---|
2424 | //! \returns true, if activation is successful |
---|
2425 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
2426 | { |
---|
2427 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
2428 | if (sps) |
---|
2429 | { |
---|
2430 | Int vpsId = sps->getVPSId(); |
---|
2431 | if (m_vpsMap.getPS(vpsId)) |
---|
2432 | { |
---|
2433 | m_activeVPSId = vpsId; |
---|
2434 | m_activeSPSId = spsId; |
---|
2435 | return true; |
---|
2436 | } |
---|
2437 | else |
---|
2438 | { |
---|
2439 | printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
2440 | } |
---|
2441 | } |
---|
2442 | else |
---|
2443 | { |
---|
2444 | printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
2445 | } |
---|
2446 | return false; |
---|
2447 | } |
---|
2448 | |
---|
2449 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
2450 | //! \returns true, if activation is successful |
---|
2451 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
2452 | { |
---|
2453 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
2454 | if (pps) |
---|
2455 | { |
---|
2456 | Int spsId = pps->getSPSId(); |
---|
2457 | if (!isIRAP && (spsId != m_activeSPSId)) |
---|
2458 | { |
---|
2459 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IRAP."); |
---|
2460 | return false; |
---|
2461 | } |
---|
2462 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
2463 | if (sps) |
---|
2464 | { |
---|
2465 | Int vpsId = sps->getVPSId(); |
---|
2466 | if (!isIRAP && (vpsId != m_activeVPSId)) |
---|
2467 | { |
---|
2468 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IRAP."); |
---|
2469 | return false; |
---|
2470 | } |
---|
2471 | if (m_vpsMap.getPS(vpsId)) |
---|
2472 | { |
---|
2473 | m_activePPSId = ppsId; |
---|
2474 | m_activeVPSId = vpsId; |
---|
2475 | m_activeSPSId = spsId; |
---|
2476 | return true; |
---|
2477 | } |
---|
2478 | else |
---|
2479 | { |
---|
2480 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
2481 | } |
---|
2482 | } |
---|
2483 | else |
---|
2484 | { |
---|
2485 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
2486 | } |
---|
2487 | } |
---|
2488 | else |
---|
2489 | { |
---|
2490 | printf("Warning: tried to activate non-existing PPS."); |
---|
2491 | } |
---|
2492 | return false; |
---|
2493 | } |
---|
2494 | |
---|
2495 | ProfileTierLevel::ProfileTierLevel() |
---|
2496 | : m_profileSpace (0) |
---|
2497 | , m_tierFlag (false) |
---|
2498 | , m_profileIdc (0) |
---|
2499 | , m_levelIdc (0) |
---|
2500 | #if L0046_CONSTRAINT_FLAGS |
---|
2501 | , m_progressiveSourceFlag (false) |
---|
2502 | , m_interlacedSourceFlag (false) |
---|
2503 | , m_nonPackedConstraintFlag(false) |
---|
2504 | , m_frameOnlyConstraintFlag(false) |
---|
2505 | #endif |
---|
2506 | { |
---|
2507 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
2508 | } |
---|
2509 | #if VPS_EXTN_PROFILE_INFO |
---|
2510 | Void ProfileTierLevel::copyProfileInfo(ProfileTierLevel *ptl) |
---|
2511 | { |
---|
2512 | this->setProfileSpace ( ptl->getProfileSpace() ); |
---|
2513 | this->setTierFlag ( ptl->getTierFlag() ); |
---|
2514 | this->setProfileIdc ( ptl->getProfileIdc() ); |
---|
2515 | for(Int j = 0; j < 32; j++) |
---|
2516 | { |
---|
2517 | this->setProfileCompatibilityFlag(j, ptl->getProfileCompatibilityFlag(j)); |
---|
2518 | } |
---|
2519 | this->setProgressiveSourceFlag ( ptl->getProgressiveSourceFlag() ); |
---|
2520 | this->setInterlacedSourceFlag ( ptl->getInterlacedSourceFlag() ); |
---|
2521 | this->setNonPackedConstraintFlag( ptl->getNonPackedConstraintFlag()); |
---|
2522 | this->setFrameOnlyConstraintFlag( ptl->getFrameOnlyConstraintFlag()); |
---|
2523 | } |
---|
2524 | #endif |
---|
2525 | |
---|
2526 | TComPTL::TComPTL() |
---|
2527 | { |
---|
2528 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
2529 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
2530 | } |
---|
2531 | #if VPS_EXTN_PROFILE_INFO |
---|
2532 | Void TComPTL::copyProfileInfo(TComPTL *ptl) |
---|
2533 | { |
---|
2534 | // Copy all information related to general profile |
---|
2535 | this->getGeneralPTL()->copyProfileInfo(ptl->getGeneralPTL()); |
---|
2536 | } |
---|
2537 | #endif |
---|
2538 | #if SIGNAL_BITRATE_PICRATE_IN_VPS |
---|
2539 | TComBitRatePicRateInfo::TComBitRatePicRateInfo() |
---|
2540 | { |
---|
2541 | ::memset(m_bitRateInfoPresentFlag, 0, sizeof(m_bitRateInfoPresentFlag)); |
---|
2542 | ::memset(m_picRateInfoPresentFlag, 0, sizeof(m_picRateInfoPresentFlag)); |
---|
2543 | ::memset(m_avgBitRate, 0, sizeof(m_avgBitRate)); |
---|
2544 | ::memset(m_maxBitRate, 0, sizeof(m_maxBitRate)); |
---|
2545 | ::memset(m_constantPicRateIdc, 0, sizeof(m_constantPicRateIdc)); |
---|
2546 | ::memset(m_avgPicRate, 0, sizeof(m_avgPicRate)); |
---|
2547 | } |
---|
2548 | #endif |
---|
2549 | |
---|
2550 | #if SVC_EXTENSION |
---|
2551 | #if AVC_SYNTAX |
---|
2552 | Void TComSlice::initBaseLayerRPL( TComSlice *pcSlice ) |
---|
2553 | { |
---|
2554 | // 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 |
---|
2555 | setPOC( pcSlice->getPOC() ); |
---|
2556 | if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) |
---|
2557 | { |
---|
2558 | setSliceType( I_SLICE ); |
---|
2559 | } |
---|
2560 | else |
---|
2561 | { |
---|
2562 | setSliceType( pcSlice->getSliceType() ); |
---|
2563 | } |
---|
2564 | |
---|
2565 | if( this->isIntra() ) |
---|
2566 | { |
---|
2567 | return; |
---|
2568 | } |
---|
2569 | |
---|
2570 | //initialize reference POC of BL |
---|
2571 | for( Int iRefPicList = 0; iRefPicList < 2; iRefPicList++ ) |
---|
2572 | { |
---|
2573 | RefPicList eRefPicList = RefPicList( iRefPicList ); |
---|
2574 | |
---|
2575 | assert( pcSlice->getNumRefIdx( eRefPicList) >= 0 ); |
---|
2576 | setNumRefIdx( eRefPicList, pcSlice->getNumRefIdx( eRefPicList ) - 1 ); |
---|
2577 | assert( getNumRefIdx( eRefPicList) <= MAX_NUM_REF); |
---|
2578 | |
---|
2579 | for(Int refIdx = 0; refIdx < getNumRefIdx( eRefPicList ); refIdx++) |
---|
2580 | { |
---|
2581 | setRefPOC( pcSlice->getRefPic( eRefPicList, refIdx )->getPOC(), eRefPicList, refIdx ); |
---|
2582 | setRefPic( pcSlice->getRefPic( eRefPicList, refIdx ), eRefPicList, refIdx ); |
---|
2583 | /* |
---|
2584 | // should be set if the base layer has its own instance of the reference picture lists, currently EL RPL is reused. |
---|
2585 | getRefPic( eRefPicList, refIdx )->setLayerId( 0 ); |
---|
2586 | getRefPic( eRefPicList, refIdx )->setIsLongTerm( pcSlice->getRefPic( eRefPicList, refIdx )->getIsLongTerm() ); |
---|
2587 | */ |
---|
2588 | |
---|
2589 | } |
---|
2590 | } |
---|
2591 | return; |
---|
2592 | } |
---|
2593 | #endif |
---|
2594 | |
---|
2595 | Void TComSlice::setBaseColPic( TComList<TComPic*>& rcListPic, UInt layerID ) |
---|
2596 | { |
---|
2597 | if (layerID == 0) |
---|
2598 | { |
---|
2599 | m_pcBaseColPic = NULL; |
---|
2600 | return; |
---|
2601 | } |
---|
2602 | setBaseColPic(xGetRefPic(rcListPic, getPOC())); |
---|
2603 | } |
---|
2604 | #endif |
---|
2605 | |
---|
2606 | #if REF_IDX_MFM |
---|
2607 | Void TComSlice::setRefPOCListILP( TComPic** ilpPic, TComPic *pcRefPicBL ) |
---|
2608 | { |
---|
2609 | //set reference picture POC of each ILP reference |
---|
2610 | Int thePoc = ilpPic[0]->getPOC(); |
---|
2611 | assert(thePoc >= 0); |
---|
2612 | assert(thePoc == pcRefPicBL->getPOC()); |
---|
2613 | |
---|
2614 | ilpPic[0]->getSlice(0)->setBaseColPic( pcRefPicBL ); |
---|
2615 | |
---|
2616 | //copy reference pictures marking from the reference layer |
---|
2617 | ilpPic[0]->getSlice(0)->copySliceInfo(pcRefPicBL->getSlice(0)); |
---|
2618 | |
---|
2619 | for( Int refList = 0; refList < 2; refList++ ) |
---|
2620 | { |
---|
2621 | RefPicList refPicList = RefPicList( refList ); |
---|
2622 | |
---|
2623 | //set reference POC of ILP |
---|
2624 | ilpPic[0]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList)); |
---|
2625 | assert(ilpPic[0]->getSlice(0)->getNumRefIdx(refPicList) >= 0); |
---|
2626 | assert(ilpPic[0]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF); |
---|
2627 | |
---|
2628 | //initialize reference POC of ILP |
---|
2629 | for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++) |
---|
2630 | { |
---|
2631 | ilpPic[0]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx); |
---|
2632 | ilpPic[0]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx); |
---|
2633 | } |
---|
2634 | |
---|
2635 | for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++) |
---|
2636 | { |
---|
2637 | ilpPic[0]->getSlice(0)->setRefPOC(0, refPicList, refIdx); |
---|
2638 | ilpPic[0]->getSlice(0)->setRefPic(NULL, refPicList, refIdx); |
---|
2639 | } |
---|
2640 | } |
---|
2641 | return; |
---|
2642 | } |
---|
2643 | #endif |
---|
2644 | |
---|
2645 | //! \} |
---|