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