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 9a780eb
Show file tree
Hide file tree
Showing 5 changed files with 36 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 @@ -642,6 +642,7 @@ namespace encode
return MOS_STATUS_SUCCESS;
}

//Please check this function and judge whether there is any coverity issue in this function.
MOS_STATUS HevcVdencPkt::AddOneTileCommands(
MOS_COMMAND_BUFFER &cmdBuffer,
uint32_t tileRow,
Expand Down Expand Up @@ -694,6 +695,13 @@ namespace encode

SETPAR_AND_ADDCMD(VDENC_PIPE_MODE_SELECT, m_vdencItf, tempCmdBuffer);

return eStatus;

}




// for Gen11+, we need to add MFX wait for both KIN and VRT before and after HCP Pipemode select...
auto &mfxWaitParams = m_miItf->MHW_GETPAR_F(MFX_WAIT)();
mfxWaitParams = {};
Expand Down
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 9a780eb

Please sign in to comment.