From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 380FC4BF1E for ; Thu, 18 Jul 2024 13:41:28 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4CB7E68DA78; Thu, 18 Jul 2024 16:41:26 +0300 (EEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B6B3E68D97D for ; Thu, 18 Jul 2024 16:41:19 +0300 (EEST) X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.11.12] ([95.33.108.53]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N4hvb-1sNG3N49OJ-00s0tq for ; Thu, 18 Jul 2024 15:41:19 +0200 Message-ID: <5fb71a99-92e3-45b3-9a36-f9fe912b24f5@gmx.net> Date: Thu, 18 Jul 2024 15:41:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <8c6c11a6-bc55-41a0-9f98-262c60f63ec8@gmx.net> <09b1f1e5-4e05-4c99-9451-28be33bfd9ba@gmail.com> <52bcfca2-2666-4c95-927b-d22714568714@gmx.net> Content-Language: en-US In-Reply-To: X-Provags-ID: V03:K1:SovXxbn9Ga7o8H6CZs2hj0HANws1t3H96r7bXgj8PFVQ72SerRr /78HkkuzieiGJhTXHFmr2XPaWdOEFxpj5U0OY7zzYxJsGqaeeQVUgGX6eDQxIrqXwYX67mT seYnstSvhth70NHlJ6H4YAmi/ycgxviZOZmRoO/g3Q4SwQUw00jaZ3zSUmZzhw1WvXH1vkj PUPX+09LMWZRVdTdn4tKw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:OKRa8ICE5Xw=;7qCfvXCCNaak1LVZ7WxE5jpSw7k WNpusCu9kZeYfykiR/e9TwMqgoZivDkDWb7lg506+kEFksFll5EVDnScSM62uxLgoGqur/RJx V0xec3379kYKZQ4x3cMgcamlTIKJS8ZCtAUSlQX6BMCqY9KmhLk6hfOxKZML1oZBFvqlRJx6e dPO8+xaGA3g9z7y5AdZseCgDX0wqx+4at6rBZ0kRhuH4EWQ6FtkBoNn/G/pwhFCzQp6dDlq03 d6hnbYHvHL3X2fhZIi1FPY6Il1OT23q/7kBylVDihPMzoqBM+bVI3qAgxnGxH5s4PK6KKx9Un TAjRGi/IR0JhwSZcanIhgSy1iJB3DaSqa4lQf/yjUI4um8JCpJZPdecgZfwF9EgcrSJl+Y7cK sjOGNszbV02TFlQd2bFeusOhLEuM9pmHyqHoUpQ3OYqNGyIzH4UpLc4bhn4GZxnCxHkkexcsF 9Af+CbtiSSFFg6F0cfjw29dFa+5MkuTjti0jHcoq3tgVNHVzS2nqLTIGb8yO1ji83dGMrjLBs n6bbbNU+qWJFX03yTAFb9HfZfR2+Xt+hJpGT1LiXN45XEsYMZG4h8p5QjX7na8OnRmYqoUxar ntT6VzWumsYx0dg1O0wreWjbqJDkLHgoHEnnUMEKxzIJYMxvliin9nGzYT4JREJC2Yy9ol9/H tqoQ7lJBgTosU+gm5JQCqaNNT275k3LSWjDDzGjHB1A23Ybqsm5lZBD1xoz0CV4alzYMnLtNS xPcLCTT2Hk41wqOoAMGTuo5vIKLb/349iMIFDIVcXY6MBYnxycFD530zFpJVgYqaPOjlEvYua CKXZt0j8h+RRVoHUK7D32U8w== Subject: Re: [FFmpeg-devel] [PATCH v2] libavformat/vapoursynth: Update to API version 4, load library at runtime X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Stefan Oltmanns via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Stefan Oltmanns Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Hi Ramiro, Am 18.07.24 um 15:04 schrieb Ramiro Polla: >>>> [...] >>>> >>>> +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. Yes, that should be possible. I did a quick search at it seems that dlopen()/LoadLibrary() is smart and will not open the same library multiple times, but return the same pointer. As dlclose won't be used anymore when removing the atexit handler, that is not an issue at all. > >> 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. Well, the DLL directory is added to PATH by the VapourSynth installer, but for safety reasons ffmpeg explictly tells the LoadLibrary function to only search the application directory and system32, quote from w32dlfcn.h: > /** > * Safe function used to open dynamic libs. This attempts to improve program security > * by removing the current directory from the dll search path. Only dll's found in the > * executable or system directory are allowed to be loaded. > * @param name The dynamic lib name. > * @return A handle to the opened lib. > */ So ffmpeg prevents that solution on purpose. Or should that behavior be changed in the w32dlfcn.h? Best regards Stefan _______________________________________________ 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".