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_DECODER_H 16 #define HDI_JPEG_DECODER_H 17 #include <cinttypes> 18 #include <codec_jpeg_vdi.h> 19 #include "hdi_mpp_mpi.h" 20 namespace OHOS { 21 namespace VDI { 22 namespace JPEG { 23 class CodecJpegDecoder { 24 public: 25 explicit CodecJpegDecoder(RKMppApi *mppApi); 26 27 ~CodecJpegDecoder(); 28 29 int32_t DeCode(BufferHandle *buffer, BufferHandle *outBuffer, const struct CodecJpegDecInfo &decInfo); 30 31 private: 32 void Destory(); 33 34 void ResetMppBuffer(); 35 36 bool PrePare(bool isDecoder = true); 37 AlignUp(uint32_t val, uint32_t align)38 inline uint32_t AlignUp(uint32_t val, uint32_t align) 39 { 40 return (val + align - 1) & (~(align - 1)); 41 } 42 43 MPP_RET SendData(const struct CodecJpegDecInfo &decInfo, BufferHandle* buffer, BufferHandle *outHandle); 44 45 MPP_RET MppTaskProcess(); 46 47 MPP_RET GetFrame(); 48 49 void DumpOutFile(); 50 51 void DumpInFile(MppBuffer pktBuf); 52 53 bool SetFormat(int32_t format); 54 55 private: 56 uint32_t width_; 57 uint32_t height_; 58 MppFrameFormat format_; 59 MppCtx mppCtx_; 60 MppApi *mpi_; 61 RKMppApi *mppApi_; 62 MppBufferGroup memGroup_; 63 MppPacket packet_; 64 MppFrame frame_; 65 }; 66 } // namespace JPEG 67 } // namespace VDI 68 } // namespace OHOS 69 #endif // HDI_JPEG_DECODER_H 70