* [FFmpeg-devel] [PR] avcodec/mfenc: limit reference frames when requested (PR #21375)
@ 2026-01-04 20:40 cgutman via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: cgutman via ffmpeg-devel @ 2026-01-04 20:40 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: cgutman
PR #21375 opened by cgutman
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21375
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21375.patch
Plumb `avctx->refs` to the corresponding [CODECAPI_AVEncVideoMaxNumRefFrame](https://learn.microsoft.com/en-us/windows/win32/medfound/codecapi-avencvideomaxnumrefframe) option used by MediaFoundation encoders.
>From 9ffa433b2f7f97a29f69adbd134cf7fb4dc9b6a6 Mon Sep 17 00:00:00 2001
From: Cameron Gutman <aicommander@gmail.com>
Date: Sun, 4 Jan 2026 13:02:38 -0600
Subject: [PATCH] avcodec/mfenc: limit reference frames when requested
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
---
libavcodec/mf_utils.h | 1 +
libavcodec/mfenc.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/libavcodec/mf_utils.h b/libavcodec/mf_utils.h
index ecebb6fcdf..f376c2ac2b 100644
--- a/libavcodec/mf_utils.h
+++ b/libavcodec/mf_utils.h
@@ -109,6 +109,7 @@ DEFINE_GUID(ff_CODECAPI_AVEncCommonMaxBitRate, 0x9651eae4, 0x39b9, 0x4ebf, 0x85,
DEFINE_GUID(ff_CODECAPI_AVEncCommonQualityVsSpeed, 0x98332df8, 0x03cd, 0x476b, 0x89, 0xfa, 0x3f, 0x9e, 0x44, 0x2d, 0xec, 0x9f);
DEFINE_GUID(ff_CODECAPI_AVEncMPVGOPSize, 0x95f31b26, 0x95a4, 0x41aa, 0x93, 0x03, 0x24, 0x6a, 0x7f, 0xc6, 0xee, 0xf1);
DEFINE_GUID(ff_CODECAPI_AVEncVideoEncodeQP, 0x2cb5696b, 0x23fb, 0x4ce1, 0xa0, 0xf9, 0xef, 0x5b, 0x90, 0xfd, 0x55, 0xca);
+DEFINE_GUID(ff_CODECAPI_AVEncVideoMaxNumRefFrame, 0x964829ed, 0x94f9, 0x43b4, 0xb7, 0x4d, 0xef, 0x40, 0x94, 0x4b, 0x69, 0xa0);
DEFINE_GUID(ff_MF_SA_D3D11_BINDFLAGS, 0xeacf97ad, 0x065c, 0x4408, 0xbe, 0xe3, 0xfd, 0xcb, 0xfd, 0x12, 0x8b, 0xe2);
DEFINE_GUID(ff_MF_SA_D3D11_USAGE, 0xe85fe442, 0x2ca3, 0x486e, 0xa9, 0xc7, 0x10, 0x9d, 0xda, 0x60, 0x98, 0x80);
diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index 541f7fb961..2d3f510a60 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -874,6 +874,9 @@ static int mf_encv_output_adjust(AVCodecContext *avctx, IMFMediaType *type)
ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVEncH264CABACEnable, FF_VAL_VT_BOOL(1));
+ if (avctx->refs > 0)
+ ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVEncVideoMaxNumRefFrame, FF_VAL_VT_UI4(avctx->refs));
+
if (c->opt_enc_scenario >= 0)
ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVScenarioInfo, FF_VAL_VT_UI4(c->opt_enc_scenario));
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-04 20:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-04 20:40 [FFmpeg-devel] [PR] avcodec/mfenc: limit reference frames when requested (PR #21375) cgutman via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git