1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup ImageProcessing
18  * @{
19  *
20  * @brief Provide image processing including color space conversion and metadata generation.
21  *
22  * @since 13
23  */
24 
25 /**
26  * @file image_processing_types.h
27  *
28  * @brief Type definitions for image processing.
29  *
30  * @library libimage_processing.so
31  * @syscap SystemCapability.Multimedia.VideoProcessingEngine
32  * @kit ImageKit
33  * @since 13
34  */
35 
36 #ifndef VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_TYPES_H
37 #define VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_TYPES_H
38 
39 #include <stdint.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /**
46  * @brief Define the object for image processing.
47  *
48  * Define a null pointer of OH_ImageProcessing and call {@link OH_ImageProcessing_Create} to create an image processing
49  * instance. The pointer should be null before creating instance.
50  * User can create multiple image processing instances for different processing types.
51  *
52  * @since 13
53  */
54 typedef struct OH_ImageProcessing OH_ImageProcessing;
55 
56 /**
57  * @brief Forward declaration of OH_PixelmapNative.
58  *
59  * @since 13
60  */
61 typedef struct OH_PixelmapNative OH_PixelmapNative;
62 
63 /**
64  * @brief Forward declaration of OH_AVFormat.
65  *
66  * @since 13
67  */
68 typedef struct OH_AVFormat OH_AVFormat;
69 
70 /**
71  * @brief Used to create an image processing instance for color space conversion.
72  *
73  * Color space conversion includes the conversion of single-layer HDR images to SDR images, as well as
74  * the color space conversion of SDR images, and the conversion of SDR images to single-layer HDR images. Some
75  * capabilities are supported by vendor. Use {@link OH_ImageProcessing_IsColorSpaceConversionSupported} to query if
76  * the conversion is supported between single-layer images.
77  *
78  * @see OH_ImageProcessing_Create
79  * @since 13
80  */
81 extern const int32_t IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION;
82 
83 /**
84  * @brief Used to create an image processing instance for HDR image composition.
85  *
86  * HDR image compose includes the conversion from dual-layer HDR images to single-layer HDR images. Some
87  * capabilities are supported by vendor. Use {@link OH_ImageProcessing_IsCompositionSupported} to
88  * query if the composition is supported from dual-layer HDR image to single-layer HDR image.
89  *
90  * @see OH_ImageProcessing_Create
91  * @since 13
92  */
93 extern const int32_t IMAGE_PROCESSING_TYPE_COMPOSITION;
94 
95 /**
96  * @brief Used to create an image processing instance for HDR image decomposition.
97  *
98  * HDR image decompose includes the conversion from single-layer HDR images to dual-layer HDR images. Some
99  * capabilities are supported by vendor. Use {@link OH_ImageProcessing_IsDecompositionSupported} to
100  * query if the decomposition is supported from single-layer image to dual-layer HDR image.
101  *
102  * @see OH_ImageProcessing_Create
103  * @since 13
104  */
105 extern const int32_t IMAGE_PROCESSING_TYPE_DECOMPOSITION;
106 
107 /**
108  * @brief Used to create an image processing instance for metadata generation.
109  *
110  * Generate HDR Vivid metadata for single-layer image. The capability is supported by vendor. If the capability is not
111  * supported, {@link OH_ImageProcessing_Create} returns {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING}.
112  *
113  * @see OH_ImageProcessing_Create
114  * @since 13
115  */
116 extern const int32_t IMAGE_PROCESSING_TYPE_METADATA_GENERATION;
117 
118 /**
119  * @brief Used to create an image processing instance for detail enhancement.
120  *
121  * Scale or resize images with the specified quality or just enhance details for rendering an image without changing
122  * its resolution.
123  *
124  * @see OH_ImageProcessing_Create
125  * @since 13
126  */
127 extern const int32_t IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER;
128 
129 /**
130  * @brief The key is used to specify the quality level for image detail enhancement.
131  *
132  * See {@link ImageDetailEnhancer_QualityLevel} for its value.
133  * Use {@link OH_ImageProcessing_SetParameter} to set the quality level.
134  * Use {@link OH_ImageProcessing_GetParameter} to get the current quality level.
135  *
136  * @see OH_VideoProcessing_SetParameter
137  * @see OH_VideoProcessing_GetParameter
138  * @since 13
139  */
140 extern const char* IMAGE_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL;
141 
142 /**
143  * @brief The color space information is used for color space conversion capability query.
144  *
145  * @see OH_ImageProcessing_IsColorSpaceConversionSupported
146  * @see OH_ImageProcessing_IsCompositionSupported
147  * @see OH_ImageProcessing_IsDecompositionSupported
148  * @since 13
149  */
150 typedef struct ImageProcessing_ColorSpaceInfo {
151     /** define metadata type, {@link enum OH_Pixelmap_HdrMetadataKey} */
152     int32_t metadataType;
153     /** define color space, {@link enum ColorSpaceName} */
154     int32_t colorSpace;
155     /** define pixel format, {@link enum PIXEL_FORMAT} */
156     int32_t pixelFormat;
157 } ImageProcessing_ColorSpaceInfo;
158 
159 /**
160  * @brief The quality level is used for detail enhancement.
161  *
162  * It is the value of the key parameter {@link IMAGE_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL}.
163  *
164  * @see OH_ImageProcessing_SetParameter
165  * @see OH_ImageProcessing_GetParameter
166  * @since 13
167  */
168 typedef enum ImageDetailEnhancer_QualityLevel {
169     /** No detail enhancement */
170     IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_NONE,
171     /** A low level of detail enhancement quality but with a fast speed. It's the default level */
172     IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_LOW,
173     /** A medium level of detail enhancement quality. Its speed is between the low setting and high setting */
174     IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_MEDIUM,
175     /** A high level of detail enhancement quality but with a relatively slow speed */
176     IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_HIGH,
177 } ImageDetailEnhancer_QualityLevel;
178 
179 /**
180  * @brief Image processing error code.
181  *
182  * @since 13
183  */
184 typedef enum ImageProcessing_ErrorCode {
185     /** @error Operation is successful. */
186     IMAGE_PROCESSING_SUCCESS,
187     /** @error Input parameter is invalid. This error is returned for all of the following error conditions:
188      *  1 - Invalid input or output image buffer - The image buffer is null.
189      *  2 - Invalid parameter - The parameter is null.
190      *  3 - Invalid type - The type passed in the create function does not exist.
191      */
192     IMAGE_PROCESSING_ERROR_INVALID_PARAMETER = 401,
193     /** @error Some unknown error occurred, such as GPU calculation failure or memcpy failure. */
194     IMAGE_PROCESSING_ERROR_UNKNOWN = 29200001,
195     /** @error The global environment initialization for image processing failed, such as failure to initialize
196      * the GPU environment.
197      */
198     IMAGE_PROCESSING_ERROR_INITIALIZE_FAILED,
199     /** @error Failed to create image processing instance. For example,
200      * the number of instances exceeds the upper limit.
201      */
202     IMAGE_PROCESSING_ERROR_CREATE_FAILED,
203     /** @error Failed to process image buffer. For example, the processing times out. */
204     IMAGE_PROCESSING_ERROR_PROCESS_FAILED,
205     /** @error The processing is not supported. You may call OH_ImageProcessing_IsXXXSupported
206      * to check whether the capability is supported.
207      */
208     IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING,
209     /** @error The operation is not permitted. This may be caused by incorrect status. */
210     IMAGE_PROCESSING_ERROR_OPERATION_NOT_PERMITTED,
211     /** @error Out of memory. */
212     IMAGE_PROCESSING_ERROR_NO_MEMORY,
213     /** @error The image processing instance is invalid. This may be caused by null instance. */
214     IMAGE_PROCESSING_ERROR_INVALID_INSTANCE,
215     /** @error Input value is invalid. This error is returned for all of the following error conditions:
216      *  1 - Invalid input or output image buffer - The image buffer width(height)
217      *      is too large or colorspace is incorrect.
218      *  2 - Invalid parameter - The parameter does not contain valid information,
219      *      such as detail enhancer level is incorrect.
220      */
221     IMAGE_PROCESSING_ERROR_INVALID_VALUE
222 } ImageProcessing_ErrorCode;
223 
224 #ifdef __cplusplus
225 }
226 #endif
227 
228 #endif // VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_TYPES_H
229 /** @} */
230