NdkImage.h revision c360382bf257d815b2a411152485d3c3b37a9f46
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
17c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh/*
18c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * This file defines an NDK API.
19c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Do not remove methods.
20c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Do not change method signatures.
21c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Do not change the value of constants.
22c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Do not change the size of any of the classes defined in here.
23c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Do not reference types that are not part of the NDK.
24c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh * Do not #include files that aren't part of the NDK.
25c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh */
26c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
27c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#ifndef _NDK_IMAGE_H
28c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#define _NDK_IMAGE_H
29c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
30c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#include "NdkMediaError.h"
31c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
32c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#ifdef __cplusplus
33c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehextern "C" {
34c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#endif
35c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
36c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehtypedef struct AImage AImage;
37c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
38c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// Formats not listed here will not be supported by AImageReader
39c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehenum {
40c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_YUV_420_888       = 0x23,
41c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_JPEG              = 0x100,
42c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_RAW16             = 0x20,
43c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_RAW_PRIVATE       = 0x24,
44c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_RAW10             = 0x25,
45c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_RAW12             = 0x26,
46c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_DEPTH16           = 0x44363159,
47c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    AIMAGE_FORMAT_DEPTH_POINT_CLOUD = 0x101
48c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh};
49c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
50c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehtypedef struct AImageCropRect {
51c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    int32_t left;
52c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    int32_t top;
53c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    int32_t right;
54c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh    int32_t bottom;
55c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh} AImageCropRect;
56c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
57c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// Return the image back to system and delete the AImage from memory
58c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// Do NOT use `image` after this call
59c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehvoid AImage_delete(AImage* image);
60c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
61c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
62c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getWidth(const AImage* image, /*out*/int32_t* width);
63c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
64c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
65c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getHeight(const AImage* image, /*out*/int32_t* height);
66c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
67c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
68c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getFormat(const AImage* image, /*out*/int32_t* format);
69c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
70c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
71c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getCropRect(const AImage* image, /*out*/AImageCropRect* rect);
72c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
73c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
74c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getTimestamp(const AImage* image, /*out*/int64_t* timestampNs);
75c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
76c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
77c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getNumberOfPlanes(const AImage* image, /*out*/int32_t* numPlanes);
78c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
79c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
80c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getPlanePixelStride(
81c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh        const AImage* image, int planeIdx, /*out*/int32_t* pixelStride);
82c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
83c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
84c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getPlaneRowStride(
85c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh        const AImage* image, int planeIdx, /*out*/int32_t* rowStride);
86c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
87c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
88c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// Note that once the AImage or the parent AImageReader is deleted, the `*data` returned from
89c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// previous AImage_getPlaneData call becomes dangling pointer. Do NOT use it after
90c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AImage or AImageReader is deleted
91c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getPlaneData(
92c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh        const AImage* image, int planeIdx,
93c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh        /*out*/uint8_t** data, /*out*/int* dataLength);
94c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
95c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#ifdef __cplusplus
96c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh} // extern "C"
97c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#endif
98c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh
99c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#endif //_NDK_IMAGE_H
100