1 /*
2  * Copyright (c) 2023 Shenzhen Kaihong DID 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 #ifndef HDI_JPEG_IMPL_H
16 #define HDI_JPEG_IMPL_H
17 #include <cinttypes>
18 #include <codec_jpeg_vdi.h>
19 #include "hdi_mpp_mpi.h"
20 #include "idisplay_buffer_vdi.h"
21 #include "v1_0/display_buffer_type.h"
22 namespace OHOS {
23 namespace VDI {
24 namespace JPEG {
25 using namespace OHOS::HDI::Display::Buffer::V1_0;
26 class CodecJpegImpl {
27 public:
28     explicit CodecJpegImpl();
29 
30     ~CodecJpegImpl();
31 
32     int32_t Init();
33 
34     void DeInit();
35 
36     int32_t AllocateBuffer(BufferHandle **buffer, uint32_t size);
37 
38     int32_t FreeBuffer(BufferHandle *buffer);
39 
40     int32_t DeCode(BufferHandle *buffer, BufferHandle *outBuffer, const struct CodecJpegDecInfo &decInfo);
41 
42 private:
AlignUp(uint32_t val, uint32_t align)43     inline uint32_t AlignUp(uint32_t val, uint32_t align)
44     {
45         return (val + align - 1) & (~(align - 1));
46     }
47 private:
48     static RKMppApi *mppApi_;
49     static IDisplayBufferVdi* displayVdi_;
50     static intptr_t libHandle_;
51 };
52 }  // namespace JPEG
53 }  // namespace VDI
54 }  // namespace OHOS
55 #endif  // HDI_JPEG_DECODER_H
56