source: 3DVCSoftware/branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPic.cpp @ 11

Last change on this file since 11 was 11, checked in by poznan-univ, 12 years ago

Poznan disocclusion coding - CU Skip

  • Property svn:eol-style set to native
File size: 12.5 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     TComPic.cpp
37    \brief    picture class
38*/
39
40#include "TComPic.h"
41#include "SEI.h"
42
43// ====================================================================================================================
44// Constructor / destructor / create / destroy
45// ====================================================================================================================
46
47TComPic::TComPic()
48{
49  m_apcPicSym         = NULL;
50  m_apcPicYuv[0]      = NULL;
51  m_apcPicYuv[1]      = NULL;
52#if POZNAN_AVAIL_MAP
53  m_apcPicYuvAvail     = NULL;
54#endif
55#if POZNAN_SYNTH_VIEW
56  m_apcPicYuvSynth     = NULL;
57#endif
58#if DEPTH_MAP_GENERATION
59  m_pcPredDepthMap    = NULL;
60#endif
61#if HHI_INTER_VIEW_MOTION_PRED
62  m_pcOrgDepthMap     = NULL;
63#endif
64#if HHI_INTER_VIEW_RESIDUAL_PRED
65  m_pcResidual        = NULL;
66#endif
67  m_pcPicYuvPred      = NULL;
68  m_pcPicYuvResi      = NULL;
69#if HHI_INTERVIEW_SKIP
70  m_pcUsedPelsMap     = NULL;
71#endif
72 
73#if PARALLEL_MERGED_DEBLK
74  m_pcPicYuvDeblkBuf     = NULL;
75#endif
76
77  m_bReconstructed    = false;
78
79  m_aiNumRefIdx[0]    = 0;
80  m_aiNumRefIdx[1]    = 0;
81
82  m_iViewIdx          = 0;
83  m_aaiCodedScale     = 0;
84  m_aaiCodedOffset    = 0;
85}
86
87TComPic::~TComPic()
88{
89}
90
91Void TComPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth )
92{
93  m_apcPicSym     = new TComPicSym;  m_apcPicSym   ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
94  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
95
96  /* there are no SEI messages associated with this picture initially */
97  m_SEIs = NULL;
98
99  return;
100}
101
102Void TComPic::destroy()
103{
104  if (m_apcPicSym)
105  {
106    m_apcPicSym->destroy();
107    delete m_apcPicSym;
108    m_apcPicSym = NULL;
109  }
110 
111  if (m_apcPicYuv[0])
112  {
113    m_apcPicYuv[0]->destroy();
114    delete m_apcPicYuv[0];
115    m_apcPicYuv[0]  = NULL;
116  }
117 
118  if (m_apcPicYuv[1])
119  {
120    m_apcPicYuv[1]->destroy();
121    delete m_apcPicYuv[1];
122    m_apcPicYuv[1]  = NULL;
123  }
124#if POZNAN_AVAIL_MAP
125  if (m_apcPicYuvAvail)
126  {
127    m_apcPicYuvAvail->destroy();
128    delete m_apcPicYuvAvail;
129    m_apcPicYuvAvail  = NULL;
130  }
131#endif
132
133#if POZNAN_SYNTH_VIEW
134  if (m_apcPicYuvSynth)
135  {
136    m_apcPicYuvSynth->destroy();
137    delete m_apcPicYuvSynth;
138    m_apcPicYuvSynth  = NULL;
139  }
140#endif
141 
142#if DEPTH_MAP_GENERATION
143  if( m_pcPredDepthMap )
144  {
145    m_pcPredDepthMap->destroy();
146    delete m_pcPredDepthMap;
147    m_pcPredDepthMap = NULL;
148  }
149#endif
150
151#if HHI_INTER_VIEW_MOTION_PRED
152  if( m_pcOrgDepthMap )
153  {
154    m_pcOrgDepthMap->destroy();
155    delete m_pcOrgDepthMap;
156    m_pcOrgDepthMap = NULL;
157  }
158#endif
159
160#if HHI_INTER_VIEW_RESIDUAL_PRED
161  if( m_pcResidual )
162  {
163    m_pcResidual->destroy();
164    delete m_pcResidual;
165    m_pcResidual = NULL;
166  }
167#endif
168
169#if HHI_INTERVIEW_SKIP
170  if( m_pcUsedPelsMap )
171  {
172    m_pcUsedPelsMap->destroy();
173    delete m_pcUsedPelsMap;
174    m_pcUsedPelsMap = NULL;
175  }
176#endif
177
178#if PARALLEL_MERGED_DEBLK
179  if (m_pcPicYuvDeblkBuf)
180  {
181    m_pcPicYuvDeblkBuf->destroy();
182    delete m_pcPicYuvDeblkBuf;
183    m_pcPicYuvDeblkBuf  = NULL;
184  }
185#endif
186
187  delete m_SEIs;
188}
189
190#if AMVP_BUFFERCOMPRESS
191Void TComPic::compressMotion()
192{
193  TComPicSym* pPicSym = getPicSym(); 
194  for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getFrameHeightInCU()*pPicSym->getFrameWidthInCU(); uiCUAddr++ )
195  {
196    TComDataCU* pcCU = pPicSym->getCU(uiCUAddr);
197    pcCU->compressMV(); 
198  } 
199}
200#endif
201
202
203
204Void
205TComPic::addOriginalBuffer()
206{
207  AOT( m_apcPicYuv[0] );
208  AOF( m_apcPicYuv[1] );
209  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
210  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
211  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
212  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
213  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
214  m_apcPicYuv[0]      = new TComPicYuv;
215  m_apcPicYuv[0]      ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
216}
217
218#if POZNAN_AVAIL_MAP
219Void
220TComPic::addAvailabilityBuffer()
221{
222  AOT( m_apcPicYuvAvail );
223  AOF( m_apcPicYuv[1] );
224  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
225  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
226  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
227  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
228  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
229  m_apcPicYuvAvail      = new TComPicYuv;
230  m_apcPicYuvAvail      ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
231}
232#endif
233
234#if POZNAN_SYNTH_VIEW
235Void
236TComPic::addSynthesisBuffer()
237{
238  AOT( m_apcPicYuvSynth );
239  AOF( m_apcPicYuv[1] );
240  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
241  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
242  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
243  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
244  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
245  m_apcPicYuvSynth      = new TComPicYuv;
246  m_apcPicYuvSynth      ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
247}
248#endif
249
250#if PARALLEL_MERGED_DEBLK
251Void
252TComPic::addDeblockBuffer()
253{
254  AOT( m_pcPicYuvDeblkBuf );
255  AOF( m_apcPicYuv[1]     );
256  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
257  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
258  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
259  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
260  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
261  m_pcPicYuvDeblkBuf  = new TComPicYuv;
262  m_pcPicYuvDeblkBuf  ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
263}
264#endif
265
266#if DEPTH_MAP_GENERATION
267Void
268TComPic::addPrdDepthMapBuffer()
269{
270  AOT( m_pcPredDepthMap );
271  AOF( m_apcPicYuv[1]   );
272  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
273  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
274  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
275  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
276  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
277  m_pcPredDepthMap    = new TComPicYuv;
278  m_pcPredDepthMap    ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
279}
280#endif
281
282#if HHI_INTER_VIEW_MOTION_PRED
283Void
284TComPic::addOrgDepthMapBuffer()
285{
286  AOT( m_pcOrgDepthMap );
287  AOF( m_apcPicYuv[1]  );
288  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
289  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
290  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
291  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
292  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
293  m_pcOrgDepthMap     = new TComPicYuv;
294  m_pcOrgDepthMap     ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
295}
296#endif
297
298#if HHI_INTER_VIEW_RESIDUAL_PRED
299Void
300TComPic::addResidualBuffer()
301{
302  AOT( m_pcResidual   );
303  AOF( m_apcPicYuv[1] );
304  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
305  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
306  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
307  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
308  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
309  m_pcResidual        = new TComPicYuv;
310  m_pcResidual        ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
311}
312#endif
313
314#if HHI_INTERVIEW_SKIP
315Void
316TComPic::addUsedPelsMapBuffer()
317{
318  AOT( m_pcUsedPelsMap );
319  AOF( m_apcPicYuv[1]  );
320  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
321  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
322  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
323  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
324  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
325  m_pcUsedPelsMap     = new TComPicYuv;
326  m_pcUsedPelsMap     ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
327}
328#endif
329
330Void
331TComPic::removeOriginalBuffer()
332{
333  if( m_apcPicYuv[0] )
334  {
335    m_apcPicYuv[0]->destroy();
336    delete m_apcPicYuv[0];
337    m_apcPicYuv[0]  = NULL;
338  }
339}
340
341#if POZNAN_AVAIL_MAP
342Void
343TComPic::removeAvailabilityBuffer()
344{
345  if( m_apcPicYuvAvail )
346  {
347    m_apcPicYuvAvail->destroy();
348    delete m_apcPicYuvAvail;
349    m_apcPicYuvAvail  = NULL;
350  }
351}
352#endif
353
354#if POZNAN_SYNTH_VIEW
355Void
356TComPic::removeSynthesisBuffer()
357{
358  if( m_apcPicYuvSynth )
359  {
360    m_apcPicYuvSynth->destroy();
361    delete m_apcPicYuvSynth;
362    m_apcPicYuvSynth  = NULL;
363  }
364}
365#endif
366
367#if PARALLEL_MERGED_DEBLK
368Void
369TComPic::removeDeblockBuffer()
370{
371  if( m_pcPicYuvDeblkBuf )
372  {
373    m_pcPicYuvDeblkBuf->destroy();
374    delete m_pcPicYuvDeblkBuf;
375    m_pcPicYuvDeblkBuf  = NULL;
376  }
377}
378#endif
379
380#if DEPTH_MAP_GENERATION
381Void
382TComPic::removePrdDepthMapBuffer()
383{
384  if( m_pcPredDepthMap )
385  {
386    m_pcPredDepthMap->destroy();
387    delete m_pcPredDepthMap;
388    m_pcPredDepthMap = NULL;
389  }
390}
391#endif
392
393#if HHI_INTER_VIEW_MOTION_PRED
394Void
395TComPic::removeOrgDepthMapBuffer()
396{
397  if( m_pcOrgDepthMap )
398  {
399    m_pcOrgDepthMap->destroy();
400    delete m_pcOrgDepthMap;
401    m_pcOrgDepthMap = NULL;
402  }
403}
404#endif
405
406#if HHI_INTER_VIEW_RESIDUAL_PRED
407Void
408TComPic::removeResidualBuffer()
409{
410  if( m_pcResidual )
411  {
412    m_pcResidual->destroy();
413    delete m_pcResidual;
414    m_pcResidual = NULL;
415  }
416}
417#endif
418
419#if HHI_INTERVIEW_SKIP
420Void
421TComPic::removeUsedPelsMapBuffer()
422{
423  if( m_pcUsedPelsMap )
424  {
425    m_pcUsedPelsMap->destroy();
426    delete m_pcUsedPelsMap;
427    m_pcUsedPelsMap = NULL;
428  }
429}
430#endif
431
432#if POZNAN_AVAIL_MAP
433Void TComPic::checkSynthesisAvailability( TComDataCU*& rpcCU, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, Bool *&rpbCUSynthesied )
434{ 
435  rpbCUSynthesied[0] = true;
436  rpbCUSynthesied[1] = true;
437  rpbCUSynthesied[2] = true;
438  rpbCUSynthesied[3] = true;
439
440  if (!getPicYuvAvail())
441  {
442    rpbCUSynthesied[0] = false;
443    rpbCUSynthesied[1] = false;
444    rpbCUSynthesied[2] = false;
445    rpbCUSynthesied[3] = false;
446    return;   
447  }
448 
449  Int x, y;
450  Bool bAvailable = true;
451  Pel* pAvail  = getPicYuvAvail()->getLumaAddr ( iCuAddr, uiAbsZorderIdx );
452  Int CUHeight = g_uiMaxCUHeight >> uiPartDepth; //rpcCU->getHeight(uiAbsZorderIdx);
453  Int CUWidth  = g_uiMaxCUWidth  >> uiPartDepth; //rpcCU->getWidth(uiAbsZorderIdx);
454 
455  Int  iStride  = getPicYuvAvail()->getStride();
456  for ( y = ((CUHeight - 1) >> 1); y >= 0; y-- )
457  {
458    for ( x = ((CUWidth - 1) >> 1); x >= 0; x-- )
459    {
460      rpbCUSynthesied[0] &= (pAvail[x] != 0);
461    }
462    for ( x = CUWidth - 1; x >= ((CUWidth) >> 1); x-- )
463    {
464      rpbCUSynthesied[1] &= (pAvail[x] != 0);
465    }
466    pAvail += iStride;
467  }
468  //for ( y = CUHeight - 1; y >= ((CUHeight) >> 1); y-- )
469  for ( y = ((CUHeight - 1) >> 1); y >= 0; y-- ) //Owieczka
470  {
471    for ( x = ((CUWidth - 1) >> 1); x >= 0; x-- )
472    {
473      rpbCUSynthesied[2] &= (pAvail[x] != 0);
474    }
475    for ( x = CUWidth - 1; x >= ((CUWidth) >> 1); x-- )
476    {
477      rpbCUSynthesied[3] &= (pAvail[x] != 0);
478    }
479    pAvail += iStride;
480  }
481
482  //rpbCUSynthesied[0] = !rpbCUSynthesied[0];
483  //rpbCUSynthesied[1] = !rpbCUSynthesied[1];
484  //rpbCUSynthesied[2] = !rpbCUSynthesied[2];
485  //rpbCUSynthesied[3] = !rpbCUSynthesied[3];
486}
487#endif
Note: See TracBrowser for help on using the repository browser.