Skip to content

Commit

Permalink
Revert "[Decode] Fix some linux coverity issues"
Browse files Browse the repository at this point in the history
This reverts commit intel-innersource/drivers.gpu.unified#c1f57e463
  • Loading branch information
luleilei1 authored and intel-mediadev committed Sep 28, 2023
1 parent 83d675a commit c4442dd
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ MOS_STATUS CodechalDecodeNV12ToP010::Execute(
surfaceRT->GetSurfaceDesc(surfaceWidth, surfaceHeight, format, sizePerPixel);

SurfaceIndex *srcSurfaceIndex;
CODECHAL_DECODE_CHK_STATUS_RETURN(srcCmSurface2D->GetIndex(srcSurfaceIndex));
srcCmSurface2D->GetIndex(srcSurfaceIndex);
SurfaceIndex *dstSurfaceIndex;
CODECHAL_DECODE_CHK_STATUS_RETURN(dstCmSurface2D->GetIndex(dstSurfaceIndex));
dstCmSurface2D->GetIndex(dstSurfaceIndex);

CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmDevice->CreateTask(m_cmTask));
CODECHAL_DECODE_CHK_NULL_RETURN(m_cmTask);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2033,7 +2033,6 @@ MOS_STATUS CodecHalDecodeScalability_InitializeState (
GpuContext = MOS_VE_MULTINODESCALING_SUPPORTED(osInterface) ? MOS_GPU_CONTEXT_VIDEO4 : GpuContext;

MHW_VDBOX_GPUNODE_LIMIT gpuNodeLimit;
MOS_ZeroMemory(&gpuNodeLimit, sizeof(MHW_VDBOX_GPUNODE_LIMIT));
CODECHAL_DECODE_CHK_STATUS_RETURN(vdboxMfxInterface->FindGpuNodeToUse(
&gpuNodeLimit));
MOS_GPU_NODE videoGpuNode = (MOS_GPU_NODE)(gpuNodeLimit.dwGpuNodeToUse);
Expand Down
1 change: 0 additions & 1 deletion media_driver/agnostic/common/codec/hal/codechal_hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ CodechalHwInterface::CodechalHwInterface(
// Basic intialization
m_osInterface = osInterface;

MOS_ZeroMemory(&m_platform, sizeof(PLATFORM));
m_osInterface->pfnGetPlatform(m_osInterface, &m_platform);

m_skuTable = m_osInterface->pfnGetSkuTable(m_osInterface);
Expand Down
2 changes: 1 addition & 1 deletion media_driver/agnostic/common/codec/hal/codechal_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ class CodechalHwInterface
{
CODECHAL_HW_FUNCTION_ENTER;

if (MEDIA_IS_WA(m_waTable, WaHucStreamoutEnable) && m_osInterface)
if (MEDIA_IS_WA(m_waTable, WaHucStreamoutEnable))
{
m_osInterface->pfnFreeResource(
m_osInterface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ MOS_STATUS MhwVdboxHcpInterfaceG10::AddHcpEncodeSliceStateCmd(
= hevcSliceParams->slice_temporal_mvp_enable_flag;
cmd.DW3.Sliceqp = hevcSliceParams->slice_qp_delta + hevcPicParams->QpY;
cmd.DW3.SliceCbQpOffset = hevcSliceParams->slice_cb_qp_offset;
cmd.DW3.SliceCrQpOffset = hevcSliceParams->slice_cr_qp_offset;
cmd.DW3.SliceCbQpOffset = hevcSliceParams->slice_cr_qp_offset;
cmd.DW3.Intrareffetchdisable = hevcSliceState->bIntraRefFetchDisable;

cmd.DW4.SliceHeaderDisableDeblockingFilterFlag = hevcSliceParams->slice_deblocking_filter_disable_flag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ MOS_STATUS CodechalDecodeAvcG11::DecodePrimitiveLevel()
DecodeProcessingParams *decProcessingParams = (DecodeProcessingParams *)m_decodeParams.m_procParams;
if (decProcessingParams != nullptr && decProcessingParams->m_isReferenceOnlyPattern)
{
CODECHAL_DECODE_CHK_STATUS_RETURN(HucCopy(&cmdBuffer,
&m_destSurface.OsResource,
&decProcessingParams->m_outputSurface->OsResource,
decProcessingParams->m_outputSurface->dwSize,
m_destSurface.dwOffset,
decProcessingParams->m_outputSurface->dwOffset
));
HucCopy(&cmdBuffer,
&m_destSurface.OsResource,
&decProcessingParams->m_outputSurface->OsResource,
decProcessingParams->m_outputSurface->dwSize,
m_destSurface.dwOffset,
decProcessingParams->m_outputSurface->dwOffset
);
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,9 @@ MOS_STATUS CodechalDecodeHevcG11::SetFrameStates ()
}

CODECHAL_DECODE_CHK_STATUS_RETURN(CheckAndCopyBitstream());
if (m_hevcPicParams->CurrPic.FrameIdx < CODECHAL_NUM_UNCOMPRESSED_SURFACE_HEVC)
{
PCODEC_REF_LIST destEntry = m_hevcRefList[m_hevcPicParams->CurrPic.FrameIdx];
MOS_ZeroMemory(destEntry, sizeof(CODEC_REF_LIST));
}

PCODEC_REF_LIST destEntry = m_hevcRefList[m_hevcPicParams->CurrPic.FrameIdx];
MOS_ZeroMemory(destEntry, sizeof(CODEC_REF_LIST));

if (m_incompletePicture)
{
Expand Down Expand Up @@ -666,7 +664,6 @@ MOS_STATUS CodechalDecodeHevcG11::SetAndPopulateVEHintParams(
if (static_cast<MhwVdboxMfxInterfaceG11*>(m_mfxInterface)->IsScalabilitySupported() && MOS_VE_SUPPORTED(m_osInterface))
{
CODECHAL_DECODE_SCALABILITY_SETHINT_PARMS scalSetParms;
MOS_ZeroMemory(&scalSetParms, sizeof(CODECHAL_DECODE_SCALABILITY_SETHINT_PARMS));
if (!MOS_VE_CTXBASEDSCHEDULING_SUPPORTED(m_osInterface))
{
scalSetParms.bNeedSyncWithPrevious = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ MOS_STATUS CodechalDecodeVp9G11::SetAndPopulateVEHintParams(
if (static_cast<MhwVdboxMfxInterfaceG11*>(m_mfxInterface)->IsScalabilitySupported() && MOS_VE_SUPPORTED(m_osInterface))
{
CODECHAL_DECODE_SCALABILITY_SETHINT_PARMS scalSetParms;
MOS_ZeroMemory(&scalSetParms, sizeof(CODECHAL_DECODE_SCALABILITY_SETHINT_PARMS));
if (!MOS_VE_CTXBASEDSCHEDULING_SUPPORTED(m_osInterface))
{
scalSetParms.bNeedSyncWithPrevious = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ MOS_STATUS CodechalCmdInitializerG11::SetCopyDmem()
m_osInterface, &m_cmdInitializerCopyDmemBuffer[m_encoder->m_currRecycledBufIdx][m_currentPass], &lockFlagsWriteOnly);
CODECHAL_ENCODE_CHK_NULL_RETURN(hucCmdCopyDmem);

MOS_ZeroMemory(hucCmdCopyDmem, sizeof(HucComDmem));
MOS_ZeroMemory(hucCmdCopyDmem, sizeof(hucCmdCopyDmem));

hucCmdCopyDmem->TotalOutputCommands = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2917,7 +2917,7 @@ MOS_STATUS MhwVdboxHcpInterfaceG11::AddHcpEncodeSliceStateCmd(
cmd.DW3.SliceTemporalMvpEnableFlag = hevcSliceParams->slice_temporal_mvp_enable_flag;
cmd.DW3.Sliceqp = abs(hevcSliceParams->slice_qp_delta + hevcPicParams->QpY);
cmd.DW3.SliceCbQpOffset = hevcSliceParams->slice_cb_qp_offset;
cmd.DW3.SliceCrQpOffset = hevcSliceParams->slice_cr_qp_offset;
cmd.DW3.SliceCbQpOffset = hevcSliceParams->slice_cr_qp_offset;
cmd.DW3.Intrareffetchdisable = hevcSliceState->bIntraRefFetchDisable;

cmd.DW4.SliceHeaderDisableDeblockingFilterFlag = hevcSliceParams->slice_deblocking_filter_disable_flag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ CodechalHwInterfaceG12::~CodechalHwInterfaceG12()
if (m_avpInterface)
{
MOS_Delete(m_avpInterface);
m_avpInterface = nullptr;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7752,7 +7752,6 @@ MOS_STATUS CodechalEncodeAvcEncFeiG8::SetCurbeAvcPreProc(PCODECHAL_ENCODE_AVC_PR
refWidth = 64;
refHeight = 32;
lenSP = 32;
break;
case 8:
// Exhaustive 48 SUs 64x32 window
refWidth = 64;
Expand Down
4 changes: 2 additions & 2 deletions media_driver/agnostic/gen9/codec/hal/codechal_fei_avc_g9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6711,10 +6711,10 @@ MOS_STATUS CodechalEncodeAvcEncFeiG9::SendAvcMfeMbEncSurfaces(PMOS_COMMAND_BUFFE
}
}

CODECHAL_ENCODE_CHK_STATUS_RETURN(m_cmDev->CreateVmeSurfaceG7_5(cmSurfForVME, &surfArrayL0[0], &surfArrayL1[0], refNum0, refNum1, cmVmeSurfIdx[0 + vmeIdx]));
m_cmDev->CreateVmeSurfaceG7_5(cmSurfForVME, &surfArrayL0[0], &surfArrayL1[0], refNum0, refNum1, cmVmeSurfIdx[0 + vmeIdx]);
cmSurfaces->MBVMEInterPredictionSurfIndex = cmVmeSurfIdx[0 + vmeIdx];

CODECHAL_ENCODE_CHK_STATUS_RETURN(m_cmDev->CreateVmeSurfaceG7_5(cmSurfForVME, &surfArrayL1[0], &surfArrayL1[0], refNum1, refNum1, cmVmeSurfIdx[1 + vmeIdx]));
m_cmDev->CreateVmeSurfaceG7_5(cmSurfForVME, &surfArrayL1[0], &surfArrayL1[0], refNum1, refNum1, cmVmeSurfIdx[1 + vmeIdx]);
cmSurfaces->MBVMEInterPredictionMRSurfIndex = cmVmeSurfIdx[1 + vmeIdx];

CM_VME_SURFACE_STATE_PARAM vmeDimensionParam;
Expand Down
3 changes: 1 addition & 2 deletions media_driver/linux/common/codec/ddi/media_ddi_decode_avc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ VAStatus DdiDecodeAVC::ParsePicParams(
for (i = 0; i < CODEC_MAX_NUM_REF_FRAME; i++)
{
//Check the surface id of reference list
if (avcPicParams->RefFrameList[i].FrameIdx < CODEC_AVC_NUM_UNCOMPRESSED_SURFACE
&& VA_INVALID_ID == m_ddiDecodeCtx->RecListSurfaceID[avcPicParams->RefFrameList[i].FrameIdx])
if (VA_INVALID_ID == m_ddiDecodeCtx->RecListSurfaceID[avcPicParams->RefFrameList[i].FrameIdx])
{
//Set invalid flag
avcPicParams->RefFrameList[i].PicFlags = PICTURE_INVALID;
Expand Down
6 changes: 6 additions & 0 deletions media_driver/linux/common/codec/ddi/media_ddi_decode_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,12 @@ VAStatus DdiMediaDecode::CreateBuffer(
buf->format = Media_Format_CPU;
break;
case VASubsetsParameterBufferType:
//maximum entry point supported should not be more than 440
if(numElements > 440)
{
va = VA_STATUS_ERROR_INVALID_PARAMETER;
goto CleanUpandReturn;
}
buf->pData = (uint8_t*)MOS_AllocAndZeroMemory(size * numElements);
buf->format = Media_Format_CPU;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ VAStatus DdiDecodeVC1::ParsePicParams(
}
uint32_t scaleFactor = 0;
// See spec, table 40 && Figure 70
if (picParam->b_picture_fraction < 21)
if ((picParam->b_picture_fraction >= 0) && (picParam->b_picture_fraction < 21))
{
scaleFactor = FractionToScaleFactor[picParam->b_picture_fraction];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ namespace decode
inline Av1SharedBuf *RefSharedBuffer(Av1SharedBuf *sharedBuf);
inline Av1SharedBuf *DeRefSharedBuffer(Av1SharedBuf *sharedBuf);
MhwVdboxAvpInterface *m_avpInterface = nullptr; //!< Avp interface;
int32_t widthInSb = 0;
int32_t heightInSb = 0;
int32_t widthInSb;
int32_t heightInSb;
MEDIA_CLASS_DEFINE_END(decode__Av1TempBufferOpInfG12)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ namespace decode
inline Av1SharedBuf *RefSharedBuffer(Av1SharedBuf *sharedBuf);
inline Av1SharedBuf *DeRefSharedBuffer(Av1SharedBuf *sharedBuf);
std::shared_ptr<mhw::vdbox::avp::Itf> m_avpItf = nullptr;
int32_t widthInSb = 0;
int32_t heightInSb = 0;
int32_t widthInSb;
int32_t heightInSb;

MEDIA_CLASS_DEFINE_END(decode__Av1TempBufferOpInf)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ DecodeMemComp::DecodeMemComp(CodechalHwInterfaceNext *hwInterface, PMOS_INTERFAC
if (hwInterface == nullptr)
{
CODEC_HW_ASSERT(hwInterface);
return;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ CodechalHwInterfaceNext::CodechalHwInterfaceNext(
CODEC_HW_ASSERT(osInterface);
m_osInterface = osInterface;

MOS_ZeroMemory(&m_platform, sizeof(PLATFORM));
m_osInterface->pfnGetPlatform(m_osInterface, &m_platform);

m_skuTable = m_osInterface->pfnGetSkuTable(m_osInterface);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ VAStatus DdiDecodeAvc::ParsePicParams(
for (i = 0; i < CODEC_MAX_NUM_REF_FRAME; i++)
{
// Check the surface id of reference list
if (avcPicParams->RefFrameList[i].FrameIdx < CODEC_AVC_NUM_UNCOMPRESSED_SURFACE &&
VA_INVALID_ID == m_decodeCtx->RecListSurfaceID[avcPicParams->RefFrameList[i].FrameIdx])
if (VA_INVALID_ID == m_decodeCtx->RecListSurfaceID[avcPicParams->RefFrameList[i].FrameIdx])
{
// Set invalid flag
avcPicParams->RefFrameList[i].PicFlags = PICTURE_INVALID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,13 @@ VAStatus DdiDecodeBase::CreateBuffer(
buf->format = Media_Format_CPU;
break;
case VASubsetsParameterBufferType:
// maximum entry point supported should not be more than 440
if (numElements > 440)
{
va = VA_STATUS_ERROR_INVALID_PARAMETER;
MOS_FreeMemory(buf);
return va;
}
buf->pData = (uint8_t*)MOS_AllocAndZeroMemory(size * numElements);
buf->format = Media_Format_CPU;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ MOS_STATUS CodechalInterfacesXe_Lpm_Plus::Initialize(
else
#endif
{
MOS_Delete(hwInterface);
CODECHAL_PUBLIC_ASSERTMESSAGE("Decode mode requested invalid!");
return MOS_STATUS_INVALID_PARAMETER;
}
Expand All @@ -511,15 +510,13 @@ MOS_STATUS CodechalInterfacesXe_Lpm_Plus::Initialize(
m_codechalDevice = MOS_New(EncodeAvcVdencPipelineAdapterXe_Lpm_Plus_Base, hwInterface, debugInterface);
if (m_codechalDevice == nullptr)
{
MOS_Delete(hwInterface);
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!");
return MOS_STATUS_INVALID_PARAMETER;
}
return MOS_STATUS_SUCCESS;
}
else
{
MOS_Delete(hwInterface);
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode allocation failed, AVC VME Encoder is not supported, please use AVC LowPower Encoder instead!");
return MOS_STATUS_INVALID_PARAMETER;
}
Expand All @@ -532,7 +529,6 @@ MOS_STATUS CodechalInterfacesXe_Lpm_Plus::Initialize(
m_codechalDevice = MOS_New(EncodeVp9VdencPipelineAdapterXe_Lpm_Plus, hwInterface, debugInterface);
if (m_codechalDevice == nullptr)
{
MOS_Delete(hwInterface);
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!");
return MOS_STATUS_INVALID_PARAMETER;
}
Expand All @@ -542,7 +538,6 @@ MOS_STATUS CodechalInterfacesXe_Lpm_Plus::Initialize(
#endif
if (info->Mode == CODECHAL_ENCODE_MODE_MPEG2)
{
MOS_Delete(hwInterface);
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode allocation failed, MPEG2 Encoder is not supported!");
return MOS_STATUS_INVALID_PARAMETER;
}
Expand All @@ -553,7 +548,6 @@ MOS_STATUS CodechalInterfacesXe_Lpm_Plus::Initialize(
m_codechalDevice = MOS_New(EncodeJpegPipelineAdapterXe_Lpm_Plus_Base, hwInterface, debugInterface);
if (m_codechalDevice == nullptr)
{
MOS_Delete(hwInterface);
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!");
return MOS_STATUS_INVALID_PARAMETER;
}
Expand All @@ -572,7 +566,6 @@ MOS_STATUS CodechalInterfacesXe_Lpm_Plus::Initialize(
}
else
{
MOS_Delete(hwInterface);
return MOS_STATUS_INVALID_PARAMETER;
}
}
Expand All @@ -586,31 +579,27 @@ MOS_STATUS CodechalInterfacesXe_Lpm_Plus::Initialize(
m_codechalDevice = MOS_New(EncodeHevcVdencPipelineAdapterXe_Lpm_Plus, hwInterface, debugInterface);
if (m_codechalDevice == nullptr)
{
MOS_Delete(hwInterface);
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!");
return MOS_STATUS_INVALID_PARAMETER;
}
return MOS_STATUS_SUCCESS;
}
else
{
MOS_Delete(hwInterface);
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode allocation failed, HEVC VME Encoder is not supported.");
return MOS_STATUS_INVALID_PARAMETER;
}
}
else
#endif
{
MOS_Delete(hwInterface);
CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported encode function requested.");
return MOS_STATUS_INVALID_PARAMETER;
}
}
else
{
CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported codec function requested.");
MOS_Delete(hwInterface);
return MOS_STATUS_INVALID_PARAMETER;
}

Expand Down

0 comments on commit c4442dd

Please sign in to comment.