aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/tiff.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/cri,tdsc,tiff: Use ff_mjpeg_decoder directlyAndreas Rheinhardt2025-04-251-6/+4
| | | | | | | | | | | | This is simpler than calling avcodec_find_decoder(). Notice that av_codec_init_static() has already been called by the time we reach these decoders' init functions, so it is not necessary to call avcodec_find_decoder() for it (which doesn't do anything for the mjpeg decoder anyway). Reviewed-by: Kacper Michajlow <kasper93@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: Check value on positive signed targetsMichael Niedermayer2024-07-151-2/+18
| | | | | | | Fixes: CID1604593 Overflowed constant Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/tiff: Suppress unused variable warningsAndreas Rheinhardt2024-06-031-2/+2
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: Assert init_get_bits8() success in unpack_gray()Michael Niedermayer2024-05-281-1/+2
| | | | | | | Helps: CID1441939 Unchecked return value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/tiff: Assert init_get_bits8() success in horizontal_fill()Michael Niedermayer2024-05-281-1/+2
| | | | | | | Helps: CID1441167 Unchecked return value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/tiff: Fix leak on errorAndreas Rheinhardt2024-05-201-1/+3
| | | | | | Fixes Coverity issue #1516957. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Remove redundant setting of AV_FRAME_FLAG_KEY, AV_PICTURE_TYPE_IAndreas Rheinhardt2024-05-191-1/+0
| | | | | | This is done generically now. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: Don't cast const away via bsearchAndreas Rheinhardt2024-04-031-1/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-311-0/+1
| | | | | | | | | | | There are lots of files that don't need it: The number of object files that actually need it went down from 2011 to 884 here. Keep it for external users in order to not cause breakages. Also improve the other headers a bit while just at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff_data: Avoid relocations for TiffGeoTagNameTypeAndreas Rheinhardt2024-03-141-12/+16
| | | | | | | | | | | | | | | Instead store all the strings in one continugous string (with internal \0) and use offsets to access the actual substrings. This replaces the pointers to the strings and therefore avoids relocations (and on x64, it actually shrinks TiffGeoTagNameType by reusing padding to store the offset field). This saves 720B of .data.rel.ro and 1080B of .rela.dyn (containing the relocation records) here while increasing .rodata by 384B. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: Use ff_tget_long() where appropriateAndreas Rheinhardt2024-03-121-18/+18
| | | | | | | No need to use the generic ff_tget() when we know the type. Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: Improve inclusionsAndreas Rheinhardt2024-03-121-0/+1
| | | | | Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: Don't check before av_freep()Andreas Rheinhardt2024-03-121-5/+2
| | | | | Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: Avoid duplicating stringsAndreas Rheinhardt2024-03-121-1/+2
| | | | | Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: Fix handling of av_strdup() failuresAndreas Rheinhardt2024-03-121-20/+18
| | | | | | | | | | | | | | | | | For unknown geokey values, get_geokey_val() returns "Unknown-%d" with val being used for %d. This string is allocated and therefore all the known geokey values (static strings) are strdup'ed. In case this fails it is either ignored or treated as "Unknown-%d". (Furthermore it is possible to call av_strdup(NULL), although this is not documented to be legal.) This commit changes this by only returning the static strings in get_geokey_val(); the unknown handling and strdup'ing is moved out of it. Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: respect side data preferenceNiklas Haas2024-03-081-5/+5
|
* avcodec/cri, tdsc, tiff: Don't forward AVCodecContext.dct_algoAndreas Rheinhardt2024-02-141-1/+0
| | | | | | It is unused for decoders. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: pass arguments to bytestream2_seek in the right orderLeo Izen2024-02-111-1/+1
| | | | | | | | The function signature for bytestream2_seek is (gb, offset, whence); Before this patch, the code passed (gb, SEEK_SET, offset), which is incorrect. Siged-off-by: Leo Izen <leo.izen@gmail.com>
* Revert "all: Don't set AVClass.item_name to its default value"Anton Khirnov2024-01-201-0/+1
| | | | | | | Some callers assume that item_name is always set, so this may be considered an API break. This reverts commit 0c6203c97a99f69dbaa6e4011d48c331e1111f5e.
* all: Don't set AVClass.item_name to its default valueAndreas Rheinhardt2023-12-221-1/+0
| | | | | | | | Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9; also avoids relocations. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: Don't cast const awayAndreas Rheinhardt2023-09-071-3/+3
| | | | | | | | lzma_stream.next_in is const for more than 15 years now and has been so in every release of liblzma. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: add a zero DNG_LINEARIZATION_TABLE checkMichael Niedermayer2023-05-061-1/+1
| | | | | | | | | Fixes: index 4294967295 out of bounds for type 'uint16_t [65536]' Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5950405086674944 Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6666195176914944 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: use the new AVFrame key_frame flag in all decoders and encodersJames Almer2023-05-041-1/+2
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/tiff: Prettify code in dng_blit()Michael Niedermayer2023-01-111-1/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/tiff: Check camera_calibration for 0Michael Niedermayer2023-01-111-2/+4
| | | | | | | | Fixes: division by 0 Fixes: 53926/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5680347889401856 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/tiff: Ignore tile_countMichael Niedermayer2022-11-281-4/+2
| | | | | | | | Fixes: out of array access Fixes: 52427/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4849108968144896 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/tiff: Avoid 0.0/0.0 in camera_xyz_coeff()Michael Niedermayer2022-11-281-0/+2
| | | | | | | | Fixes: division by zero Fixes: 52230/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5922608915021824 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/tiff: add read support for compressed rgb floating point formatsMark Reid2022-11-161-0/+68
| | | | | | | floating point uses a slightly different predictor technique describe here http://chriscox.org/TIFFTN3d1.pdf Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avcodec/tiff: Remove commented-out codeAndreas Rheinhardt2022-09-301-6/+1
| | | | | | | Also remove a variable that is only used in this commented-out codeblock. This fixes a -Wunused-variable warning. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: support multiple black levelsPaul B Mahol2022-09-251-23/+40
|
* avcodec/tiff: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAMPaul B Mahol2022-09-251-3/+8
|
* avcodec/tiff: improve color handling in DNGPaul B Mahol2022-09-251-12/+192
|
* avcodec/tiff: add packed/planar 32bit float supportPaul B Mahol2022-09-251-12/+24
|
* avcodec/tiff: improve lut handling for DNGPaul B Mahol2022-09-231-4/+4
|
* avcodec/tiff: Fix loop detectionMichael Niedermayer2022-09-161-2/+2
| | | | | | | Fixes regression with tickets/4364/L1004220.DNG Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* 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>
* lavc/tiff: Support multi-component files without RowsPerStrip tag.Carl Eugen Hoyos2022-09-011-1/+1
| | | | Fixes ticket #9514.
* avcodec/internal: Move ff_set_dimensions() to decode.hAndreas Rheinhardt2022-08-271-4/+1
| | | | | | | | | Decoder-only, as the dimensions are set by the user when encoding. Also fixup the other headers a bit while removing unnecessary internal.h inclusions. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: add cap for ICC profile supportNiklas Haas2022-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | Codecs that can read/write ICC profiles deserve a special capability so the common logic in encode.c/decode.c can decide whether or not there needs to be any special handling for ICC profiles. The motivation here is to be able to use it to decide whether or not an ICC profile needs to be generated in the encode path, but it might as well get added to decoders as well for purely informative reasons. It's not entirely clear to me whether the "thp" and "smvjpeg" variants of "mjpeg" should have this capability set or not, given that the code technically supports it but I somehow doubt these files may contain them. In either case, this cap is purely informative for decoders so it doesn't matter too much either way. It's also not entirely clear whether the "amv" encoder should signal ICC profile support, but again erring on the side of caution, we probably *shouldn't* be generating (and encoding!) ICC profiles for this type of media file. Signed-off-by: Niklas Haas <git@haasn.dev>
* avcodec/tiff: Check tile_length and tile_widthMichael Niedermayer2022-07-221-0/+3
| | | | | | | | Fixes: Division by 0 Fixes: 49235/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5495613847896064 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* 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/tiff: Check pixel format types for dngMichael Niedermayer2022-07-121-0/+3
| | | | | | | | Fixes: out of array access Fixes: 48271/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6149705769287680 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/codec_internal: Make FFCodec.decode use AVFrame*Andreas Rheinhardt2022-04-051-4/+3
| | | | | | | | This increases type-safety by avoiding conversions from/through void*. It also avoids the boilerplate "AVFrame *frame = data;" line for non-subtitle decoders. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mathops: Move bitswap_32() to its only userAndreas Rheinhardt2022-03-211-0/+1
| | | | | | | | Effectively reverts eaff1aa09e90e2711207c9463db8bf8e8dec8178 given that bitswap_32 is no longer used outside of bitstream.c since 03008c2811ec26cf338780a89b6b2b849b399e3c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt2022-03-211-7/+7
| | | | | | | | | | | | | | | | 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/tiff: do not abort on zero denominatorPaul B Mahol2022-03-031-4/+4
| | | | Fixes decoding valid DNG file.
* avcodec/thread: Don't use ThreadFrame when unnecessaryAndreas Rheinhardt2022-02-091-5/+4
| | | | | | | | | | | | | | | | | | | | | | | The majority of frame-threaded decoders (mainly the intra-only) need exactly one part of ThreadFrame: The AVFrame. They don't need the owners nor the progress, yet they had to use it because ff_thread_(get|release)_buffer() requires it. This commit changes this and makes these functions work with ordinary AVFrames; the decoders that need the extra fields for progress use ff_thread_(get|release)_ext_buffer() which work exactly as ff_thread_(get|release)_buffer() used to do. This also avoids some unnecessary allocations of progress AVBuffers, namely for H.264 and HEVC film grain frames: These frames are not used for synchronization and therefore don't need a ThreadFrame. Also move the ThreadFrame structure as well as ff_thread_ref_frame() to threadframe.h, the header for frame-threaded decoders with inter-frame dependencies. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: Remove messing with jpeg contextMichael Niedermayer2021-12-301-22/+2
| | | | | | | | | | | | | | | | The whole concept is just not correct, also as it seems not to be needed at all, all dng files i have decode without this. Fixes: various crashes Fixes: 42937/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4625073334517760 Fixes: 42938/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4643368217477120 Fixes: 42939/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4925325908246528 Fixes: 42940/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4925378806808576 Fixes: 42941/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6202009265504256 Fixes: 42944/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6076860998483968 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>