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-2011, 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 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 | |
---|
35 | |
---|
36 | /** \file TComSlice.cpp |
---|
37 | \brief slice header and SPS class |
---|
38 | */ |
---|
39 | |
---|
40 | #include "CommonDef.h" |
---|
41 | #include "TComSlice.h" |
---|
42 | #include "TComPic.h" |
---|
43 | |
---|
44 | TComSlice::TComSlice() |
---|
45 | { |
---|
46 | m_uiPPSId = 0; |
---|
47 | m_iPOC = 0; |
---|
48 | m_eSliceType = I_SLICE; |
---|
49 | m_iSliceQp = 0; |
---|
50 | m_iSymbolMode = 1; |
---|
51 | m_aiNumRefIdx[0] = 0; |
---|
52 | m_aiNumRefIdx[1] = 0; |
---|
53 | m_bLoopFilterDisable = false; |
---|
54 | |
---|
55 | m_iSliceQpDelta = 0; |
---|
56 | |
---|
57 | m_iDepth = 0; |
---|
58 | |
---|
59 | m_pcPic = NULL; |
---|
60 | m_bRefenced = false; |
---|
61 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
62 | m_bRounding = false; |
---|
63 | #endif |
---|
64 | m_uiColDir = 0; |
---|
65 | |
---|
66 | m_iViewIdx = 0 ; |
---|
67 | |
---|
68 | #if SONY_COLPIC_AVAILABILITY |
---|
69 | m_iViewOrderIdx = 0; |
---|
70 | #endif |
---|
71 | |
---|
72 | initEqualRef(); |
---|
73 | m_bNoBackPredFlag = false; |
---|
74 | #if MS_LCEC_LOOKUP_TABLE_EXCEPTION |
---|
75 | m_bRefIdxCombineCoding = false; |
---|
76 | #endif |
---|
77 | #if DCM_COMB_LIST |
---|
78 | m_bRefPicListCombinationFlag = false; |
---|
79 | m_bRefPicListModificationFlagLC = false; |
---|
80 | #endif |
---|
81 | m_uiSliceCurStartCUAddr = 0; |
---|
82 | m_uiEntropySliceCurStartCUAddr = 0; |
---|
83 | |
---|
84 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
85 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
86 | m_pcTexturePic = NULL; |
---|
87 | #ifdef WEIGHT_PRED |
---|
88 | resetWpScaling(m_weightPredTable); |
---|
89 | initWpAcDcParam(); |
---|
90 | #endif |
---|
91 | } |
---|
92 | |
---|
93 | TComSlice::~TComSlice() |
---|
94 | { |
---|
95 | } |
---|
96 | |
---|
97 | |
---|
98 | Void TComSlice::initSlice() |
---|
99 | { |
---|
100 | m_aiNumRefIdx[0] = 0; |
---|
101 | m_aiNumRefIdx[1] = 0; |
---|
102 | |
---|
103 | m_uiColDir = 0; |
---|
104 | |
---|
105 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
106 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
107 | m_pcTexturePic = NULL; |
---|
108 | |
---|
109 | initEqualRef(); |
---|
110 | m_bNoBackPredFlag = false; |
---|
111 | #if MS_LCEC_LOOKUP_TABLE_EXCEPTION |
---|
112 | m_bRefIdxCombineCoding = false; |
---|
113 | #endif |
---|
114 | #if DCM_COMB_LIST |
---|
115 | m_bRefPicListCombinationFlag = false; |
---|
116 | m_bRefPicListModificationFlagLC = false; |
---|
117 | #endif |
---|
118 | } |
---|
119 | |
---|
120 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
121 | { |
---|
122 | TComPic* pcPicExtract; |
---|
123 | TComPic* pcPicInsert; |
---|
124 | |
---|
125 | TComList<TComPic*>::iterator iterPicExtract; |
---|
126 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
127 | TComList<TComPic*>::iterator iterPicInsert; |
---|
128 | |
---|
129 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
130 | { |
---|
131 | iterPicExtract = rcListPic.begin(); |
---|
132 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
133 | pcPicExtract = *(iterPicExtract); |
---|
134 | pcPicExtract->setCurrSliceIdx(0); |
---|
135 | |
---|
136 | iterPicInsert = rcListPic.begin(); |
---|
137 | while (iterPicInsert != iterPicExtract) |
---|
138 | { |
---|
139 | pcPicInsert = *(iterPicInsert); |
---|
140 | pcPicInsert->setCurrSliceIdx(0); |
---|
141 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
142 | { |
---|
143 | break; |
---|
144 | } |
---|
145 | |
---|
146 | iterPicInsert++; |
---|
147 | } |
---|
148 | |
---|
149 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
150 | |
---|
151 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
152 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
153 | rcListPic.erase (iterPicExtract); |
---|
154 | } |
---|
155 | } |
---|
156 | |
---|
157 | Void TComSlice::setRefPOCList () |
---|
158 | { |
---|
159 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
160 | { |
---|
161 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
162 | { |
---|
163 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
164 | } |
---|
165 | } |
---|
166 | |
---|
167 | } |
---|
168 | |
---|
169 | #if DCM_COMB_LIST |
---|
170 | Void TComSlice::generateCombinedList() |
---|
171 | { |
---|
172 | if(m_aiNumRefIdx[REF_PIC_LIST_C] > 0) |
---|
173 | { |
---|
174 | m_aiNumRefIdx[REF_PIC_LIST_C]=0; |
---|
175 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++) |
---|
176 | { |
---|
177 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1; |
---|
178 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1; |
---|
179 | m_eListIdFromIdxOfLC[iNumCount]=0; |
---|
180 | m_iRefIdxFromIdxOfLC[iNumCount]=0; |
---|
181 | m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1; |
---|
182 | m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1; |
---|
183 | } |
---|
184 | |
---|
185 | for (Int iNumRefIdx = 0; iNumRefIdx < MAX_NUM_REF; iNumRefIdx++) |
---|
186 | { |
---|
187 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_0]){ |
---|
188 | Bool bTempRefIdxInL2 = true; |
---|
189 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
190 | { |
---|
191 | if (( m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) && |
---|
192 | ( m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getViewIdx() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getViewIdx() )) |
---|
193 | { |
---|
194 | m_iRefIdxOfL1FromRefIdxOfL0[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
195 | m_iRefIdxOfL0FromRefIdxOfL1[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
196 | bTempRefIdxInL2 = false; |
---|
197 | assert(m_eListIdFromIdxOfLC[iRefIdxLC]==REF_PIC_LIST_1); |
---|
198 | break; |
---|
199 | } |
---|
200 | } |
---|
201 | |
---|
202 | if(bTempRefIdxInL2 == true) |
---|
203 | { |
---|
204 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_0; |
---|
205 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
206 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
207 | } |
---|
208 | } |
---|
209 | |
---|
210 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_1]){ |
---|
211 | Bool bTempRefIdxInL2 = true; |
---|
212 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
213 | { |
---|
214 | if (( m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) && |
---|
215 | ( m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getViewIdx() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getViewIdx() )) |
---|
216 | { |
---|
217 | m_iRefIdxOfL0FromRefIdxOfL1[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
218 | m_iRefIdxOfL1FromRefIdxOfL0[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
219 | bTempRefIdxInL2 = false; |
---|
220 | assert(m_eListIdFromIdxOfLC[iRefIdxLC]==REF_PIC_LIST_0); |
---|
221 | break; |
---|
222 | } |
---|
223 | } |
---|
224 | if(bTempRefIdxInL2 == true) |
---|
225 | { |
---|
226 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_1; |
---|
227 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
228 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
229 | } |
---|
230 | } |
---|
231 | } |
---|
232 | } |
---|
233 | } |
---|
234 | #endif |
---|
235 | |
---|
236 | Void TComSlice::setRefPicListFromGOPSTring( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& rapcSpatRefPics ) |
---|
237 | { |
---|
238 | |
---|
239 | if (m_eSliceType == I_SLICE) |
---|
240 | { |
---|
241 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
242 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
243 | |
---|
244 | return; |
---|
245 | } |
---|
246 | |
---|
247 | sortPicList(rcListPic); |
---|
248 | assert( m_eSliceType != P_SLICE || m_pcPic->getNumRefs( REF_PIC_LIST_1 ) == 0 ); |
---|
249 | for(Int iRefList = 0; iRefList<2; iRefList++ ) |
---|
250 | { |
---|
251 | RefPicList eRefList = (RefPicList) iRefList; |
---|
252 | m_aiNumRefIdx[eRefList] = m_pcPic->getNumRefs( eRefList ); |
---|
253 | for( Int i =0; i<m_pcPic->getNumRefs(eRefList); i++ ) |
---|
254 | { |
---|
255 | const int iRefPoc = m_pcPic->getRefPOC( eRefList, i ); |
---|
256 | const int iRefViewIdx = m_pcPic->getRefViewIdx( eRefList, i ); |
---|
257 | m_aiRefPOCList[eRefList][i] = iRefPoc; |
---|
258 | m_aiRefViewList[eRefList][i] = iRefViewIdx; |
---|
259 | |
---|
260 | TComPic* pcRefPic = NULL; |
---|
261 | if( iRefViewIdx == m_iViewIdx ) |
---|
262 | { |
---|
263 | // temporal prediction from current view |
---|
264 | for( TComList<TComPic*>::iterator it = rcListPic.begin(); it!=rcListPic.end(); it++) |
---|
265 | { |
---|
266 | if((*it)->getPOC() == iRefPoc) |
---|
267 | { |
---|
268 | pcRefPic = *it; |
---|
269 | break; |
---|
270 | } |
---|
271 | } |
---|
272 | assert( pcRefPic ); |
---|
273 | if( pcRefPic == NULL && iRefPoc > m_iPOC ) |
---|
274 | { |
---|
275 | const int iAltRefPoc = m_iPOC-(iRefPoc-m_iPOC) ; |
---|
276 | m_aiRefPOCList[eRefList][i] = iAltRefPoc ; |
---|
277 | for( TComList<TComPic*>::iterator it = rcListPic.begin(); it!=rcListPic.end(); it++) |
---|
278 | { |
---|
279 | if((*it)->getPOC() == iAltRefPoc) |
---|
280 | { |
---|
281 | pcRefPic = *it ; |
---|
282 | break; |
---|
283 | } |
---|
284 | } |
---|
285 | } |
---|
286 | } |
---|
287 | else |
---|
288 | { |
---|
289 | // inter-view prediction |
---|
290 | assert( iRefPoc == m_iPOC ); |
---|
291 | assert( 0 <= iRefViewIdx && iRefViewIdx < rapcSpatRefPics.size() ); |
---|
292 | pcRefPic = rapcSpatRefPics[iRefViewIdx]; |
---|
293 | } |
---|
294 | if( pcRefPic ) |
---|
295 | { |
---|
296 | m_apcRefPicList[eRefList][i] = pcRefPic; |
---|
297 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
298 | } |
---|
299 | else |
---|
300 | { |
---|
301 | printf("\n inconsistence in gop string!") ; // gop string inconsistent |
---|
302 | assert(0) ; |
---|
303 | } |
---|
304 | } |
---|
305 | } |
---|
306 | } |
---|
307 | Void TComSlice::setRefPicListExplicitlyDecoderSided( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& rapcSpatRefPics ) |
---|
308 | { |
---|
309 | sortPicList(rcListPic); |
---|
310 | TComPic* pcRefPic = NULL; |
---|
311 | |
---|
312 | for(Int iRefList = 0; iRefList<2; iRefList++) |
---|
313 | { |
---|
314 | RefPicList eRefList = (RefPicList) iRefList; |
---|
315 | for( Int i=0; i<m_aiNumRefIdx[eRefList]; i++ ) |
---|
316 | { |
---|
317 | const int iRefPoc = m_aiRefPOCList[ eRefList][i ]; |
---|
318 | const int iRefViewIdx = m_aiRefViewList[ eRefList][i ]; |
---|
319 | if( iRefViewIdx == m_iViewIdx ) |
---|
320 | { |
---|
321 | for( TComList<TComPic*>::iterator it = rcListPic.begin(); it!=rcListPic.end(); it++) |
---|
322 | { |
---|
323 | if((*it)->getPOC() == iRefPoc) |
---|
324 | { |
---|
325 | pcRefPic = *it; |
---|
326 | break; |
---|
327 | } |
---|
328 | } |
---|
329 | } |
---|
330 | else |
---|
331 | { |
---|
332 | // inter-view prediction |
---|
333 | assert( iRefPoc == m_iPOC ); |
---|
334 | assert( 0 <= iRefViewIdx && iRefViewIdx < rapcSpatRefPics.size() ); |
---|
335 | pcRefPic = rapcSpatRefPics[iRefViewIdx]; |
---|
336 | } |
---|
337 | if( pcRefPic ) |
---|
338 | { |
---|
339 | m_apcRefPicList[eRefList][i] = pcRefPic; |
---|
340 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
341 | } |
---|
342 | else |
---|
343 | { |
---|
344 | printf("\n inconsistence in gop string!") ; // gop string inconsistent |
---|
345 | assert(0) ; |
---|
346 | } |
---|
347 | } |
---|
348 | } |
---|
349 | } |
---|
350 | |
---|
351 | Void TComSlice::initEqualRef() |
---|
352 | { |
---|
353 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
354 | { |
---|
355 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
356 | { |
---|
357 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
358 | { |
---|
359 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
360 | } |
---|
361 | } |
---|
362 | } |
---|
363 | } |
---|
364 | |
---|
365 | Void TComSlice::initMultiviewSlice( Int** aaiScale, Int** aaiOffset ) |
---|
366 | { |
---|
367 | if( m_pcSPS->hasCamParInSliceHeader() ) |
---|
368 | { |
---|
369 | UInt uiViewId = m_pcSPS->getViewId(); |
---|
370 | for( UInt uiBaseViewId = 0; uiBaseViewId < uiViewId; uiBaseViewId++ ) |
---|
371 | { |
---|
372 | m_aaiCodedScale [ 0 ][ uiBaseViewId ] = aaiScale [ uiBaseViewId ][ uiViewId ]; |
---|
373 | m_aaiCodedScale [ 1 ][ uiBaseViewId ] = aaiScale [ uiViewId ][ uiBaseViewId ]; |
---|
374 | m_aaiCodedOffset[ 0 ][ uiBaseViewId ] = aaiOffset[ uiBaseViewId ][ uiViewId ]; |
---|
375 | m_aaiCodedOffset[ 1 ][ uiBaseViewId ] = aaiOffset[ uiViewId ][ uiBaseViewId ]; |
---|
376 | } |
---|
377 | } |
---|
378 | } |
---|
379 | |
---|
380 | |
---|
381 | #if DCM_DECODING_REFRESH |
---|
382 | /** Function for marking the reference pictures when an IDR and CDR is encountered. |
---|
383 | * \param uiPOCCDR POC of the CDR picture |
---|
384 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
385 | * \param rcListPic reference to the reference picture list |
---|
386 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
387 | * If the nal_unit_type is IDR all pictures in the reference picture list |
---|
388 | * is marked as "unused for reference" |
---|
389 | * Otherwise do for the CDR case (non CDR case has no effect since both if conditions below will not be true) |
---|
390 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
391 | * temporal reference is greater than the temporal reference of the latest CDR picture (uiPOCCDR), |
---|
392 | * mark all reference pictures except the latest CDR picture as "unused for reference" and set |
---|
393 | * the bRefreshPending flag to false. |
---|
394 | * If the nal_unit_type is CDR, set the bRefreshPending flag to true and iPOCCDR to the temporal |
---|
395 | * reference of the current picture. |
---|
396 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
397 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
398 | */ |
---|
399 | Void TComSlice::decodingRefreshMarking(UInt& uiPOCCDR, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
400 | { |
---|
401 | TComPic* rpcPic; |
---|
402 | UInt uiPOCCurr = getPOC(); |
---|
403 | |
---|
404 | if (getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR) // IDR |
---|
405 | { |
---|
406 | // mark all pictures as not used for reference |
---|
407 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
408 | while (iterPic != rcListPic.end()) |
---|
409 | { |
---|
410 | rpcPic = *(iterPic); |
---|
411 | rpcPic->setCurrSliceIdx(0); |
---|
412 | if (rpcPic->getPOC() != uiPOCCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
413 | iterPic++; |
---|
414 | } |
---|
415 | } |
---|
416 | else // CDR or No DR |
---|
417 | { |
---|
418 | if (bRefreshPending==true && uiPOCCurr > uiPOCCDR) // CDR reference marking pending |
---|
419 | { |
---|
420 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
421 | while (iterPic != rcListPic.end()) |
---|
422 | { |
---|
423 | rpcPic = *(iterPic); |
---|
424 | if (rpcPic->getPOC() != uiPOCCurr && rpcPic->getPOC() != uiPOCCDR) rpcPic->getSlice(0)->setReferenced(false); |
---|
425 | iterPic++; |
---|
426 | } |
---|
427 | bRefreshPending = false; |
---|
428 | } |
---|
429 | if (getNalUnitType() == NAL_UNIT_CODED_SLICE_CDR) // CDR picture found |
---|
430 | { |
---|
431 | bRefreshPending = true; |
---|
432 | uiPOCCDR = uiPOCCurr; |
---|
433 | } |
---|
434 | } |
---|
435 | } |
---|
436 | #endif |
---|
437 | |
---|
438 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
439 | { |
---|
440 | assert( pSrc != NULL ); |
---|
441 | |
---|
442 | Int i, j, k; |
---|
443 | |
---|
444 | m_iPOC = pSrc->m_iPOC; |
---|
445 | m_iViewIdx = pSrc->m_iViewIdx; |
---|
446 | #if SONY_COLPIC_AVAILABILITY |
---|
447 | m_iViewOrderIdx = pSrc->m_iViewOrderIdx; |
---|
448 | #endif |
---|
449 | #if DCM_DECODING_REFRESH |
---|
450 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
451 | #endif |
---|
452 | m_eSliceType = pSrc->m_eSliceType; |
---|
453 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
454 | m_iSymbolMode = pSrc->m_iSymbolMode; |
---|
455 | m_bLoopFilterDisable = pSrc->m_bLoopFilterDisable; |
---|
456 | |
---|
457 | #if DCM_COMB_LIST |
---|
458 | for (i = 0; i < 3; i++) |
---|
459 | { |
---|
460 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
461 | } |
---|
462 | |
---|
463 | for (i = 0; i < 2; i++) |
---|
464 | { |
---|
465 | for (j = 0; j < MAX_NUM_REF_LC; j++) |
---|
466 | { |
---|
467 | m_iRefIdxOfLC[i][j] = pSrc->m_iRefIdxOfLC[i][j]; |
---|
468 | } |
---|
469 | } |
---|
470 | for (i = 0; i < MAX_NUM_REF_LC; i++) |
---|
471 | { |
---|
472 | m_eListIdFromIdxOfLC[i] = pSrc->m_eListIdFromIdxOfLC[i]; |
---|
473 | m_iRefIdxFromIdxOfLC[i] = pSrc->m_iRefIdxFromIdxOfLC[i]; |
---|
474 | m_iRefIdxOfL1FromRefIdxOfL0[i] = pSrc->m_iRefIdxOfL1FromRefIdxOfL0[i]; |
---|
475 | m_iRefIdxOfL0FromRefIdxOfL1[i] = pSrc->m_iRefIdxOfL0FromRefIdxOfL1[i]; |
---|
476 | } |
---|
477 | m_bRefPicListModificationFlagLC = pSrc->m_bRefPicListModificationFlagLC; |
---|
478 | m_bRefPicListCombinationFlag = pSrc->m_bRefPicListCombinationFlag; |
---|
479 | #else |
---|
480 | for (i = 0; i < 2; i++) |
---|
481 | { |
---|
482 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
483 | } |
---|
484 | #endif |
---|
485 | |
---|
486 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
487 | for (i = 0; i < 2; i++) |
---|
488 | { |
---|
489 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
490 | { |
---|
491 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
492 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
493 | m_aiRefViewList[i][j] = pSrc->m_aiRefViewList[i][j]; |
---|
494 | } |
---|
495 | } |
---|
496 | m_iDepth = pSrc->m_iDepth; |
---|
497 | |
---|
498 | // referenced slice |
---|
499 | m_bRefenced = pSrc->m_bRefenced; |
---|
500 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
501 | m_bRounding = pSrc->m_bRounding; |
---|
502 | #endif |
---|
503 | |
---|
504 | // access channel |
---|
505 | m_pcSPS = pSrc->m_pcSPS; |
---|
506 | m_pcPPS = pSrc->m_pcPPS; |
---|
507 | m_uiPPSId = pSrc->m_uiPPSId; |
---|
508 | m_pcPic = pSrc->m_pcPic; |
---|
509 | |
---|
510 | m_uiColDir = pSrc->m_uiColDir; |
---|
511 | m_dLambda = pSrc->m_dLambda; |
---|
512 | for (i = 0; i < 2; i++) |
---|
513 | { |
---|
514 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
515 | { |
---|
516 | for (k =0; k < MAX_NUM_REF; k++) |
---|
517 | { |
---|
518 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
519 | } |
---|
520 | } |
---|
521 | } |
---|
522 | |
---|
523 | m_bNoBackPredFlag = pSrc->m_bNoBackPredFlag; |
---|
524 | #if MS_LCEC_LOOKUP_TABLE_EXCEPTION |
---|
525 | m_bRefIdxCombineCoding = pSrc->m_bRefIdxCombineCoding; |
---|
526 | #endif |
---|
527 | m_uiSliceMode = pSrc->m_uiSliceMode; |
---|
528 | m_uiSliceArgument = pSrc->m_uiSliceArgument; |
---|
529 | m_uiSliceCurStartCUAddr = pSrc->m_uiSliceCurStartCUAddr; |
---|
530 | m_uiSliceCurEndCUAddr = pSrc->m_uiSliceCurEndCUAddr; |
---|
531 | m_uiSliceIdx = pSrc->m_uiSliceIdx; |
---|
532 | m_uiEntropySliceMode = pSrc->m_uiEntropySliceMode; |
---|
533 | m_uiEntropySliceArgument = pSrc->m_uiEntropySliceArgument; |
---|
534 | m_uiEntropySliceCurStartCUAddr = pSrc->m_uiEntropySliceCurStartCUAddr; |
---|
535 | m_uiEntropySliceCurEndCUAddr = pSrc->m_uiEntropySliceCurEndCUAddr; |
---|
536 | m_bNextSlice = pSrc->m_bNextSlice; |
---|
537 | m_bNextEntropySlice = pSrc->m_bNextEntropySlice; |
---|
538 | #ifdef WEIGHT_PRED |
---|
539 | for ( int e=0 ; e<2 ; e++ ) |
---|
540 | for ( int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
541 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
542 | #endif |
---|
543 | } |
---|
544 | |
---|
545 | #ifdef WEIGHT_PRED |
---|
546 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
547 | { |
---|
548 | wp = m_weightPredTable[e][iRefIdx]; |
---|
549 | } |
---|
550 | |
---|
551 | Void TComSlice::displayWpScaling() |
---|
552 | { |
---|
553 | Bool bFound = false; |
---|
554 | for ( int e=0 ; e<2 ; e++ ) { |
---|
555 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
556 | for ( int yuv=0 ; yuv<3 ; yuv++ ) |
---|
557 | if ( m_weightPredTable[e][i][yuv].bPresentFlag ) { |
---|
558 | if ( !bFound ) { |
---|
559 | printf("\tluma_log2_weight_denom = %d\n", m_weightPredTable[0][0][0].uiLog2WeightDenom); |
---|
560 | printf("\tchroma_log2_weight_denom = %d\n", m_weightPredTable[0][0][1].uiLog2WeightDenom); |
---|
561 | bFound = true; |
---|
562 | } |
---|
563 | Double weight = (Double)m_weightPredTable[e][i][yuv].iWeight / (Double)(1<<m_weightPredTable[0][0][0].uiLog2WeightDenom); |
---|
564 | if ( yuv == 0 ) { |
---|
565 | printf("\tluma_weight_l%d_flag = 1\n", e); |
---|
566 | printf("\t luma_weight_l%d[%d] = %d => w = %g\n", e, i, m_weightPredTable[e][i][yuv].iWeight, weight); |
---|
567 | printf("\t luma_offset_l%d[%d] = %d\n", e, i, m_weightPredTable[e][i][yuv].iOffset); |
---|
568 | } |
---|
569 | else { |
---|
570 | if ( yuv == 1 ) printf("\tchroma_weight_l%d_flag = 1\n", e); |
---|
571 | printf("\t chroma_weight_l%d[%d][%d] = %d => w = %g\n", e, i, yuv-1, m_weightPredTable[e][i][yuv].iWeight, weight); |
---|
572 | printf("\t chroma_offset_l%d[%d][%d] = %d\n", e, i, yuv-1, m_weightPredTable[e][i][yuv].iOffset); |
---|
573 | } |
---|
574 | } |
---|
575 | } |
---|
576 | } |
---|
577 | |
---|
578 | // Default WP values settings : no weight. |
---|
579 | Void TComSlice::resetWpScaling(wpScalingParam wp[2][MAX_NUM_REF][3]) |
---|
580 | { |
---|
581 | for ( int e=0 ; e<2 ; e++ ) { |
---|
582 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
583 | for ( int yuv=0 ; yuv<3 ; yuv++ ) { |
---|
584 | wpScalingParam *pwp = &(wp[e][i][yuv]); |
---|
585 | pwp->bPresentFlag = false; |
---|
586 | pwp->uiLog2WeightDenom = 0; |
---|
587 | pwp->uiLog2WeightDenom = 0; |
---|
588 | pwp->iWeight = 1; |
---|
589 | pwp->iOffset = 0; |
---|
590 | } |
---|
591 | } |
---|
592 | } |
---|
593 | |
---|
594 | Void TComSlice::initWpScaling() |
---|
595 | { |
---|
596 | initWpScaling(m_weightPredTable); |
---|
597 | } |
---|
598 | |
---|
599 | Void TComSlice::initWpScaling(wpScalingParam wp[2][MAX_NUM_REF][3]) |
---|
600 | { |
---|
601 | for ( int e=0 ; e<2 ; e++ ) { |
---|
602 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
603 | for ( int yuv=0 ; yuv<3 ; yuv++ ) { |
---|
604 | wpScalingParam *pwp = &(wp[e][i][yuv]); |
---|
605 | if ( !pwp->bPresentFlag ) { |
---|
606 | // Inferring values not present : |
---|
607 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
608 | pwp->iOffset = 0; |
---|
609 | } |
---|
610 | |
---|
611 | pwp->w = pwp->iWeight; |
---|
612 | pwp->o = pwp->iOffset * (1 << (g_uiBitDepth-8)); |
---|
613 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
614 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
615 | } |
---|
616 | } |
---|
617 | } |
---|
618 | #endif |
---|
619 | |
---|
620 | #ifdef WEIGHT_PRED |
---|
621 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
622 | { |
---|
623 | wp = m_weightACDCParam; |
---|
624 | } |
---|
625 | |
---|
626 | Void TComSlice::initWpAcDcParam() |
---|
627 | { |
---|
628 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
629 | { |
---|
630 | m_weightACDCParam[iComp].iAC = 0; |
---|
631 | m_weightACDCParam[iComp].iDC = 0; |
---|
632 | } |
---|
633 | } |
---|
634 | #endif |
---|
635 | |
---|
636 | // ------------------------------------------------------------------------------------------------ |
---|
637 | // Sequence parameter set (SPS) |
---|
638 | // ------------------------------------------------------------------------------------------------ |
---|
639 | |
---|
640 | TComSPS::TComSPS() |
---|
641 | { |
---|
642 | // Structure |
---|
643 | m_uiSPSId = 0; |
---|
644 | m_uiWidth = 352; |
---|
645 | m_uiHeight = 288; |
---|
646 | m_uiMaxCUWidth = 32; |
---|
647 | m_uiMaxCUHeight = 32; |
---|
648 | m_uiMaxCUDepth = 3; |
---|
649 | m_uiMinTrDepth = 0; |
---|
650 | m_uiMaxTrDepth = 1; |
---|
651 | m_uiMaxTrSize = 32; |
---|
652 | |
---|
653 | // Tool list |
---|
654 | m_bUseALF = false; |
---|
655 | m_bUseDQP = false; |
---|
656 | |
---|
657 | m_bUseMRG = false; // SOPH: |
---|
658 | #if HHI_MPI |
---|
659 | m_bUseMVI = false; |
---|
660 | #endif |
---|
661 | |
---|
662 | m_uiViewId = 0; |
---|
663 | m_iViewOrderIdx = 0; |
---|
664 | m_bDepth = false; |
---|
665 | m_uiCamParPrecision = 0; |
---|
666 | m_bCamParInSliceHeader = false; |
---|
667 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
668 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
669 | |
---|
670 | #if DEPTH_MAP_GENERATION |
---|
671 | m_uiPredDepthMapGeneration = 0; |
---|
672 | m_uiPdmPrecision = 0; |
---|
673 | ::memset( m_aiPdmScaleNomDelta, 0x00, sizeof( m_aiPdmScaleNomDelta ) ); |
---|
674 | ::memset( m_aiPdmOffset, 0x00, sizeof( m_aiPdmOffset ) ); |
---|
675 | #endif |
---|
676 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
677 | m_uiMultiviewMvPredMode = 0; |
---|
678 | #endif |
---|
679 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
680 | m_uiMultiviewResPredMode = 0; |
---|
681 | #endif |
---|
682 | |
---|
683 | // AMVP parameter |
---|
684 | ::memset( m_aeAMVPMode, 0, sizeof( m_aeAMVPMode ) ); |
---|
685 | |
---|
686 | #if ( HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX ) |
---|
687 | m_bUseDMM = false; |
---|
688 | #endif |
---|
689 | } |
---|
690 | |
---|
691 | TComSPS::~TComSPS() |
---|
692 | { |
---|
693 | } |
---|
694 | |
---|
695 | TComPPS::TComPPS() |
---|
696 | { |
---|
697 | #if CONSTRAINED_INTRA_PRED |
---|
698 | m_bConstrainedIntraPred = false; |
---|
699 | #endif |
---|
700 | m_uiSPSId = 0; |
---|
701 | m_uiPPSId = 0; |
---|
702 | } |
---|
703 | |
---|
704 | TComPPS::~TComPPS() |
---|
705 | { |
---|
706 | } |
---|
707 | |
---|
708 | Void |
---|
709 | TComSPS::initMultiviewSPS( UInt uiViewId, Int iViewOrderIdx, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset ) |
---|
710 | { |
---|
711 | AOT( uiViewId == 0 && iViewOrderIdx != 0 ); |
---|
712 | AOT( uiViewId != 0 && iViewOrderIdx == 0 ); |
---|
713 | AOT( uiViewId != 0 && !bCamParSlice && ( aaiScale == 0 || aaiOffset == 0 ) ); |
---|
714 | |
---|
715 | m_uiViewId = uiViewId; |
---|
716 | m_iViewOrderIdx = iViewOrderIdx; |
---|
717 | m_bDepth = false; |
---|
718 | m_uiCamParPrecision = ( m_uiViewId ? uiCamParPrecision : 0 ); |
---|
719 | m_bCamParInSliceHeader = ( m_uiViewId ? bCamParSlice : false ); |
---|
720 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
721 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
722 | if( !m_bCamParInSliceHeader ) |
---|
723 | { |
---|
724 | for( UInt uiBaseViewId = 0; uiBaseViewId < m_uiViewId; uiBaseViewId++ ) |
---|
725 | { |
---|
726 | m_aaiCodedScale [ 0 ][ uiBaseViewId ] = aaiScale [ uiBaseViewId ][ m_uiViewId ]; |
---|
727 | m_aaiCodedScale [ 1 ][ uiBaseViewId ] = aaiScale [ m_uiViewId ][ uiBaseViewId ]; |
---|
728 | m_aaiCodedOffset[ 0 ][ uiBaseViewId ] = aaiOffset[ uiBaseViewId ][ m_uiViewId ]; |
---|
729 | m_aaiCodedOffset[ 1 ][ uiBaseViewId ] = aaiOffset[ m_uiViewId ][ uiBaseViewId ]; |
---|
730 | } |
---|
731 | } |
---|
732 | } |
---|
733 | |
---|
734 | Void |
---|
735 | TComSPS::initMultiviewSPSDepth( UInt uiViewId, Int iViewOrderIdx ) |
---|
736 | { |
---|
737 | AOT( uiViewId == 0 && iViewOrderIdx != 0 ); |
---|
738 | AOT( uiViewId != 0 && iViewOrderIdx == 0 ); |
---|
739 | |
---|
740 | m_uiViewId = uiViewId; |
---|
741 | m_iViewOrderIdx = iViewOrderIdx; |
---|
742 | m_bDepth = true; |
---|
743 | m_uiCamParPrecision = 0; |
---|
744 | m_bCamParInSliceHeader = false; |
---|
745 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
746 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
747 | } |
---|
748 | |
---|
749 | |
---|
750 | #if DEPTH_MAP_GENERATION |
---|
751 | Void |
---|
752 | TComSPS::setPredDepthMapGeneration( UInt uiViewId, Bool bIsDepth, UInt uiPdmGenMode, UInt uiPdmMvPredMode, UInt uiPdmPrec, Int** aaiPdmScaleNomDelta, Int** aaiPdmOffset ) |
---|
753 | { |
---|
754 | AOF( m_uiViewId == uiViewId ); |
---|
755 | AOF( m_bDepth == bIsDepth ); |
---|
756 | AOT( ( uiViewId == 0 || bIsDepth ) && uiPdmGenMode ); |
---|
757 | AOT( uiPdmGenMode && ( aaiPdmScaleNomDelta == 0 || aaiPdmOffset == 0 ) ); |
---|
758 | AOT( uiPdmMvPredMode && uiPdmGenMode == 0 ); |
---|
759 | |
---|
760 | m_uiPredDepthMapGeneration = uiPdmGenMode; |
---|
761 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
762 | m_uiMultiviewMvPredMode = uiPdmMvPredMode; |
---|
763 | #endif |
---|
764 | m_uiPdmPrecision = ( m_uiPredDepthMapGeneration ? uiPdmPrec : 0 ); |
---|
765 | ::memset( m_aiPdmScaleNomDelta, 0x00, sizeof( m_aiPdmScaleNomDelta ) ); |
---|
766 | ::memset( m_aiPdmOffset, 0x00, sizeof( m_aiPdmOffset ) ); |
---|
767 | if( m_uiPredDepthMapGeneration ) |
---|
768 | { |
---|
769 | for( UInt uiBaseId = 0; uiBaseId < m_uiViewId; uiBaseId++ ) |
---|
770 | { |
---|
771 | m_aiPdmScaleNomDelta[ uiBaseId ] = aaiPdmScaleNomDelta[ m_uiViewId ][ uiBaseId ]; |
---|
772 | m_aiPdmOffset [ uiBaseId ] = aaiPdmOffset [ m_uiViewId ][ uiBaseId ]; |
---|
773 | } |
---|
774 | } |
---|
775 | } |
---|
776 | #endif |
---|