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