jpeg2k: use a shorter name
jpeg2k: Check for resolution levels overflow

There are 32 maximum decomposition levels, thus 33 resolution levels.
jpeg2k: define the maximum decomposition levels

And define the resolution levels according.
jpeg2k: Clean up return paths and error messages
jpeg2k: Check the number components and tile dimensions

Prevent buffer overreads.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2k: Use bytestream2

Prevent a number of overreads.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2k: Validate Isot

Make sure once we support more than a tile we do not access
over the allocated buffer.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2k: Report we support only 3 components currently

Fixes out of array accesses.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
wip: merge: jpeg2k: Check Psot size

Fixes a possible overread.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
jpeg2k: Use av_mallocz_array to allocate the tiles buffer

Prevent potential integer overflow.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2k: Reset numX/Ytiles if tiles failed allocation

Avoid a NULL pointer dereference

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
jpeg2k: Check lengthinc against array size

Avoid overread.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
jpeg2k: Check cblk size

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2k: Check nonzerobits validity

Prevent integer overflows.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2000dec: Check compno in get_coc()

Fixes out of array accesses

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
jpeg2k: check len before parsing header

Avoid overread.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
jpeg2k: simplify getsigctxno()

Drop two unnecessary returns.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
jpeg2k: remove an unnecessary field in Jpeg2KCodingStyle

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
j2k/jpeg2000 headers: Cblk/Prec cleanup & merge

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

Conflicts:

	libavcodec/j2k.h
j2k/jpeg2000: restructure cblk coord

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

Conflicts:

	libavcodec/j2k.c