avcodec/mpeg12dec: do not trust AVCodecContext input dimensions

Fixes initial wtv dimensions
Fixes Ticket4070
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 77f1199e8fd9a289ad64eb2bb5bd4deeda8bccb8)
ffmpeg_opt: store canvas size in decoder context

Fixes canvas size
Fixes Ticket4074

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 66b9e60af0b82ee8bd63d84011127dca4ea1e23f)
avcodec/h264_sei: ff_h264_decode_sei: dont try to parse trailing zeroes

reduces noise for tserrors.ts

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 688a40b4ed7d2e07d3f96c2feecf785a4866e60c)
Use -fno-optimize-sibling-calls on parisc also for gcc 4.9.

Fixes fate on hppa.
Found-by: Andreas Cadhalpun.
(cherry picked from commit f2ffaae9ac93e221a0e1e11ea3581422323abd2f)
avcodec/mpegaudio_parser: fix off by 1 error in bitrate calculation

Fixes Ticket3918

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 817663897e59f45f60016fa9d3d16e325b803967)
Remove fminf() emulation.

The emulation is unused and causes compilation trouble on systems
where fminf() is defined in <math.h> but missing from libm.
This should fix compilation on Debian powerpcspe.
(cherry picked from commit 4436a8f44dedc83767b3d9da9beb85d1fae2ca30)
Revert "v4l2: setting device parameters early"

This reverts commit b1ad9312331759679a9c956233716a67ae681d89.

Fixes Ticket #3517

Requested-by: Giorgio Vazzana <mywing81@gmail.com>
Merged-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 6f21fb793238ab6a790b94b86084148d99373ddf)

Conflicts:
	libavdevice/v4l2.c
configure: Hack to treat x32 as x86_64.

Allows shared compilation on x32 with --disable-asm.
(cherry picked from commit 5e8e2f3861dfbc4864490401c5209fbc24df3c29)
mp3enc: fix a triggerable assert

We have to check against the number of bytes actually needed, not the
theoretical maximum size.
avformat/segment: export inner muxer timebase

Fixes "Non-monotonous DTS in output stream 0:0"
Fixes Ticket4020

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit ce80f9fee97160049687bbbef4eb31a68166c3ee)
avformat/dtsdec: dts_probe: check reserved bit, check lfe, check sr_code similarity

Fixes misdetection of s16le
Fixes Ticket4109

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 0dba982bb4f711447fcbb62d381d24f820c35084)
swscale: support internal scaler cascades

Fixes Ticket3170

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit fba894615d694584057adb0ddb4d609486cad807)

Conflicts:
	libswscale/version.h
swscale/utils: support bayer input + scaling, and bayer input + any supported output

Fixes Ticket4053

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 2f6bb86f85886a7fb36e8a10e4dd8cc3a1849377)
cinedec: report white balance gain coefficients using metadata

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 2093c1dc51ee1c08cb558759a1c59e6d1e3358a0)
avfilter/vf_lut: gammaval709()

See http://www.itu.int/rec/R-REC-BT.709
Item 1.2, overall opto-electronic transfer characteristics at source

Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit b186b7131e160d7e3ea8ef4c52745b56ddcb287b)
avformat/avidec: fix handling dv in avi

Fixes Ticket4086

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit f0ae0354d3f04c369257c2a28557524d28c5df15)
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>.

(cherry picked from commit 2443e522f0059176ff8717c9c753eb6fe7e7bbf1)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
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>
(cherry picked from commit fbd6c97f9ca858140df16dd07200ea0d4bdc1a83)
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
(cherry picked from commit 1973079417e8701b52ba810a72cb6c7c6f7f9a56)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Merge commit '12700b0219521a5f20c8ba47b3ad7857ea9e0554' into release/2.4

* commit '12700b0219521a5f20c8ba47b3ad7857ea9e0554':
  mp3enc: fix a triggerable assert

Conflicts:
	libavformat/mp3enc.c

No change as the faulty assert is not in FFmpeg

Merged-by: Michael Niedermayer <michaelni@gmx.at>