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 Sep 8, 2023
1 parent 1fafbb6 commit 578c936
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,7 @@ MOS_STATUS CodechalEncodeMpeg2::SetPictureStructs()

uint8_t currRefIdx = m_picParams->m_currReconstructedPic.FrameIdx;

ENCODE_CHK_COND_RETURN(currRefIdx >= CODECHAL_NUM_UNCOMPRESSED_SURFACE_MPEG2, "currRefIdx cannot bigger than 128.");
m_refList[currRefIdx]->sRefRawBuffer = m_rawSurface;
m_refList[currRefIdx]->sRefReconBuffer = m_reconSurface;
m_refList[currRefIdx]->resBitstreamBuffer = m_resBitstreamBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ MOS_STATUS CodechalKernelBase::CreateKernelState(
CODECHAL_ENCODE_CHK_NULL_RETURN((*kernelState) = MOS_New(MHW_KERNEL_STATE));
m_kernelStatePool.insert(std::make_pair(kernelIndex, *kernelState));

CODECHAL_KERNEL_HEADER kernelHeader;
uint32_t kernelSize;
CODECHAL_KERNEL_HEADER kernelHeader = {};
uint32_t kernelSize = 0;
CODECHAL_ENCODE_CHK_STATUS_RETURN(m_callback(m_kernelBinary, operation, kernelOffset, &kernelHeader, &kernelSize));

(*kernelState)->KernelParams.iBTCount = GetBTCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CodechalKernelHme::~CodechalKernelHme()

MOS_STATUS CodechalKernelHme::AllocateResources()
{
MOS_ALLOC_GFXRES_PARAMS allocParamsForBuffer2D;
MOS_ALLOC_GFXRES_PARAMS allocParamsForBuffer2D = {};

MEDIA_WA_TABLE* waTable = m_osInterface->pfnGetWaTable(m_osInterface);
uint32_t memType = (MEDIA_IS_WA(waTable, WaForceAllocateLML4)) ? MOS_MEMPOOL_DEVICEMEMORY : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4855,6 +4855,7 @@ MOS_STATUS CodechalVdencAvcState::SetupDirtyROI(PMOS_RESOURCE vdencStreamIn)
//Dirty ROI feature just for the previous frame reference
auto ppsIdx = m_avcSliceParams->pic_parameter_set_id;
auto refPicListIdx = m_avcSliceParams[ppsIdx].RefPicList[0][0].FrameIdx;
ENCODE_CHK_COND_RETURN(refPicListIdx >= CODEC_AVC_MAX_NUM_REF_FRAME, "refPicListIdx cannot bigger than 16.");
auto refFrameListIdx = m_avcPicParam[ppsIdx].RefFrameList[refPicListIdx].FrameIdx;
if (m_prevReconFrameIdx != refFrameListIdx)
{
Expand Down Expand Up @@ -5577,7 +5578,7 @@ MOS_STATUS CodechalVdencAvcState::SetConstDataHuCBrcUpdate()

if (m_vdencStaticFrame)
{
MOS_LOCK_PARAMS lockFlagsWriteOnly;
MOS_LOCK_PARAMS lockFlagsWriteOnly = {};
auto hucConstData = (PAVCVdencBRCCostantData)m_osInterface->pfnLockResource(
m_osInterface, &m_resVdencBrcConstDataBuffer[GetCurrConstDataBufIdx()], &lockFlagsWriteOnly);
CODECHAL_ENCODE_CHK_NULL_RETURN(hucConstData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5943,6 +5943,7 @@ MOS_STATUS CodechalVdencVp9State::InitializePicture(const EncoderParams& params)
// Need to index properly when more than one temporal layer is present.
CODECHAL_ENCODE_ASSERT(m_vp9SeqParams->FrameRate[0].uiDenominator > 0);

CODECHAL_ENCODE_CHK_COND_RETURN(m_vp9SeqParams->FrameRate[0].uiDenominator == 0, "uiDenominator cannot be zero.");
uint32_t frameRate = m_vp9SeqParams->FrameRate[0].uiNumerator / m_vp9SeqParams->FrameRate[0].uiDenominator;
m_vp9SegmentParams = (PCODEC_VP9_ENCODE_SEGMENT_PARAMS)(params.pSegmentParams);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ MOS_STATUS AvcVdencPreEnc::PreparePreEncConfig(void *params)
}
m_preEncConfig.HierarchLevelPlus1 = depth + 1;

ENCODE_CHK_COND_RETURN(m_avcSliceParams->slice_type >= 10, "slice_type cannot bigger than 10.");
m_preEncConfig.SliceType = (uint8_t)HevcSliceType[m_avcSliceParams->slice_type];
m_preEncConfig.CurrOriginalPic = m_avcPicParams->CurrOriginalPic;
m_preEncConfig.UsedAsRef = m_avcPicParams->RefPicFlag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ namespace encode
ENCODE_ASSERTMESSAGE("Null basic feature, unexpected!");
return false;
}
auto hevcSeqParams = dynamic_cast<HevcBasicFeature *>(m_basicFeature)->m_hevcSeqParams;
auto hevcBasicFeature = dynamic_cast<HevcBasicFeature *>(m_basicFeature);
if (hevcBasicFeature == nullptr)
{
ENCODE_ASSERTMESSAGE("Null hevc basic feature, unexpected!");
return false;
}
auto hevcSeqParams = hevcBasicFeature->m_hevcSeqParams;
if (hevcSeqParams == nullptr)
{
ENCODE_ASSERTMESSAGE("Null seq parameters, unexpected!");
Expand Down Expand Up @@ -724,11 +730,13 @@ namespace encode

MHW_SETPAR_DECL_SRC(VDENC_WALKER_STATE, HevcEncodeTile)
{
auto picParams = dynamic_cast<HevcBasicFeature *>(m_basicFeature)->m_hevcPicParams;
auto hevcBasicFeature = dynamic_cast<HevcBasicFeature *>(m_basicFeature);
ENCODE_CHK_NULL_RETURN(hevcBasicFeature);
auto picParams = hevcBasicFeature->m_hevcPicParams;
ENCODE_CHK_NULL_RETURN(picParams);
auto seqParams = dynamic_cast<HevcBasicFeature *>(m_basicFeature)->m_hevcSeqParams;
auto seqParams = hevcBasicFeature->m_hevcSeqParams;
ENCODE_CHK_NULL_RETURN(seqParams);
auto t_sliceParams = dynamic_cast<HevcBasicFeature *>(m_basicFeature)->m_hevcSliceParams;
auto t_sliceParams = hevcBasicFeature->m_hevcSliceParams;
ENCODE_CHK_NULL_RETURN(t_sliceParams);
CODEC_HEVC_ENCODE_SLICE_PARAMS *sliceParams = (CODEC_HEVC_ENCODE_SLICE_PARAMS *)&t_sliceParams[dynamic_cast<HevcBasicFeature *>(m_basicFeature)->m_curNumSlices];

Expand Down Expand Up @@ -876,11 +884,13 @@ namespace encode

MHW_SETPAR_DECL_SRC(VDENC_HEVC_VP9_TILE_SLICE_STATE, HevcEncodeTile)
{
auto picParams = dynamic_cast<HevcBasicFeature *>(m_basicFeature)->m_hevcPicParams;
auto hevcBasicFeature = dynamic_cast<HevcBasicFeature *>(m_basicFeature);
ENCODE_CHK_NULL_RETURN(hevcBasicFeature);
auto picParams = hevcBasicFeature->m_hevcPicParams;
ENCODE_CHK_NULL_RETURN(picParams);
auto seqParams = dynamic_cast<HevcBasicFeature *>(m_basicFeature)->m_hevcSeqParams;
auto seqParams = hevcBasicFeature->m_hevcSeqParams;
ENCODE_CHK_NULL_RETURN(seqParams);
auto sliceParams = dynamic_cast<HevcBasicFeature *>(m_basicFeature)->m_hevcSliceParams;
auto sliceParams = hevcBasicFeature->m_hevcSliceParams;
ENCODE_CHK_NULL_RETURN(sliceParams);

uint32_t ctbSize = 1 << (seqParams->log2_max_coding_block_size_minus3 + 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,9 @@ MHW_SETPAR_DECL_SRC(VDENC_HEVC_VP9_TILE_SLICE_STATE, Vp9EncodeTile)
{
ENCODE_FUNC_CALL();

auto picParams = dynamic_cast<Vp9BasicFeature *>(m_basicFeature)->m_vp9PicParams;
auto vp9BasicFeature = dynamic_cast<Vp9BasicFeature *>(m_basicFeature);
ENCODE_CHK_NULL_RETURN(vp9BasicFeature);
auto picParams = vp9BasicFeature->m_vp9PicParams;
ENCODE_CHK_NULL_RETURN(picParams);
auto tileCodingParams = m_curTileCodingParams;
params.ctbSize = CODEC_VP9_SUPER_BLOCK_WIDTH;
Expand Down Expand Up @@ -703,7 +705,9 @@ MHW_SETPAR_DECL_SRC(VDENC_WALKER_STATE, Vp9EncodeTile)
{
ENCODE_FUNC_CALL();

auto picParams = dynamic_cast<Vp9BasicFeature *>(m_basicFeature)->m_vp9PicParams;
auto vp9BasicFeature = dynamic_cast<Vp9BasicFeature *>(m_basicFeature);
ENCODE_CHK_NULL_RETURN(vp9BasicFeature);
auto picParams = vp9BasicFeature->m_vp9PicParams;
ENCODE_CHK_NULL_RETURN(picParams);
auto tileCodingParams = m_curTileCodingParams;

Expand Down

0 comments on commit 578c936

Please sign in to comment.