Skip to content

Commit

Permalink
Add refresh_frame_context wa
Browse files Browse the repository at this point in the history
  • Loading branch information
leyu-yao committed Sep 20, 2024
1 parent 9049cf7 commit 22e27bd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions media_driver/linux/common/codec/ddi/media_ddi_encode_vp9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ VAStatus DdiEncodeVp9::EncodeInCodecHal(uint32_t numSlices)
CODEC_VP9_ENCODE_SEQUENCE_PARAMS *seqParams = (PCODEC_VP9_ENCODE_SEQUENCE_PARAMS)(m_encodeCtx->pSeqParams);
CODEC_VP9_ENCODE_PIC_PARAMS *vp9PicParam = (PCODEC_VP9_ENCODE_PIC_PARAMS)(m_encodeCtx->pPicParams);

if (!headerInsertFlag &&
vp9PicParam->PicFlags.fields.frame_type == CODEC_VP9_KEY_FRAME &&
m_isPreviousFrameKey)
{
vp9PicParam->PicFlags.fields.refresh_frame_context = 0;
}

// Update the flag for the next frame
m_isPreviousFrameKey = (vp9PicParam->PicFlags.fields.frame_type == CODEC_VP9_KEY_FRAME);

EncoderParams encodeParams;
MOS_ZeroMemory(&encodeParams, sizeof(EncoderParams));
encodeParams.ExecCodecFunction = m_encodeCtx->codecFunction;
Expand Down Expand Up @@ -393,6 +403,8 @@ VAStatus DdiEncodeVp9::ContextInitialize(CodechalSetting *codecHalSettings)
/* RT is used as the default target usage */
vp9TargetUsage = TARGETUSAGE_RT_SPEED;

m_isPreviousFrameKey = false;

return vaStatus;
}

Expand Down
2 changes: 2 additions & 0 deletions media_driver/linux/common/codec/ddi/media_ddi_encode_vp9.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,6 @@ class DdiEncodeVp9 : public DdiEncodeBase
uint8_t vp9TargetUsage = 0;

bool isSegParamsChanged = false;

bool m_isPreviousFrameKey = false;
};
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ VAStatus DdiEncodeVp9::EncodeInCodecHal(uint32_t numSlices)
CODEC_VP9_ENCODE_SEQUENCE_PARAMS *seqParams = (PCODEC_VP9_ENCODE_SEQUENCE_PARAMS)(m_encodeCtx->pSeqParams);
CODEC_VP9_ENCODE_PIC_PARAMS *vp9PicParam = (PCODEC_VP9_ENCODE_PIC_PARAMS)(m_encodeCtx->pPicParams);

if (!headerInsertFlag &&
vp9PicParam->PicFlags.fields.frame_type == CODEC_VP9_KEY_FRAME &&
m_isPreviousFrameKey)
{
vp9PicParam->PicFlags.fields.refresh_frame_context = 0;
}

// Update the flag for the next frame
m_isPreviousFrameKey = (vp9PicParam->PicFlags.fields.frame_type == CODEC_VP9_KEY_FRAME);

EncoderParams encodeParams;
MOS_ZeroMemory(&encodeParams, sizeof(EncoderParams));
encodeParams.ExecCodecFunction = m_encodeCtx->codecFunction;
Expand Down Expand Up @@ -404,6 +414,8 @@ VAStatus DdiEncodeVp9::ContextInitialize(CodechalSetting *codecHalSettings)
/* RT is used as the default target usage */
vp9TargetUsage = TARGETUSAGE_RT_SPEED;

m_isPreviousFrameKey = false;

return vaStatus;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ class DdiEncodeVp9 : public encode::DdiEncodeBase

bool isSegParamsChanged = false;

bool m_isPreviousFrameKey = false;

MEDIA_CLASS_DEFINE_END(encode__DdiEncodeVp9)
};

Expand Down

0 comments on commit 22e27bd

Please sign in to comment.