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