1c5e268c6Sopenharmony_ci/* 2c5e268c6Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 3c5e268c6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4c5e268c6Sopenharmony_ci * you may not use this file except in compliance with the License. 5c5e268c6Sopenharmony_ci * You may obtain a copy of the License at 6c5e268c6Sopenharmony_ci * 7c5e268c6Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8c5e268c6Sopenharmony_ci * 9c5e268c6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10c5e268c6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11c5e268c6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12c5e268c6Sopenharmony_ci * See the License for the specific language governing permissions and 13c5e268c6Sopenharmony_ci * limitations under the License. 14c5e268c6Sopenharmony_ci */ 15c5e268c6Sopenharmony_ci 16c5e268c6Sopenharmony_ci /** 17c5e268c6Sopenharmony_ci * @addtogroup Codec 18c5e268c6Sopenharmony_ci * @{ 19c5e268c6Sopenharmony_ci * 20c5e268c6Sopenharmony_ci * @brief Defines APIs of the image Codec module. 21c5e268c6Sopenharmony_ci * 22c5e268c6Sopenharmony_ci * The Codec module provides APIs for image codec, setting codec parameters, 23c5e268c6Sopenharmony_ci * and controlling and transferring image data. 24c5e268c6Sopenharmony_ci * 25c5e268c6Sopenharmony_ci * @since 4.0 26c5e268c6Sopenharmony_ci * @version 2.0 27c5e268c6Sopenharmony_ci */ 28c5e268c6Sopenharmony_ci 29c5e268c6Sopenharmony_ci/** 30c5e268c6Sopenharmony_ci * @file ICodecImage.idl 31c5e268c6Sopenharmony_ci * 32c5e268c6Sopenharmony_ci * @brief Declares the APIs for image codec. 33c5e268c6Sopenharmony_ci * 34c5e268c6Sopenharmony_ci *You can use these APIs to allocate input buffer, and decode image 35c5e268c6Sopenharmony_ci * 36c5e268c6Sopenharmony_ci * @since 4.0 37c5e268c6Sopenharmony_ci * @version 2.0 38c5e268c6Sopenharmony_ci */ 39c5e268c6Sopenharmony_ci 40c5e268c6Sopenharmony_ci/** 41c5e268c6Sopenharmony_ci * @brief Defines the path for the package of the image Codec module APIs. 42c5e268c6Sopenharmony_ci * 43c5e268c6Sopenharmony_ci * @since 4.0 44c5e268c6Sopenharmony_ci * @version 2.0 45c5e268c6Sopenharmony_ci */ 46c5e268c6Sopenharmony_cipackage ohos.hdi.codec.image.v2_0; 47c5e268c6Sopenharmony_ci 48c5e268c6Sopenharmony_ciimport ohos.hdi.codec.image.v2_0.CodecImageType; 49c5e268c6Sopenharmony_ci 50c5e268c6Sopenharmony_ciinterface ICodecImage { 51c5e268c6Sopenharmony_ci 52c5e268c6Sopenharmony_ci /** 53c5e268c6Sopenharmony_ci * @brief Obtains image codec capabilities. 54c5e268c6Sopenharmony_ci * 55c5e268c6Sopenharmony_ci * You can use this API to obtain the encoding and decoding capabilities provided by the image Codec module. 56c5e268c6Sopenharmony_ci * For details, see {@link CodecImageCapability}. 57c5e268c6Sopenharmony_ci * 58c5e268c6Sopenharmony_ci * @param capList Indicates the image codec capabilities {@link CodecImageCapability} obtained. 59c5e268c6Sopenharmony_ci * 60c5e268c6Sopenharmony_ci * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 61c5e268c6Sopenharmony_ci * @return Returns <b>HDF_FAILURE</b> if the execution fails. 62c5e268c6Sopenharmony_ci * 63c5e268c6Sopenharmony_ci * @since 4.0 64c5e268c6Sopenharmony_ci * @version 1.0 65c5e268c6Sopenharmony_ci */ 66c5e268c6Sopenharmony_ci GetImageCapability([out] struct CodecImageCapability[] capList); 67c5e268c6Sopenharmony_ci 68c5e268c6Sopenharmony_ci /** 69c5e268c6Sopenharmony_ci * @brief Image codec module init. 70c5e268c6Sopenharmony_ci * 71c5e268c6Sopenharmony_ci * You can use this API to init the Image Codec module. 72c5e268c6Sopenharmony_ci * 73c5e268c6Sopenharmony_ci * @param role Indicates the image codec role {@link CodecImageRole} obtained. 74c5e268c6Sopenharmony_ci * 75c5e268c6Sopenharmony_ci * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 76c5e268c6Sopenharmony_ci * @return Returns <b>HDF_FAILURE</b> if the execution fails. 77c5e268c6Sopenharmony_ci * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 78c5e268c6Sopenharmony_ci * see <b>HDF_STATUS</b> defined by HDF. 79c5e268c6Sopenharmony_ci * 80c5e268c6Sopenharmony_ci * @since 4.0 81c5e268c6Sopenharmony_ci * @version 1.0 82c5e268c6Sopenharmony_ci */ 83c5e268c6Sopenharmony_ci Init([in] enum CodecImageRole role); 84c5e268c6Sopenharmony_ci 85c5e268c6Sopenharmony_ci /** 86c5e268c6Sopenharmony_ci * @brief Image codec module deinit. 87c5e268c6Sopenharmony_ci * 88c5e268c6Sopenharmony_ci * You can use this API to deinit the Image Codec module. 89c5e268c6Sopenharmony_ci * 90c5e268c6Sopenharmony_ci * @param role Indicates the image codec role {@link CodecImageRole} obtained. 91c5e268c6Sopenharmony_ci * 92c5e268c6Sopenharmony_ci * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 93c5e268c6Sopenharmony_ci * @return Returns <b>HDF_FAILURE</b> if the execution fails. 94c5e268c6Sopenharmony_ci * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 95c5e268c6Sopenharmony_ci * see <b>HDF_STATUS</b> defined by HDF. 96c5e268c6Sopenharmony_ci * 97c5e268c6Sopenharmony_ci * @since 4.0 98c5e268c6Sopenharmony_ci * @version 1.0 99c5e268c6Sopenharmony_ci */ 100c5e268c6Sopenharmony_ci DeInit([in] enum CodecImageRole role); 101c5e268c6Sopenharmony_ci 102c5e268c6Sopenharmony_ci /** 103c5e268c6Sopenharmony_ci * @brief Start jpeg image decode. 104c5e268c6Sopenharmony_ci * 105c5e268c6Sopenharmony_ci * You can use this API to start jpeg image decode. 106c5e268c6Sopenharmony_ci * 107c5e268c6Sopenharmony_ci * @param inBuffer Indicates input buffer of the jpeg image decode {@link CodecImageBuffer} obtained. 108c5e268c6Sopenharmony_ci * @param outBuffer Indicates output buffer of the jpeg image decode {@link CodecImageBuffer} obtained. 109c5e268c6Sopenharmony_ci * @param decInfo Indicates decode information of the image decode {@link JpegDecInfo} obtained. 110c5e268c6Sopenharmony_ci * 111c5e268c6Sopenharmony_ci * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 112c5e268c6Sopenharmony_ci * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation fails due to invalid parameters. 113c5e268c6Sopenharmony_ci * @return Returns <b>HDF_FAILURE</b> if the execution fails. 114c5e268c6Sopenharmony_ci * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 115c5e268c6Sopenharmony_ci * see <b>HDF_STATUS</b> defined by HDF. 116c5e268c6Sopenharmony_ci * 117c5e268c6Sopenharmony_ci * @since 4.0 118c5e268c6Sopenharmony_ci * @version 1.0 119c5e268c6Sopenharmony_ci */ 120c5e268c6Sopenharmony_ci DoJpegDecode([in] struct CodecImageBuffer inBuffer, [in] struct CodecImageBuffer outBuffer, 121c5e268c6Sopenharmony_ci [in] struct CodecJpegDecInfo decInfo); 122c5e268c6Sopenharmony_ci 123c5e268c6Sopenharmony_ci /** 124c5e268c6Sopenharmony_ci * @brief Allocate input buffer. 125c5e268c6Sopenharmony_ci * 126c5e268c6Sopenharmony_ci * You can use this API to allocate input buffer for image codec. 127c5e268c6Sopenharmony_ci * After input buffer is duplicated to proxy, stub will automatically free its own reference to input buffer. 128c5e268c6Sopenharmony_ci * 129c5e268c6Sopenharmony_ci * @param inBuffer Indicates input buffer of the image codec {@link CodecImageBuffer} obtained. 130c5e268c6Sopenharmony_ci * @param size Indicates size of input buffer {@link CodecImageBuffer} obtained. 131c5e268c6Sopenharmony_ci * @param role Indicates image codec role of input buffer {@link CodecImageRole} obtained. 132c5e268c6Sopenharmony_ci * 133c5e268c6Sopenharmony_ci * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 134c5e268c6Sopenharmony_ci * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation fails due to invalid parameters. 135c5e268c6Sopenharmony_ci * @return Returns <b>HDF_FAILURE</b> if the execution fails. 136c5e268c6Sopenharmony_ci * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 137c5e268c6Sopenharmony_ci * see <b>HDF_STATUS</b> defined by HDF. 138c5e268c6Sopenharmony_ci * 139c5e268c6Sopenharmony_ci * @since 4.0 140c5e268c6Sopenharmony_ci * @version 1.0 141c5e268c6Sopenharmony_ci */ 142c5e268c6Sopenharmony_ci AllocateInBuffer([out] struct CodecImageBuffer inBuffer, [in] unsigned int size, [in] CodecImageRole role); 143c5e268c6Sopenharmony_ci 144c5e268c6Sopenharmony_ci /** 145c5e268c6Sopenharmony_ci * @brief Free input buffer. 146c5e268c6Sopenharmony_ci * 147c5e268c6Sopenharmony_ci * You can use this API to free input buffer for image decode. 148c5e268c6Sopenharmony_ci * 149c5e268c6Sopenharmony_ci * @param buffer Indicates input buffer of the image codec {@link CodecImageBuffer} obtained. 150c5e268c6Sopenharmony_ci * 151c5e268c6Sopenharmony_ci * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 152c5e268c6Sopenharmony_ci * @return Returns <b>HDF_FAILURE</b> if the execution fails. 153c5e268c6Sopenharmony_ci * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 154c5e268c6Sopenharmony_ci * see <b>HDF_STATUS</b> defined by HDF. 155c5e268c6Sopenharmony_ci * 156c5e268c6Sopenharmony_ci * @since 4.0 157c5e268c6Sopenharmony_ci * @version 1.0 158c5e268c6Sopenharmony_ci * @deprecated 159c5e268c6Sopenharmony_ci * @stub no longer hold reference to input buffer, no need to free. 160c5e268c6Sopenharmony_ci */ 161c5e268c6Sopenharmony_ci FreeInBuffer([in] struct CodecImageBuffer inBuffer); 162c5e268c6Sopenharmony_ci 163c5e268c6Sopenharmony_ci /** 164c5e268c6Sopenharmony_ci * @brief Start heif image encode. 165c5e268c6Sopenharmony_ci * 166c5e268c6Sopenharmony_ci * You can use this API to start heif image encode. 167c5e268c6Sopenharmony_ci * 168c5e268c6Sopenharmony_ci * @param inputImgs Indicates input images for the heif image encode {@link ImageItem} obtained. 169c5e268c6Sopenharmony_ci * @param inputMetas Indicates encode parameters of the image encode {@link MetaItem} obtained. 170c5e268c6Sopenharmony_ci * @param refs Indicates reference relations of the heif image encode {@link ItemRef} obtained. 171c5e268c6Sopenharmony_ci * @param output Indicates output buffer of the heif image encode {@link SharedBuffer} obtained. 172c5e268c6Sopenharmony_ci * @param filledLen Indicates filled length of output buffer if heif image encode succeed. 173c5e268c6Sopenharmony_ci * 174c5e268c6Sopenharmony_ci * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 175c5e268c6Sopenharmony_ci * @return Returns <b>HDF_FAILURE</b> if the execution fails. 176c5e268c6Sopenharmony_ci * @return Returns other values if the underlying layer returns a failure. For details about the error codes, 177c5e268c6Sopenharmony_ci * see <b>HDF_STATUS</b> defined by HDF. 178c5e268c6Sopenharmony_ci * 179c5e268c6Sopenharmony_ci * @since 5.0 180c5e268c6Sopenharmony_ci * @version 2.0 181c5e268c6Sopenharmony_ci */ 182c5e268c6Sopenharmony_ci DoHeifEncode([in] ImageItem[] inputImgs, [in] MetaItem[] inputMetas, 183c5e268c6Sopenharmony_ci [in] ItemRef[] refs, [in] SharedBuffer output, [out] unsigned int filledLen); 184c5e268c6Sopenharmony_ci} 185