source: 3DVCSoftware/branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPicYuv.h @ 12

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

Poznan Tools

  • Depth base motion vector prediction
  • 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-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     TComPicYuv.h
37    \brief    picture YUV buffer class (header)
38*/
39
40#ifndef __TCOMPICYUV__
41#define __TCOMPICYUV__
42
43#include <stdio.h>
44#include "CommonDef.h"
45
46#if POZNAN_NONLINEAR_DEPTH
47
48#include <math.h>
49
50class TComPowerConverter // OLGIERD - Z-NL-Power conversion
51{
52private:
53  Double m_fMul;
54  Float m_fPower;
55
56public:
57
58  TComPowerConverter(Float fPower, Int iInputBitIncrement, Int iOutputBitIncrement)
59  :m_fPower(fPower)
60  {
61    Double fPostMul = (1<<(8+iOutputBitIncrement))-1; // OLGIERD ToDo - should be or not?
62    Double fPreMul  = 1.0/((1<<(8+iInputBitIncrement))-1);
63    m_fMul = fPostMul*pow(fPreMul,(Double)fPower);
64  };
65
66  inline Double operator() (Double Value)
67  {   
68    if (Value<0) return -pow( -Value,(Double)m_fPower)*m_fMul;
69    return pow(Value,(Double)m_fPower)*m_fMul;
70  };
71};
72#else
73class TComPowerConverter // OLGIERD - Z-NL-Power conversion
74{
75public:
76
77  TComPowerConverter(Float fPower, Int iInputBitIncrement, Int iOutputBitIncrement)
78  {
79  };
80
81  inline Double operator() (Double Value) { return Value; };
82};
83#endif
84// ====================================================================================================================
85// Class definition
86// ====================================================================================================================
87
88/// picture YUV buffer class
89class TComPicYuv
90{
91private:
92 
93  // ------------------------------------------------------------------------------------------------
94  //  YUV buffer
95  // ------------------------------------------------------------------------------------------------
96 
97  Pel*  m_apiPicBufY;           ///< Buffer (including margin)
98  Pel*  m_apiPicBufU;
99  Pel*  m_apiPicBufV;
100 
101  Pel*  m_piPicOrgY;            ///< m_apiPicBufY + m_iMarginLuma*getStride() + m_iMarginLuma
102  Pel*  m_piPicOrgU;
103  Pel*  m_piPicOrgV;
104 
105  // ------------------------------------------------------------------------------------------------
106  //  Parameter for general YUV buffer usage
107  // ------------------------------------------------------------------------------------------------
108 
109  Int   m_iPicWidth;            ///< Width of picture
110  Int   m_iPicHeight;           ///< Height of picture
111 
112  Int   m_iCuWidth;             ///< Width of Coding Unit (CU)
113  Int   m_iCuHeight;            ///< Height of Coding Unit (CU)
114  UInt  m_uiMaxCuDepth;         ///< maximum coding unit depth
115  Int   m_iBaseUnitWidth;       ///< Width of Base Unit (with maximum depth or minimum size, m_iCuWidth >> Max. Depth)
116  Int   m_iBaseUnitHeight;      ///< Height of Base Unit (with maximum depth or minimum size, m_iCuHeight >> Max. Depth)
117  Int   m_iNumCuInWidth;
118 
119  Int   m_iLumaMarginX;
120  Int   m_iLumaMarginY;
121  Int   m_iChromaMarginX;
122  Int   m_iChromaMarginY;
123 
124  Bool  m_bIsBorderExtended;
125 
126protected:
127  Void  xExtendPicCompBorder (Pel* piTxt, Int iStride, Int iWidth, Int iHeight, Int iMarginX, Int iMarginY);
128  Void  xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal );
129 
130public:
131  TComPicYuv         ();
132  virtual ~TComPicYuv();
133 
134  // ------------------------------------------------------------------------------------------------
135  //  Memory management
136  // ------------------------------------------------------------------------------------------------
137 
138  Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth );
139  Void  destroy     ();
140 
141  Void  createLuma  ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uhMaxCUDepth );
142  Void  destroyLuma ();
143 
144  // ------------------------------------------------------------------------------------------------
145  //  Get information of picture
146  // ------------------------------------------------------------------------------------------------
147 
148  Int   getWidth    ()     { return  m_iPicWidth;    }
149  Int   getHeight   ()     { return  m_iPicHeight;   }
150
151  UInt  getMaxCuWidth ()   { return  (UInt)m_iCuWidth;   }
152  UInt  getMaxCuHeight()   { return  (UInt)m_iCuHeight;  }
153  UInt  getMaxCuDepth ()   { return  m_uiMaxCuDepth;     }
154 
155  Int   getStride   ()     { return (m_iPicWidth     ) + (m_iLumaMarginX  <<1); }
156  Int   getCStride  ()     { return (m_iPicWidth >> 1) + (m_iChromaMarginX<<1); }
157 
158  Int   getLumaMargin   () { return m_iLumaMarginX;  }
159  Int   getChromaMargin () { return m_iChromaMarginX;}
160 
161  Void  getLumaMinMax( Int* pMin, Int* pMax );
162 
163  // ------------------------------------------------------------------------------------------------
164  //  Access function for picture buffer
165  // ------------------------------------------------------------------------------------------------
166 
167  //  Access starting position of picture buffer with margin
168  Pel*  getBufY     ()     { return  m_apiPicBufY;   }
169  Pel*  getBufU     ()     { return  m_apiPicBufU;   }
170  Pel*  getBufV     ()     { return  m_apiPicBufV;   }
171 
172  //  Access starting position of original picture
173  Pel*  getLumaAddr ()     { return  m_piPicOrgY;    }
174  Pel*  getCbAddr   ()     { return  m_piPicOrgU;    }
175  Pel*  getCrAddr   ()     { return  m_piPicOrgV;    }
176 
177  //  Access starting position of original picture for specific coding unit (CU) or partition unit (PU)
178  Pel*  getLumaAddr ( Int iCuAddr );
179  Pel*  getCbAddr   ( Int iCuAddr );
180  Pel*  getCrAddr   ( Int iCuAddr );
181  Pel*  getLumaAddr ( Int iCuAddr, Int uiAbsZorderIdx );
182  Pel*  getCbAddr   ( Int iCuAddr, Int uiAbsZorderIdx );
183  Pel*  getCrAddr   ( Int iCuAddr, Int uiAbsZorderIdx );
184 
185  // ------------------------------------------------------------------------------------------------
186  //  Miscellaneous
187  // ------------------------------------------------------------------------------------------------
188
189  // sample to block and block to sample conversion
190  Void  getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY );
191  Void  getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
192 
193  //  Copy function to picture
194  Void  copyToPic       ( TComPicYuv*  pcPicYuvDst );
195  Void  copyToPicLuma   ( TComPicYuv*  pcPicYuvDst );
196  Void  copyToPicCb     ( TComPicYuv*  pcPicYuvDst );
197  Void  copyToPicCr     ( TComPicYuv*  pcPicYuvDst );
198 
199  //  Extend function of picture buffer
200  Void  extendPicBorder      ();
201 
202  //  Dump picture
203  Void  dump (char* pFileName, Bool bAdd = false);
204 
205  // Set border extension flag
206  Void  setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
207#if FIXED_ROUNDING_FRAME_MEMORY
208  Void  xFixedRoundingPic();
209#endif 
210
211  // Set Function
212  Void  setLumaTo    ( Pel pVal ); 
213  Void  setChromaTo  ( Pel pVal ); 
214
215#if POZNAN_NONLINEAR_DEPTH
216  Void power(TComPicYuv *pcPicDst, Float p);
217#endif
218};// END CLASS DEFINITION TComPicYuv
219
220void calcMD5(TComPicYuv& pic, unsigned char digest[16]);
221
222#endif // __TCOMPICYUV__
223
Note: See TracBrowser for help on using the repository browser.