1 /* 2 * Copyright (c) 2018, 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_denoise.h 24 //! \brief Head file for vebox denoise renderer 25 //! \details Head file for vebox denoise renderer 26 //! 27 #ifndef __VPHAL_RENDER_VEBOX_DENOISE_H__ 28 #define __VPHAL_RENDER_VEBOX_DENOISE_H__ 29 30 #include "renderhal.h" 31 32 #if !EMUL 33 #include "vphal_mdf_wrapper.h" 34 35 // Human Vision System Based Denoise 36 class HVSDenoise : public VPCmRenderer 37 { 38 public: 39 struct HVSDenoisePayload 40 { 41 VpCmSurfaceHolder<CmBuffer> *denoiseParam; 42 uint16_t QP; 43 uint16_t CodecID; 44 uint16_t Strength; 45 }; 46 47 HVSDenoise(const PRENDERHAL_INTERFACE vphalRenderer, void *kernelBinary, int32_t kerneBinarySize, CmContext *cmContext); 48 virtual ~HVSDenoise(); 49 50 private: 51 virtual void AttachPayload(void *payload); 52 virtual CmKernel *GetKernelToRun(std::string &name); 53 virtual void GetThreadSpaceDimension(int &tsWidth, int &tsHeight, int &tsColor); 54 virtual void PrepareKernel(CmKernel *kernel); 55 virtual void Dump(); 56 57 CmProgram *m_cmProgram = nullptr; 58 CmKernel *m_cmKernel = nullptr; 59 60 HVSDenoisePayload *m_payload = nullptr; 61 }; 62 63 class VphalHVSDenoiser 64 { 65 public: 66 explicit VphalHVSDenoiser(const PRENDERHAL_INTERFACE vphalRenderer); 67 VphalHVSDenoiser(const VphalHVSDenoiser &) = delete; 68 VphalHVSDenoiser &operator=(const VphalHVSDenoiser &) = delete; 69 virtual ~VphalHVSDenoiser(); 70 71 // This InitKernelParams function needs to be called immediately after constructor function. 72 void InitKernelParams(void *kernelBinary, const int32_t kerneBinarySize); 73 MOS_STATUS Render(const PVPHAL_SURFACE pSrcSuface); GetDenoiseParams()74 uint8_t* GetDenoiseParams() 75 { 76 return m_hvsDenoiseParam; 77 } 78 79 private: 80 void AllocateResources(const uint32_t width, const uint32_t height); 81 void FreeResources(); 82 83 EventManager* m_eventManager = nullptr; 84 PRENDERHAL_INTERFACE m_renderHal = nullptr; 85 VpCmSurfaceHolder<CmBuffer> *m_hvsDenoiseCmSurface = nullptr; 86 // Denoise Parameters in CPU memory 87 uint8_t * m_hvsDenoiseParam = nullptr; 88 HVSDenoise * m_hvsDenoise = nullptr; 89 CmContext * m_cmContext = nullptr; 90 91 uint16_t m_savedQP = 0; 92 uint16_t m_savedStrength = 0; 93 bool m_initHVSDenoise = false; 94 95 // It is defined in Media Kernel. 96 const uint32_t m_denoiseBufferInBytes = 64; 97 void *m_kernelBinary = nullptr; 98 int32_t m_kernelBinarySize = 0; 99 }; 100 #else 101 #include "vphal_common.h" 102 103 class VphalHVSDenoiser 104 { 105 public: VphalHVSDenoiser(PRENDERHAL_INTERFACE vphalRenderer)106 explicit VphalHVSDenoiser(PRENDERHAL_INTERFACE vphalRenderer) 107 { 108 MOS_UNUSED(vphalRenderer); 109 }; 110 VphalHVSDenoiser(const VphalHVSDenoiser &) = delete; 111 VphalHVSDenoiser &operator=(const VphalHVSDenoiser &) = delete; ~VphalHVSDenoiser()112 virtual ~VphalHVSDenoiser() 113 { 114 }; 115 116 // This InitKernelParams function needs to be called after construrctor immediately. InitKernelParams(void * kernelBinary,const int32_t kerneBinarySize)117 void InitKernelParams(void *kernelBinary, const int32_t kerneBinarySize) 118 { 119 MOS_UNUSED(kernelBinary); 120 MOS_UNUSED(kerneBinarySize); 121 }; 122 Render(const PVPHAL_SURFACE pSrcSuface)123 MOS_STATUS Render(const PVPHAL_SURFACE pSrcSuface) 124 { 125 return MOS_STATUS_UNIMPLEMENTED; 126 }; 127 GetDenoiseParams()128 uint8_t *GetDenoiseParams() 129 { 130 return nullptr; 131 } 132 }; 133 #endif // !EMUL 134 #endif // __VPHAL_RENDER_VEBOX_DENOISE_H__