Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [RFC] avdevice: lock to minor version of avformat
Date: Mon, 3 Jan 2022 10:48:50 +0100
Message-ID: <AM7PR03MB66600AAA819A8D34F0BAFF448F499@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw)
In-Reply-To: <CABcAi1imep=4aF-G496gbi8E36x3Uk_6DPySYorOQ_fQKuGNXw@mail.gmail.com>

Diederick C. Niehorster:
> FWIW, the macro
> #define AV_MAKE_MAJOR_MINOR_FUNC_NAME(name,major,minor)
> AV_GLUE(av,name)AV_GLUE(_version_,major)AV_GLUE(_,minor)
> doesn't compile on patchwork
> (https://patchwork.ffmpeg.org/check/49062/), but worked fine for me on
> MSVC. Is MSVC non-compliant somehow? Suggestions appreciated, I'm no
> star in C macros.
> 

AV_GLUE(av,name)AV_GLUE(_version_,major)AV_GLUE(_,minor) will yield
three preprocessor tokens after macro expansion, one for each AV_GLUE.
There will be no whitespace between them and yet they are different
preprocessor tokens. After the preprocessor has been run, these
preprocessor tokens are directly converted into tokens; there is no
"rescan" that joins preprocessor tokens that are not separated by
whitespace (and therefore appear to you to be a single token). And
therefore the result is incompliant.
It seems like MSVC does such a rescan, but the specs allow a compiler to
omit it (and GCC apparently does so).

> In any case, this is a discussion starter, so let it not compiling not
> hold us back from that.
> 
> Cheers,
> Dee
> 
> On Sun, Dec 26, 2021 at 6:17 PM Diederick Niehorster <dcnieho@gmail.com> wrote:
>>
>> As per discussion on the list (
>> https://ffmpeg.org/pipermail/ffmpeg-devel/2021-June/281513.html, see
>> especially https://ffmpeg.org/pipermail/ffmpeg-devel/2021-June/281586.html),
>> to resolve the the unholy ABI-relationship between libavdevice and
>> libavformat and allow easier working on the part of the avdevice API
>> that lives in avformat, lock avdevice to a specific major and minor
>> version of avformat.
>>
>> Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
>> ---
>>  libavdevice/avdevice.c | 10 ++++++++++
>>  libavdevice/version.h  | 10 ++++++++++
>>  libavformat/utils.c    |  5 +++++
>>  libavformat/version.h  | 11 +++++++++++
>>  libavutil/macros.h     |  2 ++
>>  5 files changed, 38 insertions(+)
>>
>> diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
>> index 8f460c7564..b608ec532f 100644
>> --- a/libavdevice/avdevice.c
>> +++ b/libavdevice/avdevice.c
>> @@ -38,6 +38,16 @@ unsigned avdevice_version(void)
>>      return LIBAVDEVICE_VERSION_INT;
>>  }
>>
>> +unsigned avdevice_version_same_minor()
>> +{
>> +    // check version of loaded lavf has same major and minor version as
>> +    // this library was compiled against
>> +    if ((avformat_version_same_minor()) & ~0xFF != (LIBAVFORMAT_VERSION_INT & ~0xFF))
>> +        abort();
>> +
>> +    return avformat_version();
>> +}
>> +
>>  const char * avdevice_configuration(void)
>>  {
>>      return FFMPEG_CONFIGURATION;
>> diff --git a/libavdevice/version.h b/libavdevice/version.h
>> index 41f568d6b0..4c511a7f53 100644
>> --- a/libavdevice/version.h
>> +++ b/libavdevice/version.h
>> @@ -26,6 +26,7 @@
>>   */
>>
>>  #include "libavutil/version.h"
>> +#include "libavutil/macros.h"
>>
>>  #define LIBAVDEVICE_VERSION_MAJOR  59
>>  #define LIBAVDEVICE_VERSION_MINOR   1
>> @@ -48,4 +49,13 @@
>>   */
>>  #define FF_API_DEVICE_CAPABILITIES (LIBAVDEVICE_VERSION_MAJOR < 60)
>>
>> +/**
>> + * avdevice_version_same_minor() expands to a function with
>> + * the same minor and major version it was compiled against
>> + * encoded in it. Enables linking locking to the minor version
>> + * of other libraries they were compiled against.
>> + */
>> +#define avdevice_version_same_minor AV_MAKE_MAJOR_MINOR_FUNC_NAME(device,LIBAVFORMAT_VERSION_MAJOR,LIBAVFORMAT_VERSION_MINOR)
>> +unsigned avdevice_version_same_minor();
>> +
>>  #endif /* AVDEVICE_VERSION_H */
>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>> index 332ba534d2..607a777c3f 100644
>> --- a/libavformat/utils.c
>> +++ b/libavformat/utils.c
>> @@ -63,6 +63,11 @@ unsigned avformat_version(void)
>>      return LIBAVFORMAT_VERSION_INT;
>>  }
>>
>> +unsigned avformat_version_same_minor()
>> +{
>> +    return avformat_version();
>> +}
>> +
>>  const char *avformat_configuration(void)
>>  {
>>      return FFMPEG_CONFIGURATION;
>> diff --git a/libavformat/version.h b/libavformat/version.h
>> index 379a68cc7c..2423800687 100644
>> --- a/libavformat/version.h
>> +++ b/libavformat/version.h
>> @@ -28,6 +28,7 @@
>>   */
>>
>>  #include "libavutil/version.h"
>> +#include "libavutil/macros.h"
>>
>>  // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
>>  // Also please add any ticket numbers that you believe might be affected here
>> @@ -63,4 +64,14 @@
>>
>>
>>  #define FF_API_R_FRAME_RATE            1
>> +
>> +/**
>> + * avformat_version_same_minor() expands to a function with
>> + * the same minor and major version it was compiled against
>> + * encoded in it. Enables linking locking to the minor version
>> + * of other libraries they were compiled against.
>> + */
>> +#define avformat_version_same_minor AV_MAKE_MAJOR_MINOR_FUNC_NAME(format,LIBAVFORMAT_VERSION_MAJOR,LIBAVFORMAT_VERSION_MINOR)
>> +unsigned avformat_version_same_minor();
>> +
>>  #endif /* AVFORMAT_VERSION_H */
>> diff --git a/libavutil/macros.h b/libavutil/macros.h
>> index 2a7567c3ea..dda1bf6452 100644
>> --- a/libavutil/macros.h
>> +++ b/libavutil/macros.h
>> @@ -73,6 +73,8 @@
>>   * @}
>>   */
>>
>> +#define AV_MAKE_MAJOR_MINOR_FUNC_NAME(name,major,minor) AV_GLUE(av,name)AV_GLUE(_version_,major)AV_GLUE(_,minor)
>> +
>>  #define AV_PRAGMA(s) _Pragma(#s)
>>
>>  #define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
>> --
>> 2.28.0.windows.1
>>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

      reply	other threads:[~2022-01-03  9:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-26 17:16 Diederick Niehorster
2021-12-28 13:19 ` Diederick C. Niehorster
2022-01-03  9:48   ` Andreas Rheinhardt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM7PR03MB66600AAA819A8D34F0BAFF448F499@AM7PR03MB6660.eurprd03.prod.outlook.com \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git