commit 6d25ae7fe97955a55c758edfa9d7c7e849cc24ba
Author: Leigh Scott <leigh123linux(a)gmail.com>
Date: Sun Jul 21 00:34:37 2024 +0100
Backport fixes for Mesa 24.0.6+ / 21.1.4+ changes for VA-API
...decode-Make-it-possible-to-send-multiple-.patch | 137 +++++++++++++++++++++
...av1-Avoid-sending-the-same-slice-buffer-m.patch | 112 +++++++++++++++++
ffmpeg.spec | 8 +-
3 files changed, 256 insertions(+), 1 deletion(-)
---
diff --git a/0001-lavc-vaapi_decode-Make-it-possible-to-send-multiple-.patch
b/0001-lavc-vaapi_decode-Make-it-possible-to-send-multiple-.patch
new file mode 100644
index 0000000..34bca43
--- /dev/null
+++ b/0001-lavc-vaapi_decode-Make-it-possible-to-send-multiple-.patch
@@ -0,0 +1,137 @@
+From 5176821735c397de2a108cd266a6c6759a5e0ffe Mon Sep 17 00:00:00 2001
+From: David Rosca <nowrep(a)gmail.com>
+Date: Wed, 8 May 2024 09:11:11 +0200
+Subject: [PATCH 1/2] lavc/vaapi_decode: Make it possible to send multiple
+ slice params buffers
+
+Reviewed-by: Neal Gompa <ngompa13(a)gmail.com>
+Signed-off-by: David Rosca <nowrep(a)gmail.com>
+Signed-off-by: Haihao Xiang <haihao.xiang(a)intel.com>
+(cherry picked from commit fe9d889dcd79ea18d4dfaa39df4ddbd4c8c3b15c)
+
+[modified to drop h264/hevc/vc1 parts stripped in Fedora Linux]
+---
+ libavcodec/vaapi_av1.c | 2 +-
+ libavcodec/vaapi_decode.c | 3 ++-
+ libavcodec/vaapi_decode.h | 1 +
+ libavcodec/vaapi_mjpeg.c | 2 +-
+ libavcodec/vaapi_mpeg2.c | 2 +-
+ libavcodec/vaapi_mpeg4.c | 2 +-
+ libavcodec/vaapi_vp8.c | 2 +-
+ libavcodec/vaapi_vp9.c | 2 +-
+ 8 files changed, 9 insertions(+), 7 deletions(-)
+
+diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c
+index 1f9a6071ba..03771dd3e0 100644
+--- a/libavcodec/vaapi_av1.c
++++ b/libavcodec/vaapi_av1.c
+@@ -409,7 +409,7 @@ static int vaapi_av1_decode_slice(AVCodecContext *avctx,
+ .tg_end = s->tg_end,
+ };
+
+- err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &slice_param,
++ err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &slice_param, 1,
+ sizeof(VASliceParameterBufferAV1),
+ buffer,
+ size);
+diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
+index ceac769c52..9344c21fd2 100644
+--- a/libavcodec/vaapi_decode.c
++++ b/libavcodec/vaapi_decode.c
+@@ -62,6 +62,7 @@ int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
+ int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx,
+ VAAPIDecodePicture *pic,
+ const void *params_data,
++ int nb_params,
+ size_t params_size,
+ const void *slice_data,
+ size_t slice_size)
+@@ -90,7 +91,7 @@ int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx,
+
+ vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context,
+ VASliceParameterBufferType,
+- params_size, 1, (void*)params_data,
++ params_size, nb_params, (void*)params_data,
+ &pic->slice_buffers[index]);
+ if (vas != VA_STATUS_SUCCESS) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to create slice "
+diff --git a/libavcodec/vaapi_decode.h b/libavcodec/vaapi_decode.h
+index 6beda14e52..702171e108 100644
+--- a/libavcodec/vaapi_decode.h
++++ b/libavcodec/vaapi_decode.h
+@@ -73,6 +73,7 @@ int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
+ int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx,
+ VAAPIDecodePicture *pic,
+ const void *params_data,
++ int nb_params,
+ size_t params_size,
+ const void *slice_data,
+ size_t slice_size);
+diff --git a/libavcodec/vaapi_mjpeg.c b/libavcodec/vaapi_mjpeg.c
+index 5b8d47bb2a..9557cf5f9b 100644
+--- a/libavcodec/vaapi_mjpeg.c
++++ b/libavcodec/vaapi_mjpeg.c
+@@ -131,7 +131,7 @@ static int vaapi_mjpeg_decode_slice(AVCodecContext *avctx,
+ sp.components[i].ac_table_selector = s->ac_index[i];
+ }
+
+- err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &sp, sizeof(sp), buffer,
size);
++ err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &sp, 1, sizeof(sp), buffer,
size);
+ if (err)
+ goto fail;
+
+diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c
+index eeb4e87321..171a742c7f 100644
+--- a/libavcodec/vaapi_mpeg2.c
++++ b/libavcodec/vaapi_mpeg2.c
+@@ -162,7 +162,7 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const
uint8_t *buffer
+ };
+
+ err = ff_vaapi_decode_make_slice_buffer(avctx, pic,
+- &slice_param, sizeof(slice_param),
++ &slice_param, 1, sizeof(slice_param),
+ buffer, size);
+ if (err < 0) {
+ ff_vaapi_decode_cancel(avctx, pic);
+diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c
+index 363b686e42..612de10cd7 100644
+--- a/libavcodec/vaapi_mpeg4.c
++++ b/libavcodec/vaapi_mpeg4.c
+@@ -169,7 +169,7 @@ static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const
uint8_t *buffer
+ };
+
+ err = ff_vaapi_decode_make_slice_buffer(avctx, pic,
+- &slice_param, sizeof(slice_param),
++ &slice_param, 1, sizeof(slice_param),
+ buffer, size);
+ if (err < 0) {
+ ff_vaapi_decode_cancel(avctx, pic);
+diff --git a/libavcodec/vaapi_vp8.c b/libavcodec/vaapi_vp8.c
+index 31137a45bd..66fdde1f39 100644
+--- a/libavcodec/vaapi_vp8.c
++++ b/libavcodec/vaapi_vp8.c
+@@ -209,7 +209,7 @@ static int vaapi_vp8_decode_slice(AVCodecContext *avctx,
+ for (i = 0; i < 8; i++)
+ sp.partition_size[i+1] = s->coeff_partition_size[i];
+
+- err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &sp, sizeof(sp), data,
data_size);
++ err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &sp, 1, sizeof(sp), data,
data_size);
+ if (err)
+ goto fail;
+
+diff --git a/libavcodec/vaapi_vp9.c b/libavcodec/vaapi_vp9.c
+index 9dc7d5e72b..ff11022db7 100644
+--- a/libavcodec/vaapi_vp9.c
++++ b/libavcodec/vaapi_vp9.c
+@@ -158,7 +158,7 @@ static int vaapi_vp9_decode_slice(AVCodecContext *avctx,
+ }
+
+ err = ff_vaapi_decode_make_slice_buffer(avctx, pic,
+- &slice_param, sizeof(slice_param),
++ &slice_param, 1, sizeof(slice_param),
+ buffer, size);
+ if (err) {
+ ff_vaapi_decode_cancel(avctx, pic);
+--
+2.45.1
+
diff --git a/0002-lavc-vaapi_av1-Avoid-sending-the-same-slice-buffer-m.patch
b/0002-lavc-vaapi_av1-Avoid-sending-the-same-slice-buffer-m.patch
new file mode 100644
index 0000000..91d018a
--- /dev/null
+++ b/0002-lavc-vaapi_av1-Avoid-sending-the-same-slice-buffer-m.patch
@@ -0,0 +1,112 @@
+From 1740980b070897fd147b2d1a5259c9d7957d58a8 Mon Sep 17 00:00:00 2001
+From: David Rosca <nowrep(a)gmail.com>
+Date: Wed, 8 May 2024 09:11:13 +0200
+Subject: [PATCH 2/2] lavc/vaapi_av1: Avoid sending the same slice buffer
+ multiple times
+
+When there are multiple tiles in one slice buffer, use multiple slice
+params to avoid sending the same slice buffer multiple times and thus
+increasing the bitstream size the driver will need to upload to hw.
+
+Reviewed-by: Neal Gompa <ngompa13(a)gmail.com>
+Signed-off-by: David Rosca <nowrep(a)gmail.com>
+Signed-off-by: Haihao Xiang <haihao.xiang(a)intel.com>
+(cherry picked from commit d2d911eb9a2fc6eb8d86b3ae025a56c1a2692fba)
+---
+ libavcodec/vaapi_av1.c | 47 +++++++++++++++++++++++++++++-------------
+ 1 file changed, 33 insertions(+), 14 deletions(-)
+
+diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c
+index 03771dd3e0..ea8dd4d93d 100644
+--- a/libavcodec/vaapi_av1.c
++++ b/libavcodec/vaapi_av1.c
+@@ -19,6 +19,7 @@
+ */
+
+ #include "libavutil/frame.h"
++#include "libavutil/mem.h"
+ #include "hwaccel_internal.h"
+ #include "vaapi_decode.h"
+ #include "internal.h"
+@@ -42,6 +43,9 @@ typedef struct VAAPIAV1DecContext {
+ */
+ VAAPIAV1FrameRef ref_tab[AV1_NUM_REF_FRAMES];
+ AVFrame *tmp_frame;
++
++ int nb_slice_params;
++ VASliceParameterBufferAV1 *slice_params;
+ } VAAPIAV1DecContext;
+
+ static VASurfaceID vaapi_av1_surface_id(AV1Frame *vf)
+@@ -97,6 +101,8 @@ static int vaapi_av1_decode_uninit(AVCodecContext *avctx)
+ for (int i = 0; i < FF_ARRAY_ELEMS(ctx->ref_tab); i++)
+ av_frame_free(&ctx->ref_tab[i].frame);
+
++ av_freep(&ctx->slice_params);
++
+ return ff_vaapi_decode_uninit(avctx);
+ }
+
+@@ -393,13 +399,24 @@ static int vaapi_av1_decode_slice(AVCodecContext *avctx,
+ {
+ const AV1DecContext *s = avctx->priv_data;
+ VAAPIDecodePicture *pic = s->cur_frame.hwaccel_picture_private;
+- VASliceParameterBufferAV1 slice_param;
+- int err = 0;
++ VAAPIAV1DecContext *ctx = avctx->internal->hwaccel_priv_data;
++ int err, nb_params;
++
++ nb_params = s->tg_end - s->tg_start + 1;
++ if (ctx->nb_slice_params < nb_params) {
++ ctx->slice_params = av_realloc_array(ctx->slice_params,
++ nb_params,
++ sizeof(*ctx->slice_params));
++ if (!ctx->slice_params) {
++ ctx->nb_slice_params = 0;
++ err = AVERROR(ENOMEM);
++ goto fail;
++ }
++ ctx->nb_slice_params = nb_params;
++ }
+
+ for (int i = s->tg_start; i <= s->tg_end; i++) {
+- memset(&slice_param, 0, sizeof(VASliceParameterBufferAV1));
+-
+- slice_param = (VASliceParameterBufferAV1) {
++ ctx->slice_params[i - s->tg_start] = (VASliceParameterBufferAV1) {
+ .slice_data_size = s->tile_group_info[i].tile_size,
+ .slice_data_offset = s->tile_group_info[i].tile_offset,
+ .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
+@@ -408,18 +425,20 @@ static int vaapi_av1_decode_slice(AVCodecContext *avctx,
+ .tg_start = s->tg_start,
+ .tg_end = s->tg_end,
+ };
+-
+- err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &slice_param, 1,
+- sizeof(VASliceParameterBufferAV1),
+- buffer,
+- size);
+- if (err) {
+- ff_vaapi_decode_cancel(avctx, pic);
+- return err;
+- }
+ }
+
++ err = ff_vaapi_decode_make_slice_buffer(avctx, pic, ctx->slice_params,
nb_params,
++ sizeof(VASliceParameterBufferAV1),
++ buffer,
++ size);
++ if (err)
++ goto fail;
++
+ return 0;
++
++fail:
++ ff_vaapi_decode_cancel(avctx, pic);
++ return err;
+ }
+
+ const FFHWAccel ff_av1_vaapi_hwaccel = {
+--
+2.45.1
+
diff --git a/ffmpeg.spec b/ffmpeg.spec
index b2adaca..ba4c88d 100644
--- a/ffmpeg.spec
+++ b/ffmpeg.spec
@@ -98,7 +98,7 @@ ExclusiveArch: armv7hnl
Summary: Digital VCR and streaming server
Name: ffmpeg%{?flavor}
Version: 6.1.1
-Release: 13%{?date:.%{?date}%{?date:git}%{?rel}}%{?dist}
+Release: 14%{?date:.%{?date}%{?date:git}%{?rel}}%{?dist}
License: %{ffmpeg_license}
URL:
https://ffmpeg.org/
%if 0%{?date}
@@ -113,6 +113,9 @@ Patch0: ffmpeg-chromium.patch
Patch1:
https://src.fedoraproject.org/rpms/ffmpeg/raw/774d42a0072430fdef97ce11b40...
Patch2:
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff_plain/42982b5a5d46153...
Patch3:
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff_plain/fef22c87ada4517...
+# Fixes for Mesa 24.0.6+ / 24.1.4+ VA-API
+Patch4: 0001-lavc-vaapi_decode-Make-it-possible-to-send-multiple-.patch
+Patch5: 0002-lavc-vaapi_av1-Avoid-sending-the-same-slice-buffer-m.patch
Conflicts: %{name}-free
Provides: %{name}-bin = %{version}-%{release}
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
@@ -531,6 +534,9 @@ cp -pa %{buildroot}%{_libdir}/libavcodec.so.* \
%changelog
+* Sat Jul 20 2024 Neal Gompa <ngompa(a)fedoraproject.org> - 6.1.1-14
+- Backport fixes for Mesa 24.0.6+ / 21.1.4+ changes for VA-API
+
* Sat Jul 20 2024 Leigh Scott <leigh123linux(a)gmail.com> - 6.1.1-13
- rebuilt