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 | #endif |
---|
1532 | { |
---|
1533 | #if !H0566_TLA |
---|
1534 | for ( UInt i = 0; i < MAX_TLAYER; i++ ) |
---|
1535 | { |
---|
1536 | m_abTLayerSwitchingFlag[i] = false; |
---|
1537 | } |
---|
1538 | #endif |
---|
1539 | } |
---|
1540 | |
---|
1541 | TComPPS::~TComPPS() |
---|
1542 | { |
---|
1543 | if( m_iNumColumnsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
1544 | { |
---|
1545 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
1546 | m_puiColumnWidth = NULL; |
---|
1547 | } |
---|
1548 | if( m_iNumRowsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
1549 | { |
---|
1550 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
1551 | m_puiRowHeight = NULL; |
---|
1552 | } |
---|
1553 | } |
---|
1554 | |
---|
1555 | Void |
---|
1556 | TComSPS::initMultiviewSPS( UInt uiViewId, Int iViewOrderIdx, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset ) |
---|
1557 | { |
---|
1558 | AOT( uiViewId == 0 && iViewOrderIdx != 0 ); |
---|
1559 | AOT( uiViewId != 0 && iViewOrderIdx == 0 ); |
---|
1560 | AOT( uiViewId != 0 && !bCamParSlice && ( aaiScale == 0 || aaiOffset == 0 ) ); |
---|
1561 | |
---|
1562 | m_uiViewId = uiViewId; |
---|
1563 | m_iViewOrderIdx = iViewOrderIdx; |
---|
1564 | m_bDepth = false; |
---|
1565 | m_uiCamParPrecision = ( m_uiViewId ? uiCamParPrecision : 0 ); |
---|
1566 | m_bCamParInSliceHeader = ( m_uiViewId ? bCamParSlice : false ); |
---|
1567 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
1568 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
1569 | if( !m_bCamParInSliceHeader ) |
---|
1570 | { |
---|
1571 | for( UInt uiBaseViewId = 0; uiBaseViewId < m_uiViewId; uiBaseViewId++ ) |
---|
1572 | { |
---|
1573 | m_aaiCodedScale [ 0 ][ uiBaseViewId ] = aaiScale [ uiBaseViewId ][ m_uiViewId ]; |
---|
1574 | m_aaiCodedScale [ 1 ][ uiBaseViewId ] = aaiScale [ m_uiViewId ][ uiBaseViewId ]; |
---|
1575 | m_aaiCodedOffset[ 0 ][ uiBaseViewId ] = aaiOffset[ uiBaseViewId ][ m_uiViewId ]; |
---|
1576 | m_aaiCodedOffset[ 1 ][ uiBaseViewId ] = aaiOffset[ m_uiViewId ][ uiBaseViewId ]; |
---|
1577 | } |
---|
1578 | } |
---|
1579 | } |
---|
1580 | |
---|
1581 | Void |
---|
1582 | TComSPS::initMultiviewSPSDepth( UInt uiViewId, Int iViewOrderIdx ) |
---|
1583 | { |
---|
1584 | AOT( uiViewId == 0 && iViewOrderIdx != 0 ); |
---|
1585 | AOT( uiViewId != 0 && iViewOrderIdx == 0 ); |
---|
1586 | |
---|
1587 | m_uiViewId = uiViewId; |
---|
1588 | m_iViewOrderIdx = iViewOrderIdx; |
---|
1589 | m_bDepth = true; |
---|
1590 | m_uiCamParPrecision = 0; |
---|
1591 | m_bCamParInSliceHeader = false; |
---|
1592 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
1593 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
1594 | } |
---|
1595 | |
---|
1596 | #if DEPTH_MAP_GENERATION |
---|
1597 | Void |
---|
1598 | TComSPS::setPredDepthMapGeneration( UInt uiViewId, Bool bIsDepth, UInt uiPdmGenMode, UInt uiPdmMvPredMode, UInt uiPdmPrec, Int** aaiPdmScaleNomDelta, Int** aaiPdmOffset ) |
---|
1599 | { |
---|
1600 | AOF( m_uiViewId == uiViewId ); |
---|
1601 | AOF( m_bDepth == bIsDepth ); |
---|
1602 | AOT( ( uiViewId == 0 || bIsDepth ) && uiPdmGenMode ); |
---|
1603 | AOT( uiPdmGenMode && ( aaiPdmScaleNomDelta == 0 || aaiPdmOffset == 0 ) ); |
---|
1604 | AOT( uiPdmMvPredMode && uiPdmGenMode == 0 ); |
---|
1605 | |
---|
1606 | m_uiPredDepthMapGeneration = uiPdmGenMode; |
---|
1607 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
1608 | m_uiMultiviewMvPredMode = uiPdmMvPredMode; |
---|
1609 | #endif |
---|
1610 | |
---|
1611 | m_uiPdmPrecision = ( m_uiPredDepthMapGeneration ? uiPdmPrec : 0 ); |
---|
1612 | ::memset( m_aiPdmScaleNomDelta, 0x00, sizeof( m_aiPdmScaleNomDelta ) ); |
---|
1613 | ::memset( m_aiPdmOffset, 0x00, sizeof( m_aiPdmOffset ) ); |
---|
1614 | if( m_uiPredDepthMapGeneration ) |
---|
1615 | { |
---|
1616 | for( UInt uiBaseId = 0; uiBaseId < m_uiViewId; uiBaseId++ ) |
---|
1617 | { |
---|
1618 | m_aiPdmScaleNomDelta[ uiBaseId ] = aaiPdmScaleNomDelta[ m_uiViewId ][ uiBaseId ]; |
---|
1619 | m_aiPdmOffset [ uiBaseId ] = aaiPdmOffset [ m_uiViewId ][ uiBaseId ]; |
---|
1620 | } |
---|
1621 | } |
---|
1622 | } |
---|
1623 | #endif |
---|
1624 | |
---|
1625 | TComReferencePictureSet::TComReferencePictureSet() |
---|
1626 | : m_numberOfPictures (0) |
---|
1627 | , m_numberOfNegativePictures (0) |
---|
1628 | , m_numberOfPositivePictures (0) |
---|
1629 | , m_numberOfLongtermPictures (0) |
---|
1630 | , m_interRPSPrediction (0) |
---|
1631 | , m_deltaRIdxMinus1 (0) |
---|
1632 | , m_deltaRPS (0) |
---|
1633 | , m_numRefIdc (0) |
---|
1634 | { |
---|
1635 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
1636 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
1637 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
1638 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
1639 | } |
---|
1640 | |
---|
1641 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
1642 | { |
---|
1643 | } |
---|
1644 | |
---|
1645 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
1646 | { |
---|
1647 | m_used[bufferNum] = used; |
---|
1648 | } |
---|
1649 | |
---|
1650 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
1651 | { |
---|
1652 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
1653 | } |
---|
1654 | |
---|
1655 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
1656 | { |
---|
1657 | m_numberOfPictures = numberOfPictures; |
---|
1658 | } |
---|
1659 | |
---|
1660 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
1661 | { |
---|
1662 | return m_used[bufferNum]; |
---|
1663 | } |
---|
1664 | |
---|
1665 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
1666 | { |
---|
1667 | return m_deltaPOC[bufferNum]; |
---|
1668 | } |
---|
1669 | |
---|
1670 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
1671 | { |
---|
1672 | return m_numberOfPictures; |
---|
1673 | } |
---|
1674 | |
---|
1675 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
1676 | { |
---|
1677 | return m_POC[bufferNum]; |
---|
1678 | } |
---|
1679 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
1680 | { |
---|
1681 | m_POC[bufferNum] = POC; |
---|
1682 | } |
---|
1683 | |
---|
1684 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
1685 | * \param uiBufferNum |
---|
1686 | * \param iRefIdc |
---|
1687 | * \returns Void |
---|
1688 | */ |
---|
1689 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
1690 | { |
---|
1691 | m_refIdc[bufferNum] = refIdc; |
---|
1692 | } |
---|
1693 | |
---|
1694 | /** get the reference idc value at uiBufferNum |
---|
1695 | * \param uiBufferNum |
---|
1696 | * \returns Int |
---|
1697 | */ |
---|
1698 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
1699 | { |
---|
1700 | return m_refIdc[bufferNum]; |
---|
1701 | } |
---|
1702 | |
---|
1703 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
1704 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
1705 | * +ve values are in increasing order. |
---|
1706 | * \returns Void |
---|
1707 | */ |
---|
1708 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
1709 | { |
---|
1710 | // sort in increasing order (smallest first) |
---|
1711 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
1712 | { |
---|
1713 | Int deltaPOC = getDeltaPOC(j); |
---|
1714 | Bool used = getUsed(j); |
---|
1715 | for (Int k=j-1; k >= 0; k--) |
---|
1716 | { |
---|
1717 | Int temp = getDeltaPOC(k); |
---|
1718 | if (deltaPOC < temp) |
---|
1719 | { |
---|
1720 | setDeltaPOC(k+1, temp); |
---|
1721 | setUsed(k+1, getUsed(k)); |
---|
1722 | setDeltaPOC(k, deltaPOC); |
---|
1723 | setUsed(k, used); |
---|
1724 | } |
---|
1725 | } |
---|
1726 | } |
---|
1727 | // flip the negative values to largest first |
---|
1728 | Int numNegPics = getNumberOfNegativePictures(); |
---|
1729 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
1730 | { |
---|
1731 | Int deltaPOC = getDeltaPOC(j); |
---|
1732 | Bool used = getUsed(j); |
---|
1733 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
1734 | setUsed(j, getUsed(k)); |
---|
1735 | setDeltaPOC(k, deltaPOC); |
---|
1736 | setUsed(k, used); |
---|
1737 | } |
---|
1738 | } |
---|
1739 | |
---|
1740 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
1741 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
1742 | * \returns Void |
---|
1743 | */ |
---|
1744 | Void TComReferencePictureSet::printDeltaPOC() |
---|
1745 | { |
---|
1746 | printf("DeltaPOC = { "); |
---|
1747 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
1748 | { |
---|
1749 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
1750 | } |
---|
1751 | if (getInterRPSPrediction()) |
---|
1752 | { |
---|
1753 | printf("}, RefIdc = { "); |
---|
1754 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
1755 | { |
---|
1756 | printf("%d ", getRefIdc(j)); |
---|
1757 | } |
---|
1758 | } |
---|
1759 | printf("}\n"); |
---|
1760 | } |
---|
1761 | |
---|
1762 | TComRPSList::TComRPSList() |
---|
1763 | { |
---|
1764 | } |
---|
1765 | |
---|
1766 | TComRPSList::~TComRPSList() |
---|
1767 | { |
---|
1768 | } |
---|
1769 | |
---|
1770 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
1771 | { |
---|
1772 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
1773 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
1774 | } |
---|
1775 | |
---|
1776 | Void TComRPSList::destroy() |
---|
1777 | { |
---|
1778 | delete [] m_referencePictureSets; |
---|
1779 | m_numberOfReferencePictureSets = 0; |
---|
1780 | m_referencePictureSets = NULL; |
---|
1781 | } |
---|
1782 | |
---|
1783 | |
---|
1784 | |
---|
1785 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
1786 | { |
---|
1787 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
1788 | } |
---|
1789 | |
---|
1790 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
1791 | { |
---|
1792 | return m_numberOfReferencePictureSets; |
---|
1793 | } |
---|
1794 | |
---|
1795 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
1796 | { |
---|
1797 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
1798 | } |
---|
1799 | |
---|
1800 | TComRefPicListModification::TComRefPicListModification() |
---|
1801 | : m_bRefPicListModificationFlagL0 (false) |
---|
1802 | , m_bRefPicListModificationFlagL1 (false) |
---|
1803 | #if !H0137_0138_LIST_MODIFICATION |
---|
1804 | , m_uiNumberOfRefPicListModificationsL0 (0) |
---|
1805 | , m_uiNumberOfRefPicListModificationsL1 (0) |
---|
1806 | #endif |
---|
1807 | { |
---|
1808 | #if !H0137_0138_LIST_MODIFICATION |
---|
1809 | ::memset( m_ListIdcL0, 0, sizeof(m_ListIdcL0) ); |
---|
1810 | #endif |
---|
1811 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
1812 | #if !H0137_0138_LIST_MODIFICATION |
---|
1813 | ::memset( m_ListIdcL1, 0, sizeof(m_ListIdcL1) ); |
---|
1814 | #endif |
---|
1815 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
1816 | } |
---|
1817 | |
---|
1818 | TComRefPicListModification::~TComRefPicListModification() |
---|
1819 | { |
---|
1820 | } |
---|
1821 | |
---|
1822 | TComAPS::TComAPS() |
---|
1823 | { |
---|
1824 | m_apsID = 0; |
---|
1825 | m_bAlfEnabled = false; |
---|
1826 | m_bSaoEnabled = false; |
---|
1827 | m_pSaoParam = NULL; |
---|
1828 | #if LCU_SYNTAX_ALF |
---|
1829 | m_alfParamSet = NULL; |
---|
1830 | #else |
---|
1831 | m_pAlfParam = NULL; |
---|
1832 | #endif |
---|
1833 | m_scalingList = NULL; |
---|
1834 | m_scalingListEnabled = false; |
---|
1835 | } |
---|
1836 | |
---|
1837 | TComAPS::~TComAPS() |
---|
1838 | { |
---|
1839 | |
---|
1840 | } |
---|
1841 | |
---|
1842 | TComAPS& TComAPS::operator= (const TComAPS& src) |
---|
1843 | { |
---|
1844 | m_apsID = src.m_apsID; |
---|
1845 | m_loopFilterOffsetInAPS = src.m_loopFilterOffsetInAPS; |
---|
1846 | m_loopFilterDisable = src.m_loopFilterDisable; |
---|
1847 | m_loopFilterBetaOffsetDiv2 = src.m_loopFilterBetaOffsetDiv2; |
---|
1848 | m_loopFilterTcOffsetDiv2 = src.m_loopFilterTcOffsetDiv2; |
---|
1849 | m_bAlfEnabled = src.m_bAlfEnabled; |
---|
1850 | m_bSaoEnabled = src.m_bSaoEnabled; |
---|
1851 | m_pSaoParam = src.m_pSaoParam; |
---|
1852 | #if LCU_SYNTAX_ALF |
---|
1853 | m_alfParamSet = src.m_alfParamSet; |
---|
1854 | #else |
---|
1855 | m_pAlfParam = src.m_pAlfParam; |
---|
1856 | #endif |
---|
1857 | m_scalingList = src.m_scalingList; |
---|
1858 | m_scalingListEnabled = src.m_scalingListEnabled; |
---|
1859 | #if SAO_UNIT_INTERLEAVING |
---|
1860 | m_saoInterleavingFlag = src.m_saoInterleavingFlag; |
---|
1861 | #endif |
---|
1862 | |
---|
1863 | return *this; |
---|
1864 | } |
---|
1865 | |
---|
1866 | Void TComAPS::createSaoParam() |
---|
1867 | { |
---|
1868 | m_pSaoParam = new SAOParam; |
---|
1869 | } |
---|
1870 | |
---|
1871 | Void TComAPS::destroySaoParam() |
---|
1872 | { |
---|
1873 | if(m_pSaoParam != NULL) |
---|
1874 | { |
---|
1875 | delete m_pSaoParam; |
---|
1876 | m_pSaoParam = NULL; |
---|
1877 | } |
---|
1878 | } |
---|
1879 | |
---|
1880 | Void TComAPS::createAlfParam() |
---|
1881 | { |
---|
1882 | #if LCU_SYNTAX_ALF |
---|
1883 | m_alfParamSet = new AlfParamSet; |
---|
1884 | #else |
---|
1885 | m_pAlfParam = new ALFParam; |
---|
1886 | #endif |
---|
1887 | } |
---|
1888 | Void TComAPS::destroyAlfParam() |
---|
1889 | { |
---|
1890 | #if LCU_SYNTAX_ALF |
---|
1891 | if(m_alfParamSet != NULL) |
---|
1892 | { |
---|
1893 | delete m_alfParamSet; |
---|
1894 | m_alfParamSet = NULL; |
---|
1895 | } |
---|
1896 | #else |
---|
1897 | if(m_pAlfParam != NULL) |
---|
1898 | { |
---|
1899 | delete m_pAlfParam; |
---|
1900 | m_pAlfParam = NULL; |
---|
1901 | } |
---|
1902 | #endif |
---|
1903 | } |
---|
1904 | |
---|
1905 | Void TComAPS::createScalingList() |
---|
1906 | { |
---|
1907 | m_scalingList = new TComScalingList; |
---|
1908 | } |
---|
1909 | Void TComAPS::destroyScalingList() |
---|
1910 | { |
---|
1911 | delete m_scalingList; |
---|
1912 | } |
---|
1913 | |
---|
1914 | TComScalingList::TComScalingList() |
---|
1915 | { |
---|
1916 | init(); |
---|
1917 | } |
---|
1918 | TComScalingList::~TComScalingList() |
---|
1919 | { |
---|
1920 | destroy(); |
---|
1921 | } |
---|
1922 | |
---|
1923 | /** set default quantization matrix to array |
---|
1924 | */ |
---|
1925 | Void TComSlice::setDefaultScalingList() |
---|
1926 | { |
---|
1927 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
1928 | { |
---|
1929 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
1930 | { |
---|
1931 | getScalingList()->processDefaultMarix(sizeId, listId); |
---|
1932 | } |
---|
1933 | } |
---|
1934 | } |
---|
1935 | /** check if use default quantization matrix |
---|
1936 | * \returns true if use default quantization matrix in all size |
---|
1937 | */ |
---|
1938 | #if SCALING_LIST |
---|
1939 | Bool TComSlice::checkDefaultScalingList() |
---|
1940 | { |
---|
1941 | UInt defaultCounter=0; |
---|
1942 | |
---|
1943 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
1944 | { |
---|
1945 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
1946 | { |
---|
1947 | if(getScalingList()->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
1948 | { |
---|
1949 | defaultCounter++; |
---|
1950 | } |
---|
1951 | } |
---|
1952 | } |
---|
1953 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? true : false; // -4 for 32x32 |
---|
1954 | } |
---|
1955 | #else |
---|
1956 | Bool TComSlice::checkDefaultScalingList() |
---|
1957 | { |
---|
1958 | UInt i; |
---|
1959 | Int *dst=0; |
---|
1960 | Int *src=0; |
---|
1961 | UInt defaultCounter=0; |
---|
1962 | |
---|
1963 | //4x4 |
---|
1964 | for(i=0;i<SCALING_LIST_NUM;i++) |
---|
1965 | { |
---|
1966 | src = (i<3) ? g_quantIntraDefault4x4 : g_quantInterDefault4x4; |
---|
1967 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_4x4,i); |
---|
1968 | if(::memcmp(dst,src,sizeof(UInt)*16) == 0) defaultCounter++; |
---|
1969 | } |
---|
1970 | |
---|
1971 | //8x8 |
---|
1972 | for(i=0;i<SCALING_LIST_NUM;i++) |
---|
1973 | { |
---|
1974 | src = (i<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
1975 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_8x8,i); |
---|
1976 | if(::memcmp(dst,src,sizeof(UInt)*64) == 0) defaultCounter++; |
---|
1977 | } |
---|
1978 | //16x16 |
---|
1979 | for(i=0;i<SCALING_LIST_NUM;i++) |
---|
1980 | { |
---|
1981 | src = (i<3) ? g_quantIntraDefault16x16 : g_quantInterDefault16x16; |
---|
1982 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_16x16,i); |
---|
1983 | if(::memcmp(dst,src,sizeof(UInt)*256) == 0) defaultCounter++; |
---|
1984 | } |
---|
1985 | //32x32 |
---|
1986 | for(i=0;i<SCALING_LIST_NUM_32x32;i++) |
---|
1987 | { |
---|
1988 | src = (i<1) ? g_quantIntraDefault32x32 : g_quantInterDefault32x32; |
---|
1989 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_32x32,i*3); |
---|
1990 | if(::memcmp(dst,src,sizeof(UInt)*1024) == 0) defaultCounter++; |
---|
1991 | } |
---|
1992 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? true : false; // -4 for 32x32 |
---|
1993 | } |
---|
1994 | #endif |
---|
1995 | /** get scaling matrix from RefMatrixID |
---|
1996 | * \param sizeId size index |
---|
1997 | * \param Index of input matrix |
---|
1998 | * \param Index of reference matrix |
---|
1999 | */ |
---|
2000 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
2001 | { |
---|
2002 | #if SCALING_LIST |
---|
2003 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListAddress(sizeId, refListId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2004 | #else |
---|
2005 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListAddress(sizeId, refListId),sizeof(Int)*g_scalingListSize[sizeId]); |
---|
2006 | #endif |
---|
2007 | } |
---|
2008 | /** parse syntax infomation |
---|
2009 | * \param pchFile syntax infomation |
---|
2010 | * \returns false if successful |
---|
2011 | */ |
---|
2012 | Bool TComScalingList::xParseScalingList(char* pchFile) |
---|
2013 | { |
---|
2014 | FILE *fp; |
---|
2015 | Char line[1024]; |
---|
2016 | UInt sizeIdc,listIdc; |
---|
2017 | UInt i,size = 0; |
---|
2018 | Int *src=0,data; |
---|
2019 | Char *ret; |
---|
2020 | UInt retval; |
---|
2021 | |
---|
2022 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
2023 | { |
---|
2024 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
2025 | return true; |
---|
2026 | } |
---|
2027 | |
---|
2028 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
2029 | { |
---|
2030 | #if SCALING_LIST |
---|
2031 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
2032 | #else |
---|
2033 | size = g_scalingListSize[sizeIdc]; |
---|
2034 | #endif |
---|
2035 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
2036 | { |
---|
2037 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
2038 | |
---|
2039 | fseek(fp,0,0); |
---|
2040 | do |
---|
2041 | { |
---|
2042 | ret = fgets(line, 1024, fp); |
---|
2043 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
2044 | { |
---|
2045 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2046 | return true; |
---|
2047 | } |
---|
2048 | } |
---|
2049 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
2050 | for (i=0; i<size; i++) |
---|
2051 | { |
---|
2052 | retval = fscanf(fp, "%d,", &data); |
---|
2053 | if (retval!=1) |
---|
2054 | { |
---|
2055 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2056 | return true; |
---|
2057 | } |
---|
2058 | src[i] = data; |
---|
2059 | } |
---|
2060 | #if SCALING_LIST |
---|
2061 | //set DC value for default matrix check |
---|
2062 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
2063 | |
---|
2064 | if(sizeIdc > SCALING_LIST_8x8) |
---|
2065 | { |
---|
2066 | fseek(fp,0,0); |
---|
2067 | do |
---|
2068 | { |
---|
2069 | ret = fgets(line, 1024, fp); |
---|
2070 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
2071 | { |
---|
2072 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
2073 | return true; |
---|
2074 | } |
---|
2075 | } |
---|
2076 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
2077 | retval = fscanf(fp, "%d,", &data); |
---|
2078 | if (retval!=1) |
---|
2079 | { |
---|
2080 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2081 | return true; |
---|
2082 | } |
---|
2083 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
2084 | setScalingListDC(sizeIdc,listIdc,data); |
---|
2085 | } |
---|
2086 | #endif |
---|
2087 | } |
---|
2088 | } |
---|
2089 | fclose(fp); |
---|
2090 | return false; |
---|
2091 | } |
---|
2092 | |
---|
2093 | /** initialization process of quantization matrix array |
---|
2094 | */ |
---|
2095 | Void TComScalingList::init() |
---|
2096 | { |
---|
2097 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2098 | { |
---|
2099 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2100 | { |
---|
2101 | #if SCALING_LIST |
---|
2102 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
2103 | #else |
---|
2104 | m_scalingListCoef[sizeId][listId] = new Int [g_scalingListSize[sizeId]]; |
---|
2105 | #endif |
---|
2106 | } |
---|
2107 | } |
---|
2108 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
2109 | } |
---|
2110 | /** destroy quantization matrix array |
---|
2111 | */ |
---|
2112 | Void TComScalingList::destroy() |
---|
2113 | { |
---|
2114 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2115 | { |
---|
2116 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2117 | { |
---|
2118 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
2119 | } |
---|
2120 | } |
---|
2121 | } |
---|
2122 | /** get default address of quantization matrix |
---|
2123 | * \param sizeId size index |
---|
2124 | * \param listId list index |
---|
2125 | * \returns pointer of quantization matrix |
---|
2126 | */ |
---|
2127 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
2128 | { |
---|
2129 | Int *src = 0; |
---|
2130 | switch(sizeId) |
---|
2131 | { |
---|
2132 | case SCALING_LIST_4x4: |
---|
2133 | src = (listId<3) ? g_quantIntraDefault4x4 : g_quantInterDefault4x4; |
---|
2134 | break; |
---|
2135 | case SCALING_LIST_8x8: |
---|
2136 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2137 | break; |
---|
2138 | #if SCALING_LIST |
---|
2139 | case SCALING_LIST_16x16: |
---|
2140 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2141 | break; |
---|
2142 | case SCALING_LIST_32x32: |
---|
2143 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2144 | break; |
---|
2145 | #else |
---|
2146 | case SCALING_LIST_16x16: |
---|
2147 | src = (listId<3) ? g_quantIntraDefault16x16 : g_quantInterDefault16x16; |
---|
2148 | break; |
---|
2149 | case SCALING_LIST_32x32: |
---|
2150 | src = (listId<1) ? g_quantIntraDefault32x32 : g_quantInterDefault32x32; |
---|
2151 | break; |
---|
2152 | #endif |
---|
2153 | default: |
---|
2154 | assert(0); |
---|
2155 | src = NULL; |
---|
2156 | break; |
---|
2157 | } |
---|
2158 | return src; |
---|
2159 | } |
---|
2160 | /** process of default matrix |
---|
2161 | * \param sizeId size index |
---|
2162 | * \param Index of input matrix |
---|
2163 | */ |
---|
2164 | Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId) |
---|
2165 | { |
---|
2166 | #if SCALING_LIST |
---|
2167 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2168 | setUseDefaultScalingMatrixFlag(sizeId,listId,true); |
---|
2169 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
2170 | #else |
---|
2171 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*(Int)g_scalingListSize[sizeId]); |
---|
2172 | #endif |
---|
2173 | } |
---|
2174 | #if SCALING_LIST |
---|
2175 | /** check DC value of matrix for default matrix signaling |
---|
2176 | */ |
---|
2177 | Void TComScalingList::checkDcOfMatrix() |
---|
2178 | { |
---|
2179 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2180 | { |
---|
2181 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2182 | { |
---|
2183 | setUseDefaultScalingMatrixFlag(sizeId,listId,false); |
---|
2184 | //check default matrix? |
---|
2185 | if(getScalingListDC(sizeId,listId) == 0) |
---|
2186 | { |
---|
2187 | processDefaultMarix(sizeId, listId); |
---|
2188 | } |
---|
2189 | } |
---|
2190 | } |
---|
2191 | } |
---|
2192 | #endif |
---|
2193 | |
---|
2194 | ParameterSetManager::ParameterSetManager() |
---|
2195 | : m_spsMap(MAX_NUM_SPS) |
---|
2196 | , m_ppsMap(MAX_NUM_PPS) |
---|
2197 | , m_apsMap(MAX_NUM_APS) |
---|
2198 | #if VIDYO_VPS_INTEGRATION |
---|
2199 | , m_vpsMap(MAX_NUM_VPS) |
---|
2200 | #endif |
---|
2201 | { |
---|
2202 | } |
---|
2203 | |
---|
2204 | |
---|
2205 | ParameterSetManager::~ParameterSetManager() |
---|
2206 | { |
---|
2207 | } |
---|
2208 | |
---|
2209 | //! \} |
---|