Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v11 1/6] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi
@ 2022-04-23 20:56 Nil Admirari
  2022-04-23 20:56 ` [FFmpeg-devel] [PATCH v11 2/6] libavformat/avisynth.c: Remove MAX_PATH limit Nil Admirari
                   ` (6 more replies)
  0 siblings, 7 replies; 51+ messages in thread
From: Nil Admirari @ 2022-04-23 20:56 UTC (permalink / raw)
  To: ffmpeg-devel

These functions are going to be used in libavformat/avisynth.c
and fftools/cmdutils.c to remove MAX_PATH limit.
---
 libavutil/wchar_filename.h | 51 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/libavutil/wchar_filename.h b/libavutil/wchar_filename.h
index 90f08245..c0e5d47e 100644
--- a/libavutil/wchar_filename.h
+++ b/libavutil/wchar_filename.h
@@ -40,6 +40,57 @@ static inline int utf8towchar(const char *filename_utf8, wchar_t **filename_w)
     MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, *filename_w, num_chars);
     return 0;
 }
+
+av_warn_unused_result
+static inline int wchartocp(unsigned int code_page, const wchar_t *filename_w,
+                            char **filename)
+{
+    DWORD flags = code_page == CP_UTF8 ? MB_ERR_INVALID_CHARS : 0;
+    int num_chars = WideCharToMultiByte(code_page, flags, filename_w, -1,
+                                        NULL, 0, NULL, NULL);
+    if (num_chars <= 0) {
+        *filename = NULL;
+        return 0;
+    }
+    *filename = av_calloc(num_chars, sizeof(char));
+    if (!*filename) {
+        errno = ENOMEM;
+        return -1;
+    }
+    WideCharToMultiByte(code_page, flags, filename_w, -1,
+                        *filename, num_chars, NULL, NULL);
+    return 0;
+}
+
+av_warn_unused_result
+static inline int wchartoutf8(const wchar_t *filename_w, char **filename)
+{
+    return wchartocp(CP_UTF8, filename_w, filename);
+}
+
+av_warn_unused_result
+static inline int wchartoansi(const wchar_t *filename_w, char **filename)
+{
+    return wchartocp(CP_ACP, filename_w, filename);
+}
+
+av_warn_unused_result
+static inline int utf8toansi(const char *filename_utf8, char **filename)
+{
+    wchar_t *filename_w = NULL;
+    int ret = -1;
+    if (utf8towchar(filename_utf8, &filename_w))
+        return -1;
+
+    if (!filename_w) {
+        *filename = NULL;
+        return 0;
+    }
+
+    ret = wchartoansi(filename_w, filename);
+    av_free(filename_w);
+    return ret;
+}
 #endif
 
 #endif /* AVUTIL_WCHAR_FILENAME_H */
-- 
2.32.0



_______________________________________________
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] 51+ messages in thread
* Re: [FFmpeg-devel] [PATCH v11 1/6] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi
@ 2022-04-24 12:08 nil-admirari
  2022-04-24 22:04 ` Soft Works
  0 siblings, 1 reply; 51+ messages in thread
From: nil-admirari @ 2022-04-24 12:08 UTC (permalink / raw)
  To: ffmpeg-devel

> 1. Patch 3/6 - Replace LoadLibraryExA with LoadLibraryExW
> What's the point in making changes to library loading? What does it fix?



From the commit https://ffmpeg.org/pipermail/ffmpeg-devel/2022-April/295571.html:

... the path length limitation is only lifted for file APIs that pass paths as wchar_t...



> 2. Patches 5/6 and 6/6 - Add Fusion Manifest

> ...

> Both of these manifest attributes are affecting the runtime behavior of
> an application running on Windows - but only starting from a certain 

> OS version.

> ...

> ... you would need to check the operating system version 

> before using to make sure that you are providing parameters in the "right"
> way - I'm not sure whether that would make much sense.



The same can be said about e.g. DirectX 11 hardware acceleration, which is available

only starting with Windows 7; and you have to check OS version before providing

parameters that enable it. Does not mean implementing that feature made no sense,

since it made FFmpeg inconsistent with previous versions of Windows. Consistency

with the greatest common denominator does not make much sense.



Considering that people from yt-dlp and StaxRip projects requested long paths feature,

looks like it does make sense to the users.



> 3. All Patches x/6 - Remove MAX_PATH limit
> The punch line sounds compelling. But how is the current situation and 

> what exactly would be the benefit?



All patches with that line replace MAX_PATH-sized buffers with dynamically-allocated

buffers of potentially arbitrary size. If application continues to use fixed-size buffers,

it's not long path aware, regardless of the manifest.


> As an example, the following command runs without issue on Windows 
> with a normal current ffmpeg build:

It simply moves the burden of long path support from FFmpeg to FFmpeg clients.



> All this is working in a predictable and reliable way on all common Windows

> versions.



It is neither predictable nor reliable. Please check https://googleprojectzero.blogspot.com/2016/02/the-definitive-guide-on-win32-to-nt.html

for things like “I actually exploited this behaviour to create

arbitrary named pipes from the Chrome sandbox awhile back.”

> 1. Windows version needs to be >= 1903
> (for being able to have both attributes in effect)



For all intents and purposes, versions of Windows < 1903 have EOLed. Exceptions:

- Windows 8.1 will EOL in January 2023,

- LTSB/LTSC branches of Windows 10 before 21H2.

None of these exceptions are particularly popular with users.



> 2. Application needs to be compiled with and manifest file as resource



Which is exactly what these patches are doing.



> 3. A registry key or group policy needs to be set on Windows to enable this
> ´ (in both cases, administrative permission/UAC is required to set it)
> 4. Even when registry key or group policy is set, it might still be pending

> a reboot



Is it a big deal to change a registry and reboot?


> On the other side, there's a risk of regressions by adding those manifest

> attributes.



Adding anything risks regressions, how manifest is supposed to be different

from any other patch?


> I wonder whether it wouldn’t be a better idea, to simply auto-add this prefix
> in the ffmpeg file handling code if:



Every command line argument that supplies a path needs to be updated.

Every filter with a file argument needs to be updated.

Code in https://ffmpeg.org/pipermail/ffmpeg-devel/2022-April/295568.html

normalises a path to use '/' instead of '\\' for whatever reason, and it cannot use \\?\

since it requires backslashes.



How adding a prefix \\?\ is supposed to be simpler than replacing a couple of buffers?



> This would work on all common Windows versions and would be predictable and

> reliable.



See https://googleprojectzero.blogspot.com/2016/02/the-definitive-guide-on-win32-to-nt.html

for predictability and reliability.


_______________________________________________
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] 51+ messages in thread

end of thread, other threads:[~2022-06-05 11:43 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-23 20:56 [FFmpeg-devel] [PATCH v11 1/6] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi Nil Admirari
2022-04-23 20:56 ` [FFmpeg-devel] [PATCH v11 2/6] libavformat/avisynth.c: Remove MAX_PATH limit Nil Admirari
2022-05-07 17:55   ` Soft Works
2022-04-23 20:56 ` [FFmpeg-devel] [PATCH v11 3/6] compat/w32dlfcn.h: Remove MAX_PATH limit and replace LoadLibraryExA with LoadLibraryExW Nil Admirari
2022-06-05 11:43   ` nil-admirari
2022-04-23 20:56 ` [FFmpeg-devel] [PATCH v11 4/6] fftools/cmdutils.c: Remove MAX_PATH limit Nil Admirari
2022-04-23 20:56 ` [FFmpeg-devel] [PATCH v11 5/6] fftools: Enable long path support on Windows (fixes #8885) Nil Admirari
2022-04-26  7:07   ` Tobias Rapp
2022-04-26  7:29     ` Hendrik Leppkes
2022-04-26  8:33       ` Tobias Rapp
2022-04-29 18:08     ` nil-admirari
2022-04-23 20:57 ` [FFmpeg-devel] [PATCH v11 6/6] fftools: Set active code page to UTF-8 on Windows Nil Admirari
2022-04-24  3:39 ` [FFmpeg-devel] [PATCH v11 1/6] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi Soft Works
2022-05-07 17:57 ` Soft Works
2022-04-24 12:08 nil-admirari
2022-04-24 22:04 ` Soft Works
2022-04-25  9:03   ` nil-admirari
2022-04-25  9:31     ` Soft Works
2022-04-25  9:51       ` nil-admirari
2022-04-25 11:12         ` Soft Works
2022-04-25 12:51           ` Hendrik Leppkes
2022-04-25 13:02             ` Martin Storsjö
2022-04-25 13:36               ` Soft Works
2022-04-29 19:08                 ` nil-admirari
2022-04-25 13:17             ` Soft Works
2022-04-29 18:59               ` nil-admirari
2022-04-29 18:52           ` nil-admirari
2022-04-30 12:34             ` Soft Works
2022-05-05 20:20               ` nil-admirari
2022-05-05 22:38                 ` Soft Works
2022-05-06 16:07                   ` nil-admirari
2022-05-07  2:57                     ` Soft Works
2022-05-07 17:33                       ` nil-admirari
2022-05-07 17:59                         ` Soft Works
2022-05-10 21:22                           ` nil-admirari
2022-05-10 22:59                             ` Soft Works
2022-05-10 23:32                               ` Soft Works
2022-05-11  7:46                                 ` Tobias Rapp
2022-05-11  7:57                                   ` Soft Works
2022-05-11  8:08                                     ` Hendrik Leppkes
2022-05-11  9:03                                     ` nil-admirari
2022-05-11 13:32                                     ` Tobias Rapp
2022-05-11 20:50                                       ` Soft Works
2022-05-11  8:57                               ` nil-admirari
2022-05-14  0:42                                 ` Soft Works
2022-05-15 19:53                                   ` nil-admirari
2022-05-15 20:34                                     ` Soft Works
2022-05-16  8:49                                       ` nil-admirari
2022-05-08 19:48                       ` Martin Storsjö
2022-04-25 20:51     ` Stephen Hutchinson
2022-04-29 19:25       ` nil-admirari

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