summaryrefslogtreecommitdiff
path: root/libavcodec
Commit message (Collapse)AuthorAge
* avcodec/pngdec: Fix memleak by postponing allocationAndreas Rheinhardt2021-03-19
| | | | | | Fixes Coverity ticket #1322342. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/tests/avpacket: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/webp: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/tiff: use av_packet_alloc() to allocate AVPacketsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/tdsc: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/pthread_frame: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/mpegvideo_enc: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libxvid: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/encode: silence a deprecation warning about av_init_packet()James Almer2021-03-17
| | | | | | No need to adapt this code as it will be removed long before av_init_packet() Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cri: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/packet_internal: make avpriv_packet_list_* functions use an internal ↵James Almer2021-03-17
| | | | | | | | | struct The next pointer is kept at the end for backwards compatability until the major bump, when it should ideally be moved at the front. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/packet: deprecate av_init_packet()James Almer2021-03-17
| | | | | | Once removed, sizeof(AVPacket) will stop being a part of the public ABI. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/vaapi_encode: use AVCodecContext.get_encode_buffer()James Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/nvenc: use AVCodecContext.get_encode_buffer()James Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/mfenc: use AVCodecContext.get_encode_buffer()James Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/librav1e: use AVCodecContext.get_encode_buffer()James Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/amfenc: use AVCodecContext.get_encode_buffer()James Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libdavs2: unbreak compilation failureGyan Doshi2021-03-17
| | | | | | FF_CODEC_CAP_AUTO_THREADS added in 8a129077cc requires internal.h Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
* lavc: drop unused argument from lock_avcodec()Anton Khirnov2021-03-16
|
* lavc: drop ff_ prefix from ff_(un)lock_avcodecAnton Khirnov2021-03-16
| | | | It is unnecessary and misleading, as those are static functions.
* lavc: move decoder bsf init into decoder-specific codeAnton Khirnov2021-03-16
|
* lavc: factor decoder validation/setup from avcodec_open2()Anton Khirnov2021-03-16
|
* lavc/encode: reindent after previous commitAnton Khirnov2021-03-16
|
* lavc: factor out encoder init/validation from avcodec_open2()Anton Khirnov2021-03-16
| | | | | | avcodec_open2() is massive, splitting it makes it more readable. Also, add a missing error code to ticks_per_frame sanity check.
* lavc: rename AV_CODEC_CAP_AUTO_THREADS->AV_CODEC_CAP_OTHER_THREADSAnton Khirnov2021-03-16
| | | | | | | | | | This cap is currently used to mark multithreading-capable codecs that wrap external libraries with their own multithreading code. The name is highly confusing for our API users, since libavcodec ALWAYS handles thread_count=0 (see commit message in previous commit). Therefore rename the cap and update its documentation to make its meaning clear. The old name is kept deprecated until next+1 major bump.
* lavc: replace internal use of AV_CODEC_CAP_AUTO_THREADS with an internal capAnton Khirnov2021-03-16
| | | | | | | | | | | | | | | | AV_CODEC_CAP_AUTO_THREADS was originally added in b4d44a45f9a to mark codecs that spawn threads internally and are able to select an optimal threads count by themselves (all such codecs are wrappers around external libraries). It is used by lavc generic code to check whether it should handle thread_count=0 itself or pass the zero directly to the codec implementation. Within this meaning, it is clearly supposed to be an internal cap rather than a public one, since from the viewpoint of a libavcodec user, lavc ALWAYS handles thread_count=0. Whether it happens in the generic code or within the codec internals is not a meaningful difference for the caller. External aspects of this flag will be dealt with in the following commit.
* avcodec/utils: Use more bits for intermediate for AV_CODEC_ID_ADPCM_MSMichael Niedermayer2021-03-15
| | | | | | | | Fixes: signed integer overflow: 1172577312 * 2 cannot be represented in type 'int' Fixes: 29924/clusterfuzz-testcase-minimized-ffmpeg_dem_BOA_fuzzer-4882912874594304 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/decode: Remove outdated commentAndreas Rheinhardt2021-03-15
| | | | | | | Removing it was forgotten in 417d473bde220a1f267bc694835c129a5adc4309. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/h264_cavlc: Reindent after the previous commitAndreas Rheinhardt2021-03-15
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/h264_cavlc: Remove redundant checkAndreas Rheinhardt2021-03-15
| | | | | | | | | | The only caller to ff_h264_decode_init_vlc() already uses ff_thread_once() for the call; ergo the check via a simple int with static storage duration in ff_h264_decode_init_vlc() is redundant. And if it were not redundant, it would be a potential for data races. So remove it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/jpegls: Check A[Q] for overflow in ff_jpegls_update_state_regular()Michael Niedermayer2021-03-14
| | | | | | | | Fixes: Timeout Fixes: 30912/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-5556235476795392 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/cfhd: Fix negative shift in cfhd_decode()Michael Niedermayer2021-03-14
| | | | | | | | Fixes: left shift of negative value -1 Fixes: 30714/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4867823371419648 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: add a mention about get_encode_buffer in the old encode API doxyJames Almer2021-03-14
| | | | | | | | Direct users to the callback that should be used to keep supporting user provided buffers with the new encode API. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/flacdec: Avoid undefined shift in error caseMichael Niedermayer2021-03-13
| | | | | | | | Fixes: flac_1040988 Reported-by: Thomas Guilbert <tguilbert@google.com> Reviewed-by: Thomas Guilbert <tguilbert@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/h264_metadata_bsf: Check nb_units before accessing the first in ↵Michael Niedermayer2021-03-13
| | | | | | | | | | h264_metadata_update_fragment() Fixes: null pointer dereference Fixes: 29835/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-4712125383704576 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 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/exr: Check col/line for integer overflowMichael Niedermayer2021-03-13
| | | | | | | | Fixes: signed integer overflow: -2272 + -2147483360 cannot be represented in type 'int' Fixes: 30009/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5005660322398208 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: add a get_encode_buffer() callback to AVCodecContextJames Almer2021-03-12
| | | | | | | | | | | This callback is functionally the same as get_buffer2() is for decoders, and implements for the new encode API the functionality of the old encode API had where the user could provide their own buffers. Reviewed-by: Lynne <dev@lynne.ee> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: James Almer <jamrial@gmail.com>
* cbs_sei: Detect payload overflows when reading SEI messagesMark Thompson2021-03-12
| | | | | | | | | | The top-level GetBitContext is sized for the whole NAL unit, so it fails to detect overflows where a payload continues into the following message. To fix that, we make a new context on the stack for reading each payload. Fixes: 29892/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_REDUNDANT_PPS_fuzzer-6310830956216320 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Tested-by: Michael Niedermayer <michael@niedermayer.cc>
* cbs_h265: Detect more reference combinations which would overflow the DPBMark Thompson2021-03-12
| | | | | | | | | | | | | | | | | | | | | In total, the number of short term references (from the selected short term ref pic set), the number of long term references (combining both the used candidates from the SPS and those defined in the slice header) and the number of instances of the current picture (usually one, but can be two if current picture reference is enabled) must never exceed the size of the DPB. This is a generalisation of the condition associated with num_long_term_pics in 7.4.7.1. We use this to apply tighter bounds to the number of long term pictures referred to in the slice header, and also to detect the invalid case where the second reference to the current picture would not fit in the DPB (this case can't be detected earlier because an STRPS with 15 pictures can still be valid in the same stream when used with a different PPS which does not require two DPB slots for the current picture). Fixes: 24913/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-6261760693370880 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Tested-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/cbs_h26[45]: Remove redundant enum constantsAndreas Rheinhardt2021-03-12
| | | | | | | Unused since 8843607f495c95c1e67a3ce3d6f15dca6e252439. Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/cbs_sei: Fix leak of AVBufferRef on errorAndreas Rheinhardt2021-03-12
| | | | | | | | | | | | | | | An AVBufferRef (and the corresponding AVBuffer and the underlying actual buffer) would leak in ff_cbs_sei_add_message() on error in case an error happened after its creation and before it has been attached to more permanent storage. Fix this by only creating the AVBufferRef immediately before attaching it to its intended target position. (Given that no SEI message currently created is refcounted, the above can't happen at the moment. But Coverity already nevertheless noticed: This commit fixes Coverity issue #1473521.) Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/cbs_sei: Don't use -1th element of arrayAndreas Rheinhardt2021-03-12
| | | | | | | | (This affected only suffix SEI messages; yet no such SEI messages are currently inserted.) Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/cbs: Remove redundant checks for CodedBitstreamContext.codecAndreas Rheinhardt2021-03-12
| | | | | | | | | | | | | Setting this field happens immediately after the allocation in ff_cbs_init(), so the whole CBS code may presume that any CodedBitstreamContext has this set. Lots of code already presumed this, yet ff_cbs_close() did it inconsistently: It checked before checking whether the CodedBitstreamType has a close function; yet it simply unconditionally read ctx->codec->priv_class. Coverity complained about this in issue #1473564, which this commit fixes. Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/nvenc: base timestamps on frameIntervalPMartin Storsjö2021-03-12
| | | | | | | | | | | | | If b-frames were enabled implicitly (if max_b_frames wasn't set by the caller at all, since a0949d0bcb0eee2f3fffcf9a4810c0295d14c0dc), we wouldn't offset dts at all, producing invalid pts/dts combinations (causing loud warnings by ffmpeg, or muxer errors if passed without an extra cleanup pass). Instead use frameIntervalP for offsetting, which should always be accurate. Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
* avcodec/decode: ReindentationAndreas Rheinhardt2021-03-12
| | | | | Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: Remove always-true checkAndreas Rheinhardt2021-03-12
| | | | | | | Forgotten in 1fd76277708cf83572ba243e98f9e848c652f83d. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/gifenc: Actually use the shrunk paletteDerek Buitenhuis2021-03-11
| | | | | | I have no idea how nobody, including myself, noticed this. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avcodec/h264_slice: don't copy frame data during error concealmentJames Almer2021-03-11
| | | | | | | | | In addition to the fact that av_image_copy() cannot handle hardware pixel formats, h->short_ref[0]->f may not be writable at this point. Based on a patch by Hendrik Leppkes. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/4xm: Check pre_gb in decode_i_block()Michael Niedermayer2021-03-11
| | | | | | | | Fixes: Timeout Fixes: 31257/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FOURXM_fuzzer-5150866229297152 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>