This is an automated email from the git hooks/post-receive script.
Git pushed a commit to branch master
in repository ffmpeg.
The following commit(s) were added to refs/heads/master by this push:
new 9acd820732 avcodec/mfenc: populate video input type with size, rate,
interlace
9acd820732 is described below
commit 9acd820732f0bf738bd743bbde6a5c3eadc216c2
Author: Ashrit Shetty <[email protected]>
AuthorDate: Tue Apr 21 21:42:29 2026 +0000
Commit: Martin Storsjö <[email protected]>
CommitDate: Wed Apr 22 10:48:24 2026 +0300
avcodec/mfenc: populate video input type with size, rate, interlace
mf_encv_input_adjust() currently only validates the pixel format and
otherwise leaves the input IMFMediaType unchanged. The Microsoft
H.264, H.265 and AV1 encoder MFTs tolerate this and internally infer
the missing attributes from the previously-set output type. Other
MediaFoundation encoder MFTs that follow the specification more
strictly reject the input type with MF_E_INVALIDMEDIATYPE (due to
MF_E_ATTRIBUTENOTFOUND on MF_MT_FRAME_SIZE / MF_MT_FRAME_RATE) when
those attributes are absent, which causes IMFTransform::SetInputType
to fail and aborts encoding.
Set MF_MT_FRAME_SIZE, MF_MT_FRAME_RATE and MF_MT_INTERLACE_MODE on
the input media type, mirroring what mf_encv_output_adjust() already
writes to the output type. Behaviour on the Microsoft MFTs is
unchanged (they were already using these values) and encoding now
works with stricter third-party MFTs.
The MF_MT_FRAME_SIZE assignment has been present but commented out
since the original MediaFoundation wrapper was added in 050b72ab5e.
Signed-off-by: Ashrit Shetty <[email protected]>
Signed-off-by: Martin Storsjö <[email protected]>
---
libavcodec/mfenc.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index 541f7fb961..b51735268b 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -904,6 +904,8 @@ static int64_t mf_encv_input_score(AVCodecContext *avctx,
IMFMediaType *type)
static int mf_encv_input_adjust(AVCodecContext *avctx, IMFMediaType *type)
{
enum AVPixelFormat pix_fmt = ff_media_type_to_pix_fmt((IMFAttributes
*)type);
+ AVRational framerate;
+
if (avctx->pix_fmt == AV_PIX_FMT_D3D11) {
if (pix_fmt != AV_PIX_FMT_NV12 && pix_fmt != AV_PIX_FMT_D3D11) {
av_log(avctx, AV_LOG_ERROR, "unsupported input pixel format
set\n");
@@ -916,7 +918,16 @@ static int mf_encv_input_adjust(AVCodecContext *avctx,
IMFMediaType *type)
}
}
- //ff_MFSetAttributeSize((IMFAttributes *)type, &MF_MT_FRAME_SIZE,
avctx->width, avctx->height);
+ ff_MFSetAttributeSize((IMFAttributes *)type, &MF_MT_FRAME_SIZE,
avctx->width, avctx->height);
+ IMFAttributes_SetUINT32(type, &MF_MT_INTERLACE_MODE,
MFVideoInterlace_Progressive);
+
+ if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
+ framerate = avctx->framerate;
+ } else {
+ framerate = av_inv_q(avctx->time_base);
+ }
+
+ ff_MFSetAttributeRatio((IMFAttributes *)type, &MF_MT_FRAME_RATE,
framerate.num, framerate.den);
return 0;
}
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]