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 cffeefe0200..80e3b856692 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_encode_avc.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_encode_avc.cpp @@ -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; } diff --git a/media_driver/agnostic/common/codec/hal/codechal_encode_avc_base.cpp b/media_driver/agnostic/common/codec/hal/codechal_encode_avc_base.cpp index 2a4b6647066..aa06efc20bc 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_encode_avc_base.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_encode_avc_base.cpp @@ -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; diff --git a/media_driver/agnostic/common/codec/hal/codechal_encode_jpeg.cpp b/media_driver/agnostic/common/codec/hal/codechal_encode_jpeg.cpp index 987ed9f5a1e..405af7994dc 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_encode_jpeg.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_encode_jpeg.cpp @@ -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 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 3f8664e8d36..43476c245cf 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_encode_vp8.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_encode_vp8.cpp @@ -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; 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 8e2dadabc0b..0fc71a33f5d 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_vdenc_avc.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_vdenc_avc.cpp @@ -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) @@ -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( 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 4f705e12daa..c052b9a3e71 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_vdenc_hevc.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_vdenc_hevc.cpp @@ -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; @@ -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++) { diff --git a/media_driver/agnostic/gen12/codec/hal/codechal_encode_hevc_g12.cpp b/media_driver/agnostic/gen12/codec/hal/codechal_encode_hevc_g12.cpp index e60558dc5e4..8e5d3294f0c 100644 --- a/media_driver/agnostic/gen12/codec/hal/codechal_encode_hevc_g12.cpp +++ b/media_driver/agnostic/gen12/codec/hal/codechal_encode_hevc_g12.cpp @@ -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, @@ -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(tmpSizePicState); + } data = (uint8_t *)m_osInterface->pfnLockResource( m_osInterface, &m_brcBuffers.resBrcImageStatesWriteBuffer[m_currRecycledBufIdx], &lockFlags); diff --git a/media_driver/agnostic/gen12/codec/hal/codechal_vdenc_vp9_g12.cpp b/media_driver/agnostic/gen12/codec/hal/codechal_vdenc_vp9_g12.cpp index bf47f7ae561..cce4f8d491d 100644 --- a/media_driver/agnostic/gen12/codec/hal/codechal_vdenc_vp9_g12.cpp +++ b/media_driver/agnostic/gen12/codec/hal/codechal_vdenc_vp9_g12.cpp @@ -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)); 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 f7621fa9469..6b6ecd45f6f 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 @@ -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; 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 32a6c2a5cd1..23a890b7626 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 @@ -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; diff --git a/media_softlet/agnostic/common/codec/hal/enc/avc/packet/encode_avc_vdenc_packet.cpp b/media_softlet/agnostic/common/codec/hal/enc/avc/packet/encode_avc_vdenc_packet.cpp index e3183d6e468..9b85d515181 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/avc/packet/encode_avc_vdenc_packet.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/avc/packet/encode_avc_vdenc_packet.cpp @@ -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()) { diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature.cpp b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature.cpp index 332161668bd..92ad37cc13d 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature.cpp @@ -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(m_constSettings); ENCODE_CHK_NULL_RETURN(settings); 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 ea7f501e09d..6a36bca86e5 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 @@ -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(m_basicFeature)->m_hevcSeqParams; if (hevcSeqParams == nullptr) { @@ -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(m_basicFeature); + ENCODE_CHK_NULL_RETURN(tmpHevcBasicFeature); - auto hevcPicParams = dynamic_cast(m_basicFeature)->m_hevcPicParams; - auto hevcSeqParams = dynamic_cast(m_basicFeature)->m_hevcSeqParams; - auto hevcSliceParams = dynamic_cast(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); diff --git a/media_softlet/agnostic/common/codec/hal/enc/shared/statusreport/encode_status_report.cpp b/media_softlet/agnostic/common/codec/hal/enc/shared/statusreport/encode_status_report.cpp index d30d4545b53..4467864b224 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/shared/statusreport/encode_status_report.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/shared/statusreport/encode_status_report.cpp @@ -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) diff --git a/media_softlet/agnostic/common/codec/hal/enc/vp9/packet/encode_vp9_vdenc_packet.cpp b/media_softlet/agnostic/common/codec/hal/enc/vp9/packet/encode_vp9_vdenc_packet.cpp index 004184063bd..0d977c90784 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/vp9/packet/encode_vp9_vdenc_packet.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/vp9/packet/encode_vp9_vdenc_packet.cpp @@ -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 diff --git a/media_softlet/agnostic/common/hw/vdbox/mhw_vdbox_vdenc_impl.h b/media_softlet/agnostic/common/hw/vdbox/mhw_vdbox_vdenc_impl.h index 85a5a41271c..e4262a1bd8e 100644 --- a/media_softlet/agnostic/common/hw/vdbox/mhw_vdbox_vdenc_impl.h +++ b/media_softlet/agnostic/common/hw/vdbox/mhw_vdbox_vdenc_impl.h @@ -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) {