Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add free logic of picParams->pDeltaQp for avoiding memory leak. #619

Merged
merged 1 commit into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions media_driver/linux/common/codec/ddi/media_ddi_encode_avc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2066,3 +2066,15 @@ uint32_t DdiEncodeAvc::getQMatrixBufferSize()
{
return sizeof(VAIQMatrixBufferH264);
}

void DdiEncodeAvc::ClearPicParams()
{
uint8_t ppsIdx = ((PCODEC_AVC_ENCODE_SLICE_PARAMS)(m_encodeCtx->pSliceParams))->pic_parameter_set_id;
PCODEC_AVC_ENCODE_PIC_PARAMS picParams = (PCODEC_AVC_ENCODE_PIC_PARAMS)m_encodeCtx->pPicParams + ppsIdx;

if (picParams != nullptr && picParams->pDeltaQp != nullptr)
{
MOS_FreeMemory(picParams->pDeltaQp);
picParams->pDeltaQp = nullptr;
}
}
2 changes: 2 additions & 0 deletions media_driver/linux/common/codec/ddi/media_ddi_encode_avc.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ class DdiEncodeAvc : public DdiEncodeBase
DDI_MEDIA_CONTEXT *mediaCtx,
void *ptr);

virtual void ClearPicParams() override;

//!
//! \brief Convert slice struct from VA to codechal
//! \details Convert slice struct from VA to codechal
Expand Down
5 changes: 5 additions & 0 deletions media_driver/linux/common/codec/ddi/media_ddi_encode_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ VAStatus DdiEncodeBase::EndPicture(
DDI_CHK_NULL(mediaCtx, "Null mediaCtx", VA_STATUS_ERROR_INVALID_CONTEXT);

VAStatus status = EncodeInCodecHal(m_encodeCtx->dwNumSlices);
ClearPicParams();
if (VA_STATUS_SUCCESS != status)
{
DDI_ASSERTMESSAGE("DDI:DdiEncode_EncodeInCodecHal return failure.");
Expand Down Expand Up @@ -1354,3 +1355,7 @@ uint32_t DdiEncodeBase::getQMatrixBufferSize()
{
return 0xffffffff;
}

void DdiEncodeBase::ClearPicParams()
{
}
8 changes: 8 additions & 0 deletions media_driver/linux/common/codec/ddi/media_ddi_encode_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,14 @@ class DdiEncodeBase : public DdiMediaBase
DDI_MEDIA_CONTEXT *mediaCtx,
void * ptr) = 0;

//!
//! \brief Clear picture params
//! \details Clear picture params called by EndPicture
//!
//! \return void
//!
virtual void ClearPicParams();

//!
//! \brief get Slice Parameter Buffer Size
//!
Expand Down