Skip to content

Commit

Permalink
[Decode] fix MPEG IT mode issue
Browse files Browse the repository at this point in the history
Fix MPEG IT mode playback issue for MTL+ platform
1. Fix incorrect decode mode
2. Fix incorrect MB number
3. Fix incorrect secondLvelBBSize
4. fix incorrect 2nd lvl indirect data
5. enable secondLvelBB dump
6. fix empty residual difference buffer
7. fix incorrect IT object struct
8. fix incorrect IT object CMD data
  • Loading branch information
shawnli2 authored and intel-mediadev committed Jul 2, 2023
1 parent 09a84a9 commit b3255d5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,6 @@ Cmd::MFD_IT_OBJECT_CMD::MFD_IT_OBJECT_CMD()

DW6.Value = 0x00000000;
//DW6.IndirectItDblkControlDataStartAddressOffset = INDIRECT_IT_DBLK_CONTROL_DATA_START_ADDRESS_OFFSET_UNNAMED0;

memset(&Mpeg2InlineData, 0, sizeof(Mpeg2InlineData));

memset(&AvcInlineData, 0, sizeof(AvcInlineData));

memset(&Vc1InlineData, 0, sizeof(Vc1InlineData));

}

Cmd::MFC_MPEG2_SLICEGROUP_STATE_CMD::MFC_MPEG2_SLICEGROUP_STATE_CMD()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4793,9 +4793,6 @@ class Cmd
};
uint32_t Value;
} DW6;
uint32_t Mpeg2InlineData[6]; //!< MPEG2 Inline Data
uint32_t AvcInlineData[7]; //!< AVC Inline Data
uint32_t Vc1InlineData[11]; //!< VC1 Inline Data

//! \name Local enumerations

Expand Down Expand Up @@ -4877,8 +4874,8 @@ class Cmd
//! \brief Explicit member initialization function
MFD_IT_OBJECT_CMD();

static const size_t dwSize = 18;
static const size_t byteSize = 72;
static const size_t dwSize = 7;
static const size_t byteSize = 28;
};

//!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ MOS_STATUS Mpeg2DecodePktXe_Lpm_Plus_Base::PackMbLevelCmds(MOS_COMMAND_BUFFER &c
DECODE_CHK_STATUS(m_miItf->AddMiBatchBufferEnd(nullptr, batchBuf));
DECODE_CHK_STATUS(Mhw_UnlockBb(m_osInterface, batchBuf, true));

#if USE_CODECHAL_DEBUG_TOOL
DECODE_CHK_STATUS(m_mpeg2Pipeline->GetDebugInterface()->Dump2ndLvlBatch(
batchBuf,
CODECHAL_NUM_MEDIA_STATES,
"_DEC"));
#endif

DECODE_CHK_STATUS(EnsureAllCommandsExecuted(cmdBuffer));
DECODE_CHK_STATUS(EndStatusReport(statusReportMfx, &cmdBuffer));
DECODE_CHK_STATUS(UpdateStatusReportNext(statusReportGlobalCount, &cmdBuffer));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ MOS_STATUS Mpeg2PipelineXe_Lpm_Plus_Base::CreateSubPackets(DecodeSubPacketManage
DECODE_CHK_STATUS(subPacketManager.Register(
DecodePacketId(this, mpeg2PictureSubPacketId), *pictureDecodePkt));

if (codecSettings.mode = CODECHAL_DECODE_MODE_MPEG2VLD)
if (codecSettings.mode == CODECHAL_DECODE_MODE_MPEG2VLD)
{
Mpeg2DecodeSlcPktXe_Lpm_Plus_Base *sliceDecodePkt = MOS_New(Mpeg2DecodeSlcPktXe_Lpm_Plus_Base, this, m_hwInterface);
DECODE_CHK_NULL(sliceDecodePkt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ MOS_STATUS Mpeg2DecodeMbPkt::AddCmd_MFD_MPEG2_IT_OBJECT(MHW_BATCH_BUFFER &batchB
}
}

headerPar.DwordLength = (m_mfxItf->MHW_GETSIZE_F(MFD_IT_OBJECT_MPEG2_INLINE_DATA)() +
m_mfxItf->MHW_GETSIZE_F(MFD_IT_OBJECT)()) >> 2;
headerPar.DwordLength = ((m_mfxItf->MHW_GETSIZE_F(MFD_IT_OBJECT_MPEG2_INLINE_DATA)() +
m_mfxItf->MHW_GETSIZE_F(MFD_IT_OBJECT)()) >> 2) - 2;
headerPar.dwDCTLength = dwDCTLength;
headerPar.IndirectItCoeffDataStartAddressOffset = mbParams->m_mbDataLoc << 2;

inlinePar.CodingType = m_mpeg2PicParams->m_pictureCodingType;
inlinePar.pMBParams = mbParams;
Expand Down Expand Up @@ -222,8 +223,9 @@ MOS_STATUS Mpeg2DecodeMbPkt::AddAllCmdsInsertSkippedMacroblocks(MHW_BATCH_BUFFER
inlinePar = {};
headerPar = {};

headerPar.DwordLength = (m_mfxItf->MHW_GETSIZE_F(MFD_IT_OBJECT_MPEG2_INLINE_DATA)() +
m_mfxItf->MHW_GETSIZE_F(MFD_IT_OBJECT)()) >> 2;
headerPar.DwordLength = ((m_mfxItf->MHW_GETSIZE_F(MFD_IT_OBJECT_MPEG2_INLINE_DATA)() +
m_mfxItf->MHW_GETSIZE_F(MFD_IT_OBJECT)()) >> 2) - 2;

headerPar.dwDCTLength = 0;

inlinePar.CodingType = m_mpeg2PicParams->m_pictureCodingType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,28 @@ MOS_STATUS Mpeg2DecodePkt::Init()
DECODE_CHK_NULL(m_picturePkt);
DECODE_CHK_STATUS(m_picturePkt->CalculateCommandSize(m_pictureStatesSize, m_picturePatchListSize));

uint32_t secondLevelBBSize = 0;
uint32_t numMacroblocks = m_mpeg2BasicFeature->m_picWidthInMb * m_mpeg2BasicFeature->m_picHeightInMb;

if (m_mpeg2BasicFeature->m_mode == CODECHAL_DECODE_MODE_MPEG2VLD)
{
subPacket = m_mpeg2Pipeline->GetSubPacket(DecodePacketId(m_mpeg2Pipeline, mpeg2SliceSubPacketId));
m_slicePkt = dynamic_cast<Mpeg2DecodeSlcPkt*>(subPacket);
DECODE_CHK_NULL(m_slicePkt);
DECODE_CHK_STATUS(m_slicePkt->CalculateCommandSize(m_sliceStatesSize, m_slicePatchListSize));
secondLevelBBSize = (m_sliceStatesSize * numMacroblocks) + m_hwInterface->m_sizeOfCmdBatchBufferEnd;
}
else
{
subPacket = m_mpeg2Pipeline->GetSubPacket(DecodePacketId(m_mpeg2Pipeline, mpeg2MbSubPacketId));
m_mbPkt = dynamic_cast<Mpeg2DecodeMbPkt*>(subPacket);
DECODE_CHK_NULL(m_mbPkt);
DECODE_CHK_STATUS(m_mbPkt->CalculateCommandSize(m_mbStatesSize, m_mbPatchListSize));
secondLevelBBSize = (m_mbStatesSize * numMacroblocks) + m_hwInterface->m_sizeOfCmdBatchBufferEnd;
}

uint32_t numMacroblocks = m_mpeg2BasicFeature->m_picWidthInMb * m_mpeg2BasicFeature->m_picHeightInMb;
uint32_t size = (m_sliceStatesSize * numMacroblocks) + m_hwInterface->m_sizeOfCmdBatchBufferEnd;
m_secondLevelBBArray = m_allocator->AllocateBatchBufferArray(
size, 1, CODEC_MPEG2_BATCH_BUFFERS_NUM, true, lockableVideoMem);
secondLevelBBSize, 1, CODEC_MPEG2_BATCH_BUFFERS_NUM, true, lockableVideoMem);
DECODE_CHK_NULL(m_secondLevelBBArray);

return MOS_STATUS_SUCCESS;
Expand Down
27 changes: 10 additions & 17 deletions media_softlet/agnostic/common/hw/vdbox/mhw_vdbox_mfx_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1350,13 +1350,12 @@ class Impl : public Itf, public mhw::Impl

auto MBType = params.pMBParams->MBType;

#define DO_FIELDS() \
DO_FIELD(DW0, MacroblockIntraType, 1); \
DO_FIELD(DW0, DctType, MBType.m_fieldResidual); \
DO_FIELD(DW0, CodedBlockPattern, params.CodedBlockPattern); \
DO_FIELD(DW1, Horzorigin, params.Horzorigin); \
DO_FIELD(DW1, Vertorigin, params.Vertorigin); \
DO_FIELD(DW0, Lastmbinrow, params.Lastmbinrow);
cmd.DW0.MacroblockIntraType = 1;
cmd.DW0.DctType = MBType.m_fieldResidual;
cmd.DW0.CodedBlockPattern = params.CodedBlockPattern;
cmd.DW0.Lastmbinrow = params.Lastmbinrow;
cmd.DW1.Horzorigin = params.Horzorigin;
cmd.DW1.Vertorigin = params.Vertorigin;

if (params.CodingType != I_TYPE)
{
Expand All @@ -1370,18 +1369,12 @@ class Impl : public Itf, public mhw::Impl
if (MBType.m_intraMb == 0)
{
uint32_t *point = (uint32_t *)(params.sPackedMVs0);

cmd.DW2.MotionVectorsField0ForwardHorizontalComponent = *point++;
cmd.DW2.MotionVectorsField0ForwardVerticalComponent = *point++;
cmd.DW3.MotionVectorsField0BackwardHorizontalComponent = *point++;
cmd.DW3.MotionVectorsField0BackwardVerticalComponent = *point++;
cmd.DW2.Value = *point++;
cmd.DW3.Value = *point++;

point = (uint32_t *)(params.sPackedMVs1);

cmd.DW4.MotionVectorsField1ForwardHorizontalComponent = *point++;
cmd.DW4.MotionVectorsField1ForwardVerticalComponent = *point++;
cmd.DW5.MotionVectorsField1BackwardHorizontalComponent = *point++;
cmd.DW5.MotionVectorsField1BackwardVerticalComponent = *point++;
cmd.DW4.Value = *point++;
cmd.DW5.Value = *point++;
}
}

Expand Down

0 comments on commit b3255d5

Please sign in to comment.