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