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