summaryrefslogtreecommitdiff
path: root/libavcodec/ffv1dec.c
Commit message (Collapse)AuthorAge
* avcodec/ffv1dec: Fix AC_GOLOMB_RICE min size checkMichael Niedermayer2022-07-21
| | | | | | Found-by: mkver Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1dec: consider run increase in minimal golomb frame sizeMichael Niedermayer2022-07-20
| | | | | | | | | Fixes: Timeout Fixes: 49160/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5672826144686080 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: Make init-threadsafety the defaultAndreas Rheinhardt2022-07-18
| | | | | | | | | | | 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/ffv1dec: Check for min packet sizeMichael Niedermayer2022-07-12
| | | | | | | | Fixes: Timeout Fixes: 48619/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5793597923917824 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1dec: Limit golomb rice coded slices to width 8MMichael Niedermayer2022-07-12
| | | | | | | This limit is possibly not reachable due to other restrictions on buffers but the decoder run table is too small beyond this, so explicitly check for it. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-05
| | | | | | | | | | | 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-05
| | | | | | | | 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/internal: Move FF_SIGNBIT and ff_log2_run to mathops.hAndreas Rheinhardt2022-03-21
| | | | | | | 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-21
| | | | | | | | | | | | | | | | 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-21
| | | | | | | | | | 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/thread: Don't use ThreadFrame when unnecessaryAndreas Rheinhardt2022-02-09
| | | | | | | | | | | | | | | | | | | | | | | 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/threadframe: Add ff_thread_(get|release)_ext_buffer()Andreas Rheinhardt2022-02-09
| | | | | | | | | These will be used by the codecs that need allocated progress and is in preparation for no longer using ThreadFrame by the codecs that don't. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/thread: Move ff_thread_(await|report)_progress to new headerAndreas Rheinhardt2022-02-09
| | | | | | | | | | This is in preparation for further commits that will stop using ThreadFrame for frame-threaded codecs that don't use ff_thread_(await|report)_progress(); the API for those codecs having inter-frame depdendencies will live in threadframe.h. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ffv1dec: Don't copy unused fieldAndreas Rheinhardt2021-12-19
| | | | | | The decoder always uses AVCodecContext.bits_per_raw_sample. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ffv1, ffv1dec: Add const where appropriateAndreas Rheinhardt2021-12-19
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ffv1dec: Remove redundant writes, fix racesAndreas Rheinhardt2021-12-19
| | | | | | | | | | | | | | Every modification of the data that is copied in update_thread_context() is a data race if it happens after ff_thread_finish_setup. ffv1dec's update_thread_context() simply uses memcpy for updating the new context, so that every modification of the src's context is a race. Some of these modifications are unnecessary: picture_number is write-only for the decoder and cur will be reset when decoding the next frame anyway. So remove them. And while just at it, also don't set cur for the slice contexts as this variable is write-only. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ffv1dec: Mark decoder as init-threadsafeAndreas Rheinhardt2021-05-02
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.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>
* avutil/pixdesc: Remove deprecated AV_PIX_FMT_FLAG_PSEUDOPALAndreas Rheinhardt2021-04-27
| | | | | | | Deprecated in d6fc031caf64eed921bbdef86d79d56bfc2633b0. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/ffv1dec: Check if trailer is availableMichael Niedermayer2021-03-13
| | | | | | | | Fixes: out of array read Fixes: 29750/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-4808377272238080.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1dec: Fix off by 1 error with quant tablesMichael Niedermayer2020-12-22
| | | | | | | | | Fixes: assertion failure Fixes: 28447/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5369575948550144 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* pthread_frame: merge the functionality for normal decoder init and ↵Anton Khirnov2020-04-10
| | | | | | | | | | | | | | | | init_thread_copy The current design, where - proper init is called for the first per-thread context - first thread's private data is copied into private data for all the other threads - a "fixup" function is called for all the other threads to e.g. allocate dynamically allocated data is very fragile and hard to follow, so it is abandoned. Instead, the same init function is used to init each per-thread context. Where necessary, AVCodecInternal.is_copy can be used to differentiate between the first thread and the other ones (e.g. for decoding the extradata just once).
* lavc: replace AVCodecInternal.allocate_progress with an internal capAnton Khirnov2020-04-10
| | | | This is a constant codec property, so a capability flag is more appropriate.
* libavcodec, libpostproc: Remove outcommented START/STOP_TIMERAndreas Rheinhardt2020-03-14
| | | | | | | as well as includes of libavutil/timer.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1dec: Use a different error message for the slice level CRCMichael Niedermayer2019-11-09
| | | | | | This way they can be told apart easily Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1dec: Check state transition tableMichael Niedermayer2018-06-25
| | | | | | | | Fixes: Timeout Fixes: 8646/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5649968353247232 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/pixdesc: deprecate AV_PIX_FMT_FLAG_PSEUDOPALwm42018-04-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PSEUDOPAL pixel formats are not paletted, but carried a palette with the intention of allowing code to treat unpaletted formats as paletted. The palette simply mapped the byte values to the resulting RGB values, making it some sort of LUT for RGB conversion. It was used for 1 byte formats only: RGB4_BYTE, BGR4_BYTE, RGB8, BGR8, GRAY8. The first 4 are awfully obscure, used only by some ancient bitmap formats. The last one, GRAY8, is more common, but its treatment is grossly incorrect. It considers full range GRAY8 only, so GRAY8 coming from typical Y video planes was not mapped to the correct RGB values. This cannot be fixed, because AVFrame.color_range can be freely changed at runtime, and there is nothing to ensure the pseudo palette is updated. Also, nothing actually used the PSEUDOPAL palette data, except xwdenc (trivially changed in the previous commit). All other code had to treat it as a special case, just to ignore or to propagate palette data. In conclusion, this was just a very strange old mechnaism that has no real justification to exist anymore (although it may have been nice and useful in the past). Now it's an artifact that makes the API harder to use: API users who allocate their own pixel data have to be aware that they need to allocate the palette, or FFmpeg will crash on them in _some_ situations. On top of this, there was no API to allocate the pseuo palette outside of av_frame_get_buffer(). This patch not only deprecates AV_PIX_FMT_FLAG_PSEUDOPAL, but also makes the pseudo palette optional. Nothing accesses it anymore, though if it's set, it's propagated. It's still allocated and initialized for compatibility with API users that rely on this feature. But new API users do not need to allocate it. This was an explicit goal of this patch. Most changes replace AV_PIX_FMT_FLAG_PSEUDOPAL with FF_PSEUDOPAL. I first tried #ifdefing all code, but it was a mess. The FF_PSEUDOPAL macro reduces the mess, and still allows defining FF_API_PSEUDOPAL to 0. Passes FATE with FF_API_PSEUDOPAL enabled and disabled. In addition, FATE passes with FF_API_PSEUDOPAL set to 1, but with allocation functions manually changed to not allocating a palette.
* avcodec/ffv1: support of more pix_fmtJérôme Martinez2018-03-10
| | | | | | | | Without direct support of such pix_fmt, content is padded to 16-bit and it is not possible to know that the source file was with a smaller bit depth so framemd5 is different Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1: Support for GBRAP10 and GBRAP12Jérôme Martinez2018-02-15
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1: Support for RGBA64 and GBRAP16Jérôme Martinez2018-02-06
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1dec: Fix out of array read in slice countingMichael Niedermayer2017-10-10
| | | | | | | Fixes: test-201710.mp4 Found-by: 连一汉 <lianyihan@360.cn> and Zhibin Hu Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1dec: Fix integer overflow in read_quant_table()Michael Niedermayer2017-09-22
| | | | | | | | Fixes: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' Fixes: 3361/clusterfuzz-testcase-minimized-5065842955911168 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1dec: Check for bitstream end in decode_line()Michael Niedermayer2017-08-18
| | | | | | | | Fixes: timeout Fixes: 2971/clusterfuzz-testcase-6130678276030464 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1dec: Fix runtime error: signed integer overflow: 1550964438 + ↵Michael Niedermayer2017-05-13
| | | | | | | | | | 1550964438 cannot be represented in type 'int' Fixes: 1559/clusterfuzz-testcase-minimized-5048096079740928 Fixes: 1560/clusterfuzz-testcase-minimized-6011037813833728 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1dec: Fix copying planes of paletted formatsMichael Niedermayer2017-05-08
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Fix all -Wformat warnings raised by DJGPPClément Bœsch2017-03-29
|
* Merge commit '17cb56b35672a2cd6ad7abe926e6cc772b8f4710'Clément Bœsch2017-03-19
|\ | | | | | | | | | | | | * commit '17cb56b35672a2cd6ad7abe926e6cc772b8f4710': ffv1: Remove broken disabled cruft Merged-by: Clément Bœsch <u@pkh.me>
| * ffv1: Remove broken disabled cruftDiego Biurrun2016-08-17
| |
| * ffv1: Report additional bitstream information in verbose modeLuca Barbato2016-06-29
| | | | | | | | Useful to inspect samples.
| * ffv1: Error out on unsupported formatJerome Martinez2016-06-18
| | | | | | | | Transparency is supported only by YUV and within specific bit depths.
| * lavu: add AV_CEIL_RSHIFT and use it in various placesClément Bœsch2016-01-11
| | | | | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* | lavc/ffv1: Support YUV4xxP12 and GRAY12.Carl Eugen Hoyos2016-11-20
| |
* | avcodec/ffv1dec: Set packed_at_lsb for 16bit YUVMichael Niedermayer2016-11-18
| | | | | | | | | | | | This avoids unneeded computations Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/ffv1dec: Support gray 10/12/16 explicitly avoid shiftsMichael Niedermayer2016-11-18
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | lavc/ffv1dec: Scale output for msb-packed compression to full 16bit.Carl Eugen Hoyos2016-11-17
| | | | | | | | 2% slowdown for existing decode-line timer.
* | avcodec/ffv1: add AV_PIX_FMT_GBRP16 supportMichael Niedermayer2016-08-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/ffv1: template functions to allow data types different from int16_tMichael Niedermayer2016-08-08
| | | | | | | | | | | | | | This is required for >= 16bit RGB support I tried it without templates but its too much duplicated code Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/ffv1dec: Test extradata_size instead of extradata for better robustnessMichael Niedermayer2016-07-21
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/ffv1dec: fix some unsupported pix_fmtJérôme Martinez2016-06-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When checking pix_fmt mapping, some bitstreams are mapped to an incorrect pix_fmt instead of being rejected (ENOSYS). Actually, such bitstreams are not supported (FFmpeg encoder does not produce such bitstream, such bitstream may come only from another encoder for the moment). - JPEG 2000 RCT 11/13/15/16 bit depths are mapped to a 8-bit FFmpeg pix_fmt (e.g. bgr0), which is not expected. - JPEG 2000 RCT 9/10/12/14 bit depths with alpha are mapped to a FFmpeg pix_fmt without alpha (e.g. AV_PIX_FMT_GBRP9 for 9-bit with alpha), which is not expected. The order for choosing the pix_fmt is changed to the one used by YCbCr selection (<=8 bit first). " && !f->transparency" is added to the other lines. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil: Rename FF_CEIL_COMPAT to AV_CEIL_COMPATDerek Buitenhuis2016-01-27
| | | | | | | | | | | | | | | | | | | | Libav, for some reason, merged this as a public API function. This will aid in future merges. A define is left for backwards compat, just in case some person used it, since it is in a public header. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>