https://code.videolan.org/videolan/vlc/-/merge_requests/6168 https://code.videolan.org/videolan/vlc/-/merge_requests/6606epel10
parent
7b9cb9e242
commit
db2b332ca1
@ -0,0 +1,82 @@
|
|||||||
|
From a618e31cf209168ae420e95750734a37359969e1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Fran=C3=A7ois=20Cartegnie?= <fcvlcdev@free.fr>
|
||||||
|
Date: Sun, 7 Jul 2024 11:14:05 +0200
|
||||||
|
Subject: [PATCH] mux: avformat: fix avio callbacks signature with ffmpeg 6.1
|
||||||
|
|
||||||
|
API signature changes introduced depending on a positive define,
|
||||||
|
then removed later, making it break prior or post removal...
|
||||||
|
|
||||||
|
(adapted from commit 503c04fad9239420be26d67aab4d5f63c53eb4f7)
|
||||||
|
---
|
||||||
|
modules/codec/avcodec/avcommon_compat.h | 3 +++
|
||||||
|
modules/demux/avformat/mux.c | 18 ++++++++++++++++++
|
||||||
|
2 files changed, 21 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/modules/codec/avcodec/avcommon_compat.h b/modules/codec/avcodec/avcommon_compat.h
|
||||||
|
index 9d16b3dc47d9..561ad83f99f9 100644
|
||||||
|
--- a/modules/codec/avcodec/avcommon_compat.h
|
||||||
|
+++ b/modules/codec/avcodec/avcommon_compat.h
|
||||||
|
@@ -77,6 +77,9 @@
|
||||||
|
#ifndef FF_MAX_B_FRAMES
|
||||||
|
# define FF_MAX_B_FRAMES 16 // FIXME: remove this
|
||||||
|
#endif
|
||||||
|
+#ifndef FF_API_AVIO_WRITE_NONCONST // removed in ffmpeg 7
|
||||||
|
+# define FF_API_AVIO_WRITE_NONCONST (LIBAVFORMAT_VERSION_MAJOR < 61)
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
#endif /* HAVE_LIBAVCODEC_AVCODEC_H */
|
||||||
|
|
||||||
|
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
|
||||||
|
index 8bf8735885f5..033a87bdaaad 100644
|
||||||
|
--- a/modules/demux/avformat/mux.c
|
||||||
|
+++ b/modules/demux/avformat/mux.c
|
||||||
|
@@ -74,11 +74,20 @@ static int AddStream( sout_mux_t *, sout_input_t * );
|
||||||
|
static void DelStream( sout_mux_t *, sout_input_t * );
|
||||||
|
static int Mux ( sout_mux_t * );
|
||||||
|
|
||||||
|
+#if FF_API_AVIO_WRITE_NONCONST
|
||||||
|
static int IOWrite( void *opaque, uint8_t *buf, int buf_size );
|
||||||
|
+#else
|
||||||
|
+static int IOWrite( void *opaque, const uint8_t *buf, int buf_size );
|
||||||
|
+#endif
|
||||||
|
static int64_t IOSeek( void *opaque, int64_t offset, int whence );
|
||||||
|
#if LIBAVFORMAT_VERSION_CHECK( 57, 7, 0, 40, 100 )
|
||||||
|
+# if FF_API_AVIO_WRITE_NONCONST
|
||||||
|
static int IOWriteTyped(void *opaque, uint8_t *buf, int buf_size,
|
||||||
|
enum AVIODataMarkerType type, int64_t time);
|
||||||
|
+# else
|
||||||
|
+int IOWriteTyped(void *opaque, const uint8_t *buf, int buf_size,
|
||||||
|
+ enum AVIODataMarkerType type, int64_t time);
|
||||||
|
+# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
@@ -411,8 +420,13 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LIBAVFORMAT_VERSION_CHECK( 57, 7, 0, 40, 100 )
|
||||||
|
+# if FF_API_AVIO_WRITE_NONCONST
|
||||||
|
int IOWriteTyped(void *opaque, uint8_t *buf, int buf_size,
|
||||||
|
enum AVIODataMarkerType type, int64_t time)
|
||||||
|
+# else
|
||||||
|
+int IOWriteTyped(void *opaque, const uint8_t *buf, int buf_size,
|
||||||
|
+ enum AVIODataMarkerType type, int64_t time)
|
||||||
|
+# endif
|
||||||
|
{
|
||||||
|
VLC_UNUSED(time);
|
||||||
|
|
||||||
|
@@ -512,7 +526,11 @@ static int Control( sout_mux_t *p_mux, int i_query, va_list args )
|
||||||
|
/*****************************************************************************
|
||||||
|
* I/O wrappers for libavformat
|
||||||
|
*****************************************************************************/
|
||||||
|
+#if FF_API_AVIO_WRITE_NONCONST
|
||||||
|
static int IOWrite( void *opaque, uint8_t *buf, int buf_size )
|
||||||
|
+#else
|
||||||
|
+static int IOWrite( void *opaque, const uint8_t *buf, int buf_size )
|
||||||
|
+#endif
|
||||||
|
{
|
||||||
|
sout_mux_t *p_mux = opaque;
|
||||||
|
sout_mux_sys_t *p_sys = p_mux->p_sys;
|
||||||
|
--
|
||||||
|
GitLab
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,149 @@
|
|||||||
|
From ba5dc03aecc1d96f81b76838f845ebde7348cf62 Mon Sep 17 00:00:00 2001
|
||||||
|
From: David Rosca <nowrep@gmail.com>
|
||||||
|
Date: Fri, 20 Dec 2024 20:24:36 +0100
|
||||||
|
Subject: [PATCH] avcodec: vaapi: Support VAAPI with latest FFmpeg
|
||||||
|
|
||||||
|
---
|
||||||
|
configure.ac | 20 +------------
|
||||||
|
modules/codec/Makefile.am | 2 +-
|
||||||
|
modules/codec/avcodec/avcommon_compat.h | 3 ++
|
||||||
|
modules/codec/avcodec/vaapi.c | 38 +++++++++++++++++++++++--
|
||||||
|
4 files changed, 41 insertions(+), 22 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/configure.ac b/configure.ac
|
||||||
|
index 00afb063c455..089339e10e0b 100644
|
||||||
|
--- a/configure.ac
|
||||||
|
+++ b/configure.ac
|
||||||
|
@@ -2550,25 +2550,7 @@ AM_CONDITIONAL([HAVE_VAAPI], [test "${have_vaapi}" = "yes"])
|
||||||
|
AM_CONDITIONAL([HAVE_VAAPI_DRM], [test "${have_vaapi_drm}" = "yes"])
|
||||||
|
AM_CONDITIONAL([HAVE_VAAPI_X11], [test "${have_vaapi_x11}" = "yes"])
|
||||||
|
AM_CONDITIONAL([HAVE_VAAPI_WL], [test "${have_vaapi_wl}" = "yes"])
|
||||||
|
-
|
||||||
|
-have_avcodec_vaapi="no"
|
||||||
|
-AS_IF([test "${have_vaapi}" = "yes" -a "${have_avcodec}" = "yes"], [
|
||||||
|
- VLC_SAVE_FLAGS
|
||||||
|
- CPPFLAGS="${CPPFLAGS} ${AVCODEC_CFLAGS}"
|
||||||
|
- CFLAGS="${CFLAGS} ${AVCODEC_CFLAGS}"
|
||||||
|
- AC_CHECK_HEADERS([libavcodec/vaapi.h], [
|
||||||
|
- AC_MSG_NOTICE([VA API acceleration activated])
|
||||||
|
- have_avcodec_vaapi="yes"
|
||||||
|
- ],[
|
||||||
|
- AS_IF([test -n "${enable_libva}"], [
|
||||||
|
- AC_MSG_ERROR([libva is present but libavcodec/vaapi.h is missing])
|
||||||
|
- ], [
|
||||||
|
- AC_MSG_WARN([libva is present but libavcodec/vaapi.h is missing ])
|
||||||
|
- ])
|
||||||
|
- ])
|
||||||
|
- VLC_RESTORE_FLAGS
|
||||||
|
-])
|
||||||
|
-AM_CONDITIONAL([HAVE_AVCODEC_VAAPI], [test "${have_avcodec_vaapi}" = "yes"])
|
||||||
|
+AM_CONDITIONAL([HAVE_AVCODEC_VAAPI], [test "${have_vaapi}" = "yes" -a "${have_avcodec}" = "yes"])
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl dxva2 needs avcodec
|
||||||
|
diff --git a/modules/codec/Makefile.am b/modules/codec/Makefile.am
|
||||||
|
index 6d9465fdaef9..dd04391c1bf7 100644
|
||||||
|
--- a/modules/codec/Makefile.am
|
||||||
|
+++ b/modules/codec/Makefile.am
|
||||||
|
@@ -416,7 +416,7 @@ libvaapi_plugin_la_SOURCES = \
|
||||||
|
codec/avcodec/vaapi.c hw/vaapi/vlc_vaapi.c hw/vaapi/vlc_vaapi.h
|
||||||
|
libvaapi_plugin_la_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
|
libvaapi_plugin_la_CFLAGS = $(AM_CFLAGS) $(AVCODEC_CFLAGS)
|
||||||
|
-libvaapi_plugin_la_LIBADD = $(LIBVA_LIBS)
|
||||||
|
+libvaapi_plugin_la_LIBADD = $(LIBVA_LIBS) $(AVCODEC_LIBS)
|
||||||
|
if HAVE_AVCODEC_VAAPI
|
||||||
|
if HAVE_VAAPI_DRM
|
||||||
|
codec_LTLIBRARIES += libvaapi_drm_plugin.la
|
||||||
|
diff --git a/modules/codec/avcodec/avcommon_compat.h b/modules/codec/avcodec/avcommon_compat.h
|
||||||
|
index ac02c06d2339..8ab6910f3250 100644
|
||||||
|
--- a/modules/codec/avcodec/avcommon_compat.h
|
||||||
|
+++ b/modules/codec/avcodec/avcommon_compat.h
|
||||||
|
@@ -84,6 +84,9 @@
|
||||||
|
#ifndef FF_API_AVIO_WRITE_NONCONST // removed in ffmpeg 7
|
||||||
|
# define FF_API_AVIO_WRITE_NONCONST (LIBAVFORMAT_VERSION_MAJOR < 61)
|
||||||
|
#endif
|
||||||
|
+#ifndef FF_API_STRUCT_VAAPI_CONTEXT
|
||||||
|
+# define FF_API_STRUCT_VAAPI_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
#endif /* HAVE_LIBAVCODEC_AVCODEC_H */
|
||||||
|
|
||||||
|
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
|
||||||
|
index c83269e43f30..e203baaf9ee2 100644
|
||||||
|
--- a/modules/codec/avcodec/vaapi.c
|
||||||
|
+++ b/modules/codec/avcodec/vaapi.c
|
||||||
|
@@ -42,12 +42,25 @@
|
||||||
|
# include <va/va_drm.h>
|
||||||
|
#endif
|
||||||
|
#include <libavcodec/avcodec.h>
|
||||||
|
+#if FF_API_STRUCT_VAAPI_CONTEXT
|
||||||
|
#include <libavcodec/vaapi.h>
|
||||||
|
+#else
|
||||||
|
+#include <libavutil/hwcontext_vaapi.h>
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
#include "avcodec.h"
|
||||||
|
#include "va.h"
|
||||||
|
#include "../../hw/vaapi/vlc_vaapi.h"
|
||||||
|
|
||||||
|
+#if !FF_API_STRUCT_VAAPI_CONTEXT
|
||||||
|
+struct vaapi_context
|
||||||
|
+{
|
||||||
|
+ VADisplay display;
|
||||||
|
+ VAConfigID config_id;
|
||||||
|
+ VAContextID context_id;
|
||||||
|
+};
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
struct vlc_va_sys_t
|
||||||
|
{
|
||||||
|
struct vlc_vaapi_instance *va_inst;
|
||||||
|
@@ -145,8 +158,10 @@ static void Delete(vlc_va_t *va, void **hwctx)
|
||||||
|
|
||||||
|
(void) hwctx;
|
||||||
|
|
||||||
|
- vlc_vaapi_DestroyContext(o, sys->hw_ctx.display, sys->hw_ctx.context_id);
|
||||||
|
- vlc_vaapi_DestroyConfig(o, sys->hw_ctx.display, sys->hw_ctx.config_id);
|
||||||
|
+ if (sys->hw_ctx.context_id != VA_INVALID_ID)
|
||||||
|
+ vlc_vaapi_DestroyContext(o, sys->hw_ctx.display, sys->hw_ctx.context_id);
|
||||||
|
+ if (sys->hw_ctx.config_id != VA_INVALID_ID)
|
||||||
|
+ vlc_vaapi_DestroyConfig(o, sys->hw_ctx.display, sys->hw_ctx.config_id);
|
||||||
|
vlc_vaapi_ReleaseInstance(sys->va_inst);
|
||||||
|
free(sys);
|
||||||
|
}
|
||||||
|
@@ -196,6 +211,7 @@ static int Create(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *d
|
||||||
|
sys->hw_ctx.config_id = VA_INVALID_ID;
|
||||||
|
sys->hw_ctx.context_id = VA_INVALID_ID;
|
||||||
|
|
||||||
|
+#if FF_API_STRUCT_VAAPI_CONTEXT
|
||||||
|
sys->hw_ctx.config_id =
|
||||||
|
vlc_vaapi_CreateConfigChecked(o, sys->hw_ctx.display, i_profile,
|
||||||
|
VAEntrypointVLD, i_vlc_chroma);
|
||||||
|
@@ -211,6 +227,24 @@ static int Create(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *d
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
ctx->hwaccel_context = &sys->hw_ctx;
|
||||||
|
+#else
|
||||||
|
+ AVBufferRef *hwdev_ref = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VAAPI);
|
||||||
|
+ if (hwdev_ref == NULL)
|
||||||
|
+ goto error;
|
||||||
|
+
|
||||||
|
+ AVHWDeviceContext *hwdev_ctx = (void *) hwdev_ref->data;
|
||||||
|
+ AVVAAPIDeviceContext *vadev_ctx = hwdev_ctx->hwctx;
|
||||||
|
+ vadev_ctx->display = va_dpy;
|
||||||
|
+
|
||||||
|
+ if (av_hwdevice_ctx_init(hwdev_ref) < 0)
|
||||||
|
+ {
|
||||||
|
+ av_buffer_unref(&hwdev_ref);
|
||||||
|
+ goto error;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ctx->hw_device_ctx = hwdev_ref;
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
va->sys = sys;
|
||||||
|
va->description = vaQueryVendorString(sys->hw_ctx.display);
|
||||||
|
va->get = Get;
|
||||||
|
--
|
||||||
|
GitLab
|
||||||
|
|
@ -1,18 +0,0 @@
|
|||||||
avcodec_vaapi requires ffmpeg-4, but other vaapi modules can be built
|
|
||||||
|
|
||||||
diff --git a/configure.ac b/configure.ac
|
|
||||||
index 69beb77..c7f7142 100644
|
|
||||||
--- a/configure.ac
|
|
||||||
+++ b/configure.ac
|
|
||||||
@@ -2454,9 +2454,9 @@ AS_IF([test "${have_vaapi}" = "yes" -a "${have_avcodec}" = "yes"], [
|
|
||||||
have_avcodec_vaapi="yes"
|
|
||||||
],[
|
|
||||||
AS_IF([test -n "${enable_libva}"], [
|
|
||||||
- AC_MSG_ERROR([libva is present but libavcodec/vaapi.h is missing])
|
|
||||||
+ AC_MSG_WARN([libva is present but libavcodec/vaapi.h is missing])
|
|
||||||
], [
|
|
||||||
- AC_MSG_WARN([libva is present but libavcodec/vaapi.h is missing ])
|
|
||||||
+ AC_MSG_NOTICE([libva is present but libavcodec/vaapi.h is missing ])
|
|
||||||
])
|
|
||||||
])
|
|
||||||
VLC_RESTORE_FLAGS
|
|
Loading…
Reference in new issue