Skip to content

Commit fb2b273

Browse files
haichund1intel-mediadev
authored andcommitted
[Decode] [PDVT-SH] Add AVC decode HW start code support reg control
Add AVC decode HW start code support reg key to control feature on/off
1 parent dcf556f commit fb2b273

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

media_common/agnostic/common/os/mos_utilities_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ typedef enum _MOS_USER_FEATURE_VALUE_ID
475475
__MEDIA_USER_FEATURE_VALUE_FINE_GRANULAR_CRC_STREAMOUT_ENABLE_ID,
476476
__MEDIA_USER_FEATURE_VALUE_FINE_GRANULAR_CRC_STREAMIN_ENABLE_ID,
477477
__MEDIA_USER_FEATURE_VALUE_FINE_GRANULAR_CRC_OUTPUT_RATE_ID,
478+
__MEDIA_USER_FEATURE_VALUE_DECODE_AVC_HW_STARTCODE_SUPPORT_DISABLE_ID,
478479
#endif
479480
__MOS_USER_FEATURE_KEY_MAX_ID,
480481
} MOS_USER_FEATURE_VALUE_ID;

media_driver/agnostic/common/os/mos_utilities.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,5 +3251,14 @@ MOS_USER_FEATURE_VALUE MosUtilities::m_mosUserFeatureDescFields[__MOS_USER_FEATU
32513251
MOS_USER_FEATURE_VALUE_TYPE_UINT32,
32523252
"0",
32533253
"Enable will streamin CRC, used in first pass(passing run)"),
3254+
MOS_DECLARE_UF_KEY_DBGONLY(__MEDIA_USER_FEATURE_VALUE_DECODE_AVC_HW_STARTCODE_SUPPORT_DISABLE_ID,
3255+
"DecodeAvcHwStartCodeSupportDisable",
3256+
__MEDIA_USER_FEATURE_SUBKEY_INTERNAL,
3257+
__MEDIA_USER_FEATURE_SUBKEY_REPORT,
3258+
"Decode",
3259+
MOS_USER_FEATURE_TYPE_USER,
3260+
MOS_USER_FEATURE_VALUE_TYPE_UINT32,
3261+
"0",
3262+
"Disable Decode AVC HW start code support. (0: Enable decode AVC HW start code support. 1: Disable decode AVC HW start code support)"),
32543263
#endif
32553264
};

media_softlet/agnostic/common/codec/hal/dec/avc/features/decode_avc_basic_feature.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,34 @@ namespace decode {
5454
DECODE_CHK_STATUS(m_refFrames.Init(this, *m_allocator));
5555
DECODE_CHK_STATUS(m_mvBuffers.Init(m_hwInterface, *m_allocator, *this, CODEC_AVC_NUM_INIT_DMV_BUFFERS));
5656

57+
// Initialize m_hwStartCodeSupportEnabled based on hardware capability and user feature setting
58+
if (m_osInterface != nullptr)
59+
{
60+
MEDIA_FEATURE_TABLE *skuTable = m_osInterface->pfnGetSkuTable(m_osInterface);
61+
if (skuTable != nullptr && MEDIA_IS_SKU(skuTable, FtrAVCd4ByteNALStartCodeSupport))
62+
{
63+
// Hardware supports the feature, enable by default
64+
m_hwStartCodeSupportEnabled = true;
65+
66+
#if (_DEBUG || _RELEASE_INTERNAL)
67+
// Check user feature setting to potentially disable the feature
68+
MOS_USER_FEATURE_VALUE_DATA userFeatureData;
69+
MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData));
70+
MOS_UserFeature_ReadValue_ID(
71+
nullptr,
72+
__MEDIA_USER_FEATURE_VALUE_DECODE_AVC_HW_STARTCODE_SUPPORT_DISABLE_ID,
73+
&userFeatureData,
74+
(MOS_CONTEXT_HANDLE) nullptr);
75+
76+
// If feature key is set to 1 (disable), override to false
77+
if (userFeatureData.bData)
78+
{
79+
m_hwStartCodeSupportEnabled = false;
80+
}
81+
#endif
82+
}
83+
}
84+
5785
return MOS_STATUS_SUCCESS;
5886
}
5987

media_softlet/agnostic/common/codec/hal/dec/avc/features/decode_avc_basic_feature.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ class AvcBasicFeature : public DecodeBasicFeature
168168
std::vector<uint32_t> m_refFrameIndexList; //!< Reference frame index list
169169
RefrenceAssociatedBuffer<MOS_BUFFER, AvcMvBufferOpInf, AvcBasicFeature> m_mvBuffers; //!< Reference associated buffers
170170

171+
bool m_hwStartCodeSupportEnabled = false; //!< Controls AVC hardware start code support based on both hardware capability and user feature setting
172+
171173
protected:
172174
virtual MOS_STATUS SetRequiredBitstreamSize(uint32_t requiredSize) override;
173175
MOS_STATUS SetPictureStructs();

media_softlet/agnostic/common/codec/hal/dec/avc/packet/decode_avc_slice_packet.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ MOS_STATUS AvcDecodeSlcPkt::AddCmd_AVC_BSD_OBJECT(MOS_COMMAND_BUFFER &cmdBuffer,
205205
DECODE_FUNC_CALL();
206206
auto &parSlice = m_mfxItf->MHW_GETPAR_F(MFX_AVC_SLICE_STATE)();
207207
auto sliceParams = m_avcSliceParams + slcIdx;
208-
MEDIA_FEATURE_TABLE *skuTable = m_osInterface->pfnGetSkuTable(m_osInterface);
209208
m_LastsliceFlag = parSlice.isLastSlice;
210209
if (parSlice.shortFormatInUse)
211210
{
@@ -216,7 +215,7 @@ MOS_STATUS AvcDecodeSlcPkt::AddCmd_AVC_BSD_OBJECT(MOS_COMMAND_BUFFER &cmdBuffer,
216215
}
217216
else
218217
{
219-
if (MEDIA_IS_SKU(skuTable, FtrAVCd4ByteNALStartCodeSupport))
218+
if (m_avcBasicFeature && m_avcBasicFeature->m_hwStartCodeSupportEnabled)
220219
{
221220
m_IndirectBsdDataLength = parSlice.Length;
222221
m_IndirectBsdDataStartAddress = sliceParams->slice_data_offset;
@@ -226,8 +225,8 @@ MOS_STATUS AvcDecodeSlcPkt::AddCmd_AVC_BSD_OBJECT(MOS_COMMAND_BUFFER &cmdBuffer,
226225
m_IndirectBsdDataLength = parSlice.Length + 1 - m_osInterface->dwNumNalUnitBytesIncluded;
227226
m_IndirectBsdDataStartAddress = sliceParams->slice_data_offset - 1 + m_osInterface->dwNumNalUnitBytesIncluded;
228227
}
229-
DECODE_VERBOSEMESSAGE("AVCd4ByteNALStartCodeSupport %d, slice_data_offset %d, parSlice Length %d, IndirectBsdDataStartAddress %d, IndirectBsdDataLength %d",
230-
MEDIA_IS_SKU(skuTable, FtrAVCd4ByteNALStartCodeSupport),
228+
DECODE_VERBOSEMESSAGE("HwStartCodeSupportEnabled %d, slice_data_offset %d, parSlice Length %d, IndirectBsdDataStartAddress %d, IndirectBsdDataLength %d",
229+
(m_avcBasicFeature ? m_avcBasicFeature->m_hwStartCodeSupportEnabled : false),
231230
sliceParams->slice_data_offset,
232231
parSlice.Length,
233232
m_IndirectBsdDataStartAddress,
@@ -424,7 +423,6 @@ MOS_STATUS AvcDecodeSlcPkt::AddCmd_AVC_SLICE_Addr(MOS_COMMAND_BUFFER &cmdBuffer,
424423
SET_AVC_SLICE_STATE(cmdBuffer, slcIdx);
425424
auto &parSlice = m_mfxItf->MHW_GETPAR_F(MFX_AVC_SLICE_STATE)();
426425
auto &parSliceAddr = m_mfxItf->MHW_GETPAR_F(MFD_AVC_SLICEADDR)();
427-
MEDIA_FEATURE_TABLE *skuTable = m_osInterface->pfnGetSkuTable(m_osInterface);
428426
parSliceAddr.decodeInUse = true;
429427
if (parSlice.fullFrameData)
430428
{
@@ -433,7 +431,7 @@ MOS_STATUS AvcDecodeSlcPkt::AddCmd_AVC_SLICE_Addr(MOS_COMMAND_BUFFER &cmdBuffer,
433431
}
434432
else
435433
{
436-
if (MEDIA_IS_SKU(skuTable, FtrAVCd4ByteNALStartCodeSupport))
434+
if (m_avcBasicFeature && m_avcBasicFeature->m_hwStartCodeSupportEnabled)
437435
{
438436
parSliceAddr.IndirectBsdDataLength = parSlice.nextLength;
439437
parSliceAddr.IndirectBsdDataStartAddress = parSlice.nextOffset;
@@ -443,8 +441,8 @@ MOS_STATUS AvcDecodeSlcPkt::AddCmd_AVC_SLICE_Addr(MOS_COMMAND_BUFFER &cmdBuffer,
443441
parSliceAddr.IndirectBsdDataLength = parSlice.nextLength + 1 - m_osInterface->dwNumNalUnitBytesIncluded;
444442
parSliceAddr.IndirectBsdDataStartAddress = parSlice.nextOffset - 1 + m_osInterface->dwNumNalUnitBytesIncluded;
445443
}
446-
DECODE_VERBOSEMESSAGE("AVCd4ByteNALStartCodeSupport %d, parSlice nextOffset %d, parSlice nextLength %d, IndirectBsdDataStartAddress %d, IndirectBsdDataLength %d",
447-
MEDIA_IS_SKU(skuTable, FtrAVCd4ByteNALStartCodeSupport),
444+
DECODE_VERBOSEMESSAGE("HwStartCodeSupportEnabled %d, parSlice nextOffset %d, parSlice nextLength %d, IndirectBsdDataStartAddress %d, IndirectBsdDataLength %d",
445+
(m_avcBasicFeature ? m_avcBasicFeature->m_hwStartCodeSupportEnabled : false),
448446
parSlice.nextOffset,
449447
parSlice.nextLength,
450448
parSliceAddr.IndirectBsdDataStartAddress,

0 commit comments

Comments
 (0)