Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Ramiro Polla <ramiro.polla@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v2] libavformat/vapoursynth: Update to API version 4, load library at runtime
Date: Thu, 18 Jul 2024 15:04:43 +0200
Message-ID: <CALweWgCn_qbR-m6WrqiYhm8+54Fb8W1Bcfe36RwZ-BJ2g9Cc4w@mail.gmail.com> (raw)
In-Reply-To: <52bcfca2-2666-4c95-927b-d22714568714@gmx.net>

On Thu, Jul 18, 2024 at 2:48 PM Stefan Oltmanns via ffmpeg-devel
<ffmpeg-devel@ffmpeg.org> wrote:
> Am 18.07.24 um 13:08 schrieb Ramiro Polla:
> >>  [...]
> >> +
> >> +#include <vapoursynth/VSScript4.h>
> >> +
> >>  struct VSState {
> >>      VSScript *vss;
> >>  };
> >>
> >> +typedef const VSSCRIPTAPI *(*VSScriptGetAPIFunc)(int version);
> >> +
> >> +typedef struct VSScriptLibrary {
> >> +    void *library;
> >> +    const VSSCRIPTAPI *vssapi;
> >> +} VSScriptLibrary;
> >> +
> >>  typedef struct VSContext {
> >>      const AVClass *class;
> >>
> >>      AVBufferRef *vss_state;
> >>
> >>      const VSAPI *vsapi;
> >> -    VSCore *vscore;
> >>
> >> -    VSNodeRef *outnode;
> >> +    VSNode *outnode;
> >>      int is_cfr;
> >>      int current_frame;
> >>
> >> @@ -70,19 +94,72 @@ static const AVOption options[] = {
> >>      {NULL}
> >>  };
> >>
> >> +static VSScriptLibrary vs_script_library;
> >
> > Does vs_script_library have to be a global?
> >
>
> I think it has to: ffmpeg allows multiple input files, in case you open
> two VapourSynth files you want to load the Library only once.

It should be possible to dlopen()/LoadLibrary() multiple times, and
the library only gets really unloaded after the last call to
dlclose()/FreeLibrary(). In that case you could move that struct to
the context. If it's unavoidable to keep the global, at least add some
locks to access it.

> This is exactly how it's done for AviSynth.

Perhaps AviSynth is not the best example to follow :)

> >> +
> >> +static int vs_atexit_called = 0;
> >> +
> >> +static av_cold void vs_atexit_handler(void);
> >> +
> >> +#ifdef _WIN32
> >> +static av_cold char* get_vs_script_dll_name(void) {
> >> +     LONG r;
> >> +     WCHAR vss_path[512];
> >> +     char *vss_path_utf8;
> >> +     DWORD buf_size = sizeof(vss_path) - 2;
> >> +     r = RegGetValueW(HKEY_CURRENT_USER, L"SOFTWARE\\VapourSynth",
> >> +                      L"VSScriptDLL", RRF_RT_REG_SZ, NULL,
> >> +                      &vss_path, &buf_size);
> >> +     if (r == ERROR_SUCCESS && wchartoutf8(vss_path, &vss_path_utf8)
> >> == 0)
> >> +         return vss_path_utf8;
> >> +     r = RegGetValueW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\VapourSynth",
> >> +                      L"VSScriptDLL", RRF_RT_REG_SZ, NULL,
> >> +                      &vss_path, &buf_size);
> >> +     if (r == ERROR_SUCCESS && wchartoutf8(vss_path, &vss_path_utf8)
> >> == 0)
> >> +         return vss_path_utf8;
> >> +     if (wchartoutf8(L"VSScript.dll", &vss_path_utf8) == 0)
> >> +         return vss_path_utf8;
> >> +     return 0;
> >> +}
> >> +#endif
> >
> > Don't fetch the path on the registry on Windows. The user should set the
> > path outside of FFmpeg.
>
> How exactly should the user do that? Additional option to ffmpeg?

By making sure the libraries are accessible in the PATH environment
variable. For example by adding the VapourSynth path to the PATH
environment variable, or overriding PATH on the call to FFmpeg on a
script. Either way that's outside the scope of FFmpeg.

> Fetching the path from the registry is the recommended method by the
> VaopourSynth author.

Sometimes the recommended method isn't necessarily the best method...

> Would it be an acceptable way to move the registry stuff to the Windows
> specific area (where for example the LoadLibrary stuff is) and create a
> function to get a UTF-8 string from the registry, so that there is no
> Windows-style code in the VapourSynth module?

It's best to just remove it.

[...]

Regards,
Ramiro
_______________________________________________
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:[~2024-07-18 13:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-06 21:08 Stefan Oltmanns via ffmpeg-devel
2024-07-18  9:37 ` Stefan Oltmanns via ffmpeg-devel
2024-07-18 11:25   ` Anton Khirnov
2024-07-18 15:38     ` Stefan Oltmanns via ffmpeg-devel
2024-07-22  6:57       ` Anton Khirnov
2024-07-23  0:24         ` Stefan Oltmanns via ffmpeg-devel
2024-07-18 11:08 ` Ramiro Polla
2024-07-18 12:48   ` Stefan Oltmanns via ffmpeg-devel
2024-07-18 13:04     ` Ramiro Polla [this message]
2024-07-18 13:41       ` Stefan Oltmanns via ffmpeg-devel
2024-07-18 14:21         ` Ramiro Polla
2024-07-18 14:53           ` Stefan Oltmanns via ffmpeg-devel
2024-07-19 17:05             ` Stephen Hutchinson
2024-07-18 15:23           ` epirat07
2024-07-21 22:08             ` Stefan Oltmanns via ffmpeg-devel
2024-07-21 22:15               ` Hendrik Leppkes
2024-07-22  0:42                 ` Stefan Oltmanns via ffmpeg-devel
2024-07-22  6:36                   ` Hendrik Leppkes
2024-07-22 12:13                 ` Ramiro Polla
2024-07-22 13:41                   ` Hendrik Leppkes
2024-07-22 18:28                     ` Ramiro Polla
2024-07-22 13:52                   ` Stefan Oltmanns via ffmpeg-devel

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=CALweWgCn_qbR-m6WrqiYhm8+54Fb8W1Bcfe36RwZ-BJ2g9Cc4w@mail.gmail.com \
    --to=ramiro.polla@gmail.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