blob: ac5ae96d423242f1dc63f8b9016a11548543912f [file] [log] [blame]
Iliyan Malchev66ea3572011-05-01 14:05:30 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H
18#define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H
19
Mattias Nissler9cf80c62016-02-03 22:20:06 +010020#include <stddef.h>
Alex Raye13f15a2013-03-19 01:41:32 -070021#include <stdint.h>
22
Mathias Agopianc9b06952011-08-11 22:35:31 -070023#ifdef __cplusplus
24extern "C" {
25#endif
Iliyan Malchev66ea3572011-05-01 14:05:30 -070026
Mathias Agopian5c9be402011-08-09 18:55:44 -070027/*
28 * If the HAL needs to create service threads to handle graphics related
29 * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority
30 * if they can block the main rendering thread in any way.
31 *
32 * the priority of the current thread can be set with:
33 *
34 * #include <sys/resource.h>
35 * setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);
36 *
37 */
38
39#define HAL_PRIORITY_URGENT_DISPLAY (-8)
40
Iliyan Malchev66ea3572011-05-01 14:05:30 -070041/**
42 * pixel format definitions
43 */
44
Dan Stoza48cd3402015-12-17 13:58:19 -080045typedef enum android_pixel_format {
Mathias Agopian8d9da282013-07-25 17:07:11 -070046 /*
47 * "linear" color pixel formats:
48 *
Eino-Ville Talvala03743412015-02-17 15:34:44 -080049 * When used with ANativeWindow, the dataSpace field describes the color
50 * space of the buffer.
51 *
52 * The color space determines, for example, if the formats are linear or
53 * gamma-corrected; or whether any special operations are performed when
54 * reading or writing into a buffer in one of these formats.
Mathias Agopian8d9da282013-07-25 17:07:11 -070055 */
Iliyan Malchev66ea3572011-05-01 14:05:30 -070056 HAL_PIXEL_FORMAT_RGBA_8888 = 1,
57 HAL_PIXEL_FORMAT_RGBX_8888 = 2,
58 HAL_PIXEL_FORMAT_RGB_888 = 3,
59 HAL_PIXEL_FORMAT_RGB_565 = 4,
60 HAL_PIXEL_FORMAT_BGRA_8888 = 5,
Iliyan Malchev66ea3572011-05-01 14:05:30 -070061
Mathias Agopian8d9da282013-07-25 17:07:11 -070062 /*
Iliyan Malchev66ea3572011-05-01 14:05:30 -070063 * 0x100 - 0x1FF
64 *
65 * This range is reserved for pixel formats that are specific to the HAL
66 * implementation. Implementations can use any value in this range to
67 * communicate video pixel formats between their HAL modules. These formats
68 * must not have an alpha channel. Additionally, an EGLimage created from a
69 * gralloc buffer of one of these formats must be supported for use with the
70 * GL_OES_EGL_image_external OpenGL ES extension.
71 */
72
73 /*
74 * Android YUV format:
75 *
Jamie Gennisda1a1f62011-05-18 14:42:46 -070076 * This format is exposed outside of the HAL to software decoders and
77 * applications. EGLImageKHR must support it in conjunction with the
Iliyan Malchev66ea3572011-05-01 14:05:30 -070078 * OES_EGL_image_external extension.
79 *
Jamie Gennisda1a1f62011-05-18 14:42:46 -070080 * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed
Iliyan Malchev66ea3572011-05-01 14:05:30 -070081 * by (W/2) x (H/2) Cr and Cb planes.
82 *
83 * This format assumes
84 * - an even width
85 * - an even height
86 * - a horizontal stride multiple of 16 pixels
87 * - a vertical stride equal to the height
88 *
89 * y_size = stride * height
Jamie Gennis185b3002012-04-30 12:50:38 -070090 * c_stride = ALIGN(stride/2, 16)
91 * c_size = c_stride * height/2
Iliyan Malchev66ea3572011-05-01 14:05:30 -070092 * size = y_size + c_size * 2
93 * cr_offset = y_size
94 * cb_offset = y_size + c_size
95 *
Eino-Ville Talvala03743412015-02-17 15:34:44 -080096 * When used with ANativeWindow, the dataSpace field describes the color
97 * space of the buffer.
Iliyan Malchev66ea3572011-05-01 14:05:30 -070098 */
99 HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar
100
Igor Murashkin9e00e662013-01-31 17:17:43 -0800101
102 /*
103 * Android Y8 format:
104 *
105 * This format is exposed outside of the HAL to the framework.
106 * The expected gralloc usage flags are SW_* and HW_CAMERA_*,
107 * and no other HW_ flags will be used.
108 *
109 * Y8 is a YUV planar format comprised of a WxH Y plane,
110 * with each pixel being represented by 8 bits.
111 *
112 * It is equivalent to just the Y plane from YV12.
113 *
114 * This format assumes
115 * - an even width
116 * - an even height
117 * - a horizontal stride multiple of 16 pixels
118 * - a vertical stride equal to the height
119 *
Igor Murashkind755b522013-02-11 11:34:53 -0800120 * size = stride * height
Igor Murashkin9e00e662013-01-31 17:17:43 -0800121 *
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800122 * When used with ANativeWindow, the dataSpace field describes the color
123 * space of the buffer.
Igor Murashkin9e00e662013-01-31 17:17:43 -0800124 */
125 HAL_PIXEL_FORMAT_Y8 = 0x20203859,
126
127 /*
128 * Android Y16 format:
129 *
130 * This format is exposed outside of the HAL to the framework.
131 * The expected gralloc usage flags are SW_* and HW_CAMERA_*,
132 * and no other HW_ flags will be used.
133 *
134 * Y16 is a YUV planar format comprised of a WxH Y plane,
135 * with each pixel being represented by 16 bits.
136 *
137 * It is just like Y8, but has double the bits per pixel (little endian).
138 *
139 * This format assumes
140 * - an even width
141 * - an even height
142 * - a horizontal stride multiple of 16 pixels
143 * - a vertical stride equal to the height
144 * - strides are specified in pixels, not in bytes
145 *
Igor Murashkind755b522013-02-11 11:34:53 -0800146 * size = stride * height * 2
Igor Murashkin9e00e662013-01-31 17:17:43 -0800147 *
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800148 * When used with ANativeWindow, the dataSpace field describes the color
149 * space of the buffer, except that dataSpace field
150 * HAL_DATASPACE_DEPTH indicates that this buffer contains a depth
Eino-Ville Talvala20651b52015-05-21 15:17:05 -0700151 * image where each sample is a distance value measured by a depth camera,
152 * plus an associated confidence value.
Igor Murashkin9e00e662013-01-31 17:17:43 -0800153 */
154 HAL_PIXEL_FORMAT_Y16 = 0x20363159,
155
Eino-Ville Talvala0a851542012-04-10 15:10:50 -0700156 /*
157 * Android RAW sensor format:
158 *
Ruben Brunk535253e2014-02-04 18:13:34 -0800159 * This format is exposed outside of the camera HAL to applications.
Eino-Ville Talvala0a851542012-04-10 15:10:50 -0700160 *
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800161 * RAW16 is a single-channel, 16-bit, little endian format, typically
Ruben Brunk535253e2014-02-04 18:13:34 -0800162 * representing raw Bayer-pattern images from an image sensor, with minimal
163 * processing.
Eino-Ville Talvala0a851542012-04-10 15:10:50 -0700164 *
165 * The exact pixel layout of the data in the buffer is sensor-dependent, and
166 * needs to be queried from the camera device.
167 *
168 * Generally, not all 16 bits are used; more common values are 10 or 12
Ruben Brunk535253e2014-02-04 18:13:34 -0800169 * bits. If not all bits are used, the lower-order bits are filled first.
170 * All parameters to interpret the raw data (black and white points,
Eino-Ville Talvala0a851542012-04-10 15:10:50 -0700171 * color space, etc) must be queried from the camera device.
172 *
173 * This format assumes
174 * - an even width
175 * - an even height
Ruben Brunk535253e2014-02-04 18:13:34 -0800176 * - a horizontal stride multiple of 16 pixels
177 * - a vertical stride equal to the height
178 * - strides are specified in pixels, not in bytes
179 *
180 * size = stride * height * 2
181 *
182 * This format must be accepted by the gralloc module when used with the
183 * following usage flags:
184 * - GRALLOC_USAGE_HW_CAMERA_*
185 * - GRALLOC_USAGE_SW_*
186 * - GRALLOC_USAGE_RENDERSCRIPT
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800187 *
188 * When used with ANativeWindow, the dataSpace should be
189 * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
190 * extra metadata to define.
Eino-Ville Talvala0a851542012-04-10 15:10:50 -0700191 */
Ruben Brunk535253e2014-02-04 18:13:34 -0800192 HAL_PIXEL_FORMAT_RAW16 = 0x20,
Ruben Brunk535253e2014-02-04 18:13:34 -0800193
194 /*
Zhijun He72fce302014-06-23 17:14:42 -0700195 * Android RAW10 format:
196 *
197 * This format is exposed outside of the camera HAL to applications.
198 *
Zhijun Hec73b73a2014-07-25 08:07:48 -0700199 * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row,
200 * unprocessed format, usually representing raw Bayer-pattern images coming from
201 * an image sensor.
Zhijun He72fce302014-06-23 17:14:42 -0700202 *
Zhijun Hec73b73a2014-07-25 08:07:48 -0700203 * In an image buffer with this format, starting from the first pixel of each
204 * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one
205 * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte
206 * contains the 2 least significant bits of the 4 pixels, the exact layout data
207 * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth
208 * bit of the ith pixel):
Zhijun He72fce302014-06-23 17:14:42 -0700209 *
210 * bit 7 bit 0
211 * =====|=====|=====|=====|=====|=====|=====|=====|
212 * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]|
213 * |-----|-----|-----|-----|-----|-----|-----|-----|
214 * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]|
215 * |-----|-----|-----|-----|-----|-----|-----|-----|
216 * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]|
217 * |-----|-----|-----|-----|-----|-----|-----|-----|
218 * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]|
219 * |-----|-----|-----|-----|-----|-----|-----|-----|
220 * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]|
221 * ===============================================
222 *
223 * This format assumes
224 * - a width multiple of 4 pixels
225 * - an even height
Zhijun He72fce302014-06-23 17:14:42 -0700226 * - a vertical stride equal to the height
Zhijun Hec73b73a2014-07-25 08:07:48 -0700227 * - strides are specified in bytes, not in pixels
Zhijun He72fce302014-06-23 17:14:42 -0700228 *
Zhijun Hec73b73a2014-07-25 08:07:48 -0700229 * size = stride * height
230 *
231 * When stride is equal to width * (10 / 8), there will be no padding bytes at
232 * the end of each row, the entire image data is densely packed. When stride is
233 * larger than width * (10 / 8), padding bytes will be present at the end of each
234 * row (including the last row).
Zhijun He72fce302014-06-23 17:14:42 -0700235 *
236 * This format must be accepted by the gralloc module when used with the
237 * following usage flags:
238 * - GRALLOC_USAGE_HW_CAMERA_*
239 * - GRALLOC_USAGE_SW_*
240 * - GRALLOC_USAGE_RENDERSCRIPT
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800241 *
242 * When used with ANativeWindow, the dataSpace field should be
243 * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
244 * extra metadata to define.
Zhijun He72fce302014-06-23 17:14:42 -0700245 */
246 HAL_PIXEL_FORMAT_RAW10 = 0x25,
247
248 /*
Yin-Chia Yeh9a5eeba2015-03-20 15:43:09 -0700249 * Android RAW12 format:
250 *
251 * This format is exposed outside of camera HAL to applications.
252 *
253 * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row,
254 * unprocessed format, usually representing raw Bayer-pattern images coming from
255 * an image sensor.
256 *
257 * In an image buffer with this format, starting from the first pixel of each
258 * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first
259 * and second byte contains the top 8 bits of first and second pixel. The third
260 * byte contains the 4 least significant bits of the two pixels, the exact layout
261 * data for each two consecutive pixels is illustrated below (Pi[j] stands for
262 * the jth bit of the ith pixel):
263 *
264 * bit 7 bit 0
265 * ======|======|======|======|======|======|======|======|
266 * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]|
267 * |------|------|------|------|------|------|------|------|
268 * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]|
269 * |------|------|------|------|------|------|------|------|
270 * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]|
271 * =======================================================
272 *
273 * This format assumes:
274 * - a width multiple of 4 pixels
275 * - an even height
276 * - a vertical stride equal to the height
277 * - strides are specified in bytes, not in pixels
278 *
279 * size = stride * height
280 *
281 * When stride is equal to width * (12 / 8), there will be no padding bytes at
282 * the end of each row, the entire image data is densely packed. When stride is
283 * larger than width * (12 / 8), padding bytes will be present at the end of
284 * each row (including the last row).
285 *
286 * This format must be accepted by the gralloc module when used with the
287 * following usage flags:
288 * - GRALLOC_USAGE_HW_CAMERA_*
289 * - GRALLOC_USAGE_SW_*
290 * - GRALLOC_USAGE_RENDERSCRIPT
291 *
292 * When used with ANativeWindow, the dataSpace field should be
293 * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
294 * extra metadata to define.
295 */
296 HAL_PIXEL_FORMAT_RAW12 = 0x26,
297
298 /*
Ruben Brunk535253e2014-02-04 18:13:34 -0800299 * Android opaque RAW format:
300 *
301 * This format is exposed outside of the camera HAL to applications.
302 *
303 * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an
304 * image sensor. The actual structure of buffers of this format is
305 * implementation-dependent.
306 *
307 * This format must be accepted by the gralloc module when used with the
308 * following usage flags:
309 * - GRALLOC_USAGE_HW_CAMERA_*
310 * - GRALLOC_USAGE_SW_*
311 * - GRALLOC_USAGE_RENDERSCRIPT
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800312 *
313 * When used with ANativeWindow, the dataSpace field should be
314 * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
315 * extra metadata to define.
Ruben Brunk535253e2014-02-04 18:13:34 -0800316 */
317 HAL_PIXEL_FORMAT_RAW_OPAQUE = 0x24,
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700318
Eino-Ville Talvala0a052482012-06-07 17:52:15 -0700319 /*
320 * Android binary blob graphics buffer format:
321 *
322 * This format is used to carry task-specific data which does not have a
323 * standard image structure. The details of the format are left to the two
324 * endpoints.
325 *
326 * A typical use case is for transporting JPEG-compressed images from the
327 * Camera HAL to the framework or to applications.
328 *
329 * Buffers of this format must have a height of 1, and width equal to their
330 * size in bytes.
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800331 *
332 * When used with ANativeWindow, the mapping of the dataSpace field to
333 * buffer contents for BLOB is as follows:
334 *
335 * dataSpace value | Buffer contents
336 * -------------------------------+-----------------------------------------
337 * HAL_DATASPACE_JFIF | An encoded JPEG image
338 * HAL_DATASPACE_DEPTH | An android_depth_points buffer
339 * Other | Unsupported
340 *
Eino-Ville Talvala0a052482012-06-07 17:52:15 -0700341 */
342 HAL_PIXEL_FORMAT_BLOB = 0x21,
343
Jamie Gennisfebe9d92012-08-22 14:44:51 -0700344 /*
345 * Android format indicating that the choice of format is entirely up to the
346 * device-specific Gralloc implementation.
347 *
348 * The Gralloc implementation should examine the usage bits passed in when
349 * allocating a buffer with this format, and it should derive the pixel
350 * format from those usage flags. This format will never be used with any
351 * of the GRALLOC_USAGE_SW_* usage flags.
352 *
353 * If a buffer of this format is to be used as an OpenGL ES texture, the
354 * framework will assume that sampling the texture will always return an
355 * alpha value of 1.0 (i.e. the buffer contains only opaque pixel values).
356 *
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800357 * When used with ANativeWindow, the dataSpace field describes the color
358 * space of the buffer.
Jamie Gennisfebe9d92012-08-22 14:44:51 -0700359 */
360 HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22,
361
Alex Raye13f15a2013-03-19 01:41:32 -0700362 /*
Lajos Molnare632c1b2015-04-23 16:17:32 -0700363 * Android flexible YCbCr 4:2:0 formats
Alex Raye13f15a2013-03-19 01:41:32 -0700364 *
Lajos Molnare632c1b2015-04-23 16:17:32 -0700365 * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0
366 * buffer layout, while still describing the general format in a
367 * layout-independent manner. While called YCbCr, it can be
Alex Raye13f15a2013-03-19 01:41:32 -0700368 * used to describe formats with either chromatic ordering, as well as
369 * whole planar or semiplanar layouts.
370 *
371 * struct android_ycbcr (below) is the the struct used to describe it.
372 *
373 * This format must be accepted by the gralloc module when
Yin-Chia Yehe49b6962015-07-14 12:15:29 -0700374 * USAGE_SW_WRITE_* or USAGE_SW_READ_* are set.
Alex Raye13f15a2013-03-19 01:41:32 -0700375 *
376 * This format is locked for use by gralloc's (*lock_ycbcr) method, and
377 * locking with the (*lock) method will return an error.
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800378 *
379 * When used with ANativeWindow, the dataSpace field describes the color
380 * space of the buffer.
Alex Raye13f15a2013-03-19 01:41:32 -0700381 */
382 HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23,
383
Lajos Molnare632c1b2015-04-23 16:17:32 -0700384 /*
385 * Android flexible YCbCr 4:2:2 formats
386 *
387 * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:2
388 * buffer layout, while still describing the general format in a
389 * layout-independent manner. While called YCbCr, it can be
390 * used to describe formats with either chromatic ordering, as well as
391 * whole planar or semiplanar layouts.
392 *
393 * This format is currently only used by SW readable buffers
394 * produced by MediaCodecs, so the gralloc module can ignore this format.
395 */
396 HAL_PIXEL_FORMAT_YCbCr_422_888 = 0x27,
397
398 /*
399 * Android flexible YCbCr 4:4:4 formats
400 *
401 * This format allows platforms to use an efficient YCbCr/YCrCb 4:4:4
402 * buffer layout, while still describing the general format in a
403 * layout-independent manner. While called YCbCr, it can be
404 * used to describe formats with either chromatic ordering, as well as
405 * whole planar or semiplanar layouts.
406 *
407 * This format is currently only used by SW readable buffers
408 * produced by MediaCodecs, so the gralloc module can ignore this format.
409 */
410 HAL_PIXEL_FORMAT_YCbCr_444_888 = 0x28,
411
412 /*
413 * Android flexible RGB 888 formats
414 *
415 * This format allows platforms to use an efficient RGB/BGR/RGBX/BGRX
416 * buffer layout, while still describing the general format in a
417 * layout-independent manner. While called RGB, it can be
418 * used to describe formats with either color ordering and optional
419 * padding, as well as whole planar layout.
420 *
421 * This format is currently only used by SW readable buffers
422 * produced by MediaCodecs, so the gralloc module can ignore this format.
423 */
424 HAL_PIXEL_FORMAT_FLEX_RGB_888 = 0x29,
425
426 /*
427 * Android flexible RGBA 8888 formats
428 *
429 * This format allows platforms to use an efficient RGBA/BGRA/ARGB/ABGR
430 * buffer layout, while still describing the general format in a
431 * layout-independent manner. While called RGBA, it can be
432 * used to describe formats with any of the component orderings, as
433 * well as whole planar layout.
434 *
435 * This format is currently only used by SW readable buffers
436 * produced by MediaCodecs, so the gralloc module can ignore this format.
437 */
438 HAL_PIXEL_FORMAT_FLEX_RGBA_8888 = 0x2A,
439
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700440 /* Legacy formats (deprecated), used by ImageFormat.java */
441 HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16
442 HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21
443 HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2
Dan Stoza48cd3402015-12-17 13:58:19 -0800444} android_pixel_format_t;
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700445
Alex Raye13f15a2013-03-19 01:41:32 -0700446/*
447 * Structure for describing YCbCr formats for consumption by applications.
448 * This is used with HAL_PIXEL_FORMAT_YCbCr_*_888.
449 *
450 * Buffer chroma subsampling is defined in the format.
451 * e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0.
452 *
453 * Buffers must have a 8 bit depth.
454 *
455 * @y, @cb, and @cr point to the first byte of their respective planes.
456 *
457 * Stride describes the distance in bytes from the first value of one row of
458 * the image to the first value of the next row. It includes the width of the
459 * image plus padding.
460 * @ystride is the stride of the luma plane.
461 * @cstride is the stride of the chroma planes.
462 *
463 * @chroma_step is the distance in bytes from one chroma pixel value to the
464 * next. This is 2 bytes for semiplanar (because chroma values are interleaved
465 * and each chroma value is one byte) and 1 for planar.
466 */
467
468struct android_ycbcr {
469 void *y;
470 void *cb;
471 void *cr;
472 size_t ystride;
473 size_t cstride;
474 size_t chroma_step;
475
476 /** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */
477 uint32_t reserved[8];
478};
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700479
480/**
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800481 * Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB
482 * with dataSpace value of HAL_DATASPACE_DEPTH.
483 * When locking a native buffer of the above format and dataSpace value,
484 * the vaddr pointer can be cast to this structure.
485 *
Eino-Ville Talvala20651b52015-05-21 15:17:05 -0700486 * A variable-length list of (x,y,z, confidence) 3D points, as floats. (x, y,
487 * z) represents a measured point's position, with the coordinate system defined
488 * by the data source. Confidence represents the estimated likelihood that this
489 * measurement is correct. It is between 0.f and 1.f, inclusive, with 1.f ==
490 * 100% confidence.
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800491 *
492 * @num_points is the number of points in the list
493 *
494 * @xyz_points is the flexible array of floating-point values.
Eino-Ville Talvala20651b52015-05-21 15:17:05 -0700495 * It contains (num_points) * 4 floats.
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800496 *
497 * For example:
498 * android_depth_points d = get_depth_buffer();
499 * struct {
Eino-Ville Talvala20651b52015-05-21 15:17:05 -0700500 * float x; float y; float z; float confidence;
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800501 * } firstPoint, lastPoint;
502 *
Eino-Ville Talvala20651b52015-05-21 15:17:05 -0700503 * firstPoint.x = d.xyzc_points[0];
504 * firstPoint.y = d.xyzc_points[1];
505 * firstPoint.z = d.xyzc_points[2];
506 * firstPoint.confidence = d.xyzc_points[3];
507 * lastPoint.x = d.xyzc_points[(d.num_points - 1) * 4 + 0];
508 * lastPoint.y = d.xyzc_points[(d.num_points - 1) * 4 + 1];
509 * lastPoint.z = d.xyzc_points[(d.num_points - 1) * 4 + 2];
510 * lastPoint.confidence = d.xyzc_points[(d.num_points - 1) * 4 + 3];
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800511 */
512
513struct android_depth_points {
514 uint32_t num_points;
515
516 /** reserved for future use, set to 0 by gralloc's (*lock)() */
517 uint32_t reserved[8];
518
Eino-Ville Talvala20651b52015-05-21 15:17:05 -0700519 float xyzc_points[];
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800520};
521
522/**
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700523 * Transformation definitions
524 *
525 * IMPORTANT NOTE:
526 * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}.
527 *
528 */
529
Dan Stoza48cd3402015-12-17 13:58:19 -0800530typedef enum android_transform {
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700531 /* flip source image horizontally (around the vertical axis) */
532 HAL_TRANSFORM_FLIP_H = 0x01,
533 /* flip source image vertically (around the horizontal axis)*/
534 HAL_TRANSFORM_FLIP_V = 0x02,
535 /* rotate source image 90 degrees clockwise */
536 HAL_TRANSFORM_ROT_90 = 0x04,
537 /* rotate source image 180 degrees */
538 HAL_TRANSFORM_ROT_180 = 0x03,
539 /* rotate source image 270 degrees clockwise */
540 HAL_TRANSFORM_ROT_270 = 0x07,
Mathias Agopian96675ed2013-09-17 23:48:54 -0700541 /* don't use. see system/window.h */
542 HAL_TRANSFORM_RESERVED = 0x08,
Dan Stoza48cd3402015-12-17 13:58:19 -0800543} android_transform_t;
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700544
Alex Rayc9f3bcf2013-11-26 16:50:46 -0800545/**
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800546 * Dataspace Definitions
Alex Rayc9f3bcf2013-11-26 16:50:46 -0800547 * ======================
548 *
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800549 * Dataspace is the definition of how pixel values should be interpreted.
550 *
551 * For many formats, this is the colorspace of the image data, which includes
552 * primaries (including white point) and the transfer characteristic function,
553 * which describes both gamma curve and numeric range (within the bit depth).
554 *
555 * Other dataspaces include depth measurement data from a depth camera.
Alex Rayc9f3bcf2013-11-26 16:50:46 -0800556 */
557
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800558typedef enum android_dataspace {
Alex Rayc9f3bcf2013-11-26 16:50:46 -0800559 /*
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800560 * Default-assumption data space, when not explicitly specified.
561 *
562 * It is safest to assume the buffer is an image with sRGB primaries and
563 * encoding ranges, but the consumer and/or the producer of the data may
564 * simply be using defaults. No automatic gamma transform should be
565 * expected, except for a possible display gamma transform when drawn to a
566 * screen.
567 */
568 HAL_DATASPACE_UNKNOWN = 0x0,
569
570 /*
571 * Arbitrary dataspace with manually defined characteristics. Definition
572 * for colorspaces or other meaning must be communicated separately.
Alex Rayc9f3bcf2013-11-26 16:50:46 -0800573 *
574 * This is used when specifying primaries, transfer characteristics,
575 * etc. separately.
576 *
577 * A typical use case is in video encoding parameters (e.g. for H.264),
578 * where a colorspace can have separately defined primaries, transfer
579 * characteristics, etc.
580 */
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800581 HAL_DATASPACE_ARBITRARY = 0x1,
582
583 /*
584 * RGB Colorspaces
585 * -----------------
586 *
587 * Primaries are given using (x,y) coordinates in the CIE 1931 definition
588 * of x and y specified by ISO 11664-1.
589 *
590 * Transfer characteristics are the opto-electronic transfer characteristic
591 * at the source as a function of linear optical intensity (luminance).
592 */
593
594 /*
595 * sRGB linear encoding:
596 *
597 * The red, green, and blue components are stored in sRGB space, but
598 * are linear, not gamma-encoded.
599 * The RGB primaries and the white point are the same as BT.709.
600 *
601 * The values are encoded using the full range ([0,255] for 8-bit) for all
602 * components.
603 */
604 HAL_DATASPACE_SRGB_LINEAR = 0x200,
605
606 /*
607 * sRGB gamma encoding:
608 *
609 * The red, green and blue components are stored in sRGB space, and
610 * converted to linear space when read, using the standard sRGB to linear
611 * equation:
612 *
613 * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045
614 * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045
615 *
616 * When written the inverse transformation is performed:
617 *
618 * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308
619 * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308
620 *
621 *
622 * The alpha component, if present, is always stored in linear space and
623 * is left unmodified when read or written.
624 *
625 * The RGB primaries and the white point are the same as BT.709.
626 *
627 * The values are encoded using the full range ([0,255] for 8-bit) for all
628 * components.
629 *
630 */
631 HAL_DATASPACE_SRGB = 0x201,
Alex Rayc9f3bcf2013-11-26 16:50:46 -0800632
633 /*
634 * YCbCr Colorspaces
635 * -----------------
636 *
637 * Primaries are given using (x,y) coordinates in the CIE 1931 definition
638 * of x and y specified by ISO 11664-1.
639 *
640 * Transfer characteristics are the opto-electronic transfer characteristic
641 * at the source as a function of linear optical intensity (luminance).
642 */
643
644 /*
645 * JPEG File Interchange Format (JFIF)
646 *
647 * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255
648 *
649 * Transfer characteristic curve:
650 * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018
651 * E = 4.500 L, 0.018 > L >= 0
652 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
653 * E - corresponding electrical signal
654 *
655 * Primaries: x y
656 * green 0.290 0.600
657 * blue 0.150 0.060
658 * red 0.640 0.330
659 * white (D65) 0.3127 0.3290
660 */
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800661 HAL_DATASPACE_JFIF = 0x101,
Alex Rayc9f3bcf2013-11-26 16:50:46 -0800662
663 /*
664 * ITU-R Recommendation 601 (BT.601) - 625-line
665 *
666 * Standard-definition television, 625 Lines (PAL)
667 *
668 * For 8-bit-depth formats:
669 * Luma (Y) samples should range from 16 to 235, inclusive
670 * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive
671 *
672 * For 10-bit-depth formats:
673 * Luma (Y) samples should range from 64 to 940, inclusive
674 * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive
675 *
676 * Transfer characteristic curve:
677 * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018
678 * E = 4.500 L, 0.018 > L >= 0
679 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
680 * E - corresponding electrical signal
681 *
682 * Primaries: x y
683 * green 0.290 0.600
684 * blue 0.150 0.060
685 * red 0.640 0.330
686 * white (D65) 0.3127 0.3290
687 */
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800688 HAL_DATASPACE_BT601_625 = 0x102,
Alex Rayc9f3bcf2013-11-26 16:50:46 -0800689
690 /*
691 * ITU-R Recommendation 601 (BT.601) - 525-line
692 *
693 * Standard-definition television, 525 Lines (NTSC)
694 *
695 * For 8-bit-depth formats:
696 * Luma (Y) samples should range from 16 to 235, inclusive
697 * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive
698 *
699 * For 10-bit-depth formats:
700 * Luma (Y) samples should range from 64 to 940, inclusive
701 * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive
702 *
703 * Transfer characteristic curve:
704 * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018
705 * E = 4.500 L, 0.018 > L >= 0
706 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
707 * E - corresponding electrical signal
708 *
709 * Primaries: x y
710 * green 0.310 0.595
711 * blue 0.155 0.070
712 * red 0.630 0.340
713 * white (D65) 0.3127 0.3290
714 */
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800715 HAL_DATASPACE_BT601_525 = 0x103,
Alex Rayc9f3bcf2013-11-26 16:50:46 -0800716
717 /*
718 * ITU-R Recommendation 709 (BT.709)
719 *
720 * High-definition television
721 *
722 * For 8-bit-depth formats:
723 * Luma (Y) samples should range from 16 to 235, inclusive
724 * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive
725 *
726 * For 10-bit-depth formats:
727 * Luma (Y) samples should range from 64 to 940, inclusive
728 * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive
729 *
730 * Primaries: x y
731 * green 0.300 0.600
732 * blue 0.150 0.060
733 * red 0.640 0.330
734 * white (D65) 0.3127 0.3290
735 */
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800736 HAL_DATASPACE_BT709 = 0x104,
737
738 /*
739 * The buffer contains depth ranging measurements from a depth camera.
740 * This value is valid with formats:
Eino-Ville Talvala20651b52015-05-21 15:17:05 -0700741 * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement
742 * and an associated confidence value. The 3 MSBs of the sample make
743 * up the confidence value, and the low 13 LSBs of the sample make up
744 * the depth measurement.
745 * For the confidence section, 0 means 100% confidence, 1 means 0%
746 * confidence. The mapping to a linear float confidence value between
747 * 0.f and 1.f can be obtained with
748 * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f;
749 * The depth measurement can be extracted simply with
750 * uint16_t range = (depthSample & 0x1FFF);
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800751 * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as
Eino-Ville Talvala20651b52015-05-21 15:17:05 -0700752 * a variable-length float (x,y,z, confidence) coordinate point list.
Eino-Ville Talvala03743412015-02-17 15:34:44 -0800753 * The point cloud will be represented with the android_depth_points
754 * structure.
755 */
756 HAL_DATASPACE_DEPTH = 0x1000
757
758} android_dataspace_t;
Alex Rayc9f3bcf2013-11-26 16:50:46 -0800759
Mathias Agopianc9b06952011-08-11 22:35:31 -0700760#ifdef __cplusplus
761}
762#endif
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700763
764#endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */