source: 3DVCSoftware/branches/0.2-poznan-univ/source/Lib/TLibCommon/TComYuv.h @ 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: 10.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 
116#if POZNAN_EIVD
117  Void    copyPartToPartYuv_EIVD        ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY ); 
118  Void    copyPartToPartLuma_EIVD   ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY );
119  Void    copyPartToPartChroma_EIVD ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY );
120#endif
121
122  // ------------------------------------------------------------------------------------------------------------------
123  //  Algebraic operation for YUV buffer
124  // ------------------------------------------------------------------------------------------------------------------
125 
126  //  Clip(pcYuvSrc0 + pcYuvSrc1) -> m_apiBuf
127  Void    addClip           ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
128  Void    addClipLuma       ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
129  Void    addClipChroma     ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
130  Void    addClipPartLuma   ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ); //GT
131
132 
133  //  pcYuvSrc0 - pcYuvSrc1 -> m_apiBuf
134  Void    subtract          ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
135  Void    subtractLuma      ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
136  Void    subtractChroma    ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
137 
138  //  (pcYuvSrc0 + pcYuvSrc1)/2 for YUV partition
139#ifdef ROUNDING_CONTROL_BIPRED
140  Void    addAvg            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, Bool bRound );
141#endif
142  Void    addAvg            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight );
143
144#if POZNAN_EIVD
145#ifdef ROUNDING_CONTROL_BIPRED
146  Void    addAvg_EIVD            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY, Bool bRound );
147#endif
148  Void    addAvg_EIVD            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY );
149#endif
150
151  //   Remove High frequency
152  Void    removeHighFreq    ( TComYuv* pcYuvSrc, UInt uiWidht, UInt uiHeight );
153  Void    removeHighFreq    ( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight );
154
155  Void    add               ( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract = false );
156  Void    addLuma           ( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract );
157  Void    addChroma         ( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract );
158
159  Void    clip              ( Int iWidth, Int iHeight );
160  Void    clipLuma          ( Int iWidth, Int iHeight );
161  Void    clipChroma        ( Int iWidth, Int iHeight );
162 
163  // ------------------------------------------------------------------------------------------------------------------
164  //  Access function for YUV buffer
165  // ------------------------------------------------------------------------------------------------------------------
166 
167  //  Access starting position of YUV buffer
168  Pel*    getLumaAddr ()    { return m_apiBufY; }
169  Pel*    getCbAddr   ()    { return m_apiBufU; }
170  Pel*    getCrAddr   ()    { return m_apiBufV; }
171 
172  //  Access starting position of YUV partition unit buffer
173  Pel*    getLumaAddr       ( UInt iPartUnitIdx );
174  Pel*    getCbAddr         ( UInt iPartUnitIdx );
175  Pel*    getCrAddr         ( UInt iPartUnitIdx );
176 
177  //  Access starting position of YUV transform unit buffer
178  Pel*    getLumaAddr       ( UInt iTransUnitIdx, UInt iBlkSize );
179  Pel*    getCbAddr         ( UInt iTransUnitIdx, UInt iBlkSize );
180  Pel*    getCrAddr         ( UInt iTransUnitIdx, UInt iBlkSize );
181 
182  //  Get stride value of YUV buffer
183  UInt    getStride   ()    { return  m_iWidth;   }
184  UInt    getCStride  ()    { return  m_iCWidth;  }
185  UInt    getHeight   ()    { return  m_iHeight;  }
186 
187  UInt    getWidth    ()    { return  m_iWidth;   }
188  UInt    getCHeight  ()    { return  m_iCHeight; }
189  UInt    getCWidth   ()    { return  m_iCWidth;  }
190 
191  Void    printout();
192 
193  // ------------------------------------------------------------------------------------------------------------------
194  //  Miscellaneous
195  // ------------------------------------------------------------------------------------------------------------------
196 
197  __inline Pel  xClip  (Pel x )      { return ( (x < 0) ? 0 : (x > (Pel)g_uiIBDI_MAX) ? (Pel)g_uiIBDI_MAX : x ); }
198 
199};// END CLASS DEFINITION TComYuv
200
201#endif // __TCOMYUV__
202
Note: See TracBrowser for help on using the repository browser.