From ad25a8568768a11cce8fa248ead577abab883bb0 Mon Sep 17 00:00:00 2001 From: caochuan Date: Mon, 20 Jan 2025 13:52:59 +0800 Subject: [PATCH 1/2] Add DMA ndk api. --- .../include/image/image_common.h | 25 +++++++++ .../include/image/image_source_native.h | 51 ++++++++++++++++++- .../image_framework/libimage_source.ndk.json | 4 ++ 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/multimedia/image_framework/include/image/image_common.h b/multimedia/image_framework/include/image/image_common.h index a4f599be8..8816c6c80 100644 --- a/multimedia/image_framework/include/image/image_common.h +++ b/multimedia/image_framework/include/image/image_common.h @@ -184,8 +184,33 @@ typedef enum { IMAGE_UNKNOWN_ERROR = 7600901, /** decode data source exception */ IMAGE_BAD_SOURCE = 7700101, + /** + * @error unsupported mime type + * @since 16 + */ + IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE = 7700102, + /** + * @error image to large + * @since 16 + */ + IMAGE_SOURCE_TOO_LARGE = 7700103, + /** + * @error unsupported allocator type, e.g., use share memory to decode a HDR image as only + * DMA supported hdr metadata. + * @since 16 + */ + IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE = 7700201, + /* @error unsupported options, e.g, cannot convert image into desired pixel format. + * @since 16 + */ + IMAGE_SOURCE_UNSUPPORTED_OPTIONS = 7700203, /** decode failed */ IMAGE_DECODE_FAILED = 7700301, + /** + * @error memory allocation failed + * @since 16 + */ + IMAGE_SOURCE_ALLOC_FAILED = 7700302, /** encode failed */ IMAGE_ENCODE_FAILED = 7800301, } Image_ErrorCode; diff --git a/multimedia/image_framework/include/image/image_source_native.h b/multimedia/image_framework/include/image/image_source_native.h index 7e54b94ef..8c40a0413 100644 --- a/multimedia/image_framework/include/image/image_source_native.h +++ b/multimedia/image_framework/include/image/image_source_native.h @@ -14,7 +14,7 @@ */ /** - * @addtogroup image + * @addtogroup ImageSourceNative * @{ * * @brief Provides APIs for access to the image interface. @@ -98,6 +98,26 @@ typedef enum { IMAGE_DYNAMIC_RANGE_HDR = 2, } IMAGE_DYNAMIC_RANGE; +/** + * @brief Type of allocator used to allocate memory of a PixelMap.. + * + * @since 16 + */ +typedef enum { + /* + * The system determines which memory to use to create the PixelMap. + */ + IMAGE_ALLOCATOR_TYPE_AUTO = 0, + /* + * Use DMA buffer to create the PixelMap. + */ + IMAGE_ALLOCATOR_TYPE_DMA = 1, + /* + * Use share memory to create the PixelMap. + */ + IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY = 2, +} IMAGE_ALLOCATOR_TYPE; + /** * @brief Create a pointer for OH_ImageSource_Info struct. * @@ -360,6 +380,35 @@ Image_ErrorCode OH_ImageSourceNative_CreateFromRawFile(RawFileDescriptor *rawFil Image_ErrorCode OH_ImageSourceNative_CreatePixelmap(OH_ImageSourceNative *source, OH_DecodingOptions *options, OH_PixelmapNative **pixelmap); +/** + * @brief Creates a PixelMap based on decoding parameters {@link OH_DecodingOptions}, the memory type used by the + * PixelMap can be specified by allocatorType {@link IMAGE_ALLOCATOR_TYPE}. By default, the system selects the memory + * type based on the image type, image size, platform capability, etc. When processing the PixelMap returned by this + * interface, please always consider the impact of stride. + * + * @param source Image Source. + * @param options Decoding parameters, such as the size, pixel format, and color space of the pixelMap. + * For details, see {@link OH_DecodingOptions}. + * @param allocator Indicate which memory type will be used by the returned PixelMap. + * @param pixelmap Decoded Pixelmap object. + * @return Error code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} source is nullptr, or picture is nullptr. + * {@link IMAGE_BAD_SOURCE} data source exception. + * {@link IMAGE_SOURCE_UNSUPPORTED_MIMETYPE} unsupported mime type. + * {@link IMAGE_SOURCE_TOO_LARGE} image to large. + * {@link IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE} unsupported allocator type, + * e.g., use share memory to decode a HDR image as only DMA supported hdr metadata. + * {@link IMAGE_SOURCE_UNSUPPORTED_OPTIONS} unsupported options, + * e.g, cannot convert image into desired pixel format. + * {@link IMAGE_DECODE_FAILED} decode failed. + * {@link IMAGE_SOURCE_ALLOC_FAILED} memory allocation failed. + * @since 16 + */ +Image_ErrorCode OH_ImageSourceNative_CreatePixelmapUsingAllocator(OH_ImageSourceNative *source, + OH_DecodingOptions *options, IMAGE_ALLOCATOR_TYPE allocator, OH_PixelmapNative **pixelmap); + + /** * @brief Decodes an void pointer * the Pixelmap objects at the C++ native layer diff --git a/multimedia/image_framework/libimage_source.ndk.json b/multimedia/image_framework/libimage_source.ndk.json index 37312763e..fd5d4e30a 100644 --- a/multimedia/image_framework/libimage_source.ndk.json +++ b/multimedia/image_framework/libimage_source.ndk.json @@ -95,6 +95,10 @@ "first_introduced": "12", "name": "OH_ImageSourceNative_CreatePixelmap" }, + { + "first_introduced": "16", + "name": "OH_ImageSourceNative_CreatePixelmapUsingAllocator" + }, { "first_introduced": "12", "name": "OH_ImageSourceNative_CreatePixelmapList" -- Gitee From 2c985d05f02ed92073552893672c9f8a835fe86e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E6=98=9F=E5=AE=87?= Date: Mon, 17 Feb 2025 07:28:50 +0000 Subject: [PATCH 2/2] update multimedia/image_framework/include/image/image_common.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 姚星宇 --- .../image_framework/include/image/image_common.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/multimedia/image_framework/include/image/image_common.h b/multimedia/image_framework/include/image/image_common.h index 8816c6c80..9edfea083 100644 --- a/multimedia/image_framework/include/image/image_common.h +++ b/multimedia/image_framework/include/image/image_common.h @@ -186,29 +186,29 @@ typedef enum { IMAGE_BAD_SOURCE = 7700101, /** * @error unsupported mime type - * @since 16 + * @since 15 */ IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE = 7700102, /** * @error image to large - * @since 16 + * @since 15 */ IMAGE_SOURCE_TOO_LARGE = 7700103, /** * @error unsupported allocator type, e.g., use share memory to decode a HDR image as only * DMA supported hdr metadata. - * @since 16 + * @since 15 */ IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE = 7700201, /* @error unsupported options, e.g, cannot convert image into desired pixel format. - * @since 16 + * @since 15 */ IMAGE_SOURCE_UNSUPPORTED_OPTIONS = 7700203, /** decode failed */ IMAGE_DECODE_FAILED = 7700301, /** * @error memory allocation failed - * @since 16 + * @since 15 */ IMAGE_SOURCE_ALLOC_FAILED = 7700302, /** encode failed */ -- Gitee