• 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 CODEC_JPEG_VDI_H
17 #define CODEC_JPEG_VDI_H
18 
19 #include <vector>
20 #include "buffer_handle.h"
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #define CODEC_JPEG_VDI_LIB_NAME "libjpeg_vdi_impl.z.so"
26 
27 struct ICodecJpegHwi {
28     int32_t (*JpegInit)();
29 
30     int32_t (*JpegDeInit)();
31 
32     int32_t (*AllocateInBuffer)(BufferHandle **buffer, uint32_t size);
33 
34     int32_t (*FreeInBuffer)(BufferHandle *buffer);
35 
36     int32_t (*DoJpegDecode)(BufferHandle *buffer, BufferHandle *outBuffer, const struct CodecJpegDecInfo *decInfo);
37 
38     void (*NotifyPowerOn)();
39 };
40 
41 struct CodecImageRegion {
42     uint32_t left;
43     uint32_t right;
44     uint32_t top;
45     uint32_t bottom;
46     uint32_t flag;
47     uint32_t rsv;
48 };
49 
50 struct CodecJpegQuantTable {
51     std::vector<uint16_t> quantVal;
52     bool tableFlag;
53 };
54 
55 struct CodecJpegHuffTable {
56     std::vector<uint8_t> bits;
57     std::vector<uint8_t> huffVal;
58     bool tableFlag;
59 };
60 struct CodecJpegCompInfo {
61     uint32_t componentId;
62     uint32_t componentIndex;
63     uint32_t hSampFactor;
64     uint32_t vSampFactor;
65     uint32_t quantTableNo;
66     uint32_t dcTableNo;
67     uint32_t acTableNo;
68     bool infoFlag;
69 };
70 
71 struct CodecJpegDecInfo {
72     uint32_t imageWidth;
73     uint32_t imageHeight;
74     uint32_t dataPrecision;
75     uint32_t numComponents;
76     uint32_t restartInterval;
77     bool arithCode;
78     bool progressiveMode;
79     std::vector<CodecJpegCompInfo> compInfo;
80     std::vector<CodecJpegHuffTable> dcHuffTbl;
81     std::vector<CodecJpegHuffTable> acHuffTbl;
82     std::vector<CodecJpegQuantTable> quantTbl;
83     struct CodecImageRegion region;
84     unsigned int sampleSize;
85     unsigned int compressPos;
86 };
87 
88 struct ICodecJpegHwi *GetCodecJpegHwi(void);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 #endif /* CODEC_JPEG_VDI_H */
94