1 /*
2 * Copyright (c) 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 encode_av1_pipeline.h
24 //! \brief Defines the interface for av1 encode pipeline
25 //!
26 #include "encode_av1_pipeline.h"
27 #include "encode_utils.h"
28 #include "encode_av1_basic_feature.h"
29
30 namespace encode
31 {
Av1Pipeline(CodechalHwInterfaceNext * hwInterface,CodechalDebugInterface * debugInterface)32 Av1Pipeline::Av1Pipeline(
33 CodechalHwInterfaceNext * hwInterface,
34 CodechalDebugInterface *debugInterface)
35 : EncodePipeline(hwInterface, debugInterface)
36 {
37 }
38
Initialize(void * settings)39 MOS_STATUS Av1Pipeline::Initialize(void *settings)
40 {
41 ENCODE_FUNC_CALL();
42 m_dualEncEnable = ((CodechalSetting *)settings)->isDualEncEnabled;
43
44 #if (_DEBUG || _RELEASE_INTERNAL)
45 MediaUserSetting::Value outValue;
46 ReadUserSetting(m_userSettingPtr,
47 outValue,
48 "AV1 Dual Encoder Force Off",
49 MediaUserSetting::Group::Sequence);
50
51 m_dualEncEnable &= !outValue.Get<bool>();
52 #endif
53
54 ENCODE_CHK_STATUS_RETURN(EncodePipeline::Initialize(settings));
55
56 #if MHW_HWCMDPARSER_ENABLED
57 mhw::HwcmdParser::InitInstance(m_osInterface, mhw::HwcmdParser::AddOnMode::AV1e);
58 #endif
59
60 return MOS_STATUS_SUCCESS;
61 }
62
Uninitialize()63 MOS_STATUS Av1Pipeline::Uninitialize()
64 {
65 ENCODE_FUNC_CALL();
66
67 return EncodePipeline::Uninitialize();
68 }
69
UserFeatureReport()70 MOS_STATUS Av1Pipeline::UserFeatureReport()
71 {
72 ENCODE_FUNC_CALL();
73 ENCODE_CHK_STATUS_RETURN(EncodePipeline::UserFeatureReport());
74
75 //TBD
76
77 #if (_DEBUG || _RELEASE_INTERNAL)
78 ReportUserSettingForDebug(
79 m_userSettingPtr,
80 __MEDIA_USER_FEATURE_VALUE_SIM_IN_USE,
81 m_osInterface->bSimIsActive,
82 MediaUserSetting::Group::Device);
83 #endif
84
85 return MOS_STATUS_SUCCESS;
86 }
87
Prepare(void * params)88 MOS_STATUS Av1Pipeline::Prepare(void *params)
89 {
90 ENCODE_FUNC_CALL();
91
92 ENCODE_CHK_STATUS_RETURN(EncodePipeline::Prepare(params));
93
94 auto basicFeature = dynamic_cast<Av1BasicFeature *>(m_featureManager->GetFeature(Av1FeatureIDs::basicFeature));
95 ENCODE_CHK_NULL_RETURN(basicFeature);
96
97 CODECHAL_DEBUG_TOOL(
98 m_debugInterface->m_currPic = basicFeature->m_currOriginalPic;
99 m_debugInterface->m_bufferDumpFrameNum = basicFeature->m_frameNum;
100 m_debugInterface->m_frameType = basicFeature->m_pictureCodingType;
101
102 if (basicFeature->m_newSeq) {
103 ENCODE_CHK_STATUS_RETURN(DumpSeqParams(
104 basicFeature->m_av1SeqParams));
105 }
106
107 ENCODE_CHK_STATUS_RETURN(DumpPicParams(
108 basicFeature->m_av1PicParams));
109
110 uint32_t numTilegroups = 0;
111 PCODEC_AV1_ENCODE_TILE_GROUP_PARAMS tileGroupParams = nullptr;
112 RUN_FEATURE_INTERFACE_RETURN(Av1EncodeTile, Av1FeatureIDs::encodeTile, GetTileGroupInfo, tileGroupParams, numTilegroups);
113
114 ENCODE_CHK_NULL_RETURN(tileGroupParams);
115
116 for (uint32_t i = 0; i < numTilegroups; i++, tileGroupParams++){
117 ENCODE_CHK_STATUS_RETURN(DumpTileGroupParams(
118 tileGroupParams, i))}
119 )
120
121 #if MHW_HWCMDPARSER_ENABLED
122 char frameType = '\0';
123 switch (basicFeature->m_pictureCodingType)
124 {
125 case I_TYPE:
126 frameType = 'I';
127 break;
128 case P_TYPE:
129 if (basicFeature->m_ref.IsLowDelay())
130 frameType = 'G';
131 else if (basicFeature->m_av1PicParams->ref_frame_ctrl_l1.RefFrameCtrl.value != 0)
132 frameType = 'B';
133 else
134 frameType = 'P';
135 break;
136 default:
137 frameType = '\0';
138 break;
139 }
140
141 auto instance = mhw::HwcmdParser::GetInstance();
142 if (instance)
143 {
144 instance->Update(frameType, (void *)m_featureManager);
145 }
146 #endif
147
148 return MOS_STATUS_SUCCESS;
149 }
150
CreateBufferTracker()151 MOS_STATUS Av1Pipeline::CreateBufferTracker()
152 {
153 return MOS_STATUS_SUCCESS;
154 }
155
CreateStatusReport()156 MOS_STATUS Av1Pipeline::CreateStatusReport()
157 {
158 return MOS_STATUS_SUCCESS;
159 }
160
161 #if USE_CODECHAL_DEBUG_TOOL
DumpSeqParams(const CODEC_AV1_ENCODE_SEQUENCE_PARAMS * seqParams)162 MOS_STATUS Av1Pipeline::DumpSeqParams(
163 const CODEC_AV1_ENCODE_SEQUENCE_PARAMS *seqParams)
164 {
165 ENCODE_FUNC_CALL();
166 ENCODE_CHK_NULL_RETURN(m_debugInterface);
167
168 if (!m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrSeqParams))
169 {
170 return MOS_STATUS_SUCCESS;
171 }
172
173 CODECHAL_DEBUG_CHK_NULL(seqParams);
174
175 std::ostringstream oss;
176 oss.setf(std::ios::showbase | std::ios::uppercase);
177 oss << "# DDI Parameters:" << std::endl;
178 oss << "seq_profile = " << +seqParams->seq_profile << std::endl;
179 oss << "seq_level_idx = " << +seqParams->seq_level_idx << std::endl;
180 oss << "GopPicSize = " << +seqParams->GopPicSize << std::endl;
181 oss << "GopRefDist = " << +seqParams->GopRefDist << std::endl;
182 oss << "GopOptFlag = " << +seqParams->GopOptFlag << std::endl;
183 oss << "TargetUsage = " << +seqParams->TargetUsage << std::endl;
184 oss << "RateControlMethod = " << +seqParams->RateControlMethod << std::endl;
185
186 for (uint8_t i = 0; i < 8; i++)
187 {
188 oss << "TargetBitRate[" << +i << "] = " << +seqParams->TargetBitRate[i] << std::endl;
189 }
190
191 oss << "MaxBitRate = " << +seqParams->MaxBitRate << std::endl;
192 oss << "MinBitRate = " << +seqParams->MinBitRate << std::endl;
193 oss << "InitVBVBufferFullnessInBit = " << +seqParams->InitVBVBufferFullnessInBit << std::endl;
194 oss << "VBVBufferSizeInBit = " << +seqParams->VBVBufferSizeInBit << std::endl;
195 oss << "OptimalVBVBufferLevelInBit = " << +seqParams->OptimalVBVBufferLevelInBit << std::endl;
196 oss << "UpperVBVBufferLevelThresholdInBit = " << +seqParams->UpperVBVBufferLevelThresholdInBit << std::endl;
197 oss << "LowerVBVBufferLevelThresholdInBit = " << +seqParams->LowerVBVBufferLevelThresholdInBit << std::endl;
198 oss << "ResetBRC = " << +seqParams->SeqFlags.fields.ResetBRC << std::endl;
199 oss << "StillPicture = " << +seqParams->SeqFlags.fields.StillPicture << std::endl;
200 oss << "UseRawReconRef = " << +seqParams->SeqFlags.fields.UseRawReconRef << std::endl;
201 oss << "DisplayFormatSwizzle = " << +seqParams->SeqFlags.fields.DisplayFormatSwizzle << std::endl;
202 oss << "bLookAheadPhase = " << +seqParams->SeqFlags.fields.bLookAheadPhase << std::endl;
203 oss << "HierarchicalFlag = " << +seqParams->SeqFlags.fields.HierarchicalFlag << std::endl;
204 oss << "Reserved0 = " << +seqParams->SeqFlags.fields.Reserved0 << std::endl;
205 oss << "SeqFlags.value = " << +seqParams->SeqFlags.value << std::endl;
206 oss << "UserMaxIFrameSize = " << +seqParams->UserMaxIFrameSize << std::endl;
207 oss << "UserMaxPBFrameSize = " << +seqParams->UserMaxPBFrameSize << std::endl;
208
209 for (uint8_t i = 0; i < 8; i++)
210 {
211 oss << "FrameRate[" << +i << "].Numerator = " << +seqParams->FrameRate[i].Numerator << std::endl;
212 oss << "FrameRate[" << +i << "].Denominator = " << +seqParams->FrameRate[i].Denominator << std::endl;
213 }
214
215 oss << "NumTemporalLayersMinus1 = " << +seqParams->NumTemporalLayersMinus1 << std::endl;
216 oss << "ICQQualityFactor = " << +seqParams->ICQQualityFactor << std::endl;
217 oss << "InputColorSpace = " << +seqParams->InputColorSpace << std::endl;
218 oss << "ScenarioInfo = " << +seqParams->ScenarioInfo << std::endl;
219 oss << "ContentInfo = " << +seqParams->ContentInfo << std::endl;
220 oss << "FrameSizeTolerance = " << +seqParams->FrameSizeTolerance << std::endl;
221 oss << "SlidingWindowSize = " << +seqParams->SlidingWindowSize << std::endl;
222 oss << "MaxBitRatePerSlidingWindow = " << +seqParams->MaxBitRatePerSlidingWindow << std::endl;
223 oss << "MinBitRatePerSlidingWindow = " << +seqParams->MinBitRatePerSlidingWindow << std::endl;
224 oss << "enable_order_hint = " << +seqParams->CodingToolFlags.fields.enable_order_hint << std::endl;
225 oss << "enable_superres = " << +seqParams->CodingToolFlags.fields.enable_superres << std::endl;
226 oss << "enable_cdef = " << +seqParams->CodingToolFlags.fields.enable_cdef << std::endl;
227 oss << "enable_restoration = " << +seqParams->CodingToolFlags.fields.enable_restoration << std::endl;
228 oss << "enable_warped_motion = " << +seqParams->CodingToolFlags.fields.enable_warped_motion << std::endl;
229 oss << "Reserved3 = " << +seqParams->CodingToolFlags.fields.Reserved3 << std::endl;
230 oss << "CodingToolFlags.value = " << +seqParams->CodingToolFlags.value << std::endl;
231
232 oss << "order_hint_bits_minus_1 = " << +seqParams->order_hint_bits_minus_1 << std::endl;
233 oss << "LookaheadDepth = " << +seqParams->LookaheadDepth << std::endl;
234 oss << "TargetFrameSizeConfidence = " << +seqParams->TargetFrameSizeConfidence << std::endl;
235 oss << "Reserved8b2 = " << +seqParams->Reserved8b2 << std::endl;
236 oss << "Reserved8b3 = " << +seqParams->Reserved8b3 << std::endl;
237
238 for (uint8_t i = 0; i < 8; i++)
239 {
240 oss << "Reserved32b[" << +i << "] = " << +seqParams->Reserved32b[i] << std::endl;
241 }
242
243 const char *fileName = m_debugInterface->CreateFileName(
244 "_DDIEnc",
245 CodechalDbgBufferType::bufSeqParams,
246 CodechalDbgExtType::txt);
247
248 std::ofstream ofs(fileName, std::ios::out);
249 ofs << oss.str();
250 ofs.close();
251
252 if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrDriverUltDump))
253 {
254 if (!m_debugInterface->m_ddiFileName.empty())
255 {
256 std::ofstream ofs(m_debugInterface->m_ddiFileName, std::ios::app);
257 ofs << "SeqParamFile"
258 << " = \"" << m_debugInterface->m_fileName << "\"" << std::endl;
259 ofs.close();
260 }
261 }
262 return MOS_STATUS_SUCCESS;
263 }
264
DumpPicParams(const CODEC_AV1_ENCODE_PICTURE_PARAMS * picParams)265 MOS_STATUS Av1Pipeline::DumpPicParams(
266 const CODEC_AV1_ENCODE_PICTURE_PARAMS *picParams)
267 {
268 ENCODE_FUNC_CALL();
269 ENCODE_CHK_NULL_RETURN(m_debugInterface);
270
271 if (!m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrPicParams))
272 {
273 return MOS_STATUS_SUCCESS;
274 }
275
276 CODECHAL_DEBUG_CHK_NULL(picParams);
277
278 std::ostringstream oss;
279 oss.setf(std::ios::showbase | std::ios::uppercase);
280
281 oss << "# DDI Parameters:" << std::endl;
282 oss << "frame_width_minus1 = " << +picParams->frame_width_minus1 << std::endl;
283 oss << "frame_height_minus1 = " << +picParams->frame_height_minus1 << std::endl;
284 oss << "NumTileGroupsMinus1 = " << +picParams->NumTileGroupsMinus1 << std::endl;
285 oss << "Reserved8b = " << +picParams->Reserved8b << std::endl;
286 oss << "CurrOriginalPic.FrameIdx = " << +picParams->CurrOriginalPic.FrameIdx << std::endl;
287 oss << "CurrOriginalPic.PicFlags = " << +picParams->CurrOriginalPic.PicFlags << std::endl;
288 oss << "CurrOriginalPic.PicEntry = " << +picParams->CurrOriginalPic.PicEntry << std::endl;
289 oss << "CurrReconstructedPic.FrameIdx = " << +picParams->CurrReconstructedPic.FrameIdx << std::endl;
290 oss << "CurrReconstructedPic.PicEntry = " << +picParams->CurrReconstructedPic.PicEntry << std::endl;
291 oss << "CurrReconstructedPic.PicFlags = " << +picParams->CurrReconstructedPic.PicFlags << std::endl;
292
293 for (uint8_t i = 0; i < 8; i++)
294 {
295 oss << "RefFrameList[" << +i << "].FrameIdx = " << +picParams->RefFrameList[i].FrameIdx << std::endl;
296 oss << "RefFrameList[" << +i << "].PicFlags = " << +picParams->RefFrameList[i].PicFlags << std::endl;
297 oss << "RefFrameList[" << +i << "].PicEntry = " << +picParams->RefFrameList[i].PicEntry << std::endl;
298 }
299
300 for (uint8_t i = 0; i < 7; i++)
301 {
302 oss << "ref_frame_idx[" << +i << "] = " << +picParams->ref_frame_idx[i] << std::endl;
303 }
304
305 oss << "HierarchLevelPlus1 = " << +picParams->HierarchLevelPlus1 << std::endl;
306 oss << "primary_ref_frame = " << +picParams->primary_ref_frame << std::endl;
307 oss << "ref_frame_ctrl_l0 = " << +picParams->ref_frame_ctrl_l0.RefFrameCtrl.value << std::endl;
308 oss << "ref_frame_ctrl_l1 = " << +picParams->ref_frame_ctrl_l1.RefFrameCtrl.value << std::endl;
309 oss << "order_hint = " << +picParams->order_hint << std::endl;
310 oss << "frame_type = " << +picParams->PicFlags.fields.frame_type << std::endl;
311 oss << "error_resilient_mode = " << +picParams->PicFlags.fields.error_resilient_mode << std::endl;
312 oss << "disable_cdf_update = " << +picParams->PicFlags.fields.disable_cdf_update << std::endl;
313 oss << "use_superres = " << +picParams->PicFlags.fields.use_superres << std::endl;
314 oss << "allow_high_precision_mv = " << +picParams->PicFlags.fields.allow_high_precision_mv << std::endl;
315 oss << "use_ref_frame_mvs = " << +picParams->PicFlags.fields.use_ref_frame_mvs << std::endl;
316 oss << "disable_frame_end_update_cdf = " << +picParams->PicFlags.fields.disable_frame_end_update_cdf << std::endl;
317 oss << "reduced_tx_set_used = " << +picParams->PicFlags.fields.reduced_tx_set_used << std::endl;
318 oss << "SegIdBlockSize = " << +picParams->PicFlags.fields.SegIdBlockSize << std::endl;
319 oss << "EnableFrameOBU = " << +picParams->PicFlags.fields.EnableFrameOBU << std::endl;
320 oss << "DisableFrameRecon = " << +picParams->PicFlags.fields.DisableFrameRecon << std::endl;
321 oss << "Reserved2 = " << +picParams->PicFlags.fields.Reserved2 << std::endl;
322 oss << "PicFlags.value = " << +picParams->PicFlags.value << std::endl;
323
324 // deblocking filter
325 for (uint8_t i = 0; i < 2; i++)
326 {
327 oss << "filter_level[" << +i << "] = " << +picParams->filter_level[i] << std::endl;
328 }
329
330 oss << "filter_level_u = " << +picParams->filter_level_u << std::endl;
331 oss << "filter_level_v = " << +picParams->filter_level_v << std::endl;
332 oss << "sharpness_level = " << +picParams->cLoopFilterInfoFlags.fields.sharpness_level << std::endl;
333 oss << "mode_ref_delta_enabled = " << +picParams->cLoopFilterInfoFlags.fields.mode_ref_delta_enabled << std::endl;
334 oss << "mode_ref_delta_update = " << +picParams->cLoopFilterInfoFlags.fields.mode_ref_delta_update << std::endl;
335 oss << "Reserved3= " << +picParams->cLoopFilterInfoFlags.fields.Reserved3 << std::endl;
336 oss << "cLoopFilterInfoFlags.value = " << +picParams->cLoopFilterInfoFlags.value << std::endl;
337 oss << "superres_scale_denominator = " << +picParams->superres_scale_denominator << std::endl;
338 oss << "interp_filter = " << +picParams->interp_filter << std::endl;
339 oss << "Reserved4 = " << +picParams->Reserved4 << std::endl;
340
341 for (uint8_t i = 0; i < 8; i++)
342 {
343 oss << "ref_deltas[" << +i << "] = " << +picParams->ref_deltas[i] << std::endl;
344 }
345
346 for (uint8_t i = 0; i < 2; i++)
347 {
348 oss << "mode_deltas[" << +i << "] = " << +picParams->mode_deltas[i] << std::endl;
349 }
350
351 // quantization
352 oss << "base_qindex = " << +picParams->base_qindex << std::endl;
353 oss << "base_qindex = " << +picParams->base_qindex << std::endl;
354 oss << "y_dc_delta_q = " << +picParams->y_dc_delta_q << std::endl;
355 oss << "u_dc_delta_q = " << +picParams->u_dc_delta_q << std::endl;
356 oss << "u_ac_delta_q = " << +picParams->u_ac_delta_q << std::endl;
357 oss << "v_dc_delta_q = " << +picParams->v_dc_delta_q << std::endl;
358 oss << "v_ac_delta_q = " << +picParams->v_ac_delta_q << std::endl;
359 oss << "MinBaseQIndex = " << +picParams->MinBaseQIndex << std::endl;
360 oss << "MaxBaseQIndex = " << +picParams->MaxBaseQIndex << std::endl;
361 oss << "Reserved5 = " << +picParams->Reserved5 << std::endl;
362
363 // quantization_matrix
364 oss << "using_qmatrix = " << +picParams->wQMatrixFlags.fields.using_qmatrix << std::endl;
365 oss << "qm_y = " << +picParams->wQMatrixFlags.fields.qm_y << std::endl;
366 oss << "qm_u = " << +picParams->wQMatrixFlags.fields.qm_u << std::endl;
367 oss << "qm_v = " << +picParams->wQMatrixFlags.fields.qm_v << std::endl;
368 oss << "Reserved6 = " << +picParams->wQMatrixFlags.fields.Reserved6 << std::endl;
369 oss << "wQMatrixFlags.value = " << +picParams->wQMatrixFlags.value << std::endl;
370 oss << "Reserved7 = " << +picParams->Reserved7 << std::endl;
371
372 // delta_q parameters
373 oss << "delta_q_present_flag = " << +picParams->dwModeControlFlags.fields.delta_q_present_flag << std::endl;
374 oss << "log2_delta_q_res = " << +picParams->dwModeControlFlags.fields.log2_delta_q_res << std::endl;
375
376 // delta_lf parameters
377 oss << "delta_lf_present_flag = " << +picParams->dwModeControlFlags.fields.delta_lf_present_flag << std::endl;
378 oss << "log2_delta_lf_res = " << +picParams->dwModeControlFlags.fields.log2_delta_lf_res << std::endl;
379 oss << "delta_lf_multi = " << +picParams->dwModeControlFlags.fields.delta_lf_multi << std::endl;
380
381 // read_tx_mode
382 oss << "tx_mode = " << +picParams->dwModeControlFlags.fields.tx_mode << std::endl;
383
384 // read_frame_reference_mode
385 oss << "reference_mode = " << +picParams->dwModeControlFlags.fields.reference_mode << std::endl;
386 oss << "reduced_tx_set_used = " << +picParams->dwModeControlFlags.fields.reduced_tx_set_used << std::endl;
387
388 oss << "skip_mode_present = " << +picParams->dwModeControlFlags.fields.skip_mode_present << std::endl;
389 oss << "Reserved8 = " << +picParams->dwModeControlFlags.fields.Reserved8 << std::endl;
390 oss << "dwModeControlFlags.value = " << +picParams->dwModeControlFlags.value << std::endl;
391
392 oss << "stAV1Segments.SegmentFlags.fields.segmentation_enabled = " << +picParams->stAV1Segments.SegmentFlags.fields.segmentation_enabled << std::endl;
393 oss << "stAV1Segments.SegmentFlags.fields.SegmentNumber = " << +picParams->stAV1Segments.SegmentFlags.fields.SegmentNumber << std::endl;
394 oss << "stAV1Segments.SegmentFlags.fields.update_map = " << +picParams->stAV1Segments.SegmentFlags.fields.update_map << std::endl;
395 oss << "stAV1Segments.SegmentFlags.fields.temporal_update = " << +picParams->stAV1Segments.SegmentFlags.fields.temporal_update << std::endl;
396 oss << "stAV1Segments.SegmentFlags.fields.Reserved0 = " << +picParams->stAV1Segments.SegmentFlags.fields.Reserved0 << std::endl;
397 oss << "stAV1Segments.SegmentFlags.value = " << +picParams->stAV1Segments.SegmentFlags.value << std::endl;
398
399 for (uint8_t i = 0; i < 8; i++)
400 {
401 for (uint8_t j = 0; j < 8; j++)
402 {
403 oss << "stAV1Segments.feature_data[" << +i << "][" << +j << "] = " << +picParams->stAV1Segments.feature_data[i][j] << std::endl;
404 }
405 }
406
407 for (uint8_t i = 0; i < 8; i++)
408 {
409 oss << "stAV1Segments.feature_mask[" << +i << "] = " << +picParams->stAV1Segments.feature_mask[i] << std::endl;
410 }
411
412 for (uint8_t i = 0; i < 4; i++)
413 {
414 oss << "stAV1Segments.Reserved1[" << +i << "] = " << +picParams->stAV1Segments.Reserved1[i] << std::endl;
415 }
416
417 oss << "tile_cols = " << +picParams->tile_cols << std::endl;
418
419 for (uint8_t i = 0; i < 63; i++)
420 {
421 oss << "width_in_sbs_minus_1[" << +i << "] = " << +picParams->width_in_sbs_minus_1[i] << std::endl;
422 }
423
424 oss << "tile_rows = " << +picParams->tile_rows << std::endl;
425
426 for (uint8_t i = 0; i < 63; i++)
427 {
428 oss << "height_in_sbs_minus_1[" << +i << "] = " << +picParams->height_in_sbs_minus_1[i] << std::endl;
429 }
430
431 oss << "context_update_tile_id = " << +picParams->context_update_tile_id << std::endl;
432 oss << "temporal_id = " << +picParams->temporal_id << std::endl;
433
434 //CDEF
435 oss << "cdef_damping_minus_3 = " << +picParams->cdef_damping_minus_3 << std::endl;
436 oss << "cdef_bits = " << +picParams->cdef_bits << std::endl;
437
438 for (uint8_t i = 0; i < 8; i++)
439 {
440 oss << "cdef_y_strengths[" << +i << "] = " << +picParams->cdef_y_strengths[i] << std::endl;
441 }
442
443 for (uint8_t i = 0; i < 8; i++)
444 {
445 oss << "cdef_uv_strengths[" << +i << "] = " << +picParams->cdef_uv_strengths[i] << std::endl;
446 }
447
448 oss << "yframe_restoration_type = " << +picParams->LoopRestorationFlags.fields.yframe_restoration_type << std::endl;
449 oss << "cbframe_restoration_type = " << +picParams->LoopRestorationFlags.fields.cbframe_restoration_type << std::endl;
450 oss << "crframe_restoration_type = " << +picParams->LoopRestorationFlags.fields.crframe_restoration_type << std::endl;
451 oss << "lr_unit_shift = " << +picParams->LoopRestorationFlags.fields.lr_unit_shift << std::endl;
452 oss << "lr_uv_shift = " << +picParams->LoopRestorationFlags.fields.lr_uv_shift << std::endl;
453 oss << "Reserved9 = " << +picParams->LoopRestorationFlags.fields.Reserved9 << std::endl;
454 oss << "LoopRestorationFlags.value = " << +picParams->LoopRestorationFlags.value << std::endl;
455
456 // global motion
457 for (uint8_t i = 0; i < 7; i++)
458 {
459 oss << "wm[" << +i << "].wmtype = " << +picParams->wm[i].wmtype << std::endl;
460
461 for (uint8_t j = 0; j < 8; j++)
462 {
463 oss << "wm[" << +i << "].wmmat[" << +j << "] = " << +picParams->wm[i].wmmat[j] << std::endl;
464 }
465
466 oss << "wm[" << +i << "].wmtype = " << +picParams->wm[i].invalid << std::endl;
467 }
468
469 oss << "QIndexBitOffset = " << +picParams->QIndexBitOffset << std::endl;
470 oss << "SegmentationBitOffset = " << +picParams->SegmentationBitOffset << std::endl;
471 oss << "LoopFilterParamsBitOffset = " << +picParams->LoopFilterParamsBitOffset << std::endl;
472 oss << "CDEFParamsSizeInBits = " << +picParams->CDEFParamsSizeInBits << std::endl;
473 oss << "obu_extension_flag = " << +picParams->TileGroupOBUHdrInfo.fields.obu_extension_flag << std::endl;
474 oss << "obu_has_size_field = " << +picParams->TileGroupOBUHdrInfo.fields.obu_has_size_field << std::endl;
475 oss << "temporal_id = " << +picParams->TileGroupOBUHdrInfo.fields.temporal_id << std::endl;
476 oss << "spatial_id = " << +picParams->TileGroupOBUHdrInfo.fields.spatial_id << std::endl;
477 oss << "CDEFParamsBitOffset = " << +picParams->CDEFParamsBitOffset << std::endl;
478 oss << "reserved8bits0 = " << +picParams->reserved8bits0 << std::endl;
479 oss << "FrameHdrOBUSizeInBits = " << +picParams->FrameHdrOBUSizeInBits << std::endl;
480 oss << "FrameHdrOBUSizeByteOffset = " << +picParams->FrameHdrOBUSizeByteOffset << std::endl;
481 oss << "StatusReportFeedbackNumber = " << +picParams->StatusReportFeedbackNumber << std::endl;
482
483 // Skip Frames
484 oss << "reserved8bs1 = " << +picParams->reserved8bs1 << std::endl;
485 oss << "reserved8bs2 = " << +picParams->reserved8bs2 << std::endl;
486 oss << "NumSkipFrames = " << +picParams->NumSkipFrames << std::endl;
487 oss << "FrameSizeReducedInBytes = " << +picParams->FrameSizeReducedInBytes << std::endl;
488 oss << "NumDirtyRects = " << +picParams->NumDirtyRects << std::endl;
489
490 if ((picParams->NumDirtyRects > 0) && picParams->pDirtyRect)
491 {
492 auto pDR = picParams->pDirtyRect;
493 for (uint16_t i = 0; i < picParams->NumDirtyRects; i++, pDR++)
494 {
495 oss << "pDirtyRect[" << +i << "].Top = " << +pDR->Top << std::endl;
496 oss << "pDirtyRect[" << +i << "].Bottom = " << +pDR->Bottom << std::endl;
497 oss << "pDirtyRect[" << +i << "].Left = " << +pDR->Left << std::endl;
498 oss << "pDirtyRect[" << +i << "].Right = " << +pDR->Right << std::endl;
499 }
500 }
501
502 oss << "NumMoveRects = " << +picParams->NumMoveRects << std::endl;
503
504 if ((picParams->NumMoveRects > 0) && picParams->pMoveRect)
505 for (uint16_t i = 0; i < picParams->NumMoveRects; i++)
506 {
507 oss << "pMoveRect[" << +i << "].SourcePointX = " << +picParams->pMoveRect->SourcePointX << std::endl;
508 oss << "pMoveRect[" << +i << "].SourcePointY = " << +picParams->pMoveRect->SourcePointY << std::endl;
509 oss << "pMoveRect[" << +i << "].DestRectTop = " << +picParams->pMoveRect->DestRectTop << std::endl;
510 oss << "pMoveRect[" << +i << "].DestRectBottom = " << +picParams->pMoveRect->DestRectBottom << std::endl;
511 oss << "pMoveRect[" << +i << "].DestRectLeft = " << +picParams->pMoveRect->DestRectLeft << std::endl;
512 oss << "pMoveRect[" << +i << "].DestRectRight = " << +picParams->pMoveRect->DestRectRight << std::endl;
513 }
514
515 oss << "InputType = " << +picParams->InputType << std::endl;
516 oss << "TargetFrameSize = " << +picParams->TargetFrameSize << std::endl;
517 oss << "QpModulationStrength = " << +picParams->QpModulationStrength << std::endl;
518
519 for (uint8_t i = 0; i < 16; i++)
520 {
521 oss << "Reserved10[" << +i << "] = " << +picParams->Reserved10[i] << std::endl;
522 }
523
524 const char *fileName = m_debugInterface->CreateFileName(
525 "_DDIEnc",
526 CodechalDbgBufferType::bufPicParams,
527 CodechalDbgExtType::txt);
528
529 std::ofstream ofs(fileName, std::ios::out);
530 ofs << oss.str();
531 ofs.close();
532
533 if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrDriverUltDump))
534 {
535 if (!m_debugInterface->m_ddiFileName.empty())
536 {
537 std::ofstream ofs(m_debugInterface->m_ddiFileName, std::ios::app);
538 ofs << "PicNum"
539 << " = \"" << m_debugInterface->m_bufferDumpFrameNum << "\"" << std::endl;
540 ofs << "PicParamFile"
541 << " = \"" << m_debugInterface->m_fileName << "\"" << std::endl;
542 ofs.close();
543 }
544 }
545
546 return MOS_STATUS_SUCCESS;
547 }
548
DumpTileGroupParams(const CODEC_AV1_ENCODE_TILE_GROUP_PARAMS * tilegroupParams,uint32_t index)549 MOS_STATUS Av1Pipeline::DumpTileGroupParams(
550 const CODEC_AV1_ENCODE_TILE_GROUP_PARAMS *tilegroupParams, uint32_t index)
551 {
552 ENCODE_FUNC_CALL();
553 ENCODE_CHK_NULL_RETURN(m_debugInterface);
554
555 if (!m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrSlcParams))
556 {
557 return MOS_STATUS_SUCCESS;
558 }
559
560 CODECHAL_DEBUG_CHK_NULL(tilegroupParams);
561 m_debugInterface->m_sliceId = index;
562
563 std::ostringstream oss;
564 oss.setf(std::ios::showbase | std::ios::uppercase);
565
566 oss << "# DDI Parameters:" << std::endl;
567 oss << "TileGroup_id = " << +index << std::endl;
568 oss << "TileGroupStart = " << +tilegroupParams->TileGroupStart << std::endl;
569 oss << "TileGroupEnd = " << +tilegroupParams->TileGroupEnd << std::endl;
570 oss << "Reserved16b = " << +tilegroupParams->Reserved16b << std::endl;
571
572 for (uint8_t j = 0; j < 9; j++)
573 {
574 oss << "Reserved32b[" << +j << "] = " << +tilegroupParams->Reserved32b[j] << std::endl;
575 }
576
577 const char *fileName = m_debugInterface->CreateFileName(
578 "_DDIEnc",
579 CodechalDbgBufferType::bufSlcParams,
580 CodechalDbgExtType::txt);
581
582 std::ofstream ofs(fileName, std::ios::out);
583 ofs << oss.str();
584 ofs.close();
585
586 if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrDriverUltDump))
587 {
588 if (!m_debugInterface->m_ddiFileName.empty())
589 {
590 std::ofstream ofs(m_debugInterface->m_ddiFileName, std::ios::app);
591 ofs << "TileGroupParamFile"
592 << " = \"" << m_debugInterface->m_fileName << "\"" << std::endl;
593 ofs.close();
594 }
595 }
596
597 return MOS_STATUS_SUCCESS;
598 }
599 #endif
600
601 } // namespace encode
602