summaryrefslogtreecommitdiff
path: root/libavcodec/jpeglsdec.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/mjpegdec: Only use receive_frame for SMVJPEGAndreas Rheinhardt2022-12-101-3/+2
| | | | | | | | | | | | | | | | | Only one codec using mjpegdec.c actually creates multiple frames from a single packet, namely SMVJPEG. The other can use the ordinary decode callback just fine. This e.g. has the advantage of confining the special SP5X/AMV code to sp5xdec.c. This reverts most of commit e9a2a8777317d91af658f774c68442ac4aa726ec; of course it is not a simple revert: Way too much has changed; furthermore, outright reverting the sp5xdec.c changes would readd a stack packet to sp5x_decode_frame() which is not desired. In order to avoid this without modifying the given AVPacket, a variant of ff_mjpeg_decode_frame() with explicit buf and size parameters has been added. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add macro to set AVCodec.long_nameAndreas Rheinhardt2022-09-031-1/+1
| | | | | | | | It reduces typing: Before this patch, there were 105 codecs whose long_name-definition exceeded the 80 char line length limit. Now there are only nine of them. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Make init-threadsafety the defaultAndreas Rheinhardt2022-07-181-1/+1
| | | | | | | | | | | and remove FF_CODEC_CAP_INIT_THREADSAFE All our native codecs are already init-threadsafe (only wrappers for external libraries and hwaccels are typically not marked as init-threadsafe yet), so it is only natural for this to also be the default state. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/jpeglsdec: fix end check for xfrmMichael Niedermayer2022-06-231-4/+4
| | | | | | | | Fixes: out of array access Fixes: 47871/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_fuzzer-5646305956855808 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-051-1/+1
| | | | | | | | | | | This is possible, because every given FFCodec has to implement exactly one of these. Doing so decreases sizeof(FFCodec) and therefore decreases the size of the binary. Notice that in case of position-independent code the decrease is in .data.rel.ro, so that this translates to decreased memory consumption. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move FF_SIGNBIT and ff_log2_run to mathops.hAndreas Rheinhardt2022-03-211-2/+0
| | | | | | | It is a more fitting place for them. Also move the definition of ff_log2_run to mathtables.c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt2022-03-211-6/+6
| | | | | | | | | | | | | | | | Up until now, codec.h contains both public and private parts of AVCodec. This exposes the internals of AVCodec to users and leads them into the temptation of actually using them and forces us to forward-declare structures and types that users can't use at all. This commit changes this by adding a new structure FFCodec to codec_internal.h that extends AVCodec, i.e. contains the public AVCodec as first member; the private fields of AVCodec are moved to this structure, leaving codec.h clean. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.hAndreas Rheinhardt2022-03-211-0/+1
| | | | | | | | | | Also move FF_CODEC_TAGS_END as well as struct AVCodecDefault. This reduces the amount of files that have to include internal.h (which comes with quite a lot of indirect inclusions), as e.g. most encoders don't need it. It is furthemore in preparation for moving the private part of AVCodec out of the public codec.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/jpeglsdec: Fix if( code styleMichael Niedermayer2022-02-151-3/+3
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeglsdec: Check get_ur_golomb_jpegls() for errorMichael Niedermayer2022-02-151-0/+2
| | | | | | | | | | | | | | Fixes: Timeout Fixes: Invalid shift Fixes: 44548/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-556487680891289 Fixes: 44569/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_fuzzer-6302543246917632 Fixes: 44570/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-4550196556595200 Fixes: 44592/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-5651610385121280 Fixes: 44571/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5094698987945984 Fixes: 44607/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5341352013987840 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeglsdec: Increase range for N in ls_get_code_runterm() by using ↵Michael Niedermayer2022-02-091-1/+1
| | | | | | | | | | | | unsigned Fixes: left shift of 32768 by 16 places cannot be represented in type 'int' Fixes: Timeout Fixes: 44219/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-4679455379947520 Fixes: 44088/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-4885976600674304 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeglsdec: Avoid get_bits_long() where possibleAndreas Rheinhardt2022-01-081-1/+1
| | | | | | | | It is possible here, because the values of ff_log2_run used here are actually in the range 0..15 given that run_index is in the range 0..31. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/jpeglsdec: force pal8 only onceMichael Niedermayer2021-06-021-2/+5
| | | | | | | | | | | Fixes: Infinite loop Fixes: 33958/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-6590264069193728 Fixes: 33981/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-5343224173559808 Fixes: 33986/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-6598815122587648 Fixes: 34001/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-6171098111672320 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeglsdec: Set alpha plane in PAL8 so image is not 100% transparentMichael Niedermayer2021-05-031-1/+1
| | | | | | Fixes: tickets/3933/128.jls Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/mjpegdec: Decode to PAL8 independant of the location of LSEMichael Niedermayer2021-05-031-2/+4
| | | | | | | | This simply performs a 2nd pass if a LSE is encountered with GRAY8 Fixes: tickets/3933/128.jls Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Revert "avcodec/mjpegdec: postpone calling ff_get_buffer() until the SOS marker"Michael Niedermayer2021-05-031-2/+4
| | | | | | This also temporary disables fate-jpegls which is re-enabled in the next commit This reverts commit c8197f73e684b0edc450f3dc2b2b4b3fb9dedd0d.
* avcodec: Constify AVCodecsAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | | | | 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/mjpegdec: postpone calling ff_get_buffer() until the SOS markerJames Almer2021-04-251-4/+2
| | | | | | | | | | | | | | | With JPEG-LS PAL8 samples, the JPEG-LS extension parameters signaled with the LSE marker show up after SOF but before SOS. For those, the pixel format chosen by get_format() in SOF is GRAY8, and then replaced by PAL8 in LSE. This has not been an issue given both pixel formats allocate the second data plane for the palette, but after the upcoming soname bump, GRAY8 will no longer do that. This will result in segfauls when ff_jpegls_decode_lse() attempts to write the palette on a buffer originally allocated as a GRAY8 one. Work around this by calling ff_get_buffer() after the actual pixel format is known. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/jpeglsdec: Don't presume the context to contain a JLSStateAndreas Rheinhardt2021-04-201-7/+8
| | | | | | | | | | | | | | | Before 9b3c46a081a9f01559082bf7a154fc6be1e06c18 every call to ff_jpegls_decode_picture() allocated and freed a JLSState. This commit instead put said structure into the context of the JPEG-LS decoder to avoid said allocation. But said function can also be called from other MJPEG-based decoders and their contexts doesn't contain said structure, leading to segfaults. This commit fixes this: The JLSState is now allocated on the first call to ff_jpegls_decode_picture() and stored in the context. Found-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/jpeglsdec: Don't allocate+free JPEGLSState for every frameAndreas Rheinhardt2021-04-181-8/+8
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/jpeglsdec: Fix k=16 in ls_get_code_regular()Michael Niedermayer2021-02-101-1/+1
| | | | | | | | | | Fixes: Timeout Fixes: left shift of 33046 by 16 places cannot be represented in type 'int' Fixes: 29258/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-4889231489105920 Fixes: 29515/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-6161940391002112 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* mjpegdec: convert to receive_frame()Anton Khirnov2020-12-101-2/+3
| | | | This will be useful in the following commit.
* avcodec/mjpegdec: Fix memleak upon init failureAndreas Rheinhardt2020-12-041-1/+1
| | | | | | | | | This affected all decoders that used ff_mjpeg_decode_init() as init function; and it also affected decoders that open jpeg decoders via ff_codec_open2_recursive() as well as MxPEG. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/jpeglsdec: Apply transform only to initialized linesMichael Niedermayer2019-10-081-2/+5
| | | | | | | | Fixes: Timeout (110sec -> 1sec) Fixes: 17123/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_fuzzer-5636452758585344 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeglsdec: Return error codes from ls_decode_line()Michael Niedermayer2019-10-081-8/+18
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeglsdec: Check for end of bitstream in ls_decode_line()Michael Niedermayer2017-10-291-0/+3
| | | | | | | | | Fixes: 1773/clusterfuzz-testcase-minimized-4832523987189760 Fixes: Timeout Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeglsdec: Check ilv for being a supported valueMichael Niedermayer2017-10-291-0/+4
| | | | | | | Fixes: 1773/clusterfuzz-testcase-minimized-4832523987189760 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeglsdec: Check get_bits_left() before decoding a pictureMichael Niedermayer2017-05-241-0/+4
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/jpeglsdec: check shift for values that cause overflow laterMichael Niedermayer2017-02-241-0/+5
| | | | | | Fixes: 657/clusterfuzz-testcase-6674741433729024 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit 'def97856de6021965db86c25a732d78689bd6bb0'Michael Niedermayer2015-07-271-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'def97856de6021965db86c25a732d78689bd6bb0': lavc: AV-prefix all codec capabilities Conflicts: cmdutils.c ffmpeg.c ffplay.c libavcodec/8svx.c libavcodec/aacenc.c libavcodec/ac3dec.c libavcodec/adpcm.c libavcodec/alac.c libavcodec/atrac3plusdec.c libavcodec/bink.c libavcodec/dnxhddec.c libavcodec/dvdec.c libavcodec/dvenc.c libavcodec/ffv1dec.c libavcodec/ffv1enc.c libavcodec/fic.c libavcodec/flacdec.c libavcodec/flacenc.c libavcodec/flvdec.c libavcodec/fraps.c libavcodec/frwu.c libavcodec/gifdec.c libavcodec/h261dec.c libavcodec/hevc.c libavcodec/iff.c libavcodec/imc.c libavcodec/libopenjpegdec.c libavcodec/libvo-aacenc.c libavcodec/libvorbisenc.c libavcodec/libvpxdec.c libavcodec/libvpxenc.c libavcodec/libx264.c libavcodec/mjpegbdec.c libavcodec/mjpegdec.c libavcodec/mpegaudiodec_float.c libavcodec/msmpeg4dec.c libavcodec/mxpegdec.c libavcodec/nvenc_h264.c libavcodec/nvenc_hevc.c libavcodec/pngdec.c libavcodec/qpeg.c libavcodec/ra288.c libavcodec/rv10.c libavcodec/s302m.c libavcodec/sp5xdec.c libavcodec/takdec.c libavcodec/tiff.c libavcodec/tta.c libavcodec/utils.c libavcodec/v210dec.c libavcodec/vp6.c libavcodec/vp9.c libavcodec/wavpack.c libavcodec/yop.c Merged-by: Michael Niedermayer <michael@niedermayer.cc>
| * lavc: AV-prefix all codec capabilitiesVittorio Giovara2015-07-271-1/+1
| | | | | | | | | | | | Express bitfields more simply. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* | Merge commit '7ca603f96f93d988e01d161d611f69a4ecaa3f02'Michael Niedermayer2015-06-011-0/+6
|\ \ | |/ | | | | | | | | | | * commit '7ca603f96f93d988e01d161d611f69a4ecaa3f02': jpegls: Check memory allocation Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * jpegls: Check memory allocationVittorio Giovara2015-05-311-0/+6
| |
* | avcodec/jpeglsdec: assert that overflows end at exactly x=wMichael Niedermayer2015-05-131-0/+1
| | | | | | | | | | | | If that ever was untrue, there would be a bug in the code Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '6a85dfc830f51f1f5c2d36d4182d265c1ea3ba25'Michael Niedermayer2015-04-201-1/+1
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '6a85dfc830f51f1f5c2d36d4182d265c1ea3ba25': lavc: Replace av_dlog and tprintf with internal macros Conflicts: libavcodec/aacdec.c libavcodec/audio_frame_queue.c libavcodec/bitstream.c libavcodec/dcadec.c libavcodec/dnxhddec.c libavcodec/dvbsubdec.c libavcodec/dvdec.c libavcodec/dvdsubdec.c libavcodec/get_bits.h libavcodec/gifdec.c libavcodec/h264.h libavcodec/h264_cabac.c libavcodec/h264_cavlc.c libavcodec/h264_loopfilter.c libavcodec/h264_refs.c libavcodec/imc.c libavcodec/interplayvideo.c libavcodec/jpeglsdec.c libavcodec/libopencore-amr.c libavcodec/mjpegdec.c libavcodec/mpeg12dec.c libavcodec/mpegvideo_enc.c libavcodec/mpegvideo_parser.c libavcodec/pngdec.c libavcodec/ratecontrol.c libavcodec/rv10.c libavcodec/svq1dec.c libavcodec/vqavideo.c libavcodec/wmadec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * lavc: Replace av_dlog and tprintf with internal macrosVittorio Giovara2015-04-191-3/+3
| |
* | avcodec/jpeglsdec: support PAL1-PAL7Michael Niedermayer2015-03-221-2/+10
| | | | | | | | | | | | Fixes Ticket3933 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '5a0e953c2465be9d449d5f523c3d3e2b886910b2'Michael Niedermayer2015-03-131-0/+2
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | * commit '5a0e953c2465be9d449d5f523c3d3e2b886910b2': mjpeg: Mark decoder family as thread safe Conflicts: libavcodec/mjpegbdec.c libavcodec/mjpegdec.c libavcodec/mxpegdec.c libavcodec/sp5xdec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * mjpeg: Mark decoder family as thread safeVittorio Giovara2015-03-131-0/+2
| | | | | | | | | | | | No global variables are used and the VLC tables are allocated without static elements. This will allow using a JPEG decoding context within other decoders.
* | avcodec/jpeglsdec: Check run value more completely in ls_decode_line()Michael Niedermayer2014-10-031-0/+5
| | | | | | | | | | | | | | | | | | | | | | previously it could have been by 1 too large Fixes out of array access Fixes: asan_heap-oob_12240f5_1_asan_heap-oob_12240f5_448_t8c1e3.jls Fixes: asan_heap-oob_12240f5_1_asan_heap-oob_12240f5_448_t8nde0.jls Fixes: asan_heap-oob_12240fa_1_asan_heap-oob_12240fa_448_t16e3.jls Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/jpeglsdec: add cast to silence pointer type warningMichael Niedermayer2014-05-031-1/+1
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/jpegls: print coding parameters stored in LSEMichael Niedermayer2014-04-111-0/+5
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/jpeglsdec/ff_jpegls_decode_lse: check len field validityMichael Niedermayer2014-04-091-1/+4
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/jpeglsdec: ask for sample for "oversized image"Michael Niedermayer2014-04-091-1/+1
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/jpeglsdec: fix palette parsing codeMichael Niedermayer2014-04-031-3/+5
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/jpeglsdec: add PAL8 supportMichael Niedermayer2014-04-011-3/+45
| | | | | | | | | | | | Fixes Ticket3478 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Add support for picture_ptr field in MJpegDecodeContextanatoly2013-12-091-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Anton Khirnov <anton@khirnov.net> (cherry picked from commit e0e3b8b297bae5144f23fd4b46a1309857040b63) Conflicts: libavcodec/jpeglsdec.c libavcodec/mjpegbdec.c libavcodec/mjpegdec.c Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/jpeglsdec: check err value for ls_get_code_runterm()Michael Niedermayer2013-10-301-0/+2
| | | | | | | | | | | | | | Fixes infinite loop Fixes Ticket3086 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/jpeglsdec: Implement the 4th (lossy) transformMichael Niedermayer2013-07-121-0/+10
| | | | | | | | | | | | | | | | Fixes remainder of Ticket893 Std deviation from the intended image is 0.11, max sample error +-1 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/jpeglsdec: support xfrm 1-3Michael Niedermayer2013-07-111-0/+37
| | | | | | | | | | | | Fixes 75% of Ticket893 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>