jpeg2k: drop unused and writeonly fields

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2k: Check that nreslevels2decode has been initialized before use

Avoid buffer overread.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2k: Propagate error code from get_cox()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
jpeg2k: remove unneeded returns
jpeg2k: Check that theres a SOT before SOD

Avoid overread.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
jpeg2k: check that we have enough components for MCT

Avoid overread.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
jpeg2k: Zero prec->cblk

Prevent use of uninitialized memory / valgrind failure

Found-by: ubitux
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
jpeg2k: Fix typo in lut_gain index
jpeg2k: Calculate block coord in ff_jpeg2k_init_component

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2k: fix quantization
jpeg2k: Improve reduced resolution decoding

Correctly scale down the component coordinates and
cleanup a bit the redundant code.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2k: Split int/float codepaths depending on the DWT

DWT53 is always int, DWT97 is always float

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2k: Use separate fields for int and float codepaths

Split stepsize and data in int and float variants.

Spare a good number of casts and make simple spot errors.
jpeg2k: remove unneeded variable initialization

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2k: fix coordinate position

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
jpeg2k: update pixel format support
jpeg2k: simplify init_tile()
jpeg2k: Use the correct sizeof in memset
jpeg2k: Proper cleanup on failure on decode_frame
jpeg2k: Refactor sot parsing