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