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

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

Poznan Tools

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