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 vphal_render_vebox_xe_xpm_denoise.h 24 //! \brief Head file for vebox xe xpm denoise renderer 25 //! \details Head file for vebox xe xpm denoise renderer 26 //! 27 #ifndef __VPHAL_RENDER_VEBOX_XE_XPM_DENOISE_H__ 28 #define __VPHAL_RENDER_VEBOX_XE_XPM_DENOISE_H__ 29 30 #include "renderhal_legacy.h" 31 32 #if !EMUL 33 #include "vphal_mdf_wrapper.h" 34 35 // Human Vision System Hpm Based Denoise 36 class HVSDenoiseHpm : public VPCmRenderer 37 { 38 public: 39 struct HVSDenoisePayloadHpm 40 { 41 VpCmSurfaceHolder<CmBuffer> *denoiseParam; 42 uint16_t Mode; 43 uint16_t Format; 44 uint16_t Width; 45 uint16_t Height; 46 uint32_t Noise_level; 47 uint32_t Noise_level_u; 48 uint32_t Noise_level_v; 49 uint32_t Sgne_Level; 50 uint32_t Sgne_Level_u; 51 uint32_t Sgne_Level_v; 52 uint32_t Sgne_Count; 53 uint32_t Sgne_Count_u; 54 uint32_t Sgne_Count_v; 55 uint32_t PrevNslvTemporal; 56 uint32_t PrevNslvTemporal_u; 57 uint32_t PrevNslvTemporal_v; 58 uint16_t QP; 59 uint16_t FirstFrame; 60 uint16_t TGNE_firstFrame; 61 uint16_t FallBack; 62 uint16_t EnableChroma; 63 uint16_t EnableTemporalGNE; 64 uint16_t CodecID; 65 }; 66 67 HVSDenoiseHpm(const PRENDERHAL_INTERFACE vphalRenderer, void *kernelBinary, int32_t kerneBinarySize, CmContext *cmContext); 68 virtual ~HVSDenoiseHpm(); 69 70 private: 71 virtual void AttachPayload(void *payload); 72 virtual CmKernel *GetKernelToRun(std::string &name); 73 virtual void GetThreadSpaceDimension(int &tsWidth, int &tsHeight, int &tsColor); 74 virtual void PrepareKernel(CmKernel *kernel); 75 virtual void Dump(); 76 77 CmProgram *m_cmProgram = nullptr; 78 CmKernel * m_cmKernel = nullptr; 79 80 HVSDenoisePayloadHpm *m_payload = nullptr; 81 }; 82 83 class VphalHVSDenoiserHpm 84 { 85 public: 86 explicit VphalHVSDenoiserHpm(const PRENDERHAL_INTERFACE vphalRenderer); 87 VphalHVSDenoiserHpm(const VphalHVSDenoiserHpm &) = delete; 88 VphalHVSDenoiserHpm &operator=(const VphalHVSDenoiserHpm &) = delete; 89 virtual ~VphalHVSDenoiserHpm(); 90 91 // This InitKernelParams function needs to be called immediately after constructor function. 92 void InitKernelParams(void *kernelBinary, const int32_t kerneBinarySize); 93 MOS_STATUS Render(const PVPHAL_DENOISE_PARAMS pDNParams); GetDenoiseParams()94 uint8_t * GetDenoiseParams() 95 { 96 return m_hvsDenoiseParam; 97 } 98 99 private: 100 void AllocateResources(const uint32_t width, const uint32_t height); 101 void FreeResources(); 102 103 EventManager * m_eventManager = nullptr; 104 PRENDERHAL_INTERFACE m_renderHal = nullptr; 105 VpCmSurfaceHolder<CmBuffer> *m_hvsDenoiseCmSurface = nullptr; 106 // Denoise Parameters in CPU memory 107 uint8_t * m_hvsDenoiseParam = nullptr; 108 HVSDenoiseHpm *m_hvsDenoise = nullptr; 109 CmContext * m_cmContext = nullptr; 110 111 uint16_t m_savedQP = 0; 112 uint16_t m_savedStrength = 0; 113 bool m_initHVSDenoise = false; 114 115 // It is defined in Media Kernel. 116 const uint32_t m_denoiseBufferInBytes = 160; //32 + 8 int 117 void * m_kernelBinary = nullptr; 118 int32_t m_kernelBinarySize = 0; 119 }; 120 #else 121 #include "vphal_common.h" 122 123 class VphalHVSDenoiserHpm 124 { 125 public: VphalHVSDenoiserHpm(PRENDERHAL_INTERFACE vphalRenderer)126 explicit VphalHVSDenoiserHpm(PRENDERHAL_INTERFACE vphalRenderer) 127 { 128 MOS_UNUSED(vphalRenderer); 129 }; 130 VphalHVSDenoiserHpm(const VphalHVSDenoiserHpm &) = delete; 131 VphalHVSDenoiserHpm &operator=(const VphalHVSDenoiserHpm &) = delete; ~VphalHVSDenoiserHpm()132 virtual ~VphalHVSDenoiserHpm(){}; 133 134 // This InitKernelParams function needs to be called after construrctor immediately. InitKernelParams(void * kernelBinary,const int32_t kerneBinarySize)135 void InitKernelParams(void *kernelBinary, const int32_t kerneBinarySize) 136 { 137 MOS_UNUSED(kernelBinary); 138 MOS_UNUSED(kerneBinarySize); 139 }; 140 Render(const PVPHAL_DENOISE_PARAMS pDNParams)141 MOS_STATUS Render(const PVPHAL_DENOISE_PARAMS pDNParams) 142 { 143 return MOS_STATUS_UNIMPLEMENTED; 144 }; 145 GetDenoiseParams()146 uint8_t *GetDenoiseParams() 147 { 148 return nullptr; 149 } 150 }; 151 #endif // !EMUL 152 #endif // __VPHAL_RENDER_VEBOX_DENOISE_H__