1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Wed, 19 Jun 2024 13:57:24 +0200
Subject: avcommon: use a specific macro to check the FFmpeg libavformat
version
This macro doesn't check for libav which is assumed to not have to relevant
code. This is the same macro name used in VLC 4.0.
---
modules/codec/avcodec/avcommon.h | 2 +-
modules/codec/avcodec/avcommon_compat.h | 8 ++++++++
modules/demux/avformat/demux.c | 3 +--
modules/demux/avformat/mux.c | 11 ++++-------
4 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/modules/codec/avcodec/avcommon.h b/modules/codec/avcodec/avcommon.h
index ff5dba0..aa0c0b8 100644
--- a/modules/codec/avcodec/avcommon.h
+++ b/modules/codec/avcodec/avcommon.h
@@ -106,7 +106,7 @@ static inline void vlc_init_avformat(vlc_object_t *obj)
avformat_network_init();
-#if (LIBAVFORMAT_VERSION_MICRO < 100) || (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100))
+#if (LIBAVFORMAT_VERSION_MICRO < 100) || !(LIBAVFORMAT_VERSION_CHECK(58, 9, 100))
av_register_all();
#endif
diff --git a/modules/codec/avcodec/avcommon_compat.h b/modules/codec/avcodec/avcommon_compat.h
index d0096bc..3feab3a 100644
--- a/modules/codec/avcodec/avcommon_compat.h
+++ b/modules/codec/avcodec/avcommon_compat.h
@@ -126,6 +126,14 @@
#ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
# include <libavformat/avformat.h>
+/* check the FFmpeg libavformat version */
+#define LIBAVFORMAT_VERSION_CHECK( a, d, e ) \
+ (LIBAVFORMAT_VERSION_MICRO >= 100 && LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT( a, d, e ) )
+
+/* LIBAV_FORMAT_VERSION_CHECK checks for the right libavformat version of libav and FFmpeg
+ * a is the major version
+ * b and c the minor and micro versions of libav
+ * d and e the minor and micro versions of FFmpeg */
#define LIBAV_FORMAT_VERSION_CHECK( a, b, c, d, e ) \
( (LIBAVFORMAT_VERSION_MICRO < 100 && LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT( a, b, c ) ) || \
(LIBAVFORMAT_VERSION_MICRO >= 100 && LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT( a, d, e ) ) )
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 830dc01..39d2366 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -52,8 +52,7 @@
# define HAVE_AVUTIL_CODEC_ATTACHMENT 1
-#if LIBAVFORMAT_VERSION_MICRO >= 100 && \
- LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 0, 100)
+#if LIBAVFORMAT_VERSION_CHECK(59, 0, 100)
# define AVF_MAYBE_CONST const
#else
# define AVF_MAYBE_CONST
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 182e945..664a646 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -95,8 +95,7 @@ int IOWriteTyped(void *opaque, const uint8_t *buf, int buf_size,
*****************************************************************************/
int avformat_OpenMux( vlc_object_t *p_this )
{
-#if LIBAVFORMAT_VERSION_MICRO >= 100 && \
- LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 0, 100)
+#if LIBAVFORMAT_VERSION_CHECK(59, 0, 100)
const AVOutputFormat *file_oformat;
#else
AVOutputFormat *file_oformat;
@@ -104,8 +103,7 @@ int avformat_OpenMux( vlc_object_t *p_this )
sout_mux_t *p_mux = (sout_mux_t*)p_this;
bool dummy = !strcmp( p_mux->p_access->psz_access, "dummy");
-#if ( (LIBAVFORMAT_VERSION_MICRO >= 100) \
- && (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 7, 100)) )
+#if LIBAVFORMAT_VERSION_MICRO >= 100 && !(LIBAVFORMAT_VERSION_CHECK(58, 7, 100))
if( dummy && strlen(p_mux->p_access->psz_path)
>= sizeof (((AVFormatContext *)NULL)->filename) )
return VLC_EGENERIC;
@@ -144,8 +142,7 @@ int avformat_OpenMux( vlc_object_t *p_this )
p_sys->oc->oformat = file_oformat;
/* If we use dummy access, let avformat write output */
if( dummy )
-#if ( (LIBAVFORMAT_VERSION_MICRO >= 100) \
- && (LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 7, 100)) )
+#if LIBAVFORMAT_VERSION_CHECK(58, 7, 100)
p_sys->oc->url = av_strdup(p_mux->p_access->psz_path);
#else
strcpy( p_sys->oc->filename, p_mux->p_access->psz_path );
@@ -397,7 +394,7 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
pkt->dts = p_data->i_dts * p_stream->time_base.den /
CLOCK_FREQ / p_stream->time_base.num;
-#if LIBAVFORMAT_VERSION_MICRO >= 100 && LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59, 2, 103)
+#if LIBAVFORMAT_VERSION_MICRO >= 100 && !(LIBAVFORMAT_VERSION_CHECK(59, 2, 103))
/* this is another hack to prevent libavformat from triggering the "non monotone timestamps" check in avformat/utils.c */
p_stream->cur_dts = ( p_data->i_dts * p_stream->time_base.den /
CLOCK_FREQ / p_stream->time_base.num ) - 1;
|