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 decode_filmgrain_gennoise_rp2_packet_g12.h 24 //! \brief Defines the implementation of av1 decode film grain regress phase2 kernel packet 25 //! 26 27 #ifndef __DECODE_FILMGRAIN_GENNOISE_RP2_PACKET_G12_H__ 28 #define __DECODE_FILMGRAIN_GENNOISE_RP2_PACKET_G12_H__ 29 30 #include "media_render_cmd_packet.h" 31 #include "decode_av1_pipeline_g12_base.h" 32 #include "decode_av1_filmgrain_feature_g12.h" 33 34 namespace decode 35 { 36 //Curbe definitions 37 struct FilmGrainRegressPhase2Curbe 38 { 39 // uint32_t 0 40 union 41 { 42 struct 43 { 44 uint32_t YRandomValuesSurfaceIndex : MOS_BITFIELD_RANGE(0, 31); 45 }; 46 struct 47 { 48 uint32_t Value; 49 }; 50 } DW0; 51 52 // uint32_t 1 53 union 54 { 55 struct 56 { 57 uint32_t URandomValuesSurfaceIndex : MOS_BITFIELD_RANGE(0, 31); 58 }; 59 struct 60 { 61 uint32_t Value; 62 }; 63 } DW1; 64 65 // uint32_t 2 66 union 67 { 68 struct 69 { 70 uint32_t VRandomValuesSurfaceIndex : MOS_BITFIELD_RANGE(0, 31); 71 }; 72 struct 73 { 74 uint32_t Value; 75 }; 76 } DW2; 77 78 // uint32_t 3 79 union 80 { 81 struct 82 { 83 uint32_t YDitheringInputSurfaceIndex : MOS_BITFIELD_RANGE(0, 31); 84 }; 85 struct 86 { 87 uint32_t Value; 88 }; 89 } DW3; 90 91 // uint32_t 4 92 union 93 { 94 struct 95 { 96 uint32_t YDitheringSurfaceIndex : MOS_BITFIELD_RANGE(0, 31); 97 }; 98 struct 99 { 100 uint32_t Value; 101 }; 102 } DW4; 103 104 // uint32_t 5 105 union 106 { 107 struct 108 { 109 uint32_t UDitheringSurfaceIndex : MOS_BITFIELD_RANGE(0, 31); 110 }; 111 struct 112 { 113 uint32_t Value; 114 }; 115 } DW5; 116 117 // uint32_t 6 118 union 119 { 120 struct 121 { 122 uint32_t VDitheringSurfaceIndex : MOS_BITFIELD_RANGE(0, 31); 123 }; 124 struct 125 { 126 uint32_t Value; 127 }; 128 } DW6; 129 130 // uint32_t 7 131 union 132 { 133 struct 134 { 135 uint32_t YCoeffSurfaceIndex : MOS_BITFIELD_RANGE(0, 31); 136 }; 137 struct 138 { 139 uint32_t Value; 140 }; 141 } DW7; 142 143 // uint32_t 8 144 union 145 { 146 struct 147 { 148 uint32_t UCoeffSurfaceIndex : MOS_BITFIELD_RANGE(0, 31); 149 }; 150 struct 151 { 152 uint32_t Value; 153 }; 154 } DW8; 155 156 // uint32_t 9 157 union 158 { 159 struct 160 { 161 uint32_t VCoeffSurfaceIndex : MOS_BITFIELD_RANGE(0, 31); 162 }; 163 struct 164 { 165 uint32_t Value; 166 }; 167 } DW9; 168 169 // uint32_t 10 170 union 171 { 172 struct 173 { 174 uint32_t RegressionCoefficientShift : MOS_BITFIELD_RANGE(0, 15); 175 uint32_t Reserved : MOS_BITFIELD_RANGE(16, 31); 176 }; 177 struct 178 { 179 uint32_t Value; 180 }; 181 } DW10; 182 183 static const size_t m_size = 11; 184 static const size_t m_byteSize = 44; 185 }; 186 C_ASSERT(sizeof(FilmGrainRegressPhase2Curbe) == 44); 187 188 // Binding Table Definitions 189 //! 190 //! \enum FilmGrainRegressPhase2BindingTableOffset 191 //! \brief Binding table offset for regressPhase2 kernel 192 //! 193 enum FilmGrainRegressPhase2BindingTableOffset 194 { 195 rp2InputYRandomValue = 0, 196 rp2InputURandomValue, 197 rp2InputVRandomValue, 198 rp2InputYDithering, 199 rp2OutputYDithering, 200 rp2OutputUDithering, 201 rp2OutputVDithering, 202 rp2InputYCoeff, 203 rp2InputUCoeff, 204 rp2InputVCoeff, 205 rp2NumSurfaces 206 }; 207 208 enum FilmGrainKernelStateIdx; 209 210 class FilmGrainRp2Packet : public RenderCmdPacket 211 { 212 public: 213 FilmGrainRp2Packet(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterface *hwInterface); 214 ~FilmGrainRp2Packet()215 virtual ~FilmGrainRp2Packet() {}; 216 217 MOS_STATUS Prepare() override; 218 MOS_STATUS Submit(MOS_COMMAND_BUFFER *commandBuffer, uint8_t packetPhase) override; 219 MOS_STATUS Initilize(); 220 221 virtual MOS_STATUS Init() override; 222 GetPacketName()223 virtual std::string GetPacketName() override 224 { 225 return "AV1_DECODE_FilmGrainRp2"; 226 } 227 228 //! 229 //! \brief Calculate Command Size 230 //! 231 //! \param [in, out] commandBufferSize 232 //! requested size 233 //! \param [in, out] requestedPatchListSize 234 //! requested size 235 //! \return MOS_STATUS 236 //! status 237 //! 238 MOS_STATUS CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize) override; 239 240 MOS_STATUS SetCurbeRegressPhase2(); 241 Destroy()242 MOS_STATUS Destroy() override 243 { 244 return RenderCmdPacket::Destroy(); 245 } 246 247 protected: 248 MOS_STATUS KernelStateSetup(); 249 MOS_STATUS SetUpSurfaceState(); 250 virtual MOS_STATUS SetupMediaWalker() override; 251 252 protected: 253 int32_t m_kernelIndex = regressPhase2; 254 Kdll_FilterEntry* m_filter = nullptr; // Kernel Filter (points to base of filter array) 255 256 MediaFeatureManager *m_featureManager = nullptr; 257 Av1PipelineG12_Base *m_av1Pipeline = nullptr; 258 DecodeAllocator *m_allocator = nullptr; 259 PMOS_INTERFACE m_osInterface = nullptr; 260 Av1BasicFeatureG12 *m_av1BasicFeature = nullptr; 261 Av1DecodeFilmGrainG12 *m_filmGrainFeature = nullptr; 262 263 MhwVdboxVdencInterface *m_vdencInterface = nullptr; 264 CodechalHwInterface *m_hwInterface = nullptr; 265 DecodeMemComp *m_mmcState = nullptr; 266 const CodecAv1PicParams *m_picParams = nullptr; //!< Pointer to picture parameter 267 268 uint32_t m_bindingTableIndex[rp2NumSurfaces] = 269 { 270 rp2InputYRandomValue, 271 rp2InputURandomValue, 272 rp2InputVRandomValue, 273 rp2InputYDithering, 274 rp2OutputYDithering, 275 rp2OutputUDithering, 276 rp2OutputVDithering, 277 rp2InputYCoeff, 278 rp2InputUCoeff, 279 rp2InputVCoeff, 280 }; 281 }; 282 } 283 #endif 284