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