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_CODECJPEGCORE_H 17 #define OHOS_HDI_CODEC_V1_0_CODECJPEGCORE_H 18 19 #include "codec_jpeg_vdi.h" 20 #include "v1_0/icodec_image_jpeg.h" 21 22 namespace OHOS { 23 namespace HDI { 24 namespace Codec { 25 namespace Image { 26 class CodecJpegCore { 27 public: 28 using GetCodecJpegHwi = ICodecJpegHwi*(*)(); 29 30 explicit CodecJpegCore(); 31 32 ~CodecJpegCore(); 33 34 int32_t Init(); 35 36 int32_t DeInit(); 37 38 int32_t AllocateInBuffer(BufferHandle **buffer, uint32_t size); 39 40 int32_t FreeInBuffer(BufferHandle *buffer); 41 42 int32_t DoDecode(BufferHandle *buffer, BufferHandle *outBuffer, const V1_0::CodecJpegDecInfo *decInfo, 43 const OHOS::sptr<V1_0::ICodecImageCallback> callbacks, int fenceFd); 44 45 static int32_t OnEvent(int32_t error); 46 47 private: 48 void AddVendorLib(); 49 50 static int32_t SyncWait(int fd); 51 52 private: 53 void *libHandle_ = nullptr; 54 GetCodecJpegHwi getCodecJpegHwi_ = nullptr; 55 ICodecJpegHwi *JpegHwi_ = nullptr; 56 struct CodecJpegCallbackHwi vdiCallback_; 57 static int fence_; 58 static OHOS::sptr<V1_0::ICodecImageCallback> callback_; 59 }; 60 } // Image 61 } // Codec 62 } // HDI 63 } // OHOS 64 65 #endif // OHOS_HDI_CODEC_V1_0_CODECJPEGCORE_H 66