Message ID | 20220423205626.39039-2-nil-admirari@mailo.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,v11,1/6] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
> -----Original Message----- > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Nil > Admirari > Sent: Saturday, April 23, 2022 10:56 PM > To: ffmpeg-devel@ffmpeg.org > Subject: [FFmpeg-devel] [PATCH v11 2/6] 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 8ba2bdea..f7bea8c3 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.32.0 > LGTM. I had assumed it would depend on 6/6
diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 8ba2bdea..f7bea8c3 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