Skip to content

Commit

Permalink
[CP] Remove default cdf buffer huc copy
Browse files Browse the repository at this point in the history
Remove default cdf buffer huc copy, use clear default cdf buffer to avoid teardown issue.
  • Loading branch information
lixin5x authored and intel-mediadev committed Nov 23, 2023
1 parent 73ee40b commit 84ab024
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ MOS_STATUS Av1PipelineG12_Base::Initialize(void *settings)

HucPacketCreatorG12 *hucPktCreator = dynamic_cast<HucPacketCreatorG12 *>(this);
DECODE_CHK_NULL(hucPktCreator);
m_cdfCopyPkt = hucPktCreator->CreateHucCopyPkt(this, m_task, m_hwInterface);
DECODE_CHK_NULL(m_cdfCopyPkt);
MediaPacket *packet = dynamic_cast<MediaPacket *>(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)
Expand All @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class Av1PipelineG12_Base : public DecodePipeline
DeclareDecodePacketId(av1DecodePacketId);
DeclareDecodePacketId(av1PictureSubPacketId);
DeclareDecodePacketId(av1TileSubPacketId);
DeclareDecodePacketId(defaultCdfBufCopyPacketId);

protected:
//!
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ MOS_STATUS Av1Pipeline::Initialize(void *settings)

HucPacketCreatorBase *hucPktCreator = dynamic_cast<HucPacketCreatorBase *>(this);
DECODE_CHK_NULL(hucPktCreator);
m_cdfCopyPkt = hucPktCreator->CreateHucCopyPkt(this, m_task, m_hwInterface);
DECODE_CHK_NULL(m_cdfCopyPkt);
MediaPacket *packet = dynamic_cast<MediaPacket *>(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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -116,7 +97,6 @@ MOS_STATUS Av1Pipeline::ActivateDecodePackets()

if (m_isFirstTileInFrm)
{
DECODE_CHK_STATUS(ActivatePacket(DecodePacketId(this, defaultCdfBufCopyPacketId), false, 0, 0));
m_isFirstTileInFrm = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class Av1Pipeline : public DecodePipeline
DeclareDecodePacketId(av1DecodePacketId);
DeclareDecodePacketId(av1PictureSubPacketId);
DeclareDecodePacketId(av1TileSubPacketId);
DeclareDecodePacketId(defaultCdfBufCopyPacketId);

protected:
//!
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 84ab024

Please sign in to comment.