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-2012, 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 ) |
---|
52 | , m_eSliceType ( I_SLICE ) |
---|
53 | , m_iSliceQp ( 0 ) |
---|
54 | #if SLICEHEADER_SYNTAX_FIX |
---|
55 | , m_dependentSliceFlag ( false ) |
---|
56 | #endif |
---|
57 | #if ADAPTIVE_QP_SELECTION |
---|
58 | , m_iSliceQpBase ( 0 ) |
---|
59 | #endif |
---|
60 | , m_deblockingFilterDisable ( false ) |
---|
61 | , m_deblockingFilterOverrideFlag ( false ) |
---|
62 | , m_deblockingFilterBetaOffsetDiv2 ( 0 ) |
---|
63 | , m_deblockingFilterTcOffsetDiv2 ( 0 ) |
---|
64 | , m_bRefPicListModificationFlagLC ( false ) |
---|
65 | , m_bRefPicListCombinationFlag ( false ) |
---|
66 | , m_bCheckLDC ( false ) |
---|
67 | , m_iSliceQpDelta ( 0 ) |
---|
68 | #if CHROMA_QP_EXTENSION |
---|
69 | , m_iSliceQpDeltaCb ( 0 ) |
---|
70 | , m_iSliceQpDeltaCr ( 0 ) |
---|
71 | #endif |
---|
72 | , m_iDepth ( 0 ) |
---|
73 | , m_bRefenced ( false ) |
---|
74 | , m_pcSPS ( NULL ) |
---|
75 | , m_pcPPS ( NULL ) |
---|
76 | , m_pcPic ( NULL ) |
---|
77 | , m_colFromL0Flag ( 1 ) |
---|
78 | , m_colRefIdx ( 0 ) |
---|
79 | #if ALF_CHROMA_LAMBDA || SAO_CHROMA_LAMBDA |
---|
80 | , m_dLambdaLuma( 0.0 ) |
---|
81 | , m_dLambdaChroma( 0.0 ) |
---|
82 | #else |
---|
83 | , m_dLambda ( 0.0 ) |
---|
84 | #endif |
---|
85 | , m_bNoBackPredFlag ( false ) |
---|
86 | , m_uiTLayer ( 0 ) |
---|
87 | #if SVC_EXTENSION |
---|
88 | , m_layerId ( 0 ) |
---|
89 | , m_pcBaseColPic ( NULL ) |
---|
90 | #endif |
---|
91 | , m_bTLayerSwitchingFlag ( false ) |
---|
92 | , m_uiSliceMode ( 0 ) |
---|
93 | , m_uiSliceArgument ( 0 ) |
---|
94 | , m_uiSliceCurStartCUAddr ( 0 ) |
---|
95 | , m_uiSliceCurEndCUAddr ( 0 ) |
---|
96 | , m_uiSliceIdx ( 0 ) |
---|
97 | , m_uiDependentSliceMode ( 0 ) |
---|
98 | , m_uiDependentSliceArgument ( 0 ) |
---|
99 | , m_uiDependentSliceCurStartCUAddr ( 0 ) |
---|
100 | , m_uiDependentSliceCurEndCUAddr ( 0 ) |
---|
101 | , m_bNextSlice ( false ) |
---|
102 | , m_bNextDependentSlice ( false ) |
---|
103 | , m_uiSliceBits ( 0 ) |
---|
104 | , m_uiDependentSliceCounter ( 0 ) |
---|
105 | , m_bFinalized ( false ) |
---|
106 | , m_uiTileOffstForMultES ( 0 ) |
---|
107 | , m_puiSubstreamSizes ( NULL ) |
---|
108 | , m_cabacInitFlag ( false ) |
---|
109 | , m_bLMvdL1Zero ( false ) |
---|
110 | , m_numEntryPointOffsets ( 0 ) |
---|
111 | #if TEMPORAL_LAYER_NON_REFERENCE |
---|
112 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
113 | #endif |
---|
114 | #if !REMOVE_NAL_REF_FLAG |
---|
115 | , m_nalRefFlag ( 0 ) |
---|
116 | #endif |
---|
117 | , m_enableTMVPFlag ( true ) |
---|
118 | { |
---|
119 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = m_aiNumRefIdx[2] = 0; |
---|
120 | |
---|
121 | initEqualRef(); |
---|
122 | |
---|
123 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++) |
---|
124 | { |
---|
125 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1; |
---|
126 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1; |
---|
127 | m_eListIdFromIdxOfLC[iNumCount]=0; |
---|
128 | m_iRefIdxFromIdxOfLC[iNumCount]=0; |
---|
129 | m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1; |
---|
130 | m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1; |
---|
131 | } |
---|
132 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
133 | { |
---|
134 | m_apcRefPicList [0][iNumCount] = NULL; |
---|
135 | m_apcRefPicList [1][iNumCount] = NULL; |
---|
136 | m_aiRefPOCList [0][iNumCount] = 0; |
---|
137 | m_aiRefPOCList [1][iNumCount] = 0; |
---|
138 | } |
---|
139 | m_bCombineWithReferenceFlag = 0; |
---|
140 | resetWpScaling(m_weightPredTable); |
---|
141 | initWpAcDcParam(); |
---|
142 | m_saoEnabledFlag = false; |
---|
143 | #if !REMOVE_ALF |
---|
144 | m_alfEnabledFlag[0] = m_alfEnabledFlag[1] = m_alfEnabledFlag[2] = false; |
---|
145 | #endif |
---|
146 | } |
---|
147 | |
---|
148 | TComSlice::~TComSlice() |
---|
149 | { |
---|
150 | delete[] m_puiSubstreamSizes; |
---|
151 | m_puiSubstreamSizes = NULL; |
---|
152 | } |
---|
153 | |
---|
154 | |
---|
155 | Void TComSlice::initSlice() |
---|
156 | { |
---|
157 | m_aiNumRefIdx[0] = 0; |
---|
158 | m_aiNumRefIdx[1] = 0; |
---|
159 | |
---|
160 | m_colFromL0Flag = 1; |
---|
161 | |
---|
162 | m_colRefIdx = 0; |
---|
163 | initEqualRef(); |
---|
164 | m_bNoBackPredFlag = false; |
---|
165 | m_bRefPicListCombinationFlag = false; |
---|
166 | m_bRefPicListModificationFlagLC = false; |
---|
167 | m_bCheckLDC = false; |
---|
168 | #if CHROMA_QP_EXTENSION |
---|
169 | m_iSliceQpDeltaCb = 0; |
---|
170 | m_iSliceQpDeltaCr = 0; |
---|
171 | #endif |
---|
172 | |
---|
173 | m_aiNumRefIdx[REF_PIC_LIST_C] = 0; |
---|
174 | |
---|
175 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
176 | |
---|
177 | m_bFinalized=false; |
---|
178 | |
---|
179 | m_tileByteLocation.clear(); |
---|
180 | m_cabacInitFlag = false; |
---|
181 | m_numEntryPointOffsets = 0; |
---|
182 | m_enableTMVPFlag = true; |
---|
183 | } |
---|
184 | |
---|
185 | Bool TComSlice::getRapPicFlag() |
---|
186 | { |
---|
187 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR |
---|
188 | #if SUPPORT_FOR_RAP_N_LP |
---|
189 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
190 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
191 | #endif |
---|
192 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT |
---|
193 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA |
---|
194 | #if !NAL_UNIT_TYPES_J1003_D7 |
---|
195 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRANT |
---|
196 | #endif |
---|
197 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
198 | } |
---|
199 | |
---|
200 | /** |
---|
201 | - allocate table to contain substream sizes to be written to the slice header. |
---|
202 | . |
---|
203 | \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1. |
---|
204 | */ |
---|
205 | Void TComSlice::allocSubstreamSizes(UInt uiNumSubstreams) |
---|
206 | { |
---|
207 | delete[] m_puiSubstreamSizes; |
---|
208 | m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0]; |
---|
209 | } |
---|
210 | |
---|
211 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
212 | { |
---|
213 | TComPic* pcPicExtract; |
---|
214 | TComPic* pcPicInsert; |
---|
215 | |
---|
216 | TComList<TComPic*>::iterator iterPicExtract; |
---|
217 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
218 | TComList<TComPic*>::iterator iterPicInsert; |
---|
219 | |
---|
220 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
221 | { |
---|
222 | iterPicExtract = rcListPic.begin(); |
---|
223 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
224 | pcPicExtract = *(iterPicExtract); |
---|
225 | pcPicExtract->setCurrSliceIdx(0); |
---|
226 | |
---|
227 | iterPicInsert = rcListPic.begin(); |
---|
228 | while (iterPicInsert != iterPicExtract) |
---|
229 | { |
---|
230 | pcPicInsert = *(iterPicInsert); |
---|
231 | pcPicInsert->setCurrSliceIdx(0); |
---|
232 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
233 | { |
---|
234 | break; |
---|
235 | } |
---|
236 | |
---|
237 | iterPicInsert++; |
---|
238 | } |
---|
239 | |
---|
240 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
241 | |
---|
242 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
243 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
244 | rcListPic.erase (iterPicExtract); |
---|
245 | } |
---|
246 | } |
---|
247 | |
---|
248 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, |
---|
249 | UInt uiPOC) |
---|
250 | { |
---|
251 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
252 | TComPic* pcPic = *(iterPic); |
---|
253 | while ( iterPic != rcListPic.end() ) |
---|
254 | { |
---|
255 | if(pcPic->getPOC() == uiPOC) |
---|
256 | { |
---|
257 | break; |
---|
258 | } |
---|
259 | iterPic++; |
---|
260 | pcPic = *(iterPic); |
---|
261 | } |
---|
262 | return pcPic; |
---|
263 | } |
---|
264 | |
---|
265 | |
---|
266 | TComPic* TComSlice::xGetLongTermRefPic (TComList<TComPic*>& rcListPic, |
---|
267 | UInt uiPOC) |
---|
268 | { |
---|
269 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
270 | TComPic* pcPic = *(iterPic); |
---|
271 | TComPic* pcStPic = pcPic; |
---|
272 | while ( iterPic != rcListPic.end() ) |
---|
273 | { |
---|
274 | pcPic = *(iterPic); |
---|
275 | if(pcPic && (pcPic->getPOC()%(1<<getSPS()->getBitsForPOC())) == (uiPOC%(1<<getSPS()->getBitsForPOC()))) |
---|
276 | { |
---|
277 | if(pcPic->getIsLongTerm()) |
---|
278 | { |
---|
279 | return pcPic; |
---|
280 | } |
---|
281 | else |
---|
282 | { |
---|
283 | pcStPic = pcPic; |
---|
284 | } |
---|
285 | break; |
---|
286 | } |
---|
287 | |
---|
288 | iterPic++; |
---|
289 | } |
---|
290 | return pcStPic; |
---|
291 | } |
---|
292 | |
---|
293 | Void TComSlice::setRefPOCList () |
---|
294 | { |
---|
295 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
296 | { |
---|
297 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
298 | { |
---|
299 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
300 | } |
---|
301 | } |
---|
302 | |
---|
303 | } |
---|
304 | |
---|
305 | Void TComSlice::generateCombinedList() |
---|
306 | { |
---|
307 | if(m_aiNumRefIdx[REF_PIC_LIST_C] > 0) |
---|
308 | { |
---|
309 | m_aiNumRefIdx[REF_PIC_LIST_C]=0; |
---|
310 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++) |
---|
311 | { |
---|
312 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1; |
---|
313 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1; |
---|
314 | m_eListIdFromIdxOfLC[iNumCount]=0; |
---|
315 | m_iRefIdxFromIdxOfLC[iNumCount]=0; |
---|
316 | m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1; |
---|
317 | m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1; |
---|
318 | } |
---|
319 | |
---|
320 | for (Int iNumRefIdx = 0; iNumRefIdx < MAX_NUM_REF; iNumRefIdx++) |
---|
321 | { |
---|
322 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_0]) |
---|
323 | { |
---|
324 | Bool bTempRefIdxInL2 = true; |
---|
325 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
326 | { |
---|
327 | if ( m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) |
---|
328 | { |
---|
329 | m_iRefIdxOfL1FromRefIdxOfL0[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
330 | m_iRefIdxOfL0FromRefIdxOfL1[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
331 | bTempRefIdxInL2 = false; |
---|
332 | break; |
---|
333 | } |
---|
334 | } |
---|
335 | |
---|
336 | if(bTempRefIdxInL2 == true) |
---|
337 | { |
---|
338 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_0; |
---|
339 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
340 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
341 | } |
---|
342 | } |
---|
343 | |
---|
344 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_1]) |
---|
345 | { |
---|
346 | Bool bTempRefIdxInL2 = true; |
---|
347 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
348 | { |
---|
349 | if ( m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) |
---|
350 | { |
---|
351 | m_iRefIdxOfL0FromRefIdxOfL1[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
352 | m_iRefIdxOfL1FromRefIdxOfL0[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
353 | bTempRefIdxInL2 = false; |
---|
354 | break; |
---|
355 | } |
---|
356 | } |
---|
357 | if(bTempRefIdxInL2 == true) |
---|
358 | { |
---|
359 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_1; |
---|
360 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
361 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
362 | } |
---|
363 | } |
---|
364 | } |
---|
365 | } |
---|
366 | } |
---|
367 | |
---|
368 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic ) |
---|
369 | { |
---|
370 | if (m_eSliceType == I_SLICE |
---|
371 | #if REF_IDX_FRAMEWORK |
---|
372 | || ( getSPS()->getLayerId() && |
---|
373 | (getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) && |
---|
374 | (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) ) |
---|
375 | #endif |
---|
376 | ) |
---|
377 | { |
---|
378 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
379 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
380 | |
---|
381 | return; |
---|
382 | } |
---|
383 | |
---|
384 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
385 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
386 | |
---|
387 | TComPic* pcRefPic= NULL; |
---|
388 | TComPic* RefPicSetStCurr0[16]; |
---|
389 | TComPic* RefPicSetStCurr1[16]; |
---|
390 | TComPic* RefPicSetLtCurr[16]; |
---|
391 | UInt NumPocStCurr0 = 0; |
---|
392 | UInt NumPocStCurr1 = 0; |
---|
393 | UInt NumPocLtCurr = 0; |
---|
394 | Int i; |
---|
395 | |
---|
396 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
397 | { |
---|
398 | if(m_pcRPS->getUsed(i)) |
---|
399 | { |
---|
400 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
401 | pcRefPic->setIsLongTerm(0); |
---|
402 | pcRefPic->setIsUsedAsLongTerm(0); |
---|
403 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
404 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
405 | NumPocStCurr0++; |
---|
406 | pcRefPic->setCheckLTMSBPresent(false); |
---|
407 | } |
---|
408 | } |
---|
409 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
410 | { |
---|
411 | if(m_pcRPS->getUsed(i)) |
---|
412 | { |
---|
413 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
414 | pcRefPic->setIsLongTerm(0); |
---|
415 | pcRefPic->setIsUsedAsLongTerm(0); |
---|
416 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
417 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
418 | NumPocStCurr1++; |
---|
419 | pcRefPic->setCheckLTMSBPresent(false); |
---|
420 | } |
---|
421 | } |
---|
422 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
423 | { |
---|
424 | if(m_pcRPS->getUsed(i)) |
---|
425 | { |
---|
426 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i)); |
---|
427 | pcRefPic->setIsLongTerm(1); |
---|
428 | pcRefPic->setIsUsedAsLongTerm(1); |
---|
429 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
430 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
431 | NumPocLtCurr++; |
---|
432 | } |
---|
433 | if(pcRefPic==NULL) |
---|
434 | { |
---|
435 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i)); |
---|
436 | } |
---|
437 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
438 | } |
---|
439 | |
---|
440 | // ref_pic_list_init |
---|
441 | UInt cIdx = 0; |
---|
442 | UInt num_ref_idx_l0_active_minus1 = m_aiNumRefIdx[0] - 1; |
---|
443 | UInt num_ref_idx_l1_active_minus1 = m_aiNumRefIdx[1] - 1; |
---|
444 | TComPic* refPicListTemp0[MAX_NUM_REF+1]; |
---|
445 | TComPic* refPicListTemp1[MAX_NUM_REF+1]; |
---|
446 | Int numRpsCurrTempList0, numRpsCurrTempList1; |
---|
447 | |
---|
448 | numRpsCurrTempList0 = numRpsCurrTempList1 = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
449 | if (numRpsCurrTempList0 <= num_ref_idx_l0_active_minus1) |
---|
450 | { |
---|
451 | numRpsCurrTempList0 = num_ref_idx_l0_active_minus1 + 1; |
---|
452 | } |
---|
453 | if (numRpsCurrTempList1 <= num_ref_idx_l1_active_minus1) |
---|
454 | { |
---|
455 | numRpsCurrTempList1 = num_ref_idx_l1_active_minus1 + 1; |
---|
456 | } |
---|
457 | |
---|
458 | cIdx = 0; |
---|
459 | while (cIdx < numRpsCurrTempList0) |
---|
460 | { |
---|
461 | for ( i=0; i<NumPocStCurr0 && cIdx<numRpsCurrTempList0; cIdx++,i++) |
---|
462 | { |
---|
463 | refPicListTemp0[cIdx] = RefPicSetStCurr0[ i ]; |
---|
464 | } |
---|
465 | for ( i=0; i<NumPocStCurr1 && cIdx<numRpsCurrTempList0; cIdx++,i++) |
---|
466 | { |
---|
467 | refPicListTemp0[cIdx] = RefPicSetStCurr1[ i ]; |
---|
468 | } |
---|
469 | for ( i=0; i<NumPocLtCurr && cIdx<numRpsCurrTempList0; cIdx++,i++) |
---|
470 | { |
---|
471 | refPicListTemp0[cIdx] = RefPicSetLtCurr[ i ]; |
---|
472 | } |
---|
473 | } |
---|
474 | cIdx = 0; |
---|
475 | while (cIdx<numRpsCurrTempList1 && m_eSliceType==B_SLICE) |
---|
476 | { |
---|
477 | for ( i=0; i<NumPocStCurr1 && cIdx<numRpsCurrTempList1; cIdx++,i++) |
---|
478 | { |
---|
479 | refPicListTemp1[cIdx] = RefPicSetStCurr1[ i ]; |
---|
480 | } |
---|
481 | for ( i=0; i<NumPocStCurr0 && cIdx<numRpsCurrTempList1; cIdx++,i++) |
---|
482 | { |
---|
483 | refPicListTemp1[cIdx] = RefPicSetStCurr0[ i ]; |
---|
484 | } |
---|
485 | for ( i=0; i<NumPocLtCurr && cIdx<numRpsCurrTempList1; cIdx++,i++) |
---|
486 | { |
---|
487 | refPicListTemp1[cIdx] = RefPicSetLtCurr[ i ]; |
---|
488 | } |
---|
489 | } |
---|
490 | |
---|
491 | for (cIdx = 0; cIdx <= num_ref_idx_l0_active_minus1; cIdx ++) |
---|
492 | { |
---|
493 | m_apcRefPicList[0][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? refPicListTemp0[ m_RefPicListModification.getRefPicSetIdxL0(cIdx) ] : refPicListTemp0[cIdx]; |
---|
494 | } |
---|
495 | if ( m_eSliceType == P_SLICE ) |
---|
496 | { |
---|
497 | m_aiNumRefIdx[1] = 0; |
---|
498 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
499 | } |
---|
500 | else |
---|
501 | { |
---|
502 | for (cIdx = 0; cIdx <= num_ref_idx_l1_active_minus1; cIdx ++) |
---|
503 | { |
---|
504 | m_apcRefPicList[1][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? refPicListTemp1[ m_RefPicListModification.getRefPicSetIdxL1(cIdx) ] : refPicListTemp1[cIdx]; |
---|
505 | } |
---|
506 | } |
---|
507 | } |
---|
508 | |
---|
509 | #if REF_IDX_FRAMEWORK |
---|
510 | Void TComSlice::addRefPicList( TComPic **pIlpPicList, Int iRefPicNum, Int iInsertOffset ) |
---|
511 | { |
---|
512 | if(getSPS()->getLayerId() && m_eSliceType != I_SLICE) |
---|
513 | { |
---|
514 | //add to list 0; |
---|
515 | Int iOffset; |
---|
516 | m_aiNumRefIdx[REF_PIC_LIST_0] += iInsertOffset; |
---|
517 | iOffset = m_aiNumRefIdx[REF_PIC_LIST_0]; |
---|
518 | for (Int i=0; i<iRefPicNum; i++) |
---|
519 | { |
---|
520 | pIlpPicList[i]->setIsLongTerm(1); //mark ilp as long-term reference |
---|
521 | pIlpPicList[i]->setIsUsedAsLongTerm(1); //mark ilp as long-term reference |
---|
522 | m_apcRefPicList[REF_PIC_LIST_0][iOffset + i] = pIlpPicList[i]; |
---|
523 | m_aiNumRefIdx[REF_PIC_LIST_0]++; |
---|
524 | //m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
525 | } |
---|
526 | if(m_eSliceType == B_SLICE) |
---|
527 | { |
---|
528 | m_aiNumRefIdx[REF_PIC_LIST_1] += iInsertOffset; |
---|
529 | iOffset = m_aiNumRefIdx[REF_PIC_LIST_1]; |
---|
530 | for (Int i=0; i<iRefPicNum; i++) |
---|
531 | { |
---|
532 | pIlpPicList[i]->setIsLongTerm(1); //mark ilp as long-term reference |
---|
533 | pIlpPicList[i]->setIsUsedAsLongTerm(1); //mark ilp as long-term reference |
---|
534 | m_apcRefPicList[REF_PIC_LIST_1][iOffset + i] = pIlpPicList[i]; |
---|
535 | m_aiNumRefIdx[REF_PIC_LIST_1]++; |
---|
536 | //m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
537 | } |
---|
538 | } |
---|
539 | } |
---|
540 | } |
---|
541 | #endif |
---|
542 | |
---|
543 | Int TComSlice::getNumRpsCurrTempList() |
---|
544 | { |
---|
545 | Int numRpsCurrTempList = 0; |
---|
546 | |
---|
547 | if (m_eSliceType == I_SLICE) |
---|
548 | { |
---|
549 | return 0; |
---|
550 | } |
---|
551 | for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++) |
---|
552 | { |
---|
553 | if(m_pcRPS->getUsed(i)) |
---|
554 | { |
---|
555 | numRpsCurrTempList++; |
---|
556 | } |
---|
557 | } |
---|
558 | return numRpsCurrTempList; |
---|
559 | } |
---|
560 | #if SVC_EXTENSION |
---|
561 | Void TComSlice::setBaseColPic( TComList<TComPic*>& rcListPic, UInt layerID ) |
---|
562 | { |
---|
563 | if (layerID == 0) |
---|
564 | { |
---|
565 | m_pcBaseColPic = NULL; |
---|
566 | return; |
---|
567 | } |
---|
568 | setBaseColPic(xGetRefPic(rcListPic, getPOC())); |
---|
569 | } |
---|
570 | #endif |
---|
571 | |
---|
572 | Void TComSlice::initEqualRef() |
---|
573 | { |
---|
574 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
575 | { |
---|
576 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
577 | { |
---|
578 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
579 | { |
---|
580 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
581 | } |
---|
582 | } |
---|
583 | } |
---|
584 | } |
---|
585 | |
---|
586 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
587 | { |
---|
588 | Int i; |
---|
589 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
590 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1-curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
591 | TComSlice* preSlice; |
---|
592 | Int preColRefPOC; |
---|
593 | for(i=curSliceIdx-1; i>=0; i--) |
---|
594 | { |
---|
595 | preSlice = pic->getSlice(i); |
---|
596 | if(preSlice->getSliceType() != I_SLICE) |
---|
597 | { |
---|
598 | preColRefPOC = preSlice->getRefPOC( RefPicList(1-preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
599 | if(currColRefPOC != preColRefPOC) |
---|
600 | { |
---|
601 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
602 | exit(EXIT_FAILURE); |
---|
603 | } |
---|
604 | else |
---|
605 | { |
---|
606 | break; |
---|
607 | } |
---|
608 | } |
---|
609 | } |
---|
610 | } |
---|
611 | |
---|
612 | Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic*>& rcListPic) |
---|
613 | { |
---|
614 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
615 | { |
---|
616 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
617 | { |
---|
618 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
619 | } |
---|
620 | } |
---|
621 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
622 | { |
---|
623 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
624 | { |
---|
625 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
626 | } |
---|
627 | } |
---|
628 | #if SUPPORT_FOR_RAP_N_LP |
---|
629 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
630 | #else |
---|
631 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR ) // IDR picture found |
---|
632 | #endif |
---|
633 | { |
---|
634 | prevRAPisBLA = false; |
---|
635 | } |
---|
636 | #if NAL_UNIT_TYPES_J1003_D7 |
---|
637 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
638 | #else |
---|
639 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRANT ) // CRA/CRANT picture found |
---|
640 | #endif |
---|
641 | { |
---|
642 | pocCRA = getPOC(); |
---|
643 | prevRAPisBLA = false; |
---|
644 | } |
---|
645 | #if SUPPORT_FOR_RAP_N_LP |
---|
646 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA |
---|
647 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT |
---|
648 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
649 | #else |
---|
650 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT ) // BLA/BLANT picture found |
---|
651 | #endif |
---|
652 | { |
---|
653 | pocCRA = getPOC(); |
---|
654 | prevRAPisBLA = true; |
---|
655 | } |
---|
656 | } |
---|
657 | |
---|
658 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
659 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
660 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
661 | * \param rcListPic reference to the reference picture list |
---|
662 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
663 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
664 | * are marked as "unused for reference" |
---|
665 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
666 | * Otherwise |
---|
667 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
668 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
669 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
670 | * the bRefreshPending flag to false. |
---|
671 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
672 | * reference of the current picture. |
---|
673 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
674 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
675 | */ |
---|
676 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
677 | { |
---|
678 | TComPic* rpcPic; |
---|
679 | UInt uiPOCCurr = getPOC(); |
---|
680 | |
---|
681 | #if SUPPORT_FOR_RAP_N_LP |
---|
682 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA |
---|
683 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT |
---|
684 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
685 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR |
---|
686 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
687 | #else |
---|
688 | if (getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT) // IDR/BLA/BLANT |
---|
689 | #endif |
---|
690 | { |
---|
691 | // mark all pictures as not used for reference |
---|
692 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
693 | while (iterPic != rcListPic.end()) |
---|
694 | { |
---|
695 | rpcPic = *(iterPic); |
---|
696 | rpcPic->setCurrSliceIdx(0); |
---|
697 | if (rpcPic->getPOC() != uiPOCCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
698 | iterPic++; |
---|
699 | } |
---|
700 | #if SUPPORT_FOR_RAP_N_LP |
---|
701 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA |
---|
702 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT |
---|
703 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
704 | #else |
---|
705 | if (getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT) |
---|
706 | #endif |
---|
707 | { |
---|
708 | pocCRA = uiPOCCurr; |
---|
709 | } |
---|
710 | } |
---|
711 | else // CRA or No DR |
---|
712 | { |
---|
713 | if (bRefreshPending==true && uiPOCCurr > pocCRA) // CRA reference marking pending |
---|
714 | { |
---|
715 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
716 | while (iterPic != rcListPic.end()) |
---|
717 | { |
---|
718 | rpcPic = *(iterPic); |
---|
719 | if (rpcPic->getPOC() != uiPOCCurr && rpcPic->getPOC() != pocCRA) rpcPic->getSlice(0)->setReferenced(false); |
---|
720 | iterPic++; |
---|
721 | } |
---|
722 | bRefreshPending = false; |
---|
723 | } |
---|
724 | #if NAL_UNIT_TYPES_J1003_D7 |
---|
725 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
726 | #else |
---|
727 | if (getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRANT) // CRA/CRANT picture found |
---|
728 | #endif |
---|
729 | { |
---|
730 | bRefreshPending = true; |
---|
731 | pocCRA = uiPOCCurr; |
---|
732 | } |
---|
733 | } |
---|
734 | } |
---|
735 | |
---|
736 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
737 | { |
---|
738 | assert( pSrc != NULL ); |
---|
739 | |
---|
740 | Int i, j, k; |
---|
741 | |
---|
742 | m_iPOC = pSrc->m_iPOC; |
---|
743 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
744 | m_eSliceType = pSrc->m_eSliceType; |
---|
745 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
746 | #if ADAPTIVE_QP_SELECTION |
---|
747 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
748 | #endif |
---|
749 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
750 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
751 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
752 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
753 | |
---|
754 | for (i = 0; i < 3; i++) |
---|
755 | { |
---|
756 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
757 | } |
---|
758 | |
---|
759 | for (i = 0; i < 2; i++) |
---|
760 | { |
---|
761 | for (j = 0; j < MAX_NUM_REF_LC; j++) |
---|
762 | { |
---|
763 | m_iRefIdxOfLC[i][j] = pSrc->m_iRefIdxOfLC[i][j]; |
---|
764 | } |
---|
765 | } |
---|
766 | for (i = 0; i < MAX_NUM_REF_LC; i++) |
---|
767 | { |
---|
768 | m_eListIdFromIdxOfLC[i] = pSrc->m_eListIdFromIdxOfLC[i]; |
---|
769 | m_iRefIdxFromIdxOfLC[i] = pSrc->m_iRefIdxFromIdxOfLC[i]; |
---|
770 | m_iRefIdxOfL1FromRefIdxOfL0[i] = pSrc->m_iRefIdxOfL1FromRefIdxOfL0[i]; |
---|
771 | m_iRefIdxOfL0FromRefIdxOfL1[i] = pSrc->m_iRefIdxOfL0FromRefIdxOfL1[i]; |
---|
772 | } |
---|
773 | m_bRefPicListModificationFlagLC = pSrc->m_bRefPicListModificationFlagLC; |
---|
774 | m_bRefPicListCombinationFlag = pSrc->m_bRefPicListCombinationFlag; |
---|
775 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
776 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
777 | #if CHROMA_QP_EXTENSION |
---|
778 | m_iSliceQpDeltaCb = pSrc->m_iSliceQpDeltaCb; |
---|
779 | m_iSliceQpDeltaCr = pSrc->m_iSliceQpDeltaCr; |
---|
780 | #endif |
---|
781 | for (i = 0; i < 2; i++) |
---|
782 | { |
---|
783 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
784 | { |
---|
785 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
786 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
787 | } |
---|
788 | } |
---|
789 | m_iDepth = pSrc->m_iDepth; |
---|
790 | |
---|
791 | // referenced slice |
---|
792 | m_bRefenced = pSrc->m_bRefenced; |
---|
793 | |
---|
794 | // access channel |
---|
795 | m_pcSPS = pSrc->m_pcSPS; |
---|
796 | m_pcPPS = pSrc->m_pcPPS; |
---|
797 | m_pcRPS = pSrc->m_pcRPS; |
---|
798 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
799 | |
---|
800 | m_pcPic = pSrc->m_pcPic; |
---|
801 | #if !REMOVE_APS |
---|
802 | m_pcAPS = pSrc->m_pcAPS; |
---|
803 | m_iAPSId = pSrc->m_iAPSId; |
---|
804 | #endif |
---|
805 | |
---|
806 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
807 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
808 | #if ALF_CHROMA_LAMBDA || SAO_CHROMA_LAMBDA |
---|
809 | m_dLambdaLuma = pSrc->m_dLambdaLuma; |
---|
810 | m_dLambdaChroma = pSrc->m_dLambdaChroma; |
---|
811 | #else |
---|
812 | m_dLambda = pSrc->m_dLambda; |
---|
813 | #endif |
---|
814 | for (i = 0; i < 2; i++) |
---|
815 | { |
---|
816 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
817 | { |
---|
818 | for (k =0; k < MAX_NUM_REF; k++) |
---|
819 | { |
---|
820 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
821 | } |
---|
822 | } |
---|
823 | } |
---|
824 | |
---|
825 | m_bNoBackPredFlag = pSrc->m_bNoBackPredFlag; |
---|
826 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
827 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
828 | |
---|
829 | m_uiSliceMode = pSrc->m_uiSliceMode; |
---|
830 | m_uiSliceArgument = pSrc->m_uiSliceArgument; |
---|
831 | m_uiSliceCurStartCUAddr = pSrc->m_uiSliceCurStartCUAddr; |
---|
832 | m_uiSliceCurEndCUAddr = pSrc->m_uiSliceCurEndCUAddr; |
---|
833 | m_uiSliceIdx = pSrc->m_uiSliceIdx; |
---|
834 | m_uiDependentSliceMode = pSrc->m_uiDependentSliceMode; |
---|
835 | m_uiDependentSliceArgument = pSrc->m_uiDependentSliceArgument; |
---|
836 | m_uiDependentSliceCurStartCUAddr = pSrc->m_uiDependentSliceCurStartCUAddr; |
---|
837 | m_uiDependentSliceCurEndCUAddr = pSrc->m_uiDependentSliceCurEndCUAddr; |
---|
838 | m_bNextSlice = pSrc->m_bNextSlice; |
---|
839 | m_bNextDependentSlice = pSrc->m_bNextDependentSlice; |
---|
840 | for ( int e=0 ; e<2 ; e++ ) |
---|
841 | { |
---|
842 | for ( int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
843 | { |
---|
844 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
845 | } |
---|
846 | } |
---|
847 | m_saoEnabledFlag = pSrc->m_saoEnabledFlag; |
---|
848 | #if SAO_TYPE_SHARING |
---|
849 | m_saoEnabledFlagChroma = pSrc->m_saoEnabledFlagChroma; |
---|
850 | #else |
---|
851 | m_saoEnabledFlagCb = pSrc->m_saoEnabledFlagCb; |
---|
852 | m_saoEnabledFlagCr = pSrc->m_saoEnabledFlagCr; |
---|
853 | #endif |
---|
854 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
855 | m_numEntryPointOffsets = pSrc->m_numEntryPointOffsets; |
---|
856 | |
---|
857 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
858 | #if !REMOVE_ALF |
---|
859 | for(Int compIdx=0; compIdx < 3; compIdx++) |
---|
860 | { |
---|
861 | m_alfEnabledFlag[compIdx] = pSrc->m_alfEnabledFlag[compIdx]; |
---|
862 | } |
---|
863 | #endif |
---|
864 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
865 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
866 | } |
---|
867 | |
---|
868 | #if PREVREFPIC_DEFN |
---|
869 | int TComSlice::m_prevPOC[MAX_TLAYER] = {0}; |
---|
870 | #else |
---|
871 | int TComSlice::m_prevPOC = 0; |
---|
872 | #endif |
---|
873 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
874 | * \param uiTLayer Temporal layer ID of the current slice |
---|
875 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
876 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
877 | * temporal_layer_switching_point_flag is set accordingly. |
---|
878 | */ |
---|
879 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
880 | { |
---|
881 | m_uiTLayer = uiTLayer; |
---|
882 | } |
---|
883 | |
---|
884 | /** Function for checking if this is a switching-point |
---|
885 | */ |
---|
886 | Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
887 | { |
---|
888 | TComPic* rpcPic; |
---|
889 | // loop through all pictures in the reference picture buffer |
---|
890 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
891 | while ( iterPic != rcListPic.end()) |
---|
892 | { |
---|
893 | rpcPic = *(iterPic++); |
---|
894 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
895 | { |
---|
896 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
897 | { |
---|
898 | return false; |
---|
899 | } |
---|
900 | } |
---|
901 | } |
---|
902 | return true; |
---|
903 | } |
---|
904 | |
---|
905 | #if STSA |
---|
906 | /** Function for checking if this is a STSA candidate |
---|
907 | */ |
---|
908 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
909 | { |
---|
910 | TComPic* rpcPic; |
---|
911 | |
---|
912 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
913 | while ( iterPic != rcListPic.end()) |
---|
914 | { |
---|
915 | rpcPic = *(iterPic++); |
---|
916 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
917 | { |
---|
918 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
919 | { |
---|
920 | return false; |
---|
921 | } |
---|
922 | } |
---|
923 | } |
---|
924 | return true; |
---|
925 | } |
---|
926 | #endif |
---|
927 | |
---|
928 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
929 | */ |
---|
930 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
931 | { |
---|
932 | TComPic* rpcPic; |
---|
933 | Int i, isReference; |
---|
934 | |
---|
935 | Int j = 0; |
---|
936 | // loop through all pictures in the reference picture buffer |
---|
937 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
938 | while ( iterPic != rcListPic.end()) |
---|
939 | { |
---|
940 | j++; |
---|
941 | rpcPic = *(iterPic++); |
---|
942 | |
---|
943 | isReference = 0; |
---|
944 | // loop through all pictures in the Reference Picture Set |
---|
945 | // to see if the picture should be kept as reference picture |
---|
946 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
947 | { |
---|
948 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
949 | { |
---|
950 | isReference = 1; |
---|
951 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
952 | rpcPic->setIsLongTerm(0); |
---|
953 | rpcPic->setIsUsedAsLongTerm(0); |
---|
954 | } |
---|
955 | } |
---|
956 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
957 | { |
---|
958 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
959 | { |
---|
960 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
961 | { |
---|
962 | isReference = 1; |
---|
963 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
964 | } |
---|
965 | } |
---|
966 | else |
---|
967 | { |
---|
968 | 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())) |
---|
969 | { |
---|
970 | isReference = 1; |
---|
971 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
972 | } |
---|
973 | } |
---|
974 | |
---|
975 | } |
---|
976 | // mark the picture as "unused for reference" if it is not in |
---|
977 | // the Reference Picture Set |
---|
978 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
979 | { |
---|
980 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
981 | rpcPic->setIsLongTerm(0); |
---|
982 | } |
---|
983 | //check that pictures of higher temporal layers are not used |
---|
984 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
985 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
986 | #if NAL_UNIT_TYPES_J1003_D7 |
---|
987 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
988 | #else |
---|
989 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA) |
---|
990 | #endif |
---|
991 | { |
---|
992 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
993 | } |
---|
994 | #if TEMPORAL_LAYER_NON_REFERENCE |
---|
995 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
996 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
997 | { |
---|
998 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
999 | } |
---|
1000 | #endif |
---|
1001 | } |
---|
1002 | } |
---|
1003 | |
---|
1004 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1005 | */ |
---|
1006 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess) |
---|
1007 | { |
---|
1008 | TComPic* rpcPic; |
---|
1009 | Int i, isAvailable, j; |
---|
1010 | Int atLeastOneLost = 0; |
---|
1011 | Int atLeastOneRemoved = 0; |
---|
1012 | Int iPocLost = 0; |
---|
1013 | |
---|
1014 | // loop through all long-term pictures in the Reference Picture Set |
---|
1015 | // to see if the picture should be kept as reference picture |
---|
1016 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1017 | { |
---|
1018 | j = 0; |
---|
1019 | isAvailable = 0; |
---|
1020 | // loop through all pictures in the reference picture buffer |
---|
1021 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1022 | while ( iterPic != rcListPic.end()) |
---|
1023 | { |
---|
1024 | j++; |
---|
1025 | rpcPic = *(iterPic++); |
---|
1026 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1027 | { |
---|
1028 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1029 | { |
---|
1030 | isAvailable = 1; |
---|
1031 | } |
---|
1032 | } |
---|
1033 | else |
---|
1034 | { |
---|
1035 | 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()) |
---|
1036 | { |
---|
1037 | isAvailable = 1; |
---|
1038 | } |
---|
1039 | } |
---|
1040 | } |
---|
1041 | // if there was no such long-term check the short terms |
---|
1042 | if(!isAvailable) |
---|
1043 | { |
---|
1044 | iterPic = rcListPic.begin(); |
---|
1045 | while ( iterPic != rcListPic.end()) |
---|
1046 | { |
---|
1047 | j++; |
---|
1048 | rpcPic = *(iterPic++); |
---|
1049 | |
---|
1050 | if((rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == (this->getPOC() + pReferencePictureSet->getDeltaPOC(i))%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()) && rpcPic->getSlice(0)->isReferenced()) |
---|
1051 | { |
---|
1052 | isAvailable = 1; |
---|
1053 | rpcPic->setIsLongTerm(1); |
---|
1054 | rpcPic->setIsUsedAsLongTerm(1); |
---|
1055 | break; |
---|
1056 | } |
---|
1057 | } |
---|
1058 | } |
---|
1059 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1060 | // but not available as reference picture |
---|
1061 | if(isAvailable == 0) |
---|
1062 | { |
---|
1063 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1064 | { |
---|
1065 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1066 | { |
---|
1067 | if(printErrors) |
---|
1068 | { |
---|
1069 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1070 | } |
---|
1071 | atLeastOneRemoved = 1; |
---|
1072 | } |
---|
1073 | else |
---|
1074 | { |
---|
1075 | if(printErrors) |
---|
1076 | { |
---|
1077 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1078 | } |
---|
1079 | atLeastOneLost = 1; |
---|
1080 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1081 | } |
---|
1082 | } |
---|
1083 | } |
---|
1084 | } |
---|
1085 | // loop through all short-term pictures in the Reference Picture Set |
---|
1086 | // to see if the picture should be kept as reference picture |
---|
1087 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
1088 | { |
---|
1089 | j = 0; |
---|
1090 | isAvailable = 0; |
---|
1091 | // loop through all pictures in the reference picture buffer |
---|
1092 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1093 | while ( iterPic != rcListPic.end()) |
---|
1094 | { |
---|
1095 | j++; |
---|
1096 | rpcPic = *(iterPic++); |
---|
1097 | |
---|
1098 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1099 | { |
---|
1100 | isAvailable = 1; |
---|
1101 | } |
---|
1102 | } |
---|
1103 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1104 | // but not available as reference picture |
---|
1105 | if(isAvailable == 0) |
---|
1106 | { |
---|
1107 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1108 | { |
---|
1109 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1110 | { |
---|
1111 | if(printErrors) |
---|
1112 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1113 | atLeastOneRemoved = 1; |
---|
1114 | } |
---|
1115 | else |
---|
1116 | { |
---|
1117 | if(printErrors) |
---|
1118 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1119 | atLeastOneLost = 1; |
---|
1120 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1121 | } |
---|
1122 | } |
---|
1123 | } |
---|
1124 | } |
---|
1125 | if(atLeastOneLost) |
---|
1126 | { |
---|
1127 | return iPocLost+1; |
---|
1128 | } |
---|
1129 | if(atLeastOneRemoved) |
---|
1130 | { |
---|
1131 | return -2; |
---|
1132 | } |
---|
1133 | else |
---|
1134 | { |
---|
1135 | return 0; |
---|
1136 | } |
---|
1137 | } |
---|
1138 | |
---|
1139 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
1140 | */ |
---|
1141 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
1142 | { |
---|
1143 | TComPic* rpcPic; |
---|
1144 | Int i, j; |
---|
1145 | Int k = 0; |
---|
1146 | Int nrOfNegativePictures = 0; |
---|
1147 | Int nrOfPositivePictures = 0; |
---|
1148 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
1149 | |
---|
1150 | // loop through all pictures in the Reference Picture Set |
---|
1151 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1152 | { |
---|
1153 | j = 0; |
---|
1154 | // loop through all pictures in the reference picture buffer |
---|
1155 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1156 | while ( iterPic != rcListPic.end()) |
---|
1157 | { |
---|
1158 | j++; |
---|
1159 | rpcPic = *(iterPic++); |
---|
1160 | |
---|
1161 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1162 | { |
---|
1163 | // This picture exists as a reference picture |
---|
1164 | // and should be added to the explicit Reference Picture Set |
---|
1165 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
1166 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i)); |
---|
1167 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
1168 | { |
---|
1169 | nrOfNegativePictures++; |
---|
1170 | } |
---|
1171 | else |
---|
1172 | { |
---|
1173 | nrOfPositivePictures++; |
---|
1174 | } |
---|
1175 | k++; |
---|
1176 | } |
---|
1177 | } |
---|
1178 | } |
---|
1179 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
1180 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
1181 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
1182 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
1183 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
1184 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
1185 | if (!pReferencePictureSet->getInterRPSPrediction()) |
---|
1186 | { |
---|
1187 | pcRPS->setInterRPSPrediction(false); |
---|
1188 | pcRPS->setNumRefIdc(0); |
---|
1189 | } |
---|
1190 | else |
---|
1191 | { |
---|
1192 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
1193 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
1194 | TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
1195 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
1196 | Int iNewIdc=0; |
---|
1197 | for(i=0; i<= iRefPics; i++) |
---|
1198 | { |
---|
1199 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
1200 | Int iRefIdc = 0; |
---|
1201 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
1202 | { |
---|
1203 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
1204 | { |
---|
1205 | if (pcRPS->getUsed(j)) |
---|
1206 | { |
---|
1207 | iRefIdc = 1; |
---|
1208 | } |
---|
1209 | else |
---|
1210 | { |
---|
1211 | iRefIdc = 2; |
---|
1212 | } |
---|
1213 | } |
---|
1214 | } |
---|
1215 | pcRPS->setRefIdc(i, iRefIdc); |
---|
1216 | iNewIdc++; |
---|
1217 | } |
---|
1218 | pcRPS->setInterRPSPrediction(true); |
---|
1219 | pcRPS->setNumRefIdc(iNewIdc); |
---|
1220 | pcRPS->setDeltaRPS(deltaRPS); |
---|
1221 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
1222 | } |
---|
1223 | |
---|
1224 | this->setRPS(pcRPS); |
---|
1225 | this->setRPSidx(-1); |
---|
1226 | } |
---|
1227 | |
---|
1228 | /** get AC and DC values for weighted pred |
---|
1229 | * \param *wp |
---|
1230 | * \returns Void |
---|
1231 | */ |
---|
1232 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
1233 | { |
---|
1234 | wp = m_weightACDCParam; |
---|
1235 | } |
---|
1236 | |
---|
1237 | /** init AC and DC values for weighted pred |
---|
1238 | * \returns Void |
---|
1239 | */ |
---|
1240 | Void TComSlice::initWpAcDcParam() |
---|
1241 | { |
---|
1242 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
1243 | { |
---|
1244 | m_weightACDCParam[iComp].iAC = 0; |
---|
1245 | m_weightACDCParam[iComp].iDC = 0; |
---|
1246 | } |
---|
1247 | } |
---|
1248 | |
---|
1249 | /** get WP tables for weighted pred |
---|
1250 | * \param RefPicList |
---|
1251 | * \param iRefIdx |
---|
1252 | * \param *&wpScalingParam |
---|
1253 | * \returns Void |
---|
1254 | */ |
---|
1255 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
1256 | { |
---|
1257 | wp = m_weightPredTable[e][iRefIdx]; |
---|
1258 | } |
---|
1259 | |
---|
1260 | /** reset Default WP tables settings : no weight. |
---|
1261 | * \param wpScalingParam |
---|
1262 | * \returns Void |
---|
1263 | */ |
---|
1264 | Void TComSlice::resetWpScaling(wpScalingParam wp[2][MAX_NUM_REF][3]) |
---|
1265 | { |
---|
1266 | for ( int e=0 ; e<2 ; e++ ) |
---|
1267 | { |
---|
1268 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1269 | { |
---|
1270 | for ( int yuv=0 ; yuv<3 ; yuv++ ) |
---|
1271 | { |
---|
1272 | wpScalingParam *pwp = &(wp[e][i][yuv]); |
---|
1273 | pwp->bPresentFlag = false; |
---|
1274 | pwp->uiLog2WeightDenom = 0; |
---|
1275 | pwp->uiLog2WeightDenom = 0; |
---|
1276 | pwp->iWeight = 1; |
---|
1277 | pwp->iOffset = 0; |
---|
1278 | } |
---|
1279 | } |
---|
1280 | } |
---|
1281 | } |
---|
1282 | |
---|
1283 | /** init WP table |
---|
1284 | * \returns Void |
---|
1285 | */ |
---|
1286 | Void TComSlice::initWpScaling() |
---|
1287 | { |
---|
1288 | initWpScaling(m_weightPredTable); |
---|
1289 | } |
---|
1290 | |
---|
1291 | /** set WP tables |
---|
1292 | * \param wpScalingParam |
---|
1293 | * \returns Void |
---|
1294 | */ |
---|
1295 | Void TComSlice::initWpScaling(wpScalingParam wp[2][MAX_NUM_REF][3]) |
---|
1296 | { |
---|
1297 | for ( int e=0 ; e<2 ; e++ ) |
---|
1298 | { |
---|
1299 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1300 | { |
---|
1301 | for ( int yuv=0 ; yuv<3 ; yuv++ ) |
---|
1302 | { |
---|
1303 | wpScalingParam *pwp = &(wp[e][i][yuv]); |
---|
1304 | if ( !pwp->bPresentFlag ) { |
---|
1305 | // Inferring values not present : |
---|
1306 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
1307 | pwp->iOffset = 0; |
---|
1308 | } |
---|
1309 | |
---|
1310 | pwp->w = pwp->iWeight; |
---|
1311 | pwp->o = pwp->iOffset * (1 << (g_uiBitDepth-8)); |
---|
1312 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
1313 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
1314 | } |
---|
1315 | } |
---|
1316 | } |
---|
1317 | } |
---|
1318 | |
---|
1319 | // ------------------------------------------------------------------------------------------------ |
---|
1320 | // Video parameter set (VPS) |
---|
1321 | // ------------------------------------------------------------------------------------------------ |
---|
1322 | TComVPS::TComVPS() |
---|
1323 | : m_VPSId ( 0) |
---|
1324 | , m_uiMaxTLayers ( 1) |
---|
1325 | , m_uiMaxLayers ( 1) |
---|
1326 | , m_bTemporalIdNestingFlag (false) |
---|
1327 | { |
---|
1328 | |
---|
1329 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
1330 | { |
---|
1331 | m_numReorderPics[i] = 0; |
---|
1332 | m_uiMaxDecPicBuffering[i] = 0; |
---|
1333 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1334 | } |
---|
1335 | } |
---|
1336 | |
---|
1337 | TComVPS::~TComVPS() |
---|
1338 | { |
---|
1339 | |
---|
1340 | |
---|
1341 | } |
---|
1342 | |
---|
1343 | // ------------------------------------------------------------------------------------------------ |
---|
1344 | // Sequence parameter set (SPS) |
---|
1345 | // ------------------------------------------------------------------------------------------------ |
---|
1346 | |
---|
1347 | TComSPS::TComSPS() |
---|
1348 | : m_SPSId ( 0) |
---|
1349 | #if !SPS_SYNTAX_CHANGES |
---|
1350 | , m_ProfileSpace ( 0) |
---|
1351 | , m_ProfileIdc ( 0) |
---|
1352 | , m_ReservedIndicatorFlags ( 0) |
---|
1353 | , m_LevelIdc ( 0) |
---|
1354 | , m_ProfileCompatibility ( 0) |
---|
1355 | #endif |
---|
1356 | , m_VPSId ( 0) |
---|
1357 | , m_chromaFormatIdc (CHROMA_420) |
---|
1358 | , m_uiMaxTLayers ( 1) |
---|
1359 | // Structure |
---|
1360 | , m_picWidthInLumaSamples (352) |
---|
1361 | , m_picHeightInLumaSamples (288) |
---|
1362 | , m_picCroppingFlag (false) |
---|
1363 | , m_picCropLeftOffset ( 0) |
---|
1364 | , m_picCropRightOffset ( 0) |
---|
1365 | , m_picCropTopOffset ( 0) |
---|
1366 | , m_picCropBottomOffset ( 0) |
---|
1367 | , m_uiMaxCUWidth ( 32) |
---|
1368 | , m_uiMaxCUHeight ( 32) |
---|
1369 | , m_uiMaxCUDepth ( 3) |
---|
1370 | , m_uiMinTrDepth ( 0) |
---|
1371 | , m_uiMaxTrDepth ( 1) |
---|
1372 | , m_bLongTermRefsPresent (false) |
---|
1373 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
1374 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
1375 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
1376 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
1377 | // Tool list |
---|
1378 | , m_usePCM (false) |
---|
1379 | , m_pcmLog2MaxSize ( 5) |
---|
1380 | , m_uiPCMLog2MinSize ( 7) |
---|
1381 | #if !REMOVE_ALF |
---|
1382 | , m_bUseALF (false) |
---|
1383 | #endif |
---|
1384 | #if !REMOVE_LMCHROMA |
---|
1385 | , m_bUseLMChroma (false) |
---|
1386 | #endif |
---|
1387 | #if !PPS_TS_FLAG |
---|
1388 | , m_useTransformSkip (false) |
---|
1389 | , m_useTransformSkipFast (false) |
---|
1390 | #endif |
---|
1391 | , m_bUseLComb (false) |
---|
1392 | , m_restrictedRefPicListsFlag ( 1) |
---|
1393 | , m_listsModificationPresentFlag( 0) |
---|
1394 | , m_uiBitDepth ( 8) |
---|
1395 | , m_uiBitIncrement ( 0) |
---|
1396 | , m_qpBDOffsetY ( 0) |
---|
1397 | , m_qpBDOffsetC ( 0) |
---|
1398 | , m_useLossless (false) |
---|
1399 | , m_uiPCMBitDepthLuma ( 8) |
---|
1400 | , m_uiPCMBitDepthChroma ( 8) |
---|
1401 | , m_bPCMFilterDisableFlag (false) |
---|
1402 | , m_uiBitsForPOC ( 8) |
---|
1403 | #if LTRP_IN_SPS |
---|
1404 | , m_numLongTermRefPicSPS ( 0) |
---|
1405 | #endif |
---|
1406 | , m_uiMaxTrSize ( 32) |
---|
1407 | #if !MOVE_LOOP_FILTER_SLICES_FLAG |
---|
1408 | , m_bLFCrossSliceBoundaryFlag (false) |
---|
1409 | #endif |
---|
1410 | , m_bUseSAO (false) |
---|
1411 | , m_bTemporalIdNestingFlag (false) |
---|
1412 | , m_scalingListEnabledFlag (false) |
---|
1413 | #if SUPPORT_FOR_VUI |
---|
1414 | , m_vuiParametersPresentFlag (false) |
---|
1415 | , m_vuiParameters () |
---|
1416 | #endif |
---|
1417 | #if SVC_EXTENSION |
---|
1418 | , m_layerId(0) |
---|
1419 | #endif |
---|
1420 | { |
---|
1421 | #if !SPS_AMVP_CLEANUP |
---|
1422 | // AMVP parameter |
---|
1423 | ::memset( m_aeAMVPMode, 0, sizeof( m_aeAMVPMode ) ); |
---|
1424 | #endif |
---|
1425 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
1426 | { |
---|
1427 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1428 | m_uiMaxDecPicBuffering[i] = 0; |
---|
1429 | m_numReorderPics[i] = 0; |
---|
1430 | } |
---|
1431 | m_scalingList = new TComScalingList; |
---|
1432 | #if LTRP_IN_SPS |
---|
1433 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
1434 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
1435 | #endif |
---|
1436 | } |
---|
1437 | |
---|
1438 | TComSPS::~TComSPS() |
---|
1439 | { |
---|
1440 | delete m_scalingList; |
---|
1441 | m_RPSList.destroy(); |
---|
1442 | } |
---|
1443 | |
---|
1444 | Void TComSPS::createRPSList( Int numRPS ) |
---|
1445 | { |
---|
1446 | m_RPSList.destroy(); |
---|
1447 | m_RPSList.create(numRPS); |
---|
1448 | } |
---|
1449 | #if BUFFERING_PERIOD_AND_TIMING_SEI |
---|
1450 | Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
1451 | { |
---|
1452 | if( !getVuiParametersPresentFlag() ) |
---|
1453 | { |
---|
1454 | return; |
---|
1455 | } |
---|
1456 | |
---|
1457 | TComVUI *vui = getVuiParameters(); |
---|
1458 | |
---|
1459 | vui->setTimingInfoPresentFlag( true ); |
---|
1460 | switch( frameRate ) |
---|
1461 | { |
---|
1462 | case 24: |
---|
1463 | vui->setNumUnitsInTick( 1125000 ); vui->setTimeScale ( 27000000 ); |
---|
1464 | break; |
---|
1465 | case 25: |
---|
1466 | vui->setNumUnitsInTick( 1080000 ); vui->setTimeScale ( 27000000 ); |
---|
1467 | break; |
---|
1468 | case 30: |
---|
1469 | vui->setNumUnitsInTick( 900900 ); vui->setTimeScale ( 27000000 ); |
---|
1470 | break; |
---|
1471 | case 50: |
---|
1472 | vui->setNumUnitsInTick( 540000 ); vui->setTimeScale ( 27000000 ); |
---|
1473 | break; |
---|
1474 | case 60: |
---|
1475 | vui->setNumUnitsInTick( 450450 ); vui->setTimeScale ( 27000000 ); |
---|
1476 | break; |
---|
1477 | default: |
---|
1478 | vui->setNumUnitsInTick( 1001 ); vui->setTimeScale ( 60000 ); |
---|
1479 | break; |
---|
1480 | } |
---|
1481 | |
---|
1482 | Bool rateCnt = ( bitRate > 0 ); |
---|
1483 | vui->setNalHrdParametersPresentFlag( rateCnt ); |
---|
1484 | vui->setVclHrdParametersPresentFlag( rateCnt ); |
---|
1485 | |
---|
1486 | vui->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
1487 | |
---|
1488 | if( vui->getSubPicCpbParamsPresentFlag() ) |
---|
1489 | { |
---|
1490 | vui->setTickDivisorMinus2( 100 - 2 ); // |
---|
1491 | vui->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
1492 | } |
---|
1493 | |
---|
1494 | vui->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
1495 | vui->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
1496 | |
---|
1497 | vui->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
1498 | if( randomAccess ) |
---|
1499 | { |
---|
1500 | vui->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
1501 | vui->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
1502 | } |
---|
1503 | else |
---|
1504 | { |
---|
1505 | vui->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
1506 | vui->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
1507 | } |
---|
1508 | |
---|
1509 | /* |
---|
1510 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
1511 | */ |
---|
1512 | Int i, j; |
---|
1513 | UInt birateValue, cpbSizeValue; |
---|
1514 | |
---|
1515 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
1516 | { |
---|
1517 | vui->setFixedPicRateFlag( i, 1 ); |
---|
1518 | vui->setPicDurationInTcMinus1( i, 0 ); |
---|
1519 | vui->setLowDelayHrdFlag( i, 0 ); |
---|
1520 | vui->setCpbCntMinus1( i, 0 ); |
---|
1521 | |
---|
1522 | birateValue = bitRate; |
---|
1523 | cpbSizeValue = bitRate; // 1 second |
---|
1524 | for( j = 0; j < ( vui->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
1525 | { |
---|
1526 | vui->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
1527 | vui->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
1528 | vui->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
1529 | |
---|
1530 | vui->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
1531 | vui->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
1532 | vui->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
1533 | } |
---|
1534 | } |
---|
1535 | } |
---|
1536 | #endif |
---|
1537 | const Int TComSPS::m_cropUnitX[]={1,2,2,1}; |
---|
1538 | const Int TComSPS::m_cropUnitY[]={1,2,1,1}; |
---|
1539 | |
---|
1540 | TComPPS::TComPPS() |
---|
1541 | : m_PPSId (0) |
---|
1542 | , m_SPSId (0) |
---|
1543 | , m_picInitQPMinus26 (0) |
---|
1544 | , m_useDQP (false) |
---|
1545 | , m_bConstrainedIntraPred (false) |
---|
1546 | #if CHROMA_QP_EXTENSION |
---|
1547 | , m_bSliceChromaQpFlag (false) |
---|
1548 | #endif |
---|
1549 | , m_pcSPS (NULL) |
---|
1550 | , m_uiMaxCuDQPDepth (0) |
---|
1551 | , m_uiMinCuDQPSize (0) |
---|
1552 | , m_chromaCbQpOffset (0) |
---|
1553 | , m_chromaCrQpOffset (0) |
---|
1554 | , m_numRefIdxL0DefaultActive (1) |
---|
1555 | , m_numRefIdxL1DefaultActive (1) |
---|
1556 | #if !REMOVE_FGS |
---|
1557 | , m_iSliceGranularity (0) |
---|
1558 | #endif |
---|
1559 | , m_TransquantBypassEnableFlag (false) |
---|
1560 | #if PPS_TS_FLAG |
---|
1561 | , m_useTransformSkip (false) |
---|
1562 | #endif |
---|
1563 | #if TILES_WPP_ENTROPYSLICES_FLAGS |
---|
1564 | , m_dependentSliceEnabledFlag (false) |
---|
1565 | , m_tilesEnabledFlag (false) |
---|
1566 | , m_entropyCodingSyncEnabledFlag (false) |
---|
1567 | , m_entropySliceEnabledFlag (false) |
---|
1568 | #endif |
---|
1569 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
1570 | , m_uniformSpacingFlag (0) |
---|
1571 | , m_iNumColumnsMinus1 (0) |
---|
1572 | , m_puiColumnWidth (NULL) |
---|
1573 | , m_iNumRowsMinus1 (0) |
---|
1574 | , m_puiRowHeight (NULL) |
---|
1575 | , m_iNumSubstreams (1) |
---|
1576 | , m_signHideFlag(0) |
---|
1577 | , m_cabacInitPresentFlag (false) |
---|
1578 | , m_encCABACTableIdx (I_SLICE) |
---|
1579 | #if SLICE_HEADER_EXTENSION |
---|
1580 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
1581 | #endif |
---|
1582 | #if MOVE_LOOP_FILTER_SLICES_FLAG |
---|
1583 | , m_loopFilterAcrossSlicesEnabledFlag (false) |
---|
1584 | #endif |
---|
1585 | { |
---|
1586 | m_scalingList = new TComScalingList; |
---|
1587 | #if !TILES_WPP_ENTROPYSLICES_FLAGS |
---|
1588 | #if DEPENDENT_SLICES |
---|
1589 | m_bDependentSliceEnabledFlag = false; |
---|
1590 | m_bCabacIndependentFlag = false; |
---|
1591 | #endif |
---|
1592 | #endif |
---|
1593 | } |
---|
1594 | |
---|
1595 | TComPPS::~TComPPS() |
---|
1596 | { |
---|
1597 | if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
1598 | { |
---|
1599 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
1600 | m_puiColumnWidth = NULL; |
---|
1601 | } |
---|
1602 | if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
1603 | { |
---|
1604 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
1605 | m_puiRowHeight = NULL; |
---|
1606 | } |
---|
1607 | delete m_scalingList; |
---|
1608 | } |
---|
1609 | |
---|
1610 | TComReferencePictureSet::TComReferencePictureSet() |
---|
1611 | : m_numberOfPictures (0) |
---|
1612 | , m_numberOfNegativePictures (0) |
---|
1613 | , m_numberOfPositivePictures (0) |
---|
1614 | , m_numberOfLongtermPictures (0) |
---|
1615 | , m_interRPSPrediction (0) |
---|
1616 | , m_deltaRIdxMinus1 (0) |
---|
1617 | , m_deltaRPS (0) |
---|
1618 | , m_numRefIdc (0) |
---|
1619 | { |
---|
1620 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
1621 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
1622 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
1623 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
1624 | } |
---|
1625 | |
---|
1626 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
1627 | { |
---|
1628 | } |
---|
1629 | |
---|
1630 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
1631 | { |
---|
1632 | m_used[bufferNum] = used; |
---|
1633 | } |
---|
1634 | |
---|
1635 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
1636 | { |
---|
1637 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
1638 | } |
---|
1639 | |
---|
1640 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
1641 | { |
---|
1642 | m_numberOfPictures = numberOfPictures; |
---|
1643 | } |
---|
1644 | |
---|
1645 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
1646 | { |
---|
1647 | return m_used[bufferNum]; |
---|
1648 | } |
---|
1649 | |
---|
1650 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
1651 | { |
---|
1652 | return m_deltaPOC[bufferNum]; |
---|
1653 | } |
---|
1654 | |
---|
1655 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
1656 | { |
---|
1657 | return m_numberOfPictures; |
---|
1658 | } |
---|
1659 | |
---|
1660 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
1661 | { |
---|
1662 | return m_POC[bufferNum]; |
---|
1663 | } |
---|
1664 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
1665 | { |
---|
1666 | m_POC[bufferNum] = POC; |
---|
1667 | } |
---|
1668 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) |
---|
1669 | { |
---|
1670 | return m_bCheckLTMSB[bufferNum]; |
---|
1671 | } |
---|
1672 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
1673 | { |
---|
1674 | m_bCheckLTMSB[bufferNum] = b; |
---|
1675 | } |
---|
1676 | |
---|
1677 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
1678 | * \param uiBufferNum |
---|
1679 | * \param iRefIdc |
---|
1680 | * \returns Void |
---|
1681 | */ |
---|
1682 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
1683 | { |
---|
1684 | m_refIdc[bufferNum] = refIdc; |
---|
1685 | } |
---|
1686 | |
---|
1687 | /** get the reference idc value at uiBufferNum |
---|
1688 | * \param uiBufferNum |
---|
1689 | * \returns Int |
---|
1690 | */ |
---|
1691 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
1692 | { |
---|
1693 | return m_refIdc[bufferNum]; |
---|
1694 | } |
---|
1695 | |
---|
1696 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
1697 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
1698 | * +ve values are in increasing order. |
---|
1699 | * \returns Void |
---|
1700 | */ |
---|
1701 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
1702 | { |
---|
1703 | // sort in increasing order (smallest first) |
---|
1704 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
1705 | { |
---|
1706 | Int deltaPOC = getDeltaPOC(j); |
---|
1707 | Bool used = getUsed(j); |
---|
1708 | for (Int k=j-1; k >= 0; k--) |
---|
1709 | { |
---|
1710 | Int temp = getDeltaPOC(k); |
---|
1711 | if (deltaPOC < temp) |
---|
1712 | { |
---|
1713 | setDeltaPOC(k+1, temp); |
---|
1714 | setUsed(k+1, getUsed(k)); |
---|
1715 | setDeltaPOC(k, deltaPOC); |
---|
1716 | setUsed(k, used); |
---|
1717 | } |
---|
1718 | } |
---|
1719 | } |
---|
1720 | // flip the negative values to largest first |
---|
1721 | Int numNegPics = getNumberOfNegativePictures(); |
---|
1722 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
1723 | { |
---|
1724 | Int deltaPOC = getDeltaPOC(j); |
---|
1725 | Bool used = getUsed(j); |
---|
1726 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
1727 | setUsed(j, getUsed(k)); |
---|
1728 | setDeltaPOC(k, deltaPOC); |
---|
1729 | setUsed(k, used); |
---|
1730 | } |
---|
1731 | } |
---|
1732 | |
---|
1733 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
1734 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
1735 | * \returns Void |
---|
1736 | */ |
---|
1737 | Void TComReferencePictureSet::printDeltaPOC() |
---|
1738 | { |
---|
1739 | printf("DeltaPOC = { "); |
---|
1740 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
1741 | { |
---|
1742 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
1743 | } |
---|
1744 | if (getInterRPSPrediction()) |
---|
1745 | { |
---|
1746 | printf("}, RefIdc = { "); |
---|
1747 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
1748 | { |
---|
1749 | printf("%d ", getRefIdc(j)); |
---|
1750 | } |
---|
1751 | } |
---|
1752 | printf("}\n"); |
---|
1753 | } |
---|
1754 | |
---|
1755 | TComRPSList::TComRPSList() |
---|
1756 | :m_referencePictureSets (NULL) |
---|
1757 | { |
---|
1758 | } |
---|
1759 | |
---|
1760 | TComRPSList::~TComRPSList() |
---|
1761 | { |
---|
1762 | } |
---|
1763 | |
---|
1764 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
1765 | { |
---|
1766 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
1767 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
1768 | } |
---|
1769 | |
---|
1770 | Void TComRPSList::destroy() |
---|
1771 | { |
---|
1772 | if (m_referencePictureSets) |
---|
1773 | { |
---|
1774 | delete [] m_referencePictureSets; |
---|
1775 | } |
---|
1776 | m_numberOfReferencePictureSets = 0; |
---|
1777 | m_referencePictureSets = NULL; |
---|
1778 | } |
---|
1779 | |
---|
1780 | |
---|
1781 | |
---|
1782 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
1783 | { |
---|
1784 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
1785 | } |
---|
1786 | |
---|
1787 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
1788 | { |
---|
1789 | return m_numberOfReferencePictureSets; |
---|
1790 | } |
---|
1791 | |
---|
1792 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
1793 | { |
---|
1794 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
1795 | } |
---|
1796 | |
---|
1797 | TComRefPicListModification::TComRefPicListModification() |
---|
1798 | : m_bRefPicListModificationFlagL0 (false) |
---|
1799 | , m_bRefPicListModificationFlagL1 (false) |
---|
1800 | { |
---|
1801 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
1802 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
1803 | } |
---|
1804 | |
---|
1805 | TComRefPicListModification::~TComRefPicListModification() |
---|
1806 | { |
---|
1807 | } |
---|
1808 | |
---|
1809 | #if !REMOVE_APS |
---|
1810 | TComAPS::TComAPS() |
---|
1811 | { |
---|
1812 | m_apsID = 0; |
---|
1813 | m_pSaoParam = NULL; |
---|
1814 | #if !REMOVE_ALF |
---|
1815 | m_alfParam[0] = m_alfParam[1] = m_alfParam[2] = NULL; |
---|
1816 | #endif |
---|
1817 | } |
---|
1818 | |
---|
1819 | TComAPS::~TComAPS() |
---|
1820 | { |
---|
1821 | delete m_pSaoParam; |
---|
1822 | #if !REMOVE_ALF |
---|
1823 | for(Int compIdx =0; compIdx < 3; compIdx++) |
---|
1824 | { |
---|
1825 | delete m_alfParam[compIdx]; |
---|
1826 | m_alfParam[compIdx] = NULL; |
---|
1827 | } |
---|
1828 | #endif |
---|
1829 | } |
---|
1830 | |
---|
1831 | TComAPS& TComAPS::operator= (const TComAPS& src) |
---|
1832 | { |
---|
1833 | m_apsID = src.m_apsID; |
---|
1834 | m_pSaoParam = src.m_pSaoParam; |
---|
1835 | #if !REMOVE_ALF |
---|
1836 | for(Int compIdx =0; compIdx < 3; compIdx++) |
---|
1837 | { |
---|
1838 | m_alfParam[compIdx] = src.m_alfParam[compIdx]; |
---|
1839 | } |
---|
1840 | #endif |
---|
1841 | return *this; |
---|
1842 | } |
---|
1843 | |
---|
1844 | Void TComAPS::createSaoParam() |
---|
1845 | { |
---|
1846 | m_pSaoParam = new SAOParam; |
---|
1847 | } |
---|
1848 | |
---|
1849 | Void TComAPS::destroySaoParam() |
---|
1850 | { |
---|
1851 | if(m_pSaoParam != NULL) |
---|
1852 | { |
---|
1853 | delete m_pSaoParam; |
---|
1854 | m_pSaoParam = NULL; |
---|
1855 | } |
---|
1856 | } |
---|
1857 | |
---|
1858 | #if !REMOVE_ALF |
---|
1859 | Void TComAPS::createAlfParam() |
---|
1860 | { |
---|
1861 | for(Int compIdx =0; compIdx < 3; compIdx++) |
---|
1862 | { |
---|
1863 | m_alfParam[compIdx] = new ALFParam(compIdx); |
---|
1864 | m_alfParam[compIdx]->alf_flag = 0; |
---|
1865 | } |
---|
1866 | } |
---|
1867 | Void TComAPS::destroyAlfParam() |
---|
1868 | { |
---|
1869 | for(Int compIdx=0; compIdx < 3; compIdx++) |
---|
1870 | { |
---|
1871 | if(m_alfParam[compIdx] != NULL) |
---|
1872 | { |
---|
1873 | delete m_alfParam[compIdx]; |
---|
1874 | m_alfParam[compIdx] = NULL; |
---|
1875 | } |
---|
1876 | } |
---|
1877 | } |
---|
1878 | #endif |
---|
1879 | #endif |
---|
1880 | |
---|
1881 | TComScalingList::TComScalingList() |
---|
1882 | { |
---|
1883 | #if TS_FLAT_QUANTIZATION_MATRIX |
---|
1884 | m_useTransformSkip = false; |
---|
1885 | #endif |
---|
1886 | init(); |
---|
1887 | } |
---|
1888 | TComScalingList::~TComScalingList() |
---|
1889 | { |
---|
1890 | destroy(); |
---|
1891 | } |
---|
1892 | |
---|
1893 | /** set default quantization matrix to array |
---|
1894 | */ |
---|
1895 | Void TComSlice::setDefaultScalingList() |
---|
1896 | { |
---|
1897 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
1898 | { |
---|
1899 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
1900 | { |
---|
1901 | getScalingList()->processDefaultMarix(sizeId, listId); |
---|
1902 | } |
---|
1903 | } |
---|
1904 | } |
---|
1905 | /** check if use default quantization matrix |
---|
1906 | * \returns true if use default quantization matrix in all size |
---|
1907 | */ |
---|
1908 | Bool TComSlice::checkDefaultScalingList() |
---|
1909 | { |
---|
1910 | UInt defaultCounter=0; |
---|
1911 | |
---|
1912 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
1913 | { |
---|
1914 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
1915 | { |
---|
1916 | 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 |
---|
1917 | && ((sizeId < SCALING_LIST_16x16) || (getScalingList()->getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
1918 | { |
---|
1919 | defaultCounter++; |
---|
1920 | } |
---|
1921 | } |
---|
1922 | } |
---|
1923 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32 |
---|
1924 | } |
---|
1925 | /** get scaling matrix from RefMatrixID |
---|
1926 | * \param sizeId size index |
---|
1927 | * \param Index of input matrix |
---|
1928 | * \param Index of reference matrix |
---|
1929 | */ |
---|
1930 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
1931 | { |
---|
1932 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
1933 | } |
---|
1934 | /** parse syntax infomation |
---|
1935 | * \param pchFile syntax infomation |
---|
1936 | * \returns false if successful |
---|
1937 | */ |
---|
1938 | Bool TComScalingList::xParseScalingList(char* pchFile) |
---|
1939 | { |
---|
1940 | FILE *fp; |
---|
1941 | Char line[1024]; |
---|
1942 | UInt sizeIdc,listIdc; |
---|
1943 | UInt i,size = 0; |
---|
1944 | Int *src=0,data; |
---|
1945 | Char *ret; |
---|
1946 | UInt retval; |
---|
1947 | |
---|
1948 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
1949 | { |
---|
1950 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
1951 | return true; |
---|
1952 | } |
---|
1953 | |
---|
1954 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
1955 | { |
---|
1956 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
1957 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
1958 | { |
---|
1959 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
1960 | |
---|
1961 | fseek(fp,0,0); |
---|
1962 | do |
---|
1963 | { |
---|
1964 | ret = fgets(line, 1024, fp); |
---|
1965 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
1966 | { |
---|
1967 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
1968 | return true; |
---|
1969 | } |
---|
1970 | } |
---|
1971 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
1972 | for (i=0; i<size; i++) |
---|
1973 | { |
---|
1974 | retval = fscanf(fp, "%d,", &data); |
---|
1975 | if (retval!=1) |
---|
1976 | { |
---|
1977 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
1978 | return true; |
---|
1979 | } |
---|
1980 | src[i] = data; |
---|
1981 | } |
---|
1982 | //set DC value for default matrix check |
---|
1983 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
1984 | |
---|
1985 | if(sizeIdc > SCALING_LIST_8x8) |
---|
1986 | { |
---|
1987 | fseek(fp,0,0); |
---|
1988 | do |
---|
1989 | { |
---|
1990 | ret = fgets(line, 1024, fp); |
---|
1991 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
1992 | { |
---|
1993 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
1994 | return true; |
---|
1995 | } |
---|
1996 | } |
---|
1997 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
1998 | retval = fscanf(fp, "%d,", &data); |
---|
1999 | if (retval!=1) |
---|
2000 | { |
---|
2001 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2002 | return true; |
---|
2003 | } |
---|
2004 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
2005 | setScalingListDC(sizeIdc,listIdc,data); |
---|
2006 | } |
---|
2007 | } |
---|
2008 | } |
---|
2009 | fclose(fp); |
---|
2010 | return false; |
---|
2011 | } |
---|
2012 | |
---|
2013 | /** initialization process of quantization matrix array |
---|
2014 | */ |
---|
2015 | Void TComScalingList::init() |
---|
2016 | { |
---|
2017 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2018 | { |
---|
2019 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2020 | { |
---|
2021 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
2022 | } |
---|
2023 | } |
---|
2024 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
2025 | } |
---|
2026 | /** destroy quantization matrix array |
---|
2027 | */ |
---|
2028 | Void TComScalingList::destroy() |
---|
2029 | { |
---|
2030 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2031 | { |
---|
2032 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2033 | { |
---|
2034 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
2035 | } |
---|
2036 | } |
---|
2037 | } |
---|
2038 | /** get default address of quantization matrix |
---|
2039 | * \param sizeId size index |
---|
2040 | * \param listId list index |
---|
2041 | * \returns pointer of quantization matrix |
---|
2042 | */ |
---|
2043 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
2044 | { |
---|
2045 | Int *src = 0; |
---|
2046 | switch(sizeId) |
---|
2047 | { |
---|
2048 | case SCALING_LIST_4x4: |
---|
2049 | #if TS_FLAT_QUANTIZATION_MATRIX |
---|
2050 | if( m_useTransformSkip ) |
---|
2051 | { |
---|
2052 | src = g_quantTSDefault4x4; |
---|
2053 | } |
---|
2054 | else |
---|
2055 | { |
---|
2056 | src = (listId<3) ? g_quantIntraDefault4x4 : g_quantInterDefault4x4; |
---|
2057 | } |
---|
2058 | #else |
---|
2059 | src = (listId<3) ? g_quantIntraDefault4x4 : g_quantInterDefault4x4; |
---|
2060 | #endif |
---|
2061 | break; |
---|
2062 | case SCALING_LIST_8x8: |
---|
2063 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2064 | break; |
---|
2065 | case SCALING_LIST_16x16: |
---|
2066 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2067 | break; |
---|
2068 | case SCALING_LIST_32x32: |
---|
2069 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2070 | break; |
---|
2071 | default: |
---|
2072 | assert(0); |
---|
2073 | src = NULL; |
---|
2074 | break; |
---|
2075 | } |
---|
2076 | return src; |
---|
2077 | } |
---|
2078 | /** process of default matrix |
---|
2079 | * \param sizeId size index |
---|
2080 | * \param Index of input matrix |
---|
2081 | */ |
---|
2082 | Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId) |
---|
2083 | { |
---|
2084 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2085 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
2086 | } |
---|
2087 | /** check DC value of matrix for default matrix signaling |
---|
2088 | */ |
---|
2089 | Void TComScalingList::checkDcOfMatrix() |
---|
2090 | { |
---|
2091 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2092 | { |
---|
2093 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2094 | { |
---|
2095 | //check default matrix? |
---|
2096 | if(getScalingListDC(sizeId,listId) == 0) |
---|
2097 | { |
---|
2098 | processDefaultMarix(sizeId, listId); |
---|
2099 | } |
---|
2100 | } |
---|
2101 | } |
---|
2102 | } |
---|
2103 | |
---|
2104 | ParameterSetManager::ParameterSetManager() |
---|
2105 | : m_vpsMap(MAX_NUM_VPS) |
---|
2106 | , m_spsMap(MAX_NUM_SPS) |
---|
2107 | , m_ppsMap(MAX_NUM_PPS) |
---|
2108 | #if !REMOVE_APS |
---|
2109 | , m_apsMap(MAX_NUM_APS) |
---|
2110 | #endif |
---|
2111 | { |
---|
2112 | } |
---|
2113 | |
---|
2114 | |
---|
2115 | ParameterSetManager::~ParameterSetManager() |
---|
2116 | { |
---|
2117 | } |
---|
2118 | |
---|
2119 | #if PROFILE_TIER_LEVEL_SYNTAX |
---|
2120 | ProfileTierLevel::ProfileTierLevel() |
---|
2121 | : m_profileSpace (0) |
---|
2122 | , m_tierFlag (false) |
---|
2123 | , m_profileIdc (0) |
---|
2124 | , m_levelIdc (0) |
---|
2125 | { |
---|
2126 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
2127 | } |
---|
2128 | TComPTL::TComPTL() |
---|
2129 | { |
---|
2130 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
2131 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
2132 | } |
---|
2133 | #endif |
---|
2134 | //! \} |
---|