• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef SUPER_RESOLUTION_POST_PROCESSOR_H
17 #define SUPER_RESOLUTION_POST_PROCESSOR_H
18 
19 #include "base_video_post_processor.h"
20 #include "video_post_processor_factory.h"
21 
22 #include "algorithm_video.h"
23 #include "algorithm_video_common.h"
24 
25 namespace OHOS {
26 namespace Media {
27 
28 class SuperResolutionPostProcessor : public BaseVideoPostProcessor,
29                                      public std::enable_shared_from_this<SuperResolutionPostProcessor> {
30 public:
31     SuperResolutionPostProcessor();
32     ~SuperResolutionPostProcessor() override;
33 
34     bool IsValid();
35 
36     Status Init() override;
37     Status Flush() override;
38     Status Stop() override;
39     Status Start() override;
40     Status Release() override;
41     Status NotifyEos(int64_t eosPts = 0) override;
42 
43     sptr<Surface> GetInputSurface() override;
44     Status SetOutputSurface(sptr<Surface> surface) override;
45 
46     Status SetCallback(const std::shared_ptr<PostProcessorCallback> callback) override;
47     Status SetEventReceiver(const std::shared_ptr<Pipeline::EventReceiver> &receiver) override;
48 
49     Status SetParameter(const Format &format) override;
50     Status SetPostProcessorOn(bool isPostProcessorOn) override;
51     Status SetVideoWindowSize(int32_t width, int32_t height) override;
52 
53     Status ReleaseOutputBuffer(uint32_t index, bool render) override;
54     Status RenderOutputBufferAtTime(uint32_t index, int64_t renderTimestampNs) override;
55 
56     void OnOutputFormatChanged(const Format &format);
57     void OnOutputBufferAvailable(uint32_t index, VideoProcessingEngine::VpeBufferFlag flag);
58     void OnOutputBufferAvailable(uint32_t index, const VideoProcessingEngine::VpeBufferInfo& info);
59     void OnSuperResolutionChanged(bool enable);
60     void OnError(VideoProcessingEngine::VPEAlgoErrCode errorCode);
61 private:
62     Status SetQualityLevel(VideoProcessingEngine::DetailEnhancerQualityLevel level);
63 
64     static constexpr VideoProcessingEngine::DetailEnhancerQualityLevel DEFAULT_QUALITY_LEVEL =
65         VideoProcessingEngine::DETAIL_ENHANCER_LEVEL_HIGH;
66     std::shared_ptr<VideoProcessingEngine::VpeVideo> postProcessor_ {nullptr};
67     bool isPostProcessorOn_ {false};
68 
69     std::shared_ptr<PostProcessorCallback> filterCallback_;
70     std::shared_ptr<Pipeline::EventReceiver> eventReceiver_ {nullptr};
71 
72     std::shared_mutex mutex_ {};
73 };
74 
75 } // namespace Media
76 } // namespace OHOS
77 #endif // SUPER_RESOLUTION_POST_PROCESSOR_H
78