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 39 struct CodecImageRegion { 40 uint32_t left; 41 uint32_t right; 42 uint32_t top; 43 uint32_t bottom; 44 uint32_t flag; 45 uint32_t rsv; 46 }; 47 48 struct CodecJpegQuantTable { 49 std::vector<uint16_t> quantVal; 50 bool tableFlag; 51 }; 52 53 struct CodecJpegHuffTable { 54 std::vector<uint8_t> bits; 55 std::vector<uint8_t> huffVal; 56 bool tableFlag; 57 }; 58 struct CodecJpegCompInfo { 59 uint32_t componentId; 60 uint32_t componentIndex; 61 uint32_t hSampFactor; 62 uint32_t vSampFactor; 63 uint32_t quantTableNo; 64 uint32_t dcTableNo; 65 uint32_t acTableNo; 66 bool infoFlag; 67 }; 68 69 struct CodecJpegDecInfo { 70 uint32_t imageWidth; 71 uint32_t imageHeight; 72 uint32_t dataPrecision; 73 uint32_t numComponents; 74 uint32_t restartInterval; 75 bool arithCode; 76 bool progressiveMode; 77 std::vector<CodecJpegCompInfo> compInfo; 78 std::vector<CodecJpegHuffTable> dcHuffTbl; 79 std::vector<CodecJpegHuffTable> acHuffTbl; 80 std::vector<CodecJpegQuantTable> quantTbl; 81 struct CodecImageRegion region; 82 unsigned int sampleSize; 83 unsigned int compressPos; 84 }; 85 86 struct ICodecJpegHwi *GetCodecJpegHwi(void); 87 88 #ifdef __cplusplus 89 } 90 #endif 91 #endif /* CODEC_JPEG_VDI_H */ 92