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>
lavf: Use MoveFileEx instead of rename/_wrename on windows

This allows getting the normal unix semantics, where a rename
allows replacing an existing file.

Based on a suggestion by Reimar Döffinger.

Signed-off-by: Martin Storsjö <martin@martin.st>
Revert "lavf: Don't try to update files atomically with renames on windows"

This reverts commit b9d08c77a44390b0848c06f20bc0e9e951ba6a3c.

After taking MoveFileEx into use, we can replace files with renames
on windows as well.

Signed-off-by: Martin Storsjö <martin@martin.st>
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>
Merge commit '79fd186a5035cf16fc0ab288d8f59da8b1ba2c0e'

* commit '79fd186a5035cf16fc0ab288d8f59da8b1ba2c0e':
  lavf: Use MoveFileEx instead of rename/_wrename on windows

Conflicts:
	configure

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit '675ac56b7ee0f204963fde55295197c5df80aa91'

* commit '675ac56b7ee0f204963fde55295197c5df80aa91':
  Revert "lavf: Don't try to update files atomically with renames on windows"

Conflicts:
	libavformat/dashenc.c
	libavformat/hdsenc.c
	libavformat/internal.h
	libavformat/smoothstreamingenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
libavutil/ppc/util_altivec.h : fix load_with_perm_vec() add marcos vcswapi2s() vcswapc() VEC_SPLAT16() VEC_SLD16() for POWER LE

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
msvc: Fix compilation errors due to header include order.

Ensures that the header include order is such that winsock2.h is always
included before windows.h or that windows.h does not include winsock.h.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
lavu: add wrappers for the pthreads mutex API

Also add no-op fallbacks when threading is disabled.

This helps keeping the code clean if Libav is compiled for targets
without threading. Since we assume that no threads of any kind are used
in such configurations, doing nothing is ok by definition.

Based on a patch by wm4 <nfxjfg@googlemail.com>.
lavu: fix memory leaks by using a mutex instead of atomics

The buffer pool has to atomically add and remove entries from the linked
list of available buffers. This was done by removing the entire list
with a CAS operation, working on it, and then setting it back again
(using a retry-loop in case another thread was doing the same thing).

This could effectively cause memory leaks: while a thread was working on
the buffer list, other threads would allocate new buffers, increasing
the pool's total size. There was no real leak, but since these extra
buffers were not needed, but not free'd either (except when the buffer
pool was destroyed), this had the same effects as a real leak. For some
reason, growth was exponential, and could easily kill the process due
to OOM in real-world uses.

Fix this by using a mutex to protect the list operations. The fancy
way atomics remove the whole list to work on it is not needed anymore,
which also avoids the situation which was causing the leak.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
vf_interlace: get rid of useless loads

Signed-off-by: Anton Khirnov <anton@khirnov.net>
opusdec: make sure all substreams have the same number of coded samples

Fixes invalid writes with invalid multichannel streams.

CC:libav-stable@libav.org
lavu/imgutils: remove redundant and wrong check in av_image_fill_arrays
avcodec/hevc_ps: More complete window reset

Fixes out of array read
Fixes: signal_sigsegv_35bcf26_471_cov_2806540268_CAINIT_A_SHARP_4.bit
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
ffmpeg: Print a debug message if the frame parameters mismatch the context

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avformat/mov: strengthen some table allocations
avformat/mov: change conjugation for "Duplicate"
avcodec/mjpegdec: Fix integer overflow in shift

Fixes: signal_sigabrt_7ffff6ac7bb9_2683_cov_4120310995_m_ijpg.avi
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avformat/udp: Allow to specify DSCP class

By appending `?dscp=26` to the URL, IP packets will be classified as
AF31 (assured forwarding for multimedia flows with low probability of
loss). On congested network, this allows a user to assign priorities to
flows.

Signed-off-by: Vincent Bernat <vincent@bernat.im>
avformat/rtpproto: Allow to specify DSCP class

By appending `?dscp=26` to the URL, IP packets will be classified as
AF31 (assured forwarding for multimedia flows with low probability of
loss). On congested network, this allows a user to assign priorities to
flows.

Signed-off-by: Vincent Bernat <vincent@bernat.im>