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