1 /* 2 * Copyright (c) 2021, Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 //! 23 //! \file decode_jpeg_basic_feature.h 24 //! \brief Defines the common interface for decode jpeg basic feature 25 //! 26 #ifndef __DECODE_JPEG_BASIC_FEATURE_H__ 27 #define __DECODE_JPEG_BASIC_FEATURE_H__ 28 29 #include "decode_basic_feature.h" 30 #include "codec_def_common_jpeg.h" 31 32 namespace decode { 33 34 #define CODECHAL_DECODE_JPEG_BLOCK_ALIGN_SIZE 8 35 #define CODECHAL_DECODE_JPEG_BLOCK_ALIGN_SIZE_X2 16 36 #define CODECHAL_DECODE_JPEG_BLOCK_ALIGN_SIZE_X4 32 37 #define CODECHAL_DECODE_JPEG_ERR_FRAME_WIDTH 32 38 #define CODECHAL_DECODE_JPEG_ERR_FRAME_HEIGHT 32 39 40 #define MAX_NUM_HUFF_TABLE_INDEX 2 41 42 class JpegBasicFeature : public DecodeBasicFeature 43 { 44 public: 45 //! 46 //! \brief JpegBasicFeature constructor 47 //! JpegBasicFeature(DecodeAllocator * allocator,void * hwInterface,PMOS_INTERFACE osInterface)48 JpegBasicFeature(DecodeAllocator *allocator, void *hwInterface, PMOS_INTERFACE osInterface) : 49 DecodeBasicFeature(allocator, hwInterface, osInterface) 50 { 51 MOS_ZeroMemory(&m_jpegHuffmanTable, sizeof(m_jpegHuffmanTable)); 52 if (osInterface != nullptr) 53 { 54 m_osInterface = osInterface; 55 } 56 }; 57 58 //! 59 //! \brief JpegBasicFeature deconstructor 60 //! 61 virtual ~JpegBasicFeature(); 62 63 //! 64 //! \brief Initialize Jpeg basic feature CodechalSetting 65 //! \return MOS_STATUS 66 //! MOS_STATUS_SUCCESS if success, else fail reason 67 //! 68 virtual MOS_STATUS Init(void *setting) override; 69 70 //! 71 //! \brief Update Jpeg decodeParams 72 //! \return MOS_STATUS 73 //! MOS_STATUS_SUCCESS if success, else fail reason 74 //! 75 virtual MOS_STATUS Update(void *params) override; 76 77 // App must use 420_OPAQUE as DecodeRT for other JPEG output formats except NV12 and YUY2 due to runtime 78 // restriction, so the real JPEG format is passed to driver in PPS data. The code here is just to get the real output format. 79 // On SKL+, app would use AYUV (instead of 420_OPAQUE) as DecodeRT for direct YUV to ARGB8888 conversion; in such case, 80 // real output format (ARGB8888) should also be from JPEG PPS; MSDK would handle the details of treating AYUV as ARGB. 81 virtual void GetRenderTargetFormat(PMOS_FORMAT format); 82 83 CodecDecodeJpegPicParams *m_jpegPicParams = nullptr; //!< Pointer to Jpeg picture parameter 84 85 // uint32_t m_dataSize; //!< Data size of the bitstream 86 // uint32_t m_dataOffset; //!< Data offset of the bitstream 87 CodecDecodeJpegScanParameter * m_jpegScanParams = nullptr; //!< Scan parameter for JPEG 88 CodecJpegQuantMatrix * m_jpegQMatrix = nullptr; //!< QMatrix for JPEG 89 PCODECHAL_DECODE_JPEG_HUFFMAN_TABLE m_jpegHuffmanTable; //!< Huffman table for JPEG 90 91 92 protected: 93 MOS_STATUS SetPictureStructs(); 94 MOS_STATUS CheckSupportedFormat(PMOS_FORMAT format); 95 virtual MOS_STATUS SetRequiredBitstreamSize(uint32_t requiredSize) override; 96 97 PMOS_INTERFACE m_osInterface = nullptr; 98 99 MEDIA_CLASS_DEFINE_END(decode__JpegBasicFeature) 100 }; 101 102 }//decode 103 104 #endif // !__DECODE_JPEG_BASIC_FEATURE_H__ 105