Skip to content

Commit

Permalink
[Encode] clean coverity issues
Browse files Browse the repository at this point in the history
clean coverity issues
  • Loading branch information
DaShi-Git authored and intel-mediadev committed Aug 30, 2023
1 parent 5e2ae2b commit 0738e88
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 34 deletions.
17 changes: 13 additions & 4 deletions media_driver/agnostic/common/codec/hal/codechal_encode_avc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5544,10 +5544,19 @@ MOS_STATUS CodechalEncodeAvcEnc::SetSequenceStructs()
dwSlidingWindowSize = MOS_MIN((uint32_t)(seqParams->FramesPer100Sec / 100), 60);
}

m_maxNumSlicesAllowed = CodecHalAvcEncode_GetMaxNumSlicesAllowed(
(CODEC_AVC_PROFILE_IDC)(seqParams->Profile),
(CODEC_AVC_LEVEL_IDC)(seqParams->Level),
seqParams->FramesPer100Sec);
if (seqParams->FramesPer100Sec)
{
m_maxNumSlicesAllowed = CodecHalAvcEncode_GetMaxNumSlicesAllowed(
(CODEC_AVC_PROFILE_IDC)(seqParams->Profile),
(CODEC_AVC_LEVEL_IDC)(seqParams->Level),
seqParams->FramesPer100Sec);
}
else
{
CODECHAL_ENCODE_ASSERTMESSAGE("FramesPer100Sec is zero, cannot get MaxNumSliceAllowed.");
eStatus = MOS_STATUS_INVALID_PARAMETER;
}


return eStatus;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3248,10 +3248,6 @@ MOS_STATUS CodechalEncodeAvcBase::SetSliceStructs()
{
slcParams->slice_qp_delta = CODECHAL_ENCODE_AVC_MAX_SLICE_QP - (picParams->pic_init_qp_minus26 + 26);
}
else
{
slcParams->slice_qp_delta = slcParams->slice_qp_delta;
}
slcParams->redundant_pic_cnt = 0;
slcParams->sp_for_switch_flag = 0;
slcParams->slice_qs_delta = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ MOS_STATUS CodechalEncodeJpegState::ExecuteSliceLevel()
// set MFC_JPEG_HUFF_TABLE - Convert encoded huffman table to actual table for HW
// We need a different params struct for JPEG Encode Huffman table because JPEG decode huffman table has Bits and codes,
// whereas JPEG encode huffman table has huffman code lengths and values
MHW_VDBOX_ENCODE_HUFF_TABLE_PARAMS huffTableParams[JPEG_MAX_NUM_HUFF_TABLE_INDEX];
MHW_VDBOX_ENCODE_HUFF_TABLE_PARAMS huffTableParams[JPEG_MAX_NUM_HUFF_TABLE_INDEX] = {};
for (uint32_t i = 0; i < m_encodeParams.dwNumHuffBuffers; i++)
{
CodechalEncodeJpegHuffTable huffmanTable;// intermediate table for each AC/DC component which will be copied to huffTableParams
Expand Down
10 changes: 5 additions & 5 deletions media_driver/agnostic/common/codec/hal/codechal_encode_vp8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3735,11 +3735,11 @@ MOS_STATUS CodechalEncodeVp8::EncodeSliceLevelBrc(PMOS_COMMAND_BUFFER cmdBuffer)

MOS_STATUS CodechalEncodeVp8::ExecuteSliceLevel()
{
MOS_COMMAND_BUFFER cmdBuffer;
MOS_SYNC_PARAMS syncParams;
EncodeReadBrcPakStatsParams readBrcPakStatsParams;
uint32_t *data;
MOS_LOCK_PARAMS lockFlagsWriteOnly;
MOS_COMMAND_BUFFER cmdBuffer = {};
MOS_SYNC_PARAMS syncParams = {};
EncodeReadBrcPakStatsParams readBrcPakStatsParams = {};
uint32_t *data = nullptr;
MOS_LOCK_PARAMS lockFlagsWriteOnly = {};
MOS_STATUS status = MOS_STATUS_SUCCESS;

CODECHAL_ENCODE_FUNCTION_ENTER;
Expand Down
19 changes: 14 additions & 5 deletions media_driver/agnostic/common/codec/hal/codechal_vdenc_avc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4093,10 +4093,19 @@ MOS_STATUS CodechalVdencAvcState::SetSequenceStructs()
m_slidingWindowSize = MOS_MIN((uint32_t)(seqParams->FramesPer100Sec / 100), 60);
}

m_maxNumSlicesAllowed = CodecHalAvcEncode_GetMaxNumSlicesAllowed(
(CODEC_AVC_PROFILE_IDC)(seqParams->Profile),
(CODEC_AVC_LEVEL_IDC)(seqParams->Level),
seqParams->FramesPer100Sec);
if (seqParams->FramesPer100Sec)
{
m_maxNumSlicesAllowed = CodecHalAvcEncode_GetMaxNumSlicesAllowed(
(CODEC_AVC_PROFILE_IDC)(seqParams->Profile),
(CODEC_AVC_LEVEL_IDC)(seqParams->Level),
seqParams->FramesPer100Sec);
}
else
{
CODECHAL_ENCODE_ASSERTMESSAGE("FramesPer100Sec is zero, cannot get MaxNumSliceAllowed.");
eStatus = MOS_STATUS_INVALID_PARAMETER;
}


m_lookaheadDepth = seqParams->LookaheadDepth;
if (m_lookaheadDepth > 0)
Expand Down Expand Up @@ -5560,7 +5569,7 @@ MOS_STATUS CodechalVdencAvcState::SetConstDataHuCBrcUpdate()
// Set VDENC BRC constant buffer, data remains the same till BRC Init is called
if (m_brcInit)
{
MOS_LOCK_PARAMS lockFlagsWriteOnly;
MOS_LOCK_PARAMS lockFlagsWriteOnly = {};
for (uint8_t picType = 0; picType < CODECHAL_ENCODE_VDENC_BRC_CONST_BUFFER_NUM; picType++)
{
auto hucConstData = (uint8_t*)m_osInterface->pfnLockResource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ MOS_STATUS CodechalVdencHevcState::SetupMbQpStreamIn(PMOS_RESOURCE streamIn)
streamIn,
&LockFlags);
CODECHAL_ENCODE_CHK_NULL_RETURN(dataGfx);
MOS_SURFACE surfInfo;
MOS_SURFACE surfInfo = {};
CODECHAL_ENCODE_CHK_STATUS_RETURN(m_osInterface->pfnGetResourceInfo(m_osInterface, streamIn, &surfInfo));

uint32_t uiSize = surfInfo.dwSize;
Expand Down Expand Up @@ -861,7 +861,7 @@ MOS_STATUS CodechalVdencHevcState::SetupMbQpStreamIn(PMOS_RESOURCE streamIn)

MOS_SecureMemcpy(pInputData, surfInfo.dwSize, pInputDataGfx, surfInfo.dwSize);

MHW_VDBOX_VDENC_STREAMIN_STATE_PARAMS streaminDataParams;
MHW_VDBOX_VDENC_STREAMIN_STATE_PARAMS streaminDataParams = {};

for (uint32_t h = 0; h < streamInHeight; h++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1908,6 +1908,7 @@ MOS_STATUS CodechalEncHevcStateG12::GetStatusReport(

MOS_LOCK_PARAMS lockFlags;
MOS_ZeroMemory(&lockFlags, sizeof(MOS_LOCK_PARAMS));
CODECHAL_ENCODE_CHK_NULL_RETURN(m_osInterface);
HCPPakHWTileSizeRecord_G12 *tileStatusReport = (HCPPakHWTileSizeRecord_G12 *)m_osInterface->pfnLockResource(
m_osInterface,
&tileSizeStatusReport->sResource,
Expand Down Expand Up @@ -8141,11 +8142,16 @@ MOS_STATUS CodechalEncHevcStateG12::LoadPakCommandAndCuRecordFromFile()
m_pakOnlyDataFolder,
m_frameNum);

uint32_t sizePicState = CodecHalHevc_GetFileSize(pathOfPicState);
if (sizePicState == 0)
int32_t tmpSizePicState = CodecHalHevc_GetFileSize(pathOfPicState);
uint32_t sizePicState = 0;
if (tmpSizePicState <= 0)
{
return MOS_STATUS_INVALID_FILE_SIZE;
}
else
{
sizePicState = static_cast<uint32_t>(tmpSizePicState);
}

data = (uint8_t *)m_osInterface->pfnLockResource(
m_osInterface, &m_brcBuffers.resBrcImageStatesWriteBuffer[m_currRecycledBufIdx], &lockFlags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4025,6 +4025,7 @@ MOS_STATUS CodechalVdencVp9StateG12::ExecutePictureLevel()
// set HCP_PIPE_MODE_SELECT values
PMHW_VDBOX_PIPE_MODE_SELECT_PARAMS pipeModeSelectParams = nullptr;
pipeModeSelectParams = m_vdencInterface->CreateMhwVdboxPipeModeSelectParams();
CODECHAL_ENCODE_CHK_NULL_RETURN(pipeModeSelectParams);

SetHcpPipeModeSelectParams(*pipeModeSelectParams);
CODECHAL_ENCODE_CHK_STATUS_RETURN(m_hcpInterface->AddHcpPipeModeSelectCmd(&cmdBuffer, pipeModeSelectParams));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,7 @@ namespace encode

if (m_rcMode == RATECONTROL_CQL || m_rcMode == RATECONTROL_QVBR)
{
if (m_basicFeature->m_av1SeqParams->ICQQualityFactor < ENCODE_AV1_MIN_ICQ_QUALITYFACTOR ||
m_basicFeature->m_av1SeqParams->ICQQualityFactor > ENCODE_AV1_MAX_ICQ_QUALITYFACTOR)
if (m_basicFeature->m_av1SeqParams->ICQQualityFactor > ENCODE_AV1_MAX_ICQ_QUALITYFACTOR)
{
ENCODE_ASSERTMESSAGE("Invalid ICQ Quality Factor input (%d)\n", m_basicFeature->m_av1SeqParams->ICQQualityFactor);
eStatus = MOS_STATUS_INVALID_PARAMETER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,6 @@ MOS_STATUS AvcBasicFeature::SetSliceStructs()
{
slcParams->slice_qp_delta = CODECHAL_ENCODE_AVC_MAX_SLICE_QP - (picParams->pic_init_qp_minus26 + 26);
}
else
{
slcParams->slice_qp_delta = slcParams->slice_qp_delta;
}
slcParams->redundant_pic_cnt = 0;
slcParams->sp_for_switch_flag = 0;
slcParams->slice_qs_delta = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ namespace encode {

MOS_STATUS AvcVdencPkt::SetRowstoreCachingOffsets()
{
ENCODE_CHK_NULL_RETURN(m_mfxItf);
// Get row store cache offset as all the needed information is got here
if (m_mfxItf->IsRowStoreCachingSupported())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ MHW_SETPAR_DECL_SRC(VDENC_CMD2, HevcBasicFeature)
params.frameIdxL1Ref0 = 0;
}

ENCODE_CHK_COND_RETURN(m_SubPelMode < 0 || m_SubPelMode > 3, "Invalid subPelMode");
ENCODE_CHK_COND_RETURN(m_SubPelMode > 3, "Invalid subPelMode");
params.subPelMode = m_bEnableSubPelMode ? m_SubPelMode : 3;
auto settings = static_cast<HevcVdencFeatureSettings *>(m_constSettings);
ENCODE_CHK_NULL_RETURN(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ namespace encode
{
ENCODE_FUNC_CALL();

if (m_basicFeature == nullptr)
{
ENCODE_ASSERTMESSAGE("Null basic feature, unexpected!");
return false;
}
auto hevcSeqParams = dynamic_cast<HevcBasicFeature *>(m_basicFeature)->m_hevcSeqParams;
if (hevcSeqParams == nullptr)
{
Expand Down Expand Up @@ -136,10 +141,12 @@ namespace encode
ENCODE_CHK_NULL_RETURN(sliceInTile);
ENCODE_CHK_NULL_RETURN(lastSliceInTile);
ENCODE_CHK_NULL_RETURN(m_basicFeature);
auto tmpHevcBasicFeature = dynamic_cast<HevcBasicFeature *>(m_basicFeature);
ENCODE_CHK_NULL_RETURN(tmpHevcBasicFeature);

auto hevcPicParams = dynamic_cast<HevcBasicFeature *>(m_basicFeature)->m_hevcPicParams;
auto hevcSeqParams = dynamic_cast<HevcBasicFeature *>(m_basicFeature)->m_hevcSeqParams;
auto hevcSliceParams = dynamic_cast<HevcBasicFeature *>(m_basicFeature)->m_hevcSliceParams;
auto hevcPicParams = tmpHevcBasicFeature->m_hevcPicParams;
auto hevcSeqParams = tmpHevcBasicFeature->m_hevcSeqParams;
auto hevcSliceParams = tmpHevcBasicFeature->m_hevcSliceParams;
ENCODE_CHK_NULL_RETURN(hevcPicParams);
ENCODE_CHK_NULL_RETURN(hevcSeqParams);
ENCODE_CHK_NULL_RETURN(hevcSliceParams);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ namespace encode {
EncodeStatusRcs *encodeStatusRcs,
bool completed)
{
ENCODE_CHK_NULL_RETURN(statusReportData);
ENCODE_CHK_NULL_RETURN(encodeStatusRcs);

if (statusReportData->func != CODECHAL_ENCODE_ENC_ID &&
statusReportData->func != CODECHAL_ENCODE_FEI_ENC_ID &&
!completed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ MOS_STATUS Vp9VdencPkt::SendPrologCmds(MOS_COMMAND_BUFFER &cmdBuffer)
ENCODE_FUNC_CALL();

#ifdef _MMC_SUPPORTED
ENCODE_CHK_NULL_RETURN(m_mmcState);
ENCODE_CHK_STATUS_RETURN(m_mmcState->SendPrologCmd(&cmdBuffer, false));
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class Impl : public Itf, public mhw::Impl
{
_MHW_SETCMD_CALLBASE(VDENC_PIPE_BUF_ADDR_STATE);

MHW_RESOURCE_PARAMS resourceParams;
MHW_RESOURCE_PARAMS resourceParams = {};

if (params.surfaceRaw)
{
Expand Down

0 comments on commit 0738e88

Please sign in to comment.