• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DETAIL_ENHANCER_IMAGE_H
17 #define INTERFACES_INNER_API_VPE_DETAIL_ENHANCER_IMAGE_H
18 
19 #include <memory>
20 
21 #include "algorithm_errors.h"
22 #include "detail_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"))) DetailEnhancerImage {
39 public:
40     /**
41      * @brief Create a DetailEnhancerImage object.
42      * @syscap
43      * @param type 超分的类型为图片还是视频
44      * @return pointer of the DetailEnhancerImage object.
45      * @since 12
46      */
47     static std::shared_ptr<DetailEnhancerImage> Create(int type = IMAGE);
48 
49     /**
50      * @brief 设置计算画质参数。可被多次调用,但只有最接近Process的一次调用设置的参数
51      * 会在Process时生效。
52      * @syscap
53      * @param parameter 转换参数
54      * @return 返回错误码VPEAlgoErrCode
55      * @since 12
56      */
57     virtual VPEAlgoErrCode SetParameter(const DetailEnhancerParameters& parameter) = 0;
58 
59     /**
60      * @brief 查询参数
61      * @syscap
62      * @param parameter 输出参数
63      * @return 返回错误码VPEAlgoErrCode
64      * @since 12
65      */
66     virtual VPEAlgoErrCode GetParameter(DetailEnhancerParameters& parameter) const = 0;
67 
68     /**
69      * @brief 用于解码后的单层图片画质增强处理,如:超分、AIHDR等
70      * @syscap
71      * @param input 输入的sdr图片或单层hdr图片
72      * @param output 输出画质增强后的sdr图片或单层hdr图片
73      * @return 返回错误码VPEAlgoErrCode
74      * @since 12
75      */
76     virtual VPEAlgoErrCode Process(const sptr<SurfaceBuffer>& input, const sptr<SurfaceBuffer>& output) = 0;
77 
78     virtual VPEAlgoErrCode EnableProtection(bool enable) = 0;
79     virtual VPEAlgoErrCode ResetProtectionStatus() = 0;
80 
81 protected:
82     DetailEnhancerImage() = default;
83     virtual ~DetailEnhancerImage() = default;
84     DetailEnhancerImage(const DetailEnhancerImage&) = delete;
85     DetailEnhancerImage& operator=(const DetailEnhancerImage&) = delete;
86     DetailEnhancerImage(DetailEnhancerImage&&) = delete;
87     DetailEnhancerImage& operator=(DetailEnhancerImage&&) = delete;
88 };
89 
90 extern "C" __attribute__((visibility("default"))) int32_t DetailEnhancerCreate(int32_t* instance);
91 extern "C" __attribute__((visibility("default"))) int32_t DetailEnhancerProcessImage(int32_t instance,
92     OHNativeWindowBuffer* inputImage, OHNativeWindowBuffer* outputImage, int32_t level);
93 extern "C" __attribute__((visibility("default"))) int32_t DetailEnhancerDestroy(int32_t* instance);
94 } // namespace VideoProcessingEngine
95 } // namespace Media
96 } // namespace OHOS
97 
98 #endif // INTERFACES_INNER_API_VPE_DETAIL_ENHANCER_IMAGE_H
99