diff mbox series

[FFmpeg-devel] */version.h: define FF_API macros unconditionally

Message ID 20211112133456.11474-1-anton@khirnov.net
State Accepted
Commit db932241ee16868475fe9ab4c958fcffd1829ecf
Headers show
Series [FFmpeg-devel] */version.h: define FF_API macros unconditionally
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Anton Khirnov Nov. 12, 2021, 1:34 p.m. UTC
There is no reason to wrap them in #ifndef guards, they should only be
defined here and nowhere else. The define guards just add the
possibility to accidentally use the same FF_API name in different
libraries.
---
 libavcodec/version.h  | 24 ------------------------
 libavdevice/version.h |  2 --
 libavfilter/version.h |  6 ------
 libavformat/version.h |  8 --------
 libavutil/version.h   |  8 --------
 5 files changed, 48 deletions(-)

Comments

James Almer Nov. 12, 2021, 1:43 p.m. UTC | #1
On 11/12/2021 10:34 AM, Anton Khirnov wrote:
> There is no reason to wrap them in #ifndef guards, they should only be
> defined here and nowhere else. The define guards just add the
> possibility to accidentally use the same FF_API name in different
> libraries.

Should be ok.

We can also later look into adding some sort of static assert to ensure 
it's not already defined, since as is the compiler will warn but keep 
going (Which is better than to silently not do anything because of the 
ifndef check, i guess).

> ---
>   libavcodec/version.h  | 24 ------------------------
>   libavdevice/version.h |  2 --
>   libavfilter/version.h |  6 ------
>   libavformat/version.h |  8 --------
>   libavutil/version.h   |  8 --------
>   5 files changed, 48 deletions(-)
> 
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index 74b8baa5f3..7d4cfa3f11 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -51,41 +51,17 @@
>    * at once through the bump. This improves the git bisect-ability of the change.
>    */
>   
> -#ifndef FF_API_OPENH264_SLICE_MODE
>   #define FF_API_OPENH264_SLICE_MODE (LIBAVCODEC_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_OPENH264_CABAC
>   #define FF_API_OPENH264_CABAC      (LIBAVCODEC_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_UNUSED_CODEC_CAPS
>   #define FF_API_UNUSED_CODEC_CAPS   (LIBAVCODEC_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_THREAD_SAFE_CALLBACKS
>   #define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_DEBUG_MV
>   #define FF_API_DEBUG_MV          (LIBAVCODEC_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_GET_FRAME_CLASS
>   #define FF_API_GET_FRAME_CLASS     (LIBAVCODEC_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_AUTO_THREADS
>   #define FF_API_AUTO_THREADS        (LIBAVCODEC_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_INIT_PACKET
>   #define FF_API_INIT_PACKET         (LIBAVCODEC_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_AVCTX_TIMEBASE
>   #define FF_API_AVCTX_TIMEBASE    (LIBAVCODEC_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_MPEGVIDEO_OPTS
>   #define FF_API_MPEGVIDEO_OPTS      (LIBAVCODEC_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_FLAG_TRUNCATED
>   #define FF_API_FLAG_TRUNCATED      (LIBAVCODEC_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_SUB_TEXT_FORMAT
>   #define FF_API_SUB_TEXT_FORMAT     (LIBAVCODEC_VERSION_MAJOR < 60)
> -#endif
>   
>   #endif /* AVCODEC_VERSION_H */
> diff --git a/libavdevice/version.h b/libavdevice/version.h
> index 8daeb0059a..914e156ec7 100644
> --- a/libavdevice/version.h
> +++ b/libavdevice/version.h
> @@ -46,8 +46,6 @@
>    * dropped at a future version bump. The defines themselves are not part of
>    * the public API and may change, break or disappear at any time.
>    */
> -#ifndef FF_API_DEVICE_CAPABILITIES
>   #define FF_API_DEVICE_CAPABILITIES (LIBAVDEVICE_VERSION_MAJOR < 60)
> -#endif
>   
>   #endif /* AVDEVICE_VERSION_H */
> diff --git a/libavfilter/version.h b/libavfilter/version.h
> index 3bd3816698..24a180d818 100644
> --- a/libavfilter/version.h
> +++ b/libavfilter/version.h
> @@ -50,14 +50,8 @@
>    * the public API and may change, break or disappear at any time.
>    */
>   
> -#ifndef FF_API_SWS_PARAM_OPTION
>   #define FF_API_SWS_PARAM_OPTION             (LIBAVFILTER_VERSION_MAJOR < 9)
> -#endif
> -#ifndef FF_API_BUFFERSINK_ALLOC
>   #define FF_API_BUFFERSINK_ALLOC             (LIBAVFILTER_VERSION_MAJOR < 9)
> -#endif
> -#ifndef FF_API_PAD_COUNT
>   #define FF_API_PAD_COUNT                    (LIBAVFILTER_VERSION_MAJOR < 9)
> -#endif
>   
>   #endif /* AVFILTER_VERSION_H */
> diff --git a/libavformat/version.h b/libavformat/version.h
> index 81ed517609..2e860b8d76 100644
> --- a/libavformat/version.h
> +++ b/libavformat/version.h
> @@ -55,18 +55,10 @@
>    * at once through the bump. This improves the git bisect-ability of the change.
>    *
>    */
> -#ifndef FF_API_LAVF_PRIV_OPT
>   #define FF_API_LAVF_PRIV_OPT            (LIBAVFORMAT_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_COMPUTE_PKT_FIELDS2
>   #define FF_API_COMPUTE_PKT_FIELDS2      (LIBAVFORMAT_VERSION_MAJOR < 60)
> -#endif
> -#ifndef FF_API_AVIOCONTEXT_WRITTEN
>   #define FF_API_AVIOCONTEXT_WRITTEN      (LIBAVFORMAT_VERSION_MAJOR < 60)
> -#endif
>   
>   
> -#ifndef FF_API_R_FRAME_RATE
>   #define FF_API_R_FRAME_RATE            1
> -#endif
>   #endif /* AVFORMAT_VERSION_H */
> diff --git a/libavutil/version.h b/libavutil/version.h
> index eeb33b388c..5ebef06829 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -105,18 +105,10 @@
>    * @{
>    */
>   
> -#ifndef FF_API_D2STR
>   #define FF_API_D2STR                    (LIBAVUTIL_VERSION_MAJOR < 58)
> -#endif
> -#ifndef FF_API_DECLARE_ALIGNED
>   #define FF_API_DECLARE_ALIGNED          (LIBAVUTIL_VERSION_MAJOR < 58)
> -#endif
> -#ifndef FF_API_COLORSPACE_NAME
>   #define FF_API_COLORSPACE_NAME          (LIBAVUTIL_VERSION_MAJOR < 58)
> -#endif
> -#ifndef FF_API_AV_MALLOCZ_ARRAY
>   #define FF_API_AV_MALLOCZ_ARRAY         (LIBAVUTIL_VERSION_MAJOR < 58)
> -#endif
>   
>   /**
>    * @}
>
Hendrik Leppkes Nov. 12, 2021, 1:59 p.m. UTC | #2
On Fri, Nov 12, 2021 at 2:35 PM Anton Khirnov <anton@khirnov.net> wrote:
>
> There is no reason to wrap them in #ifndef guards, they should only be
> defined here and nowhere else. The define guards just add the
> possibility to accidentally use the same FF_API name in different
> libraries.

Wasn't the idea here that I can just define one to true on
commandline/configure to test its removal?
Not sure if anyone really does that anymore, but at least back in the
day that was a thing ... sometimes used.

- Hendrik
Anton Khirnov Nov. 12, 2021, 2:04 p.m. UTC | #3
Quoting Hendrik Leppkes (2021-11-12 14:59:41)
> On Fri, Nov 12, 2021 at 2:35 PM Anton Khirnov <anton@khirnov.net> wrote:
> >
> > There is no reason to wrap them in #ifndef guards, they should only be
> > defined here and nowhere else. The define guards just add the
> > possibility to accidentally use the same FF_API name in different
> > libraries.
> 
> Wasn't the idea here that I can just define one to true on
> commandline/configure to test its removal?
> Not sure if anyone really does that anymore, but at least back in the
> day that was a thing ... sometimes used.

I have never heard of anyone doing that - I always just modify the value
directly when I want to test things.

And I did discover duplicate values during the recent bump, so it's not
a theoretical issue.
Andreas Rheinhardt Nov. 18, 2021, 3:28 a.m. UTC | #4
Anton Khirnov:
> Quoting Hendrik Leppkes (2021-11-12 14:59:41)
>> On Fri, Nov 12, 2021 at 2:35 PM Anton Khirnov <anton@khirnov.net> wrote:
>>>
>>> There is no reason to wrap them in #ifndef guards, they should only be
>>> defined here and nowhere else. The define guards just add the
>>> possibility to accidentally use the same FF_API name in different
>>> libraries.
>>
>> Wasn't the idea here that I can just define one to true on
>> commandline/configure to test its removal?
>> Not sure if anyone really does that anymore, but at least back in the
>> day that was a thing ... sometimes used.
> 
> I have never heard of anyone doing that - I always just modify the value
> directly when I want to test things.
> 

I did this during my preparations for the bump.

> And I did discover duplicate values during the recent bump, so it's not
> a theoretical issue.
> 

Yeah, I stumbled upon that, too.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/version.h b/libavcodec/version.h
index 74b8baa5f3..7d4cfa3f11 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -51,41 +51,17 @@ 
  * at once through the bump. This improves the git bisect-ability of the change.
  */
 
-#ifndef FF_API_OPENH264_SLICE_MODE
 #define FF_API_OPENH264_SLICE_MODE (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_OPENH264_CABAC
 #define FF_API_OPENH264_CABAC      (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_UNUSED_CODEC_CAPS
 #define FF_API_UNUSED_CODEC_CAPS   (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_THREAD_SAFE_CALLBACKS
 #define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_DEBUG_MV
 #define FF_API_DEBUG_MV          (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_GET_FRAME_CLASS
 #define FF_API_GET_FRAME_CLASS     (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_AUTO_THREADS
 #define FF_API_AUTO_THREADS        (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_INIT_PACKET
 #define FF_API_INIT_PACKET         (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_AVCTX_TIMEBASE
 #define FF_API_AVCTX_TIMEBASE    (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_MPEGVIDEO_OPTS
 #define FF_API_MPEGVIDEO_OPTS      (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_FLAG_TRUNCATED
 #define FF_API_FLAG_TRUNCATED      (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_SUB_TEXT_FORMAT
 #define FF_API_SUB_TEXT_FORMAT     (LIBAVCODEC_VERSION_MAJOR < 60)
-#endif
 
 #endif /* AVCODEC_VERSION_H */
diff --git a/libavdevice/version.h b/libavdevice/version.h
index 8daeb0059a..914e156ec7 100644
--- a/libavdevice/version.h
+++ b/libavdevice/version.h
@@ -46,8 +46,6 @@ 
  * dropped at a future version bump. The defines themselves are not part of
  * the public API and may change, break or disappear at any time.
  */
-#ifndef FF_API_DEVICE_CAPABILITIES
 #define FF_API_DEVICE_CAPABILITIES (LIBAVDEVICE_VERSION_MAJOR < 60)
-#endif
 
 #endif /* AVDEVICE_VERSION_H */
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 3bd3816698..24a180d818 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -50,14 +50,8 @@ 
  * the public API and may change, break or disappear at any time.
  */
 
-#ifndef FF_API_SWS_PARAM_OPTION
 #define FF_API_SWS_PARAM_OPTION             (LIBAVFILTER_VERSION_MAJOR < 9)
-#endif
-#ifndef FF_API_BUFFERSINK_ALLOC
 #define FF_API_BUFFERSINK_ALLOC             (LIBAVFILTER_VERSION_MAJOR < 9)
-#endif
-#ifndef FF_API_PAD_COUNT
 #define FF_API_PAD_COUNT                    (LIBAVFILTER_VERSION_MAJOR < 9)
-#endif
 
 #endif /* AVFILTER_VERSION_H */
diff --git a/libavformat/version.h b/libavformat/version.h
index 81ed517609..2e860b8d76 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -55,18 +55,10 @@ 
  * at once through the bump. This improves the git bisect-ability of the change.
  *
  */
-#ifndef FF_API_LAVF_PRIV_OPT
 #define FF_API_LAVF_PRIV_OPT            (LIBAVFORMAT_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_COMPUTE_PKT_FIELDS2
 #define FF_API_COMPUTE_PKT_FIELDS2      (LIBAVFORMAT_VERSION_MAJOR < 60)
-#endif
-#ifndef FF_API_AVIOCONTEXT_WRITTEN
 #define FF_API_AVIOCONTEXT_WRITTEN      (LIBAVFORMAT_VERSION_MAJOR < 60)
-#endif
 
 
-#ifndef FF_API_R_FRAME_RATE
 #define FF_API_R_FRAME_RATE            1
-#endif
 #endif /* AVFORMAT_VERSION_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index eeb33b388c..5ebef06829 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -105,18 +105,10 @@ 
  * @{
  */
 
-#ifndef FF_API_D2STR
 #define FF_API_D2STR                    (LIBAVUTIL_VERSION_MAJOR < 58)
-#endif
-#ifndef FF_API_DECLARE_ALIGNED
 #define FF_API_DECLARE_ALIGNED          (LIBAVUTIL_VERSION_MAJOR < 58)
-#endif
-#ifndef FF_API_COLORSPACE_NAME
 #define FF_API_COLORSPACE_NAME          (LIBAVUTIL_VERSION_MAJOR < 58)
-#endif
-#ifndef FF_API_AV_MALLOCZ_ARRAY
 #define FF_API_AV_MALLOCZ_ARRAY         (LIBAVUTIL_VERSION_MAJOR < 58)
-#endif
 
 /**
  * @}