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 #ifndef INTERFACES_INNER_API_VPE_CONTRAST_ENHANCER_IMAGE_H 17 #define INTERFACES_INNER_API_VPE_CONTRAST_ENHANCER_IMAGE_H 18 19 #include <memory> 20 21 #include "algorithm_errors.h" 22 #include "contrast_enhancer_common.h" 23 #include "external_window.h" 24 #include "refbase.h" 25 #include "surface_buffer.h" 26 27 namespace OHOS { 28 namespace Media { 29 namespace VideoProcessingEngine { 30 /** 31 * Process 32 * 执行计算画质算法对图像质量进行增强,如:超分、AIHDR等: 33 * 1. AISR超分: 34 * 原始图片 -> 缩放后的目标尺寸图片 35 * 2. AIHDR: 36 * 原始图片 -> 处理后的单层HDR图片 37 */ 38 class __attribute__((visibility("default"))) ContrastEnhancerImage { 39 public: 40 /** 41 * @brief Create a ContrastEnhancerImage object. 42 * @syscap 43 * @param type 超分的类型为图片还是视频 44 * @return pointer of the ContrastEnhancerImage object. 45 * @since 16 46 */ 47 static std::shared_ptr<ContrastEnhancerImage> Create(); 48 49 /** 50 * @brief 设置计算画质参数。可被多次调用,但只有最接近Process的一次调用设置的参数 51 * 会在Process时生效。 52 * @syscap 53 * @param parameter 转换参数 54 * @return 返回错误码VPEAlgoErrCode 55 * @since 16 56 */ 57 virtual VPEAlgoErrCode SetParameter(const ContrastEnhancerParameters& parameter) = 0; 58 59 /** 60 * @brief 查询参数 61 * @syscap 62 * @param parameter 输出参数 63 * @return 返回错误码VPEAlgoErrCode 64 * @since 12 65 */ 66 virtual VPEAlgoErrCode GetParameter(ContrastEnhancerParameters& parameter) const = 0; 67 68 /** 69 * @brief 初始化区域直方图 70 * @syscap 71 * @param input 输入的sdr图片或单层hdr图片 72 * @return 返回错误码VPEAlgoErrCode 73 * @since 16 74 */ 75 virtual VPEAlgoErrCode GetRegionHist(const sptr<SurfaceBuffer>& input) = 0; 76 77 /** 78 * @brief 基于像素值更新元数据 79 * @syscap 80 * @param displayArea 送显区域 81 * @param curPixelmapArea 当前输入pixelmap在完整原图中的区域 82 * @param completePixelmapArea 完整原图的分辨率信息 83 * @param surfaceBuffer 当前输入pixelmap的surfacebuffer 84 * @param fullRatio 缩放比例 85 * @return 返回错误码VPEAlgoErrCode 86 * @since 16 87 */ 88 virtual VPEAlgoErrCode UpdateMetadataBasedOnPixel(OHOS::Rect displayArea, OHOS::Rect curPixelmapArea, 89 OHOS::Rect completePixelmapArea, sptr<SurfaceBuffer> surfaceBuffer, float fullRatio) = 0; 90 91 /** 92 * @brief 基于LCD图更新元数据 93 * @syscap 94 * @param displayArea 送显区域 95 * @param lcdWidth lcd图的宽度 96 * @param lcdHeight lcd图的高度 97 * @param surfaceBuffer 当前输入pixelmap的surfacebuffer 98 * @return 返回错误码VPEAlgoErrCode 99 * @since 16 100 */ 101 virtual VPEAlgoErrCode UpdateMetadataBasedOnHist(OHOS::Rect displayArea, sptr<SurfaceBuffer> surfaceBuffer, 102 std::tuple<int, int, double, double, double, int> pixelmapInfo) = 0; 103 104 protected: 105 ContrastEnhancerImage() = default; 106 virtual ~ContrastEnhancerImage() = default; 107 ContrastEnhancerImage(const ContrastEnhancerImage&) = delete; 108 ContrastEnhancerImage& operator=(const ContrastEnhancerImage&) = delete; 109 ContrastEnhancerImage(ContrastEnhancerImage&&) = delete; 110 ContrastEnhancerImage& operator=(ContrastEnhancerImage&&) = delete; 111 }; 112 } // namespace VideoProcessingEngine 113 } // namespace Media 114 } // namespace OHOS 115 116 #endif // INTERFACES_INNER_API_VPE_CONTRAST_ENHANCER_IMAGE_H 117