From 449ab47772b9a4efe911856364992d5b5ccd7aae Mon Sep 17 00:00:00 2001 From: Lina Sun Date: Thu, 7 Nov 2024 07:08:13 +0000 Subject: [PATCH] [c2][encoder] Fix AV1 encoder issue Fix AV1 encode issue of "Encoder configure failed" and test be always waiting and can not run to end when running ffmpeg. "Encoder configure failed" is because in mfx_set_RateControlMethod function AV1 encoder case in not handled. Test always wait and can't run to end is because GopRefDist is not set when initializing AV1 encoder, default value of 8 from vpl is used, which caused mediasdk_c2 can't send work done notification to framework codec, so framework codec can't queue more works after queuing initial 4 works. Besides, use PROFILE_AV1_0 & LEVEL_AV1_5_3 as default AV1 encoder profile & level instead of PROFILE_AV1_0 & LEVEL_AV1_7_3, as the latter can not work. Tracked-On: OAM-124081 Signed-off-by: Lina Sun (cherry picked from commit d48d495bd7846a78719ce9b633bc4689ff84e834) Tracked-On: OAM-128364 Signed-off-by: Lina Sun --- c2_components/src/mfx_c2_encoder_component.cpp | 4 ++-- c2_utils/src/mfx_defaults.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/c2_components/src/mfx_c2_encoder_component.cpp b/c2_components/src/mfx_c2_encoder_component.cpp index e62e834b..86e9547b 100755 --- a/c2_components/src/mfx_c2_encoder_component.cpp +++ b/c2_components/src/mfx_c2_encoder_component.cpp @@ -83,7 +83,7 @@ C2R MfxC2EncoderComponent::AV1_ProfileLevelSetter(bool mayBlock, C2Pmfx.TargetKbps = 3000; break; + case MFX_CODEC_AV1: + params->mfx.TargetKbps = 3000; + break; default: MFX_DEBUG_TRACE_MSG("Unsupported Codec ID"); res = MFX_ERR_INVALID_VIDEO_PARAM; @@ -213,6 +216,21 @@ mfxStatus mfx_set_defaults_mfxVideoParam_enc(mfxVideoParam* params) params->mfx.NumRefFrame = 1; params->mfx.LowPower = MFX_CODINGOPTION_ON; break; + case MFX_CODEC_AV1: + res = mfx_set_RateControlMethod(MFX_RATECONTROL_CBR, params); + // If GopRefDist is not set, during Encoder Initialization, default + // value of 8 will be read from onevpl and used, which will cause problem. + // In framework during codec start, 4 works are queued to work queue, then + // codec will wait for work done notification to queue more works, while + // in mediasdk_c2, when handling the 4 works from framework, if GopRefDist + // is 8, the first 4 works will wait for future works to notify framework + // work done, so in framework codec will always be waiting for work done + // notification from mediasdk_c2, and mediasdk_c2 will always be waiting for + // more works from framework. + params->mfx.GopRefDist = 1; + params->mfx.GopPicSize = 16; + params->mfx.NumRefFrame = 1; + break; default: break; };