diff mbox series

[FFmpeg-devel] avcodec/mfenc: add support for AV1 MF encoders

Message ID CAEyVe9uXiOkxv1=DoYiFbeF2HoTCvmGPdNKiVLt3wHV-1wghdw@mail.gmail.com
State New
Headers show
Series [FFmpeg-devel] avcodec/mfenc: add support for AV1 MF encoders | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Dash Santosh Oct. 4, 2024, 5:44 p.m. UTC
From 77c708805c52302861650cf770f6c32a33590e90 Mon Sep 17 00:00:00 2001
From: Min Chen <chenm003@163.com>
Date: Fri, 4 Oct 2024 23:04:04 +0530
Subject: [PATCH] avcodec/mfenc: add support for AV1 MF encoders
X-Unsent: 1
To: ffmpeg-devel@ffmpeg.org

Signed-off-by: Dash Santosh <santdas36@gmail.com>
---
 configure              | 1 +
 libavcodec/allcodecs.c | 1 +
 libavcodec/mf_utils.c  | 2 ++
 libavcodec/mfenc.c     | 1 +
 4 files changed, 5 insertions(+)

Comments

Martin Storsjö Oct. 4, 2024, 5:50 p.m. UTC | #1
On Fri, 4 Oct 2024, Dash Santosh wrote:

> From 77c708805c52302861650cf770f6c32a33590e90 Mon Sep 17 00:00:00 2001
> From: Min Chen <chenm003@163.com>
> Date: Fri, 4 Oct 2024 23:04:04 +0530
> Subject: [PATCH] avcodec/mfenc: add support for AV1 MF encoders
> X-Unsent: 1
> To: ffmpeg-devel@ffmpeg.org
>
> Signed-off-by: Dash Santosh <santdas36@gmail.com>
> ---
> configure              | 1 +
> libavcodec/allcodecs.c | 1 +
> libavcodec/mf_utils.c  | 2 ++
> libavcodec/mfenc.c     | 1 +
> 4 files changed, 5 insertions(+)
>
> diff --git a/configure b/configure
> index 0247ea08d6..63bc53cc27 100755
> --- a/configure
> +++ b/configure
> @@ -3347,6 +3347,7 @@ av1_cuvid_decoder_deps="cuvid CUVIDAV1PICPARAMS"
> av1_mediacodec_decoder_deps="mediacodec"
> av1_mediacodec_encoder_deps="mediacodec"
> av1_mediacodec_encoder_select="extract_extradata_bsf"
> +av1_mf_encoder_deps="mediafoundation"
> av1_nvenc_encoder_deps="nvenc NV_ENC_PIC_PARAMS_AV1"
> av1_nvenc_encoder_select="atsc_a53"
> av1_qsv_decoder_select="qsvdec"
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index aa0fc47647..f5317616b7 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -838,6 +838,7 @@ extern const FFCodec ff_av1_nvenc_encoder;
> extern const FFCodec ff_av1_qsv_decoder;
> extern const FFCodec ff_av1_qsv_encoder;
> extern const FFCodec ff_av1_amf_encoder;
> +extern const FFCodec ff_av1_mf_encoder;
> extern const FFCodec ff_av1_vaapi_encoder;
> extern const FFCodec ff_libopenh264_encoder;
> extern const FFCodec ff_libopenh264_decoder;
> diff --git a/libavcodec/mf_utils.c b/libavcodec/mf_utils.c
> index 48e3a63efc..f740a6090b 100644
> --- a/libavcodec/mf_utils.c
> +++ b/libavcodec/mf_utils.c
> @@ -240,6 +240,7 @@ static struct GUID_Entry guid_names[] = {
>     GUID_ENTRY(MFMediaType_Video),
>     GUID_ENTRY(MFAudioFormat_PCM),
>     GUID_ENTRY(MFAudioFormat_Float),
> +    GUID_ENTRY(MFVideoFormat_AV1),
>     GUID_ENTRY(MFVideoFormat_H264),
>     GUID_ENTRY(MFVideoFormat_H264_ES),
>     GUID_ENTRY(ff_MFVideoFormat_HEVC),
> @@ -507,6 +508,7 @@ void ff_media_type_dump(void *log, IMFMediaType *type)
> const CLSID *ff_codec_to_mf_subtype(enum AVCodecID codec)
> {
>     switch (codec) {
> +    case AV_CODEC_ID_AV1:               return &MFVideoFormat_AV1;
>     case AV_CODEC_ID_H264:              return &MFVideoFormat_H264;
>     case AV_CODEC_ID_HEVC:              return &ff_MFVideoFormat_HEVC;

Doing this like this would break compilation with any earlier SDK, that 
doesn't contain a declaration of MFVideoFormat_AV1. See how we've provided 
a local definition of MFVideoFormat_HEVC in the form of 
ff_MFVideoFormat_HEVC, to work around this issue.

// Martin
Dash Santosh Oct. 7, 2024, 6:29 a.m. UTC | #2
Thanks for pointing this out, Martin. Please find the updated patch below:

From 83e8cfa99bcb13965421fb32c1feb4c792649c22 Mon Sep 17 00:00:00 2001
From: Min Chen <chenm003@163.com>
Date: Fri, 4 Oct 2024 23:04:04 +0530
Subject: [PATCH] avcodec/mfenc: add support for AV1 MF encoders
X-Unsent: 1
To: ffmpeg-devel@ffmpeg.org

Signed-off-by: Dash Santosh <santdas36@gmail.com>
---
 configure              | 1 +
 libavcodec/allcodecs.c | 1 +
 libavcodec/mf_utils.c  | 2 ++
 libavcodec/mf_utils.h  | 1 +
 libavcodec/mfenc.c     | 1 +
 5 files changed, 6 insertions(+)

diff --git a/configure b/configure
index 0247ea08d6..63bc53cc27 100755
--- a/configure
+++ b/configure
@@ -3347,6 +3347,7 @@ av1_cuvid_decoder_deps="cuvid CUVIDAV1PICPARAMS"
 av1_mediacodec_decoder_deps="mediacodec"
 av1_mediacodec_encoder_deps="mediacodec"
 av1_mediacodec_encoder_select="extract_extradata_bsf"
+av1_mf_encoder_deps="mediafoundation"
 av1_nvenc_encoder_deps="nvenc NV_ENC_PIC_PARAMS_AV1"
 av1_nvenc_encoder_select="atsc_a53"
 av1_qsv_decoder_select="qsvdec"
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index aa0fc47647..f5317616b7 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -838,6 +838,7 @@ extern const FFCodec ff_av1_nvenc_encoder;
 extern const FFCodec ff_av1_qsv_decoder;
 extern const FFCodec ff_av1_qsv_encoder;
 extern const FFCodec ff_av1_amf_encoder;
+extern const FFCodec ff_av1_mf_encoder;
 extern const FFCodec ff_av1_vaapi_encoder;
 extern const FFCodec ff_libopenh264_encoder;
 extern const FFCodec ff_libopenh264_decoder;
diff --git a/libavcodec/mf_utils.c b/libavcodec/mf_utils.c
index 48e3a63efc..ff44130ca9 100644
--- a/libavcodec/mf_utils.c
+++ b/libavcodec/mf_utils.c
@@ -240,6 +240,7 @@ static struct GUID_Entry guid_names[] = {
     GUID_ENTRY(MFMediaType_Video),
     GUID_ENTRY(MFAudioFormat_PCM),
     GUID_ENTRY(MFAudioFormat_Float),
+    GUID_ENTRY(ff_MFVideoFormat_AV1),
     GUID_ENTRY(MFVideoFormat_H264),
     GUID_ENTRY(MFVideoFormat_H264_ES),
     GUID_ENTRY(ff_MFVideoFormat_HEVC),
@@ -507,6 +508,7 @@ void ff_media_type_dump(void *log, IMFMediaType *type)
 const CLSID *ff_codec_to_mf_subtype(enum AVCodecID codec)
 {
     switch (codec) {
+    case AV_CODEC_ID_AV1:               return &ff_MFVideoFormat_AV1;
     case AV_CODEC_ID_H264:              return &MFVideoFormat_H264;
     case AV_CODEC_ID_HEVC:              return &ff_MFVideoFormat_HEVC;
     case AV_CODEC_ID_AC3:               return &MFAudioFormat_Dolby_AC3;
diff --git a/libavcodec/mf_utils.h b/libavcodec/mf_utils.h
index 387c005f38..a59b36d015 100644
--- a/libavcodec/mf_utils.h
+++ b/libavcodec/mf_utils.h
@@ -113,6 +113,7 @@
DEFINE_GUID(ff_MF_SA_MINIMUM_OUTPUT_SAMPLE_COUNT_PROGRESSIVE, 0xf5523a5,
0x1cb2,

 DEFINE_MEDIATYPE_GUID(ff_MFVideoFormat_HEVC, 0x43564548); // FCC('HEVC')
 DEFINE_MEDIATYPE_GUID(ff_MFVideoFormat_HEVC_ES, 0x53564548); // FCC('HEVS')
+DEFINE_MEDIATYPE_GUID(ff_MFVideoFormat_AV1, 0x31305641); // FCC('AV01')


 // This enum is missing from mingw-w64's codecapi.h by v7.0.0.
diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index b8f8a25f43..c062d87f11 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -1315,3 +1315,4 @@ static const FFCodecDefault defaults[] = {

 MF_ENCODER(VIDEO, h264,        H264, venc_opts, VFMTS, VCAPS, defaults);
 MF_ENCODER(VIDEO, hevc,        HEVC, venc_opts, VFMTS, VCAPS, defaults);
+MF_ENCODER(VIDEO, av1,         AV1,  venc_opts, VFMTS, VCAPS, defaults);
Martin Storsjö Oct. 9, 2024, 6:59 a.m. UTC | #3
On Mon, 7 Oct 2024, Dash Santosh wrote:

> Thanks for pointing this out, Martin. Please find the updated patch below:
>
> From 83e8cfa99bcb13965421fb32c1feb4c792649c22 Mon Sep 17 00:00:00 2001
> From: Min Chen <chenm003@163.com>
> Date: Fri, 4 Oct 2024 23:04:04 +0530
> Subject: [PATCH] avcodec/mfenc: add support for AV1 MF encoders
> X-Unsent: 1
> To: ffmpeg-devel@ffmpeg.org

Thanks - I believe this version of the patch is fine, but I can't really 
apply it from inline in this mail - can you resend it as a proper 
standalone patch?

// Martin
Dash Santosh Oct. 9, 2024, 7 a.m. UTC | #4
Sure, thanks

On Wed, 9 Oct, 2024, 12:29 Martin Storsjö, <martin@martin.st> wrote:

> On Mon, 7 Oct 2024, Dash Santosh wrote:
>
> > Thanks for pointing this out, Martin. Please find the updated patch
> below:
> >
> > From 83e8cfa99bcb13965421fb32c1feb4c792649c22 Mon Sep 17 00:00:00 2001
> > From: Min Chen <chenm003@163.com>
> > Date: Fri, 4 Oct 2024 23:04:04 +0530
> > Subject: [PATCH] avcodec/mfenc: add support for AV1 MF encoders
> > X-Unsent: 1
> > To: ffmpeg-devel@ffmpeg.org
>
> Thanks - I believe this version of the patch is fine, but I can't really
> apply it from inline in this mail - can you resend it as a proper
> standalone patch?
>
> // Martin
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
diff mbox series

Patch

diff --git a/configure b/configure
index 0247ea08d6..63bc53cc27 100755
--- a/configure
+++ b/configure
@@ -3347,6 +3347,7 @@  av1_cuvid_decoder_deps="cuvid CUVIDAV1PICPARAMS"
 av1_mediacodec_decoder_deps="mediacodec"
 av1_mediacodec_encoder_deps="mediacodec"
 av1_mediacodec_encoder_select="extract_extradata_bsf"
+av1_mf_encoder_deps="mediafoundation"
 av1_nvenc_encoder_deps="nvenc NV_ENC_PIC_PARAMS_AV1"
 av1_nvenc_encoder_select="atsc_a53"
 av1_qsv_decoder_select="qsvdec"
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index aa0fc47647..f5317616b7 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -838,6 +838,7 @@  extern const FFCodec ff_av1_nvenc_encoder;
 extern const FFCodec ff_av1_qsv_decoder;
 extern const FFCodec ff_av1_qsv_encoder;
 extern const FFCodec ff_av1_amf_encoder;
+extern const FFCodec ff_av1_mf_encoder;
 extern const FFCodec ff_av1_vaapi_encoder;
 extern const FFCodec ff_libopenh264_encoder;
 extern const FFCodec ff_libopenh264_decoder;
diff --git a/libavcodec/mf_utils.c b/libavcodec/mf_utils.c
index 48e3a63efc..f740a6090b 100644
--- a/libavcodec/mf_utils.c
+++ b/libavcodec/mf_utils.c
@@ -240,6 +240,7 @@  static struct GUID_Entry guid_names[] = {
     GUID_ENTRY(MFMediaType_Video),
     GUID_ENTRY(MFAudioFormat_PCM),
     GUID_ENTRY(MFAudioFormat_Float),
+    GUID_ENTRY(MFVideoFormat_AV1),
     GUID_ENTRY(MFVideoFormat_H264),
     GUID_ENTRY(MFVideoFormat_H264_ES),
     GUID_ENTRY(ff_MFVideoFormat_HEVC),
@@ -507,6 +508,7 @@  void ff_media_type_dump(void *log, IMFMediaType *type)
 const CLSID *ff_codec_to_mf_subtype(enum AVCodecID codec)
 {
     switch (codec) {
+    case AV_CODEC_ID_AV1:               return &MFVideoFormat_AV1;
     case AV_CODEC_ID_H264:              return &MFVideoFormat_H264;
     case AV_CODEC_ID_HEVC:              return &ff_MFVideoFormat_HEVC;
     case AV_CODEC_ID_AC3:               return &MFAudioFormat_Dolby_AC3;
diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index b8f8a25f43..c062d87f11 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -1315,3 +1315,4 @@  static const FFCodecDefault defaults[] = {

 MF_ENCODER(VIDEO, h264,        H264, venc_opts, VFMTS, VCAPS, defaults);
 MF_ENCODER(VIDEO, hevc,        HEVC, venc_opts, VFMTS, VCAPS, defaults);
+MF_ENCODER(VIDEO, av1,         AV1,  venc_opts, VFMTS, VCAPS, defaults);