Revert "pnm: remove nonsense code"

Breaks decoding pgms with 255 < maxval < 65535.

Found-by: Carl Eugen Hoyos <cehoyos@ag.or.at>.

This reverts commit a0348d0966a81a66f3a1bf061576b24d5296b933.
(cherry picked from commit 768e40b451a459fefaceed6b1b3d6e70c93596ac)
avcodec/kmvc: fix MV checks

Fixes Ticket2813
Fixes regression since 70b5583

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 3cd8aaa2b2e78faf039691e1c31ff4f8d94e3bc6)
movenc: ilbc needs audio_vbr set.

Without this the block_align or bitrate value is not available to the decoder

Fixes Ticket2858

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 3d64845600c6486a2706b118a81805f3bf4d3db5)
swr: clean layouts before checking sanity

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 6dfffe92004dfd8c79d18791f28a2b1c7e387845)
swr/rematrix: Fix handling of AV_CH_LAYOUT_STEREO_DOWNMIX output

Fixes Ticket2859

Note, testcases related to the downmix channels are welcome.
(id like to make sure this is working correctly now, as obviously it didnt
 work before ...)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit c56d4dab039b352961cca298d753b04e2f2fd990)
avfilter: fix plane validity checks

Fixes out of array accesses

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

Conflicts:

	libavfilter/vf_delogo.c
	libavfilter/vf_fieldmatch.c
	libavfilter/vf_fieldorder.c
	libavfilter/vf_hflip.c
	libavfilter/vf_kerndeint.c
	libavfilter/vf_lut.c
	libavfilter/vf_pad.c
	libavfilter/vf_showinfo.c
	libavfilter/vf_vignette.c

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avformat/paf: Fix integer overflow and out of array read

Found-by:  Laurent Butti <laurentb@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit f58cd2867a8af2eed13acdd21d067b48249b14a1)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/flashsv: check diff_start/height

Fixes out of array accesses
Fixes Ticket2844

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/rpza: Perform pointer advance and checks before using the pointers

Fixes out of array accesses
Fixes Ticket2850

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
jpeg2000: check log2_cblk dimensions

Fixes out of array access
Fixes Ticket2895

Found-by: Piotr Bandurski <ami_stuff@o2.pl>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 9a271a9368eaabf99e6c2046103acb33957e63b7)

Conflicts:

	libavcodec/jpeg2000dec.c

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