• 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_V2_1_CODECJPEGSERVICE_H
17 #define OHOS_HDI_CODEC_V2_1_CODECJPEGSERVICE_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 
25 namespace OHOS {
26 namespace HDI {
27 namespace Codec {
28 namespace Image {
29 namespace V2_1 {
30 class CodecJpegService {
31 public:
32     explicit CodecJpegService();
33 
34     ~CodecJpegService() = default;
35 
36     void NotifyJpegPowerOn();
37 
38     int32_t JpegInit();
39 
40     int32_t JpegDeInit();
41 
42     int32_t DoJpegDecode(const CodecImageBuffer& inBuffer, const CodecImageBuffer& outBuffer,
43         const CodecJpegDecInfo& decInfo);
44 
45     int32_t AllocateJpegInBuffer(CodecImageBuffer& inBuffer, uint32_t size);
46 
47     int32_t FreeJpegInBuffer(const CodecImageBuffer& buffer);
48 
49 private:
50     uint32_t GetNextBufferId();
51 
52 private:
53     uint32_t bufferId_;
54     std::mutex mutex_;
55     std::mutex initMutex_;
56     std::unique_ptr<CodecJpegCore> core_;
57 };
58 } // V2_1
59 } // Image
60 } // Codec
61 } // HDI
62 } // OHOS
63 
64 #endif // OHOS_HDI_CODEC_V2_1_CODECJPEGSERVICE_H
65