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

Last change on this file since 28 was 28, checked in by poznan-univ, 13 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: 11.1 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     TComYuv.h
37    \brief    general YUV buffer class (header)
38    \todo     this should be merged with TComPicYuv \n
39              check usage of removeHighFreq function
40*/
41
42#ifndef __TCOMYUV__
43#define __TCOMYUV__
44#include <assert.h>
45#include "CommonDef.h"
46#include "TComPicYuv.h"
47
48// ====================================================================================================================
49// Class definition
50// ====================================================================================================================
51
52/// general YUV buffer class
53class TComYuv
54{
55private:
56 
57  // ------------------------------------------------------------------------------------------------------------------
58  //  YUV buffer
59  // ------------------------------------------------------------------------------------------------------------------
60 
61  Pel*    m_apiBufY;
62  Pel*    m_apiBufU;
63  Pel*    m_apiBufV;
64 
65  // ------------------------------------------------------------------------------------------------------------------
66  //  Parameter for general YUV buffer usage
67  // ------------------------------------------------------------------------------------------------------------------
68 
69  UInt     m_iWidth;
70  UInt     m_iHeight;
71  UInt     m_iCWidth;
72  UInt     m_iCHeight;
73 
74public:
75 
76  TComYuv();
77  virtual ~TComYuv();
78 
79  // ------------------------------------------------------------------------------------------------------------------
80  //  Memory management
81  // ------------------------------------------------------------------------------------------------------------------
82 
83  Void    create            ( UInt iWidth, UInt iHeight );  ///< Create  YUV buffer
84  Void    destroy           ();                             ///< Destroy YUV buffer
85  Void    clear             ();                             ///< clear   YUV buffer
86 
87  // ------------------------------------------------------------------------------------------------------------------
88  //  Copy, load, store YUV buffer
89  // ------------------------------------------------------------------------------------------------------------------
90 
91  //  Copy YUV buffer to picture buffer
92  Void    copyToPicYuv         ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
93  Void    copyToPicLuma        ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
94  Void    copyToPicChroma      ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
95 
96  //  Copy YUV buffer from picture buffer
97  Void    copyFromPicYuv       ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx );
98  Void    copyFromPicLuma      ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx );
99  Void    copyFromPicChroma    ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx );
100 
101  //  Copy Small YUV buffer to the part of other Big YUV buffer
102  Void    copyToPartYuv         ( TComYuv*    pcYuvDst,    UInt uiDstPartIdx );
103  Void    copyToPartLuma        ( TComYuv*    pcYuvDst,    UInt uiDstPartIdx );
104  Void    copyToPartChroma      ( TComYuv*    pcYuvDst,    UInt uiDstPartIdx );
105 
106  //  Copy the part of Big YUV buffer to other Small YUV buffer
107  Void    copyPartToYuv         ( TComYuv*    pcYuvDst,    UInt uiSrcPartIdx );
108  Void    copyPartToLuma        ( TComYuv*    pcYuvDst,    UInt uiSrcPartIdx );
109  Void    copyPartToChroma      ( TComYuv*    pcYuvDst,    UInt uiSrcPartIdx );
110 
111  //  Copy YUV partition buffer to other YUV partition buffer
112  Void    copyPartToPartYuv     ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight );
113  Void    copyPartToPartLuma    ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight );
114  Void    copyPartToPartChroma  ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight );
115#if DEPTH_MAP_GENERATION
116  Void    copyPartToPartYuvPdm  ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight, UInt uiSubSampExpX, UInt uiSubSampExpY );
117  Void    copyPartToPartLumaPdm ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight, UInt uiSubSampExpX, UInt uiSubSampExpY );
118#endif
119 
120#if POZNAN_DBMP
121  Void    copyPartToPartYuv_DBMP        ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY ); 
122  Void    copyPartToPartLuma_DBMP   ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY );
123  Void    copyPartToPartChroma_DBMP ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY );
124#if DEPTH_MAP_GENERATION
125  Void    copyPartToPartYuvPdm_DBMP  ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY, UInt uiSubSampExpX, UInt uiSubSampExpY );
126  Void    copyPartToPartLumaPdm_DBMP ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY, UInt uiSubSampExpX, UInt uiSubSampExpY );
127#endif
128#endif
129 
130  // ------------------------------------------------------------------------------------------------------------------
131  //  Algebraic operation for YUV buffer
132  // ------------------------------------------------------------------------------------------------------------------
133 
134  //  Clip(pcYuvSrc0 + pcYuvSrc1) -> m_apiBuf
135  Void    addClip           ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
136  Void    addClipLuma       ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
137  Void    addClipChroma     ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
138  Void    addClipPartLuma   ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ); //GT
139
140 
141  //  pcYuvSrc0 - pcYuvSrc1 -> m_apiBuf
142  Void    subtract          ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
143  Void    subtractLuma      ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
144  Void    subtractChroma    ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
145 
146  //  (pcYuvSrc0 + pcYuvSrc1)/2 for YUV partition
147#ifdef ROUNDING_CONTROL_BIPRED
148  Void    addAvg            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, Bool bRound );
149#endif
150  Void    addAvg            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight );
151#if DEPTH_MAP_GENERATION
152  Void    addAvgPdm         ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY );
153#endif
154
155#if POZNAN_DBMP
156#ifdef ROUNDING_CONTROL_BIPRED
157  Void    addAvg_DBMP            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY, Bool bRound );
158#endif
159  Void    addAvg_DBMP            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY );
160#if DEPTH_MAP_GENERATION
161  Void    addAvgPdm_DBMP         ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY, UInt uiSubSampExpX, UInt uiSubSampExpY );
162#endif
163#endif
164
165  //   Remove High frequency
166  Void    removeHighFreq    ( TComYuv* pcYuvSrc, UInt uiWidht, UInt uiHeight );
167  Void    removeHighFreq    ( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight );
168
169  Void    add               ( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract = false );
170  Void    addLuma           ( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract );
171  Void    addChroma         ( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract );
172
173  Void    clip              ( Int iWidth, Int iHeight );
174  Void    clipLuma          ( Int iWidth, Int iHeight );
175  Void    clipChroma        ( Int iWidth, Int iHeight );
176 
177  // ------------------------------------------------------------------------------------------------------------------
178  //  Access function for YUV buffer
179  // ------------------------------------------------------------------------------------------------------------------
180 
181  //  Access starting position of YUV buffer
182  Pel*    getLumaAddr ()    { return m_apiBufY; }
183  Pel*    getCbAddr   ()    { return m_apiBufU; }
184  Pel*    getCrAddr   ()    { return m_apiBufV; }
185 
186  //  Access starting position of YUV partition unit buffer
187  Pel*    getLumaAddr       ( UInt iPartUnitIdx );
188  Pel*    getCbAddr         ( UInt iPartUnitIdx );
189  Pel*    getCrAddr         ( UInt iPartUnitIdx );
190 
191  //  Access starting position of YUV transform unit buffer
192  Pel*    getLumaAddr       ( UInt iTransUnitIdx, UInt iBlkSize );
193  Pel*    getCbAddr         ( UInt iTransUnitIdx, UInt iBlkSize );
194  Pel*    getCrAddr         ( UInt iTransUnitIdx, UInt iBlkSize );
195 
196  //  Get stride value of YUV buffer
197  UInt    getStride   ()    { return  m_iWidth;   }
198  UInt    getCStride  ()    { return  m_iCWidth;  }
199  UInt    getHeight   ()    { return  m_iHeight;  }
200 
201  UInt    getWidth    ()    { return  m_iWidth;   }
202  UInt    getCHeight  ()    { return  m_iCHeight; }
203  UInt    getCWidth   ()    { return  m_iCWidth;  }
204 
205  Void    printout();
206 
207  // ------------------------------------------------------------------------------------------------------------------
208  //  Miscellaneous
209  // ------------------------------------------------------------------------------------------------------------------
210 
211  __inline Pel  xClip  (Pel x )      { return ( (x < 0) ? 0 : (x > (Pel)g_uiIBDI_MAX) ? (Pel)g_uiIBDI_MAX : x ); }
212 
213};// END CLASS DEFINITION TComYuv
214
215#endif // __TCOMYUV__
216
Note: See TracBrowser for help on using the repository browser.