From: cgutman via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: cgutman <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] avcodec/mfenc: limit reference frames when requested (PR #21375)
Date: Sun, 04 Jan 2026 20:40:11 -0000
Message-ID: <176755921153.25.13993140703723696152@4457048688e7> (raw)
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
reply other threads:[~2026-01-04 20:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=176755921153.25.13993140703723696152@4457048688e7 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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