• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 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 OHOS_HDI_CODEC_V1_0_CODECJPEGDEC_H
17 #define OHOS_HDI_CODEC_V1_0_CODECJPEGDEC_H
18 
19 #include <map>
20 #include <mutex>
21 #include "buffer_handle.h"
22 #include "codec_jpeg_core.h"
23 #include "codec_image_config.h"
24 constexpr uint32_t CODEC_IMAGE_MAX_BUFFER_SIZE = 50 * 1024 *1024;
25 namespace OHOS {
26 namespace HDI {
27 namespace Codec {
28 namespace Image {
29 namespace V1_0 {
30 class CodecJpegDecoder : public ICodecImageJpeg {
31 public:
32     explicit CodecJpegDecoder();
33 
34     virtual ~CodecJpegDecoder() = default;
35 
36     int32_t GetImageCapability(std::vector<CodecImageCapability>& capList) override;
37 
38     int32_t JpegInit() override;
39 
40     int32_t JpegDeInit() override;
41 
42     int32_t DoJpegDecode(const CodecImageBuffer& inBuffer, const CodecImageBuffer& outBuffer,
43         const sptr<ICodecImageCallback>& callbacks, const CodecJpegDecInfo& decInfo) override;
44 
45     int32_t AllocateInBuffer(CodecImageBuffer& inBuffer, uint32_t size) override;
46 
47     int32_t FreeInBuffer(const CodecImageBuffer& buffer) override;
48 
49 private:
50     uint32_t GetNextBufferId();
51 
52 private:
53     uint32_t bufferId_;
54     std::mutex mutex_;
55     std::unique_ptr<CodecJpegCore> core_;
56     std::map<uint32_t, BufferHandle*> bufferHandleMap_;
57 };
58 } // V1_0
59 } // Image
60 } // Codec
61 } // HDI
62 } // OHOS
63 
64 #endif // OHOS_HDI_CODEC_V1_0_CODECJPEGDEC_H
65