Skip to content

Commit

Permalink
[Decode] Fix some cov issues
Browse files Browse the repository at this point in the history
1. return value check
2. Null pointer check
3. Array index check
  • Loading branch information
chuanli1 authored and intel-mediadev committed Oct 20, 2023
1 parent 962bb72 commit 9124262
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ MOS_STATUS CodechalDecodeHevcG12::AddPictureLongFormatCmds(
// Send VD_CONTROL_STATE Pipe Initialization
MOS_ZeroMemory(&vdCtrlParam, sizeof(MHW_MI_VD_CONTROL_STATE_PARAMS));
vdCtrlParam.initialization = true;
static_cast<MhwMiInterfaceG12*>(m_miInterface)->AddMiVdControlStateCmd(cmdBufferInUse, &vdCtrlParam);
CODECHAL_DECODE_CHK_STATUS_RETURN(static_cast<MhwMiInterfaceG12*>(m_miInterface)->AddMiVdControlStateCmd(cmdBufferInUse, &vdCtrlParam));

CODECHAL_DECODE_CHK_STATUS_RETURN(m_hcpInterface->AddHcpPipeModeSelectCmd(
cmdBufferInUse,
Expand All @@ -1479,7 +1479,7 @@ MOS_STATUS CodechalDecodeHevcG12::AddPictureLongFormatCmds(
// Send VD_CONTROL_STATE HcpPipeLock
MOS_ZeroMemory(&vdCtrlParam, sizeof(MHW_MI_VD_CONTROL_STATE_PARAMS));
vdCtrlParam.scalableModePipeLock = true;
static_cast<MhwMiInterfaceG12*>(m_miInterface)->AddMiVdControlStateCmd(cmdBufferInUse, &vdCtrlParam);
CODECHAL_DECODE_CHK_STATUS_RETURN(static_cast<MhwMiInterfaceG12 *>(m_miInterface)->AddMiVdControlStateCmd(cmdBufferInUse, &vdCtrlParam));
}

#ifdef _DECODE_PROCESSING_SUPPORTED
Expand Down Expand Up @@ -2089,7 +2089,7 @@ MOS_STATUS CodechalDecodeHevcG12::DecodePrimitiveLevel()
// Send VD_CONTROL_STATE Memory Implict Flush
MOS_ZeroMemory(&vdCtrlParam, sizeof(MHW_MI_VD_CONTROL_STATE_PARAMS));
vdCtrlParam.memoryImplicitFlush = true;
static_cast<MhwMiInterfaceG12*>(m_miInterface)->AddMiVdControlStateCmd(cmdBufferInUse, &vdCtrlParam);
CODECHAL_DECODE_CHK_STATUS_RETURN(static_cast<MhwMiInterfaceG12 *>(m_miInterface)->AddMiVdControlStateCmd(cmdBufferInUse, &vdCtrlParam));

if (CodecHalDecodeScalabilityIsBEPhaseG12(m_scalabilityState) ||
m_isRealTile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ MOS_STATUS CodechalDecodeVp9G12::AddPicStateMhwCmds(
// Send VD_CONTROL_STATE Pipe Initialization
MOS_ZeroMemory(&vdCtrlParam, sizeof(MHW_MI_VD_CONTROL_STATE_PARAMS));
vdCtrlParam.initialization = true;
static_cast<MhwMiInterfaceG12*>(m_miInterface)->AddMiVdControlStateCmd(cmdBuffer, &vdCtrlParam);
CODECHAL_DECODE_CHK_STATUS_RETURN(static_cast<MhwMiInterfaceG12 *>(m_miInterface)->AddMiVdControlStateCmd(cmdBuffer, &vdCtrlParam));

CODECHAL_DECODE_CHK_STATUS_RETURN(m_hcpInterface->AddHcpPipeModeSelectCmd(
cmdBuffer,
Expand All @@ -558,7 +558,7 @@ MOS_STATUS CodechalDecodeVp9G12::AddPicStateMhwCmds(
// Send VD_CONTROL_STATE HcpPipeLock
MOS_ZeroMemory(&vdCtrlParam, sizeof(MHW_MI_VD_CONTROL_STATE_PARAMS));
vdCtrlParam.scalableModePipeLock = true;
static_cast<MhwMiInterfaceG12*>(m_miInterface)->AddMiVdControlStateCmd(cmdBuffer, &vdCtrlParam);
CODECHAL_DECODE_CHK_STATUS_RETURN(static_cast<MhwMiInterfaceG12 *>(m_miInterface)->AddMiVdControlStateCmd(cmdBuffer, &vdCtrlParam));
}
#ifdef _DECODE_PROCESSING_SUPPORTED
if (!CodecHalDecodeScalabilityIsFEPhase(m_scalabilityState))
Expand Down Expand Up @@ -925,15 +925,15 @@ MOS_STATUS CodechalDecodeVp9G12 :: DecodePrimitiveLevel()
// Send VD_CONTROL_STATE Memory Implict Flush
MOS_ZeroMemory(&vdCtrlParam, sizeof(MHW_MI_VD_CONTROL_STATE_PARAMS));
vdCtrlParam.memoryImplicitFlush = true;
static_cast<MhwMiInterfaceG12*>(m_miInterface)->AddMiVdControlStateCmd(cmdBufferInUse, &vdCtrlParam);
CODECHAL_DECODE_CHK_STATUS_RETURN(static_cast<MhwMiInterfaceG12 *>(m_miInterface)->AddMiVdControlStateCmd(cmdBufferInUse, &vdCtrlParam));

if (CodecHalDecodeScalabilityIsScalableMode(m_scalabilityState) &&
CodecHalDecodeScalabilityIsBEPhaseG12(m_scalabilityState))
{
// Send VD_CONTROL_STATE HCP Pipe Unlock
MOS_ZeroMemory(&vdCtrlParam, sizeof(MHW_MI_VD_CONTROL_STATE_PARAMS));
vdCtrlParam.scalableModePipeUnlock = true;
static_cast<MhwMiInterfaceG12*>(m_miInterface)->AddMiVdControlStateCmd(cmdBufferInUse, &vdCtrlParam);
CODECHAL_DECODE_CHK_STATUS_RETURN(static_cast<MhwMiInterfaceG12 *>(m_miInterface)->AddMiVdControlStateCmd(cmdBufferInUse, &vdCtrlParam));
}

// Send VD Pipe Flush command for SKL+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ namespace decode {
auto &par = m_hucItf->MHW_GETPAR_F(HUC_IMEM_STATE)();
par = {};
par.kernelDescriptor = m_vdboxHucHevcS2lKernelDescriptor;
m_hucItf->MHW_ADDCMD_F(HUC_IMEM_STATE)(&cmdBuffer);
DECODE_CHK_STATUS(m_hucItf->MHW_ADDCMD_F(HUC_IMEM_STATE)(&cmdBuffer));

auto &mfxWaitParams = m_miItf->MHW_GETPAR_F(MFX_WAIT)();
mfxWaitParams = {};
Expand All @@ -278,7 +278,7 @@ namespace decode {
auto &par = m_hucItf->MHW_GETPAR_F(HUC_PIPE_MODE_SELECT)();
par = {};
par.streamOutEnabled = false;
m_hucItf->MHW_ADDCMD_F(HUC_PIPE_MODE_SELECT)(&cmdBuffer);
DECODE_CHK_STATUS(m_hucItf->MHW_ADDCMD_F(HUC_PIPE_MODE_SELECT)(&cmdBuffer));

mfxWaitParams = {};
mfxWaitParams.iStallVdboxPipeline = true;
Expand Down Expand Up @@ -341,7 +341,7 @@ namespace decode {
par.StartCodeByte1 = 0;
par.StartCodeByte2 = 1;

m_hucItf->MHW_ADDCMD_F(HUC_STREAM_OBJECT)(&cmdBuffer);
DECODE_CHK_STATUS(m_hucItf->MHW_ADDCMD_F(HUC_STREAM_OBJECT)(&cmdBuffer));

return MOS_STATUS_SUCCESS;
}
Expand All @@ -352,7 +352,7 @@ namespace decode {
auto &par = m_hucItf->MHW_GETPAR_F(HUC_START)();
par = {};
par.lastStreamObject = laststreamobject;
m_hucItf->MHW_ADDCMD_F(HUC_START)(&cmdBuffer);
DECODE_CHK_STATUS(m_hucItf->MHW_ADDCMD_F(HUC_START)(&cmdBuffer));

return MOS_STATUS_SUCCESS;
}
Expand Down
1 change: 1 addition & 0 deletions media_softlet/agnostic/common/os/mos_utilities_next.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ void MosUtilities::MosFreeMemory(void *ptr)
MT_MEMORY_PTR, (int64_t)(ptr),
functionName, filename, line);
free(ptr);
ptr = nullptr;
}
}

Expand Down

0 comments on commit 9124262

Please sign in to comment.