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/**
183e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @addtogroup Media Camera
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
39c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#include "NdkMediaError.h"
40c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
41c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#ifdef __cplusplus
42c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehextern "C" {
43c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#endif
44c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
451d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
461d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * AImage is an opaque type that provides access to image generated by {@link AImageReader}.
471d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
48c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehtypedef struct AImage AImage;
49c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
50c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// Formats not listed here will not be supported by AImageReader
511d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yehenum AIMAGE_FORMATS {
521d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
531d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Multi-plane Android YUV 420 format.
541d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
551d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>This format is a generic YCbCr format, capable of describing any 4:2:0
561d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * chroma-subsampled planar or semiplanar buffer (but not fully interleaved),
571d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * with 8 bits per color sample.</p>
581d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
591d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>Images in this format are always represented by three separate buffers
601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * of data, one for each color plane. Additional information always
611d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * accompanies the buffers, describing the row stride and the pixel stride
621d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * for each plane.</p>
631d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
641d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The order of planes is guaranteed such that plane #0 is always Y, plane #1 is always
651d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * U (Cb), and plane #2 is always V (Cr).</p>
661d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
671d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The Y-plane is guaranteed not to be interleaved with the U/V planes
681d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * (in particular, pixel stride is always 1 in {@link AImage_getPlanePixelStride}).</p>
691d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
701d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The U/V planes are guaranteed to have the same row stride and pixel stride, that is, the
711d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * return value of {@link AImage_getPlaneRowStride} for the U/V plane are guaranteed to be the
721d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * same, and the return value of {@link AImage_getPlanePixelStride} for the U/V plane are also
731d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * guaranteed to be the same.</p>
741d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
751d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>For example, the {@link AImage} object can provide data
761d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * in this format from a {@link ACameraDevice} through an {@link AImageReader} object.</p>
771d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
781d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>This format is always supported as an output format for the android Camera2 NDK API.</p>
791d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
801d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see AImage
811d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see AImageReader
821d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see ACameraDevice
831d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
84c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_YUV_420_888       = 0x23,
851d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
861d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
871d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Compressed JPEG format.
881d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
891d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>This format is always supported as an output format for the android Camera2 NDK API.</p>
901d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
91c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_JPEG              = 0x100,
921d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
931d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
941d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * 16 bits per pixel raw camera sensor image format, usually representing a single-channel
951d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Bayer-mosaic image.
961d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
971d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The layout of the color mosaic, the maximum and minimum encoding
981d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * values of the raw pixel data, the color space of the image, and all other
991d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * needed information to interpret a raw sensor image must be queried from
1001d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * the {@link ACameraDevice} which produced the image.</p>
1011d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
102c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_RAW16             = 0x20,
1031d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
1041d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
1051d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Private raw camera sensor image format, a single channel image with implementation depedent
1061d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * pixel layout.
1071d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1081d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>AIMAGE_FORMAT_RAW_PRIVATE is a format for unprocessed raw image buffers coming from an
1091d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * image sensor. The actual structure of buffers of this format is implementation-dependent.</p>
1101d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1111d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
112c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_RAW_PRIVATE       = 0x24,
1131d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
1141d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
1151d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Android 10-bit raw format.
1161d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
1171d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
1181d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * This is a single-plane, 10-bit per pixel, densely packed (in each row),
1191d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * unprocessed format, usually representing raw Bayer-pattern images coming
1201d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * from an image sensor.
1211d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
1221d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
1231d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * In an image buffer with this format, starting from the first pixel of
1241d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * each row, each 4 consecutive pixels are packed into 5 bytes (40 bits).
1251d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Each one of the first 4 bytes contains the top 8 bits of each pixel, The
1261d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * fifth byte contains the 2 least significant bits of the 4 pixels, the
1271d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * exact layout data for each 4 consecutive pixels is illustrated below
1281d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * (Pi[j] stands for the jth bit of the ith pixel):
1291d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
1301d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <table>
1311d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
1321d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center"></th>
1331d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 7</th>
1341d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 6</th>
1351d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 5</th>
1361d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 4</th>
1371d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 3</th>
1381d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 2</th>
1391d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 1</th>
1401d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 0</th>
1411d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
1421d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
1431d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 0:</td>
1441d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[9]</td>
1451d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[8]</td>
1461d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[7]</td>
1471d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[6]</td>
1481d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[5]</td>
1491d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[4]</td>
1501d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[3]</td>
1511d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[2]</td>
1521d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
1531d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
1541d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 1:</td>
1551d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[9]</td>
1561d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[8]</td>
1571d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[7]</td>
1581d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[6]</td>
1591d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[5]</td>
1601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[4]</td>
1611d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[3]</td>
1621d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[2]</td>
1631d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
1641d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
1651d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 2:</td>
1661d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[9]</td>
1671d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[8]</td>
1681d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[7]</td>
1691d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[6]</td>
1701d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[5]</td>
1711d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[4]</td>
1721d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[3]</td>
1731d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[2]</td>
1741d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
1751d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
1761d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 3:</td>
1771d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[9]</td>
1781d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[8]</td>
1791d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[7]</td>
1801d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[6]</td>
1811d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[5]</td>
1821d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[4]</td>
1831d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[3]</td>
1841d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[2]</td>
1851d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
1861d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
1871d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 4:</td>
1881d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[1]</td>
1891d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P3[0]</td>
1901d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[1]</td>
1911d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P2[0]</td>
1921d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[1]</td>
1931d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[0]</td>
1941d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[1]</td>
1951d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[0]</td>
1961d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
1971d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </table>
1981d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
1991d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * This format assumes
2001d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <ul>
2011d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>a width multiple of 4 pixels</li>
2021d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>an even height</li>
2031d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </ul>
2041d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
2051d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
2061d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <pre>size = row stride * height</pre> where the row stride is in <em>bytes</em>,
2071d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * not pixels.
2081d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
2091d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
2101d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Since this is a densely packed format, the pixel stride is always 0. The
2111d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * application must use the pixel data layout defined in above table to
2121d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * access each row data. When row stride is equal to (width * (10 / 8)), there
2131d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * will be no padding bytes at the end of each row, the entire image data is
2141d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * densely packed. When stride is larger than (width * (10 / 8)), padding
2151d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * bytes will be present at the end of each row.
2161d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
2171d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
2181d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * For example, the {@link AImage} object can provide data in this format from a
2191d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * {@link ACameraDevice} (if supported) through a {@link AImageReader} object.
2201d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * The number of planes returned by {@link AImage_getNumberOfPlanes} will always be 1.
2211d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * The pixel stride is undefined ({@link AImage_getPlanePixelStride} will return
2221d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * {@link AMEDIA_ERROR_UNSUPPORTED}), and the {@link AImage_getPlaneRowStride} described the
2231d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * vertical neighboring pixel distance (in bytes) between adjacent rows.
2241d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
2251d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
2261d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see AImage
2271d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see AImageReader
2281d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see ACameraDevice
2291d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
230c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_RAW10             = 0x25,
2311d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
2321d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
2331d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Android 12-bit raw format.
2341d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
2351d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
2361d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * This is a single-plane, 12-bit per pixel, densely packed (in each row),
2371d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * unprocessed format, usually representing raw Bayer-pattern images coming
2381d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * from an image sensor.
2391d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
2401d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
2411d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * In an image buffer with this format, starting from the first pixel of each
2421d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first
2431d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * and second byte contains the top 8 bits of first and second pixel. The third
2441d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * byte contains the 4 least significant bits of the two pixels, the exact layout
2451d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * data for each two consecutive pixels is illustrated below (Pi[j] stands for
2461d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * the jth bit of the ith pixel):
2471d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
2481d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <table>
2491d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
2501d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center"></th>
2511d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 7</th>
2521d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 6</th>
2531d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 5</th>
2541d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 4</th>
2551d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 3</th>
2561d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 2</th>
2571d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 1</th>
2581d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <th align="center">bit 0</th>
2591d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
2601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
2611d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 0:</td>
2621d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[11]</td>
2631d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[10]</td>
2641d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 9]</td>
2651d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 8]</td>
2661d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 7]</td>
2671d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 6]</td>
2681d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 5]</td>
2691d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 4]</td>
2701d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
2711d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
2721d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 1:</td>
2731d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[11]</td>
2741d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[10]</td>
2751d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 9]</td>
2761d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 8]</td>
2771d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 7]</td>
2781d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 6]</td>
2791d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 5]</td>
2801d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 4]</td>
2811d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
2821d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <tr>
2831d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">Byte 2:</td>
2841d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 3]</td>
2851d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 2]</td>
2861d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 1]</td>
2871d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P1[ 0]</td>
2881d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 3]</td>
2891d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 2]</td>
2901d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 1]</td>
2911d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <td align="center">P0[ 0]</td>
2921d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </tr>
2931d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </table>
2941d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
2951d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * This format assumes
2961d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <ul>
2971d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>a width multiple of 4 pixels</li>
2981d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>an even height</li>
2991d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </ul>
3001d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
3011d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3021d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <pre>size = row stride * height</pre> where the row stride is in <em>bytes</em>,
3031d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * not pixels.
3041d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3051d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
3061d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Since this is a densely packed format, the pixel stride is always 0. The
3071d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * application must use the pixel data layout defined in above table to
3081d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * access each row data. When row stride is equal to (width * (12 / 8)), there
3091d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * will be no padding bytes at the end of each row, the entire image data is
3101d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * densely packed. When stride is larger than (width * (12 / 8)), padding
3111d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * bytes will be present at the end of each row.
3121d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
3131d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>
3141d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * For example, the {@link AImage} object can provide data in this format from a
3151d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * {@link ACameraDevice} (if supported) through a {@link AImageReader} object.
3161d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * The number of planes returned by {@link AImage_getNumberOfPlanes} will always be 1.
3171d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * The pixel stride is undefined ({@link AImage_getPlanePixelStride} will return
3181d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * {@link AMEDIA_ERROR_UNSUPPORTED}), and the {@link AImage_getPlaneRowStride} described the
3191d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * vertical neighboring pixel distance (in bytes) between adjacent rows.
3201d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
3211d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3221d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see AImage
3231d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see AImageReader
3241d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * @see ACameraDevice
3251d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
326c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_RAW12             = 0x26,
3271d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
3281d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
3291d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Android dense depth image format.
3301d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3311d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>Each pixel is 16 bits, representing a depth ranging measurement from a depth camera or
3321d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * similar sensor. The 16-bit sample consists of a confidence value and the actual ranging
3331d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * measurement.</p>
3341d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3351d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The confidence value is an estimate of correctness for this sample.  It is encoded in the
3361d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * 3 most significant bits of the sample, with a value of 0 representing 100% confidence, a
3371d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * value of 1 representing 0% confidence, a value of 2 representing 1/7, a value of 3
3381d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * representing 2/7, and so on.</p>
3391d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3401d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>As an example, the following sample extracts the range and confidence from the first pixel
3411d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * of a DEPTH16-format {@link AImage}, and converts the confidence to a floating-point value
3421d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * between 0 and 1.f inclusive, with 1.f representing maximum confidence:
3431d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3441d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <pre>
3451d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    uint16_t* data;
3461d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    int dataLength;
3471d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    AImage_getPlaneData(image, 0, (uint8_t**)&data, &dataLength);
3481d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    uint16_t depthSample = data[0];
3491d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    uint16_t depthRange = (depthSample & 0x1FFF);
3501d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    uint16_t depthConfidence = ((depthSample >> 13) & 0x7);
3511d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    float depthPercentage = depthConfidence == 0 ? 1.f : (depthConfidence - 1) / 7.f;
3521d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </pre>
3531d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
3541d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3551d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>This format assumes
3561d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <ul>
3571d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>an even width</li>
3581d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>an even height</li>
3591d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <li>a horizontal stride multiple of 16 pixels</li>
3601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </ul>
3611d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </p>
3621d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3631d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <pre> y_size = stride * height </pre>
3641d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3651d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * When produced by a camera, the units for the range are millimeters.
3661d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
367c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_DEPTH16           = 0x44363159,
3681d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
3691d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
3701d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Android sparse depth point cloud format.
3711d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3721d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>A variable-length list of 3D points plus a confidence value, with each point represented
3731d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * by four floats; first the X, Y, Z position coordinates, and then the confidence value.</p>
3741d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3751d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The number of points is ((size of the buffer in bytes) / 16).
3761d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3771d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>The coordinate system and units of the position values depend on the source of the point
3781d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * cloud data. The confidence value is between 0.f and 1.f, inclusive, with 0 representing 0%
3791d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * confidence and 1.f representing 100% confidence in the measured position values.</p>
3801d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3811d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>As an example, the following code extracts the first depth point in a DEPTH_POINT_CLOUD
3821d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * format {@link AImage}:
3831d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <pre>
3841d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    float* data;
3851d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    int dataLength;
3861d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    AImage_getPlaneData(image, 0, (uint8_t**)&data, &dataLength);
3871d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    float x = data[0];
3881d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    float y = data[1];
3891d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    float z = data[2];
3901d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *    float confidence = data[3];
3911d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * </pre>
3921d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3931d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
3943e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh    AIMAGE_FORMAT_DEPTH_POINT_CLOUD = 0x101,
3951d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh
3961d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    /**
3971d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * Android private opaque image format.
3981d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     *
3991d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     * <p>This format is not currently supported by {@link AImageReader}.</p>
4001d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh     */
4011d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh    AIMAGE_FORMAT_PRIVATE           = 0x22
402c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh};
403c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
4041d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
4051d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Data type describing an cropped rectangle returned by {@link AImage_getCropRect}.
4061d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4071d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>Note that the right and bottom coordinates are exclusive, so the width of the rectangle is
4081d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * (right - left) and the height of the rectangle is (bottom - top).</p>
4091d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
410c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehtypedef struct AImageCropRect {
411c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    int32_t left;
412c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    int32_t top;
413c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    int32_t right;
414c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    int32_t bottom;
415c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh} AImageCropRect;
416c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
4171d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
4181d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Return the image back the the system and delete the AImage object from memory.
4191d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4201d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>Do NOT use the image pointer after this method returns.
4211d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Note that if the parent {@link AImageReader} is closed, all the {@link AImage} objects acquired
4221d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * from the parent reader will be returned to system. All AImage_* methods except this method will
4231d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * return {@link AMEDIA_ERROR_INVALID_OBJECT}. Application still needs to call this method on those
4241d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * {@link AImage} objects to fully delete the {@link AImage} object from memory.</p>
4251d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4261d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image The {@link AImage} to be deleted.
4271d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
428c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehvoid AImage_delete(AImage* image);
429c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
4301d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
4311d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the width of the input {@link AImage}.
4321d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4331d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
4341d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param width the width of the image will be filled here if the method call succeeeds.
4351d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4361d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
4371d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
4381d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or width is NULL.</li>
4391d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
4401d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
4411d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
442c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getWidth(const AImage* image, /*out*/int32_t* width);
443c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
4441d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
4451d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the height of the input {@link AImage}.
4461d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4471d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
4481d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param height the height of the image will be filled here if the method call succeeeds.
4491d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4501d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
4511d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
4521d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or height is NULL.</li>
4531d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
4541d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
4551d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
456c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getHeight(const AImage* image, /*out*/int32_t* height);
457c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
4581d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
4591d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the format of the input {@link AImage}.
4601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4611d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>The format value will be one of AIMAGE_FORMAT_* enum value.</p>
4621d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4631d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
4641d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param format the format of the image will be filled here if the method call succeeeds.
4651d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4661d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
4671d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
4681d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or format is NULL.</li>
4691d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
4701d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
4711d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
472c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getFormat(const AImage* image, /*out*/int32_t* format);
473c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
4741d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
4751d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the cropped rectangle of the input {@link AImage}.
4761d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4771d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>The crop rectangle specifies the region of valid pixels in the image, using coordinates in the
4781d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * largest-resolution plane.</p>
4791d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4801d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
4811d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param rect the cropped rectangle of the image will be filled here if the method call succeeeds.
4821d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4831d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
4841d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
4851d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or rect is NULL.</li>
4861d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
4871d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
4881d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
489c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getCropRect(const AImage* image, /*out*/AImageCropRect* rect);
490c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
4911d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
4921d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the timestamp of the input {@link AImage}.
4931d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
4941d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>
4951d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * The timestamp is measured in nanoseconds, and is normally monotonically increasing. The
4961d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * timestamps for the images from different sources may have different timebases therefore may not
4971d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * be comparable. The specific meaning and timebase of the timestamp depend on the source providing
4981d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * images. For images generated by camera, the timestamp value will match
4991d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * {@link ACAMERA_SENSOR_TIMESTAMP} of the {@link ACameraMetadata} in
5001d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * {@link ACameraCaptureSession_captureCallbacks#onCaptureStarted} and
5011d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * {@link ACameraCaptureSession_captureCallbacks#onCaptureCompleted} callback.
5021d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * </p>
5031d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5041d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
5051d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param timestampNs the timestamp of the image will be filled here if the method call succeeeds.
5061d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5071d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
5081d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
5091d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or timestampNs is NULL.</li>
5101d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
5111d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
5121d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
513c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getTimestamp(const AImage* image, /*out*/int64_t* timestampNs);
514c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
5151d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
5161d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the number of planes of the input {@link AImage}.
5171d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5181d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>The number of plane of an {@link AImage} is determined by its format, which can be queried by
5191d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * {@link AImage_getFormat} method.</p>
5201d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5211d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
5221d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param numPlanes the number of planes of the image will be filled here if the method call
5231d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         succeeeds.
5241d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5251d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
5261d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
5271d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or numPlanes is NULL.</li>
5281d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
5291d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
5301d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
531c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getNumberOfPlanes(const AImage* image, /*out*/int32_t* numPlanes);
532c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
5331d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
5341d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the pixel stride of the input {@link AImage}.
5351d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5361d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>This is the distance between two consecutive pixel values in a row of pixels. It may be
5371d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * larger than the size of a single pixel to account for interleaved image data or padded formats.
5381d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Note that pixel stride is undefined for some formats such as {@link AIMAGE_FORMAT_RAW_PRIVATE},
5391d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * and calling this method on images of these formats will cause {@link AMEDIA_ERROR_UNSUPPORTED}
5401d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * being returned.
5411d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * For formats where pixel stride is well defined, the pixel stride is always greater than 0.</p>
5421d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5431d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
5441d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param planeIdx the index of the plane. Must be less than the number of planes of input image.
5451d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param pixelStride the pixel stride of the image will be filled here if the method call succeeeds.
5461d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5471d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
5481d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
5491d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or pixelStride is NULL, or planeIdx
5501d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 is out of the range of [0, numOfPlanes - 1].</li>
5511d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_UNSUPPORTED} if pixel stride is undefined for the format of input
5521d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image.</li>
5531d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
5541d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
5551d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
556c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getPlanePixelStride(
557c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh        const AImage* image, int planeIdx, /*out*/int32_t* pixelStride);
558c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
5591d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
5601d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Query the row stride of the input {@link AImage}.
5611d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5621d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>This is the distance between the start of two consecutive rows of pixels in the image. Note
5631d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * that row stried is undefined for some formats such as {@link AIMAGE_FORMAT_RAW_PRIVATE}, and
5641d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * calling this method on images of these formats will cause {@link AMEDIA_ERROR_UNSUPPORTED}
5651d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * being returned.
5661d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * For formats where row stride is well defined, the row stride is always greater than 0.</p>
5671d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5681d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
5691d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param planeIdx the index of the plane. Must be less than the number of planes of input image.
5701d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param rowStride the row stride of the image will be filled here if the method call succeeeds.
5711d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5721d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
5731d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
5741d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or rowStride is NULL, or planeIdx
5751d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 is out of the range of [0, numOfPlanes - 1].</li>
5761d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_UNSUPPORTED} if row stride is undefined for the format of input
5771d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image.</li>
5781d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
5791d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
5801d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
581c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getPlaneRowStride(
582c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh        const AImage* image, int planeIdx, /*out*/int32_t* rowStride);
583c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
5841d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh/**
5851d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * Get the data pointer of the input image for direct application access.
5861d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5871d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * <p>Note that once the {@link AImage} or the parent {@link AImageReader} is deleted, the data
5881d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * pointer from previous AImage_getPlaneData call becomes invalid. Do NOT use it after the
5891d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * {@link AImage} or the parent {@link AImageReader} is deleted.</p>
5901d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5911d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param image the {@link AImage} of interest.
5921d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param planeIdx the index of the plane. Must be less than the number of planes of input image.
5931d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param data the data pointer of the image will be filled here if the method call succeeeds.
5941d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @param dataLength the valid length of data will be filled here if the method call succeeeds.
5951d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *
5961d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh * @return <ul>
5971d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_OK} if the method call succeeds.</li>
5981d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image, data or dataLength is NULL, or
5991d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 planeIdx is out of the range of [0, numOfPlanes - 1].</li>
6001d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *         <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
6011d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh *                 image has been deleted.</li></ul>
6021d0955cb5257a59f0ae435fefe26c05af4f4fbb6Yin-Chia Yeh */
603c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getPlaneData(
604c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh        const AImage* image, int planeIdx,
605c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh        /*out*/uint8_t** data, /*out*/int* dataLength);
606c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
607c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#ifdef __cplusplus
608c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh} // extern "C"
609c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#endif
610c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
611c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#endif //_NDK_IMAGE_H
6123e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh
6133e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/** @} */
614