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 TComPicYuv.h |
---|
35 | \brief picture YUV buffer class (header) |
---|
36 | */ |
---|
37 | |
---|
38 | #ifndef __TCOMPICYUV__ |
---|
39 | #define __TCOMPICYUV__ |
---|
40 | |
---|
41 | #include <stdio.h> |
---|
42 | #include "CommonDef.h" |
---|
43 | #include "TComRom.h" |
---|
44 | |
---|
45 | //! \ingroup TLibCommon |
---|
46 | //! \{ |
---|
47 | |
---|
48 | // ==================================================================================================================== |
---|
49 | // Class definition |
---|
50 | // ==================================================================================================================== |
---|
51 | |
---|
52 | /// picture YUV buffer class |
---|
53 | class TComPicYuv |
---|
54 | { |
---|
55 | private: |
---|
56 | |
---|
57 | // ------------------------------------------------------------------------------------------------ |
---|
58 | // YUV buffer |
---|
59 | // ------------------------------------------------------------------------------------------------ |
---|
60 | |
---|
61 | Pel* m_apiPicBufY; ///< Buffer (including margin) |
---|
62 | Pel* m_apiPicBufU; |
---|
63 | Pel* m_apiPicBufV; |
---|
64 | |
---|
65 | Pel* m_piPicOrgY; ///< m_apiPicBufY + m_iMarginLuma*getStride() + m_iMarginLuma |
---|
66 | Pel* m_piPicOrgU; |
---|
67 | Pel* m_piPicOrgV; |
---|
68 | |
---|
69 | // ------------------------------------------------------------------------------------------------ |
---|
70 | // Parameter for general YUV buffer usage |
---|
71 | // ------------------------------------------------------------------------------------------------ |
---|
72 | |
---|
73 | Int m_iPicWidth; ///< Width of picture |
---|
74 | Int m_iPicHeight; ///< Height of picture |
---|
75 | |
---|
76 | Int m_iCuWidth; ///< Width of Coding Unit (CU) |
---|
77 | Int m_iCuHeight; ///< Height of Coding Unit (CU) |
---|
78 | UInt m_uiMaxCuDepth; ///< maximum coding unit depth |
---|
79 | Int m_iBaseUnitWidth; ///< Width of Base Unit (with maximum depth or minimum size, m_iCuWidth >> Max. Depth) |
---|
80 | Int m_iBaseUnitHeight; ///< Height of Base Unit (with maximum depth or minimum size, m_iCuHeight >> Max. Depth) |
---|
81 | Int m_iNumCuInWidth; |
---|
82 | |
---|
83 | Int* m_cuOffsetY; |
---|
84 | Int* m_cuOffsetC; |
---|
85 | Int* m_buOffsetY; |
---|
86 | Int* m_buOffsetC; |
---|
87 | |
---|
88 | Int m_iLumaMarginX; |
---|
89 | Int m_iLumaMarginY; |
---|
90 | Int m_iChromaMarginX; |
---|
91 | Int m_iChromaMarginY; |
---|
92 | |
---|
93 | Bool m_bIsBorderExtended; |
---|
94 | |
---|
95 | protected: |
---|
96 | Void xExtendPicCompBorder (Pel* piTxt, Int iStride, Int iWidth, Int iHeight, Int iMarginX, Int iMarginY); |
---|
97 | Void xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal ); |
---|
98 | |
---|
99 | public: |
---|
100 | TComPicYuv (); |
---|
101 | virtual ~TComPicYuv(); |
---|
102 | |
---|
103 | // ------------------------------------------------------------------------------------------------ |
---|
104 | // Memory management |
---|
105 | // ------------------------------------------------------------------------------------------------ |
---|
106 | |
---|
107 | Void create ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth ); |
---|
108 | Void destroy (); |
---|
109 | |
---|
110 | Void createLuma ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uhMaxCUDepth ); |
---|
111 | Void destroyLuma (); |
---|
112 | |
---|
113 | // ------------------------------------------------------------------------------------------------ |
---|
114 | // Get information of picture |
---|
115 | // ------------------------------------------------------------------------------------------------ |
---|
116 | |
---|
117 | Int getWidth () { return m_iPicWidth; } |
---|
118 | Int getHeight () { return m_iPicHeight; } |
---|
119 | |
---|
120 | UInt getMaxCuWidth () { return (UInt)m_iCuWidth; } |
---|
121 | UInt getMaxCuHeight() { return (UInt)m_iCuHeight; } |
---|
122 | UInt getMaxCuDepth () { return m_uiMaxCuDepth; } |
---|
123 | |
---|
124 | Int getStride () { return (m_iPicWidth ) + (m_iLumaMarginX <<1); } |
---|
125 | Int getCStride () { return (m_iPicWidth >> 1) + (m_iChromaMarginX<<1); } |
---|
126 | |
---|
127 | Int getLumaMargin () { return m_iLumaMarginX; } |
---|
128 | Int getChromaMargin () { return m_iChromaMarginX;} |
---|
129 | |
---|
130 | Void getLumaMinMax( Int* pMin, Int* pMax ); |
---|
131 | |
---|
132 | // ------------------------------------------------------------------------------------------------ |
---|
133 | // Access function for picture buffer |
---|
134 | // ------------------------------------------------------------------------------------------------ |
---|
135 | |
---|
136 | // Access starting position of picture buffer with margin |
---|
137 | Pel* getBufY () { return m_apiPicBufY; } |
---|
138 | Pel* getBufU () { return m_apiPicBufU; } |
---|
139 | Pel* getBufV () { return m_apiPicBufV; } |
---|
140 | |
---|
141 | // Access starting position of original picture |
---|
142 | Pel* getLumaAddr () { return m_piPicOrgY; } |
---|
143 | Pel* getCbAddr () { return m_piPicOrgU; } |
---|
144 | Pel* getCrAddr () { return m_piPicOrgV; } |
---|
145 | |
---|
146 | // Access starting position of original picture for specific coding unit (CU) or partition unit (PU) |
---|
147 | Pel* getLumaAddr ( Int iCuAddr ) { return m_piPicOrgY + m_cuOffsetY[ iCuAddr ]; } |
---|
148 | Pel* getCbAddr ( Int iCuAddr ) { return m_piPicOrgU + m_cuOffsetC[ iCuAddr ]; } |
---|
149 | Pel* getCrAddr ( Int iCuAddr ) { return m_piPicOrgV + m_cuOffsetC[ iCuAddr ]; } |
---|
150 | Pel* getLumaAddr ( Int iCuAddr, Int uiAbsZorderIdx ) { return m_piPicOrgY + m_cuOffsetY[iCuAddr] + m_buOffsetY[g_auiZscanToRaster[uiAbsZorderIdx]]; } |
---|
151 | Pel* getCbAddr ( Int iCuAddr, Int uiAbsZorderIdx ) { return m_piPicOrgU + m_cuOffsetC[iCuAddr] + m_buOffsetC[g_auiZscanToRaster[uiAbsZorderIdx]]; } |
---|
152 | Pel* getCrAddr ( Int iCuAddr, Int uiAbsZorderIdx ) { return m_piPicOrgV + m_cuOffsetC[iCuAddr] + m_buOffsetC[g_auiZscanToRaster[uiAbsZorderIdx]]; } |
---|
153 | |
---|
154 | |
---|
155 | // ------------------------------------------------------------------------------------------------ |
---|
156 | // Miscellaneous |
---|
157 | // ------------------------------------------------------------------------------------------------ |
---|
158 | |
---|
159 | // sample to block and block to sample conversion |
---|
160 | Void getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY ); |
---|
161 | Void getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx ); |
---|
162 | |
---|
163 | |
---|
164 | // Copy function to picture |
---|
165 | Void copyToPic ( TComPicYuv* pcPicYuvDst ); |
---|
166 | Void copyToPicLuma ( TComPicYuv* pcPicYuvDst ); |
---|
167 | Void copyToPicCb ( TComPicYuv* pcPicYuvDst ); |
---|
168 | Void copyToPicCr ( TComPicYuv* pcPicYuvDst ); |
---|
169 | |
---|
170 | // Extend function of picture buffer |
---|
171 | Void extendPicBorder (); |
---|
172 | |
---|
173 | // Dump picture |
---|
174 | Void dump (char* pFileName, Bool bAdd = false); |
---|
175 | |
---|
176 | // Set border extension flag |
---|
177 | Void setBorderExtension(Bool b) { m_bIsBorderExtended = b; } |
---|
178 | #if FIXED_ROUNDING_FRAME_MEMORY |
---|
179 | Void xFixedRoundingPic(); |
---|
180 | #endif |
---|
181 | |
---|
182 | // Set Function |
---|
183 | Void setLumaTo ( Pel pVal ); |
---|
184 | Void setChromaTo ( Pel pVal ); |
---|
185 | #if QC_ARP_D0177 |
---|
186 | Void clearPic(); |
---|
187 | #endif |
---|
188 | };// END CLASS DEFINITION TComPicYuv |
---|
189 | |
---|
190 | void calcMD5(TComPicYuv& pic, unsigned char digest[16]); |
---|
191 | |
---|
192 | //! \} |
---|
193 | |
---|
194 | #endif // __TCOMPICYUV__ |
---|