b4415e2d创建于 2025年12月20日历史提交

image_processing.h

Overview

The file declares the image processing functions. It provides capabilities such as Color Space Conversion (CSC), metadata generation, and image scaling.

File to include: <multimedia/video_processing_engine/image_processing.h>

Library: libimage_processing.so

System capability: SystemCapability.Multimedia.VideoProcessingEngine

Since: 13

Related module: ImageProcessing

Summary

Functions

Name Description
ImageProcessing_ErrorCode OH_ImageProcessing_InitializeEnvironment(void) Initializes the global environment of the image processing module.
This function is optional. Generally, this function is called when the main process is started. It is used to initialize the global environment of the image processing module and reduce the time consumed by OH_ImageProcessing_Create. It must be used in pair with OH_ImageProcessing_DeinitializeEnvironment, which is used to deinitialize the global environment. This function can be used to check whether the GPU works properly.
ImageProcessing_ErrorCode OH_ImageProcessing_DeinitializeEnvironment(void) Deinitializes the global environment of the image processing module.
This function must be called after OH_ImageProcessing_InitializeEnvironment is called. Generally, this function is called when the main process is about to exit. Do not call this function when an image processing instance exists or when OH_ImageProcessing_InitializeEnvironment is not called.
bool OH_ImageProcessing_IsColorSpaceConversionSupported(const ImageProcessing_ColorSpaceInfo* sourceImageInfo, const ImageProcessing_ColorSpaceInfo* destinationImageInfo) Checks whether CSC is supported for an image.
bool OH_ImageProcessing_IsCompositionSupported(const ImageProcessing_ColorSpaceInfo* sourceImageInfo, const ImageProcessing_ColorSpaceInfo* sourceGainmapInfo,const ImageProcessing_ColorSpaceInfo* destinationImageInfo) Checks whether a dual-layer HDR image can be converted into a single-layer HDR image.
bool OH_ImageProcessing_IsDecompositionSupported(const ImageProcessing_ColorSpaceInfo* sourceImageInfo, const ImageProcessing_ColorSpaceInfo* destinationImageInfo, const ImageProcessing_ColorSpaceInfo* destinationGainmapInfo) Checks whether a single-layer HDR image can be converted into a dual-layer HDR image.
bool OH_ImageProcessing_IsMetadataGenerationSupported(const ImageProcessing_ColorSpaceInfo* sourceImageInfo) Checks whether metadata generation is supported for an image.
ImageProcessing_ErrorCode OH_ImageProcessing_Create(OH_ImageProcessing** imageProcessor, int32_t type) Creates an image processing instance.
ImageProcessing_ErrorCode OH_ImageProcessing_Destroy(OH_ImageProcessing* imageProcessor) Destroys an image processing instance.
ImageProcessing_ErrorCode OH_ImageProcessing_SetParameter(OH_ImageProcessing* imageProcessor, const OH_AVFormat* parameter) Sets a parameter for the image processing module. This function sets the parameter by key.
ImageProcessing_ErrorCode OH_ImageProcessing_GetParameter(OH_ImageProcessing* imageProcessor, OH_AVFormat* parameter) Obtains a parameter of the image processing module. This function obtains the parameter by key.
ImageProcessing_ErrorCode OH_ImageProcessing_ConvertColorSpace(OH_ImageProcessing* imageProcessor, OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage) Converts the color space for a single-layer image. This function enables CSC from HDR images to SDR images, CSC from SDR images to HDR images, CSC from SDR images to SDR images, and CSC from HDR images to SDR images.
ImageProcessing_ErrorCode OH_ImageProcessing_Compose(OH_ImageProcessing* imageProcessor, OH_PixelmapNative* sourceImage, OH_PixelmapNative* sourceGainmap, OH_PixelmapNative* destinationImage) Converts a dual-layer HDR image into a single-layer HDR image. This function is used to generate an output image based on an input image and input gain map.
ImageProcessing_ErrorCode OH_ImageProcessing_Decompose(OH_ImageProcessing* imageProcessor, OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage, OH_PixelmapNative* destinationGainmap) Converts a single-layer HDR image into a double-layer HDR image. This function is used to generate an output image and output gain map based on an input image.
ImageProcessing_ErrorCode OH_ImageProcessing_GenerateMetadata(OH_ImageProcessing* imageProcessor, OH_PixelmapNative* sourceImage) Generates metadata for an HDR image.
ImageProcessing_ErrorCode OH_ImageProcessing_EnhanceDetail(OH_ImageProcessing* imageProcessor, OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage) Enhances the image definition and details. This function performs necessary scaling operations on the source image based on the preset sizes of the input and output images to generate the target image. It uses multiple scaling methods to balance performance and image quality.

Function Description

OH_ImageProcessing_InitializeEnvironment()

ImageProcessing_ErrorCode OH_ImageProcessing_InitializeEnvironment(void)

Description

Initializes the global environment of the image processing module.

This function is optional. Generally, this function is called when the main process is started. It is used to initialize the global environment of the image processing module and reduce the time consumed by OH_ImageProcessing_Create. It must be used in pair with OH_ImageProcessing_DeinitializeEnvironment, which is used to deinitialize the global environment. This function can be used to check whether the GPU works properly.

Since: 13

Returns

Type Description
ImageProcessing_ErrorCode IMAGE_PROCESSING_SUCCESS: The initialization is successful.
IMAGE_PROCESSING_ERROR_INITIALIZE_FAILED: The initialization fails.

OH_ImageProcessing_DeinitializeEnvironment()

ImageProcessing_ErrorCode OH_ImageProcessing_DeinitializeEnvironment(void)

Description

Deinitializes the global environment of the image processing module.

This function must be called after OH_ImageProcessing_InitializeEnvironment is called. Generally, this function is called when the main process is about to exit. Do not call this function when an image processing instance exists or when OH_ImageProcessing_InitializeEnvironment is not called.

Since: 13

Returns

Type Description
ImageProcessing_ErrorCode IMAGE_PROCESSING_SUCCESS: Deinitialization is successful.
IMAGE_PROCESSING_ERROR_OPERATION_NOT_PERMITTED: The image processing instance is not destroyed or OH_ImageProcessing_InitializeEnvironment is not called.

OH_ImageProcessing_IsColorSpaceConversionSupported()

bool OH_ImageProcessing_IsColorSpaceConversionSupported(const ImageProcessing_ColorSpaceInfo* sourceImageInfo,const ImageProcessing_ColorSpaceInfo* destinationImageInfo)

Description

Checks whether CSC is supported for an image.

Since: 13

Parameters

Name Description
const ImageProcessing_ColorSpaceInfo* sourceImageInfo Pointer to the color space information of the input image.
const ImageProcessing_ColorSpaceInfo* destinationImageInfo Pointer to the color space information of the output image.

Returns

Type Description
bool Check result for the support of CSC. true if supported, false otherwise.

OH_ImageProcessing_IsCompositionSupported()

bool OH_ImageProcessing_IsCompositionSupported(const ImageProcessing_ColorSpaceInfo* sourceImageInfo,const ImageProcessing_ColorSpaceInfo* sourceGainmapInfo,const ImageProcessing_ColorSpaceInfo* destinationImageInfo)

Description

Checks whether a dual-layer HDR image can be converted into a single-layer HDR image.

Since: 13

Parameters

Name Description
const ImageProcessing_ColorSpaceInfo* sourceImageInfo Pointer to the color space information of the input image.
const ImageProcessing_ColorSpaceInfo* sourceGainmapInfo Pointer to the color space information of the input gain map.
const ImageProcessing_ColorSpaceInfo* destinationImageInfo Pointer to the color space information of the output image.

Returns

Type Description
bool Check result for the support of a conversion from a dual-layer HDR image into a single-layer HDR image. true if supported, false otherwise.

OH_ImageProcessing_IsDecompositionSupported()

bool OH_ImageProcessing_IsDecompositionSupported(const ImageProcessing_ColorSpaceInfo* sourceImageInfo,const ImageProcessing_ColorSpaceInfo* destinationImageInfo,const ImageProcessing_ColorSpaceInfo* destinationGainmapInfo)

Description

Checks whether a single-layer HDR image can be converted into a dual-layer HDR image.

Since: 13

Parameters

Name Description
const ImageProcessing_ColorSpaceInfo* sourceImageInfo Pointer to the color space information of the input image.
const ImageProcessing_ColorSpaceInfo* destinationImageInfo Pointer to the color space information of the output image.
const ImageProcessing_ColorSpaceInfo* destinationGainmapInfo Pointer to the color space information of the output gain map.

Returns

Type Description
bool Check result for the support of a conversion from a single-layer HDR image into a dual-layer HDR image. true if supported, false otherwise.

OH_ImageProcessing_IsMetadataGenerationSupported()

bool OH_ImageProcessing_IsMetadataGenerationSupported(const ImageProcessing_ColorSpaceInfo* sourceImageInfo)

Description

Checks whether metadata generation is supported for an image.

Since: 13

Parameters

Name Description
const ImageProcessing_ColorSpaceInfo* sourceImageInfo Pointer to the color space information of the input image.

Returns

Type Description
bool Check result for the support of metadata generation. true if supported, false otherwise.

OH_ImageProcessing_Create()

ImageProcessing_ErrorCode OH_ImageProcessing_Create(OH_ImageProcessing** imageProcessor, int32_t type)

Description

Creates an image processing instance.

Since: 13

Parameters

Name Description
OH_ImageProcessing** imageProcessor Double pointer to the image processing instance created. The pointer *imageProcessor points to a new image processing object and must be a null pointer before being passed.
int32_t type Image processing type. The processing type cannot be changed after the instance is created.

Returns

Type Description
ImageProcessing_ErrorCode IMAGE_PROCESSING_SUCCESS: The instance is created successfully.
IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING: The specified image processing type is not supported, for example, if metadata generation is not supported.
IMAGE_PROCESSING_ERROR_CREATE_FAILED: The instance fails to be created.
IMAGE_PROCESSING_ERROR_INVALID_INSTANCE: The instance is null or the pointer to the instance is null.
IMAGE_PROCESSING_ERROR_INVALID_PARAMETER: The specified image processing type is invalid.

OH_ImageProcessing_Destroy()

ImageProcessing_ErrorCode OH_ImageProcessing_Destroy(OH_ImageProcessing* imageProcessor)

Description

Destroys an image processing instance.

Since: 13

Parameters

Name Description
OH_ImageProcessing* imageProcessor Pointer to an image processing instance. You are advised to set the pointer to a null pointer after the instance is destroyed.

Returns

Type Description
ImageProcessing_ErrorCode IMAGE_PROCESSING_SUCCESS: The instance is destroyed.
IMAGE_PROCESSING_ERROR_INVALID_INSTANCE: The instance is null or is not an image processing instance.

OH_ImageProcessing_SetParameter()

ImageProcessing_ErrorCode OH_ImageProcessing_SetParameter(OH_ImageProcessing* imageProcessor,const OH_AVFormat* parameter)

Description

Sets a parameter for the image processing module. This function sets the parameter by key.

Since: 13

Parameters

Name Description
OH_ImageProcessing* imageProcessor Pointer to an image processing instance.
const OH_AVFormat* parameter Pointer to the parameter.

Returns

Type Description
ImageProcessing_ErrorCode IMAGE_PROCESSING_SUCCESS: The operation is successful.
IMAGE_PROCESSING_ERROR_INVALID_INSTANCE: The instance is null or is not an image processing instance.
IMAGE_PROCESSING_ERROR_INVALID_PARAMETER: parameter is empty.
IMAGE_PROCESSING_ERROR_INVALID_VALUE: parameter is invalid, for example, if parameter contains an unsupported parameter key or value.
IMAGE_PROCESSING_ERROR_NO_MEMORY: Memory allocation fails.

OH_ImageProcessing_GetParameter()

ImageProcessing_ErrorCode OH_ImageProcessing_GetParameter(OH_ImageProcessing* imageProcessor,OH_AVFormat* parameter)

Description

Obtains a parameter of the image processing module. This function obtains the parameter by key.

Since: 13

Parameters

Name Description
OH_ImageProcessing* imageProcessor Pointer to an image processing instance.
OH_AVFormat* parameter Pointer to the parameter.

Returns

Type Description
ImageProcessing_ErrorCode IMAGE_PROCESSING_SUCCESS: The operation is successful.
IMAGE_PROCESSING_ERROR_INVALID_INSTANCE: The instance is null or is not an image processing instance.
IMAGE_PROCESSING_ERROR_INVALID_PARAMETER: parameter is empty.

OH_ImageProcessing_ConvertColorSpace()

ImageProcessing_ErrorCode OH_ImageProcessing_ConvertColorSpace(OH_ImageProcessing* imageProcessor,OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage)

Description

Converts the color space for a single-layer image. This function enables CSC from HDR images to SDR images, CSC from SDR images to HDR images, CSC from SDR images to SDR images, and CSC from HDR images to SDR images.

Since: 13

Parameters

Name Description
OH_ImageProcessing* imageProcessor Pointer to an image processing instance, which is created by IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION.
OH_PixelmapNative* sourceImage Pointer to the input image. The OH_PixelmapNative it points to must be allocated in DMA memory. For details, see PixelMap Memory Types.
OH_PixelmapNative* destinationImage Pointer to the output image. The OH_PixelmapNative it points to must be allocated in DMA memory. For details, see PixelMap Memory Types.

Returns

Type Description
ImageProcessing_ErrorCode IMAGE_PROCESSING_SUCCESS: Image processing is successful.
IMAGE_PROCESSING_ERROR_INVALID_INSTANCE: The instance is null or is not an image processing instance.
IMAGE_PROCESSING_ERROR_INVALID_PARAMETER: The image is empty.
IMAGE_PROCESSING_ERROR_INVALID_VALUE: An image property is invalid, for example, unsupported color space.
IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING: Image processing is not supported.
IMAGE_PROCESSING_ERROR_PROCESS_FAILED: An error occurs during image processing.
IMAGE_PROCESSING_ERROR_NO_MEMORY: Memory allocation fails.

OH_ImageProcessing_Compose()

ImageProcessing_ErrorCode OH_ImageProcessing_Compose(OH_ImageProcessing* imageProcessor,OH_PixelmapNative* sourceImage, OH_PixelmapNative* sourceGainmap, OH_PixelmapNative* destinationImage)

Description

Converts a dual-layer HDR image into a single-layer HDR image. This function is used to generate an output image based on an input image and input gain map.

Since: 13

Parameters

Name Description
OH_ImageProcessing* imageProcessor Pointer to an image processing instance, which is created by IMAGE_PROCESSING_TYPE_COMPOSITION.
OH_PixelmapNative* sourceImage Pointer to the input image. The OH_PixelmapNative it points to must be allocated in DMA memory. For details, see PixelMap Memory Types.
OH_PixelmapNative* sourceGainmap Pointer to the input gain map. The OH_PixelmapNative it points to must be allocated in DMA memory. For details, see PixelMap Memory Types.
OH_PixelmapNative* destinationImage Pointer to the output image. The OH_PixelmapNative it points to must be allocated in DMA memory. For details, see PixelMap Memory Types.

Returns

Type Description
ImageProcessing_ErrorCode IMAGE_PROCESSING_SUCCESS: Image processing is successful.
IMAGE_PROCESSING_ERROR_INVALID_INSTANCE: The instance is null or is not an image processing instance.
IMAGE_PROCESSING_ERROR_INVALID_PARAMETER: The image is empty.
IMAGE_PROCESSING_ERROR_INVALID_VALUE: An image property is invalid, for example, unsupported color space.
IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING: Image processing is not supported.
IMAGE_PROCESSING_ERROR_PROCESS_FAILED: An error occurs during image processing.
IMAGE_PROCESSING_ERROR_NO_MEMORY: Memory allocation fails.

OH_ImageProcessing_Decompose()

ImageProcessing_ErrorCode OH_ImageProcessing_Decompose(OH_ImageProcessing* imageProcessor,OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage, OH_PixelmapNative* destinationGainmap)

Description

Converts a single-layer HDR image into a double-layer HDR image. This function is used to generate an output image and output gain map based on an input image.

Since: 13

Parameters

Name Description
OH_ImageProcessing* imageProcessor Pointer to an image processing instance, which is created by IMAGE_PROCESSING_TYPE_DECOMPOSITION.
OH_PixelmapNative* sourceImage Pointer to the input image. The OH_PixelmapNative it points to must be allocated in DMA memory. For details, see PixelMap Memory Types.
OH_PixelmapNative* destinationImage Pointer to the output image. The OH_PixelmapNative it points to must be allocated in DMA memory. For details, see PixelMap Memory Types.
OH_PixelmapNative* destinationGainmap Pointer to the output gain map. The OH_PixelmapNative it points to must be allocated in DMA memory. For details, see PixelMap Memory Types.

Returns

Type Description
ImageProcessing_ErrorCode IMAGE_PROCESSING_SUCCESS: Image processing is successful.
IMAGE_PROCESSING_ERROR_INVALID_INSTANCE: The instance is null or is not an image processing instance.
IMAGE_PROCESSING_ERROR_INVALID_PARAMETER: The image is empty.
IMAGE_PROCESSING_ERROR_INVALID_VALUE: An image property is invalid, for example, unsupported color space.
IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING: Image processing is not supported.
IMAGE_PROCESSING_ERROR_PROCESS_FAILED: An error occurs during image processing.
IMAGE_PROCESSING_ERROR_NO_MEMORY: Memory allocation fails.

OH_ImageProcessing_GenerateMetadata()

ImageProcessing_ErrorCode OH_ImageProcessing_GenerateMetadata(OH_ImageProcessing* imageProcessor,OH_PixelmapNative* sourceImage)

Description

Generates metadata for an HDR image. This function is used to generate metadata for HDR images.

Since: 13

Parameters

Name Description
OH_ImageProcessing* imageProcessor Pointer to an image processing instance, which is created by IMAGE_PROCESSING_TYPE_METADATA_GENERATION.
OH_PixelmapNative* sourceImage Pointer to the input image. The OH_PixelmapNative it points to must be allocated in DMA memory. For details, see PixelMap Memory Types.

Returns

Type Description
ImageProcessing_ErrorCode IMAGE_PROCESSING_SUCCESS: Image processing is successful.
IMAGE_PROCESSING_ERROR_INVALID_INSTANCE: The instance is null or is not an image processing instance.
IMAGE_PROCESSING_ERROR_INVALID_PARAMETER: The image is empty.
IMAGE_PROCESSING_ERROR_INVALID_VALUE: An image property is invalid, for example, unsupported color space.
IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING: Image processing is not supported.
IMAGE_PROCESSING_ERROR_PROCESS_FAILED: An error occurs during image processing.
IMAGE_PROCESSING_ERROR_NO_MEMORY: Memory allocation fails.

OH_ImageProcessing_EnhanceDetail()

ImageProcessing_ErrorCode OH_ImageProcessing_EnhanceDetail(OH_ImageProcessing* imageProcessor,OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage)

Description

Enhances the image definition and details. This function performs necessary scaling operations on the source image based on the preset sizes of the input and output images to generate the target image. It uses multiple scaling methods to balance performance and image quality.

Since: 13

Parameters

Name Description
OH_ImageProcessing* imageProcessor Pointer to an image processing instance, which is created by IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER.
OH_PixelmapNative* sourceImage Pointer to the input image. The OH_PixelmapNative it points to must be allocated in DMA memory. For details, see PixelMap Memory Types.
OH_PixelmapNative* destinationImage Pointer to the output image. The OH_PixelmapNative it points to must be allocated in DMA memory. For details, see PixelMap Memory Types.

Returns

Type Description
ImageProcessing_ErrorCode IMAGE_PROCESSING_SUCCESS: Image processing is successful.
IMAGE_PROCESSING_ERROR_INVALID_INSTANCE: The instance is null or is not an image processing instance.
IMAGE_PROCESSING_ERROR_INVALID_PARAMETER: The image is empty.
IMAGE_PROCESSING_ERROR_INVALID_VALUE: An image property is invalid, for example, unsupported color space.
IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING: Image processing is not supported.
IMAGE_PROCESSING_ERROR_PROCESS_FAILED: An error occurs during image processing.
IMAGE_PROCESSING_ERROR_NO_MEMORY: Memory allocation fails.