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 encode_const_settings.h 24 //! \brief 25 //! \details 26 //! 27 28 #ifndef __ENCODE_CONST_SETTINGS_H__ 29 #define __ENCODE_CONST_SETTINGS_H__ 30 31 #include <array> 32 #include <vector> 33 #include <functional> 34 #include "media_feature_const_settings.h" 35 #include "encode_utils.h" 36 #include "mhw_vdbox_vdenc_cmdpar.h" 37 38 struct VdencFeatureSettings: MediaFeatureSettings 39 { ~VdencFeatureSettingsVdencFeatureSettings40 virtual ~VdencFeatureSettings(){}; 41 42 std::vector< 43 std::function< 44 MOS_STATUS(mhw::vdbox::vdenc::_MHW_PAR_T(VDENC_STREAMIN_STATE) & par, bool cu64Align)> > 45 vdencStreaminStateSettings; 46 47 std::vector< 48 std::function< 49 MOS_STATUS(mhw::vdbox::vdenc::_MHW_PAR_T(VDENC_CMD1) & par, bool isLowDelay)> > 50 vdencCmd1Settings; 51 52 std::vector< 53 std::function< 54 MOS_STATUS(mhw::vdbox::vdenc::_MHW_PAR_T(VDENC_CMD2) & par, bool isLowDelay)> > 55 vdencCmd2Settings; 56 57 std::vector< 58 std::function< 59 MOS_STATUS(mhw::vdbox::vdenc::_MHW_PAR_T(VDENC_CMD3) & par)> > 60 vdencCmd3Settings; 61 62 std::vector< 63 std::function< 64 MOS_STATUS(mhw::vdbox::vdenc::_MHW_PAR_T(VDENC_AVC_IMG_STATE) & par)> > 65 vdencAvcImgStateSettings; 66 }; 67 68 class VdencConstSettings : public MediaFeatureConstSettings 69 { 70 public: VdencConstSettings(PMOS_INTERFACE osInterface)71 VdencConstSettings(PMOS_INTERFACE osInterface) : MediaFeatureConstSettings(osInterface){}; 72 VdencConstSettings() = default; 73 //! 74 //! \brief Frame level update 75 //! \param [in] params 76 //! Pointer to EncoderParams 77 //! \return MOS_STATUS 78 //! MOS_STATUS_SUCCESS if success, else fail reason 79 //! 80 virtual MOS_STATUS Update(void *params) = 0; 81 82 //! 83 //! \brief Set OS interface 84 //! \param [in] osItf 85 //! Pointer to OS interface 86 //! \return MOS_STATUS 87 //! MOS_STATUS_SUCCESS if success, else fail reason 88 //! SetOsInterface(PMOS_INTERFACE osItf)89 MOS_STATUS SetOsInterface(PMOS_INTERFACE osItf) 90 { 91 ENCODE_CHK_NULL_RETURN(osItf); 92 m_osItf = osItf; 93 94 return MOS_STATUS_SUCCESS; 95 } 96 97 protected: 98 //! 99 //! \brief Prepare VDENC STREAMIN STATE related settings 100 //! \return MOS_STATUS 101 //! MOS_STATUS_SUCCESS if success, else fail reason 102 //! SetVdencStreaminStateSettings()103 virtual MOS_STATUS SetVdencStreaminStateSettings() { return MOS_STATUS_SUCCESS; }; 104 105 //! 106 //! \brief Prepare VDENC CMD1 related settings 107 //! \return MOS_STATUS 108 //! MOS_STATUS_SUCCESS if success, else fail reason 109 //! SetVdencCmd1Settings()110 virtual MOS_STATUS SetVdencCmd1Settings() { return MOS_STATUS_SUCCESS; }; 111 112 //! 113 //! \brief Prepare VDENC CMD2 related settings 114 //! \return MOS_STATUS 115 //! MOS_STATUS_SUCCESS if success, else fail reason 116 //! 117 virtual MOS_STATUS SetVdencCmd2Settings() = 0; 118 119 //! 120 //! \brief Prepare BRC related settings 121 //! \return MOS_STATUS 122 //! MOS_STATUS_SUCCESS if success, else fail reason 123 //! 124 virtual MOS_STATUS SetBrcSettings() = 0; 125 126 protected: 127 PMOS_INTERFACE m_osItf = nullptr; 128 129 MEDIA_CLASS_DEFINE_END(VdencConstSettings) 130 }; 131 132 #define VDENC_CMD1_LAMBDA() [&](mhw::vdbox::vdenc::_MHW_PAR_T(VDENC_CMD1) & par, bool isLowDelay) -> MOS_STATUS 133 #define VDENC_CMD2_LAMBDA() [&](mhw::vdbox::vdenc::_MHW_PAR_T(VDENC_CMD2) & par, bool isLowDelay) -> MOS_STATUS 134 #define VDENC_CMD3_LAMBDA() [&](mhw::vdbox::vdenc::_MHW_PAR_T(VDENC_CMD3) & par) -> MOS_STATUS 135 #define VDENC_AVC_IMG_STATE_LAMBDA() [&](mhw::vdbox::vdenc::_MHW_PAR_T(VDENC_AVC_IMG_STATE) & par) -> MOS_STATUS 136 #define VDENC_STREAMIN_STATE_LAMBDA() [&](mhw::vdbox::vdenc::_MHW_PAR_T(VDENC_STREAMIN_STATE) & par, bool cu64Align) -> MOS_STATUS 137 138 #endif // __ENCODE_CONST_SETTINGS_H__ 139