source: 3DVCSoftware/branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.h @ 28

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

Poznan Tools

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