1 // Copyright (c) 2018-2019 Intel Corporation
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in all
11 // copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 #ifndef __MFXCAMERA_H__
21 #define __MFXCAMERA_H__
22 #include "mfxcommon.h"
23 
24 #if !defined (__GNUC__)
25 #pragma warning(disable: 4201)
26 #endif
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /* Camera Extended Buffer Ids */
33 enum {
34     MFX_EXTBUF_CAM_GAMMA_CORRECTION             = MFX_MAKEFOURCC('C','G','A','M'),
35     MFX_EXTBUF_CAM_WHITE_BALANCE                = MFX_MAKEFOURCC('C','W','B','L'),
36     MFX_EXTBUF_CAM_HOT_PIXEL_REMOVAL            = MFX_MAKEFOURCC('C','H','P','R'),
37     MFX_EXTBUF_CAM_BLACK_LEVEL_CORRECTION       = MFX_MAKEFOURCC('C','B','L','C'),
38     MFX_EXTBUF_CAM_VIGNETTE_CORRECTION          = MFX_MAKEFOURCC('C','V','G','T'),
39     MFX_EXTBUF_CAM_BAYER_DENOISE                = MFX_MAKEFOURCC('C','D','N','S'),
40     MFX_EXTBUF_CAM_COLOR_CORRECTION_3X3         = MFX_MAKEFOURCC('C','C','3','3'),
41     MFX_EXTBUF_CAM_PADDING                      = MFX_MAKEFOURCC('C','P','A','D'),
42     MFX_EXTBUF_CAM_PIPECONTROL                  = MFX_MAKEFOURCC('C','P','P','C'),
43     MFX_EXTBUF_CAM_FORWARD_GAMMA_CORRECTION     = MFX_MAKEFOURCC('C','F','G','C'),
44     MFX_EXTBUF_CAM_LENS_GEOM_DIST_CORRECTION    = MFX_MAKEFOURCC('C','L','G','D'),
45     MFX_EXTBUF_CAM_3DLUT                        = MFX_MAKEFOURCC('C','L','U','T'),
46     MFX_EXTBUF_CAM_TOTAL_COLOR_CONTROL          = MFX_MAKEFOURCC('C','T','C','C'),
47     MFX_EXTBUF_CAM_CSC_YUV_RGB                  = MFX_MAKEFOURCC('C','C','Y','R')
48 };
49 
50 typedef enum {
51     MFX_CAM_GAMMA_VALUE      = 0x0001,
52     MFX_CAM_GAMMA_LUT        = 0x0002,
53 } mfxCamGammaParam;
54 
55 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
56 typedef struct {
57     mfxExtBuffer    Header;
58     mfxU16  Mode;
59     mfxU16  reserved1;
60     mfxF64  GammaValue;
61 
62     mfxU16  reserved2[3];
63     mfxU16  NumPoints;
64     mfxU16  GammaPoint[1024];
65     mfxU16  GammaCorrected[1024];
66     mfxU32  reserved3[4];
67 } mfxExtCamGammaCorrection;
68 MFX_PACK_END()
69 
70 typedef enum {
71     MFX_CAM_WHITE_BALANCE_MANUAL   = 0x0001,
72     MFX_CAM_WHITE_BALANCE_AUTO     = 0x0002
73 } mfxCamWhiteBalanceMode;
74 
75 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
76 typedef struct {
77     mfxExtBuffer    Header;
78     mfxU32          Mode;
79     mfxF64          R;
80     mfxF64          G0;
81     mfxF64          B;
82     mfxF64          G1;
83     mfxU32          reserved[8];
84 } mfxExtCamWhiteBalance;
85 MFX_PACK_END()
86 
87 MFX_PACK_BEGIN_USUAL_STRUCT()
88 typedef struct {
89     mfxExtBuffer Header;
90     mfxU16        R;
91     mfxU16        G;
92     mfxU16        B;
93     mfxU16        C;
94     mfxU16        M;
95     mfxU16        Y;
96     mfxU16        reserved[6];
97 } mfxExtCamTotalColorControl;
98 MFX_PACK_END()
99 
100 MFX_PACK_BEGIN_USUAL_STRUCT()
101 typedef struct {
102     mfxExtBuffer Header;
103 
104     mfxF32       PreOffset[3];
105     mfxF32       Matrix[3][3];
106     mfxF32       PostOffset[3];
107     mfxU16       reserved[30];
108 } mfxExtCamCscYuvRgb;
109 MFX_PACK_END()
110 
111 MFX_PACK_BEGIN_USUAL_STRUCT()
112 typedef struct {
113     mfxExtBuffer    Header;
114     mfxU16          PixelThresholdDifference;
115     mfxU16          PixelCountThreshold;
116 } mfxExtCamHotPixelRemoval;
117 MFX_PACK_END()
118 
119 MFX_PACK_BEGIN_USUAL_STRUCT()
120 typedef struct {
121     mfxExtBuffer    Header;
122     mfxU16          R;
123     mfxU16          G0;
124     mfxU16          B;
125     mfxU16          G1;
126     mfxU32          reserved[4];
127 } mfxExtCamBlackLevelCorrection;
128 MFX_PACK_END()
129 
130 MFX_PACK_BEGIN_USUAL_STRUCT()
131 typedef struct {
132     mfxU8 integer;
133     mfxU8 mantissa;
134 } mfxCamVignetteCorrectionElement;
135 MFX_PACK_END()
136 
137 MFX_PACK_BEGIN_USUAL_STRUCT()
138 typedef struct {
139     mfxCamVignetteCorrectionElement R;
140     mfxCamVignetteCorrectionElement G0;
141     mfxCamVignetteCorrectionElement B;
142     mfxCamVignetteCorrectionElement G1;
143 } mfxCamVignetteCorrectionParam;
144 MFX_PACK_END()
145 
146 MFX_PACK_BEGIN_STRUCT_W_PTR()
147 typedef struct {
148     mfxExtBuffer    Header;
149 
150     mfxU32          Width;
151     mfxU32          Height;
152     mfxU32          Pitch;
153     mfxU32          reserved[7];
154 
155     mfxCamVignetteCorrectionParam *CorrectionMap;
156 
157 } mfxExtCamVignetteCorrection;
158 MFX_PACK_END()
159 
160 MFX_PACK_BEGIN_USUAL_STRUCT()
161 typedef struct {
162     mfxExtBuffer    Header;
163     mfxU16          Threshold;
164     mfxU16          reserved[27];
165 } mfxExtCamBayerDenoise;
166 MFX_PACK_END()
167 
168 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
169 typedef struct {
170     mfxExtBuffer    Header;
171     mfxF64          CCM[3][3];
172     mfxU32          reserved[4];
173 } mfxExtCamColorCorrection3x3;
174 MFX_PACK_END()
175 
176 MFX_PACK_BEGIN_USUAL_STRUCT()
177 typedef struct {
178     mfxExtBuffer    Header;
179     mfxU16 Top;
180     mfxU16 Bottom;
181     mfxU16 Left;
182     mfxU16 Right;
183     mfxU32 reserved[4];
184 } mfxExtCamPadding;
185 MFX_PACK_END()
186 
187 typedef enum {
188     MFX_CAM_BAYER_BGGR   = 0x0000,
189     MFX_CAM_BAYER_RGGB   = 0x0001,
190     MFX_CAM_BAYER_GBRG   = 0x0002,
191     MFX_CAM_BAYER_GRBG   = 0x0003
192 } mfxCamBayerFormat;
193 
194 MFX_PACK_BEGIN_USUAL_STRUCT()
195 typedef struct {
196     mfxExtBuffer    Header;
197     mfxU16          RawFormat;
198     mfxU16          reserved1;
199     mfxU32          reserved[5];
200 } mfxExtCamPipeControl;
201 MFX_PACK_END()
202 
203 MFX_PACK_BEGIN_USUAL_STRUCT()
204 typedef struct{
205     mfxU16 Pixel;
206     mfxU16 Red;
207     mfxU16 Green;
208     mfxU16 Blue;
209 } mfxCamFwdGammaSegment;
210 MFX_PACK_END()
211 
212 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
213 typedef struct {
214     mfxExtBuffer Header;
215 
216     mfxU16       reserved[19];
217     mfxU16       NumSegments;
218     union {
219         mfxCamFwdGammaSegment* Segment;
220         mfxU64 reserved1;
221     };
222 } mfxExtCamFwdGamma;
223 MFX_PACK_END()
224 
225 MFX_PACK_BEGIN_USUAL_STRUCT()
226 typedef struct {
227     mfxExtBuffer Header;
228 
229     mfxF32       a[3]; // [R, G, B]
230     mfxF32       b[3]; // [R, G, B]
231     mfxF32       c[3]; // [R, G, B]
232     mfxF32       d[3]; // [R, G, B]
233     mfxU16       reserved[36];
234 } mfxExtCamLensGeomDistCorrection;
235 MFX_PACK_END()
236 
237 /* LUTSize */
238 enum {
239     MFX_CAM_3DLUT17_SIZE = (17 * 17 * 17),
240     MFX_CAM_3DLUT33_SIZE = (33 * 33 * 33),
241     MFX_CAM_3DLUT65_SIZE = (65 * 65 * 65)
242 };
243 
244 MFX_PACK_BEGIN_USUAL_STRUCT()
245 typedef struct {
246     mfxU16 R;
247     mfxU16 G;
248     mfxU16 B;
249     mfxU16 Reserved;
250 } mfxCam3DLutEntry;
251 MFX_PACK_END()
252 
253 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
254 typedef struct {
255     mfxExtBuffer Header;
256 
257     mfxU16 reserved[10];
258     mfxU32 Size;
259     union
260     {
261         mfxCam3DLutEntry* Table;
262         mfxU64 reserved1;
263     };
264 } mfxExtCam3DLut;
265 MFX_PACK_END()
266 
267 #ifdef __cplusplus
268 } // extern "C"
269 #endif
270 
271 #endif // __MFXCAMERA_H__
272