1/* 2 * Copyright (c) 2025 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 Codec 18 * @{ 19 * 20 * @brief Defines APIs of the image Codec module. 21 * 22 * The Codec module provides APIs for image codec, setting codec parameters, 23 * and controlling and transferring image data. 24 * 25 * @since 4.0 26 * @version 2.0 27 */ 28 29/** 30 * @file ICodecImage.idl 31 * 32 * @brief Declares the APIs for image codec. 33 * 34 *You can use these APIs to allocate input buffer, and decode image 35 * 36 * @since 4.0 37 * @version 2.0 38 */ 39 40/** 41 * @brief Defines the path for the package of the image Codec module APIs. 42 * 43 * @since 4.0 44 * @version 2.1 45 */ 46package ohos.hdi.codec.image.v2_1; 47 48import ohos.hdi.codec.image.v2_1.CodecImageType; 49 50interface ICodecImage { 51 52 /** 53 * @brief Notify to power on the Image Codec module hardware. 54 * 55 * You can use this API to notify the Image Codec module hardware to power on. 56 * @param role Indicates the image codec role {@link CodecImageRole} obtained. 57 * 58 * @since 6.0 59 * @version 2.1 60 */ 61 [oneway] NotifyPowerOn([in] enum CodecImageRole role); 62 63 /** 64 * @brief Obtains image codec capabilities. 65 * 66 * You can use this API to obtain the encoding and decoding capabilities provided by the image Codec module. 67 * For details, see {@link CodecImageCapability}. 68 * 69 * @param capList Indicates the image codec capabilities {@link CodecImageCapability} obtained. 70 * 71 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 72 * @return Returns <b>HDF_FAILURE</b> if the execution fails. 73 * 74 * @since 4.0 75 * @version 1.0 76 */ 77 GetImageCapability([out] struct CodecImageCapability[] capList); 78 79 /** 80 * @brief Image codec module init. 81 * 82 * You can use this API to init the Image Codec module. 83 * 84 * @param role Indicates the image codec role {@link CodecImageRole} obtained. 85 * 86 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 87 * @return Returns <b>HDF_FAILURE</b> if the execution fails. 88 * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 89 * see <b>HDF_STATUS</b> defined by HDF. 90 * 91 * @since 4.0 92 * @version 1.0 93 */ 94 Init([in] enum CodecImageRole role); 95 96 /** 97 * @brief Image codec module deinit. 98 * 99 * You can use this API to deinit the Image Codec module. 100 * 101 * @param role Indicates the image codec role {@link CodecImageRole} obtained. 102 * 103 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 104 * @return Returns <b>HDF_FAILURE</b> if the execution fails. 105 * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 106 * see <b>HDF_STATUS</b> defined by HDF. 107 * 108 * @since 4.0 109 * @version 1.0 110 */ 111 DeInit([in] enum CodecImageRole role); 112 113 /** 114 * @brief Start jpeg image decode. 115 * 116 * You can use this API to start jpeg image decode. 117 * 118 * @param inBuffer Indicates input buffer of the jpeg image decode {@link CodecImageBuffer} obtained. 119 * @param outBuffer Indicates output buffer of the jpeg image decode {@link CodecImageBuffer} obtained. 120 * @param decInfo Indicates decode information of the image decode {@link JpegDecInfo} obtained. 121 * 122 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 123 * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation fails due to invalid parameters. 124 * @return Returns <b>HDF_FAILURE</b> if the execution fails. 125 * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 126 * see <b>HDF_STATUS</b> defined by HDF. 127 * 128 * @since 4.0 129 * @version 1.0 130 */ 131 DoJpegDecode([in] struct CodecImageBuffer inBuffer, [in] struct CodecImageBuffer outBuffer, 132 [in] struct CodecJpegDecInfo decInfo); 133 134 /** 135 * @brief Allocate input buffer. 136 * 137 * You can use this API to allocate input buffer for image codec. 138 * After input buffer is duplicated to proxy, stub will automatically free its own reference to input buffer. 139 * 140 * @param inBuffer Indicates input buffer of the image codec {@link CodecImageBuffer} obtained. 141 * @param size Indicates size of input buffer {@link CodecImageBuffer} obtained. 142 * @param role Indicates image codec role of input buffer {@link CodecImageRole} obtained. 143 * 144 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 145 * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation fails due to invalid parameters. 146 * @return Returns <b>HDF_FAILURE</b> if the execution fails. 147 * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 148 * see <b>HDF_STATUS</b> defined by HDF. 149 * 150 * @since 4.0 151 * @version 1.0 152 */ 153 AllocateInBuffer([out] struct CodecImageBuffer inBuffer, [in] unsigned int size, [in] CodecImageRole role); 154 155 /** 156 * @brief Free input buffer. 157 * 158 * You can use this API to free input buffer for image decode. 159 * 160 * @param buffer Indicates input buffer of the image codec {@link CodecImageBuffer} obtained. 161 * 162 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 163 * @return Returns <b>HDF_FAILURE</b> if the execution fails. 164 * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 165 * see <b>HDF_STATUS</b> defined by HDF. 166 * 167 * @since 4.0 168 * @version 1.0 169 * @deprecated 170 * @stub no longer hold reference to input buffer, no need to free. 171 */ 172 FreeInBuffer([in] struct CodecImageBuffer inBuffer); 173 174 /** 175 * @brief Start heif image encode. 176 * 177 * You can use this API to start heif image encode. 178 * 179 * @param inputImgs Indicates input images for the heif image encode {@link ImageItem} obtained. 180 * @param inputMetas Indicates encode parameters of the image encode {@link MetaItem} obtained. 181 * @param refs Indicates reference relations of the heif image encode {@link ItemRef} obtained. 182 * @param output Indicates output buffer of the heif image encode {@link SharedBuffer} obtained. 183 * @param filledLen Indicates filled length of output buffer if heif image encode succeed. 184 * 185 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 186 * @return Returns <b>HDF_FAILURE</b> if the execution fails. 187 * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 188 * see <b>HDF_STATUS</b> defined by HDF. 189 * 190 * @since 5.0 191 * @version 2.0 192 */ 193 DoHeifEncode([in] ImageItem[] inputImgs, [in] MetaItem[] inputMetas, 194 [in] ItemRef[] refs, [in] SharedBuffer output, [out] unsigned int filledLen); 195 196 /** 197 * @brief Start heif image decode. 198 * 199 * You can use this API to start heif image decode. 200 * 201 * @param inputs Indicates input buffer of the heif image decode {@link Ashmem} obtained. 202 * @param output Indicates output buffer of the heif image decode {@link NativeBuffer} obtained. 203 * @param decInfo Indicates decode information of the image decode {@link CodecHeifDecInfo} obtained. 204 * 205 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 206 * @return Returns <b>HDF_FAILURE</b> if the execution fails. 207 * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 208 * see <b>HDF_STATUS</b> defined by HDF. 209 * 210 * @since 6.0 211 * @version 1.0 212 */ 213 DoHeifDecode([in] Ashmem[] inputs, [in] NativeBuffer output, [in] struct CodecHeifDecInfo decInfo); 214} 215