[FFmpeg-devel] [PATCH v3 4/5] fftools/cmdutils.c: Replace MAX_PATH-sized buffers with dynamically sized ones

Martin Storsjö martin at martin.st
Fri Feb 18 22:09:07 EET 2022


On Thu, 17 Feb 2022, nil-admirari at mailo.com wrote:

>> if the path later is going to end up in a codepath that expects it to be UTF8 (please do check!), then we should go that way instead
>
> I checked. datadir ends up in (cmdutils.c:2104)
>
>    base[2] = datadir;
>
> and base[*] are later used in (cmdutils.c:2112 or 2116)
>
>    snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i],
>             i != 1 ? "" : "/.ffmpeg", preset_name);
>    f = fopen(filename, "r");
>
> On Windows fopen expects ANSI encoded strings, so we cannot change the 
> encoding to UTF-8 without rewriting the rest of the function.

Ok, well maybe we should change that too, to use wchar paths (or 
utf8->whcar routines?). But maybe those are libavutil internals that 
cmdutils shouldn't use?

If we stick with this form, with ansi paths, it would be good to leave a 
comment at the call to wchartoansi(), to explain why that doesn't use 
UTF-8 like everything else.

// Martin



More information about the ffmpeg-devel mailing list