summaryrefslogtreecommitdiff
path: root/libavcodec
Commit message (Collapse)AuthorAge
* 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>
* avcodec/libilbc: Support newer libiLBC versionsAndreas Rheinhardt2021-03-11
| | | | | | | | | | | | | Beginning with version 3.0, libiLBC switched the types of some parts of their public API to size_t and renamed some types; the old names continue to work as typedefs, but are deprecated. It furthermore added version macros. This commit uses said version macro to use the new types when using newer libiLBC versions. Reviewed-by: Timothy Gu <timothygu99@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec: use the buffer_size_t typedef where requiredJames Almer2021-03-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/packet: change side data related public function and struct size ↵James Almer2021-03-10
| | | | | | | | | types to size_t av_packet_add_side_data() already defines size as a size_t, so this makes it consistent across all side data functions Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/mediacodec_wrapper: use MediaCodecInfo.isSoftwareOnly() when availablesfan52021-03-10
| | | | | Added in Android 10 it provides a reliable way of filtering out software decoders, unlike existing string-based checks.
* avcodec/mediacodec_wrapper: check if codec is software earliersfan52021-03-10
|
* libavcodec/amfenc_hevc: Recommend values for min and max video quantizer scale.Ovchinnikov Dmitrii2021-03-09
| | | | | | | Current settings makes bitrate larger than expected, more information: https://github.com/HandBrake/HandBrake/issues/3447#issue-820490736 Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: Reindent after previous commitsAndreas Rheinhardt2021-03-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: Don't needlessly copy side-data for subtitlesAndreas Rheinhardt2021-03-09
| | | | | | | | AVCodecInternal.last_pkt_props is not used when decoding subtitles; ergo it makes no sense to set it at all. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: Avoid stack packets when decoding subtitlesAndreas Rheinhardt2021-03-09
| | | | | | | | | | | | | Use AVCodecInternal.buffer_pkt (previously only used in avcodec_send_packet) instead of stack packets when decoding subtitles. Also stop sharing side-data between packets and use the user-supplied packet directly for decoding when possible (no subtitle decoder ever modifies the packet it is given). Reusing AVCodecInternal.buffer_pkt is based upon an idea from James Almer. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/qsvdec: Make functions used only here static, remove headerAndreas Rheinhardt2021-03-09
| | | | | | | | | Forgotten after d78ecf10bd745cb69a71b32419e0661bfdcfb1fd. (Also mark some AVPackets as const.) Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec: Constify some AVPacketsAndreas Rheinhardt2021-03-09
| | | | | Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/dcadsp: Fix integer overflow in dmix_add_c()Michael Niedermayer2021-03-08
| | | | | | | | Fixes: signed integer overflow: 1515225320 + 759416059 cannot be represented in type 'int' Fixes: 29256/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DCA_fuzzer-5719088561258496 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/aacdec_template: Avoid undefined negation in imdct_and_windowing_eld()Michael Niedermayer2021-03-08
| | | | | | | | Fixes: negation of -2147483648 cannot be represented in type 'INTFLOAT' (aka 'int'); cast to an unsigned type to negate this value to itself Fixes: 29057/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5642758933053440 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/mpeg4videodec: add forgotten flags to mpeg4_optionsPaul B Mahol2021-03-08
|
* mobiclip: fix copyright headersFlorian Nouwt2021-03-08
| | | | | | | | The Mobiclip related code was based on Mobius (https://github.com/adibsurani/Mobius), which was based on my original reverse engineering efforts (https://github.com/Gericom/MobiclipDecoder). This commit adds the appropriate copyright headers on the related files. Signed-off-by: Florian Nouwt <fnouwt2@gmail.com>
* avcodec/ylc: Reindent after previous commitAndreas Rheinhardt2021-03-08
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/ylc: Avoid code duplication when creating and freeing VLCsAndreas Rheinhardt2021-03-08
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/ylc: Use only one temporary bufferAndreas Rheinhardt2021-03-08
| | | | | | | | | The effective lifetime of the buffer used to build the VLCs and the buffer containing the bitstream is disjoint, so that one can use a common buffer for both. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/ylc: Remove write-only variableAndreas Rheinhardt2021-03-08
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/h261dec: Remove parse_context cruftAndreas Rheinhardt2021-03-08
| | | | | | | | The H.261 decoder doesn't use the ParseContext of its MpegEncContext since e7316976650b429345da619c3acff38004aaf6b8. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavc: clarify thread_safe_callbacks doxyAnton Khirnov2021-03-08
| | | | | State explicitly when this field will be removed and how to access it in a forward compatible way.
* lscrdec: add copyright headerAnton Khirnov2021-03-08
| | | | As requested by the author.
* lavc: remove tests/optionsAnton Khirnov2021-03-08
| | | | It tests deprecated avcodec_copy_context().
* mjpegdec: handle lowres with AVID croppingAnton Khirnov2021-03-08
|
* avcodec/jpeglsenc: Allocate buffers togetherAndreas Rheinhardt2021-03-08
| | | | | | | | | Having only one allocation that is not automatically freed in particular means that one does not need to free the already allocated buffers when allocating another one fails. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>