Commit Graph

39 Commits

Author SHA1 Message Date
caleb
6a0cec5315 avcodec/jpeg2000: Fast fail if HTJ2K codeblocks are present.
Reviewed-by: Pierre-Anthony Lemieux <pal@sandflow.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-07 22:01:21 +02:00
Andreas Rheinhardt
faa62773cb avcodec/jpeg2000: Make ff_tag_tree_size() static
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-08 22:59:14 +02:00
Gautam Ramakrishnan
341064d68a libavcodec/jpeg2000: fix tag tree reset
The implementation of the tag tree did not
set the correct reset value for the encoder.
This lead to inefficent tag tree being encoded.
This patch fixes the implementation of the
ff_tag_tree_zero() function.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-30 16:18:37 +02:00
Gautam Ramakrishnan
f0e33119e4 libavcodec/j2kenc: Support for multiple layers
This patch allows setting a compression ratio and to
set multiple layers. The user has to input a compression
ratio for each layer.
The per layer compression ration can be set as follows:
-layer_rates "r1,r2,...rn"
for to create 'n' layers.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-30 16:18:37 +02:00
Gautam Ramakrishnan
3c06045a8b libavcodec/j2kenc: Fix tag tree coding
The implementation of tag tree encoding was incorrect.
However, this error was not visible as the current j2k
encoder encodes only 1 layer.
This patch fixes tag tree coding for JPEG2000 such tag
tree coding would work for multi layer encoding.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-30 16:18:37 +02:00
Gautam Ramakrishnan
87567fc398 libavcodec/jpeg2000: Make tag tree functions non static
This patch makes the tag_tree_zero() and tag_tree_size()
functions non static and callable from other files.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-30 16:18:37 +02:00
Michael Niedermayer
5036d7b20c avcodec/jpeg2000dec: Handle reducedresno of 32
Fixes: shift exponent 32 is too large for 32-bit type 'int'
Fixes: 24566/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6033783737024512

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Gautam Ramakrishnan <gautamramk@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-06 00:38:09 +02:00
Gautam Ramakrishnan
579ac96a04 libavcodec/jpeg2000.c: Precinct size check removed
This patch removes a check which throws an error if
the log2 precinct width/height is 0. The standard allows
the first component to have 0 as the log2 width/height.
However, to ensure proper intialization of coding style,
an extra check has been added.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-06-30 20:35:23 +02:00
Gautam Ramakrishnan
e58766ba12 libavcodec/jpeg2000dec.c: ROI marker support
This patch adds support for decoding images
with a Region of Interest. Allows decoding
samples such as p0_03.j2k. This patch should
fix ticket #4681.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-23 19:30:07 +02:00
Gautam Ramakrishnan
e34157f6ea libavcodec/jpeg2000.h: fix comments for JPEG2000 markers
The comments for some of the markers were incorrect.
This patch fixes the comments associated with the markers.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-03-27 01:42:16 +01:00
Michael Niedermayer
42274db1c6 avcodec/jpeg2000dec: Allocate lengthinc and data_start arrays as needed
Decreases memory requirements
Fixes: OOM
Fixes: 4525/clusterfuzz-testcase-minimized-6400713073623040

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-12-21 19:48:41 +01:00
Michael Niedermayer
b5587fd2c6 avcodec/jpeg2000: Only allocate Jpeg2000Pass for the encoder
Reduces memory needed.
Fixes: OOM
Fixes: 4427/clusterfuzz-testcase-minimized-5106919271301120

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-12-01 23:12:07 +01:00
Michael Niedermayer
3d5822d9cf avcodec/jpeg2000: Dynamically allocate codeblock data
Fixes: OOM
Fixes: 3541/clusterfuzz-testcase-minimized-6469958596820992

Adds support for decoding codeblock data larger than 8kb
Reduces decoder memory consumption

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-11-22 13:06:50 +01:00
Michael Niedermayer
e3fadc57c5 avcodec/jpeg2000: Fixes integer overflow in ff_jpeg2000_ceildivpow2()
Fixes: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: 2231/clusterfuzz-testcase-minimized-4565181982048256

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-06-16 00:21:30 +02:00
Michael Niedermayer
781f88bb26 avcodec/jpeg2000: Fix runtime error: signed integer overflow: 4185 + 2147483394 cannot be represented in type 'int'
Fixes: 1870/clusterfuzz-testcase-minimized-4686788029317120

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-28 14:01:12 +02:00
Michael Niedermayer
0eb7de1973 avcodec/jpeg2000: Change coord to 32bit to support larger than 32k width or height
Fixes: 03e0abe721b1174856d41a1eb5d6a896/signal_sigabrt_7ffff6ae7cc9_3813_e71bf3541abed3ccba031cd5ba0269a4.avi

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-15 22:11:05 +01:00
Michael Niedermayer
317be53ca6 avcodec/jpeg2000: Support 32 decomposition levels
Fixes Ticket4680

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-28 03:16:06 +02:00
Michael Niedermayer
cd1a9908b5 avcodec/jpeg2000: support >32bit in ff_jpeg2000_ceildivpow2()
Fixes part of Ticket4680

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-28 02:31:26 +02:00
Michael Niedermayer
f01028bf58 avcodec/jpeg2000: Avoid one shift in ff_jpeg2000_ceildivpow2()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-28 02:27:43 +02:00
Michael Niedermayer
c72a831931 avcodec/jpeg2000dec: Support progression order changes
Fixes Ticket4657

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-26 21:00:10 +02:00
Michael Niedermayer
f1e173049e avcodec/jpeg2000: Remove CBLK limit
This also reduces the amount of memory needed
Fixes Ticket4672

The new code seems slightly faster as well, probably due to better cache usage

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-26 01:00:17 +02:00
Michael Niedermayer
d7e224ec24 avcodec/jpeg2000: change flags array type to 16bit
reduce memory needed for flags

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-24 17:46:37 +02:00
Michael Niedermayer
d580255571 vcodec/jpeg2000: Increase cblk size limit to 128
Fixes Ticket4649

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-24 17:38:05 +02:00
Michael Niedermayer
4624656797 avcodec/j2kenc: Properly flush the end of the truncated AC stream
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-17 20:39:03 +02:00
Michael Niedermayer
4ec14ce121 avcodec/jpeg2000dec: Improve readability of SOP check
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-15 13:29:41 +02:00
Michael Niedermayer
dc73c7adc0 avcodec/jpeg2000dec: Fix Selective arithmetic coding bypass and Multiple codeword segments
These 2 are highly related so they are in the same commit
Fixes part of Ticket4605
Fixes p0_04.j2k

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-12 03:12:54 +02:00
Michael Niedermayer
b395fd3de7 avcodec/jpeg2000dec: add some sanity checking on newpasses
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-12 02:02:38 +02:00
Michael Niedermayer
b0448e5123 Merge commit 'be3271009ef893fbed9640e8edbd771685fd957b'
* commit 'be3271009ef893fbed9640e8edbd771685fd957b':
  jpeg2000: Define the maximum decomposition levels

Conflicts:
	libavcodec/jpeg2000.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-03 12:02:11 +02:00
Luca Barbato
be3271009e jpeg2000: Define the maximum decomposition levels
And define the resolution levels according.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-07-02 20:05:43 +02:00
Michael Niedermayer
2c2a8f70f5 jpeg2000: Make nreslevel fields int
This prevents potential integer overflows

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-05 18:34:07 +02:00
Michael Niedermayer
62d00aa22f jpeg2000/j2k: merge j2k/jpeg2000.c/h
Now only j2kdec / jpeg2000dec.c remain

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-30 14:57:58 +02:00
Michael Niedermayer
8bedbb82ce j2k/jpeg2000: split data pointer in int & float.
This fixes a TODO item and unifies both decoders structures
It also fixes undefined behavior due to aliasing violations

I choose 2 fields instead of a union because mistakely using the
wrong type with a union will lead to hard to debug "wrong output"
while with 2 fields mistakely using the wrong type will crash
with a null pointer derefernce which is much easier to debug

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-30 14:18:53 +02:00
Michael Niedermayer
fe7136ef82 j2k/jpeg2000: split stepsize in float & int variables
This is more clear and less prone to mistakes.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-28 22:16:14 +02:00
Michael Niedermayer
f82e7330af jpeg2000: merge mant type from j2k
mant fits in 16bit

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-27 22:25:03 +02:00
Michael Niedermayer
8c2e201c4f j2k/jpeg2000: drop xi/yi0/1 from Jpeg2000Prec
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-27 15:53:42 +02:00
Michael Niedermayer
3300b5f6ce j2k/jpeg2000 headers: Cblk/Prec cleanup & merge
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-27 15:13:18 +02:00
Michael Niedermayer
bd89b2b22a j2k/jpeg2000: log2_prec size cleanup
This also changes the cblk size storage method to what jpeg2000 uses

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-26 22:29:11 +02:00
Michael Niedermayer
e2e9bee2da Merge remote-tracking branch 'qatar/master'
* qatar/master:
  avcodec: Bump minor for JPEG 2000 decoder
  JPEG 2000 decoder for DCinema

The mqc code is merged, the rest is added independent of
the existing jpeg2000 decoder and encoder.

Conflicts:
	Changelog
	doc/general.texi
	libavcodec/Makefile
	libavcodec/allcodecs.c
	libavcodec/mqc.c
	libavcodec/mqc.h
	libavcodec/mqcdec.c
	libavcodec/version.h
	tests/fate/video.mak

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-22 20:00:54 +02:00
Nicolas Bertrand
c81a706381 JPEG 2000 decoder for DCinema
Based on the 2007 GSoC project from Kamil Nowosad <k.nowosad@students.mimuw.edu.pl>
Updated to current programming standards, style and many more small
fixes by Diego Biurrun <diego@biurrun.de>.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2013-04-22 15:38:29 +02:00