blob: 5c922942480c5d9187e0931d12e9414be3537a2b [file] [log] [blame]
Yin-Chia Yehc3603822016-01-18 22:11:19 -08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * This file defines an NDK API.
19 * Do not remove methods.
20 * Do not change method signatures.
21 * Do not change the value of constants.
22 * Do not change the size of any of the classes defined in here.
23 * Do not reference types that are not part of the NDK.
24 * Do not #include files that aren't part of the NDK.
25 */
26
27#ifndef _NDK_IMAGE_H
28#define _NDK_IMAGE_H
29
30#include "NdkMediaError.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36typedef struct AImage AImage;
37
38// Formats not listed here will not be supported by AImageReader
39enum {
40 AIMAGE_FORMAT_YUV_420_888 = 0x23,
41 AIMAGE_FORMAT_JPEG = 0x100,
42 AIMAGE_FORMAT_RAW16 = 0x20,
43 AIMAGE_FORMAT_RAW_PRIVATE = 0x24,
44 AIMAGE_FORMAT_RAW10 = 0x25,
45 AIMAGE_FORMAT_RAW12 = 0x26,
46 AIMAGE_FORMAT_DEPTH16 = 0x44363159,
47 AIMAGE_FORMAT_DEPTH_POINT_CLOUD = 0x101
48};
49
50typedef struct AImageCropRect {
51 int32_t left;
52 int32_t top;
53 int32_t right;
54 int32_t bottom;
55} AImageCropRect;
56
57// Return the image back to system and delete the AImage from memory
58// Do NOT use `image` after this call
59void AImage_delete(AImage* image);
60
61// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
62media_status_t AImage_getWidth(const AImage* image, /*out*/int32_t* width);
63
64// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
65media_status_t AImage_getHeight(const AImage* image, /*out*/int32_t* height);
66
67// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
68media_status_t AImage_getFormat(const AImage* image, /*out*/int32_t* format);
69
70// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
71media_status_t AImage_getCropRect(const AImage* image, /*out*/AImageCropRect* rect);
72
73// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
74media_status_t AImage_getTimestamp(const AImage* image, /*out*/int64_t* timestampNs);
75
76// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
77media_status_t AImage_getNumberOfPlanes(const AImage* image, /*out*/int32_t* numPlanes);
78
79// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
80media_status_t AImage_getPlanePixelStride(
81 const AImage* image, int planeIdx, /*out*/int32_t* pixelStride);
82
83// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
84media_status_t AImage_getPlaneRowStride(
85 const AImage* image, int planeIdx, /*out*/int32_t* rowStride);
86
87// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
88// Note that once the AImage or the parent AImageReader is deleted, the `*data` returned from
89// previous AImage_getPlaneData call becomes dangling pointer. Do NOT use it after
90// AImage or AImageReader is deleted
91media_status_t AImage_getPlaneData(
92 const AImage* image, int planeIdx,
93 /*out*/uint8_t** data, /*out*/int* dataLength);
94
95#ifdef __cplusplus
96} // extern "C"
97#endif
98
99#endif //_NDK_IMAGE_H