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_rp1_packet_g12.h
24 //! \brief    Defines the implementation of av1 decode film grain regres phase1 kernel packet
25 //!
26 
27 #ifndef __DECODE_FILMGRAIN_GENNOISE_RP1_PACKET_G12_H__
28 #define __DECODE_FILMGRAIN_GENNOISE_RP1_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 
37 //Curbe definitions
38 struct FilmGrainRegressPhase1Curbe
39 {
40     // uint32_t 0
41     union
42     {
43         struct
44         {
45             uint32_t YRandomValuesSurfaceIndex : MOS_BITFIELD_RANGE(0, 31);
46         };
47         struct
48         {
49             uint32_t Value;
50         };
51     } DW0;
52 
53     // uint32_t 1
54     union
55     {
56         struct
57         {
58             uint32_t YDitheringSurface : MOS_BITFIELD_RANGE(0, 31);
59         };
60         struct
61         {
62             uint32_t Value;
63         };
64     } DW1;
65 
66     // uint32_t 2
67     union
68     {
69         struct
70         {
71             uint32_t YCoeffSurface : MOS_BITFIELD_RANGE(0, 31);
72         };
73         struct
74         {
75             uint32_t Value;
76         };
77     } DW2;
78 
79     static const size_t m_size     = 3;
80     static const size_t m_byteSize = 12;
81 };
82 C_ASSERT(sizeof(FilmGrainRegressPhase1Curbe) == 12);
83 
84 // Binding Table Definitions
85 //!
86 //! \enum     FilmGrainRegressPhase1BindingTableOffset
87 //! \brief    Binding table offset for regressPhase1 kernel
88 //!
89 enum FilmGrainRegressPhase1BindingTableOffset
90 {
91     rp1InputYRandomValue = 0,
92     rp1OutputYDitheringSurface,
93     rp1InputYCoeff,
94     rp1NumSurfaces
95 };
96 
97 enum FilmGrainKernelStateIdx;
98 
99 class FilmGrainRp1Packet : public RenderCmdPacket
100 {
101 public:
102     FilmGrainRp1Packet(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterface *hwInterface);
103 
~FilmGrainRp1Packet()104     virtual ~FilmGrainRp1Packet() {};
105 
106     MOS_STATUS Prepare() override;
107     MOS_STATUS Submit(MOS_COMMAND_BUFFER *commandBuffer, uint8_t packetPhase) override;
108     MOS_STATUS Initilize();
109 
110     virtual MOS_STATUS Init() override;
111 
GetPacketName()112     virtual std::string GetPacketName() override
113     {
114         return "AV1_DECODE_FilmGrainRp1";
115     }
116 
117     //!
118     //! \brief  Calculate Command Size
119     //!
120     //! \param  [in, out] commandBufferSize
121     //!         requested size
122     //! \param  [in, out] requestedPatchListSize
123     //!         requested size
124     //! \return MOS_STATUS
125     //!         status
126     //!
127     MOS_STATUS CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize) override;
128 
129     MOS_STATUS SetCurbeRegressPhase1();
130 
Destroy()131     MOS_STATUS Destroy() override
132     {
133         return RenderCmdPacket::Destroy();
134     }
135 
136 protected:
137     MOS_STATUS KernelStateSetup();
138     MOS_STATUS SetUpSurfaceState();
139     virtual MOS_STATUS SetupMediaWalker() override;
140 
141 protected:
142     int32_t                 m_kernelIndex       = regressPhase1;
143     Kdll_FilterEntry*       m_filter            = nullptr; // Kernel Filter (points to base of filter array)
144     MediaFeatureManager     *m_featureManager   = nullptr;
145     Av1PipelineG12_Base     *m_av1Pipeline      = nullptr;
146     DecodeAllocator         *m_allocator        = nullptr;
147     PMOS_INTERFACE          m_osInterface       = nullptr;
148     Av1BasicFeatureG12      *m_av1BasicFeature  = nullptr;
149     Av1DecodeFilmGrainG12   *m_filmGrainFeature = nullptr;
150 
151     MhwVdboxVdencInterface  *m_vdencInterface   = nullptr;
152     CodechalHwInterface     *m_hwInterface      = nullptr;
153     DecodeMemComp           *m_mmcState         = nullptr;
154     const CodecAv1PicParams *m_picParams        = nullptr;  //!< Pointer to picture parameter
155 
156     uint32_t m_bindingTableIndex[rp1NumSurfaces] =
157     {
158         rp1InputYRandomValue,
159         rp1OutputYDitheringSurface,
160         rp1InputYCoeff,
161     };
162 };
163 }
164 #endif
165