1 /* 2 * Copyright (c) 2017, 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 codec_def_common_jpeg.h 24 //! \brief Defines basic JPEG types and macros shared by CodecHal, MHW, and DDI layer 25 //! \details This is the base header for all codec_def JPEG files. All codec_def JPEG files should include this file which should not contain any DDI specific code. 26 //! 27 #ifndef __CODEC_DEF_COMMON_JPEG_H__ 28 #define __CODEC_DEF_COMMON_JPEG_H__ 29 30 #include "codec_def_common.h" 31 32 #define JPEG_MAX_NUM_HUFF_TABLE_INDEX 2 // For baseline only allowed 2, else could have 4. 33 #define JPEG_NUM_QUANTMATRIX 64 // Elements of 8x8 matrix in zig-zag scan order. 34 #define JPEG_MAX_NUM_OF_QUANTMATRIX 4 // JPEG decoders can store up to 4 different quantization matrix 35 36 #define JPEG_NUM_HUFF_TABLE_DC_BITS 12 // Huffman Table DC BITS 37 #define JPEG_NUM_HUFF_TABLE_DC_HUFFVAL 12 // Huffman Table DC HUFFVAL 38 #define JPEG_NUM_HUFF_TABLE_AC_BITS 16 // Huffman Table AC BITS 39 #define JPEG_NUM_HUFF_TABLE_AC_HUFFVAL 162 // Huffman Table AC HUFFVAL 40 41 //! 42 //! \enum CodecJpegComponents 43 //! \brief JPEG Component Types 44 //! 45 enum CodecJpegComponents 46 { 47 jpegComponentY = 0, //!< Component Y 48 jpegComponentU = 1, //!< Component U 49 jpegComponentV = 2, //!< Component V 50 jpegNumComponent = 3, //!< Component number 51 }; 52 53 //! 54 //! \struct CodecJpegQuantMatrix 55 //! \brief JPEG Quantization Matrix 56 //! 57 struct CodecJpegQuantMatrix 58 { 59 uint32_t m_jpegQMTableType[JPEG_MAX_NUM_OF_QUANTMATRIX]; //!< Quant Matrix table type 60 uint8_t m_quantMatrix[JPEG_MAX_NUM_OF_QUANTMATRIX][JPEG_NUM_QUANTMATRIX]; //!< Quant Matrix 61 }; 62 63 //! 64 //! \struct CodecDecodeJpegPicParams 65 //! \brief Picture Paramters buffer structure for JPEG Decode 66 //! 67 struct CodecDecodeJpegPicParams 68 { 69 CODEC_PICTURE m_destPic; //!< Destination Picture 70 uint16_t m_frameWidth; //!< Frame Width 71 uint16_t m_frameHeight; //!< Frame Height 72 uint16_t m_numCompInFrame; //!< Component Number in Frame 73 uint8_t m_componentIdentifier[jpegNumComponent]; //!< Component identifier 74 uint8_t m_quantTableSelector[jpegNumComponent]; //!< Quant table selector 75 uint8_t m_chromaType; //!< Chroma Type 76 uint8_t m_rotation; //!< Rotation type. 77 //! 0: no rotation, 78 //! 1: rotate clockwise 90 degree, 79 //! 2: rotate counter-clockwise 90 degree (same as rotating 270 degree clockwise) 80 //! 3: rotate 180 degree (NOT the same as flipped on the x-axis) 81 //! 82 83 uint16_t m_totalScans; //!< total scans 84 85 uint32_t m_interleavedData : 1; //!< Interleaved data 86 uint32_t m_reserved : 31; //!< Reserved bits 87 88 uint32_t m_statusReportFeedbackNumber; //!< Status report feedback number 89 uint32_t m_renderTargetFormat; //!< Render target format 90 }; 91 92 //! 93 //! \struct _CODECHAL_DECODE_JPEG_HUFFMAN_TABLE 94 //! \brief typedef of struct Huffman Table used by JPEG 95 //! Note: Some DDIs have no HuffTable selector and are based on Component type 96 //! 97 typedef struct _CODECHAL_DECODE_JPEG_HUFFMAN_TABLE 98 { 99 struct 100 { 101 uint8_t DC_BITS[JPEG_NUM_HUFF_TABLE_DC_BITS]; //!< DC number of Huffman codes length 102 uint8_t DC_HUFFVAL[JPEG_NUM_HUFF_TABLE_DC_HUFFVAL]; //!< DC value of Huffman codes 103 uint8_t AC_BITS[JPEG_NUM_HUFF_TABLE_AC_BITS]; //!< AC number of Huffman codes length 104 uint8_t AC_HUFFVAL[JPEG_NUM_HUFF_TABLE_AC_HUFFVAL]; //!< AC value of Huffman codes 105 } HuffTable[JPEG_MAX_NUM_HUFF_TABLE_INDEX]; 106 } CODECHAL_DECODE_JPEG_HUFFMAN_TABLE, *PCODECHAL_DECODE_JPEG_HUFFMAN_TABLE; 107 108 #endif // __CODEC_DEF_COMMON_JPEG_H__ 109