NdkImage.h revision 3e49be17d8c8c53f50bb0d39affbbc36f6a12488
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 45c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehtypedef struct AImage AImage; 46c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 47c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// Formats not listed here will not be supported by AImageReader 48c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehenum { 49c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh AIMAGE_FORMAT_YUV_420_888 = 0x23, 50c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh AIMAGE_FORMAT_JPEG = 0x100, 51c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh AIMAGE_FORMAT_RAW16 = 0x20, 52c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh AIMAGE_FORMAT_RAW_PRIVATE = 0x24, 53c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh AIMAGE_FORMAT_RAW10 = 0x25, 54c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh AIMAGE_FORMAT_RAW12 = 0x26, 55c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh AIMAGE_FORMAT_DEPTH16 = 0x44363159, 563e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh AIMAGE_FORMAT_DEPTH_POINT_CLOUD = 0x101, 573e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh AIMAGE_FORMAT_PRIVATE = 0x22 ///> Not supported by AImageReader yet 58c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh}; 59c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 60c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehtypedef struct AImageCropRect { 61c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh int32_t left; 62c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh int32_t top; 63c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh int32_t right; 64c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh int32_t bottom; 65c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh} AImageCropRect; 66c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 67c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// Return the image back to system and delete the AImage from memory 68c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// Do NOT use `image` after this call 69c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehvoid AImage_delete(AImage* image); 70c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 71c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted 72c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getWidth(const AImage* image, /*out*/int32_t* width); 73c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 74c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted 75c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getHeight(const AImage* image, /*out*/int32_t* height); 76c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 77c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted 78c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getFormat(const AImage* image, /*out*/int32_t* format); 79c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 80c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted 81c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getCropRect(const AImage* image, /*out*/AImageCropRect* rect); 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_getTimestamp(const AImage* image, /*out*/int64_t* timestampNs); 85c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 86c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted 87c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getNumberOfPlanes(const AImage* image, /*out*/int32_t* numPlanes); 88c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 89c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted 90c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getPlanePixelStride( 91c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh const AImage* image, int planeIdx, /*out*/int32_t* pixelStride); 92c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 93c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted 94c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getPlaneRowStride( 95c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh const AImage* image, int planeIdx, /*out*/int32_t* rowStride); 96c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 97c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted 98c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// Note that once the AImage or the parent AImageReader is deleted, the `*data` returned from 99c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// previous AImage_getPlaneData call becomes dangling pointer. Do NOT use it after 100c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh// AImage or AImageReader is deleted 101c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yehmedia_status_t AImage_getPlaneData( 102c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh const AImage* image, int planeIdx, 103c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh /*out*/uint8_t** data, /*out*/int* dataLength); 104c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 105c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#ifdef __cplusplus 106c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh} // extern "C" 107c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#endif 108c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh 109c360382bf257d815b2a411152485d3c3b37a9f46Yin-Chia Yeh#endif //_NDK_IMAGE_H 1103e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh 1113e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/** @} */ 112