Skip to content

Commit

Permalink
[vpp] fix crash when vfi output is rgb format
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroYY authored and gfxVPLsdm committed Jul 17, 2024
1 parent 7e3e116 commit 83d0a48
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 34 deletions.
4 changes: 1 addition & 3 deletions _studio/mfx_lib/vpp/include/mfx_vpp_ai_frame_interpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ class MFXVideoFrameInterpolation

mfxStatus ReturnSurface(mfxU32 taskIndex, mfxFrameSurface1* out, mfxMemId internalVidMemId = 0);

bool IsScdSupportedFormat(mfxU32 fourcc);

mfxStatus AddTaskQueue(mfxU32 taskIndex);

private:
mfxStatus InitScd(const mfxFrameInfo& frameInfo);
mfxStatus InitScd(const mfxFrameInfo& inFrameInfo, const mfxFrameInfo& outFrameInfo);
mfxStatus SceneChangeDetect(mfxFrameSurface1* input, bool isExternal, mfxU32& decision);

mfxStatus DuplicateFrame();
Expand Down
53 changes: 22 additions & 31 deletions _studio/mfx_lib/vpp/src/mfx_vpp_ai_frame_interpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,6 @@ MFXVideoFrameInterpolation::MFXVideoFrameInterpolation() :
{
}

bool MFXVideoFrameInterpolation::IsScdSupportedFormat(mfxU32 fourcc)
{
if (fourcc == MFX_FOURCC_NV12 ||
fourcc == MFX_FOURCC_RGB4 ||
fourcc == MFX_FOURCC_BGR4)
{
return true;
}
return false;
}

MFXVideoFrameInterpolation::~MFXVideoFrameInterpolation()
{
if (m_responseIn.mids)
Expand All @@ -86,23 +75,20 @@ MFXVideoFrameInterpolation::~MFXVideoFrameInterpolation()
m_core->FreeFrames(&m_outSurfForFi);
}

mfxStatus MFXVideoFrameInterpolation::InitScd(const mfxFrameInfo& frameInfo)
mfxStatus MFXVideoFrameInterpolation::InitScd(const mfxFrameInfo& inFrameInfo, const mfxFrameInfo& outFrameInfo)
{
mfxStatus sts = MFX_ERR_NONE;

if (IsScdSupportedFormat(frameInfo.FourCC))
{
m_enableScd = true;
}

m_enableScd = true;

if (!m_enableScd)
return MFX_ERR_NONE;
#ifdef MFX_ENABLE_AI_VIDEO_FRAME_INTERPOLATION
MFX_CHECK_STS(m_scd.Init(frameInfo.Width, frameInfo.Height, frameInfo.Width, MFX_PICSTRUCT_PROGRESSIVE, false));
MFX_CHECK_STS(m_scd.Init(outFrameInfo.Width, outFrameInfo.Height, outFrameInfo.Width, MFX_PICSTRUCT_PROGRESSIVE, false));
m_scd.SetGoPSize(ns_asc::Immediate_GoP);
#endif

if (frameInfo.FourCC != MFX_FOURCC_NV12)
if (outFrameInfo.FourCC != MFX_FOURCC_NV12)
{
m_scdNeedCsc = true;

Expand All @@ -112,8 +98,8 @@ mfxStatus MFXVideoFrameInterpolation::InitScd(const mfxFrameInfo& frameInfo)
mfxVideoParam vppParams = {};
vppParams.AsyncDepth = 1;
vppParams.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
vppParams.vpp.In = frameInfo;
vppParams.vpp.Out = frameInfo;
vppParams.vpp.In = outFrameInfo;
vppParams.vpp.Out = outFrameInfo;
//vppParams.vpp.Out.CropX = 0;
//vppParams.vpp.Out.CropY = 0;
//vppParams.vpp.Out.CropW = m_scd.Get_asc_subsampling_width();
Expand Down Expand Up @@ -189,7 +175,7 @@ mfxStatus MFXVideoFrameInterpolation::Init(VideoCORE* core, mfxFrameInfo& inInfo
m_outStamp = 0;
m_outTick = (mfxU16)m_ratio;

MFX_CHECK_STS(InitScd(inInfo));
MFX_CHECK_STS(InitScd(inInfo, outInfo));

#ifdef MFX_ENABLE_AI_VIDEO_FRAME_INTERPOLATION
D3D11Interface* pD3d11 = QueryCoreInterface<D3D11Interface>(core);
Expand Down Expand Up @@ -596,7 +582,7 @@ mfxStatus MFXVideoFrameInterpolation::SceneChangeDetect(mfxFrameSurface1* input,
mfxU8* dataY = nullptr;
mfxI32 pitch = 0;

if (input->Info.FourCC == MFX_FOURCC_NV12)
if (!m_scdNeedCsc)
{
if (isExternal)
{
Expand All @@ -613,7 +599,7 @@ mfxStatus MFXVideoFrameInterpolation::SceneChangeDetect(mfxFrameSurface1* input,
pitch = (mfxI32)(input->Data.PitchLow + (input->Data.PitchHigh << 16));
dataY = input->Data.Y;
}
else if(input->Info.FourCC == MFX_FOURCC_RGB4)
else
{
sts = m_vppForScd->Submit(input, &m_scdImage);
MFX_CHECK_STS(sts);
Expand All @@ -624,25 +610,30 @@ mfxStatus MFXVideoFrameInterpolation::SceneChangeDetect(mfxFrameSurface1* input,
dataY = m_scdImage.Data.Y;
pitch = m_scdImage.Data.Pitch;
}
else
{
MFX_RETURN(MFX_ERR_UNSUPPORTED);
}

#ifdef MFX_ENABLE_AI_VIDEO_FRAME_INTERPOLATION
sts = m_scd.PutFrameProgressive(dataY, pitch);
MFX_CHECK_STS(sts);

decision = m_scd.Get_frame_shot_Decision();
#endif

if (isExternal)
if (!m_scdNeedCsc)
{
sts = m_core->UnlockExternalFrame(*input);
if (isExternal)
{
sts = m_core->UnlockExternalFrame(*input);
}
else
{
sts = m_core->UnlockFrame(*input);
}
}
else
{
sts = m_core->UnlockFrame(*input);
sts = m_core->UnlockFrame(m_scdImage);
}

MFX_CHECK_STS(sts);
return sts;
}
Expand Down

0 comments on commit 83d0a48

Please sign in to comment.