Do not set mkv bit_depth to av_get_bytes_per_sample() for G.726.

The value is wrong and leads to broken files.
(cherry picked from commit 565102dcac4959da60e6b1528dc31315d21194ca)
Do not read mkv audio bit_depth if bits_per_coded_sample is already set.

This allows decoding broken mkv files containing G.726 audio.
(cherry picked from commit 11329370770e5c982deece7d4eb4f2e95e725332)
avcodec/ffv1dec: fix format detection

Fixes crash with carefuly designed files.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
(cherry picked from commit a27227d401adf12534dc7a26d72e43e2f35f8944)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
ffserver: strip odd chars from html error messages before sending them back

Fixes Ticket3034

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avfilter/ff_insert_pad: fix order of operations

Fixes out of bounds access
Fixes CID732170
Fixes CID732169

No filter is known to use this function in a way so the issue can be reproduced.

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

Conflicts:

	libavfilter/avfilter.c
(cherry picked from commit 86591b244f3a27293153896813f5569b49b2f5c0)

Conflicts:

	libavfilter/avfilter.c
avcodec/avpacket/av_packet_split_side_data: ensure that side data padding is initialized

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/utils: add some saftey checks to add_metadata_from_side_data()

This fixes potential overreads with crafted files.

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

Conflicts:

	libavcodec/utils.c
avutil/opt: initialize ret

Fixes CID1108610
Fixes use of uninitialized variable

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/jpeglsdec: check err value for ls_get_code_runterm()

Fixes infinite loop
Fixes Ticket3086

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avformat/thp: fix variable types to avoid overflows

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avformat/thp: force moving forward

Fixes infinite loop
Fixes Ticket3098

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
h264: Do not treat the initial frame special in handling of frame gaps

The not handling of frame gaps has lead to the lack of a dummy reference
frame, which has lead to the failure of decode_slice_header() which has
lead to one SEI recovery message being skiped which had introduced a
slightly suboptimal recovery point for at least 1 h264 file compared to
JM.

Found-by: Carl & BugMaster
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 9e5ef1c5c37208326c59d642e2dc7afd3f10b09b)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec: move end zeroing code from av_packet_split_side_data() to avcodec_decode_subtitle2()

This code changes the input packet, which is read only and can in
rare circumstances lead to decoder errors. (i run into one of these in
the audio decoder, which corrupted the packet during av_find_stream_info()
so that actual decoding that single packet failed later)
Until a better fix is implemented, this commit limits the problem.
A better fix might be to make the subtitle decoders not depend on
data[size] = 0 or to copy their input when this is not the case.
(cherry picked from commit 01923bab98506b1e98b4cbf08419364ce6ffea6d)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/libopusenc: change default frame duration to 20 ms

20 ms is used by libopus encoder.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
(cherry picked from commit 74906d3727ec3bd9b7b28dfa7a98ff6e8cf8b6d7)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/error_resilience: factor er_supported() check out

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/error_resilience: check that er is supported before attempting to read the status of the previous slice

Fixes incorrectly set error_occured and improves speed

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avutil/log: skip IO calls on empty strings

These occur when no context is set for example, thus they are common

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
evrcdec: use memmove() instead of memcpy() when regions can overlap.

This occurs also with valid files.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 5ae484e350e4f1b20b31802dac59ca3519627c0a)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
svq3: use memmove to avoid overlap in memcpy.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 4c8ce750abaa783109630d41ca7dde5de34f6197)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/mpegvideo_motion: Check P field references

If a reference is unavailable use a field from the current
picture
Fixes null pointer dereference

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 23daee0dcc57b647b9d62d4c905e94acf0c6b8e0)

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