1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci 16094332d3Sopenharmony_ci#ifndef CODEC_JPEG_VDI_H 17094332d3Sopenharmony_ci#define CODEC_JPEG_VDI_H 18094332d3Sopenharmony_ci 19094332d3Sopenharmony_ci#include <vector> 20094332d3Sopenharmony_ci#include "buffer_handle.h" 21094332d3Sopenharmony_ci#ifdef __cplusplus 22094332d3Sopenharmony_ciextern "C" { 23094332d3Sopenharmony_ci#endif 24094332d3Sopenharmony_ci 25094332d3Sopenharmony_ci#define CODEC_JPEG_VDI_LIB_NAME "libjpeg_vdi_impl.z.so" 26094332d3Sopenharmony_ci 27094332d3Sopenharmony_cistruct ICodecJpegHwi { 28094332d3Sopenharmony_ci int32_t (*JpegInit)(); 29094332d3Sopenharmony_ci 30094332d3Sopenharmony_ci int32_t (*JpegDeInit)(); 31094332d3Sopenharmony_ci 32094332d3Sopenharmony_ci int32_t (*AllocateInBuffer)(BufferHandle **buffer, uint32_t size); 33094332d3Sopenharmony_ci 34094332d3Sopenharmony_ci int32_t (*FreeInBuffer)(BufferHandle *buffer); 35094332d3Sopenharmony_ci 36094332d3Sopenharmony_ci int32_t (*DoJpegDecode)(BufferHandle *buffer, BufferHandle *outBuffer, const struct CodecJpegDecInfo *decInfo); 37094332d3Sopenharmony_ci}; 38094332d3Sopenharmony_ci 39094332d3Sopenharmony_cistruct CodecImageRegion { 40094332d3Sopenharmony_ci uint32_t left; 41094332d3Sopenharmony_ci uint32_t right; 42094332d3Sopenharmony_ci uint32_t top; 43094332d3Sopenharmony_ci uint32_t bottom; 44094332d3Sopenharmony_ci uint32_t flag; 45094332d3Sopenharmony_ci uint32_t rsv; 46094332d3Sopenharmony_ci}; 47094332d3Sopenharmony_ci 48094332d3Sopenharmony_cistruct CodecJpegQuantTable { 49094332d3Sopenharmony_ci std::vector<uint16_t> quantVal; 50094332d3Sopenharmony_ci bool tableFlag; 51094332d3Sopenharmony_ci}; 52094332d3Sopenharmony_ci 53094332d3Sopenharmony_cistruct CodecJpegHuffTable { 54094332d3Sopenharmony_ci std::vector<uint8_t> bits; 55094332d3Sopenharmony_ci std::vector<uint8_t> huffVal; 56094332d3Sopenharmony_ci bool tableFlag; 57094332d3Sopenharmony_ci}; 58094332d3Sopenharmony_cistruct CodecJpegCompInfo { 59094332d3Sopenharmony_ci uint32_t componentId; 60094332d3Sopenharmony_ci uint32_t componentIndex; 61094332d3Sopenharmony_ci uint32_t hSampFactor; 62094332d3Sopenharmony_ci uint32_t vSampFactor; 63094332d3Sopenharmony_ci uint32_t quantTableNo; 64094332d3Sopenharmony_ci uint32_t dcTableNo; 65094332d3Sopenharmony_ci uint32_t acTableNo; 66094332d3Sopenharmony_ci bool infoFlag; 67094332d3Sopenharmony_ci}; 68094332d3Sopenharmony_ci 69094332d3Sopenharmony_cistruct CodecJpegDecInfo { 70094332d3Sopenharmony_ci uint32_t imageWidth; 71094332d3Sopenharmony_ci uint32_t imageHeight; 72094332d3Sopenharmony_ci uint32_t dataPrecision; 73094332d3Sopenharmony_ci uint32_t numComponents; 74094332d3Sopenharmony_ci uint32_t restartInterval; 75094332d3Sopenharmony_ci bool arithCode; 76094332d3Sopenharmony_ci bool progressiveMode; 77094332d3Sopenharmony_ci std::vector<CodecJpegCompInfo> compInfo; 78094332d3Sopenharmony_ci std::vector<CodecJpegHuffTable> dcHuffTbl; 79094332d3Sopenharmony_ci std::vector<CodecJpegHuffTable> acHuffTbl; 80094332d3Sopenharmony_ci std::vector<CodecJpegQuantTable> quantTbl; 81094332d3Sopenharmony_ci struct CodecImageRegion region; 82094332d3Sopenharmony_ci unsigned int sampleSize; 83094332d3Sopenharmony_ci unsigned int compressPos; 84094332d3Sopenharmony_ci}; 85094332d3Sopenharmony_ci 86094332d3Sopenharmony_cistruct ICodecJpegHwi *GetCodecJpegHwi(void); 87094332d3Sopenharmony_ci 88094332d3Sopenharmony_ci#ifdef __cplusplus 89094332d3Sopenharmony_ci} 90094332d3Sopenharmony_ci#endif 91094332d3Sopenharmony_ci#endif /* CODEC_JPEG_VDI_H */ 92