* [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c: Remove MAX_PATH limit
2022-06-09 19:04 [FFmpeg-devel] [PATCH v13 1/4] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi Nil Admirari
@ 2022-06-09 19:04 ` Nil Admirari
2022-06-10 12:56 ` Soft Works
2022-06-09 19:04 ` [FFmpeg-devel] [PATCH v13 3/4] compat/w32dlfcn.h: Remove MAX_PATH limit and replace LoadLibraryExA with LoadLibraryExW Nil Admirari
2022-06-09 19:04 ` [FFmpeg-devel] [PATCH v13 4/4] fftools/cmdutils.c: Remove MAX_PATH limit Nil Admirari
2 siblings, 1 reply; 11+ messages in thread
From: Nil Admirari @ 2022-06-09 19:04 UTC (permalink / raw)
To: ffmpeg-devel
---
libavformat/avisynth.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index 8ba2bde..f7bea8c 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -34,6 +34,7 @@
/* Platform-specific directives. */
#ifdef _WIN32
#include "compat/w32dlfcn.h"
+ #include "libavutil/wchar_filename.h"
#undef EXTERN_C
#define AVISYNTH_LIB "avisynth"
#else
@@ -810,8 +811,7 @@ static int avisynth_open_file(AVFormatContext *s)
AVS_Value arg, val;
int ret;
#ifdef _WIN32
- char filename_ansi[MAX_PATH * 4];
- wchar_t filename_wc[MAX_PATH * 4];
+ char *filename_ansi = NULL;
#endif
if (ret = avisynth_context_create(s))
@@ -819,10 +819,12 @@ static int avisynth_open_file(AVFormatContext *s)
#ifdef _WIN32
/* Convert UTF-8 to ANSI code page */
- MultiByteToWideChar(CP_UTF8, 0, s->url, -1, filename_wc, MAX_PATH * 4);
- WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1, filename_ansi,
- MAX_PATH * 4, NULL, NULL);
+ if (utf8toansi(s->url, &filename_ansi)) {
+ ret = AVERROR_UNKNOWN;
+ goto fail;
+ }
arg = avs_new_value_string(filename_ansi);
+ av_free(filename_ansi);
#else
arg = avs_new_value_string(s->url);
#endif
--
2.34.1
_______________________________________________
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c: Remove MAX_PATH limit
2022-06-09 19:04 ` [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c: Remove MAX_PATH limit Nil Admirari
@ 2022-06-10 12:56 ` Soft Works
2022-06-11 17:01 ` nil-admirari
0 siblings, 1 reply; 11+ messages in thread
From: Soft Works @ 2022-06-10 12:56 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Nil
> Admirari
> Sent: Thursday, June 9, 2022 9:04 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c:
> Remove MAX_PATH limit
>
> ---
> libavformat/avisynth.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
> index 8ba2bde..f7bea8c 100644
> --- a/libavformat/avisynth.c
> +++ b/libavformat/avisynth.c
> @@ -34,6 +34,7 @@
> /* Platform-specific directives. */
> #ifdef _WIN32
> #include "compat/w32dlfcn.h"
> + #include "libavutil/wchar_filename.h"
> #undef EXTERN_C
> #define AVISYNTH_LIB "avisynth"
> #else
> @@ -810,8 +811,7 @@ static int avisynth_open_file(AVFormatContext *s)
> AVS_Value arg, val;
> int ret;
> #ifdef _WIN32
> - char filename_ansi[MAX_PATH * 4];
> - wchar_t filename_wc[MAX_PATH * 4];
> + char *filename_ansi = NULL;
> #endif
>
> if (ret = avisynth_context_create(s))
> @@ -819,10 +819,12 @@ static int avisynth_open_file(AVFormatContext
> *s)
>
> #ifdef _WIN32
> /* Convert UTF-8 to ANSI code page */
> - MultiByteToWideChar(CP_UTF8, 0, s->url, -1, filename_wc,
> MAX_PATH * 4);
> - WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1,
> filename_ansi,
> - MAX_PATH * 4, NULL, NULL);
> + if (utf8toansi(s->url, &filename_ansi)) {
> + ret = AVERROR_UNKNOWN;
> + goto fail;
> + }
Why not use the AviSynth mechanism that allows to supply a UTF-8 string?
https://github.com/AviSynth/AviSynthPlus/blob/c377916aa4146d2f4386852d91dc177d49103c16/avs_core/core/parser/script.cpp#L477-L481
Best,
sw
_______________________________________________
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c: Remove MAX_PATH limit
2022-06-10 12:56 ` Soft Works
@ 2022-06-11 17:01 ` nil-admirari
2022-06-12 2:15 ` Stephen Hutchinson
0 siblings, 1 reply; 11+ messages in thread
From: nil-admirari @ 2022-06-11 17:01 UTC (permalink / raw)
To: ffmpeg-devel
> Why not use the AviSynth mechanism that allows to supply a UTF-8 string?
>
> https://github.com/AviSynth/AviSynthPlus/blob/c377916aa4146d2f4386852d91dc177d49103c16/avs_core/core/parser/script.cpp#L477-L481
Was not aware such a mechanism exists.
Commit dates back to 10 April 2017, first release supporting it is, apparently, Avisynth+ r2487-MT: https://github.com/pinterf/AviSynthPlus/releases/tag/r2489-MT.
A remark in https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/avisynth.c#L844 says:
/* On Windows, FFmpeg supports AviSynth interface version 6 or higher.
* This includes AviSynth 2.6 RC1 or higher, and AviSynth+ r1718 or higher,
* and excludes 2.5 and the 2.6 alphas. */
Support for plain AviSynth will have to be dropped.
On the other hand, configure checks for https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/avisynth.c#L844
> die "ERROR: AviSynth+ header version must be >= 3.7.1"
so probably plain AviSynth and AviSynth+ below r2489-MT are already unsupported.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c: Remove MAX_PATH limit
2022-06-11 17:01 ` nil-admirari
@ 2022-06-12 2:15 ` Stephen Hutchinson
2022-06-12 4:24 ` Soft Works
2022-06-13 16:53 ` nil-admirari
0 siblings, 2 replies; 11+ messages in thread
From: Stephen Hutchinson @ 2022-06-12 2:15 UTC (permalink / raw)
To: ffmpeg-devel
On 6/11/22 1:01 PM, nil-admirari@mailo.com wrote:
>> Why not use the AviSynth mechanism that allows to supply a UTF-8 string?
>>
>> https://github.com/AviSynth/AviSynthPlus/blob/c377916aa4146d2f4386852d91dc177d49103c16/avs_core/core/parser/script.cpp#L477-L481
>
> Was not aware such a mechanism exists.
>
> Commit dates back to 10 April 2017, first release supporting it is, apparently, Avisynth+ r2487-MT: https://github.com/pinterf/AviSynthPlus/releases/tag/r2489-MT.
>
> A remark in https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/avisynth.c#L844 says:
>
> /* On Windows, FFmpeg supports AviSynth interface version 6 or higher.
> * This includes AviSynth 2.6 RC1 or higher, and AviSynth+ r1718 or higher,
> * and excludes 2.5 and the 2.6 alphas. */
>
> Support for plain AviSynth will have to be dropped.
Presumably, the original manifest idea, parsed down to only using it to
force FFmpeg into UTF-8, would be sufficient for this, right? As long
as AviSynth inherits that from FFmpeg, UTF-8 strings would be pervasive
and both A) the utf8 parameter would not need to be used and B) 2.6
would work just fine with it, transparently.
The Windows API does have a SetConsoleCP function. If that accomplishes
the same effect as the manifest idea, that would be simpler, but it
probably would need to be located somewhere *other* than the AviSynth
demuxer. And while it might work for the fftools themselves, does it
also work for usage of the libraries directly in applications that may
not be console apps?
Barring that, if/else checks to ensure that
A) IsWindowsVersionOrGreater is at least 1903
A1) If yes, go to B
A2) If no, use the existing logic
B) If yes, GetACP to check that it's UTF8
B1) If yes, the Import call stays the same as it is now, no utf8 parameter
B2) If no, that's where things get complicated:
C1) Use the no result to tell it to then force UTF-8 mode with
SetConsoleCP, if that actually works for what we need it to do. Then
don't use the utf8 parameter.
C2) Use avs_get_version to detect an incompatible version of AviSynth
and gracefully exit with a message about upgrading to a supported
version of AviSynth+, before then using the utf8 parameter for real.
C3) Use avs_get_version, but if it's not a new enough version, just fall
back to the logic that exists now, where 2.6 may or may not work just
because the system may or may not be already set to UTF-8.
C2 should really be considered a last resort IMO, because it's an
artificial limit and doesn't actually have anything to do with the
AviSynth API.
The reason is that the utf8 parameter being discussed here is not part
of the AviSynth API, it's an option handed to one of the script-level
functions that avs_invoke (which is the actual API call there) is using.
> On the other hand, configure checks for https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/avisynth.c#L844
>
>> die "ERROR: AviSynth+ header version must be >= 3.7.1"
>
> so probably plain AviSynth and AviSynth+ below r2489-MT are already unsupported.
>
The header version check there isn't because of old versions of
AviSynth(+) being unsupported (as far as the demuxer is concerned,
anyway). 3.7.1 is still API compatible with 2.6 in all the functions
the demuxer uses that are shared between them. The additional
Plus-specific functionality is enabled with runtime checks, so if you
don't use the newer header, it will fail to build, but you can run 2.6
without problems even when using the newer header to compile the demuxer.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c: Remove MAX_PATH limit
2022-06-12 2:15 ` Stephen Hutchinson
@ 2022-06-12 4:24 ` Soft Works
2022-06-13 16:53 ` nil-admirari
1 sibling, 0 replies; 11+ messages in thread
From: Soft Works @ 2022-06-12 4:24 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Stephen Hutchinson
> Sent: Sunday, June 12, 2022 4:15 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c:
> Remove MAX_PATH limit
>
> On 6/11/22 1:01 PM, nil-admirari@mailo.com wrote:
> >> Why not use the AviSynth mechanism that allows to supply a UTF-8
> string?
> >>
> >>
> https://github.com/AviSynth/AviSynthPlus/blob/c377916aa4146d2f4386852
> d91dc177d49103c16/avs_core/core/parser/script.cpp#L477-L481
> >
> > Was not aware such a mechanism exists.
> >
> > Commit dates back to 10 April 2017, first release supporting it is,
> apparently, Avisynth+ r2487-MT:
> https://github.com/pinterf/AviSynthPlus/releases/tag/r2489-MT.
> >
> > A remark in
> https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/avisynth.c#L
> 844 says:
> >
> > /* On Windows, FFmpeg supports AviSynth interface version 6 or
> higher.
> > * This includes AviSynth 2.6 RC1 or higher, and AviSynth+ r1718
> or higher,
> > * and excludes 2.5 and the 2.6 alphas. */
> >
> > Support for plain AviSynth will have to be dropped.
>
> Presumably, the original manifest idea, parsed down to only using it
> to
> force FFmpeg into UTF-8, would be sufficient for this, right? As
This is a change that would affect ffmpeg behavior at a global level,
just for the sake of accommodating for a single 3rd party library
(and even: only some ancient versions of it).
> as AviSynth inherits that from FFmpeg, UTF-8 strings would be
> pervasive
> and both A) the utf8 parameter would not need to be used and B) 2.6
> would work just fine with it, transparently.
> The Windows API does have a SetConsoleCP function. If that
> accomplishes
> the same effect as the manifest idea, that would be simpler, but it
> probably would need to be located somewhere *other* than the AviSynth
> demuxer.
ffmpeg does not interact with AviSynth via console interface.
AFAIU, it uses AviSynth in-process loading it via an API instead:
val = avs_library.avs_invoke(avs->env, "Import", arg, 0);
Those functions like SetConsoleCP and SetConsoleOutputCP, have no effect
on the current process, it's only about console pipe communication with
child (cli) processes.
The manifest approach is too invasive IMO, as laid out before.
At least with regards to AviSynthPlus versions since two years ago,
we're not talking about long paths anymore.
AviSynthPlus is using the same prefixing approach for long paths
that we have employed in ffmpeg as well, now.
The only question is whether we supply the script/path argument to
AviSynthPlus as Ansi or UTF-8 string.
It will handle long paths in both cases. The only difference is that
when we're converting a UTF-8 path to an Ansi codepage, it might
become an invalid path when the projection would be ambiguous.
It's been like that all the time before - nothing new about it.
There are functions available to check the version:
avs_get_version, avs_check_version,
So - in case that requiring AviSynthPlus from 2020 as a minimum
would be undesirable, it should be possible to find out at
runtime whether the loaded AviSynth supports the UTF8 parameter
or not and set the invoke parameters accordingly.
Best regards,
softworkz
_______________________________________________
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c: Remove MAX_PATH limit
2022-06-12 2:15 ` Stephen Hutchinson
2022-06-12 4:24 ` Soft Works
@ 2022-06-13 16:53 ` nil-admirari
1 sibling, 0 replies; 11+ messages in thread
From: nil-admirari @ 2022-06-13 16:53 UTC (permalink / raw)
To: ffmpeg-devel
> Presumably, the original manifest idea, parsed down to only using it to
> force FFmpeg into UTF-8, would be sufficient for this, right?
UTF-8 in manifest was rejected as too far-reaching, and then longs paths
were reimplemented with \\?\ prefixes, so now there is no manifest at all.
> The Windows API does have a SetConsoleCP function.
It does not change process code page.
> C3) Use avs_get_version, but if it's not a new enough version, just fall
> back to the logic that exists now
Done in https://ffmpeg.org/pipermail/ffmpeg-devel/2022-June/297494.html.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* [FFmpeg-devel] [PATCH v13 3/4] compat/w32dlfcn.h: Remove MAX_PATH limit and replace LoadLibraryExA with LoadLibraryExW
2022-06-09 19:04 [FFmpeg-devel] [PATCH v13 1/4] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi Nil Admirari
2022-06-09 19:04 ` [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c: Remove MAX_PATH limit Nil Admirari
@ 2022-06-09 19:04 ` Nil Admirari
2022-06-10 18:50 ` Michael Niedermayer
2022-06-09 19:04 ` [FFmpeg-devel] [PATCH v13 4/4] fftools/cmdutils.c: Remove MAX_PATH limit Nil Admirari
2 siblings, 1 reply; 11+ messages in thread
From: Nil Admirari @ 2022-06-09 19:04 UTC (permalink / raw)
To: ffmpeg-devel
---
compat/w32dlfcn.h | 80 +++++++++++++++++++++++++++++++++++++----------
1 file changed, 64 insertions(+), 16 deletions(-)
diff --git a/compat/w32dlfcn.h b/compat/w32dlfcn.h
index 52a94ef..6b0dd7d 100644
--- a/compat/w32dlfcn.h
+++ b/compat/w32dlfcn.h
@@ -22,9 +22,31 @@
#ifdef _WIN32
#include <windows.h>
#include "config.h"
-#if (_WIN32_WINNT < 0x0602) || HAVE_WINRT
#include "libavutil/wchar_filename.h"
-#endif
+
+static inline wchar_t *get_module_filename(HMODULE module)
+{
+ wchar_t *path = NULL, *new_path = NULL;
+ DWORD path_size = 0, path_len = 0;
+
+ do {
+ path_size = path_size ? 2 * path_size : MAX_PATH;
+ new_path = av_realloc_array(path, path_size, sizeof *path);
+ if (!new_path) {
+ av_free(path);
+ return NULL;
+ }
+ path = new_path;
+ path_len = GetModuleFileNameW(module, path, path_size);
+ } while (path_len && path_size <= 32768 && path_size <= path_len);
+
+ if (!path_len) {
+ av_free(path);
+ return NULL;
+ }
+ return path;
+}
+
/**
* 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
@@ -34,29 +56,53 @@
*/
static inline HMODULE win32_dlopen(const char *name)
{
+ wchar_t *name_w = NULL;
+ if (utf8towchar(name, &name_w))
+ name_w = NULL;
#if _WIN32_WINNT < 0x0602
// Need to check if KB2533623 is available
if (!GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDefaultDllDirectories")) {
HMODULE module = NULL;
- wchar_t *path = NULL, *name_w = NULL;
- DWORD pathlen;
- if (utf8towchar(name, &name_w))
+ wchar_t *path = NULL, *new_path = NULL;
+ DWORD pathlen, pathsize, namelen;
+ if (!name_w)
goto exit;
- path = (wchar_t *)av_calloc(MAX_PATH, sizeof(wchar_t));
+ namelen = wcslen(name_w);
// Try local directory first
- pathlen = GetModuleFileNameW(NULL, path, MAX_PATH);
- pathlen = wcsrchr(path, '\\') - path;
- if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
+ path = get_module_filename(NULL);
+ if (!path)
goto exit;
- path[pathlen] = '\\';
+ new_path = wcsrchr(path, '\\');
+ if (!new_path)
+ goto exit;
+ pathlen = new_path - path;
+ pathsize = pathlen + namelen + 2;
+ new_path = av_realloc_array(path, pathsize, sizeof *path);
+ if (!new_path)
+ goto exit;
+ path = new_path;
wcscpy(path + pathlen + 1, name_w);
module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (module == NULL) {
// Next try System32 directory
- pathlen = GetSystemDirectoryW(path, MAX_PATH);
- if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
+ pathlen = GetSystemDirectoryW(path, pathsize);
+ if (!pathlen)
goto exit;
- path[pathlen] = '\\';
+ // Buffer is not enough in two cases:
+ // 1. system directory + \ + module name
+ // 2. system directory even without module name.
+ if (pathlen + namelen + 2 > pathsize) {
+ pathsize = pathlen + namelen + 2;
+ new_path = av_realloc_array(path, pathsize, sizeof *path);
+ if (!new_path)
+ goto exit;
+ path = new_path;
+ // Query again to handle case #2.
+ pathlen = GetSystemDirectoryW(path, pathsize);
+ if (!pathlen)
+ goto exit;
+ }
+ path[pathlen] = L'\\';
wcscpy(path + pathlen + 1, name_w);
module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
}
@@ -73,15 +119,17 @@ exit:
# define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
#endif
#if HAVE_WINRT
- wchar_t *name_w = NULL;
int ret;
- if (utf8towchar(name, &name_w))
+ if (!name_w)
return NULL;
ret = LoadPackagedLibrary(name_w, 0);
av_free(name_w);
return ret;
#else
- return LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
+ /* filename may be be in CP_ACP */
+ if (!name_w)
+ return LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
+ return LoadLibraryExW(name_w, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
#endif
}
#define dlopen(name, flags) win32_dlopen(name)
--
2.34.1
_______________________________________________
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [FFmpeg-devel] [PATCH v13 3/4] compat/w32dlfcn.h: Remove MAX_PATH limit and replace LoadLibraryExA with LoadLibraryExW
2022-06-09 19:04 ` [FFmpeg-devel] [PATCH v13 3/4] compat/w32dlfcn.h: Remove MAX_PATH limit and replace LoadLibraryExA with LoadLibraryExW Nil Admirari
@ 2022-06-10 18:50 ` Michael Niedermayer
2022-06-13 16:47 ` nil-admirari
0 siblings, 1 reply; 11+ messages in thread
From: Michael Niedermayer @ 2022-06-10 18:50 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 4684 bytes --]
On Thu, Jun 09, 2022 at 10:04:05PM +0300, Nil Admirari wrote:
> ---
> compat/w32dlfcn.h | 80 +++++++++++++++++++++++++++++++++++++----------
> 1 file changed, 64 insertions(+), 16 deletions(-)
breaks build on mingw64
CC libavcodec/mfenc.o
In file included from /usr/share/mingw-w64/include/dshow.h:40:0,
from src/libavcodec/mf_utils.h:32,
from src/libavcodec/mfenc.c:26:
/usr/share/mingw-w64/include/strmif.h:16503:2: warning: #warning COM interfaces layout in this header has not been verified. [-Wcpp]
#warning COM interfaces layout in this header has not been verified.
^~~~~~~
/usr/share/mingw-w64/include/strmif.h:16504:2: warning: #warning COM interfaces with incorrect layout may not work at all. [-Wcpp]
#warning COM interfaces with incorrect layout may not work at all.
^~~~~~~
/usr/share/mingw-w64/include/strmif.h:16505:1: note: #pragma message: Interface IAMAsyncReaderTimestampScaling has unverified layout.
__MINGW_BROKEN_INTERFACE(INTERFACE)
^~~~~~~~~~~~~~~~~~~~~~~~
/usr/share/mingw-w64/include/strmif.h:16533:2: warning: #warning COM interfaces layout in this header has not been verified. [-Wcpp]
#warning COM interfaces layout in this header has not been verified.
^~~~~~~
/usr/share/mingw-w64/include/strmif.h:16534:2: warning: #warning COM interfaces with incorrect layout may not work at all. [-Wcpp]
#warning COM interfaces with incorrect layout may not work at all.
^~~~~~~
/usr/share/mingw-w64/include/strmif.h:16535:1: note: #pragma message: Interface IAMPluginControl has unverified layout.
__MINGW_BROKEN_INTERFACE(INTERFACE)
^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/share/mingw-w64/include/dshow.h:33:0,
from src/libavcodec/mf_utils.h:32,
from src/libavcodec/mfenc.c:26:
src/libavutil/wchar_filename.h: In function ‘add_extended_prefix’:
src/libavutil/wchar_filename.h:211:9: error: ‘wcscpy_instead_use_StringCbCopyW_or_StringCchCopyW’ undeclared (first use in this function)
wcscpy(temp_w, unc_prefix);
^
src/libavutil/wchar_filename.h:211:9: note: each undeclared identifier is reported only once for each function it appears in
In file included from src/compat/w32dlfcn.h:25:0,
from src/libavcodec/mfenc.c:32:
src/libavutil/wchar_filename.h:211:22: warning: left-hand operand of comma expression has no effect [-Wunused-value]
wcscpy(temp_w, unc_prefix);
^
src/libavutil/wchar_filename.h:211:15: warning: statement with no effect [-Wunused-value]
wcscpy(temp_w, unc_prefix);
^
In file included from /usr/share/mingw-w64/include/dshow.h:33:0,
from src/libavcodec/mf_utils.h:32,
from src/libavcodec/mfenc.c:26:
src/libavutil/wchar_filename.h:212:9: error: ‘wcscat_instead_use_StringCbCatW_or_StringCchCatW’ undeclared (first use in this function); did you mean ‘wcscpy_instead_use_StringCbCopyW_or_StringCchCopyW’?
wcscat(temp_w, path_w + 2);
^
In file included from src/compat/w32dlfcn.h:25:0,
from src/libavcodec/mfenc.c:32:
src/libavutil/wchar_filename.h:212:22: warning: left-hand operand of comma expression has no effect [-Wunused-value]
wcscat(temp_w, path_w + 2);
^
src/libavutil/wchar_filename.h:212:22: warning: statement with no effect [-Wunused-value]
wcscat(temp_w, path_w + 2);
~~~~~~~^~~~~~~~~~~~~
src/libavutil/wchar_filename.h:220:22: warning: left-hand operand of comma expression has no effect [-Wunused-value]
wcscpy(temp_w, extended_path_prefix);
^
src/libavutil/wchar_filename.h:220:15: warning: statement with no effect [-Wunused-value]
wcscpy(temp_w, extended_path_prefix);
^
src/libavutil/wchar_filename.h:221:22: warning: left-hand operand of comma expression has no effect [-Wunused-value]
wcscat(temp_w, path_w);
^
src/libavutil/wchar_filename.h:221:15: warning: statement with no effect [-Wunused-value]
wcscat(temp_w, path_w);
^
src/ffbuild/common.mak:81: recipe for target 'libavcodec/mfenc.o' failed
make: *** [libavcodec/mfenc.o] Error 1
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* [FFmpeg-devel] [PATCH v13 4/4] fftools/cmdutils.c: Remove MAX_PATH limit
2022-06-09 19:04 [FFmpeg-devel] [PATCH v13 1/4] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi Nil Admirari
2022-06-09 19:04 ` [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c: Remove MAX_PATH limit Nil Admirari
2022-06-09 19:04 ` [FFmpeg-devel] [PATCH v13 3/4] compat/w32dlfcn.h: Remove MAX_PATH limit and replace LoadLibraryExA with LoadLibraryExW Nil Admirari
@ 2022-06-09 19:04 ` Nil Admirari
2 siblings, 0 replies; 11+ messages in thread
From: Nil Admirari @ 2022-06-09 19:04 UTC (permalink / raw)
To: ffmpeg-devel
---
fftools/cmdutils.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 5d7cdc3..d42bb04 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -50,6 +50,7 @@
#include "opt_common.h"
#ifdef _WIN32
#include <windows.h>
+#include "compat/w32dlfcn.h"
#endif
AVDictionary *sws_dict;
@@ -812,6 +813,9 @@ FILE *get_preset_file(char *filename, size_t filename_size,
{
FILE *f = NULL;
int i;
+#if HAVE_GETMODULEHANDLE && defined(_WIN32)
+ char *datadir = NULL;
+#endif
const char *base[3] = { getenv("FFMPEG_DATADIR"),
getenv("HOME"),
FFMPEG_DATADIR, };
@@ -821,19 +825,31 @@ FILE *get_preset_file(char *filename, size_t filename_size,
f = fopen(filename, "r");
} else {
#if HAVE_GETMODULEHANDLE && defined(_WIN32)
- char datadir[MAX_PATH], *ls;
+ wchar_t *datadir_w = get_module_filename(NULL);
base[2] = NULL;
- if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir, sizeof(datadir) - 1))
+ if (wchartoansi(datadir_w, &datadir))
+ datadir = NULL;
+ av_free(datadir_w);
+
+ if (datadir)
{
- for (ls = datadir; ls < datadir + strlen(datadir); ls++)
+ char *ls;
+ for (ls = datadir; *ls; ls++)
if (*ls == '\\') *ls = '/';
if (ls = strrchr(datadir, '/'))
{
- *ls = 0;
- strncat(datadir, "/ffpresets", sizeof(datadir) - 1 - strlen(datadir));
- base[2] = datadir;
+ ptrdiff_t datadir_len = ls - datadir;
+ size_t desired_size = datadir_len + strlen("/ffpresets") + 1;
+ char *new_datadir = av_realloc_array(
+ datadir, desired_size, sizeof *datadir);
+ if (new_datadir) {
+ datadir = new_datadir;
+ datadir[datadir_len] = 0;
+ strncat(datadir, "/ffpresets", desired_size - 1 - datadir_len);
+ base[2] = datadir;
+ }
}
}
#endif
@@ -853,6 +869,9 @@ FILE *get_preset_file(char *filename, size_t filename_size,
}
}
+#if HAVE_GETMODULEHANDLE && defined(_WIN32)
+ av_free(datadir);
+#endif
return f;
}
--
2.34.1
_______________________________________________
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".
^ permalink raw reply [flat|nested] 11+ messages in thread