jpeg2000dec: Add more checks when parsing headers

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
dca_parser: Handle changes in DCA frame size

A change in framesize caused a perpetual loss of synchronization.
So read (and use) the frame size from the frame header instead of
setting it only once.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
rtmpproto: Check for the right return code

Signed-off-by: Martin Storsjö <martin@martin.st>
rtmpproto: Consistently use the right prev_pkt array

prev_pkt[0] is used for input packets, while prev_pkt[1] is
used for output.

Signed-off-by: Martin Storsjö <martin@martin.st>
rtmpproto: Extend a comment to explain the prev_pkt arrays roles

Signed-off-by: Martin Storsjö <martin@martin.st>
xmv: Add more sanity checks for parameters read from the bitstream

Since the number of channels is multiplied by 36 and assigned to
to a uint16_t, make sure this calculation didn't overflow. (In
certain cases the calculation could overflow leaving the
truncated block_align at 0, leading to divisions by zero later.)

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
rtmp: Support reading interleaved chunks.

A given packet won't always come in contiguously; sometimes
they may be broken up on chunk boundaries by packets of another
channel.

This support primarily involves tracking information about the
data that's been read, so the reader can pick up where it left
off for a given channel.

As a side effect, we no longer over-report the bytes read if
(toread = MIN(size, chunk_size)) == size

Signed-off-by: Martin Storsjö <martin@martin.st>
twinvqdec: Check the ibps parameter separately

This is required, since invalid parameters actually could
pass the switch check below.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
movenc: Write the moof atom in two passes

This is a bit more work, but avoids having to fill in
the data offset field afterwards instead of directly when
the rest of the trun atom is written.

This simplifies future cases where this field needs to be set to
something different.

Signed-off-by: Martin Storsjö <martin@martin.st>
movenc: Add an option for omitting the tfhd base offset

This makes the output fragments independent of their position in
the output stream, making the output work better when streamed.

QuickTime Player doesn't support fragmented mp4 without the base
data offset, though.

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

* commit '18a245a2aea31b92bc435f2962a71e060d83b5f7':
  jpeg2000dec: Add more checks when parsing headers

The check cannot be true in FFmpeg, but does no harm.
I will move it in a subsequent commit so it can detect missing SIZ

Merged-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/jpeg2000dec: move "missing SIZ" check up

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
rmdec: Validate the fps value

Abort if it is invalid if strict error checking has been requested.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
Merge commit '8411baf6f0a42bdd61f00f34aa9efec7e138b5f2'

* commit '8411baf6f0a42bdd61f00f34aa9efec7e138b5f2':
  dca_parser: Handle changes in DCA frame size

Conflicts:
	libavcodec/dca_parser.c

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

* commit '0d3784396b736374a61fea26268febdabd803a59':
  rtmpproto: Check for the right return code

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

* commit '647d655d19c38e9716328e4787199149097d6089':
  rtmpproto: Consistently use the right prev_pkt array

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

* commit 'dc4acc820076b2149ef6c921bdabe05d07ca1bc6':
  rtmpproto: Extend a comment to explain the prev_pkt arrays roles

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

* commit 'd4c2a3740fb95f952a87ba320d2bf31f126bdf68':
  xmv: Add more sanity checks for parameters read from the bitstream

Conflicts:
	libavformat/xmv.c

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

* commit '8583b14252deac71136f1dec231910abab0ba503':
  rtmp: Support reading interleaved chunks.

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

* commit 'c77d409bf95954aceb762dd800d1ee2868c4b0d4':
  twinvqdec: Check the ibps parameter separately

See: b8dc5f8bb3b14bfd2289a0444c7b706299555d97
See: 98b377004d9c6fa1c1756c814efe9882b65f96b9
Merged-by: Michael Niedermayer <michaelni@gmx.at>