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