| 1 |
/* |
| 2 |
* Copyright (c) 2022, 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 codec_def_encode_hevc_trace.h |
| 24 |
//! |
| 25 |
|
| 26 |
#pragma once |
| 27 |
#include <vector> |
| 28 |
#include "codec_def_encode_hevc.h" |
| 29 |
#include "mos_utilities.h" |
| 30 |
|
| 31 |
#define NUM_ELEM_ARRAY(member) (sizeof(obj.member) / sizeof(obj.member[0])) |
| 32 |
#define PUSH(member) data.push_back(obj.member) |
| 33 |
#define PUSH64(member) \ |
| 34 |
{ \ |
| 35 |
auto p = reinterpret_cast<const uint32_t *>(&obj.member); \ |
| 36 |
data.push_back(p[0]); \ |
| 37 |
data.push_back(p[1]); \ |
| 38 |
} |
| 39 |
#define PUSH_ARRAY(member) \ |
| 40 |
for (size_t i0 = 0; i0 < NUM_ELEM_ARRAY(member); i0++) \ |
| 41 |
{ \ |
| 42 |
PUSH(member[i0]); \ |
| 43 |
} |
| 44 |
#define PUSH_ARRAY2(member) \ |
| 45 |
for (size_t i1 = 0; i1 < NUM_ELEM_ARRAY(member); i1++) \ |
| 46 |
{ \ |
| 47 |
PUSH_ARRAY(member[i1]); \ |
| 48 |
} |
| 49 |
#define PUSH_ARRAY3(member) \ |
| 50 |
for (size_t i2 = 0; i2 < NUM_ELEM_ARRAY(member); i2++) \ |
| 51 |
{ \ |
| 52 |
PUSH_ARRAY2(member[i2]); \ |
| 53 |
} |
| 54 |
#define PUSH_SEQ(member, num) \ |
| 55 |
for (size_t i = 0; i < num; i++) \ |
| 56 |
{ \ |
| 57 |
PUSH(member[i]); \ |
| 58 |
} |
| 59 |
|
| 60 |
class CodecDefEncodeHevcTrace |
| 61 |
{ |
| 62 |
public: |
| 63 |
static void TraceDDI(const CODEC_HEVC_ENCODE_SEQUENCE_PARAMS &obj) |
| 64 |
{ |
| 65 |
if (!TraceDDIEn()) |
| 66 |
{ |
| 67 |
return; |
| 68 |
} |
| 69 |
|
| 70 |
std::vector<uint32_t> data; |
| 71 |
data.reserve(sizeof(obj)); |
| 72 |
|
| 73 |
PUSH(wFrameWidthInMinCbMinus1); |
| 74 |
PUSH(wFrameHeightInMinCbMinus1); |
| 75 |
PUSH(general_profile_idc); |
| 76 |
PUSH(Level); |
| 77 |
PUSH(general_tier_flag); |
| 78 |
PUSH(GopPicSize); |
| 79 |
PUSH(GopRefDist); |
| 80 |
PUSH(GopOptFlag); |
| 81 |
PUSH(TargetUsage); |
| 82 |
PUSH(RateControlMethod); |
| 83 |
PUSH(TargetBitRate); |
| 84 |
PUSH(MaxBitRate); |
| 85 |
PUSH(MinBitRate); |
| 86 |
PUSH(FrameRate.Numerator); |
| 87 |
PUSH(FrameRate.Denominator); |
| 88 |
PUSH(InitVBVBufferFullnessInBit); |
| 89 |
PUSH(VBVBufferSizeInBit); |
| 90 |
PUSH(bResetBRC); |
| 91 |
PUSH(GlobalSearch); |
| 92 |
PUSH(LocalSearch); |
| 93 |
PUSH(EarlySkip); |
| 94 |
PUSH(MBBRC); |
| 95 |
PUSH(ParallelBRC); |
| 96 |
PUSH(SliceSizeControl); |
| 97 |
PUSH(SourceFormat); |
| 98 |
PUSH(SourceBitDepth); |
| 99 |
PUSH(QpAdjustment); |
| 100 |
PUSH(ROIValueInDeltaQP); |
| 101 |
PUSH(BlockQPforNonRectROI); |
| 102 |
PUSH(EnableTileBasedEncode); |
| 103 |
PUSH(bAutoMaxPBFrameSizeForSceneChange); |
| 104 |
PUSH(EnableStreamingBufferLLC); |
| 105 |
PUSH(EnableStreamingBufferDDR); |
| 106 |
PUSH(LowDelayMode); |
| 107 |
PUSH(DisableHRDConformance); |
| 108 |
PUSH(HierarchicalFlag); |
| 109 |
PUSH(EnableFastPass); |
| 110 |
PUSH(bLookAheadPhase); |
| 111 |
PUSH(UserMaxIFrameSize); |
| 112 |
PUSH(UserMaxPBFrameSize); |
| 113 |
PUSH(ICQQualityFactor); |
| 114 |
PUSH(StreamBufferSessionID); |
| 115 |
PUSH(maxAdaptiveMiniGopSize); |
| 116 |
PUSH(GopFlags.fields.ClosedGop); |
| 117 |
PUSH(GopFlags.fields.StrictGop); |
| 118 |
PUSH(GopFlags.fields.AdaptiveGop); |
| 119 |
PUSH_ARRAY(NumOfBInGop); |
| 120 |
PUSH(scaling_list_enable_flag); |
| 121 |
PUSH(sps_temporal_mvp_enable_flag); |
| 122 |
PUSH(strong_intra_smoothing_enable_flag); |
| 123 |
PUSH(amp_enabled_flag); |
| 124 |
PUSH(SAO_enabled_flag); |
| 125 |
PUSH(pcm_enabled_flag); |
| 126 |
PUSH(pcm_loop_filter_disable_flag); |
| 127 |
PUSH(chroma_format_idc); |
| 128 |
PUSH(separate_colour_plane_flag); |
| 129 |
PUSH(palette_mode_enabled_flag); |
| 130 |
PUSH(RGBEncodingEnable); |
| 131 |
PUSH(PrimaryChannelForRGBEncoding); |
| 132 |
PUSH(SecondaryChannelForRGBEncoding); |
| 133 |
PUSH(log2_max_coding_block_size_minus3); |
| 134 |
PUSH(log2_min_coding_block_size_minus3); |
| 135 |
PUSH(log2_max_transform_block_size_minus2); |
| 136 |
PUSH(log2_min_transform_block_size_minus2); |
| 137 |
PUSH(max_transform_hierarchy_depth_intra); |
| 138 |
PUSH(max_transform_hierarchy_depth_inter); |
| 139 |
PUSH(log2_min_PCM_cb_size_minus3); |
| 140 |
PUSH(log2_max_PCM_cb_size_minus3); |
| 141 |
PUSH(bit_depth_luma_minus8); |
| 142 |
PUSH(bit_depth_chroma_minus8); |
| 143 |
PUSH(pcm_sample_bit_depth_luma_minus1); |
| 144 |
PUSH(pcm_sample_bit_depth_chroma_minus1); |
| 145 |
PUSH(InputColorSpace); // enum ENCODE_INPUT_COLORSPACE |
| 146 |
PUSH(ScenarioInfo); // enum ENCODE_SCENARIO |
| 147 |
PUSH(contentInfo); // enum ENCODE_CONTENT |
| 148 |
PUSH(FrameSizeTolerance); // enum ENCODE_FRAMESIZE_TOLERANCE |
| 149 |
PUSH(SlidingWindowSize); |
| 150 |
PUSH(MaxBitRatePerSlidingWindow); |
| 151 |
PUSH(MinBitRatePerSlidingWindow); |
| 152 |
PUSH(LookaheadDepth); |
| 153 |
PUSH(MinAdaptiveGopPicSize); |
| 154 |
PUSH(MaxAdaptiveGopPicSize); |
| 155 |
PUSH(FullPassCodecType); |
| 156 |
PUSH(FastPassRatio); |
| 157 |
PUSH(FastPassDsType); |
| 158 |
|
| 159 |
MOS_TraceEventExt( |
| 160 |
EVENT_ENCODE_DDI_SEQ_PARAM_HEVC, |
| 161 |
EVENT_TYPE_INFO, |
| 162 |
data.data(), |
| 163 |
data.size() * sizeof(decltype(data)::value_type)); |
| 164 |
} |
| 165 |
|
| 166 |
static void TraceDDI(const CODEC_HEVC_ENCODE_PICTURE_PARAMS &obj) |
| 167 |
{ |
| 168 |
if (!TraceDDIEn()) |
| 169 |
{ |
| 170 |
return; |
| 171 |
} |
| 172 |
|
| 173 |
std::vector<uint32_t> data; |
| 174 |
data.reserve(sizeof(obj)); |
| 175 |
|
| 176 |
PUSH(CurrOriginalPic.PicEntry); |
| 177 |
PUSH(CurrReconstructedPic.PicEntry); |
| 178 |
PUSH(CollocatedRefPicIndex); |
| 179 |
for (size_t i = 0; i < NUM_ELEM_ARRAY(RefFrameList); i++) |
| 180 |
{ |
| 181 |
PUSH(RefFrameList[i].PicEntry); |
| 182 |
} |
| 183 |
PUSH(CurrPicOrderCnt); // int32_t |
| 184 |
PUSH_ARRAY(RefFramePOCList); // int32_t |
| 185 |
PUSH(CodingType); |
| 186 |
PUSH(HierarchLevelPlus1); |
| 187 |
PUSH(NumSlices); |
| 188 |
PUSH(tiles_enabled_flag); |
| 189 |
PUSH(entropy_coding_sync_enabled_flag); |
| 190 |
PUSH(sign_data_hiding_flag); |
| 191 |
PUSH(constrained_intra_pred_flag); |
| 192 |
PUSH(transform_skip_enabled_flag); |
| 193 |
PUSH(transquant_bypass_enabled_flag); |
| 194 |
PUSH(cu_qp_delta_enabled_flag); |
| 195 |
PUSH(weighted_pred_flag); |
| 196 |
PUSH(weighted_bipred_flag); |
| 197 |
PUSH(loop_filter_across_slices_flag); |
| 198 |
PUSH(loop_filter_across_tiles_flag); |
| 199 |
PUSH(scaling_list_data_present_flag); |
| 200 |
PUSH(dependent_slice_segments_enabled_flag); |
| 201 |
PUSH(bLastPicInSeq); |
| 202 |
PUSH(bLastPicInStream); |
| 203 |
PUSH(bUseRawPicForRef); |
| 204 |
PUSH(bEmulationByteInsertion); |
| 205 |
PUSH(BRCPrecision); |
| 206 |
PUSH(bEnableSliceLevelReport); |
| 207 |
PUSH(bEnableRollingIntraRefresh); |
| 208 |
PUSH(no_output_of_prior_pics_flag); |
| 209 |
PUSH(bEnableGPUWeightedPrediction); |
| 210 |
PUSH(bDisplayFormatSwizzle); |
| 211 |
PUSH(deblocking_filter_override_enabled_flag); |
| 212 |
PUSH(pps_deblocking_filter_disabled_flag); |
| 213 |
PUSH(bEnableCTULevelReport); |
| 214 |
PUSH(bEnablePartialFrameUpdate); |
| 215 |
PUSH(QpY); // int8_t |
| 216 |
PUSH(diff_cu_qp_delta_depth); |
| 217 |
PUSH(pps_cb_qp_offset); // int8_t |
| 218 |
PUSH(pps_cr_qp_offset); // int8_t |
| 219 |
PUSH(num_tile_columns_minus1); |
| 220 |
PUSH(num_tile_rows_minus1); |
| 221 |
PUSH_ARRAY(tile_column_width); |
| 222 |
PUSH_ARRAY(tile_row_height); |
| 223 |
PUSH(log2_parallel_merge_level_minus2); |
| 224 |
PUSH(num_ref_idx_l0_default_active_minus1); |
| 225 |
PUSH(num_ref_idx_l1_default_active_minus1); |
| 226 |
PUSH(LcuMaxBitsizeAllowed); |
| 227 |
PUSH(IntraInsertionLocation); |
| 228 |
PUSH(IntraInsertionSize); |
| 229 |
PUSH(QpDeltaForInsertedIntra); // int8_t |
| 230 |
PUSH(StatusReportFeedbackNumber); |
| 231 |
PUSH(slice_pic_parameter_set_id); |
| 232 |
PUSH(nal_unit_type); |
| 233 |
PUSH(MaxSliceSizeInBytes); |
| 234 |
PUSH(NumROI); |
| 235 |
for (size_t i = 0; i < NUM_ELEM_ARRAY(ROI); i++) |
| 236 |
{ |
| 237 |
PUSH(ROI[i].PriorityLevelOrDQp); // int8_t |
| 238 |
PUSH(ROI[i].Top); |
| 239 |
PUSH(ROI[i].Bottom); |
| 240 |
PUSH(ROI[i].Left); |
| 241 |
PUSH(ROI[i].Right); |
| 242 |
} |
| 243 |
PUSH(MaxDeltaQp); // int8_t |
| 244 |
PUSH(MinDeltaQp); // int8_t |
| 245 |
PUSH(CustomRoundingOffsetsParams.fields.EnableCustomRoudingIntra); |
| 246 |
PUSH(CustomRoundingOffsetsParams.fields.RoundingOffsetIntra); |
| 247 |
PUSH(CustomRoundingOffsetsParams.fields.EnableCustomRoudingInter); |
| 248 |
PUSH(CustomRoundingOffsetsParams.fields.RoundingOffsetInter); |
| 249 |
PUSH(SkipFrameFlag); |
| 250 |
PUSH(NumSkipFrames); |
| 251 |
PUSH(SizeSkipFrames); |
| 252 |
PUSH(BRCMaxQp); |
| 253 |
PUSH(BRCMinQp); |
| 254 |
PUSH(bEnableHMEOffset); |
| 255 |
PUSH_ARRAY2(HMEOffset); // int16_t |
| 256 |
PUSH(NumDirtyRects); |
| 257 |
PUSH64(pDirtyRect); |
| 258 |
if (obj.pDirtyRect) |
| 259 |
{ |
| 260 |
for (size_t i = 0; i < obj.NumDirtyRects; i++) |
| 261 |
{ |
| 262 |
PUSH(pDirtyRect[i].Top); |
| 263 |
PUSH(pDirtyRect[i].Bottom); |
| 264 |
PUSH(pDirtyRect[i].Left); |
| 265 |
PUSH(pDirtyRect[i].Right); |
| 266 |
} |
| 267 |
} |
| 268 |
PUSH(NumMoveRects); |
| 269 |
PUSH(LcuMaxBitsizeAllowedHigh16b); |
| 270 |
PUSH(DownScaleRatio.fields.X16Minus1_X); |
| 271 |
PUSH(DownScaleRatio.fields.X16Minus1_Y); |
| 272 |
PUSH(QpModulationStrength); |
| 273 |
PUSH(TargetFrameSize); |
| 274 |
PUSH(StatusReportEnable.fields.FrameStats); |
| 275 |
PUSH(StatusReportEnable.fields.BlockStats); |
| 276 |
PUSH(bEnableSaliencyEncode); |
| 277 |
|
| 278 |
MOS_TraceEventExt( |
| 279 |
EVENT_ENCODE_DDI_PIC_PARAM_HEVC, |
| 280 |
EVENT_TYPE_INFO, |
| 281 |
data.data(), |
| 282 |
data.size() * sizeof(decltype(data)::value_type)); |
| 283 |
} |
| 284 |
|
| 285 |
static void TraceDDI(const CODEC_HEVC_ENCODE_SLICE_PARAMS &obj) |
| 286 |
{ |
| 287 |
if (!TraceDDIEn()) |
| 288 |
{ |
| 289 |
return; |
| 290 |
} |
| 291 |
|
| 292 |
std::vector<uint32_t> data; |
| 293 |
data.reserve(sizeof(obj)); |
| 294 |
|
| 295 |
PUSH(slice_segment_address); |
| 296 |
PUSH(NumLCUsInSlice); |
| 297 |
for (size_t i = 0; i < NUM_ELEM_ARRAY(RefPicList); i++) |
| 298 |
{ |
| 299 |
for (size_t j = 0; j < NUM_ELEM_ARRAY(RefPicList[0]); j++) |
| 300 |
{ |
| 301 |
PUSH(RefPicList[i][j].PicEntry); |
| 302 |
} |
| 303 |
} |
| 304 |
PUSH(num_ref_idx_l0_active_minus1); |
| 305 |
PUSH(num_ref_idx_l1_active_minus1); |
| 306 |
PUSH(bLastSliceOfPic); |
| 307 |
PUSH(dependent_slice_segment_flag); |
| 308 |
PUSH(slice_temporal_mvp_enable_flag); |
| 309 |
PUSH(slice_type); |
| 310 |
PUSH(slice_sao_luma_flag); |
| 311 |
PUSH(slice_sao_chroma_flag); |
| 312 |
PUSH(mvd_l1_zero_flag); |
| 313 |
PUSH(cabac_init_flag); |
| 314 |
PUSH(slice_deblocking_filter_disable_flag); |
| 315 |
PUSH(collocated_from_l0_flag); |
| 316 |
PUSH(slice_qp_delta); // int8_t |
| 317 |
PUSH(slice_cb_qp_offset); // int8_t |
| 318 |
PUSH(slice_cr_qp_offset); // int8_t |
| 319 |
PUSH(beta_offset_div2); // int8_t |
| 320 |
PUSH(tc_offset_div2); // int8_t |
| 321 |
PUSH(luma_log2_weight_denom); |
| 322 |
PUSH(delta_chroma_log2_weight_denom); // int8_t |
| 323 |
PUSH_ARRAY2(luma_offset); // int8_t |
| 324 |
PUSH_ARRAY2(delta_luma_weight); // int8_t |
| 325 |
PUSH_ARRAY3(chroma_offset); // int8_t |
| 326 |
PUSH_ARRAY3(delta_chroma_weight); // int8_t |
| 327 |
PUSH(MaxNumMergeCand); |
| 328 |
PUSH(slice_id); |
| 329 |
PUSH(BitLengthSliceHeaderStartingPortion); |
| 330 |
PUSH(SliceHeaderByteOffset); |
| 331 |
PUSH(SliceQpDeltaBitOffset); |
| 332 |
PUSH(PredWeightTableBitOffset); |
| 333 |
PUSH(PredWeightTableBitLength); |
| 334 |
PUSH(SliceSAOFlagBitOffset); |
| 335 |
|
| 336 |
MOS_TraceEventExt( |
| 337 |
EVENT_ENCODE_DDI_SLC_PARAM_HEVC, |
| 338 |
EVENT_TYPE_INFO, |
| 339 |
data.data(), |
| 340 |
data.size() * sizeof(decltype(data)::value_type)); |
| 341 |
} |
| 342 |
|
| 343 |
private: |
| 344 |
static bool TraceDDIEn() |
| 345 |
{ |
| 346 |
return MosUtilities::TraceKeyEnabled(TR_KEY_ENCODE_EVENT_DDI) && |
| 347 |
MosUtilities::TracelevelEnabled(MT_EVENT_LEVEL::ALWAYS); |
| 348 |
} |
| 349 |
}; |
| 350 |
|
| 351 |
#undef NUM_ELEM_ARRAY |
| 352 |
#undef PUSH |
| 353 |
#undef PUSH64 |
| 354 |
#undef PUSH_ARRAY |
| 355 |
#undef PUSH_ARRAY2 |
| 356 |
#undef PUSH_ARRAY3 |
| 357 |
#undef PUSH_SEQ |