Skip to content

Commit

Permalink
Add free logic of picParams->pDeltaQp for avoiding memory leak.
Browse files Browse the repository at this point in the history
Fixes intel#611.

Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
  • Loading branch information
wangyan42164 committed May 21, 2019
1 parent f39c5dc commit 69470ed
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
11 changes: 11 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,14 @@ 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);
}
}
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

0 comments on commit 69470ed

Please sign in to comment.