source: 3DVCSoftware/trunk/source/Lib/TLibRenderer/TRenImage.cpp @ 1313

Last change on this file since 1313 was 1313, checked in by tech, 9 years ago

Merged 14.1-update-dev1@1312.

  • Property svn:eol-style set to native
File size: 8.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-2015, 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 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#include "TRenImage.h"
36#include "TRenImagePlane.h"
37#include "TRenFilter.h"
38#include "assert.h"
39#if NH_3D
40
41
42template<typename T>
43TRenImage<T>::TRenImage( TRenImage& rcIn )
44{ 
45  allocatePlanes( rcIn.getPlane(0)->getWidth(), rcIn.getPlane(0)->getHeight(), rcIn.getNumberOfFullPlanes(), rcIn.getNumberOfQuaterPlanes() ) ; assign(&rcIn);
46}
47
48template<typename T>
49TRenImage<T>::TRenImage( UInt uiWidth, UInt uiHeight, UInt uiNumberOfFullPlanes, UInt uiNumberOfQuaterPlanes )
50{ 
51  allocatePlanes( uiWidth, uiHeight, uiNumberOfFullPlanes, uiNumberOfQuaterPlanes );
52}
53
54template<typename T>
55TRenImage<T>::TRenImage() : m_uiNumberOfFullPlanes(0), m_uiNumberOfQuaterPlanes(0), m_uiNumberOfPlanes(0), m_apcPlanes(0)
56{
57 
58}
59
60
61template<>
62TRenImage<Pel>::TRenImage( TComPicYuv* pcPicYuv, Bool bFirstPlaneOnly )
63{ 
64  if (bFirstPlaneOnly) //400
65  {
66    m_uiNumberOfPlanes       = 1;
67    m_uiNumberOfFullPlanes   = 1;
68    m_uiNumberOfQuaterPlanes = 0;
69    m_apcPlanes    = new TRenImagePlane<Pel>*[ m_uiNumberOfPlanes ];
70    m_apcPlanes[0] = new TRenImagePlane<Pel>( pcPicYuv->getBuf( COMPONENT_Y ), pcPicYuv->getWidth( COMPONENT_Y  ) + (REN_LUMA_MARGIN << 1),   pcPicYuv->getHeight( COMPONENT_Y  ) + (REN_LUMA_MARGIN << 1), pcPicYuv->getStride( COMPONENT_Y ), REN_LUMA_MARGIN );
71  }
72  else //420
73  {
74    m_uiNumberOfPlanes       = 3;
75    m_uiNumberOfFullPlanes   = 1;
76    m_uiNumberOfQuaterPlanes = 2;
77
78    m_apcPlanes    = new TRenImagePlane<Pel>*[ m_uiNumberOfPlanes ];
79    m_apcPlanes[0] = new TRenImagePlane<Pel>( pcPicYuv->getBuf( COMPONENT_Y  ), pcPicYuv->getWidth( COMPONENT_Y  ) + (REN_LUMA_MARGIN << 1),  pcPicYuv->getHeight( COMPONENT_Y  ) + (REN_LUMA_MARGIN << 1), pcPicYuv->getStride( COMPONENT_Y ), REN_LUMA_MARGIN );
80    m_apcPlanes[1] = new TRenImagePlane<Pel>( pcPicYuv->getBuf( COMPONENT_Cb ), pcPicYuv->getWidth( COMPONENT_Cb ) +  REN_LUMA_MARGIN      ,  pcPicYuv->getHeight( COMPONENT_Cb ) +  REN_LUMA_MARGIN      , pcPicYuv->getStride( COMPONENT_Cb), REN_LUMA_MARGIN >> 1 );
81    m_apcPlanes[2] = new TRenImagePlane<Pel>( pcPicYuv->getBuf( COMPONENT_Cr ), pcPicYuv->getWidth( COMPONENT_Cr ) +  REN_LUMA_MARGIN      ,  pcPicYuv->getHeight( COMPONENT_Cr ) +  REN_LUMA_MARGIN      , pcPicYuv->getStride( COMPONENT_Cr), REN_LUMA_MARGIN >> 1 );
82  }
83}
84
85template<typename T>
86TRenImage<T>* TRenImage<T>::create()
87{
88  return new TRenImage( m_apcPlanes[0]->getWidth(), m_apcPlanes[0]->getHeight(), m_uiNumberOfFullPlanes, m_uiNumberOfQuaterPlanes );
89}
90
91
92template<typename T>
93TRenImage<T>::TRenImage( TComPicYuv* pcPicYuv, Bool bFirstPlaneOnly )
94{
95  assert(0);
96}
97
98template<class T>
99TRenImagePlane<T>* TRenImage<T>::getPlane(UInt uiPlaneNumber) const
100{
101  return m_apcPlanes[uiPlaneNumber];
102}
103
104template<class T>
105TRenImagePlane<T>** TRenImage<T>::getPlanes() const
106{
107  return m_apcPlanes;
108}
109
110template<typename T>
111Void TRenImage<T>::getDataAndStrides( T** pptData, Int* piStrides ) const
112{
113  for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++ )
114  {
115    piStrides[uiCurPlane] = m_apcPlanes[uiCurPlane]->getStride   ();
116    pptData  [uiCurPlane] = m_apcPlanes[uiCurPlane]->getPlaneData();
117  }
118}
119
120
121template<typename T>
122Void TRenImage<T>::getWidthAndHeight( Int* ppiWidths, Int* ppiHeights ) const
123{
124  for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++ )
125  {
126    ppiWidths [uiCurPlane] = m_apcPlanes[uiCurPlane]->getWidth ();
127    ppiHeights[uiCurPlane] = m_apcPlanes[uiCurPlane]->getHeight();
128  }
129}
130
131template<typename T>
132Void TRenImage<T>::allocatePlanes( UInt uiWidth, UInt uiHeight, UInt uiNumberOfFullPlanes, UInt uiNumberOfQuaterPlanes )
133{
134  assert( uiNumberOfFullPlanes + uiNumberOfQuaterPlanes);
135
136  UInt uiHalfWidth  = uiWidth  / 2;
137  UInt uiHalfHeight = uiHeight / 2;
138
139  uiHalfWidth  = (uiHalfWidth  == 0) ? 1 : uiHalfWidth ;
140  uiHalfHeight = (uiHalfHeight == 0) ? 1 : uiHalfHeight;
141
142  m_uiNumberOfPlanes       = uiNumberOfFullPlanes + uiNumberOfQuaterPlanes; ;
143  m_uiNumberOfFullPlanes   = uiNumberOfFullPlanes;
144  m_uiNumberOfQuaterPlanes = uiNumberOfQuaterPlanes;
145
146  this->m_apcPlanes    = new TRenImagePlane<T>*[m_uiNumberOfPlanes];
147
148  for (UInt uiCurPlane = 0; uiCurPlane < uiNumberOfFullPlanes; uiCurPlane++)
149  {
150    this->m_apcPlanes[uiCurPlane] = new TRenImagePlane<T>(uiWidth, uiHeight, REN_LUMA_MARGIN);
151  };
152
153  for (UInt uiCurPlane = 0; uiCurPlane < uiNumberOfQuaterPlanes; uiCurPlane++)
154  {
155    this->m_apcPlanes[uiCurPlane+uiNumberOfFullPlanes] = new TRenImagePlane<T>(uiHalfWidth, uiHalfHeight, REN_LUMA_MARGIN >> 1);
156  };
157}
158
159
160template<class T>
161Void TRenImage<T>::assign(Int iVal)
162{
163  for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++)
164  {
165    m_apcPlanes[uiCurPlane]->assign( iVal);
166  }
167}
168
169
170template<class T>
171Void TRenImage<T>::devide( Double dDevisor )
172{
173  for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++)
174  {
175    m_apcPlanes[uiCurPlane]->devide(dDevisor);
176  }
177}
178
179
180template<class T> template<class S>
181Void TRenImage<T>::assign( TRenImage<S>* pcSrcImage )
182{
183  if (pcSrcImage->getNumberOfPlanes() != m_uiNumberOfPlanes )
184  {
185    assert(0);
186  }
187
188  for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++)
189  {
190    m_apcPlanes[uiCurPlane]->assign(pcSrcImage->getPlane(uiCurPlane)->getPlaneDataOrg(),pcSrcImage->getPlane(uiCurPlane)->getStride());
191  }
192}
193
194
195template<typename T>
196Void TRenImage<T>::setData( TRenImage* pcInputImage, Bool bClean )
197{
198  for (UInt uiPlane = 0; uiPlane < m_uiNumberOfPlanes; uiPlane++)
199  {
200    m_apcPlanes[uiPlane]->setData( pcInputImage->getPlane( uiPlane ), bClean );
201  }
202}
203
204template<typename T>
205Void TRenImage<T>::extendMargin()
206{
207  for (UInt uiPlane = 0; uiPlane < m_uiNumberOfPlanes; uiPlane++)
208  {
209    m_apcPlanes[uiPlane]->extendMargin();
210  }
211}
212
213template<class T>
214Void TRenImage<T>::xDeletePlanes()
215{
216  for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++)
217  {
218    if ( m_apcPlanes[uiCurPlane])
219    {
220      delete m_apcPlanes[uiCurPlane];
221    }
222    m_apcPlanes[uiCurPlane] = 0;
223  }
224}
225
226
227template<class T>
228Void TRenImage<T>::init()
229{
230  // YUV-init
231  m_apcPlanes[0]->assign((Pel) 0 );
232
233  for (UInt uiCurPlane = 1; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++)
234  {
235    m_apcPlanes[uiCurPlane]->assign( (Pel) ( 1 << ( REN_BIT_DEPTH - 1 ) ) );
236  }
237}
238
239
240template<class T>
241TRenImage<T>::~TRenImage()
242{
243  xDeletePlanes();
244  delete[] m_apcPlanes;
245}
246
247
248
249template<class T>
250UInt TRenImage<T>::getNumberOfPlanes() const
251{
252  return m_uiNumberOfPlanes;
253}
254
255template<class T>
256UInt TRenImage<T>::getNumberOfQuaterPlanes() const
257{
258  return m_uiNumberOfQuaterPlanes;
259}
260
261template<class T>
262UInt TRenImage<T>::getNumberOfFullPlanes() const
263{
264  return m_uiNumberOfFullPlanes;
265}
266
267template class TRenImage<Pel>;
268template class TRenImage<Int>;
269template class TRenImage<Double>;
270template class TRenImage<Bool>;
271
272
273template Void TRenImage<Pel>::assign<Pel>    (TRenImage<Pel>*   );
274
275#endif // NH_3D
Note: See TracBrowser for help on using the repository browser.