1c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh/*
2c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Copyright (C) 2016 The Android Open Source Project
3c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh *
4c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Licensed under the Apache License, Version 2.0 (the "License");
5c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * you may not use this file except in compliance with the License.
6c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * You may obtain a copy of the License at
7c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh *
8c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh *      http://www.apache.org/licenses/LICENSE-2.0
9c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh *
10c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Unless required by applicable law or agreed to in writing, software
11c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * distributed under the License is distributed on an "AS IS" BASIS,
12c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * See the License for the specific language governing permissions and
14c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * limitations under the License.
15c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh */
16c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
173e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/**
1825f5ece09fc045850785f09ddd9193e45b52c9d3Quddus Chong * @addtogroup Media
193e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @{
203e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh */
213e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh
223e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/**
233e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @file NdkImage.h
243e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh */
253e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh
26c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh/*
27c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * This file defines an NDK API.
28c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Do not remove methods.
29c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Do not change method signatures.
30c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Do not change the value of constants.
31c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Do not change the size of any of the classes defined in here.
32c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Do not reference types that are not part of the NDK.
33c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Do not #include files that aren't part of the NDK.
34c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh */
35c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
36c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#ifndef _NDK_IMAGE_H
37c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#define _NDK_IMAGE_H
38c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
392975a24dc42c8953125b39a5194da3aec244cbefDan Albert#include <sys/cdefs.h>
402975a24dc42c8953125b39a5194da3aec244cbefDan Albert
41c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#include "NdkMediaError.h"
42c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
43355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai#if __ANDROID_API__ >= 26
44355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai#include <android/hardware_buffer.h>
45355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai#endif /* __ANDROID_API__ >= 26 */
46355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai
47c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#ifdef __cplusplus
48c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehextern "C" {
49c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#endif
50c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
512975a24dc42c8953125b39a5194da3aec244cbefDan Albert#if __ANDROID_API__ >= 24
522975a24dc42c8953125b39a5194da3aec244cbefDan Albert
531d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
541d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * AImage is an opaque type that provides access to image generated by {@link AImageReader}.
551d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
56c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehtypedef struct AImage AImage;
57c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
58c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// Formats not listed here will not be supported by AImageReader
591d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yehenum AIMAGE_FORMATS {
601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
61de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * 32 bits RGBA format, 8 bits for each of the four channels.
62de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     *
63de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <p>
64de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * Corresponding formats:
65de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <ul>
66de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM</li>
67de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>Vulkan: VK_FORMAT_R8G8B8A8_UNORM</li>
68de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>OpenGL ES: GL_RGBA8</li>
69de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * </ul>
70de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * </p>
71de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     *
72de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AImage
73de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AImageReader
74de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AHardwareBuffer
75de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     */
76de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai    AIMAGE_FORMAT_RGBA_8888         = 0x1,
77de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai
78de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai    /**
79de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * 32 bits RGBX format, 8 bits for each of the four channels.
80de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     *
81de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <p>
82de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * Corresponding formats:
83de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <ul>
84de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM</li>
85de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>Vulkan: VK_FORMAT_R8G8B8A8_UNORM</li>
86de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>OpenGL ES: GL_RGBA8</li>
87de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * </ul>
88de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * </p>
89de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     *
90de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AImage
91de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AImageReader
92de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AHardwareBuffer
93de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     */
94de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai    AIMAGE_FORMAT_RGBX_8888         = 0x2,
95de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai
96de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai    /**
97de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * 24 bits RGB format, 8 bits for each of the three channels.
98de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     *
99de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <p>
100de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * Corresponding formats:
101de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <ul>
102de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM</li>
103de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>Vulkan: VK_FORMAT_R8G8B8_UNORM</li>
104de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>OpenGL ES: GL_RGB8</li>
105de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * </ul>
106de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * </p>
107de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     *
108de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AImage
109de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AImageReader
110de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AHardwareBuffer
111de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     */
112de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai    AIMAGE_FORMAT_RGB_888           = 0x3,
113de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai
114de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai    /**
115de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * 16 bits RGB format, 5 bits for Red channel, 6 bits for Green channel,
116de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * and 5 bits for Blue channel.
117de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     *
118de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <p>
119de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * Corresponding formats:
120de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <ul>
121de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM</li>
122de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>Vulkan: VK_FORMAT_R5G6B5_UNORM_PACK16</li>
123de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>OpenGL ES: GL_RGB565</li>
124de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * </ul>
125de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * </p>
126de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     *
127de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AImage
128de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AImageReader
129de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AHardwareBuffer
130de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     */
131de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai    AIMAGE_FORMAT_RGB_565           = 0x4,
132de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai
133de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai    /**
134de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * 64 bits RGBA format, 16 bits for each of the four channels.
135de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     *
136de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <p>
137de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * Corresponding formats:
138de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <ul>
1399b46a4ba85ce8941573344ff515481f318397203Jesse Hall     * <li>AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT</li>
140de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>Vulkan: VK_FORMAT_R16G16B16A16_SFLOAT</li>
141de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * <li>OpenGL ES: GL_RGBA16F</li>
142de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * </ul>
143de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * </p>
144de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     *
145de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AImage
146de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AImageReader
147de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     * @see AHardwareBuffer
148de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai     */
149de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai    AIMAGE_FORMAT_RGBA_FP16         = 0x16,
150de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai
151de2a544846419f61080b8f7db427261807390747Jiwen 'Steve' Cai    /**
1521d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Multi-plane Android YUV 420 format.
1531d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1541d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>This format is a generic YCbCr format, capable of describing any 4:2:0
1551d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * chroma-subsampled planar or semiplanar buffer (but not fully interleaved),
1561d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * with 8 bits per color sample.</p>
1571d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1581d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>Images in this format are always represented by three separate buffers
1591d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * of data, one for each color plane. Additional information always
1601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * accompanies the buffers, describing the row stride and the pixel stride
1611d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * for each plane.</p>
1621d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1631d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The order of planes is guaranteed such that plane #0 is always Y, plane #1 is always
1641d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * U (Cb), and plane #2 is always V (Cr).</p>
1651d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1661d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The Y-plane is guaranteed not to be interleaved with the U/V planes
1671d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * (in particular, pixel stride is always 1 in {@link AImage_getPlanePixelStride}).</p>
1681d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1691d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The U/V planes are guaranteed to have the same row stride and pixel stride, that is, the
1701d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * return value of {@link AImage_getPlaneRowStride} for the U/V plane are guaranteed to be the
1711d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * same, and the return value of {@link AImage_getPlanePixelStride} for the U/V plane are also
1721d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * guaranteed to be the same.</p>
1731d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1741d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>For example, the {@link AImage} object can provide data
1751d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * in this format from a {@link ACameraDevice} through an {@link AImageReader} object.</p>
1761d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1771d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>This format is always supported as an output format for the android Camera2 NDK API.</p>
1781d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1791d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see AImage
1801d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see AImageReader
1811d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see ACameraDevice
1821d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
183c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_YUV_420_888       = 0x23,
1841d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
1851d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
1861d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Compressed JPEG format.
1871d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1881d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>This format is always supported as an output format for the android Camera2 NDK API.</p>
1891d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
190c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_JPEG              = 0x100,
1911d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
1921d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
1931d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * 16 bits per pixel raw camera sensor image format, usually representing a single-channel
1941d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Bayer-mosaic image.
1951d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1961d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The layout of the color mosaic, the maximum and minimum encoding
1971d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * values of the raw pixel data, the color space of the image, and all other
1981d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * needed information to interpret a raw sensor image must be queried from
1991d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * the {@link ACameraDevice} which produced the image.</p>
2001d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
201c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_RAW16             = 0x20,
2021d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
2031d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
2041d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Private raw camera sensor image format, a single channel image with implementation depedent
2051d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * pixel layout.
2061d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
2071d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>AIMAGE_FORMAT_RAW_PRIVATE is a format for unprocessed raw image buffers coming from an
2081d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * image sensor. The actual structure of buffers of this format is implementation-dependent.</p>
2091d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
2101d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
211c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_RAW_PRIVATE       = 0x24,
2121d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
2131d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
2141d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Android 10-bit raw format.
2151d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
2161d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
2171d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * This is a single-plane, 10-bit per pixel, densely packed (in each row),
2181d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * unprocessed format, usually representing raw Bayer-pattern images coming
2191d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * from an image sensor.
2201d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
2211d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
2221d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * In an image buffer with this format, starting from the first pixel of
2231d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * each row, each 4 consecutive pixels are packed into 5 bytes (40 bits).
2241d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Each one of the first 4 bytes contains the top 8 bits of each pixel, The
2251d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * fifth byte contains the 2 least significant bits of the 4 pixels, the
2261d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * exact layout data for each 4 consecutive pixels is illustrated below
2271d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * (Pi[j] stands for the jth bit of the ith pixel):
2281d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
2291d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <table>
2301d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
2311d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center"></th>
2321d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 7</th>
2331d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 6</th>
2341d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 5</th>
2351d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 4</th>
2361d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 3</th>
2371d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 2</th>
2381d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 1</th>
2391d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 0</th>
2401d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
2411d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
2421d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 0:</td>
2431d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[9]</td>
2441d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[8]</td>
2451d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[7]</td>
2461d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[6]</td>
2471d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[5]</td>
2481d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[4]</td>
2491d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[3]</td>
2501d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[2]</td>
2511d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
2521d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
2531d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 1:</td>
2541d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[9]</td>
2551d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[8]</td>
2561d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[7]</td>
2571d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[6]</td>
2581d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[5]</td>
2591d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[4]</td>
2601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[3]</td>
2611d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[2]</td>
2621d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
2631d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
2641d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 2:</td>
2651d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[9]</td>
2661d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[8]</td>
2671d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[7]</td>
2681d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[6]</td>
2691d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[5]</td>
2701d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[4]</td>
2711d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[3]</td>
2721d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[2]</td>
2731d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
2741d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
2751d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 3:</td>
2761d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[9]</td>
2771d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[8]</td>
2781d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[7]</td>
2791d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[6]</td>
2801d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[5]</td>
2811d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[4]</td>
2821d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[3]</td>
2831d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[2]</td>
2841d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
2851d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
2861d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 4:</td>
2871d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[1]</td>
2881d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[0]</td>
2891d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[1]</td>
2901d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[0]</td>
2911d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[1]</td>
2921d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[0]</td>
2931d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[1]</td>
2941d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[0]</td>
2951d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
2961d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </table>
2971d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
2981d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * This format assumes
2991d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <ul>
3001d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>a width multiple of 4 pixels</li>
3011d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>an even height</li>
3021d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </ul>
3031d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
3041d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3051d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <pre>size = row stride * height</pre> where the row stride is in <em>bytes</em>,
3061d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * not pixels.
3071d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3081d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
3091d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Since this is a densely packed format, the pixel stride is always 0. The
3101d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * application must use the pixel data layout defined in above table to
3111d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * access each row data. When row stride is equal to (width * (10 / 8)), there
3121d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * will be no padding bytes at the end of each row, the entire image data is
3131d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * densely packed. When stride is larger than (width * (10 / 8)), padding
3141d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * bytes will be present at the end of each row.
3151d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
3161d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
3171d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * For example, the {@link AImage} object can provide data in this format from a
3181d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * {@link ACameraDevice} (if supported) through a {@link AImageReader} object.
3191d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * The number of planes returned by {@link AImage_getNumberOfPlanes} will always be 1.
3201d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * The pixel stride is undefined ({@link AImage_getPlanePixelStride} will return
3211d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * {@link AMEDIA_ERROR_UNSUPPORTED}), and the {@link AImage_getPlaneRowStride} described the
3221d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * vertical neighboring pixel distance (in bytes) between adjacent rows.
3231d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
3241d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3251d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see AImage
3261d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see AImageReader
3271d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see ACameraDevice
3281d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
329c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_RAW10             = 0x25,
3301d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
3311d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
3321d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Android 12-bit raw format.
3331d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3341d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
3351d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * This is a single-plane, 12-bit per pixel, densely packed (in each row),
3361d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * unprocessed format, usually representing raw Bayer-pattern images coming
3371d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * from an image sensor.
3381d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
3391d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
3401d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * In an image buffer with this format, starting from the first pixel of each
3411d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first
3421d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * and second byte contains the top 8 bits of first and second pixel. The third
3431d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * byte contains the 4 least significant bits of the two pixels, the exact layout
3441d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * data for each two consecutive pixels is illustrated below (Pi[j] stands for
3451d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * the jth bit of the ith pixel):
3461d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
3471d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <table>
3481d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
3491d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center"></th>
3501d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 7</th>
3511d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 6</th>
3521d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 5</th>
3531d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 4</th>
3541d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 3</th>
3551d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 2</th>
3561d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 1</th>
3571d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 0</th>
3581d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
3591d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
3601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 0:</td>
3611d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[11]</td>
3621d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[10]</td>
3631d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 9]</td>
3641d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 8]</td>
3651d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 7]</td>
3661d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 6]</td>
3671d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 5]</td>
3681d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 4]</td>
3691d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
3701d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
3711d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 1:</td>
3721d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[11]</td>
3731d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[10]</td>
3741d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 9]</td>
3751d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 8]</td>
3761d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 7]</td>
3771d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 6]</td>
3781d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 5]</td>
3791d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 4]</td>
3801d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
3811d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
3821d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 2:</td>
3831d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 3]</td>
3841d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 2]</td>
3851d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 1]</td>
3861d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 0]</td>
3871d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 3]</td>
3881d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 2]</td>
3891d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 1]</td>
3901d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 0]</td>
3911d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
3921d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </table>
3931d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
3941d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * This format assumes
3951d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <ul>
3961d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>a width multiple of 4 pixels</li>
3971d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>an even height</li>
3981d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </ul>
3991d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
4001d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4011d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <pre>size = row stride * height</pre> where the row stride is in <em>bytes</em>,
4021d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * not pixels.
4031d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4041d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
4051d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Since this is a densely packed format, the pixel stride is always 0. The
4061d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * application must use the pixel data layout defined in above table to
4071d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * access each row data. When row stride is equal to (width * (12 / 8)), there
4081d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * will be no padding bytes at the end of each row, the entire image data is
4091d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * densely packed. When stride is larger than (width * (12 / 8)), padding
4101d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * bytes will be present at the end of each row.
4111d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
4121d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
4131d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * For example, the {@link AImage} object can provide data in this format from a
4141d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * {@link ACameraDevice} (if supported) through a {@link AImageReader} object.
4151d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * The number of planes returned by {@link AImage_getNumberOfPlanes} will always be 1.
4161d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * The pixel stride is undefined ({@link AImage_getPlanePixelStride} will return
4171d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * {@link AMEDIA_ERROR_UNSUPPORTED}), and the {@link AImage_getPlaneRowStride} described the
4181d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * vertical neighboring pixel distance (in bytes) between adjacent rows.
4191d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
4201d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4211d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see AImage
4221d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see AImageReader
4231d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see ACameraDevice
4241d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
425c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_RAW12             = 0x26,
4261d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
4271d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
4281d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Android dense depth image format.
4291d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4301d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>Each pixel is 16 bits, representing a depth ranging measurement from a depth camera or
4311d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * similar sensor. The 16-bit sample consists of a confidence value and the actual ranging
4321d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * measurement.</p>
4331d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4341d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The confidence value is an estimate of correctness for this sample.  It is encoded in the
4351d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * 3 most significant bits of the sample, with a value of 0 representing 100% confidence, a
4361d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * value of 1 representing 0% confidence, a value of 2 representing 1/7, a value of 3
4371d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * representing 2/7, and so on.</p>
4381d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4391d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>As an example, the following sample extracts the range and confidence from the first pixel
4401d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * of a DEPTH16-format {@link AImage}, and converts the confidence to a floating-point value
4411d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * between 0 and 1.f inclusive, with 1.f representing maximum confidence:
4421d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4431d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <pre>
4441d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    uint16_t* data;
4451d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    int dataLength;
4461d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    AImage_getPlaneData(image, 0, (uint8_t**)&data, &dataLength);
4471d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    uint16_t depthSample = data[0];
4481d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    uint16_t depthRange = (depthSample & 0x1FFF);
4491d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    uint16_t depthConfidence = ((depthSample >> 13) & 0x7);
4501d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    float depthPercentage = depthConfidence == 0 ? 1.f : (depthConfidence - 1) / 7.f;
4511d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </pre>
4521d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
4531d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4541d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>This format assumes
4551d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <ul>
4561d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>an even width</li>
4571d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>an even height</li>
4581d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>a horizontal stride multiple of 16 pixels</li>
4591d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </ul>
4601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
4611d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4621d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <pre> y_size = stride * height </pre>
4631d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4641d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * When produced by a camera, the units for the range are millimeters.
4651d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
466c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_DEPTH16           = 0x44363159,
4671d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
4681d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
4691d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Android sparse depth point cloud format.
4701d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4711d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>A variable-length list of 3D points plus a confidence value, with each point represented
4721d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * by four floats; first the X, Y, Z position coordinates, and then the confidence value.</p>
4731d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4741d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The number of points is ((size of the buffer in bytes) / 16).
4751d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4761d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The coordinate system and units of the position values depend on the source of the point
4771d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * cloud data. The confidence value is between 0.f and 1.f, inclusive, with 0 representing 0%
4781d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * confidence and 1.f representing 100% confidence in the measured position values.</p>
4791d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4801d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>As an example, the following code extracts the first depth point in a DEPTH_POINT_CLOUD
4811d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * format {@link AImage}:
4821d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <pre>
4831d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    float* data;
4841d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    int dataLength;
4851d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    AImage_getPlaneData(image, 0, (uint8_t**)&data, &dataLength);
4861d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    float x = data[0];
4871d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    float y = data[1];
4881d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    float z = data[2];
4891d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    float confidence = data[3];
4901d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </pre>
4911d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4921d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
4933e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh    AIMAGE_FORMAT_DEPTH_POINT_CLOUD = 0x101,
4941d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
4951d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
4961d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Android private opaque image format.
4971d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
4981d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>This format is not currently supported by {@link AImageReader}.</p>
4991d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
5001d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    AIMAGE_FORMAT_PRIVATE           = 0x22
501c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh};
502c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
5031d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
5041d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Data type describing an cropped rectangle returned by {@link AImage_getCropRect}.
5051d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5061d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>Note that the right and bottom coordinates are exclusive, so the width of the rectangle is
5071d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * (right - left) and the height of the rectangle is (bottom - top).</p>
5081d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
509c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehtypedef struct AImageCropRect {
510c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    int32_t left;
511c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    int32_t top;
512c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    int32_t right;
513c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    int32_t bottom;
514c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh} AImageCropRect;
515c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
5161d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
5171d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Return the image back the the system and delete the AImage object from memory.
5181d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5191d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>Do NOT use the image pointer after this method returns.
5201d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Note that if the parent {@link AImageReader} is closed, all the {@link AImage} objects acquired
5211d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * from the parent reader will be returned to system. All AImage_* methods except this method will
5221d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * return {@link AMEDIA_ERROR_INVALID_OBJECT}. Application still needs to call this method on those
5231d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * {@link AImage} objects to fully delete the {@link AImage} object from memory.</p>
5241d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5251d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image The {@link AImage} to be deleted.
5261d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
527c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehvoid AImage_delete(AImage* image);
528c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
5291d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
5301d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the width of the input {@link AImage}.
5311d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5321d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
5331d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param width the width of the image will be filled here if the method call succeeeds.
5341d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5351d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
5361d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
5371d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or width is NULL.</li>
5381d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
5391d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
5401d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
541c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getWidth(const AImage* image, /*out*/int32_t* width);
542c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
5431d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
5441d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the height of the input {@link AImage}.
5451d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5461d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
5471d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param height the height of the image will be filled here if the method call succeeeds.
5481d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5491d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
5501d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
5511d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or height is NULL.</li>
5521d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
5531d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
5541d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
555c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getHeight(const AImage* image, /*out*/int32_t* height);
556c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
5571d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
5581d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the format of the input {@link AImage}.
5591d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>The format value will be one of AIMAGE_FORMAT_* enum value.</p>
5611d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5621d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
5631d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param format the format of the image will be filled here if the method call succeeeds.
5641d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5651d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
5661d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
5671d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or format is NULL.</li>
5681d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
5691d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
5701d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
571c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getFormat(const AImage* image, /*out*/int32_t* format);
572c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
5731d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
5741d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the cropped rectangle of the input {@link AImage}.
5751d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5761d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>The crop rectangle specifies the region of valid pixels in the image, using coordinates in the
5771d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * largest-resolution plane.</p>
5781d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5791d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
5801d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param rect the cropped rectangle of the image will be filled here if the method call succeeeds.
5811d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5821d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
5831d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
5841d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or rect is NULL.</li>
5851d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
5861d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
5871d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
588c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getCropRect(const AImage* image, /*out*/AImageCropRect* rect);
589c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
5901d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
5911d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the timestamp of the input {@link AImage}.
5921d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5931d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>
5941d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * The timestamp is measured in nanoseconds, and is normally monotonically increasing. The
5951d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * timestamps for the images from different sources may have different timebases therefore may not
5961d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * be comparable. The specific meaning and timebase of the timestamp depend on the source providing
5971d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * images. For images generated by camera, the timestamp value will match
5981d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * {@link ACAMERA_SENSOR_TIMESTAMP} of the {@link ACameraMetadata} in
5991d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * {@link ACameraCaptureSession_captureCallbacks#onCaptureStarted} and
6001d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * {@link ACameraCaptureSession_captureCallbacks#onCaptureCompleted} callback.
6011d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * </p>
6021d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6031d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
6041d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param timestampNs the timestamp of the image will be filled here if the method call succeeeds.
6051d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6061d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
6071d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
6081d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or timestampNs is NULL.</li>
6091d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
6101d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
6111d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
612c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getTimestamp(const AImage* image, /*out*/int64_t* timestampNs);
613c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
6141d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
6151d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the number of planes of the input {@link AImage}.
6161d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6171d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>The number of plane of an {@link AImage} is determined by its format, which can be queried by
6181d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * {@link AImage_getFormat} method.</p>
6191d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6201d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
6211d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param numPlanes the number of planes of the image will be filled here if the method call
6221d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         succeeeds.
6231d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6241d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
6251d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
6261d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or numPlanes is NULL.</li>
6271d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
6281d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
6291d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
630c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getNumberOfPlanes(const AImage* image, /*out*/int32_t* numPlanes);
631c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
6321d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
6331d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the pixel stride of the input {@link AImage}.
6341d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6351d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>This is the distance between two consecutive pixel values in a row of pixels. It may be
6361d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * larger than the size of a single pixel to account for interleaved image data or padded formats.
6371d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Note that pixel stride is undefined for some formats such as {@link AIMAGE_FORMAT_RAW_PRIVATE},
6381d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * and calling this method on images of these formats will cause {@link AMEDIA_ERROR_UNSUPPORTED}
6391d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * being returned.
6401d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * For formats where pixel stride is well defined, the pixel stride is always greater than 0.</p>
6411d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6421d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
6431d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param planeIdx the index of the plane. Must be less than the number of planes of input image.
6441d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param pixelStride the pixel stride of the image will be filled here if the method call succeeeds.
6451d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6461d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
6471d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
6481d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or pixelStride is NULL, or planeIdx
6491d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 is out of the range of [0, numOfPlanes - 1].</li>
6501d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_UNSUPPORTED} if pixel stride is undefined for the format of input
6511d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image.</li>
6521d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
6532f1a4737c997d9589447a51974e3aaecafee2937Jiwen 'Steve' Cai *                 image has been deleted.</li>
6542f1a4737c997d9589447a51974e3aaecafee2937Jiwen 'Steve' Cai *         <li>{@link AMEDIA_IMGREADER_CANNOT_LOCK_IMAGE} if the {@link AImage} cannot be locked
6552f1a4737c997d9589447a51974e3aaecafee2937Jiwen 'Steve' Cai *                 for CPU access.</li></ul>
6561d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
657c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getPlanePixelStride(
658c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh        const AImage* image, int planeIdx, /*out*/int32_t* pixelStride);
659c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
6601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
6611d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the row stride of the input {@link AImage}.
6621d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6631d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>This is the distance between the start of two consecutive rows of pixels in the image. Note
6641d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * that row stried is undefined for some formats such as {@link AIMAGE_FORMAT_RAW_PRIVATE}, and
6651d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * calling this method on images of these formats will cause {@link AMEDIA_ERROR_UNSUPPORTED}
6661d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * being returned.
6671d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * For formats where row stride is well defined, the row stride is always greater than 0.</p>
6681d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6691d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
6701d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param planeIdx the index of the plane. Must be less than the number of planes of input image.
6711d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param rowStride the row stride of the image will be filled here if the method call succeeeds.
6721d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6731d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
6741d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
6751d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or rowStride is NULL, or planeIdx
6761d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 is out of the range of [0, numOfPlanes - 1].</li>
6771d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_UNSUPPORTED} if row stride is undefined for the format of input
6781d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image.</li>
6791d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
6802f1a4737c997d9589447a51974e3aaecafee2937Jiwen 'Steve' Cai *                 image has been deleted.</li>
6812f1a4737c997d9589447a51974e3aaecafee2937Jiwen 'Steve' Cai *         <li>{@link AMEDIA_IMGREADER_CANNOT_LOCK_IMAGE} if the {@link AImage} cannot be locked
6822f1a4737c997d9589447a51974e3aaecafee2937Jiwen 'Steve' Cai *                 for CPU access.</li></ul>
6831d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
684c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getPlaneRowStride(
685c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh        const AImage* image, int planeIdx, /*out*/int32_t* rowStride);
686c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
6871d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
6881d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Get the data pointer of the input image for direct application access.
6891d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6901d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>Note that once the {@link AImage} or the parent {@link AImageReader} is deleted, the data
6911d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * pointer from previous AImage_getPlaneData call becomes invalid. Do NOT use it after the
6921d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * {@link AImage} or the parent {@link AImageReader} is deleted.</p>
6931d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6941d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
6951d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param planeIdx the index of the plane. Must be less than the number of planes of input image.
6961d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param data the data pointer of the image will be filled here if the method call succeeeds.
6971d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param dataLength the valid length of data will be filled here if the method call succeeeds.
6981d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
6991d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
7001d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
7011d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image, data or dataLength is NULL, or
7021d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 planeIdx is out of the range of [0, numOfPlanes - 1].</li>
7031d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
7042f1a4737c997d9589447a51974e3aaecafee2937Jiwen 'Steve' Cai *                 image has been deleted.</li>
7052f1a4737c997d9589447a51974e3aaecafee2937Jiwen 'Steve' Cai *         <li>{@link AMEDIA_IMGREADER_CANNOT_LOCK_IMAGE} if the {@link AImage} cannot be locked
7062f1a4737c997d9589447a51974e3aaecafee2937Jiwen 'Steve' Cai *                 for CPU access.</li></ul>
7071d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
708c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getPlaneData(
709c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh        const AImage* image, int planeIdx,
710c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh        /*out*/uint8_t** data, /*out*/int* dataLength);
711c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
7122975a24dc42c8953125b39a5194da3aec244cbefDan Albert#endif /* __ANDROID_API__ >= 24 */
7132975a24dc42c8953125b39a5194da3aec244cbefDan Albert
714355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai#if __ANDROID_API__ >= 26
715355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai
716355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai/*
717355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * Return the image back the the system and delete the AImage object from memory asynchronously.
718355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai *
719355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * <p>Similar to {@link AImage_delete}, do NOT use the image pointer after this method returns.
720355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * However, the caller can still hold on to the {@link AHardwareBuffer} returned from this image and
721355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * signal the release of the hardware buffer back to the {@link AImageReader}'s queue using
722355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * releaseFenceFd.</p>
723355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai *
724355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * @param image The {@link AImage} to be deleted.
725355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * @param releaseFenceFd A sync fence fd defined in {@link sync.h}, which signals the release of
726355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai *         underlying {@link AHardwareBuffer}.
727355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai *
728355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * @see sync.h
729355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai */
730355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Caivoid AImage_deleteAsync(AImage* image, int releaseFenceFd);
731355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai
732355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai/**
733355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * Get the hardware buffer handle of the input image intended for GPU and/or hardware access.
734355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai *
735355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * <p>Note that no reference on the returned {@link AHardwareBuffer} handle is acquired
736355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * automatically. Once the {@link AImage} or the parent {@link AImageReader} is deleted, the
737355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * {@link AHardwareBuffer} handle from previous {@link AImage_getHardwareBuffer} becomes
738355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * invalid.</p>
739355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai *
740355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * <p>If the caller ever needs to hold on a reference to the {@link AHardwareBuffer} handle after
741355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * the {@link AImage} or the parent {@link AImageReader} is deleted, it must call {@link
742355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * AHardwareBuffer_acquire} to acquire an extra reference, and call {@link AHardwareBuffer_release}
743355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * once it has finished using it in order to properly deallocate the underlying memory managed by
744355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * {@link AHardwareBuffer}. If the caller has acquired extra reference on an {@link AHardwareBuffer}
745355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * returned from this function, it must also listen to {@link onBufferFreed} callback to be
746355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * notified when the buffer is no longer used by {@link AImageReader}.</p>
747355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai *
748355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * @param image the {@link AImage} of interest.
749355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * @param outBuffer The memory area pointed to by buffer will contain the acquired AHardwareBuffer
750355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai *         handle.
751355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * @return <ul>
752355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
753355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or buffer is NULL</li></ul>
754355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai *
755355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai * @see AImageReader_ImageCallback
756355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai */
757355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Caimedia_status_t AImage_getHardwareBuffer(const AImage* image, /*out*/AHardwareBuffer** buffer);
758355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai
759355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai#endif /* __ANDROID_API__ >= 26 */
760355d99044ff82d943792f52b83d9aa2b1c42fc8eJiwen 'Steve' Cai
761c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#ifdef __cplusplus
762c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh} // extern "C"
763c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#endif
764c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
765c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#endif //_NDK_IMAGE_H
7663e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh
7673e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/** @} */
768