Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Dmitrii Ovchinnikov <ovchinnikov.dmitrii-at-gmail.com@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: nyanmisaka <nst799610810@gmail.com>
Subject: [FFmpeg-devel] [PATCH] avcodec/amfdec: Add VP9 AMF decoder
Date: Mon, 23 Jun 2025 15:14:16 +0200
Message-ID: <20250623131416.98-1-ovchinnikov.dmitrii@gmail.com> (raw)

From: nyanmisaka <nst799610810@gmail.com>

---
 configure              |  1 +
 libavcodec/Makefile    |  1 +
 libavcodec/allcodecs.c |  1 +
 libavcodec/amfdec.c    | 16 ++++++++++++----
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index f76f946dfe..fcc0af5681 100755
--- a/configure
+++ b/configure
@@ -3457,6 +3457,7 @@ vp8_vaapi_encoder_deps="VAEncPictureParameterBufferVP8"
 vp8_vaapi_encoder_select="vaapi_encode"
 vp8_v4l2m2m_decoder_deps="v4l2_m2m vp8_v4l2_m2m"
 vp8_v4l2m2m_encoder_deps="v4l2_m2m vp8_v4l2_m2m"
+vp9_amf_decoder_deps="amf"
 vp9_cuvid_decoder_deps="cuvid"
 vp9_mediacodec_decoder_deps="mediacodec"
 vp9_mediacodec_encoder_deps="mediacodec"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 9630074205..3157729e55 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -799,6 +799,7 @@ OBJS-$(CONFIG_VP8_V4L2M2M_ENCODER)     += v4l2_m2m_enc.o
 OBJS-$(CONFIG_VP9_DECODER)             += vp9.o vp9data.o vp9dsp.o vp9lpf.o vp9recon.o \
                                           vp9block.o vp9prob.o vp9mvs.o vpx_rac.o \
                                           vp9dsp_8bpp.o vp9dsp_10bpp.o vp9dsp_12bpp.o
+OBJS-$(CONFIG_VP9_AMF_DECODER)         += amfdec.o
 OBJS-$(CONFIG_VP9_CUVID_DECODER)       += cuviddec.o
 OBJS-$(CONFIG_VP9_MEDIACODEC_DECODER)  += mediacodecdec.o
 OBJS-$(CONFIG_VP9_MEDIACODEC_ENCODER)  += mediacodecenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 3be33f5cc4..fa90e25633 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -899,6 +899,7 @@ extern const FFCodec ff_vp8_mediacodec_encoder;
 extern const FFCodec ff_vp8_qsv_decoder;
 extern const FFCodec ff_vp8_v4l2m2m_encoder;
 extern const FFCodec ff_vp8_vaapi_encoder;
+extern const FFCodec ff_vp9_amf_decoder;
 extern const FFCodec ff_vp9_cuvid_decoder;
 extern const FFCodec ff_vp9_mediacodec_decoder;
 extern const FFCodec ff_vp9_mediacodec_encoder;
diff --git a/libavcodec/amfdec.c b/libavcodec/amfdec.c
index 88e55a7752..75a624d48c 100644
--- a/libavcodec/amfdec.c
+++ b/libavcodec/amfdec.c
@@ -89,6 +89,9 @@ static int amf_init_decoder(AVCodecContext *avctx)
     AMFBuffer               *buffer;
     amf_int64               color_profile;
     int                     pool_size = 36;
+    // way-around for older drivers that don't support dynamic bitness detection -
+    // define HEVC and VP9 10-bit based on container info
+    int                     no_bitness_detect = amf_legacy_driver_no_bitness_detect(amf_device_ctx);
 
     ctx->drain = 0;
     ctx->resolution_changed = 0;
@@ -99,13 +102,17 @@ static int amf_init_decoder(AVCodecContext *avctx)
             break;
         case AV_CODEC_ID_HEVC: {
             codec_id = AMFVideoDecoderHW_H265_HEVC;
-            // way-around for older drivers that don't support dynamic butness detection -
-            // define HEVC 10-bit based on container info
-            if(amf_legacy_driver_no_bitness_detect(amf_device_ctx)){
+            if(no_bitness_detect){
                 if(avctx->pix_fmt == AV_PIX_FMT_YUV420P10)
                     codec_id = AMFVideoDecoderHW_H265_MAIN10;
             }
-
+        } break;
+        case AV_CODEC_ID_VP9: {
+            codec_id = AMFVideoDecoderHW_VP9;
+            if(no_bitness_detect){
+                if(avctx->pix_fmt == AV_PIX_FMT_YUV420P10)
+                    codec_id = AMFVideoDecoderHW_VP9_10BIT;
+            }
         } break;
         case AV_CODEC_ID_AV1:
             codec_id = AMFVideoDecoderHW_AV1;
@@ -713,4 +720,5 @@ const FFCodec ff_##x##_amf_decoder = { \
 
 DEFINE_AMF_DECODER(h264, H264, "h264_mp4toannexb")
 DEFINE_AMF_DECODER(hevc, HEVC, NULL)
+DEFINE_AMF_DECODER(vp9, VP9, NULL)
 DEFINE_AMF_DECODER(av1, AV1, NULL)
-- 
2.47.1.windows.2

_______________________________________________
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".

                 reply	other threads:[~2025-06-23 13:14 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=20250623131416.98-1-ovchinnikov.dmitrii@gmail.com \
    --to=ovchinnikov.dmitrii-at-gmail.com@ffmpeg.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=nst799610810@gmail.com \
    /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