source: 3DVCSoftware/branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPic.cpp @ 68

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

Missing new line at the end of file

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