Debian Codegraph @

media_driver/agnostic/gen12/codec/hal/codechal_encode_csc_ds_mdf_g12.h

raw
1 /*
2 * Copyright (c) 2017-2019, 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 codechal_encode_csc_ds_mdf_g12.h
24 //! \brief Gen12 class using MDF RT for CSC
25 //!
26
27 #ifndef __CodechalEncodeCscDsMdfG12__
28 #define __CodechalEncodeCscDsMdfG12__
29 #include "codechal_encode_csc_ds_g12.h"
30 #include "codechal_kernel_header_g12.h"
31
32 #include "cm_surface_2d_wrapper.h"
33
34 struct SurfaceParamsCscMdf
35 {
36 CmSurface2DWrapper *psInputSurface = nullptr;
37 CmSurface2DWrapper *psOutput4xDsSurface = nullptr;
38 CmSurface2DWrapper *psOutput2xDsSurface = nullptr;
39 CmSurface2DWrapper *psOutputCopiedSurface = nullptr;
40 CmBuffer *presMBVProcStatsBuffer = nullptr;
41 CmBuffer *presHistoryBuffer = nullptr;
42 SurfaceIndex *pHistBufSurfIdx = nullptr;
43 CmBuffer *presHistorySumBuffer = nullptr;
44 SurfaceIndex *pHistSumBufSurfIdx = nullptr;
45 CmBuffer *presMultiThreadTaskBuffer = nullptr;
46 SurfaceIndex *pMTTaskSumBufSurfIdx = nullptr;
47 };
48
49 class CodechalEncodeCscDsMdfG12 : public CodechalEncodeCscDsG12
50 {
51
52 protected:
53
54 CmThreadSpace *m_threadSpace4x = nullptr;
55 CmThreadSpace *m_threadSpace16x = nullptr;
56 CmThreadSpace *m_threadSpace32x = nullptr;
57 CmKernel *m_cmKrnCSCDS4x = nullptr;
58 CmKernel *m_cmKrnCSCDS16x = nullptr;
59 CmKernel *m_cmKrnCSCDS32x = nullptr;
60 CmProgram *m_cmProgramCSCDS = nullptr;
61
62 SurfaceParamsCscMdf m_cmSurfParamsCscDs4x;
63 SurfaceParamsCscMdf m_cmSurfParamsCscDs16x;
64 SurfaceParamsCscMdf m_cmSurfParamsCscDs32x;
65
66 // redefine the Curbe without the binding table indices
67 struct CscKernelCurbeData
68 {
69
70 CscKernelCurbeData()
71 {
72 MOS_ZeroMemory(this, sizeof(*this));
73 }
74 union
75 {
76 struct
77 {
78 // DWORD 0
79 uint32_t DW0_Reserved_0 : MOS_BITFIELD_RANGE(0, 7);
80 uint32_t DW0_Reserved_1 : MOS_BITFIELD_RANGE(8, 15);
81 uint32_t DW0_OutputBitDepthForChroma : MOS_BITFIELD_RANGE(16, 23);
82 uint32_t DW0_OutputBitDepthForLuma : MOS_BITFIELD_RANGE(24, 30);
83 uint32_t DW0_RoundingEnable : MOS_BITFIELD_BIT(31);
84 };
85 uint32_t DW0;
86 };
87
88 union
89 {
90 struct
91 {
92 // DWORD 1
93 uint32_t DW1_PictureFormat : MOS_BITFIELD_RANGE(0, 7);
94 uint32_t DW1_ConvertFlag : MOS_BITFIELD_BIT(8);
95 uint32_t DW1_DownscaleStage : MOS_BITFIELD_RANGE(9, 11);
96 uint32_t DW1_MbStatisticsDumpFlag : MOS_BITFIELD_BIT(12);
97 uint32_t DW1_YUY2ConversionFlag : MOS_BITFIELD_BIT(13);
98 uint32_t DW1_HevcEncHistorySum : MOS_BITFIELD_BIT(14);
99 uint32_t DW1_LCUSize : MOS_BITFIELD_BIT(15);
100 uint32_t DW1_ChromaSitingLocation : MOS_BITFIELD_RANGE(16, 23);
101 uint32_t DW1_Reserved_0 : MOS_BITFIELD_RANGE(24, 31);
102 };
103 uint32_t DW1;
104 };
105
106 union
107 {
108 struct
109 {
110 // DWORD 2
111 uint32_t DW2_OriginalPicWidthInSamples : MOS_BITFIELD_RANGE(0, 15);
112 uint32_t DW2_OriginalPicHeightInSamples : MOS_BITFIELD_RANGE(16, 31);
113 };
114 uint32_t DW2;
115 };
116
117 // DWORD 3
118 uint32_t DW3_MBFlatnessThreshold = 0;
119
120 // DWORD 4
121 union
122 {
123 struct
124 {
125 uint32_t DW4_CSC_Coefficient_C0 : MOS_BITFIELD_RANGE(0, 15);
126 uint32_t DW4_CSC_Coefficient_C1 : MOS_BITFIELD_RANGE(16, 31);
127 };
128 uint32_t DW4;
129 };
130
131 // DWORD 5
132 union
133 {
134 struct
135 {
136 uint32_t DW5_CSC_Coefficient_C2 : MOS_BITFIELD_RANGE(0, 15);
137 uint32_t DW5_CSC_Coefficient_C3 : MOS_BITFIELD_RANGE(16, 31);
138 };
139 uint32_t DW5;
140 };
141
142 // DWORD 6
143 union
144 {
145 struct
146 {
147 uint32_t DW6_CSC_Coefficient_C4 : MOS_BITFIELD_RANGE(0, 15);
148 uint32_t DW6_CSC_Coefficient_C5 : MOS_BITFIELD_RANGE(16, 31);
149 };
150 uint32_t DW6;
151 };
152
153 // DWORD 7
154 union
155 {
156 struct
157 {
158 uint32_t DW7_CSC_Coefficient_C6 : MOS_BITFIELD_RANGE(0, 15);
159 uint32_t DW7_CSC_Coefficient_C7 : MOS_BITFIELD_RANGE(16, 31);
160 };
161 uint32_t DW7;
162 };
163
164 // DWORD 8
165 union
166 {
167 struct
168 {
169 uint32_t DW8_CSC_Coefficient_C8 : MOS_BITFIELD_RANGE(0, 15);
170 uint32_t DW8_CSC_Coefficient_C9 : MOS_BITFIELD_RANGE(16, 31);
171 };
172 uint32_t DW8;
173 };
174
175 // DWORD 9
176 union
177 {
178 struct
179 {
180 uint32_t DW9_CSC_Coefficient_C10 : MOS_BITFIELD_RANGE(0, 15);
181 uint32_t DW9_CSC_Coefficient_C11 : MOS_BITFIELD_RANGE(16, 31);
182 };
183 uint32_t DW9;
184 };
185 };
186 C_ASSERT(MOS_BYTES_TO_DWORDS(sizeof(CscKernelCurbeData)) == 10);
187
188 public:
189
190 //!
191 //! \brief Constructor
192 //!
193 CodechalEncodeCscDsMdfG12(CodechalEncoderState* encoder);
194
195 //!
196 //! \brief Destructor
197 //!
198 virtual ~CodechalEncodeCscDsMdfG12();
199
200
201 protected:
202
203 MOS_STATUS CscKernel(
204 KernelParams* pParams) override;
205 using CodechalEncodeCscDsG12::InitKernelStateCsc;
206 MOS_STATUS InitKernelStateCsc(KernelParams* pParams);
207 MOS_STATUS SetupKernelArgsCSC(CmKernel *cmKrnCSCDS, SurfaceParamsCscMdf* surfaceparams);
208 MOS_STATUS SetCurbeCscforMDF(CMRT_UMD::vector<uint32_t, 10> & curbeData);
209 MOS_STATUS SetupSurfacesCSC(SurfaceParamsCscMdf& SurfaceParamsCsc);
210 MOS_STATUS DestroySurfaces(SurfaceParamsCscMdf& surfaceparams);
211 //!
212 //! \brief Release the MDF RT resources for Ds kernel
213 //!
214 MOS_STATUS ReleaseResources();
215
216 };
217
218 #endif // __CodechalEncodeCscDsG12__