1 /*===================== begin_copyright_notice ================================== 2 3 # Copyright (c) 2020-2022, Intel Corporation 4 5 # Permission is hereby granted, free of charge, to any person obtaining a 6 # copy of this software and associated documentation files (the "Software"), 7 # to deal in the Software without restriction, including without limitation 8 # the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 # and/or sell copies of the Software, and to permit persons to whom the 10 # Software is furnished to do so, subject to the following conditions: 11 12 # The above copyright notice and this permission notice shall be included 13 # in all copies or substantial portions of the Software. 14 15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 # OTHER DEALINGS IN THE SOFTWARE. 22 23 ======================= end_copyright_notice ==================================*/ 24 25 26 //! 27 //! \file codechal_vdenc_vp9_xe_hpm.h 28 //! \brief This file defines the base C++ class/interface for Xe_XPM VP9 VDENC 29 //! encoding to be used across CODECHAL components. 30 //! 31 32 #ifndef __CODECHAL_VDENC_VP9_XE_XPM_H__ 33 #define __CODECHAL_VDENC_VP9_XE_XPM_H__ 34 35 #include "codechal_vdenc_vp9_g12.h" 36 37 #define MAX_PAK_NUM 8 38 39 class CodechalVdencVp9StateXe_Xpm : public CodechalVdencVp9StateG12 40 { 41 public: 42 //! 43 //! \brief Constructor 44 //! CodechalVdencVp9StateXe_Xpm(CodechalHwInterface * hwInterface,CodechalDebugInterface * debugInterface,PCODECHAL_STANDARD_INFO standardInfo)45 CodechalVdencVp9StateXe_Xpm( 46 CodechalHwInterface * hwInterface, 47 CodechalDebugInterface *debugInterface, 48 PCODECHAL_STANDARD_INFO standardInfo) : CodechalVdencVp9StateG12(hwInterface, debugInterface, standardInfo){}; 49 50 //! 51 //! \brief Destructor 52 //! 53 virtual ~CodechalVdencVp9StateXe_Xpm(); 54 55 virtual MOS_STATUS SetTileCommands( 56 PMOS_COMMAND_BUFFER cmdBuffer) override; // override this function to add new cmd 57 58 MOS_STATUS SetSequenceStructs() override; 59 MOS_STATUS HuCBrcInitReset() override; 60 61 //! 62 //! \struct HucPakStitchDmemEncXehp 63 //! \brief The struct of Huc Com Dmem 64 //! 65 struct HucPakIntDmemXehp 66 { 67 uint32_t tileSizeRecordOffset[MAX_PAK_NUM + 1]; // Tile Size Records, start offset in byte, 0xffffffff means unavailable 68 uint32_t vdencStatOffset[MAX_PAK_NUM + 1]; // needed for HEVC VDEnc, VP9 VDEnc, start offset in byte, 0xffffffff means unavailable 69 uint32_t hevcPakStatOffset[MAX_PAK_NUM + 1]; // needed for HEVC VDEnc, start offset in byte, 0xffffffff means unavailable 70 uint32_t hevcStreamoutOffset[MAX_PAK_NUM + 1]; // needed for HEVC VDEnc, start offset in byte, 0xffffffff means unavailable 71 uint32_t vp9PakStatOffset[MAX_PAK_NUM + 1]; // needed for VP9 VDEnc, start offset in byte, 0xffffffff means unavailable 72 uint32_t vp9CounterBufferOffset[MAX_PAK_NUM + 1]; // needed for VP9 VDEnc, start offset in byte, 0xffffffff means unavailable 73 uint32_t lastTileBSStartInBytes; // last tile in bitstream for region 4 and region 5 74 uint32_t SliceHeaderSizeinBits; // needed for HEVC dual pipe BRC 75 uint16_t totalSizeInCommandBuffer; // Total size in bytes of valid data in the command buffer 76 uint16_t offsetInCommandBuffer; // Byte offset of the to-be-updated Length (uint32_t ) in the command buffer, 0xffff means unavailable 77 uint16_t picWidthInPixel; // Picture width in pixel 78 uint16_t picHeightInPixel; // Picture hieght in pixel 79 uint16_t totalNumberOfPaks; // [2..4] for Gen11 80 uint16_t numSlices[MAX_PAK_NUM]; // this is number of slices in each PAK 81 uint16_t numTilesPerPipe[MAX_PAK_NUM]; // this is number of tiles from each PAK 82 uint16_t picStateStartInBytes; // offset for region 7 and region 8 83 uint8_t codec; // 1: HEVC DP; 2: HEVC VDEnc; 3: VP9 VDEnc 84 uint8_t maxPass; // Max number of BRC pass >=1 85 uint8_t currentPass; // Current BRC pass [1..MAXPass] 86 uint8_t minCUSize; // Minimum CU size (3: 8x8, 4:16x16), HEVC only. 87 uint8_t cabacZeroWordFlag; // Cabac zero flag, HEVC only 88 uint8_t bitdepthLuma; // luma bitdepth, HEVC only 89 uint8_t bitdepthChroma; // chroma bitdepth, HEVC only 90 uint8_t chromaFormatIdc; // chroma format idc, HEVC only 91 uint8_t currFrameBRClevel; // Hevc dual pipe only 92 uint8_t brcUnderFlowEnable; // Hevc dual pipe only 93 uint8_t StitchEnable; // enable stitch cmd for Hevc dual pipe 94 uint8_t reserved1; 95 uint16_t StitchCommandOffset; // offset in region 10 which is the second level batch buffer 96 uint16_t reserved2; 97 uint32_t BBEndforStitch; 98 uint8_t RSVD[32]; 99 }; 100 101 static constexpr uint32_t m_pakIntDmemOffsetsSize = 216;//First six offsets are set to 0xFF as unavailable. See details in HucPakIntDmemXehp struct. 102 103 MOS_STATUS SetDmemHuCPakInt() override; 104 MOS_STATUS HuCVp9PakInt( 105 PMOS_COMMAND_BUFFER cmdBuffer) override; 106 MOS_STATUS AllocateResources() override; 107 108 MOS_STATUS SetupSegmentationStreamIn() override; 109 MOS_STATUS SetCurbeMe( 110 MeCurbeParams *params) override; 111 112 /*#if USE_CODECHAL_DEBUG_TOOL 113 MOS_STATUS PopulateDdiParam( 114 PCODEC_VP9_ENCODE_SEQUENCE_PARAMS vp9SeqParams, 115 _CODEC_VP9_ENCODE_PIC_PARAMS vp9PicParams) override; 116 #endif*/ 117 118 MOS_STATUS Initialize(CodechalSetting * settings) override; 119 120 MOS_STATUS ConstructPicStateBatchBuf( 121 PMOS_RESOURCE picStateBuffer) override; 122 123 MOS_STATUS CheckHucLoadStatus(); 124 MOS_STATUS PackHucAuthCmds(MOS_COMMAND_BUFFER &cmdBuffer); 125 126 //Resources 127 MOS_RESOURCE m_hucAuthBuf = {}; //!< Huc authentication buffer 128 MHW_BATCH_BUFFER m_2ndLevelBB[CODECHAL_ENCODE_RECYCLED_BUFFER_NUM] = {}; //!< 2nd level batch buffer 129 PMHW_BATCH_BUFFER m_batchBuf = nullptr; 130 }; 131 132 #endif // __CODECHAL_VDENC_VP9_XE_XPM_H__ 133