From c6310031d044ab53c06cfb9234bcb50a505ad169 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Wed, 19 Jun 2024 13:57:24 +0200 Subject: [PATCH] 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. Gbp-Pq: Name 0085-avcommon-use-a-specific-macro-to-check-the-FFmpeg-li.patch --- 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 ff5dba06..aa0c0b88 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 d0096bc1..3feab3a6 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 +/* 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 830dc015..39d2366c 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 182e9458..664a6467 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; -- 2.30.2