source: 3DVCSoftware/branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.cpp @ 65

Last change on this file since 65 was 48, checked in by poznan-univ, 13 years ago

some bug fix on high level syntax
fixed some compiler warning issues under windows and linux

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