• 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 IMAGE_PROCESSING_NATIVE_BASE_H
17 #define IMAGE_PROCESSING_NATIVE_BASE_H
18 
19 #include "common/native_mfmagic.h"
20 #include "pixelmap_native_impl.h"
21 #include "pixel_map.h"
22 
23 #include "image_processing_interface.h"
24 
25 namespace OHOS {
26 namespace Media {
27 namespace VideoProcessingEngine {
28 /**
29  * Base implementaion for image processing.
30  */
31 class ImageProcessingNativeBase : public IImageProcessingNative {
32 public:
33     ImageProcessing_ErrorCode Initialize() final;
34     ImageProcessing_ErrorCode Deinitialize() final;
35     ImageProcessing_ErrorCode SetParameter(const OH_AVFormat* parameter) final;
36     ImageProcessing_ErrorCode GetParameter(OH_AVFormat* parameter) final;
37     ImageProcessing_ErrorCode Process(OH_PixelmapNative* sourceImage,
38     OH_PixelmapNative* destinationImage) final;
39     ImageProcessing_ErrorCode ConvertColorSpace(OH_PixelmapNative* sourceImage,
40         OH_PixelmapNative* destinationImage) final;
41     ImageProcessing_ErrorCode Compose(OH_PixelmapNative* sourceImage,
42         OH_PixelmapNative* sourceGainmap, OH_PixelmapNative* destinationImage) final;
43     ImageProcessing_ErrorCode Decompose(OH_PixelmapNative* sourceImage,
44         OH_PixelmapNative* destinationImage, OH_PixelmapNative* destinationGainmap) final;
45     ImageProcessing_ErrorCode GenerateMetadata(OH_PixelmapNative* sourceImage) final;
46     ImageProcessing_ErrorCode EnhanceDetail(OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage) final;
47 protected:
48     explicit ImageProcessingNativeBase();
49     virtual ~ImageProcessingNativeBase() = default;
50     ImageProcessingNativeBase(const ImageProcessingNativeBase&) = delete;
51     ImageProcessingNativeBase& operator=(const ImageProcessingNativeBase&) = delete;
52     ImageProcessingNativeBase(ImageProcessingNativeBase&&) = delete;
53     ImageProcessingNativeBase& operator=(ImageProcessingNativeBase&&) = delete;
54 
55     virtual ImageProcessing_ErrorCode InitializeInner();
56     virtual ImageProcessing_ErrorCode DeinitializeInner();
57     virtual ImageProcessing_ErrorCode SetParameter(const OHOS::Media::Format& parameter);
58     virtual ImageProcessing_ErrorCode GetParameter(OHOS::Media::Format& parameter);
59     virtual ImageProcessing_ErrorCode Process(const std::shared_ptr<OHOS::Media::PixelMap>& sourceImage,
60         std::shared_ptr<OHOS::Media::PixelMap>& destinationImage);
61     virtual ImageProcessing_ErrorCode ConvertColorSpace(const std::shared_ptr<OHOS::Media::PixelMap>& sourceImage,
62         std::shared_ptr<OHOS::Media::PixelMap>& destinationImage);
63     virtual ImageProcessing_ErrorCode Compose(const std::shared_ptr<OHOS::Media::PixelMap>& sourceImage,
64         const std::shared_ptr<OHOS::Media::PixelMap>& sourceGainmap,
65         std::shared_ptr<OHOS::Media::PixelMap>& destinationImage);
66     virtual ImageProcessing_ErrorCode Decompose(const std::shared_ptr<OHOS::Media::PixelMap>& sourceImage,
67         std::shared_ptr<OHOS::Media::PixelMap>& destinationImage,
68         std::shared_ptr<OHOS::Media::PixelMap>& destinationGainmap);
69     virtual ImageProcessing_ErrorCode GenerateMetadata(const std::shared_ptr<OHOS::Media::PixelMap>& sourceImage);
70     virtual ImageProcessing_ErrorCode EnhanceDetail(const std::shared_ptr<OHOS::Media::PixelMap>& sourceImage,
71     std::shared_ptr<OHOS::Media::PixelMap>& destinationImage);
72 
73 private:
74     mutable std::mutex lock_{};
75     // Guarded by lock_ begin
76     std::atomic<bool> isInitialized_{false};
77 };
78 } // namespace VideoProcessingEngine
79 } // namespace Media
80 } // namespace OHOS
81 
82 #endif // IMAGE_PROCESSING_NATIVE_BASE_H