From 2c7cbb30dcda4727ae01084730084e14dcfa0519 Mon Sep 17 00:00:00 2001 From: akarin Date: Tue, 22 Jun 2021 18:52:16 -0400 Subject: [PATCH] VapourSynth: add lsmas.Version for better version transparency Signed-off-by: akarin --- VapourSynth/README | 8 ++++++++ VapourSynth/lsmashsource.c | 26 ++++++++++++++++++++++++++ VapourSynth/meson.build | 11 ++++++++++- VapourSynth/version.h.in | 5 +++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 VapourSynth/version.h.in diff --git a/VapourSynth/README b/VapourSynth/README index d56e4e9e..43e1e2eb 100644 --- a/VapourSynth/README +++ b/VapourSynth/README @@ -170,3 +170,11 @@ Same as 'ff_loglevel' of LibavSMASHSource(). + cachedir (default : DEFAULT_CACHEDIR) Create *.lwi file under this directory with names encoding the full path to avoid collisions. Set to "" to restore the previous behavior (storing *.lwi along side the source video file). + + [Version] + Version() + * This function returns a dict containing the following keys: + + version: lsmas version + + config: extra configuration options used during meson build. + + ffmpeg_version: the ffmpeg version used. + diff --git a/VapourSynth/lsmashsource.c b/VapourSynth/lsmashsource.c index 15923d71..368dc9f7 100644 --- a/VapourSynth/lsmashsource.c +++ b/VapourSynth/lsmashsource.c @@ -29,6 +29,13 @@ #include "lsmashsource.h" +#include "libavutil/ffversion.h" +#include "libavcodec/version.h" +#include "libavformat/version.h" +#include "libavutil/version.h" +#include "libswscale/version.h" +#include "version.h" + void set_error ( lw_log_handler_t *lhp, @@ -64,6 +71,17 @@ void set_error_on_init extern void VS_CC vs_libavsmashsource_create( const VSMap *in, VSMap *out, void *user_data, VSCore *core, const VSAPI *vsapi ); extern void VS_CC vs_lwlibavsource_create( const VSMap *in, VSMap *out, void *user_data, VSCore *core, const VSAPI *vsapi ); +void VS_CC vs_version_create( const VSMap *in, VSMap *out, void *user_data, VSCore *core, const VSAPI *vsapi ) +{ + vsapi->propSetData(out, "version", VERSION, -1, paAppend); + vsapi->propSetData(out, "config", config_opts, -1, paAppend); + vsapi->propSetData(out, "ffmpeg_version", FFMPEG_VERSION, -1, paAppend); + vsapi->propSetData(out, "ffmpeg_version", LIBAVCODEC_IDENT, -1, paAppend); + vsapi->propSetData(out, "ffmpeg_version", LIBAVFORMAT_IDENT, -1, paAppend); + vsapi->propSetData(out, "ffmpeg_version", LIBAVUTIL_IDENT, -1, paAppend); + vsapi->propSetData(out, "ffmpeg_version", LIBSWSCALE_IDENT, -1, paAppend); +} + VS_EXTERNAL_API(void) VapourSynthPluginInit( VSConfigPlugin config_func, VSRegisterFunction register_func, VSPlugin *plugin ) { config_func @@ -92,5 +110,13 @@ VS_EXTERNAL_API(void) VapourSynthPluginInit( VSConfigPlugin config_func, VSRegis NULL, plugin ); + register_func + ( + "Version", + "", + vs_version_create, + NULL, + plugin + ); #undef COMMON_OPTS } diff --git a/VapourSynth/meson.build b/VapourSynth/meson.build index d245b7f6..bfeb871b 100644 --- a/VapourSynth/meson.build +++ b/VapourSynth/meson.build @@ -3,6 +3,14 @@ project('L-SMASH-Works', 'c', meson_version: '>=0.48.0' ) +version_h = declare_dependency( + sources: vcs_tag( + command: ['git', 'describe', '--tags', '--long'], + input: 'version.h.in', + output: 'version.h' + ) +) + add_project_arguments('-DXXH_INLINE_ALL', '-D_FILE_OFFSET_BITS=64', '-DDEFAULT_CACHEDIR=' + get_option('cachedir'), language: 'c') sources = [ @@ -44,7 +52,8 @@ deps = [ dependency('libavcodec', version: '>=58.91.0'), dependency('libavformat', version: '>=58.45.0'), dependency('libavutil', version: '>=56.51.0'), - dependency('libswscale', version: '>=5.7.0') + dependency('libswscale', version: '>=5.7.0'), + version_h ] if host_machine.cpu_family().startswith('x86') diff --git a/VapourSynth/version.h.in b/VapourSynth/version.h.in new file mode 100644 index 00000000..9eb43d75 --- /dev/null +++ b/VapourSynth/version.h.in @@ -0,0 +1,5 @@ +#define VERSION "@VCS_TAG@" + +#define STRINGIFY_(x) #x +#define STRINGIFY(x) STRINGIFY_(x) +static const char *config_opts = "-Dcachedir=\"" STRINGIFY(DEFAULT_CACHEDIR) "\"";