Media (Intel® oneAPI Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK

AVC IDR Frame Quality

Walton__Daniel
Beginner
485 Views

Hi,

I'm encoding video using the AVC codec with mfx.IdrInterval = 1 so that all I-Frames are IDR Frames.  When the video is played, it appears that the quality drops (it gets blocky) at each IDR frame, then slowly improves as the P-Frames come in reaching nearly perfect quality before the next IDR frame where the quality drops again.  Is there a setting to improve the quality of IDR frames?  Note: changing the bitrate settings does not change anything.  The overall quality increases, but it still appears that the IDR frames have a drop in quality over the previous frame.

Here is my initialization code:

memset(m_mfxEncParams, 0, sizeof(mfxVideoParam));
m_mfxEncParams->mfx.CodecId = MFX_CODEC_AVC;
m_mfxEncParams->mfx.TargetUsage = MFX_TARGETUSAGE_BEST_QUALITY;
m_mfxEncParams->mfx.TargetKbps = 1500;
m_mfxEncParams->mfx.MaxKbps = 1500;
m_mfxEncParams->mfx.RateControlMethod = MFX_RATECONTROL_VBR;
m_mfxEncParams->mfx.FrameInfo.FrameRateExtN = 30;
m_mfxEncParams->mfx.FrameInfo.FrameRateExtD = 1;
m_mfxEncParams->mfx.CodecProfile =  MFX_PROFILE_AVC_BASELINE;
m_mfxEncParams->mfx.CodecLevel = MFX_LEVEL_AVC_4;

m_mfxEncParams->IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
m_mfxEncParams->mfx.FrameInfo.FourCC = MFX_FOURCC_NV12;
m_mfxEncParams->mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
m_mfxEncParams->mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;


m_mfxEncParams->mfx.FrameInfo.Width = 1920;
m_mfxEncParams->mfx.FrameInfo.Height = 1080;

m_mfxEncParams->mfx.FrameInfo.CropX = 0;
m_mfxEncParams->mfx.FrameInfo.CropY = 0;
m_mfxEncParams->mfx.FrameInfo.CropW = 1920;
m_mfxEncParams->mfx.FrameInfo.CropH = 1080;

m_mfxEncParams->mfx.GopPicSize = 30;
m_mfxEncParams->mfx.IdrInterval = 1;

m_mfxEncParams->AsyncDepth = 1;
m_mfxEncParams->mfx.GopRefDist = 1;
m_mfxEncParams->mfx.NumRefFrame = 1;

Thank you in advance.

0 Kudos
1 Solution
Mark_L_Intel1
Moderator
485 Views

Hi Daniel,

Sorry for the late response.

I would concern on your reference frame, it looks like point to a wrong position. So first you should check if this is the problem of your mfx structure settings, did you check the same setting with sample_encode and dump the setting value to compare with yours?

By the way, to set each I frame to be IDR, idrinterval should be 0 according to the spec:

https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxinfomfx

Mark

View solution in original post

0 Kudos
1 Reply
Mark_L_Intel1
Moderator
486 Views

Hi Daniel,

Sorry for the late response.

I would concern on your reference frame, it looks like point to a wrong position. So first you should check if this is the problem of your mfx structure settings, did you check the same setting with sample_encode and dump the setting value to compare with yours?

By the way, to set each I frame to be IDR, idrinterval should be 0 according to the spec:

https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxinfomfx

Mark

0 Kudos
Reply