Commit Graph

12 Commits

Author SHA1 Message Date
Andreas Rheinhardt e3b355c0be avutil/mem: Don't include avutil.h
It is not necessary at all. So remove it.
This also breaks an inclusion cycle mem.h->avutil.h->common.h->mem.h.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:42:10 +02:00
L. E. Segovia ddc1cd5cdd configure: Set WIN32_LEAN_AND_MEAN at configure time
Including winsock2.h or windows.h without WIN32_LEAN_AND_MEAN cause
bzlib.h to parse as nonsense, due to an instance of #define char small
in rpcndr.h.

See:

https://stackoverflow.com/a/27794577

Signed-off-by: L. E. Segovia <amy@amyspark.me>
Signed-off-by: Martin Storsjö <martin@martin.st>
2023-08-14 22:57:28 +03:00
James Almer 92885f2681 avutil/wchar_filename: propagate MultiByteToWideChar() and WideCharToMultiByte() failures
Don't return success if the string could not be converted.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-14 10:04:47 -03:00
Andreas Rheinhardt 4454142782 avutil/wchar_filename: Make the header C++ compatible
When compiling decklink, this header is included from
a C++ file (albeit inside 'extern "C"') and this
causes compilation failures because of an implicit
void* -> char* conversion. So add an explicit cast.
Fixes ticket #9819.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-28 10:59:31 +02:00
Nil Admirari cc5844da98 libavutil: Add wchartoutf8(), wchartoansi(), utf8toansi(), getenv_utf8(), freeenv_utf8() and getenv_dup()
wchartoutf8() converts strings returned by WinAPI into UTF-8,
which is FFmpeg's preffered encoding.

Some external dependencies, such as AviSynth, are still
not Unicode-enabled. utf8toansi() converts UTF-8 strings
into ANSI in two steps: UTF-8 -> wchar_t -> ANSI.
wchartoansi() is responsible for the second step of the conversion.
Conversion in just one step is not supported by WinAPI.

Since these character converting functions allocate the buffer
of necessary size, they also facilitate the removal of MAX_PATH limit
in places where fixed-size ANSI/WCHAR strings were used
as filename buffers.

On Windows, getenv_utf8() wraps _wgetenv() converting its input from
and its output to UTF-8. Strings returned by getenv_utf8()
must be freed by freeenv_utf8().

On all other platforms getenv_utf8() is a wrapper around getenv(),
and freeenv_utf8() is a no-op.

The value returned by plain getenv() cannot be modified;
av_strdup() is usually used when modifications are required.
However, on Windows, av_strdup() after getenv_utf8() leads to
unnecessary allocation. getenv_dup() is introduced to avoid
such an allocation. Value returned by getenv_dup() must be freed
by av_free().

Because of cleanup complexities, in places that only test the existence
of an environment variable or compare its value with a string
consisting entirely of ASCII characters, the use of plain getenv()
is still preferred. (libavutil/log.c check_color_terminal()
is an example of such a place.)

Plain getenv() is also preffered in UNIX-only code,
such as bktr.c, fbdev_common.c, oss.c in libavdevice
or af_ladspa.c in libavfilter.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-06-21 13:27:46 +03:00
softworkz c5aba39a04 avutil/wchar_filename,file_open: Support long file names on Windows
Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-06-09 13:03:47 +03:00
Andreas Rheinhardt 1ea3650823 Replace all occurences of av_mallocz_array() by av_calloc()
They do the same.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 01:03:52 +02:00
James Almer f87ad3a058 Merge commit 'e41daa62465036ad36ad0bd14e4936e848d7f07e'
* commit 'e41daa62465036ad36ad0bd14e4936e848d7f07e':
  Remove support for building for mingw32ce (Windows CE)

Merged-by: James Almer <jamrial@gmail.com>
2017-11-11 10:22:11 -03:00
Martin Storsjö e41daa6246 Remove support for building for mingw32ce (Windows CE)
The toolchain for this target is unmaintained since many years.

While it has been continuously build tested on fate, it hasn't
actually been tested at runtime since many, many years (and back
then, only a few codecs in libavcodec were tested).

So far, keeping support for it has been mostly effortless, but
the compiler does seem to have issues with dllimported data symbols,
ending up as internal compiler errors in some cases. Instead of
jumping through further hoops to work around that, just remove the
target.

Signed-off-by: Martin Storsjö <martin@martin.st>
2017-08-31 14:21:08 +03:00
Ganesh Ajjanagadde 191f611906 avutil/wchar_filename: add av_warn_unused_result
Current code is fine, this just adds robustness.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-30 13:47:28 -04:00
Michael Niedermayer 097de4d1d6 Merge commit '9326d64ed1baadd7af60df6bbcc59cf1fefede48'
* commit '9326d64ed1baadd7af60df6bbcc59cf1fefede48':
  Share the utf8 to wchar conversion routine between lavf and lavu

Conflicts:
	libavformat/os_support.h
	libavutil/file_open.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-27 11:10:26 +01:00
Martin Storsjö 9326d64ed1 Share the utf8 to wchar conversion routine between lavf and lavu
This doesn't add any dependency on library internals, since this
only is a static inline function that gets built into each of the
calling functions - this is only to reduce the code duplication.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-27 09:29:17 +02:00