PR #24480 opened by Wassim Lalaoui (wassim-devel) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24480 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24480.patch
- Fix hwaccel not renegociating when the pixel format changes - Add support for AV1 High Profile - Offer DXVA2/D3D11VA for 8/10-bit 4:2:2 and 4:4:4 AV1 streams >From 1874ce8de6c4586eef64646f2b75d8d6fc42de3e Mon Sep 17 00:00:00 2001 From: Wassim Lalaoui <[email protected]> Date: Fri, 10 Jul 2026 16:07:26 +0200 Subject: [PATCH 1/3] avcodec/av1dec: renegotiate the hwaccel when the pixel format changes get_pixel_format() kept the negotiated hwaccel whenever avctx->pix_fmt was still among the candidate formats of the new sequence header, even if the underlying sw pixel format changed. The existing decoder surfaces then have the wrong format, so only keep the current hwaccel when the sw pixel format matches the one it was negotiated for and do a full renegotiation otherwise. --- libavcodec/av1dec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index e08dbddc48..800e882d72 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -677,11 +677,14 @@ static int get_pixel_format(AVCodecContext *avctx) *fmtp++ = pix_fmt; *fmtp = AV_PIX_FMT_NONE; - for (int i = 0; pix_fmts[i] != pix_fmt; i++) - if (pix_fmts[i] == avctx->pix_fmt) { - s->pix_fmt = pix_fmt; - return 1; - } + /* the negotiated hwaccel can only be kept if the underlying pixel + * format did not change, otherwise its surfaces have the wrong format */ + if (pix_fmt == avctx->sw_pix_fmt) + for (int i = 0; pix_fmts[i] != pix_fmt; i++) + if (pix_fmts[i] == avctx->pix_fmt) { + s->pix_fmt = pix_fmt; + return 1; + } ret = ff_get_format(avctx, pix_fmts); -- 2.52.0 >From 8c7ff4ca3b45d5f4106bd25ec9f4a7b3b8af8583 Mon Sep 17 00:00:00 2001 From: Wassim Lalaoui <[email protected]> Date: Fri, 10 Jul 2026 16:07:26 +0200 Subject: [PATCH 2/3] avcodec/dxva2: add AV1 Profile 1 decoder GUID Add the AV1 High (Profile 1, 8/10-bit 4:4:4) decoder GUID, so D3D11VA/DXVA2 can match a decoder for Profile 1 streams. --- libavcodec/dxva2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 8f09fb6c44..c761f8eebb 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -47,6 +47,7 @@ DEFINE_GUID(ff_DXVA2_ModeHEVC_VLD_Main10,0x107af0e0, 0xef1a,0x4d19,0xab,0xa8,0x6 DEFINE_GUID(ff_DXVA2_ModeVP9_VLD_Profile0,0x463707f8,0xa1d0,0x4585,0x87,0x6d,0x83,0xaa,0x6d,0x60,0xb8,0x9e); DEFINE_GUID(ff_DXVA2_ModeVP9_VLD_10bit_Profile2,0xa4c749ef,0x6ecf,0x48aa,0x84,0x48,0x50,0xa7,0xa1,0x16,0x5f,0xf7); DEFINE_GUID(ff_DXVA2_ModeAV1_VLD_Profile0,0xb8be4ccb,0xcf53,0x46ba,0x8d,0x59,0xd6,0xb8,0xa6,0xda,0x5d,0x2a); +DEFINE_GUID(ff_DXVA2_ModeAV1_VLD_Profile1,0x6936ff0f,0x45b1,0x4163,0x9c,0xc1,0x64,0x6e,0xf6,0x94,0x61,0x08); DEFINE_GUID(ff_DXVA2_ModeAV1_VLD_Profile2,0x0c5f2aa1,0xe541,0x4089,0xbb,0x7b,0x98,0x11,0x0a,0x19,0xd7,0xc8); DEFINE_GUID(ff_DXVA2_ModeAV1_VLD_12bit_Profile2,0x17127009,0xa00f,0x4ce1,0x99,0x4e,0xbf,0x40,0x81,0xf6,0xf3,0xf0); DEFINE_GUID(ff_DXVA2_ModeAV1_VLD_12bit_Profile2_420,0x2d80bed6,0x9cac,0x4835,0x9e,0x91,0x32,0x7b,0xbc,0x4f,0x9e,0xe8); @@ -79,6 +80,8 @@ static const int prof_vp9_profile2[] = {AV_PROFILE_VP9_2, AV_PROFILE_UNKNOWN}; static const int prof_av1_profile0[] = {AV_PROFILE_AV1_MAIN, AV_PROFILE_UNKNOWN}; +static const int prof_av1_profile1[] = {AV_PROFILE_AV1_HIGH, + AV_PROFILE_UNKNOWN}; static const int prof_av1_profile2[] = {AV_PROFILE_AV1_PROFESSIONAL, AV_PROFILE_UNKNOWN}; @@ -109,6 +112,7 @@ static const dxva_mode dxva_modes[] = { /* AV1 */ { &ff_DXVA2_ModeAV1_VLD_Profile0, AV_CODEC_ID_AV1, prof_av1_profile0 }, + { &ff_DXVA2_ModeAV1_VLD_Profile1, AV_CODEC_ID_AV1, prof_av1_profile1 }, { &ff_DXVA2_ModeAV1_VLD_12bit_Profile2_420, AV_CODEC_ID_AV1, prof_av1_profile2 }, { &ff_DXVA2_ModeAV1_VLD_12bit_Profile2, AV_CODEC_ID_AV1, prof_av1_profile2 }, { &ff_DXVA2_ModeAV1_VLD_Profile2, AV_CODEC_ID_AV1, prof_av1_profile2 }, -- 2.52.0 >From a14deff65b36f94347db08ec30a7d6367d78c301 Mon Sep 17 00:00:00 2001 From: Wassim Lalaoui <[email protected]> Date: Fri, 10 Jul 2026 16:07:26 +0200 Subject: [PATCH 3/3] avcodec/av1dec: allow DXVA2/D3D11VA for 8/10-bit 4:2:2 and 4:4:4 Offer the DXVA2 and D3D11VA hwaccel pixel formats for YUV422P, YUV422P10 (AV1 Profile 2) and YUV444P, YUV444P10 (AV1 Profile 1), enabling hardware decoding of these streams on capable devices. --- libavcodec/av1dec.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 800e882d72..46caeac69b 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -627,11 +627,25 @@ static int get_pixel_format(AVCodecContext *avctx) #endif break; case AV_PIX_FMT_YUV422P: +#if CONFIG_AV1_DXVA2_HWACCEL + *fmtp++ = AV_PIX_FMT_DXVA2_VLD; +#endif +#if CONFIG_AV1_D3D11VA_HWACCEL + *fmtp++ = AV_PIX_FMT_D3D11VA_VLD; + *fmtp++ = AV_PIX_FMT_D3D11; +#endif #if CONFIG_AV1_VULKAN_HWACCEL *fmtp++ = AV_PIX_FMT_VULKAN; #endif break; case AV_PIX_FMT_YUV422P10: +#if CONFIG_AV1_DXVA2_HWACCEL + *fmtp++ = AV_PIX_FMT_DXVA2_VLD; +#endif +#if CONFIG_AV1_D3D11VA_HWACCEL + *fmtp++ = AV_PIX_FMT_D3D11VA_VLD; + *fmtp++ = AV_PIX_FMT_D3D11; +#endif #if CONFIG_AV1_VULKAN_HWACCEL *fmtp++ = AV_PIX_FMT_VULKAN; #endif @@ -642,11 +656,25 @@ static int get_pixel_format(AVCodecContext *avctx) #endif break; case AV_PIX_FMT_YUV444P: +#if CONFIG_AV1_DXVA2_HWACCEL + *fmtp++ = AV_PIX_FMT_DXVA2_VLD; +#endif +#if CONFIG_AV1_D3D11VA_HWACCEL + *fmtp++ = AV_PIX_FMT_D3D11VA_VLD; + *fmtp++ = AV_PIX_FMT_D3D11; +#endif #if CONFIG_AV1_VULKAN_HWACCEL *fmtp++ = AV_PIX_FMT_VULKAN; #endif break; case AV_PIX_FMT_YUV444P10: +#if CONFIG_AV1_DXVA2_HWACCEL + *fmtp++ = AV_PIX_FMT_DXVA2_VLD; +#endif +#if CONFIG_AV1_D3D11VA_HWACCEL + *fmtp++ = AV_PIX_FMT_D3D11VA_VLD; + *fmtp++ = AV_PIX_FMT_D3D11; +#endif #if CONFIG_AV1_VULKAN_HWACCEL *fmtp++ = AV_PIX_FMT_VULKAN; #endif -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
