Skip to content
This repository has been archived by the owner on Apr 15, 2022. It is now read-only.

Commit

Permalink
VapourSynth: add lsmas.Version for better version transparency
Browse files Browse the repository at this point in the history
Signed-off-by: akarin <i@akarin.info>
  • Loading branch information
AkarinVS committed Jun 22, 2021
1 parent e611793 commit 2c7cbb3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
8 changes: 8 additions & 0 deletions VapourSynth/README
Expand Up @@ -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.

26 changes: 26 additions & 0 deletions VapourSynth/lsmashsource.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
11 changes: 10 additions & 1 deletion VapourSynth/meson.build
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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')
Expand Down
5 changes: 5 additions & 0 deletions 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) "\"";

0 comments on commit 2c7cbb3

Please sign in to comment.