vcr1: add sanity checks

Fixes invalid reads with corrupted files.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
pictordec: break out of both decoding loops when y drops below 0

Otherwise picmemset can get called with negative y, resulting in an
invalid write.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
pictordec: pass correct context to avpriv_request_sample

Fixes invalid reads.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
lavf: move a variable declaration to the block where it's used
lavf: avoid integer overflow when estimating bitrate

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
4xm: check that bits per sample is strictly positive

Avoids a divide by zero.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
ape demuxer: check for EOF in potentially long loops

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
cosmetics: Fix ATRAC codec name spelling
movenc: Don't flush after each written packet

This should improve write performance quite significantly.
---
Tested with both writing a normal mp4, by using the faststart
feature and writing a fragmented mp4 file; all turn out with the
same md5sum as before.

Signed-off-by: Martin Storsjö <martin@martin.st>
Merge commit '8aba7968dd604aae91ee42cbce0be3dad7dceb30'

* commit '8aba7968dd604aae91ee42cbce0be3dad7dceb30':
  vcr1: add sanity checks

Conflicts:
	libavcodec/vcr1.c

See: 845724c82c1a732ab398c9e8cedd178f96f1626d
See: 8e09482e4d27d65bbce2ce5c2f4392216011ed09
Merged-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/vcr1: replace redundant checks from libav (8aba7968dd604aae91ee42cbce0be3dad7dceb30)  by asserts

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit '5f7aecde02a95451e514c809f2794c1deba80695'

* commit '5f7aecde02a95451e514c809f2794c1deba80695':
  pictordec: break out of both decoding loops when y drops below 0

Conflicts:
	libavcodec/pictordec.c

The added check is redundant.
It shows the error path more clearly though

See: f3f488423a12af9bb4eed6e6868cfa86ece3571b
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit 'fe9bb61f9a16be19ad91875632c39e44b7a99a8a'

* commit 'fe9bb61f9a16be19ad91875632c39e44b7a99a8a':
  pictordec: pass correct context to avpriv_request_sample

Conflicts:
	libavcodec/pictordec.c

No change as the avpriv_request_sample() has already been replaced by an implementation
of the codepath.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
riff: add 0x64 to g726 works on g726-test1.wav
Merge commit 'fab694dd3931b1c0bc3c598c3f88b1902c14a303'

* commit 'fab694dd3931b1c0bc3c598c3f88b1902c14a303':
  lavf: move a variable declaration to the block where it's used

Conflicts:
	libavformat/utils.c

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

* commit 'df33a58e5311ee9a64a573889b883a80e981af7b':
  lavf: avoid integer overflow when estimating bitrate

Merged-by: Michael Niedermayer <michaelni@gmx.at>
avformat/utils: Fix bitrate overflow check

The check added in df33a58e5311ee9a64a573889b883a80e981af7b does not work
at all, rather it broke the summing of bitrates completely.
The comparission was wrong way around.
This commit replaces it by a simpler and hopefully clearer check

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit 'a7c1689dedd11689edb30088d467ac03f9b8d1cf'

* commit 'a7c1689dedd11689edb30088d467ac03f9b8d1cf':
  4xm: check that bits per sample is strictly positive

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

* commit '488b2984fece7ad0c2596826fee18e74aa904667':
  ape demuxer: check for EOF in potentially long loops

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

* commit '7df9e693a34c84c698da60426c78140c950f95ed':
  cosmetics: Fix ATRAC codec name spelling

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