source: SHVCSoftware/branches/SHM-dev/source/Lib/TLibCommon/TComPic.cpp

Last change on this file was 1602, checked in by seregin, 7 years ago

keep original depth for ILRP for the motion compensation

  • Property svn:eol-style set to native
File size: 24.2 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-2016, 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     TComPic.cpp
35    \brief    picture class
36*/
37
38#include "TComPic.h"
39#include "SEI.h"
40
41//! \ingroup TLibCommon
42//! \{
43
44// ====================================================================================================================
45// Constructor / destructor / create / destroy
46// ====================================================================================================================
47
48TComPic::TComPic()
49: m_uiTLayer                              (0)
50, m_bUsedByCurr                           (false)
51, m_bIsLongTerm                           (false)
52, m_pcPicYuvPred                          (NULL)
53, m_pcPicYuvResi                          (NULL)
54, m_bReconstructed                        (false)
55, m_bNeededForOutput                      (false)
56, m_uiCurrSliceIdx                        (0)
57, m_bCheckLTMSB                           (false)
58#if SVC_EXTENSION
59, m_layerId( 0 )
60#endif
61{
62#if SVC_EXTENSION
63  memset( m_pcFullPelBaseRec, 0, sizeof( m_pcFullPelBaseRec ) );
64  memset( m_requireResampling, false, sizeof( m_requireResampling ) );
65  memset( m_equalPictureSizeAndOffsetFlag, false, sizeof( m_equalPictureSizeAndOffsetFlag ) );
66  memset( m_mvScalingFactor, 0, sizeof( m_mvScalingFactor ) );
67  memset( m_posScalingFactor, 0, sizeof( m_posScalingFactor ) );
68#endif
69  for(UInt i=0; i<NUM_PIC_YUV; i++)
70  {
71    m_apcPicYuv[i]      = NULL;
72  }
73}
74
75TComPic::~TComPic()
76{
77  destroy();
78}
79#if SVC_EXTENSION
80#if REDUCED_ENCODER_MEMORY
81Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bCreateEncoderSourcePicYuv, const Bool bCreateForImmediateReconstruction, const UInt layerId, const Bool isILRP )
82#else
83Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual, const UInt layerId, const Bool isILRP )
84#endif
85{
86  destroy();
87
88  const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();
89  const Int          iWidth = sps.getPicWidthInLumaSamples();
90  const Int          iHeight = sps.getPicHeightInLumaSamples();
91  const UInt         uiMaxCuWidth = sps.getMaxCUWidth();
92  const UInt         uiMaxCuHeight = sps.getMaxCUHeight();
93  const UInt         uiMaxDepth = sps.getMaxTotalCUDepth();
94  const Window& conformanceWindow = sps.getConformanceWindow();
95
96  // original uiMaxDepth must be used for motion compensation for inter-layer prediction, since EL partition address is used to derive reference PU location.
97  m_maxILRPdepth = uiMaxDepth;
98
99  if( isILRP )
100  {
101    UInt maxDepth = 0;
102    if( isILRP )
103    {
104      while( ( uiMaxCuWidth >> maxDepth ) > 16 )
105      {
106        maxDepth++;
107      }
108    }
109
110    m_maxILRPdepth = ( ( uiMaxCuWidth >> sps.getMaxTotalCUDepth() ) > 16 && isILRP ) ? maxDepth : sps.getMaxTotalCUDepth();
111
112    UInt* piTmp = &m_auiZscanToRaster[0];
113    initZscanToRaster( m_maxILRPdepth + 1, 1, 0, piTmp );
114    initRasterToZscan( uiMaxCuWidth, uiMaxCuHeight, m_maxILRPdepth + 1, m_auiZscanToRaster, m_auiRasterToZscan );
115    initRasterToPelXY( uiMaxCuWidth, uiMaxCuHeight, m_maxILRPdepth + 1, m_auiRasterToPelX, m_auiRasterToPelY );
116  }
117
118  m_layerId = layerId;
119
120#if REDUCED_ENCODER_MEMORY
121  m_picSym.create( sps, pps, m_maxILRPdepth, bCreateForImmediateReconstruction, layerId );
122  if (bCreateEncoderSourcePicYuv)
123#else
124  m_picSym.create( sps, pps, m_maxILRPdepth, layerId );
125
126  if (!bIsVirtual)
127#endif
128  {
129    m_apcPicYuv[PIC_YUV_ORG     ]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_ORG     ]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true, &conformanceWindow );
130    m_apcPicYuv[PIC_YUV_TRUE_ORG]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true, &conformanceWindow );
131  }
132#if REDUCED_ENCODER_MEMORY
133  if (bCreateForImmediateReconstruction)
134  {
135#endif
136  m_apcPicYuv[PIC_YUV_REC]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true, &conformanceWindow );
137
138  for( Int i = 0; i < MAX_LAYERS; i++ )
139  {
140    if( m_requireResampling[i] )
141    {
142      m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true, &conformanceWindow );
143    }
144  }
145#if REDUCED_ENCODER_MEMORY
146  }
147#endif
148
149  // there are no SEI messages associated with this picture initially
150  if (m_SEIs.size() > 0)
151  {
152    deleteSEIs (m_SEIs);
153  }
154  m_bUsedByCurr = false;
155}
156#else
157#if REDUCED_ENCODER_MEMORY
158Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bCreateEncoderSourcePicYuv, const Bool bCreateForImmediateReconstruction )
159#else
160Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual)
161#endif
162{
163  destroy();
164
165  const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();
166  const Int          iWidth          = sps.getPicWidthInLumaSamples();
167  const Int          iHeight         = sps.getPicHeightInLumaSamples();
168  const UInt         uiMaxCuWidth    = sps.getMaxCUWidth();
169  const UInt         uiMaxCuHeight   = sps.getMaxCUHeight();
170  const UInt         uiMaxDepth      = sps.getMaxTotalCUDepth();
171
172#if REDUCED_ENCODER_MEMORY
173  m_picSym.create( sps, pps, uiMaxDepth, bCreateForImmediateReconstruction );
174  if (bCreateEncoderSourcePicYuv)
175#else
176  m_picSym.create( sps, pps, uiMaxDepth );
177  if (!bIsVirtual)
178#endif
179  {
180    m_apcPicYuv[PIC_YUV_ORG    ]   = new TComPicYuv;  m_apcPicYuv[PIC_YUV_ORG     ]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
181    m_apcPicYuv[PIC_YUV_TRUE_ORG]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
182  }
183#if REDUCED_ENCODER_MEMORY
184  if (bCreateForImmediateReconstruction)
185  {
186#endif
187    m_apcPicYuv[PIC_YUV_REC]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
188#if REDUCED_ENCODER_MEMORY
189  }
190#endif
191
192  // there are no SEI messages associated with this picture initially
193  if (m_SEIs.size() > 0)
194  {
195    deleteSEIs (m_SEIs);
196  }
197  m_bUsedByCurr = false;
198}
199#endif
200
201#if REDUCED_ENCODER_MEMORY
202Void TComPic::prepareForEncoderSourcePicYuv()
203{
204  const TComSPS &sps=m_picSym.getSPS();
205
206  const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();
207  const Int          iWidth          = sps.getPicWidthInLumaSamples();
208  const Int          iHeight         = sps.getPicHeightInLumaSamples();
209  const UInt         uiMaxCuWidth    = sps.getMaxCUWidth();
210  const UInt         uiMaxCuHeight   = sps.getMaxCUHeight();
211  const UInt         uiMaxDepth      = sps.getMaxTotalCUDepth();
212
213#if SVC_EXTENSION
214  const Window& conformanceWindow    = sps.getConformanceWindow();
215
216  if (m_apcPicYuv[PIC_YUV_ORG    ]==NULL)
217  {
218    m_apcPicYuv[PIC_YUV_ORG    ]   = new TComPicYuv;  m_apcPicYuv[PIC_YUV_ORG     ]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true, &conformanceWindow );
219  }
220  if (m_apcPicYuv[PIC_YUV_TRUE_ORG    ]==NULL)
221  {
222    m_apcPicYuv[PIC_YUV_TRUE_ORG]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true, &conformanceWindow );
223  }
224#else
225  if (m_apcPicYuv[PIC_YUV_ORG    ]==NULL)
226  {
227    m_apcPicYuv[PIC_YUV_ORG    ]   = new TComPicYuv;  m_apcPicYuv[PIC_YUV_ORG     ]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
228  }
229  if (m_apcPicYuv[PIC_YUV_TRUE_ORG    ]==NULL)
230  {
231    m_apcPicYuv[PIC_YUV_TRUE_ORG]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
232  }
233#endif
234}
235
236Void TComPic::prepareForReconstruction()
237{
238  if (m_apcPicYuv[PIC_YUV_REC] == NULL)
239  {
240    const TComSPS &sps=m_picSym.getSPS();
241    const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();
242    const Int          iWidth          = sps.getPicWidthInLumaSamples();
243    const Int          iHeight         = sps.getPicHeightInLumaSamples();
244    const UInt         uiMaxCuWidth    = sps.getMaxCUWidth();
245    const UInt         uiMaxCuHeight   = sps.getMaxCUHeight();
246    const UInt         uiMaxDepth      = sps.getMaxTotalCUDepth();
247
248#if SVC_EXTENSION
249    const Window& conformanceWindow    = sps.getConformanceWindow();
250
251    m_apcPicYuv[PIC_YUV_REC]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true, &conformanceWindow );
252
253    for( Int i = 0; i < MAX_LAYERS; i++ )
254    {
255      if( m_requireResampling[i] )
256      {
257        m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true, &conformanceWindow );
258      }
259    } 
260#else
261    m_apcPicYuv[PIC_YUV_REC]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
262#endif
263  }
264
265  // mark it should be extended
266  m_apcPicYuv[PIC_YUV_REC]->setBorderExtension(false);
267
268  m_picSym.prepareForReconstruction();
269}
270
271Void TComPic::releaseReconstructionIntermediateData()
272{
273  m_picSym.releaseReconstructionIntermediateData();
274}
275
276Void TComPic::releaseEncoderSourceImageData()
277{
278  if (m_apcPicYuv[PIC_YUV_ORG    ])
279  {
280    m_apcPicYuv[PIC_YUV_ORG]->destroy();
281    delete m_apcPicYuv[PIC_YUV_ORG];
282    m_apcPicYuv[PIC_YUV_ORG] = NULL;
283  }
284  if (m_apcPicYuv[PIC_YUV_TRUE_ORG    ])
285  {
286    m_apcPicYuv[PIC_YUV_TRUE_ORG]->destroy();
287    delete m_apcPicYuv[PIC_YUV_TRUE_ORG];
288    m_apcPicYuv[PIC_YUV_TRUE_ORG] = NULL;
289  }
290}
291
292Void TComPic::releaseAllReconstructionData()
293{
294  if (m_apcPicYuv[PIC_YUV_REC    ])
295  {
296    m_apcPicYuv[PIC_YUV_REC]->destroy();
297    delete m_apcPicYuv[PIC_YUV_REC];
298    m_apcPicYuv[PIC_YUV_REC] = NULL;
299  }
300  m_picSym.releaseAllReconstructionData();
301}
302#endif
303
304Void TComPic::destroy()
305{
306  m_picSym.destroy();
307
308  for(UInt i=0; i<NUM_PIC_YUV; i++)
309  {
310    if (m_apcPicYuv[i])
311    {
312      m_apcPicYuv[i]->destroy();
313      delete m_apcPicYuv[i];
314      m_apcPicYuv[i]  = NULL;
315    }
316  }
317
318  deleteSEIs(m_SEIs);
319#if SVC_EXTENSION
320  for( Int i = 0; i < MAX_LAYERS; i++ )
321  {
322    if( m_requireResampling[i] && m_pcFullPelBaseRec[i] )
323    {
324      m_pcFullPelBaseRec[i]->destroy();
325      delete m_pcFullPelBaseRec[i];
326      m_pcFullPelBaseRec[i]  = NULL;
327    }
328  }
329
330  for( Int comp = 0; comp < 2; comp++ )
331  {
332    if( m_mvScalingFactor[comp] )
333    {
334      delete [] m_mvScalingFactor[comp];
335      m_mvScalingFactor[comp] = NULL;
336    }
337
338    if( m_posScalingFactor[comp] )
339    {
340      delete [] m_posScalingFactor[comp];
341      m_posScalingFactor[comp] = NULL;
342    }
343  }
344#endif
345}
346
347Void TComPic::compressMotion()
348{
349  TComPicSym* pPicSym = getPicSym();
350  for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getNumberOfCtusInFrame(); uiCUAddr++ )
351  {
352    TComDataCU* pCtu = pPicSym->getCtu(uiCUAddr);
353    pCtu->compressMV();
354  }
355}
356
357Bool  TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr)
358{
359  Bool mergeCtbInSliceSeg = (mergeAddr >= getPicSym()->getCtuTsToRsAddrMap(getCtu(currAddr)->getSlice()->getSliceCurStartCtuTsAddr()));
360  Bool mergeCtbInTile     = (getPicSym()->getTileIdxMap(mergeAddr) == getPicSym()->getTileIdxMap(currAddr));
361  return (mergeCtbInSliceSeg && mergeCtbInTile);
362}
363
364UInt TComPic::getSubstreamForCtuAddr(const UInt ctuAddr, const Bool bAddressInRaster, TComSlice *pcSlice)
365{
366  UInt subStrm;
367  const bool bWPPEnabled=pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag();
368  const TComPicSym &picSym            = *(getPicSym());
369
370  if ((bWPPEnabled && picSym.getFrameHeightInCtus()>1) || (picSym.getNumTiles()>1)) // wavefronts, and possibly tiles being used.
371  {
372    if (bWPPEnabled)
373    {
374      const UInt ctuRsAddr                = bAddressInRaster?ctuAddr : picSym.getCtuTsToRsAddrMap(ctuAddr);
375      const UInt frameWidthInCtus         = picSym.getFrameWidthInCtus();
376      const UInt tileIndex                = picSym.getTileIdxMap(ctuRsAddr);
377      const UInt numTileColumns           = (picSym.getNumTileColumnsMinus1()+1);
378      const TComTile *pTile               = picSym.getTComTile(tileIndex);
379      const UInt firstCtuRsAddrOfTile     = pTile->getFirstCtuRsAddr();
380      const UInt tileYInCtus              = firstCtuRsAddrOfTile / frameWidthInCtus;
381      // independent tiles => substreams are "per tile"
382      const UInt ctuLine                  = ctuRsAddr / frameWidthInCtus;
383      const UInt startingSubstreamForTile =(tileYInCtus*numTileColumns) + (pTile->getTileHeightInCtus()*(tileIndex%numTileColumns));
384      subStrm = startingSubstreamForTile + (ctuLine - tileYInCtus);
385    }
386    else
387    {
388      const UInt ctuRsAddr                = bAddressInRaster?ctuAddr : picSym.getCtuTsToRsAddrMap(ctuAddr);
389      const UInt tileIndex                = picSym.getTileIdxMap(ctuRsAddr);
390      subStrm=tileIndex;
391    }
392  }
393  else
394  {
395    // dependent tiles => substreams are "per frame".
396    subStrm = 0;
397  }
398  return subStrm;
399}
400
401#if SVC_EXTENSION
402Void TComPic::createMvScalingFactor(UInt numOfILRPs)
403{
404  // picture object might be reused and hence m_mvScalingFactor[0] can be already allocated
405  if(m_mvScalingFactor[0])
406  {
407    delete m_mvScalingFactor[0];
408  }
409  m_mvScalingFactor[0] = new Int[numOfILRPs];
410
411  // picture object might be reused and hence m_mvScalingFactor[1] can be already allocated
412  if(m_mvScalingFactor[1])
413  {
414    delete m_mvScalingFactor[1];
415  }
416  m_mvScalingFactor[1] = new Int[numOfILRPs];
417}
418
419Void TComPic::createPosScalingFactor(UInt numOfILRPs)
420{
421  // picture object might be reused and hence m_posScalingFactor[0] can be already allocated
422  if(m_posScalingFactor[0])
423  {
424    delete m_posScalingFactor[0];
425  }
426  m_posScalingFactor[0] = new Int[numOfILRPs];
427
428  // picture object might be reused and hence m_posScalingFactor[1] can be already allocated
429  if(m_posScalingFactor[1])
430  {
431    delete m_posScalingFactor[1];
432  }
433  m_posScalingFactor[1] = new Int[numOfILRPs];
434}
435
436Void copyOnetoOnePicture(    // SVC_NONCOLL
437                  Pel *in,       
438                  Pel *out,     
439                  Int nCols,
440                  Int nRows, 
441                  Int fullRowWidth)
442{
443  Int rX;
444
445  for (rX = 0; rX < nRows; rX++)       
446  {
447    memcpy( out, in, sizeof(Pel) * nCols );
448    in = in + fullRowWidth;
449    out = out + fullRowWidth;
450  }
451}
452
453Void TComPic::copyUpsampledPictureYuv(TComPicYuv*   pcPicYuvIn, TComPicYuv*   pcPicYuvOut)
454{
455#if SCALABLE_REXT
456  Int upsampledRowWidthLuma = pcPicYuvOut->getStride(COMPONENT_Y); // 2 * pcPicYuvOut->getLumaMargin() + pcPicYuvOut->getWidth();
457  copyOnetoOnePicture(
458    pcPicYuvIn->getAddr(COMPONENT_Y),       
459    pcPicYuvOut->getAddr(COMPONENT_Y),     
460    pcPicYuvOut->getWidth(COMPONENT_Y), 
461    pcPicYuvOut->getHeight(COMPONENT_Y),
462    upsampledRowWidthLuma);
463
464  if(pcPicYuvOut->getChromaFormat() != CHROMA_400)
465  {
466    Int upsampledRowWidthChroma = pcPicYuvOut->getStride(COMPONENT_Cb); //2 * pcPicYuvOut->getChromaMargin() + (pcPicYuvOut->getWidth()>>1);
467
468    copyOnetoOnePicture(
469      pcPicYuvIn->getAddr(COMPONENT_Cr),       
470      pcPicYuvOut->getAddr(COMPONENT_Cr),     
471      pcPicYuvOut->getWidth(COMPONENT_Cr), 
472      pcPicYuvOut->getHeight(COMPONENT_Cr),
473      upsampledRowWidthChroma);
474    copyOnetoOnePicture(
475      pcPicYuvIn->getAddr(COMPONENT_Cb),       
476      pcPicYuvOut->getAddr(COMPONENT_Cb),     
477      pcPicYuvOut->getWidth(COMPONENT_Cb), 
478      pcPicYuvOut->getHeight(COMPONENT_Cb),
479      upsampledRowWidthChroma);
480  }
481#else
482  Int upsampledRowWidthLuma = pcPicYuvOut->getStride(COMPONENT_Y); // 2 * pcPicYuvOut->getLumaMargin() + pcPicYuvOut->getWidth();
483  Int upsampledRowWidthCroma = pcPicYuvOut->getStride(COMPONENT_Cb); //2 * pcPicYuvOut->getChromaMargin() + (pcPicYuvOut->getWidth()>>1);
484
485  copyOnetoOnePicture(
486    pcPicYuvIn->getAddr(COMPONENT_Y),       
487    pcPicYuvOut->getAddr(COMPONENT_Y),     
488    pcPicYuvOut->getWidth(COMPONENT_Y), 
489    pcPicYuvOut->getHeight(COMPONENT_Y),
490    upsampledRowWidthLuma);
491  copyOnetoOnePicture(
492    pcPicYuvIn->getAddr(COMPONENT_Cr),       
493    pcPicYuvOut->getAddr(COMPONENT_Cr),     
494    pcPicYuvOut->getWidth(COMPONENT_Y)>>1, 
495    pcPicYuvOut->getHeight(COMPONENT_Y)>>1,
496    upsampledRowWidthCroma);
497  copyOnetoOnePicture(
498    pcPicYuvIn->getAddr(COMPONENT_Cb),       
499    pcPicYuvOut->getAddr(COMPONENT_Cb),     
500    pcPicYuvOut->getWidth(COMPONENT_Y)>>1, 
501    pcPicYuvOut->getHeight(COMPONENT_Y)>>1,
502    upsampledRowWidthCroma);
503#endif
504}
505
506Void TComPic::copyUpsampledMvField(UInt refLayerIdc, Int** mvScalingFactor, Int** posScalingFactor)
507{
508  const TComSPS *sps       = getSlice(0)->getSPS();
509  const UInt uiMaxDepth    = m_maxILRPdepth;
510  const UInt numPartitions = 1<<(uiMaxDepth<<1);
511  const UInt widthMinPU    = sps->getMaxCUWidth()  / (1<<uiMaxDepth);
512  const UInt heightMinPU   = sps->getMaxCUHeight() / (1<<uiMaxDepth);
513  const Int  unitNum       = max( 1, (Int)((16/widthMinPU)*(16/heightMinPU)) ); 
514
515  for( UInt ctuRsAddr = 0; ctuRsAddr < m_picSym.getNumberOfCtusInFrame(); ctuRsAddr++ )  //each CTU
516  {
517    TComDataCU* pcCUDes = getCtu(ctuRsAddr);
518
519#if REDUCED_ENCODER_MEMORY
520    TComPicSym::DPBPerCtuData &dpbForCtu = m_picSym.getDPBPerCtuData(ctuRsAddr);
521#endif
522
523    for(UInt absPartIdx = 0; absPartIdx < numPartitions; absPartIdx+=unitNum )  //each 16x16 unit
524    {
525      //pixel position of each unit in up-sampled layer
526      UInt pelX = pcCUDes->getCUPelX() + m_auiRasterToPelX[ m_auiZscanToRaster[absPartIdx] ];
527      UInt pelY = pcCUDes->getCUPelY() + m_auiRasterToPelY[ m_auiZscanToRaster[absPartIdx] ];
528      UInt baseCUAddr, baseAbsPartIdx;
529
530      TComDataCU *pcColCU = 0;
531      pcColCU = pcCUDes->getBaseColCU(refLayerIdc, pelX, pelY, baseCUAddr, baseAbsPartIdx, posScalingFactor, true);
532
533      if( pcColCU && pcColCU->getPredictionMode(baseAbsPartIdx) == MODE_INTER )  //base layer unit not skip and invalid mode
534      {
535        for(UInt refPicList = 0; refPicList < 2; refPicList++)  //for each reference list
536        {
537          TComMvField sMvFieldBase, sMvField;
538          pcColCU->getMvField( pcColCU, baseAbsPartIdx, (RefPicList)refPicList, sMvFieldBase);
539          pcCUDes->scaleBaseMV( refLayerIdc, sMvField, sMvFieldBase, mvScalingFactor );
540
541          pcCUDes->getCUMvField((RefPicList)refPicList)->setMvField(sMvField, absPartIdx);
542          pcCUDes->setPredictionMode(absPartIdx, MODE_INTER);
543        }
544      }
545      else
546      {
547        TComMvField zeroMvField;  //zero MV and invalid reference index
548        pcCUDes->getCUMvField(REF_PIC_LIST_0)->setMvField(zeroMvField, absPartIdx);
549        pcCUDes->getCUMvField(REF_PIC_LIST_1)->setMvField(zeroMvField, absPartIdx);
550        pcCUDes->setPredictionMode(absPartIdx, MODE_INTRA);
551      }
552
553#if REDUCED_ENCODER_MEMORY
554      dpbForCtu.m_CUMvField[REF_PIC_LIST_0].setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_0)->getMv(absPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_0)->getRefIdx(absPartIdx), absPartIdx);
555      dpbForCtu.m_CUMvField[REF_PIC_LIST_1].setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_1)->getMv(absPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_1)->getRefIdx(absPartIdx), absPartIdx);
556#endif
557
558      for(UInt i = 1; i < unitNum; i++ ) 
559      {
560        pcCUDes->getCUMvField(REF_PIC_LIST_0)->setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_0)->getMv(absPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_0)->getRefIdx(absPartIdx), absPartIdx + i);
561        pcCUDes->getCUMvField(REF_PIC_LIST_1)->setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_1)->getMv(absPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_1)->getRefIdx(absPartIdx), absPartIdx + i);
562
563#if REDUCED_ENCODER_MEMORY
564        dpbForCtu.m_CUMvField[REF_PIC_LIST_0].setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_0)->getMv(absPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_0)->getRefIdx(absPartIdx), absPartIdx + i);
565        dpbForCtu.m_CUMvField[REF_PIC_LIST_1].setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_1)->getMv(absPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_1)->getRefIdx(absPartIdx), absPartIdx + i);
566#endif
567        pcCUDes->setPredictionMode(absPartIdx+i, pcCUDes->getPredictionMode(absPartIdx));
568      }
569    }
570    memset( pcCUDes->getPartitionSize(), SIZE_2Nx2N, sizeof(*pcCUDes->getPartitionSize())*numPartitions );
571
572#if REDUCED_ENCODER_MEMORY
573    memcpy( dpbForCtu.m_pePredMode, pcCUDes->getPredictionMode(), sizeof(*pcCUDes->getPredictionMode()) * numPartitions );
574    memcpy( dpbForCtu.m_pePartSize, pcCUDes->getPartitionSize(), sizeof(*pcCUDes->getPartitionSize()) * numPartitions );
575    dpbForCtu.m_pSlice = pcCUDes->getSlice();
576#endif
577  }
578}
579
580Void TComPic::initUpsampledMvField()
581{
582  const UInt uiMaxDepth      = m_maxILRPdepth;
583  const UInt numPartitions = 1<<(uiMaxDepth<<1);
584
585  for( UInt ctuRsAddr = 0; ctuRsAddr < m_picSym.getNumberOfCtusInFrame(); ctuRsAddr++ )  //each CTU
586  {
587    TComDataCU* pcCUDes = getCtu(ctuRsAddr);
588    TComMvField zeroMvField;
589
590#if REDUCED_ENCODER_MEMORY
591    TComPicSym::DPBPerCtuData &dpbForCtu = m_picSym.getDPBPerCtuData(ctuRsAddr);
592#endif
593
594    for( UInt i = 0; i < numPartitions; i++ ) 
595    {
596      pcCUDes->getCUMvField(REF_PIC_LIST_0)->setMvField(zeroMvField, i);
597      pcCUDes->getCUMvField(REF_PIC_LIST_1)->setMvField(zeroMvField, i);
598      pcCUDes->setPredictionMode(i, MODE_INTRA);
599      pcCUDes->setPartitionSize(i, SIZE_2Nx2N);
600
601#if REDUCED_ENCODER_MEMORY
602      dpbForCtu.m_CUMvField[REF_PIC_LIST_0].setMvField(zeroMvField, i);
603      dpbForCtu.m_CUMvField[REF_PIC_LIST_1].setMvField(zeroMvField, i);
604#endif
605    }
606
607#if REDUCED_ENCODER_MEMORY
608    memcpy( dpbForCtu.m_pePredMode, pcCUDes->getPredictionMode(), sizeof(*pcCUDes->getPredictionMode()) * numPartitions );
609    memcpy( dpbForCtu.m_pePartSize, pcCUDes->getPartitionSize(), sizeof(*pcCUDes->getPartitionSize()) * numPartitions );
610    dpbForCtu.m_pSlice = pcCUDes->getSlice();
611#endif
612  }
613}
614
615Bool TComPic::checkSameRefInfo()
616{
617  Bool bSameRefInfo = true;
618  TComSlice * pSlice0 = getSlice( 0 );
619  for( UInt uSliceID = getNumAllocatedSlice() - 1 ; bSameRefInfo && uSliceID > 0 ; uSliceID-- )
620  {
621    TComSlice * pSliceN = getSlice( uSliceID );
622    if( pSlice0->getSliceType() != pSliceN->getSliceType() )
623    {
624      bSameRefInfo = false;
625    }
626    else if( pSlice0->getSliceType() != I_SLICE )
627    {
628      Int nListNum = pSlice0->getSliceType() == B_SLICE ? 2 : 1;
629      for( Int nList = 0 ; nList < nListNum ; nList++ )
630      {
631        RefPicList eRefList = ( RefPicList )nList;
632        if( pSlice0->getNumRefIdx( eRefList ) == pSliceN->getNumRefIdx( eRefList ) )
633        {
634          for( Int refIdx = pSlice0->getNumRefIdx( eRefList ) - 1 ; refIdx >= 0 ; refIdx-- )
635          {
636            if( pSlice0->getRefPic( eRefList , refIdx ) != pSliceN->getRefPic( eRefList , refIdx ) )
637            {
638              bSameRefInfo = false;
639              break;
640            }
641          }
642        }
643        else
644        {
645          bSameRefInfo = false;
646          break;
647        }
648      }
649    }
650  }
651
652  return( bSameRefInfo ); 
653}
654#endif //SVC_EXTENSION
655
656//! \}
Note: See TracBrowser for help on using the repository browser.