1 /* 2 * Copyright (c) 2019-2020, 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 encode_hevc_dss.h 24 //! \brief Defines the common interface for hevc encode dynamic slice feature 25 //! 26 27 #ifndef __ENCODE_HEVC_DSS_H__ 28 #define __ENCODE_HEVC_DSS_H__ 29 30 #include "media_feature.h" 31 #include "encode_allocator.h" 32 #include "codec_hw_next.h" 33 #include "encode_basic_feature.h" 34 #include "encode_pipeline.h" 35 #include "encode_status_report.h" 36 37 #define ENCODE_HEVC_MIN_DSS_PIC_WIDTH 480 38 #define ENCODE_HEVC_MIN_DSS_PIC_HEIGHT 320 39 40 namespace encode 41 { 42 class HevcEncodeDss : public MediaFeature 43 { 44 public: 45 HevcEncodeDss(MediaFeatureManager *featureManager, EncodeAllocator *allocator, CodechalHwInterfaceNext *hwInterface, void *constSettings); 46 ~HevcEncodeDss()47 ~HevcEncodeDss() {} 48 49 //! 50 //! \brief Init cqp basic features related parameter 51 //! \param [in] settings 52 //! Pointer to settings 53 //! \return MOS_STATUS 54 //! MOS_STATUS_SUCCESS if success, else fail reason 55 //! 56 MOS_STATUS Init(void *settings); 57 58 //! 59 //! \brief Update cqp basic features related parameter 60 //! \param [in] params 61 //! Pointer to parameters 62 //! \return MOS_STATUS 63 //! MOS_STATUS_SUCCESS if success, else fail reason 64 //! 65 MOS_STATUS Update(void *params); 66 67 //! 68 //! \brief Add command to read the HCP status 69 //! 70 //! \param [in] vdboxIndex 71 //! Index of vdbox 72 //! \param [in] statusReport 73 //! Encode status report 74 //! \param [in, out] cmdBuffer 75 //! Command buffer 76 //! 77 //! \return MOS_STATUS 78 //! MOS_STATUS_SUCCESS if success, else fail reason 79 //! 80 MOS_STATUS ReadHcpStatus( 81 MHW_VDBOX_NODE_IND vdboxIndex, 82 MOS_COMMAND_BUFFER &cmdBuffer); 83 84 MOS_STATUS ReadSliceSizeForSinglePipe(EncodePipeline *pipeline, MOS_COMMAND_BUFFER &cmdBuffer); 85 86 MOS_STATUS ReadSliceSize(EncodePipeline *pipeline, MOS_COMMAND_BUFFER &cmdBuffer); 87 88 MOS_STATUS CopyDataBlock( 89 PMOS_RESOURCE sourceSurface, 90 uint32_t sourceOffset, 91 PMOS_RESOURCE destSurface, 92 uint32_t destOffset, 93 uint32_t copySize, 94 MOS_COMMAND_BUFFER &cmdBuffer); 95 96 MOS_STATUS GetDssBuffer(PMOS_RESOURCE &resSliceCountBuffer, PMOS_RESOURCE &resVDEncModeTimerBuffer); 97 98 protected: 99 //! \brief Allocate feature related resources 100 //! \return MOS_STATUS 101 //! MOS_STATUS_SUCCESS if success, else fail reason 102 //! 103 virtual MOS_STATUS AllocateResources(); 104 105 // Parameters passed from application 106 const CODEC_HEVC_ENCODE_PICTURE_PARAMS * m_hevcPicParams = nullptr; //!< Pointer to picture parameter 107 const CODEC_HEVC_ENCODE_SEQUENCE_PARAMS *m_hevcSeqParams = nullptr; //!< Pointer to sequence parameter 108 const CODEC_HEVC_ENCODE_SLICE_PARAMS * m_hevcSliceParams = nullptr; //!< Pointer to slice parameter 109 EncodeAllocator * m_allocator = nullptr; 110 CodechalHwInterfaceNext * m_hwInterface = nullptr; 111 EncodeBasicFeature * m_basicFeature = nullptr; //!< EncodeBasicFeature 112 MOS_RESOURCE m_resSliceReport[CODECHAL_ENCODE_STATUS_NUM] = {}; 113 PMOS_RESOURCE m_resSliceCountBuffer = nullptr; //!< Resource of slice count buffer 114 PMOS_RESOURCE m_resVDEncModeTimerBuffer = nullptr; //!< Resource of Vdenc mode timer buffer 115 HEVC_TILE_STATS_INFO m_hevcTileStatsOffset = {}; 116 117 std::shared_ptr<mhw::vdbox::hcp::Itf> m_hcpItf = nullptr; 118 std::shared_ptr<mhw::mi::Itf> m_miItf = nullptr; 119 std::shared_ptr<mhw::vdbox::vdenc::Itf> m_vdencItf = nullptr; 120 121 MEDIA_CLASS_DEFINE_END(encode__HevcEncodeDss) 122 }; 123 124 } 125 #endif 126