summaryrefslogtreecommitdiff
path: root/libavcodec/jpeg2000dec.c
Commit message (Collapse)AuthorAge
* avcodec/jpeg2000dec: Make decoder init-threadsafeAndreas Rheinhardt2021-05-12
| | | | | | | | | | | | | | | The JPEG-2000 decoder and encoder share common luts; the decoder initializes them once, guarded by a dedicated AVOnce, whereas the encoder initializes them always during init. This means that the decoder is not init-threadsafe; in fact there is a potential data race because these luts can be initialized while an active decoder/encoder is using them. Fix this and make the decoder init-threadsafe by making the initialization function guard initialization itself with a dedicated AVOnce. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mqc: Hardcode tables to save spaceAndreas Rheinhardt2021-05-12
| | | | | | | | | | | | | | | | | | mqc currently initializes three arrays at runtime; each of them has 2 * 47 elements, one is uint16_t, two are uint8_t, so that their combined size is 8 * 47. The source data for these initializations is contained in an array of 47 elements of size six. Said array is only used in order to initialize the other arrays, so the savings are just 2 * 47B. Yet this is dwarfed by the size of the code for performing the initializations: It is 109B (GCC 10.2, x64, -O3 albeit in an av_cold function); this does not even include the size of the code in the callers. So just hardcode these tables. This also fixes a data race, because the encoder always initialized these tables during init, although they might already be used at the same time by already running encoder/decoder instances. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Constify AVCodecsAndreas Rheinhardt2021-04-27
| | | | | | | | | | Given that the AVCodec.next pointer has now been removed, most of the AVCodecs are not modified at all any more and can therefore be made const (as this patch does); the only exceptions are the very few codecs for external libraries that have a init_static_data callback. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/jpeg2000dec: Check atom_size in jp2_find_codestream()Michael Niedermayer2021-02-10
| | | | | | | | Fixes: Infinite loop Fixes: 29722/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6412228041506816 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeg2000dec: Check remaining data in packed_headers_stream before useMichael Niedermayer2020-08-10
| | | | | | | | | | Fixes: out of array read Fixes: 24487/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5165847820369920 Fixes: 24636/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5700973918683136 Fixes: 24683/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6202883897556992 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeg2000dec: Handle reducedresno of 32Michael Niedermayer2020-08-06
| | | | | | | | | 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>
* libavcodec/jpeg2000dec: Support for PPM markerGautam Ramakrishnan2020-07-28
| | | | | | | | This patch adds support for PPM marker for JPEG2000 decoder. It allows the samples p1_03.j2k and p1_05.j2k to be decoded. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeg2000dec: Move reslevelno check before use in case JPEG2000_PGOD_RPCLMichael Niedermayer2020-07-28
| | | | | | | | | | Fixes: division by zero Fixes: 24201/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5665813827420160 Fixes: 24245/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6285831682392064 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>
* libavcodec/jpeg2000dec: Fix codeblock decode checkGautam Ramakrishnan2020-07-24
| | | | | | | | | | | The codeblock decoder checks whether the mqc decoder has decoded the right number of bytes. However, this check does not account for the fact that the mqc encoder's flush routine adds 2 bytes of data which does not have to be read by the decoder. The check is modified to account for this. This patch solves issue #4827 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/jpeg2000dec: Add check when done with main header markersGautam Ramakrishnan2020-07-23
| | | | | | | This patch sets a flag when the processing of the main header is complete. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/jpeg2000dec: Support for Parameterless MarkersGautam Ramakrishnan2020-07-19
| | | | | | | | | The JPEG2000 standard reserves marker values 0xFF30 to 0xFF3F to be used as parameterless markers. This patch adds support to decode codestream with such markers. This allows decoding of p0_02.j2k. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/jpeg2000 Fix RPCL Progression order checkGautam Ramakrishnan2020-07-16
| | | | | | | The RPCL progression order check was incomplete. This patch completes the check. Tested on p1_07.j2k. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/jpeg2000 Fix PCRL Progression Order checkGautam Ramakrishnan2020-07-16
| | | | | | | The PCRL progression checks were incomplete. This patch modifes completes the check. Tested on p1_05.j2k. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/jpeg2000dec : Prevent overriding SOP marker bitGautam Ramakrishnan2020-07-14
| | | | | | | | Currently, the COC marker overrides the SOP marker bit. However, only the COD marker may set this value. This patch fixes this bug. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/jpeg2000dec.c: Enable image offsetsGautam Ramakrishnan2020-07-06
| | | | | | This patch enables support for image offsets. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/jpeg2000dec: Enhance pix fmt selectionGautam Ramakrishnan2020-07-06
| | | | | | | This patch assigns default pix format values when a match does not take place. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/jpeg2000.c: Precinct size check removedGautam Ramakrishnan2020-06-30
| | | | | | | | | | 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>
* libavcodec/jpeg2000dec.c Fixed WRITE_FRAME and tile co-ordinates:Gautam Ramakrishnan2020-06-27
| | | | | | | | | | libopenjpeg2000 uses ceiling division while dividing tile co-ordinates with the sample separation. Also, corrections were made to the WRITE_FRAME macro. Improves: p1_01.j2k and p1_07.j2k Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/jpeg2000dec.c: Modify image dimensionsGautam Ramakrishnan2020-06-27
| | | | | | | | | | Reduce image size of the image if all components have a non zero sample separation. This is to replicate the output of opj_decompress. Improves: p1_01.j2k Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeg2000dec: Fix/check for multiple integer overflowsMichael Niedermayer2020-06-14
| | | | | | | | Fixes: shift exponent 35 is too large for 32-bit type 'int' Fixes: 22857/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5202709358837760 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeg2000dec: clear pointer which become stale in get_ppt()Michael Niedermayer2020-06-01
| | | | | | | | | Fixes: use after free Fixes: 22484/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5671488765296640 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>
* avcodec/jpeg2000dec: Free packed_headersMichael Niedermayer2020-05-17
| | | | | | | | | Fixes: memleak Fixes: 21784/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-565256551058636 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>
* libavcodec/jpeg2000dec.c: ROI marker supportGautam Ramakrishnan2020-04-23
| | | | | | | | | 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>
* libavcodec/jpeg2000dec.c: Support for CRG markerGautam Ramakrishnan2020-04-22
| | | | | | | | This patch adds support to skip the CRG marker. The CRG marker, is an informational marker. Allows samples such as p0_03.j2k to be decoded. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc/jpeg2000dec: Cosmetics, re-indent after last commit.Carl Eugen Hoyos2020-04-15
|
* lavc/jpeg2000dec: Allow to force a compatible pix_fmt.Carl Eugen Hoyos2020-04-15
| | | | | This copies the behaviour of the libopenjpeg decoder. Fixes ticket #5919.
* libavcodec/jpeg2000dec.c: fix error in cod markerGautam Ramakrishnan2020-04-11
| | | | | | | | | | This patch fixes an error where the COC marker overrides all data of the SPcod field of the COD marker. It must override only one bit of SPcod field. This now allows p0_08.j2k to be decoded correctly (mentioned in #4679). Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeg2000dec: Fix mixed declaration and codeAndreas Rheinhardt2020-04-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* libavcodec/jpeg2000dec.c: Add support for PPT markerGautam Ramakrishnan2020-04-09
| | | | | | | This patch adds functional changes to support the PPT marker. This patch fixes bug ticket #4610. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/jpeg2000dec.c: Fix indentationGautam Ramakrishnan2020-04-04
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/jpeg2000dec.c: Handle non EOC streamsGautam Ramakrishnan2020-04-04
| | | | | | | This patch allows decoding of j2k streams which do not have an EOC marker. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeg2000dec: error check when processing tlm markerGautam Ramakrishnan2020-03-27
| | | | | | | Validate the value of ST field in the TLM marker of JPEG2000. Throw an error when ST takes value of 0b11. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeg2000dec: Fix return type of get_plt()Michael Niedermayer2019-04-25
| | | | | Found-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeg2000dec: Check PLT data somewhatMichael Niedermayer2019-04-25
| | | | | | | | 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>
* avcodec/jpeg2000dec: Replace the step_x/y assert by a check in the CPRL case ↵Michael Niedermayer2019-04-25
| | | | | | | | | | 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>
* avcodec/jpeg2000dec: Skip de-quantization of empty areasMichael Niedermayer2019-03-25
| | | | | | | | 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>
* avcodec/jpeg2000dec: Skip DWT if nothing is codedMichael Niedermayer2018-12-08
| | | | | | | | | | 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>
* avcodec/jpeg2000dec: Fix off by 1 error in JPEG2000_PGOD_CPRL handlingMichael Niedermayer2018-10-23
| | | | | | | | 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>
* avcodec/jpeg2000dec: Fixes invalid shifts in ↵Michael Niedermayer2018-07-04
| | | | | | | | | | 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>
* avcodec/jpeg2000dec: Check that there are enough bytes for all tilesMichael Niedermayer2018-07-04
| | | | | | | | 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>
* lavc/jpeg2000dec: Move a variable declaration closer to its usage.Carl Eugen Hoyos2018-05-22
|
* lavc/jpeg2000dec: Use a define to clarify the meaning of a constant.Carl Eugen Hoyos2018-05-22
|
* avcodec/jpeg2000dec: Fix undefined shift in the ↵Michael Niedermayer2018-05-06
| | | | | | | | | | 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>
* avcodec/jpeg2000dec: Skip init for component in CPRL if nothing is to be doneMichael Niedermayer2018-05-06
| | | | | | | | 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>
* avcodec/jpeg2000dec: Reduce the number of tile parts allocatedMichael Niedermayer2018-05-06
| | | | | | | | | | | | | | 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>
* avcodec/jpeg2000dec: Use av_image_check_size2()Michael Niedermayer2018-02-17
| | | | | | | | 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>
* avcodec: do not use init_static_data on some codecsMuhammad Faiz2018-02-04
| | | | | | | | | | | | | | 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>
* lavc/jpeg2000dec: Support reading 64-bit atom size.Carl Eugen Hoyos2017-12-28
| | | | Fixes ticket #6935.
* avcodec/jpeg2000dec: Free lengthinc earlierMichael Niedermayer2017-12-21
| | | | | | Reduces memory needed Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeg2000dec: Allocate lengthinc and data_start arrays as neededMichael Niedermayer2017-12-21
| | | | | | | | | 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>