avcommon: use a specific macro to check the FFmpeg libavformat version
authorSteve Lhomme <robux4@ycbcr.xyz>
Wed, 19 Jun 2024 11:57:24 +0000 (13:57 +0200)
committerSebastian Ramacher <sramacher@debian.org>
Tue, 14 Jan 2025 22:09:47 +0000 (23:09 +0100)
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
modules/codec/avcodec/avcommon_compat.h
modules/demux/avformat/demux.c
modules/demux/avformat/mux.c

index ff5dba06c921070eeddb28b58e694be17cdf8026..aa0c0b88b859acb3a446915621c3035fd0edddbd 100644 (file)
@@ -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
 
index d0096bc1bbb36ecae277c653c4846baba64e37f3..3feab3a657e55f6ace1679c3e9ff782d197de362 100644 (file)
 #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 ) ) )
index 830dc0157e2b7929946b7f856a48ae90c4d1981d..39d2366cef2b1575d926c0add135870e32346751 100644 (file)
@@ -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
index 182e94587ad6bee623d121557e8731c9bcb05c7e..664a646734c0d17eda901170878231cfc72e8553 100644 (file)
@@ -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;