Commit Graph

303 Commits

Author SHA1 Message Date
Michael Niedermayer 2be0bd12b7 avcodec/jpeg2000dec: Fix return type of get_plt()
Found-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-04-25 19:18:29 +02:00
Michael Niedermayer e627113329 avcodec/jpeg2000dec: Check PLT data somewhat
Fixes: Timeout (21sec -> 0.6sec)
Fixes: 14134/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5768371078955008

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-04-25 14:49:51 +02:00
Michael Niedermayer 6381b6f6a9 avcodec/jpeg2000dec: Replace the step_x/y assert by a check in the CPRL case as with the PCRL case
Fixes: assertion failure
Fixes: 14246/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5758393601490944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-04-25 14:49:51 +02:00
Michael Niedermayer b8f53a2342 avcodec/jpeg2000dec: Skip de-quantization of empty areas
Fixes: Timeout (26sec -> 18sec)
Fixes: 13448/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-576903098243481

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-03-25 13:20:30 +01:00
Michael Niedermayer fe0416f8a1 avcodec/jpeg2000dec: Skip DWT if nothing is coded
Improves speed in uncommon case

Fixes: Timeout
Fixes: 10964/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5132066034286592

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-12-08 17:01:03 +01:00
Michael Niedermayer 305e523105 avcodec/jpeg2000dec: Fix off by 1 error in JPEG2000_PGOD_CPRL handling
Fixes: assertion failure
Fixes: 10785/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5672160496975872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-10-23 00:51:55 +02:00
Michael Niedermayer 652d7c6348 avcodec/jpeg2000dec: Fixes invalid shifts in jpeg2000_decode_packets_po_iteration()
Fixes: shift exponent 47 is too large for 32-bit type 'int'
Fixes: 9163/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5661750182543360

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-07-04 01:10:28 +02:00
Michael Niedermayer 0898a3d990 avcodec/jpeg2000dec: Check that there are enough bytes for all tiles
Fixes: OOM
Fixes: 8781/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5810709081358336

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-07-04 01:10:28 +02:00
Carl Eugen Hoyos 1083808c48 lavc/jpeg2000dec: Move a variable declaration closer to its usage. 2018-05-22 12:55:46 +02:00
Carl Eugen Hoyos 848ce6f0a6 lavc/jpeg2000dec: Use a define to clarify the meaning of a constant. 2018-05-22 12:54:32 +02:00
Michael Niedermayer 652ba72ed3 avcodec/jpeg2000dec: Fix undefined shift in the jpeg2000_decode_packets_po_iteration() CPRL case
Fixes: shift exponent 47 is too large for 32-bit type 'int'
Fixes: 7955/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6016721977606144

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-06 21:02:04 +02:00
Michael Niedermayer a96c131eb5 avcodec/jpeg2000dec: Skip init for component in CPRL if nothing is to be done
Fixes: assertion failure
Fixes: 7949/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-4819602782552064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-06 21:02:04 +02:00
Michael Niedermayer 3543522d20 avcodec/jpeg2000dec: Reduce the number of tile parts allocated
This is large enough for all jpeg2000 files i tested. If some need more then this
should be changed to dynamic allocation. Dynamic allocation would need to be done
carefully as these are many relatively small arrays so repeatly reallocating them
would not be good.
The decrease is a clean and simple solution assuming it works for all files.

Fixes: OOM
Fixes: 6534/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-4821490731057152

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-06 21:02:04 +02:00
Michael Niedermayer 01370b31ac avcodec/jpeg2000dec: Use av_image_check_size2()
Fixes: OOM
Fixes: 5733/clusterfuzz-testcase-minimized-4906757966004224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-02-17 20:31:39 +01:00
Muhammad Faiz 3caecf7ce8 avcodec: do not use init_static_data on some codecs
They don't modify AVCodec, no needs to call it at register. They will be
wasteful if these codecs are unused. Instead, call static data initialization
at codecs' init.

Benchmark:
old: 51281340 decicycles in avcodec_register_all,       1 runs,      0 skips
new:  6738960 decicycles in avcodec_register_all,       1 runs,      0 skips

Reviewed-by: wm4 <nfxjfg@googlemail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
2018-02-04 06:11:07 +07:00
Carl Eugen Hoyos 658bdc6771 lavc/jpeg2000dec: Support reading 64-bit atom size.
Fixes ticket #6935.
2017-12-28 02:58:56 +01:00
Michael Niedermayer 80344959f0 avcodec/jpeg2000dec: Free lengthinc earlier
Reduces memory needed

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-12-21 19:48:41 +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 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
Carl Eugen Hoyos b998a56b0a lavc/jpeg2000dec: Fix used variables reading palette.
Affected files with palette and colour-depth < 8.
2017-11-12 04:29:06 +01:00
Michael Niedermayer 5d0b69f3b7 avcodec/jpeg2000dec: Fix h/vden typo
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-07-27 00:01:27 +02:00
Michael Niedermayer 1b00600319 avcodec/jpeg2000dec: Fix division by zero in jp2_find_codestream()
Fixes: 2707/clusterfuzz-testcase-minimized-5179636394754048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-07-26 17:06:29 +02:00
Carl Eugen Hoyos 4c1aac893c lavc/jpeg2000dec: Read the sample aspect ratio from the jp2 resolution box. 2017-07-18 11:51:10 +02:00
Michael Niedermayer dfb61ea263 avcodec/jpeg2000dec: Check nonzerobits more completely
Fixes: runtime error: shift exponent 36 is too large for 32-bit type 'int'
Fixes: 2239/clusterfuzz-testcase-minimized-5639766592716800

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 20:32:39 +02:00
Michael Niedermayer f3da6fbff8 avcodec/jpeg2000dec: Use ff_set_dimensions()
Fixes: OOM
Fixes: 1890/clusterfuzz-testcase-minimized-6329019509243904

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-29 13:46:09 +02:00
Michael Niedermayer 9c1812491f avcodec/jpeg2000dec: Check tile offsets more completely
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-28 13:52:13 +02:00
Michael Niedermayer 5782e0ba8c avcodec/jpeg2000dec: Fix copy and paste error
Found-by: jamrial
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-25 11:29:12 +02:00
Michael Niedermayer 89325417e7 avcodec/jpeg2000dec: Check tile offsets
Fixes: runtime error: signed integer overflow: 4096 - -2147483648 cannot be represented in type 'int'

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-24 19:41:15 +02:00
Carl Eugen Hoyos a75ef1506a lavc/jpeg2000dec: Fix jp2 inner atom size used for overread checks. 2017-05-03 03:45:33 +02:00
Paul B Mahol 585cfabb79 avcodec/jpeg2000dec: add slice threading support
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-25 22:00:52 +01:00
Paul B Mahol e2298b3fcc avcodec/jpeg2000dec: account two last bytes from end of bytestream as EOC marker
This silences missing EOC marker when decoding j2k files with Psot set to 0.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-25 22:00:52 +01:00
Michael Niedermayer 0aada30510 avcodec/jpeg2000dec: More completely check cdef
Fixes out of array read
Fixes: j2k-poc.bin

Found-by: Lucas Leong <wmliang.tw@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-27 17:18:00 +01:00
Hendrik Leppkes 5e8b053452 Merge commit '2c6811397bdf13d43ca206e48d6d6da9c2cd47c6'
* commit '2c6811397bdf13d43ca206e48d6d6da9c2cd47c6':
  lavc: add profiles to AVCodecDescriptor

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-01-01 16:20:39 +01:00
Anton Khirnov 2c6811397b lavc: add profiles to AVCodecDescriptor
The profiles are a property of the codec, so it makes sense to export
them through AVCodecDescriptors, not just the codec implementations.
2015-12-12 21:22:49 +01:00
Michael Niedermayer a85b02dcf7 avcodec/jpeg2000dec: Check bpno in decode_cblk()
Fixes: undefined shift
Fixes: c409ef86f892335a0a164b5871174d5a/asan_heap-oob_1dff564_2159_162b7234616deab02b544410455eb07b.mov

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-04 18:54:39 +01: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 65d3359fb3 avcodec/jpeg2000dec: Fix potential integer overflow with tile dimensions
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-15 21:36:19 +01:00
Michael Niedermayer 6ef819c40b avcodec/jpeg2000dec: Check SIZ dimensions to be within the supported range
Fixes potential integer overflows
Fixes: 03e0abe721b1174856d41a1eb5d6a896/signal_sigabrt_7ffff6ae7cc9_3813_e71bf3541abed3ccba031cd5ba0269a4.avi

This fix is choosen to be simple to backport, better solution
for master is planed

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-15 21:36:19 +01:00
Michael Niedermayer 44a7f17d0b avcodec/jpeg2000dec: Check for duplicate SIZ marker
Fixes: 0231a17345734228011c6f35a64e4594/asan_heap-oob_1d92a72_3218_1213809a9e3affec77e4c191fdfdc0a9.mov

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-14 00:58:54 +01:00
Michael Niedermayer 43492ff3ab avcodec/jpeg2000dec: Clip all tile coordinates
Fixes out of array access
Fixes: b877a6b788a25c70e8b1d014f8628549/asan_heap-oob_1da2c3f_2324_5a1b329b0b3c4bb6b1d775660ac56717.r3d

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-07 02:17:04 +01:00
Michael Niedermayer c980c5e54d avcodec/jpeg2000dec: Clear properties in jpeg2000_dec_cleanup() too
Fixes: Ticket4878

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-15 22:00:49 +02:00
Michael Niedermayer c08b06c225 avcodec/jpeg2000dec: Check that step_x/y are valid before use in JPEG2000_PGOD_PCRL
Fixes: CID1322305 and CID1322304

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-11 15:43:26 +02:00
Hendrik Leppkes 64f72bb61f Merge commit '29b00f880faa404aa1d0d6820310c510c5996479'
* commit '29b00f880faa404aa1d0d6820310c510c5996479':
  jpeg2000: Templatize the frame writer

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-16 12:08:39 +02:00
Hendrik Leppkes 5a754f92d1 Merge commit '41bcc3d15204f290400ba02e4e8f87fc07bcc00e'
* commit '41bcc3d15204f290400ba02e4e8f87fc07bcc00e':
  jpeg2000: Split codeblock decoding from the main tile decoding

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-16 11:31:40 +02:00
Luca Barbato 1b709f23fb jpeg2000: Refactor decode_packets
Move the packet-specific parsers in separate functions.
2015-09-14 14:31:25 +02:00
Luca Barbato 29b00f880f jpeg2000: Templatize the frame writer 2015-09-14 14:28:03 +02:00
Luca Barbato 41bcc3d152 jpeg2000: Split codeblock decoding from the main tile decoding
That loop is completely stand-alone.
2015-09-14 14:26:54 +02:00
Hendrik Leppkes 84d04a0dfa Merge commit '5788623d29c3e806a7879210986110aced758dc2'
* commit '5788623d29c3e806a7879210986110aced758dc2':
  jpeg2000: Split codeblock decoding from the main tile decoding

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-12 13:25:38 +02:00
Hendrik Leppkes 6e611a1839 Merge commit 'db53a2306f62f05faa67e6f3c60ee55a9b8e4776'
* commit 'db53a2306f62f05faa67e6f3c60ee55a9b8e4776':
  jpeg2000: Do not warn about known and skippable markers

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-12 13:16:13 +02:00
Luca Barbato 5788623d29 jpeg2000: Split codeblock decoding from the main tile decoding
That loop is completely stand-alone.
2015-09-11 18:19:39 +02:00