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 1946F4C4D2 for ; Sun, 28 Jul 2024 13:16:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C194A68D827; Sun, 28 Jul 2024 16:16:07 +0300 (EEST) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C4F3768D63B for ; Sun, 28 Jul 2024 16:16:00 +0300 (EEST) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-52efbc57456so2761976e87.1 for ; Sun, 28 Jul 2024 06:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722172559; x=1722777359; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=0dBevItwvy0RrqMBqvPvgyeClMj3OopxCfMQ6ah4Jfo=; b=T1HqWB3Zm5275GQi/tmSTETQ9CE53xrBrRsv3wlfe+wmveQ24zPqt4uDEzoFMpIruR pNsZLFUcMF0dUuJ5kUUxW2T/AMO827Ksoi/BWrFBBukUmTmGRYGW8rO+2weKFcne7g6Y efeZ5WGeKmvb2DJw9OCmMqDHr8Oi9DWIGZ4EzJl2pUluoo9NHJtHICsi9ypDbvs999Yy RWOnCg6e+1Nk7YV3JUEVG6dLYh3IURTN2Kovh/Yg73qC6+i+MZYhTtJLm/AF0Cv1pTRO gVqz/qsK+j3g7mwyXyYDq629kVi2q4JkQBRa8n8+P8uYVT83Z6DNXGO2q7YN+sn93Png HIog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722172559; x=1722777359; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0dBevItwvy0RrqMBqvPvgyeClMj3OopxCfMQ6ah4Jfo=; b=AzcXJDg5t+X+SE95OUPQIdZvA7cQNmA3BgtLoQdAKPx61oPJwFaJVhTdjxZ8HjzTq2 njd9xaJmseV/nssj3vPKKkqQj+4IoewdmJ6mOZaojSjnyqh80Zd1ZA6p82ypTuC/dR+X /pFFJog/TIqh6/wx0u925kOUx9VloDbq1V9ASGVYXsT40iF/lXDcvJRavEeMP3UR6B3L wVINEqBv4HJwqTqWb1HCc0r3CcG8/MU6213QquT64Rq7VGaxKkrpxkc1PqdzpTMP8+I5 8Afuash9uJIs63BRFBM5766WVSfySpqrsDa4rDEhsnl0f21ceUts1Nc+nP6JztwcnpuN pAQA== X-Gm-Message-State: AOJu0YwPI6x38rqkplWmaBNxx8zN+Y7Ityrazxx9QWc/pwe1Si7YKWNh JtiFvfVTbto5niS2lUF166va5unrUEuz8/3SsJJ1Fp0FH5jLYalDgmjwme7BBxc= X-Google-Smtp-Source: AGHT+IHPy8y+VJHz397qIgqbXVEnuwaLnf0Ezr5svENnzFLvg1Yji0rJ1m1NILyoNDPkq3h9l++Jpw== X-Received: by 2002:a05:6512:210f:b0:52e:941d:7039 with SMTP id 2adb3069b0e04-5309b2ce6afmr3270354e87.59.1722172559018; Sun, 28 Jul 2024 06:15:59 -0700 (PDT) Received: from [192.168.178.81] (dslb-088-072-175-225.088.072.pools.vodafone-ip.de. [88.72.175.225]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad92cd7sm389470166b.179.2024.07.28.06.15.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Jul 2024 06:15:58 -0700 (PDT) Message-ID: Date: Sun, 28 Jul 2024 15:15:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <33cb91e2-a4d3-47c5-8f15-d0ccb1107eaa@gmx.net> Content-Language: en-US From: Ramiro Polla In-Reply-To: <33cb91e2-a4d3-47c5-8f15-d0ccb1107eaa@gmx.net> Subject: Re: [FFmpeg-devel] [PATCH v3 2/2] 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: , Reply-To: FFmpeg development discussions and patches 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: On 2024-07-23 16:59, Stefan Oltmanns via ffmpeg-devel wrote: > This is the second part for loading the library at runtime, changes > compared to previous patch revisions: > > -No atexit anymore > -No global states anymore > -Moved the registry read for Windows from a separate function inside the > function to load the dynamic library and simplified it, reducing the > amount windows-specific code. > > Tested with 2 VapourSynth inputs on these platforms, no problems and > clean exit: > > -Linux x86_64 (Ubuntu 22.04) > -Windows 10 x86_64 > -macOS 14 aarch64 > From 6a8e8b7d5bfcfb8eb3cb24ea1f7e14ca117882c4 Mon Sep 17 00:00:00 2001 > From: Stefan Oltmanns > Date: Tue, 23 Jul 2024 16:19:46 +0200 > Subject: [PATCH 2/2] avformat/vapoursynth: load library at runtime > > Signed-off-by: Stefan Oltmanns > --- > configure | 2 +- > libavformat/vapoursynth.c | 65 +++++++++++++++++++++++++++++++++++++-- > 2 files changed, 64 insertions(+), 3 deletions(-) > > diff --git a/configure b/configure > index c50b5ad4b4..1b6670505a 100755 > --- a/configure > +++ b/configure > @@ -7085,7 +7085,7 @@ enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/r > { enabled libdrm || > die "ERROR: rkmpp requires --enable-libdrm"; } > } > -enabled vapoursynth && require_pkg_config vapoursynth "vapoursynth-script >= 55" VSScript4.h getVSScriptAPI > +enabled vapoursynth && require_headers "vapoursynth/VSScript4.h vapoursynth/VapourSynth4.h" > > > if enabled gcrypt; then > diff --git a/libavformat/vapoursynth.c b/libavformat/vapoursynth.c > index ce15f68180..ad1d6eac61 100644 > --- a/libavformat/vapoursynth.c > +++ b/libavformat/vapoursynth.c > @@ -25,7 +25,7 @@ > > #include > > -#include > +#include > > #include "libavutil/avassert.h" > #include "libavutil/avstring.h" > @@ -39,11 +39,26 @@ > #include "demux.h" > #include "internal.h" > > +/* Platform-specific directives. */ > +#ifdef _WIN32 > + #include > + #include "compat/w32dlfcn.h" > + #include "libavutil/wchar_filename.h" > + #undef EXTERN_C > + #define VSSCRIPT_LIB "VSScript.dll" > +#else > + #include > + #define VSSCRIPT_NAME "libvapoursynth-script" > + #define VSSCRIPT_LIB VSSCRIPT_NAME SLIBSUF > +#endif > + > struct VSState { > const VSSCRIPTAPI *vssapi; > VSScript *vss; > }; > > +typedef const VSSCRIPTAPI *(*VSScriptGetAPIFunc)(int version); > + > typedef struct VSContext { > const AVClass *class; > > @@ -51,6 +66,7 @@ typedef struct VSContext { > > const VSSCRIPTAPI *vssapi; > const VSAPI *vsapi; > + void *vslibrary; > > VSNode *outnode; > int is_cfr; > @@ -70,6 +86,40 @@ static const AVOption options[] = { > {NULL} > }; > > +static av_cold void* vs_load_library(VSScriptGetAPIFunc *get_vssapi) > +{ > + void *vslibrary = NULL; > +#ifdef _WIN32 > + const HKEY hkeys[] = {HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE}; > + LONG r; > + WCHAR vss_path[512]; > + DWORD buf_size = sizeof(vss_path) - 2; > + char *vss_path_utf8; > + int i; > + > + for (i = 0; i < sizeof(hkeys); i++) { FF_ARRAY_ELEMS(hkeys) > + if ((r = RegGetValueW(hkeys[i], L"SOFTWARE\\VapourSynth", > + L"VSScriptDLL", RRF_RT_REG_SZ, NULL, > + &vss_path, &buf_size)) == ERROR_SUCCESS) > + break; > + } > + if (r == ERROR_SUCCESS && wchartoutf8(vss_path, &vss_path_utf8) == 0) { > + vslibrary = dlopen(vss_path_utf8, RTLD_NOW | RTLD_GLOBAL); I think calling win32_dlopen() with a full path will be problematic for systems without KB2533623. win32_dlopen() might need to be fixed in a separate patch. [...] 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".