source: 3DVCSoftware/trunk/source/Lib/TLibCommon/TComYuv.h @ 17

Last change on this file since 17 was 5, checked in by hhi, 13 years ago

Clean version with cfg-files

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