Debian Codegraph @

media_driver/linux/common/codec/ddi/media_ddi_encode_vp9.h

raw
1 /*
2 * Copyright (c) 2017, 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 //!
24 //! \file media_ddi_encode_vp9.h
25 //! \brief Defines class for DDI media vp9 encode
26 //!
27
28 #include "media_ddi_encode_base.h"
29
30 //!
31 //! \class DdiEncodeVp9
32 //! \brief Ddi encode VP9
33 //!
34 class DdiEncodeVp9 : public DdiEncodeBase
35 {
36 public:
37 //!
38 //! \brief Constructor
39 //!
40 DdiEncodeVp9(){};
41
42 //!
43 //! \brief Destructor
44 //!
45 ~DdiEncodeVp9();
46
47 //!
48 //! \brief Initialize Encode Context and CodecHal Setting for Vp9
49 //!
50 //! \param [out] codecHalSettings
51 //! Pointer to CodechalSetting *
52 //!
53 //! \return VAStatus
54 //! VA_STATUS_SUCCESS if success, else fail reason
55 //!
56 VAStatus ContextInitialize(
57 CodechalSetting *codecHalSettings) override;
58
59 //!
60 //! \brief Parse buffer to the server.
61 //!
62 //! \param [in] ctx
63 //! Pointer to VADriverContextP
64 //! \param [in] context
65 //! VA context ID
66 //! \param [in] buffers
67 //! Pointer to VABufferID
68 //! \param [in] numBuffers
69 //! Number of buffers
70 //!
71 //! \return VAStatus
72 //! VA_STATUS_SUCCESS if success, else fail reason
73 //!
74 VAStatus RenderPicture(
75 VADriverContextP ctx,
76 VAContextID context,
77 VABufferID *buffers,
78 int32_t numBuffers) override;
79
80 protected:
81 //!
82 //! \brief Reset Encode Context At Frame Level
83 //!
84 //! \return VAStatus
85 //! VA_STATUS_SUCCESS if success, else fail reason
86 //!
87 VAStatus ResetAtFrameLevel() override;
88
89 //!
90 //! \brief Encode in CodecHal for Vp9
91 //!
92 //! \param [in] numSlices
93 //! Number of slice data structures
94 //!
95 //! \return VAStatus
96 //! VA_STATUS_SUCCESS if success, else fail reason
97 //!
98 VAStatus EncodeInCodecHal(
99 uint32_t numSlices) override;
100
101 //!
102 //! \brief Parse Picture Parameter buffer to Encode Context
103 //!
104 //! \param [in] mediaCtx
105 //! Pointer to DDI_MEDIA_CONTEXT
106 //! \param [in] ptr
107 //! Pointer to Picture Parameter buffer
108 //!
109 //! \return VAStatus
110 //! VA_STATUS_SUCCESS if success, else fail reason
111 //!
112 VAStatus ParsePicParams(
113 DDI_MEDIA_CONTEXT *mediaCtx,
114 void *ptr) override;
115
116 uint32_t getSequenceParameterBufferSize() override;
117
118 uint32_t getPictureParameterBufferSize() override;
119
120 uint32_t getQMatrixBufferSize() override;
121
122 //!
123 //! \brief Parse QMatrix buffer to Encode Context
124 //!
125 //! \param [in] ptr
126 //! Pointer to QMatrix buffer
127 //!
128 //! \return VAStatus
129 //! VA_STATUS_SUCCESS if success, else fail reason
130 //!
131 VAStatus Qmatrix(
132 void *ptr);
133
134 //!
135 //! \brief Parse Sequence Parameter buffer to Encode Context
136 //!
137 //! \param [in] ptr
138 //! Pointer to Sequence Parameter buffer
139 //!
140 //! \return VAStatus
141 //! VA_STATUS_SUCCESS if success, else fail reason
142 //!
143 VAStatus ParseSeqParams(
144 void *ptr);
145
146 //!
147 //! \brief Parse Packed Header Parameter buffer to Encode Context
148 //!
149 //! \param [in] ptr
150 //! Pointer to Packed Header Parameter buffer
151 //!
152 //! \return VAStatus
153 //! VA_STATUS_SUCCESS if success, else fail reason
154 //!
155 VAStatus ParsePackedHeaderParams(
156 void *ptr);
157
158 //!
159 //! \brief Parse Packed Header Data buffer to Encode Context
160 //!
161 //! \param [in] ptr
162 //! Pointer to Packed Header Data buffer
163 //!
164 //! \return VAStatus
165 //! VA_STATUS_SUCCESS if success, else fail reason
166 //!
167 VAStatus ParsePackedHeaderData(
168 void *ptr);
169
170 //!
171 //! \brief Parse Misc Parameter buffer to Encode Context
172 //!
173 //! \param [in] ptr
174 //! Pointer to Misc Parameter buffer
175 //!
176 //! \return VAStatus
177 //! VA_STATUS_SUCCESS if success, else fail reason
178 //!
179 VAStatus ParseMiscParams(
180 void *ptr);
181
182 //!
183 //! \brief Parse Segment Map Parameter buffer to Encode Context
184 //!
185 //! \param [in] buf
186 //! Pointer to Segment Map Parameter buffer
187 //!
188 //! \return VAStatus
189 //! VA_STATUS_SUCCESS if success, else fail reason
190 //!
191 VAStatus ParseSegMapParams(
192 DDI_MEDIA_BUFFER *buf);
193
194 //!
195 //! \brief Report extra encode status for completed coded buffer.
196 //!
197 //! \param [in] encodeStatusReport
198 //! Pointer to encode status reported by Codechal
199 //! \param [out] codedBufferSegment
200 //! Pointer to coded buffer segment
201 //!
202 //! \return VAStatus
203 //! VA_STATUS_SUCCESS if success, else fail reason
204 //!
205 VAStatus ReportExtraStatus(
206 EncodeStatusReport *encodeStatusReport,
207 VACodedBufferSegment *codedBufferSegment) override;
208
209 private:
210 //!
211 //! \brief Setup Codec Picture for Vp9
212 //!
213 //! \param [in] mediaCtx
214 //! Pointer to DDI_MEDIA_CONTEXT
215 //! \param [in] rtTbl
216 //! Pointer to DDI_CODEC_RENDER_TARGET_TABLE
217 //! \param [in] surfaceID
218 //! VASurface index
219 //! \param [in] picReference
220 //! Reference picture flag
221 //! \param [out] codecHalPic
222 //! Pointer to CODEC_PICTURE
223 //!
224 //! \return void
225 //!
226 void SetupCodecPicture(
227 DDI_MEDIA_CONTEXT *mediaCtx,
228 DDI_CODEC_RENDER_TARGET_TABLE *rtTbl,
229 CODEC_PICTURE *codecHalPic,
230 VASurfaceID surfaceID,
231 bool picReference);
232
233 //!
234 //! \brief Parse Misc Param Buffer Quality Level to Encode Context
235 //!
236 //! \param [in] data
237 //! Pointer to Misc Param Buffer Quality Level
238 //!
239 //! \return VAStatus
240 //! VA_STATUS_SUCCESS if success, else fail reason
241 //!
242 VAStatus ParseMiscParamQualityLevel(
243 void *data);
244
245 //!
246 //! \brief Parse Misc Param VBV Data buffer to Encode Context
247 //!
248 //! \param [in] data
249 //! Pointer to Misc Param VBV Data buffer
250 //!
251 //! \return VAStatus
252 //! VA_STATUS_SUCCESS if success, else fail reason
253 //!
254 VAStatus ParseMiscParamVBV(
255 void *data);
256
257 //!
258 //! \brief Parse Misc Param FrameRate Data buffer to Encode Context
259 //!
260 //! \param [in] data
261 //! Pointer to Misc Param FR Data buffer
262 //!
263 //! \return VAStatus
264 //! VA_STATUS_SUCCESS if success, else fail reason
265 //!
266 VAStatus ParseMiscParamFR(
267 void *data);
268
269 //!
270 //! \brief Parse Misc Param RateControl Data buffer to Encode Context
271 //!
272 //! \param [in] data
273 //! Pointer to Misc Param RC Data buffer
274 //!
275 //! \return VAStatus
276 //! VA_STATUS_SUCCESS if success, else fail reason
277 //!
278 VAStatus ParseMiscParamRC(
279 void *data);
280
281 //!
282 //! \brief Parse Misc Param Enc Quality to Encode Context
283 //!
284 //! \param [in] data
285 //! Pointer to Misc Param Private Data buffer
286 //!
287 //! \return VAStatus
288 //! VA_STATUS_SUCCESS if success, else fail reason
289 //!
290 VAStatus ParseMiscParamEncQuality(
291 void *data);
292
293 //!
294 //! \brief Parse Misc Parameter Temporal Layer Params buffer to Encode Context
295 //!
296 //! \param [in] data
297 //! Pointer to Misc Parameter Temporal Layer Params buffer
298 //!
299 //! \return VAStatus
300 //! VA_STATUS_SUCCESS if success, else fail reason
301 //!
302 VAStatus ParseMiscParameterTemporalLayerParams(
303 void *data);
304
305 CODEC_VP9_ENCODE_SEGMENT_PARAMS *m_segParams = nullptr; //!< Segment parameters.
306
307 VACodedBufferVP9Status *m_codedBufStatus = nullptr; //!< .Coded buffer status
308
309 private:
310 uint32_t savedTargetBit[CODECHAL_ENCODE_VP9_MAX_NUM_TEMPORAL_LAYERS] = { 0 };
311 uint32_t savedMaxBitRate[CODECHAL_ENCODE_VP9_MAX_NUM_TEMPORAL_LAYERS] = { 0 };
312
313 uint32_t savedFrameRate[CODECHAL_ENCODE_VP9_MAX_NUM_TEMPORAL_LAYERS] = { 0 };
314
315 uint32_t savedGopSize = 0;
316
317 uint32_t savedHrdSize = 0;
318
319 uint32_t savedHrdBufFullness = 0;
320
321 bool headerInsertFlag = 0;
322
323 uint32_t lastPackedHeaderType = 0;
324
325 uint8_t vp9TargetUsage = 0;
326
327 bool isSegParamsChanged = false;
328 };