From 84ab0242544620dbb8f2815b84fbfb027098fc4a Mon Sep 17 00:00:00 2001 From: Li_Xin6 Date: Thu, 23 Nov 2023 15:18:31 +0800 Subject: [PATCH] [CP] Remove default cdf buffer huc copy Remove default cdf buffer huc copy, use clear default cdf buffer to avoid teardown issue. --- .../Xe_HPM/hw/vdbox/mhw_vdbox_avp_xe_hpm.cpp | 2 +- .../gen12/hw/vdbox/mhw_vdbox_avp_g12_X.cpp | 2 +- .../features/decode_av1_basic_feature_g12.cpp | 18 ++++------------ .../features/decode_av1_basic_feature_g12.h | 1 - .../pipeline/decode_av1_pipeline_g12_base.cpp | 21 ------------------- .../pipeline/decode_av1_pipeline_g12_base.h | 2 -- .../av1/features/decode_av1_basic_feature.cpp | 16 +++----------- .../av1/features/decode_av1_basic_feature.h | 1 - .../dec/av1/pipeline/decode_av1_pipeline.cpp | 20 ------------------ .../dec/av1/pipeline/decode_av1_pipeline.h | 2 -- .../common/hw/vdbox/mhw_vdbox_avp_impl.h | 2 +- 11 files changed, 10 insertions(+), 77 deletions(-) diff --git a/media_driver/agnostic/Xe_M/Xe_HPM/hw/vdbox/mhw_vdbox_avp_xe_hpm.cpp b/media_driver/agnostic/Xe_M/Xe_HPM/hw/vdbox/mhw_vdbox_avp_xe_hpm.cpp index 753fd45d481..68961a2062e 100644 --- a/media_driver/agnostic/Xe_M/Xe_HPM/hw/vdbox/mhw_vdbox_avp_xe_hpm.cpp +++ b/media_driver/agnostic/Xe_M/Xe_HPM/hw/vdbox/mhw_vdbox_avp_xe_hpm.cpp @@ -333,7 +333,7 @@ MOS_STATUS MhwVdboxAvpInterfaceXe_Hpm::AddAvpPipeBufAddrCmd( resourceParams.dwOffset = params->m_cdfTableInitializationBufferOffset; resourceParams.pdwCmd = (cmd.CdfTablesInitializationBufferAddress.DW0_1.Value); resourceParams.dwLocationInCmd = 27; - resourceParams.bIsWritable = true; + resourceParams.bIsWritable = false; InitMocsParams(resourceParams, &cmd.CdfTablesInitializationBufferAddressAttributes.DW0.Value, 1, 6); MHW_MI_CHK_STATUS(AddResourceToCmd( m_osInterface, diff --git a/media_driver/agnostic/gen12/hw/vdbox/mhw_vdbox_avp_g12_X.cpp b/media_driver/agnostic/gen12/hw/vdbox/mhw_vdbox_avp_g12_X.cpp index 561fe746413..c898bd61608 100644 --- a/media_driver/agnostic/gen12/hw/vdbox/mhw_vdbox_avp_g12_X.cpp +++ b/media_driver/agnostic/gen12/hw/vdbox/mhw_vdbox_avp_g12_X.cpp @@ -732,7 +732,7 @@ MOS_STATUS MhwVdboxAvpInterfaceG12::AddAvpPipeBufAddrCmd( resourceParams.dwOffset = 0; resourceParams.pdwCmd = (cmd.CdfTablesInitializationBufferAddress.DW0_1.Value); resourceParams.dwLocationInCmd = 27; - resourceParams.bIsWritable = true; + resourceParams.bIsWritable = false; MHW_MI_CHK_STATUS(AddResourceToCmd( m_osInterface, diff --git a/media_driver/media_softlet/agnostic/gen12/codec/hal/dec/av1/features/decode_av1_basic_feature_g12.cpp b/media_driver/media_softlet/agnostic/gen12/codec/hal/dec/av1/features/decode_av1_basic_feature_g12.cpp index f96742f3aab..c3150dcfb07 100644 --- a/media_driver/media_softlet/agnostic/gen12/codec/hal/dec/av1/features/decode_av1_basic_feature_g12.cpp +++ b/media_driver/media_softlet/agnostic/gen12/codec/hal/dec/av1/features/decode_av1_basic_feature_g12.cpp @@ -35,16 +35,10 @@ namespace decode { for (uint8_t i = 0; i < av1DefaultCdfTableNum; i++) { - if (!m_allocator->ResourceIsNull(&m_tmpCdfBuffers[i]->OsResource)) - { - m_allocator->Destroy(m_tmpCdfBuffers[i]); - } - if (!m_allocator->ResourceIsNull(&m_defaultCdfBuffers[i]->OsResource)) { m_allocator->Destroy(m_defaultCdfBuffers[i]); } - } if (m_usingDummyWl == true) { @@ -954,20 +948,16 @@ namespace decode { for (uint8_t index = 0; index < av1DefaultCdfTableNum; index++) { - m_tmpCdfBuffers[index] = m_allocator->AllocateBuffer( + m_defaultCdfBuffers[index] = m_allocator->AllocateBuffer( MOS_ALIGN_CEIL(m_cdfMaxNumBytes, CODECHAL_PAGE_SIZE), "TempCdfTableBuffer", resourceInternalRead, lockableVideoMem); - DECODE_CHK_NULL(m_tmpCdfBuffers[index]); + DECODE_CHK_NULL(m_defaultCdfBuffers[index]); - auto data = (uint16_t *)m_allocator->LockResourceForWrite(&m_tmpCdfBuffers[index]->OsResource); + auto data = (uint16_t *)m_allocator->LockResourceForWrite(&m_defaultCdfBuffers[index]->OsResource); DECODE_CHK_NULL(data); - + // reset all CDF tables to default values DECODE_CHK_STATUS(InitDefaultFrameContextBuffer(data, index)); - m_defaultCdfBuffers[index] = m_allocator->AllocateBuffer( - MOS_ALIGN_CEIL(m_cdfMaxNumBytes, CODECHAL_PAGE_SIZE), "m_defaultCdfBuffers", - resourceInternalRead, notLockableVideoMem); - DECODE_CHK_NULL(m_defaultCdfBuffers[index]); } m_defaultFcInitialized = true;//set only once, won't set again diff --git a/media_driver/media_softlet/agnostic/gen12/codec/hal/dec/av1/features/decode_av1_basic_feature_g12.h b/media_driver/media_softlet/agnostic/gen12/codec/hal/dec/av1/features/decode_av1_basic_feature_g12.h index 5ef7a8d940a..afee4131ab0 100644 --- a/media_driver/media_softlet/agnostic/gen12/codec/hal/dec/av1/features/decode_av1_basic_feature_g12.h +++ b/media_driver/media_softlet/agnostic/gen12/codec/hal/dec/av1/features/decode_av1_basic_feature_g12.h @@ -124,7 +124,6 @@ namespace decode CodecAv1SegmentsParams *m_segmentParams = nullptr; //!< Pointer to AV1 segments parameter CodecAv1TileParams *m_av1TileParams = nullptr; //!< Pointer to AV1 tiles parameter - PMOS_BUFFER m_tmpCdfBuffers[4] = {}; //!< 4 temporal cdf table buffers for later use. PMOS_BUFFER m_defaultCdfBuffers[4] = {}; //!< 4 default frame contexts per base_qindex PMOS_BUFFER m_defaultCdfBufferInUse = nullptr; //!< default cdf table used base on current base_qindex uint8_t m_curCoeffCdfQCtx = 0; //!< Coeff CDF Q context ID for current frame diff --git a/media_driver/media_softlet/agnostic/gen12_base/codec/hal/dec/av1/pipeline/decode_av1_pipeline_g12_base.cpp b/media_driver/media_softlet/agnostic/gen12_base/codec/hal/dec/av1/pipeline/decode_av1_pipeline_g12_base.cpp index bb54707e228..f72cd7d71ab 100644 --- a/media_driver/media_softlet/agnostic/gen12_base/codec/hal/dec/av1/pipeline/decode_av1_pipeline_g12_base.cpp +++ b/media_driver/media_softlet/agnostic/gen12_base/codec/hal/dec/av1/pipeline/decode_av1_pipeline_g12_base.cpp @@ -100,12 +100,6 @@ MOS_STATUS Av1PipelineG12_Base::Initialize(void *settings) HucPacketCreatorG12 *hucPktCreator = dynamic_cast(this); DECODE_CHK_NULL(hucPktCreator); - m_cdfCopyPkt = hucPktCreator->CreateHucCopyPkt(this, m_task, m_hwInterface); - DECODE_CHK_NULL(m_cdfCopyPkt); - MediaPacket *packet = dynamic_cast(m_cdfCopyPkt); - DECODE_CHK_NULL(packet); - DECODE_CHK_STATUS(RegisterPacket(DecodePacketId(this, defaultCdfBufCopyPacketId), packet)); - DECODE_CHK_STATUS(packet->Init()); bool forceTileBasedDecodingRead = 0; #if (_DEBUG || _RELEASE_INTERNAL) @@ -125,19 +119,6 @@ MOS_STATUS Av1PipelineG12_Base::Prepare(void *params) DECODE_CHK_NULL(basicFeature); DECODE_CHK_STATUS(DecodePipeline::Prepare(params)); - if (basicFeature->m_frameNum == 0) - { - for (uint8_t i = 0; i < basicFeature->av1DefaultCdfTableNum; i++) - { - HucCopyPktItf::HucCopyParams copyParams = {}; - copyParams.srcBuffer = &(basicFeature->m_tmpCdfBuffers[i]->OsResource); - copyParams.srcOffset = 0; - copyParams.destBuffer = &(basicFeature->m_defaultCdfBuffers[i]->OsResource); - copyParams.destOffset = 0; - copyParams.copyLength = basicFeature->m_cdfMaxNumBytes; - m_cdfCopyPkt->PushCopyParams(copyParams); - } - } return MOS_STATUS_SUCCESS; } @@ -167,9 +148,7 @@ MOS_STATUS Av1PipelineG12_Base::ActivateDecodePackets() if (m_isFirstTileInFrm) { - DECODE_CHK_STATUS(ActivatePacket(DecodePacketId(this, defaultCdfBufCopyPacketId), immediateSubmit, 0, 0)); m_isFirstTileInFrm = false; - m_activePacketList.back().frameTrackingRequested = false; } if (!m_forceTileBasedDecoding) diff --git a/media_driver/media_softlet/agnostic/gen12_base/codec/hal/dec/av1/pipeline/decode_av1_pipeline_g12_base.h b/media_driver/media_softlet/agnostic/gen12_base/codec/hal/dec/av1/pipeline/decode_av1_pipeline_g12_base.h index 002a01ea510..137a3aad175 100644 --- a/media_driver/media_softlet/agnostic/gen12_base/codec/hal/dec/av1/pipeline/decode_av1_pipeline_g12_base.h +++ b/media_driver/media_softlet/agnostic/gen12_base/codec/hal/dec/av1/pipeline/decode_av1_pipeline_g12_base.h @@ -62,7 +62,6 @@ class Av1PipelineG12_Base : public DecodePipeline DeclareDecodePacketId(av1DecodePacketId); DeclareDecodePacketId(av1PictureSubPacketId); DeclareDecodePacketId(av1TileSubPacketId); - DeclareDecodePacketId(defaultCdfBufCopyPacketId); protected: //! @@ -169,7 +168,6 @@ class Av1PipelineG12_Base : public DecodePipeline #endif protected: - HucCopyPktItf *m_cdfCopyPkt = nullptr; //!< Update default cdf buffer with huc stream out packet Av1DecodeMode m_decodeMode = baseDecodeMode; //!< Decode mode uint16_t m_passNum = 1; //!< Decode pass number bool m_isFirstTileInFrm = true; //!< First tile in the first frame diff --git a/media_softlet/agnostic/common/codec/hal/dec/av1/features/decode_av1_basic_feature.cpp b/media_softlet/agnostic/common/codec/hal/dec/av1/features/decode_av1_basic_feature.cpp index cd6bb211b5a..b474f0b7ff2 100644 --- a/media_softlet/agnostic/common/codec/hal/dec/av1/features/decode_av1_basic_feature.cpp +++ b/media_softlet/agnostic/common/codec/hal/dec/av1/features/decode_av1_basic_feature.cpp @@ -34,16 +34,10 @@ namespace decode { for (uint8_t i = 0; i < av1DefaultCdfTableNum; i++) { - if (!m_allocator->ResourceIsNull(&m_tmpCdfBuffers[i]->OsResource)) - { - m_allocator->Destroy(m_tmpCdfBuffers[i]); - } - if (!m_allocator->ResourceIsNull(&m_defaultCdfBuffers[i]->OsResource)) { m_allocator->Destroy(m_defaultCdfBuffers[i]); } - } if (m_usingDummyWl == true) { @@ -873,20 +867,16 @@ namespace decode { for (uint8_t index = 0; index < av1DefaultCdfTableNum; index++) { - m_tmpCdfBuffers[index] = m_allocator->AllocateBuffer( + m_defaultCdfBuffers[index] = m_allocator->AllocateBuffer( MOS_ALIGN_CEIL(m_cdfMaxNumBytes, CODECHAL_PAGE_SIZE), "TempCdfTableBuffer", resourceInternalRead, lockableVideoMem); - DECODE_CHK_NULL(m_tmpCdfBuffers[index]); + DECODE_CHK_NULL(m_defaultCdfBuffers[index]); - auto data = (uint16_t *)m_allocator->LockResourceForWrite(&m_tmpCdfBuffers[index]->OsResource); + auto data = (uint16_t *)m_allocator->LockResourceForWrite(&m_defaultCdfBuffers[index]->OsResource); DECODE_CHK_NULL(data); // reset all CDF tables to default values DECODE_CHK_STATUS(InitDefaultFrameContextBuffer(data, index)); - m_defaultCdfBuffers[index] = m_allocator->AllocateBuffer( - MOS_ALIGN_CEIL(m_cdfMaxNumBytes, CODECHAL_PAGE_SIZE), "m_defaultCdfBuffers", - resourceInternalRead, notLockableVideoMem); - DECODE_CHK_NULL(m_defaultCdfBuffers[index]); } m_defaultFcInitialized = true;//set only once, won't set again diff --git a/media_softlet/agnostic/common/codec/hal/dec/av1/features/decode_av1_basic_feature.h b/media_softlet/agnostic/common/codec/hal/dec/av1/features/decode_av1_basic_feature.h index 9844c591716..00b8e32ecde 100644 --- a/media_softlet/agnostic/common/codec/hal/dec/av1/features/decode_av1_basic_feature.h +++ b/media_softlet/agnostic/common/codec/hal/dec/av1/features/decode_av1_basic_feature.h @@ -122,7 +122,6 @@ namespace decode CodecAv1SegmentsParams *m_segmentParams = nullptr; //!< Pointer to AV1 segments parameter CodecAv1TileParams *m_av1TileParams = nullptr; //!< Pointer to AV1 tiles parameter - PMOS_BUFFER m_tmpCdfBuffers[4] = {}; //!< 4 temporal cdf table buffers for later use. PMOS_BUFFER m_defaultCdfBuffers[4] = {}; //!< 4 default frame contexts per base_qindex PMOS_BUFFER m_defaultCdfBufferInUse = nullptr; //!< default cdf table used base on current base_qindex uint8_t m_curCoeffCdfQCtx = 0; //!< Coeff CDF Q context ID for current frame diff --git a/media_softlet/agnostic/common/codec/hal/dec/av1/pipeline/decode_av1_pipeline.cpp b/media_softlet/agnostic/common/codec/hal/dec/av1/pipeline/decode_av1_pipeline.cpp index 7a245f2dbe2..f1e1a5cca6c 100644 --- a/media_softlet/agnostic/common/codec/hal/dec/av1/pipeline/decode_av1_pipeline.cpp +++ b/media_softlet/agnostic/common/codec/hal/dec/av1/pipeline/decode_av1_pipeline.cpp @@ -47,12 +47,6 @@ MOS_STATUS Av1Pipeline::Initialize(void *settings) HucPacketCreatorBase *hucPktCreator = dynamic_cast(this); DECODE_CHK_NULL(hucPktCreator); - m_cdfCopyPkt = hucPktCreator->CreateHucCopyPkt(this, m_task, m_hwInterface); - DECODE_CHK_NULL(m_cdfCopyPkt); - MediaPacket *packet = dynamic_cast(m_cdfCopyPkt); - DECODE_CHK_NULL(packet); - DECODE_CHK_STATUS(RegisterPacket(DecodePacketId(this, defaultCdfBufCopyPacketId), packet)); - DECODE_CHK_STATUS(packet->Init()); auto *codecSettings = (CodechalSetting*)settings; DECODE_CHK_NULL(codecSettings); @@ -75,19 +69,6 @@ MOS_STATUS Av1Pipeline::Prepare(void *params) DECODE_CHK_NULL(basicFeature); DECODE_CHK_STATUS(DecodePipeline::Prepare(params)); - if (basicFeature->m_frameNum == 0) - { - for (uint8_t i = 0; i < basicFeature->av1DefaultCdfTableNum; i++) - { - HucCopyPktItf::HucCopyParams copyParams = {}; - copyParams.srcBuffer = &(basicFeature->m_tmpCdfBuffers[i]->OsResource); - copyParams.srcOffset = 0; - copyParams.destBuffer = &(basicFeature->m_defaultCdfBuffers[i]->OsResource); - copyParams.destOffset = 0; - copyParams.copyLength = basicFeature->m_cdfMaxNumBytes; - m_cdfCopyPkt->PushCopyParams(copyParams); - } - } return MOS_STATUS_SUCCESS; } @@ -116,7 +97,6 @@ MOS_STATUS Av1Pipeline::ActivateDecodePackets() if (m_isFirstTileInFrm) { - DECODE_CHK_STATUS(ActivatePacket(DecodePacketId(this, defaultCdfBufCopyPacketId), false, 0, 0)); m_isFirstTileInFrm = false; } diff --git a/media_softlet/agnostic/common/codec/hal/dec/av1/pipeline/decode_av1_pipeline.h b/media_softlet/agnostic/common/codec/hal/dec/av1/pipeline/decode_av1_pipeline.h index 31ea4cd8c92..210fdbe8872 100644 --- a/media_softlet/agnostic/common/codec/hal/dec/av1/pipeline/decode_av1_pipeline.h +++ b/media_softlet/agnostic/common/codec/hal/dec/av1/pipeline/decode_av1_pipeline.h @@ -62,7 +62,6 @@ class Av1Pipeline : public DecodePipeline DeclareDecodePacketId(av1DecodePacketId); DeclareDecodePacketId(av1PictureSubPacketId); DeclareDecodePacketId(av1TileSubPacketId); - DeclareDecodePacketId(defaultCdfBufCopyPacketId); protected: //! @@ -150,7 +149,6 @@ class Av1Pipeline : public DecodePipeline #endif protected: - HucCopyPktItf *m_cdfCopyPkt = nullptr; //!< Update default cdf buffer with huc stream out packet Av1DecodeMode m_decodeMode = baseDecodeMode; //!< Decode mode uint16_t m_passNum = 1; //!< Decode pass number bool m_isFirstTileInFrm = true; //!< First tile in the first frame diff --git a/media_softlet/agnostic/common/hw/vdbox/mhw_vdbox_avp_impl.h b/media_softlet/agnostic/common/hw/vdbox/mhw_vdbox_avp_impl.h index 59070bd8a9c..6051f157fb0 100644 --- a/media_softlet/agnostic/common/hw/vdbox/mhw_vdbox_avp_impl.h +++ b/media_softlet/agnostic/common/hw/vdbox/mhw_vdbox_avp_impl.h @@ -1021,7 +1021,7 @@ class Impl : public Itf, public mhw::Impl resourceParams.dwOffset = params.cdfTableInitBufferOffset; resourceParams.pdwCmd = (cmd.CdfTablesInitializationBufferAddress.DW0_1.Value); resourceParams.dwLocationInCmd = _MHW_CMD_DW_LOCATION(CdfTablesInitializationBufferAddress); - resourceParams.bIsWritable = true; + resourceParams.bIsWritable = false; InitMocsParams(resourceParams, &cmd.CdfTablesInitializationBufferAddressAttributes.DW0.Value, 1, 6);