1 /*
2 * Copyright (c) 2020-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     vp_dn_filter.h
24 //! \brief    Defines the common interface for denoise
25 //!           this file is for the base interface which is shared by all denoise in driver.
26 //!
27 #ifndef __VP_DN_FILTER_H__
28 #define __VP_DN_FILTER_H__
29 #include "vp_filter.h"
30 #include "sw_filter.h"
31 
32 namespace vp {
33 class VpDnFilter : public VpFilter
34 {
35 public:
36 
37     VpDnFilter(
38         PVP_MHWINTERFACE vpMhwInterface);
39 
~VpDnFilter()40     ~VpDnFilter()
41     {
42         Destroy();
43     };
44 
45     virtual MOS_STATUS Init() override;
46 
47     virtual MOS_STATUS Prepare() override;
48 
49     virtual MOS_STATUS Destroy() override;
50 
51     virtual MOS_STATUS SetExecuteEngineCaps(
52         FeatureParamDenoise         &dnParams,
53         VP_EXECUTE_CAPS         vpExecuteCaps);
54 
55     MOS_STATUS CalculateEngineParams();
GetVeboxParams()56     PVEBOX_DN_PARAMS GetVeboxParams()
57     {
58         return m_veboxDnParams;
59     }
60 
61 protected:
62     FeatureParamDenoise     m_dnParams = {};
63     PVEBOX_DN_PARAMS        m_veboxDnParams = nullptr;
64 
65 MEDIA_CLASS_DEFINE_END(VpDnFilter)
66 };
67 
68 struct HW_FILTER_DN_PARAM : public HW_FILTER_PARAM
69 {
70     FeatureParamDenoise         dnParams;
71 };
72 
73 class HwFilterDnParameter : public HwFilterParameter
74 {
75 public:
76     static HwFilterParameter *Create(HW_FILTER_DN_PARAM &param, FeatureType featureType);
77     HwFilterDnParameter(FeatureType featureType);
78     virtual ~HwFilterDnParameter();
79     virtual MOS_STATUS ConfigParams(HwFilter &hwFilter);
80 
81     MOS_STATUS Initialize(HW_FILTER_DN_PARAM&param);
82 
83 private:
84     HW_FILTER_DN_PARAM m_Params = {};
85 
86 MEDIA_CLASS_DEFINE_END(HwFilterDnParameter)
87 };
88 
89 class VpVeboxDnParameter : public VpPacketParameter
90 {
91 public:
92     static VpPacketParameter *Create(HW_FILTER_DN_PARAM &param);
93     VpVeboxDnParameter(PVP_MHWINTERFACE pHwInterface, PacketParamFactoryBase *packetParamFactory);
94     virtual ~VpVeboxDnParameter();
95 
96     virtual bool SetPacketParam(VpCmdPacket *pPacket);
97 
98 private:
99     MOS_STATUS Initialize(HW_FILTER_DN_PARAM&params);
100 
101     VpDnFilter m_dnFilter;
102 
103 MEDIA_CLASS_DEFINE_END(VpVeboxDnParameter)
104 };
105 
106 class PolicyVeboxDnHandler : public PolicyFeatureHandler
107 {
108 public:
109     PolicyVeboxDnHandler(VP_HW_CAPS &hwCaps);
110     virtual ~PolicyVeboxDnHandler();
111     virtual bool IsFeatureEnabled(VP_EXECUTE_CAPS vpExecuteCaps);
112     virtual HwFilterParameter *CreateHwFilterParam(VP_EXECUTE_CAPS vpExecuteCaps, SwFilterPipe &swFilterPipe, PVP_MHWINTERFACE pHwInterface);
113 
CreatePacketParam(HW_FILTER_PARAM & param)114     static VpPacketParameter* CreatePacketParam(HW_FILTER_PARAM& param)
115     {
116         if (param.type != FeatureTypeDnOnVebox)
117         {
118             VP_PUBLIC_ASSERTMESSAGE("Invalid parameter for Vebox De-Noise!");
119             return nullptr;
120         }
121 
122         HW_FILTER_DN_PARAM* dnParam = (HW_FILTER_DN_PARAM*)(&param);
123         return VpVeboxDnParameter::Create(*dnParam);
124     }
125 
126 private:
127     PacketParamFactory<VpVeboxDnParameter> m_PacketParamFactory;
128 
129 MEDIA_CLASS_DEFINE_END(PolicyVeboxDnHandler)
130 };
131 }
132 #endif
133