Skip to content

Commit

Permalink
[Decode] Fix memory issues for stage code
Browse files Browse the repository at this point in the history
  • Loading branch information
pengxin99 authored and intel-mediadev committed Nov 27, 2023
1 parent 929db10 commit 8c6c6e4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,16 @@ MOS_STATUS CodechalKernelOlpMdf::Execute(PMOS_SURFACE src, uint16_t *srcMemory_o
CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmDevice->CreateThreadGroupSpace(1, 1, threadWidth, threadHeight, m_threadGroupSpaces[0]));
CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmKernels[0]->AssociateThreadGroupSpace(m_threadGroupSpaces[0]));
CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmTask->AddKernel(m_cmKernels[0]));

auto delete_event = [&]()
{
MOS_Delete(event);
};

if (!m_SingleTaskPhase)
{
auto sts = m_cmQueue->EnqueueWithGroup(m_cmTask, event);
MOS_STATUS stmtStatus = (MOS_STATUS)(sts);
if (stmtStatus != MOS_STATUS_SUCCESS)
{
event = CM_NO_EVENT;
return stmtStatus;
}
CODECHAL_ENCODE_CHK_STATUS_RETURN(m_cmTask->Reset());
CODECHAL_ENCODE_CHK_STATUS_WITH_DESTROY_RETURN(m_cmQueue->EnqueueWithGroup(m_cmTask, event), delete_event);
CODECHAL_ENCODE_CHK_STATUS_WITH_DESTROY_RETURN(m_cmTask->Reset(), delete_event);
}

threadWidth = MOS_ALIGN_CEIL(src->dwWidth, 16) / 16;
Expand All @@ -180,14 +180,8 @@ MOS_STATUS CodechalKernelOlpMdf::Execute(PMOS_SURFACE src, uint16_t *srcMemory_o
CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmDevice->CreateThreadGroupSpace(1, 1, threadWidth, threadHeight, m_threadGroupSpaces[1]));
CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmKernels[1]->AssociateThreadGroupSpace(m_threadGroupSpaces[1]));
CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmTask->AddKernel(m_cmKernels[1]));
auto sts = m_cmQueue->EnqueueWithGroup(m_cmTask, event);
MOS_STATUS stmtStatus = (MOS_STATUS)(sts);
if (stmtStatus != MOS_STATUS_SUCCESS)
{
event = CM_NO_EVENT;
return stmtStatus;
}
CODECHAL_ENCODE_CHK_STATUS_RETURN(m_cmTask->Reset());
CODECHAL_ENCODE_CHK_STATUS_WITH_DESTROY_RETURN(m_cmQueue->EnqueueWithGroup(m_cmTask, event), delete_event);
CODECHAL_ENCODE_CHK_STATUS_WITH_DESTROY_RETURN(m_cmTask->Reset(), delete_event);

return MOS_STATUS_SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,8 @@ MOS_STATUS CodechalInterfacesNextXe_Hpm::Initialize(

if (CodecHalIsDecode(CodecFunction))
{
MOS_Delete(hwInterface);
mhwInterfaces->SetDestroyState(true);
CODECHAL_PUBLIC_ASSERTMESSAGE("Decode allocation failed, Decoder with CodechalDeviceNext is not supported!");
return MOS_STATUS_INVALID_PARAMETER;

Expand All @@ -873,19 +875,25 @@ MOS_STATUS CodechalInterfacesNextXe_Hpm::Initialize(
}
else
{
MOS_Delete(hwInterface);
mhwInterfaces->SetDestroyState(true);
return MOS_STATUS_INVALID_PARAMETER;
}
}
else
#endif
{
MOS_Delete(hwInterface);
mhwInterfaces->SetDestroyState(true);
CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported encode function requested.");
return MOS_STATUS_INVALID_PARAMETER;
}

}
else
{
MOS_Delete(hwInterface);
mhwInterfaces->SetDestroyState(true);
CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported codec function requested.");
return MOS_STATUS_INVALID_PARAMETER;
}
Expand Down

0 comments on commit 8c6c6e4

Please sign in to comment.