Skip to content

Commit

Permalink
[Decode] fix some cov issues
Browse files Browse the repository at this point in the history
Null Ptr check
  • Loading branch information
chuanli1 authored and intel-mediadev committed Sep 25, 2023
1 parent a999b6b commit d198103
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6884,7 +6884,6 @@ MOS_STATUS CodechalEncodeAvcEncFeiG8::InitializeState()
}

bWeightedPredictionSupported = true;
m_brcHistoryBufferSize = m_brcHistoryBufferSize;
dwBrcConstantSurfaceWidth = m_brcConstantSurfaceWidth;
dwBrcConstantSurfaceHeight = m_brcConstantSurfaceHeight;

Expand Down
4 changes: 2 additions & 2 deletions media_driver/linux/common/codec/ddi/media_libva_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static int32_t DdiDecode_GetDisplayInfo(VADriverContextP ctx)
vsinfo.yres = 0;

fd = open("/dev/graphics/fb0",O_RDONLY);
if(fd > 0)
if(fd >= 0)
{
if(ioctl(fd, FBIOGET_VSCREENINFO, &vsinfo) < 0)
{
Expand Down Expand Up @@ -527,7 +527,7 @@ VAStatus DdiDecode_StatusReport(PDDI_MEDIA_CONTEXT mediaCtx, DecodePipelineAdapt
// The surface is not busy in HW, but uNumCompletedReport is 0, treat as engine reset
else
{
surface->curStatusReport.decode.status == CODECHAL_STATUS_INCOMPLETE;
surface->curStatusReport.decode.status = CODECHAL_STATUS_INCOMPLETE;
surface->curStatusReportQueryState = DDI_MEDIA_STATUS_REPORT_QUERY_STATE_COMPLETED;
DDI_ASSERTMESSAGE("No report available at all! Engine reset may have occured.");
}
Expand Down
1 change: 1 addition & 0 deletions media_driver/linux/common/renderhal/renderhal_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ MOS_STATUS RenderHal_SetSurfaceStateToken(

SURFACE_STATE_TOKEN_COMMON *pTokenState = (SURFACE_STATE_TOKEN_COMMON*)pSurfaceStateToken;
PMOS_INTERFACE pOsInterface = pRenderHal->pOsInterface;
MHW_MI_CHK_NULL(pOsInterface);
PMOS_RESOURCE pOsResource = &(pParams->pOsSurface->OsResource);

int32_t iAllocationIndex = pOsInterface->pfnGetResourceAllocationIndex(pOsInterface, pOsResource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class HevcDecodeBackEndPktXe_Lpm_Plus_Base : public HevcDecodeBackEndPkt
: HevcDecodeBackEndPkt(pipeline, task, hwInterface)
{
m_hwInterface = dynamic_cast<CodechalHwInterfaceXe_Lpm_Plus_Base*>(hwInterface);
DECODE_CHK_NULL_NO_STATUS_RETURN(m_hwInterface);
m_vdencItf = std::static_pointer_cast<mhw::vdbox::vdenc::Itf>(m_hwInterface->GetVdencInterfaceNext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class HevcDecodeFrontEndPktXe_Lpm_Plus_Base : public HevcDecodeFrontEndPkt
: HevcDecodeFrontEndPkt(pipeline, task, hwInterface)
{
m_hwInterface = dynamic_cast<CodechalHwInterfaceXe_Lpm_Plus_Base*>(hwInterface);
DECODE_CHK_NULL_NO_STATUS_RETURN(m_hwInterface);
m_vdencItf = std::static_pointer_cast<mhw::vdbox::vdenc::Itf>(m_hwInterface->GetVdencInterfaceNext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class HevcDecodeLongPktXe_Lpm_Plus_Base : public HevcDecodeLongPkt
: HevcDecodeLongPkt(pipeline, task, hwInterface)
{
m_hwInterface = dynamic_cast<CodechalHwInterfaceXe_Lpm_Plus_Base*>(hwInterface);
DECODE_CHK_NULL_NO_STATUS_RETURN(m_hwInterface);
m_vdencItf = std::static_pointer_cast<mhw::vdbox::vdenc::Itf>(m_hwInterface->GetVdencInterfaceNext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class HevcDecodeRealTilePktXe_Lpm_Plus_Base : public HevcDecodeRealTilePkt
: HevcDecodeRealTilePkt(pipeline, task, hwInterface)
{
m_hwInterface = dynamic_cast<CodechalHwInterfaceXe_Lpm_Plus_Base*>(hwInterface);
DECODE_CHK_NULL_NO_STATUS_RETURN(m_hwInterface);
m_vdencItf = std::static_pointer_cast<mhw::vdbox::vdenc::Itf>(m_hwInterface->GetVdencInterfaceNext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Vp9DecodeBackEndPktXe_Lpm_Plus_Base : public Vp9DecodeBackEndPkt
: Vp9DecodeBackEndPkt(pipeline, task, hwInterface)
{
m_hwInterface = dynamic_cast<CodechalHwInterfaceXe_Lpm_Plus_Base *>(hwInterface);
DECODE_CHK_NULL_NO_STATUS_RETURN(m_hwInterface);
m_vdencItf = std::static_pointer_cast<mhw::vdbox::vdenc::Itf>(m_hwInterface->GetVdencInterfaceNext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Vp9DecodeFrontEndPktXe_Lpm_Plus_Base : public Vp9DecodeFrontEndPkt
: Vp9DecodeFrontEndPkt(pipeline, task, hwInterface)
{
m_hwInterface = dynamic_cast<CodechalHwInterfaceXe_Lpm_Plus_Base *>(hwInterface);
DECODE_CHK_NULL_NO_STATUS_RETURN(m_hwInterface);
m_vdencItf = std::static_pointer_cast<mhw::vdbox::vdenc::Itf>(m_hwInterface->GetVdencInterfaceNext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Vp9DecodeSinglePktXe_Lpm_Plus_Base : public Vp9DecodeSinglePkt
Vp9DecodeSinglePkt(pipeline, task, hwInterface)
{
m_hwInterface = dynamic_cast<CodechalHwInterfaceXe_Lpm_Plus_Base *>(hwInterface);
DECODE_CHK_NULL_NO_STATUS_RETURN(m_hwInterface);
m_vdencItf = std::static_pointer_cast<mhw::vdbox::vdenc::Itf>(m_hwInterface->GetVdencInterfaceNext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ VAStatus DdiDecodeFunctions::StatusReport(
// The surface is not busy in HW, but uNumCompletedReport is 0, treat as engine reset
else
{
surface->curStatusReport.decode.status == CODECHAL_STATUS_INCOMPLETE;
surface->curStatusReport.decode.status = CODECHAL_STATUS_INCOMPLETE;
surface->curStatusReportQueryState = DDI_MEDIA_STATUS_REPORT_QUERY_STATE_COMPLETED;
DDI_ASSERTMESSAGE("No report available at all! Engine reset may have occured.");
}
Expand Down Expand Up @@ -1252,7 +1252,7 @@ int32_t DdiDecodeFunctions::GetDisplayInfo(VADriverContextP ctx)
vsinfo.yres = 0;

fd = open("/dev/graphics/fb0",O_RDONLY);
if (fd > 0)
if (fd >= 0)
{
if (ioctl(fd, FBIOGET_VSCREENINFO, &vsinfo) < 0)
{
Expand Down

0 comments on commit d198103

Please sign in to comment.