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

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

Poznan Tools

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