1 /* 2 * Copyright (c) 2020 - 2023, 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_av1_superres.h 24 //! \brief Super-res feature 25 //! 26 27 #ifndef __ENCODE_AV1_SUPERRES_H__ 28 #define __ENCODE_AV1_SUPERRES_H__ 29 30 #include "encode_av1_basic_feature.h" 31 #include "media_sfc_interface.h" 32 33 namespace encode 34 { 35 class Av1SuperRes : public MediaFeature, public mhw::vdbox::vdenc::Itf::ParSetting, public mhw::vdbox::avp::Itf::ParSetting 36 { 37 public: 38 Av1SuperRes(MediaFeatureManager *featureManager, 39 EncodeAllocator *allocator, 40 void *constSettings); 41 42 virtual MOS_STATUS Init(void *setting) override; 43 44 virtual MOS_STATUS Update(void *params) override; 45 46 MOS_STATUS InitMMCState(EncodeMemComp *mmcState); 47 GetUpscaledWidth()48 uint32_t GetUpscaledWidth() const { return m_oriAlignedFrameWidth; } 49 GetRawSurfaceToEnc()50 PMOS_SURFACE GetRawSurfaceToEnc() const { return m_rawDs.resource; } 51 IsSuperResUsed()52 const bool IsSuperResUsed() { return m_useSuperRes; } 53 GetDownScalingParams()54 VEBOX_SFC_PARAMS& GetDownScalingParams() { return m_downScalingParams;} 55 56 MHW_SETPAR_DECL_HDR(AVP_PIC_STATE); 57 58 MHW_SETPAR_DECL_HDR(AVP_INLOOP_FILTER_STATE); 59 60 protected: 61 62 struct SURFACE 63 { 64 PMOS_SURFACE resource = nullptr; 65 uint32_t unalignedWidth = 0; 66 uint32_t unalignedHeight = 0; 67 }; 68 69 virtual MOS_STATUS PrepareRawSurface(); 70 71 MOS_STATUS PrepareVeSfcDownscalingParam(const SURFACE &inSurf, const SURFACE &outSurf, VEBOX_SFC_PARAMS ¶ms); 72 73 MediaFeatureManager *m_featureManager = nullptr; 74 EncodeAllocator *m_allocator = nullptr; 75 Av1BasicFeature *m_basicFeature = nullptr; //!< EncodeBasicFeature 76 TrackedBuffer *m_trackedBuf = nullptr; 77 EncodeMemComp *m_mmcState = nullptr; 78 79 VEBOX_SFC_PARAMS m_downScalingParams = {}; 80 SURFACE m_raw = {}; 81 SURFACE m_rawDs = {}; 82 bool m_useSuperRes = false; 83 uint32_t m_oriFrameHeight = 0; //!< Original frame height 84 uint32_t m_oriAlignedFrameWidth = 0; //!< Original Aligned frame width 85 uint32_t m_frameWidth = 0; 86 uint32_t m_frameWidthDs = 0; //!< Frame width in luma samples 87 uint32_t m_frameHeight = 0; //!< Frame height in luma samples 88 uint32_t m_prevDsWidth = 0; 89 uint8_t m_superResDenom = 0; 90 int8_t m_subsamplingX[3] = {}; 91 bool m_is10Bit = false; 92 bool m_widthChanged = false; 93 94 MEDIA_CLASS_DEFINE_END(encode__Av1SuperRes) 95 }; 96 } // namespace encode 97 98 #endif // __ENCODE_AV1_SUPERRES_H__ 99