1 /* 2 * Copyright (c) 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_avc_vdenc_roi_interface.h 24 //! \brief Define interface of the ROI features of AVC VDENC 25 //! 26 27 #ifndef __CODECHAL_AVC_VDENC_ROI_INTERFACE_H__ 28 #define __CODECHAL_AVC_VDENC_ROI_INTERFACE_H__ 29 30 #include "encode_avc_brc.h" 31 #include "encode_avc_vdenc_stream_in_feature.h" 32 33 namespace encode 34 { 35 36 //! 37 //! \class AvcVdencRoiInterface 38 //! 39 //! \brief AvcVdencRoiInterface is unified interface of VDEnc ROI and Dirty ROI. 40 //! 41 //! \detail This class is an feature interface for AVC native and non-native ROI 42 //! in both ForceQP and DeltaQP modes and Dirty ROI. 43 class AvcVdencRoiInterface : public MediaFeature 44 { 45 public: 46 47 union SupportedModes 48 { 49 struct 50 { 51 uint32_t ROI_Native : MOS_BITFIELD_RANGE(0, 0); 52 uint32_t ROI_NonNative : MOS_BITFIELD_RANGE(1, 1); 53 uint32_t MBQP_ForceQP : MOS_BITFIELD_RANGE(2, 2); 54 uint32_t MBQP_DeltaQP : MOS_BITFIELD_RANGE(3, 3); 55 uint32_t DirtyROI : MOS_BITFIELD_RANGE(4, 4); 56 uint32_t ArbROI : MOS_BITFIELD_RANGE(5, 5); 57 uint32_t Reserved26 : MOS_BITFIELD_RANGE(6, 31); 58 }; 59 uint32_t Value; SupportedModes()60 SupportedModes() : Value(0) {} 61 }; 62 63 AvcVdencRoiInterface( 64 MediaFeatureManager *featureManager, 65 EncodeAllocator *allocator, 66 CodechalHwInterfaceNext *hwInterface, 67 void *constSettings, 68 SupportedModes& supportedModes); 69 ~AvcVdencRoiInterface()70 virtual ~AvcVdencRoiInterface() {} 71 72 //! 73 //! \brief Init encode parameter 74 //! \param [in] settings 75 //! Pointer to settings 76 //! \return MOS_STATUS 77 //! MOS_STATUS_SUCCESS if success, else fail reason 78 //! 79 virtual MOS_STATUS Init(void *setting) override; 80 81 //! 82 //! \brief Update encode parameter 83 //! \param [in] params 84 //! Pointer to parameters 85 //! \return MOS_STATUS 86 //! MOS_STATUS_SUCCESS if success, else fail reason 87 //! 88 virtual MOS_STATUS Update(void *params) override; 89 90 protected: 91 92 //! 93 //! \brief Sort and set distinct delta QPs 94 //! 95 //! \return bool 96 //! true if native ROI, otherwise false 97 //! 98 bool ProcessRoiDeltaQp(); 99 100 virtual MOS_STATUS SetupROI(); 101 102 virtual MOS_STATUS SetupDirtyROI(); 103 104 virtual MOS_STATUS SetupMBQP(); 105 106 virtual MOS_STATUS SetupForceSkip(); 107 108 virtual MOS_STATUS SetupArbROI(); 109 110 MOS_STATUS IsModesSupported(uint32_t modes, std::string featureName); 111 112 MOS_STATUS GetDeltaQPIndex(uint32_t maxNumRoi, int32_t dqp, int32_t& dqpIdx); 113 114 static constexpr uint8_t m_maxNumRoi = 16; //!< VDEnc maximum number of ROI supported (uncluding non-ROI zone0) 115 static constexpr uint8_t m_maxNumNativeRoi = 3; //!< Number of native ROI with different dQP supported by VDEnc HW 116 117 EncodeAllocator* m_allocator = nullptr; 118 CodechalHwInterfaceNext* m_hwInterface = nullptr; 119 AvcBasicFeature* m_basicFeature = nullptr; 120 AvcEncodeBRC* m_brcFeature = nullptr; 121 AvcVdencStreamInFeature* m_vdencStreamInFeature = nullptr; 122 PCODEC_AVC_ENCODE_PIC_PARAMS m_picParam = nullptr; 123 124 SupportedModes m_supportedModes; 125 bool m_isNativeRoi = false; 126 127 MEDIA_CLASS_DEFINE_END(encode__AvcVdencRoiInterface) 128 }; 129 130 } // namespace encode 131 #endif //<! __CODECHAL_AVC_VDENC_ROI_INTERFACE_H__ 132