From d1336b4d95a031bb1a067dffd6002333d0eff6f0 Mon Sep 17 00:00:00 2001 From: DaShi Date: Fri, 1 Sep 2023 12:11:10 +0800 Subject: [PATCH] [Encode] clean coverity issues clean coverity issues. --- .../common/codec/hal/codechal_encode_avc.cpp | 21 +++++++++---------- .../codec/hal/codechal_encode_hevc_base.cpp | 4 ++++ .../codec/hal/codechal_encode_mpeg2.cpp | 10 ++++++--- .../common/codec/hal/codechal_encode_vp8.cpp | 4 ++++ .../common/codec/hal/codechal_vdenc_avc.cpp | 19 +++++++---------- .../common/codec/hal/codechal_vdenc_hevc.cpp | 4 ++-- .../codec/hal/codechal_vdenc_vp9_base.cpp | 8 +++++-- .../common/hw/vdbox/mhw_vdbox_hcp_generic.h | 1 + .../codec/hal/codechal_vdenc_avc_g12.cpp | 4 ++++ .../gen12/hw/vdbox/mhw_vdbox_vdenc_g12_X.h | 4 ++++ .../features/decode_av1_reference_frames.cpp | 4 ++++ .../hal/enc/av1/features/encode_av1_brc.cpp | 4 ++++ .../av1/features/encode_av1_segmentation.cpp | 2 +- .../avc/features/encode_avc_basic_feature.cpp | 2 +- .../avc/features/encode_avc_vdenc_preenc.cpp | 8 ++++++- .../pipeline/encode_avc_reference_frames.cpp | 4 ++++ .../pipeline/encode_avc_reference_frames.h | 4 ++-- .../enc/hevc/features/encode_hevc_tile.cpp | 4 ++++ .../enc/jpeg/packet/encode_jpeg_packet.cpp | 4 ++++ .../hal/enc/vp9/features/encode_vp9_brc.h | 2 +- .../vp9/features/encode_vp9_segmentation.cpp | 4 ++++ 21 files changed, 85 insertions(+), 36 deletions(-) diff --git a/media_driver/agnostic/common/codec/hal/codechal_encode_avc.cpp b/media_driver/agnostic/common/codec/hal/codechal_encode_avc.cpp index 80e3b856692..dc948a39a44 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_encode_avc.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_encode_avc.cpp @@ -5544,19 +5544,14 @@ MOS_STATUS CodechalEncodeAvcEnc::SetSequenceStructs() dwSlidingWindowSize = MOS_MIN((uint32_t)(seqParams->FramesPer100Sec / 100), 60); } - if (seqParams->FramesPer100Sec) + if (seqParams->FramesPer100Sec == 0) { - 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 MOS_STATUS_INVALID_PARAMETER; } - + m_maxNumSlicesAllowed = CodecHalAvcEncode_GetMaxNumSlicesAllowed( + (CODEC_AVC_PROFILE_IDC)(seqParams->Profile), + (CODEC_AVC_LEVEL_IDC)(seqParams->Level), + seqParams->FramesPer100Sec); return eStatus; } @@ -5920,6 +5915,10 @@ MOS_STATUS CodechalEncodeAvcEnc::InitializePicture(const EncoderParams& params) m_madEnabled = params.bMADEnabled; m_avcSeqParams[spsidx] = (PCODEC_AVC_ENCODE_SEQUENCE_PARAMS)(params.pSeqParams); + if (ppsidx >= CODEC_AVC_MAX_PPS_NUM) + { + return MOS_STATUS_INVALID_PARAMETER; + } m_avcPicParams[ppsidx] = (PCODEC_AVC_ENCODE_PIC_PARAMS)(params.pPicParams); m_avcQCParams = (PCODECHAL_ENCODE_AVC_QUALITY_CTRL_PARAMS)params.pAVCQCParams; m_avcRoundingParams = (PCODECHAL_ENCODE_AVC_ROUNDING_PARAMS)params.pAVCRoundingParams; diff --git a/media_driver/agnostic/common/codec/hal/codechal_encode_hevc_base.cpp b/media_driver/agnostic/common/codec/hal/codechal_encode_hevc_base.cpp index 6acf2f34ea3..8f61c09b718 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_encode_hevc_base.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_encode_hevc_base.cpp @@ -998,6 +998,10 @@ MOS_STATUS CodechalEncodeHevcBase::SetPictureStructs() } for (uint32_t i = 0; i <= numRef; i++) { + if (i >= CODEC_MAX_NUM_REF_FRAME_HEVC) + { + return MOS_STATUS_INVALID_PARAMETER; + } CODEC_PICTURE refPic = slcParams->RefPicList[ll][i]; if (!CodecHal_PictureIsInvalid(refPic) && !CodecHal_PictureIsInvalid(m_hevcPicParams->RefFrameList[refPic.FrameIdx])) diff --git a/media_driver/agnostic/common/codec/hal/codechal_encode_mpeg2.cpp b/media_driver/agnostic/common/codec/hal/codechal_encode_mpeg2.cpp index 1211a6373b0..a9fd8854646 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_encode_mpeg2.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_encode_mpeg2.cpp @@ -2715,9 +2715,13 @@ MOS_STATUS CodechalEncodeMpeg2::InitializePicture(const EncoderParams& params) CODECHAL_ENCODE_CHK_STATUS_RETURN(DumpSliceParams( m_sliceParams));) - CODECHAL_ENCODE_CHK_STATUS_RETURN(SetStatusReportParams( - m_refList[m_currReconstructedPic.FrameIdx])); - + if (m_currReconstructedPic.FrameIdx >= CODECHAL_NUM_UNCOMPRESSED_SURFACE_MPEG2) + { + return MOS_STATUS_INVALID_PARAMETER; + } + CODECHAL_ENCODE_CHK_STATUS_RETURN(SetStatusReportParams( + m_refList[m_currReconstructedPic.FrameIdx])); + m_bitstreamUpperBound = m_encodeParams.dwBitstreamSize; return eStatus; diff --git a/media_driver/agnostic/common/codec/hal/codechal_encode_vp8.cpp b/media_driver/agnostic/common/codec/hal/codechal_encode_vp8.cpp index 43476c245cf..3d06af3af5a 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_encode_vp8.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_encode_vp8.cpp @@ -1287,6 +1287,10 @@ MOS_STATUS CodechalEncodeVp8::SetPictureStructs() else { m_averagePFrameQp = averageQp; + if (m_vp8SeqParams->GopPicSize == 0) + { + return MOS_STATUS_INVALID_PARAMETER; + } m_pFramePositionInGop = m_vp8SeqParams->RateControlMethod == RATECONTROL_CQP ? 0 : (m_storeData - 1) % m_vp8SeqParams->GopPicSize; } diff --git a/media_driver/agnostic/common/codec/hal/codechal_vdenc_avc.cpp b/media_driver/agnostic/common/codec/hal/codechal_vdenc_avc.cpp index 0fc71a33f5d..c43f6f7cfb3 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_vdenc_avc.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_vdenc_avc.cpp @@ -4093,20 +4093,15 @@ MOS_STATUS CodechalVdencAvcState::SetSequenceStructs() m_slidingWindowSize = MOS_MIN((uint32_t)(seqParams->FramesPer100Sec / 100), 60); } - if (seqParams->FramesPer100Sec) + if (seqParams->FramesPer100Sec == 0) { - 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 MOS_STATUS_INVALID_PARAMETER; } + m_maxNumSlicesAllowed = CodecHalAvcEncode_GetMaxNumSlicesAllowed( + (CODEC_AVC_PROFILE_IDC)(seqParams->Profile), + (CODEC_AVC_LEVEL_IDC)(seqParams->Level), + seqParams->FramesPer100Sec); - m_lookaheadDepth = seqParams->LookaheadDepth; if (m_lookaheadDepth > 0) { @@ -4274,7 +4269,7 @@ MOS_STATUS CodechalVdencAvcState::SetPictureStructs() if ((m_lookaheadDepth > 0) && (m_prevTargetFrameSize > 0)) { int64_t targetBufferFulness = (int64_t)m_targetBufferFulness; - targetBufferFulness += (int64_t)(m_prevTargetFrameSize << 3) - (int64_t)m_averageFrameSize; + targetBufferFulness += (((int64_t)m_prevTargetFrameSize) << 3) - (int64_t)m_averageFrameSize; m_targetBufferFulness = targetBufferFulness < 0 ? 0 : (targetBufferFulness > 0xFFFFFFFF ? 0xFFFFFFFF : (uint32_t)targetBufferFulness); } diff --git a/media_driver/agnostic/common/codec/hal/codechal_vdenc_hevc.cpp b/media_driver/agnostic/common/codec/hal/codechal_vdenc_hevc.cpp index c052b9a3e71..8c926ce2332 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_vdenc_hevc.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_vdenc_hevc.cpp @@ -2930,7 +2930,7 @@ MOS_STATUS CodechalVdencHevcState::SetPictureStructs() if ((m_lookaheadDepth > 0) && (m_prevTargetFrameSize > 0)) { int64_t targetBufferFulness = (int64_t)m_targetBufferFulness; - targetBufferFulness += (int64_t)(m_prevTargetFrameSize << 3) - (int64_t)m_averageFrameSize; + targetBufferFulness += (((int64_t)m_prevTargetFrameSize) << 3) - (int64_t)m_averageFrameSize; m_targetBufferFulness = targetBufferFulness < 0 ? 0 : (targetBufferFulness > 0xFFFFFFFF ? 0xFFFFFFFF : (uint32_t)targetBufferFulness); } @@ -3230,7 +3230,7 @@ MOS_STATUS CodechalVdencHevcState::GetStatusReport( if (m_prevTargetFrameSize > 0) { int64_t encTargetBufferFulness = (int64_t)m_targetBufferFulness; - encTargetBufferFulness += (int64_t)(m_prevTargetFrameSize << 3) - (int64_t)m_averageFrameSize; + encTargetBufferFulness += (((int64_t)m_prevTargetFrameSize) << 3) - (int64_t)m_averageFrameSize; m_targetBufferFulness = encTargetBufferFulness < 0 ? 0 : (encTargetBufferFulness > 0xFFFFFFFF ? 0xFFFFFFFF : (uint32_t)encTargetBufferFulness); int32_t deltaBits = (int32_t)((int64_t)(encodeStatus->lookaheadStatus.targetBufferFulness) + m_bufferFulnessError - (int64_t)(m_targetBufferFulness)); diff --git a/media_driver/agnostic/common/codec/hal/codechal_vdenc_vp9_base.cpp b/media_driver/agnostic/common/codec/hal/codechal_vdenc_vp9_base.cpp index 293e426a2b5..7fc87b62c90 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_vdenc_vp9_base.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_vdenc_vp9_base.cpp @@ -5992,8 +5992,12 @@ MOS_STATUS CodechalVdencVp9State::InitializePicture(const EncoderParams& params) m_scalingEnabled = m_hmeSupported; m_useRawForRef = m_vp9SeqParams->SeqFlags.fields.bUseRawReconRef; - CODECHAL_ENCODE_CHK_STATUS_RETURN(SetStatusReportParams(m_refList[m_currReconstructedPic.FrameIdx])); - + if (m_currReconstructedPic.FrameIdx >= m_numUncompressedSurface) + { + return MOS_STATUS_INVALID_PARAMETER; + } + CODECHAL_ENCODE_CHK_STATUS_RETURN(SetStatusReportParams(m_refList[m_currReconstructedPic.FrameIdx])); + CODECHAL_DEBUG_TOOL( m_debugInterface->m_currPic = m_vp9PicParams->CurrOriginalPic; m_debugInterface->m_bufferDumpFrameNum = m_storeData; diff --git a/media_driver/agnostic/common/hw/vdbox/mhw_vdbox_hcp_generic.h b/media_driver/agnostic/common/hw/vdbox/mhw_vdbox_hcp_generic.h index bfb930f7f19..a81854eb975 100644 --- a/media_driver/agnostic/common/hw/vdbox/mhw_vdbox_hcp_generic.h +++ b/media_driver/agnostic/common/hw/vdbox/mhw_vdbox_hcp_generic.h @@ -762,6 +762,7 @@ class MhwVdboxHcpInterfaceGeneric : public MhwVdboxHcpInterface MHW_FUNCTION_ENTER; + MHW_MI_CHK_NULL(cmdBuffer); MHW_MI_CHK_NULL(m_osInterface); MHW_MI_CHK_NULL(hevcSliceState); diff --git a/media_driver/agnostic/gen12/codec/hal/codechal_vdenc_avc_g12.cpp b/media_driver/agnostic/gen12/codec/hal/codechal_vdenc_avc_g12.cpp index c03c3116326..54bdd596b11 100644 --- a/media_driver/agnostic/gen12/codec/hal/codechal_vdenc_avc_g12.cpp +++ b/media_driver/agnostic/gen12/codec/hal/codechal_vdenc_avc_g12.cpp @@ -772,6 +772,10 @@ MOS_STATUS CodechalVdencAvcStateG12::SetPictureStructs() CODECHAL_ENCODE_ASSERTMESSAGE("ROI/DirtyROI disabled for TCBRC\n"); m_avcPicParam->NumDirtyROI = m_avcPicParam->NumROI = 0; } + if (m_avcSeqParam->FramesPer100Sec == 0) + { + return MOS_STATUS_INVALID_PARAMETER; + } m_avcPicParam->TargetFrameSize = uint32_t(m_avcSeqParam->TargetBitRate * (100. / 8) / m_avcSeqParam->FramesPer100Sec); } diff --git a/media_driver/agnostic/gen12/hw/vdbox/mhw_vdbox_vdenc_g12_X.h b/media_driver/agnostic/gen12/hw/vdbox/mhw_vdbox_vdenc_g12_X.h index f492ed07536..0311ea32788 100644 --- a/media_driver/agnostic/gen12/hw/vdbox/mhw_vdbox_vdenc_g12_X.h +++ b/media_driver/agnostic/gen12/hw/vdbox/mhw_vdbox_vdenc_g12_X.h @@ -2522,6 +2522,10 @@ class MhwVdboxVdencInterfaceG12X : public MhwVdboxVdencInterfaceG12RefPicList[1][0].FrameIdx; diffPoc = ((refFrameId >= CODEC_MAX_NUM_REF_FRAME_HEVC) ? 0x0 : hevcPicParams->RefFramePOCList[refFrameId]) - hevcPicParams->CurrPicOrderCnt; cmd.DW3.PocNumberForRefid0InL1 = CodecHal_Clip3(-16, 16, -diffPoc); + if (refFrameId >= CODEC_MAX_NUM_REF_FRAME_HEVC) + { + return MOS_STATUS_INVALID_PARAMETER; + } cmd.DW2.LongTermReferenceFlagsL1 = CodecHal_PictureIsLongTermRef(hevcPicParams->RefFrameList[refFrameId]); cmd.DW3.PocNumberForRefid1InL1 = cmd.DW3.PocNumberForRefid1InL0; diff --git a/media_softlet/agnostic/common/codec/hal/dec/av1/features/decode_av1_reference_frames.cpp b/media_softlet/agnostic/common/codec/hal/dec/av1/features/decode_av1_reference_frames.cpp index eb117814eec..e5fac4d5169 100644 --- a/media_softlet/agnostic/common/codec/hal/dec/av1/features/decode_av1_reference_frames.cpp +++ b/media_softlet/agnostic/common/codec/hal/dec/av1/features/decode_av1_reference_frames.cpp @@ -216,6 +216,10 @@ namespace decode DECODE_FUNC_CALL(); // override internal reference list with anchor_frame_list passed from APP + if (picParams.m_anchorFrameNum > CODECHAL_MAX_DPB_NUM_LST_AV1) + { + return MOS_STATUS_INVALID_PARAMETER; + } for (auto i = 0; i < picParams.m_anchorFrameNum; i++) { DECODE_CHK_STATUS(m_allocator->GetSurfaceInfo(&picParams.m_anchorFrameList[i])); diff --git a/media_softlet/agnostic/common/codec/hal/enc/av1/features/encode_av1_brc.cpp b/media_softlet/agnostic/common/codec/hal/enc/av1/features/encode_av1_brc.cpp index 6b6ecd45f6f..efe487885f6 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/av1/features/encode_av1_brc.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/av1/features/encode_av1_brc.cpp @@ -528,6 +528,10 @@ namespace encode MEMCPY_CONST(INIT_InstRateThreshP0, instRateThresholdP); #undef MEMCPY_CONST + if (dmem->INIT_FrameRateM == 0) + { + return MOS_STATUS_INVALID_PARAMETER; + } double inputBitsPerFrame = ((double)dmem->INIT_MaxRate * (double)dmem->INIT_FrameRateD) / (double)dmem->INIT_FrameRateM; double bpsRatio = inputBitsPerFrame / ((double)dmem->INIT_BufSize / brcSettings.devStdFPS); bpsRatio = MOS_CLAMP_MIN_MAX(bpsRatio, brcSettings.bpsRatioLow, brcSettings.bpsRatioHigh); diff --git a/media_softlet/agnostic/common/codec/hal/enc/av1/features/encode_av1_segmentation.cpp b/media_softlet/agnostic/common/codec/hal/enc/av1/features/encode_av1_segmentation.cpp index 9b40f8e9155..a0d528ad71b 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/av1/features/encode_av1_segmentation.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/av1/features/encode_av1_segmentation.cpp @@ -310,7 +310,7 @@ namespace encode const uint32_t segMapPitch = MOS_ALIGN_CEIL(CurFrameWidth, m_segmentMapBlockSize) / m_segmentMapBlockSize; const uint32_t segMapHeight = MOS_ALIGN_CEIL(CurFrameHeight, m_segmentMapBlockSize) / m_segmentMapBlockSize; - const uint64_t minSegmentMapDataSize = segMapPitch * segMapHeight; // 1 byte per segment Id + const uint64_t minSegmentMapDataSize = (uint64_t)segMapPitch * (uint64_t)segMapHeight; // 1 byte per segment Id if (m_segmentMapDataSize < minSegmentMapDataSize) { diff --git a/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_basic_feature.cpp b/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_basic_feature.cpp index 23a890b7626..997b50da3d0 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_basic_feature.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_basic_feature.cpp @@ -440,7 +440,7 @@ MOS_STATUS AvcBasicFeature::SetPictureStructs() if ((m_lookaheadDepth > 0) && (m_prevTargetFrameSize > 0)) { int64_t targetBufferFulness = (int64_t)m_targetBufferFulness; - targetBufferFulness += (int64_t)(m_prevTargetFrameSize << 3) - (int64_t)m_averageFrameSize; + targetBufferFulness += (((int64_t)m_prevTargetFrameSize) << 3) - (int64_t)m_averageFrameSize; m_targetBufferFulness = (uint32_t)MOS_CLAMP_MIN_MAX(targetBufferFulness, 0, 0xFFFFFFFF); } m_prevTargetFrameSize = picParams->TargetFrameSize; diff --git a/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_vdenc_preenc.cpp b/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_vdenc_preenc.cpp index caab9e309c2..9f00568ff24 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_vdenc_preenc.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_vdenc_preenc.cpp @@ -151,7 +151,13 @@ MOS_STATUS AvcVdencPreEnc::PreparePreEncConfig(void *params) m_preEncConfig.GopRefDist = (uint8_t)m_avcSeqParams->GopRefDist; uint8_t depth = 0; - uint32_t poc = m_preEncConfig.CurrPicOrderCnt % m_preEncConfig.GopRefDist; + uint32_t poc = 0; + if (m_preEncConfig.GopRefDist = 0) + { + return MOS_STATUS_INVALID_PARAMETER; + } + poc = m_preEncConfig.CurrPicOrderCnt % m_preEncConfig.GopRefDist; + if (poc == 0) { diff --git a/media_softlet/agnostic/common/codec/hal/enc/avc/pipeline/encode_avc_reference_frames.cpp b/media_softlet/agnostic/common/codec/hal/enc/avc/pipeline/encode_avc_reference_frames.cpp index eb30bc49156..31899f60755 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/avc/pipeline/encode_avc_reference_frames.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/avc/pipeline/encode_avc_reference_frames.cpp @@ -563,6 +563,10 @@ MHW_SETPAR_DECL_SRC(VDENC_AVC_IMG_STATE, AvcReferenceFrames) { auto id = slcParams->RefPicList[LIST_1][0].FrameIdx; params.longtermReferenceFrameBwdRef0Indicator = (id < CODEC_AVC_MAX_NUM_REF_FRAME) && CodecHal_PictureIsLongTermRef(picParams->RefFrameList[id]); + if (id >= CODEC_AVC_MAX_NUM_REF_FRAME) + { + return MOS_STATUS_INVALID_PARAMETER; + } id = m_picIdx[id].ucPicIdx; params.bwdRefIdx0ReferencePicture = m_refList[id]->ucFrameId; refPoc[1][0] = (uint8_t)m_refList[id]->iFieldOrderCnt[0]; diff --git a/media_softlet/agnostic/common/codec/hal/enc/avc/pipeline/encode_avc_reference_frames.h b/media_softlet/agnostic/common/codec/hal/enc/avc/pipeline/encode_avc_reference_frames.h index ea4b09c8348..c9adab15724 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/avc/pipeline/encode_avc_reference_frames.h +++ b/media_softlet/agnostic/common/codec/hal/enc/avc/pipeline/encode_avc_reference_frames.h @@ -175,11 +175,11 @@ class AvcReferenceFrames : public mhw::vdbox::vdenc::Itf::ParSetting, public mhw uint16_t m_pictureCodingType = 0; //!< I, P, or B frame CODEC_PIC_ID m_picIdx[CODEC_AVC_MAX_NUM_REF_FRAME] = {}; //!< Picture index PCODEC_REF_LIST m_refList[CODEC_AVC_NUM_UNCOMPRESSED_SURFACE] = {}; //!< Pointer to reference pictures - CODEC_AVC_FRAME_STORE_ID m_frameStoreID[CODEC_AVC_MAX_NUM_REF_FRAME]; //!< Refer to CODEC_AVC_FRAME_STORE_ID + CODEC_AVC_FRAME_STORE_ID m_frameStoreID[CODEC_AVC_MAX_NUM_REF_FRAME] = {}; //!< Refer to CODEC_AVC_FRAME_STORE_ID PCODEC_REF_LIST m_currRefList = nullptr; //!< Current reference list // B-frame - uint32_t m_distScaleFactorList0[CODEC_AVC_MAX_NUM_REF_FRAME * 2]; //!< the DistScaleFactor used to derive temporal direct motion vector + uint32_t m_distScaleFactorList0[CODEC_AVC_MAX_NUM_REF_FRAME * 2] = {}; //!< the DistScaleFactor used to derive temporal direct motion vector uint32_t m_biWeight = 0; //!< Bidirectional Weight AvcBasicFeature *m_basicFeature = nullptr; //!< AVC paramter diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_tile.cpp b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_tile.cpp index 6a36bca86e5..e3a8a37ff29 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_tile.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_tile.cpp @@ -436,6 +436,10 @@ namespace encode if (hevcSeqParams->RateControlMethod == RATECONTROL_CBR) { // Assume max padding num < target frame size derived from target bit rate and frame rate + if (hevcSeqParams->FrameRate.Denominator == 0) + { + return MOS_STATUS_INVALID_PARAMETER; + } uint32_t actualFrameRate = hevcSeqParams->FrameRate.Numerator / hevcSeqParams->FrameRate.Denominator; uint64_t reservedPart = (uint64_t)hevcSeqParams->TargetBitRate / 8 / (uint64_t)actualFrameRate * 1024; diff --git a/media_softlet/agnostic/common/codec/hal/enc/jpeg/packet/encode_jpeg_packet.cpp b/media_softlet/agnostic/common/codec/hal/enc/jpeg/packet/encode_jpeg_packet.cpp index ac4fa6a2a68..681e86c8d4b 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/jpeg/packet/encode_jpeg_packet.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/jpeg/packet/encode_jpeg_packet.cpp @@ -690,6 +690,10 @@ namespace encode { m_jpegHuffmanTable->m_huffmanData[i + 2].m_tableClass = m_jpegHuffmanTable->m_huffmanData[i].m_tableClass; m_jpegHuffmanTable->m_huffmanData[i + 2].m_tableID = m_jpegHuffmanTable->m_huffmanData[i].m_tableID; + if ((i + 2) >= JPEG_NUM_ENCODE_HUFF_BUFF) + { + return MOS_STATUS_INVALID_PARAMETER; + } ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy(&m_jpegHuffmanTable->m_huffmanData[i + 2].m_bits[0], sizeof(uint8_t) * JPEG_NUM_HUFF_TABLE_AC_BITS, &m_jpegHuffmanTable->m_huffmanData[i].m_bits[0], diff --git a/media_softlet/agnostic/common/codec/hal/enc/vp9/features/encode_vp9_brc.h b/media_softlet/agnostic/common/codec/hal/enc/vp9/features/encode_vp9_brc.h index e4b16d21a8e..d1aa0b89f4f 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/vp9/features/encode_vp9_brc.h +++ b/media_softlet/agnostic/common/codec/hal/enc/vp9/features/encode_vp9_brc.h @@ -399,7 +399,7 @@ class Vp9EncodeBrc : public MediaFeature, public mhw::vdbox::huc::Itf::ParSettin bool m_vdencBrcEnabled = false; //!< Vdenc bitrate control enabled flag // BRC Resources/Buffers - HucBrcBuffers m_brcBuffers; + HucBrcBuffers m_brcBuffers = {}; uint32_t m_brcHistoryBufferSize = 0; //!< Bitrate control history buffer size uint32_t m_vdencBrcStatsBufferSize = 0; //!< VDENC bitrate control buffer size MOS_RESOURCE m_resFrameStatStreamOutBuffer = {0}; //!< Frame statistics stream out buffer diff --git a/media_softlet/agnostic/common/codec/hal/enc/vp9/features/encode_vp9_segmentation.cpp b/media_softlet/agnostic/common/codec/hal/enc/vp9/features/encode_vp9_segmentation.cpp index ab103f5139e..fddce094588 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/vp9/features/encode_vp9_segmentation.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/vp9/features/encode_vp9_segmentation.cpp @@ -105,6 +105,10 @@ MOS_STATUS Vp9Segmentation::Update(void *params) } // Need to index properly when more than one temporal layer is present ENCODE_ASSERT(vp9SeqParams->FrameRate[0].uiDenominator > 0); + if (vp9SeqParams->FrameRate[0].uiDenominator == 0) + { + return MOS_STATUS_INVALID_PARAMETER; + } uint32_t frameRate = vp9SeqParams->FrameRate[0].uiNumerator / vp9SeqParams->FrameRate[0].uiDenominator; if (!m_mbBrcEnabled)